Math & Science ⇒ box around just one equation inside align
box around just one equation inside align
I am using "\begin{align}..." to align two equations. I would like to put a box around the second equation only. However, "\boxed{...}" does not seem to work if the alignment character "&" is inside the "{}".
Any advice?
Thanks a lot,
Kai
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
box around just one equation inside align
Code: Select all
\documentclass{memoir}
\usepackage{calc,amsmath}
\newlength\dlf
\newcommand\alignedbox[2]{
% #1 = before alignment
% #2 = after alignment
&
\begingroup
\settowidth\dlf{$\displaystyle #1$}
\addtolength\dlf{\fboxsep+\fboxrule}
\hspace{-\dlf}
\boxed{#1 #2}
\endgroup
}
\begin{document}
\begin{align*}
f(x) &= a \\
\alignedbox{g(x)}{=5}
\end{align*}
\end{document}
Re: box around just one equation inside align
Brilliant, works perfectly!
Thanks a lot,
Kai