# How to make a part toc that looks like the following with package titletoc?

\documentclass[openany]{book}
\raggedbottom       %reduce underfull \vbox

\usepackage{titlesec, titletoc}
%change the part format in book
\titleformat{\part}[frame]{\normalfont\huge\bfseries}{\partname\ \thepart }{20pt}{\Huge\centering}
\titlecontents{part}%
{}{\partname~}
{\hfill\contentspage}%replaced with {} if don't want page number for parts

\titlecontents{chapter}%
{\chaptertitlename\ \thecontentslabel~}{}
{\hfill\contentspage}%

%change the appendix name from chapter to appendix
\makeatletter
\renewcommand\chaptername{Appendix}%
}
\makeatother
%force paragraph newline
\titleformat{\paragraph}[hang]{\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}

%insert figures
\usepackage{graphicx}

%improve the interface for defining floating objects such as figures and tables
\usepackage{float}

%customize page layout
\usepackage[a4paper, left=3cm, right=3cm]{geometry}

%color
\usepackage[dvipsnames]{xcolor}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}

%booktitle
\author{\textbf{Stanley B.Lippman} \and \textbf{Jos\'ee Lajoie} \and \textbf{Barbara E.Moo}}
\date{}

%revise\@endpart macro
\makeatletter
\def\@endpart{\bigbreak}
\makeatother

% add mini-ta­bles-of-con­tents (mini­tocs) at the be­gin­ning of ev­ery chap­ter, part or sec­tion.
\usepackage{minitoc}
\setcounter{minitocdepth}{1}
\renewcommand\tightmtcfalse

\begin{document}
%initialize minitoc
\dominitoc

\frontmatter
\maketitle
\tableofcontents

\mainmatter
\chapter{Getting Started}
\minitoc
%\startcontents[mainsections]
%\printcontents[mainsections]{l}{1}{\section*{Main Sections}\setcounter{todepth}{1}}

This chapter introduces most of the basic elements of C++: types, variables,
expressions, statements, and functions. Along the way, we’ll briefly explain how to
compile and execute a program.

After having read this chapter and worked through the exercises, you should be able
to write, compile, and execute simple programs. Later chapters will assume that you
can use the features introduced in this chapter, and will explain these features in more
detail.
\newpage
\section{Writing a Simple C++ Program}

\section{A First Look at Input/Output}\label{a first look at input/output}

%\stopcontents[mainsections]

\backmatter
\chapter{Index}

\end{document}

\section{A First Look at Input/Output}\label{a first look at input/output}

%\stopcontents[mainsections]

\backmatter
\chapter{Index}

\end{document}


Since the 'titletoc' and 'minitoc' are incompatible, I want to remove the package 'minitoc' and make the part toc with 'titletoc'.

• Provoking suggestion: Drop titlesec etc. rather ;-) – user31729 Sep 23 '17 at 6:06
• I need 'titletoc' to format my table of content, as you can see. – K.Robert Sep 23 '17 at 6:10

Maybe you want something like this.

\documentclass[openany]{book}
\raggedbottom       %reduce underfull \vbox

\usepackage{titlesec, titletoc}
\usepackage{indentfirst}% indents first paragraph after a section/chapter heading
%change the part format in book
\titleformat{\part}[frame]{\normalfont\huge\bfseries}{\partname\ \thepart }{20pt}{\Huge\centering}
\titlecontents{part}%
{}{\partname~}
{\hfill\contentspage}%replaced with {} if don't want page number for parts

\titlecontents{chapter}%
{\chaptertitlename\ \thecontentslabel~}{}
{\hfill\contentspage}%

%change the appendix name from chapter to appendix
\makeatletter
\renewcommand\chaptername{Appendix}%
}
\makeatother
%force paragraph newline
\titleformat{\paragraph}[hang]{\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}

\titleformat{\chapter}[display]{\normalfont\bfseries\huge}{\chaptertitlename\ \thechapter}{20pt}{\Huge}[%
\vspace*{4pc}
\startcontents
{\normalsize\bfseries\contentsname\endgraf\vspace{5pt}}
\contentsmargin{1em}
\titlerule\vspace{5pt}
\printcontents{l}{1}{}
\vspace{5pt}\titlerule
]
\titlecontents*{lsection}[10pt]{\small}{}{}{\titlerule*[1pc]{.} \contentspage}[\endgraf]

%insert figures
\usepackage{graphicx}

%improve the interface for defining floating objects such as figures and tables
\usepackage{float}

%customize page layout
\usepackage[a4paper, left=3cm, right=3cm]{geometry}

%color
\usepackage[dvipsnames]{xcolor}

\usepackage{blindtext}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}

%booktitle
\author{\textbf{Stanley B.Lippman} \and \textbf{Jos\'ee Lajoie} \and \textbf{Barbara E.Moo}}
\date{}

%revise\@endpart macro
\makeatletter
\def\@endpart{\bigbreak}
\makeatother

\begin{document}

\startcontents[chapters]
\tableofcontents

\chapter{Getting Started}

This chapter introduces most of the basic elements of C++: types, variables,
expressions, statements, and functions. Along the way, we’ll briefly explain how to
compile and execute a program.

After having read this chapter and worked through the exercises, you should be able
to write, compile, and execute simple programs. Later chapters will assume that you
can use the features introduced in this chapter, and will explain these features in more
detail.
\blindtext
\newpage
\section{Writing a Simple C++ Program}

\section{A First Look at Input/Output}\label{a first look at input/output}