[Tex/LaTex] How to adjust the table of contents

table of contents

I'm trying to write a report in LaTeX. First, I tried to align the table of contents to the left. Then I changed my mind but I couldn't restore. I would like to make some distance between the Sections and Subsections such as 4cm (not aling to left). I would like to change table of contents as below figure.

enter image description here

Could you please help me?

\documentclass[12pt]{report}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=25mm,bmargin=25mm,lmargin=30mm,rmargin=25mm}
\pagestyle{plain}
\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\usepackage[active]{srcltx}
\usepackage{xcolor}
\usepackage{tocbibind}

\usepackage{lipsum}
\usepackage{float}
\usepackage{siunitx}
\usepackage{fixltx2e}
\usepackage{mathdots}
\usepackage{stmaryrd}
\usepackage{stackrel}
\usepackage{setspace}
\PassOptionsToPackage{version=3}{mhchem}
\usepackage{caption}
\usepackage{times}
\usepackage[titletoc]{appendix}
\usepackage[square, numbers, comma, sort&compress]{natbib}

\usepackage[round]{natbib}
\usepackage[unicode=true,pdfusetitle, bookmarks=t`enter code here`rue,bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=1, breaklinks=false,pdfborder={0 0 0},backref=false,colorlinks=false] {hyperref}


\makeatletter
\renewcommand{\baselinestretch}{1.5}
\renewcommand{\cfttoctitlefont}{\hfill\Huge\bfseries}
\renewcommand{\cftaftertoctitle}{\hfill}
\renewcommand{\cftloftitlefont}{\hfill\Huge\bfseries}
\renewcommand{\cftafterloftitle}{\hfill}
\renewcommand{\cftlottitlefont}{\hfill\Huge\bfseries}
\renewcommand{\cftafterlottitle}{\hfill}

\renewcommand\cftchapdotsep{\cftdotsep}


\renewcommand\thechapter{\arabic{chapter}}
\renewcommand\thesection{\arabic{chapter}.\arabic{section}}
\providecolor{lyxadded}{rgb}{0,0,1}
\providecolor{lyxdeleted}{rgb}{1,0,0}
\DeclareRobustCommand{\lyxadded}[3]{{\texorpdfstring{\color{lyxadded}{}}{}#3}}
\DeclareRobustCommand{\lyxdeleted}[3]{{\texorpdfstring{\color{lyxdeleted}\sout{#3}}{}}}
\usepackage{tocloft}

\usepackage{minitoc}
\usepackage[tocfullflat]{tocstyle}

\usepackage[labelfont=bf]{caption} 
\renewcommand{\@pnumwidth}{0.9em}
\usepackage{feyn}

 \usepackage[center]{titlesec}
 \titleformat{\chapter}[block]
   {\normalfont\fontsize{14pt}{12pt}\selectfont\bfseries
\centering} {\MakeUppercase \thechapter.}{1pt}{\MakeUppercase}
 \titleformat{\section}
   {\normalfont\fontsize{12pt}{14pt}\selectfont\bfseries}{\thesection .}{1pt}{}
 \titleformat{\subsection}
   {\normalfont\fontsize{12pt}{14pt}\selectfont\bfseries}{\thesubsection .}{1pt}{}
     \titleformat{\subsubsection}
   {\normalfont\fontsize{12pt}{14pt}\selectfont\bfseries}{\thesubsubsection .}{1pt}{}
 \titlespacing*{\chapter} {0pt}{12pt}{0.3ex plus .2ex}
 \titlespacing*{\section} {0pt}{12pt}{0.3ex plus .2ex}
 \titlespacing*{\subsection}{0pt}{12pt}{0.3ex plus .2ex}
\titlespacing*{\subsubsection}{0pt}{12pt}{0.3ex plus .2ex}


\begin{document}

\clearpage
\thispagestyle{plain}

\renewcommand{\cfttoctitlefont}{\large\hfil\textbf}
\pagenumbering{roman} \setcounter{page}{5}
\def\contentsname{CONTENTS}


\setlength{\cftsecindent}{0em}  
\setlength{\cftsubsecindent}{25em} 
\setlength{\cftsubsubsecindent}{25em} 
\setlength{\cftbeforechapskip}{0em}
\renewcommand{\cftdot}{.}
\renewcommand{\cftdotsep}{0.1}
\setlength{\cftchapnumwidth}{1.0em}
\setlength{\cftsecnumwidth}{1.7em}
\setlength{\cftsubsecnumwidth}{2.4em}
\setlength{\cftsubsubsecnumwidth}{2.8em}
\renewcommand{\cftchapleader}{\cftdotfill{\cftsecdotsep}}
\renewcommand{\cftchapfont}{\rmfamily\mdseries}
\renewcommand{\cftchappagefont}{\normalfont}
\renewcommand{\cftchapaftersnum}{.}
\renewcommand{\cftsecaftersnum}{.}
\renewcommand{\cftsubsecaftersnum}{.}
\renewcommand{\cftsubsubsecaftersnum}{.}

\newpage
\tableofcontents

\clearpage
\thispagestyle{plain}
\renewcommand{\cfttoctitlefont}{\large\hfil\textbf}
\pagenumbering{arabic} \setcounter{page}{1}

\addcontentsline{toc}{chapter}{Contents}



\chapter{A}
\section{Introduction}
\subsection{a}
\end{document}

Best Answer

Remove the tocfullflat option from the package tocstyle.

% arara: pdflatex
% arara: pdflatex

\documentclass[12pt, a4paper]{report}
\usepackage{geometry}
\geometry{verbose,tmargin=25mm,bmargin=25mm,lmargin=30mm,rmargin=25mm}
\setlength{\parskip}{\medskipamount}
\usepackage{tocloft}
\usepackage{times}
\renewcommand{\baselinestretch}{1.5}
%\renewcommand{\cftaftertoctitle}{\hfill} % if you want this title centred, this has to go away
\usepackage{minitoc}
\usepackage{tocstyle} % removed the flat toc option here
\usepackage{titlesec}
\titleformat{\chapter}[block]
{\normalfont\fontsize{14pt}{12pt}\selectfont\bfseries
    \centering} {\MakeUppercase \thechapter.}{1pt}{\MakeUppercase}
\titleformat{\section}
{\normalfont\fontsize{12pt}{14pt}\selectfont\bfseries}{\thesection .}{1pt}{}
\titleformat{\subsection}
{\normalfont\fontsize{12pt}{14pt}\selectfont\bfseries}{\thesubsection .}{1pt}{}
%\titleformat{\subsubsection}
%{\normalfont\fontsize{12pt}{14pt}\selectfont\bfseries}{\thesubsubsection .}{1pt}{} % not used here
\titlespacing*{\chapter} {0pt}{12pt}{0.3ex plus .2ex}
\titlespacing*{\section} {0pt}{12pt}{0.3ex plus .2ex}
\titlespacing*{\subsection}{0pt}{12pt}{0.3ex plus .2ex}
%\titlespacing*{\subsubsection}{0pt}{12pt}{0.3ex plus .2ex} % not used here

\begin{document}    
    \renewcommand{\cfttoctitlefont}{\large\hfil\textbf}
    \pagenumbering{roman} \setcounter{page}{5}
    \def\contentsname{CONTENTS} 

    \setlength{\cftsecindent}{0em}  
    \setlength{\cftsubsecindent}{25em} 
    \tableofcontents
    \clearpage
    \pagenumbering{arabic} \setcounter{page}{1} 
    \addcontentsline{toc}{chapter}{Contents}    

    \chapter{A}
    \section{Introduction}
    \subsection{a}
\end{document}

enter image description here

Related Question