# TOC part formatting - How to change from: I. NAME PART 1 to: PART I. NAME PART 1

I'm using \usepackage{titlesec} packages and have included the simplest example possible to illustrate the problem and that the first proposed solution does work only when the titlesec formatting command is removed for the \part.

And the code:

\documentclass{report}
\usepackage[rm, tiny,center, compact]{titlesec}

%%%%%%%% Code to change sectioning size in main body of the document
\titleformat{\part}{\centering\normalsize}{PART \thepart.}{1em}{}{} % conflcts with patchcmd
\titleformat{\chapter}{\centering\normalsize}{\thechapter.}{1em}{}
\titleformat{\section}{\centering\normalsize}{\thesection}{1em}{}
\titleformat{\subsection}{\centering\normalsize\it}{\thesubsection}{1em}{}
\titleformat{\subsubsection}{\centering\normalsize\it}{\thesubsubsection}{1em}{}
%%%%%%%%
\usepackage{etoolbox}
\begin{document}
\tableofcontents
\part{Name of part 1}
%%%%%%% Code to add 'PART' I First Part Title in the ToC both code parts don't work together.
\makeatletter
\patchcmd\@part
{\thepart\hspace{1em}}
{\MakeUppercase{\partname}\ \thepart\hspace{1em}}
{}{}
\makeatother
%%%%%%%
\part{Name of part 2}
\end{document}


@Phelype, Running this results in errors.....

\documentclass{report}
\usepackage[rm, tiny,center, compact]{titlesec}

%%%%%%%% Code to change sectioning size in main body of the document
\titleformat{\part}{\centering\normalsize}{PART \thepart.}{1em}{}{} % conflcts with patchcmd
\titleformat{\chapter}{\centering\normalsize}{\thechapter.}{1em}{}
\titleformat{\section}{\centering\normalsize}{\thesection}{1em}{}
\titleformat{\subsection}{\centering\normalsize\it}{\thesubsection}{1em}{}
\titleformat{\subsubsection}{\centering\normalsize\it}{\thesubsubsection}{1em}{}
%%%%%%%%

\usepackage{titletoc}
\titlecontents{part}
[0pt]{}{}
{PART\ \thecontentslabel}
[\endgraf\vskip\baselineskip]

\usepackage{etoolbox}
\begin{document}
\tableofcontents
\part{Name of part 1}
%%%%%%%% Code to add 'PART' I First Part Title in the ToC both code parts don't work together.
%\makeatletter
%\patchcmd\@part
%  {\thepart\hspace{1em}}
%  {\MakeUppercase{\partname}\ \thepart\hspace{1em}}
%  {}{}
%\makeatother
%%%%%%%%
\part{Name of part 2}
\end{document}


The ToC line of \part is written by the \@part macro. You can redefine it or, more simply, patch it:

\usepackage{etoolbox}
\makeatletter
\patchcmd\@part
{\thepart\hspace{1em}}
{\MakeUppercase{\partname}\ \thepart\hspace{1em}}
{}{}
\makeatother


Attention: you have to patch it before loading hyperref. hyperref redefines \@part and stores the old \@part macro in \H@old@part.

Edit: after a long time dwelling the the huge amount of packages overwriting each other's definitions, I decided that the solution that works is adding one more to the fighting pit:

\usepackage{titletoc}
\titlecontents{part}
[0pt]{}{}
{PART\ \thecontentslabel}
[\endgraf\vskip\baselineskip]


Sorry, I couldn't find a better way.

• @user3780514 Well, I just did it here and it worked (sorry for the music tag at the top :P). Please add an edit to your question showing how you patched for me to check. – Phelype Oleinik May 16 '18 at 23:48
• @user3780514 I assumed to be the ToC, because on the title to the question you said "TOC part formatting", and because you posted a screenshot of the ToC, and because on the body of the document there's already the saying "Part I. NAME PART 1". Is the picture I posted in my comment above what you want? If it is not, please clarify your question. Otherwise, try replacing \MakeUppercase{\partname} by PART to see if it helps. But with the edited code I get the result from this picture (minus the Gleichschritt thing). – Phelype Oleinik May 17 '18 at 13:00
• @user3780514 The code I used is exactly the one from your question plus this tamuconfig. Stupid question: did you remember to compile twice? – Phelype Oleinik May 17 '18 at 14:59
• – Phelype Oleinik May 17 '18 at 15:26
• Thanks for looking at this. I know it has been a huge pain. I think the latest revision shows that there are not a lot of packages over writing each other causing the problem. The issue is that your proposing a solution that does not work the the titlesec package. You do solve the problem, and create another one. – user3780514 May 17 '18 at 21:50

The solution was to add the following to the preamble after the titlesec package is loaded.

\titlecontents{part}%
[0pt]{}%remove rule if you like
{}{\MakeUppercase{\partname}~}
{\cftpartleader\contentspage}%replaced with {} if don't want page number for parts