![设置章节标题后的首行相对于顶部边距,而不是相对于章节结尾标题](https://linux22.com/image/296918/%E8%AE%BE%E7%BD%AE%E7%AB%A0%E8%8A%82%E6%A0%87%E9%A2%98%E5%90%8E%E7%9A%84%E9%A6%96%E8%A1%8C%E7%9B%B8%E5%AF%B9%E4%BA%8E%E9%A1%B6%E9%83%A8%E8%BE%B9%E8%B7%9D%EF%BC%8C%E8%80%8C%E4%B8%8D%E6%98%AF%E7%9B%B8%E5%AF%B9%E4%BA%8E%E7%AB%A0%E8%8A%82%E7%BB%93%E5%B0%BE%E6%A0%87%E9%A2%98.png)
我想将每一章的初始文本行设置为相对于页面上边距从页面上的相同位置开始,而不是相对于章节标题的最后一行。
我只是想不出如何做到这一点,如果能提供任何想法我将不胜感激。
这是一个最小的工作示例:
\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}