4

Latex takes care of the number of tables by itself. Like it will automatically number the table as Table 4 etc. I want to use this number in the text.

For example, if I write "See Table 4" and later on I insert one more table above it then Table 4 becomes Table 5 but my text still says Table 4 which is inconsistent.

  • 4
    You need to insert \label{name} after the table caption and then you can refer to the table by \ref{name} in the text. LaTeX will take care of updating the number. You will need to compile the document twice to get the referencing right. – mythealias Mar 03 '13 at 19:04
  • 1
    When a structural change in the document occurs that affects the numbers of sectioning headers and floats, be sure to recompile twice so that all cross-references are fully updated. For a general discussion of LaTeX cross-referencing methods see, e.g., http://tex.stackexchange.com/a/36312/5001. – Mico Mar 03 '13 at 19:55

1 Answers1

12

I suggest to have a look at The Not So Short Introduction to LaTex2e, in particular Section 2.8, which explains cross referencing.

In short, you need to define a label for your table, and later on reference this label to have an always updated number. It looks like this:

\documentclass{article}
\begin{document}
\begin{table}
  \centering%
  \begin{tabular}{ll}
    Some & text
  \end{tabular}
  \caption{The caption of the table}\label{table:somename}
\end{table}
In text, I can reference the Table~\ref{table:somename} like this.
\end{document}

You need to run latex twice to get the reference mechanism correct.

mafp
  • 19,096