2

Consider the following MWE:

\documentclass{article}

\usepackage{lipsum}
\usepackage{hyperref}

\begin{document}

\section{Test~A}
\label{section:test-a-start}
\lipsum

\subsection{Test~A2}
\lipsum\\[\baselineskip]
\label{section:test-a-end}

\section{Test~B}
\label{section:test-b}
The former section ranges from page~\pageref{section:test-a-start} to \pageref{section:test-a-end}.

\end{document}

It seems to me that \pageref{section:test-a-end} gives the page number at the very end of the first section which is what I want.

However, when using hyperref, \pageref{section:test-a-end} links to the beginning of the last subsection. Can I somehow link to the end of the subsection (and thereby the end of the section) rather than to the beginning of it?

2

Insert a \phantomsection to mark a different location to what was set with the previous \refstepcounter:

\phantomsection\label{section:test-a-end}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.