1

I'm wanting to reference a figure, but I know that the usual way of doing it:

\begin{document}
\begin{figure}[h!] 
\centering
\includegraphics{image.png}\\
\label{fig:fig1}}
\end{figure}
\end{document}

then using \ref{fig:fig1} in the text only allows you to reference a figure when the reference in the text comes after the figure placement. Is there a way of doing it so that I can reference a figure earlier in the text?

2
  • Welcome to TeX.SE. Commented Apr 30, 2014 at 6:49
  • Actually, you need a \caption as well, the above won't give any figure number to reference. However, as Romain says, \ref works whether it is placed either before or after the element that is referenced. Edit: And that \\ after \includegraphics is sort of pointless. Commented Apr 30, 2014 at 7:17

2 Answers 2

1

You can do the same. You will have to compile your file two time and the reference will be good.

0

I was able to reference my figure in the text preceding my figure by placing the \label command after \caption in the figure.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .