10

I am using \boxed to place emphasis on important equations in an assignment I am typing up, and would like to give the final answer a bit of extra emphasis. I'm using \begin{equation} ... \end{equation} to number each line, so that I can put in references in the text.

There are some very nice looking boxes in the answers to Attractive Boxed Equations and framed equations, but both rely on colour, when I have a black and white printer. I was thinking of a double line around the final equation, but I'll take other answers if they are easier to code or look better.

I would love it if either the balanced boxes or the full width boxes were incorporated into the answer, but this is optional. It is a class assignment that the TA will look at for all of 10 minutes, not a publication.

Minimal Working Example:

\documentclass[letterpaper]{article}
\usepackage{kpfonts}
\usepackage{amssymb,mathtools}

\begin{document}
\begin{equation} \frac{M}{R} \propto R^2 \rho  \end{equation}
\begin{equation} \label{eqn:density} \boxed{ \rho \propto \frac{M}{R^3} } \end{equation}
\end{document}
  • 1
    Could you include an equation showing your current "emphasis" so the community has a frame of reference (or a \boxed reference :-))? – Werner Jan 26 '12 at 0:27
  • I added a MWE. \boxed is from amsmath or mathtools. I used kpfonts as that is what I was using there, so if you compile it your equations will look exactly the same. – Canageek Jan 26 '12 at 0:51
13

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

enter image description here

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.

  • I like doublebox a lot, thank you. The easier it is for the TA to notice the things that should be me marks, the more likely I am to get them. – Canageek Jan 26 '12 at 2:31
2

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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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