我想将零件名称作为 MODULE - I 放在目录的中心,不带页码。
\documentclass{scrbook}
\usepackage[english]{babel}
\usepackage{lipsum}
\usepackage{tocstyle}
\renewcommand{\partname}{Module}%
\usetocstyle{standard}
%\settocfeature{pagenumberhook}{}
\renewcommand*{\addparttocentry}[2]{%
\addtocentrydefault{part}{}{\protect\parbox{\textwidth}{\protect\centering#2}}% original #1 in second argument
}
\begin{document}
\tableofcontents
\part{A}
\chapter{chapter A}
\section{Section a}
\lipsum
\part{B}
\chapter{chapter B}
\section{Section b}
\lipsum
\end{document}
答案1
l@part
你可以l@part
使用以下方法进行破解,而不必重新定义\addtokomafont
:
\addto\captionsenglish
用于重新定义零件名称。请参阅:更改报告书目的文本
\documentclass{scrbook}
\usepackage[english]{babel}
\usepackage{lipsum}
\addto\captionsenglish{%
\renewcommand{\partname}{Module}%
}
\makeatletter
\addtokomafont{partentry}{\def\numberline#1{--~#1\autodot\quad}\centering\partname~}
\addtokomafont{partentrypagenumber}{\let\hfil\relax\def\hb@xt@#1#2{}}
\makeatother
\begin{document}
\tableofcontents
\part{A}
\chapter{chapter A}
\section{Section a}
\lipsum
\part{B}
\chapter{chapter B}
\section{Section b}
\lipsum
\end{document}
答案2
您可以重新定义\l@part
为scrbook.cls
:
\documentclass{scrbook}
\renewcommand\partname{Module}
\makeatletter
\renewcommand*\l@part[2]{%
\ifnum \c@tocdepth >-2\relax
\addpenalty{-\@highpenalty}%
\addvspace{2.25em \@plus\p@}%
\setlength{\@tempdima}{2em}%
\if@tocleft
\ifx\toc@l@number\@empty\else
\setlength\@tempdima{0\toc@l@number}%
\fi
\fi
\begingroup
\leavevmode
\centering\usekomafont{partentry}{\partname\ -- #1\nobreak
\usekomafont{partentrypagenumber}{}}\null\par
\ifnum \scr@compatibility>\@nameuse{scr@[email protected]}\relax
\endgroup
\penalty20010
\else
\penalty\@highpenalty
\endgroup
\fi
\fi
}\makeatother
\begin{document}
\tableofcontents
\part{Test Part One}
\chapter{Test Chapter}
\section{Test Section}
\part{Test Part Two}
\chapter{Test Chapter}
\section{Test Section}
\end{document}