I want to refer to a figure within a section (say 1.2), using \ref{fig:xyz}

Section:

\section{XYZ}


Figure:

\begin{figure}
\includegraphics[width=1\linewidth]{xyz.jpg}
\label{fig:xyz}
\caption[XYZ]
\end{figure}


When I add \ref{label:001} to my document, it does not link to the figure, but to the section (1.2).

What can I get it right?

• The most F asked question of all. \label has to be after (or in) \caption – David Carlisle May 31 '13 at 13:27
• @DavidCarlisle I could not find it here, that's why I added it. – mcbetz May 31 '13 at 13:28
• @DavidCarlisle Yes, that is a possible duplicate. However, I could not find it using the keywords that were relevant for me, ref, label and section. Maybe my question is a good addition, maybe not. – mcbetz May 31 '13 at 13:30
• @PaulStanley Totally understand that! Let's see what the others think. I was just thinking about how I could do it differently next time. Probably have to extend my search and specificly look for possible duplicates... – mcbetz May 31 '13 at 13:40
• Another really helpful duplicate is: Understanding how references and labels work – Alan Munn May 31 '13 at 16:06

You have to put \label after \caption - and everything will work.
Thus, your figure will now be: