summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/kluwer/klumath.sty
blob: b4f9b9d1eef429e36b7ede358c5e5efc1d6174a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
%
%<*other>
%
\ifcat a\noexpand @\let\next\relax\else \def\next{%
\documentclass{kluwer}\usepackage{doc}\MakePercentIgnore}\fi\next
\def\filedate{1999/09/09}
% \def\changes#1#2{}
% \changes{1999/09/09}{bugfix pf* environment}
% \changes{1999/11/08}{AtEndOfPackage replaced with custom hook AtEndKluMath
%   for the benefit of a single docstripped kluwer.cls}
% \changes{1999/12/01}{Fixed indent after fleqn / displaymath}
% \changes{2000/01/19}{Removed begin/endgroup for subequations to
%   eliminate unwanted indentation}
% \changes{2000/02/10}{Removed superfluous thmdot in case of opt. arg}
% \changes{2000/02/24}{Preserved some list parameters within theorem}
% \changes{2000/03/27}{trivlist replaced with trivm@th for
%   displaymath to preserve spacing inside enumerate and itemize}
% \changes{2000/04/03}{removed bgroup/egroup from trivma@th to
%   eliminate spurious indentation}
\def\filename{klumath.sty}
%\DoNotIndex{\@M,\def,\c@secnumdepth,\baselineskip,\@pnumwidth,\else,\fi}
%\DoNotIndex{\newcommand,\z@,\relax,\renewcommand,\ifnum,\csname,\endcsname}
%\DoNotIndex{\baselineskip,\vskip,\hskip,\relax,\secdef,\refstepcounter}
%\DoNotIndex{\normalsize,\numberline,\protect,\endinput}
%\DoNotIndex{\@compare,\ifx,\global}
%\CodelineIndex
%\newcommand{\Bs}{$\backslash$}
%\parindent=0pt
%\parskip=3pt
%\hfuzz=10pt
%\MakeShortVerb{\|}
%\setlength{\marginparwidth}{0in}
%\addtolength{\textwidth}{4pc}
%\begin{document}
%\begin{opening}
%\title{\filename}
%\date{\filedate}
%\author{T. \surname{Hoekwater}}
%\institute{Kluwer Academic Publishers}
%\begin{abstract}
% The math environments |varequation| and |subequation|, and the
% |mathsec| and |mathchap| options have been moved here. 
% These are  intended for large articles or books.
%
% This package also implements theorem-like environment
% support. There is one option: |thms|, which also defines the
% theorems, instead of just controlling layout for user defined
% theorems. This option is only supplied for backward compatibility,
% use is deprecated.   
%\end{abstract} 
%\end{opening}
%\tableofcontents
%\newpage\section{Usage notes}
%\subsection{Math environments}
% Two environments are defined to use with equations: |varequation|
% and\\ |subequation|. 
%
%  For |varequation|, there is one argument needed to be typeset as the
%  `equation counter'. Usage example: 
%\begin{verbatim}
%\begin{varequation}{A.345}
%...  
%\end{varequation}
%\end{verbatim}
%results in: 
%\begin{varequation}{A.345}
%...  
%\end{varequation}
% This environment does not step the equation counter.
% 
% For |subequation|,
% there is one {\it optional\/} argument, that allows selecting the formatted
% layout of the added part of the equation number. Example usage:
%\begin{verbatim}
%\begin{subequation}[alph] % this is also the default value
%\begin{equation}
%...    
%\end{equation}
%\end{subequation}
%\end{verbatim}  
%
% There are four package options, namely:
% \begin{itemize}
% \item[leqno] For equation numbers on the left.
% \item[fleqn] For flush left equations.
%\item[mathsec] For numbering within sections.
%\item[mathchap] For numbering within chapters. 
% (make sure the chapter counter is defined before you use this one)                                             
% \end{itemize}
%
% There are two user settings:
% \begin{itemize}
% \item |\mathindent| controls the amount of left indentation of
%    equations under |fleqn|. 
% \item |\eqnoindent| controls indentation for equation numbers. 
% This only makes sense when used together with flush left equations, in 
% which case it will move the equation counter from the right side to 
% the left, with the specified indentation from the margin.                                                                     
%                                                         
% \end{itemize}
%
% \subsection{Theorems}
% This part of the stylefile is a bit strange, because it doesn't really do
% much. For the theorem part, all it does is redefining the internal
% \LaTeX\ command from |\newtheorem| to recognize some common
% strings. Then it tries to extract meaning from the string it has
% found, and typesets the entire theorem accordingly. 
%
% All this has the following effect: If you define something like 
%\begin{verbatim}
%\newtheorem{thm}{THEOREM}[subsubsection] 
%\end{verbatim}
% It will still be typeset according to the rules defined in the
% stylefile you're using, regardless of the environment name and the
% used counter. 
%
% At this time, the following ``names'' are recognized: 
%
%\begin{tabular}{lllll} \hline
%THEOREM & COROLLARY & LEMMA & CLAIM\\
%ALGORITHM & DEFINITION & EXAMPLE & REMARK\\
%PROBLEM & CONJECTURE & PROPOSITION & \\[6pt]
%Remark & Note & Summary & Case & Criterion\\ \hline
%\end{tabular}
%
% The case distinction is significant here, so please note that
% |REMARK| and |Remark| are typeset differently.
%
% \subsection{Proof environments}
%
% The stylefile defines the environments |pf|  and |pf*| for use in
% proofs. |pf*| requires one argument, to be used as the `name' of the
% proof. Example usage:
%\begin{verbatim}
%\begin{thm}
%......  
%\end{thm}
%\begin{pf*}{Proofs}  
%....
%\end{pf*}\qed
%\end{verbatim}
%\begin{pf*}{Proofs}  
%....
%\end{pf*}\qed
% |\qed| Typesets an open box on the right margin.
%
%\newpage\section{Implementation}
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{klumath}[\filedate ]
%</other>
%<*head>
\let\@EndKlumathook\@empty
\def\AtEndKluMath{\g@addto@macro\@EndKlumathook}

