1

I want the equal sign aligned in the middle of the page and the -2ab completely to the right. This is what I have:

\begin{align*}
    (a+b)^2 & =  4 \cdot \frac{1}{2} ab + c^2  \\
    a^2 + 2ab + b^2 & = \cdot 2ab + c^2  & \vert - 2ab\\
    a^2 + b^2 & = c^2
\end{align*}

I already tried the \flushright and the \equation*command, but they don't work. Output

1 Answer 1

2

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}

enter image description here

Note that I used \mid instead of \vert: note the different spacing

$\mid-2ab$ vs. $\vert-2ab$enter image description here

1
  • Thank you! Yes, the cdot was misplaced.
    – Gesakom
    May 13, 2021 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.