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 to make a table of contents for each part of a book document. I use minitoc package, and \parttoc command.

I have line breaks (\\) in the chapters and sections titles in both [] and {} options, otherwise they look ugly.

In minitoc package, it is said that linebreaks in titles may cause the problem. The problem for my file is that LaTeX spreads the text in the title lines before \\ until the end of the line. (No problems in \tableofcontents though, but I need a table of contents for each part separately).

How can I fix it?

In the package description, they suggest to use \protect\linebreak, but where should I place it? I tried several variants, none has worked.

Here is the example:

\documentclass{book}

\usepackage{minitoc}

\begin{document}

\doparttoc

\tableofcontents

\part{First Part}

\parttoc

\chapter[Chapter1 Chapter1 Chapter1 Chapter1\\Chapter1 Chapter1]{Chapter1 Chapter1 Chapter1 Chapter1\\Chapter1 Chapter1}

\section{Section1}

\chapter[Chapter2 Chapter2 Chapter2 Chapter2\\Chapter2 Chapter2]{Chapter2 Chapter2 Chapter2 Chapter2\\Chapter2 Chapter2}

\section{Section2}

\chapter[Chapter3 Chapter3 Chapter3 Chapter3\\Chapter3 Chapter3]{Chapter3 Chapter3 Chapter3 Chapter3\\Chapter3 Chapter3}

\section{Section3}

\subsection{Subsections3}

\part{Second Part}

\end{document}

Please see page 1 and 5 of the generated document for ToC and MiniToC. I need the same alignment for MiniToC as for ToC (in the names of chapters).

share|improve this question
3  
Even though you didn't format your "minimal working example" as a code sample, the example itself was outstanding. I wish every "first question asked at tex.sx" would include an example like this one! –  lockstep Oct 11 '11 at 19:39

1 Answer 1

up vote 10 down vote accepted

Replace \\ with \protect\newline (and a space) in the optional arguments of your \chapter commands.

\documentclass{book}

\usepackage{minitoc}

\begin{document}

\doparttoc

\tableofcontents

\part{First Part}

\parttoc

\chapter[Chapter1 Chapter1 Chapter1 Chapter1\protect\newline Chapter1 Chapter1]{Chapter1 Chapter1 Chapter1 Chapter1\\Chapter1 Chapter1}

\section{Section1}

\chapter[Chapter2 Chapter2 Chapter2 Chapter2\protect\newline Chapter2 Chapter2]{Chapter2 Chapter2 Chapter2 Chapter2\\Chapter2 Chapter2}

\section{Section2}

\chapter[Chapter3 Chapter3 Chapter3 Chapter3\protect\newline Chapter3 Chapter3]{Chapter3 Chapter3 Chapter3 Chapter3\\Chapter3 Chapter3}

\section{Section3}

\subsection{Subsections3}

\part{Second Part}

\end{document}
share|improve this answer
    
That works! Thank you very much for your help!!!! –  Natalia Oct 12 '11 at 10:26

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.