# Describing steps in an equation

I am always describing the steps on how a formula is achieved or describing the underlying Mathematical principles taken to solve a problem in the align environment. But the descriptions are not displayed in the best manner possible. For example:

\documentclass[letterpaper]{article}
\usepackage{fullpage}
\usepackage{amsmath,amssymb,amsthm,enumitem}
\usepackage[dvipsnames]{xcolor}
\newcommand{\red}[1]{%
{\color{OrangeRed}#1}}

\begin{document}
Let us show that by completing the square, we can achieve this.
\begin{align*}
f(x)&=ax^2+bx+c \qquad\qquad\qquad\qquad\qquad\mbox{ Factor $a$ from $ax^2+bx$. Do you know why?}\\
&=a\left(x^2+\frac{b}{a}x\right)+c\qquad\qquad\qquad\qquad\mbox{ \red{Complete the square by adding $\frac{b^2}{4a^2}$.}} \\
&=a\left(x^2+\frac{b}{a}x+\red{\frac{b^2}{4a^2}} \right)+c\red{-a\left(\frac{b^2}{4a^2}\right)}\mbox{~~~Factor and simplify.}\\
&=a\left(x+\frac{b}{2a}\right)^2+c-\frac{b^2}{4a}\\
&=a\left(x+\frac{b}{2a}\right)^2+\frac{4ac-b^2}{4a}\\
&=a(x-h)^2+k
\end{align*}
\end{document}

yeilds:

which does not display the description properly. If you notice in my code above, I am forcing the descriptions to have a left indent based on the longest line of math display (where the a\left(x^2+\frac{b}{a}x+\red{\frac{b^2}{4a^2}} \right)+c\red{-a\left(\frac{b^2}{4a^2}\right)} is found.)

Now here is a different scenario:

\documentclass[letterpaper]{article}
\usepackage{fullpage}
\usepackage{amsmath,amssymb,amsthm,enumitem}
\usepackage[dvipsnames]{xcolor}
\newcommand{\red}[1]{%
{\color{OrangeRed}#1}}

\begin{document}
Let us apply completing the square to the standard form of a quadratic equation, $ax^2+bx+c=0$.

\begin{align*}

\documentclass[letterpaper]{article}
\usepackage{fullpage}
\usepackage{amsmath,amssymb,amsthm,enumitem}
\usepackage[dvipsnames]{xcolor}
\newcommand{\red}[1]{%
{\color{OrangeRed}#1}}

\usepackage{tikz}
\usetikzlibrary{calc, arrows.meta, bending, decorations.pathreplacing}

\usepackage{witharrows}

\begin{document}
Let us apply completing the square to the standard form of a quadratic equation, $ax^2+bx+c=0$.

$\begin{WithArrows} ax^2+bx+c&=0 \Arrow{Divide by a, the leading coefficient.}\\ x^2+\frac{b}{a}x+\frac{c}{a}&=0 \Arrow{Transpose the constant term to the RHS.}\\ x^2+\frac{b}{a}x&=-\frac{c}{a} \Arrow[tikz=OrangeRed]{Add \left(\frac{1}{2}\left(\frac{b}{a}\right)\right)^2 to both sides.}\\ x^2+\frac{b}{a}x+\frac{b^2}{4a^2}&=-\frac{c}{a}+\frac{b^2}{4a^2} \Arrow{Factor the LHS and simplify the RHS.}\\ \left(x+\frac{b}{a}\right)^2&=\frac{b^2-4ac}{4a^2} \Arrow{Take the square root of both sides.}\\ x+\frac{b}{a}&=\pm\frac{\sqrt{b^2-4ac}}{2a} \Arrow{Solve for x.}\\ x&=\frac{-b\pm\sqrt{b^2-4ac}}{2a} \end{WithArrows}$ \end{document}

Note: Package documentation doesn't mention it, but we should load TikZ and calc, arrows.meta, bending, decorations.pathreplacing tikzlibraries to use WithArrows environment.