我如何自定义目录?

我如何自定义目录?

我是 LaTeX 新手,请帮帮我。我正在写论文,遇到了目录问题,我想删除目录第一部分之间的空格,即

AUTHOR'S DECLARATION i
ABSTRACT ii
ACKNOWLEDGEMENTS iii
TABEL OF CONTENT iv
LIST OF FIGURES v
LIST OF ABBRAVIATIONS

然后使用 0.5 厘米的垂直间距放置双倍行距,然后出现目录的第二部分,即

CHAPTER ONE INTRODUCTION 1
1.1 rst section 1
1.2 second section 1
CHAPTER TWO INTRODUCTION 2
2.1 rst section 2
2.2 second section 2

注意:第一章和第二章之间的垂直间距为0.3厘米。我使用了以下方法:

    %\documentclass[a4paper]{article}
    \documentclass[12pt,english]{report}

    \setlength{\parindent}{1.27cm}

    \usepackage{setspace}
    \onehalfspacing
    \usepackage{titlesec, blindtext, color}
    \usepackage[font=small,labelfont=bf,justification=centering]{caption}
    \usepackage{geometry}

    \geometry{
      verbose,
      tmargin=2cm,
      bmargin=2.5cm,
      lmargin=3.8cm,
      rmargin=2.5cm
    }
    \newcommand{\mychapter}[3][]{%
    \setcounter{chapter}{#3}
    \setcounter{section}{0}
    \chapter*{#2}
    \if\relax\detokenize{#1}\relax
      \addcontentsline{toc}{chapter}{#2}
    \else
      \addcontentsline{toc}{chapter}{#1}
    \fi
    }
\usepackage{tocloft}  % use for th next command in order to remove dots
\renewcommand{\cftdot}{} % remove dots of table of content
\renewcommand{\cfttoctitlefont}{\hfil\bf} 
    \begin{document}
    \pagenumbering{roman}
    \setcounter{page}{1}
      \titlespacing*{\chapter}{10pt}{0pt}{10pt}
      \titleformat{\chapter}[display]
          {\centering\normalfont\large\bfseries}{ \chaptertitlename\ \thechapter}{0pt}{\large}

          \include{declartion}

          \addcontentsline{toc}{chapter}{\numberline{} AUTHOR'S  DECLARATION} \vspace*{-1cm} %

          %\abstract{\addtocontents{toc}

          \newpage

          \addcontentsline{toc}{chapter}{\numberline{}ABSTRACT} {\vspace*{6cm}}%
          \include{abstract}
          \newpage
          \chapter*{ACKNOWLEDGEMENTS}%
          \addcontentsline{toc}{chapter}{\numberline{}ACKNOWLEDGEMENTS} {\vspace{7em}}%
          \newpage

          \tableofcontents

          \addcontentsline{toc}{chapter}{\numberline{}TABEL OF CONTENT} %{\vspace{-5em}}%

          \newpage
          \listoffigures
          \addcontentsline{toc}{chapter}{\numberline{}LIST OF FIGURES} %{\vspace{-6em}}%
          \addcontentsline{toc}{chapter}{\numberline{}LIST OF ABBRAVIATIONS} % {\vspace{-6em}}%
          \newpage


          \newpage
          \tableofcontents

           \titlespacing*{\chapter}{10pt}{0pt}{10pt}
            \titleformat{\chapter}[display]
                {\centering\normalfont\large\bfseries}{ \chaptertitlename\ \thechapter}{40pt}{\large}
\mychapter[CHAPTER ONE INTRODUCTION]{CHAPTER ONE\\INTRODUCTION}{1} % the problem if happen fron centering
\pagenumbering{arabic}
sfsdfsf
sfsdfsf
\section{first section}
This is section one in chapter one.
\section{second section }

This is section two  in chapter one.
\mychapter[CHAPTER TWO RELATED WORK]{CHAPTER TWO \\RELATED WORD}{2} % the problem if happen fron centering
\section{first section}
This is section one in chapter TWO.
\section{second section }
This is section two  in chapter TWO.
          \end{document}

在此处输入图片描述

答案1

从我的角度来看也许有一些提示。

  • 我不明白你为什么要定义命令\mychapter。我认为你可以用 chapter 实现相同的效果,但需要进行一些修改:

    \titleformat{\chapter}[hang]{\centering\normalfont\large\bfseries}{}{0pt}{\large}
    \renewcommand\thesection{\arabic{section}}
    \setlength{\cftchapnumwidth}{0pt}
    \renewcommand\thechapter{}
    

    请注意,您将拥有许多相等的部分编号。

  • 您可以使用包tocbibind将 toc、lof 等放入目录中。

  • 为什么要使用\numberline?它会导致出现不常见的、不需要的空间。很简单:

    \addcontentsline{toc}{chapter}{ACKNOWLEDGEMENTS}
    
  • 目录中任何章节条目前的空格由 定义tocloft\cftbeforechapskip因此,您可以使用 随处更改它\addtocontents(参见示例)
  • 我个人更喜欢\clearpage而不是newpage

addchap顺便说一句,请允许我稍微提示一下像 memoir 或 KOMA 这样的新文档类。KOMA 提供了在目录中创建未编号条目的命令。

这是您修改后的 MWE:

\documentclass[12pt,english]{report}
\usepackage{setspace}\onehalfspacing
\usepackage{titlesec, blindtext, color}
\usepackage[]{tocbibind}
\usepackage{tocloft} 
\renewcommand{\cftdot}{} % remove dots of table of content
\renewcommand{\cfttoctitlefont}{\hfil\bf} 
\titleformat{\chapter}[hang]{\centering\normalfont\large\bfseries}{}{0pt}{\large}
\renewcommand\thesection{\arabic{section}}
\setlength{\cftchapnumwidth}{0pt}
\renewcommand\thechapter{}
\titlespacing*{\chapter}{10pt}{0pt}{10pt}
\begin{document}
\pagenumbering{roman}
\addtocontents{toc}{\protect\setlength{\cftbeforechapskip}{0em}}%


%\include{declartion}

\addcontentsline{toc}{chapter}{AUTHOR'S  DECLARATION}

\clearpage
\addcontentsline{toc}{chapter}{ABSTRACT}
\include{abstract}
\clearpage
\chapter*{ACKNOWLEDGEMENTS}%
\addcontentsline{toc}{chapter}{ACKNOWLEDGEMENTS}

\clearpage
\tableofcontents

\clearpage
\listoffigures
\addcontentsline{toc}{chapter}{LIST OF ABBRAVIATIONS}

\clearpage
\addtocontents{toc}{\protect\setlength{\cftbeforechapskip}{1.0em plus 1pt}}%

\chapter[CHAPTER ONE INTRODUCTION]{CHAPTER ONE\\INTRODUCTION}
\pagenumbering{arabic}
sfsdfsf
sfsdfsf
\section{first section}
This is section one in chapter one.
\section{second section }
This is section two  in chapter one.

\chapter[CHAPTER TWO RELATED WORK]{CHAPTER TWO \\RELATED WORD}
\section{first section}
This is section one in chapter TWO.
\section{second section }
This is section two  in chapter TWO.
\end{document}

在此处输入图片描述

相关内容