The cases environment in latex

The cases environment defined by the amsmath package sets each case to be inline math style. This will look ugly when the formulas in the cases are complicated, such as fractions or integrals. Consider the following sample code:

\frac{1}{2(x-1)}, & x>1 \\
\frac{\Gamma(x)}{2^{x-1}}, & 0<x<1

The result looks like this:

The solution is to use the dcases environment provided by the mathtools package instead. The prefix `d’ means `display’. It will set the cases in displayed math style (exactly the same as \frac versus \dfrac). So if we write the following code

\frac{1}{2(x-1)}, & x>1 \\
\frac{\Gamma(x)}{2^{x-1}}, & 0<x<1

then we will see the result which looks like this:


2 Responses to “The cases environment in latex”

  1. 1 Sotiris December 1, 2011 at 3:02 am

    you can also just use dfracs and at the end of the first line use \\[3ex] instead of \\

    • 2 Jie December 1, 2011 at 12:51 pm

      Yes you are right. But there are two reasons why I don’t. First I just don’t like manually controlling the line spacing. Second, this only works for fractions, but not integrals or other complicated formulas. The point is that the cases environment set the cases in inline math style, which does not look good sometimes. To make them all changed to displayed style, you might need to add \displayedmath in each case. In that case, why not just use the mathtools package for simplicity?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


Blog Stats

  • 264,577 hits

%d bloggers like this: