I have an equation of the form: constant = f(parm, parm, ...) with a very long list of parameters, which I would like to automatically wrap (after a comma) at the end of each line such that the second and subsequent lines (of parameters) are aligned under right hand side of the equation. But I don't want to manually insert line breaks and \quads for each line. Is there a way to achieve this?
Here's what I would like it to look like, noting another bug whereby negative numbers at the start of a line (e.g. the second line) are rendered as " - 19...", rather than "-19...". I'd love to fix this bug too :) :
Here's the source that generated the above (including manual line breaks and \quads to produce the desired formatting)
\begin{aligned}
0 &= P(3,1152921504606846976,120,(0,\allowbreak2^{59},\allowbreak-3^{3}\cdot2^{57},\allowbreak3\cdot2^{59},\allowbreak5^{3}\cdot2^{56},\allowbreak-13\cdot2^{58},\allowbreak0,\allowbreak \\
&\quad -19\cdot2^{58},\allowbreak3^{3}\cdot2^{54},\allowbreak2^{55},\allowbreak0,\allowbreak3\cdot31\cdot2^{53},\allowbreak0,\allowbreak2^{53},\allowbreak-7^{2}\cdot2^{52},\allowbreak-19\cdot2^{54},\allowbreak0,\allowbreak-13\cdot2^{52},\allowbreak0,\allowbreak \\
&\quad -113\cdot2^{49},\allowbreak-3^{3}\cdot2^{48},\allowbreak2^{49},\allowbreak0,\allowbreak-5^{3}\cdot2^{47},\allowbreak-5^{3}\cdot2^{46},\allowbreak2^{47},\allowbreak-3^{3}\cdot2^{45},\allowbreak3\cdot2^{47},\allowbreak0,\allowbreak-13\cdot2^{46},\allowbreak \\
&\quad 0,\allowbreak-19\cdot2^{46},\allowbreak3^{3}\cdot2^{42},\allowbreak2^{43},\allowbreak5^{3}\cdot2^{41},\allowbreak3\cdot31\cdot2^{41},\allowbreak0,\allowbreak2^{41},\allowbreak3^{3}\cdot2^{39},\allowbreak-3^{3}\cdot2^{39},\allowbreak0,\allowbreak-13\cdot2^{40},\allowbreak \\
&\quad 0,\allowbreak3\cdot2^{39},\allowbreak7^{2}\cdot2^{37},\allowbreak2^{37},\allowbreak0,\allowbreak-5^{3}\cdot2^{35},\allowbreak0,\allowbreak2^{35},\allowbreak-3^{3}\cdot2^{33},\allowbreak3\cdot2^{35},\allowbreak0,\allowbreak-13\cdot2^{34},\allowbreak-5^{3}\cdot2^{31},\allowbreak \\
&\quad -19\cdot2^{34},\allowbreak3^{3}\cdot2^{30},\allowbreak2^{31},\allowbreak0,\allowbreak-2^{34},\allowbreak0,\allowbreak2^{29},\allowbreak3^{3}\cdot2^{27},\allowbreak-19\cdot2^{30},\allowbreak-5^{3}\cdot2^{26},\allowbreak-13\cdot2^{28},\allowbreak0,\allowbreak \\
&\quad 3\cdot2^{27},\allowbreak-3^{3}\cdot2^{24},\allowbreak2^{25},\allowbreak0,\allowbreak-5^{3}\cdot2^{23},\allowbreak0,\allowbreak2^{23},\allowbreak7^{2}\cdot2^{22},\allowbreak3\cdot2^{23},\allowbreak0,\allowbreak-13\cdot2^{22},\allowbreak0,\allowbreak-3^{3}\cdot2^{19},\allowbreak \\
&\quad 3^{3}\cdot2^{18},\allowbreak2^{19},\allowbreak0,\allowbreak3\cdot31\cdot2^{17},\allowbreak5^{3}\cdot2^{16},\allowbreak2^{17},\allowbreak3^{3}\cdot2^{15},\allowbreak-19\cdot2^{18},\allowbreak0,\allowbreak-13\cdot2^{16},\allowbreak0,\allowbreak3\cdot2^{15},\allowbreak \\
&\quad -3^{3}\cdot2^{12},\allowbreak2^{13},\allowbreak-5^{3}\cdot2^{11},\allowbreak-5^{3}\cdot2^{11},\allowbreak0,\allowbreak2^{11},\allowbreak-3^{3}\cdot2^{9},\allowbreak-113\cdot2^{9},\allowbreak0,\allowbreak-13\cdot2^{10},\allowbreak0,\allowbreak \\
&\quad -19\cdot2^{10},\allowbreak-7^{2}\cdot2^{7},\allowbreak2^{7},\allowbreak0,\allowbreak3\cdot31\cdot2^{5},\allowbreak0,\allowbreak2^{5},\allowbreak3^{3}\cdot2^{3},\allowbreak-19\cdot2^{6},\allowbreak0,\allowbreak-13\cdot2^{4},\allowbreak5^{3}\cdot2,\allowbreak3\cdot2^{3},\allowbreak \\
&\quad -3^{3},\allowbreak2,\allowbreak0,\allowbreak0))
\end{aligned}
\quad
instruction before the-
(minus) symbols in question, TeX interprets the-
symbol as a binary rather than as a unary operator; hence the added space. If you wanted to persist with thealign
/manual line breaking approach, you'd have to change all instances of-
that follow\quad
to{-}
; this changes the math status of-
to "math-ordinary" instead of "math-bin", making TeX interpret the symbol as unary operator, as desired.