pdfLaTeX中的首字下沉

15

我希望能找到一种在pdfLaTeX中生成首字下沉效果(大号的首字母)的方法。我知道有一个名为dropping的包可以在使用latex+dvips时很好地实现该效果。但是,当与pdflatex一起使用时,结果看起来很丑陋。

我的源文件如下:

\documentclass[12pt]{article}

% for pdflatex file.tex # dropping is ugly
% \usepackage[pdftex]{graphicx}
% \usepackage[pdftex]{dropping}

% for latex file.tex ; dvips -T 12cm,8cm file.dvi # dropping is OK
\usepackage[dvips]{graphicx}
\usepackage{dropping}

\usepackage[papersize={12cm,8cm},
    left=0.5cm,right=0.5cm,
    top=0.5cm,bottom=0.5cm]{geometry}

\begin{document}
\dropping[-3pt]{3}{W}ith a drop cap, the initial sits within the margins and
runs several lines deep into the paragraph, pushing some normal-sized text off
these lines. This keeps the left and top margins of the paragraph flush.
In~modern browsers, this can be done with a combination of HTML and CSS
by~using the float: left; setting.
\end{document}

当我将其编译为

latex drop.tex && dvips -T 12cm,8cm drop.dvi

结果是OK:
当我取消注释 [pdftex] 行并编译它时:

dropping-latex-dvips

pdflatex drop.tex

结果如下:

结果是:

dropping-pdflatex

有人能建议一种更好的方法来使用 pdflatex 生成drop caps吗?

4个回答

22
非常感谢您的迅速回复!事实上,Hop和Charlie Martin的两条评论都很有用。 lettrine.sty是一个非常好的软件包,它可以工作,但前提是使用可缩放字体。
因此,解决方案是强制使用Type 1 CM字体而不是默认的CM字体,并使用lettrine.stylettrine.sty文档建议使用\usepackage{type1cm}
这个方法可以解决问题:
\documentclass[12pt]{article}

% works with pdfLaTeX
\usepackage{type1cm} % scalable fonts
\usepackage{lettrine}

\usepackage[papersize={12cm,4cm},
    left=0.5cm,right=0.5cm,
    top=0.5cm,bottom=0.5cm]{geometry}

\begin{document}
\lettrine[lines=3,slope=-4pt,nindent=-4pt]{W}{ith} a drop cap, the initial sits
within the margins and runs several lines deep into the paragraph, pushing some
normal-sized text off these lines. This keeps the left and top margins of the
paragraph flush.  In~modern browsers, this can be done with a combination of
HTML and CSS by~using the float: left; setting.
\end{document}

以下是结果:

pdflatex-type1cm-lettrine

谢谢!

附注:dropping即使配合type1cm也无法正常工作。

更新:此示例还适用于xelatex


6
尝试使用另一种具有缩放功能的字体;这似乎是PDF未找到足够大的字体来替代大写字母W。另一个选项是使用dvi-to-PDF转换。

4

我怀疑这样做不会有帮助。W下降得很好,基线也下移了,但它的字符大小不够大。 - Charlie Martin
删除在使用pdflatex时不太好用。如果lettrine对他无效,我会撤回这个答案。 - user3850

3
jetxee所提到的,为了得到正确大小的首字母,使用可伸缩字体是必要的。如果您更改默认字体,这将自动发生,无需进行任何操作。
由于历史原因,默认的CM字体被加载以“捕捉”特定大小,而不是可以在任何缩放大小下加载。这是来自使用原始Metafont源代码的时代,当不同的字体大小改变了字形的实际形状(对于好奇的人来说,可以Google“光学尺寸”)。
修复CM字体此问题的规范解决方案是加载fix-cm包。 type1cm包是一个旧包,基本上做相同的事情。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接