diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/mathtools/mathtools.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/mathtools/mathtools.dtx | 842 |
1 files changed, 537 insertions, 305 deletions
diff --git a/Master/texmf-dist/source/latex/mathtools/mathtools.dtx b/Master/texmf-dist/source/latex/mathtools/mathtools.dtx index 2405eba3b23..2aece4d7e72 100644 --- a/Master/texmf-dist/source/latex/mathtools/mathtools.dtx +++ b/Master/texmf-dist/source/latex/mathtools/mathtools.dtx @@ -68,7 +68,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: mathtools 2015/11/12 v1.18} +\Msg{* Package: mathtools 2017/05/24 v1.19} \Msg{************************************************************************} \keepsilent @@ -131,7 +131,7 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{mathtools.drv}% - [2015/11/12 v1.18 mathematical typesetting tools] + [2017/05/24 v1.19 mathematical typesetting tools] \documentclass{ltxdoc} \IfFileExists{fourier.sty}{\usepackage{fourier}}{} \addtolength\marginparwidth{-25pt} @@ -267,7 +267,9 @@ and the derived files \let\MTtheindex\theindex \def\theindex{\MTtheindex\MakePrivateLetters} -\usepackage[final,hyperindex=false]{hyperref} +\usepackage[final, +hyperindex=false, +]{hyperref} \renewcommand*\usage[1]{\textit{\hyperpage{#1}}} \OnlyDescription @@ -277,11 +279,13 @@ and the derived files %</driver> % \fi % +% \changes{v1.19}{2017/03/31}{Updated to match some macro renaming in +% \pkg{mhsetup}} % \changes{v1.0}{2004/07/26}{Initial release} % % \GetFileInfo{mathtools.drv} % -% \CheckSum{3174} +% \CheckSum{3146} % % \title{The \pkg{mathtools} package\thanks{This file has version number % \fileversion, last revised \filedate.}} @@ -292,10 +296,10 @@ and the derived files % \maketitle % % \begin{abstract} -% The \pkg{mathtools} package is an extension package to +% \noindent The \pkg{mathtools} package is an extension package to % \pkg{amsmath}. There are two things on \pkg{mathtools}' agenda: -% 1)~correct various bugs/defeciencies in \pkg{amsmath} until -% these are fixed by the \AmS{} and 2)~provide useful tools +% (1)~correct various bugs/defeciencies in \pkg{amsmath} until +% these are fixed by the \AmS{} and (2)~provide useful tools % for mathematical typesetting, be it a small macro for % typesetting a prescript or an underbracket, or entirely new % display math constructs such as a \env{multlined} environment. @@ -1357,6 +1361,11 @@ and the derived files % } % \end{verbatim} % +% \medskip\noindent +% \textbf{Caveat:} +% \CommentAdded{2017/05/22} +% \cs{shoveleft} and \cs{shoveright} does not work as expected if +% used as the last line in \env{multlined}. % % % \subsubsection{More \env{cases}-like environments} @@ -1606,7 +1615,7 @@ and the derived files % \end{alignat*} % % -% \subsubsection{Centered \cs{vdots}} +% \subsubsection{Centered \texorpdfstring{\cs{vdots}}{\textbackslash vdots}} % % If one want to mark a vertical continuation, there is % the \verb?\vdots? command, but combine this with an alignment and @@ -1774,6 +1783,7 @@ and the derived files % \textbf{Tip:} \cs{intertext} and \cs{shortintertext} also works % within \env{gather}. % +% % \subsection{Paired delimiters} % % @@ -2012,7 +2022,7 @@ and the derived files % \end{verbatim} % Thus giving support for \verb|\Prob{A \given B}|. % -% \medskip\noindent\textbf{Note:} As the number of arguments increase +% \medskip\noindent\textbf{Note 1:} As the number of arguments increase % the \cs{DeclarePairedDelimiter...} macros become hard for users to % understand. A key-value interface would be better. This is planed % for a future release. In @@ -2025,6 +2035,12 @@ and the derived files % obvious how to get \pkg{xparse} to support \verb|[3]| for the number % of arguments. We will consider this for a future release. % +% \medskip\noindent\textbf{Note 2:} If you want to define your own +% manual scaler macros, it is importent that you besides \cs{foo} also +% defines \cs{fool} and \cs{foor}. When a scaler is specified, in say +% \cs{abs[\cs{big}]}\marg{arg}, we actually use \cs{bigl} and \cs{bigr}. +% +% % \subsubsection{Expert use} % % Within the starred version of \cs{DeclarePairedDelimiter} and @@ -2035,26 +2051,44 @@ and the derived files % '$\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{nostar}}}\marg{code} +% \SpecialUsageIndex{\reDeclarePairedDelimiterInnerWrapper}\cs{reDeclarePairedDelimiterInnerWrapper}\marg{macro name}\marg{\textnormal{\texttt{star}} or \textnormal{\texttt{nostarnonscaled}} or \textnormal{\texttt{nostarscaled}}}\marg{code} % \end{codesyntax} -% Internally several macros are created, including two call backs +% Internally several macros are created, including three call backs % that take care of the formatting. There is one internal macro for -% the starred version, labeled \texttt{star}, the other one is -% labeled \texttt{nostar}. Within \meta{code}, \texttt{\#1} will be -% replaced by the scaled left fence, \texttt{\#3} the corresponding -% scaled right fence, and \texttt{\#2} the stuff in between. For -% example, here is how one might turn the content into \cs{mathinner}: +% the starred version, labeled \texttt{star}, the other two are +% labeled \texttt{nostarnonscaled} and \texttt{nostarscaled}. Within +% \meta{code}, \texttt{\#1} will be replaced by the (scaled) left +% fence, \texttt{\#3} the corresponding (scaled) right fence, and +% \texttt{\#2} the stuff in between. For example, here is how one +% might turn the content into \cs{mathinner}: % \begin{verbatim} % \DeclarePairedDelimiter\abs\lvert\rvert % \reDeclarePairedDelimiterInnerWrapper\abs{star}{#1#2#3} -% \reDeclarePairedDelimiterInnerWrapper\abs{nostar}{\mathinner{#1#2#3}} +% \reDeclarePairedDelimiterInnerWrapper\abs{nostarnonscaled}{\mathinner{#1#2#3}} +% \reDeclarePairedDelimiterInnerWrapper\abs{nostarscaled}{\mathinner{#1#2#3}} % \end{verbatim} % The default values for the call backs corresponds to % \begin{verbatim} -% star: \mathopen{}\mathclose\bgroup #1#2\aftergroup\egroup #3 -% nostar: \mathopen{#1}#2\mathclose{#3} +% star: \mathopen{}\mathclose\bgroup #1#2\aftergroup\egroup #3 +% nostarnonscaled: \mathopen#1#2\mathclose#3 +% nostarscaled: \mathopen{#1}#2\mathclose{#3} % \end{verbatim} -% +% The two \texttt{nostar...} versions look the same, but they are +% not. In most (math) fonts, the first item in this list will be +% different from the rest (the superscript sits +% higher).\footnote{Interestingly it dod not show up in the font of +% this manual, which uses the \pkg{fourier} font set.} +% \begin{verbatim} +% \mathclose{\rvert}^2\mathclose\rvert^2\rvert^2 +% \end{verbatim} +% +% +% \bigskip\noindent \textbf{Breaking change:} Prior to May 2017, we +% used two wrappers, the other named \texttt{nostar}. As of May 2017 +% \texttt{nostar} has been split into \texttt{nostarnonscaled} and +% \texttt{nostarscaled} and \texttt{nostar} alone is no longer +% supported (will give an error). +% % \bigskip\noindent \textbf{Note:} Since we are using macros to add % the \verb|\left...\right| constructions around some body, it % \emph{is} (in principle) possible to make such a construction @@ -2679,13 +2713,13 @@ and the derived files % \begin{macrocode} %<*package> \ProvidesPackage{mathtools}% - [2015/11/12 v1.18 mathematical typesetting tools] + [2017/05/24 v1.19 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}[2010/01/21] +\RequirePackage{mhsetup}[2017/03/31] \MHInternalSyntaxOn % \end{macrocode} % \changes{v1.13}{2013/02/11}{Robustifying \cs{(}\cs{)}\cs{[}\cs{]}} @@ -2811,7 +2845,7 @@ and the derived files % We have to turn off the new syntax when \pkg{amstext} is loaded. % \begin{macrocode} \MHInternalSyntaxOff -\RequirePackage{amsmath}[2000/07/18] +\RequirePackage{amsmath}[2016/11/05] \MHInternalSyntaxOn \AtEndOfPackage{\MHInternalSyntaxOff} % \end{macrocode} @@ -2968,14 +3002,15 @@ and the derived files % so do not let the tag have width zero. Rememeber % \cs{@safe@activestrue/false} in order to handle active chars in labels. % \changes{v1.12}{2012/04/24}{Added \cs{@safe@activestrue/false}} +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} - \if_meaning:NN \df@label\@empty + \MH_if_meaning:NN \df@label\@empty \MH_if_boolean:nTF {manual_tag}% this was \MH_if_boolean:nT before { \MH_if_boolean:nTF {show_manual_tags} { \MT_prev_tagform:n {#1} } { \stepcounter{equation} } }{\kern1sp}% this last {\kern1sp} is new. - \else: + \MH_else: \MH_if_boolean:nTF {manual_tag} { \MH_if_boolean:nTF {show_manual_tags} { \MT_prev_tagform:n {#1} } @@ -2988,6 +3023,7 @@ and the derived files % referred to. % \changes{v1.12}{2011/06/08}{Added the falsification of manual tag % when show manual tags is off and maual tag is not referred to} +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} { \global\MH_set_boolean_F:n {manual_tag} } { \MT_prev_tagform:n {#1} } @@ -3001,7 +3037,7 @@ and the derived files { \refstepcounter{equation}\MT_prev_tagform:n {#1} } \@safe@activesfalse } - \fi: + \MH_fi: \global\MH_set_boolean_T:n {raw_maketag} } % \end{macrocode} @@ -3009,11 +3045,12 @@ and the derived files % \begin{macro}{\MT_extended_maketag:n} % The extended version of \cs{maketag@@@}. % \changes{v1.12}{2012/04/24}{Added \cs{@safe@activestrue/false}} +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} \def\MT_extended_maketag:n #1{ \ifx\df@label\@empty \MT_maketag:n {#1} - \else: + \MH_else: \MH_if_boolean:nTF {raw_maketag} { \MH_if_boolean:nTF {show_manual_tags} @@ -3026,7 +3063,7 @@ and the derived files } } { \MT_maketag:n {#1} } - \fi: + \MH_fi: % \end{macrocode} % As this function is always called we let it set the marker for a manual % tag false when exiting (well actually not true, see above). @@ -3084,15 +3121,16 @@ and the derived files \newcommand*\MT@newlabel[1]{ \global\@namedef{MT_r_#1}{} } % \end{macrocode} % \end{macro} +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} \MH_new_boolean:n {show_only_refs} \MH_new_boolean:n {show_manual_tags} \define@key{\MT_options_name:}{showmanualtags}[true]{ - \@ifundefined{boolean_show_manual_tags_#1:} + \@ifundefined{MH_boolean_show_manual_tags_#1:} { \MT_true_false_error: - \@nameuse{boolean_show_manual_tags_false:} + \@nameuse{MH_boolean_show_manual_tags_false:} } - { \@nameuse{boolean_show_manual_tags_#1:} } + { \@nameuse{MH_boolean_show_manual_tags_#1:} } } % \end{macrocode} % \begin{macro}{\MT_showonlyrefs_true:} @@ -3158,17 +3196,19 @@ and the derived files % equation number where we don't want it. This is probably not needed % since \cs{nonumber} is unnecessary when \key{showonlyrefs} is in % effect, but now you can use it with old documents as well. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} \renewcommand\nonumber{ \if@eqnsw - \if_meaning:NN \incr@eqnum\@empty + \MH_if_meaning:NN \incr@eqnum\@empty % \end{macrocode} % Only subtract the number if |show_only_refs| is false. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} \MH_if_boolean:nF {show_only_refs} {\addtocounter{equation}\m@ne} - \fi: - \fi: + \MH_fi: + \MH_fi: \MH_let:NwN \print@eqnum\@empty \MH_let:NwN \incr@eqnum\@empty \global\@eqnswfalse } @@ -3186,7 +3226,7 @@ and the derived files % to \cs{nocite}. % \begin{macrocode} \MHInternalSyntaxOff -\newcommand\noeqref[1]{\@bsphack +\newcommand\noeqref[1]{\@bsphack% \@for\@tempa:=#1\do{% \@safe@activestrue% \edef\@tempa{\expandafter\@firstofone\@tempa}% @@ -3197,7 +3237,7 @@ and the derived files }{}% \if@filesw\protected@write\@auxout{}% {\string\MT@newlabel{\@tempa}}\fi% - \@safe@activesfalse} + \@safe@activesfalse}% \@esphack} % \end{macrocode} @@ -3585,25 +3625,26 @@ and the derived files % \begin{macro}{\MT_test_for_tcb_other:nnnnn} % This tests if the token(s) is/are equal to either t, c, or~b, or % something entirely different. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} \newcommand*\MT_test_for_tcb_other:nnnnn [1]{ - \if:w t#1\relax + \MH_if:w t#1\relax \expandafter\MH_use_choice_i:nnnn - \else: - \if:w c#1\relax + \MH_else: + \MH_if:w c#1\relax \expandafter\expandafter\expandafter\MH_use_choice_ii:nnnn - \else: - \if:w b#1\relax + \MH_else: + \MH_if:w b#1\relax \expandafter\expandafter\expandafter \expandafter\expandafter\expandafter\expandafter \MH_use_choice_iii:nnnn - \else: + \MH_else: \expandafter\expandafter\expandafter \expandafter\expandafter\expandafter\expandafter \MH_use_choice_iv:nnnn - \fi: - \fi: - \fi: + \MH_fi: + \MH_fi: + \MH_fi: } % \end{macrocode} % \end{macro} @@ -3612,20 +3653,23 @@ and the derived files % \textbf{BUG:} \cs{baselineskip} is zero inside an array or matrix, % thus in those cases the line is \emph{not} invisible. % \changes{v1.14}{2014/05/21}{Added -\cs{jot}} +% \changes{v1.19}{2017/05/24}{Removed -\cs{jot} again, do not +% remember why we added it in the first place} % \begin{macrocode} \def\MT_mult_invisible_line: { \crcr \global\MH_set_boolean_F:n {mult_firstline} \hbox to \l_MT_multwidth_dim{}\crcr - \noalign{\vskip-\baselineskip \vskip-\jot \vskip-\normallineskip} + \noalign{\vskip-\baselineskip \vskip-\normallineskip} } % \end{macrocode} % \end{macro} % \begin{macro}{\MT_mult_mathcr_atat:w} % The normal \cs{math@cr@@} with our hooks. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} \def\MT_mult_mathcr_atat:w [#1]{% - \if_num:w 0=`{\fi: \iffalse}\fi: + \MH_if_num:w 0=`{\MH_fi: \iffalse}\MH_fi: \MH_if_boolean:nT {mult_firstline}{ \kern\l_MT_mult_left_fdim \MT_mult_invisible_line: @@ -3633,9 +3677,9 @@ and the derived files \crcr \noalign{\vskip#1\relax} \global\advance\g_MT_multlinerow_int\@ne - \if_num:w \g_MT_multlinerow_int=\l_MT_multline_lastline_fint + \MH_if_num:w \g_MT_multlinerow_int=\l_MT_multline_lastline_fint \MH_let:NwN \math@cr@@\MT_mult_last_mathcr:w - \fi: + \MH_fi: } % \end{macrocode} % \end{macro} @@ -3643,9 +3687,10 @@ and the derived files % The special case where there is a two-line \env{multlined}. We % insert the first kern, then the invisible line of the desired % width, the optional vertical space and then the last kern. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} \def\MT_mult_firstandlast_mathcr:w [#1]{% - \if_num:w 0=`{\fi: \iffalse}\fi: + \MH_if_num:w 0=`{\MH_fi: \iffalse}\MH_fi: \kern\l_MT_mult_left_fdim \MT_mult_invisible_line: \noalign{\vskip#1\relax} @@ -3655,9 +3700,10 @@ and the derived files % \end{macro} % \begin{macro}{\MT_mult_last_mathcr:w} % The normal last \cs{math@cr@@} which inserts the last kern. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} \def\MT_mult_last_mathcr:w [#1]{ - \if_num:w 0=`{\fi: \iffalse}\fi:\math@cr@@@ + \MH_if_num:w 0=`{\MH_fi: \iffalse}\MH_fi:\math@cr@@@ \noalign{\vskip#1\relax} \kern\l_MT_mult_right_fdim} % \end{macrocode} @@ -3700,9 +3746,11 @@ and the derived files % \begin{macro}{\MT_mult_internal:n} % \changes{v1.01a}{2004/10/10}{Added Ord atom to beginning of each line} % The real internal \env{multlined}. +% \changes{v1.19}{2017/05/22}{Added \cs{alignedspace@left} instead of +% \cs{null}\cs{,}} % \begin{macrocode} \newcommand*\MT_mult_internal:n [1]{ - \MH_if_boolean:nF {outer_mult}{\null\,} + \MH_if_boolean:nF {outer_mult}{\alignedspace@left} %<-- requires amsmath 2016/11/05 \MT_next: \bgroup % \end{macrocode} @@ -3727,18 +3775,20 @@ and the derived files \MT_measure_mult:n {#1} % \end{macrocode} % Make sure the box is wide enough. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} - \if_dim:w \l_MT_multwidth_dim<\l_MT_multline_measure_fdim + \MH_if_dim:w \l_MT_multwidth_dim<\l_MT_multline_measure_fdim \MH_setlength:dn \l_MT_multwidth_dim{\l_MT_multline_measure_fdim} \fi \MH_set_boolean_T:n {mult_firstline} % \end{macrocode} % Tricky bit: If we only encountered one \cmd{\\} then use a very % special \cs{math@cr@@} that inserts everything needed. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} - \if_num:w \l_MT_multline_lastline_fint=\@ne + \MH_if_num:w \l_MT_multline_lastline_fint=\@ne \MH_let:NwN \math@cr@@ \MT_mult_firstandlast_mathcr:w - \fi: + \MH_fi: % \end{macrocode} % Do the typesetting. % \begin{macrocode} @@ -3779,6 +3829,7 @@ and the derived files % \end{macro} % \begin{macro}{\MT_multlined_second_arg:w} % Scan for a second optional argument. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} \MaybeMHPrecedingSpacesOff \newcommand*\MT_multlined_second_arg:w [1][\@empty]{ @@ -3787,10 +3838,10 @@ and the derived files {\def\MT_mult_default_pos:{#1}} {\def\MT_mult_default_pos:{#1}} { - \if_meaning:NN \@empty#1\@empty - \else: + \MH_if_meaning:NN \@empty#1\@empty + \MH_else: \setlength \l_MT_multwidth_dim{#1} - \fi: + \MH_fi: } \MT_start_mult:N \MT_mult_default_pos: } @@ -3812,7 +3863,7 @@ and the derived files \renewenvironment{subarray}[1]{% \vcenter\bgroup \Let@ \restore@math@cr \default@tag - \let\math@cr@@\AMS@math@cr@@ + \let\math@cr@@\AMS@math@cr@@ % <--- the fix \baselineskip\fontdimen10 \scriptfont\tw@ \advance\baselineskip\fontdimen12 \scriptfont\tw@ \lineskip\thr@@\fontdimen8 \scriptfont\thr@@ @@ -3830,6 +3881,7 @@ and the derived files % \begin{environment}{multlined} % The user environment. Scan for an optional argument. % \changes{v1.18}{2015/11/12}{Added \cs{MultlinedHook}} +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} \newenvironment{multlined}[1][] {\MH_group_align_safe_begin: @@ -3839,10 +3891,10 @@ and the derived files {\def\MT_mult_default_pos:{#1}} {\def\MT_mult_default_pos:{#1}} { - \if_meaning:NN \@empty#1\@empty - \else: + \MH_if_meaning:NN \@empty#1\@empty + \MH_else: \setlength \l_MT_multwidth_dim{#1} - \fi: + \MH_fi: } \MT_multlined_second_arg:w } @@ -3897,30 +3949,81 @@ and the derived files \@namedef{MT_delim_\MH_cs_to_str:N #1 _star_wrapper:nnn}##1##2##3{ \mathopen{}\mathclose\bgroup ##1 ##2 \aftergroup\egroup ##3 } - \@namedef{MT_delim_\MH_cs_to_str:N #1 _nostar_wrapper:nnn}##1##2##3{ +% \end{macrocode} +% Turns out that there is a difference between \verb|\mathclose{)}| +% and \verb|\mathclose)| (placement of for example superscript), so instead of two wrappers, we need three. +% \changes{v1.19}{2017/05/22}{added \cs{...nostarnonscaled..} wrapper} +% \changes{v1.19}{2017/05/22}{renamed \cs{...nostar..} to \cs{...nostarscaled..} } +% \begin{macrocode} + \@namedef{MT_delim_\MH_cs_to_str:N #1 _nostarscaled_wrapper:nnn}##1##2##3{ \mathopen{##1}##2\mathclose{##3} } + \@namedef{MT_delim_\MH_cs_to_str:N #1 _nostarnonscaled_wrapper:nnn}##1##2##3{ + \mathopen##1##2\mathclose##3 + } } % \end{macrocode} % \end{macro} % % \begin{macro}{\reDeclarePairedDelimiterInnerWrapper} -% Macro enabling the user to alter an existing call back. Note that -% currently no checks are performed. First argument is the name of -% the macro we are altering (as defined via \cs{DeclarePaired...}), -% the second is \texttt{star} or \texttt{nostar}. In the last +% Macro enabling the user to alter an existing call back. First +% argument is the name of the macro we are altering (as defined via +% \cs{DeclarePaired...}), the second is \texttt{star}, +% \texttt{nostarnonscaled} or \texttt{nostarscaled}. In the last % argument \texttt{\#1} and \texttt{\#3} respectively refer to the -% scaled fences and \texttt{\#3} refer to whatever come between. +% scaled fences and \texttt{\#2} refer to whatever come between. +% \changes{v1.19}{2017/05/23}{Added a test and error} % \begin{macrocode} \newcommand\reDeclarePairedDelimiterInnerWrapper[3]{ - \@namedef{MT_delim_\MH_cs_to_str:N #1 _ #2 _wrapper:nnn}##1##2##3{ - #3 + \@ifundefined{MT_delim_\MH_cs_to_str:N #1 _ #2 _wrapper:nnn}{ + \PackageError{mathtools}{ + Wrapper~not~found~for~\string#1~and~option~'#2'.\MessageBreak + Either~\string#1~is~ not~ defined,~or~ you~ are~using~ the~ + \MessageBreak + 'nostar'~ option,~which~ is~ no~ longer~ supported.~ + \MessageBreak + Please~ use~ 'nostarnonscaled'~ or~ 'nostarscaled~ + \MessageBreak instead.~ + }{See the manual} + }{ + \@namedef{MT_delim_\MH_cs_to_str:N #1 _ #2 _wrapper:nnn}##1##2##3{ + #3 + } } } % \end{macrocode} % +% \begin{macro}{\MT_etb_ifdefempty_x:nnn} +% \begin{macro}{\MT_etb_ifblank:nnn} +% \changes{v1.19}{2017/05/23}{Added so we can test for empty args} +% This is a copy of \cs{etb@ifdefempty} (it is \emph{not} the same +% as \cs{ifdefempty}) and \cs{ifblank} from \pkg{etoolbox}, +% currently we do not want to make \pkg{etoolbox} a requirement, +% that may change in the future. We need a reliable method to check +% whether a macro is blank or not (including spaces). +% \begin{macrocode} +\def\MT_etb_ifdefempty_x:nnn #1{ + \expandafter\expandafter\expandafter + \MT_etb_ifblank:nnn + \expandafter\expandafter\expandafter{% + \expandafter\strip@prefix\meaning#1} +} +\def\MT_etb_ifblank:nnn #1{ + \expandafter\ifx\expandafter\relax\detokenize\expandafter{\@gobble#1?}\relax + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi +} + + +% \end{macrocode} +% \end{macro} +% \end{macro} +% % +% % \end{macro} % \begin{macro}{\DeclarePairedDelimiter} % \changes{v1.06}{2008/08/01}{Made user command robust} @@ -3934,12 +4037,11 @@ and the derived files % before the delimiters, wrapped in a callback function. % \changes{1.08e}{2010/09/02}{`Fixed' \cs{left}\dots\cs{right} bad spacing} % \changes{1.08e}{2010/09/14}{redid the \cs{left}\dots\cs{right} fix, -% see \cs{DeclarePairedDelimiterX} for details.} +% see \cs{DeclarePairedDelimiterXPP} for details.} % \changes{v1.13}{2012/05/10}{Using call back instead} % \begin{macrocode} - \MT_delim_default_inner_wrappers:n{#1} + \MT_delim_default_inner_wrappers:n{#1} % define the wrappers \@namedef{MT_delim_\MH_cs_to_str:N #1 _star:}##1 - %{\mathopen{}\mathclose\bgroup\left#2 ##1 \aftergroup\egroup\right #3}% { \@nameuse{MT_delim_\MH_cs_to_str:N #1 _star_wrapper:nnn}% {\left#2}{##1}{\right#3} }% % \end{macrocode} @@ -3955,13 +4057,39 @@ and the derived files % With the default optional argument we wind up with \cs{relax}, % else we get \cs{biggr} and \cs{biggl} etc. % \changes{v1.13}{2012/05/10}{Using call back instead} -% \begin{macrocode} - %\mathopen{\@nameuse {\MH_cs_to_str:N ##1 l} #2} ##2 - %\mathclose{\@nameuse {\MH_cs_to_str:N ##1 r} #3}} - \@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostar_wrapper:nnn}% - {\@nameuse {\MH_cs_to_str:N ##1 l} #2} - {##2} - {\@nameuse {\MH_cs_to_str:N ##1 r} #3} +% \changes{v1.19}{2017/05/23}{Split the wrappers in two, so know +% \cs{}\cs{@gobble} is now only used to check if the optional +% argument is empty.} +% \begin{macrocode} + \def\@tempa{\\@gobble} + \def\@tempb{##1} + \ifx\@tempa\@tempb +% \end{macrocode} +% As of May 2017, we now run explicit wrapper in the nonscaled +% version, so we can remove the feature to to add l and r version of +% the scaler (as there is none). +% \begin{macrocode} + \@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarnonscaled_wrapper:nnn}% + {#2} + {##2} + {#3} + \else +% \end{macrocode} +% Next we need to check whether \texttt{\#\#1} is blank as that +% should not be scaled +% \begin{macrocode} + \MT_etb_ifblank:nnn {##1}{ + \@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarnonscaled_wrapper:nnn}% + {#2} + {##2} + {#3} + }{ + \@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarscaled_wrapper:nnn}% + {\@nameuse {\MH_cs_to_str:N ##1 l} #2} + {##2} + {\@nameuse {\MH_cs_to_str:N ##1 r} #3} + } + \fi } % \end{macrocode} % The user command comes here. Just check for the star and choose @@ -3977,24 +4105,159 @@ and the derived files % \end{macrocode} % \end{macro} % -% \begin{macro}{\DeclarePairedDelimiterX} -% \changes{v1.08}{2010/06/10}{Added \cs{DeclarePairedDelimiterX}} -% It has turned out that it is convenient to have a more general -% version of \cs{DeclarePairedDelimiter}. In this version the user -% can specify the number of arguments the created macro has, and they -% can specify the code for the inner part of the macro. Other than -% that the code is fairly similar to \cs{DeclarePairedDelimiter} -% \changes{v1.08e}{2010/09/02}{Provided better implementation of -% \cs{DeclarePairedDelimiterX}} +% \begin{macro}{\MT_paired_delimx_arg_test:n} +% This tests the \oarg{num args} part of +% \cs{DeclarePairedDelimiterX} and \cs{DeclarePairedDelimiterXPP} +% (code reuse), and complains if it is not 1,\dots,9. +% \changes{v1.14}{2014/05/20}{Added} % \begin{macrocode} -\def\MHempty{} -\def\DeclarePairedDelimiterX#1[#2]#3#4#5{% +\def\MT_paired_delimx_arg_test:n #1{ + \ifnum#1>9\relax + \PackageError{mathtools}{No~ more~ than~ 9~ arguments}{} + \else + \ifnum#1<1\relax + \PackageError{mathtools}{Macro~ need~ 1~ or~ more~ + arguments.\MessageBreak Please~ change~ [#1]~ to~ [1]~ ... [9]}{} + \fi + \fi + } + +% \end{macrocode} +% \end{macro} +% \begin{macro}{\MT_delim_inner_generator:n..n} +% \changes{v1.19}{2017/05/14}{Macro added, changes notes in the +% implementation are taken from when this code was not factored out} +% This generates the internal macro from +% \cs{DeclarePairedDelimiterX} and \cs{DeclarePairedDelimiterXPP} +% that handles the non-starred part of the generated macro. The +% macro takes 7 arguments mimicing the arguments of +% \cs{DeclarePairedDelimiterXPP}: +% \begin{enumerate}\setlength\itemsep{0pt} +% \item external macro name +% \item number of arguments, 1-9, already checked at this stage +% \item predata +% \item left scaler +% \item right scaler +% \item postdata +% \item body +% \end{enumerate} +% +% \begin{macrocode} +\def\@MHempty{} +\newcommand\MT_delim_inner_generator:nnnnnnn [7]{ +% \end{macrocode} +% In order for the starred and non-starred version of +% \cs{DeclarePairedDelimiterX(PP)} to have the same arguments, we need +% to introduce an extra macro to catch the optional argument (this +% means that the non-starred version can actually support ten +% arguments!). Here we do things a little differently than with +% \cs{DeclarePairedDelimiter}. The optional argument have +% \cs{@MHempty} as the default. This was earlier locally redefined to +% eat l/r additions to the scaler when there were no scaler. In this +% implementation, we just look for that macro to see if no scaler has +% been given at all. +% \begin{macrocode} + \@xp\@xp\@xp + \newcommand + \@xp\csname MT_delim_\MH_cs_to_str:N #1 _nostar_inner:\endcsname + [#2] + { +% \end{macrocode} +% Add the (possibly empty) precode: +% \begin{macrocode} + #3 +% \end{macrocode} +% Next we provide the inner workhorse. We need a bit of expansion +% magic to get \cs{delimsize} to work. +% \changes{v1.13}{2012/05/10}{Using call backs for \cs{mathopen} and +% \cs{mathclose} additions} +% \changes{v1.19}{2017/04/27}{Added resetting code for \cs{@MHempty}, +% cannot rely on groups here. 2017/05/23 removed because of reimplementation} +% +% May 2017: Due to \verb+\mathclose{|}^2+ generally not being equal to +% \verb+\mathclose|^2+ we needed to split the wrapper macro into +% separate nonscaled and scaled versions. This also have the benefit +% of completely eliminating the need to gobble any chars. There is now +% the nonscaled version, which we do not add any scalers to and the +% manually scaled version where we \emph{know} there is a scaler. The +% complication is now that we need to be able to check for blank +% input, thus the including of a few macros from \pkg{etoolbox}. +% \changes{v1.19}{2017/05/23}{Split into two wrappers and some tests} +% First we need to look at \cs{delimsize} to see if it is equal to +% \cs{@MHempty}. If it is run the nonscaled version. +% \begin{macrocode} + \def\@tempa{\@MHempty} + \@xp\def\@xp\@tempb\@xp{\delimsize} + \ifx\@tempa\@tempb + \@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarnonscaled_wrapper:nnn} + {#4}{#7}{#5} + \else +% \end{macrocode} +% Next we use a copy of a macro from \pkg{etoolbox} to determine +% whether \cs{delimsize} is empty or not. This is to be sure that +% \verb|\abs[]| and similar still end up in the unscaled branch. +% \begin{macrocode} + \MT_etb_ifdefempty_x:nnn {\delimsize}{ + \@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarnonscaled_wrapper:nnn} + {#4}{#7}{#5} + }{ +% \end{macrocode} +% In the scaled version we add features to convert til scaler to its +% l/r versions. +% \begin{macrocode} + \@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostarscaled_wrapper:nnn} + { + \@xp\@xp\@xp\csname\@xp\MH_cs_to_str:N \delimsize l\endcsname #4 + } + {#7} + { + \@xp\@xp\@xp\csname\@xp\MH_cs_to_str:N \delimsize r\endcsname #5 + } + } + \fi +% \end{macrocode} +% Add the (possibly empty) post code +% \begin{macrocode} + #6 + \endgroup + } +} + +% \end{macrocode} +% +% \end{macro} +% \begin{macro}{\DeclarePairedDelimiterXPP} +% \changes{v1.19}{2017/05/24}{Rewritten as we might as well +% implement ...X via ...XPP} It turns out it is useful to have a +% more general version of \cs{DeclarePairedDelimiter} where we can +% access the body and perhaps even add stuff on the outside of the +% fences. Historically, we added \cs{DeclarePairedDelimiterX} first, +% giving access to the body and the most general +% \cs{DeclarePairedDelimiterXPP} was requested after that, thus +% ending up with two macros so not to break existing document. As of +% May 2017, since \cs{DeclarePairedDelimiterX} is just +% \cs{DeclarePairedDelimiterXPP} with no pre- or postcode, we will +% use this update to just define \cs{DeclarePairedDelimiterXPP} and +% define \cs{DeclarePairedDelimiterX} from that. +% +% The arguments for \cs{DeclarePairedDelimiterXPP} are interpreted +% as +% \begin{center} +% \marg{macroname}\oarg{num~args}\allowbreak\marg{pre~code}\allowbreak\marg{left +% delim}\goodbreak \marg{right delim}\marg{post code}\marg{body} +% \end{center} +% Inside \marg{body} \cs{delimsize} +% refers to the current size of the scaler (\cs{middle} in the starred version). +% \begin{macrocode} +\def\DeclarePairedDelimiterXPP#1[#2]#3#4#5#6#7{% \@ifdefinable{#1}{ % \end{macrocode} % The constructor takes five arguments, the name of the macro, the % number of arguments (1-9), the left and right delimiter, the inner % code for the two macros. First we verify that the number of arguments fit. -% \changes{v1.14}{2014/05/20}{Factored out in separate macro for reuse} +% \changes{v1.14}{2014/05/20}{Factored out in separate macro +% (\cs{MT_paired_delimx_arg_test:n}) for reuse. Comment refers back to +% old \cs{DeclarePairedDelimiterX} implementation.} % \begin{macrocode} \MT_paired_delimx_arg_test:n{#2} % \end{macrocode} @@ -4004,7 +4267,7 @@ and the derived files \MT_delim_default_inner_wrappers:n{#1} % \end{macrocode} % We make sure to store the delimiter size in the local variable -% \cs{delimsize}. Then users can refer to the size in the fifth +% \cs{delimsize}. Then users can refer to the size in the \marg{body} % argument. In the starred version it will refer to \cs{middle} and in % the normal version it will hold the provided optional argument. % \begin{macrocode} @@ -4016,6 +4279,10 @@ and the derived files \begingroup \def\delimsize{\middle} % \end{macrocode} +% Adding the \marg{precode} (possibly empty) +% \begin{macrocode} + #3 +% \end{macrocode} % This is slightly controversial, \cs{left}\dots\cs{right} are known % to produce an inner atom, thus may cause different spacing than % normal delimiters. We `fix' this by introducing \cs{mathopen} and @@ -4025,63 +4292,42 @@ and the derived files % started 2010-08-12.} % \changes{v1.13}{2012/05/10}{Using call back instead} % \begin{macrocode} - %\mathopen{}\mathclose\bgroup\left#3 #5 \aftergroup\egroup\right#4 \@nameuse{MT_delim_\MH_cs_to_str:N #1 _star_wrapper:nnn} - {\left#3}{#5}{\right#4} + {\left#4}{#7}{\right#5} + #6 \endgroup } % \end{macrocode} % In order for the starred and non-starred version to have the same % arguments, we need to introduce an extra macro to catch the optional % argument (this means that the non-starred version can actually -% support ten arguments!). -% Here we do things a little differently than with -% \cs{DeclarePairedDelimiter}. The optional argument have \cs{MHempty} -% as the default. This is locally changed when we scale the -% delimiters, such that it can eat the l/r if needed. +% support ten arguments!). % \begin{macrocode} \@xp\@xp\@xp \newcommand \@xp\csname MT_delim_\MH_cs_to_str:N #1 _nostar:\endcsname - [1][\MHempty] + [1][\@MHempty] { % \end{macrocode} % We need to introduce a local group in order to support nesting. It -% is ended inside \verb|\MT_delim_\MH_cs_to_str:N #1 _nostar_inner:| +% is ended inside \verb|\MT_delim_\MH_cs_to_str:N #1 _nostar_inner:|, +% here we also stores the scaler in \cs{delimsize}. % \begin{macrocode} \begingroup \def\delimsize{##1} \@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostar_inner:} - } + } % \end{macrocode} -% Next we provide the inner workhorse. We need a bit of expansion -% magic to get \cs{delimsize} to work. -% \changes{v1.13}{2012/05/10}{Using call back instead} +% To make the code easier to work with we factored the next macro +% out. Since \cs{DeclarePairedDelimiterX} is now implemented via +% \cs{DeclarePairedDelimiterXPP} we did not need to. But it makes the +% code a bit simpler. \cs{MT_delim_inner_generator:nnnnnnn} just +% takes care of generating the appropriate \cs{..._nostar_inner:} macro. +% \begin{macrocode} + \MT_delim_inner_generator:nnnnnnn {#1}{#2}{#3}{#4}{#5}{#6}{#7} +% \end{macrocode} +% At the end, generate the actual user command. % \begin{macrocode} - \@xp\@xp\@xp - \newcommand - \@xp\csname MT_delim_\MH_cs_to_str:N #1 _nostar_inner:\endcsname - [#2] - { - %\mathopen{% - % \let\MHempty\@gobble - % \@xp\@xp\@xp\csname\@xp\MH_cs_to_str:N \delimsize l\endcsname #3} - %#5 - %\mathclose{% - % \let\MHempty\@gobble - % \@xp\@xp\@xp\csname\@xp\MH_cs_to_str:N \delimsize r\endcsname #4} - \@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostar_wrapper:nnn} - { - \let\MHempty\@gobble - \@xp\@xp\@xp\csname\@xp\MH_cs_to_str:N \delimsize l\endcsname #3 - } - {#5} - { - \let\MHempty\@gobble - \@xp\@xp\@xp\csname\@xp\MH_cs_to_str:N \delimsize r\endcsname #4 - } - \endgroup - } \DeclareRobustCommand{#1}{ \@ifstar {\@nameuse{MT_delim_\MH_cs_to_str:N #1 _star:}} @@ -4089,90 +4335,24 @@ and the derived files } } } -% \end{macrocode} -% \end{macro} -% \begin{macro}{\MT_paired_delimx_arg_test:n} -% This tests the \oarg{num args} part of -% \cs{DeclarePairedDelimiterX} and \cs{DeclarePairedDelimiterXPP} -% (code reuse), and complains if it is not 1,\dots,9. -% \changes{v1.14}{2014/05/20}{Added} -% \begin{macrocode} -\def\MT_paired_delimx_arg_test:n #1{ - \ifnum#1>9\relax - \PackageError{mathtools}{No~ more~ than~ 9~ arguments}{} - \else - \ifnum#1<1\relax - \PackageError{mathtools}{Macro~ need~ 1~ or~ more~ - arguments.\MessageBreak Please~ change~ [#1]~ to~ [1]~ ... [9]}{} - \fi - \fi - } % \end{macrocode} % \end{macro} -% \begin{macro}{\DeclarePairedDelimiterXPP} -% \changes{v1.14}{2014/05/20}{Added} -% Similar to \cs{DeclarePairedDelimiterX}, but we can add \meta{pre} -% and \meta{pre} code before and after the delimiters. Arguments are -% interpreted as -% \marg{macro}\oarg{num}\marg{pre code}\marg{left delim}\marg{right -% delim}\marg{post code}\marg{body} +% \begin{macro}{\DeclarePairedDelimiterX} +% \changes{v1.08}{2010/06/10}{Added +% \cs{DeclarePairedDelimiterX}. 2017/05/24: old comment, kept for +% historic reasons.} +% \changes{v1.08e}{2010/09/02}{Provided better implementation of +% \cs{DeclarePairedDelimiterX}. 2017/05/24: old comment, kept for +% historic reasons.} +% As of May 2017, this is now just a call to \cs{DeclarePairedDelimiterXPP}. % \begin{macrocode} -\def\DeclarePairedDelimiterXPP#1[#2]#3#4#5#6#7{% - \@ifdefinable{#1}{ - \MT_paired_delimx_arg_test:n{#2} - \MT_delim_default_inner_wrappers:n{#1} - \@xp\@xp\@xp - \newcommand - \@xp\csname MT_delim_\MH_cs_to_str:N #1 _star:\endcsname - [#2] - { - \begingroup - \def\delimsize{\middle} - #3 - \@nameuse{MT_delim_\MH_cs_to_str:N #1 _star_wrapper:nnn} - {\left#4}{#7}{\right#5} - #6 - \endgroup - } - \@xp\@xp\@xp - \newcommand - \@xp\csname MT_delim_\MH_cs_to_str:N #1 _nostar:\endcsname - [1][\MHempty] - { - \begingroup - \def\delimsize{##1} - \@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostar_inner:} - } - \@xp\@xp\@xp - \newcommand - \@xp\csname MT_delim_\MH_cs_to_str:N #1 _nostar_inner:\endcsname - [#2] - { - #3 - \@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostar_wrapper:nnn} - { - \let\MHempty\@gobble - \@xp\@xp\@xp\csname\@xp\MH_cs_to_str:N \delimsize l\endcsname #4 - } - {#7} - { - \let\MHempty\@gobble - \@xp\@xp\@xp\csname\@xp\MH_cs_to_str:N \delimsize r\endcsname #5 - } - #6 - \endgroup - } - \DeclareRobustCommand{#1}{ - \@ifstar - {\@nameuse{MT_delim_\MH_cs_to_str:N #1 _star:}} - {\@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostar:}} - } - } +\def\DeclarePairedDelimiterX#1[#2]#3#4#5{ + \DeclarePairedDelimiterXPP{#1}[#2]{}{#3}{#4}{}{#5} } - % \end{macrocode} % \end{macro} +% % @@ -4485,88 +4665,94 @@ and the derived files % \end{macrocode} % Check if A is \cs{mathop}. If it is, we know that B is the argument % of the \cs{mathop}. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} - \if_meaning:NN \MT_smop_arg_A: \MT_smop_mathop:n + \MH_if_meaning:NN \MT_smop_arg_A: \MT_smop_mathop:n % \end{macrocode} % If A was \cs{mathop} we check if C is \cs{limits} +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} - \if_meaning:NN \MT_smop_arg_C:\MT_smop_limits: + \MH_if_meaning:NN \MT_smop_arg_C:\MT_smop_limits: \def\MT_smop_final_arg_A:{#1{#2}}% % \end{macrocode} % Now we have something like \verb|\mathop{TTT}\limits|. Then check % if D is \cs{@nil}. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} - \if_meaning:NN \MT_smop_arg_D: \@nnil - \else: + \MH_if_meaning:NN \MT_smop_arg_D: \@nnil + \MH_else: \MH_set_boolean_T:n {smop_one} \MH_let:NwN \MT_smop_final_arg_B: \MT_smop_arg_D: \MH_let:NwN \MT_smop_final_arg_C: \MT_smop_arg_E: - \if_meaning:NN \MT_smop_arg_F: \@nnil - \else: + \MH_if_meaning:NN \MT_smop_arg_F: \@nnil + \MH_else: \MH_set_boolean_T:n {smop_two} \MH_let:NwN \MT_smop_final_arg_D: \MT_smop_arg_F: \edef\MT_smop_final_arg_E: {\expandafter\MT_smop_remove_nil_vi:N \MT_smop_arg_G: } - \fi: - \fi: - \else: + \MH_fi: + \MH_fi: + \MH_else: % \end{macrocode} % Here we have something like \verb|\mathop{TTT}|. Still check % if D is \cs{@nil}. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} \def\MT_smop_final_arg_A:{#1{#2}}% - \if_meaning:NN \MT_smop_arg_D: \@nnil - \else: + \MH_if_meaning:NN \MT_smop_arg_D: \@nnil + \MH_else: \MH_set_boolean_T:n {smop_one} \MH_let:NwN \MT_smop_final_arg_B: \MT_smop_arg_C: \MH_let:NwN \MT_smop_final_arg_C: \MT_smop_arg_D: - \if_meaning:NN \MT_smop_arg_F: \@nnil - \else: + \MH_if_meaning:NN \MT_smop_arg_F: \@nnil + \MH_else: \MH_set_boolean_T:n {smop_two} \MH_let:NwN \MT_smop_final_arg_D: \MT_smop_arg_E: \MH_let:NwN \MT_smop_final_arg_E: \MT_smop_arg_F: - \fi: - \fi: - \fi: + \MH_fi: + \MH_fi: + \MH_fi: % \end{macrocode} % If A was not \cs{mathop}, it is an operator in itself, so we check % if B is \cs{limits} +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} - \else: - \if_meaning:NN \MT_smop_arg_B:\MT_smop_limits: + \MH_else: + \MH_if_meaning:NN \MT_smop_arg_B:\MT_smop_limits: \def\MT_smop_final_arg_A:{#1}% - \if_meaning:NN \MT_smop_arg_D: \@nnil - \else: + \MH_if_meaning:NN \MT_smop_arg_D: \@nnil + \MH_else: \MH_set_boolean_T:n {smop_one} \MH_let:NwN \MT_smop_final_arg_B: \MT_smop_arg_C: \MH_let:NwN \MT_smop_final_arg_C: \MT_smop_arg_D: - \if_meaning:NN \MT_smop_arg_F: \@nnil - \else: + \MH_if_meaning:NN \MT_smop_arg_F: \@nnil + \MH_else: \MH_set_boolean_T:n {smop_two} \MH_let:NwN \MT_smop_final_arg_D: \MT_smop_arg_E: \MH_let:NwN \MT_smop_final_arg_E: \MT_smop_arg_F: - \fi: - \fi: - \else: + \MH_fi: + \MH_fi: + \MH_else: % \end{macrocode} % No \cs{limits} was found, so we already have the right input. Just % forget about the last two arguments. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} \def\MT_smop_final_arg_A:{#1}% - \if_meaning:NN \MT_smop_arg_C: \@nnil - \else: + \MH_if_meaning:NN \MT_smop_arg_C: \@nnil + \MH_else: \MH_set_boolean_T:n {smop_one} \MH_let:NwN \MT_smop_final_arg_B: \MT_smop_arg_B: \MH_let:NwN \MT_smop_final_arg_C: \MT_smop_arg_C: - \if_meaning:NN \MT_smop_arg_D: \@nnil - \else: + \MH_if_meaning:NN \MT_smop_arg_D: \@nnil + \MH_else: \MH_set_boolean_T:n {smop_two} \MH_let:NwN \MT_smop_final_arg_D: \MT_smop_arg_D: \MH_let:NwN \MT_smop_final_arg_E: \MT_smop_arg_E: - \fi: - \fi: - \fi: - \fi: + \MH_fi: + \MH_fi: + \MH_fi: + \MH_fi: % \end{macrocode} % No reason to measure if there's no sub or sup. % \begin{macrocode} @@ -4680,10 +4866,11 @@ and the derived files % as we have no need for the combination % $(\cs{displaystyle},\cs{textstyle})$ etc. Only % $(\cs{scriptstyle},\cs{scriptstyle})$ is useful. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} - \if_dim:w \@tempdima>\z@ + \MH_if_dim:w \@tempdima>\z@ \mathop{#1}\limits#2{#3} - \else: + \MH_else: \mathop{#1\MT_vphantom:Nn \displaystyle{#4}}\limits #2{ \def\finsm@sh{\ht\z@\z@ \box\z@} @@ -4691,8 +4878,8 @@ and the derived files \MT_vphantom:Nn \scriptstyle {\MT_cramped_internal:Nn \scriptstyle{#6}} } - \fi: - \if_dim:w \@tempdima>\z@ + \MH_fi: + \MH_if_dim:w \@tempdima>\z@ \mathop{#4\MT_vphantom:Nn \displaystyle{#1}}\limits #5 { @@ -4701,9 +4888,9 @@ and the derived files \def\finsm@sh{\ht\z@\z@ \box\z@} \mathsm@sh\scriptstyle{\MT_cramped_internal:Nn \scriptstyle{#6}} } - \else: + \MH_else: \mathop{#4}\limits#5{#6} - \fi: + \MH_fi: } % \end{macrocode} % \end{macro} @@ -5068,6 +5255,8 @@ and the derived files % test not only \cs{linewidth} against \cs{columnwidth} but also if % \cs{@totalleftmargin} is not zero. The implementation used is due to % David Carlisle. +% \changes{v1.19}{2016/05/26}{Added \cs{ignorespaces} after +% \cs{noindent}, bug inherited from \pkg{amsmath}} % \begin{macrocode} \ifdim \ifdim\@totalleftmargin=\z@ @@ -5078,17 +5267,32 @@ and the derived files =\columnwidth \else \parshape\@ne \@totalleftmargin \linewidth \fi - \noindent##1\par}% + \noindent\ignorespaces##1\par}% \penalty\predisplaypenalty\vskip\abovedisplayskip% \vskip-\lineskiplimit % CCS \vskip\normallineskiplimit % CCS \vskip\l_MT_above_intertext_sep }% -}} + }% % \end{macrocode} -% And provide a key to switch +% We might as well hook on to this and only activate +% \cs{shortintertext} whenever \cs{intertext} is active. This allows +% us to get the same error messages as \cs{intertext}. +% \changes{v1.19}{2017/03/31}{Added} % \begin{macrocode} -\def\MT_orig_intertext_true: { \MH_let:NwN \intertext@ \MT_orig_intertext: } + \MH_let:NwN \shortintertext \shortintertext@ +} +% \end{macrocode} +% And provide a key to switch +% \changes{v1.19}{2017/03/31}{Changed \cs{MT_orig_intertext_true:}} +% Changed \cs{MT_orig_intertext_true:} to also activate +% \cs{shortintertext}, because when this is active, our change to +% \cs{intertext@} is not active. +% \begin{macrocode} +\def\MT_orig_intertext_true: { + \MH_let:NwN \intertext@ \MT_orig_intertext: + \MH_let:NwN \shortintertext \shortintertext@ +} \def\MT_orig_intertext_false: { \MH_let:NwN \intertext@ \MT_intertext: } \define@key{\MT_options_name:}{original-intertext}[true]{ \@nameuse{MT_orig_intertext_#1:} @@ -5124,18 +5328,21 @@ and the derived files % \end{macrocode} % \changes{v1.17}{2015/06/17}{Added extra `in list' check} % Same comment as for \cs{intertext} above. +% \changes{v1.19}{2016/05/26}{Added \cs{ignorespaces} after +% \cs{noindent}, bug inherited from \pkg{amsmath}} +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} - \if_dim:w - \if_dim:w \@totalleftmargin=\z@ + \MH_if_dim:w + \MH_if_dim:w \@totalleftmargin=\z@ \linewidth - \else: + \MH_else: -\maxdimen - \fi: + \MH_fi: =\columnwidth - \else: + \MH_else: \parshape\@ne \@totalleftmargin \linewidth - \fi: - \noindent#1\par}% + \MH_fi: + \noindent\ignorespaces#1\par}% \penalty\predisplaypenalty\vskip\abovedisplayshortskip% }% } @@ -5189,29 +5396,43 @@ and the derived files % \end{macrocode} % \changes{v1.17}{2015/06/17}{Added extra `in list' check} % Same comment as for \cs{intertext} above. +% \changes{v1.19}{2016/05/26}{Added \cs{ignorespaces} after +% \cs{noindent}, bug inherited from \pkg{amsmath}} +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} - \if_dim:w - \if_dim:w \@totalleftmargin=\z@ + \MH_if_dim:w + \MH_if_dim:w \@totalleftmargin=\z@ \linewidth - \else: + \MH_else: -\maxdimen - \fi: + \MH_fi: =\columnwidth - \else: + \MH_else: \parshape\@ne \@totalleftmargin \linewidth - \fi: - \noindent#1\par}% + \MH_fi: + \noindent\ignorespaces#1\par}% \penalty\predisplaypenalty\vskip\abovedisplayshortskip% \vskip-\lineskiplimit \vskip\normallineskiplimit \vskip\l_MT_below_shortintertext_sep }% -} +} % \end{macrocode} % Next we need to be able to switch. +% \changes{v1.19}{2017/03/31}{Changed \cs{shortintertext} to be +% internal here.} +% \begin{macrocode} +\def\MT_orig_shortintertext_true: { \MH_let:NwN \shortintertext@ \MT_orig_shortintertext:n } +\def\MT_orig_shortintertext_false: { \MH_let:NwN \shortintertext@ \MT_shortintertext:n } +% \end{macrocode} +% Next make \cs{shortintertext} a no-go everywhere. Thus \cs{shortintertext} is only +% available when \cs{intertext} is, or when +% \verb+original-intertext=true+ is used. +% \changes{v1.19}{2017/03/31}{Added} +% \begin{macrocode} +\newcommand{\shortintertext}{\@amsmath@err{\Invalid@@\shortintertext}\@eha} +% \end{macrocode} % \begin{macrocode} -\def\MT_orig_shortintertext_true: { \MH_let:NwN \shortintertext \MT_orig_shortintertext:n } -\def\MT_orig_shortintertext_false: { \MH_let:NwN \shortintertext \MT_shortintertext:n } \define@key{\MT_options_name:}{original-shortintertext}[true]{ \@nameuse{MT_orig_shortintertext_#1:} } @@ -5466,14 +5687,15 @@ and the derived files \newcommand{\MT_prescript_inner:}[4]{ % \end{macrocode} % Put the sup in box 0 and the sub in box 2. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} \@mathmeasure\z@#4{\MT_prescript_sup:{#1}} \@mathmeasure\tw@#4{\MT_prescript_sub:{#2}} - \if_dim:w \wd\tw@>\wd\z@ + \MH_if_dim:w \wd\tw@>\wd\z@ \setbox\z@\hbox to\wd\tw@{\hfil\unhbox\z@} - \else: + \MH_else: \setbox\tw@\hbox to\wd\z@{\hfil\unhbox\tw@} - \fi: + \MH_fi: % \end{macrocode} % Do not let a preceding mathord symbol approach without any % intervening space. @@ -5532,13 +5754,14 @@ and the derived files % only provide the fix for older kernels. % \changes{v1.18}{2015/11/12}{This was now moved into the kernel, thus % we only provide it for older kernels} +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} \ifx\e@alloc\@undefined% kernel thus older than 2015 \def\@DeclareMathSizes #1#2#3#4#5{% \@defaultunits\dimen@ #2pt\relax\@nnil - \if:w $#3$% + \MH_if:w $#3$% \MH_let:cN {S@\strip@pt\dimen@}\math@fontsfalse - \else: + \MH_else: \@defaultunits\dimen@ii #3pt\relax\@nnil \@defaultunits\@tempdima #4pt\relax\@nnil \@defaultunits\@tempdimb #5pt\relax\@nnil @@ -5549,7 +5772,7 @@ and the derived files \gdef\noexpand\ssf@size{\strip@pt\@tempdimb}% \the\toks@ }% - \fi: + \MH_fi: } \fi % \end{macrocode} @@ -5572,6 +5795,7 @@ and the derived files % Save the original meaning if you need to go back (note that this % does not save the robust part of the macro, we fix this later on by % rerobustifying). +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} \MH_if_boolean:nTF {robustify}{ \MH_let:NwN \MT_mathic_redeffer: \DeclareRobustCommand @@ -5583,37 +5807,40 @@ and the derived files \MT_mathic_redeffer:*\({ \relax\ifmmode\@badmath\else \ifhmode - \if_dim:w \fontdimen\@ne\font>\z@ + \MH_if_dim:w \fontdimen\@ne\font>\z@ % \end{macrocode} % We have a small problem here, if the user use >>\verb|text~\(|<< then % the italic correction is lost due to the penalty (see \cite{TBT}, % section 4.3.3). However, we \emph{know} what \verb|~| does, a % (positive) penalty and a skip. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} - \if_dim:w \lastskip>\z@ + \MH_if_dim:w \lastskip>\z@ \skip@\lastskip\unskip % \end{macrocode} % \changes{v1.15}{2014/07/16}{Added penalty workaround} % Here is the fix. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} - \if_num:w \lastpenalty>\z@ + \MH_if_num:w \lastpenalty>\z@ \count@\lastpenalty\unpenalty - \fi: + \MH_fi: \@@italiccorr % \end{macrocode} % \changes{v1.15}{2014/07/16}{Added penalty workaround} % And here it is inserted again. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} - \if_num:w \count@>\z@ + \MH_if_num:w \count@>\z@ \penalty\count@ - \fi: + \MH_fi: \hskip\skip@ - \else: + \MH_else: \@@italiccorr - \fi: - \fi: - \fi: - $\fi: + \MH_fi: + \MH_fi: + \MH_fi: + $\MH_fi: } } } @@ -5767,29 +5994,31 @@ and the derived files % supported/described in the documentation anymore so new users % won't know about it and b)~it forbids the use of \cs{tag} % anyway. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} \if@fleqn - \if_num:w \xatlevel@=\tw@ + \MH_if_num:w \xatlevel@=\tw@ \kern-\@mathmargin - \fi: - \fi: + \MH_fi: + \MH_fi: % \end{macrocode} % End of additions. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} - \if:w 1\shift@tag\row@\relax + \MH_if:w 1\shift@tag\row@\relax \rlap{\vbox{% \normalbaselines \boxz@ \vbox to\lineht@{}% \raise@tag }}% - \else: + \MH_else: \rlap{\boxz@}% - \fi: + \MH_fi: \kern\displaywidth@ - \else: + \MH_else: \kern-\tagshift@ - \if:w 1\shift@tag\row@\relax + \MH_if:w 1\shift@tag\row@\relax \llap{\vtop{% \raise@tag \normalbaselines @@ -5798,10 +6027,10 @@ and the derived files \box\@ne \boxz@ }}% - \else: + \MH_else: \llap{\boxz@}% - \fi: - \fi: + \MH_fi: + \MH_fi: } % \end{macrocode} % \end{macro} @@ -5816,31 +6045,34 @@ and the derived files % <recently read> \@tempcntb % \end{verbatim} % when in \mode{fleqn,leqno} mode. Not very comprehensible for the user. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} \def\x@calc@shift@lf{% - \if_dim:w \eqnshift@=\z@ + \MH_if_dim:w \eqnshift@=\z@ \global\eqnshift@\@mathmargin\relax \alignsep@\displaywidth \advance\alignsep@-\totwidth@ % \end{macrocode} % The addition: If \cs{@tempcntb} is zero we avoid division. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} - \if_num:w \@tempcntb=0 - \else: + \MH_if_num:w \@tempcntb=0 + \MH_else: \global\divide\alignsep@\@tempcntb % original line - \fi: + \MH_fi: % \end{macrocode} % Addition end. +% \changes{v1.19}{2017/03/31}{Added MH\_ prefix} % \begin{macrocode} - \if_dim:w \alignsep@<\minalignsep\relax + \MH_if_dim:w \alignsep@<\minalignsep\relax \global\alignsep@\minalignsep\relax - \fi: - \fi: - \if_dim:w \tag@width\row@>\@tempdima + \MH_fi: + \MH_fi: + \MH_if_dim:w \tag@width\row@>\@tempdima \saveshift@1% - \else: + \MH_else: \saveshift@0% - \fi:}% + \MH_fi:}% % \end{macrocode} % \end{macro} % \begin{macrocode} |