%%% ==================================================================== %%% @LaTeX-file{ %%% filename = "amsthm.dtx", %%% version = "1.2beta", %%% date = "1994/10/27", %%% time = "11:25:13 EDT", %%% author = "American Mathematical Society", %%% copyright = "Copyright (C) 1994 American Mathematical Society, %%% all rights reserved. Copying of this file is %%% authorized only if either: %%% (1) you make absolutely no changes to your copy, %%% including name; OR %%% (2) if you do make changes, you first rename it %%% to some other name.", %%% address = "American Mathematical Society, %%% Technical Support, %%% Electronic Products and Services, %%% P. O. Box 6248, %%% Providence, RI 02940, %%% USA", %%% telephone = "401-455-4080 or (in the USA and Canada) %%% 800-321-4AMS (321-4267)", %%% FAX = "401-331-3842", %%% checksum = "01388 549 2338 19979", %%% email = "tech-support@math.ams.org (Internet)", %%% codetable = "ISO/ASCII", %%% keywords = "latex, amslatex, ams-latex, theorem", %%% supported = "yes", %%% abstract = "This is part of the AMS-\LaTeX{} distribution. %%% It is a package which provides multiple %%% theorem styles, unnumbered theorem types, and %%% a proof environment with automatic ending %%% Q.E.D. symbol. Loosely derived from %%% Mittelbach's theorem.sty.", %%% docstring = "The checksum field above contains a CRC-16 %%% checksum as the first value, followed by the %%% equivalent of the standard UNIX wc (word %%% count) utility output of lines, words, and %%% characters. This is produced by Robert %%% Solovay's checksum utility.", %%% } %%% ==================================================================== % \iffalse % The following section of code makes this file self-printable. % \begin{macrocode} %<*driver> \NeedsTeXFormat{LaTeX2e} \documentclass{amsdtx} \begin{document} \title{The \pkg{amsthm} package} \author{American Mathematical Society\\Michael Downes} \date{Version \fileversion, \filedate} \hDocInput{amsthm.dtx} \end{document} % % \end{macrocode} % \fi % % \maketitle % \section{Introduction} % The \pkg{amsthm} package is loosely derived from \fn{theorem.sty} % version 2.1c; it adds \cn{newtheorem*} for unnumbered environments % and changes the extensibility support for loading extra theorem % styles from external files: now it is done through the package % option mechanism. % % Here are some examples showing the kinds of theorem environment % declarations that are possible with the \pkg{amsthm} package. % \begin{verbatim} % \newtheorem{prop}{Proposition} % \newtheorem{thm}{Theorem}[section] % \newtheorem{lem}[thm]{Lemma} % \newtheorem*{Zorn}{Zorn's Lemma} % % \theoremstyle{definition} % \newtheorem{dfn}{Definition} % % \theoremstyle{remark} % \newtheorem*{rmk}{Remark} % \end{verbatim} % % The first four statements all define environments using the default % theorem style (`plain'), since there is no prefatory % \cn{theoremstyle} declaration. % The first statement defines an automatically numbered \env{prop} % environment whose headings will look like this: Proposition 1, % Proposition 2, and so forth. The second statement % defines an environment \env{thm} with % numbers subordinate to section numbers, so the headings will look % like this: Theorem 1.1, Theorem 1.2, Theorem 1.3, \dots, (in % section 2:) Theorem 2.1, Theorem 2.2, and so forth. The third % statement defines a \env{lem} environment whose numbers % will interleave in sequence with the theorem numbers: Theorem 1.3, % Lemma 1.4, Lemma 1.5, Theorem 1.6, and so forth. The fourth % statement defines a special unnumbered lemma named `Zorn's Lemma'. % The remaining two \cn{newtheorem} statements have no special % features except for the \cn{theoremstyle} declarations that cause % them to use different styles. % % There are three basic styles provided: The `plain' style produces % bold headings and italic text; the `definition' style produces bold % headings and roman text; the `remark' style produces italic % headings and roman text. Other theorem styles can be provided by % putting a suitable definition in a separate file whose name ends % with \fn{.thm}. For example, suppose that you wanted to make a % theorem style `exercise' for exercises. Create a file called % \fn{exercise.thm} and in it define a command \cs{th@exercise} % following the form of the commands \cs{th@plain}, % \cs{th@definition}, \cs{th@remark} given below. Then to use the % new style, write % \begin{verbatim} % \usepackage[exercise]{amsthm} % ... % \theoremstyle{exercise} % \end{verbatim} % % \StopEventually{} % % \section{Implementation} % Standard declaration of package name and date. % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{amsthm}[1994/10/27 v1.2beta] % \end{macrocode} % % Load some utility functions from \pkg{amsgen} if it is not already % loaded. Can't use \cn{RequirePackage} because of the later % \cn{ProcessOptions} command, and can't put this after the % \cn{ProcessOptions} command because we might need some bits for % processing a \fn{.thm} file. % \begin{macrocode} \@ifl@aded{sty}{amsgen}{}{\input{amsgen.sty}} % \end{macrocode} % % The \cn{theoremstyle} command is very simple except for the need to % warn about an unknown theoremstyle. % \begin{macrocode} \newcommand{\theoremstyle}[1]{% \@ifundefined{th@#1}{% \PackageWarning{amsthm}{% Unknown theoremstyle `#1'. Using `plain'}% \theorem@style{plain}% }{% \theorem@style{#1}% }% } % \end{macrocode} % % \begin{macrocode} \newtoks\theorem@style \theorem@style{plain} % \end{macrocode} % % This code for handling theorem body and header font is a % simplification of the code in Mittelbach's \fn{theorem} package. % For consistency we make the header punctuation a token register as % well. And we add a separate font specification for the optional % note (since in AMS publications the note usually takes a different % font). The \cs{normalfont} that in Mittelbach's code resided here % is transferred to \cs{@thm}. % \begin{macrocode} \newtoks\theorembodyfont \theorembodyfont{\itshape} \newtoks\theoremheadfont \theoremheadfont{\bfseries} \newtoks\theoremnotefont \theoremnotefont{\bfseries} \newtoks\theoremheadpunct \theoremheadpunct{.} \newskip\theorempreskipamount \newskip\theorempostskipamount % \end{macrocode} % Modify \cn{newtheorem} to add |*| option. If a |*| is found, pass % it on to \cs{@xnthm} as the first argument. Otherwise pass a dummy % first arg of \cs{relax}. % \begin{macrocode} \renewcommand{\newtheorem}{\@ifstar{\@xnthm *}{\@xnthm \relax}} % \end{macrocode} % % Check to see if an optional arg is present after the first % mandatory arg (which is \arg{2} at the moment since the |*| or % non-|*| is \arg{1}). % \begin{macrocode} \def\@xnthm#1#2{% \let\@tempa\relax \@xp\@ifdefinable\csname #2\endcsname{% \global\@xp\let\csname end#2\endcsname\@endtheorem \ifx *#1% unnumbered, need to get one more mandatory arg \edef\@tempa##1{% \gdef\@xp\@nx\csname#2\endcsname{% \@nx\@thm{\@xp\@nx\csname th@\the\theorem@style\endcsname}% {}{##1}}}% \else % numbered theorem, need to check for optional arg \def\@tempa{\@oparg{\@ynthm{#2}}[]}% \fi }% \@tempa } % \end{macrocode} % % Environment numbered together with a previously defined % environment. % % Arg1: env name, e.g. `thm'\par % Arg2: optional sibling counter\par % Arg3: heading text e.g. `Theorem' % \begin{macrocode} \def\@ynthm#1[#2]#3{% % \end{macrocode} % If optional arg \arg{2} is empty, call \cs{@xthm} to look for a % possible optional arg in terminal position. Note that % the two optional args are mutually exclusive. % \begin{macrocode} \@ifempty{#2}{% \@oparg{\@xthm{#1}{#3}}[]% }{% \@ifundefined{c@#2}{% \@nocounterr{#2}% }{% \@xp\xdef\csname the#1\endcsname{\@xp\@nx\csname the#2\endcsname}% \toks@{#3}% \@xp\xdef\csname#1\endcsname{% \@nx\@thm{\@xp\@nx\csname th@\the\theorem@style\endcsname}% {#2}{\the\toks@}}% }% }% } % \end{macrocode} % % Environment numbered relative to the counter given as \arg{3}. This % function should really be named \cs{@znthm} but we're trying to % save a bit of hash table and string pool by reusing one of the % command names rendered obsolete by the amsthm option. % % Arg1: env name e.g. `thm'; % Arg2: heading text e.g. `Theorem'; % Arg3: parent counter e.g. section. % \begin{macrocode} \def\@xthm#1#2[#3]{% % \end{macrocode} % Set up the counter \verb'c@#1' and optionally add it to the reset % list of counter \arg{3}. % \begin{macrocode} \@ifempty{#3}{% \newcounter{#1}% }{% \newcounter{#1}[#3]% % \end{macrocode} % Define \cn{thexxx} to be \verb'\theyyy.\arabic{xxx}' (assuming % default values of punctuation and numbering style). The use of % \cs{xdef} here is inherited from the old \LaTeX{} code, I'm not % sure it's a good idea in general, but there should not be any % problems unless someone changes the value of \cs{@thmcounter} or % \cs{@thmcounter}. % \begin{macrocode} \@xp\xdef\csname the#1\endcsname{\@xp\@nx\csname the#3\endcsname \@thmcountersep\@thmcounter{#1}}% }% \toks@{#2}% \@xp\xdef\csname#1\endcsname{% \@nx\@thm{\@xp\@nx\csname th@\the\theorem@style\endcsname}% {#1}{\the\toks@}}% } % \end{macrocode} % % If arg \arg{2} is empty, this is an unnumbered environment; % otherwise \arg{2} is the name of a counter. \arg{3} is descriptive % name such as ``Theorem'' or ``Lemma''. Arg \arg{1} is the style % function, for example \cs{th@plain}. % \begin{macrocode} \def\@thm#1#2#3{\normalfont \trivlist \labelsep.5em\relax % \end{macrocode} % Explicitly set plain style here, then override parts as necessary % in the function provided as \arg{1}. % \begin{macrocode} \let\theoremindent\noindent % no indent \let\theorem@swap\@nonswapped \theoremheadfont{\bfseries}% heading font bold \theoremnotefont\@emptytoks% default to header font \theoremheadpunct{.}% add period after heading \theorempreskipamount1\baselineskip\@plus.2\baselineskip \@minus.2\baselineskip \theorempostskipamount\theorempreskipamount #1% style overrides \@topsep \theorempreskipamount % used by first \item \@topsepadd \theorempostskipamount % used by \@endparenv \def\@tempa{#2}\ifx\@empty\@tempa \def\@tempa{\@oparg{\@begintheorem{#3}{}}[]}% \else \refstepcounter{#2}% \def\@tempa{\@oparg{\@begintheorem{#3}{\csname the#2\endcsname}}[]}% \fi \@tempa } % \end{macrocode} % % This variation of the \cs{@thm} command is no longer needed. The % variation \cs{@xthm} was commandeered for \cn{newtheorem} use. % \begin{macrocode} \let\@ythm\relax % \end{macrocode} % % If argument \arg{2} is empty, then this is an unnumbered % environment. Otherwise \arg{2} is a numbering command such as % \cn{thexyz}. % \begin{macrocode} \def\@begintheorem#1#2[#3]{% \item[\normalfont % reset in case body font is abnormal % \end{macrocode} % The standard weird compensation for labelsep space inside an % \cn{item} that is not a normal user-level \cn{item}: % \begin{macrocode} \hskip\labelsep \the\theoremheadfont \theoremindent % \end{macrocode} % The \cs{theorem@swap} function might be changed under some % circumstances to swap the position of the heading text and the % number. % \begin{macrocode} \theorem@swap{#1}{#2}% % \end{macrocode} % If there is an optional note for the theorem head, add it here. % Note that this part is not localized to a group, so the final % punctuation (if present) will match the font of the theorem note % (if a note is present). % \begin{macrocode} \@ifnotempty{#3}{\space\the\theoremnotefont(#3\unskip)}% % \end{macrocode} % I can't think of any example where the after-head punctuation % should be omitted so it seems correct not to use \cs{@addpunct} % here. % \begin{macrocode} \the\theoremheadpunct]% \ignorespaces} % \end{macrocode} % % \begin{macro}{\nonslanted} % The \cn{nonslanted} command changes the current font to % \cn{upshape} if it is \cn{itshape} or \cn{slshape}. This is used % for document structure numbers that should be consistently upright % in all contexts. % \begin{macrocode} \def\nonslanted{\relax \ifx\f@shape\itdefault\upshape \else\ifx\f@shape\sldefault\upshape\fi\fi} % \end{macrocode} % \end{macro} % % \begin{macro}{\@nonswapped} % The default value of \cs{theorem@swap} is nonswapped. % \begin{macrocode} \def\@nonswapped#1#2{#1\@ifnotempty{#2}{\enskip{\nonslanted#2}\unskip}}% % \end{macrocode} % \end{macro} % % \begin{macro}{\@swapped} % The amsart documentclass uses a different default definition of % \cs{@swapped} that also does some font changes and uses a different % horizontal space. % \begin{macrocode} \def\@swapped#1#2{% {\nonslanted#2}\@ifnotempty{#1}{\@addpunct{.}\enskip#1\unskip}} % \end{macrocode} % \end{macro} % % \begin{macro}{\theorem@swap} % This function could be changed by the \cn{swapnumbers} command. % Default is \cs{@nonswapped}. % \begin{macrocode} \let\theorem@swap=\@nonswapped % \end{macrocode} % \end{macro} % % \begin{macro}{\swapnumbers} % The command \verb'\swapnumbers{thm,prop,defn,...}' causes all the % given environments to have the numbers swapped to the front. % \begin{macrocode} \def\swapnumbers#1{\PackageError{amsthm}{Command \nx@\swapnumbers not ready yet}} % \end{macrocode} % \end{macro} % % \cs{@opargbegintheorem} not needed, \cs{@oparg} utility serves % instead. % \begin{macrocode} \let\@opargbegintheorem\relax % \end{macrocode} % % The default style of `plain', all except the body font, is built % into the \cs{@thm} macro to ensure that nested environments work % properly. So the \cs{th@plain} macro can just give the body font. % \begin{macrocode} \def\th@plain{% %%\let\theoremindent\noindent % no indent %%\let\theorem@swap\@nonswapped % don't swap number to the left %%\theoremheadfont{\bfseries}% heading font is bold %%\theoremnotefont{}% same as heading font %%\theoremheadpunct{.}% add period after heading %%\theorempreskipamount\baselineskip\@plus.2\baselineskip %% \@minus.2\baselineskip %%\theorempostskipamount\theorempreskipamount \itshape % body font } % \end{macrocode} % % Theorem style `definition' is the same as `plain' except for the % body font. % \begin{macrocode} \def\th@definition{% \normalfont % body font } % \end{macrocode} % % Theorem style `remark' differs from `plain' in head font and body % font. % \begin{macrocode} \def\th@remark{% \theoremheadfont{\itshape}% \normalfont % body font } % \end{macrocode} % % The standard definition of \cs{@endtheorem} is just % \cs{endtrivlist}, but that doesn't automatically start a new % paragraph, so we add \cs{@endpefalse} in order to ensure a new % paragraph. % \begin{macrocode} \def\@endtheorem{\endtrivlist\@endpefalse } % \end{macrocode} % % \begin{macro}{\newtheoremstyle} % An easy way to make a not too complicated variant theorem style. % Usage: % \begin{verbatim} % \newtheoremstyle{NAME}% % {INDENT}{SWAP}{HEADFONT}{NOTEFONT}{PUNCT}{BODYFONT}% % {ABOVESPACE}{BELOWSPACE} % \end{verbatim} % Values for INDENT are empty=yes or `no'; values for SWAP are % empty=no or 's'. Other values are accepted as given. % \begin{macrocode} \newcommand{\newtheoremstyle}[9]{% \@xp\ifx\csname#2indent\endcsname\noindent \toks@{\let\theoremindent\noindent}% \else \toks@{\let\theoremindent\indent}% \fi \ifx s#3% \@temptokena{\let\theorem@swap\@swapped}% \else \@temptokena{\let\theorem@swap\@nonswapped}% \fi \theoremheadfont{\theoremheadfont{#4}% \theoremnotefont{#5}\theoremheadpunct{#6}% \theorempreskipamount#8\relax \theorempostskipamount#9\relax #7% body font }% \@xp\xdef\csname th@#1\endcsname{% \the\toks@ \the\@temptokena \the\theoremheadfont}% } % \end{macrocode} % \end{macro} % % % \begin{macro}{\qed} % Define \cn{qed} for end of proof. This command should \emph{not} % ever occur in inner math mode (i.e. |$...$| at paragraph level) but % it might be used in a displayed equation. % \begin{macrocode} \DeclareRobustCommand{\qed}{% \ifmmode % do nothing extra \else \leavevmode\unskip\penalty9999 \hbox{}\nobreak\hfill \fi % \end{macrocode} % The hbox is to prevent a line break within the \cn{qedsymbol} if it % is defined to be something composite--- e.g., things like % \verb"(Corollary 1.2) \openbox" as are occasionally done. % \begin{macrocode} \quad\hbox{\qedsymbol}} % \end{macrocode} % \end{macro} % % The reason that we do not simply use the \cn{square} symbol from % msam for the open-box qed symbol is that we want to avoid requiring % users to have the AMSFonts font package. And the \fn{lasy} \cn{Box} % is too large. % \begin{macrocode} \newcommand{\openbox}{\leavevmode \hbox to.77778em{% \hfil\vrule \vbox to.675em{\hrule width.6em\vfil\hrule}% \vrule\hfil}} \newcommand{\qedsymbol}{\openbox} % \end{macrocode} % % The proof environment is never numbered, and has a \cn{qed} at the % end, which makes it inconvenient to use \cn{newtheorem} for % defining it. Also authors frequently need to substitute an % alternative heading text (e.g. `Proof of the Dilation Lemma') % instead of the default `Proof'. For all these reasons we define the % proof environment here instead of leaving it for authors to define. % \begin{macrocode} \newenvironment{proof}[1][\proofname]{\par \normalfont \topsep6\p@\@plus6\p@ \trivlist \item[\hskip\labelsep\itshape #1\@addpunct{.}]\ignorespaces }{% \qed\endtrivlist } % \end{macrocode} % Default for \cn{proofname}: % \begin{macrocode} \newcommand{\proofname}{Proof} % \end{macrocode} % % Any option given in the \cn{usepackage} statement will be treated % as the name of a file containing additional theorem style % definitions. % \begin{macrocode} \DeclareOption*{\input{\CurrentOption .thm}} \ProcessOptions % \end{macrocode} % % For reference: % \begin{verbatim} % From: tycchow@math.mit.edu (Timothy Y. Chow) % Subject: Suppressing theorem numbering in LaTeX % Message-ID: <1994Aug11.234754.22523@galois.mit.edu> % Date: Thu, 11 Aug 94 23:47:54 GMT % To: tex-news@SHSU.EDU % % A friend of mine wants numbering of theorems, conjectures, and so on % suppressed if there is only one of them in his article. In other words % he wants "Conjecture 1" to appear as simply "Conjecture" if there is no % Conjecture 2. What is the best way to go about doing this? % ... % \end{verbatim} % % The usual \cs{endinput} to ensure that random garbage at the end of % the file doesn't get copied by \fn{docstrip}. % \begin{macrocode} \endinput % \end{macrocode} % % \CheckSum{377} % \Finale