4

The "ChangeLog for hyperref bundle" file claims that support for the showkeys package was added to hyperref in various stages on 2000-05-08, 2001-01-27, and 2007-05-29. However, there still seem to be some incompatibilities between the two packages. Furthermore, some strange interactions occur depending on which of the two packages is loaded first.

Consider the following MWE, where showkeys is loaded before hyperref:

\documentclass{article}
\usepackage{showkeys}
\usepackage{hyperref}

\begin{document}

\section{New Section}
\label{some-label}

This is a really important section.

Now we want to refer to~\autoref{some-label} on \autopageref{some-label}.

What if we just refer to section~\ref{some-label} on page~\ref{some-label}?
This seems to work fine.

\begin{thebibliography}{99}
\bibitem{abc}
    This book has no title.
\end{thebibliography}
\end{document}

First of all, it appears that the \autopageref command has no support for package showkeys, as the label is not printed. Next, with this example, the \bibitem key is not printed either.

On the other hand, suppose we reverse the package loading order, and load hyperref before showkeys. In this case, the key for \bibitem is displayed correctly, but now \autopageref is totally broken: The page number is missing from the output text, replaced by ??some-label, and the following warning is written:

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

So when I prepare my draft documents, I'm stuck having to choose between having the \bibitem keys not shown or having \autopageref totally broken. I can live with the \autopageref keys not being shown, as long as the output is the correct text (showkeys before hyperref), but I really want to have the \bibitem keys shown (hyperref before showkeys) so that I can copy the labels into citations when typing the rest of the document. How can I correct one or the other of these problems to get the best of both scenarios?

3

The hyperref manual states in Section 8:

Packages that typeset the contents of the \label and \ref macros, such as showkeys. Since the hyperref package redefines these commands, you must set implicit=false for these packages to work.

Your example appears to work for me if the document starts as follows:

\documentclass{article}
\usepackage{showkeys}
\usepackage[implicit=false]{hyperref}
  • 2
    But then the hyperlinks disappear, defeating the purpose of loading hyperref. Moreover, \autoref and \autopageref both produce only the number 1, rather than the intended section 1 and page 1 (respectively). – Ari Brodsky Aug 25 '15 at 22:55

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.