# \cases

Typesetting piecewise functions using Plain TeX syntax

https://texform.dev/latex/commands/cases

## Metadata

| Field | Value |
| --- | --- |
| Topic | [Matrices](https://texform.dev/latex/topics/matrices) |
| Packages | base |
| Allowed mode | math |
| Tags | mathjax-extension, discouraged |
| Commonality | medium |
| Kind | prefix |

## Syntax

### base

Argument specification: `m`

Typesetting piecewise functions using Plain TeX syntax

## Examples

```latex
\cases{a & b \cr c & d}
```

[Open in Playground](https://play.texform.dev/?input=%5Ccases%7Ba+%26+b+%5Ccr+c+%26+d%7D)

```latex
\cases a
```

[Open in Playground](https://play.texform.dev/?input=%5Ccases+a)

## Renderer support

| Package | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- |
| base | full | none | full |

## Usage frequency

0% of formulas in the measured corpus contain this entry, rank 257 of 263 entries with frequency data.

## In TeXForm

TeXForm parses this entry as prefix syntax; the package determines its argument specification.

### Discouraged in base

Plain TeX command that has been superseded by LaTeX environments.

```latex
\begin{cases} $1 \end{cases}
```

Standard LaTeX (amsmath) convention.

### [base/cases-to-cases-env](https://texform.dev/rules/base/cases-to-cases-env)

Rewrite plain-TeX cases to the standard cases environment with row breaks.

Level: authoring. Fidelity: reading.

```latex
\cases{#1 \cr #2}
```

→

```latex
\begin{cases} #1 \\ #2 \end{cases}
```

```latex
\cases{x^2 & x>1 \cr 0 & x=0 \cr -x & x<0}
```

→

```latex
\begin{cases} x^2 & x>1 \\ 0 & x=0 \\ -x & x<0 \end{cases}
```

## See also

- [\\array](https://texform.dev/latex/commands/array)
- [\\displaylines](https://texform.dev/latex/commands/displaylines)
- [\\eqalign](https://texform.dev/latex/commands/eqalign)
- [\\eqalignno](https://texform.dev/latex/commands/eqalignno)
- [\\leqalignno](https://texform.dev/latex/commands/leqalignno)
- [\\matrix](https://texform.dev/latex/commands/matrix)
- [\\pmatrix](https://texform.dev/latex/commands/pmatrix)

## Test cases

### base

| Input | Case | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- | --- |
| \cases{a} | Positive: baseline | Pass | Fail | Pass |
| \cases a | Positive: bare[0] | Pass | Fail | Pass |
