[Tex/LaTex] numcases environment with showlabels package

casesnumberingshowlabels

I just discovered the environment numcases, which upgrades the package cases allowing to number the different cases.

I am also currently using the showlabels package, which puts the name of the label on the PDF, right where you put it in the TeX file. Very useful feature, especially when writing a long document and you want to get the tag name from the PDF scrolling up a page rather than open another TeX file and search for the equation!

Unfortunately, I can't get the numcases environment to work properly with the showlabels package. In particular, I cannot give a label to the last case, otherwise I get the error "Incompatible list can't be unboxed". However, without the showcases package, everything works smoothly. It also works smoothly if I don't label the last case, but of course that's not optimal, cause I need to label all the cases…

Here's an example. Comment/uncomment the line where the showlabels package is included to see the behavior.

\documentclass{article}

\usepackage{showlabels}
\usepackage{cases}

\begin{document}

\begin{numcases}{}
a & b \label{a}\\
c & d \label{b}
\end{numcases}

\end{document}

Does anybody know a workaround for this? I would be fine also with a way to avoid numcases (while getting the same result).

Best Answer

I cannot understand why lines of a cases environment should be separately numbered. However, you get the effect with empheq:

\documentclass{article}

\usepackage{empheq}
\usepackage{showlabels}

\begin{document}

\begin{empheq}[left=\empheqlbrace]{alignat=2}
&a\qquad & b \label{a}\\
&c\qquad & d \label{b}
\end{empheq}

\end{document}

enter image description here

Related Question