0

Consider the following (non-compiling) example:

\documentclass{article}

\usepackage{hyperref}

\begin{document}

\section{Test~A}
\label{sec:A}
Test
\newpage

\section{Test~B}
\label{sec:B}
\hyperlink{page.\pageref{sec:A}}{Something}

\end{document}

How do I extract the page number of, say, the page with the Test A section, so that I can use it within the first argument of the \hyperlink command? (\pageref is not allowed but I don't know what else to try.)

5
  • why don't you use \hyperlink[sec:A]{Something}? Aug 29, 2021 at 20:37
  • @UlrikeFischer That gives the warning pdfTeX warning (dest): name{[} has been referenced but does not exist, replaced by a fixed one and then it links to the first page (also in larger documents where the section isn't on the first page). Aug 29, 2021 at 20:50
  • 3
    Sorry I meant \hyperref[sec:A]{Something} Aug 29, 2021 at 20:58
  • That works like a charm! Thanks alot. Aug 29, 2021 at 21:04
  • 1
    To answer your question, look at \getpagerefnumber (documented in refcount, but available from hyperref). Aug 30, 2021 at 0:39

1 Answer 1

1

Using Ulrike's comment: Using something like \hyperref[sec:A]{Something} worked according to the OP's response.

You must log in to answer this question.

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