我正在尝试格式化目录、图片列表和表格列表。我需要将所有标题居中,但当我这样做时,目录中的图片列表和表格列表会添加额外的间距。
这是我的代码(我删除了不必要的部分):
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{dissertation}
[2015/06/05 v0.2 Dissertation Class]
\newif\if@endorse
\DeclareOption{endorse}{\@endorsetrue}
\DeclareOption{noendorse}{\@endorsefalse}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}
\ExecuteOptions{noendorse, 12pt, letterpaper}
\ProcessOptions
\LoadClass{report}
\RequirePackage[hmargin={1.5in,1in},vmargin=1in,foot=0.5in]{geometry}
\RequirePackage[nottoc]{tocbibind}
\RequirePackage{needspace}
\RequirePackage{tocloft}
\newcommand\makefrontmatter{%
\maketitle
\pdfbookmark[chapter]{\contentsname}{toc}
\tableofcontents \newpage \listoftables \newpage \listoffigures
\clearpage
\pagenumbering{arabic} \global\let\thanks\relax
\global\let\maketitle\relax \global\let\title\relax
\global\let\author\relax \global\let\date\relax
\global\let\and\relax \global\let\abstract\relax
\global\let\dedication\relax}
\renewcommand{\contentsname}{\hfill \normalfont Table of Contents \hfill}
\renewcommand{\cftaftertoctitle}{\hfill}
\renewcommand\cftsecfont{\normalsize \normalfont}
\renewcommand\cftsecpagefont{\normalsize \normalfont}
\renewcommand\cftsubsecfont{\normalsize \normalfont}
\renewcommand\cftsubsecpagefont{\normalsize \normalfont}
\renewcommand\cftloftitlefont{\normalsize \normalfont}
\renewcommand{\listfigurename}{\hfill \normalfont List of Figures \hfill}
\renewcommand{\listtablename}{\hfill \normalfont List of tables \hfill}
\renewcommand{\cfttoctitlefont}{\normalfont}
\renewcommand{\cftloftitlefont}{\normalfont}
\renewcommand{\cftlottitlefont}{\normalfont}
\renewcommand{\cftfigfont}{\normalfont}
\renewcommand{\cftfigpagefont}{\normalfont}
以下是我得到的结果:
答案1
这有帮助吗?
% tocloftcenteringprob.tex SE 573019
\documentclass{report}
\usepackage{tocloft}
%%% center ToC, etc titles
\renewcommand{\cfttoctitlefont}{\hfil\Large\bfseries} \renewcommand{\cftaftertoctitle}{\hfill}
\renewcommand{\cftloftitlefont}{\hfill\Large\bfseries} \renewcommand{\cftafterloftitle}{\hfill}
\begin{document}
\tableofcontents
\listoffigures \addcontentsline{toc}{chapter}{\listfigurename}
\chapter{A chapter}
\begin{figure}
\centering
A FIGURE
\caption{A figure}
\end{figure}
\end{document}