A table reference is just a label plus a reference command. LaTeX does the numbering, so references stay correct when you add, remove or reorder tables.
What you’ll learn:
- Label a table
- Refer to it with
\ref - Add “Table” automatically with
\autoref - Use
\creffor lists and ranges - Fix
??and wrong numbers
Label a table with \label and \caption
Use this on every table you’ll mention in the text. The table environment numbers the table through \caption, and \label names that number.
- Wrap the
tabularin atableenvironment. - Add
\caption{…}. - Put
\label{tab:name}directly after the caption.
\begin{table}[htbp] \centering \caption{Test results by group} \label{tab:results} \begin{tabular}{|c|c|} \hline Group & Mean \\ \hline A & 4.2 \\ B & 3.9 \\ \hline \end{tabular}\end{table}Result: a numbered, captioned table that LaTeX knows as tab:results.

The tab: prefix is only a naming habit, but it keeps table, figure (fig:) and equation (eq:) labels apart. Captions above tables are the usual style; for a caption below, put \caption and \label after the tabular.
If the cells hold long text, see how to wrap long text in table cells with p{} or tabularx columns.
Refer to a table with \ref
Use this when you want plain numbers and full control of the wording. \ref prints only the number, so type “Table” yourself:
As shown in Table~\ref{tab:results}, group A scored higher.The ~ is a non-breaking space; it stops “Table” and its number from landing on different lines.

Result: “As shown in Table 1, …”, and the number updates whenever the table order changes. Compile twice to see it.

Add the word Table automatically with \autoref
Use this when you load hyperref anyway and want “Table 1” without typing “Table”. \autoref belongs to the hyperref package, so it fails with “Undefined control sequence” unless hyperref is loaded.
\usepackage{hyperref} % in the preamble, after most other packages
As detailed in \autoref{tab:results}, the results show a clear trend.
Result: “As detailed in Table 1, …”, with “Table 1” as a clickable link. The same command prints “Figure”, “Section” or “Equation” for other label types.
Refer to several tables with cleveref
Use this in longer documents. The cleveref package’s \cref works like \autoref but also handles several labels at once and is easier to customise.
Load cleveref after hyperref:
\usepackage{hyperref}\usepackage{cleveref}Use
\crefmid-sentence and\Crefat the start of one:\Cref{tab:results} summarises the scores.See \cref{tab:results,tab:second} for details.
Result: “Table 1 summarises the scores. See tables 1 and 2 for details.” cleveref groups and sorts multiple references for you.
Reference figures, equations and listings the same way
Use this for any numbered item. The pattern is always: give it a number, add \label right after the numbering command, then reference it.
| Item | Where \label goes | Reference |
|---|---|---|
| Table | After \caption in table | Table~\ref{tab:x} |
| Figure | After \caption in figure | Figure~\ref{fig:x} |
| Equation | Inside equation | Equation~\eqref{eq:x} (amsmath) |
| Section | After \section{…} | Section~\ref{sec:x} |
| Code listing | label= option of lstlisting | Listing~\ref{lst:x} |
For figures, see how to label and reference figures. Code blocks are covered in the guide to inserting code listings in LaTeX.
Which reference command should you use?
| Command | Package | Output | Handles lists of labels |
|---|---|---|---|
\ref | Built in | 1 | No |
\pageref | Built in | Page number, e.g. 4 | No |
\autoref | hyperref | Table 1 | No |
\cref / \Cref | cleveref | table 1 / Table 1 | Yes (tables 1 and 2) |
\vref | varioref | Table 1 on the next page | With cleveref |
\nameref | hyperref | The caption or heading text | No |
Overleaf’s cross-referencing guide and the cleveref package on CTAN go deeper into the options.
Common errors
??instead of a number: compile twice. If it persists, check that the label names match exactly, including case.- “Reference ‘tab:results’ on page 1 undefined” warning: same cause as
??. - The reference shows the section number:
\labelis before\caption, or outside thetable. Move it directly after\caption. - “Undefined control sequence” at
\autoref: load hyperref. - “Undefined control sequence” at
\cref: load cleveref, after hyperref. - “There were multiply-defined labels” warning: two items share a label. Rename one.
- The label is inside
tabular: it still works if the caption is above it, but put it next to\captionfor clarity.
Making references clickable
Loading hyperref turns every reference into a link. To change link colours or remove the red boxes, use \hypersetup, as explained in the guide to hyperref link colours and URLs. The hyperref package on CTAN lists every option.
If you later need to convert the finished document to Word, check the cross-references in the result; they may come through as plain text. More reference and table tutorials are in the LaTeX guides.
Word’s own numbered captions and cross-references are covered in how to insert captions in Word.