5

Right now, I have

\begin{gather}
Eq1
\\ Eq2
\\ Eq3
\end{gather}

where variables ... are defined as

\begin{gather}
Eq4
\\ Eq5
\end{gather}

I would like to put a box around all of this including the text "where variables ... are defined as". Is it possible to do this using the empheq environment?

1 Answer 1

5

Yes, it's possible, and you have several options depending on the desired result. Below I show six different possibilities.

enter image description here

The code:

\documentclass{article}
\usepackage[vmargin=1cm]{geometry}
\usepackage{amsmath}
\usepackage[many]{tcolorbox}
\usepackage{empheq}

\begin{document}

\begin{empheq}[box=\fbox]{gather}
Eq1
\\ Eq2
\\ Eq3
\\ \notag\text{where variables ... are defined as}
\\ Eq4
\\ Eq5
\end{empheq}

\begin{empheq}[box=\fbox]{gather}
Eq1
\\ Eq2
\\ Eq3
\\ \notag\text{\parbox{.7\linewidth}{where variables ... are defined as}}
\\ Eq4
\\ Eq5
\end{empheq}

\begin{empheq}[box=\tcbhighmath]{gather}
Eq1
\\ Eq2
\\ Eq3
\\ \notag\text{where variables ... are defined as}
\\ Eq4
\\ Eq5
\end{empheq}

\begin{empheq}[box=\tcbhighmath]{gather}
Eq1
\\ Eq2
\\ Eq3
\\ \notag\text{\parbox{.7\linewidth}{where variables ... are defined as}}
\\ Eq4
\\ Eq5
\end{empheq}

\begin{tcolorbox}[enhanced,oversize,breakable,colframe=cyan,colback=cyan!20,top=-\abovedisplayskip,bottom=0pt]
\begin{gather}
Eq1
\\ Eq2
\\ Eq3
\end{gather}
where variables ... are defined as
\begin{gather}
Eq4
\\ Eq5
\end{gather}
\end{tcolorbox}

\noindent\makebox[\linewidth]{\fcolorbox{orange}{orange!10}{%
\begin{minipage}[t]{\linewidth}
\vskip-\abovedisplayskip
\begin{gather}
Eq1
\\ Eq2
\\ Eq3
\end{gather}
where variables ... are defined as
\begin{gather}
Eq4
\\ Eq5
\end{gather}
\end{minipage}}}

\end{document}

Explanation

  • In options one through four, instead of two gather environments I used just one. The text was written using \text.

  • In options two and four, the text was additionally placed inside a \parbox, so you can control its width and have possible line breaks.

  • Options one and two use a standard empheq environment with \fbox as the framing method.

  • Options three and four use the interaction between tcolorbox and empheq; the framing method is \tcbhighmath.

  • In option five, a tcolorbox was used to surround both gather environments and the text; page breaks are allowed.

  • In option six, a \fcolorbox was used to surround both gather environments and the text; page breaks are not allowed since a minipage was used.

12
  • Thanks for your quick and helpful response. With tcolorbox, is there a way to change the width of the frame?
    – KevinB
    Jul 25, 2015 at 17:43
  • @KevinB You're welcome. I edited my answer (in case you didn't noticed it). Regarding your question, you can use boxrule as in \begin{tcolorbox}[oversize,breakable,colframe=cyan,colback=cyan!20,boxrule=0.4pt] ...\end{tcolorbox} (change 0.4pt to the desired value.) Jul 25, 2015 at 17:47
  • I did see your edit. Thanks for such a thorough answer with the different options. I like the tcolorbox option the best. However when I use boxrule: \begin{tcolorbox}[oversize,breakable,colframe=black,colback=white!20,boxrule=0.4 p‌​t] I'm getting an error " Illegal unit of measure (pt inserted). <to be read again> p l.351 ...ck,colback=white!20,boxrule=0.4 p‌​t] Dimensions can be in units of em, ex, in, pt, pc, cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one!"
    – KevinB
    Jul 25, 2015 at 17:53
  • @KevinB for some reason there's a strange character in your code in the pt part (probably a result of copy-paste). Delete 0.4 pt and write it again directly from your keyboard. Jul 25, 2015 at 18:04
  • Thanks, that works. Unfortunately with tcolorbox, the equations I want to box are getting split into two boxes because they extend beyond the bottom of the page. Therefore, I think I will use fcolorbox because as you mentioned, that doesn't allow page breaks. With fcolorbox, how should I specify the frame width? Thanks for all your help.
    – KevinB
    Jul 25, 2015 at 18:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .