Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

As much as I have tried, it doesn't seem possible to use separate labels when using a casesconstruction (from the amsmath package).

Ideally, I would like to be able to write something like

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
f(x)=\begin{cases}
  1&x\geq0\label{positive}\\
  0&x<0\label{negative}
\end{cases}
\end{equation}
\end{document}

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

share|improve this question
add comment

3 Answers

up vote 19 down vote accepted

You can use numcases from the cases package if you want each case labelled as a separate equation. There is also the subnumcases environment which gives you an alternative labelling:

enter image description here

\documentclass{standalone}
\usepackage{amsmath}
\usepackage{cases}
\begin{document}
\begin{numcases}{f(x)=}
1&$x\geq0$\label{positive}\\
0&$x<0$\label{negative}
\end{numcases}

See the second case \ref{negative} or the first \ref{positive}

\begin{subnumcases}{f(x)=}
1&$x\geq0$\label{positive-subnum}\\
0&$x<0$\label{negative-subnum}
\end{subnumcases}

See the second case \ref{negative-subnum} or the first \ref{positive-subnum}
\end{document}
share|improve this answer
    
Exactly what I needed! Worth mentioning is the subnum package option that turns every numcases environment into a subnumcases one. –  FelixCQ Oct 19 '11 at 6:23
add comment

You can do this by the empheq package from the mh bundle.

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{empheq}   % loads »mathtools«, which in turn loads »amsmath«

\begin{document}
  \begin{empheq}[left={f(x)=\empheqlbrace}]{align}
    1 &\quad x\geq0\label{positive}\\
    0 &\quad x<0\label{negative}
  \end{empheq}
\end{document}
share|improve this answer
add comment

Using only the amsmath package and no additional packages, it is possible with some box manipulation:

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
\newsavebox{\mycases}% Store case "title" and brace
\begin{align}
  \sbox{\mycases}{$\displaystyle f(x)=\left\{\begin{array}{@{}c@{}}\vphantom{1\ x\geq0}\\\vphantom{0\ x<0}\end{array}\right.\kern-\nulldelimiterspace$}
  \raisebox{-.5\ht\mycases}[0pt][0pt]{\usebox{\mycases}}1 \quad x\geq0\label{positive} \\
     0 \quad x<0\label{negative}
\end{align}
\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.