This question already has an answer here:

When writing I normally don't care if I write first the caption or the label of a figure. A friend recently told me to write always the caption first and then the label.

What reasons are to do this? Are there any advantages by writing it this way?

marked as duplicate by Werner, Maarten Dhondt, Rico, Zarko, user13907 Jan 10 '16 at 19:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Your friend is right. The \label command will store the latest updated counter, which for the figure is done by \caption. In the code below try to move the \label to before the \caption and compile twice. Then it refers to the latest updated counter, in this case the section.

\section{Test section one}
Bla bla 
\section{Test section two}
Bla bla 
  % \label{fig:one}
Bla in Fig~\ref{fig:one}.

Not the answer you're looking for? Browse other questions tagged or ask your own question.