dropping – a L^{A}TEX Macro for Dropping the First Character(s) of a Paragraph^{∗}

Mats Dahlgren

                         (matsd@homenet.se)

1997/06/12

Abstract

This document describes the dropping package, which defines a command, \dropping, to drop the first character(s) of a paragraph. It is based on Fred J. Lauwers’s dropcaps.sty. In short, dropping is an automatization of dropcaps in that the user does not need to know the internal name of the font file (the .tfm-file) but can control this via the ordinary L^{A}TEX 2ε commands ‘\rmfamily’ etc. This file and the package: Copyright \begin{matrix}c \\ ◯ \end{matrix} 1996-1997 by Mats Dahlgren. All rights reserved.

1 Introduction

dropping is a L^{A}TEX package which makes it easy to start a new paragraph with a dropped letter or letters. The lines following the dropped letter are indented so no over-writing is to occur.

2 Userguide

2.1 Requirements

The file dropping.sty must be available in the user’s TEXINPUTS directories. It requires L^{A}TEX 2ε of 1995/12/01 (or newer). dropping works best with dvips and MakeTeXPK installed, although not formally needed. Without these, the output may not be as good as expected.

dropping v.0.12 has been tested using MiKTEX 1.07, including L^{A}TEX 2ε of 1996/12/01 and TEX 3.14159, under Win95. Only change relative previous version is a bug/typo fix.

2.2 Usage

The package is included by stating

  \usepackage{dropping}

In the document preamble. The package recognizes the same options as the graphics package v.1.0 (1996/05/29) by D. P. Carlisle and S. P. Q. Rahtz. Which is used is assumed to be controlled via the existence of a graphics.cfg file in the L^{A}TEX installation.

∗This document describes dropping version 0.12, and was last updated 1997/06/12.

2.3 Commands

\dropping The command \dropping is the main feature of the package. This command takes two mandatory

and one optional argument:

  \dropping[len]{numb}{text}

The len argument is a L^{A}TEX length (with unit) which states how far from the left margin the dropped text should start. A positive number corresponds to an indentation rightwards, a negative number will force the dropped text to start to the left of the paragraph. The default value is 0pt, meaning the dropped text will be aligned with the rest of the paragraph. The mandatory numb argument should be an integer number which states how many lines tall the dropped text should be. The last argument, text, is the text which should be dropped. This argument may either be a single letter or several letters without any formatting information, or the argument may start with a font-changing command of the type \rmfamily. In the former case, there are no special things to think about, and the dropped text will be type-set in the document’s default font. However, if a font-changing command is used, there are two things to be aware of: 1. You can only use the

font-changing commands \rmfamily, \sffamily, \ttfamily, \mdseries, \bfseries, \upshape,

\itshape, \slshape, or \scshape (i. e. not the \textxx commands). 2. The font-changing command(s) must be followed by a pair of braces, {}, and a blank space for the internal stripping routines to work. Several font-changing commands may be used in series. Thus, both {This},

{\bfseries{} this}, and {\ttfamily\itshape{} this} are examples of valid text arguments

to \dropping. Note that the construct \textit{\dropping[len]{numb}{text}} does not work properly.

\bigdrop Fred J. Lauwers’s command \bigdrop is also available if the dropping package is loaded. It has

exactly the same syntax as if dropcaps is loaded, that is:

  \bigdrop{len}{numb}{font}{text}

where the arguments len and numb are exactly the same as for \dropping (in fact, these two arguments are passed directly from \dropping to \bigdrop). The font argument is the internal font name to be used for the dropped text, i. e. the .tfm-file name (cmsl10 is an example of a valid font argument). The fourth argument, text, is the text to be dropped (only plain text is valid here!). For further details, please see the dropcaps documentation.

3 Examples

This section gives some simple examples of the use of dropping. As a first example, this very paragraph was started by stating the command ‘\dropping{3}{\itshape{} This}’ in the beginning. Notice the braces (‘{}’)

and the space before ‘This’! I n addition, this paragraph gives an example where the optional first argument of \dropping is

 used. The paragraph was started by ‘\dropping[-6pt]{2}{\slshape\sffamily{} I}n’, and as

you (hopefully!) can see, it works fine to have several font-changing commands in one \dropping command. The third example is an example where the default document font is being used. By now,

you probably have figured out that this paragraph is started with ‘\dropping{4}{T}he’. For you to see the full effect of the dropping, there has to be at least four complete lines in the paragraph, and so this text with not so much to say the L^{A}TEX user is going on

and on and on and on and on and on…

4 Known Problems

• If \dropping is used to start a paragraph which itself starts close to the bottom of a page, the dropped text will hang down into the footer and give a rather weird impression. Avoid this by some (unfortunately manual) page-breaking.

