Wednesday, February 3, 2021

QuickTip: LaTeX multiline equations with explanations

Sometimes you want to write a sequence of steps, and write the explanation for each step next to it.

abc = xyz    pythagoras rule

    = uvw    triangle inequality

    = ABC    

It is easy to do this with the amsmath package as detailed in this StackOverflow question.
\usepackage{amsmath}

\begin{align*}
abc &= xyz \\
    &= uvw && \text{pythagoras rule} \\
    &= D   && \text{triangle inequality} \\
    &= ABC && 
\end{align*}