[Tex/LaTex] How to link to specified page of an outer pdf document

hyperref

Recently, I made a beamer presentation and I want to link to a pdf I have made before, but I can only link to the first page of pdf document using the command:

\href{doc/mydoc.pdf}{thedoc}

and I want to link to a specific page.
Someone told me to use

\href{doc/mydoc.pdf#page.5}{thedoc}

or

\href{doc/mydoc.pdf#page=5}{thedoc}

but they don't work.
Does anyone know how to do this?

Best Answer

All hyperref/pdfLaTeX can do is insert a link of a certain form. It's up to the PDF viewer what to do with that link, and I don’t think there’s a standard link format for pages of external PDF files. Even if some viewers have implemented something for this, it wouldn’t be a robust solution.

My suggestion would be to actually include the linked-to PDF in the PDF you’re creating, and then you can use features of the pdfpages package to insert hyperlink targets for the included pages, and then you can use internal links. A quick example:

\documentclass{article}
\usepackage{pdfpages}
\usepackage{hyperref}
\begin{document}
Here's a \hyperlink{included.pdf.2}{link to to page 2 of the included pdf}.
\includepdf[pages=1-5,link=true]{included.pdf}
\end{document}

With beamer, at the end, you probably want something like:

{
\beamertemplatenavigationsymbolsempty
\setbeamercolor{background canvas}{bg=}
\includepdf[pages=1-5,link=true,fitpaper]{included.pdf}
}

so that the included PDF fits the paper size of the original for the included pages, and beamer's background color and navigation bars are suppressed on those pages.

Related Question