Debian Codegraph @

texmf-dist/doc/latex/theoremref/theoremref-doc.tex

raw
1 \documentclass[pagesize=auto]{scrartcl}
2
3 % Many thanks to whoever generated this documentation file. --E.J.
4
5 \usepackage{fixltx2e}
6 \usepackage{etex}
7 \usepackage{lmodern}
8 \usepackage[T1]{fontenc}
9 \usepackage{textcomp}
10 \usepackage[utf8]{inputenc}
11 \usepackage{microtype}
12 \usepackage{hyperref}
13
14 \newcommand*{\mail}[1]{\href{mailto:#1}{\texttt{#1}}}
15 \newcommand*{\pkg}[1]{\textsf{#1}}
16 \newcommand*{\cs}[1]{\texttt{\textbackslash#1}}
17 \makeatletter
18 \newcommand*{\cmd}[1]{\cs{\expandafter\@gobble\string#1}}
19 \makeatother
20 \newcommand*{\meta}[1]{\textlangle\textsl{#1}\textrangle}
21 \newcommand*{\marg}[1]{\texttt{\{}\meta{#1}\texttt{\}}}
22
23 \addtokomafont{title}{\rmfamily}
24
25 \title{The \pkg{theoremref} package}
26 \author{Emil Jeřábek\thanks{\mail{[email protected]} (replace \texttt{spam} with \texttt{cas})}}
27 \date{2013/05/22}
28
29
30 \begin{document}
31
32 \maketitle
33
34
35 \section{Introduction}
36
37 So, you are writting up your math paper or thesis. There is the
38 all-important Lemma~3.14 referenced from a dozen places throughout
39 the paper, but you have just realized that its proof requires another
40 lemma which should go before Lemma~3.14, hence all the references to
41 Lemma~3.14 have to shift to Lemma~3.15. Now that's quite simple to do:
42 you just insert the new lemma, and \LaTeX\ relabels the references for you
43 behind the scenes. Good.
44
45 Then you decide that Lemma~3.15 is, in fact, so important that you
46 better call it a Theorem rather than just a Lemma, hence all the
47 references to Lemma~3.15 should change to Theorem 3.15. Now that's
48 quite simple to do: you just replace the name of the theorem
49 environment of~3.15, and \LaTeX\ relabels the references for you behind
50 the scenes\dots\ uhhh, except that it does not, actually. You have to go
51 through the paper and manually change every occurrence of
52 \verb|Lemma~\ref{main}| to \verb|Theorem~\ref{main}|. Your editor software may
53 help with automatic text replacement, but that's no good by itself,
54 you unfortunately still have to watch out for cases like
55 \verb|Lemmas \ref{baz-quux} and~\ref{main}|. Needless to say, the whole business
56 is rather error-prone, and very annoying, especially if you later
57 decide that 3.15 is, after all, a Lemma, with the prospect of changing
58 all those references back again.
59
60 The \pkg{theoremref} package is designed to fill this gap in the \LaTeX\ %
61 automatic reference system. It provides variants of the \cmd{\label} and
62 \cmd{\ref} commands which automatically supply the correct theorem
63 environment name into a reference, thus avoiding all the hassle
64 described above.
65
66
67 \section{Basic usage}
68
69 \renewcommand*{\labelenumi}{(\theenumi)}
70 \begin{enumerate}
71 \item Put \verb|\usepackage{theoremref}| anywhere in the document preamble.
72 \pagebreak[2]
73
74 \item For each theorem which you intend to use in the new system, declare
75 its label by \cmd{\thlabel}\marg{foobar}. For example,
76 %
77 \begin{verbatim}
78 \begin{Lem}\thlabel{exact}
79 Every projective formula is exact.
80 \end{Lem}
81 \end{verbatim}
82
83 \item There are three commands available for producing references to
84 your theorems: \cmd{\ref}\marg{foo} gives the number, as usual;
85 \cmd{\thref}\marg{foo} gives the theorem name followed by number; and
86 \cmd{\thnameref}\marg{foo} gives just the theorem name. Example:
87
88 \begin{tabular}{l@{ $\to$ }l@{}}
89 \verb|\ref{exact}| & \verb|5.7.7| \\
90 \verb|\thref{exact}| & \verb|Lemma~5.7.7| \\
91 \verb|\thnameref{exact}| & \verb|Lemma|
92 \end{tabular}
93
94 The \cmd{\thref} command can handle an arbitrary number of arguments,
95 separated by commas:
96
97 \begin{tabular}{l@{ $\to$ }l@{}}
98 \verb|\thref{exact,zorn,main}| & \verb|Lemmas 5.7.7 and~2.1.5 and Theorem~6.6.4|
99 \end{tabular}
100 \end{enumerate}
101
102
103 \section{Options}
104
105 \begin{itemize}
106 \item \verb|\usepackage[lowercase]{theoremref}| will set your theorem
107 references in lowercase, e.\,g., ``lemma 5.7.7''. Note that there is
108 no provision for capitalization at the beginning of a sentence.
109
110 \item \sloppy \verb|\usepackage[reftex]{theoremref}| provides an alternative
111 interface to the main commands: you can say \cmd{\th}\cmd{\label}\marg{foo} and
112 \cmd{\th}\cmd{\ref}\marg{foo} instead of \cmd{\thlabel}\marg{foo} and \cmd{\thref}\marg{foo}.
113 The effect is that the labelling and referencing commands are
114 correctly recognized as such by the Emacs reftex package (and,
115 presumably, other similar editing tools).
116 \end{itemize}
117
118 \fussy
119
120
121 \section{Caveats}
122
123 \begin{itemize}
124 \item The \cmd{\thlabel} command reuses the slot for page number in the \texttt{.aux}
125 file. This should do no harm, as the latter is generally useless, I've
126 never seen anybody refer to a numbered theorem by its page number. But
127 to be on the safe side, here's an explicit warning: if you declare \meta{foo}
128 by \cmd{\thlabel}\marg{foo}, you cannot use \cmd{\pageref}\marg{foo} to get its page
129 number (it will actually give the theorem name). If you absolutely
130 need both, you can declare two labels for the same theorem:
131 \cmd{\label}\marg{foo-page}\cmd{\thlabel}\marg{foo-name}.
132
133 \item If \cmd{\thref}\marg{bar} gives you a cryptic result like ``12 3.15''
134 instead of the theorem name, you probably forgot to use \cmd{\thlabel}
135 instead of \cmd{\label} (see the previous point for explanation). Note
136 that after you switch from one to the other, you may need to \TeX\ the
137 file twice in order for the change to propagate to the \texttt{.aux} file and
138 back.
139
140 \item The new referencing commands only work for theorem environments
141 declared using the \cmd{\newtheorem} command. You \emph{cannot} use them for
142 e.\,g.\ tables, figures, equations, sections, and other environments.
143
144 \item The implementation depends on some internals of the theorem
145 typesetting macros. It is compatible with the \pkg{theorem} and
146 \pkg{amsthm} packages, as well as the default theorem system in base
147 \LaTeX. It may fail for other theorem-like packages.
148
149 The package is compatible with \pkg{hyperref}, but not with other
150 packages that change the syntax of \cmd{\newlabel} commands written
151 to the \texttt{.aux} file.
152 \end{itemize}
153
154 \section{History}
155
156 \begin{itemize}
157 \item 2008-05-13: Initial public release.
158 \item 2013-05-22: Added support for hyperref.
159 \end{itemize}
160
161 \section{License}
162
163 The \pkg{theoremref} package is dually licensed under GPL or LPPL at your
164 option:
165
166 Copyright © 2008, 2013 Emil Jeřábek
167
168 This package may be distributed and/or modified under the
169 conditions of the \LaTeX\ Project Public License, either version 1.3
170 of this license or (at your option) any later version.
171 The latest version of this license is in
172 \url{http://www.latex-project.org/lppl.txt}
173 and version~1.3 or later is part of all distributions of \LaTeX\ %
174 version~2003/12/01 or later.
175
176 This package is free software; you can redistribute it and/or modify
177 it under the terms of the GNU General Public License as published by
178 the Free Software Foundation; either version~2 of the License, or
179 (at your option) any later version.
180
181 This package is distributed in the hope that it will be useful,
182 but WITHOUT ANY WARRANTY; without even the implied warranty of
183 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
184 GNU General Public License for more details.
185
186 You should have received a copy of the GNU General Public License
187 along with this program; if not, write to the Free Software
188 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
189
190 \end{document}