Hi all.
Does anybody know why sometimes it happens that a \ref command produces a reference to the section number even if the corresponding \label is inserted in a table or figure environment?
This happens especially when I'm using the hyperref package, but I'm not sure if there's a connection. I'm using Miktex 2.4.1461.
Thank you,
Giangiacomo
General ⇒ \ref gives section number instead of figure or table number
NEW: TikZ book now 40% off at Amazon.com for a short time.
- pumpkinegan
- Posts: 91
- Joined: Thu May 03, 2007 10:29 pm
\ref gives section number instead of figure or table number
I experienced something similar. The solution was to make sure that you put the
You have to ensure that
or
Patrick.
\label
in the right part of the environment (whether it is equation, figure, or table).You have to ensure that
\label
comes last. For example:Code: Select all
\begin{table}
\centering
\begin{tabular}
\end{tabular}
\caption{Table caption.}
\label{tab:xxxx}
\end{table}
Code: Select all
\begin{figure}
\centering
\includegraphics{}
\caption{Figure caption.}
\label{fig:xxxx}
\end{figure}
- countbela666
- Posts: 64
- Joined: Thu Apr 26, 2007 2:44 pm
\ref gives section number instead of figure or table number
As Patrick has already said it is fundamental to put your label after the caption command. This is because a label always refers to the last counter which has been changed before. If you invert the sequence of caption and label, you always refer to that point in your document where the last counter has been changed--which will mostly be the last section or chapter command--as in that case the caption command changes the counter of the figure environment you want to refer to after the label has been set.
Regards
Marcel
Regards
Marcel
Listen to me children of the night, beyond the doors of darkness you will find
a thousand worlds for you to see here, take my hand and follow me...
a thousand worlds for you to see here, take my hand and follow me...