The OP's comment clarified that the only thing that should be changed should be the ToC listing, and nothing else. So my other answer is less than optimal because everywhere the counter for \thechapter
is used what shows up will be effected. In particular, when labels are written to the .aux
file it will include also the part information making it show up also in calls to \ref
.
In this case the easiest thing to do would be to get your hands dirty and actually create a new chapter command which adds the part info only to the .toc
file and otherwise behaves exactly like the ordinary \chapter
. To do so, you can first dive into the document class you are using (which is book.cls
), and see that \chapter
is defined by
\newcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi
\thispagestyle{plain}%
\global\@topnum\z@
\@afterindentfalse
\secdef\@chapter\@schapter}
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
\addcontentsline{toc}{chapter}%
{\protect\numberline{\thechapter}#1}%
\else
\addcontentsline{toc}{chapter}{#1}%
\fi
\else
\addcontentsline{toc}{chapter}{#1}%
\fi
\chaptermark{#1}%
\addtocontents{lof}{\protect\addvspace{10\p@}}%
\addtocontents{lot}{\protect\addvspace{10\p@}}%
\if@twocolumn
\@topnewpage[\@makechapterhead{#2}]%
\else
\@makechapterhead{#2}%
\@afterheading
\fi}
There are of course other commands involved in building the \chapter
command, but the one that concerns us, where the ToC entry is written, is in \@chapter
, where the \addcontentsline
command is called. Specifically it reads
\addcontentsline{toc}{chapter}%
{\protect\numberline{\thechapter}#1}%
So all we need to do is to create a new command that does exactly the samething as \chapter
except swap out the \numberline{\thechapter}
bit with \numberline{\thepart.\thechapter}
. If you always want to use this particular format in the ToC, we can just patch \@chapter
by redefining it. But we want to also have the possibility of \chapter{Chapter Five}
that doesn't show the part info. So we will define a new command called \pchapter
that does everything like \chapter
except this one minor addition.
The following code makes this change. (Note for convenience I removed the formatting commands for titlesec
and titletoc
; they should not be effected by the code, since titlesec
patches \@makechapterhead
to achieve the formatting, which we still call in the new \@pchapter
.)
\documentclass[a4paper, twoside, openright, 12pt]{book}
\usepackage[newparttoc]{titlesec}
\makeatletter
% The \pchapter command differs from \chapter only in changing to call
% to \@chapter to \@pchapter
\newcommand\pchapter{\if@openright\cleardoublepage\else\clearpage\fi
\thispagestyle{plain}%
\global\@topnum\z@
\@afterindentfalse
\secdef\@pchapter\@schapter}
% As discussed above, the \@pchapter command only changes in how it calls
% \addcontentsline
\def\@pchapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
\addcontentsline{toc}{chapter}%
{\protect\numberline{\thepart.\thechapter}#1}%
\else
\addcontentsline{toc}{chapter}{#1}%
\fi
\else
\addcontentsline{toc}{chapter}{#1}%
\fi
\chaptermark{#1}%
\addtocontents{lof}{\protect\addvspace{10\p@}}%
\addtocontents{lot}{\protect\addvspace{10\p@}}%
\if@twocolumn
\@topnewpage[\@makechapterhead{#2}]%
\else
\@makechapterhead{#2}%
\@afterheading
\fi}
\makeatother
\pagestyle{empty}
\title{ToC Test}
\begin{document}
\frontmatter
\maketitle
\mainmatter
\tableofcontents
\part{Part One}
% Calls to \pchapter records I.1 and I.2 in the ToC
\pchapter{Chapter One}
\pchapter{Chapter Two}
\part{Part Two}
\pchapter{Chapter Three}
\pchapter{Chapter Four}
% Call to \chapter records 5 in the ToC
\chapter{Chapter Five}
\end{document}
You will probably still need to use titletoc
or at least do something to make enough room for the labels in the ToC.