在许多书籍(主要是小说)中,一些段落之间通常会有一个空行,以表示叙述中的某种“停顿”。如果其中一个空行出现在页面顶部或底部,则会用“* * *”替换,以便读者知道有一个停顿。
当我在 LaTeX 文档中放置这些空白行时,我使用如下波浪符号:
stuff blah blah paragraph ends here
~
new paragraph, more stuff...
在大多数情况下,这种方法都行得通,但如果星号出现在页面顶部或底部,它当然不会帮我添加星号。有没有办法自动完成这一操作?
答案1
你可以用可丢弃的物品隐藏装饰物:
\documentclass{minimal}
\usepackage{xcolor}
\usepackage{xparse}
\makeatletter
\ExplSyntaxOn
\box_new:N \g_hide_box
\AtBeginDocument {
\vbox_set:Nn \g_hide_box {
\color@begingroup
\color { white }
\hrule width \linewidth height \baselineskip depth \c_zero_dim
\color@endgroup
}
}
\NewDocumentCommand \ornament { } {
\par
\nopagebreak
\centerline { $ * \quad * \quad * $ }
\vskip -0.8\baselineskip
\cleaders \box_use:N \g_hide_box \vskip 1.1\baselineskip
\par
}
\ExplSyntaxOff
\makeatother
\begin{document}
\ExplSyntaxOn
\prg_replicate:nn { 50 } { aaa \ornament }
\ExplSyntaxOff
\end{document}
答案2
文档memoir
类有一个命令\plainfancybreak
(或\pfbreak
),它提供只有与分页符一致时才带有星号的分隔符。
答案3
有没有办法可以自动完成? 我的理解是,目前没有可以做到这一点的软件包。但是,这里有一个半自动解决方案!该宏使用一种特殊字体(webomints),可在http://www.ctan.org/tex-archive/fonts/webomints/
\documentclass[a4paper]{article}
\newcommand{\wb}[2]{\fontsize{#1}{#2}\usefont{U}{webo}{xl}{n}}
\newcommand{\wbc}[3]{\vspace*{#1}\begin{center}
\wb{#2}{#2}#3\end{center}\vspace*{#1}}
\def\thoughtBreak{ \wbc{2ex}{6}{IJLKIJLKIJLKIJLKIJ}}
\begin{document}
\textsc{The King and Queen of Hearts} were seated on their throne
when they arrived, with a great crowd assembled about them
--- all sorts of little birds and beasts, as well as the
whole pack of cards: the Knave was standing before them,
in chains, with a soldier on each side to guard him; and
near the King was the White Rabbit, with a trumpet in one
hand, and a scroll of parchment in the other. In the very
middle of the court was a table, with a large dish of
tarts upon it: they looked so good, that it made Alice
quite hungry to look at them --- ``I wish they'd get the
trial done,'' she thought, ``and hand round the
refreshments!''. But there seemed to be no chance of this,
so she began looking at everything about her to pass away
the time. \thoughtBreak
Alice had never been in a court of justice before, but she
had read about them in books, and she was quite pleased to
find that she knew the name of nearly everything there.
``That's the judge,'' she said to herself, ``because of his
great wig.''.\thoughtBreak
The judge, by the way, was the King, and as he wore his
crown over the wig, (look at the frontispiece if you want
to see how he did it,) he did not look at all comfortable,
and it was certainly not becoming. \thoughtBreak
\end{document}
您所指的通常称为ornaments
或thought breakers
。我更喜欢后者,因为段落是unit of thought
而不是文本单位!我定义了一个名为 的宏,\thoughtBreak
您可以在段落末尾添加它。它不能解决 的问题orphan ornaments
,也就是说,您仍然需要依赖 TeX 的惩罚系统来确保装饰物不会移到新页面的第一行。
实现自动化的可能解决方案是使用软件包使用的方法来lineno
对段落的行进行编号,并\thoughtBreak
在段落末尾添加。另一个可能的解决方案是重新定义\par
通常结束段落的命令。后者可能会变得混乱,因为par
它也用于各种其他地方,例如标题、列表...
最后,你可以使用output
例程,这是正确的方法 - 因为你也可以提前检查章节等(如果后面跟着章节,你不会希望装饰物结束段落)。这可能会让调试和编程变得非常混乱,而且 LaTeX 输出例程几乎不可能被破解!
答案4
(编辑:我刚刚注意到完全地误解了这个问题——我仍然会在这里留下我的答案,希望有人会觉得它有用。)
我不会把这样的装饰品放在每一个段落 — 段落应该非常频繁地使用(恕我直言,每隔几句话就使用一次),并且使用经常会分散注意力的装饰。
相反,我会定义一个命令,明确地将这种装饰插入到任何有意义的地方。或者,您可以重新定义该\subsubsection
命令(或另一个分段命令)来插入这种装饰。
对于我的论文文档类,我定义了这样一个命令,它允许以下用法:
This is some text.
Some more text.
New paragraph with more text (indented by \verb/\parindent/ = \the\parindent).
\hr
This is after a big skip (notice: no indentation)
\hr*
This is after an ornamented big skip (still no indentation).
输出结果如下:
我将其称为\hr
(代表“水平规则”),因为这是 HTML 中此元素的名称(并且在 HTML 中,它默认呈现为实际规则)。
该宏有两个版本:\hr
,仅插入空格,以及\hr*
,另外插入装饰物。
我的\hr
宏可以通过另外两个宏进行配置:
\hrskip
(默认值\baselineskip
:)是段落之间的空间大小,以及\hrornament
指定使用哪种装饰物。
\hr
定义如下:
\newlength\hrskip
\setlength{\hrskip}{\baselineskip}
\newcommand*\hrornament{\ding{167}}
\newcommand*\hr{\hr@starornot}
\WithSuffix{\newcommand*}\hr*{\hr@starornot[*]}
\newcommand*\hr@starornot[1][]
{\begingroup%
\par\vspace{0.5\hrskip}%
\ifx#1*
\noindent\centering \hrornament%
\else
\fi%
\vspace{0.5\hrskip}%
\par%
\endgroup\@afterindentfalse\@afterheading}
(该\WithSuffix
命令需要suffix
包。默认装饰物需要pifont
包,但您基本上可以使用任何其他装饰物来代替。)