# Word-wrapping page-long polynomials in latex

I know that you can enter multiline equations using the align environment and line breaks (\\).

I want to LaTeX multiple polynomials that are very long (up to a page in length, single-spaced and 12 point font) without having to manually insert each line break. Even if I went through the trouble once, I'd have to do it all over again just to reformat the document.

Is there a way to do this, or do I have to use something like the verbatim environment or the listings environment, where the polynomials just become text?

-
Welcome to TeX.sx! A tip: you can use backticks  to mark your inline code as I did in my edit. –  doncherry Jul 18 '11 at 9:04

Displayed math can't be broken automatically, but in-line math can. So you can try something like

\newenvironment{polynomial}
{\par\vspace{\abovedisplayskip}%
\setlength{\leftskip}{\parindent}%
\setlength{\rightskip}{\leftskip}%
\medmuskip=4mu plus 2mu minus 2mu
\binoppenalty=0
\noindent$\displaystyle} {$\par\vspace{\belowdisplayskip}}


and put your long polynomial in the newly defined environment.

-

Have a look at the breqn package, I used it few years back briefly with good results. There is also a presentation which shows a few eqs.

(I find it rather inconvenient that docstrip documentation just describe packages without actually showing what they output. Sigh.)

-
Just found out that there is breqn tag at tex.stackexchange. –  eudoxos Jul 18 '11 at 9:46

if you're using amsmath, there's a command \allowdisplaybreaks that would work in an align environment (though not in the aligned sub-environment). it's documented in the amsmath user's guide on pp.8-9. the recommendation is to put

\allowdisplaybreaks[1]


in your preamble if you want it to work throughout the document.

-

You may also use the breqn environment to break the equation across many lines. Example taken from the breqn user guide.

\documentclass{article}

\usepackage{mathpazo}
\usepackage[mathpazo]{flexisym}
\usepackage{breqn}

\begin{document}

\begin{dmath}[label={sna74}]
\frac{1}{6} \left(\sigma(k,h,0) +\frac{3(h-1)}{h}\right)
+\frac{1}{6} \left(\sigma(h,k,0) +\frac{3(k-1)}{k}\right)
=\frac{1}{6} \left(\frac{h}{k} +\frac{k}{h} +\frac{1}{hk}\right)
+\frac{1}{2} -\frac{1}{2h} -\frac{1}{2k},
\end{dmath}

\end{document}


Note that, according to the user guide, the breqn class only supports the mathpazo and mathptmx packages, but that could have changed since the document was written.

Like I mentioned in my previous post, the dmath environment is similar to the equation environment, except that it supports line breaking and variant numbers (i.e. equation numbering). To avoid number variants, use the dmath* environment. See the breqn` user guide for other environments.

Hope this helps (and that the format is easier to read).

-