# Mid-paragraph drop cap / float (lettrine)

I'm trying to typeset drop caps, but I have some instances where I need a drop cap to be mid-paragraph.

I'm picturing something like:

 /\  *Some multiline text
/==\ starts here and goes
below, eventually  ending
up below.  Now, the  next
sentence  is   associated
with the marker  'B'  but
lies  in  the  same para-
|D) graph.  *Left it is,
|,D) the  second  marker,
dropped below the line on
began.


In this case, it's not strictly a drop cap in the sense of being the first letter of a word in the paragraph, but rather I'm wanting some reliable and simple way to typeset something like the above.

Clearly, the lettrine package was the first place I looked, but it always forces a paragraph and doesn't really let you tie a drop cap to a particular word or sentence in the paragraph in this sense.

After looking through many of the questions about lettrine, I came to the conclusion that there are plenty of caveats here; for example, lettrine doesn't seem to do very well across page breaks.

I suppose what I really want is just some way of making a rectangular float flush with the left edge that is

• associated with a particular point in the text (a la todonotes), always starting on the same line;
• always a certain number of lines deep (in my case, 2);
• careful not to split across page boundaries;
• automatically given the correct width (with letters like m or numbers like 15 using more space than letters like i or numbers like 2).
-
Could wrapfig or something similar work for you? – ienissei Aug 5 '12 at 14:49
@ienissei I'm not sure -- is it hard to make wrapfig do what I described? – codebeard Aug 5 '12 at 14:53
From the package documentation, it looks like you can't put several of them in the same paragraph (at least I don't manage to in my test document)… Hopefully someone will find a solution that works. – ienissei Aug 5 '12 at 15:30
wrapfig won't help: “More specifically, a floated wrapping environment will only begin… • at the beginning of a paragraph […]” (from the wrapfig manual) – clemens Sep 24 '12 at 21:25

This isn't as robust as it could be, in particular it doesn't stop page breaking at the lines with the drop caps. (It should probably build an e-tex penalties list at the same time as building the parshape list) Also it doesn't absolutely guarantee that it will put the drop cap in the space it leaves, it could be out by a line or more if the surrounding text is hard to break and so the line breaks don't land where the macro estimates they will land after the trial run. As written it assumes the drop cap is always two lines, but that's a minor restriction it could easily be made to cover more.

\documentclass{article}

\makeatletter

\def\dc#1{%
\setbox0\hbox{\Huge #1}%
\leavevmode\vadjust{\vskip\wd0 \penalty123}\rlap{\smash{\copy0}}\vrule width2\wd0 height 1pt depth 0pt\relax}

\def\dcpar#1#2{{%
\parindent\z@
\emergencystretch.2\hsize
\@tempcnta\z@
\xdef\@pshape{\space}%
\setbox0\vbox{{\hsize#1\relax
#2%
\endgraf
\@tempdima=#1\relax
\loop
\@tempdima\hsize
\dimen@\z@
\ifnum\lastnodetype=11 \unskip\fi
\ifnum\lastnodetype=13
\count@\lastpenalty\unpenalty
\ifnum\count@=123
\dimen@\lastskip
\unskip
\xdef\@pshape{\the\dimen@\space \the\@tempdima\space\expandafter\eat@two\@pshape}%
\fi
\fi
\ifnum\lastnodetype=\@ne
\setbox\z@\lastbox
\xdef\@pshape{\the\dimen@\space \the\@tempdima\space\@pshape}%
\fi
\ifnum\lastnodetype=\m@ne
\xdef\@pshape{\the\@tempcnta\space\@pshape}%
\else
\repeat
}}%
\parshape=\@pshape
#2\par
}}

\def\eat@two#1 #2 {}

\makeatother

\begin{document}

\dcpar{.3\textwidth}{
\dc{A}Some multiline text
starts here and goes
below, eventually  ending
up below.  Now, the  next
sentence  is   associated
with the marker  'B'  but
lies  in  the  same paragraph.
\dc{D}Left it is,
the  second  marker,
dropped below the line on
began.}

\dcpar{.4\textwidth}{
\dc{A}Some multiline text
starts here and goes
below, eventually  ending
up below.  Now, the  next
sentence  is   associated
with the marker  'B'  but
lies  in  the  same paragraph.
\dc{D}Left it is,
the  second  marker,
dropped below the line on
began.}

\dcpar{.5\textwidth}{
\dc{A}Some multiline text
starts here and goes
below, eventually  ending
up below.  Now, the  next
sentence  is   associated
with the marker  'B'  but
lies  in  the  same paragraph.
\dc{D}Left it is,
the  second  marker,
dropped below the line on

would it help the alignment if you added a strut or a \vphantom` with the depth of the main text font to the drop cap? the second initial looks pretty awful as it is now. – barbara beeton Sep 28 '12 at 15:29