summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/mathtools/empheq.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2020-03-25 03:01:53 +0000
committerNorbert Preining <norbert@preining.info>2020-03-25 03:01:53 +0000
commite32477e40d853a81951c9811f8554455dbff4014 (patch)
tree12744b350742c71cbb3c768354084a5c50369ce7 /macros/latex/contrib/mathtools/empheq.dtx
parente9af7499b89170ca5c737240b0cdb9563dcf6c5a (diff)
CTAN sync 202003250301
Diffstat (limited to 'macros/latex/contrib/mathtools/empheq.dtx')
-rw-r--r--macros/latex/contrib/mathtools/empheq.dtx599
1 files changed, 404 insertions, 195 deletions
diff --git a/macros/latex/contrib/mathtools/empheq.dtx b/macros/latex/contrib/mathtools/empheq.dtx
index 45dace201f..7f4b76b8ae 100644
--- a/macros/latex/contrib/mathtools/empheq.dtx
+++ b/macros/latex/contrib/mathtools/empheq.dtx
@@ -1,7 +1,8 @@
% \iffalse meta-comment
%
% Copyright (C) 2002-2007 by Morten Hoegholm
-% Copyright (C) 2012 by Lars Madsen
+% Copyright (C) 2012-2019 by Lars Madsen
+% Copyright (C) 2020 by Lars Madsen, The LaTeX3 Project
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
@@ -14,7 +15,7 @@
% This work has the LPPL maintenance status "maintained".
%
% This Current Maintainer of this work is
-% Lars Madsen
+% Lars Madsen, The LaTeX3 Project
%
% This work consists of the main source file empheq.dtx
% and the derived files
@@ -68,7 +69,7 @@
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
-\Msg{* Package: empheq 2017/03/31 v2.15 empheq}
+\Msg{* Package: empheq 2020/03/24 v2.16 empheq}
\Msg{************************************************************************}
\keepsilent
@@ -79,7 +80,8 @@
This is a generated file.
Copyright (C) 2002-2007 by Morten Hoegholm
-Copyright (C) 2012- by Lars Madsen
+Copyright (C) 2012-2019 by Lars Madsen
+Copyright (C) 2020- by Lars Madsen, The LaTeX3 Project
This work may be distributed and/or modified under the
@@ -93,7 +95,7 @@ LaTeX version 2005/12/01 or later.
This work has the LPPL maintenance status "maintained".
This Current Maintainer of this work is
-Lars Madsen
+Lars Madsen, The LaTeX3 Project
This work consists of the main source file empheq.dtx
and the derived files
@@ -131,7 +133,7 @@ and the derived files
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{empheq.drv}%
- [2017/03/31 v2.15 Emphasizing equations]
+ [2020/03/24 v2.16 Emphasizing equations]
\documentclass{ltxdoc}
\usepackage{mathpazo}
\usepackage[overload]{empheq}
@@ -142,6 +144,7 @@ and the derived files
\hyphenation{emph-eq}
\makeatletter
\providecommand*\pkg[1]{\textsf{#1}}
+\providecommand*\cls[1]{\textsf{#1}}
\providecommand*\env[1]{\texttt{#1}}
\providecommand*\email[1]{\href{mailto:#1}{\texttt{#1}}}
\providecommand*\mode[1]{\texttt{[#1]}}
@@ -149,6 +152,17 @@ and the derived files
\addtolength\marginparwidth{-30pt}
+\newcommand\lineref[1]{
+ \begingroup
+ % \p@CodelineNo \normalfont \scriptsize 475
+ \let\p@CodelineNo\relax
+ \let\normalfont\relax
+ %\let\scriptsize\relax
+ \ref{#1}
+ \endgroup
+}
+
+
\newcommand*\AddDescribe[3]{%
\@namedef{Describe#1}{\leavevmode\@bsphack\begingroup\MakePrivateLetters
\@nameuse{Describe@#1}}
@@ -323,7 +337,8 @@ and the derived files
\DocInput{empheq.dtx}
\end{document}
%</driver>
-% \fi
+% \fi
+% \changes{v2.16}{2020/03/24}{fixed several bugs related to amsart/-book}
% \changes{v2.15}{2017/03/31}{Fixed a bug in relation to the AMS
% classes and completed prefixing macros belonging to \pkg{mhsetup}
% and \pkg{empheq}}
@@ -366,7 +381,7 @@ and the derived files
% \title{The \pkg{empheq} package\thanks{This file has version number
% \fileversion, last revised \filedate.}\\
% Emphasizing equations in \LaTeXe}
-% \author{Morten H\o gholm, Lars Madsen}
+% \author{Morten Hoegholm, Lars Madsen, The LaTeX3 Project}
%
% \date{\filedate}
%
@@ -1624,11 +1639,10 @@ and the derived files
% \section{Contact information}
%
% Should you have any feature request, suggestions, or bug reports
-% then feel free to contact Lars Madsen at
+% then feel free to open an issue at (it also covers \pkg{empheq})
% \begin{quote}
-% \email{daleif@math.au.dk}
+% \url{https://github.com/latex3/mathtools}
% \end{quote}
-% Please put `empheq' in the subject line.
%
% \subsection*{Contributors}
%
@@ -1874,6 +1888,7 @@ and the derived files
% \begin{macro}{\l_EQ_totalwidth_dim}
% \begin{macro}{\l_EQ_displaywidth_dim}
% \begin{macro}{\l_EQ_temp_linewidth_dim}
+% \begin{macro}{\l_EQ_linewidth_dim}
% \begin{macro}{\EmphEqdelimitershortfall}
% \begin{macro}{\EmphEqdelimiterfactor}
% \begin{macro}{\g_EQ_toptag_height_dim}
@@ -1889,9 +1904,13 @@ and the derived files
\newdimen\l_EQ_displaywidth_dim
% \end{macrocode}
% Just to make it accessible.
+% \changes{v2.16}{2020/03/23}{Added \cs{l_EQ_linewidth_dim} since due
+% to the \AmS\ classes being able to not rely on \cs{linewidth} can be
+% useful.}
% \begin{macrocode}
\def\EmphEqdisplaywidth{\l_EQ_displaywidth_dim}
\newdimen\l_EQ_temp_linewidth_dim
+\newdimen\l_EQ_linewidth_dim
\newdimen\EmphEqdelimitershortfall
\newcount\EmphEqdelimiterfactor
\EmphEqdelimiterfactor950
@@ -1913,6 +1932,7 @@ and the derived files
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% \begin{macro}{\EQ_outerbox:}
% \begin{macro}{\EQ_innerbox:}
@@ -2049,8 +2069,8 @@ and the derived files
\MH_else:
\setkeys{\MT_options_name:}{multlined-pos=t}
\MH_fi:
- \g@addto@macro\EQ_complete_mathdisplay:{
- \begin{MTmultlined}\relax}
+ \g@addto@macro\EQ_complete_mathdisplay:{
+ \begin{MTmultlined}\relax}
}
\g@addto@macro\EQ_complete_mathdisplay:\EQ_mathbody:
\MH_if_boolean:nT {outer_mult}{
@@ -2220,7 +2240,45 @@ and the derived files
% \begin{macrocode}
\MH_let:NwN\SetTagPlusEndMark\EQ_tag_plus_endmark:
\MH_let:NwN\SetOnlyEndMark\EQ_only_endmark:
+% \end{macrocode}
+% \changes{v2.16}{2020/03/19}{Added fix for amsart and amsbook}
+% \changes{v2.16}{2020/03/23}{Added additional length as it is useful
+% against amsart and friends}
+% \begin{macrocode}
\l_EQ_temp_linewidth_dim\linewidth
+ \l_EQ_linewidth_dim\linewidth
+% \end{macrocode}
+% In classes like \cls{amsart} and \cls{amsbook} thye set
+% \cs{displaywidth} to a fixed value. This gives problems inside
+% lists, where these classes want to use the full width, not the
+% effective width. They do this via \cs{everydisplay}
+% which is actually too late for when \cs{EQ_initialize:} runs!
+% We know that \cls{amsart/book} defines
+% \begin{verbatim}
+% \def\fullwidthdisplay{\displayindent\z@ \displaywidth\columnwidth}
+% \end{verbatim}
+% and then adds this to \cs{everydisplay}. So our fix will be to see
+% if \cs{fullwidthdisplay} is defined, run it locally and then extract
+% the value of \cs{displaywidth} using a global scratch variable. If
+% that size is then larger than the current \cs{linewidth} we will use
+% it. Additionally we also save this value in a static length, so we
+% can use this everywhere instead of \cs{linewidth}.
+% \begin{macrocode}
+ \@tempdima\z@
+ \begingroup
+ \ifdefined\fullwidthdisplay\relax
+ \fullwidthdisplay
+ \global\@tempdima\displaywidth
+ \fi
+ \endgroup
+ \ifdim\@tempdima>\linewidth\relax
+ \l_EQ_temp_linewidth_dim\@tempdima
+ \l_EQ_linewidth_dim\@tempdima
+ \fi
+ \@tempdima\z@
+% \end{macrocode}
+% -- end of \cls{amsart/-book} fix.
+% \begin{macrocode}
\g_EQ_toprow_height_dim\z@
\g_EQ_bottomrow_depth_dim\z@
\g_EQ_toptag_height_dim\z@
@@ -2303,7 +2361,9 @@ and the derived files
% \subsubsection{Separating Tags and Display}
%
% \begin{macro}{\EQ_typeset_tags:}
-% Typesetting the tags without the display.
+% Typesetting the tags without the display. The main idea here is to
+% typeset everything inside a box of a massive width, so wide that
+% the math part is way outside the area of the text block.
% \begin{macrocode}
\def\EQ_typeset_tags:{%
\sbox\EQ_tag_box{%
@@ -2319,7 +2379,7 @@ and the derived files
% The AMS classes sets \cs{displaywidth} equal to \cs{columnwidth} in
% \cs{everydisplay}. This is bad for us as then the reqno equation
% numbers are not typeset at the right edge of the parbox we are
-% in. Simplest solution: Locally reset \cs{columnwidth}.
+% in. Simplest solution: Locally reset \cs{columnwidth}.
% \changes{v2.15}{2017/03/28}{Resetting \cs{columnwidth} as a fix for
% a setting in AMS classes}
% \begin{macrocode}
@@ -2727,9 +2787,13 @@ and the derived files
% math display.
% \changes{v2.15}{2017/03/31}{added MH\_ prefix}
% \changes{v2.15}{2017/03/31}{added EQ\_ prefix}
+% \changes{v2.16}{2020/03/23}{switched \cs{linewidth} to
+% \cs{l_EQ_linewidth_dim} due to amsart forcing full width displays}
% \begin{macrocode}
\setlength{\l_EQ_temp_linewidth_dim}{%
- \linewidth-\l_EQ_totalwidth_dim-\widthof{\EQ_outerbox:{}}}%
+ % \linewidth
+ \l_EQ_linewidth_dim
+ -\l_EQ_totalwidth_dim-\widthof{\EQ_outerbox:{}}}%
\MH_fi:}
\def\EQ_modify_linewidth_ii:{\EQ_modify_linewidth_i:}
\def\EQ_find_displaywidth_i:{%
@@ -2777,6 +2841,13 @@ and the derived files
% This was fairly easy, but then I had to take care of \ldots
%
% \subsubsection{The \env{multline} Family}
+%
+% \emph{Note: These next three paragraphs are rather confusing. They
+% are referring to an older implementation (also available via the
+% \opt{oldmultline} option, where the \env{multline} feature was
+% implemented via \env{flalign}, nowadays we use \env{multlined} from
+% \pkg{mathtools} wrapped inside a \env{gather} for the equation number.}
+%
% This was quite a pickle. Its implementation in \pkg{amsmath} is
% very strange indeed; for instance the tag is typeset in the
% measuring phase! So instead I thought I could fake it, but how
@@ -2798,6 +2869,10 @@ and the derived files
% \cs{MakeKeyvalAliasAddon} now}
% Then we make \env{multline} into an alias for {flalign} but with
% an extra switch \cs{ifEQ_multline:} set to true.
+%
+% Note this version of the \env{multline} code is being used when we
+% use the \emph{bad} \env{multline} implementation, see code line
+% \lineref{goodandbad} onwards.
% \begin{macrocode}
\MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{multline}
{flalign}{\MH_set_boolean_T:n {multline}}
@@ -2863,78 +2938,108 @@ and the derived files
\MH_let:NwN \endMTmultlined \endmultlined
% \end{macrocode}
% \end{environment}
-% We make a choice here: the good \env{multline} or the bad?
+% We make a choice here: the good \env{multline} or the bad?
+% \refstepcounter{CodelineNo}\label{goodandbad}\addtocounter{CodelineNo}{-1}
% \begin{macrocode}
\MH_if_boolean:nTF {good_mult}{
% \end{macrocode}
% The good:
% \changes{v2.15}{2017/03/31}{added MH\_ prefix}
% \changes{v2.15}{2017/03/31}{added EQ\_ prefix}
-% \begin{macrocode}
-\MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{multline}{gather}
- {\MH_set_boolean_T:n {outer_mult}}
-\MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{multline*}{gather*}
- {\MH_set_boolean_T:n {outer_mult}}
-\def\EQ_modify_linewidth_iii_mult:{
- \setlength{\l_EQ_temp_linewidth_dim}{%
- \linewidth-\widthof{\EQ_outerbox:{}}}%
- \MH_if_dim:w \g_EQ_widesttag_dim>\z@
- \EQ_multline_modify_linewidth_tag:
- \MH_else:
- \EQ_multline_modify_linewidth_notag:
- \MH_fi:
- \MH_setlength:dn \l_MT_multwidth_dim{\l_EQ_temp_linewidth_dim}
-}
-\def\EQ_modify_linewidth_iv_mult:{\EQ_modify_linewidth_iii_mult:}
-\def\EQ_find_displaywidth_iii_mult:{%
- \MH_setlength:dn \l_EQ_displaywidth_dim{\totwidth@}%
- \MH_if_case:w \l_EQ_alignmentmode_int \MH_or: \MH_or: % #1 & #2:
- \MH_or: % #3:
- \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
- \MH_or: % #4:
- \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
- \MH_fi:}
-\def\EQ_find_displaywidth_iv_mult:{\EQ_find_displaywidth_iii_mult:}
-\def\EQ_place_display_iii_mult:{
- \MH_if_case:w \l_EQ_alignmentmode_int
- \MH_or: % #1:
+% \changes{v2.16}{2020/03/23}{switched \cs{linewidth} to
+% \cs{l_EQ_linewidth_dim} due to amsart forcing full width displays}
+% \begin{macrocode}
+ \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{multline}{gather}
+ {\MH_set_boolean_T:n {outer_mult}}
+ \MH_keyval_alias_with_addon:nnnn {EmphEqEnv}{multline*}{gather*}
+ {\MH_set_boolean_T:n {outer_mult}}
+ \def\EQ_modify_linewidth_iii_mult:{
+ \setlength{\l_EQ_temp_linewidth_dim}{%
+ % \linewidth
+ \l_EQ_linewidth_dim
+ -\widthof{\EQ_outerbox:{}}}%
\MH_if_dim:w \g_EQ_widesttag_dim>\z@
- \abovedisplayshortskip=\abovedisplayskip
- \rlap{
- \kern-.5\linewidth
- \kern\multlinegap
- \EQ_use_mathdisplay:
- }
+ \EQ_multline_modify_linewidth_tag:
\MH_else:
- \EQ_use_mathdisplay:
+ \EQ_multline_modify_linewidth_notag:
\MH_fi:
- \MH_or: % #2:
- \MH_if_dim:w \g_EQ_widesttag_dim>\z@
- \llap{
+ \MH_setlength:dn \l_MT_multwidth_dim{\l_EQ_temp_linewidth_dim}
+% \end{macrocode}
+% Here is an interesting issue. We have just calculated
+% \cs{l_MT_multwidth_dim} which will be the width of the internal
+% \env{multline}. But we are typesetting inside \env{gather} inside a
+% box of width \cs{l_EQ_temp_linewidth_dim} so the effective width of
+% the display is \cs{@mathmargin} less. Solution: add \cs{@mathmargin}
+% back in:
+% \changes{v2.16}{2020/03/23}{Added \cs{@mathmargin} back into the box
+% width}
+% \begin{macrocode}
+ \MH_if_case:w \l_EQ_alignmentmode_int
+ \MH_or: \MH_or: % 1 and 2
+ \MH_or:
+ \MH_addtolength:dn
+ \l_EQ_temp_linewidth_dim{\@mathmargin}%
+ \MH_or:
+ \MH_addtolength:dn
+ \l_EQ_temp_linewidth_dim{\@mathmargin}%
+ \MH_fi:
+ }
+ \def\EQ_modify_linewidth_iv_mult:{\EQ_modify_linewidth_iii_mult:}
+ \def\EQ_find_displaywidth_iii_mult:{%
+ \MH_setlength:dn \l_EQ_displaywidth_dim{\totwidth@}%
+ \MH_if_case:w \l_EQ_alignmentmode_int \MH_or: \MH_or: % #1 & #2:
+ \MH_or: % #3:
+ \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
+ \MH_or: % #4:
+ \MH_addtolength:dn \l_EQ_displaywidth_dim{-\@mathmargin}%
+ \MH_fi:}
+ \def\EQ_find_displaywidth_iv_mult:{\EQ_find_displaywidth_iii_mult:}
+% \end{macrocode}
+% \changes{v2.16}{2020/03/23}{switched \cs{linewidth} to
+% \cs{l_EQ_linewidth_dim} due to amsart forcing full width displays}
+% \begin{macrocode}
+ \def\EQ_place_display_iii_mult:{
+ \MH_if_case:w \l_EQ_alignmentmode_int
+ \MH_or: % #1:
+ \MH_if_dim:w \g_EQ_widesttag_dim>\z@
+ \abovedisplayshortskip=\abovedisplayskip
+ \rlap{
+ % \kern-.5\linewidth
+ \kern-.5\l_EQ_linewidth_dim
+ \kern\multlinegap
+ \EQ_use_mathdisplay:
+ }
+ \MH_else:
\EQ_use_mathdisplay:
- \kern-.5\linewidth
- \kern\multlinegap
- }%
- \MH_else:
+ \MH_fi:
+ \MH_or: % #2:
+ \MH_if_dim:w \g_EQ_widesttag_dim>\z@
+ \llap{
+ \EQ_use_mathdisplay:
+ % \kern-.5\linewidth
+ \kern-.5\l_EQ_linewidth_dim
+ \kern\multlinegap
+ }%
+ \MH_else:
+ \EQ_use_mathdisplay:
+ \MH_fi:
+ \MH_or: % #3:
+ \EQ_use_mathdisplay:
+ \MH_or: % #4:
\EQ_use_mathdisplay:
\MH_fi:
- \MH_or: % #3:
- \EQ_use_mathdisplay:
- \MH_or: % #4:
- \EQ_use_mathdisplay:
- \MH_fi:
-}
-\def\EQ_place_display_iv_mult: {\EQ_place_display_iii_mult:}
+ }
+ \def\EQ_place_display_iv_mult: {\EQ_place_display_iii_mult:}
% \end{macrocode}
% \begin{macrocode}
-}{
+}{% on to the 'bad' version
% \end{macrocode}
% The bad
% \begin{macrocode}
-\def\EQ_generic_multline:nnnnn #1#2#3#4#5{%
+ \def\EQ_generic_multline:nnnnn #1#2#3#4#5{%
% \end{macrocode}
% This is a very tricky little detail. If we're in \mode{leqno} mode
-% we need just a we little width inside the \env{flalign}, so we put
+% we need just a wee little width inside the \env{flalign}, so we put
% in the smallest possible amount. Otherwise we wind up in a
% \begin{verbatim}
% ! Arithmetic overflow.
@@ -2946,8 +3051,8 @@ and the derived files
% how many users can fix this by themselves?
% \changes{v2.15}{2017/03/31}{added MH\_ prefix}
% \begin{macrocode}
- \hskip1sp#2#3{{}#5}#4%
- \MH_if:w *#1\relax\MH_else:\notag\MH_fi:}
+ \hskip1sp#2#3{{}#5}#4%
+ \MH_if:w *#1\relax\MH_else:\notag\MH_fi:}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -2958,51 +3063,51 @@ and the derived files
% first three are the general purpose ones that also have a starred
% version. The other three are for normal use.
% \begin{macrocode}
-\def\multleft{\@ifstar{%
- \MH_if_boolean:nTF {multlined}{
- \def\EQ_next:{\EQ_multlined_left:n}
- }{
- \def\EQ_next:{
- \EQ_generic_multline:nnnnn {*}{}{\mathrlap}{&&&&&}}
- }
- \EQ_next:}{%
- \MH_if_boolean:nTF {multlined}{
- \def\EQ_next:{\EQ_multlined_left:n}%
- }{
- \def\EQ_next:{
- \EQ_generic_multline:nnnnn {}{}{\mathrlap}{&&&&&}}
- }
- \EQ_next:}}%
-\def\multcenter{\@ifstar{%
- \MH_if_boolean:nTF {multlined}{
- \def\EQ_next:{\EQ_multlined_center:n}%
- }{
- \def\EQ_next:{
- \EQ_generic_multline:nnnnn {*}{&&}{\mathclap}{&&&}}
- }
- \EQ_next:}{%
- \MH_if_boolean:nTF {multlined}{
- \def\EQ_next:{\EQ_multlined_center:n }%
- }{
- \def\EQ_next:{
- \EQ_generic_multline:nnnnn {}{&&}{\mathclap}{&&&}}
- }
- \EQ_next:}}%
-\def\multright{\@ifstar{%
- \MH_if_boolean:nTF {multlined}{
- \def\EQ_next:{\EQ_multlined_right:n }%
- }{
- \def\EQ_next:{
- \EQ_generic_multline:nnnnn {*}{&&&&&}{\mathllap}{}}
- }
- \EQ_next:}{%
- \MH_if_boolean:nTF {multlined}{
- \def\EQ_next:{\EQ_multlined_right:n }%
- }{
- \def\EQ_next:{
- \EQ_generic_multline:nnnnn {}{&&&&&}{\mathllap}{}}
- }
- \EQ_next:}}
+ \def\multleft{\@ifstar{%
+ \MH_if_boolean:nTF {multlined}{
+ \def\EQ_next:{\EQ_multlined_left:n}
+ }{
+ \def\EQ_next:{
+ \EQ_generic_multline:nnnnn {*}{}{\mathrlap}{&&&&&}}
+ }
+ \EQ_next:}{%
+ \MH_if_boolean:nTF {multlined}{
+ \def\EQ_next:{\EQ_multlined_left:n}%
+ }{
+ \def\EQ_next:{
+ \EQ_generic_multline:nnnnn {}{}{\mathrlap}{&&&&&}}
+ }
+ \EQ_next:}}%
+ \def\multcenter{\@ifstar{%
+ \MH_if_boolean:nTF {multlined}{
+ \def\EQ_next:{\EQ_multlined_center:n}%
+ }{
+ \def\EQ_next:{
+ \EQ_generic_multline:nnnnn {*}{&&}{\mathclap}{&&&}}
+ }
+ \EQ_next:}{%
+ \MH_if_boolean:nTF {multlined}{
+ \def\EQ_next:{\EQ_multlined_center:n }%
+ }{
+ \def\EQ_next:{
+ \EQ_generic_multline:nnnnn {}{&&}{\mathclap}{&&&}}
+ }
+ \EQ_next:}}%
+ \def\multright{\@ifstar{%
+ \MH_if_boolean:nTF {multlined}{
+ \def\EQ_next:{\EQ_multlined_right:n }%
+ }{
+ \def\EQ_next:{
+ \EQ_generic_multline:nnnnn {*}{&&&&&}{\mathllap}{}}
+ }
+ \EQ_next:}{%
+ \MH_if_boolean:nTF {multlined}{
+ \def\EQ_next:{\EQ_multlined_right:n }%
+ }{
+ \def\EQ_next:{
+ \EQ_generic_multline:nnnnn {}{&&&&&}{\mathllap}{}}
+ }
+ \EQ_next:}}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -3014,65 +3119,70 @@ and the derived files
% be placed in the first line.
% \changes{v2.15}{2017/03/31}{added MH\_ prefixes}
% \begin{macrocode}
-\def\multfirst{%
- \MH_if_boolean:nTF {multlined}{
- \def\EQ_next:{\EQ_multlined_left:n }%
- }{
- \MH_if_case:w \l_EQ_alignmentmode_int
- \MH_or: % #1:
- \def\EQ_next:{\multleft}%
- \MH_or: % #2:
- \def\EQ_next:{\multleft*}%
- \MH_or: % #3:
- \def\EQ_next:{\multleft}%
- \MH_or: % #4:
- \def\EQ_next:{\multleft*}%
- \MH_fi:
- }
- \EQ_next:}
-% \end{macrocode}
-% Pretend the star was never there.
-% \begin{macrocode}
-\def\multmiddle{%
- \def\EQ_next:{%
+ \def\multfirst{%
\MH_if_boolean:nTF {multlined}{
- \expandafter\EQ_multlined_center:n
+ \def\EQ_next:{\EQ_multlined_left:n }%
}{
- \expandafter\multcenter
+ \MH_if_case:w \l_EQ_alignmentmode_int
+ \MH_or: % #1:
+ \def\EQ_next:{\multleft}%
+ \MH_or: % #2:
+ \def\EQ_next:{\multleft*}%
+ \MH_or: % #3:
+ \def\EQ_next:{\multleft}%
+ \MH_or: % #4:
+ \def\EQ_next:{\multleft*}%
+ \MH_fi:
}
- }%
- \@ifstar{\EQ_next:}{\EQ_next:}}
+ \EQ_next:}
+% \end{macrocode}
+% Pretend the star was never there.
+% \begin{macrocode}
+ \def\multmiddle{%
+ \def\EQ_next:{%
+ \MH_if_boolean:nTF {multlined}{
+ \expandafter\EQ_multlined_center:n
+ }{
+ \expandafter\multcenter
+ }
+ }%
+ \@ifstar{\EQ_next:}{\EQ_next:}}
% \end{macrocode}
% If we're using the \mode{reqno} option, the equation number
% should be placed in the last line.
% \changes{v2.15}{2017/03/31}{added MH\_ prefixes}
% \begin{macrocode}
-\def\multlast{%
- \MH_if_boolean:nTF {multlined}{
- \def\EQ_next:{\EQ_multlined_right:n }%
- }{
- \MH_if_case:w \l_EQ_alignmentmode_int
- \MH_or: % #1:
- \def\EQ_next:{\multright*}%
- \MH_or: % #2:
- \def\EQ_next:{\multright}%
- \MH_or: % #3:
- \def\EQ_next:{\multright*}%
- \MH_or: % #4:
- \def\EQ_next:{\multright}%
- \MH_fi:
- }
- \EQ_next:}
+ \def\multlast{%
+ \MH_if_boolean:nTF {multlined}{
+ \def\EQ_next:{\EQ_multlined_right:n }%
+ }{
+ \MH_if_case:w \l_EQ_alignmentmode_int
+ \MH_or: % #1:
+ \def\EQ_next:{\multright*}%
+ \MH_or: % #2:
+ \def\EQ_next:{\multright}%
+ \MH_or: % #3:
+ \def\EQ_next:{\multright*}%
+ \MH_or: % #4:
+ \def\EQ_next:{\multright}%
+ \MH_fi:
+ }
+ \EQ_next:}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\multlinedwidth}
% Here begins the code for \env{multlined}.
-% \begin{macrocode}
-\MH_new_boolean:n {multlined}
-\newdimen\multlinedwidth
-\MH_setlength:dn \multlinedwidth{.7\linewidth}
+% \changes{v2.16}{2020/03/23}{switched \cs{linewidth} to
+% \cs{l_EQ_linewidth_dim} due to amsart forcing full width displays}
+% \begin{macrocode}
+ \MH_new_boolean:n {multlined}
+ \newdimen\multlinedwidth
+ \MH_setlength:dn \multlinedwidth{
+ % .7\linewidth
+ 0.7\l_EQ_linewidth_dim
+ }
% \end{macrocode}
% \end{macro}
% \begin{environment}{multlined}
@@ -3084,25 +3194,25 @@ and the derived files
% Some trickery as we want to scan for two optional arguments that
% may be interchanged.
% \begin{macrocode}
-\renewenvironment{multlined}%
- {\MH_nospace_ifnextchar:Nnn [ {\EQ_multlined_I:w}
- {\EQ_multlined_I:w[c]}
- }
- { \endaligned }
-\def\EQ_multlined_I:w[#1]{%
- \MH_nospace_ifnextchar:Nnn[ {\EQ_multlined_II:w[#1]}
- {\EQ_multlined_II:w[#1][\multlinedwidth]}}
-\def\EQ_multlined_II:w[#1][#2]{%
+ \renewenvironment{multlined}%
+ {\MH_nospace_ifnextchar:Nnn [ {\EQ_multlined_I:w}
+ {\EQ_multlined_I:w[c]}
+ }
+ { \endaligned }
+ \def\EQ_multlined_I:w[#1]{%
+ \MH_nospace_ifnextchar:Nnn[ {\EQ_multlined_II:w[#1]}
+ {\EQ_multlined_II:w[#1][\multlinedwidth]}}
+ \def\EQ_multlined_II:w[#1][#2]{%
% \end{macrocode}
% We tell \LaTeX\ that we're in \env{multlined}.
% \begin{macrocode}
- \MH_set_boolean_T:n {multlined}
+ \MH_set_boolean_T:n {multlined}
% \end{macrocode}
% \changes{v2.10}{2004/07/26}{Fixed restoration of \cmd{\\}}
% Restore the meaning of \cmd{\\} inside \env{multlined}, else it
% wouldn't work in the \env{equation} environment.
% \begin{macrocode}
- \MH_let:NwN \Let@\MT_saved_Let:
+ \MH_let:NwN \Let@\MT_saved_Let:
% \end{macrocode}
% Then check the first optional argument and call
% \cs{EQ_multlined_III:w}, which sets \cs{multlinewidth} if
@@ -3110,21 +3220,21 @@ and the derived files
% three columns).
% \changes{v2.15}{2017/03/31}{added MH\_ prefix}
% \begin{macrocode}
- \MH_if:w t#1\relax \EQ_multlined_III:nn {#1}{#2}%
- \MH_else:
- \MH_if:w b#1\relax \EQ_multlined_III:nn {#1}{#2}%
+ \MH_if:w t#1\relax \EQ_multlined_III:nn {#1}{#2}%
\MH_else:
- \MH_if:w c#1\relax \EQ_multlined_III:nn {#1}{#2}%
+ \MH_if:w b#1\relax \EQ_multlined_III:nn {#1}{#2}%
\MH_else:
- \EQ_multlined_III:nn {#2}{#1}%
+ \MH_if:w c#1\relax \EQ_multlined_III:nn {#1}{#2}%
+ \MH_else:
+ \EQ_multlined_III:nn {#2}{#1}%
+ \MH_fi:
\MH_fi:
\MH_fi:
- \MH_fi:
- \mkern-\thinmuskip
- \EQ_next:}
-\def\EQ_multlined_III:nn #1#2{%
- \def\EQ_next:{\setlength\multlinedwidth{#2}%
- \start@aligned{#1}{\thr@@}}}
+ \mkern-\thinmuskip
+ \EQ_next:}
+ \def\EQ_multlined_III:nn #1#2{%
+ \def\EQ_next:{\setlength\multlinedwidth{#2}%
+ \start@aligned{#1}{\thr@@}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -3136,12 +3246,12 @@ and the derived files
% The internal versions of \cs{multleft} etc.\ adapted for
% \env{multlined}.
% \begin{macrocode}
-\def\EQ_multlined_left:n #1{%
- \mathrlap{#1}&\hskip.5\multlinedwidth&&\hskip.5\multlinedwidth&&}
-\def\EQ_multlined_center:n #1{%
- &\hskip.5\multlinedwidth&&\mathclap{#1}\hskip.5\multlinedwidth&&}
-\def\EQ_multlined_right:n #1{%
- &\hskip.5\multlinedwidth&&\hskip.5\multlinedwidth&&\mathllap{#1}}
+ \def\EQ_multlined_left:n #1{%
+ \mathrlap{#1}&\hskip.5\multlinedwidth&&\hskip.5\multlinedwidth&&}
+ \def\EQ_multlined_center:n #1{%
+ &\hskip.5\multlinedwidth&&\mathclap{#1}\hskip.5\multlinedwidth&&}
+ \def\EQ_multlined_right:n #1{%
+ &\hskip.5\multlinedwidth&&\hskip.5\multlinedwidth&&\mathllap{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -3155,12 +3265,16 @@ and the derived files
% \subsubsection{The Code for \env{flalign} \& \env{multline}}
% \changes{v2.15}{2017/03/31}{added MH\_ prefix}
% \changes{v2.15}{2017/03/31}{added EQ\_ prefix}
+% \changes{v2.16}{2020/03/23}{switched \cs{linewidth} to
+% \cs{l_EQ_linewidth_dim} due to amsart forcing full width displays}
% \begin{macrocode}
\EQ_new_equationtype:nnn {EmphEqEnv}{flalign}{5}
\EQ_new_equationtype:nnn {EmphEqEnv}{flalign*}{6}
\def\EQ_modify_linewidth_v:{%
\setlength{\l_EQ_temp_linewidth_dim}{%
- \linewidth-\l_EQ_totalwidth_dim-\widthof{\EQ_outerbox:{}}}%
+ % \linewidth
+ \l_EQ_linewidth_dim
+ -\l_EQ_totalwidth_dim-\widthof{\EQ_outerbox:{}}}%
\MH_if_dim:w \g_EQ_widesttag_dim>\z@
\MH_if_boolean:nTF {multline}{
\EQ_multline_modify_linewidth_tag:
@@ -3190,16 +3304,24 @@ and the derived files
\MH_setlength:dn
\l_EQ_displaywidth_dim{\l_EQ_temp_linewidth_dim}}
\def\EQ_find_displaywidth_vi:{\EQ_find_displaywidth_v:}
+% \end{macrocode}
+% \changes{v2.16}{2020/03/23}{switched \cs{linewidth} to
+% \cs{l_EQ_linewidth_dim} due to amsart forcing full width displays}
+% \begin{macrocode}
\def\EQ_place_display_v:{%
\MH_if_case:w \l_EQ_alignmentmode_int
\MH_or: % #1:
\MH_if_dim:w \g_EQ_widesttag_dim>\z@
\MH_if_boolean:nTF {multline}{
- \rlap{\kern\multlinegap \kern-.5\linewidth
+ \rlap{\kern\multlinegap
+ % \kern-.5\linewidth
+ \kern-.5\l_EQ_linewidth_dim
\EQ_use_mathdisplay:
\kern-\mintagsep \kern\multlinetaggap}%
}{
- \rlap{\kern-.5\linewidth\EQ_use_mathdisplay:}%
+ \rlap{%\kern-.5\linewidth
+ \kern-.5\l_EQ_linewidth_dim
+ \EQ_use_mathdisplay:}%
}
\MH_else:
\EQ_use_mathdisplay:
@@ -3209,15 +3331,27 @@ and the derived files
\MH_if_boolean:nTF {multline}{
\llap{\kern-\mintagsep \kern\multlinetaggap
\EQ_use_mathdisplay:
- \kern\multlinegap \kern-.5\linewidth}%
+ \kern\multlinegap
+ % \kern-.5\linewidth
+ \kern-.5\l_EQ_linewidth_dim
+ }%
}{
- \llap{\EQ_use_mathdisplay:\kern-.5\linewidth}%
+ \llap{\EQ_use_mathdisplay:
+ % \kern-.5\linewidth
+ \kern-.5\l_EQ_linewidth_dim
+ }%
}
\MH_else:
\EQ_use_mathdisplay:
\MH_fi:
\MH_or: % #3:
- \MH_if_boolean:nF {multline}{ \kern-\multlinetaggap }
+% \end{macrocode}
+% \changes{v2.16}{2020/03/24}{\cs{multlinetaggap} should be added when
+% \opt{multline} is true, and if false \cs{\@mathmargin} should ned
+% kerned away}
+% \begin{macrocode}
+ \MH_if_boolean:nTF {multline}{ \kern-\multlinetaggap }
+ { \kern-\@mathmargin }
\EQ_use_mathdisplay:
\MH_or: % #4:
\MH_if_dim:w \g_EQ_widesttag_dim>\z@
@@ -3538,6 +3672,81 @@ and the derived files
% \end{macro}
%
%
+% \subsection{Adjusting for \cls{amsart} and \cls{amsbook}}
+% \label{sec:adjust-clsams-clsams}
+%
+% As mentioned earlier the \AmS{} classes \cls{amsart} and
+% \cls{amsbook} explicitly sets \cs{displaywidth} to
+% \cs{columnwidth}. The main reason for this (1) they use equation
+% numbers on the left and (2) if an equation is inside a list, they
+% still want the equation to use the full width (the standard classes
+% under \opt{leqno} will have their equation number indented to match
+% the effective line width/indentation).
+%
+% Why is problematic for us? Firstly, this messes up our trick to
+% separate the tags (equation numbers) from the display (as we need
+% the construction to follow our \emph{very large} line
+% width). Secondly this messes up the calculations of \cs{alignsep@},
+% since we can no longer assume that \cs{alignsep@} was calculated
+% against the with of the box we wanted. Here is an example that
+% \begin{verbatim}
+% \makeatletter
+% \begingroup
+% \fbox{\parbox{0.5\textwidth}{%
+% \def\maketag@@@#1{\kern1sp\vphantom{#1}}%
+% \begin{align}
+% align &= align & align &= align \\ &= align
+% \end{align}}}
+% \par\noindent
+% \def\fullwidthdisplay{\displayindent\z@ \displaywidth\columnwidth}
+% \edef\@tempa{\noexpand\fullwidthdisplay\the\everydisplay}
+% \everydisplay\expandafter{\@tempa}
+% \fbox{\parbox{0.5\textwidth}{%
+% \def\maketag@@@#1{\kern1sp\vphantom{#1}}%
+% \begin{align}
+% align &= align & align &= align \\ &= align
+% \end{align}}\vspace{-2\baselineskip}}
+% \endgroup
+% \makeatletter
+% \end{verbatim}
+% \makeatletter
+% \begingroup^^A
+% \fboxsep=2pt
+% \abovedisplayskip0pt
+% \belowdisplayskip0pt
+% \abovedisplayshortskip0pt
+% \belowdisplayshortskip0pt
+% \fbox{\parbox{0.5\textwidth}{%
+% \def\maketag@@@#1{\kern1sp\vphantom{#1}}%
+% \begin{align}
+% align &= align & align &= align \\ &= align
+% \end{align}}}
+% \par\noindent
+% \def\fullwidthdisplay{\displayindent\z@ \displaywidth\columnwidth}^^A
+% \edef\@tempa{\noexpand\fullwidthdisplay\the\everydisplay}^^A
+% \everydisplay\expandafter{\@tempa}^^A
+% \fbox{\parbox{0.5\textwidth}{%
+% \def\maketag@@@#1{\kern1sp\vphantom{#1}}%
+% \begin{align}
+% align &= align & align &= align \\ &= align
+% \end{align}}\vspace{-2\baselineskip}}
+% \endgroup
+% \makeatletter
+% \par\medskip\noindent
+% It is pretty obvious that the space between the two alignment
+% columns are wrong. Like when we handled the tag separation, one
+% solution could be to explicitly set \cs{columnwidth} to be the
+% effective line width. Alternatively we could redefine
+% \cs{fullwidthdisplay} to do nothing. The latter is probably the
+% less severe.
+% \begin{macrocode}
+\g@addto@macro\EQ_typeset_display_hook:{
+ % \columnwidth\linewidth
+ \def\fullwidthdisplay{}
+}
+% \end{macrocode}
+%
+%
% \section{The \opt{overload} option}
% \begin{macro}{\EQ_overload_ams_begin:n}
% A helper for saving snapshots: