2

I found that if I don't place \label in a \begin{figure}...\end{figure} correctly, it will generate a ?? when I \autoref it.

Where is the appropriate position?

\begin{figure}
\label{}
\includegraphics{}
\caption{}
\end{figure}

or

\begin{figure}
\includegraphics{}
\label{}
\caption{}
\end{figure}

or

\begin{figure}
\includegraphics{}
\caption{}
\label{}
\end{figure}
Mico
  • 506,678
Norman
  • 527
  • 3
  • 13
  • 4
    LaTeX tries to associate the argument of \label with the most recently incremented counter variable -- here: the figure counter. The figure counter gets incremented by the \caption directive. Hence, the only possible correct answer in your list is #3. – Mico Feb 23 '21 at 07:26
  • 3
    A fourth (working) variant is \caption{text\label{label}}. – Ulrike Fischer Feb 23 '21 at 07:48
  • @UlrikeFischer Wow this could be very clean – Norman Feb 23 '21 at 07:48
  • @UlrikeFischer Unfortunately TexStudio produces a ugly green squiggly line used to show potential syntax error (despite no error). I guess your solution is too advanced haha. – Norman Feb 23 '21 at 07:57
  • 2
    but it is better, a \label behind a caption can affect spacing in some cases. – Ulrike Fischer Feb 23 '21 at 08:12

0 Answers0