27

I saw in some articles, the links in the table of content appear in the pages. For example, suppose the first section, Introduction, is at page 11 as the following:

1 Introduction 11

Then the box showing the link is at around number 11 (page number).

In my machine, however, when I use \tableofcontents, the box is around the section title, i.e. "Introduction".

What is the setting I'm missing here? Thanks.

2
  • 6
    Try \usepackage[linktocpage=true]{hyperref}
    – user31729
    Apr 13, 2015 at 21:40
  • @ChristianHupfer Hi, can you change your comment to an answer so that I can accept it. Thank you very much.
    – sean
    Apr 13, 2015 at 21:41

2 Answers 2

32

The standard setup of the package hyperref is to use the content titles (i.e. the section or chapter etc. names) in the ToC as link, however, the option linktocpage=true to hyperref or in \hypersetup will use the page number, saying linktocpage only will work as well (for the lazy ones ;-)

\documentclass{article}
\usepackage{blindtext} 
\usepackage[linktocpage]{hyperref}
\begin{document}
\tableofcontents
\section{First}
\blindtext[5]
\section{Second}
\blindtext[10]
\end{document}

enter image description here

0
23

It is even possible to link both: The section label and the page number. Just pass linktoc=all.

\usepackage[linktoc=all]{hyperref}

Full example:

\documentclass{article}
\usepackage{blindtext} 
\usepackage[linktoc=all]{hyperref}
\begin{document}
\tableofcontents
\section{First}
\blindtext[5]
\section{Second}
\blindtext[10]
\end{document}

MWE

MWE is based on the MWE by Christian Hupfer.

You must log in to answer this question.

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