# The vertical spacing before the title of TOC is inconsistent with the normal section title

I use the tocloft package to customize the format of TOC and the ctex package to support Chinese typesetting and to customize the section title format. Everything works well. But I find that the vertical spacing before the title of TOC is slightly smaller than that before the normal section title. Here is MWE:

%!TeX program = xelatex
\documentclass{article}

% for Chinese typesetting
\ctexset{
section/format = \bfseries \centering \LARGE
}

\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage}

\usepackage{tocloft}
\renewcommand{\cfttoctitlefont}{\hfill \bfseries \LARGE}
\renewcommand{\contentsname}{目录}
\renewcommand{\cftaftertoctitle}{\hfill}
\renewcommand{\cftbeforesecskip}{0em}
\renewcommand{\cftsecdotsep}{\cftdotsep}

\usepackage{fancyhdr}
\fancypagestyle{main}{
\fancyhf{}
\fancyfoot[C]{\thepage}
}

\makeatletter
\renewcommand{\maketitle}{
\begin{titlepage}
\vspace*{\fill}
\begin{center}
{\Huge\bfseries\@title} \\
\vspace{2em}
{\Large\@author} \\
\vspace{\stretch{3}}
{\large\@date}
\end{center}
\vspace{\stretch{0.5}}
\end{titlepage}
}
\makeatother

\AtBeginDocument{
\let \oldtableofcontents \tableofcontents
\renewcommand{\tableofcontents}{
\fancypagestyle{plain}{
\fancyhf{}
}
\pagestyle{plain}
\oldtableofcontents
\clearpage
\pagestyle{main}
}
}

\title{标题}
\author{作者}
\date{\today}

\begin{document}
\maketitle
\tableofcontents

\section{第一节}
这是第一节。This is the first section.

\section{第二节}
这是第二节。This is the second section.
\end{document}



It can be seen, though not obvious, that the vertical spacing before TOC title is smaller. I tried to solve this problem and I found this question. Add this code in my preamble:

\renewcommand{\cftbeforetoctitleskip}{10em}


But it has no effect.

Then I read the doc of tocloft package and found the definition of TOC title:

\newcommand{\@cftmaketoctitle}{%
\if@cfthaschapter
\vspace*{\cftbeforetoctitleskip}%
\else
\vspace{\cftbeforetoctitleskip}%
\fi
\@cftpagestyle
{\interlinepenalty\@M
{\cfttoctitlefont\contentsname}{\cftaftertoctitle}%
\cftmarktoc
\par\nobreak
\vskip \cftaftertoctitleskip



So the problem might come from \vspace，I renewcommand this macro by substitute \vspace to \vspace*. But this time, a new problem arose! The spacing became larger:

I finally solved this problem by renewcommanding \@cftmaketoctitle like this:

\renewcommand{\@cftmaketoctitle}{%
\section*{\contentsname}

• If the TOC title should be a normal unnumbered section title, set option titles for package tocloft: \usepackage[titles]{tocloft}. – esdd May 16 at 10:18