考虑以下代码:
\documentclass[foolscap]{octavo} % to get a small image
\usepackage{lettrine,lmodern,xcolor}
\usepackage[tracking=true]{microtype}
\input GoudyIn.fd
\renewcommand{\LettrineFontHook}{\usefont{U}{GoudyIn}{xl}{n}}
\fboxsep=0pt % padding thickness
\fboxrule=0pt % border thickness
\begin{document}
\thispagestyle{empty}
\lettrine[lines=3,loversize=.30,findent=.21em,nindent=2.5pt]{\fcolorbox{black}{blue!35}{T\kern-.04em}}{his} is an example of the use of a lettrine where the letters following the lettrine appear in small caps. All is fine.
\vspace*{7pt}
\lettrine[lines=3,loversize=.30,findent=.21em,nindent=2.5pt]{\fcolorbox{black}{blue!35}{A\kern-.04em}}{} lettrine where there are no letters to be displayed in small caps. Notice the difference in the spacing of the two displays.
\vspace*{7pt}
\lettrine[lines=3,loversize=.30,findent=.21em,nindent=2.5pt]{\fcolorbox{black}{blue!35}{A\kern-.04em}}{} lettrine where there are no letters to be displayed in small caps. Notice the spacing between the lettrine itself and the word "lettrine".
\vspace*{7pt}
\lettrine[lines=3,loversize=.30,findent=.21em,nindent=2.5pt]{\fcolorbox{black}{blue!35}{A\kern-.04em}}{} lettrine where no letters are displayed in small caps. Notice again, that in the previous example, the spacing between the lettrine itself and the word "lettrine" immediately following was off. But now it's fine.
\vspace*{7pt}
\lettrine[lines=3,loversize=.30,findent=.21em,nindent=2.5pt]{\fcolorbox{black}{blue!35}{A\kern-.04em}}{} lettrine where there are no letters to be displayed in small caps. Notice again, that in the previous example, the spacing between the lettrine itself and the word "lettrine" immediately following was off. But now, in this paragraph, all again is \emph{not} fine.
\end{document}
输出结果如下:
请注意,在第一的在这五个段落中,是小写字母按照信函内容 --- 一切似乎都很好。
在里面第二段落中,字母“A”构成一个单词,因此没有小写字母接下来,与第一段相比,我们看到整个段落的间距略微增加了。
这第三段落比前两段更长,并且将单词“lettrine”向右移动了更远,但在接下来的几行中并没有出现类似的现象。
在里面第四段,事情似乎又恢复正常了。
唉,当我们在第五例如,事情似乎又回到了第三个例子中的情况。
问题:有人能指出为什么会发生这些差异以及我该如何防止这种情况发生,以便当我的字母表后面没有小写字母时,所有字母都可以像第一段一样显示出来?
答案1
答案2
如果 的第二个强制参数是\lettrine
你想使用 kern 而不是空格,并且这个 kern 应该与 相同nindent
。接下来你要忽略可能出现的空格。
字距不参与对齐,其大小是固定的。第一个单词后面的空格则参与对齐,但当然,当第二个参数(除首字母外的第一个单词)时,您不希望它参与对齐。
现在您清楚地看到了需要一个宏来完成所有工作。
\documentclass[foolscap]{octavo} % to get a small image
\usepackage{lettrine,lmodern,xcolor}
\usepackage[tracking=true]{microtype}
\input{GoudyIn.fd}
\renewcommand{\LettrineFontHook}{\usefont{U}{GoudyIn}{xl}{n}}
\newcommand{\LTR}[2]{%
\lettrine[
lines=3,
loversize=0.3,
findent=0.21em,
nindent=2.5pt,
]{%
\setlength{\fboxsep}{0pt}%
\colorbox{blue!35}{#1\kern-0.04em}%
}{#2}%
% now we fix the problem with an empty argument
\if\relax\detokenize{#2}\relax
\kern2.5pt\ignorespaces
\fi
}
\begin{document}
\LTR{T}{his} is an example of the use of a lettrine where the letters
following the lettrine appear in small caps. All is fine.
\vspace*{7pt}
\LTR{A}{} lettrine where there are no letters to be displayed in small
caps. Notice the difference in the spacing of the two displays.
\vspace*{7pt}
\LTR{A}{} lettrine where there are no letters to be displayed in small caps.
Notice the spacing between the lettrine itself and the word ``lettrine''.
\vspace*{7pt}
\LTR{A}{} lettrine where no letters are displayed in small caps.
Notice again, that in the previous example, the spacing between
the lettrine itself and the word "lettrine" immediately following
was off. But now it's fine.
\vspace*{7pt}
\LTR{A}{} lettrine where there are no letters to be displayed in small caps.
Notice again, that in the previous example, the spacing between the lettrine
itself and the word "lettrine" immediately following was off. But now,
in this paragraph, all again is \emph{not} fine.
\end{document}
答案3
由于您的问题今天再次出现,我希望我可以及时添加一些评论。
首先,该软件包lettrine
现在接受(2022/09 发布的 v. 2.30 和昨天发布的 2.40)与命令相同的选项\lettrine
,因此您的 MWE 可以稍微简化,但这不是重点。
如果您想要与第一个示例相同的布局,您可以编写代码,\lettrine{...}{lettrine}
而不是使用空的第二个参数,重新定义\LettrineTextFont
以摆脱小型大写字母,然后使用选项findent
和nindent
:
\documentclass[foolscap]{octavo} % to get a small image
\usepackage{lmodern,xcolor}
\usepackage[lines=3, loversize=.30, findent=.21em,
nindent=2.5pt]{lettrine}
\usepackage[tracking=true]{microtype}
\input{GoudyIn.fd}
\renewcommand{\LettrineFontHook}{\usefont{U}{GoudyIn}{xl}{n}}
\fboxsep=0pt % padding thickness
\fboxrule=0pt % border thickness
\begin{document}
\thispagestyle{empty}
\lettrine{\fcolorbox{black}{blue!35}{T\kern-.04em}}{his}
is an example of the use of a lettrine where the letters
following the lettrine appear in small caps. All is fine.
\vspace*{7pt}
\renewcommand{\LettrineTextFont}{} % No small caps
\lettrine{\fcolorbox{black}{blue!35}{A\kern-.04em}}{lettrine}
where there are no letters to be displayed in small caps.
Notice the difference in the spacing of the two displays.
\vspace*{7pt}
\lettrine{\fcolorbox{black}{blue!35}{A\kern-.04em}}
{lettrine} where there are no letters to be displayed in
small caps. Notice the spacing between the lettrine itself
and the word "lettrine".
\vspace*{7pt}
\lettrine[findent=0.5em,nindent=0pt]{\fcolorbox{black}{blue!35}{A\kern-.04em}}{lettrine}
where no letters are displayed in small caps.
Notice again, that in the previous example, the spacing
between the lettrine itself and the word "lettrine"
immediately following was off. But now it's fine.
\end{document}
如果您希望所有行都左对齐,最后一段会显示不同的布局。当第二个参数和第一个参数属于同一个单词(即 This)时,让它们靠近是有意义的,否则可能就不合理了(只有 A)。
findent
修复了第一个和第二个强制参数之间的距离\lettrine
,nindent
修复了额外的跳过下一行。如果将第二个参数设为空,则会失去这些调整选项。