Add an initial model for testing TU encodings
[latex2e.git] / latex2e-20160331 / base / ltthm.dtx
blob7b6177f1377cb8013ec51b9c4255ca6985322fd8
1 % \iffalse meta-comment
3 % Copyright 1993-2016
4 % The LaTeX3 Project and any individual authors listed elsewhere
5 % in this file.
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
22 % information.
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.
28 % \fi
30 % \iffalse
31 %%% From File: ltthm.dtx
32 %<*driver>
33 % \fi
34 \ProvidesFile{ltthm.dtx}
35              [2014/09/29 v1.0f 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}
50 \begin{document}
51  \MaintainedByLaTeXTeam{latex}
52  \maketitle
53  \DocInput{\filename}
54 \end{document}
55 %</driver>
56 % \fi
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,
72 %  and vice-versa.
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}.
83 % \StopEventually{}
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}
92 % \begin{oldcomments}
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.
99 %     The default is:
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
106 %         default is '.'.
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] ==
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
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
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
160 % \@xthm{NAME}{TEXT} ==
161 %   BEGIN
162 %    \@begintheorem{TEXT}{\theNAME}
163 %    \ignorespaces
164 %   END
166 % \@ythm{NAME}{TEXT}[OPARG] ==
167 %   BEGIN
168 %    \@opargbegintheorem{TEXT}{\theNAME}{OPARG}
169 %    \ignorespaces
170 %   END
171 % \end{oldcomments}
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}
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}
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|)
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}
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}
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}
239 % \begin{macro}{\@thm}
240 %    \begin{macrocode}
241 \def\@thm#1#2{%
242   \refstepcounter{#1}%
243   \@ifnextchar[{\@ythm{#1}{#2}}{\@xthm{#1}{#2}}}
244 %    \end{macrocode}
245 % \end{macro}
247 % \begin{macro}{\@xthm}
248 % \begin{macro}{\@ythm}
249 %    \begin{macrocode}
250 \def\@xthm#1#2{%
251   \@begintheorem{#2}{\csname the#1\endcsname}\ignorespaces}
252 \def\@ythm#1#2[#3]{%
253   \@opargbegintheorem{#2}{\csname the#1\endcsname}{#3}\ignorespaces}
254 %    \end{macrocode}
255 % \end{macro}
256 % \end{macro}
258 % Default values
259 % \begin{macro}{\@thmcounter}
260 % \begin{macro}{\@thmcountersep}
261 %    \begin{macrocode}
262 \def\@thmcounter#1{\noexpand\arabic{#1}}
263 \def\@thmcountersep{.}
264 %    \end{macrocode}
265 % \end{macro}
266 % \end{macro}
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
273 %         NFSS}
274 %    Providing theorem defaults.
275 %  \task{???}{add `reset@font?}
276 %    \begin{macrocode}
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}
282 %</2ekernel>
283 %    \end{macrocode}
284 %  \end{macro}
285 %  \end{macro}
286 %  \end{macro}
288 % \Finale