Sign up ×
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 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.

share|improve this question
    
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 '11 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 '11 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? –  Gonzalo Medina Oct 13 '11 at 16:01

1 Answer 1

up vote 3 down vote accepted

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

share|improve this answer
    
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 '11 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 '11 at 13:45
    
@Natalia: see my updated answer. –  Gonzalo Medina Oct 13 '11 at 16:16
    
That is perfect! Thank you very much! –  Natalia Oct 13 '11 at 18: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.
http://tex.stackexchange.com/questions/31458/table-of-contents-nice-titles-for-parts
tex.stackexchange.com
crawl=CC-MAIN-2015-40
79216
application/http; msgtype=response
sha1:MKK4YOUGM6NP5OLTQQ4KFTKXLAPXAOYS
<urn:uuid:9f196c30-8d33-45c5-ad3b-db59ce3e94a4>
2015-10-05T08:59:20Z
104.16.12.128
sha1:A4DMUGLZYEB5ZXB4X3M4W5JUMO5QJUDR
<urn:uuid:e68cd56a-8ad5-4555-9a34-a75b87a6aa69>
http://tex.stackexchange.com/questions/31458/table-of-contents-nice-titles-for-parts
length
response
<urn:uuid:d05796c0-d565-473d-a0b2-0224d0859a68>
robots: classic
hostname: ip-10-137-6-227.ec2.internal
software: Nutch 1.6 (CC)/CC WarcExport 1.0
isPartOf: CC-MAIN-2015-40
operator: CommonCrawl Admin
description: Wide crawl of the web for September 2015
publisher: CommonCrawl
format: WARC File Format 1.0
conformsTo: http://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1_latestdraft.pdf