i was idly wondering instead of having see Section \ref{labelname} produces

see Section 4.1.1

i could make it so that see Section \ref{labelname} produces

see Section 4.1.1 (p65)

is this possible? Would using hyperref mess this up?


You can define a command, like \myref

\newcommand{\myref}[1]{\ref{#1} (p\pageref{#1})}

Then you can use \myref{xxx}

  • thanks, that works good, i cant seem to get it replace the \ref command with this though.
    – GreyCloud
    Aug 21 '12 at 10:12
  • 2
    You can use \let\oldref=\ref \renewcommand{\ref}[1]{\oldref{#1} (p\pageref{#1})}. It's simple yet maybe not very robust.
    – goodluck
    Aug 21 '12 at 11:50
  • Heiko Oberdiek's answer should be more robust.
    – goodluck
    Aug 21 '12 at 11:56

The cleaner way would be a new macro like in the answer of goodluck. But also \ref can be redefined. It should be done as late as possible, because many packages redefines it. In the solution it is done in \AtBeginDocument at the end of the preamble, especially after package hyperref is loaded.

Also package hyperref supports a star form that generates the reference without the link. For example, this is useful if the reference is part of another reference to avoid nested links.


      \original@ref*{#1} \textbf{(p\pageref*{#1})}%
      \original@ref{#1} \textbf{(p\pageref{#1})}%

\section{Foo bar}
\subsection{Hello World}
This is subsection \ref{sec:hello}.

Reference link with page


Maybe you would like to take a look at the varioref package with its command \vref. This will generate your demanded output. In addition, this does not have an effect on your hyperref settings.

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.