I want to have a table of contents as follows:
1. Introduction
Part 1: the partition function
2. section 2
3. section 3
Part 2: theta function
4. section 4
How can I do this?
I want to have a table of contents as follows:
1. Introduction
Part 1: the partition function
2. section 2
3. section 3
Part 2: theta function
4. section 4
How can I do this?
You can use the tocloft package to add the string "Part" to the entries in the ToC; I used
\@addtoreset{section}{part}
\renewcommand\thepart{\arabic{part}}
so the the section counter is reset in each new part and the part counter uses Arabic numbers.
\documentclass{article}
\usepackage{tocloft}
\makeatletter
\@addtoreset{section}{part}
\makeatother
\newlength\mylen
\renewcommand\thepart{\arabic{part}}
\renewcommand\cftpartpresnum{Part~}
\settowidth\mylen{\bfseries\cftpartpresnum\cftpartaftersnum}
\addtolength\cftpartnumwidth{\mylen}
\begin{document}
\tableofcontents
\section{Introduction}
\part{First test part}
\section{Test section}
\section{Test section}
\part{Second test part}
\section{Test section}
\section{Test section}
\end{document}

\renewcommand\cftpartpresnum{Part~} work in the book class?
– jhabbott
Dec 22 '15 at 08:10
\documentclass[]{book}
\newcommand{\atoc}[1]{\addtocontents{toc}{#1\par}}
\renewcommand{\thesection}{\arabic{section}.}
\begin{document}
\tableofcontents
\section{Introduction}
\atoc{Part 1: the partition function}
\section{section 2}
\section{section 3}
\atoc{Part 2: theta function}
\section{section 4}
\end{document}
an image is attached

addtocontents line to match the new format---a monotonous and error prone task. It would be better to place the line inside a newcommand that abstracts the idea of adding a TOC entry for the part.
– Sean Allred
Aug 22 '13 at 20:36
\part{...}I would expect that to add to the toc automatically. – David Carlisle Aug 22 '13 at 15:54partto appear before the part number. – vy32 Jun 19 '21 at 16:21