The draftdoc package for L^{A}TEX 2ε and dvips

               Albert Dvornik, <bert@mit.edu>

Version 0.10b February 14, 1998

Contents

1 Introduction 1

2 Source code 1 2.1 Preamble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2.2 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

2.2.1 Banner text . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2.2.2 Filled vs. outlined characters . . . . . . . . . . . . . . . . . 2

This documentation is still essentially non-existent. (I should fix that.)

1 Introduction

2 Source code

2.1 Preamble

This package requires L^{A}TEX 2ε. It’s unclear what is the earliest version that will work, so we don’t specify the earliest allowed version. If you notice a version of L^{A}TEX 2ε this doesn’t work with, please let me know.

 1 \NeedsTeXFormat{LaTeX2e}

We also specify the name of the package, and a message to be displayed when it is invoked:

 2 \ProvidesPackage{draftdoc}[1998/02/14 v0.10b <bert@mit.edu>]

2.2 Parameters

There are several parameters that may be changed either using a command, by package options,^{1} or both.

1Package options are the arguments specified between the []’s on the \usepackage[options] {draftdoc} line.

2.2.1 Banner text

The text printed across the page defaults to “Draft”. This can be changed by specifying \drafttext{new-text}, or by specifying the text=new-text option to the package. Please note that the option may not contain whitespace; to specify a banner containing whitespace, use \drafttext.

 3 \newcommand\dr@fttext{Draft}
 4 \newcommand\drafttext[1]{\def\dr@fttext{#1}}

(The option is handled by \DeclareOption*, below.)

2.2.2 Filled vs. outlined characters

 5 \newcommand\dr@ftshow{}
 6 \DeclareOption{outline}%
 7 {\draftgray{.85}\def\dr@ftshow{false charpath stroke}}
 8 \DeclareOption{fill}%
 9 {\draftgray{.95}\def\dr@ftshow{show}}

10 %

11 \newcommand\dr@ftfont{}
12 \newcommand\draftfont[1]{\def\dr@ftfont{#1}}
13 \DeclareOption{times}{\draftfont{Times-Roman}}
14 \DeclareOption{times-italic}{\draftfont{Times-Italic}}
15 \DeclareOption{helvetica}{\draftfont{Helvetica}}
16 \DeclareOption{helvetica-bold}{\draftfont{Helvetica-Bold}}
17 \DeclareOption{ncs}{\draftfont{NewCenturySchlbk}}

18 %

19 \newcommand\dr@ftangle{0}
20 \newcommand\draftangle[1]{\def\dr@ftangle{#1}}
21 \DeclareOption{45deg}{\draftangle{45}}
22 \DeclareOption{diagonal}{\draftangle{vsize hsize atan}}

Nominal size (has effect only on fonts which do not scale linearly)

23 \newcommand\dr@ftscaling{100}
24 \newcommand\draftscaling[1]{\def\dr@ftscaling{#1}}

Level of grayness (higher==lighter)

25 \newcommand\dr@ftgray{0.9}
26 \newcommand\draftgray[1]{\def\dr@ftgray{#1}}

27 %

28 \newcommand\dr@ftmargins{18}
29 \newcommand\draftmargins[1]{\def\dr@ftmargins{#1}}
30 \DeclareOption{wide}{\draftmargins{18}}
31 \DeclareOption{narrow}{\draftmargins{72}}

32 %

33 \newcommand\dr@fttwoside{}
34 \DeclareOption{twoside}%
35 {\def\dr@fttwoside{page-parity mul exch}}
36 \DeclareOption{noflip}%
37 {\def\dr@fttwoside{}}

38 %

39 \def\draft@noopt#1,{\PackageError{draftdoc}%
40 {Unknown option `\CurrentOption'}%
41 {You specified `\CurrentOption' as a local option to the `draftdoc'
42 package.\MessageBreak This option isn't declared; did you spell its
43 name right?\MessageBreak You can try typing \space <return> \space
44 to ignore this option and continue.}}
45 \def\draft@novalue,{\PackageError{draftdoc}%
46 {Missing value for option `\CurrentOption'}%
47 {You specified `\CurrentOption' as a local option to the `draftdoc'
48 package.\MessageBreak This option requires an argument, as in
49 `\CurrentOption=<some data>'.\MessageBreak You can try typing \space
50 <return> \space to ignore this option and continue.}}
51 \def\draft@assign#1={%
52 \@ifundefined{draft#1}{\draft@noopt}{\draft@checkarg{draft#1}}}
53 \def\draft@checkarg#1{\@ifnextchar,{\draft@novalue}{\draft@set{#1}}}
54 \def\draft@set#1#2=,{\@nameuse{#1}{#2}}
55 \DeclareOption*{\expandafter\draft@assign\CurrentOption=,}

56 %

57 \ExecuteOptions{times,wide,diagonal,fill,noflip}
58 \ProcessOptions\relax

When the document starts, invoke \dr@ftspecial (q.v.), and make further invocations of setting commands be an error.

59 \AtBeginDocument{\begingroup \def\ { }\dr@ftspecial\endgroup}

\dr@ftspecial generates a \special with specified parameters.

Assumptions about the (PostScript) universe:

1. /bop-hook is invoked just after the beginning of every page if it’s defined in userdict. The top item on the stack when /bop-hook is invoked is the physical page number, which is numbered starting from zero.

2. No other dvips hacks will override /bop-hook. [We hope.]

3. Postscript symbols vsize and hsize refer to page width and height in PostScript points (ie, TEX’s “bp” units).

All of these assumptions are true for dvipsk 5.66a.

It is worth remembering that no blank lines should occur inside a \special. (TEX would replace them with a \par in the body of the special!)

60 \def\dr@ftspecial{%
61 \special{!%
62  userdict /bop-hook {
63  gsave \dr@ftgray\ setgray hsize 2 div vsize 2 div translate
64  dup 2 mod 2 mul 1 exch sub /page-parity exch def
65  /\dr@ftfont\ findfont \dr@ftscaling\ scalefont setfont
66  newpath 0 0 moveto (\dr@fttext) false charpath pathbbox newpath

l d r u

67  4 copy

l d r u l d r u

68  3 -1 roll sub 3 1 roll sub neg exch

l d r u w=r-l h=u-d

69  2 copy

l d r u w h w h

70  exch atan neg dup

l d r u w h box-angle box-angle

71  \dr@ftangle\ add

l d r u w h box-angle diag-angle

72  cos exch cos div

l d r u w h width-factor

73  hsize \dr@ftmargins\ 2 mul sub exch div

l d r u w h scaled-width

74  3 -1 roll div exch pop

l d r u scaling

75  dup \dr@fttwoside\ scale

l d r u

76  \dr@ftangle\ rotate

l d r u

   \dr@ftangle

Center the text around origin

77  3 -1 roll add -2 div 3 1 roll add -2 div exch moveto
78  (\dr@fttext) \dr@ftshow\
79  grestore} put}}

The driver for this documentation

80 ⟨∗docstrip⟩

81 \begingroup
82 \input docstrip
83 \preamble
84 You are permitted to use, copy, distribute and modify this package
85 under the following conditions:
86 * This and other copyright notices must be left intact.
87 * You must distribute both ``draftdoc.dtx'' and ``draftdoc.ins''.
88 * If you modify any file, you *must* change the file name and
89 document the changes.
90 * You may not charge for it in any way, shape or form.
91 If you use this and like it, please send an e-mail note to <bert@mit.edu>.
92 \endpreamble\keepsilent\Msg{*** Generating `draftdoc' package style ***}
93 \generate{\file{draftdoc.sty}{\from{draftdoc.dtx}{draftdoc,dvips}}}
94 \ifToplevel{
95 \Msg{***********************************************************}
96 \Msg{* To finish the installation you have to move the file}
97 \Msg{* `draftdoc.sty' into a directory searched by TeX.}

 98 \Msg{***********************************************************}

99 }

100 \endgroup

101 ⟨/docstrip⟩ 102 ⟨∗driver⟩

103 \message{*** Generating documentation for `draftdoc' ***}
104 \documentclass{ltxdoc}
105 \usepackage{verbatim}
106 \begin{document}
107 \DocInput{draftdoc.dtx}
108 \end{document}

109 ⟨/driver⟩