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.

Following on my previous question here, I would now like to add the string "Part" to the TOC.

Using a modified thesis style and \documentclass{report} which dictates how the TOC appears. I have tried other solutions presented in other questions, but these do not seem to work.

I am currently using:

\usepackage{fmtcount} \renewcommand{\thepart}{\Numberstring{part}}

to change the \part numbering to a numberstring "One" "Two" etc. I would like the string "Part" to appear in the TOC. Instead of:

One Some title here

Is there a way to get the TOC listing to be:

Part One Some title here

??

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Assuming, the "modified thesis style" is the same as in your previous question and therefore does not change the definition of "part" and that your document uses the original \@part definition from report.sty:

\def\@part[#1]#2{\ifnum \c@secnumdepth >-2\relax
        \refstepcounter{part}%

        \addcontentsline{toc}{part}{\thepart
        \hspace{1em}#1}\else

        \addcontentsline{toc}{part}{#1}\fi
   \markboth{}{}%
   {\centering
    \interlinepenalty \@M
    \ifnum \c@secnumdepth >-2\relax
      \huge\bf \partname~\thepart
    \par
    \vskip 20\p@\fi
    \Huge \bf
    #2\par}\@endpart}

then including

\makeatletter
\def\@part[#1]#2{\ifnum \c@secnumdepth >-2\relax
        \refstepcounter{part}%

        \addcontentsline{toc}{part}{Part \thepart
        \hspace{1em}#1}\else

        \addcontentsline{toc}{part}{#1}\fi
   \markboth{}{}%
   {\centering
    \interlinepenalty \@M
    \ifnum \c@secnumdepth >-2\relax
      \huge\bf \partname~\thepart
    \par
    \vskip 20\p@\fi
    \Huge \bf
    #2\par}\@endpart}
\makeatother

in your document will work.

I set up an example of how this works at writeLaTeX. (lines 284-299)

Output

share|improve this answer
1  
Voila! It does work- it didn't the first time I tried it (after two PDFlatex runs), but after looking at your example code at writeLaTeX, adding the code right before \makeatother (then two more PDFlatex runs), it then seemed to work fine. –  charles Jul 29 at 18:29
    
ps. subtle with the Part titles ;) –  charles Jul 29 at 18:30
    
Glad it worked. And always remember - including an MWE makes it much easier for the folks at TeX.SX to work on your question. ;) –  Sora. Jul 29 at 18:31
    
Probably why you were the only one to answer having slogged through the MWE in my previous question! –  charles Jul 29 at 18:33

You also can do that with titlesec/titletoc. Specifically, for the case of \part, it requires ìts formatting be redefined with \titleformat and choosing the newparttoc option. Here is an example:

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}

\usepackage[english]{babel}
\usepackage[newparttoc,explicit, clearempty]{titlesec}%
\usepackage{titletoc}
\usepackage{chngcntr}
\usepackage{fmtcount}
\counterwithin*{chapter}{part}

\usepackage{etoolbox}

\def\partname{Part}

\renewcommand\thepart{\NUMBERstring{part}}% \titleformat{\part}[display]{\bfseries\filcenter}{\huge\partname~\thepart}{20pt}{\Huge #1}[\thispagestyle{empty}]%

\titlecontents{part}[0em]{\large\bfseries\protect\addvspace{25pt}\titlerule\addvspace{1.5ex}}%
{\contentslabel[\rlap{\partname~\thecontentslabel}]{0em}\hphantom{\partname~\thecontentslabel\quad}}{}%
{,\quad\contentspage}[\addvspace{1ex}\titlerule\addvspace{1ex}]%

\begin{document}

\tableofcontents

\part{A First Part}
\chapter{Chapter the First}
\section{Section 1.1}
\section{Section 1.2}

\chapter{Chapter the Second}
\section{Section 2.1}
\section{Section 2.2}

\part{Another Part} \label{part-2}

\chapter{Chapter the First}
\section{Section 1.1}
\section{Section 1.2}

\chapter{Chapter the Second}
\section{Section 2.1}
\section{Section 2.2}

\end{document} 

enter image description here

share|improve this answer

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.