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}

그러면 다음과 같은 결과가 생성됩니다.


현재 TOC 스크린샷


이제 출판사가 다음을 요청했습니다.제목에는 제목과 페이지 번호 사이에 점이 있어야 합니다.

패키지를 찾았 tocstyle지만 해당 문서를 이해하지 못합니다. 패키지가 내가 해야 할 일을 할 수 있게 해주는지조차 확신할 수 없습니다. 누군가 내가 원하는 것을 얻는 방법에 대해 제안해 주실 수 있나요? 감사해요.

편집하다:부품 페이지 번호도 제거해야 합니다. 원래 질문에 이 요구 사항을 게시했지만 스레드당 여러 질문을 사용하는 것은 권장되지 않습니다. 그러나 나중에 이것이 실제로 여기에 묻는 질문에도 영향을 미칠 수 있다는 것이 밝혀졌습니다. tocstyle페이지 부품 번호를 표시하지 않으려면 장 점을 제거하기 위해 여기에 게시된 솔루션에 영향을 미칠 수 있습니다.

답변1

tocloftKOMA-Script 클래스와 함께 패키지(귀하의 답변에 언급됨)를 사용하지 마십시오 .

장 제목과 목차의 페이지 번호 사이의 공간을 점으로 채우는 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}

tocstyleKOMA-Script 번들의 일부인 패키지를 사용하는 것도 가능합니다 . 모든 레벨의 제목과 TOC의 페이지 번호 사이에 점을 찍으려면 다음을 사용하세요.

\usetocstyle{allwithdot}

@Peter Ebelsberger가 이미 제안한대로. TOC에서 부품 제목의 점과 페이지 번호를 제거하려면 다음을 추가하세요.

\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

new 에서는 tocloft다음과 같이 작동합니다.

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

관련 정보