5

I'm trying to implement a "drop cap", not to use it (I know there is a package to do it), but to practice some box things. So far I have this written:

\parindent=0pt

\newdimen\pdim
\def\bigletra#1{
    \leavevmode%
    {%
    \fontsize{24pt}{0pt}\selectfont%
    \global\setbox0\hbox to 0pt {\llap{#1}}%
    }%
    \box0%
    \pdim=\linewidth\advance\pdim by -2em
    \parshape 3
    2em \pdim
    2em \pdim
    0pt \linewidth
}

\begin{document}

\bigletra Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. 
Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, 
consectetuer id, vulputate a, magna.

The result is this: enter image description here

Using \lower doesn't work as you would like hehe.

1 Answer 1

7

You need to lower the box and smash it.

\RequirePackage{fix-cm}

\documentclass{article}

\newsavebox{\bigletrbox}
\newcommand{\bigletra}[2]{%
  \par
  \sbox\bigletrbox{\fontsize{2.1\baselineskip}{0}\selectfont#1}%
  \parshape 3
    \dimeval{\wd\bigletrbox+2pt} \dimeval{\linewidth-\wd\bigletrbox-2pt}
    \dimeval{\wd\bigletrbox+2pt} \dimeval{\linewidth-\wd\bigletrbox-2pt}
    0pt \linewidth
  \noindent
  \makebox[0pt][r]{%
    \raisebox{-\baselineskip}[0pt][0pt]{\usebox{\bigletrbox}}\hspace{2pt}%
  }\textsc{#2}%
}

\begin{document}

\bigletra{L}{orem} ipsum dolor sit amet, consectetuer adipiscing elit.
Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget,
consectetuer id, vulputate a, magna.

\end{document}

enter image description here

Why the \textsc part? This way you're sure not to get characters with ascenders that would make the drop capital to look unbalanced. I added also some gutter (2pt) between the drop capital and the text.

Instead of \parshape you could use

\hangindent\dimeval{\wd\bigletrbox+2pt}\hangafter=-2

and, if you plan to use drop capitals also not at top of pages, adding \vadjust{\nobreak} at the end of the macro should be better, so you don't get a page break in the middle.

1
  • Thank you so much! I had forgotten the existence of \smash because I never had to use it and I never really got around to seeing what it did. I didn't know \hangafter and \hangindent.
    – gxono
    Commented May 18 at 15:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .