1

The answer https://tex.stackexchange.com/a/55620/13492, with its MWE shown below, allows creating a link to arbitrary text on a page — without the target being any kind of numbered item such as a section, theorem, equation, etc.

Question: Can it be modified so that the page number of the target will appear in the link? Or can some other approach accomplish the same thing.

In the MWE, this means that the link "this page" on page 1, which has as target page 3, would appear as "on page 3".

Ideally, the page reference would be "smart" (as with cleveref) so that if the link had been to page 2 rather than 3, the output would say instead "on the preceding page"; and if the link had been to a new page 4, the output would say instead "on the next page" (or "on the following page").

Note that one would not know ahead of time on which page the target was located, so that the approach of https://tex.stackexchange.com/a/19416 is not applicable.

\documentclass{article}

\usepackage{refcount}
\usepackage[pageanchor]{hyperref}

%% Martin Scharrer's patch for hyperref
%% available at https://tex.stackexchange.com/a/19416/9237
\makeatletter
\let\orig@Hy@EveryPageAnchor\Hy@EveryPageAnchor
\def\Hy@EveryPageAnchor{%
    \begingroup
    \hypersetup{pdfview=Fit}%
    \orig@Hy@EveryPageAnchor
    \endgroup
}
\makeatother 

\begin{document}

See \hyperlink{page.\getpagerefnumber{mypage}}{this page} for further clarification.
\clearpage

\dots
\clearpage
This is the linked page.\label{mypage}

\end{document}

From the output of the preceding, here is the page having the link.

Page with link to text on another page

2

0

You must log in to answer this question.

Browse other questions tagged .