1 % \iffalse meta-comment
4 % The LaTeX3 Project and any individual authors listed elsewhere
7 % This file is part of the LaTeX base system.
8 % -------------------------------------------
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.
18 % This file has the LPPL maintenance status "maintained".
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
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.
30 %%% From File: ltmath.dtx
32 %<leqno>\ProvidesFile{leqno.clo}
33 %<fleqn>\ProvidesFile{fleqn.clo}
34 %<leqno,fleqn> [2016/12/29 v1.2a Standard LaTeX option
35 %<leqno> (left equation numbers)]
36 %<fleqn> (flush left equations)]
40 \ProvidesFile{ltmath.dtx}
41 [2016/12/29 v1.2a LaTeX Kernel (Math Setup)]
46 \documentclass{ltxdoc}
47 \GetFileInfo{ltmath.dtx}
59 \MaintainedByLaTeXTeam{latex}
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.}
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.
81 \message{math definitions,}
86 % \subsection{Math commands based on plain \TeX}
88 % \subsubsection{The log-like functions}
90 % \changes{1.0m}{1994/10/29}{ASAJ: Added \cs{DeclareMathOperator}.}
91 % \changes{v1.0o}{1994/11/17}
92 % {\cs{@tempa} to \cs{reserved@a}}
93 % \changes{1.0q}{1994/11/30}{ASAJ: \cs{DeclareMathOperator} moved to
95 % \changes{v1.0r}{1995/05/07}{Use \cs{hb@xt@}}
96 % \changes{v1.0r}{1995/05/21}{Update some plain macros}
97 % \changes{v1.0t}{1995/06/28}{minor doc edits}
100 % The standard operators:
102 \def\log{\mathop{\operator@font log}\nolimits}
103 \def\lg{\mathop{\operator@font lg}\nolimits}
104 \def\ln{\mathop{\operator@font ln}\nolimits}
105 \def\lim{\mathop{\operator@font lim}}
106 \def\limsup{\mathop{\operator@font lim\,sup}}
107 \def\liminf{\mathop{\operator@font lim\,inf}}
108 \def\sin{\mathop{\operator@font sin}\nolimits}
109 \def\arcsin{\mathop{\operator@font arcsin}\nolimits}
110 \def\sinh{\mathop{\operator@font sinh}\nolimits}
111 \def\cos{\mathop{\operator@font cos}\nolimits}
112 \def\arccos{\mathop{\operator@font arccos}\nolimits}
113 \def\cosh{\mathop{\operator@font cosh}\nolimits}
114 \def\tan{\mathop{\operator@font tan}\nolimits}
115 \def\arctan{\mathop{\operator@font arctan}\nolimits}
116 \def\tanh{\mathop{\operator@font tanh}\nolimits}
117 \def\cot{\mathop{\operator@font cot}\nolimits}
118 \def\coth{\mathop{\operator@font coth}\nolimits}
119 \def\sec{\mathop{\operator@font sec}\nolimits}
120 \def\csc{\mathop{\operator@font csc}\nolimits}
121 \def\max{\mathop{\operator@font max}}
122 \def\min{\mathop{\operator@font min}}
123 \def\sup{\mathop{\operator@font sup}}
124 \def\inf{\mathop{\operator@font inf}}
125 \def\arg{\mathop{\operator@font arg}\nolimits}
126 \def\ker{\mathop{\operator@font ker}\nolimits}
127 \def\dim{\mathop{\operator@font dim}\nolimits}
128 \def\hom{\mathop{\operator@font hom}\nolimits}
129 \def\det{\mathop{\operator@font det}}
130 \def\exp{\mathop{\operator@font exp}\nolimits}
131 \def\Pr{\mathop{\operator@font Pr}}
132 \def\gcd{\mathop{\operator@font gcd}}
133 \def\deg{\mathop{\operator@font deg}\nolimits}
137 % \begin{macro}{\bmod}
138 % And some operators have to be done by hand:
141 \nonscript\mskip-\medmuskip\mkern5mu%
142 \mathbin{\operator@font mod}\penalty900\mkern5mu%
143 \nonscript\mskip-\medmuskip}
147 % \begin{macro}{\pmod}
150 \allowbreak\mkern18mu({\operator@font mod}\,\,#1)}
154 % \subsubsection{Biggggg}
156 % \begin{macro}{\big}
157 % Variants on |\big| and friends for use with delimiters:
159 \def\bigl{\mathopen\big}
160 \def\bigm{\mathrel\big}
161 \def\bigr{\mathclose\big}
162 \def\Bigl{\mathopen\Big}
163 \def\Bigm{\mathrel\Big}
164 \def\Bigr{\mathclose\Big}
165 \def\biggl{\mathopen\bigg}
166 \def\biggm{\mathrel\bigg}
167 \def\biggr{\mathclose\bigg}
168 \def\Biggl{\mathopen\Bigg}
169 \def\Biggm{\mathrel\Bigg}
170 \def\Biggr{\mathclose\Bigg}
174 % \subsubsection{The UNSORTED Rest}
176 % The other math commands are lifted from plain \TeX.
178 % \begin{macro}{\jot}
185 % \begin{macro}{\interdisplaylinepenalty}
187 \newcount\interdisplaylinepenalty
188 \interdisplaylinepenalty=100
192 % \begin{macro}{\choose}
194 \def\choose{\atopwithdelims()}
198 % \begin{macro}{\brack}
200 \def\brack{\atopwithdelims[]}
204 % \begin{macro}{\brace}
206 \def\brace{\atopwithdelims\{\}}
210 % \begin{macro}{\mathpalette}
212 \def\mathpalette#1#2{%
214 {#1\displaystyle{#2}}%
216 {#1\scriptstyle{#2}}%
217 {#1\scriptscriptstyle{#2}}}
221 % \begin{macro}{\root}
222 % \changes{v1.1d}{1997/01/08}
223 % {(DPC) Remove spurious space tokens from
224 % plain \TeX\ definition /2359}
225 % \begin{macro}{\rootbox}
226 % \begin{macro}{\r@@t}
227 % \changes{v1.0r}{1995/05/21}{Use \cs{sqrtsign} instead of
235 \setbox\rootbox\hbox{$\m@th\scriptscriptstyle{#1}$}%
241 \setbox\z@\hbox{$\m@th#1\sqrtsign{#2}$}%
242 \dimen@\ht\z@ \advance\dimen@-\dp\z@
243 \mkern5mu\raise.6\dimen@\copy\rootbox
250 % \begin{macro}{\phantom}
251 % \changes{v1.0p}{1994/11/18}
252 % {(DPC) use \cs{expandafter} instead of \cs{next}}
253 % \changes{v1.0p}{1994/11/18}
254 % {(DPC) colour support}
255 % \begin{macro}{\hphantom}
256 % \begin{macro}{\vphantom}
263 \def\vphantom{\v@true\h@false\ph@nt}
267 \def\hphantom{\v@false\h@true\ph@nt}
271 \def\phantom{\v@true\h@true\ph@nt}
277 \expandafter\mathpalette\expandafter\mathph@nt
279 \expandafter\makeph@nt
285 \setbox\z@\hbox{\color@begingroup#1\color@endgroup}\finph@nt}
290 \setbox\z@\hbox{$\m@th#1{#2}$}\finph@nt}
296 \ifv@ \ht\tw@\ht\z@ \dp\tw@\dp\z@\fi
297 \ifh@ \wd\tw@\wd\z@\fi \box\tw@}
303 % \begin{macro}{\mathstrut}
305 \def\mathstrut{\vphantom(}
309 % \begin{macro}{\smash}
310 % \changes{v1.0p}{1994/11/18}
311 % {(DPC) use \cs{expandafter} instead of \cs{next}}
312 % \changes{v1.0p}{1994/11/18}
313 % {(DPC) colour support}
316 \relax % \relax, in case this comes first in \halign
318 \expandafter\mathpalette\expandafter\mathsm@sh
320 \expandafter\makesm@sh
326 \setbox\z@\hbox{\color@begingroup#1\color@endgroup}\finsm@sh}
328 \setbox\z@\hbox{$\m@th#1{#2}$}\finsm@sh}
329 \def\finsm@sh{\ht\z@\z@ \dp\z@\z@ \box\z@}
333 % \begin{macro}{\buildrel}
335 \def\buildrel#1\over#2{\mathrel{\mathop{\kern\z@#2}\limits^{#1}}}
340 % \begin{macro}{\cases}
341 % \changes{LaTeX2.09}{1991/08/14}
342 % {(RmS) inserted extra braces around entry for NFSS}
344 \def\cases#1{\left\{\,\vcenter{\normalbaselines\m@th
345 \ialign{$##\hfil$&\quad{##}\hfil\crcr#1\crcr}}\right.}
349 % \begin{macro}{\matrix}
351 \def\matrix#1{\null\,\vcenter{\normalbaselines\m@th
352 \ialign{\hfil$##$\hfil&&\quad\hfil$##$\hfil\crcr
353 \mathstrut\crcr\noalign{\kern-\baselineskip}
354 #1\crcr\mathstrut\crcr\noalign{\kern-\baselineskip}}}\,}
358 % \begin{macro}{\pmatrix}
360 \def\pmatrix#1{\left(\matrix{#1}\right)}
365 % \begin{macro}{\bordermatrix}
366 % \changes{LaTeX2e}{1994/01/25}{Removed \cs{p@renwd}.}
368 \def\bordermatrix#1{\begingroup \m@th
371 \def\cr{\crcr\noalign{\kern2\p@\global\let\cr\endline}}%
372 \ialign{$##$\hfil\kern2\p@\kern\@tempdima&\thinspace\hfil$##$\hfil
373 &&\quad\hfil$##$\hfil\crcr
374 \omit\strut\hfil\crcr\noalign{\kern-\baselineskip}%
375 #1\crcr\omit\strut\cr}}%
376 \setbox\tw@\vbox{\unvcopy\z@\global\setbox\@ne\lastbox}%
377 \setbox\tw@\hbox{\unhbox\@ne\unskip\global\setbox\@ne\lastbox}%
378 \setbox\tw@\hbox{$\kern\wd\@ne\kern-\@tempdima\left(\kern-\wd\@ne
379 \global\setbox\@ne\vbox{\box\@ne\kern2\p@}%
380 \vcenter{\kern-\ht\@ne\unvbox\z@\kern-\baselineskip}\,\right)$}%
381 \null\;\vbox{\kern\ht\@ne\box\tw@}\endgroup}
385 % \begin{macro}{\openup}
387 \def\openup{\afterassignment\@penup\dimen@}
391 \def\@penup{\advance\lineskip\dimen@
392 \advance\baselineskip\dimen@
393 \advance\lineskiplimit\dimen@}
397 % \begin{macro}{\displaylines}
403 \def\displ@y{\global\dt@ptrue\openup\jot\m@th
404 \everycr{\noalign{\ifdt@p \global\dt@pfalse \ifdim\prevdepth>-1000\p@
405 \vskip-\lineskiplimit \vskip\normallineskiplimit \fi
406 \else \penalty\interdisplaylinepenalty \fi}}}
410 \def\@lign{\tabskip\z@skip\everycr{}} % restore inside \displ@y
414 \def\displaylines#1{\displ@y \tabskip\z@skip
415 \halign{\hb@xt@\displaywidth{$\@lign\hfil\displaystyle##\hfil$}\crcr
420 % \changes{v1.0r}{1995/05/21}{Remove \cs{mathhexbox} from this file}
435 %\def\,{\mskip\thinmuskip} % already defined in ltspace
436 \def\>{\mskip\medmuskip}
437 \def\;{\mskip\thickmuskip}
438 \def\!{\mskip-\thinmuskip}
446 \def\*{\discretionary{\thinspace\the\textfont2\char2}{}{}}
451 % Nickname for the medium space since |\>| is not available inside
458 % \begin{macro}{\active@math@prime}
459 % \changes{v1.1e}{1999/10/09}{Macro added, see PR 3104.}
460 % This is the definition of the active math prime.
462 \def\active@math@prime{^\bgroup\prim@s}
466 % \begin{macro}{\prime@s}
467 % \changes{v1.0p}{1994/11/18}
468 % {(DPC) use \cs{@let@token} instead of \cs{next}
469 % and \cs{expandafter} instead of \cs{nxt}}
470 % \changes{v1.1e}{1999/10/09}{Introduce \cs{active@math@prime}.}
472 {\catcode`\'=\active \global\let'\active@math@prime}
477 \prime\futurelet\@let@token\pr@m@s}
486 \expandafter\expandafter\expandafter\pr@@@t
494 \def\pr@@@s#1{\prim@s}
498 \def\pr@@@t#1#2{#2\egroup}
502 % \changes{v1.0i}{1994/05/17}{Replaced \cs{let} by \cs{gdef}, for
503 % indirect definition.}
505 {\catcode`\_=\active \gdef_{\_}} % _ in math is
506 % either subscript or \_
510 % \changes{v1.0m}{1994/10/29}{ASAJ: Removed \cs{dag}, \cs{ddag}.}
511 % \changes{v1.0m}{1994/10/29}{ASAJ: Renamed \cs{S} and \cs{P} to
512 % \cs{mathsection} and \cs{mathparagraph} and made them
513 % \cs{mathchardef}s.}
514 % \changes{v1.0m}{1994/10/29}{ASAJ: Added \cs{mathellipsis},
515 % \cs{mathdollar} and \cs{mathsterling}.}
516 % \changes{v1.0n}{1994/10/30}{ASAJ: Moved the new commands to ltoutenc.}
518 % \subsection{Math Environments}
520 % \changes{1.0m}{1994/10/29}{ASAJ: Tidied up documentation.}
524 % Produces |$...$| with checks that |\(| isn't used in math mode, and
525 % that |\)| is only used in math mode begun with |\(|.
526 % \changes{v1.1h}{2015/01/08}{Make Robust (latexrelease)}
529 %<latexrelease>\IncludeInRelease{2015/01/01}{\(}{Make \( robust}%
530 %<*2ekernel|latexrelease>
531 \DeclareRobustCommand\({%
532 \relax\ifmmode\@badmath\else$\fi}%
533 \DeclareRobustCommand\){%
534 \relax\ifmmode\ifinner$\else\@badmath\fi\else \@badmath\fi}%
535 %</2ekernel|latexrelease>
536 %<latexrelease>\EndIncludeInRelease
537 %<latexrelease>\IncludeInRelease{0000/00/00}{\(}{Make \( robust}%
538 %<latexrelease>\def\({%
539 %<latexrelease> \relax\ifmmode\@badmath\else$\fi}%
540 %<latexrelease>\expandafter\let\csname\string( \endcsname\@undefined
541 %<latexrelease>\def\){%
542 %<latexrelease> \relax\ifmmode\ifinner$\else\@badmath\fi\else \@badmath\fi}%
543 %<latexrelease>\expandafter\let\csname\string) \endcsname\@undefined
544 %<latexrelease>\EndIncludeInRelease
551 % \changes{v1.1g}{2005/11/10}
552 % {(MH) Fixed potential problem in \cs{[} (pr/3399).}
554 % Produces |$$...$$| with checks that |\[| isn't used in math mode,
555 % and that |\]| is only used in display math mode (though there is no
556 % real test that this display math started with |\[| and not with |$$|).
557 % \changes{v1.1h}{2015/01/08}{Make Robust (latexrelease)}
560 %<latexrelease>\IncludeInRelease{2015/01/01}{\[}{Make \[ robust}%
561 %<*2ekernel|latexrelease>
562 \DeclareRobustCommand\[{%
568 \makebox[.6\linewidth]{}%
570 $$%%$$ BRACE MATCH HACK
576 \DeclareRobustCommand\]{%
581 $$%%$$ BRACE MATCH HACK
591 %</2ekernel|latexrelease>
592 %<latexrelease>\EndIncludeInRelease
593 %<latexrelease>\IncludeInRelease{0000/00/00}{\[}{Make \[ robust}%
594 %<latexrelease>\def\[{%
595 %<latexrelease> \relax\ifmmode
596 %<latexrelease> \@badmath
597 %<latexrelease> \else
598 %<latexrelease> \ifvmode
599 %<latexrelease> \nointerlineskip
600 %<latexrelease> \makebox[.6\linewidth]{}%
602 %<latexrelease> $$%%$$ BRACE MATCH HACK
605 %<latexrelease>\expandafter\let\csname\string[ \endcsname\@undefined
609 %<latexrelease>\def\]{%
610 %<latexrelease> \relax\ifmmode
611 %<latexrelease> \ifinner
612 %<latexrelease> \@badmath
613 %<latexrelease> \else
614 %<latexrelease> $$%%$$ BRACE MATCH HACK
616 %<latexrelease> \else
617 %<latexrelease> \@badmath
619 %<latexrelease> \ignorespaces
621 %<latexrelease>\expandafter\let\csname\string] \endcsname\@undefined
622 %<latexrelease>\EndIncludeInRelease
628 % \begin{environment}{math}
629 % \begin{environment}{displaymath}
630 % Disguises for |\(...\)| and |\[...\]|.
638 \def\enddisplaymath{\]\@ignoretrue}
644 % \begin{environment}{equation}
645 % \changes{LaTeX2.09}{1992/01/10}{RmS: put \cs{hbox} around \cs{@eqnnum}
646 % to typeset the equation number in text mode
647 % (as in the eqnarray env.)}
648 % \begin{macro}{\c@equation}
649 % Numbered equations, using the counter |\c@equation|.
650 % \emph{Note}: The document style must define |\theequation| etc., and
651 % do the appropriate |\@addtoreset|. It should also redefine |\@eqnnum|
652 % if another format for the equation number is desired other than the
653 % standard (...), or to move the equation numbers to the flushleft.
654 % (See comment on the |\def| of |\@eqnnum|.)
656 \@definecounter{equation}
657 \def\equation{$$\refstepcounter{equation}}
658 \def\endequation{\eqno \hbox{\@eqnnum}$$\@ignoretrue}
663 % \begin{macro}{\@eqnnum}
664 % \changes{LaTeX2.09}{1991/09/29}{RmS: \cs{reset@font} added.}
665 % \changes{v1.0l}{1994/10/23}{Added \cs{normalcolor} since \cs{eqno}
666 % introduces a subgroup of the displayed math group}
668 % Produces the equation number for equation and
669 % eqnarray environments. The following definition is for
670 % flushright numbers; for flushleft numbers, see leqno.clo.
671 % The equation number is set in black roman type even
672 % if an eqnarray environment appears in an italic environment.
673 % \changes{v1.0s}{1995/05/26}{Removed \cs{rmfamily} (PR 1578),
674 % replaced \cs{reset@font} with \cs{normalfont}}
676 \def\@eqnnum{{\normalfont \normalcolor (\theequation)}}
680 % \begin{macro}{\stackrel}
681 % A disguise for plain \TeX's buildrel.
683 \def\stackrel#1#2{\mathrel{\mathop{#2}\limits^{#1}}}
687 % \changes{v0.9g}{1993/12/11}{Added a group around the first argument
688 % of \cs{frac} to prevent
689 % changes (for example font changes) from modifying the contents of
690 % the second argument.}
692 % \begin{macro}{\frac}
693 % A disguise for plain \TeX's |\over|.
695 \def\frac#1#2{{\begingroup#1\endgroup\over#2}}
699 % \begin{macro}{\sqrt}
700 % \changes{v1.0y}{1995/10/16}{(DPC) Make robust /1808}
701 % \begin{macro}{\@sqrt}
702 % Add an optional argument to plain's |\sqrt| to give the $n$th root
703 % of an expression $\sqrt[n]{e}$.
704 % \changes{v1.0r}{1995/05/21}{Use \cs{sqrtsign}}
706 \DeclareRobustCommand\sqrt{\@ifnextchar[\@sqrt\sqrtsign}
707 \def\@sqrt[#1]{\root #1\of}
712 % \changes{LaTeX2.09}{1985/11/04}{produce warning message if line
713 % extends into margin. Doesn't warn about formula
714 % overprinting equation number.}
715 % \changes{LaTeX2.09}{1993/11/02}{RmS:
716 % Corrected description of \cs{@eqnsel}, moved \cs{@eqnsel}
717 % accordingly and removed extra \cs{tabskip} assignment.}
718 % \changes{LaTeX2e}{1993/11/03}{RmS: Initialized \cs{everycr} to empty}
719 % \changes{v0.9i}{1993/12/16}
720 % {use \cs{refstepcounter} instead of shortcut}
721 % \changes{v0.9o}{1994/01/13}{correcting 0.9i}
723 % \begin{environment}{eqnarray}
724 % \begin{macro}{\@eqcnt}
725 % \begin{macro}{\@eqpen}
726 % \begin{macro}{\if@eqnsw}
727 % \begin{macro}{\@eqnsel}
728 % Here's the eqnarray environment:
729 % Default is for left-hand side of equations to be flushright.
730 % To make them flushleft, |\let\@eqnsel = \hfil|.
734 \newif\if@eqnsw\@eqnswtrue
736 \@centering = 0pt plus 1000pt
738 % To get a proper \cs{@currentlabel} we have to redefine it for the
739 % whole display. Note that we can't use \cs{refstepcounter} as this
740 % results in |\@currentlabel| getting restored at the wrong and
741 % thus always writing the first label to the \texttt{.aux} file.
744 \stepcounter{equation}%
745 \def\@currentlabel{\p@equation\theequation}%
751 $$\everycr{}\halign to\displaywidth\bgroup
752 \hskip\@centering$\displaystyle\tabskip\z@skip{##}$\@eqnsel
753 &\global\@eqcnt\@ne\hskip \tw@\arraycolsep \hfil${##}$\hfil
754 &\global\@eqcnt\tw@ \hskip \tw@\arraycolsep
755 $\displaystyle{##}$\hfil\tabskip\@centering
756 &\global\@eqcnt\thr@@ \hb@xt@\z@\bgroup\hss##\egroup
766 \global\advance\c@equation\m@ne
780 % \begin{macro}{\nonumber}
781 % Switches off equation numbering.
783 \def\nonumber{\global\@eqnswfalse}
787 % \begin{macro}{\@eqncr}
788 % \begin{macro}{\@xeqncr}
789 % \begin{macro}{\@yeqncr}
790 % \changes{v1.0y}{1995/10/16}{(DPC) Use \cs{@testopt} /1911}
795 \global\@eqpen\@M\@yeqncr
797 \global\@eqpen\interdisplaylinepenalty \@yeqncr
803 \def\@yeqncr{\@testopt\@xeqncr\z@skip}
810 \noalign{\penalty\@eqpen\vskip\jot\vskip #1\relax}%
818 % \begin{macro}{\@@eqncr}
819 % \changes{v0.9i}{1993/12/16}{use \cs{refstepcounter} instead of shortcut}
820 % \changes{v0.9o}{1994/01/13}{correcting 0.9i}
823 \def\@@eqncr{\let\reserved@a\relax
824 \ifcase\@eqcnt \def\reserved@a{& & &}\or \def\reserved@a{& &}%
825 \or \def\reserved@a{&}\else
826 \let\reserved@a\@empty
827 \@latex@error{Too many columns in eqnarray environment}\@ehc\fi
828 \reserved@a \if@eqnsw\@eqnnum\stepcounter{equation}\fi
829 \global\@eqnswtrue\global\@eqcnt\z@\cr}
833 % \begin{environment}{eqnarray*}
834 % \begin{macro}{\@seqncr}
835 % Here's the eqnarray* environment:
841 \@namedef{eqnarray*}{\def\@eqncr{\nonumber\@seqncr}\eqnarray}
845 \@namedef{endeqnarray*}{\nonumber\endeqnarray}
850 % \begin{macro}{\lefteqn}
851 % |\lefteqn{FORMULA}| typesets |FORMULA| in display math style
852 % flushleft in a box of width zero.
853 % \changes{v1.0r}{1995/05/21}{Use \cs{rlap}}
855 \def\lefteqn#1{\rlap{$\displaystyle #1$}}
859 % \begin{macro}{\ensuremath}
860 % In math mode, |\ensuremath{text}| is equivalent to text; in LR or
861 % paragraph mode, it is equivalent to |$|text|$|.
862 % |\relax| is not needed
863 % in front of the |\ifmmode| as |\protect| will be |\let| to |\relax|.
864 % This version (due to Donald Arseneau) avoids duplicating its
865 % argument in the `then' and `else' part of the |\ifmath| which is
866 % necessary in nested `tabular' like environments. See amslatex/2104.
867 % \changes{v1.0k}{1994/05/16}
868 % {Use \cs{DeclareRobustCommand} and add extra braces in math mode}
869 % \changes{v1.0l}{1994/10/23}{Remove extra braces: but see p 168 of
871 % \changes{v1.1a}{1996/03/25}{Reimplement for amslatex/2104}
873 \DeclareRobustCommand{\ensuremath}{%
875 \expandafter\@firstofone
877 \expandafter\@ensuredmath
882 % \begin{macro}{\@ensuredmath}
883 % \changes{v1.1a}{1996/03/25}{Macro added for amslatex/2104}
884 % \changes{v1.1c}{1996/11/09}{Made long, as it was before. /2104}
885 % The |\relax| stops |\ensuremath{}| starting display math.
887 \long\def\@ensuredmath#1{$\relax#1$}
897 % \subsection{External options to the standard document classes}
899 % \changes{v1.0u}{1995/08/09}
900 % {Added code for class options leqno and fleqn}
902 % \subsubsection{Left equation numbering}
904 % \begin{macro}{\@eqnnum}
905 % To put the equation number on the left side of an equation we
906 % have to use a little trick. The number is shifted |\displaywidth|
907 % to the left inside a box of (approximately) zero width. This
908 % fails when the quation is too wide, the equation number than may
909 % overprint the equation itself.
910 % \changes{v1.2y classes}{1995/01/12}{Added \cs{normalcolor}}
911 % \changes{v1.3c classes}{1995/05/25}
912 % {replace \cs{reset@font}\cs{rmfamily} with \cs{normalfont}
916 \renewcommand\@eqnnum{\hb@xt@.01\p@{}%
917 \rlap{\normalfont\normalcolor
918 \hskip -\displaywidth(\theequation)}}
923 % \subsubsection{Flush left equations}
925 % To get the displayed math environments to print the contents
926 % flush left (with an indentation) we have to redefine all of
927 % \LaTeXe's displayed math environments.
929 % \begin{macro}{\mathindent}
930 % The amount of indentation of the equations is stored in a register.
935 % The setting of |\mathindent| has to be deferred until the class
936 % file has been processed, because |\leftmargini| is still 0pt
937 % wide at the moment \texttt{fleqn.clo} is read in.
938 % \changes{v1.0n classes}
939 % {1994/01/19}{Deferred setting of \cs{mathindent}}
940 % \changes{v1.2t classes}
941 % {1994/06/22}{Set \cs{mathindent} at the end of the
942 % class instead of at begin document}
944 \AtEndOfClass{\mathindent\leftmargini}
949 % Begin display math;
951 \IncludeInRelease{2015/01/01}{\[}{Make \[ robust}%
952 \DeclareRobustCommand\[{\relax
956 \@beginparpenalty\predisplaypenalty
957 \@endparpenalty\postdisplaypenalty
959 \hb@xt@\linewidth\bgroup $\m@th\displaystyle %$
960 \hskip\mathindent\bgroup
966 \IncludeInRelease{0000/00/00}{\[}{Make \[ robust}%
967 \renewcommand\[{\relax
971 \@beginparpenalty\predisplaypenalty
972 \@endparpenalty\postdisplaypenalty
974 \hb@xt@\linewidth\bgroup $\m@th\displaystyle %$
975 \hskip\mathindent\bgroup
984 \IncludeInRelease{2015/01/01}{\]}{Make \] robust}%
985 \DeclareRobustCommand\]{\relax
996 \IncludeInRelease{0000/00/00}{\]}{Make \] robust}%
997 \renewcommand\]{\relax
1004 \EndIncludeInRelease
1008 % \begin{environment}{equation}
1009 % The \textsf{equation} environment
1011 \renewenvironment{equation}%
1012 {\@beginparpenalty\predisplaypenalty
1013 \@endparpenalty\postdisplaypenalty
1014 \refstepcounter{equation}%
1015 \trivlist \item[]\leavevmode
1016 \hb@xt@\linewidth\bgroup $\m@th% $
1020 \displaywidth\linewidth\hbox{\@eqnnum}%
1026 % \begin{environment}{eqnarray}
1027 % The \textsf{eqnarray} environment
1029 \renewenvironment{eqnarray}{%
1030 \stepcounter{equation}%
1031 \def\@currentlabel{\p@equation\theequation}%
1032 \global\@eqnswtrue\m@th
1036 \setlength\abovedisplayskip{\topsep}%
1038 \addtolength\abovedisplayskip{\partopsep}%
1041 % When the documentclass uses a non-zero |\parskip| setting the
1042 % |\topsep| might have a negative value to compensate for
1043 % that. Therefore we add |\parskip| to |\abovedisplayskip|.
1044 % \changes{v1.2v classes}{1994/11/10}{Added value of \cs{parskip} to
1045 % \cs{abovedisplayskip} to compensate for negative \cs{topsep}}
1047 \addtolength\abovedisplayskip{\parskip}%
1048 \setlength\belowdisplayskip{\abovedisplayskip}%
1049 \setlength\belowdisplayshortskip{\abovedisplayskip}%
1050 \setlength\abovedisplayshortskip{\abovedisplayskip}%
1051 $$\everycr{}\halign to\linewidth% $$
1054 $\displaystyle\tabskip\z@skip{##}$\@eqnsel&%
1055 \global\@eqcnt\@ne \hskip \tw@\arraycolsep \hfil${##}$\hfil&%
1056 \global\@eqcnt\tw@ \hskip \tw@\arraycolsep
1057 $\displaystyle{##}$\hfil \tabskip\@centering&%
1058 \global\@eqcnt\thr@@
1059 \hb@xt@\z@\bgroup\hss##\egroup\tabskip\z@skip\cr}%
1062 \global\advance\c@equation\m@ne$$% $$