Black and white emphasis for \boxed?
You can use the predefined boxes from the fancybox
package, which you can wrap around equations via the empheq
package:
\documentclass[letterpaper]{article}
\usepackage{kpfonts,amssymb,empheq,fancybox}
\newsavebox{\mybox}
\newcommand{\raisedshadowbox}[1]{%
\sbox\mybox{\shadowbox{#1}}%
\raisebox{-0.5\ht\mybox-0.5\shadowsize+0.6ex}{\usebox\mybox}%
}
\begin{document}
A double box
\begin{empheq}[box=\doublebox]{align}
a&=b\\
E&=mc^2 + \int_a^a x\, dx
\end{empheq}
An oval box (cheesy)
\begin{empheq}[box=\ovalbox]{align}
a&=b\\
E&=mc^2 + \int_a^a x\, dx
\end{empheq}
A shadowbox, which has some vertical alignment problems \ldots
\begin{empheq}[box=\shadowbox]{align}
a&=b\\
E&=mc^2 + \int_a^a x\, dx
\end{empheq}
\ldots which apparently can be fixed by sticking it into a raisebox.
\begin{empheq}[box=\raisedshadowbox]{align}
a&=b\\
E&=mc^2 + \int_a^a x\, dx
\end{empheq}
\end{document}
This gives
Note that the definition of \raisedshadowbox
contains a fudge factor of 0.6ex for the vertical offset correction. I don't know what this compensates for, but it does seem to work across different font sizes, line heights as well as \shadowbox
, \fboxsep
and \fboxrule
settings.
Some alternative examples made with tcboxmath
, ams equation|gather|align|...
tcolorbox
environments:
\documentclass[letterpaper]{article}
\usepackage{lmodern}
\usepackage{amssymb,mathtools}
\usepackage[most]{tcolorbox}
\tcbset{colback=white,colframe=black}
\begin{document}
With \texttt{tcboxmath} only the equation is boxed
\begin{equation}
\tcboxmath{\frac{M}{R} \propto R^2 \rho}
\end{equation}
An \texttt{ams equation} also boxes equation number
\begin{tcolorbox}[ams equation]
\label{eqn:density} \rho \propto \frac{M}{R^3}
\end{tcolorbox}
With \texttt{tcbhighmath} some part can be detached
\begin{tcolorbox}[ams gather]
\frac{M}{R} \propto R^2 \rho \\
\tcbhighmath[colback=black,coltext=white,colframe=white]{\rho \propto \frac{M}{R^3}}
\end{tcolorbox}
Boxes can have shadows:
\tcboxmath[enhanced, drop shadow]{\frac{M}{R} \propto R^2 \rho} \hfill
\tcboxmath[enhanced, drop fuzzy shadow]{\frac{M}{R} \propto R^2 \rho}\hfill
\tcboxmath[enhanced, drop lifted shadow]{\frac{M}{R} \propto R^2 \rho}
sharp corners
\begin{tcolorbox}[ams equation, sharp corners]
\label{eqn:density} \rho \propto \frac{M}{R^3}
\end{tcolorbox}
border lines
\begin{tcolorbox}[enhanced, ams equation, sharp corners, borderline={1pt}{-3pt}{black}]
\label{eqn:density} \rho \propto \frac{M}{R^3}
\end{tcolorbox}
\dots
\end{document}