4

I am interested in this thing because I think that the framed formulas make my document more beautiful. For example how can I make this formula framed?

$F=m\cdot a$

I would like to make a light green frame around it. It does not need to be too wide (I mean it does not need to be as wide as the paper, which is A4 paper). So how can I make this frame? Can I modify the width of it?

Sean Allred
  • 27,421
ostal123
  • 847

2 Answers2

8

Here is a simple coloured box around an alignment, made with the help of empheq and xcolor. Needless to load amsmath: empheq loads mathtools, which loads amsmath. I added a quad on each side of the box so it doesn't look too tight.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[x11names]{xcolor}
\usepackage{empheq}
\newcommand*\widefcolorbox[1]{\setlength\fboxrule{0.8pt}\fcolorbox{DarkSeaGreen3}{LemonChiffon1!15!}{\hspace{1em}#1\hspace{1em}}}

\begin{document}

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

\end{document} 

enter image description here

You can see much fancier boxes in the empheq documentation, ยง6.2.

Bernard
  • 271,350
5

From the empheq package documentation,

\documentclass{minimal}
\usepackage{empheq}
\begin{document}
\begin{empheq}[box=\fbox]{align*}
a&=b \tag{*}\\
E&=mc^2 + \int_a^a x\, dx
\end{empheq}
\end{document}

EDIT:

To get the box in color, you can simply do this:

\documentclass{minimal}
\usepackage[svgnames]{xcolor}
\usepackage{empheq}
\begin{document}
\begin{empheq}[box=\fcolorbox{Green}{White}]{align*}
a&=b \tag{*}\\
E&=mc^2 + \int_a^a x\, dx
\end{empheq}
\end{document}

enter image description here

JPi
  • 13,595