# Fancy part name in TOC

I was just trying to add some fancy part name in TOC using a code I got from a post in this site. Here is what I added.

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{kpfonts}
\usepackage{tikz}
\usepackage{titletoc}
%------------------------------------------
\contentsmargin{0cm}
%------------------------------------------
\titlecontents{part}[0pc]
\begin{tikzpicture}%
\draw[help lines,step=.4cm,color=blue] (0,0) grid (2.4,1.2);%
\pgftext[left,x=.1cm,y=.6cm]{\Large\sc \partname};%
\fill[fill=white,draw=blue] (1.8,.6) circle (0.4cm);%
\pgftext[x=1.8cm,y=.6cm]{\protect\thepart};%
\end{tikzpicture}\\\color{blue}\large\sc\bfseries}%
{}
{}
{\;\titlerule\;\large\bfseries \thecontentspage}%
%------------------------------------------
\titlecontents{chapter}[0pc]
\begin{tikzpicture}%
\draw[help lines,step=.4cm,color=red] (0,0) grid (3.2,1.2);%
\pgftext[left,x=.1cm,y=.6cm]{\Large\sc chapter};%
\fill[fill=white,draw=red] (2.7,.6) circle (0.35cm);%
\pgftext[x=2.7cm,y=.6cm]{\thecontentslabel};%
\end{tikzpicture}\\\color{red}\large\sc\bfseries}%
{}
{}
{\;\titlerule\;\large\bfseries \thecontentspage}%
%------------------------------------------
\titlecontents{section}[2.4pc]
{\contentslabel[\thecontentslabel]{2.4pc}}
{}
{\hfill\small \thecontentspage}
%------------------------------------------
[]
\titlecontents*{subsection}[4pc]
{}
{}
{\ --- \small\thecontentspage}
[ \textbullet\ ][]
%-------------------------
\begin{document}
\tableofcontents
\part{Part One}
\chapter{(title chapter 1)}
\section{(title section 1)}
\subsection{(title sub-section 1)}
\subsection{(title sub-section 2)}
\section{(title section 2)}
\subsection{(title sub-section 1)}
\subsection{(title sub-section 2)}
%--------------------------
\end{document}


Here is what I get:

My problem: The part number I is not coming inside the circle after PART instead it is coming below with the part name.

How to get the part number inside the circle like in chapter? What else I have to add?

-

The redefinitions for part using titletoc will work as soon as you use the newparttoc option for the titlesec package and provide a suitable redefinition for \part using titlesec; in the following example (just for the example's sake) I gave a quick redefinition of \part using titlesec just to illustrate the effect on the part entries in the ToC:

\documentclass{book}
\usepackage{tikz}
\usepackage[newparttoc]{titlesec}
\usepackage{titletoc}

%------------------------------------------
\contentsmargin{0cm}
%------------------------------------------

\titleformat{\part}[display]
{\normalfont\huge\bfseries}{\thepart}{20pt}{\Huge}

\titlecontents{part}[0pc]
{
\begin{tikzpicture}%
\draw[help lines,step=.4cm,color=blue] (0,0) grid (2.4,1.2);%
\pgftext[left,x=.1cm,y=.6cm]{\Large\scshape\partname};%
\fill[fill=white,draw=blue] (1.8,.6) circle (0.4cm);%
\node at(1.8cm,.6cm) {I};%
\end{tikzpicture}\\\color{blue}\large\scshape\bfseries
\thepart}%
{}
{l}
{$\;$\titlerule$\;$\large\bfseries\thecontentspage}%

\begin{document}
\tableofcontents
\part{Part One}

\end{document}


-
Thanks and great. Will the same strategy work for your answer in tex.stackexchange.com/questions/35825/pretty-table-of-contents also? –  Harish Kumar Mar 13 '12 at 13:04
@HarishKumar: You're welcome. I don't know if the strategy will work there, but I will do some tests. Thanks for the comment. –  Gonzalo Medina Mar 13 '12 at 15:02