How could I test whether some label is on the current page, or on the previous or next one. Typically I would like to build a macro \onthispage{label}{text1}{text2} which would print text1 if the page and the text are on the same page and text2 otherwise. This could be useful when one wants to insert something like this into the TeX source:
see the figure \ref{figure}\onthispage{figure}{above}{page \pageref{figure}}.
An extension would be to have this kind of command to compare the current page to \pageref{label} and print this page, previous page, next page or page \pageref{label} accordingly.
I've tried a dirty trick with a definition of a extra label inside the command \onthispage but this fails. Any ideas ?
varioref? – Heiko Oberdiek Apr 27 '15 at 15:52