\ref{}
produces a section number instead of the number of a labeled figure/table. In nearly all cases, the issue is that \label{}
is placed before \caption{}
. However, in the example below (see "this should show figure 2"), I have placed the label just before \end{figure}
but nevertheless the section number is referenced. Can someone explain what is wrong?Code: Select all
\documentclass[crop=false]{standalone}
\usepackage{graphicx}
\usepackage{hyperref}
\newenvironment{fignote}{\begin{quote}\footnotesize}{\end{quote}}
\title{Working Example}
\begin{document}
\ifstandalone
\maketitle
\fi
\section{Foo}
This should show ``Figure 1'': \autoref{fig:fig_1}
\begin{figure}[h!]
\centering
\textbf{\caption{Title of Fig 1}}
\includegraphics[width=0.98\linewidth]{ente.png}
\label{fig:fig_1}
\end{figure}
This should show ``Figure 2'': \autoref{fig:fig_2}
\begin{figure}
\centering
\textbf{\caption{Title of Fig 2}}
\includegraphics[width=\linewidth]{ente.png}
\begin{fignote}
Note: Here is a ton of text usually.
\end{fignote}
\label{fig:fig_2}
\end{figure}
\end{document}