How to write a equation like the following which contain many regions?

Asked
Active
Viewed 2,823 times
2 Answers
4
Use cases environment
\documentclass{article}
\usepackage{amsmath}
\begin{document}\begin{equation}
f(n) = \begin{cases} n/2 &\mbox{if } n \equiv 0 \\
(3n +1)/2 & \mbox{if } n \equiv 1 \\
(3n +1)/2 & \mbox{if } n \equiv 1
\end{cases}
\end{equation}
\end{document}

David Carlisle
- 757,742
Red
- 10,181
-
1Better
\text{…}than\mbox{…}. And if you loadmathtoolsinsteado ofamsmath, you can usecases*environment, which sets the second column to text mode. – Manuel Dec 11 '13 at 16:34
3
Here is MWE that can help you to begin:

\documentclass{article}
\usepackage{amsmath,amssymb}
\begin{document}
\[ X_i=
\begin{cases}
0 & \text{ for } i=0\\
(X_{i-1}\oplus A_i)\cdot H & \text{ for } i=1,\dotsc,m-1
\end{cases}
\]
\end{document}
Also read the following:
casesenvironment. – azetina Dec 11 '13 at 15:44casesis a good choice. You can also usearray, if for some reason you don't want to useamsmath. But I can see some additional traps. In particular, what arelenand||? Their behaviour should depend on their function. – Przemysław Scherwentke Dec 11 '13 at 16:09