5

I want to enclose some equations in a widebox, but I need to make the box bigger the the y-direction/vertical direction. How is this done?

A sample code is given below (taken from the empheq manual).

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

Thank you!

  • Please check your MWE produces the example that you expect. As posted that typesets widefbox before the equation. – David Carlisle Mar 11 '14 at 14:10
  • 3
    Please, don't use the minimal class, even for short examples. – egreg Mar 11 '14 at 14:31
4
\documentclass{minimal}
\usepackage{empheq}
\begin{document}
\newcommand*\widefbox[1]{\fbox{\rule[-1.8cm]{0pt}{4cm}\hspace{1em}#1\hspace{1em}}}
\begin{empheq}[box=\widefbox]{align*}
a&=b \tag{*}\\
E&=mc^2 + \int_a^a x\, dx
\end{empheq}
\end{document}
| improve this answer | |
4

You can \addstackgap in the definition. The optional argument (here 20pt) can be changed to suit. This gap is an addition to the existing equation height/depth (rather than a replacement to it, which a \rule would be).

\documentclass{minimal}
\usepackage{empheq}
\usepackage{stackengine}
\begin{document}
\newcommand*\widefbox[1]{\fbox{\hspace{1em}\addstackgap[20pt]{#1}\hspace{1em}}}
\begin{empheq}[box=\widefbox]{align*}
a&=b \tag{*}\\
E&=mc^2 + \int_a^a x\, dx
\end{empheq}
\end{document}
| improve this answer | |
  • 1+ This is a more versatile solution! – Gonzalo Medina Mar 11 '14 at 14:19
2

An indirect solution. Offsets definition provided by hf-tikz allows more flexibility in customizing the frame size.

\documentclass{article}
\usepackage{amsmath}
\usepackage[customcolors]{hf-tikz}

\tikzset{offset definition 1/.style={
    above left offset={-0.4,0.6},
    below right offset={0.4,-0.5},
  },
  offset definition 2/.style={
    above left offset={-0.4,1.5},
    below right offset={0.4,-1.3},
  },
  filling/.style={
    disable rounded corners=true,
    set fill color=white,
    set border color=black,
  },
  box it 1/.style={
    offset definition 1,
    filling
  },
  box it 2/.style={
    offset definition 2,
    filling
  },
}

\begin{document}

\begin{align*}
\tikzmarkin[box it 1]{a}a&=b \tag{*}\\
E&=mc^2 + \int_a^a x\, dx \tikzmarkend{a}
\end{align*}

\vspace{2cm}

\begin{align*}
\tikzmarkin[box it 2]{b}a&=b \tag{*}\\
E&=mc^2 + \int_a^a x\, dx \tikzmarkend{b}
\end{align*}
\end{document}

The result:

enter image description here

Remember to compile at least twice.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.