如何在LaTeX中将目录的标题居中?

Ben*_*ino 9 latex

我试图用以下命令将LaTeX中目录的标题居中

\usepackage{tocloft}
\renewcommand{\contentsname}{\centering Table of Contents}
Run Code Online (Sandbox Code Playgroud)

正如我在问我确定你们都意识到这不起作用,对我可以尝试的任何建议?

编辑:我得到了它

\renewcommand{\cfttoctitlefont}{\hfill\Huge}
Run Code Online (Sandbox Code Playgroud)

Jos*_*Lee 14

这工作(没有usepackage):

\renewcommand{\contentsname}{\centering Contents}
Run Code Online (Sandbox Code Playgroud)

确保它可能在序言中,并尝试查杀该.aux文件.


小智 5

这适用于\documentclass{book},无需使用包:

\renewcommand*\contentsname{\hfill Contents \hfill}
\tableofcontents
Run Code Online (Sandbox Code Playgroud)

如果 \renewcommand 紧接在 \tableofcontents 命令之前,它甚至应该可以工作。