\DeclareOption{leqno}{\AtEndKluMath{\varleqno}}                       
\DeclareOption{fleqn}{\AtEndKluMath{\varfleqn}}      
\DeclareOption{mathsec}{%
   \def\theequation{\arabic{section}.\arabic{equation}}}
\DeclareOption{mathchap}{%
   \def\theequation{\arabic{chapter}.\arabic{equation}}}
\newif\if@thms \@thmsfalse
\DeclareOption{thms}{\@thmstrue } 
\DeclareOption{secthm}{\AtEndKluMath{\if@thms
    \renewcommand{\thethm}{\thesection.\arabic{thm}.}%
    \renewcommand{\thecrit}{\thesection.\arabic{crit}.}%            
    \renewcommand{\therem}{\thesection.\arabic{rem}.}%
    \renewcommand{\theNote}{\thesection.\arabic{Note}.}%
    \renewcommand{\thesumm}{\thesection.\arabic{summ}.}%
    \renewcommand{\thecase}{\thesection.\arabic{case}.}%
    \fi
    }}
%\ExecuteOptions{}
%</head>
%<*other>
\ProcessOptions 
%    \end{macrocode}
% \subsection{Math environments} 
% First off is |varequation|. Doesn't step any counters, and it has one
% argument to define the `equationnumber' to be used.  The option
% |\eqnoindent| allows fooling around with the location of the number.
% 
%    \begin{macrocode}
%</other>
%<*main>
\def\trivm@th{%
%  \bgroup
  \ifnum \@itemdepth >0 \topsep\topsepm@th \fi
  \ifnum \@enumdepth >0 \topsep\topsepm@th \fi
  \trivlist}
\def\endtrivm@th{\endtrivlist %\egroup
}
\newdimen\eqnoindent
\setlength{\eqnoindent}{0pt}
\def\varequation#1{$$ \gdef\curr@vareq{#1}}
\def\endvarequation{\eqno \var@eqnnum $$\global\@ignoretrue }
\def\var@eqnnum{\reset@font\normalcolor  (\curr@vareq)}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\varleqno{%
   \def\@eqnnum{\hbox to .01\p@{}%
     \rlap{\reset@font\rmfamily\normalcolor
     \hskip -\displaywidth (\theequation)}}%
   \def\var@eqnnum{\hbox to .01\p@{}%
     \rlap{\reset@font\rmfamily\normalcolor
     \hskip -\displaywidth (\curr@vareq)}}%
}%
%    \end{macrocode}      
% |varfleqn| takes care of redefinitions in case of fleqn.
% |varequation| also has to be redefined, because it uses a
% trivlist.
%    \begin{macrocode}                                  
\def\varfleqn{%
  \newdimen\mathindent
  \mathindent\leftmargini
  \def\varequation##1{%
    \@beginparpenalty\predisplaypenalty
    \@endparpenalty\postdisplaypenalty                  
    \gdef\curr@vareq{##1}\trivm@th 
    \item[]\leavevmode
    \hbox to\linewidth\bgroup $ \displaystyle              
    \hskip\mathindent }%
  \def\endvarequation{$\hfil \displaywidth\linewidth 
    \ifdim \eqnoindent =\z@ 
       \llap{\hbox{\var@eqnnum}}%
     \else                                
       \llap{\hbox to 2pc{\var@eqnnum\hss}\kern \displaywidth
        \kern -\eqnoindent}%
     \fi
     \egroup  \endtrivm@th}%
% code copied from ltmath.ltx
  \def\[{\relax
          \ifmmode\@badmath
         \else
         \begin{trivm@th}%
           \@beginparpenalty\predisplaypenalty
           \@endparpenalty\postdisplaypenalty
           \item[]\leavevmode
           \hbox to\linewidth\bgroup $\m@th\displaystyle %$
             \hskip\mathindent\bgroup
         \fi}%
  \def\]{\relax
          \ifmmode
                \egroup $\hfil% $
              \egroup
            \end{trivm@th}%
          \else \@badmath
          \fi}%
%
% equation/endequation: as above, but with equation number
%
  \renewenvironment{equation}{%
     \@beginparpenalty\predisplaypenalty
     \@endparpenalty\postdisplaypenalty
     \refstepcounter{equation}%
     \trivm@th
       \item[]\leavevmode
       \hbox to\linewidth\bgroup $\m@th% $
         \displaystyle
         \hskip\mathindent}%%%%%%%
        {$\hfil % $
         \displaywidth\linewidth
    \ifdim \eqnoindent =\z@ 
       \llap{\hbox{\@eqnnum}}%
     \else
       \llap{\hbox to 2pc{\@eqnnum\hss}\kern \displaywidth
        \kern -\eqnoindent}%
     \fi
       \egroup
     \endtrivm@th}%
%
  \renewenvironment{eqnarray}{%
    \stepcounter{equation}%
    \def\@currentlabel{\p@equation\theequation}%
    \global\@eqnswtrue\m@th
    \global\@eqcnt\z@
    \tabskip\mathindent
    \let\\=\@eqncr
    \setlength{\abovedisplayskip}{\topsep}%
    \ifvmode
      \addtolength{\abovedisplayskip}{\partopsep}%
    \fi
    \addtolength{\abovedisplayskip}{\parskip}%
    \setlength{\belowdisplayskip}{\abovedisplayskip}%
    \setlength{\belowdisplayshortskip}{\abovedisplayskip}%
    \setlength{\abovedisplayshortskip}{\abovedisplayskip}%
    $$\everycr{}\halign to\linewidth% $$
    \bgroup
      \hskip\@centering
      $\displaystyle\tabskip\z@skip{####}$\@eqnsel&%
      \global\@eqcnt\@ne \hskip \tw@\arraycolsep \hfil${####}$\hfil&%
      \global\@eqcnt\tw@ \hskip \tw@\arraycolsep
        $\displaystyle{####}$\hfil \tabskip\@centering&%
      \global\@eqcnt\thr@@
           \llap \bgroup 
          \ifdim \eqnoindent =\z@ \else
         \hbox to 2pc \bgroup \fi 
              ####\ifdim \eqnoindent =\z@ 
              \egroup \else \hss\egroup\kern \displaywidth
        \kern -\eqnoindent\egroup
     \fi \tabskip\z@skip\cr}%
      {\@@eqncr
    \egroup
    \global\advance\c@equation\m@ne$$% $$
    \global\@ignoretrue
    }}                   
%    \end{macrocode}
% |subequation| is a lot smarter, it implements subnumbering by
% moving the current value of the |equation| counter to a fixed place,
% then resets |equation| and restarts numbering. 
%
%  Now the equation number consists of the `fixed' part and the
%  updated new part. 
%
%    \begin{macrocode}
\def\subequation{\@ifnextchar[{\@subequation}{\@subequation[alph]}}
\def\@subequation[#1]{\refstepcounter{equation}%
%    \end{macrocode}
% |\@testoption| is needed because we would like to have 
% $$\hfill (1.1)$$
% with a dot, but 
%$$\hfill (1a)$$ without.  
% 
%    \begin{macrocode}
  \def\@testoption{arabic}%
  \def\@testparam{#1}%
%  \begingroup
%    \end{macrocode}
% Save old values
%    \begin{macrocode}
  \edef\old@equation{\the\c@equation}%
  \edef\old@theequation{\theequation}%
  \setcounter{equation}{0}%
%    \end{macrocode}
% If the optional arg. == arabic; typeset a dot in between.
%    \begin{macrocode}
  \ifx\@testoption\@testparam
    \def\theequation{\old@theequation.\csname #1\endcsname{equation}}%
  \else
    \def\theequation{\old@theequation\csname #1\endcsname{equation}}%
  \fi}
%    \end{macrocode}
% Restore old values
%    \begin{macrocode}
\def\endsubequation{%
  \setcounter{equation}{\old@equation}%
%  \endgroup
  \global\@ignoretrue
}
%    \end{macrocode}
%\section{Theorems}
% \subsection{Fixed macros}
%    \begin{macrocode}
\newif\if@novspace
\let\@thmscase\uppercase
\newdimen\theoremsep
\theoremsep\z@
\def\thmdot{.}
\def\@stylehead{\rm }
\def\@styletext{\em }
\let\@dispcase\relax  
\newdimen\dispsep
\dispsep\parindent
\def\dispdot{.}
\def\@disphead{\it }
\def\@disptext{\rm }
%    \end{macrocode}
% Definition of the |pf| and |pf*| environments. These take into
% account the value of |\if@novspace| that is set by the theorem-like
% environments. 
%    \begin{macrocode} 
% |pf*| has an argument that allow on-the-spot redefinition of
% |\proofname|. 
%    \begin{macrocode}

\def\pr@@f#1{% 
  \par
    \if@novspace \vskip-\lastskip
    \else \addvspace{1\baselineskip 
            \@plus 0.5\baselineskip \@minus 0.1\baselineskip}%
    \fi \indent
    {\it #1.\/} \ignorespaces
}
\def\endpr@@f{%
  \par
   \addvspace{1\baselineskip \@plus 0.5\baselineskip \@minus 
        0.1\baselineskip}%
    \global\@novspacefalse
}

\def\newproof#1#2{% 
  \expandafter\def\csname #1\endcsname{\pr@@f{#2}}%
  \expandafter\def\csname end#1\endcsname{\endpr@@f}}
\newproof{pf}{Proof}

\newenvironment{pf*}[1]{\pr@@f{#1}}{\endpr@@f}
%    \end{macrocode}
% |\qed| takes into account whether it is called during math mode or
% text mode. This is important because outside of math mode there will
% usually be a line to much in the output.
%    \begin{macrocode}
\def\qed{\relax
     \ifmmode
       ~\hfill\Box
     \else
        \unskip\nobreak ~\hfill$\Box$%
      \fi \par}
%    \end{macrocode}
%|\@begintheorem| and |\@opargbegintheorem| do the real work.  Both
%have roughly the same layout: 
%    \begin{macrocode}
\newlength\items@ve\newlength\labels@ve
\def\@begintheorem#1#2{%
  \items@ve=\itemindent \labels@ve=\labelsep
  \trivlist  
    \global\@novspacetrue \itemindent\theoremsep 
     \item[\kern\labelsep 
     {\@stylehead\@thmscase{#1}\ #2\thmdot\/}]\ \@styletext
     \itemindent=\items@ve \labelsep=\labels@ve}
\def\@opargbegintheorem#1#2#3{%
      \items@ve=\itemindent \labels@ve=\labelsep
      \trivlist \labelsep\z@  
      \global\@novspacetrue \itemindent\theoremsep 
      \item[\kern \labelsep {\@stylehead\@thmscase{#1}\ #2\ 
      (#3). \/}]\ \@styletext
      \itemindent=\items@ve \labelsep=\labels@ve}
\def\@endtheorem{\endtrivlist}     
\def\rmtheorem#1{% 
    \expandafter\g@addto@macro\csname #1\endcsname{\rmfamily\upshape }%
    }
%    \end{macrocode}
%
% |\newdisplay|.
%
% This is taken from |ltthm.dtx|. It echoes the redefinitions
% for theorems. 
%    \begin{macrocode} 
\def\newdisplay#1{\@ifnextchar[{\@odisp{#1}}{\@ndisp{#1}}}
\def\@ndisp#1#2{%
  \@ifnextchar[{\@xndisp{#1}{#2}}{\@yndisp{#1}{#2}}}
\def\@xndisp#1#2[#3]{\expandafter\@ifdefinable\csname #1\endcsname
  {\@definecounter{#1}\@newctr{#1}[#3]%                     
      \expandafter\xdef\csname the#1\endcsname{\expandafter\noexpand
        \csname the#3\endcsname \@dispcountersep \@dispcounter{#1}}%
\global\@namedef{#1}{%
  \@disp{#1}{#2}}\global\@namedef{end#1}{\@enddisplay}}}
\def\@yndisp#1#2{\expandafter\@ifdefinable\csname #1\endcsname
{\@definecounter{#1}%
\expandafter\xdef\csname the#1\endcsname{\@dispcounter{#1}}%
\global\@namedef{#1}{%
  \@disp{#1}{#2}}\global\@namedef{end#1}{\@enddisplay}}}
\def\@odisp#1[#2]#3{%
  \@ifundefined{c@#2}{\@nocounterr{#2}}%
  {\expandafter\@ifdefinable\csname #1\endcsname
  {\global\@namedef{the#1}{\@nameuse{the#2}}%
\global\@namedef{#1}{\@disp{#2}{#3}}%
\global\@namedef{end#1}{\@enddisplay}}}}
\def\@disp#1#2{\refstepcounter         
    {#1}\@ifnextchar[{\@ydisp{#1}{#2}}{\@xdisp{#1}{#2}}}
\def\@xdisp#1#2{\@begindisplay{#2}{\csname the#1\endcsname}\ignorespaces}
\def\@ydisp#1#2[#3]{\@opargbegindisplay{#2}{\csname
       the#1\endcsname}{#3}\ignorespaces}
\def\@dispcounter#1{\noexpand\arabic{#1}}
\def\@dispcountersep{.}
\def\@begindisplay#1#2{%
    \items@ve=\itemindent \labels@ve=\labelsep
    \trivlist
    \global\@novspacefalse \itemindent\dispsep
        \item[{\@disphead 
        \@dispcase{#1}\ #2\dispdot \/}]\@disptext
        \itemindent=\items@ve \labelsep=\labels@ve}
\def\@opargbegindisplay#1#2#3{%
    \items@ve=\itemindent \labels@ve=\labelsep
      \trivlist
      \global\@novspacefalse
      \itemindent \dispsep
      \item[{\@disphead \@dispcase{#1}\ #2\dispdot\ 
      (\@dispcase{#3})\/}]\@disptext
      \itemindent=\items@ve \labelsep=\labels@ve}
\def\@enddisplay{\endtrivlist}     
%    \end{macrocode}
%    \begin{macrocode}
\if@thms
  \newtheorem{thm}{THEOREM}
  \newtheorem{cor}[thm]{COROLLARY} 
  \newtheorem{lem}[thm]{LEMMA}
  \newtheorem{claim}[thm]{CLAIM}
  \newtheorem{conj}[thm]{CONJECTURE}
  \newtheorem{prop}[thm]{PROPOSITION}
  \newtheorem{exer}[thm]{EXERCISE}
  \newtheorem{REM}[thm]{REMARK}
  \newtheorem{prob}[thm]{PROBLEM}
  \newtheorem{alg}{ALGORITHM}
  \rmtheorem{alg}
  \newtheorem{defn}[thm]{DEFINITION}
  \rmtheorem{defn}
  \newtheorem{exmp}[thm]{EXAMPLE}
  \rmtheorem{exmp}
  \newdisplay{crit}{Criterion}
  \newdisplay{rem}{Remark}
  \newdisplay{Note}{Note}
  \newdisplay{summ}{Summary}
  \newdisplay{case}{Case}
\fi
\arraycolsep = 3pt
\@EndKlumathook
%</main>
%<*other>
\endinput
%    \end{macrocode}
% \IndexParms{\hbadness=10000}
%\PrintIndex
%\end{document}
% end of klumath.sty
%</other>