Here is a minimum working example

(an image 'test.png' needs to be in the working directory. I used this one.)

% Created 2011-05-23 Mon 15:21

\section{figure test}
autoref test \autoref{fig:fig1}. 

ref test \ref{fig:fig1}

\caption{test figure}

\section{table test}

autoref test \autoref{tab:tab1}. 

ref test \ref{tab:tab1}

\caption{test table}
\begin{tabular}{ l c r }
  1 & 2 & 3 \\
  4 & 5 & 6 \\
  7 & 8 & 9 \\


This is a snapshot of the output that I get:

enter image description here


How can I get the references to work?

Note: In my document, I am finding that the \autoref{fig:figurename} gives output as "item 1" instead of "figure 1". When making the MWE, the problems have changed, but I am still confused.

  • If you indent lines by 4 spaces, then they are marked as a code sample. You can also highlight the code and click the "code" button (with "101010" on it).
    – Caramdir
    Commented May 26, 2011 at 19:23

2 Answers 2


(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.

  • 1
    I fixed the table reference and added a caption, but I am still getting a reference to the section. Commented May 26, 2011 at 19:20
  • 1
    @David: Your code works for me (after compiling twice).
    – Caramdir
    Commented May 26, 2011 at 19:23
  • 1
    The new code is working here too. As Caramdir said, compile it twice. Commented May 26, 2011 at 19:26
  • 1
    thanks for the help. Works after compiling twice here as well. Putting the \label after the \caption solved my problem in the actual document as well. Commented May 26, 2011 at 19:40
  • 9
    For anyone else that comes here; the label needs to come after the caption without any command between label and caption. I had an \end{center} between my caption and label, which caused this same issue.
    – erichlf
    Commented Feb 10, 2012 at 15:15

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:

\usepackage{graphicx, xcolor}

Crazy woman gaining!  See \autoref{fig:CrazyWomanGaining}.
  \caption{Chantel DuBois is gaining.}

\flushleft{Kowalski!  Intel!  Sir, we have a serious problem.}

\autoref{fig:OmegaThreeSlick}.  Petal to the metal private!

      \caption{Our Omega 3 slick will take them down.}

We need more power!  Kowalski!  Fire up the Nuclear reactor!

After I compile this and run, I get:

enter image description here

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".

  • 1
    I don't know why the minipages and the flushs and the textcolor, you will get an upvote anyway.
    – Johannes_B
    Commented Feb 19, 2017 at 16:53
  • 1
    Apart from penguins, i am not sure what quality this answer really adds.
    – Johannes_B
    Commented Feb 19, 2017 at 16:55
  • I come to stackoverflow for plug and play copy paste answers like this one. When my code doesn't work right because of bugs in \autoref, I want something plug and play that will work that I can fiddle around with. The code in the original question and the most upvoted answer doesn't have that. Commented Feb 19, 2017 at 17:00

You must log in to answer this question.

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