TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When a cross-reference to a figure is not on the same page as the figure, I would like to include the page number in the figure. But when they are on the same page, this is redundant--and I want to omit the page number.

In other words, I want to switch between these two styles of figure referencing depending on samepage/differentpage:

\newcommand{\figref}[1]{Figure~\ref{fig:#1}, page \pageref{fig:#1}}

Probably Testing for current page and conditionals can do this, has anybody got a recipe worked out?

share|improve this question
up vote 9 down vote accepted

Try the varioref package.



\usepackage{blindtext}% just for testing

Text \vref{fig1}. \blindtext

\blindtext[5]% change this number to see
             % the different outputs of \vref

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.