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

9
我正在尝试使用以下命令在LaTeX中居中目录表的标题:
\usepackage{tocloft}
\renewcommand{\contentsname}{\centering Table of Contents}

我相信你们都已经意识到这个方法不起作用了,有什么建议可以尝试吗?

编辑: 我已经通过某种方式使它工作了。

\renewcommand{\cfttoctitlefont}{\hfill\Huge}
3个回答

17

这个代码可以正常工作(没有使用 usepackage):

\renewcommand{\contentsname}{\centering Contents}

确保它在导言部分中,尝试删除.aux文件。


它在articlereport文档类中工作正常,但在book中会产生错误。 - MattAllegro

5

\documentclass{book} 中可以直接使用此功能,无需使用额外的 usepackage

\renewcommand*\contentsname{\hfill Contents \hfill}
\tableofcontents

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


3

更新contentsname可能会失败,因为\begin{document}从babel重写组件,需要将命令添加到\captionsenglish中。 这篇文章详细介绍了此问题。

\usepackage{tocloft}
\addto\captionsenglish{\renewcommand{\contentsname}{Table of Contents}}
\renewcommand{\cfttoctitlefont}{\hfill\normalsize}
\renewcommand{\cftaftertoctitle}{\hfill}

这个解决了我很多小时不理解为什么“\renewcommand{\contentsname}{Other title}”无效的问题,真是救了我的一天。 - potmo

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接