7

I am currently making references like this:

\section{BliBlaBlup} \label{sec:BliBlaBlup}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi pharetra
pharetra viverra. Vestibulum ante ipsum primis in faucibus orci luctus et 
ultrices posuere cubilia Curae; Suspendisse potenti. Curabitur mollis cursus 
libero, sed tempus ligula accumsan in. Nulla commodo metus quis nulla luctus 
quis euismod diam tincidunt.
[...]
As you can read in section~\ref{sec:BliBlaBlup} ...

Now, only the number that gets generated by \ref{sec:BliBlaBlup} is linked. But I would like to have Section~\ref{sec:BliBlaBlup} being linked. How can I do so?

0
4

\autoref

Lowercase section is default for \autoref. But it can be changed:

\usepackage{hyperref}
\renewcommand*{\chapterautorefname}{Chapter}
\renewcommand*{\sectionautorefname}{Section}
% ...
\begin{document}
...
As you can read in \autoref{sec:BliBlaBlup} ...

\hyperref[]

Or manually:

\usepackage{hyperref}
% ...
\begin{document}
...
As you can read in \hyperref[sec:BliBlaBlup]{Section~\ref*{sec:BliBlaBlup}} ...

The star form \ref*{...} avoids a nested link.

6

You can use the \autoref feature of hyperref:

\documentclass{article}
\usepackage{hyperref}

\begin{document}

\section{Blip}\label{blip}
What's this? A reference to \autoref{blip}.

\end{document}

enter image description here

Alternatively, if you want to capitalize the name and don't want to fiddle with hyperref's settings, you can use cleveref:

\documentclass{article}
\usepackage{hyperref}
\usepackage[nameinlink]{cleveref}

\begin{document}

\section{Blip}\label{blip}
What's this? A reference to \Cref{blip}.

\end{document}

enter image description here

2
  • What do you mean by "capitalize the name"? \Cref resulted in two ? instead of a reference and \autoref did only link the number (so it gave me the same result as I get by now). Where does the text section come from? What if blip was a reference to a figure? How would I change the text in that case? Dec 13 '12 at 9:20
  • @moose You need to compile twice in order to solve the reference and get rid of the ??. The \autoref issue probably depends on options you give to hyperref. If you want "Section 1" rather than "section 1" use \Cref with cleveref; with \cref{blip} you'd get "section 1". It works with any kind of standard references (sections, chapters, figures, tables, ...).
    – egreg
    Dec 13 '12 at 9:23

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.