# Tag Info

## Hot answers tagged cases

110

For the question as it was originally posed, we can still use cases very easily. We simply employ the technique of using \left. at the start and then we can put \right\} at the end: $X(m, n) = \left. \begin{cases} x(n), & \text{for } 0 \leq n \leq 1 \\ x(n - 1), & \text{for } 0 \leq n \leq 1 \\ x(n - 1), & \text{for } 0 \leq n \... 108 \documentclass{article} \usepackage{amsmath} \begin{document} \[ X(m,n) = \left\{\begin{array}{lr} x(n), & \text{for } 0\leq n\leq 1\\ x(n-1), & \text{for } 0\leq n\leq 1\\ x(n-1), & \text{for } 0\leq n\leq 1 \end{array}\right\} = xy$ \end{document} If you want two conditions on different lines, can use ...

43

In the displaymath mode, you can not use any paragraph triggering commands such as blank lines or \par commands. (Not a good idea, but you can use it inside the cases environment). Also you don't need to switch to text mode and then again to math mode. You can just use text on the text and leave the rest as it is. Another point is the use of & ...

33

The following may be close to what you're looking for: \documentclass[12pt]{article} \usepackage{amsmath} \begin{document} \begin{gather*} c \colon \{1, \dots, n\} \rightarrow \{1, \dots, n\} \text{ such that}\\ \begin{cases} c(a_i) = a_{i+1} & \text{for }1\le i<l\\ c(a_l) = a_1 \end{cases} \end{gather*} \end{document} Some comments: ...

33

\documentclass{article} \usepackage{mathtools} %loads amsmath as well \DeclarePairedDelimiter\Floor\lfloor\rfloor \DeclarePairedDelimiter\Ceil\lceil\rceil \begin{document} T(n) = \begin{cases} 0 & \text{if n=1} \\ 1 & \text{if n=2} \\ T(\Floor{n/2}) + T(\Ceil{... 26 Short answer The cases environment requires the amsmath package: \usepackage{amsmath} Long answer For historical reasons, LaTeX defines a \cases macro: on page 232 of Lamport's manual one reads Most Plain TeX commands can be used in LaTeX, but only with care. and \cases is indeed a Plain TeX command which has quite a different syntax than the cases ... 24 You can make use of mathtools and its cases* environment. The environments cases* and dcases* handles the second column as text, so you wont have to manually "escape" mathmode to typeset the text correctly. The dcases* variant use displaystyle math in the first column, which will make no difference in your situation. See section 3.4.3 in the package ... 23 The package mathtools (that also loads amsmath) provides dcases and dcases*: \documentclass{article} \usepackage{mathtools} \begin{document} $$\alpha_{mn} = \begin{dcases*} \frac{16\mu^2}{mn\pi^2[\pi^2(m^2/a^2 + n^2/b^2) - \mu^2]} & for m and n odd;\\ 0\vphantom{\frac{0}{0}} & for m or n even; \end{dcases*}$$ \... 19 Referencing my chat message from 2013-04-05, here is the definition of the cases environment that accepts one optional argument, the column specification of the left column. Thus writing \begin{cases}[r] the left column is set right-aligned. This way you actually could even use siunitx’ table typsetting with the S column. Code \documentclass{article} \... 19 Essentially the same answer as Ignasi, but with the use of \text for the word for. (And with the \leqslant symbol of amssymb which I find much more elegant.) \documentclass{article} \usepackage{amsmath, amssymb} \newcommand{\for}{\text{for }} \begin{document} \[ X(m,n)= \left\{ \begin{array}{lr} x(n),& \for 0\leqslant n \leqslant 1 \\... 18 You may better use aligned: \documentclass[11pt,a4paper]{article} \usepackage{amsmath} \usepackage{amssymb} \usepackage{amsthm} \begin{document} \begin{aligned} \frac{I}{Z} &= 12+\frac{7}{Z}\;[eV], && Z<13 \\ \frac{I}{Z} &= 9.76+58.8Z^{-1.19}\;[eV], && Z\geq13 \end{aligned} \end{document} 17 Simplest is probably to use \phantom{-}1 17 For example: \documentclass{article} \usepackage{amsmath} \begin{document} \[ L = \begin{cases} (0 + 1)* & \text{if P = \mathit{NP}} \\ \emptyset & \text{otherwise} \end{cases} \end{document}

16

This has already been addressed, but I can't remember where nor when. So here is a simple solution with the empheq package, which loads mathtools, hence amsmath: \documentclass{article} \usepackage{amssymb} \usepackage[overload]{empheq} \newcommand{\for}{\text{for }} \begin{document} \begin{equation*}[right=\empheqrbrace{=xy.}] X(m,n)= \begin{...

15

You can combine the preceding solution with the subequations environment if you refer to the equations as a group. If you want to refer to the group, you have to introduce a \label just before entering the align environment. Here it is in action: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{fourier} \usepackage{...

15

You could also use a \hphantom{} to add the appropriate amount of horizontal space: Code: \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align} f(x) &= \begin{cases} x\hphantom{-\sqrt{-}} & \text{if } x\geq 0,\\ -x & \text{if } x <0, \end{cases}\\ g(x) &= \begin{cases} \sqrt{x} & \text{if } x \...

14

No, you don't need xstring for that. TeX's syntax is sufficient. \def in TeX use a parameter template to extract any format of argument. The syntax is (c.f. TeX for the Impatient): \def \foo parameter text {replacement text} Thus you can directly use \def\parsedate #1-#2-#3\stopmark{Use #1 and #2 and #3 as you wish} to get the different arguments in a ...

14

Although the cases environment probably suits your needs best, I'd like to mention the more versatile and (probably) equivalent syntax \left\{ <blank> \right\}for future use, in case you haven't come across it.

14


13

The dcases environment is implemented by the mathtools package, so you need to load it in the preamble: \usepackage{mathtools}

13

I would load the mathtools package, which is a superset of the amsmath package, and employ that package's dcases* environment. \documentclass{article} \usepackage{mathtools} % for 'dcases*' env. \begin{document} \[ R\ge R_t \equiv \begin{dcases*} \frac{r_{t+1}}{f'(k_{t+1})}\frac{1-W(k_t)}{\lambda} & if $k_t < K(\lambda)$\,, \\[1ex] \frac{r_{t+1}}...

12

Here's a solution which (a) uses the align* environment instead of the array environment and (b) inverts the order of the arguments inside the cases environment (as I believe that this may be closer to general usage of this environment). It also defines a macro called \abs to simplify typesetting in the body of the example. \documentclass{article} \...

12

If you want a result really good-looking, adopt this way: \documentclass{article} \usepackage{amsmath} \usepackage{calc} \newlength{\maxmin} \setlength{\maxmin}{\widthof{$\max$}-\widthof{$\min$}} \begin{document} S_{i,t}= \begin{cases} \begin{cases} [x_{i,t}=X^*, r_{i,t}=1] & \text{if $\max\{X_{i,t}\}=X^*$} \\ [x_{...

12

I do not see a problem, except that the source can be simplified: Many pairs of curly braces can be removed, e.g.: {a} is equivalent to \mathord{a} and a that is already an ordinary atom. Package amsmath also provides environment vmatrix. Example file: \documentclass{article} \usepackage{amsmath} \begin{document} \[ D = \begin{vmatrix} a_{1} &...

12

Environment cases of package amsmath internally uses environment array with columns of type l. The column specification is @{}l@{\quad}l@{}. Thus \multicolumn will work: \multicolumn{1}{@{}c@{\quad}}{1} Also an easier way is possible. The justification code of array/tabular just adds an \hfil at the right side of a column of type l. This moves the cell ...

12

You can redefine the way amsmath defines the cases specification by updating \env@cases. Below I removed the zero-width column padding that was stripped from the array column specification: \documentclass{scrbook} \usepackage{amsmath} \makeatletter \def\env@cases{% \let\@ifnextchar\new@ifnextchar \left\lbrace \def\arraystretch{1.2}% \array{l@{\quad}...

12

A solution that uses an array environment; note that using a cases environment seems like overkill for the case (pun intended) at hand. \documentclass{article} \usepackage{amsmath} \begin{document} \begin{equation*} \left\{ \begin{array}{@{} r @{{}={}} r} \zeta_A & -10.1234567\cdots,\\ \zeta_B & 1{,}001.2345678\cdots.\\ \end{array} \right. \end{...

12

Use the optional argument to \\ to add additional space between the lines, e.g.\\[10pt]. \documentclass{article} \usepackage{amsmath} \begin{document} \begin{equation*} X_i = \begin{cases} \left[\begin{smallmatrix} 0 \\ 1 \\ 2 \end{smallmatrix}\right] & \text{if $i$ is even;} \\[10pt] \left[\begin{smallmatrix} 2 \...

12

The issue seems to be that you want the "column" to the right of the brace to be centered rather than left justified, which is what happens in all of the cases environments (at least, in all of the ones that I know about). To fix this this the OP's idea of using an array seems to be the way to go, but a few tweaks are needed. First, if you use \left\{ then ...

11

Here's a take using regular arrays: \documentclass{article} \usepackage{amsmath}% http://ctan.org/pkg/amsmath \begin{document} \begin{align*} \text{function} = {\left\{\begin{array}{@{}l@{\quad}l@{}} \text{case}_1 & \text{if } n = 0 \\ \left\{\begin{array}{@{}l@{}} \text{case}_2 \\ \left\{\begin{array}{@{}l@{}} \text{...

Only top voted, non community-wiki answers of a minimum length are eligible