0

This question mentions a conflict between refcheck, subcaption and hyperref, and proposes a patch to help deal with some issues due to hyperref.

I would like to know if there is a workaround for the issue with refcheck and subcaption, in that refcheck warns about unused labels due to the sub@ prefix.

For instance, in this MWE:

\documentclass[11pt]{report}

\usepackage{subcaption}
\usepackage{refcheck}

\begin{document}
Figure \ref{fig:1a}, inside Figure \ref{fig:1}.

\begin{figure}
  \begin{subfigure}{0.45\textwidth}
    \caption{A subcaption}
    \label{fig:1a}
  \end{subfigure}
  \caption{A caption}
  \label{fig:1}
\end{figure}

\end{document}

Both labels fig:1 and fig:1a are referenced, but refcheck still reports:

Package refcheck Warning: Unused label `sub@fig:1a' on input line 12.

Is there a way to avoid the warning?

1

This redefines the subcaption label command to always report the dummy label "sub@label" as used.

\documentclass[11pt]{report}

\usepackage{subcaption}
\usepackage{refcheck}

\makeatletter
\let\orig@subcaption@@label\subcaption@@label
\def\subcaption@@label#1#2{\usedref{sub@#2}\orig@subcaption@@label{#1}{#2}}
\makeatother

\begin{document}
Figure \ref{fig:1a}, inside Figure \ref{fig:1}.

\begin{figure}
  \begin{subfigure}{0.45\textwidth}
    \caption{A subcaption}
    \label{fig:1a}
  \end{subfigure}
  \caption{A caption}
  \label{fig:1}
\end{figure}

\end{document}

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.