[Tex/LaTex] Putting frame only around equation using mdframed package

mdframed

I am in the process of finalizing the notebook text, and I am into framing equations and figures. For this I am testing mdframed package, which produces nice frames. However, I don't know how to frame only equations, without framing equation numbers. Is that possible in mdframed?

Best Answer

To supplement the answer of Harish Kumar, the packages empheq and tcolorbox can by used in symbiosis. empheq allows to specify any box to mark the given equations. For the box you may insert any tcolorbox which behaves like fbox. Typically, such boxes are based on the \tcbox macro (like \tcbhighmath in the answer of Harish Kumar).

I think, the following example demonstrates what you can do. The singleline equation is boxed with \tcbhighmath directly, the multiline equations (align) are boxed using empheq in conjunction with \tcbhighmath and some other \tcbox-based examples.

\documentclass{article}
\usepackage[svgnames,hyperref]{xcolor}
\usepackage{empheq}
\usepackage[many]{tcolorbox}

\tcbset{highlight math style={enhanced,
  colframe=red!60!black,colback=yellow!50!white,arc=4pt,boxrule=1pt,
  drop fuzzy shadow}}

\newtcbox{\otherbox}[1][]{nobeforeafter,math upper,tcbox raise base,
  enhanced,frame hidden,boxrule=0pt,interior style={top color=green!10!white,
  bottom color=green!10!white,middle color=green!50!yellow},
  fuzzy halo=1pt with green,#1}

\newtcbox{\picturebox}[1][]{nobeforeafter,math upper,tcbox raise base,
  enhanced,watermark graphics=example-grid-100x100bp.jpg,% from package mwe
  colback=white,frame hidden,boxrule=0pt,arc=10pt,
  watermark stretch=1.00,watermark opacity=0.4,#1}

\begin{document}

\begin{equation}
\tcbhighmath{E = mc^2}
\end{equation}

\begin{empheq}[box=\tcbhighmath]{align}
a&=b\\
E&=mc^2 + \int_a^a x\, dx
\end{empheq}

\begin{empheq}[box={\tcbhighmath[colback=blue!20!white]}]{align}
a&=b\\
E&=mc^2 + \int_a^a x\, dx
\end{empheq}

\begin{empheq}[box={\tcbhighmath[watermark text=?!,watermark color=yellow!90!red]}]{align}
a&=b\\
E&=mc^2 + \int_a^a x\, dx
\end{empheq}

\begin{empheq}[box=\otherbox]{align}
a&=b\\
E&=mc^2 + \int_a^a x\, dx
\end{empheq}

\begin{empheq}[box=\picturebox]{align}
a&=b\\
E&=mc^2 + \int_a^a x\, dx
\end{empheq}

\end{document}

enter image description here