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?

Mark
  • 1,393
  • refcheck manual says that it should be loaded after hyperref, but using it the other way round will make the error message to vanish –  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 –  Mar 29 '16 at 15:16
  • See my updated answer please. –  Mar 29 '16 at 15:19

1 Answers1

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}
  • I don't know what sorcery this is, but it certainly seems to work. I don't need the star variants anyway. I have no clue how you did that so fast. I sometimes suspect some of you people know the code for every package on ctan or something. Anyway, thank you!! – Mark Mar 29 '16 at 15:31
  • @Mark: Usually we have CTAN almost completely on our disks, so it's 'easy' to look into the code ;-) –  Mar 29 '16 at 15:32
  • Obviously you have it on disk, but no mere mortal could read and understand an entire package like refcheck that fast, surely? – Mark Mar 29 '16 at 15:35
  • 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 ;-) –  Mar 29 '16 at 15:51
  • Fair enough... I'm still going to call it sorcery :) – Mark Mar 29 '16 at 15:53
  • Do you suppose it makes sense to report this as a bug/feature request to the refcheck maintainer? – Mark Mar 29 '16 at 16:59
  • @Mark: Let's call it a missing feature :D (It's no bug really -- the maintainer(s) just forgot to take care about \nameref) –  Mar 29 '16 at 17:53
  • So, do you think it makes sense to ask for this feature? – Mark Mar 29 '16 at 19:59
  • 1
    @Mark: Yes, I think so. The maintainer's mail address can be found on CTAN –  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! –  Mar 30 '16 at 02:58
  • No response so far. – Mark Mar 30 '16 at 18:40
  • 1
    @Mark: Well, I did not expect the Spanish Inquisition --, I mean, a quick response ;-) –  Mar 30 '16 at 19:27
  • 1
    @Mark: Any news? –  Apr 11 '16 at 18:49
  • And answer came there none :( – Mark Apr 11 '16 at 22:50
  • 1
    @Mark: Looks like the author abandoned the maintenance of the package. –  Apr 11 '16 at 22:51
  • Probably. Unless there's some other explanation we're missing. – Mark Apr 11 '16 at 23:23
  • @Mark: Unless the author isn't on an expedition to the two summits of Mount Kilimanjaro (;-)) and will not return before the next Star Wars movies is released, we have to wait some time and if there's no reaction, the take-over-authorship-and-rule-the-world machinery starts (however, I've no idea how to trigger this. Perhaps I've to ask the folks of CTAN about this) –  Apr 11 '16 at 23:27
  • Shouldn't at least someone else send an email first, to make sure it's not just an allergic reaction to my email or something? :) – Mark Apr 11 '16 at 23:28
  • @Mark: Define 'someone'. John Doe? –  Apr 11 '16 at 23:29
  • Someone from CTAN? – Mark Apr 11 '16 at 23:31
  • 1
    @Mark: I think that's the usual way to achieve this. I can ask Joseph Wright also -- he has taken over maintenance for some packages, I think he knows the procedure. Besides all of this: the CTAN folks sometimes have another mail address of the authors to contact them, which differs from the official package 'mail address'. –  Apr 11 '16 at 23:34
  • 1
    @Mark: And it will certainly not me who takes the maintenance. In this case, Heiko Oberdiek (maintainer of hyperref) should do the job (he will curse me for this proposition ;-)) and thereby use his knowledge, of course –  Apr 11 '16 at 23:41
  • 1
    Oh dear. Look what I've started. I didn't mean to start curses flying! ;) – Mark Apr 11 '16 at 23:43
  • 1
    @Mark: See the very related question (about the maintenance issue) here: http://tex.stackexchange.com/questions/188430/publishing-a-package-update-on-ctan –  Apr 11 '16 at 23:45