MWE如下:
\documentclass[12pt,letter]{report}
\usepackage[titles]{tocloft}
\usepackage[compact,tiny]{titlesec}
\begin{document}
\setcounter{tocdepth}{3}
\setlength\cftaftertoctitleskip{0pt}
\titlespacing*{\chapter}{0.00in}{0.48in}{5mm}
\titleformat{\chapter}[display]{\normalfont\normalsize\filcenter}{%
\centering\chaptertitlename\ \thechapter}{0pt}{\normalsize\uppercase}
\renewcommand{\contentsname}{TABLE OF CONTENTS}
\renewcommand{\cftchapfont}{\normalsize}
\renewcommand{\cftchappagefont}{\normalsize}
\renewcommand{\cftchapleader}{\normalsize\cftdotfill{\cftchapdotsep}}
\tableofcontents
\univchapter[first chapter]{first chapter}
some text
\univchapter[second chapter]{second chapter}
some more text
\end{document}
的定义\univchapter
是
\newcommand\univchapter{\if@openright\cleardoublepage\else\clearpage\fi
\thispagestyle{plain}%
\global\@topnum\z@
\@afterindentfalse
\secdef\@univchapter\@schapter}
\def\@univchapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
\addcontentsline{toc}{chapter}%
{\chaptername\, \protect\numberline{\thechapter} \uppercase{#1}}%
\else
\addcontentsline{toc}{chapter}{\chaptername\, \uppercase{#1}}%
\fi
\chaptermark{#1}%
\addtocontents{lof}{\protect\addvspace{10\p@}}%
\addtocontents{lot}{\protect\addvspace{10\p@}}%
\if@twocolumn
\@topnewpage[\@makechapterhead{#2}]%
\else
\@makechapterhead{#2}%
\@afterheading
\fi}
在创建 MWE 以及按照您的建议执行代码时生成的错误是Use of \@ doesnt match its definition. \univchapter...i\thispagestyle{plain}global \@t opnum\z@afterindentfal....
答案1
您可以使用tocloft
包装并改变长度\cftaftertoctitleskip
;一个小例子(而不是0pt
,您可以使用最适合您需要的长度):
\documentclass[12pt,letter]{report}
\usepackage{tocloft}
\setlength\cftaftertoctitleskip{0pt}
\begin{document}
\tableofcontents
\chapter{first chapter}
some text
\chapter{second chapter}
some more text
\end{document}
为了保持一致,您可能还需要更改\cftafterlottitleskip
(对于 LoT)和\cftafterloftitleskip
(对于 LoF)。
由于使用了titles
的选项tocloft
(现在从对原始问题的编辑中可以清楚地看出),对 的更改\cftaftertoctitleskip
将不会产生任何效果;在这种情况下,一个可能的解决方案是修补\tableofcontents
、\listoffigures
和\listoftables
命令以添加一些负空间;这里有一个示例,其中包含对原始问题的编辑中提供的新设置:
\documentclass[12pt,letterpaper]{report}
\usepackage[titles]{tocloft}
\usepackage[compact,tiny]{titlesec}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\tableofcontents}{\@starttoc{toc}}{\vskip-10pt\@starttoc{toc}}{}{}
\patchcmd{\listoffigures}{\@starttoc{lof}}{\vskip-10pt\@starttoc{lof}}{}{}
\patchcmd{\listoftables}{\@starttoc{lot}}{\vskip-10pt\@starttoc{lot}}{}{}
\makeatother
\makeatletter
\newcommand\univchapter{\if@openright\cleardoublepage\else\clearpage\fi
\thispagestyle{plain}%
\global\@topnum\z@
\@afterindentfalse
\secdef\@univchapter\@schapter}
\def\@univchapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
\addcontentsline{toc}{chapter}%
{\chaptername\, \protect\numberline{\thechapter} \uppercase{#1}}%
\else
\addcontentsline{toc}{chapter}{\chaptername\, \uppercase{#1}}%
\fi
\chaptermark{#1}%
\addtocontents{lof}{\protect\addvspace{10\p@}}%
\addtocontents{lot}{\protect\addvspace{10\p@}}%
\if@twocolumn
\@topnewpage[\@makechapterhead{#2}]%
\else
\@makechapterhead{#2}%
\@afterheading
\fi}
\makeatother
\setcounter{tocdepth}{3}
\titlespacing*{\chapter}{0.00in}{0.48in}{5mm}
\titleformat{\chapter}[display]{\normalfont\normalsize\filcenter}{%
\centering\chaptertitlename\ \thechapter}{0pt}{\normalsize\uppercase}
\renewcommand{\contentsname}{TABLE OF CONTENTS}
\renewcommand{\cftchapfont}{\normalsize}
\renewcommand{\cftchappagefont}{\normalsize}
\renewcommand{\cftchapleader}{\normalsize\cftdotfill{\cftchapdotsep}}
\begin{document}
\tableofcontents
\univchapter[first chapter]{first chapter}
some text
\univchapter[second chapter]{second chapter}
some more text
\end{document}