If you’ve written up a LaTeX document and find that some of the figures, tables, algorithms, etc. are being referenced wrong (such as Figure 2.4 being referenced as figure 6), chances are you’ve put your caption and \label tags in the wrong order. LaTeX needs \label to be after \caption, or for \label to be in the \caption definition. They also need to be in the same environment.

For example,

\begin{center}
\caption{...}
\label{...}
\end{center}

will work, as will

\begin{center}
\caption{...label{...}}
\end{center}

but

\begin{center}
\label{...}
\caption{...}
\end{center}

won’t, and neither will

\begin{center}
\caption{...}
\end{center}
\label{...}

It’s confusing, but it’s LaTeX.

  1. monday says:

    thanks a lot for this little post. it really saved lot of time 🙂