我正在尝试更改目录的一些内容以符合提交指南。
首先,必须在第一章上方插入单词“Chapter”,并与数字对齐。
其次,我需要在不同级别之间插入一个空行,即章节条目和部分之间有一行,但不在多个部分之间,等等。
另外,我想将所有章节标题都大写。目前,我已通过在各个章节的文件中将章节名称全部大写来实现此目的,但我觉得一定有更好的方法。
这是我的 MWE。
\documentclass[oneside,11pt,paper=letter,listof=nochaptergap]{scrbook}
\usepackage[right=1in,top=1in,bottom=1in,left=1.5in]{geometry} % margins
\KOMAoptions{toc=listof} % place lists of figures and tables unnumbered in table of contents
\KOMAoptions{bibliography=totoc}
\AfterTOCHead[lof]{\noindent\textbf{\figurename}\hfill \textbf{Page}\par}
\AfterTOCHead[lot]{\noindent\textbf{\tablename}\hfill \textbf{Page}\par}
\DeclareTOCStyleEntry[
beforeskip=\baselineskip,
indent=0pt
]{default}{figure}
\DeclareTOCStyleEntry[
beforeskip=\baselineskip,
indent=0pt
]{default}{table}
\DeclareTOCStyleEntry[
beforeskip=\baselineskip,
indent=0pt
]{default}{chapter}
\begin{document}
\frontmatter % start roman numerals on title page
\chapter{Abstract}
this is an abstract.
\renewcommand*{\contentsname}{TABLE OF CONTENTS}
\tableofcontents % (required)
\renewcommand{\listtablename}{LIST OF TABLES}
\listoftables % (when appropriate)
\renewcommand{\listfigurename}{LIST OF FIGURES}
\listoffigures % (when appropriate)
\mainmatter
\chapter{First Chapter}
this is a chapter
\captionof{figure}{Figure in first chapter}
\section{Section}
\section{No Space Between Us}
\subsection{But I Need a Space}
\chapter{Second Chapter}
this is a chapter
\section{Section}
\section{No Space Between Us}
\subsection{But I Need a Space}
\end{document}
编辑:
我通过添加以下内容设法使间距正确:
\DeclareTOCStyleEntry[
onstarthigherlevel= \vspace{\baselineskip},
onstartlowerlevel= \vspace{\baselineskip}
]{default}{section}
\DeclareTOCStyleEntry[
onstarthigherlevel= \vspace{\baselineskip},
onstartlowerlevel= \vspace{\baselineskip}
]{default}{subsection}
另外,我似乎可以使用 \addxcontentsline 添加单词“Chapter”,但它带有页码,我不知道如何删除。有什么想法可以解决这个问题吗?
答案1
您可以为章节前缀和补丁声明自己的条目样式\addchaptertocentry
:\addchapterlinesformat
\documentclass[oneside,paper=letter]{scrbook}
\usepackage{blindtext}% only for dummy text
\usepackage[margin=1in,left=1.5in]{geometry}
\KOMAoption{listof}{totoc,nochaptergap}
\KOMAoptions{bibliography=totoc}
\AfterTOCHead[lof]{\noindent\textbf{\figurename}\hfill \textbf{Page}\par}
\AfterTOCHead[lot]{\noindent\textbf{\tablename}\hfill \textbf{Page}\par}
\DeclareTOCStyleEntry[
level=\chaptertocdepth,
numwidth=0pt,
indent=0pt,
entryformat=\usekomafont{chapterentry},
pagenumberformat=\phantom,
linefill=\hfill
]{default}{chapterprefix}
\DeclareTOCStyleEntries[
beforeskip=\baselineskip,
indent=0pt
]{default}{chapterprefix,chapter,figure,table}
\DeclareTOCStyleEntries[
onstarthigherlevel= \vspace{\baselineskip},
onstartlowerlevel= \vspace{\baselineskip}
]{default}{section,subsection}
\usepackage{xpatch}
\xpatchcmd{\chapterlinesformat}
{#3}
{\MakeUppercase{#3}}
{}{\PatchFailedI}
\xpatchcmd{\addchaptertocentry}
{\addtocentrydefault{chapter}{#1}{#2}}
{%
\ifnum \value{chapter}=1 \addtocentrydefault{chapterprefix}{}{\MakeUppercase{\chaptername}}\fi
\addtocentrydefault{chapter}{#1}{\MakeUppercase{#2}}%
}
{}{\PatchFailedII}
\begin{document}
\frontmatter
\chapter{Abstract}
This is an abstract.
\tableofcontents
\listoftables
\listoffigures
\mainmatter
\chapter{First Chapter}
This is a chapter
\captionof{figure}{Figure in first chapter}
\section{Section}
\section{No Space Between Us}
\subsection{But I Need a Space}
\chapter{Second Chapter}
This is a chapter
\section{Section}
\section{No Space Between Us}
\subsection{But I Need a Space}
\blinddocument
\blinddocument
\end{document}