summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/source/latex/ntheorem/ntheorem.drv58
-rw-r--r--Master/texmf-dist/source/latex/ntheorem/ntheorem.dtx4711
-rw-r--r--Master/texmf-dist/source/latex/ntheorem/ntheorem.ins18
3 files changed, 4787 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/ntheorem/ntheorem.drv b/Master/texmf-dist/source/latex/ntheorem/ntheorem.drv
new file mode 100644
index 00000000000..fb5d10aa434
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ntheorem/ntheorem.drv
@@ -0,0 +1,58 @@
+%%
+%% This is file `ntheorem.drv',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% ntheorem.dtx (with options: `driver')
+%%
+%% IMPORTANT NOTICE:
+%%
+%% For the copyright see the source file.
+%%
+%% Any modified versions of this file must be renamed
+%% with new filenames distinct from ntheorem.drv.
+%%
+%% For distribution of the original source see the terms
+%% for copying and modification in the file ntheorem.dtx.
+%%
+%% This generated file may be distributed as long as the
+%% original source files, as listed above, are part of the
+%% same distribution. (The sources need not necessarily be
+%% in the same archive or directory.)
+\def\filedate{2004/09/20}
+\def\docdate{2004/09/20}
+\def\fileversion{1.24}
+\def\basename{ntheorem}
+%% This file may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.2
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.2 or later is part of all distributions of LaTeX
+%% version 1999/12/01 or later.
+%% \CharacterTable
+%% {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
+%% 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
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
+\documentclass{ltxdoc} \usepackage{latexsym}
+\usepackage{framed} \usepackage{pstricks}
+\usepackage[thmmarks,thref,noconfig,framed]{ntheorem} \parindent0pt\hfuzz2pt
+\setlength{\textwidth}{360pt}
+\begin{document}
+ \DocInput{ntheorem.dtx}
+\end{document}
+\endinput
+%%
+%% End of file `ntheorem.drv'.
diff --git a/Master/texmf-dist/source/latex/ntheorem/ntheorem.dtx b/Master/texmf-dist/source/latex/ntheorem/ntheorem.dtx
new file mode 100644
index 00000000000..ac97da8d719
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ntheorem/ntheorem.dtx
@@ -0,0 +1,4711 @@
+\def\filedate{2004/09/20}
+\def\docdate{2004/09/20}
+\def\fileversion{1.24}
+\def\basename{ntheorem}
+% \iffalse
+%
+% Package 'ntheorem' to use with LaTeX2e
+% Copyright 1997 - 2004 by Wolfgang May and Andreas Schlechte.
+%
+% Written and maintained by
+% Wolfgang May (Uni Goettingen, formerly Uni Freiburg)
+% [theorem-marks, general layout]
+% and Andreas Schlechte (formerly TU Clausthal)
+% [theorem-lists, list layout]
+%
+%% This file may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.2
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.2 or later is part of all distributions of LaTeX
+%% version 1999/12/01 or later.
+%
+% Please send bugreports and suggestions to
+%
+% Wolfgang May
+% Institut f"ur Informatik, Universit"at Goettingen
+% e-mail: may@informatik.uni-goettingen.de
+%
+% Andreas Schlechte
+% e-mail: ntheorem@andreas-schlechte.de
+%
+% \fi
+%
+% \CheckSum{2575}
+%% \CharacterTable
+%% {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
+%% 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
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
+%
+% \RecordChanges
+% \changes{v0.80}{1997/02/11}{Started integration of `thmmarks.sty' with
+% `newthm.sty':}
+% \changes{v0.82}{1997/02/12}{included handling of theoremlists from
+% newthm.sty (WM)}
+% \changes{v0.85}{1997/02/14}{replaced `bf' by corresponding \LaTeXe-commands (AS)}
+% \changes{v0.87}{1997/02/18}{Renamed style to `ntheorem.sty' (WM)}
+% \changes{v0.88}{1997/02/18}{fixed some package-infos (AS)}
+% \changes{v0.90}{1997/02/19}{changed `addtheoremline, @nthm, @othm' (WM)}
+% \changes{v0.90}{1997/02/19}{counter only active if `if@thmmarks' (WM)}
+% \changes{v0.91}{1997/02/24}{moved things from @othm, @xnthm, @ynthm to
+% @newtheorem, introduced @@name (WM)}
+% \changes{v0.91}{1997/02/24}{added name* (no entry in list) (WM)}
+% \changes{v0.91}{1997/02/28}{included .sty in .dtx file (WM)}
+% \changes{v1.00}{1997/04/21}{First official version, not changed against 0.94 (WM)}
+% \changes{v1.01}{1997/05/01}{changed some `def' to `gdef' and `edef'
+% to `xdef' in `newtheorem' and related
+% macros (WM)}
+% \changes{v1.17}{1999/09/06}{Y2K for changes in documentation (AS)}
+% \changes{v1.17}{1999/09/06}{included option noconfig in driver (AS)}
+% \changes{v1.18}{1999/12/23}{debugged starred version of 'newtheorem'
+% (WM, reported by Jonathan King)}
+% \changes{v1.18}{1999/12/25}{adapted for complex theorem keywords
+% (WM, reported by Jonathan King)}
+% \changes{v1.19}{2001/01/12}{adapted to amsmath-2.0 (WM, several
+% solutions by Giovanni Dore)}
+% \changes{v1.19}{2001/01/13}{added handling of amsmath-labels with thref;
+% moved option thref before amsmath (amsmath needs redefinition of
+% `label') (WM)}
+% \changes{v1.21}{2002/12/30}{added theoremprework and postwork (WM)}
+%
+% \MakeShortVerb{\|}
+% \def\envfont{\normalfont\ttfamily}
+% \def\deflabel#1{\ttfamily #1\hfill}
+% \def\deflist#1{\begin{list}{}{\settowidth\labelwidth{\ttfamily #1}%
+% \setlength\leftmargin\labelwidth
+% \addtolength\leftmargin\labelsep
+% \let\makelabel\deflabel}}
+% \def\enddeflist{\end{list}}
+%
+% \def\packedlist#1{%
+% \begin{list}{}{\settowidth\labelwidth{#1}\setlength\leftmargin\labelwidth
+% \addtolength\leftmargin\labelsep
+% \topsep=0pt\itemsep=0.05cm\parsep=0.05cm
+% \let\makelabel\nlabel}}
+% \def\endpackedlist{\end{list}}
+% \makeatletter
+% \def\packeddescr{%
+% \begin{list}{}{\leftmargin0.5cm
+% \labelwidth\z@\itemindent-\leftmargin
+% \topsep=0pt\itemsep=0.05cm\parsep=0.05cm
+% \let\makelabel\nlabel}}
+% \def\endpackeddescr{\end{list}}
+%
+% \def\Codelabel#1{\@bsphack
+% \protected@write\@auxout{}{\string\newlabel{#1}{{\number\the
+% \c@CodelineNo}{\thepage}}}\@esphack}
+% \newcounter{tmpcount}
+% \def\Coderef#1#2{\setcounter{tmpcount}{0}\@ifundefined{r@#1}\relax
+% {\setcounter{tmpcount}{\ref{#1}}}\relax
+% \addtocounter{tmpcount}{#2}\arabic{tmpcount}}
+% \makeatother
+%
+% \def\nlabel#1{#1\hfill}
+% \def\nlist#1{\begin{list}{}{\settowidth\labelwidth{#1}%
+% \setlength\leftmargin\labelwidth
+% \addtolength\leftmargin\labelsep
+% \let\makelabel\nlabel}}
+% \def\endnlist{\end{list}}
+% \def\DANGER{{\LARGE\textbf{! }\rule{0pt}{2ex}}}
+% \def\env{\meta{env}}
+% \def\envx{\meta{env'}}
+%
+% \theoremstyle{marginbreak}
+% \theoremheaderfont{\normalfont\bfseries}\theorembodyfont{\slshape}
+% \theoremsymbol{\ensuremath{\diamondsuit}}
+% \theoremseparator{:}
+% \newtheorem{Theorem}{Theorem}
+%
+% \theoremstyle{changebreak}
+% \theoremsymbol{\ensuremath{\heartsuit}}
+% \theoremindent0.5cm
+% \theoremnumbering{greek}
+% \newtheorem{Lemma}{Lemma}
+%
+% \theoremindent0cm
+% \theoremsymbol{\ensuremath{\spadesuit}}
+% \theoremnumbering{arabic}
+% \newtheorem{Corollary}[Theorem]{Corollary}
+%
+% \theoremstyle{change}
+% \theorembodyfont{\upshape}
+% \theoremsymbol{\ensuremath{\ast}}
+% \theoremseparator{}
+% \newtheorem{Example}{Example}
+%
+% \theoremstyle{plain}
+% \theoremsymbol{\ensuremath{\clubsuit}}
+% \theoremseparator{.}
+% \theoremprework{\bigskip\hrule}
+% \theorempostwork{\hrule\bigskip}
+% \newtheorem{Definition}{Definition}
+%
+% \theoremheaderfont{\sc}\theorembodyfont{\upshape}
+% \theoremstyle{nonumberplain}
+% \theoremseparator{}
+% \theoremsymbol{\rule{1ex}{1ex}}
+% \newtheorem{Proof}{Proof}%
+%
+%
+% \title{An Extension of the \LaTeX-Theorem Evironment\thanks{This
+% file has version number \fileversion{}, last revised \filedate.}}
+% \author{\setcounter{footnote}{2}%
+% Wolfgang May\thanks{\texttt{may@informatik.uni-goettingen.de}}\\
+% Institut f\"ur Informatik, \\
+% Universit\"at G\"ottingen \\
+% Germany
+% \and
+% Andreas Schlechte\thanks{\texttt{ntheorem@andreas-schlechte.de}}\\
+% }
+% \date{\filedate}
+% \maketitle
+%
+% \begin{abstract}
+% \noindent
+% |ntheorem.sty| is a package for handling theorem-like
+% environments.
+% Aditionally to several features for defining the layout of
+% theorem-like environments which can be regarded to be standard
+% requirements for a theorem-package, it provides solutions for
+% two related problems: placement of endmarks and generation of
+% lists of theorem-like environments.
+%
+% In contrast to former approaches, it solves the problem of
+% setting endmarks of theorem-like environments (theorems,
+% definitions, examples, and proofs) \emph{automatically} at the
+% right positions, even if the environment ends with a |displaymath|
+% or (even nested) list environments, it also copes with the
+% |amsmath| package.
+% This is done in the same manner as the handling of labels by
+% using the |.aux| file.
+%
+% It also introduces the generation of lists of theorem-like
+% environments in the same manner as |listoffigures|. Additionally,
+% more comfortable referencing is supported.
+%
+% After running \LaTeX\ several times (depending on the complexity
+% of references, in general, three runs are sufficient), the endmarks
+% are set correctly, and theoremlists are generated.
+%
+% Since |ntheorem.sty| uses the standard \LaTeX\ |\newtheorem|
+% command, existing documents can be switched to
+% |ntheorem.sty| without having to change the |.tex| file.
+% Also, it is compatible with \LaTeX\ files using |theorem.sty|
+% written by Frank Mittelbach.
+% \end{abstract}
+% \newpage
+%
+% \tableofcontents
+%
+%
+% \section{Introduction}
+%
+% For our purposes here, ``theorems'' are labelled enunciations,
+% often set off from the main text by extra space and a font change.
+% Theorems, corollaries, conjectures, definitions, examples,
+% remarks, and proofs are all instances of ``theorems''.
+% The ``header'' of
+% these structures is composed of the type of the structure
+% (such as \textsc{Theorem} or \textsc{Remark}), a number
+% which serializes the instances of the same type throughout the
+% document, and an optional name (such as ``Correctness Theorem'').
+%
+% The layout of theorems can be changed by parameters as the fonts
+% of the header and the body, the way how to arrange the headers,
+% the indentation, and the way of numbering it.
+% Confronted with these requirements, |theorem.sty|, a style for
+% dealing with theorem layout was developed by Frank Mittelbach
+% which was the standard theorem-environment for long time.
+%
+% But then the desire for additional features like ``endmarks''
+% and ``theorem-lists'' arose.
+% Two extensions of |theorem.sty| were developped: One for handling
+% endmarks, |thmmarks.sty| and one for generating lists, |newthm.sty|.
+% Thus, Frank Mittelbach suggested to combine the new features into
+% one ``standard-to-be'' package.
+% And now, here it is.
+%
+% \section{The User-Interface}
+% \subsection{How to include the package}
+%
+% The package |ntheorem.sty| is included by
+% \begin{quote}
+% |\usepackage[|\meta{options}|]{ntheorem}|,
+% \end{quote}
+% where the optional parameter \meta{options} selects predefined
+% configurations and special requirements.
+%
+% The following \meta{options} are available by now, concerning
+% partially independent issues:
+% \begin{description}
+% \item[Predefined environments:] (see Section~\ref{sec:standard})
+% With [standard] and [noconfig], it can be chosen, if and what
+% file is used for activating a (user-defined) standard set of
+% theorem environments.
+% \item[Fancy boxes around theorems:] The [framed] option allows
+% to use |framed.sty| that provides boxes even across pagebreaks.
+% \item[Activation of endmarks:]
+% [thmmarks] enables the automatical placement of endmarks
+% (see \ref{sec:general}); when using the |amsmath|-package,
+% [thmmarks] must be complemented by [amsmath]
+% (see Section~\ref{sec:amslatex}).
+% \item[Activation of extended reference features:]
+% [thref] enables the extended reference features
+% (see Section~\ref{sec-ExtRef}); when using the |amsmath|-package,
+% [thref] must be complemented by [amsmath]
+% (see Section~\ref{sec:amslatex}).
+% \item[Compatibility with amsthm:] option [amsthm] provides
+% compatibility with the theorem-layout
+% commands of the |amsthm|-package (see Section~\ref{sec:amslatex}).
+% \item[Compatibility with hyperref:] option [hyperref] provides
+% compability with the |hyperref|-package
+% (see section~\ref{sec:hyperref}).
+% \end{description}
+%
+% \subsection{Defining New Theorem Sets}
+%
+% \DescribeMacro\newtheorem
+% The syntax and semantics is exactly the same as in standard
+% \LaTeX{}: the command |\newtheorem| defines a new ``theorem set''
+% or ``theorem-like structure''.
+% Two required arguments name the new environment set and give the
+% text to be typeset with each instance of the new ``set'', while
+% an optional argument determines how the ``set'' is enumerated:
+% \begin{description}
+% \item[\ttfamily \bslash newtheorem\{foo\}\{bar\}]
+% The theorem set {\envfont foo} (whose name is \texttt{bar})
+% uses its own counter.
+% \item[\ttfamily \bslash newtheorem\{foo2\}{[foo]}\{bar2\}]
+% The theorem set {\envfont foo2} (printed name \texttt{bar2})
+% uses the same counter as the theorem set \texttt{foo}.
+% \item[\ttfamily \bslash newtheorem\{foo3\}\{bar\}{[section]}]
+% The theorem set {\envfont foo3} (printed name \texttt{bar}) is
+% enumerated within the counter \texttt{section}, i.e.\ with every
+% new |\section| the enumeration begins again with 1, and
+% the enumeration is composed from the section-number and the
+% theorem counter itself.
+% \end{description}
+%
+% For every environment \meta{name}\ defined by |\newtheorem|,
+% \emph{two} enviroments \meta{name} and \meta{name|*|}\ are defined.
+% In the main document, they have exactly the same effect, but
+% the latter causes no entry in the respective list of theorems
+% (cf.\ |\section| and |\section*|), see also Section
+% \ref{sec:thmlists}.
+%
+% \DescribeMacro\renewtheorem
+% Theorem sets can be redefined by |\renewtheorem|, with the same arguments
+% as explained for |\newtheorem|. When redefining a theorem set, the
+% counter is not re-initialized.
+%
+% \subsection{Defining the Layout of Theorem Sets}\label{sec:general}
+%
+% For theorem-like environments, the user can set parameters
+% by setting several switches and then calling |\newtheorem|.
+% The layout of a theorem set is defined with the values of the switches
+% at the time |\newtheorem| is called.
+%
+% \subsubsection{Common Parameters for all Theorem Sets}
+%
+% \DescribeMacro\theorempreskipamount
+% \DescribeMacro\theorempostskipamount
+% These additional parameters affect the vertical space around
+% theorem environments:
+% |\theorempreskipamount| and |\theorempostskipamount| define,
+% respectively, the spacing before and after such an environment.
+% These parameters apply for all theorem sets and can be manipulated
+% with the ordinary length macros. They are rubber lengths,
+% (`\textsf{skips}'), and therefore can contain \texttt{plus} and
+% \texttt{minus} parts.
+%
+% \subsubsection{Parameters for Individual Sets}
+%
+% The layout of individual theorem sets can be further determined
+% by switches controlling the appearance of the headers and the
+% header-body-layout:
+%
+% \begin{itemize}
+% \item
+% \DescribeMacro\theoremstyle
+% |\theoremstyle{|\meta{style}|}|: The general structure of the
+% theorem layout is defined via its |\theoremstyle|. |\ntheorem|
+% provides several predefined styles including those of
+% Frank Mittelbach's |theorem.sty|
+% (cf.\ Section \ref{sec:predefdstyles}.
+% Additional styles can be defined by |\newtheoremstyle|
+% (cf.\ Section\ref{sec:newtheoremstyle}).
+% \item
+% \DescribeMacro\theoremheaderfont
+% |\theoremheaderfont{|\meta{fontcmds}|}|: The theorem header is set
+% in the font specified by \meta{fontcmds}.
+%
+% In contrast to |theorem.sty|, |\theoremheaderfont| can be set
+% individually for each environment type.
+% \item
+% \DescribeMacro\theorembodyfont
+% |\theorembodyfont{|\meta{fontcmds}|}|: The theorem body is set
+% in the font specified by \meta{fontcmds}.
+% \item
+% \DescribeMacro\theoremseparator
+% |\theoremseparator{|\meta{thing}|}|: \meta{thing} separates the
+% header from the body of the theorem-environment.
+% E.g., \meta{thing} can be
+% ``:'' or ``.''.
+% \item
+% \DescribeMacro\theoremprework
+% |\theoremprework{|\meta{thing}|}|: \meta{thing} is performed
+% before starting the theorem structure.
+% E.g., \meta{thing} can be |\hrule|.
+% \item
+% \DescribeMacro\theorempostwork
+% |\theorempostwork{|\meta{thing}|}|: \meta{thing} is performed
+% after finishing the theorem structure.
+% E.g., \meta{thing} can be |\hrule|.
+% \item
+% \DescribeMacro\theoremindent
+% |\theoremindent{|\meta{dimen}|}| can be used to indent the theorem wrt.\
+% the surrounding text.
+%
+% \DANGER It's a `\textsf(dimen)', so the user shouldn't try to specify a
+% \texttt{plus} or \texttt{minus} part, because this leads to an error.
+% \item
+% \DescribeMacro\theoremnumbering
+% |\theoremnumbering{|\meta{style}|}| specifies the appearance of
+% the numbering of the theorem set. Possible \meta{styles} are
+% |arabic| (default), |alph|, |Alph|, |roman|,
+% |Roman|, |greek|, |Greek|, and |fnsymbol|.
+%
+% Clearly, if a theorem-environment uses the counter of another
+% environment type, also the numbering style of that environment
+% is used.
+% \item
+% \DescribeMacro\theoremsymbol
+% |\theoremsymbol{|\meta{thing}|}|: This is only active if
+% |ntheorem.sty| is loaded with option |[thmmarks]|.
+% \meta{thing} is set as an endmark at the end of every instance
+% of the environment.
+% If no symbol should appear, say |\theoremsymbol{}|.
+% \end{itemize}
+%
+% The flexibility provided by these command should relieve the
+% users from the ugly hacking in |\newtheorem| to fit most of
+% the requirements stated by publishers or supervisors.
+%
+% \DescribeMacro\theoremclass
+% With the command |\theoremclass{|\meta{theorem-type}|}|
+% (where \meta{theorem-type} must be an already defined theorem type),
+% these parameters can be set to the values which were used when
+% |\newtheorem| was called for \meta{theorem-type}.
+%
+% With |\theoremclass{LaTeX}|, the standard \LaTeX\ layout can be
+% chosen.
+%
+% \subsubsection{Font Selection}
+%
+% From the document structuring point of view, theorem environments
+% are regarded as special parts inside a document. Furthermore,
+% the theorem header is only a distinguished part of a theorem
+% environment.
+% Thus, |\theoremheaderfont| inherits characteristics of
+% |\theorembodyfont| which also inherits in characteristics of
+% the font of the surrounding environment.
+% Thus, if for example |\theorembodyfont| is |\itshape| and
+% |\theoremheaderfont| is |\bfseries| the font selected for the
+% header will have the characteristics `bold extended italic'.
+% If this is not desired, the corresponding property has to be
+% explicitly overwritten in |\theoremheaderfont|, e.g.
+% by |\theoremheaderfont{\normalfont\bfseries}|
+%
+% \subsubsection{Predefined theorem styles}\label{sec:predefdstyles}
+%
+% The following theorem styles are predefined, covering those
+% from |theorem.sty|:
+% \begin{deflist}{nonumberbreak:}
+% \item[plain]
+% This theorem style emulates the original \LaTeX{} definition,
+% except that additionally the parameters
+% |\theorem...skipamount| are used.
+% \item[break]
+% In this style, the theorem header is followed by a line
+% break.
+% \item[change]
+% Header number and text are interchanged, without a line break.
+% \item[changebreak]
+% Like \texttt{change}, but with a line break after the header.
+% \item[margin]
+% The number is set in the left margin, without a line break.
+% \item[marginbreak]
+% Like \texttt{margin}, but with a line break after the header.
+% \item[nonumberplain]
+% Like \texttt{plain}, without number (e.g.\ for proofs).
+% \item[nonumberbreak]
+% Like \texttt{break}, without number.
+% \item[empty]
+% No number, no name. Only the optional argument is typeset.
+% \end{deflist}
+%
+% \subsubsection{Default Setting}
+%
+% If no option is given, i.e.\ |ntheorem.sty| is loaded by
+% |\usepackage{ntheorem.sty}|, the following default is set up:
+% \begin{quote}
+% |\theoremstyle{plain}|,\\
+% |\theoremheaderfont{\normalfont\bfseries}| and\\
+% |\theorembodyfont{\itshape}|,\\
+% |\theoremseparator{}|,\\
+% |\theoremindent0cm|,\\
+% |\theoremnumbering{arabic}|, \\
+% |\theoremsymbol{}|.
+% \end{quote}
+% Thus, by only saying |\newtheorem{...}{...}|, the user gets
+% the same layout as in standard \LaTeX.
+%
+%
+% \subsubsection{A Standard Set of Theorems}\label{sec:standard}
+%
+% A standard configuration of theorem sets is provided within
+% the file |ntheorem.std|, which will be included by the option
+% |[standard]|. It uses the |amssymb| and |latexsym| (automatically
+% loaded) packages and defines the following sets:
+% \begin{nlist}{Definitions:}
+% \item[Theorems:] % |Theorem|, |Lemma|, |Proposition|,
+% |Corollary|, |Satz|, |Korollar|,
+% \item[Definitions:] |Definition|,
+% \item[Examples:] |Example|, |Beispiel|,
+% \item[Remarks:] |Anmerkung|, |Bemerkung|, |Remark|,
+% \item[Proofs:] |Proof| and |Beweis|.
+% \end{nlist}
+% These theorem sets seem to be the most frequently used environments
+% in english and german
+% documents.
+%
+% The layout is defined to be theoremstyle |plain|, bodyfont |\itshape|,
+% Headerfont |\bfseries|, and endmark (theoremsymbol)
+% |\ensuremath{_\Box}| for all theorem-like environments\footnote{Note,
+% that mathmode is ensured for the symbol.}.
+% For the definition-, remark- and example-like sets,
+% the above setting is used, except bodyfont |\upshape|.
+% The proof-like sets are handled a bit differently. There, the layout
+% is defined as theoremstyle |nonumberplain|, bodyfont |\upshape|,
+% headerfont |\scshape| and endmark |\ensuremath{_\blacksquare}|.
+% For a more detailed information look at
+% |ntheorem.std| or at the code-section.
+%
+% \subsubsection{Framed and Boxed Theorems}\label{sec:frames-and-boxes}
+%
+% With the advent of the |framed| package (by Donald Arseneau) in 2001,
+% a feature that has often been asked for for ntheorem could be
+% implemented: theorems that are framed, or that are put into a colored
+% box.
+% It requires to load the |framed| package; shaded theorems also
+% require the |pstricks| package.
+% Frames and colored boxes are orthogonal to the existing
+% theoremstyles -- thus, they can be combined in arbitrary ways.
+%
+% \DescribeMacro\newframedtheorem
+% A theorem type can be framed by defining it by
+% \begin{quote}
+% |\newframedtheorem{...}{...}|
+% \end{quote}
+% with the same parameters as usually for |\newtheorem|.
+% Note that the use of the |framed| package also allows to have longer
+% theorems across a page break framed.
+%
+% \DescribeMacro\newshadedtheorem
+%
+% The same ideas hold for theorems in shaded boxes. The declaration
+% \begin{quote}
+% |\newshadedtheorem{...}{...}|
+% \end{quote}
+% declares a theorem environment that is shaded. By default, the
+% background color is |gray|. This can be changed by defining \\
+% \begin{quote}
+% |\shadecolor{|\meta{color}|}|
+% \end{quote}
+% before declaring the theorem type. Note that later declarations
+% of other shaded theorem types can use another shadecolor.
+%
+% By default, the box is given as a |\psframebox| (see |pstricks|
+% package) with shadecolor as |linecolor| and |fillcolor|. All
+% these parameters can be changed by setting
+% \begin{quote}
+% |\def\theoremframecommand{|\meta{any box command}|}|
+% \end{quote}
+% before declaring the theorem type (for examples, the
+% user is referred to section \ref{sec:examples}).
+%
+% \subsubsection{Customization and Local Settings}
+%
+% Since the user should not change |ntheorem.std|,
+% we've added the possibility to use an own configuration-file.
+% If one places the file |ntheorem.cfg| in the path searched by
+% \TeX, this file is read automatically (if |[standard]|
+% is not given). The usage of |ntheorem.cfg| can be prevented by the
+% |[noconfig]| option. Thus, just
+% a copy of |ntheorem.std| to |ntheorem.cfg| must be made
+% which then can freely be modified by the user. Note, that if a
+% configuration-file exists, this will always be used (I.e.\ with
+% option |standard| and an existing configuration-file, the |.cfg|
+% file will be used and the |.std| file won't.
+%
+% \subsection{Generating Theoremlists}\label{sec:thmlists}
+%
+% \DescribeMacro\listtheorems
+% Similar to the \LaTeX\ command |\listoffigures|,
+% any theorem set defined with a |\newtheorem| statement
+% may be listed at any place in your document by
+% \begin{quote}
+% |\listtheorems{|\meta{list}|}|
+% \end{quote}
+% The argument \meta{list} is a comma-separated list
+% of the theorem sets to be listed.
+% For a theorem set \meta{name}, only the instances are listed
+% which are instantiated by |\begin{|\meta{name}|}|. Those
+% instantiated by |\begin{|\meta{name}|*}| are omitted
+% (cf.\ |\section| and |\section*|).
+%
+% For example,
+% |\listtheorems{Corollary,Lemma}|
+% leads to a list of all instances of one of the theorem sets
+% ``Corollary'' or ``Lemma''.
+% Note, that the set name given to the command is the first
+% argument which is specified by |\newtheorem| which is also
+% the one to be used in |\begin{theorem} ... \end{theorem}|.
+%
+% If |\listtheorems| is called for a set name which is not defined
+% via |\newtheorem|, the user is informed that a list is generated,
+% but there will be no typeset output at all.
+%
+% \subsubsection{Defining the List Layout}
+%
+% \DescribeMacro\theoremlisttype
+% Theoremlists can be formatted in different ways. Analogous to
+% theorem layout, there are several predefined types which can be
+% selected by
+% \begin{quote}
+% |\theoremlisttype{|\meta{type}|}|
+% \end{quote}
+% The following four \meta{type}s are available (for examples, the
+% user is referred to section \ref{sec:examples}).
+% \begin{deflist}{allname}
+% \item[all] List any theorem of the specified set by number,
+% (optional) name and pagenumber. This one is also the
+% default value.
+% \item[allname] Like |all|, additionally with leading theoremname.
+% \item[opt] Analogous to |all|, but only the theorems which have an
+% optional name are listed.
+% \item[optname] Like |opt|, with leading theoremname.
+% \end{deflist}
+%
+% \subsubsection{Writing Extra Stuff to the Theorem File}
+%
+% Similar to |\addcontentsline| and |\addtocontents|,
+% additional entries to theoremlists are supported.
+% Since entries to theoremlists are a bit more intricate than
+% entries to the lists maintained by standard \LaTeX\,
+% |\addcontentsline| and |\addtocontents| cannot be used in a
+% straightforward way\footnote{for a theorem, its number has
+% to be stored explicitly since different theorem sets can use
+% the same counter. Also, it is optional to reset the counter for
+% each section.}.
+%
+% \DescribeMacro\addtheoremline
+% Analogous to |\addcontentsline|, an extra entry for a theorem
+% list can be made by
+% \begin{quote}
+% |\addtheoremline{|\meta{name}|}{|\meta{text}|}|
+% \end{quote}
+% where \meta{name} is the name of a valid theorem set and \meta{text}
+% is the text, which should appear in the list. For example,
+% \begin{quote}
+% |\addtheoremline{Example}{Extra Entry with number}|
+% \end{quote}
+% \addtheoremline{Example}{Extra Entry with number}
+% generates an entry with the following characteristics:
+% \begin{itemize}
+% \item The Label of the theorem ``Example'' is used.
+% \item The current value of the counter for ``Example'' is used
+% \item The current pagenumber is used.
+% \item The specified text is the optional text for the theorem.
+% \end{itemize}
+% Thus, the above command has the same effect as it would be for
+% \begin{quote}
+% |\begin{Example}[Extra Entry with number] \end{Example}|
+% \end{quote}
+% except, that there would be no output of the theorem, and the counter
+% isn't advanced.
+%
+% \DescribeMacro{\addtheoremline*}
+% Alternatively you can use
+% \begin{quote}
+% |\addtheoremline*{Example}{Extra Entry}|
+% \end{quote}
+% \addtheoremline*{Example}{Extra Entry}
+% which is the same as above, except that the entry appears without
+% number.
+%
+% \DescribeMacro\addtotheoremfile
+% Sometimes, e.g.\ for long lists, special control sequences
+% (e.g.\ a pagebreak) or additional text should be inserted into a
+% list. This is done by
+% \begin{quote}
+% |\addtotheoremfile[|\meta{name}|]{|\meta{text}|}|
+% \end{quote}
+% where \meta{name} is the name of a theorem set and
+% \meta{text} is the text to be written into the theorem file.
+% If the optional argument \meta{name} is omitted, the given
+% text is inserted in every list, otherwise it is only inserted
+% for the given theorem set.
+%
+% \subsection{For Experts: Defining Layout Styles}
+% \subsubsection{Defining New Theorem Layouts}\label{sec:newtheoremstyle}
+%
+% \DescribeMacro\newtheoremstyle
+% Additional layout styles for theorems can be defined by
+% \begin{quote}
+% |\newtheoremstyle{|\meta{name}|}{|\meta{head}|}{|\meta{opt-head}|}|.
+% \end{quote}
+% After this, |\theoremstyle{|\meta{name}|}| is a valid
+% |\theoremstyle|.
+% Here, \meta{head} has to be a statement using two arguments,
+% |##1|, containing the keyword, and |##2|, containing the number.
+% \meta{opt-head} has to be a statement using three arguments where
+% the additional argument |##3| contains the optional parameter.
+%
+% Since \LaTeX\ implements theorem-like environments by |\trivlist|s,
+% both header declarations must be of the form
+% |\item[... \theorem@headerfont ...]...|, where
+% the dotted parts can be formulated by the user.
+% If there are some statements producing
+% output after the |\item[...]|, you have to care about implicit
+% spaces.
+%
+% Because of the |@|, if |\newtheoremstyle| is used in a
+% |.tex| file, it has to be put between |\makeatletter| and
+% |\makeatother|.
+%
+% For details, look at the code documentation or the
+% definitions of the predefined theoremstyles.
+%
+% \DescribeMacro\renewtheoremstyle
+% Theorem styles can be redefined by |\renewtheoremstyle|, with the
+% same arguments as explained for |\newtheoremstyle|.
+%
+% \subsubsection{Defining New Theorem List Layouts}\label{sec:listtypes}
+%
+% \DescribeMacro\newtheoremlisttype
+% Analogous, additional layouts for theorem lists can be defined by
+% \begin{quote}
+% |\newtheoremlisttype{|\meta{name}|}{|\meta{start}|}{|\meta{line}%
+% |}{|\meta{end}|}|.
+% \end{quote}
+% The first argument, \meta{name}, is the name of the listtype,
+% which can the be used as a valid |\theoremlisttype|.
+% \meta{start} is the sequence of commands to be executed at
+% the very beginning of the list.
+% Corresponding, \meta{end} will be executed at the end of the list.
+% These two are set to do nothing in the standard-types.
+% \meta{line} is the part to be called for every entry of the list.
+% It has to be a statement using four arguments: |##1| will be
+% replaced with the name of the theorem, |##2| with the number,
+% |##3| with the theorem's optional text and |##4| with the pagenumber.
+%
+% WARNING: Self-defined Layouts will break with the |hyperref|-package.
+%
+% \DescribeMacro\renewtheoremlisttype
+% Theorem list types can be redefined by |\renewtheoremlisttype|, with
+% the same arguments as explained for |\newtheoremlisttype|.
+%
+% \subsection{Setting End Marks}
+%
+% The automatic placement of endmarks is activated by calling
+% |ntheorem.sty| with the option |[thmmarks]|.
+% Since then, the endmarks are set automatically, there are only
+% a few commands for dealing with very special situations.
+%
+% \DescribeMacro\qed
+% \DescribeMacro\qedsymbol
+% If in a single environment, the user wants to replace the standard
+% endmark by some other, this can be done by saying |\qed|,
+% if |\qedsymbol| has been defined by |\qedsymbol{|\meta{something}|}|
+% (in option standard, |\qedsymbol| is defined to be the symbol
+% used for proofs, since a potential use of this features is to
+% close trivial corollaries without explicitly proving them).
+%
+% Additionally, if in a single environment of a theorem set, that
+% is defined without an endmark, the user wants to set an endmark,
+% this is done with |\qedsymbol| and |\qed| as described above.
+% |\qedsymbol| can be redefined everywhere in the document.
+%
+% \DescribeMacro\NoEndMark
+% \DescribeMacro\TheoremSymbol
+% On the other hand, if in some situation, the user decides to set
+% the endmark manually (e.g.\ inside a figure or a minipage), the
+% automatic handling can be turned off by |\NoEndMark| for the
+% current environment.
+% Then -- assumed that he current environment is of type \meta{name},
+% the endmark can manually be set by just saying
+% |\|\meta{name}|Symbol|.
+%
+% Note that there must be no empty line in the input before the
+% |\end{theorem}|, since then, the end mark is ignored (cf.\
+% Theorem~\ref{ex-empty-line} in Section~\ref{sec:examples}).
+%
+% \subsection{Extended Referencing Features}
+%
+% The extended referencing features are activated by calling
+% |ntheorem.sty| with the option |[thref]|.
+%
+% Often, when writing a paper, one changes propositions into
+% theorems, theorems into corollaries, lemmata into remarks
+% an so on. Then, it is necessary to adjust also the references,
+% i.e., from ``|see Proposition~\ref{completeness}|'' to
+% ``|see Theorem~\ref{completeness}|''. For relieving the user
+% from this burden, the type of the respective labeled entities
+% can be associated with the label itself:
+%
+% \begin{quote}
+% |\label{|\meta{label}|}[|\meta{type}|]|
+% \end{quote}
+% associates the type \meta{type} with \meta{label}. \\
+% This task is automated for theorem-like environments:
+%
+% \begin{quote}
+% |\begin{Theorem}[|\meta{name}|]\label{|\meta{label}|}|
+% \end{quote}
+% is equivalent to
+% \begin{quote}
+% |\begin{Theorem}[|\meta{name}|]\label{|\meta{label}|}[Theorem]|
+% \end{quote}
+%
+% The additional information is used by
+% \DescribeMacro\thref
+% \begin{quote}
+% |\thref{|\meta{label}|}|
+% \end{quote}
+% which outputs the respective environment-type \emph{and} the number,
+% e.g., ``Theorem~42''. Note that \LaTeX\ has to be run twice after
+% changing labels (similar to getting references OK; in the
+% intermediate run, warnings about undefined reference types can
+% occur).
+%
+% The |[thref]| option interferes with the |babel| package, thus in
+% this case, |ntheorem| has to be loaded \emph{after} |babel|. It also
+% interferes with |amsmath|; see Section~\ref{sec:amslatex}.
+%
+%
+% \subsection{Miscellaneous}
+%
+% Inside a theorem-like environment \meta{env}, the name given as optional
+% argument is accessible by |\|\meta{env}|name|.
+%
+% \section{Possible Interferences}
+% Since |ntheorem| reimplements the handling of theorem-environments
+% completely, it is incompatible with every package also concerning
+% those macros.
+%
+% Additionally, the |thmmarks| algorithm for placing endmarks
+% requires modifications of several environments (cf.\ Section
+% \ref{sec:code}).
+% Thus, environments which are reimplemented or additionally defined
+% by document options or styles are not covered by the endmark
+% algorithm of |ntheorem.sty|.
+%
+% The |[thref]| option changes the |\label| command and the treatment
+% of labels when reading the |.aux| file. Thus it is potentially
+% incompatible with all packages also changing |\label| (or
+% |\newlabel|). Compatibility with babel's |\newlabel| isa
+% achieved if babel is loaded before ntheorem.
+%
+% \subsection{Interfering Document Options.}
+%
+% |ntheorem.sty| also copes with the usual document options
+% |leqno| and |fleqn|\footnote{although for \texttt{fleqn} and
+% long formulas
+% reaching to the right margin, equation numbers and endmarks can
+% be smashed over the formula since \texttt{fleqn} does not use
+% \texttt{\bslash eqno} for controlling the setting of the equation
+% number.}.
+% If one of those options is used in the |\documentclass|
+% declaration, it is automatically recognized by the |thmmarks| part
+% of |ntheorem.sty|.
+%
+% If one of those options is not used in |\documentclass|, but
+% with |amsmath| (see next section), it must not be specified
+% for |ntheorem|, since all |amsmath| environments detect this option
+% by themselves.
+%
+% \subsection{Combination with amslatex.}\label{sec:amslatex}
+%
+% |ntheorem.sty| interferes with |amsmath.sty| and |amsthm.sty|.
+%
+% Note, that the LaTeX amstex package |amstex.sty| (\LaTeX2.09) is
+% obsolete and you should use |amsmath| and |amstext| for
+% \LaTeXe\ instead. Up to |ntheorem-1.18|, it is compatible with
+% |amsmath-1.x|. Since |ntheorem-1.19|, it is (hopefully) compatible
+% with |amsmath-2.x|.
+%
+% We would be happy if someone knowing and using |amsmath| would
+% join the development and maintenance of this style.
+%
+% \subsubsection{amsmath}
+%
+% Compatibility with amsmath (end marks for math environments, and
+% handling of labels in math environments) is provided in the option
+% |[amsmath]|, (i.e., if |\usepackage{amsmath}| is used then
+% \begin{itemize}
+% \item |\usepackage[thmmarks]{ntheorem}| must be completed to \\
+% |\usepackage[amsmath,thmmarks]{ntheorem}|), and also
+% \item |\usepackage[thref]{ntheorem}| must be completed to \\
+% |\usepackage[amsmath,thref]{ntheorem}|).
+% \end{itemize}
+% Note, that |amsmath| has to be loaded \emph{before} |ntheorem|
+% since the definitions have to be overwritten.
+%
+% \subsubsection{amsthm}
+%
+% |amsthm.sty| conflicts with the definition of theorem
+% layouts in |theorem.sty|, some features of |amsthm.sty|
+% have been incorporated into option |[amsthm]| which has
+% to be used \emph{instead of} |\usepackage{amsthm}|.
+%
+% The Option provides theoremstyles |plain|, |definition|, and
+% |remark|, and a |proof| environment as in |amsthm.sty|.
+%
+% The |\newtheorem*| command is defined even without this
+% option. Note that |\newtheorem*| always switches to the
+% nonumbered version of the current theoremstyle which
+% thus must be defined.
+%
+% The command |\newtheoremstyle| is not taken over from
+% |amsthm.sty|. Also, |\swapnumbers| is not implemented.
+% Here, the user has to express his definitions by the
+% |\newtheoremstyle| command provided by |ntheorem.sty|,
+% including the use of |\theoremheaderfont| and |\theorembodyfont|.
+% The options |[amsthm]| and |[standard]| are in conflict
+% since they both define an environment |proof|.
+%
+% Thus, we recommend not to use
+% |amsthm|, since the features for defining theorem-like
+% environments in |ntheorem.sty|---following
+% |theorem.sty|---seem to be more intuitive and user-friendly.
+%
+% \subsection{Babel}\label{sec:babel}
+%
+% The |[thref]| option interferes with the |babel| package, thus in
+% case that |babel| is used, |ntheorem| has to be loaded \emph{after}
+% |babel|.
+%
+% \subsection{Hyperref}\label{sec:hyperref}
+%
+% Since |hyperref| redefines the \LaTeX\ |\contentsline|-command, it breaks
+% with |ntheorem| below version 1.17. Since version 1.17, the option
+% |[hyperref]| makes |ntheorem| work with |hyperref|.
+% Theoremlists will then get linked list.
+%
+% WARNING: The definition and redefinition of Theorem List Layouts
+% (see Section~\ref{sec:listtypes}) isn't yet working with
+% the |hyperref|-package.
+%
+%
+% \section{Examples}\label{sec:examples}
+%
+% The setting is as follows.
+% \begin{itemize}
+% \item For Theorems:
+% \begin{verbatim}
+% \theoremstyle{marginbreak}
+% \theoremheaderfont{\normalfont\bfseries}\theorembodyfont{\slshape}
+% \theoremsymbol{\ensuremath{\diamondsuit}}
+% \theoremseparator{:}
+% \newtheorem{Theorem}{Theorem}\end{verbatim}
+% \item For Lemmas:
+% \begin{verbatim}
+% \theoremstyle{changebreak}
+% \theoremsymbol{\ensuremath{\heartsuit}}
+% \theoremindent0.5cm
+% \theoremnumbering{greek}
+% \newtheorem{Lemma}{Lemma}\end{verbatim}
+% \item For Corollaries:
+% \begin{verbatim}
+% \theoremindent0cm
+% \theoremsymbol{\ensuremath{\spadesuit}}
+% \theoremnumbering{arabic}
+% \newtheorem{Corollary}[Theorem]{Corollary}\end{verbatim}
+% \item For Examples:
+% \begin{verbatim}
+% \theoremstyle{change}
+% \theorembodyfont{\upshape}
+% \theoremsymbol{\ensuremath{\ast}}
+% \theoremseparator{}
+% \newtheorem{Example}{Example}\end{verbatim}
+% \item For Definitions:
+% \begin{verbatim}
+% \theoremstyle{plain}
+% \theoremsymbol{\ensuremath{\clubsuit}}
+% \theoremseparator{.}
+% \theoremprework{\bigskip\hrule}
+% \theorempostwork{\hrule\bigskip}
+% \newtheorem{Definition}{Definition}\end{verbatim}
+% \item For Proofs (note that |theoremprework| and |theorempostwork|
+% are reset -- proofs do not have lines above and below):
+% \begin{verbatim}
+% \theoremheaderfont{\sc}\theorembodyfont{\upshape}
+% \theoremstyle{nonumberplain}
+% \theoremseparator{}
+% \theoremsymbol{\rule{1ex}{1ex}}
+% \newtheorem{Proof}{Proof}\end{verbatim}
+% \end{itemize}
+% Note, that parts of the setting are inherited. For instance, the
+% fonts are not reset before defining ``Lemma'', so the font setting
+% of ``Theorem'' is used.
+%
+% \begin{Example}[Simple one]
+% The first example is just a text.
+%
+% In the next examples, it is shown how an endmark is put at a
+% displaymath, a single equation and both types of eqnarrays.
+% \end{Example}
+%
+% \begin{Theorem}[Long Theorem]
+% The examples are put into this theorem environment.
+%
+% The next example will not appear in the list of examples since
+% it is written as
+% \begin{quote}
+% |\begin{Example*} ... \end{Example*}|
+% \end{quote}
+% \begin{Example*}[Ending with a displayed formula]
+% Look, the endmark is really at the bottom of the line:
+% \[ f^{(n)}(z) =
+% \frac{n!}{2\pi i} \int \limits _{\partial D}
+% \frac{f(\zeta)}{(\zeta-z)^{n+1}} d\zeta \]
+% \end{Example*}
+% At this point, we add an additional entry without number
+% in the Example list:
+% \begin{verbatim}
+% \addtheoremline*{Example}{Extra Entry}\end{verbatim}
+% \addtheoremline*{Example}{Extra Entry}
+% \begin{Lemma}[Display with array]
+% Lemmata are indented and numbered with greek symbols.
+% Also for displayed arrays of this form, it looks good:
+% \begin{verbatim}
+% \[\begin{array}{l}
+% a = \begin{array}[t]{l}
+% first\ line \\
+% second\ line
+% \end{array}%
+% \mbox{try to put this text in the lowest line}\end{array}\] \end{verbatim}
+% Just try to get this with the presented array structure ... without
+% using dirty tricks, you can position the outer array either [t], [c],
+% or [b], and you will not get the desired effect.
+% \[\begin{array}{l}
+% a = \begin{array}[t]{l}
+% first\ line \\
+% second\ line
+% \end{array} \mbox{try to put this text in the lowest line}
+% \end{array}\]
+% \end{Lemma}
+% \begin{Lemma}[Equation]
+% For |equation|s, we decided to put the endmark after the equation
+% number, which is vertically centered.
+% Currently, we do not know, how to get the equation number centered and
+% the endmark at the bottom (one has to know the internal height of the
+% math material) ... If anyone knows, please inform us.
+% \begin{equation}
+% \int_{\gamma} f(z)\, dz := \int_a^b f(\gamma (t)) \gamma'(t) \, dt
+% \end{equation}
+% \end{Lemma}
+%
+% With the |break|-theoremstyles, if the environment is labeled and
+% written as
+% \begin{quote}
+% |\begin{Lemma}[Breakstyle]\label{breakstyle}|
+% \end{quote}
+% \begin{Lemma}[Breakstyle]\label{breakstyle}
+% you see, there is a leading space \dots \\
+% If a percent (comment) (or an explicit |\ignorespaces|) is put directly
+% after the label, e.g.
+% \begin{quote}
+% |\begin{Lemma}[Breakstyle]\label{breakstyle}%|,
+% \end{quote}
+% the space disappears.
+%
+% From the predefined styles, this is exactly the case for the break-styles.
+% That's no bug, it's \LaTeX-immanent.
+%
+% \noindent
+% The example goes on with an |eqnarray|:
+% \begin{eqnarray}
+% f(z) &=&
+% \frac{1}{2\pi i}
+% \int \limits_{\partial D} \frac{f(\zeta)}{\zeta-z} d\zeta \\
+% &= &
+% \frac{1}{2\pi}
+% \int \limits_0^{2\pi}
+% f(z_0 + re^{it}) dt
+% \end{eqnarray}
+% \end{Lemma}
+%
+% \begin{Proof}[of nothing]
+% \begin{eqnarray*}
+% f(z) &=&
+% \frac{1}{2\pi i}
+% \int \limits_{\partial D} \frac{f(\zeta)}{\zeta-z} d\zeta \\
+% &= &
+% \frac{1}{2\pi}
+% \int \limits_0^{2\pi}
+% f(z_0 + re^{it}) dt
+% \end{eqnarray*}
+% \end{Proof}
+% That's it (the end of the Theorem).
+% \end{Theorem}
+%
+%
+% If there are some environments in the same thm-environment,
+% the last gets the endmark:
+% \begin{Definition}[With a list]
+% \begin{equation}
+% \int_{\gamma} f(z)\, dz := \int_a^b f(\gamma (t)) \gamma'(t) \, dt
+% \end{equation}
+% \begin{itemize}
+% \item you've seen, how it works for text and
+% \item math environments,
+% \item and it works for lists.
+% \end{itemize}
+% \end{Definition}
+%
+% \begin{Corollary}[Q.E.D.]
+% And here is a trivial corollary, which is ended by
+% |\qedsymbol{\textrm{q.e.d}}| and |\qed|.
+% \qedsymbol{q.e.d}\qed
+% \end{Corollary}
+%
+% \begin{Example}
+% \[ f^{(n)}(z) =
+% \frac{n!}{2\pi i} \int \limits _{\partial D}
+% \frac{f(\zeta)}{(\zeta-z)^{n+1}} d\zeta \]
+% If there is some text after an environment, the endmark is put
+% after the text.
+% \end{Example}
+%
+% The next one is done by the following sequence. Note, that
+% |~\hfill~| is inserted to prevent \LaTeX\ from using its nested list
+% management (a verbatim is also a trivlist),
+% i.e.\ this causes \LaTeX\ to start the |verbatim|-Part in a new line.
+% \begin{quote}
+% |\begin{Example}| \\
+% |~\hfill~| \\
+% |\begin{verbatim}| \\
+% |And, it also works for verbatim|\\
+% |... when the \end{verbatim} is in the|\\
+% |same line as the text ends. \end{verbatim}|\\
+% | ^| this space is important !!\\
+% |\end{Example}|
+% \end{quote}
+%
+% \begin{Example}[Using |verbatim|]
+% ~\hfill~
+% \begin{verbatim}
+% And, it also works for verbatim
+% ... when the end{verbatim} is in the
+% same line as the text ends. \end{verbatim}
+% \end{Example}
+%
+% There must be no empty line in the input before the |\end{theorem}|
+% (since then, the end mark is ignored) \\
+% \begin{quote}
+% |\begin{Theorem}| \\
+% |some text ... but no end mark| \\
+% | | \\
+% |\end{Theorem}|
+% \end{quote}
+%
+% \begin{Theorem}\label{ex-empty-line}
+% some text ... but no end mark
+%
+% \end{Theorem}
+%
+%
+% Now, there is a corollary which should appear with a different
+% name in the list of corollaries:
+% \begin{quote}
+% |\begin{Corollary*}[title in text]\label{otherlabel}| \\
+% |...|\\
+% |\end{Corollary*}|
+% |\addtheoremline{Corollary}{title in list}| \\
+% \end{quote}
+% \begin{Corollary*}[title in text]\label{otherlabel}\ignorespaces
+% let's do something weird:
+% \begin{center}
+% It also works in the \\
+% center \\
+% environment.
+% \end{center}
+% \end{Corollary*}
+% \addtheoremline{Corollary}{title in list}
+%
+% \begin{Theorem}[Quote]
+% \begin{quote}
+% In quote environments, the text is normally indented from left
+% and right by the same space. The endmark is not indented from the
+% right margin, i.e., it is typeset to the right margin of the
+% surrounding text.
+% \end{quote}
+% \end{Theorem}
+%
+% Here is an example for turning off the endmark automatics and
+% manual handling:
+%
+% \begin{verbatim}
+% \begin{Theorem}[Manual End Mark]\label{somelabel}
+% a line of text with a manually set endmark \hfill\TheoremSymbol \\
+% some more text, but no automatic endmark set. \NoEndMark
+% \end{Theorem}\end{verbatim}
+%
+% \begin{Theorem}[Manual End Mark]\label{somelabel}
+% a line of text with a manually set endmark \hfill\TheoremSymbol \\
+% some more text, but no automatic endmark set. \NoEndMark
+% \end{Theorem}
+% Also, one should note, that |\hfill| is inserted to set
+% the endmark at the right margin.
+%
+% \begin{Example}[Quickie] It also works for short one's.
+% \end{Example}
+%
+% If you are tired of the greek numbers and the indentation for lemmata ...
+% you can redefine it:
+% \theoremstyle{changebreak}
+% \theoremheaderfont{\normalfont\bfseries}\theorembodyfont{\slshape}
+% \theoremsymbol{\ensuremath{\heartsuit}}
+% \theoremsymbol{\ensuremath{\diamondsuit}}
+% \theoremseparator{:}
+% \theoremindent0cm
+% \theoremnumbering{arabic}
+% \renewtheorem{Lemma}{Lemma}
+% \begin{quote}
+% |\theoremstyle{changebreak}| \\
+% |\theoremheaderfont{\normalfont\bfseries}\theorembodyfont{\slshape}| \\
+% |\theoremsymbol{\ensuremath{\heartsuit}}|\\
+% |\theoremsymbol{\ensuremath{\diamondsuit}}|\\
+% |\theoremseparator{:}|\\
+% |\theoremindent0.5cm|\\
+% |\theoremnumbering{arabic}|\\
+% |\renewtheorem{Lemma}{Lemma}|
+% \end{quote}
+% \begin{Lemma}
+% another lemma, with arabic numbering ... note that the numbering
+% continues.
+% \end{Lemma}
+%
+% the optional argument (i.e.\ the `theorem'-name) can be accessed by
+% |\|\meta{env}|name|.
+%
+% \begin{quote}
+% |\begin{Theorem}[somename]|\\
+% |Obviously, we are in Theorem~\Theoremname|.\\
+% |\end{Theorem}|
+% \end{quote}
+% \begin{Theorem}[somename]
+% Obviously, we are in Theorem~\Theoremname.
+% \end{Theorem}
+%
+% This feature can e.g.\ be used for automatically generating
+% executable code and a commented solution sheet:
+% \begin{quote}
+% |\begin{exercise}[quicksort]| \\
+% \meta{the exercise text} \\
+% |\begin{verbatimwrite}{solutions/\exercisename.c}|\\
+% \meta{C-code} \\
+% |\end{verbatimwrite}|\\
+% |\verbatiminput{solutions/\exercisename.c}|\\
+% |\end{exercise}|
+% \end{quote}
+% This will write the C-code to a file |solutions/quicksort.c| and
+% type it also on the solution sheet.
+%
+% Now, we define an environment |KappaTheorem| which uses the same
+% style parameters as Theorems and is numbered together with
+% Corollaries (Theorems are also numbered with Corollaries).
+% Note that we define a complex header text and a complex end mark.
+%
+% |\theoremclass{Theorem}|\\
+% |\theoremsymbol{\ensuremath{a\atop b}}| \\
+% |\newtheorem{KappaTheorem}[Corollary]{\(\kappa\)-Theorem}|
+%
+% \theoremclass{Theorem}
+% \theoremsymbol{\ensuremath{a\atop b}}
+% \newtheorem{KappaTheorem}[Theorem]{\(\kappa\)-Theorem}
+%
+% \begin{KappaTheorem}[1st \(\kappa\)-Theorem]\label{kappatheorem1}
+% That's the first Kappa-Theorem.
+% \end{KappaTheorem}
+%
+% \subsection{Extended Referencing Features}\label{sec-ExtRef}[Section]
+%
+% The standard |\label| command is extended by an optional argument
+% which is intended to contain the ``name'' of the structure which
+% is labeled, allowing more comfortable referencing; e.g., this
+% section has been started with
+%
+% \begin{quote}
+% |\subsection*{Extended Referencing Features}%|\\
+% |\label{sec-ExtRef}[Section]|
+% \end{quote}
+%
+% As already stated, for theorem-like environments the optional
+% argument is filled in automatically, i.e.,
+% \begin{quote}
+% |\begin{Theorem}[Manual End Mark]\label{somelabel}|
+% \end{quote}
+% (cf.\ page~\pageref{somelabel}) is equivalent to
+% \begin{quote}
+% |\begin{Theorem}[Manual End Mark]\label{somelabel}[Theorem]|
+% \end{quote}
+%
+% |\thref{|\meta{label}|}| additionally outputs the contents
+% of the optional argument which has been associated with \meta{label}:
+%
+% \begin{quote}
+% |This is \thref{sec-ExtRef}| \\
+% |A theorem end mark has been set manually in \thref{somelabel}.| \\
+% |A center environment has been shown in \thref{otherlabel}.| \\
+% |The first Kappa-Theorem has been given in \thref{kappatheorem1}.|
+% \end{quote}
+%
+% generates
+% \begin{quote}
+% This is \thref{sec-ExtRef}. \\
+% A theorem end mark has been set manually in \thref{somelabel}.
+% A center environment has been shown in \thref{otherlabel}.
+% The first Kappa-Theorem has been given in \thref{kappatheorem1}.
+% \end{quote}
+%
+% Here one must be careful that the handling of the optional
+% argument is automated
+% only for environments defined by |\newtheorem|, i.e., \emph{not}
+% for sectioning, equations, or enumerations.
+%
+% Calling |\thref{|\meta{label}|}| for a label which has been
+% set without an optional argument can result in different unintended
+% results: If \meta{label} is not inside a theorem-like environment, an
+% error message is obtained, otherwise the type of the surrounding
+% theorem-like environment is output, e.g., calling |\thref{label}|
+% then results in ``Theorem~\meta{number}''!
+% Additionally, currently there is no support for multiple references
+% such as ``see Theorems~5 and~7'' (this would require plural-forms
+% for different languages and handling of |\ref|-lists, probably
+% splitting into different sublists for different environments)\footnote{If
+% someone is interested in programming this, please contact us; it
+% seems to be algorithmically easy, but tedious.}.
+%
+% \subsection{Framed and Shaded Theorems}
+%
+% Framed theorem classes are defined as follows:
+% \begin{quote}
+% |\theoremclass{Theorem}| \\
+% |\theoremstyle{break}| \\
+% |\newframedtheorem{importantTheorem}[Theorem]{Theorem}|
+% \end{quote}
+% \theoremclass{Theorem}
+% \theoremstyle{break}
+% \newframedtheorem{importantTheorem}[Theorem]{Theorem}
+% defines important theorems to use the same design as for theorems
+% (except that the break header style is used except the margin header
+% style), number them with the same counter, and put a frame around
+% them:
+%
+% An instance is created by
+% \begin{quote}
+% |\begin{importantTheorem}[Important Theorem]| \\
+% |This is an important theorem.| \\
+% |\end{importantTheorem}|
+% \end{quote}
+% \begin{importantTheorem}[Important Theorem]
+% This is an important theorem. \\
+% \end{importantTheorem}
+% More important theorems are shaded -- by default in grey:
+%
+% \begin{quote}
+% |\theoremclass{Theorem}| \\
+% |\theoremstyle{break}| \\
+% |\newshadedtheorem{moreImportantTheorem}[Theorem]{Theorem}| \\
+% |\begin{moreImportantTheorem}[More Important Theorem]| \\
+% |This is a more important theorem.| \\
+% |\end{moreImportantTheorem}|
+% \end{quote}
+% \theoremclass{Theorem}
+% \theoremstyle{break}
+% \newshadedtheorem{moreImportantTheorem}[Theorem]{Theorem}
+% \begin{moreImportantTheorem}[More Important Theorem]
+% This is a more important theorem.
+% \end{moreImportantTheorem}
+%
+% Even more important theorems are shaded in red:
+%
+% \begin{quote}
+% |\theoremclass{Theorem}| \\
+% |\theoremstyle{break}| \\
+% |\shadecolor{red}| \\
+% |\newshadedtheorem{evenMoreImportantTheorem}[Theorem]{Theorem}| \\
+% |\begin{evenMoreImportantTheorem}[Even More Important Theorem]| \\
+% |This is an even more important theorem. | \\
+% |\end{evenMoreImportantTheorem}|
+% \end{quote}
+% \theoremclass{Theorem}
+% \theoremstyle{break}
+% \shadecolor{red}
+% \newshadedtheorem{evenMoreImportantTheorem}[Theorem]{Theorem}
+% \begin{evenMoreImportantTheorem}[Even More Important Theorem]
+% This is an even more important theorem.
+% \end{evenMoreImportantTheorem}
+%
+% Most important theorems get a framed, blue colored box with a shadow.
+% Here, |\def\theoremframecommand| is used:
+%
+% \begin{quote}
+% |\theoremclass{Theorem}| \\
+% |\theoremstyle{break}| \\
+% |\shadecolor{red}| \\
+% |\def\theoremframecommand{%| \\
+% | \psshadowbox[fillstyle=solid,fillcolor=blue,linecolor=black]}| \\
+% |\newshadedtheorem{MostImportantTheorem}[Theorem]{Theorem}| \\
+% |\begin{MostImportantTheorem}[Most Important Theorem]| \\
+% |This is a most important theorem. | \\
+% |\end{MostImportantTheorem}|
+% \end{quote}
+% \theoremclass{Theorem}
+% \theoremstyle{break}
+% \shadecolor{red}
+% \def\theoremframecommand{%
+% \psshadowbox[fillstyle=solid,fillcolor=blue,linecolor=black]}
+% \newshadedtheorem{MostImportantTheorem}[Theorem]{Theorem}
+% \begin{MostImportantTheorem}[Most Important Theorem]
+% This is a most important theorem.
+% \end{MostImportantTheorem}
+%
+% \subsection{Lists of Theorems and Friends}
+%
+% Note, that we put the following lists into the |quote|-environment
+% to emphazise them from the surrounding text. So the lists
+% are indented slightly at the margin.
+%
+% With
+% \begin{quote}
+% |\addtotheoremfile{Added into all theorem lists}|,
+% \end{quote}
+% in every list, an additional line of text would be inserted.
+% But it isn't actually done in this documentation since we want
+% to use different list formats.
+%
+% Only for the list of Examples, this one is added:
+% \begin{quote}
+% |\addtotheoremfile[Example]{Only concerning Example lists}|
+% \end{quote}
+% \addtotheoremfile[Example]{Only concerning Example lists}
+%
+% With
+% \begin{quote}
+% |\theoremlisttype{all}| \\
+% |\listtheorems{Lemma}|,
+% \end{quote}
+% all lemmas are listed:
+% \begin{quote}
+% \theoremlisttype{all}
+% \listtheorems{Lemma}
+% \end{quote}
+%
+% From the examples, only those are listed which have an optional name:
+% \begin{quote}
+% |\theoremlisttype{opt}| \\
+% |\listtheorems{Example}|
+% \end{quote}
+% leads to
+% \begin{quote}
+% \theoremlisttype{opt}
+% \listtheorems{Example}
+% \end{quote}
+% One should note the line \emph{Only concerning example lists}, which
+% was added by the |\addtotheoremfile|-statement above.
+%
+% For the next list, another layout, using the |tabular|-environment,
+% is defined:
+% \begin{verbatim}
+% \newtheoremlisttype{tab}%
+% {\begin{tabular*}{\linewidth}{@{}lrl@{\extracolsep{\fill}}r@{}}}%
+% {##1&##2&##3&##4\\}%
+% {\end{tabular*}}\end{verbatim}
+% Thus, by saying
+% \begin{quote}
+% |\theoremlisttype{tab}|\\
+% |\listtheorems{Theorem,importantTheorem,moreImportantTheorem,|
+% | evenMoreImportantTheorem,MostImportantTheorem,Lemma},|
+% \end{quote}
+% theorems (of all importance levels) and lemmata are listed:
+% \begin{quote}
+% \DeleteShortVerb{\|}
+% \newtheoremlisttype{tab}%
+% {\begin{tabular*}{\linewidth}{@{}lrl@{\extracolsep{\fill}}r@{}}}%
+% {##1&##2&##3&##4\\}%
+% {\end{tabular*}}
+% \theoremlisttype{tab}
+% \listtheorems{Theorem,importantTheorem,moreImportantTheorem,evenMoreImportantTheorem,MostImportantTheorem,Lemma}
+% \MakeShortVerb{\|}
+% \end{quote}
+%
+% \LaTeX-lists can also be used to format the theoremlist.
+% The input
+% \begin{verbatim}
+% \newtheoremlisttype{list}%
+% {\begin{trivlist}\item}
+% {\item[##2 ##1:]\ ##3\dotfill ##4}%
+% {\end{trivlist}}
+% \theoremlisttype{list}
+% \listtheorems{Corollary}\end{verbatim}
+% leads to%
+% \begin{quote}%
+% \DeleteShortVerb{\|}%
+% \newtheoremlisttype{list}%
+% {\begin{trivlist}}%
+% {\item[##2 ##1:]\ ##3\dotfill ##4}%
+% {\end{trivlist}}%
+% \theoremlisttype{list}\listtheorems{Corollary}%
+% \MakeShortVerb{\|}%
+% \end{quote}%
+% In this example, after the item, \verb*!\ ! is used instead of
+% \verb*! !, because in the latter case, |\dotfill| will produce an
+% error if the optional argument (|##3|)
+% is missing.
+%
+% \section{The End Mark Algorithm}
+%
+% \subsection{The Idea}
+%
+% The handling of endmarks with |thmmarks.sty| is based on the same
+% two-pass principle as the handling of labels: the necessary information
+% about endmarks is contained in the |.aux| file.
+%
+% With |thmmarks.sty|, \TeX\ is always aware whether it is in
+% some theorem-like environment.
+% There, potential positions for endmarks can be
+% \begin{enumerate}
+% \item\label{elist:1} at the end of simple text lines in open text,
+% \item\label{elist:2} at the end of displaymaths,
+% \item\label{elist:3} at the end of equations or equationarrays, or
+% \item\label{elist:4} at the end of text lines at the end of lists (or, more general,
+% |trivlists|, such as |verbatim| or |center|).
+% \end{enumerate}
+%
+% The problem is, that in the cases (\ref{elist:2})--(\ref{elist:4}), the endmarks has to
+% be placed in a box which is already shipped out, when
+% |\end{...}| is processed.
+% Thus, in those situations, \TeX\ needs to know from the |.aux|
+% file, whether is has to put an endmark.
+%
+% When \TeX\ is in a theorem-like environment and comes to one of
+% the points mentioned in (\ref{elist:2})--(\ref{elist:4}),
+% and the |.aux| file says that there is an endmark, then
+% it is put there.
+% Anyway, it maintains a counter of the potential positions of an end
+% mark in the current theorem-like environment.
+% When it comes to an |\end{theorem}|, it looks if it is in
+% situation (\ref{elist:1}) (then the endmark is simply put at the end of the
+% current line).
+% Otherwise, the last horizontal box is already shipped out
+% (thus it contains a situation (\ref{elist:2})--(\ref{elist:4})) and the endmark must be
+% set in it.
+% In this case, a note is written in the |.aux| file, where the
+% endmark actually has to be set (ie, at the latest potential point for
+% setting an endmark inside the theorem).
+%
+% \subsection{The Realization}
+%
+% Let \env\ be a theorem-like environment. Then, additional to
+% the counter \env, \TeX\ maintains two counters
+% |curr|\env|ctr| and |end|\env|ctr|.
+% In the $i$th environment of type \env, |curr|\env|ctr|$=i$
+% (the \LaTeX\ counter \env\ cannot be used since a)
+% environments can use the counter of other environments, and b)
+% often counters are reinitialized inside a document).
+% |end|\env|ctr| counts the potential situations for
+% putting an endmark inside an environment.
+% It is set to 1 when starting an environment. Each time, when
+% a situation (\ref{elist:2})--(\ref{elist:4}) is reached, the command
+% \begin{quote}
+% |\mark|$<$|\roman{curr|env|ctr}|$>$\env
+% $<$|\roman{end|\env|ctr}|$>$
+% \end{quote}
+% is called
+% ($<$|\roman{curr|\env|ctr}|$>$\env
+% $<$|\roman{end|\env|ctr}|$>$
+% uniquely identifies all situations (\ref{elist:2})--(\ref{elist:4}) in a document).
+%
+% If at this position an endmark has to be set,
+% \begin{quote}
+% |\mark|$<$|\roman{curr|\env|ctr}|$>$\env
+% $<$|\roman{end|\env|ctr}|$>$
+% \end{quote}
+% is defined in the |.aux| file to be |\end|\env|Symbol|,
+% otherwise it is undefined and simply ignored.
+%
+% When \TeX\ comes to an |\end{|\env|}|, it looks if it is in
+% situation (\ref{elist:1}). If so, the endmark is simply put at the end of the
+% current line.
+% Otherwise,
+% \begin{quote}
+% |\def\mark|$<$|\roman{curr|env|ctr}|$>$\env|%|\\
+% $<$|\roman{end|\env|ctr}|$>$|{|\env|Symbol}|
+% \end{quote}
+% is written to the |.aux| file for setting the endmark
+% at the latest potential position inside the theorem in the next run.
+%
+% \begin{Theorem}[Correctness]
+% \begin{enumerate}
+% \item For a |.tex| file, which does not contain nested theorem-like
+% environments of the same type, in the above situation, the following
+% holds:
+% When compiling, at the $i$th situation in the $j$th environment of type
+% \env, |mark|$\;j\,$\env$\;i$ is handled.
+%
+% For |.tex| files which contain nested theorem-like environments of
+% the same type, |mark|$\;k\,$\env$\;l$ is handled, where
+% $k$ is the number of the latest environment of type \env\ which
+% has been called at this moment, and $l$ is the number of situations
+% (\ref{elist:2})--(\ref{elist:4}) which have occurred in
+% environments of type \env\ since
+% the the $k$th |\begin{|\env|}|.
+%
+% \item When finishing an environment, either an endmark is set directly
+% (when in a text line) or an order to put the end symbol at the latest
+% potential position is written to the |.aux| file.
+% \end{enumerate}
+% \end{Theorem}
+%
+% \begin{Theorem}[Completeness]
+% The handling of endmarks is complete wrt.\ plain text, |displaymath|,
+% |equation|,\\ |eqnarray|, |eqnarray*|, and all environments
+% ended by |endtrivlist|, including |center| and
+% |verbatim|.
+% \end{Theorem}
+%
+% So, where can be bugs ?
+% \begin{itemize}
+% \item in the plain \TeX\ handling of endmarks,
+% \item in some special situations which have not been tested yet,
+% \item in some special environments which have not been tested yet.
+% \item in the |amsmath| environments. We seldom use them, so we do not
+% know their pitfalls, and we ran only general test cases.
+% \end{itemize}
+%
+% \section{Problems and Questions}
+% \subsection{Known Limitations}
+%
+% \begin{itemize}
+% \item Since |ntheorem.sty| uses the |.aux| file for storing
+% information about the positions of endmarks, \LaTeX\ must be
+% run twice for correctly setting the endmarks.
+% \item Since |ntheorem.sty| uses the |.aux| file for storing
+% information about lists in the |.thm| file, a minimum of
+% two runs is needed. If theorems move in any of these
+% runs up to five runs can be needed to generate correct lists.
+% \item Since we need to expand the optional argument of theorems
+% in various ways for the lists, we decided to copy the text verbatim
+% into the |.thm| file. Thus, if you use things like |\thesection|
+% etc., the list won't show the correct text. Therefore you shouldn't
+% use any command that needs to be expanded.
+% \item In nested environments ending at the same time,
+% only the endmark for the inner environment is set, as the following
+% example shows:
+% \begin{verbatim}
+% \begin{Lemma}
+% Some text.
+% \begin{Proof} The Proof \end{Proof}
+% \end{Lemma}\end{verbatim}
+% yields to
+% \begin{Lemma}
+% Some text.
+% \begin{Proof} The Proof \end{Proof}
+% \end{Lemma}
+%
+% You can handle this by specifying something invisible after the end
+% of the inner theorem. Then the endmark for the outer theorem is
+% set in the next line:
+% \begin{verbatim}
+% \begin{Lemma}
+% Some text.
+% \begin{Proof} The Proof \end{Proof}~
+% \end{Lemma}\end{verbatim}
+% yields to
+% \begin{Lemma}
+% Some text.
+% \begin{Proof} The Proof \end{Proof}~
+% \end{Lemma}
+%
+% \item Document option |fleqn| is problematic: |fleqn| handles
+% equations not by |$$| but by lists (check what happens for
+% \begin{quote}
+% |\begin{theorem} \[ displaymath \] \end{theorem}|
+% \end{quote}
+% in standard \LaTeX:
+% The displaymath is \emph{not} set in an own line).
+% Also, for long formulas, the equation number and the endmark are
+% smashed into the formula at the right text margin.
+% \item Naturally, |ntheorem.sty| will not work correctly in
+% combination with other styles which change the handling
+% of
+% \begin{enumerate}
+% \item theorem-like environments, or
+% \item environments concerned with the handling of endmarks, e.g.
+% |\[...\]|, |eqnarray|, etc.
+% \end{enumerate}
+% \item |ntheorem.sty| is compatible with Frank Mittelbach's
+% |theorem.sty|, which is the most widespread style for setting
+% theorems.
+%
+% It cannot be used \emph{with} |theorem.sty|, but it can be
+% used instead of it.
+% \end{itemize}
+%
+% \subsection{Known ``Bugs'' and Problems}
+%
+% \begin{itemize}
+% \item Ending a theorem \emph{directly} after the text, e.g.
+% \begin{quote}
+% |\begin{Theorem} text\end{Theorem}|
+% \end{quote}
+% suppresses the endmark:
+% \begin{Theorem} text\end{Theorem}
+% Therefore a space or a newline should be inserted
+% before |\end{...}|.
+% \item With theoremstyle break, if the linebreak would cause
+% ugly linebreaking in the following text, it is suppressed.
+% \end{itemize}
+%
+% \subsection{Open Questions}
+% \begin{itemize}
+% \item
+% For |equation|s, we decided to put the endmark after the equation
+% number, which is vertically centered.
+% Currently, we do not know, how to get the equation number centered and
+% the endmark at the bottom (one has to know the internal height of the
+% math material).
+% \item
+% The placement of endmarks is mainly based on a check whether \LaTeX\
+% is in an ordinary text line when encountering an end-of-environment.
+% This question is \emph{partially} answered by |\ifhmode|: In a text
+% line, \LaTeX\ is always in |\hmode|.
+% But, after an displaymath, \LaTeX\ is also in |\hmode|. Thus,
+% additionally |\lastskip| is checked: after a displaymath,
+% |\lastskip|=0 holds.
+% In most situations, when text has been written into a line,
+% |\lastskip| $\neq$ 0. But, this does not hold, if the source code
+% is of the following form: |...text\label{bla}|: then, |\lastskip|=0.
+% In those situations, the endmark is suppressed. \\
+% ?? How can it be detected whether \LaTeX\ has just ended a displaymath?
+% \item
+% The above problem with the label: The break style enforces a linebreak
+% by |\hfill\penalty-8000| after the |\trivlist|-item. Thus, \TeX\
+% gets back into the horizontal mode. The label places a ``whatsit''
+% somewhere ... and, it seems that the ``whatsit'' makes \TeX\ think
+% that there is a line of text.
+% \end{itemize}
+% If someone has a solution to one of those questions, please inform us.
+% (You can be sure to be mentioned in the Acknowledgements.)
+%
+% \section{Code Documentation}\label{sec:code}
+% \iffalse
+% \subsection{The documentation driver file}
+%
+% The next bit of code contains the documentation driver file for
+% \TeX{}, i.e., the file that will produce the documentation you are
+% currently reading. It will be extracted from this file by the
+% \texttt{docstrip} program. Since it is the first code in the file
+% one can alternatively process this file directly with \LaTeXe{} to
+% obtain the documentation.
+%
+% \begin{macrocode}
+%<*driver>
+\documentclass{ltxdoc} \usepackage{latexsym}
+\usepackage{framed} \usepackage{pstricks}
+\usepackage[thmmarks,thref,noconfig,framed]{ntheorem} \parindent0pt\hfuzz2pt
+\setlength{\textwidth}{360pt}
+\begin{document}
+ \DocInput{ntheorem.dtx}
+\end{document}
+%</driver>
+% \end{macrocode}
+%\fi
+% \subsection{Documentation of the Macros}
+% \setcounter{CodelineNo}{0}
+%\iffalse
+%<*package>\fi
+% \begin{macrocode}
+\typeout{Style `\basename', Version \fileversion\space <\filedate>}
+\ProvidesPackage{ntheorem}[\filedate \space\fileversion]
+\newif\if@thmmarks\@thmmarksfalse
+\newif\if@thref\@threffalse
+\newif\ifthm@tempif
+% \end{macrocode}
+%
+% general setup.
+%
+% \subsubsection{Thmmarks-Related Stuff}
+%
+% \setcounter{CodelineNo}{0}
+% \changes{v0.87}{1997/02/18}{option 'thmmarks' added (WM)}
+% \begin{macrocode}
+\DeclareOption{thmmarks}{%*********************************
+\PackageInfo{\basename}{Option `thmmarks' loaded}%
+%
+\@thmmarkstrue
+\newcounter{endNonectr}
+\newcounter{currNonectr}
+\newif\ifsetendmark\setendmarktrue
+% \end{macrocode}
+%
+% activate placement of endmarks and define counters for upper
+% level. \\
+% |\ifsetendmark|: true if an endmark has to be set in a complex
+% situation which must be handled by the |.aux| file.
+% For further comments see |\@endtheorem|.
+%
+% In the following, all relevant environments are changed for
+% handling potential end mark positions:
+%
+% \paragraph{Changes to List Environment}\ \\
+% Original: ltlists.dtx
+%
+% \begin{macro}{\endtrivlist}
+% \changes{v1.19}{2001/01/13}{changed hbox into unskip (OK/WM)}
+% Replaces \LaTeX's |\endtrivlist|. An augmented functionality of
+% \LaTeX's |\endtrivlist| is contained in |\@endtrivlist|.
+%
+% \begin{macrocode}
+\gdef\endtrivlist{%
+ \@endtrivlist{\PotEndMark{\unskip\nobreak\hfill\nobreak}}}
+% \end{macrocode}
+%
+% At an |\endtrivlist| (which is called at the end
+% of |\list| environments and several other environments),
+% |\@endtrivlist| is called to end the |\trivlist| and
+% set a potential position for an endmark at the end of the line if
+% \TeX\ is in a text line.
+% \end{macro}
+%
+%
+% \begin{macro}{\@endtrivlist}
+% A new command] which augments \LaTeX's functionality of
+% |\endtrivlist| by checking if an end mark has to be set:
+%
+% \Codelabel{atendtrivlist}
+% \begin{macrocode}
+\gdef\@endtrivlist#1{% % from \endtrivlist
+ \if@inlabel \indent\fi
+ \if@newlist \@noitemerr\fi
+ \ifhmode
+ \ifdim\lastskip >\z@ #1\unskip \par %<<<<<<<<<<<<<<<<<<<<<<
+ \else \unskip \par \fi
+ \fi
+ \if@noparlist \else
+ \ifdim\lastskip >\z@
+ \@tempskipa\lastskip \vskip -\lastskip
+ \advance\@tempskipa\parskip \advance\@tempskipa -\@outerparskip
+ \vskip\@tempskipa
+ \fi
+ \@endparenv
+ \fi}
+% \end{macrocode}
+%
+% New: parameter |#1|. \\
+% |#1| is executed when the |\trivlist| ends with a text line (ie the
+% endmark can be put simply at the end of the line): \\
+% Line \Coderef{atendtrivlist}{5}:
+% case split: if in |hmode| and |\lastskip| $>$ 0,
+% then \TeX\ is in a text line, the endmark is set here.
+% \end{macro}
+%
+% \paragraph{Changes to Math Environments}\ \\
+% Original: ltmath.dtx
+%
+% \begin{macro}{\endequation}
+% For equations, end marks are placed behind the equation number:
+% \Codelabel{standard-endequation}
+% \begin{macrocode}
+\gdef\SetMark@endeqn{\quad}% as default, cf. option leqno
+\gdef\endequation{\eqno \hbox{\@eqnnum \PotEndMark{\SetMark@endeqn}}%
+ $$\global\@ignoretrue}
+% \end{macrocode}
+%
+% \begin{packeddescr}
+% \item[Line \Coderef{standard-endequation}{1}:]
+% As default, work for equation numbers at the right:
+% Then, a |\quad| is placed between equation number and endmark.
+% \item[Line \Coderef{standard-endequation}{2}:]
+% In addition to the equation number (set by |\@eqnnum| at the
+% right of the line) |\SetMark@endeqn| is carried out.
+% \end{packeddescr}\end{macro}
+%
+% \begin{macro}{\[}
+% If an end mark is set, a displaymath is put into box such that
+% the end marks appears at its bottom level at the right. Thus, also
+% the definition of |\[| has to be changed:
+% \Codelabel{st-b-displ}
+% \begin{macrocode}
+\gdef\[{%
+ \relax\ifmmode
+ \@badmath
+ \else
+ \ifvmode
+ \nointerlineskip
+ \makebox[.6\linewidth]%
+ \fi
+ $$\stepcounter{end\InTheoType ctr}%
+ \@ifundefined{mark\roman{curr\InTheoType ctr}%
+ \InTheoType\roman{end\InTheoType ctr}}{\relax}%
+ {\ifx\csname\InTheoType Symbol\endcsname\@empty\else
+ \boxmaxdepth=.5ex\begin{array}[b]{l}%
+ \boxmaxdepth=\maxdimen\displaystyle\fi}%
+ \addtocounter{end\InTheoType ctr}{-1}%
+ %%$$ BRACE MATCH HACK
+ \fi}
+% \end{macrocode}
+%
+% \begin{packeddescr}
+% \item[Lines \Coderef{st-b-displ}{2}--\Coderef{st-b-displ}{8},
+% \Coderef{st-b-displ}{16}, \Coderef{st-b-displ}{17}:]
+% the old definition.
+% \item[Lines \Coderef{st-b-displ}{9}--\Coderef{st-b-displ}{12}:]
+% The end position of a displaymath inside a theorem-environment
+% corresponds to |end\InTheoType ctr|+1.
+% An endmark has to be set there, if \\
+% \hspace*{0.5cm} |\mark|$<$|\roman{curr#1ctr}|$>$|#1|%
+% $<$|\roman{end#1ctr}|$+1>$
+% is defined and not the empty symbol.
+% \item[Lines \Coderef{st-b-displ}{13}--\Coderef{st-b-displ}{14}:]
+% If so, the whole displayed stuff is put in an array with
+% maximal depth 0.5|ex| and vertically adjusted with its bottom line
+% (then, the endmarks will appear adjusted to its bottom line).
+% \item[Line \Coderef{st-b-displ}{15}:]The counter has to be re-decremented.
+% \end{packeddescr}\end{macro}
+%
+% \begin{macro}{\]}
+% At the end of a displaymath, the end marks is set at its bottom level:
+% \Codelabel{st-e-displ}
+% \begin{macrocode}
+\gdef\]{%
+ \stepcounter{end\InTheoType ctr}%
+ \@ifundefined{mark\roman{curr\InTheoType ctr}%
+ \InTheoType\roman{end\InTheoType ctr}}{\relax}%
+ {\ifx\csname\InTheoType Symbol\endcsname\@empty\else
+ \end{array}\fi}%
+ \addtocounter{end\InTheoType ctr}{-1}%
+ \relax\ifmmode
+ \ifinner
+ \@badmath
+ \else
+ \PotEndMark{\eqno}\global\@ignoretrue$$%%$$ BRACE MATCH HACK
+ \fi
+ \else
+ \@badmath
+ \fi
+ \ignorespaces}
+% \end{macrocode}
+%
+% \begin{packeddescr}
+% \item[Lines \Coderef{st-e-displ}{2}--\Coderef{st-e-displ}{7}:]
+% Look, if an endmark has to be set in this displaymath
+% (analogous to lines
+% \Coderef{st-b-displ}{9}--\Coderef{st-b-displ}{15} of |\def\[|)
+% If so, there is an inner array which has to be closed
+% (line \Coderef{st-e-displ}{6}).
+% \item[Lines \Coderef{st-e-displ}{8}--\Coderef{st-e-displ}{17}:]
+% the old definition.
+% \item[Line \Coderef{st-e-displ}{12}:] changed to set an endmark at
+% the right of the line if necessary (this is done by |\eqno|).
+% \end{packeddescr}\end{macro}
+%
+% \begin{macro}{\endeqnarray}
+% For |\eqnarray|s, the end marks is set below the number
+% of the last equation:
+% \changes{v0.90}{1997/02/19}{fixed endmark for `eqnarrays' (WM)}
+% \changes{v0.91}{1997/02/22}{fixed `endeqnarray' (WM)}
+% \Codelabel{st-endeqnarray}
+% \begin{macrocode}
+\gdef\SetMark@endeqnarray#1{\llap{\raisebox{-1.3em}{#1}}}
+\gdef\endeqnarray{%
+ \global\let\Oldeqnnum=\@eqnnum
+ \gdef\@eqnnum{\Oldeqnnum\PotEndMark{\SetMark@endeqnarray}}%
+ \@@eqncr
+ \egroup
+ \global\advance\c@equation\m@ne
+ $$\global\@ignoretrue
+ \global\let\@eqnnum\Oldeqnnum}
+% \end{macrocode}
+%
+% \begin{packeddescr}
+% \item[Line \Coderef{st-endeqnarray}{1}:]
+% As default work for equation numbers at the right:
+% Then, the endmark is placed below the last equation number at the
+% right margin.
+% \item[New: Lines \Coderef{st-endeqnarray}{3},%
+% \Coderef{st-endeqnarray}{4}, \Coderef{st-endeqnarray}{9}:]\
+% \item[Line \Coderef{st-endeqnarray}{3}:] save |\@eqnnum|.
+% \item[Line \Coderef{st-endeqnarray}{4}:]
+% define |\@eqnnum| to carry out |\Oldeqnnum|, then a potential endmark
+% position is handled:
+% if an endmark is set, between the equation number and the endmark,
+% the command sequence |\SetMark@endeqnarray| is carried out --
+% there, since |\SetMark@endeqnarray| is a function of one
+% argument, the endmark will be this argument.
+% \item[Lines \Coderef{st-endeqnarray}{5}--\Coderef{st-endeqnarray}{8}:]
+% from |latex.ltx|.
+% Line \Coderef{st-endeqnarray}{5} sets the equation number.
+% \item[Line \Coderef{st-endeqnarray}{9}:] restore |\@eqnnum|.
+% \end{packeddescr}\end{macro}
+%
+% \begin{macro}{\endeqnarray*}
+% In an |\eqnarray*|, the end mark is set at the right of the
+% last equation:
+% \Codelabel{st-endeqnarray-star}
+% \begin{macrocode}
+\@namedef{endeqnarray*}{%
+ % from \@@eqncr:
+ \let\reserved@a\relax
+ \ifcase\@eqcnt \def\reserved@a{& & &}\or \def\reserved@a{& &}%
+ \or \def\reserved@a{&}\else
+ \let\reserved@a\@empty
+ \@latex@error{Too many columns in eqnarray environment}\@ehc\fi
+ \reserved@a {\normalfont \normalcolor \PotEndMark{}}%
+ \global\@eqnswtrue\global\@eqcnt\z@\cr
+ %
+ \egroup
+ \global\advance\c@equation\m@ne
+ $$\global\@ignoretrue}
+% \end{macrocode}
+%
+% This is just \LaTeX's |\endeqnarray| where lines
+% \Coderef{st-endeqnarray-star}{3}--\Coderef{st-endeqnarray-star}{9}
+% are inserted from |\@@eqncr| and augmented (line
+% \Coderef{st-endeqnarray-star}{8}) to set a potential endmark
+% (with no additional commands) at the end of the current line.
+% \end{macro}
+%
+% \paragraph{Changes to Tabbing Environment}\ \\
+% Original: lttab.dtx
+%
+%\begin{macro}{\endtabbing}%
+% \changes{v1.04}{1998/05/26}{added 'endtabbing' (WM)}
+% Here, the |\endtrivlist| modification is not sufficient: \LaTeX\ is
+% not in hmode when it calls |\endtrivlist| from |\endtabbing|;
+% additionally, |\@stopline| already outputs a linebreak.
+% Thus, the end mark is inserted \emph{before} |\@stopline| at
+% the right margin (using |\`|).
+% \begin{macrocode}
+\gdef\endtabbing{%
+ \PotEndMark{\`}\@stopline\ifnum\@tabpush >\z@ \@badpoptabs
+ \fi\endtrivlist}
+% \end{macrocode}
+% \end{macro}
+%
+% \paragraph{Changes to Center Environment}\ \\
+% Original: ltmiscen.dtx
+%
+%\begin{macro}{\endcenter}%
+% In \LaTeX, |\endcenter| just calls |\endtrivlist|.
+% Here, the situation is more complex since the the endmark has
+% to be put in the last line without affecting its centering:
+% if in a text line (only then, here is a potential endmark
+% position):
+% \begin{macrocode}
+\gdef\endcenter{%
+ \@endtrivlist
+ {\PotEndMark{\rightskip0pt%
+ \settowidth{\leftskip}%
+ { \csname mark\roman{curr\InTheoType ctr}\InTheoType
+ \roman{end\InTheoType ctr}\endcsname}%
+ \advance\leftskip\@flushglue\hskip\@flushglue}}}
+% \end{macrocode}
+%
+% The |\rightskip| of the line is set to 0, |\leftskip|
+% is set to the width of one space (since on the right, one space is
+% added after the text) plus the endmark and infinitely stretchable glue
+% (|\@flushglue|), and also the line is continued with
+% |\@flushglue| (the actual position is one space after the text),
+% and then the endmark is placed (by |\PotEndMark|).
+% \end{macro}
+%
+% \paragraph{Handling of Endmarks}
+%
+% \begin{macro}{\@endtheorem-thmmarks}
+% |\@endtheorem| is called for every |\end{|\env|}|, where \env\ is a
+% theorem-like environment. |\@endtheorem| is extended to organize
+% the placement of the corresponding end mark
+% (|\InTheoType| gives the innermost theorem-like environment,
+% i.e.\ the one to be ended):
+%
+% \Codelabel{atendtheorem}
+% \begin{macrocode}
+\gdef\@empty{}
+\gdef\@endtheorem{%
+ \expandafter
+ \ifx\csname\InTheoType Symbol\endcsname\@empty\setendmarkfalse\fi
+ \@endtrivlist
+ {\ifsetendmark
+ \unskip\nobreak\hfill\nobreak\csname\InTheoType Symbol\endcsname
+ \setendmarkfalse \fi}%
+ \ifsetendmark\OrganizeTheoremSymbol\else\global\setendmarktrue\fi
+ \csname\InTheoType @postwork\endcsname
+ }
+% \end{macrocode}
+% \changes{v0.91}{1997/02/27}{'@empty' fixed (WM)}
+% \changes{v0.94}{1997/03/19}{'setendmarktrue' globalized (WM)}
+% \changes{v1.19}{2001/01/13}{changed hbox into unskip (OK/WM)}
+% \changes{v1.21}{2002/12/30}{added handling of 'theorempostwork' (WM)}
+%
+% \begin{packeddescr}
+% \item[Lines \Coderef{atendtheorem}{3}, \Coderef{atendtheorem}{4}:]
+% if the end symbol of the environment $\env$ to be closed is
+% empty, simply no end symbol has to be set (it makes a difference, if no
+% end symbol is set, or if an empty end symbol is set).
+% \item[Lines \Coderef{atendtheorem}{5}, \Coderef{atendtheorem}{9}:]
+% (originally, it calls |\endtrivlist|):
+% \item[Lines \Coderef{atendtheorem}{5}, \Coderef{atendtheorem}{7},
+% \Coderef{atendtheorem}{8}:]
+% |\@endtrivlist| is called to put $\env$|Symbol|
+% at the end of the line and set |setendmark| to false
+% if \TeX\ is in a text line and |setendmark| is true. \\
+% At this point, |setendmark| is false iff the user has disabled
+% it locally or the end symbol is empty.
+% \item[Line \Coderef{atendtheorem}{6}:] the endmark is not set,
+% if |setendmark| is false.
+% \item[Line \Coderef{atendtheorem}{9}:]
+% if |setendmark| is true, the correct placement of the end
+% symbol is organized, else (ie either |setendmarkfalse| is set
+% by the user, or the endmark is already set by |\@endtrivlist|)
+% reset |setendmark| to true.\\
+% For further comments see |\@endtrivlist| and
+% |\OrganizeTheoremSymbol|.
+% \end{packeddescr}
+% The construction in line \Coderef{atendtheorem}{7} guarantees that
+% the endmark is put at the end of the line, even if it is the only
+% letter in this line.
+% \end{macro}
+%
+% \begin{macro}{\NoEndMark}
+% By |\NoEndMark|, the automatical setting of an end mark is blocked
+% for the \emph{current} environment.
+% \begin{macrocode}
+\gdef\NoEndMark{\global\setendmarkfalse}
+% \end{macrocode}
+% \changes{v0.94}{1997/03/19}{'NoEndMark' introduced (WM)}
+% \end{macro}
+%
+% set |setendmark| to false. It is automatically reset to |true| after
+% the end of the current environment.
+%
+% \begin{macro}{\qed}
+% With |\qed|, the user can locally change the end symbol to appear:
+% \begin{macrocode}
+\gdef\qed{\expandafter\def\csname \InTheoType Symbol\endcsname
+ {\the\qedsymbol}}%
+% \end{macrocode}\end{macro}
+%
+% When calling |\qed|, the end symbol of the innermost theorem-like
+% environment at that time is set to the value stored in |\qedsymbol|
+% at that time.
+%
+% \begin{macro}{\PotEndMark}
+% Handling a potential endmark position:
+%
+% \begin{macrocode}
+\gdef\PotEndMark#1{\SetEndMark{\InTheoType}{#1}}%
+% \end{macrocode}
+%
+% Argument: \meta{cmd\_seq}:=|#1| is a command sequence to be
+% executed when setting the endmark. \\
+% It adds the current theorem type \env\ to the parameters, and
+% calls \\
+% |\PotEndMark{|\env|}{|\meta{cmd\_seq}|}|.
+% \end{macro}
+%
+% \begin{macro}{\SetEndMark}
+% |\SetEndMark| sets an endmark for an environment. It is
+% called by |\PotEndMark|.
+% \changes{v1.16}{1999/08/05}{extended for handling right indents (quote) (WM)}
+% \changes{v1.16}{2001/11/28}{removed tilde in hbox (WM)}
+% \Codelabel{SetEndMark}
+% \begin{macrocode}
+\gdef\SetEndMark#1#2{%
+ \stepcounter{end#1ctr}%
+ \@ifundefined{mark\roman{curr#1ctr}#1\roman{end#1ctr}}%
+ {\relax}%
+ {#2{\csname mark\roman{curr#1ctr}#1\roman{end#1ctr}\endcsname
+ \ifdim\rightmargin>\z@\hskip-\rightmargin\fi
+ \hbox to 0cm{}}}}%
+% \end{macrocode}
+%
+% Arguments: \\
+% \env:=|#1|: current theorem-environment. \\
+% \meta{cmd\_seq}:= |#2|: is a command sequence to be executed when setting
+% the endmark. Both arguments are transmitted from by |\PotEndMark|. \\
+% \begin{packeddescr}
+% \item[Line \Coderef{SetEndMark}{2}:]
+% increments |end|\env|ctr| for preparing the next situation
+% for setting a potential endmark.
+% \item[Line \Coderef{SetEndMark}{3}, \Coderef{SetEndMark}{4}:]
+% if
+% \begin{quote}
+% |\mark|$<$|\roman{curr|\env|ctr}|$>$\env%
+% $<$|\roman{end|\env|ctr}|$>$
+% \end{quote}
+% is undefined
+% -- which is the case iff at this position no endmark has to be set --,
+% nothing is done,
+% \item[Line \Coderef{SetEndMark}{5}:]
+% otherwise, \meta{cmd\_seq} and then
+% \begin{quote}
+% |\mark|$<$|\roman{curr|\env|ctr}|$>$|\env|%
+% $<$|\roman{end|\env|ctr}|$>$,
+% \end{quote}
+% which is defined in the |.aux| file to be the end symbol are called. \\
+% The construction \meta{cmd\_seq}|{|\ldots|}| in line
+% \Coderef{SetEndMark}{5} allows the handling of the end symbol as an
+% argument of \meta{cmd\_seq} as needed for |\endeqnarray|.
+% \item[Line \Coderef{SetEndMark}{6}:]
+% By |\hskip-\rightmargin\hbox to 0cm{}|, a negative hspace of
+% amount |\rightmargin| is added \emph{after} the end symbol -- thus,
+% the symbol is set as there were no right margin (this concerns,
+% e.g., |\quote| environments). \\
+% (applied only if |\rightmargin| is more than 0 -- otherwise bug
+% if preceding line ends with hyphenation.)
+% \end{packeddescr}
+% \changes{v1.20}{2001/12/30}{apply negative hskip only if more than 0 (WM)}
+%\end{macro}
+%
+% \paragraph{Writing to .aux file.}
+% (copied from |\def\label| (ltxref.dtx))
+%
+% \changes{v0.91}{1997/02/20}{fixed `OrganizeTheoremSymbol' (WM)}
+% \changes{v1.20}{2001/10/09}{check that not in vmode in bbsphack (WM)}
+% \Codelabel{bbsphack}
+% \begin{macrocode}
+\newskip\mysavskip
+\gdef\@bbsphack{%
+ \ifvmode\else\mysavskip\lastskip
+ \unskip\fi}
+%
+\gdef\@eesphack{%
+ \ifdim\mysavskip>\z@
+ \vskip\mysavskip \else\fi}
+% \end{macrocode}
+% \begin{packeddescr}
+% \item[Lines \Coderef{bbsphack}{2}--\Coderef{bbsphack}{4} and
+% \Coderef{bbsphack}{5}--\Coderef{bbsphack}{7}]
+% are similar to |\@bsphack| and |\@bsphack|
+% of latex.ltx. They undo resp.\ redo the last |skip|.
+% \end{packeddescr}
+% Note that |@bbsphack| and |@eesphack| are also part of the
+% thref option. Change both if you change them.
+%
+% \begin{macro}{\OrganizeTheoremSymbol}
+% The information for setting the end marks is written to the .aux file:
+%
+% \Codelabel{OrgThSymb}
+% \begin{macrocode}
+\gdef\OrganizeTheoremSymbol{%
+ \@bbsphack
+ \edef\thm@tmp{\expandafter\expandafter\expandafter\thm@meaning
+ \expandafter\meaning\csname\InTheoType Symbol\endcsname\relax}%
+ \protected@write\@auxout{}%
+ {\string\global\string\def\string\mark%
+ \roman{curr\InTheoType ctr}\InTheoType \roman{end\InTheoType ctr}%
+ {\thm@tmp}}%
+ \@eesphack}
+% \end{macrocode}
+%
+% \begin{packeddescr}
+% \item[Lines \Coderef{OrgThSymb}{5}--\Coderef{OrgThSymb}{7}:]
+% Write \\
+% |\global\def\mark|$<$|\roman{curr|\env|ctr}|$>\env
+% <$|\roman{end|\env|ctr}|$>$%
+% |{<|\env|Symbol>}|
+% to the |.aux| file. \\
+% \env :=|\InTheoType| gives the innermost theorem-like environment,
+% i.e. the one the end symbol has to be set for.
+% \end{packeddescr}\end{macro}
+%
+% \begin{macrocode}
+} % end of option [thmmarks]
+% \end{macrocode}
+%
+% \subsubsection{Option leqno to Thmmarks}
+%
+% \Codelabel{Optleqno}
+% \begin{macrocode}
+\DeclareOption{leqno}{% *********************************************
+ \if@thmmarks
+ \PackageInfo{\basename}{Option `leqno' loaded}%
+ \gdef\SetMark@endeqn#1{\hss\llap{#1}}
+ \gdef\SetMark@endeqnarray#1{\hss\llap{#1}}
+ \fi}%
+% \end{macrocode}
+% |leqno| is only active it |thmmarks| is also active. \\
+% \begin{packeddescr}
+% \item[Line \Coderef{Optleqno}{4}, \Coderef{Optleqno}{5}:]
+% Since with |leqno|, the equation number is placed on
+% the left, after infinitely stretchable glue, the endmark can be
+% set straight at the right margin.
+% \end{packeddescr}
+%
+% \subsubsection{Option fleqn to Thmmarks}
+%
+% \begin{macrocode}
+\DeclareOption{fleqn}{% *********************************************
+\if@thmmarks
+ \PackageInfo{\basename}{Option `fleqn' loaded}%
+% \end{macrocode}
+%
+% |fleqn| is only active it |thmmarks| is also active.
+%
+% \begin{macro}{\[}
+% Since |fleqn| treats displayed math as trivlists, it's quite
+% another thing:
+%
+% \Codelabel{fleqn-b-displ}
+% \begin{macrocode}
+ \renewcommand\[{\relax
+ \ifmmode\@badmath
+ \else
+ \begin{trivlist}%
+ \@beginparpenalty\predisplaypenalty
+ \@endparpenalty\postdisplaypenalty
+ \item[]\leavevmode
+ \hb@xt@\linewidth\bgroup $\m@th\displaystyle %$
+ \hskip\mathindent\bgroup
+ \stepcounter{end\InTheoType ctr}%
+ \@ifundefined{mark\roman{curr\InTheoType ctr}%
+ \InTheoType\roman{end\InTheoType ctr}}{\relax}%
+ {\ifx\csname\InTheoType Symbol\endcsname\@empty\else
+ \boxmaxdepth=.5ex\begin{array}[b]{l}%
+ \boxmaxdepth=\maxdimen\displaystyle\fi}%
+ \addtocounter{end\InTheoType ctr}{-1}%
+ \fi}
+% \end{macrocode}
+%
+% \begin{packeddescr}
+% \item[Lines \Coderef{fleqn-b-displ}{1}--\Coderef{fleqn-b-displ}{9},%
+% \Coderef{fleqn-b-displ}{17}:]
+% the old definition.
+% \item[Line \Coderef{fleqn-b-displ}{10}--\Coderef{fleqn-b-displ}{16}:]
+% if an endmark has to be set in this displaymath, it
+% is put into an array with depth $\le 0.5$|ex|, and vertically
+% adjusted to the bottom line.
+% \end{packeddescr}\end{macro}
+%
+% \begin{macro}{\]}
+% Here, the end mark is placed after a |\hfil| ate the end of the line
+% containing the displaymath:
+%
+% \Codelabel{fleqn-e-displ}
+% \begin{macrocode}
+ \renewcommand\]{%
+ \stepcounter{end\InTheoType ctr}%
+ \@ifundefined{mark\roman{curr\InTheoType ctr}%
+ \InTheoType\roman{end\InTheoType ctr}}{\relax}%
+ {\ifx\csname\InTheoType Symbol\endcsname\@empty\else
+ \end{array}\fi}%
+ \addtocounter{end\InTheoType ctr}{-1}%
+ \relax\ifmmode
+ \egroup $\hfil\PotEndMark{}% $
+ \egroup
+ \end{trivlist}%
+ \else \@badmath
+ \fi}
+% \end{macrocode}
+%
+% \begin{packeddescr}
+% \item[Lines \Coderef{fleqn-e-displ}{2}--\Coderef{fleqn-e-displ}{6}:]
+% Look, if an endmark has to be set in this displaymath.
+% If so, close the inner array.
+% \item[Lines \Coderef{fleqn-e-displ}{8}--\Coderef{fleqn-e-displ}{13}:]
+% the old definition.
+% \item[Line \Coderef{fleqn-e-displ}{9}:] Added |\PotEndMark|.
+% \end{packeddescr}\end{macro}
+%
+% \begin{macro}{\endequation}
+% for equations, the end mark is also set with the equation number:
+% \Codelabel{fleqn-endeqn}
+% \begin{macrocode}
+\gdef\endequation{%
+ $\hfil % $
+ \displaywidth\linewidth\hbox{\@eqnnum \PotEndMark{\SetMark@endeqn}}%
+ \egroup
+ \endtrivlist}
+% \end{macrocode}
+%
+% \begin{packeddescr}
+% \item[Line \Coderef{fleqn-endeqn}{3}:]
+% When the equation number is set, also the endmark is set with
+% the same trick as for |\endequation| without |fleqn|.
+% \end{packeddescr}\end{macro}
+%
+% \begin{macro}{\endeqnarray}
+% When the equation number is set, also the endmark is set with
+% the same trick as for |\endeqnarray| without |fleqn| (see
+% Lines \Coderef{fleqn-endeqnarray}{2}, \Coderef{fleqn-endeqnarray}{3},%
+% \Coderef{fleqn-endeqnarray}{8}):
+%
+% \Codelabel{fleqn-endeqnarray}
+% \begin{macrocode}
+\gdef\endeqnarray{%
+ \global\let\Oldeqnnum=\@eqnnum
+ \gdef\@eqnnum{\Oldeqnnum\PotEndMark{\SetMark@endeqnarray}}%
+ \@@eqncr
+ \egroup
+ \global\advance\c@equation\m@ne$$% $$
+ \global\@ignoretrue
+ \global\let\@eqnnum\Oldeqnnum}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\fi}% end of option fleqn
+% \end{macrocode}
+%
+% \subsubsection{Extended Referencing Facilities}\label{sec:Referencing}
+%
+% \begin{macrocode}
+\DeclareOption{thref}{%**********************************************
+ \PackageInfo{\basename}{Option `thref' loaded}%
+\@threftrue
+% \end{macrocode}
+%
+% Option ``thref'' needs a special handling when combined with amsmath.
+% This is also a reason why it is handled first.
+%
+% \begin{macro}{\bbsphack(2)}
+% \changes{v1.19}{2001/01/12}{added to thref option (error if thref
+% was used without thmmarks; OK/WM)}
+% \changes{v1.20}{2001/10/09}{check that not in vmode in bbsphack; (WM)}
+% \begin{macrocode}
+\newskip\mysavskip
+\gdef\@bbsphack{%
+ \ifvmode\else\mysavskip\lastskip
+ \unskip\fi}
+%
+\gdef\@eesphack{%
+ \ifdim\mysavskip>\z@
+ \vskip\mysavskip \else\fi}
+% \end{macrocode}
+% Note that |@bbsphack| and |@eesphack| are also part of the
+% thmmarks option. Change both if you change them.
+% \end{macro}
+%
+% \begin{macro}{\label}
+% \changes{v1.1}{1998/08/30}{added optional argument to 'label'. (WM)}
+% \changes{v1.18}{1999/12/25}{Adapted for complex keywords (WM)}
+% The original |\label| macro is extended (cf.\ ltxref.dtx) with an
+% optional argument, containing the type of the labeled construct:
+% \Codelabel{label}
+% \begin{macrocode}
+\def\label#1{%
+ \@ifnextchar[%]
+ {\label@optarg{#1}}%
+ {\thm@makelabel{#1}}}
+%
+\def\thm@makelabel#1{%
+ \@bbsphack
+ \edef\thm@tmp{\expandafter\expandafter\expandafter\thm@meaning
+ \expandafter\meaning\csname\InTheoType Keyword\endcsname\relax}%
+ \protected@write\@auxout{}%
+ {\string\newlabel{#1}{{\@currentlabel}{\thepage}}[\thm@tmp]}%
+ \@eesphack}
+%
+\def\label@optarg#1[#2]{%
+ \@bsphack
+ \protected@write\@auxout{}%
+ {\string\newlabel{#1}{{\@currentlabel}{\thepage}}[#2]}%
+ \@esphack}
+% \end{macrocode}
+%
+% \begin{packeddescr}
+% \item[|thm@makelabel|:]
+% If no optional argument is given, the keyword of the current
+% environment type is used instead.
+% \item[|label@optarg|:]
+% The original definition, extended with the optional argument
+% which is appended to the |\newlabel|-command to be written
+% to the .aux-file.
+% \end{packeddescr}
+% \end{macro}
+%
+% \begin{macro}{\newlabel}
+% \changes{v1.1}{1998/08/30}{added modified macro '@newl@bel'. (WM)}
+% The original behavior of |\newlabel| (called when evaluating
+% the .aux-file) is also adapted. \\
+% Original syntax:
+% |\newlabel{|\meta{label}|}{{|\meta{section}|}{|\meta{page}|}}|\\
+% Modified syntax:
+% |\newlabel{|\meta{label}|}|%
+% |{{|\meta{section}|}{|\meta{page}|}}[|\meta{type}|]|\\
+% Definition of |\newlabel|: |\def\newlabel{\@newl@bel r}|. \\
+% Therefore, the modification is encoded into the |\@newl@bel| macro:
+%
+% \Codelabel{newlabel}
+% \changes{v1.18}{1999/12/26}{adapted to babel-3.6 (WM)}
+% \begin{macrocode}
+\def\@newl@bel#1#2#3{%
+ \@ifpackageloaded{babel}{\@safe@activestrue}\relax%
+ \@ifundefined{#1@#2}%
+ \relax
+ {\gdef \@multiplelabels {%
+ \@latex@warning@no@line{There were multiply-defined labels}}%
+ \@latex@warning@no@line{Label `#2' multiply defined}}%
+ \global\@namedef{#1@#2}{#3}%
+ \@ifnextchar[{\set@label@type{#1}{#2}}%]
+ \relax}%
+\def\set@label@type#1#2[#3]{%
+ \global\@namedef{#1@#2@type}{#3}}
+% \end{macrocode}
+%
+% the macro is called with three arguments (same as originally):\\
+% |#1|=|r|, \\
+% \meta{labelname} := |#2| is the label name,\\
+% |#3| is a pair (section, page-number) consisting of the values
+% needed for |\ref| and |\pageref|, respectively.
+%
+% \begin{packeddescr}
+% \item[Line \Coderef{newlabel}{2}:] adaptation to babel
+% \item[Lines \Coderef{newlabel}{3}--\Coderef{newlabel}{8}:]
+% The original definition (both standard \LaTeX\ and babel).
+% \item[Line \Coderef{newlabel}{9}:] if an optional argument
+% follows (containing the environment-type), continue with
+% |\set@label@type|, otherwise return (the original behavior).
+% \item[Lines \Coderef{newlabel}{11},\Coderef{newlabel}{12}:]
+% set |\r@|\meta{labelname}|@type| to the type of the
+% respective environment.
+% \end{packeddescr}
+% \end{macro}
+
+
+% \begin{macro}{\testdef}
+% \changes{v1.19}{2001/01/12}{added (HO/WM, reported by Hans-Christoph Wirth)}
+% A problem occurred, when about 250 labels to theorem-like
+% environments have been defined: after the end of a document,
+% the .aux file is read once more (to check if references changed).
+% Here, \LaTeX\ redefines |\@newl@bel| into |\@testdef| -- and
+% \LaTeX\ does not know that ntheorem's |\label| has an additional
+% optional argument. Thus, the argument values are not processed,
+% but are output as normal text. Normally, this did not matter
+% since output has already benn finished by a |\clearpage| in
+% |\end{document}|. For so many labels, a page gets filled
+% and the output routine is called.
+%
+% \Codelabel{testdef}
+% \begin{macrocode}
+\newcommand\org@testdef{}
+\let\org@testdef\@testdef
+\def\@testdef#1#2#3{%
+ \org@testdef{#1}{#2}{#3}%
+ \@ifnextchar[{\@gobbleopt}{}%
+}
+\newcommand\@gobbleopt{}
+\long\def\@gobbleopt[#1]{}
+% \end{macrocode}
+% \begin{packeddescr}
+% \item[Line \Coderef{testdef}{4}:]
+% process the optional argument.
+% \end{packeddescr}
+% \end{macro}
+%
+% \begin{macro}{\thref}
+% \changes{v1.1}{1998/08/30}{added macro 'thref'. (WM)}
+% \changes{v1.13}{1998/12/01}{made 'thref' an option. (WM)}
+%
+% |\thref| is an adaptation of |\ref|:
+% \Codelabel{thref}
+% \begin{macrocode}
+\def\thref#1{%
+ \expandafter\ifx\csname r@#1@type\endcsname\None
+ \PackageWarning{\basename}{thref: Reference Type of `#1' on page
+ \thepage \space undefined}\G@refundefinedtrue
+ \else\csname r@#1@type\endcsname~\fi%
+ \expandafter\@setref\csname r@#1\endcsname\@firstoftwo{#1}}
+% \end{macrocode}
+%
+% \begin{packeddescr}
+% \item[Lines \Coderef{thref}{1},\Coderef{thref}{6}:]
+% similar to |\ref|.
+% \item[Line \Coderef{newlabel}{2}:] if a legal theorem type
+% is given, then output
+% |\r@|\meta{labelname}|@type| and avoid linebreaking
+% between the type and the number.
+% \end{packeddescr}
+% \end{macro}
+% \begin{macrocode}
+}% end of option thref ************************************************
+% \end{macrocode}
+%
+% \subsubsection{Option amsmath to Thmmarks}
+% Most of the commands are extensions of commands in |amsmath.sty|.
+%
+% \begin{macrocode}
+\DeclareOption{amsmath}{% ***************************************************
+\if@thref
+ \PackageInfo{\basename}{option `amsmath' handling for `thref' loaded}%
+% \end{macrocode}
+%
+% if |thref| is active, the handling of labels in amsmath equations has also
+% to be adapted.
+%
+% \begin{macro}{ams-thref}
+% \changes{v1.19}{2001/01/12}{added handling of thref in ams-equations
+% (reported by Lars Relund).}
+% \begin{macrocode}
+\let\ltx@label\label
+% \end{macrocode}
+% keep the handling of |\label| ... (the one defined above in the thref option).
+%
+% amsmath implements a special handling of |\label| inside of displaymath
+% environments. It is extended to process the optional argument provided
+% be the thref option:
+%
+% \begin{macrocode}
+\global\let\thm@df@label@optarg\@empty
+\def\label@in@display#1{%
+ \ifx\df@label\@empty\else
+ \@amsmath@err{Multiple \string\label's:
+ label '\df@label' will be lost}\@eha
+ \fi
+ \gdef\df@label{#1}%
+ \@ifnextchar[{\thm@label@in@display@optarg}{\thm@label@in@display@noarg}%]
+}
+\def\thm@label@in@display@noarg{%
+ \global\let\thm@df@label@optarg\@empty
+}
+\def\thm@label@in@display@optarg[#1]{%
+ \gdef\thm@df@label@optarg{#1}%
+}
+% \end{macrocode}
+% \changes{v1.22}{2003/06/25}{fixed thm@df@label@optarg (WM, reported by
+% Marija Kulas)}
+%
+% The contents of |\df@label| is handled when the equation is finished.
+% (Currently) this happens in three macros. The modification consists
+% of the check if |\thm@df@label@optarg| is non-empty (i.e., holds the
+% optional argument), and to handle it.
+%
+% \begin{macrocode}
+\def\endmathdisplay@a{%
+ \if@eqnsw \gdef\df@tag{\tagform@\theequation}\fi
+ \if@fleqn \@xp\endmathdisplay@fleqn
+ \else \ifx\df@tag\@empty \else \veqno \alt@tag \df@tag \fi
+ \ifx\df@label\@empty \else
+ \ifx\thm@df@label@optarg\@empty \@xp\ltx@label\@xp{\df@label}
+ \else \@xp\ltx@label\@xp{\df@label}[\thm@df@label@optarg]\fi
+ \fi
+ \fi
+ \ifnum\dspbrk@lvl>\m@ne
+ \postdisplaypenalty -\@getpen\dspbrk@lvl
+ \global\dspbrk@lvl\m@ne
+ \fi
+}
+\def\make@display@tag{%
+ \if@eqnsw
+ \refstepcounter{equation}%
+ \tagform@\theequation
+ \else
+ \iftag@
+ \df@tag
+ \global\let\df@tag\@empty
+ \fi
+ \fi
+ \ifmeasuring@
+ \else
+ \ifx\df@label\@empty\else
+ \ifx\thm@df@label@optarg\@empty \@xp\ltx@label\@xp{\df@label}
+ \else \@xp\ltx@label\@xp{\df@label}[\thm@df@label@optarg]\fi
+ \global\let\df@label\@empty
+ \fi
+ \fi
+}
+\def\endmathdisplay@fleqn{%
+ $\hfil\hskip\@mathmargin\egroup
+ \ifnum\badness<\inf@bad \let\too@wide\@ne \else \let\too@wide\z@ \fi
+ \ifx\@empty\df@tag
+ \else
+ \setbox4\hbox{\df@tag
+ \ifx\thm@df@label@optarg\@empty \@xp\ltx@label\@xp{\df@label}
+ \else \@xp\ltx@label\@xp{\df@label}[\thm@df@label@optarg]\fi
+ }%
+ \fi
+ \csname emdf@%
+ \ifx\df@tag\@empty U\else \iftagsleft@ L\else R\fi\fi
+ \endcsname
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+\fi
+% end of option amsmath/thref ******************************************
+\if@thmmarks
+ \PackageInfo{\basename}{option `amsmath' handling for `thmmarks' loaded}%
+\newdimen\thm@amstmpdepth
+% \end{macrocode}
+% A temporarily used register.
+%
+% \begin{macro}{\TagsPlusEndmarks}
+% \changes{v1.03}{1997/07/15}{Fixed 'TagsPlusEndMarks', introduced
+% 'SetOnlyEndMark' and 'SetTagPlusEndMark' (WM)}
+% Since |amsmath| uses ``tags'' for setting end marks,
+% some macros are defined which prepare tags which include endmarks:
+% \Codelabel{EndTags}
+% \begin{macrocode}
+\gdef\TagsPlusEndmarks{%
+ \global\let\Old@maketag@@@=\maketag@@@
+ \global\let\Old@df@tag=\df@tag
+ \if@eqnsw\SetTagPlusEndMark
+ \else
+ \iftag@\SetTagPlusEndMark
+ \else\SetOnlyEndMark
+ \fi
+ \fi}
+% \end{macrocode}
+% \begin{packeddescr}
+% \item[Lines \Coderef{EndTags}{2}, \Coderef{EndTags}{3}:]
+% store the original macros.
+% \item[Line \Coderef{EndTags}{4}:]
+% if equation numbers are set as default, call
+% |\SetTagPlusEndMark| to set tag and end mark.
+% \item[Line \Coderef{EndTags}{5}:]
+% if a tag is set manually, call
+% |\SetTagPlusEndMark| to set tag and end mark.
+% \item[Line \Coderef{EndTags}{6}:]
+% otherwise, call |\SetOnlyEndMark| to set only an end mark.
+% \end{packeddescr}
+% \end{macro}
+%
+% \begin{macro}{\SetOnlyEndMark}
+% \Codelabel{OnlyEnd}
+% \begin{macrocode}
+\gdef\SetOnlyEndMark{%
+ \global\tag@true
+ \iftagsleft@
+ \gdef\df@tag{\hbox
+ to \displaywidth{\hss\PotEndMark{\maketag@@@}}}%
+ \else
+ \gdef\df@tag{\PotEndMark{\maketag@@@}}%
+ \fi}
+% \end{macrocode}
+% Set only an end mark:
+%
+% \begin{packeddescr}
+% \item[Line \Coderef{OnlyEnd}{2}:]
+% force setting the end mark as a tag:
+% \item[Lines \Coderef{OnlyEnd}{4},\Coderef{OnlyEnd}{5}:]
+% if tags are set to the left, the tag consists of a
+% |\hbox| over the whole displaywidth, with the (potential) endmark
+% at its right.
+% \item[Line \Coderef{OnlyEnd}{7}:]
+% if tags are set to the right, the tag consists only of the
+% (potential) endmark.
+% \end{packeddescr}
+% \end{macro}
+%
+% \begin{macro}{\SetTagsPlusEndMark}
+% \Codelabel{TagsPlus}
+% \begin{macrocode}
+\gdef\SetTagPlusEndMark{%
+ \iftagsleft@
+ \gdef\maketag@@@##1{%
+ \hbox to \displaywidth{\m@th\normalfont##1%
+ \hss\PotEndMark{\hss}}}%
+ \else
+ \gdef\maketag@@@##1{\hbox{\m@th\normalfont##1%
+ \llap{\hss\PotEndMark{\raisebox{-1.3em}}}}}%
+ \fi}
+% \end{macrocode}
+%
+% Set a tag \emph{and} an end mark:
+% \begin{packeddescr}
+% \item[Lines \Coderef{TagsPlus}{2}--\Coderef{TagsPlus}{9}:]
+% redefine the |\maketag@@@| macro:
+% \item[Lines \Coderef{TagsPlus}{3}--\Coderef{TagsPlus}{5}:]
+% if tags are set to the left, build a box of the whole
+% displaywidth and put the original tag on the left, and the (potential)
+% endmark at the right.
+% \item[Lines \Coderef{TagsPlus}{7},\Coderef{TagsPlus}{8}:]
+% if the tags are set to the right, the (potential) end
+% mark is put below it.
+% \end{packeddescr}
+% \changes{v1.20}{2001/12/29}{added hss if tags left (GD/WM)}
+% \end{macro}
+%
+% \begin{macro}{\RestoreTags}
+% \Codelabel{RestoreTags}
+% \begin{macrocode}
+\gdef\RestoreTags{%
+ \global\let\maketag@@@=\Old@maketag@@@
+ \global\let\df@tag=\Old@df@tag}
+% \end{macrocode}
+%
+% \begin{packeddescr}
+% \item[Lines \Coderef{RestoreTags}{2},\Coderef{RestoreTags}{3}:]
+% restore the original macros.
+% \end{packeddescr}\end{macro}
+%
+% \begin{macro}{\endgather}
+% \changes{v1.19}{2001/01/12}{adapted to amsmath-2.0 (GD/WM)}
+% In the |gather| environment, just the augmented tag is used:
+% \Codelabel{endgather}
+% \begin{macrocode}
+\gdef\endgather{%
+ \TagsPlusEndmarks % <<<<<<<<<
+ \math@cr
+ \black@\totwidth@
+ \egroup
+ $$%
+ \RestoreTags % <<<<<<<<<
+ \ignorespacesafterend}
+%
+\expandafter\let\csname endgather*\endcsname\endgather
+% \end{macrocode}
+%
+% New:
+% \begin{packeddescr}
+% \item[Line \Coderef{endgather}{2}:]
+% the last tag contains the potential endmark.
+% \item[Line \Coderef{endgather}{7}:]
+% restore the original macros.
+% \item[Line \Coderef{endgather}{10}:]
+% Since |let| always takes the expansion of a macro when the
+% let is executed, all let's have to be adjusted (this is the same
+% for all subsequent let-statements).
+% \end{packeddescr}\end{macro}
+%
+% \begin{macro}{\math@cr@@@align}
+% \changes{v1.12}{1998/11/15}{dropped redefinition of 'math@cr@@@align' (WM,
+% reported by Frank-Christian Otto)}
+% \end{macro}
+%
+% \begin{macro}{\endalign}
+% |\endalign| also uses the augmented tags:
+% \Codelabel{endalign}
+% \begin{macrocode}
+\def\endalign{%
+ \ifingather@\else % <<<<<<<<<
+ \TagsPlusEndmarks\fi % <<<<<<<<<
+ \math@cr
+ \black@\totwidth@
+ \egroup
+ \ifingather@
+ \restorealignstate@
+ \egroup
+ \nonumber
+ \ifnum0=`{\fi\iffalse}\fi
+ \else
+ $$%
+ \RestoreTags % <<<<<<<<<
+ \fi
+ \ignorespacesafterend}
+% \end{macrocode}
+%
+% \changes{v1.19}{2001/01/12}{adapted to amsmath-2.0 (GD/WM)}
+% New:
+% \begin{packeddescr}
+% \item[Lines \Coderef{endalign}{2}, \Coderef{endalign}{3}:]
+% if the |align| is not inside another environment,
+% its tags have to contain the endmarks.
+% \item[Line \Coderef{endalign}{14}:]
+% this case, the original macros have to be restored.
+% \end{packeddescr}\end{macro}
+%
+% \begin{macrocode}
+\expandafter\let\csname endalign*\endcsname\endalign
+\let\endxalignat\endalign
+\expandafter\let\csname endxalignat*\endcsname\endalign
+\let\endxxalignat\endalign
+\let\endalignat\endalign
+\expandafter\let\csname endalignat*\endcsname\endalign
+\let\endflalign\endalign
+\expandafter\let\csname endflalign*\endcsname\endalign
+% \end{macrocode}
+%
+% Adjust let-statements.
+%
+% \begin{macro}{\lendmultline}
+% The |multline| environment has two different |\end| commands,
+% depending if the equation numbers are set on the left or on the right:
+% \Codelabel{lendmultline}
+% \begin{macrocode}
+\def\lendmultline@{%
+ \global\@eqnswfalse\tag@false\tagsleft@false
+ \rendmultline@}
+% \end{macrocode}
+%
+% End of |multline| environment if tags are set to the left:
+% in this case, the last line of a |multline| does not contain a tag.
+% Thus the situation of setting an endmark tag at the right is faked:
+% \begin{packeddescr}
+% \item[Lines \Coderef{lendmultline}{2}, \Coderef{lendmultline}{3}:]
+% display no equation number, don't set an equation tag
+% (but use the tag mechanism for the end mark - see |\TagsPlusEndmarks|
+% and |\SetOnlyEndMark|), set it at the right,
+% and call |\rendmultline|.
+% \end{packeddescr}
+% \changes{v1.20}{2001/12/29}{debugged (GD/WM)}
+% \end{macro}
+%
+% \begin{macro}{\rendmultline}
+% |\rendmultline| also uses the augmented tags:
+% \Codelabel{rendmultline}
+% \begin{macrocode}
+\def\rendmultline@{%
+ \TagsPlusEndmarks % <<<<<<<<<
+ \iftag@
+ $\let\endmultline@math\relax
+ \ifshifttag@
+ \hskip\multlinegap
+ \llap{\vtop{%
+ \raise@tag
+ \normalbaselines
+ \setbox\@ne\null
+ \dp\@ne\lineht@
+ \box\@ne
+ \hbox{\strut@\make@display@tag}%
+ }}%
+ \else
+ \hskip\multlinetaggap
+ \make@display@tag
+ \fi
+ \else
+ \hskip\multlinegap
+ \fi
+ \hfilneg
+ \math@cr
+ \egroup$$%
+ \RestoreTags} % <<<<<<<<<
+% \end{macrocode}
+%
+% New: \\
+% Line \Coderef{rendmultline}{2}:
+% last tag contains the potential endmark. \\
+% Line \Coderef{rendmultline}{26}:
+% restore the original macros
+% \changes{v1.19}{2001/01/12}{adapted to amsmath-2.0 (GD/WM)}
+% \end{macro}
+%
+% \begin{macro}{\endmathdisplay}
+%
+% \Codelabel{ams-e-displ}
+% \begin{macrocode}
+\def\endmathdisplay#1{%
+ \ifmmode \else \@badmath \fi
+ \TagsPlusEndmarks % <<<<<<<<<
+ \endmathdisplay@a
+ $$%
+ \RestoreTags % <<<<<<<<<
+ \global\let\df@label\@empty \global\let\df@tag\@empty
+ \global\tag@false \global\let\alt@tag\@empty
+ \global\@eqnswfalse
+}
+% \end{macrocode}
+% \changes{v0.94}{1997/03/19}{end mark with raisebox (WM)}
+% \changes{v1.19}{2001/01/12}{completely new for amsmath-2.0, begin[ deleted (GD/WM)}
+% \end{macro}
+%
+% Added Line \Coderef{ams-e-displ}{4}: set potential end mark at
+% bottom niveau of displaymath.
+%
+% \begin{macro}{equation}
+% \changes{v1.19}{2001/01/12}{adapted to amsmath-2.0 (WM)}
+% \begin{macrocode}
+\renewenvironment{equation}{%
+ \edef\reset@equation{%
+ \@nx\setcounter{equation}{\number\c@equation}}%
+ \refstepcounter{equation}%
+ \st@rredfalse \global\@eqnswtrue
+ \mathdisplay{equation}%
+}{%
+ \endmathdisplay{equation}%
+ \ignorespacesafterend
+}
+\renewenvironment{equation*}{%
+ \st@rredtrue \global\@eqnswfalse
+ \mathdisplay{equation*}%
+}{%
+ \endmathdisplay{equation*}%
+ \ignorespacesafterend
+}
+% \end{macrocode}
+% unchanged from |amsmath.sty|.
+% \end{macro}
+%
+% \begin{macrocode}
+\fi
+}% end of option amsmath/thmmarks **************************************
+% \end{macrocode}
+%
+%
+% \subsubsection{Theorem-Layout Stuff}
+%
+% \changes{v1.11}{1998/10/26}{added 'noconfig' option (AS/WM)}
+% \begin{macrocode}
+\let\thm@usestd\@undefined
+\DeclareOption{standard}{\let\thm@usestd\relax}
+\let\thm@noconfig\@undefined
+\DeclareOption{noconfig}{\let\thm@noconfig\relax}
+% \end{macrocode}
+%
+% Options for selection of a configuration: if no such option is given
+% |ntheorem.cfg| will be loaded (which has to be provided by the
+% user), |[standard]| will load |ntheorem.std|, a predefined setting,
+% and |[noconfig]| does not preload any configuration.
+%
+% \begin{macrocode}
+\gdef\InTheoType{None}
+\gdef\NoneKeyword{None}
+\gdef\NoneSymbol{None}
+\gdef\None{None}
+% \end{macrocode}
+%
+% Set |\InTheoType| to |none| on the upper document level.
+%
+% \begin{macro}{\newtheoremstyle}
+% \changes{v0.93}{1997/03/12}{'newtheoremstyle' only if not yet defined (WM)}
+% With |\newtheoremstyle|, new theorem-layout styles are defined.
+% \Codelabel{newthmstyle}
+% \begin{macrocode}
+\gdef\newtheoremstyle#1#2#3{%
+ \expandafter\@ifundefined{th@#1}%
+ {\expandafter\gdef\csname th@#1\endcsname{%
+ \def\@begintheorem####1####2{#2}%
+ \def\@opargbegintheorem####1####2####3{#3}}}%
+ {\PackageError{\basename}{Theorem style #1 already defined}\@eha}}
+% \end{macrocode}
+%
+% Arguments: \\
+% \meta{style}:=|#1|: the name of the theoremstyle to be defined, \\
+% \meta{cmd\_seq1}:=|#2|: command sequence for setting the header
+% for environment instances with no optional text, \\
+% \meta{cmd\_seq2}:=|#3|: command sequence for setting the header
+% for environment instances with optional text. \\
+% Line \Coderef{newthmstyle}{2}: if this style is not yet defined, define
+% it. \\
+% Line \Coderef{newthmstyle}{3}:
+% define |\th@|\meta{style} to be a macro which defines \\
+% Line \Coderef{newthmstyle}{4}:
+% a) the two-argument macro |\@begintheorem#1#2| to be \meta{cmd\_seq1}, \\
+% Line \Coderef{newthmstyle}{5}:
+% b) |\@opargbegintheorem#1#2#3| to be \meta{cmd\_seq2}.
+% \end{macro}
+%
+% The predefined theorem styles use this command.%
+%
+% \begin{macro}{\renewtheoremstyle}
+% \changes{v0.93}{1997/03/12}{introduced 'renewtheoremstyle' (WM)}
+% \Codelabel{renewthmstyle}
+% \begin{macrocode}
+\gdef\renewtheoremstyle#1#2#3{%
+ \expandafter\@ifundefined{th@#1}%
+ {\PackageError{\basename}{Theorem style #1 undefined}\@ehc}%
+ {}%
+ \expandafter\let\csname th@#1\endcsname\relax
+ \newtheoremstyle{#1}{#2}{#3}}
+% \end{macrocode}
+% \end{macro}
+% Arguments: \\
+% \meta{style}:=|#1|: the name of the theoremstyle to be defined, \\
+% |#2|, |#3| as for |\newtheoremstyle|. \\
+% Checks, if theoremstyle \meta{style} is already defined. If so,
+% |\th@|\meta{style} is made undefined and |\newtheoremstyle| is called
+% with the same arguments.
+%
+% \paragraph{Predefined Theorem Styles}
+% \begin{macro}{theoremstyles}
+% |th@plain|, |th@change|, and |th@margin| taken from theorem.sty by
+% Frank Mittelbach; the break-styles have been changed.
+%
+% \changes{v1.03}{1997/07/15}{break styles changed (WM)}
+% \changes{v1.15}{1999/02/01}{fixed nonumberbreak (WM)}
+% \changes{v1.19}{2001/01/13}{break styles and empty style changed,
+% now it is analogous to theorem.sty (OK/WM)}
+% \begin{macrocode}
+\newtheoremstyle{plain}%
+ {\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\theorem@separator]}%
+ {\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\ (##3)\theorem@separator]}
+%
+\newtheoremstyle{break}%
+ {\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
+ ##1\ ##2\theorem@separator}\hbox{\strut}}}]}%
+ {\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
+ ##1\ ##2\ (##3)\theorem@separator}\hbox{\strut}}}]}
+%
+\newtheoremstyle{change}%
+ {\item[\hskip\labelsep \theorem@headerfont ##2\ ##1\theorem@separator]}%
+ {\item[\hskip\labelsep \theorem@headerfont ##2\ ##1\ (##3)\theorem@separator]}
+%
+\newtheoremstyle{changebreak}%
+ {\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
+ ##2\ ##1\theorem@separator}\hbox{\strut}}}]}%
+ {\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
+ ##2\ ##1\ (##3)\theorem@separator}\hbox{\strut}}}]}
+%
+\newtheoremstyle{margin}%
+ {\item[\theorem@headerfont \llap{##2}\hskip\labelsep ##1\theorem@separator]}%
+ {\item[\theorem@headerfont \llap{##2}\hskip\labelsep ##1\ (##3)\theorem@separator]}
+%
+\newtheoremstyle{marginbreak}%
+ {\item[\rlap{\vbox{\hbox{\theorem@headerfont
+ \llap{##2}\hskip\labelsep\relax ##1\theorem@separator}\hbox{\strut}}}]}
+ {\item[\rlap{\vbox{\hbox{\theorem@headerfont
+ \llap{##2}\hskip\labelsep\relax ##1\
+ (##3)\theorem@separator}\hbox{\strut}}}]}
+%
+\newtheoremstyle{nonumberplain}%
+ {\item[\theorem@headerfont\hskip\labelsep ##1\theorem@separator]}%
+ {\item[\theorem@headerfont\hskip \labelsep ##1\ (##3)\theorem@separator]}
+%
+\newtheoremstyle{nonumberbreak}%
+ {\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
+ ##1\theorem@separator}\hbox{\strut}}}]}%
+ {\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
+ ##1\ (##3)\theorem@separator}\hbox{\strut}}}]}
+%
+\newtheoremstyle{empty}%
+ {\item[]}%
+ {\item[\theorem@headerfont \hskip\labelsep\relax ##3]}
+\newtheoremstyle{emptybreak}%
+ {\item[]}%
+ {\item[\rlap{\vbox{\hbox{\hskip\labelsep\relax \theorem@headerfont
+ ##3\theorem@separator}\hbox{\strut}}}]}
+%
+\@namedef{th@nonumbermargin}{\th@nonumberplain}
+\@namedef{th@nonumberchange}{\th@nonumberplain}
+\@namedef{th@nonumbermarginbreak}{\th@nonumberbreak}
+\@namedef{th@nonumberchangebreak}{\th@nonumberbreak}
+\@namedef{th@plainNo}{\th@nonumberplain}
+\@namedef{th@breakNo}{\th@nonumberplain}
+\@namedef{th@marginNo}{\th@nonumberplain}
+\@namedef{th@changeNo}{\th@nonumberplain}
+\@namedef{th@marginbreakNo}{\th@nonumberbreak}
+\@namedef{th@changebreakNo}{\th@nonumberbreak}
+% \end{macrocode}
+% \changes{v0.81}{1997/02/12}{`theoremnumbering' and styles ...No added
+% (WM)}
+% \changes{v1.04}{1998/05/26}{theoremstyle empty added (WM)}
+%\end{macro}
+%
+% For instance, |break| is commented:
+%
+% |\newtheoremstyle{break}| results in
+% \begin{quote}
+% |\gdef\th@break{%| \\
+% | \def\@begintheorem##1##2{%| \\
+% | \item[\hskip\labelsep \theorem@headerfont| \\
+% | ##1\ ##2\theorem@separator]%| \\
+% | \hfill\penalty-8000}%| \\
+% | \def\@opargbegintheorem##1##2##3{%| \\
+% | \item[\hskip\labelsep \theorem@headerfont| \\
+% | ##1\ ##2\ (##3)\theorem@separator]%| \\
+% | \hfill\penalty-8000}}|
+% \end{quote}
+%
+% Then, calling |\th@break| sets |\@begintheorem| as follows: \\
+% Since each theorem environment is basically a trivlist,
+% the header is set as the item contents: |\theorem@headerfont|
+% holds the font commands for the header font, |##1| is the
+% keyword to be displayed, and |##2| its environment number.
+% The linebreak after the header is achieved by offering to fill the
+% line with space and the distinct wish to put a linebreak after it.
+% Thus, if plain text follows, the line break is executed, but if
+% a list or a display follows, it is not executed.
+%
+% Note: The |\hfill\penalty-8000| causes \TeX\ to leave vertical mode,
+% setting the item contents (ie the header) and entering horizontal mode
+% to perform the |\hfill|.
+%
+% \begin{macro}{\theoremstyle}
+% The handling of |\theoremstyle|, |\theorembodyfont|, and
+% |\theoremskipamounts| is taken from theorem.sty by Frank Mittelbach:
+% \changes{v0.80}{1997/02/11}{`theoremseparator' added (WM)}
+% \changes{v1.20}{2002/12/30}{`theoremprework' and `theorempostwork'
+% added (WM)}
+% \begin{macrocode}
+\gdef\theoremstyle#1{%
+ \@ifundefined{th@#1}{\@warning
+ {Unknown theoremstyle `#1'. Using `plain'}%
+ \theorem@style{plain}}%
+ {\theorem@style{#1}}}
+\newtoks\theorem@style
+\newtoks\theorem@@style
+\global\theorem@style{plain}
+% \end{macrocode}\end{macro}
+%
+% If |\theoremstyle| is called, it is checked if the argument
+% is a valid |theoremstyle|, and if so, it is stored in the token
+% |\theorem@style|. It is initialized to |plain|.
+%
+% \begin{macro}{\theorembodyfont}
+% \begin{macrocode}
+\newtoks\theorembodyfont
+\global\theorembodyfont{\itshape}
+% \end{macrocode}\end{macro}
+%
+% \begin{macro}{\theoremnumbering}
+% \begin{macrocode}
+\newtoks\theoremnumbering
+\global\theoremnumbering{arabic}
+% \end{macrocode}\end{macro}
+%
+% \begin{macro}{\theorempreskipamount}
+% \begin{macro}{\theorempostskipamount}
+% \begin{macrocode}
+\newskip\theorempreskipamount
+\newskip\theorempostskipamount
+\global\theorempreskipamount\topsep
+\global\theorempostskipamount\topsep
+% \end{macrocode}\end{macro}
+% \changes{v0.94}{1997/03/20}{'theorem...skip' fixed (WM)}
+% \end{macro}
+%
+% \begin{macro}{\theoremindent}
+% \begin{macrocode}
+\newdimen\theoremindent
+\global\theoremindent0cm
+\newdimen\theorem@indent
+% \end{macrocode}\end{macro}
+%
+% \begin{macro}{\theoremheaderfont}
+% \begin{macrocode}
+\newtoks\theoremheaderfont
+\global\theoremheaderfont{\normalfont\bfseries}
+\def\theorem@headerfont{\normalfont\bfseries}
+% \end{macrocode}\end{macro}
+%
+% \begin{macro}{\theoremseparator}
+% \begin{macrocode}
+\newtoks\theoremseparator
+\global\theoremseparator{}
+\def\theorem@separator{}
+% \end{macrocode}\end{macro}
+%
+% \begin{macro}{\theoremprework}
+% \begin{macro}{\theorempostwork}
+% \begin{macrocode}
+\newtoks\theoremprework
+\global\theoremprework{\relax}
+\newtoks\theorempostwork
+\global\theorempostwork{\relax}
+\def\theorem@prework{}
+% \end{macrocode}\end{macro}
+% \end{macro}
+%
+% \begin{macro}{\theoremsymbol}
+% \begin{macrocode}
+\newtoks\theoremsymbol
+\global\theoremsymbol{}
+% \end{macrocode}\end{macro}
+%
+% \begin{macro}{\qedsymbol}
+% \begin{macrocode}
+\newtoks\qedsymbol
+\global\qedsymbol{}
+% \end{macrocode}\end{macro}
+%
+% \begin{macro}{\theoremkeyword}
+% \begin{macrocode}
+\newtoks\theoremkeyword
+\global\theoremkeyword{None}
+% \end{macrocode}\end{macro}
+%
+% \begin{macro}{\theoremclass}
+% \changes{v1.16}{1999/08/07}{introduced 'theoremclass' and
+% defined 'th@class@LaTeX' (WM)}
+% \begin{macrocode}
+\gdef\theoremclass#1{%
+ \csname th@class@#1\endcsname}
+\gdef\th@class@LaTeX{%
+ \theoremstyle{plain}
+ \theoremheaderfont{\normalfont\bfseries}
+ \theorembodyfont{\itshape}
+ \theoremseparator{}
+ \theoremprework{\relax}
+ \theorempostwork{\relax}
+ \theoremindent0cm
+ \theoremnumbering{arabic}
+ \theoremsymbol{}}
+% \end{macrocode}\end{macro}
+% Calling |\theoremclass{|\env|}| calls |\th@class@|\env\ (which is
+% defined in |\@newtheorem| in Lines \Coderef{atnewthm}{31--45}).
+% |\th@class@|\env\ restores all style parameters to their values
+% given for \env.
+% Especially, |\th@class@LaTeX| restores the standard LaTeX parameters.
+%
+% \begin{macro}{\qedsymbol}
+% \begin{macrocode}
+\newtoks\qedsymbol
+\global\qedsymbol{}
+% \end{macrocode}\end{macro}
+%
+% \paragraph{Compatibility with amsthm.}
+%
+% \begin{macro}{amsthm}
+% \changes{v1.02}{1997/05/31}{proof-environment fixed (WM)}
+% \begin{macrocode}
+\DeclareOption{amsthm}{% *********************************************
+ \PackageInfo{\basename}{Option `amsthm' loaded}%
+\def\swapnumbers{\PackageError{\basename}{swapnumbers not implemented.
+ Use theoremstyle change instead.}\@eha}
+
+\gdef\th@plain{%
+ \def\theorem@headerfont{\normalfont\bfseries}\itshape%
+ \def\@begintheorem##1##2{%
+ \item[\hskip\labelsep \theorem@headerfont ##1\ ##2.]}%
+ \def\@opargbegintheorem##1##2##3{%
+ \item[\hskip\labelsep \theorem@headerfont ##1\ ##2\ (##3).]}}
+\gdef\th@nonumberplain{%
+ \def\theorem@headerfont{\normalfont\bfseries}\itshape%
+ \def\@begintheorem##1##2{%
+ \item[\hskip\labelsep \theorem@headerfont ##1.]}%
+ \def\@opargbegintheorem##1##2##3{%
+ \item[\hskip\labelsep \theorem@headerfont ##1\ (##3).]}}
+\gdef\th@definition{%
+ \th@plain\def\theorem@headerfont{\normalfont\bfseries}\itshape}
+\gdef\th@nonumberdefinition{%
+ \th@nonumberplain\def\theorem@headerfont{\normalfont\bfseries}\itshape}
+\gdef\th@remark{%
+ \th@plain\def\theorem@headerfont{\itshape}\normalfont}
+\gdef\th@nonumberremark{%
+ \th@nonumberplain\def\theorem@headerfont{\itshape}\normalfont}
+\newcounter{proof}%
+\if@thmmarks
+ \newcounter{currproofctr}%
+ \newcounter{endproofctr}%
+\fi
+\newcommand{\openbox}{\leavevmode
+ \hbox to.77778em{%
+ \hfil\vrule
+ \vbox to.675em{\hrule width.6em\vfil\hrule}%
+ \vrule\hfil}}
+\gdef\proofSymbol{\openbox}
+\newcommand{\proofname}{Proof}
+\newenvironment{proof}[1][\proofname]{
+ \th@nonumberplain
+ \def\theorem@headerfont{\itshape}%
+ \normalfont
+ \theoremsymbol{\ensuremath{_\blacksquare}}
+ \@thm{proof}{proof}{#1}}%
+ {\@endtheorem}
+}% end of option amsthm **********************************************
+% \end{macrocode}
+% \end{macro}
+%
+% Defines theorem styles |plain|, |definition|, and
+% |remark|, and environment |proof| according to
+% |amsthm.sty|.
+%
+% \subsubsection{Theorem-Environment Handling Stuff}
+% Original: ltthm.dtx
+%
+% \begin{macrocode}
+\newskip\thm@topsepadd
+% \end{macrocode}
+%
+% An auxiliary variable.
+%
+% \paragraph{Defining New Theorem-Environments.}
+%
+% \begin{macro}{\newtheorem}
+% \changes{v1.18}{1999/12/23}{debugged starred version of 'newtheorem' (WM)}
+% \changes{v1.23}{2004/06/13}{moved normal 'newtheorem' into 'ntheorem@i' (WM)}
+% \changes{v1.23}{2004/06/13}{normal 'newtheorem': reset theoremprework and
+% theorempostwork, then call 'ntheorem@i' (WM, reported by Christoph Kluss)}
+% \changes{v1.24}{2004/09/20}{debugged: reset after call, moved downwards (WM)}
+% \begin{macrocode}
+\gdef\newtheorem{%
+ \newtheorem@i%
+}
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\newtheorem@i}
+% \changes{v1.23}{2004/06/13}{moved normal 'newtheorem' into 'ntheorem@i' (WM)}
+% The syntax of the original |\newtheorem| is retained. The macro is extended
+% to deal with the additional requirements:
+% \begin{macrocode}
+\gdef\newtheorem@i{%
+ \@ifstar
+ {\expandafter\@ifundefined{th@nonumber\the\theorem@style}%
+ {\PackageError{\basename}{Theorem style {nonumber\the\theorem@style}
+ undefined (you need it here for newtheorem*) }\@ehc}%
+ {}%
+ \edef\@tempa{{nonumber\the\theorem@style}}%
+ \expandafter\theorem@@style\@tempa\@newtheorem}%
+ {\edef\@tempa{{\the\theorem@style}}%
+ \expandafter\theorem@@style\@tempa\@newtheorem}}
+% \end{macrocode}
+% \end{macro}
+%
+% Defines |\theorem@@style| to be the current |\theoremstyle|
+% or -- in case of |\newtheorem*| -- to be its non-numbered
+% equivalent (which has to be defined!), and then calls |\@newtheorem|.
+
+% \begin{macro}{\renewtheorem}
+% \changes{v0.93}{1997/03/12}{introduced 'renewtheorem' (WM)}
+% \changes{v1.18}{1999/12/23}{debugged starred version of 'renewtheorem' (WM)}
+% \Codelabel{renewthm}
+% \begin{macrocode}
+\gdef\renewtheorem{%
+ \@ifstar
+ {\expandafter\@ifundefined{th@nonumber\the\theorem@style}%
+ {\PackageError{\basename}{Theorem style {nonumber\the\theorem@style}
+ undefined (you need it here for newtheorem*) }\@ehc}%
+ {}%
+ \edef\@tempa{{nonumber\the\theorem@style}}%
+ \expandafter\theorem@@style\@tempa\@renewtheorem}%
+ {\edef\@tempa{{\the\theorem@style}}%
+ \expandafter\theorem@@style\@tempa\@renewtheorem}}
+% \end{macrocode}
+% Analogous to |\newtheorem|.
+% \end{macro}
+%
+% \begin{macro}{\@newtheorem}
+% |\@newtheorem| does the main job for initializing a new theorem
+% environment type. It is called by |\newtheorem|.
+%
+% \Codelabel{atnewthm}
+% \changes{v0.83}{1997/02/13}{fixed, for bold math in headers (AS)}
+% \changes{v0.93}{1997/03/12}{check ifdefinable star-env. added (WM)}
+% \changes{v0.93}{1997/03/12}{newcounters only if not yet defined (WM)}
+% \changes{v1.02}{1997/05/31}{fixed collision at '@thm', introduced
+% 'setparms' and 'mkheader' (WM)}
+% \changes{v1.16}{1999/08/07}{introduced 'th@class' (WM)}
+% \changes{v1.18}{1999/12/23}{'protected@xdef' for Symbol (WM)}
+% \changes{v1.21}{2002/12/30}{added handling of 'theoremprework' and
+% 'theorempostwork' (WM)}
+% \changes{v1.24}{2004/09/20}{debugged: reset theorempre/postwork (WM)}
+% \begin{macrocode}
+\gdef\@newtheorem#1{%
+ \thm@tempiffalse
+ \expandafter\@ifdefinable\csname #1\endcsname
+ {\expandafter\@ifdefinable\csname #1*\endcsname
+ {\thm@tempiftrue
+ \thm@definelthm{#1}% for lists
+ \if@thmmarks
+ \expandafter\@ifundefined{c@curr#1ctr}%
+ {\newcounter{curr#1ctr}}{}%
+ \expandafter\@ifundefined{c@end#1ctr}%
+ {\newcounter{end#1ctr}}{}%
+ \fi
+ \expandafter\protected@xdef\csname #1Symbol\endcsname{\the\theoremsymbol}%
+ \expandafter\protected@xdef\csname #1@postwork\endcsname{%
+ \the\theorempostwork}%
+ \expandafter\gdef\csname#1\endcsname{%
+ \let\thm@starredenv\@undefined
+ \csname mkheader@#1\endcsname}%
+ \expandafter\gdef\csname#1*\endcsname{%
+ \let\thm@starredenv\relax
+ \csname mkheader@#1\endcsname}%
+ \def\@tempa{\expandafter\noexpand\csname end#1\endcsname}%
+ \expandafter\xdef\csname end#1*\endcsname{\@tempa}%
+ \expandafter\xdef\csname setparms@#1\endcsname
+ {\noexpand \def \noexpand \theorem@headerfont
+ {\the\theoremheaderfont\noexpand\theorem@checkbold}%
+ \noexpand \def \noexpand \theorem@separator
+ {\the\theoremseparator}%
+ \noexpand \def \noexpand \theorem@prework
+ {\the\theoremprework}%
+ \noexpand \def \noexpand \theorem@indent
+ {\the\theoremindent}%
+ \the \theorembodyfont
+ \noexpand\csname th@\the \theorem@@style \endcsname}%
+ \expandafter\xdef\csname th@class@#1\endcsname
+ {\noexpand\theoremstyle{\the\theorem@style}%
+ \noexpand\theoremheaderfont{\the\theoremheaderfont}%
+ \noexpand\theorembodyfont{\the \theorembodyfont}%
+ \noexpand\theoremseparator{\the\theoremseparator}%
+ \noexpand\theoremprework{\the\theoremprework}%
+ \noexpand\theorempostwork{\the\theorempostwork}%
+ \noexpand\theoremindent\the\theoremindent%
+ \noexpand\theoremnumbering{\the\theoremnumbering}%
+ \noexpand\theoremsymbol{\the\theoremsymbol}}%
+ }}%
+ \theoremprework{\relax}%
+ \theorempostwork{\relax}%
+ \@ifnextchar[{\@othm{#1}}{\@nthm{#1}}}% MUST NOT BE IN ANY IF !!!
+% \end{macrocode}
+%
+% Argument: \env:=|#1| is the (internal) environment name to be defined,
+% which is read from the \LaTeX\ source.
+% \begin{packeddescr}
+% \item[Line \Coderef{atnewthm}{3}:]
+% check if \env\ is not yet defined (or is redefined).
+% \item[Lines \Coderef{atnewthm}{5}--\Coderef{atnewthm}{30}]
+% are executed exactly if \env\ and \env * are not yet defined.
+% \item[Line \Coderef{atnewthm}{5}:]
+% |\thm@tempif=true| iff \env\ and \env * are not yet defined.
+% \item[Line \Coderef{atnewthm}{6}:]
+% Initialize theorem list handling for \env.
+% \item[Lines \Coderef{atnewthm}{8}--\Coderef{atnewthm}{11}:]
+% if |thmmarks| is active and the counters are not yet defined,
+% for every theorem-like, define \\
+% |curr|\env|ctr|: in the $i$th environment of type \env,
+% $|curr|\env|ctr|=i$, and \\
+% |end|\env|ctr|: when the innermost environment is of
+% type \env, in the $j$th potential position for an end
+% mark in this environment, $|end|\env|ctr|=j$.
+% (if the counters are already defined, \env\ is redefined,
+% and these internal counters have to be continued).
+% \item[Lines \Coderef{atnewthm}{13}--\Coderef{atnewthm}{30}:]
+% define several commands:
+% (|\xdef| expands the definition at the time it is called and
+% makes it global):
+% \item[Line \Coderef{atnewthm}{13}:]
+% store the current value of |\theoremsymbol|
+% (|\edef|: expand |\the\theoremsymbol| now) as \env|Symbol|.
+% \item[Line \Coderef{atnewthm}{14}:]
+% store the current value of |\theorempostwork|
+% (|\edef|: expand |\the\theorempostwork| now) as \env|postwork|.
+% \item[Lines \Coderef{atnewthm}{15}--\Coderef{atnewthm}{17},
+% \Coderef{atnewthm}{18}--\Coderef{atnewthm}{20}:]
+% Define the commands |\env| and |\env*| to set the header
+% of |\env|.
+% (using a switch |\thm@starredenv|: |\relax| iff starred).
+% \item[Lines \Coderef{atnewthm}{21}, \Coderef{atnewthm}{22}:]
+% Set |\end|\env|*| to |\end|\env.
+% \item[Lines \Coderef{atnewthm}{23}--\Coderef{atnewthm}{33}:]
+% define |\setparms@|\env\ to set the style parameters of the
+% header for every \env\ environment (in the sequel,
+% \emph{current} means, at the moment |\@newtheorem| is called):
+% \item[Lines \Coderef{atnewthm}{24}, \Coderef{atnewthm}{25}:]
+% setting |\theorem@headerfont| to the \emph{current}
+% value of |\theoremheaderfont|, followed by a check if
+% it is a bold style,
+% \item[Lines \Coderef{atnewthm}{26}, \Coderef{atnewthm}{27}:]
+% setting |\theorem@separator| to the \emph{current}
+% value of |\theoremseparator|,
+% \item[Lines \Coderef{atnewthm}{28}, \Coderef{atnewthm}{29}:]
+% setting |\theorem@prework| to the \emph{current}
+% value of |\theoremprework|,
+% \item[Lines \Coderef{atnewthm}{30}, \Coderef{atnewthm}{31}:]
+% setting |\theorem@indent| to the \emph{current}
+% value of |\theoremindent|,
+% \item[Line \Coderef{atnewthm}{32}:]
+% executing the command sequence currently stored in
+% |\theorembodyfont|, and
+% \item[Line \Coderef{atnewthm}{33}:]
+% calling |th@\the\theorem@@style| (which initializes
+% |\@begintheorem| and |\@opargbegintheorem| according to the
+% \emph{current} value of |\theoremstyle| by calling
+% |th@\the\theorem@@style|).
+% \item [Line \Coderef{atnewthm}{34}--\Coderef{atnewthm}{48}:]
+% define |\th@class@|\env\ to initialize all style
+% parameters as they are set for the \env\ environment.
+% \item[Note,] that the |\@ifdefinable| from line \Coderef{atnewthm}{3}
+% ends after line \Coderef{atnewthm}{48}.
+% \item[Line \Coderef{atnewthm}{49}:]
+% According to the next character, call |\@othm{|\env|}|
+% (if another counter is used) or |\@nthm{|\env|}|.
+% \end{packeddescr}
+%
+% Thus, when calling |\@newthm| with |#1|=\env,
+% for current values |\theoremstyle=plain|,
+% |\theorembodyfont=\upshape|, |\theoremheaderfont=\bf|,
+% |\theoremseparator=:|, |\theoremindent=1cm|,
+% |\theoremnumbering=arabic|, and |\theoremsymbol=\Box|,
+%
+% the macro |\setparms@|\env\ is defined as
+% \begin{quote}
+% |\setparms@|\env| == \def\theorem@headerfont{\bf\theorem@checkbold}| \\
+% | \def\theorem@separator{:}| \\
+% | \def\theorem@indent{0cm}| \\
+% | \upshape| \\
+% | \th@plain|
+% \end{quote}
+% and the macro |\th@class@|\env\ is defined as
+% \begin{quote}
+% |\th@class@|\env| == \def\theoremstyle{plain}|\\
+% | \def\theoremheaderfont{\bf}| \\
+% | \def\theorembodyfont{\upshape}| \\
+% | \def\theoremseparator{:}| \\
+% | \def\theoremindent{0cm}| \\
+% | \def\theoremnumbering{arabic}| \\
+% | \def\theoremsymbol{\Box}|
+% \end{quote}
+% Note, that line \Coderef{atnewthm}{32} must not be inside
+% \emph{any} |\if...\fi| construct.
+% \end{macro}
+%
+% \begin{macro}{\@renewtheorem}
+% \changes{v0.93}{1997/03/12}{introduced 'renewtheorem' (WM)}
+% \changes{v1.18}{1999/12/23}{calls '@newtheorem' instead of
+% 'newtheorem' (WM)}
+% \Codelabel{atrenewthm}
+% \begin{macrocode}
+\gdef\@renewtheorem#1{%
+ \expandafter\@ifundefined{#1}%
+ {\PackageError{\basename}{Theorem style #1 undefined}\@ehc}%
+ {}%
+ \expandafter\let\csname #1\endcsname\relax
+ \expandafter\let\csname #1*\endcsname\relax
+ \@newtheorem{#1}}
+% \end{macrocode}
+% Argument: \env:=|#1| is the (internal) environment name to be
+% redefined, which is read from the \LaTeX\ source. \\
+% If \env\ is already defined, make it (and \env*, too) undefined
+% and call |\@newtheorem{|\env|}|.
+% \end{macro}
+%
+% \begin{macro}{\@nthm}
+% \changes{v1.1}{1998/08/30}{added 'output@' to '@nthm' and '@othm'. (WM)}
+% \changes{v1.18}{1999/12/25}{'protected@xdef' instead of 'xdef' (WM)}
+% \changes{v1.18}{1999/12/25}{'output' changed and modified into
+% 'Keyword' (WM)}
+% \Codelabel{nthm}
+% |\@nthm| is called by |\@newtheorem| if the environment to be defined
+% has a counter of its own.
+% \begin{macrocode}
+\gdef\@nthm#1#2{%
+ \expandafter\protected@xdef\csname num@addtheoremline#1\endcsname{%
+ \noexpand\@num@addtheoremline{#1}{#2}}%
+ \expandafter\protected@xdef\csname nonum@addtheoremline#1\endcsname{%
+ \noexpand\@nonum@addtheoremline{#1}{#2}}%
+ \theoremkeyword{#2}%
+ \expandafter\protected@xdef\csname #1Keyword\endcsname
+ {\the\theoremkeyword}%
+ \@ifnextchar[{\@xnthm{#1}{#2}}{\@ynthm{#1}{#2}}}
+% \end{macrocode}
+%
+% Arguments: \\
+% \env:=|#1| is the (internal) environment name to be defined
+% (transmitted from |\@newtheorem|). \\
+% \meta{output\_name}:=|#2| is its keyword to be used in the
+% output (read from the \LaTeX\ source).
+% \begin{packeddescr}
+% \item[Lines \Coderef{nthm}{2}--\Coderef{nthm}{5}:]
+% Define |\|(no)|num@addtheoremline|\env\ to call \\
+% |\@|(no)|num@addtheoremline{|\env|}{|\meta{output\_name}|}|. \\
+% For comments on |\@num@addtheoremline| and
+% |\@nonum@addtheoremline| see Section \ref{sec:CodeLists}.
+% \item[Lines \Coderef{nthm}{6}--\Coderef{nthm}{8}:]
+% Define |\|\env|Keyword|\env\ to typeset/output \meta{output\_name}.
+% (note the similarity with the handling of |\theoremsymbol|
+% for handling complex keywords)
+% \item[Line \Coderef{nthm}{9}:]
+% According to the next character, call
+% |\@xnthm{|\env|}{|\meta{output\_name}|}| (if \env-environments
+% should be numbered relative to some structuring level) or
+% |\@ynthm{|\env|}{|\meta{output\_name}|}|.
+% \end{packeddescr}
+% \end{macro}
+%
+% \begin{macro}{\@othm}
+% \changes{v1.02}{1997/05/31}{fixed collision at '@thm', introduced
+% 'setparms' and 'mkheader' (WM)}
+% \changes{v1.1}{1998/08/30}{added 'output@' to '@nthm' and '@othm'. (WM)}
+% \changes{v1.12}{1998/11/15}{fixed a bug in '@output' (WM, reported by
+% David Epstein)}
+% \changes{v1.18}{1999/12/25}{'protected@xdef' instead of 'xdef' (WM)}
+% \changes{v1.18}{1999/12/25}{'output' changed and modified into
+% 'Keyword' (WM)}
+% |\@othm| is called by |\@newtheorem| if the environment to be defined
+% uses another counter.
+% \Codelabel{othm}
+% \begin{macrocode}
+\gdef\@othm#1[#2]#3{%
+ \@ifundefined{c@#2}{\@nocounterr{#2}}%
+ {\ifthm@tempif
+ \global\@namedef{the#1}{\@nameuse{the#2}}%
+ \expandafter\protected@xdef\csname num@addtheoremline#1\endcsname{%
+ \noexpand\@num@addtheoremline{#1}{#3}}%
+ \expandafter\protected@xdef\csname nonum@addtheoremline#1\endcsname{%
+ \noexpand\@nonum@addtheoremline{#1}{#3}}%
+ \theoremkeyword{#3}%
+ \expandafter\protected@xdef\csname #1Keyword\endcsname
+ {\the\theoremkeyword}%
+ \expandafter\gdef\csname mkheader@#1\endcsname
+ {\csname setparms@#1\endcsname
+ \@thm{#1}{#2}{#3}}%
+ \global\@namedef{end#1}{\@endtheorem}\fi}}
+% \end{macrocode}
+%
+% Arguments: \\
+% \env:=|#1| is the (internal) environment name to be defined
+% (transmitted from |\@newtheorem|). \\
+% \meta{use\_ctr}:=|#2| is the internal name of the theorem which counter
+% is used, and \\
+% \meta{output\_name}:=|#3| is its ``name'' to be used in the
+% output (both read from the \LaTeX\ source).
+%
+% \begin{packeddescr}
+% \item[Line \Coderef{othm}{2}:]
+% if the counter to be used is undefined, goto error, else
+% set |\the|\env\ to use |\the|\meta{use\_ctr} and do the following:
+% \item[Lines \Coderef{othm}{4}--\Coderef{othm}{12}]
+% happen only if \env\ is not yet defined or gets redefined:
+% \item[Line \Coderef{othm}{4}:] (from latex.ltx)
+% make \env\ use the counter \meta{use\_ctr}.
+% \item[Lines \Coderef{othm}{5}--\Coderef{othm}{11}]
+% similar to lines \Coderef{nthm}{2}--\Coderef{nthm}{8}
+% of |\@nthm|.
+% \item[Lines \Coderef{othm}{12}--\Coderef{othm}{14}]
+% define |\mkheader@|\env\ to set the style parameters of the header
+% and set the header (by |\@thm|):
+% \begin{quote}
+% |\mkheader@|\env\ ==
+% |\setparms@|\env|\@thm{|\env|}{|\meta{use\_ctr}|}{|\meta{output\_name}|}|.
+% \end{quote}
+% (|\setparms@|\env\ is defined when |\@newtheorem{|\env|}| is
+% carried out).
+% \item[Line \Coderef{othm}{15}:]
+% (from latex.ltx): |\end|\env\ calls |\@endtheorem|.
+% \end{packeddescr}
+% \end{macro}
+%
+% \begin{macro}{\@xnthm}
+% \changes{v0.93}{1997/03/12}{@definecounter only if not yet defined (WM)}
+% \changes{v1.02}{1997/05/31}{fixed collision at '@thm', introduced
+% 'setparms' and 'mkheader' (WM)}
+% |\@xnthm| is called by |\@nthm| if the numbering is relative to some
+% structuring level.
+% \Codelabel{xnthm}
+% \begin{macrocode}
+\gdef\@xnthm#1#2[#3]{%
+ \ifthm@tempif
+ \expandafter\@ifundefined{c@#1}%
+ {\@definecounter{#1}}{}%
+ \@newctr{#1}[#3]%
+ \expandafter\xdef\csname the#1\endcsname{%
+ \expandafter\noexpand\csname the#3\endcsname \@thmcountersep
+ {\noexpand\csname\the\theoremnumbering\endcsname{#1}}}%
+ \expandafter\gdef\csname mkheader@#1\endcsname
+ {\csname setparms@#1\endcsname
+ \@thm{#1}{#1}{#2}}%
+ \global\@namedef{end#1}{\@endtheorem}\fi}
+% \end{macrocode}
+%
+% Arguments: \\
+% \env:=|#1| is the (internal) environment name to be defined
+% (transmitted from |\@newtheorem|). \\
+% \meta{output\_name}:=|#2| is its keyword to be used in the
+% output, \\
+% \meta{level}:=|#3| is the structuring level relative to which \env\
+% has to be numbered (both read from the \LaTeX\ source).
+%
+% \begin{packeddescr}
+% \item[Lines \Coderef{xnthm}{3}--\Coderef{xnthm}{12}]
+% happen only if \env\ is not yet defined or gets redefined:
+% \item[Lines \Coderef{xnthm}{3},\Coderef{xnthm}{4}:]
+% in not yet defined, define \env- counter (otherwise, \env\
+% is redefined).
+% \item[Line \Coderef{xnthm}{6}:]
+% (from latex.ltx): define the counter for \env\ and add
+% \meta{level} to its reset-triggers.
+% \item[Lines \Coderef{xnthm}{7}, \Coderef{xnthm}{8}:]
+% define |\the|\env\ to be the command sequence
+% \begin{quote}
+% |\the|\meta{level}|\@thmcountersep|\meta{numbering}|{|\env|}|~,
+% \end{quote}
+% where \meta{numbering} is the value of |\theoremnumbering| when
+% |\@xnthm| (and thus, |\newtheorem{|\env|}|) is called.
+% \item[Lines \Coderef{xnthm}{9}--\Coderef{xnthm}{11}:]
+% define |\mkheader@|\env\ to set the style parameters of the header
+% and set the header (by |\@thm|):
+% \begin{quote}
+% |\mkheader@|\env\ ==
+% |\setparms@|\env|\@thm{|\env|}{|\env|}{|\meta{output\_name}|}|.
+% \end{quote}
+% (|\setparms@|\env\ is defined when |\@newtheorem{|\env|}| is
+% carried out).
+% \item[Line \Coderef{xnthm}{12}:]
+% (from latex.ltx): |\end|\env\ calls |\@endtheorem|.
+% \end{packeddescr}
+% \end{macro}
+%
+% \begin{macro}{\@ynthm}
+% \changes{v0.93}{1997/03/12}{'@definecounter' only if not yet defined (WM)}
+% \changes{v1.02}{1997/05/31}{fixed collision at '@thm', introduced
+% 'setparms' and 'mkheader' (WM)}
+% |\@ynthm| is called by |\@nthm| if the counter is not relative to any
+% structuring level.\\
+% \Codelabel{ynthm}
+% \begin{macrocode}
+\gdef\@ynthm#1#2{%
+ \ifthm@tempif
+ \expandafter\@ifundefined{c@#1}%
+ {\@definecounter{#1}}{}%
+ \expandafter\xdef\csname the#1\endcsname
+ {\noexpand\csname\the\theoremnumbering\endcsname{#1}}%
+ \expandafter\gdef\csname mkheader@#1\endcsname
+ {\csname setparms@#1\endcsname
+ \@thm{#1}{#1}{#2}}%
+ \global\@namedef{end#1}{\@endtheorem}\fi}
+% \end{macrocode}
+%
+% Arguments: \\
+% \env:=|#1| is the (internal) environment name to be defined
+% (transmitted from |\@newtheorem|). \\
+% \meta{output\_name}:=|#2| is its keyword to be used in the
+% output. \\
+% |\@ynthm| works analogous to |\@xnthm|.
+% \end{macro}
+%
+% \paragraph{Handling Instances of Theorem-Environments.}
+%
+% \begin{macro}{\@thm}
+% |\@thm| is called by |\@|\env\ (which is defined by
+% |\@othm|/|\@xnthm|/|\@ynthm|).
+% \changes{v1.21}{2002/12/30}{added handling of 'theoremprework' (WM)}
+% \Codelabel{atthm}
+% \begin{macrocode}
+\gdef\@thm#1#2#3{%
+ \if@thmmarks
+ \stepcounter{end\InTheoType ctr}%
+ \fi
+ \renewcommand{\InTheoType}{#1}%
+ \if@thmmarks
+ \stepcounter{curr#1ctr}%
+ \setcounter{end#1ctr}{0}%
+ \fi
+ \refstepcounter{#2}%
+ \theorem@prework
+ \thm@topsepadd \theorempostskipamount % cf. latex.ltx: \@trivlist
+ \ifvmode \advance\thm@topsepadd\partopsep\fi
+ \trivlist
+ \@topsep \theorempreskipamount
+ \@topsepadd \thm@topsepadd % used by \@endparenv
+ \advance\linewidth -\theorem@indent
+ \advance\@totalleftmargin \theorem@indent
+ \parshape \@ne \@totalleftmargin \linewidth
+ \@ifnextchar[{\@ythm{#1}{#2}{#3}}{\@xthm{#1}{#2}{#3}}}
+% \end{macrocode}
+% \changes{v0.91}{1997/02/27}{'theorem...skip' fixed (WM)}
+%
+% Changed to three instead of two parameters (the first one is new): \\
+% \env:=|#1|: (added) internal name of the theorem environment, \\
+% \meta{use\_ctr}:=|#2|: internal name of the theorem which counter
+% is used, \\
+% \meta{output\_name}:=|#3|: keyword to be displayed in the output;
+% all arguments are transmitted from |\@othm|/|\@xnthm|/|\@ynthm|.
+% \begin{packeddescr}
+% \item[Lines \Coderef{atthm}{2}--\Coderef{atthm}{4}:]
+% if |thmmarks| is active, the counter for the current
+% environment \envx\ is incremented, since the last endmark in
+% environment \envx\ is definitely not the position for its endmark
+% (necessary for nested environments ending at the same time).
+% \item[Line \Coderef{atthm}{5}:]
+% set |\InTheoType| to \env.
+% \item[Lines \Coderef{atthm}{6}--\Coderef{atthm}{9}:]
+% if |thmmarks| is active, increment |curr|\env|ctr| and
+% set |end|\env|ctr| to 0.
+% \item[Line \Coderef{atthm}{10}:]
+% adapted from latex.ltx: increment the corresponding counter.
+% \item[Line \Coderef{atthm}{11}:]
+% perform |prework| (before theorem structure is generated).
+% \item[Lines \Coderef{atthm}{12}--\Coderef{atthm}{16}:]
+% handle |\theorempreskipamount| and |\theorempostskipamount|
+% (if in |vmode|, there is additional space,
+% cf.\ |\trivlist| and |\@trivlist| in latex.ltx).
+% \item[Lines \Coderef{atthm}{17}--\Coderef{atthm}{19}:]
+% handle |\theoremindent|.
+% \item[Line \Coderef{atthm}{20}:]
+% if there is an optional argument, call
+% |\@ythm{|\env|}{|\meta{use\_ctr}|}{|\meta{output\_name}|}|, otherwise
+% call |\@xthm{|\env|}{|\meta{use\_ctr}|}{|\meta{output\_name}|}|.
+% \end{packeddescr}\end{macro}
+%
+% \begin{macro}{\@xthm}
+% |\@xthm| is called by |\@thm| if there is no optional text in
+% the theorem header.
+% \Codelabel{xthm}
+% \begin{macrocode}
+\def\@xthm#1#2#3{%
+ \@begintheorem{#3}{\csname the#2\endcsname}%
+ \ifx\thm@starredenv\@undefined
+ \thm@thmcaption{#1}{{#3}{\csname the#2\endcsname}{}}\fi
+ \ignorespaces}
+% \end{macrocode}
+%
+% Changed to three instead of two parameters (the first one is new): \\
+% \env:=|#1|: (added) internal name of the theorem environment, \\
+% \meta{use\_ctr}:=|#2|: internal name of the theorem which counter
+% is used, \\
+% \meta{output\_name}:=|#3|: keyword to be displayed in the output. \\
+% All arguments are transmitted from |\@thm|. \\
+% For comments, see |\@ythm|.
+% \end{macro}
+%
+% \begin{macro}{\@ythm}
+% \changes{v1.1}{1998/03/31}{added definition of 'env\-name' (WM)}
+% |\@ythm| is called by |\@thm| if there is an optional text in
+% the theorem header.
+% \Codelabel{ythm}
+% \begin{macrocode}
+\def\@ythm#1#2#3[#4]{%
+ \expandafter\global\expandafter\def\csname#1name\endcsname{#4}%
+ \@opargbegintheorem{#3}{\csname the#2\endcsname}{#4}%
+ \ifx\thm@starredenv\@undefined
+ \thm@thmcaption{#1}{{#3}{\csname the#2\endcsname}{#4}}\fi%
+ \ignorespaces}
+% \end{macrocode}
+%
+% Changed to four instead of three parameters (the first one is new): \\
+% \env:=|#1|: (added) internal name of the theorem environment, \\
+% \meta{use\_ctr}:=|#2|: internal name of the theorem which counter
+% is used, \\
+% \meta{output\_name}:=|#3|: keyword to be displayed in the output. \\
+% \meta{opt\_text}:=|#4|: optional text to appear in the header. \\
+% |#1|--|#3| are transmitted from |\@thm|, |#4| is read from the \LaTeX\
+% source.
+% \begin{packeddescr}
+% \item[Line \Coderef{ythm}{2}:]
+% define |\|\meta{env}|name| to be the optional argument.
+% \item[Line \Coderef{ythm}{3}:] call
+% \begin{quote}
+% |\@opargbegintheorem{|\meta{output\_name}|}{\the|\meta{use\_ctr}|}{|\meta{opt\_text}|}|
+% \end{quote}
+% which outputs the header.
+% \item[Line \Coderef{ythm}{4}, \Coderef{ythm}{5}:]
+% if \env\ is not the starred version, call
+% \begin{quote}
+% |\thm@thmcaption{|\meta{env}|}{{|\meta{output\_name}|}|\ignorespaces
+% |{\the|\meta{use\_ctr}|}{|\meta{opt\_text}|}}|
+% \end{quote}
+% which makes an entry into the theorem list.
+% \end{packeddescr} \end{macro}
+%
+% \begin{macro}{\@endtheorem}
+% \changes{v1.21}{2002/12/30}{added changes to '@endtheorem' in case that
+% [thmmarks] is not active (WM)}
+%
+% |\@endtheorem| is called for every |\end{|\env|}|, where \env\ is a
+% theorem-like environment.
+% (note that |\@endtheorem| it is also changed by option [thmmarks]
+% to organize the placement of the corresponding end mark).
+% |\InTheoType| gives the innermost theorem-like environment,
+% i.e.\ the one to be ended:
+%
+% \begin{macrocode}
+\gdef\@endtheorem{%
+ \endtrivlist
+ \csname\InTheoType @postwork\endcsname
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Framed and Boxed Theorems}
+%
+% The option `framed' activates framed and boxed layouts.
+% It requires to load the |framed| package and the |pstricks| package.
+%
+% \changes{v1.21}{2002/12/30}{included option `framed' (WM)}
+% \begin{macro}{framed}
+%
+% \begin{macrocode}
+\DeclareOption{framed}{%*********************************
+\newtoks\shadecolor
+\shadecolor{gray}
+\let\theoremframecommand\relax
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{newshadedtheorem}
+% \changes{v1.21}{2002/12/30}{added (WM)}
+% \begin{macrocode}
+\def\newshadedtheorem#1{%
+ \expandafter\global\expandafter\xdef\csname#1@shadecolor\endcsname{%
+ \the\shadecolor}%
+ \ifx\theoremframecommand\relax
+ \expandafter\global\expandafter\xdef\csname#1@framecommand\endcsname{%
+ \noexpand\psframebox[fillstyle=solid,
+ fillcolor=\csname#1@shadecolor\endcsname,
+ linecolor=\csname#1@shadecolor\endcsname]}%
+ \else
+ \expandafter\global\expandafter\let\csname#1@framecommand\endcsname%
+ \theoremframecommand%
+ \fi
+ \theoremprework{%
+ \def\FrameCommand{\csname#1@framecommand\endcsname}\framed}%
+ \theorempostwork{\endframed}%
+ \newtheorem@i{#1}%
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{newframedtheorem}
+% \begin{macrocode}
+\def\newframedtheorem#1{%
+ \theoremprework{\framed}%
+ \theorempostwork{\endframed}%
+ \newtheorem@i{#1}%
+ }
+}% end of option framed **********************************************
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Generation of Theorem Lists}\label{sec:CodeLists}
+%
+% The following macros are are needed for the generation of theorem-lists.
+% We will document it for the theorem
+% |\begin{definition}[optional]|, which we assume to be the first
+% definition at all and which is placed on page 5.
+%
+% \begin{macro}{\thm@thmcaption}
+% This macro, used internally, strips of the outer brackets
+% from the second argument and calls |\thm@@thmcaption|.
+% It's typically called like this
+% \begin{quote}
+% |\thm@thmcaption{definition}{{Definition}{1}{optional}}|
+% \end{quote}
+% (internal name of the environment, output keyword, running number,
+% optional text)
+% \begin{macrocode}
+\def\thm@thmcaption#1#2{\thm@@thmcaption{#1}#2}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\thm@@thmcaption}
+% \changes{v1.18}{1999/12/25}{'thm@parseforwriting' also for \#2 (WM)}
+% |\thm@caption| is called from |\thm@caption|; it writes an
+% appropriate entry to the |.thm|-file.
+% \Codelabel{thmcaption}
+% \begin{macrocode}
+\def\thm@@thmcaption#1#2#3#4{%
+ \thm@parseforwriting{#2}%
+ \let\thm@tmpii\thm@tmp%
+ \thm@parseforwriting{#4}%
+ \edef\thm@t{{\thm@tmpii}{#3}{\thm@tmp}}%
+ \addcontentsline{thm}{#1}{\thm@t}}
+% \end{macrocode}
+%
+% Arguments:
+% \env:=|#1| is the internal environment name,
+% \meta{output\_name}:=|#2| is its keyword to be used in the
+% output, |#3| is the running number, and |#4| is the optional
+% text argument in the header.
+%
+% \begin{packeddescr}
+% \item[Lines \Coderef{thmcaption}{1},\Coderef{thmcaption}{2}:]
+% the command sequence for the output keyword is prepared by
+% |\thm@parseforwriting| (which returns |\thm@tmpii|) and then
+% stored in |\thm@tmpii|.
+% \item[Line \Coderef{thmcaption}{3}:]
+% the optional text is also prepared by |\thm@parseforwriting|
+% \item[Lines \Coderef{thmcaption}{4},\Coderef{thmcaption}{5}:]
+% The output is collected and written into the |.aux| file,
+% which will forward it to the theorem-file.
+% \end{packeddescr}
+% \end{macro}
+%
+% The following two macros are just shortcuts, often needed
+% for the output of one single line in the theorem-lists. The
+% first one is used in unnamed lists, the second one in named.
+% Warning: Don't remove the leading |\let|, since you will get
+% wrong |\if|-|\fi|-nesting without it, if you don't use
+% |hyperref|.
+% \begin{macro}{\thm@@thmline@noname}
+% \changes{v1.17}{1999/09/06}{intruduced shortcuts for single lines in lists (AS)}
+% \changes{v1.17}{1999/09/07}{hyperref adjustment (AS)}
+% \begin{macrocode}
+\def\thm@@thmline@noname#1#2#3#4{%
+ \@dottedtocline{-2}{0em}{2.3em}%
+ {\protect\numberline{#2}#3}%
+ {#4}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\thm@@thmline@name}
+% \begin{macrocode}
+\def\thm@@thmline@name#1#2#3#4{%
+ \@dottedtocline{-2}{0em}{2.3em}%
+ {#1 \protect\numberline{#2}#3}%
+ {#4}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\thm@thmline}
+% This is another short one, which only discards the outer brackets
+% from the first argument and calls |\thm@@thmline|. It's normally
+% called like this:
+% \begin{quote}
+% |\thm@@thmline{{Definition}{1}{optional}}{5}|
+% \end{quote}
+% \begin{macrocode}
+\def\thm@thmline#1#2{\thm@@thmline#1{#2}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\thm@lgobble}
+% The next macro is used to ignore all theorem-sets, which should not
+% be listed.
+% \begin{macrocode}
+\long\def\thm@lgobble#1#2{\ignorespaces}
+% \end{macrocode}
+% \end{macro}
+%
+% The following four macros set up the predefined list-types. To do so,
+% they define the internal macros |\thm@@thmlstart| (containing the code
+% to be executed at the beginning of the list), |\thm@@thmlend| (code
+% to be executed at the end of the list) and |\thm@@thmline| (code to
+% be executed for every line). In order to gain compatibility with
+% |newthm.sty|, we decided not to make this commands inaccessible
+% to the user. But we recommend not using these commands, because they may
+% disappear in later distributions.
+%
+% \begin{macro}{\theoremlistall}
+% This one implements the type |all|.
+% \begin{macrocode}
+\def\theoremlistall{%
+ \let\thm@@thmlstart=\relax
+ \let\thm@@thmlend=\relax
+ \let\thm@@thmline=\thm@@thmline@noname}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\theoremlistallname}
+% And here's the type |allname|.
+% \begin{macrocode}
+\def\theoremlistallname{%
+ \let\thm@@thmlstart=\relax
+ \let\thm@@thmlend=\relax
+ \let\thm@@thmline=\thm@@thmline@name}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\theoremlistoptional}
+% This one is the list-type |opt|. In case of |[hyperref]|, the fifth
+% argument, which is provided by |hyperref.sty| is automatically
+% given to |\thm@@thmline@noname|.
+% \begin{macrocode}
+\def\theoremlistoptional{%
+ \let\thm@@thmlstart=\relax
+ \let\thm@@thmlend=\relax
+ \def\thm@@thmline##1##2##3##4{%
+ \ifx\empty ##3%
+ \else
+ \thm@@thmline@noname{##1}{##2}{##3}{##4}%
+ \fi}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\theoremlistoptname}
+% And the last type, |optname|. In case of |[hyperref]|, the fifth
+% argument, which is provided by |hyperref.sty| is automatically
+% given to |\thm@@thmline@name|.
+% \begin{macrocode}
+\def\theoremlistoptname{%
+ \let\thm@@thmlstart=\relax
+ \let\thm@@thmlend=\relax
+ \def\thm@@thmline##1##2##3##4{%
+ \ifx\empty ##3%
+ \else%
+ \thm@@thmline@name{##1}{##2}{##3}{##4}%
+ \fi}}
+% \end{macrocode}
+% \end{macro}
+%
+% \paragraph{Theoremlists and Hyperref}
+%
+% Since the |hyperref|-package redefines |\contentsline|, we must
+% redefine some commands to handle this:
+% \begin{enumerate}
+% \item Let the different versions of |\thm@@thmline@..| take a 5th
+% argument, the one provided by |hyperref|.
+% \item Don't use hyperref's contentsline: restore the normal
+% definition at the beginning of |\thm@processlist| (see there).
+% \item Let |\thm@lgobble| take one more argument,
+% the one provided by hyperref.
+% \item Do the hyperlinks manually in the different versions of
+% |\thm@@thmline| as defined by the theoremtypes.
+% \end{enumerate}
+%
+% \changes{v1.17}{1999/09/07}{added 'hyperref' option
+% (AS, based on a proposal by Didier Verna)}
+% \begin{macro}{hyperref}
+% \begin{macrocode}
+\DeclareOption{hyperref}{% **********************************************
+ \def\thm@@thmline@noname#1#2#3#4#5{%
+ \ifx\\#5\\%
+ \@dottedtocline{-2}{0em}{2.3em}%
+ {\protect\numberline{#2}#3}%
+ {#4}%
+ \else
+ \ifHy@linktocpage\relax\relax
+ \@dottedtocline{-2}{0em}{2.3em}%
+ {\protect\numberline{#2}#3}%
+ {\hyper@linkstart{link}{#5}{#4}\hyper@linkend}
+ \else
+ \@dottedtocline{-2}{0em}{2.3em}%
+ {\hyper@linkstart{link}{#5}{\protect\numberline{#2}#3}%
+ \hyper@linkend}%
+ {#4}%
+ \fi
+ \fi}%
+ \def\thm@@thmline@name#1#2#3#4#5{%
+ \ifx\\#5\\%
+ \@dottedtocline{-2}{0em}{2.3em}%
+ {#1 \protect\numberline{#2}#3}%
+ {#4}
+ \else
+ \ifHy@linktocpage\relax\relax
+ \@dottedtocline{-2}{0em}{2.3em}%
+ {#1 \protect\numberline{#2}#3}%
+ {\hyper@linkstart{link}{#5}{#4}\hyper@linkend}%
+ \else
+ \@dottedtocline{-2}{0em}{2.3em}%
+ {\hyper@linkstart{link}{#5}%
+ {#1 \protect\numberline{#2}#3}\hyper@linkend}%
+ {#4}%
+ \fi
+ \fi}
+ \def\thm@thmline#1#2#3{\thm@@thmline#1{#2}{#3}}
+ \long\def\thm@lgobble#1#2#3{\ignorespaces}
+ \def\theoremlistoptional{%
+ \let\thm@@thmlstart=\relax
+ \let\thm@@thmlend=\relax
+ \def\thm@@thmline##1##2##3##4##5{%
+ \ifx\empty ##3%
+ \else%
+ \thm@@thmline@noname{##1}{##2}{##3}{##4}{##5}%
+ \fi}}
+ \def\theoremlistoptname{%
+ \let\thm@@thmlstart=\relax
+ \let\thm@@thmlend=\relax
+ \def\thm@@thmline##1##2##3##4##5{%
+ \ifx\empty ##3%
+ \else%
+ \thm@@thmline@name{##1}{##2}{##3}{##4}{##5}%
+ \fi}}
+}% end of option hyperref *********************************************
+% \end{macrocode}
+% \changes{v1.20}{2002/01/07}{replaced ifhy by ifHy (AS, reported by J.J.Bataille)}
+% \end{macro}
+%
+% \begin{macro}{\theoremlisttype}
+% \changes{v0.92}{1997/03/03}{added error-handling (AS)}
+% The next one is the user-interface for selecting the list-type. It simply
+% calls |\thm@thml@|\meta{type}, if the given \meta{type} is defined.
+% \begin{macrocode}
+\def\theoremlisttype#1{%
+ \@ifundefined{thm@thml@#1}%
+ {\PackageError{\basename}{Listtype #1 not defined}\@eha}%
+ {\csname thm@thml@#1\endcsname}}
+% \end{macrocode}
+% \end{macro}
+% Now, here is a the code, which maps the types -- selected by
+% |\theoremlisttype| -- to the defined macros.
+% \begin{macrocode}
+\def\thm@thml@all{\theoremlistall}
+\def\thm@thml@opt{\theoremlistoptional}
+\def\thm@thml@optname{\theoremlistoptname}
+\def\thm@thml@allname{\theoremlistallname}
+% \end{macrocode}
+%
+% \begin{macro}{\newtheoremlisttype}
+% \changes{v0.86}{1997/02/15}{added (AS)}
+% \changes{v0.92}{1997/03/03}{added error-handling (AS)}
+% According to the given documentation, this one can be used to define
+% new list-types. It's done by defininig the macro
+% |\thm@thml@|\meta{type}, which \emph{locally} redefines
+% the commands |\thm@thmlstart|, |\thm@@thmline| and |\thm@@thmlend|.
+% \begin{macrocode}
+\def\newtheoremlisttype#1#2#3#4{%
+ \@ifundefined{thm@thml@#1}%
+ {\expandafter\gdef\csname thm@thml@#1\endcsname{%
+ \def\thm@@thmlstart{#2}%
+ \def\thm@@thmline####1####2####3####4{#3}%
+ \def\thm@@thmlend{#4}}%
+ }{\PackageError{\basename}{list type #1 already defined}\@eha}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\renewtheoremlisttype}
+% \changes{v0.93}{1997/03/12}{introduced newtheoremlisttype (WM)}
+% \begin{macrocode}
+\def\renewtheoremlisttype#1#2#3#4{%
+ \@ifundefined{thm@thml@#1}%
+ {\PackageError{\basename}{List type #1 not defined}\@ehc}{}%
+ \expandafter\let\csname thm@thml@#1\endcsname\relax
+ \newtheoremlisttype{#1}{#2}{#3}{#4}}
+% \end{macrocode}
+% if the list type to be redefined is already defined, make it undefined
+% and define it.
+% \end{macro}
+%
+%
+% \begin{macro}{\thm@definelthm}
+% For each theorem-set, we need to setup two commands. Thus, the next
+% macro is called by |\newtheorem|. It defines the command |\l@|\meta{theorem-set}
+% and |\thm@listdo|\meta{theorem-set}, which initially discard the input by
+% calling |\thm@lgobble|.
+% The first one is called for each theorem when you
+% are generating lists. The second one is called, if you've added something
+% with |\addtotheoremfile|.
+% \begin{macrocode}
+\def\thm@definelthm#1{%
+ \expandafter\gdef\csname l@#1\endcsname{\thm@lgobble}%
+ \expandafter\gdef\csname thm@listdo#1\endcsname{\thm@lgobble}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\thm@inlistdo}
+% If in some case, you've written additional text into the theorem-file
+% by |\addtotheoremfile|, this one is called internally. It simply discards
+% the first argument and strips of the outer brackets from the second one.
+% \begin{macrocode}
+\long\def\thm@inlistdo#1#2{#2}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\listtheorems}
+% \changes{v0.89}{1997/02/18}{fixed a bug for lists (AS)}
+% \changes{v0.92}{1997/03/02}{made commands global in order to handle
+% tabular-lists (AS)}
+% Now we need the user-interface for generating lists. This is done by the next
+% macro. We set the |tocdepth| to $-2$ to assure that the predefined list-types
+% work. After storing the names of the theorem-sets, we call |\thm@processlist|,
+% which actually generates the list.
+% \begin{macrocode}
+\def\listtheorems#1{\begingroup
+ \c@tocdepth=-2%
+ \def\thm@list{#1}\thm@processlist
+ \endgroup}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\thm@processlist}
+%
+% \changes{v1.17}{1999/09/06}{Switch to normal contentsline-behaviour for lists (hyperref) (AS)}
+% \changes{v1.19}{2001/01/13}{check for yet undefined theoremsets (WM)}
+% The file \meta{jobname}|.thm| contains commands of the form \\
+% \hspace*{0.5cm}
+% |\contentsline{|\meta{theoremset}|}{{|\meta{header}|}{|\meta{number}|}}{|\meta{page}|}|.\\
+% Thus, dependent on which theoremsets should be listed,
+% |\contentsline| must be defined to evaluate the first argument and then
+% to output all arguments, or to discard the second and third one.
+%
+% This is done the following way:
+% The commands |\l@|\meta{theorem-set} and |\thm@listdo|\meta{theorem-set}
+% (which initially were set to ignore everything by |\newtheorem|)
+% are redefined for the theorem sets which should be listed to
+% generate output.
+% |\contentsline| is defined to call |\l@|\meta{theorem-set}, adding a
+% line to the list or ignoring the entry.
+% Since for theorem sets which are not yet known (i.e., if the list
+% is created at the beginning of the document, and the theoremset is
+% only defined later), |\l@|\meta{theorem-set} is not yet defined,
+% |\contentsline| has to check if the command is defined, otherwise
+% ignore the arguments.
+%
+% Then, the |.thm| file is processed, evaluating the |\contentsline|
+% commands.
+% After processing the theorem-file, the mentioned commands are
+% again redefined to discard everything. We need to define the macros
+% globally for dealing with complex, user-defined, list-types.
+%
+% \begin{macrocode}
+\def\thm@processlist{%
+ \begingroup
+ \typeout{** Generating table of \thm@list}%
+ \def\contentsline##1{%
+ \expandafter\@ifundefined{l@##1}{\thm@lgobble}{\csname l@##1\endcsname}}%
+ \thm@@thmlstart
+ \@for\thm@currentlist:=\thm@list\do{%
+ \ifx\thm@currentlist\@empty\else
+ \expandafter\gdef\csname l@\thm@currentlist\endcsname{\thm@thmline}%
+ \expandafter\gdef\csname thm@listdo\thm@currentlist\endcsname{\thm@inlistdo}%
+ \fi
+ }%
+ \@input{\jobname .thm}%
+ \thm@@thmlend
+ \@for\thm@currentlist:=\thm@list\do{%
+ \ifx\thm@currentlist\@empty\else
+ \expandafter\gdef\csname l@\thm@currentlist\endcsname{\thm@lgobble}%
+ \expandafter\gdef\csname thm@listdo\thm@currentlist\endcsname{\thm@lgobble}%
+ \fi
+ }%
+ \endgroup}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\thm@enablelistoftheorems}
+% \changes{v0.92}{1997/03/02}{renamed (AS)}
+% Up to now, we've set up various macros for writing and reading the
+% theorem-file.
+% Thus, it's time to set up the file itself. This is done by the next macro.
+% We simply took the lines for |\@starttoc| from the \LaTeX-base and
+% changed some things. The main intention to copy |\@starttoc| is that
+% we don't want the file to be input when it is set up -- like it's done
+% by |\@starttoc|.
+% \begin{macrocode}
+\def\thm@enablelistoftheorems{%
+ \begingroup
+ \makeatletter
+ \if@filesw
+ \expandafter\newwrite\csname tf@thm\endcsname%
+ \immediate\openout \csname tf@thm\endcsname \jobname.thm\relax%
+ \fi
+ \@nobreakfalse
+ \endgroup}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\addtheoremline}
+% \changes{v0.89}{1997/02/18}{added (AS)}
+% By |\addtheoremline{|\meta{theorem-set}|}{|\meta{entry}|}|,
+% the user can insert an extra entry into the theorem-file.
+% |\addtheoremline*| calls the internal macro
+% |\nonum@addtheoremline|, otherwise |\num@addtheoremline| is called.
+% |\num/nonum@addtheoremline{|\meta{theorem-set}|}{|\meta{entry}|}|
+% calls
+% |\num/nonum@addtheoremline|\meta{theorem-set}|{|\meta{entry}|}|
+% which are
+% defined when \meta{theorem-set} is declared (cf.\ |\@nthm|).
+% These in turn call |\@num/nonum@addtheoremline{|\meta{theorem-set}%
+% |}{|\meta{keyword}|}{|\meta{entry}|}|
+% which write information to the theorem file.
+%
+% \begin{macrocode}
+\def\addtheoremline{\@ifstar{\nonum@addtheoremline}{\num@addtheoremline}}
+\def\nonum@addtheoremline#1{\csname nonum@addtheoremline#1\endcsname}%
+\def\num@addtheoremline#1{\csname num@addtheoremline#1\endcsname}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@nonum@addtheoremline}
+% |\@num@addtheoremline| and |\@nonum@addtheoremline| write the
+% actual entries to the |.thm| file. \\
+% Syntax: |\@num/nonum@addtheoremline{|%
+% \meta{theorem-set}|}{|\meta{keyword}|}{|\meta{entry}|}|
+% \begin{macrocode}
+\def\@nonum@addtheoremline#1#2#3{%
+ \thm@parseforwriting{#3}%
+ \edef\thm@t{{#2}{}{\thm@tmp}}%
+ \addcontentsline{thm}{#1}{\thm@t}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\@num@addtheoremline}
+% \begin{macrocode}
+\def\@num@addtheoremline#1#2#3{%
+ \thm@parseforwriting{#3}%
+ \edef\thm@t{{#2}{\csname the#1\endcsname}{\thm@tmp}}%
+ \addcontentsline{thm}{#1}{\thm@t}}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\addtotheoremfile}
+% \changes{v0.89}{1997/02/18}{added (AS)}
+% To write any additional stuff into the theorem-file, the next macro
+% is used. It first checks, if the optional name of a theorem-set is given.
+% In that case, the macro |\@@addtotheoremfile|, otherwise
+% |\@addtotheoremfile| is used to write the stuff into the file.
+% \begin{macrocode}
+\long\def\addtotheoremfile{%
+ \@ifnextchar[{\@@addtotheoremfile}{\@addtotheoremfile}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\@addtotheoremfile}
+% Write additional stuff for all theorems.
+% \begin{macrocode}
+\long\def\@addtotheoremfile#1{%
+ \thm@parseforwriting{#1}%
+ \protected@write\@auxout%
+ {}{\string\@writefile{thm}{\thm@tmp}}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\@@addtotheoremfile}
+% Write additional stuff for a given theorem-set.
+% \begin{macrocode}
+\long\def\@@addtotheoremfile[#1]#2{%
+ \thm@parseforwriting{#2}%
+ \protected@write\@auxout%
+ {}{\string\@writefile{thm}{\string\theoremlistdo{#1}{\thm@tmp}}}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\theoremlistdo}
+% \changes{v1.19}{2001/01/13}{check for yet undefined theoremsets (WM)}
+% This one is called from the theorem-file to insert the additional
+% stuff for a theorem-set.
+% \begin{macrocode}
+\long\def\theoremlistdo#1#2{\expandafter\@ifundefined{thm@listdo#1}%
+ \relax{\csname thm@listdo#1\endcsname{#1}{#2}}}
+% \end{macrocode}
+% \end{macro}
+%
+% Now we assure, that the theorem-file is activated. This is done by
+% inserting a hook at the end of the document.
+% \changes{v0.83}{1997/02/13}{added `AtEndDocument'-Hook for lists (AS)}
+% \begin{macrocode}
+\AtEndDocument{\thm@enablelistoftheorems}
+% \end{macrocode}
+%
+% \subsubsection{Auxiliary macros}
+%
+% For generating theorem-lists, we need to write informations into
+% a separate file. Beause we don't want to expand this information,
+% we parse it specially for writing.
+% \begin{macrocode}
+\def\thm@meaning#1->#2\relax{#2}% remove "macro: ->"
+\long\def\thm@parseforwriting#1{%
+ \def\thm@tmp{#1}%
+ \edef\thm@tmp{\expandafter\thm@meaning\meaning\thm@tmp\relax}}
+% \end{macrocode}
+%
+% In some countries it's usual to number theorems with greek letters:
+%
+% \begin{macro}{\theorem@checkbold}
+% \changes{v0.83}{1997/02/13}{fixed greek numbering for bold headers (AS)}
+% For correctness, we need to check if a bold font is active. This
+% is done by the following macro:
+% \begin{macrocode}
+\def\theorem@checkbold{\if b\expandafter\@car\f@series\@nil\boldmath\fi}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\@greek}
+% Accoding to \LaTeX-base, this is the internal command for generating
+% lowercase greek numberings.
+% \begin{macrocode}
+\def\@greek#1{\theorem@checkbold%
+ \ifcase#1\or$\alpha$\or$\beta$\or$\gamma$\or$\delta$\or$\varepsilon$%
+ \or$\zeta$\or$\eta$\or$\vartheta$\or$\iota$\or$\kappa$\or$\lambda$\or$%
+ \mu$\or$\nu$\or$\xi$\or$ o$\or$\varpi$\or$\varrho$\or$\varsigma$\or$\tau$%
+ \or$\upsilon$\or$\varphi$\or$\chi$\or$\psi$\or$\omega$\else\@ctrerr\fi}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\@Greek}
+% According to \LaTeX-base, this is the internal command for generating
+% uppercase greek numberings.
+% \begin{macrocode}
+\def\@Greek#1{\theorem@checkbold%
+ \ifcase#1\or A\or B\or$\Gamma$\or$\Delta$\or E%
+ \or Z\or H\or$\Theta$\or I\or K\or$\Lambda$\or M%
+ \or N\or$\Xi$\or O\or$\Pi$\or P\or$\Sigma$\or T%
+ \or$\Upsilon$\or$\Phi$\or X\or$\Psi$\or$\Omega$\else\@ctrerr\fi}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\greek}
+% According to \LaTeX-base, this is the user interface for lowercase
+% greek numberings.
+% \begin{macrocode}
+\def\greek#1{\@greek{\csname c@#1\endcsname}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\Greek}
+% According to \LaTeX-base, this is the user interface for uppercase
+% greek numberings.
+% \begin{macrocode}
+\def\Greek#1{\@Greek{\csname c@#1\endcsname}}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Other Things}
+%
+% After declaring several package-options, we need to process the
+% specified ones. The additional |\relax| was mentioned by Rainer Sch\"opf
+% at DANTE'97.
+% \begin{macrocode}
+\ProcessOptions\relax
+% \end{macrocode}
+% Now we set up the default theorem listtype. Make sure this is called after
+% processing the options. Otherwise, |ntheorem| will break with |hyperref|.
+% \begin{macrocode}
+\theoremlistall
+% \end{macrocode}
+%
+% If automatical configuration is not disabled by |[noconfig]|, it is
+% checked if the file |ntheorem.cfg| exists and in this case
+% the definitions in this file are read. If it does not exist and the
+% option |standard| was specified, the file |ntheorem.std| is used.
+%
+% \changes{v0.84}{1997/02/13}{added 'ntheorem.cfg' feature (AS)}
+% \changes{v1.11}{1998/10/26}{added 'noconfig' option (AS/WM)}
+% \begin{macrocode}
+\ifx\thm@noconfig\@undefined
+\InputIfFileExists{ntheorem.cfg}%
+ {\PackageInfo{\basename}{Local config file ntheorem.cfg used}}%
+ {\ifx\thm@usestd\@undefined%
+ \else%
+ \InputIfFileExists{ntheorem.std}%
+ {\PackageInfo{\basename}{Standard config file ntheorem.std used}}{}
+ \fi}
+\fi
+% \end{macrocode}
+%\iffalse
+%</package>\fi
+%
+% \subsection{The Standard Configuration}
+%
+% \changes{v0.84}{1997/02/13}{moved standard-theorems to extra file (AS)}
+% \setcounter{CodelineNo}{0}
+%\iffalse
+%<*standard>\fi
+% \begin{macrocode}
+\theoremnumbering{arabic}
+\theoremstyle{plain}
+\RequirePackage{latexsym}
+\theoremsymbol{\ensuremath{_\Box}}
+\theorembodyfont{\itshape}
+\theoremheaderfont{\normalfont\bfseries}
+\theoremseparator{}
+\newtheorem{Theorem}{Theorem}
+\newtheorem{theorem}{Theorem}
+\newtheorem{Satz}{Satz}
+\newtheorem{satz}{Satz}
+\newtheorem{Proposition}{Proposition}
+\newtheorem{proposition}{Proposition}
+\newtheorem{Lemma}{Lemma}
+\newtheorem{lemma}{Lemma}
+\newtheorem{Korollar}{Korollar}
+\newtheorem{korollar}{Korollar}
+\newtheorem{Corollary}{Corollary}
+\newtheorem{corollary}{Corollary}
+
+\theorembodyfont{\upshape}
+\newtheorem{Example}{Example}
+\newtheorem{example}{Example}
+\newtheorem{Beispiel}{Beispiel}
+\newtheorem{beispiel}{Beispiel}
+\newtheorem{Bemerkung}{Bemerkung}
+\newtheorem{bemerkung}{Bemerkung}
+\newtheorem{Anmerkung}{Anmerkung}
+\newtheorem{anmerkung}{Anmerkung}
+\newtheorem{Remark}{Remark}
+\newtheorem{remark}{Remark}
+\newtheorem{Definition}{Definition}
+\newtheorem{definition}{Definition}
+
+\theoremstyle{nonumberplain}
+\theoremheaderfont{\scshape}
+\theorembodyfont{\normalfont}
+\theoremsymbol{\ensuremath{_\blacksquare}}
+\RequirePackage{amssymb}
+\newtheorem{Proof}{Proof}
+\newtheorem{proof}{Proof}
+\newtheorem{Beweis}{Beweis}
+\newtheorem{beweis}{Beweis}
+\qedsymbol{\ensuremath{_\blacksquare}}
+\theoremclass{LaTeX}
+% \end{macrocode}
+%\iffalse
+%</standard>\fi
+%
+% \section{History and Acknowledgements}
+%
+% \subsection{The endmark-Story (Wolfgang May)}
+%
+% In 1995, I started a hack for setting endmarks semiautomatically
+% at the end of displayed formulas.
+% The work on |thmmarks.sty| begun in October 1996
+% by a thread asking for a routine for setting endmarks in
+% \emph{de.comp.tex}
+% initiated by Boris Piwinger.
+% Version 0.1 incorporated the main features for setting endmarks
+% automagically by using the |.aux| file. Version 0.2 included
+% some bugfixes and was the first one accessible on the internet.
+% Boris suggested to include |fleqn| and |leqno| which has been
+% done in version 0.3 (which was never made public).
+% Since at this point, |thmmarks.sty| was incompatible to the widely
+% used |theorem.sty| written by Frank Mittelbach, in Version 0.4,
+% the features of theorem.sty have been integrated.
+%
+% With version 0.5, the case of ``empty'' end symbols has been handled,
+% |\qed| has been added (also suggested by Boris), and
+% the handling of theoremstyles by |\newtheoremstyle| has been
+% included.
+%
+% For version 0.6, the handling of endmarks in displaymaths has been
+% changed in order to adjust them with the bottom of the displayed
+% math.
+%
+% Version 0.6 was the first one announced in \emph{comp.text.tex}.
+% For version 0.7, I added the handling of |amsmath| features,
+% suggested by my colleague Peter Neuhaus.
+%
+% Versions 0.71 and 0.72 incorporated minor bugfixes.
+%
+% \subsection{Lists, Lists, Lists (Andreas Schlechte)}
+%
+% I often saw questions on theoremlists in the
+% german newsgroup \emph{de.comp.text.tex}, but I never
+% spent any attention on those postings. This changed in
+% summer 1996, when I needed those lists for myself. Thus, I
+% asked the holy question. But none of the given answers
+% satisfied my wish for a simple, easy to use and short
+% solution.
+%
+% I decided to take a look at Frank Mittelbachs
+% |theorem.sty|. First I didn't understand much of the code,
+% but Bernd Raichle helped me a lot by answering my
+% boring questions and I finally understood it.
+%
+% I started the coding and within a few days, a first
+% experimental version was born. Not only that I had implemented
+% the lists, I also inserted a separator and a flexible numbering
+% of the theorems.
+%
+% After a long period of
+% testing, I wanted to share the new features with other
+% \TeX-Freaks and wrote an article for the ``Die \TeX nische Kom\"odie''
+% (Journal of german tug, DANTE e.V.). As soon as I had sent
+% the article to DANTE, I got first reactions on the style.
+% Gerd Neugebauer gave me many hints. I hided several
+% cryptical notations in easy definitions and improved the
+% user interface.
+%
+% In January 1997, I released ``newthm'' to the world and it
+% was uploaded to the CTAN-Archives. Few days later I sent
+% my files to Frank Mittelbach in order to show him my extensions.
+% He told me, that already other extensions were made, and that
+% it would be good to combine alltogether.
+%
+% \subsection{Let's come together}
+%
+% With version 0.8, in February 1997, the combination of
+% |thmmarks.sty| with |newthm.sty| to |ntheorem.sty| has been started.
+% On April 21, 1997, version 0.94 beta has been made public as
+% version 1.0.
+%
+% In course of the development, the following changes were made:
+%
+% \GlossaryPrologue{}
+%
+% \IfFileExists{ntheorem.gls}{\PrintChanges}
+% {\begin{quote}You should create the list of changes by
+%
+% ~~~ \texttt{makeindex -s gglo.ist -o ntheorem.gls ntheorem.glo}
+%
+% and running \texttt{latex ntheorem.drv} again.\end{quote}}
+%
+%
+% \subsection{Acknowledgements}
+%
+% This place is dedicated to all those, who helped us developing
+% our separate styles and this combined package. Thanks to
+% (listed in alphabetical order):
+% \begin{quote}
+% Donald Arseneau,
+% Giovanni Dore,
+% Oliver Karch,
+% Frank Mittelbach,
+% Gerd Neugebauer,
+% Heiko Oberdiek,
+% Boris Piwinger,
+% Bernd Raichle,
+% Rainer Sch\"opf,
+% Didier Verna.
+% \end{quote}
+%
+% \Finale
+\endinput
+
+% Local Variables:
+% TeX-command-default: "LaTeX"
+% TeX-master: t
+% End:
+% mode: latex
diff --git a/Master/texmf-dist/source/latex/ntheorem/ntheorem.ins b/Master/texmf-dist/source/latex/ntheorem/ntheorem.ins
new file mode 100644
index 00000000000..6f8d87d4b50
--- /dev/null
+++ b/Master/texmf-dist/source/latex/ntheorem/ntheorem.ins
@@ -0,0 +1,18 @@
+\def\filedate{1997/04/21}
+\def\batchfile{ntheorem.ins}
+\input docstrip.tex
+\generateFile{ntheorem.drv}{t}{\from{ntheorem.dtx}{driver}}
+\generateFile{ntheorem.sty}{t}{\from{ntheorem.dtx}{package}}
+\generateFile{ntheorem.std}{t}{\from{ntheorem.dtx}{standard}}
+%
+\Msg{***************************************************************}
+\Msg{*}
+\Msg{* To finish the installation you have to move the following}
+\Msg{* files into a directory searched by TeX:}
+\Msg{*}
+\Msg{* All the files with the extension '.sty' and '.std'}
+\Msg{*}
+\Msg{* To produce the documentation run the .drv File through LaTeX.}
+\Msg{*}
+\Msg{* Happy TeXing}
+\Msg{***************************************************************}