3

Consider the following MWE:

\documentclass[12pt]{article}
\usepackage[colorlinks]{hyperref}
\usepackage[norefs]{refcheck}
\begin{document}
Why?
\label{stuff}
Because \autopageref{stuff}
\end{document}

The \autopageref command doesn't work. Is there some wizardry akin to Making refcheck work with cleveref I should use?

edit: even a comment like "I have no clue" would be appreciated at this point.

2 Answers 2

3
+50

Try this one:

\documentclass[12pt]{article}
\usepackage[verbose,colorlinks]{hyperref}
\usepackage[norefs]{refcheck}

\makeatletter
\renewcommand*{\autopageref}{\@ifstar{\@autopagereffstar}{\@autopagereffnostar}}

\newcommand*{\@autopagereffstar}[1]{\HyRef@autopagerefname \pageref{#1}}
\newcommand*{\@autopagereffnostar}[1]{\hyperref[#1]{\HyRef@autopagerefname \pageref{#1}}}
\makeatother

\begin{document}
Why?
\label{stuff2}
\label{stuff}
Because \autopageref{stuff}

\end{document}

This is the log:

Package: `refcheck' v1.9.1 <2013/02/14>
options: showrefs, showcites, msgs, chckunlbld

Package refcheck Warning: Unused label `stuff2' on input line 14.

(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/se-ascii-print.def)
[1] (./test.aux) )
Output written on test.pdf (1 page).
SyncTeX written on test.synctex.gz.
Transcript written on test.log.

This is the result I get: enter image description here

Using the workaround proposed in the link provided by @Naphaneal:

\documentclass[12pt]{article}
\usepackage[verbose,colorlinks]{hyperref}
\usepackage[norefs]{refcheck}


\makeatletter

\AtBeginDocument{%
  \@ifpackageloaded{refcheck}
  {%
    \@ifundefined{hyperref}{}{%
      \let\T@ref@orig\T@ref%
      \def\T@ref#1{\T@ref@orig{#1}\wrtusdrf{#1}}%
      \let\@refstar@orig\@refstar%
      \def\@refstar#1{\@refstar@orig{#1}\wrtusdrf{#1}}
      \DeclareRobustCommand\ref{\@ifstar\@refstar\T@ref}%
    }%
  }{}%
}

\makeatother

\begin{document}
Why?
\label{stuff2}
\label{stuff}
Because \autopageref{stuff}

\end{document}

this is what I get:

Package: `refcheck' v1.9.1 <2013/02/14>
options: showrefs, showcites, msgs, chckunlbld

Package refcheck Warning: Unused label `stuff2' on input line 25.


Package refcheck Warning: Unused label `stuff' on input line 26.


LaTeX Warning: Reference `*' on page 1 undefined on input line 27.

(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/se-ascii-print.def)
[1] (./test.aux)

LaTeX Warning: There were undefined references.

 )
Output written on test.pdf (1 page).
SyncTeX written on test.synctex.gz.
Transcript written on test.log.

and this is the document produced

enter image description here

Hope this will help!

5
  • I'm pretty sure that page is wrong. I admit that your example fixes the immediate problem, but the side effect is that refcheck no longer works. That is, it no longer warns about unused labels.
    – Mark
    Commented Mar 18, 2016 at 22:47
  • 1
    I've edited the answer: you were right.
    – PieCot
    Commented Mar 19, 2016 at 0:22
  • Wow. After seeing so many magic incantations on this site, your solution is beautifully simple. Considering I don't need the * forms of the commands, your solution collapses to \def\autopageref#1{page~\pagref{#1}}. As far as I can tell though, your * form is not right: it still creates a hyperlink (but only for the page number, and not the word page). Actually, the non-starred form technically creates a nested hyperlink, but I guess it does no harm.
    – Mark
    Commented Mar 19, 2016 at 4:02
  • Edit time out expired: I should have said it collapses to \def#1{\hyperref[#1]{page~\pageref{#1}}}
    – Mark
    Commented Mar 19, 2016 at 4:12
  • There's a timeout before I can award the bounty. Leave a comment here if I forget.
    – Mark
    Commented Mar 19, 2016 at 4:13
1

As explained here refcheck disrepects hyperref on certain levels. Also there is a workaround provided which might help in your case.

1
  • Nope, doesn't help. Thanks though.
    – Mark
    Commented Mar 19, 2016 at 3:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .