[Tex/LaTex] How to make long aligned equations wrap around automatically across lines and pages

equationssplit

I have a list of identities as follows.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
 \sum _{i=1}^n i&=\frac{1}{2} n (n+1) \\
 \sum _{i=1}^n i^2&=\frac{1}{6} n (n+1) (2 n+1) \\
 \sum _{i=1}^n i^3&=\frac{1}{4} n^2 (n+1)^2 \\
 \sum _{i=1}^n i^4&=\frac{1}{30} n (n+1) (2 n+1) \left(3 n^2+3 n-1\right) \\
 \sum _{i=1}^n i^5&=\frac{1}{12} n^2 (n+1)^2 \left(2 n^2+2 n-1\right) \\
 \sum _{i=1}^n i^6&=\frac{1}{42} n (n+1) (2 n+1) \left(3 n^4+6 n^3-3 n+1\right) \\
 \sum _{i=1}^n i^7&=\frac{1}{24} n^2 (n+1)^2 \left(3 n^4+6 n^3-n^2-4 n+2\right) \\
 \sum _{i=1}^n i^8&=\frac{1}{90} n (n+1) (2 n+1) \left(5 n^6+15 n^5+5 n^4-15 n^3-n^2+9 n-3\right) \\
 \sum _{i=1}^n i^9&=\frac{1}{20} n^2 (n+1)^2 \left(n^2+n-1\right) \left(2 n^4+4 n^3-n^2-3 n+3\right) \\
 \sum _{i=1}^n i^{10}&=\frac{1}{66} n (n+1) (2 n+1) \left(n^2+n-1\right) \left(3 n^6+9 n^5+2 n^4-11 n^3+3
   n^2+10 n-5\right) \\
 \sum _{i=1}^n i^{11}&=\frac{1}{24} n^2 (n+1)^2 \left(2 n^8+8 n^7+4 n^6-16 n^5-5 n^4+26 n^3-3 n^2-20
   n+10\right) \\
 \sum _{i=1}^n i^{12}&=\frac{n (n+1) (2 n+1) \left(105 n^{10}+525 n^9+525 n^8-1050 n^7-1190 n^6+2310
   n^5+1420 n^4-3285 n^3-287 n^2+2073 n-691\right)}{2730} \\
 \sum _{i=1}^n i^{13}&=\frac{1}{420} n^2 (n+1)^2 \left(30 n^{10}+150 n^9+125 n^8-400 n^7-326 n^6+1052
   n^5+367 n^4-1786 n^3+202 n^2+1382 n-691\right) \\
 \sum _{i=1}^n i^{14}&=\frac{1}{90} n (n+1) (2 n+1) \left(3 n^{12}+18 n^{11}+24 n^{10}-45 n^9-81 n^8+144
   n^7+182 n^6-345 n^5-217 n^4+498 n^3+44 n^2-315 n+105\right) \\
 \sum _{i=1}^n i^{15}&=\frac{1}{48} n^2 (n+1)^2 \left(3 n^{12}+18 n^{11}+21 n^{10}-60 n^9-83 n^8+226
   n^7+203 n^6-632 n^5-226 n^4+1084 n^3-122 n^2-840 n+420\right) \\
 \sum _{i=1}^n i^{16}&=\frac{1}{510} n (n+1) (2 n+1) \left(15 n^{14}+105 n^{13}+175 n^{12}-315 n^{11}-805
   n^{10}+1365 n^9+2775 n^8-4845 n^7-6275 n^6+11835 n^5+7485 n^4-17145 n^3-1519 n^2+10851 n-3617\right)
   \\
 \sum _{i=1}^n i^{17}&=\frac{1}{180} n^2 (n+1)^2 \left(10 n^{14}+70 n^{13}+105 n^{12}-280 n^{11}-565
   n^{10}+1410 n^9+2165 n^8-5740 n^7-5271 n^6+16282 n^5+5857 n^4-27996 n^3+3147 n^2+21702 n-10851\right)
   \\
 \sum _{i=1}^n i^{18}&=\frac{n (n+1) (2 n+1) \left(105 n^{16}+840 n^{15}+1680 n^{14}-2940 n^{13}-9996
   n^{12}+16464 n^{11}+48132 n^{10}-80430 n^9-167958 n^8+292152 n^7+380576 n^6-716940 n^5-454036
   n^4+1039524 n^3+92162 n^2-658005 n+219335\right)}{3990} \\
 \sum _{i=1}^n i^{19}&=\frac{1}{840} n^2 (n+1)^2 \left(42 n^{16}+336 n^{15}+616 n^{14}-1568 n^{13}-4263
   n^{12}+10094 n^{11}+22835 n^{10}-55764 n^9-87665 n^8+231094 n^7+213337 n^6-657768 n^5-236959
   n^4+1131686 n^3-127173 n^2-877340 n+438670\right) \\
 \sum _{i=1}^n i^{20}&=\frac{330 n^{21}+3465 n^{20}+11550 n^{19}-65835 n^{17}+426360 n^{15}-2238390
   n^{13}+8817900 n^{11}-24551230 n^9+44767800 n^7-47625039 n^5+24126850 n^3-3666831 n}{6930} \\
\end{align*}
\end{document}

enter image description here

How to make long aligned equations wrap around automatically across lines and pages? I want to print a list of the first 100 identities or more for fun.

Best Answer

(I've simplified the answer, to require the use of \parbox directive only on the right-hand side of the equations.)

Here's a solution that uses a \parbox for the material to the right of the &= particles; that way, LaTeX can insert linebreaks as needed. Note that it's necessary to

  • remove all \left and \right directives, as linebreaks are allowed in a group encased by \left( and \right). (In your equations, the \left and \right directives are superfluous anyway.), and to

  • modify the \frac{<very long expression>}{<number>} expressions to

    `\frac{1}{<number>}(<very long expression>)`
    

Finally, for the case of your set of equations, observe that linebreaks are really only needed from the 10th equation (or so) onwards.

enter image description here

\documentclass{article}
\usepackage{amsmath}  % for "align*" environment
\allowdisplaybreaks % allow page breaks, if needed
\usepackage{setspace} % for "\setstretch" macro

\newcommand\mybox[1]{\parbox[t]{0.75\textwidth}{%
    \setstretch{1.33}\raggedright$\displaystyle #1$}}

\begin{document}
\begin{align*}
\sum_{i=1}^n i  &=\tfrac{1}{2} n (n+1) \\
\sum_{i=1}^n i^2&=\tfrac{1}{6} n (n+1) (2 n+1) \\
\sum_{i=1}^n i^3&=\tfrac{1}{4} n^2 (n+1)^2 \\
\sum_{i=1}^n i^4&=\tfrac{1}{30}n(n+1)(2n+1)(3n^2+3n-1) \\
&\vdots \\
\sum_{i=1}^n i^9&=\mybox{\tfrac{1}{20} n^2 (n+1)^2 
   (n^2+n-1) (2 n^4+4 n^3-n^2-3 n+3)} \\
\sum_{i=1}^n i^{10}&=\mybox{\tfrac{1}{66} n (n+1) 
   (2 n+1) (n^2+n-1) (3 n^6+9 n^5+2 n^4-11 n^3+3
   n^2+10 n-5)} \\
&\vdots \\
\sum_{i=1}^n i^{19}&=\mybox{\tfrac{1}{840} n^2 (n+1)^2 
   (42 n^{16}+336 n^{15}+616 n^{14}-1568 n^{13}-4263 n^{12}
   +10094 n^{11}+22835 n^{10}-55764 n^9-87665 n^8+231094 n^7
   +213337 n^6-657768 n^5-236959 n^4+1131686 n^3
   -127173 n^2-877340 n+438670)} \\
\sum_{i=1}^n i^{20}&=\mybox{\tfrac{1}{6930}(330 n^{21}
   +3465 n^{20}+11550 n^{19}-65835 n^{17}+426360 n^{15}
   -2238390 n^{13}+8817900 n^{11}-24551230 n^9
   +44767800 n^7-47625039 n^5+24126850 n^3-3666831 n)} 
\end{align*}
\end{document}
Related Question