%%
%% This is file `ntheorem.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ntheorem.dtx  (with options: `package')
%% 
%% IMPORTANT NOTICE:
%% 
%% For the copyright see the source file.
%% 
%% Any modified versions of this file must be renamed
%% with new filenames distinct from ntheorem.sty.
%% 
%% 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{2005/07/07}
\def\docdate{2005/07/07}
\def\fileversion{1.25}
\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         \~}
\typeout{Style `\basename', Version \fileversion\space <\filedate>}
\ProvidesPackage{ntheorem}[\filedate \space\fileversion]
\newif\if@thmmarks\@thmmarksfalse
\newif\if@thref\@threffalse
\newif\ifthm@tempif
\DeclareOption{thmmarks}{%*********************************
\PackageInfo{\basename}{Option `thmmarks' loaded}%
\@thmmarkstrue
\newcounter{endNonectr}
\newcounter{currNonectr}
\newif\ifsetendmark\setendmarktrue
\gdef\endtrivlist{%
  \@endtrivlist{\PotEndMark{\unskip\nobreak\hfill\nobreak}}}
\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}
\gdef\SetMark@endeqn{\quad}%  as default, cf. option leqno
\gdef\endequation{\eqno \hbox{\@eqnnum \PotEndMark{\SetMark@endeqn}}%
    $$\global\@ignoretrue}
\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}
\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}
\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}
\@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}
\gdef\endtabbing{%
  \PotEndMark{\`}\@stopline\ifnum\@tabpush >\z@ \@badpoptabs
  \fi\endtrivlist}
\gdef\endcenter{%
  \@endtrivlist
    {\PotEndMark{\rightskip0pt%
         \settowidth{\leftskip}%
          { \csname mark\roman{curr\InTheoType ctr}\InTheoType
                   \roman{end\InTheoType ctr}\endcsname}%
         \advance\leftskip\@flushglue\hskip\@flushglue}}}
\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
  }
\gdef\NoEndMark{\global\setendmarkfalse}
\gdef\qed{\expandafter\def\csname \InTheoType Symbol\endcsname
          {\the\qedsymbol}}%
\gdef\PotEndMark#1{\SetEndMark{\InTheoType}{#1}}%
\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{}}}}%
\newskip\mysavskip
\gdef\@bbsphack{%
    \ifvmode\else\mysavskip\lastskip
    \unskip\fi}
\gdef\@eesphack{%
    \ifdim\mysavskip>\z@
    \vskip\mysavskip \else\fi}
\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 of option [thmmarks]
\DeclareOption{leqno}{% *********************************************
  \if@thmmarks
  \PackageInfo{\basename}{Option `leqno' loaded}%
   \gdef\SetMark@endeqn#1{\hss\llap{#1}}
   \gdef\SetMark@endeqnarray#1{\hss\llap{#1}}
  \fi}%
\DeclareOption{fleqn}{% *********************************************
\if@thmmarks
 \PackageInfo{\basename}{Option `fleqn' loaded}%
 \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}
 \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}
\gdef\endequation{%
     $\hfil % $
         \displaywidth\linewidth\hbox{\@eqnnum \PotEndMark{\SetMark@endeqn}}%
       \egroup
      \endtrivlist}
\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}
\fi}% end of option fleqn
\DeclareOption{thref}{%**********************************************
  \PackageInfo{\basename}{Option `thref' loaded}%
\@threftrue
\newskip\mysavskip
\gdef\@bbsphack{%
    \ifvmode\else\mysavskip\lastskip
    \unskip\fi}
\gdef\@eesphack{%
    \ifdim\mysavskip>\z@
    \vskip\mysavskip \else\fi}
\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}
\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}}

