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:
\hypersetup{linktocpage}
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:
\documentclass[a4paper,11pt]{book}
\usepackage[latin1]{inputenc}
\usepackage[sc]{mathpazo}
\usepackage[T1]{fontenc}
\usepackage{palatino}
\usepackage[english,spanish,activeacute]{babel}
\usepackage{enumerate}
\usepackage{minitoc}
\usepackage[dvipsnames,table]{xcolor}
\usepackage[pdftex, breaklinks=true, colorlinks=true,linkcolor={blue}, citecolor={black}]{hyperref}
\hypersetup{linktocpage}
\begin{document}
\dominitoc
\setcounter{secnumdepth}{6} \setcounter{tocdepth}{6}
\renewcommand{\contentsname}{Table of contents}
\tableofcontents
\pagenumbering{arabic}
\chapter{Chapter 1}
Text
\section{Section 1}
Text
\subsection{Subsection 1}
Text
\subsubsection{Subsubsection 1}
Text
\end{document}
Thank you so much!
Best Answer
The default setup with
hyperref
is to make only the sectional titles hyperlinked. However, you can use thelinktoc
key-value option to switch betweennone
: Neither title nor page number is hyperlinked;section
: Only section titles are hyperlinked;page
: Only page entries are hyperlinked; andall
: 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
: