我希望名称“章节 [编号]”位于顶部,实际的下方\chapter
。
\documentclass[egregdoesnotlikesansseriftitles,headings=optiontoheadandtoc]{scrreprt}
\usepackage{newtxtext}
\setkomafont{chapter}{\rmfamily \LARGE}
\addtokomafont{subsection}{\normalfont \itshape }
%code below here does not seem to work
\renewcommand*{\raggedchapter}{\centering} %chapter in toc and on page (numbering)
\renewcommand*{\chaptermarkformat}{\chapappifchapterprefix{\nobreakspace}\thechapter\autodot:\enskip}
\let\originaladdchaptertocentry\addchaptertocentry
\renewcommand*{\addchaptertocentry}[2]{%
\IfArgIsEmpty{#1}
{\originaladdchaptertocentry{#1}{#2}}
{\originaladdchaptertocentry{\chapappifchapterprefix{\nobreakspace}#1\autodot}{#2}}%
}
\RedeclareSectionCommand[
tocentrynumberformat={\def\autodot{:}},
tocdynnumwidth
]{chapter}
\let\originalappendix\appendix
\renewcommand*{\appendix}{%
\originalappendix
%\renewcommand*\chapterformat{}% remove the chapter number from chapter heading
%\renewcommand*\chaptermarkformat{}% remove the chapter number from header entry
\renewcommand*{\addchaptertocentry}[2]{% remove the chapter number from ToC entry
\originaladdchaptertocentry{}{##2}%
}%
}
答案1
为此调用了 KOMA-Script 选项chapterprefix
(可以在 KOMA Script 手册的“3.16. 文档结构”部分找到)。
\documentclass[
egregdoesnotlikesansseriftitles,
headings=optiontoheadandtoc,
chapterprefix=true
]{scrreprt}
\usepackage{newtxtext}
\addtokomafont{chapter}{\LARGE}
\addtokomafont{subsection}{\normalfont \itshape}
\begin{document}
\chapter{First Chapter}
\end{document}