summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/mh/mathtools.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-02-13 00:07:08 +0000
committerKarl Berry <karl@freefriends.org>2013-02-13 00:07:08 +0000
commit2544b4503021f61f279205ee9cecd1b29a6615ec (patch)
tree89d542a6cf783a92dbebec9ef461f8a06a7712ab /Master/texmf-dist/source/latex/mh/mathtools.dtx
parent33b9decf3736250e2c7bc7c110b29116cef82dda (diff)
mh (12feb13)
git-svn-id: svn://tug.org/texlive/trunk@29094 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/mh/mathtools.dtx')
-rw-r--r--Master/texmf-dist/source/latex/mh/mathtools.dtx262
1 files changed, 220 insertions, 42 deletions
diff --git a/Master/texmf-dist/source/latex/mh/mathtools.dtx b/Master/texmf-dist/source/latex/mh/mathtools.dtx
index 6c76f41d408..8f3414345b9 100644
--- a/Master/texmf-dist/source/latex/mh/mathtools.dtx
+++ b/Master/texmf-dist/source/latex/mh/mathtools.dtx
@@ -1,6 +1,7 @@
% \iffalse meta-comment
%
% Copyright (C) 2004-2011 by Morten Hoegholm
+% Copyright (C) 2012 by Lars Madsen
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
@@ -67,7 +68,7 @@
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
-\Msg{* Package: mathtools 2012/05/10 v1.12}
+\Msg{* Package: mathtools 2013/02/12 v1.13}
\Msg{************************************************************************}
\keepsilent
@@ -78,6 +79,8 @@
This is a generated file.
Copyright (C) 2002-2011 by Morten Hoegholm
+Copyright (C) 2012 by Lars Madsen
+
This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either
@@ -128,7 +131,7 @@ and the derived files
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{mathtools.drv}%
- [2012/05/10 v1.12 mathematical typesetting tools]
+ [2013/02/12 v1.13 mathematical typesetting tools]
\documentclass{ltxdoc}
\IfFileExists{fourier.sty}{\usepackage{fourier}}{}
\addtolength\marginparwidth{-25pt}
@@ -319,6 +322,11 @@ and the derived files
% \begin{quote}\email{mh.ctan@gmail.com}\end{quote}
% This is of course also the address to use in case of bug reports.
%
+%
+% \medskip\noindent
+% Update 2013: We now makes \cs{(}\cs{)} and \cs[\cs]
+% robust (can be disabled via \texttt{nonrobust} package option).
+%
% \section{Package loading}
%
%
@@ -789,7 +797,7 @@ and the derived files
% change the appearence of the tags \emph{and} you are also using the
% \pkg{ntheorem} package, then please postpone the change of
% appearance until \emph{after} loading \pkg{ntheorem}. (In order to
-% do its thing \pkg{ntheorem} has to mess with the tags\dots)
+% do its thing, \pkg{ntheorem} has to mess with the tags\dots)
%
% \subsubsection{Showing only referenced tags}
%
@@ -919,12 +927,29 @@ and the derived files
% \medskip\noindent\textbf{BUG 2:} Currently there is a bug between
% \key{showonlyrefs} and the \pkg{ntheorem} package, when the
% \pkg{ntheorem} option \key{thmmarks} is active. The shown equation
-% numbers may come out wrong (seems to be multiplied by 2). The
-% easiest fix is to add the following line
+% numbers may come out wrong (seems to be multiplied by 2). Or the end
+% marker may be placed in the wrong place if a proof ends with a
+% displayed formula, and that formula is not refered to.
+%
+% There are two possible solutions to this both involving \pkg{empheq}.
+% The easiest fix is to add the following line
% \begin{verbatim}
% \usepackage[overload,ntheorem]{empheq}
% \end{verbatim}
-% before loading \pkg{ntheorem}. The \pkg{empheq} package fixes some
+% before loading \pkg{ntheorem}. But the \texttt{overload} option of
+% course disables things like \cs{intertext} and \cs{shotintertext}.
+%
+% The other thing to try is to use drop the \texttt{overload} option
+% and use \env{empheq} on the very last expression, as in
+% \begin{verbatim}
+% \begin{empheq}{align}
+% A &= B \label {eq:32}\\
+% & = 1. \label{eq:31}
+% \end{empheq}
+% \end{proof}
+% \end{verbatim}
+%
+% The \pkg{empheq} package fixes some
% problems with \pkg{ntheorem} and lets \pkg{mathtools} get correct
% access to the equation numbers again.
%
@@ -989,7 +1014,25 @@ and the derived files
% \cs{xleftrightharpoons}\oarg{sub}\marg{sup}
% \end{codesyntax}
% \pkg{mathtools} also provides the extensible harpoons shown above.
-% They're taken from~\cite{Voss:2004}.
+% They're taken from~\cite{Voss:2004}. For those liking visuals, here
+% are the macros in use in the order listed in the two boxes above.
+% \begin{align*}
+% A &\xleftrightarrow[below]{above} B &
+% A &\xRightarrow[below]{above} B \\
+% A &\xLeftarrow[below]{above} B &
+% A &\xLeftrightarrow[below]{above} B \\
+% A &\xhookleftarrow[below]{above} B &
+% A &\xhookrightarrow[below]{above} B \\
+% A &\xmapsto[below]{above} B \\
+% A &\xrightharpoondown[below]{above} B &
+% A &\xrightharpoonup[below]{above} B \\
+% A &\xleftharpoondown[below]{above} B &
+% A &\xleftharpoonup[below]{above} B \\
+% A &\xrightleftharpoons[below]{above} B &
+% A &\xleftrightharpoons[below]{above} B \\
+% \end{align*}
+%
+%
%
% \subsubsection{Braces and brackets}
%
@@ -1372,14 +1415,14 @@ and the derived files
% \begin{codesyntax}
% \SpecialEnvIndex{\MoveEqLeft}\cs{MoveEqLeft}\oarg{number}
% \end{codesyntax}
-% \ProvidedBy{Lars Madsen}{2008/06/05}
-% In \cite{Swanson}, Ellen Swanson recommends that when ever one has
-% a long displayed formula, spanning several lines, and it is
-% unfeasible to align against a relation within the first line, then
-% all lines in the display should be aligned at the left most edge of
-% the first line, and all subsequent lines should be indented by 2em
-% (or if needed by a smaller amount). That is we are talking about
-% displayes that end up looking like this
+% \ProvidedBy{Lars Madsen}{2008/06/05} In \cite{Swanson}, Ellen
+% Swanson recommends that when ever one has a long displayed formula,
+% spanning several lines, and it is unfeasible to align against a
+% relation within the first line, then all lines in the display
+% should be aligned at the left most edge of the first line, and all
+% subsequent lines should be indented by 2\,em (or if needed by a
+% smaller amount). That is we are talking about displayes that end up
+% looking like this
% \begin{align*}
% \MoveEqLeft \framebox[10cm][c]{Long first line}\\
% & = \framebox[6cm][c]{ \hphantom{g} 2nd line}\\
@@ -1668,10 +1711,10 @@ and the derived files
% \SpecialKeyIndex{original-intertext}$\key{original-intertext}=\texttt{true}\vert\texttt{false}$ \quad(default: \texttt{false})\\
% \SpecialKeyIndex{original-shortintertext}$\key{original-shortintertext}=\texttt{true}\vert\texttt{false}$
% \quad(default: \texttt{false})\\
-% \SpecialKeyIndex{above-intertext-dim}$\key{above-intertext-dim}=\meta{dimen}$ \quad(default: 0pt)\\
-% \SpecialKeyIndex{below-intertext-dim}$\key{below-intertext-dim}=\meta{dimen}$ \quad(default: 0pt)\\
-% \SpecialKeyIndex{above-shortintertext-dim}$\key{above-shortintertext-dim}=\meta{dimen}$ \quad(default: 3pt)\\
-% \SpecialKeyIndex{below-shortintertext-dim}$\key{below-shortintertext-dim}=\meta{dimen}$ \quad(default: 3pt)
+% \SpecialKeyIndex{above-intertext-sep}$\key{above-intertext-sep}=\meta{dimen}$ \quad(default: 0pt)\\
+% \SpecialKeyIndex{below-intertext-sep}$\key{below-intertext-sep}=\meta{dimen}$ \quad(default: 0pt)\\
+% \SpecialKeyIndex{above-shortintertext-sep}$\key{above-shortintertext-sep}=\meta{dimen}$ \quad(default: 3pt)\\
+% \SpecialKeyIndex{below-shortintertext-sep}$\key{below-shortintertext-sep}=\meta{dimen}$ \quad(default: 3pt)
% \end{codesyntax}
% The updated \cs{shortintertext} will look like the original version
% unless for areas with an enlarged \cs{jot} value (see for example
@@ -2031,6 +2074,8 @@ and the derived files
% \par
% \end{quote}
%
+% As of 2013, \cs(\cs) are robust, as is the italic corrected versions.
+%
% \subsection{Left sub/superscripts}
%
% \begin{codesyntax}
@@ -2397,7 +2442,7 @@ and the derived files
% \begin{macrocode}
%<*package>
\ProvidesPackage{mathtools}%
- [2012/04/24 v1.12 mathematical typesetting tools]
+ [2013/02/12 v1.13 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}}
@@ -2406,8 +2451,71 @@ and the derived files
\RequirePackage{mhsetup}[2010/01/21]
\MHInternalSyntaxOn
% \end{macrocode}
-%
-% \begin{macro}{\MT_options_name:}
+% \changes{v1.13}{2013/02/11}{Robustifying \cs{(}\cs{)}\cs{[}\cs{]}}
+% We'd like to make \cs{(}\cs{)} and \cs{[}\cs{]} robust. This can
+% easily be done via the \pkg{fixltx2e} package, but auto loading that
+% package may cause problems for some. We make copies instead.
+% \begin{macro}{\EQ_MakeRobust}
+% \begin{macro}{\forced_EQ_MakeRobust}
+% \begin{macrocode}
+ % borrowed from fixltx2e
+\def\EQ_MakeRobust#1{%
+ \@ifundefined{\expandafter\@gobble\string#1}{%
+ \@latex@error{The control sequence `\string#1' is undefined!%
+ \MessageBreak There is nothing here to make robust}%
+ \@eha
+ }%
+ {%
+ \@ifundefined{\expandafter\@gobble\string#1\space}%
+ {%
+ \expandafter\let\csname
+ \expandafter\@gobble\string#1\space\endcsname=#1%
+ \edef\reserved@a{\string#1}%
+ \def\reserved@b{#1}%
+ \edef\reserved@b{\expandafter\strip@prefix\meaning\reserved@b}%
+ \edef#1{%
+ \ifx\reserved@a\reserved@b
+ \noexpand\x@protect\noexpand#1%
+ \fi
+ \noexpand\protect\expandafter\noexpand
+ \csname\expandafter\@gobble\string#1\space\endcsname}%
+ }%
+ {\@latex@info{The control sequence `\string#1' is already robust}}%
+ }%
+}
+% \end{macrocode}
+% We also provide a handy alternativ version, that will robustify no
+% matter what. Useful for the \texttt{mathic} option.
+% \begin{macrocode}
+\def\forced_EQ_MakeRobust#1{%
+ \@ifundefined{\expandafter\@gobble\string#1}{%
+ \@latex@error{The control sequence `\string#1' is undefined!%
+ \MessageBreak There is nothing here to make robust}%
+ \@eha
+ }%
+ {%
+ % \@ifundefined{\expandafter\@gobble\string#1\space}%
+ % {%
+ \expandafter\let\csname
+ \expandafter\@gobble\string#1\space\endcsname=#1%
+ \edef\reserved@a{\string#1}%
+ \def\reserved@b{#1}%
+ \edef\reserved@b{\expandafter\strip@prefix\meaning\reserved@b}%
+ \edef#1{%
+ \ifx\reserved@a\reserved@b
+ \noexpand\x@protect\noexpand#1%
+ \fi
+ \noexpand\protect\expandafter\noexpand
+ \csname\expandafter\@gobble\string#1\space\endcsname}%
+ % }%
+ % {\@latex@info{The control sequence `\string#1' is already robust}}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\MT_options_name:}
% \begin{macro}{\mathtoolsset}
% The name for the options and a user interface for setting keys.
% \begin{macrocode}
@@ -2442,11 +2550,24 @@ and the derived files
\MH_let:NwN \MH_maybe_nospace_ifnextchar:Nnn \MH_nospace_ifnextchar:Nnn
}
% \end{macrocode}
+% \changes{v1.13}{2013/02/11}{Option to disable robustifying
+% \cs{(}\cs{)} and \cs{[}\cs{]}}
+% Option to disallow robustifying \cs{(}\cs{)} and \cs{[}\cs{]}.
+% \begin{macrocode}
+\MH_new_boolean:n {robustify}
+\MH_set_boolean_T:n {robustify}
+\DeclareOption{nonrobust}{
+ \MH_set_boolean_F:n {robustify}
+}
+% \end{macrocode}
% Pass all other options directly to \pkg{amsmath}.
% \begin{macrocode}
\DeclareOption*{
\PassOptionsToPackage{\CurrentOption}{amsmath}
}
+% \end{macrocode}
+% Executing options
+% \begin{macrocode}
\ExecuteOptions{fixamsmath,disallowspaces}
\ProcessOptions\relax
% \end{macrocode}
@@ -2467,6 +2588,19 @@ and the derived files
}
% \end{macrocode}
% \end{macro}
+% \changes{v1.13}{2013/02/11}{Make \cs{(}\cs{)} and \cs{[}\cs{]}
+% robust}
+% We start of with making \cs{(}\cs{)} and \cs{[}\cs{]} robust,
+% unless the user explicitly asked us not to.
+% \begin{macrocode}
+\MH_if_boolean:nT {robustify}{
+ \EQ_MakeRobust\(
+ \EQ_MakeRobust\)
+ \EQ_MakeRobust\[
+ \EQ_MakeRobust\]
+}
+% \end{macrocode}
+%
%
% \section{Macros I got ideas for myself}
%
@@ -4516,20 +4650,31 @@ and the derived files
% original \cs{intertext} in case a user would rather want it.
% \begin{macro}{\MT_orig_intertext:}
% \begin{macro}{\MT_intertext:}
-% \begin{macro}{\l_MT_above_intertext_dim}
-% \begin{macro}{\l_MT_below_intertext_dim}
+% \changes{v1.13}{2012/08/19}{\cs{l_MT_X_intertext_dim} renamed to
+% \cs{l_MT_X_intertext_sep}}
+% \begin{macro}{\l_MT_above_intertext_sep}
+% \begin{macro}{\l_MT_below_intertext_sep}
% First store the originam Ams version.
% \begin{macrocode}
\MH_let:NwN \MT_orig_intertext: \intertext@
% \end{macrocode}
% And then for some reconfiguration. First a few lengths
+% \changes{v1.13}{2012/08/19}{Fixed typos and changed the names}
% \begin{macrocode}
-\newdimen\l_MT_above_intertext_dim
-\newdimen\l_MT_below_intertext_dim
+\newdimen\l_MT_above_intertext_sep
+\newdimen\l_MT_below_intertext_sep
\define@key{\MT_options_name:}
- {aboveintertextdim}{\setlength\l_MT_above_interetext_dim{#1}}
+ {aboveintertextdim}{\setlength\l_MT_above_intertext_sep{#1}}
\define@key{\MT_options_name:}
- {belowintertextdim}{\setlength\l_MT_below_intertext_dim{#1}}
+ {belowintertextdim}{\setlength\l_MT_below_intertext_sep{#1}}
+\define@key{\MT_options_name:}
+ {above-intertext-dim}{\setlength\l_MT_above_intertext_sep{#1}}
+\define@key{\MT_options_name:}
+ {below-intertext-dim}{\setlength\l_MT_below_intertext_sep{#1}}
+\define@key{\MT_options_name:}
+ {above-intertext-sep}{\setlength\l_MT_above_intertext_sep{#1}}
+\define@key{\MT_options_name:}
+ {below-intertext-sep}{\setlength\l_MT_below_intertext_sep{#1}}
% \end{macrocode}
% Their default values are zero. Now for our extended version of
% CCShan's solution.
@@ -4541,7 +4686,7 @@ and the derived files
\penalty\postdisplaypenalty\vskip\belowdisplayskip
\vskip-\lineskiplimit % CCS
\vskip\normallineskiplimit % CCS
- \vskip\l_MT_above_intertext_dim
+ \vskip\l_MT_above_intertext_sep
\vbox{\normalbaselines
\ifdim\linewidth=\columnwidth
\else \parshape\@ne \@totalleftmargin \linewidth
@@ -4550,7 +4695,7 @@ and the derived files
\penalty\predisplaypenalty\vskip\abovedisplayskip%
\vskip-\lineskiplimit % CCS
\vskip\normallineskiplimit % CCS
- \vskip\l_MT_above_intertext_dim
+ \vskip\l_MT_above_intertext_sep
}%
}}
% \end{macrocode}
@@ -4578,8 +4723,8 @@ and the derived files
% \begin{macro}{\shortintertext}
% \begin{macro}{\MT_orig_shortintertext}
% \begin{macro}{\MT_shortintertext}
-% \begin{macro}{\l_above_shortintertext_dim}
-% \begin{macro}{\l_below_shortintertext_dim}
+% \begin{macro}{\l_above_shortintertext_sep}
+% \begin{macro}{\l_below_shortintertext_sep}
% This is like \cs{intertext} but uses shorter skips between the
% math. Again this turned out to have the same problem as
% \cs{intertext}, so we provide two versions.
@@ -4599,13 +4744,24 @@ and the derived files
}
% \end{macrocode}
% Lengths like above
+% \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.}
% \begin{macrocode}
-\newdimen\l_MT_above_shortintertext_dim
-\newdimen\l_MT_below_shortintertext_dim
+\newdimen\l_MT_above_shortintertext_sep
+\newdimen\l_MT_below_shortintertext_sep
+\define@key{\MT_options_name:}
+ {aboveshortintertextdim}{\setlength \l_MT_above_shortintertext_sep{#1}}
+\define@key{\MT_options_name:}
+ {belowshortintertextdim}{\setlength \l_MT_below_shortintertext_sep{#1}}
\define@key{\MT_options_name:}
- {aboveshortintertextdim}{\setlength \l_MT_above_shortintertext_dim{#1}}
+ {above-short-intertext-dim}{\setlength \l_MT_above_shortintertext_sep{#1}}
\define@key{\MT_options_name:}
- {belowshortintertextdim}{\setlength \l_MT_below_shortintertext_dim{#1}}
+ {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}}
+\define@key{\MT_options_name:}
+ {below-short-intertext-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.
@@ -4623,7 +4779,7 @@ and the derived files
\penalty\postdisplaypenalty\vskip\abovedisplayshortskip
\vskip-\lineskiplimit
\vskip\normallineskiplimit
- \vskip\l_MT_above_shortintertext_dim
+ \vskip\l_MT_above_shortintertext_sep
\vbox{\normalbaselines
\if_dim:w \linewidth=\columnwidth
\else:
@@ -4633,7 +4789,7 @@ and the derived files
\penalty\predisplaypenalty\vskip\abovedisplayshortskip%
\vskip-\lineskiplimit
\vskip\normallineskiplimit
- \vskip\l_MT_below_shortintertext_dim
+ \vskip\l_MT_below_shortintertext_sep
}%
}
% \end{macrocode}
@@ -4982,16 +5138,28 @@ and the derived files
% \begin{macro}{\MT_mathic_true:}
% \begin{macro}{\MT_mathic_false:}
% Renew \cs{(} so that it detects the slant of the font and inserts
-% an italic correction.
+% an italic correction. In January 2013 Andrew Swann suggested that
+% this should be made robust. It is a little tricky, but seems to
+% work.
+% \changes{v1.13}{2013/02/11}{Added robustness code}
% \begin{macrocode}
\def\MT_mathic_true: {
\MH_if_boolean:nF {math_italic_corr}{
\MH_set_boolean_T:n {math_italic_corr}
% \end{macrocode}
-% Save the original meaning if you need to go back.
+% 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).
% \begin{macrocode}
+ \MH_if_boolean:nTF {robustify}{
+ \MH_let:NwN \MT_mathic_redeffer: \DeclareRobustCommand
+ }{
+ \MH_let:NwN \MT_mathic_redeffer: \renewcommand
+ }
\MH_let:NwN \MT_begin_inlinemath: \(
- \renewcommand*\({\relax\ifmmode\@badmath\else
+ %\renewcommand*\({
+ \MT_mathic_redeffer:*\({
+ \relax\ifmmode\@badmath\else
\ifhmode
\if_dim:w \fontdimen\@ne\font>\z@
\if_dim:w \lastskip>\z@
@@ -5014,7 +5182,17 @@ and the derived files
\def\MT_mathic_false: {
\MH_if_boolean:nT {math_italic_corr}{
\MH_set_boolean_F:n {math_italic_corr}
- \MH_let:NwN \( \MT_begin_inlinemath:
+% \end{macrocode}
+% When \cs{(} is robust, we cannot simply relet it to the old value,
+% as all the robust macro is not saved. Instead we redefined partly
+% and force robustness.
+% \begin{macrocode}
+ \MH_if_boolean:nTF {robustify}{
+ \edef\({\MT_begin_inlinemath:}%
+ \forced_EQ_MakeRobust\(%
+ }{
+ \MH_let:NwN \( \MT_begin_inlinemath:
+ }
}
}
\MH_new_boolean:n {math_italic_corr}