3

When you are using the hyperref package, it creates nice, clickable links within the PDF output when you use cross references (\ref{chap:label}). But, when I refer to "Section 1", only the "1" is clickable. Is there away to add arbitrary, or semi-arbitrary text to one of these references?

5

Yes. hyperref provides \hyperref[<link>]{<stuff>}:

enter image description here

\documentclass{article}
\usepackage{hyperref}% http://ctan.org/pkg/hyperref
\begin{document}
\section{A section}\label{mysection}
See \hyperref[mysection]{Section~\ref*{mysection}}.
\end{document}

To avoid a hyperlink within a hyperlink, it also provides \ref*. For less arbitrary but still automated text additions to cross references, it provides \autoref:

enter image description here

\documentclass{article}
\usepackage{hyperref}% http://ctan.org/pkg/hyperref
%\providecommand{\sectionautorefname}{Section}
\begin{document}
\section{A section}\label{mysection}
See \hyperref[mysection]{Section~\ref*{mysection}} or \autoref{mysection}.
\end{document}

You need to set \<counter>autorefname for each of the <counter>s you would reference.

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.