hyperref
hyperref copied to clipboard
Code behavior and doc explanation about class option "implicit"
Problem reproduction
This latex document produces error "Undefined control sequence: \@pagerefstar"
\documentclass{article}
\usepackage[implicit=false]{hyperref}
\begin{document}
a\label{key}
b\pageref*{key}
\end{document}
While compiling, the following steps happen in turn (this may contain mistakes):
hyperrefprocesses package options(s), which makes\Hy@implicitfalse\pagerefis redefined to use\@pagerefstarin star form\ifHy@implicitis tested, then\MaybeStopEarlyis defined to contain\endinput\MaybeStopEarlyis expanded since not equal to\relax, hence\endinputis inserted- defintion of
\@pagerefstaris skipped, hence\@pagerefstaris never defined, which causes theUndefined control sequenceerror.
Questions
- In the current doc of
hyperref, Sec. 3.1, optionimplicitis documented asredefines LaTeX internals. But even ifimplicit=falseis used, result of using\pageref*is still changed, compared toarticleclass withouthyperref.
To make things more consistency, do we need to restore/postpone the redefinition of\pagerefifimplicit=falseis used? - Maybe it is better to provide a list of "what does the option
implicit=falseturn off" to the currentimplicit-related documentation. This will remind user "which part ofhyperrefis turned off if I setimplicitto false or use a document class likebeamerwhich turns offimplicitimplicitly"
There must be other commands acts like \pageref, I use \pageref as an example only.
Related source ranges (this reflects what I have known so far, and may contain mistakes):
step 2 https://github.com/ho-tex/hyperref/blob/068644918d98531b2376b536ed2263803b34b871/hyperref.dtx#L7742-L7744
step 3 https://github.com/ho-tex/hyperref/blob/068644918d98531b2376b536ed2263803b34b871/hyperref.dtx#L7351-L7375
step 4 https://github.com/ho-tex/hyperref/blob/068644918d98531b2376b536ed2263803b34b871/hyperref.dtx#L10661-L10665
step 5 https://github.com/ho-tex/hyperref/blob/068644918d98531b2376b536ed2263803b34b871/hyperref.dtx#L13311-L13313
Hm. yes from the logic and the documentation implicit=false should prevent the redefinition of \pageref. But then \pageref*{key} will not error but instead give
Reference `*' on page 1 undefined on input line 141
and print ??key, which isn't ideal either. Probably the best would be to add
\ifHy@implicit \else \let \@pagerefstar\T@pageref \fi
after the \pageref definition.
But then
\pageref*{key}will not error but instead giveReference `*' on page 1 undefined on input line 141and print
??key, which isn't ideal either.
Yes, and this is truly the same behavior with latex2e.
I understand that an ideal output is preferred, but then the related part of documentation is not easy to write.
Personally, I never use option implicit. But since beamer class loads hyperref with implicit=false, and this changes the syntax of user commands of hyperref, beamer users may need a documentation which lists "what does the option implicit=false turn off" and hence "which part of functions of hyperref is supported in beamer". Again personally, I think it is the responsibility of hyperref to provide such documentation, which then can be referred in doc of beamer.