Splitting long formulas
9.3 Splitting long formulas
The multline environment is used to split one very long formula into several lines. The first line is set flush left, the last line is set flush right, and the middle lines are centered:
(4) (x 1 x 2 x 3 x 4 x 5 x 6 ) 2
+ (y 1 y 2 y 3 y 4 y 5 +y 1 y 3 y 4 y 5 y 6 +y 1 y 2 y 4 y 5 y 6 +y 1 y 2 y 3 y 5 y 6 ) 2 + (z 1 z 2 z 3 z 4 z 5 +z 1 z 3 z 4 z 5 z 6 +z 1 z 2 z 4 z 5 z 6 +z 1 z 2 z 3 z 5 z 6 ) 2 + (u 1 u 2 u 3 u 4 +u 1 u 2 u 3 u 5 +u 1 u 2 u 4 u 5 +u 1 u 3 u 4 u 5 ) 2
This formula is typed as \begin{multline}\label{E:mm2}
(x_{1} x_{2} x_{3} x_{4} x_{5} x_{6})^{2}\\ + (y_{1} y_{2} y_{3} y_{4} y_{5} + y_{1} y_{3} y_{4} y_{5} y_{6} + y_{1} y_{2} y_{4} y_{5} y_{6} + y_{1} y_{2} y_{3} y_{5} y_{6})^{2}\\ + (z_{1} z_{2} z_{3} z_{4} z_{5} + z_{1} z_{3} z_{4} z_{5} z_{6} + z_{1} z_{2} z_{4} z_{5} z_{6} + z_{1} z_{2} z_{3} z_{5} z_{6})^{2}\\ + (u_{1} u_{2} u_{3} u_{4} + u_{1} u_{2} u_{3} u_{5}
+ u_{1} u_{2} u_{4} u_{5} + u_{1} u_{3} u_{4} u_{5})^{2} \end{multline}
9.3 Splitting long formulas 213
Rule
multline environment
1. Lines are separated with \\. Do not type a \\ at the end of the last line!
2. The formula is numbered as a whole unless it is \tag-ged or the numbering is suppressed with \notag. (Alternatively, use the multline* environment.)
3. No blank lines are permitted within the environment.
4. Each line is a subformula (see Section 9.4.2).
If you are very observant, you may have noticed that we failed to type {}+ follow- ing the line separators of the formula. In Section 8.1.2, you were told that this omission would result in the second line being typeset as
4 y 5 +y 1 y 3 y 4 y 5 y 6 +y 1 y 2 y 4 y 5 y 6 +y 1 y 2 y 3 y 5 y 6 ) The multline environment, however, knows that a long formula is being broken and
+(y 1 y 2 y 3 y
so typesets + as a binary operation.
A common mistake is to write multiline for multline, resulting in the mes- sage:
! LaTeX Error: Environment multiline undefined. In the multline* environment, the formula is not numbered but can be \tag-ged.
The indentation of the first and last lines is controlled by the \multlinegap length command, with a default of 10 points, unless there is a tag on one of those lines. You can adjust the indentation by enclosing the multline environment in a setlength environment (see Section 15.5.2 ), as follows:
\begin{multline*} (x_{1} x_{2} x_{3} x_{4} x_{5} x_{6})^{2}\\ + (x_{1} x_{2} x_{3} x_{4} x_{5} + x_{1} x_{3} x_{4} x_{5} x_{6} + x_{1} x_{2} x_{4} x_{5} x_{6} + x_{1} x_{2} x_{3} x_{5} x_{6})^{2}\\ + (x_{1} x_{2} x_{3} x_{4} + x_{1} x_{2} x_{3} x_{5} + x_{1} x_{2} x_{4} x_{5} + x_{1} x_{3} x_{4})^{2}
\end{multline*} \begin{setlength}{\multlinegap}{0pt}
\begin{multline*} (x_{1} x_{2} x_{3} x_{4} x_{5} x_{6})^{2}\\ + (x_{1} x_{2} x_{3} x_{4} x_{5} + x_{1} x_{3} x_{4} x_{5} x_{6} + x_{1} x_{2} x_{4} x_{5} x_{6}
214 Chapter 9 Multiline math displays
+ x_{1} x_{2} x_{3} x_{5} x_{6})^{2}\\ + (x_{1} x_{2} x_{3} x_{4} + x_{1} x_{2} x_{3} x_{5} + x_{1} x_{2} x_{4} x_{5} + x_{1} x_{3} x_{4})^{2}
\end{multline*} \end{setlength}
which typesets as
Notice that the second variant is not indented. Any line of a multline environment can be typeset flush left or right by making
it the argument of a \shoveleft or \shoveright command, respectively (same with multline*). For instance, to typeset the second line of formula (4) flush left, as in
(x 1 x 2 x 3 x 4 x 5 x 6 ) 2
+ (x 1 x 2 x 3 x 4 x 5 +x 1 x 3 x 4 x 5 x 6 +x 1 x 2 x 4 x 5 x 6 +x 1 x 2 x 3 x 5 x 6 ) 2 + (x 1 x 2 x 3 x 4 +x 1 x 2 x 3 x 5 +x 1 x 2 x 4 x 5 +x 1 x 3 x 4 x 5 ) 2
type the formula as follows: \begin{multline*}
(x_{1} x_{2} x_{3} x_{4} x_{5} x_{6})^{2}\\ \shoveleft{+ (x_{1} x_{2} x_{3} x_{4} x_{5}
+ x_{1} x_{3} x_{4} x_{5} x_{6} + x_{1} x_{2} x_{4} x_{5} x_{6} + x_{1} x_{2} x_{3} x_{5} x_{6})^{2}}\\ + (x_{1} x_{2} x_{3} x_{4} + x_{1} x_{2} x_{3} x_{5} + x_{1} x_{2} x_{4} x_{5}
+ x_{1} x_{3} x_{4} x_{5})^{2} \end{multline*}
Observe that the entire line is the argument of the \shoveleft command, which is followed by \\ unless it is the last line of the environment.
9.4 Some general rules 215