# Equation too long [duplicate]

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!

-
I think your question is answered here and here (possible duplicates). –  Hendrik Vogt Feb 18 '11 at 13:55

## marked as duplicate by Hendrik Vogt, lockstep, Caramdir, Joseph Wright♦Feb 18 '11 at 22:16

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:

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.

-
Thanks! Example of using breqn in my case please? –  Tim Feb 18 '11 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 Feb 18 '11 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! –  Will Robertson Feb 19 '11 at 1:22

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.

-
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 Feb 18 '11 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. –  Harald Hanche-Olsen Feb 18 '11 at 14:44