9

I would like to list some cases which are needed to be consider in text. I didn't find a standard way to do this. There is "case" for math mode, but that is not what I want. Look the following picture:

With Space

I use \\ \\ ( 2 new lines ) and \textbf to get the above result. But I doubt the space is too large ( larger then the space before \begin{Theorem} ).

I also use

Without Space

but it looks like no space is not good neither. Is there a standard way to do this, otherwise, what's the best space for it?

user565739
  • 5,482
  • Please compile what you have into a MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. – Peter Grill Nov 22 '11 at 11:55
  • It should be a simple matter of adjusting the spacing before and after each Case, so solution may vary based on how you are doing. – Peter Grill Nov 22 '11 at 11:58
  • @Peter, I mentioned that I use "2 new line" to get the above result. I thought it is really simple to "recreate" it. And this not really a problem if there is a stanard method to list the cases. – user565739 Nov 22 '11 at 12:23
  • 1
    Since it is relatively simple to recreate it, you should do so and post it here. – Peter Grill Nov 22 '11 at 12:24

2 Answers2

9

You can define an enumerate-like environment customized via the enumitem package:

\documentclass{article}
\usepackage{enumitem}
\usepackage{lipsum}

\newlength\mylen
\settowidth\mylen{\textbf{Case~5.}}
\newlist{mycases}{enumerate}{1}
\setlist[mycases,1]{label=\textbf{Case~\arabic*.}, 
  labelwidth=\dimexpr-\mylen-\labelsep\relax,leftmargin=0pt,align=right}

\begin{document}

\noindent There are three cases to consider:
\begin{mycases}
\item \lipsum[1]
\item \lipsum[1]
\item \lipsum[1]
\end{mycases}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128
  • 2
    +1 It might be nice to setup your own list using \newlist, and then customize it globally in the preamble using \setlist; this would save you from having to specify all of the options every time. – cmhughes Nov 22 '11 at 19:24
  • 2
    @cmhughes You're right. Now it's done. Thanks! – Gonzalo Medina Nov 22 '11 at 19:27
8

I generally use an environment (for numbering) and a separate case command. That looks like this:

\newcounter{casenum}
\newenvironment{caseof}{\setcounter{casenum}{1}}{\vskip.5\baselineskip}
\newcommand{\case}[2]{\vskip.5\baselineskip\par\noindent {\bfseries Case \arabic{casenum}:} #1\\#2\addtocounter{casenum}{1}}

In the text I can then use:

\begin{caseof}
  \case{$x>0$}{In this case, $x$ is larger than $0$}
  \case{$x<0$}{In this case, $x$ is smaller than $0$}
  \case{$x=0$}{In this case, $x$ equals $0$}
\end{caseof}

The full example would look like this:

\documentclass{article}
\begin{document}
  \newcounter{casenum}
  \newenvironment{caseof}{\setcounter{casenum}{1}}{\vskip.5\baselineskip}
  \newcommand{\case}[2]{\vskip.5\baselineskip\par\noindent {\bfseries Case \arabic{casenum}:} #1\\#2\addtocounter{casenum}{1}}
  \begin{caseof}
    \case{$x>0$}{
      In this case, $x$ is larger than $0$
    }
    \case{$x<0$}{
      In this case, $x$ is smaller than $0$
    }
    \case{$x=0$}{In this case, $x$ equals $0$}
  \end{caseof}
\end{document}

And the result like this:

Cases

Roelof Spijker
  • 17,663
  • 5
  • 55
  • 63