Problem with align command [closed]

I faced a weird situation when using "Align" command. Here is what I write

Since $l$ is fixed, $\sum_{k=0}^{l-1} k^i \cos (2k \theta)$ and $\sum_{k=0}^{l-1} k^i \sin (2k \theta)$ are bounded for $i=0,1,2$, using \textbf{Cor. 1.1.1} we have
\begin{align*}
B_W^2 &:= \mathrm{Var}(W'_n ( \theta))\\
&= \mathrm{Var} (- \sum_{j=0}^{m-1} \sum_{k=0}^{l-1} a_{2jl+k} ( (2j+1/2)l+k )  \sin ((2j+1/2)l+k) \theta ) \\
&= \sum_j \sum_k \left( (4j^2 + 2j +1/4)l^2 + (4j+1)lk +k^2 \right) \frac{1 - \cos ((4j+1)l + 2k) \theta}{2} \\
&= \frac{1}{2} \sum_j \left( l^3 (4j^2 + 2j +1/4) + \frac{l^3 -l^2 }{2}(4j+1) +  \frac{2l^3 - 3l^2 + l }{6} \right) \\
&- \frac{1}{2} \sum_j \sum_k \left( (4j^2 + 2j +1/4)l^2 + (4j+1)lk +k^2 \right) \cos ((4j+1)l + 2k) \theta \\
&= \frac{2l^3m^3}{3} + \mathcal{O}(m^2) - \frac{1}{2} \sum_j \sum_k \left( (4j^2 + 2j +1/4)l^2 + (4j+1)lk +k^2 \right) \cos ((4j+1)l + 2k) \theta \\
&= \frac{2l^3m^3}{3} + \mathcal{O}(m^2) - \frac{1}{2} \sum_j \sum_k \left( (4j^2 + 2j +1/4)l^2 + (4j+1)lk +k^2 \right) \cos (4j+1)l \theta \cos (2k) \theta \\
&+ \frac{1}{2} \sum_j \sum_k \left( (4j^2 + 2j +1/4)l^2 + (4j+1)lk +k^2 \right) \sin (4j+1)l \theta \sin (2k) \theta \\
&= \frac{n^3}{12} + \mathcal{O}(n^2) - \frac{l^2}{2} (4P_2 (l \theta ) + 2P_1 (l \theta ) + 1/4) \sum_k \cos (2k) \theta \\
&+ \frac{l^2}{2} (4Q_2 (l \theta ) + 2Q_1 (l \theta ) + 1/4) \sum_k \sin (2k) \theta - \frac{l}{2} (4P_1 (l \theta ) + 1) \sum_k k \cos (2k) \theta \\
&+ \frac{l}{2} (4Q_1 (l \theta ) + 1) \sum_k k \sin (2k) \theta - \frac{1}{2} P_0 (l \theta ) \sum_k k^2 \cos (2k) \theta + \frac{1}{2} Q_0 (l \theta ) \sum_k k^2 \sin (2k) \theta \\
&= \frac{n^3}{12} + \mathcal{O}(n^2)+ \mathcal{O}(\frac{m^2}{\epsilon}) = \frac{n^3}{12} + \mathcal{O}(n^2).
\end{align*}


but there is huge gap between the last sentence and the next line as you see in the picture. What shall I do? P.S. When I add \newpage, everything is back to normal. I thing the problem is with margins or something like that.

closed as off-topic by Henri Menke, Troy, ebosi, Stefan Pinnow, CarLaTeXJun 22 '17 at 4:04

• This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

• Please edit your question so that we have a complete MWE - a minimum working example. That's a compilable document edited down as small as can be that still shows the problem. – Ethan Bolker Jun 21 '17 at 23:59
• Add \raggedbottom after \begin{document}. – Henri Menke Jun 22 '17 at 0:05
• @ Henri It solved the problem. Thanks a lot. – Aleph-null Jun 22 '17 at 0:57
• I'm voting to close this question as off-topic because the problem was caused by unbreakable material after the alignment which was not part of the MWE. This will most likely not be useful to future readers. – Henri Menke Jun 22 '17 at 1:02

This is because of the texts and floats around the equation, not the equation itself. What LaTeX is doing is fill the page by stretching the space between the text and the equation. Check this:

Now remove some text from the paragraph after the equation:

LaTeX has increased the white space. Why? Because it is trying to avoid line breaking so it tries to fill the column with whole paragraphs.

Now remove more text:

As you can see, removing more text caused the section of the next column to be written after the paragraph. Three lines aren't really that bad in terms of their appearance so latex accepts that. Otherwise, LaTeX will push the conclusions section to the next column and try to fill the first column by increasing the white space.

The solution here is to work on what is around the equation, including floats, not only the text itself. Also, try tuning these parameters in the preamble.

\predisplaypenalty=1000: penalty for breaking before an equation (default: 1000) \postdisplaypenalty=0: penalty for breaking after an equation (default: 0)

• How is adjusting \predisplaypenalty and \postdisplaypenalty going to affect unbreakable material after an equation? – Henri Menke Jun 22 '17 at 1:20
• it's very strange that there is more space above the equation than below. you don't happen to have a blank line before the equation, do you? it you don't, then i would like to see the exact input, because in that case, this looks either like a bug, or the preset skips above and below the display have been modified. – barbara beeton Jun 22 '17 at 1:25
• @barbarabeeton The math italics PMARE and max suggest strongly that this is a cause of erroneous input. – Henri Menke Jun 22 '17 at 1:46
• What you wrote about linebreaking is wrong. The issue is caused by 'flushbottom' option used it books. Also, use the command '\max' to typeset max in roman. – Michael Fraiman Jun 22 '17 at 7:21
• @HenriMenke -- oh, i agree that there is erroneous input, but since we haven't seen what it was, the question about the blank line still stands -- if there wasn't a blank line, then the definition of the skips must be questioned, and that's not an area that a novice usually meddles with, although the suggestion regarding the penalties hints that this person may have done so. in any event, the spacing above and below the equation is just plain wrong, and i would like to know why. – barbara beeton Jun 22 '17 at 12:16