The empheq07 package^{∗} Emphasizing equations in L^{A}TEX 2ε^{†}

Morten Høgholm 2004/07/27

Abstract The empheq07 package automatically detects several amsmath environments and the size of the displayed math material. The user interface makes it easy to add various kinds of visual markup to these equations.

Contents

1 Important Notice 1 2 Introduction 1 3 Examples 2 4 Bugs and shortcomings 4

1 Important Notice

This package (empheq07 v0.7d) is no longer supported. See the documentation of empheq for more details.

2 Introduction

Users who have wanted to put a system of equations inside boxes has hitherto been forced to use the features of fancybox or the \boxed command of amsmath. Both alternatives have serious limitations though. fancybox allows only eqnarray-style equations and at the end of the day they aren’t all that pretty. Most mathematical typesetting in L^{A}TEX is done with the aid of amsmath anyway, but it only offers the single line quick-fix \boxed. What we really want is something that will enable us to do something along the likes of this:

S̃ = 1 ⇒ \begin{cases}a & = ∫_{−2}^{3} tb^{t} dt and & (1a) \\ c & = d − a & (1b) \end{cases}

∗This file has version number v0.7d, last revised 2004/07/27.

†Thanks to Lars Madsen for asking for the subtle feature that evolved into this package.

As you can see, empheq07 can do all the tricks the cases package by Donald Arseneau can do and more. It even supports subequations—as shown in equations (1a) and (1b)—from amsmath without complaining.

In order to combine the best of two worlds the empheq07 package tries to take advantage of the widespread features of amsmath. As it should be well known if you read this, amsmath has amongst its arsenal of structures align, gather, alignat and multline. empheq07 works with these as well as their starred variants.

“But what about equation?” you say. equation is (in my opinion) merely a poor man’s gather. If you really want to use empheq07’s features on a one-liner (no pun intended) go with gather. Anyway the real goal of this package is to do nifty tricks with multi line equations …

3 Examples

Any options given to empheq07 is passed on to amsmath, thus the line

   \usepackage[⟨options⟩]{empheq07}

will load amsmath with exactly those options. empheq07 doesn’t redefine anything so to use it in an existing document you need only replace amsmath with empheq07—no harm done.

empheq07 is really easy to use; you simply put an empheq environment around your amsmath environment:

 \begin{empheq}
   \begin{align}
     E&=mc^2 \\
     Y&= \sum_{n=1}^\infty \frac{1}{n^2}
   \end{align}
 \end{empheq}

\begin{aligned}E & = mc^{2} & (2) \\ Y & = ∑_{n=1}^{∞} \frac{1}{n^{2}} & (3) \end{aligned}

Impressed? No? Well then I guess it’s about time I told you about the optional argument of the empheq environment. It allows you control what material to put on either side of the math and the sort of box to go around it all. That means that we can say

 \begin{empheq}[boxtype=\fbox]
   \begin{align}
     E&=mc^2 \\
     Y&= \sum_{n=1}^\infty \frac{1}{n^2}
   \end{align}
 \end{empheq}

to obtain the display

\begin{aligned}E & = mc^{2} & (4) \\ Y & = ∑_{n=1}^{∞} \frac{1}{n^{2}} & (5) \end{aligned}

This requires the use of the keyval package from the tools bundle, which is undoubtedly installed on your system. When using the keyval package there are a few things we need to keep in mind. In mathematical typesetting ‘=’ and ‘,’ are quite frequently used, thus requiring the user to enclose them in braces:

 \begin{empheq}[boxtype=\fbox,
                Left={(a,b)=(c,i) \Rightarrow\empheqlbrace}]
 \begin{alignat}{2}
 (a,b)&= (\cos^a c, \tan^b i)&& \quad\text{for $i>1$}\\
 (a,b)&= (\arccos x^a, \arctan i^b)&& \quad\text{for $i\leq1$}
 \end{alignat}
 \end{empheq}

(a, b) = (c, i) ⇒ \begin{cases}(a, b) & = (cos^{a} c, tan^{b} i) & for i > 1 & (6) \\ (a, b) & = (arccos c^{a}, arctan i^{b}) & for i ≤ 1 & (7) \end{cases}

The same with cases from amsmath for comparison:

(a, b) = (c, i) ⇒ \begin{cases}(a, b) = (cos^{a} c, tan^{b} i) & for i > 1 \\ (a, b) = (arccos x^{a}, arctan i^{b}) & for i ≤ 1 \end{cases}

Notice that cases uses an array for the conditions, so you have to force \displaystyle yourself. This is not needed with empheq07 as you’re already using a \displaystyle environment such as gather etc.

Observe what can be done if we replace \fbox with another framed box and add some space on all sides:

 \definecolor{lightblue}{rgb}{.8, .8, 1}
 \begin{empheq}[boxtype={\setlength{\fboxsep}{10pt}%
                         \colorbox{lightblue}},
                Right={\empheqrbrace \beta}]
      .
      .
      .
 \end{empheq}

\begin{matrix}a & = ∫_{−2}^{3} tb^{t} dt and & (8) \\ c & = d − a & (9) \end{matrix} \} β

As a convenience for the user, it is also possible to declare delimiters with the commands \DeclareRightDelimiter{⟨delimiter⟩} and its companion \DeclareLeftDelimiter{⟨delimiter⟩}. For instance the commands

     \DeclareRightDelimiter{\rangle} defines \empheqrangle

and

     \DeclareLeftDelimiter{\langle} defines \empheqlangle.

The usage is simple.

 \begin{empheq}[Right=\empheqrangle,
                Left=\empheqlangle]
  \begin{gather}
    a=b \\
    c=d
  \end{gather}
 \end{empheq}

⟨\begin{matrix}a = b & (10) \\ c = d & (11) \end{matrix} ⟩

\DeclareRightDelimiter and its companion have an optional argument which controls spacing (default is a negative thinspace), but beware: It will simply overwrite the original definition and it might not look all that pretty as the following example shows:

 \DeclareRightDelimiter[\>]{\rangle}
 \DeclareLeftDelimiter[\mkern-10mu]{\langle}

⟨\begin{matrix}a = b & (12) \\ c = d & (13) \end{matrix} ⟩

These examples will have given you a glimpse of the possibilities empheq07 offers. In particular the commands \empheqlbrace and \empheqrbrace produce braces just tall enough to encompass the display. You can of course use \big... delimiters if you want.

If you want you can even create your own box and use it with empheq. In the following silly example I have created \ErrorBox with PSTricks to achieve a disturbing effect:

Error! \begin{aligned}E & = mc^{3} \\ F & = G\frac{m + M}{r^{2}} \end{aligned}

Remember one thing when creating your own box: Make it symmetrical.

4 Bugs and shortcomings

This package (empheq07) is not supported anymore. Try with the new version and see if it works; if not, then contact me. See how in the manual of empheq.