I found a conflict between the hyperref/subcaption/refcheck packages.
I was using figures with subfigures and subcaptions, enabling the hyperref package for cross referencing in the document without any problems so far.
When I included the refcheck package to check for unused bib items and cross references, it causes problems if I cross link a subfigure using the \subref{...}
command to a figure label with underscores, eg. \label{fig:A_A_A}
, in the caption of the figure environment (see MWE with \subref{fig:A_A_A}
)
It complaings about missing $ as if it would like to put the underscores in math mode.
Missing $ inserted [...]
Any ideas how to fix this conflict?
EDIT: If I load the refcheck package before the other two packages, the document compiles fine, but then actually the refcheck package functionality is lost, i.e. no warnings about unused references.
MWE.tex
\documentclass[a4paper,11pt]{report}
\usepackage{hyperref} %Make hyperlinks available
\usepackage{subcaption} %Make subfigures available
%commenting out this package restores the working version
\usepackage{refcheck} %Warn for unused bibitems
\begin{document}
Figure \ref{fig:A_A} %no problem with the reference here
\begin{figure}[bhpt!]
\centering
\begin{subfigure}{0.45\textwidth}
\rule{3cm}{3cm} %dummy for a grafic
\caption{A subcaption}
\label{fig:A_A_A} %problematic label for subfigure with underscores
\end{subfigure}
\caption[A short caption]%
%caption without the subref works without any problems
%{A long caption without a subref}
%caption with subref for the label with underscores causes problem
{A long caption with a subref with underscores \subref{fig:A_A_A}}
\label{fig:A_A} %no problem with label for figure with underscores
\end{figure}
\end{document}