0

I use of mathtools package and dcases environment.
Ideally, I would like to be able to write something like below:

‎\documentclass[12pt,a4paper]{article}‎
‎\usepackage{amsthm,amssymb,amsmath,mathrsfs}‎ 
\usepackage{mathtools}

\begin{document}
\begin{equation}
f(x)=\begin{dcases}
  1&x\geq0\label{positive}\\
  0&x<0\label{negative}
\end{dcases}
\end{equation}
\end{document}

and later refer to both dcases lines at different places. What would be the best way to achieve this result?

Fahim B
  • 661

1 Answers1

2

You can't do that with dcases, as far as I know, but there are two ways to obtain what you want:

  • either use the empheq package and an alignat environment (possibly with `subequations, depending on how you want to number the cases),
  • or use the numcases or the subnumcases environment from the cases package.

Here are codes for each:

\documentclass[12pt, a4paper]{article}
\usepackage{amsthm, amssymb, mathrsfs}
\usepackage{empheq}
\usepackage{cases}

\begin{document}

\begin{numcases}{f(x) =}
 1 & $ x \geq 0 $\label{pos} \\
 0 & $ x < 0 $ \label{neg}
\end{numcases}

\begin{subnumcases}{f(x) =}
 1 & $ x \geq 0 $\label{P} \\
 0 & $ x < 0 $ \label{N}
\end{subnumcases}

\begin{empheq}[left={f(x) = \empheqlbrace\,}]{alignat=2}
 1&\quad x\geq0\label{positive}\\
 0&\quad x<0\label{negative}
\end{empheq}

\begin{subequations}
\begin{empheq}[left={f(x) = \empheqlbrace\,}]{alignat=2}
 1&\quad x\geq0\label{Positive}\\
 0&\quad x<0\label{Negative}
\end{empheq}
\end{subequations}
So by \eqref{positive}, \eqref{Positive},\eqref{P} and\eqref{pos}, we have %…

\end{document} 

enter image description here

Bernard
  • 271,350