Take the 2-minute tour ×
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.

Possible Duplicate:
Table reference
Why does an environment's label have to appear after the caption?

If you compile the LaTeX below, you get section numbers for some references instead of table numbers. This happens after the first two.

Code to reproduce:

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\begin{document}
\subsubsection{Example}
\label{sec-2-4-1}
    (see tables \ref{doc-1} and \ref{doc-2})
\begin{table}[htb]
\caption{document 1} 
\label{doc-1}
\begin{center}
\begin{tabular}{llr}
\end{tabular}
\end{center}
\end{table}
\begin{table}[htb]
\caption{document 2} 
  \label{doc-2}
\begin{center}
\begin{tabular}{llr}
\end{tabular}
\end{center}
\end{table}
    (see table \ref{doc-extracted}).
\begin{table}[htb]
  \label{doc-extracted}
\caption{extracted} 
\begin{center}
\begin{tabular}{llr}
\end{tabular}
\end{center}
\end{table}
    (see table \ref{doc-sum})
    (see table \ref{doc-avg}).
\begin{table}[htb]
  \label{doc-sum}
\caption{sum} 
\begin{center}
\begin{tabular}{lr}
\end{tabular}
\end{center}
\end{table}
\begin{table}[htb]
  \label{doc-avg}
\caption{average} 
\begin{center}
\begin{tabular}{lr}
\end{tabular}
\end{center}
\end{table}
\end{document}

Would anyone know how to fix this?

share|improve this question

marked as duplicate by lockstep, Thorsten, Gonzalo Medina, David Carlisle, Claudio Fiandrino Jul 27 '12 at 16:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Always put captions before labels. –  Ian Thompson Jul 27 '12 at 16:27
2  
Inside a float, \label must always go after \caption. –  Gonzalo Medina Jul 27 '12 at 16:28
    
Yep, that fixed it. The first one to answer gets +15 :-) –  Reactormonk Jul 27 '12 at 16:30
add comment

1 Answer 1

up vote 0 down vote accepted

Always put captions before labels.

share|improve this answer
add comment

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