I'm using book class and I'm trying to achieve a toc which titles and page numbers are all clickable and hyperlinked to their corresponding sections, but with the characteristic that the page numbers have different color from their sections.

I think I need to set something inside \hypersetup, but I can't figure out how to do it.

I have tried using:


But it only makes clickable the page numbers; I'd like to make both page numbers and titles clickable. Here is my complete code and a picture of what I'm trying to get:

\usepackage[pdftex, breaklinks=true, colorlinks=true,linkcolor={blue}, citecolor={black}]{hyperref}

\setcounter{secnumdepth}{6} \setcounter{tocdepth}{6}
\renewcommand{\contentsname}{Table of contents}

\chapter{Chapter 1}
\section{Section 1}
\subsection{Subsection 1}
\subsubsection{Subsubsection 1}


enter image description here

Thank you so much!

  • Welcome to TeX.SX!. Please provide a compilable document, not just fragments. Using color and xcolor is useless, just use xcolor
    – user31729
    Mar 15 '16 at 19:33
  • Sure! I have just updated my question. Thanks
    – Isaías
    Mar 15 '16 at 19:48

The default setup with hyperref is to make only the sectional titles hyperlinked. However, you can use the linktoc key-value option to switch between

  • none: Neither title nor page number is hyperlinked;
  • section: Only section titles are hyperlinked;
  • page: Only page entries are hyperlinked; and
  • all: Both section titles and pages are hyperlinked.

The following minimal example changes the link colour of the page temporarily using the hooks provided by tocloft:

enter image description here


\let\cftsubsecpagefont\cftsecpagefont % \renewcommand{\cftsubsecpagefont}{\HyColor@HyperrefColor{red}\@linkcolor}






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.