![页边空白处的章节和节号以及章节前缀与 scrbook 中的文本对齐](https://linux22.com/image/309486/%E9%A1%B5%E8%BE%B9%E7%A9%BA%E7%99%BD%E5%A4%84%E7%9A%84%E7%AB%A0%E8%8A%82%E5%92%8C%E8%8A%82%E5%8F%B7%E4%BB%A5%E5%8F%8A%E7%AB%A0%E8%8A%82%E5%89%8D%E7%BC%80%E4%B8%8E%20scrbook%20%E4%B8%AD%E7%9A%84%E6%96%87%E6%9C%AC%E5%AF%B9%E9%BD%90.png)
我尝试自定义章节标题,而不使用其他软件包,例如标题安全,因为我想避免与周围所有其他东西不兼容。
我几乎已经得到了我想要的东西:
\documentclass[
fontsize=12pt,
BCOR=15mm,
DIV=15,
twoside=true,
open=right,
chapterprefix = true,
headings=twolinechapter,
headings=big,
]{scrbook}
\usepackage{fontspec}
\setmainfont[Numbers = OldStyle,Ligatures = TeX,SmallCapsFeatures = {Renderer=Basic}]{Minion Pro}
\usepackage{anyfontsize}
\setkomafont{chapter}{\normalfont\Huge}
\renewcommand*{\chapterheadstartvskip}{\vspace*{5\baselineskip}}
\renewcommand*{\chapterheadendvskip}{\vspace*{2\baselineskip}}
\renewcommand*{\chapterformat}{%
{\fontsize{20}{30}\scshape\chapappifchapterprefix{\nobreakspace}}
\fontsize{120}{30}\selectfont\thechapter\autodot\enskip}
\renewcommand*{\raggedchapter}{\raggedleft}
\setkomafont{section}{\Large\rmfamily}
\usepackage{blindtext}
\begin{document}
\chapter{Hello World!}
\section{Section 1}
\blindmathpaper
\end{document}
只是缺少一个细节:
如何在页边空白处放置章节编号并将标题和前缀与文本对齐?
所以基本上我试图实现:
答案1
为章节和类似内容添加以下定义
\renewcommand*\othersectionlevelsformat[3]{%
\llap{#3\autodot\enskip}%
}
并将的定义更改\chapterformat
为
\renewcommand*{\chapterformat}{%
{\fontsize{20}{30}\scshape\chapappifchapterprefix{}}%
\fontsize{120}{30}\selectfont\rlap{\thechapter\autodot}%
}
梅威瑟:
\documentclass[
fontsize=12pt,
BCOR=15mm,
DIV=15,
twoside=true,
open=right,
chapterprefix = true,
headings=twolinechapter,
headings=big,
]{scrbook}
\usepackage{fontspec}
\setmainfont[Numbers = OldStyle,Ligatures = TeX,SmallCapsFeatures = {Renderer=Basic}]{Minion Pro}
\usepackage{anyfontsize}
\setkomafont{chapter}{\normalfont\Huge}
\renewcommand*{\chapterheadstartvskip}{\vspace*{5\baselineskip}}
\renewcommand*{\chapterheadendvskip}{\vspace*{2\baselineskip}}
\renewcommand*{\chapterformat}{%
{\fontsize{20}{30}\scshape\chapappifchapterprefix{}}%
\fontsize{120}{30}\selectfont\rlap{\thechapter\autodot}%
}
\renewcommand*{\raggedchapter}{\raggedleft}
\renewcommand*\othersectionlevelsformat[3]{%
\llap{#3\autodot\enskip}%
}
\setkomafont{section}{\Large\rmfamily}
\usepackage{blindtext}
\begin{document}
\chapter{Hello World!}
\section{Section 1}
\blindmathpaper
\end{document}
输出:
更新(KOMA-Script v3.17)
从 KOMA-Script v3.17 开始,\othersectionlevelsformat
不再像以前那样工作,因此,不要使用
\renewcommand*\othersectionlevelsformat[3]{%
\llap{#3\autodot\enskip}%
}
你必须使用
\renewcommand*{\sectionformat}{%
\llap{\thesection\autodot\enskip}%
}
而是。如果你也希望子部分有这样的行为,请使用
\renewcommand*{\subsectionformat}{%
\llap{\thesubsection\autodot\enskip}%
}
等等。