[comp.text.tex] Large initial

spit@ruunsa.fys.ruu.nl (Werenfried Spit) (01/09/91)

DD  oes someone have a TeX macro that produces a large 
D D initial in the first line of a paragraph, somewhat
DD  like the big D in front of this one. I figure one
has to twiddle a little bit with \hangindent, but I do
not get it completely right. 

Thanks in advance


Werenfried Spit                            
   R.J. v.d. Graafflaboratorium            +31-(0)30-53-2330                   
   Postbus 80.000                          
   3508 TA  Utrecht                        spit@fys.ruu.nl      
   The Netherlands                         spit@hutruu51.bitnet    

xiaofei@acsu.buffalo.edu (Xiaofei Wang) (01/09/91)

In article <1869@ruunsa.fys.ruu.nl> spit@ruunsa.fys.ruu.nl (Werenfried Spit) writes:
* DD  oes someone have a TeX macro that produces a large 
* D D initial in the first line of a paragraph, somewhat
* DD  like the big D in front of this one. I figure one
* has to twiddle a little bit with \hangindent, but I do
* not get it completely right. 
* 
* Thanks in advance
* 
* 
The following code was not written by me but I know it works. It is
LaTeX and I will be happy if some one changes it to TeX. The big letter
extendes to two lines, almost. And I would be happy also if some one
can make it bigger or smaller. I don't have good knowledge of LaTeX or
time to do these.

\documentstyle{article}
\begin{document}
\def\bigfirstletter#1#2{{\noindent
    \setbox0\hbox{\Huge #1}\setbox1\hbox{#2}\setbox2\hbox{(}%
    \count0=\ht0\advance\count0 by\dp0\count1\baselineskip
    \advance\count0 by-\ht1\advance\count0 by\ht2
    \dimen1=.5ex\advance\count0 by\dimen1\divide\count0 by\count1
    \advance\count0 by1\dimen0\wd0
    \advance\dimen0 by.25em\dimen1=\ht0\advance\dimen1 by-\ht1
    \global\hangindent\dimen0\global\hangafter-\count0
    \hskip-\dimen0\setbox0\hbox to\dimen0{\raise-\dimen1\box0\hss}%
    \dp0=0in\ht0=0in\box0}#2}
\bigfirstletter
This works very well. The first letter `T' is bigger than the others. See 
where the second line go? Guess what? It is behind T. and also see where 
the third line go? guess what? It is aligned with T.
\end{document}

smith@zeus.harvard.edu (Steven Smith) (01/09/91)

The following macro produces a large initial letter.  By default, it
provides an initial letter in the font cmr17, scaled so that the
letter extends from the top of an `X' in the current font to the
bottom of the second line, with no horizontal offsets.  These defaults
may be overridden, as described below.  It behooves the user to employ
Rokicki's dvips conversion program to handle the arbitrary font
scaling capability.  I've been pondering the addition of another
feature that would allow one to indent the entire first letter, i.e.,

>       DD  oes someone have a TeX macro that produces a large 
>       D D initial in the first line of a paragraph, somewhat
>       DD  like the big D in front of this one. I figure one has
> to twiddle a little bit with \hangindent, but I do not get it
> completely right. 

but this remains unimplemented.  I would appreciate any comments or
improvements that anyone could suggest.

