[texhax] fbox in align environment

Philip G. Ratcliffe philip.ratcliffe at uninsubria.it
Mon Jun 15 10:29:06 CEST 2009


> Say you have three equations in an align environment. You 
> want to box only one of them, say the last one. How does one 
> do this? I want all three equations aligned (at, say the = 
> sign). Fancybox.sty wasn't of much help in this regard. I can 
> put the first two eqns in an align, and the third eqn in an 
> fbox in the equation environment, but the alignment is disturbed. 

If you haven't found anything better, here's a not very elegant solution:

\documentclass{article}
\usepackage{amsmath}
\newcommand\alignboxed[2]{\rlap{\boxed{#1#2}}\hphantom{#1\mkern6mu}}
\begin{document}
\begin{align}
  f_1(x) &= a+bx, \\
  f_2(x) &= a+bx+cx², \\
  \alignboxed{f_3(x)}{= a+bx+cx²+dx³.}
\end{align}
\end{document}

This works similarly:

\documentclass{article}
\usepackage{amsmath}
\def\alignboxed#1&#2\endalignboxed{\rlap{\boxed{#1#2}}\hphantom{#1\mkern6mu}
}
\begin{document}
\begin{align}
  f_1(x) &= a+bx, \\
  f_2(x) &= a+bx+cx², \\
  \alignboxed
  f_3(x) &= a+bx+cx²+dx³.
  \endalignboxed
\end{align}
\end{document}

Cheers,  Phil



More information about the texhax mailing list