Debian Codegraph @

texmf-dist/source/latex/mathtools/empheq.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2002-2007 by Morten Hoegholm
4 % Copyright (C) 2012-2019 by Lars Madsen
5 % Copyright (C) 2020 by Lars Madsen, The LaTeX3 Project
6 %
7 % This work may be distributed and/or modified under the
8 % conditions of the LaTeX Project Public License, either
9 % version 1.3 of this license or (at your option) any later
10 % version. The latest version of this license is in
11 % http://www.latex-project.org/lppl.txt
12 % and version 1.3 or later is part of all distributions of
13 % LaTeX version 2005/12/01 or later.
14 %
15 % This work has the LPPL maintenance status "maintained".
16 %
17 % This Current Maintainer of this work is
18 % Lars Madsen, The LaTeX3 Project
19 %
20 % This work consists of the main source file empheq.dtx
21 % and the derived files
22 % empheq.sty, empheq.pdf, empheq.ins, empheq.drv.
23 %
24 % Distribution:
25 % CTAN:macros/latex/contrib/mh/empheq.dtx
26 % CTAN:macros/latex/contrib/mh/empheq.pdf
27 %
28 % Unpacking:
29 % (a) If empheq.ins is present:
30 % tex empheq.ins
31 % (b) Without empheq.ins:
32 % tex empheq.dtx
33 % (c) If you insist on using LaTeX
34 % latex \let\install=y\input{empheq.dtx}
35 % (quote the arguments according to the demands of your shell)
36 %
37 % Documentation:
38 % (a) If empheq.drv is present:
39 % latex empheq.drv
40 % (b) Without empheq.drv:
41 % latex empheq.dtx; ...
42 % The class ltxdoc loads the configuration file ltxdoc.cfg
43 % if available. Here you can specify further options, e.g.
44 % use A4 as paper format:
45 % \PassOptionsToClass{a4paper}{article}
46 %
47 % Programm calls to get the documentation (example):
48 % pdflatex empheq.dtx
49 % makeindex -s gind.ist empheq.idx
50 % pdflatex empheq.dtx
51 % makeindex -s gind.ist empheq.idx
52 % pdflatex empheq.dtx
53 %
54 % Installation:
55 % TDS:tex/latex/mh/empheq.sty
56 % TDS:doc/latex/mh/empheq.pdf
57 % TDS:source/latex/mh/empheq.dtx
58 %
59 %<*ignore>
60 \begingroup
61 \def\x{LaTeX2e}
62 \expandafter\endgroup
63 \ifcase 0\ifx\install y1\fi\expandafter
64 \ifx\csname processbatchFile\endcsname\relax\else1\fi
65 \ifx\fmtname\x\else 1\fi\relax
66 \else\csname fi\endcsname
67 %</ignore>
68 %<*install>
69 \input docstrip.tex
70 \Msg{************************************************************************}
71 \Msg{* Installation}
72 \Msg{* Package: empheq 2024/08/09 v2.17 empheq}
73 \Msg{************************************************************************}
74
75 \keepsilent
76 \askforoverwritefalse
77
78 \preamble
79
80 This is a generated file.
81
82 Copyright (C) 2002-2007 by Morten Hoegholm
83 Copyright (C) 2012-2019 by Lars Madsen
84 Copyright (C) 2020- by Lars Madsen, The LaTeX3 Project
85
86
87 This work may be distributed and/or modified under the
88 conditions of the LaTeX Project Public License, either
89 version 1.3 of this license or (at your option) any later
90 version. The latest version of this license is in
91 http://www.latex-project.org/lppl.txt
92 and version 1.3 or later is part of all distributions of
93 LaTeX version 2005/12/01 or later.
94
95 This work has the LPPL maintenance status "maintained".
96
97 This Current Maintainer of this work is
98 Lars Madsen, The LaTeX3 Project
99
100 This work consists of the main source file empheq.dtx
101 and the derived files
102 empheq.sty, empheq.pdf, empheq.ins, empheq.drv.
103
104 \endpreamble
105
106 \generate{%
107 \file{empheq.ins}{\from{empheq.dtx}{install}}%
108 \file{empheq.drv}{\from{empheq.dtx}{driver}}%
109 \usedir{tex/latex/mh}%
110 \file{empheq.sty}{\from{empheq.dtx}{package}}%
111 }
112
113 \obeyspaces
114 \Msg{************************************************************************}
115 \Msg{*}
116 \Msg{* To finish the installation you have to move the following}
117 \Msg{* file into a directory searched by TeX:}
118 \Msg{*}
119 \Msg{* empheq.sty}
120 \Msg{*}
121 \Msg{* To produce the documentation run the file `empheq.drv'}
122 \Msg{* through LaTeX.}
123 \Msg{*}
124 \Msg{* Happy TeXing!}
125 \Msg{*}
126 \Msg{************************************************************************}
127
128 \endbatchfile
129 %</install>
130 %<*ignore>
131 \fi
132 %</ignore>
133 %<*driver>
134 \NeedsTeXFormat{LaTeX2e}
135 \ProvidesFile{empheq.drv}%
136 [2024/08/09 v2.17 Emphasizing equations]
137 \documentclass{ltxdoc}
138 \usepackage{mathpazo}
139 \usepackage[overload]{empheq}
140 \usepackage{xcolor,varioref,booktabs,fancybox,iftex}
141 \usepackage[overload]{textcase}
142
143 \iftutex\else
144 \usepackage[T1]{fontenc}
145 \fi
146
147
148 \pagestyle{headings}
149 \hyphenation{emph-eq}
150 \makeatletter
151 \providecommand*\pkg[1]{\textsf{#1}}
152 \providecommand*\cls[1]{\textsf{#1}}
153 \providecommand*\env[1]{\texttt{#1}}
154 \providecommand*\email[1]{\href{mailto:#1}{\texttt{#1}}}
155 \providecommand*\mode[1]{\texttt{[#1]}}
156 \providecommand*\file[1]{\texttt{#1}}
157 \addtolength\marginparwidth{-30pt}
158
159
160 \newcommand\lineref[1]{
161 \begingroup
162 % \p@CodelineNo \normalfont \scriptsize 475
163 \let\p@CodelineNo\relax
164 \let\normalfont\relax
165 %\let\scriptsize\relax
166 \ref{#1}
167 \endgroup
168 }
169
170
171 \newcommand*\AddDescribe[3]{%
172 \@namedef{Describe#1}{\leavevmode\@bsphack\begingroup\MakePrivateLetters
173 \@nameuse{Describe@#1}}
174 \@namedef{Describe@#1}##1{\endgroup
175 \marginpar{\raggedleft\@nameuse{PrintDescribe#1}{##1}}%
176 \@nameuse{Special#1Index}{##1}\@esphack\ignorespaces}
177 \@namedef{Special#1Index}##1{\@bsphack
178 \index{##1\actualchar{\protect\ttfamily ##1}
179 (#2)\encapchar usage}%
180 \index{#3:\levelchar##1\actualchar{\protect\ttfamily ##1}\encapchar
181 usage}\@esphack}
182 \@namedef{PrintDescribe#1}##1{\strut \MacroFont ##1\ }%
183 \@namedef{Print#1Name}##1{\strut \MacroFont ##1\ }%
184 }
185 \AddDescribe{Color}{color}{colors}
186 \AddDescribe{KeyFamily}{key family}{key families}
187 \newcommand*\DescribeDelimiter[1]{%
188 \cs{#1}&\SpecialMkhIndex{empheq#1}\cs{empheq}\texttt{#1} &
189 \SpecialMkhIndex{empheqbig#1}\cs{empheqbig}\texttt{#1} &
190 $\@nameuse{#1}$\tabularnewline}
191 \newcommand*\SpecialMkhIndex[1]{%
192 \@bsphack
193 \index{#1\actualchar{\protect\ttfamily \protect\bslash\space#1}
194 (` $\bslash#1$ ')\encapchar usage}%
195 \@esphack
196 }
197 \newcommand\TabDescribeOption[3][(default)]{%
198 \SpecialOptIndex{#2}\opt{#2} & #3 \tabularnewline
199 }
200 \newcommand*\TabDescribeAmsKey[2][]{%
201 \SpecialKeyIndex{#2}\env{#2} &
202 \texttt{\{#2#1\}} &
203 \SpecialKeyIndex{#2*}\env{#2*} &
204 \texttt{\{#2*#1\}} \tabularnewline
205 }
206 \newcommand*\TabDescribeOptKey[3][]{%
207 \SpecialKeyIndex{#2}\key{#2} &
208 \texttt{#2=}\meta{#3} & #1 \tabularnewline
209 }
210
211 \newenvironment{codesyntax}
212 {\par\small\addvspace{4.5ex plus 1ex}%
213 \vskip -\parskip
214 \noindent
215 \begin{tabular}{|l|}\hline\ignorespaces}%
216 {\\\hline\end{tabular}\nobreak\par\nobreak
217 \vspace{2.3ex}\vskip -\parskip\noindent\ignorespacesafterend}
218 \makeatletter
219
220 \newcommand*\FeatureRequest[2]{%
221 \hskip1sp
222 \marginpar{%
223 \parbox[b]{\marginparwidth}{\small\sffamily\raggedright
224 \strut Feature request by\\#1\\#2%
225 }
226 }%
227 }
228
229 \newcommand*\cttPosting[2]{%
230 \hskip1sp
231 \marginpar{%
232 \parbox[b]{\marginparwidth}{\small\sffamily\raggedright
233 \strut Posted on \texttt{comp.text.tex} \\#1\\#2%
234 }%
235 }%
236 }
237
238 \expandafter\def\expandafter\MakePrivateLetters\expandafter{%
239 \MakePrivateLetters \catcode`\_=11\relax
240 }
241
242 \providecommand*\SpecialOptIndex[1]{%
243 \@bsphack
244 \index{#1\actualchar{\protect\ttfamily #1}
245 (option)\encapchar usage}%
246 \index{options:\levelchar#1\actualchar{\protect\ttfamily #1}\encapchar
247 usage}\@esphack}
248 \providecommand*\opt[1]{\texttt{#1}}
249
250 \providecommand*\SpecialKeyIndex[1]{%
251 \@bsphack
252 \index{#1\actualchar{\protect\ttfamily #1}
253 (key)\encapchar usage}%
254 \index{keys:\levelchar#1\actualchar{\protect\ttfamily #1}\encapchar
255 usage}\@esphack}
256 \providecommand*\key[1]{\textsf{#1}}
257 \providecommand*\keyfam[1]{\textsf{#1}}
258
259 \providecommand*\eTeX{$\m@th\varepsilon$-\TeX}
260
261 \def\MTmeta#1{%
262 \ensuremath\langle
263 \ifmmode \expandafter \nfss@text \fi
264 {%
265 \meta@font@select
266 \edef\meta@hyphen@restore
267 {\hyphenchar\the\font\the\hyphenchar\font}%
268 \hyphenchar\font\m@ne
269 \language\l@nohyphenation
270 #1\/%
271 \meta@hyphen@restore
272 }\ensuremath\rangle
273 \endgroup
274 }
275 \makeatother
276 \DeclareRobustCommand\meta{\begingroup\MakePrivateLetters\MTmeta}%
277 \def\MToarg#1{{\ttfamily[}\meta{#1}{\ttfamily]}\endgroup}
278 \DeclareRobustCommand\oarg{\begingroup\MakePrivateLetters\MToarg}%
279 \def\MHmarg#1{{\ttfamily\char`\{}\meta{#1}{\ttfamily\char`\}}\endgroup}
280 \DeclareRobustCommand\marg{\begingroup\MakePrivateLetters\MHmarg}%
281 \def\MHarg#1{{\ttfamily\char`\{#1\ttfamily\char`\}}\endgroup}
282 \DeclareRobustCommand\arg{\begingroup\MakePrivateLetters\MHarg}%
283 \def\MHcs#1{\texttt{\char`\\#1}\endgroup}
284 \DeclareRobustCommand\cs{\begingroup\MakePrivateLetters\MHcs}
285 \def\MHbool#1{{\ttfamily #1}\endgroup}
286 \DeclareRobustCommand\bool{\begingroup\MakePrivateLetters\MHbool}%
287
288 \def\endverbatim{\if@newlist
289 \leavevmode\fi\endtrivlist\vspace{-\baselineskip}}
290 \expandafter\let\csname endverbatim*\endcsname =\endverbatim
291
292 \let\MTtheindex\theindex
293 \def\theindex{\MTtheindex\MakePrivateLetters}
294
295 \newcommand*\widefbox[1]{\fbox{\hspace{1em}#1\hspace{1em}}}
296 \definecolor{myblue}{rgb}{.8, .8, 1}
297 \newcommand*\mybluebox[1]{%
298 \colorbox{myblue}{\hspace{1em}#1\hspace{1em}}}
299 \newenvironment{important}[2][]{%
300 \setkeys{EmphEqEnv}{#2}%
301 \setkeys{EmphEqOpt}{box=\mybluebox,#1}%
302 \EmphEqMainEnv}%
303 {\endEmphEqMainEnv}
304 \definecolor{shadecolor}{cmyk}{0,0,0.41,0}
305 \definecolor{light-blue}{cmyk}{0.25,0,0,0}
306 \newsavebox{\mysaveboxM} % M for math
307 \newsavebox{\mysaveboxT} % T for text
308 \newcommand*\Garybox[2][Example]{%
309 \sbox{\mysaveboxM}{#2}%
310 \sbox{\mysaveboxT}{\fcolorbox{black}{light-blue}{#1}}%
311 \sbox{\mysaveboxM}{%
312 \parbox[b][\ht\mysaveboxM+.5\ht\mysaveboxT+.5\dp\mysaveboxT][b]{%
313 \wd\mysaveboxM}{#2}%
314 }%
315 \sbox{\mysaveboxM}{%
316 \fcolorbox{black}{shadecolor}{%
317 \makebox[\linewidth-10em]{\usebox{\mysaveboxM}}%
318 }%
319 }%
320 \usebox{\mysaveboxM}%
321 \makebox[0pt][r]{%
322 \makebox[\wd\mysaveboxM][c]{%
323 \raisebox{\ht\mysaveboxM-0.5\ht\mysaveboxT
324 +0.5\dp\mysaveboxT-0.5\fboxrule}{\usebox{\mysaveboxT}}%
325 }%
326 }%
327 }
328
329 \newcommand\EmphEqpart{%
330 \def\partname{\EmphEqpartname}%
331 \part}
332
333 \def\EmphEqpartname{Part}
334 \makeatother
335
336 \usepackage{graphicx}
337 \usepackage[final,breaklinks=true,hyperindex=false]{hyperref}
338 \renewcommand*\usage[1]{\textit{\hyperpage{#1}}}
339
340 \OnlyDescription
341 \begin{document}
342 \DocInput{empheq.dtx}
343 \end{document}
344 %</driver>
345 % \fi
346 % \changes{v2.17}{2024/08/09}{Fixed typo in manual}
347 % \changes{v2.16}{2020/03/24}{fixed several bugs related to amsart/-book}
348 % \changes{v2.15}{2017/03/31}{Fixed a bug in relation to the AMS
349 % classes and completed prefixing macros belonging to \pkg{mhsetup}
350 % and \pkg{empheq}}
351 % \changes{v2.14}{2014/07/16}{Updated maintenance and contact info}
352 %
353 % \changes{v2.11}{2004/08/03}{Removed interface to the obsolete empheq
354 % package \pkg{empheq07}}
355 %
356 % \changes{v2.10}{2004/07/26}{Rewrote most of the documentation}
357 %
358 % \changes{v2.10}{2004/07/26}{Moved options \texttt{fixamsmath} and
359 % \texttt{donotfixamsmathbugs} to \pkg{mathtools}}
360 %
361 % \changes{v2.10}{2004/07/26}{Added support for \pkg{showkeys}}
362 %
363 % \changes{v2.00}{2004/04/14}{Added options \opt{overload},
364 % \opt{overload2}, \texttt{fixamsmath}, and
365 % \texttt{donotfixamsmathbugs} plus descriptions of their use}
366 %
367 % \changes{v1.06}{2004/03/13}{Upgraded license to LPPL version 1.3}
368 %
369 % \changes{v1.00}{2004/02/15}{Complete rewrite of the package hence
370 % no description of the changes made}
371 %
372 % \changes{v0.7a}{2004/02/15}{Made the old package obsolete and
373 % changed its name to \pkg{empheq-obsolete}}
374 %
375 % \changes{v0.7}{2003/05/11}{Added further examples and changed
376 % existing ones}
377 % \changes{v0.6b}{2003/03/04}{Added example for changing margins
378 % inside the boxtype}
379 % \changes{v0.6a}{2003/01/28}{Minor updates to documentation}
380 %
381 % \changes{v0.5}{2002/12/30}{First experimental and very limited
382 % release}
383 %
384 % \GetFileInfo{empheq.drv}
385 % \CheckSum{2635}
386 %
387 % \title{The \pkg{empheq} package\thanks{This file has version number
388 % \fileversion, last revised \filedate.}\\
389 % Emphasizing equations in \LaTeXe}
390 % \author{Morten Hoegholm, Lars Madsen, The LaTeX3 Project}
391 %
392 % \date{\filedate}
393 %
394 % \maketitle
395 %
396 % \begin{abstract}
397 % \noindent The \pkg{empheq} package can best be described as a visual markup
398 % extension to \pkg{amsmath}. In short it offers a)~a multi line
399 % equivalent of \cs{boxed} from \pkg{amsmath} and b)~a way to
400 % produce arbitrary delimiters that span entire math displays.
401 % \end{abstract}
402 %
403 % \tableofcontents
404 %
405 % \clearpage
406 % \EmphEqpart{Basic user's guide}
407 %
408 % There can be little doubt that the de facto standard for
409 % mathematical typesetting in \LaTeX{} is the \pkg{amsmath} package.
410 % For the creation of \pkg{empheq}, a visual markup package for use
411 % in math, it made perfect sense to have \pkg{amsmath} as the
412 % backbone.
413 %
414 % The main idea of \pkg{empheq} is to maintain the familiar syntax
415 % of the \pkg{amsmath} environments while still providing an easy
416 % way of specifying markup instructions. This manual is plastered
417 % with examples showing just how.
418 %
419 %
420 % \section{Basic use of the package}
421 %
422 % So what is it \pkg{empheq} does? Well, it allows you to produce
423 % displays like this:
424 % \begin{subequations}
425 % \begin{empheq}[
426 % box=\mybluebox,
427 % right={\;\makebox[.9em]{$\raisebox{-.5\totalheight+\fontdimen22\textfont2}
428 % {\resizebox{!}{\EmphEqdisplayheight+\EmphEqdisplaydepth}{!}}$}},
429 % left={X=Y\Rightarrow\empheqlbrace}
430 % ]{alignat=3}
431 % A_1&=b_1 & \qquad c_1&=d_1 & \qquad e_1&= f_1
432 % \tag*{\_A\raisebox{1ex}{silly}\raisebox{-1ex}{tag}\_}\\
433 % A_2&=b_2 & \qquad c_2&=d_2 & \qquad e_2&= f_2 \\
434 % A_3&=b_3 & \qquad c_3&=d_3 & \qquad e_3&= f_3
435 % \end{empheq}
436 % \end{subequations}
437 % In short \pkg{empheq} enables the user to put things on every side
438 % of the display without said user having to worry about what
439 % happens to the equation numbers. For example you can now have a
440 % display containing multiple lines and still get the effect of the
441 % \cs{boxed} command from \pkg{amsmath}.
442 %
443 %
444 % \subsection{Using the \env{empheq} environment}
445 %
446 % The package defines a single environment
447 % \SpecialEnvIndex{empheq}\env{empheq} and the usage is kind of
448 % straightforward:
449 % \begin{codesyntax}
450 % |\begin{empheq}|\oarg{markup instructions}\marg{\AmS{} env_name}\\
451 % \mbox{}\quad\meta{contents of \AmS{} environment}\\
452 % |\end{empheq}|
453 % \end{codesyntax}
454 % A first minimal example file would then be something like
455 % \begin{verbatim}
456 % \documentclass{minimal}
457 % \usepackage{empheq}
458 % \begin{document}
459 % \begin{empheq}{align*}
460 % a&=b \tag{*}\\
461 % E&=mc^2 + \int_a^a x\, dx
462 % \end{empheq}
463 % \end{document}
464 % \end{verbatim}
465 % This gives the following display:
466 % \begin{empheq}{align*}
467 % a&=b \tag{*}\\
468 % E&=mc^2 + \int_a^a x\, dx
469 % \end{empheq}
470 % Maybe not the most impressive example, but as you can see the
471 % contents of the environment are exactly the same as for the regular
472 % \env{align*} evironment from \pkg{amsmath}. The rest of the \AmS{}
473 % environments are chosen the same way by typing the name as the
474 % mandatory argument of \env{empheq} with the exception of the
475 % \env{alignat} environment. For this you have to specify the number
476 % of columns as shown below.
477 % \begin{verbatim}
478 % \begin{empheq}{alignat=2}
479 % a &= b &\quad c &= d \\
480 % \text{this} &= \text{that} &\quad \mathit{fish}&\neq fish
481 % \end{empheq}
482 % \end{verbatim}
483 % \begin{empheq}{alignat=2}
484 % a &= b &\quad c &= d \\
485 % \text{this} &= \text{that} &\quad \mathit{fish}&\neq fish
486 % \end{empheq}
487 % To choose the starred version of \env{alignat}, simply type
488 % \arg{alignat*=2} instead in the above example.
489 %
490 % The supported \AmS{} environments are listed in Table
491 % \vref{tab:environments}. Not supported is the standard \LaTeX{}
492 % \env{eqnarray} environment as it is fundamentally
493 % deficient.\footnote{See for instance
494 % \url{http://www.tex.ac.uk/cgi-bin/texfaq2html?label=eqnarray}}
495 %
496 % \begin{table}
497 % \centering
498 % \begin{tabular}{llll}\toprule
499 % Environment & Usage & Environment & Usage \\ \midrule
500 % \TabDescribeAmsKey{equation}
501 % \TabDescribeAmsKey{align}
502 % \TabDescribeAmsKey{gather}
503 % \TabDescribeAmsKey{flalign}
504 % \TabDescribeAmsKey[=\textrm{\meta{cols}}]{alignat}
505 % \TabDescribeAmsKey{multline} \bottomrule
506 % \end{tabular}
507 % \caption{The supported \pkg{amsmath}
508 % environments}\label{tab:environments}
509 % \end{table}
510 %
511 %
512 % \subsection{Markup instructions}
513 %
514 % The optional argument of the \env{empheq} environment will take
515 % markup instructions consisting of a $\meta{key}=\meta{value}$ list
516 % of assignments. There are currently five such keys (a sixth is
517 % added for naming consistency). They're shown in Table
518 % \vref{tab:keys}.
519 %
520 % \begin{table}
521 % \centering
522 % \begin{tabular}{llp{13em}}\toprule
523 % Key & Usage & Additional Info \tabularnewline \midrule
524 % \TabDescribeOptKey{box}{box command}
525 % \TabDescribeOptKey{innerbox}{box command}
526 % \TabDescribeOptKey[Use \cs{text}\arg{...} if you need text
527 % material.]{left}{math material}
528 % \TabDescribeOptKey[Use \cs{text}\arg{...} if you need text
529 % material.]{right}{math material}
530 % \TabDescribeOptKey[Alias for \key{box}.]{outerbox}{box command}
531 % \TabDescribeOptKey[Contents must be horizontally centered;
532 % can only be used in \mode{fleqn} mode.]
533 % {marginbox}{box command}
534 % \bottomrule
535 % \end{tabular}
536 % \caption{The six keys for the optional argument of the
537 % \env{empheq} environment}\label{tab:keys}
538 % \end{table}
539 %
540 % \begin{codesyntax}
541 % \SpecialKeyIndex{left}\key{left}
542 % \end{codesyntax}
543 % The key \key{left} is for material put on the left side of the
544 % display. The material is typeset in math mode and centered
545 % vertically.
546 % \begin{verbatim}
547 % \begin{empheq}[left=L\Rightarrow]{align}
548 % a&=b\\
549 % E&=mc^2 + \int_a^a x\, dx
550 % \end{empheq}
551 % \end{verbatim}
552 % \begin{empheq}[left=L\Rightarrow]{align}
553 % a&=b\\
554 % E&=mc^2 + \int_a^a x\, dx
555 % \end{empheq}
556 %
557 %
558 % \begin{codesyntax}
559 % \SpecialKeyIndex{right}\key{right}
560 % \end{codesyntax}
561 % As there is a \key{left} key it hopefully comes as no surprise
562 % that there is a companion \key{right} key for typesetting material
563 % on the right side of the display.
564 % \begin{verbatim}
565 % \begin{empheq}[right=\Leftarrow R]{align}
566 % a&=b\\
567 % E&=mc^2 + \int_a^a x\, dx
568 % \end{empheq}
569 % \end{verbatim}
570 % \begin{empheq}[right=\Leftarrow R]{align}
571 % a&=b\\
572 % E&=mc^2 + \int_a^a x\, dx
573 % \end{empheq}
574 %
575 % \begin{codesyntax}
576 % \SpecialKeyIndex{box}\key{box}\\
577 % \SpecialKeyIndex{outerbox}\key{outerbox}
578 % \end{codesyntax}
579 % The key \key{box} specifies the kind of box you would like to put
580 % around the display. It can be any kind of box, as long as the
581 % contents of the box are situated on the baseline like in a
582 % \fbox{\cs{fbox}}.
583 % \begin{verbatim}
584 % \begin{empheq}[box=\fbox]{align}
585 % a&=b\\
586 % E&=mc^2 + \int_a^a x\, dx
587 % \end{empheq}
588 % \end{verbatim}
589 % \begin{empheq}[box=\fbox]{align}
590 % a&=b\\
591 % E&=mc^2 + \int_a^a x\, dx
592 % \end{empheq}
593 % The key \key{outerbox} is an alias for \key{box} and is added for
594 % naming consistency with the key described below.
595 %
596 % \begin{codesyntax}
597 % \SpecialKeyIndex{innerbox}\key{innerbox}
598 % \end{codesyntax}
599 % There is also an \key{innerbox} key. It is not very interesting
600 % unless you use one of the other keys.
601 % \begin{verbatim}
602 % \begin{empheq}[innerbox=\fbox,
603 % left=L\Rightarrow]{align}
604 % a&=b\\
605 % E&=mc^2 + \int_a^a x\, dx
606 % \end{empheq}
607 % \end{verbatim}
608 % \begin{empheq}[innerbox=\fbox,
609 % left=L\Rightarrow]{align}
610 % a&=b\\
611 % E&=mc^2 + \int_a^a x\, dx
612 % \end{empheq}
613 %
614 % \begin{codesyntax}
615 % \SpecialKeyIndex{marginbox}\key{marginbox}
616 % \end{codesyntax}
617 % \FeatureRequest{Uwe Siart}{2003/12/08}
618 % The last key is the \key{marginbox} key. If you typeset your math
619 % in \mode{fleqn} mode\footnote{Sorry, but I can't show you because
620 % this manual features centered math displays.} you may want the
621 % math display and not the outer box to align at the left margin (or
622 % rather: the indentation). If you make sure the contents of the
623 % outer box are centered horizontally inside the box, \key{marginbox}
624 % will align it properly. You shouldn't set both \key{box} and
625 % \key{marginbox} at the same time, as this is surely not what you
626 % want and the package will silently use the last one in the list.
627 %
628 %
629 % \begin{quote}
630 % \textbf{Warning}: \pkg{keyval} treats commas and equal signs as
631 % separator and assignment signs which in turn means that if you
632 % want to typeset either of them, they \emph{must}---and believe me,
633 % it's really important---be enclosed in braces. In short:
634 % \begin{description}
635 % \item[{\makebox[3em][l]{Good}}] \texttt{[left=\{(A,B)=(1,0)\}]}
636 % \item[{\makebox[3em][l]{Bad}}] \texttt{[left=(A,B)=(1,0)]}
637 % \end{description}
638 % \end{quote}
639 %
640 % \begin{codesyntax}
641 % \SpecialUsageIndex{\empheqset}\cs{empheqset}\marg{markup instructions}
642 % \end{codesyntax}
643 % \FeatureRequest{Uwe Siart}{2004/01/13}
644 % You can also set the keys globally\footnote{Or rather: outside the
645 % scope of the \env{empheq} environment. The settings will still
646 % obey scoping rules.} with the command
647 % \cs{empheqset}. This means that
648 % \begin{verbatim}
649 % \empheqset{marginbox=\psframebox}
650 % \end{verbatim}
651 % will force a |box=\psframebox| in all occurrences of the
652 % \env{empheq} environment, but an explicitly given \key{box} or
653 % \key{marginbox} will override this setting. You can only use the
654 % keys listed in this section as arguments to \cs{empheqset}; not
655 % the \AmS\ environments.
656 %
657 %
658 %
659 % \subsection{What won't work in the \env{empheq} environment}
660 %
661 % \begin{codesyntax}
662 % \SpecialUsageIndex{intertext}\cs{intertext}\marg{text}\\
663 % \SpecialUsageIndex{displaybreak}\cs{displaybreak}\oarg{num}
664 % \end{codesyntax}
665 % Now we've seen some of the things that work in the \env{empheq}
666 % environment but we also have to take note of what won't work. As
667 % this package provides a way to box multi line math displays it can
668 % come as no surprise that using either \cs{intertext}\footnote{And
669 % thus also \cs{shortintertext} (\pkg{mathtools}).} or
670 % \cs{displaybreak} inside the \env{empheq} environment makes no
671 % sense. Should you however happen to try them anyway, you'll
672 % experience that \cs{intertext} issues an error message and
673 % \cs{displaybreak} issues a warning. The reason only \cs{intertext}
674 % gives an error message is that you'll get output very different
675 % from what you expect, and that is not the case (so much at least)
676 % with \cs{displaybreak}. But of course, you'll never see either
677 % message because you read the manual!
678 % \begin{codesyntax}
679 % Very long lines
680 % \end{codesyntax}
681 % The standard \AmS\ environments will move the equation number if a
682 % line gets too close to it. Due to implementation, this feature is
683 % \emph{not} carried correctly to the \env{empheq} environments, so keep
684 % equation lines short then applying \env{empheq} to them.
685 %
686 % \subsection{Special delimiters}
687 %
688 % As you've seen a few pages back, it's possible to add material on
689 % both sides of the math display. When doing so you often need a
690 % delimiter that scales to fit the entire display, so it comes as no
691 % surprise that \pkg{empheq} provides such delimiters.
692 % \begin{codesyntax}
693 % \cs{empheql}\meta{delim_name} \cs{empheqbigl}\meta{delim_name}\\
694 % \cs{empheqr}\meta{delim_name} \cs{empheqbigr}\meta{delim_name}
695 % \end{codesyntax}
696 % For example one might need a large brace like the one in the
697 % \env{cases} environment:
698 % \begin{verbatim}
699 % \begin{empheq}[left=\empheqlbrace, right=\empheqrbrace]{align}
700 % E&=mc^2 \\
701 % Y&= \sum_{n=1}^\infty \frac{1}{n^2}
702 % \end{empheq}
703 % \end{verbatim}
704 % \begin{empheq}[left=\empheqlbrace, right=\empheqrbrace]{align}
705 % E&=mc^2 \\
706 % Y&= \sum_{n=1}^\infty \frac{1}{n^2}
707 % \end{empheq}
708 % The naming scheme is \cs{empheq}\meta{delimiter name} and
709 % \cs{empheqbig}\meta{delimiter name}. Thus \cs{empheqrbrace}
710 % produces an auto-scaling right brace with same size as the math
711 % display while \cs{empheqbigrbrace} produces an even bigger version
712 % that spans the inner box plus the math display inside it. For a
713 % complete list of supported delimiters see Table
714 % \vref{tab:delimiters}.
715 %
716 % \begin{table}
717 % \centering
718 % \begin{tabular}{lllc} \toprule
719 % \multicolumn{3}{c}{\textbf{Delimiter}}\\ \cmidrule{1-3}
720 % \multicolumn{1}{c}{Original} & \multicolumn{1}{c}{Normal} &
721 % \multicolumn{1}{c}{Bigger} & Symbol\\ \midrule
722 % \DescribeDelimiter{lbrace} \DescribeDelimiter{rbrace}
723 % \DescribeDelimiter{lbrack} \DescribeDelimiter{rbrack} \midrule
724 % \DescribeDelimiter{langle} \DescribeDelimiter{rangle}
725 % \DescribeDelimiter{lparen} \DescribeDelimiter{rparen} \midrule
726 % \DescribeDelimiter{lvert} \DescribeDelimiter{rvert}
727 % \DescribeDelimiter{lVert} \DescribeDelimiter{rVert} \midrule
728 % \DescribeDelimiter{lfloor} \DescribeDelimiter{rfloor}
729 % \DescribeDelimiter{lceil} \DescribeDelimiter{rceil} \bottomrule
730 % \end{tabular}
731 % \caption{The supported auto-scaling delimiters in
732 % \pkg{empheq}}\label{tab:delimiters}
733 % \end{table}
734 %
735 %
736 %
737 % \section{Taking things a little further}
738 %
739 % So far we have covered the basic functions of \pkg{empheq}: the
740 % markup instructions and the predefined auto-scaling delimiters.
741 % There is more to \pkg{empheq} however, and we'll cover that in
742 % this section.
743 %
744 % \subsection{Loading the package}
745 %
746 % The package has two main requirements: One is the
747 % \pkg{mathtools}\footnote{By the same author and is distributed
748 % with \pkg{empheq}. See its documentation for more information.}
749 % package which provides \pkg{empheq} with a lot of necessary tools
750 % for doing its thing. The other one is \pkg{amsmath} of course, and
751 % to make the loading procedure as easy as possible, you can simply
752 % substitute
753 % \begin{verbatim}
754 % \usepackage[leqno,fleqn,intlimits]{amsmath}
755 % \end{verbatim}
756 % with
757 % \begin{verbatim}
758 % \usepackage[leqno,fleqn,intlimits]{empheq}
759 % \end{verbatim}
760 % \pkg{empheq} makes sure that the \pkg{amsmath} options are passed
761 % on and loaded by \pkg{amsmath}. The same goes for the options
762 % provided by \pkg{mathtools}.
763 %
764 %
765 % \subsubsection{Compatibility with the old version}
766 %
767 % The current version (\fileversion) of \pkg{empheq} is incompatible with
768 % versions prior to and including~0.7e. If you have documents produced
769 % with versions prior to~0.7e, then you have to load the package
770 % \pkg{empheq07} instead. \pkg{empheq07} now exists as a separate package
771 % with its own documentation, but I strongly recommend switching
772 % to the new version because it is so much better.
773 %
774 % \subsection{Package options}
775 %
776 % In addition to the \pkg{amsmath} options, \pkg{empheq} itself
777 % provides a string of options listed in Table \vref{tab:options}.
778 %
779 % \begin{table}[ht]
780 % \centering
781 % \begin{tabular}{lp{21em}} \toprule
782 % Option & Short description \tabularnewline \midrule
783 % \TabDescribeOption[]{overload}
784 % {Lets you use the \pkg{empheq} visual markup extensions
785 % transparently in an existing document.}
786 % \TabDescribeOption[]{overload2}
787 % {A wild version of \opt{overload}. Use with care.}
788 % \TabDescribeOption[]{ntheorem}
789 % {A support module for users of \pkg{ntheorem} and its
790 % \opt{thmmarks} and \opt{thref} options.}
791 % \TabDescribeOption[]{newmultline}
792 % {With v2.10 of \pkg{empheq} the syntax for \env{multline} and
793 % \env{multlined} has been improved immensely.}
794 % \TabDescribeOption[]{oldmultline}
795 % {Support for the somewhat strange syntax for \env{multline} and
796 % \env{multlined} in v2.00.}
797 % \bottomrule
798 % \end{tabular}
799 % \caption{Supported options in the \pkg{empheq} package}
800 % \label{tab:options}
801 % \end{table}
802 %
803 %
804 % \begin{codesyntax}
805 % \SpecialOptIndex{ntheorem}\opt{ntheorem}
806 % \end{codesyntax}
807 % The \pkg{ntheorem} package is supported by means of the
808 % \opt{ntheorem} option. In order for this to work properly, an
809 % \pkg{amsmath} bug\footnote{See the \LaTeX{} Bugs Database
810 % \url{http://www.latex-project.org/cgi-bin/ltxbugs2html} under
811 % \AmS-\LaTeX{} problem report 3624.} is fixed. For more information
812 % on this option see \S \vref{sec:ntheorem-support}.
813 %
814 % \subsubsection{Using \env{multline}}
815 %
816 % \begin{codesyntax}
817 % \SpecialOptIndex{newmultline}\opt{newmultline}\\
818 % \SpecialOptIndex{oldmultline}\opt{oldmultline}
819 % \end{codesyntax}
820 % Those familiar with v2.00 of this package will recognize the
821 % somewhat weird syntax for using \env{multline} and
822 % \env{multlined}. The good news is that since v2.10 there is now a
823 % much improved syntax available. The option \opt{newmultline}
824 % (default) selects this better interface, while the old interface
825 % is provided for compatibility reasons by the \opt{oldmultline}
826 % option.
827 %
828 %
829 % \begin{codesyntax}
830 % \SpecialUsageIndex{\shoveleft}\cs{shoveleft}\oarg{dimen}\marg{arg}\\
831 % \SpecialUsageIndex{\shoveright}\cs{shoveright}\oarg{dimen}\marg{arg}
832 % \end{codesyntax}
833 % With the new interface you also get an extended syntax for
834 % \cs{shoveleft} and \cs{shoveright} as shown in the example below.
835 % \begin{verbatim}
836 % \begin{empheq}{multline}
837 % \framebox[.65\columnwidth]{First line} \\
838 % \framebox[.5\columnwidth]{Second line} \\
839 % \shoveleft{L+E+F+T} \\
840 % \shoveright{R+I+G+H+T} \\
841 % \shoveleft[1cm]{L+E+F+T} \\
842 % \shoveright[\widthof{$R+I+G+H+T$}]{R+I+G+H+T} \\
843 % \framebox[.65\columnwidth]{Last line}
844 % \end{empheq}
845 % \end{verbatim}
846 % \begin{empheq}{multline}
847 % \framebox[.65\columnwidth]{First line} \\
848 % \framebox[.5\columnwidth]{Second line} \\
849 % \shoveleft{L+E+F+T} \\
850 % \shoveright{R+I+G+H+T} \\
851 % \shoveleft[1cm]{L+E+F+T} \\
852 % \shoveright[\widthof{$R+I+G+H+T$}]{R+I+G+H+T} \\
853 % \framebox[.65\columnwidth]{Last line}
854 % \end{empheq}
855 %
856 %
857 % There are however a few differences in the output between the
858 % original \pkg{amsmath} version of \env{multline} and the one
859 % \pkg{empheq} provides. In \pkg{amsmath} a centered line in
860 % \env{multline} is centered on the page without taking into account
861 % the \cs{multlinegap}, \cs{multlinetaggap}, and the tag width. Thus
862 % \pkg{amsmath} can sometimes give you horrible output without
863 % giving you any warning as shown below.
864 % \begin{verbatim}
865 % \begin{multline}
866 % \framebox[.65\columnwidth]{First line} \\
867 % \framebox[.9\columnwidth]{Loooong line} \\
868 % \framebox[.65\columnwidth]{Last line} \tag{wide tag}
869 % \end{multline}
870 % \end{verbatim}
871 % \begin{AmSmultline}
872 % \framebox[.65\columnwidth]{First line} \\
873 % \framebox[.9\columnwidth]{Loooong line} \\
874 % \framebox[.65\columnwidth]{Last line} \tag{wide tag}
875 % \end{AmSmultline}
876 % In \pkg{empheq} these parameters are taken into account, so the
877 % same input will produce this in \pkg{empheq}:
878 % \begin{verbatim}
879 % \begin{empheq}{multline}
880 % \framebox[.65\columnwidth]{First line} \\
881 % \framebox[.9\columnwidth]{Loooong line} \\
882 % \framebox[.65\columnwidth]{Last line} \tag{wide tag}
883 % \end{empheq}
884 % \end{verbatim}
885 % \begin{multline*}
886 % \framebox[.65\columnwidth]{First line} \\
887 % \framebox[.9\columnwidth]{Loooong line} \\
888 % \framebox[.65\columnwidth]{Last line} \tag{wide tag}
889 % \end{multline*}
890 % This results in an
891 % \begin{verbatim}
892 % Overfull \hbox (30.03783pt too wide) in paragraph ...
893 % \end{verbatim}
894 % message in the log file, indicating a visual problem. I think this
895 % behavior is more sensible than the one the original \env{multline}
896 % environment provides.
897 %
898 % \begin{codesyntax}
899 % \SpecialEnvIndex{MTmultlined}\cs{begin}\arg{MTmultlined}\oarg{pos}\oarg{width}
900 % \meta{contents} \cs{end}\arg{MTmultlined}
901 % \end{codesyntax}
902 % When you choose the \opt{oldmultline} option you may still want to
903 % use the much improved \env{multlined} environment defined in
904 % \pkg{mathtools} but unfortunately there will be a name clash.
905 % Instead you can access it under the name \env{MTmultlined}.
906 %
907 %
908 %
909 % \subsubsection{The \opt{overload} option}\label{sec:overload}
910 %
911 % \begin{codesyntax}
912 % \SpecialOptIndex{overload}\opt{overload}\\
913 % \SpecialOptIndex{overload2}\opt{overload2}
914 % \end{codesyntax}
915 % \FeatureRequest{Lars Madsen}{2004/03/25}
916 % The \opt{overload} option redefines the original \AmS{}
917 % environments so that they take an optional argument.
918 % \begin{codesyntax}
919 % \cs{begin}\marg{\AmS{} env_name}\oarg{markup instructions}\\
920 % \meta{contents of \AmS{} environment}\\
921 % \cs{end}\marg{\AmS{} env_name}
922 % \end{codesyntax}
923 % For example
924 % \begin{verbatim}
925 % \begin{gather}[box=\widefbox]
926 % a = b
927 % \end{gather}
928 % \end{verbatim}
929 % is then actually short for
930 % \begin{verbatim}
931 % \begin{empheq}[box=\widefbox]{gather}
932 % a = b
933 % \end{empheq}
934 % \end{verbatim}
935 % All the \AmS{} environments are supported by this option except
936 % for the pseudo environment |\[ ... \]| (it's not really an
937 % environment), \footnote{With the option \opt{oldmultline} the
938 % \env{multline} and \env{multline*} environments aren't supported
939 % either because their syntax in \pkg{empheq} then differs from their
940 % syntax in \pkg{amsmath}.} because a)~you don't really need markup
941 % instructions for a one line display, and b)~would you really like
942 % a syntax like
943 % \begin{verbatim}
944 % \[[box=\fbox] a=b \]
945 % \end{verbatim}
946 % where it's difficult to see whether or not there is a typo?
947 % Choosing \opt{overload} is meant for people who don't want to
948 % change their entire document into \pkg{empheq} syntax. I have no
949 % problems with that; just be careful when you fiddle with
950 % \cs{empheqset} as it will affect \emph{all} math displays!
951 %
952 %
953 % There is of course a catch (well, two actually): These redefined
954 % environments don't run as fast as the regular ones (about three
955 % times as slow), but in this day and age I seriously doubt you'll
956 % be able to tell the difference unless you have a vast number of
957 % equations. The other catch is that you cannot use \cs{intertext}
958 % and \cs{displaybreak} as described earlier. If you find yourself
959 % wanting to use one of these features in say, an \env{align}
960 % environment, you have to use the original \env{align} environment.
961 % Luckily it is available if you call it like this:
962 % \begin{codesyntax}
963 % \cs{begin}\arg{AmS\meta{\rmfamily \AmS{} env_name}} \\
964 % \texttt{~~}\meta{contents of \AmS{} environment}\\
965 % \cs{end}\arg{AmS\meta{\rmfamily \AmS{} env_name}}
966 % \end{codesyntax}
967 % For example the original \env{align} environment could be selected
968 % with
969 % \begin{verbatim}
970 % \begin{AmSalign}
971 % ...
972 % \end{AmSalign}
973 % \end{verbatim}
974 % These original versions with prefix \texttt{AmS} exist for all the
975 % environments.
976 %
977 %
978 % The option \opt{overload2} activates the overloading feature
979 % for the pseudo environment |\[ ... \]|, although I doubt you'll
980 % find it useful. Beware that this definition is fragile unless you
981 % have \eTeX{} as \LaTeX{} engine.\footnote{\eTeX{} has been the
982 % default engine for \LaTeX{} in most major distributions since
983 % 2003.} Not surprisingly \opt{overload2} activates
984 % \opt{overload}.
985 %
986 %
987 %
988 % Before you get all excited about these options, you should take
989 % note of some aspects of centered math displays in \pkg{amsmath}.
990 % In certain circumstances truly centering the display is not always
991 % the best solution as in this example:
992 % \begin{center}
993 % \mbox{}\hfill
994 % \framebox[.75\linewidth]{Wide math display; not adjusted}%
995 % \hfill\mbox{}%
996 % \makebox[0pt][r]{Wide Tag}
997 % \end{center}
998 % Instead centering the display in the available space works pretty
999 % well:
1000 % \begin{gather*}
1001 % \framebox[.75\linewidth]{Wide math display; adjusted}%
1002 % \tag*{Wide Tag}
1003 % \end{gather*}
1004 % This is what \pkg{amsmath} does normally, but in the \env{gather}
1005 % environment it does it on a per line basis. This means that we get
1006 % results like
1007 % \begin{AmSgather*}
1008 % \framebox[.75\linewidth]{Wide math display; adjusted}%
1009 % \tag*{Wide Tag} \\
1010 % \framebox[.75\linewidth]{Wide math display; not adjusted} \tag{i}%
1011 % \end{AmSgather*}
1012 % whether we like it or not. Inside the \env{empheq} environment we
1013 % need to have the same adjustment for all lines else the boxing
1014 % process will not work properly, so when activating the
1015 % \opt{overload} option the above two-line \env{gather} will
1016 % instead look like this:
1017 % \begin{empheq}{gather*}
1018 % \framebox[.75\linewidth]{Wide math display; adjusted}%
1019 % \tag*{Wide Tag} \\
1020 % \framebox[.75\linewidth]{Wide math display; adjusted} \tag*{i}%
1021 % \end{empheq}
1022 % I leave it to you to choose whether or not this is better (I think
1023 % it is better).
1024 %
1025 %
1026 %
1027 % \subsection{A note on boxed displays}
1028 %
1029 % When browsing a 400+ pages textbook with at least twice the number
1030 % of displayed formulae, some of them are surely more important than
1031 % others. Thus the author of the book (in cooperation with the
1032 % designer) should make sure that such formulae are easily found
1033 % again i.e., they should be easily distinguishable from the rest of
1034 % the pack. One way of doing this is putting the formula into a box
1035 % which is something we've seen \pkg{empheq} being capable of. There
1036 % are however a few things to keep in mind:
1037 % \begin{itemize}
1038 % \item Don't overdo it. If you do it on half of them there's no
1039 % point in doing it at all. I don't see much reason for applying
1040 % this technique to more than 10\% of the formulae.
1041 % \item Choose the type of box carefully. You want to draw
1042 % attention to it so it might as well look good.
1043 % \end{itemize}
1044 % The latter point can be illustrated by defining a macro similar to
1045 % \cs{fbox} only with a little more space to the right and left of
1046 % the argument.
1047 % \begin{verbatim}
1048 % \newcommand*\widefbox[1]{\fbox{\hspace{1em}#1\hspace{1em}}}
1049 % \end{verbatim}
1050 % If we replace the \cs{fbox} from the \key{box} example before, we
1051 % get this display:
1052 % \begin{verbatim}
1053 % \begin{empheq}[box=\widefbox]{align}
1054 % a&=b\\
1055 % E&=mc^2 + \int_a^a x\, dx
1056 % \end{empheq}
1057 % \end{verbatim}
1058 % \begin{empheq}[box=\widefbox]{align}
1059 % a&=b\\
1060 % E&=mc^2 + \int_a^a x\, dx
1061 % \end{empheq}
1062 % Compare it with
1063 % \begin{empheq}[box=\fbox]{align}
1064 % a&=b\\
1065 % E&=mc^2 + \int_a^a x\, dx
1066 % \end{empheq}
1067 % and see which one you prefer.
1068 %
1069 % Similarly one might be tempted to use colored boxes:
1070 % \begin{verbatim}
1071 % \definecolor{myblue}{rgb}{.8, .8, 1}
1072 % \newcommand*\mybluebox[1]{%
1073 % \colorbox{myblue}{\hspace{1em}#1\hspace{1em}}}
1074 % \end{verbatim}
1075 % We know the drill by now.
1076 % \begin{verbatim}
1077 % \begin{empheq}[box=\mybluebox]{align}
1078 % a&=b\\
1079 % E&=mc^2 + \int_a^a x\, dx
1080 % \end{empheq}
1081 % \end{verbatim}
1082 % \begin{empheq}[box=\mybluebox]{align}
1083 % a&=b\\
1084 % E&=mc^2 + \int_a^a x\, dx
1085 % \end{empheq}
1086 % There is more on boxes later in this manual. If you're into the
1087 % \pkg{fancybox} package then remember to read \S
1088 % \vref{sec:fancybox_support}.
1089 %
1090 % \section{Support for other packages}
1091 %
1092 % With the multitude of packages for \LaTeX, it is not always easy
1093 % to be a PWWO package (``Plays Well With Others''), but
1094 % \pkg{empheq} tries really hard to do so. This section lists the
1095 % packages where \pkg{empheq} has to provide workarounds and they
1096 % can be divided into two categories.
1097 % \begin{description}
1098 % \item[Compatibility] Some packages affect \LaTeX's labelling
1099 % mechanism and since \pkg{empheq} internally has to turn off
1100 % labels and related code temporarily, hooks must be provided for
1101 % these packages. Examples of such packages are \pkg{hyperref} and
1102 % \pkg{showkeys}.
1103 %
1104 % \item[Enhancements] Other packages provide useful features that
1105 % for some reason may not work directly or optimally with
1106 % \pkg{empheq}. In these cases the problematic commands are
1107 % redefined so that they not only work with \pkg{empheq}, but
1108 % also give the same if not better output. An example of this
1109 % would be the \cs{shadowbox} command from \pkg{fancybox}
1110 % (described below).
1111 % \end{description}
1112 % %
1113 % \subsection{Support for \pkg{fancybox}}\label{sec:fancybox_support}
1114 %
1115 % The \pkg{fancybox} package provides various boxes and you can use
1116 % them with \pkg{empheq} as well. Here's \cs{ovalbox}:
1117 % \begin{verbatim}
1118 % \begin{empheq}[box=\ovalbox]{align}
1119 % E&=mc^2 \\
1120 % Y&= \sum_{n=1}^\infty \frac{1}{n^2}
1121 % \end{empheq}
1122 % \end{verbatim}
1123 % \begin{empheq}[box=\ovalbox]{align}
1124 % E&=mc^2 \\
1125 % Y&= \sum_{n=1}^\infty \frac{1}{n^2}
1126 % \end{empheq}
1127 %
1128 %
1129 % \begin{codesyntax}
1130 % \SpecialUsageIndex{\shadowbox}\SpecialUsageIndex{\shadowbox*}
1131 % \cs{shadowbox*}\marg{arg} \\
1132 % \SpecialColorIndex{shadowcolor} \texttt{shadowcolor}
1133 % \end{codesyntax}
1134 % The only problem with using the \pkg{fancybox} boxes in
1135 % conjunction with the \env{empheq} environment is \cs{shadowbox},
1136 % as this macro typesets the shadow on the baseline and for the
1137 % equation numbers to be placed correctly, the box command must set
1138 % its argument on the baseline. Thus the normal \cs{shadowbox}
1139 % produces \shadowbox{\meta{arg}}, but we need this instead:
1140 % \shadowbox*{\meta{arg}}. Therefore \pkg{empheq} will detect if
1141 % \pkg{fancybox} is loaded and in that case it'll enhance
1142 % \cs{shadowbox} in two ways:
1143 % \begin{itemize}
1144 % \item It defines a starred version \cs{shadowbox*} which
1145 % typesets its argument on the baseline.
1146 %
1147 % \item The color \texttt{shadowcolor} is introduced. The default
1148 % color is black.
1149 % \end{itemize}
1150 % \begin{verbatim}
1151 % \definecolor{shadowcolor}{rgb}{0,.5,.5}
1152 % \setlength\shadowsize{2pt}
1153 % Line of text for \shadowbox*{testing of \Verb|f#&%\| verbatim} and
1154 % showing the shadow color.
1155 % \end{verbatim}
1156 % \begin{quote}
1157 % \definecolor{shadowcolor}{rgb}{0,.5,.5}
1158 % \setlength\shadowsize{2pt}
1159 % Line of text for \shadowbox*{testing of \Verb|f#&%\| verbatim} and
1160 % showing the shadow color.
1161 % \end{quote}
1162 %
1163 % The point is that if you want a \cs{shadowbox} around your math
1164 % display then you must use the starred version:
1165 % \begin{verbatim}
1166 % \begin{empheq}[box=\shadowbox*]{align}
1167 % E&=mc^2 \\
1168 % Y&= \sum_{n=1}^\infty \frac{1}{n^2}
1169 % \end{empheq}
1170 % \end{verbatim}
1171 % \begin{empheq}[box=\shadowbox*]{align}
1172 % E&=mc^2 \\
1173 % Y&= \sum_{n=1}^\infty \frac{1}{n^2}
1174 % \end{empheq}
1175 %
1176 % See \S \vref{stunning} if you want
1177 % to make a fancy box yourself.
1178 %
1179 %
1180 % \subsection{Support for \pkg{ntheorem}}\label{sec:ntheorem-support}
1181 %
1182 % \changes{v2.13}{2012/05/09}{Added caveat}
1183 % \textbf{Caveat:} Due to an unfortunate interaction between \pkg{empheq} and
1184 % \pkg{ntheorem}, users may want to add
1185 % \begin{verbatim}
1186 % \usetagform{default}
1187 % \end{verbatim}
1188 % \emph{after} loading \pkg{ntheorem} otherwise the tags may be
1189 % placed wrong and any labels within the \env{empheq} environment may
1190 % be lost. In the future \pkg{ntheorem} should be able to test for
1191 % this and add \verb|\usetagform{default}| automatically.
1192 %
1193 % Users who use \verb|\usetagform| to get another tag design should
1194 % make sure to postpone this configuration until \emph{after} loading
1195 % \pkg{ntheorem}.
1196 %
1197 % \bigskip
1198 %
1199 % \changes{v2.00}{2004/04/14}{Added description of the
1200 % \opt{ntheorem} option}
1201 % \changes{v1.05}{2004/02/16}{Added support for the end-of-theorem
1202 % marker mechanism of \pkg{ntheorem}}
1203 %
1204 % \begin{codesyntax}
1205 % \SpecialOptIndex{ntheorem}\opt{ntheorem}
1206 % \end{codesyntax}
1207 % The \pkg{ntheorem} package is supported by the means of the
1208 % \opt{ntheorem} option of \pkg{empheq}. This loads a set of
1209 % extra macros which fixes various compatibility problems between
1210 % \pkg{ntheorem} and \pkg{amsmath} and furthermore introduces
1211 % special (internal) macros for optimum positioning of
1212 % end-of-theorem markers, while retaining a user friendly interface.
1213 %
1214 %
1215 % When you want to use the automatic end-of-theorem marker mechanism
1216 % from \pkg{ntheorem} you sometimes run into problems as you would
1217 % want the marker to be placed aligned at the bottom of the math
1218 % display but still keeping the tags in their proper place. In
1219 % \mode{leqno} mode this is not that much of a problem as the tags
1220 % and the marker are set on either side of the math display like
1221 % in Figure \vref{fig:markerI}.
1222 % \changes{v1.05a}{2004/02/17}{Added explanatory drawings for
1223 % \pkg{ntheorem}}
1224 %
1225 % \begin{figure}[btp]\centering
1226 % \unitlength2.5pt \thicklines
1227 % \begin{picture}(90,30)(-30,40)
1228 % \put(0,50){\framebox(25,20){Math Height}}
1229 % \put(0,40){\framebox(25,10){Math Depth}}
1230 % \put(-30,50){\framebox(20,10){Tag height}}
1231 % \put(-30,45){\framebox(20,5){Tag depth}}
1232 % \put(40,40){\framebox(20,10){Marker}}
1233 % \multiput(26,40)(2,0){7}{\line(1,0){1}}
1234 % \end{picture}
1235 % \caption{Marker placement in \mode{leqno} mode}
1236 % \label{fig:markerI}
1237 % \end{figure}
1238 %
1239 % \begin{codesyntax}
1240 % \SpecialUsageIndex{\mintagvsep}\cs{mintagvsep}
1241 % \end{codesyntax}
1242 % Unfortunately things are not this easy in \mode{reqno} mode. There
1243 % are two possible situations as shown in Figure \vref{fig:markerII}.
1244 % \begin{figure}[btp]
1245 % \unitlength2.5pt \thicklines
1246 % \begin{picture}(60,45)(0,25)
1247 % \put(0,50){\framebox(25,20){Math Height}}
1248 % \put(0,25){\framebox(25,25){Math Depth}}
1249 % \put(40,50){\framebox(20,10){Tag height}}
1250 % \put(40,45){\framebox(20,5){Tag depth}}
1251 % \put(40,25){\framebox(20,10){Marker}}
1252 % \put(50,35){\vector(0,1){10}}
1253 % \put(50,45){\vector(0,-1){10}}
1254 % \put(50,39){\ \ $>\delta$}
1255 % \multiput(26,25)(2,0){7}{\line(1,0){1}}
1256 % \end{picture} \hfill\vrule\hfill
1257 % \begin{picture}(60,45)(0,25)
1258 % \put(0,50){\framebox(25,20){Math Height}}
1259 % \put(0,40){\framebox(25,10){Math Depth}}
1260 % \put(40,50){\framebox(20,10){Tag height}}
1261 % \put(40,45){\framebox(20,5){Tag depth}}
1262 % \put(40,28){\framebox(20,10){Marker}}
1263 % \put(50,38){\vector(0,1){7}}
1264 % \put(50,45){\vector(0,-1){7}}
1265 % \put(50,40){\ \ $=\delta$}
1266 % \end{picture}
1267 % \caption{The two possible situations for end marks in \mode{reqno}
1268 % mode}
1269 % \label{fig:markerII}
1270 % \end{figure}
1271 % If possible we want the bottom of the marker to be aligned with
1272 % the bottom of the math display, but at the same time we want to
1273 % ensure a minimum vertical separation $\delta$ between marker and
1274 % tag. In \pkg{empheq} this is controlled by the length parameter
1275 % \cs{mintagvsep} which by default is 5\,pt.
1276 %
1277 % The good news is that this is where \pkg{empheq} sets in.
1278 % Basically all you need to do is to use the \env{empheq}
1279 % environment to typeset your equations inside the theorem
1280 % environments:
1281 % \begin{verbatim}
1282 % \begin{Theorem}
1283 % Some text at first and then a math display
1284 % \begin{empheq}{align}
1285 % a&=b\\
1286 % E&=mc^2 + \int_a^a x\, dx
1287 % \end{empheq}
1288 % \end{Theorem}
1289 % \end{verbatim}
1290 % Then the tag placement and the end-of-theorem marker will be set
1291 % properly (after a couple of runs as usual).
1292 %
1293 % To ensure the correct outcome remember to load the packages like
1294 % this:
1295 % \begin{verbatim}
1296 % \usepackage[ntheorem]{empheq} % this loads amsmath as well
1297 % \usepackage[thmmarks,amsmath]{ntheorem}
1298 % \end{verbatim}
1299 % Remember that if you use the \opt{overload} option you
1300 % can just use the regular math environments to get the desired
1301 % result with the end mark. The exception is the |\[ ... \]|
1302 % environment which will only work if you use the option
1303 % \opt{overload2}.
1304 %
1305 % \clearpage
1306 %
1307 % \EmphEqpart{Advanced user's guide}
1308 %
1309 % The \pkg{empheq} package has more to offer than you have seen, but
1310 % I found some of the functionality so dangerous it was best to hide
1311 % it for a little while. The commands you have encountered so far in
1312 % this manual all have one thing in common: They have only lower
1313 % case letters in their names. Now it's time to reveal those that
1314 % have \emph{mixed-case} names, thus implying that you should take
1315 % great care when using them.
1316 %
1317 % \section{Delimiters revisited}
1318 % Let's go back to delimiters, shall we?
1319 %
1320 % \subsection{Creating your own delimiters}
1321 % As a convenience for the user, this interface is extended in a
1322 % more general way so that it is also possible to declare delimiters
1323 % with the following two commands: \SpecialUsageIndex{\DeclareLeftDelimiter}
1324 % \SpecialUsageIndex{\DeclareRightDelimiter}
1325 % \begin{codesyntax}
1326 % \cs{DeclareLeftDelimiter}\oarg{space adjustment}\marg{delimiter}\\
1327 % \cs{DeclareRightDelimiter}\oarg{space adjustment}\marg{delimiter}
1328 % \end{codesyntax}
1329 % While \pkg{empheq} provides auto-scaling versions of the most
1330 % common delimiters, you may sometimes want some new ones. Say for
1331 % instance you have loaded the \pkg{stmaryrd} package and you want
1332 % to use the double bracket commands \cs{llbracket} and
1333 % \cs{rrbracket} with \pkg{empheq}. Then you simply do this:
1334 % \begin{verbatim}
1335 % \DeclareLeftDelimiter{\llbracket}
1336 % \DeclareRightDelimiter{\rrbracket}
1337 % \end{verbatim}
1338 % This defines the new delimiters \cs{empheqllbracket},
1339 % \cs{empheqbigllbracket}, \cs{empheqrrbracket} and
1340 % \cs{empheqbigrrbracket}.
1341 %
1342 % You can use \cs{big...} delimiters as well if you don't like the
1343 % automatic scaling. There are however ways to fine-tune if you
1344 % really want it.
1345 %
1346 % \subsection{Fine-tuning of delimiters}
1347 %
1348 % \TeX{} provides two primitives to control the scaling of
1349 % delimiters produced with \cs{left} and \cs{right}, namely the
1350 % dimension \cs{delimitershortfall} (denoted by $\delta$ here) and
1351 % the integer \cs{delimiterfactor} ($f$). The idea is that the
1352 % sub-formula inside the \cs{left}-\cs{right} pair is to be
1353 % vertically centered and given its height $h_1$ and its depth $h_2$
1354 % we want to produce a delimiter with total height $h$, where $h =
1355 % 2 \max(h_1,h_2)$. \TeX's rules on this are that the minimum
1356 % delimiter size $h_{\min}$ must meet the requirements
1357 % \[
1358 % h_{\min}\geq h \frac{f}{1000} \quad\land \quad h_{\min}\geq h-\delta
1359 % \]
1360 % \LaTeX{} sets $\cs{delimitershortfall} = \text{\the\delimitershortfall} $
1361 % and $\cs{delimiterfactor} = \the\delimiterfactor$, but in our case
1362 % we will almost always want a delimiter that spans the entire
1363 % \cs{left}-\cs{right} pair (the math display), thus a change of
1364 % these settings is needed.
1365 %
1366 % \begin{codesyntax}
1367 % \SpecialUsageIndex{\EmphEqdelimitershortfall}
1368 % \cs{EmphEqdelimitershortfall}\\
1369 % \SpecialUsageIndex{\EmphEqdelimiterfactor}
1370 % \cs{EmphEqdelimiterfactor}
1371 % \end{codesyntax}
1372 % However it is a bad idea to just change these two settings without
1373 % thinking of the effect it'll have on the rest of the mathematics
1374 % in your document. Therefore \pkg{empheq} provides the parameters
1375 % \cs{EmphEqdelimitershortfall} (default setting is
1376 % \the\EmphEqdelimitershortfall) and \cs{EmphEqdelimiterfactor}
1377 % (default is \the\EmphEqdelimiterfactor) to cater for this.
1378 %
1379 %
1380 % \subsection{Scaling material yourself}
1381 %
1382 % The attentive reader may have noticed that I still haven't
1383 % revealed how I managed to get the right size of that big
1384 % exclamation mark in the first example of this manual, so I guess
1385 % it's about time.
1386 % \begin{codesyntax}
1387 % \SpecialUsageIndex{\EmphEqdisplayheight}\cs{EmphEqdisplayheight} \\
1388 % \SpecialUsageIndex{\EmphEqdisplaydepth}\cs{EmphEqdisplaydepth}
1389 % \end{codesyntax}
1390 % The height of the math display plus the surrounding inner box is
1391 % given by \cs{EmphEqdisplayheight} and the depth by
1392 % \cs{EmphEqdisplaydepth}. These can be used when constructing
1393 % something that should scale to fit the display and can't be done
1394 % with ``auto-scaling'' commands like \cs{vrule} or \cs{left} or
1395 % \cs{right}. There is a catch however: If you do any horizontal
1396 % resizing of the material you want to scale, then you must specify
1397 % the width \emph{manually}:\footnote{The
1398 % \cs{fontdimen22}\cs{textfont2} in the \meta{length} argument of
1399 % \cs{raisebox} is the \emph{math axis} of the font. It is needed in
1400 % order to get the vertical positioning of the oversized exclamation
1401 % mark just right.}
1402 % \begin{verbatim}
1403 % \begin{empheq}[
1404 % box=\colorbox{myblue},
1405 % right={\;
1406 % \makebox[.9em]{%
1407 % $\raisebox{-.5\totalheight+\fontdimen22\textfont2}
1408 % {\resizebox{!}{%
1409 % \EmphEqdisplayheight+\EmphEqdisplaydepth}{!}}$%
1410 % }},
1411 % left={X=Y\Rightarrow}
1412 % ]{alignat=3}
1413 % A_1&=b_1 & \qquad c_1&=d_1 & \qquad e_1&= f_1
1414 % \tag*{\_A\raisebox{1ex}{silly}\raisebox{-1ex}{tag}\_}\\
1415 % A_2&=b_2 & \qquad c_2&=d_2 & \qquad e_2&= f_2 \\
1416 % A_3&=b_3 & \qquad c_3&=d_3 & \qquad e_3&= f_3
1417 % \end{empheq}
1418 % \end{verbatim}
1419 %
1420 % Here's another example. We want to be able to put a \cs{parbox}
1421 % with some descriptive text top-aligned on the side of the display.
1422 % \begin{verbatim}
1423 % \begin{empheq}[
1424 % left={\parbox[c][\EmphEqdisplayheight+\EmphEqdisplaydepth][t]
1425 % {4.5cm}
1426 % {You may find this kind of description useful.}\enspace}]
1427 % {align}
1428 % a&=\int_0^1 x\,dx +\frac{foo + bar}{baz}\\
1429 % E&= mc^2
1430 % \end{empheq}
1431 % \end{verbatim}
1432 % \begin{empheq}[
1433 % left={\parbox[c][\EmphEqdisplayheight+\EmphEqdisplaydepth][t]
1434 % {4.5cm}
1435 % {You may find this kind of description useful.}\enspace}]
1436 % {align}
1437 % a&=\int_0^1 x\,dx +\frac{foo + bar}{baz}\\
1438 % E&= mc^2
1439 % \end{empheq}
1440 %
1441 %
1442 % \section{A few short notes}
1443 %
1444 % \subsection{About \texorpdfstring{$\cs{eqref}$}{\textbackslash eqref}}
1445 %
1446 % Internally \env{empheq} separates the displayed math from
1447 % the corresponding equation numbers such that we can add special
1448 % delimiters or boxes. This is done by nullifying (or rather
1449 % conveniently redefining) an internal command called
1450 % \cs{maketag@@@}. Unfortunately, this component is also used by
1451 % \cs{eqref} to typeset a reference to an equation number, so in
1452 % earlier versions, \cs{eqref} would not work inside an \env{empheq}
1453 % environment.
1454 %
1455 % In the current version this should now be working, but if you ever
1456 % need to mess with \cs{eqref} it may be handy to know what is being
1457 % done. In essence we do something similar to this:
1458 % \begin{verbatim}
1459 % \let\empheqeqrefbase\textup
1460 % ... % next go inside empheq env
1461 % \renewcommand\eqref[1]{\empheqeqrefbase{%
1462 % \let\maketag@@@\EQsavedmaketag%
1463 % \tagform@{\ref{##1}}}}
1464 % \end{verbatim}
1465 % Thus if you need to alter things inside \cs{eqref} and need that to
1466 % work within \env{empheq} as well, you may get away with redefining
1467 % \cs{empheqeqrefbase}.
1468 %
1469 %
1470 %
1471 % \subsection{About changes to
1472 % \texorpdfstring{$\cs{baselineskip}$}{\textbackslash baselineskip}}
1473 %
1474 % Users should never mess with \cs{baselineskip} directly, it is not
1475 % the correct manner to get double spacing. Have a look at say the
1476 % \pkg{setspace} package or similar, or play with
1477 % \cs{baselinestretch} followed by \cs{normalsize} to initiate.
1478 %
1479 % Explanation: We use \cs{parbox} inside to place the display box and
1480 % the box containing the eqn numbers. To do its stuff \cs{parbox}
1481 % resets some internal settings, in this case, \cs{baselineskip} is
1482 % reset to \cs{normalbaselineskip}. So if you don't remember to reset
1483 % that one as well\dots
1484 %
1485 %
1486 % \section{Creating something new}
1487 %
1488 % You can create your own environments and boxes to go with
1489 % \pkg{empheq}, but there are certain things that must be fulfilled
1490 % to get it to work properly.
1491 %
1492 % \subsection{New \env{empheq}-like environments}
1493 %
1494 % \begin{codesyntax}
1495 % \SpecialEnvIndex{EmphEqMainEnv}\env{EmphEqMainEnv}\\
1496 % \SpecialUsageIndex{\EmphEqMainEnv}\cs{EmphEqMainEnv}\\
1497 % \SpecialUsageIndex{\endEmphEqMainEnv}\cs{endEmphEqMainEnv}
1498 % \end{codesyntax}
1499 % Although the real work in \pkg{empheq} is done by an environment
1500 % (\env{EmphEqMainEnv}), you cannot use it like that yourself when
1501 % you want to define an \env{empheq}-like environment. Due to
1502 % technical reasons (see~\cite{Ams99}), you have to use a slightly
1503 % different syntax:
1504 % \begin{codesyntax}
1505 % \cs{newenvironment}
1506 % \marg{env_name} \oarg{num} \oarg{default}\\
1507 % \texttt{~~}\arg{\meta{other commands} \cs{EmphEqMainEnv}}\\
1508 % \texttt{~~}\arg{\cs{endEmphEqMainEnv}}
1509 % \end{codesyntax}
1510 % In the above environment the \meta{other commands} part must
1511 % contain certain things before it'll work.
1512 % \begin{codesyntax}
1513 % \SpecialKeyFamilyIndex{EmphEqEnv}\keyfam{EmphEqEnv}\\
1514 % \SpecialKeyFamilyIndex{EmphEqOpt}\keyfam{EmphEqOpt}
1515 % \end{codesyntax}
1516 % Before your homemade environment will work you must set at least
1517 % one key. The key family \keyfam{EmphEqOpt} is for all the markup
1518 % instructions like \key{left} and \key{box}, while
1519 % \keyfam{EmphEqEnv} controls the type of \AmS{} environment. You
1520 % must set the \keyfam{EmphEqEnv} family before \cs{EmhpEqMainEnv}
1521 % else you'll get an error message.
1522 %
1523 % One example could be something like this:
1524 % \begin{verbatim}
1525 % \newenvironment{important}[2][]{%
1526 % \setkeys{EmphEqEnv}{#2}%
1527 % \setkeys{EmphEqOpt}{box=\mybluebox,#1}%
1528 % \EmphEqMainEnv}%
1529 % {\endEmphEqMainEnv}
1530 % \end{verbatim}
1531 % Thus
1532 % \begin{verbatim}
1533 % \begin{important}{gather}
1534 % a = b + c +d \\ e = f
1535 % \end{important}
1536 % \end{verbatim}
1537 % produces
1538 % \begin{important}{gather}
1539 % a = b + c +d \\ e = f
1540 % \end{important}
1541 % while
1542 % \begin{verbatim}
1543 % \begin{important}[left={A=B \Rightarrow \empheqlbrace}]{alignat=2}
1544 % a &= b &\quad c &= d \\
1545 % \text{this} &= \text{that} &\quad \mathit{fish}&\neq fish
1546 % \end{important}
1547 % \end{verbatim}
1548 % produces
1549 % \begin{important}[left={A=B \Rightarrow \empheqlbrace}]{alignat=2}
1550 % a &= b &\quad c &= d \\
1551 % \text{this} &= \text{that} &\quad \mathit{fish}&\neq fish
1552 % \end{important}
1553 %
1554 %
1555 % \subsection{Creating fancy boxes}\label{stunning}
1556 %
1557 % As a final example I will show you how to create complicated
1558 % displays involving (vertically) asymmetrical boxes like
1559 % \cs{shadowbox*}. In order to get the correct output, the contents
1560 % of the box must be placed on the baseline as in \fbox{\cs{fbox}}.
1561 % In this example we want to put a set of equations into a bright
1562 % yellow box and then add another box with some explanatory text at
1563 % the top of the yellow box making them overlap.
1564 %
1565 % First we define the colors used and allocate the boxes. We could
1566 % probably use scratch boxes, but this is safer.
1567 % \begin{verbatim}
1568 % \definecolor{shadecolor}{cmyk}{0,0,0.41,0}
1569 % \definecolor{light-blue}{cmyk}{0.25,0,0,0}
1570 % \newsavebox{\mysaveboxM} % M for math
1571 % \newsavebox{\mysaveboxT} % T for text
1572 % \end{verbatim}
1573 % Save the display body in \cs{mysaveboxM} and the text argument in
1574 % \cs{mysaveboxT}.
1575 % \begin{verbatim}
1576 % \newcommand*\Garybox[2][Example]{%
1577 % \sbox{\mysaveboxM}{#2}%
1578 % \sbox{\mysaveboxT}{\fcolorbox{black}{light-blue}{#1}}%
1579 % \end{verbatim}
1580 % Then typeset the math display in a \cs{parbox} where we control
1581 % the height and save it in \cs{mysaveboxM}.
1582 % \begin{verbatim}
1583 % \sbox{\mysaveboxM}{%
1584 % \parbox[b][\ht\mysaveboxM+.5\ht\mysaveboxT+.5\dp\mysaveboxT][b]{%
1585 % \wd\mysaveboxM}{#2}%
1586 % }%
1587 % \end{verbatim}
1588 % We put it into the colored box with the desired width.
1589 % \begin{verbatim}
1590 % \sbox{\mysaveboxM}{%
1591 % \fcolorbox{black}{shadecolor}{%
1592 % \makebox[\linewidth-10em]{\usebox{\mysaveboxM}}%
1593 % }%
1594 % }%
1595 % \end{verbatim}
1596 % Then finally we get to the real typesetting. We just insert the
1597 % math display and then make a box of zero width right next to it.
1598 % In that box we lift the text argument and center it at the top of
1599 % the display.
1600 % \begin{verbatim}
1601 % \usebox{\mysaveboxM}%
1602 % \makebox[0pt][r]{%
1603 % \makebox[\wd\mysaveboxM][c]{%
1604 % \raisebox{\ht\mysaveboxM-0.5\ht\mysaveboxT
1605 % +0.5\dp\mysaveboxT-0.5\fboxrule}{\usebox{\mysaveboxT}}%
1606 % }%
1607 % }%
1608 % }
1609 % \end{verbatim}
1610 % Let's see what it looks like.
1611 % \begin{verbatim}
1612 % \begin{empheq}[box=\Garybox]{align}
1613 % \sum \mathbf{F} &= \mathbf{0} \\
1614 % \sum F_{x} \,\mathbf{i} + \sum F_{y} \,\mathbf{j}
1615 % + \sum F_{z} \,\mathbf{k} &= \mathbf{0} \\
1616 % \sum F_{x} &= 0 \\ \sum F_{y} &= 0 \\ \sum F_{z} &= 0
1617 % \end{empheq}
1618 % \end{verbatim}
1619 % \begin{subequations}
1620 % \begin{empheq}[box=\Garybox]{align}
1621 % \sum \mathbf{F} &= \mathbf{0} \\
1622 % \sum F_{x} \,\mathbf{i} + \sum F_{y} \,\mathbf{j} + \sum F_{z}
1623 % \,\mathbf{k} &= \mathbf{0}\\
1624 % \sum F_{x} &= 0 \\ \sum F_{y} &= 0 \\ \sum F_{z} &= 0
1625 % \end{empheq}
1626 % If we use the optional argument of \cs{Garybox} we have to enclose
1627 % the entire argument of \key{box} in braces because we're in
1628 % \env{empheq}'s optional argument (as described in \cite[page
1629 % 167]{Lamp94}):
1630 % \begin{verbatim}
1631 % \begin{empheq}[box={\Garybox[Same old example again]}]{align}
1632 % a&=b\\
1633 % E&=mc^2 + \int_a^a x\, dx
1634 % \end{empheq}
1635 % \end{verbatim}
1636 % \begin{empheq}[box={\Garybox[Same old example again]}]{align}
1637 % a&=b\\
1638 % E&=mc^2 + \int_a^a x\, dx
1639 % \end{empheq}
1640 % \end{subequations}
1641 %
1642 %
1643 %
1644 %
1645 % \section{Contact information}
1646 %
1647 % Should you have any feature request, suggestions, or bug reports
1648 % then feel free to open an issue at (it also covers \pkg{empheq})
1649 % \begin{quote}
1650 % \url{https://github.com/latex3/mathtools}
1651 % \end{quote}
1652 %
1653 % \subsection*{Contributors}
1654 %
1655 % \begin{itemize}
1656 % \item In November 2002 Lars Madsen (\email{[email protected]})
1657 % asked for some features that wasn't readily available with
1658 % \pkg{amsmath} or any other package. This was the start of
1659 % \pkg{empheq}.
1660 %
1661 % \item Gary Gray (\email{[email protected]}) gave me some bug
1662 % reports on the old version (v0.7) which convinced me to rewrite
1663 % the package completely. The \cs{Garybox} example is inspired by
1664 % a wish from Gary.
1665 %
1666 % \item Uwe Siart (\email{[email protected]}) has been a thorough
1667 % beta-tester on v1.00 of the package.
1668 %
1669 % \item Bernard Alfonsi (\email{[email protected]}) reported
1670 % a problem with the \opt{ntheorem} option. It turned out to be a
1671 % bug in the \pkg{ntheorem} package itself but it's fixed in the
1672 % option.
1673 %
1674 % \item I have received reports on weird behavior from
1675 % \pkg{empheq} when used with the \pkg{color} package on some
1676 % dvi-viewers, which is caused by the lack of color support in
1677 % those dvi-viewers. Both Andrew B.~Collier (\email{[email protected]})
1678 % and Andr\'e M.~de Roos (\email{[email protected]}) have
1679 % notified me of this. The solution is to either upgrade you
1680 % dvi-viewer if possible or convert the document in question to
1681 % PDF or PS.
1682 % \end{itemize}
1683 % Thank you all.
1684 %
1685 %
1686 % \begin{thebibliography}{99}
1687 % \bibitem{Lamp94}
1688 % Leslie Lamport,
1689 % \emph{LaTeX User's Guide and Reference Manual}, 2nd edition,
1690 % Addison-Wesley, Reading, Massachusetts,
1691 % 1994.
1692 % \bibitem{Goos-etal94}
1693 % Michel Goossens, Frank Mittelbach, and Alexander Samarin,
1694 % \emph{The \LaTeX\ Companion},
1695 % Addison-Wesley, Reading, Massachusetts,
1696 % 1994.
1697 % \bibitem{Knut86}
1698 % Donald Ervin Knuth,
1699 % \emph{The \TeX book},
1700 % Addison-Wesley, Reading, Mas\-sa\-chu\-setts,
1701 % 1986.
1702 % \bibitem{Ams99}
1703 % American Mathematical Society and Michael Downes,
1704 % \emph{Technical notes on the \pkg{amsmath} package} Version 2.0,
1705 % 1999/10/29.
1706 % (Available from CTAN as file \texttt{technote.tex}.)
1707 % \bibitem{Ams00}
1708 % Frank Mittelbach, Rainer Sch\"opf, Michael Downes, and David M.~Jones,
1709 % \emph{The \pkg{amsmath} package} Version 2.13,
1710 % 2000/07/18.
1711 % (Available from CTAN as file \texttt{amsmath.dtx}.)
1712 %
1713 % \changes{v1.05b}{2004/02/18}{Added \pkg{fancybox} and
1714 % \pkg{ntheorem} to the \refname}
1715 % \bibitem{fancybox}
1716 % Timothy Van Zandt,
1717 % \emph{The \pkg{fancybox} package} Version 1.3,
1718 % 2000/09/19.
1719 % (Available from CTAN as file \texttt{fancybox.sty}.)
1720 %
1721 % \bibitem{Raht03}
1722 % Sebastian Rahtz,
1723 % \emph{Hypertext marks in \LaTeX} Version v6.74m,
1724 % 2003/11/30.
1725 % (Available from \url{http://www.tug.org/applications/hyperref} as file
1726 % \texttt{hyperref.dtx}.)
1727 %
1728 % \bibitem{Carl99}
1729 % David Carlisle,
1730 % \emph{The \pkg{keyval} Package},
1731 % Version 1.13, 1999/03/16.
1732 % (Available from CTAN as file \texttt{keyval.dtx}.)
1733 %
1734 % \changes{v1.06}{2004/03/13}{Added \pkg{calc} to the \refname}
1735 % \bibitem{Thorup:calc:1998}
1736 % Kresten~Krab Thorup, Frank Jensen, and Chris Rowley.
1737 % \emph{The {\pkg{calc}} package}, Version 4.1b, 1998/07/07.
1738 % (Available from CTAN as file \texttt{calc.dtx}.)
1739 %
1740 % \bibitem{ntheorem}
1741 % Wolfgang May and Andreas Schlechte,
1742 % \emph{The \pkg{ntheorem} package} Version 1.203,
1743 % 2002/01/07.
1744 % (Available from CTAN as file \texttt{ntheorem.dtx}.)
1745 %
1746 % \changes{v2.10}{2004/07/26}{Added \pkg{showkeys} to the \refname}
1747 % \bibitem{Carlisle:showkeys:1997}
1748 % David Carlisle. \emph{The {\pkg{showkeys}} package}, v3.12,
1749 % 1997/06/12. (Available from CTAN as file \texttt{showkeys.dtx}.)
1750 %
1751 % \end{thebibliography}
1752 %
1753 % \StopEventually{}
1754 %
1755 % \EmphEqpart{Implementation}
1756 %
1757 % \section{Requirements, Options, and Strategy}
1758 % Lets start the package. We'll need the tools from \pkg{mhsetup}.
1759 % \begin{macrocode}
1760 %<*package>
1761 \ProvidesPackage{empheq}%
1762 [2024/08/09 v2.17 Emphasizing equations]
1763 % \end{macrocode}
1764 % \changes{v2.15}{2017/03/31}{Bumped required mhsetup release}
1765 % \begin{macrocode}
1766 \RequirePackage{mhsetup}[2017/03/31]
1767 \MHInternalSyntaxOn
1768 % \end{macrocode}
1769 %
1770 %
1771 % \subsection{Requirements, Options, and Allocation}
1772 %
1773 % The \opt{overload} option allows the user to type
1774 % \begin{verbatim}
1775 % \begin{gather}[box=\fbox]
1776 % a = b
1777 % \end{gather}
1778 % \end{verbatim}
1779 % when they really mean
1780 % \begin{verbatim}
1781 % \begin{empheq}[box=\fbox]{gather}
1782 % a = b
1783 % \end{empheq}
1784 % \end{verbatim}
1785 % \begin{macrocode}
1786 \MH_new_boolean:n {overload_ams}
1787 \DeclareOption{overload}{
1788 \MH_set_boolean_T:n {overload_ams}
1789 }
1790 \MH_new_boolean:n {overload_amsII}
1791 \DeclareOption{overload2}{
1792 \MH_set_boolean_T:n {overload_ams}
1793 \MH_set_boolean_T:n {overload_amsII}
1794 }
1795 % \end{macrocode}
1796 % Old crappy \env{multline} interface or the new dazzling?
1797 % \begin{macrocode}
1798 \MH_new_boolean:n {good_mult}
1799 \DeclareOption{oldmultline}{\MH_set_boolean_F:n {good_mult}}
1800 \DeclareOption{newmultline}{\MH_set_boolean_T:n {good_mult}}
1801 % \end{macrocode}
1802 %
1803 %
1804 % Load the \pkg{ntheorem} support file.
1805 % \begin{macrocode}
1806 \gdef\g@EQ@ntheorem@support@bool{01}
1807 \DeclareOption{ntheorem}{\gdef\g@EQ@ntheorem@support@bool{00}}
1808 % \end{macrocode}
1809 % Pass other options to \pkg{mathtools}.
1810 % \begin{macrocode}
1811 \DeclareOption*{
1812 \PassOptionsToPackage{\CurrentOption}{mathtools}
1813 }
1814 \ExecuteOptions{newmultline}
1815 \ProcessOptions\relax
1816 % \end{macrocode}
1817 % The name of the game is \pkg{amsmath} so we'll need that of
1818 % course. Since v2.10 that is now taken care of in the
1819 % \pkg{mathtools} package which'll pass on the options to
1820 % \pkg{amsmath}.
1821 % \changes{v2.15}{2017/03/31}{Bumped required mathtools release}
1822 % \begin{macrocode}
1823 \MHInternalSyntaxOff
1824 \RequirePackage{mathtools}[2017/03/31]
1825 % \end{macrocode}
1826 % Activate the internal syntax.
1827 % \begin{macrocode}
1828 \MHInternalSyntaxOn
1829 \AtEndOfPackage{\MHInternalSyntaxOff}
1830 % \end{macrocode}
1831 % \changes{v2.00}{2004/04/14}{Changed description of naming
1832 % conventions. Altered \emph{all} private macros; this is not
1833 % mentioned at each macro as this would just be too troublesome}
1834 %
1835 % \begin{macro}{\l_EQ_equationtype_int}
1836 % \begin{macro}{\l_EQ_alignmentmode_int}
1837 % I'll use the following numbering scheme for the equation types,
1838 % and store the value in \cs{l_EQ_equationtype_int}:
1839 % \begin{multicols}{2}
1840 % \begin{enumerate}\setlength{\itemsep}{0pt}
1841 % \item align
1842 % \item align*
1843 % \item gather
1844 % \item gather*
1845 % \item flalign
1846 % \item flalign*
1847 % \item alignat
1848 % \item alignat*
1849 % \end{enumerate}
1850 % \end{multicols}
1851 % As you notice \env{equation} and \env{equation*} are missing. This
1852 % is because \env{gather} and \env{gather*} work the same way, only
1853 % they are `nicer'. Cuts down on the amount of code as well. I will
1854 % add an alias so that a user can use the key \key{equation}, but
1855 % then \key{gather} will kick in instead behind the scenes. Also the
1856 % \env{multline} environments are missing here, but again it's
1857 % because I'm faking it. See \S~\vref{sec:flalign+multline} for
1858 % further details. The value $0$ isn't used for any of the
1859 % environments and thus serves as a checkpoint (see
1860 % page~\pageref{ZeroCheckpoint}).
1861 %
1862 % Similarly I'll use the counter \cs{l_EQ_alignmentmode_int} to
1863 % store the standard options for placement of math displays and
1864 % equation numbering.
1865 % \begin{multicols}{2}
1866 % \begin{enumerate}\setlength{\itemsep}{0pt}
1867 % \item reqno
1868 % \item leqno
1869 % \item fleqn, reqno
1870 % \item fleqn, leqno
1871 % \end{enumerate}
1872 % \end{multicols}
1873 %
1874 % \changes{v2.15}{2017/03/31}{added MH\_ prefix}
1875 % \begin{macrocode}
1876 \newcount\l_EQ_equationtype_int
1877 \newcount\l_EQ_alignmentmode_int
1878 \if@fleqn
1879 \iftagsleft@
1880 \l_EQ_alignmentmode_int=4
1881 \MH_else:
1882 \l_EQ_alignmentmode_int=\thr@@
1883 \MH_fi:
1884 \MH_else:
1885 \iftagsleft@
1886 \l_EQ_alignmentmode_int=\tw@
1887 \MH_else:
1888 \l_EQ_alignmentmode_int=\@ne
1889 \MH_fi:
1890 \MH_fi:
1891 % \end{macrocode}
1892 % \end{macro}
1893 % \end{macro}
1894 % \begin{macro}{\l_EQ_totalwidth_dim}
1895 % \begin{macro}{\l_EQ_displaywidth_dim}
1896 % \begin{macro}{\l_EQ_temp_linewidth_dim}
1897 % \begin{macro}{\l_EQ_linewidth_dim}
1898 % \begin{macro}{\EmphEqdelimitershortfall}
1899 % \begin{macro}{\EmphEqdelimiterfactor}
1900 % \begin{macro}{\g_EQ_toptag_height_dim}
1901 % \begin{macro}{\g_EQ_bottomtag_depth_dim}
1902 % \begin{macro}{\g_EQ_toprow_height_dim}
1903 % \begin{macro}{\g_EQ_bottomrow_depth_dim}
1904 % \begin{macro}{\g_EQ_widesttag_dim}
1905 % Some lengths we'll need. Could possibly be scratch registers but we
1906 % have to make global assignments so that road is a little
1907 % dangerous.
1908 % \begin{macrocode}
1909 \newdimen\l_EQ_totalwidth_dim
1910 \newdimen\l_EQ_displaywidth_dim
1911 % \end{macrocode}
1912 % Just to make it accessible.
1913 % \changes{v2.16}{2020/03/23}{Added \cs{l_EQ_linewidth_dim} since due
1914 % to the \AmS\ classes being able to not rely on \cs{linewidth} can be
1915 % useful.}
1916 % \begin{macrocode}
1917 \def\EmphEqdisplaywidth{\l_EQ_displaywidth_dim}
1918 \newdimen\l_EQ_temp_linewidth_dim
1919 \newdimen\l_EQ_linewidth_dim
1920 \newdimen\EmphEqdelimitershortfall
1921 \newcount\EmphEqdelimiterfactor
1922 \EmphEqdelimiterfactor950
1923 \EmphEqdelimitershortfall\p@
1924 \newdimen\g_EQ_toptag_height_dim
1925 \newdimen\g_EQ_bottomtag_depth_dim
1926 \newdimen\g_EQ_toprow_height_dim
1927 \newdimen\g_EQ_bottomrow_depth_dim
1928 \newdimen\g_EQ_widesttag_dim
1929 \def\EmphEqtagwidth{\g_EQ_widesttag_dim}
1930 % \end{macrocode}
1931 % \end{macro}
1932 % \end{macro}
1933 % \end{macro}
1934 % \end{macro}
1935 % \end{macro}
1936 % \end{macro}
1937 % \end{macro}
1938 % \end{macro}
1939 % \end{macro}
1940 % \end{macro}
1941 % \end{macro}
1942 %
1943 % \begin{macro}{\EQ_outerbox:}
1944 % \begin{macro}{\EQ_innerbox:}
1945 % \begin{macro}{\EQ_left_side:}
1946 % \begin{macro}{\EQ_right_side:}
1947 % The two boxes and the material on either side of the math display.
1948 % \begin{macrocode}
1949 \def\EQ_outerbox:{}
1950 \def\EQ_innerbox:{}
1951 \def\EQ_left_side:{}
1952 \def\EQ_right_side:{}
1953 % \end{macrocode}
1954 % \end{macro}
1955 % \end{macro}
1956 % \end{macro}
1957 % \end{macro}
1958 %
1959 % \subsection{Strategy}
1960 %
1961 % In non-\mode{fleqn} math displays are centered---even when having
1962 % tags. However this can look rather appalling when either the tag
1963 % or the math display are very wide like in the following example.
1964 % \begin{center}
1965 % \makebox[\linewidth][s]{\mbox{}\hfill \mbox{$\displaystyle
1966 % a+b+c+d+e+f+g+h+i+j+k+l+m+n+o$} \hfill\mbox{} \llap{(wide tag)}}
1967 % \end{center}
1968 % Not exactly pleasing to look at. \pkg{amsmath} takes care to do
1969 % this adjustment for us, so the user instead obtains the far better
1970 % \begin{gather*}
1971 % a+b+c+d+e+f+g+h+i+j+k+l+m+n+o \tag{wide tag}
1972 % \end{gather*}
1973 % So \pkg{amsmath} handles this quite well. That's good. It looks
1974 % like \pkg{amsmath} has an internal threshold that matches the
1975 % width of the math display against the width of the tags. But what
1976 % if we have a multiple line display and one of the lines causes an
1977 % adjustment to kick in while the others don't need it? Then we
1978 % cannot keep track of the complete display anymore. Furthermore we
1979 % may want to add material on either side of the math display making
1980 % the whole thing even more complicated, if not impossible to do
1981 % without some sort of different approach.
1982 %
1983 % Luckily we have such an approach. The idea that comes to mind is
1984 % to see if one can typeset the labels and the math displays
1985 % \emph{separately}, store them in separate boxes and then put them
1986 % back together again afterwards. Is this really possible? Yes.
1987 % Come, I'll show you.
1988 %
1989 % \subsection{The Main Environment}
1990 % \begin{macro}{\EQ_mathdisplay_box}
1991 % \begin{macro}{\EmphEqdisplayheight}
1992 % \begin{macro}{\EmphEqdisplaydepth}
1993 % \begin{macro}{\EQ_tag_box}
1994 % Okay, we'll start by allocating two box registers.
1995 % \begin{macrocode}
1996 \newsavebox\EQ_mathdisplay_box
1997 \def\EmphEqdisplayheight{\ht\EQ_mathdisplay_box}
1998 \def\EmphEqdisplaydepth{\dp\EQ_mathdisplay_box}
1999 \newsavebox\EQ_tag_box
2000 % \end{macrocode}
2001 % \end{macro}
2002 % \end{macro}
2003 % \end{macro}
2004 % \end{macro}
2005 %
2006 % \begin{macro}{\EQ_complete_mathdisplay:}
2007 % \begin{macro}{\EQ_getbody:n}
2008 % \begin{environment}{EmphEqMainEnv}
2009 % The \env{EmphEqMainEnv} is (as the name implies) the main
2010 % environment. I decided to go with the environment form because
2011 % that's what \pkg{amsmath} users are accustomed to. But the code
2012 % will require the contents of the environment to be handled as an
2013 % argument to a command, so we use \cs{collect@body} from
2014 % \pkg{amsmath} itself to collect it.
2015 % \begin{macrocode}
2016 \def\EQ_complete_mathdisplay:{}
2017 \def\EQ_getbody:n #1{%
2018 \def\EQ_complete_mathdisplay:{}\def\EQ_mathbody:{#1}}
2019 \newenvironment{EmphEqMainEnv}{\collect@body\EQ_getbody:n}{%
2020 % \end{macrocode}
2021 % If the user didn't specify the mandatory argument we will catch it
2022 % because \cs{l_EQ_equationtype_int} is zero. An error is
2023 % issued\label{ZeroCheckpoint}.
2024 % \changes{v2.15}{2017/03/31}{added MH\_ prefix, twice}
2025 % \begin{macrocode}
2026 \MH_if_num:w \l_EQ_equationtype_int=\z@ %ZeroCheckpoint
2027 \EQ_upgrade_error:
2028 \MH_else:
2029 % \end{macrocode}
2030 % Those that read the manual get the reward here: The package will
2031 % actually work!
2032 % \changes{v2.15}{2017/03/31}{added MH\_ prefix}
2033 % \begin{macrocode}
2034 \EQ_post_process:
2035 \ignorespacesafterend
2036 \MH_fi:}
2037 % \end{macrocode}
2038 % \end{environment}
2039 % \end{macro}
2040 % \end{macro}
2041 % \subsection{Post Processing}
2042 % \begin{macro}{\EQ_post_process:}
2043 % I know: it almost looked easy for a while didn't it? Sadly the
2044 % post-processing step of the code is also by far the most
2045 % complicated.
2046 % \begin{macrocode}
2047 \def\EQ_post_process:{%
2048 % \end{macrocode}
2049 % First a hook where we initialize a few things like storing the
2050 % line width for later manipulation. Also we want to measure the
2051 % height of the top row and the depth of the bottom row for best
2052 % possible placement of the math display and the boxes around it
2053 % (same with the tags). Those four dimensions are globally set
2054 % during the code, hence this assignment. Most other stuff is local.
2055 % \begin{macrocode}
2056 \EQ_initialize:
2057 % \end{macrocode}
2058 % Then we proceed by completing the input. We store it in the
2059 % control sequence \cs{EQ_complete_mathdisplay}.
2060 % \cs{EQ_begin_equation:} adds the start of the environment and
2061 % \cs{EQ_end_equation:} adds the corresponding end.
2062 % \begin{macrocode}
2063 \EQ_begin_equation:
2064 % \end{macrocode}
2065 % In case we face a \env{multline} we add what's necessary.
2066 % \begin{macrocode}
2067 \MH_if_boolean:nT {outer_mult}{
2068 \setkeys{\MT_options_name:}{
2069 firstline-afterskip=0pt,
2070 lastline-preskip=0pt,
2071 multlined-width=0pt,
2072 }
2073 \ifodd \l_EQ_alignmentmode_int
2074 \setkeys{\MT_options_name:}{multlined-pos=b}
2075 \MH_else:
2076 \setkeys{\MT_options_name:}{multlined-pos=t}
2077 \MH_fi:
2078 \g@addto@macro\EQ_complete_mathdisplay:{
2079 \begin{MTmultlined}\relax}
2080 }
2081 \g@addto@macro\EQ_complete_mathdisplay:\EQ_mathbody:
2082 \MH_if_boolean:nT {outer_mult}{
2083 \g@addto@macro\EQ_complete_mathdisplay:{\end{MTmultlined}}
2084 }
2085 \EQ_end_equation:
2086 % \end{macrocode}
2087 % Save the value of the \pkg{hyperref} link counter
2088 % \cs{Hy@linkcounter}.
2089 % \begin{macrocode}
2090 \edef\EQ_hyperref_link_fint{\number\Hy@linkcounter}
2091 % \end{macrocode}
2092 % Firstly we call \cs{EQ_typeset_tags:} which suppresses all
2093 % output from the equations with the exception of the \cs{tag}'s.
2094 % This also allows us to find the widest tag which we'll need for
2095 % the environments that set's the math displays flush to the
2096 % margins, namely the \env{flalign} family. We save the counters
2097 % first though. As an extra treat we're also able to measure the
2098 % height and depth of the tags and the math display.
2099 % \begin{macrocode}
2100 \savecounters@
2101 \EQ_typeset_tags:
2102 % \end{macrocode}
2103 % \changes{v1.05d}{2004/02/26}{Removed one instance of
2104 % \cs{EQ_typeset_display:}}
2105 % Then find the widest tag. In an earlier implementation it was
2106 % necessary to typeset the display twice---a very costly procedure!
2107 % Now we save roughly 2120 lines of output from \cs{tracingall} on a
2108 % simple \env{gather} and 2600 lines with \env{align}. That's a
2109 % little more than 21\% saved\ldots
2110 % \changes{v2.10}{2004/07/26}{Removed \cs{find_widesttag:}}
2111 % \changes{v2.10}{2004/07/26}{Added check for equation number to
2112 % make sure the labelling/printing mechanism of \pkg{mathtools} work
2113 % properly}
2114 % Then we restore the counters and measure the extra material.
2115 % Save the value of the equation counter for later in case the
2116 % special equation numbering scheme from \pkg{mathtools} is in
2117 % effect.
2118 % \begin{macrocode}
2119 \edef\l_EQ_equation_fint{\number\c@equation}
2120 \restorecounters@
2121 % \end{macrocode}
2122 % Restore the value of the \pkg{hyperref} link counter
2123 % \cs{Hy@linkcounter}.
2124 % \begin{macrocode}
2125 \Hy@linkcounter=\EQ_hyperref_link_fint
2126 \settowidth\l_EQ_totalwidth_dim{%
2127 $\EQ_left_side:\EQ_innerbox:{}\EQ_right_side:$}%
2128 % \end{macrocode}
2129 % Then call the appropriate \cs{EQ_modify_linewidth_}\meta{num}\texttt{:}
2130 % where \meta{num} is taken from the numbering scheme shown earlier.
2131 % \begin{macrocode}
2132 \MH_if_boolean:nTF {outer_mult}
2133 { \def\EQ_next:{_mult} }
2134 { \def\EQ_next:{} }
2135 \@nameuse{EQ_modify_linewidth_
2136 \romannumeral\l_EQ_equationtype_int\EQ_next: :}%
2137 % \end{macrocode}
2138 % We can then typeset the display knowing that all modifications
2139 % have been made correctly. \cs{EQ_typeset_display:} gobbles the
2140 % \cs{tag}'s, which in turn is equivalent to setting the display
2141 % centered in non-\mode{fleqn} mode.
2142 % \begin{macrocode}
2143 \EQ_typeset_display:
2144 % \end{macrocode}
2145 % Call the appropriate \cs{find_displaywidth_}\meta{num}\texttt{:}
2146 % which extracts the display width (\cs{l_EQ_displaywidth_dim}).
2147 % \changes{v2.15}{2017/03/31}{added EQ\_ prefix}
2148 % \begin{macrocode}
2149 \@nameuse{EQ_find_displaywidth_
2150 \romannumeral\l_EQ_equationtype_int\EQ_next: :}
2151 \MH_addtolength:dn
2152 \l_EQ_totalwidth_dim{\l_EQ_displaywidth_dim}
2153 % \end{macrocode}
2154 % We save the math display in a box of the correct size.
2155 % \changes{v2.15}{2017/03/31}{added MH\_ prefix}
2156 % \begin{macrocode}
2157 \savebox\EQ_mathdisplay_box[\l_EQ_totalwidth_dim][c]{%
2158 $\EQ_left_side:
2159 \EQ_innerbox:{%
2160 \MH_if_case:w \l_EQ_alignmentmode_int\MH_or:
2161 % \end{macrocode}
2162 % If the equation is centered we make the box centered
2163 % \begin{macrocode}
2164 \makebox[\l_EQ_displaywidth_dim][c]
2165 {\usebox{\EQ_mathdisplay_box}}%
2166 \MH_or:
2167 \makebox[\l_EQ_displaywidth_dim][c]
2168 {\usebox{\EQ_mathdisplay_box}}%
2169 \MH_or:
2170 % \end{macrocode}
2171 % Else we set it in a left aligned box and take care of the
2172 % \cs{@mathmargin} unless we're in \env{flalign} or \env{flalign*}.
2173 % \begin{macrocode}
2174 \makebox[\l_EQ_displaywidth_dim][l]{%
2175 \MH_if_num:w \l_EQ_equationtype_int=5 \MH_else:
2176 \MH_if_num:w \l_EQ_equationtype_int=6 \MH_else:
2177 \kern-\@mathmargin
2178 \MH_fi:
2179 \MH_fi:
2180 \usebox{\EQ_mathdisplay_box}}%
2181 \MH_or:
2182 \makebox[\l_EQ_displaywidth_dim][l]{%
2183 \MH_if_num:w \l_EQ_equationtype_int=5 \MH_else:
2184 \MH_if_num:w \l_EQ_equationtype_int=6 \MH_else:
2185 \kern-\@mathmargin
2186 \MH_fi:
2187 \MH_fi:
2188 \usebox{\EQ_mathdisplay_box}}%
2189 \MH_fi:}%
2190 \EQ_right_side:$}%
2191 % \end{macrocode}
2192 % Then we're ready for typesetting. We just use an ordinary
2193 % |\begin{equation*}| | ... | |\end{equation*}| construction.
2194 % \changes{v2.00}{2004/04/14}{Used a saved definition of
2195 % \env{equation*} instead to allow overloading}
2196 % With v2.00 this changed to using a copy of the original
2197 % \env{equation*} environment. All this because of the
2198 % \opt{overload} option.
2199 % \begin{macrocode}
2200 \begin{AmSequation*}
2201 \@nameuse{EQ_place_display_
2202 \romannumeral\l_EQ_equationtype_int\EQ_next: :}
2203 % \end{macrocode}
2204 % \cs{tag} must have a non-zero width argument in order to function
2205 % properly, so we make sure there is a tag before we try to typeset
2206 % it. Also make sure that the boolean |show_manual_tags| is true
2207 % just for this tag.
2208 % \changes{v2.15}{2017/03/31}{added MH\_ prefixes}
2209 % \begin{macrocode}
2210 \MH_if_dim:w \g_EQ_widesttag_dim>\z@
2211 \MH_set_boolean_T:n {show_manual_tags}
2212 % \end{macrocode}
2213 % Set the tag in a left aligned box when in \mode{leqno} mode and
2214 % right aligned when in \mode{reqno} mode.
2215 % \changes{v2.15}{2017/03/31}{added MH\_ prefixes}
2216 % \begin{macrocode}
2217 \MH_if_case:w \l_EQ_alignmentmode_int
2218 \MH_or: \EQ_place_tag:N r %#1
2219 \MH_or: \EQ_place_tag:N l %#2
2220 \MH_or: \EQ_place_tag:N r %#3
2221 \MH_or: \EQ_place_tag:N l %#4
2222 \MH_fi:
2223 \MH_fi:
2224 \end{AmSequation*}
2225 % \end{macrocode}
2226 % \changes{v2.11}{2004/08/03}{Use raw \TeX{} commands to speed it up}
2227 % Restore the equation counter.
2228 % \begin{macrocode}
2229 \global\c@equation=\l_EQ_equation_fint\relax
2230 }
2231 % \end{macrocode}
2232 % \end{macro}
2233 %
2234 % \subsubsection{Initializing the Equations}
2235 %
2236 % \begin{macro}{\EQ_initialize:}
2237 % We save all the initializations in this hook:
2238 % \begin{macrocode}
2239 \def\EQ_initialize:{%
2240 \m@th
2241 % \end{macrocode}
2242 % More support for \pkg{ntheorem}. We use special versions of
2243 % the tag setting commands in order to produce the correct result.
2244 % For instance in \mode{leqno} mode you would still want the end of
2245 % theorem symbol at the bottom of the math display.
2246 % \begin{macrocode}
2247 \MH_let:NwN\SetTagPlusEndMark\EQ_tag_plus_endmark:
2248 \MH_let:NwN\SetOnlyEndMark\EQ_only_endmark:
2249 % \end{macrocode}
2250 % \changes{v2.16}{2020/03/19}{Added fix for amsart and amsbook}
2251 % \changes{v2.16}{2020/03/23}{Added additional length as it is useful
2252 % against amsart and friends}
2253 % \begin{macrocode}
2254 \l_EQ_temp_linewidth_dim\linewidth
2255 \l_EQ_linewidth_dim\linewidth
2256 % \end{macrocode}
2257 % In classes like \cls{amsart} and \cls{amsbook} thye set
2258 % \cs{displaywidth} to a fixed value. This gives problems inside
2259 % lists, where these classes want to use the full width, not the
2260 % effective width. They do this via \cs{everydisplay}
2261 % which is actually too late for when \cs{EQ_initialize:} runs!
2262 % We know that \cls{amsart/book} defines
2263 % \begin{verbatim}
2264 % \def\fullwidthdisplay{\displayindent\z@ \displaywidth\columnwidth}
2265 % \end{verbatim}
2266 % and then adds this to \cs{everydisplay}. So our fix will be to see
2267 % if \cs{fullwidthdisplay} is defined, run it locally and then extract
2268 % the value of \cs{displaywidth} using a global scratch variable. If
2269 % that size is then larger than the current \cs{linewidth} we will use
2270 % it. Additionally we also save this value in a static length, so we
2271 % can use this everywhere instead of \cs{linewidth}.
2272 % \begin{macrocode}
2273 \@tempdima\z@
2274 \begingroup
2275 \ifdefined\fullwidthdisplay\relax
2276 \fullwidthdisplay
2277 \global\@tempdima\displaywidth
2278 \fi
2279 \endgroup
2280 \ifdim\@tempdima>\linewidth\relax
2281 \l_EQ_temp_linewidth_dim\@tempdima
2282 \l_EQ_linewidth_dim\@tempdima
2283 \fi
2284 \@tempdima\z@
2285 % \end{macrocode}
2286 % -- end of \cls{amsart/-book} fix.
2287 % \begin{macrocode}
2288 \g_EQ_toprow_height_dim\z@
2289 \g_EQ_bottomrow_depth_dim\z@
2290 \g_EQ_toptag_height_dim\z@
2291 \g_EQ_bottomtag_depth_dim\z@
2292 \g_EQ_widesttag_dim\z@
2293 % \end{macrocode}
2294 % \changes{v2.11}{2004/08/03}{Added a \cs{g_EQ_latest_nonzerodepth_row_fint}}
2295 % \begin{macrocode}
2296 \xdef\g_EQ_latest_nonzerodepth_row_fint{\z@}
2297 \edef\EQ_restore_tex_delimiter:{%
2298 \delimiterfactor\the\delimiterfactor
2299 \delimitershortfall\the\delimitershortfall\relax}%
2300 \g@addto@macro\EQ_complete_mathdisplay:
2301 \EQ_restore_tex_delimiter:
2302 \delimitershortfall\EmphEqdelimitershortfall
2303 \delimiterfactor\EmphEqdelimiterfactor
2304 % \end{macrocode}
2305 % Disable \cs{intertext} and issue an error message. Using the
2306 % normal error message for an invalid \cs{intertext} would be less
2307 % than great because it would say
2308 % \begin{verbatim}
2309 % ! Package amsmath Error: Invalid use of \intertext.
2310 %
2311 % See the amsmath package documentation for explanation.
2312 % Type H <return> for immediate help.
2313 % ...
2314 % \end{verbatim}
2315 % That's not good enough, so we redefine things a bit. In
2316 % \pkg{amsmath} the command \cs{intertext@} is called inside the
2317 % math environments and defines \cs{intertext}. We hook into this.
2318 % \begin{macrocode}
2319 \MH_let:NwN\intertext@\EQ_intertext:
2320 \EQ_displaybreak:}
2321 % \end{macrocode}
2322 % \end{macro}
2323 % \begin{macro}{\EQ_intertext:}
2324 % Then we issue a suitable error message.
2325 % \changes{v2.15}{2017/03/31}{Extended to also include \cs{shortintertext}}
2326 % \begin{macrocode}
2327 \def\EQ_intertext:{%
2328 \def\intertext##1{\PackageError{empheq}{%
2329 You~cannot~use~\string\intertext\space inside~the~`empheq'
2330 \MessageBreak
2331 environment,~as~`empheq'~creates~an~unbreakable~box}\@eha}
2332 \def\shortintertext##1{\PackageError{empheq}{%
2333 You~cannot~use~\string\shortintertext\space inside~the~`empheq'
2334 \MessageBreak
2335 environment,~as~`empheq'~creates~an~unbreakable~box}\@eha}
2336 }
2337 \def\EQ_displaybreak:{%
2338 \def\dspbrk@[##1]{\PackageWarning{empheq}{%
2339 You~cannot~use~\string\displaybreak\space inside~the~`empheq'%
2340 \MessageBreak
2341 environment,~as~`empheq'~creates~an~unbreakable~box.}}}
2342 % \end{macrocode}
2343 % \end{macro}
2344 % \begin{macro}{\EQ_new_equationtype:nnn}
2345 % \begin{macro}{\EQ_new_equationtype_arg:nnn}
2346 % We have to inform \env{EmphEqMainEnv} which equation type we're
2347 % using, so we define an interface for that.
2348 % \begin{macrocode}
2349 \def\EQ_new_equationtype:nnn #1#2#3{%
2350 \define@key{#1}{#2}[true]{%
2351 \l_EQ_equationtype_int=#3\relax
2352 \def\EQ_begin_equation:
2353 {\g@addto@macro{\EQ_complete_mathdisplay:}{\begin{#2}}}%
2354 \def\EQ_end_equation:
2355 {\g@addto@macro{\EQ_complete_mathdisplay:}{\end{#2}}}}}
2356 \def\EQ_new_equationtype_arg:nnn #1#2#3{%
2357 \define@key{#1}{#2}{%
2358 \l_EQ_equationtype_int=#3\relax
2359 \def\EQ_begin_equation:
2360 {\g@addto@macro{\EQ_complete_mathdisplay:}{\begin{#2}{##1}}}%
2361 \def\EQ_end_equation:
2362 {\g@addto@macro{\EQ_complete_mathdisplay:}{\end{#2}}}}}
2363 % \end{macrocode}
2364 % \end{macro}
2365 % \end{macro}
2366 %
2367 % \subsubsection{Separating Tags and Display}
2368 %
2369 % \begin{macro}{\EQ_typeset_tags:}
2370 % Typesetting the tags without the display. The main idea here is to
2371 % typeset everything inside a box of a massive width, so wide that
2372 % the math part is way outside the area of the text block.
2373 % \begin{macrocode}
2374 \def\EQ_typeset_tags:{%
2375 \sbox\EQ_tag_box{%
2376 \parbox{.5\maxdimen}{%
2377 \hbadness\@M
2378 % \end{macrocode}
2379 % Make sure all skips are zero ands support \pkg{ntheorem}.
2380 % \changes{v1.05a}{2004/02/17}{Forgot to support \pkg{ntheorem} in
2381 % both \cs{EQ_typeset_tags:} and \cs{EQ_typeset_display:}.}
2382 % \begin{macrocode}
2383 \EQ_prevent_vertical_space:
2384 % \end{macrocode}
2385 % The AMS classes sets \cs{displaywidth} equal to \cs{columnwidth} in
2386 % \cs{everydisplay}. This is bad for us as then the reqno equation
2387 % numbers are not typeset at the right edge of the parbox we are
2388 % in. Simplest solution: Locally reset \cs{columnwidth}.
2389 % \changes{v2.15}{2017/03/28}{Resetting \cs{columnwidth} as a fix for
2390 % a setting in AMS classes}
2391 % \begin{macrocode}
2392 \columnwidth\linewidth
2393 % \end{macrocode}
2394 % Support for \pkg{ntheorem}. This package patches \cs{endgather}
2395 % and \cs{endalign} with the commands \cs{TagsPlusEndmarks} and
2396 % \cs{RestoreTags} but we do not want them disturbing our output so
2397 % we disable them when typesetting the display.
2398 % \begin{macrocode}
2399 \EQ_typeset_tags_hook:
2400 % \end{macrocode}
2401 % Then use our own versions of \cs{set@gather@field} and
2402 % \cs{set@field}.
2403 % \begin{macrocode}
2404 \MH_let:NwN\set@gather@field\EQ_set_gather_field:
2405 \MH_let:NwN\set@field\EQ_set_align_field:
2406 % \end{macrocode}
2407 % Next two lines are for measuring of the first and last row of a
2408 % display of the \env{align}, \env{alignat} or \env{flalign} family.
2409 % \begin{macrocode}
2410 \MH_set_boolean_T:n {continue_measuring}
2411 \global\g_EQ_temprow_int\m@ne
2412 \MH_let:NwN \EQ_saved_maketag:n \maketag@@@
2413 \def\maketag@@@##1{
2414 \EQ_maketag:Nn \EQ_saved_maketag:n {##1}}
2415 % \end{macrocode}
2416 % Then typeset the display.
2417 % \begin{macrocode}
2418 \EQ_complete_mathdisplay:}}}
2419 % \end{macrocode}
2420 % \end{macro}
2421 %
2422 % \begin{macro}{\EQ_predisplay_adjustment:}
2423 % \changes{v1.05c}{2004/02/25}{Added \cs{EQ_predisplay_adjustment:}}
2424 %
2425 % \changes{v2.00}{2004/04/14}{Added a missing \cs{normallineskip} in
2426 % case of extremely big tag height}
2427 %
2428 % For adjusting vertical spacing in the display.
2429 % \changes{v2.15}{2017/03/31}{added MH\_ prefix}
2430 % \begin{macrocode}
2431 \def\EQ_predisplay_adjustment:{%
2432 \MH_if_dim:w \g_EQ_toprow_height_dim<\baselineskip
2433 \vskip\g_EQ_toprow_height_dim
2434 \vskip-\baselineskip
2435 \MH_else:
2436 \vskip-\normallineskip
2437 \MH_fi:
2438 \MH_if_dim:w \g_EQ_toptag_height_dim>\g_EQ_toprow_height_dim
2439 \MH_if_dim:w \g_EQ_toptag_height_dim>\baselineskip
2440 \vskip-\g_EQ_toptag_height_dim
2441 \vskip\baselineskip
2442 \vskip-\normallineskip
2443 \MH_fi:
2444 \MH_fi:}
2445 % \end{macrocode}
2446 % \end{macro}
2447 % \begin{macro}{\EQ_postdisplay_adjustment:}
2448 % \changes{v1.05c}{2004/02/25}{Added \cs{EQ_postdisplay_adjustment:}}
2449 % Name says it all.
2450 % \changes{v2.15}{2017/03/31}{added MH\_ prefixes}
2451 % \begin{macrocode}
2452 \def\EQ_postdisplay_adjustment:{%
2453 \MH_if_dim:w \g_EQ_bottomrow_depth_dim<\dp\strutbox
2454 \vskip\g_EQ_bottomrow_depth_dim
2455 \vskip-\dp\strutbox
2456 \MH_fi:
2457 \MH_if_dim:w \g_EQ_bottomtag_depth_dim>\g_EQ_bottomrow_depth_dim
2458 \MH_if_dim:w \g_EQ_bottomtag_depth_dim>\dp\strutbox
2459 \vskip-\g_EQ_bottomtag_depth_dim
2460 \vskip\dp\strutbox
2461 \MH_fi:
2462 \MH_fi:}
2463 % \end{macrocode}
2464 % \end{macro}
2465 % \begin{macro}{\EQ_typeset_display:}
2466 % \changes{v1.05c}{2004/02/25}{Now takes two arguments: Either both
2467 % empty or \cs{EQ_predisplay_adjustment:} \&
2468 % \cs{EQ_postdisplay_adjustment:}}
2469 % \changes{v1.05d}{2004/02/26}{Changed again. Uses only
2470 % \cs{EQ_predisplay_adjustment:} \& \cs{EQ_postdisplay_adjustment:}}
2471 % We typeset the display without the tags and save it in a box.
2472 % \begin{macrocode}
2473 \def\EQ_typeset_display:{%
2474 \sbox\EQ_mathdisplay_box{%
2475 \parbox{\l_EQ_temp_linewidth_dim}{%
2476 % \end{macrocode}
2477 % We adjust the vertical spacing if needed:
2478 % \begin{macrocode}
2479 \EQ_predisplay_adjustment:
2480 \EQ_prevent_vertical_space:
2481 % \end{macrocode}
2482 % Support for \pkg{ntheorem}. This package patches \cs{endgather}
2483 % and \cs{endalign} with the commands \cs{TagsPlusEndmarks} and
2484 % \cs{RestoreTags} but we do not want them disturbing our output so
2485 % we disable them when typesetting the display.
2486 % \begin{macrocode}
2487 \EQ_typeset_display_hook:
2488 % \end{macrocode}
2489 % Instead of gobbling the tags it's better to use \cs{phantom} since
2490 % a tall tag will ruin the vertical spacing. We use a special
2491 % version of \cs{phantom} to help us with other things as well.
2492 % \begin{macrocode}
2493 \def\maketag@@@##1{\EQ_maketag:Nn \vphantom{##1}}%
2494 \EQ_complete_mathdisplay:
2495 % \end{macrocode}
2496 % More space adjustment.
2497 % \begin{macrocode}
2498 \EQ_postdisplay_adjustment:}}}
2499 % \end{macrocode}
2500 % \end{macro}
2501 % We need a few little helpers:
2502 % \begin{macro}{\EQ_prevent_vertical_space:}
2503 % \changes{v2.00}{2004/04/14}{Used \cs{nointerlineskip} instead}
2504 % As we typeset the math display inside a \cs{parbox} the math
2505 % environment will add \cs{abovedisplayskip} at the top and
2506 % \cs{belowdisplayskip} at the bottom. Also we suppress interline
2507 % skip with \cs{nointerlineskip}.
2508 % \begin{macrocode}
2509 \def\EQ_prevent_vertical_space:{%
2510 \nointerlineskip
2511 \abovedisplayskip\z@ \belowdisplayskip\z@\relax}
2512 % \end{macrocode}
2513 % \end{macro}
2514 % \begin{macro}{\EQ_maketag:Nn}
2515 % \changes{v1.05d}{2004/02/26}{Changed name from
2516 % \cs{EmphEqphantom} to \cs{EmphEqMaketag}}
2517 % This takes care of two things: We need to store the height of the
2518 % top tag and the depth of the bottom tag for later, but we also
2519 % need to use a \cs{vphantom} of the tag as it may be taller than
2520 % the line of math it is attached to (say, if you are using node
2521 % connectors from \pkg{pstricks} or some other weird stuff).
2522 % \changes{v2.15}{2017/03/31}{added MH\_ prefixes}
2523 % \begin{macrocode}
2524 \def\EQ_maketag:Nn #1#2{%
2525 \setboxz@h{#2}%
2526 \MH_if_num:w \row@=\@ne
2527 \global \g_EQ_toptag_height_dim = \ht\z@
2528 \MH_fi:
2529 % \end{macrocode}
2530 % Similarly the depth of the last row is determined by measuring the
2531 % depth of box zero for each row and then using the last of the
2532 % values.
2533 % \begin{macrocode}
2534 \global \g_EQ_bottomtag_depth_dim=\dp\z@
2535 % \end{macrocode}
2536 % \changes{v2.11}{2004/08/03}{Added a check for being in the last row.}
2537 % Save the row number for later as the \opt{ntheorem} option will need
2538 % it.
2539 % \changes{v2.15}{2017/03/31}{added MH\_ prefixes}
2540 % \begin{macrocode}
2541 \xdef\g_EQ_latest_nonzerodepth_row_fint{\number\row@}
2542 \@tempdima=\wd\z@
2543 \MH_if_dim:w \@tempdima > \g_EQ_widesttag_dim
2544 \global \g_EQ_widesttag_dim = \@tempdima
2545 \MH_fi:
2546 #1{#2}%
2547 }
2548 % \end{macrocode}
2549 % \end{macro}
2550 %
2551 % \subsubsection{Measuring \env{gather}}
2552 % \begin{macro}{\EQ_set_gather_field:}
2553 % Box zero (\cs{z@}) contains the entire line of math in a
2554 % \env{gather}, so instead of typesetting it we typeset the phantom
2555 % of it and call \cs{EQ_measure_gather:}.
2556 % \changes{v2.15}{2017/03/31}{added MH\_ prefix}
2557 % \begin{macrocode}
2558 \def\EQ_set_gather_field:{%
2559 \iftagsleft@
2560 \global\lineht@\ht\z@
2561 \MH_else:
2562 \global\lineht@\dp\z@
2563 \MH_fi:
2564 \kern\eqnshift@
2565 %\boxz@ % Original amsmath version
2566 \EQ_measure_gather:
2567 \phantom{\boxz@}%
2568 \hfil}
2569 % \end{macrocode}
2570 % \end{macro}
2571 % \begin{macro}{\EQ_measure_gather:}
2572 % Measuring the height of the individual lines in a \env{gather} is
2573 % fairly easy. If \cs{row@} is equal to one, we're in the first
2574 % line, and the height of the top row is simply given by the height
2575 % of box zero.
2576 % \changes{v2.15}{2017/03/31}{added MH\_ prefixes}
2577 % \begin{macrocode}
2578 \def\EQ_measure_gather:{%
2579 \MH_if_num:w \row@=\@ne
2580 \g_EQ_toprow_height_dim=\ht\z@
2581 \MH_fi:
2582 % \end{macrocode}
2583 % Similarly the depth of the last row is determined by measuring the
2584 % depth of box zero for each row and then using the last of the
2585 % values.
2586 % \begin{macrocode}
2587 \g_EQ_bottomrow_depth_dim=\dp\z@
2588 \global\g_EQ_toprow_height_dim\g_EQ_toprow_height_dim
2589 \global\g_EQ_bottomrow_depth_dim\g_EQ_bottomrow_depth_dim}
2590 % \end{macrocode}
2591 % \end{macro}
2592 %
2593 % \subsubsection{Measuring \env{align}, \env{alignat} and \env{flalign}}
2594 % \begin{macro}{\EQ_set_align_field:}
2595 % Same technique as for \cs{EQ_set_gather_field}. Only this time
2596 % we have to stop the underlying \cs{start@align} from going over
2597 % the measuring phase twice. That's when the conditional
2598 % \bool{continue_measuring} comes into the picture.
2599 % \changes{v2.15}{2017/03/31}{added MH\_ prefix}
2600 % \begin{macrocode}
2601 \def\EQ_set_align_field:{%
2602 \column@plus
2603 \iftagsleft@
2604 \MH_if_dim:w \ht\z@>\lineht@
2605 \global\lineht@\ht\z@
2606 \MH_fi:
2607 \MH_else:
2608 \MH_if_dim:w \dp\z@>\lineht@
2609 \global\lineht@\dp\z@
2610 \MH_fi:
2611 \MH_fi:
2612 %\boxz@ % Original amsmath version
2613 \MH_if_boolean:nT {continue_measuring}{ \EQ_measure_align: }
2614 \phantom{\boxz@}}
2615 % \end{macrocode}
2616 % \end{macro}
2617 % \begin{macro}{\EQ_measure_align:}
2618 % We have to measure every single field of the \cs{align@} \ldots\@
2619 % Oh well, here it comes:
2620 % \changes{v2.15}{2017/03/31}{added MH\_ prefix}
2621 % \begin{macrocode}
2622 \newcount\g_EQ_temprow_int
2623 \MH_new_boolean:n {still_in_samerow}
2624 \MH_new_boolean:n {continue_measuring}
2625 \def\EQ_measure_align:{%
2626 \MH_if_num:w \g_EQ_temprow_int=\row@
2627 \MH_set_boolean_T:n {still_in_samerow}
2628 \MH_else:
2629 \MH_if_num:w \g_EQ_temprow_int>\row@
2630 \global\MH_set_boolean_F:n {continue_measuring}
2631 \MH_fi:
2632 \MH_set_boolean_F:n {still_in_samerow}
2633 \global\@tempdimc=\@tempdimb
2634 \global\@tempdimb=\g_EQ_bottomrow_depth_dim
2635 \MH_fi:
2636 \MH_if_boolean:nTF {continue_measuring}{
2637 \global\g_EQ_temprow_int=\row@
2638 \@tempcnta=\row@
2639 \MH_if_num:w \@tempcnta=\z@
2640 \@tempdima=\g_EQ_toprow_height_dim
2641 \g_EQ_toprow_height_dim=\ht\z@\relax
2642 \MH_if_dim:w \g_EQ_toprow_height_dim<\@tempdima
2643 \g_EQ_toprow_height_dim\@tempdima
2644 \MH_fi:
2645 \MH_fi:
2646 \MH_if_boolean:nTF {still_in_samerow}{
2647 \@tempdima=\g_EQ_bottomrow_depth_dim
2648 \g_EQ_bottomrow_depth_dim=\dp\z@\relax
2649 \MH_if_dim:w \g_EQ_bottomrow_depth_dim<\@tempdima
2650 \g_EQ_bottomrow_depth_dim\@tempdima
2651 \MH_fi:
2652 }{
2653 \g_EQ_bottomrow_depth_dim\dp\z@\relax
2654 }
2655 }{
2656 \global\g_EQ_bottomrow_depth_dim=\@tempdimc
2657 }
2658 \global\g_EQ_toprow_height_dim\g_EQ_toprow_height_dim
2659 \global\g_EQ_bottomrow_depth_dim\g_EQ_bottomrow_depth_dim}
2660 % \end{macrocode}
2661 % \end{macro}
2662 % \subsubsection{Typesetting the Tags}
2663 % \begin{macro}{\EQ_place_tag:N}
2664 % Fool \LaTeX\ into thinking the tag is only as wide as the widest
2665 % tag (remember the real width of the \cs{EQ_tag_box} is
2666 % $0.5$\cs{maxdimen}.
2667 % \begin{macrocode}
2668 \def\EQ_place_tag:N #1{%
2669 \tag*{\makebox[\g_EQ_widesttag_dim][#1]{%
2670 \EQ_vertical_tag_adjustment:n {\usebox{\EQ_tag_box}}}}}
2671 % \end{macrocode}
2672 % \end{macro}
2673 % \begin{macro}{\EQ_vertical_tag_adjustment:n}
2674 % \changes{v2.00}{2004/04/14}{Added a missing \cs{normallineskip} in
2675 % case of extremely big tag height}
2676 % This is a little tricky. We have measured the height of the top
2677 % row and top tag and the depth of the bottom row and bottom tag.
2678 % Now we have to adjust the vertical spacing so it comes out just
2679 % right. Remember we have separated the tags and the math display
2680 % but we would still like to have them line up as they should! We do
2681 % it all inside a group so we can use the scratch dimensions safely.
2682 % \changes{v2.15}{2017/03/31}{added MH\_ prefix}
2683 % \begin{macrocode}
2684 \def\EQ_vertical_tag_adjustment:n #1{{%
2685 \@tempdima\z@\@tempdimb\z@
2686 \@tempdimc=\dp\strutbox
2687 \MH_if_dim:w \g_EQ_toprow_height_dim<\baselineskip
2688 \MH_setlength:dn
2689 \@tempdima{\g_EQ_toprow_height_dim-\baselineskip}
2690 \MH_else:
2691 \MH_setlength:dn \@tempdima{-\normallineskip}
2692 \MH_fi:
2693 \MH_if_dim:w \g_EQ_toptag_height_dim>\g_EQ_toprow_height_dim
2694 \MH_if_dim:w \g_EQ_toptag_height_dim>\baselineskip
2695 \MH_addtolength:dn \@tempdima
2696 {-\g_EQ_toptag_height_dim+\baselineskip-\normallineskip}
2697 \MH_fi:
2698 \MH_fi:
2699 \MH_if_dim:w \g_EQ_bottomrow_depth_dim<\@tempdimc
2700 \MH_setlength:dn \@tempdimb
2701 {\g_EQ_bottomrow_depth_dim-\@tempdimc}
2702 \MH_fi:
2703 % \end{macrocode}
2704 % \changes{v2.00}{2004/04/14}{Fixed minor bug}
2705 % If the last condition is fulfilled we also need to cancel the
2706 % first condition.
2707 % \changes{v2.15}{2017/03/31}{added MH\_ prefix}
2708 % \begin{macrocode}
2709 \MH_if_dim:w \g_EQ_bottomtag_depth_dim>\g_EQ_bottomrow_depth_dim
2710 \MH_if_dim:w \g_EQ_bottomtag_depth_dim<\@tempdimc
2711 \MH_else:
2712 \MH_addtolength:dn \@tempdimb
2713 {-\g_EQ_bottomtag_depth_dim+\@tempdimc}
2714 \MH_fi:
2715 \MH_fi:
2716 \raisebox{-0.5\@tempdima+0.5\@tempdimb}{#1}}}%
2717 % \end{macrocode}
2718 % \end{macro}
2719 % \section{Adding the Equation Types}
2720 % Adding an equation type is fairly easy. The outline is this:
2721 % \begin{list}{}{\leftmargin2em}
2722 % \item[]|\EQ_new_equationtype{EmphEqEnv}|\marg{\AmS\
2723 % env}\marg{arabic num}\texttt{:}
2724 % \item[]|\def\EQ_modify_linewidth_|\meta{roman num}\texttt{:}\\
2725 % \hspace*{2em}\marg{Optionally alter \cs{l_EQ_temp_linewidth_dim}}
2726 % \item[]|\def\EQ_find_displaywidth_|\meta{roman num}\texttt{:}\\
2727 % \hspace*{2em}\marg{Set \cs{l_EQ_displaywidth_dim}}
2728 % \item[]|\def\EQ_place_display_|\meta{roman num}\texttt{:}\\
2729 % \hspace*{2em}\marg{Make use of \cs{EQ_use_mathdisplay:}}
2730 % \end{list}
2731 % \begin{macro}{\EQ_use_mathdisplay:}
2732 % A shorthand.
2733 % \begin{macrocode}
2734 \def\EQ_use_mathdisplay:{%
2735 \EQ_outerbox:{\usebox{\EQ_mathdisplay_box}}}
2736 % \end{macrocode}
2737 % \end{macro}
2738 % \begin{macrocode}
2739 \def\EQ_options_name:{EmphEqOpt}
2740 % \end{macrocode}
2741 % \subsection{The \env{equation} Family}
2742 % Just a few aliases because \env{equation} and \env{equation*}
2743 % behave strangely. Much better to use \env{gather} instead as this
2744 % is easier to measure. Besides it's less work (for us, not the
2745 % compiler). ;-)
2746 % \begin{macrocode}
2747 \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{equation}{gather}
2748 {\EQ_disable_linebreak:}
2749 \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{equation*}{gather*}
2750 {\EQ_disable_linebreak:}
2751 % \end{macrocode}
2752 % \begin{macro}{\EQ_disable_linebreak:}
2753 % \changes{v1.05c}{2004/02/25}{Introduced
2754 % \cs{EQ_disable_linebreak:} to prevent multi line
2755 % \env{equation}'s}
2756 % \changes{v1.05c}{2004/02/25}{Fixed it so that it works better}
2757 % Disable the line breaks in \env{equation} as these are actually
2758 % possible now, since we're in a \env{gather}! \cs{Let@} does it in
2759 % the environment, so that's the place to hack.
2760 % \begin{macrocode}
2761 \def\EQ_disable_linebreak:{%
2762 \MH_let:NwN \EQ_saved_Let: \Let@
2763 \def\Let@{\def\\{%
2764 \PackageError{empheq}{You~ cannot~ use~ \string\\~ in~ equation!}
2765 {\@eha}}
2766 % \end{macrocode}
2767 % Then restore the meaning of \cs{Let@} in case there is a
2768 % \env{gathered} or alike coming up.
2769 % \begin{macrocode}
2770 \MH_let:NwN \Let@ \EQ_saved_Let:
2771 }%
2772 }
2773 % \end{macrocode}
2774 % \end{macro}
2775 %
2776 % \subsection{The \env{align} Family}
2777 % \begin{macrocode}
2778 \EQ_new_equationtype:nnn {EmphEqEnv}{align}{1}
2779 \EQ_new_equationtype:nnn {EmphEqEnv}{align*}{2}
2780 % \end{macrocode}
2781 % \begin{macrocode}
2782 \def\EQ_modify_linewidth_i:{%
2783 % \end{macrocode}
2784 % If $\cs{maxfields@}=2$ we're in a single column \env{align} and
2785 % thus there is no flexible space.
2786 % \changes{v2.15}{2017/03/31}{added MH\_ prefix}
2787 % \begin{macrocode}
2788 \MH_if_num:w \maxfields@=\tw@
2789 \MH_else:
2790 % \end{macrocode}
2791 % But if there is any flexible space we would very much like to
2792 % adjust it because we add material to the right and left of the
2793 % math display.
2794 % \changes{v2.15}{2017/03/31}{added MH\_ prefix}
2795 % \changes{v2.15}{2017/03/31}{added EQ\_ prefix}
2796 % \changes{v2.16}{2020/03/23}{switched \cs{linewidth} to
2797 % \cs{l_EQ_linewidth_dim} due to amsart forcing full width displays}
2798 % \begin{macrocode}
2799 \setlength{\l_EQ_temp_linewidth_dim}{%
2800 % \linewidth
2801 \l_EQ_linewidth_dim
2802 -\l_EQ_totalwidth_dim-\widthof{\EQ_outerbox:{}}}%
2803 \MH_fi:}
2804 \def\EQ_modify_linewidth_ii:{\EQ_modify_linewidth_i:}
2805 \def\EQ_find_displaywidth_i:{%
2806 \MH_setlength:dn \l_EQ_displaywidth_dim
2807 {\l_EQ_temp_linewidth_dim-\alignsep@}
2808 \MH_if_case:w \l_EQ_alignmentmode_int
2809 \MH_or: % #1:
2810 \MH_addtolength:dn \l_EQ_displaywidth_dim{-\alignsep@}%
2811 \MH_or: % #2:
2812 \MH_addtolength:dn \l_EQ_displaywidth_dim{-\alignsep@}%
2813 \MH_or: % #3:
2814 \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
2815 \MH_or: % #4:
2816 \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
2817 \MH_fi:}
2818 \def\EQ_find_displaywidth_ii:{\EQ_find_displaywidth_i:}
2819 \def\EQ_place_display_i: {\EQ_use_mathdisplay:}
2820 \def\EQ_place_display_ii:{\EQ_place_display_i:}
2821 % \end{macrocode}
2822 %
2823 % \subsection{The \env{gather} Family}
2824 % This is a gem. Notice how easy it is once we got the framework for
2825 % it.
2826 % \changes{v2.15}{2017/03/31}{added MH\_ prefixes}
2827 % \changes{v2.15}{2017/03/31}{added EQ\_ prefix}
2828 % \begin{macrocode}
2829 \EQ_new_equationtype:nnn {EmphEqEnv}{gather}{3}
2830 \EQ_new_equationtype:nnn {EmphEqEnv}{gather*}{4}
2831 \def\EQ_modify_linewidth_iii:{}
2832 \def\EQ_modify_linewidth_iv:{\EQ_modify_linewidth_iii:}
2833 \def\EQ_find_displaywidth_iii:{%
2834 \MH_setlength:dn \l_EQ_displaywidth_dim{\totwidth@}%
2835 \MH_if_case:w \l_EQ_alignmentmode_int \MH_or: \MH_or: % #1 & #2:
2836 \MH_or: % #3:
2837 \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
2838 \MH_or: % #4:
2839 \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
2840 \MH_fi:}
2841 \def\EQ_find_displaywidth_iv:{\EQ_find_displaywidth_iii:}
2842 \def\EQ_place_display_iii:{\EQ_use_mathdisplay:}
2843 \def\EQ_place_display_iv: {\EQ_place_display_iii:}
2844 % \end{macrocode}
2845 %
2846 % \subsection{The \env{flalign} Family}\label{sec:flalign+multline}
2847 % This was fairly easy, but then I had to take care of \ldots
2848 %
2849 % \subsubsection{The \env{multline} Family}
2850 %
2851 % \emph{Note: These next three paragraphs are rather confusing. They
2852 % are referring to an older implementation (also available via the
2853 % \opt{oldmultline} option, where the \env{multline} feature was
2854 % implemented via \env{flalign}, nowadays we use \env{multlined} from
2855 % \pkg{mathtools} wrapped inside a \env{gather} for the equation number.}
2856 %
2857 % This was quite a pickle. Its implementation in \pkg{amsmath} is
2858 % very strange indeed; for instance the tag is typeset in the
2859 % measuring phase! So instead I thought I could fake it, but how
2860 % should I do it?
2861 %
2862 % The basic idea of \env{multline} is to typeset the first line
2863 % flush left, the last line flush right and the rest centered.
2864 % ``Aha,'' I thought, ``what if I make three columns, fool \LaTeX{}
2865 % into thinking the contents of the columns take no space and then
2866 % just put each line into a column?'' Thus the \env{flalign}
2867 % environment came to mind. I also distinctly remembered to have
2868 % seen an article about the equivalent of \cs{rlap} and \cs{llap} in
2869 % math mode, namely an article by Alexander R.~Perlis. This works
2870 % pretty well, and so does the same trick for producing a
2871 % \env{multlined} environment. That one uses an \env{alignedat} with
2872 % three columns.
2873 %
2874 % \changes{v1.05c}{2004/02/25}{Makes use of
2875 % \cs{MakeKeyvalAliasAddon} now}
2876 % Then we make \env{multline} into an alias for {flalign} but with
2877 % an extra switch \cs{ifEQ_multline:} set to true.
2878 %
2879 % Note this version of the \env{multline} code is being used when we
2880 % use the \emph{bad} \env{multline} implementation, see code line
2881 % \lineref{goodandbad} onwards.
2882 % \begin{macrocode}
2883 \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{multline}
2884 {flalign}{\MH_set_boolean_T:n {multline}}
2885 \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{multline*}
2886 {flalign*}{\MH_set_boolean_T:n {multline}}
2887 % \end{macrocode}
2888 % \begin{macro}{\if_EQ_multline:}
2889 % \begin{macro}{\EQ_generic_multline:nnnnn}
2890 % We make a general command that'll provide the correct spacing and
2891 % then just define the user commands in terms of that single generic
2892 % one.
2893 % \begin{macrocode}
2894 \MH_new_boolean:n {multline}
2895 % \end{macrocode}
2896 % \begin{macro}{\EQ_multline_modify_linewidth_tag:}
2897 % \begin{macro}{\EQ_multline_modify_linewidth_notag:}
2898 % There is a big difference between the spacing in \env{multline}
2899 % depending on the presence of a tag. Therefore we split it up in
2900 % two cases. I made this choice because we need these adjustments
2901 % inside the adjustments for \env{flalign} and that makes it
2902 % incredibly difficult to see what happens.
2903 % \changes{v2.15}{2017/03/31}{added MH\_ prefixes}
2904 % \begin{macrocode}
2905 \def\EQ_multline_modify_linewidth_tag:{%
2906 \MH_if_case:w \l_EQ_alignmentmode_int
2907 \MH_or: % #1:
2908 \MH_addtolength:dn \l_EQ_temp_linewidth_dim{%
2909 -\g_EQ_widesttag_dim-\multlinetaggap-\multlinegap}%
2910 \MH_or:
2911 \MH_addtolength:dn \l_EQ_temp_linewidth_dim{%
2912 -\g_EQ_widesttag_dim-\multlinetaggap-\multlinegap}%
2913 \MH_or:
2914 \MH_addtolength:dn \l_EQ_temp_linewidth_dim{%
2915 -\@mathmargin-\g_EQ_widesttag_dim-\multlinetaggap}%
2916 \MH_or:
2917 \MH_addtolength:dn
2918 \l_EQ_temp_linewidth_dim{-\@mathmargin-\multlinegap}%
2919 \MH_fi:
2920 }
2921 \def\EQ_multline_modify_linewidth_notag:{%
2922 \MH_if_case:w \l_EQ_alignmentmode_int
2923 \MH_or:
2924 \MH_addtolength:dn \l_EQ_temp_linewidth_dim{-2\multlinegap}
2925 \MH_or:
2926 \MH_addtolength:dn \l_EQ_temp_linewidth_dim{-2\multlinegap}
2927 \MH_or:
2928 \MH_addtolength:dn
2929 \l_EQ_temp_linewidth_dim{-\@mathmargin-\multlinegap}%
2930 \MH_or:
2931 \MH_addtolength:dn
2932 \l_EQ_temp_linewidth_dim{-\@mathmargin-\multlinegap}%
2933 \MH_fi:
2934 }
2935 % \end{macrocode}
2936 % \end{macro}
2937 % \end{macro}
2938 %
2939 % \begin{environment}{MTmultlined}
2940 % Save the superior \env{multlined} from \pkg{mathtools} under a new
2941 % name.
2942 % \begin{macrocode}
2943 \MH_let:NwN \MTmultlined \multlined
2944 \MH_let:NwN \endMTmultlined \endmultlined
2945 % \end{macrocode}
2946 % \end{environment}
2947 % We make a choice here: the good \env{multline} or the bad?
2948 % ^^A daleif 2024/10/07: the line below fails
2949 % ^^A \stepcounter{CodelineNo}\label{goodandbad}\addtocounter{CodelineNo}{-1}
2950 % \begin{macrocode}
2951 \MH_if_boolean:nTF {good_mult}{
2952 % \end{macrocode}
2953 % The good:
2954 % \changes{v2.15}{2017/03/31}{added MH\_ prefix}
2955 % \changes{v2.15}{2017/03/31}{added EQ\_ prefix}
2956 % \changes{v2.16}{2020/03/23}{switched \cs{linewidth} to
2957 % \cs{l_EQ_linewidth_dim} due to amsart forcing full width displays}
2958 % \begin{macrocode}
2959 \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{multline}{gather}
2960 {\MH_set_boolean_T:n {outer_mult}}
2961 \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{multline*}{gather*}
2962 {\MH_set_boolean_T:n {outer_mult}}
2963 \def\EQ_modify_linewidth_iii_mult:{
2964 \setlength{\l_EQ_temp_linewidth_dim}{%
2965 % \linewidth
2966 \l_EQ_linewidth_dim
2967 -\widthof{\EQ_outerbox:{}}}%
2968 \MH_if_dim:w \g_EQ_widesttag_dim>\z@
2969 \EQ_multline_modify_linewidth_tag:
2970 \MH_else:
2971 \EQ_multline_modify_linewidth_notag:
2972 \MH_fi:
2973 \MH_setlength:dn \l_MT_multwidth_dim{\l_EQ_temp_linewidth_dim}
2974 % \end{macrocode}
2975 % Here is an interesting issue. We have just calculated
2976 % \cs{l_MT_multwidth_dim} which will be the width of the internal
2977 % \env{multline}. But we are typesetting inside \env{gather} inside a
2978 % box of width \cs{l_EQ_temp_linewidth_dim} so the effective width of
2979 % the display is \cs{@mathmargin} less. Solution: add \cs{@mathmargin}
2980 % back in:
2981 % \changes{v2.16}{2020/03/23}{Added \cs{@mathmargin} back into the box
2982 % width}
2983 % \begin{macrocode}
2984 \MH_if_case:w \l_EQ_alignmentmode_int
2985 \MH_or: \MH_or: % 1 and 2
2986 \MH_or:
2987 \MH_addtolength:dn
2988 \l_EQ_temp_linewidth_dim{\@mathmargin}%
2989 \MH_or:
2990 \MH_addtolength:dn
2991 \l_EQ_temp_linewidth_dim{\@mathmargin}%
2992 \MH_fi:
2993 }
2994 \def\EQ_modify_linewidth_iv_mult:{\EQ_modify_linewidth_iii_mult:}
2995 \def\EQ_find_displaywidth_iii_mult:{%
2996 \MH_setlength:dn \l_EQ_displaywidth_dim{\totwidth@}%
2997 \MH_if_case:w \l_EQ_alignmentmode_int \MH_or: \MH_or: % #1 & #2:
2998 \MH_or: % #3:
2999 \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
3000 \MH_or: % #4:
3001 \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
3002 \MH_fi:}
3003 \def\EQ_find_displaywidth_iv_mult:{\EQ_find_displaywidth_iii_mult:}
3004 % \end{macrocode}
3005 % \changes{v2.16}{2020/03/23}{switched \cs{linewidth} to
3006 % \cs{l_EQ_linewidth_dim} due to amsart forcing full width displays}
3007 % \begin{macrocode}
3008 \def\EQ_place_display_iii_mult:{
3009 \MH_if_case:w \l_EQ_alignmentmode_int
3010 \MH_or: % #1:
3011 \MH_if_dim:w \g_EQ_widesttag_dim>\z@
3012 \abovedisplayshortskip=\abovedisplayskip
3013 \rlap{
3014 % \kern-.5\linewidth
3015 \kern-.5\l_EQ_linewidth_dim
3016 \kern\multlinegap
3017 \EQ_use_mathdisplay:
3018 }
3019 \MH_else:
3020 \EQ_use_mathdisplay:
3021 \MH_fi:
3022 \MH_or: % #2:
3023 \MH_if_dim:w \g_EQ_widesttag_dim>\z@
3024 \llap{
3025 \EQ_use_mathdisplay:
3026 % \kern-.5\linewidth
3027 \kern-.5\l_EQ_linewidth_dim
3028 \kern\multlinegap
3029 }%
3030 \MH_else:
3031 \EQ_use_mathdisplay:
3032 \MH_fi:
3033 \MH_or: % #3:
3034 \EQ_use_mathdisplay:
3035 \MH_or: % #4:
3036 \EQ_use_mathdisplay:
3037 \MH_fi:
3038 }
3039 \def\EQ_place_display_iv_mult: {\EQ_place_display_iii_mult:}
3040 % \end{macrocode}
3041 % \begin{macrocode}
3042 }{% on to the 'bad' version
3043 % \end{macrocode}
3044 % The bad
3045 % \begin{macrocode}
3046 \def\EQ_generic_multline:nnnnn #1#2#3#4#5{%
3047 % \end{macrocode}
3048 % This is a very tricky little detail. If we're in \mode{leqno} mode
3049 % we need just a wee little width inside the \env{flalign}, so we put
3050 % in the smallest possible amount. Otherwise we wind up in a
3051 % \begin{verbatim}
3052 % ! Arithmetic overflow.
3053 % <recently read> \count@
3054 %
3055 % l.304 % \end{empheq}
3056 % \end{verbatim}
3057 % If you scroll past this error it will be typeset correctly, but
3058 % how many users can fix this by themselves?
3059 % \changes{v2.15}{2017/03/31}{added MH\_ prefix}
3060 % \begin{macrocode}
3061 \hskip1sp#2#3{{}#5}#4%
3062 \MH_if:w *#1\relax\MH_else:\notag\MH_fi:}
3063 % \end{macrocode}
3064 % \end{macro}
3065 % \end{macro}
3066 % \begin{macro}{\multleft}
3067 % \begin{macro}{\multcenter}
3068 % \begin{macro}{\multright}
3069 % Then the commands that use \cs{EQ_generic_multline:nnnnn}. The
3070 % first three are the general purpose ones that also have a starred
3071 % version. The other three are for normal use.
3072 % \begin{macrocode}
3073 \def\multleft{\@ifstar{%
3074 \MH_if_boolean:nTF {multlined}{
3075 \def\EQ_next:{\EQ_multlined_left:n}
3076 }{
3077 \def\EQ_next:{
3078 \EQ_generic_multline:nnnnn {*}{}{\mathrlap}{&&&&&}}
3079 }
3080 \EQ_next:}{%
3081 \MH_if_boolean:nTF {multlined}{
3082 \def\EQ_next:{\EQ_multlined_left:n}%
3083 }{
3084 \def\EQ_next:{
3085 \EQ_generic_multline:nnnnn {}{}{\mathrlap}{&&&&&}}
3086 }
3087 \EQ_next:}}%
3088 \def\multcenter{\@ifstar{%
3089 \MH_if_boolean:nTF {multlined}{
3090 \def\EQ_next:{\EQ_multlined_center:n}%
3091 }{
3092 \def\EQ_next:{
3093 \EQ_generic_multline:nnnnn {*}{&&}{\mathclap}{&&&}}
3094 }
3095 \EQ_next:}{%
3096 \MH_if_boolean:nTF {multlined}{
3097 \def\EQ_next:{\EQ_multlined_center:n }%
3098 }{
3099 \def\EQ_next:{
3100 \EQ_generic_multline:nnnnn {}{&&}{\mathclap}{&&&}}
3101 }
3102 \EQ_next:}}%
3103 \def\multright{\@ifstar{%
3104 \MH_if_boolean:nTF {multlined}{
3105 \def\EQ_next:{\EQ_multlined_right:n }%
3106 }{
3107 \def\EQ_next:{
3108 \EQ_generic_multline:nnnnn {*}{&&&&&}{\mathllap}{}}
3109 }
3110 \EQ_next:}{%
3111 \MH_if_boolean:nTF {multlined}{
3112 \def\EQ_next:{\EQ_multlined_right:n }%
3113 }{
3114 \def\EQ_next:{
3115 \EQ_generic_multline:nnnnn {}{&&&&&}{\mathllap}{}}
3116 }
3117 \EQ_next:}}
3118 % \end{macrocode}
3119 % \end{macro}
3120 % \end{macro}
3121 % \end{macro}
3122 % \begin{macro}{\multfirst}
3123 % \begin{macro}{\multmiddle}
3124 % \begin{macro}{\multlast}
3125 % If we're using the \mode{leqno} option, the equation number should
3126 % be placed in the first line.
3127 % \changes{v2.15}{2017/03/31}{added MH\_ prefixes}
3128 % \begin{macrocode}
3129 \def\multfirst{%
3130 \MH_if_boolean:nTF {multlined}{
3131 \def\EQ_next:{\EQ_multlined_left:n }%
3132 }{
3133 \MH_if_case:w \l_EQ_alignmentmode_int
3134 \MH_or: % #1:
3135 \def\EQ_next:{\multleft}%
3136 \MH_or: % #2:
3137 \def\EQ_next:{\multleft*}%
3138 \MH_or: % #3:
3139 \def\EQ_next:{\multleft}%
3140 \MH_or: % #4:
3141 \def\EQ_next:{\multleft*}%
3142 \MH_fi:
3143 }
3144 \EQ_next:}
3145 % \end{macrocode}
3146 % Pretend the star was never there.
3147 % \begin{macrocode}
3148 \def\multmiddle{%
3149 \def\EQ_next:{%
3150 \MH_if_boolean:nTF {multlined}{
3151 \expandafter\EQ_multlined_center:n
3152 }{
3153 \expandafter\multcenter
3154 }
3155 }%
3156 \@ifstar{\EQ_next:}{\EQ_next:}}
3157 % \end{macrocode}
3158 % If we're using the \mode{reqno} option, the equation number
3159 % should be placed in the last line.
3160 % \changes{v2.15}{2017/03/31}{added MH\_ prefixes}
3161 % \begin{macrocode}
3162 \def\multlast{%
3163 \MH_if_boolean:nTF {multlined}{
3164 \def\EQ_next:{\EQ_multlined_right:n }%
3165 }{
3166 \MH_if_case:w \l_EQ_alignmentmode_int
3167 \MH_or: % #1:
3168 \def\EQ_next:{\multright*}%
3169 \MH_or: % #2:
3170 \def\EQ_next:{\multright}%
3171 \MH_or: % #3:
3172 \def\EQ_next:{\multright*}%
3173 \MH_or: % #4:
3174 \def\EQ_next:{\multright}%
3175 \MH_fi:
3176 }
3177 \EQ_next:}
3178 % \end{macrocode}
3179 % \end{macro}
3180 % \end{macro}
3181 % \end{macro}
3182 % \begin{macro}{\multlinedwidth}
3183 % Here begins the code for \env{multlined}.
3184 % \changes{v2.16}{2020/03/23}{switched \cs{linewidth} to
3185 % \cs{l_EQ_linewidth_dim} due to amsart forcing full width displays}
3186 % \begin{macrocode}
3187 \MH_new_boolean:n {multlined}
3188 \newdimen\multlinedwidth
3189 \MH_setlength:dn \multlinedwidth{
3190 % .7\linewidth
3191 0.7\l_EQ_linewidth_dim
3192 }
3193 % \end{macrocode}
3194 % \end{macro}
3195 % \begin{environment}{multlined}
3196 % \changes{v2.10}{2004/07/26}{Disallow spaces before optional
3197 % arguments.}
3198 % \begin{macro}{\EQ_multlined_I:w}
3199 % \begin{macro}{\EQ_multlined_II:w}
3200 % \begin{macro}{\EQ_multlined_III:nn}
3201 % Some trickery as we want to scan for two optional arguments that
3202 % may be interchanged.
3203 % \begin{macrocode}
3204 \renewenvironment{multlined}%
3205 {\MH_nospace_ifnextchar:Nnn [ {\EQ_multlined_I:w}
3206 {\EQ_multlined_I:w[c]}
3207 }
3208 { \endaligned }
3209 \def\EQ_multlined_I:w[#1]{%
3210 \MH_nospace_ifnextchar:Nnn[ {\EQ_multlined_II:w[#1]}
3211 {\EQ_multlined_II:w[#1][\multlinedwidth]}}
3212 \def\EQ_multlined_II:w[#1][#2]{%
3213 % \end{macrocode}
3214 % We tell \LaTeX\ that we're in \env{multlined}.
3215 % \begin{macrocode}
3216 \MH_set_boolean_T:n {multlined}
3217 % \end{macrocode}
3218 % \changes{v2.10}{2004/07/26}{Fixed restoration of \cmd{\\}}
3219 % Restore the meaning of \cmd{\\} inside \env{multlined}, else it
3220 % wouldn't work in the \env{equation} environment.
3221 % \begin{macrocode}
3222 \MH_let:NwN \Let@\MT_saved_Let:
3223 % \end{macrocode}
3224 % Then check the first optional argument and call
3225 % \cs{EQ_multlined_III:w}, which sets \cs{multlinewidth} if
3226 % specified and calls \cs{start@aligned} (an \env{alignedat} with
3227 % three columns).
3228 % \changes{v2.15}{2017/03/31}{added MH\_ prefix}
3229 % \begin{macrocode}
3230 \MH_if:w t#1\relax \EQ_multlined_III:nn {#1}{#2}%
3231 \MH_else:
3232 \MH_if:w b#1\relax \EQ_multlined_III:nn {#1}{#2}%
3233 \MH_else:
3234 \MH_if:w c#1\relax \EQ_multlined_III:nn {#1}{#2}%
3235 \MH_else:
3236 \EQ_multlined_III:nn {#2}{#1}%
3237 \MH_fi:
3238 \MH_fi:
3239 \MH_fi:
3240 \mkern-\thinmuskip
3241 \EQ_next:}
3242 \def\EQ_multlined_III:nn #1#2{%
3243 \def\EQ_next:{\setlength\multlinedwidth{#2}%
3244 \start@aligned{#1}{\thr@@}}}
3245 % \end{macrocode}
3246 % \end{macro}
3247 % \end{macro}
3248 % \end{macro}
3249 % \end{environment}
3250 % \begin{macro}{\EQ_multlined_left:n}
3251 % \begin{macro}{\EQ_multlined_center:n}
3252 % \begin{macro}{\EQ_multlined_right:n}
3253 % The internal versions of \cs{multleft} etc.\ adapted for
3254 % \env{multlined}.
3255 % \begin{macrocode}
3256 \def\EQ_multlined_left:n #1{%
3257 \mathrlap{#1}&\hskip.5\multlinedwidth&&\hskip.5\multlinedwidth&&}
3258 \def\EQ_multlined_center:n #1{%
3259 &\hskip.5\multlinedwidth&&\mathclap{#1}\hskip.5\multlinedwidth&&}
3260 \def\EQ_multlined_right:n #1{%
3261 &\hskip.5\multlinedwidth&&\hskip.5\multlinedwidth&&\mathllap{#1}}
3262 % \end{macrocode}
3263 % \end{macro}
3264 % \end{macro}
3265 % \end{macro}
3266 %
3267 % End of bad multline.
3268 % \begin{macrocode}
3269 }
3270 % \end{macrocode}
3271 %
3272 % \subsubsection{The Code for \env{flalign} \& \env{multline}}
3273 % \changes{v2.15}{2017/03/31}{added MH\_ prefix}
3274 % \changes{v2.15}{2017/03/31}{added EQ\_ prefix}
3275 % \changes{v2.16}{2020/03/23}{switched \cs{linewidth} to
3276 % \cs{l_EQ_linewidth_dim} due to amsart forcing full width displays}
3277 % \begin{macrocode}
3278 \EQ_new_equationtype:nnn {EmphEqEnv}{flalign}{5}
3279 \EQ_new_equationtype:nnn {EmphEqEnv}{flalign*}{6}
3280 \def\EQ_modify_linewidth_v:{%
3281 \setlength{\l_EQ_temp_linewidth_dim}{%
3282 % \linewidth
3283 \l_EQ_linewidth_dim
3284 -\l_EQ_totalwidth_dim-\widthof{\EQ_outerbox:{}}}%
3285 \MH_if_dim:w \g_EQ_widesttag_dim>\z@
3286 \MH_if_boolean:nTF {multline}{
3287 \EQ_multline_modify_linewidth_tag:
3288 }{
3289 \MH_if_case:w \l_EQ_alignmentmode_int
3290 \MH_or: % #1:
3291 \MH_addtolength:dn \l_EQ_temp_linewidth_dim
3292 {-\g_EQ_widesttag_dim-\mintagsep}
3293 \MH_or: % #2:
3294 \MH_addtolength:dn \l_EQ_temp_linewidth_dim
3295 {-\g_EQ_widesttag_dim-\mintagsep}%
3296 \MH_or: % #3:
3297 \MH_addtolength:dn \l_EQ_temp_linewidth_dim
3298 {-\g_EQ_widesttag_dim-\mintagsep}
3299 \MH_or: % #4:
3300 \MH_addtolength:dn \l_EQ_temp_linewidth_dim
3301 {-\@mathmargin}
3302 \MH_fi:
3303 }
3304 \MH_else:
3305 \MH_if_boolean:nT {multline}{
3306 \EQ_multline_modify_linewidth_notag:
3307 }
3308 \MH_fi:}
3309 \def\EQ_modify_linewidth_vi:{\EQ_modify_linewidth_v:}
3310 \def\EQ_find_displaywidth_v:{%
3311 \MH_setlength:dn
3312 \l_EQ_displaywidth_dim{\l_EQ_temp_linewidth_dim}}
3313 \def\EQ_find_displaywidth_vi:{\EQ_find_displaywidth_v:}
3314 % \end{macrocode}
3315 % \changes{v2.16}{2020/03/23}{switched \cs{linewidth} to
3316 % \cs{l_EQ_linewidth_dim} due to amsart forcing full width displays}
3317 % \begin{macrocode}
3318 \def\EQ_place_display_v:{%
3319 \MH_if_case:w \l_EQ_alignmentmode_int
3320 \MH_or: % #1:
3321 \MH_if_dim:w \g_EQ_widesttag_dim>\z@
3322 \MH_if_boolean:nTF {multline}{
3323 \rlap{\kern\multlinegap
3324 % \kern-.5\linewidth
3325 \kern-.5\l_EQ_linewidth_dim
3326 \EQ_use_mathdisplay:
3327 \kern-\mintagsep \kern\multlinetaggap}%
3328 }{
3329 \rlap{%\kern-.5\linewidth
3330 \kern-.5\l_EQ_linewidth_dim
3331 \EQ_use_mathdisplay:}%
3332 }
3333 \MH_else:
3334 \EQ_use_mathdisplay:
3335 \MH_fi:
3336 \MH_or: % #2:
3337 \MH_if_dim:w \g_EQ_widesttag_dim>\z@
3338 \MH_if_boolean:nTF {multline}{
3339 \llap{\kern-\mintagsep \kern\multlinetaggap
3340 \EQ_use_mathdisplay:
3341 \kern\multlinegap
3342 % \kern-.5\linewidth
3343 \kern-.5\l_EQ_linewidth_dim
3344 }%
3345 }{
3346 \llap{\EQ_use_mathdisplay:
3347 % \kern-.5\linewidth
3348 \kern-.5\l_EQ_linewidth_dim
3349 }%
3350 }
3351 \MH_else:
3352 \EQ_use_mathdisplay:
3353 \MH_fi:
3354 \MH_or: % #3:
3355 % \end{macrocode}
3356 % \changes{v2.16}{2020/03/24}{\cs{multlinetaggap} should be added when
3357 % \opt{multline} is true, and if false \cs{\@mathmargin} should ned
3358 % kerned away}
3359 % \begin{macrocode}
3360 \MH_if_boolean:nTF {multline}{ \kern-\multlinetaggap }
3361 { \kern-\@mathmargin }
3362 \EQ_use_mathdisplay:
3363 \MH_or: % #4:
3364 \MH_if_dim:w \g_EQ_widesttag_dim>\z@
3365 \MH_else:
3366 \MH_if_boolean:nF {multline}{ \kern-\@mathmargin }
3367 \MH_fi:
3368 \EQ_use_mathdisplay:
3369 \MH_fi:
3370 \MH_set_boolean_F:n {multline}}
3371 \def\EQ_place_display_vi:{\EQ_place_display_v:}
3372 % \end{macrocode}
3373 %
3374 % \subsection{The \env{alignat} Family}
3375 % This is just as easy as \env{gather}. Actually only one line is
3376 % different from \env{gather}!
3377 % \changes{v2.15}{2017/03/31}{added MH\_ prefixes}
3378 % \changes{v2.15}{2017/03/31}{added EQ\_ prefix}
3379 % \begin{macrocode}
3380 \EQ_new_equationtype_arg:nnn {EmphEqEnv}{alignat}{7}
3381 \EQ_new_equationtype_arg:nnn {EmphEqEnv}{alignat*}{8}
3382 \def\EQ_modify_linewidth_vii:{}
3383 \def\EQ_modify_linewidth_viii:{\EQ_modify_linewidth_vii:}
3384 \def\EQ_find_displaywidth_vii:{%
3385 \MH_setlength:dn \l_EQ_displaywidth_dim{\totwidth@}%
3386 \MH_if_case:w \l_EQ_alignmentmode_int
3387 \MH_or: % #1:
3388 \MH_or: % #2:
3389 \MH_or: % #3:
3390 \MH_addtolength:dn \l_EQ_displaywidth_dim{-\eqnshift@}%
3391 \MH_or: % #4:
3392 \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
3393 \MH_fi:}
3394 \def\EQ_find_displaywidth_viii:{\EQ_find_displaywidth_vii:}
3395 \def\EQ_place_display_vii:{\EQ_use_mathdisplay:}
3396 \def\EQ_place_display_viii:{\EQ_place_display_vii:}
3397 % \end{macrocode}
3398 % \section{The User Interface}
3399 % The different keys.
3400 % \begin{macrocode}
3401 \define@key{\EQ_options_name:}{box}{\def\EQ_outerbox:{#1}}
3402 \MH_keyval_alias:nnn {\EQ_options_name:}{outerbox}{box}
3403 % \end{macrocode}
3404 % \begin{macro}{\EQ_marginbox:nn}
3405 % The margin box. Uwe Siart wanted it.
3406 % \begin{macrocode}
3407 \def\EQ_marginbox:nn #1#2{%
3408 \settowidth{\@tempdima}{#2}%
3409 \makebox[\z@]{\hspace{\@tempdima}#1{#2}}}
3410 \define@key{\EQ_options_name:}{marginbox}{%
3411 \def\EQ_outerbox:{\EQ_marginbox:nn {#1}}}
3412 % \end{macrocode}
3413 % \end{macro}
3414 % Almost self-explanatory, isn't?
3415 % \begin{macrocode}
3416 \define@key{\EQ_options_name:}{innerbox}{\def\EQ_innerbox:{#1}}
3417 \define@key{\EQ_options_name:}{left}{\def\EQ_left_side:{#1}}
3418 \define@key{\EQ_options_name:}{right}{\def\EQ_right_side:{#1}}
3419 % \end{macrocode}
3420 % \begin{macro}{\empheqset}
3421 % Just a user friendly way to set keys. Uwe Siart again.
3422 % \begin{macrocode}
3423 \newcommand*\empheqset[1]{\setkeys{\EQ_options_name:}{#1}}
3424 % \end{macrocode}
3425 % \end{macro}
3426 % The old keys from the original version are no longer supported.
3427 % Instead they give an error message (RM):
3428 % \begin{macrocode}
3429 \def\EQ_upgrade_error:{%
3430 \PackageError{empheq}
3431 {You~ are~ using~ the~ old~ syntax!\MessageBreak
3432 The~ `empheq'~ environment~ takes~ a~ mandatory~
3433 argument~ now.\MessageBreak
3434 You~ need~ to~ exit~ and~ change~ your~ source~ file.}
3435 {It~ won't~ work,~ trust me.~ Press~ `X'~ now.}}
3436 \define@key{\EQ_options_name:}{boxtype}{\EQ_upgrade_error:}
3437 \define@key{\EQ_options_name:}{Left}{\EQ_upgrade_error:}
3438 \define@key{\EQ_options_name:}{Right}{\EQ_upgrade_error:}
3439 % \end{macrocode}
3440 % \begin{macro}{\empheqeqrefbase}
3441 % This macro is used to locally redefine \cs{eqref}, it will just
3442 % point at \cs{textup}, the user can then redefine it if nessary.
3443 % \begin{macrocode}
3444 \let\empheqeqrefbase\textup
3445 % \end{macrocode}
3446 %
3447 % \end{macro}
3448 % \begin{environment}{empheq}
3449 % The environment.
3450 % \begin{macrocode}
3451 \newenvironment{empheq}[2][]{%
3452 % \end{macrocode}
3453 % \begin{macro}{\EQ_saved_maketag}
3454 % \changes{v2.13}{2013/02/11}{Fixing \cs{eqref}}
3455 % We start with a small caveat: During processing \cs{maketag@@@} is
3456 % redefined, enabling us to separate math and eqn numbers. But the
3457 % user may have used \cs{eqref} in a comment in the math, and
3458 % \cs{eqref} use \cs{maketag@@@}\dots{} First save the original \cs{maketag@@@}:
3459 % \begin{macrocode}
3460 \MH_let:NwN\EQ_saved_maketag: \maketag@@@%
3461 % \end{macrocode}
3462 % Next redefine \cs{eqref} to locally bring back the original:
3463 % \begin{macrocode}
3464 \renewcommand\eqref[1]{\empheqeqrefbase{%
3465 \let\maketag@@@\EQ_saved_maketag:%
3466 \tagform@{\ref{##1}}}}
3467 \setkeys{EmphEqEnv}{#2}\setkeys{\EQ_options_name:}{#1}%
3468 \EmphEqMainEnv}{\endEmphEqMainEnv}
3469 % \end{macrocode}
3470 % \end{macro}
3471 % \end{environment}
3472 % \begin{macro}{\DeclareLeftDelimiter}
3473 % \begin{macro}{\EQ_declare_left_delimiter:nnnn}
3474 % \begin{macro}{\DeclareRightDelimiter}
3475 % \begin{macro}{\EQ_declare_right_delimiter:nnnn}
3476 % The delimiter interface.
3477 % \changes{v0.7}{2003/05/11}{Introduced delimiter interface}
3478 % \changes{v1.05d}{2004/02/26}{Changed the definitions.}
3479 % We now use the \cs{EQ_tag_box} to calculate the height but
3480 % adjust the vertical spacing. All this to prevent running
3481 % \cs{EQ_typeset_display:} twice.
3482 % \begin{macrocode}
3483 \newcommand*\DeclareLeftDelimiter[2][]{%
3484 \EQ_declare_left_delimiter:nnnn {#1}{#2}{}{}%
3485 \EQ_declare_left_delimiter:nnnn {#1}{#2}{big}{\EQ_innerbox:}}
3486 \def\EQ_declare_left_delimiter:nnnn #1#2#3#4{%
3487 \@namedef{empheq#3\expandafter\@gobble\string#2}{%
3488 \left#2%
3489 \mkern-\thinmuskip
3490 \vphantom{#4{\parbox{.5\maxdimen}{%
3491 \EQ_predisplay_adjustment:
3492 \EQ_prevent_vertical_space:
3493 \usebox{\EQ_tag_box}%
3494 \EQ_postdisplay_adjustment:}}}%
3495 \right.%
3496 \kern-\nulldelimiterspace #1}}
3497 \newcommand*\DeclareRightDelimiter[2][]{%
3498 \EQ_declare_right_delimiter:nnnn {#1}{#2}{}{}%
3499 \EQ_declare_right_delimiter:nnnn {#1}{#2}{big}{\EQ_innerbox:}}
3500 \def\EQ_declare_right_delimiter:nnnn #1#2#3#4{%
3501 \@namedef{empheq#3\expandafter\@gobble\string#2}{%
3502 \kern-\nulldelimiterspace
3503 #1%
3504 \left.%
3505 \vphantom{#4{\parbox{.5\maxdimen}{%
3506 \EQ_predisplay_adjustment:
3507 \EQ_prevent_vertical_space:
3508 \usebox{\EQ_tag_box}%
3509 \EQ_postdisplay_adjustment:}}}%
3510 \mkern-\thinmuskip
3511 \right#2}}
3512 % \end{macrocode}
3513 % \end{macro}
3514 % \end{macro}
3515 % \end{macro}
3516 % \end{macro}
3517 % The actual declarations.
3518 % \begin{macrocode}
3519 \DeclareLeftDelimiter{\lbrace}
3520 \DeclareRightDelimiter{\rbrace}
3521 \DeclareLeftDelimiter{\lbrack}
3522 \DeclareRightDelimiter{\rbrack}
3523 \DeclareLeftDelimiter{\langle}
3524 \DeclareRightDelimiter{\rangle}
3525 \DeclareLeftDelimiter{\lvert}
3526 \DeclareRightDelimiter{\rvert}
3527 \DeclareLeftDelimiter{\lVert}
3528 \DeclareRightDelimiter{\rVert}
3529 \DeclareLeftDelimiter{\lfloor}
3530 \DeclareRightDelimiter{\rfloor}
3531 \DeclareLeftDelimiter{\lceil}
3532 \DeclareRightDelimiter{\rceil}
3533 \DeclareLeftDelimiter{\lparen}
3534 \DeclareRightDelimiter{\rparen}
3535 % \end{macrocode}
3536 %
3537 % \section{Support for Other Packages}
3538 %
3539 % Support for various other packages is found in this section. The
3540 % \pkg{ntheorem} package now has a dedicated section (\S
3541 % \vref{sec:impl:ntheorem}), as it now a module.
3542 %
3543 %
3544 %
3545 % \begin{macrocode}
3546 \def\EQ_typeset_tags_hook:{}
3547 \def\EQ_typeset_display_hook:{}
3548 % \end{macrocode}
3549 %
3550 % \subsection{\pkg{showkeys}}
3551 % \changes{v2.10}{2004/07/26}{Added support for the \pkg{showkeys}
3552 % package}
3553 % We just disable \pkg{showkeys} when typesetting the labels.
3554 % \begin{macrocode}
3555 \g@addto@macro\EQ_typeset_display_hook:{
3556 \def\SK@@label#1>#2\SK@{}
3557 }
3558 % \end{macrocode}
3559 % If we overload the \AmS{} equation types we should still be able
3560 % to use \pkg{showkeys}.
3561 % \begin{macrocode}
3562 \@namedef{SK@AmSequation} {\SK@equationtrue}
3563 \@namedef{SK@AmSequation*} {\SK@equationtrue}
3564 \@namedef{SK@AmSalign} {\SK@equationtrue}
3565 \@namedef{SK@AmSalign*} {\SK@equationtrue}
3566 \@namedef{SK@AmSalignat} {\SK@equationtrue}
3567 \@namedef{SK@AmSalignat*} {\SK@equationtrue}
3568 \@namedef{SK@AmSgather} {\SK@equationtrue}
3569 \@namedef{SK@AmSgather*} {\SK@equationtrue}
3570 \@namedef{SK@AmSmultline} {\SK@equationtrue}
3571 \@namedef{SK@AmSmultline*} {\SK@equationtrue}
3572 \@namedef{SK@AmSflalign} {\SK@equationtrue}
3573 \@namedef{SK@AmSflalign*} {\SK@equationtrue}
3574 % \end{macrocode}
3575 %
3576 % \subsection{\pkg{hyperref}}
3577 %
3578 %
3579 % A little trick to avoid the (in)famous warning
3580 % \begin{verbatim}
3581 % ! pdfTeX warning (ext4): destination with the same identifier
3582 % (name{equation.1a }) has been already used, duplicate ignored
3583 % <to be read again>
3584 % \endgroup \set@typeset@protect
3585 % \end{verbatim}
3586 % This doesn't require \pkg{hyperref}.
3587 % \begin{macrocode}
3588 \AtBeginDocument{
3589 \@ifundefined{Hy@linkcounter}{\newcount\Hy@linkcounter}{}
3590 }
3591 \g@addto@macro\EQ_typeset_display_hook:{
3592 \MH_let:NwN \hyper@refstepcounter\@gobble
3593 }
3594 % \end{macrocode}
3595 %
3596 % \subsection{\pkg{nccmath}}
3597 %
3598 % Must disable this macro, otherwise the spacing is wrong.
3599 % \begin{macrocode}
3600 \g@addto@macro\EQ_typeset_display_hook:{
3601 \let\NCC@ignorepar\relax
3602 }
3603 \g@addto@macro\EQ_typeset_tags_hook:{
3604 \let\NCC@ignorepar\relax
3605 }
3606 % \end{macrocode}
3607 %
3608 % \subsection{Basic \pkg{ntheorem} support}
3609 % \begin{macrocode}
3610 \g@addto@macro\EQ_typeset_tags_hook:{
3611 \MH_let:NwN\TagsPlusEndmarks\relax
3612 \MH_let:NwN\RestoreTags\relax
3613 }
3614 \g@addto@macro\EQ_typeset_display_hook:{
3615 \MH_let:NwN\TagsPlusEndmarks\relax
3616 \MH_let:NwN\RestoreTags\relax
3617 }
3618 % \end{macrocode}
3619 % \subsection{Basic \LaTeXe{} support}
3620 % Gobble the \cs{ltx@label} and disable most error messages.
3621 % \changes{v2.00}{2004/04/14}{Make a special label-gobbling command
3622 % to support \pkg{ntheorem} even more}
3623 % \begin{macrocode}
3624 \g@addto@macro\EQ_typeset_display_hook:{
3625 \MH_let:NwN\ltx@label\MT_gobblelabel:w
3626 \MH_let:NwN \GenericError \@gobblefour
3627 }
3628 % \end{macrode}
3629 % \subsection{Support for \pkg{fancybox}}
3630 % First check if \pkg{fancybox} is loaded and then see if
3631 % \pkg{color} is loaded. If the latter is loaded we define
3632 % \texttt{shadowcolor} else we let \cs{textcolor} gobble the first
3633 % argument (the color).
3634 % \begin{macrocode}
3635 \AtBeginDocument{%
3636 \@ifpackageloaded{fancybox}{%
3637 \@ifpackageloaded{color}{\definecolor{shadowcolor}{rgb}{0,0,0}}%
3638 {\newcommand*\textcolor[2]{\normalcolor{#2}}}%
3639 % \end{macrocode}
3640 % \begin{macro}{\shadowbox}
3641 % Then define the \cs{shadowbox}. Use a conditional to let us know if
3642 % it was starred or not.
3643 % \begin{macrocode}
3644 \MH_new_boolean:n {shadowbox_star}
3645 \renewcommand*\shadowbox{%
3646 \@ifstar{\MH_set_boolean_T:n {shadowbox_star}
3647 \VerbBox\EQ_shadowbox:n}
3648 {\MH_set_boolean_F:n {shadowbox_star}
3649 \VerbBox\EQ_shadowbox:n}}
3650 % \end{macrocode}
3651 % \end{macro}
3652 % \begin{macro}{\EQ_shadowbox:n}
3653 % The internal version of \cs{shadowbox}.
3654 % \begin{macrocode}
3655 \def\EQ_shadowbox:n #1{%
3656 \sbox{\z@}{\fbox{#1}}%
3657 % \end{macrocode}
3658 % The difference between the two versions is that \cs{shadowbox}
3659 % aligns the bottom of the shadow at the baseline whereas
3660 % \cs{shadowbox*} aligns the argument on the baseline, so for the
3661 % starred version the trick is to raise the box by the depth of the
3662 % argument plus the size of the shadow.
3663 % \begin{macrocode}
3664 \MH_if_boolean:nTF {shadowbox_star}{
3665 \MH_setlength:dn \@tempdima{\z@}%
3666 }{
3667 \MH_setlength:dn \@tempdima{\dp\z@+\shadowsize}%
3668 }
3669 \raisebox{\@tempdima}{%
3670 \makebox[\z@][l]{%
3671 \kern\shadowsize \textcolor{shadowcolor}{%
3672 \rule[-\dp\z@-\shadowsize]{\wd\z@}{\shadowsize}}%
3673 }%
3674 \usebox\z@\textcolor{shadowcolor}{%
3675 \rule[-\dp\z@-\shadowsize]{\shadowsize}{\ht\z@+\dp\z@}}}}%
3676 }{}%
3677 }
3678 % \end{macrocode}
3679 % \end{macro}
3680 %
3681 %
3682 % \subsection{Adjusting for \cls{amsart} and \cls{amsbook}}
3683 % \label{sec:adjust-clsams-clsams}
3684 %
3685 % As mentioned earlier the \AmS{} classes \cls{amsart} and
3686 % \cls{amsbook} explicitly sets \cs{displaywidth} to
3687 % \cs{columnwidth}. The main reason for this (1) they use equation
3688 % numbers on the left and (2) if an equation is inside a list, they
3689 % still want the equation to use the full width (the standard classes
3690 % under \opt{leqno} will have their equation number indented to match
3691 % the effective line width/indentation).
3692 %
3693 % Why is problematic for us? Firstly, this messes up our trick to
3694 % separate the tags (equation numbers) from the display (as we need
3695 % the construction to follow our \emph{very large} line
3696 % width). Secondly this messes up the calculations of \cs{alignsep@},
3697 % since we can no longer assume that \cs{alignsep@} was calculated
3698 % against the with of the box we wanted. Here is an example that
3699 % \begin{verbatim}
3700 % \makeatletter
3701 % \begingroup
3702 % \fbox{\parbox{0.5\textwidth}{%
3703 % \def\maketag@@@#1{\kern1sp\vphantom{#1}}%
3704 % \begin{align}
3705 % align &= align & align &= align \\ &= align
3706 % \end{align}}}
3707 % \par\noindent
3708 % \def\fullwidthdisplay{\displayindent\z@ \displaywidth\columnwidth}
3709 % \edef\@tempa{\noexpand\fullwidthdisplay\the\everydisplay}
3710 % \everydisplay\expandafter{\@tempa}
3711 % \fbox{\parbox{0.5\textwidth}{%
3712 % \def\maketag@@@#1{\kern1sp\vphantom{#1}}%
3713 % \begin{align}
3714 % align &= align & align &= align \\ &= align
3715 % \end{align}}\vspace{-2\baselineskip}}
3716 % \endgroup
3717 % \makeatletter
3718 % \end{verbatim}
3719 % \makeatletter
3720 % \begingroup^^A
3721 % \fboxsep=2pt
3722 % \abovedisplayskip0pt
3723 % \belowdisplayskip0pt
3724 % \abovedisplayshortskip0pt
3725 % \belowdisplayshortskip0pt
3726 % \fbox{\parbox{0.5\textwidth}{%
3727 % \def\maketag@@@#1{\kern1sp\vphantom{#1}}%
3728 % \begin{align}
3729 % align &= align & align &= align \\ &= align
3730 % \end{align}}}
3731 % \par\noindent
3732 % \def\fullwidthdisplay{\displayindent\z@ \displaywidth\columnwidth}^^A
3733 % \edef\@tempa{\noexpand\fullwidthdisplay\the\everydisplay}^^A
3734 % \everydisplay\expandafter{\@tempa}^^A
3735 % \fbox{\parbox{0.5\textwidth}{%
3736 % \def\maketag@@@#1{\kern1sp\vphantom{#1}}%
3737 % \begin{align}
3738 % align &= align & align &= align \\ &= align
3739 % \end{align}}\vspace{-2\baselineskip}}
3740 % \endgroup
3741 % \makeatletter
3742 % \par\medskip\noindent
3743 % It is pretty obvious that the space between the two alignment
3744 % columns are wrong. Like when we handled the tag separation, one
3745 % solution could be to explicitly set \cs{columnwidth} to be the
3746 % effective line width. Alternatively we could redefine
3747 % \cs{fullwidthdisplay} to do nothing. The latter is probably the
3748 % less severe.
3749 % \begin{macrocode}
3750 \g@addto@macro\EQ_typeset_display_hook:{
3751 % \columnwidth\linewidth
3752 \def\fullwidthdisplay{}
3753 }
3754 % \end{macrocode}
3755 %
3756 %
3757 % \section{The \opt{overload} option}
3758 % \begin{macro}{\EQ_overload_ams_begin:n}
3759 % A helper for saving snapshots:
3760 % \begin{macrocode}
3761 \def\EQ_overload_ams_begin:n #1{%
3762 \MH_let:cc {AmS#1}{#1}%
3763 \MH_let:cc {AmS#1*}{#1*}
3764 }
3765 % \end{macrocode}
3766 % \end{macro}
3767 % \begin{macro}{\EQ_overload_ams_end:n}
3768 % All but one of the aligned variations must be set to the original
3769 % \begin{macrocode}
3770 \def\EQ_overload_ams_end:n #1{%
3771 \MH_let:cc {endAmS#1}{endAmSalign}
3772 }
3773 % \end{macrocode}
3774 % \end{macro}
3775 % \begin{environment}{AmSequation}
3776 % \begin{environment}{AmSequation*}
3777 % \changes{v2.10}{2004/07/26}{Moved redefinitions to
3778 % \cs{AtBeginDocument} to give \pkg{hyperref} a chance}
3779 % Before we start redefining environments, we'll need a basic
3780 % \env{equation} environment that is not redefined.
3781 % \begin{macrocode}
3782 \AtBeginDocument{
3783 \EQ_overload_ams_begin:n {equation}
3784 \MH_let:cc {endAmSequation}{endequation}
3785 \MH_let:cc {endAmSequation*}{endequation*}
3786 % \end{macrocode}
3787 % \end{environment}
3788 % \end{environment}
3789 % Lets start overloading.
3790 % \begin{macrocode}
3791 \MH_if_boolean:nT {overload_ams}{
3792 % \end{macrocode}
3793 % \begin{macro}{\EQ_renew_ams_environment:n}
3794 % \changes{v2.10}{2004/07/26}{Disallow spaces before the optional
3795 % argument.}
3796 % Then we can renew the environments. Syntax is
3797 % \cs{begin}\marg{\AmS{} env}\oarg{markup}. Exception to this rule
3798 % is \env{alignat} (see further down).
3799 % \begin{macrocode}
3800 \def\EQ_renew_ams_environment:n #1{%
3801 \MaybeMHPrecedingSpacesOff
3802 \renewenvironment{#1}[1][]{%
3803 % \end{macrocode}
3804 % \changes{v2.13}{2013/02/11}{Adding \cs{eqref} fix}
3805 % Remember to add \cs{eqref} fix to the overloaded envs as well.
3806 % \begin{macrocode}
3807 \MH_let:NwN\EQ_saved_maketag: \maketag@@@%
3808 \renewcommand\eqref[1]{\empheqeqrefbase{%
3809 \let\maketag@@@\EQ_saved_maketag:%
3810 \tagform@{\ref{####1}}}}
3811 \setkeys{\EQ_options_name:}{##1}%
3812 \setkeys{EmphEqEnv}{AmS#1}%
3813 \EmphEqMainEnv
3814 }{\endEmphEqMainEnv}
3815 \MHPrecedingSpacesOn
3816 }
3817 % \end{macrocode}
3818 % \end{macro}
3819 % Add equation type: \emph{Must} have same number as original type!
3820 % \begin{macrocode}
3821 \EQ_new_equationtype:nnn {EmphEqEnv}{AmSalign} {1}
3822 \EQ_new_equationtype:nnn {EmphEqEnv}{AmSalign*} {2}
3823 \EQ_new_equationtype:nnn {EmphEqEnv}{AmSgather} {3}
3824 \EQ_new_equationtype:nnn {EmphEqEnv}{AmSgather*} {4}
3825 \EQ_new_equationtype:nnn {EmphEqEnv}{AmSflalign} {5}
3826 \EQ_new_equationtype:nnn {EmphEqEnv}{AmSflalign*}{6}
3827 \EQ_new_equationtype_arg:nnn {EmphEqEnv}{AmSalignat} {7}
3828 \EQ_new_equationtype_arg:nnn {EmphEqEnv}{AmSalignat*}{8}
3829 % \end{macrocode}
3830 % Then overload by saving the snapshots of the old definitions. We
3831 % do it via \cs{AtBeginDocument}, because a package like
3832 % \pkg{ntheorem} redefines \cs{endgather} etc.
3833 %
3834 % First the \env{gather} and \env{equation} families.
3835 % \begin{macrocode}
3836 \EQ_overload_ams_begin:n {gather}
3837 \MH_let:cc {endAmSgather}{endgather}
3838 \MH_let:cc {endAmSgather*}{endAmSgather}
3839 \EQ_renew_ams_environment:n {gather}
3840 \EQ_renew_ams_environment:n {gather*}
3841 \EQ_overload_ams_begin:n {equation}
3842 \MH_keyval_alias_with_addon:nnnn {EmphEqEnv} {AmSequation}
3843 {AmSgather}{\EQ_disable_linebreak:}
3844 \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{AmSequation*}
3845 {AmSgather*}{\EQ_disable_linebreak:}
3846 \EQ_renew_ams_environment:n {equation}
3847 \EQ_renew_ams_environment:n {equation*}
3848 % \end{macrocode}
3849 % The \env{align} family.
3850 % \begin{macrocode}
3851 \EQ_overload_ams_begin:n {align}
3852 \MH_let:cc {endAmSalign}{endalign}
3853 \EQ_overload_ams_end:n {align*}
3854 \EQ_renew_ams_environment:n {align}
3855 \EQ_renew_ams_environment:n {align*}
3856 % \end{macrocode}
3857 % The \env{flalign} family.
3858 % \begin{macrocode}
3859 \EQ_overload_ams_begin:n {flalign}
3860 \EQ_overload_ams_end:n {flalign}
3861 \EQ_overload_ams_end:n {flalign*}
3862 \EQ_renew_ams_environment:n {flalign}
3863 \EQ_renew_ams_environment:n {flalign*}
3864 % \end{macrocode}
3865 % The \env{alignat} family.
3866 % \begin{macrocode}
3867 \EQ_overload_ams_begin:n {alignat}
3868 \EQ_overload_ams_end:n {alignat}
3869 \EQ_overload_ams_end:n {alignat*}
3870 % \end{macrocode}
3871 % \begin{macro}{\EQ_alignat_optional:w}
3872 % \changes{v2.10}{2004/07/26}{Disallow spaces before the optional
3873 % argument.}
3874 % \begin{environment}{alignat}
3875 % \begin{environment}{alignat*}
3876 % This one is a little different because we want a syntax like
3877 % \cs{begin\{alignat\}}\linebreak[0]\marg{cols}\oarg{markup}, so we
3878 % have to make a separate command for testing the trailing optional
3879 % argument.
3880 % \begin{macrocode}
3881 \MaybeMHPrecedingSpacesOff
3882 \newcommand*\EQ_alignat_optional:w [1][]{
3883 \setkeys{\EQ_options_name:}{#1}
3884 \EmphEqMainEnv}
3885 \MHPrecedingSpacesOn
3886 % \end{macrocode}
3887 % \changes{v2.13}{2013/02/11}{Adding \cs{eqref} fix}
3888 % Remember to add \cs{eqref} fix to the overloaded envs as well.
3889 % \begin{macrocode}
3890 \renewenvironment{alignat}[1]{
3891 \MH_let:NwN\EQ_saved_maketag: \maketag@@@%
3892 \renewcommand\eqref[1]{\empheqeqrefbase{%
3893 \let\maketag@@@\EQ_saved_maketag:%
3894 \tagform@{\ref{##1}}}}
3895 \setkeys{EmphEqEnv}{AmSalignat=#1}
3896 \EQ_alignat_optional:w}
3897 {\endEmphEqMainEnv}
3898 \renewenvironment{alignat*}[1]{%
3899 \MH_let:NwN\EQ_saved_maketag: \maketag@@@%
3900 \renewcommand\eqref[1]{\empheqeqrefbase{%
3901 \let\maketag@@@\EQ_saved_maketag:%
3902 \tagform@{\ref{##1}}}}
3903 \setkeys{EmphEqEnv}{AmSalignat*=#1}%
3904 \EQ_alignat_optional:w}%
3905 {\endEmphEqMainEnv}
3906 % \end{macrocode}
3907 % \end{environment}
3908 % \end{environment}
3909 % \end{macro}
3910 % \begin{macro}{\[}
3911 % \begin{macro}{\]}
3912 % Then restore \cs{[} and \cs{]}.
3913 % \begin{macrocode}
3914 \DeclareRobustCommand{\[}{\begin{AmSequation*}}
3915 \DeclareRobustCommand{\]}{\end{AmSequation*}}
3916 % \end{macrocode}
3917 % \end{macro}
3918 % \end{macro}
3919 % Finally a string of aliases so that we can blend \opt{overload}
3920 % syntax with regular syntax.
3921 % \begin{macrocode}
3922 \MH_keyval_alias:nnn {EmphEqEnv}{gather} {AmSgather}
3923 \MH_keyval_alias:nnn {EmphEqEnv}{gather*} {AmSgather*}
3924 \MH_keyval_alias:nnn {EmphEqEnv}{align} {AmSalign}
3925 \MH_keyval_alias:nnn {EmphEqEnv}{align*} {AmSalign*}
3926 \MH_keyval_alias:nnn {EmphEqEnv}{flalign} {AmSflalign}
3927 \MH_keyval_alias:nnn {EmphEqEnv}{flalign*}{AmSflalign*}
3928 \MH_keyval_alias:nnn {EmphEqEnv}{alignat} {AmSalignat}
3929 \MH_keyval_alias:nnn {EmphEqEnv}{alignat*}{AmSalignat*}
3930 \MH_if_boolean:nT {good_mult}{
3931 \EQ_overload_ams_begin:n {multline}
3932 \MH_let:cc {endAmSmultline}{endmultline}
3933 \MH_let:cc {endAmSmultline*}{endAmSmultline}
3934 \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{AmSmultline}
3935 {AmSgather}{\MH_set_boolean_T:n {outer_mult}}
3936 \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{AmSmultline*}
3937 {AmSgather*}{\MH_set_boolean_T:n {outer_mult}}
3938 \EQ_renew_ams_environment:n {multline}
3939 \EQ_renew_ams_environment:n {multline*}
3940 }
3941 % \end{macrocode}
3942 % End of \opt{overload}. We go into \opt{overload2}\ldots This
3943 % is dangerous, but will probably work. The macro \cs{[} is now
3944 % fragile except if you're running \eTeX{} as engine for \LaTeX.
3945 % \begin{macrocode}
3946 \MH_if_boolean:nT {overload_amsII}{
3947 \MH_protected:\def\[#1\]{\begin{equation*} #1\end{equation*}}
3948 % \end{macrocode}
3949 % Then we add the \env{multline} family.
3950 % \begin{macrocode}
3951 \MH_if_boolean:nF {good_mult}{
3952 \EQ_overload_ams_begin:n {multline}
3953 \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{AmSmultline}
3954 {AmSflalign}{\MH_set_boolean_T:n {multline}}
3955 \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{AmSmultline*}
3956 {AmSflalign*}{\MH_set_boolean_T:n {multline}}
3957 \EQ_renew_ams_environment:n {multline}
3958 \EQ_renew_ams_environment:n {multline*}
3959 }
3960 }
3961 }
3962 }
3963 % \end{macrocode}
3964 % End of \cs{AtBeginDocument} additions.
3965 %
3966 % If we need to load \pkg{ntheorem} support this is where it
3967 % happens. Otherwise we just stop here.
3968 % \begin{macrocode}
3969 \if\g@EQ@ntheorem@support@bool
3970 \else
3971 \expandafter\endinput
3972 \fi
3973 % \end{macrocode}
3974 %
3975 % \section{Patching Things up for \pkg{ntheorem}}
3976 % \label{sec:impl:ntheorem}
3977 %
3978 % Although \pkg{ntheorem} provides a lot of useful features it
3979 % does however ruin things in the \pkg{amsmath} environments,
3980 % because of the alternative syntax of its \cs{label} command.
3981 % \begin{macro}{\EQ_default_raisetag}
3982 % \begin{macro}{\raisetag}
3983 % \begin{macro}{\raise@tag}
3984 % \changes{v1.06}{2004/03/13}{Fixed \pkg{amsmath} bug \# 3624}
3985 % This corrects a bug\footnote{See
3986 % \url{http://www.latex-project.org/cgi-bin/ltxbugs2html?pr=amslatex/3624}}
3987 % in \pkg{amsmath} that could cause tags to cross page boundaries
3988 % without warning. The \cs{nobreak} is the addition.
3989 % \changes{v2.15}{2017/03/31}{added MH\_ prefix}
3990 % \changes{v2.15}{2017/03/31}{added EQ\_ prefix}
3991 % \begin{macrocode}
3992 \def\EQ_default_raisetag:{\nobreak}
3993 \def\raisetag#1{
3994 \skip@#1\relax
3995 \xdef\raise@tag{\EQ_default_raisetag:
3996 \vskip\iftagsleft@\MH_else:-\MH_fi:\the\skip@\relax}}
3997 \MH_let:NwN\raise@tag\EQ_default_raisetag:
3998 % \end{macrocode}
3999 % \end{macro}
4000 % \end{macro}
4001 % \end{macro}
4002 % \begin{macro}{\displ@y@}
4003 % Patch it so that it doesn't set \cs{raise@tag} to \cs{@empty}
4004 % globally.
4005 % \changes{v2.15}{2017/03/31}{added EQ\_ prefix}
4006 % \begin{macrocode}
4007 \def\displ@y@{\@display@init{%
4008 \global\column@\z@ \global\dspbrk@lvl\m@ne
4009 \global\tag@false \global\MH_let:NwN\raise@tag\EQ_default_raisetag:
4010 }}
4011 % \end{macrocode}
4012 % \end{macro}
4013 % \begin{macro}{\MT_gobblelabel:w}
4014 % \changes{v2.00}{2004/04/14}{Added \cs{MT_gobblelabel:w}}
4015 % \begin{macro}{\EQ_gobbleoptional:w}
4016 % \changes{v2.00}{2004/04/14}{Added \cs{EQ_gobbleoptional:w}}
4017 % Macros for gobbling the `unorthodox' \cs{label} syntax of
4018 % \pkg{ntheorem}. Also overrides the normal \cs{label}-gobbling.
4019 % \begin{macrocode}
4020 \def\MT_gobblelabel:w #1{\@ifnextchar[{\EQ_gobbleoptional:w}{}}
4021 \def\EQ_gobbleoptional:w [#1]{}
4022 % \end{macrocode}
4023 % \end{macro}
4024 % \end{macro}
4025 % \subsection{Fixing \env{gather}}
4026 % The measuring phase of \env{gather} is patched by letting
4027 % \cs{label} be a copy of the internal \cs{MT_gobblelabel:w}
4028 % instead of \cs{@gobble}.
4029 % \begin{macrocode}
4030 \def\gmeasure@#1{%
4031 \begingroup
4032 \measuring@true
4033 \totwidth@\z@
4034 \global\MH_let:NwN\tag@lengths\@empty
4035 \savecounters@
4036 \setbox\@ne\vbox{%
4037 \everycr{\noalign{\global\tag@false
4038 % \end{macrocode}
4039 % The patch for \cs{raisetag}.
4040 % \changes{v2.15}{2017/03/31}{added EQ\_ prefix}
4041 % \begin{macrocode}
4042 \global\MH_let:NwN\raise@tag\EQ_default_raisetag:
4043 \global\column@\z@}}%
4044 % \end{macrocode}
4045 % The patch for \cs{label}.
4046 % \changes{v2.15}{2017/03/31}{added MH\_ prefix}
4047 % \begin{macrocode}
4048 \MH_let:NwN\label\MT_gobblelabel:w
4049 \halign{%
4050 \setboxz@h{$\m@th\displaystyle{##}$}%
4051 \MH_if_dim:w \wdz@>\totwidth@
4052 \global\totwidth@\wdz@
4053 \MH_fi:
4054 &\setboxz@h{\strut@{##}}%
4055 \savetaglength@
4056 \crcr
4057 #1%
4058 \math@cr@@@
4059 }%
4060 }%
4061 \restorecounters@
4062 \if@fleqn
4063 \global\advance\totwidth@\@mathmargin
4064 \MH_fi:
4065 \iftagsleft@
4066 \MH_if_dim:w \totwidth@>\displaywidth
4067 \global\MH_let:NwN\gdisplaywidth@\totwidth@
4068 \MH_else:
4069 \global\MH_let:NwN\gdisplaywidth@\displaywidth
4070 \MH_fi:
4071 \MH_fi:
4072 \endgroup
4073 }
4074 % \end{macrocode}
4075 %
4076 % \subsection{Fixing \env{align}, \env{alignat}, and \env{flalign}}
4077 % Just copy the definition of \cs{measure@} from \pkg{amsmath} and
4078 % change one (1!) line like we did for \env{gather}.
4079 % \begin{macrocode}
4080 \def\measure@#1{%
4081 \begingroup
4082 \measuring@true
4083 \global\eqnshift@\z@
4084 \global\alignsep@\z@
4085 \global\MH_let:NwN\tag@lengths\@empty
4086 \global\MH_let:NwN\field@lengths\@empty
4087 \savecounters@
4088 \global\setbox0\vbox{%
4089 \MH_let:NwN\math@cr@@@\math@cr@@@align@measure
4090 \everycr{\noalign{\global\tag@false
4091 % \end{macrocode}
4092 % The patch for \cs{raisetag}.
4093 % \changes{v2.15}{2017/03/31}{added EQ\_ prefix}
4094 % \begin{macrocode}
4095 \global\MH_let:NwN\raise@tag\EQ_default_raisetag:
4096 \global\column@\z@}}%
4097 % \end{macrocode}
4098 % The patch.
4099 % \changes{v2.15}{2017/03/31}{added MH\_ prefix}
4100 % \begin{macrocode}
4101 \MH_let:NwN\label\MT_gobblelabel:w
4102 \global\row@\z@
4103 \tabskip\z@
4104 \halign{\span\align@preamble\crcr
4105 #1%
4106 \math@cr@@@
4107 \global\column@\z@
4108 \add@amps\maxfields@\cr
4109 }%
4110 }%
4111 \restorecounters@
4112 \ifodd\maxfields@
4113 \global\advance\maxfields@\@ne
4114 \MH_fi:
4115 \MH_if_num:w \xatlevel@=\tw@
4116 \MH_if_num:w \maxfields@<\thr@@
4117 \MH_let:NwN\xatlevel@\z@
4118 \MH_fi:
4119 \MH_fi:
4120 \setbox\z@\vbox{%
4121 \unvbox\z@ \unpenalty \global\setbox\@ne\lastbox
4122 }%
4123 \global\totwidth@\wd\@ne
4124 \if@fleqn \global\advance\totwidth@\@mathmargin \MH_fi:
4125 \global\MH_let:NwN\maxcolumn@widths\@empty
4126 \begingroup
4127 \MH_let:NwN\MH_or:\relax
4128 \loop
4129 \global\setbox\@ne\hbox{%
4130 \unhbox\@ne \unskip \global\setbox\thr@@\lastbox
4131 }%
4132 \ifhbox\thr@@
4133 \xdef\maxcolumn@widths{ \MH_or: \the\wd\thr@@ \maxcolumn@widths}%
4134 \repeat
4135 \endgroup
4136 \dimen@\displaywidth
4137 \advance\dimen@-\totwidth@
4138 \MH_if_case:w \xatlevel@
4139 \global\alignsep@\z@
4140 \MH_let:NwN\minalignsep\z@
4141 \@tempcntb\z@
4142 \if@fleqn
4143 \@tempcnta\@ne
4144 \global\eqnshift@\@mathmargin
4145 \MH_else:
4146 \@tempcnta\tw@
4147 \global\eqnshift@\dimen@
4148 \global\divide\eqnshift@\@tempcnta
4149 \MH_fi:
4150 \MH_or:
4151 \@tempcntb\maxfields@
4152 \divide\@tempcntb\tw@
4153 \@tempcnta\@tempcntb
4154 \advance\@tempcntb\m@ne
4155 \if@fleqn
4156 \global\eqnshift@\@mathmargin
4157 \global\alignsep@\dimen@
4158 \global\divide\alignsep@\@tempcnta
4159 \MH_else:
4160 \global\advance\@tempcnta\@ne
4161 \global\eqnshift@\dimen@
4162 \global\divide\eqnshift@\@tempcnta
4163 \global\alignsep@\eqnshift@
4164 \MH_fi:
4165 \MH_or:
4166 \@tempcntb\maxfields@
4167 \divide\@tempcntb\tw@
4168 \global\advance\@tempcntb\m@ne
4169 \global\@tempcnta\@tempcntb
4170 \global\eqnshift@\z@
4171 \global\alignsep@\dimen@
4172 \if@fleqn
4173 \global\advance\alignsep@\@mathmargin\relax
4174 \MH_fi:
4175 \global\divide\alignsep@\@tempcntb
4176 \MH_fi:
4177 \MH_if_dim:w \alignsep@<\minalignsep\relax
4178 \global\alignsep@\minalignsep\relax
4179 \MH_if_dim:w \eqnshift@>\z@
4180 \if@fleqn\MH_else:
4181 \global\eqnshift@\displaywidth
4182 \global\advance\eqnshift@-\totwidth@
4183 \global\advance\eqnshift@-\@tempcntb\alignsep@
4184 \global\divide\eqnshift@\tw@
4185 \MH_fi:
4186 \MH_fi:
4187 \MH_fi:
4188 \MH_if_dim:w \eqnshift@<\z@
4189 \global\eqnshift@\z@
4190 \MH_fi:
4191 \calc@shift@align
4192 \global\tagshift@\totwidth@
4193 \global\advance\tagshift@\@tempcntb\alignsep@
4194 \if@fleqn
4195 \MH_if_num:w \xatlevel@=\tw@
4196 \global\advance\tagshift@-\@mathmargin\relax
4197 \MH_fi:
4198 \MH_else:
4199 \global\advance\tagshift@\eqnshift@
4200 \MH_fi:
4201 \iftagsleft@ \MH_else:
4202 \global\advance\tagshift@-\displaywidth
4203 \MH_fi:
4204 \dimen@\minalignsep\relax
4205 \global\advance\totwidth@\@tempcntb\dimen@
4206 \MH_if_dim:w \totwidth@>\displaywidth
4207 \global\MH_let:NwN\displaywidth@\totwidth@
4208 \MH_else:
4209 \global\MH_let:NwN\displaywidth@\displaywidth
4210 \MH_fi:
4211 \endgroup
4212 }
4213 % \end{macrocode}
4214 %
4215 % \subsection{Fixing \env{multline}}
4216 % \begin{macro}{\EQ_multline_labelhack:n}
4217 % \begin{macro}{\EQ_multline_labelhack_opt:nw}
4218 % As \pkg{ntheorem} defines \cs{label} to have the syntax
4219 % \cs{label}\marg{label}\oarg{name}, we need to make sure that it
4220 % has that inside \env{multline} as well. Especially since the
4221 % measuring phase of \env{multline} \emph{defines} \cs{label} as
4222 % well.
4223 % \begin{macrocode}
4224 \def\EQ_multline_labelhack:n #1{%
4225 \begingroup\measuring@false\label@in@display{#1}\endgroup}
4226 \def\EQ_multline_labelhack_opt:nw #1[#2]{%
4227 \begingroup\measuring@false\label@in@display{#1}[#2]\endgroup}
4228 % \end{macrocode}
4229 % \end{macro}
4230 % \end{macro}
4231 % \begin{macro}{\multline@}
4232 % Patching \env{multline} takes more work because it does its
4233 % processing differently, so we need to apply hooks twice: One in
4234 % the measuring phase \cs{mmeasure@} where \cs{label} is redefined
4235 % and one in the production phase \cs{multline@} where the ordinary
4236 % \cs{label} is gobbled (we use \cs{MT_gobblelabel:w} as
4237 % before). First the typesetting phase.
4238 % \begin{macrocode}
4239 \def\multline@#1{%
4240 \Let@
4241 \@display@init{\global\advance\row@\@ne \global\dspbrk@lvl\m@ne}%
4242 \chardef\dspbrk@context\z@
4243 \restore@math@cr
4244 \MH_let:NwN\tag\tag@in@align
4245 % \end{macrocode}
4246 % The patch for \cs{raisetag}.
4247 % \changes{v2.15}{2017/03/31}{added EQ\_ prefix}
4248 % \begin{macrocode}
4249 \global\tag@false \global\MH_let:NwN\raise@tag\EQ_default_raisetag:
4250 \mmeasure@{#1}%
4251 \MH_let:NwN\tag\gobble@tag
4252 % \end{macrocode}
4253 % The patch.
4254 % \changes{v2.15}{2017/03/31}{added MH\_ prefixes}
4255 % \begin{macrocode}
4256 \MH_let:NwN\label\MT_gobblelabel:w
4257 \tabskip \if@fleqn \@mathmargin \MH_else: \z@skip \MH_fi:
4258 \totwidth@\displaywidth
4259 \if@fleqn
4260 \advance\totwidth@-\@mathmargin
4261 \MH_fi:
4262 \halign\bgroup
4263 \hbox to\totwidth@{%
4264 \if@fleqn
4265 \hskip \@centering \relax
4266 \MH_else:
4267 \hfil
4268 \MH_fi:
4269 \strut@
4270 $\m@th\displaystyle{}##\endmultline@math%$
4271 \hfil
4272 }%
4273 \crcr
4274 \if@fleqn
4275 \hskip-\@mathmargin
4276 \def\multline@indent{\hskip\@mathmargin}% put it back
4277 \MH_else:
4278 \hfilneg
4279 \def\multline@indent{\hskip\multlinegap}%
4280 \MH_fi:
4281 \iftagsleft@
4282 \iftag@
4283 \begingroup
4284 \ifshifttag@
4285 \rlap{\vbox{%
4286 \normalbaselines
4287 \hbox{%
4288 \strut@
4289 \make@display@tag
4290 }%
4291 \vbox to\lineht@{}%
4292 \raise@tag
4293 }}%
4294 \multline@indent
4295 \MH_else:
4296 \setbox\z@\hbox{\make@display@tag}%
4297 \dimen@\@mathmargin \advance\dimen@-\wd\z@
4298 \MH_if_dim:w \dimen@<\multlinetaggap
4299 \dimen@\multlinetaggap
4300 \MH_fi:
4301 \box\z@ \hskip\dimen@\relax
4302 \MH_fi:
4303 \endgroup
4304 \MH_else:
4305 \multline@indent
4306 \MH_fi:
4307 \MH_else:
4308 \multline@indent
4309 \MH_fi:
4310 #1%
4311 }
4312 % \end{macrocode}
4313 % \end{macro}
4314 % \begin{macro}{\mmeasure@}
4315 % Then redefine the label correctly.
4316 % \begin{macrocode}
4317 \def\mmeasure@#1{%
4318 \begingroup
4319 \measuring@true
4320 % \end{macrocode}
4321 % The patch.
4322 % \changes{v2.15}{2017/03/31}{added MH\_ prefixes}
4323 % \begin{macrocode}
4324 \def\label##1{%
4325 \@ifnextchar[
4326 {\EQ_multline_labelhack_opt:nw {##1}}
4327 {\EQ_multline_labelhack:n {##1}}
4328 }
4329 \def\math@cr@@@{\cr}%
4330 \MH_let:NwN\shoveleft\@iden \MH_let:NwN\shoveright\@iden
4331 \savecounters@
4332 \global\row@\z@
4333 \setbox\@ne\vbox{%
4334 \global\MH_let:NwN\df@tag\@empty
4335 \halign{%
4336 \setboxz@h{\@lign$\m@th\displaystyle{}##$}%
4337 \iftagsleft@
4338 \MH_if_num:w \row@=\@ne
4339 \global\totwidth@\wdz@
4340 \global\lineht@\ht\z@
4341 \MH_fi:
4342 \MH_else:
4343 \global\totwidth@\wdz@
4344 \global\lineht@\dp\z@
4345 \MH_fi:
4346 \crcr
4347 #1%
4348 \crcr
4349 }%
4350 }%
4351 \MH_if_meaning:NN
4352 \df@tag\@empty
4353 \MH_else:
4354 \global\tag@true
4355 \MH_fi:
4356 \if@eqnsw\global\tag@true\MH_fi:
4357 \iftag@
4358 \setboxz@h{%
4359 \if@eqnsw
4360 \stepcounter{equation}%
4361 \tagform@\theequation
4362 \MH_else:
4363 \df@tag
4364 \MH_fi:
4365 }%
4366 \global\tagwidth@\wdz@
4367 \dimen@\totwidth@
4368 \advance\dimen@\tagwidth@
4369 \advance\dimen@\multlinetaggap
4370 \iftagsleft@\MH_else:
4371 \if@fleqn
4372 \advance\dimen@\@mathmargin
4373 \MH_fi:
4374 \MH_fi:
4375 \MH_if_dim:w \dimen@>\displaywidth
4376 \global\shifttag@true
4377 \MH_else:
4378 \global\shifttag@false
4379 \MH_fi:
4380 \MH_fi:
4381 \restorecounters@
4382 \endgroup
4383 }
4384 % \end{macrocode}
4385 % \end{macro}
4386 %
4387 % \subsection{Setting End Marks Correctly}
4388 %
4389 % \begin{macro}{\mintagvsep}
4390 % \changes{v1.05}{2004/02/16}{Introduced \cs{mintagvsep} to
4391 % support the \pkg{ntheorem} package}
4392 % \begin{macro}{\EQ_only_endmark:}
4393 % \changes{v1.05}{2004/02/16}{Introduced \cs{EQ_only_endmark:}
4394 % to support the \pkg{ntheorem} package}
4395 % \changes{v2.11}{2004/08/03}{Make sure the tag is printed even with the
4396 % \pkg{mathtools} key \key{showonlyrefs} activated}
4397 % \begin{macro}{\EQ_tag_plus_endmark:}
4398 % \changes{v1.05}{2004/02/16}{Introduced
4399 % \cs{EQ_tag_plus_endmark:} to support the \pkg{ntheorem} package}
4400 % \pkg{ntheorem} provides an extension to the theorem environment
4401 % and also supports automatic end of theorem marks. To do so it must
4402 % redefine parts of the \pkg{amsmath} code and it eventually ends up
4403 % in problems when the tags and the marker are all typeset at the
4404 % right margin.
4405 %
4406 % There are basically two different possibilities:
4407 % \begin{center}\hfill
4408 % \unitlength2.5pt \thicklines
4409 % \begin{picture}(60,45)(0,25)
4410 % \put(0,50){\framebox(25,20){Math Height}}
4411 % \put(0,25){\framebox(25,25){Math Depth}}
4412 % \put(40,50){\framebox(20,10){Tag height}}
4413 % \put(40,45){\framebox(20,5){Tag depth}}
4414 % \put(40,25){\framebox(20,10){Marker}}
4415 % \put(50,35){\vector(0,1){10}}
4416 % \put(50,45){\vector(0,-1){10}}
4417 % \put(50,39){\ \ $\delta>0$}
4418 % \multiput(26,25)(2,0){7}{\line(1,0){1}}
4419 % \end{picture} \hfill\vrule\hfill
4420 % \begin{picture}(60,45)(0,25)
4421 % \put(0,50){\framebox(25,20){Math Height}}
4422 % \put(0,40){\framebox(25,10){Math Depth}}
4423 % \put(40,50){\framebox(20,10){Tag height}}
4424 % \put(40,45){\framebox(20,5){Tag depth}}
4425 % \put(40,28){\framebox(20,10){Marker}}
4426 % \put(50,38){\vector(0,1){7}}
4427 % \put(50,45){\vector(0,-1){7}}
4428 % \put(50,40){\ \ $\delta=0$}
4429 % \end{picture}\hfill\mbox{}
4430 % \end{center}
4431 % Let's look closer at this. $h_M$ is the height of the end of
4432 % theorem marker, which we'll try to place so that its baseline
4433 % aligns with the bottom of the math display. $d_D$ is the depth of
4434 % the the last line of the math display including the depth of the
4435 % surrounding boxes while $d_T$ is the depth of the tag. Also we let
4436 % $m$ denote the minimum vertical distance between tag and marker
4437 % and $\delta$ is some positive length that may be added to $m$
4438 % depending on the other values. To ensure a ``proper'' placement of
4439 % the marker we simply test the inequality
4440 % \begin{gather}
4441 % h_M + d_T + m > d_D \label{eq:tag_placement}
4442 % \end{gather}
4443 % If the test is true we're done and just have to set the marker so
4444 % that the top of it is placed at a distance of $m$ from the bottom
4445 % of the tag. If it's not we can safely put the marker at the bottom
4446 % of the display.
4447 % \begin{macrocode}
4448 \newlength\mintagvsep
4449 \mintagvsep5pt
4450 \def\EQ_only_endmark:{%
4451 \MH_set_boolean_T:n {show_manual_tags}
4452 \global\tag@true
4453 \iftagsleft@
4454 \gdef\df@tag{%
4455 \hbox to \displaywidth{%
4456 \hss
4457 % \end{macrocode}
4458 % If the tags are set to the left we just have to lower the end mark
4459 % by the total depth of the display including its surrounding box.
4460 % Also we have to take care of \cs{normallineskip}.
4461 % \changes{v2.15}{2017/03/31}{added MH\_ prefixes}
4462 % \begin{macrocode}
4463 \raisebox{-\normallineskip
4464 -\depthof{\EQ_outerbox:{}}
4465 -\heightof{\EQ_outerbox:{}}
4466 -\dp\EQ_mathdisplay_box
4467 -\ht\EQ_mathdisplay_box}
4468 [0pt][0pt]{\PotEndMark{\maketag@@@}}}}
4469 \MH_else:
4470 \gdef\df@tag{%
4471 \raisebox{-\dp\EQ_mathdisplay_box
4472 -\depthof{\EQ_outerbox:{}}}
4473 {\PotEndMark{\maketag@@@}}}%
4474 \MH_fi:}
4475 % \end{macrocode}
4476 % \changes{v2.00}{2004/04/14}{Fixed another bug in placement of the
4477 % marker}
4478 % \changes{v2.10}{2004/07/26}{Fixed horizontal spacing in \env{equation}}
4479 % In v2.00 I fixed another bug I had overlooked. This is getting
4480 % embarrassing. The outer box must be taken into account as well.
4481 % \begin{macrocode}
4482 \def\EQ_tag_plus_endmark:{%
4483 \iftagsleft@
4484 \gdef\maketag@@@##1{%
4485 % \end{macrocode}
4486 % The following fixes a bug when there is a wide tag in an
4487 % \env{equation} environment and was reported by Bernard
4488 % Alfonsi.\footnote{\email{[email protected]}} The problem
4489 % arises when \pkg{ntheorem} tries to typeset a tag and an end mark,
4490 % because the tag is set at the left margin and the end mark at the
4491 % right margin and \pkg{ntheorem} over-simplifies this and forgets
4492 % to take the displayed math into account! The right solution is to
4493 % wrap the tag in a box of the correct size, namely |\widthof{##1}|
4494 % and then push the end mark to the right margin. Then the displayed
4495 % math is set correcly.
4496 % \changes{v2.15}{2017/03/31}{added MH\_ prefixes}
4497 % \begin{macrocode}
4498 \hfuzz\displaywidth
4499 \makebox[\widthof{##1}][l]{%
4500 \hbox to \displaywidth{\m@th\normalfont##1\hss
4501 \raisebox{-\dp\EQ_mathdisplay_box
4502 -\depthof{\EQ_outerbox:{}}}
4503 {\PotEndMark{\hss}}}}}%
4504 \MH_else:
4505 \gdef\maketag@@@##1{%
4506 \hbox{\m@th\normalfont##1\llap{\hss\PotEndMark{%
4507 \settoheight{\@tempdima}{\@nameuse{\InTheoType Symbol}}%
4508 \MH_addtolength:dn \@tempdima
4509 {\g_EQ_bottomtag_depth_dim+\mintagvsep}
4510 \setlength{\@tempdimb}
4511 {\g_EQ_bottomrow_depth_dim+\depthof{\EQ_outerbox:{}}
4512 +\depthof{\EQ_innerbox:{}}}
4513 \MH_if_dim:w \@tempdima>\@tempdimb
4514 \MH_setlength:dn \@tempdima{-\dp\EQ_mathdisplay_box
4515 -\@tempdima+\g_EQ_bottomrow_depth_dim}
4516 \addtolength{\@tempdima}{\depthof{\EQ_innerbox:{}}}%
4517 \def\EQ_next:{\raisebox{\@tempdima}}%
4518 \MH_else:
4519 % \end{macrocode}
4520 % \changes{v1.06}{2004/03/13}{Fixed bug in placement of the marker
4521 % and re-arranged some code}
4522 % In v1.06 I fixed a stupid bug regarding placement of the marker.
4523 % If I had done a proper test I would have discovered it
4524 % immediately!
4525 % \changes{v2.15}{2017/03/31}{added MH\_ prefixes}
4526 % \begin{macrocode}
4527 \def\EQ_next:{
4528 \raisebox{-\dp\EQ_mathdisplay_box
4529 -\depthof{\EQ_outerbox:{}}}}%
4530 \MH_fi:\EQ_next:}}}}%
4531 \MH_fi:}
4532 % \end{macrocode}
4533 % \end{macro}
4534 % \end{macro}
4535 % \end{macro}
4536 %
4537 % \begin{macro}{\MT_nonumber:}
4538 % \begin{macrocode}
4539 \MH_let:NwN \MT_nonumber: \nonumber
4540 % \end{macrocode}
4541 % \end{macro}
4542 % \begin{macro}{\nonumber}
4543 % Redefine \cs{nonumber} to reset depth of bottom tag.
4544 % \changes{v2.15}{2017/03/31}{added MH\_ prefixes}
4545 % \begin{macrocode}
4546 \def\g_EQ_latest_nonzerodepth_row_fint{\z@}
4547 \renewcommand*\nonumber{
4548 \@tempcnta=\row@
4549 \MH_if_num:w \l_EQ_equationtype_int=\thr@@
4550 \advance\@tempcnta\m@ne
4551 \MH_else:
4552 \MH_if_num:w \l_EQ_equationtype_int=4\relax
4553 \advance\@tempcnta\m@ne
4554 \MH_fi:
4555 \MH_fi:
4556 \MH_if_num:w \g_EQ_latest_nonzerodepth_row_fint=\@tempcnta
4557 \MH_else:
4558 \global\g_EQ_bottomtag_depth_dim=-\baselineskip
4559 \MH_fi:
4560 \MT_nonumber:
4561 }
4562 % \end{macrocode}
4563 % \end{macro}
4564 %
4565 % End of \pkg{ntheorem} patches and package.
4566 % \begin{macrocode}
4567 %</package>
4568 % \end{macrocode}
4569 % \Finale
4570 \endinput