# Include the target page number in a hyperref description?

\documentclass{article}

\usepackage[pdfpagelabels=true]{hyperref}

\begin{document}

\tableofcontents

\newpage

\section{S1}
\label{s1}

\subsection{SS1}
\label{ss1}
Subsection 1
\newpage

\subsection{SS2}
\label{ss2}
Subsection 2
\newpage

\subsection{SS3}
\label{ss3}
Subsection 3.  For more info, see \hyperref[ss2]{Subsection 2, pg. How Do I Put The Target Page Number Here}.
\newpage

\end{document}


\pageref would work here.

\documentclass{article}

\usepackage[pdfpagelabels=true]{hyperref}

\begin{document}

\tableofcontents

\newpage

\section{S1}
\label{s1}

\subsection{SS1}
\label{ss1}
Subsection 1
\newpage

\subsection{SS2}
\label{ss2}
Subsection 2
\newpage

\subsection{SS3}
\label{ss3}
\pageref{ss2}}.
\newpage

\end{document}

• Is there a way to reference the page number without having to list the label id twice? – mpr May 17 '18 at 15:11
• @mpr There are many possibilities, you could write a macro for it, or you look at some of the packages like in Mico's answer or in Moewe's comment. It really depends on the overall structure of your document. Notice also that the current version has certain advantages, it allows you to refer to a special bit in the subsection that is not on the same page as the head of the subsection. – user121799 May 17 '18 at 15:16
• Yeah it just occurred to me that a macro would be perfect for my setup, and also allow me to possibly use cref or other things later. Thanks. – mpr May 17 '18 at 15:17

You could employ the cleveref package and its highly customizable \cref and \cpageref commands.

(The colors in the following screenshot highlight the hyperlink targets; if you don't want colors, be sure to set the allcolors=black option while loading hyperref.)

\documentclass{article}

\crefname{subsection}{subsection}{subsections}
\crefname{page}{pg.}{pgs.}

\begin{document}
\tableofcontents
\newpage

\section{S1}\label{s1}
Section 1

\subsection{SS1}
\label{ss1}
Subsection 1.1
\newpage

\subsection{SS2}
\label{ss2}
Subsection 1.2
\newpage

\subsection{SS3}
\label{ss3}