如何使用 Lettrine 写短段落

如何使用 Lettrine 写短段落

我尝试使用 lettrine,一切都很顺利,直到出现一个短段落。文本开始与第一个字符重叠。

最小工作示例:

\documentclass{book}

\usepackage{lettrine}

\begin{document}
\lettrine[lines=3]{T}{his} are a few words.

Now some more words overlapping the ``T''. This paragraph must be long enough so the problem appears.

Now some more words overlapping the ``T''. This paragraph must be long enough so the problem appears.

Now some more words overlapping the ``T''. This paragraph must be long enough so the problem appears.
\end{document}

所以我找到了这个解决方案,但不起作用

采用上述解决方案的最小(非)工作示例:

\documentclass{book}

\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=2]{T}{his} are a few words.

\zz
Now some more words overlapping the ``T''. This paragraph must be long enough so the problem appears.

\zz
Now some more words overlapping the ``T''. This paragraph must be long enough so the problem appears.

\zz
Now some more words overlapping the ``T''. This paragraph must be long enough so the problem appears.
\end{document}

! 缺失数字,视为零。\relax\zz

有人能帮我解决这个问题吗?

答案1

以 \zz 开头的命令始终有效:-)

在此处输入图片描述

但只需在以下段落中使用它

\documentclass{book}

\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=2]{T}{his} are a few words.

\zz
Now some more words overlapping the ``T''. This paragraph must be long enough so the problem appears.

%\zz
Now some more words overlapping the ``T''. This paragraph must be long enough so the problem appears.

%\zz
Now some more words overlapping the ``T''. This paragraph must be long enough so the problem appears.
\end{document}

答案2

欢迎来到 TeX.SE!好吧,我想说,一般来说,\lettrine段落越长,使用效果越好,这样看起来就更好了……

对于你的情况,我更倾向于你链接问题中第二个答案中给出的其他解决方案。请参阅以下 mwe

\documentclass{book}

\usepackage{lettrine}

\def\Fpar{\hfil\vadjust{\vskip\parskip}\break\indent} % <===============
\def\Fparn{\hfil\vadjust{\vskip\parskip}\break\noindent} % <============


\begin{document}
\lettrine[lines=2]{T}{his} are a few words.\Fparn % <=================== 1
Now some more words overlapping the ``T''. 
This paragraph must be long enough so the problem appears.
Now some more words overlapping the ``T''. 
This paragraph must be long enough so the problem appears.

Now some more words overlapping the ``T''. 
This paragraph must be long enough so the problem appears.

Now some more words overlapping the ``T''. 
This paragraph must be long enough so the problem appears.

\lettrine[lines=2]{T}{his} are a few words. % <========================= 2
Now some more words overlapping the ``T''. 
This paragraph must be long enough so the problem appears.
Now some more words overlapping the ``T''. 
This paragraph must be long enough so the problem appears.

\lettrine[lines=2]{T}{his} is a short paragraph.\Fpar % <=============== 3
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.

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}

并查看以下结果 pdf:

带有标记的 PDF 结果

请参见图片中的红色 1:我在这里\Fparn没有为新段落使用缩进。看起来有一个小缩进,但请按照红线 4 标记带有红色箭头 2 的标记。在那里,您会在较长的段落中看到相同的行为。带有红色箭头 3 的段落显示了使用 lettrine 的第二段的缩进。这对我来说看起来不太好看...

您可以看到新段落的标准缩进以第 5 行标记。

相关内容