Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drop caps in 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?

like image 300
sastanin Avatar asked Jan 05 '09 18:01

sastanin


2 Answers

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.

like image 57
sastanin Avatar answered Sep 26 '22 02:09

sastanin


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.

like image 26
Charlie Martin Avatar answered Sep 24 '22 02:09

Charlie Martin