Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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 ?

share|improve this question
    
Welcome to TeX.sx! A tip: You can use backticks ` to mark your inline code –  Corentin Oct 29 '12 at 11:46

1 Answer 1

up vote 7 down vote accepted

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

share|improve this answer
    
That simple ... Many thanks :D –  AldurDisciple Oct 29 '12 at 12:14
    
Thank you, I have resolved the same problem loading hyperref package after the titletoc/titlesec ones. –  ThierryB Apr 2 '13 at 5:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.