Debian Codegraph @

texmf-dist/source/latex/base/ltthm.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 1993-2025
4 % The LaTeX Project and any individual authors listed elsewhere
5 % in this file.
6 %
7 % This file is part of the LaTeX base system.
8 % -------------------------------------------
9 %
10 % It may be distributed and/or modified under the
11 % conditions of the LaTeX Project Public License, either version 1.3c
12 % of this license or (at your option) any later version.
13 % The latest version of this license is in
14 % https://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of LaTeX
16 % version 2008 or later.
17 %
18 % This file has the LPPL maintenance status "maintained".
19 %
20 % The list of all files belonging to the LaTeX base distribution is
21 % given in the file `manifest.txt'. See also `legal.txt' for additional
22 % information.
23 %
24 % The list of derived (unpacked) files belonging to the distribution
25 % and covered by LPPL is defined by the unpacking scripts (with
26 % extension .ins) which are part of the distribution.
27 %
28 % \fi
29 %
30 % \iffalse
31 %%% From File: ltthm.dtx
32 %<*driver>
33 % \fi
34 \ProvidesFile{ltthm.dtx}
35 [2024/03/18 v1.0g LaTeX Kernel (Theorems)]
36 % \iffalse
37 \documentclass{ltxdoc}
38 \GetFileInfo{ltthm.dtx}
39 \title{\filename}
40 \date{\filedate}
41 \author{%
42 Johannes Braams\and
43 David Carlisle\and
44 Alan Jeffrey\and
45 Leslie Lamport\and
46 Frank Mittelbach\and
47 Chris Rowley\and
48 Rainer Sch\"opf}
49
50 \begin{document}
51 \MaintainedByLaTeXTeam{latex}
52 \maketitle
53 \DocInput{\filename}
54 \end{document}
55 %</driver>
56 % \fi
57 %
58 %
59 % \section{Theorem Environments}
60 %
61 %
62 % The user creates his own theorem-like environments with the command\\
63 % |\newtheorem|\marg{name}\marg{text}\oarg{counter} or\\
64 % |\newtheorem|\marg{name}\oarg{oldname}\marg{text}\\
65 % This defines the environment \meta{name} to be just as one would
66 % expect a theorem environment to be, except that it prints \meta{text}
67 % instead of ``Theorem''.
68 %
69 % If \meta{oldname} is given, then environments \meta{name} and
70 % \meta{oldname} use the same counter, so using a \meta{name}
71 % environment advances the number of the next \meta{name} environment,
72 % and vice-versa.
73 %
74 % If \meta{counter} is given, then environment \meta{name} is numbered
75 % within \meta{counter}.
76 %
77 % E.g., if \meta{counter} = |subsection|, then the first \meta{name} in
78 % subsection 7.2 is numbered \meta{text} 7.2.1.
79 %
80 % The way \meta{name} environments are numbered can be changed by
81 % redefining |\the|\meta{name}.
82 %
83 % \MaybeStop{}
84 %
85 %
86 % \changes{v1.0a}{1994/03/28}{Initial version, split from latex.dtx}
87 % \changes{v1.0c}{1994/05/25}{Modify documentation}
88 % \changes{v1.0f}{1995/10/10}{Make \cs{newtheorem} `only preamble'}
89 % \changes{v1.0g}{1995/10/16}
90 % {Revert to previous \cs{newtheorem} behaviour}
91 %
92 % \begin{oldcomments}
93 %
94 % DOCUMENT STYLE PARAMETERS
95 %
96 % \@thmcounter{COUNTER} : A command such that
97 % \edef\theCOUNTER{\@thmcounter{COUNTER}}
98 % defines \theCOUNTER to produce a number for a theorem environment.
99 % The default is:
100 % BEGIN \noexpand\arabic{COUNTER} END
101 %
102 % \@thmcountersep : A separator placed between a theorem number and
103 % the number of the counter within which it is numbered.
104 % E.g., to make the third theorem of section 7.2 be numbered
105 % 7.2-3, \@thmcountersep should be \def'ed to '-'. Its
106 % default is '.'.
107 %
108 % \@begintheorem{NAME}{NUMBER} : A command that begins a theorem
109 % environment for a 'theorem' named 'NAME NUMBER' --
110 % e.g., \@begintheorem{Lemma}{3.7} starts Lemma 3.7.
111 %
112 % \@opargbegintheorem{NAME}{NUMBER}{OPARG} :
113 % A command that begins a theorem
114 % environment for a 'theorem' named 'NAME NUMBER' with optional
115 % argument OPARG -- e.g., \@begintheorem{Lemma}{3.7}{Jones}
116 % starts `Lemma 3.7 (Jones):'.
117 %
118 % \@endtheorem : A command that ends a theorem environment.
119 %
120 % \newtheorem{NAME}{TEXT}[COUNTER] ==
121 % BEGIN
122 % if \NAME is definable
123 % then \@definecounter{NAME}
124 % if COUNTER present
125 % then \@newctr{NAME}[COUNTER] fi
126 % \theNAME == BEGIN \theCOUNTER \@thmcountersep
127 % eval\@thmcounter{NAME} END
128 % else \theNAME == BEGIN eval\@thmcounter{NAME} END
129 % \NAME == \@thm{NAME}{TEXT}
130 % \endNAME == \@endtheorem
131 % else error
132 % fi
133 % END
134 %
135 % \newtheorem{NAME}[OLDNAME]{TEXT}==
136 % BEGIN
137 % if counter OLDNAME nonexistent
138 % then ERROR
139 % else
140 % if \NAME is definable
141 % then BEGIN
142 % \theNAME == \theOLDNAME
143 % \NAME == \@thm{OLDNAME}{TEXT}
144 % \endNAME == \@endtheorem
145 % END
146 % else error
147 % fi
148 % fi
149 % END
150 %
151 % \@thm{NAME}{TEXT} ==
152 % BEGIN
153 % \refstepcounter{NAME}
154 % if next char = [
155 % then \@ythm{NAME}{TEXT}
156 % else \@xthm{NAME}{TEXT}
157 % fi
158 % END
159 %
160 % \@xthm{NAME}{TEXT} ==
161 % BEGIN
162 % \@begintheorem{TEXT}{\theNAME}
163 % \ignorespaces
164 % END
165 %
166 % \@ythm{NAME}{TEXT}[OPARG] ==
167 % BEGIN
168 % \@opargbegintheorem{TEXT}{\theNAME}{OPARG}
169 % \ignorespaces
170 % END
171 % \end{oldcomments}
172 %
173 % \begin{macro}{\newtheorem}
174 % |\newtheorem| ought really be allowed only in the preamble
175 % Which would be good document style, and allow some main memory to be
176 % saved by declaring these commands to be
177 % |\@onlypreamble|. Unfortunately the \LaTeX\ book indicates that
178 % |\newtheorem| may be used anywhere in the document\ldots
179 % \begin{macrocode}
180 %<*2ekernel>
181 \def\newtheorem#1{%
182 \@ifnextchar[{\@othm{#1}}{\@nthm{#1}}}
183 % \end{macrocode}
184 % \end{macro}
185 %
186 % \begin{macro}{\@nthm}
187 % \begin{macrocode}
188 \def\@nthm#1#2{%
189 \@ifnextchar[{\@xnthm{#1}{#2}}{\@ynthm{#1}{#2}}}
190 % \end{macrocode}
191 % \end{macro}
192 %
193 % \begin{macro}{\@xnthm}
194 %
195 % 92/09/18 RmS: Changed |\@addtoreset| to |\@newctr| to produce error
196 % message if counter |#3| does not exist (to be
197 % consistent with behaviour of |\newcounter|)
198 % \begin{macrocode}
199 \def\@xnthm#1#2[#3]{%
200 \expandafter\@ifdefinable\csname #1\endcsname
201 {\@definecounter{#1}\@newctr{#1}[#3]%
202 \expandafter\xdef\csname the#1\endcsname{%
203 \expandafter\noexpand\csname the#3\endcsname \@thmcountersep
204 \@thmcounter{#1}}%
205 \global\@namedef{#1}{\@thm{#1}{#2}}%
206 \global\@namedef{end#1}{\@endtheorem}}}
207 % \end{macrocode}
208 % \end{macro}
209 %
210 % \begin{macro}{\@ynthm}
211 % \begin{macrocode}
212 \def\@ynthm#1#2{%
213 \expandafter\@ifdefinable\csname #1\endcsname
214 {\@definecounter{#1}%
215 \expandafter\xdef\csname the#1\endcsname{\@thmcounter{#1}}%
216 \global\@namedef{#1}{\@thm{#1}{#2}}%
217 \global\@namedef{end#1}{\@endtheorem}}}
218 % \end{macrocode}
219 % \end{macro}
220 %
221 % \begin{macro}{\@othm}
222 % \changes{LaTeX2.09}{1992/01/10}
223 % {(RmS) Check for existence of theorem environment}
224 % \changes{LaTeX2.09}{1992/08/19}
225 % {(RmS) Changed error message to complain about undefined
226 % counter}
227 % \changes{v1.0b}{1994/04/09}{Use standard counter error message (FMi)}
228 % \changes{v1.0c}{1994/04/17}{Use new std counter error message (FMi)}
229 % \begin{macrocode}
230 \def\@othm#1[#2]#3{%
231 \@ifundefined{c@#2}{\@nocounterr{#2}}%
232 {\expandafter\@ifdefinable\csname #1\endcsname
233 {\global\@namedef{the#1}{\@nameuse{the#2}}%
234 \global\@namedef{#1}{\@thm{#2}{#3}}%
235 \global\@namedef{end#1}{\@endtheorem}}}}
236 % \end{macrocode}
237 % \end{macro}
238 %
239 % \begin{macro}{\@thm}
240 % \changes{v1.0c}{1994/04/17}{Use new std counter error message (FMi)}
241 % \changes{v1.0g}{2024/03/18}{Use \cs{@kernel@refstepcounter} to avoid an unwanted target (UFi)}
242 % \begin{macrocode}
243 %</2ekernel>
244 %<*2ekernel|latexrelease>
245 %<latexrelease>\IncludeInRelease{2024/03/18}%
246 %<latexrelease> {\@thm}{no link target}%
247 \def\@thm#1#2{%
248 \@kernel@refstepcounter{#1}%
249 \@ifnextchar[{\@ythm{#1}{#2}}{\@xthm{#1}{#2}}}
250 %<latexrelease>\EndIncludeInRelease
251 %<latexrelease>\IncludeInRelease{0000/00/00}%
252 %<latexrelease> {\@thm}{no link target}%
253 %<latexrelease>\def\@thm#1#2{%
254 %<latexrelease> \refstepcounter{#1}%
255 %<latexrelease> \@ifnextchar[{\@ythm{#1}{#2}}{\@xthm{#1}{#2}}}
256 %<latexrelease>\EndIncludeInRelease
257 %</2ekernel|latexrelease>
258 % \end{macrocode}
259 % \end{macro}
260 %
261 % \begin{macro}{\@xthm}
262 % \begin{macro}{\@ythm}
263 % \begin{macrocode}
264 %<*2ekernel>
265 \def\@xthm#1#2{%
266 \@begintheorem{#2}{\csname the#1\endcsname}\ignorespaces}
267 \def\@ythm#1#2[#3]{%
268 \@opargbegintheorem{#2}{\csname the#1\endcsname}{#3}\ignorespaces}
269 % \end{macrocode}
270 % \end{macro}
271 % \end{macro}
272 %
273 % Default values
274 % \begin{macro}{\@thmcounter}
275 % \begin{macro}{\@thmcountersep}
276 % \begin{macrocode}
277 \def\@thmcounter#1{\noexpand\arabic{#1}}
278 \def\@thmcountersep{.}
279 % \end{macrocode}
280 % \end{macro}
281 % \end{macro}
282 %
283 % \begin{macro}{\@begintheorem}
284 % \begin{macro}{\@opargbegintheorem}
285 % \begin{macro}{\@endtheorem}
286 % \changes{LaTeX2.09}{1991/08/14}
287 % {Moved \cs{itshape} after \cs{item} to make it work with
288 % NFSS}
289 % Providing theorem defaults.
290 % \task{???}{add `reset@font?}
291 % % \changes{v1.0g}{2024/03/18}{Insert link target in the label (UFi)}
292 % \begin{macrocode}
293 %</2ekernel>
294 %<*2ekernel|latexrelease>
295 %<latexrelease>\IncludeInRelease{2024/03/18}%
296 %<latexrelease> {\@begintheorem}{add link targets}%
297 \def\@begintheorem#1#2{\trivlist
298 \item[\MakeLinkTarget{\@currentcounter}\hskip \labelsep{\bfseries #1\ #2}]\itshape}
299 \def\@opargbegintheorem#1#2#3{\trivlist
300 \item[\MakeLinkTarget{\@currentcounter}\hskip \labelsep{\bfseries #1\ #2\ (#3)}]\itshape}
301 %<latexrelease>\EndIncludeInRelease
302 %<latexrelease>\IncludeInRelease{0000/00/00}%
303 %<latexrelease> {\@begintheorem}{add link targets}%
304 %<latexrelease>\def\@begintheorem#1#2{\trivlist
305 %<latexrelease> \item[\hskip \labelsep{\bfseries #1\ #2}]\itshape}
306 %<latexrelease>\def\@opargbegintheorem#1#2#3{\trivlist
307 %<latexrelease> \item[\hskip \labelsep{\bfseries #1\ #2\ (#3)}]\itshape}
308 %<latexrelease>\EndIncludeInRelease
309 %</2ekernel|latexrelease>
310 %<*2ekernel>
311 \def\@endtheorem{\endtrivlist}
312 %</2ekernel>
313 % \end{macrocode}
314 % \end{macro}
315 % \end{macro}
316 % \end{macro}
317 %
318 % \Finale
319 %