我正在尝试创建一个分节符,当它出现在页面中间时会显示一个分隔符,但如果它位于页面的顶部或底部(没有任何内容可分隔)则不显示任何内容。
我能找到最接近的方法是回忆录类的 \pfbreak,但是它的作用与我想要的相反(在顶部或底部显示内容,但不在页面中间)。
我希望从文件中提取代码这里(从第 10858 行开始, \def\pfbreakOutput 似乎是感兴趣的部分)但获得我想要的行为似乎涉及重新设计输出例程,这远远超出了我的理解范围。
有人可以建议一种改变这种方法以获得所描述的 \inversepfbreak 命令吗,或者建议一种替代方法来解决这个问题?
另一种可能性是设置 \label{end-of-section} 和 \label{start-of-next-section};我认为可以对它们的 \pageref 进行字符串比较,并据此显示/隐藏内容。不过我认为这不是一个好的解决方案,因为在处理之前您无法确定页面,之后如果我开始添加/删除页面分隔符,分页符无论如何都会改变。
谢谢!
克里斯托弗
答案1
领导者可以用来制定像空间一样被丢弃的规则:
\documentclass{article}
\addtolength\textheight{-24\baselineskip}
\let\xsection\section
\renewcommand\section{%
\par
\bigskip\leaders\hrule\vskip1pt
\nobreak\smallskip
\csname @nobreaktrue\endcsname
\xsection}
\begin{document}
\section{aaa}
One two three\par Four five six seven eight nine ten.
One two three\par Four five six seven eight nine ten.
One two three. Four five six seven eight nine ten.
One two three\par Four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three\par Four five six seven eight nine ten.
One two three\par Four five six seven eight nine ten.
\section{aaa}
Red yellow blue. One two three\par Four five six seven eight nine ten.
One two three\par Four five six seven eight nine ten.
One two three. Four five six seven eight nine ten.
One two three\par Four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three\par Four five six seven eight nine ten.
One two three\par Four five six seven eight nine ten.
\section{aaa}
zzzz. One two three\par Four five six seven eight nine ten.
One two three\par Four five six seven eight nine ten.
One two three. Four five six seven eight nine ten.
One two three\par Four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three\par Four five six seven eight nine ten.
One two three\par Four five six seven eight nine ten.
\end{document}