2

Is it possible to create a hyperlink to a page that doesn't exist in the current document?

The reason for asking, is that I have many documents on Overleaf, which are split in order to increase productivity by focusing on one specific document at a time, and in order to alleviate compile timeouts, among other vital reasons. I am unable to switch to a local TeX installation either.

I cannot simply merge the .tex source code into one large document and compile from there, as I would easily exceed the compile timeout limits on Overleaf for my account.

Is there a specific function or piece of code utilising hyperref that allows a clickable link to redirect the user to a specific page that is not included in the current document where the link will be created, but where that page will be included once PDFs are merged together using PDFtk?

In order to clarify, the process goes as follows:

  1. Document 1 creates a clickable link to some certain page that is in Document 2, this link is useless until all PDFs are merged, only then the link finds its correct destination
  2. Documents 1 through 2 are compiled separately and merged using PDFtk
  3. Clicking on the link in Document 1 in the final merged document will take the user to the correct page that would have had been on Document 2 pre-merge

Take the following MWEs:

Document 1:

\documentclass[a4paper, 12pt]{article}
\usepackage[]{hyperref}
\usepackage{lipsum}

\begin{document}

\lipsum \lipsum \lipsum

% Create a link to page 10

\end{document}

Document 2:

\documentclass[a4paper, 12pt]{article}
\usepackage[]{hyperref}
\usepackage{lipsum}

\setcounter{page}{6}

\begin{document}

\lipsum \lipsum \lipsum

% Any code required here that would be necessary for a cross-PDF link?

\end{document}

These 2 PDFs would be merged together using PDFtk.

Some piece of code that does not work for this specific scenario is \hyperlink{page.10}{On page 10...}, I'm assuming this is due to the fact that a 10th page does not exist in Document 1, where there are only 5 available pages to create a hyperlink to.

The goal is to create a clickable link on page 1 that would take the user to page 10 after both documents have been merged.

8aa
  • 64
  • If anything in this post is unclear, I would be more than happy to remedy it either by editing or providing an additional comment to clarify certain aspects. I recognise this is a very unlikely scenario for anyone to find themselves in, much less require an answer for. Cheers in advance to anyone who attempts to take a stab at this question. – 8aa Apr 26 '22 at 21:43
  • 1
    See https://tex.stackexchange.com/questions/320468/how-to-create-a-link-to-open-attached-pdf-in-an-specific-page although I have no idea how PDFtk will affect them. – John Kormylo Apr 27 '22 at 03:58
  • 1
    You can't create a link to a not existing page in the same document as you don't know the object number, but as John wrote you can create a link to an external document with \href[page=20]{external.pdf}{on page 20} it is then up to the merge application if it can handle it. – Ulrike Fischer Apr 27 '22 at 07:29
  • @JohnKormylo and @UlrikeFischer, thank you both for providing the solution to this problem. It seems that \href[page=20]{external.pdf}{on page 20} ended up working when merged using PDFtk. Since there isn't an "answer" on this post, I'm unsure of how to either close this question, or select a comment as an answer. I have upvoted both of your comments to show my gratitude. If there is anything I can do to close this question, please do advise. – 8aa Apr 30 '22 at 13:43

0 Answers0