2

Possible Duplicate:
How can I split an equation over two lines

I have a long equation,

$\operatorname{E} (Z_{n+1} - Z_n | X_1,..., X_n)
= \operatorname{E} (S_{n+1}^2 - (n+1) \sigma^2 - S_n^2 + n \sigma^2  | X_1,..., X_n)
= \operatorname{E} (S_{n+1}^2 - S_n^2 - (n+1) \sigma^2 + n \sigma^2  | X_1,..., X_n)
= \operatorname{E} (X_{n+1}(X_{n+1} + 2\sum_{i=1}^n X_i) - \sigma^2 | X_1,..., X_n)
= \operatorname{E} (X_{n+1}X_{n+1}) + 2\operatorname{E} (X_{n+1}) \sum_{i=1}^n X_i - \sigma^2
= \sigma^2  - \sigma^2 =0
$.

which I think causes warning:

Overfull \hbox (3.16257pt too wide)

Is there some way automatically line-break long equations? Or must I specify where to line-break? Thanks!

1
  • 2
    I think your question is answered here and here (possible duplicates). Commented Feb 18, 2011 at 13:55

2 Answers 2

2

You can specify linebreaking manually, as per Harald Hanche-Olsen's example. In some cases, breqn package can automatically break your lines (breqn is part of the MH bundle, see documentation on ctan).

Minimal example is:

\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{breqn}
\begin{document}
\begin{dmath*}
\operatorname{E} (Z_{n+1} - Z_n | X_1,..., X_n) 
    = \operatorname{E} (S_{n+1}^2 - (n+1) \sigma^2 - S_n^2 + n \sigma^2  | X_1,..., X_n) 
    = \operatorname{E} (S_{n+1}^2 - S_n^2 - (n+1) \sigma^2 + n \sigma^2  | X_1,..., X_n) 
    = \operatorname{E} (X_{n+1}(X_{n+1} + 2\sum_{i=1}^n X_i) - \sigma^2 | X_1,..., X_n) 
    = \operatorname{E} (X_{n+1}X_{n+1}) + 2\operatorname{E} (X_{n+1}) \sum_{i=1}^n X_i - \sigma^2 
    = \sigma^2  - \sigma^2 =0
\end{dmath*}
\end{document}

It will not be much help for your specific example. Example of output: breqn automatic linebreaking

As you can see, breqn did a good job with binary symbol +, but was not helpful with equal signs. That is in line with what Harald Hanche-Olsen said.

3
  • Thanks! Example of using breqn in my case please?
    – Tim
    Commented Feb 18, 2011 at 14:18
  • I expanded my answer in response to your question. It seems that Harald Hanche-Olsen already answered your question. Still, a reference to breqn might be helpful generally if not in this particular case.
    – ipavlic
    Commented Feb 18, 2011 at 15:12
  • That breqn output is strange; I thought it should have wanted to split the equation by the equals signs. The algorithm isn't perfect yet! Commented Feb 19, 2011 at 1:22
4

Equations can be broken at relation symbols and binary operators, so long as they are not enclosed in braces. In this case, however, I think it's better to use a displayed equation with line breaks of your own choosing:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
\operatorname{E} (Z_{n+1} - Z_n | X_1,..., X_n)
&= \operatorname{E} (S_{n+1}^2 - (n+1) \sigma^2 - S_n^2 + n \sigma^2 | X_1,..., X_n) \\
&= \operatorname{E} (S_{n+1}^2 - S_n^2 - (n+1) \sigma^2 + n \sigma^2 | X_1,..., X_n) \\
&= \operatorname{E} (X_{n+1}(X_{n+1} + 2\sum_{i=1}^n X_i) - \sigma^2 | X_1,..., X_n) \\
&= \operatorname{E} (X_{n+1}X_{n+1})
   + 2\operatorname{E} (X_{n+1}) \sum_{i=1}^n X_i - \sigma^2 \\
&= \sigma^2  - \sigma^2 =0.
\end{align*}
\end{document}

Running texdoc amsldoc on your system should give you more information on using the amsmath package.

2
  • Thanks! By "Equations can be broken at relation symbols and binary operators", do you mean automatically or manually? Could you give an xxample of using a displayed equation with line breaks?
    – Tim
    Commented Feb 18, 2011 at 14:19
  • @Tim: I expanded my answer in response to your second question. As to the first, I mean automatically. You can put a manual linebreak anywhere you like. Commented Feb 18, 2011 at 14:44

Not the answer you're looking for? Browse other questions tagged .