Undefined reference: autoref points to section instead of figure or table
(This answer refers to the original code in the question.)
The table reference isn't working because you are referencing tab:fig1
, while the label is named tab:tab1
.
The references are pointing to the section, because there is no caption (and hence no number) in your figure
/table
environment. Always have the \label
after \caption
.
Minimal example of using autoref for a figure:
If your autorefs are showing with questionmarks or are linking to the incorrect figures/equations, you have to flush and reset the *.aux files and recompile twice. Maybe it's a bug in how the autorefs are resolved. This code demonstrates autorefs correctly:
\documentclass{article}
\usepackage[hidelinks]{hyperref}
\usepackage{graphicx, xcolor}
\begin{document}
\section{Skipper}
Crazy woman gaining! See \autoref{fig:CrazyWomanGaining}.
\begin{figure}[ht]
\begin{minipage}{.5\textwidth}
\includegraphics[width=160pt]{crazy_woman_gaining.png}
\caption{Chantel DuBois is gaining.}
\label{fig:CrazyWomanGaining}
\end{minipage}
\end{figure}
\flushleft{Kowalski! Intel! Sir, we have a serious problem.}
\autoref{fig:OmegaThreeSlick}. Petal to the metal private!
\begin{figure}[ht]
\textcolor{black}{\fboxrule=1pt\fbox{
\begin{minipage}{.5\textwidth}
\frame{\includegraphics[width=175pt]{omega_three_slick.png}}
\caption{Our Omega 3 slick will take them down.}
\label{fig:OmegaThreeSlick}
\end{minipage}
}}
\end{figure}
We need more power! Kowalski! Fire up the Nuclear reactor!
\end{document}
After I compile this and run, I get:
Note the use of \autoref{fig:CrazyWomanGaining}
is converted to the string: "Figure 1", and \autoref{fig:OmegaThreeSlick}
is converted to the string "Figure 2".