Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
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 May 26 '11 at 19:23

1 Answer 1

up vote 10 down vote accepted

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

share|improve this answer
I fixed the table reference and added a caption, but I am still getting a reference to the section. – David LeBauer May 26 '11 at 19:20
@David: Your code works for me (after compiling twice). – Caramdir May 26 '11 at 19:23
The new code is working here too. As Caramdir said, compile it twice. – Paulo Cereda May 26 '11 at 19:26
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. – David LeBauer May 26 '11 at 19:40
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. – lvleph Feb 10 '12 at 15:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.