• Really large (more than two lines tall) dropped text is not very beautiful unless the graphics.cfg files specifies dvips as the default graphics’ driver (or an option which in turn calls the dvips option).

5 Acknowledgements

First and most of all, I want to acknowledge Fred J. Lauwers for providing the dropcaps package and letting me use the code thereof (according to the copyright notice in the dropcaps.sty file; see also dropping.ins). dropping would of course not be what it is today without Fred’s work. (Unfortunately, I do not have any current e-mail address of Fred’s.)

I also want to thank Donald Arsenau (asnd@reg.triumf.ca) and Robin Fairbairns

(Robin.Fairbairns@cl.cam.ac.uk) for answering my question to comp.text.tex about condi-

tional stripping of strings, as well as Piet van Oostrum (piet@cs.ruu.nl) and Alain Ketterlin (alain@ia1.u-strasbg.fr) for answering my “splitting of a string” question.

6 Sending a Bug Report

dropping is likely to contain bugs. Although, I do not consider this to be a “supported” package, reports of bugs in the package are most welcome. Before filing a bug report, please take the following actions:

1. Ensure your problem is not due to your own input file, package(s), or class(es);

2. Ensure your problem is not covered in the section “Known Problems” above;

3. Try to locate the problem by writing a minimal L^{A}TEX input file which reproduces the problem.

Include the command

       \setcounter{errorcontextlines}{999}

in your input;

4. Run your file through L^{A}TEX;

5. Send a description of your problem, the input file and the log file via e-mail to:

        matsd@homenet.se.

Enjoy your L^{A}TEX!mats d.

7 The Code

For the interested reader(s), here is a short description of the code. First, the package is to identify itself:

 1 \NeedsTeXFormat{LaTeX2e}[1995/12/01]
 2 \ProvidesPackage{dropping}[1997/06/12 v.0.12]

Then, some counters, dimensions and a boolean are set:

 3 \newcount\bigscale
 4 \newcount\down
 5 \newdimen\saveunitlength
 6 \newdimen\wantedheight
 7 \newif\ifstrtcmmnd \strtcmmndfalse

