updated
[latex2e.git] / base / ltmath.dtx
blob420c7b287ffd2c1dcd1c6192f029f9fdfb912990
1 % \iffalse meta-comment
3 % Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009
4 % The LaTeX3 Project and any individual authors listed elsewhere
5 % in this file. 
6
7 % This file is part of the LaTeX base system.
8 % -------------------------------------------
9
10 % It may be distributed and/or modified under the
11 % conditions of the LaTeX Project Public License, either version 1.3c
12 % of this license or (at your option) any later version.
13 % The latest version of this license is in
14 %    http://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of LaTeX 
16 % version 2005/12/01 or later.
17
18 % This file has the LPPL maintenance status "maintained".
19
20 % The list of all files belonging to the LaTeX base distribution is
21 % given in the file `manifest.txt'. See also `legal.txt' for additional
22 % information.
23
24 % The list of derived (unpacked) files belonging to the distribution 
25 % and covered by LPPL is defined by the unpacking scripts (with 
26 % extension .ins) which are part of the distribution.
27
28 % \fi
29 % \iffalse
30 %%% From File: ltmath.dtx
32 %<leqno>\ProvidesFile{leqno.clo}
33 %<fleqn>\ProvidesFile{fleqn.clo}
34 %<leqno,fleqn>        [1998/08/17 v1.1c Standard LaTeX option
35 %<leqno>                                   (left equation numbers)]
36 %<fleqn>                                   (flush left equations)]
38 %<*driver>
39 % \fi
40 \ProvidesFile{ltmath.dtx}
41               [2005/11/10 v1.1g LaTeX Kernel (Math Setup)]
42 % \iffalse
43 %</driver>
45 %<*driver>
46 \documentclass{ltxdoc}
47 \GetFileInfo{ltmath.dtx}
48 \title{\filename}
49 \date{\filedate}
50 \author{%
51   Johannes Braams\and
52   David Carlisle\and
53   Alan Jeffrey\and
54   Leslie Lamport\and
55   Frank Mittelbach\and
56   Chris Rowley\and
57   Rainer Sch\"opf}
58 \begin{document}
59    \maketitle
60    \DocInput{\filename}
61 \end{document}
62 %</driver>
63 % \fi
65 % \CheckSum{1101}
67 % \changes{v1.1b}{1996/07/26}{Removed \cs{global} before
68 %     \cs{@ignoretrue} in various places.}
69 % \changes{v1.1c}{1998/08/17}{(RmS) Minor documentation fixes.}
70 % \changes{v1.1g}{2005/11/10}{(MH) Minor documentation fixes.}
71
72 % \section{Math setup}
74 % This file contains a lot of the original plain \TeX{} code, as well
75 % as the \LaTeX{} environments for math. It still needs sorting out.
77 % \StopEventually{}
79 %    \begin{macrocode}
80 %<*2ekernel>
81 \message{math definitions,}
82 %    \end{macrocode}
85 %% \CharacterTable
86 %%  {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
87 %%   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
88 %%   Digits        \0\1\2\3\4\5\6\7\8\9
89 %%   Exclamation   \!     Double quote  \"     Hash (number) \#
90 %%   Dollar        \$     Percent       \%     Ampersand     \&
91 %%   Acute accent  \'     Left paren    \(     Right paren   \)
92 %%   Asterisk      \*     Plus          \+     Comma         \,
93 %%   Minus         \-     Point         \.     Solidus       \/
94 %%   Colon         \:     Semicolon     \;     Less than     \<
95 %%   Equals        \=     Greater than  \>     Question mark \?
96 %%   Commercial at \@     Left bracket  \[     Backslash     \\
97 %%   Right bracket \]     Circumflex    \^     Underscore    \_
98 %%   Grave accent  \`     Left brace    \{     Vertical bar  \|
99 %%   Right brace   \}     Tilde         \~}
102 % \subsection{Math commands based on plain \TeX}
104 % \subsubsection{The log-like functions}
106 % \changes{1.0m}{1994/10/29}{ASAJ: Added \cs{DeclareMathOperator}.}
107 % \changes{v1.0o}{1994/11/17}
108 %         {\cs{@tempa} to \cs{reserved@a}}
109 % \changes{1.0q}{1994/11/30}{ASAJ: \cs{DeclareMathOperator} moved to
110 %    AMS\LaTeX.}
111 % \changes{v1.0r}{1995/05/07}{Use \cs{hb@xt@}}
112 % \changes{v1.0r}{1995/05/21}{Update some plain macros}
113 % \changes{v1.0t}{1995/06/28}{minor doc edits}
115 % \begin{macro}{\log}
116 % The standard operators:
117 %    \begin{macrocode}
118 \def\log{\mathop{\operator@font log}\nolimits}
119 \def\lg{\mathop{\operator@font lg}\nolimits}
120 \def\ln{\mathop{\operator@font ln}\nolimits}
121 \def\lim{\mathop{\operator@font lim}}
122 \def\limsup{\mathop{\operator@font lim\,sup}}
123 \def\liminf{\mathop{\operator@font lim\,inf}}
124 \def\sin{\mathop{\operator@font sin}\nolimits}
125 \def\arcsin{\mathop{\operator@font arcsin}\nolimits}
126 \def\sinh{\mathop{\operator@font sinh}\nolimits}
127 \def\cos{\mathop{\operator@font cos}\nolimits}
128 \def\arccos{\mathop{\operator@font arccos}\nolimits}
129 \def\cosh{\mathop{\operator@font cosh}\nolimits}
130 \def\tan{\mathop{\operator@font tan}\nolimits}
131 \def\arctan{\mathop{\operator@font arctan}\nolimits}
132 \def\tanh{\mathop{\operator@font tanh}\nolimits}
133 \def\cot{\mathop{\operator@font cot}\nolimits}
134 \def\coth{\mathop{\operator@font coth}\nolimits}
135 \def\sec{\mathop{\operator@font sec}\nolimits}
136 \def\csc{\mathop{\operator@font csc}\nolimits}
137 \def\max{\mathop{\operator@font max}}
138 \def\min{\mathop{\operator@font min}}
139 \def\sup{\mathop{\operator@font sup}}
140 \def\inf{\mathop{\operator@font inf}}
141 \def\arg{\mathop{\operator@font arg}\nolimits}
142 \def\ker{\mathop{\operator@font ker}\nolimits}
143 \def\dim{\mathop{\operator@font dim}\nolimits}
144 \def\hom{\mathop{\operator@font hom}\nolimits}
145 \def\det{\mathop{\operator@font det}}
146 \def\exp{\mathop{\operator@font exp}\nolimits}
147 \def\Pr{\mathop{\operator@font Pr}}
148 \def\gcd{\mathop{\operator@font gcd}}
149 \def\deg{\mathop{\operator@font deg}\nolimits}
150 %    \end{macrocode}
151 % \end{macro}
153 % \begin{macro}{\bmod}
154 % And some operators have to be done by hand:
155 %    \begin{macrocode}
156 \def\bmod{%
157   \nonscript\mskip-\medmuskip\mkern5mu%
158   \mathbin{\operator@font mod}\penalty900\mkern5mu%
159   \nonscript\mskip-\medmuskip}
160 %    \end{macrocode}
161 % \end{macro}
163 % \begin{macro}{\pmod}
164 %    \begin{macrocode}
165 \def\pmod#1{%
166   \allowbreak\mkern18mu({\operator@font mod}\,\,#1)}
167 %    \end{macrocode}
168 % \end{macro}
170 % \subsubsection{Biggggg}
172 % \begin{macro}{\big}
173 % Variants on |\big| and friends for use with delimiters:
174 %    \begin{macrocode}
175 \def\bigl{\mathopen\big}
176 \def\bigm{\mathrel\big}
177 \def\bigr{\mathclose\big}
178 \def\Bigl{\mathopen\Big}
179 \def\Bigm{\mathrel\Big}
180 \def\Bigr{\mathclose\Big}
181 \def\biggl{\mathopen\bigg}
182 \def\biggm{\mathrel\bigg}
183 \def\biggr{\mathclose\bigg}
184 \def\Biggl{\mathopen\Bigg}
185 \def\Biggm{\mathrel\Bigg}
186 \def\Biggr{\mathclose\Bigg}
187 %    \end{macrocode}
188 % \end{macro}
190 % \subsubsection{The UNSORTED Rest}
192 % The other math commands are lifted from plain \TeX.
194 % \begin{macro}{\jot}
195 %    \begin{macrocode}
196 \newdimen\jot
197 \jot=3pt
198 %    \end{macrocode}
199 % \end{macro}
201 % \begin{macro}{\interdisplaylinepenalty}
202 %    \begin{macrocode}
203 \newcount\interdisplaylinepenalty
204 \interdisplaylinepenalty=100
205 %    \end{macrocode}
206 % \end{macro}
208 % \begin{macro}{\choose}
209 %    \begin{macrocode}
210 \def\choose{\atopwithdelims()}
211 %    \end{macrocode}
212 % \end{macro}
214 % \begin{macro}{\brack}
215 %    \begin{macrocode}
216 \def\brack{\atopwithdelims[]}
217 %    \end{macrocode}
218 % \end{macro}
220 % \begin{macro}{\brace}
221 %    \begin{macrocode}
222 \def\brace{\atopwithdelims\{\}}
223 %    \end{macrocode}
224 % \end{macro}
226 % \begin{macro}{\mathpalette}
227 %    \begin{macrocode}
228 \def\mathpalette#1#2{%
229   \mathchoice
230     {#1\displaystyle{#2}}%
231     {#1\textstyle{#2}}%
232     {#1\scriptstyle{#2}}%
233     {#1\scriptscriptstyle{#2}}}
234 %    \end{macrocode}
235 % \end{macro}
237 % \begin{macro}{\root}
238 % \changes{v1.1d}{1997/01/08}
239 %      {(DPC) Remove spurious space tokens from
240 %              plain \TeX\ definition /2359}
241 % \begin{macro}{\rootbox}
242 % \begin{macro}{\r@@t}
243 % \changes{v1.0r}{1995/05/21}{Use \cs{sqrtsign} instead of
244 %                             \cs{sqrt}}
245 %    \begin{macrocode}
246 \newbox\rootbox
247 %    \end{macrocode}
249 %    \begin{macrocode}
250 \def\root#1\of{%
251   \setbox\rootbox\hbox{$\m@th\scriptscriptstyle{#1}$}%
252   \mathpalette\r@@t}
253 %    \end{macrocode}
255 %    \begin{macrocode}
256 \def\r@@t#1#2{%
257   \setbox\z@\hbox{$\m@th#1\sqrtsign{#2}$}%
258   \dimen@\ht\z@ \advance\dimen@-\dp\z@
259   \mkern5mu\raise.6\dimen@\copy\rootbox
260   \mkern-10mu\box\z@}
261 %    \end{macrocode}
262 % \end{macro}
263 % \end{macro}
264 % \end{macro}
266 % \begin{macro}{\phantom}
267 % \changes{v1.0p}{1994/11/18}
268 %         {(DPC) use \cs{expandafter} instead of \cs{next}}
269 % \changes{v1.0p}{1994/11/18}
270 %         {(DPC) colour support}
271 % \begin{macro}{\hphantom}
272 % \begin{macro}{\vphantom}
273 %    \begin{macrocode}
274 \newif\ifv@
275 \newif\ifh@
276 %    \end{macrocode}
278 %    \begin{macrocode}
279 \def\vphantom{\v@true\h@false\ph@nt}
280 %    \end{macrocode}
282 %    \begin{macrocode}
283 \def\hphantom{\v@false\h@true\ph@nt}
284 %    \end{macrocode}
286 %    \begin{macrocode}
287 \def\phantom{\v@true\h@true\ph@nt}
288 %    \end{macrocode}
290 %    \begin{macrocode}
291 \def\ph@nt{%
292   \ifmmode
293     \expandafter\mathpalette\expandafter\mathph@nt
294   \else
295     \expandafter\makeph@nt
296   \fi}
297 %    \end{macrocode}
299 %    \begin{macrocode}
300 \def\makeph@nt#1{%
301   \setbox\z@\hbox{\color@begingroup#1\color@endgroup}\finph@nt}
302 %    \end{macrocode}
304 %    \begin{macrocode}
305 \def\mathph@nt#1#2{%
306   \setbox\z@\hbox{$\m@th#1{#2}$}\finph@nt}
307 %    \end{macrocode}
309 %    \begin{macrocode}
310 \def\finph@nt{%
311   \setbox\tw@\null
312   \ifv@ \ht\tw@\ht\z@ \dp\tw@\dp\z@\fi
313   \ifh@ \wd\tw@\wd\z@\fi \box\tw@}
314 %    \end{macrocode}
315 % \end{macro}
316 % \end{macro}
317 % \end{macro}
319 % \begin{macro}{\mathstrut}
320 %    \begin{macrocode}
321 \def\mathstrut{\vphantom(}
322 %    \end{macrocode}
323 % \end{macro}
325 % \begin{macro}{\smash}
326 % \changes{v1.0p}{1994/11/18}
327 %         {(DPC) use \cs{expandafter} instead of \cs{next}}
328 % \changes{v1.0p}{1994/11/18}
329 %         {(DPC) colour support}
330 %    \begin{macrocode}
331 \def\smash{%
332   \relax % \relax, in case this comes first in \halign
333   \ifmmode
334     \expandafter\mathpalette\expandafter\mathsm@sh
335   \else
336     \expandafter\makesm@sh
337   \fi}
338 %    \end{macrocode}
340 %    \begin{macrocode}
341 \def\makesm@sh#1{%
342   \setbox\z@\hbox{\color@begingroup#1\color@endgroup}\finsm@sh}
343 \def\mathsm@sh#1#2{%
344   \setbox\z@\hbox{$\m@th#1{#2}$}\finsm@sh}
345 \def\finsm@sh{\ht\z@\z@ \dp\z@\z@ \box\z@}
346 %    \end{macrocode}
347 % \end{macro}
349 % \begin{macro}{\buildrel}
350 %    \begin{macrocode}
351 \def\buildrel#1\over#2{\mathrel{\mathop{\kern\z@#2}\limits^{#1}}}
352 %    \end{macrocode}
353 % \end{macro}
356 % \begin{macro}{\cases}
357 % \changes{LaTeX2.09}{1991/08/14}
358 %         {(RmS) inserted extra braces around entry for NFSS}
359 %    \begin{macrocode}
360 \def\cases#1{\left\{\,\vcenter{\normalbaselines\m@th
361     \ialign{$##\hfil$&\quad{##}\hfil\crcr#1\crcr}}\right.}
362 %    \end{macrocode}
363 % \end{macro}
365 % \begin{macro}{\matrix}
366 %    \begin{macrocode}
367 \def\matrix#1{\null\,\vcenter{\normalbaselines\m@th
368     \ialign{\hfil$##$\hfil&&\quad\hfil$##$\hfil\crcr
369       \mathstrut\crcr\noalign{\kern-\baselineskip}
370       #1\crcr\mathstrut\crcr\noalign{\kern-\baselineskip}}}\,}
371 %    \end{macrocode}
372 % \end{macro}
374 % \begin{macro}{\pmatrix}
375 %    \begin{macrocode}
376 \def\pmatrix#1{\left(\matrix{#1}\right)}
377 %    \end{macrocode}
378 % \end{macro}
381 % \begin{macro}{\bordermatrix}
382 % \changes{LaTeX2e}{1994/01/25}{Removed \cs{p@renwd}.}
383 %    \begin{macrocode}
384 \def\bordermatrix#1{\begingroup \m@th
385   \@tempdima 8.75\p@
386   \setbox\z@\vbox{%
387     \def\cr{\crcr\noalign{\kern2\p@\global\let\cr\endline}}%
388     \ialign{$##$\hfil\kern2\p@\kern\@tempdima&\thinspace\hfil$##$\hfil
389       &&\quad\hfil$##$\hfil\crcr
390       \omit\strut\hfil\crcr\noalign{\kern-\baselineskip}%
391       #1\crcr\omit\strut\cr}}%
392   \setbox\tw@\vbox{\unvcopy\z@\global\setbox\@ne\lastbox}%
393   \setbox\tw@\hbox{\unhbox\@ne\unskip\global\setbox\@ne\lastbox}%
394   \setbox\tw@\hbox{$\kern\wd\@ne\kern-\@tempdima\left(\kern-\wd\@ne
395     \global\setbox\@ne\vbox{\box\@ne\kern2\p@}%
396     \vcenter{\kern-\ht\@ne\unvbox\z@\kern-\baselineskip}\,\right)$}%
397   \null\;\vbox{\kern\ht\@ne\box\tw@}\endgroup}
398 %    \end{macrocode}
399 % \end{macro}
401 % \begin{macro}{\openup}
402 %    \begin{macrocode}
403 \def\openup{\afterassignment\@penup\dimen@}
404 %    \end{macrocode}
406 %    \begin{macrocode}
407 \def\@penup{\advance\lineskip\dimen@
408   \advance\baselineskip\dimen@
409   \advance\lineskiplimit\dimen@}
410 %    \end{macrocode}
411 % \end{macro}
413 % \begin{macro}{\displaylines}
414 %    \begin{macrocode}
415 \newif\ifdt@p
416 %    \end{macrocode}
418 %    \begin{macrocode}
419 \def\displ@y{\global\dt@ptrue\openup\jot\m@th
420   \everycr{\noalign{\ifdt@p \global\dt@pfalse \ifdim\prevdepth>-1000\p@
421       \vskip-\lineskiplimit \vskip\normallineskiplimit \fi
422       \else \penalty\interdisplaylinepenalty \fi}}}
423 %    \end{macrocode}
425 %    \begin{macrocode}
426 \def\@lign{\tabskip\z@skip\everycr{}} % restore inside \displ@y
427 %    \end{macrocode}
429 %    \begin{macrocode}
430 \def\displaylines#1{\displ@y \tabskip\z@skip
431   \halign{\hb@xt@\displaywidth{$\@lign\hfil\displaystyle##\hfil$}\crcr
432     #1\crcr}}
433 %    \end{macrocode}
434 % \end{macro}
436 % \changes{v1.0r}{1995/05/21}{Remove \cs{mathhexbox} from this file}
438 % \begin{macro}{\sp}
439 % \begin{macro}{\sb}
440 %    \begin{macrocode}
441 \let\sp=^
442 \let\sb=_
443 %    \end{macrocode}
444 % \end{macro}
445 % \end{macro}
447 % \begin{macro}{\>}
448 % \begin{macro}{\;}
449 % \begin{macro}{\!}
450 %    \begin{macrocode}
451 %\def\,{\mskip\thinmuskip}      % already defined in ltspace
452 \def\>{\mskip\medmuskip}
453 \def\;{\mskip\thickmuskip}
454 \def\!{\mskip-\thinmuskip}
455 %    \end{macrocode}
456 % \end{macro}
457 % \end{macro}
458 % \end{macro}
460 % \begin{macro}{\*}
461 %    \begin{macrocode}
462 \def\*{\discretionary{\thinspace\the\textfont2\char2}{}{}}
463 %    \end{macrocode}
464 % \end{macro}
466 % \begin{macro}{\:}
467 %    Nickname for the medium space since |\>| is not available inside
468 %    \texttt{tabbing}.
469 %    \begin{macrocode}
470 \let\:=\>
471 %    \end{macrocode}
472 % \end{macro}
474 % \begin{macro}{\active@math@prime}
475 % \changes{v1.1e}{1999/10/09}{Macro added, see PR 3104.}
476 %    This is the definition of the active math prime.
477 %    \begin{macrocode}
478 \def\active@math@prime{^\bgroup\prim@s}
479 %    \end{macrocode}
480 % \end{macro}
482 % \begin{macro}{\prime@s}
483 % \changes{v1.0p}{1994/11/18}
484 %         {(DPC) use \cs{@let@token} instead of \cs{next}
485 %           and \cs{expandafter} instead of \cs{nxt}}
486 % \changes{v1.1e}{1999/10/09}{Introduce \cs{active@math@prime}.}
487 %    \begin{macrocode}
488 {\catcode`\'=\active \global\let'\active@math@prime}
489 %    \end{macrocode}
491 %    \begin{macrocode}
492 \def\prim@s{%
493   \prime\futurelet\@let@token\pr@m@s}
494 %    \end{macrocode}
496 %    \begin{macrocode}
497 \def\pr@m@s{%
498   \ifx'\@let@token
499     \expandafter\pr@@@s
500   \else
501     \ifx^\@let@token
502       \expandafter\expandafter\expandafter\pr@@@t
503     \else
504       \egroup
505     \fi
506   \fi}
507 %    \end{macrocode}
509 %    \begin{macrocode}
510 \def\pr@@@s#1{\prim@s}
511 %    \end{macrocode}
513 %    \begin{macrocode}
514 \def\pr@@@t#1#2{#2\egroup}
515 %    \end{macrocode}
516 % \end{macro}
518 % \changes{v1.0i}{1994/05/17}{Replaced \cs{let} by \cs{gdef}, for
519 %            indirect definition.}
520 %    \begin{macrocode}
521 {\catcode`\_=\active \gdef_{\_}} % _ in math is
522                                  % either subscript or \_
523 %    \end{macrocode}
526 % \changes{v1.0m}{1994/10/29}{ASAJ: Removed \cs{dag}, \cs{ddag}.}
527 % \changes{v1.0m}{1994/10/29}{ASAJ: Renamed \cs{S} and \cs{P} to 
528 %    \cs{mathsection} and \cs{mathparagraph} and made them 
529 %    \cs{mathchardef}s.} 
530 % \changes{v1.0m}{1994/10/29}{ASAJ: Added \cs{mathellipsis}, 
531 %    \cs{mathdollar} and \cs{mathsterling}.}
532 % \changes{v1.0n}{1994/10/30}{ASAJ: Moved the new commands to ltoutenc.}
534 % \subsection{Math Environments}
536 % \changes{1.0m}{1994/10/29}{ASAJ: Tidied up documentation.}
538 % \begin{macro}{\(}
539 % \begin{macro}{\)}
540 %    Produces |$...$| with checks that |\(| isn't used in math mode, and
541 %    that |\)| is only used in math mode begun with |\(|.
542 %    \begin{macrocode}
543 \def\({\relax\ifmmode\@badmath\else$\fi}
544 \def\){\relax\ifmmode\ifinner$\else\@badmath\fi\else \@badmath\fi}
545 %    \end{macrocode}
546 % \end{macro}
547 % \end{macro}
549 % \begin{macro}{\[}
550 % \changes{v1.1g}{2005/11/10}
551 %                {(MH) Fixed potential problem in \cs{[} (pr/3399).}
552 % \begin{macro}{\]}
553 %    Produces |$$...$$| with checks that |\[| isn't used in math mode, 
554 %    and that |\]| is only used in math mode begun with |\]|.
555 %    \begin{macrocode}
556 \def\[{%
557    \relax\ifmmode
558       \@badmath
559    \else
560       \ifvmode
561          \nointerlineskip 
562          \makebox[.6\linewidth]{}%
563       \fi
564       $$%%$$ BRACE MATCH HACK
565    \fi
567 %    \end{macrocode}
569 %    \begin{macrocode}
570 \def\]{%
571    \relax\ifmmode
572       \ifinner
573          \@badmath
574       \else
575          $$%%$$ BRACE MATCH HACK
576       \fi
577    \else
578       \@badmath 
579    \fi
580    \ignorespaces
582 %    \end{macrocode}
583 % \end{macro}
584 % \end{macro}
586 % \begin{environment}{math}
587 % \begin{environment}{displaymath}
588 %    Disguises for |\(...\)| and |\[...\]|.
589 %    \begin{macrocode}
590 \let\math=\(
591 \let\endmath=\)
592 %    \end{macrocode}
594 %    \begin{macrocode}
595 \def\displaymath{\[}
596 \def\enddisplaymath{\]\@ignoretrue}
597 %    \end{macrocode}
598 % \end{environment}
599 % \end{environment}
602 % \begin{environment}{equation}
603 % \changes{LaTeX2.09}{1992/01/10}{RmS: put \cs{hbox} around \cs{@eqnnum}
604 %    to typeset the equation number in text mode 
605 %    (as in the eqnarray env.)}
606 % \begin{macro}{\c@equation}
607 %  Numbered equations, using the counter |\c@equation|.
608 %  \emph{Note}: The document style must define |\theequation| etc., and
609 %  do the appropriate |\@addtoreset|. It should also redefine |\@eqnnum|
610 %  if another format for the equation number is desired other than the
611 %  standard (...), or to move the equation numbers to the flushleft.
612 %   (See comment on the |\def| of |\@eqnnum|.)
613 %    \begin{macrocode}
614 \@definecounter{equation}
615 \def\equation{$$\refstepcounter{equation}}
616 \def\endequation{\eqno \hbox{\@eqnnum}$$\@ignoretrue}
617 %    \end{macrocode}
618 % \end{macro}
619 % \end{environment}
621 % \begin{macro}{\@eqnnum}
622 % \changes{LaTeX2.09}{1991/09/29}{RmS: \cs{reset@font} added.}
623 % \changes{v1.0l}{1994/10/23}{Added \cs{normalcolor} since \cs{eqno}
624 %    introduces a subgroup of the displayed math group}
626 %     Produces the equation number for equation and
627 %     eqnarray environments.  The following definition is for
628 %     flushright numbers; for flushleft numbers, see leqno.clo.
629 %     The equation number is set in black roman type even
630 %     if an eqnarray environment appears in an italic environment.
631 % \changes{v1.0s}{1995/05/26}{Removed \cs{rmfamily} (PR 1578),
632 % replaced \cs{reset@font} with \cs{normalfont}}
633 %    \begin{macrocode}
634 \def\@eqnnum{{\normalfont \normalcolor (\theequation)}}
635 %    \end{macrocode}
636 % \end{macro}
638 % \begin{macro}{\stackrel}
639 %    A disguise for plain \TeX's buildrel.
640 %    \begin{macrocode}
641 \def\stackrel#1#2{\mathrel{\mathop{#2}\limits^{#1}}}
642 %    \end{macrocode}
643 % \end{macro}
645 %  \changes{v0.9g}{1993/12/11}{Added a group around the first argument
646 %    of \cs{frac} to prevent
647 %    changes (for example font changes) from modifying the contents of
648 %     the second argument.}
650 %  \begin{macro}{\frac}
651 %    A disguise for plain \TeX's |\over|.
652 %    \begin{macrocode}
653 \def\frac#1#2{{\begingroup#1\endgroup\over#2}}
654 %    \end{macrocode}
655 %  \end{macro}
657 % \begin{macro}{\sqrt}
658 % \changes{v1.0y}{1995/10/16}{(DPC) Make robust /1808}
659 % \begin{macro}{\@sqrt}
660 %    Add an optional argument to plain's |\sqrt| to give the $n$th root 
661 %    of an expression $\sqrt[n]{e}$.
662 % \changes{v1.0r}{1995/05/21}{Use \cs{sqrtsign}}
663 %    \begin{macrocode}
664 \DeclareRobustCommand\sqrt{\@ifnextchar[\@sqrt\sqrtsign}
665 \def\@sqrt[#1]{\root #1\of}
666 %    \end{macrocode}
667 % \end{macro}
668 % \end{macro}
670 % \changes{LaTeX2.09}{1985/11/04}{produce warning message if line
671 %      extends into margin.  Doesn't warn about formula
672 %      overprinting equation number.}
673 % \changes{LaTeX2.09}{1993/11/02}{RmS: 
674 %        Corrected description of \cs{@eqnsel}, moved \cs{@eqnsel}
675 %        accordingly and removed extra \cs{tabskip} assignment.}
676 % \changes{LaTeX2e}{1993/11/03}{RmS: Initialized \cs{everycr} to empty}
677 % \changes{v0.9i}{1993/12/16}
678 %     {use \cs{refstepcounter} instead of shortcut}
679 % \changes{v0.9o}{1994/01/13}{correcting 0.9i}
681 % \begin{environment}{eqnarray}
682 % \begin{macro}{\@eqcnt}
683 % \begin{macro}{\@eqpen}
684 % \begin{macro}{\if@eqnsw}
685 % \begin{macro}{\@eqnsel}
686 %    Here's the eqnarray environment:
687 %    Default is for left-hand side of equations to be flushright.
688 %    To make them flushleft, |\let\@eqnsel = \hfil|.
689 %    \begin{macrocode}
690 \newcount\@eqcnt
691 \newcount\@eqpen
692 \newif\if@eqnsw\@eqnswtrue
693 \newskip\@centering
694 \@centering = 0pt plus 1000pt
695 %    \end{macrocode}
696 %    To get a proper \cs{@currentlabel} we have to redefine it for the
697 %    whole display. Note that we can't use \cs{refstepcounter} as this
698 %    results in |\@currentlabel| getting restored at the wrong and
699 %    thus always writing the first label to the \texttt{.aux} file.
700 %    \begin{macrocode}
701 \def\eqnarray{%
702    \stepcounter{equation}%
703    \def\@currentlabel{\p@equation\theequation}%
704    \global\@eqnswtrue
705    \m@th
706    \global\@eqcnt\z@
707    \tabskip\@centering
708    \let\\\@eqncr
709    $$\everycr{}\halign to\displaywidth\bgroup
710        \hskip\@centering$\displaystyle\tabskip\z@skip{##}$\@eqnsel
711       &\global\@eqcnt\@ne\hskip \tw@\arraycolsep \hfil${##}$\hfil
712       &\global\@eqcnt\tw@ \hskip \tw@\arraycolsep 
713          $\displaystyle{##}$\hfil\tabskip\@centering
714       &\global\@eqcnt\thr@@ \hb@xt@\z@\bgroup\hss##\egroup
715          \tabskip\z@skip
716       \cr
718 %    \end{macrocode}
720 %    \begin{macrocode}
721 \def\endeqnarray{%
722       \@@eqncr
723       \egroup
724       \global\advance\c@equation\m@ne
725    $$\@ignoretrue
727 %    \end{macrocode}
729 %    \begin{macrocode}
730 \let\@eqnsel=\relax
731 %    \end{macrocode}
732 % \end{macro}
733 % \end{macro}
734 % \end{macro}
735 % \end{macro}
736 % \end{environment}
738 % \begin{macro}{\nonumber}
739 %    Switches off equation numbering.
740 %    \begin{macrocode}
741 \def\nonumber{\global\@eqnswfalse}
742 %    \end{macrocode}
743 % \end{macro}
745 % \begin{macro}{\@eqncr}
746 % \begin{macro}{\@xeqncr}
747 % \begin{macro}{\@yeqncr}
748 % \changes{v1.0y}{1995/10/16}{(DPC) Use \cs{@testopt} /1911}
749 %    \begin{macrocode}
750 \def\@eqncr{%
751    {\ifnum0=`}\fi
752    \@ifstar{%
753       \global\@eqpen\@M\@yeqncr
754    }{%
755       \global\@eqpen\interdisplaylinepenalty \@yeqncr
756    }%
758 %    \end{macrocode}
760 %    \begin{macrocode}
761 \def\@yeqncr{\@testopt\@xeqncr\z@skip}
762 %    \end{macrocode}
764 %    \begin{macrocode}
765 \def\@xeqncr[#1]{%
766    \ifnum0=`{\fi}%
767    \@@eqncr
768    \noalign{\penalty\@eqpen\vskip\jot\vskip #1\relax}%
770 %    \end{macrocode}
772 % \end{macro}
773 % \end{macro}
774 % \end{macro}
776 %  \begin{macro}{\@@eqncr}
777 % \changes{v0.9i}{1993/12/16}{use \cs{refstepcounter} instead of shortcut}
778 % \changes{v0.9o}{1994/01/13}{correcting 0.9i}
780 %    \begin{macrocode}
781 \def\@@eqncr{\let\reserved@a\relax
782     \ifcase\@eqcnt \def\reserved@a{& & &}\or \def\reserved@a{& &}%
783      \or \def\reserved@a{&}\else
784        \let\reserved@a\@empty
785        \@latex@error{Too many columns in eqnarray environment}\@ehc\fi
786      \reserved@a \if@eqnsw\@eqnnum\stepcounter{equation}\fi
787      \global\@eqnswtrue\global\@eqcnt\z@\cr}
788 %    \end{macrocode}
789 %  \end{macro}
791 % \begin{environment}{eqnarray*}
792 % \begin{macro}{\@seqncr}
793 %    Here's the eqnarray* environment:
794 %    \begin{macrocode}
795 \let\@seqncr=\@eqncr
796 %    \end{macrocode}
798 %    \begin{macrocode}
799 \@namedef{eqnarray*}{\def\@eqncr{\nonumber\@seqncr}\eqnarray}
800 %    \end{macrocode}
802 %    \begin{macrocode}
803 \@namedef{endeqnarray*}{\nonumber\endeqnarray}
804 %    \end{macrocode}
805 % \end{macro}
806 % \end{environment}
808 % \begin{macro}{\lefteqn}
809 %  |\lefteqn{FORMULA}| typesets |FORMULA| in display math style
810 %  flushleft in a box of width zero.
811 % \changes{v1.0r}{1995/05/21}{Use \cs{rlap}}
812 %    \begin{macrocode}
813 \def\lefteqn#1{\rlap{$\displaystyle #1$}}
814 %    \end{macrocode}
815 % \end{macro}
817 % \begin{macro}{\ensuremath}
818 %   In math mode, |\ensuremath{text}| is equivalent to text; in LR or
819 %   paragraph mode, it is equivalent to |$|text|$|. 
820 %   |\relax| is not needed
821 %   in front of the |\ifmmode| as |\protect| will be |\let| to |\relax|.
822 %   This version (due to Donald Arseneau) avoids duplicating its
823 %   argument in the `then' and `else' part of the |\ifmath| which is
824 %   necessary in nested  `tabular' like environments. See amslatex/2104.
825 % \changes{v1.0k}{1994/05/16}
826 %     {Use \cs{DeclareRobustCommand} and add extra braces in math mode}
827 % \changes{v1.0l}{1994/10/23}{Remove extra braces: but see p 168 of
828 %      Leslie's book}
829 % \changes{v1.1a}{1996/03/25}{Reimplement for amslatex/2104}
830 %    \begin{macrocode}
831 \DeclareRobustCommand{\ensuremath}{% 
832   \ifmmode
833     \expandafter\@firstofone
834   \else
835     \expandafter\@ensuredmath 
836   \fi}
837 %    \end{macrocode}
838 % \end{macro}
840 % \begin{macro}{\@ensuredmath}
841 % \changes{v1.1a}{1996/03/25}{Macro added for amslatex/2104}
842 % \changes{v1.1c}{1996/11/09}{Made long, as it was before. /2104}
843 % The |\relax| stops |\ensuremath{}| starting display math.
844 %    \begin{macrocode}
845 \long\def\@ensuredmath#1{$\relax#1$}
846 %    \end{macrocode}
847 % \end{macro}
849 %    \begin{macrocode}
850 %</2ekernel>
851 %    \end{macrocode}
855 % \subsection{External options to the standard document classes}
857 % \changes{v1.0u}{1995/08/09}
858 %    {Added code for class options leqno and fleqn}
860 % \subsubsection{Left equation numbering}
862 %  \begin{macro}{\@eqnnum}
863 %    To put the equation number on the left side of an equation we
864 %    have to use a little trick. The number is shifted |\displaywidth|
865 %    to the left inside a box of (approximately) zero width. This
866 %    fails when the quation is too wide, the equation number than may
867 %    overprint the equation itself.
868 % \changes{v1.2y classes}{1995/01/12}{Added \cs{normalcolor}}
869 % \changes{v1.3c classes}{1995/05/25}
870 %    {replace \cs{reset@font}\cs{rmfamily} with \cs{normalfont}
871 %      (PR 1578)}
872 %    \begin{macrocode}
873 %<*leqno>
874 \renewcommand\@eqnnum{\hb@xt@.01\p@{}%
875                       \rlap{\normalfont\normalcolor
876                         \hskip -\displaywidth(\theequation)}}
877 %</leqno>
878 %    \end{macrocode}
879 %  \end{macro}
881 % \subsubsection{Flush left equations}
883 %    To get the displayed math environments to print the contents
884 %    flush left (with an indentation) we have to redefine all of
885 %    \LaTeXe's displayed math environments. 
887 %  \begin{macro}{\mathindent}
888 %    The amount of indentation of the equations is stored in a register.
889 %    \begin{macrocode}
890 %<*fleqn>
891 \newdimen\mathindent
892 %    \end{macrocode}
893 %    The setting of |\mathindent| has to be deferred until the class
894 %    file has been processed, because |\leftmargini| is still 0pt
895 %    wide at the moment \texttt{fleqn.clo} is read in.
896 % \changes{v1.0n classes}
897 %    {1994/01/19}{Deferred setting of \cs{mathindent}}
898 % \changes{v1.2t classes}
899 %    {1994/06/22}{Set \cs{mathindent} at the end of the
900 %    class instead of at begin document}
901 %    \begin{macrocode}
902 \AtEndOfClass{\mathindent\leftmargini}
903 %    \end{macrocode}
904 % \end{macro}
906 %  \begin{macro}{\[}
907 %    Begin display math;
908 %    \begin{macrocode}
909 \renewcommand\[{\relax
910                 \ifmmode\@badmath
911                 \else
912                   \begin{trivlist}%
913                     \@beginparpenalty\predisplaypenalty
914                     \@endparpenalty\postdisplaypenalty
915                     \item[]\leavevmode
916                     \hb@xt@\linewidth\bgroup $\m@th\displaystyle %$
917                       \hskip\mathindent\bgroup
918                 \fi}
919 %    \end{macrocode}
920 % \end{macro}
922 %  \begin{macro}{\]}
923 %    end display math;
924 %    \begin{macrocode}
925 \renewcommand\]{\relax
926                 \ifmmode
927                       \egroup $\hfil% $
928                     \egroup
929                   \end{trivlist}%
930                 \else \@badmath
931                 \fi}
932 %    \end{macrocode}
933 % \end{macro}
935 %  \begin{environment}{equation}
936 %    The \textsf{equation} environment
937 %    \begin{macrocode}
938 \renewenvironment{equation}%
939     {\@beginparpenalty\predisplaypenalty
940      \@endparpenalty\postdisplaypenalty
941      \refstepcounter{equation}%
942      \trivlist \item[]\leavevmode
943        \hb@xt@\linewidth\bgroup $\m@th% $
944          \displaystyle
945          \hskip\mathindent}%
946         {$\hfil % $
947          \displaywidth\linewidth\hbox{\@eqnnum}%
948        \egroup
949      \endtrivlist}
950 %    \end{macrocode}
951 % \end{environment}
953 % \begin{environment}{eqnarray}
954 %    The \textsf{eqnarray} environment
955 %    \begin{macrocode}
956 \renewenvironment{eqnarray}{%
957     \stepcounter{equation}%
958     \def\@currentlabel{\p@equation\theequation}%
959     \global\@eqnswtrue\m@th
960     \global\@eqcnt\z@
961     \tabskip\mathindent
962     \let\\=\@eqncr
963     \setlength\abovedisplayskip{\topsep}%
964     \ifvmode
965       \addtolength\abovedisplayskip{\partopsep}%
966     \fi
967 %    \end{macrocode}
968 %    When the documentclass uses a non-zero |\parskip| setting the
969 %    |\topsep| might have a negative value to compensate for
970 %    that. Therefore we add |\parskip| to |\abovedisplayskip|.
971 % \changes{v1.2v classes}{1994/11/10}{Added value of \cs{parskip} to
972 %    \cs{abovedisplayskip} to compensate for negative \cs{topsep}}
973 %    \begin{macrocode}
974     \addtolength\abovedisplayskip{\parskip}%
975     \setlength\belowdisplayskip{\abovedisplayskip}%
976     \setlength\belowdisplayshortskip{\abovedisplayskip}%
977     \setlength\abovedisplayshortskip{\abovedisplayskip}%
978     $$\everycr{}\halign to\linewidth% $$
979     \bgroup
980       \hskip\@centering
981       $\displaystyle\tabskip\z@skip{##}$\@eqnsel&%
982       \global\@eqcnt\@ne \hskip \tw@\arraycolsep \hfil${##}$\hfil&%
983       \global\@eqcnt\tw@ \hskip \tw@\arraycolsep
984         $\displaystyle{##}$\hfil \tabskip\@centering&%
985       \global\@eqcnt\thr@@
986         \hb@xt@\z@\bgroup\hss##\egroup\tabskip\z@skip\cr}%
987       {\@@eqncr
988     \egroup
989     \global\advance\c@equation\m@ne$$% $$
990     \@ignoretrue
991     }
992 %</fleqn>
993 %    \end{macrocode}
994 % \end{environment}
998 % \Finale