# How can I use multline within an align environment?

I've been looking around and I know that there are possibilities to mimic the multline environment within the gather or align environments, or by using multlined but not in a way that I like, I think.

If I understood well, the multline environment has two features (for a two line equation):

• automatically put the upper part on the far left and the lower part on the far right
• automatically number the second line only

Is it true that none of the features listed above are offered by one of the aligning solutions mentioned at the beginning of my message when two or more separate equations are involved?

What I need could be coded as follows:

\begin{align}
&\begin{multline}
equation 1 part 1 \\ equation 1 part 2
\end{multline}\\
&\begin{multline}
equation 2 part 1 \\ equation 2 part 2
\end{multline}
\end{align}

• You can also try the breqn package for automatic line splitting. – Aditya Sep 28 '11 at 7:45

To answer the question, yes the gather, align do not automatically behave as multline does.

multline will left align the first row, the second and all the following ones except the last are centered, and the last line is right aligned. The last lines gets numbered for right equation numbers, and the first one is numbered for the case of left equation numbers.

The gather environment will center all equations and by default number each one, and the align environment has an {rlrl...} alignment and also numbers each equation unless otherwise instructed.

A comprehensive review of mathematics in LaTeX is available in the Mathmode document.

• thanks but from what I could read, there is no satisfactory solution for a multline behaviour on two consecutive long equations. The last chance was to use split within align but split requires & in its {rlrl..} framework, that I do not want to use. What I need is more like a \hfill on the second (or last) part of a long equation so that it goes as far as possible on the right. – pluton Sep 28 '11 at 1:45
• Not sure I understand. Please add a MWE to illustrate what you want. – Peter Grill Sep 28 '11 at 1:49
• Is the multlined what you are looking for (from the mathtools package? – Peter Grill Sep 28 '11 at 2:03
• Probably. I could find what is in my answer. Thanks. It is not fully automatic because the width of the equations have to be provided but it is almost there. – pluton Sep 28 '11 at 2:46

Based on Peter Grill's comments, what is below is a possibility that could potentially be improved.

\documentclass[fleqn]{book}
\usepackage{mathtools}
\begin{document}
text text text text text text text text text text text text text text text text text   text text text text text text text text text text text text text text text text text text text text text text text
\begin{align}
&\begin{multlined}[b][.87\textwidth]
\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\\=\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi
\end{multlined}\\
&\begin{multlined}[b][.87\textwidth]
\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\\=\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos \pi
\end{multlined}
\end{align}
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
\end{document}


It seems that the coefficient 0.87 has to be adapted to the font used in the document

There is no satisfactory solution for a multline behaviour on two consecutive long equations.

Yes, there is.

\documentclass{article}

\usepackage{mathtools}
\usepackage[nopar]{lipsum} % for dummy text only

\begin{document}

\lipsum[1]
\begin{align}
A=&\begin{multlined}[t]
\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\\=\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi
\end{multlined}\\
B=&\begin{multlined}[t]
\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\\=\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos\pi\cos \pi
\end{multlined}
\end{align}
\lipsum[1]

\end{document}


The solution may seem obvious now, but I came across it after two hours of playing around with align, gather, multline, split, alginat, flalign and all its variants; just before I was about to contact Lars Mad­sen (main­tainer of the mathtools package) for an upgrade. It had to be something with an automated format, in pure LaTeX style, not through the use of \quad or \hspace or \vphantom or the like.

It is amazing how such a basic typesetting feature is so unknown. I mean, I couldn't find a solution in the whole Internet! It ought to be included in the the guides and tutorials. Multi-line equations are in our day to day.

I knew there had to be more people demanding a solution to this, which I'm now sharing throughout the forum. It also proves how robust the coding of the mathtools package is, responding successfully to this workaround.

Enjoy!