# Customize part in TOC by titletoc

I want to represent the \part in the TOC as on the figure below:

The problem is the \part could be represented so simple as other headers. As you see in the MWE below, the \part design has been created by same way as \section, but the color box in not displayed in the first case:

\documentclass[a4paper,twoside]{article}

\usepackage{color}
\usepackage[svgnames,x11names,table]{xcolor}

\usepackage{tikz}
\usepackage{titletoc}

\setcounter{tocdepth}{3}
\contentsmargin{2.55em}

\titlecontents{part}[0pc]
{}
{\begin{tikzpicture}[baseline={([yshift=-.8ex]current bounding box.center)},]
\node [thick, draw=LavenderBlush4, fill=LavenderBlush1, rectangle, rounded corners] {\thecontentslabel};\end{tikzpicture}\quad}
{}
{}

\titlecontents{section}[0pc]
{}
{\begin{tikzpicture}[baseline={([yshift=-.8ex]current bounding box.center)},]
\node [thick, draw=LavenderBlush4, fill=LavenderBlush1, rectangle, rounded corners] {\thecontentslabel};\end{tikzpicture}\quad}
{}
{$\:$\titlerule[0.5pt]$\:$\small\thecontentspage}

\dottedcontents{subsection}[3.6em]{}{2.5em}{1pc}

\titlecontents*{subsubsection}[1.8pc]
{\small}{\thecontentslabel}

\begin{document}

\tableofcontents

\part{A}
\section{AA}
\subsection{AAA}
\subsubsection{AAAA}
\subsubsection{AAAB}
\subsection{AAB}
\subsection{AAC}

\end{document}


Unfortunately, citing the titlesec manual

Standard parts write the toc entry number in a non standard way. You may change that with newparttoc so that titletoc or a similar package can manipulate the entry. (That works only if \part has been redeﬁned.)

This means that you have to load the titlesec package with the option newparttoc

\usepackage[newparttoc]{titlesec}


and redefine \part in a way to reproduce the standard article class behavior:

\titleformat{\part}[display]
{\Large\bfseries}
{\partname\nobreakspace\thepart}
{0mm}
{\huge\bfseries}


After doing that, your tikzpicture magically appears...

MWE:

\documentclass[a4paper,twoside]{article}

\usepackage{color}
\usepackage[svgnames,x11names,table]{xcolor}

\usepackage{tikz}

\usepackage[newparttoc]{titlesec}

\titleformat{\part}[display]
{\Large\bfseries}
{\partname\nobreakspace\thepart}
{0mm}
{\huge\bfseries}

\usepackage{titletoc}

\setcounter{tocdepth}{3}
\contentsmargin{2.55em}

\titlecontents{part}[0pc]
{}
{\begin{tikzpicture}[baseline={([yshift=-.8ex]current bounding box.center)},]
\node [thick, draw=LavenderBlush4, fill=LavenderBlush1, rectangle, rounded corners] {\thecontentslabel};\end{tikzpicture}\quad}
{}
{}

\titlecontents{section}[0pc]
{}
{\begin{tikzpicture}[baseline={([yshift=-.8ex]current bounding box.center)},]
\node [thick, draw=LavenderBlush4, fill=LavenderBlush1, rectangle, rounded corners] {\thecontentslabel};\end{tikzpicture}\quad}
{}
{$\:$\titlerule[0.5pt]$\:$\small\thecontentspage}

\dottedcontents{subsection}[3.6em]{}{2.5em}{1pc}

\titlecontents*{subsubsection}[1.8pc]
{\small}{\thecontentslabel}

\begin{document}

\tableofcontents

\part{A}
\section{AA}
\subsection{AAA}
\subsubsection{AAAA}
\subsubsection{AAAB}
\subsection{AAB}
\subsection{AAC}