[texhax] Extra space above multline (Bug in amsmath?)

Morten Høgholm morten.hoegholm at gmail.com
Fri Aug 17 20:17:14 CEST 2007


On Fri, 17 Aug 2007 16:14:16 +0200, Plamen Tanovski wrote:


Hi Plamen,

> I have noticed that the space above multline from amsmath.sty is
> always bigger then the other environments. Carefully looking at the
> examples in testmath.pdf or TLC2 also shows this difference. The space
> above is gettig bigger if the text has to stretch vertically. There is
> also even a bigger difference between equation and the other amsmath
> environments! So, the different spacing, using equation and multline
> on the same page, can be visually recognised.
>
> The \jot has to do with this extra space of multline. If I set \jot to
> 0 in the following example, the extra space of multline vanish. Is
> this a bug? I can't imagine, that I am the first who finds this
> difference. I've searched the newsgroups and the bug database but
> didn't find something. Here is the example example.

This was reported in December last year here on texhax. Checking my mail  
archive I am not sure I ever posted the fix here but AMS is informed. The  
diagnosis is as follows:

If we compare it to the gather environment we notice the following:
\gather@ also applies \jot to \lineskip and friends but in the measuring
phase, \gmeasure@ locally resets \everycr. \multline@ also applies \jot
but \mmeasure@ does not reset \everycr so the extra \jot we see is
inserted in the measuring phase. Adding a
   \everycr={}%
right after
   \setbox\@ne\vbox{%
in \mmeasure@ seems to take care of the problem. Attached is a small
testfile.


\documentclass{article}
\newcount\tracingonline
\usepackage{amsmath,trace}

\makeatletter
\def\mmeasure@#1{%
     \begingroup
         \measuring at true
         \def\label##1{%
           \begingroup\measuring at false\label at in@display{##1}\endgroup}%
         \def\math at cr@@@{\cr}%
         \let\shoveleft\@iden \let\shoveright\@iden
         \savecounters@
         \global\row@\z@
         \setbox\@ne\vbox{%
             \global\let\df at tag\@empty
             \everycr{}% Added this line to prevent \jot-effect
             \halign{%
                 \setboxz at h{\@lign$\m at th\displaystyle{}##$}%
                 \iftagsleft@
                     \ifnum\row@=\@ne
                         \global\totwidth@\wdz@
                         \global\lineht@\ht\z@
                     \fi
                 \else
                     \global\totwidth@\wdz@
                     \global\lineht@\dp\z@
                 \fi
                 \crcr
                 #1%
                 \crcr
             }%
         }%
         \ifx\df at tag\@empty\else\global\tag at true\fi
         \if at eqnsw\global\tag at true\fi
         \iftag@
             \setboxz at h{%
                 \if at eqnsw
                     \stepcounter{equation}%
                     \tagform@\theequation
                 \else
                     \df at tag
                 \fi
             }%
             \global\tagwidth@\wdz@
             \dimen@\totwidth@
             \advance\dimen@\tagwidth@
             \advance\dimen@\multlinetaggap
             \iftagsleft@\else
                 \if at fleqn
                     \advance\dimen@\@mathmargin
                 \fi
             \fi
             \ifdim\dimen@>\displaywidth
                 \global\shifttag at true
             \else
                 \global\shifttag at false
             \fi
         \fi
         \restorecounters@
     \endgroup
}
\sbox0{$\m at th$}% to ease trace
\makeatother

\begin{document}

\setlength\abovedisplayskip{0pt}
\setlength\jot{30pt}

\noindent
Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah\traceon
\begin{gather*}
A=B BBBBBBB BBBBBB\\
	A=B BBBBBBB BBBBBB
\end{gather*}
Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah
\begin{multline}
A=B BBBBBBB BBBBBB\\
center \\
A=B BBBBBBB BBBBBB
\end{multline}
Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah
\traceoff
\loggingoutput
\end{document}



-- 
Morten


More information about the texhax mailing list