diff options
Diffstat (limited to 'macros/latex/contrib/mathtools/mathtools.dtx')
-rw-r--r-- | macros/latex/contrib/mathtools/mathtools.dtx | 222 |
1 files changed, 135 insertions, 87 deletions
diff --git a/macros/latex/contrib/mathtools/mathtools.dtx b/macros/latex/contrib/mathtools/mathtools.dtx index 472c713942..68672cfe35 100644 --- a/macros/latex/contrib/mathtools/mathtools.dtx +++ b/macros/latex/contrib/mathtools/mathtools.dtx @@ -6,11 +6,11 @@ % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either -% version 1.3 of this license or (at your option) any later +% version 1.3c of this license or (at your option) any later % version. The latest version of this license is in % http://www.latex-project.org/lppl.txt -% and version 1.3 or later is part of all distributions of -% LaTeX version 2005/12/01 or later. +% and version 1.3c or later is part of all distributions of +% LaTeX version 2008/05/05 or later. % % This work has the LPPL maintenance status "maintained". % @@ -69,7 +69,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: mathtools 2020/03/24 v1.24} +\Msg{* Package: mathtools 2021/03/18 v1.25} \Msg{************************************************************************} \keepsilent @@ -81,16 +81,16 @@ This is a generated file. Copyright (C) 2002-2011 by Morten Hoegholm Copyright (C) 2012-2019 by Lars Madsen -Copyright (C) 2020 by Lars Madsen, the LaTeX3 project +Copyright (C) 2020- by Lars Madsen, the LaTeX3 project This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either -version 1.3 of this license or (at your option) any later +version 1.3c of this license or (at your option) any later version. The latest version of this license is in http://www.latex-project.org/lppl.txt -and version 1.3 or later is part of all distributions of -LaTeX version 2005/12/01 or later. +and version 1.3c or later is part of all distributions of +LaTeX version 2008/05/04 or later. This work has the LPPL maintenance status "maintained". @@ -133,7 +133,7 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{mathtools.drv}% - [2020/03/24 v1.24 mathematical typesetting tools] + [2021/03/18 v1.25 mathematical typesetting tools] \documentclass{ltxdoc} \IfFileExists{fourier.sty}{\usepackage{fourier}}{} \addtolength\marginparwidth{-25pt} @@ -321,7 +321,7 @@ colorlinks, % % \GetFileInfo{mathtools.drv} % -% \CheckSum{3333} +% \CheckSum{3364} % % \title{The \pkg{mathtools} package\thanks{This file has version number % \fileversion, last revised \filedate.}} @@ -696,15 +696,15 @@ colorlinks, % \SpecialUsageIndex{\smashoperator} % \cs{smashoperator}\oarg{pos}\marg{operator with limits} % \end{codesyntax} -% \FeatureRequest{Lars Madsen}{2004/05/04} -% Above we shoved how to get \LaTeX{} to ignore the width of the -% subscript of an operator. However this approach takes a lot of -% extra typing, especially if you have a wide superscript, meaning -% you have to put in \cs{crampedclap} in both sub- and superscript. -% To make things easier, \pkg{mathtools} provides a -% \cs{smashoperator} command, which simply ignores the width of the -% sub- and superscript. It also takes an optional argument, -% \texttt{l}, \texttt{r}, or \texttt{lr} (default), denoting which +% \FeatureRequest{Lars Madsen}{2004/05/04} Above we showed how to get +% \LaTeX{} to ignore the width of the subscript of an +% operator. However this approach takes a lot of extra typing, +% especially if you have a wide superscript, meaning you have to put +% in \cs{crampedclap} in both sub- and superscript. To make things +% easier, \pkg{mathtools} provides a \cs{smashoperator} command, +% which simply ignores the width of the sub- and superscript. It also +% takes an optional argument, \texttt{l}, \texttt{r}, or \texttt{lr} +% (default, \texttt{rl} is an alias for \texttt{lr}), denoting which % side of the operator should be ignored (smashed). % \begin{verbatim} % \[ @@ -1967,11 +1967,11 @@ colorlinks, % % Thus % \begin{quote} -% \cs{DeclarePairedDelimiter}\marg{cmd}\marg{left_delim}\marg{right_delim} +% \cs{DeclarePairedDelimiter}\marg{cmd}\marg{left_delim}\marg{right_delim} % \end{quote} % is the same thing as % \begin{quote} -% \cs{DeclarePairedDelimiterX}\marg{cmd}\verb|[1]|\marg{left_delim}\marg{right_delim}\verb|{#1}| +% \cs{DeclarePairedDelimiterX}\marg{cmd}\texttt{[1]}\marg{left_delim}\marg{right_delim}\rlap{\texttt{\{\#1\}}} % \end{quote} % % % Let us do some examples. First we want to prepare a macro for inner @@ -2157,7 +2157,9 @@ colorlinks, % '$\sin$' and '('. In some special cases it may be useful to be % able to tinker with the behavior. % \begin{codesyntax} -% \SpecialUsageIndex{\reDeclarePairedDelimiterInnerWrapper}\cs{reDeclarePairedDelimiterInnerWrapper}\marg{macro name}\marg{\textnormal{\texttt{star}} or \textnormal{\texttt{nostarnonscaled}} or \textnormal{\texttt{nostarscaled}}}\marg{code} +% \SpecialUsageIndex{\reDeclarePairedDelimiterInnerWrapper} +% \cs{reDeclarePairedDelimiterInnerWrapper}\marg{macro name}\%\\ +% \qquad \marg{\textnormal{\texttt{star}} or \textnormal{\texttt{nostarnonscaled}} or \textnormal{\texttt{nostarscaled}}}\marg{code} % \end{codesyntax} % Internally several macros are created, including three call backs % that take care of the formatting. There is one internal macro for @@ -2298,6 +2300,7 @@ colorlinks, % \cs{vcentcolon} is a shorthand for such a vertically centered % colon, and can be used as in |$a \vcentcolon= b$| and results in % the desired output: $a \vcentcolon= b$. % for now +% See also the \pkg{colonequals} package. % % Typing \cs{vcentcolon} every time is quite tedious, so one can use % the key \key{centercolon} to make the colon active instead. @@ -2537,8 +2540,8 @@ colorlinks, % been fixed in \LaTeX, this fix will be removed from % \pkg{mathtools}. % -% The \CommentAdded{2015/11/12} fix was added to the \LaTeX{} kernel i 2015. We will continue to -% provide it on older kernels. +% The \CommentAdded{2015/11/12} fix was added to the \LaTeX{} kernel +% in 2015. We will continue to provide it on older kernels. % % \subsection{Spreading equations}\label{sec:spread} % @@ -2755,7 +2758,7 @@ colorlinks, % \verb|\xmathstrut{0.1}| % \end{center} % will give you a new strut where 10\% of the \emph{total height of -% the normal math stut} (\verb|\mathstrut=\mathstrut{0}|) will be +% the normal math stut} (\verb|\mathstrut=\xmathstrut{0}|) will be % added to both \emph{the height} and \emph{the depth} of the % original strut (thus 20\% gets added in total). On the other hand % \begin{center} @@ -2785,14 +2788,14 @@ colorlinks, % \] % \begin{verbatim} % \[ \begin{cases*} -% \frac{\frac{ x-1 }{ x-\sin x} }{ \sqrt{ 1 -x }} & $x >0$ \\ +% \frac{ \frac{ x-1 }{ x-\sin x } }{ \sqrt{ 1-x } } & $x>0$ \\ % 0 & otherwise % \end{cases*} % \qquad\text{vs.}\qquad % \begin{cases*} % \frac{ \frac{ \xmathstrut{0.1} x-1 } -% { \xmathstrut{0.25} x-\sin x} } -% {\xmathstrut{0.4} \sqrt{ 1 -x } } & $x >0$ \\ +% { \xmathstrut{0.25} x-\sin x } } +% {\xmathstrut{0.4} \sqrt{ 1-x } } & $x>0$ \\ % 0 & otherwise % \end{cases*} \] % \end{verbatim} @@ -2808,15 +2811,17 @@ colorlinks, % \begin{verbatim} % \newcommand\vfb[1]{\begingroup\fboxsep=0pt\boxed{\,#1\,}\endgroup} % \[ -% a \vfb{\mathstrut} \ % normal strut -% \vfb{\xmathstrut{0}} \ % just 0 => normal strut -% \vfb{\xmathstrut{0.5} } \ % twice as large 50% + 50% -% \vfb{\xmathstrut{-0.1} } \ % negative gives something smaller -% \vfb{\xmathstrut[0.5]{0}} a % change only the depth +% a +% \vfb{ \mathstrut } \ % normal strut +% \vfb{ \xmathstrut{0} } \ % just 0 => normal strut +% \vfb{ \xmathstrut{0.5} } \ % twice as large 50% + 50% +% \vfb{ \xmathstrut{-0.1} } \ % negative gives something smaller +% \vfb{ \xmathstrut[0.5]{0} } % change only the depth +% a % \] % \end{verbatim} % -- the last box showcases a strut where we have only changed the -% depth of the strut. One can see \verb|\xmathstrut[B]{0}| kind of the +% depth of the strut. One can see \verb|\xmathstrut[0.5]{0}| kind of the % opposite of \verb|\smash[b]{...}|, the former makes the depth larger % and the latter ignores the depth. % @@ -2925,20 +2930,19 @@ colorlinks, % % % \begin{thebibliography}{9} -% \bibitem{Perlis01} -% Alexander R. Perlis, -% \emph{A complement to \cs{smash}, \cs{llap}, and \cs{rlap}}, -% TUGboat 22(4) (2001). -% \bibitem{Ams99} -% American Mathematical Society and Michael Downes, -% \emph{Technical notes on the \pkg{amsmath} package} Version 2.0, -% 1999/10/29. -% (Available from CTAN as file \texttt{technote.tex}.) -% \bibitem{Ams00} -% Frank Mittelbach, Rainer Sch\"opf, Michael Downes, and David M.~Jones, -% \emph{The \pkg{amsmath} package} Version 2.13, -% 2000/07/18. -% (Available from CTAN as file \texttt{amsmath.dtx}.) +% \bibitem{Perlis01} Alexander R. Perlis, \emph{A complement to +% \cs{smash}, \cs{llap}, and \cs{rlap}}, TUGboat 22(4) +% (2001). Available at +% \url{https://www.tug.org/TUGboat/tb22-4/tb72perlS.pdf}. +% \bibitem{Ams99} American Mathematical Society and Michael Downes, +% \emph{Technical notes on the \pkg{amsmath} package}. Version 2.0, +% 1999/10/29. Available via +% \url{http://mirrors.ctan.org/macros/latex/required/amsmath/technote.pdf}. +% \bibitem{Ams00} Frank Mittelbach, Rainer Sch\"opf, Michael Downes, +% David M.~Jones and David Carlisle, \emph{The \pkg{amsmath} +% package}. Version 2.17e, 2020/01/20. Maintained by the \LaTeX3 +% project. Available as file +% \url{http://mirrors.ctan.org/macros/latex/required/amsmath/amsmath.dtx}. % \bibitem{A-W:MG04} % Frank Mittelbach and Michel Goossens. % \emph{The {\LaTeX} Companion}. @@ -2946,28 +2950,25 @@ colorlinks, % Boston, Massachusetts, 2 edition, 2004. % With Johannes Braams, David Carlisle, and Chris Rowley. % -% \bibitem{Carl99} -% David Carlisle, -% \emph{The \pkg{keyval} Package}, -% Version 1.13, 1999/03/16. -% (Available from CTAN as file \texttt{keyval.dtx}.) -% -% \bibitem{Voss:2004} -% Herbert Vo\ss, -% \emph{Math mode}, Version 1.71, -% 2004/07/06. -% (Available from CTAN as file \texttt{Voss-Mathmode.pdf}.) +% \bibitem{Carl99} David Carlisle, \emph{The \pkg{keyval} Package}. +% Version 1.15, 2014/10/28. Available via +% \url{https://ctan.org/pkg/keyval}. +% +% \bibitem{Voss:2004} Herbert Vo\ss, \emph{Math mode}. Version 2.47, +% 2014/01/30. Available as +% \url{http://mirrors.ctan.org/obsolete/info/math/voss/mathmode/Mathmode.pdf}. Please +% note that the author has marked the document as \emph{obsolete}. % % \bibitem{Swanson} % Ellen Swanson, % \emph{Mathematics into type}. % American Mathematical Society, updated edition, 1999. % Updated by Arlene O'Sean and Antoinette Schleyer. Available from -% the AMS at \url{http://www.ams.org/arc/styleguide/mit-2.pdf} +% the AMS at \url{https://www.ams.org/arc/styleguide/mit-2.pdf}. % -% \bibitem{TBT} -% Victor Eijkhout, \emph{\TeX\ by Topic, A Texnician's Reference}, 2007. -% Freely available at \url{https://ctan.org/pkg/texbytopic}. +% \bibitem{TBT} Victor Eijkhout, \emph{\TeX\ by Topic, A Texnician's +% Reference}, 2007. The book is available at +% \url{https://ctan.org/pkg/texbytopic}. % \end{thebibliography} % % @@ -2981,13 +2982,13 @@ colorlinks, % \begin{macrocode} %<*package> \ProvidesPackage{mathtools}% - [2020/03/24 v1.24 mathematical typesetting tools] + [2021/03/18 v1.25 mathematical typesetting tools] % \end{macrocode} % \changes{v1.10}{2011/02/12}{Might as well make sure that we need the % latest version of \texttt{mhsetup}} % \begin{macrocode} \RequirePackage{keyval,calc} -\RequirePackage{mhsetup}[2017/03/31] +\RequirePackage{mhsetup}[2021/03/18] \MHInternalSyntaxOn % \end{macrocode} % \changes{v1.13}{2013/02/11}{Robustifying \cs{(}\cs{)}\cs{[}\cs{]}} @@ -4158,7 +4159,13 @@ colorlinks, \lineskip\thr@@\fontdimen8 \scriptfont\thr@@ \lineskiplimit\lineskip \ialign\bgroup\ifx c##1\hfil\fi - $\m@th\scriptstyle\kern-\nulldelimiterspace\radical\z@{####}$ +% \end{macrocode} +% \changes{v1.25}{2021/03/18}{use \cs{MT_cramped_internal:Nn} instead, +% see issue \#17} +% Here we should use the proper cramped internal macro +% \begin{macrocode} + %% $\m@th\scriptstyle\kern-\nulldelimiterspace\radical\z@{####}$ + \span\MT_cramped_internal:Nn \scriptstyle {####}% \hfil\crcr }{% \crcr\egroup\egroup @@ -4728,21 +4735,24 @@ colorlinks, % both columns, while \env{dcases*} has text in the second column. % \changes{v1.08}{2010/06/10}{changed to match the change in % \cs{newcases} plus added rcases and drcases} +% \changes{v1.25}{2021/01/14}{Replaced \texttt{\{\#\#\}} by +% \texttt{\#\#}, otherwise one cannot counteract the \cs{hfil} in the +% definition with a \cs{hfil(l)} in a cell. Related to issue \#20 and https://tex.stackexchange.com/a/252412/3929} % \begin{macrocode} \newcases{dcases}{\quad}{% - $\m@th\displaystyle{##}$\hfil}{$\m@th\displaystyle{##}$\hfil}{\lbrace}{.} + $\m@th\displaystyle##$\hfil}{$\m@th\displaystyle##$\hfil}{\lbrace}{.} \newcases{dcases*}{\quad}{% - $\m@th\displaystyle{##}$\hfil}{{##}\hfil}{\lbrace}{.} + $\m@th\displaystyle##$\hfil}{##\hfil}{\lbrace}{.} \newcases{rcases}{\quad}{% - $\m@th{##}$\hfil}{$\m@th{##}$\hfil}{.}{\rbrace} + $\m@th##$\hfil}{$\m@th##$\hfil}{.}{\rbrace} \newcases{rcases*}{\quad}{% - $\m@th{##}$\hfil}{{##}\hfil}{.}{\rbrace} + $\m@th##$\hfil}{##\hfil}{.}{\rbrace} \newcases{drcases}{\quad}{% - $\m@th\displaystyle{##}$\hfil}{$\m@th\displaystyle{##}$\hfil}{.}{\rbrace} + $\m@th\displaystyle##$\hfil}{$\m@th\displaystyle##$\hfil}{.}{\rbrace} \newcases{drcases*}{\quad}{% - $\m@th\displaystyle{##}$\hfil}{{##}\hfil}{.}{\rbrace} + $\m@th\displaystyle##$\hfil}{##\hfil}{.}{\rbrace} \newcases{cases*}{\quad}{% - $\m@th{##}$\hfil}{{##}\hfil}{\lbrace}{.} + $\m@th##$\hfil}{##\hfil}{\lbrace}{.} % \end{macrocode} % \end{environment} % \end{environment} @@ -4913,12 +4923,19 @@ colorlinks, % specialized commands \cs{MT_smop_smash_l:NNNNN}, % \cs{MT_smop_smash_r:NNNNN}, or the default % \cs{MT_smop_smash_lr:NNNNN}. +% \changes{v1.25}{2021/03/04}{Verify that opt arg corresponds to +% something predefined} % \begin{macrocode} \newcommand*\smashoperator[2][lr]{ - \def\MT_smop_use:NNNNN {\@nameuse{MT_smop_smash_#1:NNNNN}} - \toks@{#2} - \expandafter\MT_smop_get_args:wwwNnNn + \@ifundefined{MT_smop_smash_#1:NNNNN}{ + \PackageError{mathtools}{Opt~ arg~ '#1'~ for~ \@backslashchar smashoperator~ + is~ not~ supported.\MessageBreak Use~ l,~r~or~lr~ (default)}{} + }{ + \def\MT_smop_use:NNNNN {\@nameuse{MT_smop_smash_#1:NNNNN}} + \toks@{#2} + \expandafter\MT_smop_get_args:wwwNnNn \the\toks@\@nil\@nil\@nil\@nil\@nil\@nil\@@nil + } } % \end{macrocode} % \end{macro} @@ -5119,12 +5136,17 @@ colorlinks, } % \end{macrocode} % The `lr' variant +% \changes{v1.25}{2021/03/04}{add `rl' as an alias for `lr'} % \begin{macrocode} \def\MT_smop_smash_lr:NNNNN #1#2#3#4#5{ \MT_smop_needed_args:NNNNN #1#2#3#4#5 } % \end{macrocode} -% +% Add `rl' as an alias for `lr' +% \begin{macrocode} +\MH_let:NwN \MT_smop_smash_rl:NNNNN \MT_smop_smash_lr:NNNNN +% \end{macrocode} +% % % \subsection{Adjusting limits} % @@ -5777,24 +5799,26 @@ colorlinks, % \begin{macro}{\MT_mathclap:Nn} % First we'll \cs{provide} those macros (they are so simple that I % think other packages might define them as well). +% \changes{v1.15}{2021/03/04}{Add \cs{relax} before the \cs{ifx}'s to +% prevent corner case premature expansions} % \begin{macrocode} \providecommand*\clap[1]{\hb@xt@\z@{\hss#1\hss}} \providecommand*\mathllap[1][\@empty]{ - \ifx\@empty#1\@empty + \relax\ifx\@empty#1\@empty \expandafter \mathpalette \expandafter \MT_mathllap:Nn \else \expandafter \MT_mathllap:Nn \expandafter #1 \fi } \providecommand*\mathrlap[1][\@empty]{ - \ifx\@empty#1\@empty + \relax\ifx\@empty#1\@empty \expandafter \mathpalette \expandafter \MT_mathrlap:Nn \else \expandafter \MT_mathrlap:Nn \expandafter #1 \fi } \providecommand*\mathclap[1][\@empty]{ - \ifx\@empty#1\@empty + \relax\ifx\@empty#1\@empty \expandafter \mathpalette \expandafter \MT_mathclap:Nn \else \expandafter \MT_mathclap:Nn \expandafter #1 @@ -5881,9 +5905,11 @@ colorlinks, % % \begin{macro}{\cramped} % Make sure the expansion is timed correctly. +% \changes{v1.15}{2021/03/04}{Add \cs{relax} before the \cs{ifx}'s to +% prevent corner case premature expansions} % \begin{macrocode} \providecommand*\cramped[1][\@empty]{ - \ifx\@empty#1\@empty + \relax\ifx\@empty#1\@empty \expandafter \mathpalette \expandafter \MT_cramped_internal:Nn \else \expandafter \MT_cramped_internal:Nn \expandafter #1 @@ -5898,8 +5924,14 @@ colorlinks, % \end{macrocode} % Create a box containing the math and force a cramped style by % issuing a non-existing radical. +% \changes{v1.25}{2020/12/16}{Don't set \cs{nulldelimiterspace} to +% zero, back kern intead, solves issue \#18} +% \changes{v1.25}{2021/03/18}{placed \cs{sbox}\cs{z@} by +% \cs{setbox}\cs{z@}\cs{hbox} to better handle expansion in +% \env{crampedsubarray}, see issue \#17} % \begin{macrocode} - \sbox\z@{$\m@th#1\nulldelimiterspace=\z@\radical\z@{#2}$} + %% \sbox\z@{$\m@th#1\kern-\nulldelimiterspace\radical\z@{#2}$} + \setbox\z@\hbox{$\m@th#1\kern-\nulldelimiterspace\radical\z@{#2}$} % \end{macrocode} % Then make sure the height is correct. % \begin{macrocode} @@ -5919,7 +5951,14 @@ colorlinks, 3 \fi \advance\dimen@-\ht\z@ \ht\z@=-\dimen@ - \box\z@ +% \end{macrocode} +% Leave vertical mode before typesetting the box and add a +% \texttt{\{\}} in front to gard against unnecessary reboxing +% \changes{v1.25}{2021/03/04}{Added vmode protection and reboxing +% gard, see issue \#19} +% \begin{macrocode} + \ifvmode\leavevmode\fi + {}\box\z@ } % \end{macrocode} % \end{macro} @@ -5934,9 +5973,11 @@ colorlinks, % \begin{macro}{\crampedrlap} % \begin{macro}{\MT_cramped_rlap_internal:Nn} % Cramped versions of \cs{mathXlap} (for speed). Made by the author. +% \changes{v1.15}{2021/03/04}{Add \cs{relax} before the \cs{ifx}'s to +% prevent corner case premature expansions} % \begin{macrocode} \providecommand*\crampedllap[1][\@empty]{ - \ifx\@empty#1\@empty + \relax\ifx\@empty#1\@empty \expandafter \mathpalette \expandafter \MT_cramped_llap_internal:Nn \else \expandafter \MT_cramped_llap_internal:Nn \expandafter #1 @@ -5946,7 +5987,7 @@ colorlinks, {}\llap{\MT_cramped_internal:Nn #1{#2}} } \providecommand*\crampedclap[1][\@empty]{ - \ifx\@empty#1\@empty + \relax\ifx\@empty#1\@empty \expandafter \mathpalette \expandafter \MT_cramped_clap_internal:Nn \else \expandafter \MT_cramped_clap_internal:Nn \expandafter #1 @@ -5956,7 +5997,7 @@ colorlinks, {}\clap{\MT_cramped_internal:Nn #1{#2}} } \providecommand*\crampedrlap[1][\@empty]{ - \ifx\@empty#1\@empty + \relax\ifx\@empty#1\@empty \expandafter \mathpalette \expandafter \MT_cramped_rlap_internal:Nn \else \expandafter \MT_cramped_rlap_internal:Nn \expandafter #1 @@ -5992,7 +6033,14 @@ colorlinks, \lineskip\thr@@\fontdimen8 \scriptfont\thr@@ \lineskiplimit\lineskip \ialign\bgroup\ifx c#1\hfil\fi - $\m@th\scriptstyle\kern-\nulldelimiterspace\radical\z@{##}$% <-- changed line +% \end{macrocode} +% Though here we ought to use the proper cramped internal macro, as +% otherwise there will be a slight difference in vertical spacing +% \changes{v1.25}{2021/03/18}{Added \cs{MT_cramped_internal:Nn}, see +% issue \#17} +% \begin{macrocode} + %%$\m@th\scriptstyle\kern-\nulldelimiterspace\radical\z@{##}$% <-- changed line + \span\MT_cramped_internal:Nn \scriptstyle {##}% \hfil\crcr% }{% \crcr\egroup\egroup |