Two ways: abusing \tag
and using flalign
. (BTW the \cdot
after the equal sign looks misplaced.)
% twocolumn for smaller snapshot
\documentclass[twocolumn]{article}
\usepackage{amsmath}
\begin{document}
Abusing \verb+\tag+
\begin{align}
(a+b)^2 & = 4 \cdot \frac{1}{2} ab + c^2 \nonumber \\
a^2 + 2ab + b^2 & = \cdot 2ab + c^2 \tag*{$\mid - 2ab$} \\
a^2 + b^2 & = c^2 \nonumber
\end{align}
or with \verb+flalign*+
\begin{flalign*}
&& (a+b)^2 & = 4 \cdot \frac{1}{2} ab + c^2 \\
\phantom{ \mid- 2ab}&& a^2 + 2ab + b^2 & = \cdot 2ab + c^2 & \mid - 2ab \\
&& a^2 + b^2 & = c^2
\end{flalign*}
This is what happens with the second one if you don't use \verb+\phantom+
\begin{flalign*}
&& (a+b)^2 & = 4 \cdot \frac{1}{2} ab + c^2 \\
&& a^2 + 2ab + b^2 & = \cdot 2ab + c^2 & \mid - 2ab \\
&& a^2 + b^2 & = c^2
\end{flalign*}
\end{document}

Note that I used \mid
instead of \vert
: note the different spacing
$\mid-2ab$ vs. $\vert-2ab$
→ 