4

I am trying to get a link to a page that is relative to a hypertarget. For example, in the MWE I would like to get one page after the link chap2, so that my link goes to the page after.

\documentclass{book}
\usepackage{mwe}
\usepackage{hyperref}

\begin{document}

\chapter{Chapter 1}

\hyperlink{chap2}{Here is the second page of chapter 2}  % What should go here?

\lipsum[1]

\chapter{Chapter 2}
\hypertarget{chap2}{}
\lipsum[1-20]

\end{document}

1 Answer 1

4

Adding the afterpage package to your preamble and using

\afterpage{\phantomsection\hypertarget{chap2}{}}

will create a hypertarget at the top-left corner of the text block on the second page of the chapter:

\documentclass{book}
\usepackage{hyperref,lipsum,afterpage}

\begin{document}

\chapter{Chapter 1}

\hyperlink{chap2}{Here is the second page of chapter 2}  % What should go here?

\lipsum[1]

\chapter{Chapter 2}
\afterpage{\phantomsection\hypertarget{chap2}{}}% Hypertarget on p2 of chapter
\lipsum[1-20]

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .