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}
59 % \section{Theorem Environments}
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''.
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,
74 % If \meta{counter} is given, then environment \meta{name} is numbered
75 % within \meta{counter}.
77 % E.g., if \meta{counter} = |subsection|, then the first \meta{name} in
78 % subsection 7.2 is numbered \meta{text} 7.2.1.
80 % The way \meta{name} environments are numbered can be changed by
81 % redefining |\the|\meta{name}.
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}
94 % DOCUMENT STYLE PARAMETERS
96 % \@thmcounter{COUNTER} : A command such that
97 % \edef\theCOUNTER{\@thmcounter{COUNTER}}
98 % defines \theCOUNTER to produce a number for a theorem environment.
100 % BEGIN \noexpand\arabic{COUNTER} END
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
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.
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):'.
118 % \@endtheorem : A command that ends a theorem environment.
120 % \newtheorem{NAME}{TEXT}[COUNTER] ==
122 % if \NAME is definable
123 % then \@definecounter{NAME}
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
135 % \newtheorem{NAME}[OLDNAME]{TEXT}==
137 % if counter OLDNAME nonexistent
140 % if \NAME is definable
142 % \theNAME == \theOLDNAME
143 % \NAME == \@thm{OLDNAME}{TEXT}
144 % \endNAME == \@endtheorem
151 % \@thm{NAME}{TEXT} ==
153 % \refstepcounter{NAME}
155 % then \@ythm{NAME}{TEXT}
156 % else \@xthm{NAME}{TEXT}
160 % \@xthm{NAME}{TEXT} ==
162 % \@begintheorem{TEXT}{\theNAME}
166 % \@ythm{NAME}{TEXT}[OPARG] ==
168 % \@opargbegintheorem{TEXT}{\theNAME}{OPARG}
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
182 \@ifnextchar[{\@othm{#1}}{\@nthm{#1}}}
186 % \begin{macro}{\@nthm}
189 \@ifnextchar[{\@xnthm{#1}{#2}}{\@ynthm{#1}{#2}}}
193 % \begin{macro}{\@xnthm}
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|)
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
205 \global\@namedef{#1}{\@thm{#1}{#2}}%
206 \global\@namedef{end#1}{\@endtheorem}}}
210 % \begin{macro}{\@ynthm}
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}}}
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
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)}
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}}}}
239 % \begin{macro}{\@thm}
243 \@ifnextchar[{\@ythm{#1}{#2}}{\@xthm{#1}{#2}}}
247 % \begin{macro}{\@xthm}
248 % \begin{macro}{\@ythm}
251 \@begintheorem{#2}{\csname the#1\endcsname}\ignorespaces}
253 \@opargbegintheorem{#2}{\csname the#1\endcsname}{#3}\ignorespaces}
259 % \begin{macro}{\@thmcounter}
260 % \begin{macro}{\@thmcountersep}
262 \def\@thmcounter#1{\noexpand\arabic{#1}}
263 \def\@thmcountersep{.}
268 % \begin{macro}{\@begintheorem}
269 % \begin{macro}{\@opargbegintheorem}
270 % \begin{macro}{\@endtheorem}
271 % \changes{LaTeX2.09}{1991/08/14}
272 % {Moved \cs{itshape} after \cs{item} to make it work with
274 % Providing theorem defaults.
275 % \task{???}{add `reset@font?}
277 \def\@begintheorem#1#2{\trivlist
278 \item[\hskip \labelsep{\bfseries #1\ #2}]\itshape}
279 \def\@opargbegintheorem#1#2#3{\trivlist
280 \item[\hskip \labelsep{\bfseries #1\ #2\ (#3)}]\itshape}
281 \def\@endtheorem{\endtrivlist}