12

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 enter image description here

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 ?

1

1 Answer 1

19

Load hyperref in the last place:

\documentclass[12pt,a4paper]{book}
\usepackage{titletoc}
\usepackage[toctitles]{titlesec}
\usepackage[hidelinks]{hyperref}

\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}

enter image description here

1
  • Thank you, I have resolved the same problem loading hyperref package after the titletoc/titlesec ones. Apr 2, 2013 at 5:01

You must log in to answer this question.

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