7.1 \label

Synopsis:

\label{key}

Assign a reference number to key. In ordinary text \label{key} assigns to key the number of the current sectional unit. Inside an environment with numbering, such as a table or theorem environment, \label{key} assigns to key the number of that environment. Retrieve the assigned number with the \ref{key} command (see \ref).

A key name can consist of any sequence of letters, digits, or common punctuation characters. Upper and lowercase letters are distinguished, as usual.

A common convention is to use key’s consisting of a prefix and a suffix separated by a colon or period. For instance \label{fig:Post} for a label of a figure with a portrait of Emil Post. This helps to avoid accidentally creating two labels with the same key, and makes your source more readable. Some commonly-used prefixes:

ch

for chapters

sec
subsec

for lower-level sectioning commands

fig

for figures

tab

for tables

eq

for equations

The \label macro writes reference information into the auxiliary file, as a line like this:
\newlabel{key}{{currentlabel}{pagenumber}...}. The currentlabel is the value of the macro \@currentlabel at the time \label is processed. \@currentlabel is updated whenever you call \refstepcounter{counter} directly or indirectly (e.g., with a sectioning command such as \section, or with \caption within a figure environment).

Below, the key sec:test will get the number of the current section and the key fig:test will get the number of the figure. (Incidentally, put labels after captions in figures and tables.)

\section{section name}
\label{sec:test}
This is Section~\ref{sec:test}.
\begin{figure}
  ...
  \caption{caption text}
  \label{fig:test}
\end{figure}
See Figure~\ref{fig:test}.

Unofficial LaTeX2e reference manual