I am currently writing my PhD thesis, and I have trouble defining a common style for my global TOC and the partial TOCs generated by titletoc.
Basically if you check the following MWE, I like the general style of the global TOC, in particular the fact that hyperref links include the labels. However, I find that the dotted lines in the global TOC are not dense enough, and prefer those of the partial TOCs.
\documentclass[12pt,a4paper]{book}
\usepackage{caption}
\usepackage{titletoc}
\usepackage[colorlinks]{hyperref}
\usepackage{lipsum}
\renewcommand{\cleardoublepage}{\clearpage}
\newcommand{\PartialToc}{\vspace*{0.5pc}\vbox{\bf\large\noindent Chapter contents}\vspace*{0.3pc}\startcontents[chapters]\vspace*{0.3pc}\printcontents[chapters]{p}{1}{}\vspace*{0.3pc}}
\begin{document}
% Custom style for partial TOCs
\titlecontents{psection}[3.6em]{\small\bfseries}{\contentslabel{1.8em}}{}{\mdseries\titlerule*[0.25pc]{.}\contentspage\hspace*{1.8em}}{}
\titlecontents{psubsection}[6.0em]{\small}{\contentslabel{2.4em}}{}{\titlerule*[0.25pc]{.}\contentspage\hspace*{1.8em}}{}
\tableofcontents
\listoffigures
\listoftables
\chapter{Chapter 1}
\vfill
\lipsum[1-2]
\vfill\PartialToc\clearpage
\section{Section 1}
\lipsum[1]
\begin{figure}[t]
\caption{Figure 1}
\end{figure}
\section{Section 2}
\lipsum[1]
\subsection{Subsection 2.1}
\lipsum[1]
\subsection{Subsection 2.1}
\lipsum[1]
\section{Section 3}
\lipsum[1]
\begin{table}[t]
\caption{Table 1}
\end{table}
\end{document}
Therefore, I tried to increase the density of the dotted lines in the global TOC, by adding the following titletoc style declarations after \begin{document}
:
\titlecontents{section}[3.8em]{}{\contentslabel{2.3em}}{\hspace*{-2.3em}}{\titlerule*[0.25pc]{.}\contentspage}{}
\titlecontents{subsection}[6.2em]{}{\contentslabel{2.9em}}{}{\titlerule*[0.25pc]{.}\contentspage}{}
However, in this case, the hyperref links are changed, which I would like to avoid (no I am not a maniac…). Is there a way to achieve this ? And can this also be used to make the hyperref links in the partial TOCs include the labels ?
And as a subsidiary question, how do I assign the same style to entries in the List of Figures and List of Tables ?
Thank you for your help
Best Answer
The
titlesec
/titletoc
packages are somewhat incompatible withhyperref
, and you happened to run into such a situation.To get the links on the labels in the ToCs back, we have to teach that to
titletoc
with:That is, the format of the
contentslabel
is changed from being simply\thecontentslabel
to a proper hyperlink.To obtain the narrow dots line in the LoT and LoF I would use package
tocloft
. This package can also handle the ToC, so you may find thattitletoc
is superfluous. Just use