Greetings LaTeX Masters!
In the code below, I'm trying to align the solution steps on the equal sign. The alignment works until I get to the final step where I draw a box around the solution. This line of code doesn't draw the box:
\boxed{x&=2} and crashes the compiler.
Without the &, the solution box doesn't align.
[![Mis-aligned solution box][1]][1]
\documentclass{article}
\usepackage{mathtools}
\usepackage{amsmath}
\begin{document}
Trapezoids: Median line formula\
%\setcounter{equation}{2}
\begin{equation}
\setlength{\jot}{8pt}
\begin{aligned}
Median &= \dfrac{1}{2}(top + bottom)\
3x+1&=\dfrac{(2x+1)+(2x+5)}{2}\
2\cdot (3x+1)&=\Biggl(\dfrac{(2x+1)+(2x+5)}{2}\Biggr) \cdot \dfrac{2}{1}\
6x+2&=4x+6\
6x&=4x+4\
2x&=4\
\boxed{x=2}
\end{aligned}
\end{equation}
\end{document} ```
{...}around a&in any tex alignment – David Carlisle Apr 03 '23 at 19:45