# Annoying long equations in LaTeX

I am giving up on this long and annoying equation. I tried in so many different ways to try to fit into my page, but no success so far...Any suggestions, please? How to break down this long equation and fit into my page?

Here is my equation:

\begin{align}
\delta _{E}^{2}(\textbf{u})=E\left \{Z^{*}(\textbf{u})-Z(\textbf{u})\right\}
=E\left \{[Z^{*}(\textbf{u})^2]  \right \}-2\cdot E\left \{Z ^{*}(\textbf{u})\cdot Z(\textbf{u})  \right \} +E\left \{ [Z(\textbf{u})]^2 \right \}
=\sum_{\alpha =1}^{n}\sum_{\beta =1}^{n}\lambda _{\alpha }\lambda _{\beta }E\left \{ Z(\textbf{u}_{\alpha })\cdot Z(\textbf{u}_{\beta}) \right \}-2\cdot\sum_{\alpha =1}^{n} \lambda _{\alpha }E\left \{ Z(\textbf{u})\cdot Z(\textbf{u}_{\alpha }) \right \}+C(0)
=C(0)-2\cdot \sum_{\alpha =1}^{n}\lambda _{\alpha }C(\textbf{u},\textbf{u}_{\alpha})+\sum_{\alpha =1}^{n}\sum_{\beta =1}^{n}\lambda _{\alpha }\lambda _{\beta }C
(\textbf{u}_{\alpha}\textbf{u}_{\beta)}
\end{align}

