Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
.nr *% \n(%#u+7u
2
.ds NR "\f2nroff\fP
3
.ds TR "\f2troff\|\fP
4
.ds Tr \f2Troff\|\fP
5
.ds Nr \f2Nroff\fP
6
.		\" CW - constant width font not from -ms
7
.de T&
8
.X "END US
9
.X "US T&
10
..
11
.de CW
12
.nr PQ \\n(.f
13
.if \\n(.$=0 .ft CW
14
.if \\n(.$>0 \%\&\\$3\f(CW\\$1\\f\\n(PQ\\$2
15
..
16
.de BI
17
.nr PQ \\n(.f
18
.if \\n(.$=0 .ft 4
19
.if \\n(.$>0 \%\&\\$3\f2\\$1\\f\\n(PQ\\$2
20
..
21
.de UC
22
\\$3\s-2\\$1\s+2\\$2
23
..
24
.am NH
25
.nr p \\np+1
26
.nr s 0 1
27
..
28
.fp 4 BI LucidaSansI
29
.bd 4 3
30
.de sc
31
.LP
32
\f4\\np.\\n+s.\ \ \\$1\f1\0
33
..
34
.de bt
35
.SP .25
36
.LP
37
.NE 2.1
38
.ta 1.5i 2.5i 3.5i 4.5i
39
\\$1	\\$2	\\$3	\\$4
40
.IP "" 0.8i
41
....br
42
\\$5
43
..
44
.
45
.
46
.
47
.
48
.
49
.
50
.
51
.TL
52
Troff User's Manual
53
.AU
54
Joseph F. Ossanna
55
Brian W. Kernighan
56
.sp
57
bwk@research.bell-labs.com
58
.EQ
59
delim @@
60
define cw % "\&" font CW %
61
.EN
62
.SH
63
Introduction
64
.PP
65
\*(Tr and \*(NR are text processors 
66
that format text for typesetter- and
67
typewriter-like terminals, respectively.
68
They accept lines of text interspersed with lines of
69
format control information and
70
format the text into a printable, paginated document
71
having a user-designed style.
72
\*(Tr and \*(NR offer
73
unusual freedom in document styling:
74
arbitrary style headers and footers;
75
arbitrary style footnotes;
76
multiple automatic sequence numbering for paragraphs, sections, etc;
77
multiple column output;
78
dynamic font and point-size control;
79
arbitrary horizontal and vertical local motions at any point;
80
and
81
a family of automatic overstriking, bracket construction, and
82
line-drawing functions.
83
.
84
.de TL
85
.LP
86
.ce
87
.ps +2
88
.ft B
89
..
90
.
91
.PP
92
.I Troff
93
produces its output in a device-independent form,
94
although parameterized for a specific device;
95
\*(TR output must be processed by a driver for that
96
device to produce printed output.
97
.PP
98
\*(Tr and \*(NR are highly compatible with each other and it is almost always
99
possible to prepare input acceptable to both.
100
Conditional input is provided to enable
101
the user to embed input expressly destined for either program.
102
\*(Nr can prepare output directly for a variety of terminal types and
103
is capable of utilizing the full resolution of each terminal.
104
\*(Nr is the same program as \*(TR; in fact, on Plan 9 
105
\*(NR is a shell script that calls \*(TR with the
106
.CW -N
107
argument.
108
.SH
109
Background to the Plan 9 Edition
110
.PP
111
The primary change to \*(TR and \*(NR for Plan 9 is
112
support of the Unicode Standard, which was added during
113
1992 and 1993.  There are two results.  First, there is much
114
less need for the myriad of two-character names that are so
115
much a part of \*(TR lore; in Plan 9, for example, one naturally uses the
116
Unicode character ½ instead of \*(TR\|'s
117
.CW \\e(12 .
118
Second, the output device, though called
119
.CW utf ,
120
is almost always a form of PostScript printer;
121
the panoply of special drivers for different typesetters
122
has largely disappeared.
123
Unfortunately, not all PostScript printers can cope
124
with Unicode characters, so there remains a need for
125
programs that synthesize PostScript characters from bitmaps;
126
this is especially true for Asian languages.
127
.SH
128
Background to the Second Edition
129
.PP
130
\*(Tr
131
was originally written by the late Joe Ossanna
132
in about 1973, in assembly language for the
133
.UC PDP -11,
134
to drive the Graphic Systems CAT typesetter.
135
It was rewritten in C around 1975,
136
and underwent slow but steady evolution until
137
Ossanna's death late in 1977.
138
.PP
139
In 1979, Brian Kernighan
140
modified
141
\*(TR
142
so that it would produce output for a variety of typesetters,
143
while retaining its input specifications.
144
Over the decade from 1979 to 1989,
145
the internals
146
have been modestly revised,
147
though much of the code remains as it was when Ossanna wrote it.
148
.PP
149
\*(Tr
150
reads parameter files
151
each time it is invoked, to
152
set values for machine resolution,
153
legal type sizes and fonts, and character names,
154
character widths
155
and the like.
156
\*(Tr
157
output is
158
.UC ASCII
159
characters
160
in a simple language
161
that describes where each character is to be placed
162
and in what size and font.
163
A post-processor must be written for each device
164
to convert this typesetter-independent language
165
into specific instructions for that device.
166
.PP
167
The output language contains information that was not readily
168
identifiable in the older output.
169
In the newer language, the beginning of each page, line, and word
170
is marked,
171
so post-processors can do device-specific optimizations
172
such as sorting the data vertically or printing it boustrophedonically,
173
independent of
174
\*(TR.
175
.PP
176
Capabilities for graphics have been added:
177
\*(TR
178
recognizes commands for drawing diagonal lines,
179
circles, ellipses, circular arcs,
180
and quadratic B-splines.
181
There are also ways to pass arbitrary information to the output,
182
unprocessed by
183
\*(TR.
184
.PP
185
A number of limitations have been eased or eliminated.
186
A document may have an arbitrary number of fonts on any page
187
(if the output device permits it, of course).
188
Fonts may be accessed merely by naming them;
189
``mounting'' is no longer necessary.
190
There are no limits on the number of characters.
191
\H'8'Character height\H'10' and \S'-1'sl\S'0'a\S'1'nt\S'0' may be set
192
independently of width.
193
.PP
194
The remainder of this document contains a description of
195
usage and command-line options;
196
a summary of requests, escape sequences, and pre-defined number registers;
197
a reference manual;
198
tutorial examples;
199
and a list of commonly-available characters.
200
.SH
201
Acknowledgements
202
.PP
203
Joe Ossanna's
204
\*(TR
205
remains a remarkable accomplishment.
206
For more than twenty years, it has proven a robust tool,
207
taking unbelievable abuse from a variety of preprocessors
208
and being forced into uses that were never conceived of
209
in the original design,
210
all with considerable grace under fire.
211
.PP
212
Recent versions of \*(TR have profited from
213
significant code improvements by
214
Jaap Akkerhuis, Dennis Ritchie, Ken Thompson, and Molly Wagner.
215
UTF facilities owe much to Jaap Akkerhuis.
216
Andrew Hume, Doug McIlroy, Peter Nelson and Ravi Sethi made valuable suggestions on the manual.
217
I fear that the remaining bugs are my fault.
218
.sp 100
219
.BP
220
.TL
221
Usage
222
.SP
223
.PP
224
\*(Tr or \*(NR is invoked as
225
.P1
226
troff  \fIoptions  files\fP
227
nroff  \fIoptions  files\fP
228
.P2
229
where @options@ represents any of a number of option arguments
230
and @files@ represents the list of files containing the document
231
to be formatted.
232
An argument consisting of a single minus
233
.CW - ' `
234
represents standard input.
235
If no filenames are given input is taken from the standard input.
236
The options, which may appear in any order so long as they appear
237
before the files, are:
238
.TS
239
center;
240
lfCW lw(4.5i).
241
-m@name@	T{
242
Read the macro file
243
@cw /sys/lib/tmac. name@
244
before the input @files@.
245
T}
246
-T@name@	T{
247
Specifies
248
the type of the output device.
249
Specific devices are site-dependent.
250
For
251
\*(TR,
252
the most useful name is
253
.CW utf .
254
For
255
\*(NR,
256
useful names include
257
@cw "37"@ for the (default) Model 37 Teletype,
258
@cw lp@ for ``dumb'' line printer terminals (no half-line motions,
259
no reverse motions),
260
and @cw think@ for the HP ThinkJet printer.
261
T}
262
-i	T{
263
Read standard input after the input files are exhausted.
264
T}
265
-o@list@	T{
266
Print only pages whose page numbers appear in @list@,
267
which consists of comma-separated numbers and number ranges.
268
A number range has the form @N-M@
269
and means pages @N@ through @M@;
270
a initial @-N@ means
271
from the beginning to page @N@; and a final @N-@ means
272
from @N@ to the end.
273
T}
274
-n@N@	T{
275
Number first generated page @N@.
276
T}
277
-r@aN@	T{
278
Set number register @a@ (one-character) to @N@.
279
T}
280
-s@N@	T{
281
Stop every @N@ pages.
282
\*(Nr will halt prior to every @N@ pages (default @N=1@)
283
to allow paper loading or
284
changing, and will resume upon receipt of a newline.
285
\*(Tr will include a ``pause'' code every @N@ pages;
286
its meaning, if any, depends on the output device.
287
T}
288
-u@N@	T{
289
Set amount of emboldening for the
290
.CW bd
291
request to @N@.
292
T}
293
-F@path@	T{
294
Look in directory @path@ for font information;
295
the defaults are
296
.CW /sys/lib/troff/font
297
and
298
.CW /sys/lib/troff/term
299
for \*(TR
300
and \*(NR respectively.
301
T}
302
.sp .5
303
	T{
304
                  \*(TR Only
305
T}
306
-a	T{
307
Send a printable approximation
308
of the results to the standard output.
309
T}
310
.sp .5
311
	T{
312
                  \*(NR Only
313
T}
314
-e	T{
315
Produce equally-spaced words in adjusted
316
lines, using full terminal resolution.
317
T}
318
-h	T{
319
Use tabs instead of spaces
320
to speed up printing.
321
T}
322
-q	T{
323
Invoke the simultaneous input-output mode of the @cw rd@ request.
324
T}
325
.TE
326
.PP
327
Each option is a separate argument;
328
for example,
329
.P1
330
troff -Tutf -ms -mpictures -o4,6,8-10 \f2file1 file2\fP
331
.P2
332
requests formatting of pages 4, 6, and 8 through 10 of a document contained in the files
333
named \f2file1\fP and \f2file2\fP,
334
specifies the output in UTF,
335
and invokes the macro packages
336
.CW -ms
337
and
338
.CW -mpictures .
339
.PP
340
Various pre- and post-processors are available for use with \*(NR and \*(TR.
341
These include the equation preprocessor
342
.I eqn
343
(for \*(TR only),
344
the table-construction preprocessor
345
.I tbl ,
346
and
347
.I pic 
348
and
349
.I grap
350
for various forms of graphics.
351
.sp 100
352
.BP
353
.TL
354
Request Summary
355
.PP
356
In the following table,
357
the notation @+- N@ in the
358
.BI "Request Form
359
column means that the forms @N@, @+N@, or @-N@ are permitted,
360
to set the parameter to @N@, increment it by @N@, or decrement it by @N@,
361
respectively.
362
Plain @N@ means that the value is used to set the parameter.
363
.BI "Initial Values
364
separated by 
365
.CW ;
366
are for
367
\*(TR
368
and
369
\*(NR
370
respectively.
371
In the 
372
.BI Notes
373
column,
374
.TS
375
center;
376
c lw(4.5i).
377
B	T{
378
Request normally causes a break.
379
The use of
380
.CW ' \&
381
as control character (instead of
382
.CW . )\&
383
suppresses the break function.
384
T}
385
D	T{
386
Mode or relevant parameters associated with current diversion level.
387
T}
388
E	T{
389
Relevant parameters are a part of the current environment.
390
T}
391
O	T{
392
Must stay in effect until logical output.
393
T}
394
P	T{
395
Mode must be still or again in effect at the time of physical output.
396
T}
397
T	T{
398
\*(TR only; no effect in \*(NR.
399
T}
400
@bold v@, @bold p@, @bold m@, @bold u@	T{
401
Default scale indicator; if not specified, scale indicators are ignored.
402
T}
403
.TE
404
.sp
405
.tr &.
406
.ps 9
407
.vs 11
408
.nr z 0 1
409
.TS
410
lf2 lf2 lf2 lf2 lf2
411
lf2 lf2 lf2 lf2 lf2
412
lfCW l l l l.
413
Request	Initial	If No
414
Form	Value	Argument	Notes	Explanation
415
.sp .5
416
.T&
417
lf3 s s s s.
418
\\n+z.  General Information
419
.sp .5
420
.T&
421
lf3 s s s s
422
lfCW l l l l.
423
\\n+z.  Font and Character Size Control
424
.sp .5
425
&ps @+- N@	10 point	previous	E,T	Point size; also @cw "\es" +- N@.
426
&ss @N@	12/36\fBm\fP	ignored	E,T	Space-character size set to @N/36@ em.
427
&cs @ F~N~ M@	off	-	P,T	Constant character space (width) mode (font @F@).
428
&bd @F~N@	off	-	P,T	Embolden font @F@ by @N-1@ units.
429
&bd S@~F~N@	off	-	P,T	Embolden Special Font when current font is @F@.
430
&ft@~F@	Roman	previous	E	Change to font @F@; also @cw "\ef" x@, @cw "\ef(" xx@, @cw "\ef" N@.
431
&fp@~N~F~L@	R,I,B,...,S	ignored	-	Mount font named @F@ on physical position @N <= 1@;
432
				  long name is @L@ if given.
433
.sp .5
434
.T&
435
lf3 s s s s
436
lfCW l l l l.
437
\\n+z.  Page Control
438
&pl @+- N@	11i	11i	@bold v@	Page length.
439
&bp @+- N@	@N=1@	-	B,@bold v@	Eject current page; next page number @N@.
440
&pn @+- N@	@N=1@	ignored	-	Next page number @N@.
441
&po @+- N@	1i; 0	previous	@bold v@	Page offset.
442
&ne @N@	-	@N=1 roman v@	D,@bold v@	Need @N@ vertical space.
443
&mk @R@	none	internal	D	Mark current vertical place in register @R@.
444
&rt @+- N@	none	internal	D,@bold v@	Return (upward only) to marked vertical place.
445
.sp .5
446
.T&
447
lf3 s s s s
448
lfCW l l l l.
449
\\n+z.  Text Filling, Adjusting, and Centering
450
&br	-	-	B	Break.
451
&fi	fill	-	B,E	Fill output lines.
452
&nf	fill	-	B,E	No filling or adjusting of output lines.
453
&ad @c@	adj, both	adjust	E	Adjust output lines with mode @c@;  @c = cw l , cw r , cw c , cw b , none@
454
&na	adjust	-	E	No output line adjusting.
455
&ce @N@	off	@N=1@	B,E	Center next @N@ input text lines.
456
.sp .5
457
.T&
458
lf3 s s s s
459
lfCW l l l l.
460
\\n+z.  Vertical Spacing
461
&vs @N@	12p; 1/6i	previous	E,@bold p@	Vertical baseline spacing (@V@).
462
&ls @N@	@N=1@	previous	E	Output @N-1@ @bold v@'s after each text output line.
463
&sp @N@	-	@N=1@v	B,@bold v@	Space vertical distance @N@ in either direction.
464
&sv @N@	-	@N=1@v	@bold v@	Save vertical distance @N@.
465
&os	-	-	-	Output saved vertical distance.
466
&ns	space	-	D	Turn no-space mode on.
467
&rs	-	-	D	Restore spacing; turn no-space mode off.
468
.sp .5
469
.T&
470
lf3 s s s s
471
lfCW l l l l.
472
\\n+z.  Line Length and Indenting
473
&ll @+- N@	6.5i	previous	E,@bold m@	Line length.
474
&in @+- N@	@N=0@	previous	B,E,@bold m@	Indent.
475
&ti @+- N@	-	ignored	B,E,@bold m@	Temporary indent.
476
.sp .5
477
.ne 2.1
478
.T&
479
lf3 s s s s
480
lfCW l l l l.
481
\\n+z.  Macros, Strings, Diversion, and Position Traps
482
&de @xx~yy@	-	@.yy= cw ".."@	-	Define or redefine macro @xx@; end at call of @yy@.
483
&am @xx~yy@	-	@.yy= cw ".."@	-	Append to a macro.
484
&ds @xx~string@	-	ignored	-	Define a string @xx@ containing @string@.
485
&as @xx~string@	-	ignored	-	Append @string@ to string @xx@.
486
&rm @xx@	-	ignored	-	Remove request, macro, or string.
487
&rn @xx~yy@	-	ignored	-	Rename request, macro, or string @xx@ to @yy@.
488
&di @xx@	-	end	D	Divert output to macro @xx@.
489
&da @xx@	-	end	D	Divert and append to @xx@.
490
&wh @N~xx@	-	-	@bold v@	Set location trap; negative is w.r.t. page bottom.
491
&ch @xx~N@	-	-	@bold v@	Change trap location.
492
&dt @N~xx@	-	off	D,@bold v@	Set a diversion trap.
493
&it @N~xx@	-	off	E	Set an input-line count trap.
494
&em @xx@	none	none	-	End macro is @xx@.
495
.sp .5
496
.T&
497
lf3 s s s s
498
lfCW l l l l.
499
\\n+z.  Number Registers
500
&nr @R~+- N~M@		-	@bold u@	Define and set number register @R@;
501
				  auto-increment by @M@.
502
&af @R~c@	arabic	-	-	Assign format to register @R@ (@c= cw "1" , cw i , cw I , cw a , cw A@).
503
&rr @R@	-	-	-	Remove register @R@.
504
.sp .5
505
.T&
506
lf3 s s s s
507
lfCW l l l l.
508
\\n+z.  Tabs, Leaders, and Fields
509
&ta@~Nt~. . .@	0.5i; 0.8n	none	E,@bold m@	Tab settings; left-adjusting, unless
510
				  @t= cw R@ (right), @cw C@ (centered).
511
&tc@~c@	none	none	E	Tab repetition character.
512
&lc@~c@	@cw "."@	none	E	Leader repetition character.
513
&fc@~a~b@	off	off	-	Set field delimiter @a@ and pad character @b@.
514
.sp .5
515
.T&
516
lf3 s s s s
517
lfCW l l l l.
518
\\n+z.  Input and Output Conventions and Character Translations
519
&ec@~c@	\e	\e	-	Set escape character.
520
&eo	on	-	-	Turn off escape character mechanism.
521
&lg@~N@	on; -	on	T	Ligature mode on if @N>0@.
522
&ul@~N@	off	@N=1@	E	Underline (italicize in \*(TR\^) @N@ input lines.
523
&cu@~N@	off	@N=1@	E	Continuous underline in \*(NR; in \*(TR, like @cw ul@.
524
&uf@~F@	Italic	Italic	-	Underline font set to @F@ (to be switched to by @cw ul@).
525
&cc@~c@	@cw .@	@cw .@	E	Set control character to @c@.
526
&c2@~c@	@cw "'"@	@cw "'"@	E	Set no-break control character to @c@.
527
&tr@~abcd....@	none	-	O	Translate @a@ to @b@, etc., on output.
528
.sp .5
529
.T&
530
lf3 s s s s.
531
\\n+z.  Local Horizontal and Vertical Motions, and the Width Function
532
.sp .5
533
.T&
534
lf3 s s s s.
535
\\n+z.  Overstrike, Bracket, Line-drawing, Graphics, and Zero-width Functions
536
.sp .5
537
.T&
538
lf3 s s s s
539
lfCW l l l l.
540
\\n+z.  Hyphenation.
541
&nh	hyphenate	-	E	No hyphenation.
542
&hy@~N@	hyphenate	hyphenate	E	Hyphenate; @N =@ mode.
543
&hc@~c@	@cw "\e%"@	@cw "\e%"@	E	Hyphenation indicator character @c@.
544
&hw@~word~. . .@		ignored	-	Add words to hyphenation dictionary.
545
.sp .5
546
.T&
547
lf3 s s s s
548
lfCW l l l l.
549
\\n+z.  Three-Part Titles.
550
&tl@~'l'c'r'@		-	-	Three-part title; delimiter may be any character.
551
&pc@~c@	@cw %@	off	-	Page number character.
552
&lt@~+- N@	6.5i	previous	E,@bold m@	Length of title.
553
.sp .5
554
.T&
555
lf3 s s s s
556
lfCW l l l l.
557
\\n+z.  Output Line Numbering.
558
&nm@~+- N^M^S^I@		off	E	Number mode on or off, set parameters.
559
&nn@~N@	-	@N=1@	E	Do not number next @N@ lines.
560
.sp .5
561
.ne 2
562
.T&
563
lf3 s s s s
564
lfCW l l l l.
565
\\n+z.  Conditional Acceptance of Input
566
&if@~c~any@		-	-	If condition @c@ true, accept @any@ as input;
567
				  for multi-line, use @cw "\e{" any cw "\e}"@.
568
&if !@c~any@		-	-	If condition @c@ false, accept @any@.
569
&if@~N~any@		-	@bold u@	If expression @N > 0@, accept @any@.
570
&if !@N~any@		-	@bold u@	If expression @N <= 0@ [sic], accept @any@.
571
&if@~ 's1 's2 '~any@		-	-	If string @s1@ identical to @s2@, accept @any@.
572
&if !@ 's1 's2 '~any@		-	-	If string @s1@ not identical to @s2@, accept @any@.
573
&ie@~c~any@		-	@bold u@	If portion of if-else; all above forms (like @cw "if"@).
574
&el@~any@		-	-	Else portion of if-else.
575
.sp .5
576
.T&
577
lf3 s s s s
578
lfCW l l l l.
579
\\n+z.  Environment Switching
580
&ev@~N@	@N=0@	previous	-	Environment switch (push down).
581
.sp .5
582
.T&
583
lf3 s s s s
584
lfCW l l l l.
585
\\n+z.  Insertions from the Standard Input
586
&rd@~prompt@	-	@prompt@=\s-1BEL\s+1	-	Read insertion.
587
&ex	-	-	-	Exit.
588
.sp .5
589
.T&
590
lf3 s s s s
591
lfCW l l l l.
592
\\n+z.  Input/Output File Switching
593
&so@~filename@		-	-	Switch source file (push down).
594
&nx@~filename@		end-of-file	-	Next file.
595
&sy@~string@		-	-	Execute program @string@.  Output not interpolated.
596
&pi@~string@		-	-	Pipe output to program @string@.
597
&cf@~filename@		-	-	Copy file contents to \*(TR output.
598
.sp .5
599
.T&
600
lf3 s s s s
601
lfCW l l l l.
602
\\n+z.  Miscellaneous
603
&mc@~c~N@	-	off	E,@bold m@	Set margin character @c@ and separation @N@.
604
&tm@~string@	-	newline	-	Print @string@ on terminal (standard error).
605
&ab@~string@	-	newline	-	Print @string@ on standard error, exit program.
606
&ig@~yy@	-	@.yy= cw ".."@	-	Ignore input until call of @yy@.
607
&lf@~N ~f@		-	-	Set input line number to @N@ and filename to @f@.
608
&pm@~t@	-	all	-	Print macro names, sizes; if @t@ present, print total.
609
&fl	-	-	B	Flush output buffer.
610
.sp .5
611
.T&
612
lf3 s s s s.
613
\\n+z.  Output and Error Messages
614
.sp .5
615
\\n+z.  Output Language
616
.sp .5
617
\\n+z.  Device and Font Description Files
618
.TE
619
.br
620
.nr zz 9
621
.de cl
622
.ie \\n+(cl<\n(zz \{\
623
.	po +\\n(.lu/\n(zzu
624
.	rt\}
625
.el \{.po 1i\}
626
..
627
.nr cl 0 1
628
.di zz
629
.ta .45iR
630
... was .35
631
.nf
632
.ps 9
633
.vs 10.5
634
\f(CWab\fP	20
635
\f(CWad\fP	4
636
\f(CWaf\fP	8
637
\f(CWam\fP	7
638
\f(CWas\fP	7
639
\f(CWbd\fP	2
640
\f(CWbp\fP	3
641
\f(CWbr\fP	4
642
\f(CWc2\fP	10
643
\f(CWcc\fP	10
644
\f(CWce\fP	4
645
\f(CWcf\fP	19
646
\f(CWch\fP	7
647
\f(CWcs\fP	2
648
\f(CWcu\fP	10
649
\f(CWda\fP	7
650
\f(CWde\fP	7
651
\f(CWdi\fP	7
652
\f(CWds\fP	7
653
\f(CWdt\fP	7
654
\f(CWec\fP	10
655
\f(CWel\fP	16
656
\f(CWem\fP	7
657
\f(CWeo\fP	10
658
\f(CWev\fP	17
659
\f(CWex\fP	18
660
\f(CWfc\fP	9
661
\f(CWfi\fP	4
662
\f(CWfl\fP	20
663
\f(CWfp\fP	2
664
\f(CWft\fP	2
665
\f(CWhc\fP	13
666
\f(CWhw\fP	13
667
\f(CWhy\fP	13
668
\f(CWie\fP	16
669
\f(CWif\fP	16
670
\f(CWig\fP	20
671
\f(CWin\fP	6
672
\f(CWit\fP	7
673
\f(CWlc\fP	9
674
\f(CWlg\fP	10
675
\f(CWlf\fP	20
676
\f(CWll\fP	6
677
\f(CWls\fP	5
678
\f(CWlt\fP	14
679
\f(CWmc\fP	20
680
\f(CWmk\fP	3
681
\f(CWna\fP	4
682
\f(CWne\fP	3
683
\f(CWnf\fP	4
684
\f(CWnh\fP	13
685
\f(CWnm\fP	15
686
\f(CWnn\fP	15
687
\f(CWnr\fP	8
688
\f(CWns\fP	5
689
\f(CWnx\fP	19
690
\f(CWos\fP	5
691
\f(CWpc\fP	14
692
\f(CWpi\fP	19
693
\f(CWpl\fP	3
694
\f(CWpm\fP	20
695
\f(CWpn\fP	3
696
\f(CWpo\fP	3
697
\f(CWps\fP	2
698
\f(CWrd\fP	18
699
\f(CWrm\fP	7
700
\f(CWrn\fP	7
701
\f(CWrr\fP	8
702
\f(CWrs\fP	5
703
\f(CWrt\fP	3
704
\f(CWso\fP	19
705
\f(CWsp\fP	5
706
\f(CWss\fP	2
707
\f(CWsv\fP	5
708
\f(CWsy\fP	19
709
\f(CWta\fP	9
710
\f(CWtc\fP	9
711
\f(CWti\fP	6
712
\f(CWtl\fP	14
713
\f(CWtm\fP	20
714
\f(CWtr\fP	10
715
\f(CWuf\fP	10
716
\f(CWul\fP	10
717
\f(CWvs\fP	5
718
\f(CWwh\fP	7
719
.di
720
.nr aa \n(dn/\n(zz
721
.ne \\n(aau+10p
722
.sp
723
.SP 2
724
.TL
725
Alphabetical Request and Section Number Cross Reference
726
.SP .5
727
.LP
728
.sp .5
729
.nf
730
.wh \n(nlu+\n(aau cl
731
.nr qq \n(nlu+\n(aau
732
.ps
733
.vs
734
.mk
735
.zz
736
.rt
737
.sp \n(.tu
738
.ch cl 12i
739
.sp 100
740
.BP
741
.TL
742
Escape Sequences for Characters, Indicators, and Functions
743
.SP .5
744
.LP
745
.ps -1
746
.vs -1
747
.TS
748
center;
749
c2 l
750
c2 l2 l
751
n2 l2fCW l.
752
.ft 4
753
Section	Escape
754
Reference	Sequence	Meaning
755
.ft
756
.sp .5
757
10.1	\e\e	\&\f(CW\e\fP prevents or delays the interpretation of \&\f(CW\e\fP
758
10.1	\ee	Printable version of the current escape character.
759
2.1	\e'	\' (acute accent); equivalent to \&\f(CW\e(aa\fP
760
2.1	\e`	\` (grave accent); equivalent to \&\f(CW\e(ga\fP
761
2.1	\e\-	\- Minus sign in the current font
762
7.	\e\^.	Period (dot) (see \&\f(CWde\fP)
763
11.1	\e\f2space\fP	Unpaddable space-size space character
764
11.1	\e0	Digit width space
765
11.1	\e|	1/6 em narrow space character (zero width in \*(NR\^)
766
11.1	\e^	1/12 em half-narrow space character (zero width in \*(NR\^)
767
.tr &&
768
4.1	\e&	Non-printing, zero width character
769
.tr &.
770
10.6	\e!	Transparent line indicator
771
10.8	\e"	Beginning of comment; continues to end of line
772
13.	\e%	Default optional hyphenation character
773
2.1	\e(@xx@	Character named @xx@
774
7.1	\e*@x,~@\e*(@xx@	Interpolate string @x@ or @xx@
775
7.3	\e$@N@	Interpolate argument @1 <= N <= 9@
776
9.1	\ea	Non-interpreted leader character
777
12.3	\eb'@abc...@'	Bracket building function
778
4.2	\ec	Connect to next input text
779
2.1	\eC'@xyz@'	Character named @xyz@
780
11.1	\ed	Downward 1/2 em vertical motion (1/2 line in \*(NR\^)
781
12.5	\eD'@c...@'	Draw graphics function @c@ with parameters @. . .@; @c= cw l , cw c , cw e , cw a , cw "~"@
782
2.2	\ef@x,~@\ef(@xx,~@\ef@N@	Change to font named @x@ or @xx@, or position @N@
783
8.	\eg@x,~@\eg(@xx@	Format of number register @x@ or @xx@
784
11.1	\eh'@N@'	Local horizontal motion; move right @N@ (negative left)
785
2.3	\eH'@N@'	Height of current font is @N@
786
11.3	\ek@x@	Mark horizontal input place in register @x@
787
12.4	\el'@Nc@'	Horizontal line drawing function (optionally with @c@ )
788
12.4	\eL'@Nc@'	Vertical line drawing function (optionally with @c@ )
789
8.	\en@x,~@\en(@xx@	Contents of number register @x@ or @xx@
790
2.1	\eN'@N@'	Character number @N@ on current font
791
12.1	\eo'@abc...@'	Overstrike characters @a,~ b,~ c@, ...
792
4.1	\ep	Break and spread output line
793
11.1	\er	Reverse 1 em vertical motion (reverse line in \*(NR\^)
794
2.3	\es@N,~@\es@+- N@	Point-size change function; also @cw "\es(" nn@, @cw "\es" +- cw "(" nn@
795
2.2	\eS'@N@'	Slant output @N@ degrees
796
9.1	\et	Non-interpreted horizontal tab
797
11.1	\eu	Reverse (up) 1/2 em vertical motion (1/2 line in \*(NR\^)
798
11.1	\ev'@N@'	Local vertical motion; move down N (negative up)
799
11.2	\ew'@string@'	Width of @string@
800
5.2	\ex'@N@'	Extra line-space function (negative before, positive after)
801
10.7	\eX'@string@'	Output @string@ as device control function
802
12.2	\ez@c@	Print @c@ with zero width (without spacing)
803
16.	\e{	Begin conditional input
804
16.	\e}	End conditional input
805
10.8	\e@newline@	Concealed (ignored) newline
806
-	\e@Z@	@Z@, any character not listed above
807
.TE
808
.ps +1
809
.vs +1
810
.LP
811
The escape sequences
812
.CW \e\e ,
813
.CW \e\^. ,
814
.CW \e" ,
815
.CW \e$ ,
816
.CW \e* ,
817
.CW \ea ,
818
.CW \en ,
819
.CW \et ,
820
.CW \eg ,
821
and
822
.CW \e@newline@
823
are interpreted in copy mode (§7.2).
824
.SP .5i
825
\0
826
.sp 100
827
.BP
828
.TL
829
Predefined Number Registers
830
.LP
831
.ps -1
832
.vs -1
833
.TS
834
c2l
835
c2 l2 l
836
n2 l2fCW l.
837
.ft 4
838
Section	Register
839
Reference	Name	Description
840
.ft
841
.sp .5
842
3.	%	Current page number.
843
11.2	ct	Character type (set by \&\f(CW\ew\fP function).
844
7.4	dl	Width (maximum) of last completed diversion.
845
7.4	dn	Height (vertical size) of last completed diversion.
846
-	dw	Current day of the week (1-7).
847
-	dy	Current day of the month (1-31).
848
15.	ln	Output line number.
849
-	mo	Current month (1-12).
850
4.1	nl	Vertical position of last printed text baseline.
851
11.2	sb	Depth of string below baseline (generated by \&\f(CW\ew\fP function).
852
11.2	st	Height of string above baseline (generated by \&\f(CW\ew\fP function).
853
-	yr	Last two digits of current year.
854
.TE
855
.ps +1
856
.vs +1
857
 
858
 
859
.TL
860
Predefined Read-Only Number Registers
861
.LP
862
.ps -1
863
.vs -1
864
.TS
865
c2 l
866
c2 l2 l
867
n2 l2fCW l.
868
.ft 4
869
Section	Register
870
Reference	Name	Description
871
.ft
872
.sp .5
873
19.	$$	Process id of \*(TR or \*(NR.
874
7.3	&$	Number of arguments available at the current macro level.
875
5.2	&a	Post-line extra line-space most recently used in @cw "\ex'" N cw "'" @.
876
-	&A	Set to 1 in \*(TR, if @cw -a@ option used; always 1 in \*(NR.
877
2.3	&b	Emboldening level.
878
20.	&c	Number of lines read from current input file.
879
7.4	&d	Current vertical place in current diversion; equal to @cw nl@, if no diversion.
880
2.2	&f	Current font number.
881
20.	&F	Current input file name [sic].
882
4.	&h	Text baseline high-water mark on current page or diversion.
883
11.1	&H	Available horizontal resolution in basic units.
884
6.	&i	Current indent.
885
4.2	&j	Current @cw ad@ mode.
886
4.1	&k	Current output horizontal position.
887
6.	&l	Current line length.
888
5.1	&L	Current @cw ls@ value.
889
4.	&n	Length of text portion on previous output line.
890
3.	&o	Current page offset.
891
3.	&p	Current page length.
892
7.5	.R	Number of unused number registers.
893
-	&T	Set to 1 in \*(NR, if \&\f(CW-T\fP option used; always 0 in \*(TR.
894
2.3	&s	Current point size.
895
7.5	&t	Distance to the next trap.
896
4.1	&u	Equal to 1 in fill mode and 0 in nofill mode.
897
5.1	&v	Current vertical line spacing.
898
11.1	&V	Available vertical resolution in basic units.
899
11.2	&w	Width of previous character.
900
-	&x	Reserved version-dependent register.
901
-	&y	Reserved version-dependent register.
902
7.4	&z	Name [sic] of current diversion.
903
.TE
904
.ps +1
905
.vs +1
906
.sp 100
907
.BP
908
.TL
909
Reference Manual
910
.NH
911
General Explanation
912
.sc "Form of input.
913
Input consists of \fItext lines\fR, which are destined to be printed,
914
interspersed with \fIcontrol lines\fR,
915
which set parameters or otherwise control subsequent processing.
916
Control lines begin with a \fIcontrol character\fR\(em\
917
normally \&\f(CW.\fR (period) or \&\f(CW'\fR (single quote)\(em\
918
followed by a one or two character name that specifies
919
a basic \fIrequest\fR or the substitution of
920
a user-defined \fImacro\fR in place of the control line.
921
The control character \&\f(CW'\fR suppresses the \fIbreak\fR function\(em\
922
the forced output of a partially filled line\(em\
923
caused by certain requests.
924
The control character may be separated from the request/macro name by
925
white space (spaces and/or tabs) for aesthetic reasons.
926
Names should be followed by either
927
space or newline.
928
Control lines with unrecognized names are ignored.
929
.PP
930
Various special functions may be introduced anywhere in the input by
931
means of an \fIescape\fR character, normally \&\f(CW\e\fR.
932
For example, the function
933
.CW \en@R@
934
causes the interpolation of the contents of the
935
\fInumber register R\fR
936
in place of the function;
937
here @R@ is either a single character name
938
as in \&\f(CW\en\fIx\fR,
939
or a two-character name introduced by
940
a left-parenthesis, as in \&\f(CW\en(\fIxx\fR.
941
.sc "Formatter and device resolution.
942
\*(Tr internally stores and processes dimensions in units that correspond to
943
the particular device for which output is being prepared;
944
values from 300 to 1200/inch are typical.
945
See §23.
946
\*(Nr internally uses 240 units/inch,
947
corresponding to the least common multiple of the
948
horizontal and vertical resolutions of various
949
typewriter-like output devices.
950
\*(Tr rounds horizontal/vertical numerical parameter input to the actual
951
horizontal/vertical resolution of the output device indicated by the \&\f(CW-T\fR option
952
(default
953
.CW post ).
954
\*(Nr similarly rounds numerical input to the actual resolution
955
of its output device
956
(default Model 37 Teletype).
957
.sc "Numerical parameter input.
958
Both \*(NR and \*(TR
959
accept numerical input with the appended scale
960
indicators
961
shown in the following table,
962
where
963
\fIS\fR is the current type size in points and
964
\fIV\fR is the current vertical line spacing in
965
basic units.
966
.TS
967
center box;
968
c|c
969
c|c
970
c|l.
971
Scale
972
Indicator	Meaning
973
_
974
\&\f(CWi\fR	Inch
975
\&\f(CWc\fR	Centimeter
976
\&\f(CWP\fR	Pica = 1/6 inch
977
\&\f(CWm\fR	Em = \fIS\fR points
978
\&\f(CWn\fR	En = Em/2
979
\&\f(CWp\fR	Point = 1/72 inch
980
\&\f(CWu\fR	Basic unit
981
\&\f(CWv\fR	Vertical line space \fIV\fR
982
none	Default, see below
983
.TE
984
In \*(NR, both the em and the en are taken to be equal to the
985
nominal character width,
986
which is output-device dependent;
987
common values are 1/10 and 1/12 inch.
988
Actual character widths in \*(NR need not be all the same and constructed characters
989
such as -> (→) are often extra wide.
990
The default scaling is
991
.CW m
992
for the horizontally-oriented requests
993
and functions
994
.CW ll ,
995
.CW in ,
996
.CW ti ,
997
.CW ta ,
998
.CW lt ,
999
.CW po ,
1000
.CW mc ,
1001
.CW \eh ,
1002
.CW \el ,
1003
and horizontal coordinates of
1004
.CW \eD ;
1005
.CW v
1006
for the vertically-oriented requests and functions
1007
.CW pl ,
1008
.CW wh ,
1009
.CW ch ,
1010
.CW dt ,
1011
.CW sp ,
1012
.CW sv ,
1013
.CW ne ,
1014
.CW rt ,
1015
.CW \ev ,
1016
.CW \ex ,
1017
.CW \eL ,
1018
and vertical coordinates of
1019
.CW \eD ;
1020
.CW p
1021
for the
1022
.CW vs
1023
request;
1024
and
1025
.CW u
1026
for the requests
1027
.CW nr ,
1028
.CW if ,
1029
and
1030
.CW ie .
1031
\fIAll\fR other requests ignore any scale indicators.
1032
When a number register containing an already appropriately scaled number
1033
is interpolated to provide numerical input,
1034
the unit scale indicator
1035
\&\f(CWu\fR may need to be appended to prevent
1036
an additional inappropriate default scaling.
1037
The number, @N@, may be specified in decimal-fraction form
1038
but the parameter finally stored is rounded to an integer number of basic units.
1039
Internal computations are performed in integer arithmetic.
1040
.PP
1041
The \fIabsolute position\fR indicator \&\f(CW|\fR may be prefixed
1042
to a number @N@
1043
to generate the distance to the vertical or horizontal place @N@.
1044
For vertically-oriented requests and functions, \&\f(CW|\fP@N@
1045
becomes the distance in basic units from the current vertical place on the page or in a \fIdiversion\fR (§7.4)
1046
to the vertical place @N@.
1047
For \fIall\fR other requests and functions,
1048
\&\f(CW|\fP@N@
1049
becomes the distance from
1050
the current horizontal place on the \fIinput\fR line to the horizontal place @N@.
1051
For example,
1052
.P1
1053
\&.sp |3.2c
1054
.P2
1055
will space in the required direction to 3.2 centimeters from the top of the page.
1056
.sc "Numerical expressions.
1057
.tr &&
1058
Wherever numerical input is expected,
1059
an expression involving parentheses,
1060
the arithmetic operators \&\f(CW+\fR, \&\f(CW-\fR, \&\f(CW/\fR, \&\f(CW\(**\fR, \&\f(CW%\fR (mod),
1061
and the logical operators
1062
\&\f(CW<\fR,
1063
\&\f(CW>\fR,
1064
\&\f(CW<=\fR,
1065
\&\f(CW>=\fR,
1066
\&\f(CW=\fR (or \&\f(CW==\fR),
1067
\&\f(CW&\fR\ (and),
1068
\&\f(CW:\fR\ (or)
1069
may be used.
1070
Except where controlled by parentheses, evaluation of expressions is left-to-right;
1071
there is no operator precedence.
1072
In the case of certain requests, an initial \&\f(CW+\fR or \&\f(CW-\fR is stripped
1073
and interpreted as an increment or decrement indicator respectively.
1074
In the presence of default scaling, the desired scale indicator must be
1075
attached to \fIevery\fR number in an expression
1076
for which the desired and default scaling differ.
1077
For example,
1078
if the number register \&\f(CWx\fR contains 2
1079
and the current point size is 10,
1080
then
1081
.P1
1082
\&.ll (4.25i+\enxP+3)/2u
1083
.P2
1084
will set the line length to 1/2 the sum of 4.25 inches + 2 picas + 3 ems.
1085
.sc "Notation.
1086
Numerical parameters are indicated in this manual in two ways.
1087
@+- N@ means that the argument may take the forms @N@, @+N@, or @-N@ and
1088
that the corresponding effect is to set the parameter
1089
to @N@, to increment it by @N@, or to decrement it by @N@ respectively.
1090
Plain @N@ means that an initial algebraic sign is \fInot\fR
1091
an increment indicator,
1092
but merely the sign of @N@.
1093
Generally, unreasonable numerical input is either ignored
1094
or truncated to a reasonable value.
1095
For example,
1096
most requests expect to set parameters to non-negative
1097
values;
1098
exceptions are
1099
.CW sp ,
1100
.CW wh ,
1101
.CW ch ,
1102
.CW nr ,
1103
and
1104
.CW if .
1105
The requests
1106
.CW ps ,
1107
.CW ft ,
1108
.CW po ,
1109
.CW vs ,
1110
.CW ls ,
1111
.CW ll ,
1112
.CW in ,
1113
and
1114
.CW lt 
1115
restore the previous parameter value in the absence
1116
of an argument.
1117
.PP
1118
Single character arguments are indicated by single lower case letters
1119
and
1120
one/two character arguments are indicated by a pair of lower case letters.
1121
Character string arguments are indicated by multi-character mnemonics.
1122
.NH
1123
Font and Character Size Control
1124
.sc "Character set.
1125
The \*(TR character set is defined by a description file specific to each output device (§23).
1126
There are normally several regular fonts and one or more special fonts.
1127
Characters are input as themselves,
1128
as @cw "\e(" xx@, as @cw "\eC'" name cw "'"@,
1129
or as 
1130
.CW \eN'@n@' .
1131
The form
1132
.CW \eC'@name@'
1133
permits a name of any length;
1134
the form
1135
.CW \eN'@n@'
1136
refers to the @n@-th character on the current font,
1137
whether named or not.
1138
.PP
1139
Normally the input characters
1140
.CW ` ,
1141
.CW ' ,
1142
and
1143
.CW -
1144
are printed as `, ', and - respectively;
1145
.CW \e` ,
1146
.CW \e' ,
1147
and
1148
.CW \e-
1149
produce \`, \', and \-.
1150
If the character does not exist in the font, \*(TR assumes the width is 1 em and
1151
outputs the character with a
1152
.CW C
1153
name as defined in Section 22.
1154
(This is independent of how the device handles characters unknown to it.)
1155
.PP
1156
\*(Nr has an analogous, but different, mechanism for defining legal characters
1157
and how to print them.
1158
By default all characters are valid.
1159
There are such
1160
additional characters as may be available on
1161
the output device,
1162
such characters as may be constructed
1163
by overstriking or other combination,
1164
and those that can reasonably be mapped
1165
into other printable characters.
1166
The exact behavior is determined by a driving
1167
table prepared for each device.
1168
.sc "Fonts.
1169
\*(Tr
1170
begins execution by reading information for a set of defaults fonts,
1171
said to be
1172
.I mounted ;
1173
conventionally, the first four are
1174
Times Roman (\&\f(CWR\fR),
1175
Times Italic
1176
(\&\f(CWI\fR),
1177
Times Bold
1178
(\&\f(CWB\fR),
1179
and
1180
Times Bold Italic
1181
(\&\f(CWBI\fR) ,
1182
and the last is a Special font
1183
.CW S ) (
1184
containing miscellaneous characters.
1185
(This document uses Lucida Sans in place of Times.)
1186
The set of fonts and positions is determined by the device description file,
1187
described in §23.
1188
.PP
1189
The current font, initially Roman, may be changed
1190
by the \&\f(CWft\fR request,
1191
or by embedding at any desired point
1192
\&\f(CW\ef\fIx\fR, \&\f(CW\ef(\fIxx\fR, or \&\f(CW\ef\fP@N@,
1193
where
1194
\fIx\fR and \fIxx\fR are the name of a font
1195
and @N@ is a numerical font position.
1196
.PP
1197
It is not necessary to change to the Special font;
1198
characters on that font are automatically handled
1199
as if they were physically part of the current font.
1200
The Special font may actually be several fonts;
1201
the name
1202
.CW S
1203
is reserved and is generally used for one of these.
1204
All special fonts must be mounted after regular fonts.
1205
.PP
1206
\*(Tr can be informed that any particular font is mounted
1207
by use of the \&\f(CWfp\fR request.
1208
The list of known fonts is installation dependent.
1209
In the subsequent discussion of font-related requests,
1210
@F@ represents either a one/two-character
1211
font name or the numerical font position.
1212
The current font is available (as a numerical position) in the read-only number register \&\f(CW.f\fR.
1213
.PP
1214
A request for a named but not-mounted font is honored
1215
if the font description information exists.
1216
In this way, there is no limit on the number of fonts that may be printed
1217
in any part of a document.
1218
Mounted fonts may be handled more efficiently,
1219
and they may be referred to by their mount positions,
1220
but there is no other difference.
1221
Mention of an unmounted font loads it temporarily at font position
1222
zero, which serves as a one-font cache.
1223
.PP
1224
The function
1225
.CW \eS'@+- N@'
1226
causes the current font to be slanted by
1227
@+- N@
1228
degrees.
1229
Not all devices support slanting.
1230
.PP
1231
\*(Nr understands font control
1232
and normally underlines italic characters (see §10.5).
1233
.sc "Character size.
1234
Character point sizes available depend on the specific output device;
1235
a typical (historical) set of values is
1236
6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 28, and 36.
1237
This is a range of 1/12 inch to 1/2 inch.
1238
The \&\f(CWps\fR request is used to change or restore the point size.
1239
Alternatively the point size may be changed between any two characters
1240
by embedding a
1241
.CW \es@N@
1242
at the desired point
1243
to set the size to @N@,
1244
or a
1245
.CW "\&\f(CW\es@+- N@
1246
(@1 <= N <= 9@)
1247
to increment/decrement the size by @N@;
1248
.CW \es0
1249
restores the previous size.
1250
Requested point size values that are between two valid
1251
sizes yield the larger of the two.
1252
.PP
1253
Note that through an accident of history, a construction like
1254
.CW \es39
1255
is parsed as size 39, and thus converted to size 36 (given the sizes above),
1256
while
1257
.CW \es40
1258
is parsed as size 4 followed by
1259
.CW 0 .
1260
The forms
1261
@cw "\es(" nn@ and @cw "\es" +- cw "(" nn@
1262
permit specification of sizes that would otherwise be ambiguous.
1263
.PP
1264
The current size is available in the \&\f(CW.s\fR register.
1265
\*(Nr ignores type size requests.
1266
.PP
1267
The function
1268
.CW "\eH'@+- N@'
1269
sets \H'+2'the height of the current font\H'0' to
1270
@N@, or increments it by @+N@, or decrements it by @-N@;
1271
if @N=0@, the height is restored to the current point size.
1272
In each case, the width is unchanged.
1273
Not all devices support independent height and width for characters.
1274
.FS
1275
*The fields have the same meaning as described earlier in the Request Summary.
1276
.FE
1277
.SP .5
1278
.LP
1279
.ne 2.1
1280
.ta 1.5i 2.5i 3.5i 4.5i
1281
\f2Request\fR	\f2Initial\fR	\f2If\ No\fR
1282
.br
1283
\f2Form\fR	\f2Value\fR	\f2Argument\fR	\f2Notes\fR
1284
.bt "\&\f(CW.ps\fI \(+-N\fR*" "10\|point" "previous" "E" "Point size
1285
set to @+- N@.
1286
Alternatively, embed
1287
.CW \es@N@
1288
or
1289
.CW "\&\f(CW\es@+- N@" .
1290
Any positive size value may be requested;
1291
if invalid, the next larger valid size will result, with a
1292
maximum of 36.
1293
A paired sequence
1294
@+N@, @-N@
1295
will work because the previous requested value is also remembered.
1296
Ignored in \*(NR.
1297
.bt "\&\f(CW.ss\fI N\fR" "12/36\|em" "ignored" "E" "Space-character size
1298
(i.e., inter-word gap)
1299
is set to @N@/36 ems.
1300
This size is the minimum word spacing in adjusted text.
1301
Ignored in \*(NR.
1302
.bt "\&\f(CW.cs\fI\|F\|N\|M\fR" "off" "-" "P" "Constant character space
1303
(width) mode is
1304
set on for font @F@ (if mounted); the width of every character will be
1305
taken to be @N@/36 ems.
1306
If @M@ is absent,
1307
the em is that of the character's point size;
1308
if @M@ is given,
1309
the em is @M@ points.
1310
All affected characters
1311
are centered in this space, including those with an actual width
1312
larger than this space.
1313
Special Font characters occurring while the current font
1314
is @F@ are also so treated.
1315
If @N@ is absent, the mode is turned off.
1316
The mode must be in effect when the characters are physically printed.
1317
Ignored in \*(NR.
1318
.bt "\&\f(CW.bd\fI F N\fR" "off" "-" "P" "The characters in font @F@ will be artificially
1319
emboldened by printing each one twice, separated by @N-1@ basic units.
1320
A reasonable value for @N@ is 3 when the character size is near 10 points.
1321
If @N@ is missing the embolden mode is turned off.
1322
The emboldening value @N@ is in the \&\f(CW.b\fP register.
1323
.IP
1324
.bd R 3
1325
This paragraph is printed with \&\f(CW.bd R 3\fR.
1326
The mode must be in effect when the characters are physically printed.
1327
Ignored in \*(NR.
1328
.br
1329
.bd R
1330
.bt "\&\f(CW.bd S \fIF N\fR" "off" "-" "P" "The characters in the Special font
1331
will be emboldened whenever the current font is @F@.
1332
The mode must be in effect when the characters are physically printed.
1333
Ignored in \*(NR.
1334
.bt "\&\f(CW.ft\fP @F@" "Roman" "previous" "E" "Font changed to
1335
@F@.
1336
Alternatively, embed
1337
.CW \ef@F@ .
1338
The font name \&\f(CWP\fR is reserved to mean the previous font,
1339
and the name
1340
.CW S
1341
for the special font.
1342
.bt "\&\f(CW.fp \fIN F L\fR" "R,I,B,...,S" "ignored" "-" "Font position.
1343
This is a statement
1344
that a font named @F@ is associated with position @N@.
1345
It is a fatal error if @F@ is not known.
1346
For fonts with names longer than two characters,
1347
.I L
1348
refers to the long name,
1349
and
1350
.I F
1351
becomes a synonym.
1352
There is generally a limit of about 10 mounted fonts.
1353
.NH
1354
Page control
1355
.PP
1356
Top and bottom margins are not automatically provided;
1357
it is conventional to define two \fImacros\fR and to set \fItraps\fR
1358
for them at vertical positions 0 (top) and @-N@ (distance @N@ up from the bottom).
1359
See §7 and Tutorial Examples §T2.
1360
A pseudo-page transition onto the first page occurs
1361
either when the first \fIbreak\fR occurs or
1362
when the first \fInon-diverted\fR text processing occurs.
1363
Arrangements
1364
for a trap to occur at the top of the first page
1365
must be completed before this transition.
1366
In the following, references to the \fIcurrent diversion\fR (§7.4)
1367
mean that the mechanism being described works during both
1368
ordinary and diverted output (the former considered as the top diversion level).
1369
.PP
1370
The limitations on \*(TR and \*(NR output dimensions
1371
are device dependent.
1372
.bt "\&\f(CW.pl\fI \(+-N\fR" "11\|in" "11\|in" "\fBv\fR" "Page length set to @+- N@.
1373
The current page length is available in the \&\f(CW.p\fR register.
1374
.bt "\&\f(CW.bp\fI \(+-N\fR" "\fIN\(eq\fR1" "-" "B,\fBv\fR" "Begin page.
1375
The current page is ejected and a new page is begun.
1376
If @+- N@ is given, the new page number will be @+- N@.
1377
Also see request \&\f(CWns\fR.
1378
.bt "\&\f(CW.pn\fI \(+-N\fR" "@N@\(eq1" "ignored" "-" "Page number.
1379
The next page (when it occurs) will have the page number @+- N@.
1380
A \&\f(CWpn\fR must occur before the initial pseudo-page transition
1381
to affect the page number of the first page.
1382
The current page number is in the \&\f(CW%\fR register.
1383
.bt "\&\f(CW.po\fI \(+-N\fR" "1\|in; 0" "previous" "\fBv\fR" "Page offset.
1384
The current \fIleft margin\fR is set to @+- N@.
1385
The \*(TR initial value provides 1 inch of paper margin
1386
on a typical device.
1387
The current page offset is available in the \&\f(CW.o\fR register.
1388
.bt "\&\f(CW.ne\fI N\fR" "-" "\fIN\(eq\fR1\|\fIV\fR" "D,\fBv\fR" "Need @N@ vertical space.
1389
If the distance \fID\fR to the next trap position (see §7.5) is less than @N@,
1390
a forward vertical space of size \fID\fR occurs,
1391
which will spring the trap.
1392
If there are no remaining
1393
traps on the page,
1394
\fID\fR is the distance to the bottom of the page.
1395
If @D<V@, another line could still be output
1396
and spring the trap.
1397
In a diversion, \fID\fR is the distance to the \fIdiversion trap\fR, if any,
1398
or is very large.
1399
.bt "\&\f(CW.mk\fI R\fR" "none" "internal" "D" "Mark the current vertical place
1400
in an internal register (both associated with the current diversion level),
1401
or in register @R@, if given.
1402
See \&\f(CWrt\fR request.
1403
.bt "\&\f(CW.rt\fI \(+-N\fR" "none" "internal" "D,\fBv\fR" "Return \fIupward only\fR to a marked vertical place
1404
in the current diversion.
1405
If @+- N@ (with respect to current place) is given,
1406
the place is @+- N@ from the top of the page or diversion
1407
or, if @N@ is absent, to a
1408
place marked by a previous \&\f(CWmk\fR.
1409
The \&\f(CWsp\fR request (§5.3) may be used
1410
instead of \&\f(CWrt\fR
1411
by spacing to the absolute place stored in a explicit register,
1412
e.g., using
1413
.CW ".mk
1414
@R@ ...\&
1415
.CW ".sp
1416
.CW |\en@R@u ;
1417
this also works when the motion is downwards.
1418
.NH
1419
Text Filling, Adjusting, and Centering
1420
.sc "Filling and adjusting.
1421
Normally,
1422
words are collected from input text lines
1423
and assembled into a output text line
1424
until some word does not fit.
1425
An attempt is then made
1426
to hyphenate the word to put part
1427
of it into the output line.
1428
The spaces between the words on the output line
1429
are then increased to spread out the line
1430
to the current \fIline length\fR
1431
minus any current \fIindent\fR.
1432
A \fIword\fR is any string of characters delimited by
1433
the \fIspace\fR character or the beginning/end of the input line.
1434
Any adjacent pair of words that must be kept together
1435
(neither split across output lines nor spread apart
1436
in the adjustment process)
1437
can be tied together by separating them with the
1438
\fIunpaddable space\fR character
1439
``\&\f(CW\e\ \fR'' (backslash-space).
1440
The adjusted word spacings are uniform in \*(TR
1441
and the minimum interword spacing can be controlled
1442
with the \&\f(CWss\fR request (§2).
1443
In \*(NR, they are normally nonuniform because of
1444
quantization to character-size spaces;
1445
however,
1446
the command line option \&\f(CW-e\fR causes uniform
1447
spacing with full output device resolution.
1448
Filling, adjustment, and hyphenation (§13) can all be
1449
prevented or controlled.
1450
The text length on the last line output is available in the \&\f(CW.n\fR register,
1451
and text baseline position on the page for this line is in the \&\f(CWnl\fR register.
1452
The text baseline high-water mark (lowest place) on the current page is in
1453
the \&\f(CW.h\fR register.
1454
The current horizontal output position is in the \&\f(CW.k\fP register.
1455
.PP
1456
An input text line
1457
.I ending
1458
with \&\f(CW.\fR\^, \&\f(CW?\fR, or \&\f(CW!\fR,
1459
optionally followed by any number of
1460
.CW \&" ,
1461
.CW ' ,
1462
.CW ) ,
1463
.CW ] ,
1464
.CW * ,
1465
or
1466
†,
1467
is taken
1468
to be the end of a sentence, and an additional space character is
1469
automatically provided during filling.
1470
To prevent this, add
1471
.CW \e&
1472
to the end of the input line.
1473
Multiple inter-word space characters found in the input are retained,
1474
except for trailing spaces;
1475
initial spaces also cause a break.
1476
.PP
1477
When filling is in effect, a \&\f(CW\ep\fR may be embedded or attached to a word to
1478
cause a break at the end of the word and have the resulting output
1479
line spread out to fill the current line length.
1480
.PP
1481
.tr &&
1482
A text input line that happens to begin
1483
with a control character can
1484
be made not to look like a control line
1485
by prefixing it with
1486
the non-printing, zero-width filler character \&\f(CW\e&\fR.
1487
Still another way is to specify output translation of some
1488
convenient character into the control character
1489
using \&\f(CWtr\fR (§10.5).
1490
.tr &.
1491
.sc "Interrupted text.
1492
The copying of a input line in \fInofill\f (non-fill) mode can be interrupted
1493
by terminating
1494
the partial line with a \&\f(CW\ec\fR.
1495
The next encountered input text line will be considered to be a continuation
1496
of the same line of input text.
1497
Similarly,
1498
a word within \fIfilled\fR text may be interrupted by terminating the
1499
word (and line) with \&\f(CW\ec\fR;
1500
the next encountered text will be taken as a continuation of the
1501
interrupted word.
1502
If the intervening control lines cause a break,
1503
any partial line will be forced out along with any partial word.
1504
.bt "\&\f(CW.br\fR" "-" "-" "B" "Break.
1505
The filling of the line currently
1506
being collected is stopped and
1507
the line is output without adjustment.
1508
Text lines beginning with space characters
1509
(but not tabs)
1510
and empty text lines (blank lines) also cause a break.
1511
.bt "\&\f(CW.fi\fR" "fill on" - B,E "Fill subsequent output lines.
1512
The register \&\f(CW.u\fR is 1 in fill mode and 0 in nofill mode.
1513
.bt "\&\f(CW.nf\fR" "fill on" "-" "B,E" "Nofill.
1514
Subsequent output lines are neither filled nor adjusted.
1515
Input text lines are copied directly to output lines
1516
without regard for the current line length.
1517
.bt "\&\f(CW.ad\fI c\fR" "adj, both" "adjust" "E" "Line adjustment is begun.
1518
If fill mode is not on, adjustment will be deferred until
1519
fill mode is back on.
1520
If the type indicator @c@ is present,
1521
the adjustment type is changed as shown in the following table.
1522
.TS
1523
center box;
1524
c|c
1525
c|l.
1526
Indicator	Adjust Type
1527
_
1528
\&\f(CWl\fR	adjust left margin only
1529
\&\f(CWr\fR	adjust right margin only
1530
\&\f(CWc\fR	center
1531
\&\f(CWb\fR or \&\f(CWn\fR	adjust both margins
1532
absent	unchanged
1533
.TE
1534
The number register
1535
.CW .j
1536
contains the current value of the
1537
.CW ad
1538
setting;
1539
its value can be recorded and used subsequently to set adjustment.
1540
.bt "\&\f(CW.na\fR" "adjust" "-" "E" "Noadjust.
1541
Adjustment is turned off;
1542
the right margin will be ragged.
1543
The adjustment type for \&\f(CWad\fR is not changed.
1544
Output line filling still occurs if fill mode is on.
1545
.bt "\&\f(CW.ce\fI N\fR" "off" "@N=1@" "B,E" "Center the next @N@ input text lines
1546
within the current available horizontal space (line-length minus indent).
1547
If @N=0@, any residual count is cleared.
1548
A break occurs after each of the @N@ input lines.
1549
If the input line is too long,
1550
it will be left adjusted.
1551
.NH
1552
Vertical Spacing
1553
.sc "Baseline spacing.
1554
The vertical spacing @(V)@ between the baselines of successive
1555
output lines can be set
1556
using the \&\f(CWvs\fR request.
1557
\fIV\fR should be large enough to accommodate the character sizes
1558
on the affected output lines.
1559
For the common type sizes (9-12 points),
1560
usual typesetting practice is to set \fIV\fR to 2 points greater than the
1561
point size;
1562
\*(TR default is 10-point type on a 12-point spacing
1563
(as in this document).
1564
The current \fIV\fR is available in the \&\f(CW.v\fR register.
1565
Multiple-\fIV\|\fR line separation (e.g., double spacing) may be requested
1566
with \&\f(CWls\fR,
1567
but it is better to use a large
1568
.CW vs
1569
instead;
1570
certain preprocessors assume single spacing.
1571
The current line spacing is available in the \&\f(CW.L\fP register.
1572
.sc "Extra line-space.
1573
If a word contains a tall construct requiring
1574
the output line containing it to have extra vertical space
1575
before and/or after it,
1576
the \fIextra-line-space\fR function \&\f(CW\ex'\fIN\fP'\fR
1577
can be embedded in or attached to that word.
1578
If @N@ is negative,
1579
the output line containing the word will
1580
be preceded by @N@ extra vertical space;
1581
if @N@ is positive,
1582
the output line containing the word
1583
will be followed by @N@ extra vertical space.
1584
If successive requests for extra space apply to the same line,
1585
the maximum values are used.
1586
The most recently utilized post-line extra line-space is available in the \&\f(CW.a\fR register.
1587
.PP
1588
In
1589
.CW \ex'\f2...\fP'
1590
and other functions having a pair of delimiters around
1591
their parameter,
1592
the delimiter choice (here 
1593
.CW ' )
1594
is arbitrary,
1595
except that it can not look like the continuation of a number expression for @N@.
1596
.sc "Blocks of vertical space.
1597
A block of vertical space is ordinarily requested using \&\f(CWsp\fR,
1598
which honors the \fIno-space\fR mode and which does
1599
not space past a trap.
1600
A contiguous block of vertical space may be reserved using \&\f(CWsv\fR.
1601
.bt "\&\f(CW.vs \fIN\fR" "12pts; 1/6in" "previous" "E,\fBp\fR" "Set vertical baseline spacing size \fIV\fR.
1602
Transient extra vertical space is available with \&\f(CW\ex\fI'N\|'\fR (see above).
1603
.bt "\&\f(CW.ls \fIN\fR" "@N=1@" "previous" "E" "\fILine\fR spacing
1604
set to @+- N@.
1605
@N-1@ \fIV\fR\^s (blank lines) are
1606
appended to each output text line.
1607
Appended blank lines are omitted, if the text or previous appended blank line reached a trap position.
1608
.bt "\&\f(CW.sp \fIN\fR" "-" "@N=1~V@" "B,\fBv\fR" "Space vertically in either direction.
1609
If @N@ is negative, the motion is backward (upward)
1610
and is limited to the distance to the top of the page.
1611
Forward (downward) motion is truncated to the distance to the
1612
nearest trap.
1613
(Recall the use of
1614
.CW ".sp |\f2N\fP
1615
from §1.3.)
1616
If the no-space mode is on,
1617
no spacing occurs (see \&\f(CWns\fR and \&\f(CWrs\fR below).
1618
.bt "\&\f(CW.sv\fI N\fR" "-" "@N=1~V@" "\fBv\fR" "Save a contiguous vertical block of size @N@.
1619
If the distance to the next trap is greater
1620
than @N@, @N@ vertical space is output.
1621
No-space mode has no effect.
1622
If this distance is less than @N@,
1623
no vertical space is immediately output,
1624
but @N@ is remembered for later output (see \&\f(CWos\fR).
1625
Subsequent \&\f(CWsv\fR requests will overwrite any still remembered @N@.
1626
.bt "\&\f(CW.os\fR" "-" "-" "-" "Output saved vertical space.
1627
No-space mode has no effect.
1628
Used to finally output a block of vertical space requested
1629
by an earlier \&\f(CWsv\fR request.
1630
.bt "\&\f(CW.ns\fR" "space" "-" "D" "No-space mode turned on.
1631
When on, no-space mode inhibits \&\f(CWsp\fR requests and
1632
\&\f(CWbp\fR requests \fIwithout\fR a next page number.
1633
No-space mode is turned off when a line of
1634
output occurs, or with \&\f(CWrs\fR.
1635
.bt "\&\f(CW.rs\fR" "space" "-" "D" "Restore spacing.
1636
The no-space mode is turned off.
1637
.bt "\&Blank text line." "" "-" "B" "Causes a break and
1638
output of a blank line exactly like \&\f(CWsp 1\fR.
1639
.NH
1640
Line Length and Indenting
1641
.PP
1642
The maximum line length for fill mode may be set with \&\f(CWll\fR.
1643
The indent may be set with \&\f(CWin\fR;
1644
an indent applicable to only the next output line may be set with \&\f(CWti\fR.
1645
The line length includes indent space but not
1646
page offset space.
1647
The line length minus the indent is the basis for centering with \&\f(CWce\fR.
1648
The effect of \&\f(CWll\fR, \&\f(CWin\fR, or \&\f(CWti\fR
1649
is delayed, if a partially collected line exists,
1650
until after that line is output.
1651
In fill mode the length of text on an output line is less than or equal to
1652
the line length minus the indent.
1653
The current line length and indent are available in registers \&\f(CW.l\fR and \&\f(CW.i\fR respectively.
1654
The length of \fIthree-part titles\fR produced by \&\f(CWtl\fR
1655
(see §14) is independently set by \&\f(CWlt\fR.
1656
.bt "\&\f(CW.ll\fI \(+-N\fR" "6.5\|in" "previous" "E,\fBm\fR" "Line length is set to \(+-@N@.
1657
.bt "\&\f(CW.in\fI \(+-N\fR" "\fIN\(eq\^\fR0" "previous" "B,E,\fBm\fR" "Indent is set to @+- N@.
1658
The indent is prefixed to each output line.
1659
.bt "\&\f(CW.ti\fI \(+-N\fR" "-" "ignored" "B,E,\fBm\fR" "Temporary indent.
1660
The next output text line will be indented a distance @+- N@
1661
with respect to the current indent.
1662
The resulting total indent may not be negative.
1663
The current indent is not changed.
1664
.NH
1665
Macros, Strings, Diversion, and Position Traps
1666
.sc "Macros and strings.
1667
A \fImacro\fR is a named set of arbitrary \fIlines\fR that may be invoked by name or
1668
with a \fItrap\fR.
1669
A \fIstring\fR is a named string of \fIcharacters\fR,
1670
not including a newline character,
1671
that may be interpolated by name at any point.
1672
Request, macro, and string names share the same name list.
1673
Macro and string names
1674
may be one or two characters long and may usurp previously defined
1675
request, macro, or string names;
1676
this implies that built-in operations may be (irrevocably) redefined.
1677
Any of these entities may be renamed with \&\f(CWrn\fR
1678
or removed with \&\f(CWrm\fR.
1679
.PP
1680
Macros are created by \&\f(CWde\fR and \&\f(CWdi\fR, and appended to by \&\f(CWam\fR and \&\f(CWda\fR;
1681
\&\f(CWdi\fR and \&\f(CWda\fR cause normal output to be stored in a macro.
1682
A macro is invoked in the same way as a request;
1683
a control line beginning \&\f(CW.\fIxx\fR will interpolate the contents of macro \fIxx\fR.
1684
The remainder of the line may contain up to nine \fIarguments\fR.
1685
.PP
1686
Strings are created by \&\f(CWds\fR and appended to by \&\f(CWas\fR.
1687
The strings \fIx\fR and \fIxx\fR are interpolated at any desired point with
1688
\&\f(CW\e\(**\fIx\fR and \&\f(CW\e\(**(\fIxx\fR respectively.
1689
String references and macro invocations may be nested.
1690
.sc "Copy mode input interpretation.
1691
During the definition and extension
1692
of strings and macros (not by diversion)
1693
the input is read in \fIcopy mode\fR.
1694
In copy mode, input is copied without interpretation
1695
except that:
1696
.IP
1697
.ds + \v'-.1m'\s-4\(bu\s+4\v'+.1m'
1698
.nf
1699
\*+ The contents of number registers indicated by \&\f(CW\en\fR are interpolated.
1700
\*+ Strings indicated by \&\f(CW\e\(**\fR are interpolated.
1701
\*+ Arguments indicated by \&\f(CW\e$\fR are interpolated.
1702
\*+ Concealed newlines indicated by \&\f(CW\e\fP\f2newline\fP are eliminated.
1703
\*+ Comments indicated by \&\f(CW\e"\fR are eliminated.
1704
\*+ \&\f(CW\et\fR and \&\f(CW\ea\fR are interpreted as \s-1ASCII\s+1 horizontal tab and \s-1SOH\s+1 respectively (§9).
1705
\*+ \&\f(CW\e\e\fR is interpreted as \&\f(CW\e\fR.
1706
\*+ \&\f(CW\e.\fR is interpreted as ``\&\f(CW.\fR''.
1707
.LP
1708
These interpretations can be suppressed by
1709
prefixing
1710
a \&\f(CW\e\fR.
1711
For example, since \&\f(CW\e\e\fR maps into a \&\f(CW\e\fR, \&\f(CW\e\en\fR will copy as \&\f(CW\en\fR, which
1712
will be interpreted as a number register indicator when the
1713
macro or string is reread.
1714
.sc "Arguments.
1715
When a macro is invoked by name, the remainder of the line is
1716
taken to contain up to nine arguments.
1717
The argument separator is the space character (not tab), and arguments
1718
may be surrounded by double quotes to permit embedded space characters.
1719
Pairs of double quotes may be embedded in double-quoted arguments to
1720
represent a single double-quote character.
1721
The argument
1722
.CW \&""
1723
is explicitly null.
1724
If the desired arguments won't fit on a line,
1725
a concealed newline may be used to continue on the next line.
1726
A trailing double quote may be omitted.
1727
.PP
1728
When a macro is invoked the \fIinput level\fR is \fIpushed down\fR and
1729
any arguments available at the previous level become unavailable
1730
until the macro is completely read and the previous level is restored.
1731
A macro's own arguments can be interpolated at any point
1732
within the macro with
1733
.CW \e$@N@ ,
1734
which interpolates the @N@\^th
1735
argument
1736
(@1 <= N <= 9@).
1737
If an invoked argument does not exist,
1738
a null string results.
1739
For example, the macro \fIxx\fR may be defined by
1740
.P1
1741
.ta .75i
1742
&de xx	\e" begin definition
1743
Today is \e\e$1 the \e\e$2.
1744
&.	\e" end definition
1745
.P2
1746
and called by
1747
.P1
1748
&xx Monday 14th
1749
.P2
1750
to produce the text
1751
.P1
1752
Today is Monday the 14th.
1753
.P2
1754
Note that each \&\f(CW\e$\fR
1755
was concealed in the definition with a prefixed \&\f(CW\e\fR.
1756
The number of
1757
arguments is in the \&\f(CW.$\fR register.
1758
.PP
1759
No arguments are available at the top (non-macro) level,
1760
within a string, or within a trap-invoked macro.
1761
.PP
1762
Arguments are copied in copy mode onto a stack
1763
where they are available for reference.
1764
It is advisable to
1765
conceal string references (with an extra \&\f(CW\e\fR\|)
1766
to delay interpolation until argument reference time.
1767
.sc "Diversions.
1768
Processed output may be diverted into a macro for purposes
1769
such as footnote processing (see Tutorial §T5)
1770
or determining the horizontal and vertical size of some text for
1771
conditional changing of pages or columns.
1772
A single diversion trap may be set at a specified vertical position.
1773
The number registers \&\f(CWdn\fR and \&\f(CWdl\fR respectively contain the
1774
vertical and horizontal size of the most
1775
recently ended diversion.
1776
Processed text that is diverted into a macro
1777
retains the vertical size of each of its lines when reread
1778
in \fInofill\fR mode
1779
regardless of the current \fIV\fR.
1780
Constant-spaced (\&\f(CWcs\fR) or emboldened (\&\f(CWbd\fR) text that is diverted
1781
can be reread correctly only if these modes are again or still in effect
1782
at reread time.
1783
One way to do this is to embed in the diversion the appropriate
1784
\&\f(CWcs\fR or \&\f(CWbd\fR requests with the \fItransparent\fR
1785
mechanism described in §10.6.
1786
.PP
1787
Diversions may be nested
1788
and certain parameters and registers
1789
are associated
1790
with the current diversion level
1791
(the top non-diversion level may be thought of as the
1792
0th diversion level).
1793
These are the diversion trap and associated macro,
1794
no-space mode,
1795
the internally-saved marked place (see \&\f(CWmk\fR and \&\f(CWrt\fR),
1796
the current vertical place (\&\f(CW.d\fR register),
1797
the current high-water text baseline (\&\f(CW.h\fR register),
1798
and the current diversion name (\&\f(CW.z\fR register).
1799
.sc "Traps.
1800
Three types of trap mechanisms are available\(empage traps, a diversion trap, and
1801
an input-line-count trap.
1802
Macro-invocation traps may be planted using \&\f(CWwh\fR at any page position including the top.
1803
This trap position may be changed using \&\f(CWch\fR.
1804
Trap positions at or below the bottom of the page
1805
have no effect unless or until
1806
moved to within the page or rendered effective by an increase in page length.
1807
Two traps may be planted at the same position only by first planting them at different
1808
positions and then moving one of the traps;
1809
the first planted trap will conceal the second unless and until the first one is moved
1810
(see Tutorial Examples).
1811
If the first one is moved back, it again conceals the second trap.
1812
The macro associated with a page trap is automatically
1813
invoked when a line of text is output whose vertical size reaches
1814
or sweeps past the trap position.
1815
Reaching the bottom of a page springs the top-of-page trap, if any,
1816
provided there is a next page.
1817
The distance to the next trap position is available in the \&\f(CW.t\fR register;
1818
if there are no traps between the current position and the bottom of the page,
1819
the distance returned is the distance to the page bottom.
1820
.PP
1821
A macro-invocation trap effective in the current diversion may be planted using \&\f(CWdt\fR.
1822
The \&\f(CW.t\fR register works in a diversion; if there is no subsequent trap a large
1823
distance is returned.
1824
For a description of input-line-count traps, see \&\f(CWit\fR below.
1825
.bt "\&\f(CW&de\fI xx yy\fR" "-" "\fI.yy=\&\f(CW..\fR" "-" "Define or redefine the macro \fIxx\fR.
1826
The contents of the macro begin on the next input line.
1827
Input lines are copied in \fIcopy mode\fR until the definition is terminated by a
1828
line beginning with \&\f(CW.\fIyy\fR,
1829
whereupon the macro \fIyy\fR is called.
1830
In the absence of \fIyy\fR, the definition
1831
is terminated by a
1832
line beginning with ``\&\f(CW..\fR''.
1833
A macro may contain \&\f(CWde\fR requests
1834
provided the terminating macros differ
1835
or the contained definition terminator is concealed.
1836
\&``\&\f(CW..\fR'' can be concealed as
1837
\&\f(CW\e\e..\fR which will copy as \&\f(CW\e..\fR and be reread as ``\&\f(CW..\fR''.
1838
.bt "\&\f(CW&am\fI xx yy\fR" "-" "\fI.yy=\&\f(CW..\fR" "-" "Append to macro
1839
.I xx
1840
(append version of \&\f(CWde\fR).
1841
.bt "\&\f(CW&ds\fI xx string\fR" "-" "ignored" "-" "Define a string
1842
\fIxx\fR containing \fIstring\fR.
1843
Any initial double quote in \fIstring\fR is stripped off to permit
1844
initial blanks.
1845
.bt "\&\f(CW&as\fI xx string\fR" "-" "ignored" "-" "Append
1846
\fIstring\fR to string \fIxx\fR
1847
(append version of \&\f(CWds\fR).
1848
.bt "\&\f(CW&rm\fI xx\fR" "-" "ignored" "-" "Remove
1849
request, macro, or string.
1850
The name \fIxx\fR is removed from the name list and
1851
any related storage space is freed.
1852
Subsequent references will have no effect.
1853
If many macros and strings are being created dynamically, it
1854
may become necessary to remove unused ones
1855
to recapture internal storage space for newer registers.
1856
.bt "\&\f(CW&rn\fI xx yy\fR" "-" "ignored" "-" "Rename request, macro, or string
1857
\fIxx\fR to \fIyy\fR.
1858
If \fIyy\fR exists, it is first removed.
1859
.bt "\&\f(CW&di\fI xx\fR" "-" "end" "D" "Divert output to macro \fIxx\fR.
1860
Normal text processing occurs during diversion
1861
except that page offsetting is not done.
1862
The diversion ends when the request \&\f(CWdi\fR or \&\f(CWda\fR is encountered without an argument;
1863
extraneous
1864
requests of this type should not appear when nested diversions are being used.
1865
.bt "\&\f(CW&da \fIxx\fR" "-" "end" "D" "Divert, appending to macro \fIxx\fR
1866
(append version of \&\f(CWdi\fR).
1867
.bt "\&\f(CW&wh\fI N xx\fR" "-" "-" "\fBv\fR" "Install
1868
a trap to invoke \fIxx\fR at page position \fIN\fR;
1869
a negative N will be interpreted as a distance from the
1870
page bottom.
1871
Any macro previously planted at @N@ is replaced by \fIxx\fR.
1872
A zero @N@ refers to the top of a page.
1873
In the absence of \fIxx\fR, the first trap found at @N@, if any, is removed.
1874
.bt "\&\f(CW&ch\fI xx N\fR" "-" "-" "\fBv\fR" "Change
1875
the trap position for macro \fIxx\fR to be @N@.
1876
In the absence of @N@, the trap, if any, is removed.
1877
.bt "\&\f(CW&dt\fI N xx\fR" "-" "off" "D,\fBv\fR" "Install a diversion trap
1878
at position @N@ in the \fIcurrent\fR diversion to invoke
1879
macro \fIxx\fR.
1880
Another \&\f(CWdt\fR will redefine the diversion trap.
1881
If no arguments are given, the diversion trap is removed.
1882
.bt "\&\f(CW&it\fI N xx\fR" "-" "off" "E" "Set an input-line-count trap
1883
to invoke the macro \fIxx\fR after @N@ lines of \fItext\fR input
1884
have been read
1885
(control or request lines do not count).
1886
The text may be inline text or
1887
text interpolated by inline or trap-invoked macros.
1888
.bt "\&\f(CW&em\fI xx\fR" "none" "none" "-" "The
1889
macro \fIxx\fR will be invoked
1890
when all input has ended.
1891
The effect is almost as if the contents of \fIxx\fR had been at the end
1892
of the last file processed,
1893
but all processing ceases at the next page eject.
1894
.NH
1895
Number Registers
1896
.PP
1897
A variety of parameters are available to the user as
1898
predefined \fInumber registers\fR (see Summary, page \n(*%).
1899
In addition, users may define their own registers.
1900
Register names are one or two characters long and do not conflict
1901
with request, macro, or string names.
1902
Except for certain predefined read-only registers,
1903
a number register can be read, written, automatically
1904
incremented or decremented, and interpolated
1905
into the input in a variety of formats.
1906
One common use of user-defined registers is to
1907
automatically number sections, paragraphs, lines, etc.
1908
A number register may be used any time numerical input is expected or desired
1909
and may be used in numerical \fIexpressions\fR (§1.4).
1910
.PP
1911
Number registers are created and modified using \&\f(CWnr\fR, which
1912
specifies the name, numerical value, and the auto-increment size.
1913
Registers are also modified, if accessed
1914
with an auto-incrementing sequence.
1915
If the registers \fIx\fR and \fIxx\fR both contain
1916
@N@ and have the auto-increment size @M@,
1917
the following access sequences have the effect shown:
1918
.TS
1919
center box;
1920
c2|c2|c
1921
c2|c2|c2
1922
l2|c2|c2
1923
l2|c2|c2
1924
l2|l2|c2.
1925
	Effect on	Value
1926
Sequence	Register	Interpolated
1927
_
1928
\&\f(CW\en\fIx\fR	none	@N@
1929
\&\f(CW\en(\fIxx\fR	none	@N@
1930
\&\f(CW\en+\fIx\fR	\fIx\fR incremented by @M@	\fIN+M\fR
1931
\&\f(CW\en-\fIx\fR	\fIx\fR decremented by @M@	\fIN-M\fR
1932
\&\f(CW\en+(\fIxx\fR	\fIxx\fR incremented by @M@	\fIN+M\fR
1933
\&\f(CW\en-(\fIxx\fR	\fIxx\fR decremented by @M@	\fIN-M\fR
1934
.TE
1935
When interpolated, a number register is converted to
1936
decimal (default),
1937
decimal with leading zeros,
1938
lower-case Roman,
1939
upper-case Roman,
1940
lower-case sequential alphabetic,
1941
or
1942
upper-case sequential alphabetic
1943
according to the format specified by \&\f(CWaf\fR.
1944
.bt "\&\f(CW&nr\fI R \(+-N M\fR" "" "-" "\fBu\fR" "The number register
1945
@R@ is assigned the value @+- N@
1946
with respect to the previous value, if any.
1947
The increment for auto-incrementing is set to @M@.
1948
.bt "\&\f(CW&af\fI R c\fR" "arabic" "-" "-" "Assign
1949
format @c@ to register @R@.
1950
The available formats are:
1951
.Tm number register format	s
1952
.TS
1953
center box;
1954
c2|c
1955
c2|c
1956
c2|l.
1957
	Numbering
1958
Format	Sequence
1959
_
1960
\&\f(CW1\fR	0, 1, 2, 3, 4, 5, ...
1961
\&\f(CW001\fR	000, 001, 002, 003, 004, 005, ...
1962
\&\f(CWi\fR	0, i, ii, iii, iv, v, ...
1963
\&\f(CWI\fR	0, I, II, III, IV, V, ...
1964
\&\f(CWa\fR	0, a, b, c, ..., z, aa, ab, ..., zz, aaa, ...
1965
\&\f(CWA\fR	0, A, B, C, ..., Z, AA, AB, ..., ZZ, AAA, ...
1966
.TE
1967
An arabic format having @N@ digits
1968
specifies a field width of @N@ digits (example 2 above).
1969
The read-only registers and the width function
1970
.CW \ew
1971
(§11.2)
1972
are always arabic.
1973
Warning: the value of a number register in a non-Arabic format
1974
is not numeric, and will not produce the expected results in expressions.
1975
.IP
1976
The function
1977
.CW \eg@x@
1978
or
1979
.CW \eg(@xx@
1980
returns the format of a number register in a form suitable for
1981
.CW af ;
1982
it returns nothing if the register has not been used.
1983
.bt "\&\f(CW&rr\fI R\fR" "-" "ignored" "-" "Remove number register @R@.
1984
If many registers are being created dynamically, it
1985
may become necessary to remove unused registers
1986
to recapture internal storage space for newer registers.
1987
The register
1988
.CW .R
1989
contains the number of number registers still available.
1990
.NH
1991
Tabs, Leaders, and Fields
1992
.sc "Tabs and leaders.
1993
The \s-1ASCII\s+1 horizontal tab character and the \s-1ASCII\s+1
1994
\s-1SOH\s+1 (control-A, hereafter called the \fIleader\fR character)
1995
can both be used to generate either horizontal motion or
1996
a string of repeated characters.
1997
The length of the generated entity is governed
1998
by internal \fItab stops\fR specifiable
1999
with \&\f(CWta\fR.
2000
The default difference is that tabs generate motion and leaders generate
2001
a string of periods;
2002
\&\f(CWtc\fR and \&\f(CWlc\fR
2003
offer the choice of repeated character or motion.
2004
There are three types of internal tab stops\(em\
2005
\fIleft\fR adjusting, \fIright\fR adjusting,
2006
and \fIcentering\fR.
2007
In the following table,
2008
\fID\fR is the distance from the current position on the \fIinput\fR line
2009
(where a tab or leader was found)
2010
to the next tab stop,
2011
\fInext-string\fR consists
2012
of the input characters following the tab (or leader) up to the next tab (or leader) or end of line,
2013
and
2014
\fIW\fR is the width of \fInext-string\fR.
2015
.TS
2016
center box;
2017
c2|c2|c
2018
c2|c2|c
2019
c2|c2|l.
2020
Tab	Length of motion or	Location of
2021
type	repeated characters	\fInext-string\fR
2022
_
2023
Left	\fID\fR	Following \fID\fR
2024
Right	\fID-W\fR	Right adjusted within \fID\fR
2025
Centered	\fID-W/\fR2	Centered on right end of \fID\fR
2026
.TE
2027
The length of generated motion is allowed to be negative, but
2028
that of a repeated character string cannot be.
2029
Repeated character strings contain an integer number of characters, and
2030
any residual distance is prepended as motion.
2031
Tabs or leaders found after the last tab stop are ignored, but may be used
2032
as \fInext-string\fR terminators.
2033
.PP
2034
Tabs and leaders are not interpreted in copy mode.
2035
\&\f(CW\et\fR and \&\f(CW\ea\fR always generate a non-interpreted
2036
tab and leader respectively, and
2037
are equivalent to actual tabs and leaders in copy mode.
2038
.sc "Fields.
2039
A \fIfield\fR is contained between
2040
a pair of \fIfield delimiter\fR characters,
2041
and consists of substrings
2042
separated by \fIpadding\fR indicator characters.
2043
The field length is the distance on the
2044
\fIinput\fR line from the position where the field begins to the next tab stop.
2045
The difference between the total length of all the substrings
2046
and the field length is incorporated as horizontal
2047
padding space that is divided among the indicated
2048
padding places.
2049
The incorporated padding is allowed to be negative.
2050
For example,
2051
if the field delimiter is \&\f(CW#\fR and the padding indicator is \&\f(CW^\fR,
2052
\&\f(CW#^\fIxxx\&\f(CW^\fIright\|\&\f(CW#\fR
2053
specifies a right-adjusted string with the string \fIxxx\fR centered
2054
in the remaining space.
2055
.h1
2056
.bt "\&\f(CW&ta\fI Nt ...\fR" "0.8; 0.5in" "none" "E,\fBm\fR" "Set tab stops and types.
2057
\fIt=\&\f(CWR\fR, right adjusting;
2058
\fIt=\&\f(CWC\fR, centering;
2059
\fIt\fR absent, left adjusting.
2060
\*(Tr tab stops are preset every 0.5in.,
2061
\*(NR every 0.8in.
2062
The stop values are separated by spaces, and
2063
a value preceded by \&\f(CW+\fR
2064
is treated as an increment to the previous stop value.
2065
.bt "\&\f(CW&tc\fI c\fR" "none" "none" "E" "The tab repetition character
2066
becomes @c@,
2067
or is removed, thus specifying motion.
2068
.bt "\&\f(CW&lc\fI c\fR" "\&\f(CW.\fR" "none" "E" "The leader repetition character
2069
becomes @c@,
2070
or is removed, thus specifying motion.
2071
.bt "\&\f(CW&fc\fI a b\fR" "off" "off" "-" "The field delimiter
2072
is set to \fIa\fR;
2073
the padding indicator is set to the space character or to
2074
\fIb\fR, if given.
2075
In the absence of arguments the field mechanism is turned off.
2076
.NH
2077
Input and Output Conventions and Character Translations
2078
.sc "Input character translations.
2079
Ways of inputting the valid character set were
2080
discussed in §2.1.
2081
The \s-1ASCII\s+1 control characters horizontal tab (§9.1),
2082
\s-1SOH\s+1 (§9.1), and backspace (§10.3) are discussed elsewhere.
2083
The newline delimits input lines.
2084
In addition,
2085
\s-1STX\s+1, \s-1ETX\s+1, \s-1ENQ\s+1, \s-1ACK\s+1, and \s-1BEL\s+1
2086
are accepted,
2087
and may be used as delimiters or translated into a graphic with \&\f(CWtr\fR (§10.5).
2088
All others are ignored.
2089
.PP
2090
The \fIescape\fR character \&\f(CW\e\fR
2091
introduces \fIescape sequences\fR,
2092
which cause the following character to mean
2093
another character, or to indicate
2094
some function.
2095
.nr %% \n(*%-1
2096
A complete list of such sequences is given in the Summary on page \n(*%.
2097
The escape character \&\f(CW\e\fR
2098
should not be confused with the \s-1ASCII\s+1 control character \s-1ESC\s+1.
2099
The escape character \&\f(CW\e\fR can be input with the sequence \&\f(CW\e\e\fR.
2100
The escape character can be changed with \&\f(CWec\fR,
2101
and all that has been said about the default \&\f(CW\e\fR becomes true
2102
for the new escape character.
2103
\&\f(CW\ee\fR can be used to print whatever the current escape character is.
2104
The escape mechanism may be turned off with \&\f(CWeo\fR,
2105
and restored with \&\f(CWec\fR.
2106
.h1
2107
.bt "\&\f(CW&ec\fI c\fR" "\&\f(CW\e\fR" "\&\f(CW\e\fR" "-" "Set escape character
2108
to \&\f(CW\e\fR, or to @c@, if given.
2109
.bt "\&\f(CW&eo\fR" "on" "-" "-" "Turn escape mechanism off.
2110
.sc "Ligatures.
2111
.lg0
2112
The set of available ligatures is device and font dependent,
2113
but is often a subset of
2114
\&\fBfi\fR, \&\fBfl\fR, \&\fBff\fR, \&\fBffi\fR, and \&\fBffl\fR.
2115
They may be input by
2116
\&\f(CW\e(fi\fR, \&\f(CW\e(fl\fR, \&\f(CW\e(ff\fR, \&\f(CW\e(Fi\fR, and \&\f(CW\e(Fl\fR respectively.
2117
.lg
2118
The ligature mode is normally on in \*(TR, and automatically invokes 
2119
ligatures during input.
2120
.h1
2121
.bt "\&\f(CW&lg\fI N\fR" "on; off" "on" "-" "Ligature mode
2122
is turned on if @N@ is absent or non-zero,
2123
and turned off if @N=0@.
2124
If @N=2@, only the two-character ligatures are automatically invoked.
2125
Ligature mode is inhibited for
2126
request, macro, string, register, or file names,
2127
and in copy mode.
2128
No effect in \*(NR.
2129
.sc "Backspacing, underlining, overstriking, etc.
2130
Unless in copy mode, the \s-1ASCII\s+1 backspace character is replaced
2131
by a backward horizontal motion having the width of the
2132
space character.
2133
Underlining as a form of line-drawing is discussed in §12.4.
2134
A generalized overstriking function is described in §12.1.
2135
.PP
2136
\*(Nr automatically underlines
2137
characters in the \fIunderline\fR font,
2138
specifiable with \&\f(CWuf\fR,
2139
normally that on font position 2.
2140
In addition to \&\f(CWft\fR and
2141
.CW \ef@F@ ,
2142
the underline font may be selected by \&\f(CWul\fR and \&\f(CWcu\fR.
2143
Underlining is restricted to an output-device-dependent
2144
subset of reasonable characters.
2145
.bt "\&\f(CW&ul\fI N\fR" "off" "@N=1@" "E" "Italicize in \*(TR
2146
(underline in \*(NR) the next @N@
2147
input text lines.
2148
Actually, switch to underline font, saving the
2149
current font for later restoration;
2150
other font changes within the span of a \&\f(CWul\fR
2151
will take effect,
2152
but the restoration will undo the last change.
2153
Output generated by \&\f(CWtl\fR (§14) is affected by the
2154
font change, but does not decrement @N@.
2155
If @N>1@, there is the risk that
2156
a trap interpolated macro may provide text
2157
lines within the span;
2158
environment switching can prevent this.
2159
.bt "\&\f(CW&cu\fI N\fR" "off" "@N=1@" "E" "Continuous underline.
2160
A variant
2161
of \&\f(CWul\fR that causes \fIevery\fR character to be underlined in \*(NR.
2162
Identical to \&\f(CWul\fR in \*(TR.
2163
.bt "\&\f(CW&uf\fI F\fR" "Italic" "Italic" "-" "Underline font set to @F@.
2164
In \*(NR,
2165
@F@ may not be on position 1.
2166
.sc "Control characters.
2167
Both the control character \&\f(CW.\fR and the \fIno-break\fR
2168
control character \&\f(CW'\fR may be changed.
2169
Such a change must be compatible with the design
2170
of any macros used in the span of the change,
2171
and
2172
particularly of any trap-invoked macros.
2173
.bt "\&\f(CW&cc\fI c\fR" "\&\f(CW.\fR" "\&\f(CW.\fR" "E" "The basic control character
2174
is set to @c@,
2175
or reset to ``\&\f(CW.\fR''.
2176
.bt "\&\f(CW&c2\fI c\fR" "\&\f(CW'" "'\fR" "E" "The \fIno-break\fR control character is set
2177
to @c@, or reset to ``\&\f(CW'\fR''.
2178
.sc "Output translation.
2179
One character can be made a stand-in for another character using \&\f(CWtr\fR.
2180
All text processing (e.g., character comparisons) takes place
2181
with the input (stand-in) character, which appears to have the width of the final
2182
character.
2183
The graphic translation occurs at the moment of output
2184
(including diversion).
2185
.bt "\&\f(CW&tr\fI abcd....\fR" "none" "-" "O" "Translate
2186
\fIa\fR into \fIb\fR, @c@ into \fId\fR, etc.
2187
If an odd number of characters is given,
2188
the last one will be mapped into the space character.
2189
To be consistent, a particular translation
2190
must stay in effect from \fIinput\fR to \fIoutput\fR time.
2191
.sc "Transparent throughput.
2192
An input line beginning with a \&\f(CW\e!\fR is read in copy mode and \fItrans\%parently\fR output
2193
(without the initial \&\f(CW\e!\fR);
2194
the text processor is otherwise unaware of the line's presence.
2195
This mechanism may be used to pass control information to a post-processor
2196
or to embed control lines in a macro created by a diversion.
2197
.sc "Transparent output
2198
The sequence
2199
.CW \eX'@anything@'
2200
copies
2201
.I anything
2202
to the output, as a device control function of the form
2203
.CW x
2204
.CW X 
2205
.I anything 
2206
(§22).
2207
Escape sequences in
2208
.I anything
2209
are processed.
2210
.sc "Comments and concealed newlines.
2211
An uncomfortably long input line that must stay
2212
one line (e.g., a string definition, or nofilled text)
2213
can be split into several physical lines by ending all but
2214
the last one with the escape \&\f(CW\e\fR.
2215
The sequence \&\f(CW\e\fR@newline@ is always ignored,
2216
except in a comment.
2217
Comments may be embedded at the end of any line by
2218
prefacing them with \&\f(CW\e"\fR.
2219
The newline at the end of a comment cannot be concealed.
2220
A line beginning with \&\f(CW\e"\fR will appear as a blank line and
2221
behave like
2222
.CW ".sp\ 1" ;
2223
a comment can be on a line by itself by beginning the line with \&\f(CW.\e"\fR.
2224
.NH
2225
Local Horizontal and Vertical Motions, and the Width Function
2226
.sc "Local Motions.
2227
The functions \&\f(CW\ev'\fIN\&\f(CW'\fR and
2228
\&\f(CW\eh'\fIN\&\f(CW'\fR
2229
can be used for \fIlocal\fR vertical and horizontal motion respectively.
2230
The distance @N@ may be negative; the positive directions
2231
are rightward and downward.
2232
A local motion is one contained within a line.
2233
To avoid unexpected vertical dislocations, it is necessary that
2234
the net vertical local motion within a word in filled text
2235
and otherwise within a line balance to zero.
2236
The escape sequences providing local motion are
2237
summarized in the following table.
2238
.ds Y \0\0\0
2239
.KS
2240
.TS
2241
center box;
2242
c2|cs2||c2|cs2
2243
c1|c2c2||c2|c2c2.
2244
Vertical	Effect in	Horizontal	Effect in
2245
Local Motion	\*(TR	\*(NR	Local Motion	\*(TR	\*(NR
2246
_
2247
.sp.4
2248
.TC
2249
l2|ls2||l2|ls2.
2250
\&\f(CW\*Y\ev'\fIN\|\f(CW'\fR	Move distance @N@	\
2251
\&\f(CW\*Y\eh'\fIN\|\f(CW'\fR	Move distance @N@
2252
.TC
2253
_2|_2_2||l2|ls2.
2254
x	x	x	\&\f(CW\*Y\e\fP\f2space\fP	Unpaddable space-size space
2255
.TC
2256
l2|l2|l2||l2|ls2.
2257
\&\f(CW\*Y\eu\fR	½ em up	½ line up	\&\f(CW\*Y\e0\fR	Digit-size space
2258
.TC
2259
l2|l2|l2||_2|_2_2.
2260
\&\f(CW\*Y\ed\fR	½ em down	½ line down	x	x	x
2261
.TC
2262
l2|l2|l2||l2|l2|l2.
2263
\&\f(CW\*Y\er\fR	1 em up	1 line up	\&\f(CW\*Y\e|\fR	1/6 em space	ignored
2264
			\&\f(CW\*Y\e^\fR	1/12 em space	ignored
2265
.sp.4
2266
.TE
2267
.KE
2268
As an example,
2269
\&\f(CWE\s-2\v'-.4m'2\v'.4m'\s+2\fR
2270
could be generated by a sequence of size changes and motions:
2271
\&\f(CWE\es-2\ev'-0.4m'2\ev'0.4m'\es+2\fR;
2272
note that
2273
the 0.4 em vertical motions are at the smaller size.
2274
.sc "Width Function.
2275
The \fIwidth\fR function \&\f(CW\ew'\fIstring\&\f(CW'\fR
2276
generates the numerical width of \fIstring\fR (in basic units).
2277
Size and font changes may be embedded in \fIstring\fR,
2278
and will not affect the current environment.
2279
For example,
2280
\&\&\f(CW.ti\ -\ew'\efB1.\ 'u\fR could be used to
2281
temporarily indent leftward a distance equal to the
2282
size of the string ``\&\f(CW1.\ \fR'' in font
2283
.CW B .
2284
.PP
2285
The width function also sets three number registers.
2286
The registers \&\f(CWst\fR and \&\f(CWsb\fR are set respectively to the highest and
2287
lowest extent of \fIstring\fR relative to the baseline;
2288
then, for example,
2289
the total height of the string is \&\f(CW\en(stu-\en(sbu\fR.
2290
In \*(TR the number register \&\f(CWct\fR is set to a value
2291
between 0 and 3.
2292
The value
2293
 
2294
case characters without descenders (like \&\f(CWe\fR);
2295
1 means that at least one character has a descender (like \&\f(CWy\fR);
2296
2 means that at least one character is tall (like \&\f(CWH\fR);
2297
and 3 means that both tall characters and characters with
2298
descenders are present.
2299
.sc "Mark horizontal place.
2300
The function \&\f(CW\ek\fIx\fR causes the current horizontal
2301
position in the \fIinput line\fR to be stored in register \fIx\fR.
2302
For example,
2303
the construction \&\f(CW\ekx\fIword\f(CW\eh'|\enxu+3u'\fIword\&\f(CW\fR
2304
will embolden \fIword\fR by backing up to almost its beginning and overprinting it,
2305
resulting in \kz\fIword\fR\h'|\nzu+3u'\fIword\fR.
2306
.NH
2307
Overstrike, Bracket, Line-drawing, Graphics, and Zero-width Functions
2308
.sc "Overstriking.
2309
Automatically centered overstriking of up to nine characters
2310
is provided by the \fIoverstrike\fR function
2311
\&\f(CW\eo'\fIstring\&\f(CW\|'\fR.
2312
The characters in \fIstring\fR are overprinted with centers aligned; the total width
2313
is that of the widest character.
2314
\fIstring\fR may not contain local vertical motion.
2315
As examples,
2316
\&\f(CW\eo'e\e''\fR produces \o'e\'', and
2317
\&\f(CW\eo'\e(mo\e(sl'\fR produces \o'\(mo\(sl'.
2318
.sc "Zero-width characters.
2319
The function
2320
.CW \ez@c@
2321
will output @c@ without spacing over
2322
it, and can be used to produce left-aligned overstruck
2323
combinations.
2324
As examples,
2325
\&\f(CW\ez□+\fR will produce \z□+, and
2326
\&\f(CW\e(br\ez\e(rn\e(ul\e(br\fR will produce a small
2327
badly constructed box \&\(br\z\(rn\(ul\(br\|.
2328
.sc "Large Brackets.
2329
The Special Font usually contains a number of bracket construction pieces
2330
\|\|\(lt\|\|\(lb\|\|\(rt\|\|\(rb\|\|\(lk\|\|\(rk\|\|\(bv\|\|\(lf\|\|\(rf\|\|\(lc\|\|\(rc\|\|
2331
that can be combined into various bracket styles.
2332
The function \&\f(CW\eb'\fIstring\&\f(CW\|'\fR may be used to pile
2333
up vertically the characters in \fIstring\fR
2334
(the first character on top and the last at the bottom);
2335
the characters are vertically separated by 1 em and the total
2336
pile is centered 1/2 em above the current baseline
2337
(½ line in \*(NR).
2338
For example,
2339
.P1
2340
\eb'\e(lc\e(lf'E\eb'\e(rc\e(rf'\ex'-0.5m'\ex'0.5m'
2341
.P2
2342
produces
2343
\x'-.5m'\x'.5m'\b'\(lc\(lf'E\b'\(rc\(rf'.
2344
.sc "Line drawing.
2345
.tr &&
2346
The function \&\f(CW\el'\fINc\f(CW'\fR (backslash-ell) draws a string of repeated @c@'s towards the right for a distance @N@.
2347
If @c@ looks like a continuation of
2348
an expression for @N@, it may be insulated from @N@ with \&\f(CW\e&\fR.
2349
If @c@ is not specified, the \&\f(CW\(ru\fR (baseline rule) is used
2350
(underline character in \*(NR).
2351
If @N@ is negative, a backward horizontal motion
2352
of size @N@ is made before drawing the string.
2353
Any space resulting from @N@/(size of @c@) having a remainder is put at the beginning (left end)
2354
of the string.
2355
If @N@ is less than the width of @c@,
2356
a single @c@ is centered on a distance @N@.
2357
In the case of characters
2358
that are designed to be connected, such as
2359
baseline-rule\ \&\f(CW\(ru\fR\|,
2360
under-rule\ \&\f(CW\(ul\fR\|,
2361
and
2362
root-en\ \&\f(CW\(rn\fR\|,
2363
the remainder space is covered by overlapping.
2364
As an example, a macro to underscore a string can be written
2365
.tr &.
2366
.P1
2367
.ne 2.1
2368
&de us
2369
\e\e$1\e\|l\|'|0\e(ul'
2370
&&
2371
.P2
2372
.ne2.1
2373
.de xu
2374
\\$1\l'|0\(ul'
2375
..
2376
or one to draw a box around a string
2377
.P1
2378
&de bx
2379
\e(br\e|\e\e$1\e|\e(br\e\|l\|'|0\e(rn'\e\|l\|'|0\e(ul'
2380
&&
2381
.P2
2382
.de bx
2383
\(br\|\\$1\|\(br\l'|0\(rn'\l'|0\(ul'
2384
..
2385
such that
2386
.P1
2387
&ul "underlined words"
2388
.P2
2389
and
2390
.P1
2391
&bx "words in a box"
2392
.P2
2393
yield
2394
.xu "underlined words"
2395
and
2396
.bx "words in a box"
2397
\h'-\w'.'u'.
2398
.PP
2399
The function \&\f(CW\eL'\fINc\&\f(CW'\fR draws a vertical line consisting
2400
of the (optional) character @c@ stacked vertically apart 1\|em
2401
(1 line in \*(NR),
2402
with the first two characters overlapped,
2403
if necessary, to form a continuous line.
2404
The default character is the \fIbox rule\fR \|\(br\| (\&\f(CW\|\e(br\fR);
2405
the other suitable character is the \fIbold vertical\fR \|\(bv\| (\&\f(CW\|\e(bv\fR).
2406
The line is begun without any initial motion relative to the
2407
current baseline.
2408
A positive @N@ specifies a line drawn downward and
2409
a negative @N@ specifies a line drawn upward.
2410
After the line is drawn no compensating
2411
motions are made;
2412
the instantaneous baseline is at the end of the line.
2413
.PP
2414
.de eb
2415
.sp -1
2416
.nf
2417
\h'-.5n'\L'|\\nzu-1'\l'\\n(.lu+1n\(ul'\L'-|\\nzu+1'\l'|0u-.5n\(ul'
2418
.fi
2419
..
2420
.ne 2i
2421
.mk z
2422
.nr z \nz+1
2423
The horizontal and vertical line drawing functions may be used
2424
in combination to produce large boxes.
2425
The zero-width \fIbox-rule\fR and the ½-em wide \fIunder-rule\fR
2426
were designed to form corners when using 1-em vertical
2427
spacings.
2428
For example the macro
2429
.nr x \n(DV
2430
.nr DV 0
2431
.P1 .15i
2432
.ps -1
2433
\&.de eb
2434
\&.sp -1	\e"compensate for next automatic baseline spacing
2435
\&.nf	\e"avoid possibly overflowing word buffer
2436
\&\eh'-.5n'\eL'|\e\enau-1'\el'\e\en(.lu+1n\e(ul'\eL'-|\e\enau+1'\el'|0u-.5n\e(ul'
2437
\&.fi
2438
\&..
2439
.ps +1
2440
.P2
2441
.nr DV \nx 
2442
will draw a box around some text whose beginning vertical place was
2443
saved in number register \fIa\fR
2444
(e.g., using \&\f(CW.mk\ a\fR)
2445
as was done for this paragraph.
2446
.eb
2447
.sc "Graphics.
2448
The function
2449
.CW \eD'@c...@'
2450
draws a graphic object of type @c@
2451
according to a sequence of parameters,
2452
which are generally pairs of numbers.
2453
.IP
2454
.nf
2455
.ta 1.7i
2456
\f(CW\eD'l @dh~ dv@'	\f1draw line from current position by @dh,~dv@\f(CW
2457
\f(CW\eD'c @d@'	\f1draw circle of diameter @d@ with left side at current position\f(CW
2458
\f(CW\eD'e @d sub 1 d sub 2@'	\f1draw ellipse of diameters @d sub 1@ and @d sub 2@\f(CW
2459
\f(CW\eD'a @dh sub 1~ dv sub 1~ dh sub 2~ dv sub 2@'\f(CW	\f1draw arc from current position to @dh sub 1 +dh sub 2@, @dv sub 1 +dv sub 2@,\f(CW
2460
	   \f1with center at @dh sub 1 ,~ dv sub 1@ from current position\f(CW
2461
\f(CW\eD'~ @dh sub 1 dv sub 1 dh sub 2 dv sub 2 "..."@'\f(CW	\f1draw B-spline from current position by @dh sub 1, dv sub 1@,\f(CW
2462
	   \f1then by @dh sub 2 , dv sub 2@, then by @dh sub 2 , dv sub 2@, then ...\f(CW
2463
.LP
2464
For example,
2465
.CW "\eD'e0.2i 0.1i'"
2466
draws the ellipse
2467
\D'e.2i .1i'\|,
2468
and
2469
.CW "\eD'l.2i -.1i'\eD'l.1i .1i'"
2470
the line
2471
\D'l.2i -.1i'\D'l.1i .1i'\|.
2472
A
2473
.CW \\eD
2474
with an unknown @c@ is processed and copied through to the output
2475
for unspecified interpretation;
2476
coordinates are interpreted alternately as horizontal and vertical
2477
values.
2478
.PP
2479
Numbers taken as horizontal (first, third, etc.) have default scaling of ems;
2480
vertical numbers (second, fourth, etc.) have default scaling of @V^@s (§1.3).
2481
The position after a graphical object has been drawn is
2482
at its end; for circles and ellipses, the ``end''
2483
is at the right side.
2484
.NH
2485
Hyphenation.
2486
.PP
2487
Automatic hyphenation may be switched off and on.
2488
When switched on with \&\f(CWhy\fR,
2489
several variants may be set.
2490
A \fIhyphenation indicator\fR character may be embedded in a word to
2491
specify desired hyphenation points,
2492
or may be prefixed to suppress hyphenation.
2493
In addition,
2494
the user may specify a small list of exception words.
2495
.PP
2496
Only words that consist of a central alphabetic string
2497
surrounded by (usually null) non-alphabetic strings
2498
are candidates for automatic hyphenation.
2499
Words that contain hyphens
2500
(minus),
2501
em-dashes (\&\f(CW\e(em\fR),
2502
or hyphenation indicator characters
2503
are always subject to splitting after those characters,
2504
whether automatic hyphenation is on or off.
2505
.bt "\&\f(CW&nh\fR" "hyphenate" "-" "E" "Automatic hyphenation is turned off.
2506
.bt "\&\f(CW&hy\fP@~N@" "on, @N=1@" "on, @N=1@" "E" "Automatic hyphenation is turned on
2507
for @N >= 1@, or off for @N=0@.
2508
If @N=2@, last lines (ones that will cause a trap)
2509
are not hyphenated.
2510
For @N=4@ and 8, the last and first two characters
2511
respectively of a word are not split off.
2512
These values are additive;
2513
i.e., @N=14@ will invoke all three restrictions.
2514
.bt "\&\f(CW&hc\fI c\fR" "\&\f(CW\e%" "\e%\fR" "E" "Hyphenation indicator character is set
2515
to @c@ or to the default \&\f(CW\e%\fR.
2516
The indicator does not appear in the output.
2517
.bt "\&\f(CW&hw\fI word ...\fR" "" "ignored" "-" "Specify
2518
hyphenation points in words
2519
with embedded minus signs.
2520
Versions of a word with terminal \fIs\fR are implied;
2521
i.e.,
2522
.CW dig-it
2523
implies
2524
.CW dig-its .
2525
This list is examined initially and after
2526
each suffix stripping.
2527
The space available is small.
2528
.NH
2529
Three-Part Titles.
2530
.PP
2531
The titling function \&\f(CWtl\fR provides for automatic placement
2532
of three fields at the left, center, and right of a line
2533
with a title length
2534
specifiable with \&\f(CWlt\fR.
2535
\&\f(CWtl\fR may be used anywhere, and is independent of the
2536
normal text collecting process.
2537
A common use is in header and footer macros.
2538
.h1
2539
.bt "\&\f(CW&tl '\fIleft\fP'\fIcenter\fP'\fIright\fP'\fR" "-" "-" "" "The strings
2540
\fIleft\fR, \fIcenter\fR, and \fIright\fR are
2541
respectively left-adjusted, centered, and right-adjusted
2542
in the current title length.
2543
Any of the strings may be empty,
2544
and overlapping is permitted.
2545
If the page-number character (initially \&\f(CW%\fR) is found within any of the fields it is replaced
2546
by the current page number in the format assigned to register \&\f(CW%\fR.
2547
Any character may be used in place of
2548
.CW '
2549
as the string delimiter.
2550
.bt "\&\f(CW&pc\fI c\fR" "\&\f(CW%\fR" "off" "-" "The page number character is set to @c@,
2551
or removed.
2552
The page number register remains \&\f(CW%\fR.
2553
.bt "\&\f(CW&lt\fI \(+-N\fR" "6.5\|in" "previous" "E,\fBm\fR" "Length of title
2554
is set to @+- N@.
2555
The line length and the title length are independent.
2556
Indents do not apply to titles; page offsets do.
2557
.NH
2558
Output Line Numbering.
2559
.PP
2560
.ll -\w'0000'u
2561
.nm 1 3
2562
Automatic sequence numbering of output lines may be
2563
requested with \&\f(CWnm\fR.
2564
When in effect,
2565
a three-digit, arabic number plus a digit-space
2566
is prefixed to output text lines.
2567
The text lines are thus offset by four digit-spaces,
2568
and otherwise retain their line length;
2569
a reduction in line length may be desired to keep the right margin
2570
aligned with an earlier margin.
2571
Blank lines, other vertical spaces, and lines generated by \&\f(CWtl\fR
2572
are not numbered.
2573
Numbering can be temporarily suspended with \&\f(CWnn\fR,
2574
or with an \&\f(CW.nm\fR followed by a later \&\f(CW.nm +0\fR.
2575
In addition,
2576
a line number indent \fII\fR, and the number-text separation \fIS\fR
2577
may be specified in digit-spaces.
2578
Further, it can be specified that only those line numbers that are
2579
multiples of some number @M@ are to be printed (the others will appear
2580
as blank number fields).
2581
.br
2582
.nm
2583
.ll
2584
.bt "\&\f(CW&nm\fI \(+-N M S I\fR" "" "off" "E" "Line number mode.
2585
If @+- N@ is given,
2586
line numbering is turned on,
2587
and the next output line numbered is numbered @+- N@.
2588
Default values are @M=1@, @S=1@, and @I=0@.
2589
Parameters corresponding to missing arguments are unaffected;
2590
a non-numeric argument is considered missing.
2591
In the absence of all arguments, numbering is turned off;
2592
the next line number is preserved for possible further use
2593
in number register \&\f(CWln\fR.
2594
.bt "\&\f(CW&nn\fI N\fR" "-" "@N=1@" "E" "The next @N@ text output lines are not
2595
numbered.
2596
.PP
2597
.ll -\w'0000'u
2598
.nm +0
2599
As an example, the paragraph portions of this section
2600
are numbered with \fIM=\fR\|3:
2601
\&\&\f(CW.nm\ 1\ 3\fR was placed at the beginning;
2602
\&\&\f(CW.nm\fR was placed at the end of the first paragraph;
2603
and \&\f(CW.nm\ +0\fR was placed in front of this paragraph;
2604
and \&\f(CW.nm\fR finally placed at the end.
2605
Line lengths were also changed (by \&\f(CW\ew'0000'u\fR) to keep the right side aligned.
2606
Another example is
2607
.CW .nm
2608
.CW +5
2609
.CW 5
2610
.CW x
2611
.CW 3 ,
2612
which turns on numbering with the line number of the next
2613
line to be 5 greater than the last numbered line,
2614
with @M=5@, with spacing \fIS\fR untouched, and with the indent \fII\fR set to 3.
2615
.br
2616
.ll
2617
.nm
2618
.NH
2619
Conditional Acceptance of Input
2620
.PP
2621
In the following,
2622
@c@ is a one-character built-in \fIcondition\fR name,
2623
\&\f(CW!\fR signifies \fInot\fR,
2624
@N@ is a numerical expression,
2625
\fIstring1\fR and \fIstring2\fR are strings delimited by any non-blank, non-numeric character not in the strings,
2626
and
2627
\fIanything\fR represents what is conditionally accepted.
2628
.bt "\&\f(CW&if\fI c anything\fR" "-" "-" "" "If condition
2629
@c@ true, accept \fIanything\fR as input;
2630
in multi-line case use \e{\fIanything\|\fR\e}.
2631
.bt "\&\f(CW&if !\fIc anything\fR" "-" "-" "" "If condition @c@ false, accept \fIanything\fR.
2632
.bt "\&\f(CW&if\fI N anything\fR" "" "-" "\fBu\fR" "If expression @N@ > 0, accept \fIanything\fR.
2633
.bt "\&\f(CW&if !\fIN anything\fR" "" "-" "\fBu\fR" "If expression @N@ ≤ 0 [sic], accept \fIanything\fR.
2634
.bt "\&\f(CW&if '\fIstring1\f(CW'\fIstring2\f(CW'\fI anything\fR" "-" "" "" "If \fIstring1\fR identical to \fIstring2\fR,
2635
accept \fIanything\fR.
2636
.bt "\&\f(CW&if !'\fIstring1\f(CW'\fIstring2\f(CW'\fI anything\fR" "-" "" "" "If \fIstring1\fR not identical to \fIstring2\fR,
2637
accept \fIanything\fR.
2638
.bt "\&\f(CW&ie\fI c anything\fR" "" "-" "\fBu\fR" "If portion of if-else;
2639
all of the forms for \&\f(CWif\fR above are valid.
2640
.bt "\&\f(CW&el\fI anything\fR" "-" "-" "" "Else portion of if-else.
2641
.PP
2642
The built-in condition names are:
2643
.TS
2644
center box;
2645
c2|c2
2646
c2|c2
2647
c2|l2.
2648
Condition
2649
Name	True If
2650
_
2651
\&\f(CWo\fR	Current page number is odd
2652
\&\f(CWe\fR	Current page number is even
2653
\&\f(CWt\fR	Formatter is \*(TR
2654
\&\f(CWn\fR	Formatter is \*(NR
2655
.TE
2656
If the condition @c@ is true, or if the number @N@ is greater than zero,
2657
or if the strings compare identically (including motions and character size and font),
2658
\fIanything\fR is accepted as input.
2659
If a \&\f(CW!\fR precedes the condition, number, or string comparison,
2660
the sense of the acceptance is reversed.
2661
.PP
2662
Any spaces between the condition and the beginning of \fIanything\fR are skipped over.
2663
The \fIanything\fR can be either a single input line (text, macro, or whatever)
2664
or a number of input lines.
2665
In the multi-line case,
2666
the first line must begin with a left delimiter \&\f(CW\e{\fR and
2667
the last line must end with a right delimiter \&\f(CW\e}\fR.
2668
.PP
2669
The request \&\f(CWie\fR (if-else) is identical to \&\f(CWif\fR
2670
except that the acceptance state is remembered.
2671
A subsequent and matching \&\f(CWel\fR (else) request then uses the reverse sense of that state.
2672
\&\f(CWie\fR-\&\f(CWel\fR pairs may be nested.
2673
.PP
2674
Some examples are:
2675
.P1
2676
&if e .tl '\|Even Page %'''
2677
.P2
2678
which outputs a title if the page number is even; and
2679
.P1
2680
&ie \en%>1 \e{\e
2681
\&'	sp 0.5i
2682
&	tl 'Page %'''
2683
\&'	sp |1.2i \e}
2684
&el .sp |2.5i
2685
.P2
2686
which treats page 1 differently from other pages.
2687
.NH
2688
Environment Switching.
2689
.PP
2690
A number of the parameters that
2691
control the text processing are gathered together into an
2692
\fIenvironment\fR, which can be switched by the user.
2693
The environment parameters are those associated
2694
with requests noting E in their \fINotes\fR column;
2695
in addition, partially collected lines and words are in the environment.
2696
Everything else is global; examples are page-oriented parameters,
2697
diversion-oriented parameters, number registers, and macro and string definitions.
2698
All environments are initialized with default parameter values.
2699
.bt "\&\f(CW&ev\fI N\fR" "@N=0@" "previous" "-" "Environment switched to
2700
environment @0 <= N <= 2@.
2701
Switching is done in push-down fashion so that
2702
restoring a previous environment \fImust\fR be done with \&\f(CW.ev\fR
2703
rather than specific reference.
2704
Note that what is pushed down and restored is the environment
2705
.I number,
2706
not its contents.
2707
.NH
2708
Insertions from the Standard Input
2709
.PP
2710
The input can be temporarily switched to the system standard input
2711
with \&\f(CWrd\fR,
2712
which will switch back when two consecutive newlines
2713
are found (the extra blank line is not used).
2714
This mechanism is intended for insertions in form-letter-like documentation.
2715
The standard input can be the user's keyboard,
2716
a pipe, or a file.
2717
.bt "\&\f(CW&rd\fI prompt\fR" "-" "\fIprompt=\fR\s-1BEL\s+1" "-" "Read insertion
2718
from the standard input until two newlines in a row are found.
2719
If the standard input is the user's keyboard, \fIprompt\fR (or a \s-1BEL\s+1)
2720
is written onto the standard output.
2721
\&\f(CWrd\fR behaves like a macro,
2722
and arguments may be placed after \fIprompt\fR.
2723
.bt "\&\f(CW&ex\fR" "-" "-" "-" "Exit from \*(NR/\*(TR.
2724
Text processing is terminated exactly as if all input had ended.
2725
.PP
2726
If insertions are to be
2727
taken from the terminal keyboard while output is being printed
2728
on the terminal, the command line option \&\f(CW-q\fR will turn off the echoing
2729
of keyboard input and prompt only with \s-1BEL\s+1.
2730
The regular input and insertion input cannot
2731
simultaneously come from the standard input.
2732
.PP
2733
As an example,
2734
multiple copies of a form letter may be prepared by entering the insertions
2735
for all the copies in one file to be used as the standard input,
2736
and causing the file containing the letter to reinvoke itself with \&\f(CWnx\fR (§19);
2737
the process would ultimately be ended by an \&\f(CWex\fR in the insertion file.
2738
.NH
2739
Input/Output File Switching
2740
.bt "\&\f(CW&so\fI filename\fR" "" "-" "-" "Switch source file.
2741
The top input (file reading) level is switched to \fIfilename\fR.
2742
When the new file ends,
2743
input is again taken from the original file.
2744
\&\f(CWso\fR's may be nested.
2745
.bt "\&\f(CW&nx\fI filename\fR" "" "end-of-file" "-" "Next file is \fIfilename\fR.
2746
The current file is considered ended, and the input is immediately switched
2747
to \fIfilename\fR.
2748
.bt "\&\f(CW&sy\fI string\fR" "" "-" "-" "Execute program from \fIstring\fR,
2749
which is the rest of the input line.
2750
The output is not collected automatically.
2751
The number register
2752
.CW $$ ,
2753
which contains the process id of the \*(TR process,
2754
may be useful in generating unique filenames for output.
2755
.bt "\&\f(CW&pi\fI string\fR" "" "-" "-" "Pipe output to \fIstring\fR,
2756
which is the rest of the input line.
2757
This request must occur before any printing occurs;
2758
typically it is the first line of input.
2759
.bt "\&\f(CW&cf\fI filename\fR" "" "-" "-" "Copy
2760
contents of file
2761
.I filename
2762
to output, completely unprocessed.
2763
The file is assumed to contain something meaningful
2764
to subsequent processes.
2765
.NH
2766
Miscellaneous
2767
.br
2768
.mc \s12\(br\s0
2769
.bt "\&\f(CW.mc\fI c N\fR" - off E,\fBm\fR "Specifies
2770
that a \fImargin\fR character @c@ appear a distance
2771
@N@ to the right of the right margin
2772
after each non-empty text line (except those produced by \&\f(CWtl\fR).
2773
If the output line is too long (as can happen in nofill mode)
2774
the character will be appended to the line.
2775
If @N@ is not given, the previous @N@ is used; the initial @N@ is
2776
0.2 inches in \*(NR and 1 em in \*(TR.
2777
The margin character used with this paragraph was a 12-point box-rule.
2778
.br
2779
.mc
2780
.bt "\&\f(CW.tm\fI string\fR" "-" "newline" "-" "After skipping initial blanks,
2781
\fIstring\fR (rest of the line) is read in copy mode
2782
and written on the standard error.
2783
.bt "\&\f(CW&ab\fI string\fR" "-" "newline" "-" "After skipping initial blanks,
2784
\fIstring\fR (rest of the line) is read in copy mode
2785
and written on the standard error.
2786
\*(Tr or \*(NR then exit.
2787
.bt "\&\f(CW.ig\fI yy\fR" "-" "\fI.yy=\&\f(CW..\fR" "-" "Ignore
2788
input lines.
2789
\&\f(CWig\fR behaves exactly like \&\f(CWde\fR (§7) except that the
2790
input is discarded.
2791
The input is read in copy mode, and any auto-incremented
2792
registers will be affected.
2793
.bt "\&\f(CW.lf\fI N filename\fR" "" "-" "-" "Set
2794
line number to @N@ and filename to @filename@
2795
for purposes of subsequent error messages, etc.
2796
The number register [sic]
2797
.CW .F
2798
contains the name of the current input file,
2799
as set by command line argument,
2800
.CW so ,
2801
.CW nx ,
2802
or
2803
.CW lf .
2804
The number register
2805
.CW .c
2806
contains the number of input lines read from the current file,
2807
again perhaps as modified by
2808
.CW lf .
2809
.CW 
2810
.bt "\&\f(CW.pm\fI t\fR" "-" "all" "-" "Print macros.
2811
The names and sizes of all of the defined macros and strings are printed
2812
on the standard error;
2813
if \fIt\fR is given, only the total of the sizes is printed.
2814
The sizes is given in blocks
2815
of 128 characters.
2816
.bt "\&\f(CW.fl\fR" - - B "Flush output buffer.
2817
Force output, including any pending position information.
2818
......
2819
.NH
2820
Output and Error Messages.
2821
.PP
2822
The output from \&\f(CWtm\fR, \&\f(CWpm\fR, and the prompt from \&\f(CWrd\fR,
2823
as well as various error messages, are written onto
2824
the standard error.
2825
The latter is different from the standard output,
2826
where formatted text goes.
2827
By default, both are written onto the user's terminal,
2828
but they can be independently redirected.
2829
.PP
2830
Various error conditions may occur during
2831
the operation of \*(NR and \*(TR.
2832
Certain less serious errors having only local impact do not
2833
cause processing to terminate.
2834
Two examples are \fIword overflow\fR, caused by a word that is too large
2835
to fit into the word buffer (in fill mode), and
2836
\fIline overflow\fR, caused by an output line that grew too large
2837
to fit in the line buffer.
2838
In both cases, a message is printed, the offending excess
2839
is discarded,
2840
and the affected word or line is marked at the point of truncation
2841
with a \(** in \*(NR and a \(lh in \*(TR.
2842
Processing continues if possible,
2843
on the grounds that output useful for debugging may be produced.
2844
If a serious error occurs, processing terminates,
2845
and a message is printed, along with a list of the macro names currently active.
2846
Examples of serious errors include the inability to create, read, or write files,
2847
and the exceeding of certain internal limits that
2848
make future output unlikely to be useful.
2849
.NH
2850
Output Language
2851
.PP
2852
\*(Tr
2853
produces its output in a language that is independent of any
2854
specific output device,
2855
except that the numbers in it have been computed on the basis
2856
of the resolution of the device,
2857
and the sizes, fonts, and characters that that device can print.
2858
Nevertheless it is quite possible to interpret that output
2859
on a different device, within the latter's capabilities.
2860
.IP
2861
.nf
2862
.ta .7i
2863
@cw s n@	set point size to @n@
2864
@cw f n@	set font to @n@
2865
@cw c c@	print character @c@
2866
@cw C name@	print the character called @name@; terminate @name@ by white space
2867
@cw N n@	print character @n@ on current font
2868
@cw H n@	go to absolute horizontal position \f2n\fP (@n >= 0@)
2869
@cw V n@	go to absolute vertical position \f2n\fP (@n >= 0@, down is positive)
2870
@cw h n@	go \f2n\fP units horizontally; @n < 0@ is to the left
2871
@cw v n@	go \f2n\fP units vertically; @n < 0@ is up
2872
@nnc@	move right \f2nn\fP, then print \s-1UTF\s0 character \f2c\fP;  \f2nn\fP must be exactly 2 digits
2873
@cw p n@	new page \f2n\fP begins\(emset vertical position to 0
2874
@cw n b~a@	end of line (information only\(emno action);  \f2b\fP = space before line, \f2a\fP = after
2875
@cw w@	paddable word space (information only\(emno action)
2876
@cw D c@ ...\en	graphics function @c@; see below
2877
@cw x@ ...\en	device control functions; see below
2878
@cw "#"@ ...\en	comment
2879
.LP
2880
All position values are in units.
2881
Sequences that end in digits must be followed by a non-digit.
2882
Blanks, tabs and newlines may occur as separators
2883
in the input, and are mandatory to separate constructions
2884
that would otherwise be confused.
2885
Graphics functions, device control functions, and comments extend to the
2886
end of the line they occur on.
2887
.PP
2888
The device control and graphics commands are intended as open-ended
2889
families, to be expanded as needed.
2890
The graphics functions coincide directly with the
2891
.CW \eD 
2892
sequences:
2893
.IP
2894
.nf
2895
.ta 1.7i
2896
@cw Dl@ \f2dh dv\fP	draw line from current position by @dh,~ dv@
2897
@cw Dc@ \f2d\fP	draw circle of diameter \f2d\fP with left side here
2898
@cw De@ @dh sub 1~dv sub 2@	draw ellipse of diameters @dh sub 1@ and @ dv sub 2@\fP
2899
@cw Da ~dh sub 1~ dv sub 1 ~ dh sub 2 ~dv sub 2@	draw arc from current position to @dh sub 1 +dh sub 2 ,~ dv sub 1 +dv sub 2@,
2900
		   center at @dh sub 1 ,~ dv sub 1@ from current position
2901
@cw "D~" ~dh sub 1 ~dv sub 1 ~dh sub 2 ~dv sub 2@ ...	draw B-spline from current position to @dh sub 1 ,~ dv sub 1@,
2902
		   then to @dh sub 2 , ~dv sub 2@, then to ...
2903
@cw "D"z ~dh sub 1 ~dv sub 1 ~dh sub 2 ~dv sub 2@ ...	for any other @z@ is uninterpreted
2904
.LP
2905
In all of these, @dh, ~dv@ is an increment on the current horizontal and
2906
vertical position,
2907
with down and right positive.
2908
All distances and dimensions are in units.
2909
.PP
2910
The device control functions begin with
2911
.CW x ,
2912
then a command, then other parameters.
2913
.IP
2914
.ta .8i 1.2i
2915
.nf
2916
.ft CW
2917
x T \f2s\fP	\f1name of typesetter is @s@\f(CW
2918
x r \f2n h v\fP	\f1resolution is @n@ units/inch;\f(CW
2919
		\f1@h@ = minimum horizontal motion, @v@ = minimum vertical\f(CW
2920
x i	\f1initialize\fP
2921
x f \f2n s\fP	\f1mount font @s@ on font position @n@\f(CW
2922
x p	\f1pause\(emcan restart\f(CW
2923
x s	\f1stop\(emdone forever\f(CW
2924
x t	\f1generate trailer information, if any\f(CW
2925
x H \f2n\fP	\f1set character height to @n@\f(CW
2926
x S \f2n\fP	\f1set slant to @n@\f(CW
2927
x X \f2any\fP	\f1generated by the \&\f(CW\eX\fP function\f(CW
2928
x \f2any\fP	\f1to be ignored if not recognized\f(CW
2929
.LP
2930
Subcommands like
2931
.CW i '' ``
2932
may be spelled out like
2933
.CW init ''. ``
2934
.PP
2935
The commands
2936
.CW "x T" ,
2937
.CW "x r " ...,
2938
and
2939
.CW "x i"
2940
must occur first;
2941
fonts must be mounted before they can be used;
2942
.CW "x s
2943
comes last.
2944
There are no other order requirements.
2945
.PP
2946
The following is the output from
2947
.CW hello, "" ``
2948
.CW world ''
2949
for a typical printer,
2950
as described in §23:
2951
.P1
2952
x T utf
2953
x res 720 1 1
2954
x init
2955
V0
2956
p1
2957
.P2
2958
.P1
2959
x font 1 R
2960
x font 2 I
2961
x font 3 B
2962
x font 4 BI
2963
x font 5 CW
2964
x font 6 H
2965
x font 7 HB
2966
x font 8 HX
2967
x font 9 S1
2968
x font 10 S
2969
.P2
2970
.P1
2971
s10
2972
f1
2973
H0
2974
s10
2975
f1
2976
V0
2977
H720
2978
V120
2979
ch
2980
50e44l28l28o50,w58w72o50r33l28dn120 0
2981
x trailer
2982
V7920
2983
x stop
2984
.P2
2985
.PP
2986
\*(Tr output is normally not redundant;
2987
size and font changes and position information are not included
2988
unless needed.
2989
Nevertheless, each page is self-contained, for the benefit of postprocessors
2990
that re-order pages or process only a subset.
2991
.NH
2992
Device and Font Description Files
2993
.PP
2994
The parameters that describe a output device
2995
.I name
2996
are read
2997
from the directory
2998
.CW /sys/lib/troff/font/dev@name@ ,
2999
each time
3000
\*(TR
3001
is invoked.
3002
The device name is provided by default,
3003
by the environment variable
3004
.CW TYPESETTER ,
3005
or by a command-line argument
3006
.CW -T@name@ .
3007
The default device name is
3008
.CW utf ,
3009
for \s-1UTF\s0-encoded Unicode characters.
3010
The pre-defined string
3011
.CW .T
3012
contains the name of the device.
3013
The
3014
.CW -F
3015
command-line option may be used to change the default directory.
3016
.......
3017
.sc "Device description file.
3018
General parameters of the device are stored, one per line, in
3019
the file 
3020
.CW /sys/lib/troff/font/dev@name@/DESC ,
3021
as a sequence of names and values.
3022
\*(Tr recognizes these parameters, and ignores any
3023
others that may be present for specific drivers:
3024
.IP
3025
.nf
3026
.ta 1i
3027
@cw fonts ~ n ~ F sub 1  ~F sub 2  ~. . .~ F sub n@
3028
@cw sizes ~ s sub 1 ~ s sub 2 ~ . . . cw 0@
3029
@cw res ~n@
3030
@cw hor ~n@
3031
@cw vert ~n@
3032
@cw unitwidth ~n@
3033
@cw charset@
3034
\f2list of multi-character character names (optional)\fP
3035
.LP
3036
The @F sub i@ are font names
3037
to be initially mounted.
3038
The list of sizes is a set of integers representing
3039
some or all of the legal sizes the device can produce,
3040
terminated by a zero.
3041
The 
3042
.CW res
3043
parameter gives the resolution of the machine in units per inch;
3044
.CW hor
3045
and
3046
.CW ver
3047
give the minimum number of units that can be moved
3048
horizontally and vertically.
3049
.PP
3050
Character widths for each font are assumed to be given in machine units
3051
at point size
3052
.CW unitwidth .
3053
(In other words, a character with a width of
3054
@n@ is @n@ units wide at size
3055
.CW unitwidth .)
3056
All widths are integers at all sizes.
3057
.PP
3058
A list of valid character names may be introduced by
3059
.CW charset ;
3060
the list of names is optional.
3061
.PP
3062
A line whose first non-blank character is
3063
.CW #
3064
is a comment.
3065
Except that
3066
.CW charset
3067
must occur last, parameters may appear in any order.
3068
.PP
3069
Here is a subset of the
3070
.CW DESC
3071
file for a typical Postscript printer:
3072
.P1
3073
# Description file for Postscript printers.
3074
 
3075
fonts 10 R I B BI CW H HB HX S1 S
3076
sizes 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
3077
   24 25 26 27 28 29 30 31 32 33 34 35 36 38 40 44 48 54 60 72 0
3078
res 720
3079
hor 1
3080
vert 1
3081
unitwidth 10
3082
charset
3083
hy ct fi fl ff Fi Fl dg em 14 34 12 en aa
3084
ga ru sc dd -> br Sl ps cs cy as os =. ld
3085
rd le ge pp -+ ob vr
3086
sq bx ci fa te ** pl mi eq ~= *A *B *X *D
3087
*E *F *G *Y *I *K *L *M *N *O *P *R *H *S *T *U *W
3088
*C *Q *Z ul rn *a *b *x *d *e *f *g *y *i *k
3089
*l *m *n *o *p *h *r *s *t *u *w *c *q *z
3090
.P2
3091
.sc "Font description files.
3092
Each font is described by an analogous description file,
3093
which begins with parameters of the font, one per line, followed by a
3094
list of characters and widths.
3095
The file for font
3096
.I f
3097
is
3098
.CW /sys/lib/troff/font/dev@name@/@f@ .
3099
.IP
3100
.ta 1.7i
3101
.nf
3102
@cw name ~str@	name of font is @str@
3103
@cw ligatures ~ ". . ." ~ cw "0"@	list of ligatures
3104
@cw spacewidth ~n@	width of a space on this font
3105
@cw special@	this is a special font
3106
@cw charset@
3107
\f2list of character name, width, ascender/descender, code\fP, tab separated
3108
.LP
3109
The
3110
.CW name
3111
and
3112
.CW charset
3113
fields are mandatory;
3114
.CW charset
3115
must be last.
3116
Comments are permitted,
3117
as are other unrecognized parameters.
3118
.PP
3119
Each line following
3120
.CW charset 
3121
describes one character: its name, its width in units as described above,
3122
ascender/descender information, and a decimal, octal or hexadecimal value
3123
by which the output device knows it
3124
(the
3125
.CW \eN
3126
``number'' of the character).
3127
The character name is arbitrary, except that
3128
.CW ---
3129
signifies an unnamed character.
3130
If the width field contains
3131
.CW \&" ,
3132
the name is a synonym for the previous character.
3133
The ascender/descender field is 1 if
3134
the character has a descender (hangs below the baseline, like
3135
.CW y ),
3136
is 2 if it has an ascender (is tall, like
3137
.CW Y ),
3138
is 3 if both,
3139
and is 0 if neither.
3140
The value is returned
3141
in the 
3142
.CW ct
3143
register, as computed by the
3144
.CW \ew
3145
function (§11.2).
3146
.PP
3147
Here are excerpts from a typical font description file
3148
for the same Postscript printer.
3149
.P1
3150
hy	33	0	45	hyphen \e(hy
3151
-	"			- is a synonym for \e(hy
3152
.sp .3
3153
Q	72	3	81
3154
.sp .3
3155
a	44	0	97
3156
b	50	2	98
3157
c	44	0	99
3158
d	50	2	100
3159
y	50	1	121
3160
.sp .3
3161
em	100	0	208
3162
---	44	2	220	Pound symbol £, \eN'220'
3163
---	36	0	221	centered dot \eN'221'
3164
.P2
3165
This says, for example, that the width of the letter
3166
.CW a
3167
is 44 units at point size 10,
3168
the value of 
3169
.CW unitwidth .
3170
Point sizes are scaled linearly and rounded, so the width of
3171
.CW a
3172
will be 44 at size 10, 40 at size 9, 35 at size 8,
3173
and so on.
3174
.sp 100
3175
.BP
3176
.fp 8 C CW
3177
.tr &.
3178
.tr |
3179
.tr ~|
3180
.TL
3181
Tutorial Examples
3182
.SP
3183
....2C
3184
.sp .25i
3185
.SH
3186
Introduction
3187
.PP
3188
It is almost always necessary to
3189
prepare at least a small set of macro definitions
3190
to describe a document.
3191
Such common formatting needs
3192
as page margins and footnotes
3193
are deliberately not built into \*(NR and \*(TR.
3194
Instead,
3195
the macro and string definition, number register, diversion,
3196
environment switching, page-position trap, and conditional input mechanisms
3197
provide the basis for user-defined implementations.
3198
.PP
3199
For most uses, a standard package like
3200
.CW -ms
3201
or
3202
.CW -mm
3203
is the right choice.
3204
The next stage is to augment that,
3205
or to selectively replace macros from the standard package.
3206
The last stage, much harder,
3207
is to write one's own from scratch.
3208
This is not a task for the novice.
3209
.PP
3210
The examples discussed here are intended to be useful and somewhat realistic,
3211
but will not necessarily cover all relevant contingencies.
3212
Explicit numerical parameters are used
3213
in the examples
3214
to make them easier to read and to
3215
illustrate typical values.
3216
In many cases, number registers would be used
3217
to reduce the number of places where numerical
3218
information is kept,
3219
and to concentrate conditional parameter initialization
3220
like that which depends on whether \*(TR or \*(NR is being used.
3221
.SH
3222
Page Margins
3223
.PP
3224
As discussed in §3,
3225
header and footer macros are usually defined
3226
to describe the top and bottom page margin areas respectively.
3227
A trap is planted at page position 0 for the header, and at
3228
\fI-N\fR (\fIN\fR from the page bottom) for the footer.
3229
The simplest such definitions might be
3230
.P1 .1i
3231
&de hd	\e"define header
3232
\&'sp 1i
3233
&&	\e"end definition
3234
&de fo	\e"define footer
3235
\&'bp
3236
&&	\e"end definition
3237
&wh 0 hd
3238
&wh -1i fo
3239
.P2
3240
which provide blank 1 inch top and bottom margins.
3241
The header will occur on the \fIfirst\fR page
3242
only if the definition and trap exist prior to
3243
the initial pseudo-page transition (§3).
3244
In fill mode, the output line that springs the footer trap
3245
was typically forced out because some part or whole word didn't fit on it.
3246
If anything in the footer and header that follows causes a break,
3247
that word or part word will be forced out.
3248
In this and other examples,
3249
requests like \&\f(CWbp\fR and \&\f(CWsp\fR that normally cause breaks are invoked using
3250
the no-break control character \&\f(CW'\fR
3251
to avoid this.
3252
When the header/footer design contains material
3253
requiring independent text processing, the
3254
environment may be switched, avoiding
3255
most interaction with the running text.
3256
.PP
3257
A more realistic example would be
3258
.P1 .1i
3259
&de hd	\e"header
3260
&if \e\en%>1 \e{\e
3261
\&'sp ~0.5i-1	\e"tl base at 0.5i
3262
&tl ''- % -''	\e"centered page number
3263
&ps	\e"restore size
3264
&ft	\e"restore font
3265
&vs  \e}	\e"restore vs
3266
\&'sp ~1.0i  	\e"space to 1.0i
3267
&ns	\e"turn on no-space mode
3268
&&
3269
&de fo	\e"footer
3270
&ps 10	\e"set footer/header size
3271
&ft R	\e"set font
3272
&vs 12p	\e"set baseline spacing
3273
&if \e\en%=1 \e{\e
3274
\&'sp ~\e\en(.pu-0.5i-1  \e"tl base 0.5i up
3275
&tl ''- % -'' \e}  \e"first page number
3276
\&'bp
3277
&&
3278
&wh 0 hd
3279
&wh -1i fo
3280
.P2
3281
which sets the size, font, and baseline spacing for the
3282
header/footer material, and ultimately restores them.
3283
The material in this case is a page number at the bottom of the
3284
first page and at the top of the remaining pages.
3285
The \&\f(CWsp\fR's refer to absolute positions to avoid
3286
dependence on the baseline spacing.
3287
Another reason for doing this in the footer
3288
is that the footer is invoked by printing a line whose
3289
vertical spacing swept past the trap position by possibly
3290
as much as the baseline spacing.
3291
No-space mode is turned on at the end of \&\f(CWhd\fR
3292
to render ineffective
3293
accidental occurrences of \&\f(CWsp\fR at the top of the running text.
3294
.PP
3295
This method of restoring size, font, etc., presupposes
3296
that such requests (that set \fIprevious\fR value) are \fInot\fR
3297
used in the running text.
3298
A better scheme is to save and restore both the current \fIand\fR
3299
previous values as shown for size in the following:
3300
.P1 .1i
3301
&de fo
3302
&nr s1 \e\en(.s	\e"current size
3303
&ps
3304
&nr s2 \e\en(.s	\e"previous size
3305
&  ---	\e"rest of footer
3306
&&
3307
&de hd
3308
&  ---	\e"header stuff
3309
&ps \e\en(s2  \e"restore previous size
3310
&ps \e\en(s1  \e"restore current size
3311
&&
3312
.P2
3313
Page numbers may be printed in the bottom margin
3314
by a separate macro triggered during the footer's
3315
page ejection:
3316
.P1 .1i
3317
&de bn	\e"bottom number
3318
&tl ''- % -''	\e"centered page number
3319
&&
3320
&wh -0.5i-1v bn	 \e"tl base 0.5i up
3321
.P2
3322
.SH
3323
Paragraphs and Headings
3324
.PP
3325
The housekeeping
3326
associated with starting a new paragraph should be collected
3327
in a paragraph macro
3328
that, for example,
3329
does the desired preparagraph spacing,
3330
forces the correct font, size, baseline spacing, and indent,
3331
checks that enough space remains for \fImore than one\fR line,
3332
and
3333
requests a temporary indent.
3334
.P1 .1i
3335
&de pg    \e"paragraph
3336
&br       \e"break
3337
&ft R     \e"force font,
3338
&ps 10    \e"size,
3339
&vs 12p   \e"spacing,
3340
&in 0     \e"and indent
3341
&sp 0.4   \e"prespace
3342
&ne 1+\e\en(.Vu  \e"want more than 1 line
3343
&ti 0.2i         \e"temp indent
3344
&&
3345
.P2
3346
The first break in \&\f(CWpg\fR
3347
will force out any previous partial lines,
3348
and must occur before the \&\f(CWvs\fR.
3349
The forcing of font, etc., is
3350
partly a defense against prior error and
3351
partly to permit
3352
things like section heading macros to
3353
set parameters only once.
3354
The prespacing parameter is suitable for \*(TR;
3355
a larger space, at least as big as the output device vertical resolution, would be
3356
more suitable in \*(NR.
3357
The choice of remaining space to test for in the \&\f(CWne\fR
3358
is the smallest amount greater than one line
3359
(the \&\f(CW.V\fR is the available vertical resolution).
3360
.PP
3361
A macro to automatically number section headings
3362
might look like:
3363
.P1 .1i
3364
&de sc	\e"section
3365
&  ---	\e"force font, etc.
3366
&sp 0.4	\e"prespace
3367
&ne 2.4+\e\en(.Vu \e"want 2.4+ lines
3368
.lg 0
3369
&fi
3370
.lg
3371
\e\en+S.
3372
&&
3373
&nr S 0 1	\e"init S
3374
.P2
3375
The usage is \&\f(CW.sc\fR,
3376
followed by the section heading text,
3377
followed by \&\f(CW.pg\fR.
3378
The \&\f(CWne\fR test value includes one line of heading,
3379
0.4 line in the following \&\f(CWpg\fR, and
3380
one line of the paragraph text.
3381
A word consisting of the next section number and a period is
3382
produced to begin the heading line.
3383
The format of the number may be set by \&\f(CWaf\fR (§8).
3384
.PP
3385
Another common form is the labeled, indented paragraph,
3386
where the label protrudes left into the indent space.
3387
.P1 .1i
3388
&de lp	\e"labeled paragraph
3389
&pg
3390
&in 0.5i	\e"paragraph indent
3391
&ta 0.2i 0.5i	\e"label, paragraph
3392
&ti 0
3393
\et\e\e$1\et\ec	\e"flow into paragraph
3394
&&
3395
.P2
3396
The intended usage is ``\&\f(CW.lp\fR \fIlabel\fR\|'';
3397
\fIlabel\fR will begin at 0.2 inch, and
3398
cannot exceed a length of 0.3 inch without intruding into
3399
the paragraph.
3400
The label could be right adjusted against 0.4 inch by
3401
setting the tabs instead with \&\f(CW.ta|0.4iR|0.5i\fR.
3402
The last line of \&\f(CWlp\fR ends with \&\f(CW\ec\fR so that
3403
it will become a part of the first line of the text
3404
that follows.
3405
.SH
3406
Multiple Column Output
3407
.PP
3408
The production of multiple column pages requires
3409
the footer macro to decide whether it was
3410
invoked by other than the last column,
3411
so that it will begin a new column rather than
3412
produce the bottom margin.
3413
The header can initialize a column register that
3414
the footer will increment and test.
3415
The following is arranged for two columns, but
3416
is easily modified for more.
3417
.P1 .1i
3418
&de hd	\e"header
3419
&  ---
3420
&nr cl 0 1	\e"init column count
3421
&mk	\e"mark top of text
3422
&&
3423
.P2
3424
.P1 .1i
3425
&de fo	\e"footer
3426
&ie \e\en+(cl<2 \e{\e
3427
&po +3.4i	\e"next column; 3.1+0.3
3428
&rt	\e"back to mark
3429
&ns \e}	\e"no-space mode
3430
&el \e{\e
3431
&po \e\enMu	\e"restore left margin
3432
&  ---
3433
\&'bp \e}
3434
&&
3435
&ll 3.1i	\e"column width
3436
&nr M \e\en(.o	\e"save left margin
3437
.P2
3438
Typically a portion of the top of the first page
3439
contains full width text;
3440
the request for the narrower line length,
3441
as well as another \&\f(CW.mk\fR would
3442
be made where the two column output was to begin.
3443
.SH
3444
Footnotes
3445
.PP
3446
The footnote mechanism to be described is used by
3447
embedding the footnotes in the input text at the
3448
point of reference,
3449
demarcated by an initial \&\f(CW.fn\fR and a terminal \&\f(CW.ef\fR:
3450
.P1 .1i
3451
&fn
3452
\fIFootnote text and control lines...\fP
3453
&ef
3454
.P2
3455
In the following,
3456
footnotes are processed in a separate environment and diverted
3457
for later printing in the space immediately prior to the bottom
3458
margin.
3459
There is provision for the case where the last collected
3460
footnote doesn't completely fit in the available space.
3461
.P1 .1i
3462
&de hd	\e"header
3463
&  ---
3464
&nr x 0 1	\e"init footnote count
3465
&nr y 0-\e\enb	\e"current footer place
3466
&ch fo -\e\enbu	\e"reset footer trap
3467
&if \e\en(dn .fz	\e"leftover footnote
3468
&&
3469
.P2
3470
.P1 .1i
3471
&de fo	\e"footer
3472
&nr dn 0  \e"zero last diversion size
3473
&if \e\enx \e{\e
3474
&ev 1	\e"expand footnotes in ev1
3475
&nf	\e"retain vertical size
3476
&FN	\e"footnotes
3477
&rm FN	\e"delete it
3478
.P2
3479
.P1 .1i
3480
&if "\e\en(.z"fy" .di  \e"end overflow di
3481
&nr x 0	\e"disable fx
3482
&ev  \e}	\e"pop environment
3483
&  ---
3484
\&'bp
3485
&&
3486
.P2
3487
.P1 .1i
3488
&de fx	\e"process footnote overflow
3489
&if \e\enx .di fy	\e"divert overflow
3490
&&
3491
.P2
3492
.P1 .1i
3493
&de fn	\e"start footnote
3494
&da FN	\e"divert (append) footnote
3495
&ev 1	\e"in environment 1
3496
&if \e\en+x=1 .fs   \e"if 1st, separator
3497
&fi	\e"fill mode
3498
&&
3499
.P2
3500
.P1 .1i
3501
&de ef	\e"end footnote
3502
&br	\e"finish output
3503
&nr z \e\en(.v	\e"save spacing
3504
&ev	\e"pop ev
3505
&di	\e"end diversion
3506
&nr y -\e\en(dn	\e"new footer position,
3507
&if \e\enx=1 .nr y -(\e\en(.v-\e\enz) \e
3508
	\e"uncertainty correction
3509
&ch fo \e\enyu	\e"y is negative
3510
&if (\e\en(nl+1v)>(\e\en(.p+\e\eny) \e
3511
&ch fo \e\en(nlu+1v	 \e"didn't fit
3512
&&
3513
.P2
3514
.P1 .1i
3515
&de fs	\e"separator
3516
\el'1i'	\e"1 inch rule
3517
&br
3518
&&
3519
.P2
3520
.P1 .1i
3521
&de fz	\e"get leftover footnote
3522
&fn
3523
&nf	\e"retain vertical size
3524
&fy	\e"where fx put it
3525
&ef
3526
&&
3527
.P2
3528
.P1 .1i
3529
&nr b 1.0i  \e"bottom margin size
3530
&wh 0 hd    \e"header trap
3531
&wh 12i fo  \e"footer trap->temp pos
3532
&wh -\e\enbu fx	\e"fx at footer position
3533
&ch fo -\e\enbu	\e"conceal fx with fo
3534
.P2
3535
.PP
3536
The header \&\f(CWhd\fR initializes a footnote count register \&\f(CWx\fR,
3537
and sets both the current footer trap position register \&\f(CWy\fR and
3538
the footer trap itself to a nominal position specified in
3539
register \&\f(CWb\fR.
3540
In addition, if the register \&\f(CWdn\fR indicates a leftover footnote,
3541
\&\f(CWfz\fR is invoked to reprocess it.
3542
The footnote start macro \&\f(CWfn\fR begins a diversion (append) in environment 1,
3543
and increments the count \&\f(CWx\fR; if the count is one, the footnote separator \&\f(CWfs\fR
3544
is interpolated.
3545
The separator is kept in a separate macro to permit user redefinition.
3546
.PP
3547
The footnote end macro \&\f(CWef\fR restores
3548
the previous environment and ends the diversion after saving the spacing size in register \&\f(CWz\fR.
3549
\&\f(CWy\fR is then decremented by the size of the footnote, available in \&\f(CWdn\fR;
3550
then on the first footnote, \&\f(CWy\fR is further decremented by the difference
3551
in vertical baseline spacings of the two environments, to
3552
prevent the late triggering of the footer trap from causing the last
3553
line of the combined footnotes to overflow.
3554
The footer trap is then set to the lower (on the page) of \&\f(CWy\fR or the current page position (\&\f(CWnl\fR)
3555
plus one line, to allow for printing the reference line.
3556
.PP
3557
If indicated by \&\f(CWx\fR, the footer \&\f(CWfo\fR rereads the footnotes from \&\f(CWFN\fR in nofill mode
3558
in environment 1,
3559
and deletes \&\f(CWFN\fR.
3560
If the footnotes were too large to fit, the macro \&\f(CWfx\fR will be trap-invoked to redivert
3561
the overflow into \&\f(CWfy\fR,
3562
and the register \&\f(CWdn\fR will later indicate to the header whether \&\f(CWfy\fR is empty.
3563
.PP
3564
Both \&\f(CWfo\fR and \&\f(CWfx\fR are planted in the nominal footer trap position in an order
3565
that causes \&\f(CWfx\fR to be concealed unless the \&\f(CWfo\fR trap is moved.
3566
The footer then terminates the overflow diversion, if necessary, and
3567
zeros \&\f(CWx\fR to disable \&\f(CWfx\fR,
3568
because the uncertainty correction
3569
together with a not-too-late triggering of the footer can result
3570
in the footnote rereading finishing before reaching the \&\f(CWfx\fR trap.
3571
.PP
3572
A good exercise for the student is to combine the multiple-column and footnote mechanisms.
3573
.SH
3574
The Last Page
3575
.PP
3576
After the last input file has ended, \*(NR and \*(TR
3577
invoke the \fIend macro\fR (§7), if any,
3578
and when it finishes, eject the remainder of the page.
3579
During the eject, any traps encountered are processed normally.
3580
At the end of this last page, processing terminates
3581
unless a partial line, word, or partial word remains.
3582
If it is desired that another page be started, the end-macro
3583
.P1 .1i
3584
&de en	\e"end-macro
3585
\ec
3586
\&'bp
3587
&&
3588
&em en
3589
.P2
3590
will deposit a null partial word,
3591
and produce another last page.
3592
....1C
3593
.sp 100
3594
.BP
3595
........
3596
.TL
3597
Special Character Names
3598
.SP
3599
.PP
3600
The following table lists names for a set of characters,
3601
most of which have traditionally been provided by \*(TR using
3602
the `special' or `symbol' font.
3603
Many of these sequences are old ways to get what are now Unicode
3604
characters;
3605
Lucida Sans, for example, has glyphs corresponding to many of these
3606
but does not have the special sequences.
3607
Therefore
3608
the \*(TR sequence
3609
.CW \e(*F
3610
gives the character \(*F from the Times font instead of the
3611
character Φ from the current font, in this case Lucida Sans.
3612
Not all sequences print on any particular device, including this one; Peter
3613
faces appear in their place.
3614
.TS
3615
center;
3616
l l20fCW l l20fCW l l20fCW.
3617
\&\'	\e'	\(*m	\e(*m	\(~=	\e(~=
3618
\`	\e`	\(*n	\e(*n	\(ap	\e(ap
3619
\(em	\e(em	\(*c	\e(*c	\(!=	\e(!=
3620
\(en	\e(en	\(*o	\e(*o	\(->	\e(->
3621
\(hy	\e(hy	\(*p	\e(*p	\(<-	\e(<-
3622
\-	\e-	\(*r	\e(*r	\(ua	\e(ua
3623
\(bu	\e(bu	\(*s	\e(*s	\(da	\e(da
3624
\(sq	\e(sq	\(ts	\e(ts	\(mu	\e(mu
3625
\(ru	\e(ru	\(*t	\e(*t	\(di	\e(di
3626
\(14	\e(14	\(*u	\e(*u	\(+-	\e(+-
3627
\(12	\e(12	\(*f	\e(*f	\(cu	\e(cu
3628
\(34	\e(34	\(*x	\e(*x	\(ca	\e(ca
3629
\(fi	\e(fi	\(*q	\e(*q	\(sb	\e(sb
3630
\(fl	\e(fl	\(*w	\e(*w	\(sp	\e(sp
3631
\(ff	\e(ff	\(*A	\e(*A	\(ib	\e(ib
3632
\(Fi	\e(Fi	\(*B	\e(*B	\(ip	\e(ip
3633
\(Fl	\e(Fl	\(*G	\e(*G	\(if	\e(if
3634
\(de	\e(de	\(*D	\e(*D	\(pd	\e(pd
3635
\(dg	\e(dg	\(*E	\e(*E	\(gr	\e(gr
3636
\(fm	\e(fm	\(*Z	\e(*Z	\(no	\e(no
3637
\(ct	\e(ct	\(*Y	\e(*Y	\(is	\e(is
3638
\(rg	\e(rg	\(*H	\e(*H	\(pt	\e(pt
3639
\(co	\e(co	\(*I	\e(*I	\(es	\e(es
3640
\(pl	\e(pl	\(*K	\e(*K	\(mo	\e(mo
3641
\(mi	\e(mi	\(*L	\e(*L	\(br	\e(br
3642
\(eq	\e(eq	\(*M	\e(*M	\(dd	\e(dd
3643
\(**	\e(**	\(*N	\e(*N	\(rh	\e(rh
3644
\(sc	\e(sc	\(*C	\e(*C	\(lh	\e(lh
3645
\(aa	\e(aa	\(*O	\e(*O	\(L1	\e(bs
3646
\(ga	\e(ga	\(*P	\e(*P	\(or	\e(or
3647
\(ul	\e(ul	\(*R	\e(*R	\(ci	\e(ci
3648
\(sl	\e(sl	\(*S	\e(*S	\(lt	\e(lt
3649
\(*a	\e(*a	\(*T	\e(*T	\(lb	\e(lb
3650
\(*b	\e(*b	\(*U	\e(*U	\(rt	\e(rt
3651
\(*g	\e(*g	\(*F	\e(*F	\(rb	\e(rb
3652
\(*d	\e(*d	\(*X	\e(*X	\(lk	\e(lk
3653
\(*e	\e(*e	\(*Q	\e(*Q	\(rk	\e(rk
3654
\(*z	\e(*z	\(*W	\e(*W	\(bv	\e(bv
3655
\(*y	\e(*y	\(sr	\e(sr	\(lf	\e(lf
3656
\(*h	\e(*h	\(rn	\e(rn	\(rf	\e(rf
3657
\(*i	\e(*i	\(>=	\e(>=	\(lc	\e(lc
3658
\(*k	\e(*k	\(<=	\e(<=	\(rc	\e(rc
3659
\(*l	\e(*l	\(==	\e(==	\d\h'-5m'\(LH\u	\e(LH
3660
.TE