11

I have a very long equations inside

\begin{eqnarray}
   long equation go over 2 pages...
\end{eqnarray}

I can't break into two by

 \begin{eqnarray}
          1/n of long
    \end{eqnarray}
    \begin{eqnarray}
          b/n of long
    \end{eqnarray}

Unfortunately, the alignment is gone since the alignment of the second page is based on the first equation on the second page. I wonder is there a way to keep the same alignment for a really long equations?

roxrook
  • 9,907

1 Answers1

17

Instead of using eqnarray, use align (or any of the other environments provided by the amsmath package). During the document preparation, using \allowdisplaybreaks[1] in the preamble, allows an individual automatic page break inside displayed equations; a simple example:

\documentclass{article}
\usepackage[paperheight=4cm]{geometry}% just for the example
\usepackage{amsmath}

\allowdisplaybreaks[1]

\begin{document}

\begin{align*}
a &= b \\
&= c \\
&= c \\
&= c \\
&= c \\
&= c \\
&= c \\
&= c 
\end{align*}

\end{document}

enter image description here

As egreg mentions in his comment, once the document is finished, is best to suppress \allowdisplaybreaks[1] from the preamble and use \displaybreak inside the corresponding displayed equation and put it in the best place for the break (which may not be the one automatically chosen); this command is best placed immediately before the line change command where it is to take effect:

\documentclass{article}
\usepackage[paperheight=4cm]{geometry}% just for the example
\usepackage{amsmath}

\begin{document}

\begin{align*}
a &= b \\
&= c \\
&= c \\
&= c \displaybreak\\
&= c \\
&= c \\
&= c \\
&= c 
\end{align*}

\end{document}

The reasons for not using eqnarray can be found in Avoid eqnarray! by Lars Madsen.

Gonzalo Medina
  • 505,128
  • This is right when working on the document. In the final revision \allowdisplaybreaks should be disabled and \displaybreak put in the best place for a break, which may not be the one chosen automatically. – egreg Nov 29 '12 at 00:33
  • @egreg I added your comment to my answer. Thank you! – Gonzalo Medina Nov 29 '12 at 00:41
  • It would be nice if latex had a way to write displaybreak[30], which would change the breaking penalty. Then, you could put optional displaybreaks everywhere, and latex would choose the best one(s). – Neil G Dec 24 '12 at 06:57
  • Let me tell you that this site is awesome. Many of the things that I don't know how to do in LaTeX were already asked and answered by someone here in this site! :) – Vicent Jul 11 '14 at 21:21
  • Why \allowdisplaybreaks[1] should be avoided in the final document version? Why is it no good to leave it like that? – Vicent Jul 11 '14 at 21:24
  • @Vincent because the automatic break point produced by \allowdisplaybreaks[1] might not necessarily be the best one. – Gonzalo Medina Jul 11 '14 at 22:02