• I've edited your syntax highlighting, but the %\end{align} is wrong. As well as \textbf{..} – user31729 Dec 13 '15 at 21:30
• I have made a mistake and guess deleted your edited code accidentally..apologies. – Sally7874 Dec 13 '15 at 21:32
• You're not using a single feature of the align environment actually – user31729 Dec 13 '15 at 21:33
• that "align" gives you--the equation(s) to be numbered, let's say if you have more than one equation and they are linked to each other i.e. 1.1, 1.2...1.n? – Sally7874 Dec 13 '15 at 21:35
• @Sally7874 you should only use align if you have alignment points (&) just use equation for a single equation. Your question would be much clearer if you provided a complete small document (as in Christian's answer) in particular you ask to make it fit into the page without saying how wide the page is. – David Carlisle Dec 13 '15 at 21:51

I propose a variant solution, based on flalign, that fits all equations on one line. I removed some unnecessary (from my point of view) \cdots:

\documentclass{article}

\usepackage{mathtools}

\begin{document}

\begin{flalign}
\mathrlap{ \delta _{E}^{2}(\mathbf{u})=E\left \{Z^{*}(\mathbf{u})-Z(\mathbf{u})\right\}}\\
& & & =E\left \{[Z^{*}(\mathbf{u})^2] \right \}-2\, E\left \{Z ^{*}(\mathbf{u})\cdot Z(\mathbf{u}) \right \} +E\left \{ [Z(\mathbf{u})]^2 \right \} \\
& & & =\sum_{\alpha =1}^{n}\sum_{\beta =1}^{n}\lambda _{\alpha }\lambda _{\beta }E\left \{ Z(\mathbf{u}_{\alpha })\cdot Z(\mathbf{u}_{\beta}) \right \}-2\sum_{\alpha =1}^{n} \lambda _{\alpha }E\left \{ Z(\mathbf{u})\cdot Z(\mathbf{u}_{\alpha }) \right \}+C(0) \\
& & & =C(0)-2\smash[t]{ \sum_{\alpha =1}^{n}}\lambda _{\alpha }C(\mathbf{u},\mathbf{u}_{\alpha})+\smash[t]{\sum_{\alpha =1}^{n}\sum_{\beta =1}^{n}}\lambda _{\alpha }\lambda _{\beta }C(\mathbf{u}_{\alpha}\mathbf{u}_{\beta})
\end{flalign}

\end{document}


Using align with \\ will improve the look, but the 3rd equation is still too wide.

Using split within align will improve that 3rd. equation as well.

\documentclass{article}

\usepackage{mathtools}

\newcommand{\tbf}[1]{\mathbf{#1}}}

\begin{document}

\begin{align}
\delta _{E}^{2}(\tbf{u})& =E\left \{Z^{*}(\tbf{u})-Z(\tbf{u})\right\}\\
&=E\left \{[Z^{*}(\tbf{u})^2]  \right \}-2\cdot E\left \{Z ^{*}(\tbf{u})\cdot Z(\tbf{u})  \right \} +E\left \{ [Z(\tbf{u})]^2 \right \} \\
&=\sum_{\alpha =1}^{n}\sum_{\beta =1}^{n}\lambda _{\alpha }\lambda _{\beta }E\left \{ Z(\tbf{u}_{\alpha })\cdot Z(\tbf{u}_{\beta}) \right \}-2\cdot\sum_{\alpha =1}^{n} \lambda _{\alpha }E\left \{ Z(\tbf{u})\cdot Z(\tbf{u}_{\alpha }) \right \}+C(0) \\
&=C(0)-2\cdot \sum_{\alpha =1}^{n}\lambda _{\alpha }C(\tbf{u},\tbf{u}_{\alpha})+\sum_{\alpha =1}^{n}\sum_{\beta =1}^{n}\lambda _{\alpha }\lambda _{\beta }C(\tbf{u}_{\alpha}\tbf{u}_{\beta)}
\end{align}

\begin{align}
\delta _{E}^{2}(\tbf{u})& =E\left \{Z^{*}(\tbf{u})-Z(\tbf{u})\right\}\\
&=E\left \{[Z^{*}(\tbf{u})^2]  \right \}-2\cdot E\left \{Z ^{*}(\tbf{u})\cdot Z(\tbf{u})  \right \} +E\left \{ [Z(\tbf{u})]^2 \right \} \\
\begin{split}\label{somelabel}
& =\sum_{\alpha =1}^{n}\sum_{\beta =1}^{n}\lambda _{\alpha }\lambda _{\beta }E\left \{ Z(\tbf{u}_{\alpha })\cdot Z(\tbf{u}_{\beta}) \right \} \\
& \quad -2\cdot\sum_{\alpha =1}^{n} \lambda _{\alpha }E\left \{ Z(\tbf{u})\cdot Z(\tbf{u}_{\alpha }) \right \}+C(0) \\
\end{split} \\
&=C(0)-2\cdot \sum_{\alpha =1}^{n}\lambda _{\alpha }C(\tbf{u},\tbf{u}_{\alpha})+\sum_{\alpha =1}^{n}\sum_{\beta =1}^{n}\lambda _{\alpha }\lambda _{\beta }C(\tbf{u}_{\alpha}\tbf{u}_{\beta)}
\end{align}

\end{document}


• I think split should be used – user31729 Dec 13 '15 at 21:38
• why \text{\textbf (\textbf would be the same but quicker , but I'd use \mathbf which is much quicker, and semantically purer, I think) – David Carlisle Dec 13 '15 at 21:48
• @DavidCarlisle: I rarely use \mathbf, actually, but I've changed it in the wrapper. – user31729 Dec 13 '15 at 21:50
• Not at all your fault, but the positioning of that C(0) gives the unfortunate first impression of an out of alignment - and out of sequence - equation number – Au101 Dec 13 '15 at 22:05
• @ChristianHupfer I think you should use split for the whole thing. – egreg Dec 13 '15 at 23:37

Be sure to tell LaTeX where the line breaks should occur and where on each line alignment should take place. In the example at hand, alignment should probably happen on the four = symbols, right?

Some suggestions to make the material a bit more compact so that even the longest line fits inside the available space:

• Omit the \cdot directives -- they take up a lot of space and, frankly, aren't needed for legibility.

• Load the mleftright package and issue the instruction \mleftright in the preamble. That way, the extra whitespace to the left of each \left directive and to the right of each \right directive is suppressed. Alternatively, you could simply omit all six \left and all six \right directives, since the curly braces they apply to don't need to be enlarged in the first place.

• Do arrange the elements in the third equation so that they correspond more naturally to those in the second and fourth equation.

• Since E is an operator, it should be set in an upright font shape. See the code below for an implementation of this idea.

• Use \mathbf instead of \textbf in math mode.

• Do fix the misplaced position of the very last ) symbol in the final line: It should be ... \mathbf{u}_{\beta}) instead of ...\mathbf{u}_{\beta)}, right?

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\E}{E}
\usepackage{mleftright}\mleftright
\begin{document}
\begin{align}
\delta_{\E}^{2}(\mathbf{u})
&= \E\left\{ Z^{*}(\mathbf{u})-Z(\mathbf{u})\right\} \\
&= \E\left\{ [Z^{*}(\mathbf{u})^2] \right\}-2 \E\left\{ Z ^{*}(\mathbf{u}) Z(\mathbf{u}) \right\} +\E\left\{ [Z(\mathbf{u})]^2 \right\} \\
&= C(0)-2\sum_{\alpha=1}^{n} \lambda_{\alpha}\E\left\{ Z(\mathbf{u}) Z(\mathbf{u}_{\alpha}) \right\} +\sum_{\alpha=1}^{n}\sum_{\beta=1}^{n}\lambda_{\alpha}\lambda_{\beta } \E\left\{ Z(\mathbf{u}_{\alpha}) Z(\mathbf{u}_{\beta}) \right\} \\
&= C(0)-2 \sum_{\alpha=1}^{n}\lambda_{\alpha}C(\mathbf{u},\mathbf{u}_{\alpha}) +\sum_{\alpha=1}^{n}\sum_{\beta=1}^{n} \lambda_{\alpha}\lambda_{\beta}  C(\mathbf{u}_{\alpha}\mathbf{u}_{\beta})
\end{align}
\end{document}


You can make use of the breakeqn package. You enclose the equation in the dmath environment. The package should be loaded after other packages dealing with maths, e.g., amsmath, amssymb, or packages such as mathpazo or mathptmx.

\documentclass{article}
\usepackage{mathtools}
% The breqn package should come after any maths packages.
\usepackage{breqn}

\begin{document}
% Like the equation environment but the dmath environment allows for line breaking.
\begin{dmath}
\delta_{E}^{2}(\textbf{u})=E\left \{Z^{*}(\textbf{u})-Z(\textbf{u})\right\}
=E\left \{[Z^{*}(\textbf{u})^2]  \right \}-2\cdot E\left \{Z ^{*}(\textbf{u})\cdot Z(\textbf{u})  \right \} +E\left \{ [Z(\textbf{u})]^2 \right \}
=\sum_{\alpha =1}^{n}\sum_{\beta =1}^{n}\lambda _{\alpha }\lambda _{\beta }E\left \{ Z(\textbf{u}_{\alpha })\cdot Z(\textbf{u}_{\beta}) \right \}-2\cdot\sum_{\alpha =1}^{n} \lambda _{\alpha }E\left \{ Z(\textbf{u})\cdot Z(\textbf{u}_{\alpha }) \right \}+C(0)
=C(0)-2\cdot \sum_{\alpha =1}^{n}\lambda _{\alpha }C(\textbf{u},\textbf{u}_{\alpha})+\sum_{\alpha=1}^{n}\sum_{\beta=1}^{n}\lambda _{\alpha }\lambda _{\beta }C(\textbf{u}_{\alpha}\textbf{u}_{\beta)}
\end{dmath}

\end{document}


The package should automate line breaking for you.