summaryrefslogtreecommitdiff
path: root/macros/latex/required/amsmath/amsmath.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/required/amsmath/amsmath.dtx')
-rw-r--r--macros/latex/required/amsmath/amsmath.dtx155
1 files changed, 108 insertions, 47 deletions
diff --git a/macros/latex/required/amsmath/amsmath.dtx b/macros/latex/required/amsmath/amsmath.dtx
index a5cf333e79..34d17b65f0 100644
--- a/macros/latex/required/amsmath/amsmath.dtx
+++ b/macros/latex/required/amsmath/amsmath.dtx
@@ -2,7 +2,7 @@
% \iffalse meta-comment
%
% Copyright (C) 1995, 2000, 2013 American Mathematical Society.
-% Copyright (C) 2016-2021 LaTeX Project and American Mathematical Society.
+% Copyright (C) 2016-2022 LaTeX Project and American Mathematical Society.
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
@@ -68,7 +68,7 @@ Bug reports can be opened (category \texttt{#1}) at\\%
% provided here is found in the AMSmath Users' Guide,
% \fn{amsldoc.tex}.
%
-% \StopEventually{}
+% \MaybeStop{}
%
% Standard file identification.
% \begin{macrocode}
@@ -86,7 +86,7 @@ Bug reports can be opened (category \texttt{#1}) at\\%
% \end{macrocode}
%
% \begin{macrocode}
-\ProvidesPackage{amsmath}[2021/10/15 v2.17l AMS math features]
+\ProvidesPackage{amsmath}[2022/04/08 v2.17n AMS math features]
% \end{macrocode}
%
% \section{Catcode defenses}
@@ -615,7 +615,8 @@ Foreign command \@backslashchar#1;\MessageBreak
% abbreviations for some commonly needed mathstyle overrides. To
% conserve csnames we avoid making \cn{dfrac} and \cn{tfrac} robust
% (\cn{genfrac} is itself robust).
-% \changes{v2.17i}{2020/09/23}{added \cs{Ustack} for luatex (moved patch from lualatex-math)}
+% \changes{v2.17i}{2020/09/23}{added \cs{Ustack} for luatex (moved patch from lualatex-math)}
+% \changes{v2.17n}{2022/04/08}{Make fraction commands robust (gh/123)}
% \begin{macrocode}
%
\ifx\directlua\@undefined
@@ -623,8 +624,8 @@ Foreign command \@backslashchar#1;\MessageBreak
\else
\DeclareRobustCommand{\frac}[2]{{\Ustack{\begingroup#1\endgroup\@@over#2}}}
\fi
-\newcommand{\dfrac}{\genfrac{}{}{}0}
-\newcommand{\tfrac}{\genfrac{}{}{}1}
+\DeclareRobustCommand{\dfrac}{\genfrac{}{}{}0}
+\DeclareRobustCommand{\tfrac}{\genfrac{}{}{}1}
% \end{macrocode}
% The \cn{binom} command for binomial notation works like \cn{frac}
% and has similar variants. Note that we do not use \cs{z@} in
@@ -632,10 +633,11 @@ Foreign command \@backslashchar#1;\MessageBreak
% like \cn{binom}, and so the \cs{z@} with the potentially
% problematic \qc{\@} character would become visible when writing one
% of those commands to a \fn{.toc} file.
+% \changes{v2.17n}{2022/04/08}{Make binom commands robust (gh/123)}
% \begin{macrocode}
\DeclareRobustCommand{\binom}{\genfrac()\z@{}}
-\newcommand{\dbinom}{\genfrac(){0pt}0}
-\newcommand{\tbinom}{\genfrac(){0pt}1}
+\DeclareRobustCommand{\dbinom}{\genfrac(){0pt}0}
+\DeclareRobustCommand{\tbinom}{\genfrac(){0pt}1}
% \end{macrocode}
%
% \begin{macro}{\genfrac}
@@ -938,8 +940,9 @@ Foreign command \@backslashchar#1;\MessageBreak
% an equation or piece of an equation. (Not including the equation
% number.) This isn't trivial for end-users to do it properly
% with \cs{fbox} so we provide a command for them.
+% \changes{v2.17n}{2022/04/08}{Make \cs{boxed} command robust (gh/123)}
% \begin{macrocode}
-\newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}}
+\DeclareRobustCommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}}
% \end{macrocode}
% \end{macro}
%
@@ -980,8 +983,9 @@ Foreign command \@backslashchar#1;\MessageBreak
% small space on the left, larger space on the right. The \qc{\:}
% character by itself is treated as a \cs{mathrel} i.e. large, equal
% spacing on both sides.
+% \changes{v2.17n}{2022/04/08}{Make \cs{colon} command robust (gh/123)}
% \begin{macrocode}
-\renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript
+\DeclareRobustCommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript
\mkern-\thinmuskip{:}\mskip6muplus1mu\relax}
% \end{macrocode}
% \end{macro}
@@ -1386,10 +1390,10 @@ Foreign command \@backslashchar#1;\MessageBreak
{{\cdotp}\mkern1mu{\cdotp}\mkern1mu{\cdotp}}%
{{\cdotp}\mkern1mu{\cdotp}\mkern1mu{\cdotp}}}
%
-\ams@newcommand{\iint}{\DOTSI\protect\MultiIntegral{2}}
-\ams@newcommand{\iiint}{\DOTSI\protect\MultiIntegral{3}}
-\ams@newcommand{\iiiint}{\DOTSI\protect\MultiIntegral{4}}
-\newcommand{\idotsint}{\DOTSI\protect\MultiIntegral{0}}
+\ams@newcommand{\iint}{\DOTSI\MultiIntegral{2}}
+\ams@newcommand{\iiint}{\DOTSI\MultiIntegral{3}}
+\ams@newcommand{\iiiint}{\DOTSI\MultiIntegral{4}}
+\newcommand{\idotsint}{\DOTSI\MultiIntegral{0}}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -1403,8 +1407,9 @@ Foreign command \@backslashchar#1;\MessageBreak
% the left-hand space a bit to make the subscript visually centered.
%
% \verb'#1' is the multiplicity.
+% \changes{v2.17n}{2022/04/08}{Make \cs{MultiIntegral} command robust (gh/123)}
% \begin{macrocode}
-\newcommand{\MultiIntegral}[1]{%
+\DeclareRobustCommand{\MultiIntegral}[1]{%
\edef\ints@c{\noexpand\intop
\ifnum#1=\z@\noexpand\intdots@\else\noexpand\intkern@\fi
\ifnum#1>\tw@\noexpand\intop\noexpand\intkern@\fi
@@ -1582,11 +1587,12 @@ Foreign command \@backslashchar#1;\MessageBreak
% the \latex/ kernel; the macro |\n@space| is then superfluous (since
% it is only used once) and should be removed to avoid wasting hash
% table space unnecessarily.
+% \changes{v2.17n}{2022/04/08}{Make biggg commands robust (gh/123)}
% \begin{macrocode}
-\renewcommand{\big}{\bBigg@\@ne}
-\renewcommand{\Big}{\bBigg@{1.5}}
-\renewcommand{\bigg}{\bBigg@\tw@}
-\renewcommand{\Bigg}{\bBigg@{2.5}}
+\DeclareRobustCommand{\big}{\bBigg@\@ne}
+\DeclareRobustCommand{\Big}{\bBigg@{1.5}}
+\DeclareRobustCommand{\bigg}{\bBigg@\tw@}
+\DeclareRobustCommand{\Bigg}{\bBigg@{2.5}}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -1666,6 +1672,17 @@ Foreign command \@backslashchar#1;\MessageBreak
{\mathop{\kern\z@#1}\limits^{\vbox to-1.4\ex@{\kern-\tw@\ex@
\hbox{\,\normalfont....}\vss}}}}
% \end{macrocode}
+%
+% We make the commands robust only at the end of the preamble as
+% \pkg{amsmath} interacts with \pkg{stix} (which should also move
+% to robust commands).
+% \changes{v2.17n}{2022/04/08}{Make dddot commands robust (gh/123)}
+% \begin{macrocode}
+\AtBeginDocument{%
+ \MakeRobust\dddot
+ \MakeRobust\ddddot
+ }
+% \end{macrocode}
% \end{macro}
% \end{macro}
%
@@ -2087,14 +2104,16 @@ Foreign command \@backslashchar#1;\MessageBreak
% \begin{macro}{\mod}
% The commands \cn{bmod}, \cn{pmod}, \cn{pod}, \cn{mod} aren't
% currently robust. [mjd, 1994/09/05]
+% Now they are
+% \changes{v2.17n}{2022/04/08}{Make mod commands robust (gh/123)}
% \begin{macrocode}
-\renewcommand{\bmod}{\nonscript\mskip-\medmuskip\mkern5mu\mathbin
+\DeclareRobustCommand{\bmod}{\nonscript\mskip-\medmuskip\mkern5mu\mathbin
{\operator@font mod}\penalty900
\mkern5mu\nonscript\mskip-\medmuskip}
-\newcommand{\pod}[1]{\allowbreak
+\DeclareRobustCommand{\pod}[1]{\allowbreak
\if@display\mkern18mu\else\mkern8mu\fi(#1)}
-\renewcommand{\pmod}[1]{\pod{{\operator@font mod}\mkern6mu#1}}
-\newcommand{\mod}[1]{\allowbreak\if@display\mkern18mu
+\DeclareRobustCommand{\pmod}[1]{\pod{{\operator@font mod}\mkern6mu#1}}
+\DeclareRobustCommand{\mod}[1]{\allowbreak\if@display\mkern18mu
\else\mkern12mu\fi{\operator@font mod}\,\,#1}
% \end{macrocode}
% \end{macro}
@@ -2109,8 +2128,9 @@ Foreign command \@backslashchar#1;\MessageBreak
% fraction rules to line up. The \cs{strut} keeps the numerator of
% a subsidiary cfrac from coming too close to the fraction rule above
% it.
+% \changes{v2.17n}{2022/04/08}{Make \cs{cfrac} command robust (gh/123)}
% \begin{macrocode}
-\newcommand{\cfrac}[3][c]{{\displaystyle\frac{%
+\DeclareRobustCommand{\cfrac}[3][c]{{\displaystyle\frac{%
\strut\ifx r#1\hfill\fi#2\ifx l#1\hfill\fi}{#3}}%
\kern-\nulldelimiterspace}
% \end{macrocode}
@@ -2123,13 +2143,15 @@ Foreign command \@backslashchar#1;\MessageBreak
% naturally accept limits. \cs{binrel@@} uses information collected
% by \cs{binrel@} to make the resulting construction be of type
% mathrel or mathbin if the base symbol is either of those types.
+% \changes{v2.17n}{2022/04/08}{Make \cs{overset}, \cs{underset} and
+% \cs{overunderset} commands robust (gh/123)}
% \begin{macrocode}
-\newcommand{\overset}[2]{\binrel@{#2}%
+\DeclareRobustCommand{\overset}[2]{\binrel@{#2}%
\binrel@@{\mathop{\kern\z@#2}\limits^{#1}}}
% \end{macrocode}
%
% \begin{macrocode}
-\newcommand{\underset}[2]{\binrel@{#2}%
+\DeclareRobustCommand{\underset}[2]{\binrel@{#2}%
\binrel@@{\mathop{\kern\z@#2}\limits_{#1}}}
% \end{macrocode}
% \end{macro}
@@ -2141,7 +2163,7 @@ Foreign command \@backslashchar#1;\MessageBreak
% something that is sometimes needed.
% \changes{v2.17c}{2019/04/01}{New command \cs{overunderset}}
% \begin{macrocode}
-\newcommand{\overunderset}[3]{\binrel@{#3}%
+\DeclareRobustCommand{\overunderset}[3]{\binrel@{#3}%
\binrel@@{\mathop{\kern\z@#3}\limits^{#1}_{#2}}}
% \end{macrocode}
% \end{macro}
@@ -2157,8 +2179,9 @@ Foreign command \@backslashchar#1;\MessageBreak
% have to read and measure the top and bottom limits and use
% mathchoice to always get the right mathstyle for each piece,
% etc., etc.
+% \changes{v2.17n}{2022/04/08}{Make \cs{sideset} command robust (gh/123)}
% \begin{macrocode}
-\newcommand{\sideset}[3]{%
+\DeclareRobustCommand{\sideset}[3]{%
\@mathmeasure\z@\displaystyle{#3}%
% \end{macrocode}
% Use a global box assignment here since the depth override is
@@ -2182,9 +2205,10 @@ Foreign command \@backslashchar#1;\MessageBreak
% denoting the part of the formula to be smashed.
% \changes{v2.17b}{2018/12/01}{Start LR-mode for \cs{smash}
% if necessary (github/49)}
+% \changes{v2.17n}{2022/04/08}{Make \cs{smash} command robust (gh/123)}
% \begin{macrocode}
\ifx\leavevmode@ifvmode\@undefined
-\renewcommand{\smash}[1][tb]{%
+\DeclareRobustCommand{\smash}[1][tb]{%
\def\mb@t{\ht}\def\mb@b{\dp}\def\mb@tb{\ht\z@\z@\dp}%
\edef\finsm@sh{\csname mb@#1\endcsname\z@\z@\box\z@}%
\ifmmode \@xp\mathpalette\@xp\mathsm@sh
@@ -2192,7 +2216,7 @@ Foreign command \@backslashchar#1;\MessageBreak
\fi
}
\else
-\renewcommand{\smash}[1][tb]{%
+\DeclareRobustCommand{\smash}[1][tb]{%
\def\mb@t{\ht}\def\mb@b{\dp}\def\mb@tb{\ht\z@\z@\dp}%
\edef\finsm@sh{\csname mb@#1\endcsname\z@\z@ \leavevmode@ifvmode\box\z@}%
\ifmmode \@xp\mathpalette\@xp\mathsm@sh
@@ -2240,9 +2264,10 @@ Foreign command \@backslashchar#1;\MessageBreak
%
% \begin{macro}{\relbar}
% \begin{macro}{\Relbar}
+% \changes{v2.17n}{2022/04/08}{Make commands robust (gh/123)}
% \begin{macrocode}
-\ams@def\relbar{\mathrel{\mathpalette\mathsm@sh\std@minus}}
-\ams@def\Relbar{\mathrel\std@equal}
+\ams@DeclareRobustCommand\relbar{\mathrel{\mathpalette\mathsm@sh\std@minus}}
+\ams@DeclareRobustCommand\Relbar{\mathrel\std@equal}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -2272,6 +2297,17 @@ Foreign command \@backslashchar#1;\MessageBreak
\ams@newcommand{\overleftrightarrow}{%
\mathpalette{\overarrow@\leftrightarrowfill@}}
% \end{macrocode}
+% Again we delay making commands robut for \pkg{stix}.
+% \changes{v2.17n}{2022/04/08}{Make commands robust (gh/123)}
+% \begin{macrocode}
+\AtBeginDocument{%
+ \expandafter\let\csname overleftarrow \endcsname\@undefined
+ \expandafter\let\csname overrightarrow \endcsname\@undefined
+ \MakeRobust\overrightarrow
+ \MakeRobust\overleftarrow
+ \MakeRobust\overleftrightarrow
+ }
+% \end{macrocode}
%
% \begin{macrocode}
\def\underarrow@#1#2#3{%
@@ -2285,8 +2321,19 @@ Foreign command \@backslashchar#1;\MessageBreak
\mathpalette{\underarrow@\leftrightarrowfill@}}
% \end{macrocode}
%
+%
+% \changes{v2.17n}{2022/04/08}{Make commands robust (gh/123)}
% \begin{macrocode}
-%\newcommand{\xrightarrow}[2][]{\ext@arrow 0359\rightarrowfill@{#1}{#2}}
+\AtBeginDocument{%
+ \MakeRobust\underrightarrow
+ \MakeRobust\underleftarrow
+ \MakeRobust\underleftrightarrow
+ }
+% \end{macrocode}
+%
+% \changes{v2.17n}{2022/04/08}{Make commands robust (gh/123)}
+% \begin{macrocode}
+%\DeclareRobustCommand{\xrightarrow}[2][]{\ext@arrow 0359\rightarrowfill@{#1}{#2}}
\def\ext@arrow#1#2#3#4#5#6#7{%
\mathrel{\mathop{%
% \end{macrocode}
@@ -2315,8 +2362,8 @@ Foreign command \@backslashchar#1;\MessageBreak
% sub/superscripts. These commands are robust because they take an
% optional argument.
% \begin{macrocode}
-\newcommand{\xrightarrow}[2][]{\ext@arrow 0359\rightarrowfill@{#1}{#2}}
-\newcommand{\xleftarrow}[2][]{\ext@arrow 3095\leftarrowfill@{#1}{#2}}
+\DeclareRobustCommand{\xrightarrow}[2][]{\ext@arrow 0359\rightarrowfill@{#1}{#2}}
+\DeclareRobustCommand{\xleftarrow}[2][]{\ext@arrow 3095\leftarrowfill@{#1}{#2}}
% \end{macrocode}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -2406,8 +2453,9 @@ Foreign command \@backslashchar#1;\MessageBreak
% \begin{macro}{\substack}
% The \cn{substack} command is just an abbreviation for the
% most common use of \env{subarray}.
+% \changes{v2.17n}{2022/04/08}{Make command robust (gh/123)}
% \begin{macrocode}
-\newcommand{\substack}[1]{\subarray{c}#1\endsubarray}
+\DeclareRobustCommand{\substack}[1]{\subarray{c}#1\endsubarray}
% \end{macrocode}
% \end{macro}
%
@@ -2630,8 +2678,9 @@ ill-advised in LaTeX.%
% numbered within sections. The \LaTeX{} kernel contains a similar command
% \cs{counterwithin} (with a slightly extended syntax) that can be used
% as a drop-in replacement for \cs{numberwithin}.
+% \changes{v2.17n}{2022/04/08}{Make command robust (gh/123)}
% \begin{macrocode}
-\newcommand{\numberwithin}[3][\arabic]{%
+\DeclareRobustCommand{\numberwithin}[3][\arabic]{%
\@ifundefined{c@#2}{\@nocounterr{#2}}{%
\@ifundefined{c@#3}{\@nocnterr{#3}}{%
\@addtoreset{#2}{#3}%
@@ -2645,8 +2694,9 @@ ill-advised in LaTeX.%
% To make references to equation numbers easier, we provide
% \cn{eqref}. We almost don't need \cn{textup}, except that
% \cs{tagform@} doesn't supply the italic correction.
+% \changes{v2.17n}{2022/04/08}{Make command robust (gh/123)}
% \begin{macrocode}
-\newcommand{\eqref}[1]{\textup{\tagform@{\ref{#1}}}}
+\DeclareRobustCommand{\eqref}[1]{\textup{\tagform@{\ref{#1}}}}
% \end{macrocode}
% \end{macro}
%
@@ -2685,8 +2735,9 @@ ill-advised in LaTeX.%
% The \cn{allowdisplaybreaks} command. Since this is intended for use
% outside displayed formulas (typically in the preamble), it does not
% need to use \cs{new@ifnextchar}.
+% \changes{v2.17n}{2022/04/08}{Make command robust (gh/123)}
% \begin{macrocode}
-\newcommand{\allowdisplaybreaks}[1][4]{%
+\DeclareRobustCommand{\allowdisplaybreaks}[1][4]{%
\interdisplaylinepenalty\getdsp@pen{#1}\relax
}
% \end{macrocode}
@@ -2709,8 +2760,9 @@ ill-advised in LaTeX.%
% \begin{macro}{\dspbrk@context}
% \begin{macro}{\nogood@displaybreak}
% For breaks in a certain row of a alignment.
+% \changes{v2.17n}{2022/04/08}{Make command robust (gh/123)}
% \begin{macrocode}
-\newcommand{\displaybreak}{\new@ifnextchar[\dspbrk@{\dspbrk@[4]}}
+\DeclareRobustCommand{\displaybreak}{\new@ifnextchar[\dspbrk@{\dspbrk@[4]}}
\chardef\dspbrk@context=\sixt@@n
% \end{macrocode}
%
@@ -6130,15 +6182,16 @@ Cannot use `split' here;\MessageBreak trying to recover with `aligned'}%
% in his \fn{amstex.doc} Spivak indicates those commands should never
% be used on a first or last line. Perhaps better to leave the
% question open unless/until real-life examples turn up.
+% \changes{v2.17m}{2022/02/03}{Make \cs{shoveright} robust (if def is not trival)}
% \begin{macrocode}
\iftagsleft@
- \def\shoveright#1{%
+ \protected\def\shoveright#1{%
#1%
\hfilneg
\hskip\multlinegap
}
\else
- \def\shoveright#1{%
+ \protected\def\shoveright#1{%
#1%
\hfilneg
\iftag@
@@ -6153,12 +6206,14 @@ Cannot use `split' here;\MessageBreak trying to recover with `aligned'}%
\fi
}
\fi
-
+% \end{macrocode}
+% \changes{v2.17m}{2022/02/03}{Make \cs{shoveleft} robust (if def is not trival)}
+% \begin{macrocode}
\if@fleqn
\def\shoveleft#1{#1}%
\else
\iftagsleft@
- \def\shoveleft#1{%
+ \protected\def\shoveleft#1{%
\setboxz@h{$\m@th\displaystyle{}#1$}%
\setbox\@ne\hbox{$\m@th\displaystyle#1$}%
\hfilneg
@@ -6173,17 +6228,23 @@ Cannot use `split' here;\MessageBreak trying to recover with `aligned'}%
\hskip\multlinegap
\fi
\hskip.5\wd\@ne
- \hskip-.5\wdz@
+% \end{macrocode}
+% \changes{v2.17m}{2022/02/03}{Added missing \cs{relax} for (gh/716)}
+% \begin{macrocode}
+ \hskip-.5\wdz@ \relax
#1%
}
\else
- \def\shoveleft#1{%
+ \protected\def\shoveleft#1{%
\setboxz@h{$\m@th\displaystyle{}#1$}%
\setbox\@ne\hbox{$\m@th\displaystyle#1$}%
\hfilneg
\hskip\multlinegap
\hskip.5\wd\@ne
- \hskip-.5\wdz@
+% \end{macrocode}
+% \changes{v2.17m}{2022/02/03}{Added missing \cs{relax} for (gh/716)}
+% \begin{macrocode}
+ \hskip-.5\wdz@ \relax
#1%
}
\fi