pdfLaTeX 中的首字下沉

发布于 2024-07-11 10:16:03 字数 1488 浏览 9 评论 0原文

我想找到一种在 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

结果正常:

dropping-latex-dvips

当我取消注释 [pdftex] 行并编译它时,

pdflatex drop.tex

结果是:

dropping-pdflatex< /a>

谁能建议一种更好的方法来使用 pdflatex 生成首字下沉?

I want to find a way to produce drop caps (large initial letters several lines high) in pdfLaTeX. I know that there is a dropping package which works well when used with latex + dvips. However, when used with pdflatex the result looks ugly.

My source file is:

\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}

When I compile it as

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

the result is OK:

dropping-latex-dvips

When I uncomment [pdftex] lines and compile it as

pdflatex drop.tex

the results is:

dropping-pdflatex

Can anyone suggest a better way to produce drop caps with pdflatex?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

梦行七里 2024-07-18 10:16:03

非常感谢您的快速回复! 事实上,霍普和查理·马丁的评论都很有用。 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

谢谢!

附言。 即使使用 type1cmdropping 也无法正常工作。

UPD。此示例也适用于xelatex

Thank you very much for quick responces! Actually, both comments by hop and Charlie Martin were useful. lettrine.sty is a fantastic package, and it works if scaleable fonts are used.

So, the solution was to force Type 1 CM fonts instead of default CM and use lettrine.sty. lettrine.sty documentation suggests to \usepackage{type1cm}.

This works:

\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}

And this is the result:

pdflatex-type1cm-lettrine

Thank you!

PS. dropping does not work correctly even with type1cm.

UPD. This example also works with xelatex.

听风念你 2024-07-18 10:16:03

尝试另一种字体,一种可以缩放的字体; 看起来 PDF 没有为 cap-W 找到足够大的字体,正在替换。 另一种选择是使用 dvi 到 PDF 的转换。

Try another font, one with scaling; this looks like the PDF isn't finding a big enough font for the cap-W and is substituting. The other option is to use a dvi-to-PDF translation.

累赘 2024-07-18 10:16:03

正如 jetxee 提到的,有必要使用可缩放字体才能准确获得初始尺寸正确。 如果您更改默认字体,则无需执行任何操作即可发生这种情况。

由于历史原因,默认 CM 字体被加载为“对齐”到特定尺寸,而不是能够以任何缩放尺寸加载。 这是从使用原始 Metafont 源开始的,当时不同的字体大小改变了字形的实际形状(好奇的可以谷歌光学尺寸)。

解决 CM 字体问题的规范解决方案是加载 fix-cm 包。 type1cm 包是一个较旧的包,基本上做同样的事情。

As jetxee mentioned, it is necessary to use a scalable font in order to get exactly the right size for the initial. If you change the font from the default, this will occur without you having to do anything.

For historical reasons, the default CM fonts are loaded to "snap" to specific sizes, rather than being load-able at any scaled size. This is from the time when the original Metafont sources were used, when a different font size changed the actual shape of the glyphs (Google optical sizes for the curious).

The canonical solution to fix this problem with the CM fonts is to load the fix-cm package. The package type1cm is an older package that basically does the same thing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文