1

Consider the following MWE

\documentclass[12pt]{article}
\usepackage[colorlinks]{hyperref}
\usepackage[norefs]{refcheck}
\begin{document}
As we will see later (see \nameref{ans}), the answer is 42.
\section{The answer}\label{ans}
This simplifies to 42.
\end{document}

This typesets properly, but I get a warning that ans is never referenced. How can I get refcheck to realize that it was?

  • refcheck manual says that it should be loaded after hyperref, but using it the other way round will make the error message to vanish – user31729 Mar 29 '16 at 15:06
  • Unfortunately, the manual is right. Loading it the other way is equivalent to not loading refcheck at all, so it's not too surprising the error vanishes :) – Mark Mar 29 '16 at 15:13
  • refcheck does a lot of redefinitions with the internal commands \ref etc. Perhaps this can be replicated for \nameref as well – user31729 Mar 29 '16 at 15:16
  • See my updated answer please. – user31729 Mar 29 '16 at 15:19
2

Warning, this does not work for \nameref* so far...

refcheck redefines the usual \...ref commands like \ref, \pageref and \biblabel etc., and hooks into those commands, storing the argument to a list (of used label names) but it does not provide a similar approach for \nameref.

I assume, that \cref etc. from cleveref will fail as well then.

\documentclass[12pt]{article}
\usepackage[colorlinks]{hyperref}
\usepackage[norefs]{refcheck}
\makeatletter
\AtBeginDocument{%
\let\@@nameref@@\nameref
\expandafter\DeclareRobustCommand\expandafter
{\csname relax\string\nameref\endcsname}[1]{\@@nameref@@{#1}\wrtusdrf{#1}}%
\expandafter\let\expandafter\nameref\csname relax\string\nameref\endcsname
}
\makeatother

\begin{document}
As we will see later (see \nameref{ans}), the answer is 42.
\section{The answer}\label{ans}
This simplifies to 42.
\end{document}
  • 1
    @Mark: I had just a suspicion that refcheck would use a hooking approach for \label and \ref.... -- the rest was copying and adapting to \nameref ;-) – user31729 Mar 29 '16 at 15:51
  • 1
    @Mark: Yes, I think so. The maintainer's mail address can be found on CTAN – user31729 Mar 29 '16 at 20:07
  • 1
    Yep, you're right, found it. Emailing now. – Mark Mar 29 '16 at 22:45
  • 1
    @Mark: That's fine. Please keep me informed, by chance! – user31729 Mar 30 '16 at 2:58
  • 1
    @Mark: Well, I did not expect the Spanish Inquisition --, I mean, a quick response ;-) – user31729 Mar 30 '16 at 19:27

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.