# How do I obtain multline-type alignment within a group of equations?

I want to achieve something like the following (for now achieved using Microsoft Paint):

That is, I want to group a number of multi-line equations within a single equation-type environment (i.e. they have the same number) and have each one aligned like in the "multline"-environment (first line left-aligned, last line right-aligned). Is this possible?

– dgs
Commented Jun 1, 2012 at 16:01
• The mathtools package provides a multlined environment that might fit your needs. Maybe this question can help. Commented Jun 1, 2012 at 16:25
– dgs
Commented Jun 1, 2012 at 16:44
• The accepted answer is the closest to what I was asking for, but the others help to further map out the space of possibilities here. Thanks! (just noticed I forgot a plus after f_1 and f_2 btw.) Commented Jun 11, 2012 at 9:11

The \shoveleft and \shoveright commands allow to flush left or right the equations of a multline environment.

\documentclass{article}
\usepackage{amsmath}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{multline}
a_1 + b_1 + c_1 + d_1 + e_1 + f_1\\
\shoveright{g_1 + h_1 + i_1 + j_1 + k_1 + l_1}\\
\shoveleft{a_2 + b_2 + c_2 + d_2 + e_2 + f_2}\\
g_2 + h_2 + i_2 + j_2 + k_2 + l_2
\end{multline}
\lipsum[2]
\end{document}


As pointed out by @barbara beeton, the position of the equation number is ambiguous. This can be solved by using the subsidiary environment multlined provided by mathtools inside an equation (first proposed by @egreg). This approach also benefits from the improved spacing of the equation environment.

\usepackage{mathtools}

$$\begin{multlined}[.7\textwidth] a_1 + b_1 + c_1 + d_1 + e_1 + f_1\\ \shoveright{g_1 + h_1 + i_1 + j_1 + k_1 + l_1}\\ \shoveleft{a_2 + b_2 + c_2 + d_2 + e_2 + f_2}\\ g_2 + h_2 + i_2 + j_2 + k_2 + l_2 \end{multlined}$$

• unfortunately, this places the equation number at the bottom, rather than in the middle, which isn't optimum for this situation since it then looks like only the second equation is numbered. Commented Jun 1, 2012 at 17:13
• I agree. I wasn't aware of the multlined environment mentioned by @egreg in the comments to the OP, which in this case is clearly superior.
– dgs
Commented Jun 1, 2012 at 18:34
• i wasn't aware of that either -- it's clearly a mathtools improvement on amsmath. Commented Jun 1, 2012 at 18:56

A regular array can be used for this, if needed:

\documentclass{article}
\usepackage{array}% http://ctan.org/pkg/array
\begin{document}
$$\begin{array}{>{}p{.55\textwidth}<{}} a_1+b_1+c_1+d_1+e_1+f_1 \\ \hfill g_1+h_1+i_1+j_1+k_1+l_1 \\[\jot] a_2+b_2+c_2+d_2+e_2+f_2 \\ \hfill g_2+h_2+i_2+j_2+k_2+l_2 \end{array}$$
\end{document}


The paragraph-style column is key and allows \hfill since it has a fixed width. However, it also formats its contents in a box that is in text mode. Switching back to math mode is achieved via array's >{<before>} and <{<after>} specification. For presentation purposes, I chose .55\textwidth. \jot adds a little bigger gap between the equations.

Not knowing how wide the text block of your document is, I don't think it's possible to give a completely general or automatic method for achieving the look-and-feel you illustrate in your example. However, as the MWE below suggests, using the split environment provided by the amsmath package inside an equation environment would seem to come reasonably close to having a fully-automated method.

Relative to the visual example you provide, this method has the advantage (in my opinion...) of letting you align the + signs across all four lines of the equation. Note also that because the split environment doesn't provide its own numbering of equation lines, the output automatically has only one equation number that's correctly centered vertically between lines 2 and 3 of the equation.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$$\begin{split} a_1+b_1+c_1+d_1+{}&e_1+f_1 \\ &g_1+h_1+i_1+j_1+k_1+l_1 \\ a_2+b_2+c_2+d_2+{}&e_2+f_2 \\ &g_2+h_2+i_2+j_2+k_2+l_2 \end{split}$$
\end{document}


Observe that it's necessary, in lines 1 and 3 of the equation's code, to place a {} construct before the & alignment points so that TeX doesn't think that the preceding + symbol is a unary operator.

• i think this (a general approach) is something that should be looked at when amsmath is overhauled. i'll put it on the list. Commented Jun 1, 2012 at 17:15