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:

  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

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.

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

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

  3. 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?

1 Answer 1


here are a couple of possibilities using alignat, with split added in to allow numbering.

  A ={}&&& 17\,a^2\,b^{16}\,c^5 \\
  &+{}&& 3\,a^2\,c^4\,d \\
  &-{}&& a\,b^6 \\
  B ={}&&& a^2\,b^6 \\
  &-{}&& 5\,a\,b^7
    A = \phantom{{}+{}}& 17\,a^2\,b^{16}\,c^5 \\
     {}+{}& 3\,a^2\,c^4\,d \\
     {}-{}& a\,b^6
 \end{split} \\
   B = \phantom{{}+{}}& a^2\,b^6 \\
      {}-{}& 5\,a\,b^7

output of example code

edit: the second example would more simply be entered with align rather than alignat. as @egreg explains in a comment, the single alignment point in the split is also taken as the alignment point for the align.

  • I must confess that I don't understand how the alignment between the equations works in that second example. The way I understand it, all your & there refer to the split, so how dows alignat know where to align?
    – MvG
    Commented Dec 7, 2016 at 13:50
  • hmmm. as i was working it out, i was just modifying a copy of the first example. you are on the right track -- alignat isn't necessary; align will do just as well. but neither equation nor gather would work, equation because more than one "line" is involved, and gather because the widths of the chunks are different. Commented Dec 7, 2016 at 14:13
  • 2
    @MvG split knows whether it is called in align or alignat, so it sets the alignment point to the overall one.
    – egreg
    Commented Dec 7, 2016 at 14:48
  • Your answer made me look at the difference between split and aligned, and egreg's answer there made me aware that I could write \begin{aligned}[t] to get top alignment, to cater for my use case in the definition list. Even found that option documented in amsldoc now. I haven't found docs for the alignment of split to its surroundings that @egreg described. Very useful to know, all of this!
    – MvG
    Commented Dec 7, 2016 at 15:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .