Debian Codegraph @

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

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 1993-2026
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 [2025/12/31 v1.0h 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 %</2ekernel>
219 % \end{macrocode}
220 % \end{macro}
221 %
222 % \begin{macro}{\@othm}
223 % \changes{LaTeX2.09}{1992/01/10}
224 % {(RmS) Check for existence of theorem environment}
225 % \changes{LaTeX2.09}{1992/08/19}
226 % {(RmS) Changed error message to complain about undefined
227 % counter}
228 % \changes{v1.0b}{1994/04/09}{Use standard counter error message (FMi)}
229 % \changes{v1.0c}{1994/04/17}{Use new std counter error message (FMi)}
230 % \changes{v1.0h}{2025-12-31}{Use new alias counter (UFi)}
231 % \begin{macrocode}
232 %<*2ekernel|latexrelease>
233 %<latexrelease>\IncludeInRelease{2026/06/01}%
234 %<latexrelease> {\@othm}{use alias counter}%
235 \def\@othm#1[#2]#3{%
236 \@ifundefined{c@#2}{\@nocounterr{#2}}%
237 {\expandafter\@ifdefinable\csname #1\endcsname
238 {\newcounteralias{#1}{#2}%
239 \global\@namedef{#1}{\@thm{#1}{#3}}%
240 \global\@namedef{end#1}{\@endtheorem}}}}
241 %<latexrelease>\EndIncludeInRelease
242 %<latexrelease>\IncludeInRelease{0000/00/00}%
243 %<latexrelease> {\@othm}{use alias counter}%
244 %<latexrelease>\def\@othm#1[#2]#3{%
245 %<latexrelease> \@ifundefined{c@#2}{\@nocounterr{#2}}%
246 %<latexrelease> {\expandafter\@ifdefinable\csname #1\endcsname
247 %<latexrelease> {\global\@namedef{the#1}{\@nameuse{the#2}}%
248 %<latexrelease> \global\@namedef{#1}{\@thm{#2}{#3}}%
249 %<latexrelease> \global\@namedef{end#1}{\@endtheorem}}}}
250 %<latexrelease>\EndIncludeInRelease
251 %</2ekernel|latexrelease>
252 % \end{macrocode}
253 % \end{macro}
254 %
255 % \begin{macro}{\@thm}
256 % \changes{v1.0c}{1994/04/17}{Use new std counter error message (FMi)}
257 % \changes{v1.0g}{2024/03/18}{Use \cs{@kernel@refstepcounter} to avoid an unwanted target (UFi)}
258 % \begin{macrocode}
259 %<*2ekernel|latexrelease>
260 %<latexrelease>\IncludeInRelease{2024/03/18}%
261 %<latexrelease> {\@thm}{no link target}%
262 \def\@thm#1#2{%
263 \@kernel@refstepcounter{#1}%
264 \@ifnextchar[{\@ythm{#1}{#2}}{\@xthm{#1}{#2}}}
265 %<latexrelease>\EndIncludeInRelease
266 %<latexrelease>\IncludeInRelease{0000/00/00}%
267 %<latexrelease> {\@thm}{no link target}%
268 %<latexrelease>\def\@thm#1#2{%
269 %<latexrelease> \refstepcounter{#1}%
270 %<latexrelease> \@ifnextchar[{\@ythm{#1}{#2}}{\@xthm{#1}{#2}}}
271 %<latexrelease>\EndIncludeInRelease
272 %</2ekernel|latexrelease>
273 % \end{macrocode}
274 % \end{macro}
275 %
276 % \begin{macro}{\@xthm}
277 % \begin{macro}{\@ythm}
278 % \begin{macrocode}
279 %<*2ekernel>
280 \def\@xthm#1#2{%
281 \@begintheorem{#2}{\csname the#1\endcsname}\ignorespaces}
282 \def\@ythm#1#2[#3]{%
283 \@opargbegintheorem{#2}{\csname the#1\endcsname}{#3}\ignorespaces}
284 % \end{macrocode}
285 % \end{macro}
286 % \end{macro}
287 %
288 % Default values
289 % \begin{macro}{\@thmcounter}
290 % \begin{macro}{\@thmcountersep}
291 % \begin{macrocode}
292 \def\@thmcounter#1{\noexpand\arabic{#1}}
293 \def\@thmcountersep{.}
294 % \end{macrocode}
295 % \end{macro}
296 % \end{macro}
297 %
298 % \begin{macro}{\@begintheorem}
299 % \begin{macro}{\@opargbegintheorem}
300 % \begin{macro}{\@endtheorem}
301 % \changes{LaTeX2.09}{1991/08/14}
302 % {Moved \cs{itshape} after \cs{item} to make it work with
303 % NFSS}
304 % Providing theorem defaults.
305 % \task{???}{add `reset@font?}
306 % % \changes{v1.0g}{2024/03/18}{Insert link target in the label (UFi)}
307 % \begin{macrocode}
308 %</2ekernel>
309 %<*2ekernel|latexrelease>
310 %<latexrelease>\IncludeInRelease{2024/03/18}%
311 %<latexrelease> {\@begintheorem}{add link targets}%
312 \def\@begintheorem#1#2{\trivlist
313 \item[\MakeLinkTarget{\@currentcounter}\hskip \labelsep{\bfseries #1\ #2}]\itshape}
314 \def\@opargbegintheorem#1#2#3{\trivlist
315 \item[\MakeLinkTarget{\@currentcounter}\hskip \labelsep{\bfseries #1\ #2\ (#3)}]\itshape}
316 %<latexrelease>\EndIncludeInRelease
317 %<latexrelease>\IncludeInRelease{0000/00/00}%
318 %<latexrelease> {\@begintheorem}{add link targets}%
319 %<latexrelease>\def\@begintheorem#1#2{\trivlist
320 %<latexrelease> \item[\hskip \labelsep{\bfseries #1\ #2}]\itshape}
321 %<latexrelease>\def\@opargbegintheorem#1#2#3{\trivlist
322 %<latexrelease> \item[\hskip \labelsep{\bfseries #1\ #2\ (#3)}]\itshape}
323 %<latexrelease>\EndIncludeInRelease
324 %</2ekernel|latexrelease>
325 %<*2ekernel>
326 \def\@endtheorem{\endtrivlist}
327 %</2ekernel>
328 % \end{macrocode}
329 % \end{macro}
330 % \end{macro}
331 % \end{macro}
332 %
333 % \Finale
334 %