Document ClassesProblem with custom Package File

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
lavanya
Posts: 3
Joined: Fri May 04, 2012 1:13 pm

Problem with custom Package File

Post by lavanya »

I am using the style file »enghb2e« style to prepare a manuscript. However, the cross referencing for the figures are wrong. For example, Figure 1.1 when referenced using \ref gives Figure 1.1.1, which is not wanted.

How do I correct this? Please find attached the style file for immediate reference.

Can anyone help me with the same?
Attachments
enghb2e.sty
(44.75 KiB) Downloaded 497 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

alainremillard
Posts: 45
Joined: Fri Mar 16, 2012 8:22 pm

Problem with custom Package File

Post by alainremillard »

When labeling a figure, you have to put the label AFTER the caption. If you put it before, latex refere to the section it is in.

If this doesn't solve your problem, please post a Infominimal working example. This way we might be able to better comprehend the problem

regards
Alain Rémillard
lavanya
Posts: 3
Joined: Fri May 04, 2012 1:13 pm

Problem with custom Package File

Post by lavanya »

This doesn't help as the problem is somewhere in the style file. As there is no proper redirection to the aux file with respect to the label, that I've used. For example, see the following code.

Code: Select all

\begin{figure}[ht!]
\centering
\includegraphics{Figure5.eps}
   \caption{A graphical representation of a permutation $p = (1~3~2~4)(5~7~6)(8) (9~10)$.}
 \label{Cyclegraph}
\end{figure}
In the corresponding aux file, the data is stored as follows.

Code: Select all

\@writefile{lof}{\contentsline {figure}{\numberline {1.1}{A graphical representation of a permutation $p = (1\nobreakspace  {}3\nobreakspace  {}2\nobreakspace  {}4)(5\nobreakspace  {}7\nobreakspace  {}6)(8) (9\nobreakspace  {}10)$.}}{{\FolioBoldFont 1}-{\FolioFont 5}}}
\newlabel{Cyclegraph}{{1.1.1}{{\FolioBoldFont 1}-{\FolioFont 5}}}
In addition, I also noticed that all the figures take the same label (1.1.1).
But actually the figure captions are properly numbered as "Figure 1.1 " , "Figure 1.2" ... When referenced, they all give the same "1.1.1" .
lavanya
Posts: 3
Joined: Fri May 04, 2012 1:13 pm

Problem with custom Package File

Post by lavanya »

Problem Solved.

This is for others who come up with similar queries, I would like to post the solution for the above mentioned problem.

When one uses the label for the figure to cross reference it later, you can also use the \label inside the \caption environment.

For example,

Code: Select all

\begin{figure}[ht!]
\centering
\includegraphics{Figure5.eps}
\caption{A graphical representation of a permutation $p = (1~3~2~4)(5~7~6)(8) (9~10)$. \label{Cyclegraph} }
\end{figure}
When we use it as above the mentioned problem doesn't arise. That is everything works perfectly...
Last edited by Stefan Kottwitz on Mon May 07, 2012 5:48 pm, edited 1 time in total.
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Problem with custom Package File

Post by sommerfee »

lavanya wrote:When we use it as above the mentioned problem doesn't arise.
\label always has to be put into the same (TeX) group as the \refstepcounter macro incrementing the counter. Usually \caption uses \refstepcounter inside the same group, so \label after \caption works fine. But the (quite unusual) redefinition of \caption done in enghb2e.sty uses \refstepcounter inside an own group; for that reason only \label inside \caption works correct here since it's the only way getting the \label done inside the same group as \refstepcounter.
Post Reply