summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-01-11 23:55:08 +0000
committerKarl Berry <karl@freefriends.org>2006-01-11 23:55:08 +0000
commit018eddbb412852f79bbfcee05c61b8a959601a6d (patch)
tree7cf67ac127efeae65589f319ee31a5ae0584be8d
parentd9aa4a0d0dc45506f1b4d1b4454769c50eefc2a9 (diff)
trunk/Master/texmf-dist/source/latex/mh
git-svn-id: svn://tug.org/texlive/trunk@387 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/source/latex/mh/empheq.dtx4050
-rw-r--r--Master/texmf-dist/source/latex/mh/empheq.ins56
-rw-r--r--Master/texmf-dist/source/latex/mh/empheq07.dtx1402
-rw-r--r--Master/texmf-dist/source/latex/mh/empheq07.ins54
-rw-r--r--Master/texmf-dist/source/latex/mh/mathtools.dtx3688
-rw-r--r--Master/texmf-dist/source/latex/mh/mathtools.ins54
-rw-r--r--Master/texmf-dist/source/latex/mh/mhsetup.dtx528
-rw-r--r--Master/texmf-dist/source/latex/mh/mhsetup.ins54
8 files changed, 9886 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/mh/empheq.dtx b/Master/texmf-dist/source/latex/mh/empheq.dtx
new file mode 100644
index 00000000000..32f5fadbbd4
--- /dev/null
+++ b/Master/texmf-dist/source/latex/mh/empheq.dtx
@@ -0,0 +1,4050 @@
+% \iffalse meta-comment
+% File `empheq.dtx'.
+% Copyright 2002-2004 Morten H\o gholm.
+% moho01ab@student.cbs.dk
+%
+% It 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.
+% 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 2003/12/01 or later.
+%
+% This work has the LPPL maintenance status "maintained".
+%
+% The Current Maintainer of this work is Morten H\o gholm.
+%
+% This work consists of the files empheq.dtx and empheq.ins and the
+% derived files empheq.sty and ntheorem.fix.
+% \fi
+% \iffalse
+%<empheq>\NeedsTeXFormat{LaTeX2e}
+%<empheq>\ProvidesPackage{empheq}
+%<ntheorem>\ProvidesFile{ntheorem.fix}
+%<*dtx>
+ \ProvidesFile{empheq.dtx}
+%</dtx>
+ [2004/10/10 v2.11a
+%<empheq> Emphasizing equations (MH)
+%<ntheorem> empheq support and fixes for ntheorem (MH)
+ ]
+%<*driver>
+\documentclass[a4paper]{ltxdoc}
+\usepackage[overload]{empheq}
+\usepackage{color,varioref,booktabs,fancybox}
+
+\pagestyle{headings}
+\hyphenation{emph-eq}
+\makeatletter
+\providecommand*\pkg[1]{\textsf{#1}}
+\providecommand*\env[1]{\texttt{#1}}
+\providecommand*\email[1]{\href{mailto:#1}{\texttt{#1}}}
+\providecommand*\mode[1]{\texttt{[#1]}}
+\providecommand*\file[1]{\texttt{#1}}
+\addtolength\marginparwidth{-30pt}
+
+
+\newcommand*\AddDescribe[3]{%
+ \@namedef{Describe#1}{\leavevmode\@bsphack\begingroup\MakePrivateLetters
+ \@nameuse{Describe@#1}}
+ \@namedef{Describe@#1}##1{\endgroup
+ \marginpar{\raggedleft\@nameuse{PrintDescribe#1}{##1}}%
+ \@nameuse{Special#1Index}{##1}\@esphack\ignorespaces}
+ \@namedef{Special#1Index}##1{\@bsphack
+ \index{##1\actualchar{\protect\ttfamily ##1}
+ (#2)\encapchar usage}%
+ \index{#3:\levelchar##1\actualchar{\protect\ttfamily ##1}\encapchar
+ usage}\@esphack}
+ \@namedef{PrintDescribe#1}##1{\strut \MacroFont ##1\ }%
+ \@namedef{Print#1Name}##1{\strut \MacroFont ##1\ }%
+}
+\AddDescribe{Color}{color}{colors}
+\AddDescribe{KeyFamily}{key family}{key families}
+\newcommand*\DescribeDelimiter[1]{%
+ \cs{#1}&\SpecialMkhIndex{empheq#1}\cs{empheq}\texttt{#1} &
+ \SpecialMkhIndex{empheqbig#1}\cs{empheqbig}\texttt{#1} &
+ $\@nameuse{#1}$\tabularnewline}
+\newcommand*\SpecialMkhIndex[1]{%
+ \@bsphack
+ \index{#1\actualchar{\protect\ttfamily \protect\bslash\space#1}
+ (` $\bslash#1$ ')\encapchar usage}%
+ \@esphack
+}
+\newcommand\TabDescribeOption[3][(default)]{%
+ \SpecialOptIndex{#2}\opt{#2} & #3 \tabularnewline
+}
+\newcommand*\TabDescribeAmsKey[2][]{%
+ \SpecialKeyIndex{#2}\env{#2} &
+ \texttt{\{#2#1\}} &
+ \SpecialKeyIndex{#2*}\env{#2*} &
+ \texttt{\{#2*#1\}} \tabularnewline
+}
+\newcommand*\TabDescribeOptKey[3][]{%
+ \SpecialKeyIndex{#2}\key{#2} &
+ \texttt{#2=}\meta{#3} & #1 \tabularnewline
+}
+
+\newenvironment{codesyntax}
+ {\par\small\addvspace{4.5ex plus 1ex}%
+ \vskip -\parskip
+ \noindent
+ \begin{tabular}{|l|}\hline\ignorespaces}%
+ {\\\hline\end{tabular}\nobreak\par\nobreak
+ \vspace{2.3ex}\vskip -\parskip\noindent\ignorespacesafterend}
+\makeatletter
+
+\newcommand*\FeatureRequest[2]{%
+ \hskip1sp
+ \marginpar{%
+ \parbox[b]{\marginparwidth}{\small\sffamily\raggedright
+ \strut Feature request by\\#1\\#2%
+ }
+ }%
+}
+
+\newcommand*\cttPosting[2]{%
+ \hskip1sp
+ \marginpar{%
+ \parbox[b]{\marginparwidth}{\small\sffamily\raggedright
+ \strut Posted on \texttt{comp.text.tex} \\#1\\#2%
+ }%
+ }%
+}
+
+\expandafter\def\expandafter\MakePrivateLetters\expandafter{%
+ \MakePrivateLetters \catcode`\_=11\relax
+}
+
+\providecommand*\SpecialOptIndex[1]{%
+ \@bsphack
+ \index{#1\actualchar{\protect\ttfamily #1}
+ (option)\encapchar usage}%
+ \index{options:\levelchar#1\actualchar{\protect\ttfamily #1}\encapchar
+ usage}\@esphack}
+\providecommand*\opt[1]{\texttt{#1}}
+
+\providecommand*\SpecialKeyIndex[1]{%
+ \@bsphack
+ \index{#1\actualchar{\protect\ttfamily #1}
+ (key)\encapchar usage}%
+ \index{keys:\levelchar#1\actualchar{\protect\ttfamily #1}\encapchar
+ usage}\@esphack}
+\providecommand*\key[1]{\textsf{#1}}
+\providecommand*\keyfam[1]{\textsf{#1}}
+
+\providecommand*\eTeX{$\m@th\varepsilon$-\TeX}
+
+\def\MTmeta#1{%
+ \ensuremath\langle
+ \ifmmode \expandafter \nfss@text \fi
+ {%
+ \meta@font@select
+ \edef\meta@hyphen@restore
+ {\hyphenchar\the\font\the\hyphenchar\font}%
+ \hyphenchar\font\m@ne
+ \language\l@nohyphenation
+ #1\/%
+ \meta@hyphen@restore
+ }\ensuremath\rangle
+ \endgroup
+}
+\makeatother
+\DeclareRobustCommand\meta{\begingroup\MakePrivateLetters\MTmeta}%
+\def\MToarg#1{{\ttfamily[}\meta{#1}{\ttfamily]}\endgroup}
+\DeclareRobustCommand\oarg{\begingroup\MakePrivateLetters\MToarg}%
+\def\MHmarg#1{{\ttfamily\char`\{}\meta{#1}{\ttfamily\char`\}}\endgroup}
+\DeclareRobustCommand\marg{\begingroup\MakePrivateLetters\MHmarg}%
+\def\MHarg#1{{\ttfamily\char`\{#1\ttfamily\char`\}}\endgroup}
+\DeclareRobustCommand\arg{\begingroup\MakePrivateLetters\MHarg}%
+\def\MHcs#1{\texttt{\char`\\#1}\endgroup}
+\DeclareRobustCommand\cs{\begingroup\MakePrivateLetters\MHcs}
+\def\MHbool#1{{\ttfamily #1}\endgroup}
+\DeclareRobustCommand\bool{\begingroup\MakePrivateLetters\MHbool}%
+
+\def\endverbatim{\if@newlist
+\leavevmode\fi\endtrivlist\vspace{-\baselineskip}}
+\expandafter\let\csname endverbatim*\endcsname =\endverbatim
+
+\let\MTtheindex\theindex
+\def\theindex{\MTtheindex\MakePrivateLetters}
+
+\newcommand*\widefbox[1]{\fbox{\hspace{1em}#1\hspace{1em}}}
+\definecolor{myblue}{rgb}{.8, .8, 1}
+\newcommand*\mybluebox[1]{%
+ \colorbox{myblue}{\hspace{1em}#1\hspace{1em}}}
+\newenvironment{important}[2][]{%
+ \setkeys{EmphEqEnv}{#2}%
+ \setkeys{EmphEqOpt}{box=\mybluebox,#1}%
+ \EmphEqMainEnv}%
+ {\endEmphEqMainEnv}
+\definecolor{shadecolor}{cmyk}{0,0,0.41,0}
+\definecolor{light-blue}{cmyk}{0.25,0,0,0}
+\newsavebox{\mysaveboxM} % M for math
+\newsavebox{\mysaveboxT} % T for text
+\newcommand*\Garybox[2][Example]{%
+ \sbox{\mysaveboxM}{#2}%
+ \sbox{\mysaveboxT}{\fcolorbox{black}{light-blue}{#1}}%
+ \sbox{\mysaveboxM}{%
+ \parbox[b][\ht\mysaveboxM+.5\ht\mysaveboxT+.5\dp\mysaveboxT][b]{%
+ \wd\mysaveboxM}{#2}%
+ }%
+ \sbox{\mysaveboxM}{%
+ \fcolorbox{black}{shadecolor}{%
+ \makebox[\linewidth-10em]{\usebox{\mysaveboxM}}%
+ }%
+ }%
+ \usebox{\mysaveboxM}%
+ \makebox[0pt][r]{%
+ \makebox[\wd\mysaveboxM][c]{%
+ \raisebox{\ht\mysaveboxM-0.5\ht\mysaveboxT
+ +0.5\dp\mysaveboxT-0.5\fboxrule}{\usebox{\mysaveboxT}}%
+ }%
+ }%
+}
+
+\newcommand\EmphEqpart{%
+ \def\partname{\EmphEqpartname}%
+ \part}
+
+\def\EmphEqpartname{Part}
+\makeatother
+
+\usepackage{graphicx}
+\usepackage[final,breaklinks=true,hyperindex=false,linkbordercolor=false]{hyperref}
+\renewcommand*\usage[1]{\textit{\hyperpage{#1}}}
+
+\OnlyDescription
+\begin{document}
+\DocInput{empheq.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \changes{v2.11}{2004/08/03}{Removed interface to the obsolete empheq
+% package \pkg{empheq07}}
+%
+% \changes{v2.10}{2004/07/26}{Rewrote most of the documentation}
+%
+% \changes{v2.10}{2004/07/26}{Moved options \texttt{fixamsmath} and
+% \texttt{donotfixamsmathbugs} to \pkg{mathtools}}
+%
+% \changes{v2.10}{2004/07/26}{Added support for \pkg{showkeys}}
+%
+% \changes{v2.00}{2004/04/14}{Added options \opt{overload},
+% \opt{overload2}, \texttt{fixamsmath}, and
+% \texttt{donotfixamsmathbugs} plus descriptions of their use}
+%
+% \changes{v1.06}{2004/03/13}{Upgraded license to LPPL version 1.3}
+%
+% \changes{v1.00}{2004/02/15}{Complete rewrite of the package hence
+% no description of the changes made}
+%
+% \changes{v0.7a}{2004/02/15}{Made the old package obsolete and
+% changed its name to \pkg{empheq-obsolete}}
+%
+% \changes{v0.7}{2003/05/11}{Added further examples and changed
+% existing ones}
+% \changes{v0.6b}{2003/03/04}{Added example for changing margins
+% inside the boxtype}
+% \changes{v0.6a}{2003/01/28}{Minor updates to documentation}
+%
+% \changes{v0.5}{2002/12/30}{First experimental and very limited
+% release}
+%
+% \GetFileInfo{empheq.dtx}
+% \CheckSum{2495}
+%
+% \title{The \pkg{empheq} package\thanks{This file has version number
+% \fileversion, last revised \filedate.}\\
+% Emphasizing equations in \LaTeXe}
+% \author{Morten H\o gholm}
+% \date{\filedate}
+%
+% \maketitle
+%
+% \begin{abstract}
+% The \pkg{empheq} package can best be described as a visual markup
+% extension to \pkg{amsmath}. In short it offers a)~a multi line
+% equivalent of \cs{boxed} from \pkg{amsmath} and b)~a way to
+% produce arbitrary delimiters that span entire math displays.
+% \end{abstract}
+%
+% \tableofcontents
+%
+% \clearpage
+% \EmphEqpart{Basic user's guide}
+%
+% There can be little doubt that the de facto standard for
+% mathematical typesetting in \LaTeX{} is the \pkg{amsmath} package.
+% For the creation of \pkg{empheq}, a visual markup package for use
+% in math, it made perfect sense to have \pkg{amsmath} as the
+% backbone.
+%
+% The main idea of \pkg{empheq} is to maintain the familiar syntax
+% of the \pkg{amsmath} environments while still providing an easy
+% way of specifying markup instructions. This manual is plastered
+% with examples showing just how.
+%
+%
+% \section{Basic use of the package}
+%
+% So what is it \pkg{empheq} does? Well, it allows you to produce
+% displays like this:
+% \begin{subequations}
+% \begin{empheq}[
+% box=\mybluebox,
+% right={\;\makebox[.9em]{$\raisebox{-.5\totalheight+\fontdimen22\textfont2}
+% {\resizebox{!}{\EmphEqdisplayheight+\EmphEqdisplaydepth}{!}}$}},
+% left={X=Y\Rightarrow\empheqlbrace}
+% ]{alignat=3}
+% A_1&=b_1 & \qquad c_1&=d_1 & \qquad e_1&= f_1
+% \tag*{\_A\raisebox{1ex}{silly}\raisebox{-1ex}{tag}\_}\\
+% A_2&=b_2 & \qquad c_2&=d_2 & \qquad e_2&= f_2 \\
+% A_3&=b_3 & \qquad c_3&=d_3 & \qquad e_3&= f_3
+% \end{empheq}
+% \end{subequations}
+% In short \pkg{empheq} enables the user to put things on every side
+% of the display without said user having to worry about what
+% happens to the equation numbers. For example you can now have a
+% display containing multiple lines and still get the effect of the
+% \cs{boxed} command from \pkg{amsmath}.
+%
+%
+% \subsection{Using the \env{empheq} environment}
+%
+% The package defines a single environment
+% \SpecialEnvIndex{empheq}\env{empheq} and the usage is kind of straight
+% forward:
+% \begin{codesyntax}
+% |\begin{empheq}|\oarg{markup instructions}\marg{\AmS{} env_name}\\
+% \mbox{}\quad\meta{contents of \AmS{} environment}\\
+% |\end{empheq}|
+% \end{codesyntax}
+% A first minimal example file would then be something like
+% \begin{verbatim}
+% \documentclass{minimal}
+% \usepackage{empheq}
+% \begin{document}
+% \begin{empheq}{align*}
+% a&=b \tag{*}\\
+% E&=mc^2 + \int_a^a x\, dx
+% \end{empheq}
+% \end{document}
+% \end{verbatim}
+% This gives the following display:
+% \begin{empheq}{align*}
+% a&=b \tag{*}\\
+% E&=mc^2 + \int_a^a x\, dx
+% \end{empheq}
+% Maybe not the most impressive example, but as you can see the
+% contents of the environment is exactly the same as for the regular
+% \env{align*} evironment from \pkg{amsmath}. The rest of the \AmS{}
+% environments are chosen the same way by typing the name as the
+% mandatory argument of \env{empheq} with the exception of the
+% \env{alignat} environment. For this you have to specify the number
+% of columns as shown below.
+% \begin{verbatim}
+% \begin{empheq}{alignat=2}
+% a &= b &\quad c &= d \\
+% \text{this} &= \text{that} &\quad \mathit{fish}&\neq fish
+% \end{empheq}
+% \end{verbatim}
+% \begin{empheq}{alignat=2}
+% a &= b &\quad c &= d \\
+% \text{this} &= \text{that} &\quad \mathit{fish}&\neq fish
+% \end{empheq}
+% To choose the starred version of \env{alignat}, simply type
+% \arg{alignat*=2} instead in the above example.
+%
+% The supported \AmS{} environments are listed in Table
+% \vref{tab:environments}. Not supported is the standard \LaTeX{}
+% \env{eqnarray} environment as it is fundamentally
+% deficient.\footnote{See for instance
+% \url{http://www.tex.ac.uk/cgi-bin/texfaq2html?label=eqnarray}}
+%
+% \begin{table}
+% \centering
+% \begin{tabular}{llll}\toprule
+% Environment & Usage & Environment & Usage \\ \midrule
+% \TabDescribeAmsKey{equation}
+% \TabDescribeAmsKey{align}
+% \TabDescribeAmsKey{gather}
+% \TabDescribeAmsKey{flalign}
+% \TabDescribeAmsKey[=\textrm{\meta{cols}}]{alignat}
+% \TabDescribeAmsKey{multline} \bottomrule
+% \end{tabular}
+% \caption{The supported \pkg{amsmath}
+% environments}\label{tab:environments}
+% \end{table}
+%
+%
+% \subsection{Markup instructions}
+%
+% The optional argument of the \env{empheq} environment will take
+% markup instructions consisting of a $\meta{key}=\meta{value}$ list
+% of assignments. There are currently five such keys (a sixth is
+% added for naming consistency). They're shown in Table
+% \vref{tab:keys}.
+%
+% \begin{table}
+% \centering
+% \begin{tabular}{llp{13em}}\toprule
+% Key & Usage & Additional Info \tabularnewline \midrule
+% \TabDescribeOptKey{box}{box command}
+% \TabDescribeOptKey{innerbox}{box command}
+% \TabDescribeOptKey[Use \cs{text}\arg{...} if you need text
+% material.]{left}{math material}
+% \TabDescribeOptKey[Use \cs{text}\arg{...} if you need text
+% material.]{right}{math material}
+% \TabDescribeOptKey[Alias for \key{box}.]{outerbox}{box command}
+% \TabDescribeOptKey[Contents must be horizontally centered;
+% can only be used in \mode{fleqn} mode.]
+% {marginbox}{box command}
+% \bottomrule
+% \end{tabular}
+% \caption{The six keys for the optional argument of the
+% \env{empheq} environment}\label{tab:keys}
+% \end{table}
+%
+% \begin{codesyntax}
+% \SpecialKeyIndex{left}\key{left}
+% \end{codesyntax}
+% The key \key{left} is for material put on the left side of the
+% display. The material is typeset in math mode and centered
+% vertically.
+% \begin{verbatim}
+% \begin{empheq}[left=L\Rightarrow]{align}
+% a&=b\\
+% E&=mc^2 + \int_a^a x\, dx
+% \end{empheq}
+% \end{verbatim}
+% \begin{empheq}[left=L\Rightarrow]{align}
+% a&=b\\
+% E&=mc^2 + \int_a^a x\, dx
+% \end{empheq}
+%
+%
+% \begin{codesyntax}
+% \SpecialKeyIndex{right}\key{right}
+% \end{codesyntax}
+% As there is a \key{left} key it hopefully comes as no surprise
+% that there is a companion \key{right} key for typesetting material
+% on the right side of the display.
+% \begin{verbatim}
+% \begin{empheq}[right=\Leftarrow R]{align}
+% a&=b\\
+% E&=mc^2 + \int_a^a x\, dx
+% \end{empheq}
+% \end{verbatim}
+% \begin{empheq}[right=\Leftarrow R]{align}
+% a&=b\\
+% E&=mc^2 + \int_a^a x\, dx
+% \end{empheq}
+%
+% \begin{codesyntax}
+% \SpecialKeyIndex{box}\key{box}\\
+% \SpecialKeyIndex{outerbox}\key{outerbox}
+% \end{codesyntax}
+% The key \key{box} specifies the kind of box you would like to put
+% around the display. It can be any kind of box, as long as the
+% contents of the box is situated on the baseline like in a
+% \fbox{\cs{fbox}}.
+% \begin{verbatim}
+% \begin{empheq}[box=\fbox]{align}
+% a&=b\\
+% E&=mc^2 + \int_a^a x\, dx
+% \end{empheq}
+% \end{verbatim}
+% \begin{empheq}[box=\fbox]{align}
+% a&=b\\
+% E&=mc^2 + \int_a^a x\, dx
+% \end{empheq}
+% The key \key{outerbox} is an alias for \key{box} and is added for
+% naming consistency with the key described below.
+%
+% \begin{codesyntax}
+% \SpecialKeyIndex{innerbox}\key{innerbox}
+% \end{codesyntax}
+% There is also an \key{innerbox} key. It is not very interesting
+% unless you use one of the other keys.
+% \begin{verbatim}
+% \begin{empheq}[innerbox=\fbox,
+% left=L\Rightarrow]{align}
+% a&=b\\
+% E&=mc^2 + \int_a^a x\, dx
+% \end{empheq}
+% \end{verbatim}
+% \begin{empheq}[innerbox=\fbox,
+% left=L\Rightarrow]{align}
+% a&=b\\
+% E&=mc^2 + \int_a^a x\, dx
+% \end{empheq}
+%
+% \begin{codesyntax}
+% \SpecialKeyIndex{marginbox}\key{marginbox}
+% \end{codesyntax}
+% \FeatureRequest{Uwe Siart}{2003/12/08}
+% The last key is the \key{marginbox} key. If you typeset your math
+% in \mode{fleqn} mode\footnote{Sorry, but I can't show you because
+% this manual features centered math displays.} you may want the
+% math display and not the outer box to align at the left margin (or
+% rather: the indentation). If you make sure the contents of the
+% outer box is centered horizontally inside the box, \key{marginbox}
+% will align it properly. You shouldn't set both \key{box} and
+% \key{marginbox} at the same time, as this is surely not what you
+% want and the package will silently use the last one in the list.
+%
+%
+% \begin{quote}
+% \textbf{Warning}: \pkg{keyval} treats commas and equal signs as
+% separator and assignment signs which in turn means that if you
+% want to typeset either of them, they \emph{must}---and believe me,
+% it's really important---be enclosed in braces. In short:
+% \begin{description}
+% \item[{\makebox[3em][l]{Good}}] \texttt{[left=\{(A,B)=(1,0)\}]}
+% \item[{\makebox[3em][l]{Bad}}] \texttt{[left=(A,B)=(1,0)]}
+% \end{description}
+% \end{quote}
+%
+% \begin{codesyntax}
+% \SpecialUsageIndex{\empheqset}\cs{empheqset}\marg{markup instructions}
+% \end{codesyntax}
+% \FeatureRequest{Uwe Siart}{2004/01/13}
+% You can also set the keys globally\footnote{Or rather: outside the
+% scope of the \env{empheq} environment. The settings will still
+% obey scoping rules.} with the command
+% \cs{empheqset}. This means that
+% \begin{verbatim}
+% \empheqset{marginbox=\psframebox}
+% \end{verbatim}
+% will force a |box=\psframebox| in all occurrences of the
+% \env{empheq} environment, but an explicitly given \key{box} or
+% \key{marginbox} will override this setting. You can only use the
+% keys listed in this section as arguments to \cs{empheqset}; not
+% the \AmS\ environments.
+%
+%
+%
+% \subsection{What won't work in the \env{empheq} environment}
+%
+% \begin{codesyntax}
+% \SpecialUsageIndex{intertext}\cs{intertext}\marg{text}\\
+% \SpecialUsageIndex{displaybreak}\cs{displaybreak}\oarg{num}
+% \end{codesyntax}
+% Now we've seen some of the things that work in the \env{empheq}
+% environment but we also have to take note of what won't work. As
+% this package provides a way to box multi line math displays it can
+% come as no surprise that using either \cs{intertext} or
+% \cs{displaybreak} inside the \env{empheq} environment makes no
+% sense. Should you however happen to try them anyway, you'll
+% experience that \cs{intertext} issues an error message and
+% \cs{displaybreak} issues a warning. The reason only \cs{intertext}
+% gives an error message is that you'll get output very different
+% from what you expect, and that is not the case (so much at least)
+% with \cs{displaybreak}. But of course, you'll never see either
+% message because you read the manual!
+%
+%
+%
+% \subsection{Special delimiters}
+%
+% As you've seen a few pages back, it's possible to add material on
+% both sides of the math display. When doing so you often need a
+% delimiter that scales to fit the entire display, so it comes as no
+% surprise that \pkg{empheq} provides such delimiters.
+% \begin{codesyntax}
+% \cs{empheql}\meta{delim_name} \cs{empheqbigl}\meta{delim_name}\\
+% \cs{empheqr}\meta{delim_name} \cs{empheqbigr}\meta{delim_name}
+% \end{codesyntax}
+% For example one might need a large brace like the one in the
+% \env{cases} environment:
+% \begin{verbatim}
+% \begin{empheq}[left=\empheqlbrace, right=\empheqrbrace]{align}
+% E&=mc^2 \\
+% Y&= \sum_{n=1}^\infty \frac{1}{n^2}
+% \end{empheq}
+% \end{verbatim}
+% \begin{empheq}[left=\empheqlbrace, right=\empheqrbrace]{align}
+% E&=mc^2 \\
+% Y&= \sum_{n=1}^\infty \frac{1}{n^2}
+% \end{empheq}
+% The naming scheme is \cs{empheq}\meta{delimiter name} and
+% \cs{empheqbig}\meta{delimiter name}. Thus \cs{empheqrbrace}
+% produces an auto-scaling right brace with same size as the math
+% display while \cs{empheqbigrbrace} produces an even bigger version
+% that spans the inner box plus the math display inside it. For a
+% complete list of supported delimiters see Table
+% \vref{tab:delimiters}.
+%
+% \begin{table}
+% \centering
+% \begin{tabular}{lllc} \toprule
+% \multicolumn{3}{c}{\textbf{Delimiter}}\\ \cmidrule{1-3}
+% \multicolumn{1}{c}{Original} & \multicolumn{1}{c}{Normal} &
+% \multicolumn{1}{c}{Bigger} & Symbol\\ \midrule
+% \DescribeDelimiter{lbrace} \DescribeDelimiter{rbrace}
+% \DescribeDelimiter{lbrack} \DescribeDelimiter{rbrack} \midrule
+% \DescribeDelimiter{langle} \DescribeDelimiter{rangle}
+% \DescribeDelimiter{lparen} \DescribeDelimiter{rparen} \midrule
+% \DescribeDelimiter{lvert} \DescribeDelimiter{rvert}
+% \DescribeDelimiter{lVert} \DescribeDelimiter{rVert} \midrule
+% \DescribeDelimiter{lfloor} \DescribeDelimiter{rfloor}
+% \DescribeDelimiter{lceil} \DescribeDelimiter{rceil} \bottomrule
+% \end{tabular}
+% \caption{The supported auto-scaling delimiters in
+% \pkg{empheq}}\label{tab:delimiters}
+% \end{table}
+%
+%
+%
+% \section{Taking things a little further}
+%
+% So far we have covered the basic functions of \pkg{empheq}: the
+% markup instructions and the predefined auto-scaling delimiters.
+% There is more to \pkg{empheq} however, and we'll cover that in
+% this section.
+%
+% \subsection{Loading the package}
+%
+% The package has two main requirements: One is the
+% \pkg{mathtools}\footnote{By the same author and is distributed
+% with \pkg{empheq}. See its documentation for more information.}
+% package which provides \pkg{empheq} with a lot of necessary tools
+% for doing its thing. The other one is \pkg{amsmath} of course, and
+% to make the loading procedure as easy as possible, you can simply
+% substitute
+% \begin{verbatim}
+% \usepackage[leqno,fleqn,intlimits]{amsmath}
+% \end{verbatim}
+% with
+% \begin{verbatim}
+% \usepackage[leqno,fleqn,intlimits]{empheq}
+% \end{verbatim}
+% \pkg{empheq} makes sure that the \pkg{amsmath} options are passed
+% on and loaded by \pkg{amsmath}. The same goes for the options
+% provided by \pkg{mathtools}.
+%
+%
+% \subsubsection{Compatibility with the old version}
+%
+% The current version (\fileversion) of \pkg{empheq} is incompatible with
+% versions prior to and including~0.7d. If you have documents produced
+% with versions prior to~0.7d, then you have to load the package
+% \pkg{empheq07} instead. \pkg{empheq07} now exists as a separate package
+% package with its own documentation, but I strongly recommend switching
+% to the new version because it is so much better.
+%
+% \subsection{Package options}
+%
+% In addition to the \pkg{amsmath} options, \pkg{empheq} itself
+% provides a string of options listed in Table \vref{tab:options}.
+%
+% \begin{table}[ht]
+% \centering
+% \begin{tabular}{lp{21em}} \toprule
+% Option & Short description \tabularnewline \midrule
+% \TabDescribeOption[]{overload}
+% {Lets you use the \pkg{empheq} visual markup extensions
+% transparently in an existing document.}
+% \TabDescribeOption[]{overload2}
+% {A wild version of \opt{overload}. Use with care.}
+% \TabDescribeOption[]{ntheorem}
+% {A support module for users of \pkg{ntheorem} and its
+% \opt{thmmarks} and \opt{thref} options.}
+% \TabDescribeOption[]{newmultline}
+% {With v2.10 of \pkg{empheq} the syntax for \env{multline} and
+% \env{multlined} has been improved immensely.}
+% \TabDescribeOption[]{oldmultline}
+% {Support for the somewhat strange syntax for \env{multline} and
+% \env{multlined} in v2.00.}
+% \bottomrule
+% \end{tabular}
+% \caption{Supported options in the \pkg{empheq} package}
+% \label{tab:options}
+% \end{table}
+%
+%
+% \begin{codesyntax}
+% \SpecialOptIndex{ntheorem}\opt{ntheorem}
+% \end{codesyntax}
+% The \pkg{ntheorem} package is supported by means of the
+% \opt{ntheorem} option. In order for this to work properly, an
+% \pkg{amsmath} bug\footnote{See the \LaTeX{} Bugs Database
+% \url{http://www.latex-project.org/cgi-bin/ltxbugs2html} under
+% \AmS\LaTeX{} problem report 3624.} is fixed. For more information
+% on this option see \S \vref{sec:ntheorem-support}.
+%
+% \subsubsection{Using \env{multline}}
+%
+% \begin{codesyntax}
+% \SpecialOptIndex{newmultline}\opt{newmultline}\\
+% \SpecialOptIndex{oldmultline}\opt{oldmultline}
+% \end{codesyntax}
+% Those familiar with v2.00 of this package will recognize the
+% somewhat weird syntax for using \env{multline} and
+% \env{multlined}. The good news is that since v2.10 there is now a
+% much improved syntax available. The option \opt{newmultline}
+% (default) selects this better interface, while the old interface
+% is provided for compatibility reasons by the \opt{oldmultline}
+% option.
+%
+%
+% \begin{codesyntax}
+% \SpecialUsageIndex{\shoveleft}\cs{shoveleft}\oarg{dimen}\marg{arg}\\
+% \SpecialUsageIndex{\shoveright}\cs{shoveright}\oarg{dimen}\marg{arg}
+% \end{codesyntax}
+% With the new interface you also get an extended syntax for
+% \cs{shoveleft} and \cs{shoveright} as shown in the example below.
+% \begin{verbatim}
+% \begin{empheq}{multline}
+% \framebox[.65\columnwidth]{First line} \\
+% \framebox[.5\columnwidth]{Second line} \\
+% \shoveleft{L+E+F+T} \\
+% \shoveright{R+I+G+H+T} \\
+% \shoveleft[1cm]{L+E+F+T} \\
+% \shoveright[\widthof{$R+I+G+H+T$}]{R+I+G+H+T} \\
+% \framebox[.65\columnwidth]{Last line}
+% \end{empheq}
+% \end{verbatim}
+% \begin{empheq}{multline}
+% \framebox[.65\columnwidth]{First line} \\
+% \framebox[.5\columnwidth]{Second line} \\
+% \shoveleft{L+E+F+T} \\
+% \shoveright{R+I+G+H+T} \\
+% \shoveleft[1cm]{L+E+F+T} \\
+% \shoveright[\widthof{$R+I+G+H+T$}]{R+I+G+H+T} \\
+% \framebox[.65\columnwidth]{Last line}
+% \end{empheq}
+%
+%
+% There are however a few differences in the output between the
+% original \pkg{amsmath} version of \env{multline} and the one
+% \pkg{empheq} provides. In \pkg{amsmath} a centered line in
+% \env{multline} is centered on the page without taking into account
+% the \cs{multlinegap}, \cs{multlinetaggap}, and the tag width. Thus
+% \pkg{amsmath} can sometimes give you horrible output without
+% giving you any warning as shown below.
+% \begin{verbatim}
+% \begin{multline}
+% \framebox[.65\columnwidth]{First line} \\
+% \framebox[.9\columnwidth]{Loooong line} \\
+% \framebox[.65\columnwidth]{Last line} \tag{wide tag}
+% \end{multline}
+% \end{verbatim}
+% \begin{AmSmultline}
+% \framebox[.65\columnwidth]{First line} \\
+% \framebox[.9\columnwidth]{Loooong line} \\
+% \framebox[.65\columnwidth]{Last line} \tag{wide tag}
+% \end{AmSmultline}
+% In \pkg{empheq} these parameters are taken into account, so the
+% same input will produce this in \pkg{empheq}:
+% \begin{verbatim}
+% \begin{empheq}{multline}
+% \framebox[.65\columnwidth]{First line} \\
+% \framebox[.9\columnwidth]{Loooong line} \\
+% \framebox[.65\columnwidth]{Last line} \tag{wide tag}
+% \end{empheq}
+% \end{verbatim}
+% \begin{multline*}
+% \framebox[.65\columnwidth]{First line} \\
+% \framebox[.9\columnwidth]{Loooong line} \\
+% \framebox[.65\columnwidth]{Last line} \tag{wide tag}
+% \end{multline*}
+% This results in an
+% \begin{verbatim}
+% Overfull \hbox (30.03783pt too wide) in paragraph ...
+% \end{verbatim}
+% message in the log file, indicating a visual problem. I think this
+% behavior is more sensible than the one the original \env{multline}
+% environment provides.
+%
+% \begin{codesyntax}
+% \SpecialEnvIndex{MTmultlined}\cs{begin}\arg{MTmultlined}\oarg{pos}\oarg{width}
+% \meta{contents} \cs{end}\arg{MTmultlined}
+% \end{codesyntax}
+% When you choose the \opt{oldmultline} option you may still want to
+% use the much improved \env{multlined} environment defined in
+% \pkg{mathtools} but unfortunately there will be a name clash.
+% Instead you can access it under the name \env{MTmultlined}.
+%
+%
+%
+% \subsubsection{The \opt{overload} option}\label{sec:overload}
+%
+% \begin{codesyntax}
+% \SpecialOptIndex{overload}\opt{overload}\\
+% \SpecialOptIndex{overload2}\opt{overload2}
+% \end{codesyntax}
+% \FeatureRequest{Lars Madsen}{2004/03/25}
+% The \opt{overload} option redefines the original \AmS{}
+% environments so that they take an optional argument.
+% \begin{codesyntax}
+% \cs{begin}\marg{\AmS{} env_name}\oarg{markup instructions}\\
+% \meta{contents of \AmS{} environment}\\
+% \cs{end}\marg{\AmS{} env_name}
+% \end{codesyntax}
+% For example
+% \begin{verbatim}
+% \begin{gather}[box=\widefbox]
+% a = b
+% \end{gather}
+% \end{verbatim}
+% is then actually short for
+% \begin{verbatim}
+% \begin{empheq}[box=\widefbox]{gather}
+% a = b
+% \end{empheq}
+% \end{verbatim}
+% All the \AmS{} environments are supported by this option except
+% for the pseudo environment |\[ ... \]| (it's not really an
+% environment), \footnote{With the option \opt{oldmultline} the
+% \env{multline} and \env{multline*} environments aren't supported
+% either because their syntax in \pkg{empheq} then differ from their
+% syntax in \pkg{amsmath}.} because a)~you don't really need markup
+% instructions for a one line display, and b)~would you really like
+% a syntax like
+% \begin{verbatim}
+% \[[box=\fbox] a=b \]
+% \end{verbatim}
+% where its difficult to see whether or not there is a typo?
+% Choosing \opt{overload} is meant for people who don't want to
+% change their entire document into \pkg{empheq} syntax. I have no
+% problems with that; just be careful when you fiddle with
+% \cs{empheqset} as it will affect \emph{all} math displays!
+%
+%
+% There is of course a catch (well, two actually): These redefined
+% environments don't run as fast as the regular ones (about three
+% times as slow), but in this day and age I seriously doubt you'll
+% be able to tell the difference unless you have a vast number of
+% equations. The other catch is that you cannot use \cs{intertext}
+% and \cs{displaybreak} as described earlier. If you find yourself
+% wanting to use one of these features in say, an \env{align}
+% environment, you have to use the original \env{align} environment.
+% Luckily it is available if you call it like this:
+% \begin{codesyntax}
+% \cs{begin}\arg{AmS\meta{\rmfamily \AmS{} env_name}} \\
+% \texttt{~~}\meta{contents of \AmS{} environment}\\
+% \cs{end}\arg{AmS\meta{\rmfamily \AmS{} env_name}}
+% \end{codesyntax}
+% For example the original \env{align} environment could be selected
+% with
+% \begin{verbatim}
+% \begin{AmSalign}
+% ...
+% \end{AmSalign}
+% \end{verbatim}
+% These original versions with prefix \texttt{AmS} exist for all the
+% environments.
+%
+%
+% The option \opt{overload2} activates the overloading feature
+% for the pseudo environment |\[ ... \]|, although I doubt you'll
+% find it useful. Beware that this definition is fragile unless you
+% have \eTeX{} as \LaTeX{} engine.\footnote{\eTeX{} has been the
+% default engine for \LaTeX{} in most major distributions since
+% 2003.} Not surprisingly \opt{overload2} activates
+% \opt{overload}.
+%
+%
+%
+% Before you get all excited about these options, you should take
+% note of some aspects of centered math displays in \pkg{amsmath}.
+% In certain circumstances truly centering the display is not always
+% the best solution as in this example:
+% \begin{center}
+% \mbox{}\hfill
+% \framebox[.75\linewidth]{Wide math display; not adjusted}%
+% \hfill\mbox{}%
+% \makebox[0pt][r]{Wide Tag}
+% \end{center}
+% Instead centering the display in the available space works pretty
+% well:
+% \begin{gather*}
+% \framebox[.75\linewidth]{Wide math display; adjusted}%
+% \tag*{Wide Tag}
+% \end{gather*}
+% This is what \pkg{amsmath} does normally, but in the \env{gather}
+% environment it does it on a per line basis. This means that we get
+% results like
+% \begin{AmSgather*}
+% \framebox[.75\linewidth]{Wide math display; adjusted}%
+% \tag*{Wide Tag} \\
+% \framebox[.75\linewidth]{Wide math display; not adjusted} \tag{i}%
+% \end{AmSgather*}
+% whether we like it or not. Inside the \env{empheq} environment we
+% need to have the same adjustment for all lines else the boxing
+% process will not work properly, so when activating the
+% \opt{overload} option the above two-line \env{gather} will
+% instead look like this:
+% \begin{empheq}{gather*}
+% \framebox[.75\linewidth]{Wide math display; adjusted}%
+% \tag*{Wide Tag} \\
+% \framebox[.75\linewidth]{Wide math display; adjusted} \tag*{i}%
+% \end{empheq}
+% I leave it to you to choose whether or not this is better (I think
+% it is better).
+%
+%
+%
+% \subsection{A note on boxed displays}
+%
+% When browsing a 400+ pages textbook with at least twice the number
+% of displayed formulae, some of them are surely more important than
+% others. Thus the author of the book (in cooperation with the
+% designer) should make sure that such formulae are easily found
+% again i.e., they should be easily distinguishable from the rest of
+% the pack. One way of doing this is putting the formula into a box
+% which is something we've seen \pkg{empheq} being capable of. There
+% are however a few things to keep in mind:
+% \begin{itemize}
+% \item Don't overdo it. If you do it on half of them there's no
+% point in doing it at all. I don't see much reason for applying
+% this technique to more than 10\% of the formulae.
+% \item Choose the type of box carefully. You want to draw
+% attention to it so it might as well look good.
+% \end{itemize}
+% The latter point can be illustrated by defining a macro similar to
+% \cs{fbox} only with a little more space to the right and left of
+% the argument.
+% \begin{verbatim}
+% \newcommand*\widefbox[1]{\fbox{\hspace{1em}#1\hspace{1em}}}
+% \end{verbatim}
+% If we replace the \cs{fbox} from the \key{box} example before, we
+% get this display:
+% \begin{verbatim}
+% \begin{empheq}[box=\widefbox]{align}
+% a&=b\\
+% E&=mc^2 + \int_a^a x\, dx
+% \end{empheq}
+% \end{verbatim}
+% \begin{empheq}[box=\widefbox]{align}
+% a&=b\\
+% E&=mc^2 + \int_a^a x\, dx
+% \end{empheq}
+% Compare it with
+% \begin{empheq}[box=\fbox]{align}
+% a&=b\\
+% E&=mc^2 + \int_a^a x\, dx
+% \end{empheq}
+% and see which one you prefer.
+%
+% Similarly one might be tempted to use colored boxes:
+% \begin{verbatim}
+% \definecolor{myblue}{rgb}{.8, .8, 1}
+% \newcommand*\mybluebox[1]{%
+% \colorbox{myblue}{\hspace{1em}#1\hspace{1em}}}
+% \end{verbatim}
+% We know the drill by now.
+% \begin{verbatim}
+% \begin{empheq}[box=\mybluebox]{align}
+% a&=b\\
+% E&=mc^2 + \int_a^a x\, dx
+% \end{empheq}
+% \end{verbatim}
+% \begin{empheq}[box=\mybluebox]{align}
+% a&=b\\
+% E&=mc^2 + \int_a^a x\, dx
+% \end{empheq}
+% There is more on boxes later in this manual. If you're into the
+% \pkg{fancybox} package then remember to read \S
+% \vref{sec:fancybox_support}.
+%
+% \section{Support for other packages}
+%
+% With the multitude of packages for \LaTeX, it is not always easy
+% to be a PWWO package (``Plays Well With Others''), but
+% \pkg{empheq} tries really hard to do so. This section lists the
+% packages where \pkg{empheq} has to provide workarounds and they
+% can be divided into two categories.
+% \begin{description}
+% \item[Compatibility] Some packages affect \LaTeX' labelling
+% mechanism and since \pkg{empheq} internally has to turn off
+% labels and related code temporarily, hooks must be provided for
+% these packages. Examples of such packages are \pkg{hyperref} and
+% \pkg{showkeys}.
+%
+% \item[Enhancements] Other packages provide useful features that
+% for some reason may not work directly or optimally with
+% \pkg{empheq}. In these cases the problematic commands are
+% redefined so that they not only work with \pkg{empheq}, but
+% also give the same if not better output. An example of this
+% would be the \cs{shadowbox} command from \pkg{fancybox}
+% (described below).
+% \end{description}
+% %
+% \subsection{Support for \pkg{fancybox}}\label{sec:fancybox_support}
+%
+% The \pkg{fancybox} package provides various boxes and you can use
+% them with \pkg{empheq} as well. Here's \cs{ovalbox}:
+% \begin{verbatim}
+% \begin{empheq}[box=\ovalbox]{align}
+% E&=mc^2 \\
+% Y&= \sum_{n=1}^\infty \frac{1}{n^2}
+% \end{empheq}
+% \end{verbatim}
+% \begin{empheq}[box=\ovalbox]{align}
+% E&=mc^2 \\
+% Y&= \sum_{n=1}^\infty \frac{1}{n^2}
+% \end{empheq}
+%
+%
+% \begin{codesyntax}
+% \SpecialUsageIndex{\shadowbox}\SpecialUsageIndex{\shadowbox*}
+% \cs{shadowbox*}\marg{arg} \\
+% \SpecialColorIndex{shadowcolor} \texttt{shadowcolor}
+% \end{codesyntax}
+% The only problem with using the \pkg{fancybox} boxes in
+% conjunction with the \env{empheq} environment is \cs{shadowbox},
+% as this macro typesets the shadow on the baseline and for the
+% equation numbers to be placed correctly, the box command must set
+% its argument on the baseline. Thus the normal \cs{shadowbox}
+% produces \shadowbox{\meta{arg}}, but we need this instead:
+% \shadowbox*{\meta{arg}}. Therefore \pkg{empheq} will detect if
+% \pkg{fancybox} is loaded and in that case it'll enhance
+% \cs{shadowbox} in two ways:
+% \begin{itemize}
+% \item It defines a starred version \cs{shadowbox*} which
+% typesets its argument on the baseline.
+%
+% \item The color \texttt{shadowcolor} is introduced. The default
+% color is black.
+% \end{itemize}
+% \begin{verbatim}
+% \definecolor{shadowcolor}{rgb}{0,.5,.5}
+% \setlength\shadowsize{2pt}
+% Line of text for \shadowbox*{testing of \Verb|f#&%\| verbatim} and
+% showing the shadow color.
+% \end{verbatim}
+% \begin{quote}
+% \definecolor{shadowcolor}{rgb}{0,.5,.5}
+% \setlength\shadowsize{2pt}
+% Line of text for \shadowbox*{testing of \Verb|f#&%\| verbatim} and
+% showing the shadow color.
+% \end{quote}
+%
+% The point is that if you want a \cs{shadowbox} around your math
+% display then you must use the starred version:
+% \begin{verbatim}
+% \begin{empheq}[box=\shadowbox*]{align}
+% E&=mc^2 \\
+% Y&= \sum_{n=1}^\infty \frac{1}{n^2}
+% \end{empheq}
+% \end{verbatim}
+% \begin{empheq}[box=\shadowbox*]{align}
+% E&=mc^2 \\
+% Y&= \sum_{n=1}^\infty \frac{1}{n^2}
+% \end{empheq}
+%
+% See \S \vref{stunning} if you want
+% to make a fancy box yourself.
+%
+%
+% \subsection{Support for \pkg{ntheorem}}\label{sec:ntheorem-support}
+%
+% \changes{v2.00}{2004/04/14}{Added description of the
+% \opt{ntheorem} option}
+% \changes{v1.05}{2004/02/16}{Added support for the end-of-theorem
+% marker mechanism of \pkg{ntheorem}}
+%
+% \begin{codesyntax}
+% \SpecialOptIndex{ntheorem}\opt{ntheorem}
+% \end{codesyntax}
+% The \pkg{ntheorem} package is supported by the means of the
+% \opt{ntheorem} option of \pkg{empheq}. This loads a set of
+% extra macros which fixes various compatibility problems between
+% \pkg{ntheorem} and \pkg{amsmath} and furthermore introduces
+% special (internal) macros for optimum positioning of
+% end-of-theorem markers, while retaining a user friendly interface.
+%
+%
+% When you want to use the automatic end-of-theorem marker mechanism
+% from \pkg{ntheorem} you sometimes run into problems as you would
+% want the marker to be placed aligned at the bottom of the math
+% display but still keeping the tags in their proper place. In
+% \mode{leqno} mode this is not that much of a problem as the tags
+% and the marker are set on either side of the math display like
+% in Figure \vref{fig:markerI}.
+% \changes{v1.05a}{2004/02/17}{Added explanatory drawings for
+% \pkg{ntheorem}}
+%
+% \begin{figure}[btp]\centering
+% \unitlength2.5pt \thicklines
+% \begin{picture}(90,30)(-30,40)
+% \put(0,50){\framebox(25,20){Math Height}}
+% \put(0,40){\framebox(25,10){Math Depth}}
+% \put(-30,50){\framebox(20,10){Tag height}}
+% \put(-30,45){\framebox(20,5){Tag depth}}
+% \put(40,40){\framebox(20,10){Marker}}
+% \multiput(26,40)(2,0){7}{\line(1,0){1}}
+% \end{picture}
+% \caption{Marker placement in \mode{leqno} mode}
+% \label{fig:markerI}
+% \end{figure}
+%
+% \begin{codesyntax}
+% \SpecialUsageIndex{\mintagvsep}\cs{mintagvsep}
+% \end{codesyntax}
+% Unfortunately things are not this easy in \mode{reqno} mode. There
+% are two possible situations as shown in Figure \vref{fig:markerII}.
+% \begin{figure}[btp]
+% \unitlength2.5pt \thicklines
+% \begin{picture}(60,45)(0,25)
+% \put(0,50){\framebox(25,20){Math Height}}
+% \put(0,25){\framebox(25,25){Math Depth}}
+% \put(40,50){\framebox(20,10){Tag height}}
+% \put(40,45){\framebox(20,5){Tag depth}}
+% \put(40,25){\framebox(20,10){Marker}}
+% \put(50,35){\vector(0,1){10}}
+% \put(50,45){\vector(0,-1){10}}
+% \put(50,39){\ \ $>\delta$}
+% \multiput(26,25)(2,0){7}{\line(1,0){1}}
+% \end{picture} \hfill\vrule\hfill
+% \begin{picture}(60,45)(0,25)
+% \put(0,50){\framebox(25,20){Math Height}}
+% \put(0,40){\framebox(25,10){Math Depth}}
+% \put(40,50){\framebox(20,10){Tag height}}
+% \put(40,45){\framebox(20,5){Tag depth}}
+% \put(40,28){\framebox(20,10){Marker}}
+% \put(50,38){\vector(0,1){7}}
+% \put(50,45){\vector(0,-1){7}}
+% \put(50,40){\ \ $=\delta$}
+% \end{picture}
+% \caption{The two possible situations for end marks in \mode{reqno}
+% mode}
+% \label{fig:markerII}
+% \end{figure}
+% If possible we want the bottom of the marker to be aligned with
+% the bottom of the math display, but at the same time we want to
+% ensure a minimum vertical separation $\delta$ between marker and
+% tag. In \pkg{empheq} this is controlled by the length parameter
+% \cs{mintagvsep} which by default is 5\,pt.
+%
+% The good news is that this is where \pkg{empheq} sets in.
+% Basically all you need to do is to use the \env{empheq}
+% environment to type set your equations inside the theorem
+% environments:
+% \begin{verbatim}
+% \begin{Theorem}
+% Some text at first and then a math display
+% \begin{empheq}{align}
+% a&=b\\
+% E&=mc^2 + \int_a^a x\, dx
+% \end{empheq}
+% \end{Theorem}
+% \end{verbatim}
+% Then the tag placement and the end-of-theorem marker will be set
+% properly (after a couple of runs as usual).
+%
+% To ensure the correct outcome remember to load the packages like
+% this:
+% \begin{verbatim}
+% \usepackage[ntheorem]{empheq} % this loads amsmath as well
+% \usepackage[thmmarks,amsmath]{ntheorem}
+% \end{verbatim}
+% Remember that if you use the \opt{overload} option you
+% can just use the regular math environments to get the desired
+% result with the end mark. The exception is the |\[ ... \]|
+% environment which will only work if you use the option
+% \opt{overload2}.
+%
+% \clearpage
+%
+% \EmphEqpart{Advanced user's guide}
+%
+% The \pkg{empheq} package has more to offer than you have seen, but
+% I found some of the functionality so dangerous it was best to hide
+% it for a little while. The commands you have encountered so far in
+% this manual all have one thing in common: They have only lower
+% case letters in their names. Now it's time to reveal those that
+% have \emph{mixed-case} names, thus implying that you should take
+% great care when using them.
+%
+% \section{Delimiters revisited}
+% Let's go back to delimiters, shall we?
+%
+% \subsection{Creating your own delimiters}
+% As a convenience for the user, this interface is extended in a
+% more general way so that it is also possible to declare delimiters
+% with the following two commands: \SpecialUsageIndex{\DeclareLeftDelimiter}
+% \SpecialUsageIndex{\DeclareRightDelimiter}
+% \begin{codesyntax}
+% \cs{DeclareLeftDelimiter}\oarg{space adjustment}\marg{delimiter}\\
+% \cs{DeclareRightDelimiter}\oarg{space adjustment}\marg{delimiter}
+% \end{codesyntax}
+% While \pkg{empheq} provides auto-scaling versions of the most
+% common delimiters, you may sometimes want some new ones. Say for
+% instance you have loaded the \pkg{stmaryrd} package and you want
+% to use the double bracket commands \cs{llbracket} and
+% \cs{rrbracket} with \pkg{empheq}. Then you simply do this:
+% \begin{verbatim}
+% \DeclareLeftDelimiter{\llbracket}
+% \DeclareRightDelimiter{\rrbracket}
+% \end{verbatim}
+% This defines the new delimiters \cs{empheqllbracket},
+% \cs{empheqbigllbracket}, \cs{empheqrrbracket} and
+% \cs{empheqbigrrbracket}.
+%
+% You can use \cs{big...} delimiters as well if you don't like the
+% automatic scaling. There are however ways to fine-tune if you
+% really want it.
+%
+% \subsection{Fine-tuning of delimiters}
+%
+% \TeX{} provides two primitives to control the scaling of
+% delimiters produced with \cs{left} and \cs{right}, namely the
+% dimension \cs{delimitershortfall} (denoted by $\delta$ here) and
+% the integer \cs{delimiterfactor} ($f$). The idea is that the
+% sub-formula inside the \cs{left}-\cs{right} pair is to be
+% vertically centered and given its height $h_1$ and its depth $h_2$
+% we want to produce a delimiter with total height $h$, where $h =
+% 2 \max(h_1,h_2)$. \TeX' rules on this is that the minimum
+% delimiter size $h_{\min}$ must meet the requirements
+% \[
+% h_{\min}\geq h \frac{f}{1000} \quad\land \quad h_{\min}\geq h-\delta
+% \]
+% \LaTeX{} sets $\cs{delimitershortfall} = \text{\the\delimitershortfall} $
+% and $\cs{delimiterfactor} = \the\delimiterfactor$, but in our case
+% we will almost always want a delimiter that spans the entire
+% \cs{left}-\cs{right} pair (the math display), thus a change of
+% these settings is needed.
+%
+% \begin{codesyntax}
+% \SpecialUsageIndex{\EmphEqdelimitershortfall}
+% \cs{EmphEqdelimitershortfall}\\
+% \SpecialUsageIndex{\EmphEqdelimiterfactor}
+% \cs{EmphEqdelimiterfactor}
+% \end{codesyntax}
+% However it is a bad idea to just change these two settings without
+% thinking of the effect it'll have on the rest of the mathematics
+% in your document. Therefore \pkg{empheq} provides the parameters
+% \cs{EmphEqdelimitershortfall} (default setting is
+% \the\EmphEqdelimitershortfall) and \cs{EmphEqdelimiterfactor}
+% (default is \the\EmphEqdelimiterfactor) to cater for this.
+%
+%
+% \subsection{Scaling material yourself}
+%
+% The attentive reader may have noticed that I still haven't
+% revealed how I managed to get the right size of that big
+% exclamation mark in the first example of this manual, so I guess
+% it's about time.
+% \begin{codesyntax}
+% \SpecialUsageIndex{\EmphEqdisplayheight}\cs{EmphEqdisplayheight} \\
+% \SpecialUsageIndex{\EmphEqdisplaydepth}\cs{EmphEqdisplaydepth}
+% \end{codesyntax}
+% The height of the math display plus the surrounding inner box is
+% given by \cs{EmphEqdisplayheight} and the depth by
+% \cs{EmphEqdisplaydepth}. These can be used when constructing
+% something that should scale to fit the display and can't be done
+% with ``auto-scaling'' commands like \cs{vrule} or \cs{left} or
+% \cs{right}. There is a catch however: If you do any horizontal
+% resizing of the material you want to scale, then you must specify
+% the width \emph{manually}:\footnote{The
+% \cs{fontdimen22}\cs{textfont2} in the \meta{length} argument of
+% \cs{raisebox} is the \emph{math axis} of the font. It is needed in
+% order to get the vertical positioning of the oversized exclamation
+% mark just right.}
+% \begin{verbatim}
+% \begin{empheq}[
+% box=\colorbox{myblue},
+% right={\;
+% \makebox[.9em]{%
+% $\raisebox{-.5\totalheight+\fontdimen22\textfont2}
+% {\resizebox{!}{%
+% \EmphEqdisplayheight+\EmphEqdisplaydepth}{!}}$%
+% }},
+% left={X=Y\Rightarrow}
+% ]{alignat=3}
+% A_1&=b_1 & \qquad c_1&=d_1 & \qquad e_1&= f_1
+% \tag*{\_A\raisebox{1ex}{silly}\raisebox{-1ex}{tag}\_}\\
+% A_2&=b_2 & \qquad c_2&=d_2 & \qquad e_2&= f_2 \\
+% A_3&=b_3 & \qquad c_3&=d_3 & \qquad e_3&= f_3
+% \end{empheq}
+% \end{verbatim}
+%
+% Here's another example. We want to be able to put a \cs{parbox}
+% with some descriptive text top-aligned on the side of the display.
+% \begin{verbatim}
+% \begin{empheq}[
+% left={\parbox[c][\EmphEqdisplayheight+\EmphEqdisplaydepth][t]
+% {4.5cm}
+% {You may find this kind of description useful.}\enspace}]
+% {align}
+% a&=\int_0^1 x\,dx +\frac{foo + bar}{baz}\\
+% E&= mc^2
+% \end{empheq}
+% \end{verbatim}
+% \begin{empheq}[
+% left={\parbox[c][\EmphEqdisplayheight+\EmphEqdisplaydepth][t]
+% {4.5cm}
+% {You may find this kind of description useful.}\enspace}]
+% {align}
+% a&=\int_0^1 x\,dx +\frac{foo + bar}{baz}\\
+% E&= mc^2
+% \end{empheq}
+%
+% \section{Creating something new}
+%
+% You can create your own environments and boxes to go with
+% \pkg{empheq}, but there are certain things that must be fulfilled
+% to get it to work properly.
+%
+% \subsection{New \env{empheq}-like environments}
+%
+% \begin{codesyntax}
+% \SpecialEnvIndex{EmphEqMainEnv}\env{EmphEqMainEnv}\\
+% \SpecialUsageIndex{\EmphEqMainEnv}\cs{EmphEqMainEnv}\\
+% \SpecialUsageIndex{\endEmphEqMainEnv}\cs{endEmphEqMainEnv}
+% \end{codesyntax}
+% Although the real work in \pkg{empheq} is done by an environment
+% (\env{EmphEqMainEnv}), you cannot use it like that yourself when
+% you want to define an \env{empheq}-like environment. Due to
+% technical reasons (see~\cite{Ams99}), you have to use a slightly
+% different syntax:
+% \begin{codesyntax}
+% \cs{newenvironment}
+% \marg{env_name} \oarg{num} \oarg{default}\\
+% \texttt{~~}\arg{\meta{other commands} \cs{EmpheqMainEnv}}\\
+% \texttt{~~}\arg{\cs{endEmpheqMainEnv}}
+% \end{codesyntax}
+% In the above environment the \meta{other commands} part must
+% contain certain things before it'll work.
+% \begin{codesyntax}
+% \SpecialKeyFamilyIndex{EmphEqEnv}\keyfam{EmphEqEnv}\\
+% \SpecialKeyFamilyIndex{EmphEqOpt}\keyfam{EmphEqOpt}
+% \end{codesyntax}
+% Before your homemade environment will work you must set at least
+% one key. The key family \keyfam{EmphEqOpt} is for all the markup
+% instructions like \key{left} and \key{box}, while
+% \keyfam{EmphEqEnv} controls the type of \AmS{} environment. You
+% must set the \keyfam{EmphEqEnv} family before \cs{EmhpEqMainEnv}
+% else you'll get an error message.
+%
+% One example could be something like this:
+% \begin{verbatim}
+% \newenvironment{important}[2][]{%
+% \setkeys{EmphEqEnv}{#2}%
+% \setkeys{EmphEqOpt}{box=\mybluebox,#1}%
+% \EmphEqMainEnv}%
+% {\endEmphEqMainEnv}
+% \end{verbatim}
+% Thus
+% \begin{verbatim}
+% \begin{important}{gather}
+% a = b + c +d \\ e = f
+% \end{important}
+% \end{verbatim}
+% produces
+% \begin{important}{gather}
+% a = b + c +d \\ e = f
+% \end{important}
+% while
+% \begin{verbatim}
+% \begin{important}[left={A=B \Rightarrow \empheqlbrace}]{alignat=2}
+% a &= b &\quad c &= d \\
+% \text{this} &= \text{that} &\quad \mathit{fish}&\neq fish
+% \end{important}
+% \end{verbatim}
+% produces
+% \begin{important}[left={A=B \Rightarrow \empheqlbrace}]{alignat=2}
+% a &= b &\quad c &= d \\
+% \text{this} &= \text{that} &\quad \mathit{fish}&\neq fish
+% \end{important}
+%
+%
+% \subsection{Creating fancy boxes}\label{stunning}
+%
+% As a final example I will show you how to create complicated
+% displays involving (vertically) asymmetrical boxes like
+% \cs{shadowbox*}. In order to get the correct output, the contents
+% of the box must be placed on the baseline as in \fbox{\cs{fbox}}.
+% In this example we want to put a set of equations into a bright
+% yellow box and then add another box with some explanatory text at
+% the top of the yellow box making them overlap.
+%
+% First we define the colors used and allocate the boxes. We could
+% probably use scratch boxes, but this is safer.
+% \begin{verbatim}
+% \definecolor{shadecolor}{cmyk}{0,0,0.41,0}
+% \definecolor{light-blue}{cmyk}{0.25,0,0,0}
+% \newsavebox{\mysaveboxM} % M for math
+% \newsavebox{\mysaveboxT} % T for text
+% \end{verbatim}
+% Save the display body in \cs{mysaveboxM} and the text argument in
+% \cs{mysaveboxT}.
+% \begin{verbatim}
+% \newcommand*\Garybox[2][Example]{%
+% \sbox{\mysaveboxM}{#2}%
+% \sbox{\mysaveboxT}{\fcolorbox{black}{light-blue}{#1}}%
+% \end{verbatim}
+% Then typeset the math display in a \cs{parbox} where we control
+% the height and save it in \cs{mysaveboxM}.
+% \begin{verbatim}
+% \sbox{\mysaveboxM}{%
+% \parbox[b][\ht\mysaveboxM+.5\ht\mysaveboxT+.5\dp\mysaveboxT][b]{%
+% \wd\mysaveboxM}{#2}%
+% }%
+% \end{verbatim}
+% We put it into the colored box with the desired width.
+% \begin{verbatim}
+% \sbox{\mysaveboxM}{%
+% \fcolorbox{black}{shadecolor}{%
+% \makebox[\linewidth-10em]{\usebox{\mysaveboxM}}%
+% }%
+% }%
+% \end{verbatim}
+% Then finally we get to the real typesetting. We just insert the
+% math display and then make a box of zero width right next to it.
+% In that box we lift the text argument and center it at the top of
+% the display.
+% \begin{verbatim}
+% \usebox{\mysaveboxM}%
+% \makebox[0pt][r]{%
+% \makebox[\wd\mysaveboxM][c]{%
+% \raisebox{\ht\mysaveboxM-0.5\ht\mysaveboxT
+% +0.5\dp\mysaveboxT-0.5\fboxrule}{\usebox{\mysaveboxT}}%
+% }%
+% }%
+% }
+% \end{verbatim}
+% Let's see what it looks like.
+% \begin{verbatim}
+% \begin{empheq}[box=\Garybox]{align}
+% \sum \mathbf{F} &= \mathbf{0} \\
+% \sum F_{x} \,\mathbf{i} + \sum F_{y} \,\mathbf{j}
+% + \sum F_{z} \,\mathbf{k} &= \mathbf{0} \\
+% \sum F_{x} &= 0 \\ \sum F_{y} &= 0 \\ \sum F_{z} &= 0
+% \end{empheq}
+% \end{verbatim}
+% \begin{subequations}
+% \begin{empheq}[box=\Garybox]{align}
+% \sum \mathbf{F} &= \mathbf{0} \\
+% \sum F_{x} \,\mathbf{i} + \sum F_{y} \,\mathbf{j} + \sum F_{z}
+% \,\mathbf{k} &= \mathbf{0}\\
+% \sum F_{x} &= 0 \\ \sum F_{y} &= 0 \\ \sum F_{z} &= 0
+% \end{empheq}
+% If we use the optional argument of \cs{Garybox} we have to enclose
+% the entire argument of \key{box} in braces because we're in
+% \env{empheq}'s optional argument (as described in \cite[page
+% 167]{Lamp94}):
+% \begin{verbatim}
+% \begin{empheq}[box={\Garybox[Same old example again]}]{align}
+% a&=b\\
+% E&=mc^2 + \int_a^a x\, dx
+% \end{empheq}
+% \end{verbatim}
+% \begin{empheq}[box={\Garybox[Same old example again]}]{align}
+% a&=b\\
+% E&=mc^2 + \int_a^a x\, dx
+% \end{empheq}
+% \end{subequations}
+%
+%
+%
+%
+% \section{Contact information}
+%
+% Should you have any feature request, suggestions, or bug reports
+% then feel free to contact me at
+% \begin{quote}
+% \email{moho01ab@student.cbs.dk}
+% \end{quote}
+% Please put `empheq' in the subject line.
+%
+% \subsection*{Contributors}
+%
+% \begin{itemize}
+% \item In November 2002 Lars Madsen (\email{daleif@imf.au.dk})
+% asked for some features that wasn't readily available with
+% \pkg{amsmath} or any other package. This was the start of
+% \pkg{empheq}.
+%
+% \item Gary Gray (\email{gray@engr.psu.edu}) gave me some bug
+% reports on the old version (v0.7) which convinced me to rewrite
+% the package completely. The \cs{Garybox} example is inspired by
+% a wish from Gary.
+%
+% \item Uwe Siart (\email{uwe.siart@tum.de}) has been a thorough
+% beta-tester on v1.00 of the package.
+%
+% \item Bernard Alfonsi (\email{alfonsi@math.u-psud.fr}) reported
+% a problem with the \opt{ntheorem} option. It turned out to be a
+% bug in the \pkg{ntheorem} package itself but it's fixed in the
+% option.
+%
+% \item I have received reports on weird behavior from
+% \pkg{empheq} when used with the \pkg{color} package on some
+% dvi-viewers, which is caused by the lack of color support in
+% those dvi-viewers. Both Andrew B.~Collier (\email{colliera@ukzn.ac.za})
+% and Andr\'e M.~de Roos (\email{aroos@science.uva.nl}) have
+% notified me of this. The solution is to either upgrade you
+% dvi-viewer if possible or convert the document in question to
+% PDF or PS.
+% \end{itemize}
+% Thank you all.
+%
+%
+% \begin{thebibliography}{99}
+% \bibitem{Lamp94}
+% Leslie Lamport,
+% \emph{LaTeX User's Guide and Reference Manual}, 2nd edition,
+% Addison-Wesley, Reading, Massachusetts,
+% 1994.
+% \bibitem{Goos-etal94}
+% Michel Goossens, Frank Mittelbach, and Alexander Samarin,
+% \emph{The \LaTeX\ Companion},
+% Addison-Wesley, Reading, Massachusetts,
+% 1994.
+% \bibitem{Knut86}
+% Donald Ervin Knuth,
+% \emph{The \TeX book},
+% Addison-Wesley, Reading, Mas\-sa\-chu\-setts,
+% 1986.
+% \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}.)
+%
+% \changes{v1.05b}{2004/02/18}{Added \pkg{fancybox} and
+% \pkg{ntheorem} to the \refname}
+% \bibitem{fancybox}
+% Timothy Van Zandt,
+% \emph{The \pkg{fancybox} package} Version 1.3,
+% 2000/09/19
+% (Available from CTAN as file \texttt{fancybox.sty}.)
+%
+% \bibitem{Raht03}
+% Sebastian Rahtz,
+% \emph{Hypertext marks in \LaTeX} Version v6.74m,
+% 2003/11/30.
+% (Available from \url{http://www.tug.org/applications/hyperref} as file
+% \texttt{hyperref.dtx}.)
+%
+% \bibitem{Carl99}
+% David Carlisle,
+% \emph{The \pkg{keyval} Package},
+% Version 1.13, 1999/03/16.
+% (Available from CTAN as file \texttt{keyval.dtx}.)
+%
+% \changes{v1.06}{2004/03/13}{Added \pkg{calc} to the \refname}
+% \bibitem{Thorup:calc:1998}
+% Kresten~Krab Thorup, Frank Jensen, and Chris Rowley.
+% \emph{The {\pkg{calc}} package}, Version 4.1b, 1998/07/07,
+% (Available from CTAN as file \texttt{calc.dtx}.)
+%
+% \bibitem{ntheorem}
+% Wolfgang May and Andreas Schlechte,
+% \emph{The \pkg{ntheorem} package} Version 1.203,
+% 2002/01/07,
+% (Available from CTAN as file \texttt{ntheorem.dtx}.)
+%
+% \changes{v2.10}{2004/07/26}{Added \pkg{showkeys} to the \refname}
+% \bibitem{Carlisle:showkeys:1997}
+% David Carlisle. \emph{The {\pkg{showkeys}} package}, v3.12,
+% 1997/06/12, (Available from CTAN as file \texttt{showkeys.dtx}.)
+%
+% \end{thebibliography}
+%
+% \StopEventually{}
+%
+% \EmphEqpart{Implementation}
+%
+% \section{Requirements, Options, and Strategy}
+% Lets start the package. We'll need the tools from \pkg{mhsetup}.
+% \begin{macrocode}
+%<*empheq>
+% \end{macrocode}
+% \begin{macrocode}
+\RequirePackage{mhsetup}[2004/10/10]
+\MHInternalSyntaxOn
+% \end{macrocode}
+%
+%
+% \subsection{Requirements, Options, and Allocation}
+%
+% The \opt{overload} option allows the user to type
+% \begin{verbatim}
+% \begin{gather}[box=\fbox]
+% a = b
+% \end{gather}
+% \end{verbatim}
+% when they really mean
+% \begin{verbatim}
+% \begin{empheq}{gather}[box=\fbox]
+% a = b
+% \end{empheq}
+% \end{verbatim}
+% \begin{macrocode}
+\MH_new_boolean:n {overload_ams}
+\DeclareOption{overload}{
+ \MH_set_boolean_T:n {overload_ams}
+}
+\MH_new_boolean:n {overload_amsII}
+\DeclareOption{overload2}{
+ \MH_set_boolean_T:n {overload_ams}
+ \MH_set_boolean_T:n {overload_amsII}
+}
+% \end{macrocode}
+% Old crappy \env{multline} interface or the new dazzling?
+% \begin{macrocode}
+\MH_new_boolean:n {good_mult}
+\DeclareOption{oldmultline}{\MH_set_boolean_F:n {good_mult}}
+\DeclareOption{newmultline}{\MH_set_boolean_T:n {good_mult}}
+% \end{macrocode}
+%
+%
+% Load the \pkg{ntheorem} support file.
+% \begin{macrocode}
+\DeclareOption{ntheorem}{\AtEndOfPackage{\input{ntheorem.fix}}}
+% \end{macrocode}
+% Pass other options to \pkg{mathtools}.
+% \begin{macrocode}
+\DeclareOption*{
+ \PassOptionsToPackage{\CurrentOption}{mathtools}
+}
+\ExecuteOptions{newmultline}
+\ProcessOptions\relax
+% \end{macrocode}
+% The name of the game is \pkg{amsmath} so we'll need that of
+% course. Since v2.10 that is now taken care of in the
+% \pkg{mathtools} package which'll pass on the options to
+% \pkg{amsmath}.
+% \begin{macrocode}
+\MHInternalSyntaxOff
+\RequirePackage{mathtools}[2004/10/10]
+% \end{macrocode}
+% Activate the internal syntax.
+% \begin{macrocode}
+\MHInternalSyntaxOn
+\AtEndOfPackage{\MHInternalSyntaxOff}
+% \end{macrocode}
+% \changes{v2.00}{2004/04/14}{Changed description of naming
+% conventions. Altered \emph{all} private macros; this is not
+% mentioned at each macro as this would just be too troublesome}
+%
+% \begin{macro}{\l_EQ_equationtype_int}
+% \begin{macro}{\l_EQ_alignmentmode_int}
+% I'll use the following numbering scheme for the equation types,
+% and store the value in \cs{l_EQ_equationtype_int}:
+% \begin{multicols}{2}
+% \begin{enumerate}\setlength{\itemsep}{0pt}
+% \item align
+% \item align*
+% \item gather
+% \item gather*
+% \item flalign
+% \item flalign*
+% \item alignat
+% \item alignat*
+% \end{enumerate}
+% \end{multicols}
+% As you notice \env{equation} and \env{equation*} are missing. This
+% is because \env{gather} and \env{gather*} work the same way, only
+% they are `nicer'. Cuts down on the amount of code as well. I will
+% add an alias so that a user can use the key \key{equation}, but
+% then \key{gather} will kick in instead behind the scenes. Also the
+% \env{multline} environments are missing here, but again it's
+% because I'm faking it. See \S~\vref{sec:flalign+multline} for
+% further details. The value $0$ isn't used for any of the
+% environments and thus serves as a checkpoint (see
+% page~\pageref{ZeroCheckpoint}).
+%
+% Similarly I'll use the counter \cs{l_EQ_alignmentmode_int} to
+% store the standard options for placement of math displays and
+% equation numbering.
+% \begin{multicols}{2}
+% \begin{enumerate}\setlength{\itemsep}{0pt}
+% \item reqno
+% \item leqno
+% \item fleqn, reqno
+% \item fleqn, leqno
+% \end{enumerate}
+% \end{multicols}
+%
+% \begin{macrocode}
+\newcount\l_EQ_equationtype_int
+\newcount\l_EQ_alignmentmode_int
+\if@fleqn
+ \iftagsleft@
+ \l_EQ_alignmentmode_int=4
+ \else:
+ \l_EQ_alignmentmode_int=\thr@@
+ \fi:
+\else:
+ \iftagsleft@
+ \l_EQ_alignmentmode_int=\tw@
+ \else:
+ \l_EQ_alignmentmode_int=\@ne
+ \fi:
+\fi:
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\l_EQ_totalwidth_dim}
+% \begin{macro}{\l_EQ_displaywidth_dim}
+% \begin{macro}{\l_EQ_temp_linewidth_dim}
+% \begin{macro}{\EmphEqdelimitershortfall}
+% \begin{macro}{\EmphEqdelimiterfactor}
+% \begin{macro}{\g_EQ_toptag_height_dim}
+% \begin{macro}{\g_EQ_bottomtag_depth_dim}
+% \begin{macro}{\g_EQ_toprow_height_dim}
+% \begin{macro}{\g_EQ_bottomrow_depth_dim}
+% \begin{macro}{\g_EQ_widesttag_dim}
+% Some lengths we'll need. Could possibly be scratch registers but we
+% have to make global assignments so that road is a little
+% dangerous.
+% \begin{macrocode}
+\newdimen\l_EQ_totalwidth_dim
+\newdimen\l_EQ_displaywidth_dim
+% \end{macrocode}
+% Just to make it accessible.
+% \begin{macrocode}
+\def\EmphEqdisplaywidth{\l_EQ_displaywidth_dim}
+\newdimen\l_EQ_temp_linewidth_dim
+\newdimen\EmphEqdelimitershortfall
+\newcount\EmphEqdelimiterfactor
+\EmphEqdelimiterfactor950
+\EmphEqdelimitershortfall\p@
+\newdimen\g_EQ_toptag_height_dim
+\newdimen\g_EQ_bottomtag_depth_dim
+\newdimen\g_EQ_toprow_height_dim
+\newdimen\g_EQ_bottomrow_depth_dim
+\newdimen\g_EQ_widesttag_dim
+\def\EmphEqtagwidth{\g_EQ_widesttag_dim}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\EQ_outerbox:}
+% \begin{macro}{\EQ_innerbox:}
+% \begin{macro}{\EQ_left_side:}
+% \begin{macro}{\EQ_right_side:}
+% The two boxes and the material on either side of the math display.
+% \begin{macrocode}
+\def\EQ_outerbox:{}
+\def\EQ_innerbox:{}
+\def\EQ_left_side:{}
+\def\EQ_right_side:{}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Strategy}
+%
+% In non-\mode{fleqn} math displays are centered---even when having
+% tags. However this can look rather appalling when either the tag
+% or the math display are very wide like in the following example.
+% \begin{center}
+% \makebox[\linewidth][s]{\mbox{}\hfill \mbox{$\displaystyle
+% a+b+c+d+e+f+g+h+i+j+k+l+m+n+o$} \hfill\mbox{} \llap{(wide tag)}}
+% \end{center}
+% Not exactly pleasing to look at. \pkg{amsmath} takes care to do
+% this adjustment for us, so the user instead obtains the far better
+% \begin{gather*}
+% a+b+c+d+e+f+g+h+i+j+k+l+m+n+o \tag{wide tag}
+% \end{gather*}
+% So \pkg{amsmath} handles this quite well. That's good. It looks
+% like \pkg{amsmath} has an internal threshold that matches the
+% width of the math display against the width of the tags. But what
+% if we have a multiple line display and one of the lines causes an
+% adjustment to kick in while the others don't need it? Then we
+% cannot keep track of the complete display anymore. Furthermore we
+% may want to add material on either side of the math display making
+% the whole thing even more complicated, if not impossible to do
+% without some sort of different approach.
+%
+% Luckily we have such an approach. The idea that comes to mind is
+% to see if one can typeset the labels and the math displays
+% \emph{separately}, store them in separate boxes and then put them
+% back together again afterwards. Is this really possible? Yes.
+% Come, I'll show you.
+%
+% \subsection{The Main Environment}
+% \begin{macro}{\EQ_mathdisplay_box}
+% \begin{macro}{\EmphEqdisplayheight}
+% \begin{macro}{\EmphEqdisplaydepth}
+% \begin{macro}{\EQ_tag_box}
+% Okay, we'll start by allocating two box registers.
+% \begin{macrocode}
+\newsavebox\EQ_mathdisplay_box
+\def\EmphEqdisplayheight{\ht\EQ_mathdisplay_box}
+\def\EmphEqdisplaydepth{\dp\EQ_mathdisplay_box}
+\newsavebox\EQ_tag_box
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\EQ_complete_mathdisplay:}
+% \begin{macro}{\EQ_getbody:n}
+% \begin{environment}{EmphEqMainEnv}
+% The \env{EmphEqMainEnv} is (as the name implies) the main
+% environment. I decided to go with the environment form because
+% that's what \pkg{amsmath} users are accustomed to. But the code
+% will require the contents of the environment to be handled as an
+% argument to a command, so we use \cs{collect@body} from
+% \pkg{amsmath} itself to collect it.
+% \begin{macrocode}
+\def\EQ_complete_mathdisplay:{}
+\def\EQ_getbody:n #1{%
+ \def\EQ_complete_mathdisplay:{}\def\EQ_mathbody:{#1}}
+\newenvironment{EmphEqMainEnv}{\collect@body\EQ_getbody:n}{%
+% \end{macrocode}
+% If the user didn't specify the mandatory argument we will catch it
+% because \cs{l_EQ_equationtype_int} is zero. An error is
+% issued\label{ZeroCheckpoint}.
+% \begin{macrocode}
+ \if_num:w \l_EQ_equationtype_int=\z@ %ZeroCheckpoint
+ \EQ_upgrade_error:
+ \else:
+% \end{macrocode}
+% Those that read the manual get the reward here: The package will
+% actually work!
+% \begin{macrocode}
+ \EQ_post_process:
+ \ignorespacesafterend
+ \fi:}
+% \end{macrocode}
+% \end{environment}
+% \end{macro}
+% \end{macro}
+% \subsection{Post Processing}
+% \begin{macro}{\EQ_post_process:}
+% I know: it almost looked easy for a while didn't it? Sadly the
+% post-processing step of the code is also by far the most
+% complicated.
+% \begin{macrocode}
+\def\EQ_post_process:{%
+% \end{macrocode}
+% First a hook where we initialize a few things like storing the
+% line width for later manipulation. Also we want to measure the
+% height of the top row and the depth of the bottom row for best
+% possible placement of the math display and the boxes around it
+% (same with the tags). Those four dimensions are globally set
+% during the code, hence this assignment. Most other stuff is local.
+% \begin{macrocode}
+ \EQ_initialize:
+% \end{macrocode}
+% Then we proceed by completing the input. We store it in the
+% control sequence \cs{EQ_complete_mathdisplay}.
+% \cs{EQ_begin_equation:} adds the start of the environment and
+% \cs{EQ_end_equation:} adds the corresponding end.
+% \begin{macrocode}
+ \EQ_begin_equation:
+% \end{macrocode}
+% In case we face a \env{multline} we add what's necessary.
+% \begin{macrocode}
+ \MH_if_boolean:nT {outer_mult}{
+ \setkeys{\MT_options_name:}{
+ firstline-afterskip=0pt,
+ lastline-preskip=0pt,
+ multlined-width=0pt,
+ }
+ \ifodd \l_EQ_alignmentmode_int
+ \setkeys{\MT_options_name:}{multlined-pos=b}
+ \else:
+ \setkeys{\MT_options_name:}{multlined-pos=t}
+ \fi:
+ \g@addto@macro\EQ_complete_mathdisplay:{
+ \begin{MTmultlined}\relax}
+ }
+ \g@addto@macro\EQ_complete_mathdisplay:\EQ_mathbody:
+ \MH_if_boolean:nT {outer_mult}{
+ \g@addto@macro\EQ_complete_mathdisplay:{\end{MTmultlined}}
+ }
+ \EQ_end_equation:
+% \end{macrocode}
+% Save the value of the \pkg{hyperref} link counter
+% \cs{Hy@linkcounter}.
+% \begin{macrocode}
+ \edef\EQ_hyperref_link_fint{\number\Hy@linkcounter}
+% \end{macrocode}
+% Firstly we call \cs{EQ_typeset_tags:} which suppresses all
+% output from the equations with the exception of the \cs{tag}'s.
+% This also allows us to find the widest tag which we'll need for
+% the environments that set's the math displays flush to the
+% margins, namely the \env{flalign} family. We save the counters
+% first though. As an extra treat we're also able to measure the
+% height and depth of the tags and the math display.
+% \begin{macrocode}
+ \savecounters@
+ \EQ_typeset_tags:
+% \end{macrocode}
+% \changes{v1.05d}{2004/02/26}{Removed one instance of
+% \cs{EQ_typeset_display:}}
+% Then find the widest tag. In an earlier implementation it was
+% necessary to typeset the display twice---a very costly procedure!
+% Now we save roughly 2120 lines of output from \cs{tracingall} on a
+% simple \env{gather} and 2600 lines with \env{align}. That's a
+% little more than 21\% saved\ldots
+% \changes{v2.10}{2004/07/26}{Removed \cs{find_widesttag:}}
+% \changes{v2.10}{2004/07/26}{Added check for equation number to
+% make sure the labelling/printing mechanism of \pkg{mathtools} work
+% properly}
+% Then we restore the counters and measure the extra material.
+% Save the value of the equation counter for later in case the
+% special equation numbering scheme from \pkg{mathtools} is in
+% effect.
+% \begin{macrocode}
+ \edef\l_EQ_equation_fint{\number\c@equation}
+ \restorecounters@
+% \end{macrocode}
+% Restore the value of the \pkg{hyperref} link counter
+% \cs{Hy@linkcounter}.
+% \begin{macrocode}
+ \Hy@linkcounter=\EQ_hyperref_link_fint
+ \settowidth\l_EQ_totalwidth_dim{%
+ $\EQ_left_side:\EQ_innerbox:{}\EQ_right_side:$}%
+% \end{macrocode}
+% Then call the appropriate \cs{EQ_modify_linewidth_}\meta{num}\texttt{:}
+% where \meta{num} is taken from the numbering scheme shown earlier.
+% \begin{macrocode}
+ \MH_if_boolean:nTF {outer_mult}
+ { \def\EQ_next:{_mult} }
+ { \def\EQ_next:{} }
+ \@nameuse{EQ_modify_linewidth_
+ \romannumeral\l_EQ_equationtype_int\EQ_next: :}%
+% \end{macrocode}
+% We can then typeset the display knowing that all modifications
+% have been made correctly. \cs{EQ_typeset_display:} gobbles the
+% \cs{tag}'s, which in turn is equivalent to setting the display
+% centered in non-\mode{fleqn} mode.
+% \begin{macrocode}
+ \EQ_typeset_display:
+% \end{macrocode}
+% Call the appropriate \cs{find_displaywidth_}\meta{num}\texttt{:}
+% which extracts the display width (\cs{l_EQ_displaywidth_dim}).
+% \begin{macrocode}
+ \@nameuse{find_displaywidth_
+ \romannumeral\l_EQ_equationtype_int\EQ_next: :}
+ \MH_addtolength:dn
+ \l_EQ_totalwidth_dim{\l_EQ_displaywidth_dim}
+% \end{macrocode}
+% We save the math display in a box of the correct size.
+% \begin{macrocode}
+ \savebox\EQ_mathdisplay_box[\l_EQ_totalwidth_dim][c]{%
+ $\EQ_left_side:
+ \EQ_innerbox:{%
+ \if_case:w \l_EQ_alignmentmode_int\or:
+% \end{macrocode}
+% If the equation is centered we make the box centered
+% \begin{macrocode}
+ \makebox[\l_EQ_displaywidth_dim][c]
+ {\usebox{\EQ_mathdisplay_box}}%
+ \or:
+ \makebox[\l_EQ_displaywidth_dim][c]
+ {\usebox{\EQ_mathdisplay_box}}%
+ \or:
+% \end{macrocode}
+% Else we set it in a left aligned box and take care of the
+% \cs{@mathmargin} unless we're in \env{flalign} or \env{flalign*}.
+% \begin{macrocode}
+ \makebox[\l_EQ_displaywidth_dim][l]{%
+ \if_num:w \l_EQ_equationtype_int=5 \else:
+ \if_num:w \l_EQ_equationtype_int=6 \else:
+ \kern-\@mathmargin
+ \fi:
+ \fi:
+ \usebox{\EQ_mathdisplay_box}}%
+ \or:
+ \makebox[\l_EQ_displaywidth_dim][l]{%
+ \if_num:w \l_EQ_equationtype_int=5 \else:
+ \if_num:w \l_EQ_equationtype_int=6 \else:
+ \kern-\@mathmargin
+ \fi:
+ \fi:
+ \usebox{\EQ_mathdisplay_box}}%
+ \fi:}%
+ \EQ_right_side:$}%
+% \end{macrocode}
+% Then we're ready for typesetting. We just use an ordinary
+% |\begin{equation*}| | ... | |\end{equation*}| construction.
+% \changes{v2.00}{2004/04/14}{Used a saved definition of
+% \env{equation*} instead to allow overloading}
+% With v2.00 this changed to using a copy of the original
+% \env{equation*} environment. All this because of the
+% \opt{overload} option.
+% \begin{macrocode}
+ \begin{AmSequation*}
+ \@nameuse{EQ_place_display_
+ \romannumeral\l_EQ_equationtype_int\EQ_next: :}
+% \end{macrocode}
+% \cs{tag} must have a non-zero width argument in order to function
+% properly, so we make sure there is a tag before we try to typeset
+% it. Also make sure that the boolean |show_manual_tags| is true
+% just for this tag.
+% \begin{macrocode}
+ \if_dim:w \g_EQ_widesttag_dim>\z@
+ \MH_set_boolean_T:n {show_manual_tags}
+% \end{macrocode}
+% Set the tag in a left aligned box when in \mode{leqno} mode and
+% right aligned when in \mode{reqno} mode.
+% \begin{macrocode}
+ \if_case:w \l_EQ_alignmentmode_int
+ \or: \EQ_place_tag:N r %#1
+ \or: \EQ_place_tag:N l %#2
+ \or: \EQ_place_tag:N r %#3
+ \or: \EQ_place_tag:N l %#4
+ \fi:
+ \fi:
+ \end{AmSequation*}
+% \end{macrocode}
+% \changes{v2.11}{2004/08/03}{Use raw \TeX{} commands to speed it up}
+% Restore the equation counter.
+% \begin{macrocode}
+ \global\c@equation=\l_EQ_equation_fint\relax
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Initializing the Equations}
+%
+% \begin{macro}{\EQ_initialize:}
+% We save all the initializations in this hook:
+% \begin{macrocode}
+\def\EQ_initialize:{%
+ \m@th
+% \end{macrocode}
+% More support for \pkg{ntheorem}. We use special versions of
+% the tag setting commands in order to produce the correct result.
+% For instance in \mode{leqno} mode you would still want the end of
+% theorem symbol at the bottom of the math display.
+% \begin{macrocode}
+ \MH_let:NwN\SetTagPlusEndMark\EQ_tag_plus_endmark:
+ \MH_let:NwN\SetOnlyEndMark\EQ_only_endmark:
+ \l_EQ_temp_linewidth_dim\linewidth
+ \g_EQ_toprow_height_dim\z@
+ \g_EQ_bottomrow_depth_dim\z@
+ \g_EQ_toptag_height_dim\z@
+ \g_EQ_bottomtag_depth_dim\z@
+ \g_EQ_widesttag_dim\z@
+% \end{macrocode}
+% \changes{v2.11}{2004/08/03}{Added a \cs{g_EQ_latest_nonzerodepth_row_fint}}
+% \begin{macrocode}
+ \xdef\g_EQ_latest_nonzerodepth_row_fint{\z@}
+ \edef\EQ_restore_tex_delimiter:{%
+ \delimiterfactor\the\delimiterfactor
+ \delimitershortfall\the\delimitershortfall\relax}%
+ \g@addto@macro\EQ_complete_mathdisplay:
+ \EQ_restore_tex_delimiter:
+ \delimitershortfall\EmphEqdelimitershortfall
+ \delimiterfactor\EmphEqdelimiterfactor
+% \end{macrocode}
+% Disable \cs{intertext} and issue an error message. Using the
+% normal error message for an invalid \cs{intertext} would be less
+% than great because it would say
+% \begin{verbatim}
+% ! Package amsmath Error: Invalid use of \intertext.
+%
+% See the amsmath package documentation for explanation.
+% Type H <return> for immediate help.
+% ...
+% \end{verbatim}
+% That's not good enough, so we redefine things a bit. In
+% \pkg{amsmath} the command \cs{intertext@} is called inside the
+% math environments and defines \cs{intertext}. We hook into this.
+% \begin{macrocode}
+ \MH_let:NwN\intertext@\EQ_intertext:
+ \EQ_displaybreak:}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\EQ_intertext:}
+% Then we issue a suitable error message.
+% \begin{macrocode}
+\def\EQ_intertext:{%
+ \def\intertext##1{\PackageError{empheq}{%
+ You~cannot~use~\string\intertext\space inside~the~`empheq'
+ \MessageBreak
+ environment,~as~`empheq'~creates~an~unbreakable~box}\@eha}}
+\def\EQ_displaybreak:{%
+ \def\dspbrk@[##1]{\PackageWarning{empheq}{%
+ You~cannot~use~\string\displaybreak\space inside~the~`empheq'%
+ \MessageBreak
+ environment,~as~`empheq'~creates~an~unbreakable~box.}}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\EQ_new_equationtype:nnn}
+% \begin{macro}{\EQ_new_equationtype_arg:nnn}
+% We have to inform \env{EmphEqMainEnv} which equation type we're
+% using, so we define an interface for that.
+% \begin{macrocode}
+\def\EQ_new_equationtype:nnn #1#2#3{%
+ \define@key{#1}{#2}[true]{%
+ \l_EQ_equationtype_int=#3\relax
+ \def\EQ_begin_equation:
+ {\g@addto@macro{\EQ_complete_mathdisplay:}{\begin{#2}}}%
+ \def\EQ_end_equation:
+ {\g@addto@macro{\EQ_complete_mathdisplay:}{\end{#2}}}}}
+\def\EQ_new_equationtype_arg:nnn #1#2#3{%
+ \define@key{#1}{#2}{%
+ \l_EQ_equationtype_int=#3\relax
+ \def\EQ_begin_equation:
+ {\g@addto@macro{\EQ_complete_mathdisplay:}{\begin{#2}{##1}}}%
+ \def\EQ_end_equation:
+ {\g@addto@macro{\EQ_complete_mathdisplay:}{\end{#2}}}}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \subsubsection{Separating Tags and Display}
+%
+% \begin{macro}{\EQ_typeset_tags:}
+% Typesetting the tags without the display.
+% \begin{macrocode}
+\def\EQ_typeset_tags:{%
+ \sbox\EQ_tag_box{%
+ \parbox{.5\maxdimen}{%
+ \hbadness\@M
+% \end{macrocode}
+% Make sure all skips are zero ands support \pkg{ntheorem}.
+% \changes{v1.05a}{2004/02/17}{Forgot to support \pkg{ntheorem} in
+% both \cs{EQ_typeset_tags:} and \cs{EQ_typeset_display:}.}
+% \begin{macrocode}
+ \EQ_prevent_vertical_space:
+% \end{macrocode}
+% Support for \pkg{ntheorem}. This package patches \cs{endgather}
+% and \cs{endalign} with the commands \cs{TagsPlusEndmarks} and
+% \cs{RestoreTags} but we do not want them disturbing our output so
+% we disable them when typesetting the display.
+% \begin{macrocode}
+ \EQ_typeset_tags_hook:
+% \end{macrocode}
+% Then use our own versions of \cs{set@gather@field} and
+% \cs{set@field}.
+% \begin{macrocode}
+ \MH_let:NwN\set@gather@field\EQ_set_gather_field:
+ \MH_let:NwN\set@field\EQ_set_align_field:
+% \end{macrocode}
+% Next two lines are for measuring of the first and last row of a
+% display of the \env{align}, \env{alignat} or \env{flalign} family.
+% \begin{macrocode}
+ \MH_set_boolean_T:n {continue_measuring}
+ \global\g_EQ_temprow_int\m@ne
+ \MH_let:NwN \EQ_saved_maketag:n \maketag@@@
+ \def\maketag@@@##1{
+ \EQ_maketag:Nn \EQ_saved_maketag:n {##1}}
+% \end{macrocode}
+% Then typeset the display.
+% \begin{macrocode}
+ \EQ_complete_mathdisplay:}}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\EQ_predisplay_adjustment:}
+% \changes{v1.05c}{2004/02/25}{Added \cs{EQ_predisplay_adjustment:}}
+%
+% \changes{v2.00}{2004/04/14}{Added a missing \cs{normallineskip} in
+% case of extremely big tag height}
+%
+% For adjusting vertical spacing in the display.
+% \begin{macrocode}
+\def\EQ_predisplay_adjustment:{%
+ \if_dim:w \g_EQ_toprow_height_dim<\baselineskip
+ \vskip\g_EQ_toprow_height_dim
+ \vskip-\baselineskip
+ \else:
+ \vskip-\normallineskip
+ \fi:
+ \if_dim:w \g_EQ_toptag_height_dim>\g_EQ_toprow_height_dim
+ \if_dim:w \g_EQ_toptag_height_dim>\baselineskip
+ \vskip-\g_EQ_toptag_height_dim
+ \vskip\baselineskip
+ \vskip-\normallineskip
+ \fi:
+ \fi:}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\EQ_postdisplay_adjustment:}
+% \changes{v1.05c}{2004/02/25}{Added \cs{EQ_postdisplay_adjustment:}}
+% Name says it all.
+% \begin{macrocode}
+\def\EQ_postdisplay_adjustment:{%
+ \if_dim:w \g_EQ_bottomrow_depth_dim<\dp\strutbox
+ \vskip\g_EQ_bottomrow_depth_dim
+ \vskip-\dp\strutbox
+ \fi:
+ \if_dim:w \g_EQ_bottomtag_depth_dim>\g_EQ_bottomrow_depth_dim
+ \if_dim:w \g_EQ_bottomtag_depth_dim>\dp\strutbox
+ \vskip-\g_EQ_bottomtag_depth_dim
+ \vskip\dp\strutbox
+ \fi:
+ \fi:}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\EQ_typeset_display:}
+% \changes{v1.05c}{2004/02/25}{Now takes two arguments: Either both
+% empty or \cs{EQ_predisplay_adjustment:} \&
+% \cs{EQ_postdisplay_adjustment:}}
+% \changes{v1.05d}{2004/02/26}{Changed again. Uses only
+% \cs{EQ_predisplay_adjustment:} \& \cs{EQ_postdisplay_adjustment:}}
+% We typeset the display without the tags and save it in a box.
+% \begin{macrocode}
+\def\EQ_typeset_display:{%
+ \sbox\EQ_mathdisplay_box{%
+ \parbox{\l_EQ_temp_linewidth_dim}{%
+% \end{macrocode}
+% We adjust the vertical spacing if needed:
+% \begin{macrocode}
+ \EQ_predisplay_adjustment:
+ \EQ_prevent_vertical_space:
+% \end{macrocode}
+% Support for \pkg{ntheorem}. This package patches \cs{endgather}
+% and \cs{endalign} with the commands \cs{TagsPlusEndmarks} and
+% \cs{RestoreTags} but we do not want them disturbing our output so
+% we disable them when typesetting the display.
+% \begin{macrocode}
+ \EQ_typeset_display_hook:
+% \end{macrocode}
+% Instead of gobbling the tags it's better to use \cs{phantom} since
+% a tall tag will ruin the vertical spacing. We use a special
+% version of \cs{phantom} to help us with other things as well.
+% \begin{macrocode}
+ \def\maketag@@@##1{\EQ_maketag:Nn \vphantom{##1}}%
+ \EQ_complete_mathdisplay:
+% \end{macrocode}
+% More space adjustment.
+% \begin{macrocode}
+ \EQ_postdisplay_adjustment:}}}
+% \end{macrocode}
+% \end{macro}
+% We need a few little helpers:
+% \begin{macro}{\EQ_prevent_vertical_space:}
+% \changes{v2.00}{2004/04/14}{Used \cs{nointerlineskip} instead}
+% As we typeset the math display inside a \cs{parbox} the math
+% environment will add \cs{abovedisplayskip} at the top and
+% \cs{belowdisplayskip} at the bottom. Also we suppress interline
+% skip with \cs{nointerlineskip}.
+% \begin{macrocode}
+\def\EQ_prevent_vertical_space:{%
+ \nointerlineskip
+ \abovedisplayskip\z@ \belowdisplayskip\z@\relax}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\EQ_maketag:Nn}
+% \changes{v1.05d}{2004/02/26}{Changed name from
+% \cs{EmphEqphantom} to \cs{EmphEqMaketag}}
+% This takes care of two things: We need to store the height of the
+% top tag and the depth of the bottom tag for later, but we also
+% need to use a \cs{vphantom} of the tag as it may be taller than
+% the line of math it is attached to (say, if you are using node
+% connectors from \pkg{pstricks} or some other weird stuff).
+% \begin{macrocode}
+\def\EQ_maketag:Nn #1#2{%
+ \setboxz@h{#2}%
+ \if_num:w \row@=\@ne
+ \global \g_EQ_toptag_height_dim = \ht\z@
+ \fi:
+% \end{macrocode}
+% Similarly the depth of the last row is determined by measuring the
+% depth of box zero for each row and then using the last of the
+% values.
+% \begin{macrocode}
+ \global \g_EQ_bottomtag_depth_dim=\dp\z@
+% \end{macrocode}
+% \changes{v2.11}{2004/08/03}{Added a check for being in the last row.}
+% Save the row number for later as the \opt{ntheorem} option will need
+% it.
+% \begin{macrocode}
+ \xdef\g_EQ_latest_nonzerodepth_row_fint{\number\row@}
+ \@tempdima=\wd\z@
+ \if_dim:w \@tempdima > \g_EQ_widesttag_dim
+ \global \g_EQ_widesttag_dim = \@tempdima
+ \fi:
+ #1{#2}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Measuring \env{gather}}
+% \begin{macro}{\EQ_set_gather_field:}
+% Box zero (\cs{z@}) contains the entire line of math in a
+% \env{gather}, so instead of typesetting it we typeset the phantom
+% of it and call \cs{EQ_measure_gather:}.
+% \begin{macrocode}
+\def\EQ_set_gather_field:{%
+ \iftagsleft@
+ \global\lineht@\ht\z@
+ \else:
+ \global\lineht@\dp\z@
+ \fi:
+ \kern\eqnshift@
+ %\boxz@ % Original amsmath version
+ \EQ_measure_gather:
+ \phantom{\boxz@}%
+ \hfil}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\EQ_measure_gather:}
+% Measuring the height of the individual lines in a \env{gather} is
+% fairly easy. If \cs{row@} is equal to one, we're in the first
+% line, and the height of the top row is simply given by the height
+% of box zero.
+% \begin{macrocode}
+\def\EQ_measure_gather:{%
+ \if_num:w \row@=\@ne
+ \g_EQ_toprow_height_dim=\ht\z@
+ \fi:
+% \end{macrocode}
+% Similarly the depth of the last row is determined by measuring the
+% depth of box zero for each row and then using the last of the
+% values.
+% \begin{macrocode}
+ \g_EQ_bottomrow_depth_dim=\dp\z@
+ \global\g_EQ_toprow_height_dim\g_EQ_toprow_height_dim
+ \global\g_EQ_bottomrow_depth_dim\g_EQ_bottomrow_depth_dim}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Measuring \env{align}, \env{alignat} and \env{flalign}}
+% \begin{macro}{\EQ_set_align_field:}
+% Same technique as for \cs{EQ_set_gather_field}. Only this time
+% we have to stop the underlying \cs{start@align} from going over
+% the measuring phase twice. That's when the conditional
+% \bool{continue_measuring} comes into the picture.
+% \begin{macrocode}
+\def\EQ_set_align_field:{%
+ \column@plus
+ \iftagsleft@
+ \if_dim:w \ht\z@>\lineht@
+ \global\lineht@\ht\z@
+ \fi:
+ \else:
+ \if_dim:w \dp\z@>\lineht@
+ \global\lineht@\dp\z@
+ \fi:
+ \fi:
+ %\boxz@ % Original amsmath version
+ \MH_if_boolean:nT {continue_measuring}{ \EQ_measure_align: }
+ \phantom{\boxz@}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\EQ_measure_align:}
+% We have to measure every single field of the \cs{align@} \ldots\@
+% Oh well, here it comes:
+% \begin{macrocode}
+\newcount\g_EQ_temprow_int
+\MH_new_boolean:n {still_in_samerow}
+\MH_new_boolean:n {continue_measuring}
+\def\EQ_measure_align:{%
+ \if_num:w \g_EQ_temprow_int=\row@
+ \MH_set_boolean_T:n {still_in_samerow}
+ \else:
+ \if_num:w \g_EQ_temprow_int>\row@
+ \global\MH_set_boolean_F:n {continue_measuring}
+ \fi:
+ \MH_set_boolean_F:n {still_in_samerow}
+ \global\@tempdimc=\@tempdimb
+ \global\@tempdimb=\g_EQ_bottomrow_depth_dim
+ \fi:
+ \MH_if_boolean:nTF {continue_measuring}{
+ \global\g_EQ_temprow_int=\row@
+ \@tempcnta=\row@
+ \if_num:w \@tempcnta=\z@
+ \@tempdima=\g_EQ_toprow_height_dim
+ \g_EQ_toprow_height_dim=\ht\z@\relax
+ \if_dim:w \g_EQ_toprow_height_dim<\@tempdima
+ \g_EQ_toprow_height_dim\@tempdima
+ \fi:
+ \fi:
+ \MH_if_boolean:nTF {still_in_samerow}{
+ \@tempdima=\g_EQ_bottomrow_depth_dim
+ \g_EQ_bottomrow_depth_dim=\dp\z@\relax
+ \if_dim:w \g_EQ_bottomrow_depth_dim<\@tempdima
+ \g_EQ_bottomrow_depth_dim\@tempdima
+ \fi:
+ }{
+ \g_EQ_bottomrow_depth_dim\dp\z@\relax
+ }
+ }{
+ \global\g_EQ_bottomrow_depth_dim=\@tempdimc
+ }
+ \global\g_EQ_toprow_height_dim\g_EQ_toprow_height_dim
+ \global\g_EQ_bottomrow_depth_dim\g_EQ_bottomrow_depth_dim}
+% \end{macrocode}
+% \end{macro}
+% \subsubsection{Typesetting the Tags}
+% \begin{macro}{\EQ_place_tag:N}
+% Fool \LaTeX\ into thinking the tag is only as wide as the widest
+% tag (remember the real width of the \cs{EQ_tag_box} is
+% $0.5$\cs{maxdimen}.
+% \begin{macrocode}
+\def\EQ_place_tag:N #1{%
+ \tag*{\makebox[\g_EQ_widesttag_dim][#1]{%
+ \EQ_vertical_tag_adjustment:n {\usebox{\EQ_tag_box}}}}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\EQ_vertical_tag_adjustment:n}
+% \changes{v2.00}{2004/04/14}{Added a missing \cs{normallineskip} in
+% case of extremely big tag height}
+% This is a little tricky. We have measured the height of the top
+% row and top tag and the depth of the bottom row and bottom tag.
+% Now we have to adjust the vertical spacing so it comes out just
+% right. Remember we have separated the tags and the math display
+% but we would still like to have them line up as they should! We do
+% it all inside a group so we can use the scratch dimensions safely.
+% \begin{macrocode}
+\def\EQ_vertical_tag_adjustment:n #1{{%
+ \@tempdima\z@\@tempdimb\z@
+ \@tempdimc=\dp\strutbox
+ \if_dim:w \g_EQ_toprow_height_dim<\baselineskip
+ \MH_setlength:dn
+ \@tempdima{\g_EQ_toprow_height_dim-\baselineskip}
+ \else:
+ \MH_setlength:dn \@tempdima{-\normallineskip}
+ \fi:
+ \if_dim:w \g_EQ_toptag_height_dim>\g_EQ_toprow_height_dim
+ \if_dim:w \g_EQ_toptag_height_dim>\baselineskip
+ \MH_addtolength:dn \@tempdima
+ {-\g_EQ_toptag_height_dim+\baselineskip-\normallineskip}
+ \fi:
+ \fi:
+ \if_dim:w \g_EQ_bottomrow_depth_dim<\@tempdimc
+ \MH_setlength:dn \@tempdimb
+ {\g_EQ_bottomrow_depth_dim-\@tempdimc}
+ \fi:
+% \end{macrocode}
+% \changes{v2.00}{2004/04/14}{Fixed minor bug}
+% If the last condition is fulfilled we also need to cancel the
+% first condition.
+% \begin{macrocode}
+ \if_dim:w \g_EQ_bottomtag_depth_dim>\g_EQ_bottomrow_depth_dim
+ \if_dim:w \g_EQ_bottomtag_depth_dim<\@tempdimc
+ \else:
+ \MH_addtolength:dn \@tempdimb
+ {-\g_EQ_bottomtag_depth_dim+\@tempdimc}
+ \fi:
+ \fi:
+ \raisebox{-0.5\@tempdima+0.5\@tempdimb}{#1}}}%
+% \end{macrocode}
+% \end{macro}
+% \section{Adding the Equation Types}
+% Adding an equation type is fairly easy. The outline is this:
+% \begin{list}{}{\leftmargin2em}
+% \item[]|\EQ_new_equationtype{EmphEqEnv}|\marg{\AmS\
+% env}\marg{arabic num}\texttt{:}
+% \item[]|\def\EQ_modify_linewidth_|\meta{roman num}\texttt{:}\\
+% \hspace*{2em}\marg{Optionally alter \cs{l_EQ_temp_linewidth_dim}}
+% \item[]|\def\find_displaywidth_|\meta{roman num}\texttt{:}\\
+% \hspace*{2em}\marg{Set \cs{l_EQ_displaywidth_dim}}
+% \item[]|\def\EQ_place_display_|\meta{roman num}\texttt{:}\\
+% \hspace*{2em}\marg{Make use of \cs{EQ_use_mathdisplay:}}
+% \end{list}
+% \begin{macro}{\EQ_use_mathdisplay:}
+% A shorthand.
+% \begin{macrocode}
+\def\EQ_use_mathdisplay:{%
+ \EQ_outerbox:{\usebox{\EQ_mathdisplay_box}}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+\def\EQ_options_name:{EmphEqOpt}
+% \end{macrocode}
+% \subsection{The \env{equation} Family}
+% Just a few aliases because \env{equation} and \env{equation*}
+% behave strangely. Much better to use \env{gather} instead as this
+% is easier to measure. Besides it's less work (for us, not the
+% compiler). ;-)
+% \begin{macrocode}
+\MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{equation}{gather}
+ {\EQ_disable_linebreak:}
+\MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{equation*}{gather*}
+ {\EQ_disable_linebreak:}
+% \end{macrocode}
+% \begin{macro}{\EQ_disable_linebreak:}
+% \changes{v1.05c}{2004/02/25}{Introduced
+% \cs{EQ_disable_linebreak:} to prevent multi line
+% \env{equation}'s}
+% \changes{v1.05c}{2004/02/25}{Fixed it so that it works better}
+% Disable the line breaks in \env{equation} as these are actually
+% possible now, since we're in a \env{gather}! \cs{Let@} does it in
+% the environment, so that's the place to hack.
+% \begin{macrocode}
+\def\EQ_disable_linebreak:{%
+ \MH_let:NwN \EQ_saved_Let: \Let@
+ \def\Let@{\def\\{%
+ \PackageError{empheq}{You~ cannot~ use~ \string\\~ in~ equation!}
+ {\@eha}}
+% \end{macrocode}
+% Then restore the meaning of \cs{Let@} in case there is a
+% \env{gathered} or alike coming up.
+% \begin{macrocode}
+ \MH_let:NwN \Let@ \EQ_saved_Let:
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{The \env{align} Family}
+% \begin{macrocode}
+\EQ_new_equationtype:nnn {EmphEqEnv}{align}{1}
+\EQ_new_equationtype:nnn {EmphEqEnv}{align*}{2}
+% \end{macrocode}
+% \begin{macrocode}
+\def\EQ_modify_linewidth_i:{%
+% \end{macrocode}
+% If $\cs{maxfields@}=2$ we're in a single column \env{align} and
+% thus there is no flexible space.
+% \begin{macrocode}
+ \if_num:w \maxfields@=\tw@
+ \else:
+% \end{macrocode}
+% But if there is any flexible space we would very much like to
+% adjust it because we add material to the right and left of the
+% math display.
+% \begin{macrocode}
+ \setlength{\l_EQ_temp_linewidth_dim}{%
+ \linewidth-\l_EQ_totalwidth_dim-\widthof{\EQ_outerbox:{}}}%
+ \fi:}
+\def\EQ_modify_linewidth_ii:{\EQ_modify_linewidth_i:}
+\def\find_displaywidth_i:{%
+ \MH_setlength:dn \l_EQ_displaywidth_dim
+ {\l_EQ_temp_linewidth_dim-\alignsep@}
+ \if_case:w \l_EQ_alignmentmode_int
+ \or: % #1:
+ \MH_addtolength:dn \l_EQ_displaywidth_dim{-\alignsep@}%
+ \or: % #2:
+ \MH_addtolength:dn \l_EQ_displaywidth_dim{-\alignsep@}%
+ \or: % #3:
+ \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
+ \or: % #4:
+ \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
+ \fi:}
+\def\find_displaywidth_ii:{\find_displaywidth_i:}
+\def\EQ_place_display_i: {\EQ_use_mathdisplay:}
+\def\EQ_place_display_ii:{\EQ_place_display_i:}
+% \end{macrocode}
+%
+% \subsection{The \env{gather} Family}
+% This is a gem. Notice how easy it is once we got the framework for
+% it.
+% \begin{macrocode}
+\EQ_new_equationtype:nnn {EmphEqEnv}{gather}{3}
+\EQ_new_equationtype:nnn {EmphEqEnv}{gather*}{4}
+\def\EQ_modify_linewidth_iii:{}
+\def\EQ_modify_linewidth_iv:{\EQ_modify_linewidth_iii:}
+\def\find_displaywidth_iii:{%
+ \MH_setlength:dn \l_EQ_displaywidth_dim{\totwidth@}%
+ \if_case:w \l_EQ_alignmentmode_int \or: \or: % #1 & #2:
+ \or: % #3:
+ \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
+ \or: % #4:
+ \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
+ \fi:}
+\def\find_displaywidth_iv:{\find_displaywidth_iii:}
+\def\EQ_place_display_iii:{\EQ_use_mathdisplay:}
+\def\EQ_place_display_iv: {\EQ_place_display_iii:}
+% \end{macrocode}
+%
+% \subsection{The \env{flalign} Family}\label{sec:flalign+multline}
+% This was fairly easy, but then I had to take care of \ldots
+%
+% \subsubsection{The \env{multline} Family}
+% This was quite a pickle. Its implementation in \pkg{amsmath} is
+% very strange indeed; for instance the tag is typeset in the
+% measuring phase! So instead I thought I could fake it, but how
+% should I do it?
+%
+% The basic idea of \env{multline} is to typeset the first line
+% flush left, the last line flush right and the rest centered.
+% ``Aha,'' I thought, ``what if I make three columns, fool \LaTeX{}
+% into thinking the contents of the columns take no space and then
+% just put each line into a column?'' Thus the \env{flalign}
+% environment came to mind. I also distinctly remembered to have
+% seen an article about the equivalent of \cs{rlap} and \cs{llap} in
+% math mode, namely an article by Alexander R.~Perlis. This works
+% pretty well, and so does the same trick for producing a
+% \env{multlined} environment. That one uses an \env{alignedat} with
+% three columns.
+%
+% \changes{v1.05c}{2004/02/25}{Makes use of
+% \cs{MakeKeyvalAliasAddon} now}
+% Then we make \env{multline} into an alias for {flalign} but with
+% an extra switch \cs{ifEQ_multline:} set to true.
+% \begin{macrocode}
+\MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{multline}
+ {flalign}{\MH_set_boolean_T:n {multline}}
+\MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{multline*}
+ {flalign*}{\MH_set_boolean_T:n {multline}}
+% \end{macrocode}
+% \begin{macro}{\if_EQ_multline:}
+% \begin{macro}{\EQ_generic_multline:nnnnn}
+% We make a general command that'll provide the correct spacing and
+% then just define the user commands in terms of that single generic
+% one.
+% \begin{macrocode}
+\MH_new_boolean:n {multline}
+% \end{macrocode}
+% \begin{macro}{\EQ_multline_modify_linewidth_tag:}
+% \begin{macro}{\EQ_multline_modify_linewidth_notag:}
+% There is a big difference between the spacing in \env{multline}
+% depending on the presence of a tag. Therefore we split it up in
+% two cases. I made this choice because we need these adjustments
+% inside the adjustments for \env{flalign} and that makes it
+% incredibly difficult to see what happens.
+% \begin{macrocode}
+\def\EQ_multline_modify_linewidth_tag:{%
+ \if_case:w \l_EQ_alignmentmode_int
+ \or: % #1:
+ \MH_addtolength:dn \l_EQ_temp_linewidth_dim{%
+ -\g_EQ_widesttag_dim-\multlinetaggap-\multlinegap}%
+ \or:
+ \MH_addtolength:dn \l_EQ_temp_linewidth_dim{%
+ -\g_EQ_widesttag_dim-\multlinetaggap-\multlinegap}%
+ \or:
+ \MH_addtolength:dn \l_EQ_temp_linewidth_dim{%
+ -\@mathmargin-\g_EQ_widesttag_dim-\multlinetaggap}%
+ \or:
+ \MH_addtolength:dn
+ \l_EQ_temp_linewidth_dim{-\@mathmargin-\multlinegap}%
+ \fi:
+}
+\def\EQ_multline_modify_linewidth_notag:{%
+ \if_case:w \l_EQ_alignmentmode_int\or:
+ \MH_addtolength:dn \l_EQ_temp_linewidth_dim{-2\multlinegap}
+ \or:
+ \MH_addtolength:dn \l_EQ_temp_linewidth_dim{-2\multlinegap}
+ \or:
+ \MH_addtolength:dn
+ \l_EQ_temp_linewidth_dim{-\@mathmargin-\multlinegap}%
+ \or:
+ \MH_addtolength:dn
+ \l_EQ_temp_linewidth_dim{-\@mathmargin-\multlinegap}%
+ \fi:
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{environment}{MTmultlined}
+% Save the superior \env{multlined} from \pkg{mathtools} under a new
+% name.
+% \begin{macrocode}
+\MH_let:NwN \MTmultlined \multlined
+\MH_let:NwN \endMTmultlined \endmultlined
+% \end{macrocode}
+% \end{environment}
+% We make a choice here: the good \env{multline} or the bad?
+% \begin{macrocode}
+\MH_if_boolean:nTF {good_mult}{
+% \end{macrocode}
+% The good:
+% \begin{macrocode}
+\MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{multline}{gather}
+ {\MH_set_boolean_T:n {outer_mult}}
+\MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{multline*}{gather*}
+ {\MH_set_boolean_T:n {outer_mult}}
+\def\EQ_modify_linewidth_iii_mult:{
+ \setlength{\l_EQ_temp_linewidth_dim}{%
+ \linewidth-\widthof{\EQ_outerbox:{}}}%
+ \if_dim:w \g_EQ_widesttag_dim>\z@
+ \EQ_multline_modify_linewidth_tag:
+ \else:
+ \EQ_multline_modify_linewidth_notag:
+ \fi:
+ \MH_setlength:dn \l_MT_multwidth_dim{\l_EQ_temp_linewidth_dim}
+}
+\def\EQ_modify_linewidth_iv_mult:{\EQ_modify_linewidth_iii_mult:}
+\def\find_displaywidth_iii_mult:{%
+ \MH_setlength:dn \l_EQ_displaywidth_dim{\totwidth@}%
+ \if_case:w \l_EQ_alignmentmode_int \or: \or: % #1 & #2:
+ \or: % #3:
+ \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
+ \or: % #4:
+ \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
+ \fi:}
+\def\find_displaywidth_iv_mult:{\find_displaywidth_iii_mult:}
+\def\EQ_place_display_iii_mult:{
+ \if_case:w \l_EQ_alignmentmode_int
+ \or: % #1:
+ \if_dim:w \g_EQ_widesttag_dim>\z@
+ \abovedisplayshortskip=\abovedisplayskip
+ \rlap{
+ \kern-.5\linewidth
+ \kern\multlinegap
+ \EQ_use_mathdisplay:
+ }
+ \else:
+ \EQ_use_mathdisplay:
+ \fi:
+ \or: % #2:
+ \if_dim:w \g_EQ_widesttag_dim>\z@
+ \llap{
+ \EQ_use_mathdisplay:
+ \kern-.5\linewidth
+ \kern\multlinegap
+ }%
+ \else:
+ \EQ_use_mathdisplay:
+ \fi:
+ \or: % #3:
+ \EQ_use_mathdisplay:
+ \or: % #4:
+ \EQ_use_mathdisplay:
+ \fi:
+}
+\def\EQ_place_display_iv_mult: {\EQ_place_display_iii_mult:}
+% \end{macrocode}
+% \begin{macrocode}
+}{
+% \end{macrocode}
+% The bad
+% \begin{macrocode}
+\def\EQ_generic_multline:nnnnn #1#2#3#4#5{%
+% \end{macrocode}
+% This is a very tricky little detail. If we're in \mode{leqno} mode
+% we need just a we little width inside the \env{flalign}, so we put
+% in the smallest possible amount. Otherwise we wind up in a
+% \begin{verbatim}
+% ! Arithmetic overflow.
+% <recently read> \count@
+%
+% l.304 % \end{empheq}
+% \end{verbatim}
+% If you scroll past this error it will be typeset correctly, but
+% how many users can fix this by themselves?
+% \begin{macrocode}
+ \hskip1sp#2#3{{}#5}#4%
+ \if:w *#1\relax\else:\notag\fi:}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\multleft}
+% \begin{macro}{\multcenter}
+% \begin{macro}{\multright}
+% Then the commands that use \cs{EQ_generic_multline:nnnnn}. The
+% first three are the general purpose ones that also have a starred
+% version. The other three are for normal use.
+% \begin{macrocode}
+\def\multleft{\@ifstar{%
+ \MH_if_boolean:nTF {multlined}{
+ \def\EQ_next:{\EQ_multlined_left:n}
+ }{
+ \def\EQ_next:{
+ \EQ_generic_multline:nnnnn {*}{}{\mathrlap}{&&&&&}}
+ }
+ \EQ_next:}{%
+ \MH_if_boolean:nTF {multlined}{
+ \def\EQ_next:{\EQ_multlined_left:n}%
+ }{
+ \def\EQ_next:{
+ \EQ_generic_multline:nnnnn {}{}{\mathrlap}{&&&&&}}
+ }
+ \EQ_next:}}%
+\def\multcenter{\@ifstar{%
+ \MH_if_boolean:nTF {multlined}{
+ \def\EQ_next:{\EQ_multlined_center:n}%
+ }{
+ \def\EQ_next:{
+ \EQ_generic_multline:nnnnn {*}{&&}{\mathclap}{&&&}}
+ }
+ \EQ_next:}{%
+ \MH_if_boolean:nTF {multlined}{
+ \def\EQ_next:{\EQ_multlined_center:n }%
+ }{
+ \def\EQ_next:{
+ \EQ_generic_multline:nnnnn {}{&&}{\mathclap}{&&&}}
+ }
+ \EQ_next:}}%
+\def\multright{\@ifstar{%
+ \MH_if_boolean:nTF {multlined}{
+ \def\EQ_next:{\EQ_multlined_right:n }%
+ }{
+ \def\EQ_next:{
+ \EQ_generic_multline:nnnnn {*}{&&&&&}{\mathllap}{}}
+ }
+ \EQ_next:}{%
+ \MH_if_boolean:nTF {multlined}{
+ \def\EQ_next:{\EQ_multlined_right:n }%
+ }{
+ \def\EQ_next:{
+ \EQ_generic_multline:nnnnn {}{&&&&&}{\mathllap}{}}
+ }
+ \EQ_next:}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\multfirst}
+% \begin{macro}{\multmiddle}
+% \begin{macro}{\multlast}
+% If we're using the \mode{leqno} option, the equation number should
+% be placed in the first line.
+% \begin{macrocode}
+\def\multfirst{%
+ \MH_if_boolean:nTF {multlined}{
+ \def\EQ_next:{\EQ_multlined_left:n }%
+ }{
+ \if_case:w \l_EQ_alignmentmode_int
+ \or: % #1:
+ \def\EQ_next:{\multleft}%
+ \or: % #2:
+ \def\EQ_next:{\multleft*}%
+ \or: % #3:
+ \def\EQ_next:{\multleft}%
+ \or: % #4:
+ \def\EQ_next:{\multleft*}%
+ \fi:
+ }
+ \EQ_next:}
+% \end{macrocode}
+% Pretend the star was never there.
+% \begin{macrocode}
+\def\multmiddle{%
+ \def\EQ_next:{%
+ \MH_if_boolean:nTF {multlined}{
+ \expandafter\EQ_multlined_center:n
+ }{
+ \expandafter\multcenter
+ }
+ }%
+ \@ifstar{\EQ_next:}{\EQ_next:}}
+% \end{macrocode}
+% If we're using the \mode{reqno} option, the equation number
+% should be placed in the last line.
+% \begin{macrocode}
+\def\multlast{%
+ \MH_if_boolean:nTF {multlined}{
+ \def\EQ_next:{\EQ_multlined_right:n }%
+ }{
+ \if_case:w \l_EQ_alignmentmode_int
+ \or: % #1:
+ \def\EQ_next:{\multright*}%
+ \or: % #2:
+ \def\EQ_next:{\multright}%
+ \or: % #3:
+ \def\EQ_next:{\multright*}%
+ \or: % #4:
+ \def\EQ_next:{\multright}%
+ \fi:
+ }
+ \EQ_next:}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\multlinedwidth}
+% Here begins the code for \env{multlined}.
+% \begin{macrocode}
+\MH_new_boolean:n {multlined}
+\newdimen\multlinedwidth
+\MH_setlength:dn \multlinedwidth{.7\linewidth}
+% \end{macrocode}
+% \end{macro}
+% \begin{environment}{multlined}
+% \changes{v2.10}{2004/07/26}{Disallow spaces before optional
+% arguments.}
+% \begin{macro}{\EQ_multlined_I:w}
+% \begin{macro}{\EQ_multlined_II:w}
+% \begin{macro}{\EQ_multlined_III:nn}
+% Some trickery as we want to scan for two optional arguments that
+% may be interchanged.
+% \begin{macrocode}
+\renewenvironment{multlined}%
+ {\MH_nospace_ifnextchar:Nnn [ {\EQ_multlined_I:w}
+ {\EQ_multlined_I:w[c]}
+ }
+ { \endaligned }
+\def\EQ_multlined_I:w[#1]{%
+ \MH_nospace_ifnextchar:Nnn[ {\EQ_multlined_II:w[#1]}
+ {\EQ_multlined_II:w[#1][\multlinedwidth]}}
+\def\EQ_multlined_II:w[#1][#2]{%
+% \end{macrocode}
+% We tell \LaTeX\ that we're in \env{multlined}.
+% \begin{macrocode}
+ \MH_set_boolean_T:n {multlined}
+% \end{macrocode}
+% \changes{v2.10}{2004/07/26}{Fixed restoration of \cmd{\\}}
+% Restore the meaning of \cmd{\\} inside \env{multlined}, else it
+% wouldn't work in the \env{equation} environment.
+% \begin{macrocode}
+ \MH_let:NwN \Let@\MT_saved_Let:
+% \end{macrocode}
+% Then check the first optional argument and call
+% \cs{EQ_multlined_III:w}, which sets \cs{multlinewidth} if
+% specified and calls \cs{start@aligned} (an \env{alignedat} with
+% three columns).
+% \begin{macrocode}
+ \if:w t#1\relax \EQ_multlined_III:nn {#1}{#2}%
+ \else:
+ \if:w b#1\relax \EQ_multlined_III:nn {#1}{#2}%
+ \else:
+ \if:w c#1\relax \EQ_multlined_III:nn {#1}{#2}%
+ \else:
+ \EQ_multlined_III:nn {#2}{#1}%
+ \fi:
+ \fi:
+ \fi:
+ \mkern-\thinmuskip
+ \EQ_next:}
+\def\EQ_multlined_III:nn #1#2{%
+ \def\EQ_next:{\setlength\multlinedwidth{#2}%
+ \start@aligned{#1}{\thr@@}}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{environment}
+% \begin{macro}{\EQ_multlined_left:n}
+% \begin{macro}{\EQ_multlined_center:n}
+% \begin{macro}{\EQ_multlined_right:n}
+% The internal versions of \cs{multleft} etc.\ adapted for
+% \env{multlined}.
+% \begin{macrocode}
+\def\EQ_multlined_left:n #1{%
+ \mathrlap{#1}&\hskip.5\multlinedwidth&&\hskip.5\multlinedwidth&&}
+\def\EQ_multlined_center:n #1{%
+ &\hskip.5\multlinedwidth&&\mathclap{#1}\hskip.5\multlinedwidth&&}
+\def\EQ_multlined_right:n #1{%
+ &\hskip.5\multlinedwidth&&\hskip.5\multlinedwidth&&\mathllap{#1}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% End of bad multline.
+% \begin{macrocode}
+}
+% \end{macrocode}
+%
+% \subsubsection{The Code for \env{flalign} \& \env{multline}}
+% \begin{macrocode}
+\EQ_new_equationtype:nnn {EmphEqEnv}{flalign}{5}
+\EQ_new_equationtype:nnn {EmphEqEnv}{flalign*}{6}
+\def\EQ_modify_linewidth_v:{%
+ \setlength{\l_EQ_temp_linewidth_dim}{%
+ \linewidth-\l_EQ_totalwidth_dim-\widthof{\EQ_outerbox:{}}}%
+ \if_dim:w \g_EQ_widesttag_dim>\z@
+ \MH_if_boolean:nTF {multline}{
+ \EQ_multline_modify_linewidth_tag:
+ }{
+ \if_case:w \l_EQ_alignmentmode_int
+ \or: % #1:
+ \MH_addtolength:dn \l_EQ_temp_linewidth_dim
+ {-\g_EQ_widesttag_dim-\mintagsep}
+ \or: % #2:
+ \MH_addtolength:dn \l_EQ_temp_linewidth_dim
+ {-\g_EQ_widesttag_dim-\mintagsep}%
+ \or: % #3:
+ \MH_addtolength:dn \l_EQ_temp_linewidth_dim
+ {-\g_EQ_widesttag_dim-\mintagsep}
+ \or: % #4:
+ \MH_addtolength:dn \l_EQ_temp_linewidth_dim
+ {-\@mathmargin}
+ \fi:
+ }
+ \else:
+ \MH_if_boolean:nT {multline}{
+ \EQ_multline_modify_linewidth_notag:
+ }
+ \fi:}
+\def\EQ_modify_linewidth_vi:{\EQ_modify_linewidth_v:}
+\def\find_displaywidth_v:{%
+ \MH_setlength:dn
+ \l_EQ_displaywidth_dim{\l_EQ_temp_linewidth_dim}}
+\def\find_displaywidth_vi:{\find_displaywidth_v:}
+\def\EQ_place_display_v:{%
+ \if_case:w \l_EQ_alignmentmode_int
+ \or: % #1:
+ \if_dim:w \g_EQ_widesttag_dim>\z@
+ \MH_if_boolean:nTF {multline}{
+ \rlap{\kern\multlinegap \kern-.5\linewidth
+ \EQ_use_mathdisplay:
+ \kern-\mintagsep \kern\multlinetaggap}%
+ }{
+ \rlap{\kern-.5\linewidth\EQ_use_mathdisplay:}%
+ }
+ \else:
+ \EQ_use_mathdisplay:
+ \fi:
+ \or: % #2:
+ \if_dim:w \g_EQ_widesttag_dim>\z@
+ \MH_if_boolean:nTF {multline}{
+ \llap{\kern-\mintagsep \kern\multlinetaggap
+ \EQ_use_mathdisplay:
+ \kern\multlinegap \kern-.5\linewidth}%
+ }{
+ \llap{\EQ_use_mathdisplay:\kern-.5\linewidth}%
+ }
+ \else:
+ \EQ_use_mathdisplay:
+ \fi:
+ \or: % #3:
+ \MH_if_boolean:nF {multline}{ \kern-\multlinetaggap }
+ \EQ_use_mathdisplay:
+ \or: % #4:
+ \if_dim:w \g_EQ_widesttag_dim>\z@
+ \else:
+ \MH_if_boolean:nF {multline}{ \kern-\@mathmargin }
+ \fi:
+ \EQ_use_mathdisplay:
+ \fi:
+ \MH_set_boolean_F:n {multline}}
+\def\EQ_place_display_vi:{\EQ_place_display_v:}
+% \end{macrocode}
+%
+% \subsection{The \env{alignat} Family}
+% This is just as easy as \env{gather}. Actually only one line is
+% different from \env{gather}!
+% \begin{macrocode}
+\EQ_new_equationtype_arg:nnn {EmphEqEnv}{alignat}{7}
+\EQ_new_equationtype_arg:nnn {EmphEqEnv}{alignat*}{8}
+\def\EQ_modify_linewidth_vii:{}
+\def\EQ_modify_linewidth_viii:{\EQ_modify_linewidth_vii:}
+\def\find_displaywidth_vii:{%
+ \MH_setlength:dn \l_EQ_displaywidth_dim{\totwidth@}%
+ \if_case:w \l_EQ_alignmentmode_int
+ \or: % #1:
+ \or: % #2:
+ \or: % #3:
+ \MH_addtolength:dn \l_EQ_displaywidth_dim{-\eqnshift@}%
+ \or: % #4:
+ \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
+ \fi:}
+\def\find_displaywidth_viii:{\find_displaywidth_vii:}
+\def\EQ_place_display_vii:{\EQ_use_mathdisplay:}
+\def\EQ_place_display_viii:{\EQ_place_display_vii:}
+% \end{macrocode}
+% \section{The User Interface}
+% The different keys.
+% \begin{macrocode}
+\define@key{\EQ_options_name:}{box}{\def\EQ_outerbox:{#1}}
+\MH_keyval_alias:nnn {\EQ_options_name:}{outerbox}{box}
+% \end{macrocode}
+% \begin{macro}{\EQ_marginbox:nn}
+% The margin box. Uwe Siart wanted it.
+% \begin{macrocode}
+\def\EQ_marginbox:nn #1#2{%
+ \settowidth{\@tempdima}{#2}%
+ \makebox[\z@]{\hspace{\@tempdima}#1{#2}}}
+\define@key{\EQ_options_name:}{marginbox}{%
+ \def\EQ_outerbox:{\EQ_marginbox:nn {#1}}}
+% \end{macrocode}
+% \end{macro}
+% Almost self-explanatory, isn't?
+% \begin{macrocode}
+\define@key{\EQ_options_name:}{innerbox}{\def\EQ_innerbox:{#1}}
+\define@key{\EQ_options_name:}{left}{\def\EQ_left_side:{#1}}
+\define@key{\EQ_options_name:}{right}{\def\EQ_right_side:{#1}}
+% \end{macrocode}
+% \begin{macro}{\empheqset}
+% Just a user friendly way to set keys. Uwe Siart again.
+% \begin{macrocode}
+\newcommand*\empheqset[1]{\setkeys{\EQ_options_name:}{#1}}
+% \end{macrocode}
+% \end{macro}
+% The old keys from the original version are no longer supported.
+% Instead they give an error message (RM):
+% \begin{macrocode}
+\def\EQ_upgrade_error:{%
+ \PackageError{empheq}
+ {You~ are~ using~ the~ old~ syntax!\MessageBreak
+ The~ `empheq'~ environment~ takes~ a~ mandatory~
+ argument~ now.\MessageBreak
+ You~ need~ to~ exit~ and~ change~ your~ source~ file.}
+ {It~ won't~ work,~ trust me.~ Press~ `X'~ now.}}
+\define@key{\EQ_options_name:}{boxtype}{\EQ_upgrade_error:}
+\define@key{\EQ_options_name:}{Left}{\EQ_upgrade_error:}
+\define@key{\EQ_options_name:}{Right}{\EQ_upgrade_error:}
+% \end{macrocode}
+% \begin{environment}{empheq}
+% The environment.
+% \begin{macrocode}
+\newenvironment{empheq}[2][]{%
+ \setkeys{EmphEqEnv}{#2}\setkeys{\EQ_options_name:}{#1}%
+ \EmphEqMainEnv}{\endEmphEqMainEnv}
+% \end{macrocode}
+% \end{environment}
+% \begin{macro}{\DeclareLeftDelimiter}
+% \begin{macro}{\EQ_declare_left_delimiter:nnnn}
+% \begin{macro}{\DeclareRightDelimiter}
+% \begin{macro}{\EQ_declare_right_delimiter:nnnn}
+% The delimiter interface.
+% \changes{v0.7}{2003/05/11}{Introduced delimiter interface}
+% \changes{v1.05d}{2004/02/26}{Changed the definitions.}
+% We now use the \cs{EQ_tag_box} to calculate the height but
+% adjust the vertical spacing. All this to prevent running
+% \cs{EQ_typeset_display:} twice.
+% \begin{macrocode}
+\newcommand*\DeclareLeftDelimiter[2][]{%
+ \EQ_declare_left_delimiter:nnnn {#1}{#2}{}{}%
+ \EQ_declare_left_delimiter:nnnn {#1}{#2}{big}{\EQ_innerbox:}}
+\def\EQ_declare_left_delimiter:nnnn #1#2#3#4{%
+ \@namedef{empheq#3\expandafter\@gobble\string#2}{%
+ \left#2%
+ \mkern-\thinmuskip
+ \vphantom{#4{\parbox{.5\maxdimen}{%
+ \EQ_predisplay_adjustment:
+ \EQ_prevent_vertical_space:
+ \usebox{\EQ_tag_box}%
+ \EQ_postdisplay_adjustment:}}}%
+ \right.%
+ \kern-\nulldelimiterspace #1}}
+\newcommand*\DeclareRightDelimiter[2][]{%
+ \EQ_declare_right_delimiter:nnnn {#1}{#2}{}{}%
+ \EQ_declare_right_delimiter:nnnn {#1}{#2}{big}{\EQ_innerbox:}}
+\def\EQ_declare_right_delimiter:nnnn #1#2#3#4{%
+ \@namedef{empheq#3\expandafter\@gobble\string#2}{%
+ \kern-\nulldelimiterspace
+ #1%
+ \left.%
+ \vphantom{#4{\parbox{.5\maxdimen}{%
+ \EQ_predisplay_adjustment:
+ \EQ_prevent_vertical_space:
+ \usebox{\EQ_tag_box}%
+ \EQ_postdisplay_adjustment:}}}%
+ \mkern-\thinmuskip
+ \right#2}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% The actual declarations.
+% \begin{macrocode}
+\DeclareLeftDelimiter{\lbrace}
+\DeclareRightDelimiter{\rbrace}
+\DeclareLeftDelimiter{\lbrack}
+\DeclareRightDelimiter{\rbrack}
+\DeclareLeftDelimiter{\langle}
+\DeclareRightDelimiter{\rangle}
+\DeclareLeftDelimiter{\lvert}
+\DeclareRightDelimiter{\rvert}
+\DeclareLeftDelimiter{\lVert}
+\DeclareRightDelimiter{\rVert}
+\DeclareLeftDelimiter{\lfloor}
+\DeclareRightDelimiter{\rfloor}
+\DeclareLeftDelimiter{\lceil}
+\DeclareRightDelimiter{\rceil}
+\DeclareLeftDelimiter{\lparen}
+\DeclareRightDelimiter{\rparen}
+% \end{macrocode}
+%
+% \section{Support for Other Packages}
+%
+% Support for various other packages is found in this section. The
+% \pkg{ntheorem} package now has a dedicated section (\S
+% \vref{sec:impl:ntheorem}), as it now a module.
+%
+%
+%
+% \begin{macrocode}
+\def\EQ_typeset_tags_hook:{}
+\def\EQ_typeset_display_hook:{}
+% \end{macrocode}
+%
+% \subsection{\pkg{showkeys}}
+% \changes{v2.10}{2004/07/26}{Added support for the \pkg{showkeys}
+% package}
+% We just disable \pkg{showkeys} when typesetting the labels.
+% \begin{macrocode}
+\g@addto@macro\EQ_typeset_display_hook:{
+ \def\SK@@label#1>#2\SK@{}
+}
+% \end{macrocode}
+% If we overload the \AmS{} equation types we should still be able
+% to use \pkg{showkeys}.
+% \begin{macrocode}
+\@namedef{SK@AmSequation} {\SK@equationtrue}
+\@namedef{SK@AmSequation*} {\SK@equationtrue}
+\@namedef{SK@AmSalign} {\SK@equationtrue}
+\@namedef{SK@AmSalign*} {\SK@equationtrue}
+\@namedef{SK@AmSalignat} {\SK@equationtrue}
+\@namedef{SK@AmSalignat*} {\SK@equationtrue}
+\@namedef{SK@AmSgather} {\SK@equationtrue}
+\@namedef{SK@AmSgather*} {\SK@equationtrue}
+\@namedef{SK@AmSmultline} {\SK@equationtrue}
+\@namedef{SK@AmSmultline*} {\SK@equationtrue}
+\@namedef{SK@AmSflalign} {\SK@equationtrue}
+\@namedef{SK@AmSflalign*} {\SK@equationtrue}
+% \end{macrocode}
+%
+% \subsection{\pkg{hyperref}}
+%
+%
+% A little trick to avoid the (in)famous warning
+% \begin{verbatim}
+% ! pdfTeX warning (ext4): destination with the same identifier
+% (name{equation.1a }) has been already used, duplicate ignored
+% <to be read again>
+% \endgroup \set@typeset@protect
+% \end{verbatim}
+% This doesn't require \pkg{hyperref}.
+% \begin{macrocode}
+\AtBeginDocument{
+ \@ifundefined{Hy@linkcounter}{\newcount\Hy@linkcounter}{}
+}
+\g@addto@macro\EQ_typeset_display_hook:{
+ \MH_let:NwN \hyper@refstepcounter\@gobble
+}
+% \end{macrocode}
+%
+%
+% \subsection{Basic \pkg{ntheorem} support}
+% \begin{macrocode}
+\g@addto@macro\EQ_typeset_tags_hook:{
+ \MH_let:NwN\TagsPlusEndmarks\relax
+ \MH_let:NwN\RestoreTags\relax
+}
+\g@addto@macro\EQ_typeset_display_hook:{
+ \MH_let:NwN\TagsPlusEndmarks\relax
+ \MH_let:NwN\RestoreTags\relax
+}
+% \end{macrocode}
+% \subsection{Basic \LaTeXe{} support}
+% Gobble the \cs{ltx@label} and disable most error messages.
+% \changes{v2.00}{2004/04/14}{Make a special label-gobbling command
+% to support \pkg{ntheorem} even more}
+% \begin{macrocode}
+\g@addto@macro\EQ_typeset_display_hook:{
+ \MH_let:NwN\ltx@label\MT_gobblelabel:w
+ \MH_let:NwN \GenericError \@gobblefour
+}
+% \end{macrode}
+% \subsection{Support for \pkg{fancybox}}
+% First check if \pkg{fancybox} is loaded and then see if
+% \pkg{color} is loaded. If the latter is loaded we define
+% \texttt{shadowcolor} else we let \cs{textcolor} gobble the first
+% argument (the color).
+% \begin{macrocode}
+\AtBeginDocument{%
+ \@ifpackageloaded{fancybox}{%
+ \@ifpackageloaded{color}{\definecolor{shadowcolor}{rgb}{0,0,0}}%
+ {\newcommand*\textcolor[2]{\normalcolor{#2}}}%
+% \end{macrocode}
+% \begin{macro}{\shadowbox}
+% Then define the \cs{shadowbox}. Use a conditional to let us know if
+% it was starred or not.
+% \begin{macrocode}
+ \MH_new_boolean:n {shadowbox_star}
+ \renewcommand*\shadowbox{%
+ \@ifstar{\MH_set_boolean_T:n {shadowbox_star}
+ \VerbBox\EQ_shadowbox:n}
+ {\MH_set_boolean_F:n {shadowbox_star}
+ \VerbBox\EQ_shadowbox:n}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\EQ_shadowbox:n}
+% The internal version of \cs{shadowbox}.
+% \begin{macrocode}
+ \def\EQ_shadowbox:n #1{%
+ \sbox{\z@}{\fbox{#1}}%
+% \end{macrocode}
+% The difference between the two versions is that \cs{shadowbox}
+% aligns the bottom of the shadow at the baseline whereas
+% \cs{shadowbox*} aligns the argument on the baseline, so for the
+% starred version the trick is to raise the box by the depth of the
+% argument plus the size of the shadow.
+% \begin{macrocode}
+ \MH_if_boolean:nTF {shadowbox_star}{
+ \MH_setlength:dn \@tempdima{\z@}%
+ }{
+ \MH_setlength:dn \@tempdima{\dp\z@+\shadowsize}%
+ }
+ \raisebox{\@tempdima}{%
+ \makebox[\z@][l]{%
+ \kern\shadowsize \textcolor{shadowcolor}{%
+ \rule[-\dp\z@-\shadowsize]{\wd\z@}{\shadowsize}}%
+ }%
+ \usebox\z@\textcolor{shadowcolor}{%
+ \rule[-\dp\z@-\shadowsize]{\shadowsize}{\ht\z@+\dp\z@}}}}%
+ }{}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \section{The \opt{overload} option}
+% \begin{macro}{\EQ_overload_ams_begin:n}
+% A helper for saving snapshots:
+% \begin{macrocode}
+\def\EQ_overload_ams_begin:n #1{%
+ \MH_let:cc {AmS#1}{#1}%
+ \MH_let:cc {AmS#1*}{#1*}
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\EQ_overload_ams_end:n}
+% All but one of the aligned variations must be set to the original
+% \begin{macrocode}
+\def\EQ_overload_ams_end:n #1{%
+ \MH_let:cc {endAmS#1}{endAmSalign}
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{environment}{AmSequation}
+% \begin{environment}{AmSequation*}
+% \changes{v2.10}{2004/07/26}{Moved redefinitions to
+% \cs{AtBeginDocument} to give \pkg{hyperref} a chance}
+% Before we start redefining environments, we'll need a basic
+% \env{equation} environment that is not redefined.
+% \begin{macrocode}
+\AtBeginDocument{
+ \EQ_overload_ams_begin:n {equation}
+ \MH_let:cc {endAmSequation}{endequation}
+ \MH_let:cc {endAmSequation*}{endequation*}
+% \end{macrocode}
+% \end{environment}
+% \end{environment}
+% Lets start overloading.
+% \begin{macrocode}
+ \MH_if_boolean:nT {overload_ams}{
+% \end{macrocode}
+% \begin{macro}{\EQ_renew_ams_environment:n}
+% \changes{v2.10}{2004/07/26}{Disallow spaces before the optional
+% argument.}
+% Then we can renew the environments. Syntax is
+% \cs{begin}\marg{\AmS{} env}\oarg{markup}. Exception to this rule
+% is \env{alignat} (see further down).
+% \begin{macrocode}
+ \def\EQ_renew_ams_environment:n #1{%
+ \MaybeMHPrecedingSpacesOff
+ \renewenvironment{#1}[1][]{%
+ \setkeys{\EQ_options_name:}{##1}%
+ \setkeys{EmphEqEnv}{AmS#1}%
+ \EmphEqMainEnv
+ }{\endEmphEqMainEnv}
+ \MHPrecedingSpacesOn
+ }
+% \end{macrocode}
+% \end{macro}
+% Add equation type: \emph{Must} have same number as original type!
+% \begin{macrocode}
+ \EQ_new_equationtype:nnn {EmphEqEnv}{AmSalign} {1}
+ \EQ_new_equationtype:nnn {EmphEqEnv}{AmSalign*} {2}
+ \EQ_new_equationtype:nnn {EmphEqEnv}{AmSgather} {3}
+ \EQ_new_equationtype:nnn {EmphEqEnv}{AmSgather*} {4}
+ \EQ_new_equationtype:nnn {EmphEqEnv}{AmSflalign} {5}
+ \EQ_new_equationtype:nnn {EmphEqEnv}{AmSflalign*}{6}
+ \EQ_new_equationtype_arg:nnn {EmphEqEnv}{AmSalignat} {7}
+ \EQ_new_equationtype_arg:nnn {EmphEqEnv}{AmSalignat*}{8}
+% \end{macrocode}
+% Then overload by saving the snapshots of the old definitions. We
+% do it via \cs{AtBeginDocument}, because a package like
+% \pkg{ntheorem} redefines \cs{endgather} etc.
+%
+% First the \env{gather} and \env{equation} families.
+% \begin{macrocode}
+ \EQ_overload_ams_begin:n {gather}
+ \MH_let:cc {endAmSgather}{endgather}
+ \MH_let:cc {endAmSgather*}{endAmSgather}
+ \EQ_renew_ams_environment:n {gather}
+ \EQ_renew_ams_environment:n {gather*}
+ \EQ_overload_ams_begin:n {equation}
+ \MH_keyval_alias_with_addon:nnnn {EmphEqEnv} {AmSequation}
+ {AmSgather}{\EQ_disable_linebreak:}
+ \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{AmSequation*}
+ {AmSgather*}{\EQ_disable_linebreak:}
+ \EQ_renew_ams_environment:n {equation}
+ \EQ_renew_ams_environment:n {equation*}
+% \end{macrocode}
+% The \env{align} family.
+% \begin{macrocode}
+ \EQ_overload_ams_begin:n {align}
+ \MH_let:cc {endAmSalign}{endalign}
+ \EQ_overload_ams_end:n {align*}
+ \EQ_renew_ams_environment:n {align}
+ \EQ_renew_ams_environment:n {align*}
+% \end{macrocode}
+% The \env{flalign} family.
+% \begin{macrocode}
+ \EQ_overload_ams_begin:n {flalign}
+ \EQ_overload_ams_end:n {flalign}
+ \EQ_overload_ams_end:n {flalign*}
+ \EQ_renew_ams_environment:n {flalign}
+ \EQ_renew_ams_environment:n {flalign*}
+% \end{macrocode}
+% The \env{alignat} family.
+% \begin{macrocode}
+ \EQ_overload_ams_begin:n {alignat}
+ \EQ_overload_ams_end:n {alignat}
+ \EQ_overload_ams_end:n {alignat*}
+% \end{macrocode}
+% \begin{macro}{\EQ_alignat_optional:w}
+% \changes{v2.10}{2004/07/26}{Disallow spaces before the optional
+% argument.}
+% \begin{environment}{alignat}
+% \begin{environment}{alignat*}
+% This one is a little different because we want a syntax like
+% \cs{begin\{alignat\}}\linebreak[0]\marg{cols}\oarg{markup}, so we
+% have to make a separate command for testing the trailing optional
+% argument.
+% \begin{macrocode}
+ \MaybeMHPrecedingSpacesOff
+ \newcommand*\EQ_alignat_optional:w [1][]{
+ \setkeys{\EQ_options_name:}{#1}
+ \EmphEqMainEnv}
+ \MHPrecedingSpacesOn
+ \renewenvironment{alignat}[1]{
+ \setkeys{EmphEqEnv}{AmSalignat=#1}
+ \EQ_alignat_optional:w}
+ {\endEmphEqMainEnv}
+ \renewenvironment{alignat*}[1]{%
+ \setkeys{EmphEqEnv}{AmSalignat*=#1}%
+ \EQ_alignat_optional:w}%
+ {\endEmphEqMainEnv}
+% \end{macrocode}
+% \end{environment}
+% \end{environment}
+% \end{macro}
+% \begin{macro}{\[}
+% \begin{macro}{\]}
+% Then restore \cs{[} and \cs{]}.
+% \begin{macrocode}
+ \DeclareRobustCommand{\[}{\begin{AmSequation*}}
+ \DeclareRobustCommand{\]}{\end{AmSequation*}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% Finally a string of aliases so that we can blend \opt{overload}
+% syntax with regular syntax.
+% \begin{macrocode}
+ \MH_keyval_alias:nnn {EmphEqEnv}{gather} {AmSgather}
+ \MH_keyval_alias:nnn {EmphEqEnv}{gather*} {AmSgather*}
+ \MH_keyval_alias:nnn {EmphEqEnv}{align} {AmSalign}
+ \MH_keyval_alias:nnn {EmphEqEnv}{align*} {AmSalign*}
+ \MH_keyval_alias:nnn {EmphEqEnv}{flalign} {AmSflalign}
+ \MH_keyval_alias:nnn {EmphEqEnv}{flalign*}{AmSflalign*}
+ \MH_keyval_alias:nnn {EmphEqEnv}{alignat} {AmSalignat}
+ \MH_keyval_alias:nnn {EmphEqEnv}{alignat*}{AmSalignat*}
+ \MH_if_boolean:nT {good_mult}{
+ \EQ_overload_ams_begin:n {multline}
+ \MH_let:cc {endAmSmultline}{endmultline}
+ \MH_let:cc {endAmSmultline*}{endAmSmultline}
+ \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{AmSmultline}
+ {AmSgather}{\MH_set_boolean_T:n {outer_mult}}
+ \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{AmSmultline*}
+ {AmSgather*}{\MH_set_boolean_T:n {outer_mult}}
+ \EQ_renew_ams_environment:n {multline}
+ \EQ_renew_ams_environment:n {multline*}
+ }
+% \end{macrocode}
+% End of \opt{overload}. We go into \opt{overload2}\ldots This
+% is dangerous, but will probably work. The macro \cs{[} is now
+% fragile except if you're running \eTeX{} as engine for \LaTeX.
+% \begin{macrocode}
+ \MH_if_boolean:nT {overload_amsII}{
+ \MH_protected:\def\[#1\]{\begin{equation*} #1\end{equation*}}
+% \end{macrocode}
+% Then we add the \env{multline} family.
+% \begin{macrocode}
+ \MH_if_boolean:nF {good_mult}{
+ \EQ_overload_ams_begin:n {multline}
+ \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{AmSmultline}
+ {AmSflalign}{\MH_set_boolean_T:n {multline}}
+ \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{AmSmultline*}
+ {AmSflalign*}{\MH_set_boolean_T:n {multline}}
+ \EQ_renew_ams_environment:n {multline}
+ \EQ_renew_ams_environment:n {multline*}
+ }
+ }
+ }
+}
+% \end{macrocode}
+% End of \cs{AtBeginDocument} additions.
+% \begin{macrocode}
+%</empheq>
+% \end{macrocode}
+%
+%
+% \section{Patching Things up for \pkg{ntheorem}}
+% \label{sec:impl:ntheorem}
+%
+% Although \pkg{ntheorem} provides a lot of useful features it
+% does however ruin things in the \pkg{amsmath} environments,
+% because of the alternative syntax of its \cs{label} command.
+% \begin{macro}{\default_raisetag}
+% \begin{macro}{\raisetag}
+% \begin{macro}{\raise@tag}
+% \changes{v1.06}{2004/03/13}{Fixed \pkg{amsmath} bug \# 3624}
+% This corrects a bug\footnote{See
+% \url{http://www.latex-project.org/cgi-bin/ltxbugs2html?pr=amslatex/3624}}
+% in \pkg{amsmath} that could cause tags to cross page boundaries
+% without warning. The \cs{nobreak} is the addition.
+% \begin{macrocode}
+%<*ntheorem>
+\def\default_raisetag:{\nobreak}
+\def\raisetag#1{
+ \skip@#1\relax
+ \xdef\raise@tag{\default_raisetag:
+ \vskip\iftagsleft@\else:-\fi:\the\skip@\relax}}
+\MH_let:NwN\raise@tag\default_raisetag:
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\displ@y@}
+% Patch it so that it doesn't set \cs{raise@tag} to \cs{@empty}
+% globally.
+% \begin{macrocode}
+\def\displ@y@{\@display@init{%
+ \global\column@\z@ \global\dspbrk@lvl\m@ne
+ \global\tag@false \global\MH_let:NwN\raise@tag\default_raisetag:
+}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\MT_gobblelabel:w}
+% \changes{v2.00}{2004/04/14}{Added \cs{MT_gobblelabel:w}}
+% \begin{macro}{\EQ_gobbleoptional:w}
+% \changes{v2.00}{2004/04/14}{Added \cs{EQ_gobbleoptional:w}}
+% Macros for gobbling the `unorthodox' \cs{label} syntax of
+% \pkg{ntheorem}. Also overrides the normal \cs{label}-gobbling.
+% \begin{macrocode}
+\def\MT_gobblelabel:w #1{\@ifnextchar[{\EQ_gobbleoptional:w}{}}
+\def\EQ_gobbleoptional:w [#1]{}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \subsection{Fixing \env{gather}}
+% The measuring phase of \env{gather} is patched by letting
+% \cs{label} be a copy of the internal \cs{MT_gobblelabel:w}
+% instead of \cs{@gobble}.
+% \begin{macrocode}
+\def\gmeasure@#1{%
+ \begingroup
+ \measuring@true
+ \totwidth@\z@
+ \global\MH_let:NwN\tag@lengths\@empty
+ \savecounters@
+ \setbox\@ne\vbox{%
+ \everycr{\noalign{\global\tag@false
+% \end{macrocode}
+% The patch for \cs{raisetag}.
+% \begin{macrocode}
+ \global\MH_let:NwN\raise@tag\default_raisetag:
+ \global\column@\z@}}%
+% \end{macrocode}
+% The patch for \cs{label}.
+% \begin{macrocode}
+ \MH_let:NwN\label\MT_gobblelabel:w
+ \halign{%
+ \setboxz@h{$\m@th\displaystyle{##}$}%
+ \if_dim:w \wdz@>\totwidth@
+ \global\totwidth@\wdz@
+ \fi:
+ &\setboxz@h{\strut@{##}}%
+ \savetaglength@
+ \crcr
+ #1%
+ \math@cr@@@
+ }%
+ }%
+ \restorecounters@
+ \if@fleqn
+ \global\advance\totwidth@\@mathmargin
+ \fi:
+ \iftagsleft@
+ \if_dim:w \totwidth@>\displaywidth
+ \global\MH_let:NwN\gdisplaywidth@\totwidth@
+ \else:
+ \global\MH_let:NwN\gdisplaywidth@\displaywidth
+ \fi:
+ \fi:
+ \endgroup
+}
+% \end{macrocode}
+%
+% \subsection{Fixing \env{align}, \env{alignat}, and \env{flalign}}
+% Just copy the definition of \cs{measure@} from \pkg{amsmath} and
+% change one (1!) line like we did for \env{gather}.
+% \begin{macrocode}
+\def\measure@#1{%
+ \begingroup
+ \measuring@true
+ \global\eqnshift@\z@
+ \global\alignsep@\z@
+ \global\MH_let:NwN\tag@lengths\@empty
+ \global\MH_let:NwN\field@lengths\@empty
+ \savecounters@
+ \global\setbox0\vbox{%
+ \MH_let:NwN\math@cr@@@\math@cr@@@align@measure
+ \everycr{\noalign{\global\tag@false
+% \end{macrocode}
+% The patch for \cs{raisetag}.
+% \begin{macrocode}
+ \global\MH_let:NwN\raise@tag\default_raisetag:
+ \global\column@\z@}}%
+% \end{macrocode}
+% The patch.
+% \begin{macrocode}
+ \MH_let:NwN\label\MT_gobblelabel:w
+ \global\row@\z@
+ \tabskip\z@
+ \halign{\span\align@preamble\crcr
+ #1%
+ \math@cr@@@
+ \global\column@\z@
+ \add@amps\maxfields@\cr
+ }%
+ }%
+ \restorecounters@
+ \ifodd\maxfields@
+ \global\advance\maxfields@\@ne
+ \fi:
+ \if_num:w \xatlevel@=\tw@
+ \if_num:w \maxfields@<\thr@@
+ \MH_let:NwN\xatlevel@\z@
+ \fi:
+ \fi:
+ \setbox\z@\vbox{%
+ \unvbox\z@ \unpenalty \global\setbox\@ne\lastbox
+ }%
+ \global\totwidth@\wd\@ne
+ \if@fleqn \global\advance\totwidth@\@mathmargin \fi:
+ \global\MH_let:NwN\maxcolumn@widths\@empty
+ \begingroup
+ \MH_let:NwN\or:\relax
+ \loop
+ \global\setbox\@ne\hbox{%
+ \unhbox\@ne \unskip \global\setbox\thr@@\lastbox
+ }%
+ \ifhbox\thr@@
+ \xdef\maxcolumn@widths{ \or: \the\wd\thr@@ \maxcolumn@widths}%
+ \repeat
+ \endgroup
+ \dimen@\displaywidth
+ \advance\dimen@-\totwidth@
+ \if_case:w \xatlevel@
+ \global\alignsep@\z@
+ \MH_let:NwN\minalignsep\z@
+ \@tempcntb\z@
+ \if@fleqn
+ \@tempcnta\@ne
+ \global\eqnshift@\@mathmargin
+ \else:
+ \@tempcnta\tw@
+ \global\eqnshift@\dimen@
+ \global\divide\eqnshift@\@tempcnta
+ \fi:
+ \or:
+ \@tempcntb\maxfields@
+ \divide\@tempcntb\tw@
+ \@tempcnta\@tempcntb
+ \advance\@tempcntb\m@ne
+ \if@fleqn
+ \global\eqnshift@\@mathmargin
+ \global\alignsep@\dimen@
+ \global\divide\alignsep@\@tempcnta
+ \else:
+ \global\advance\@tempcnta\@ne
+ \global\eqnshift@\dimen@
+ \global\divide\eqnshift@\@tempcnta
+ \global\alignsep@\eqnshift@
+ \fi:
+ \or:
+ \@tempcntb\maxfields@
+ \divide\@tempcntb\tw@
+ \global\advance\@tempcntb\m@ne
+ \global\@tempcnta\@tempcntb
+ \global\eqnshift@\z@
+ \global\alignsep@\dimen@
+ \if@fleqn
+ \global\advance\alignsep@\@mathmargin\relax
+ \fi:
+ \global\divide\alignsep@\@tempcntb
+ \fi:
+ \if_dim:w \alignsep@<\minalignsep\relax
+ \global\alignsep@\minalignsep\relax
+ \if_dim:w \eqnshift@>\z@
+ \if@fleqn\else:
+ \global\eqnshift@\displaywidth
+ \global\advance\eqnshift@-\totwidth@
+ \global\advance\eqnshift@-\@tempcntb\alignsep@
+ \global\divide\eqnshift@\tw@
+ \fi:
+ \fi:
+ \fi:
+ \if_dim:w \eqnshift@<\z@
+ \global\eqnshift@\z@
+ \fi:
+ \calc@shift@align
+ \global\tagshift@\totwidth@
+ \global\advance\tagshift@\@tempcntb\alignsep@
+ \if@fleqn
+ \if_num:w \xatlevel@=\tw@
+ \global\advance\tagshift@-\@mathmargin\relax
+ \fi:
+ \else:
+ \global\advance\tagshift@\eqnshift@
+ \fi:
+ \iftagsleft@ \else:
+ \global\advance\tagshift@-\displaywidth
+ \fi:
+ \dimen@\minalignsep\relax
+ \global\advance\totwidth@\@tempcntb\dimen@
+ \if_dim:w \totwidth@>\displaywidth
+ \global\MH_let:NwN\displaywidth@\totwidth@
+ \else:
+ \global\MH_let:NwN\displaywidth@\displaywidth
+ \fi:
+ \endgroup
+}
+% \end{macrocode}
+%
+% \subsection{Fixing \env{multline}}
+% \begin{macro}{\EQ_multline_labelhack:n}
+% \begin{macro}{\EQ_multline_labelhack_opt:nw}
+% As \pkg{ntheorem} defines \cs{label} to have the syntax
+% \cs{label}\marg{label}\oarg{name}, we need to make sure that it
+% has that inside \env{multline} as well. Especially since the
+% measuring phase of \env{multline} \emph{defines} \cs{label} as
+% well.
+% \begin{macrocode}
+\def\EQ_multline_labelhack:n #1{%
+ \begingroup\measuring@false\label@in@display{#1}\endgroup}
+\def\EQ_multline_labelhack_opt:nw #1[#2]{%
+ \begingroup\measuring@false\label@in@display{#1}[#2]\endgroup}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\multline@}
+% Patching \env{multline} takes more work because it does its
+% processing differently, so we need to apply hooks twice: One in
+% the measuring phase \cs{mmeasure@} where \cs{label} is redefined
+% and one in the production phase \cs{multline@} where the ordinary
+% \cs{label} is gobbled (we use \cs{MT_gobblelabel:w} as
+% before). First the typesetting phase.
+% \begin{macrocode}
+\def\multline@#1{%
+ \Let@
+ \@display@init{\global\advance\row@\@ne \global\dspbrk@lvl\m@ne}%
+ \chardef\dspbrk@context\z@
+ \restore@math@cr
+ \MH_let:NwN\tag\tag@in@align
+% \end{macrocode}
+% The patch for \cs{raisetag}.
+% \begin{macrocode}
+ \global\tag@false \global\MH_let:NwN\raise@tag\default_raisetag:
+ \mmeasure@{#1}%
+ \MH_let:NwN\tag\gobble@tag
+% \end{macrocode}
+% The patch.
+% \begin{macrocode}
+ \MH_let:NwN\label\MT_gobblelabel:w
+ \tabskip \if@fleqn \@mathmargin \else: \z@skip \fi:
+ \totwidth@\displaywidth
+ \if@fleqn
+ \advance\totwidth@-\@mathmargin
+ \fi:
+ \halign\bgroup
+ \hbox to\totwidth@{%
+ \if@fleqn
+ \hskip \@centering \relax
+ \else:
+ \hfil
+ \fi:
+ \strut@
+ $\m@th\displaystyle{}##\endmultline@math
+ \hfil
+ }%
+ \crcr
+ \if@fleqn
+ \hskip-\@mathmargin
+ \def\multline@indent{\hskip\@mathmargin}% put it back
+ \else:
+ \hfilneg
+ \def\multline@indent{\hskip\multlinegap}%
+ \fi:
+ \iftagsleft@
+ \iftag@
+ \begingroup
+ \ifshifttag@
+ \rlap{\vbox{%
+ \normalbaselines
+ \hbox{%
+ \strut@
+ \make@display@tag
+ }%
+ \vbox to\lineht@{}%
+ \raise@tag
+ }}%
+ \multline@indent
+ \else:
+ \setbox\z@\hbox{\make@display@tag}%
+ \dimen@\@mathmargin \advance\dimen@-\wd\z@
+ \if_dim:w \dimen@<\multlinetaggap
+ \dimen@\multlinetaggap
+ \fi:
+ \box\z@ \hskip\dimen@\relax
+ \fi:
+ \endgroup
+ \else:
+ \multline@indent
+ \fi:
+ \else:
+ \multline@indent
+ \fi:
+ #1%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\mmeasure@}
+% Then redefine the label correctly.
+% \begin{macrocode}
+\def\mmeasure@#1{%
+ \begingroup
+ \measuring@true
+% \end{macrocode}
+% The patch.
+% \begin{macrocode}
+ \def\label##1{%
+ \@ifnextchar[
+ {\EQ_multline_labelhack_opt:nw {##1}}
+ {\EQ_multline_labelhack:n {##1}}
+ }
+ \def\math@cr@@@{\cr}%
+ \MH_let:NwN\shoveleft\@iden \MH_let:NwN\shoveright\@iden
+ \savecounters@
+ \global\row@\z@
+ \setbox\@ne\vbox{%
+ \global\MH_let:NwN\df@tag\@empty
+ \halign{%
+ \setboxz@h{\@lign$\m@th\displaystyle{}##$}%
+ \iftagsleft@
+ \if_num:w \row@=\@ne
+ \global\totwidth@\wdz@
+ \global\lineht@\ht\z@
+ \fi:
+ \else:
+ \global\totwidth@\wdz@
+ \global\lineht@\dp\z@
+ \fi:
+ \crcr
+ #1%
+ \crcr
+ }%
+ }%
+ \if_meaning:NN
+ \df@tag\@empty
+ \else:
+ \global\tag@true
+ \fi:
+ \if@eqnsw\global\tag@true\fi:
+ \iftag@
+ \setboxz@h{%
+ \if@eqnsw
+ \stepcounter{equation}%
+ \tagform@\theequation
+ \else:
+ \df@tag
+ \fi:
+ }%
+ \global\tagwidth@\wdz@
+ \dimen@\totwidth@
+ \advance\dimen@\tagwidth@
+ \advance\dimen@\multlinetaggap
+ \iftagsleft@\else:
+ \if@fleqn
+ \advance\dimen@\@mathmargin
+ \fi:
+ \fi:
+ \if_dim:w \dimen@>\displaywidth
+ \global\shifttag@true
+ \else:
+ \global\shifttag@false
+ \fi:
+ \fi:
+ \restorecounters@
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Setting End Marks Correctly}
+%
+% \begin{macro}{\mintagvsep}
+% \changes{v1.05}{2004/02/16}{Introduced \cs{mintagvsep} to
+% support the \pkg{ntheorem} package}
+% \begin{macro}{\EQ_only_endmark:}
+% \changes{v1.05}{2004/02/16}{Introduced \cs{EQ_only_endmark:}
+% to support the \pkg{ntheorem} package}
+% \changes{v2.11}{2004/08/03}{Make sure the tag is printed even with the
+% \pkg{mathtools} key \key{showonlyrefs} activated}
+% \begin{macro}{\EQ_tag_plus_endmark:}
+% \changes{v1.05}{2004/02/16}{Introduced
+% \cs{EQ_tag_plus_endmark:} to support the \pkg{ntheorem} package}
+% \pkg{ntheorem} provides an extension to the theorem environment
+% and also supports automatic end of theorem marks. To do so it must
+% redefine parts of the \pkg{amsmath} code and it eventually ends up
+% in problems when the tags and the marker are all typeset at the
+% right margin.
+%
+% There are basically two different possibilities:
+% \begin{center}\hfill
+% \unitlength2.5pt \thicklines
+% \begin{picture}(60,45)(0,25)
+% \put(0,50){\framebox(25,20){Math Height}}
+% \put(0,25){\framebox(25,25){Math Depth}}
+% \put(40,50){\framebox(20,10){Tag height}}
+% \put(40,45){\framebox(20,5){Tag depth}}
+% \put(40,25){\framebox(20,10){Marker}}
+% \put(50,35){\vector(0,1){10}}
+% \put(50,45){\vector(0,-1){10}}
+% \put(50,39){\ \ $\delta>0$}
+% \multiput(26,25)(2,0){7}{\line(1,0){1}}
+% \end{picture} \hfill\vrule\hfill
+% \begin{picture}(60,45)(0,25)
+% \put(0,50){\framebox(25,20){Math Height}}
+% \put(0,40){\framebox(25,10){Math Depth}}
+% \put(40,50){\framebox(20,10){Tag height}}
+% \put(40,45){\framebox(20,5){Tag depth}}
+% \put(40,28){\framebox(20,10){Marker}}
+% \put(50,38){\vector(0,1){7}}
+% \put(50,45){\vector(0,-1){7}}
+% \put(50,40){\ \ $\delta=0$}
+% \end{picture}\hfill\mbox{}
+% \end{center}
+% Let's look closer at this. $h_M$ is the height of the end of
+% theorem marker, which we'll try to place so that its baseline
+% aligns with the bottom of the math display. $d_D$ is the depth of
+% the the last line of the math display including the depth of the
+% surrounding boxes while $d_T$ is the depth of the tag. Also we let
+% $m$ denote the minimum vertical distance between tag and marker
+% and $\delta$ is some positive length that may be added to $m$
+% depending on the other values. To ensure a ``proper'' placement of
+% the marker we simply test the inequality
+% \begin{gather}
+% h_M + d_T + m > d_D \label{eq:tag_placement}
+% \end{gather}
+% If the test is true we're done and just have to set the marker so
+% that the top of it is placed at a distance of $m$ from the bottom
+% of the tag. If it's not we can safely put the marker at the bottom
+% of the display.
+% \begin{macrocode}
+\newlength\mintagvsep
+\mintagvsep5pt
+\def\EQ_only_endmark:{%
+ \MH_set_boolean_T:n {show_manual_tags}
+ \global\tag@true
+ \iftagsleft@
+ \gdef\df@tag{%
+ \hbox to \displaywidth{%
+ \hss
+% \end{macrocode}
+% If the tags are set to the left we just have to lower the end mark
+% by the total depth of the display including its surrounding box.
+% Also we have to take care of \cs{normallineskip}.
+% \begin{macrocode}
+ \raisebox{-\normallineskip
+ -\depthof{\EQ_outerbox:{}}
+ -\heightof{\EQ_outerbox:{}}
+ -\dp\EQ_mathdisplay_box
+ -\ht\EQ_mathdisplay_box}
+ [0pt][0pt]{\PotEndMark{\maketag@@@}}}}
+ \else:
+ \gdef\df@tag{%
+ \raisebox{-\dp\EQ_mathdisplay_box
+ -\depthof{\EQ_outerbox:{}}}
+ {\PotEndMark{\maketag@@@}}}%
+ \fi:}
+% \end{macrocode}
+% \changes{v2.00}{2004/04/14}{Fixed another bug in placement of the
+% marker}
+% \changes{v2.10}{2004/07/26}{Fixed horizontal spacing in \env{equation}}
+% In v2.00 I fixed another bug I had overlooked. This is getting
+% embarrassing. The outer box must be taken into account as well.
+% \begin{macrocode}
+\def\EQ_tag_plus_endmark:{%
+ \iftagsleft@
+ \gdef\maketag@@@##1{%
+% \end{macrocode}
+% The following fixes a bug when there is a wide tag in an
+% \env{equation} environment and was reported by Bernard
+% Alfonsi.\footnote{\email{alfonsi@math.u-psud.fr}} The problem
+% arises when \pkg{ntheorem} tries to typeset a tag and an end mark,
+% because the tag is set at the left margin and the end mark at the
+% right margin and \pkg{ntheorem} over-simplifies this and forgets
+% to take the displayed math into account! The right solution is to
+% wrap the tag in a box of the correct size, namely |\widthof{##1}|
+% and then push the end mark to the right margin. Then the displayed
+% math is set correcly.
+% \begin{macrocode}
+ \hfuzz\displaywidth
+ \makebox[\widthof{##1}][l]{%
+ \hbox to \displaywidth{\m@th\normalfont##1\hss
+ \raisebox{-\dp\EQ_mathdisplay_box
+ -\depthof{\EQ_outerbox:{}}}
+ {\PotEndMark{\hss}}}}}%
+ \else:
+ \gdef\maketag@@@##1{%
+ \hbox{\m@th\normalfont##1\llap{\hss\PotEndMark{%
+ \settoheight{\@tempdima}{\@nameuse{\InTheoType Symbol}}%
+ \MH_addtolength:dn \@tempdima
+ {\g_EQ_bottomtag_depth_dim+\mintagvsep}
+ \setlength{\@tempdimb}
+ {\g_EQ_bottomrow_depth_dim+\depthof{\EQ_outerbox:{}}
+ +\depthof{\EQ_innerbox:{}}}
+ \if_dim:w \@tempdima>\@tempdimb
+ \MH_setlength:dn \@tempdima{-\dp\EQ_mathdisplay_box
+ -\@tempdima+\g_EQ_bottomrow_depth_dim}
+ \addtolength{\@tempdima}{\depthof{\EQ_innerbox:{}}}%
+ \def\EQ_next:{\raisebox{\@tempdima}}%
+ \else:
+% \end{macrocode}
+% \changes{v1.06}{2004/03/13}{Fixed bug in placement of the marker
+% and re-arranged some code}
+% In v1.06 I fixed a stupid bug regarding placement of the marker.
+% If I had done a proper test I would have discovered it
+% immediately!
+% \begin{macrocode}
+ \def\EQ_next:{
+ \raisebox{-\dp\EQ_mathdisplay_box
+ -\depthof{\EQ_outerbox:{}}}}%
+ \fi:\EQ_next:}}}}%
+ \fi:}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\MT_nonumber:}
+% \begin{macrocode}
+\MH_let:NwN \MT_nonumber: \nonumber
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\nonumber}
+% Redefine \cs{nonumber} to reset depth of bottom tag.
+% \begin{macrocode}
+\def\g_EQ_latest_nonzerodepth_row_fint{\z@}
+\renewcommand*\nonumber{
+ \@tempcnta=\row@
+ \if_num:w \l_EQ_equationtype_int=\thr@@
+ \advance\@tempcnta\m@ne
+ \else:
+ \if_num:w \l_EQ_equationtype_int=4\relax
+ \advance\@tempcnta\m@ne
+ \fi:
+ \fi:
+ \if_num:w \g_EQ_latest_nonzerodepth_row_fint=\@tempcnta
+ \else:
+ \global\g_EQ_bottomtag_depth_dim=-\baselineskip
+ \fi:
+ \MT_nonumber:
+}
+% \end{macrocode}
+% \end{macro}
+%
+% End of \pkg{ntheorem} patches.
+% \begin{macrocode}
+%</ntheorem>
+% \end{macrocode}
+% \Finale
+\endinput
diff --git a/Master/texmf-dist/source/latex/mh/empheq.ins b/Master/texmf-dist/source/latex/mh/empheq.ins
new file mode 100644
index 00000000000..c0d42567628
--- /dev/null
+++ b/Master/texmf-dist/source/latex/mh/empheq.ins
@@ -0,0 +1,56 @@
+%%
+%% This file will generate fast loadable files and documentation
+%% driver files from the doc files in this package when run through
+%% LaTeX or TeX.
+%%
+%% File `empheq.ins'.
+%% Copyright 2002--2004 Morten H\o gholm.
+%% moho01ab@student.cbs.dk
+%%
+%% It 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.
+%% 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 2003/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "maintained".
+%%
+%% The Current Maintainer of this work is Morten H\o gholm.
+%%
+%% This work consists of the files empheq.dtx and empheq.ins and the
+%% derived files empheq.sty and ntheorem.fix.
+%%
+%% --------------- start of docstrip commands ------------------
+%%
+\input docstrip
+
+\keepsilent
+
+\preamble
+
+It 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.
+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 2003/12/01 or later.
+
+This work has the LPPL maintenance status "maintained".
+
+The Current Maintainer of this work is Morten H\string\o gholm.
+
+This work consists of the files empheq.dtx and empheq.ins and the
+derived files empheq.sty and ntheorem.fix
+
+\endpreamble
+
+%%%%%%%%%%%%%%%
+\generate{%
+ \file{empheq.sty}{\from{empheq.dtx}{empheq}}%
+ \file{ntheorem.fix}{\from{empheq.dtx}{ntheorem}}%
+}
+
+\endbatchfile
diff --git a/Master/texmf-dist/source/latex/mh/empheq07.dtx b/Master/texmf-dist/source/latex/mh/empheq07.dtx
new file mode 100644
index 00000000000..09bb2c6f3c0
--- /dev/null
+++ b/Master/texmf-dist/source/latex/mh/empheq07.dtx
@@ -0,0 +1,1402 @@
+%\iffalse meta-comment
+% File `empheq07.dtx'.
+% Copyright 2002-2004 Morten H\o gholm.
+% moho01ab@student.cbs.dk
+%
+% It 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.
+% 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 2003/12/01 or later.
+%
+% This work has the LPPL maintenance status "maintained".
+%
+% The Current Maintainer of this work is Morten H\o gholm.
+%
+% This work consists of the files empheq07.dtx and empheq07.ins
+% and the derived file empheq07.sty.
+%
+%<*dtx>
+ \ProvidesFile{empheq07.dtx}
+%</dtx>
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{empheq07}
+ [2004/07/27 v0.7d Emphasizing equations (MH)]
+%<*driver>
+\documentclass[a4paper]{ltxdoc}
+\usepackage{empheq07}
+\usepackage{color,fancybox,ifpdf}
+\ifpdf\else
+ \usepackage{pstricks}
+\fi
+\definecolor{lightblue}{rgb}{.8, .8, 1}
+\OnlyDescription
+\begin{document}
+\DocInput{empheq07.dtx}
+\end{document}
+%</driver>
+% \fi
+% \DeclareRobustCommand{\mode}[1]{\texttt{#1}}
+% \DeclareRobustCommand{\env}[1]{\textsf{#1}}
+% \DeclareRobustCommand{\pkg}[1]{\texttt{#1}}
+% \DeclareRobustCommand{\EQ}{\pkg{empheq07}}
+%
+% \changes{v0.7d}{2004/07/27}{Changed name to \pkg{empheq07} by request
+% of Robin Fairbairns}
+%
+% \changes{v0.7c}{2004/04/01}{Separated \pkg{empheq} and
+% \pkg{empheq-obsolete}}
+%
+% \changes{v0.7b}{2004/03/13}{Upgraded license to LPPL version 1.3.
+% The package is still obsolete}
+%
+% \changes{v0.7a}{2004/02/15}{This package is now obsolete and has
+% changed its name to \pkg{empheq-obsolete}}
+%
+% \changes{v0.6a}{2003/01/28}{Minor updates to documentation.}
+%
+% \changes{v0.5}{2002/12/30}{First experimental and very limited release}
+% \newif\ifBonusExample
+% \ifpdf\else
+% \BonusExampletrue
+% \fi
+% \GetFileInfo{empheq07.dtx}
+% \CheckSum{1273}
+% \title{The \EQ\ package\thanks{This file
+% has version number \fileversion, last
+% revised \filedate.}\\Emphasizing equations in \LaTeXe
+% \thanks{Thanks to Lars Madsen for asking for the subtle feature
+% that evolved into this package.}}
+% \author{Morten H\o gholm}
+% \date{\filedate}
+%
+% \maketitle
+%
+%
+% \begin{abstract}
+% \noindent The \EQ\ package automatically detects several \pkg{amsmath}
+% environments and the size of the displayed math material. The user
+% interface makes it easy to add various kinds of visual markup to
+% these equations.
+% \end{abstract}
+% \tableofcontents
+% \section{Important Notice}
+%
+% This package (\EQ\ \fileversion) is no longer supported. See the
+% documentation of \pkg{empheq} for more details.
+%
+%
+% \section{Introduction}
+% Users who have wanted to put a system of equations inside boxes has
+% hitherto been forced to use the features of \pkg{fancybox} or the \cmd{\boxed} command
+% of \pkg{amsmath}. Both alternatives have serious limitations though.
+% \pkg{fancybox} allows only \env{eqnarray}-style equations and at
+% the end of the day they aren't all that pretty. Most mathematical
+% typesetting in \LaTeX\ is done with the aid of \pkg{amsmath}
+% anyway, but it only offers the single line quick-fix \cmd{\boxed}.
+% What we really want is something that will enable us to do
+% something along the likes of this:
+% \begin{subequations}\label{eq:1}
+% \begin{empheq}[boxtype=\fbox,Left= {\tilde{S}=1 \Rightarrow\empheqlbrace}]
+% \begin{align}
+% a&=\int_{-2}^3{t}b^t \, dt \quad\text{and} \label{eq:1a}\\
+% c&=d-a \label{eq:1b}
+% \end{align}
+% \end{empheq}
+% \end{subequations}
+% As you can see, \EQ\ can do all the tricks the \pkg{cases} package
+% by Donald Arseneau can do and more. It even supports
+% \env{subequations}---as shown in equations \eqref{eq:1a} and
+% \eqref{eq:1b}---from \pkg{amsmath} without complaining.
+%
+% In order to combine the best of two worlds the \EQ\ package
+% tries to take advantage of the widespread features of \pkg{amsmath}.
+% As it should be well known if you read this, \pkg{amsmath} has
+% amongst its arsenal of structures \env{align}, \env{gather}, \env{alignat} and \env{multline}.
+% \EQ\ works with these as well as their starred
+% variants.
+%
+% ``But what about \env{equation}?'' you say. \env{equation} is (in
+% my opinion) merely a poor man's \env{gather}. If you really want
+% to use \EQ's features on a one-liner (no pun intended) go with
+% \env{gather}. Anyway the real goal of this package is to do nifty
+% tricks with multi line equations \ldots
+%
+%
+% \section{Examples}
+% \changes{v0.7}{2003/05/11}{Added further examples and changed existing ones}
+% Any options given to \EQ\ is passed on to \pkg{amsmath}, thus the
+% line\par
+% \cmd{\usepackage}\oarg{options}|{empheq07}|\\
+% will load \pkg{amsmath} with exactly those options. \EQ\ doesn't
+% redefine anything so to use it in an existing document you need
+% only replace \pkg{amsmath} with \EQ---no harm done.
+%
+%
+% \EQ\ is \emph{really} easy to use; you simply put an \env{empheq}
+% environment around your \pkg{amsmath} environment:
+% \begin{verbatim}
+% \begin{empheq}
+% \begin{align}
+% E&=mc^2 \\
+% Y&= \sum_{n=1}^\infty \frac{1}{n^2}
+% \end{align}
+% \end{empheq}
+% \end{verbatim}
+% \begin{empheq}
+% \begin{align}
+% E&=mc^2 \\
+% Y&= \sum_{n=1}^\infty \frac{1}{n^2}
+% \end{align}
+% \end{empheq}
+% Impressed? No? Well then I guess it's about time I told you about
+% the \emph{optional} argument of the \env{empheq} environment. It allows
+% you control what material to put on either side of the math and
+% the sort of box to go around it all. That means that we can say
+% \begin{verbatim}
+% \begin{empheq}[boxtype=\fbox]
+% \begin{align}
+% E&=mc^2 \\
+% Y&= \sum_{n=1}^\infty \frac{1}{n^2}
+% \end{align}
+% \end{empheq}
+% \end{verbatim}
+% to obtain the display
+% \begin{empheq}[boxtype=\fbox]
+% \begin{align}
+% E&=mc^2 \\
+% Y&= \sum_{n=1}^\infty \frac{1}{n^2}
+% \end{align}
+% \end{empheq}
+% This requires the use of the \pkg{keyval} package from the tools
+% bundle, which is undoubtedly installed on your system. When using
+% the \pkg{keyval} package there are a few things we need to keep in
+% mind. In mathematical typesetting `|=|' and `|,|' are quite
+% frequently used, thus requiring the user to enclose them in
+% braces:
+% \begin{verbatim}
+% \begin{empheq}[boxtype=\fbox,
+% Left={(a,b)=(c,i) \Rightarrow\empheqlbrace}]
+% \begin{alignat}{2}
+% (a,b)&= (\cos^a c, \tan^b i)&& \quad\text{for $i>1$}\\
+% (a,b)&= (\arccos x^a, \arctan i^b)&& \quad\text{for $i\leq1$}
+% \end{alignat}
+% \end{empheq}
+% \end{verbatim}
+% \begin{empheq}[boxtype=\fbox,
+% Left={(a,b)=(c,i) \Rightarrow\empheqlbrace}]
+% \begin{alignat}{2}
+% (a,b)&= (\cos^a c, \tan^b i)&& \quad\text{for $i>1$}\\
+% (a,b)&= (\arccos c^a, \arctan i^b)&& \quad\text{for $i\leq1$}
+% \end{alignat}
+% \end{empheq}
+% The same with \env{cases} from \pkg{amsmath} for comparison:
+% \[
+% \boxed{(a,b)=(c,i) \Rightarrow
+% \begin{cases} (a,b)= (\cos^a c, \tan^b i)& \text{for $i>1$}\\
+% (a,b)= (\arccos x^a, \arctan i^b)& \text{for $i\leq1$}
+% \end{cases}}
+% \]
+% Notice that \env{cases} uses an array for the conditions, so you
+% have to force \cmd{\displaystyle} yourself. This is not needed with
+% \EQ\ as you're already using a \cmd{\displaystyle} environment such as
+% \env{gather} etc.
+%
+% \changes{v0.6b}{2003/03/04}{Added example for changing margins inside the boxtype.}
+% Observe what can be done if we replace
+% |\fbox| with another framed box and add some space on all sides:
+% \begin{verbatim}
+% \definecolor{lightblue}{rgb}{.8, .8, 1}
+% \begin{empheq}[boxtype={\setlength{\fboxsep}{10pt}%
+% \colorbox{lightblue}},
+% Right={\empheqrbrace \beta}]
+% .
+% .
+% .
+% \end{empheq}
+% \end{verbatim}
+% \begin{empheq}[boxtype={\setlength{\fboxsep}{10pt}%
+% \colorbox{lightblue}},Right={\empheqrbrace \beta}]
+% \begin{align}
+% a&=\int_{-2}^3{t}b^t \, dt \quad\text{and}\\
+% c&=d-a
+% \end{align}
+% \end{empheq}
+%
+% As a convenience for the user, it is also possible to declare
+% delimiters with the commands
+% \cmd{\DeclareRightDelimiter}\marg{delimiter} and its companion
+% \cmd{\DeclareLeftDelimiter}\marg{delimiter}. For instance the commands
+% \begin{quote}
+% |\DeclareRightDelimiter{\rangle}| defines \cmd{\empheqrangle}
+% \end{quote}
+% and
+% \begin{quote}
+% |\DeclareLeftDelimiter{\langle}| defines \cmd{\empheqlangle}.
+% \end{quote}
+% The usage is simple. \DeclareRightDelimiter{\rangle} \DeclareLeftDelimiter{\langle}
+% \begin{verbatim}
+% \begin{empheq}[Right=\empheqrangle,
+% Left=\empheqlangle]
+% \begin{gather}
+% a=b \\
+% c=d
+% \end{gather}
+% \end{empheq}
+% \end{verbatim}
+% \begin{empheq}[Right=\empheqrangle,Left=\empheqlangle]
+% \begin{gather}
+% a=b \\
+% c=d
+% \end{gather}
+% \end{empheq}
+% \cmd{\DeclareRightDelimiter} and its companion have an optional
+% argument which controls spacing (default is a negative thinspace),
+% but beware: It will simply overwrite the original definition and
+% it might not look all that pretty as the following example shows:
+% \DeclareRightDelimiter[\>]{\rangle}
+% \DeclareLeftDelimiter[\mkern-10mu]{\langle}
+% \begin{verbatim}
+% \DeclareRightDelimiter[\>]{\rangle}
+% \DeclareLeftDelimiter[\mkern-10mu]{\langle}
+% \end{verbatim}
+% \begin{empheq}[Right=\empheqrangle,Left=\empheqlangle]
+% \begin{gather}
+% a=b \\
+% c=d
+% \end{gather}
+% \end{empheq}
+%
+% These examples will have given you a glimpse of the possibilities
+% \EQ\ offers. In particular the commands \cmd{\empheqlbrace} and
+% \cmd{\empheqrbrace} produce braces just tall enough to encompass
+% the display. You can of course use \cmd{\big...} delimiters if you
+% want.
+%
+% \ifBonusExample
+% If you want you can even create your own box and use it with
+% \env{empheq}. In the following silly example I have created
+% \cmd{\ErrorBox} with \pkg{PSTricks} to achieve a disturbing
+% effect:
+% \makeatletter
+% \newcommand{\ErrorBox}[1]{%
+% \setlength{\@tempdima}{\heightof{#1}}%
+% \addtolength{\@tempdima}{\depthof{#1}}%
+% \setlength{\@tempdimb}{\widthof{#1}}%
+% \psset{yunit=\@tempdima}%
+% \psset{xunit=\@tempdimb}%
+% \psframebox[fillstyle=vlines,linestyle=none,hatchsep=.2\@tempdimb,hatchcolor=red,hatchangle=-60]{%
+% \rlap{\kern.5\@tempdimb\makebox[0pt]{{\Large\color{gray} \textbf{Error!}}}}#1}%
+% }
+% \makeatother
+% \begin{empheq}[boxtype=\ErrorBox]
+% \begin{align*}
+% E&=mc^3 \\
+% F&=G\frac{m+M}{r^2}
+% \end{align*}
+% \end{empheq}
+% Remember one thing when creating your own box: Make it
+% symmetrical.
+% \fi
+%
+% \section{Bugs and shortcomings}
+% This package (\EQ) is not supported anymore. Try with the new
+% version and see if it works; if not, then contact me. See how in
+% the manual of \pkg{empheq}.
+%
+% \StopEventually{}
+% \section{Implementation}
+% \subsection{Strategy}
+%
+% Whenever \pkg{amsmath} is typesetting a display environment it
+% actually does it twice; the first for the ``measuring'' phase and
+% the second for the ``production'' phase. The \EQ\ package uses a
+% similar approach:
+% \begin{itemize}
+% \item Collects the input in a token register for later use.
+% \item Typesets the input in the background and checks certain values to determine the kind of math structure you just typed.
+% \item Based on the given information, alterations are made to various lengths.
+% \item Then the equations are typeset again and stored in a box
+% for easy retrieval.
+% \item Finally the saved box is put into a box of the user's liking.
+% Any material to the right or left of the math structure (added with
+% the |Left| and |Right| keys) are put into the box as well.
+% \end{itemize}
+% Assuming we have found out which \pkg{amsmath} structure the
+% user typed, there are still a few things we need to sort out
+% before we proceed.
+%
+% First of all the equation number should still be aligned with
+% those of the ordinary math structures, which is a problem as soon
+% as the additions we make to the left and the right
+% differ---presumably they will. And when we are in \mode{fleqn}
+% mode, we should make sure that the structure is shifted just
+% enough to the right so that all equations still are right
+% adjusted. Therefore we need to make clever changes to the
+% line width to make sure the margins come out right.
+%
+% Then assuming we have overcome all of this there's still the final
+% step: Placing the math structure in the appropriate box at the
+% appropriate position. Once again we need to do some manipulation
+% with spacing to make it just right.
+%
+% \subsection{Preliminary actions}
+%
+% To avoid clashes with other packages, all private commands will contain the sequence \verb|@emphEQ@|.
+%
+% We will need \pkg{amsmath} of course and it would be nice if \EQ\
+% would recognize all the \pkg{amsmath} options so we make that
+% happen. To make sure the user has an updated system the newest
+% release of \pkg{amsmath} is required.
+%
+% \pkg{calc} is used to increase readability of the code
+% (thus making it \emph{far} easier to write too) and \pkg{keyval}
+% is used for user friendliness. They should all be part of any
+% \LaTeX\ system.
+% \begin{macrocode}
+%<*package>
+\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{amsmath}}
+\ProcessOptions\relax
+\RequirePackage{amsmath}[2000/07/18]
+\RequirePackage{calc,keyval}
+% \end{macrocode}
+% \begin{macro}{\if@emphEQ@FLL}\begin{macro}{\if@emphEQ@FLR}\begin{macro}{\if@emphEQ@L}\begin{macro}{\if@emphEQ@R}
+% There are four available layouts for mathematical displays:
+% |[fleqn,leqno]| (FLL), |[fleqn,reqno]| (FLR), |[leqno]| (L) and |[reqno]| (R). We create four \TeX\ conditionals
+% to make the algorithm easier to read as well as to speed up things a bit.
+% \begin{macrocode}
+\newif\if@emphEQ@FLL
+\newif\if@emphEQ@FLR
+\newif\if@emphEQ@L
+\newif\if@emphEQ@R
+% \end{macrocode}
+%\end{macro}\end{macro}\end{macro}\end{macro}
+% We then perform a simple test to determine the current mode.
+% \begin{macrocode}
+\if@fleqn
+ \iftagsleft@
+ \@emphEQ@FLLtrue
+ \else
+ \@emphEQ@FLRtrue
+ \fi
+\else
+ \iftagsleft@
+ \@emphEQ@Ltrue
+ \else
+ \@emphEQ@Rtrue
+ \fi
+\fi
+% \end{macrocode}
+% \begin{macro}{\if@emphEQ@gather}\begin{macro}{\if@emphEQ@align}\begin{macro}{\if@emphEQ@alignat}
+% \begin{macro}{\if@emphEQ@multline}\begin{macro}{\if@emphEQ@NoNumEq}
+% Since we're going to determinate which math structure the user has
+% input, we create some more conditionals to improve speed and
+% readability. Furthermore it will show crucial to know whether or
+% not the equation counter has been stepped since \env{multline$*$}
+% and \env{multline} don't have exactly the same structure.
+% \begin{macrocode}
+\newif\if@emphEQ@gather
+\newif\if@emphEQ@align
+\newif\if@emphEQ@alignat
+\newif\if@emphEQ@multline
+\newif\if@emphEQ@NoNumEq
+% \end{macrocode}
+% \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}
+%
+%
+%
+% \begin{macro}{\@emphEQ@Box}\begin{macro}{\@emphEQ@BoxWidth}
+% \begin{macro}{\@emphEQ@displaywidth}\begin{macro}{\@emphEQ@mathbody}
+% We need a single box to hold the math structure, a length so we
+% can remember the size of the displayed math for later use and a
+% token register for the math environment.
+% \begin{macrocode}
+\newsavebox{\@emphEQ@Box}
+\newlength{\@emphEQ@BoxWidth}
+\newlength{\@emphEQ@displaywidth}
+\newtoks\@emphEQ@mathbody
+% \end{macrocode}
+% \end{macro}\end{macro}\end{macro}\end{macro}
+% \begin{macro}{\@emphEQ@Left}\begin{macro}{\@emphEQ@Right}\begin{macro}{\@emphEQ@lwd}\begin{macro}{\@emphEQ@rwd}
+% Here are some vital parts: The additional informations the user
+% want to display on either side of the math structure are saved by
+% \cmd{\@emphEQ@Left} and \cmd{\@emphEQ@Right} and \cmd{\@emphEQ@lwd} and \cmd{\@emphEQ@rwd}
+% measure the width of them for later use.
+% \begin{macrocode}
+\newcommand{\@emphEQ@Left}{}
+\newcommand{\@emphEQ@Right}{}
+\newlength{\@emphEQ@lwd}
+\newlength{\@emphEQ@rwd}
+% \end{macrocode}
+% \end{macro}\end{macro}\end{macro}\end{macro}
+% \begin{macro}{\@emphEQ@boxtype}\begin{macro}{\@emphEQ@boxtypelength}
+% \begin{macro}{\@emphEQ@shadowbox}\begin{macro}{\if@emphEQ@shadowbox}
+% To make sure spacing is right when putting the math structure into
+% a box, we need to know what kind of box it is: The width is
+% extremely important. Often we will have to subtract or add half of
+% an empty (but \emph{not} zero-width) box' width to certain
+% lengths. When using an \cmd{\fbox} or \cmd{\colorbox} this is just
+% \cmd{\fboxrule}+\cmd{\fboxsep}, but when using say,
+% \cmd{\doublebox} of \pkg{fancybox} fame the necessity arises.
+% \pkg{fancybox} also defines \cmd{\shadowbox} which needs extra
+% taking care of, since it's asymmetrical unlike most other framed
+% boxes.
+%
+% Thus we test whether or not \pkg{fancybox} has been loaded at the
+% beginning of the document. If it has, we don't lift a finger; if
+% it hasn't, we let \cmd{\fbox} be an alias for \cmd{\shadowbox}.
+% Then we create a private version of \cmd{\shadowbox} for
+% testing purposes and a conditional for the algorithm.
+% \begin{macrocode}
+\newcommand{\@emphEQ@boxtype}{}
+\newlength{\@emphEQ@boxtypelength}
+\AtBeginDocument{%
+ \@ifpackageloaded{fancybox}{}{%
+ \let\shadowbox=\fbox}}
+\newcommand{\@emphEQ@shadowbox}{\shadowbox}
+\newif\if@emphEQ@shadowbox
+% \end{macrocode}
+% \end{macro}\end{macro}\end{macro}\end{macro}
+% \begin{macro}{\@emphEQ@templength}\begin{macro}{@emphEQ@EqCtr}
+% We are almost ready to go. We only need two temporary little
+% helpers: one length and one counter.
+% \begin{macrocode}
+\newlength{\@emphEQ@templength}
+\newcounter{@emphEQ@EqCtr}
+% \end{macrocode}
+% \end{macro}\end{macro}
+%
+% \subsubsection{Faraway, so close}\label{sec:CloseEnough}
+% \begin{macro}{\@emphEQ@CloseEnough}
+% \changes{v0.6}{2003/01/10}{Added a test for lengths being almost identical}
+% When determining the display type we will occasionally have to check if an equation of the
+% form
+% \[
+% \cmd{\totwidth@}-\cmd{\tagshift@}=\cmd{\linewidth}
+% \]
+% is true. However small rounding errors \emph{can} occur in
+% \env{alignat} so we would rather see if the equation
+% \[
+% -\delta<\cmd{\totwidth@}-\cmd{\tagshift@}-\cmd{\linewidth}<\delta
+% \]
+% holds for some sufficiently small $\delta>\text{$0$ pt}$. I have used $\delta=\text{$5$ sp}$.
+% \begin{macrocode}
+\newcommand{\@emphEQ@CloseEnough}[4]{%
+ \setlength{\@tempdima}{#1-#2}%
+ \ifdim\@tempdima>-5sp
+ \ifdim\@tempdima<5sp
+ #3
+ \else
+ #4
+ \fi
+ \else
+ #4
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Saving the input}
+% \begin{macro}{\@emphEQ@MainEnv}
+% \changes{v0.7}{2003/05/11}{Added use of token register to remove the
+% need for an extra \cmd{\write} and \pkg{verbatim}}
+% \begin{macro}{\end@emphEQ@MainEnv}
+% \begin{macro}{\@emphEQ@get@body}\begin{macro}{\@emphEQ@findend}
+% \begin{macro}{\@emphEQ@EnvName}
+% We start out by saving the input in the token register
+% \cmd{\@emphEQ@mathbody}. The method is heavily inspired by
+% \pkg{tabularx} \dots\@ No need to copy the words of David Carlisle here---his code will do!
+% \begin{macrocode}
+\def\@emphEQ@MainEnv{%
+ \edef\@emphEQ@EnvName{\@currenvir}%
+ {\ifnum0=`}\fi
+ \@emphEQ@mathbody{}\@emphEQ@get@body
+}
+\let\end@emphEQ@MainEnv\relax
+\long\def\@emphEQ@get@body#1\end{%
+ \@emphEQ@mathbody\expandafter{\the\@emphEQ@mathbody #1}%
+ \@emphEQ@findend
+}
+\def\@emphEQ@findend#1{%
+ \def\@tempa{#1}%
+ \ifx\@tempa\@emphEQ@EnvName
+ \expandafter\@emphEQ@PostProcess
+ \else
+ \@emphEQ@mathbody\expandafter{\the\@emphEQ@mathbody\end{#1}}%
+ \expandafter\@emphEQ@get@body
+ \fi
+}
+\def\@emphEQ@EnvName{@emphEQ@MainEnv}
+% \end{macrocode}
+% \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}
+% \begin{macro}{@emphEQ@PostProcess}
+% Now we can go on with the post processing, which is the real
+% workhorse in this package. The first job is to test if we're
+% using a \cmd{\shadowbox} and then we set some \pkg{amsmath}
+% dimensions to zero---\pkg{amsmath} doesn't do this by itself, and
+% for that we can be thankful. Otherwise you wouldn't be reading
+% this now~;-)
+% \begin{macrocode}
+\newcommand*{\@emphEQ@PostProcess}{%
+ \ifx\@emphEQ@boxtype\@emphEQ@shadowbox
+ \@emphEQ@shadowboxtrue
+ \else
+ \@emphEQ@shadowboxfalse
+ \fi
+ \tagshift@=0pt \tagwidth@=0pt \totwidth@=0pt
+ \eqnshift@=0pt \alignsep@=0pt
+% \end{macrocode}
+% \subsection{The first pass}
+% We then run the first pass to find out which environment we've
+% got. However we have to store the equation counter because it is
+% stepped in this pass, and we certainly don't want that to happen.
+% As a side effect this will also tell us if the equations are
+% numbered.
+%
+% If we are to put a brace to the left of the display, it would be
+% rather pleasant to know just how high the structure is, since this
+% will affect the height and more importantly the width the brace:
+% we will need to know the \emph{exact} width of such material.
+% Hence we put it in a box which is easy to measure and fiddle
+% around with. To achieve this we put the contents of the token register
+% \cmd{\@emphEQ@mathbody} in a \env{minipage} inside a \env{lrbox}. Alas,
+% \env{lrbox} won't let us escape into display math mode, so we play
+% a dirty trick on it and use a \env{minipage}, which will let us
+% have our way with it.
+%
+% The \env{minipage} starts in horizontal mode and then goes
+% straight to display math mode, thus adding some space before the
+% display math. However there was nothing on the first line in the
+% \env{minipage} thus leading \TeX\ to add a \cmd{\abovedisplayskip}
+% before the display. We subtract this as fast as we can!
+% Furthermore it showed in test runs, that an additional~1~pt had to
+% be subtracted in the top---but not in the bottom. It has nothing
+% to do with any of the standard page dimensions or parameters.
+% Strange indeed.
+% \begin{macrocode}
+ \setcounter{@emphEQ@EqCtr}{\value{equation}}%
+ \begin{lrbox}{\@emphEQ@Box}%
+ \begin{minipage}{\linewidth}%
+ \vskip-\abovedisplayskip\relax\vskip-1pt\relax
+ \the\@emphEQ@mathbody
+ \end{minipage}%
+ \end{lrbox}%
+% \end{macrocode}
+% We then look at the equation counter to see if we had any numbered
+% equations and reset it if that was the case. If we used a
+% \env{multline$*$} we can detect this by measuring |\tagwidth@|.
+% \begin{macrocode}
+ \ifnum\value{equation}=\value{@emphEQ@EqCtr}%
+ \ifdim\tagwidth@>0pt
+ \else
+ \@emphEQ@NoNumEqtrue
+ \fi
+ \else
+ \setcounter{equation}{\value{@emphEQ@EqCtr}}%
+ \fi
+% \end{macrocode}
+% Now we can determine the various math environments. Firstly we
+% measure an empty \cmd{\@emphEQ@boxtype}---we will need this
+% information when the math structure is finally put into a box of
+% this type, but we have to take it into account when calculating
+% the allowable width of \env{multline} displays because we want to
+% use the margins already set for this environment.
+% \begin{macrocode}
+ \settowidth{\@emphEQ@boxtypelength}{\@emphEQ@boxtype{}}%
+% \end{macrocode}
+% The idea is that each of the \pkg{amsmath} multiple line
+% environments can be singled out because it uses a certain
+% dimension in a way none of the others use it.
+% \begin{list}{}{}
+% \item[\env{align}:] Uses \cmd{\alignsep@} and sets it to something
+% positive. None of the others use it.
+% \item[\env{multline}:] Doesn't use \cmd{\eqnshift@}.
+% \item[\env{gather}:] Doesn't use \cmd{\tagshift@}.
+% \item[\env{alignat}:] Can be determined because some dimensions
+% will have special relations e.g., when in |[fleqn,reqno]| mode
+% the equation
+% \[
+% \cmd{\totwidth@}-\cmd{\tagshift@}=\cmd{\linewidth}
+% \]
+% holds\footnote{Well almost---they may be off by a few scaled points.
+% See section~\ref{sec:CloseEnough} for further details.}
+% and similarly for the other three display modes. See the
+% code for these equations.
+% \end{list}
+%
+% \subsubsection{\mode{[fleqn,leqno]}}
+% ~
+% \begin{macrocode}
+ \if@emphEQ@FLL % fleqn and leqno
+ \ifdim\alignsep@>0pt % => align
+ \@emphEQ@aligntrue
+ \setlength{\@emphEQ@displaywidth}{\tagshift@-\@mathmargin}%
+ \else
+ \ifdim\eqnshift@=0pt % => multline %tagwidth@>
+ \@emphEQ@multlinetrue
+ \if@emphEQ@NoNumEq
+ \setlength{\@emphEQ@displaywidth}{%
+ \linewidth-\multlinegap-\@mathmargin
+ -\@emphEQ@boxtypelength}%
+ \else
+ \setlength{\@emphEQ@displaywidth}{%
+ \linewidth-\tagwidth@-\multlinegap
+ -\multlinetaggap-\@emphEQ@boxtypelength}%
+ \fi
+ \else
+ \ifdim\tagshift@=0pt % => gather
+ \@emphEQ@gathertrue
+ \setlength{\@emphEQ@displaywidth}{%
+ \totwidth@-\@mathmargin}%
+ \else
+ \ifdim\tagshift@=\totwidth@ % => alignat
+ \@emphEQ@alignattrue
+ \setlength{\@emphEQ@displaywidth}{%
+ \totwidth@-\@mathmargin}%
+ \else
+ %Nothing thus far...
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+% \end{macrocode}
+% \subsubsection{\mode{[fleqn,reqno]}}
+% ~
+% \begin{macrocode}
+ \if@emphEQ@FLR % fleqn and reqno
+ \ifdim\alignsep@>0pt % => align
+ \@emphEQ@aligntrue
+ \setlength{\@emphEQ@displaywidth}{%
+ \linewidth-\@mathmargin+\tagshift@}%
+ \else
+ \ifdim\eqnshift@=0pt % => multline
+ \@emphEQ@multlinetrue
+ \if@emphEQ@NoNumEq
+ \setlength{\@emphEQ@displaywidth}{%
+ \linewidth-\multlinegap-\@mathmargin
+ -\@emphEQ@boxtypelength}%
+ \else
+ \setlength{\@emphEQ@displaywidth}{%
+ \linewidth-\tagwidth@-\@mathmargin
+ -\multlinetaggap-\@emphEQ@boxtypelength}%
+ \fi
+ \else
+ \ifdim\tagshift@=0pt % => gather
+ \@emphEQ@gathertrue
+ \setlength{\@emphEQ@displaywidth}{%
+ \totwidth@-\@mathmargin}%
+ \else
+ \@emphEQ@CloseEnough{\totwidth@-\tagshift@}%
+ {\linewidth}%
+ {\@emphEQ@alignattrue
+ \setlength{\@emphEQ@displaywidth}%
+ {\totwidth@-\eqnshift@}}{}%
+ \fi
+ \fi
+ \fi
+ \fi
+% \end{macrocode}
+% \subsubsection{\mode{[reqno]}}
+% ~
+% \begin{macrocode}
+ \if@emphEQ@R % reqno
+ \ifdim\alignsep@>0pt % => align
+ \@emphEQ@aligntrue
+ \setlength{\@emphEQ@displaywidth}{\totwidth@}%
+ \else
+ \ifdim\eqnshift@=0pt % => multline
+ \@emphEQ@multlinetrue
+ \if@emphEQ@NoNumEq
+ \setlength{\@emphEQ@displaywidth}{%
+ \linewidth-2\multlinegap
+ -\@emphEQ@boxtypelength}%
+ \else
+ \setlength{\@emphEQ@displaywidth}{%
+ \linewidth-\tagwidth@-\multlinegap
+ -\multlinetaggap-\@emphEQ@boxtypelength}%
+ \fi
+ \else
+ \ifdim\tagshift@=0pt % => gather
+ \@emphEQ@gathertrue
+ \setlength{\@emphEQ@displaywidth}{\totwidth@}%
+ \else
+ \@emphEQ@CloseEnough{\tagshift@}{-\eqnshift@}%
+ {\@emphEQ@alignattrue
+ \setlength{\@emphEQ@displaywidth}{\totwidth@}}{}%
+ \fi
+ \fi
+ \fi
+ \fi
+% \end{macrocode}
+% \subsubsection{\mode{[leqno]}}
+% ~
+% \begin{macrocode}
+ \if@emphEQ@L % leqno
+ \ifdim\alignsep@>0pt % => align
+ \@emphEQ@aligntrue
+ \setlength{\@emphEQ@displaywidth}{\totwidth@}%
+ \else
+ \ifdim\eqnshift@=0pt % => multline
+ \@emphEQ@multlinetrue
+ \if@emphEQ@NoNumEq
+ \setlength{\@emphEQ@displaywidth}{%
+ \linewidth-2\multlinegap
+ -\@emphEQ@boxtypelength}%
+ \else
+ \setlength{\@emphEQ@displaywidth}{%
+ \linewidth-\tagwidth@-\multlinegap
+ -\multlinetaggap-\@emphEQ@boxtypelength}%
+ \fi
+ \else
+ \ifdim\tagshift@=0pt % => gather
+ \@emphEQ@gathertrue
+ \setlength{\@emphEQ@displaywidth}{\totwidth@}%
+ \else
+ \@emphEQ@CloseEnough{%
+ \linewidth-\eqnshift@}{\tagshift@}{%
+ \@emphEQ@alignattrue
+ \setlength{\@emphEQ@displaywidth}{\totwidth@}}%
+ {}%
+ \fi
+ \fi
+ \fi
+ \fi
+% \end{macrocode}
+% Phew! That was tedious, but necessary. I wish I could say it got
+% better further down the road, but it doesn't. Now we can measure
+% the width of the additional material on both sides of the math
+% structure. We add braces here and there to avoid any
+% \cmd{\thinmuskip}'s.
+% \begin{macrocode}
+ \settowidth{\@emphEQ@lwd}{${\@emphEQ@Left}%
+ {\vphantom{\usebox{\@emphEQ@Box}}}$}%
+ \settowidth{\@emphEQ@rwd}{${\vphantom{\usebox{\@emphEQ@Box}}}%
+ {\@emphEQ@Right}$}%
+% \end{macrocode}
+%
+% \subsection{The second pass}
+%
+% When we try to create an effect as in the preliminary example
+% there are a few things we need to tell \LaTeX\ for the overall
+% result to be acceptable. If the display math is centered, then the
+% new one should also be centered. This means that when typesetting
+% the math structure for the second time, we need to make
+% adjustments to \cmd{\linewidth}, \cmd{\@mathmargin} etc.\ for the
+% equation tag to be placed correctly.
+%
+% That process is extremely tedious, but there are only few
+% shortcuts, so we just go through each of the four environments, check
+% each of the four display modes and alter dimensions a we trudge
+% along. First we check if we are trying to put something into an
+% asymmetrical box and then make it symmetrical be removing the size
+% of the shadow.
+% \begin{macrocode}
+ \begin{lrbox}{\@emphEQ@Box}%
+ \if@emphEQ@shadowbox
+ \addtolength{\@emphEQ@boxtypelength}{-\shadowsize}%
+ \fi
+% \end{macrocode}
+% \subsubsection{\env{align}}
+% ~
+% \begin{macrocode}
+ \if@emphEQ@align
+ \if@emphEQ@FLL
+ \begin{minipage}{\linewidth+\@emphEQ@lwd
+ +.5\@emphEQ@boxtypelength}%
+ \addtolength{\@mathmargin}{\@emphEQ@lwd
+ +.5\@emphEQ@boxtypelength}%%
+ \fi
+ \if@emphEQ@FLR
+ \begin{minipage}{\linewidth}%
+ \addtolength{\@mathmargin}{\@emphEQ@lwd
+ +.5\@emphEQ@boxtypelength}%%
+ \fi
+ \if@emphEQ@L
+ \begin{minipage}{\linewidth+\@emphEQ@lwd-\@emphEQ@rwd}%
+ \fi
+ \if@emphEQ@R
+ \begin{minipage}{\linewidth-\@emphEQ@lwd+\@emphEQ@rwd}%
+ \fi
+ \fi
+% \end{macrocode}
+% \subsubsection{\env{gather}}
+% ~
+% \begin{macrocode}
+ \if@emphEQ@gather
+ \if@emphEQ@FLL
+ \begin{minipage}{\linewidth+\@emphEQ@lwd
+ +.5\@emphEQ@boxtypelength}%
+ \addtolength{\@mathmargin}{\@emphEQ@lwd
+ +.5\@emphEQ@boxtypelength}%%
+ \fi
+ \if@emphEQ@FLR
+ \begin{minipage}{\linewidth}%
+ \addtolength{\@mathmargin}{\@emphEQ@lwd
+ +.5\@emphEQ@boxtypelength}%%
+ \fi
+ \if@emphEQ@R
+ \setlength{\@emphEQ@templength}{\linewidth-\totwidth@
+ -\eqnshift@}%
+ \begin{minipage}{\linewidth-\@emphEQ@lwd+\@emphEQ@rwd
+ +\@emphEQ@templength-\eqnshift@}%
+ \fi
+ \if@emphEQ@L
+ \setlength{\@emphEQ@templength}{\linewidth-\totwidth@
+ -\eqnshift@}%
+ \begin{minipage}{\linewidth+\@emphEQ@lwd-\@emphEQ@rwd
+ -\@emphEQ@templength+\eqnshift@}%
+ \fi
+ \fi
+% \end{macrocode}
+% \subsubsection{\env{alignat}}
+% ~
+% \begin{macrocode}
+ \if@emphEQ@alignat
+ \if@emphEQ@FLL
+ \begin{minipage}{\linewidth+\@emphEQ@lwd
+ +.5\@emphEQ@boxtypelength}%
+ \addtolength{\@mathmargin}{\@emphEQ@lwd
+ +.5\@emphEQ@boxtypelength}%%
+ \fi
+ \if@emphEQ@FLR
+ \begin{minipage}{\linewidth}%
+ \addtolength{\@mathmargin}{\@emphEQ@lwd
+ +.5\@emphEQ@boxtypelength}%%
+ \fi
+ \if@emphEQ@L
+ \begin{minipage}{\linewidth+\@emphEQ@lwd-\@emphEQ@rwd}%
+ \fi
+ \if@emphEQ@R
+ \begin{minipage}{\linewidth-\@emphEQ@lwd+\@emphEQ@rwd}%
+ \fi
+ \fi
+% \end{macrocode}
+% \subsubsection{\env{multline}}
+% ~
+% \begin{macrocode}
+ \if@emphEQ@multline
+ \if@emphEQ@FLL
+ \begin{minipage}{\linewidth}%
+ \if@emphEQ@NoNumEq
+ \addtolength{\@mathmargin}{\@emphEQ@lwd
+ +.5\@emphEQ@boxtypelength}%
+ \if@emphEQ@shadowbox
+ \addtolength{\@mathmargin}{\shadowsize}
+ \fi%
+ \else
+ \addtolength{\multlinetaggap}{\@emphEQ@lwd
+ +.5\@emphEQ@boxtypelength}%
+ \if@emphEQ@shadowbox
+ \addtolength{\multlinegap}{\shadowsize}%
+ \fi
+ \fi
+ \addtolength{\multlinegap}{\@emphEQ@rwd
+ +.5\@emphEQ@boxtypelength}%
+ \fi
+ \if@emphEQ@FLR
+ \begin{minipage}{\linewidth}%
+ \if@emphEQ@NoNumEq
+ \addtolength{\multlinegap}{\@emphEQ@rwd
+ +.5\@emphEQ@boxtypelength}%
+ \if@emphEQ@shadowbox
+ \addtolength{\multlinegap}{\shadowsize}%
+ \fi
+ \else
+ \addtolength{\multlinetaggap}{\@emphEQ@rwd
+ +.5\@emphEQ@boxtypelength}%
+ \if@emphEQ@shadowbox
+ \addtolength{\multlinetaggap}{\shadowsize}%
+ \fi
+ \fi
+ \addtolength{\@mathmargin}{\@emphEQ@lwd
+ +.5\@emphEQ@boxtypelength}%
+ \fi
+ \if@emphEQ@L
+ \begin{minipage}{\linewidth}%
+ \if@emphEQ@NoNumEq
+ \addtolength{\multlinegap}{.5\@emphEQ@rwd
+ +.5\@emphEQ@lwd+.5\@emphEQ@boxtypelength}%
+ \if@emphEQ@shadowbox
+ \addtolength{\multlinegap}{.5\shadowsize}%
+ \fi
+ \else
+ \addtolength{\multlinetaggap}{\@emphEQ@lwd
+ +.5\@emphEQ@boxtypelength}%
+ \addtolength{\multlinegap}{\@emphEQ@rwd
+ +.5\@emphEQ@boxtypelength}%
+ \if@emphEQ@shadowbox
+ \addtolength{\multlinegap}{\shadowsize}%
+ \fi
+ \fi
+ \fi
+ \if@emphEQ@R
+ \begin{minipage}{\linewidth}%
+ \if@emphEQ@NoNumEq
+ \addtolength{\multlinegap}{.5\@emphEQ@rwd
+ +.5\@emphEQ@lwd+.5\@emphEQ@boxtypelength}%
+ \if@emphEQ@shadowbox
+ \addtolength{\multlinegap}{.5\shadowsize}
+ \fi
+ \else
+ \addtolength{\multlinetaggap}{\@emphEQ@rwd
+ +.5\@emphEQ@boxtypelength}%
+ \addtolength{\multlinegap}{\@emphEQ@lwd
+ +.5\@emphEQ@boxtypelength}%
+ \if@emphEQ@shadowbox
+ \addtolength{\multlinetaggap}{\shadowsize}
+ \fi
+ \fi
+ \fi
+ \fi
+% \end{macrocode}
+% Finally we get to typeset the contents of \cmd{\@emphEQ@mathbody} for
+% the second time\ldots
+% \begin{macrocode}
+ \vskip-\abovedisplayskip\relax\vskip-1pt\relax
+ \the\@emphEQ@mathbody
+ \end{minipage}%
+ \end{lrbox}%
+% \end{macrocode}
+%
+% \subsection{Putting it into the box}
+%
+% Because we were clever to start with---by measuring the width of
+% the display math and storing it in
+% \cmd{\@emphEQ@displaywidth}---we can now put it into a box of
+% width
+% \cmd{\@emphEQ@displaywidth}+\cmd{\@emphEQ@rwd}+\cmd{\@emphEQ@lwd}.
+% This doesn't apply to \env{multline} though: it has to be set in a
+% box of width \cmd{\@emphEQ@displaywidth}.
+% \begin{macrocode}
+\setlength{\@emphEQ@BoxWidth}{\@emphEQ@displaywidth+\@emphEQ@rwd
+ +\@emphEQ@lwd}%
+% \end{macrocode}
+% \subsubsection{\env{align}}
+% ~
+% \begin{macrocode}
+\if@emphEQ@align
+ \if@emphEQ@FLL
+ \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][l]{%
+ \if@emphEQ@shadowbox \kern.5\shadowsize \fi
+ $\@emphEQ@Left$%
+ \kern-.5\@emphEQ@boxtypelength%
+ \kern-\@mathmargin
+ \kern-\@emphEQ@lwd
+ \usebox{\@emphEQ@Box}%
+ \kern-\@emphEQ@displaywidth
+ \kern-\@emphEQ@rwd
+ \kern-\@emphEQ@lwd
+ $\@emphEQ@Right$}}%
+ \fi
+ \if@emphEQ@FLR
+ \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][l]{%
+ \if@emphEQ@shadowbox \kern.5\shadowsize \fi
+ $\@emphEQ@Left$%
+ \kern-.5\@emphEQ@boxtypelength%
+ \kern-\@mathmargin
+ \kern-\@emphEQ@lwd
+ \usebox{\@emphEQ@Box}%
+ \kern-\alignsep@
+ $\@emphEQ@Right$}}%
+ \fi
+ \if@emphEQ@L
+ \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][c]{%
+ %\kern\eqnshift@
+ %\kern-\alignsep@
+ $\@emphEQ@Left$%
+ \kern-\eqnshift@
+ %\kern-\alignsep@
+ \usebox{\@emphEQ@Box}%
+ %\kern-\eqnshift@
+ \kern-\alignsep@
+ $\@emphEQ@Right$}}%
+ \fi
+ \if@emphEQ@R
+ \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][c]{%
+ $\@emphEQ@Left$%
+ \kern-\eqnshift@
+ \usebox{\@emphEQ@Box}%
+ \kern-\eqnshift@
+ $\@emphEQ@Right$}}%
+ \fi
+\fi
+% \end{macrocode}
+% \subsubsection{\env{alignat}}
+% ~
+% \begin{macrocode}
+\if@emphEQ@alignat
+ \if@emphEQ@FLL
+ \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][l]{%
+ \if@emphEQ@shadowbox \kern.5\shadowsize \fi
+ $\@emphEQ@Left$%
+ \kern-.5\@emphEQ@boxtypelength
+ \kern-\@mathmargin
+ \kern-\@emphEQ@lwd
+ \usebox{\@emphEQ@Box}%
+ \kern\@mathmargin
+ \kern\@emphEQ@displaywidth
+ \kern-\linewidth
+ $\@emphEQ@Right$}}%
+ \fi
+ \if@emphEQ@FLR
+ \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][l]{%
+ \if@emphEQ@shadowbox \kern.5\shadowsize \fi
+ $\@emphEQ@Left$%
+ \kern-.5\@emphEQ@boxtypelength
+ \kern-\@mathmargin
+ \kern-\@emphEQ@lwd
+ \usebox{\@emphEQ@Box}%
+ \kern\@mathmargin
+ \kern\@emphEQ@displaywidth
+ \kern-\linewidth
+ \kern\@emphEQ@lwd
+ \kern.5\@emphEQ@boxtypelength
+ $\@emphEQ@Right$}}%
+ \fi
+ \if@emphEQ@L
+ \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][c]{%
+ $\@emphEQ@Left$%
+ \kern-\eqnshift@
+ \usebox{\@emphEQ@Box}%
+ \kern-\eqnshift@
+ $\@emphEQ@Right$}}%
+ \fi
+ \if@emphEQ@R
+ \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][c]{%
+ $\@emphEQ@Left$%
+ \kern-\eqnshift@
+ \usebox{\@emphEQ@Box}%
+ \kern-\eqnshift@
+ $\@emphEQ@Right$}}%
+ \fi
+\fi
+% \end{macrocode}
+% \subsubsection{\env{gather}}
+% ~
+% \begin{macrocode}
+\if@emphEQ@gather
+ \if@emphEQ@FLL
+ \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][l]{%
+ \if@emphEQ@shadowbox \kern.5\shadowsize \fi
+ $\@emphEQ@Left$%
+ \kern-.5\@emphEQ@boxtypelength
+ \kern-\@mathmargin
+ \kern-\@emphEQ@lwd
+ \usebox{\@emphEQ@Box}%
+ \kern-\linewidth
+ \kern\@mathmargin
+ \kern\@emphEQ@displaywidth
+ $\@emphEQ@Right$}}%
+ \fi
+ \if@emphEQ@FLR
+ \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][l]{%
+ \if@emphEQ@shadowbox \kern.5\shadowsize
+ \fi
+ $\@emphEQ@Left$%
+ \kern-.5\@emphEQ@boxtypelength
+ \kern-\@mathmargin
+ \kern-\@emphEQ@lwd
+ \usebox{\@emphEQ@Box}%
+ \kern-\linewidth
+ \kern.5\@emphEQ@boxtypelength
+ \kern\@mathmargin
+ \kern\@emphEQ@displaywidth
+ \kern\@emphEQ@lwd
+ $\@emphEQ@Right$}}%
+ \fi
+ \if@emphEQ@L
+ \setlength{\tagwidth@}{\eqnshift@+\@emphEQ@rwd}%
+ \setlength{\@emphEQ@templength}{\linewidth-\totwidth@
+ -\eqnshift@}%
+ \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][c]{%
+ \ifdim\@emphEQ@templength<\tagwidth@
+ \setlength{\tagwidth@}{\@emphEQ@templength
+ +\@emphEQ@lwd}%
+ \ifdim\tagwidth@<\eqnshift@
+ \kern-\@emphEQ@templength
+ \kern\eqnshift@
+ \fi
+ \else
+ \kern-\@emphEQ@lwd
+ \kern\@emphEQ@rwd
+ \kern-\@emphEQ@templength
+ \kern\eqnshift@
+ \fi
+ $\@emphEQ@Left$%
+ \kern-\eqnshift@
+ \usebox{\@emphEQ@Box}%
+ %\kern-\eqnshift@
+ \kern-\@emphEQ@lwd
+ \kern\@emphEQ@rwd
+ \kern-\@emphEQ@templength
+ $\@emphEQ@Right$}}%
+ \fi
+ \if@emphEQ@R
+ \setlength{\tagwidth@}{\eqnshift@+\@emphEQ@rwd}%
+ \setlength{\@emphEQ@templength}{\linewidth-\totwidth@
+ -\eqnshift@}%
+ \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@BoxWidth][c]{%
+ \kern-\@emphEQ@lwd
+ \kern\@emphEQ@rwd
+ \kern\@emphEQ@templength
+ \kern-\eqnshift@
+ $\@emphEQ@Left$%
+ \ifdim\@emphEQ@templength>\tagwidth@
+ \kern-\eqnshift@
+ \else
+ \kern\@emphEQ@lwd
+ \kern-\@emphEQ@rwd
+ \kern-\@emphEQ@templength
+ \fi
+ \usebox{\@emphEQ@Box}%
+ \kern-\eqnshift@
+ $\@emphEQ@Right$}}%
+ \fi
+\fi
+% \end{macrocode}
+% \subsubsection{\env{multline}}
+%
+% \env{multline} is somewhat more difficult because \env{multline$*$}
+% differs on several accounts. Thus we make use of our little test
+% to see if the math structure was numbered to begin with
+% (\verb|\if@emphEQ@NoNumEq|).
+% \begin{macrocode}
+\if@emphEQ@multline
+ \if@emphEQ@FLL
+ \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@displaywidth][l]{%
+ \if@emphEQ@shadowbox \kern.5\shadowsize \fi
+ $\@emphEQ@Left$%
+ \kern-.5\@emphEQ@boxtypelength
+ \kern-\@emphEQ@lwd
+ \if@emphEQ@NoNumEq
+ \if@emphEQ@shadowbox \kern-\shadowsize \fi
+ \kern-\@mathmargin
+ \else
+ \kern-\tagwidth@
+ \kern-\multlinetaggap
+ \fi
+ \usebox{\@emphEQ@Box}%
+ \kern-\@emphEQ@boxtypelength
+ \if@emphEQ@NoNumEq
+ \kern-\multlinegap
+ \else
+ \kern\multlinegap
+ \fi
+ \kern-\@emphEQ@rwd
+ \kern-\@emphEQ@lwd
+ \kern-\@mathmargin
+ $\@emphEQ@Right$}}%
+ \fi
+ \if@emphEQ@FLR
+ \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@displaywidth][l]{%
+ \if@emphEQ@shadowbox \kern.5\shadowsize \fi
+ $\@emphEQ@Left$%
+ \kern-.5\@emphEQ@boxtypelength
+ \kern-\@emphEQ@lwd
+ \kern-\@mathmargin
+ \usebox{\@emphEQ@Box}%
+ \kern-\@emphEQ@boxtypelength
+ \kern-\@emphEQ@rwd
+ \kern-\@emphEQ@lwd
+ \if@emphEQ@NoNumEq
+ \kern-\multlinegap
+ \else
+ \kern-\multlinetaggap
+ \fi
+ \kern-\@mathmargin
+ \kern-\tagwidth@
+ $\@emphEQ@Right$}}%
+ \fi
+ \if@emphEQ@L
+ \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@displaywidth][l]{%
+ \if@emphEQ@shadowbox \kern.5\shadowsize \fi
+ $\@emphEQ@Left$%
+ \kern-.5\@emphEQ@boxtypelength
+ \kern-\@emphEQ@lwd
+ \if@emphEQ@NoNumEq
+ \kern-\multlinegap
+ \kern.5\@emphEQ@lwd
+ \kern-.5\@emphEQ@rwd
+ \if@emphEQ@shadowbox \kern-.5\shadowsize \fi
+ \else
+ \kern-\multlinetaggap
+ \kern-\tagwidth@
+ \fi
+ \usebox{\@emphEQ@Box}%
+ \kern-.5\@emphEQ@boxtypelength
+ \if@emphEQ@NoNumEq
+ \kern.5\@emphEQ@rwd
+ \kern-.5\@emphEQ@lwd
+ \fi
+ \kern-\@emphEQ@rwd
+ \kern-\multlinegap
+ $\@emphEQ@Right$}}%
+ \fi
+ \if@emphEQ@R
+ \savebox{\@emphEQ@Box}{\makebox[\@emphEQ@displaywidth][l]{%
+ \if@emphEQ@shadowbox \kern.5\shadowsize \fi
+ $\@emphEQ@Left$%
+ \kern-.5\@emphEQ@boxtypelength
+ \if@emphEQ@NoNumEq
+ \if@emphEQ@shadowbox \kern-.5\shadowsize \fi
+ \kern-.5\@emphEQ@rwd
+ \kern.5\@emphEQ@lwd
+ \fi
+ \kern-\@emphEQ@lwd
+ \kern-\multlinegap
+ \usebox{\@emphEQ@Box}%
+ \kern-.5\@emphEQ@boxtypelength
+ \kern-\@emphEQ@rwd
+ \if@emphEQ@NoNumEq
+ \kern-\multlinegap
+ \kern-.5\@emphEQ@lwd
+ \kern.5\@emphEQ@rwd
+ \else
+ \kern-\multlinetaggap
+ \fi
+ \kern-\tagwidth@
+ $\@emphEQ@Right$}}%
+ \fi
+\fi
+% \end{macrocode}
+%
+% \subsubsection{The final step}
+%
+% At last here comes the good part! We are now ready to place the
+% box containing all of our math material. If we have used a
+% \env{multline} we have to do a few kerning tricks but at least we
+% would seem to know the drill by now\ldots To make sure vertical
+% spacing is ok, we put it all into a simple math environment
+% \verb|\[...\]|.
+% \begin{macrocode}
+\[
+ \if@emphEQ@align
+ \if@emphEQ@L
+ \kern-\alignsep@
+ \kern\eqnshift@
+ \fi
+ \fi
+ \if@emphEQ@gather
+ \if@emphEQ@L
+ \kern-\@emphEQ@templength
+ \kern\eqnshift@
+ \kern\@emphEQ@rwd
+ \kern-\@emphEQ@lwd
+ \fi
+ \if@emphEQ@R
+ \setlength{\tagwidth@}{\eqnshift@+\@emphEQ@rwd}%
+ \ifdim\@emphEQ@templength>\tagwidth@
+ \kern-\@emphEQ@templength
+ \kern\eqnshift@
+ \kern\@emphEQ@lwd
+ \else
+ \kern\@emphEQ@templength
+ \kern-\eqnshift@
+ \kern\@emphEQ@rwd
+ \kern-\@emphEQ@lwd
+ \fi
+ \fi
+ \fi
+ \if@emphEQ@multline
+ \if@emphEQ@NoNumEq
+ % naught
+ \else
+ \if@emphEQ@FLL
+ \kern-\@mathmargin
+ \kern\tagwidth@
+ \kern\multlinetaggap
+ \fi
+ \if@emphEQ@L
+ \kern\tagwidth@
+ \kern\multlinetaggap
+ \kern-\multlinegap
+ \fi
+ \if@emphEQ@R
+ \kern-\tagwidth@
+ \kern-\multlinetaggap
+ \kern\multlinegap
+ \fi
+ \fi
+ \else
+% \end{macrocode}
+% If we are using a \cmd{\shadowbox} in centered display mode, I
+% would rather that the shadowsize is ignored when placing the box.
+% Reason: I think it looks better. Judge for yourself:
+% \begin{gather}
+% a=b\\
+% \Phi(x)=\int_{-\infty}^x e^{-t^2/2}\, dt
+% \end{gather}
+%
+% \begin{empheq}[boxtype=\shadowbox]
+% \begin{gather}
+% a=b\\
+% \Phi(x)=\int_{-\infty}^x e^{-t^2/2}\, dt
+% \end{gather}
+% \end{empheq}
+% \begin{macrocode}
+ \if@emphEQ@shadowbox
+ \if@emphEQ@R
+ \kern\shadowsize
+ \fi
+ \if@emphEQ@L
+ \kern\shadowsize
+ \fi
+ \fi
+ \fi
+ \@emphEQ@boxtype{\usebox{\@emphEQ@Box}}%
+% \end{macrocode}
+% After all is done, we empty out the added material and the
+% boxtype.
+% \begin{macrocode}
+ \gdef\@emphEQ@Left{}\gdef\@emphEQ@Right{}%
+ \gdef\@emphEQ@boxtype{}%
+ \]%
+ \ifnum0=`{\fi}%
+ \expandafter\end\expandafter{\@emphEQ@EnvName}%
+}
+% \end{macrocode}
+%
+% \subsection{Going public\ldots}
+% \begin{macro}{boxtype}\begin{macro}{Left}\begin{macro}{Right}\begin{macro}{empheq}
+% In order to simplify the user interface, we make use of
+% \pkg{keyval}. We define three keys to be used along with a more
+% accessible version of \env{@emphEQ@MainEnv}.
+% \changes{v0.7}{2003/05/11}{Changed the user interface slightly}
+% \begin{macrocode}
+\define@key{empheq}{boxtype}{\renewcommand\@emphEQ@boxtype{#1}}
+\define@key{empheq}{Left}{\def\@emphEQ@Left{#1}}
+\define@key{empheq}{Right}{\def\@emphEQ@Right{#1}}
+\newenvironment{empheq}[1][]{\setkeys{empheq}{#1}\@emphEQ@MainEnv}%
+ {\end@emphEQ@MainEnv\ignorespacesafterend}%
+% \end{macrocode}
+% \end{macro}\end{macro}\end{macro}\end{macro}
+% \begin{macro}{\DeclareLeftDelimiter}
+% \changes{v0.7}{2003/05/11}{Added delimiter interface}
+% \begin{macro}{\DeclareRightDelimiter}
+% \changes{v0.7}{2003/05/11}{Added delimiter interface}
+% It might come in handy to have delimiters of the appropriate size
+% available to cover the math display as in \eqref{eq:1}. Therefore
+% we define two commands that will create such delimiters once and
+% for all.
+% Use this as an inspiration for further kinds of delimiters.
+% \begin{macrocode}
+\newcommand{\DeclareLeftDelimiter}[2][\!]{%
+ \@namedef{empheq\expandafter\@gobble\string#2}{
+ \left#2
+ \vphantom{\usebox{\@emphEQ@Box}}%
+ \right.#1}}
+\newcommand{\DeclareRightDelimiter}[2][\!]{%
+ \@namedef{empheq\expandafter\@gobble\string#2}{%
+ #1\left.
+ \vphantom{\usebox{\@emphEQ@Box}}%
+ \right#2}}%
+\DeclareRightDelimiter{\rbrace}
+\DeclareLeftDelimiter{\lbrace}
+%</package>
+% \end{macrocode}
+% \end{macro}\end{macro}\end{macro}
+% \Finale
+\endinput
diff --git a/Master/texmf-dist/source/latex/mh/empheq07.ins b/Master/texmf-dist/source/latex/mh/empheq07.ins
new file mode 100644
index 00000000000..c001b4a482c
--- /dev/null
+++ b/Master/texmf-dist/source/latex/mh/empheq07.ins
@@ -0,0 +1,54 @@
+%%
+%% This file will generate fast loadable files and documentation
+%% driver files from the doc files in this package when run through
+%% LaTeX or TeX.
+%%
+%% File `empheq07.ins'.
+%% Copyright 2002--2004 Morten H\o gholm.
+%% moho01ab@student.cbs.dk
+%%
+%% It 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.
+%% 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 2003/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "maintained".
+%%
+%% The Current Maintainer of this work is Morten H\o gholm.
+%%
+%% This work consists of the files empheq07.dtx and empheq07.ins and
+%% the derived file empheq07.sty.
+%% --------------- start of docstrip commands ------------------
+%%
+\input docstrip
+
+\keepsilent
+
+\preamble
+
+It 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.
+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 2003/12/01 or later.
+
+This work has the LPPL maintenance status "maintained".
+
+The Current Maintainer of this work is Morten H\string\o gholm.
+
+This work consists of the files empheq07.dtx and empheq07.ins and
+the derived file empheq07.sty.
+
+\endpreamble
+
+%%%%%%%%%%%%%%%
+\generate{%
+ \file{empheq07.sty}{\from{empheq07.dtx}{package}}%
+}
+
+\endbatchfile
diff --git a/Master/texmf-dist/source/latex/mh/mathtools.dtx b/Master/texmf-dist/source/latex/mh/mathtools.dtx
new file mode 100644
index 00000000000..96ac01a4a9a
--- /dev/null
+++ b/Master/texmf-dist/source/latex/mh/mathtools.dtx
@@ -0,0 +1,3688 @@
+% \iffalse meta-comment
+% File `mathtools.dtx'.
+% Copyright 2004 Morten H\o gholm.
+% moho01ab@student.cbs.dk
+%
+% It 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.
+% 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 2003/12/01 or later.
+%
+% This work has the LPPL maintenance status "maintained".
+%
+% The Current Maintainer of this work is Morten H\o gholm.
+%
+% This work consists of the files mathtools.dtx and mathtools.ins
+% and the derived file mathtools.sty.
+%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{mathtools}
+%<*dtx>
+ \ProvidesFile{mathtools.dtx}
+%</dtx>
+ [2004/10/10 v1.01a mathematical typesetting tools (MH)]
+%<*driver>
+\documentclass[a4paper]{ltxdoc}
+\addtolength\marginparwidth{-25pt}
+\usepackage{mathtools}
+
+\setcounter{IndexColumns}{2}
+
+\providecommand*\pkg[1]{\textsf{#1}}
+\providecommand*\env[1]{\texttt{#1}}
+\providecommand*\email[1]{\href{mailto:#1}{\texttt{#1}}}
+\providecommand*\mode[1]{\texttt{[#1]}}
+\providecommand*\file[1]{\texttt{#1}}
+\usepackage{color,varioref}
+\makeatletter
+\newcommand*\thinfbox[2][black]{\fboxsep0pt\textcolor{#1}{\rulebox{{\normalcolor#2}}}}
+\newcommand*\thinboxed[2][black]{\thinfbox[#1]{\ensuremath{\displaystyle#2}}}
+\newcommand*\rulebox[1]{%
+ \sbox\z@{\ensuremath{\displaystyle#1}}%
+ \@tempdima\dp\z@
+ \hbox{%
+ \lower\@tempdima\hbox{%
+ \vbox{\hrule height\fboxrule\box\z@\hrule height\fboxrule}%
+ }%
+ }%
+}
+
+\newenvironment{codesyntax}
+ {\par\small\addvspace{4.5ex plus 1ex}%
+ \vskip -\parskip
+ \noindent
+ \begin{tabular}{|l|}\hline\ignorespaces}%
+ {\\\hline\end{tabular}\nobreak\par\nobreak
+ \vspace{2.3ex}\vskip -\parskip\noindent\ignorespacesafterend}
+\makeatletter
+
+\newcommand*\FeatureRequest[2]{%
+ \hskip1sp
+ \marginpar{%
+ \parbox[b]{\marginparwidth}{\small\sffamily\raggedright
+ \strut Feature request by\\#1\\#2%
+ }
+ }%
+}
+
+\newcommand*\cttPosting[2]{%
+ \hskip1sp
+ \marginpar{%
+ \parbox[b]{\marginparwidth}{\small\sffamily\raggedright
+ \strut Posted on \texttt{comp.text.tex} \\#1\\#2%
+ }%
+ }%
+}
+
+\expandafter\def\expandafter\MakePrivateLetters\expandafter{%
+ \MakePrivateLetters \catcode`\_=11\relax
+}
+
+\providecommand*\SpecialOptIndex[1]{%
+ \@bsphack
+ \index{#1\actualchar{\protect\ttfamily #1}
+ (option)\encapchar usage}%
+ \index{options:\levelchar#1\actualchar{\protect\ttfamily #1}\encapchar
+ usage}\@esphack}
+\providecommand*\opt[1]{\texttt{#1}}
+
+\providecommand*\SpecialKeyIndex[1]{%
+ \@bsphack
+ \index{#1\actualchar{\protect\ttfamily #1}
+ (key)\encapchar usage}%
+ \index{keys:\levelchar#1\actualchar{\protect\ttfamily #1}\encapchar
+ usage}\@esphack}
+\providecommand*\key[1]{\textsf{#1}}
+
+\providecommand*\eTeX{$\m@th\varepsilon$-\TeX}
+
+\def\MTmeta#1{%
+ \ensuremath\langle
+ \ifmmode \expandafter \nfss@text \fi
+ {%
+ \meta@font@select
+ \edef\meta@hyphen@restore
+ {\hyphenchar\the\font\the\hyphenchar\font}%
+ \hyphenchar\font\m@ne
+ \language\l@nohyphenation
+ #1\/%
+ \meta@hyphen@restore
+ }\ensuremath\rangle
+ \endgroup
+}
+\makeatother
+\DeclareRobustCommand\meta{\begingroup\MakePrivateLetters\MTmeta}%
+\def\MToarg#1{{\ttfamily[}\meta{#1}{\ttfamily]}\endgroup}
+\DeclareRobustCommand\oarg{\begingroup\MakePrivateLetters\MToarg}%
+\def\MHmarg#1{{\ttfamily\char`\{}\meta{#1}{\ttfamily\char`\}}\endgroup}
+\DeclareRobustCommand\marg{\begingroup\MakePrivateLetters\MHmarg}%
+\def\MHarg#1{{\ttfamily\char`\{#1\ttfamily\char`\}}\endgroup}
+\DeclareRobustCommand\arg{\begingroup\MakePrivateLetters\MHarg}%
+\def\MHcs#1{\texttt{\char`\\#1}\endgroup}
+\DeclareRobustCommand\cs{\begingroup\MakePrivateLetters\MHcs}
+
+\def\endverbatim{\if@newlist
+\leavevmode\fi\endtrivlist\vspace{-\baselineskip}}
+\expandafter\let\csname endverbatim*\endcsname =\endverbatim
+
+\let\MTtheindex\theindex
+\def\theindex{\MTtheindex\MakePrivateLetters}
+
+\usepackage[final,hyperindex=false,linkbordercolor=false]{hyperref}
+\renewcommand*\usage[1]{\textit{\hyperpage{#1}}}
+
+\OnlyDescription
+\begin{document}
+ \DocInput{mathtools.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \changes{v1.0}{2004/07/26}{Initial release}
+%
+% \GetFileInfo{mathtools.dtx}
+%
+% \CheckSum{2004}
+%
+% \title{The \pkg{mathtools} package\thanks{This file has version number
+% \fileversion, last revised \filedate.}}
+%
+% \author{Morten H\o gholm}
+% \date{\filedate}
+%
+% \maketitle
+%
+% \begin{abstract}
+% 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
+% for mathematical typesetting, be it a small macro for
+% typesetting a prescript or an underbraket, or entirely new
+% display math constructs such as a \env{multlined} environment.
+% \end{abstract}
+%
+% \tableofcontents
+%
+% \section{Introduction}
+%
+% Although \pkg{amsmath} provides many handy tools for mathematical
+% typesetting, it is nonetheless a static package. This is not a bad
+% thing, because what it does, it mostly does quite well and having
+% a stable math typesetting package is ``a good thing.'' However,
+% \pkg{amsmath} does not fulfill all the needs of the mathematical
+% part of the \LaTeX{} community, resulting in many authors writing
+% small snippets of code for tweaking the mathematical layout. Some
+% of these snippets has also been posted to newsgroups and mailing
+% lists over the years, although more often than not without being
+% released as stand-alone packages.
+%
+%
+% The \pkg{mathtools} package is exactly what its name implies:
+% tools for mathematical typesetting. It is a collection of many of
+% these often needed small tweaks---with some big tweaks added as
+% well. It can only do so by having me harvesting newsgroups for
+% code and/or you writing me with wishes for code to be included, so
+% if you have any good macros or just macros that help you when
+% writing mathematics, then don't hesitate to report them to me. I
+% can be reached at
+% \begin{quote}\email{moho01ab@student.cbs.dk}\end{quote}
+% This is of course also the address to use in case of bug reports.
+%
+% \section{Package loading}
+%
+%
+% The \pkg{mathtools} package requires \pkg{amsmath} but is able to
+% pass options to it as well. Thus a line like
+% \begin{verbatim}
+% \usepackage[fleqn,tbtags]{mathtools}
+% \end{verbatim}
+% is equivalent to
+% \begin{verbatim}
+% \usepackage[fleqn,tbtags]{amsmath}
+% \usepackage{mathtools}
+% \end{verbatim}
+%
+%
+% \subsection{Special \pkg{mathtools} options}
+%
+% \begin{codesyntax}
+% \SpecialOptIndex{fixamsmath}\opt{fixamsmath}\texttt{~~~~}
+% \SpecialOptIndex{donotfixamsmathbugs}\opt{donotfixamsmathbugs}
+% \end{codesyntax}
+% The option \opt{fixamsmath} (default) fixes two bugs in
+% \pkg{amsmath}.\footnote{See the online \LaTeX{} bugs database
+% \url{http://www.latex-project.org/cgi-bin/ltxbugs2html} under
+% \AmS\LaTeX{} problem reports 3591 and 3614.} Should you for some
+% reason not want to fix these bugs then just add the option
+% \opt{donotfixamsmathbugs} (if you can do it without typos). The
+% reason for this extremely long name is that I really don't see why
+% you wouldn't want these bugs to be fixed, so I've made it slightly
+% difficult not to fix them.
+%
+% \begin{codesyntax}
+% \SpecialOptIndex{allowspaces}\opt{allowspaces}\texttt{~~~~}
+% \SpecialOptIndex{disallowspaces}\opt{disallowspaces}
+% \end{codesyntax}
+% Sometimes \pkg{amsmath} gives you nasty surprises, as here where
+% things look seemingly innocent:
+% \begin{verbatim}
+% \[
+% \begin{gathered}
+% [p] = 100 \\
+% [v] = 200
+% \end{gathered}
+% \]
+% \end{verbatim}
+% Without \pkg{mathtools} this will result in this output:
+% \[
+% \begin{gathered}[c]
+% = 100 \\
+% [v] = 200
+% \end{gathered}
+% \]
+% Yes, the \texttt[p] has been gobbled without any warning
+% whatsoever.\footnote{\pkg{amsmath} thought the \texttt[p] was an
+% optional argument, checked if it was \texttt{t} or \texttt{b} and
+% when both tests failed, assumed it was a \texttt{c}.} This is
+% hardly what you'd expect as an end user, as the desired output was
+% probably something like this instead:
+% \[
+% \begin{gathered}[c]
+% [p] = 100 \\
+% [v] = 200
+% \end{gathered}
+% \]
+% With the option \opt{disallowspaces} (default) \pkg{mathtools}
+% disallows spaces in front of optional arguments where it could
+% possibly cause problems just as \pkg{amsmath} does with |\\|
+% inside the display environments. This includes the environments
+% \env{gathered} (and also those shown in \S
+% \vref{subsec:gathered}), \env{aligned}, \env{multlined}, and the
+% extended \env{matrix}-environments (\S \vref{subsubsec:matrices}).
+% If you however want to preserve the more dangerous standard
+% optional spaces, simply choose the option \opt{allowspaces}.
+%
+%
+% \section{Tools for mathematical typesetting}
+%
+% \begin{codesyntax}
+% \SpecialUsageIndex{\mathtoolsset}\cs{mathtoolsset}\marg{key val list}
+% \end{codesyntax}
+% Many of the tools shown in this manual can be turned on and off be
+% setting a switch to either true or false. In all cases it is done
+% with the command \cs{mathtoolsset}. A typical use could be something like
+% \begin{verbatim}
+% \mathtoolsset{
+% showonlyrefs,
+% mathic % or mathic = true
+% }
+% \end{verbatim}
+% More information on the keys later on.
+%
+% \subsection{Fine-tuning mathematical layout}
+%
+% Sometimes you need to tweak the layout of formulas a little to get
+% the best result and this part of the manual describes the various
+% macros \pkg{mathtools} provides for this.
+%
+% \subsubsection{A complement to \texttt{\textbackslash smash},
+% \texttt{\textbackslash llap}, and \texttt{\textbackslash rlap}}
+%
+% \begin{codesyntax}
+% \SpecialUsageIndex{\mathllap}
+% \cs{mathllap}\oarg{mathstyle}\marg{math}\texttt{~~}
+% \SpecialUsageIndex{\mathclap}
+% \cs{mathclap}\oarg{mathstyle}\marg{math}\\
+% \SpecialUsageIndex{\mathrlap}
+% \cs{mathrlap}\oarg{mathstyle}\marg{math}\texttt{~~}
+% \SpecialUsageIndex{\clap}
+% \cs{clap}\marg{text}\\
+% \SpecialUsageIndex{\mathmbox}
+% \cs{mathmbox}\marg{math}\phantom{\meta{mathstyle}}\texttt{~~~~}
+% \SpecialUsageIndex{\mathmakebox}
+% \cs{mathmakebox}\oarg{width}\oarg{pos}\marg{math}
+% \end{codesyntax}
+% In \cite{Perlis01}, Alexander R.~Perlis describes some simple yet
+% useful macros for use in math displays. For example the display
+% \begin{verbatim}
+% \[
+% X = \sum_{1\le i\le j\le n} X_{ij}
+% \]
+% \end{verbatim}
+% \[
+% X = \sum_{1\le i\le j\le n} X_{ij}
+% \]
+% contains a lot of excessive white space. The idea that comes to
+% mind is to fake the width of the subscript. The command
+% \cs{mathclap} puts its argument in a zero width box and centers
+% it, so it could possibly be of use here.
+% \begin{verbatim}
+% \[
+% X = \sum_{\mathclap{1\le i\le j\le n}} X_{ij}
+% \]
+% \end{verbatim}
+% \[
+% X = \sum_{\mathclap{1\le i\le j\le n}} X_{ij}
+% \]
+% For an in-depth discussion of
+% these macros I find it better to read the article; an online
+% version can be found at
+% \begin{quote}
+% \url{http://www.tug.org/TUGboat/Articles/tb22-4/tb72perlS.pdf}
+% \end{quote}
+% Note that the definitions shown in the article do not exactly
+% match the definitions in \pkg{mathtools}. Besides providing an
+% optional argument for specifying the desired math style, these
+% versions also work around a most unfortunate \TeX{}
+% ``feature.''\footnote{The faulty reboxing procedure.} The
+% \cs{smash} macro is fixed too.
+%
+%
+% \subsubsection{Forcing a cramped style}
+%
+% \begin{codesyntax}
+% \SpecialUsageIndex{\cramped}
+% \cs{cramped}\oarg{mathstyle}\marg{math}
+% \end{codesyntax}
+% \cttPosting{Michael Herschorn}{1992/07/21}
+% Let's look at another example where we have used \cs{mathclap}:
+% \begin{verbatim}
+% \begin{equation}\label{eq:mathclap}
+% \sum_{\mathclap{a^2<b^2<c}}\qquad
+% \sum_{a^2<b^2<c}
+% \end{equation}
+% \end{verbatim}
+% \begin{equation}\label{eq:mathclap}
+% \sum_{\mathclap{a^2<b^2<c}}\qquad
+% \sum_{a^2<b^2<c}
+% \end{equation}
+% Do you see the difference? Maybe if I zoomed in a bit:
+% \begingroup \fontsize{24}{\baselineskip}\selectfont
+% \[
+% \sum_{\mathclap{a^2<b^2<c}}\qquad
+% \sum_{a^2<b^2<c}
+% \]
+% \endgroup
+% Notice how the limit of the right summation sign is typeset in a
+% more compact style than the left. It is because \TeX{} sets the
+% limits of operators in a \emph{cramped} style. For each of \TeX'
+% four math styles (\cs{displaystyle}, \cs{textstyle},
+% \cs{scriptstyle}, and \cs{scriptscriptstyle}), there also exists a
+% cramped style that doesn't raise exponents as much. Besides in the
+% limits of operators, \TeX{} also automatically uses these cramped
+% styles in radicals such as \cs{sqrt} and in the denominators of
+% fractions, but unfortunately there are no primitive commands that
+% allows you to detect crampedness or switch to it.
+%
+% \pkg{mathtools} offers the command \cs{cramped} which forces a
+% cramped style in normal un-cramped math. Additionally you can
+% choose which of the four styles you want it in as well by
+% specifying it as the optional argument:
+% \begin{verbatim}
+% \[
+% \cramped{x^2} \leftrightarrow x^2 \quad
+% \cramped[\scriptstyle]{x^2} \leftrightarrow {\scriptstyle x^2}
+% \]
+% \end{verbatim}
+% \[
+% \cramped{x^2} \leftrightarrow x^2 \quad
+% \cramped[\scriptstyle]{x^2} \leftrightarrow {\scriptstyle x^2}
+% \]
+% You may be surprised how often the cramped style can be
+% beneficial yo your output. Take a look at this example:
+% \begin{verbatim}
+% \begin{quote}
+% The 2005 Euro\TeX{} conference is held in Abbaye des
+% Pr\'emontr\'es, France, marking the 16th ($2^{2^2}$) anniversary
+% of both Dante and GUTenberg (the German and French \TeX{} users
+% group resp.).
+% \end{quote}
+% \end{verbatim}
+% \begin{quote}
+% The 2005 Euro\TeX{} conference is held in Abbaye des
+% Pr\'emontr\'es, France, marking the 16th ($2^{2^2}$) anniversary
+% of both Dante and GUTenberg (the German and French \TeX{} users
+% group resp.).
+% \end{quote}
+% Typesetting on a grid is generally considered quite desirable, but
+% as the second line of the example shows, the exponents of $2$
+% causes the line to be too tall for the normal value of
+% \cs{baselineskip}, so \TeX{} inserts a \cs{lineskip} (normal value
+% is \the\lineskip). In order to circumvent the problem, we can
+% force a cramped style so that the exponents aren't raised as much:
+% \begin{verbatim}
+% \begin{quote}
+% The 2005 Euro\TeX{} ... 16th ($\cramped{2^{2^2}}$) ...
+% \end{quote}
+% \end{verbatim}
+% \begin{quote}
+% The 2005 Euro\TeX{} conference is held in Abbaye des
+% Pr\'emontr\'es, France, marking the 16th ($\cramped{2^{2^2}}$)
+% anniversary of both Dante and GUTenberg (the German and French
+% \TeX{} users group resp.).
+% \end{quote}
+%
+% \begin{codesyntax}
+% \SpecialUsageIndex{\crampedllap}
+% \cs{crampedllap}\oarg{mathstyle}\marg{math}\texttt{~~}
+% \SpecialUsageIndex{\crampedclap}
+% \cs{crampedclap}\oarg{mathstyle}\marg{math}\\
+% \SpecialUsageIndex{\crampedrlap}
+% \cs{crampedrlap}\oarg{mathstyle}\marg{math}
+% \end{codesyntax}
+% The commands \cs{crampedllap}, \cs{crampedclap}, and
+% \cs{crampedrlap} are identical to the three \cs{mathXlap} commands
+% described earlier except the argument is typeset in cramped style.
+% You need this in order to typeset \eqref{eq:mathclap} correctly
+% while still faking the width of the limit.
+% \begin{verbatim}
+% \begin{equation*}\label{eq:mathclap-b}
+% \sum_{\crampedclap{a^2<b^2<c}}
+% \tag{\ref{eq:mathclap}*}
+% \end{equation*}
+% \end{verbatim}
+% \begin{equation*}\label{eq:mathclap-b}
+% \sum_{\crampedclap{a^2<b^2<c}}
+% \tag{\ref{eq:mathclap}*}
+% \end{equation*}
+% Of course you could just type
+% \begin{verbatim}
+% \sum_{\mathclap{\cramped{a^2<b^2<c}}}
+% \end{verbatim}
+% but it has one major disadvantage: In order for \cs{mathXlap} and
+% \cs{cramped} to get the right size, \TeX{} has to process them
+% four times, meaning that nesting them as shown above will cause
+% \TeX{} to typeset $4^2$ instances before choosing the right one.
+% In this situation however, we will of course need the same style
+% for both commands so it makes sense to combine the commands in
+% one, thus letting \TeX{} make the choice only once rather than
+% twice.
+%
+%
+%
+% \subsubsection{Smashing an operator}
+%
+%
+%
+% \begin{codesyntax}
+% \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
+% side of the operator should be ignored (smashed).
+% \begin{verbatim}
+% \[
+% V = \sum_{1\le i\le j\le n}^{\infty} V_{ij} \quad
+% X = \smashoperator{\sum_{1\le i\le j\le n}^{3456}} X_{ij} \quad
+% Y = \smashoperator[r]{\sum\limits_{1\le i\le j\le n}} Y_{ij} \quad
+% Z = \smashoperator[l]{\mathop{T}_{1\le i\le j\le n}} Z_{ij}
+% \]
+% \end{verbatim}
+% \[
+% V = \sum_{1\le i\le j\le n}^{\infty} V_{ij} \quad
+% X = \smashoperator{\sum_{1\le i\le j\le n}^{3456}} X_{ij} \quad
+% Y = \smashoperator[r]{\sum\limits_{1\le i\le j\le n}} Y_{ij} \quad
+% Z = \smashoperator[l]{\mathop{T}_{1\le i\le j\le n}} Z_{ij}
+% \]
+% Note that \cs{smashoperator} always sets its argument in display
+% style and with limits even if you have used the \opt{nosumlimits}
+% option of \pkg{amsmath}. If you wish, you can use shorthands for
+% \texttt{\_} and \texttt{\textasciicircum} such as \cs{sb} and
+% \cs{sp}.
+%
+%
+% \subsubsection{Adjusting limits of operators}
+%
+% \begin{codesyntax}
+% \SpecialUsageIndex{\adjustlimits}
+% \cs{adjustlimits}\marg{operator$\sb1$}\texttt{\_}\marg{limit$\sb1$}
+% \marg{operator$\sb2$}\texttt{\_}\marg{limit$\sb2$}
+% \end{codesyntax}
+% \FeatureRequest{Lars Madsen}{2004/07/09}
+% When typesetting two consecutive operators with limits one often
+% wishes the limits of the operators were better aligned. Look
+% closely at these examples:
+% \begin{verbatim}
+% \[
+% \text{a)} \lim_{n\to\infty} \max_{p\ge n} \quad
+% \text{b)} \lim_{n\to\infty} \max_{p^2\ge n} \quad
+% \text{c)} \lim_{n\to\infty} \sup_{p^2\ge nK} \quad
+% \text{d)} \limsup_{n\to\infty} \max_{p\ge n}
+% \]
+% \end{verbatim}
+% \[
+% \text{a)} \lim_{n\to\infty} \max_{p\ge n} \quad
+% \text{b)} \lim_{n\to\infty} \max_{p^2\ge n} \quad
+% \text{c)} \lim_{n\to\infty} \sup_{p^2\ge nK} \quad
+% \text{d)} \limsup_{n\to\infty} \max_{p\ge n}
+% \]
+% a) looks okay, but b) is not quite as good because the second
+% limit ($\cramped{p^2\ge n}$) is significantly taller than the
+% first ($n\to\infty$). With c)~things begin to look really bad,
+% because the second operator has a descender while the first
+% doesn't, and finally we have d)~which looks just as bad as~c). The
+% command \cs{adjustlimits} is useful in these cases, as you can
+% just put it in front of these consecutive operators and it'll make
+% the limits line up.
+% \begin{verbatim}
+% \[
+% \text{a)} \adjustlimits\lim_{n\to\infty} \max_{p\ge n} \quad
+% \text{b)} \adjustlimits\lim_{n\to\infty} \max_{p^2\ge n} \quad
+% \text{c)} \adjustlimits\lim_{n\to\infty} \sup_{p^2\ge nK} \quad
+% \text{d)} \adjustlimits\limsup_{n\to\infty} \max_{p\ge n}
+% \]
+% \end{verbatim}
+% \[
+% \text{a)} \adjustlimits\lim_{n\to\infty} \max_{p\ge n} \quad
+% \text{b)} \adjustlimits\lim_{n\to\infty} \max_{p^2\ge n} \quad
+% \text{c)} \adjustlimits\lim_{n\to\infty} \sup_{p^2\ge nK} \quad
+% \text{d)} \adjustlimits\limsup_{n\to\infty} \max_{p\ge n}
+% \]
+% The use of \cs{sb} instead of \texttt{\_} is allowed.
+%
+%
+%
+% \subsection{Controlling tags}
+%
+% In this section various tools for altering the appearance of tags
+% are shown. All of the tools here can be used at any point in the
+% document but they should probably be affect the whole document, so
+% the preamble is the best place to issue them.
+%
+% \subsubsection{The appearance of tags}
+% \begin{codesyntax}
+% \SpecialUsageIndex{\newtagform}
+% \cs{newtagform}\marg{name}\oarg{inner_format}\marg{left}\marg{right}\\
+% \SpecialUsageIndex{\renewtagform}
+% \cs{renewtagform}\marg{name}\oarg{inner_format}\marg{left}\marg{right}\\
+% \SpecialUsageIndex{\usetagform}
+% \cs{usetagform}\marg{name}
+% \end{codesyntax}
+% Altering the layout of equation numbers in \pkg{amsmath} is not
+% very user friendly (it involves a macro with three \texttt{@}'s in
+% its name), so \pkg{mathtools} provides an interface somewhat
+% reminiscent of the page style concept. This way you can define
+% several different tag forms and then choose the one you prefer.
+%
+% As an example let's try to define a tag form which puts the
+% equation number in square brackets. First we define a brand new tag
+% form:
+% \begin{verbatim}
+% \newtagform{brackets}{[}{]}
+% \end{verbatim}
+% Then we activate it:
+% \begin{verbatim}
+% \usetagform{brackets}
+% \end{verbatim}
+% The result is then
+% \newtagform{brackets}{[}{]}
+% \usetagform{brackets}
+% \begin{equation}
+% E \neq m c^3
+% \end{equation}
+%
+% Similarly you could define a second version of the brackets that
+% prints the equation number in bold face instead
+% \begin{verbatim}
+% \newtagform{brackets2}[\textbf]{[}{]}
+% \usetagform{brackets2}
+% \begin{equation}
+% E \neq m c^3
+% \end{equation}
+% \end{verbatim}
+% \newtagform{brackets2}[\textbf]{[}{]}
+% \usetagform{brackets2}
+% \begin{equation}
+% E \neq m c^3
+% \end{equation}
+% When you reference an equation with \cs{eqref}, the tag form in
+% effect at the time of referencing controls the formatting, so be
+% careful if you use different tag forms throughout your document.
+%
+% If you want to renew a tag form, then use the command
+% \cs{renewtagform}. Should you want to
+% return to the standard setting then choose\usetagform{default}
+% \begin{verbatim}
+% \usetagform{default}
+% \end{verbatim}
+%
+% \subsubsection{Showing only referenced tags}
+%
+% \begin{codesyntax}
+% \SpecialKeyIndex{showonlyrefs}$\key{showonlyrefs}=\texttt{true}\vert\texttt{false}$\\
+% \SpecialKeyIndex{showmanualtags}$\key{showmanualtags}=\texttt{true}\vert\texttt{false}$\\
+% \SpecialUsageIndex{\refeq}\cs{refeq}\marg{label}
+% \end{codesyntax}
+% An equation where the tag is produced with a manual \cs{tag*}
+% shouldn't be referenced with the normal \cs{eqref} because that
+% would format it according to the current tag format. Using just
+% \cs{ref} on the other hand may not be a good solution either as
+% the argument of \cs{tag*} is always set in upright shape in the
+% equation and you may be referencing it in italic text. In the
+% example below, the command \cs{refeq} is used to avoid what could
+% possibly lead to confusion in cases where the tag font has very
+% different form in upright and italic shape (here we switch to
+% Palatino in the example):
+% \begin{verbatim}
+% \begin{quote}\renewcommand*\rmdefault{ppl}\normalfont\itshape
+% \begin{equation*}
+% a=b \label{eq:example}\tag*{Q\&A}
+% \end{equation*}
+% See \ref{eq:example} or is it better with \refeq{eq:example}?
+% \end{quote}
+% \end{verbatim}
+% \begin{quote}\renewcommand*\rmdefault{ppl}\normalfont\itshape
+% \begin{equation*}
+% a=b \label{eq:example}\tag*{Q\&A}
+% \end{equation*}
+% See \ref{eq:example} or is it better with \refeq{eq:example}?
+% \end{quote}
+%
+%
+% Another problem sometimes faced is the need for showing the
+% equation numbers for only those equations actually referenced. In
+% \pkg{mathtools} this can be done by setting the key
+% \key{showonlyrefs} to either true or false by using
+% \cs{mathtoolsset}. You can also choose whether or not to show the
+% manual tags specified with \cs{tag} or \cs{tag*} by setting the
+% option \key{showmanualtags} to true or false.\footnote{I recommend
+% setting \key{showmanualtags} to true, else the whole idea of using
+% \cs{tag} doesn't really make sense, does it?} For both keys just
+% typing the name of it chooses true as shown in the following
+% example.
+%
+% \begin{verbatim}
+% \mathtoolsset{showonlyrefs,showmanualtags}
+% \usetagform{brackets}
+% \begin{gather}
+% a=a \label{eq:a} \\
+% b=b \label{eq:b} \tag{**}
+% \end{gather}
+% This should refer to the equation containing $a=a$: \eqref{eq:a}.
+% Then a switch of tag forms.
+% \usetagform{default}
+% \begin{align}
+% c&=c \label{eq:c} \\
+% d&=d \label{eq:d}
+% \end{align}
+% This should refer to the equation containing $d=d$: \eqref{eq:d}.
+% \begin{equation}
+% e=e
+% \end{equation}
+% Back to normal.\mathtoolsset{showonlyrefs=false}
+% \begin{equation}
+% f=f
+% \end{equation}
+% \end{verbatim}
+% \mathtoolsset{showonlyrefs,showmanualtags}
+% \usetagform{brackets}
+% \begin{gather}
+% a=a \label{eq:a} \\
+% b=b \label{eq:b} \tag{**}
+% \end{gather}
+% This should refer to the equation containing $a=a$: \eqref{eq:a}.
+% Then a switch of tag forms.
+% \usetagform{default}
+% \begin{align}
+% c&=c \label{eq:c} \\
+% d&=d \label{eq:d}
+% \end{align}
+% This should refer to the equation containing $d=d$: \eqref{eq:d}.
+% \begin{equation}
+% e=e
+% \end{equation}
+% Back to normal.\mathtoolsset{showonlyrefs=false}
+% \begin{equation}
+% f=f
+% \end{equation}
+%
+% Note that this feature only works if you use \cs{eqref} or
+% \cs{refeq} to reference your equations.
+%
+% \subsection{Extensible symbols}
+%
+% The number of horizontally extensible symbols in standard \LaTeX{}
+% and \pkg{amsmath} is somewhat low. This part of the manual
+% describes what \pkg{mathtools} does to help this situation.
+%
+% \subsubsection{Arrow-like symbols}
+%
+%
+% \begin{codesyntax}
+% \SpecialUsageIndex{\xleftrightarrow}
+% \cs{xleftrightarrow}\oarg{sub}\marg{sup}\texttt{~~~~~~~~~}
+% \SpecialUsageIndex{\xRightarrow}
+% \cs{xRightarrow}\oarg{sub}\marg{sup}\\
+% \SpecialUsageIndex{\xLeftarrow}
+% \cs{xLeftarrow}\oarg{sub}\marg{sup}\texttt{~~~~~~~~~~~~~~}
+% \SpecialUsageIndex{\xLeftrightarrow}
+% \cs{xLeftrightarrow}\oarg{sub}\marg{sup}\\
+% \SpecialUsageIndex{\xhookleftarrow}
+% \cs{xhookleftarrow}\oarg{sub}\marg{sup}\texttt{~~~~~~~~~~}
+% \SpecialUsageIndex{\xhookrightarrow}
+% \cs{xhookrightarrow}\oarg{sub}\marg{sup}\\
+% \SpecialUsageIndex{\xmapsto}
+% \cs{xmapsto}\oarg{sub}\marg{sup}
+% \end{codesyntax}
+% Extensible arrows are part of \pkg{amsmath} in the form of the
+% commands
+% \begin{quote}
+% \cs{xrightarrow}\oarg{subscript}\marg{superscript}\quad and\\
+% \cs{xleftarrow}\oarg{subscript}\marg{superscript}
+% \end{quote}
+% But what about extensible versions of say, \cs{leftrightarrow} or
+% \cs{Longleftarrow}? It turns out that the above mentioned
+% extensible arrows are the only two of their kind defined by
+% \pkg{amsmath}, but luckily \pkg{mathtools} helps with that. The
+% extensible arrow-like symbols in \pkg{mathtools} follow the same
+% naming scheme as the ones in \pkg{amsmath} so to get an extensible
+% \cs{Leftarrow} you simply do a
+% \begin{verbatim}
+% \[
+% A \xLeftarrow[under]{over} B
+% \]
+% \end{verbatim}
+% \[
+% A \xLeftarrow[under]{over} B
+% \]
+% \begin{codesyntax}
+% \SpecialUsageIndex{\xrightharpoondown}
+% \cs{xrightharpoondown}\oarg{sub}\marg{sup}\texttt{~~~~}
+% \SpecialUsageIndex{\xrightharpoonup}
+% \cs{xrightharpoonup}\oarg{sub}\marg{sup}\\
+% \SpecialUsageIndex{\xleftharpoondown}
+% \cs{xleftharpoondown}\oarg{sub}\marg{sup}\texttt{~~~~~}
+% \SpecialUsageIndex{\xleftharpoonup}
+% \cs{xleftharpoonup}\oarg{sub}\marg{sup}\\
+% \SpecialUsageIndex{\xrightleftharpoons}
+% \cs{xrightleftharpoons}\oarg{sub}\marg{sup}\texttt{~~~}
+% \SpecialUsageIndex{\xleftrightharpoons}
+% \cs{xleftrightharpoons}\oarg{sub}\marg{sup}
+% \end{codesyntax}
+% \pkg{mathtools} also provides the extensible harpoons shown above.
+% They're taken from~\cite{Voss:2004}.
+%
+% \subsubsection{Braces and brackets}
+%
+% \LaTeX{} defines other kinds of extensible symbols like
+% \cs{overbrace} and \cs{underbrace}, but sometimes you may want
+% another symbol, say, a bracket.
+% \begin{codesyntax}
+% \SpecialUsageIndex{\underbracket}\cs{underbracket}\oarg{rule thickness}
+% \oarg{bracket height}\marg{arg}\\
+% \SpecialUsageIndex{\overbracket}\cs{overbracket}\oarg{rule thickness}
+% \oarg{bracket height}\marg{arg}
+% \end{codesyntax}
+% The commands \cs{underbracket} and \cs{overbracket} are inspired
+% by \cite{Voss:2004}, although the implementation here is slightly
+% different.
+% Used without the optional arguments the bracket commands produce this:
+% \begin{quote}
+% |$\underbracket {foo\ bar}_{baz}$|\quad $\underbracket {foo\ bar}_{baz}$ \\
+% |$\overbracket {foo\ bar}^{baz}$ |\quad $\overbracket {foo\ bar}^{baz}$
+% \end{quote}
+% The default rule thickness is equal to that of \cs{underbrace}
+% (app.~$5/18$\,ex) while the default bracket height is equal to
+% app.~$0.7$\,ex. These values give really pleasing results in all
+% font sizes, but feel free to use the optional arguments. That way
+% you may get ``beauties'' like
+% \begin{verbatim}
+% \[
+% \underbracket[3pt]{xxx\ yyy}_{zzz} \quad \text{and} \quad
+% \underbracket[1pt][7pt]{xxx\ yyy}_{zzz}
+% \]
+% \end{verbatim}
+% \[
+% \underbracket[3pt]{xxx\ yyy}_{zzz} \quad \text{and} \quad
+% \underbracket[1pt][7pt]{xxx\ yyy}_{zzz}
+% \]
+% \begin{codesyntax}
+% \SpecialUsageIndex{\underbrace}\cs{underbrace}\marg{arg}\texttt{~~}
+% \SpecialUsageIndex{\LaTeXunderbrace}\cs{LaTeXunderbrace}\marg{arg}\\
+% \SpecialUsageIndex{\overbrace}\cs{overbrace}\marg{arg}\texttt{~~~}
+% \SpecialUsageIndex{\LaTeXoverbrace}\cs{LaTeXoverbrace}\marg{arg}
+% \end{codesyntax}
+% The standard implementation of the math operators \cs{underbrace}
+% and \cs{overbrace} in \LaTeX{} has some deficiencies. For example,
+% all lengths used internally are \emph{fixed} and optimized for
+% 10\,pt typesetting. As a direct consequence thereof, using font
+% sizes other than 10 will produce less than optimal results.
+% Another unfortunate feature is the size of the braces. In the
+% example below, notice how the math operator \cs{sum} places its
+% limit compared to \cs{underbrace}.
+% \[
+% \mathop{\thinboxed[blue]{\sum}}_{n}
+% \mathop{\thinboxed[blue]{\LaTeXunderbrace{\thinboxed[green]{foof}}}}_{zzz}
+% \]
+% The blue lines indicate the dimensions of the math operator and
+% the green lines the dimensions of $foof$. As you can see, there
+% seems to be too much space between the brace and the $zzz$ whereas
+% the space between brace and $foof$ is okay. Let's see what happens
+% when we use a bigger font size:\par\Huge\vskip-\baselineskip
+% \[
+% \mathop{\thinboxed[blue]{\sum}}_{n}
+% \mathop{\thinboxed[blue]{\LaTeXunderbrace{\thinboxed[green]{foof}}}}_{zzz}
+% \]
+% \normalsize Now there's to little space between the brace and the
+% $zzz$ and also too little space between the brace and the $foof$.
+% If you use Computer Modern you'll actually see that the $f$
+% overlaps with the brace! Let's try in \cs{footnotesize}:
+% \par\footnotesize
+% \[
+% \mathop{\thinboxed[blue]{\sum}}_{n}
+% \mathop{\thinboxed[blue]{\LaTeXunderbrace{\thinboxed[green]{foof}}}}_{zzz}
+% \]\normalsize
+% Here the spacing above and below the brace is quite excessive.
+%
+% As \cs{overbrace} has the exact same problems, there are good
+% reasons for \pkg{mathtools} to make redefinitions of
+% \cs{underbrace} and \cs{overbrace}. These new versions work
+% equally well in all font sizes and fixes the spacing issues and
+% apart from working with the default Computer Modern fonts, they
+% also work with the packages \pkg{mathpazo}, \pkg{pamath},
+% \pkg{fourier}, \pkg{eulervm}, \pkg{cmbright}, and \pkg{mathptmx}.
+% If you use the \pkg{ccfonts} to get the full Concrete fonts, the
+% original version saved under the names \cs{LaTeXunderbrace} and
+% \cs{LaTeXoverbrace} are better, due to of the special design of
+% the Concrete extensible braces. In that case you should probably
+% just add the lines
+% \begin{verbatim}
+% \let\underbrace\LaTeXunderbrace
+% \let\overbrace\LaTeXoverbrace
+% \end{verbatim}
+% to your preamble after loading \pkg{mathtools} which will restore
+% the original definitions of \cs{overbrace} and \cs{underbrace}.
+%
+%
+%
+% \subsection{New mathematical building blocks}
+%
+% In this part of the manual, various mathematical environments are
+% described.
+%
+% \subsubsection{Matrices}\label{subsubsec:matrices}
+%
+% \begin{codesyntax}
+% \SpecialEnvIndex{matrix*}\cs{begin}\arg{matrix*}\texttt{ }\oarg{col}
+% \meta{contents} \cs{end}\arg{matrix*}\\
+% \SpecialEnvIndex{pmatrix*}\cs{begin}\arg{pmatrix*}\oarg{col}
+% \meta{contents} \cs{end}\arg{pmatrix*}\\
+% \SpecialEnvIndex{bmatrix*}\cs{begin}\arg{bmatrix*}\oarg{col}
+% \meta{contents} \cs{end}\arg{bmatrix*}\\
+% \SpecialEnvIndex{Bmatrix*}\cs{begin}\arg{Bmatrix*}\oarg{col}
+% \meta{contents} \cs{end}\arg{Bmatrix*}\\
+% \SpecialEnvIndex{vmatrix*}\cs{begin}\arg{vmatrix*}\oarg{col}
+% \meta{contents} \cs{end}\arg{vmatrix*}\\
+% \SpecialEnvIndex{Vmatrix*}\cs{begin}\arg{Vmatrix*}\oarg{col}
+% \meta{contents} \cs{end}\arg{Vmatrix*}
+% \end{codesyntax}
+% \FeatureRequest{Lars Madsen}{2004/04/05}
+% All of the \pkg{amsmath} \env{matrix} environments center the
+% columns by default, which is not always what you want. Thus
+% \pkg{mathtools} provides a starred version for each of the original
+% environments. These starred environments take an optional argument
+% specifying the alignment of the columns, so that
+% \begin{verbatim}
+% \[
+% \begin{pmatrix*}[r]
+% -1 & 3 \\
+% 2 & -4
+% \end{pmatrix*}
+% \]
+% \end{verbatim}
+% yields
+% \[
+% \begin{pmatrix*}[r]
+% -1 & 3 \\
+% 2 & -4
+% \end{pmatrix*}
+% \]
+% The optional argument (default is \texttt{[c]}) can be any column
+% type valid in the usual \env{array} environment.
+%
+%
+%
+%
+% \subsubsection{The \env{multlined} environment}
+%
+% \begin{codesyntax}
+% \SpecialEnvIndex{multlined}\cs{begin}\arg{multlined}\oarg{pos}\oarg{width}
+% \meta{contents} \cs{end}\arg{multlined}\\
+% \SpecialUsageIndex{\shoveleft}\cs{shoveleft}\oarg{dimen}\marg{arg}\texttt{~~}
+% \SpecialUsageIndex{\shoveright}\cs{shoveright}\oarg{dimen}\marg{arg}\\
+% \makeatletter\settowidth\@tempdimc{\cs{shoveleft}\oarg{dimen}\marg{arg}}\global\@tempdimc\@tempdimc
+% \SpecialKeyIndex{firstline-afterskip}\makebox[\@tempdimc][l]{$\key{firstline-afterskip}=\meta{dimen}$}\texttt{~~}
+% \SpecialKeyIndex{lastline-preskip}$\key{lastline-preskip}=\meta{dimen}$\\
+% \makeatletter\SpecialKeyIndex{multlined-width}\makebox[\@tempdimc][l]{$\key{multlined-width}=\meta{dimen}$}\texttt{~~}
+% \SpecialKeyIndex{multlined-pos}$\key{multlined-pos}=\texttt{c}\vert\texttt{b}\vert\texttt{t}$
+% \end{codesyntax}
+% Some of the \pkg{amsmath} environments exist in two forms: an
+% outer and an inner environment. One example is the pair
+% \env{gather} \& \env{gathered}. There is one important omission on
+% this list however, as there is no inner \env{multlined}
+% environment, so this is where \pkg{mathtools} steps in.
+%
+% One might wonder what the sensible behavior should be. We want it
+% to be an inner environment so that it is not wider than necessary,
+% but on the other hand we would like to be able to control the
+% width. The current implementation of \env{multlined} handles both
+% cases. The idea is this: Set the first line flush left and add a
+% hard space after it; this space is governed by the
+% \key{firstline-afterskip} key. The last line should be set flush
+% right and preceded by a hard space of size \key{lastline-preskip}.
+% Both these hard spaces have a default value of \cs{multlinegap}.
+% Here we use a `t' in the first optional argument denoting a
+% top-aligned building block (the default is `c').
+% \begin{verbatim}
+% \[
+% A = \begin{multlined}[t]
+% \framebox[4cm]{first} \\
+% \framebox[4cm]{last}
+% \end{multlined} B
+% \]
+% \end{verbatim}
+% \[
+% A = \begin{multlined}[t]
+% \framebox[4cm]{first} \\
+% \framebox[4cm]{last}
+% \end{multlined} B
+% \]
+% Note also that \env{multlined} gives you access to an extended
+% syntax for \cs{shoveleft} and \cs{shoveright} as shown in the
+% example below.
+% \begin{verbatim}
+% \[
+% \begin{multlined}
+% \framebox[.65\columnwidth]{First line} \\
+% \framebox[.5\columnwidth]{Second line} \\
+% \shoveleft{L+E+F+T} \\
+% \shoveright{R+I+G+H+T} \\
+% \shoveleft[1cm]{L+E+F+T} \\
+% \shoveright[\widthof{$R+I+G+H+T$}]{R+I+G+H+T} \\
+% \framebox[.65\columnwidth]{Last line}
+% \end{multlined}
+% \]
+% \end{verbatim}
+% \[
+% \begin{multlined}
+% \framebox[.65\columnwidth]{First line} \\
+% \framebox[.5\columnwidth]{Second line} \\
+% \shoveleft{L+E+F+T} \\
+% \shoveright{R+I+G+H+T} \\
+% \shoveleft[1cm]{L+E+F+T} \\
+% \shoveright[\widthof{$R+I+G+H+T$}]{R+I+G+H+T} \\
+% \framebox[.65\columnwidth]{Last line}
+% \end{multlined}
+% \]
+%
+% You can also choose the width yourself by specifying it as an
+% optional argument:
+% \begin{verbatim}
+% \[
+% \begin{multlined}[b][7cm]
+% \framebox[4cm]{first} \\
+% \framebox[4cm]{last}
+% \end{multlined} = B
+% \]
+% \end{verbatim}
+% \[
+% \begin{multlined}[b][7cm]
+% \framebox[4cm]{first} \\
+% \framebox[4cm]{last}
+% \end{multlined} = B
+% \]
+% There can be two optional arguments (position and width) and
+% they're interchangeable.
+%
+% \subsubsection{More \env{cases}-like environments}
+%
+% \begin{codesyntax}
+% \SpecialEnvIndex{dcases}
+% \cs{begin}\arg{dcases}\texttt{~} \meta{math_column} |&| \meta{math_column}
+% \cs{end}\arg{dcases}\\
+% \SpecialEnvIndex{dcases*}
+% \cs{begin}\arg{dcases*} \meta{math_column} |&| \makebox[\widthof{\meta{math\_column}}][l]{\meta{text\_column}}
+% \cs{end}\arg{dcases*}
+% \end{codesyntax}
+% \FeatureRequest{Lars Madsen}{2004/07/01}
+% Anyone who have tried to use an integral in the regular
+% \env{cases} environment from \pkg{amsmath} will have noticed that
+% it is set as
+% \[
+% a=\begin{cases}
+% E = m c^2 & \text{Nothing to see here} \\
+% \int x-3\, dx & \text{Integral is text style}
+% \end{cases}
+% \]
+% \pkg{mathtools} provides two environments similar to \env{cases}.
+% Using the \env{dcases} environment you get the same output as with
+% \env{cases} except that the rows are set in display style.
+% \begin{verbatim}
+% \[
+% \begin{dcases}
+% E = m c^2 & c \approx 3.00\times 10^{8}\,\mathrm{m}/\mathrm{s} \\
+% \int x-3\, dx & \text{Integral is display style}
+% \end{dcases}
+% \]
+% \end{verbatim}
+% \[
+% \begin{dcases}
+% E = m c^2 & c \approx 3.00\times 10^{8}\,\mathrm{m}/\mathrm{s} \\
+% \int x-3\, dx & \text{Integral is display style}
+% \end{dcases}
+% \]
+% Additionally the environment \env{dcases*} acts just the same, but
+% the second column is set in the normal roman font of the
+% document.\footnote{Or rather: it inherits the font characteristics
+% active just before the \env{dcases*} environment.}
+% \begin{verbatim}
+% \[
+% a= \begin{dcases*}
+% E = m c^2 & Nothing to see here \\
+% \int x-3\, dx & Integral is display style
+% \end{dcases*}
+% \]
+% \end{verbatim}
+% \[
+% a= \begin{dcases*}
+% E = m c^2 & Nothing to see here \\
+% \int x-3\, dx & Integral is display style
+% \end{dcases*}
+% \]
+%
+% \subsection{Short intertext}
+%
+%
+% \begin{codesyntax}
+% \SpecialUsageIndex{\shortintertext}\cs{shortintertext}\marg{text}
+% \end{codesyntax}
+% \cttPosting{Gabriel Zachmann and Donald Arseneau}{2000/05/12--13}
+% \pkg{amsmath} provides the command \cs{intertext} for interrupting
+% a multi line display while still maintaining the alignment points.
+% However the spacing often seems quite excessive as seen below.
+% \begin{verbatim}
+% \begin{align}
+% a&=b \intertext{Some text}
+% c&=d
+% \end{align}
+% \end{verbatim}
+% \begin{align}
+% a&=b \intertext{Some text}
+% c&=d
+% \end{align}
+%
+% Using the command \cs{shortintertext} alleviates this situation
+% somewhat:
+% \begin{verbatim}
+% \begin{align}
+% a&=b \shortintertext{Some text}
+% c&=d
+% \end{align}
+% \end{verbatim}
+% \begin{align}
+% a&=b \shortintertext{Some text}
+% c&=d
+% \end{align}
+%
+%
+%
+%
+%
+% \subsection{Paired delimiters}
+%
+%
+% \begin{codesyntax}
+% \SpecialUsageIndex{\DeclarePairedDelimiter}
+% \cs{DeclarePairedDelimiter}\marg{cmd}\marg{left_delim}\marg{right_delim}
+% \end{codesyntax}
+% \FeatureRequest{Lars Madsen}{2004/06/25}
+% In the \pkg{amsmath} documentation it is shown how to define a few
+% commands for typesetting the absolute value and norm. These
+% definitions are:
+% \begin{verbatim}
+% \newcommand*\abs[1]{\lvert#1\rvert}
+% \newcommand*\norm[1]{\lVert#1\rVert}
+% \end{verbatim}
+% \DeclarePairedDelimiter\abs\lvert\rvert
+% While they produce correct horizontal spacing you have to be
+% careful about the vertical spacing if the argument is just a
+% little taller than usual as in
+% \[
+% \abs{\frac{a}{b}}
+% \]
+% Here it won't give a nice result, so you have to manually put in
+% either \cs{left}--\cs{right} pair or a \cs{bigl}--\cs{bigr} pair.
+% Both methods mean that you have to delete your \cs{abs} command,
+% which may not sound like an ideal solution.
+%
+% With the command \cs{DeclarePairedDelimiter} you can combine all
+% these features in one easy to use command. Let's show an example:
+% \begin{verbatim}
+% \DeclarePairedDelimiter\abs{\lvert}{\rvert}
+% \end{verbatim}
+% This defines the command \cs{abs} just like in the
+% \pkg{amsmath} documentation but with a few additions:
+% \begin{itemize}
+% \item A starred variant: \cs{abs*} produces delimiters that are preceded
+% by \cs{left} and \cs{right} resp.:
+% \begin{verbatim}
+% \[
+% \abs*{\frac{a}{b}}
+% \]
+% \end{verbatim}
+% \[
+% \abs*{\frac{a}{b}}
+% \]
+% \item A variant with an optional argument:
+% \cs{abs}\oarg{size_cmd}, where
+% \meta{size_cmd} is either \cs{big}, \cs{Big}, \cs{bigg}, or
+% \cs{Bigg} (if you have any bigggger versions you can use them
+% too).
+% \begin{verbatim}
+% \[
+% \abs[\Bigg]{\frac{a}{b}}
+% \]
+% \end{verbatim}
+% \[
+% \abs[\Bigg]{\frac{a}{b}}
+% \]
+% \end{itemize}
+%
+%
+%
+% \subsection{Special symbols}
+%
+% This part of the manual is about special symbols. So far only one
+% technique is covered, but more will come.
+%
+% \subsubsection{Left and right parentheses}
+%
+% \begin{codesyntax}
+% \SpecialUsageIndex{\lparen}\cs{lparen}\texttt{~~}
+% \SpecialUsageIndex{\rparen}\cs{rparen}
+% \end{codesyntax}
+% When you want a big parenthesis or bracket in a math display you
+% usually just type
+% \begin{quote}
+% |\left( ... \right)|\quad or\quad |\left[ ... \right]|
+% \end{quote}
+% \LaTeX{} also defines the macro names \cs{lbrack} and \cs{rbrack}
+% to be shorthands for the left and right square bracket resp., but
+% doesn't provide similar definitions for the parentheses. Some
+% packages need command names to work with\footnote{The \pkg{empheq}
+% package needs command names for delimiters in order to make
+% auto-scaling versions.} so \pkg{mathtools} defines the commands
+% \cs{lparen} and \cs{rparen} to represent the left and right
+% parenthesis resp.
+%
+%
+% \subsubsection{Vertically centered colon}
+%
+% \begin{codesyntax}
+% \SpecialKeyIndex{centercolon}$\key{centercolon}=\texttt{true}\vert\texttt{false}$\\
+% \SpecialUsageIndex{\vcentcolon}\cs{vcentcolon}\texttt{~~}
+% \SpecialUsageIndex{\ordinarycolon}\cs{ordinarycolon}
+% \end{codesyntax}
+% \cttPosting{Donald Arseneau}{2000/12/07}
+% When trying to show assignment operations as in $ a := b $, one
+% quickly notices that the colon is not centered on the math axis as
+% the equal sign, leading to an odd-looking output. The command
+% \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$.
+%
+% Typing \cs{vcentcolon} every time is quite tedious, so one can use
+% the key \key{centercolon} to make the colon active instead.
+% \begin{verbatim}
+% \mathtoolsset{centercolon}
+% \[
+% a := b
+% \]
+% \mathtoolsset{centercolon=false}
+% \end{verbatim}
+% \[\mathtoolsset{centercolon}
+% a := b
+% \]
+% In this case the command \cs{ordinarycolon} typesets an~\ldots\
+% ordinary colon (what a surprise).
+%
+% \begin{codesyntax}
+% \SpecialUsageIndex{\coloneqq}\cs{coloneqq}\texttt{~~~~~}
+% \SpecialUsageIndex{\Coloneqq}\cs{Coloneqq}\texttt{~~~~~}
+% \SpecialUsageIndex{\coloneq}\cs{coloneq}\texttt{~~~}
+% \SpecialUsageIndex{\Coloneq}\cs{Coloneqq}\\
+% \SpecialUsageIndex{\eqqcolon}\cs{eqqcolon}\texttt{~~~~~}
+% \SpecialUsageIndex{\Eqqcolon}\cs{Eqqcolon}\texttt{~~~~~}
+% \SpecialUsageIndex{\eqcolon}\cs{eqcolon}\texttt{~~~}
+% \SpecialUsageIndex{\Eqcolon}\cs{Eqcolon}\\
+% \SpecialUsageIndex{\colonapprox}\cs{colonapprox}\texttt{~~}
+% \SpecialUsageIndex{\Colonapprox}\cs{Colonapprox}\texttt{~~}
+% \SpecialUsageIndex{\colonsim}\cs{colonsim}\texttt{~~}
+% \SpecialUsageIndex{\Colonsim}\cs{Colonsim}\\
+% \SpecialUsageIndex{\dblcolon}\cs{dblcolon}
+% \end{codesyntax}
+% The font packages \pkg{txfonts} and \pkg{pxfonts} provides various
+% symbols that include a vertically centered colon but with tighter
+% spacing. For example, the combination |:=| exists as the symbol
+% \cs{coloneqq} which typesets as $\coloneqq$ instead of
+% $\vcentcolon=$. The primary disadvantage of using these fonts are
+% the support packages' lack of support for \pkg{amsmath} (and thus
+% \pkg{mathtools}) and worse yet, the side-bearings are way too
+% tight; see~\cite{A-W:MG04} for examples. If you're not using these
+% fonts, \pkg{mathtools} provides the symbols for you. Here are a few
+% examples:
+% \begin{verbatim}
+% \[
+% a \coloneqq b \quad c \Colonapprox d \quad e \dblcolon f
+% \]
+% \end{verbatim}
+% \[
+% a \coloneqq b \quad c \Colonapprox d \quad e \dblcolon f
+% \]
+%
+% \section{A tribute to Michael J.~Downes}
+%
+% Michael J.~Downes (1958--2003) was one of the major architects
+% behind \pkg{amsmath} and member of the \LaTeX{} Team. He made many
+% great contributions to the \TeX{} community; not only by the means
+% of widely spread macro packages such as \pkg{amsmath} but also in
+% the form of actively giving advice on newsgroups. Some of
+% Michael's macro solutions on the newsgroups never made it into
+% publicly available macro packages although they certainly deserved
+% it, so \pkg{mathtools} tries to rectify this matter. The macros
+% described in this section are either straight copies or heavily
+% inspired by his original postings.
+%
+% \subsection{Mathematics within italic text}
+%
+% \begin{codesyntax}
+% \SpecialKeyIndex{mathic}$\key{mathic}=\texttt{true}\vert\texttt{false}$
+% \end{codesyntax}
+% \cttPosting{Michael J.~Downes}{1998/05/14}
+% \TeX{} usually takes care of italic corrections in text, but fails
+% when it comes to math. If you use the \LaTeX{} inline math
+% commands \cs{(} and \cs{)} you can however work around it by
+% setting the key \key{mathic} to true as shown below.
+% \begin{verbatim}
+% \begin{quote}\itshape
+% Compare these lines: \par
+% \mathtoolsset{mathic} % or \mathtoolsset{mathic=true}
+% Subset of \(V\) and subset of \(A\). \par
+% \mathtoolsset{mathic=false}
+% Subset of \(V\) and subset of \(A\).
+% \par
+% \end{quote}
+% \end{verbatim}
+% \begin{quote}\itshape
+% Compare these lines: \par
+% \mathtoolsset{mathic}
+% Subset of \(V\) and subset of \(A\). \par
+% \mathtoolsset{mathic=false}
+% Subset of \(V\) and subset of \(A\).
+% \par
+% \end{quote}
+%
+% \subsection{Left sub/superscripts}
+%
+% \begin{codesyntax}
+% \SpecialUsageIndex{\prescript}
+% \cs{prescript}\marg{sup}\marg{sub}\marg{arg}\texttt{~~}
+% \SpecialKeyIndex{prescript-sup-format}
+% $\key{prescript-sup-format}=\meta{cmd}$\\
+% \SpecialKeyIndex{prescript-sub-format}
+% $\key{prescript-sub-format}=\meta{cmd}$\hfill
+% \SpecialKeyIndex{prescript-arg-format}
+% \rlap{$\key{prescript-arg-format}=\meta{cmd}$}^^A
+% \phantom{$\key{prescript-sup-format}=\meta{cmd}$}
+% \end{codesyntax}
+% \cttPosting{Michael J.~Downes}{2000/12/20}
+% Sometimes one wants to put a sub- or superscript on the left of
+% the argument. The \cs{prescript} command does just that:
+% \begin{verbatim}
+% \[
+% {}^{4}_{12}\mathbf{C}^{5+}_{2} \quad
+% \prescript{14}{2}{\mathbf{C}}^{5+}_{2} \quad
+% \prescript{4}{12}{\mathbf{C}}^{5+}_{2} \quad
+% \prescript{14}{}{\mathbf{C}}^{5+}_{2} \quad
+% \prescript{}{2}{\mathbf{C}}^{5+}_{2}
+% \]
+% \end{verbatim}
+% \[
+% {}^{4}_{12}\mathbf{C}^{5+}_{2} \quad
+% \prescript{14}{2}{\mathbf{C}}^{5+}_{2} \quad
+% \prescript{4}{12}{\mathbf{C}}^{5+}_{2} \quad
+% \prescript{14}{}{\mathbf{C}}^{5+}_{2} \quad
+% \prescript{}{2}{\mathbf{C}}^{5+}_{2}
+% \]
+%
+% The formatting of the arguments is controlled by three keys. This
+% silly example shows you how to use them:
+% \begin{verbatim}
+% \newcommand*\myisotope[3]{%
+% \begingroup % to keep changes local. We cannot use a brace group
+% % as it affects spacing!
+% \mathtoolsset{
+% prescript-sup-format=\mathit,
+% prescript-sub-format=\mathbf,
+% prescript-arg-format=\mathrm,
+% }%
+% \prescript{#1}{#2}{#3}%
+% \endgroup
+% }
+% \[
+% \myisotope{A}{Z}{X}\to \myisotope{A-4}{Z-2}{Y}+
+% \myisotope{4}{2}{\alpha}
+% \]
+% \end{verbatim}
+% \newcommand*\myisotope[3]{%
+% \begingroup
+% \mathtoolsset{
+% prescript-sup-format=\mathit,
+% prescript-sub-format=\mathbf,
+% prescript-arg-format=\mathrm,
+% }%
+% \prescript{#1}{#2}{#3}%
+% \endgroup
+% }
+% \[
+% \myisotope{A}{Z}{X}\to \myisotope{A-4}{Z-2}{Y}+
+% \myisotope{4}{2}{\alpha}
+% \]
+%
+%
+% \subsection{Declaring math sizes}
+%
+% \begin{codesyntax}
+% \SpecialUsageIndex{\DeclareMathSizes}
+% \cs{DeclareMathSizes}\marg{dimen}\marg{dimen}\marg{dimen}\marg{dimen}
+% \end{codesyntax}
+% \cttPosting{Michael J.~Downes}{2002/10/17}
+% If you don't know about \cs{DeclareMathSizes}, then skip the rest
+% of this text. If you do know, then all that is needed to say is
+% that with \pkg{mathtools} it is patched so that all regular
+% dimension suffixes are now valid in the last three arguments. Thus
+% a declaration such as
+% \begin{verbatim}
+% \DeclareMathSize{9.5dd}{9.5dd}{7.5dd}{6.5dd}
+% \end{verbatim}
+% will now work (it doesn't in standard \LaTeX). When this bug has
+% been fixed in \LaTeX, this fix will be removed from
+% \pkg{mathtools}.
+%
+% \subsection{Spreading equations}
+%
+% \begin{codesyntax}
+% \SpecialEnvIndex{spreadlines}
+% \cs{begin}\arg{spreadlines}\marg{dimen} \meta{contents}
+% \cs{end}\arg{spreadlines}
+% \end{codesyntax}
+% \cttPosting{Michael J.~Downes}{2002/10/17}
+% The spacing between lines in a multi line math environment such as
+% \env{gather} is governed by the dimension \cs{jot}. The
+% \env{spreadlines} environment takes one argument denoting the
+% value of \cs{jot} inside the environment:
+% \begin{verbatim}
+% \begin{spreadlines}{20pt}
+% Large spaces between the lines.
+% \begin{gather}
+% a=b\\
+% c=d
+% \end{gather}
+% \end{spreadlines}
+% Back to normal spacing.
+% \begin{gather}
+% a=b\\
+% c=d
+% \end{gather}
+% \end{verbatim}
+% \begin{spreadlines}{20pt}
+% Large spaces between the lines.
+% \begin{gather}
+% a=b\\
+% c=d
+% \end{gather}
+% \end{spreadlines}
+% Back to normal spacing.
+% \begin{gather}
+% a=b\\
+% c=d
+% \end{gather}
+%
+%
+% \subsection{Gathered environments}\label{subsec:gathered}
+%
+% \begin{codesyntax}
+% \SpecialEnvIndex{lgathered}\cs{begin}\arg{lgathered}\oarg{pos}
+% \meta{contents} \cs{end}\arg{lgathered} \\
+% \SpecialEnvIndex{rgathered}\cs{begin}\arg{rgathered}\oarg{pos}
+% \meta{contents} \cs{end}\arg{rgathered} \\
+% \SpecialUsageIndex{\newgathered}\cs{newgathered}\marg{name}\marg{pre_line}\marg{post_line}\marg{after}\\
+% \SpecialUsageIndex{\renewgathered}\cs{renewgathered}\marg{name}\marg{pre_line}\marg{post_line}\marg{after}
+% \end{codesyntax}
+% \cttPosting{Michael J.~Downes}{2001/01/17}
+% In a document set in \opt{fleqn}, you might sometimes want an
+% inner \env{gathered} environment that doesn't center its lines but
+% puts them flush left. The \env{lgathered} environment works just
+% like the standard \env{gathered} except that it flushes its
+% contents left:
+% \begin{verbatim}
+% \begin{equation}
+% \begin{lgathered}
+% x=1,\quad x+1=2 \\
+% y=2
+% \end{lgathered}
+% \end{equation}
+% \end{verbatim}
+% \begin{equation}
+% \begin{lgathered}
+% x=1,\quad x+1=2 \\
+% y=2
+% \end{lgathered}
+% \end{equation}
+% Similarly the \env{rgathered} puts it contents flush right.
+%
+% More interesting is probably the command \cs{newgathered}. In this
+% example we define a gathered version that centers the lines and
+% also prints a star and a number at the left of each line.
+% \begin{verbatim}
+% \newcounter{steplinecnt}
+% \newcommand\stepline{\stepcounter{steplinecnt}\thesteplinecnt}
+% \newgathered{stargathered}
+% {\llap{\stepline}$*$\quad\hfil}% \hfil for centering
+% {\hfil}% \hfil for centering
+% {\setcounter{steplinecnt}{0}}% reset counter
+% \end{verbatim}
+% \newcounter{steplinecnt}
+% \newcommand\stepline{\stepcounter{steplinecnt}\thesteplinecnt}
+% \newgathered{stargathered}{\llap{\stepline}$*$\quad\hfil}{\hfil}{\setcounter{steplinecnt}{0}}
+% With these definitions we can get something like this:
+% \begin{verbatim}
+% \begin{gather}
+% \begin{stargathered}
+% x=1,\quad x+1=2 \\
+% y=2
+% \end{stargathered}
+% \end{gather}
+% \end{verbatim}
+% \begin{gather}
+% \begin{stargathered}
+% x=1,\quad x+1=2 \\
+% y=2
+% \end{stargathered}
+% \end{gather}
+% \cs{renewgathered} renews a gathered environment of course.
+%
+% In all fairness it should be stated that the original concept by
+% Michael has been extended quite a bit in \pkg{mathtools}. Only the
+% end product of \env{lgathered} is the same.
+%
+% \subsection{Split fractions}
+%
+% \begin{codesyntax}
+% \SpecialUsageIndex{\splitfrac}\cs{splitfrac}\marg{numer}\marg{denom}\texttt{~~}
+% \SpecialUsageIndex{\splitdfrac}\cs{splitdfrac}\marg{numer}\marg{denom}
+% \end{codesyntax}
+% \cttPosting{Michael J.~Downes}{2001/12/06}
+% These commands provide split fractions e.g., multi line fractions:
+% \begin{verbatim}
+% \[
+% a=\frac{
+% \splitfrac{xy + xy + xy + xy + xy}
+% {+ xy + xy + xy + xy}
+% }
+% {z}
+% =\frac{
+% \splitdfrac{xy + xy + xy + xy + xy}
+% {+ xy + xy + xy + xy}
+% }
+% {z}
+% \]
+% \end{verbatim}
+% \[
+% a=\frac{
+% \splitfrac{xy + xy + xy + xy + xy}
+% {+ xy + xy + xy + xy}
+% }
+% {z}
+% =\frac{
+% \splitdfrac{xy + xy + xy + xy + xy}
+% {+ xy + xy + xy + xy}
+% }
+% {z}
+% \]
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+%
+% \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{A-W:MG04}
+% Frank Mittelbach and Michel Goossens.
+% \emph{The {\LaTeX} Companion}.
+% Tools and Techniques for Computer Typesetting. Addison-Wesley,
+% 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}.)
+%
+% \end{thebibliography}
+%
+%
+% \StopEventually{}
+%
+%
+% \section{Options and package loading}
+%
+%
+% Lets start the package.
+% \begin{macrocode}
+%<*package>
+% \end{macrocode}
+% \begin{macrocode}
+\RequirePackage{keyval,calc}
+\RequirePackage{mhsetup}[2004/10/10]
+\MHInternalSyntaxOn
+% \end{macrocode}
+%
+% \begin{macro}{\MT_options_name:}
+% \begin{macro}{\mathtoolsset}
+% The name for the options and a user interface for setting keys.
+% \begin{macrocode}
+\def\MT_options_name:{mathtools}
+\newcommand*\mathtoolsset[1]{\setkeys{\MT_options_name:}{#1}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% Fix \pkg{amsmath} bugs (strongly recommended!). It requires a
+% great deal of typing to avoid fixing the bugs. He he.
+% \begin{macrocode}
+\MH_new_boolean:n {fixamsmath}
+\DeclareOption{fixamsmath}{
+ \MH_set_boolean_T:n {fixamsmath}
+}
+\DeclareOption{donotfixamsmathbugs}{
+ \MH_set_boolean_F:n {fixamsmath}
+}
+% \end{macrocode}
+% Disallow spaces before optional arguments in certain \pkg{amsmath}
+% building blocks.
+% \begin{macrocode}
+\DeclareOption{allowspaces}{
+ \MH_let:NwN \MaybeMHPrecedingSpacesOff
+ \relax
+ \MH_let:NwN \MH_maybe_nospace_ifnextchar:Nnn \kernel@ifnextchar
+}
+\DeclareOption{disallowspaces}{
+ \MH_let:NwN \MaybeMHPrecedingSpacesOff
+ \MHPrecedingSpacesOff
+ \MH_let:NwN \MH_maybe_nospace_ifnextchar:Nnn \MH_nospace_ifnextchar:Nnn
+}
+% \end{macrocode}
+% Pass all other options directly to \pkg{amsmath}.
+% \begin{macrocode}
+\DeclareOption*{
+ \PassOptionsToPackage{\CurrentOption}{amsmath}
+}
+\ExecuteOptions{fixamsmath,disallowspaces}
+\ProcessOptions\relax
+% \end{macrocode}
+% We have to turn off the new syntax when \pkg{amstext} is loaded.
+% \begin{macrocode}
+\MHInternalSyntaxOff
+\RequirePackage{amsmath}[2000/07/18]
+\MHInternalSyntaxOn
+\AtEndOfPackage{\MHInternalSyntaxOff}
+% \end{macrocode}
+% \begin{macro}{\MT_true_false_error:}
+% Make sure the user selects either `true' or `false' when asked too.
+% \begin{macrocode}
+\def\MT_true_false_error:{
+ \PackageError{mathtools}
+ {You~ have~ to~ select~ either~ `true'~ or~ `false'}
+ {I'll~ assume~ you~ chose~ `false'~ for~ now.}
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \section{Macros I got ideas for myself}
+%
+%
+%
+% \subsection{Tag forms}
+% This is quite simple, but why isn't it then a part of some widely
+% distributed package? Beats me.
+%
+% \begin{macro}{\MT_define_tagform:nwnn}
+% We start out by defining a command that will allow us to define
+% commands similar to \cs{tagform@} only this will give us tag form
+% \emph{types}. The actual code is very similar to the one in
+% \pkg{amsmath}.
+% \begin{macrocode}
+\def\MT_define_tagform:nwnn #1[#2]#3#4{
+ \@namedef{MT_tagform_#1:n}##1
+ {\maketag@@@{#3\ignorespaces#2{##1}\unskip\@@italiccorr#4}}
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\newtagform}
+% Similar to \cs{newcommand}. Check if defined and scan for presence
+% of optional argument. Then call generic command.
+% \begin{macrocode}
+\providecommand*\newtagform[1]{%
+ \@ifundefined{MT_tagform_#1:n}
+ {\@ifnextchar[%
+ {\MT_define_tagform:nwnn #1}%
+ {\MT_define_tagform:nwnn #1[]}%
+ }{\PackageError{mathtools}
+ {The~ tag~ form~ `#1'~ is~ already~ defined\MessageBreak
+ You~ probably~ want~ to~ look~ up~ \@backslashchar renewtagform~
+ instead}
+ {I~ will~ just~ ignore~ your~ wish~ for~ now.}}
+}
+% \end{macrocode}
+% Provide a default tag form which---surprise, surprise---is
+% identical to the standard definition.
+% \begin{macrocode}
+\newtagform{default}{(}{)}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\renewtagform}
+% Similar to \cs{renewcommand}.
+% \begin{macrocode}
+\providecommand*\renewtagform[1]{%
+ \@ifundefined{MT_tagform_#1:n}
+ {\PackageError{mathtools}
+ {The~ tag~ form~ `#1'~ is~ not~ defined\MessageBreak
+ You~ probably~ want~ to~ look~ up~ \@backslashchar newtagform~ instead}
+ {I~ will~ just~ ignore~ your~ wish~ for~ now.}}
+ {\@ifnextchar[%
+ {\MT_define_tagform:nwnn #1}%
+ {\MT_define_tagform:nwnn #1[]}%
+ }
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\usetagform}
+% Then the activator. Test if the tag form is defined and then
+% activate it by redefining \cs{tagform@}.
+% \begin{macrocode}
+\providecommand*\usetagform[1]{%
+ \@ifundefined{MT_tagform_#1:n}
+ {
+ \PackageError{mathtools}{%
+ You~ have~ chosen~ the~ tag~ form~ `#1'\MessageBreak
+ but~ it~ appears~ to~ be~ undefined}
+ {I~ will~ use~ the~ default~ tag~ form~ instead.}%
+ \@namedef{tagform@}{\@nameuse{MT_tagform_default:n}}
+ }
+ { \@namedef{tagform@}{\@nameuse{MT_tagform_#1:n}} }
+% \end{macrocode}
+% Here we patch if we're using the special ``show only referenced
+% equations'' feature.
+% \begin{macrocode}
+ \MH_if_boolean:nT {show_only_refs}{
+ \MH_let:NwN \MT_prev_tagform:n \tagform@
+ \def\tagform@##1{\MT_extended_tagform:n {##1}}
+ }
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Showing only referenced tags}
+% A little more interesting is the way to print only the equation
+% numbers that are actually referenced.
+%
+% A few booleans to help determine which situations we're in.
+% \begin{macrocode}
+\MH_new_boolean:n {manual_tag}
+\MH_new_boolean:n {raw_maketag}
+% \end{macrocode}
+% \begin{macro}{\MT_AmS_tag_in_align:}
+% \begin{macro}{\tag@in@align}
+% \begin{macro}{\tag@in@display}
+% We'll need to know when the user has put in a manual tag, and since
+% \cs{tag} is \cs{let} to all sorts of things inside the \pkg{amsmath}
+% code it is safer to provide a small hack to the functions it is copied
+% from. Note that we can't use \cs{iftag@}.
+% \begin{macrocode}
+\MH_let:NwN \MT_AmS_tag_in_align: \tag@in@align
+\def\tag@in@align{
+ \global\MH_set_boolean_T:n {manual_tag}
+ \MT_AmS_tag_in_align:
+}
+\def\tag@in@display#1#{
+ \relax
+ \global\MH_set_boolean_T:n {manual_tag}
+ \tag@in@display@a{#1}
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\MT_extended_tagform:n}
+% \changes{v1.01}{2004/08/03}{Simplified quite a bit}
+% The extended version of \cs{tagform@}.
+% \begin{macrocode}
+\def\MT_extended_tagform:n #1{
+ \MH_set_boolean_F:n {raw_maketag}
+% \end{macrocode}
+% We test if the equation was labelled. We already know if it was tagged
+% manually.
+% \begin{macrocode}
+ \if_meaning:NN \df@label\@empty
+ \MH_if_boolean:nT {manual_tag}
+ { \MH_if_boolean:nTF {show_manual_tags}
+ { \MT_prev_tagform:n {#1} }
+ { \stepcounter{equation} }
+ }
+ \else:
+ \MH_if_boolean:nTF {manual_tag}
+ { \MH_if_boolean:nTF {show_manual_tags}
+ { \MT_prev_tagform:n {#1} }
+ { \@ifundefined{MT_r_\df@label}
+ { }
+ { \MT_prev_tagform:n {#1} }
+ }
+ }
+ { \@ifundefined{MT_r_\df@label}
+ { }
+ { \refstepcounter{equation}\MT_prev_tagform:n {#1} }
+ }
+ \fi:
+ \global\MH_set_boolean_T:n {raw_maketag}
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\MT_extended_maketag:n}
+% The extended version of \cs{maketag@@@}.
+% \begin{macrocode}
+\def\MT_extended_maketag:n #1{
+ \ifx\df@label\@empty
+ \MT_maketag:n {#1}
+ \else:
+ \MH_if_boolean:nTF {raw_maketag}
+ {
+ \MH_if_boolean:nTF {show_manual_tags}
+ { \MT_maketag:n {#1} }
+ { \@ifundefined{MT_r_\df@label}
+ { }
+ { \MT_maketag:n {#1} }
+ }
+ }
+ { \MT_maketag:n {#1} }
+ \fi:
+% \end{macrocode}
+% As this function is always called we let it set the marker for a manual
+% tag false when exiting.
+% \begin{macrocode}
+ \global\MH_set_boolean_F:n {manual_tag}
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\MT_extended_eqref:n}
+% \changes{v1.01}{2004/08/03}{Make it robust}
+% We let \cs{eqref} write the label to the \file{aux} file, which is
+% read at the beginning of the next run. Then we print the equation
+% number as usual.
+% \begin{macrocode}
+\def\MT_extended_eqref:n #1{
+ \protected@write\@auxout{}
+ {\string\MT@newlabel{#1}}
+ \textup{\MT_prev_tagform:n {\ref{#1}}}
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\refeq}
+% \begin{macro}{\MT_extended_refeq:n}
+% Similar to \cs{eqref} and \cs{MT_extended_eqref:n}.
+% \begin{macrocode}
+\newcommand*\refeq[1]{
+ \textup{\ref{#1}}
+}
+\def\MT_extended_refeq:n #1{
+ \protected@write\@auxout{}
+ {\string\MT@newlabel{#1}}
+ \textup{\ref{#1}}
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\MT@newlabel}
+% We can't use |:| or |_| in the command name (yet). We define the
+% special labels for the equations that have been referenced in the
+% previous run.
+% \begin{macrocode}
+\newcommand*\MT@newlabel[1]{ \global\@namedef{MT_r_#1}{} }
+% \end{macrocode}
+% \end{macro}
+% \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:}
+ { \MT_true_false_error:
+ \@nameuse{boolean_show_manual_tags_false:}
+ }
+ { \@nameuse{boolean_show_manual_tags_#1:} }
+}
+% \end{macrocode}
+% \begin{macro}{\MT_showonlyrefs_true:}
+% The implementation is based on the idea that \cs{tagform@} can be
+% called in two circumstances: when the tag is being printed in the
+% equation and when it is being printed during a reference.
+% \begin{macrocode}
+\newcommand*\MT_showonlyrefs_true:{
+ \MH_if_boolean:nF {show_only_refs}{
+ \MH_set_boolean_T:n {show_only_refs}
+% \end{macrocode}
+% Save the definitions of the original commands.
+% \begin{macrocode}
+ \MH_let:NwN \MT_incr_eqnum: \incr@eqnum
+ \MH_let:NwN \incr@eqnum \@empty
+ \MH_let:NwN \MT_array_parbox_restore: \@arrayparboxrestore
+ \@xp\def\@xp\@arrayparboxrestore\@xp{\@arrayparboxrestore
+ \MH_let:NwN \incr@eqnum \@empty
+ }
+ \MH_let:NwN \MT_prev_tagform:n \tagform@
+ \MH_let:NwN \MT_eqref:n \eqref
+ \MH_let:NwN \MT_refeq:n \refeq
+ \MH_let:NwN \MT_maketag:n \maketag@@@
+ \MH_let:NwN \maketag@@@ \MT_extended_maketag:n
+% \end{macrocode}
+% We redefine \cs{tagform@}.
+% \begin{macrocode}
+ \def\tagform@##1{\MT_extended_tagform:n {##1}}
+% \end{macrocode}
+% Then \cs{eqref}:
+% \begin{macrocode}
+ \MH_let:NwN \eqref \MT_extended_eqref:n
+ \MH_let:NwN \refeq \MT_extended_refeq:n
+ }
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\MT_showonlyrefs_false:}
+% This macro reverts the settings.
+% \begin{macrocode}
+\def\MT_showonlyrefs_false: {
+ \MH_if_boolean:nT {show_only_refs}{
+ \MH_set_boolean_F:n {show_only_refs}
+ \MH_let:NwN \tagform@ \MT_prev_tagform:n
+ \MH_let:NwN \eqref \MT_eqref:n
+ \MH_let:NwN \refeq \MT_refeq:n
+ \MH_let:NwN \maketag@@@ \MT_maketag:n
+ \MH_let:NwN \incr@eqnum \MT_incr_eqnum:
+ \MH_let:NwN \@arrayparboxrestore \MT_array_parbox_restore:
+ }
+}
+\define@key{\MT_options_name:}{showonlyrefs}[true]{
+ \@nameuse{MT_showonlyrefs_#1:}
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\nonumber}
+% \changes{v1.01}{2004/08/03}{Fixed using \cs{notag} or \cs{nonumber}
+% with the \key{showonlyrefs} feature}
+% We have to redefine \cs{nonumber} else it will subtract one from the
+% 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.
+% \begin{macrocode}
+\renewcommand\nonumber{
+ \if@eqnsw
+ \if_meaning:NN \incr@eqnum\@empty
+% \end{macrocode}
+% Only subtract the number if |show_only_refs| is false.
+% \begin{macrocode}
+ \MH_if_boolean:nF {show_only_refs}
+ {\addtocounter{equation}\m@ne}
+ \fi:
+ \fi:
+ \MH_let:NwN \print@eqnum\@empty \MH_let:NwN \incr@eqnum\@empty
+ \global\@eqnswfalse
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Extensible arrows etc.}
+%
+% \begin{macro}{\xleftrightarrow}
+% \begin{macro}{\MT_leftrightarrow_fill:}
+% \begin{macro}{\xLeftarrow}
+% \begin{macro}{\xRightarrow}
+% \begin{macro}{\xLeftrightarrow}
+%
+% These are straight adaptions from \pkg{amsmath}.
+% \begin{macrocode}
+\providecommand*\xleftrightarrow[2][]{%
+ \ext@arrow 3095\MT_leftrightarrow_fill:{#1}{#2}}
+\def\MT_leftrightarrow_fill:{%
+ \arrowfill@\leftarrow\relbar\rightarrow}
+\providecommand*\xLeftarrow[2][]{%
+ \ext@arrow 0055{\Leftarrowfill@}{#1}{#2}}
+\providecommand*\xRightarrow[2][]{%
+ \ext@arrow 0055{\Rightarrowfill@}{#1}{#2}}
+\providecommand*\xLeftrightarrow[2][]{%
+ \ext@arrow 0055{\Leftrightarrowfill@}{#1}{#2}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\MT_rightharpoondown_fill:}
+% \begin{macro}{\MT_rightharpoonup_fill:}
+% \begin{macro}{\MT_leftharpoondown_fill:}
+% \begin{macro}{\MT_leftharpoonup_fill:}
+% \begin{macro}{\xrightharpoondown}
+% \begin{macro}{\xrightharpoonup}
+% \begin{macro}{\xleftharpoondown}
+% \begin{macro}{\xleftharpoonup}
+% \begin{macro}{\xleftrightharpoons}
+% \begin{macro}{\xrightleftharpoons}
+% The harpoons.
+% \begin{macrocode}
+\def\MT_rightharpoondown_fill:{%
+ \arrowfill@\relbar\relbar\rightharpoondown}
+\def\MT_rightharpoonup_fill:{%
+ \arrowfill@\relbar\relbar\rightharpoonup}
+\def\MT_leftharpoondown_fill:{%
+ \arrowfill@\leftharpoondown\relbar\relbar}
+\def\MT_leftharpoonup_fill:{%
+ \arrowfill@\leftharpoonup\relbar\relbar}
+\providecommand*\xrightharpoondown[2][]{%
+ \ext@arrow 0359\MT_rightharpoondown_fill:{#1}{#2}}
+\providecommand*\xrightharpoonup[2][]{%
+ \ext@arrow 0359\MT_rightharpoonup_fill:{#1}{#2}}
+\providecommand*\xleftharpoondown[2][]{%
+ \ext@arrow 3095\MT_leftharpoondown_fill:{#1}{#2}}
+\providecommand*\xleftharpoonup[2][]{%
+ \ext@arrow 3095\MT_leftharpoonup_fill:{#1}{#2}}
+\providecommand*\xleftrightharpoons[2][]{\mathrel{%
+ \raise.22ex\hbox{%
+ $\ext@arrow 3095\MT_leftharpoonup_fill:{\phantom{#1}}{#2}$}%
+ \setbox0=\hbox{%
+ $\ext@arrow 0359\MT_rightharpoondown_fill:{#1}{\phantom{#2}}$}%
+ \kern-\wd0 \lower.22ex\box0}}
+\providecommand*\xrightleftharpoons[2][]{\mathrel{%
+ \raise.22ex\hbox{%
+ $\ext@arrow 3095\MT_rightharpoonup_fill:{\phantom{#1}}{#2}$}%
+ \setbox0=\hbox{%
+ $\ext@arrow 0359\MT_leftharpoondown_fill:{#1}{\phantom{#2}}$}%
+ \kern-\wd0 \lower.22ex\box0}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\xhookleftarrow}
+% \begin{macro}{\xhookrightarrow}
+% \begin{macro}{\MT_hookright_fill:}
+% The hooks.
+% \begin{macrocode}
+\providecommand*\xhookleftarrow[2][]{%
+ \ext@arrow 3095\MT_hookleft_fill:{#1}{#2}}
+\def\MT_hookleft_fill:{%
+ \arrowfill@\leftarrow\relbar{\relbar\joinrel\rhook}}
+\providecommand*\xhookrightarrow[2][]{%
+ \ext@arrow 3095\MT_hookright_fill:{#1}{#2}}
+\def\MT_hookright_fill:{%
+ \arrowfill@{\lhook\joinrel\relbar}\relbar\rightarrow}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\xmapsto}
+% \begin{macro}{\MT_mapsto_fill:}
+% The maps-to arrow.
+% \begin{macrocode}
+\providecommand*\xmapsto[2][]{%
+ \ext@arrow 0395\MT_mapsto_fill:{#1}{#2}}
+\def\MT_mapsto_fill:{%
+ \arrowfill@{\mapstochar\relbar}\relbar\rightarrow}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \subsection{Underbrackets etc.}
+% \begin{macro}{\underbracket}
+% \begin{macro}{\MT_underbracket_I:w}
+% \begin{macro}{\MT_underbracket_II:w}
+% \begin{macro}{\upbracketfill}
+% \begin{macro}{\upbracketend}
+% The \cs{underbracket} macro. Scan for two optional arguments. When
+% \pkg{xparse} becomes the standard this will be so much easier.
+% \begin{macrocode}
+\providecommand*\underbracket{
+ \@ifnextchar[
+ {\MT_underbracket_I:w}
+ {\MT_underbracket_I:w[\l_MT_bracketheight_fdim]}}
+\def\MT_underbracket_I:w[#1]{
+ \@ifnextchar[
+ {\MT_underbracket_II:w[#1]}
+ {\MT_underbracket_II:w[#1][.7\fontdimen5\textfont2]}}
+\def\MT_underbracket_II:w[#1][#2]#3{%
+ \mathop{\vtop{\m@th\ialign{##
+ \crcr
+ $\hfil\displaystyle{#3}\hfil$%
+ \crcr
+ \noalign{\kern .2\fontdimen5\textfont2 \nointerlineskip}%
+ \upbracketfill {#1}{#2}%
+ \crcr}}}
+ \limits}
+\def\upbracketfill#1#2{%
+ \sbox\z@{$\braceld$}
+ \edef\l_MT_bracketheight_fdim{\the\ht\z@}%
+ \upbracketend{#1}{#2}
+ \leaders \vrule \@height \z@ \@depth #1 \hfill
+ \upbracketend{#1}{#2}%
+}
+\def\upbracketend#1#2{\vrule \@height #2 \@width #1\relax}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\overbracket}
+% \begin{macro}{\MT_overbracket_I:w}
+% \begin{macro}{\MT_overbracket_II:w}
+% \begin{macro}{\downbracketfill}
+% \begin{macro}{\downbracketend}
+% The overbracket is quite similar.
+% \begin{macrocode}
+\providecommand*\overbracket{
+ \@ifnextchar[
+ {\MT_overbracket_I:w}
+ {\MT_overbracket_I:w[\l_MT_bracketheight_fdim]}}
+\def\MT_overbracket_I:w[#1]{
+ \@ifnextchar[
+ {\MT_overbracket_II:w[#1]}
+ {\MT_overbracket_II:w[#1][.7\fontdimen5\textfont2]}}
+\def\MT_overbracket_II:w[#1][#2]#3{%
+ \mathop{\vbox{\m@th\ialign{##
+ \crcr
+ \downbracketfill{#1}{#2}%
+ \crcr
+ \noalign{\kern .2\fontdimen5\textfont2 \nointerlineskip}%
+ $\hfil\displaystyle{#3}\hfil$
+ \crcr}}}%
+ \limits}
+\def\downbracketfill#1#2{%
+ \sbox\z@{$\braceld$}\edef\l_MT_bracketheight_fdim{\the\ht\z@}
+ \downbracketend{#1}{#2}
+ \leaders \vrule \@height #1 \@depth \z@ \hfill
+ \downbracketend{#1}{#2}%
+}
+\def\downbracketend#1#2{\vrule \@width #1\@depth #2\relax}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\LaTeXunderbrace}
+% \begin{macro}{\underbrace}
+% Redefinition of \cs{underbrace} and \cs{overbrace}.
+% \begin{macrocode}
+\MH_let:NwN \LaTeXunderbrace \underbrace
+\def\underbrace#1{\mathop{\vtop{\m@th\ialign{##\crcr
+ $\hfil\displaystyle{#1}\hfil$\crcr
+ \noalign{\kern.7\fontdimen5\textfont2\nointerlineskip}%
+% \end{macrocode}
+% |.5\fontdimen5\textfont2| is the height of the tip of the brace.
+% the remaining |.2\fontdimen5\textfont2| is for space between
+% \begin{macrocode}
+ \upbracefill\crcr\noalign{\kern.5\fontdimen5\textfont2}}}}\limits}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\LaTeXoverbrace}
+% \begin{macro}{\overbrace}
+% Same technique for \cs{overbrace}.
+% \begin{macrocode}
+\MH_let:NwN \LaTeXoverbrace \overbrace
+\def\overbrace#1{\mathop{\vbox{\m@th\ialign{##\crcr
+ \noalign{\kern.5\fontdimen5\textfont2}%
+% \end{macrocode}
+% Adjust for tip height
+% \begin{macrocode}
+ \downbracefill\crcr
+ \noalign{\kern.7\fontdimen5\textfont2\nointerlineskip}%
+% \end{macrocode}
+% |.5\fontdimen5\textfont2| is the height of the tip of the brace.
+% The remaining |.2\fontdimen5\textfont2| is for space between
+% \begin{macrocode}
+ $\hfil\displaystyle{#1}\hfil$\crcr}}}\limits}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%
+%
+%
+%
+% \subsection{Special symbols}
+%
+% \subsubsection{Command names for parentheses}
+% \begin{macro}{\lparen}
+% \begin{macro}{\rparen}
+% Just an addition to the \LaTeXe\ kernel.
+% \begin{macrocode}
+\providecommand*\lparen{(}
+\providecommand*\rparen{)}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+
+% \subsubsection{Vertically centered colon}
+%
+% \begin{macro}{\vcentcolon}
+% \begin{macro}{\ordinarycolon}
+% \begin{macro}{\MT_active_colon_true:}
+% \begin{macro}{\MT_active_colon_false:}
+% This is from the hands of Donald Arseneau. Somehow it is not
+% distributed, so I include it here. Here's the original text by
+% Donald:
+% \begin{verbatim}
+% centercolon.sty Dec 7, 2000
+% Donald Arseneau asnd@triumf.ca
+% Public domain.
+% Vertically center colon characters (:) in math mode.
+% Particularly useful for $ a:=b$, and still correct for
+% $f : x\to y$. May be used in any TeX.
+% \end{verbatim}
+% \begin{macrocode}
+\def\vcentcolon{\mathrel{\mathop\ordinarycolon}}
+\begingroup
+ \catcode`\:=\active
+ \lowercase{\endgroup
+ \ifnum\mathcode`\:=32768\relax
+ \let\ordinarycolon= :%
+ \else
+ \mathchardef\ordinarycolon\mathcode`\: %
+ \fi
+ \let :\vcentcolon
+ }
+\MH_new_boolean:n {center_colon}
+\define@key{\MT_options_name:}{centercolon}[true]{
+ \@ifundefined{MT_active_colon_#1:}
+ { \MT_true_false_error:n
+ \@nameuse{MT_active_colon_false:}
+ }
+ { \@nameuse{MT_active_colon_#1:} }
+}
+\def\MT_active_colon_true: {
+ \MH_if_boolean:nF {center_colon}{
+ \MH_set_boolean_T:n {center_colon}
+ \edef\MT_active_colon_false:
+ {\mathcode`\noexpand\:=\the\mathcode`\:\relax}
+ \mathcode`\:=32768
+ }
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\dblcolon}
+% \begin{macro}{\coloneqq}
+% \begin{macro}{\Coloneqq}
+% \begin{macro}{\coloneq}
+% \begin{macro}{\Coloneq}
+% \begin{macro}{\eqqcolon}
+% \begin{macro}{\Eqqcolon}
+% \begin{macro}{\eqcolon}
+% \begin{macro}{\Eqcolon}
+% \begin{macro}{\colonapprox}
+% \begin{macro}{\Colonapprox}
+% \begin{macro}{\colonsim}
+% \begin{macro}{\Colonsim}
+% This is just to simulate all the \cs{..colon..} symbols from
+% \pkg{txfonts} and \pkg{pxfonts}.
+% \begin{macrocode}
+\AtBeginDocument{
+ \providecommand*\dblcolon{\vcentcolon\mkern-.9mu\vcentcolon}
+ \providecommand*\coloneqq{\vcentcolon\mkern-1.2mu=}
+ \providecommand*\Coloneqq{\dblcolon\mkern-1.2mu=}
+ \providecommand*\coloneq{\vcentcolon\mkern-1.2mu\mathrel{-}}
+ \providecommand*\Coloneq{\dblcolon\mkern-1.2mu\mathrel{-}}
+ \providecommand*\eqqcolon{=\mkern-1.2mu\vcentcolon}
+ \providecommand*\Eqqcolon{=\mkern-1.2mu\dblcolon}
+ \providecommand*\eqcolon{\mathrel{-}\mkern-1.2mu\vcentcolon}
+ \providecommand*\Eqcolon{\mathrel{-}\mkern-1.2mu\dblcolon}
+ \providecommand*\colonapprox{\vcentcolon\mkern-1.2mu\approx}
+ \providecommand*\Colonapprox{\dblcolon\mkern-1.2mu\approx}
+ \providecommand*\colonsim{\vcentcolon\mkern-1.2mu\sim}
+ \providecommand*\Colonsim{\dblcolon\mkern-1.2mu\sim}
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+%
+% \subsection{Multlined}
+%
+% \begin{macro}{\g_MT_multlinerow_int}
+% \begin{macro}{\l_MT_multwidth_dim}
+% Helpers.
+% \begin{macrocode}
+\MH_new_boolean:n {mult_firstline}
+\MH_new_boolean:n {outer_mult}
+\newcount\g_MT_multlinerow_int
+\newdimen\l_MT_multwidth_dim
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \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.
+% \begin{macrocode}
+\newcommand*\MT_test_for_tcb_other:nnnnn [1]{
+ \if:w t#1\relax
+ \expandafter\MH_use_choice_i:nnnn
+ \else:
+ \if:w c#1\relax
+ \expandafter\expandafter\expandafter\MH_use_choice_ii:nnnn
+ \else:
+ \if:w b#1\relax
+ \expandafter\expandafter\expandafter
+ \expandafter\expandafter\expandafter\expandafter
+ \MH_use_choice_iii:nnnn
+ \else:
+ \expandafter\expandafter\expandafter
+ \expandafter\expandafter\expandafter\expandafter
+ \MH_use_choice_iv:nnnn
+ \fi:
+ \fi:
+ \fi:
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\MT_mult_invisible_line:}
+% An invisible line.
+% \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}
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\MT_mult_mathcr_atat:w}
+% The normal \cs{math@cr@@} with our hooks.
+% \begin{macrocode}
+\def\MT_mult_mathcr_atat:w [#1]{%
+ \if_num:w 0=`{\fi: \iffalse}\fi:
+ \MH_if_boolean:nT {mult_firstline}{
+ \kern\l_MT_mult_left_fdim
+ \MT_mult_invisible_line:
+ }
+ \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_let:NwN \math@cr@@\MT_mult_last_mathcr:w
+ \fi:
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\MT_mult_firstandlast_mathcr:w}
+% 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.
+% \begin{macrocode}
+\def\MT_mult_firstandlast_mathcr:w [#1]{%
+ \if_num:w 0=`{\fi: \iffalse}\fi:
+ \kern\l_MT_mult_left_fdim
+ \MT_mult_invisible_line:
+ \noalign{\vskip#1\relax}
+ \kern\l_MT_mult_right_fdim
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\MT_mult_last_mathcr:w}
+% The normal last \cs{math@cr@@} which inserts the last kern.
+% \begin{macrocode}
+\def\MT_mult_last_mathcr:w [#1]{
+ \if_num:w 0=`{\fi: \iffalse}\fi:\math@cr@@@
+ \noalign{\vskip#1\relax}
+ \kern\l_MT_mult_right_fdim}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\MT_start_mult:N}
+% Setup for \env{multlined}. Finds the position.
+% \begin{macrocode}
+\newcommand\MT_start_mult:N [1]{
+ \MT_test_for_tcb_other:nnnnn {#1}
+ { \MH_let:NwN \MT_next:\vtop }
+ { \MH_let:NwN \MT_next:\vcenter }
+ { \MH_let:NwN \MT_next:\vbox }
+ {
+ \PackageError{mathtools}
+ {Invalid~ position~ specifier.~ I'll~ try~ to~ recover~ with~
+ `c'}\@ehc
+ }
+ \collect@body\MT_mult_internal:n
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\MT_shoveright:wn}
+% \begin{macro}{\MT_shoveleft:wn}
+% Extended versions of \cs{shoveleft} and \cs{shoveright}.
+% \begin{macrocode}
+\newcommand*\MT_shoveright:wn [2][0pt]{%
+ #2\hfilneg
+ \setlength\@tempdima{#1}
+ \kern\@tempdima
+}
+\newcommand*\MT_shoveleft:wn [2][0pt]{%
+ \hfilneg
+ \setlength\@tempdima{#1}
+ \kern\@tempdima
+ #2
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \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}.
+% \begin{macrocode}
+\newcommand*\MT_mult_internal:n [1]{
+ \MH_if_boolean:nF {outer_mult}{\null\,}
+ \MT_next:
+ \bgroup
+% \end{macrocode}
+% Restore the meaning of \cmd{\\} inside \env{multlined}, else it
+% wouldn't work in the \env{equation} environment. Set the fake row
+% counter to zero.
+% \begin{macrocode}
+ \Let@
+ \def\l_MT_multline_lastline_fint{0 }
+ \chardef\dspbrk@context\@ne \restore@math@cr
+% \end{macrocode}
+% Use private versions.
+% \begin{macrocode}
+ \MH_let:NwN \math@cr@@\MT_mult_mathcr_atat:w
+ \MH_let:NwN \shoveleft\MT_shoveleft:wn
+ \MH_let:NwN \shoveright\MT_shoveright:wn
+ \spread@equation
+ \MH_set_boolean_F:n {mult_firstline}
+% \end{macrocode}
+% Do some measuring.
+% \begin{macrocode}
+ \MT_measure_mult:n {#1}
+% \end{macrocode}
+% Make sure the box is wide enough.
+% \begin{macrocode}
+ \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.
+% \begin{macrocode}
+ \if_num:w \l_MT_multline_lastline_fint=\@ne
+ \MH_let:NwN \math@cr@@ \MT_mult_firstandlast_mathcr:w
+ \fi:
+% \end{macrocode}
+% Do the typesetting.
+% \begin{macrocode}
+ \ialign\bgroup
+ \hfil\strut@$\m@th\displaystyle{}##$\hfil
+ \crcr
+ \hfilneg
+ #1
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\MT_measure_mult:n}
+% \changes{v1.01a}{2004/10/10}{Added Ord atom to beginning of each line}
+% Measuring. Disable all labelling and check the number of lines.
+% \begin{macrocode}
+\newcommand\MT_measure_mult:n [1]{
+ \begingroup
+ \g_MT_multlinerow_int\@ne
+ \MH_let:NwN \label\MT_gobblelabel:w
+ \MH_let:NwN \tag\gobble@tag
+ \setbox\z@\vbox{
+ \ialign{\strut@$\m@th\displaystyle{}##$
+ \crcr
+ #1
+ \crcr
+ }
+ }
+ \xdef\l_MT_multline_measure_fdim{\the\wdz@}
+ \advance\g_MT_multlinerow_int\m@ne
+ \xdef\l_MT_multline_lastline_fint{\number\g_MT_multlinerow_int}
+ \endgroup
+ \g_MT_multlinerow_int\@ne
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\MT_multlined_second_arg:w}
+% Scan for a second optional argument.
+% \begin{macrocode}
+\MaybeMHPrecedingSpacesOff
+\newcommand*\MT_multlined_second_arg:w [1][\@empty]{
+ \MT_test_for_tcb_other:nnnnn {#1}
+ {\def\MT_mult_default_pos:{#1}}
+ {\def\MT_mult_default_pos:{#1}}
+ {\def\MT_mult_default_pos:{#1}}
+ {
+ \if_meaning:NN \@empty#1\@empty
+ \else:
+ \setlength \l_MT_multwidth_dim{#1}
+ \fi:
+ }
+ \MT_start_mult:N \MT_mult_default_pos:
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{environment}{multlined}
+% The user environment. Scan for an optional argument.
+% \begin{macrocode}
+\newenvironment{multlined}[1][]
+ {
+ \MT_test_for_tcb_other:nnnnn {#1}
+ {\def\MT_mult_default_pos:{#1}}
+ {\def\MT_mult_default_pos:{#1}}
+ {\def\MT_mult_default_pos:{#1}}
+ {
+ \if_meaning:NN \@empty#1\@empty
+ \else:
+ \setlength \l_MT_multwidth_dim{#1}
+ \fi:
+ }
+ \MT_multlined_second_arg:w
+ }
+ {
+ \hfilneg \endaligned
+ }
+\MHPrecedingSpacesOn
+% \end{macrocode}
+% \end{environment}
+% The keys needed.
+% \begin{macrocode}
+\define@key{\MT_options_name:}
+ {firstline-afterskip}{\def\l_MT_mult_left_fdim{#1}}
+\define@key{\MT_options_name:}
+ {lastline-preskip}{\def\l_MT_mult_right_fdim{#1}}
+\define@key{\MT_options_name:}
+ {multlined-width}{\setlength \l_MT_multwidth_dim{#1}}
+\define@key{\MT_options_name:}
+ {multlined-pos}{\def\MT_mult_default_pos:{#1}}
+\setkeys{\MT_options_name:}{
+ firstline-afterskip=\multlinegap,
+ lastline-preskip=\multlinegap,
+ multlined-width=0pt,
+ multlined-pos=c,
+}
+% \end{macrocode}
+% \begin{macro}{\MT_gobblelabel:w}
+% Better than to assume that \cs{label} has exactly one mandatory
+% argument, hence the \texttt{w} specifier.
+% \begin{macrocode}
+\def\MT_gobblelabel:w #1{}
+% \end{macrocode}
+% \end{macro}
+%
+%
+%
+%
+% \section{Macros suggested/requested by Lars Madsen}
+%
+% The macros in this section are all requests made by Lars Madsen.
+%
+% \subsection{Paired delimiters}
+%
+% \begin{macro}{\DeclarePairedDelimiter}
+% This macro defines |#1| to be a control sequence that takes either
+% a star or an optional argument.
+% \begin{macrocode}
+\newcommand*\DeclarePairedDelimiter[3]{%
+ \@ifdefinable{#1}{
+ \edef\MT_next: {\MH_cs_to_str:N #1}
+% \end{macrocode}
+% Define the starred command to just put \cs{left} and \cs{right}
+% before the delimiters.
+% \begin{macrocode}
+ \@namedef{MT_delim_\MT_next: _star:}##1
+ {\left#2 ##1 \right #3}%
+% \end{macrocode}
+% The command with optional argument. It should be \cs{bigg} or
+% alike.
+% \begin{macrocode}
+ \@xp\@xp\@xp
+ \newcommand
+ \@xp\csname MT_delim_\MT_next: _nostar:\endcsname[2][\\@gobble]
+ { \edef\MT_next: {\MH_cs_to_str:N ##1}
+% \end{macrocode}
+% With the default optional argument we wind up with \cs{relax},
+% else we get \cs{biggr} and \cs{biggl} etc.
+% \begin{macrocode}
+ \@nameuse {\MT_next: l} #2 ##2 \@nameuse {\MT_next: r} #3}
+% \end{macrocode}
+% The user command comes here. Just check for the star and choose
+% the right internal command.
+% \begin{macrocode}
+ \newcommand{#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}
+%
+% \begin{macro}{\MT_start_cases:nn}
+% We define a single command that does all the hard work.
+% \begin{macrocode}
+\def\MT_start_cases:nn #1#2{
+ \RIfM@\else
+ \nonmatherr@{\begin{\@currenvir}}%
+ \fi
+% \end{macrocode}
+% Put in the brace and center the contents (nothing else makes
+% sense).
+% \begin{macrocode}
+ \left\lbrace
+ \vcenter \bgroup
+ \Let@ \chardef\dspbrk@context\@ne \restore@math@cr
+ \spread@equation
+ \ialign\bgroup
+% \end{macrocode}
+% Set the first column flush left in \cs{displaystyle} math and the
+% second as specified by the second argument. The first argument is
+% the separation between the columns. It could be a \cs{quad} or
+% something entirely different.
+% \begin{macrocode}
+ \strut@$\m@th\displaystyle{##}$\hfil&#1\strut@
+% \end{macrocode}
+% Insert the specification of the second column.
+% \begin{macrocode}
+ #2
+ \crcr
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\newcases}
+% \begin{macro}{\renewcases}
+% Easy creation of new \env{cases}-like environments.
+% \begin{macrocode}
+\newcommand*\newcases[3]{
+ \newenvironment{#1}
+ {\MT_start_cases:nn {#2}{#3}}
+ {\endaligned\right.}
+}
+\newcommand*\renewcases[3]{
+ \renewenvironment{#1}
+ {\MT_start_cases:nn {#2}{#3}}
+ {\endaligned\right.}
+}
+% \end{macrocode}
+% \begin{environment}{dcases}
+% \begin{environment}{dcases*}
+% \env{dcases} is a traditional cases with display style math in
+% both columns, while \env{dcases*} has text in the second column.
+% \begin{macrocode}
+\newcases{dcases}{\quad}{$\m@th\displaystyle{##}$\hfil}
+\newcases{dcases*}{\quad}{{##}\hfil}
+% \end{macrocode}
+% \end{environment}
+% \end{environment}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{New matrix environments}
+% \begin{macro}{\MT_matrix_begin:N}
+% \begin{macro}{\MT_matrix_end:}
+% Here are a few helpers for the matrices. \cs{MT_matrix_begin:N}
+% takes one argument specifying the column type for the array inside
+% the matrix. and \cs{MT_matrix_end:} inserts the correct ending.
+% \begin{macrocode}
+\def\MT_matrix_begin:N #1{%
+ \hskip -\arraycolsep
+ \MH_let:NwN \@ifnextchar \MH_nospace_ifnextchar:Nnn
+ \array{*\c@MaxMatrixCols #1}}
+\def\MT_matrix_end:{\endarray \hskip -\arraycolsep}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% Before we define the environments we better make sure that spaces
+% before the optional argument is disallowed. Else a user who types
+% \begin{verbatim}
+% \[
+% \begin{pmatrix*}
+% [c] & a \\
+% b & d
+% \end{pmatrix*}
+% \]
+% \end{verbatim}
+% will lose the \texttt{[c]}!
+% \begin{macrocode}
+\MaybeMHPrecedingSpacesOff
+% \end{macrocode}
+% \begin{environment}{matrix*}
+% This environment is just like \env{matrix} only it takes an
+% optional argument specifying the column type.
+% \begin{macrocode}
+\newenvironment{matrix*}[1][c]
+ {\MT_matrix_begin:N #1}
+ {\MT_matrix_end:}
+% \end{macrocode}
+% \end{environment}
+% \begin{environment}{pmatrix*}
+% \begin{environment}{bmatrix*}
+% \begin{environment}{Bmatrix*}
+% \begin{environment}{vmatrix*}
+% \begin{environment}{Vmatrix*}
+% Then starred versions of the other \AmS{} matrices.
+% \begin{macrocode}
+\newenvironment{pmatrix*}[1][c]
+ {\left(\MT_matrix_begin:N #1}
+ {\MT_matrix_end:\right)}
+\newenvironment{bmatrix*}[1][c]
+ {\left[\MT_matrix_begin:N #1}
+ {\MT_matrix_end:\right]}
+\newenvironment{Bmatrix*}[1][c]
+ {\left\lbrace\MT_matrix_begin:N #1}
+ {\MT_matrix_end:\right\rbrace}
+\newenvironment{vmatrix*}[1][c]
+ {\left\lvert\MT_matrix_begin:N #1}
+ {\MT_matrix_end:\right\rvert}
+\newenvironment{Vmatrix*}[1][c]
+ {\left\lVert\MT_matrix_begin:N #1}
+ {\MT_matrix_end:\right\lVert}
+% \end{macrocode}
+% Restore the usual behavior.
+% \begin{macrocode}
+\MHPrecedingSpacesOn
+% \end{macrocode}
+% \end{environment}
+% \end{environment}
+% \end{environment}
+% \end{environment}
+% \end{environment}
+%
+%
+% \subsection{Smashing an operator with limits}
+%
+% \begin{macro}{\smashoperator}
+% The user command. Define \cs{MT_smop_use:NNNNN} to be one of the
+% specialized commands \cs{MT_smop_smash_l:NNNNN},
+% \cs{MT_smop_smash_r:NNNNN}, or the default
+% \cs{MT_smop_smash_lr:NNNNN}.
+% \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
+ \the\toks@\@nil\@nil\@nil\@nil\@nil\@nil\@@nil
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\MT_smop_remove_nil_vi:N}
+% \begin{macro}{\MT_smop_mathop:n}
+% \begin{macro}{\MT_smop_limits:}
+% Some helper functions.
+% \begin{macrocode}
+\def\MT_smop_remove_nil_vi:N #1\@nil\@nil\@nil\@nil\@nil\@nil{#1}
+\def\MT_smop_mathop:n {\mathop}
+\def\MT_smop_limits: {\limits}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% Some conditionals.
+% \begin{macrocode}
+\MH_new_boolean:n {smop_one}
+\MH_new_boolean:n {smop_two}
+% \end{macrocode}
+% \begin{macro}{\MT_smop_get_args:wwwNnNn}
+% The argument stripping. There are three different valid types of
+% input:
+% \begin{enumerate}
+% \item An operator with neither subscript nor superscript.
+% \item An operator with one subscript or superscript.
+% \item An operator with both subscript and superscript.
+% \end{enumerate}
+% Additionally an operator can be either a single macro as in
+% \cs{sum} or in \cs{mathop}\arg{A} and people might be tempted to
+% put a \cs{limits} after the operator, even though it's not
+% necessary. Thus the input with most tokens would be something like
+% \begin{verbatim}
+% \mathop{TTT}\limits_{sub}^{sup}
+% \end{verbatim}
+% Therefore we have to scan for seven arguments, but there might
+% only be one actually. So let's list the possible situations:
+% \begin{enumerate}
+% \item \verb|\mathop{TTT}\limits_{subsub}^{supsup}|
+% \item \verb|\mathop{TTT}_{subsub}^{supsup}|
+% \item \verb|\sum\limits_{subsub}^{supsup}|
+% \item \verb|\sum_{subsub}^{supsup}|
+% \end{enumerate}
+% Furthermore the |_{subsub}^{supsup}| part can also just be
+% |_{subsub}| or empty.
+% \begin{macrocode}
+\def\MT_smop_get_args:wwwNnNn #1#2#3#4#5#6#7\@@nil{%
+ \begingroup
+ \def\MT_smop_arg_A: {#1} \def\MT_smop_arg_B: {#2}
+ \def\MT_smop_arg_C: {#3} \def\MT_smop_arg_D: {#4}
+ \def\MT_smop_arg_E: {#5} \def\MT_smop_arg_F: {#6}
+ \def\MT_smop_arg_G: {#7}
+% \end{macrocode}
+% Check if A is \cs{mathop}. If it is, we know that B is the argument
+% of the \cs{mathop}.
+% \begin{macrocode}
+ \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}
+% \begin{macrocode}
+ \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}.
+% \begin{macrocode}
+ \if_meaning:NN \MT_smop_arg_D: \@nnil
+ \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_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:
+% \end{macrocode}
+% Here we have something like \verb|\mathop{TTT}|. Still check
+% if D is \cs{@nil}.
+% \begin{macrocode}
+ \def\MT_smop_final_arg_A:{#1{#2}}%
+ \if_meaning:NN \MT_smop_arg_D: \@nnil
+ \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_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:
+% \end{macrocode}
+% If A was not \cs{mathop}, it is an operator in itself, so we check
+% if B is \cs{limits}
+% \begin{macrocode}
+ \else:
+ \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_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_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:
+% \end{macrocode}
+% No \cs{limits} was found, so we already have the right input. Just
+% forget about the last two arguments.
+% \begin{macrocode}
+ \def\MT_smop_final_arg_A:{#1}%
+ \if_meaning:NN \MT_smop_arg_C: \@nnil
+ \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_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:
+% \end{macrocode}
+% No reason to measure if there's no sub or sup.
+% \begin{macrocode}
+ \MH_if_boolean:nT {smop_one}{
+ \MT_smop_measure:NNNNN
+ \MT_smop_final_arg_A: \MT_smop_final_arg_B: \MT_smop_final_arg_C:
+ \MT_smop_final_arg_D: \MT_smop_final_arg_E:
+ }
+ \MT_smop_use:NNNNN
+ \MT_smop_final_arg_A: \MT_smop_final_arg_B: \MT_smop_final_arg_C:
+ \MT_smop_final_arg_D: \MT_smop_final_arg_E:
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+% Typeset what is necessary and ignore width of sub and sup:
+% \begin{macrocode}
+\def\MT_smop_needed_args:NNNNN #1#2#3#4#5{%
+ \displaystyle #1
+ \MH_if_boolean:nT {smop_one}{
+% \end{macrocode}
+% Let's use the internal versions of \cs{crampedclap} now that we now
+% it is set in \cs{scriptstyle}.
+% \begin{macrocode}
+ \limits#2{\MT_cramped_clap_internal:Nn \scriptstyle{#3}}
+ \MH_if_boolean:nT {smop_two}{
+ #4{\MT_cramped_clap_internal:Nn \scriptstyle{#5}}
+ }
+ }
+}
+% \end{macrocode}
+% Measure the natural width. \cs{@tempdima} holds the dimen we need to
+% adjust it all with.
+% \begin{macrocode}
+\def\MT_smop_measure:NNNNN #1#2#3#4#5{%
+ \MH_let:NwN \MT_saved_mathclap:Nn \MT_cramped_clap_internal:Nn
+ \MH_let:NwN \MT_cramped_clap_internal:Nn \@secondoftwo
+ \sbox\z@{$\m@th\MT_smop_needed_args:NNNNN #1#2#3#4#5$}
+ \MH_let:NwN \MT_cramped_clap_internal:Nn \MT_saved_mathclap:Nn
+ \sbox\tw@{$\m@th\displaystyle#1$}
+ \@tempdima=.5\wd0
+ \advance\@tempdima-.5\wd2
+}
+% \end{macrocode}
+% The `l' variant
+% \begin{macrocode}
+\def\MT_smop_smash_l:NNNNN #1#2#3#4#5{
+ \MT_smop_needed_args:NNNNN #1#2#3#4#5\kern\@tempdima
+}
+% \end{macrocode}
+% The `r' variant
+% \begin{macrocode}
+\def\MT_smop_smash_r:NNNNN #1#2#3#4#5{
+ \kern\@tempdima\MT_smop_needed_args:NNNNN #1#2#3#4#5
+}
+% \end{macrocode}
+% The `lr' variant
+% \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}
+%
+%
+% \subsection{Adjusting limits}
+%
+%
+% \begin{macro}{\MT_vphantom:Nn}
+% \begin{macro}{\MT_hphantom:Nn}
+% \begin{macro}{\MT_phantom:Nn}
+% \begin{macro}{\MT_internal_phantom:N}
+% The main advantage of \cs{phantom} et al., is the ability to
+% choose the right size automatically, but it requires the input to
+% be typeset four times. Since we will need to have a \cs{cramped}
+% inside a \cs{vphantom} it is much, much faster to choose the style
+% ourselves (we already know it). These macros make it possible.
+% \begin{macrocode}
+\def\MT_vphantom:Nn {\v@true\h@false\MT_internal_phantom:N}
+\def\MT_hphantom:Nn {\v@false\h@true\MT_internal_phantom:N}
+\def\MT_phantom:Nn {\v@true\h@true\MT_internal_phantom:N}
+\def\MT_internal_phantom:N #1{
+ \ifmmode
+ \expandafter\mathph@nt\expandafter#1
+ \else
+ \expandafter\makeph@nt
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\adjustlimits}
+% This is for making sure limits line up on two consecutive
+% operators.
+% \begin{macrocode}
+\newcommand*\adjustlimits[6]{
+% \end{macrocode}
+% We measure the two operators and save the difference of their
+% depths.
+% \begin{macrocode}
+ \sbox\z@{$\m@th \displaystyle #1$}
+ \sbox\tw@{$\m@th \displaystyle #4$}
+ \@tempdima=\dp\z@ \advance\@tempdima-\dp\tw@
+% \end{macrocode}
+% We force \cs{displaystyle} for the operator and \cs{scripstyle}
+% for the limit. If we make use of the regular \cs{smash},
+% \cs{vphantom}, and \cs{cramped} macros, and let \TeX{} choose the
+% right style for each one of them, we get a lot of redundant code
+% as we have no need for the combination
+% $(\cs{displaystyle},\cs{textstyle})$ etc. Only
+% $(\cs{scriptstyle},\cs{scriptstyle})$ is useful.
+% \begin{macrocode}
+ \if_dim:w \@tempdima>\z@
+ \mathop{#1}\limits#2{#3}
+ \else:
+ \mathop{#1\MT_vphantom:Nn \displaystyle{#4}}\limits
+ #2{
+ \def\finsm@sh{\ht\z@\z@ \box\z@}
+ \mathsm@sh\scriptstyle{\MT_cramped_internal:Nn \scriptstyle{#3}}
+ \MT_vphantom:Nn \scriptstyle
+ {\MT_cramped_internal:Nn \scriptstyle{#6}}
+ }
+ \fi:
+ \if_dim:w \@tempdima>\z@
+ \mathop{#4\MT_vphantom:Nn \displaystyle{#1}}\limits
+ #5
+ {
+ \MT_vphantom:Nn \scriptstyle
+ {\MT_cramped_internal:Nn \scriptstyle{#3}}
+ \def\finsm@sh{\ht\z@\z@ \box\z@}
+ \mathsm@sh\scriptstyle{\MT_cramped_internal:Nn \scriptstyle{#6}}
+ }
+ \else:
+ \mathop{#4}\limits#5{#6}
+ \fi:
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \section{Macros by other people}
+%
+% \subsection{Short intertext}
+%
+% Gabriel Zachmann, Donald Arseneau on comp.text.tex 2000/05/12-13
+% \begin{macro}{\shortintertext}
+% This is like \cs{intertext} but uses shorter skips betweeb the math.
+% \begin{macrocode}
+\def\shortintertext#1{%
+ \ifvmode\else\\\@empty\fi
+ \noalign{%
+ \penalty\postdisplaypenalty\vskip\abovedisplayshortskip
+ \vbox{\normalbaselines
+ \if_dim:w \linewidth=\columnwidth
+ \else:
+ \parshape\@ne \@totalleftmargin \linewidth
+ \fi:
+ \noindent#1\par}%
+ \penalty\predisplaypenalty\vskip\abovedisplayshortskip%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Fine-tuning mathematical layout}
+%
+% \subsubsection{A complement to \texttt{\textbackslash smash},
+% \texttt{\textbackslash llap}, and \texttt{\textbackslash rlap}}
+% \begin{macro}{\clap}
+% \begin{macro}{\mathllap}
+% \begin{macro}{\mathrlap}
+% \begin{macro}{\mathclap}
+% \begin{macro}{\MT_mathllap:Nn}
+% \begin{macro}{\MT_mathrlap:Nn}
+% \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).
+% \begin{macrocode}
+\providecommand*\clap[1]{\hb@xt@\z@{\hss#1\hss}}
+\providecommand*\mathllap[1][\@empty]{
+ \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
+ \expandafter \mathpalette \expandafter \MT_mathrlap:Nn
+ \else
+ \expandafter \MT_mathrlap:Nn \expandafter #1
+ \fi
+}
+\providecommand*\mathclap[1][\@empty]{
+ \ifx\@empty#1\@empty
+ \expandafter \mathpalette \expandafter \MT_mathclap:Nn
+ \else
+ \expandafter \MT_mathclap:Nn \expandafter #1
+ \fi
+}
+% \end{macrocode}
+% We have to insert |{}| because we otherwise risk triggering a
+% ``feature'' in \TeX.
+% \begin{macrocode}
+\def\MT_mathllap:Nn #1#2{{}\llap{$\m@th#1{#2}$}}
+\def\MT_mathrlap:Nn #1#2{{}\rlap{$\m@th#1{#2}$}}
+\def\MT_mathclap:Nn #1#2{{}\clap{$\m@th#1{#2}$}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\mathmbox}
+% \begin{macro}{\MT_mathmbox:nn}
+% \begin{macro}{\mathmakebox}
+% \begin{macro}{\MT_mathmakebox_I:w}
+% \begin{macro}{\MT_mathmakebox_II:w}
+% \begin{macro}{\MT_mathmakebox_III:w}
+% Then the \cs{mathmbox}\marg{arg} and
+% \cs{mathmakebox}\oarg{width}\oarg{pos}\marg{arg} macros which are
+% very similar to \cs{mbox} and \cs{makebox}. The differences are:
+% \begin{itemize}
+% \item \meta{arg} is set in math mode of course.
+% \item No need for \cs{leavevmode} as we're in math mode.
+% \item No need to make them \cs{long} (we're still in math mode).
+% \item No need to support a picture version.
+% \end{itemize}
+% The first is easy.
+% \begin{macrocode}
+\providecommand*\mathmbox{\mathpalette\MT_mathmbox:nn}
+\def\MT_mathmbox:nn #1#2{\mbox{$\m@th#1#2$}}
+% \end{macrocode}
+% We scan for the optional arguments first.
+% \begin{macrocode}
+\providecommand*\mathmakebox{
+ \@ifnextchar[ \MT_mathmakebox_I:w
+ \mathmbox}
+\def\MT_mathmakebox_I:w[#1]{%
+ \@ifnextchar[ {\MT_mathmakebox_II:w[#1]}
+ {\MT_mathmakebox_II:w[#1][c]}}
+% \end{macrocode}
+% We had to get the optional arguments out of the way before calling
+% upon the powers of \cs{mathpalette}.
+% \begin{macrocode}
+\def\MT_mathmakebox_II:w[#1][#2]{
+ \mathpalette{\MT_mathmakebox_III:w[#1][#2]}}
+\def\MT_mathmakebox_III:w[#1][#2]#3#4{%
+ \@begin@tempboxa\hbox{$\m@th#3#4$}%
+ \setlength\@tempdima{#1}%
+ \hbox{\hb@xt@\@tempdima{\csname bm@#2\endcsname}}%
+ \@end@tempboxa}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\mathsm@sh}
+% Fix \cs{smash}.
+% \begin{macrocode}
+\def\mathsm@sh#1#2{%
+ \setbox\z@\hbox{$\m@th#1{#2}$}{}\finsm@sh}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsubsection{A cramped style}
+%
+% 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}
+% \end{quote}
+% The (better) user interface by the author.
+%
+% \begin{macro}{\cramped}
+% Make sure the expansion is timed correctly.
+% \begin{macrocode}
+\providecommand*\cramped[1][\@empty]{
+ \ifx\@empty#1\@empty
+ \expandafter \mathpalette \expandafter \MT_cramped_internal:Nn
+ \else
+ \expandafter \MT_cramped_internal:Nn \expandafter #1
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\MT_cramped_internal:Nn}
+% The internal command.
+% \begin{macrocode}
+\def\MT_cramped_internal:Nn #1#2{
+% \end{macrocode}
+% Create a box containing the math and force a cramped style by
+% issuing a non-existing radical.
+% \begin{macrocode}
+ \sbox\z@{$\m@th#1\nulldelimiterspace=\z@\radical\z@{#2}$}
+% \end{macrocode}
+% Then make sure the height is correct.
+% \begin{macrocode}
+ \ifx#1\displaystyle
+ \dimen@=\fontdimen8\textfont3
+ \advance\dimen@ .25\fontdimen5\textfont2
+ \else
+ \dimen@=1.25\fontdimen8
+ \ifx#1\textstyle\textfont
+ \else
+ \ifx#1\scriptstyle
+ \scriptfont
+ \else
+ \scriptscriptfont
+ \fi
+ \fi
+ 3
+ \fi
+ \advance\dimen@-\ht\z@ \ht\z@=-\dimen@
+ \box\z@
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Cramped versions of \texttt{\textbackslash
+% mathllap}, \texttt{\textbackslash mathclap}, and
+% \texttt{\textbackslash mathrlap}}
+% \begin{macro}{\crampedllap}
+% \begin{macro}{\MT_cramped_llap_internal:Nn}
+% \begin{macro}{\crampedclap}
+% \begin{macro}{\MT_cramped_clap_internal:Nn}
+% \begin{macro}{\crampedrlap}
+% \begin{macro}{\MT_cramped_rlap_internal:Nn}
+% Cramped versions of \cs{mathXlap} (for speed). Made by the author.
+% \begin{macrocode}
+\providecommand*\crampedllap[1][\@empty]{
+ \ifx\@empty#1\@empty
+ \expandafter \mathpalette \expandafter \MT_cramped_llap_internal:Nn
+ \else
+ \expandafter \MT_cramped_llap_internal:Nn \expandafter #1
+ \fi
+}
+\def\MT_cramped_llap_internal:Nn #1#2{
+ {}\llap{\MT_cramped_internal:Nn #1{#2}}
+}
+\providecommand*\crampedclap[1][\@empty]{
+ \ifx\@empty#1\@empty
+ \expandafter \mathpalette \expandafter \MT_cramped_clap_internal:Nn
+ \else
+ \expandafter \MT_cramped_clap_internal:Nn \expandafter #1
+ \fi
+}
+\def\MT_cramped_clap_internal:Nn #1#2{
+ {}\clap{\MT_cramped_internal:Nn #1{#2}}
+}
+\providecommand*\crampedrlap[1][\@empty]{
+ \ifx\@empty#1\@empty
+ \expandafter \mathpalette \expandafter \MT_cramped_rlap_internal:Nn
+ \else
+ \expandafter \MT_cramped_rlap_internal:Nn \expandafter #1
+ \fi
+}
+\def\MT_cramped_rlap_internal:Nn #1#2{
+ {}\rlap{\MT_cramped_internal:Nn #1{#2}}
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+%
+% \section{Macros by Michael J.~Downes}
+%
+% The macros in this section are all by Michael J.~Downes. Either
+% they are straight copies of his original macros or inspired and
+% extended here.
+%
+%
+% \subsection{Prescript}
+% \begin{macro}{\prescript}
+% This command is taken from a posting to comp.text.tex on
+% December~20th 2000 by Michael J.~Downes. The comments are his. I
+% have added some formatting options to the arguments so that a user
+% can emulate the \pkg{isotope} package.
+% \begin{macrocode}
+\DeclareRobustCommand{\prescript}[3]{
+% \end{macrocode}
+% Put the sup in box 0 and the sub in box 2.
+% \begin{macrocode}
+ \@mathmeasure\z@\scriptstyle{\MT_prescript_sup:{#1}}
+ \@mathmeasure\tw@\scriptstyle{\MT_prescript_sub:{#2}}
+ \if_dim:w \wd\tw@>\wd\z@
+ \setbox\z@\hbox to\wd\tw@{\hfil\unhbox\z@}
+ \else:
+ \setbox\tw@\hbox to\wd\z@{\hfil\unhbox\tw@}
+ \fi:
+% \end{macrocode}
+% Do not let a preceding mathord symbol approach without any
+% intervening space.
+% \begin{macrocode}
+ \mathop{}
+% \end{macrocode}
+% Use \cs{mathopen} to suppress space between the prescripts and the
+% base object even when the latter is not of type ord.
+% \begin{macrocode}
+ \mathopen{\vphantom{\MT_prescript_arg:{#3}}}^{\box\z@}\sb{\box\tw@}
+ \MT_prescript_arg:{#3}
+}
+% \end{macrocode}
+% \end{macro}
+% Then the named arguments. Can you see I'm preparing for templates?
+% \begin{macrocode}
+\define@key{\MT_options_name:}
+ {prescript-sup-format}{\def\MT_prescript_sup:{#1}}
+\define@key{\MT_options_name:}
+ {prescript-sub-format}{\def\MT_prescript_sub:{#1}}
+\define@key{\MT_options_name:}
+ {prescript-arg-format}{\def\MT_prescript_arg:{#1}}
+\setkeys{\MT_options_name:}{
+ prescript-sup-format={},
+ prescript-sub-format={},
+ prescript-arg-format={},
+}
+% \end{macrocode}
+%
+% \subsection{Math sizes}
+% \begin{macro}{\@DeclareMathSizes}
+% This command is taken from a posting to comp.text.tex on
+% October~17th 2002 by Michael J.~Downes. The purpose is to be able
+% to put dimensions on the last three arguments of
+% \cs{DeclareMathSizes}.
+% \begin{macrocode}
+\def\@DeclareMathSizes #1#2#3#4#5{%
+ \@defaultunits\dimen@ #2pt\relax\@nnil
+ \if:w $#3$%
+ \MH_let:cN {S@\strip@pt\dimen@}\math@fontsfalse
+ \else:
+ \@defaultunits\dimen@ii #3pt\relax\@nnil
+ \@defaultunits\@tempdima #4pt\relax\@nnil
+ \@defaultunits\@tempdimb #5pt\relax\@nnil
+ \toks@{#1}%
+ \expandafter\xdef\csname S@\strip@pt\dimen@\endcsname{%
+ \gdef\noexpand\tf@size{\strip@pt\dimen@ii}%
+ \gdef\noexpand\sf@size{\strip@pt\@tempdima}%
+ \gdef\noexpand\ssf@size{\strip@pt\@tempdimb}%
+ \the\toks@
+ }%
+ \fi:
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Mathematics within italic text}
+% mathic: Michael J.~Downes on comp.text.tex, 1998/05/14.
+% \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.
+% \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.
+% \begin{macrocode}
+ \MH_let:NwN \MT_begin_inlinemath: \(
+ \renewcommand*\({\relax\ifmmode\@badmath\else
+ \ifhmode
+ \if_dim:w \fontdimen\@ne\font>\z@
+ \if_dim:w \lastskip>\z@
+ \skip@\lastskip\unskip
+ \@@italiccorr
+ \hskip\skip@
+ \else:
+ \@@italiccorr
+ \fi:
+ \fi:
+ \fi:
+ $\fi:
+ }
+ }
+}
+% \end{macrocode}
+% Just for restoring the old behavior.
+% \begin{macrocode}
+\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:
+ }
+}
+\MH_new_boolean:n {math_italic_corr}
+\define@key{\MT_options_name:}{mathic}[true]{
+ \@ifundefined{MT_mathic_#1:}
+ { \MT_true_false_error:
+ \@nameuse{MT_mathic_false:}
+ }
+ { \@nameuse{MT_mathic_#1:} }
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Spreading equations}
+%
+% Michael J.~Downes on comp.text.tex 1999/08/25
+% \begin{environment}{spreadlines}
+% This is meant to be used outside math, just like
+% \env{subequations}.
+% \begin{macrocode}
+\newenvironment{spreadlines}[1]{
+ \setlength{\jot}{#1}
+ \ignorespaces
+}{ \ignorespacesafterend }
+% \end{macrocode}
+% \end{environment}
+%
+% \subsection{Gathered}
+%
+% Inspired by Michael J.~Downes on comp.text.tex 2002/01/17.
+% \begin{environment}{MT_gathered_env}
+% Just like the normal \env{gathered}, only here we're allowed to
+% specify actions before and after each line.
+% \begin{macrocode}
+\MaybeMHPrecedingSpacesOff
+\newenvironment{MT_gathered_env}[1][c]{%
+ \RIfM@\else
+ \nonmatherr@{\begin{\@currenvir}}%
+ \fi
+ \null\,%
+ \if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi \bgroup
+ \Let@ \chardef\dspbrk@context\@ne \restore@math@cr
+ \spread@equation
+ \ialign\bgroup
+ \MT_gathered_pre:
+ \strut@$\m@th\displaystyle##$
+ \MT_gathered_post:
+ \crcr
+}{%
+ \endaligned
+ \MT_gathered_env_end:
+}
+\MHPrecedingSpacesOn
+% \end{macrocode}
+% \end{environment}
+% \begin{macro}{\newgathered}
+% \begin{macro}{\renewgathered}
+% \begin{environment}{lgathered}
+% \begin{environment}{rgathered}
+% \begin{environment}{gathered}
+% An easier interface.
+% \begin{macrocode}
+\newcommand*\newgathered[4]{
+ \newenvironment{#1}
+ { \def\MT_gathered_pre:{#2}
+ \def\MT_gathered_post:{#3}
+ \def\MT_gathered_env_end:{#4}
+ \MT_gathered_env
+ }{\endMT_gathered_env}
+}
+\newcommand*\renewgathered[4]{
+ \renewenvironment{#1}
+ { \def\MT_gathered_pre:{#2}
+ \def\MT_gathered_post:{#3}
+ \def\MT_gathered_env_end:{#4}
+ \MT_gathered_env
+ }{\endMT_gathered_env}
+}
+\newgathered{lgathered}{}{\hfil}{}
+\newgathered{rgathered}{\hfil}{}{}
+\renewgathered{gathered}{\hfil}{\hfil}{}
+% \end{macrocode}
+% \end{environment}
+% \end{environment}
+% \end{environment}
+% \end{macro}
+% \end{macro}
+%
+% \subsection{Split fractions}
+%
+% Michael J.~Downes on comp.text.tex 2001/12/06.
+% \begin{macro}{\splitfrac}
+% \begin{macro}{\splitdfrac}
+% These commands use \cs{genfrac} to typeset a split fraction. The
+% thickness of the fraction rule is simply set to zero.
+% \begin{macrocode}
+\newcommand*\splitfrac[2]{%
+ \genfrac{}{}{0pt}{1}%
+ {\textstyle#1\quad\hfill}%
+ {\textstyle\hfill\quad\mathstrut#2}%
+}
+\newcommand*\splitdfrac[2]{%
+ \genfrac{}{}{0pt}{0}{#1\quad\hfill}{\hfill\quad\mathstrut #2}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%
+% \section{Bug fixes for \pkg{amsmath}}
+% The following fixes some bugs in \pkg{amsmath}, but only if the
+% switch is true.
+% \begin{macrocode}
+\MH_if_boolean:nT {fixamsmath}{
+% \end{macrocode}
+% \begin{macro}{\place@tag}
+% This corrects a bug in \pkg{amsmath} affecting tag placement in
+% \env{flalign}.\footnote{See
+% \url{http://www.latex-project.org/cgi-bin/ltxbugs2html?pr=amslatex/3591}}
+% \begin{macrocode}
+\def\place@tag{%
+ \iftagsleft@
+ \kern-\tagshift@
+% \end{macrocode}
+% The addition. If we're in \env{flalign} (meaning
+% $\cs{xatlevel@}=\cs{tw@}$) we skip back by an amount of
+% \cs{@mathmargin}. This test is also true for the \env{xxalignat}
+% environment, but it doesn't matter because a)~it's not
+% supported/described in the documentation anymore so new users
+% won't know about it and b)~it forbids the use of \cs{tag}
+% anyway.
+% \begin{macrocode}
+ \if@fleqn
+ \if_num:w \xatlevel@=\tw@
+ \kern-\@mathmargin
+ \fi:
+ \fi:
+% \end{macrocode}
+% End of additions.
+% \begin{macrocode}
+ \if:w 1\shift@tag\row@\relax
+ \rlap{\vbox{%
+ \normalbaselines
+ \boxz@
+ \vbox to\lineht@{}%
+ \raise@tag
+ }}%
+ \else:
+ \rlap{\boxz@}%
+ \fi:
+ \kern\displaywidth@
+ \else:
+ \kern-\tagshift@
+ \if:w 1\shift@tag\row@\relax
+ \llap{\vtop{%
+ \raise@tag
+ \normalbaselines
+ \setbox\@ne\null
+ \dp\@ne\lineht@
+ \box\@ne
+ \boxz@
+ }}%
+ \else:
+ \llap{\boxz@}%
+ \fi:
+ \fi:
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\x@calc@shift@lf}
+% This corrects a bug\footnote{See
+% \url{http://www.latex-project.org/cgi-bin/ltxbugs2html?pr=amslatex/3614}}
+% in \pkg{amsmath} that could cause a non-positive value of the dimension
+% \cs{@mathmargin} to cause an
+% \begin{verbatim}
+% ! Arithmetic overflow.
+% <recently read> \@tempcntb
+% \end{verbatim}
+% when in \mode{fleqn,leqno} mode. Not very comprehensible for the user.
+% \begin{macrocode}
+\def\x@calc@shift@lf{%
+ \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.
+% \begin{macrocode}
+ \if_num:w \@tempcntb=0
+ \else:
+ \global\divide\alignsep@\@tempcntb % original line
+ \fi:
+% \end{macrocode}
+% Addition end.
+% \begin{macrocode}
+ \if_dim:w \alignsep@<\minalignsep\relax
+ \global\alignsep@\minalignsep\relax
+ \fi:
+ \fi:
+ \if_dim:w \tag@width\row@>\@tempdima
+ \saveshift@1%
+ \else:
+ \saveshift@0%
+ \fi:}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+}
+% \end{macrocode}
+% End of bug fixing.
+%
+% \subsection{Making environments safer}
+%
+% \begin{macro}
+% Here we make the \pkg{amsmath} inner environments disallow spaces
+% before their optional positioning specifier.
+% \begin{macrocode}{\aligned@a}
+\MaybeMHPrecedingSpacesOff
+\renewcommand\aligned@a[1][c]{\start@aligned{#1}\m@ne}
+\MHPrecedingSpacesOn
+% \end{macrocode}
+% \end{macro}
+%
+% This is the end of the \pkg{mathtools} package.
+% \begin{macrocode}
+%</package>
+% \end{macrocode}
+%
+% \Finale
+\endinput
diff --git a/Master/texmf-dist/source/latex/mh/mathtools.ins b/Master/texmf-dist/source/latex/mh/mathtools.ins
new file mode 100644
index 00000000000..5b541376b07
--- /dev/null
+++ b/Master/texmf-dist/source/latex/mh/mathtools.ins
@@ -0,0 +1,54 @@
+%%
+%% This file will generate fast loadable files and documentation
+%% driver files from the doc files in this package when run through
+%% LaTeX or TeX.
+%%
+%% File `mathtools.ins'.
+%% Copyright 2004 Morten H\o gholm.
+%% moho01ab@student.cbs.dk
+%%
+%% It 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.
+%% 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 2003/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "maintained".
+%%
+%% The Current Maintainer of this work is Morten H\o gholm.
+%%
+%% This work consists of the files mathtools.dtx and mathtools.ins
+%% and the derived file mathtools.sty.
+%% --------------- start of docstrip commands ------------------
+%%
+\input docstrip
+
+\keepsilent
+
+\preamble
+
+It 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.
+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 2003/12/01 or later.
+
+This work has the LPPL maintenance status "maintained".
+
+The Current Maintainer of this work is Morten H\string\o gholm.
+
+This work consists of the files mathtools.dtx and mathtools.ins
+and the derived file mathtools.sty.
+
+\endpreamble
+
+%%%%%%%%%%%%%%%
+\generate{%
+ \file{mathtools.sty}{\from{mathtools.dtx}{package}}%
+}
+
+\endbatchfile
diff --git a/Master/texmf-dist/source/latex/mh/mhsetup.dtx b/Master/texmf-dist/source/latex/mh/mhsetup.dtx
new file mode 100644
index 00000000000..ac168a685d9
--- /dev/null
+++ b/Master/texmf-dist/source/latex/mh/mhsetup.dtx
@@ -0,0 +1,528 @@
+% \iffalse meta-comment
+% File `mhsetup.dtx'.
+% Copyright 2004 Morten H\o gholm.
+% moho01ab@student.cbs.dk
+%
+% It 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.
+% 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 2003/12/01 or later.
+%
+% This work has the LPPL maintenance status "maintained".
+%
+% The Current Maintainer of this work is Morten H\o gholm.
+%
+% This work consists of the files mhsetup.dtx and mhsetup.ins and the
+% derived file mhsetup.sty.
+%
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{mhsetup}
+%<*dtx>
+ \ProvidesFile{mhsetup.dtx}
+%</dtx>
+ [2004/10/10 v1.0b programming setup (MH)]
+%<*driver>
+\documentclass[a4paper]{ltxdoc}
+\usepackage{mhsetup}
+
+\addtolength\oddsidemargin{30pt}
+\providecommand*\pkg[1]{\textsf{#1}}
+\providecommand*\env[1]{\texttt{#1}}
+\providecommand*\opt[1]{\texttt{#1}}
+\def\MakePrivateLetters{%
+ \makeatletter\catcode`\_=11\relax \catcode`\:=11\relax
+}
+
+
+
+\def\MHmarg#1{{\ttfamily\char`\{}\meta{#1}{\ttfamily\char`\}}\endgroup}
+\DeclareRobustCommand\marg{\begingroup\MakePrivateLetters\MHmarg}%
+\def\MHarg#1{{\ttfamily\char`\{#1\ttfamily\char`\}}\endgroup}
+\DeclareRobustCommand\arg{\begingroup\MakePrivateLetters\MHarg}%
+\def\MHcs#1{\texttt{\char`\\#1}\endgroup}
+\DeclareRobustCommand\cs{\begingroup\MakePrivateLetters\MHcs}
+\makeatletter
+\providecommand*\eTeX{$\m@th\varepsilon$-\TeX}
+\makeatother
+\begin{document}
+ \DocInput{mhsetup.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{286}
+%
+% \GetFileInfo{mhsetup.dtx}
+%
+% \title{The \pkg{mhsetup} package\thanks{This package has version
+% number \fileversion, last revised on \filedate.}}
+% \author{Morten H\o gholm}
+% \date{\filedate}
+% \maketitle
+%
+% \begin{abstract}
+% The \pkg{mhsetup} package provides tools for a \LaTeX{}
+% programming environment similar to the one described in
+% \texttt{expl3} on \textsc{ctan} although not as extensive. It is
+% a required part of both the \pkg{mathtools} and \pkg{empheq}
+% packages.
+% \end{abstract}
+%
+% \section{The new internal syntax}
+%
+% The \LaTeX3 package \pkg{ldcsetup} defines the command
+% \cs{InternalSyntaxOn} which makes |_| and |:| letters and then
+% automatically restores the category codes at the end of the
+% package. This usually works fine but when you try to load
+% \pkg{amstext} you will experience that \TeX{} goes into an
+% infinite loop. Packages containing code like
+% |\@for\@tempa:=\@tempb\do{...}| will not work correctly either,
+% thus we provide an alternative version here with the pair of
+% commands
+% \DescribeMacro{\MHInternalSyntaxOn}\cs{MHInternalSyntaxOn} and
+% \DescribeMacro{\MHInternalSyntaxOff}\cs{MHInternalSyntaxOff}. They
+% are to be used only as a pair, because \cs{MHInternalSyntaxOn}
+% defines \cs{MHInternalSyntaxOff} so that it restores the category
+% codes correctly.
+%
+%
+% \section{Handling optional arguments}
+%
+% The standard behavior of scanning for optional arguments in
+% \LaTeX{} allows any number of spaces preceding the optional
+% argument and that is not always good in math. For that reason
+% \pkg{amsmath} makes sure that commands like |\\| disallows spaces
+% before the optional argument but at the same time it fails to
+% provide ``safe'' environments. What would you expect from the
+% following input?
+% \begin{verbatim}
+% \[
+% \begin{gathered}
+% [v] = 100 \\
+% [t] = 200
+% \end{gathered}
+% \]
+% \end{verbatim}
+% \LaTeX{} will see the \texttt{[v]} as an optional argument of
+% \env{gathered} and use it. In this case the test inside
+% \env{gathered} checks if it's a \texttt{t} or \texttt{b} and if
+% it's neither it'll choose \cs{vcenter} internally. So you get no
+% warning, only missing output. Another example, this time from the
+% \pkg{empheq} package used with its \opt{overload} option: If
+% preceding spaces are allowed, the input
+% \begin{verbatim}
+% \begin{gather}
+% [a] = [b]
+% \end{gather}
+% \end{verbatim}
+% results in the rather strange error message
+% \begin{verbatim}
+% ! Package keyval Error: a undefined.
+% \end{verbatim}
+%
+% When using \cs{newcommand} etc.\ for defining commands and
+% environments with optional arguments, the peek ahead is done by
+% \cs{kernel@ifnextchar} (since \LaTeX{} release 2003/12/01, else
+% \cs{@ifnextchar}) and it is \emph{hardwired at definition time} by
+% \cs{@xargdef}. With the commands
+% \DescribeMacro{\MHPrecedingSpacesOff}\cs{MHPrecedingSpacesOff} and
+% \DescribeMacro{\MHPrecedingSpacesOn}\cs{MHPrecedingSpacesOn}
+% \pkg{mhsetup} provides an interface to define commands and
+% environments where the optional argument cannot have preceding
+% spaces. You simply wrap them around the definitions:
+% \begin{verbatim}
+% \MHPrecedingSpacesOff
+% \newenvironment*{test}[1][default]{Start, arg: (#1)}{Ending.}
+% \MHPrecedingSpacesOn
+% \begin{test}
+% [text]
+% \end{test}
+% \begin{test}[text]
+% \end{test}
+% \end{verbatim}
+% \MHPrecedingSpacesOff
+% \newenvironment*{test}[1][default]{Start, arg: (#1)}{Ending.}
+% \MHPrecedingSpacesOn
+% \begin{quote}
+% \begin{test}
+% [text]
+% \end{test}
+% \begin{test}[text]
+% \end{test}
+% \end{quote}
+% It is of somewhat limited use in commands (control words in \TeX{}
+% terminology), because \TeX{} discards the spaces. The exception is
+% \emph{control symbols} where \TeX{} obeys following spaces but
+% there are rather few of them available. All is not lost however.
+% In the \env{aligned} environment from \pkg{amsmath} (shown below)
+% a command is used as argument grabber.
+% \begin{verbatim}
+% \newenvironment{aligned}{%
+% \let\@testopt\alignsafe@testopt
+% \aligned@a
+% }{%
+% \crcr\egroup
+% \restorecolumn@
+% \egroup
+% }
+% \newcommand{\aligned@a}[1][c]{\start@aligned{#1}\m@ne}
+% \end{verbatim}
+% By applying our trick on the grabber function, we get a space
+% obeying version:
+% \begin{verbatim}
+% \MHPrecedingSpacesOff
+% \renewcommand*\aligned@a[1][c]{\start@aligned{#1}\m@ne}
+% \MHPrecedingSpacesOn
+% \end{verbatim}
+% This way a nested \env{aligned} environment is still safe from
+% empty first cells.
+%
+% \StopEventually{}
+%
+%
+% \section{First bits of a new programming environment}
+%
+%
+% \begin{macrocode}
+%<*package>
+% \end{macrocode}
+% \subsection{The new internal syntax}
+% \begin{macro}{\MHInternalSyntaxOn}
+% \begin{macro}{\MHInternalSyntaxOff}
+% Almost copy of \cs{InternalSyntaxOn}.
+% \begin{macrocode}
+\def\MHInternalSyntaxOn{
+ \edef\MHInternalSyntaxOff{%
+ \catcode`\noexpand\~=\the\catcode`\~\relax
+ \catcode`\noexpand\ =\the\catcode`\ \relax
+ \catcode`\noexpand\^^I=\the\catcode`\^^I\relax
+ \catcode`\noexpand\@=\the\catcode`\@\relax
+ \catcode`\noexpand\:=\the\catcode`\:\relax
+ \catcode`\noexpand\_=\the\catcode`\_\relax
+ \endlinechar=\the\endlinechar\relax
+ }%
+ \catcode`\~=10\relax
+ \catcode`\ =9\relax
+ \catcode`\^^I=9\relax
+ \makeatletter
+ \catcode`\_=11\relax
+ \catcode`\:=11\relax
+ \endlinechar=` %
+ \relax
+}
+\MHInternalSyntaxOn
+\AtEndOfPackage{\MHInternalSyntaxOff}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \subsection{Programming tools}
+%
+% The whole idea is to provide programming tools that are convenient
+% but not yet widely available. I hope this'll be obsolete soon!
+%
+% Firstly we setup a few helper functions.
+% \begin{macro}{\MH_let:NwN}
+% An alias for \cs{let}.
+% \begin{macrocode}
+\let\MH_let:NwN \let
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\MH_let:cN}
+% This one takes a \cs{csname}-\cs{endcsname} name and \cs{let}s it
+% to a single macro. We'll use this to setup our conditionals.
+% \begin{macrocode}
+\def\MH_let:cN #1#2{
+ \expandafter\MH_let:NwN \csname#1\endcsname#2}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\MH_let:cc}
+% This one has takes a \cs{csname}-\cs{endcsname} name and \cs{let}s
+% it to a another \cs{csname}-\cs{endcsname} name. To be used in
+% constructions with weird characters like \texttt{*} or alike in
+% them and can take a \cs{global} prefix if wanted (we want that
+% later on).
+% \begin{macrocode}
+\def\MH_let:cc #1#2{
+ \expandafter\MH_let:NwN\csname#1\expandafter\endcsname
+ \csname#2\endcsname}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MH_new_boolean:n}
+% \begin{macro}{\MH_set_boolean_F:n}
+% \begin{macro}{\MH_set_boolean_T:n}
+% \begin{macro}{\MH_if_boolean:nTF}
+% \begin{macro}{\MH_if_boolean:nT}
+% \begin{macro}{\MH_if_boolean:nF}
+% Sets up conditionals. For instance
+% \begin{quote}
+% \cs{MH_new_boolean:n} \marg{name}
+% \end{quote}
+% defines the boolean \meta{name} but also the conditional
+% \cs{if_boolean_\meta{name}:} to be used in the ordinary
+% \begin{tabbing}
+% \mbox{}\quad\= \kill
+% \cs{if_boolean_\meta{name}:}\\
+% \> \meta{true code} \\
+% \cs{else:} \\
+% \> \meta{false code} \\
+% \cs{fi:}
+% \end{tabbing}
+% There is also a more ``\LaTeX-like'' interface available by using
+% the commands
+% \begin{quote}
+% \cs{MH_if_boolean:nT}\marg{name}\marg{arg}
+% \end{quote}
+% which will execute the argument if the current value of the
+% boolean is `true' while
+% \begin{quote}
+% \cs{MH_if_boolean:nF}\marg{name}\marg{arg}
+% \end{quote}
+% is the equivalent with `false'. Finally we have
+% \begin{quote}
+% \cs{MH_if_boolean:nTF}\marg{name}\marg{true code}\marg{false code}.
+% \end{quote}
+% This is the interface I have used in this package.
+%
+% Initially \cs{if_boolean_\meta{name}:} is `false'. This can be
+% changed by saying
+% \begin{tabbing}
+% \quad \= \LaTeX:\quad \= \kill
+% \> \TeX: \> \cs{boolean_\meta{name}_true:} \quad \emph{or}\\
+% \> \LaTeX: \> \cs{MH_set_boolean_T:n}\marg{name}
+% \end{tabbing}
+% and changed back again by
+% \begin{tabbing}
+% \quad \= \LaTeX:\quad \= \kill
+% \> \TeX: \> \cs{boolean_\meta{name}_false:} \quad \emph{or}\\
+% \> \LaTeX: \> \cs{MH_set_boolean_F:n}\marg{name}
+% \end{tabbing}
+%
+% And yes, we're also using alternative names for \cs{else} and
+% \cs{fi} now. That way a simple search and replace will be all that
+% is needed for this package to be a certified \LaTeX3 package (well,
+% maybe a little more is needed, but not much).
+% \begin{macrocode}
+\def\MH_new_boolean:n #1{
+ \expandafter\@ifdefinable\csname if_boolean_#1:\endcsname{
+ \@namedef{boolean_#1_true:}
+ {\MH_let:cN{if_boolean_#1:}\iftrue}
+ \@namedef{boolean_#1_false:}
+ {\MH_let:cN{if_boolean_#1:}\iffalse}
+ \@nameuse{boolean_#1_false:}%
+ }
+}
+\def\MH_set_boolean_F:n #1{ \@nameuse{boolean_#1_false:} }
+\def\MH_set_boolean_T:n #1{ \@nameuse{boolean_#1_true:} }
+\def\MH_if_boolean:nTF #1{
+ \@nameuse{if_boolean_#1:}
+ \expandafter\@firstoftwo
+ \else:
+ \expandafter\@secondoftwo
+ \fi:
+}
+\def\MH_if_boolean:nT #1{
+ \@nameuse{if_boolean_#1:}
+ \expandafter\@firstofone
+ \else:
+ \expandafter\@gobble
+ \fi:
+}
+\def\MH_if_boolean:nF #1{
+ \@nameuse{if_boolean_#1:}
+ \expandafter\@gobble
+ \else:
+ \expandafter\@firstofone
+ \fi:
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\if:w}
+% \changes{v1.0b}{2004/10/10}{Use different test}
+% \begin{macro}{\if_meaning:NN}
+% \changes{v1.0b}{2004/10/10}{Use different test}
+% \begin{macro}{\else:}
+% \changes{v1.0b}{2004/10/10}{Use different test}
+% \begin{macro}{\fi:}
+% \changes{v1.0b}{2004/10/10}{Use different test}
+% \begin{macro}{\if_num:w}
+% \changes{v1.0b}{2004/10/10}{Use different test}
+% \begin{macro}{\if_dim:w}
+% \changes{v1.0b}{2004/10/10}{Use different test}
+% \begin{macro}{\if_case:w}
+% \changes{v1.0b}{2004/10/10}{Use different test}
+% \begin{macro}{\or:}
+% \changes{v1.0b}{2004/10/10}{Use different test}
+% Copies of \TeX{} primitives.
+% \begin{macrocode}
+\@ifundefined{if:w}{\MH_let:NwN \if:w =\if}{}
+\@ifundefined{if_meaning:NN}{\MH_let:NwN \if_meaning:NN =\ifx}{}
+\@ifundefined{else:}{\MH_let:NwN \else:=\else}{}
+\@ifundefined{fi:}{\MH_let:NwN \fi:=\fi}{}
+\@ifundefined{if_num:w}{\MH_let:NwN \if_num:w =\ifnum}{}
+\@ifundefined{if_dim:w}{\MH_let:NwN \if_dim:w =\ifdim}{}
+\@ifundefined{if_case:w}{\MH_let:NwN \if_case:w =\ifcase}{}
+\@ifundefined{or:}{\MH_let:NwN \or:=\or}{}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\MH_cs_to_str:N}
+% Strip off the backslash of a macro name.
+% \begin{macrocode}
+\def\MH_cs_to_str:N {\expandafter\@gobble\string}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\MH_protected:}
+% \begin{macro}{\MH_setlength:dn}
+% \changes{v1.0a}{2004/08/23}{Fixed bug in \cs{MH_setlength:dn} so that
+% it now uses the \pkg{calc} definition of \cs{setlength}}
+% \begin{macro}{\MH_addtolength:dn}
+% \changes{v1.0a}{2004/08/23}{Fixed bug in \cs{MH_addtolength:dn} so that
+% it now uses the \pkg{calc} definition of \cs{addtolength}}
+% We might as well make use of some of the extended features from
+% \eTeX. We use \cs{dimexpr} for some simple calculations as it
+% saves a lot of the scanning that goes on inside \pkg{calc}. The
+% \cs{protected} primitive comes in handy when we want to declare a
+% robust command, that cannot be `robustified' with
+% \cs{DeclareRobustCommand}. If we don't have \eTeX{} we'll just let
+% our private macros be aliases for the less effective alternatives.
+% \begin{macrocode}
+\@ifundefined{eTeXversion}
+ {
+ \MH_let:NwN \MH_protected:\relax
+ \def\MH_setlength:dn{\setlength}
+ \def\MH_addtolength:dn{\addtolength}
+ }
+ {
+ \MH_let:NwN \MH_protected:\protected
+ \def\MH_setlength:dn #1#2{#1=\dimexpr#2\relax\relax}
+ \def\MH_addtolength:dn #1#2{\advance#1 \dimexpr#2\relax\relax}
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+
+% \begin{macro}{\MH_keyval_alias_with_addon:nnnn}
+% \begin{macro}{\MH_keyval_alias:nnn}
+% A way to make aliases with \pkg{keyval}. This will come in
+% handy later.
+% \begin{macrocode}
+\def\MH_keyval_alias_with_addon:nnnn #1#2#3#4{
+ \@namedef{KV@#1@#2}{\@nameuse{KV@#1@#3}#4}
+ \@namedef{KV@#1@#2@default}{\@nameuse{KV@#1@#3@default}#4}}
+\def\MH_keyval_alias:nnn #1#2#3{
+ \MH_keyval_alias_with_addon:nnnn {#1}{#2}{#3}{}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\MH_use_choice_i:nnnn}
+% \begin{macro}{\MH_use_choice_ii:nnnn}
+% \begin{macro}{\MH_use_choice_iii:nnnn}
+% \begin{macro}{\MH_use_choice_iv:nnnn}
+% I need to be able to pick up individual arguments in a list of
+% four (similar to \cs{@secondoftwo}).
+% \begin{macrocode}
+\def\MH_use_choice_i:nnnn #1#2#3#4{#1}
+\def\MH_use_choice_ii:nnnn #1#2#3#4{#2}
+\def\MH_use_choice_iii:nnnn #1#2#3#4{#3}
+\def\MH_use_choice_iv:nnnn #1#2#3#4{#4}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\MH_nospace_ifnextchar:Nnn}
+% \begin{macro}{\MH_nospace_nextchar:}
+% \begin{macro}{\MH_nospace_testopt:nn}
+% \begin{macro}{\MH_nospace_protected_testopt:n}
+% Scanning for the next character but disallow spaces.
+% \begin{macrocode}
+\long\def\MH_nospace_ifnextchar:Nnn #1#2#3{
+ \MH_let:NwN\reserved@d=~#1
+ \def\reserved@a{#2}
+ \def\reserved@b{#3}
+ \futurelet\@let@token\MH_nospace_nextchar:
+}
+\def\MH_nospace_nextchar:{
+ \if_meaning:NN \@let@token\reserved@d
+ \MH_let:NwN \reserved@b\reserved@a
+ \fi:
+ \reserved@b
+}
+\long\def\MH_nospace_testopt:nn #1#2{
+ \MH_nospace_ifnextchar:Nnn[
+ {#1}
+ {#1[{#2}]}
+}
+\def\MH_nospace_protected_testopt:n #1{
+ \if_meaning:NN \protect\@typeset@protect
+ \expandafter\MH_nospace_testopt:nn
+ \else:
+ \@x@protect#1
+ \fi:
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\kernel@ifnextchar}
+% \begin{macro}{\MH_kernel_xargdef:nwwn}
+% \begin{macro}{\MH_nospace_xargdef:nwwn}
+% \begin{macro}{\MHPrecedingSpacesOff}
+% \begin{macro}{\MHPrecedingSpacesOn}
+% The code for the space sensitive peek ahead.
+% \begin{macrocode}
+\@ifundefined{kernel@ifnextchar}
+ {\MH_let:NwN \kernel@ifnextchar \@ifnextchar}
+ {}
+\MH_let:NwN \MH_kernel_xargdef:nwwn \@xargdef
+\long\def\MH_nospace_xargdef:nwwn #1[#2][#3]#4{
+ \@ifdefinable#1{
+ \expandafter\def\expandafter#1\expandafter{
+ \expandafter
+ \MH_nospace_protected_testopt:n
+ \expandafter
+ #1
+ \csname\string#1\endcsname
+ {#3}}
+ \expandafter\@yargdef
+ \csname\string#1\endcsname
+ \tw@
+ {#2}
+ {#4}}}
+\providecommand*\MHPrecedingSpacesOff{
+ \MH_let:NwN \@xargdef \MH_nospace_xargdef:nwwn
+}
+\providecommand*\MHPrecedingSpacesOn{
+ \MH_let:NwN \@xargdef \MH_kernel_xargdef:nwwn
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macrocode}
+%</package>
+% \end{macrocode}
+%
+% \Finale
+\endinput
diff --git a/Master/texmf-dist/source/latex/mh/mhsetup.ins b/Master/texmf-dist/source/latex/mh/mhsetup.ins
new file mode 100644
index 00000000000..25c5e2d7395
--- /dev/null
+++ b/Master/texmf-dist/source/latex/mh/mhsetup.ins
@@ -0,0 +1,54 @@
+%%
+%% This file will generate fast loadable files and documentation
+%% driver files from the doc files in this package when run through
+%% LaTeX or TeX.
+%%
+%% File `mhsetup.ins'.
+%% Copyright 2004 Morten H\o gholm.
+%% moho01ab@student.cbs.dk
+%%
+%% It 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.
+%% 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 2003/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "maintained".
+%%
+%% The Current Maintainer of this work is Morten H\o gholm.
+%%
+%% This work consists of the files mhsetup.dtx and mhsetup.ins and
+%% the derived file mhsetup.sty.
+%% --------------- start of docstrip commands ------------------
+%%
+\input docstrip
+
+\keepsilent
+
+\preamble
+
+It 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.
+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 2003/12/01 or later.
+
+This work has the LPPL maintenance status "maintained".
+
+The Current Maintainer of this work is Morten H\string\o gholm.
+
+This work consists of the files mhsetup.dtx and mhsetup.ins and
+the derived file mhsetup.sty.
+
+\endpreamble
+
+%%%%%%%%%%%%%%%
+\generate{%
+ \file{mhsetup.sty}{\from{mhsetup.dtx}{package}}%
+}
+
+\endbatchfile