How do I obtain multline-type alignment within a group of equations?
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}
Addendum
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{equation}
\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}
\end{equation}
A regular array
can be used for this, if needed:
\documentclass{article}
\usepackage{array}% http://ctan.org/pkg/array
\begin{document}
\begin{equation}
\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{equation}
\end{document}
The p
aragraph-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{equation}
\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{equation}
\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.