A large document uses \ref and \autoref to link to figures. For most of the document it works fine, but in some sections, it gives links to figures with the wrong numbers. Although the Figure appears to be correctly numbered (in this case as Fig. 10.3), the \ref command calls it 10.1.2 instead. Here is the code:
...blah.blah.blah of the full survey predicts $\sim200-1000$ quasars at
$6.5<z<7.5$ (\autoref{fig:z7:quasars}); such quasars should be...
\begin{figure}
\label{fig:z7:quasars}
\begin{center}
\includegraphics[angle=0,scale=0.5]{agn/agn_census_z7_quasars.pdf}
\caption{{\it Left:} $z-y$ vs. $y$ color-magnitude diagram
\end{center}
\end{figure}
Any ideas under what conditions it can mess up in this way?
Graphics, Figures & Tables ⇒ \ref and \autoref numbering figures like subsections
NEW: TikZ book now 40% off at Amazon.com for a short time.

- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
\ref and \autoref numbering figures like subsections
Hi sivertz,
welcome to the board!
Use \label right after the \caption command, not before, see \label description.
Btw. inside figure environments I recommend to use \centering instead of \begin{center} ... \end{center}, see center vs. \centering. Further placement parameters for \begin{figure} like [htbp] could be useful.
Stefan
welcome to the board!
Use \label right after the \caption command, not before, see \label description.
Btw. inside figure environments I recommend to use \centering instead of \begin{center} ... \end{center}, see center vs. \centering. Further placement parameters for \begin{figure} like [htbp] could be useful.
Stefan
LaTeX.org admin
Re: \ref and \autoref numbering figures like subsections
Thanks, Stefan_K. Moving the \label after the \caption did not solve the numbering problem. But the caption is very long. Could that be part of the problem?
Also, is there an \endcentering command? How does LaTeX know the scope
of \centering?
Also, is there an \endcentering command? How does LaTeX know the scope
of \centering?
- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
\ref and \autoref numbering figures like subsections
Did you compile two times to check that?sivertz wrote:Moving the \label after the \caption did not solve the numbering problem.
The scope is limited by the surrounding environment. That's why \end{figure} will end the effect of \centering. It's also possible to limit the scope by braces, likesivertz wrote:Also, is there an \endcentering command? How does LaTeX know the scope of \centering?
Code: Select all
{\centering ... your text ... }
Stefan
LaTeX.org admin