I wish to make a Table of Contents like this one:
This is what I have achieved so far (still lack the - I -\newline and \fbox{\thechapter}):
How can I make such a TOC?
Below is a MWE.
\documentclass{book}
\usepackage{titletoc}
\titlecontents{part}
[0em]
{\addvspace{1.5pc}\filcenter}
{\partname~\thecontentslabel}
{\uppercase}
{} % without page number
[\addvspace{.5pc}]
\titlecontents{chapter}
[2em] % i.e., 0em (part) + 2em
{\addvspace{.5pc}}
{\contentslabel{2em}}
{\hspace{-2em}}
{\hfill\contentspage}
\titlecontents{section}
[4em] % i.e., 2em (chapter) + 2em
{}
{\contentslabel{2em}}
{\hspace{-2em}}
{\titlerule*[1em]{.}\contentspage}
\titlecontents{subsection}
[7em] % i.e., 4em (section) + 3em
{}
{\contentslabel{3em}}
{\hspace{-3em}}
{\titlerule[1em]{.}\contentspage}
\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}}
\def\quad{\ \ }
\def\qquad{\ \ \ \ }
\usepackage[hidelinks,linktoc=all]{hyperref}
\begin{document}
\ttfamily
%% Hard coded
%%=====================================
% \begin{center}
% - I - \FIRST PART
% \end{center}
% \fbox{1}\quad First chapter \hfill 1\
% \null\qquad 1 \quad First section\ \ . . . . . . . . . . . . . . . . . .\hfill 1\
% \null\qquad 2 \quad Second section . . . . . . . . . . . . . . . . . .\hfill 3\[.5pc]
% \fbox{2}\quad Second chapter \hfill 4\
% \null\qquad 1 \quad First section\ \ . . . . . . . . . . . . . . . . . .\hfill 4\
% \null\qquad\qquad 1.1 \quad First subsection\ \ ,. . . . . . . . . . . . . .\hfill 4\
% \null\qquad 2 \quad Second section . . . . . . . . . . . . . . . . . .\hfill 5\
\tableofcontents
\part{First part}
\chapter{First chapter}
\section{First section}
\section{Second section}
\chapter{Second chapter}
\section{First section}
\subsection{First subsection}
\section{Second section}
\end{document}




\setpartToC) seems to have to no effect if the title format of\parthas been modified bytitlesec, even with the optionnewparttocadded. Do you have any suggestions? – Jinwen Feb 08 '21 at 00:27titlesecworks withtitletoc, but you can't mix those two withtocloft. They're competing packages, so its one or the other. It depends on how you also want to format the sectional units within the text. – Werner Feb 08 '21 at 01:52tocloftto format the sectional units? – Jinwen Feb 08 '21 at 01:56sectsty. So, how intricate are the required changes? Of course, that falls out of scope in terms of this question. – Werner Feb 08 '21 at 02:12