1

Using the package hyperref I'm noticing that I can't reference things properly. It seems that \autoref actually references the latest section, table, equation or figure (in short environment) before a label. Is this right? and what am I doing wrong?

\subsection{One one}

I want to write: `\autoref{tab:one}' shows such and such:

\begin{table}
    \caption{some bumpf}
    \label{tab:one}
\end{table}

Gives me: I want to write subsection 1.1 shows such and such.

EDIT

I have caption I forgot it in this instance. The question I'm asking is why my reference is to something that is not labelled? Eg, why do I get a reference to a subsection if the label is clearly in the figure environment or table environment? Is it really always because I may have forgotten the order of label after caption somewhere?

HCAI
  • 3,325
  • 3
    You need a caption in the table environment for the label to get a sensible value. So \caption{<text of the caption>}\label{tab:one} – egreg May 23 '13 at 21:54
  • 1
    You've gotten your answer, so for reference: http://tex.stackexchange.com/questions/111280/understanding-how-references-and-labels-work and http://tex.stackexchange.com/questions/32325/why-does-an-environments-label-have-to-appear-after-the-caption – Torbjørn T. May 23 '13 at 22:02
  • 1
    The caption didn't "warn" the label that there is a table waiting for labelling, so instead it got stuck to the last labellable thing it saw: the subsection. It is really oversimplifying, but you shouldn't think about it too much anyway: the behavior of a label before its caption is unspecified, that's all that matters. – T. Verron May 24 '13 at 06:58

1 Answers1

2

You need to add a \caption{...} before the \label:

\subsection{One one}

I want to write: `\autoref{tab:one}' shows such and such:

\begin{table}
    \caption{Some Table}
    \label{tab:one}
\end{table}

enter image description here

Herr K.
  • 17,946
  • 4
  • 61
  • 118