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?
\labelmust always go after\caption. – Gonzalo Medina Jul 27 '12 at 16:28