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'.
27 \def\FMithmInfo{2014/10/28 v2.2c Theorem extension package (FMi)}
29 % \ProvidesFile{theorem.dtx}[\FMithmInfo]
30 %\iffalse % this is a METACOMMENT !
32 %% Package `theorem' to use with LaTeX2e
33 %% Copyright (C) 1989-1995 Frank Mittelbach, all rights reserved.
34 %<+package>\@ifundefined{theorem@style}{}{\endinput}
35 %<+package>\NeedsTeXFormat{LaTeX2e}[1995/06/01]
36 %<+package>\ProvidesPackage{theorem}
37 %<+package> [\FMithmInfo]
41 % \changes{v1.0}{87/05/07}{First draft.}
42 % \changes{v1.0a}{87/05/07}{`thistheoremstyle' added.}
43 % \changes{v1.1a}{87/07/29}{New concept: redefine the internal
44 % \protect\LaTeX{} commands `@xnthm' etc.}
45 % \changes{v1.1b}{87/07/31}{`theoremfont' used to specify font.}
46 % \changes{v1.2a}{88/01/08}{`@endtheorem' now globally defined.}
47 % \changes{v1.2b}{88/01/11}{`newtheorem' only allowed in the preamble.}
48 % \changes{v1.3a}{88/02/14}{`theoremfont' now a toks register.}
50 % \changes{v2.0a}{88/11/16}{New implementation and new documentation.}
51 % \changes{v2.0a}{88/11/16}{No layout changes but internal modifications
52 % old substyles won't work.}
53 % \changes{v2.0b}{89/01/30}{`global' used for all definitions.}
54 % \changes{v2.0c}{89/06/15}{Documentation translated to English.
55 % Thanks to LLL and Nina}
56 % \changes{v2.1a}{90/02/15}{Support for new font selection.}
57 % \changes{v2.2a}{94/02/03}{Cleanup for LaTeX2e}
59 % \DoNotIndex{\@endparenv,\@ifdefinable,\@ifnextchar,\@ifundefined}
60 % \DoNotIndex{\@namedef,\@nameuse,\@spaces,\@tempa,\@warning}
62 % \DoNotIndex{\begingroup,\bfseries}
63 % \DoNotIndex{\csname}
64 % \DoNotIndex{\def,\do,\docdate}
65 % \DoNotIndex{\endcsname,\endgroup,\endinput,\endtrivlist,\expandafter}
66 % \DoNotIndex{\filedate,\fileversion}
67 % \DoNotIndex{\gdef,\global}
68 % \DoNotIndex{\hbox,\hskip}
69 % \DoNotIndex{\ignorespaces,\input,\itshape,\item}
70 % \DoNotIndex{\labelsep,\let,\llap}
71 % \DoNotIndex{\makeatletter}
72 % \DoNotIndex{\noexpand}
73 % \DoNotIndex{\refstepcounter,\relax,\rlap}
74 % \DoNotIndex{\setlength,\slshape,\space,\string,\strut}
75 % \DoNotIndex{\the,\trivlist,\typeout}
79 % \def\deflabel#1{\ttfamily #1\hfill}
80 % \def\deflist#1{\begin{list}{}{\settowidth\labelwidth{\ttfamily #1}%
81 % \setlength\leftmargin\labelwidth
82 % \addtolength\leftmargin\labelsep
83 % \let\makelabel\deflabel}}
84 % \def\enddeflist{\end{list}}
85 % \def\envfont{\normalfont\ttfamily}
89 % \newcommand{\TUB}{{\sl TUGboat\/}}
91 % \GetFileInfo{theorem.dtx}
92 % \title{An Extension of the
93 % \LaTeX{} theorem environment\thanks{This file
94 % has version number \fileversion, last
95 % revised \filedate.}}
96 % \author{Frank Mittelbach}
98 % \MaintainedByLaTeXTeam{tools}
102 % The macros described in this paper yield an extension of the
103 % \LaTeX{} theorem mechanism. It is designed is to satisfy the
104 % different requirements of various journals. Thus, the
105 % layout of the ``theorems'' can be manipulated by determining a
106 % ``style''. This article describes not only the use, but
107 % also the definition, of the necessary macros.
110 % \section*{Preface to version 2.2}
112 % For \LaTeXe{} this package did not need any fundamental changes. I
113 % only modified the messages generated so that theorem layout styles
114 % will show up with the |\listfiles| command and cleaned the section
115 % on the New Font Selection Scheme since this is now included in
118 % \section*{Preface to version 2.1}
120 % This version is identical to 2.0g described in \TUB\ 10\#3 except
121 % for some internal defaults which are now set depending on the used
122 % font selection scheme.
124 % This was done to avoid unpleasant surprises if the new font selection
125 % scheme is in force. For further details see
126 % section~\ref{sec:newfonts} and \cite{bk:GMS94}.
128 % \section{Introduction}
130 % For our purposes here, ``theorems'' are labelled enunciations,
131 % often set off from the main text by extra space and a font change.
132 % Theorems, corollaries, conjectures, definitions, and remarks
133 % are all instances of ``theorems''. The ``header'' of these structures
134 % is composed of a label (such as \textsc{Theorem} or \textsc{Remark})
135 % and a number which serializes an item in the sequence of items
136 % with the same label.
138 % Shortly after the introduction of \LaTeX{} at the Fachbereich
139 % Mathematik in Mainz, the desire to manipulate the layout of
140 % ``theorems'' arose. In Mainz, the following two conventions came
143 % \item The number of the theorem is shown in the margin.
144 % \item There is a line break at
145 % the end of the theorem header.
148 % Additionally, some journals require different formats which depend on
149 % the ``sort of theorem'': e.g.\ often remarks and definitions are set
150 % in |\upshape|, while |\itshape| is employed for main theorems.
152 % Confronted with these requirements, a theorem environment was
153 % developed in Mainz which allows separate determination of the
154 % layout of the ``theorems sets'', comparable to |\pagestyle|.
157 % \section{The user interface}
158 % \subsection{Defining new theorem sets}
160 % \DescribeMacro\newtheorem
161 % As in the original \LaTeX{} version, the command |\newtheorem|
162 % defines a new ``theorem set'' or ``theorem-like structure''.
163 % Two required arguments name the new environment and give the text
164 % to be typeset with each instance of the new ``set'', while
165 % an optional argument determines how
166 % the ``set'' is enumerated:
167 % \begin{description}
168 % \item[\ttfamily \bslash newtheorem\{foo\}\{bar\}]
169 % The theorem set {\envfont foo} (whose name is \texttt{bar})
170 % uses its own counter.
171 % \item[\ttfamily \bslash newtheorem\{foo2\}{[foo]}\{bar2\}]
172 % The theorem set {\envfont foo2} (printed name \texttt{bar2})
173 % uses the same counter as the theorem set \texttt{foo}.
174 % \item[\ttfamily \bslash newtheorem\{foo3\}\{bar3\}{[section]}]
175 % The theorem set {\envfont foo3} (printed name \texttt{bar3}) is
176 % enumerated within the counter \texttt{section}, i.e.\ with every
177 % new |\section| the enumeration begins again with 1, and
178 % the enumeration is composed from the section-number and the
179 % theorem counter itself.
182 % \DescribeMacro\theoremstyle
183 % Additionally, the command |\theoremstyle| can define the layout
184 % of various, or all, theorem sets. It should be noted that any
185 % theorem set defined by |\newtheorem| is typeset in the
186 % |\theoremstyle| that is current at the time of the definition.
187 % Thus, the following
189 % \theoremstyle{break} \newtheorem{Cor}{Corollary}
190 % \theoremstyle{plain} \newtheorem{Exa}{Example}[section]
191 %\end{verbatim} ^^A No blank at line start
192 % leads to the result that the set {\envfont Cor} is formatted in the
193 % style \texttt{break}, while the set {\envfont Exa} and all the
194 % following ones are formatted in the style \texttt{plain}, unless
195 % another |\theoremstyle| follows. Since the definitions installed by
196 % |\newtheorem| are global, one also can limit |\theoremstyle| locally
197 % by grouping braces.
199 % \DescribeMacro\theorembodyfont
200 % The choice of the font for the theorem body is completely
201 % independent of the chosen |\theoremstyle|; this has proven to
202 % be very advantageous. For example,
204 % {\theorembodyfont{\upshape} \newtheorem{Rem}{Remark}}
206 % defines a theorem set {\envfont Rem}, which will be set in
207 % |\upshape| in the current layout (which in our example is
208 % \texttt{plain}). As with |\theoremstyle|, the |\theorembodyfont|
209 % chosen is that current at the time of |\newtheorem|. If
210 % |\theorembodyfont| is not specified or one defines
211 % |\theorembodyfont{}|, then the font used will be that defined by the
214 % \DescribeMacro\theoremheaderfont It is also possible to customize
215 % the font used for the theorem headers. This is, however, a global
216 % declaration, and therefore there should be at most one
217 % |\theoremheaderfont| declaration in the preamble.\footnote{If it is
218 % actually necessary to have different header fonts, one has to define
219 % new theorem styles (substituting the desired font) or specify the
220 % information directly in the \texttt{\bslash newtheorem} declaration
221 % (the unclean variant).}
223 % \DescribeMacro\theorempreskipamount
224 % \DescribeMacro\theorempostskipamount Two additional parameters
225 % affect the vertical space around the theorem environments:
226 % |\theorempreskipamount| and |\theorempostskipamount| define,
227 % respectively, the spacing before and after such an environment.
228 % These parameters apply for all theorem sets and can be manipulated
229 % with the ordinary length macros. They are rubber lengths,
230 % (`\textsf{skips}'), and therefore can contain \texttt{plus} and
231 % \texttt{minus} parts.
233 % Since the definition of theorem sets should---most sensibly---be
234 % placed in the preamble, we only allow installation there.
235 % It is therefore possible to release the memory used here after
236 % |\begin{document}|, in order to make room for other
240 % \subsection{Existing theorem styles}
242 % The following theorem styles exist to date:
243 % \begin{deflist}{marginbreak}
245 % This theorem style emulates the original \LaTeX{} definition,
246 % except that additionally the parameters
247 % |\theorem...skipamount| are used.
249 % In this style, the theorem header is followed by a line
252 % The theorem number is set in the margin, and there is a line
253 % break as in \texttt{break}.
255 % Like \texttt{break}, but with header number and text
258 % Header number and text are interchanged, without a line break.
260 % The number is set in the left margin, without a line break.
262 % All styles (except \texttt{plain}) select |\slshape| as the default
263 % |\theorembodyfont|.
266 % \subsection{Examples}
268 % Given the above theorem sets {\envfont Cor}, {\envfont Exa}
269 % and {\envfont Rem},
270 % suppose that the preamble also contains the declarations:
272 % \theoremstyle{marginbreak} \newtheorem{Lem}[Cor]{Lemma}
273 % \theoremstyle{change}
274 % \theorembodyfont{\itshape} \newtheorem{Def}[Cor]{Definition}
276 % \theoremheaderfont{\scshape}
278 % Then the following are some typical examples of the typeset output
279 % resulting from their use.
282 % This is a sentence typeset in the theorem environment {\envfont
287 % This is a sentence typeset in the theorem environment {\envfont
292 % This is a sentence typeset in the theorem environment {\envfont
296 % \begin{Lem}[Ben User]
297 % This is a sentence typeset in the theorem environment {\envfont
301 % \begin{Def}[Very impressive Definition]
302 % This is a sentence typeset in the theorem environment {\envfont
306 % The last two examples show the effect of the optional argument to
307 % a theorem environment (it is the text typeset in parentheses).
310 % \section{Special Considerations}
311 % \label{sec:newfonts}
313 % Theoremheader and body are implemented as a unit. This means that
314 % the |\theoremheaderfont| will inherit characteristics of the
315 % |\theorembodyfont| in \LaTeXe. Thus, if for example
316 % |\theorembodyfont| is |\itshape| and |\theoremheaderfont|
317 % is |\bfseries| the font selected for the header will have the
318 % characteristics `bold extended italic'. If this is not desired one
319 % should set the |\theoremheaderfont| to something like
321 % \theoremheaderfont{\normalfont\bfseries}
323 % i.e.\ supplying all necessary font information explicitly.
327 % \section{Acknowledgements}
329 % The publication of this set of macros was only possible with the
330 % help of Christina Busse (translating the manuscript into English),
331 % Joachim Pense (playing the r\^ole of typist), Chris Rowley
332 % (looking everything over) and many others providing useful
336 % \begin{thebibliography}{9}
337 % \bibitem{bk:GMS94} \textsc{M.~Goossens}, \textsc{F.~Mittelbach}
338 % and \textsc{A.~Samarin}.
339 % \newblock The \LaTeX{} Companion.
341 % Addison-Wesley, Reading, Massachusetts, 1994.
342 % \bibitem{latex:source} \textsc{Lamport, Leslie.} \newblock
343 % \texttt{latex.tex}, version 2.09, date
345 % \end{thebibliography}
350 % \section{The documentation driver file}
352 % The next bit of code contains the documentation driver file for
353 % \TeX{}, i.e., the file that will produce the documentation you are
354 % currently reading. It will be extracted from this file by the
355 % \texttt{docstrip} program. Since it is the first code in the file
356 % one can alternatively process this file directly with \LaTeXe{} to
357 % obtain the documentation.
361 \documentclass{ltxdoc}
365 %<+driver>% The next few lines define theorem sets which are used
366 %<+driver>% in the example section of the documentation.
368 \theoremstyle{break} \newtheorem{Cor}{Corollary}
369 \theoremstyle{plain} \newtheorem{Exa}{Example}[section]
370 {\theorembodyfont{\upshape}\newtheorem{Rem}{Remark}}
371 \theoremstyle{marginbreak} \newtheorem{Lem}[Cor]{Lemma}
372 \theoremstyle{change}
373 \theorembodyfont{\itshape} \newtheorem{Def}[Cor]{Definition}
375 \theoremheaderfont{\scshape}
380 \DocInput{theorem.dtx}
385 % \section{Definition of the Macros}
387 % If the file has been loaded before, we abort immediately. If not the
388 % package announces itself (this is actually done at the very top if
389 % the file---the way it is done isn't good style so don't copy it).
390 % \changes{v2.0e}{89/07/19}{Spaces removed from `typeout'.}
391 % \changes{v2.2b}{95/11/19}{Announce moved to top of file}
394 %\@ifundefined{theorem@style}{}{\endinput}
395 %\def\FMithmInfo{1995/11/19 v2.2b Theorem extension package (FMi)}
396 %\ProvidesPackage{theorem}[\FMithmInfo]
400 % \subsection{Definition of theorem styles and fonts}
402 % All the definitions in this file are done globally to allow
403 % inputting this file inside a group.
405 % \begin{macro}{\theoremstyle}
406 % Before a theorem style can be installed, the chosen style must be
407 % known. For that reason, we must test to see that
408 % |\th@|\meta{style} is known or, more precisely, that it is
409 % different from |\relax|. If the style is not known then
410 % |\th@plain| is used.
412 \gdef\theoremstyle#1{%
413 \@ifundefined{th@#1}{\@warning
414 {Unknown theoremstyle `#1'. Using `plain'}%
415 \theorem@style{plain}}%
417 % We save the theorem style to be used in the token register
420 {\theorem@style{#1}}%
422 % Now we ``evaluate'' the theorem style: this means, we call the
423 % macro |\th@|\meta{style} which will activate the relevant
424 % definitions which are contained in a separate file. This is done
425 % in a group to suppress changes to the current font. This could
426 % otherwise pose problems together with the new font selection
427 % scheme\footnote{When I printed the original article using the new
428 % font selection scheme I ended with a document with slanted
429 % typefaces (text headings and all) simply because one of the
430 % theorem styles used \texttt{\bslash sl} at toplevel.} if the
431 % |\th@|\meta{style} is evaluated a second time.
432 % \changes{v2.1a}{90/02/15}{Group added around `th@..}
433 % \changes{v2.1a}{90/02/15}{Reseting of `..@begintheorem removed.}
436 \csname th@\the\theorem@style \endcsname
442 % \begin{macro}{\@begintheorem}
443 % \changes{v2.1a}{90/02/15}{Relaxed at toplevel.}
444 % \begin{macro}{\@opargbegintheorem}
445 % \changes{v2.1a}{90/02/15}{Relaxed at toplevel.}
446 % We reset |\@begintheorem| and |\@opargbegintheorem| to
447 % |\relax| since these commands are no longer necessary at
448 % toplevel. This will save a few tokens.
450 \global\let\@begintheorem\relax
451 \global\let\@opargbegintheorem\relax
456 % \begin{macro}{\theorem@style}
457 % Obviously the \textsf{token} register used above has to be
458 % allocated. To assure the utmost compatibility with the
459 % original \LaTeX{} definition, we set the default theorem style to
460 % \texttt{plain}, which implements the usual \LaTeX{} convention.
461 % \changes{v2.0f}{89/07/20}{Unnecessary `global' removed.}
463 \newtoks\theorem@style
464 \global\theorem@style{plain}
468 % \begin{macro}{\theorembodyfont}
469 % \begin{macro}{\theorem@bodyfont}
470 % If the |\theorembodyfont| is set by the user then it should not
471 % interact with the default font set in the theorem style. When the
472 % new font selection is in force this may happen if, for example,
473 % the default is |\itshape| and the new |\theorembodyfont| is
474 % |\sffamily|. So we add a |\reset@font| command in front of the
476 % \changes{v2.0f}{89/07/20}{Unnecessary `global' removed.}
477 % \changes{v2.0g}{89/09/19}{`theoremfont to `theorembodyfont.}
478 % \changes{v2.1c}{92/06/22}{`reset@font added and logic changed.}
479 % \changes{v2.1d}{92/10/28}{Reset to empty if arg is empty}
481 \gdef\theorembodyfont#1{%
483 % We check if the argument supplied is empty and if so put nothing
484 % into the |\theorem@bodyfont| token register to allow for
485 % |\theorembodyfont{}| as a mean of using the default of the
486 % current |\theoremstyle|.
492 \theorem@bodyfont{\reset@font#1}%
495 \newtoks\theorem@bodyfont
496 \global\theorem@bodyfont{}
502 % \begin{macro}{\theoremheaderfont}
503 % \changes{v2.0g}{89/09/19}{Macro added.}
504 % The font for the theorem headers is handled differently because
505 % this definition applies to all theorem styles.
507 \gdef\theoremheaderfont#1{\gdef\theorem@headerfont{#1}%
509 % After using the macro once it is redefined to produce an error
512 \gdef\theoremheaderfont##1{%
513 \typeout{\string\theoremheaderfont\space should be used
518 % \begin{macro}{\theorem@headerfont}
519 % \changes{v2.0g}{89/09/19}{Macro added.}
520 % To set the |\theorem@headerfont| default we first test if
521 % the new fontselection scheme is in force.
522 % \changes{v2.1a}{90/02/15}{Support for new font selection.}
524 \ifx\upshape\undefined
526 % If not we define it to expand into |\bfseries|. We don't use
527 % |\let| just in case a following style option redefines this
530 \gdef\theorem@headerfont{\bfseries}
532 % Otherwise we reset the current shape before calling |\bfseries|.
534 \else \gdef\theorem@headerfont{\normalfont\bfseries}\fi
538 % \begin{macro}{\th@plain}
539 % \begin{macro}{\th@break}
540 % \begin{macro}{\th@marginbreak}
541 % \begin{macro}{\th@changebreak}
542 % \begin{macro}{\th@change}
543 % \begin{macro}{\th@margin}
544 % The different styles are defined in macros such as
545 % |\th@plain|. Since memory space is precious in
546 % ``non-Big-versions'', we have to avoid offering too many unused
547 % definitions. Therefore we define these styles in separate files
548 % that can be loaded on demand. Thus the commands themselves only
549 % load these files. We use |\@input@| a \LaTeXe{} internal command
550 % that ensures that the file will be listed with |\listfiles|
551 % \changes{v2.2a}{94/02/02}{Use `@input@ to load theorem layout files}
553 \gdef\th@plain{\@input@{thp.sty}}
554 \gdef\th@break{\@input@{thb.sty}}
555 \gdef\th@marginbreak{\@input@{thmb.sty}}
556 \gdef\th@changebreak{\@input@{thcb.sty}}
557 \gdef\th@change{\@input@{thc.sty}}
558 \gdef\th@margin{\@input@{thm.sty}}
560 % This list will be expanded when new styles become
561 % available. For testing, just append new theorem substyles
562 % as document options.
572 % \subsection{Definition of a new theorem set}
574 % As already pointed out, a new theorem environment can be defined in
575 % three different ways:
577 % \newtheorem{Lem}{Lemma}
578 % \newtheorem{Lem}{Lemma}[section]
579 % \newtheorem{Lem}[Theorem]{Lemma}
581 % The function of the macro |\newtheorem| is to recognize these cases
582 % and then to branch into one of the three macros |\@ynthm|, |\@xnthm|
583 % or |\@othm|. This mechanism is adopted unchanged from
584 % \cite{latex:source}; the essential point here is that, for example,
585 % in the second case, the arguments \texttt{Lem}, \texttt{Lemma} and
586 % \texttt{section} are passed over to the macro |\@xnthm|.
588 % We inspect this case first because the others present fewer problems,
589 % and thus are easily derived from this one.
591 % \begin{macro}{\@xnthm}
592 % For our example arguments, the macro |\@xnthm| must fulfill
596 % Define a new \LaTeX-counter `Lem'
598 % reset this counter within a |\section|
600 % define the macro |\theLem|
602 % define the environment macros |\Lem| and
603 % |\endLem| using the current
604 % |\theoremstyle| and |\theorem@bodyfont|.
606 % Obviously, all this should happen only if the first argument
607 % of |\@xnthm| (i.e.\ \texttt{Lem} in our example) is chosen so
608 % as not to conflict with any previously defined commands or
609 % environments. This test is performed by the \LaTeX{} macro
612 \gdef\@xnthm#1#2[#3]{\expandafter\@ifdefinable\csname #1\endcsname
614 % Therefore, the first argument of |\@ifdefinable| is the
615 % expansion (in the example, |\Lem|) of
616 % |\csname||#1\endcsname|. The second argument is
617 % executed only if the test has been completed successfully.
621 % Now we define the new counter. The names of the \LaTeX{}
622 % macros employed should speak for themselves:
623 % \changes{v2.2b}{1995/10/07}{Use \cs{@newctr}}
624 % \changes{v2.2c}{1995/11/23}{Use \cs{@newctr} properly.}
626 \@definecounter{#1}\@newctr{#1}[#3]%
628 % Using |\@newctr| will give a proper error message if the counter
629 % in |#3| is not defined.
630 % In defining `|\theLem|' we must generate the desired macro
631 % name by use of |\expandafter| and |\csname|.
633 \expandafter\xdef\csname the#1\endcsname
635 % An |\xdef| is used in order to make the definition global,
636 % and to ensure that it contains the replacement texts of
637 % |\@thmcountersep| and |\@thmcounter|.\footnote{These
638 % two macros can be defined by the document style. Their default
639 % values produce a `\texttt{.}' as separation and an arabic
640 % representation of the number.} However, not everything should be
641 % expanded. For example, it saves space to use |\thesection|
642 % instead of its---at times---lengthy expansion.
644 {\expandafter \noexpand \csname the#3\endcsname
645 \@thmcountersep \@thmcounter{#1}}%
647 % Thus with the defaults of \LaTeX{}, |\theLem| would be
648 % replaced by the command sequence |\thesection.\arabic{Lem}|.
650 % We will now look at the definition of the macro which is executed
651 % at the beginning of the actual environment (in our example this
652 % macro is |\Lem|). It should be noted that we use an
653 % ``|\expandafter| trick'' to expand only certain parts of the
654 % replacement text at the time of the definition.
656 \def\@tempa{\global\@namedef{#1}}%
657 \expandafter \@tempa \expandafter{%
659 % First, the macro that contains the current definitions of
660 % |\@begintheorem| and |\@opargtheorem| should be called
661 % up. The name of this macro---as is already known---has the form
662 % |\th@|\meta{theorem\ style}; therefore, it must be called by
664 \csname th@\the \theorem@style
666 % In addition the default theorem font should be changeable, i.e.\
667 % we have to insert the contents of |\theorem@bodyfont|. For
668 % that reason, we expand even further, beyond |\endcsname|,
669 % and thus insert the contents of the \textsf{token} register
670 % |\theorem@bodyfont| in the replacement text.
672 \expandafter \endcsname \the \theorem@bodyfont
674 % Now it is time to call the macro |\@thm| which takes over
675 % the further processing. It has two arguments: the current
676 % counter name (in our example, \texttt{Lem}), and the text of the
677 % label (in our example, \texttt{Lemma}).
681 % With this, the `sub-definition' is complete. The macro
682 % |\@endtheorem| ends a theorem environment and is, so far, nothing
683 % but an |\endtrivlist|. (Hence it is defined globally, and not
684 % within the theorem styles.\footnote{This has to be changed as
685 % soon as theorem styles that change \texttt{\bslash @endtheorem}
686 % exist. In such a case, all existing styles must be changed as
687 % well since they will have to reset the macro.}) Therefore, we can
688 % set it equivalent to the macro that ends the theorem set (in our
689 % example, |\endLem|). However, if some day theorem styles exist
690 % that do change |\@endtheorem|, we would have to use the
691 % commented-out line instead.
693 \global \expandafter \let \csname end#1\endcsname \@endtheorem
694 % \global\@namedef{end#1}{\@endtheorem}%
696 % With these commands all the required definitions are employed,
697 % unless the test |\@ifdefinable| has failed. Therefore, we
698 % end the second argument of this macro and with it the definition
705 % \begin{macro}{\@ynthm}
706 % The definition of |\@ynthm| is completely analogous. In
707 % this case the new counter that is defined is not reset within
708 % another counter; thus the definition of |\the...|
711 \gdef\@ynthm#1#2{\expandafter\@ifdefinable\csname #1\endcsname
712 {\@definecounter{#1}%
713 \expandafter\xdef\csname the#1\endcsname{\@thmcounter{#1}}%
715 % The rest of the definition corresponds literally to that of
718 \def\@tempa{\global\@namedef{#1}}\expandafter \@tempa
719 \expandafter{\csname th@\the \theorem@style \expandafter
720 \endcsname \the\theorem@bodyfont \@thm{#1}{#2}}%
721 \global \expandafter \let \csname end#1\endcsname \@endtheorem}}
725 % \begin{macro}{\@othm}
726 % The definition of |\@othm| does not contain anything new.
728 \gdef\@othm#1[#2]#3{%
730 % \changes{v2.2b}{95/10/07}{Build in check for counter defined}
731 % We do not define a new counter but instead use one that has
732 % already been defined. Thus the only definition we need is that
733 % of this pseudo-counter (i.e.\ |\the|\meta{env.\ name}).
734 % First we check if |#2| corresponds to a known counter name.
736 \expandafter\ifx\csname c@#2\endcsname\relax
739 \expandafter\@ifdefinable\csname #1\endcsname
740 {\expandafter \xdef \csname the#1\endcsname
741 {\expandafter \noexpand \csname the#2\endcsname}%
743 % All other parts of the definition can be adopted from
744 % |\@xnthm|. We have to remember, though, that in this case
745 % the name of the current counter and the theorem label have moved
746 % to the second and third arguments.
748 \def\@tempa{\global\@namedef{#1}}\expandafter \@tempa
749 \expandafter{\csname th@\the \theorem@style \expandafter
750 \endcsname \the\theorem@bodyfont \@thm{#2}{#3}}%
751 \global \expandafter \let \csname end#1\endcsname \@endtheorem}%
756 % \subsection{Macros that are employed in a {\envfont theorem}
759 % \begin{macro}{\@thm}
760 % The macro |\@thm| has to increase the current counter. Then,
761 % depending on whether the environment has (or does not have) an
762 % optional argument, it has to branch into either |\@begintheorem|
763 % or |\@opargtheorem|.
765 \gdef\@thm#1#2{\refstepcounter{#1}%
767 % Now we start a {\envfont trivlist} environment, and give
768 % |\@topsep| and |\@topsepadd| the values of the \textsf{skip}
769 % registers |\theorempreskipamount| and |\theorempostskipamount|.
770 % The value in |\@topsep| is the vertical space that is inserted by
771 % the first (and only) |\item| in our |\trivlist| whilst
772 % |\@topsepadd| is inserted by |\@endparenv| at the end of that
773 % {\envfont trivlist} environment. By using these registers, we
774 % obtain the desired space around a {\envfont theorem} environment.
777 \@topsep \theorempreskipamount % used by first \item
778 \@topsepadd \theorempostskipamount % used by \@endparenv
780 % Now we have to test whether an optional argument has been given.
781 % \changes{v2.0d}{89/07/18}{Forgotten percent added.}
785 % If there is an optional argument, we will call |\@ythm|, and
786 % move the arguments read back into the input stream.
790 % If not, we call |\@begintheorem|. Its first argument is the
791 % name of the theorem set (hence the second argument of
792 % |\@thm|). Its second argument is the macro that produces the
795 {\@begintheorem{#2}{\csname the#1\endcsname}\ignorespaces}}
799 % \begin{macro}{\@xthm}
800 % \begin{macro}{\@ythm}
801 % Both these macros were originally called by |\@thm|. We do
802 % not need |\@xthm| anymore, hence we reset it to
803 % |\relax|. The definition of |\@ythm| has not changed at
804 % all from its definition in \LaTeX. In order to make the macros
805 % easier to understand, we will
806 % nevertheless present it (commented out).
808 \global\let\@xthm\relax
809 % \def\@ythm#1#2[#3]{\@opargbegintheorem{#2}{\csname
810 % the#1\endcsname}{#3}\ignorespaces}
813 % The primitive |\ignorespaces| in |\@ythm| and
814 % |\@thm| is needed to remove the spaces between the
815 % |\begin{...}| and the actual text.
820 % \subsection{Definition of the theorem substyles}
822 % As already pointed out, the theorem substyles, defined below, are
823 % only loaded when necessary. Note that all these substyles, except
824 % \texttt{plain}, have |\slshape| as the default body font.
826 % \subsubsection{The \texttt{plain} style}
828 % \label{dok:th@plain} As the following macros use |@|, we have
829 % to locally set the |\catcode| of this symbol to ``letter''.
830 % This happens within a group, so that we do not have to worry about
831 % which |\catcode| that symbol had before.
834 \begingroup \makeatletter
836 % Since we are now within a group, we must make all definitions
837 % globally. First we make sure that \texttt{theorem.sty} is loaded.
838 % This will allow us to use this file as a document style option
839 % without having to call \texttt{theorem} itself as an option. At the
840 % same time, we assure that at least version 2 is loaded, since
841 % |\theorem@style| was not defined in earlier versions.
843 \@ifundefined{theorem@style}{\input{theorem.sty}}{}
844 \ProvidesFile{thp.sty}
849 % \begin{macro}{\th@plain}
850 % \begin{macro}{\@begintheorem}
851 % \begin{macro}{\@opargbegintheorem}
852 % |\theoremstyle{plain}| corresponds to the original
853 % definition, except that the distances to the surrounding text are
854 % determined by the parameters |\theorempreskipamount| and
855 % |\theorempostskipamount|.
856 % First we set the default body font.
858 \gdef\th@plain{\normalfont\itshape
860 % Then we define |\@begintheorem| and
861 % |\@opargbegintheorem|. These two macros define how the
862 % header of a theorem is typeset. |\@opargbegintheorem| will
863 % be called if a \textsf{theorem} environment with an optional
864 % argument is encountered; otherwise, the header is constructed by
865 % calling |\@begintheorem|. If one of these macros is
866 % executed, we are within a \textsf{trivlist} environment started by
867 % |\@thm|. So the theorem header is produced with an
870 % Instead of specifying the header font directly, all standard
871 % theorem styles use the |\theorem@headerfont| macro to allow
872 % customization. The extra space (|\labelsep|) is necessary
873 % because of problems in the \textsf{trivlist} environment.
875 \def\@begintheorem##1##2{%
876 \item[\hskip\labelsep \theorem@headerfont ##1\ ##2]}%
878 % The definition of |\@opargbegintheorem| is completely
879 % analogous. The only difference is the fact that there exists a
880 % third argument (which is the optional parameter of the
881 % environment and contains additional information about the
882 % theorem). Customarily we enclose it in parentheses.
884 \def\@opargbegintheorem##1##2##3{%
885 \item[\hskip\labelsep \theorem@headerfont ##1\ ##2\ (##3)]}}
892 % We conclude with an |\endgroup| to restore the
900 % \subsubsection{The \texttt{break} style}
902 % This style option is stored in the file |thb.sty|.
903 % For the next two lines see the documentation for |\th@plain| on
904 % page~\pageref{dok:th@plain}.
907 \begingroup \makeatletter
908 \@ifundefined{theorem@style}{\input{theorem.sty}}{}
909 \ProvidesFile{thb.sty}
913 % \begin{macro}{\th@break}
914 % |\theoremstyle{break}| produces a line break after the name
915 % of the theorem. The font is |\slshape|. Hence, we define
916 % |\th@break| as follows:
918 \gdef\th@break{\normalfont\slshape
919 \def\@begintheorem##1##2{\item[%
921 % We run into the following problem: it is not possible to create
922 % the header with |\item[|\meta{title}|]| and then start
923 % a new line by, for example, |\mbox{}\\|. Such a definition
924 % will fail whenever a list environment follows immediately. With
925 % the above construction, the |\mbox{}| causes the switch
926 % |@inlabel| (cf.\ definition of |\list| and
927 % |\trivlist| in \cite{latex:source}) to be set to \texttt{false}
928 % and so the following list will insert additional vertical
929 % space (|\topskip|). This is quite annoying. Therefore, we
930 % create the line break within the |\item|. In order to ensure
931 % that the text will begin at the proper position in the following
932 % line, we simply pretend that the label does not take any
933 % room.\footnote{This will lead to problems whenever very high
934 % symbols occurring in the line tower into the
935 % heading. So, something else has to be done here sometime.}
937 \rlap{\vbox{\hbox{\hskip \labelsep\theorem@headerfont ##1\ ##2}%
940 % Again, the definition of |\@opargbegintheorem| is
941 % completely analogous.
943 \def\@opargbegintheorem##1##2##3{%
944 \item[\rlap{\vbox{\hbox{\hskip \labelsep \theorem@headerfont
953 % \subsubsection{The \texttt{changebreak} style}
956 % This style option is stored in the file |thcb.sty|.
959 \begingroup \makeatletter
960 \@ifundefined{theorem@style}{\input{theorem.sty}}{}
961 \ProvidesFile{thcb.sty}
965 % \begin{macro}{\th@changebreak}
966 % The \texttt{change-break} theorem style is like \texttt{break}
967 % but with interchange of theorem name and theorem number. Thus we
968 % define |\th@changebreak| as follows:
970 \gdef\th@changebreak{\normalfont\slshape
971 \def\@begintheorem##1##2{\item
972 [\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont ##2\ ##1}%
974 \def\@opargbegintheorem##1##2##3{%
975 \item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
984 % \subsubsection{The \texttt{change} style}
986 % This style option is stored in the file |thc.sty|.
989 \begingroup \makeatletter
990 \@ifundefined{theorem@style}{\input{theorem.sty}}{}
991 \ProvidesFile{thc.sty}
995 % \begin{macro}{\th@change}
996 % The \texttt{change} theorem style corresponds to the
997 % \texttt{change break} style without a linebreak after the header.
998 % To say it in another way, it's the same as the \texttt{plain}
999 % style but with number and name interchanged and |\slshape| as the
1002 \gdef\th@change{\normalfont\slshape
1003 \def\@begintheorem##1##2{\item
1004 [\hskip\labelsep \theorem@headerfont ##2\ ##1]}%
1005 \def\@opargbegintheorem##1##2##3{%
1006 \item[\hskip\labelsep \theorem@headerfont ##2\ ##1\ (##3)]}}
1013 % \subsubsection{The \texttt{marginbreak} style}
1015 % This style option is the one used most often at Mainz. It is saved
1016 % in the file |thmb.sty|.
1019 \begingroup \makeatletter
1020 \@ifundefined{theorem@style}{\input{theorem.sty}}{}
1021 \ProvidesFile{thmb.sty}
1025 % \begin{macro}{\th@marginbreak}
1026 % The \texttt{margin break} style is nearly the same as the
1027 % \texttt{change break} style. The only difference is the placement
1028 % of the theorem number. We use |\llap| to place it in the left
1031 % In this style |\labelsep| denotes the separation between the
1032 % number and the text.
1034 \gdef\th@marginbreak{\normalfont\slshape
1035 \def\@begintheorem##1##2{\item
1036 [\rlap{\vbox{\theorem@headerfont
1037 \hbox{\llap{##2}\hskip\labelsep ##1}%
1039 \def\@opargbegintheorem##1##2##3{%
1040 \item[\rlap{\vbox{\theorem@headerfont
1041 \hbox{\llap{##2}\hskip\labelsep ##1\ (##3)}%
1046 % \changes{v2.1c}{90/02/17}{`endgroup outside macrocode env.}
1051 % \subsubsection{The \texttt{margin} style}
1053 % This style option is stored in the file |thm.sty|.
1056 \begingroup \makeatletter
1057 \@ifundefined{theorem@style}{\input{theorem.sty}}{}
1058 \ProvidesFile{thm.sty}
1062 % \begin{macro}{\th@margin}
1063 % Again this is only a variant of the theorem styles described
1064 % above without any new ideas.
1066 \gdef\th@margin{\normalfont\slshape
1067 \def\@begintheorem##1##2{\item
1068 [\theorem@headerfont \llap{##2}\hskip\labelsep ##1]}%
1069 \def\@opargbegintheorem##1##2##3{%
1070 \item[\theorem@headerfont \llap{##2}\hskip\labelsep ##1\ (##3)]}}
1079 % \subsection{Final Definitions}
1081 % \begin{macro}{\theorempreskipamount}
1082 % \begin{macro}{\theorempostskipamount}
1083 % The \textsf{skip} parameters that regulate the vertical empty space
1084 % before and after the {\envfont theorem} environment have
1085 % to be allocated as well.
1086 % \changes{v2.0f}{89/07/20}{Unnecessary `global' removed.}
1089 \newskip\theorempreskipamount
1090 \newskip\theorempostskipamount
1092 % Since we have used the same values for all theorem sets, we now can
1095 \global\setlength\theorempreskipamount{12pt plus 5pt minus 3pt}
1096 \global\setlength\theorempostskipamount{8pt plus 3pt minus 1.5pt}
1102 % \begin{macro}{\@endtheorem}
1103 % The same holds for the macro |\@endtheorem|, which ends a
1104 % {\envfont theorem} environment. Since it is the same for all
1105 % theorem sets, it is removed from the macros |\th@|\meta{style}.
1106 % It simply ends the {\envfont trivlist} environment, which was
1109 \global\let\@endtheorem=\endtrivlist
1115 % \begin{macro}{\@preamblecmds}
1116 % All macros defined above are to be used only in the preamble.
1117 % Therefore, we insert them in |\@preamblecmds| which will disable
1118 % them at begin document. This is done by the internal \LaTeXe{}
1119 % command |\@onlypreamble|.
1120 % \changes{v2.0g}{89/09/19}{`theoremheaderfont and `theorembodyfont
1122 % \changes{v2.2a}{94/02/03}{Use \LaTeXe{} interface}
1124 \@onlypreamble\@xnthm
1125 \@onlypreamble\@ynthm
1126 \@onlypreamble\@othm
1127 \@onlypreamble\newtheorem
1128 \@onlypreamble\theoremstyle
1129 \@onlypreamble\theorembodyfont
1130 \@onlypreamble\theoremheaderfont
1134 % Finally we declare the \texttt{plain} theorem style to be the default.
1135 % \changes{v2.1b}{90/06/04}{Fixed missing `item by declaring default
1138 \theoremstyle{plain}