章节标题垂直居中,但目录不垂直居中

章节标题垂直居中,但目录不垂直居中

我的大学要求章节标题放在单独的页面上,并且垂直和水平排列。根据论坛上的一些答案,我使用以下代码来实现它。

\documentclass[thesis,letterpaper,12pt]{utthesis}
\usepackage{fancyhdr}                % fancy headers and footers
\usepackage{titlesec}
\titleformat{\chapter}[display]{\vfil\normalfont\huge\bfseries\centering}{\chaptertitlename\ \thechapter}{20pt}{\Huge}    % for vertical and horizontal centring
 \renewcommand\contentsname{Table of Contents}
\setcounter{chapter}{-1}  % PACKAGES PRELOADED WITH CLASS: amsmath,amsthm,amssymb,setspace,geometry,hyperref,and color
\begin{document}
\pagenumbering{alph} % this is needed to clear certain issues with the hyperref package
\pagenumbering{roman}
\setcounter{page}{10}
\addToPDFBookmarks{0}{Table of Contents}{f}
\tableofcontents
\include{chapters/preface}
\include{chapters/chap1}`

我运行一切正常,但现在我注意到目录显示不正确。它几乎从页面末尾开始,尽管它应该从页面开头开始。有人能帮忙吗?

答案1

您可以将\titleformat命令移动到文档主体中您希望更改开始生效的位置之前;在您的情况下,您可以\titleformat从序言中移动并在之后使用它\tableofcontents

\documentclass[thesis,letterpaper,12pt]{utthesis}
\usepackage{fancyhdr}                % fancy headers and footers
\usepackage{titlesec}
 \renewcommand\contentsname{Table of Contents}
\setcounter{chapter}{-1}  % PACKAGES PRELOADED WITH CLASS: amsmath,amsthm,amssymb,setspace,geometry,hyperref,and color
\begin{document}
\pagenumbering{alph} % this is needed to clear certain issues with the hyperref package
\pagenumbering{roman}
\setcounter{page}{10}
\addToPDFBookmarks{0}{Table of Contents}{f}
\tableofcontents

\titleformat{\chapter}[display]{\vfil\normalfont\huge\bfseries\centering}{\chaptertitlename\ \thechapter}{20pt}{\Huge}    % for vertical and horizontal centring
\include{chapters/preface}
\include{chapters/chap1}
\end{document}

相关内容