diff options
author | Karl Berry <karl@freefriends.org> | 2014-05-21 22:04:53 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-05-21 22:04:53 +0000 |
commit | e9c424012078dfba8a839b14b82a3c99ce75ce4c (patch) | |
tree | 7c9225ecb518aa8e4219e8d4681067648be418cf /Master/texmf-dist/source | |
parent | de342a74d559603226d5634fb33cf65d4dc5c4f7 (diff) |
mh (21may14)
git-svn-id: svn://tug.org/texlive/trunk@34175 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r-- | Master/texmf-dist/source/latex/mh/mathtools.dtx | 342 |
1 files changed, 309 insertions, 33 deletions
diff --git a/Master/texmf-dist/source/latex/mh/mathtools.dtx b/Master/texmf-dist/source/latex/mh/mathtools.dtx index 94b422bf3ef..314db56e4a4 100644 --- a/Master/texmf-dist/source/latex/mh/mathtools.dtx +++ b/Master/texmf-dist/source/latex/mh/mathtools.dtx @@ -1,7 +1,7 @@ % \iffalse meta-comment % % Copyright (C) 2004-2011 by Morten Hoegholm -% Copyright (C) 2012 by Lars Madsen +% Copyright (C) 2012- by Lars Madsen % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either @@ -68,7 +68,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: mathtools 2013/02/12 v1.13} +\Msg{* Package: mathtools 2014/05/21 v1.14} \Msg{************************************************************************} \keepsilent @@ -79,7 +79,7 @@ This is a generated file. Copyright (C) 2002-2011 by Morten Hoegholm -Copyright (C) 2012 by Lars Madsen +Copyright (C) 2012- by Lars Madsen This work may be distributed and/or modified under the @@ -131,7 +131,7 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{mathtools.drv}% - [2013/02/12 v1.13 mathematical typesetting tools] + [2014/05/21 v1.14 mathematical typesetting tools] \documentclass{ltxdoc} \IfFileExists{fourier.sty}{\usepackage{fourier}}{} \addtolength\marginparwidth{-25pt} @@ -203,6 +203,14 @@ and the derived files }% }% } +\newcommand*\CommentAdded[1]{% + \hskip1sp + \marginpar{% + \parbox[b]{\marginparwidth}{\small\sffamily\raggedright + \strut Comment added\\#1% + }% + }% +} \expandafter\def\expandafter\MakePrivateLetters\expandafter{% @@ -273,7 +281,7 @@ and the derived files % % \GetFileInfo{mathtools.drv} % -% \CheckSum{2836} +% \CheckSum{3095} % % \title{The \pkg{mathtools} package\thanks{This file has version number % \fileversion, last revised \filedate.}} @@ -1322,6 +1330,16 @@ and the derived files % There can be two optional arguments (position and width) and % they're interchangeable. % +% \medskip\noindent +% \textbf{Bug:} +% \CommentAdded{2014/05/11} +% If used inside an \env{array} or +% a derivative (say, a \env{matrix} variant), \env{multlined} does +% not work as expected. The implementation contains an `invisible' +% line after the first \env{multline} row, inside an \env{array} this +% line is no longer `invisible' because \env{array} sets +% \cs{baselineskip} to zero. Currently we have no workaround for this. +% % \subsubsection{More \env{cases}-like environments} % % \begin{codesyntax} @@ -1509,6 +1527,16 @@ and the derived files % Note how the \cs{fboxsep} change only affect the box coming % immediately after it. % +% \marginpar{\strut\\% +% \parbox[b]{\marginparwidth}{\small\sffamily\raggedright +% \strut Comment by Qrrbrbirlbel on \url{tex.stackexchange.com}, 2013/05/20. +% }\strut +% }% +% As \cs{Aboxed} looks for the alignment \texttt{\&} it may be +% necessary to \emph{hide} constructions like matrices that also make +% use of \texttt{\&}. Just add a set of braces around the construction +% you want to hide. +% % \subsubsection{Adding arrows between lines in an alignment} % % This first macro is a bit misleading, it is only intended to be @@ -1789,28 +1817,32 @@ and the derived files % % \begin{codesyntax} % \SpecialUsageIndex{\DeclarePairedDelimiterX} -% \cs{DeclarePairedDelimiterX}\marg{cmd}\oarg{num args}\marg{left_delim}\marg{right_delim}\marg{code}\\ +% \cs{DeclarePairedDelimiterX}\marg{cmd}\oarg{num args}\marg{left_delim}\marg{right_delim}\marg{body}\\ % \cs{delimsize} % \end{codesyntax} -% \ProvidedBy{Lars Madsen}{2010/06/15} -% Sometimes \cs{DeclarePairedDelimiter} just is not enough. One -% might want to have the capabilities of \cs{DeclarePairedDelimiter}, -% but also want a macro the takes more than one argument. +% Sometimes one might want to have the capabilities of +% \cs{DeclarePairedDelimiter}, but also want a macro the takes more +% than one argument and specify plus being able to specify the body +% of the generated macro. % % \cs{DeclarePairedDelimiterX} extends the features of % \cs{DeclarePairedDelimiter} such that the user will get a macro % which is fenced off at either end, plus the capability to provide -% the code for what ever the macro should do within these fences. +% the \meta{body} for what ever the macro should do within these +% fences. % -% Inside the \meta{code} part, the macro \cs{delimsize} refer to the -% size of the outer fences. It can then be used inside \meta{code} to +% Inside the \meta{body} part, the macro \cs{delimsize} refer to the +% size of the outer fences. It can then be used inside \meta{body} to % scale any inner fences. % -% In this setting -% \cs{DeclarePairedDelimiter}\marg{cmd}\marg{left_delim}\marg{right_delim} is the same thing as -% \begin{center} +% Thus +% \begin{quote} +% \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}| -% \end{center} +% \end{quote} % % % Let us do some examples. First we want to prepare a macro for inner % products, with two arguments such that we can hide the character @@ -1862,6 +1894,95 @@ and the derived files % is a feature of the \cs{left}\dots\cs{right} construction). % \fi % +% With the inner scaling, we can provide macros whos syntax closely +% follow the mathematical meaning. Fx for building +% sets, try this\footnote{The reason for \cs{SetSymbol} can be seen +% when one want to build a complicated set where the condition has to +% span several lines, then one may have to resort to a different +% construction, giving the need to be able to refer back to the symbol +% being used.} +% \begin{verbatim} +% % just to make sure it exists +% \providecommand\given{} +% % can be useful to refer to this outside \Set +% \newcommand\SetSymbol[1][]{\nonscript\:#1\vert\nonscript\:\allowbreak} +% \DeclarePairedDelimiterX\Set[1]\{\}{% +% \renewcommand\given{\SetSymbol[\delimsize]} +% #1 +% } +% \end{verbatim} +% \providecommand\given{} +% \newcommand\SetSymbol[1][]{\nonscript\:#1\vert\nonscript\:\allowbreak} +% \DeclarePairedDelimiterX\Set[1]\{\}{% +% \renewcommand\given{\SetSymbol[\delimsize]} +% #1 +% } +% \begin{verbatim} +% \[ \Set*{ x \in X \given \frac{\sqrt{x}}{x^2+1} > 1 } \] +% \end{verbatim} +% \[ \Set*{ x \in X \given \frac{\sqrt{x}}{x^2+1} > 1 } \] +% Thus we end up with a syntax much closer to how we read this +% aloud. Also we hide the `given' symbol for easy replacement. +% +% Combining with \pkg{etoolbox} it becomes easy to make a function +% that automatically provide a marker for a blank argument: +% \begin{verbatim} +% \usepackage{etoolbox} +% \DeclarePairedDelimiterX\norm[1]\lVert\rVert{ +% \ifblank{#1}{\:\cdot\:}{#1} +% } +% \end{verbatim} +% Then \verb|\norm{}| will give you $\lVert\:\cdot\:\rVert$ while +% \verb|\norm{a}| gives the expected $\lVert a \rVert$. +% +% \begin{codesyntax} +% \SpecialUsageIndex{\DeclarePairedDelimiterXPP} +% \cs{DeclarePairedDelimiterXPP}\marg{cmd}\oarg{num args}\marg{pre +% code}\marg{left_delim}\\% +% \marg{right_delim}\marg{post code}\marg{body} +% \end{codesyntax} +% \FeatureRequest{Barbara Beeton (on TSE)}{2013/10/07} +% \cs{DeclarePairedDelimiterX} has an annoying caveat: it is very hard +% to make a macro \verb|\lnorm{a}| that should result in $\lVert +% a\rVert_2$.\footnote{The added `\texttt{\_2}' is hard to get around +% the argument parsing.} +% +% As a consequence we provide +% \cs{DeclarePairedDelimiterXPP}.\footnote{Extended +% DeclarePairedDelimiter with Pre and Post code.} With the addition of +% the \marg{pre code} and \marg{post code} it is identical to +% \cs{DeclarePairedDelimiterX}. It should be interpreted as +% \begin{center} +% \marg{pre code} \marg{left_delim} \marg{body} +% \marg{right_delim} \marg{post code} +% \end{center} +% +% +% An $\mathcal{L}^2$ norm can now be defined as +% \begin{verbatim} +% \DeclarePairedDelimiterXPP\lnorm[1]{}\lVert\rVert{_2}{#1} +% \end{verbatim} +% A probability macro with build in support for conditionals +% (\cs{given} initialized as above) +% \begin{verbatim} +% \DeclarePairedDelimiterXPP\Prop[1]{\mathbb{P}}(){}{ +% \renewcommand\given{\nonscript\:\delimsize\vert\nonscript\:} +% #1} +% \end{verbatim} +% Thus giving support for \verb|\Prob{A \given B}|. +% +% \medskip\noindent\textbf{Note:} 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 +% \url{http://tex.stackexchange.com/a/136767/3929} there is a +% suggested replacement for \cs{DeclarePairedDelimiter}, that greatly +% reduces the number of macros and provides a key-val +% interface. However, the code use \pkg{xparse}, and if we want to use +% \pkg{xparse} for some of our macros, we might just as well rewrite +% the entire package in \pkg{expl3}. Also it is not obvious how to get +% \pkg{xparse} to support \verb|[3]| for the number of arguments. We +% will consider this for a future release. % % \subsubsection{Expert use} % @@ -1892,7 +2013,69 @@ and the derived files % star: \mathopen{}\mathclose\bgroup #1#2\aftergroup\egroup #3 % nostar: \mathopen{#1}#2\mathclose{#3} % \end{verbatim} -% +% +% \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 +% breakable across lines, even breakable within an \env{align} +% construction. Currently, this can only be applied to macros made +% using \cs{DeclarePairedDelimiter} and \emph{not} macros made using +% \cs{DeclarePairedDelimiterX} or \cs{DeclarePairedDelimiterXPP} as +% the contents is typeset inside a group (to limit \cs{delimsize}) +% and thus hide any \verb|&| or \verb|\\| from \env{align} and +% \env{align} breaks down. +% +% When \cs{DeclarePairedDelimiter} is used, Sebastien Gouezel has +% provided the following example \ProvidedBy{Sebastien +% Gouezel}{2014/05/14} +% \begin{verbatim} +% \newcommand\MTkillspecial[1]{% helper macro +% \bgroup +% \catcode`\&=9 +% \let\\\relax% +% \scantokens{#1}% +% \egroup +% } +% \DeclarePairedDelimiter\abs\lvert\rvert +% \reDeclarePairedDelimiterInnerWrapper\abs{star}{ +% \mathopen{#1\vphantom{\MTkillspecial{#2}}\kern-\nulldelimiterspace\right.} +% #2 +% \mathclose{\left.\kern-\nulldelimiterspace\vphantom{\MTkillspecial{#2}}#3}} +% \end{verbatim} +% Then this example works just fine: +% \begin{verbatim} +% \begin{align*} +% f(a) &= +% \!\begin{aligned}[t] +% \abs*{ & \frac{1}{2}+\cdots \\ +% & \dots+\frac{1}{2} } +% \end{aligned} +% \end{align*} +% \end{verbatim} +% \newcommand\MTkillspecial[1]{% helper macro +% \bgroup +% \catcode`\&=9 +% \let\\\relax% +% \scantokens{#1}% +% \egroup +% } +% \let\abs\relax +% \MHInternalSyntaxOn +% \MH_let:NwN\MT_delim_abs_nostar:\relax +% \MHInternalSyntaxOff +% \DeclarePairedDelimiter\abs\lvert\rvert +% \reDeclarePairedDelimiterInnerWrapper\abs{star}{ +% \mathopen{#1\vphantom{\MTkillspecial{#2}}\kern-\nulldelimiterspace\right.} +% #2 +% \mathclose{\left.\kern-\nulldelimiterspace\vphantom{\MTkillspecial{#2}}#3}} +% \begin{align*} +% f(a) &= +% \!\begin{aligned}[t] +% \abs*{&\frac{1}{2}+\cdots \\ +% &\dots+\frac{1}{2}} +% \end{aligned} +% \end{align*} +% % % \subsection{Special symbols} % @@ -1962,7 +2145,7 @@ and the derived files % \SpecialUsageIndex{\coloneqq}\cs{coloneqq}\texttt{~~~~~} % \SpecialUsageIndex{\Coloneqq}\cs{Coloneqq}\texttt{~~~~~} % \SpecialUsageIndex{\coloneq}\cs{coloneq}\texttt{~~~} -% \SpecialUsageIndex{\Coloneq}\cs{Coloneqq}\\ +% \SpecialUsageIndex{\Coloneq}\cs{Coloneq}\\ % \SpecialUsageIndex{\eqqcolon}\cs{eqqcolon}\texttt{~~~~~} % \SpecialUsageIndex{\Eqqcolon}\cs{Eqqcolon}\texttt{~~~~~} % \SpecialUsageIndex{\eqcolon}\cs{eqcolon}\texttt{~~~} @@ -3360,12 +3543,15 @@ and the derived files % \end{macro} % \begin{macro}{\MT_mult_invisible_line:} % An invisible line. +% \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}} % \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-\normallineskip} + \noalign{\vskip-\baselineskip \vskip-\jot \vskip-\normallineskip} } % \end{macrocode} % \end{macro} @@ -3615,6 +3801,8 @@ and the derived files } % \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 @@ -3631,18 +3819,17 @@ and the derived files % \end{macrocode} % -% \end{macro} % \end{macro} % \begin{macro}{\DeclarePairedDelimiter} % \changes{v1.06}{2008/08/01}{Made user command robust} % This macro defines |#1| to be a control sequence that takes either -% a star or an optional argument. +% a star or an optional argument and one mandatory argument. % \begin{macrocode} \newcommand*\DeclarePairedDelimiter[3]{% \@ifdefinable{#1}{ % \end{macrocode} % Define the starred command to just put \cs{left} and \cs{right} -% before the delimiters. +% 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.} @@ -3705,17 +3892,12 @@ and the derived files % 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} % \begin{macrocode} - \ifnum#2>9\relax - \PackageError{mathtools}{No~ more~ than~ 9~ arguments}{} - \else - \ifnum#2<1\relax - \PackageError{mathtools}{Macro~ need~ 1~ or~ more~ arguments}{} - \fi - \fi + \MT_paired_delimx_arg_test:n{#2} % \end{macrocode} % \changes{v1.13}{2012/05/10}{Using call back instead} -% Initiate the default call backs. +% Define the default call backs. % \begin{macrocode} \MT_delim_default_inner_wrappers:n{#1} % \end{macrocode} @@ -3807,6 +3989,90 @@ 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{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:}} + } + } +} + +% \end{macrocode} +% \end{macro} + + % % \subsection{A \texttt{\textbackslash displaystyle} \env{cases} environment} % @@ -4386,8 +4652,9 @@ and the derived files % \begin{macrocode} \newcommand\Aboxed[1]{\let\bgroup{\romannumeral-`}\@Aboxed#1&&\ENDDNE} % \end{macrocode} +% \sloppy % The macro has been reimplemented courtesy of Florent Chervet out of -% a posting on ctt, \url{https://groups.google.com/group/comp.text.tex/browse_thread/thread/5d66395f2a1b5134/93fd9661484bd8d8?#93fd9661484bd8d8} +% a posting on ctt, \url{https://groups.google.com/group/comp.text.tex/browse_thread/thread/5d66395f2a1b5134/93fd9661484bd8d8?#93fd9661484bd8d8} % \begin{macrocode} \def\@Aboxed#1\ENDDNE{% \ifnum0=`{}\fi \setbox \z@ @@ -4499,6 +4766,7 @@ and the derived files \def\etb@tempa##1|#1|##2\MT@END{\endgroup \ifx\@empty##2\@empty\notag\fi}% \expandafter\etb@tempa\expandafter|alignedat|aligned|split|#1|\MT@END} + %| emacs % \end{macrocode} % These macros take care of removing the space above or below. Since % these may be useful for the user in very special cases, we provide @@ -4749,6 +5017,8 @@ and the derived files % \changes{v1.13}{2012/08/19}{The option was named differently in the % manual. Also renamed to use the postfix \emph{sep} instead. Though % the old names remain for compatibility.} +% \changes{v1.14}{2014/01/20}{Apparently did not check it good enough, +% the option should have shortintertext not short-intertext} % \begin{macrocode} \newdimen\l_MT_above_shortintertext_sep \newdimen\l_MT_below_shortintertext_sep @@ -4758,12 +5028,18 @@ and the derived files {belowshortintertextdim}{\setlength \l_MT_below_shortintertext_sep{#1}} \define@key{\MT_options_name:} {above-short-intertext-dim}{\setlength \l_MT_above_shortintertext_sep{#1}} +% old typo in manual \define@key{\MT_options_name:} {below-short-intertext-dim}{\setlength \l_MT_below_shortintertext_sep{#1}} \define@key{\MT_options_name:} {above-short-intertext-sep}{\setlength \l_MT_above_shortintertext_sep{#1}} +% old typo in manual \define@key{\MT_options_name:} {below-short-intertext-sep}{\setlength \l_MT_below_shortintertext_sep{#1}} +\define@key{\MT_options_name:} + {above-shortintertext-sep}{\setlength \l_MT_above_shortintertext_sep{#1}} +\define@key{\MT_options_name:} + {below-shortintertext-sep}{\setlength \l_MT_below_shortintertext_sep{#1}} % \end{macrocode} % Looks best with the `old' values of the original \cs{jot} % setting. So we set them to 3pt each. @@ -4926,7 +5202,7 @@ and the derived files % comp.text.tex on 1992/07/21 by Michael Herschorn. % With speed-ups by the Grand Wizard himself as shown on % \begin{quote}\rightskip-\leftmargini -% \url{http://www.tug.org/tex-archive/digests/tex-implementors/042} +% \url{http://mirrors.ctan.org/info/digests/tex-implementors/042} % \end{quote} % The (better) user interface by the author. % |