4

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

??

2 Answers 2

1

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

4
  • 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
    Commented Jul 29, 2014 at 18:29
  • ps. subtle with the Part titles ;)
    – charles
    Commented Jul 29, 2014 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.
    Commented Jul 29, 2014 at 18:31
  • Probably why you were the only one to answer having slogged through the MWE in my previous question!
    – charles
    Commented Jul 29, 2014 at 18:33
1

You also can do that with titlesec/titletoc.

Specifically, for the case of \part, it requires its formatting to be redefined with \titleformat and choosing the newparttoc option when loading titlesec.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .
https://tex.stackexchange.com/questions/193809/add-part-string-to-part-list-in-toc/193813
tex.stackexchange.com
CC-MAIN-2024-26
162002
application/http; msgtype=response
sha1:Y2FV5VGICPVZNRV4YUMGQXYJCJHOLPAL
<urn:uuid:26d19a15-625c-4bb9-ab22-3d3244a0e779>
2024-06-24T06:44:53Z
104.18.43.226
text/html
sha1:V3SMIW5U7U7CPKZ3GGJUPU6CPST22BCP
<urn:uuid:a740642d-dd83-4a4c-a8ea-913733451c20>
https://tex.stackexchange.com/questions/193809/add-part-string-to-part-list-in-toc/193813
response
<urn:uuid:46ce04af-294e-4603-9459-e7cf17c53fd6>
isPartOf: CC-MAIN-2024-26
publisher: Common Crawl
description: Wide crawl of the web for June 2024
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-109
software: Apache Nutch 1.20 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.5-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/