scrbook/komascript 中的目錄:將點

scrbook/komascript 中的目錄:將點

我需要根據出版商的要求自訂目錄的外觀。

這是現在的一個最小範例:

\documentclass{scrbook}

\begin{document}

\frontmatter

\tableofcontents

\chapter{Preface}

\mainmatter

\part{First part}

\chapter{First chapter}
\section{First section}
\subsection{First subsection}
\subsection{Second subsection}
\section{Second section}

\chapter{Second chapter}

\end{document}

這會產生如下所示的結果:


我目前目錄的螢幕截圖


現在我的出版商要求章節標題和頁碼之間應有點。

我找到了這個tocstyle包,但我不明白它的文檔。我甚至不確定該軟體包是否能讓我做我需要做的事情。有人可以就如何獲得我想要的東西提出建議嗎?謝謝。

編輯:我還需要刪除部分頁碼。我在最初的問題中發布了此要求,但不鼓勵每個線程提出多個問題。然而,後來事實證明,這實際上也可以對此處提出的問題產生影響:如果我使用tocstyle抑制頁面部件號,這可能會影響此處發布的消除章節點的解決方案。

答案1

不要將套件tocloft(在您自己的答案中提到)與 KOMA-Script 類別一起使用。

有一個 KOMA-Script 選項可以用點填滿目錄中章節標題和頁碼之間的空間:

\KOMAoptions{toc=chapterentrydotfill}

在此輸入影像描述


如果章節標題的頁碼不應使用粗體

\addtokomafont{chapterentrypagenumber}{\mdseries}

也可以從目錄中刪除部分標題的頁碼:

\addtokomafont{partentrypagenumber}{\nullfont}

在此輸入影像描述

代碼:

\documentclass[toc=chapterentrydotfill]{scrbook}
\addtokomafont{chapterentrypagenumber}{\mdseries}
\addtokomafont{partentrypagenumber}{\nullfont}
\begin{document}
\frontmatter
\tableofcontents
\chapter{Preface}
\mainmatter
\part{First part}
\chapter{First chapter}
\section{First section}
\subsection{First subsection}
\subsection{Second subsection}
\section{Second section}
\chapter{Second chapter}
\end{document}

也可以使用tocstyleKOMA-Script 套件中的套件。若要在目錄中所有層級的標題和頁碼之間新增點,請使用

\usetocstyle{allwithdot}

正如@Peter Ebelsberger 已經建議的那樣。若要刪除目錄中部分標題的點和頁碼,請新增

\settocstylefeature[-1]{leaders}{\hfill}
\settocstylefeature[-1]{pagenumberhook}{\nullfont}

微量元素:

\documentclass{scrbook}
\usepackage{tocstyle}
\usetocstyle{allwithdot}
\settocstylefeature[-1]{leaders}{\hfill}
\settocstylefeature[-1]{pagenumberhook}{\nullfont}
\begin{document}
\frontmatter
\tableofcontents
\chapter{Preface}
\mainmatter
\part{First part}
\chapter{First chapter}
\section{First section}
\subsection{First subsection}
\subsection{Second subsection}
\section{Second section}
\chapter{Second chapter}
\end{document}

運行多次即可得到

在此輸入影像描述

答案2

\documentclass{scrbook}

\usepackage{tocstyle}
\usetocstyle{allwithdot}
\begin{document}

\frontmatter

\tableofcontents

\chapter{Preface}

\mainmatter

\part{First part}

\chapter{First chapter}
\section{First section}
\subsection{First subsection}
\subsection{Second subsection}
\section{Second section}

\chapter{Second chapter}

\end{document}

答案3

我在其他地方找到了這個:

\RequirePackage{tocloft}
\let\partbackup\l@part  % create a backup copy of the part definition
\renewcommand*\l@part[2]{\partbackup{#1}{}}  % redefine part in order to leave out the page number for part
\renewcommand{\cftchapdotsep}{\cftdotsep}  % add dots for chapter entries
\renewcommand{\cftchapleader}{\cftdotfill{\cftchapdotsep}}  % add dots for chapter entries
\renewcommand{\cftchappagefont}{\mdseries}  % define chapter page numbers to be printed in normal font, not bold

人們會同意這是一個很好的解決方案,還是有我不知道的副作用?

答案4

對於 new tocloft,它的工作原理如下:

\DeclareTOCStyleEntry[%
  level=\chaptertocdepth,
  linefill=\TOCLineLeaderFill,
]{chapter}{chapter}

相關內容