# What should be the relative positioning between label and caption in a figure? [duplicate]

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

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.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\section{Test section one}
Bla bla
\section{Test section two}
Bla bla
\begin{figure}[htb]
\centering
\tikz\draw(0,0)rectangle(5,3);
% \label{fig:one}
\caption{Test}
\label{fig:one}
\end{figure}
Bla in Fig~\ref{fig:one}.
\end{document}