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 クラスと一緒に使用しないでください。

TOC の章タイトルとページ番号の間のスペースをドットで埋める KOMA スクリプト オプションがあります。

\KOMAoptions{toc=chapterentrydotfill}

ここに画像の説明を入力してください


章見出しのページ番号を太字にしない場合は、

\addtokomafont{chapterentrypagenumber}{\mdseries}

TOC からパート見出しのページ番号を削除することもできます。

\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}

KOMA-Scriptバンドルの一部であるパッケージを使用することもできますtocstyle。すべてのレベルの見出しと目次のページ番号の間にドットを表示するには、以下を使用します。

\usetocstyle{allwithdot}

@Peter Ebelsbergerが既に提案しているように、目次の見出しのドットとページ番号を削除するには、

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

MWE:

\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

新しい ではtocloft、次のように動作します。

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

関連情報