3

I want my equations to be typeset inside one amsmath environment and all be numbered. For this, I decided to use gather environment. But I ran into problem, that it break page when equations altogether don't fit. I want that every equation can turn out to be on a separate page. This is my mwe. In this example, equations protrude into the bottom boundary.

\documentclass[fleqn]{article}

\usepackage{amsmath}
\usepackage{lipsum}

\begin{document}

\lipsum

\begin{gather}
    \sigma^2_w(t) = p_1(t) \sigma^2_1(t) + p_2(t) \sigma^2_2(t) \\[\baselineskip]
    p(i) = \frac{N_i}{N} \\[\baselineskip]
    p_1(t) = \sum^{t}_{i=1} p(i) \\[\baselineskip]
    p_2(t) = \sum^{256}_{i=t+1} p(i) = 1 - p_1(t) \\[\baselineskip]
    \mu_1(t) = \sum^{t}_{i=1} \frac{ip(i)}{p_1(t)} \\[\baselineskip]
    \mu_2(t) = \sum^{256}_{i=t+1} \frac{ip(i)}{p_2(t)} \\[\baselineskip]
    \sigma^2_1(t) = \sum^{t}_{i=1} [i - \mu_1(t)]^2 \frac{p(i)}{p_1(t)} \\[\baselineskip]
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\[\baselineskip]
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\[\baselineskip]
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\[\baselineskip]
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\[\baselineskip]
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\[\baselineskip]
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\[\baselineskip]
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\[\baselineskip]
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\[\baselineskip]
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\[\baselineskip]
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\[\baselineskip]
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\[\baselineskip]
\end{gather}

\end{document}
1
  • 4
    Use \allowdisplaybreaks
    – Mane32
    Commented Jun 13 at 17:36

1 Answer 1

4

You can use \allowdisplaybreaks during document preparation.

\documentclass[fleqn]{article}
\usepackage{amsmath}

\usepackage{lipsum}

\newcommand{\openupnext}[2]{%
  \AddToHookNext{env/#1/begin}{\setlength{\jot}{#2}}\ignorespaces
}

\allowdisplaybreaks

\begin{document}

\lipsum[1-2]
\openupnext{gather}{6pt}
\begin{gather}
    \sigma^2_w(t) = p_1(t) \sigma^2_1(t) + p_2(t) \sigma^2_2(t) \\
    p(i) = \frac{N_i}{N} \\
    p_1(t) = \sum^{t}_{i=1} p(i) \\
    p_2(t) = \sum^{256}_{i=t+1} p(i) = 1 - p_1(t) \\
    \mu_1(t) = \sum^{t}_{i=1} \frac{ip(i)}{p_1(t)} \\
    \mu_2(t) = \sum^{256}_{i=t+1} \frac{ip(i)}{p_2(t)} \\
    \sigma^2_1(t) = \sum^{t}_{i=1} [i - \mu_1(t)]^2 \frac{p(i)}{p_1(t)} \\
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)}
\end{gather}

\end{document}

You also see here how to add vertical space between rows (if you really want it; personally I don't think it's necessary).

You can check that the page is broken after equation 9.

When the document is in final form (for the text), you should comment out the \allowdisplaybreaks line and examine what you get, adding \displaybreak in the lines that you think are a good break point: this requires judgment and a machine won't do it better than you; usually worse, actually.

In this case, equation 9 seems a good place where to break, so you get

\documentclass[fleqn]{article}
\usepackage{amsmath}

\usepackage{lipsum}

\newcommand{\openupnext}[2]{%
  \AddToHookNext{env/#1/begin}{\setlength{\jot}{#2}}\ignorespaces
}

\begin{document}

\lipsum[1-2]
\openupnext{gather}{6pt}
\begin{gather}
    \sigma^2_w(t) = p_1(t) \sigma^2_1(t) + p_2(t) \sigma^2_2(t) \\
    p(i) = \frac{N_i}{N} \\
    p_1(t) = \sum^{t}_{i=1} p(i) \\
    p_2(t) = \sum^{256}_{i=t+1} p(i) = 1 - p_1(t) \\
    \mu_1(t) = \sum^{t}_{i=1} \frac{ip(i)}{p_1(t)} \\
    \mu_2(t) = \sum^{256}_{i=t+1} \frac{ip(i)}{p_2(t)} \\
    \sigma^2_1(t) = \sum^{t}_{i=1} [i - \mu_1(t)]^2 \frac{p(i)}{p_1(t)} \\
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} 
\displaybreak \\
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)} \\
    \sigma^2_2(t) = \sum^{256}_{i=t+1} [i - \mu_2(t)]^2 \frac{p(i)}{p_2(t)}
\end{gather}

\end{document}

You must log in to answer this question.

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