在我的 LaTeX 代码中,我使用了 KOMA-script 包的实际版本及其 documentclass scrbook。在这方面,我想知道如何将使用 titlesec 包的代码转换为应该使用更兼容 KOMA-script 的 scrlayer-scrpage 包的代码。请在下面找到相关代码。如果有人能帮助我,我将不胜感激!
\usepackage{titlesec}
%modify part-page-style
\titleformat{\part}[display]
{\huge\filcenter\bfseries}
{\Huge{\MakeUppercase{\partname} \thepart}}
{5pt}
{\titlerule[3pt] \vspace{10pt}}
[]
%modify chapter-page-style
\titleformat{\chapter}[display]
{\LARGE\filcenter\bfseries}
{\titlerule[3pt] \vspace{3pt} \titlerule[1pt] \vspace{5pt} \huge{\MakeUppercase{\chaptertitlename} \thechapter}}
{0pt}
{\titlerule[1pt] \vspace{10pt}}
[]
\titlespacing*{\chapter}{0pt}{0pt}{40pt}
答案1
这是一个需要的建议KOMA 脚本 版本 3.17(CTAN 上的当前版本)或更新版本:
\documentclass{scrbook}[2015/04/23]
\usepackage{microtype}
% modify part
\setkomafont{part}{\normalfont\bfseries\huge}
\setkomafont{partnumber}{\normalfont\bfseries\Huge}
\RedeclareSectionCommand[innerskip=10pt]{part}
\renewcommand\partformat{%
\strut\MakeUppercase{\lsstyle% Upper case sequences should be spaced
\partname~\thepart}%
\vspace{5pt}\hrule height 3pt%
}
% modify chapter
\KOMAoptions{chapterprefix}
\renewcommand\raggedchapter{\centering}
\setkomafont{chapter}{\normalfont\bfseries\LARGE}
\setkomafont{chapterprefix}{\huge}
\RedeclareSectionCommand[beforeskip=0pt,afterskip=40pt,innerskip=12pt]{chapter}
\renewcommand\chapterformat{%
\hrule height 3pt\vspace{3pt}\hrule height 1pt\vspace{5pt}%
\mbox{\strut\MakeUppercase{\lsstyle% Upper case sequences should be spaced
\chapapp\nobreakspace\thechapter}}%
\hrule height 1pt%
}
\usepackage{blindtext}% dummy text
\begin{document}
\tableofcontents
\part{Part title}
\blinddocument
\end{document}
请注意,inner skip
选项是在 KOMA-Script 版本 3.17 中引入的。因此版本 3.15 或 3.16(当前版本在 MiKTeX 和 TeX Live 2014 中)你必须使用
\renewcommand\partheadmidvskip{\vspace{10pt}}
和
\renewcommand\chapterheadmidvskip{\vspace{12pt}}
相反。这也适用于 3.17 或更新版本。
代码:
\documentclass{scrbook}[2015/01/01]
\usepackage{microtype}
% modify part
\setkomafont{part}{\normalfont\bfseries\huge}
\setkomafont{partnumber}{\normalfont\bfseries\Huge}
\renewcommand\partheadmidvskip{\vspace{10pt}}
\renewcommand\partformat{%
\strut\MakeUppercase{\lsstyle% Upper case sequences should be spaced
\partname~\thepart}%
\vspace{5pt}\hrule height 3pt%
}
% modify chapter
\KOMAoptions{chapterprefix}
\renewcommand\raggedchapter{\centering}
\setkomafont{chapter}{\normalfont\bfseries\LARGE}
\setkomafont{chapterprefix}{\huge}
\RedeclareSectionCommand[beforeskip=0pt,afterskip=40pt]{chapter}
\renewcommand\chapterheadmidvskip{\vspace{12pt}}
\renewcommand\chapterformat{%
\hrule height 3pt\vspace{3pt}\hrule height 1pt\vspace{5pt}%
\mbox{\strut\MakeUppercase{\lsstyle% Upper case sequences should be spaced
\chapapp\nobreakspace\thechapter}}%
\hrule height 1pt%
}
\usepackage{blindtext}% dummy text
\begin{document}
\tableofcontents
\part{Part title}
\blinddocument
\end{document}
\documentclass{scrbook}
\usepackage{microtype}
% modify part
\setkomafont{part}{\normalfont\bfseries\huge}
\setkomafont{partnumber}{\normalfont\bfseries\Huge}
\renewcommand\partheadmidvskip{\vspace{10pt}}
\renewcommand\partformat{%
\strut\MakeUppercase{\lsstyle% Upper case sequences should be spaced
\partname~\thepart}%
\vspace{5pt}\hrule height 3pt%
}
% modify chapter
\KOMAoptions{chapterprefix}
\renewcommand\raggedchapter{\centering}
\setkomafont{chapter}{\normalfont\bfseries\LARGE}
\setkomafont{chapterprefix}{\huge}
\RedeclareSectionCommand[beforeskip=0pt,afterskip=40pt]{chapter}
\renewcommand\chapterheadmidvskip{\vspace{12pt}}
\renewcommand\chapterformat{%
\hrule height 3pt\vspace{3pt}\hrule height 1pt\vspace{5pt}%
\mbox{\strut\MakeUppercase{\lsstyle% Upper case sequences should be spaced
\chapapp\nobreakspace\thechapter}}%
\hrule height 1pt%
}
\usepackage{blindtext}% dummy text
\begin{document}
\tableofcontents
\part{Part title}
\blinddocument
\end{document}
答案2
据我所知,KOMA-script 有一个\RedeclareSectionCommand
,它提供了与 类似的界面titlesec
。请参阅手册第 21 章。