diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/amsmath/amsmath.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/amsmath/amsmath.dtx | 201 |
1 files changed, 176 insertions, 25 deletions
diff --git a/Master/texmf-dist/source/latex/amsmath/amsmath.dtx b/Master/texmf-dist/source/latex/amsmath/amsmath.dtx index 42f3088867d..7f324700f67 100644 --- a/Master/texmf-dist/source/latex/amsmath/amsmath.dtx +++ b/Master/texmf-dist/source/latex/amsmath/amsmath.dtx @@ -86,7 +86,7 @@ Bug reports can be opened (category \texttt{#1}) at\\% % \end{macrocode} % % \begin{macrocode} -\ProvidesPackage{amsmath}[2020/01/20 v2.17e AMS math features] +\ProvidesPackage{amsmath}[2020/09/23 v2.17i AMS math features] % \end{macrocode} % % \section{Catcode defenses} @@ -466,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} @@ -598,8 +615,14 @@ 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)} % \begin{macrocode} +% +\ifx\directlua\@undefined \DeclareRobustCommand{\frac}[2]{{\begingroup#1\endgroup\@@over#2}} +\else +\DeclareRobustCommand{\frac}[2]{{\Ustack{\begingroup#1\endgroup\@@over#2}}} +\fi \newcommand{\dfrac}{\genfrac{}{}{}0} \newcommand{\tfrac}{\genfrac{}{}{}1} % \end{macrocode} @@ -732,12 +755,12 @@ Foreign command \@backslashchar#1;\MessageBreak \fi } % \end{macrocode} -% +% \changes{v2.17i}{2020/09/23}{added \cs{Ustack} (moved patch from lualatex-math)} % \begin{macrocode} \DeclareRobustCommand{\genfrac}[6]{{% \@mathstyle{#4}% \genfrac@choice o{#1}% -{\begingroup#5\endgroup\ifx @#3@\@@over\else\@@above\fi#3\relax#6}% +{\Ustack {\begingroup#5\endgroup\ifx @#3@\@@over\else\@@above\fi#3\relax#6}}% \genfrac@choice c{#2}% }} % \end{macrocode} @@ -1633,13 +1656,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} @@ -2184,17 +2209,33 @@ Foreign command \@backslashchar#1;\MessageBreak % The minus sign used in constructing these arrow fills is smashed so % that superscripts above the arrows won't be too high. This % primarily affects the \cn{xleftarrow} and \cn{xrightarrow} arrows. -% +% \changes{v2.17h}{2020/08/24}{detect unicode engines and use their commands} % \begin{macrocode} -\mathchardef\std@minus\mathcode`\-\relax -\mathchardef\std@equal\mathcode`\=\relax +\@ifundefined{Umathcode} + {% + \mathchardef\std@minus\mathcode`\-\relax + \mathchardef\std@equal\mathcode`\=\relax + } + {% + \Umathcharnumdef\std@minus\Umathcodenum`\-\relax + \Umathcharnumdef\std@equal\Umathcodenum`\=\relax + } % \end{macrocode} % In case some alternative math fonts are loaded later: % \begin{macrocode} -\AtBeginDocument{% - \mathchardef\std@minus\mathcode`\-\relax - \mathchardef\std@equal\mathcode`\=\relax -} +\@ifundefined{Umathcode} + {% + \AtBeginDocument{% + \mathchardef\std@minus\mathcode`\-\relax + \mathchardef\std@equal\mathcode`\=\relax + }% + } + {% + \AtBeginDocument{% + \Umathcharnumdef\std@minus\Umathcodenum`\-\relax + \Umathcharnumdef\std@equal\Umathcodenum`\=\relax + }% + } % \end{macrocode} % % \begin{macro}{\relbar} @@ -2301,7 +2342,9 @@ Foreign command \@backslashchar#1;\MessageBreak % for use in a subscript or superscript. At the moment the supported % arguments are not the full possibilities of \env{array} but only % |c| or |l| for centered or left-aligned. And only one column. +% \changes{v2.17i}{2020/09/23}{moved to version from lualatex-math for luatex} % \begin{macrocode} +\ifx\directlua\@undefined \newenvironment{subarray}[1]{% % \end{macrocode} % Note: The predecessors of \env{subarray} (\env{Sb} and \env{Sp}, @@ -2340,6 +2383,23 @@ Foreign command \@backslashchar#1;\MessageBreak }{% \crcr\egroup\egroup } +\else +\newenvironment{subarray}[1]{% + \vcenter\bgroup + \Let@ \restore@math@cr \default@tag + \baselineskip \Umathstacknumup \scriptstyle + \advance\baselineskip \Umathstackdenomdown \scriptstyle + \lineskip \Umathstackvgap \scriptstyle + \lineskiplimit \lineskip + \ialign\bgroup\ifx c#1\hfil\fi + \Ustartmath + \m@th\scriptstyle## + \Ustopmath + \hfil\crcr +}{% + \crcr\egroup\egroup +} +\fi % \end{macrocode} % \end{environment} % @@ -3438,7 +3498,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 @@ -3654,6 +3715,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 @@ -3678,7 +3810,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@ @@ -3721,6 +3856,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} @@ -3805,12 +3947,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 } |