[Tex/LaTex] Cases environment with angle brackets

amsmathbracketscases

I would like to create a cases environment showing an angle bracket, instead of a curly one. I can't re-define the environment itself because I have to use the new environment together with the old one, that is I have to use 'curly cases' and 'angle cases' in the same document. Is there a package I could use?

Best Answer

The following code updates cases to take an optional argument. The optional argument is used as the left delimiter instead of the traditional (default) \lbrace:

enter image description here

\documentclass{article}

\usepackage{amsmath,etoolbox}

\makeatletter
\renewenvironment{cases}[1][\lbrace]{%
  \def\@ldelim{#1}
  \matrix@check\cases\env@cases
}{%
  \endarray\right.%
}
\patchcmd{\env@cases}{\lbrace}{\@ldelim}{}{}
\makeatother

\begin{document}

\[
  f(x) = \begin{cases}
    a & \text{if $x < 0$} \\
    b & \text{otherwise}
  \end{cases}
\]

\[
  f(x) = \begin{cases}[\langle]
    a & \text{if $x < 0$} \\
    b & \text{otherwise}
  \end{cases}
\]

\end{document}

It should function as expected, even if nested:

enter image description here

\[
  f(x) = \begin{cases}
    a & \text{if $x < 0$} \\
    b & \begin{cases}[\langle]
      {} + c & \text{if $x < 7$} \\
      {} + d & \text{otherwise}
    \end{cases}
  \end{cases}
\]

However, you may be better off using a regular array. It depends on how you nest the content.