# Coloured shadowed boxes around equations

When I want to highlight some important result, I traditionnally put my equations in boxes:

$$boxed{\Delta = b^2-4ac}$$

I would like to have a more fancy thing:

• to be able to set the thickness and the color of the line of the box
• to be able to add a coloured shadow under this box

to obtain this kind of result:

I asked the same kind of question a while ago (see here) but the answer does not work for equations.

How to do that?

• – Marco Daniel Jul 7 '13 at 14:31
• I read your question again and saw that you want coloured shadows. Now, I extended my answer with examples for such coloured shadows. – Thomas F. Sturm Jul 8 '13 at 7:00

Here are some additions using tcolorbox. You can use a macro \tcbhighmath which is designed for such a task. The style can be varied also by options given to this macro.

\documentclass{article}
\usepackage[skins,theorems]{tcolorbox}
\tcbset{highlight math style={enhanced,
colframe=red,colback=white,arc=0pt,boxrule=1pt}}
\begin{document}
$$\tcbhighmath[drop fuzzy shadow]{\Delta = b^2 - 4ac}$$

$$\tcbhighmath[boxrule=2pt,drop fuzzy shadow=blue]{E = m\cdot c^2}$$

$$\tcbhighmath[boxrule=0.4pt,colframe=blue,drop fuzzy shadow=red]{a^2 + b^2} = \tcbhighmath[arc=4pt,drop fuzzy shadow=green]{c^2}$$

$$\tcbhighmath[boxrule=2pt,arc=1pt,colback=blue!10!white,colframe=blue, drop fuzzy shadow=red]{ \ln|x| = \int\limits_1^x t~dt }$$

$$\tcbhighmath[fuzzy halo=1mm with blue!50!white,arc=2pt, boxrule=0pt,frame hidden]{ \ln|x| = \int\limits_1^x t~dt }$$

\tcbset{myinner/.style={no shadow,shrink tight,extrude by=1mm,colframe=blue,
boxrule=0.4pt,frame style={opacity=0.25},interior style={opacity=0.5}}}
$$\tcbhighmath[drop fuzzy shadow=red!50!yellow,colback=red!20!white]{ \tcbhighmath[myinner]{\Delta} = \tcbhighmath[myinner]{b^2 - 4ac}}$$

\end{document}

I can't say I know all the ins and outs of tcolorbox, but this demonstrates that it works with equation material.

\documentclass{article}
\usepackage{tcolorbox}
\begin{document}
Testing
$$\tcbox[nobeforeafter]{$$\Delta = b^2 - 4ac$$}$$
\end{document}

• For the intended purpose I would recommend the \tcbhighmath macro from tcolorbox instead of \tcbox. Nevertheless, you could achieve the same with \tcbox and additional options :-) – Thomas F. Sturm Jul 7 '13 at 15:59
• @ThomasF.Sturm I defer to your expertise on tcolorbox. Thanks for the tip, which will aid me and the readers of this. – Steven B. Segletes Jul 7 '13 at 16:02
• @Steven B. Segletes: Is there any way to get rid of the rounded corners? I prefer sharp corners. – omehoque Dec 24 '17 at 5:21
• @far.westerner Best to ask Thomas Sturm, who provided the other answer and who wrote the tcolorbox package. – Steven B. Segletes Dec 24 '17 at 12:27

According to the Tcolorbox manual, they provide custom ams equation environments inside the tcolorbox so you don't even have to make an equation environment:

\begin{tcolorbox}[ams equation, colback=yellow, colframe=red]
\sum\limits_{n=1}^{\infty} \frac{1}{n} = \infty
\end{tcolorbox}

They also provide environments like ams align (just replace with this option in the above), which is very handy.