[Tex/LaTex] How to box multiple aligned equations

boxesequations

This question is two-fold. In my document, I currently have boxes around single equations like so:

\documentclass[11pt]{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\setlength\fboxsep{0.25cm}
\setlength\fboxrule{0.4pt}
\boxed{\bar{\nabla}^{\mu}\bar{h}_{\mu\nu}=0. 
\end{equation}
\end{document}
  • I would now like to be able to adjust the fboxsep for each side top and bottom margins separately from the left and right margins

  • Also, I would like to box – in the same style – multiple equations that are aligned.

How can I do these?

(a) shows the output of corresponding to the box in the MWE, (b) shows an example of what I'd like to get from adjusting the left and right margins independently of the top and bottom ones, (c) shows what how I'd like – in a consistent manner – the boxing of equations that are currently in an align environment (inside a subequations):

enter image description here

Best Answer

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

sample output