\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]{}
\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 of option thref ************************************************
\DeclareOption{amsmath}{% ***************************************************
\if@thref
 \PackageInfo{\basename}{option `amsmath' handling for `thref' loaded}%
\let\ltx@label\label
\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}%
}
\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
}
\fi
\if@thmmarks
 \PackageInfo{\basename}{option `amsmath' handling for `thmmarks' loaded}%
\newdimen\thm@amstmpdepth
\gdef\TagsPlusEndmarks{%
      \global\let\Old@maketag@@@=\maketag@@@
      \global\let\Old@df@tag=\df@tag
      \if@eqnsw\SetTagPlusEndMark
        \else
          \iftag@\SetTagPlusEndMark
            \else\SetOnlyEndMark
          \fi
      \fi}
\gdef\SetOnlyEndMark{%
      \global\tag@true
        \iftagsleft@
           \gdef\df@tag{\hbox
                       to \displaywidth{\hss\PotEndMark{\maketag@@@}}}%
        \else
            \gdef\df@tag{\PotEndMark{\maketag@@@}}%
        \fi}
\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}
\gdef\RestoreTags{%
    \global\let\maketag@@@=\Old@maketag@@@
    \global\let\df@tag=\Old@df@tag}
\gdef\endgather{%
      \TagsPlusEndmarks % <<<<<<<<<
      \math@cr
      \black@\totwidth@
    \egroup
    $$%
    \RestoreTags        % <<<<<<<<<
    \ignorespacesafterend}
