1 % \iffalse meta-comment
4 % The LaTeX3 Project and any individual authors listed elsewhere
7 % This file is part of the LaTeX base system.
8 % -------------------------------------------
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 % http://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of LaTeX
16 % version 2005/12/01 or later.
18 % This file has the LPPL maintenance status "maintained".
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
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.
31 %%% From File: ltthm.dtx
34 \ProvidesFile{ltthm.dtx}
35 [2014/09/29 v1.0f LaTeX Kernel (Theorems)]
37 \documentclass{ltxdoc}
38 \GetFileInfo{ltthm.dtx}
51 \MaintainedByLaTeXTeam{latex}
60 % \section{Theorem Environments}
63 % The user creates his own theorem-like environments with the command\\
64 % |\newtheorem|\marg{name}\marg{text}\oarg{counter} or\\
65 % |\newtheorem|\marg{name}\oarg{oldname}\marg{text}\\
66 % This defines the environment \meta{name} to be just as one would
67 % expect a theorem environment to be, except that it prints \meta{text}
68 % instead of ``Theorem''.
70 % If \meta{oldname} is given, then environments \meta{name} and
71 % \meta{oldname} use the same counter, so using a \meta{name}
72 % environment advances the number of the next \meta{name} environment,
75 % If \meta{counter} is given, then environment \meta{name} is numbered
76 % within \meta{counter}.
78 % E.g., if \meta{counter} = |subsection|, then the first \meta{name} in
79 % subsection 7.2 is numbered \meta{text} 7.2.1.
81 % The way \meta{name} environments are numbered can be changed by
82 % redefining |\the|\meta{name}.
87 % \changes{v1.0a}{1994/03/28}{Initial version, split from latex.dtx}
88 % \changes{v1.0c}{1994/05/25}{Modify documentation}
89 % \changes{v1.0f}{1995/10/10}{Make \cs{newtheorem} `only preamble'}
90 % \changes{v1.0g}{1995/10/16}
91 % {Revert to previous \cs{newtheorem} behaviour}
95 % DOCUMENT STYLE PARAMETERS
97 % \@thmcounter{COUNTER} : A command such that
98 % \edef\theCOUNTER{\@thmcounter{COUNTER}}
99 % defines \theCOUNTER to produce a number for a theorem environment.
101 % BEGIN \noexpand\arabic{COUNTER} END
103 % \@thmcountersep : A separator placed between a theorem number and
104 % the number of the counter within which it is numbered.
105 % E.g., to make the third theorem of section 7.2 be numbered
106 % 7.2-3, \@thmcountersep should be \def'ed to '-'. Its
109 % \@begintheorem{NAME}{NUMBER} : A command that begins a theorem
110 % environment for a 'theorem' named 'NAME NUMBER' --
111 % e.g., \@begintheorem{Lemma}{3.7} starts Lemma 3.7.
113 % \@opargbegintheorem{NAME}{NUMBER}{OPARG} :
114 % A command that begins a theorem
115 % environment for a 'theorem' named 'NAME NUMBER' with optional
116 % argument OPARG -- e.g., \@begintheorem{Lemma}{3.7}{Jones}
117 % starts `Lemma 3.7 (Jones):'.
119 % \@endtheorem : A command that ends a theorem environment.
121 % \newtheorem{NAME}{TEXT}[COUNTER] ==
123 % if \NAME is definable
124 % then \@definecounter{NAME}
126 % then \@newctr{NAME}[COUNTER] fi
127 % \theNAME == BEGIN \theCOUNTER \@thmcountersep
128 % eval\@thmcounter{NAME} END
129 % else \theNAME == BEGIN eval\@thmcounter{NAME} END
130 % \NAME == \@thm{NAME}{TEXT}
131 % \endNAME == \@endtheorem
136 % \newtheorem{NAME}[OLDNAME]{TEXT}==
138 % if counter OLDNAME nonexistent
141 % if \NAME is definable
143 % \theNAME == \theOLDNAME
144 % \NAME == \@thm{OLDNAME}{TEXT}
145 % \endNAME == \@endtheorem
152 % \@thm{NAME}{TEXT} ==
154 % \refstepcounter{NAME}
156 % then \@ythm{NAME}{TEXT}
157 % else \@xthm{NAME}{TEXT}
161 % \@xthm{NAME}{TEXT} ==
163 % \@begintheorem{TEXT}{\theNAME}
167 % \@ythm{NAME}{TEXT}[OPARG] ==
169 % \@opargbegintheorem{TEXT}{\theNAME}{OPARG}
174 % \begin{macro}{\newtheorem}
175 % |\newtheorem| ought really be allowed only in the preamble
176 % Which would be good document style, and allow some main memory to be
177 % saved by declaring these commands to be
178 % |\@onlypreamble|. Unfortunately the \LaTeX\ book indicates that
179 % |\newtheorem| may be used anywhere in the document\ldots
183 \@ifnextchar[{\@othm{#1}}{\@nthm{#1}}}
187 % \begin{macro}{\@nthm}
190 \@ifnextchar[{\@xnthm{#1}{#2}}{\@ynthm{#1}{#2}}}
194 % \begin{macro}{\@xnthm}
196 % 92/09/18 RmS: Changed |\@addtoreset| to |\@newctr| to produce error
197 % message if counter |#3| does not exist (to be
198 % consistent with behaviour of |\newcounter|)
200 \def\@xnthm#1#2[#3]{%
201 \expandafter\@ifdefinable\csname #1\endcsname
202 {\@definecounter{#1}\@newctr{#1}[#3]%
203 \expandafter\xdef\csname the#1\endcsname{%
204 \expandafter\noexpand\csname the#3\endcsname \@thmcountersep
206 \global\@namedef{#1}{\@thm{#1}{#2}}%
207 \global\@namedef{end#1}{\@endtheorem}}}
211 % \begin{macro}{\@ynthm}
214 \expandafter\@ifdefinable\csname #1\endcsname
215 {\@definecounter{#1}%
216 \expandafter\xdef\csname the#1\endcsname{\@thmcounter{#1}}%
217 \global\@namedef{#1}{\@thm{#1}{#2}}%
218 \global\@namedef{end#1}{\@endtheorem}}}
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
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)}
232 \@ifundefined{c@#2}{\@nocounterr{#2}}%
233 {\expandafter\@ifdefinable\csname #1\endcsname
234 {\global\@namedef{the#1}{\@nameuse{the#2}}%
235 \global\@namedef{#1}{\@thm{#2}{#3}}%
236 \global\@namedef{end#1}{\@endtheorem}}}}
240 % \begin{macro}{\@thm}
244 \@ifnextchar[{\@ythm{#1}{#2}}{\@xthm{#1}{#2}}}
248 % \begin{macro}{\@xthm}
249 % \begin{macro}{\@ythm}
252 \@begintheorem{#2}{\csname the#1\endcsname}\ignorespaces}
254 \@opargbegintheorem{#2}{\csname the#1\endcsname}{#3}\ignorespaces}
260 % \begin{macro}{\@thmcounter}
261 % \begin{macro}{\@thmcountersep}
263 \def\@thmcounter#1{\noexpand\arabic{#1}}
264 \def\@thmcountersep{.}
269 % \begin{macro}{\@begintheorem}
270 % \begin{macro}{\@opargbegintheorem}
271 % \begin{macro}{\@endtheorem}
272 % \changes{LaTeX2.09}{1991/08/14}
273 % {Moved \cs{itshape} after \cs{item} to make it work with
275 % Providing theorem defaults.
276 % \task{???}{add `reset@font?}
278 \def\@begintheorem#1#2{\trivlist
279 \item[\hskip \labelsep{\bfseries #1\ #2}]\itshape}
280 \def\@opargbegintheorem#1#2#3{\trivlist
281 \item[\hskip \labelsep{\bfseries #1\ #2\ (#3)}]\itshape}
282 \def\@endtheorem{\endtrivlist}