TransWikia.com

Word-wrapping page-long polynomials in latex

TeX - LaTeX Asked by DCT on May 25, 2021

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?

4 Answers

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

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

and put your long polynomial in the newly defined environment.

Correct answer by egreg on May 25, 2021

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.)

Answered by eudoxos on May 25, 2021

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.

Answered by barbara beeton on May 25, 2021

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).

Answered by Bill on May 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP