latex3 / latex3/hyperref

`hyperref` makes `varioref`'s `\vrefformat` no-op

Open
#225 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
205
Forks
41
PR merge metrics
No merged PRs in 30d

Description

Currently, hyperref makes varioref's user customization option \vrefformat no-op, as shown in the MWE below:

\documentclass{article}

\usepackage[nospace]{varioref}
\usepackage{hyperref}

\renewcommand*{\vrefformat}[2]{%
  Foo \ref{#2} \vpageref[#1]{#2}}

\begin{document}

\section{Section 1}
\label{sec:section-1}

\clearpage{}

\vref{sec:section-1}

\end{document}

Renders:

Screenshot from 2022-01-31 17-06-08

Commenting hyperref out of the above document renders:

Screenshot from 2022-01-31 17-07-41

This happens because hyperref redefines \vr@f and \vref@star (I haven't tested, but I presume the same problem occurs with \Vref for the same reason). And does so without using \vrefformat (and \Vrefformat), but hard-coding the formats in the redefinitions it makes.

As far as I can tell, this is done at: https://github.com/latex3/hyperref/blob/c25f44c5d880a5897376d947957e7a129b376e6c/hyperref.dtx#L13027-L13058

I don't know if there's a reason for this that I've missed, but it seems possible, at first glance, to use \vrefformat instead of hard-coding it (maybe redefining \vrefdefaultformat for this). And thus not override this user option from varioref.

Edit: Besides what was already mentioned, the above also means that \usepackage[japanese]{varioref} won't work with hyperref (well, theoretically at least, I don't actually know how to set up a document in Japanese).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with hyperref.dtx around lines 13027–13058, focusing on the redefinitions of \vr@f and \vref@star, then compile the supplied LaTeX MWE with and without hyperref. Confirm that a customized \vrefformat is honored when hyperref is loaded, and investigate whether the corresponding \Vref behavior is also covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
latex
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.