% dropcap.tex - drop capitals for start of chapters

% by Paul Taylor 12 December 1993
% vaguely based on Damian Cugley's version

% The first letter is dropped, to align with the top of the rest of the
% first word, which is set in capitals.  More precisely, small caps from
% a larger font are used, because small caps are designed to be used for
% whole words, which capitals are not. If the dropcap is an A or L, the
% rest of the word is kerned into it. The following lines are indented by
% the width of the drop cap plus a bit (\dimen2).

\countdef\dropcaptmp=255

%  #1  -- font command to use for dropcap
%  #2  -- letter to use as dropcap - use braces for ligatures, eg Dutch {IJ}
%  #3  -- rest of first word - use braces to put more words in capitals

\def\dropcap#1#2#3 % 
{%
    % finish previous paragraph if necessary
    \par
%
    % extra indentation of following lines (reduce for F, P, T, V, W, Y)
    \dimen2=0.5em
%
    % set the big capital, and the following words in small caps
    \setbox0=\hbox{#1\kern-0.0555em#2\/\kern\dimen2}%
    \setbox1=\hbox{\kern-\dimen2 \large\textsc{\lowercase{#3 }}}%
%
    % indentation of following lines
    \hangindent=\wd0
%
    % amount to drop - visually align top of drop cap and first word
    \dimen0=\ht0 
    \advance\dimen0 by -.9\ht1
%
    % number of lines to drop
    \dimen1=\dimen0 \advance\dimen1+1.9\baselineskip
    \dropcaptmp=\dimen1
    \divide\dropcaptmp\baselineskip
    \hangafter=-\dropcaptmp
%
    % calculate how much to kern the first word into the dropped capital
    % for this we use the amount of the automatic kern between the capital
    % and a following V or T (depending on the number of lines dropped)
    % (This does not seem to be enough.)
    \setbox2=\hbox{%
       #1% set the font
       \edef\next{\ifcase\dropcaptmp\or\or V\else T\fi}% which letter?
       #2\next % set them together, with the inter-letter kern
       \setbox0=\hbox{#2}\kern-\wd0%   subtract one letter
       \setbox0=\hbox{\next}\kern-\wd0% and the other
       \kern.03em % put some space in anyway
    }%
%
%    \message{baseline=\the\baselineskip\space heights=\the\ht0, \the\ht1}%
%    \message{drop=\the\dimen0 \space=\the\dropcaptmp\space lines}%
%    \message{letter=#2\space indent=\the\wd0 \space kern=\the\wd2}%
%
%   % drop the capital
    \setbox0=\hbox to0pt{\hss\lower\dimen0\box0}\dp0=0pt \ht0=0pt
%
%   % print it all
    \noindent\box0\kern\wd2\box1
}
