1 % \iffalse meta-comment
5 % The LaTeX3 Project and any individual authors listed elsewhere
8 % This file is part of the Standard LaTeX `Tools Bundle'.
9 % -------------------------------------------------------
11 % It may be distributed and/or modified under the
12 % conditions of the LaTeX Project Public License, either version 1.3c
13 % of this license or (at your option) any later version.
14 % The latest version of this license is in
15 % http://www.latex-project.org/lppl.txt
16 % and version 1.3c or later is part of all distributions of LaTeX
17 % version 2005/12/01 or later.
19 % The list of all files belonging to the LaTeX `Tools Bundle' is
20 % given in the file `manifest.txt'.
26 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
27 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
28 %% Digits \0\1\2\3\4\5\6\7\8\9
29 %% Exclamation \! Double quote \" Hash (number) \#
30 %% Dollar \$ Percent \% Ampersand \&
31 %% Acute accent \' Left paren \( Right paren \)
32 %% Asterisk \* Plus \+ Comma \,
33 %% Minus \- Point \. Solidus \/
34 %% Colon \: Semicolon \; Less than \<
35 %% Equals \= Greater than \> Question mark \?
36 %% Commercial at \@ Left bracket \[ Backslash \\
37 %% Right bracket \] Circumflex \^ Underscore \_
38 %% Grave accent \` Left brace \{ Vertical bar \|
39 %% Right brace \} Tilde \~}
43 \def\FMithmInfo{2014/10/28 v2.2c Theorem extension package (FMi)}
45 % \ProvidesFile{theorem.dtx}[\FMithmInfo]
46 %\iffalse % this is a METACOMMENT !
48 %% Package `theorem' to use with LaTeX2e
49 %% Copyright (C) 1989-1995 Frank Mittelbach, all rights reserved.
50 %<+package>\@ifundefined{theorem@style}{}{\endinput}
51 %<+package>\NeedsTeXFormat{LaTeX2e}[1995/06/01]
52 %<+package>\ProvidesPackage{theorem}
53 %<+package> [\FMithmInfo]
57 % \changes{v1.0}{87/05/07}{First draft.}
58 % \changes{v1.0a}{87/05/07}{`thistheoremstyle' added.}
59 % \changes{v1.1a}{87/07/29}{New concept: redefine the internal
60 % \protect\LaTeX{} commands `@xnthm' etc.}
61 % \changes{v1.1b}{87/07/31}{`theoremfont' used to specify font.}
62 % \changes{v1.2a}{88/01/08}{`@endtheorem' now globally defined.}
63 % \changes{v1.2b}{88/01/11}{`newtheorem' only allowed in the preamble.}
64 % \changes{v1.3a}{88/02/14}{`theoremfont' now a toks register.}
66 % \changes{v2.0a}{88/11/16}{New implementation and new documentation.}
67 % \changes{v2.0a}{88/11/16}{No layout changes but internal modifications
68 % old substyles won't work.}
69 % \changes{v2.0b}{89/01/30}{`global' used for all definitions.}
70 % \changes{v2.0c}{89/06/15}{Documentation translated to English.
71 % Thanks to LLL and Nina}
72 % \changes{v2.1a}{90/02/15}{Support for new font selection.}
73 % \changes{v2.2a}{94/02/03}{Cleanup for LaTeX2e}
75 % \DoNotIndex{\@endparenv,\@ifdefinable,\@ifnextchar,\@ifundefined}
76 % \DoNotIndex{\@namedef,\@nameuse,\@spaces,\@tempa,\@warning}
78 % \DoNotIndex{\begingroup,\bfseries}
79 % \DoNotIndex{\csname}
80 % \DoNotIndex{\def,\do,\docdate}
81 % \DoNotIndex{\endcsname,\endgroup,\endinput,\endtrivlist,\expandafter}
82 % \DoNotIndex{\filedate,\fileversion}
83 % \DoNotIndex{\gdef,\global}
84 % \DoNotIndex{\hbox,\hskip}
85 % \DoNotIndex{\ignorespaces,\input,\itshape,\item}
86 % \DoNotIndex{\labelsep,\let,\llap}
87 % \DoNotIndex{\makeatletter}
88 % \DoNotIndex{\noexpand}
89 % \DoNotIndex{\refstepcounter,\relax,\rlap}
90 % \DoNotIndex{\setlength,\slshape,\space,\string,\strut}
91 % \DoNotIndex{\the,\trivlist,\typeout}
95 % \def\deflabel#1{\ttfamily #1\hfill}
96 % \def\deflist#1{\begin{list}{}{\settowidth\labelwidth{\ttfamily #1}%
97 % \setlength\leftmargin\labelwidth
98 % \addtolength\leftmargin\labelsep
99 % \let\makelabel\deflabel}}
100 % \def\enddeflist{\end{list}}
101 % \def\envfont{\normalfont\ttfamily}
105 % \newcommand{\TUB}{{\sl TUGboat\/}}
107 % \GetFileInfo{theorem.dtx}
108 % \title{An Extension of the
109 % \LaTeX{} theorem environment\thanks{This file
110 % has version number \fileversion, last
111 % revised \filedate.}}
112 % \author{Frank Mittelbach}
114 % \MaintainedByLaTeXTeam{tools}
118 % The macros described in this paper yield an extension of the
119 % \LaTeX{} theorem mechanism. It is designed is to satisfy the
120 % different requirements of various journals. Thus, the
121 % layout of the ``theorems'' can be manipulated by determining a
122 % ``style''. This article describes not only the use, but
123 % also the definition, of the necessary macros.
126 % \section*{Preface to version 2.2}
128 % For \LaTeXe{} this package did not need any fundamental changes. I
129 % only modified the messages generated so that theorem layout styles
130 % will show up with the |\listfiles| command and cleaned the section
131 % on the New Font Selection Scheme since this is now included in
134 % \section*{Preface to version 2.1}
136 % This version is identical to 2.0g described in \TUB\ 10\#3 except
137 % for some internal defaults which are now set depending on the used
138 % font selection scheme.
140 % This was done to avoid unpleasant surprises if the new font selection
141 % scheme is in force. For further details see
142 % section~\ref{sec:newfonts} and \cite{bk:GMS94}.
144 % \section{Introduction}
146 % For our purposes here, ``theorems'' are labelled enunciations,
147 % often set off from the main text by extra space and a font change.
148 % Theorems, corollaries, conjectures, definitions, and remarks
149 % are all instances of ``theorems''. The ``header'' of these structures
150 % is composed of a label (such as \textsc{Theorem} or \textsc{Remark})
151 % and a number which serializes an item in the sequence of items
152 % with the same label.
154 % Shortly after the introduction of \LaTeX{} at the Fachbereich
155 % Mathematik in Mainz, the desire to manipulate the layout of
156 % ``theorems'' arose. In Mainz, the following two conventions came
159 % \item The number of the theorem is shown in the margin.
160 % \item There is a line break at
161 % the end of the theorem header.
164 % Additionally, some journals require different formats which depend on
165 % the ``sort of theorem'': e.g.\ often remarks and definitions are set
166 % in |\upshape|, while |\itshape| is employed for main theorems.
168 % Confronted with these requirements, a theorem environment was
169 % developed in Mainz which allows separate determination of the
170 % layout of the ``theorems sets'', comparable to |\pagestyle|.
173 % \section{The user interface}
174 % \subsection{Defining new theorem sets}
176 % \DescribeMacro\newtheorem
177 % As in the original \LaTeX{} version, the command |\newtheorem|
178 % defines a new ``theorem set'' or ``theorem-like structure''.
179 % Two required arguments name the new environment and give the text
180 % to be typeset with each instance of the new ``set'', while
181 % an optional argument determines how
182 % the ``set'' is enumerated:
183 % \begin{description}
184 % \item[\ttfamily \bslash newtheorem\{foo\}\{bar\}]
185 % The theorem set {\envfont foo} (whose name is \texttt{bar})
186 % uses its own counter.
187 % \item[\ttfamily \bslash newtheorem\{foo2\}{[foo]}\{bar2\}]
188 % The theorem set {\envfont foo2} (printed name \texttt{bar2})
189 % uses the same counter as the theorem set \texttt{foo}.
190 % \item[\ttfamily \bslash newtheorem\{foo3\}\{bar3\}{[section]}]
191 % The theorem set {\envfont foo3} (printed name \texttt{bar3}) is
192 % enumerated within the counter \texttt{section}, i.e.\ with every
193 % new |\section| the enumeration begins again with 1, and
194 % the enumeration is composed from the section-number and the
195 % theorem counter itself.
198 % \DescribeMacro\theoremstyle
199 % Additionally, the command |\theoremstyle| can define the layout
200 % of various, or all, theorem sets. It should be noted that any
201 % theorem set defined by |\newtheorem| is typeset in the
202 % |\theoremstyle| that is current at the time of the definition.
203 % Thus, the following
205 % \theoremstyle{break} \newtheorem{Cor}{Corollary}
206 % \theoremstyle{plain} \newtheorem{Exa}{Example}[section]
207 %\end{verbatim} ^^A No blank at line start
208 % leads to the result that the set {\envfont Cor} is formatted in the
209 % style \texttt{break}, while the set {\envfont Exa} and all the
210 % following ones are formatted in the style \texttt{plain}, unless
211 % another |\theoremstyle| follows. Since the definitions installed by
212 % |\newtheorem| are global, one also can limit |\theoremstyle| locally
213 % by grouping braces.
215 % \DescribeMacro\theorembodyfont
216 % The choice of the font for the theorem body is completely
217 % independent of the chosen |\theoremstyle|; this has proven to
218 % be very advantageous. For example,
220 % {\theorembodyfont{\upshape} \newtheorem{Rem}{Remark}}
222 % defines a theorem set {\envfont Rem}, which will be set in
223 % |\upshape| in the current layout (which in our example is
224 % \texttt{plain}). As with |\theoremstyle|, the |\theorembodyfont|
225 % chosen is that current at the time of |\newtheorem|. If
226 % |\theorembodyfont| is not specified or one defines
227 % |\theorembodyfont{}|, then the font used will be that defined by the
230 % \DescribeMacro\theoremheaderfont It is also possible to customize
231 % the font used for the theorem headers. This is, however, a global
232 % declaration, and therefore there should be at most one
233 % |\theoremheaderfont| declaration in the preamble.\footnote{If it is
234 % actually necessary to have different header fonts, one has to define
235 % new theorem styles (substituting the desired font) or specify the
236 % information directly in the \texttt{\bslash newtheorem} declaration
237 % (the unclean variant).}
239 % \DescribeMacro\theorempreskipamount
240 % \DescribeMacro\theorempostskipamount Two additional parameters
241 % affect the vertical space around the theorem environments:
242 % |\theorempreskipamount| and |\theorempostskipamount| define,
243 % respectively, the spacing before and after such an environment.
244 % These parameters apply for all theorem sets and can be manipulated
245 % with the ordinary length macros. They are rubber lengths,
246 % (`\textsf{skips}'), and therefore can contain \texttt{plus} and
247 % \texttt{minus} parts.
249 % Since the definition of theorem sets should---most sensibly---be
250 % placed in the preamble, we only allow installation there.
251 % It is therefore possible to release the memory used here after
252 % |\begin{document}|, in order to make room for other
256 % \subsection{Existing theorem styles}
258 % The following theorem styles exist to date:
259 % \begin{deflist}{marginbreak}
261 % This theorem style emulates the original \LaTeX{} definition,
262 % except that additionally the parameters
263 % |\theorem...skipamount| are used.
265 % In this style, the theorem header is followed by a line
268 % The theorem number is set in the margin, and there is a line
269 % break as in \texttt{break}.
271 % Like \texttt{break}, but with header number and text
274 % Header number and text are interchanged, without a line break.
276 % The number is set in the left margin, without a line break.
278 % All styles (except \texttt{plain}) select |\slshape| as the default
279 % |\theorembodyfont|.
282 % \subsection{Examples}
284 % Given the above theorem sets {\envfont Cor}, {\envfont Exa}
285 % and {\envfont Rem},
286 % suppose that the preamble also contains the declarations:
288 % \theoremstyle{marginbreak} \newtheorem{Lem}[Cor]{Lemma}
289 % \theoremstyle{change}
290 % \theorembodyfont{\itshape} \newtheorem{Def}[Cor]{Definition}
292 % \theoremheaderfont{\scshape}
294 % Then the following are some typical examples of the typeset output
295 % resulting from their use.
298 % This is a sentence typeset in the theorem environment {\envfont
303 % This is a sentence typeset in the theorem environment {\envfont
308 % This is a sentence typeset in the theorem environment {\envfont
312 % \begin{Lem}[Ben User]
313 % This is a sentence typeset in the theorem environment {\envfont
317 % \begin{Def}[Very impressive Definition]
318 % This is a sentence typeset in the theorem environment {\envfont
322 % The last two examples show the effect of the optional argument to
323 % a theorem environment (it is the text typeset in parentheses).
326 % \section{Special Considerations}
327 % \label{sec:newfonts}
329 % Theoremheader and body are implemented as a unit. This means that
330 % the |\theoremheaderfont| will inherit characteristics of the
331 % |\theorembodyfont| in \LaTeXe. Thus, if for example
332 % |\theorembodyfont| is |\itshape| and |\theoremheaderfont|
333 % is |\bfseries| the font selected for the header will have the
334 % characteristics `bold extended italic'. If this is not desired one
335 % should set the |\theoremheaderfont| to something like
337 % \theoremheaderfont{\normalfont\bfseries}
339 % i.e.\ supplying all necessary font information explicitly.
343 % \section{Acknowledgements}
345 % The publication of this set of macros was only possible with the
346 % help of Christina Busse (translating the manuscript into English),
347 % Joachim Pense (playing the r\^ole of typist), Chris Rowley
348 % (looking everything over) and many others providing useful
352 % \begin{thebibliography}{9}
353 % \bibitem{bk:GMS94} \textsc{M.~Goossens}, \textsc{F.~Mittelbach}
354 % and \textsc{A.~Samarin}.
355 % \newblock The \LaTeX{} Companion.
357 % Addison-Wesley, Reading, Massachusetts, 1994.
358 % \bibitem{latex:source} \textsc{Lamport, Leslie.} \newblock
359 % \texttt{latex.tex}, version 2.09, date
361 % \end{thebibliography}
366 % \section{The documentation driver file}
368 % The next bit of code contains the documentation driver file for
369 % \TeX{}, i.e., the file that will produce the documentation you are
370 % currently reading. It will be extracted from this file by the
371 % \texttt{docstrip} program. Since it is the first code in the file
372 % one can alternatively process this file directly with \LaTeXe{} to
373 % obtain the documentation.
377 \documentclass{ltxdoc}
381 %<+driver>% The next few lines define theorem sets which are used
382 %<+driver>% in the example section of the documentation.
384 \theoremstyle{break} \newtheorem{Cor}{Corollary}
385 \theoremstyle{plain} \newtheorem{Exa}{Example}[section]
386 {\theorembodyfont{\upshape}\newtheorem{Rem}{Remark}}
387 \theoremstyle{marginbreak} \newtheorem{Lem}[Cor]{Lemma}
388 \theoremstyle{change}
389 \theorembodyfont{\itshape} \newtheorem{Def}[Cor]{Definition}
391 \theoremheaderfont{\scshape}
396 \DocInput{theorem.dtx}
401 % \section{Definition of the Macros}
403 % If the file has been loaded before, we abort immediately. If not the
404 % package announces itself (this is actually done at the very top if
405 % the file---the way it is done isn't good style so don't copy it).
406 % \changes{v2.0e}{89/07/19}{Spaces removed from `typeout'.}
407 % \changes{v2.2b}{95/11/19}{Announce moved to top of file}
410 %\@ifundefined{theorem@style}{}{\endinput}
411 %\def\FMithmInfo{1995/11/19 v2.2b Theorem extension package (FMi)}
412 %\ProvidesPackage{theorem}[\FMithmInfo]
416 % \subsection{Definition of theorem styles and fonts}
418 % All the definitions in this file are done globally to allow
419 % inputting this file inside a group.
421 % \begin{macro}{\theoremstyle}
422 % Before a theorem style can be installed, the chosen style must be
423 % known. For that reason, we must test to see that
424 % |\th@|\meta{style} is known or, more precisely, that it is
425 % different from |\relax|. If the style is not known then
426 % |\th@plain| is used.
428 \gdef\theoremstyle#1{%
429 \@ifundefined{th@#1}{\@warning
430 {Unknown theoremstyle `#1'. Using `plain'}%
431 \theorem@style{plain}}%
433 % We save the theorem style to be used in the token register
436 {\theorem@style{#1}}%
438 % Now we ``evaluate'' the theorem style: this means, we call the
439 % macro |\th@|\meta{style} which will activate the relevant
440 % definitions which are contained in a separate file. This is done
441 % in a group to suppress changes to the current font. This could
442 % otherwise pose problems together with the new font selection
443 % scheme\footnote{When I printed the original article using the new
444 % font selection scheme I ended with a document with slanted
445 % typefaces (text headings and all) simply because one of the
446 % theorem styles used \texttt{\bslash sl} at toplevel.} if the
447 % |\th@|\meta{style} is evaluated a second time.
448 % \changes{v2.1a}{90/02/15}{Group added around `th@..}
449 % \changes{v2.1a}{90/02/15}{Reseting of `..@begintheorem removed.}
452 \csname th@\the\theorem@style \endcsname
458 % \begin{macro}{\@begintheorem}
459 % \changes{v2.1a}{90/02/15}{Relaxed at toplevel.}
460 % \begin{macro}{\@opargbegintheorem}
461 % \changes{v2.1a}{90/02/15}{Relaxed at toplevel.}
462 % We reset |\@begintheorem| and |\@opargbegintheorem| to
463 % |\relax| since these commands are no longer necessary at
464 % toplevel. This will save a few tokens.
466 \global\let\@begintheorem\relax
467 \global\let\@opargbegintheorem\relax
472 % \begin{macro}{\theorem@style}
473 % Obviously the \textsf{token} register used above has to be
474 % allocated. To assure the utmost compatibility with the
475 % original \LaTeX{} definition, we set the default theorem style to
476 % \texttt{plain}, which implements the usual \LaTeX{} convention.
477 % \changes{v2.0f}{89/07/20}{Unnecessary `global' removed.}
479 \newtoks\theorem@style
480 \global\theorem@style{plain}
484 % \begin{macro}{\theorembodyfont}
485 % \begin{macro}{\theorem@bodyfont}
486 % If the |\theorembodyfont| is set by the user then it should not
487 % interact with the default font set in the theorem style. When the
488 % new font selection is in force this may happen if, for example,
489 % the default is |\itshape| and the new |\theorembodyfont| is
490 % |\sffamily|. So we add a |\reset@font| command in front of the
492 % \changes{v2.0f}{89/07/20}{Unnecessary `global' removed.}
493 % \changes{v2.0g}{89/09/19}{`theoremfont to `theorembodyfont.}
494 % \changes{v2.1c}{92/06/22}{`reset@font added and logic changed.}
495 % \changes{v2.1d}{92/10/28}{Reset to empty if arg is empty}
497 \gdef\theorembodyfont#1{%
499 % We check if the argument supplied is empty and if so put nothing
500 % into the |\theorem@bodyfont| token register to allow for
501 % |\theorembodyfont{}| as a mean of using the default of the
502 % current |\theoremstyle|.
508 \theorem@bodyfont{\reset@font#1}%
511 \newtoks\theorem@bodyfont
512 \global\theorem@bodyfont{}
518 % \begin{macro}{\theoremheaderfont}
519 % \changes{v2.0g}{89/09/19}{Macro added.}
520 % The font for the theorem headers is handled differently because
521 % this definition applies to all theorem styles.
523 \gdef\theoremheaderfont#1{\gdef\theorem@headerfont{#1}%
525 % After using the macro once it is redefined to produce an error
528 \gdef\theoremheaderfont##1{%
529 \typeout{\string\theoremheaderfont\space should be used
534 % \begin{macro}{\theorem@headerfont}
535 % \changes{v2.0g}{89/09/19}{Macro added.}
536 % To set the |\theorem@headerfont| default we first test if
537 % the new fontselection scheme is in force.
538 % \changes{v2.1a}{90/02/15}{Support for new font selection.}
540 \ifx\upshape\undefined
542 % If not we define it to expand into |\bfseries|. We don't use
543 % |\let| just in case a following style option redefines this
546 \gdef\theorem@headerfont{\bfseries}
548 % Otherwise we reset the current shape before calling |\bfseries|.
550 \else \gdef\theorem@headerfont{\normalfont\bfseries}\fi
554 % \begin{macro}{\th@plain}
555 % \begin{macro}{\th@break}
556 % \begin{macro}{\th@marginbreak}
557 % \begin{macro}{\th@changebreak}
558 % \begin{macro}{\th@change}
559 % \begin{macro}{\th@margin}
560 % The different styles are defined in macros such as
561 % |\th@plain|. Since memory space is precious in
562 % ``non-Big-versions'', we have to avoid offering too many unused
563 % definitions. Therefore we define these styles in separate files
564 % that can be loaded on demand. Thus the commands themselves only
565 % load these files. We use |\@input@| a \LaTeXe{} internal command
566 % that ensures that the file will be listed with |\listfiles|
567 % \changes{v2.2a}{94/02/02}{Use `@input@ to load theorem layout files}
569 \gdef\th@plain{\@input@{thp.sty}}
570 \gdef\th@break{\@input@{thb.sty}}
571 \gdef\th@marginbreak{\@input@{thmb.sty}}
572 \gdef\th@changebreak{\@input@{thcb.sty}}
573 \gdef\th@change{\@input@{thc.sty}}
574 \gdef\th@margin{\@input@{thm.sty}}
576 % This list will be expanded when new styles become
577 % available. For testing, just append new theorem substyles
578 % as document options.
588 % \subsection{Definition of a new theorem set}
590 % As already pointed out, a new theorem environment can be defined in
591 % three different ways:
593 % \newtheorem{Lem}{Lemma}
594 % \newtheorem{Lem}{Lemma}[section]
595 % \newtheorem{Lem}[Theorem]{Lemma}
597 % The function of the macro |\newtheorem| is to recognize these cases
598 % and then to branch into one of the three macros |\@ynthm|, |\@xnthm|
599 % or |\@othm|. This mechanism is adopted unchanged from
600 % \cite{latex:source}; the essential point here is that, for example,
601 % in the second case, the arguments \texttt{Lem}, \texttt{Lemma} and
602 % \texttt{section} are passed over to the macro |\@xnthm|.
604 % We inspect this case first because the others present fewer problems,
605 % and thus are easily derived from this one.
607 % \begin{macro}{\@xnthm}
608 % For our example arguments, the macro |\@xnthm| must fulfill
612 % Define a new \LaTeX-counter `Lem'
614 % reset this counter within a |\section|
616 % define the macro |\theLem|
618 % define the environment macros |\Lem| and
619 % |\endLem| using the current
620 % |\theoremstyle| and |\theorem@bodyfont|.
622 % Obviously, all this should happen only if the first argument
623 % of |\@xnthm| (i.e.\ \texttt{Lem} in our example) is chosen so
624 % as not to conflict with any previously defined commands or
625 % environments. This test is performed by the \LaTeX{} macro
628 \gdef\@xnthm#1#2[#3]{\expandafter\@ifdefinable\csname #1\endcsname
630 % Therefore, the first argument of |\@ifdefinable| is the
631 % expansion (in the example, |\Lem|) of
632 % |\csname||#1\endcsname|. The second argument is
633 % executed only if the test has been completed successfully.
637 % Now we define the new counter. The names of the \LaTeX{}
638 % macros employed should speak for themselves:
639 % \changes{v2.2b}{1995/10/07}{Use \cs{@newctr}}
640 % \changes{v2.2c}{1995/11/23}{Use \cs{@newctr} properly.}
642 \@definecounter{#1}\@newctr{#1}[#3]%
644 % Using |\@newctr| will give a proper error message if the counter
645 % in |#3| is not defined.
646 % In defining `|\theLem|' we must generate the desired macro
647 % name by use of |\expandafter| and |\csname|.
649 \expandafter\xdef\csname the#1\endcsname
651 % An |\xdef| is used in order to make the definition global,
652 % and to ensure that it contains the replacement texts of
653 % |\@thmcountersep| and |\@thmcounter|.\footnote{These
654 % two macros can be defined by the document style. Their default
655 % values produce a `\texttt{.}' as separation and an arabic
656 % representation of the number.} However, not everything should be
657 % expanded. For example, it saves space to use |\thesection|
658 % instead of its---at times---lengthy expansion.
660 {\expandafter \noexpand \csname the#3\endcsname
661 \@thmcountersep \@thmcounter{#1}}%
663 % Thus with the defaults of \LaTeX{}, |\theLem| would be
664 % replaced by the command sequence |\thesection.\arabic{Lem}|.
666 % We will now look at the definition of the macro which is executed
667 % at the beginning of the actual environment (in our example this
668 % macro is |\Lem|). It should be noted that we use an
669 % ``|\expandafter| trick'' to expand only certain parts of the
670 % replacement text at the time of the definition.
672 \def\@tempa{\global\@namedef{#1}}%
673 \expandafter \@tempa \expandafter{%
675 % First, the macro that contains the current definitions of
676 % |\@begintheorem| and |\@opargtheorem| should be called
677 % up. The name of this macro---as is already known---has the form
678 % |\th@|\meta{theorem\ style}; therefore, it must be called by
680 \csname th@\the \theorem@style
682 % In addition the default theorem font should be changeable, i.e.\
683 % we have to insert the contents of |\theorem@bodyfont|. For
684 % that reason, we expand even further, beyond |\endcsname|,
685 % and thus insert the contents of the \textsf{token} register
686 % |\theorem@bodyfont| in the replacement text.
688 \expandafter \endcsname \the \theorem@bodyfont
690 % Now it is time to call the macro |\@thm| which takes over
691 % the further processing. It has two arguments: the current
692 % counter name (in our example, \texttt{Lem}), and the text of the
693 % label (in our example, \texttt{Lemma}).
697 % With this, the `sub-definition' is complete. The macro
698 % |\@endtheorem| ends a theorem environment and is, so far, nothing
699 % but an |\endtrivlist|. (Hence it is defined globally, and not
700 % within the theorem styles.\footnote{This has to be changed as
701 % soon as theorem styles that change \texttt{\bslash @endtheorem}
702 % exist. In such a case, all existing styles must be changed as
703 % well since they will have to reset the macro.}) Therefore, we can
704 % set it equivalent to the macro that ends the theorem set (in our
705 % example, |\endLem|). However, if some day theorem styles exist
706 % that do change |\@endtheorem|, we would have to use the
707 % commented-out line instead.
709 \global \expandafter \let \csname end#1\endcsname \@endtheorem
710 % \global\@namedef{end#1}{\@endtheorem}%
712 % With these commands all the required definitions are employed,
713 % unless the test |\@ifdefinable| has failed. Therefore, we
714 % end the second argument of this macro and with it the definition
721 % \begin{macro}{\@ynthm}
722 % The definition of |\@ynthm| is completely analogous. In
723 % this case the new counter that is defined is not reset within
724 % another counter; thus the definition of |\the...|
727 \gdef\@ynthm#1#2{\expandafter\@ifdefinable\csname #1\endcsname
728 {\@definecounter{#1}%
729 \expandafter\xdef\csname the#1\endcsname{\@thmcounter{#1}}%
731 % The rest of the definition corresponds literally to that of
734 \def\@tempa{\global\@namedef{#1}}\expandafter \@tempa
735 \expandafter{\csname th@\the \theorem@style \expandafter
736 \endcsname \the\theorem@bodyfont \@thm{#1}{#2}}%
737 \global \expandafter \let \csname end#1\endcsname \@endtheorem}}
741 % \begin{macro}{\@othm}
742 % The definition of |\@othm| does not contain anything new.
744 \gdef\@othm#1[#2]#3{%
746 % \changes{v2.2b}{95/10/07}{Build in check for counter defined}
747 % We do not define a new counter but instead use one that has
748 % already been defined. Thus the only definition we need is that
749 % of this pseudo-counter (i.e.\ |\the|\meta{env.\ name}).
750 % First we check if |#2| corresponds to a known counter name.
752 \expandafter\ifx\csname c@#2\endcsname\relax
755 \expandafter\@ifdefinable\csname #1\endcsname
756 {\expandafter \xdef \csname the#1\endcsname
757 {\expandafter \noexpand \csname the#2\endcsname}%
759 % All other parts of the definition can be adopted from
760 % |\@xnthm|. We have to remember, though, that in this case
761 % the name of the current counter and the theorem label have moved
762 % to the second and third arguments.
764 \def\@tempa{\global\@namedef{#1}}\expandafter \@tempa
765 \expandafter{\csname th@\the \theorem@style \expandafter
766 \endcsname \the\theorem@bodyfont \@thm{#2}{#3}}%
767 \global \expandafter \let \csname end#1\endcsname \@endtheorem}%
772 % \subsection{Macros that are employed in a {\envfont theorem}
775 % \begin{macro}{\@thm}
776 % The macro |\@thm| has to increase the current counter. Then,
777 % depending on whether the environment has (or does not have) an
778 % optional argument, it has to branch into either |\@begintheorem|
779 % or |\@opargtheorem|.
781 \gdef\@thm#1#2{\refstepcounter{#1}%
783 % Now we start a {\envfont trivlist} environment, and give
784 % |\@topsep| and |\@topsepadd| the values of the \textsf{skip}
785 % registers |\theorempreskipamount| and |\theorempostskipamount|.
786 % The value in |\@topsep| is the vertical space that is inserted by
787 % the first (and only) |\item| in our |\trivlist| whilst
788 % |\@topsepadd| is inserted by |\@endparenv| at the end of that
789 % {\envfont trivlist} environment. By using these registers, we
790 % obtain the desired space around a {\envfont theorem} environment.
793 \@topsep \theorempreskipamount % used by first \item
794 \@topsepadd \theorempostskipamount % used by \@endparenv
796 % Now we have to test whether an optional argument has been given.
797 % \changes{v2.0d}{89/07/18}{Forgotten percent added.}
801 % If there is an optional argument, we will call |\@ythm|, and
802 % move the arguments read back into the input stream.
806 % If not, we call |\@begintheorem|. Its first argument is the
807 % name of the theorem set (hence the second argument of
808 % |\@thm|). Its second argument is the macro that produces the
811 {\@begintheorem{#2}{\csname the#1\endcsname}\ignorespaces}}
815 % \begin{macro}{\@xthm}
816 % \begin{macro}{\@ythm}
817 % Both these macros were originally called by |\@thm|. We do
818 % not need |\@xthm| anymore, hence we reset it to
819 % |\relax|. The definition of |\@ythm| has not changed at
820 % all from its definition in \LaTeX. In order to make the macros
821 % easier to understand, we will
822 % nevertheless present it (commented out).
824 \global\let\@xthm\relax
825 % \def\@ythm#1#2[#3]{\@opargbegintheorem{#2}{\csname
826 % the#1\endcsname}{#3}\ignorespaces}
829 % The primitive |\ignorespaces| in |\@ythm| and
830 % |\@thm| is needed to remove the spaces between the
831 % |\begin{...}| and the actual text.
836 % \subsection{Definition of the theorem substyles}
838 % As already pointed out, the theorem substyles, defined below, are
839 % only loaded when necessary. Note that all these substyles, except
840 % \texttt{plain}, have |\slshape| as the default body font.
842 % \subsubsection{The \texttt{plain} style}
844 % \label{dok:th@plain} As the following macros use |@|, we have
845 % to locally set the |\catcode| of this symbol to ``letter''.
846 % This happens within a group, so that we do not have to worry about
847 % which |\catcode| that symbol had before.
850 \begingroup \makeatletter
852 % Since we are now within a group, we must make all definitions
853 % globally. First we make sure that \texttt{theorem.sty} is loaded.
854 % This will allow us to use this file as a document style option
855 % without having to call \texttt{theorem} itself as an option. At the
856 % same time, we assure that at least version 2 is loaded, since
857 % |\theorem@style| was not defined in earlier versions.
859 \@ifundefined{theorem@style}{\input{theorem.sty}}{}
860 \ProvidesFile{thp.sty}
865 % \begin{macro}{\th@plain}
866 % \begin{macro}{\@begintheorem}
867 % \begin{macro}{\@opargbegintheorem}
868 % |\theoremstyle{plain}| corresponds to the original
869 % definition, except that the distances to the surrounding text are
870 % determined by the parameters |\theorempreskipamount| and
871 % |\theorempostskipamount|.
872 % First we set the default body font.
874 \gdef\th@plain{\normalfont\itshape
876 % Then we define |\@begintheorem| and
877 % |\@opargbegintheorem|. These two macros define how the
878 % header of a theorem is typeset. |\@opargbegintheorem| will
879 % be called if a \textsf{theorem} environment with an optional
880 % argument is encountered; otherwise, the header is constructed by
881 % calling |\@begintheorem|. If one of these macros is
882 % executed, we are within a \textsf{trivlist} environment started by
883 % |\@thm|. So the theorem header is produced with an
886 % Instead of specifying the header font directly, all standard
887 % theorem styles use the |\theorem@headerfont| macro to allow
888 % customization. The extra space (|\labelsep|) is necessary
889 % because of problems in the \textsf{trivlist} environment.
891 \def\@begintheorem##1##2{%
892 \item[\hskip\labelsep \theorem@headerfont ##1\ ##2]}%
894 % The definition of |\@opargbegintheorem| is completely
895 % analogous. The only difference is the fact that there exists a
896 % third argument (which is the optional parameter of the
897 % environment and contains additional information about the
898 % theorem). Customarily we enclose it in parentheses.
900 \def\@opargbegintheorem##1##2##3{%
901 \item[\hskip\labelsep \theorem@headerfont ##1\ ##2\ (##3)]}}
908 % We conclude with an |\endgroup| to restore the
916 % \subsubsection{The \texttt{break} style}
918 % This style option is stored in the file |thb.sty|.
919 % For the next two lines see the documentation for |\th@plain| on
920 % page~\pageref{dok:th@plain}.
923 \begingroup \makeatletter
924 \@ifundefined{theorem@style}{\input{theorem.sty}}{}
925 \ProvidesFile{thb.sty}
929 % \begin{macro}{\th@break}
930 % |\theoremstyle{break}| produces a line break after the name
931 % of the theorem. The font is |\slshape|. Hence, we define
932 % |\th@break| as follows:
934 \gdef\th@break{\normalfont\slshape
935 \def\@begintheorem##1##2{\item[%
937 % We run into the following problem: it is not possible to create
938 % the header with |\item[|\meta{title}|]| and then start
939 % a new line by, for example, |\mbox{}\\|. Such a definition
940 % will fail whenever a list environment follows immediately. With
941 % the above construction, the |\mbox{}| causes the switch
942 % |@inlabel| (cf.\ definition of |\list| and
943 % |\trivlist| in \cite{latex:source}) to be set to \texttt{false}
944 % and so the following list will insert additional vertical
945 % space (|\topskip|). This is quite annoying. Therefore, we
946 % create the line break within the |\item|. In order to ensure
947 % that the text will begin at the proper position in the following
948 % line, we simply pretend that the label does not take any
949 % room.\footnote{This will lead to problems whenever very high
950 % symbols occurring in the line tower into the
951 % heading. So, something else has to be done here sometime.}
953 \rlap{\vbox{\hbox{\hskip \labelsep\theorem@headerfont ##1\ ##2}%
956 % Again, the definition of |\@opargbegintheorem| is
957 % completely analogous.
959 \def\@opargbegintheorem##1##2##3{%
960 \item[\rlap{\vbox{\hbox{\hskip \labelsep \theorem@headerfont
969 % \subsubsection{The \texttt{changebreak} style}
972 % This style option is stored in the file |thcb.sty|.
975 \begingroup \makeatletter
976 \@ifundefined{theorem@style}{\input{theorem.sty}}{}
977 \ProvidesFile{thcb.sty}
981 % \begin{macro}{\th@changebreak}
982 % The \texttt{change-break} theorem style is like \texttt{break}
983 % but with interchange of theorem name and theorem number. Thus we
984 % define |\th@changebreak| as follows:
986 \gdef\th@changebreak{\normalfont\slshape
987 \def\@begintheorem##1##2{\item
988 [\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont ##2\ ##1}%
990 \def\@opargbegintheorem##1##2##3{%
991 \item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
1000 % \subsubsection{The \texttt{change} style}
1002 % This style option is stored in the file |thc.sty|.
1005 \begingroup \makeatletter
1006 \@ifundefined{theorem@style}{\input{theorem.sty}}{}
1007 \ProvidesFile{thc.sty}
1011 % \begin{macro}{\th@change}
1012 % The \texttt{change} theorem style corresponds to the
1013 % \texttt{change break} style without a linebreak after the header.
1014 % To say it in another way, it's the same as the \texttt{plain}
1015 % style but with number and name interchanged and |\slshape| as the
1018 \gdef\th@change{\normalfont\slshape
1019 \def\@begintheorem##1##2{\item
1020 [\hskip\labelsep \theorem@headerfont ##2\ ##1]}%
1021 \def\@opargbegintheorem##1##2##3{%
1022 \item[\hskip\labelsep \theorem@headerfont ##2\ ##1\ (##3)]}}
1029 % \subsubsection{The \texttt{marginbreak} style}
1031 % This style option is the one used most often at Mainz. It is saved
1032 % in the file |thmb.sty|.
1035 \begingroup \makeatletter
1036 \@ifundefined{theorem@style}{\input{theorem.sty}}{}
1037 \ProvidesFile{thmb.sty}
1041 % \begin{macro}{\th@marginbreak}
1042 % The \texttt{margin break} style is nearly the same as the
1043 % \texttt{change break} style. The only difference is the placement
1044 % of the theorem number. We use |\llap| to place it in the left
1047 % In this style |\labelsep| denotes the separation between the
1048 % number and the text.
1050 \gdef\th@marginbreak{\normalfont\slshape
1051 \def\@begintheorem##1##2{\item
1052 [\rlap{\vbox{\theorem@headerfont
1053 \hbox{\llap{##2}\hskip\labelsep ##1}%
1055 \def\@opargbegintheorem##1##2##3{%
1056 \item[\rlap{\vbox{\theorem@headerfont
1057 \hbox{\llap{##2}\hskip\labelsep ##1\ (##3)}%
1062 % \changes{v2.1c}{90/02/17}{`endgroup outside macrocode env.}
1067 % \subsubsection{The \texttt{margin} style}
1069 % This style option is stored in the file |thm.sty|.
1072 \begingroup \makeatletter
1073 \@ifundefined{theorem@style}{\input{theorem.sty}}{}
1074 \ProvidesFile{thm.sty}
1078 % \begin{macro}{\th@margin}
1079 % Again this is only a variant of the theorem styles described
1080 % above without any new ideas.
1082 \gdef\th@margin{\normalfont\slshape
1083 \def\@begintheorem##1##2{\item
1084 [\theorem@headerfont \llap{##2}\hskip\labelsep ##1]}%
1085 \def\@opargbegintheorem##1##2##3{%
1086 \item[\theorem@headerfont \llap{##2}\hskip\labelsep ##1\ (##3)]}}
1095 % \subsection{Final Definitions}
1097 % \begin{macro}{\theorempreskipamount}
1098 % \begin{macro}{\theorempostskipamount}
1099 % The \textsf{skip} parameters that regulate the vertical empty space
1100 % before and after the {\envfont theorem} environment have
1101 % to be allocated as well.
1102 % \changes{v2.0f}{89/07/20}{Unnecessary `global' removed.}
1105 \newskip\theorempreskipamount
1106 \newskip\theorempostskipamount
1108 % Since we have used the same values for all theorem sets, we now can
1111 \global\setlength\theorempreskipamount{12pt plus 5pt minus 3pt}
1112 \global\setlength\theorempostskipamount{8pt plus 3pt minus 1.5pt}
1118 % \begin{macro}{\@endtheorem}
1119 % The same holds for the macro |\@endtheorem|, which ends a
1120 % {\envfont theorem} environment. Since it is the same for all
1121 % theorem sets, it is removed from the macros |\th@|\meta{style}.
1122 % It simply ends the {\envfont trivlist} environment, which was
1125 \global\let\@endtheorem=\endtrivlist
1131 % \begin{macro}{\@preamblecmds}
1132 % All macros defined above are to be used only in the preamble.
1133 % Therefore, we insert them in |\@preamblecmds| which will disable
1134 % them at begin document. This is done by the internal \LaTeXe{}
1135 % command |\@onlypreamble|.
1136 % \changes{v2.0g}{89/09/19}{`theoremheaderfont and `theorembodyfont
1138 % \changes{v2.2a}{94/02/03}{Use \LaTeXe{} interface}
1140 \@onlypreamble\@xnthm
1141 \@onlypreamble\@ynthm
1142 \@onlypreamble\@othm
1143 \@onlypreamble\newtheorem
1144 \@onlypreamble\theoremstyle
1145 \@onlypreamble\theorembodyfont
1146 \@onlypreamble\theoremheaderfont
1150 % Finally we declare the \texttt{plain} theorem style to be the default.
1151 % \changes{v2.1b}{90/06/04}{Fixed missing `item by declaring default
1154 \theoremstyle{plain}