\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 labels consisting of a prefix and a suffix
separated by a colon or period. Thus, \label{fig:Post}
is a
label for a figure with a portrait of Emil Post. This helps to avoid
accidentally creating two labels with the same name, 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
In the auxiliary file the reference information is kept as the text of
a command of the form
\newlabel{label}{{currentlabel}{pagenumber}}
.
Here currentlabel is the current value of the macro
\@currentlabel
that is usually updated whenever you call
\refstepcounter{counter}
.
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}.