4

I have some long titles for Parts in a {book} file.

In TOC I receive the following:

I Paaaaaaaaaaaaaaa

aaaaaaaaaaaaaaaaaaart    pagenum

And I would like to have it like the following:

I Paaaaaaaaaaaaaaa

     aaaaaaaaaaaaaaaaaaart    pagenum

(so, I want to have some space in the second line before the text)

Do you have any ideas how to do it? I tried to add \hspace{} in title, but it does not help.

LaTeX makes it in such format for chapters and sections, but not for Parts.

Another small question: I use tocloft package for design. I wanted to add the word Part before the numbers of parts in TOC (f.e. using \cftpartpresnum), but I want to add it only for numbered parts. For example I want to have:

Intro ..... 1
Part I Lalala ...2
Part II Lalalala...4
Conclusion ....6

Is it possible? \cftpartpresnum adds to all parts.

3
  • Welcome to TeX.sx! Please only ask one question per post (unless they're really closely related, which is not the case here). I recommend moving your second question from this one to a new question (after making sure it hasn't been asked yet).
    – doncherry
    Oct 13, 2011 at 13:05
  • Sure, I will copy it to another question. For me it was like one subject, as I want to implement either the first, or the second solution for my file.
    – Natalia
    Oct 13, 2011 at 13:30
  • @Natalia: so, finally how should the entries look like? Do you want lines 2,3,... indented by some given amount and the word "Part" or you just want the indentation? Oct 13, 2011 at 16:01

1 Answer 1

3

You can achieve what you want, without using tocloft, by redefining the \@part and \l@part commands (the latter actually typesets the part entries in the ToC); here's an example of such redefinition (I wasn't sure of the desired alignment and indentation, but you can easily change these settings):

\documentclass{book}

\makeatletter
\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >-2\relax
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\protect\numberline{\thepart}#1}%NEW
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    \markboth{}{}%
    {\centering
     \interlinepenalty \@M
     \normalfont
     \ifnum \c@secnumdepth >-2\relax
       \huge\bfseries \partname\nobreakspace\thepart
       \par
       \vskip 20\p@
     \fi
     \Huge \bfseries #2\par}%
    \@endpart}
\renewcommand*\l@part[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{3.3em}%NEW: indentation for lines 2,3,... change according to your needs
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode\large\bfseries
      \advance\leftskip\@tempdima% NEW: comment out if no indentation required for lines 2,3,...
      \hskip -\leftskip
      #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
      \penalty\@highpenalty
    \endgroup
  \fi}\makeatother

\begin{document}

\tableofcontents

\part{Test part one with a really really long title spanning two lines}
\part{Test part two with a really really long title spanning two lines}
\part{Test part three with a really really long title spanning two lines}
\part{Test part four with a really really long title spanning two lines}

\end{document}

enter image description here

3
  • That works, Thank you! What have you added to the code that is responsible for such a margin at the left side?
    – Natalia
    Oct 13, 2011 at 13:42
  • I am asking, because it does not provide the same space for different parts (I, II, III). To see my point, please insert into your code instead of one \part three \part-s with the same text.
    – Natalia
    Oct 13, 2011 at 13:45
  • @Natalia: see my updated answer. Oct 13, 2011 at 16:16

You must log in to answer this question.

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