I'm trying to achieve a formatting similar to this:
So essentially I've got two points of alignment here, one between right end of = and left end of + resp. -, the other between right end of + resp. - and the actual terms. I've used monomials as terms here as an example, but in my actual application there might be arbitrary expressions in each of the terms. The example above I did typeset like this:
\begin{align*}
A =& \mathbin{\phantom+} 17\,a^2\,b^{16}\,c^5 \\
&+ 3\,a^2\,c^4\,d \\
&- a\,b^6 \\
B =& \mathbin{\phantom+} a^2\,b^6 \\
&- 5\,a\,b^7
\end{align*}
The \mathbin
was vital to get the spacing in the first row match that of the latter rows. One thing I like about this is that the implicit {}
after the alignment makes my + and - use spacing appropriate for binary use, instead of unary as you'd see at the beginning of a line.
Nevertheless, the way I wrote this doesn't satisfy all my expectations.
Conventionally one places the alignment point before the equals sign, i.e. writes
&=
instead of=&
. Looking at Spacing after equals sign in align for details, I think that with my approach above, the spacing between the = and the + will be that around a binary operator, not that around a relation. It's not as if I could tell just by looking at the result, though, particularly as they are not on the same line, so perhaps I need not worry.If I were to add equation numbering, then each row of this equation would be numbered independently. I think it would be cleaner to write something like
A &= \begin{…}…\end{…}
but I don't know of a suitable environment here.{gathered}
will center its content, both vertically and horizontally, while I would need it flushed left and aligned with the first line.In my context it would be even better if I could use this for inline math as well, in a way that aligns with the baseline of the first line. That's because if possible I'd like to place this formula inside a
{description}
environment, so I'd want the description label to line up with the first line of the formula. Might try a minipage if that doesn't work out another way, though.
Can you think of a way to improve one or more of the points mentioned above?