[Tex/LaTex] Mathtools’ showonlyrefs fails with subequations

mathtoolssubequations

For the code

\begin{subequations}\label{eq:sub}
\begin{gather}
  \frac{\text{d}b_1}{\text{d}z} - \im\beta_1b_1 = C_{12}b_2,\\
  \frac{\text{d}b_2}{\text{d}z} - \im\beta_2b_2 = C_{21}b_1.
\end{gather}
\end{subequations}

with \mathtoolsset{showonlyrefs=true,showmanualtags=true}, the \eqref correctly references the equation group number, however the equations themselves appear in the document without numbers (so the previous equation is, say (2.7), the following one is (2.9) and no numbers 2.8a and 2.8b). Is it to be expected? Is there a work-around?

Best Answer

A workaround might be to label the two inner equations and use \noeqref to silently reference them. At the moment showonlytags does not take subequations into account, and might be difficult to implement.

Here is how showonlyrefs works. \eqref sets a special marker label to mark a given label referred to. mathtools changes the manner in which the equation numbers are typeset to see if the local label has been marked. If not it is not typeset.

The problem here is that the outer label will never be seen by the eq number typesetter within the gather.

EDIT: this works. BTW: next time please post a minimal example not a sniplet, I have no idea what \im is.

\documentclass[a4paper]{article}
\usepackage{mathtools}
\mathtoolsset{showonlyrefs=true,showmanualtags=true}
\begin{document}
\begin{subequations}\label{eq:sub}
  \noeqref{eq:1,eq:2}
  \begin{gather}
    \frac{\text{d}b_1}{\text{d}z} - \beta_1b_1 = C_{12}b_2,\label{eq:1}\\
    \frac{\text{d}b_2}{\text{d}z} - \beta_2b_2 = C_{21}b_1.\label{eq:2}
  \end{gather}
\end{subequations}
\eqref{eq:sub}
\end{document}