前面博客中有提到改環境,但沒有具體的實例來進行說明其使用方法和常見的使用場合。該環境通常用在分段函數的輸入中,非常精巧方便。
如下便是我輸入的幾個例子:
演示代碼如下:
\documentclass{article}
\pagestyle{empty}
\setcounter{page}{6}
\setlength\textwidth{207.0pt}
\usepackage{CJK}
\usepackage{amsmath}
\begin{CJK*}{GBK}{song}
\begin{document}
\begin{equation} 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{equation}
\begin{equation} f(x) =
\begin{cases}
1 & \text{如果x為有理數,} \\
2
& \text{如果x為無理數,}\\
0 & \text{其他.}
\end{cases} \end{equation}
\begin{gather} \raisetag{-10pt}
\text{The sign function: \ }
\mathcal{S}(x) = \begin{cases}
-1 & x < 0 \\
0 & x = 0 \\
1 & x > 0
\end{cases}
\end{gather}
\end{CJK*}
\end{document}