*** empty log message ***
[m17n/m17n-docs.git] / styles / ntheorem-hyper.sty
1 %%
2 %% This is file `ntheorem.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% ntheorem.dtx  (with options: `package')
8 %%
9 %%
10 %% ### WARNING: =============================================================
11 %%
12 %% This file is a patched version that works (it seems) with hyperref.
13 %% Hyperref's \contentsline version breaks with ntheorem because it puts 3
14 %% arguments in the text field (e.g.: \contentsline{def}{{def}{1}{foo}}{21})
15 %%
16 %% To work around the problem, the following steps are implemented:
17 %% 1/ Don't use hyperref's contentsline: restore the normal definition at the
18 %%    beginning of \thm@processlist.
19 %% 2/ Let the different versions of \thm@@thmline take a 5th argument, the one
20 %%    provided by hyperref.
21 %% 3/ Let \thm@lgobble take a 3rd argument, the one provided by hyperref.
22 %% 4/ Do the hyperlinks manually in the different versions of \thm@@thmline
23 %%
24 %% You'll find comments starting with `%%DV' around my changes in the code.
25 %%
26 %%
27 %%                                           Didier Verna <verna@inf.enst.fr>
28 %%
29 %% ==========================================================================
30 %%
31 %% IMPORTANT NOTICE:
32 %%
33 %% For the copyright see the source file.
34 %%
35 %% Any modified versions of this file must be renamed
36 %% with new filenames distinct from ntheorem.sty.
37 %%
38 %% For distribution of the original source see the terms
39 %% for copying and modification in the file ntheorem.dtx.
40 %%
41 %% This generated file may be distributed as long as the
42 %% original source files, as listed above, are part of the
43 %% same distribution. (The sources need not necessarily be
44 %% in the same archive or directory.)
45 \def\filedate{1998/12/03}
46 \def\docdate{1998/12/03}
47 \def\fileversion{1.14}
48 \def\basename{ntheorem-hyper}
49 %% \CharacterTable
50 %%  {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
51 %%   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
52 %%   Digits        \0\1\2\3\4\5\6\7\8\9
53 %%   Exclamation   \!     Double quote  \"     Hash (number) \#
54 %%   Dollar        \$     Percent       \%     Ampersand     \&
55 %%   Acute accent  \'     Left paren    \(     Right paren   \)
56 %%   Asterisk      \*     Plus          \+     Comma         \,
57 %%   Minus         \-     Point         \.     Solidus       \/
58 %%   Colon         \:     Semicolon     \;     Less than     \<
59 %%   Equals        \=     Greater than  \>     Question mark \?
60 %%   Commercial at \@     Left bracket  \[     Backslash     \\
61 %%   Right bracket \]     Circumflex    \^     Underscore    \_
62 %%   Grave accent  \`     Left brace    \{     Vertical bar  \|
63 %%   Right brace   \}     Tilde         \~}
64 \typeout{Style `\basename', Version \fileversion\space <\filedate>}
65 \ProvidesPackage{ntheorem-hyper}[\filedate \space\fileversion]
66 \newif\if@thmmarks\@thmmarksfalse
67 \newif\ifthm@tempif
68 \DeclareOption{thmmarks}{%*********************************
69 \PackageInfo{\basename}{Option `thmmarks' loaded}%
70 \@thmmarkstrue
71 \newcounter{endNonectr}
72 \newcounter{currNonectr}
73 \newif\ifsetendmark\setendmarktrue
74 \gdef\endtrivlist{%
75   \@endtrivlist{\PotEndMark{\hbox{}\nobreak\hfill\nobreak}}}
76 \gdef\@endtrivlist#1{%  % from \endtrivlist
77   \if@inlabel \indent\fi
78   \if@newlist \@noitemerr\fi
79   \ifhmode
80      \ifdim\lastskip >\z@ #1\unskip \par  %<<<<<<<<<<<<<<<<<<<<<<
81            \else \unskip \par \fi
82      \fi
83   \if@noparlist \else
84     \ifdim\lastskip >\z@
85        \@tempskipa\lastskip \vskip -\lastskip
86       \advance\@tempskipa\parskip \advance\@tempskipa -\@outerparskip
87       \vskip\@tempskipa
88     \fi
89     \@endparenv
90   \fi}
91 \gdef\SetMark@endeqn{\quad}%  as default, cf. option leqno
92 \gdef\endequation{\eqno \hbox{\@eqnnum \PotEndMark{\SetMark@endeqn}}%
93     $$\global\@ignoretrue}
94 \gdef\[{%
95    \relax\ifmmode
96       \@badmath
97    \else
98       \ifvmode
99          \nointerlineskip
100          \makebox[.6\linewidth]%
101       \fi
102       $$\stepcounter{end\InTheoType ctr}%
103         \@ifundefined{mark\roman{curr\InTheoType ctr}%
104                       \InTheoType\roman{end\InTheoType ctr}}{\relax}%
105           {\ifx\csname\InTheoType Symbol\endcsname\@empty\else
106              \boxmaxdepth=.5ex\begin{array}[b]{l}%
107              \boxmaxdepth=\maxdimen\displaystyle\fi}%
108         \addtocounter{end\InTheoType ctr}{-1}%
109         %%$$ BRACE MATCH HACK
110    \fi}
111 \gdef\]{%
112       \stepcounter{end\InTheoType ctr}%
113         \@ifundefined{mark\roman{curr\InTheoType ctr}%
114                       \InTheoType\roman{end\InTheoType ctr}}{\relax}%
115           {\ifx\csname\InTheoType Symbol\endcsname\@empty\else
116               \end{array}\fi}%
117         \addtocounter{end\InTheoType ctr}{-1}%
118    \relax\ifmmode
119       \ifinner
120          \@badmath
121       \else
122           \PotEndMark{\eqno}\global\@ignoretrue$$%%$$ BRACE MATCH HACK
123       \fi
124    \else
125       \@badmath
126    \fi
127    \ignorespaces}
128 \gdef\SetMark@endeqnarray#1{\llap{\raisebox{-1.3em}{#1}}}
129 \gdef\endeqnarray{%
130       \global\let\Oldeqnnum=\@eqnnum
131       \gdef\@eqnnum{\Oldeqnnum\PotEndMark{\SetMark@endeqnarray}}%
132       \@@eqncr
133       \egroup
134       \global\advance\c@equation\m@ne
135    $$\global\@ignoretrue
136       \global\let\@eqnnum\Oldeqnnum}
137 \@namedef{endeqnarray*}{%
138      %    from \@@eqncr:
139     \let\reserved@a\relax
140     \ifcase\@eqcnt \def\reserved@a{& & &}\or \def\reserved@a{& &}%
141      \or \def\reserved@a{&}\else
142        \let\reserved@a\@empty
143        \@latex@error{Too many columns in eqnarray environment}\@ehc\fi
144      \reserved@a {\normalfont \normalcolor \PotEndMark{}}%
145      \global\@eqnswtrue\global\@eqcnt\z@\cr
146      %
147       \egroup
148       \global\advance\c@equation\m@ne
149    $$\global\@ignoretrue}
150 \gdef\endtabbing{%
151   \PotEndMark{\`}\@stopline\ifnum\@tabpush >\z@ \@badpoptabs
152   \fi\endtrivlist}
153 \gdef\endcenter{%
154   \@endtrivlist
155     {\PotEndMark{\rightskip0pt%
156          \settowidth{\leftskip}%
157           { \csname mark\roman{curr\InTheoType ctr}\InTheoType
158                    \roman{end\InTheoType ctr}\endcsname}%
159          \advance\leftskip\@flushglue\hskip\@flushglue}}}
160 \gdef\@empty{}
161 \gdef\@endtheorem{%
162   \expandafter
163   \ifx\csname\InTheoType Symbol\endcsname\@empty\setendmarkfalse\fi
164   \@endtrivlist
165     {\ifsetendmark
166      \hbox{}\nobreak\hfill\nobreak\csname\InTheoType Symbol\endcsname
167      \setendmarkfalse \fi}%
168   \ifsetendmark\OrganizeTheoremSymbol\else\global\setendmarktrue\fi}
169 \gdef\NoEndMark{\global\setendmarkfalse}
170 \gdef\qed{\expandafter\def\csname \InTheoType Symbol\endcsname
171           {\the\qedsymbol}}%
172 \gdef\PotEndMark#1{\SetEndMark{\InTheoType}{#1}}%
173 \gdef\SetEndMark#1#2{%
174    \stepcounter{end#1ctr}%
175    \@ifundefined{mark\roman{curr#1ctr}#1\roman{end#1ctr}}%
176    {\relax}%
177    {#2{\csname mark\roman{curr#1ctr}#1\roman{end#1ctr}\endcsname}}}%
178 \newskip\mysavskip
179 \gdef\@bbsphack{%
180     \mysavskip\lastskip
181     \unskip}
182 \gdef\@eesphack{%
183     \ifdim\mysavskip>\z@
184     \vskip\mysavskip \else\fi}
185 %% \begin{macrocode}
186 \gdef\OrganizeTheoremSymbol{%
187   \@bbsphack
188   \edef\thm@tmp{\expandafter\expandafter\expandafter\thm@meaning
189          \expandafter\meaning\csname\InTheoType Symbol\endcsname\relax}%
190   \protected@write\@auxout{}%
191      {\string\global\string\def\string\mark%
192       \roman{curr\InTheoType ctr}\InTheoType \roman{end\InTheoType ctr}%
193       {\thm@tmp}}%
194   \@eesphack}
195 } % end of option [thmmarks]
196 \DeclareOption{leqno}{%
197   \if@thmmarks
198   \PackageInfo{\basename}{Option `leqno' loaded}%
199    \gdef\SetMark@endeqn#1{\hss\llap{#1}}
200    \gdef\SetMark@endeqnarray#1{\hss\llap{#1}}
201   \fi}%
202 \DeclareOption{fleqn}{%
203 \if@thmmarks
204  \PackageInfo{\basename}{Option `fleqn' loaded}%
205  \renewcommand\[{\relax
206     \ifmmode\@badmath
207     \else
208      \begin{trivlist}%
209         \@beginparpenalty\predisplaypenalty
210         \@endparpenalty\postdisplaypenalty
211         \item[]\leavevmode
212         \hb@xt@\linewidth\bgroup $\m@th\displaystyle %$
213         \hskip\mathindent\bgroup
214           \stepcounter{end\InTheoType ctr}%
215           \@ifundefined{mark\roman{curr\InTheoType ctr}%
216                         \InTheoType\roman{end\InTheoType ctr}}{\relax}%
217             {\ifx\csname\InTheoType Symbol\endcsname\@empty\else
218               \boxmaxdepth=.5ex\begin{array}[b]{l}%
219               \boxmaxdepth=\maxdimen\displaystyle\fi}%
220           \addtocounter{end\InTheoType ctr}{-1}%
221     \fi}
222  \renewcommand\]{%
223     \stepcounter{end\InTheoType ctr}%
224     \@ifundefined{mark\roman{curr\InTheoType ctr}%
225                   \InTheoType\roman{end\InTheoType ctr}}{\relax}%
226       {\ifx\csname\InTheoType Symbol\endcsname\@empty\else
227           \end{array}\fi}%
228     \addtocounter{end\InTheoType ctr}{-1}%
229     \relax\ifmmode
230                   \egroup $\hfil\PotEndMark{}% $
231                 \egroup
232               \end{trivlist}%
233             \else \@badmath
234             \fi}
235 \gdef\endequation{%
236      $\hfil % $
237          \displaywidth\linewidth\hbox{\@eqnnum \PotEndMark{\SetMark@endeqn}}%
238        \egroup
239       \endtrivlist}
240 \gdef\endeqnarray{%
241     \global\let\Oldeqnnum=\@eqnnum
242     \gdef\@eqnnum{\Oldeqnnum\PotEndMark{\SetMark@endeqnarray}}%
243     \@@eqncr
244     \egroup
245     \global\advance\c@equation\m@ne$$% $$
246     \global\@ignoretrue
247     \global\let\@eqnnum\Oldeqnnum}
248 \fi}% end of option fleqn
249 \DeclareOption{amsmath}{%
250 \if@thmmarks
251  \PackageInfo{\basename}{Option `amsmath' loaded}%
252 \newdimen\thm@amstmpdepth
253 \gdef\TagsPlusEndmarks{%
254       \global\let\Old@maketag@@@=\maketag@@@
255       \global\let\Old@df@tag=\df@tag
256       \if@eqnsw\SetTagPlusEndMark\else
257         \iftag@\SetTagPlusEndMark
258       \else\SetOnlyEndMark
259       \fi\fi}
260 \gdef\SetOnlyEndMark{%
261       \global\tag@true
262         \iftagsleft@
263            \gdef\df@tag{\hbox
264                        to \displaywidth{\hss\PotEndMark{\maketag@@@}}}%
265         \else
266             \gdef\df@tag{\PotEndMark{\maketag@@@}}%
267         \fi}
268 \gdef\SetTagPlusEndMark{%
269         \iftagsleft@
270           \gdef\maketag@@@##1{%
271                \hbox to \displaywidth{\m@th\normalfont##1%
272                                       \PotEndMark{\hss}}}%
273         \else
274           \gdef\maketag@@@##1{\hbox{\m@th\normalfont##1%
275                            \llap{\hss\PotEndMark{\raisebox{-1.3em}}}}}%
276         \fi}
277 \gdef\RestoreTags{%
278     \global\let\maketag@@@=\Old@maketag@@@
279     \global\let\df@tag=\Old@df@tag}
280 \gdef\endgather{%
281       \TagsPlusEndmarks % <<<<<<<<<
282       \math@cr
283       \black@\totwidth@
284     \egroup
285     $$%
286     \RestoreTags        % <<<<<<<<<
287     \global\@ignoretrue}
288 \expandafter\let\csname endgather*\endcsname\endgather
289 \def\endalign{%
290         \ifingather@\else       % <<<<<<<<<
291            \TagsPlusEndmarks\fi % <<<<<<<<<
292         \math@cr
293         \black@\totwidth@
294     \egroup
295     \ifingather@
296         \restorealignstate@
297         \egroup
298         \nonumber
299         \ifnum0=`{\fi}%
300     \else
301         $$%
302         \RestoreTags            % <<<<<<<<<
303     \fi
304     \global\@ignoretrue}
305 \expandafter\let\csname endalign*\endcsname\endalign
306 \let\endxalignat\endalign
307 \expandafter\let\csname endxalignat*\endcsname\endalign
308 \let\endxxalignat\endalign
309 \let\endalignat\endalign
310 \expandafter\let\csname endalignat*\endcsname\endalign
311 \let\endflalign\endalign
312 \expandafter\let\csname endflalign*\endcsname\endalign
313 \def\lendmultline@{%
314         \@eqnswfalse\tag@true\tagsleft@false
315         \rendmultline@}
316 \def\rendmultline@{%
317     \TagsPlusEndmarks           % <<<<<<<<<
318     \iftag@
319         \begingroup
320             \ifshifttag@
321                 \hskip\multlinegap
322                 \llap{\vtop{%
323                     \raise@tag
324                     \normalbaselines
325                     \setbox\@ne\null
326                     \dp\@ne\lineht@
327                     \box\@ne
328                     \hbox{\strut@\make@display@tag}%
329                 }}%
330             \else
331                 \hskip\multlinetaggap
332                 \make@display@tag
333             \fi
334         \endgroup
335     \else
336         \hskip\multlinegap
337     \fi
338     \hfilneg
339         \math@cr
340     \egroup$$%
341     \RestoreTags}                % <<<<<<<<<
342 \def\[{%
343      \relax\ifmmode% \RIfM@ <<<<<<<<<<<<<<<<<<<<<<<<<<<<
344         \@badmath
345     \else
346         \DN@{%
347             $$%
348             \ingather@true
349             \inany@true
350             \def\\{\@amsmath@err{\Invalid@@\\}\@eha}%
351             \tabskip\@mathmargin
352             \halign to \displaywidth\bgroup
353                 \if@fleqn\else\hfil\fi
354                 \setboxz@h{$\m@th\displaystyle{####}$}%
355                 \global\totwidth@\wdz@
356                 \global\thm@amstmpdepth\dp0% <<<<<<<<<<<<
357                 \boxz@
358                 \tabskip 0pt plus 1000pt%<<<<<<<<<<<<<<
359                 & ####% <<<<<<<<<<<<<<<<<<<<<<<<
360                 \tabskip 0pt%
361                 \cr
362         }%
363         \@xp\next@
364     \fi}
365 \def\]{%
366      \relax\ifmmode%  \RIfM@ <<<<<<<<<<
367         \DN@{%
368               \PotEndMark{&\raisebox{-\thm@amstmpdepth}}% <<<<<<<<<
369               \crcr
370             \black@\totwidth@
371             \egroup
372             $$%
373         }%
374         \@xp\next@
375     \else
376         \@badmath
377     \fi}
378 \def\equation{\gather\def\\{\@amsmath@err{\Invalid@@\\}\@eha}}
379 \def\endequation{\endgather}
380 \renewenvironment{equation*}{\equation}{\nonumber\endequation}
381 \else\PackageError{\basename}{Option amsmath cannot be used without
382     option thmmarks.}\@eha
383 \fi
384 }% end of option amsmath
385 \let\thm@usestd\@undefined
386 \DeclareOption{standard}{\let\thm@usestd\relax}
387 \let\thm@noconfig\@undefined
388 \DeclareOption{noconfig}{\let\thm@noconfig\relax}
389 \gdef\InTheoType{None}
390 \def\output@None{None}
391 \def\None{None}
392 \gdef\newtheoremstyle#1#2#3{%
393   \expandafter\@ifundefined{th@#1}%
394    {\expandafter\gdef\csname th@#1\endcsname{%
395     \def\@begintheorem####1####2{#2}%
396     \def\@opargbegintheorem####1####2####3{#3}}}%
397    {\PackageError{\basename}{Theorem style #1 already defined}\@eha}}
398 \gdef\renewtheoremstyle#1#2#3{%
399   \expandafter\@ifundefined{th@#1}%
400    {\PackageError{\basename}{Theorem style #1 undefined}\@ehc}%
401      {}%
402   \expandafter\let\csname th@#1\endcsname\relax
403   \newtheoremstyle{#1}{#2}{#3}}
404 \newtheoremstyle{plain}%
405   {\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\theorem@separator]}%
406   {\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\ (##3)\theorem@separator]}
407 \newtheoremstyle{break}%
408   {\item\hbox to \textwidth{\theorem@headerfont ##1\
409       ##2\theorem@separator\hfill}}%
410   {\item\hbox to \textwidth{\theorem@headerfont ##1\ ##2\
411       (##3)\theorem@separator\hfill}}
412 \newtheoremstyle{change}%
413   {\item[\hskip\labelsep \theorem@headerfont ##2\ ##1\theorem@separator]}%
414   {\item[\hskip\labelsep \theorem@headerfont ##2\ ##1\ (##3)\theorem@separator]}
415 \newtheoremstyle{changebreak}%
416   {\item\hbox to \textwidth{\theorem@headerfont ##2\
417       ##1\theorem@separator\hfill}}%
418   {\item\hbox to \textwidth{\theorem@headerfont ##2\ ##1\
419       (##3)\theorem@separator\hfill}}
420 \newtheoremstyle{margin}%
421   {\item[\theorem@headerfont \llap{##2}\hskip\labelsep ##1\theorem@separator]}%
422   {\item[\theorem@headerfont \llap{##2}\hskip\labelsep ##1\ (##3)\theorem@separator]}
423 \newtheoremstyle{marginbreak}%
424   {\item\hbox to \textwidth{\theorem@headerfont \llap{##2}\hskip\labelsep
425       ##1\theorem@separator\hfill}}%
426   {\item\hbox to \textwidth{\theorem@headerfont
427       \llap{##2}\hskip\labelsep
428       ##1\ (##3)\theorem@separator\hfill}}
429 \newtheoremstyle{nonumberplain}%
430   {\item[\theorem@headerfont\hskip\labelsep ##1\theorem@separator]}%
431   {\item[\theorem@headerfont\hskip \labelsep ##1\ (##3)\theorem@separator]}
432 \newtheoremstyle{nonumberbreak}%
433   {\item\hbox to \textwidth{\theorem@headerfont\hskip\labelsep
434        ##1\theorem@separator\hfill}}%
435   {\item\hbox to \textwidth{\theorem@headerfont\hskip\labelsep
436        ##1\ (##3)\theorem@separator\hfill}}
437 \newtheoremstyle{empty}%
438   {\item~\hfill}%
439   {\item\hbox to \textwidth{\theorem@headerfont##3\hfill}}
440 \@namedef{th@nonumbermargin}{\th@nonumberplain}
441 \@namedef{th@nonumberchange}{\th@nonumberplain}
442 \@namedef{th@nonumbermarginbreak}{\th@nonumberbreak}
443 \@namedef{th@nonumberchangebreak}{\th@nonumberbreak}
444 \@namedef{th@plainNo}{\th@nonumberplain}
445 \@namedef{th@breakNo}{\th@nonumberplain}
446 \@namedef{th@marginNo}{\th@nonumberplain}
447 \@namedef{th@changeNo}{\th@nonumberplain}
448 \@namedef{th@marginbreakNo}{\th@nonumberbreak}
449 \@namedef{th@changebreakNo}{\th@nonumberbreak}
450 \gdef\theoremstyle#1{%
451    \@ifundefined{th@#1}{\@warning
452           {Unknown theoremstyle `#1'. Using `plain'}%
453           \theorem@style{plain}}%
454       {\theorem@style{#1}}}
455 \newtoks\theorem@style
456 \newtoks\theorem@@style
457 \global\theoremstyle{plain}
458 \newtoks\theorembodyfont
459 \global\theorembodyfont{\itshape}
460 \newtoks\theoremnumbering
461 \global\theoremnumbering{arabic}
462 \newskip\theorempreskipamount
463 \newskip\theorempostskipamount
464 \global\theorempreskipamount\topsep
465 \global\theorempostskipamount\topsep
466 \newdimen\theoremindent
467 \global\theoremindent0cm
468 \newdimen\theorem@indent
469 \newtoks\theoremheaderfont
470 \global\theoremheaderfont{\normalfont\bfseries}
471 \def\theorem@headerfont{\normalfont\bfseries}
472 \newtoks\theoremseparator
473 \global\theoremseparator{}
474 \def\theorem@separator{}
475 \newtoks\theoremsymbol
476 \global\theoremsymbol{}
477 \newtoks\qedsymbol
478 \global\qedsymbol{}
479 \DeclareOption{amsthm}{%
480   \PackageInfo{\basename}{Option `amsthm' loaded}%
481 \def\swapnumbers{\PackageError{\basename}{swapnumbers not implemented.
482   Use theoremstyle change instead.}\@eha}
483
484 \gdef\th@plain{%
485   \def\theorem@headerfont{\normalfont\bfseries}\itshape%
486   \def\@begintheorem##1##2{%
487       \item[\hskip\labelsep \theorem@headerfont ##1\ ##2.]}%
488   \def\@opargbegintheorem##1##2##3{%
489      \item[\hskip\labelsep \theorem@headerfont ##1\ ##2\ (##3).]}}
490 \gdef\th@nonumberplain{%
491   \def\theorem@headerfont{\normalfont\bfseries}\itshape%
492   \def\@begintheorem##1##2{%
493       \item[\hskip\labelsep \theorem@headerfont ##1.]}%
494   \def\@opargbegintheorem##1##2##3{%
495      \item[\hskip\labelsep \theorem@headerfont ##1\ (##3).]}}
496 \gdef\th@definition{%
497   \th@plain\def\theorem@headerfont{\normalfont\bfseries}\itshape}
498 \gdef\th@nonumberdefinition{%
499   \th@nonumberplain\def\theorem@headerfont{\normalfont\bfseries}\itshape}
500 \gdef\th@remark{%
501   \th@plain\def\theorem@headerfont{\itshape}\normalfont}
502 \gdef\th@nonumberremark{%
503   \th@nonumberplain\def\theorem@headerfont{\itshape}\normalfont}
504 \newcounter{proof}%
505 \if@thmmarks
506  \newcounter{currproofctr}%
507  \newcounter{endproofctr}%
508 \fi
509 \newcommand{\openbox}{\leavevmode
510   \hbox to.77778em{%
511   \hfil\vrule
512   \vbox to.675em{\hrule width.6em\vfil\hrule}%
513   \vrule\hfil}}
514 \gdef\proofSymbol{\openbox}
515 \newcommand{\proofname}{Proof}
516 \newenvironment{proof}[1][\proofname]{
517   \th@nonumberplain
518   \def\theorem@headerfont{\itshape}%
519   \normalfont
520   \theoremsymbol{\ensuremath{_\blacksquare}}
521   \@thm{proof}{proof}{#1}}%
522   {\@endtheorem}
523 }% end of option amsthm
524 \newskip\thm@topsepadd
525 \gdef\newtheorem{%
526    \@ifstar
527      {\edef\@tempa{{nonumber\the\theorem@style}}%
528       \expandafter\theorem@@style\@tempa}%
529      {\edef\@tempa{{\the\theorem@style}}%
530       \expandafter\theorem@@style\@tempa}%
531   \@newtheorem}
532
533 \gdef\renewtheorem{%
534    \@ifstar
535      {\edef\@tempa{{nonumber\the\theorem@style}}%
536       \expandafter\theorem@@style\@tempa}%
537      {\edef\@tempa{{\the\theorem@style}}%
538       \expandafter\theorem@@style\@tempa}%
539   \@renewtheorem}
540 \gdef\@newtheorem#1{%
541   \thm@tempiffalse
542   \expandafter\@ifdefinable\csname #1\endcsname
543   {\expandafter\@ifdefinable\csname #1*\endcsname
544    {\thm@tempiftrue
545     \thm@definelthm{#1}% for lists
546     \if@thmmarks
547       \expandafter\@ifundefined{c@curr#1ctr}%
548         {\newcounter{curr#1ctr}}{}%
549       \expandafter\@ifundefined{c@end#1ctr}%
550         {\newcounter{end#1ctr}}{}%
551     \fi
552     \expandafter\xdef\csname #1Symbol\endcsname{\the\theoremsymbol}%
553     \expandafter\gdef\csname#1\endcsname{%
554        \let\thm@starredenv\@undefined
555        \csname mkheader@#1\endcsname}%
556     \expandafter\gdef\csname#1*\endcsname{%
557        \let\thm@starredenv\relax
558        \csname mkheader@#1\endcsname}%
559     \def\@tempa{\expandafter\noexpand\csname end#1\endcsname}%
560     \expandafter\xdef\csname end#1*\endcsname{\@tempa}%
561     \expandafter\xdef\csname setparms@#1\endcsname
562      {\noexpand \def \noexpand \theorem@headerfont
563         {\the\theoremheaderfont\noexpand\theorem@checkbold}%
564       \noexpand \def \noexpand \theorem@separator
565         {\the\theoremseparator}%
566       \noexpand \def \noexpand \theorem@indent
567         {\the\theoremindent}%
568       \the \theorembodyfont
569       \noexpand\csname th@\the \theorem@@style \endcsname}}}%
570   \@ifnextchar[{\@othm{#1}}{\@nthm{#1}}}% MUST NOT BE IN ANY IF !!!
571 \gdef\@renewtheorem#1{%
572   \expandafter\@ifundefined{#1}%
573    {\PackageError{\basename}{Theorem style #1 undefined}\@ehc}%
574      {}%
575   \expandafter\let\csname #1\endcsname\relax
576   \expandafter\let\csname #1*\endcsname\relax
577   \newtheorem{#1}}
578 \gdef\@nthm#1#2{%
579   \expandafter\xdef\csname num@addtheoremline#1\endcsname{%
580               \noexpand\@num@addtheoremline{#1}{#2}}%
581   \expandafter\xdef\csname nonum@addtheoremline#1\endcsname{%
582               \noexpand\@nonum@addtheoremline{#1}{#2}}%
583   \expandafter\xdef\csname output@#1\endcsname{#2}%
584   \@ifnextchar[{\@xnthm{#1}{#2}}{\@ynthm{#1}{#2}}}
585 \gdef\@othm#1[#2]#3{%
586   \@ifundefined{c@#2}{\@nocounterr{#2}}%
587    {\ifthm@tempif
588      \global\@namedef{the#1}{\@nameuse{the#2}}%
589      \expandafter\xdef\csname num@addtheoremline#1\endcsname{%
590               \noexpand\@num@addtheoremline{#1}{#3}}%
591      \expandafter\xdef\csname nonum@addtheoremline#1\endcsname{%
592               \noexpand\@nonum@addtheoremline{#1}{#3}}%
593      \expandafter\xdef\csname output@#1\endcsname{#3}%
594      \expandafter\gdef\csname mkheader@#1\endcsname
595        {\csname setparms@#1\endcsname
596         \@thm{#1}{#2}{#3}}%
597      \global\@namedef{end#1}{\@endtheorem}\fi}}
598 \gdef\@xnthm#1#2[#3]{%
599   \ifthm@tempif
600      \expandafter\@ifundefined{c@#1}%
601         {\@definecounter{#1}}{}%
602      \@newctr{#1}[#3]%
603      \expandafter\xdef\csname the#1\endcsname{%
604        \expandafter\noexpand\csname the#3\endcsname \@thmcountersep
605           {\noexpand\csname\the\theoremnumbering\endcsname{#1}}}%
606      \expandafter\gdef\csname mkheader@#1\endcsname
607        {\csname setparms@#1\endcsname
608         \@thm{#1}{#1}{#2}}%
609      \global\@namedef{end#1}{\@endtheorem}\fi}
610 \gdef\@ynthm#1#2{%
611   \ifthm@tempif
612      \expandafter\@ifundefined{c@#1}%
613         {\@definecounter{#1}}{}%
614      \expandafter\xdef\csname the#1\endcsname
615         {\noexpand\csname\the\theoremnumbering\endcsname{#1}}%
616      \expandafter\gdef\csname mkheader@#1\endcsname
617        {\csname setparms@#1\endcsname
618         \@thm{#1}{#1}{#2}}%
619      \global\@namedef{end#1}{\@endtheorem}\fi}
620 \gdef\@thm#1#2#3{%
621    \if@thmmarks
622      \stepcounter{end\InTheoType ctr}%
623    \fi
624    \renewcommand{\InTheoType}{#1}%
625    \if@thmmarks
626      \stepcounter{curr#1ctr}%
627      \setcounter{end#1ctr}{0}%
628    \fi
629    \refstepcounter{#2}%
630    \thm@topsepadd \theorempostskipamount   % cf. latex.ltx: \@trivlist
631    \ifvmode \advance\thm@topsepadd\partopsep\fi
632    \trivlist
633    \@topsep \theorempreskipamount
634    \@topsepadd \thm@topsepadd        % used by \@endparenv
635    \advance\linewidth -\theorem@indent
636    \advance\@totalleftmargin \theorem@indent
637    \parshape \@ne \@totalleftmargin \linewidth
638    \@ifnextchar[{\@ythm{#1}{#2}{#3}}{\@xthm{#1}{#2}{#3}}}
639 \def\@xthm#1#2#3{%
640   \@begintheorem{#3}{\csname the#2\endcsname}%
641   \ifx\thm@starredenv\@undefined
642     \thm@thmcaption{#1}{{#3}{\csname the#2\endcsname}{}}\fi
643   \ignorespaces}
644 \def\@ythm#1#2#3[#4]{%
645   \expandafter\global\expandafter\def\csname#1name\endcsname{#4}%
646   \@opargbegintheorem{#3}{\csname the#2\endcsname}{#4}%
647   \ifx\thm@starredenv\@undefined
648     \thm@thmcaption{#1}{{#3}{\csname the#2\endcsname}{#4}}\fi%
649   \ignorespaces}
650 \DeclareOption{thref}{%*********************************
651   \PackageInfo{\basename}{Option `thref' loaded}%
652 \def\label#1{
653   \@ifnextchar[%]
654      {\label@optarg{#1}}%
655      {\label@optarg{#1}%
656       [\csname output@\InTheoType\endcsname]}}
657 \def\label@optarg#1[#2]{\@bsphack
658   \protected@write\@auxout{}%
659      {\string\newlabel{#1}{{\@currentlabel}{\thepage}}[#2]}%
660   \@esphack}
661 \def\@newl@bel#1#2#3{%
662   \@ifundefined{#1@#2}%
663     \relax
664     {\gdef \@multiplelabels {%
665        \@latex@warning@no@line{There were multiply-defined labels}}%
666      \@latex@warning@no@line{Label `#2' multiply defined}}%
667   \global\@namedef{#1@#2}{#3}%
668   \@ifnextchar[{\set@labeltype#1#2}{\relax}%]
669   }
670 \def\set@labeltype#1#2[#3]{\global\@namedef{#1@#2@type}{#3}}
671 \@ifpackageloaded{babel}%
672   {\message{ntheorem-babel adapation loaded}%
673    \def\newlabel#1#2{%
674      \@ifnextchar[{\nth@bbl@newlabel{#1}{#2}}%]
675                   {\nth@bbl@newlabel{#1}{#2}[None]}}%
676    \def\nth@bbl@newlabel#1#2[#3]{%
677      \@safe@activestrue\bbl@newlabel{#1}{#2}[#3]\@safe@activesfalse}}%
678   \relax
679 \def\thref#1{%
680    \expandafter\ifx\csname r@#1@type\endcsname\None
681      \PackageWarning{\basename}{thref: Reference Type of `#1' on page
682       \thepage \space undefined}\G@refundefinedtrue
683      \else\csname r@#1@type\endcsname~\fi%
684    \expandafter\@setref\csname r@#1\endcsname\@firstoftwo{#1}}
685 }% end of option thref
686 \def\thm@thmcaption#1#2{\thm@@thmcaption{#1}#2}
687 \def\thm@@thmcaption#1#2#3#4{%
688     \thm@parseforwriting{#4}%
689     \edef\thm@t{{#2}{#3}{\thm@tmp}}%
690     \addcontentsline{thm}{#1}{\thm@t}}
691 \def\theoremlistall{%
692     \let\thm@@thmlstart=\relax
693     \let\thm@@thmlend=\relax
694 %%DV Use a fith argument (supplied by hyperref) and do the links manually
695     \def\thm@@thmline##1##2##3##4##5{%
696         \ifx\\##5\\%
697             \@dottedtocline{-2}{0em}{2.3em}%
698                 {\protect\numberline{##2}##3}%
699                 {##4}
700         \else
701             \ifhy@linktocpage
702                 \@dottedtocline{-2}{0em}{2.3em}%
703                     {\protect\numberline{##2}##3}%
704                     {\hyper@linkstart{link}{##5}{##4}\hyper@linkend}
705             \else
706                 \@dottedtocline{-2}{0em}{2.3em}%
707                     {\hyper@linkstart{link}{##5}{\protect\numberline{##2}##3}%
708                       \hyper@linkend}%
709                     {##4}
710             \fi
711         \fi}}
712 %%DV    \def\thm@@thmline##1##2##3##4{%
713 %%DV        \@dottedtocline{-2}{0em}{2.3em}%
714 %%DV                   {\protect\numberline{##2}##3}%
715 %%DV                   {##4}}}
716 \def\theoremlistallname{%
717     \let\thm@@thmlstart=\relax
718     \let\thm@@thmlend=\relax
719 %%DV Use a fith argument (supplied by hyperref) and do the links manually
720     \def\thm@@thmline##1##2##3##4##5{%
721         \ifx\\##5\\%
722             \@dottedtocline{-2}{0em}{2.3em}%
723                 {##1 \protect\numberline{##2}##3}%
724                 {##4}
725         \else
726             \ifhy@linktocpage
727                 \@dottedtocline{-2}{0em}{2.3em}%
728                     {##1 \protect\numberline{##2}##3}%
729                     {\hyper@linkstart{link}{##5}{##4}\hyper@linkend}
730             \else
731                 \@dottedtocline{-2}{0em}{2.3em}%
732                     {\hyper@linkstart{link}{##5}%
733                       {##1 \protect\numberline{##2}##3}\hyper@linkend}%
734                     {##4}
735             \fi
736         \fi}}
737 %%DV    \def\thm@@thmline##1##2##3##4{%
738 %%DV         \@dottedtocline{-2}{0em}{2.3em}%
739 %%DV                   {##1 \protect\numberline{##2}##3}%
740 %%DV                   {##4}}}
741 \def\theoremlistoptional{%
742     \let\thm@@thmlstart=\relax
743     \let\thm@@thmlend=\relax
744 %%DV Use a fith argument (supplied by hyperref) and do the links manually
745     \def\thm@@thmline##1##2##3##4##5{%
746       \ifx\empty ##3%
747       \else%
748         \ifx\\##5\\%
749             \@dottedtocline{-2}{0em}{2.3em}%
750                 {\protect\numberline{##2}##3}%
751                 {##4}
752         \else
753             \ifhy@linktocpage
754                 \@dottedtocline{-2}{0em}{2.3em}%
755                     {\protect\numberline{##2}##3}%
756                     {\hyper@linkstart{link}{##5}{##4}\hyper@linkend}
757             \else
758                 \@dottedtocline{-2}{0em}{2.3em}%
759                     {\hyper@linkstart{link}{##5}{\protect\numberline{##2}##3}%
760                       \hyper@linkend}%
761                     {##4}
762             \fi
763         \fi
764       \fi}}
765 %%DV    \def\thm@@thmline##1##2##3##4{%
766 %%DV         \ifx\empty ##3%
767 %%DV         \else%
768 %%DV            \@dottedtocline{-2}{0em}{2.3em}%
769 %%DV                     {\protect\numberline{##2}##3}%
770 %%DV                     {##4}%
771 %%DV         \fi}}
772 \def\theoremlistoptname{%
773     \let\thm@@thmlstart=\relax
774     \let\thm@@thmlend=\relax
775 %%DV Use a fith argument (supplied by hyperref) and do the links manually
776     \def\thm@@thmline##1##2##3##4##5{%
777       \ifx\empty ##3%
778       \else
779         \ifx\\##5\\%
780             \@dottedtocline{-2}{0em}{2.3em}%
781                 {##1 \protect\numberline{##2}##3}%
782                 {##4}
783         \else
784             \ifhy@linktocpage
785                 \@dottedtocline{-2}{0em}{2.3em}%
786                     {##1 \protect\numberline{##2}##3}%
787                     {\hyper@linkstart{link}{##5}{##4}\hyper@linkend}
788             \else
789                 \@dottedtocline{-2}{0em}{2.3em}%
790                     {\hyper@linkstart{link}{##5}%
791                       {##1 \protect\numberline{##2}##3}\hyper@linkend}%
792                     {##4}
793             \fi
794         \fi
795       \fi}}
796 %%DV    \def\thm@@thmline##1##2##3##4{%
797 %%DV         \ifx\empty ##3%
798 %%DV         \else%
799 %%DV            \@dottedtocline{-2}{0em}{2.3em}%
800 %%DV                     {##1 \protect\numberline{##2}##3}%
801 %%DV                     {##4}%
802 %%DV         \fi}}
803 \theoremlistall
804 \def\theoremlisttype#1{%
805     \@ifundefined{thm@thml@#1}%
806        {\PackageError{\basename}{Listtype #1 not defined}\@eha}
807        {\csname thm@thml@#1\endcsname}}
808 \def\thm@thml@all{\theoremlistall}
809 \def\thm@thml@opt{\theoremlistoptional}
810 \def\thm@thml@optname{\theoremlistoptname}
811 \def\thm@thml@allname{\theoremlistallname}
812 \def\newtheoremlisttype#1#2#3#4{%
813   \@ifundefined{thm@thml@#1}%
814   {\expandafter\gdef\csname thm@thml@#1\endcsname{%
815     \def\thm@@thmlstart{#2}%
816     \def\thm@@thmline####1####2####3####4{#3}%
817     \def\thm@@thmlend{#4}}%
818   }{\PackageError{\basename}{list type #1 already defined}\@eha}}
819 \def\renewtheoremlisttype#1#2#3#4{%
820   \@ifundefined{thm@thml@#1}%
821     {\PackageError{\basename}{List type #1 not defined}\@ehc}{}%
822   \expandafter\let\csname thm@thml@#1\endcsname\relax
823   \newtheoremlisttype{#1}{#2}{#3}{#4}}
824 %%DV Use a third argument (supplied by hyperref)
825 \def\thm@thmline#1#2#3{\thm@@thmline#1{#2}{#3}}
826 %%DV\def\thm@thmline#1#2{\thm@@thmline#1{#2}}
827 %%DV Use a third argument (supplied by hyperref)
828 \long\def\thm@lgobble#1#2#3{\ignorespaces}
829 %%DV\long\def\thm@lgobble#1#2{\ignorespaces}
830 \def\thm@definelthm#1{%
831  \expandafter\gdef\csname l@#1\endcsname{\thm@lgobble}%
832  \expandafter\gdef\csname thm@listdo#1\endcsname{\thm@lgobble}}
833 \long\def\thm@inlistdo#1#2{#2}%
834 \def\listtheorems#1{\begingroup%
835   \c@tocdepth=-2%
836   \def\thm@list{#1}\thm@processlist%
837   \endgroup}
838 \def\thm@processlist{%
839  \begingroup%
840  \typeout{** Generating table of \thm@list}%
841 %%DV: don't use hyperref's \contentsline !! Use the normal definition.
842  \def\contentsline##1{\csname l@##1\endcsname}
843  \thm@@thmlstart
844  \@for\thm@currentlist:=\thm@list\do{%
845   \ifx\thm@currentlist\@empty\else%
846    \expandafter\gdef\csname l@\thm@currentlist\endcsname{\thm@thmline}%
847    \expandafter\gdef\csname thm@listdo\thm@currentlist\endcsname{\thm@inlistdo}%
848   \fi%
849  }%
850  \@input{\jobname .thm}%
851  \thm@@thmlend%
852  \@for\thm@currentlist:=\thm@list\do{%
853   \ifx\thm@currentlist\@empty\else%
854    \expandafter\gdef\csname l@\thm@currentlist\endcsname{\thm@lgobble}%
855    \expandafter\gdef\csname thm@listdo\thm@currentlist\endcsname{\thm@lgobble}%
856   \fi%
857  }%
858  \endgroup}
859 \def\thm@enablelistoftheorems{%
860   \begingroup%
861     \makeatletter%
862     \if@filesw%
863       \expandafter\newwrite\csname tf@thm\endcsname%
864       \immediate\openout \csname tf@thm\endcsname \jobname.thm\relax%
865     \fi%
866     \@nobreakfalse%
867   \endgroup}
868 \def\addtheoremline{\@ifstar{\nonum@addtheoremline}{\num@addtheoremline}}
869 \def\nonum@addtheoremline#1{\csname nonum@addtheoremline#1\endcsname}%
870 \def\num@addtheoremline#1{\csname num@addtheoremline#1\endcsname}%
871 \def\@nonum@addtheoremline#1#2#3{%
872     \thm@parseforwriting{#3}%
873     \edef\thm@t{{#2}{}{\thm@tmp}}%
874     \addcontentsline{thm}{#1}{\thm@t}}
875 \def\@num@addtheoremline#1#2#3{%
876    \thm@parseforwriting{#3}%
877     \edef\thm@t{{#2}{\csname the#1\endcsname}{\thm@tmp}}%
878     \addcontentsline{thm}{#1}{\thm@t}}
879 \long\def\addtotheoremfile{%
880   \@ifnextchar[{\@@addtotheoremfile}{\@addtotheoremfile}}
881 \long\def\@addtotheoremfile#1{%
882    \thm@parseforwriting{#1}%
883    \protected@write\@auxout%
884       {}{\string\@writefile{thm}{\thm@tmp}}}
885 \long\def\@@addtotheoremfile[#1]#2{%
886    \thm@parseforwriting{#2}%
887    \protected@write\@auxout%
888       {}{\string\@writefile{thm}{\string\theoremlistdo{#1}{\thm@tmp}}}}
889 \long\def\theoremlistdo#1#2{\csname thm@listdo#1\endcsname{#1}{#2}}
890 \AtEndDocument{\thm@enablelistoftheorems}
891 \def\thm@meaning#1->#2\relax{#2}% remove "macro:->"
892 \long\def\thm@parseforwriting#1{%
893     \def\thm@tmp{#1}%
894     \edef\thm@tmp{\expandafter\thm@meaning\meaning\thm@tmp\relax}}
895 \def\theorem@checkbold{\if b\expandafter\@car\f@series\@nil\boldmath\fi}
896 \def\@greek#1{\theorem@checkbold%
897  \ifcase#1\or$\alpha$\or$\beta$\or$\gamma$\or$\delta$\or$\varepsilon$%
898   \or$\zeta$\or$\eta$\or$\vartheta$\or$\iota$\or$\kappa$\or$\lambda$\or$%
899   \mu$\or$\nu$\or$\xi$\or$ o$\or$\varpi$\or$\varrho$\or$\varsigma$\or$\tau$%
900   \or$\upsilon$\or$\varphi$\or$\chi$\or$\psi$\or$\omega$\else\@ctrerr\fi}
901 \def\@Greek#1{\theorem@checkbold%
902  \ifcase#1\or A\or B\or$\Gamma$\or$\Delta$\or E%
903   \or Z\or H\or$\Theta$\or I\or K\or$\Lambda$\or M%
904   \or N\or$\Xi$\or O\or$\Pi$\or P\or$\Sigma$\or T%
905   \or$\Upsilon$\or$\Phi$\or X\or$\Psi$\or$\Omega$\else\@ctrerr\fi}
906 \def\greek#1{\@greek{\csname c@#1\endcsname}}
907 \def\Greek#1{\@Greek{\csname c@#1\endcsname}}
908 \ProcessOptions\relax
909 \ifx\thm@noconfig\@undefined
910 \InputIfFileExists{ntheorem.cfg}%
911   {\PackageInfo{\basename}{Local config file ntheorem.cfg used}}%
912   {\ifx\thm@usestd\@undefined%
913    \else%
914      \InputIfFileExists{ntheorem.std}%
915       {\PackageInfo{\basename}{Standard config file ntheorem.std used}}{}
916    \fi}
917 \fi
918 \endinput
919 %%
920 %% End of file `ntheorem.sty'.