Skip to content

Cross-references in LaTeX: \label and \ref

Put \label{key} right after the thing you want to refer to (after \section{...}, after \caption{...}, inside an equation) and write \ref{key} where you want its number; Scissor LaTeX fills in the number when it typesets.

Label, then refer

A cross-reference has two halves. \label{key} marks a numbered thing, and \ref{key} prints its number. The key is any name you choose; prefixes such as sec:, fig:, tab: and eq: are a habit that keeps keys readable, not a rule.

Referring to a section and a figure

\section{Results}
\label{sec:results}

\begin{figure}[h]
  \centering
  \begin{tikzpicture}
    \draw (0,0) -- (1,0.8) -- (2,0.3) -- (3,1.1);
  \end{tikzpicture}
  \caption{Measured values.}
  \label{fig:values}
\end{figure}

Section~\ref{sec:results} shows the values in Figure~\ref{fig:values}.
Rendered by Scissor LaTeX: Referring to a section and a figure

The ~ between the word and the reference is a space that never breaks, so "Figure" and its number stay on the same line.

Where to put the label

The label takes the number of the closest numbered thing before it:

Refer toPut \label\ref prints
A sectionright after \section{...} (or \subsection, \chapter)2, 2.1
A figure or tableafter \caption{...}, inside the float1
An equationinside equation or a numbered align1
A list itemafter \item in an enumerate2, 2b
A theoreminside theorem, lemma and similar environments1
A footnoteinside the \footnote{...} text2

Equations

\eqref{key} prints an equation number in parentheses, as equation numbers are usually shown. \ref{key} gives the bare number.

\eqref and \ref for an equation

LaTeXPreamble: \usepackage{amsmath}Open in editor (opens in a new tab)
\begin{equation}
  a^2 + b^2 = c^2
  \label{eq:pythagoras}
\end{equation}
Equation~\eqref{eq:pythagoras} is famous; its number is \ref{eq:pythagoras}.

An align or gather block gets one number in Scissor LaTeX, not one per row. Only the first \label in the block is kept, so a reference to a later row's label prints ??. See Equations, alignment and numbering for the details.

Commands that add the name: \autoref and \cref

\autoref (from hyperref) and \cref (from cleveref) print the kind of thing together with its number, so you do not have to write "Figure" yourself. \cref follows cleveref's defaults: lower case and short names ("fig.", "eq."), and \Cref at the start of a sentence gives the capitalised, full name.

\autoref, \cref and \Cref

LaTeXPreamble: \usepackage{amsmath,hyperref,cleveref}Open in editor (opens in a new tab)
\section{Method}
\label{sec:method}
\begin{equation}
  y = 44x
  \label{eq:line}
\end{equation}
\begin{table}[h]
  \centering
  \caption{Settings.}
  \label{tab:settings}
  \begin{tabular}{lr} Runs & 44 \\ \end{tabular}
\end{table}
\autoref{sec:method} uses \cref{tab:settings} and \cref{eq:line}.
\Cref{tab:settings} lists the runs.
Rendered by Scissor LaTeX: \autoref, \cref and \Cref

cleveref can also refer to several labels at once, and to a range:

Lists and ranges with \cref

LaTeXPreamble: \usepackage{amsmath,cleveref}Open in editor (opens in a new tab)
\begin{equation} a = 1 \label{eq:a} \end{equation}
\begin{equation} b = 2 \label{eq:b} \end{equation}
See \cref{eq:a,eq:b}, or \crefrange{eq:a}{eq:b}.

The package options capitalise (or capitalize), noabbrev and nameinlink are read, and so are \crefname and \Crefname in the preamble.

cleveref options and \crefname

\documentclass{article}
\usepackage{amsmath}
\usepackage[capitalise,noabbrev]{cleveref}
\crefname{table}{Tab.}{Tabs.}
\begin{document}
\begin{equation} E = mc^2 \label{eq:e} \end{equation}
\begin{table}[h]
  \centering
  \caption{Masses.}
  \label{tab:m}
  \begin{tabular}{l} 44 kg \\ \end{tabular}
\end{table}
\cref{eq:e} uses the mass in \cref{tab:m}.
\end{document}
Rendered by Scissor LaTeX: cleveref options and \crefname
CommandIn Scissor LaTeXNotes
\ref{key}WorksThe number only.
\eqref{key}WorksThe number in parentheses.
\pageref{key}WorksThe page number where the label is.
\autoref{key}Partly"Section 2", "Figure 1", "Table 1", "Theorem 1". For equations it prints the bare number, not "Equation 1".
\cref, \CrefWorksOne or several labels; cleveref's default names, or yours from \crefname.
\crefrange, \cpageref, \namecrefWorksA range, the page, or the name alone.
\nameref{key}PartlyPrints the number, not the section title.
\vref{key}PartlyPrints the number, without "on the next page".
\hyperref[key]{text}WorksPrints your text as a link to the label.

Pages and missing labels

\pageref prints the page a label is on. A reference to a label that does not exist prints a bold ??, just as LaTeX does before its second run, and the Problems tab lists every missing label once: "References to labels that do not exist (shown as ??): sec:nowhere".

\pageref and a missing label

\section{Data}
\label{sec:data}
The data is described on page~\pageref{sec:data}.
This label does not exist: Section~\ref{sec:nowhere}.

Problems tab: References to labels that do not exist (shown as ??): sec:nowhere

What differs from a TeX installation

For the packages, see cleveref and hyperref; the full manuals are on CTAN: cleveref, hyperref.

Questions and answers

Why does my reference show ?? in LaTeX?

The label does not exist, or it is spelled differently from the \ref. In Scissor LaTeX it can also mean the label is the second one in an align block, which gets only one number.

How do I reference an equation with parentheses?

Use \eqref{key} from amsmath. It prints the number in parentheses, for example (1).

What is the difference between \ref and \autoref?

\ref prints only the number. \autoref adds the kind, such as "Figure 1" or "Section 2", which saves you typing the word yourself.

Every example on this page is typeset by Scissor LaTeX when the site is built. Last updated 2026-11-06.