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

如何移除scrbook类目录(TOC)的自身条目?现有方案无效

移除scrbook类LaTeX文档目录中的“Contents”条目

问题背景

使用scrbook类编写LaTeX文档时,目录(TOC)的第一条条目为“Contents”(指向目录自身),需要将其移除。尝试过旧方案如\tableofcontents*或KeepFromToc环境均无效:\tableofcontents*在当前环境下不生效,KeepFromToc仅适用于memoir类,无法被scrbook识别。

最小工作示例(MWC)

\documentclass[a4paper,11pt,oneside,chapterprefix=TRUE]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage{scrlayer-scrpage}
\usepackage[pass,a4paper]{geometry}
\usepackage{acronym}
\usepackage[notindex]{tocbibind}
\usepackage{titletoc}
\usepackage{makeidx} 

\makeindex

\begin{document}
\frontmatter
\setcounter{page}{1}
\tableofcontents
\listoftables
\listoffigures
%\KOMAoptions{open=right}
\include{acronyms}
\include{ACK}
\include{Publications Related to Thesis}
\mainmatter
\chapter{Introduction}
\backmatter
\printbibliography
\end{document}

当前输出

目录第一条显示“Contents”条目,指向目录页面。

解决方案

方法1:修改tocbibind包选项(推荐)

问题根源是tocbibind包默认会将目录、列表等条目加入目录。只需在加载tocbibind时添加nottoc选项,禁止将目录自身加入目录:

\usepackage[notindex,nottoc]{tocbibind}

修改后的完整MWC:

\documentclass[a4paper,11pt,oneside,chapterprefix=TRUE]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage{scrlayer-scrpage}
\usepackage[pass,a4paper]{geometry}
\usepackage{acronym}
\usepackage[notindex,nottoc]{tocbibind} % 添加nottoc选项
\usepackage{titletoc}
\usepackage{makeidx} 

\makeindex

\begin{document}
\frontmatter
\setcounter{page}{1}
\tableofcontents
\listoftables
\listoffigures
%\KOMAoptions{open=right}
\include{acronyms}
\include{ACK}
\include{Publications Related to Thesis}
\mainmatter
\chapter{Introduction}
\backmatter
\printbibliography
\end{document}

方法2:临时调整目录深度(不依赖包修改)

如果不想改动tocbibind的选项,可以在生成目录前临时将目录深度设为-1(不显示任何条目),生成目录后再恢复原深度:

\frontmatter
\setcounter{page}{1}
\addtocontents{toc}{\protect\setcounter{tocdepth}{-1}} % 临时隐藏所有目录条目
\tableofcontents
\addtocontents{toc}{\protect\setcounter{tocdepth}{2}} % 恢复目录深度(可根据需求调整为1/3等)

此方法会阻止\tableofcontents生成自身的目录条目,同时不影响后续章节、列表的目录显示。

方法3:利用titletoc包过滤条目

由于已加载titletoc包,可以通过重定义目录样式来过滤“Contents”条目:

\usepackage{titletoc}
\titlecontents{chapter}
  [0em]
  {\bfseries}
  {\thecontentslabel\space}
  {}
  {\hfill\contentspage}
  [\addvspace{0.5em}]
\titlecontents{section}
  [2em]
  {}
  {\thecontentslabel\space}
  {}
  {\titlerule*[1pc]{.}\contentspage}
% 过滤掉Contents条目
\addtocontents{toc}{\protect\vspace{-\baselineskip}} % 移除空白行
\addtocontents{toc}{\protect\deletecontentsline{chapter}{Contents}{1}}

注意:此方法需要准确对应“Contents”条目的层级和页码,灵活性稍差。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.14 11:13:21