Typesetting one-step equations

The letters l and r stand for left-alignment and right-alignment respectively. Notice the columns are aligned rrlr. There are six columns because align and alignat are comprised of lr pairs, because alignment often involves hugging both sides of =. Whenever we are adding or subtracting from both sides, we want right alignment. The alignment of = doesn't matter. In this case, it was simpler to use l, but we could have used r for the same effect. Unfortunately, we can't use MathJax, because it doesn't support \cline, and every workaround makes the code god-awful.


\documentclass[margin=10pt]{standalone}
\begin{document}

$\arraycolsep=0pt
\begin{array}{rrcr}
x & {} + 3 & {} = {} &      7 \\
  & {} - 3 &         & {} - 3 \\
\cline{2-2}\cline{4-4}
x &        & = &      4
\end{array}$

\end{document}

Division problems are a bit different, because of the fraction bar. My preferred style mimics how I would solve such an equation on paper. Here it is:


$$\begin{align}
        \dfrac{x}{3} &= 24         \\[1em]
3 \cdot \dfrac{x}{3} &= 24 \cdot 3 \\[1em]
                   x &= 72
\end{align}$$
$$\begin{align} \dfrac{x}{3} &= 24 \\[1em] 3 \cdot \dfrac{x}{3} &= 24 \cdot 3 \\[1em] x &= 72 \end{align}$$

Also, important to note, if you want space to appear on both sides of the operator, yet only the second operand is present, you do {} + 3. If you want space on just one side of the operator, say, the right, do +\>3. I haven't found a reason to ever type this, but it might be useful later!