我如何调整目录?

我如何调整目录?

我正在尝试用 LaTeX 写一份报告。首先,我尝试将目录左对齐。然后我改变了主意,但无法恢复。我想在章节和子章节之间留出一些距离,例如 4 厘米(不向左对齐)。我想更改目录,如下图所示。

在此处输入图片描述

请你帮助我好吗?

\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}

答案1

tocfullflat从包中删除该选项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}

在此处输入图片描述

相关内容