How can I box multiple aligned equations?
The empheq
package is your friend. The wide box is made with a normal box, with some space left and right, that you can adjust to your likings.
\documentclass[11pt]{article}
\usepackage{empheq}
\newcommand*\widefbox[1]{\fbox{\hspace{2em}#1\hspace{2em}}}
\begin{document}
\begin{empheq}[box=\widefbox]{equation}
\bar{\nabla}^{\mu} \bar{h}_{\mu\nu} = 0
\end{empheq}
\begin{subequations}
\begin{empheq}[box=\widefbox]{align}
\bar{\nabla}^{\mu} \bar{h}_{\mu\nu} & = 0 \\
\bar{\nabla}^{\mu} \bar{h}_{\mu\nu} & = 0
\end{empheq}
\end{subequations}
\end{document}
yields
tcolorbox
package provides commands to produce colorful framed boxes which can also be applied to math
environments.
\tcboxmath
and \tcbhighmath
commands add boxes to math expressions. The second one is used to highlight some part of a math expression, even inside a boxed one. Default configurations for these kind of boxes look like
\begin{equation}
\tcboxmath{\bar{\nabla}^{\mu}\bar{h}_{\mu\nu}=0.}
\end{equation}
\begin{equation}
\tcboxmath{\tcbhighmath{\bar{\nabla}^{\mu}\bar{h}_{\mu\nu}}=0.}
\end{equation}
If equation number must be included into the box, theorems
library provides ams equation
, ams align
and ams gather
environments. Two customized examples:
\newtcolorbox{mymathbox}[1][]{colback=white, sharp corners, #1}
\begin{mymathbox}[ams equation]
\bar{\nabla}^{\mu}\bar{h}_{\mu\nu}=0.
\end{mymathbox}
\begin{mymathbox}[ams gather, title=two equations, colframe=blue!30!black]
\sum\limits_{n=1}^{\infty} \frac{1}{n} = \infty.\\
\int x^2 ~\text{d}x = \frac13 x^3 + c.
\end{mymathbox}
Finally, tcboxes
can be used to define boxes compatible with empheq
package to box multiline equations (no number inside box).
\newtcbox{\othermathbox}[1][]{nobeforeafter, math upper, tcbox raise base,
enhanced, sharp corners, colback=black!10, colframe=red!30!black,
drop fuzzy shadow, left=1em, top=2em, right=3em, bottom=4em}
left
, top
, right
and bottom
values define extra margins inside the box.
\begin{empheq}[box=\othermathbox]{align}
\sum\limits_{n=1}^{\infty} \frac{1}{n} &= \infty.\\
\int x^2 ~\text{d}x &= \frac13 x^3 + c.
\end{empheq}
The complete code
\documentclass{report}
\usepackage{amsmath}
\usepackage{empheq}
\usepackage[theorems,skins]{tcolorbox}
\newtcolorbox{mymathbox}[1][]{colback=white, sharp corners, #1}
\newtcbox{\othermathbox}[1][]{nobeforeafter, math upper, tcbox raise base, enhanced, sharp corners, colback=black!10, colframe=red!30!black, drop fuzzy shadow, left=1em, top=2em, right=3em, bottom=4em}
\begin{document}
\begin{equation}
\tcboxmath{\bar{\nabla}^{\mu}\bar{h}_{\mu\nu}=0.}
\end{equation}
\begin{equation}
\tcboxmath{\tcbhighmath{\bar{\nabla}^{\mu}\bar{h}_{\mu\nu}}=0.}
\end{equation}
\begin{mymathbox}[ams equation]
\bar{\nabla}^{\mu}\bar{h}_{\mu\nu}=0.
\end{mymathbox}
\begin{mymathbox}[ams gather, title=two equations, colframe=blue!30!black]
\sum\limits_{n=1}^{\infty} \frac{1}{n} = \infty.\\
\int x^2 ~\text{d}x = \frac13 x^3 + c.
\end{mymathbox}
\begin{empheq}[box=\othermathbox]{align}
\sum\limits_{n=1}^{\infty} \frac{1}{n} &= \infty.\\
\int x^2 ~\text{d}x &= \frac13 x^3 + c.
\end{empheq}
\end{document}