# How can I split an equation over two (or more) lines

I am having the following equation:

\begin{equation}
Q(\lambda,\hat{\lambda}) = -\frac{1}{2} P(O \mid \lambda ) \sum_s \sum_m \sum_t \gamma_m^{(s)} (t) \left( n \log(2 \pi ) + \log \left| C_m^{(s)} \right| + \left( \mathbf{o}_t - \hat{\mu}_m^{(s)} \right) ^T C_m^{(s)-1} \left(\mathbf{o}_t - \hat{\mu}_m^{(s)}\right) \right)
\end{equation}


which does not very well fit on one line. How can I split this over two lines? What I have in mind is that I specify the splitting place, and that the first line is left aligned and the second line right aligned to make clear that it is still the same equation.

The linebreak \\ does not work.

• For those who come to this question looking for a way to center each line of a multi-line equation, see this answer to another question--or one of the other answers to that question.
– Mars
Aug 17, 2017 at 21:02
• \begin{gather} ... \end{gather} Mar 30, 2019 at 12:23

Use either breqn to break lines automatically or use amsmath and its many environments exactly for this purpose. For example, with breqn:

\documentclass{article}
\usepackage{breqn}
\begin{document}
\begin{dmath}
Q(\lambda,\hat{\lambda}) = -\frac{1}{2} P{(O \mid \lambda )} \sum_s \sum_m \sum_t \gamma_m^{(s)} (t) \left( n \log(2 \pi ) + \log \left| C_m^{(s)} \right| + \left( \mathbf{o}_t - \hat{\mu}_m^{(s)} \right) ^T C_m^{(s)-1} \left(\mathbf{o}_t - \hat{\mu}_m^{(s)}\right) \right)
\end{dmath}
\end{document}


Note, the expression around \mid required braces to prevent it from breaking at this point; I'm sure there is a better way to do that; anyway, here's the output: With amsmath, you need to specify the break points manually: (as others have also mentioned)

\usepackage{amsmath}
...
\begin{multline}
A+B+C+ \\ +D+E+F
\end{multline}


The users guide to amsmath is called amsldoc.pdf, but you can access it by typing texdoc amsmath on the command line. The main environments you'll use there would be align, split, and multline.

