使用 Lettrine 处理短段落

使用 Lettrine 处理短段落

我正在尝试使用该软件包创建首字下沉lettrine,但当第一段太短时,我遇到了麻烦。看来该软件包只会缩进出现的段落,而后续段落的所有行均不受影响。

以下是 MWE:

\documentclass{book}
\usepackage{lmodern}
\usepackage{lettrine}

\begin{document}
\lettrine[lines=3]{T}{his} is a short paragraph.

This is a longer one, which fills all the lines taken up by the large letter, but unfortunately is not properly indented to accommodate that letter.
\end{document}

这会产生以下不良结果:

第二段的排版位置与通常位置完全相同,与大字母重叠。

一种解决方案是删除段落分隔符,而使用\\ \hspace*{\parindent}。有没有更优雅、更语义化的解决方案?

答案1

在此处输入图片描述

放在\zz下一段之前,如果需要的话它会延长切口。

\documentclass{book}
\usepackage{lmodern}

\newcount\zzc
\makeatletter
\def\zz{%
\ifnum\prevgraf<\c@L@lines
\zzc\z@
\loop
\ifnum\zzc<\prevgraf
\advance\zzc\@ne
\afterassignment\zzda\count@\L@parshape\relax
\repeat
\parshape\L@parshape
\fi}
\def\zzda{\afterassignment\zzdb\dimen@}
\def\zzdb{\afterassignment\zzdef\dimen@}
\def\zzdef#1\relax{\edef\L@parshape{\the\numexpr\count@-1\relax\space #1}}
\makeatother
\usepackage{lettrine}

\begin{document}




\lettrine[lines=3]{T}{his} is a short paragraph.

\zz
This is a longer one, which fills all the lines taken up by the large letter, but unfortunately is not properly indented to accommodate that letter.



\lettrine[lines=3]{T}{his} is not a short paragraph.
This is is not a short paragraph. This is is not a short paragraph.
This is is not a short paragraph. This is is not a short paragraph.
This is is not a short paragraph. This is is not a short paragraph.

\zz
This is a longer one, which fills all the lines taken up by the large letter, but unfortunately is not properly indented to accommodate that letter.
\end{document}

答案2

我曾经需要构建多个复杂的 parshape,每个 parshape 都必须跨越多个段落。我不想为每个段落定义一个 parshape,因为那样会花费更多工作量。

我已经不记得这个命令是从哪里来的了,我也不为此声称自己是功劳,但你实际上可以\par通过执行以下操作来“伪造”一个命令:

\def\Fpar{\hfil\vadjust{\vskip\parskip}\break\indent}

由于 lettrine 似乎\parshape在内部使用,因此该解决方案也适合您的要求。

梅威瑟:

\documentclass{book}
\usepackage{lmodern}
\usepackage{lettrine}
\def\Fpar{\hfil\vadjust{\vskip\parskip}\break\indent}
\begin{document}
\lettrine[lines=3]{T}{his} is a short paragraph.\Fpar
This is a longer one, which fills all the lines taken up by the large letter, but unfortunately is not properly indented to accommodate that letter.
\end{document}

输出:

在此处输入图片描述

这种方法之所以有效,似乎是因为,虽然\Fpar会产生与 a 相同的文档输出\par,但它不会被识别为\parshape段落的结尾,因此该\lettrine命令有更多的文本可供处理。

相关内容