diff options
Diffstat (limited to 'Master/texmf-dist/source/latex-dev/amsmath/amsmath.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex-dev/amsmath/amsmath.dtx | 191 |
1 files changed, 155 insertions, 36 deletions
diff --git a/Master/texmf-dist/source/latex-dev/amsmath/amsmath.dtx b/Master/texmf-dist/source/latex-dev/amsmath/amsmath.dtx index 11b7545c266..e3ad7c60420 100644 --- a/Master/texmf-dist/source/latex-dev/amsmath/amsmath.dtx +++ b/Master/texmf-dist/source/latex-dev/amsmath/amsmath.dtx @@ -2,7 +2,7 @@ % \iffalse meta-comment % % Copyright (C) 1995, 2000, 2013 American Mathematical Society. -% Copyright (C) 2016-2019 LaTeX3 Project and American Mathematical Society. +% Copyright (C) 2016-2020 LaTeX3 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 @@ -11,9 +11,9 @@ % https://www.latex-project.org/lppl.txt % and version 1.3c or later is part of all distributions of LaTeX % version 2005/12/01 or later. -% +% % This work has the LPPL maintenance status `maintained'. -% +% % The Current Maintainer of this work is the LaTeX3 Project. % % \fi @@ -86,7 +86,7 @@ Bug reports can be opened (category \texttt{#1}) at\\% % \end{macrocode} % % \begin{macrocode} -\ProvidesPackage{amsmath}[2019/11/16 v2.17d AMS math features] +\ProvidesPackage{amsmath}[2020/03/17 v2.17g AMS math features] % \end{macrocode} % % \section{Catcode defenses} @@ -302,10 +302,13 @@ For additional information on amsmath, use the \lq ?\rq\space option.% % \end{macrocode} % % Processing to handle the \opt{cmex10} option is a little tricky -% because of different possible loading orders for \pkg{amsmath} and -% \pkg{amsfonts}. The package \pkg{amsmath} sets the \cs{cmex@opt} -% flag to 7 or 10, and the package \pkg{amsfonts} sets the flag to 1 -% or 0. +% because of different possible loading orders for \pkg{amsmath} +% and \pkg{amsfonts}. The package \pkg{amsmath} sets the +% \cs{cmex@opt} flag to 0, 7 or 10, and in the past the package +% \pkg{amsfonts} did set the flag to 1 or 0. These days it always +% sets it to 10. The situation is a bit unsettled but we don't own +% \pkg{amsfonts}. +% \changes{v2.17d}{2019/12/01}{docu update, no code change (gh/200)} % \begin{macrocode} \ifnum\cmex@opt=7 \relax \DeclareFontShape{OMX}{cmex}{m}{n}{% @@ -463,24 +466,41 @@ For additional information on amsmath, use the \lq ?\rq\space option.% % \cs{DeclareRobustCommand}. % \changes{v2.17b}{2018/12/01}{Start LR-mode for \cs{thinspace} and % friends if necessary (github/49)} +% +% We start by undefining a number of commands (which in a current +% \LaTeX{} kernel will be defined, so that the +% \cs{DeclareRobustCommand} declarations below do not add a +% ``Command redefined'' info into the log. +% \begin{macrocode} +\let\tmspace\@undefined +\let\,\@undefined +\let\!\@undefined +\let\:\@undefined +\let\negmedspace\@undefined +\let\negthickspace\@undefined +% \end{macrocode} +% +% +% \changes{v2.17g}{2020/03/07}{Math/text spacing commands are now in +% the \LaTeX{} kernel and are made robust (gh/303)} % \begin{macrocode} \ifx\leavevmode@ifvmode\@undefined -\DeclareRobustCommand{\tmspace}[3]{% +\DeclareRobustCommand\tmspace[3]{% \ifmmode\mskip#1#2\else\kern#1#3\fi\relax} \else -\DeclareRobustCommand{\tmspace}[3]{% +\DeclareRobustCommand\tmspace[3]{% \ifmmode\mskip#1#2\else\leavevmode@ifvmode\kern#1#3\fi\relax} \fi -\renewcommand{\,}{\tmspace+\thinmuskip{.1667em}} +\DeclareRobustCommand\,{\tmspace+\thinmuskip{.1667em}} \let\thinspace\, -\renewcommand{\!}{\tmspace-\thinmuskip{.1667em}} +\DeclareRobustCommand\!{\tmspace-\thinmuskip{.1667em}} \let\negthinspace\! -\renewcommand{\:}{\tmspace+\medmuskip{.2222em}} +\DeclareRobustCommand\:{\tmspace+\medmuskip{.2222em}} \let\medspace\: -\newcommand{\negmedspace}{\tmspace-\medmuskip{.2222em}} -\renewcommand{\;}{\tmspace+\thickmuskip{.2777em}} +\DeclareRobustCommand\negmedspace{\tmspace-\medmuskip{.2222em}} +\renewcommand\;{\tmspace+\thickmuskip{.2777em}} \let\thickspace\; -\newcommand{\negthickspace}{\tmspace-\thickmuskip{.2777em}} +\DeclareRobustCommand\negthickspace{\tmspace-\thickmuskip{.2777em}} % \end{macrocode} % \end{macro} % \end{macro} @@ -517,9 +537,13 @@ For additional information on amsmath, use the \lq ?\rq\space option.% \@xp\@tempa\vert\@empty\@nil \ifnum\@tempcnta>\z@ \advance\@tempcnta "4000000 - \xdef\lvert{\delimiter\number\@tempcnta\space } +% \end{macrocode} +% Use \cs{protected} on the new delimiters. +% \changes{v2.17e}{2020/01/20}{Make delimiters robust (gh/251))} +% \begin{macrocode} + \protected\xdef\lvert{\delimiter\number\@tempcnta\space } \advance\@tempcnta "1000000 - \xdef\rvert{\delimiter\number\@tempcnta\space } + \protected\xdef\rvert{\delimiter\number\@tempcnta\space } \else \ifx\@@undefined\lvert % Fall back to cmex encoding since we don't know what else to do. @@ -532,9 +556,9 @@ For additional information on amsmath, use the \lq ?\rq\space option.% \@xp\@tempa\Vert\@empty\@nil \ifnum\@tempcnta>\z@ \advance\@tempcnta "4000000 - \xdef\lVert{\delimiter\number\@tempcnta\space } + \protected\xdef\lVert{\delimiter\number\@tempcnta\space } \advance\@tempcnta "1000000 - \xdef\rVert{\delimiter\number\@tempcnta\space } + \protected\xdef\rVert{\delimiter\number\@tempcnta\space } \else \ifx\@@undefined\lVert \DeclareMathDelimiter{\lVert} @@ -645,13 +669,13 @@ Foreign command \@backslashchar#1;\MessageBreak % \end{macrocode} % % \begin{macrocode} -\else +\else % \end{macrocode} % XeTeX version % \begin{macrocode} \def\genfrac@rule#1#2#3#4{% \hbox{$\left#1\vcenter{\hrule \@width\z@ - \@height + \@height \ifdim\fontdimen#2#3\tw@=\z@ #4\fontdimen6#3\tw@ \else @@ -697,7 +721,7 @@ Foreign command \@backslashchar#1;\MessageBreak % \begin{macrocode} \def\genfrac@rule#1#2#3{% \hbox{$\left#1\vcenter{\hrule \@width\z@ - \@height + \@height \ifdim\Umathfractiondelsize#2=\z@ #3\fontdimen6#3\tw@ \else @@ -1093,7 +1117,7 @@ Foreign command \@backslashchar#1;\MessageBreak % \changes{v2.15}{2016/02/20}{Indent \cs{mdots@@} for readability and add additional tests} % \begin{macrocode} \def\mdots@@{\gdef\thedots@{\dotso@}% - \ifx\@let@token\boldsymbol + \ifx\@let@token\boldsymbol \gdef\thedots@\boldsymbol{\boldsymboldots@}% \else \ifx,\@let@token \gdef\thedots@{\dotsc}% @@ -1167,7 +1191,7 @@ Foreign command \@backslashchar#1;\MessageBreak % \begin{macrocode} \fi % end macro \ifgtest@ test (no else) \fi % end if \Umathchar test - \fi % end \math@ \ifgtest@ + \fi % end \math@ \ifgtest@ \fi % end \keybin@ \ifgtest@ test (no else) \fi % end if \not (no else) \fi % end if comma (no else) @@ -1626,13 +1650,15 @@ Foreign command \@backslashchar#1;\MessageBreak % \begin{macro}{\dddot} % \begin{macro}{\ddddot} % Triple and quadruple dot accents. +% \changes{v2.17f}{2020/02/20}{Add a kern so that a single char is not +% vertically shifted and move the dots slightly to the right (gh/126)} % \begin{macrocode} \ams@newcommand{\dddot}[1]{% - {\mathop{#1}\limits^{\vbox to-1.4\ex@{\kern-\tw@\ex@ - \hbox{\normalfont ...}\vss}}}} + {\mathop{\kern\z@#1}\limits^{\vbox to-1.4\ex@{\kern-\tw@\ex@ + \hbox{\,\normalfont...}\vss}}}} \ams@newcommand{\ddddot}[1]{% - {\mathop{#1}\limits^{\vbox to-1.4\ex@{\kern-\tw@\ex@ - \hbox{\normalfont....}\vss}}}} + {\mathop{\kern\z@#1}\limits^{\vbox to-1.4\ex@{\kern-\tw@\ex@ + \hbox{\,\normalfont....}\vss}}}} % \end{macrocode} % \end{macro} % \end{macro} @@ -3190,9 +3216,10 @@ ill-advised in LaTeX.% % \end{macro} % % \begin{macro}{\ifst@rred} -% The switch |st@rred| is set to true by all starred -% environments -% and set to false by the unstarred versions. +% The switch |st@rred| is set to true by all starred environments +% and set to false by the unstarred versions. +% One exception is the \env{xxalignat} environment where this is set +% to true. % \begin{macrocode} \newif\ifst@rred % \end{macrocode} @@ -3430,7 +3457,8 @@ and fix things up.} % \end{macro} % % \begin{macro}{\black@} -% \changes{v2.17a}{2017/09/02}{add fixed width box so overfull warning generated in centred environments in lists} +% \changes{v2.17a}{2017/09/02}{Add fixed width box so overfull warning +% generated in centred environments in lists} % This macro is made to produce an overfull box message and % possibly (depending on the value of \cs{overfullrule}) % a rule in the margin if the total width of an alignment @@ -3443,7 +3471,8 @@ and fix things up.} \nointerlineskip \vskip-\ht\strutbox@ \vskip-\dp\strutbox@ - \vbox{\noindent\hbox to\displaywidth{\hbox to#1{\strut@\hfill}}}% + \vbox{\noindent\hbox to\displaywidth{% + \hbox to#1{\strut@\hfill}}}% \prevdepth\dimen@ \fi }% @@ -3645,6 +3674,77 @@ and fix things up.} % \end{macrocode} % \end{macro} % +% +% +% \begin{macro}{\ams@start@box} +% This macro tests the optional positioning argument (in +% \texttt{gathered} or \texttt{aligned}. It explicitly tests for the +% value \texttt{b}, \texttt{c} and \texttt{t} and if the value is +% different, then we assume that it is a bracket group that belongs +% to the formula instead of being an misspelled optional argument. +% (In earlier versions of the code anything other than \texttt{b} +% or \texttt{t} was interpreted as \texttt{c} and the data was +% otherwise dropped.) +% \changes{v2.17g}{2020/03/10}{Explicity test for b/t/c and return +% optional argument is different (gh/5)} +% \begin{macrocode} +\def\ams@start@box#1{% +% \end{macrocode} +% As we may pick up an arbitrary part of the formula by mistake, we +% need to be very careful with the testing to avoid low-level +% errors. This is why we use \cs{detokenize}. But we also need to +% expand the argument (if possible) in case the position value is +% hidden inside a macro. We therefore apply the \cs{romannumeral} +% trick (known as f-expansion in \texttt{expl3}) in its old form. +% The code assumes that +% the default is correctly set up (which in this case is \texttt{c}). +% \begin{macrocode} + \edef\reserved@a{\csname ams@pos@\expandafter\detokenize + \expandafter{\romannumeral-`\0#1}\endcsname}% + \expandafter\ifx\reserved@a\relax +% \end{macrocode} +% If the argument is neither \texttt{b}, \texttt{c} or \texttt{t} +% we save it in \cs{ams@return@opt@arg}, so it can later be +% returned as part of the environment body. We could at this point +% also issue a warning that bracket group was found at the start of +% the formula and that it is safer to add a \cs{relax} before it. +% \begin{macrocode} + \PackageWarning{amsmath}{% + Bracket group \detokenize{[#1]} at formula start!\MessageBreak + It could be a misspelled positional argument.\MessageBreak + If it belongs to the formula add a \relax in\MessageBreak + front to hide it}% + \def\ams@return@opt@arg{[#1]}\vcenter +% \end{macrocode} +% If the argument was identified then we clear +% \cs{ams@return@opt@arg} (just in case somebod ever nests these +% environment. +% \begin{macrocode} + \else + \let\ams@return@opt@arg\@empty\reserved@a + \fi +} +% \end{macrocode} +% +% \begin{macro}{\ams@pos@t} +% \begin{macro}{\ams@pos@b} +% \begin{macro}{\ams@pos@c} +% +% \begin{macrocode} +\def\ams@pos@t{\vtop} +\def\ams@pos@b{\vbox} +\def\ams@pos@c{\vcenter} +% \end{macrocode} +% And we accept an empty argument as a way to get the default (as +% that was the case before as well, albeit by mistake in some sense). +% \begin{macrocode} +\let\ams@pos@\ams@pos@c +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% % \begin{macro}{\start@aligned} % The \env{aligned} and \env{alignedat} environments are identical % except that the latter takes a mandatory argument to specify the @@ -3669,7 +3769,10 @@ and fix things up.} % to the margin. % \begin{macrocode} \alignedspace@left - \if #1t\vtop \else \if#1b \vbox \else \vcenter \fi \fi \bgroup +% \end{macrocode} +% Select the right kind of box based on the optional argument \verb=#1=. +% \begin{macrocode} + \ams@start@box{#1}\bgroup \maxfields@#2\relax \ifnum\maxfields@>\m@ne \multiply\maxfields@\tw@ @@ -3712,6 +3815,13 @@ and fix things up.} \hfil \tabskip\alignsep@ \crcr +% \end{macrocode} +% If we picked up a bracket group by mistake here is the place to +% return it for processing. +% \changes{v2.17g}{2020/03/10}{Explicity test for b/t/c and return +% optional argument is different (gh/5)} +% \begin{macrocode} + \ams@return@opt@arg } % \end{macrocode} % \end{macro} @@ -3796,12 +3906,21 @@ and fix things up.} \nonmatherr@{\begin{gathered}}% \fi \alignedspace@left - \if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi \bgroup +% \end{macrocode} +% Select the right kind of box based on the optional argument \verb=#1=. +% \begin{macrocode} + \ams@start@box{#1}\bgroup \Let@ \chardef\dspbrk@context\@ne \restore@math@cr \spread@equation \ialign\bgroup \hfil\strut@$\m@th\displaystyle##$\hfil \crcr +% \end{macrocode} +% And put a mistaking picked up bracket group back: +% \changes{v2.17g}{2020/03/10}{Explicity test for b/t/c and return +% optional argument is different (gh/5)} +% \begin{macrocode} + \ams@return@opt@arg }{% \endaligned } |