ltthm.dtx

Johannes Braams  David Carlisle  Alan Jeffrey
Leslie Lamport  Frank Mittelbach  Chris Rowley

Rainer Schöpf

1995/10/10

1 Theorem Environments

The user creates his own theorem-like environments with the command \newtheorem{⟨name⟩}{⟨text⟩}[⟨counter⟩] or \newtheorem{⟨name⟩}[⟨oldname⟩]{⟨text⟩} This defines the environment ⟨name⟩ to be just as one would expect a theorem environment to be, except that it prints ⟨text⟩ instead of “Theorem”.

If ⟨oldname⟩ is given, then environments ⟨name⟩ and ⟨oldname⟩ use the same counter, so using a ⟨name⟩ environment advances the number of the next ⟨name⟩ environment, and vice-versa.

If ⟨counter⟩ is given, then environment ⟨name⟩ is numbered within ⟨counter⟩. E.g., if ⟨counter⟩ = subsection, then the first ⟨name⟩ in subsection 7.2 is

numbered ⟨text⟩ 7.2.1.

The way ⟨name⟩ environments are numbered can be changed by redefining \the⟨name⟩.

DOCUMENT STYLE PARAMETERS

\@thmcounter{COUNTER} : A command such that

               \edef\theCOUNTER{\@thmcounter{COUNTER}}

defines \theCOUNTER to produce a number for a theorem environment. The default is:

            BEGIN \noexpand\arabic{COUNTER} END

\@thmcountersep : A separator placed between a theorem number and the number of the counter within which it is numbered. E.g., to make the third theorem of section 7.2 be numbered 7.2-3, \@thmcountersep should be \def'ed to ’-’. Its default is ’.’.

\@begintheorem{NAME}{NUMBER} : A command that begins a theorem environment for a ’theorem’ named ’NAME NUMBER’ – e.g., \@begintheorem{Lemma}{3.7} starts Lemma 3.7.

\@opargbegintheorem{NAME}{NUMBER}{OPARG} :

A command that begins a theorem environment for a ’theorem’ named ’NAME NUMBER’ with

optional argument OPARG – e.g., \@begintheorem{Lemma}{3.7}{Jones} starts ‘Lemma 3.7 (Jones):’.

\@endtheorem : A command that ends a theorem environment.

\newtheorem{NAME}{TEXT}[COUNTER] ==

BEGIN

if \NAME is definable

then \@definecounter{NAME}

if COUNTER present

then \@newctr{NAME}[COUNTER] fi

          \theNAME == BEGIN \theCOUNTER \@thmcountersep
                              eval\@thmcounter{NAME}

END

     else \theNAME == BEGIN eval\@thmcounter{NAME} END
   \NAME == \@thm{NAME}{TEXT}
   \endNAME == \@endtheorem

else error fi

END

\newtheorem{NAME}[OLDNAME]{TEXT}==

BEGIN

if counter OLDNAME nonexistant then ERROR else

if \NAME is definable

then BEGIN

          \theNAME == \theOLDNAME
          \NAME == \@thm{OLDNAME}{TEXT}
          \endNAME == \@endtheorem

END else error

fi fi

END

\@thm{NAME}{TEXT} == BEGIN

\refstepcounter{NAME}

if next char = [ then \@ythm{NAME}{TEXT} else \@xthm{NAME}{TEXT}

fi END

\@xthm{NAME}{TEXT} ==

BEGIN

\@begintheorem{TEXT}{\theNAME}
\ignorespaces

END

\@ythm{NAME}{TEXT}[OPARG] == BEGIN

\@opargbegintheorem{TEXT}{\theNAME}{OPARG}
\ignorespaces

END

\newtheorem \newtheorem ought really be allowed only in the preamble Which would be good document style, and allow some main memory to be saved by declaring these commands to be \@onlypreamble. Unfortunately the L^{A}TEX book indicates that \newtheorem may be used anywhere in the document…

1 ⟨∗2ekernel⟩

2 \def\newtheorem#1{%
3 \@ifnextchar[{\@othm{#1}}{\@nthm{#1}}}
\@nthm
4 \def\@nthm#1#2{%
5 \@ifnextchar[{\@xnthm{#1}{#2}}{\@ynthm{#1}{#2}}}

\@xnthm 92/09/18 RmS: Changed \@addtoreset to \@newctr to produce error message if counter #3 does not exist (to be consistent with behaviour of \newcounter)

6 \def\@xnthm#1#2[#3]{%
7 \expandafter\@ifdefinable\csname #1\endcsname
8  {\@definecounter{#1}\@newctr{#1}[#3]%
9  \expandafter\xdef\csname the#1\endcsname{%
10  \expandafter\noexpand\csname the#3\endcsname \@thmcountersep
11  \@thmcounter{#1}}%
12  \global\@namedef{#1}{\@thm{#1}{#2}}%
13  \global\@namedef{end#1}{\@endtheorem}}}
\@ynthm
14 \def\@ynthm#1#2{%
15 \expandafter\@ifdefinable\csname #1\endcsname
16  {\@definecounter{#1}%
17  \expandafter\xdef\csname the#1\endcsname{\@thmcounter{#1}}%

18  \global\@namedef{#1}{\@thm{#1}{#2}}%
19  \global\@namedef{end#1}{\@endtheorem}}}
\@othm
20 \def\@othm#1[#2]#3{%
21 \@ifundefined{c@#2}{\@nocounterr{#2}}%
22  {\expandafter\@ifdefinable\csname #1\endcsname
23  {\global\@namedef{the#1}{\@nameuse{the#2}}%
24 \global\@namedef{#1}{\@thm{#2}{#3}}%
25 \global\@namedef{end#1}{\@endtheorem}}}}
\@thm
26 \def\@thm#1#2{%
27 \refstepcounter{#1}%
28 \@ifnextchar[{\@ythm{#1}{#2}}{\@xthm{#1}{#2}}}
\@xthm \@ythm
29 \def\@xthm#1#2{%
30 \@begintheorem{#2}{\csname the#1\endcsname}\ignorespaces}
31 \def\@ythm#1#2[#3]{%
32 \@opargbegintheorem{#2}{\csname the#1\endcsname}{#3}\ignorespaces}

Default values

\@thmcounter
\@thmcountersep
33 \def\@thmcounter#1{\noexpand\arabic{#1}}
34 \def\@thmcountersep{.}
\@begintheorem \@opargbegintheorem \@endtheorem Providing theorem defaults.
35 \def\@begintheorem#1#2{\trivlist
36 \item[\hskip \labelsep{\bfseries #1\ #2}]\itshape}
37 \def\@opargbegintheorem#1#2#3{\trivlist
38  \item[\hskip \labelsep{\bfseries #1\ #2\ (#3)}]\itshape}
39 \def\@endtheorem{\endtrivlist}

40 ⟨/2ekernel⟩