Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The title says it all: The "cases" environment works only in math mode. Is there an alternative in text mode?

share|improve this question
    
Are you referring to the amsmath cases environment, or those provided by mathtools: dcases, rcases, ... And I assume by "text mode" you're referring to "inline math mode"? –  Werner Sep 5 '11 at 16:40
    
By "cases" environment I mean "cases" environment, and by text mode I mean text mode, the mode you are in by default if you don't open a $ or a \[. –  Turion Sep 5 '11 at 17:03
    
So you just want to type Some text \begin{cases} ... \end{cases} some more text and it should automatically switch to math mode and back? –  Werner Sep 5 '11 at 17:05
add comment

3 Answers

You can emulate a cases environment for text mode using a \parbox or a tabular environment:

\documentclass{article}
\usepackage{amsmath}

\newcommand\Text{text text text text text text text text text text text text text text text text text text text text text text text text text }

\begin{document}

\[
\left\lbrace\parbox{7cm}{\Text}\right.
\]

\[
\left\lbrace
\begin{tabular}{@{}p{6cm}p{4cm}} 
\Text & \Text\Text \\
\Text & \Text\Text 
\end{tabular}\right.
\]

\end{document}

enter image description here

share|improve this answer
add comment

The cases environment works without modification in inline math mode. That is, the following works:

\usepackage{amsmath}% http://ctan.org/pkg/amsmath
...
Some interesting text $P_{r-j}=\begin{cases} ... \end{cases}$ and more interesting text.

However, if need be, you could just create your own using an array in inline math mode. Here is an example:

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
Some interesting text 
$P_{r-j}=\left\{\def\arraystretch{1.2}\begin{tabular}{@{}l@{\quad}l@{}}
  $0$ & if $r-j$ is odd \\
  $r!((-1)^{(r-j)/2}$ & if $r-j$ is even.
\end{tabular}\right.$ 
Of course, this will modify the baseline compared to the display format:
\[
  P_{r-j}=\begin{cases}
      0 & \text{if $r-j$ is odd} \\
      r!((-1)^{(r-j)/2} & \text{if $r-j$ is even.}
    \end{cases}
\]
\end{document}

The definitions within the tabular environment (resetting \arraystretch to 1.2 and the column alignment/specification @{}l@{\quad}l@{}) were taken directly from the definitions of the cases environment in the amsmath package

Cases in inline math mode and displaystyle math mode

share|improve this answer
    
Of course it works in inline. But I want to get rid of the \text, which is why I want it to work in text mode. –  Turion Sep 5 '11 at 17:05
    
Using tabular instead of array in my example above you could get rid of \text. However, then the left column needs $...$. –  Werner Sep 5 '11 at 17:49
add comment

you can define the height by the number of lines, in this case 11

\documentclass{article}
\usepackage[english]{babel}
\usepackage{multirow,bigdelim}

\newcommand\Text{text text text text text text text 
text text text text 
text text text text text text text text text 
text text text text text }

\begin{document}

\begin{tabular}{l p{6cm} }
\ldelim\{{11}{1.5cm}[Left Side ]
  & \Text\Text \\
  & \Text
\end{tabular}

\end{document}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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