• You should also mention split, that does in a cleaner way what I used to do with align. Oct 6, 2010 at 1:57
• I noticed that breqn does not align the second part(broken part) of the equation to the right by itself. This can be noticed when you have a short first term in which case it is center aligned. Is there a way to align it to the right explicitly? Dec 4, 2012 at 15:51
• The package unfortunately has huge incompatibility issues. Jan 30, 2015 at 8:33
• @MateusAraújo What is cleaner about split? Oct 30, 2015 at 10:35
• Why is it called multline instead of multiline. I misspelt it at first :(
– xji
Jun 13, 2018 at 21:48

You can use multline or split provided by amsmath package.

• Use multline to split equations without alignment (first line left, last line right)
• Use split to split equations with alignment

Here are examples: The corresponding source code is as follows:

(i).Use equation:
\begin{equation}
1+2+3+4+8x+7=1+2+3+4+4x+35 \\
\Rightarrow x=7
\end{equation}

(ii).Use \emph{multline} to split equations without alignment:
\begin{multline}
1+2+3+4+8x+7=1+2+3+4+4x+35 \\
\Rightarrow x=7
\end{multline}

(iii).Use \emph{split} to split equations with alignment
\begin{equation}
\begin{split}
1+2+3+4+8x+7 & =1+2+3+4+4x+35 \\
& \Rightarrow x=7
\end{split}
\end{equation}


For more info, you can refer to User’s Guide for the amsmath Package.

• Why does multline give the equation number on the second line rather than in the middle like split does? Sep 15, 2016 at 13:58
• For multline the tag placement is fixed: first line if leqn, last line if reqno. For split the placement is customizable. By default, the centertags option, tags are centered vertically. The tbtags option makes the placement the same as multline. Feb 16, 2017 at 10:02
• Tip: Look carefully: There is no "i" in "multline".
– Mars
Aug 17, 2017 at 20:43
• I think that was at least the second time that I found this answer (which I'd forgotten) and was puzzled when I got an error from "multiline".
– Mars
Aug 18, 2017 at 16:07
• But without '&' split is similar to multi-line. Apr 1, 2019 at 1:10

First line left, last line right—that is the multline environment:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{multline}
Q(\lambda,\hat{\lambda}) = -\frac{1}{2} P(O \mid \lambda ) \sum_s \sum_m \sum_t \gamma_m^{(s)} (t) \biggl( n \log(2 \pi ) \\
+ \log \left| C_m^{(s)} \right| + \left( \mathbf{o}_t - \hat{\mu}_m^{(s)} \right) ^T C_m^{(s)-1} \left(\mathbf{o}_t - \hat{\mu}_m^{(s)}\right) \biggr)
\end{multline}
\end{document}

• Environment multiline undefined. \begin{multiline}
– hola
Sep 24, 2018 at 6:56
• @pushpen.paul There's only one i in multline. This seems to be one of the most awful choices of naming in all of latex, given how many people instinctively want to put that second i in there. Feb 8, 2019 at 14:36

I often have the same problem, but opt for left-aligning on subsequent lines. In any case, I would suggest using the amsmath align environment. If I wanted right-aligning, here's what I would try (with white space liberally applied):

\begin{align}
Q(\lambda,\hat{\lambda})
= -\frac{1}{2} P(O \mid \lambda )
\sum_s \sum_m \sum_t \gamma_m^{(s)} (t)
\Biggl( n\log(2\pi)
\mspace{150mu}
\notag\\
+ \log \left| C_m^{(s)} \right|
+ \left( \mathbf{o}_t - \hat{\mu}_m^{(s)} \right)^T C_m^{(s)-1}
\left(\mathbf{o}_t - \hat{\mu}_m^{(s)}\right)
\Biggr)
\end{align}


Remarks:

• I replaced the outermost parentheses with large fixed-size parentheses, \Biggl( and \Biggr); scale these according to your taste.
• The \mspace command adds horizontal space in math mode, on the first line. Thus, the first line is not so much left-aligned, as it is right-aligned with a fixed amount of white-space added at the end. Vary this according to taste as well.
• You can split your equation across several lines by employing \notag\\ several times where desired.
• If you would prefer the equation number to straddle the two lines, as opposed to being placed on the last line, nest the mathematics inside a split environment (and omit the \notag commands); this would otherwise work verbatim.

[Edited to stand alone as a response]

• Could you share why? Is my english confusing? Oct 6, 2010 at 1:56
• @Mateus: Your English seemed fine to me, sorry if it seemed as though I were critiquing it! I meant the LaTeX code itself, which I had difficulty reading. From scanning it, it seemed to be mostly-different from what I was recommending; but as I was not totally certain, I was leaving open the possibility that I was posting essentially a duplicate answer. — I note that your answer is no longer visible: I hope you did not delete your response on my account. Oct 6, 2010 at 6:48
• The LaTeX code was similar, but not equal. For starters I used the alignment characters & and you didn't. But I deleted because it was a bad answer; with the split environment from amsmath you can manually specify the line breaks and positions, without having wrong numbering. Robertson's answer is way better. Oct 6, 2010 at 14:29
• If you indent lines by 4 spaces (as I did in my edit) instead of using <pre> and </pre>, then they are marked as a LaTeX code sample, which means they also get the nice syntax coloring. You can also highlight the code and click the "code" button (with "101010" on it). May 10, 2011 at 19:34

For future reference, when trying to remember the name for the multiline environment, which is very handy and does this automatically (or about as close to it as Latex can go) - just remember, it's multline:

\begin{multline}
I want my awesome formula to split lines here \\
so this next part is aligned to the right in the following line, looking smart.
\end{multline}

• Haha I think I added this answer just for myself, since I kept forgetting the name of the multline environment, since it's so stupid to not just call it multiline. Sep 29, 2014 at 16:32
• They saved on command name length! I used to work with someone who abbreviated things like "width", by writing "wdth" instead. Nov 29, 2016 at 16:11

One thing while working with multline if you are using \displaystyle is that you have to type it on each line otherwise you'll get an error

\begin{multline*}
K=\displaystyle{\frac{1}{2}m_1 L_1^2 \dot{\theta_1}^2+\frac{1}{2} m_2[L_1^2 \dot{\theta_1}^2+L_2^2 \dot{\theta_2}^2+2 L_1 L_2 \dot{\theta_1}\dot{\theta_2}\cos(\theta_1-\theta_2)]} \\
\displaystyle{+\frac{1}{2}m_3[L_1^2 \dot{\theta_1}^2+L_2^2 \dot{\theta_2}^2+L_3^2+ \dot{\theta_3}^2+2 L_1 L_2 \dot{\theta_1}\dot{\theta_2}\cos(\theta_1-\theta_2)}
\end{multline*}


Notice the \displaystyle for each new line

\documentclass[1pt]{article}

\begin{document}
\begin{tabular}{p{0.5cm}p{0.5cm}p{10cm}}
K &=&  $\frac{1}{2} m_1 L_1^2 \dot{\theta_1}^2 +\frac{1}{2} m_2[L_1^2 \dot{\theta_1}^2 +L_2^2 \dot{\theta_2}^2 +2 L_1 L_2 \dot{\theta_1}\dot{\theta_2}\cos(\theta_1-\theta_2)]$\\
&&$+\frac{1}{2}m_3[L_1^2 \dot{\theta_1}^2+L_2^2 \dot{\theta_2}^2+L_3^2+ \dot{\theta_3}^2+2 L_1 L_2 \dot{\theta_1} \dot{\theta_2}\cos(\theta_1-\theta_2)]$\\
\end{tabular}
\end{document}


This does not need any packages. You could try. Please send me your response.

• To much space around equal (=) sign. This is considered as bad typography. May 8, 2020 at 15:55

Kind of a hack solution (uses \hspace) from me which however, sticks to the amsmath alignat environment in order to maintain the alignment between the first and any further lines of the split equations. The first line (equation) in the attached image and the code is to indicate the alignment. \begin{alignat}{1}
\frac{d\tilde{x}}{dt} &= -(\tilde{x}+x_0)\{\tilde{x}^2 + (2x_0-2)\tilde{x} + (x_0^2-2x_0-\mu_0-\tilde{\mu})\} \nonumber \\
\frac{d\tilde{x}}{dt} &= -\{\tilde{x}^3 + (3x_0-2)\tilde{x}^2 + (3x_0^2-4x_0-\mu_0-\tilde{\mu})\tilde{x} \\
&{\hspace{12pt}} +(x_0^3 -2x_0^2 -x_0\mu_0 -x_0\tilde{\mu})\} \nonumber
\end{alignat}

• Welcome to tex.sx. However, the question asked for the first line of the broken equation to be shifted to the left, and the second line to the right. When multiple equations appear in the same display, the multlined environment can be used to set a broken one with left/right positioning (requires the mathtools package, which loads amsmath). Unfortunately, this doesn't automatically allow alignment of multiple equations; that can be done, but is more complicated. May 2 at 2:22