Steven Smith
smith@sandalphon.harvard.edu


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Cut Here %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                         %
%                               \bigstart                                 %
%                                                                         %
%  A general macro to provide large letters at the start of paragraphs.   %
%                                                                         %
%  Syntax: \bigstart{a}{b}[c_1][c_2]...[c_n] #1                           %
%                                                                         %
%  where the following arguments are optional:                            %
%                                                                         %
%    a: font specification (Default=cmr17)                                %
%    b: font scale (Default=scale to nth line)                            %
%    c_1: 1st line offset from width of character                         %
%    c_2: 2d line offset from width of character                          %
%    ...                                                                  %
%    c_n: nth line offset from width of character                         %
%    (Default=two lines, zero offset)                                     %
%                                                                         %
%  Examples:  \bigstart Call me Ishmael.                                  %
%                                                                         %
%  \bigstart{cmb10}{\magstep4} Four score and seven years ago ...         %
%                                                                         %
%  \font\rm=ptmr at12pt \rm                                               %
%  \bigstart{ptmr}[0pt][-4pt][-8pt] WE, THE PEOPLE of the United States,  %
%  in order to form a more perfect Union, establish justice, insure       %
%  domestic tranquility, provide for the common defense, promote the      %
%  general welfare, and secure the blessings of liberty to ourselves and  %
%  our posterity, do ordain and establish this Constitution for the       %
%  United States of America.                                              %
%                                                                         %
%                                                                         %
%  Author: Steven T. Smith, 1990                                          %
%                                                                         %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\catcode`\@=11  % Make @ a letter (to name unlikely control sequences).

\newif\ifsc@lespec
\newif\if@ffsetspec
\newif\iffirst@ff
\newcount\linec@unt

% Define macro to give the ratio of two integers times 1000.
% Result: #1=1000(#2/#3)
\newcount\numerat@r \newcount\denominat@r \newcount\tempc@unt
\def\magratio#1#2#3{\numerat@r=#2 \denominat@r=#3 \def\r@t{}%
  \tempc@unt=\numerat@r \divide\tempc@unt by\denominat@r
  \ifnum\tempc@unt>0 \edef\r@t{\the\tempc@unt}\fi
  \multiply\tempc@unt by\denominat@r \advance\numerat@r by-\tempc@unt
  \multiply\numerat@r by10 \tempc@unt=\numerat@r
    \divide\tempc@unt by\denominat@r \edef\r@t{\r@t\the\tempc@unt}%
    \multiply\tempc@unt by\denominat@r \advance\numerat@r by-\tempc@unt
  \multiply\numerat@r by10 \tempc@unt=\numerat@r
    \divide\tempc@unt by\denominat@r \edef\r@t{\r@t\the\tempc@unt}%
    \multiply\tempc@unt by\denominat@r \advance\numerat@r by-\tempc@unt
  \multiply\numerat@r by10 \tempc@unt=\denominat@r
  \divide\tempc@unt by2 \advance\numerat@r by\tempc@unt
  \divide\numerat@r by\denominat@r \edef\r@t{\r@t\the\numerat@r}%
  #1=\r@t}

\def\bigstart{\par\begingroup \def\par{\endgraf\endgroup}%
  \def\f@ntrootdefault{cmr17}%
  \def\linec@untdefault{1}\def\@ffsetdefault{[0pt][0pt]}%
  \sc@lespecfalse\@ffsetspecfalse\linec@unt=-1\def\@ffset{}%
  \futurelet\next\brace@ptional}

\def\brace@ptional{\ifx\next\bgroup\def\@temp{\f@ntspec}%
  \else \def\@temp{\edef\f@ntroot{\f@ntrootdefault}\brack@ptional}\fi \@temp}
\def\f@ntspec#1{\def\f@ntroot{#1}\futurelet\next\brace@@ptional}

\def\brace@@ptional{\ifx\next\bgroup\def\@temp{\sc@lespectrue\sc@lespec}%
  \else \def\@temp{\sc@lespecfalse\brack@ptional}\fi \@temp}
\def\sc@lespec#1{\def\sc@le{#1}\futurelet\next\brack@ptional}

\def\brack@ptional{\ifx\next[\def\@temp{\@ffsetspectrue\@ffsetspec}%
  \else \def\@temp{\bigst@rtinit}\fi \@temp}
\def\@ffsetspec[#1]{\advance\linec@unt by1
  \edef\@ffset{\@ffset[#1]}\futurelet\next\brack@ptional}

\def\bigst@rtinit#1{\if@ffsetspec\else \linec@unt=\linec@untdefault
  \edef\@ffset{\@ffsetdefault}\fi \setbox0=\hbox{X}%
  \ifsc@lespec \font\bigch@r=\f@ntroot\space scaled\sc@le \else
    \font\bigch@r=\f@ntroot \setbox1=\hbox{\bigch@r X}%
    \dimen0=\baselineskip \multiply\dimen0 by\linec@unt
    \advance\dimen0 by\ht0 \dimen1=\ht1 \advance\dimen1 by\dp1
    \count11=\dimen0 \count12=\dimen1
    \magratio{\count10}{\count11}{\count12}%
    \font\bigch@r=\f@ntroot\space scaled\count10\fi
  \setbox1=\hbox{\bigch@r#1}\advance\linec@unt by2
  \edef\parsh@pe{\the\linec@unt}%
  \first@fftrue \edef\@temp{\futurelet\noexpand\next\noexpand\initparsh@pe
    \@ffset} \@temp}

\def\initparsh@pe{\ifx\next[\def\@temp{\m@keparsh@pe}\else
  \def\@temp{\bigst@rt}\fi \@temp}
\def\m@keparsh@pe[#1]{\dimen0=\wd1 \dimen1=\hsize
  \advance\dimen0 by#1 \advance\dimen1 by-\dimen0
  \edef\parsh@pe{\parsh@pe\space\the\dimen0\space\the\dimen1}%
  \iffirst@ff \dimen2=\dimen0\first@fffalse \fi
  \futurelet\next\initparsh@pe}

\def\bigst@rt{\edef\parsh@pe{\parsh@pe\space 0pt \hsize}%
  \expandafter\parshape\parsh@pe \noindent
  \rlap{\kern-\dimen2\raise\ht0\vbox to0pt{\box1\vss}}\ignorespaces}

\catcode`\@=12  % Make @ an ``other'' (back to normal).

nbeck@weber.ucsd.edu (Nathaniel Beck) (01/10/91)

>>       DD  oes someone have a TeX macro that produces a large 
>>       D D initial in the first line of a paragraph, somewhat
>>       DD  like the big D in front of this one. I figure one has
>> to twiddle a little bit with \hangindent, but I do not get it
>> completely right. 

Try drop.sty which is available from Clarkson. I personally have not
used it but it does claim to do what the initial poster wanted.
(Sorry about following up to the reply, but I send mail to the
initial poster before I realized there was more traffic on this.)


-- 
Neal Beck 
Dept of Politcal Science, UCSD
beck@ucsd.edu
Dislaimer: The Regents pay me (a bit!) to distribute my opinions.
Neal Beck 
Dept of Politcal Science, UCSD
beck@ucsd.edu
Dislaimer: The Regents pay me (a bit!) to distribute my opinions.