You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用tocloft与titlesec包,如何让LaTeX目录标题居中?

解决LaTeX目录标题无法居中的问题(附完整配置方案)

针对你使用titlesec和tocloft包时,目录标题Contents无法居中、同时需实现标题大写及添加前缀行的需求,可通过以下修改实现:

核心问题原因

tocloft包默认会接管目录、插图列表、表格列表的标题格式,默认左对齐,因此需要手动重定义标题的字体和对齐方式,而非依赖titlesec的全局标题设置。

具体修改步骤

1. 目录标题:大写+居中

在导言区添加以下代码,将默认的Contents改为大写,并通过左右填充实现居中:

% 重定义目录标题为大写
\renewcommand{\contentsname}{CONTENTS}
% 设置标题字体为加粗超大号,并左填充
\renewcommand{\cfttoctitlefont}{\hfill\Huge\bfseries}
% 右填充实现整体居中
\renewcommand{\cftaftertoctitle}{\hfill}

2. 插图列表/表格列表:大写+居中

同理处理插图和表格列表的标题:

% 插图列表配置
\renewcommand{\listfigurename}{LIST OF FIGURES}
\renewcommand{\cftloftitlefont}{\hfill\Huge\bfseries}
\renewcommand{\cftafterloftitle}{\hfill}

% 表格列表配置
\renewcommand{\listtablename}{LIST OF TABLES}
\renewcommand{\cftlottitlefont}{\hfill\Huge\bfseries}
\renewcommand{\cftafterlottitle}{\hfill}

3. 添加前缀行(Chapters/Figure/Table)

通过tocloft的前缀定义命令,给目录章节、插图、表格添加指定前缀,并调整缩进适配前缀长度:

% 目录中章节添加Chapters前缀
\renewcommand{\cftchappresnum}{Chapters\space}
\cftsetindents{chapter}{0em}{8em} % 调整缩进,为前缀预留空间

% 插图列表添加Figure前缀
\renewcommand{\cftfigpresnum}{Figure\space}
\cftsetindents{figure}{0em}{7em}

% 表格列表添加Table前缀
\renewcommand{\cfttabpresnum}{Table\space}
\cftsetindents{table}{0em}{6em}

完整示例代码

\documentclass{book}
\usepackage{titlesec}
\usepackage{tocloft}

% 目录标题配置
\renewcommand{\contentsname}{CONTENTS}
\renewcommand{\cfttoctitlefont}{\hfill\Huge\bfseries}
\renewcommand{\cftaftertoctitle}{\hfill}

% 插图列表配置
\renewcommand{\listfigurename}{LIST OF FIGURES}
\renewcommand{\cftloftitlefont}{\hfill\Huge\bfseries}
\renewcommand{\cftafterloftitle}{\hfill}

% 表格列表配置
\renewcommand{\listtablename}{LIST OF TABLES}
\renewcommand{\cftlottitlefont}{\hfill\Huge\bfseries}
\renewcommand{\cftafterlottitle}{\hfill}

% 前缀与缩进配置
\renewcommand{\cftchappresnum}{Chapters\space}
\cftsetindents{chapter}{0em}{8em}

\renewcommand{\cftfigpresnum}{Figure\space}
\cftsetindents{figure}{0em}{7em}

\renewcommand{\cfttabpresnum}{Table\space}
\cftsetindents{table}{0em}{6em}

\begin{document}
\tableofcontents
\listoffigures
\listoftables

\chapter{First Chapter}
\begin{figure}[h]
\centering
\rule{5cm}{3cm} % 占位示例图
\caption{Sample Figure}
\end{figure}

\begin{table}[h]
\centering
\begin{tabular}{|c|c|}
\hline
Column A & Column B \\
\hline
1 & 2 \\
\hline
\end{tabular}
\caption{Sample Table}
\end{table}

\chapter{Second Chapter}
\end{document}

内容的提问来源于stack exchange,提问作者Alex

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 02:56:13