According to the varioref package documentation:

The implementation of \vref below produces only a \ref when reference and \label are on the same page. It will additionally produce one of the strings ‘on the facing page’, ‘on the preceding page’, or ‘on the following page’, if label and reference differ by one and it will produce both \ref and \pageref when the difference is larger. The word ‘facing’ is used when label and reference both fall onto a double spread. However, if a special page numbering scheme is used instead of the usual arabic numbering (e.g., \pagenumbering{roman}) then there will be no distinction between one or many pages off.

I would like to use \vref but have it output a \nameref instead of a \ref. I don't think varioref provides an option for this; is it possible to achieve this in a simple way?

  • You should take a look at at the cleveref package documentation (cleveref has to be loaded after varioref). – Bernard Jan 13 '17 at 11:38
  • Please give a specific example of what you have in mind. – Mico Jan 13 '17 at 12:02
  • Please give an example of a \nameref. – Mico Jan 13 '17 at 12:10
  • \section{Introduction}\label{intro} [...] Please see section \nameref{intro} on page \pageref{intro} – Grodriguez Jan 13 '17 at 12:17
  • @Mico \nameref is provided by the nameref package which is part of the hyperref bundle – clemens Mar 17 '17 at 15:03

You can patch the internal \vr@f (which should be rather safe I believe):


% replace \ref with \nameref,
% \patchcmd is provided by the etoolbox package:


\section{Foo bar baz}\label{sec:foo}


See section \vref{sec:foo}


I have achieved what I needed by defining a new command \xref as follows:

\newcommand{\xref}[1]{\nameref{#1} \vpageref[\unskip]{#1}}

This outputs a \nameref, and additionally a string similar to 'on page XX' if reference and \label are not on the same page.

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.