1

When trying to cross-reference one of the multi-case equations in the subnumcases environment with cleveref, only the equation number is shown and not the letter. Example:

\documentclass{article}
\usepackage{cases}
\usepackage{cleveref}
\begin{document}

\begin{subnumcases}{y=}
   x^2 + 1, & $n = 1$ \label{eq:1}\\
   3x^2 + 2, & $n > 1$ \label{eq:2}
\end{subnumcases}

We first want to refer to equation 1a with \Cref{eq:1}.
Then to equation 1b with \Cref{eq:2}.

\end{document}

Output:

enter image description here

What is going wrong here?

  • The equation number 1a etc. is not transported into \@currentlabel which stores the reference value to the .aux file finally -- that's wrong with it – user31729 Feb 15 at 20:41
  • Possibly related: cleveref and cases packages clash – Bubaya Feb 15 at 20:44
1

A quick and dirty hack would be to take the solution for the linked question, and alter it in the following way: we define a new environment mysubnumcases, which contains empheq, but first we

  1. save the old value of the equation counter to a new one,
  2. reset the equation counter to zero,
  3. alter the appearance of equation numbers by renewing \theequation,
  4. have the empheq environment,
  5. restore the value of the equation counter.

so we have:

\documentclass{article}
\usepackage{empheq} % loading `mathtools` % loading `amsmath`
\usepackage{cleveref} % load this as very last package

\newcounter{case}
\newenvironment{mysubnumcases}{
    \begingroup
    \stepcounter{equation}
    \setcounter{case}{\theequation}
    \setcounter{equation}{0}
    \renewcommand\theequation{\arabic{case}\alph{equation}}
    \empheq[left={=\empheqbiglbrace~}]{align}
}{
    \endempheq
    \setcounter{equation}{\thecase}
    \endgroup
}
\begin{document}    
    \section{Intro} 
    \begin{equation}
        A=B \label{eq1}
    \end{equation}
    Some text
    \begin{mysubnumcases}
        a&=b\label{eq2}\\
        c&=d\label{eq3}
    \end{mysubnumcases}
    Some text
    \begin{equation}
        A=B \label{eq4}
    \end{equation}
    Cleveref references: \cref{eq1} \cref{eq2} \cref{eq3} \cref{eq4}.
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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