TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am having the following 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)

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.

share|improve this question
Read this article on TUGboat and be enlightened. – Willie Wong Oct 5 '10 at 14:19
up vote 93 down vote accepted

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

  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)

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:

alt text

With amsmath, you need to specify the break points manually: (as others have also mentioned)

  A+B+C+ \\ +D+E+F 

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.

share|improve this answer
You should also mention split, that does in a cleaner way what I used to do with align. – Mateus Araújo Oct 6 '10 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? – Shafi Dec 4 '12 at 15:51
Note that the environment is multline not multiline. I spent about an hour trying to figure out what was wrong. – user545424 Mar 26 '14 at 2:34
The package unfortunately has huge incompatibility issues. – Troy Woo Jan 30 '15 at 8:33
@MateusAraújo What is cleaner about split? – Travis Bemrose Oct 30 '15 at 10:35

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

  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)
share|improve this answer

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):

  = -\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)


  • 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]

share|improve this answer
Could you share why? Is my english confusing? – Mateus Araújo Oct 6 '10 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. – Niel de Beaudrap Oct 6 '10 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. – Mateus Araújo Oct 6 '10 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). – doncherry May 10 '11 at 19:34

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:

enter image description here

The corresponding source code is as follows:

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

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

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

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

share|improve this answer

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:

 I want my awesome formula to split lines here \\ 
           so this next part is aligned to the right in the following line, looking smart. 
share|improve this answer
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. – gakera Sep 29 '14 at 16:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.