# PDF hyperlinks to a given page.

I would like a command that takes two arguments: a page number and a block of text. I would like the command to create a PDF hyperlink around the text that will jump to the given page.

I see that the undocumented \hyperpage{} command from the hyperref package will create a link to the given page, however, I don't see how it can be used to make a link for arbitrary text. I took a look at the underlying code in hyperref.sty but I can't really figure it out.

I do realize that I could use \hyperlink{}{}, but that requires I put a \hypertarget{}{} on each of the pages to be linked. In my case, I only know the numerical number of the page to be linked.

-
I also tried the solutions listed here: tex.stackexchange.com/questions/1021/… but none seemed to apply for my problem. –  ESultanik Aug 16 '10 at 19:45

You could use \hyperlink with the already defined page targets:

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\newpage
text on page 2
\end{document}

-
Thanks; that worked! I had tried \hyperlink{Page.2}{Go to page 2}, but that caused errors. I guess the "page" is case sensitive. –  ESultanik Aug 16 '10 at 20:42
Yes. \hyperpage relies on those anchor names, it uses \hyperlink{page.\the\toks@}{\the\toks@} in hyperref.sty. –  Stefan Kottwitz Aug 16 '10 at 20:51

Not sure it is the same, but you can create a link with something like this.

First you add a label somewhere in the document.

\label{sec:listOfFiles}


\ref{sec:listOfFiles}
\pageref{sec:listOfFiles}


\usepackage{hyperref}


it becomes a link you can click on.

-
That is not what I want. The "\pageref{}" command typesets the page number of the associated label. I want to have an arbitrary string with a link to a specific page number. For example, I might want to typeset the text "click here to go to page 10" and have that text link to page 10 of the document when clicked from the PDF. Since I don't know a priori how TeX is going to break the pages, I wouldn't know where to put the "\label{}" such that it were guaranteed to be on page 10. –  ESultanik Aug 16 '10 at 20:38
ok, a "arbitrary string" is not possible with this method. And you would add the label right next the the thing you need to link to, and then pageref gives you what page that is. But that is also the opposite from what you what. –  Johan Aug 16 '10 at 20:48