1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This document is an unofficial reference manual for LaTeX, a
document preparation system, version of October 2018.
This manual was originally translated from LATEX.HLP v1.0a in the
VMS Help Library. The pre-translation version was written by
George D. Greenwade of Sam Houston State University. The
LaTeX 2.09 version was written by Stephen Gilmore. The
LaTeX2e version was adapted from this by Torsten Martinsen. Karl
Berry made further updates and additions, and gratefully acknowledges
using Hypertext Help with LaTeX, by Sheldon Green, and
LaTeX Command Summary (for LaTeX 2.09) by
L. Botway and C. Biemesderfer (published by the TeX Users
Group as TeXniques number 10), as reference material. We also
gratefully acknowledge additional material appearing in
latex2e-reference by Martin Herbert Dietze. (From these references no
text was directly copied.)
Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2013,
2014, 2015, 2016, 2017, 2018 Karl Berry.
Copyright 1988, 1994, 2007 Stephen Gilmore.
Copyright 1994, 1995, 1996 Torsten Martinsen.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the entire
resulting derived work is distributed under the terms of a permission
notice identical to this one.
Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions. -->
<!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Cross references (LaTeX2e unofficial reference manual (October 2018))</title>
<meta name="description" content="Cross references (LaTeX2e unofficial reference manual (October 2018))">
<meta name="keywords" content="Cross references (LaTeX2e unofficial reference manual (October 2018))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="latex2e_0.html#Top" rel="start" title="Top">
<link href="latex2e_30.html#Index" rel="index" title="Index">
<link href="latex2e_0.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="latex2e_0.html#Top" rel="up" title="Top">
<link href="latex2e_8.html#Environments" rel="next" title="Environments">
<link href="latex2e_6.html#g_t_005c_0040startsection" rel="prev" title="\@startsection">
<style type="text/css">
<!--
body {margin: 1em; margin-top: 0px; padding-top: 1px}
a.anchor {float: right}
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body id="top" lang="en">
<a name="Cross-references" class="anchor"></a>
<a name="Cross-references-1" class="anchor"></a>
<h2 class="chapter">Cross references</h2>
<a name="index-cross-references" class="anchor"></a>
<a name="index-label" class="anchor"></a>
<p>We often want something like ‘<samp>See Theorem~31</samp>’. But by-hand typing
the 31 is poor practice. Instead you should write a <em>label</em> such as
<code>\label{eq:GreensThm}</code> and then <em>reference</em> it, as with
<code>See equation~\ref{eq:GreensThm}</code>. LaTeX will automatically
work out the number, put it into the output, and will change that number
later if needed.
</p>
<div class="example">
<pre class="example">We will see this with Theorem~\ref{th:GreensThm}. % forward reference
...
\begin{theorem} \label{th:GreensThm}
...
\end{theorem}
...
See Theorem~\ref{th:GreensThm} on page~\pageref{th:GreensThm}.
</pre></div>
<p>LaTeX tracks cross reference information in a file having the
extension <samp>.aux</samp> and with the same base name as the file containing
the <code>\label</code>. So if <code>\label</code> is in <samp>calculus.tex</samp> then
the information is in <samp>calculus.aux</samp>. LaTeX puts the
information in that file every time it runs across a <code>\label</code>.
</p>
<a name="index-forward-reference" class="anchor"></a>
<a name="index-reference_002c-forward" class="anchor"></a>
<p>The behavior described in the prior paragraph results in a quirk that
happens when your document has a <em>forward reference</em>, a <code>\ref</code>
that appears before the associated <code>\label</code>. If this is the first
time that you are compiling the document then you will get ‘<samp>LaTeX
Warning: Label(s) may have changed. Rerun to get cross references right</samp>’
and in the output the forward reference will appear as two question
marks ‘<samp>??</samp>’, in boldface. A similar thing happens if you
change some things so the references changes; you get the same warning
and the output contains the old reference information. In both cases,
resolve this by compiling the document a second time.
</p>
<a name="index-package_002c-cleveref" class="anchor"></a>
<a name="index-cleveref-package" class="anchor"></a>
<p>The <code>cleveref</code> package enhances LaTeX’s
cross referencing features. You can arrange that if you enter
<code>\begin{thm}\label{th:Nerode}...\end{thm}</code> then
<code>\cref{th:Nerode}</code> will output ‘<samp>Theorem 3.21</samp>’, without you
having to enter the “Theorem.”
</p>
<hr>
<a name="g_t_005clabel" class="anchor"></a>
<a name="g_t_005clabel-1" class="anchor"></a>
<h3 class="section"><code>\label</code></h3>
<a name="index-_005clabel" class="anchor"></a>
<p>Synopsis:
</p>
<div class="example">
<pre class="example">\label{<var>key</var>}
</pre></div>
<p>Assign a reference number to <var>key</var>. In ordinary text
<code>\label{<var>key</var>}</code> assigns to <var>key</var> the number of the
current sectional unit. Inside an environment with numbering, such as a
<code>table</code> or <code>theorem</code> environment, <code>\label{<var>key</var>}</code>
assigns to <var>key</var> the number of that environment. Retrieve the
assigned number with the <code>\ref{<var>key</var>}</code> command
(see <a href="#g_t_005cref">\ref</a>).
</p>
<p>A key name can consist of any sequence of letters, digits, or common
punctuation characters. Upper and lowercase letters are
distinguished, as usual.
</p>
<p>A common convention is to use labels consisting of a prefix and a suffix
separated by a colon or period. Thus, <code>\label{fig:Post}</code> 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:
</p>
<dl compact="compact">
<dt><code>ch</code></dt>
<dd><p>for chapters
</p>
</dd>
<dt><code>sec</code></dt>
<dt><code>subsec</code></dt>
<dd><p>for lower-level sectioning commands
</p>
</dd>
<dt><code>fig</code></dt>
<dd><p>for figures
</p>
</dd>
<dt><code>tab</code></dt>
<dd><p>for tables
</p>
</dd>
<dt><code>eq</code></dt>
<dd><p>for equations
</p></dd>
</dl>
<p>In the auxiliary file the reference information is kept as the text of
a command of the form
<code>\newlabel{<var>label</var>}{{<var>currentlabel</var>}{<var>pagenumber</var>}}</code>.
Here <var>currentlabel</var> is the current value of the macro
<code>\@currentlabel</code> that is usually updated whenever you call
<code>\refstepcounter{<var>counter</var>}</code>.
</p>
<p>Below, the key <code>sec:test</code> will get the number of the current
section and the key <code>fig:test</code> will get the number of the figure.
(Incidentally, put labels after captions in figures and tables.)
</p>
<div class="example">
<pre class="example">\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}.
</pre></div>
<hr>
<a name="g_t_005cpageref" class="anchor"></a>
<a name="g_t_005cpageref-1" class="anchor"></a>
<h3 class="section"><code>\pageref</code></h3>
<a name="index-_005cpageref" class="anchor"></a>
<a name="index-cross-referencing-with-page-number" class="anchor"></a>
<a name="index-page-number_002c-cross-referencing" class="anchor"></a>
<p>Synopsis:
</p>
<div class="example">
<pre class="example">\pageref{<var>key</var>}
</pre></div>
<p>Produce the page number of the place in the text where the corresponding
<code>\label</code>{<var>key</var>} command appears.
</p>
<p>If there is no <code>\label{<var>key</var>}</code> then you get something like
‘<samp>LaTeX Warning: Reference `th:GrensThm' on page 1 undefined on
input line 11.</samp>’
</p>
<p>Below, the <code>\label{eq:main}</code> is used both for the formula number
and for the page number. (Note that the two references are forward
references so this document would need to be compiled twice to resolve
those.)
</p>
<div class="example">
<pre class="example">The main result is formula~\ref{eq:main} on page~\pageref{eq:main}.
...
\begin{equation} \label{eq:main}
\mathbf{P}=\mathbf{NP}
\end{equation}
</pre></div>
<hr>
<a name="g_t_005cref" class="anchor"></a>
<a name="g_t_005cref-1" class="anchor"></a>
<h3 class="section"><code>\ref</code></h3>
<a name="index-_005cref" class="anchor"></a>
<a name="index-cross-referencing_002c-symbolic" class="anchor"></a>
<a name="index-section-number_002c-cross-referencing" class="anchor"></a>
<a name="index-equation-number_002c-cross-referencing" class="anchor"></a>
<a name="index-figure-number_002c-cross-referencing" class="anchor"></a>
<a name="index-footnote-number_002c-cross-referencing" class="anchor"></a>
<p>Synopsis:
</p>
<div class="example">
<pre class="example">\ref{<var>key</var>}
</pre></div>
<p>Produces the number of the sectional unit,
equation, footnote, figure, …, of the corresponding
<code>\label</code> command (see <a href="#g_t_005clabel">\label</a>). It does not produce any text,
such as the word ‘Section’ or ‘Figure’, just the bare number itself.
</p>
<p>If there is no <code>\label{<var>key</var>}</code> then you get something like
‘<samp>LaTeX Warning: Reference `th:GrensThm' on page 1 undefined on
input line 11.</samp>’
</p>
<p>In this example the <code>\ref{popular}</code> produces ‘<samp>2</samp>’. Note that
it is a forward reference since it comes before <code>\label{popular}</code>
so this document would have to be compiled twice.
</p>
<div class="example">
<pre class="example">The most widely-used format is item number~\ref{popular}.
\begin{enumerate}
\item Plain \TeX
\item \label{popular} \LaTeX
\item Con\TeX t
\end{enumerate}
</pre></div>
<a name="index-package_002c-cleveref-1" class="anchor"></a>
<a name="index-cleveref-package-1" class="anchor"></a>
<p>The <samp>cleveref</samp> package includes text such as ‘<samp>Theorem</samp>’ in the
reference. See the documentation on CTAN.
</p>
</body>
</html>
|