How to properly format a proof/explanation with multiple points of alignment?

This answered question addresses how to properly align/format a proof, allowing one to add text commentary alongside equations without ruining the alignment of the equations; however, it only seems to allow for one point of alignment in the equation and one point of alignment in the text, how can we get a similar result with multiple points of alignment?

eg. points of alignment for equations are indicated by an asterisk (*)

  *aaaaaaaaa *= bbbbbbbb
= *ccccccccc *= bbbbbbbb      comment or explanatory remark.
= *ddddddddd *= bbbbbbbb      second comment or explanatory remark.


Here is a hacked approximation of what I was trying to describe: Here:

• the column of \Rightarrow and = are right-aligned;
• the LHS of the equations are right-aligned;
• the column of = are left-aligned;
• the RHS of the equations are left-aligned;
• the text is also left-aligned.

Issues that I could not resolve even in this hacked example:

1. Ideally the the text would be pushed as far to the right as possible and have minimal effect on the horizontal centering of the equations (i.e. w.r.t. the page). It would be especially nice if it were possible to specify the width of the text column in such a way that text exceeding that width would automatically format justified and multi-lined, vertically centered about the corresponding line of math, but I imagine that's a bit of a pipe dream …

2. The final boxed form would be properly centered w.r.t. to the math above it. I realize it may not be possible to do this easily and so am open to any other means of clearly distinguishing the final form.

Here are two ways of doing things.

I define right aligned notes, that require using the flalign(*) environment and the \llap command. If there is enough white space to input a (short) note, you use the \shortrnote command. If there is not, you put the note on a line of its own.

Similarly, I define left aligned notes, that use the alignat(*) environment and the \rlap command. There are \shortlnote and \longlnote commands. If the note is very long, one has to replace \rlap with \clap — so that it's the middle of the note that is left aligned.

    \documentclass[ a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{mathtools}

\newcommand{\shortrnote}[1]{ &  & \text{\footnotesize\llap{#1}}}
\newcommand{\longrnote}[1]{ &  &  \\ \notag  &  &  &  &  & \text{\footnotesize\llap{#1}}}

\newcommand{\longlnote}[1]{   \\ \notag &  &  & \text{\footnotesize\rlap{#1}}}
\newcommand{\verylonglnote}[1]{   \\ \notag &  &  & \text{\footnotesize\clap{#1}}}

\begin{document}

Right aligned notes result  in this :
\begin{flalign}
&  & xyz  & = abc \\
&  &           abc  & = xyz  &  & \\
\shortintertext{next math group: }
&  &           cba &= abc \shortrnote{(A short note)} \\
& & (x + y + z)^{2} & = x^{2} + y^{2}  + z^{2}
\longrnote{(A longer note:  true only in characteristic 2)}
\end{flalign}

While left aligned notes give:
\begin{alignat}{2}
xyz  & = abc \\
abc  & = xyz  \\
\shortintertext{next math group: }
cba &= abc  \shortlnote{(A short note)}  \\
(x + y + z)^{2} & = x^{2} + y^{2}  + z^{2}\longlnote{(A somewhat longer note)}\\
(x + y + z)^{3} & = x^{3} + y^{3}  + z^{3}
\verylonglnote{(A really longer note:  true only in characteristic 3)}
\end{alignat}

With two alignment points:

\begin{alignat}{3}
xyz  & =  abc  &&  =  def\\
abc  & = xyz & &  =  uvw  \\
\shortintertext{next math group: }
cba & = xyzt   &  &  = acb \shortlnote{(A short note)}  \\
(x + y + z)^{3} & =  \mathrlap{x^{3} + y^ {3} + z^{3}}    &
\shortlnote{(In characteristic 3)} \\
(x + y + z)^{3} & =  \mathrlap{x^{3}+y^ {3} + z^{3}}
\longlnote{(True only in characteristic 3)}
\end{alignat}

\end{document}​


• Bernard - thank you kindly for the detailed reply; however, unless I'm missing something, this still only has a single point of alignment (at the equality symbol) and so is effectively the same as the cited Q&A. I have hacked together something that approximates the rendering I'm looking for and will add it to the question in order to help clarify. Please let me know if I've missed or misunderstood. – Rax Adaam Jul 30 '14 at 16:08
• I think my answer can be easily adapted, but it would indeed be nice to have more concrete examples to play with, so that the answer can be fine-tuned. – Bernard Jul 30 '14 at 16:19
• @Rax Adaam: I've added an example that shows what can be done with 2 alignment points. Hope this fits better what you want. – Bernard Jul 30 '14 at 18:43
• my apologies for the edit not coming through yesterday. I'm in a rural area with poor internet connectivity and it just wouldn't load. I believe it has updated now. Thank you for the multi-point example, I'll try it out now! – Rax Adaam Jul 31 '14 at 18:49
• Of course each case can be specific, but you have the general idea: using \(math)rlap or \(math)llap when necessary? – Bernard Jul 31 '14 at 19:14