Posts Tagged ‘LaTeX figures with section names as labels’

For LaTeX referencing glitches, check the \label location

December 15th, 2010

Problem: LaTeX gives the section number instead of the figure number in a text reference.
Solution: Be sure that the figure’s label is AFTER its caption.

Correct:

\begin{figure}
\includegraphics{./images/myimage.png}
\caption{A beautiful, wonderful image.}
\label{fig:myimage}
\end{figure}

Wrong:

\begin{figure}
\includegraphics{./images/myimage.png}
\label{fig:myimage}
\caption{A beautiful, wonderful image.}
\end{figure}

LaTeX requires \label to follow \caption. That is, a \label preceding a \caption is ignored.
If you’re getting section numbers instead of figure numbers as the response to a \ref, check where the \label is specified.

Tags: , , , , , , , , ,
Posted in PhD diary, random thoughts | Comments (0)