\expandafter\let\csname endgather*\endcsname\endgather
\def\endalign{%
        \ifingather@\else       % <<<<<<<<<
           \TagsPlusEndmarks\fi % <<<<<<<<<
        \math@cr
        \black@\totwidth@
    \egroup
    \ifingather@
        \restorealignstate@
        \egroup
        \nonumber
        \ifnum0=`{\fi\iffalse}\fi
    \else
        $$%
        \RestoreTags            % <<<<<<<<<
    \fi
    \ignorespacesafterend}
\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
\def\lendmultline@{%
        \global\@eqnswfalse\tag@false\tagsleft@false
        \rendmultline@}
\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}                % <<<<<<<<<
\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
}
\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
}
\fi
}% end of option amsmath/thmmarks **************************************
\let\thm@usestd\@undefined
\DeclareOption{standard}{\let\thm@usestd\relax}
\let\thm@noconfig\@undefined
\DeclareOption{noconfig}{\let\thm@noconfig\relax}
\gdef\InTheoType{None}
\gdef\NoneKeyword{None}
\gdef\NoneSymbol{None}
\gdef\None{None}
\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}}
\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}}
\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}
\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}
\newtoks\theorembodyfont
\global\theorembodyfont{\itshape}
\newtoks\theoremnumbering
\global\theoremnumbering{arabic}
\newskip\theorempreskipamount
\newskip\theorempostskipamount
\global\theorempreskipamount\topsep
\global\theorempostskipamount\topsep
\newdimen\theoremindent
\global\theoremindent0cm
\newdimen\theorem@indent
\newtoks\theoremheaderfont
\global\theoremheaderfont{\normalfont\bfseries}
\def\theorem@headerfont{\normalfont\bfseries}
\newtoks\theoremseparator
\global\theoremseparator{}
\def\theorem@separator{}
\newtoks\theoremprework
\global\theoremprework{\relax}
\newtoks\theorempostwork
\global\theorempostwork{\relax}
\def\theorem@prework{}
\newtoks\theoremsymbol
\global\theoremsymbol{}
\newtoks\qedsymbol
\global\qedsymbol{}
\newtoks\theoremkeyword
\global\theoremkeyword{None}
\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{}}
\newtoks\qedsymbol
\global\qedsymbol{}
\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 **********************************************
\newskip\thm@topsepadd
\gdef\newtheorem{%
  \newtheorem@i%
}

\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}}

\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}}
\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 !!!
\gdef\@renewtheorem#1{%
  \expandafter\@ifundefined{#1}%
   {\PackageError{\basename}{Theorem keyword #1 undefined}\@ehc}%
     {}%
  \expandafter\let\csname #1\endcsname\relax
  \expandafter\let\csname #1*\endcsname\relax
  \@newtheorem{#1}}
\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}}}
\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}}
\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}
\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}
\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}}}
\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}
\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}
\gdef\@endtheorem{%
  \endtrivlist
  \csname\InTheoType @postwork\endcsname
  }
\DeclareOption{framed}{%*********************************
\newtoks\shadecolor
\shadecolor{gray}
\let\theoremframecommand\relax
\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}%
  }
\def\newframedtheorem#1{%
  \theoremprework{\framed}%
  \theorempostwork{\endframed}%
  \newtheorem@i{#1}%
  }
}% end of option framed **********************************************
\def\thm@thmcaption#1#2{\thm@@thmcaption{#1}#2}
\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}}
\def\thm@@thmline@noname#1#2#3#4{%
            \@dottedtocline{-2}{0em}{2.3em}%
                   {\protect\numberline{#2}#3}%
                   {#4}}
\def\thm@@thmline@name#1#2#3#4{%
        \@dottedtocline{-2}{0em}{2.3em}%
                   {#1 \protect\numberline{#2}#3}%
                   {#4}}
\def\thm@thmline#1#2{\thm@@thmline#1{#2}}
\long\def\thm@lgobble#1#2{\ignorespaces}
\def\theoremlistall{%
    \let\thm@@thmlstart=\relax
    \let\thm@@thmlend=\relax
    \let\thm@@thmline=\thm@@thmline@noname}
\def\theoremlistallname{%
    \let\thm@@thmlstart=\relax
    \let\thm@@thmlend=\relax
    \let\thm@@thmline=\thm@@thmline@name}
\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}}
\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}}
\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 *********************************************
\def\theoremlisttype#1{%
    \@ifundefined{thm@thml@#1}%
       {\PackageError{\basename}{Listtype #1 not defined}\@eha}%
       {\csname thm@thml@#1\endcsname}}
\def\thm@thml@all{\theoremlistall}
\def\thm@thml@opt{\theoremlistoptional}
\def\thm@thml@optname{\theoremlistoptname}
\def\thm@thml@allname{\theoremlistallname}
\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}}
\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}}
\def\thm@definelthm#1{%
 \expandafter\gdef\csname l@#1\endcsname{\thm@lgobble}%
 \expandafter\gdef\csname thm@listdo#1\endcsname{\thm@lgobble}}
\long\def\thm@inlistdo#1#2{#2}%
\def\listtheorems#1{\begingroup
  \c@tocdepth=-2%
  \def\thm@list{#1}\thm@processlist
  \endgroup}
\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}
\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}
\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}%
\def\@nonum@addtheoremline#1#2#3{%
    \thm@parseforwriting{#3}%
    \edef\thm@t{{#2}{}{\thm@tmp}}%
    \addcontentsline{thm}{#1}{\thm@t}}
\def\@num@addtheoremline#1#2#3{%
   \thm@parseforwriting{#3}%
    \edef\thm@t{{#2}{\csname the#1\endcsname}{\thm@tmp}}%
    \addcontentsline{thm}{#1}{\thm@t}}%
\long\def\addtotheoremfile{%
  \@ifnextchar[{\@@addtotheoremfile}{\@addtotheoremfile}}
\long\def\@addtotheoremfile#1{%
   \thm@parseforwriting{#1}%
   \protected@write\@auxout%
      {}{\string\@writefile{thm}{\thm@tmp}}}
\long\def\@@addtotheoremfile[#1]#2{%
   \thm@parseforwriting{#2}%
   \protected@write\@auxout%
      {}{\string\@writefile{thm}{\string\theoremlistdo{#1}{\thm@tmp}}}}
\long\def\theoremlistdo#1#2{\expandafter\@ifundefined{thm@listdo#1}%
     \relax{\csname thm@listdo#1\endcsname{#1}{#2}}}
\AtEndDocument{\thm@enablelistoftheorems}
\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}}
\def\theorem@checkbold{\if b\expandafter\@car\f@series\@nil\boldmath\fi}
\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}
\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}
\def\greek#1{\@greek{\csname c@#1\endcsname}}
\def\Greek#1{\@Greek{\csname c@#1\endcsname}}
\ProcessOptions\relax
\theoremlistall
\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
\endinput
%%
%% End of file `ntheorem.sty'.
