我的书里有几封信,有些很短,用 scrbook、reledmac 排版\raggedbottom
。\chapter
用于年并\section
用于个别字母。
我需要这个leavevmode
命令,因为当字母数量过多时,它会重置某些内容。但这会在字母标题后引入不必要的分页符。为什么会这样?我该如何调整部分命令以达到所需的效果?
梅威瑟:
\documentclass{scrbook}
\usepackage{reledmac}
\usepackage[english]{babel}
\usepackage{blindtext}
\raggedbottom
\begin{document}
\chapter{Letters from 1900}
\leavevmode\pagebreak[3]\section{Letter 1}\nopagebreak[3]
\beginnumbering
\pstart
\blindtext
\pend
\pstart
\blindtext
\pend
\endnumbering
\leavevmode\pagebreak[3]\section{Letter 2}\nopagebreak[3]
\beginnumbering
\pstart
\blindtext
\pend
\endnumbering
\leavevmode\pagebreak[3]\section{Letter 3}\nopagebreak[3]
\beginnumbering
\pstart
\blindtext
\pend
\endnumbering
\end{document}
答案1
据我所知,\leavevmode
由于节标题前有一个额外的空白段落,因此会产生额外的垂直空间。这不是问题,因为它不允许在以下内容后分页\section
。
问题出\pagenumbering
在 之后\section
。您应该\nopagebreak
在 之后添加/移动\pagenumbering
:
\documentclass{scrbook}
\usepackage{reledmac}
\usepackage[english]{babel}
\usepackage{blindtext}
\raggedbottom
\begin{document}
\chapter{Letters from 1900}
\leavevmode\pagebreak[3]\section{Letter 1}
\beginnumbering\nopagebreak
\pstart
\blindtext
\pend
\pstart
\blindtext
\pend
\endnumbering
\leavevmode\pagebreak[3]\section{Letter 2}
\beginnumbering\nopagebreak
\pstart
\blindtext
\pend
\endnumbering
\leavevmode\pagebreak[3]\section{Letter 3}
\beginnumbering\nopagebreak
\pstart
\blindtext
\pend
\endnumbering
\end{document}
但是,如果您确实想要在部分之前有额外的垂直空间,为什么要使用\leavevmode
它来获取它而不是使用它\RedeclareSectionCommand
来增加beforeskip
值:
\documentclass{scrbook}
\usepackage{reledmac}
\usepackage[english]{babel}
\usepackage{blindtext}
\raggedbottom
\RedeclareSectionCommand[beforeskip=-10ex plus -1ex minus -.2ex]{section}
\begin{document}
\chapter{Letters from 1900}
\section{Letter 1}
\beginnumbering\nopagebreak
\pstart
\blindtext
\pend
\pstart
\blindtext
\pend
\endnumbering
\section{Letter 2}
\beginnumbering\nopagebreak
\pstart
\blindtext
\pend
\endnumbering
\section{Letter 3}
\beginnumbering\nopagebreak
\pstart
\blindtext
\pend
\endnumbering
\end{document}
如果\beginnumbering
都要避免分页符,则可以修补命令:
\documentclass{scrbook}
\usepackage{reledmac}
\usepackage[english]{babel}
\usepackage{blindtext}
\raggedbottom
\RedeclareSectionCommand[beforeskip=-10ex plus -1ex minus -.2ex]{section}
\usepackage{xpatch}
\xapptocmd{\beginnumbering}{\nopagebreak}{}{}
\begin{document}
\chapter{Letters from 1900}
\section{Letter 1}
\beginnumbering
\pstart
\blindtext
\pend
\pstart
\blindtext
\pend
\endnumbering
\section{Letter 2}
\beginnumbering
\pstart
\blindtext
\pend
\endnumbering
\section{Letter 3}
\beginnumbering
\pstart
\blindtext
\pend
\endnumbering
\end{document}
或者你可以定义一个新命令:
\documentclass{scrbook}
\usepackage{reledmac}
\usepackage[english]{babel}
\usepackage{blindtext}
\raggedbottom
\RedeclareSectionCommand[beforeskip=-10ex plus -1ex minus -.2ex]{section}
\newcommand\beginnumberingnobreak{\beginnumbering\nopagebreak}
\begin{document}
\chapter{Letters from 1900}
\section{Letter 1}
\beginnumberingnobreak
\pstart
\blindtext
\pend
\pstart
\blindtext
\pend
\endnumbering
\section{Letter 2}
\beginnumberingnobreak
\pstart
\blindtext
\pend
\endnumbering
\section{Letter 3}
\beginnumberingnobreak
\pstart
\blindtext
\pend
\endnumbering
\end{document}
您还可以尝试检测是否\beginnumbering
遵循\section
另一个命令来防止分页:
\documentclass{scrbook}
\usepackage{reledmac}
\usepackage[english]{babel}
\usepackage{blindtext}
\raggedbottom
\RedeclareSectionCommand[beforeskip=-10ex plus -1ex minus -.2ex]{section}
\usepackage{xpatch}
\makeatletter
\xpretocmd{\beginnumbering}{\if@nobreak\let\afterbeginnumbering\nopagebreak\else\let\afterbeginnumbering\relax\fi}{}{}
\xapptocmd{\beginnumbering}{\afterbeginnumbering}{}{}
\makeatother
\begin{document}
\chapter{Letters from 1900}
\section{Letter 1}
\beginnumbering
\pstart
\blindtext
\pend
\pstart
\blindtext
\pend
\endnumbering
\section{Letter 2}
\beginnumbering
\pstart
\blindtext
\pend
\endnumbering
\section{Letter 3}
\beginnumbering
\pstart
\blindtext
\pend
\endnumbering
\end{document}
答案2
如果您从示例文档中删除\leavevmode
和\nopagebreak
,则标题不在页面末尾,因为虚假的白色段落已经\leavevmode
消失,但如果您添加更多行(如下所示),则页面会在标题后中断。这是由于和,\beginnumbering
如果您取消注释重新定义,则可防止在该点处出现分页,并且标题中会保留一行额外的行。
\documentclass{scrbook}
\usepackage{reledmac}
\usepackage[english]{babel}
\usepackage{blindtext}
\raggedbottom
\let\oldbeginnumbering\beginnumbering
%\def\beginnumbering{\oldbeginnumbering\par\nopagebreak}
\begin{document}
\chapter{Letters from 1900}
\section{Letter 1}
\beginnumbering
\pstart
\blindtext
\pend
\pstart
\blindtext
\pend
\endnumbering
\section{Letter 2}
\beginnumbering
\pstart
\blindtext
a\\ba\\c
\pend
\endnumbering
\section{Letter 3}
\beginnumbering
\pstart
\blindtext
\pend
\endnumbering
\end{document}