LaTeX scrbook环境下修改\tableofcontents标题及解决前置章节标题异常显示问题
嗨,我来帮你搞定这个scrbook里目录页眉的问题!从你的描述来看,核心问题是前置到目录前的章节标题(比如「Liste der Abkürzungen」)跑到了目录的页眉上,同时你希望把目录页眉改成「Inhaltsverzeichnis」或者直接清空。下面分两种需求给你具体解决方案:
一、把目录页眉改成「Inhaltsverzeichnis」
你已经重定义了\contentsname为「Inhaltsverzeichnis」,但这只是目录的页面标题,不是页眉内容。scrbook的页眉是由章节标记(mark)控制的,之前的前置章节的mark没有被清除,所以目录继承了它的标题。我们可以手动给目录设置页眉标记:
步骤1:清除前置章节的标记
在你的01_0_fundamental_stuff_root.tex里,前置章节的末尾(\clearpage之前)添加一行代码,清除当前章节的页眉标记,避免后续页面继承它:
\chapter{Liste der Abkürzungen} \thispagestyle{empty} \begin{itemize} \item \textbf{A} - Text A \item \textbf{B} - Text B \item \textbf{V} - Text C \end{itemize} \markboth{}{} % 清除当前章节的页眉标记 \clearpage
步骤2:给目录及后续列表设置页眉标记
打开你的toc_lof_lot_lol.tex文件,在每个目录/列表命令前添加\markboth{}{}来设置对应的页眉内容:
\renewcommand{\contentsname}{Inhaltsverzeichnis} \renewcommand{\listfigurename}{Abbildungsverzeichnis} \renewcommand{\listtablename}{Tabellenverzeichnis} \renewcommand{\listalgorithmname}{Pseudocodeverzeichnis} \renewcommand{\lstlistlistingname}{Quelltextverzeichnis} % 给目录设置页眉为Inhaltsverzeichnis \markboth{\contentsname}{\contentsname} \tableofcontents % 给图表目录设置对应页眉 \markboth{\listfigurename}{\listfigurename} \listoffigures\thispagestyle{empty} \clearpage{\pagestyle{empty}\cleardoublepage} \markboth{\listtablename}{\listtablename} \listoftables\thispagestyle{empty} \clearpage{\pagestyle{empty}\cleardoublepage} \markboth{\lstlistlistingname}{\lstlistlistingname} \lstlistoflistings\thispagestyle{empty} \clearpage{\pagestyle{empty}\cleardoublepage} \setcounter{page}{1}
这样每个列表页面的页眉都会显示对应的名称,目录页的页眉就是你想要的「Inhaltsverzeichnis」啦。
二、完全清空目录及列表页面的页眉
如果你想让这些页面的页眉完全为空,除了保持\thispagestyle{empty},还要确保整个frontmatter里这些页面的全局页眉样式都是empty,并且清除前置章节的标记:
步骤1:清除前置章节标记(同上)
还是在01_0_fundamental_stuff_root.tex里添加\markboth{}{}:
\markboth{}{} % 清除当前章节的页眉标记 \clearpage
步骤2:设置全局页眉为空
在toc_lof_lot_lol.tex的开头添加\pagestyle{empty},确保所有后续页面(目录、图表目录等)的页眉都是空的,然后在进入mainmatter前再恢复默认页眉样式(可选,如果你需要mainmatter有页眉的话):
\renewcommand{\contentsname}{Inhaltsverzeichnis} % ... 其他名称重定义 ... \pagestyle{empty} % 设置全局页眉为空 \tableofcontents \listoffigures\thispagestyle{empty} \clearpage{\pagestyle{empty}\cleardoublepage} \listoftables\thispagestyle{empty} \clearpage{\pagestyle{empty}\cleardoublepage} \lstlistoflistings\thispagestyle{empty} \clearpage{\pagestyle{empty}\cleardoublepage} \setcounter{page}{1}
然后在你的主文档mainmatter之前,可以添加\pagestyle{headings}来恢复scrbook默认的页眉样式(如果需要的话)。
额外说明
因为你用的是scrbook,它默认使用scrlayer-scrpage(旧版是scrpage2)来管理页眉页脚,\markboth是标准LaTeX命令,用来设置双页文档的左页(偶数页)和右页(奇数页)页眉内容,完全适配scrbook的机制,不会有冲突。
备注:内容来源于stack exchange,提问作者Kuzniarz




