I have been looking for two hours for an explanation to the problem I am facing, and so far I found no hint.
In a document of the book
class, I am trying to include partial TOC at the beginning of my chapters after some text introducing the chapter. I was using the minitoc
package successfully for that purpose. However, I needed the [toctitles]
option of package titlesec
to fix problems due to wide titles in headers. As minitoc
complained that the use of titlesec
was not compatible, I tried to get titletoc
to generate my partial TOCs.
Here is a test document demonstrating my problem:
\documentclass[12pt,a4paper]{book}
\usepackage[hidelinks]{hyperref}
\usepackage{titletoc}
\usepackage[toctitles]{titlesec}
\newcommand{\PartialToc}{\vspace*{2pc}\hrule\vspace*{1pc}%
\startcontents[chapters]\vbox{\bf\Large Outline}
\printcontents[chapters]{}{1}{}\vspace*{1pc}\hrule}
\begin{document}
\chapter{First Chapter}
Text Text Text Text Text Text Text Text Text Text Text Text Text
\PartialToc
\section{First Section}
\section{Another Section}
\subsection{One Subsection}
\subsection{Two Subsection}
\chapter{Second Chapter}
Text Text Text Text Text Text Text Text Text Text Text Text Text
\PartialToc
\section{Last Section}
\subsection{Three Subsection}
\subsection{Four Subsection}
\end{document}
This results in the following partial TOC for chapter 1
Notice the lines "chapter.1" and "section.2.1 subsection.2.1.1 subsection.2.1.2" before and after the TOC. I think this text comes from the last argument of the \contentsline
instructions in the .ptc
file, but I have no idea why they show up …
Anyone knows how to get rid of them ?
Best Answer
Load
hyperref
in the last place: