1

I am trying to get the last equation in a list of aligned equations boxed, however this is more challenging than I thought it might be. I would like to be able to do it with the box both including the equation number and without. Below are my current simple methods for framing equations. Any input is welcome and appreciated.

\documentclass{article}

\usepackage{amsmath}
\usepackage{mdframed}
\usepackage{empheq}

\begin{document}

Blah blah blah.

\begin{mdframed}
\begin{align}
1+2&=3\\
1+2+3&=6
\end{align}
\end{mdframed}

Blah blah blah.

\begin{empheq}[box=\fbox]{align}
1+2&=3\\
1+2+3&=6
\end{empheq}

\end{document}

enter image description here

0
2

The mathtools package has a command to box a single equation in an alignment. Here is a way to customise this box as an \fcolorbox, with the help of xpatch and xcolor:

\documentclass{article}

\usepackage{empheq}
\usepackage[svgnames]{xcolor}
\usepackage{xpatch}
\makeatletter
\newcommand{\colorboxed}[1]{\fcolorbox{DarkSeaGreen}{DarkSeaGreen!20}{\m@th$\displaystyle#1$}}
\xpatchcmd{\@Aboxed}{\boxed}{\colorboxed}{}{}
\makeatother

\begin{document}

\begin{align}
1+2 &=3\\
1+2+3 &=6 \\
\Aboxed{1+2+3 + 4 &=10}
\end{align}

\end{document}

enter image description here

2
  • That's quite nice, thank you. Do you know if that box can be extended easily to include the equation number? – Garf Oct 3 '18 at 17:35
  • A priori, it must not be so easy. If you use the coloured version, I would suggest a coloured equation tag (of the same colour as the frame) instead. Unrelated: I forgot to mention that, when you load mathtools or empheq, you don't have to load amsmath. – Bernard Oct 3 '18 at 18:44

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