The differences between the different graphics’ drivers are taken care of by means of options to the package. First, the dvips option is declared (code greatefully taken from dropcaps.sty).

 8 \DeclareOption{dvips}{%
 9 \newcount\wantedcount
10 \newcount\actualcount%
11 \newdimen\actualheight%
12 \def\findsize#1#2{%
13 \bigscale=1000%
14 \font\BIG=#1 scaled \bigscale%
15 \setbox0=\hbox{\BIG #2\/}%
16 \actualheight=\ht0%
17 \wantedcount=\wantedheight \actualcount=\actualheight%
18 \advance\actualcount by 50%
19 \divide\actualcount by 100%
20 \multiply\wantedcount by 10%
21 \divide\wantedcount by \actualcount%
22 \font\BIG=#1 scaled \wantedcount%
23 \setbox0=\hbox{\BIG #2\/}%
24 \bigscale=\wantedcount}}

Next, the “non-dvips-users’” code from dropcaps.sty is declared to be an option, “other”:

25 \DeclareOption{other}{%
26 \def\nextmagstep#1#2#3{%
27 \bigscale=#3%
28 \font\BIG=#1 scaled \bigscale%
29 \setbox0=\hbox{\BIG #2\/}}%
30 \def\findsize#1#2{%
31 \nextmagstep{#1}{#2}{\magstep0}%
32 \ifdim\ht0<\wantedheight%
33 \nextmagstep{#1}{#2}{\magstephalf}%
34 \ifdim\ht0<\wantedheight%
35 \nextmagstep{#1}{#2}{\magstep1}%
36 \ifdim\ht0<\wantedheight%
37 \nextmagstep{#1}{#2}{\magstep2}%
38 \ifdim\ht0<\wantedheight%
39 \nextmagstep{#1}{#2}{\magstep3}%
40 \ifdim\ht0<\wantedheight%
41 \nextmagstep{#1}{#2}{\magstep4}%
42 \ifdim\ht0<\wantedheight%
43 \nextmagstep{#1}{#2}{\magstep5}%
44 \fi\fi\fi\fi\fi\fi}}

Following this, the various other graphics’ drivers as recognized by the graphics package are declared. The xdvi option just calls dvips (as in graphics), and so does the oztex option^{1} (a recent release of OzTEX contains a graphics.cfg which calls the dvips-option of graphics). All other options call the other option. Note if some user(s) find that an option should use dvips instead of other, please feel free to change in your local dropping.sty file as long as you also inform me (via e-mail to matsd@physchem.kth.se) of the appropriate change!

45 \DeclareOption{xdvi}{\ExecuteOptions{dvips}}
46 \DeclareOption{dvipsone}{\ExecuteOptions{other}}
47 \DeclareOption{dviwindo}{\ExecuteOptions{other}}
48 \DeclareOption{emtex}{\ExecuteOptions{other}}
49 \DeclareOption{dviwin}{\ExecuteOptions{other}}
50 \DeclareOption{oztex}{\ExecuteOptions{dvips}}
51 \DeclareOption{textures}{\ExecuteOptions{other}}
52 \DeclareOption{pctexps}{\ExecuteOptions{other}}
53 \DeclareOption{pctexwin}{\ExecuteOptions{other}}
54 \DeclareOption{pctexhp}{\ExecuteOptions{other}}
55 \DeclareOption{dvi2ps}{\ExecuteOptions{other}}
56 \DeclareOption{dvialw}{\ExecuteOptions{other}}
57 \DeclareOption{dvilaser}{\ExecuteOptions{other}}
58 \DeclareOption{dvitops}{\ExecuteOptions{other}}
59 \DeclareOption{psprint}{\ExecuteOptions{other}}
60 \DeclareOption{pubps}{\ExecuteOptions{other}}
61 \DeclareOption{ln}{\ExecuteOptions{other}}
62 \DeclareOption*{\ExecuteOptions{other}}

Now it is time to load the graphics.cfg file, and if it is not found send a warning to the user and assume dvips is around… Then in order to free some memory, any remaining option is processed.

63 \InputIfFileExists{graphics.cfg}{}{%
64 \PackageWarningNoLine{dropping}{%
65 You have no `graphics.cfg' file installed.\MessageBreak
66 I will assume you are using `dvips'}
67 \ExecuteOptions{dvips}}
68 \ProcessOptions

\bigdrop Next follows Fred J. Lauwers’s original command \bigdrop except that the \typeout statements have been removed.

69 \def\bigdrop#1#2#3#4{%
70 \saveunitlength=\unitlength%
71 \unitlength=\baselineskip%
72 \setbox1=\hbox{\the\font I}%
73 \wantedheight=#2\baselineskip \advance\wantedheight by -\baselineskip%
74 \advance\wantedheight by \ht1%
75 \findsize{#3}{#4}%
76 \hangindent=\wd0 \advance\hangindent by #1%
77 \hangafter=-#2%
78 \ifdim\dp0>0.25\baselineskip%
79 \loop\ifdim\dp0>\baselineskip
80 \advance\baselineskip by \baselineskip
81 \advance\hangafter by -1
82 \repeat
83 \advance\hangafter by -1
84 \baselineskip=\unitlength

1Thanks to Johan Fröberg (emgion@physchem.kth.se) for testing dropping on his Macintosh.

 85 \fi%
 86 \noindent%
 87 \down=-#2 \advance\down by 1%
 88 \begin{picture}(0,0)%
 89 \put(0,\down){\makebox(0,0)[br]{\box0}}%
 90 \end{picture}%
 91 \unitlength=\saveunitlength}

Now we define some internal macros to be able to automize the use of \bigdrop. (Thanks to Donald Arsenau, Robin Fairbairns, Piet van Oostrum, and Alain Ketterlin!)

 92 \def\spltatspc#1 #2\spltatspc{#1}
 93 \def\spltstrng#1{\expandafter\@split#1\end}
 94 \def\@split#1 #2\end{\def\strngn{#1}\def\strngtw{#2}}
 95 \def\isit#1{\expandafter\@isit\string#1\@null}
 96 \def\@isit#1#2\@null{%
 97 \ifnum`#1=`\\
 98  \global\strtcmmndtrue
 99 \else
100  \global\strtcmmndfalse
101 \fi

102 }

\dropping Finally, the macro \dropping is defined:

103 \newcommand{\dropping}[3][0pt]{%
104 \get@external@font%
105 \edef\n@vf@nt{\expandafter\spltatspc\external@font \spltatspc}%
106 \setbox8=\hbox{#3\get@external@font%
107 \global\let\external@font@export\external@font%
108 \edef\n@vf@ntb@x{\expandafter\spltatspc\external@font \spltatspc}%
109 \global\let\n@vf@nt\n@vf@ntb@x}%
110 \let\external@font\external@font@export%
111 \edef\xprt@rgtr{\expandafter\spltatspc\external@font\expandafter{}
112 \spltatspc}
113 \def\spltslsk{#3}%
114 \isit{#3}%
115 \ifstrtcmmnd
116 \spltstrng\spltslsk%
117 \let\xprt@rgfr\strngtw
118 \else
119 \def\xprt@rgfr{#3}
120 \fi
121 \protect\bigdrop{#1}{#2}{\xprt@rgtr}{\xprt@rgfr}%

122 }

This brings us to the end of dropping. Hope you’ll enjoy it!

Copyright \begin{matrix}c \\ ◯ \end{matrix}1997 by Mats Dahlgren