我想将每一章的初始文本行设置为相对于页面上边距从页面上的相同位置开始,而不是相对于章节标题的最后一行。
我只是想不出如何做到这一点,如果能提供任何想法我将不胜感激。
这是一个最小的工作示例:
\documentclass{scrbook}
\usepackage[papersize={130mm,210mm},top=13mm,showframe]{geometry}
\usepackage[]{titlesec}
\titleformat{\chapter}[hang]{\MakeUppercase}{}{0mm}{}[]
\titlespacing{\chapter}{0pt}{-1\baselineskip}{3\baselineskip}
\begin{document}
\chapter{Short chapter title}
This initial line of the chapter’s text is 3 lines below the end of the title,
and 4 lines below the top margin.
\chapter{Long chapter title that keeps going on so long that it ends up on two lines}
This initial line of the chapter’s text is also 3 lines below the end of the title,
but \textit{I want it to be 2 lines below since the chapter title, being longer,
has moved the text down, too}.
It should start at the same distance from the top margin as the first line of text
in chapters with single-line titles.
\end{document}
答案1
一般情况下,你不应该使用titlesec
KOMA-script。如果你有需要,这里有一种方法。我们可以使用\parbox
或来括住章节标题并固定/minipage
的高度。我使用了选项,并使用了\parbox
minipage
explicit
titlesec
\parbox[t][2\baselineskip][t]{\textwidth} {\MakeUppercase{#1}}
这里盒子的高度是2\baselineskip
。
代码:
\documentclass{scrbook}
\usepackage[papersize={130mm,210mm},top=13mm,showframe]{geometry} %% better to use typerea by koma
\usepackage[explicit]{titlesec}
\titleformat{\chapter}[display]
{}
{}{0mm}{\parbox[t][2\baselineskip][t]{\textwidth} {\MakeUppercase{#1}}}[]
\titlespacing{\chapter}{0pt}{-2\baselineskip}{2\baselineskip }
\begin{document}
\let\cleardoublepage\clearpage %%% Just for demo, remove
\chapter{Short chapter title}
This initial line of the chapter’s text is 3 lines below the end of the title,
and 4 lines below the top margin.
\chapter{Long chapter title that keeps going on so long that it ends up on two lines}
This initial line of the chapter’s text is also 3 lines below the end of the title,
but \textit{I want it to be 2 lines below since the chapter title, being longer,
has moved the text down, too}.
It should start at the same distance from the top margin as the first line of text
in chapters with single-line titles.
\end{document}