我有一个手动列表,其中列出了一些物品,为了方便视觉查看,有时会用标尺(或者我自己的自定义标尺)将它们分开。
有时,页面的顶部或底部会结束这条规则,这使得它变得毫无用处。
如果它位于页面的顶部或底部,有没有办法阻止它被添加?
问题的 MWE:
\documentclass{book}
\usepackage{tikz}
\begin{document}
\newcommand\rulesep{%
\par % make sure we end a paragraph
\vskip5pt % space above the rule
\leaders\vrule width \textwidth\vskip0.4pt % rule thickness is 0.4pt
\nointerlineskip % disable interline glue here
\vskip5pt % space below the rule
}
\def\dotikzcircle#1{\begin{tikzpicture}\draw(0,0)circle(#1);\end{tikzpicture}}
\rulesep
\noindent This is a test\noindent
\rulesep
\noindent End of test
\rulesep
\dotikzcircle3
\rulesep
\begin{center}\dotikzcircle3\end{center}
\rulesep
\begin{center}\dotikzcircle3\end{center}
\rulesep
\dotikzcircle1
\rulesep
\dotikzcircle2
\rulesep
\dotikzcircle3
\rulesep
\dotikzcircle4
\rulesep
\dotikzcircle5
\rulesep
\end{document}
答案1
将你的规则变成可丢弃的项目:
\newcommand\disappearingrule{%
\par % make sure we end a paragraph
\vskip5pt % space above the rule
\leaders\vrule width \textwidth\vskip0.4pt % rule thickness is 0.4pt
\nointerlineskip % disable interline glue here
\vskip5pt % space below the rule
}
由于 TeX 的分页规则,垂直前导符和后面的 不能换行\medskip
。如果在 处换页\bigskip
,后面的粘连(或前导符)将会消失。
答案2
以下是 egreg 解决方案的扩展演示。
\documentclass{book}
\usepackage{tikz}
\usepackage{pgfpages}
\pgfpagesuselayout{8 on 1}[a4paper,landscape,border shrink=2.5mm]
\newcount\absdiscnt
\newcommand\rulesep{%
\par\vskip5pt
\leaders\vrule width \textwidth\vskip0.4pt
\nointerlineskip\vskip5pt
}
%\raggedbottom
\begin{document}
\absdiscnt0
\loop
\advance\absdiscnt by 1\relax
\ifnum\absdiscnt<121\relax
\rulesep
\centerline{Eh, this line is by Abstract Dissonance!}\endgraf
\rulesep
\edef\tempa{\the\dimexpr.25\baselineskip}
\edef\tempb{\the\dimexpr\textwidth-2\tempa-\parindent}
\begin{tikzpicture}
\draw[fill=blue](0,0)circle(\tempa);
\draw[fill=red](\tempb,0)circle(\tempa);
\end{tikzpicture}
\repeat
\end{document}