[Tex/LaTex] amsmath’s multline and fleqn

amsmathequationsmultline

As a fleqn fanatic, I run across this problem once every week: when splitting a long formula using amsmath's multline, the middle lines are flushed left:

\documentclass[fleqn]{article}
\usepackage{amsmath}
\begin{document}
\begin{multline}
  1+2+3+4+5+6+7+8+9+10+11+12 \\
  +13+14+15+16+17+18+19+20+21+22 \\
  +23+24+25+26+27+28+29+30+31
\end{multline}
\end{document}

While this is even documented, I think it is rather borken behaviour.

Is there a way to fix this? I understand that amsmath is essentially frozen, but even some kludgy way, even a \shovecenter that could eventually become part of the thankfully more lively mathtools would be helpful!

P.S. This fundamentalistic adherence of multline to the fleqn option is to be contrasted with the more liberal approach taken by gathered, by the way! The worst of both worlds 🙂

\documentclass[fleqn]{article}
\usepackage{amsmath}
\begin{document}
  \[
    \left(
      \begin{gathered}
        1+2+3+4+5+6+7+8+9+10+11+12 \\
        16+17+18+19+20+21+22 \\
        +23+24+25+26+27+28+29+30+31
      \end{gathered} 
    \right)
  \]
\end{document}

Best Answer

this is a kludge, but you can take advantage of the \multline \shoveright feature to reposition lines that are erroneously positioned too far to the left:

\documentclass[fleqn]{article}
\usepackage{amsmath}
\begin{document}
\begin{multline}
  1+2+3+4+5+6+7+8+9+10+11+12 \\
  \shoveright{+13+14+15+16+17+18+19+20+21+22} \kern.1\textwidth \\
  +23+24+25+26+27+28+29+30+31
\end{multline}
\end{document}

outpot of example code

the amount of extra space needed at the end of such a line is (unfortunately) a matter for experimentation.

the positioning bug was reported long ago (in 1996), and a fix is known, but updates to amsmath haven't been scheduled.

in answer to the question posed in a comment as to who gave this beast the name multline, that was michael spivak; the concept, and a good part of the code, were lifted from the original amstex (non-latex!) package.