summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/dropping/dropping.dtx
blob: 0b69192d248b8c52927d9e08d66e2f829fa98278 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
%  
%  \iffalse 
% 
%    The first part is a comment to the reader(s) of `dropping.dtx'. 
% 
%  dropping.dtx    Version 0.12a, June 12, 1997 
%  (c) 1997-98 by Mats Dahlgren  (matsd@sssk.se) 
% 
%  Please see the information in file `dropping.ins' on how you 
%  may use and (re-)distribute this file.  Run LaTeX on the file  
%  `dropping.ins' to get a .sty-file and then on `dropping.dtx' 
%  to obtain instructions.  
% 
%  This file may NOT be distributed if not accompanied by 'dropping.ins'. 
% 
%<*driver> 
\documentclass[a4paper]{ltxdoc} 
\usepackage{dropping} 
\textwidth=150mm 
\textheight=210mm 
\topmargin=0mm 
\oddsidemargin=5mm 
\evensidemargin=5mm 
  \DocInput{dropping.dtx}  
%  \PrintChanges 
\end{document} 
%</driver> 
%  \fi 
%  
%  \CheckSum{286} 
%  
%  \def\filename{dropping.dtx} 
%  \def\fileversion{1.0} 
%  \def\filedate{1997/07/12}\def\docdate{1998/06/05} 
%  \MakeShortVerb{\|} 
%  \date{\docdate} 
%  \title{\textsf{dropping} -- a \LaTeX{} Macro for Dropping the 
%  First Character(s) of a Paragraph\thanks{This document describes 
%  \textsf{dropping} version 
%  \fileversion , and was last updated \docdate .}} 
%  \author{Mats Dahlgren\footnote{Email:\ \texttt{matsd@sssk.se}\ \ \ 
%  Web:\ \texttt{http://www.homenet.se/matsd/}}}  
%  \begin{document} 
%  \maketitle 
%  \begin{abstract} 
%  This document describes the \textsf{dropping} package, which 
%  defines a command, |\dropping|, to drop the first character(s) of 
%  a paragraph.  It is based on Fred~J.\ Lauwers's 
%  \texttt{dropcaps.sty}.  In short, \textsf{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 \LaTeXe{} commands `|\rmfamily|' 
%  \textit{etc.} 
%  \\ This file and the package:\ 
%  Copyright \copyright\ 1996-1998 by Mats Dahlgren.  All rights 
%  reserved. 
%  \end{abstract} 
%   
%  \section{Introduction} 
%  \textsf{dropping} is a \LaTeX{} 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.  
%   
%  This userguide is also available in \texttt{.pdf}-format 
%  on the internet.  It is found from my \LaTeX\ web page: 
%  \texttt{http://www.homenet.se/matsd/latex/}
%    
%  \section{Userguide} 
%  \subsection{Requirements} 
%  The file |dropping.sty| must be available in the user's 
%  |TEXINPUTS| directories. 
%  It requires \LaTeXe{} of 1996/12/01 (or newer).  
%  \textsf{dropping} works best with |dvips| and |MakeTeXPK| 
%  installed, although not formally needed.  Without these, the 
%  output may not be as good as expected.  
%  
%  \textsf{dropping} v.\fileversion{} has been tested using 
%  MiK\TeX{} 1.07, including \LaTeXe{} of 1997/06/01 
%  and \TeX{} 3.14159, under Win95.  Only change relative previous 
%  version is a bug/typo fix.  
% 
%  \subsection{Usage} 
%  The package is included by stating\\ 
%  |  \usepackage{dropping}| \\ 
%  In the document preamble.  The package recognizes the same 
%  options as the \textsf{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 \LaTeX{} installation.  
%  
%   \newpage
%  \subsection{Commands}         
%   
%  \DescribeMacro{\dropping}
%  The command |\dropping| is the main feature of the package.  This 
%  command takes two mandatory and one optional argument:\\
%  |  \dropping[|\textit{len}|]{|\textit{numb}|}{|\textit{text}|}|\\
%  The \textit{len} argument is a \LaTeX{} 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 \textit{numb} argument should be an integer number which 
%  states how many lines tall the dropped text should be.  The last 
%  argument, \textit{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:  \textbf{1.} You can only use the font-changing commands 
%  |\rmfamily|, |\sffamily|, |\ttfamily|, |\mdseries|, |\bfseries|, 
%  |\upshape|, |\itshape|, |\slshape|, or |\scshape| (\textit{i.~e.}
%  \emph{not} the |\text|\textit{xx} commands).  \textbf{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 \textit{text} arguments to |\dropping|.  
%  Note that the construct
%  |\textit{\dropping[|\textit{len}|]{|\textit{numb}|}{|\textit{text}|}}|
%  does \emph{not} work properly. 
%  
%  \DescribeMacro{\bigdrop}
%  Fred~J.~Lauwers's command |\bigdrop| is also available if the 
%  \textsf{dropping} package is loaded.  It has exactly the same 
%  syntax as if \textsf{dropcaps} is loaded, that is:\\
%  |  \bigdrop{|\textit{len}|}{|\textit{numb}|}{|\textit{font}|}{|\textit{text}|}|\\
%  where the arguments \textit{len} and \textit{numb} are exactly the 
%  same as for |\dropping| (in fact, these two arguments are passed 
%  directly from |\dropping| to |\bigdrop|).  The \textit{font} 
%  argument is the internal font name to be used for the dropped 
%  text, \textit{i.~e.\ } the |.tfm|-file name (|cmsl10| is an example 
%  of a valid \textit{font} argument).  The fourth argument, 
%  \textit{text}, is the text to be dropped (only plain text is valid 
%  here!).  For further details, please see the \textsf{dropcaps} 
%  documentation.
%  
%  \section{Examples}
%  
%  \dropping{3}{\itshape{} This}section gives some simple examples 
%  of the use of \textsf{dropping}.  As a first example, this very 
%  paragraph was started by stating the command\linebreak 
%  `|\dropping{3}{\itshape{} This}|' 
%  in the beginning.  Notice the braces (`|{}|') and the space before 
%  `This'!  
%  
%  \dropping[-6pt]{2}{\slshape\sffamily{} 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.  
%  
%  \dropping{4}{T}he 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 \LaTeX{} user is going on and 
%  on and on and on and on and on\ldots  
%   
%  \section{Known Problems}  
%  
%  \begin{itemize}
%  \item 
%  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.  
%  \item
%  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).
%  \end{itemize}
%  
%  \section{Acknowledgements}
%  
%  First and most of all, I want to acknowledge Fred~J.\ Lauwers for 
%  providing the \textsf{dropcaps} package and letting me use the 
%  code thereof (according to the copyright notice in the 
%  |dropcaps.sty| file; see also |dropping.ins|).  
%  \textsf{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\linebreak (|Robin.Fairbairns@cl.cam.ac.uk|) for 
%  answering my question to |comp.text.tex| about conditional 
%  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.  
%  
%  \section{Sending a Bug Report}
%  \textsf{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:
%  \begin{enumerate}
%  \item Ensure your problem is not due to your own input file, 
%     package(s), or class(es);
%  \item Ensure your problem is not covered in the section 
%     ``Known Problems'' above;
%  \item  Try to locate the problem by writing a minimal 
%     \LaTeX{} input file which reproduces the problem.  
%     Include the command\\ 
%     |  \setcounter{errorcontextlines}{999}|\\ 
%     in your input;
%  \item Run your file through \LaTeX ;
%  \item Send a description of your problem, the input file 
%     and the log file via e-mail to:\\
%     \hspace*{5mm} \texttt{matsd@sssk.se}.
%  \end{enumerate}\bigskip
%  
%  \noindent{\itshape Enjoy your 
%  \LaTeX!\raisebox{-\baselineskip}{mats d.}}
% \StopEventually{\vfill\hfill\scriptsize Copyright \copyright 
%  1997-98 by Mats Dahlgren}
%  \newpage 
%  
%  \section{The Code} 
%  For the interested reader(s), here is a short description 
%  of the code. 
% \iffalse
%<*paketkod>
% \fi
%  First, the package is to identify itself:  
%    \begin{macrocode} 
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{dropping}[1997/06/12 v.0.12]
%    \end{macrocode}
%  Then, some counters, dimensions and a boolean are set:
%    \begin{macrocode} 
\newcount\bigscale
\newcount\down
\newdimen\saveunitlength
\newdimen\wantedheight
\newif\ifstrtcmmnd \strtcmmndfalse
%    \end{macrocode}
%  
%  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|).
%    \begin{macrocode} 
\DeclareOption{dvips}{%
\newcount\wantedcount
\newcount\actualcount%
\newdimen\actualheight%
\def\findsize#1#2{%
\bigscale=1000%
\font\BIG=#1 scaled \bigscale%
\setbox0=\hbox{\BIG #2\/}%
\actualheight=\ht0%
\wantedcount=\wantedheight \actualcount=\actualheight%
\advance\actualcount by 50%
\divide\actualcount by 100%
\multiply\wantedcount by 10%
\divide\wantedcount by \actualcount%
\font\BIG=#1 scaled \wantedcount%
\setbox0=\hbox{\BIG #2\/}%
\bigscale=\wantedcount}}
%    \end{macrocode}
%  Next, the ``non-|dvips|-users'{}'' code from |dropcaps.sty| is 
%  declared to be an option, ``|other|'':
%    \begin{macrocode} 
\DeclareOption{other}{%
\def\nextmagstep#1#2#3{%
\bigscale=#3%
\font\BIG=#1 scaled \bigscale%
\setbox0=\hbox{\BIG #2\/}}%
\def\findsize#1#2{%
\nextmagstep{#1}{#2}{\magstep0}%
\ifdim\ht0<\wantedheight%
\nextmagstep{#1}{#2}{\magstephalf}%
\ifdim\ht0<\wantedheight%
\nextmagstep{#1}{#2}{\magstep1}%
\ifdim\ht0<\wantedheight%
\nextmagstep{#1}{#2}{\magstep2}%
\ifdim\ht0<\wantedheight%
\nextmagstep{#1}{#2}{\magstep3}%
\ifdim\ht0<\wantedheight%
\nextmagstep{#1}{#2}{\magstep4}%
\ifdim\ht0<\wantedheight%
\nextmagstep{#1}{#2}{\magstep5}%
\fi\fi\fi\fi\fi\fi}}
%    \end{macrocode}
%  Following this, the various other graphics' drivers as recognized 
%  by the \textsf{graphics} package are declared.  The |xdvi| option 
%  just calls |dvips| (as in \textsf{graphics}), and so does the 
%  |oztex| option\footnote{Thanks to Johan Fr\"oberg 
%  (\texttt{emgion@physchem.kth.se}) for testing \textsf{dropping} on 
%  his Macintosh.}  (a recent release of Oz\TeX{} contains a 
%  |graphics.cfg| which calls the |dvips|-option of 
%  \textsf{graphics}).  All other options  
%  call the |other| option.  \textbf{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@sssk.se|) of the
%  appropriate change! 
%    \begin{macrocode} 
\DeclareOption{xdvi}{\ExecuteOptions{dvips}}
\DeclareOption{dvipsone}{\ExecuteOptions{other}}
\DeclareOption{dviwindo}{\ExecuteOptions{other}}
\DeclareOption{emtex}{\ExecuteOptions{other}}
\DeclareOption{dviwin}{\ExecuteOptions{other}}
\DeclareOption{oztex}{\ExecuteOptions{dvips}}
\DeclareOption{textures}{\ExecuteOptions{other}}
\DeclareOption{pctexps}{\ExecuteOptions{other}}
\DeclareOption{pctexwin}{\ExecuteOptions{other}}
\DeclareOption{pctexhp}{\ExecuteOptions{other}}
\DeclareOption{dvi2ps}{\ExecuteOptions{other}}
\DeclareOption{dvialw}{\ExecuteOptions{other}}
\DeclareOption{dvilaser}{\ExecuteOptions{other}}
\DeclareOption{dvitops}{\ExecuteOptions{other}}
\DeclareOption{psprint}{\ExecuteOptions{other}}
\DeclareOption{pubps}{\ExecuteOptions{other}}
\DeclareOption{ln}{\ExecuteOptions{other}}
\DeclareOption*{\ExecuteOptions{other}}
%    \end{macrocode}
%  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\ldots{}  Then in order to free some memory, any remaining
%  option is processed.
%    \begin{macrocode} 
\InputIfFileExists{graphics.cfg}{}{%
\PackageWarningNoLine{dropping}{%
You have no `graphics.cfg' file installed.\MessageBreak 
I will assume you are using `dvips'}
\ExecuteOptions{dvips}}
\ProcessOptions
%    \end{macrocode}
%  
%  \DescribeMacro{\bigdrop}
%  Next follows Fred~J.\ Lauwers's original command |\bigdrop| except 
%  that the |\typeout| statements have been removed.
%    \begin{macrocode} 
\def\bigdrop#1#2#3#4{%
\saveunitlength=\unitlength%
\unitlength=\baselineskip%
\setbox1=\hbox{\the\font I}%
\wantedheight=#2\baselineskip \advance\wantedheight by -\baselineskip%
\advance\wantedheight by \ht1% 
\findsize{#3}{#4}%
\hangindent=\wd0 \advance\hangindent by #1%
\hangafter=-#2%
\ifdim\dp0>0.25\baselineskip% 
 \loop\ifdim\dp0>\baselineskip
  \advance\baselineskip by \baselineskip
  \advance\hangafter by -1
 \repeat
 \advance\hangafter by -1
 \baselineskip=\unitlength
\fi%
\noindent%
\down=-#2 \advance\down by 1%
\begin{picture}(0,0)%
\put(0,\down){\makebox(0,0)[br]{\box0}}%
\end{picture}%
\unitlength=\saveunitlength}
%    \end{macrocode}
%  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!)
%    \begin{macrocode} 
\def\spltatspc#1 #2\spltatspc{#1}
\def\spltstrng#1{\expandafter\@split#1\end}
\def\@split#1 #2\end{\def\strngn{#1}\def\strngtw{#2}}
\def\isit#1{\expandafter\@isit\string#1\@null}
\def\@isit#1#2\@null{%
  \ifnum`#1=`\\
    \global\strtcmmndtrue
  \else
    \global\strtcmmndfalse
  \fi
}
%    \end{macrocode}
%  
%  \DescribeMacro{\dropping}
%  Finally, the macro |\dropping| is defined:
%    \begin{macrocode} 
\newcommand{\dropping}[3][0pt]{%
\get@external@font%
\edef\n@vf@nt{\expandafter\spltatspc\external@font \spltatspc}%
\setbox8=\hbox{#3\get@external@font%
\global\let\external@font@export\external@font%
\edef\n@vf@ntb@x{\expandafter\spltatspc\external@font \spltatspc}%
\global\let\n@vf@nt\n@vf@ntb@x}%  
\let\external@font\external@font@export%
\edef\xprt@rgtr{\expandafter\spltatspc\external@font\expandafter{} 
\spltatspc}
\def\spltslsk{#3}%
\isit{#3}%
\ifstrtcmmnd
\spltstrng\spltslsk%
\let\xprt@rgfr\strngtw
\else
\def\xprt@rgfr{#3}
\fi
\protect\bigdrop{#1}{#2}{\xprt@rgtr}{\xprt@rgfr}%
}
%    \end{macrocode}
%  This brings us to the end of \textsf{dropping}.  Hope you'll 
%  enjoy it!
% \iffalse
%</paketkod>
% \fi
% \Finale
%
\endinput