~ubuntu-branches/ubuntu/utopic/groff/utopic-proposed

« back to all changes in this revision

Viewing changes to .pc/texinfo-syntax.patch/doc/groff.texinfo

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2014-01-08 02:22:41 UTC
  • Revision ID: package-import@ubuntu.com-20140108022241-v9q5y36a81oxmj8t
Tags: 1.22.2-4
* Move debian/source.lintian-overrides to preferred location of
  debian/source/lintian-overrides.
* Use 'set -e' rather than '#! /bin/sh -e' in maintainer scripts.
* Fix bad Texinfo markup for \z escape.
* Fix grolbp crash if a printer was never created (thanks, Mayhem team at
  CMU; closes: #716003).
* Force gzip compression for groff-base.deb, to avoid causing problems for
  debootstrap on non-Debian-based systems following dpkg 1.17.0.
* Switch to git; adjust Vcs-* fields.
* Add support for various new BSD versions (thanks, Guillem Jover; closes:
  #717608).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
\input texinfo
 
2
 
 
3
@c
 
4
@c Please convert this manual with `texi2dvi -e groff.texinfo' due to
 
5
@c problems in texinfo regarding expansion of user-defined macros.
 
6
@c
 
7
@c You need texinfo 4.8 or newer to format this document!
 
8
@c
 
9
 
 
10
@c %**start of header (This is for running Texinfo on a region.)
 
11
@setfilename groff.info
 
12
@settitle The GNU Troff Manual
 
13
@setchapternewpage odd
 
14
@footnotestyle separate
 
15
@c %**end of header (This is for running Texinfo on a region.)
 
16
 
 
17
@documentlanguage en
 
18
@documentencoding ISO-8859-1
 
19
 
 
20
 
 
21
@smallbook
 
22
 
 
23
@finalout
 
24
 
 
25
 
 
26
@copying
 
27
This manual documents GNU @code{troff} version 1.22.2.
 
28
 
 
29
Copyright @copyright{} 1994-2013 Free Software Foundation, Inc.
 
30
 
 
31
@quotation
 
32
Permission is granted to copy, distribute and/or modify this document
 
33
under the terms of the GNU Free Documentation License, Version 1.3 or
 
34
any later version published by the Free Software Foundation; with no
 
35
Invariant Sections, with the Front-Cover texts being `A GNU Manual,''
 
36
and with the Back-Cover Texts as in (a) below.  A copy of the license is
 
37
included in the section entitled `GNU Free Documentation License.''
 
38
 
 
39
(a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
 
40
modify this GNU manual.  Buying copies from the FSF supports it in
 
41
developing GNU and promoting software freedom.''
 
42
@end quotation
 
43
@end copying
 
44
 
 
45
 
 
46
@c We use the following indices:
 
47
@c
 
48
@c   cindex: concepts
 
49
@c   rqindex: requests
 
50
@c   esindex: escapes
 
51
@c   vindex: registers
 
52
@c   kindex: commands in font files
 
53
@c   pindex: programs and files
 
54
@c   tindex: environment variables
 
55
@c   maindex: macros
 
56
@c   stindex: strings
 
57
@c   opindex: operators
 
58
@c
 
59
@c tindex and cindex are merged.
 
60
 
 
61
@defcodeindex rq
 
62
@defcodeindex es
 
63
@defcodeindex ma
 
64
@defcodeindex st
 
65
@defcodeindex op
 
66
@syncodeindex tp cp
 
67
 
 
68
 
 
69
@c To avoid uppercasing in @deffn while converting to info, we define
 
70
@c our special @Var{}.
 
71
 
 
72
@macro Var{arg}
 
73
@r{@slanted{\arg\}}
 
74
@end macro
 
75
 
 
76
 
 
77
@c To assure correct HTML translation, some ugly hacks are necessary.
 
78
@c While processing a @def... request, the HTML translator looks at the
 
79
@c next line to decide whether to start indentation, and if the line
 
80
@c starts with @def... (e.g. @deffnx), indentation is started.  We must
 
81
@c therefore ensure that a @def... is seen, during macro expansion.
 
82
@c
 
83
@c The following macros have to be used:
 
84
@c
 
85
@c One item:
 
86
@c
 
87
@c   @Def...
 
88
@c
 
89
@c Two items:
 
90
@c
 
91
@c   @Def...List
 
92
@c   @Def...ListEnd
 
93
@c
 
94
@c More than two:
 
95
@c
 
96
@c   @Def...List
 
97
@c   @Def...Item
 
98
@c   @Def...Item
 
99
@c   ...
 
100
@c   @Def...ListEnd
 
101
@c
 
102
@c The definition block must end with
 
103
@c
 
104
@c   @endDef...
 
105
@c
 
106
@c The above is valid for texinfo 4.0f and above.
 
107
 
 
108
 
 
109
@c a dummy macro to assure the `@def...'
 
110
 
 
111
@macro defdummy
 
112
@c
 
113
@end macro
 
114
 
 
115
 
 
116
@c definition of requests
 
117
 
 
118
@macro Defreq{name, arg}
 
119
@deffn Request @t{.\name\} \arg\
 
120
@rqindex \name\
 
121
@c
 
122
@end macro
 
123
 
 
124
@macro DefreqList{name, arg}
 
125
@deffn Request @t{.\name\} \arg\
 
126
@defdummy
 
127
@rqindex \name\
 
128
@c
 
129
@end macro
 
130
 
 
131
@macro DefreqItem{name, arg}
 
132
@deffnx Request @t{.\name\} \arg\
 
133
@defdummy
 
134
@rqindex \name\
 
135
@c
 
136
@end macro
 
137
 
 
138
@macro DefreqListEnd{name, arg}
 
139
@deffnx Request @t{.\name\} \arg\
 
140
@rqindex \name\
 
141
@c
 
142
@end macro
 
143
 
 
144
@macro endDefreq
 
145
@end deffn
 
146
@end macro
 
147
 
 
148
 
 
149
@c definition of escapes
 
150
 
 
151
@macro Defesc{name, delimI, arg, delimII}
 
152
@deffn Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
 
153
@esindex \name\
 
154
@c
 
155
@end macro
 
156
 
 
157
@macro DefescList{name, delimI, arg, delimII}
 
158
@deffn Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
 
159
@defdummy
 
160
@esindex \name\
 
161
@c
 
162
@end macro
 
163
 
 
164
@macro DefescItem{name, delimI, arg, delimII}
 
165
@deffnx Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
 
166
@defdummy
 
167
@esindex \name\
 
168
@c
 
169
@end macro
 
170
 
 
171
@macro DefescListEnd{name, delimI, arg, delimII}
 
172
@deffnx Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
 
173
@esindex \name\
 
174
@c
 
175
@end macro
 
176
 
 
177
@macro endDefesc
 
178
@end deffn
 
179
@end macro
 
180
 
 
181
 
 
182
@c definition of registers
 
183
 
 
184
@macro Defreg{name}
 
185
@deffn Register @t{\\n[\name\]}
 
186
@vindex \name\
 
187
@c
 
188
@end macro
 
189
 
 
190
@macro DefregList{name}
 
191
@deffn Register @t{\\n[\name\]}
 
192
@defdummy
 
193
@vindex \name\
 
194
@c
 
195
@end macro
 
196
 
 
197
@macro DefregItem{name}
 
198
@deffnx Register @t{\\n[\name\]}
 
199
@defdummy
 
200
@vindex \name\
 
201
@c
 
202
@end macro
 
203
 
 
204
@macro DefregListEnd{name}
 
205
@deffnx Register @t{\\n[\name\]}
 
206
@vindex \name\
 
207
@c
 
208
@end macro
 
209
 
 
210
@macro endDefreg
 
211
@end deffn
 
212
@end macro
 
213
 
 
214
 
 
215
@c definition of registers specific to macro packages, preprocessors, etc.
 
216
 
 
217
@macro Defmpreg{name, package}
 
218
@deffn Register @t{\\n[\name\]}
 
219
@vindex \name\ @r{[}\package\@r{]}
 
220
@c
 
221
@end macro
 
222
 
 
223
@macro DefmpregList{name, package}
 
224
@deffn Register @t{\\n[\name\]}
 
225
@defdummy
 
226
@vindex \name\ @r{[}\package\@r{]}
 
227
@c
 
228
@end macro
 
229
 
 
230
@macro DefmpregItem{name, package}
 
231
@deffnx Register @t{\\n[\name\]}
 
232
@defdummy
 
233
@vindex \name\ @r{[}\package\@r{]}
 
234
@c
 
235
@end macro
 
236
 
 
237
@macro DefmpregListEnd{name, package}
 
238
@deffnx Register @t{\\n[\name\]}
 
239
@vindex \name\ @r{[}\package\@r{]}
 
240
@c
 
241
@end macro
 
242
 
 
243
@macro endDefmpreg
 
244
@end deffn
 
245
@end macro
 
246
 
 
247
 
 
248
@c definition of macros
 
249
 
 
250
@macro Defmac{name, arg, package}
 
251
@defmac @t{.\name\} \arg\
 
252
@maindex \name\ @r{[}\package\@r{]}
 
253
@c
 
254
@end macro
 
255
 
 
256
@macro DefmacList{name, arg, package}
 
257
@defmac @t{.\name\} \arg\
 
258
@defdummy
 
259
@maindex \name\ @r{[}\package\@r{]}
 
260
@c
 
261
@end macro
 
262
 
 
263
@macro DefmacItem{name, arg, package}
 
264
@defmacx @t{.\name\} \arg\
 
265
@defdummy
 
266
@maindex \name\ @r{[}\package\@r{]}
 
267
@c
 
268
@end macro
 
269
 
 
270
@macro DefmacListEnd{name, arg, package}
 
271
@defmacx @t{.\name\} \arg\
 
272
@maindex \name\ @r{[}\package\@r{]}
 
273
@c
 
274
@end macro
 
275
 
 
276
@macro endDefmac
 
277
@end defmac
 
278
@end macro
 
279
 
 
280
 
 
281
@c definition of strings
 
282
 
 
283
@macro Defstr{name, package}
 
284
@deffn String @t{\\*[\name\]}
 
285
@stindex \name\ @r{[}\package\@r{]}
 
286
@c
 
287
@end macro
 
288
 
 
289
@macro DefstrList{name, package}
 
290
@deffn String @t{\\*[\name\]}
 
291
@defdummy
 
292
@stindex \name\ @r{[}\package\@r{]}
 
293
@c
 
294
@end macro
 
295
 
 
296
@macro DefstrItem{name, package}
 
297
@deffnx String @t{\\*[\name\]}
 
298
@defdummy
 
299
@stindex \name\ @r{[}\package\@r{]}
 
300
@c
 
301
@end macro
 
302
 
 
303
@macro DefstrListEnd{name, package}
 
304
@deffnx String @t{\\*[\name\]}
 
305
@stindex \name\ @r{[}\package\@r{]}
 
306
@c
 
307
@end macro
 
308
 
 
309
@macro endDefstr
 
310
@end deffn
 
311
@end macro
 
312
 
 
313
 
 
314
@c our example macros
 
315
 
 
316
@macro Example
 
317
@example
 
318
@group
 
319
@end macro
 
320
 
 
321
@macro endExample
 
322
@end group
 
323
@end example
 
324
@end macro
 
325
 
 
326
@macro CartoucheExample
 
327
@cartouche
 
328
@example
 
329
@end macro
 
330
 
 
331
@macro endCartoucheExample
 
332
@end example
 
333
@end cartouche
 
334
@end macro
 
335
 
 
336
 
 
337
@c <text>
 
338
 
 
339
@tex
 
340
\gdef\Langlemacro{\angleleft}
 
341
\gdef\Ranglemacro{\angleright}
 
342
@end tex
 
343
 
 
344
@iftex
 
345
@set Langlemacro @Langlemacro
 
346
@set Ranglemacro @Ranglemacro
 
347
@end iftex
 
348
 
 
349
@ifnottex
 
350
@set Langlemacro <
 
351
@set Ranglemacro >
 
352
@end ifnottex
 
353
 
 
354
@macro angles{text}
 
355
@value{Langlemacro}@r{\text\}@value{Ranglemacro}
 
356
@end macro
 
357
 
 
358
 
 
359
@c a <= sign
 
360
@c
 
361
@c A value defined with @set is embedded into three group levels if
 
362
@c called with @value, so we need seven \aftergroup to put \le outside
 
363
@c of the groups -- this is necessary to get proper mathematical
 
364
@c spacing.
 
365
 
 
366
@tex
 
367
\gdef\LEmacro{\aftergroup\aftergroup\aftergroup\aftergroup
 
368
              \aftergroup\aftergroup\aftergroup\le}
 
369
@end tex
 
370
 
 
371
@iftex
 
372
@set LEmacro @LEmacro
 
373
@end iftex
 
374
 
 
375
@ifnottex
 
376
@set LEmacro <=
 
377
@end ifnottex
 
378
 
 
379
@macro LE
 
380
@value{LEmacro}
 
381
@end macro
 
382
 
 
383
 
 
384
@c Special care is required with parentheses, brackets, and braces:
 
385
@c
 
386
@c . Real parentheses in @deffn produce an error while compiling with
 
387
@c   TeX.
 
388
@c . Real brackets use the wrong font in @deffn, overriding @t{}.
 
389
@c
 
390
@c . @{ and @} fail with info if used in a macro.
 
391
@c
 
392
@c Since macros aren't expanded in @deffn during -E, the following
 
393
@c definitions are for non-TeX only.
 
394
@c
 
395
@c This is true for texinfo 4.0 and above.
 
396
 
 
397
@iftex
 
398
@set Lparenmacro @lparen
 
399
@set Rparenmacro @rparen
 
400
@set Lbrackmacro @lbrack
 
401
@set Rbrackmacro @rbrack
 
402
@set Lbracemacro @{
 
403
@set Rbracemacro @}
 
404
@end iftex
 
405
 
 
406
@ifnottex
 
407
@set Lparenmacro (
 
408
@set Rparenmacro )
 
409
@set Lbrackmacro [
 
410
@set Rbrackmacro ]
 
411
@set Lbracemacro @{
 
412
@set Rbracemacro @}
 
413
@end ifnottex
 
414
 
 
415
@macro Lparen{}
 
416
@value{Lparenmacro}
 
417
@end macro
 
418
@macro Rparen{}
 
419
@value{Rparenmacro}
 
420
@end macro
 
421
@macro Lbrack{}
 
422
@value{Lbrackmacro}
 
423
@end macro
 
424
@macro Rbrack{}
 
425
@value{Rbrackmacro}
 
426
@end macro
 
427
@macro Lbrace{}
 
428
@value{Lbracemacro}
 
429
@end macro
 
430
@macro Rbrace{}
 
431
@value{Rbracemacro}
 
432
@end macro
 
433
 
 
434
 
 
435
@c This suppresses the word `Appendix' in the appendix headers.
 
436
 
 
437
@tex
 
438
\gdef\gobblefirst#1#2{#2}
 
439
\gdef\putwordAppendix{\gobblefirst}
 
440
@end tex
 
441
 
 
442
 
 
443
@c We map some latin-1 characters to corresponding texinfo macros.
 
444
@c Newer versions of texinfo.tex have similar code included already.
 
445
 
 
446
@tex
 
447
\global\catcode`^^e4\active % �
 
448
\gdef^^e4{\"a}
 
449
\global\catcode`^^c4\active % �
 
450
\gdef^^c4{\"A}
 
451
\global\catcode`^^e9\active % �
 
452
\gdef^^e9{\'e}
 
453
\global\catcode`^^c9\active % �
 
454
\gdef^^c9{\'E}
 
455
\global\catcode`^^f6\active % �
 
456
\gdef^^f6{\"o}
 
457
\global\catcode`^^d6\active % �
 
458
\gdef^^d6{\"O}
 
459
\global\catcode`^^fc\active % �
 
460
\gdef^^fc{\"u}
 
461
\global\catcode`^^dc\active % �
 
462
\gdef^^dc{\"U}
 
463
\global\catcode`^^e6\active % �
 
464
\gdef^^e6{\ae}
 
465
\global\catcode`^^c6\active % �
 
466
\gdef^^c6{\AE}
 
467
\global\catcode`^^df\active % �
 
468
\gdef^^df{\ss}
 
469
@end tex
 
470
 
 
471
 
 
472
@c Note: We say `Roman numerals' but `roman font'.
 
473
 
 
474
 
 
475
@dircategory Typesetting
 
476
@direntry
 
477
* Groff: (groff).               The GNU troff document formatting system.
 
478
@end direntry
 
479
 
 
480
 
 
481
@titlepage
 
482
@title groff
 
483
@subtitle The GNU implementation of @code{troff}
 
484
@subtitle Edition 1.22.2
 
485
@subtitle Spring 2013
 
486
@author by Trent A.@tie{}Fisher
 
487
@author and Werner Lemberg (@email{bug-groff@@gnu.org})
 
488
 
 
489
@page
 
490
@vskip 0pt plus 1filll
 
491
@insertcopying
 
492
@end titlepage
 
493
 
 
494
@contents
 
495
 
 
496
@ifnottex
 
497
@node Top, Introduction, (dir), (dir)
 
498
@top GNU troff
 
499
@end ifnottex
 
500
 
 
501
@menu
 
502
* Introduction::
 
503
* Invoking groff::
 
504
* Tutorial for Macro Users::
 
505
* Macro Packages::
 
506
* gtroff Reference::
 
507
* Preprocessors::
 
508
* Output Devices::
 
509
* File formats::
 
510
* Installation::
 
511
* Copying This Manual::
 
512
* Request Index::
 
513
* Escape Index::
 
514
* Operator Index::
 
515
* Register Index::
 
516
* Macro Index::
 
517
* String Index::
 
518
* Glyph Name Index::
 
519
* Font File Keyword Index::
 
520
* Program and File Index::
 
521
* Concept Index::
 
522
@end menu
 
523
 
 
524
@ifnottex
 
525
@insertcopying
 
526
@end ifnottex
 
527
 
 
528
 
 
529
 
 
530
@c =====================================================================
 
531
@c =====================================================================
 
532
 
 
533
@node Introduction, Invoking groff, Top, Top
 
534
@chapter Introduction
 
535
@cindex introduction
 
536
 
 
537
GNU @code{troff} (or @code{groff}) is a system for typesetting
 
538
documents.  @code{troff} is very flexible and has been used extensively
 
539
for some thirty years.  It is well entrenched in the @acronym{UNIX}
 
540
community.
 
541
 
 
542
@menu
 
543
* What Is groff?::
 
544
* History::
 
545
* groff Capabilities::
 
546
* Macro Package Intro::
 
547
* Preprocessor Intro::
 
548
* Output device intro::
 
549
* Credits::
 
550
@end menu
 
551
 
 
552
 
 
553
@c =====================================================================
 
554
 
 
555
@node What Is groff?, History, Introduction, Introduction
 
556
@section What Is @code{groff}?
 
557
@cindex what is @code{groff}?
 
558
@cindex @code{groff} -- what is it?
 
559
 
 
560
@code{groff} belongs to an older generation of document preparation
 
561
systems, which operate more like compilers than the more recent
 
562
interactive @acronym{WYSIWYG}@footnote{What You See Is What You Get}
 
563
systems.  @code{groff} and its contemporary counterpart, @TeX{}, both
 
564
work using a @dfn{batch} paradigm: The input (or @dfn{source}) files are
 
565
normal text files with embedded formatting commands.  These files can
 
566
then be processed by @code{groff} to produce a typeset document on a
 
567
variety of devices.
 
568
 
 
569
@code{groff} should not be confused with a @dfn{word processor}, an
 
570
integrated system of editor and text formatter.  Also, many word
 
571
processors follow the @acronym{WYSIWYG} paradigm discussed earlier.
 
572
 
 
573
Although @acronym{WYSIWYG} systems may be easier to use, they have a
 
574
number of disadvantages compared to @code{troff}:
 
575
 
 
576
@itemize @bullet
 
577
@item
 
578
They must be used on a graphics display to work on a document.
 
579
 
 
580
@item
 
581
Most of the @acronym{WYSIWYG} systems are either non-free or are not
 
582
very portable.
 
583
 
 
584
@item
 
585
@code{troff} is firmly entrenched in all @acronym{UNIX} systems.
 
586
 
 
587
@item
 
588
It is difficult to have a wide range of capabilities within the confines
 
589
of a GUI/window system.
 
590
 
 
591
@item
 
592
It is more difficult to make global changes to a document.
 
593
@end itemize
 
594
 
 
595
@quotation
 
596
``GUIs normally make it simple to accomplish simple actions and
 
597
impossible to accomplish complex actions.''  --Doug Gwyn (22/Jun/91 in
 
598
@code{comp.unix.wizards})
 
599
@end quotation
 
600
 
 
601
 
 
602
@c =====================================================================
 
603
 
 
604
@node History, groff Capabilities, What Is groff?, Introduction
 
605
@section History
 
606
@cindex history
 
607
 
 
608
@cindex @code{RUNOFF}, the program
 
609
@cindex @code{rf}, the program
 
610
@code{troff} can trace its origins back to a formatting program called
 
611
@code{RUNOFF}, written by Jerry Saltzer, which ran on the @acronym{CTSS}
 
612
(@emph{Compatible Time Sharing System}, a project of MIT, the
 
613
Massachusetts Institute of Technology) in the
 
614
mid-sixties.@footnote{Jerome H.@: Saltzer, a grad student then, later a
 
615
Professor of Electrical Engineering, now retired.  Saltzer's PhD thesis
 
616
was the first application for @code{RUNOFF} and is available from the
 
617
MIT Libraries.}  The name came from the use of the phrase ``run off a
 
618
document'', meaning to print it out.
 
619
@c
 
620
@c Tom Van Vleck <thvv@multicians.org> writes about the following:
 
621
@c
 
622
@c I am not sure about this.. I think the BCPL runoff was the port to
 
623
@c the 635 architecture, and that the order of events is
 
624
@c 1. CTSS runoff
 
625
@c 2. BCPL runoff on Multics
 
626
@c 3. BCPL runoff on 635
 
627
@c 4. rf on PDP-7
 
628
@c
 
629
Bob Morris ported it to the 635 architecture and called the program
 
630
@code{roff} (an abbreviation of @code{runoff}).  It was rewritten as
 
631
@code{rf} for the @w{PDP-7} (before having @acronym{UNIX}), and at the
 
632
same time (1969), Doug McIllroy rewrote an extended and simplified
 
633
version of @code{roff} in the @acronym{BCPL} programming language.
 
634
 
 
635
@cindex @code{roff}, the program
 
636
In 1971, the UNIX developers wanted to get a @w{PDP-11}, and to justify
 
637
the cost, proposed the development of a document formatting system for
 
638
the @acronym{AT&T} patents division.  This first formatting program was
 
639
a reimplementation of McIllroy's @code{roff}, written by J.@tie{}F.@:
 
640
Ossanna.
 
641
 
 
642
@cindex @code{nroff}, the program
 
643
When they needed a more flexible language, a new version of @code{roff}
 
644
called @code{nroff} (``Newer @code{roff}'') was written.  It had a much
 
645
more complicated syntax, but provided the basis for all future versions.
 
646
When they got a Graphic Systems CAT Phototypesetter, Ossanna wrote a
 
647
version of @code{nroff} that would drive it.  It was dubbed
 
648
@code{troff}, for ``typesetter @code{roff}'', although many people have
 
649
speculated that it actually means ``Times @code{roff}'' because of the
 
650
use of the Times font family in @code{troff} by default.  As such, the
 
651
name @code{troff} is pronounced `@w{t-roff}' rather than `trough'.
 
652
 
 
653
With @code{troff} came @code{nroff} (they were actually the same program
 
654
except for some @samp{#ifdef}s), which was for producing output for line
 
655
printers and character terminals.  It understood everything @code{troff}
 
656
did, and ignored the commands which were not applicable (e.g.@: font
 
657
changes).
 
658
 
 
659
Since there are several things which cannot be done easily in
 
660
@code{troff}, work on several preprocessors began.  These programs would
 
661
transform certain parts of a document into @code{troff}, which made a
 
662
very natural use of pipes in @acronym{UNIX}.
 
663
 
 
664
The @code{eqn} preprocessor allowed mathematical formul� to be specified
 
665
in a much simpler and more intuitive manner.  @code{tbl} is a
 
666
preprocessor for formatting tables.  The @code{refer} preprocessor (and
 
667
the similar program, @code{bib}) processes citations in a document
 
668
according to a bibliographic database.
 
669
 
 
670
Unfortunately, Ossanna's @code{troff} was written in @w{PDP-11} assembly
 
671
language and produced output specifically for the CAT phototypesetter.
 
672
He rewrote it in C, although it was now 7000@tie{}lines of uncommented
 
673
code and still dependent on the CAT.  As the CAT became less common, and
 
674
was no longer supported by the manufacturer, the need to make it support
 
675
other devices became a priority.  However, before this could be done,
 
676
Ossanna died by a severe heart attack in a hospital while recovering
 
677
from a previous one.
 
678
 
 
679
@pindex ditroff
 
680
@cindex @code{ditroff}, the program
 
681
So, Brian Kernighan took on the task of rewriting @code{troff}.  The
 
682
newly rewritten version produced device independent code which was very
 
683
easy for postprocessors to read and translate to the appropriate printer
 
684
codes.  Also, this new version of @code{troff} (called @code{ditroff}
 
685
for ``device independent @code{troff}'') had several extensions, which
 
686
included drawing functions.
 
687
 
 
688
Due to the additional abilities of the new version of @code{troff},
 
689
several new preprocessors appeared.  The @code{pic} preprocessor
 
690
provides a wide range of drawing functions.  Likewise the @code{ideal}
 
691
preprocessor did the same, although via a much different paradigm.  The
 
692
@code{grap} preprocessor took specifications for graphs, but, unlike
 
693
other preprocessors, produced @code{pic} code.
 
694
 
 
695
James Clark began work on a GNU implementation of @code{ditroff} in
 
696
early@tie{}1989.  The first version, @code{groff}@tie{}0.3.1, was
 
697
released June@tie{}1990.  @code{groff} included:
 
698
 
 
699
@itemize @bullet
 
700
@item
 
701
A replacement for @code{ditroff} with many extensions.
 
702
 
 
703
@item
 
704
The @code{soelim}, @code{pic}, @code{tbl}, and @code{eqn} preprocessors.
 
705
 
 
706
@item
 
707
Postprocessors for character devices, @sc{PostScript}, @TeX{} DVI, and
 
708
X@tie{}Windows.  GNU @code{troff} also eliminated the need for a
 
709
separate @code{nroff} program with a postprocessor which would produce
 
710
@acronym{ASCII} output.
 
711
 
 
712
@item
 
713
A version of the @file{me} macros and an implementation of the
 
714
@file{man} macros.
 
715
@end itemize
 
716
 
 
717
Also, a front-end was included which could construct the, sometimes
 
718
painfully long, pipelines required for all the post- and preprocessors.
 
719
 
 
720
Development of GNU @code{troff} progressed rapidly, and saw the
 
721
additions of a replacement for @code{refer}, an implementation of the
 
722
@file{ms} and @file{mm} macros, and a program to deduce how to format a
 
723
document (@code{grog}).
 
724
 
 
725
It was declared a stable (i.e.@: non-beta) package with the release of
 
726
version@tie{}1.04 around November@tie{}1991.
 
727
 
 
728
Beginning in@tie{}1999, @code{groff} has new maintainers (the package
 
729
was an orphan for a few years).  As a result, new features and programs
 
730
like @code{grn}, a preprocessor for gremlin images, and an output device
 
731
to produce @acronym{HTML} and @acronym{XHTML} have been added.
 
732
 
 
733
 
 
734
@c =====================================================================
 
735
 
 
736
@node groff Capabilities, Macro Package Intro, History, Introduction
 
737
@section @code{groff} Capabilities
 
738
@cindex @code{groff} capabilities
 
739
@cindex capabilities of @code{groff}
 
740
 
 
741
So what exactly is @code{groff} capable of doing?  @code{groff} provides
 
742
a wide range of low-level text formatting operations.  Using these, it
 
743
is possible to perform a wide range of formatting tasks, such as
 
744
footnotes, table of contents, multiple columns, etc.  Here's a list of
 
745
the most important operations supported by @code{groff}:
 
746
 
 
747
@itemize @bullet
 
748
@item
 
749
text filling, adjusting, and centering
 
750
 
 
751
@item
 
752
hyphenation
 
753
 
 
754
@item
 
755
page control
 
756
 
 
757
@item
 
758
font and glyph size control
 
759
 
 
760
@item
 
761
vertical spacing (e.g.@: double-spacing)
 
762
 
 
763
@item
 
764
line length and indenting
 
765
 
 
766
@item
 
767
macros, strings, diversions, and traps
 
768
 
 
769
@item
 
770
number registers
 
771
 
 
772
@item
 
773
tabs, leaders, and fields
 
774
 
 
775
@item
 
776
input and output conventions and character translation
 
777
 
 
778
@item
 
779
overstrike, bracket, line drawing, and zero-width functions
 
780
 
 
781
@item
 
782
local horizontal and vertical motions and the width function
 
783
 
 
784
@item
 
785
three-part titles
 
786
 
 
787
@item
 
788
output line numbering
 
789
 
 
790
@item
 
791
conditional acceptance of input
 
792
 
 
793
@item
 
794
environment switching
 
795
 
 
796
@item
 
797
insertions from the standard input
 
798
 
 
799
@item
 
800
input/output file switching
 
801
 
 
802
@item
 
803
output and error messages
 
804
@end itemize
 
805
 
 
806
 
 
807
@c =====================================================================
 
808
 
 
809
@node Macro Package Intro, Preprocessor Intro, groff Capabilities, Introduction
 
810
@section Macro Packages
 
811
@cindex macro packages
 
812
 
 
813
Since @code{groff} provides such low-level facilities, it can be quite
 
814
difficult to use by itself.  However, @code{groff} provides a
 
815
@dfn{macro} facility to specify how certain routine operations
 
816
(e.g.@tie{}starting paragraphs, printing headers and footers, etc.)@:
 
817
should be done.  These macros can be collected together into a
 
818
@dfn{macro package}.  There are a number of macro packages available;
 
819
the most common (and the ones described in this manual) are @file{man},
 
820
@file{mdoc}, @file{me}, @file{ms}, and @file{mm}.
 
821
 
 
822
 
 
823
@c =====================================================================
 
824
 
 
825
@node Preprocessor Intro, Output device intro, Macro Package Intro, Introduction
 
826
@section Preprocessors
 
827
@cindex preprocessors
 
828
 
 
829
Although @code{groff} provides most functions needed to format a
 
830
document, some operations would be unwieldy (e.g.@: to draw pictures).
 
831
Therefore, programs called @dfn{preprocessors} were written which
 
832
understand their own language and produce the necessary @code{groff}
 
833
operations.  These preprocessors are able to differentiate their own
 
834
input from the rest of the document via markers.
 
835
 
 
836
To use a preprocessor, @acronym{UNIX} pipes are used to feed the output
 
837
from the preprocessor into @code{groff}.  Any number of preprocessors
 
838
may be used on a given document; in this case, the preprocessors are
 
839
linked together into one pipeline.  However, with @code{groff}, the user
 
840
does not need to construct the pipe, but only tell @code{groff} what
 
841
preprocessors to use.
 
842
 
 
843
@code{groff} currently has preprocessors for producing tables
 
844
(@code{tbl}), typesetting equations (@code{eqn}), drawing pictures
 
845
(@code{pic} and @code{grn}), processing bibliographies
 
846
(@code{refer}), and drawing chemical structures (@code{chem}).  An
 
847
associated program which is useful when dealing with preprocessors is
 
848
@code{soelim}.
 
849
 
 
850
A free implementation of @code{grap}, a preprocessor for drawing graphs,
 
851
can be obtained as an extra package; @code{groff} can use @code{grap}
 
852
also.
 
853
 
 
854
Unique to @code{groff} is the @code{preconv} preprocessor which enables
 
855
@code{groff} to handle documents in various input encodings.
 
856
 
 
857
There are other preprocessors in existence, but, unfortunately, no free
 
858
implementations are available.  Among them is a preprocessor for drawing
 
859
mathematical pictures (@code{ideal}).
 
860
 
 
861
 
 
862
@c =====================================================================
 
863
 
 
864
@node Output device intro, Credits, Preprocessor Intro, Introduction
 
865
@section Output Devices
 
866
@cindex postprocessors
 
867
@cindex output devices
 
868
@cindex devices for output
 
869
 
 
870
@code{groff} actually produces device independent code which may be fed
 
871
into a postprocessor to produce output for a particular device.
 
872
Currently, @code{groff} has postprocessors for @sc{PostScript} devices,
 
873
character terminals, X@tie{}Windows (for previewing), @TeX{} DVI format,
 
874
HP LaserJet@tie{}4 and Canon LBP printers (which use @acronym{CAPSL}),
 
875
@acronym{HTML}, @acronym{XHTML}, and PDF.
 
876
 
 
877
 
 
878
@c =====================================================================
 
879
 
 
880
@node Credits,  , Output device intro, Introduction
 
881
@section Credits
 
882
@cindex credits
 
883
 
 
884
Large portions of this manual were taken from existing documents, most
 
885
notably, the manual pages for the @code{groff} package by James Clark,
 
886
and Eric Allman's papers on the @file{me} macro package.
 
887
 
 
888
The section on the @file{man} macro package is partly based on
 
889
Susan@tie{}G.@: Kleinmann's @file{groff_man} manual page written for the
 
890
Debian GNU/Linux system.
 
891
 
 
892
Larry Kollar contributed the section in the @file{ms} macro package.
 
893
 
 
894
 
 
895
 
 
896
@c =====================================================================
 
897
@c =====================================================================
 
898
 
 
899
@node Invoking groff, Tutorial for Macro Users, Introduction, Top
 
900
@chapter Invoking @code{groff}
 
901
@cindex invoking @code{groff}
 
902
@cindex @code{groff} invocation
 
903
 
 
904
This section focuses on how to invoke the @code{groff} front end.  This
 
905
front end takes care of the details of constructing the pipeline among
 
906
the preprocessors, @code{gtroff} and the postprocessor.
 
907
 
 
908
It has become a tradition that GNU programs get the prefix @samp{g} to
 
909
distinguish it from its original counterparts provided by the host (see
 
910
@ref{Environment}, for more details).  Thus, for example, @code{geqn} is
 
911
GNU @code{eqn}.  On operating systems like GNU/Linux or the Hurd, which
 
912
don't contain proprietary versions of @code{troff}, and on
 
913
MS-DOS/MS-Windows, where @code{troff} and associated programs are not
 
914
available at all, this prefix is omitted since GNU @code{troff} is the
 
915
only used incarnation of @code{troff}.  Exception: @samp{groff} is never
 
916
replaced by @samp{roff}.
 
917
 
 
918
In this document, we consequently say @samp{gtroff} when talking about
 
919
the GNU @code{troff} program.  All other implementations of @code{troff}
 
920
are called @acronym{AT&T} @code{troff} which is the common origin of all
 
921
@code{troff} derivates (with more or less compatible changes).
 
922
Similarly, we say @samp{gpic}, @samp{geqn}, etc.
 
923
 
 
924
@menu
 
925
* Groff Options::
 
926
* Environment::
 
927
* Macro Directories::
 
928
* Font Directories::
 
929
* Paper Size::
 
930
* Invocation Examples::
 
931
@end menu
 
932
 
 
933
 
 
934
@c =====================================================================
 
935
 
 
936
@node Groff Options, Environment, Invoking groff, Invoking groff
 
937
@section Options
 
938
@cindex options
 
939
 
 
940
@pindex groff
 
941
@pindex gtroff
 
942
@pindex gpic
 
943
@pindex geqn
 
944
@pindex ggrn
 
945
@pindex grap
 
946
@pindex gtbl
 
947
@pindex gchem
 
948
@pindex grefer
 
949
@pindex gsoelim
 
950
@pindex preconv
 
951
@code{groff} normally runs the @code{gtroff} program and a
 
952
postprocessor appropriate for the selected device.  The default device
 
953
is @samp{ps} (but it can be changed when @code{groff} is configured and
 
954
built).  It can optionally preprocess with any of @code{gpic},
 
955
@code{geqn}, @code{gtbl}, @code{ggrn}, @code{grap}, @code{gchem},
 
956
@code{grefer}, @code{gsoelim}, or @code{preconv}.
 
957
 
 
958
This section only documents options to the @code{groff} front end.  Many
 
959
of the arguments to @code{groff} are passed on to @code{gtroff},
 
960
therefore those are also included.  Arguments to pre- or postprocessors
 
961
can be found in @ref{Invoking gpic}, @ref{Invoking geqn}, @ref{Invoking
 
962
gtbl}, @ref{Invoking ggrn}, @ref{Invoking grefer}, @ref{Invoking gchem},
 
963
@ref{Invoking gsoelim}, @ref{Invoking preconv}, @ref{Invoking grotty},
 
964
@ref{Invoking grops}, @ref{Invoking gropdf}, @ref{Invoking grohtml},
 
965
@ref{Invoking grodvi}, @ref{Invoking grolj4}, @ref{Invoking grolbp}, and
 
966
@ref{Invoking gxditview}.
 
967
 
 
968
The command line format for @code{groff} is:
 
969
 
 
970
@Example
 
971
groff [ -abceghijklpstvzCEGNRSUVXZ ] [ -d@var{cs} ] [ -D@var{arg} ]
 
972
      [ -f@var{fam} ] [ -F@var{dir} ] [ -I@var{dir} ] [ -K@var{arg} ]
 
973
      [ -L@var{arg} ] [ -m@var{name} ] [ -M@var{dir} ] [ -n@var{num} ]
 
974
      [ -o@var{list} ] [ -P@var{arg} ] [ -r@var{cn} ] [ -T@var{def} ]
 
975
      [ -w@var{name} ] [ -W@var{name} ] [ @var{files}@dots{} ]
 
976
@endExample
 
977
 
 
978
The command line format for @code{gtroff} is as follows.
 
979
 
 
980
@Example
 
981
gtroff [ -abcivzCERU ] [ -d@var{cs} ] [ -f@var{fam} ] [ -F@var{dir} ]
 
982
       [ -m@var{name} ] [ -M@var{dir} ] [ -n@var{num} ] [ -o@var{list} ]
 
983
       [ -r@var{cn} ] [ -T@var{name} ] [ -w@var{name} ] [ -W@var{name} ]
 
984
       [ @var{files}@dots{} ]
 
985
@endExample
 
986
 
 
987
@noindent
 
988
Obviously, many of the options to @code{groff} are actually passed on to
 
989
@code{gtroff}.
 
990
 
 
991
Options without an argument can be grouped behind a
 
992
single@tie{}@option{-}.  A filename of@tie{}@file{-} denotes the
 
993
standard input.  It is possible to have whitespace between an option and
 
994
its parameter.
 
995
 
 
996
The @code{grog} command can be used to guess the correct @code{groff}
 
997
command to format a file.
 
998
 
 
999
Here's the description of the command-line options:
 
1000
 
 
1001
@cindex command-line options
 
1002
@table @samp
 
1003
@item -a
 
1004
@cindex @acronym{ASCII} approximation output register (@code{.A})
 
1005
Generate an @acronym{ASCII} approximation of the typeset output.  The
 
1006
read-only register @code{.A} is then set to@tie{}1.  @xref{Built-in
 
1007
Registers}.  A typical example is
 
1008
 
 
1009
@Example
 
1010
groff -a -man -Tdvi troff.man | less
 
1011
@endExample
 
1012
 
 
1013
@noindent
 
1014
which shows how lines are broken for the DVI device.  Note that this
 
1015
option is rather useless today since graphic output devices are
 
1016
available virtually everywhere.
 
1017
 
 
1018
@item -b
 
1019
Print a backtrace with each warning or error message.  This backtrace
 
1020
should help track down the cause of the error.  The line numbers given
 
1021
in the backtrace may not always be correct: @code{gtroff} can get
 
1022
confused by @code{as} or @code{am} requests while counting line numbers.
 
1023
 
 
1024
@item -c
 
1025
Suppress color output.
 
1026
 
 
1027
@item -C
 
1028
Enable compatibility mode.  @xref{Implementation Differences}, for the
 
1029
list of incompatibilities between @code{groff} and @acronym{AT&T}
 
1030
@code{troff}.
 
1031
 
 
1032
@item -d@var{c}@var{s}
 
1033
@itemx -d@var{name}=@var{s}
 
1034
Define @var{c} or @var{name} to be a string@tie{}@var{s}.
 
1035
@var{c}@tie{}must be a one-letter name; @var{name} can be of arbitrary
 
1036
length.  All string assignments happen before loading any macro file
 
1037
(including the start-up file).
 
1038
 
 
1039
@item -D@var{arg}
 
1040
Set default input encoding used by @code{preconv} to @var{arg}.  Implies
 
1041
@option{-k}.
 
1042
 
 
1043
@item -e
 
1044
Preprocess with @code{geqn}.
 
1045
 
 
1046
@item -E
 
1047
Inhibit all error messages.
 
1048
 
 
1049
@item -f@var{fam}
 
1050
Use @var{fam} as the default font family.  @xref{Font Families}.
 
1051
 
 
1052
@item -F@var{dir}
 
1053
Search @file{@var{dir}} for subdirectories @file{dev@var{name}}
 
1054
(@var{name} is the name of the device), for the @file{DESC} file, and
 
1055
for font files before looking in the standard directories (@pxref{Font
 
1056
Directories}).  This option is passed to all pre- and postprocessors
 
1057
using the @env{GROFF_FONT_PATH} environment variable.
 
1058
 
 
1059
@item -g
 
1060
Preprocess with @code{ggrn}.
 
1061
 
 
1062
@item -G
 
1063
Preprocess with @code{grap}.  Implies @option{-p}.
 
1064
 
 
1065
@item -h
 
1066
Print a help message.
 
1067
 
 
1068
@item -i
 
1069
Read the standard input after all the named input files have been
 
1070
processed.
 
1071
 
 
1072
@item -I@var{dir}
 
1073
This option may be used to specify a directory to search for files.
 
1074
It is passed to the following programs:
 
1075
 
 
1076
@itemize
 
1077
@item
 
1078
@code{gsoelim} (see @ref{gsoelim} for more details);
 
1079
it also implies @code{groff}'s @option{-s} option.
 
1080
 
 
1081
@item
 
1082
@code{gtroff}; it is used to search files named in the @code{psbb} and
 
1083
@code{so} requests.
 
1084
 
 
1085
@item
 
1086
@code{grops}; it is used to search files named in the
 
1087
@w{@code{\X'ps: import}} and @w{@code{\X'ps: file}} escapes.
 
1088
@end itemize
 
1089
 
 
1090
The current directory is always searched first.  This option may be
 
1091
specified more than once; the directories are searched in the order
 
1092
specified.  No directory search is performed for files specified using
 
1093
an absolute path.
 
1094
 
 
1095
@item -j
 
1096
Preprocess with @code{gchem}.  Implies @option{-p}.
 
1097
 
 
1098
@item -k
 
1099
Preprocess with @code{preconv}.  This is run before any other
 
1100
preprocessor.  Please refer to @code{preconv}'s manual page for its
 
1101
behaviour if no @option{-K} (or @option{-D}) option is specified.
 
1102
 
 
1103
@item -K@var{arg}
 
1104
Set input encoding used by preconv to @var{arg}.  Implies @option{-k}.
 
1105
 
 
1106
@item -l
 
1107
Send the output to a spooler for printing.  The command used for this is
 
1108
specified by the @code{print} command in the device description file
 
1109
(see @ref{Font Files}, for more info).  If not present, @option{-l} is
 
1110
ignored.
 
1111
 
 
1112
@item -L@var{arg}
 
1113
Pass @var{arg} to the spooler.  Each argument should be passed with a
 
1114
separate @option{-L} option.  Note that @code{groff} does not prepend a
 
1115
@samp{-} to @var{arg} before passing it to the postprocessor.  If the
 
1116
@code{print} keyword in the device description file is missing,
 
1117
@option{-L} is ignored.
 
1118
 
 
1119
@item -m@var{name}
 
1120
Read in the file @file{@var{name}.tmac}.  Normally @code{groff} searches
 
1121
for this in its macro directories.  If it isn't found, it tries
 
1122
@file{tmac.@var{name}} (searching in the same directories).
 
1123
 
 
1124
@item -M@var{dir}
 
1125
Search directory @file{@var{dir}} for macro files before the standard
 
1126
directories (@pxref{Macro Directories}).
 
1127
 
 
1128
@item -n@var{num}
 
1129
Number the first page @var{num}.
 
1130
 
 
1131
@item -N
 
1132
Don't allow newlines with @code{eqn} delimiters.  This is the same as
 
1133
the @option{-N} option in @code{geqn}.
 
1134
 
 
1135
@item -o@var{list}
 
1136
@cindex print current page register (@code{.P})
 
1137
Output only pages in @var{list}, which is a comma-separated list of page
 
1138
ranges; @samp{@var{n}} means print page@tie{}@var{n},
 
1139
@samp{@var{m}-@var{n}} means print every page between @var{m}
 
1140
and@tie{}@var{n}, @samp{-@var{n}} means print every page up
 
1141
to@tie{}@var{n}, @samp{@var{n}-} means print every page beginning
 
1142
with@tie{}@var{n}.  @code{gtroff} exits after printing the last page in
 
1143
the list.  All the ranges are inclusive on both ends.
 
1144
 
 
1145
Within @code{gtroff}, this information can be extracted with the
 
1146
@samp{.P} register.  @xref{Built-in Registers}.
 
1147
 
 
1148
If your document restarts page numbering at the beginning of each
 
1149
chapter, then @code{gtroff} prints the specified page range for each
 
1150
chapter.
 
1151
 
 
1152
@item -p
 
1153
Preprocess with @code{gpic}.
 
1154
 
 
1155
@item -P@var{arg}
 
1156
Pass @var{arg} to the postprocessor.  Each argument should be passed
 
1157
with a separate @option{-P} option.  Note that @code{groff} does not
 
1158
prepend @samp{-} to @var{arg} before passing it to the postprocessor.
 
1159
 
 
1160
@item -r@var{c}@var{n}
 
1161
@itemx -r@var{name}=@var{n}
 
1162
Set number register@tie{}@var{c} or @var{name} to the
 
1163
value@tie{}@var{n}.  @var{c}@tie{}must be a one-letter name; @var{name}
 
1164
can be of arbitrary length.  @var{n}@tie{}can be any @code{gtroff}
 
1165
numeric expression.  All register assignments happen before loading any
 
1166
macro file (including the start-up file).
 
1167
 
 
1168
@item -R
 
1169
Preprocess with @code{grefer}.  No mechanism is provided for passing
 
1170
arguments to @code{grefer} because most @code{grefer} options have
 
1171
equivalent commands which can be included in the file.  @xref{grefer},
 
1172
for more details.
 
1173
 
 
1174
@pindex troffrc
 
1175
@pindex troffrc-end
 
1176
Note that @code{gtroff} also accepts a @option{-R} option, which is not
 
1177
accessible via @code{groff}.  This option prevents the loading of the
 
1178
@file{troffrc} and @file{troffrc-end} files.
 
1179
 
 
1180
@item -s
 
1181
Preprocess with @code{gsoelim}.
 
1182
 
 
1183
@item -S
 
1184
@cindex @code{open} request, and safer mode
 
1185
@cindex @code{opena} request, and safer mode
 
1186
@cindex @code{pso} request, and safer mode
 
1187
@cindex @code{sy} request, and safer mode
 
1188
@cindex @code{pi} request, and safer mode
 
1189
@cindex safer mode
 
1190
@cindex mode, safer
 
1191
Safer mode.  Pass the @option{-S} option to @code{gpic} and disable the
 
1192
@code{open}, @code{opena}, @code{pso}, @code{sy}, and @code{pi}
 
1193
requests.  For security reasons, this is enabled by default.
 
1194
 
 
1195
@item -t
 
1196
Preprocess with @code{gtbl}.
 
1197
 
 
1198
@item -T@var{dev}
 
1199
Prepare output for device @var{dev}.  The default device is @samp{ps},
 
1200
unless changed when @code{groff} was configured and built.  The
 
1201
following are the output devices currently available:
 
1202
 
 
1203
@table @code
 
1204
@item ps
 
1205
For @sc{PostScript} printers and previewers.
 
1206
 
 
1207
@item pdf
 
1208
For PDF viewers or printers.
 
1209
 
 
1210
@item dvi
 
1211
For @TeX{} DVI format.
 
1212
 
 
1213
@item X75
 
1214
For a 75@dmn{dpi} X11 previewer.
 
1215
 
 
1216
@item X75-12
 
1217
For a 75@dmn{dpi} X11 previewer with a 12@dmn{pt} base font in the
 
1218
document.
 
1219
 
 
1220
@item X100
 
1221
For a 100@dmn{dpi} X11 previewer.
 
1222
 
 
1223
@item X100-12
 
1224
For a 100@dmn{dpi} X11 previewer with a 12@dmn{pt} base font in the
 
1225
document.
 
1226
 
 
1227
@item ascii
 
1228
@cindex encoding, output, @acronym{ASCII}
 
1229
@cindex @acronym{ASCII}, output encoding
 
1230
@cindex output encoding, @acronym{ASCII}
 
1231
For typewriter-like devices using the (7-bit) @acronym{ASCII}
 
1232
character set.
 
1233
 
 
1234
@item latin1
 
1235
@cindex encoding, output, @w{latin-1} (ISO @w{8859-1})
 
1236
@cindex @w{latin-1} (ISO @w{8859-1}), output encoding
 
1237
@cindex ISO @w{8859-1} (@w{latin-1}), output encoding
 
1238
@cindex output encoding, @w{latin-1} (ISO @w{8859-1})
 
1239
For typewriter-like devices that support the @w{Latin-1}
 
1240
(ISO@tie{}@w{8859-1}) character set.
 
1241
 
 
1242
@item utf8
 
1243
@cindex encoding, output, @w{utf-8}
 
1244
@cindex @w{utf-8}, output encoding
 
1245
@cindex output encoding, @w{utf-8}
 
1246
For typewriter-like devices which use the Unicode (ISO@tie{}10646)
 
1247
character set with @w{UTF-8} encoding.
 
1248
 
 
1249
@item cp1047
 
1250
@cindex encoding, output, @acronym{EBCDIC}
 
1251
@cindex @acronym{EBCDIC}, output encoding
 
1252
@cindex output encoding, @acronym{EBCDIC}
 
1253
@cindex encoding, output, cp1047
 
1254
@cindex cp1047, output encoding
 
1255
@cindex output encoding, cp1047
 
1256
@cindex IBM cp1047 output encoding
 
1257
For typewriter-like devices which use the @acronym{EBCDIC} encoding IBM
 
1258
cp1047.
 
1259
 
 
1260
@item lj4
 
1261
For HP LaserJet4-compatible (or other PCL5-compatible) printers.
 
1262
 
 
1263
@item lbp
 
1264
For Canon @acronym{CAPSL} printers (@w{LBP-4} and @w{LBP-8} series laser
 
1265
printers).
 
1266
 
 
1267
@pindex pre-grohtml
 
1268
@pindex post-grohtml
 
1269
@cindex @code{grohtml}, the program
 
1270
@item html
 
1271
@itemx xhtml
 
1272
To produce @acronym{HTML} and @acronym{XHTML} output, respectively.
 
1273
Note that this driver consists of two parts, a preprocessor
 
1274
(@code{pre-grohtml}) and a postprocessor (@code{post-grohtml}).
 
1275
@end table
 
1276
 
 
1277
@cindex output device name string register (@code{.T})
 
1278
@cindex output device usage number register (@code{.T})
 
1279
The predefined @code{gtroff} string register @code{.T} contains the
 
1280
current output device; the read-only number register @code{.T} is set
 
1281
to@tie{}1 if this option is used (which is always true if @code{groff}
 
1282
is used to call @code{gtroff}).  @xref{Built-in Registers}.
 
1283
 
 
1284
The postprocessor to be used for a device is specified by the
 
1285
@code{postpro} command in the device description file.  (@xref{Font
 
1286
Files}, for more info.)  This can be overridden with the @option{-X}
 
1287
option.
 
1288
 
 
1289
@item -U
 
1290
@cindex mode, unsafe
 
1291
@cindex unsafe mode
 
1292
Unsafe mode.  This enables the @code{open}, @code{opena}, @code{pso},
 
1293
@code{sy}, and @code{pi} requests.
 
1294
 
 
1295
@item -w@var{name}
 
1296
Enable warning @var{name}.  Available warnings are described in
 
1297
@ref{Debugging}.  Multiple @option{-w} options are allowed.
 
1298
 
 
1299
@item -W@var{name}
 
1300
Inhibit warning @var{name}.  Multiple @option{-W} options are allowed.
 
1301
 
 
1302
@item -v
 
1303
Make programs run by @code{groff} print out their version number.
 
1304
 
 
1305
@item -V
 
1306
Print the pipeline on @code{stdout} instead of executing it.  If
 
1307
specified more than once, print the pipeline on @code{stderr} and
 
1308
execute it.
 
1309
 
 
1310
@item -X
 
1311
Preview with @code{gxditview} instead of using the usual postprocessor.
 
1312
This is unlikely to produce good results except with @option{-Tps}.
 
1313
 
 
1314
Note that this is not the same as using @option{-TX75} or
 
1315
@option{-TX100} to view a document with @code{gxditview}: The former
 
1316
uses the metrics of the specified device, whereas the latter uses
 
1317
X-specific fonts and metrics.
 
1318
 
 
1319
@item -z
 
1320
Suppress output from @code{gtroff}.  Only error messages are printed.
 
1321
 
 
1322
@item -Z
 
1323
Do not postprocess the output of @code{gtroff}.  Normally @code{groff}
 
1324
automatically runs the appropriate postprocessor.
 
1325
@end table
 
1326
 
 
1327
 
 
1328
@c =====================================================================
 
1329
 
 
1330
@node Environment, Macro Directories, Groff Options, Invoking groff
 
1331
@section Environment
 
1332
@cindex environment variables
 
1333
@cindex variables in environment
 
1334
 
 
1335
There are also several environment variables (of the operating system,
 
1336
not within @code{gtroff}) which can modify the behavior of @code{groff}.
 
1337
 
 
1338
@table @code
 
1339
@item GROFF_BIN_PATH
 
1340
@tindex GROFF_BIN_PATH@r{, environment variable}
 
1341
This search path, followed by @code{PATH}, is used for commands executed
 
1342
by @code{groff}.
 
1343
 
 
1344
@item GROFF_COMMAND_PREFIX
 
1345
@tindex GROFF_COMMAND_PREFIX@r{, environment variable}
 
1346
@cindex command prefix
 
1347
@cindex prefix, for commands
 
1348
If this is set to@tie{}@var{X}, then @code{groff} runs
 
1349
@code{@var{X}troff} instead of @code{gtroff}.  This also applies to
 
1350
@code{tbl}, @code{pic}, @code{eqn}, @code{grn}, @code{chem},
 
1351
@code{refer}, and @code{soelim}.  It does not apply to @code{grops},
 
1352
@code{grodvi}, @code{grotty}, @code{pre-grohtml}, @code{post-grohtml},
 
1353
@code{preconv}, @code{grolj4}, @code{gropdf}, and @code{gxditview}.
 
1354
 
 
1355
The default command prefix is determined during the installation
 
1356
process.  If a non-GNU troff system is found, prefix @samp{g} is used,
 
1357
none otherwise.
 
1358
 
 
1359
@item GROFF_ENCODING
 
1360
@tindex GROFF_ENCODING@r{, environment variable}
 
1361
The value of this environment value is passed to the @code{preconv}
 
1362
preprocessor to select the encoding of input files.  Setting this option
 
1363
implies @code{groff}'s command line option @option{-k} (this is,
 
1364
@code{groff} actually always calls @code{preconv}).  If set without a
 
1365
value, @code{groff} calls @code{preconv} without arguments.  An explicit
 
1366
@option{-K} command line option overrides the value of
 
1367
@env{GROFF_ENCODING}.  See the manual page of @code{preconv} for details.
 
1368
 
 
1369
@item GROFF_FONT_PATH
 
1370
@tindex GROFF_FONT_PATH@r{, environment variable}
 
1371
A colon-separated list of directories in which to search for the
 
1372
@code{dev}@var{name} directory (before the default directories are
 
1373
tried).  @xref{Font Directories}.
 
1374
 
 
1375
@item GROFF_TMAC_PATH
 
1376
@tindex GROFF_TMAC_PATH@r{, environment variable}
 
1377
A colon-separated list of directories in which to search for macro files
 
1378
(before the default directories are tried).  @xref{Macro Directories}.
 
1379
 
 
1380
@item GROFF_TMPDIR
 
1381
@tindex GROFF_TMPDIR@r{, environment variable}
 
1382
@tindex TMPDIR@r{, environment variable}
 
1383
The directory in which @code{groff} creates temporary files.  If this is
 
1384
not set and @env{TMPDIR} is set, temporary files are created in that
 
1385
directory.  Otherwise temporary files are created in a system-dependent
 
1386
default directory (on Unix and GNU/Linux systems, this is usually
 
1387
@file{/tmp}).  @code{grops}, @code{grefer}, @code{pre-grohtml}, and
 
1388
@code{post-grohtml} can create temporary files in this directory.
 
1389
 
 
1390
@item GROFF_TYPESETTER
 
1391
@tindex GROFF_TYPESETTER@r{, environment variable}
 
1392
The default output device.
 
1393
@end table
 
1394
 
 
1395
Note that MS-DOS and MS-Windows ports of @code{groff} use semi-colons,
 
1396
rather than colons, to separate the directories in the lists described
 
1397
above.
 
1398
 
 
1399
 
 
1400
@c =====================================================================
 
1401
 
 
1402
@node Macro Directories, Font Directories, Environment, Invoking groff
 
1403
@section Macro Directories
 
1404
@cindex macro directories
 
1405
@cindex directories for macros
 
1406
@cindex searching macros
 
1407
@cindex macros, searching
 
1408
 
 
1409
All macro file names must be named @code{@var{name}.tmac} or
 
1410
@code{tmac.@var{name}} to make the @option{-m@var{name}} command line
 
1411
option work.  The @code{mso} request doesn't have this restriction; any
 
1412
file name can be used, and @code{gtroff} won't try to append or prepend
 
1413
the @samp{tmac} string.
 
1414
 
 
1415
@cindex tmac, directory
 
1416
@cindex directory, for tmac files
 
1417
@cindex tmac, path
 
1418
@cindex path, for tmac files
 
1419
@cindex searching macro files
 
1420
@cindex macro files, searching
 
1421
@cindex files, macro, searching
 
1422
Macro files are kept in the @dfn{tmac directories}, all of which
 
1423
constitute the @dfn{tmac path}.  The elements of the search path for
 
1424
macro files are (in that order):
 
1425
 
 
1426
@itemize @bullet
 
1427
@item
 
1428
The directories specified with @code{gtroff}'s or @code{groff}'s
 
1429
@option{-M} command line option.
 
1430
 
 
1431
@item
 
1432
@tindex GROFF_TMAC_PATH@r{, environment variable}
 
1433
The directories given in the @env{GROFF_TMAC_PATH} environment variable.
 
1434
 
 
1435
@item
 
1436
@cindex safer mode
 
1437
@cindex mode, safer
 
1438
@cindex unsafe mode
 
1439
@cindex mode, unsafe
 
1440
@cindex current directory
 
1441
@cindex directory, current
 
1442
The current directory (only if in unsafe mode using the @option{-U}
 
1443
command line switch).
 
1444
 
 
1445
@item
 
1446
@cindex home directory
 
1447
@cindex directory, home
 
1448
The home directory.
 
1449
 
 
1450
@item
 
1451
@cindex site-specific directory
 
1452
@cindex directory, site-specific
 
1453
@cindex platform-specific directory
 
1454
@cindex directory, platform-specific
 
1455
A platform-dependent directory, a site-specific (platform-independent)
 
1456
directory, and the main tmac directory; the default locations are
 
1457
 
 
1458
@Example
 
1459
/usr/local/lib/groff/site-tmac
 
1460
/usr/local/share/groff/site-tmac
 
1461
/usr/local/share/groff/1.22.2/tmac
 
1462
@endExample
 
1463
 
 
1464
@noindent
 
1465
assuming that the version of @code{groff} is 1.22.2, and the
 
1466
installation prefix was @file{/usr/local}.  It is possible to fine-tune
 
1467
those directories during the installation process.
 
1468
@end itemize
 
1469
 
 
1470
 
 
1471
@c =====================================================================
 
1472
 
 
1473
@node Font Directories, Paper Size, Macro Directories, Invoking groff
 
1474
@section Font Directories
 
1475
@cindex font directories
 
1476
@cindex directories for fonts
 
1477
@cindex searching fonts
 
1478
@cindex fonts, searching
 
1479
 
 
1480
Basically, there is no restriction how font files for @code{groff} are
 
1481
named and how long font names are; however, to make the font family
 
1482
mechanism work (@pxref{Font Families}), fonts within a family should
 
1483
start with the family name, followed by the shape.  For example, the
 
1484
Times family uses @samp{T} for the family name and @samp{R}, @samp{B},
 
1485
@samp{I}, and @samp{BI} to indicate the shapes `roman', `bold',
 
1486
`italic', and `bold italic', respectively.  Thus the final font names
 
1487
are @samp{TR}, @samp{TB}, @samp{TI}, and @samp{TBI}.
 
1488
 
 
1489
@cindex font path
 
1490
@cindex path, for font files
 
1491
All font files are kept in the @dfn{font directories} which constitute
 
1492
the @dfn{font path}.  The file search functions always append the
 
1493
directory @code{dev}@var{name}, where @var{name} is the name of the
 
1494
output device.  Assuming, say, DVI output, and @file{/foo/bar} as a font
 
1495
directory, the font files for @code{grodvi} must be in
 
1496
@file{/foo/bar/devdvi}.
 
1497
 
 
1498
The elements of the search path for font files are (in that order):
 
1499
 
 
1500
@itemize @bullet
 
1501
@item
 
1502
The directories specified with @code{gtroff}'s or @code{groff}'s
 
1503
@option{-F} command line option.  All device drivers and some
 
1504
preprocessors also have this option.
 
1505
 
 
1506
@item
 
1507
@tindex GROFF_FONT_PATH@r{, environment variable}
 
1508
The directories given in the @env{GROFF_FONT_PATH} environment variable.
 
1509
 
 
1510
@item
 
1511
@cindex site-specific directory
 
1512
@cindex directory, site-specific
 
1513
A site-specific directory and the main font directory; the default
 
1514
locations are
 
1515
 
 
1516
@Example
 
1517
/usr/local/share/groff/site-font
 
1518
/usr/local/share/groff/1.22.2/font
 
1519
@endExample
 
1520
 
 
1521
@noindent
 
1522
assuming that the version of @code{groff} is 1.22.2, and the
 
1523
installation prefix was @file{/usr/local}.  It is possible to fine-tune
 
1524
those directories during the installation process.
 
1525
@end itemize
 
1526
 
 
1527
 
 
1528
@c =====================================================================
 
1529
 
 
1530
@node Paper Size, Invocation Examples, Font Directories, Invoking groff
 
1531
@section Paper Size
 
1532
@cindex paper size
 
1533
@cindex size, paper
 
1534
@cindex landscape page orientation
 
1535
@cindex orientation, landscape
 
1536
@cindex page orientation, landscape
 
1537
 
 
1538
In groff, the page size for @code{gtroff} and for output devices are
 
1539
handled separately.  @xref{Page Layout}, for vertical manipulation of
 
1540
the page size.  @xref{Line Layout}, for horizontal changes.
 
1541
 
 
1542
A default paper size can be set in the device's @file{DESC} file.  Most
 
1543
output devices also have a command line option @option{-p} to override
 
1544
the default paper size and option @option{-l} to use landscape
 
1545
orientation.  @xref{DESC File Format}, for a description of the
 
1546
@code{papersize} keyword which takes the same argument as @option{-p}.
 
1547
 
 
1548
@pindex papersize.tmac
 
1549
@pindex troffrc
 
1550
A convenient shorthand to set a particular paper size for @code{gtroff}
 
1551
is command line option @option{-dpaper=@var{size}}.  This defines string
 
1552
@code{paper} which is processed in file @file{papersize.tmac} (loaded in
 
1553
the start-up file @file{troffrc} by default).  Possible values for
 
1554
@var{size} are the same as the predefined values for the
 
1555
@code{papersize} keyword (but only in lowercase) except
 
1556
@code{a7}-@code{d7}.  An appended @samp{l} (ell) character denotes
 
1557
landscape orientation.
 
1558
 
 
1559
For example, use the following for PS output on A4 paper in landscape
 
1560
orientation:
 
1561
 
 
1562
@Example
 
1563
groff -Tps -dpaper=a4l -P-pa4 -P-l -ms foo.ms > foo.ps
 
1564
@endExample
 
1565
 
 
1566
Note that it is up to the particular macro package to respect default
 
1567
page dimensions set in this way (most do).
 
1568
 
 
1569
 
 
1570
@c =====================================================================
 
1571
 
 
1572
@node Invocation Examples,  , Paper Size, Invoking groff
 
1573
@section Invocation Examples
 
1574
@cindex invocation examples
 
1575
@cindex examples of invocation
 
1576
 
 
1577
This section lists several common uses of @code{groff} and the
 
1578
corresponding command lines.
 
1579
 
 
1580
@Example
 
1581
groff file
 
1582
@endExample
 
1583
 
 
1584
@noindent
 
1585
This command processes @file{file} without a macro package or a
 
1586
preprocessor.  The output device is the default, @samp{ps}, and the
 
1587
output is sent to @code{stdout}.
 
1588
 
 
1589
@Example
 
1590
groff -t -mandoc -Tascii file | less
 
1591
@endExample
 
1592
 
 
1593
@noindent
 
1594
This is basically what a call to the @code{man} program does.
 
1595
@code{gtroff} processes the manual page @file{file} with the
 
1596
@file{mandoc} macro file (which in turn either calls the @file{man} or
 
1597
the @file{mdoc} macro package), using the @code{tbl} preprocessor and
 
1598
the @acronym{ASCII} output device.  Finally, the @code{less} pager
 
1599
displays the result.
 
1600
 
 
1601
@Example
 
1602
groff -X -m me file
 
1603
@endExample
 
1604
 
 
1605
@noindent
 
1606
Preview @file{file} with @code{gxditview}, using the @file{me} macro
 
1607
package.  Since no @option{-T} option is specified, use the default
 
1608
device (@samp{ps}).  Note that you can either say @w{@samp{-m me}} or
 
1609
@w{@samp{-me}}; the latter is an anachronism from the early days of
 
1610
@acronym{UNIX}.@footnote{The same is true for the other main macro
 
1611
packages that come with @code{groff}: @file{man}, @file{mdoc},
 
1612
@file{ms}, @file{mm}, and @file{mandoc}.  This won't work in general;
 
1613
for example, to load @file{trace.tmac}, either @samp{-mtrace} or
 
1614
@w{@samp{-m trace}} must be used.}
 
1615
 
 
1616
@Example
 
1617
groff -man -rD1 -z file
 
1618
@endExample
 
1619
 
 
1620
@noindent
 
1621
Check @file{file} with the @file{man} macro package, forcing
 
1622
double-sided printing -- don't produce any output.
 
1623
 
 
1624
@menu
 
1625
* grog::
 
1626
@end menu
 
1627
 
 
1628
@c ---------------------------------------------------------------------
 
1629
 
 
1630
@node grog,  , Invocation Examples, Invocation Examples
 
1631
@subsection @code{grog}
 
1632
 
 
1633
@pindex grog
 
1634
@code{grog} reads files, guesses which of the @code{groff} preprocessors
 
1635
and/or macro packages are required for formatting them, and prints the
 
1636
@code{groff} command including those options on the standard output.  It
 
1637
generates one or more of the options @option{-e}, @option{-man},
 
1638
@option{-me}, @option{-mm}, @option{-mom}, @option{-ms}, @option{-mdoc},
 
1639
@option{-mdoc-old}, @option{-p}, @option{-R}, @option{-g}, @option{-G},
 
1640
@option{-s}, and @option{-t}.
 
1641
 
 
1642
A special file name@tie{}@file{-} refers to the standard input.
 
1643
Specifying no files also means to read the standard input.  Any
 
1644
specified options are included in the printed command.  No space is
 
1645
allowed between options and their arguments.  The only options
 
1646
recognized are @option{-C} (which is also passed on) to enable
 
1647
compatibility mode, and @option{-v} to print the version number and
 
1648
exit.
 
1649
 
 
1650
For example,
 
1651
 
 
1652
@Example
 
1653
grog -Tdvi paper.ms
 
1654
@endExample
 
1655
 
 
1656
@noindent
 
1657
guesses the appropriate command to print @file{paper.ms} and then prints
 
1658
it to the command line after adding the @option{-Tdvi} option.  For
 
1659
direct execution, enclose the call to @code{grog} in backquotes at the
 
1660
@acronym{UNIX} shell prompt:
 
1661
 
 
1662
@Example
 
1663
`grog -Tdvi paper.ms` > paper.dvi
 
1664
@endExample
 
1665
 
 
1666
@noindent
 
1667
As seen in the example, it is still necessary to redirect the output to
 
1668
something meaningful (i.e.@: either a file or a pager program like
 
1669
@code{less}).
 
1670
 
 
1671
 
 
1672
 
 
1673
@c =====================================================================
 
1674
@c =====================================================================
 
1675
 
 
1676
@node Tutorial for Macro Users, Macro Packages, Invoking groff, Top
 
1677
@chapter Tutorial for Macro Users
 
1678
@cindex tutorial for macro users
 
1679
@cindex macros, tutorial for users
 
1680
@cindex user's tutorial for macros
 
1681
@cindex user's macro tutorial
 
1682
 
 
1683
Most users tend to use a macro package to format their papers.  This
 
1684
means that the whole breadth of @code{groff} is not necessary for most
 
1685
people.  This chapter covers the material needed to efficiently use a
 
1686
macro package.
 
1687
 
 
1688
@menu
 
1689
* Basics::
 
1690
* Common Features::
 
1691
@end menu
 
1692
 
 
1693
 
 
1694
@c =====================================================================
 
1695
 
 
1696
@node Basics, Common Features, Tutorial for Macro Users, Tutorial for Macro Users
 
1697
@section Basics
 
1698
@cindex basics of macros
 
1699
@cindex macro basics
 
1700
 
 
1701
This section covers some of the basic concepts necessary to understand
 
1702
how to use a macro package.@footnote{This section is derived from
 
1703
@cite{Writing Papers with nroff using -me} by Eric P.@tie{}Allman.}
 
1704
References are made throughout to more detailed information, if desired.
 
1705
 
 
1706
@code{gtroff} reads an input file prepared by the user and outputs a
 
1707
formatted document suitable for publication or framing.  The input
 
1708
consists of text, or words to be printed, and embedded commands
 
1709
(@dfn{requests} and @dfn{escapes}), which tell @code{gtroff} how to
 
1710
format the output.  For more detail on this, see @ref{Embedded
 
1711
Commands}.
 
1712
 
 
1713
The word @dfn{argument} is used in this chapter to mean a word or number
 
1714
which appears on the same line as a request, and which modifies the
 
1715
meaning of that request.  For example, the request
 
1716
 
 
1717
@Example
 
1718
.sp
 
1719
@endExample
 
1720
 
 
1721
@noindent
 
1722
spaces one line, but
 
1723
 
 
1724
@Example
 
1725
.sp 4
 
1726
@endExample
 
1727
 
 
1728
@noindent
 
1729
spaces four lines.  The number@tie{}4 is an argument to the @code{sp}
 
1730
request which says to space four lines instead of one.  Arguments are
 
1731
separated from the request and from each other by spaces (@emph{no}
 
1732
tabs).  More details on this can be found in @ref{Request and Macro
 
1733
Arguments}.
 
1734
 
 
1735
The primary function of @code{gtroff} is to collect words from input
 
1736
lines, fill output lines with those words, justify the right-hand margin
 
1737
by inserting extra spaces in the line, and output the result.  For
 
1738
example, the input:
 
1739
 
 
1740
@Example
 
1741
Now is the time
 
1742
for all good men
 
1743
to come to the aid
 
1744
of their party.
 
1745
Four score and seven
 
1746
years ago, etc.
 
1747
@endExample
 
1748
 
 
1749
@noindent
 
1750
is read, packed onto output lines, and justified to produce:
 
1751
 
 
1752
@quotation
 
1753
Now is the time for all good men to come to the aid of their party.
 
1754
Four score and seven years ago, etc.
 
1755
@end quotation
 
1756
 
 
1757
@cindex break
 
1758
@cindex line break
 
1759
Sometimes a new output line should be started even though the current
 
1760
line is not yet full; for example, at the end of a paragraph.  To do
 
1761
this it is possible to cause a @dfn{break}, which starts a new output
 
1762
line.  Some requests cause a break automatically, as normally do blank
 
1763
input lines and input lines beginning with a space.
 
1764
 
 
1765
Not all input lines are text to be formatted.  Some input lines are
 
1766
requests which describe how to format the text.  Requests always have a
 
1767
period (@samp{.}) or an apostrophe (@samp{'}) as the first character of
 
1768
the input line.
 
1769
 
 
1770
The text formatter also does more complex things, such as automatically
 
1771
numbering pages, skipping over page boundaries, putting footnotes in the
 
1772
correct place, and so forth.
 
1773
 
 
1774
Here are a few hints for preparing text for input to @code{gtroff}.
 
1775
 
 
1776
@itemize @bullet
 
1777
@item
 
1778
First, keep the input lines short.  Short input lines are easier to
 
1779
edit, and @code{gtroff} packs words onto longer lines anyhow.
 
1780
 
 
1781
@item
 
1782
In keeping with this, it is helpful to begin a new line after every
 
1783
comma or phrase, since common corrections are to add or delete sentences
 
1784
or phrases.
 
1785
 
 
1786
@item
 
1787
End each sentence with two spaces -- or better, start each sentence on a
 
1788
new line.  @code{gtroff} recognizes characters that usually end a
 
1789
sentence, and inserts sentence space accordingly.
 
1790
 
 
1791
@item
 
1792
Do not hyphenate words at the end of lines -- @code{gtroff} is smart
 
1793
enough to hyphenate words as needed, but is not smart enough to take
 
1794
hyphens out and join a word back together.  Also, words such as
 
1795
``mother-in-law'' should not be broken over a line, since then a space
 
1796
can occur where not wanted, such as ``@w{mother- in}-law''.
 
1797
@end itemize
 
1798
 
 
1799
@cindex double-spacing (@code{ls})
 
1800
@cindex spacing
 
1801
@code{gtroff} double-spaces output text automatically if you use the
 
1802
request @w{@samp{.ls 2}}.  Reactivate single-spaced mode by typing
 
1803
@w{@samp{.ls 1}}.@footnote{If you need finer granularity of the vertical
 
1804
space, use the @code{pvs} request (@pxref{Changing Type Sizes}).}
 
1805
 
 
1806
A number of requests allow to change the way the output looks, sometimes
 
1807
called the @dfn{layout} of the output page.  Most of these requests
 
1808
adjust the placing of @dfn{whitespace} (blank lines or spaces).
 
1809
 
 
1810
@cindex new page (@code{bp})
 
1811
The @code{bp} request starts a new page, causing a line break.
 
1812
 
 
1813
@cindex blank line (@code{sp})
 
1814
@cindex empty line (@code{sp})
 
1815
@cindex line, empty (@code{sp})
 
1816
The request @w{@samp{.sp @var{N}}} leaves @var{N}@tie{}lines of blank
 
1817
space.  @var{N}@tie{}can be omitted (meaning skip a single line) or can
 
1818
be of the form @var{N}i (for @var{N}@tie{}inches) or @var{N}c (for
 
1819
@var{N}@tie{}centimeters).  For example, the input:
 
1820
 
 
1821
@Example
 
1822
.sp 1.5i
 
1823
My thoughts on the subject
 
1824
.sp
 
1825
@endExample
 
1826
 
 
1827
@noindent
 
1828
leaves one and a half inches of space, followed by the line ``My
 
1829
thoughts on the subject'', followed by a single blank line (more
 
1830
measurement units are available, see @ref{Measurements}).
 
1831
 
 
1832
@cindex centering lines (@code{ce})
 
1833
@cindex lines, centering (@code{ce})
 
1834
Text lines can be centered by using the @code{ce} request.  The line
 
1835
after @code{ce} is centered (horizontally) on the page.  To center more
 
1836
than one line, use @w{@samp{.ce @var{N}}} (where @var{N} is the number
 
1837
of lines to center), followed by the @var{N}@tie{}lines.  To center many
 
1838
lines without counting them, type:
 
1839
 
 
1840
@Example
 
1841
.ce 1000
 
1842
lines to center
 
1843
.ce 0
 
1844
@endExample
 
1845
 
 
1846
@noindent
 
1847
The @w{@samp{.ce 0}} request tells @code{groff} to center zero more
 
1848
lines, in other words, stop centering.
 
1849
 
 
1850
@cindex line break (@code{br})
 
1851
@cindex break (@code{br})
 
1852
All of these requests cause a break; that is, they always start a new
 
1853
line.  To start a new line without performing any other action, use
 
1854
@code{br}.
 
1855
 
 
1856
 
 
1857
@c =====================================================================
 
1858
 
 
1859
@node Common Features,  , Basics, Tutorial for Macro Users
 
1860
@section Common Features
 
1861
@cindex common features
 
1862
@cindex features, common
 
1863
 
 
1864
@code{gtroff} provides very low-level operations for formatting a
 
1865
document.  There are many common routine operations which are done in
 
1866
all documents.  These common operations are written into @dfn{macros}
 
1867
and collected into a @dfn{macro package}.
 
1868
 
 
1869
All macro packages provide certain common capabilities which fall into
 
1870
the following categories.
 
1871
 
 
1872
@menu
 
1873
* Paragraphs::
 
1874
* Sections and Chapters::
 
1875
* Headers and Footers::
 
1876
* Page Layout Adjustment::
 
1877
* Displays::
 
1878
* Footnotes and Annotations::
 
1879
* Table of Contents::
 
1880
* Indices::
 
1881
* Paper Formats::
 
1882
* Multiple Columns::
 
1883
* Font and Size Changes::
 
1884
* Predefined Strings::
 
1885
* Preprocessor Support::
 
1886
* Configuration and Customization::
 
1887
@end menu
 
1888
 
 
1889
@c ---------------------------------------------------------------------
 
1890
 
 
1891
@node Paragraphs, Sections and Chapters, Common Features, Common Features
 
1892
@subsection Paragraphs
 
1893
@cindex paragraphs
 
1894
 
 
1895
One of the most common and most used capability is starting a paragraph.
 
1896
There are a number of different types of paragraphs, any of which can be
 
1897
initiated with macros supplied by the macro package.  Normally,
 
1898
paragraphs start with a blank line and the first line indented, like the
 
1899
text in this manual.  There are also block style paragraphs, which omit
 
1900
the indentation:
 
1901
 
 
1902
@Example
 
1903
Some   men  look   at  constitutions   with  sanctimonious
 
1904
reverence, and deem them like the ark of the covenant, too
 
1905
sacred to be touched.
 
1906
@endExample
 
1907
 
 
1908
@noindent
 
1909
And there are also indented paragraphs which begin with a tag or label
 
1910
at the margin and the remaining text indented.
 
1911
 
 
1912
@Example
 
1913
one   This is  the first paragraph.  Notice  how the first
 
1914
      line of  the resulting  paragraph lines up  with the
 
1915
      other lines in the paragraph.
 
1916
@endExample
 
1917
@Example
 
1918
longlabel
 
1919
      This  paragraph   had  a  long   label.   The  first
 
1920
      character of text on the first line does not line up
 
1921
      with  the  text  on  second  and  subsequent  lines,
 
1922
      although they line up with each other.
 
1923
@endExample
 
1924
 
 
1925
A variation of this is a bulleted list.
 
1926
 
 
1927
@Example
 
1928
.     Bulleted lists start with a bullet.   It is possible
 
1929
      to use other glyphs instead of the bullet.  In nroff
 
1930
      mode using the ASCII character set for output, a dot
 
1931
      is used instead of a real bullet.
 
1932
@endExample
 
1933
 
 
1934
@c ---------------------------------------------------------------------
 
1935
 
 
1936
@node Sections and Chapters, Headers and Footers, Paragraphs, Common Features
 
1937
@subsection Sections and Chapters
 
1938
 
 
1939
Most macro packages supply some form of section headers.  The simplest
 
1940
kind is simply the heading on a line by itself in bold type.  Others
 
1941
supply automatically numbered section heading or different heading
 
1942
styles at different levels.  Some, more sophisticated, macro packages
 
1943
supply macros for starting chapters and appendices.
 
1944
 
 
1945
@c ---------------------------------------------------------------------
 
1946
 
 
1947
@node Headers and Footers, Page Layout Adjustment, Sections and Chapters, Common Features
 
1948
@subsection Headers and Footers
 
1949
 
 
1950
Every macro package gives some way to manipulate the @dfn{headers} and
 
1951
@dfn{footers} (also called @dfn{titles}) on each page.  This is text put
 
1952
at the top and bottom of each page, respectively, which contain data
 
1953
like the current page number, the current chapter title, and so on.  Its
 
1954
appearance is not affected by the running text.  Some packages allow for
 
1955
different ones on the even and odd pages (for material printed in a book
 
1956
form).
 
1957
 
 
1958
The titles are called @dfn{three-part titles}, that is, there is a
 
1959
left-justified part, a centered part, and a right-justified part.  An
 
1960
automatically generated page number may be put in any of these fields
 
1961
with the @samp{%} character (see @ref{Page Layout}, for more details).
 
1962
 
 
1963
@c ---------------------------------------------------------------------
 
1964
 
 
1965
@node Page Layout Adjustment, Displays, Headers and Footers, Common Features
 
1966
@subsection Page Layout
 
1967
 
 
1968
Most macro packages let the user specify top and bottom margins and
 
1969
other details about the appearance of the printed pages.
 
1970
 
 
1971
@c ---------------------------------------------------------------------
 
1972
 
 
1973
@node Displays, Footnotes and Annotations, Page Layout Adjustment, Common Features
 
1974
@subsection Displays
 
1975
@cindex displays
 
1976
 
 
1977
@dfn{Displays} are sections of text to be set off from the body of the
 
1978
paper.  Major quotes, tables, and figures are types of displays, as are
 
1979
all the examples used in this document.
 
1980
 
 
1981
@cindex quotes, major
 
1982
@cindex major quotes
 
1983
@dfn{Major quotes} are quotes which are several lines long, and hence
 
1984
are set in from the rest of the text without quote marks around them.
 
1985
 
 
1986
@cindex list
 
1987
A @dfn{list} is an indented, single-spaced, unfilled display.  Lists
 
1988
should be used when the material to be printed should not be filled and
 
1989
justified like normal text, such as columns of figures or the examples
 
1990
used in this paper.
 
1991
 
 
1992
@cindex keep
 
1993
A @dfn{keep} is a display of lines which are kept on a single page if
 
1994
possible.  An example for a keep might be a diagram.  Keeps differ from
 
1995
lists in that lists may be broken over a page boundary whereas keeps are
 
1996
not.
 
1997
 
 
1998
@cindex keep, floating
 
1999
@cindex floating keep
 
2000
@dfn{Floating keeps} move relative to the text.  Hence, they are good
 
2001
for things which are referred to by name, such as ``See figure@tie{}3''.
 
2002
A floating keep appears at the bottom of the current page if it fits;
 
2003
otherwise, it appears at the top of the next page.  Meanwhile, the
 
2004
surrounding text `flows' around the keep, thus leaving no blank areas.
 
2005
 
 
2006
@c ---------------------------------------------------------------------
 
2007
 
 
2008
@node Footnotes and Annotations, Table of Contents, Displays, Common Features
 
2009
@subsection Footnotes and Annotations
 
2010
@cindex footnotes
 
2011
@cindex annotations
 
2012
 
 
2013
There are a number of requests to save text for later printing.
 
2014
 
 
2015
@dfn{Footnotes} are printed at the bottom of the current page.
 
2016
 
 
2017
@cindex delayed text
 
2018
@dfn{Delayed text} is very similar to a footnote except that it is
 
2019
printed when called for explicitly.  This allows a list of references to
 
2020
appear (for example) at the end of each chapter, as is the convention in
 
2021
some disciplines.
 
2022
 
 
2023
Most macro packages which supply this functionality also supply a means
 
2024
of automatically numbering either type of annotation.
 
2025
 
 
2026
@c ---------------------------------------------------------------------
 
2027
 
 
2028
@node Table of Contents, Indices, Footnotes and Annotations, Common Features
 
2029
@subsection Table of Contents
 
2030
@cindex table of contents
 
2031
@cindex contents, table of
 
2032
 
 
2033
@dfn{Tables of contents} are a type of delayed text having a tag
 
2034
(usually the page number) attached to each entry after a row of dots.
 
2035
The table accumulates throughout the paper until printed, usually after
 
2036
the paper has ended.  Many macro packages provide the ability to have
 
2037
several tables of contents (e.g.@: a standard table of contents, a list
 
2038
of tables, etc).
 
2039
 
 
2040
@c ---------------------------------------------------------------------
 
2041
 
 
2042
@node Indices, Paper Formats, Table of Contents, Common Features
 
2043
@subsection Indices
 
2044
@cindex index, in macro package
 
2045
 
 
2046
While some macro packages use the term @dfn{index}, none actually
 
2047
provide that functionality.  The facilities they call indices are
 
2048
actually more appropriate for tables of contents.
 
2049
 
 
2050
@pindex makeindex
 
2051
To produce a real index in a document, external tools like the
 
2052
@code{makeindex} program are necessary.
 
2053
 
 
2054
@c ---------------------------------------------------------------------
 
2055
 
 
2056
@node Paper Formats, Multiple Columns, Indices, Common Features
 
2057
@subsection Paper Formats
 
2058
@cindex paper formats
 
2059
 
 
2060
Some macro packages provide stock formats for various kinds of
 
2061
documents.  Many of them provide a common format for the title and
 
2062
opening pages of a technical paper.  The @file{mm} macros in particular
 
2063
provide formats for letters and memoranda.
 
2064
 
 
2065
@c ---------------------------------------------------------------------
 
2066
 
 
2067
@node Multiple Columns, Font and Size Changes, Paper Formats, Common Features
 
2068
@subsection Multiple Columns
 
2069
 
 
2070
Some macro packages (but not @file{man}) provide the ability to have two
 
2071
or more columns on a page.
 
2072
 
 
2073
@c ---------------------------------------------------------------------
 
2074
 
 
2075
@node Font and Size Changes, Predefined Strings, Multiple Columns, Common Features
 
2076
@subsection Font and Size Changes
 
2077
 
 
2078
The built-in font and size functions are not always intuitive, so all
 
2079
macro packages provide macros to make these operations simpler.
 
2080
 
 
2081
@c ---------------------------------------------------------------------
 
2082
 
 
2083
@node Predefined Strings, Preprocessor Support, Font and Size Changes, Common Features
 
2084
@subsection Predefined Strings
 
2085
 
 
2086
Most macro packages provide various predefined strings for a variety of
 
2087
uses; examples are sub- and superscripts, printable dates, quotes and
 
2088
various special characters.
 
2089
 
 
2090
@c ---------------------------------------------------------------------
 
2091
 
 
2092
@node Preprocessor Support, Configuration and Customization, Predefined Strings, Common Features
 
2093
@subsection Preprocessor Support
 
2094
 
 
2095
All macro packages provide support for various preprocessors and may
 
2096
extend their functionality.
 
2097
 
 
2098
For example, all macro packages mark tables (which are processed with
 
2099
@code{gtbl}) by placing them between @code{TS} and @code{TE} macros.
 
2100
The @file{ms} macro package has an option, @samp{.TS@tie{}H}, that
 
2101
prints a caption at the top of a new page (when the table is too long to
 
2102
fit on a single page).
 
2103
 
 
2104
@c ---------------------------------------------------------------------
 
2105
 
 
2106
@node Configuration and Customization,  , Preprocessor Support, Common Features
 
2107
@subsection Configuration and Customization
 
2108
 
 
2109
Some macro packages provide means of customizing many of the details of
 
2110
how the package behaves.  This ranges from setting the default type size
 
2111
to changing the appearance of section headers.
 
2112
 
 
2113
 
 
2114
 
 
2115
@c =====================================================================
 
2116
@c =====================================================================
 
2117
 
 
2118
@node Macro Packages, gtroff Reference, Tutorial for Macro Users, Top
 
2119
@chapter Macro Packages
 
2120
@cindex macro packages
 
2121
@cindex packages, macros
 
2122
 
 
2123
This chapter documents the main macro packages that come with
 
2124
@code{groff}.
 
2125
 
 
2126
Different main macro packages can't be used at the same time; for
 
2127
example
 
2128
 
 
2129
@Example
 
2130
groff -m man foo.man -m ms bar.doc
 
2131
@endExample
 
2132
 
 
2133
@noindent
 
2134
doesn't work.  Note that option arguments are processed before
 
2135
non-option arguments; the above (failing) sample is thus reordered to
 
2136
 
 
2137
@Example
 
2138
groff -m man -m ms foo.man bar.doc
 
2139
@endExample
 
2140
 
 
2141
@menu
 
2142
* man::
 
2143
* mdoc::
 
2144
* ms::
 
2145
* me::
 
2146
* mm::
 
2147
* mom::
 
2148
@end menu
 
2149
 
 
2150
 
 
2151
@c =====================================================================
 
2152
 
 
2153
@node man, mdoc, Macro Packages, Macro Packages
 
2154
@section @file{man}
 
2155
@cindex manual pages
 
2156
@cindex man pages
 
2157
@pindex an.tmac
 
2158
@pindex man.tmac
 
2159
@pindex man-old.tmac
 
2160
 
 
2161
This is the most popular and probably the most important macro package
 
2162
of @code{groff}.  It is easy to use, and a vast majority of manual pages
 
2163
are based on it.
 
2164
 
 
2165
@menu
 
2166
* Man options::
 
2167
* Man usage::
 
2168
* Man font macros::
 
2169
* Miscellaneous man macros::
 
2170
* Predefined man strings::
 
2171
* Preprocessors in man pages::
 
2172
* Optional man extensions::
 
2173
@end menu
 
2174
 
 
2175
@c ---------------------------------------------------------------------
 
2176
 
 
2177
@node Man options, Man usage, man, man
 
2178
@subsection Options
 
2179
 
 
2180
The command line format for using the @file{man} macros with
 
2181
@code{groff} is:
 
2182
 
 
2183
@Example
 
2184
groff -m man [ -rLL=@var{length} ] [ -rLT=@var{length} ] [ -rFT=@var{dist} ]
 
2185
      [ -rcR=1 ] [ -rC1 ] [ -rD1 ] [-rHY=@var{flags} ]
 
2186
      [ -rP@var{nnn} ] [ -rS@var{xx} ] [ -rX@var{nnn} ]
 
2187
      [ -rIN=@var{length} ] [ -rSN=@var{length} ] [ @var{files}@dots{} ]
 
2188
@endExample
 
2189
 
 
2190
@noindent
 
2191
It is possible to use @samp{-man} instead of @w{@samp{-m man}}.
 
2192
 
 
2193
@table @code
 
2194
@item -rcR=1
 
2195
This option (the default if a TTY output device is used) creates a
 
2196
single, very long page instead of multiple pages.  Use @code{-rcR=0} to
 
2197
disable it.
 
2198
 
 
2199
@item -rC1
 
2200
If more than one manual page is given on the command line, number the
 
2201
pages continuously, rather than starting each at@tie{}1.
 
2202
 
 
2203
@item -rD1
 
2204
Double-sided printing.  Footers for even and odd pages are formatted
 
2205
differently.
 
2206
 
 
2207
@item -rFT=@var{dist}
 
2208
Set the position of the footer text to @var{dist}.  If positive, the
 
2209
distance is measured relative to the top of the page, otherwise it is
 
2210
relative to the bottom.  The default is @minus{}0.5@dmn{i}.
 
2211
 
 
2212
@item -rHY=@var{flags}
 
2213
Set hyphenation flags.  Possible values are 1@tie{}to hyphenate without
 
2214
restrictions, 2@tie{}to not hyphenate the last word on a page, 4@tie{}to
 
2215
not hyphenate the last two characters of a word, and 8@tie{}to not
 
2216
hyphenate the first two characters of a word.  These values are
 
2217
additive; the default is@tie{}14.
 
2218
 
 
2219
@item -rIN=@var{length}
 
2220
Set the body text indentation to @var{length}.  If not specified, the
 
2221
indentation defaults to 7@dmn{n} (7@tie{}characters) in nroff mode and
 
2222
7.2@dmn{n} otherwise.  For nroff, this value should always be an integer
 
2223
multiple of unit @samp{n} to get consistent indentation.
 
2224
 
 
2225
@item -rLL=@var{length}
 
2226
Set line length to @var{length}.  If not specified, the line length is
 
2227
set to respect any value set by a prior @samp{ll} request (which
 
2228
@emph{must} be in effect when the @samp{TH} macro is invoked), if this
 
2229
differs from the built-in default for the formatter; otherwise it
 
2230
defaults to 78@dmn{n} in nroff mode (this is 78 characters per line) and
 
2231
6.5@dmn{i} in troff mode.@footnote{Note that the use of a @samp{.ll
 
2232
@var{length}} request to initialize the line length, prior to use of the
 
2233
@samp{TH} macro, is supported for backward compatibility with some
 
2234
versions of the @code{man} program.  @emph{Always} use the
 
2235
@option{-rLL=@var{length}} option, or an equivalent @samp{.nr LL
 
2236
@var{length}} request, in preference to such a @samp{.ll @var{length}}
 
2237
request.  In particular, note that in nroff mode, the request @samp{.ll
 
2238
65n}, (with any @var{length} expression which evaluates equal to
 
2239
65@dmn{n}, i.e., the formatter's default line length in nroff mode),
 
2240
does @emph{not} set the line length to 65@dmn{n} (it is adjusted to the
 
2241
@code{man} macro package's default setting of 78@dmn{n}), whereas the
 
2242
use of the @option{-rLL=65n} option, or the @samp{.nr LL 65n} request
 
2243
@emph{does} establish a line length of 65@dmn{n}.}
 
2244
 
 
2245
@item -rLT=@var{length}
 
2246
Set title length to @var{length}.  If not specified, the title length
 
2247
defaults to the line length.
 
2248
 
 
2249
@item -rP@var{nnn}
 
2250
Page numbering starts with @var{nnn} rather than with@tie{}1.
 
2251
 
 
2252
@item -rS@var{xx}
 
2253
Use @var{xx} (which can be 10, 11, or@tie{}12@dmn{pt}) as the base
 
2254
document font size instead of the default value of@tie{}10@dmn{pt}.
 
2255
 
 
2256
@item -rSN=@var{length}
 
2257
Set the indentation for sub-subheadings to @var{length}.  If not
 
2258
specified, the indentation defaults to 3@dmn{n}.
 
2259
 
 
2260
@item -rX@var{nnn}
 
2261
After page @var{nnn}, number pages as @var{nnn}a, @var{nnn}b,
 
2262
@var{nnn}c, etc.  For example, the option @option{-rX2} produces the
 
2263
following page numbers: 1, 2, 2a, 2b, 2c, etc.
 
2264
@end table
 
2265
 
 
2266
@c ---------------------------------------------------------------------
 
2267
 
 
2268
@node Man usage, Man font macros, Man options, man
 
2269
@subsection Usage
 
2270
@cindex @code{man} macros
 
2271
@cindex macros for manual pages [@code{man}]
 
2272
 
 
2273
@pindex man.local
 
2274
This section describes the available macros for manual pages.  For
 
2275
further customization, put additional macros and requests into the file
 
2276
@file{man.local} which is loaded immediately after the @file{man}
 
2277
package.
 
2278
 
 
2279
@Defmac {TH, title section [@Var{extra1} [@Var{extra2} [@Var{extra3}]]], man}
 
2280
Set the title of the man page to @var{title} and the section to
 
2281
@var{section}, which must have a value between 1 and@tie{}8.  The value
 
2282
of @var{section} may also have a string appended, e.g.@: @samp{.pm}, to
 
2283
indicate a specific subsection of the man pages.
 
2284
 
 
2285
Both @var{title} and @var{section} are positioned at the left and right
 
2286
in the header line (with @var{section} in parentheses immediately
 
2287
appended to @var{title}.  @var{extra1} is positioned in the middle of
 
2288
the footer line.  @var{extra2} is positioned at the left in the footer
 
2289
line (or at the left on even pages and at the right on odd pages if
 
2290
double-sided printing is active).  @var{extra3} is centered in the
 
2291
header line.
 
2292
 
 
2293
For @acronym{HTML} and @acronym{XHTML} output, headers and footers are
 
2294
completely suppressed.
 
2295
 
 
2296
Additionally, this macro starts a new page; the new line number
 
2297
is@tie{}1 again (except if the @option{-rC1} option is given on the
 
2298
command line) -- this feature is intended only for formatting multiple
 
2299
man pages; a single man page should contain exactly one @code{TH} macro
 
2300
at the beginning of the file.
 
2301
@endDefmac
 
2302
 
 
2303
@Defmac {SH, [@Var{heading}], man}
 
2304
Set up an unnumbered section heading sticking out to the left.  Prints
 
2305
out all the text following @code{SH} up to the end of the line (or the
 
2306
text in the next line if there is no argument to @code{SH}) in bold face
 
2307
(or the font specified by the string @code{HF}), one size larger than
 
2308
the base document size.  Additionally, the left margin and the
 
2309
indentation for the following text is reset to its default value.
 
2310
@endDefmac
 
2311
 
 
2312
@Defmac {SS, [@Var{heading}], man}
 
2313
Set up an unnumbered (sub)section heading.  Prints out all the text
 
2314
following @code{SS} up to the end of the line (or the text in the next
 
2315
line if there is no argument to @code{SS}) in bold face (or the font
 
2316
specified by the string @code{HF}), at the same size as the base
 
2317
document size.  Additionally, the left margin and the indentation for
 
2318
the following text is reset to its default value.
 
2319
@endDefmac
 
2320
 
 
2321
@Defmac {TP, [@Var{nnn}], man}
 
2322
Set up an indented paragraph with label.  The indentation is set to
 
2323
@var{nnn} if that argument is supplied (the default unit is @samp{n} if
 
2324
omitted), otherwise it is set to the previous indentation value
 
2325
specified with @code{TP}, @code{IP}, or @code{HP} (or to the default
 
2326
value if none of them have been used yet).
 
2327
 
 
2328
The first line of text following this macro is interpreted as a string
 
2329
to be printed flush-left, as it is appropriate for a label.  It is not
 
2330
interpreted as part of a paragraph, so there is no attempt to fill the
 
2331
first line with text from the following input lines.  Nevertheless, if
 
2332
the label is not as wide as the indentation the paragraph starts at the
 
2333
same line (but indented), continuing on the following lines.  If the
 
2334
label is wider than the indentation the descriptive part of the
 
2335
paragraph begins on the line following the label, entirely indented.
 
2336
Note that neither font shape nor font size of the label is set to a
 
2337
default value; on the other hand, the rest of the text has default font
 
2338
settings.
 
2339
@endDefmac
 
2340
 
 
2341
@DefmacList {LP, , man}
 
2342
@DefmacItem {PP, , man}
 
2343
@DefmacListEnd {P, , man}
 
2344
These macros are mutual aliases.  Any of them causes a line break at the
 
2345
current position, followed by a vertical space downwards by the amount
 
2346
specified by the @code{PD} macro.  The font size and shape are reset to
 
2347
the default value (10@dmn{pt} roman if no @option{-rS} option is given
 
2348
on the command line).  Finally, the current left margin and the
 
2349
indentation is restored.
 
2350
@endDefmac
 
2351
 
 
2352
@Defmac {IP, [@Var{designator} [@Var{nnn}]], man}
 
2353
Set up an indented paragraph, using @var{designator} as a tag to mark
 
2354
its beginning.  The indentation is set to @var{nnn} if that argument is
 
2355
supplied (default unit is @samp{n}), otherwise it is set to the previous
 
2356
indentation value specified with @code{TP}, @code{IP}, or @code{HP} (or
 
2357
the default value if none of them have been used yet).  Font size and
 
2358
face of the paragraph (but not the designator) are reset to their
 
2359
default values.
 
2360
 
 
2361
To start an indented paragraph with a particular indentation but without
 
2362
a designator, use @samp{""} (two double quotes) as the first argument of
 
2363
@code{IP}.
 
2364
 
 
2365
For example, to start a paragraph with bullets as the designator and
 
2366
4@tie{}en indentation, write
 
2367
 
 
2368
@Example
 
2369
.IP \(bu 4
 
2370
@endExample
 
2371
@endDefmac
 
2372
 
 
2373
@Defmac {HP, [@Var{nnn}], man}
 
2374
@cindex hanging indentation [@code{man}]
 
2375
@cindex @code{man} macros, hanging indentation
 
2376
Set up a paragraph with hanging left indentation.  The indentation is
 
2377
set to @var{nnn} if that argument is supplied (default unit is
 
2378
@samp{n}), otherwise it is set to the previous indentation value
 
2379
specified with @code{TP}, @code{IP}, or @code{HP} (or the default value
 
2380
if non of them have been used yet).  Font size and face are reset to
 
2381
their default values.
 
2382
@endDefmac
 
2383
 
 
2384
@Defmac {RS, [@Var{nnn}], man}
 
2385
@cindex left margin, how to move [@code{man}]
 
2386
@cindex @code{man} macros, moving left margin
 
2387
Move the left margin to the right by the value @var{nnn} if specified
 
2388
(default unit is @samp{n}); otherwise it is set to the previous
 
2389
indentation value specified with @code{TP}, @code{IP}, or @code{HP} (or
 
2390
to the default value if none of them have been used yet).  The
 
2391
indentation value is then set to the default.
 
2392
 
 
2393
Calls to the @code{RS} macro can be nested.
 
2394
@endDefmac
 
2395
 
 
2396
@Defmac {RE, [@Var{nnn}], man}
 
2397
Move the left margin back to level @var{nnn}, restoring the previous
 
2398
left margin.  If no argument is given, it moves one level back.  The
 
2399
first level (i.e., no call to @code{RS} yet) has number@tie{}1, and each
 
2400
call to @code{RS} increases the level by@tie{}1.
 
2401
@endDefmac
 
2402
 
 
2403
@cindex line breaks, with vertical space [@code{man}]
 
2404
@cindex @code{man} macros, line breaks with vertical space
 
2405
To summarize, the following macros cause a line break with the insertion
 
2406
of vertical space (which amount can be changed with the @code{PD}
 
2407
macro): @code{SH}, @code{SS}, @code{TP}, @code{LP} (@code{PP},
 
2408
@code{P}), @code{IP}, and @code{HP}.
 
2409
 
 
2410
@cindex line breaks, without vertical space [@code{man}]
 
2411
@cindex @code{man} macros, line breaks without vertical space
 
2412
The macros @code{RS} and @code{RE} also cause a break but do not insert
 
2413
vertical space.
 
2414
 
 
2415
@cindex default indentation, resetting [@code{man}]
 
2416
@cindex indentaion, resetting to default [@code{man}]
 
2417
@cindex @code{man} macros, resetting default indentation
 
2418
Finally, the macros @code{SH}, @code{SS}, @code{LP} (@code{PP},
 
2419
@code{P}), and @code{RS} reset the indentation to its default value.
 
2420
 
 
2421
@c ---------------------------------------------------------------------
 
2422
 
 
2423
@node Man font macros, Miscellaneous man macros, Man usage, man
 
2424
@subsection Macros to set fonts
 
2425
@cindex font selection [@code{man}]
 
2426
@cindex @code{man} macros, how to set fonts
 
2427
 
 
2428
The standard font is roman; the default text size is 10@tie{}point.  If
 
2429
command line option @option{-rS=@var{n}} is given, use @var{n}@dmn{pt}
 
2430
as the default text size.
 
2431
 
 
2432
@Defmac {SM, [@Var{text}], man}
 
2433
Set the text on the same line or the text on the next line in a font
 
2434
that is one point size smaller than the default font.
 
2435
@endDefmac
 
2436
 
 
2437
@Defmac {SB, [@Var{text}], man}
 
2438
@cindex bold face [@code{man}]
 
2439
@cindex @code{man} macros, bold face
 
2440
Set the text on the same line or the text on the next line in bold face
 
2441
font, one point size smaller than the default font.
 
2442
@endDefmac
 
2443
 
 
2444
@Defmac {BI, text, man}
 
2445
Set its arguments alternately in bold face and italic, without a space
 
2446
between the arguments.  Thus,
 
2447
 
 
2448
@Example
 
2449
.BI this "word and" that
 
2450
@endExample
 
2451
 
 
2452
@noindent
 
2453
produces ``thisword andthat'' with ``this'' and ``that'' in bold face,
 
2454
and ``word and'' in italics.
 
2455
@endDefmac
 
2456
 
 
2457
@Defmac {IB, text, man}
 
2458
Set its arguments alternately in italic and bold face, without a space
 
2459
between the arguments.
 
2460
@endDefmac
 
2461
 
 
2462
@Defmac {RI, text, man}
 
2463
Set its arguments alternately in roman and italic, without a space
 
2464
between the arguments.
 
2465
@endDefmac
 
2466
 
 
2467
@Defmac {IR, text, man}
 
2468
Set its arguments alternately in italic and roman, without a space
 
2469
between the arguments.
 
2470
@endDefmac
 
2471
 
 
2472
@Defmac {BR, text, man}
 
2473
Set its arguments alternately in bold face and roman, without a space
 
2474
between the arguments.
 
2475
@endDefmac
 
2476
 
 
2477
@Defmac {RB, text, man}
 
2478
Set its arguments alternately in roman and bold face, without a space
 
2479
between the arguments.
 
2480
@endDefmac
 
2481
 
 
2482
@Defmac {B, [@Var{text}], man}
 
2483
Set @var{text} in bold face.  If no text is present on the line where
 
2484
the macro is called, then the text of the next line appears in bold
 
2485
face.
 
2486
@endDefmac
 
2487
 
 
2488
@Defmac {I, [@Var{text}], man}
 
2489
@cindex italic fonts [@code{man}]
 
2490
@cindex @code{man} macros, italic fonts
 
2491
Set @var{text} in italic.  If no text is present on the line where the
 
2492
macro is called, then the text of the next line appears in italic.
 
2493
@endDefmac
 
2494
 
 
2495
@c ---------------------------------------------------------------------
 
2496
 
 
2497
@node Miscellaneous man macros, Predefined man strings, Man font macros, man
 
2498
@subsection Miscellaneous macros
 
2499
 
 
2500
@pindex grohtml
 
2501
@cindex @code{man} macros, default indentation
 
2502
@cindex default indentation [@code{man}]
 
2503
The default indentation is 7.2@dmn{n} in troff mode and 7@dmn{n} in
 
2504
nroff mode except for @code{grohtml} which ignores indentation.
 
2505
 
 
2506
@Defmac {DT, , man}
 
2507
@cindex tab stops [@code{man}]
 
2508
@cindex @code{man} macros, tab stops
 
2509
Set tabs every 0.5@tie{}inches.  Since this macro is always executed
 
2510
during a call to the @code{TH} macro, it makes sense to call it only if
 
2511
the tab positions have been changed.
 
2512
@endDefmac
 
2513
 
 
2514
@Defmac {PD, [@Var{nnn}], man}
 
2515
@cindex empty space before a paragraph [@code{man}]
 
2516
@cindex @code{man} macros, empty space before a paragraph
 
2517
Adjust the empty space before a new paragraph (or section).  The
 
2518
optional argument gives the amount of space (default unit is @samp{v});
 
2519
without parameter, the value is reset to its default value (1@tie{}line
 
2520
in nroff mode, 0.4@dmn{v}@tie{}otherwise).
 
2521
 
 
2522
This affects the macros @code{SH}, @code{SS}, @code{TP}, @code{LP} (as
 
2523
well as @code{PP} and @code{P}), @code{IP}, and @code{HP}.
 
2524
@endDefmac
 
2525
 
 
2526
The following two macros are included for BSD compatibility.
 
2527
 
 
2528
@Defmac {AT, [@Var{system} [@Var{release}]], man}
 
2529
@cindex @code{man}macros, BSD compatibility
 
2530
Alter the footer for use with @acronym{AT&T} manpages.  This command
 
2531
exists only for compatibility; don't use it.  The first argument
 
2532
@var{system} can be:
 
2533
 
 
2534
@table @code
 
2535
@item 3
 
2536
7th Edition (the default)
 
2537
 
 
2538
@item 4
 
2539
System III
 
2540
 
 
2541
@item 5
 
2542
System V
 
2543
@end table
 
2544
 
 
2545
An optional second argument @var{release} to @code{AT} specifies the
 
2546
release number (such as ``System V Release 3'').
 
2547
@endDefmac
 
2548
 
 
2549
@Defmac {UC, [@Var{version}], man}
 
2550
@cindex @code{man}macros, BSD compatibility
 
2551
Alters the footer for use with BSD manpages.  This command exists only
 
2552
for compatibility; don't use it.  The argument can be:
 
2553
 
 
2554
@table @code
 
2555
@item 3
 
2556
3rd Berkeley Distribution (the default)
 
2557
 
 
2558
@item 4
 
2559
4th Berkeley Distribution
 
2560
 
 
2561
@item 5
 
2562
4.2 Berkeley Distribution
 
2563
 
 
2564
@item 6
 
2565
4.3 Berkeley Distribution
 
2566
 
 
2567
@item 7
 
2568
4.4 Berkeley Distribution
 
2569
@end table
 
2570
@endDefmac
 
2571
 
 
2572
@c ---------------------------------------------------------------------
 
2573
 
 
2574
@node Predefined man strings, Preprocessors in man pages, Miscellaneous man macros, man
 
2575
@subsection Predefined strings
 
2576
 
 
2577
The following strings are defined:
 
2578
 
 
2579
@Defstr {S, man}
 
2580
Switch back to the default font size.
 
2581
@endDefstr
 
2582
 
 
2583
@Defstr {HF, man}
 
2584
The typeface used for headings.
 
2585
The default is @samp{B}.
 
2586
@endDefstr
 
2587
 
 
2588
@Defstr {R, man}
 
2589
The `registered' sign.
 
2590
@endDefstr
 
2591
 
 
2592
@Defstr {Tm, man}
 
2593
The `trademark' sign.
 
2594
@endDefstr
 
2595
 
 
2596
@DefstrList {lq, man}
 
2597
@DefstrListEnd {rq, man}
 
2598
@cindex @code{lq} glyph, and @code{lq} string [@code{man}]
 
2599
@cindex @code{rq} glyph, and @code{rq} string [@code{man}]
 
2600
Left and right quote.  This is equal to @code{\(lq} and @code{\(rq},
 
2601
respectively.
 
2602
@endDefstr
 
2603
 
 
2604
@c ---------------------------------------------------------------------
 
2605
 
 
2606
@node Preprocessors in man pages, Optional man extensions, Predefined man strings, man
 
2607
@subsection Preprocessors in @file{man} pages
 
2608
 
 
2609
@cindex preprocessor, calling convention
 
2610
@cindex calling convention of preprocessors
 
2611
If a preprocessor like @code{gtbl} or @code{geqn} is needed, it has
 
2612
become common usage to make the first line of the man page look like
 
2613
this:
 
2614
 
 
2615
@Example
 
2616
'\" @var{word}
 
2617
@endExample
 
2618
 
 
2619
@pindex geqn@r{, invocation in manual pages}
 
2620
@pindex grefer@r{, invocation in manual pages}
 
2621
@pindex gtbl@r{, invocation in manual pages}
 
2622
@pindex man@r{, invocation of preprocessors}
 
2623
@noindent
 
2624
Note the single space character after the double quote.  @var{word}
 
2625
consists of letters for the needed preprocessors: @samp{e} for
 
2626
@code{geqn}, @samp{r} for @code{grefer}, @samp{t} for @code{gtbl}.
 
2627
Modern implementations of the @code{man} program read this first line
 
2628
and automatically call the right preprocessor(s).
 
2629
 
 
2630
@c ---------------------------------------------------------------------
 
2631
 
 
2632
@node Optional man extensions,  , Preprocessors in man pages, man
 
2633
@subsection Optional @file{man} extensions
 
2634
 
 
2635
@pindex man.local
 
2636
Use the file @file{man.local} for local extensions to the @code{man}
 
2637
macros or for style changes.
 
2638
 
 
2639
@unnumberedsubsubsec Custom headers and footers
 
2640
@cindex @code{man} macros, custom headers and footers
 
2641
 
 
2642
In groff versions 1.18.2 and later, you can specify custom headers and
 
2643
footers by redefining the following macros in @file{man.local}.
 
2644
 
 
2645
@Defmac {PT, , man}
 
2646
Control the content of the headers.  Normally, the header prints the
 
2647
command name and section number on either side, and the optional fifth
 
2648
argument to @code{TH} in the center.
 
2649
@endDefmac
 
2650
 
 
2651
@Defmac {BT, , man}
 
2652
Control the content of the footers.  Normally, the footer prints the
 
2653
page number and the third and fourth arguments to @code{TH}.
 
2654
 
 
2655
Use the @code{FT} number register to specify the footer position.  The
 
2656
default is @minus{}0.5@dmn{i}.
 
2657
@endDefmac
 
2658
 
 
2659
@unnumberedsubsubsec Ultrix-specific man macros
 
2660
@cindex Ultrix-specific @code{man} macros
 
2661
@cindex @code{man} macros, Ultrix-specific
 
2662
 
 
2663
@pindex man.ultrix
 
2664
The @code{groff} source distribution includes a file named
 
2665
@file{man.ultrix}, containing macros compatible with the Ultrix variant
 
2666
of @code{man}.  Copy this file into @file{man.local} (or use the
 
2667
@code{mso} request to load it) to enable the following macros.
 
2668
 
 
2669
@Defmac {CT, @Var{key}, man}
 
2670
Print @samp{<CTRL/@var{key}>}.
 
2671
@endDefmac
 
2672
 
 
2673
@Defmac {CW, , man}
 
2674
Print subsequent text using the constant width (Courier) typeface.
 
2675
@endDefmac
 
2676
 
 
2677
@Defmac {Ds, , man}
 
2678
Begin a non-filled display.
 
2679
@endDefmac
 
2680
 
 
2681
@Defmac {De, , man}
 
2682
End a non-filled display started with @code{Ds}.
 
2683
@endDefmac
 
2684
 
 
2685
@Defmac {EX, [@Var{indent}], man}
 
2686
Begin a non-filled display using the constant width (Courier) typeface.
 
2687
Use the optional @var{indent} argument to indent the display.
 
2688
@endDefmac
 
2689
 
 
2690
@Defmac {EE, , man}
 
2691
End a non-filled display started with @code{EX}.
 
2692
@endDefmac
 
2693
 
 
2694
@Defmac {G, [@Var{text}], man}
 
2695
Set @var{text} in Helvetica.  If no text is present on the line where
 
2696
the macro is called, then the text of the next line appears in
 
2697
Helvetica.
 
2698
@endDefmac
 
2699
 
 
2700
@Defmac {GL, [@Var{text}], man}
 
2701
Set @var{text} in Helvetica Oblique.  If no text is present on the line
 
2702
where the macro is called, then the text of the next line appears in
 
2703
Helvetica Oblique.
 
2704
@endDefmac
 
2705
 
 
2706
@Defmac {HB, [@Var{text}], man}
 
2707
Set @var{text} in Helvetica Bold.  If no text is present on the line
 
2708
where the macro is called, then all text up to the next @code{HB}
 
2709
appears in Helvetica Bold.
 
2710
@endDefmac
 
2711
 
 
2712
@Defmac {TB, [@Var{text}], man}
 
2713
Identical to @code{HB}.
 
2714
@endDefmac
 
2715
 
 
2716
@Defmac {MS, @Var{title} @Var{sect} [@Var{punct}], man}
 
2717
Set a manpage reference in Ultrix format.  The @var{title} is in Courier
 
2718
instead of italic.  Optional punctuation follows the section number
 
2719
without an intervening space.
 
2720
@endDefmac
 
2721
 
 
2722
@Defmac {NT, [@code{C}] [@Var{title}], man}
 
2723
Begin a note.  Print the optional @Var{title}, or the word ``Note'',
 
2724
centered on the page.  Text following the macro makes up the body of the
 
2725
note, and is indented on both sides.  If the first argument is @code{C},
 
2726
the body of the note is printed centered (the second argument replaces
 
2727
the word ``Note'' if specified).
 
2728
@endDefmac
 
2729
 
 
2730
@Defmac {NE, , man}
 
2731
End a note begun with @code{NT}.
 
2732
@endDefmac
 
2733
 
 
2734
@Defmac {PN, @Var{path} [@Var{punct}], man}
 
2735
Set the path name in constant width (Courier), followed by optional
 
2736
punctuation.
 
2737
@endDefmac
 
2738
 
 
2739
@Defmac {Pn, [@Var{punct}] @Var{path} [@Var{punct}], man}
 
2740
If called with two arguments, identical to @code{PN}.  If called with
 
2741
three arguments, set the second argument in constant width (Courier),
 
2742
bracketed by the first and third arguments in the current font.
 
2743
@endDefmac
 
2744
 
 
2745
@Defmac {R, , man}
 
2746
Switch to roman font and turn off any underlining in effect.
 
2747
@endDefmac
 
2748
 
 
2749
@Defmac {RN, , man}
 
2750
Print the string @samp{<RETURN>}.
 
2751
@endDefmac
 
2752
 
 
2753
@Defmac {VS, [@code{4}], man}
 
2754
Start printing a change bar in the margin if the number@tie{}@code{4} is
 
2755
specified.  Otherwise, this macro does nothing.
 
2756
@endDefmac
 
2757
 
 
2758
@Defmac {VE, , man}
 
2759
End printing the change bar begun by @code{VS}.
 
2760
@endDefmac
 
2761
 
 
2762
@unnumberedsubsubsec Simple example
 
2763
 
 
2764
The following example @file{man.local} file alters the @code{SH} macro
 
2765
to add some extra vertical space before printing the heading.  Headings
 
2766
are printed in Helvetica Bold.
 
2767
 
 
2768
@Example
 
2769
.\" Make the heading fonts Helvetica
 
2770
.ds HF HB
 
2771
.
 
2772
.\" Put more whitespace in front of headings.
 
2773
.rn SH SH-orig
 
2774
.de SH
 
2775
.  if t .sp (u;\\n[PD]*2)
 
2776
.  SH-orig \\$*
 
2777
..
 
2778
@endExample
 
2779
 
 
2780
 
 
2781
@c =====================================================================
 
2782
 
 
2783
@node mdoc, ms, man, Macro Packages
 
2784
@section @file{mdoc}
 
2785
@cindex @code{mdoc} macros
 
2786
 
 
2787
@c XXX documentation
 
2788
@c XXX this is a placeholder until we get stuff knocked into shape
 
2789
See the @cite{groff_mdoc(7)} man page (type @command{man groff_mdoc}
 
2790
at the command line).
 
2791
 
 
2792
 
 
2793
@c =====================================================================
 
2794
 
 
2795
@node ms, me, mdoc, Macro Packages
 
2796
@section @file{ms}
 
2797
@cindex @code{ms} macros
 
2798
 
 
2799
The @file{-ms} macros are suitable for reports, letters, books, user
 
2800
manuals, and so forth.  The package provides macros for cover pages,
 
2801
section headings, paragraphs, lists, footnotes, pagination, and a table
 
2802
of contents.
 
2803
 
 
2804
@menu
 
2805
* ms Intro::
 
2806
* General ms Structure::
 
2807
* ms Document Control Registers::
 
2808
* ms Cover Page Macros::
 
2809
* ms Body Text::
 
2810
* ms Page Layout::
 
2811
* Differences from AT&T ms::
 
2812
* Naming Conventions::
 
2813
@end menu
 
2814
 
 
2815
@c ---------------------------------------------------------------------
 
2816
 
 
2817
@node ms Intro, General ms Structure, ms, ms
 
2818
@subsection Introduction to @file{ms}
 
2819
 
 
2820
The original @file{-ms} macros were included with @acronym{AT&T}
 
2821
@code{troff} as well as the @file{man} macros.  While the @file{man}
 
2822
package is intended for brief documents that can be read on-line as well
 
2823
as printed, the @file{ms} macros are suitable for longer documents that
 
2824
are meant to be printed rather than read on-line.
 
2825
 
 
2826
The @file{ms} macro package included with @code{groff} is a complete,
 
2827
bottom-up re-implementation.  Several macros (specific to @acronym{AT&T}
 
2828
or Berkeley) are not included, while several new commands are.
 
2829
@xref{Differences from AT&T ms}, for more information.
 
2830
 
 
2831
@c ---------------------------------------------------------------------
 
2832
 
 
2833
@node General ms Structure, ms Document Control Registers, ms Intro, ms
 
2834
@subsection General structure of an @file{ms} document
 
2835
@cindex @code{ms} macros, general structure
 
2836
 
 
2837
The @file{ms} macro package expects a certain amount of structure, but
 
2838
not as much as packages such as @file{man} or @file{mdoc}.
 
2839
 
 
2840
The simplest documents can begin with a paragraph macro (such as
 
2841
@code{LP} or @code{PP}), and consist of text separated by paragraph
 
2842
macros or even blank lines.  Longer documents have a structure as
 
2843
follows:
 
2844
 
 
2845
@table @strong
 
2846
@item Document type
 
2847
If you invoke the @code{RP} (report) macro on the first line of the
 
2848
document, @code{groff} prints the cover page information on its own
 
2849
page; otherwise it prints the information on the first page with your
 
2850
document text immediately following.  Other document formats found in
 
2851
@acronym{AT&T} @code{troff} are specific to @acronym{AT&T} or Berkeley,
 
2852
and are not supported in @code{groff}.
 
2853
 
 
2854
@item Format and layout
 
2855
By setting number registers, you can change your document's type (font
 
2856
and size), margins, spacing, headers and footers, and footnotes.
 
2857
@xref{ms Document Control Registers}, for more details.
 
2858
 
 
2859
@item Cover page
 
2860
A cover page consists of a title, the author's name and institution, an
 
2861
abstract, and the date.@footnote{Actually, only the title is required.}
 
2862
@xref{ms Cover Page Macros}, for more details.
 
2863
 
 
2864
@item Body
 
2865
Following the cover page is your document.  You can use the @file{ms}
 
2866
macros to write reports, letters, books, and so forth.  The package is
 
2867
designed for structured documents, consisting of paragraphs interspersed
 
2868
with headings and augmented by lists, footnotes, tables, and other
 
2869
common constructs.  @xref{ms Body Text}, for more details.
 
2870
 
 
2871
@item Table of contents
 
2872
Longer documents usually include a table of contents, which you can
 
2873
invoke by placing the @code{TC} macro at the end of your document.  The
 
2874
@file{ms} macros have minimal indexing facilities, consisting of the
 
2875
@code{IX} macro, which prints an entry on standard error.  Printing the
 
2876
table of contents at the end is necessary since @code{groff} is a
 
2877
single-pass text formatter, thus it cannot determine the page number of
 
2878
each section until that section has actually been set and printed.
 
2879
Since @file{ms} output is intended for hardcopy, you can manually
 
2880
relocate the pages containing the table of contents between the cover
 
2881
page and the body text after printing.
 
2882
@end table
 
2883
 
 
2884
@c ---------------------------------------------------------------------
 
2885
 
 
2886
@node ms Document Control Registers, ms Cover Page Macros, General ms Structure, ms
 
2887
@subsection Document control registers
 
2888
@cindex @code{ms} macros, document control registers
 
2889
 
 
2890
The following is a list of document control number registers.  For the
 
2891
sake of consistency, set registers related to margins at the beginning
 
2892
of your document, or just after the @code{RP} macro.  You can set other
 
2893
registers later in your document, but you should keep them together at
 
2894
the beginning to make them easy to find and edit as necessary.
 
2895
 
 
2896
@unnumberedsubsubsec Margin Settings
 
2897
 
 
2898
@Defmpreg {PO, ms}
 
2899
Defines the page offset (i.e., the left margin).  There is no explicit
 
2900
right margin setting; the combination of the @code{PO} and @code{LL}
 
2901
registers implicitly define the right margin width.
 
2902
 
 
2903
Effective: next page.
 
2904
 
 
2905
Default value: 1@dmn{i}.
 
2906
@endDefmpreg
 
2907
 
 
2908
@Defmpreg {LL, ms}
 
2909
Defines the line length (i.e., the width of the body text).
 
2910
 
 
2911
Effective: next paragraph.
 
2912
 
 
2913
Default: 6@dmn{i}.
 
2914
@endDefmpreg
 
2915
 
 
2916
@Defmpreg {LT, ms}
 
2917
Defines the title length (i.e., the header and footer width).  This
 
2918
is usually the same as @code{LL}, but not necessarily.
 
2919
 
 
2920
Effective: next paragraph.
 
2921
 
 
2922
Default: 6@dmn{i}.
 
2923
@endDefmpreg
 
2924
 
 
2925
@Defmpreg {HM, ms}
 
2926
Defines the header margin height at the top of the page.
 
2927
 
 
2928
Effective: next page.
 
2929
 
 
2930
Default: 1@dmn{i}.
 
2931
@endDefmpreg
 
2932
 
 
2933
@Defmpreg {FM, ms}
 
2934
Defines the footer margin height at the bottom of the page.
 
2935
 
 
2936
Effective: next page.
 
2937
 
 
2938
Default: 1@dmn{i}.
 
2939
@endDefmpreg
 
2940
 
 
2941
@unnumberedsubsubsec Text Settings
 
2942
 
 
2943
@Defmpreg {PS, ms}
 
2944
Defines the point size of the body text.  If the value is larger than or
 
2945
equal to 1000, divide it by 1000 to get a fractional point size.  For
 
2946
example, @samp{.nr PS 10250} sets the document's point size to
 
2947
10.25@dmn{p}.
 
2948
 
 
2949
Effective: next paragraph.
 
2950
 
 
2951
Default: 10@dmn{p}.
 
2952
@endDefmpreg
 
2953
 
 
2954
@Defmpreg {VS, ms}
 
2955
Defines the space between lines (line height plus leading).  If the
 
2956
value is larger than or equal to 1000, divide it by 1000 to get a
 
2957
fractional point size.  Due to backwards compatibility, @code{VS} must
 
2958
be smaller than 40000 (this is 40.0@dmn{p}).
 
2959
 
 
2960
Effective: next paragraph.
 
2961
 
 
2962
Default: 12@dmn{p}.
 
2963
@endDefmpreg
 
2964
 
 
2965
@Defmpreg {PSINCR, ms}
 
2966
Defines an increment in point size, which is applied to section headings
 
2967
at nesting levels below the value specified in @code{GROWPS}.  The value
 
2968
of @code{PSINCR} should be specified in points, with the @dmn{p} scaling
 
2969
factor, and may include a fractional component; for example,
 
2970
@w{@samp{.nr PSINCR 1.5p}} sets a point size increment of 1.5@dmn{p}.
 
2971
 
 
2972
Effective: next section heading.
 
2973
 
 
2974
Default: 1@dmn{p}.
 
2975
@endDefmpreg
 
2976
 
 
2977
@Defmpreg {GROWPS, ms}
 
2978
Defines the heading level below which the point size increment set by
 
2979
@code{PSINCR} becomes effective.  Section headings at and above the
 
2980
level specified by @code{GROWPS} are printed at the point size set by
 
2981
@code{PS}; for each level below the value of @code{GROWPS}, the point
 
2982
size is increased in steps equal to the value of @code{PSINCR}.  Setting
 
2983
@code{GROWPS} to any value less than@tie{}2 disables the incremental
 
2984
heading size feature.
 
2985
 
 
2986
Effective: next section heading.
 
2987
 
 
2988
Default: 0.
 
2989
@endDefmpreg
 
2990
 
 
2991
@Defmpreg {HY, ms}
 
2992
Defines the hyphenation level.  @code{HY} sets safely the value of the
 
2993
low-level @code{hy} register.  Setting the value of @code{HY} to@tie{}0
 
2994
is equivalent to using the @code{nh} request.
 
2995
 
 
2996
Effective: next paragraph.
 
2997
 
 
2998
Default: 14.
 
2999
@endDefmpreg
 
3000
 
 
3001
@Defmpreg {FAM, ms}
 
3002
Defines the font family used to typeset the document.
 
3003
 
 
3004
Effective: next paragraph.
 
3005
 
 
3006
Default: as defined in the output device.
 
3007
@endDefmpreg
 
3008
 
 
3009
@unnumberedsubsubsec Paragraph Settings
 
3010
 
 
3011
@Defmpreg {PI, ms}
 
3012
Defines the initial indentation of a (@code{PP} macro) paragraph.
 
3013
 
 
3014
Effective: next paragraph.
 
3015
 
 
3016
Default: 5@dmn{n}.
 
3017
@endDefmpreg
 
3018
 
 
3019
@Defmpreg {PD, ms}
 
3020
Defines the space between paragraphs.
 
3021
 
 
3022
Effective: next paragraph.
 
3023
 
 
3024
Default: 0.3@dmn{v}.
 
3025
@endDefmpreg
 
3026
 
 
3027
@Defmpreg {QI, ms}
 
3028
Defines the indentation on both sides of a quoted (@code{QP} macro)
 
3029
paragraph.
 
3030
 
 
3031
Effective: next paragraph.
 
3032
 
 
3033
Default: 5@dmn{n}.
 
3034
@endDefmpreg
 
3035
 
 
3036
@Defmpreg {PORPHANS, ms}
 
3037
Defines the minimum number of initial lines of any paragraph which
 
3038
should be kept together, to avoid orphan lines at the bottom of a page.
 
3039
If a new paragraph is started close to the bottom of a page, and there
 
3040
is insufficient space to accommodate @code{PORPHANS} lines before an
 
3041
automatic page break, then the page break is forced, before the start of
 
3042
the paragraph.
 
3043
 
 
3044
Effective: next paragraph.
 
3045
 
 
3046
Default: 1.
 
3047
@endDefmpreg
 
3048
 
 
3049
@Defmpreg {HORPHANS, ms}
 
3050
Defines the minimum number of lines of the following paragraph which
 
3051
should be kept together with any section heading introduced by the
 
3052
@code{NH} or @code{SH} macros.  If a section heading is placed close to
 
3053
the bottom of a page, and there is insufficient space to accommodate
 
3054
both the heading and at least @code{HORPHANS} lines of the following
 
3055
paragraph, before an automatic page break, then the page break is forced
 
3056
before the heading.
 
3057
 
 
3058
Effective: next paragraph.
 
3059
 
 
3060
Default: 1.
 
3061
@endDefmpreg
 
3062
 
 
3063
@unnumberedsubsubsec Footnote Settings
 
3064
 
 
3065
@Defmpreg {FL, ms}
 
3066
Defines the length of a footnote.
 
3067
 
 
3068
Effective: next footnote.
 
3069
 
 
3070
Default: @math{@code{@\n[LL]} * 5 / 6}.
 
3071
@endDefmpreg
 
3072
 
 
3073
@Defmpreg {FI, ms}
 
3074
Defines the footnote indentation.
 
3075
 
 
3076
Effective: next footnote.
 
3077
 
 
3078
Default: 2@dmn{n}.
 
3079
@endDefmpreg
 
3080
 
 
3081
@Defmpreg {FF, ms}
 
3082
The footnote format:
 
3083
@table @code
 
3084
@item 0
 
3085
Print the footnote number as a superscript; indent the footnote
 
3086
(default).
 
3087
 
 
3088
@item 1
 
3089
Print the number followed by a period (like 1.@:) and indent the
 
3090
footnote.
 
3091
 
 
3092
@item 2
 
3093
Like 1, without an indentation.
 
3094
 
 
3095
@item 3
 
3096
Like 1, but print the footnote number as a hanging paragraph.
 
3097
@end table
 
3098
 
 
3099
Effective: next footnote.
 
3100
 
 
3101
Default: 0.
 
3102
@endDefmpreg
 
3103
 
 
3104
@Defmpreg {FPS, ms}
 
3105
Defines the footnote point size.  If the value is larger than or equal
 
3106
to 1000, divide it by 1000 to get a fractional point size.
 
3107
 
 
3108
Effective: next footnote.
 
3109
 
 
3110
Default: @math{@code{@\n[PS]} - 2}.
 
3111
@endDefmpreg
 
3112
 
 
3113
@Defmpreg {FVS, ms}
 
3114
Defines the footnote vertical spacing.  If the value is larger than or
 
3115
equal to 1000, divide it by 1000 to get a fractional point size.
 
3116
 
 
3117
Effective: next footnote.
 
3118
 
 
3119
Default: @math{@code{@\n[FPS]} + 2}.
 
3120
@endDefmpreg
 
3121
 
 
3122
@Defmpreg {FPD, ms}
 
3123
Defines the footnote paragraph spacing.
 
3124
 
 
3125
Effective: next footnote.
 
3126
 
 
3127
Default: @math{@code{@\n[PD]} / 2}.
 
3128
@endDefmpreg
 
3129
 
 
3130
@unnumberedsubsubsec Miscellaneous Number Registers
 
3131
 
 
3132
@Defmpreg {MINGW, ms}
 
3133
Defines the minimum width between columns in a multi-column document.
 
3134
 
 
3135
Effective: next page.
 
3136
 
 
3137
Default: 2@dmn{n}.
 
3138
@endDefmpreg
 
3139
 
 
3140
@Defmpreg {DD, ms}
 
3141
Sets the vertical spacing before and after a display, a @code{tbl} table, an
 
3142
@code{eqn} equation, or a @code{pic} image.
 
3143
 
 
3144
Effective: next paragraph.
 
3145
 
 
3146
Default: 0.5@dmn{v}.
 
3147
@endDefmpreg
 
3148
 
 
3149
@c ---------------------------------------------------------------------
 
3150
 
 
3151
@node ms Cover Page Macros, ms Body Text, ms Document Control Registers, ms
 
3152
@subsection Cover page macros
 
3153
@cindex @code{ms} macros, cover page
 
3154
@cindex cover page macros, [@code{ms}]
 
3155
 
 
3156
Use the following macros to create a cover page for your document in the
 
3157
order shown.
 
3158
 
 
3159
@Defmac {RP, [@code{no}], ms}
 
3160
Specifies the report format for your document.  The report format
 
3161
creates a separate cover page.  The default action (no @code{RP} macro)
 
3162
is to print a subset of the cover page on page@tie{}1 of your document.
 
3163
 
 
3164
If you use the word @code{no} as an optional argument, @code{groff}
 
3165
prints a title page but does not repeat any of the title page
 
3166
information (title, author, abstract, etc.@:) on page@tie{}1 of the
 
3167
document.
 
3168
@endDefmac
 
3169
 
 
3170
@Defmac {P1, , ms}
 
3171
(P-one) Prints the header on page@tie{}1.  The default is to suppress
 
3172
the header.
 
3173
@endDefmac
 
3174
 
 
3175
@Defmac {DA, [@dots{}], ms}
 
3176
(optional) Prints the current date, or the arguments to the macro if
 
3177
any, on the title page (if specified) and in the footers.  This is the
 
3178
default for @code{nroff}.
 
3179
@endDefmac
 
3180
 
 
3181
@Defmac {ND, [@dots{}], ms}
 
3182
(optional) Prints the current date, or the arguments to the macro if
 
3183
any, on the title page (if specified) but not in the footers.  This is
 
3184
the default for @code{troff}.
 
3185
@endDefmac
 
3186
 
 
3187
@Defmac {TL, , ms}
 
3188
Specifies the document title.  @code{groff} collects text following the
 
3189
@code{TL} macro into the title, until reaching the author name or
 
3190
abstract.
 
3191
@endDefmac
 
3192
 
 
3193
@Defmac {AU, , ms}
 
3194
Specifies the author's name, which appears on the line (or lines)
 
3195
immediately following.  You can specify multiple authors as follows:
 
3196
 
 
3197
@Example
 
3198
.AU
 
3199
John Doe
 
3200
.AI
 
3201
University of West Bumblefuzz
 
3202
.AU
 
3203
Martha Buck
 
3204
.AI
 
3205
Monolithic Corporation
 
3206
 
 
3207
...
 
3208
@endExample
 
3209
@endDefmac
 
3210
 
 
3211
@Defmac {AI, , ms}
 
3212
Specifies the author's institution.  You can specify multiple
 
3213
institutions in the same way that you specify multiple authors.
 
3214
@endDefmac
 
3215
 
 
3216
@Defmac {AB, [@code{no}], ms}
 
3217
Begins the abstract.  The default is to print the word
 
3218
@acronym{ABSTRACT}, centered and in italics, above the text of the
 
3219
abstract.  The word @code{no} as an optional argument suppresses this
 
3220
heading.
 
3221
@endDefmac
 
3222
 
 
3223
@Defmac {AE, , ms}
 
3224
Ends the abstract.
 
3225
@endDefmac
 
3226
 
 
3227
The following is example mark-up for a title page.
 
3228
@cindex title page, example markup
 
3229
@cindex example markup, title page
 
3230
 
 
3231
@CartoucheExample
 
3232
.RP
 
3233
.TL
 
3234
The Inevitability of Code Bloat
 
3235
in Commercial and Free Software
 
3236
.AU
 
3237
J. Random Luser
 
3238
.AI
 
3239
University of West Bumblefuzz
 
3240
.AB
 
3241
This report examines the long-term growth
 
3242
of the code bases in two large, popular software
 
3243
packages; the free Emacs and the commercial
 
3244
Microsoft Word.
 
3245
While differences appear in the type or order
 
3246
of features added, due to the different
 
3247
methodologies used, the results are the same
 
3248
in the end.
 
3249
.PP
 
3250
The free software approach is shown to be
 
3251
superior in that while free software can
 
3252
become as bloated as commercial offerings,
 
3253
free software tends to have fewer serious
 
3254
bugs and the added features are in line with
 
3255
user demand.
 
3256
.AE
 
3257
 
 
3258
... the rest of the paper follows ...
 
3259
@endCartoucheExample
 
3260
 
 
3261
@c ---------------------------------------------------------------------
 
3262
 
 
3263
@node ms Body Text, ms Page Layout, ms Cover Page Macros, ms
 
3264
@subsection Body text
 
3265
@cindex @code{ms} macros, body text
 
3266
 
 
3267
This section describes macros used to mark up the body of your document.
 
3268
Examples include paragraphs, sections, and other groups.
 
3269
 
 
3270
@menu
 
3271
* Paragraphs in ms::
 
3272
* Headings in ms::
 
3273
* Highlighting in ms::
 
3274
* Lists in ms::
 
3275
* Indentation values in ms::
 
3276
* Tabstops in ms::
 
3277
* ms Displays and Keeps::
 
3278
* ms Insertions::
 
3279
* Example multi-page table::
 
3280
* ms Footnotes::
 
3281
@end menu
 
3282
 
 
3283
@c ---------------------------------------------------------------------
 
3284
 
 
3285
@node Paragraphs in ms, Headings in ms, ms Body Text, ms Body Text
 
3286
@subsubsection Paragraphs
 
3287
@cindex @code{ms} macros, paragraph handling
 
3288
 
 
3289
The following paragraph types are available.
 
3290
 
 
3291
@Defmac {PP, , ms}
 
3292
Sets a paragraph with an initial indentation.
 
3293
@endDefmac
 
3294
 
 
3295
@Defmac {LP, , ms}
 
3296
Sets a paragraph without an initial indentation.
 
3297
@endDefmac
 
3298
 
 
3299
@Defmac {QP, , ms}
 
3300
Sets a paragraph that is indented at both left and right margins.  The
 
3301
effect is identical to the @acronym{HTML} @code{<BLOCKQUOTE>} element.
 
3302
The next paragraph or heading returns margins to normal.
 
3303
@endDefmac
 
3304
 
 
3305
@Defmac {XP, , ms}
 
3306
Sets a paragraph whose lines are indented, except for the first line.
 
3307
This is a Berkeley extension.
 
3308
@endDefmac
 
3309
 
 
3310
The following markup uses all four paragraph macros.
 
3311
 
 
3312
@CartoucheExample
 
3313
.NH 2
 
3314
Cases used in the study
 
3315
.LP
 
3316
The following software and versions were
 
3317
considered for this report.
 
3318
.PP
 
3319
For commercial software, we chose
 
3320
.B "Microsoft Word for Windows" ,
 
3321
starting with version 1.0 through the
 
3322
current version (Word 2000).
 
3323
.PP
 
3324
For free software, we chose
 
3325
.B Emacs ,
 
3326
from its first appearance as a standalone
 
3327
editor through the current version (v20).
 
3328
See [Bloggs 2002] for details.
 
3329
.QP
 
3330
Franklin's Law applied to software:
 
3331
software expands to outgrow both
 
3332
RAM and disk space over time.
 
3333
.LP
 
3334
Bibliography:
 
3335
.XP
 
3336
Bloggs, Joseph R.,
 
3337
.I "Everyone's a Critic" ,
 
3338
Underground Press, March 2002.
 
3339
A definitive work that answers all questions
 
3340
and criticisms about the quality and usability of
 
3341
free software.
 
3342
@endCartoucheExample
 
3343
 
 
3344
The @code{PORPHANS} register (@pxref{ms Document Control Registers})
 
3345
operates in conjunction with each of these macros, to inhibit the
 
3346
printing of orphan lines at the bottom of any page.
 
3347
 
 
3348
@c ---------------------------------------------------------------------
 
3349
 
 
3350
@node Headings in ms, Highlighting in ms, Paragraphs in ms, ms Body Text
 
3351
@subsubsection Headings
 
3352
@cindex @code{ms} macros, headings
 
3353
 
 
3354
Use headings to create a hierarchical structure for your document.  The
 
3355
@file{ms} macros print headings in @strong{bold}, using the same font
 
3356
family and point size as the body text.
 
3357
 
 
3358
The following describes the heading macros:
 
3359
 
 
3360
@DefmacList {NH, @Var{curr-level}, ms}
 
3361
@DefmacListEnd {NH, @t{S} @Var{level0} @dots{}, ms}
 
3362
Numbered heading.  The argument is either a numeric argument to indicate
 
3363
the level of the heading, or the letter@tie{}@code{S} followed by
 
3364
numeric arguments to set the heading level explicitly.
 
3365
 
 
3366
If you specify heading levels out of sequence, such as invoking
 
3367
@samp{.NH 3} after @samp{.NH 1}, @code{groff} prints a warning on
 
3368
standard error.
 
3369
@endDefmac
 
3370
 
 
3371
@DefstrList {SN, ms}
 
3372
@DefstrItem {SN-DOT, ms}
 
3373
@DefstrListEnd {SN-NO-DOT, ms}
 
3374
After invocation of @code{NH}, the assigned section number is made
 
3375
available in the strings @code{SN-DOT} (as it appears in a printed
 
3376
section heading with default formatting, followed by a terminating
 
3377
period), and @code{SN-NO-DOT} (with the terminating period omitted).
 
3378
The string @code{SN} is also defined, as an alias for @code{SN-DOT}; if
 
3379
preferred, you may redefine it as an alias for @code{SN-NO-DOT}, by
 
3380
including the initialization
 
3381
@Example
 
3382
.als SN SN-NO-DOT
 
3383
@endExample
 
3384
 
 
3385
@noindent
 
3386
at any time @strong{before} you would like the change to take effect.
 
3387
@endDefstr
 
3388
 
 
3389
@Defstr {SN-STYLE, ms}
 
3390
You may control the style used to print section numbers, within numbered
 
3391
section headings, by defining an appropriate alias for the string
 
3392
@code{SN-STYLE}.  The default style, in which the printed section number
 
3393
is followed by a terminating period, is obtained by defining the alias
 
3394
@Example
 
3395
.als SN-STYLE SN-DOT
 
3396
@endExample
 
3397
 
 
3398
@noindent
 
3399
If you prefer to omit the terminating period, from section numbers
 
3400
appearing in numbered section headings, you may define the alias
 
3401
@Example
 
3402
.als SN-STYLE SN-NO-DOT
 
3403
@endExample
 
3404
 
 
3405
@noindent
 
3406
Any such change in section numbering style becomes effective from the
 
3407
next use of @code{.NH}, following redefinition of the alias for
 
3408
@code{SN-STYLE}.
 
3409
@endDefstr
 
3410
 
 
3411
@Defmac {SH, [@Var{match-level}], ms}
 
3412
Unnumbered subheading.
 
3413
 
 
3414
The optional @var{match-level} argument is a GNU extension.  It is a
 
3415
number indicating the level of the heading, in a manner analogous to the
 
3416
@var{curr-level} argument to @code{.NH}.  Its purpose is to match the
 
3417
point size, at which the heading is printed, to the size of a numbered
 
3418
heading at the same level, when the @code{GROWPS} and @code{PSINCR}
 
3419
heading size adjustment mechanism is in effect.  @xref{ms Document
 
3420
Control Registers}.
 
3421
@endDefmac
 
3422
 
 
3423
The @code{HORPHANS} register (@pxref{ms Document Control Registers})
 
3424
operates in conjunction with the @code{NH} and @code{SH} macros, to
 
3425
inhibit the printing of orphaned section headings at the bottom of any
 
3426
page.
 
3427
 
 
3428
@c ---------------------------------------------------------------------
 
3429
 
 
3430
@node Highlighting in ms, Lists in ms, Headings in ms, ms Body Text
 
3431
@subsubsection Highlighting
 
3432
@cindex @code{ms} macros, highlighting
 
3433
 
 
3434
The @file{ms} macros provide a variety of methods to highlight or
 
3435
emphasize text:
 
3436
 
 
3437
@Defmac {B, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
 
3438
Sets its first argument in @strong{bold type}.  If you specify a second
 
3439
argument, @code{groff} prints it in the previous font after the bold
 
3440
text, with no intervening space (this allows you to set punctuation
 
3441
after the highlighted text without highlighting the punctuation).
 
3442
Similarly, it prints the third argument (if any) in the previous font
 
3443
@strong{before} the first argument.  For example,
 
3444
 
 
3445
@Example
 
3446
.B foo ) (
 
3447
@endExample
 
3448
 
 
3449
prints (@strong{foo}).
 
3450
 
 
3451
If you give this macro no arguments, @code{groff} prints all text
 
3452
following in bold until the next highlighting, paragraph, or heading
 
3453
macro.
 
3454
@endDefmac
 
3455
 
 
3456
@Defmac {R, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
 
3457
Sets its first argument in roman (or regular) type.  It operates
 
3458
similarly to the @code{B}@tie{}macro otherwise.
 
3459
@endDefmac
 
3460
 
 
3461
@Defmac {I, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
 
3462
Sets its first argument in @emph{italic type}.  It operates similarly
 
3463
to the @code{B}@tie{}macro otherwise.
 
3464
@endDefmac
 
3465
 
 
3466
@Defmac {CW, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
 
3467
Sets its first argument in a @code{constant width face}.  It operates
 
3468
similarly to the @code{B}@tie{}macro otherwise.
 
3469
@endDefmac
 
3470
 
 
3471
@Defmac {BI, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
 
3472
Sets its first argument in bold italic type.  It operates similarly to
 
3473
the @code{B}@tie{}macro otherwise.
 
3474
@endDefmac
 
3475
 
 
3476
@Defmac {BX, [@Var{txt}], ms}
 
3477
Prints its argument and draws a box around it.  If you want to box a
 
3478
string that contains spaces, use a digit-width space (@code{\0}).
 
3479
@endDefmac
 
3480
 
 
3481
@Defmac {UL, [@Var{txt} [@Var{post}]], ms}
 
3482
Prints its first argument with an underline.  If you specify a second
 
3483
argument, @code{groff} prints it in the previous font after the
 
3484
underlined text, with no intervening space.
 
3485
@endDefmac
 
3486
 
 
3487
@Defmac {LG, , ms}
 
3488
Prints all text following in larger type (two points larger than the
 
3489
current point size) until the next font size, highlighting, paragraph,
 
3490
or heading macro.  You can specify this macro multiple times to
 
3491
enlarge the point size as needed.
 
3492
@endDefmac
 
3493
 
 
3494
@Defmac {SM, , ms}
 
3495
Prints all text following in smaller type (two points smaller than the
 
3496
current point size) until the next type size, highlighting, paragraph,
 
3497
or heading macro.  You can specify this macro multiple times to reduce
 
3498
the point size as needed.
 
3499
@endDefmac
 
3500
 
 
3501
@Defmac {NL, , ms}
 
3502
Prints all text following in the normal point size (that is, the value
 
3503
of the @code{PS} register).
 
3504
@endDefmac
 
3505
 
 
3506
@DefstrList {@Lbrace{}, ms}
 
3507
@DefstrListEnd {@Rbrace{}, ms}
 
3508
Text enclosed with @code{\*@{} and @code{\*@}} is printed as a
 
3509
superscript.
 
3510
@endDefstr
 
3511
 
 
3512
@c ---------------------------------------------------------------------
 
3513
 
 
3514
@node Lists in ms, Indentation values in ms, Highlighting in ms, ms Body Text
 
3515
@subsubsection Lists
 
3516
@cindex @code{ms} macros, lists
 
3517
 
 
3518
The @code{IP} macro handles duties for all lists.
 
3519
 
 
3520
@Defmac {IP, [@Var{marker} [@Var{width}]], ms}
 
3521
The @var{marker} is usually a bullet glyph (@code{\[bu]}) for unordered
 
3522
lists, a number (or auto-incrementing number register) for numbered
 
3523
lists, or a word or phrase for indented (glossary-style) lists.
 
3524
 
 
3525
The @var{width} specifies the indentation for the body of each list
 
3526
item; its default unit is @samp{n}.  Once specified, the indentation
 
3527
remains the same for all list items in the document until specified
 
3528
again.
 
3529
 
 
3530
The @code{PORPHANS} register (@pxref{ms Document Control Registers})
 
3531
operates in conjunction with the @code{IP} macro, to inhibit the
 
3532
printing of orphaned list markers at the bottom of any page.
 
3533
@endDefmac
 
3534
 
 
3535
The following is an example of a bulleted list.
 
3536
@cindex example markup, bulleted list [@code{ms}]
 
3537
@cindex bulleted list, example markup [@code{ms}]
 
3538
 
 
3539
@Example
 
3540
A bulleted list:
 
3541
.IP \[bu] 2
 
3542
lawyers
 
3543
.IP \[bu]
 
3544
guns
 
3545
.IP \[bu]
 
3546
money
 
3547
@endExample
 
3548
 
 
3549
Produces:
 
3550
 
 
3551
@Example
 
3552
A bulleted list:
 
3553
 
 
3554
o lawyers
 
3555
 
 
3556
o guns
 
3557
 
 
3558
o money
 
3559
@endExample
 
3560
 
 
3561
The following is an example of a numbered list.
 
3562
@cindex example markup, numbered list [@code{ms}]
 
3563
@cindex numbered list, example markup [@code{ms}]
 
3564
 
 
3565
@Example
 
3566
.nr step 1 1
 
3567
A numbered list:
 
3568
.IP \n[step] 3
 
3569
lawyers
 
3570
.IP \n+[step]
 
3571
guns
 
3572
.IP \n+[step]
 
3573
money
 
3574
@endExample
 
3575
 
 
3576
Produces:
 
3577
 
 
3578
@Example
 
3579
A numbered list:
 
3580
 
 
3581
1. lawyers
 
3582
 
 
3583
2. guns
 
3584
 
 
3585
3. money
 
3586
@endExample
 
3587
 
 
3588
Note the use of the auto-incrementing number register in this example.
 
3589
 
 
3590
The following is an example of a glossary-style list.
 
3591
@cindex example markup, glossary-style list [@code{ms}]
 
3592
@cindex glossary-style list, example markup [@code{ms}]
 
3593
 
 
3594
@Example
 
3595
A glossary-style list:
 
3596
.IP lawyers 0.4i
 
3597
Two or more attorneys.
 
3598
.IP guns
 
3599
Firearms, preferably
 
3600
large-caliber.
 
3601
.IP money
 
3602
Gotta pay for those
 
3603
lawyers and guns!
 
3604
@endExample
 
3605
 
 
3606
Produces:
 
3607
 
 
3608
@Example
 
3609
A glossary-style list:
 
3610
 
 
3611
lawyers
 
3612
      Two or more attorneys.
 
3613
 
 
3614
guns  Firearms, preferably large-caliber.
 
3615
 
 
3616
money
 
3617
      Gotta pay for those lawyers and guns!
 
3618
@endExample
 
3619
 
 
3620
In the last example, the @code{IP} macro places the definition on the
 
3621
same line as the term if it has enough space; otherwise, it breaks to
 
3622
the next line and starts the definition below the term.  This may or may
 
3623
not be the effect you want, especially if some of the definitions break
 
3624
and some do not.  The following examples show two possible ways to force
 
3625
a break.
 
3626
 
 
3627
The first workaround uses the @code{br} request to force a break after
 
3628
printing the term or label.
 
3629
 
 
3630
@CartoucheExample
 
3631
A glossary-style list:
 
3632
.IP lawyers 0.4i
 
3633
Two or more attorneys.
 
3634
.IP guns
 
3635
.br
 
3636
Firearms, preferably large-caliber.
 
3637
.IP money
 
3638
Gotta pay for those lawyers and guns!
 
3639
@endCartoucheExample
 
3640
 
 
3641
The second workaround uses the @code{\p} escape to force the break.
 
3642
Note the space following the escape; this is important.  If you omit the
 
3643
space, @code{groff} prints the first word on the same line as the term
 
3644
or label (if it fits) @strong{then} breaks the line.
 
3645
 
 
3646
@CartoucheExample
 
3647
A glossary-style list:
 
3648
.IP lawyers 0.4i
 
3649
Two or more attorneys.
 
3650
.IP guns
 
3651
\p Firearms, preferably large-caliber.
 
3652
.IP money
 
3653
Gotta pay for those lawyers and guns!
 
3654
@endCartoucheExample
 
3655
 
 
3656
To set nested lists, use the @code{RS} and @code{RE} macros.
 
3657
@xref{Indentation values in ms}, for more information.
 
3658
@cindex @code{ms} macros, nested lists
 
3659
@cindex nested lists [@code{ms}]
 
3660
 
 
3661
For example:
 
3662
 
 
3663
@CartoucheExample
 
3664
.IP \[bu] 2
 
3665
Lawyers:
 
3666
.RS
 
3667
.IP \[bu]
 
3668
Dewey,
 
3669
.IP \[bu]
 
3670
Cheatham,
 
3671
.IP \[bu]
 
3672
and Howe.
 
3673
.RE
 
3674
.IP \[bu]
 
3675
Guns
 
3676
@endCartoucheExample
 
3677
 
 
3678
Produces:
 
3679
 
 
3680
@Example
 
3681
o Lawyers:
 
3682
 
 
3683
  o  Dewey,
 
3684
 
 
3685
  o  Cheatham,
 
3686
 
 
3687
  o  and Howe.
 
3688
 
 
3689
o Guns
 
3690
@endExample
 
3691
 
 
3692
@c ---------------------------------------------------------------------
 
3693
 
 
3694
@node Indentation values in ms, Tabstops in ms, Lists in ms, ms Body Text
 
3695
@subsubsection Indentation values
 
3696
 
 
3697
In many situations, you may need to indentation a section of text while
 
3698
still wrapping and filling.  @xref{Lists in ms}, for an example of
 
3699
nested lists.
 
3700
 
 
3701
@DefmacList {RS, , ms}
 
3702
@DefmacListEnd {RE, , ms}
 
3703
These macros begin and end an indented section.  The @code{PI} register
 
3704
controls the amount of indentation, allowing the indented text to line
 
3705
up under hanging and indented paragraphs.
 
3706
@endDefmac
 
3707
 
 
3708
@xref{ms Displays and Keeps}, for macros to indentation and turn off
 
3709
filling.
 
3710
 
 
3711
@c ---------------------------------------------------------------------
 
3712
 
 
3713
@node Tabstops in ms, ms Displays and Keeps, Indentation values in ms, ms Body Text
 
3714
@subsubsection Tab Stops
 
3715
 
 
3716
Use the @code{ta} request to define tab stops as needed.  @xref{Tabs and
 
3717
Fields}.
 
3718
 
 
3719
@Defmac {TA, , ms}
 
3720
Use this macro to reset the tab stops to the default for @file{ms}
 
3721
(every 5n).  You can redefine the @code{TA} macro to create a different
 
3722
set of default tab stops.
 
3723
@endDefmac
 
3724
 
 
3725
@c ---------------------------------------------------------------------
 
3726
 
 
3727
@node ms Displays and Keeps, ms Insertions, Tabstops in ms, ms Body Text
 
3728
@subsubsection Displays and keeps
 
3729
@cindex @code{ms} macros, displays
 
3730
@cindex @code{ms} macros, keeps
 
3731
@cindex keeps [@code{ms}]
 
3732
@cindex displays [@code{ms}]
 
3733
 
 
3734
Use displays to show text-based examples or figures (such as code
 
3735
listings).
 
3736
 
 
3737
Displays turn off filling, so lines of code are displayed as-is without
 
3738
inserting @code{br} requests in between each line.  Displays can be
 
3739
@dfn{kept} on a single page, or allowed to break across pages.
 
3740
 
 
3741
@DefmacList {DS, @t{L}, ms}
 
3742
@DefmacItem {LD, , ms}
 
3743
@DefmacListEnd {DE, , ms}
 
3744
Left-justified display.  The @samp{.DS L} call generates a page break,
 
3745
if necessary, to keep the entire display on one page.  The @code{LD}
 
3746
macro allows the display to break across pages.  The @code{DE} macro
 
3747
ends the display.
 
3748
@endDefmac
 
3749
 
 
3750
@DefmacList {DS, @t{I}, ms}
 
3751
@DefmacItem {ID, , ms}
 
3752
@DefmacListEnd {DE, , ms}
 
3753
Indents the display as defined by the @code{DI} register.  The @samp{.DS
 
3754
I} call generates a page break, if necessary, to keep the entire display
 
3755
on one page.  The @code{ID} macro allows the display to break across
 
3756
pages.  The @code{DE} macro ends the display.
 
3757
@endDefmac
 
3758
 
 
3759
@DefmacList {DS, @t{B}, ms}
 
3760
@DefmacItem {BD, , ms}
 
3761
@DefmacListEnd {DE, , ms}
 
3762
Sets a block-centered display: the entire display is left-justified, but
 
3763
indented so that the longest line in the display is centered on the
 
3764
page.  The @samp{.DS B} call generates a page break, if necessary, to
 
3765
keep the entire display on one page.  The @code{BD} macro allows the
 
3766
display to break across pages.  The @code{DE} macro ends the display.
 
3767
@endDefmac
 
3768
 
 
3769
@DefmacList {DS, @t{C}, ms}
 
3770
@DefmacItem {CD, , ms}
 
3771
@DefmacListEnd {DE, , ms}
 
3772
Sets a centered display: each line in the display is centered.  The
 
3773
@samp{.DS C} call generates a page break, if necessary, to keep the
 
3774
entire display on one page.  The @code{CD} macro allows the display to
 
3775
break across pages.  The @code{DE} macro ends the display.
 
3776
@endDefmac
 
3777
 
 
3778
@DefmacList {DS, @t{R}, ms}
 
3779
@DefmacItem {RD, , ms}
 
3780
@DefmacListEnd {DE, , ms}
 
3781
Right-justifies each line in the display.  The @samp{.DS R} call
 
3782
generates a page break, if necessary, to keep the entire display on one
 
3783
page.  The @code{RD} macro allows the display to break across pages.
 
3784
The @code{DE} macro ends the display.
 
3785
@endDefmac
 
3786
 
 
3787
@DefmacList {Ds, , ms}
 
3788
@DefmacListEnd {De, , ms}
 
3789
These two macros were formerly provided as aliases for @code{DS} and
 
3790
@code{DE}, respectively.  They have been removed, and should no longer
 
3791
be used.  The original implementations of @code{DS} and @code{DE} are
 
3792
retained, and should be used instead.  X11 documents which actually use
 
3793
@code{Ds} and @code{De} always load a specific macro file from the X11
 
3794
distribution (@file{macros.t}) which provides proper definitions for the
 
3795
two macros.
 
3796
@endDefmac
 
3797
 
 
3798
On occasion, you may want to @dfn{keep} other text together on a page.
 
3799
For example, you may want to keep two paragraphs together, or a
 
3800
paragraph that refers to a table (or list, or other item) immediately
 
3801
following.  The @file{ms} macros provide the @code{KS} and @code{KE}
 
3802
macros for this purpose.
 
3803
 
 
3804
@DefmacList {KS, , ms}
 
3805
@DefmacListEnd {KE, , ms}
 
3806
The @code{KS} macro begins a block of text to be kept on a single page,
 
3807
and the @code{KE} macro ends the block.
 
3808
@endDefmac
 
3809
 
 
3810
@DefmacList {KF, , ms}
 
3811
@DefmacListEnd {KE, , ms}
 
3812
Specifies a @dfn{floating keep}; if the keep cannot fit on the current
 
3813
page, @code{groff} holds the contents of the keep and allows text
 
3814
following the keep (in the source file) to fill in the remainder of the
 
3815
current page.  When the page breaks, whether by an explicit @code{bp}
 
3816
request or by reaching the end of the page, @code{groff} prints the
 
3817
floating keep at the top of the new page.  This is useful for printing
 
3818
large graphics or tables that do not need to appear exactly where
 
3819
specified.
 
3820
@endDefmac
 
3821
 
 
3822
You can also use the @code{ne} request to force a page break if there is
 
3823
not enough vertical space remaining on the page.
 
3824
 
 
3825
Use the following macros to draw a box around a section of text (such as
 
3826
a display).
 
3827
 
 
3828
@DefmacList {B1, , ms}
 
3829
@DefmacListEnd {B2, , ms}
 
3830
Marks the beginning and ending of text that is to have a box drawn
 
3831
around it.  The @code{B1} macro begins the box; the @code{B2} macro ends
 
3832
it.  Text in the box is automatically placed in a diversion (keep).
 
3833
@endDefmac
 
3834
 
 
3835
@c ---------------------------------------------------------------------
 
3836
 
 
3837
@node ms Insertions, Example multi-page table, ms Displays and Keeps, ms Body Text
 
3838
@subsubsection Tables, figures, equations, and references
 
3839
@cindex @code{ms} macros, tables
 
3840
@cindex @code{ms} macros, figures
 
3841
@cindex @code{ms} macros, equations
 
3842
@cindex @code{ms} macros, references
 
3843
@cindex tables [@code{ms}]
 
3844
@cindex figures [@code{ms}]
 
3845
@cindex equations [@code{ms}]
 
3846
@cindex references [@code{ms}]
 
3847
 
 
3848
The @file{ms} macros support the standard @code{groff} preprocessors:
 
3849
@code{tbl}, @code{pic}, @code{eqn}, and @code{refer}.
 
3850
@pindex tbl
 
3851
@pindex pic
 
3852
@pindex eqn
 
3853
@pindex refer
 
3854
You mark text meant for preprocessors by enclosing it in pairs of tags
 
3855
as follows.
 
3856
 
 
3857
@DefmacList {TS, [@code{H}], ms}
 
3858
@DefmacListEnd {TE, , ms}
 
3859
Denotes a table, to be processed by the @code{tbl} preprocessor.  The
 
3860
optional argument@tie{}@code{H} to @code{TS} instructs @code{groff} to
 
3861
create a running header with the information up to the @code{TH} macro.
 
3862
@code{groff} prints the header at the beginning of the table; if the
 
3863
table runs onto another page, @code{groff} prints the header on the next
 
3864
page as well.
 
3865
@endDefmac
 
3866
 
 
3867
@DefmacList {PS, , ms}
 
3868
@DefmacListEnd {PE, , ms}
 
3869
Denotes a graphic, to be processed by the @code{pic} preprocessor.  You
 
3870
can create a @code{pic} file by hand, using the @acronym{AT&T}
 
3871
@code{pic} manual available on the Web as a reference, or by using a
 
3872
graphics program such as @code{xfig}.
 
3873
@endDefmac
 
3874
 
 
3875
@DefmacList {EQ, [@Var{align}], ms}
 
3876
@DefmacListEnd {EN, , ms}
 
3877
Denotes an equation, to be processed by the @code{eqn} preprocessor.
 
3878
The optional @var{align} argument can be @code{C}, @code{L},
 
3879
or@tie{}@code{I} to center (the default), left-justify, or indent the
 
3880
equation.
 
3881
@endDefmac
 
3882
 
 
3883
@DefmacList {[, , ms}
 
3884
@DefmacListEnd {], , ms}
 
3885
Denotes a reference, to be processed by the @code{refer} preprocessor.
 
3886
The GNU @cite{refer(1)} man page provides a comprehensive reference to
 
3887
the preprocessor and the format of the bibliographic database.
 
3888
@endDefmac
 
3889
 
 
3890
@menu
 
3891
* Example multi-page table::
 
3892
@end menu
 
3893
 
 
3894
@c ---------------------------------------------------------------------
 
3895
 
 
3896
@node Example multi-page table, ms Footnotes, ms Insertions, ms Body Text
 
3897
@subsubsection An example multi-page table
 
3898
@cindex example markup, multi-page table [@code{ms}]
 
3899
@cindex multi-page table, example markup [@code{ms}]
 
3900
 
 
3901
The following is an example of how to set up a table that may print
 
3902
across two or more pages.
 
3903
 
 
3904
@CartoucheExample
 
3905
.TS H
 
3906
allbox expand;
 
3907
cb | cb .
 
3908
Text      ...of heading...
 
3909
_
 
3910
.TH
 
3911
.T&
 
3912
l | l .
 
3913
... the rest of the table follows...
 
3914
.CW
 
3915
.TE
 
3916
@endCartoucheExample
 
3917
 
 
3918
@c ---------------------------------------------------------------------
 
3919
 
 
3920
@node ms Footnotes,  , Example multi-page table, ms Body Text
 
3921
@subsubsection Footnotes
 
3922
@cindex @code{ms} macros, footnotes
 
3923
@cindex footnotes [@code{ms}]
 
3924
 
 
3925
The @file{ms} macro package has a flexible footnote system.  You can
 
3926
specify either numbered footnotes or symbolic footnotes (that is, using
 
3927
a marker such as a dagger symbol).
 
3928
 
 
3929
@Defstr {*, ms}
 
3930
Specifies the location of a numbered footnote marker in the text.
 
3931
@endDefesc
 
3932
 
 
3933
@DefmacList {FS, , ms}
 
3934
@DefmacListEnd {FE, , ms}
 
3935
Specifies the text of the footnote.  The default action is to create a
 
3936
numbered footnote; you can create a symbolic footnote by specifying a
 
3937
@dfn{mark} glyph (such as @code{\[dg]} for the dagger glyph) in the body
 
3938
text and as an argument to the @code{FS} macro, followed by the text of
 
3939
the footnote and the @code{FE} macro.
 
3940
@endDefmac
 
3941
 
 
3942
You can control how @code{groff} prints footnote numbers by changing the
 
3943
value of the @code{FF} register.  @xref{ms Document Control Registers}.
 
3944
 
 
3945
@cindex footnotes, and keeps [@code{ms}]
 
3946
@cindex keeps, and footnotes [@code{ms}]
 
3947
@cindex footnotes, and displays [@code{ms}]
 
3948
@cindex displays, and footnotes [@code{ms}]
 
3949
Footnotes can be safely used within keeps and displays, but you should
 
3950
avoid using numbered footnotes within floating keeps.  You can set a
 
3951
second @code{\**} marker between a @code{\**} and its corresponding
 
3952
@code{.FS} entry; as long as each @code{FS} macro occurs @emph{after}
 
3953
the corresponding @code{\**} and the occurrences of @code{.FS} are in
 
3954
the same order as the corresponding occurrences of @code{\**}.
 
3955
 
 
3956
@c ---------------------------------------------------------------------
 
3957
 
 
3958
@node ms Page Layout, Differences from AT&T ms, ms Body Text, ms
 
3959
@subsection Page layout
 
3960
@cindex @code{ms} macros, page layout
 
3961
@cindex page layout [@code{ms}]
 
3962
 
 
3963
The default output from the @file{ms} macros provides a minimalist page
 
3964
layout: it prints a single column, with the page number centered at the
 
3965
top of each page.  It prints no footers.
 
3966
 
 
3967
You can change the layout by setting the proper number registers and
 
3968
strings.
 
3969
 
 
3970
@menu
 
3971
* ms Headers and Footers::
 
3972
* ms Margins::
 
3973
* ms Multiple Columns::
 
3974
* ms TOC::
 
3975
* ms Strings and Special Characters::
 
3976
@end menu
 
3977
 
 
3978
@c ---------------------------------------------------------------------
 
3979
 
 
3980
@node ms Headers and Footers, ms Margins, ms Page Layout, ms Page Layout
 
3981
@subsubsection Headers and footers
 
3982
@cindex @code{ms} macros, headers
 
3983
@cindex @code{ms} macros, footers
 
3984
@cindex headers [@code{ms}]
 
3985
@cindex footers [@code{ms}]
 
3986
 
 
3987
For documents that do not distinguish between odd and even pages, set
 
3988
the following strings:
 
3989
 
 
3990
@DefstrList {LH, ms}
 
3991
@DefstrItem {CH, ms}
 
3992
@DefstrListEnd {RH, ms}
 
3993
Sets the left, center, and right headers.
 
3994
@endDefstr
 
3995
 
 
3996
@DefstrList {LF, ms}
 
3997
@DefstrItem {CF, ms}
 
3998
@DefstrListEnd {RF, ms}
 
3999
Sets the left, center, and right footers.
 
4000
@endDefstr
 
4001
 
 
4002
For documents that need different information printed in the even and
 
4003
odd pages, use the following macros:
 
4004
 
 
4005
@DefmacList {OH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
 
4006
@DefmacItem {EH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
 
4007
@DefmacItem {OF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
 
4008
@DefmacListEnd {EF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
 
4009
The @code{OH} and @code{EH} macros define headers for the odd and even
 
4010
pages; the @code{OF} and @code{EF} macros define footers for the odd and
 
4011
even pages.  This is more flexible than defining the individual strings.
 
4012
 
 
4013
You can replace the quote (@code{'}) marks with any character not
 
4014
appearing in the header or footer text.
 
4015
@endDefmac
 
4016
 
 
4017
To specify custom header and footer processing, redefine the following
 
4018
macros:
 
4019
 
 
4020
@DefmacList {PT,, ms}
 
4021
@DefmacItem {HD,, ms}
 
4022
@DefmacListEnd {BT,, ms}
 
4023
The @code{PT} macro defines a custom header; the @code{BT} macro defines
 
4024
a custom footer.  These macros must handle odd/even/first page
 
4025
differences if necessary.
 
4026
 
 
4027
The @code{HD} macro defines additional header processing to take place
 
4028
after executing the @code{PT} macro.
 
4029
@endDefmac
 
4030
 
 
4031
@c ---------------------------------------------------------------------
 
4032
 
 
4033
@node ms Margins, ms Multiple Columns, ms Headers and Footers, ms Page Layout
 
4034
@subsubsection Margins
 
4035
@cindex @code{ms} macros, margins
 
4036
 
 
4037
You control margins using a set of number registers.  @xref{ms Document
 
4038
Control Registers}, for details.
 
4039
 
 
4040
@c ---------------------------------------------------------------------
 
4041
 
 
4042
@node ms Multiple Columns, ms TOC, ms Margins, ms Page Layout
 
4043
@subsubsection Multiple columns
 
4044
@cindex @code{ms} macros, multiple columns
 
4045
@cindex multiple columns [@code{ms}]
 
4046
 
 
4047
The @file{ms} macros can set text in as many columns as do reasonably
 
4048
fit on the page.  The following macros are available; all of them force
 
4049
a page break if a multi-column mode is already set.  However, if the
 
4050
current mode is single-column, starting a multi-column mode does
 
4051
@emph{not} force a page break.
 
4052
 
 
4053
@Defmac {1C, , ms}
 
4054
Single-column mode.
 
4055
@endDefmac
 
4056
 
 
4057
@Defmac {2C, , ms}
 
4058
Two-column mode.
 
4059
@endDefmac
 
4060
 
 
4061
@Defmac {MC, [@Var{width} [@Var{gutter}]], ms}
 
4062
Multi-column mode.  If you specify no arguments, it is equivalent to the
 
4063
@code{2C} macro.  Otherwise, @var{width} is the width of each column and
 
4064
@var{gutter} is the space between columns.  The @code{MINGW} number
 
4065
register controls the default gutter width.
 
4066
@endDefmac
 
4067
 
 
4068
@c ---------------------------------------------------------------------
 
4069
 
 
4070
@node ms TOC, ms Strings and Special Characters, ms Multiple Columns, ms Page Layout
 
4071
@subsubsection Creating a table of contents
 
4072
@cindex @code{ms} macros, creating table of contents
 
4073
@cindex table of contents, creating [@code{ms}]
 
4074
 
 
4075
The facilities in the @file{ms} macro package for creating a table of
 
4076
contents are semi-automated at best.  Assuming that you want the table
 
4077
of contents to consist of the document's headings, you need to repeat
 
4078
those headings wrapped in @code{XS} and @code{XE} macros.
 
4079
 
 
4080
@DefmacList {XS, [@Var{page}], ms}
 
4081
@DefmacItem {XA, [@Var{page}], ms}
 
4082
@DefmacListEnd {XE, , ms}
 
4083
These macros define a table of contents or an individual entry in the
 
4084
table of contents, depending on their use.  The macros are very simple;
 
4085
they cannot indent a heading based on its level.  The easiest way to
 
4086
work around this is to add tabs to the table of contents string.  The
 
4087
following is an example:
 
4088
 
 
4089
@CartoucheExample
 
4090
.NH 1
 
4091
Introduction
 
4092
.XS
 
4093
Introduction
 
4094
.XE
 
4095
.LP
 
4096
...
 
4097
.CW
 
4098
.NH 2
 
4099
Methodology
 
4100
.XS
 
4101
Methodology
 
4102
.XE
 
4103
.LP
 
4104
...
 
4105
@endCartoucheExample
 
4106
 
 
4107
You can manually create a table of contents by beginning with the
 
4108
@code{XS} macro for the first entry, specifying the page number for that
 
4109
entry as the argument to @code{XS}.  Add subsequent entries using the
 
4110
@code{XA} macro, specifying the page number for that entry as the
 
4111
argument to @code{XA}.  The following is an example:
 
4112
 
 
4113
@CartoucheExample
 
4114
.XS 1
 
4115
Introduction
 
4116
.XA 2
 
4117
A Brief History of the Universe
 
4118
.XA 729
 
4119
Details of Galactic Formation
 
4120
...
 
4121
.XE
 
4122
@endCartoucheExample
 
4123
@endDefmac
 
4124
 
 
4125
@Defmac {TC, [@code{no}], ms}
 
4126
Prints the table of contents on a new page, setting the page number
 
4127
to@tie{}@strong{i} (Roman lowercase numeral one).  You should usually
 
4128
place this macro at the end of the file, since @code{groff} is a
 
4129
single-pass formatter and can only print what has been collected up to
 
4130
the point that the @code{TC} macro appears.
 
4131
 
 
4132
The optional argument @code{no} suppresses printing the title specified
 
4133
by the string register @code{TOC}.
 
4134
@endDefmac
 
4135
 
 
4136
@Defmac {PX, [@code{no}], ms}
 
4137
Prints the table of contents on a new page, using the current page
 
4138
numbering sequence.  Use this macro to print a manually-generated table
 
4139
of contents at the beginning of your document.
 
4140
 
 
4141
The optional argument @code{no} suppresses printing the title specified
 
4142
by the string register @code{TOC}.
 
4143
@endDefmac
 
4144
 
 
4145
The @cite{Groff and Friends HOWTO} includes a @code{sed} script that
 
4146
automatically inserts @code{XS} and @code{XE} macro entries after each
 
4147
heading in a document.
 
4148
 
 
4149
Altering the @code{NH} macro to automatically build the table of
 
4150
contents is perhaps initially more difficult, but would save a great
 
4151
deal of time in the long run if you use @file{ms} regularly.
 
4152
 
 
4153
@c ---------------------------------------------------------------------
 
4154
 
 
4155
@node ms Strings and Special Characters,  , ms TOC, ms Page Layout
 
4156
@subsubsection Strings and Special Characters
 
4157
@cindex @code{ms} macros, strings
 
4158
@cindex @code{ms} macros, special characters
 
4159
@cindex @code{ms} macros, accent marks
 
4160
@cindex accent marks [@code{ms}]
 
4161
@cindex special characters [@code{ms}]
 
4162
@cindex strings [@code{ms}]
 
4163
 
 
4164
The @file{ms} macros provide the following predefined strings.  You can
 
4165
change the string definitions to help in creating documents in languages
 
4166
other than English.
 
4167
 
 
4168
@Defstr {REFERENCES, ms}
 
4169
Contains the string printed at the beginning of the references
 
4170
(bibliography) page.  The default is @samp{References}.
 
4171
@endDefstr
 
4172
 
 
4173
@Defstr {ABSTRACT, ms}
 
4174
Contains the string printed at the beginning of the abstract.  The
 
4175
default is @samp{ABSTRACT}.
 
4176
@endDefstr
 
4177
 
 
4178
@Defstr {TOC, ms}
 
4179
Contains the string printed at the beginning of the table of contents.
 
4180
@endDefstr
 
4181
 
 
4182
@DefstrList {MONTH1, ms}
 
4183
@DefstrItem {MONTH2, ms}
 
4184
@DefstrItem {MONTH3, ms}
 
4185
@DefstrItem {MONTH4, ms}
 
4186
@DefstrItem {MONTH5, ms}
 
4187
@DefstrItem {MONTH6, ms}
 
4188
@DefstrItem {MONTH7, ms}
 
4189
@DefstrItem {MONTH8, ms}
 
4190
@DefstrItem {MONTH9, ms}
 
4191
@DefstrItem {MONTH10, ms}
 
4192
@DefstrItem {MONTH11, ms}
 
4193
@DefstrListEnd {MONTH12, ms}
 
4194
Prints the full name of the month in dates.  The default is
 
4195
@samp{January}, @samp{February}, etc.
 
4196
@endDefstr
 
4197
 
 
4198
The following special characters are available@footnote{For an
 
4199
explanation what special characters are see @ref{Special Characters}.}:
 
4200
 
 
4201
@Defstr {-, ms}
 
4202
Prints an em dash.
 
4203
@endDefstr
 
4204
 
 
4205
@DefstrList {Q, ms}
 
4206
@DefstrListEnd {U, ms}
 
4207
Prints typographer's quotes in troff, and plain quotes in nroff.
 
4208
@code{\*Q} is the left quote and @code{\*U} is the right quote.
 
4209
@endDefstr
 
4210
 
 
4211
Improved accent marks are available in the @file{ms} macros.
 
4212
 
 
4213
@Defmac {AM, , ms}
 
4214
Specify this macro at the beginning of your document to enable extended
 
4215
accent marks and special characters.  This is a Berkeley extension.
 
4216
 
 
4217
To use the accent marks, place them @strong{after} the character being
 
4218
accented.
 
4219
 
 
4220
Note that groff's native support for accents is superior to the
 
4221
following definitions.
 
4222
@endDefmac
 
4223
 
 
4224
The following accent marks are available after invoking the @code{AM}
 
4225
macro:
 
4226
 
 
4227
@Defstr {\', ms}
 
4228
Acute accent.
 
4229
@endDefstr
 
4230
 
 
4231
@Defstr {\`, ms}
 
4232
Grave accent.
 
4233
@endDefstr
 
4234
 
 
4235
@Defstr {^, ms}
 
4236
Circumflex.
 
4237
@endDefstr
 
4238
 
 
4239
@Defstr {\,, ms}
 
4240
Cedilla.
 
4241
@endDefstr
 
4242
 
 
4243
@Defstr {~, ms}
 
4244
Tilde.
 
4245
@endDefstr
 
4246
 
 
4247
@deffn String @t{\*[:]}
 
4248
@ifnotinfo
 
4249
@stindex : @r{[}ms@r{]}
 
4250
@end ifnotinfo
 
4251
@ifinfo
 
4252
@stindex \*[@r{<colon>}] @r{[}ms@r{]}
 
4253
@end ifinfo
 
4254
Umlaut.
 
4255
@end deffn
 
4256
 
 
4257
@Defstr {v, ms}
 
4258
Hacek.
 
4259
@endDefstr
 
4260
 
 
4261
@Defstr {_, ms}
 
4262
Macron (overbar).
 
4263
@endDefstr
 
4264
 
 
4265
@Defstr {., ms}
 
4266
Underdot.
 
4267
@endDefstr
 
4268
 
 
4269
@Defstr {o, ms}
 
4270
Ring above.
 
4271
@endDefstr
 
4272
 
 
4273
The following are standalone characters available after invoking the
 
4274
@code{AM} macro:
 
4275
 
 
4276
@Defstr {?, ms}
 
4277
Upside-down question mark.
 
4278
@endDefstr
 
4279
 
 
4280
@Defstr {!, ms}
 
4281
Upside-down exclamation point.
 
4282
@endDefstr
 
4283
 
 
4284
@Defstr {8, ms}
 
4285
German � ligature.
 
4286
@endDefstr
 
4287
 
 
4288
@Defstr {3, ms}
 
4289
Yogh.
 
4290
@endDefstr
 
4291
 
 
4292
@Defstr {Th, ms}
 
4293
Uppercase thorn.
 
4294
@endDefstr
 
4295
 
 
4296
@Defstr {th, ms}
 
4297
Lowercase thorn.
 
4298
@endDefstr
 
4299
 
 
4300
@Defstr {D-, ms}
 
4301
Uppercase eth.
 
4302
@endDefstr
 
4303
 
 
4304
@Defstr {d-, ms}
 
4305
Lowercase eth.
 
4306
@endDefstr
 
4307
 
 
4308
@Defstr {q, ms}
 
4309
Hooked o.
 
4310
@endDefstr
 
4311
 
 
4312
@Defstr {ae, ms}
 
4313
Lowercase � ligature.
 
4314
@endDefstr
 
4315
 
 
4316
@Defstr {Ae, ms}
 
4317
Uppercase � ligature.
 
4318
@endDefstr
 
4319
 
 
4320
@c ---------------------------------------------------------------------
 
4321
 
 
4322
@node Differences from AT&T ms, Naming Conventions, ms Page Layout, ms
 
4323
@subsection Differences from @acronym{AT&T} @file{ms}
 
4324
@cindex @code{ms} macros, differences from @acronym{AT&T}
 
4325
@cindex @acronym{AT&T} @code{troff}, @code{ms} macro package differences
 
4326
 
 
4327
This section lists the (minor) differences between the @code{groff -ms}
 
4328
macros and @acronym{AT&T} @code{troff -ms} macros.
 
4329
 
 
4330
@itemize @bullet
 
4331
@item
 
4332
The internals of @code{groff -ms} differ from the internals of
 
4333
@acronym{AT&T} @code{troff -ms}.  Documents that depend upon
 
4334
implementation details of @acronym{AT&T} @code{troff -ms} may not format
 
4335
properly with @code{groff -ms}.
 
4336
 
 
4337
@item
 
4338
The general error-handling policy of @code{groff -ms} is to detect and
 
4339
report errors, rather than silently to ignore them.
 
4340
 
 
4341
@item
 
4342
@code{groff -ms} does not work in compatibility mode (this is, with the
 
4343
@option{-C} option).
 
4344
 
 
4345
@item
 
4346
There is no special support for typewriter-like devices.
 
4347
 
 
4348
@item
 
4349
@code{groff -ms} does not provide cut marks.
 
4350
 
 
4351
@item
 
4352
Multiple line spacing is not supported.  Use a larger vertical spacing
 
4353
instead.
 
4354
 
 
4355
@item
 
4356
Some @acronym{UNIX} @code{ms} documentation says that the @code{CW} and
 
4357
@code{GW} number registers can be used to control the column width and
 
4358
gutter width, respectively.  These number registers are not used in
 
4359
@code{groff -ms}.
 
4360
 
 
4361
@item
 
4362
Macros that cause a reset (paragraphs, headings, etc.@:) may change the
 
4363
indentation.  Macros that change the indentation do not increment or
 
4364
decrement the indentation, but rather set it absolutely.  This can cause
 
4365
problems for documents that define additional macros of their own.  The
 
4366
solution is to use not the @code{in} request but instead the @code{RS}
 
4367
and @code{RE} macros.
 
4368
 
 
4369
@item
 
4370
To make @code{groff -ms} use the default page offset (which also
 
4371
specifies the left margin), the @code{PO} register must stay undefined
 
4372
until the first @file{-ms} macro is evaluated.  This implies that
 
4373
@code{PO} should not be used early in the document, unless it is changed
 
4374
also: Remember that accessing an undefined register automatically
 
4375
defines it.
 
4376
@end itemize
 
4377
 
 
4378
@Defmpreg {GS, ms}
 
4379
This number register is set to@tie{}1 by the @code{groff -ms} macros,
 
4380
but it is not used by the @code{AT&T} @code{troff -ms} macros.
 
4381
Documents that need to determine whether they are being formatted with
 
4382
@code{AT&T} @code{troff -ms} or @code{groff -ms} should use this number
 
4383
register.
 
4384
@endDefmpreg
 
4385
 
 
4386
Emulations of a few ancient Bell Labs macros can be re-enabled by
 
4387
calling the otherwise undocumented @code{SC} section-header macro.
 
4388
Calling @code{SC} enables @code{UC} for marking up a product or
 
4389
application name, and the pair @code{P1}/@code{P2} for surrounding code
 
4390
example displays.
 
4391
 
 
4392
These are not enabled by default because (a)@tie{}they were not
 
4393
documented, in the original @code{ms} manual, and (b)@tie{}the @code{P1}
 
4394
and @code{UC} macros collide with different macros with the same names
 
4395
in the Berkeley version of @code{ms}.
 
4396
 
 
4397
These @code{groff} emulations are sufficient to give back the 1976
 
4398
Kernighan@tie{}& Cherry paper @cite{Typsetting Mathematics -- User's
 
4399
Guide} its section headings, and restore some text that had gone missing
 
4400
as arguments of undefined macros.  No warranty express or implied is
 
4401
given as to how well the typographic details these produce match the
 
4402
original Bell Labs macros.
 
4403
 
 
4404
@menu
 
4405
* Missing ms Macros::
 
4406
* Additional ms Macros::
 
4407
@end menu
 
4408
 
 
4409
@c ---------------------------------------------------------------------
 
4410
 
 
4411
@node Missing ms Macros, Additional ms Macros, Differences from AT&T ms, Differences from AT&T ms
 
4412
@subsubsection @code{troff} macros not appearing in @code{groff}
 
4413
 
 
4414
Macros missing from @code{groff -ms} are cover page macros specific to
 
4415
Bell Labs and Berkeley.  The macros known to be missing are:
 
4416
 
 
4417
@table @code
 
4418
@item .TM
 
4419
Technical memorandum; a cover sheet style
 
4420
 
 
4421
@item .IM
 
4422
Internal memorandum; a cover sheet style
 
4423
 
 
4424
@item .MR
 
4425
Memo for record; a cover sheet style
 
4426
 
 
4427
@item .MF
 
4428
Memo for file; a cover sheet style
 
4429
 
 
4430
@item .EG
 
4431
Engineer's notes; a cover sheet style
 
4432
 
 
4433
@item .TR
 
4434
Computing Science Tech Report; a cover sheet style
 
4435
 
 
4436
@item .OK
 
4437
Other keywords
 
4438
 
 
4439
@item .CS
 
4440
Cover sheet information
 
4441
 
 
4442
@item .MH
 
4443
A cover sheet macro
 
4444
@end table
 
4445
 
 
4446
@c ---------------------------------------------------------------------
 
4447
 
 
4448
@node Additional ms Macros,  , Missing ms Macros, Differences from AT&T ms
 
4449
@subsubsection @code{groff} macros not appearing in @acronym{AT&T} @code{troff}
 
4450
 
 
4451
The @code{groff -ms} macros have a few minor extensions compared to the
 
4452
@acronym{AT&T} @code{troff -ms} macros.
 
4453
 
 
4454
@Defmac {AM, , ms}
 
4455
Improved accent marks.  @xref{ms Strings and Special Characters}, for
 
4456
details.
 
4457
@endDefmac
 
4458
 
 
4459
@Defmac {DS, @t{I}, ms}
 
4460
Indented display.  The default behavior of @acronym{AT&T} @code{troff
 
4461
-ms} was to indent; the @code{groff} default prints displays flush left
 
4462
with the body text.
 
4463
@endDefmac
 
4464
 
 
4465
@Defmac {CW, , ms}
 
4466
Print text in @code{constant width} (Courier) font.
 
4467
@endDefmac
 
4468
 
 
4469
@Defmac {IX, , ms}
 
4470
Indexing term (printed on standard error).  You can write a script to
 
4471
capture and process an index generated in this manner.
 
4472
@endDefmac
 
4473
 
 
4474
The following additional number registers
 
4475
appear in @code{groff -ms}:
 
4476
 
 
4477
@Defmpreg {MINGW, ms}
 
4478
Specifies a minimum space between columns (for multi-column output);
 
4479
this takes the place of the @code{GW} register that was documented but
 
4480
apparently not implemented in @acronym{AT&T} @code{troff}.
 
4481
@endDefmpreg
 
4482
 
 
4483
Several new string registers are available as well.  You can change
 
4484
these to handle (for example) the local language.  @xref{ms Strings and
 
4485
Special Characters}, for details.
 
4486
 
 
4487
@c ---------------------------------------------------------------------
 
4488
 
 
4489
@node Naming Conventions,  , Differences from AT&T ms, ms
 
4490
@subsection Naming Conventions
 
4491
@cindex @code{ms} macros, naming conventions
 
4492
@cindex naming conventions, @code{ms} macros
 
4493
 
 
4494
The following conventions are used for names of macros, strings and
 
4495
number registers.  External names available to documents that use the
 
4496
@code{groff -ms} macros contain only uppercase letters and digits.
 
4497
 
 
4498
Internally the macros are divided into modules; naming conventions are
 
4499
as follows:
 
4500
 
 
4501
@itemize @bullet
 
4502
@item
 
4503
Names used only within one module are of the form
 
4504
@var{module}@code{*}@var{name}.
 
4505
 
 
4506
@item
 
4507
Names used outside the module in which they are defined are of the form
 
4508
@var{module}@code{@@}@var{name}.
 
4509
 
 
4510
@item
 
4511
Names associated with a particular environment are of the form
 
4512
@var{environment}@code{:}@var{name}; these are used only within the
 
4513
@code{par} module.
 
4514
 
 
4515
@item
 
4516
@var{name} does not have a module prefix.
 
4517
 
 
4518
@item
 
4519
Constructed names used to implement arrays are of the form
 
4520
@var{array}@code{!}@var{index}.
 
4521
@end itemize
 
4522
 
 
4523
Thus the groff ms macros reserve the following names:
 
4524
 
 
4525
@itemize @bullet
 
4526
@item
 
4527
Names containing the characters @code{*}, @code{@@}, and@tie{}@code{:}.
 
4528
 
 
4529
@item
 
4530
Names containing only uppercase letters and digits.
 
4531
@end itemize
 
4532
 
 
4533
 
 
4534
@c =====================================================================
 
4535
 
 
4536
@node me, mm, ms, Macro Packages
 
4537
@section @file{me}
 
4538
@cindex @code{me} macro package
 
4539
 
 
4540
@c XXX documentation
 
4541
@c XXX this is a placeholder until we get stuff knocked into shape
 
4542
See the @file{meintro.me} and @file{meref.me} documents in groff's
 
4543
@file{doc} directory.
 
4544
 
 
4545
 
 
4546
@c =====================================================================
 
4547
 
 
4548
@node mm, mom, me, Macro Packages
 
4549
@section @file{mm}
 
4550
@cindex @code{mm} macro package
 
4551
 
 
4552
@c XXX documentation
 
4553
@c XXX this is a placeholder until we get stuff knocked into shape
 
4554
See the @cite{groff_mm(7)} man page (type @command{man groff_mm} at the
 
4555
command line).
 
4556
 
 
4557
 
 
4558
@c =====================================================================
 
4559
 
 
4560
@node mom,  , mm, Macro Packages
 
4561
@section @file{mom}
 
4562
@cindex @code{mom} macro package
 
4563
 
 
4564
@c XXX documentation
 
4565
@c XXX this is a placeholder until we get stuff knocked into shape
 
4566
See the @cite{groff_mom(7)} man page (type @command{man groff_mom} at
 
4567
the command line), which gives a short overview and a link to its
 
4568
extensive documentation in HTML format.
 
4569
 
 
4570
 
 
4571
 
 
4572
@c =====================================================================
 
4573
@c =====================================================================
 
4574
 
 
4575
@node gtroff Reference, Preprocessors, Macro Packages, Top
 
4576
@chapter @code{gtroff} Reference
 
4577
@cindex reference, @code{gtroff}
 
4578
@cindex @code{gtroff}, reference
 
4579
 
 
4580
This chapter covers @strong{all} of the facilities of @code{gtroff}.
 
4581
Users of macro packages may skip it if not interested in details.
 
4582
 
 
4583
 
 
4584
@menu
 
4585
* Text::
 
4586
* Measurements::
 
4587
* Expressions::
 
4588
* Identifiers::
 
4589
* Embedded Commands::
 
4590
* Registers::
 
4591
* Manipulating Filling and Adjusting::
 
4592
* Manipulating Hyphenation::
 
4593
* Manipulating Spacing::
 
4594
* Tabs and Fields::
 
4595
* Character Translations::
 
4596
* Troff and Nroff Mode::
 
4597
* Line Layout::
 
4598
* Line Control::
 
4599
* Page Layout::
 
4600
* Page Control::
 
4601
* Fonts and Symbols::
 
4602
* Sizes::
 
4603
* Strings::
 
4604
* Conditionals and Loops::
 
4605
* Writing Macros::
 
4606
* Page Motions::
 
4607
* Drawing Requests::
 
4608
* Traps::
 
4609
* Diversions::
 
4610
* Environments::
 
4611
* Suppressing output::
 
4612
* Colors::
 
4613
* I/O::
 
4614
* Postprocessor Access::
 
4615
* Miscellaneous::
 
4616
* Gtroff Internals::
 
4617
* Debugging::
 
4618
* Implementation Differences::
 
4619
@end menu
 
4620
 
 
4621
 
 
4622
@c =====================================================================
 
4623
 
 
4624
@node Text, Measurements, gtroff Reference, gtroff Reference
 
4625
@section Text
 
4626
@cindex text, @code{gtroff} processing
 
4627
 
 
4628
@code{gtroff} input files contain text with control commands
 
4629
interspersed throughout.  But, even without control codes, @code{gtroff}
 
4630
still does several things with the input text:
 
4631
 
 
4632
@itemize @bullet
 
4633
@item
 
4634
filling and adjusting
 
4635
 
 
4636
@item
 
4637
adding additional space after sentences
 
4638
 
 
4639
@item
 
4640
hyphenating
 
4641
 
 
4642
@item
 
4643
inserting implicit line breaks
 
4644
@end itemize
 
4645
 
 
4646
@menu
 
4647
* Filling and Adjusting::
 
4648
* Hyphenation::
 
4649
* Sentences::
 
4650
* Tab Stops::
 
4651
* Implicit Line Breaks::
 
4652
* Input Conventions::
 
4653
* Input Encodings::
 
4654
@end menu
 
4655
 
 
4656
@c ---------------------------------------------------------------------
 
4657
 
 
4658
@node Filling and Adjusting, Hyphenation, Text, Text
 
4659
@subsection Filling and Adjusting
 
4660
@cindex filling
 
4661
@cindex adjusting
 
4662
 
 
4663
When @code{gtroff} reads text, it collects words from the input and fits
 
4664
as many of them together on one output line as it can.  This is known as
 
4665
@dfn{filling}.
 
4666
 
 
4667
@cindex leading spaces
 
4668
@cindex spaces, leading and trailing
 
4669
@cindex extra spaces
 
4670
@cindex trailing spaces
 
4671
Once @code{gtroff} has a @dfn{filled} line, it tries to @dfn{adjust} it.
 
4672
This means it widens the spacing between words until the text reaches
 
4673
the right margin (in the default adjustment mode).  Extra spaces between
 
4674
words are preserved, but spaces at the end of lines are ignored.  Spaces
 
4675
at the front of a line cause a @dfn{break} (breaks are explained in
 
4676
@ref{Implicit Line Breaks}).
 
4677
 
 
4678
@xref{Manipulating Filling and Adjusting}.
 
4679
 
 
4680
@c ---------------------------------------------------------------------
 
4681
 
 
4682
@node Hyphenation, Sentences, Filling and Adjusting, Text
 
4683
@subsection Hyphenation
 
4684
@cindex hyphenation
 
4685
 
 
4686
Since the odds are not great for finding a set of words, for every
 
4687
output line, which fit nicely on a line without inserting excessive
 
4688
amounts of space between words, @code{gtroff} hyphenates words so that
 
4689
it can justify lines without inserting too much space between words.  It
 
4690
uses an internal hyphenation algorithm (a simplified version of the
 
4691
algorithm used within @TeX{}) to indicate which words can be hyphenated
 
4692
and how to do so.  When a word is hyphenated, the first part of the word
 
4693
is added to the current filled line being output (with an attached
 
4694
hyphen), and the other portion is added to the next line to be filled.
 
4695
 
 
4696
@xref{Manipulating Hyphenation}.
 
4697
 
 
4698
@c ---------------------------------------------------------------------
 
4699
 
 
4700
@node Sentences, Tab Stops, Hyphenation, Text
 
4701
@subsection Sentences
 
4702
@cindex sentences
 
4703
 
 
4704
Although it is often debated, some typesetting rules say there should be
 
4705
different amounts of space after various punctuation marks.  For
 
4706
example, the @cite{Chicago typsetting manual} says that a period at the
 
4707
end of a sentence should have twice as much space following it as would
 
4708
a comma or a period as part of an abbreviation.
 
4709
 
 
4710
@c XXX exact citation of Chicago manual
 
4711
 
 
4712
@cindex sentence space
 
4713
@cindex space between sentences
 
4714
@cindex french-spacing
 
4715
@code{gtroff} does this by flagging certain characters (normally
 
4716
@samp{!}, @samp{?}, and @samp{.}) as @dfn{end-of-sentence} characters.
 
4717
When @code{gtroff} encounters one of these characters at the end of a
 
4718
line, it appends a normal space followed by a @dfn{sentence space} in
 
4719
the formatted output.  (This justifies one of the conventions mentioned
 
4720
in @ref{Input Conventions}.)
 
4721
 
 
4722
@cindex transparent characters
 
4723
@cindex character, transparent
 
4724
@cindex @code{dg} glyph, at end of sentence
 
4725
@cindex @code{rq} glyph, at end of sentence
 
4726
@cindex @code{"}, at end of sentence
 
4727
@cindex @code{'}, at end of sentence
 
4728
@cindex @code{)}, at end of sentence
 
4729
@cindex @code{]}, at end of sentence
 
4730
@cindex @code{*}, at end of sentence
 
4731
In addition, the following characters and symbols are treated
 
4732
transparently while handling end-of-sentence characters: @samp{"},
 
4733
@samp{'}, @samp{)}, @samp{]}, @samp{*}, @code{\[dg]}, and @code{\[rq]}.
 
4734
 
 
4735
See the @code{cflags} request in @ref{Using Symbols}, for more details.
 
4736
 
 
4737
@cindex @code{\&}, at end of sentence
 
4738
To prevent the insertion of extra space after an end-of-sentence
 
4739
character (at the end of a line), append @code{\&}.
 
4740
 
 
4741
@c ---------------------------------------------------------------------
 
4742
 
 
4743
@node Tab Stops, Implicit Line Breaks, Sentences, Text
 
4744
@subsection Tab Stops
 
4745
@cindex tab stops
 
4746
@cindex stops, tabulator
 
4747
@cindex tab character
 
4748
@cindex character, tabulator
 
4749
 
 
4750
@cindex @acronym{EBCDIC} encoding
 
4751
@cindex encoding, @acronym{EBCDIC}
 
4752
@code{gtroff} translates @dfn{tabulator characters}, also called
 
4753
@dfn{tabs} (normally code point @acronym{ASCII} @code{0x09} or
 
4754
@acronym{EBCDIC} @code{0x05}), in the input into movements to the next
 
4755
tabulator stop.  These tab stops are initially located every half inch
 
4756
across the page.  Using this, simple tables can be made easily.
 
4757
However, it can often be deceptive as the appearance (and width) of the
 
4758
text on a terminal and the results from @code{gtroff} can vary greatly.
 
4759
 
 
4760
Also, a possible sticking point is that lines beginning with tab
 
4761
characters are still filled, again producing unexpected results.  For
 
4762
example, the following input
 
4763
 
 
4764
@multitable {12345678} {12345678} {12345678} {12345678}
 
4765
@item
 
4766
@tab 1 @tab 2 @tab 3
 
4767
@item
 
4768
@tab   @tab 4 @tab 5
 
4769
@end multitable
 
4770
 
 
4771
@noindent
 
4772
produces
 
4773
 
 
4774
@multitable {12345678} {12345678} {12345678} {12345678} {12345678} {12345678} {12345678}
 
4775
@item
 
4776
@tab 1 @tab 2 @tab 3 @tab   @tab 4 @tab 5
 
4777
@end multitable
 
4778
 
 
4779
@xref{Tabs and Fields}.
 
4780
 
 
4781
@c ---------------------------------------------------------------------
 
4782
 
 
4783
@node Implicit Line Breaks, Input Conventions, Tab Stops, Text
 
4784
@subsection Implicit Line Breaks
 
4785
@cindex implicit line breaks
 
4786
@cindex implicit breaks of lines
 
4787
@cindex line, implicit breaks
 
4788
@cindex break, implicit
 
4789
@cindex line break
 
4790
 
 
4791
An important concept in @code{gtroff} is the @dfn{break}.  When a break
 
4792
occurs, @code{gtroff} outputs the partially filled line (unjustified),
 
4793
and resumes collecting and filling text on the next output line.
 
4794
 
 
4795
@cindex blank line
 
4796
@cindex empty line
 
4797
@cindex line, blank
 
4798
@cindex blank line macro (@code{blm})
 
4799
There are several ways to cause a break in @code{gtroff}.  A blank line
 
4800
not only causes a break, but it also outputs a one-line vertical space
 
4801
(effectively a blank line).  Note that this behaviour can be modified
 
4802
with the blank line macro request @code{blm}.  @xref{Blank Line Traps}.
 
4803
 
 
4804
@cindex fill mode
 
4805
@cindex mode, fill
 
4806
@cindex leading spaces macro (@code{lsm})
 
4807
A line that begins with a space causes a break and the space is output
 
4808
at the beginning of the next line.  Note that this space isn't adjusted,
 
4809
even in fill mode; however, the behaviour can be modified with the
 
4810
leading spaces macro request @code{lsm}.  @xref{Leading Spaces Traps}.
 
4811
 
 
4812
The end of file also causes a break -- otherwise the last line of the
 
4813
document may vanish!
 
4814
 
 
4815
Certain requests also cause breaks, implicitly or explicitly.  This is
 
4816
discussed in @ref{Manipulating Filling and Adjusting}.
 
4817
 
 
4818
@c ---------------------------------------------------------------------
 
4819
 
 
4820
@node Input Conventions, Input Encodings, Implicit Line Breaks, Text
 
4821
@subsection Input Conventions
 
4822
@cindex input conventions
 
4823
@cindex conventions for input
 
4824
 
 
4825
Since @code{gtroff} does filling automatically, it is traditional in
 
4826
@code{groff} not to try and type things in as nicely formatted
 
4827
paragraphs.  These are some conventions commonly used when typing
 
4828
@code{gtroff} text:
 
4829
 
 
4830
@itemize @bullet
 
4831
@item
 
4832
Break lines after punctuation, particularly at the end of a sentence and
 
4833
in other logical places.  Keep separate phrases on lines by themselves,
 
4834
as entire phrases are often added or deleted when editing.
 
4835
 
 
4836
@item
 
4837
Try to keep lines less than 40-60@tie{}characters, to allow space for
 
4838
inserting more text.
 
4839
 
 
4840
@item
 
4841
Do not try to do any formatting in a @acronym{WYSIWYG} manner (i.e.,
 
4842
don't try using spaces to get proper indentation).
 
4843
@end itemize
 
4844
 
 
4845
@c ---------------------------------------------------------------------
 
4846
 
 
4847
@node Input Encodings,  , Input Conventions, Text
 
4848
@subsection Input Encodings
 
4849
 
 
4850
Currently, the following input encodings are available.
 
4851
 
 
4852
@table @asis
 
4853
@item cp1047
 
4854
@cindex encoding, input, @acronym{EBCDIC}
 
4855
@cindex @acronym{EBCDIC}, input encoding
 
4856
@cindex input encoding, @acronym{EBCDIC}
 
4857
@cindex encoding, input, cp1047
 
4858
@cindex cp1047, input encoding
 
4859
@cindex input encoding, cp1047
 
4860
@cindex IBM cp1047 input encoding
 
4861
@pindex cp1047.tmac
 
4862
This input encoding works only on @acronym{EBCDIC} platforms (and vice
 
4863
versa, the other input encodings don't work with @acronym{EBCDIC}); the
 
4864
file @file{cp1047.tmac} is by default loaded at start-up.
 
4865
 
 
4866
@item latin-1
 
4867
@cindex encoding, input, @w{latin-1} (ISO @w{8859-1})
 
4868
@cindex @w{latin-1} (ISO @w{8859-1}), input encoding
 
4869
@cindex ISO @w{8859-1} (@w{latin-1}), input encoding
 
4870
@cindex input encoding, @w{latin-1} (ISO @w{8859-1})
 
4871
@pindex latin1.tmac
 
4872
This is the default input encoding on non-@acronym{EBCDIC} platforms;
 
4873
the file @file{latin1.tmac} is loaded at start-up.
 
4874
 
 
4875
@item latin-2
 
4876
@cindex encoding, input, @w{latin-2} (ISO @w{8859-2})
 
4877
@cindex @w{latin-2} (ISO @w{8859-2}), input encoding
 
4878
@cindex ISO @w{8859-2} (@w{latin-2}), input encoding
 
4879
@cindex input encoding, @w{latin-2} (ISO @w{8859-2})
 
4880
@pindex latin2.tmac
 
4881
To use this encoding, either say @w{@samp{.mso latin2.tmac}} at the very
 
4882
beginning of your document or use @samp{-mlatin2} as a command line
 
4883
argument for @code{groff}.
 
4884
 
 
4885
@item latin-5
 
4886
@cindex encoding, input, @w{latin-5} (ISO @w{8859-9})
 
4887
@cindex @w{latin-2} (ISO @w{8859-9}), input encoding
 
4888
@cindex ISO @w{8859-9} (@w{latin-2}), input encoding
 
4889
@cindex input encoding, @w{latin-2} (ISO @w{8859-9})
 
4890
@pindex latin2.tmac
 
4891
For Turkish.  Either say @w{@samp{.mso latin9.tmac}} at the very
 
4892
beginning of your document or use @samp{-mlatin9} as a command line
 
4893
argument for @code{groff}.
 
4894
 
 
4895
@item latin-9 (latin-0)
 
4896
@cindex encoding, input, @w{latin-9} (@w{latin-0}, ISO @w{8859-15})
 
4897
@cindex @w{latin-9} (@w{latin-0}, ISO @w{8859-15}), input encoding
 
4898
@cindex ISO @w{8859-15} (@w{latin-9}, @w{latin-0}), input encoding
 
4899
@cindex input encoding, @w{latin-9} (@w{latin-9}, ISO @w{8859-15})
 
4900
@pindex latin9.tmac
 
4901
This encoding is intended (at least in Europe) to replace @w{latin-1}
 
4902
encoding.  The main difference to @w{latin-1} is that @w{latin-9}
 
4903
contains the Euro character.  To use this encoding, either say
 
4904
@w{@samp{.mso latin9.tmac}} at the very beginning of your document or
 
4905
use @samp{-mlatin9} as a command line argument for @code{groff}.
 
4906
@end table
 
4907
 
 
4908
Note that it can happen that some input encoding characters are not
 
4909
available for a particular output device.  For example, saying
 
4910
 
 
4911
@Example
 
4912
groff -Tlatin1 -mlatin9 ...
 
4913
@endExample
 
4914
 
 
4915
@noindent
 
4916
fails if you use the Euro character in the input.  Usually, this
 
4917
limitation is present only for devices which have a limited set of
 
4918
output glyphs (e.g.@: @option{-Tascii} and @option{-Tlatin1}); for other
 
4919
devices it is usually sufficient to install proper fonts which contain
 
4920
the necessary glyphs.
 
4921
 
 
4922
@pindex freeeuro.pfa
 
4923
@pindex ec.tmac
 
4924
Due to the importance of the Euro glyph in Europe, the groff package now
 
4925
comes with a @sc{PostScript} font called @file{freeeuro.pfa} which
 
4926
provides various glyph shapes for the Euro.  In other words,
 
4927
@w{latin-9} encoding is supported for the @option{-Tps} device out of
 
4928
the box (@w{latin-2} isn't).
 
4929
 
 
4930
By its very nature, @option{-Tutf8} supports all input encodings;
 
4931
@option{-Tdvi} has support for both @w{latin-2} and @w{latin-9} if the
 
4932
command line @option{-mec} is used also to load the file @file{ec.tmac}
 
4933
(which flips to the EC fonts).
 
4934
 
 
4935
 
 
4936
@c =====================================================================
 
4937
 
 
4938
@node Measurements, Expressions, Text, gtroff Reference
 
4939
@section Measurements
 
4940
@cindex measurements
 
4941
@cindex scaling indicator
 
4942
@cindex indicator, scaling
 
4943
 
 
4944
@cindex units of measurement
 
4945
@cindex basic unit (@code{u})
 
4946
@cindex machine unit (@code{u})
 
4947
@cindex measurement unit
 
4948
@cindex @code{u} unit
 
4949
@cindex unit, @code{u}
 
4950
@code{gtroff} (like many other programs) requires numeric parameters to
 
4951
specify various measurements.  Most numeric parameters@footnote{those
 
4952
that specify vertical or horizontal motion or a type size} may have a
 
4953
@dfn{measurement unit} attached.  These units are specified as a single
 
4954
character which immediately follows the number or expression.  Each of
 
4955
these units are understood, by @code{gtroff}, to be a multiple of its
 
4956
@dfn{basic unit}.  So, whenever a different measurement unit is
 
4957
specified @code{gtroff} converts this into its @dfn{basic units}.  This
 
4958
basic unit, represented by a @samp{u}, is a device dependent measurement
 
4959
which is quite small, ranging from 1/75@dmn{th} to 1/72000@dmn{th} of an
 
4960
inch.  The values may be given as fractional numbers; however,
 
4961
fractional basic units are always rounded to integers.
 
4962
 
 
4963
Some of the measurement units are completely independent of any of the
 
4964
current settings (e.g.@: type size) of @code{gtroff}.
 
4965
 
 
4966
@table @code
 
4967
@item i
 
4968
@cindex inch unit (@code{i})
 
4969
@cindex @code{i} unit
 
4970
@cindex unit, @code{i}
 
4971
Inches.  An antiquated measurement unit still in use in certain
 
4972
backwards countries with incredibly low-cost computer equipment.  One
 
4973
inch is equal to@tie{}2.54@dmn{cm}.
 
4974
 
 
4975
@item c
 
4976
@cindex centimeter unit (@code{c})
 
4977
@cindex @code{c} unit
 
4978
@cindex unit, @code{c}
 
4979
Centimeters.  One centimeter is equal to@tie{}0.3937@dmn{in}.
 
4980
 
 
4981
@item p
 
4982
@cindex point unit (@code{p})
 
4983
@cindex @code{p} unit
 
4984
@cindex unit, @code{p}
 
4985
Points.  This is a typesetter's measurement used for measure type size.
 
4986
It is 72@tie{}points to an inch.
 
4987
 
 
4988
@item P
 
4989
@cindex pica unit (@code{P})
 
4990
@cindex @code{P} unit
 
4991
@cindex unit, @code{P}
 
4992
Pica.  Another typesetting measurement.  6@tie{}Picas to an inch (and
 
4993
12@tie{}points to a pica).
 
4994
 
 
4995
@item s
 
4996
@itemx z
 
4997
@cindex @code{s} unit
 
4998
@cindex unit, @code{s}
 
4999
@cindex @code{z} unit
 
5000
@cindex unit, @code{z}
 
5001
@xref{Fractional Type Sizes}, for a discussion of these units.
 
5002
 
 
5003
@item f
 
5004
@cindex @code{f} unit
 
5005
@cindex unit, @code{f}
 
5006
Fractions.  Value is 65536.
 
5007
@xref{Colors}, for usage.
 
5008
@end table
 
5009
 
 
5010
The other measurements understood by @code{gtroff} depend on settings
 
5011
currently in effect in @code{gtroff}.  These are very useful for
 
5012
specifying measurements which should look proper with any size of text.
 
5013
 
 
5014
@table @code
 
5015
@item m
 
5016
@cindex em unit (@code{m})
 
5017
@cindex @code{m} unit
 
5018
@cindex unit, @code{m}
 
5019
Ems.  This unit is equal to the current font size in points.  So called
 
5020
because it is @emph{approximately} the width of the letter@tie{}@samp{m}
 
5021
in the current font.
 
5022
 
 
5023
@item n
 
5024
@cindex en unit (@code{n})
 
5025
@cindex @code{n} unit
 
5026
@cindex unit, @code{n}
 
5027
Ens.  In @code{groff}, this is half of an em.
 
5028
 
 
5029
@item v
 
5030
@cindex vertical space unit (@code{v})
 
5031
@cindex space, vertical, unit (@code{v})
 
5032
@cindex @code{v} unit
 
5033
@cindex unit, @code{v}
 
5034
Vertical space.  This is equivalent to the current line spacing.
 
5035
@xref{Sizes}, for more information about this.
 
5036
 
 
5037
@item M
 
5038
@cindex @code{M} unit
 
5039
@cindex unit, @code{M}
 
5040
100ths of an em.
 
5041
@end table
 
5042
 
 
5043
@menu
 
5044
* Default Units::
 
5045
@end menu
 
5046
 
 
5047
@c ---------------------------------------------------------------------
 
5048
 
 
5049
@node Default Units,  , Measurements, Measurements
 
5050
@subsection Default Units
 
5051
@cindex default units
 
5052
@cindex units, default
 
5053
 
 
5054
Many requests take a default unit.  While this can be helpful at times,
 
5055
it can cause strange errors in some expressions.  For example, the line
 
5056
length request expects em units.  Here are several attempts to get a
 
5057
line length of 3.5@tie{}inches and their results:
 
5058
 
 
5059
@Example
 
5060
3.5i      @result{}   3.5i
 
5061
7/2       @result{}   0i
 
5062
7/2i      @result{}   0i
 
5063
(7 / 2)u  @result{}   0i
 
5064
7i/2      @result{}   0.1i
 
5065
7i/2u     @result{}   3.5i
 
5066
@endExample
 
5067
 
 
5068
@noindent
 
5069
Everything is converted to basic units first.  In the above example it
 
5070
is assumed that 1@dmn{i} equals@tie{}240@dmn{u}, and 1@dmn{m}
 
5071
equals@tie{}10@dmn{p} (thus 1@dmn{m} equals@tie{}33@dmn{u}).  The value
 
5072
7@dmn{i}/2 is first handled as 7@dmn{i}/2@dmn{m}, then converted to
 
5073
1680@dmn{u}/66@dmn{u} which is 25@dmn{u}, and this is approximately
 
5074
0.1@dmn{i}.  As can be seen, a scaling indicator after a closing
 
5075
parenthesis is simply ignored.
 
5076
 
 
5077
@cindex measurements, specifying safely
 
5078
Thus, the safest way to specify measurements is to always attach a
 
5079
scaling indicator.  If you want to multiply or divide by a certain
 
5080
scalar value, use @samp{u} as the unit for that value.
 
5081
 
 
5082
 
 
5083
@c =====================================================================
 
5084
 
 
5085
@node Expressions, Identifiers, Measurements, gtroff Reference
 
5086
@section Expressions
 
5087
@cindex expressions
 
5088
 
 
5089
@code{gtroff} has most arithmetic operators common to other languages:
 
5090
 
 
5091
@itemize @bullet
 
5092
@item
 
5093
@cindex arithmetic operators
 
5094
@cindex operators, arithmetic
 
5095
@opindex +
 
5096
@opindex -
 
5097
@opindex /
 
5098
@opindex *
 
5099
@opindex %
 
5100
Arithmetic: @samp{+} (addition), @samp{-} (subtraction), @samp{/}
 
5101
(division), @samp{*} (multiplication), @samp{%} (modulo).
 
5102
 
 
5103
@code{gtroff} only provides integer arithmetic.  The internal type used
 
5104
for computing results is @samp{int}, which is usually a 32@dmn{bit}
 
5105
signed integer.
 
5106
 
 
5107
@item
 
5108
@cindex comparison operators
 
5109
@cindex operators, comparison
 
5110
@opindex <
 
5111
@opindex >
 
5112
@opindex >=
 
5113
@opindex <=
 
5114
@opindex =
 
5115
@opindex ==
 
5116
Comparison: @samp{<} (less than), @samp{>} (greater than), @samp{<=}
 
5117
(less than or equal), @samp{>=} (greater than or equal), @samp{=}
 
5118
(equal), @samp{==} (the same as @samp{=}).
 
5119
 
 
5120
@item
 
5121
@cindex logical operators
 
5122
@cindex operators, logical
 
5123
@opindex &
 
5124
@ifnotinfo
 
5125
@opindex :
 
5126
@end ifnotinfo
 
5127
@ifinfo
 
5128
@opindex @r{<colon>}
 
5129
@end ifinfo
 
5130
Logical: @samp{&} (logical and), @samp{:} (logical or).
 
5131
 
 
5132
@item
 
5133
@cindex unary operators
 
5134
@cindex operators, unary
 
5135
@opindex -
 
5136
@opindex +
 
5137
@opindex !
 
5138
@cindex @code{if} request, and the @samp{!} operator
 
5139
@cindex @code{while} request, and the @samp{!} operator
 
5140
Unary operators: @samp{-} (negating, i.e.@: changing the sign), @samp{+}
 
5141
(just for completeness; does nothing in expressions), @samp{!} (logical
 
5142
not; this works only within @code{if} and @code{while}
 
5143
requests).@footnote{Note that, for example, @samp{!(-1)} evaluates to
 
5144
`true' because @code{gtroff} treats both negative numbers and zero as
 
5145
`false'.}  See below for the use of unary operators in motion requests.
 
5146
 
 
5147
@cindex logical not, limitation in expression
 
5148
@cindex expression, limitation of logical not in
 
5149
The logical not operator,
 
5150
as described above,
 
5151
works only within @code{if} and @code{while} requests.
 
5152
Furthermore, it may appear
 
5153
only at the beginning of an expression,
 
5154
and negates the entire expression.
 
5155
Attempting to insert the @samp{!} operator
 
5156
within the expression results in a
 
5157
@samp{numeric expression expected} warning.  This
 
5158
maintains compatibility
 
5159
with old versions of @code{troff}.
 
5160
 
 
5161
Example:
 
5162
 
 
5163
@Example
 
5164
.nr X 1
 
5165
.nr Y 0
 
5166
.\" This does not work as expected
 
5167
.if (\n[X])&(!\n[Y]) .nop X only
 
5168
.
 
5169
.\" Use this construct instead
 
5170
.if (\n[X]=1)&(\n[Y]=0) .nop X only
 
5171
@endExample
 
5172
 
 
5173
@item
 
5174
@cindex extremum operators (@code{>?}, @code{<?})
 
5175
@cindex operators, extremum (@code{>?}, @code{<?})
 
5176
@opindex >?
 
5177
@opindex <?
 
5178
Extrema: @samp{>?} (maximum), @samp{<?} (minimum).
 
5179
 
 
5180
Example:
 
5181
 
 
5182
@Example
 
5183
.nr x 5
 
5184
.nr y 3
 
5185
.nr z (\n[x] >? \n[y])
 
5186
@endExample
 
5187
 
 
5188
@noindent
 
5189
The register@tie{}@code{z} now contains@tie{}5.
 
5190
 
 
5191
@item
 
5192
@cindex scaling operator
 
5193
@cindex operator, scaling
 
5194
Scaling: @code{(@var{c};@var{e})}.  Evaluate@tie{}@var{e}
 
5195
using@tie{}@var{c} as the default scaling indicator.  If @var{c} is
 
5196
missing, ignore scaling indicators in the evaluation of@tie{}@var{e}.
 
5197
@end itemize
 
5198
 
 
5199
@cindex parentheses
 
5200
@cindex order of evaluation in expressions
 
5201
@cindex expression, order of evaluation
 
5202
@opindex (
 
5203
@opindex )
 
5204
Parentheses may be used as in any other language.  However, in
 
5205
@code{gtroff} they are necessary to ensure order of evaluation.
 
5206
@code{gtroff} has no operator precedence; expressions are evaluated left
 
5207
to right.  This means that @code{gtroff} evaluates @samp{3+5*4} as if it
 
5208
were parenthesized like @samp{(3+5)*4}, not as @samp{3+(5*4)}, as might
 
5209
be expected.
 
5210
 
 
5211
@cindex @code{+}, and page motion
 
5212
@cindex @code{-}, and page motion
 
5213
@cindex motion operators
 
5214
@cindex operators, motion
 
5215
For many requests which cause a motion on the page, the unary operators
 
5216
@samp{+} and @samp{-} work differently if leading an expression.  They
 
5217
then indicate a motion relative to the current position (down or up,
 
5218
respectively).
 
5219
 
 
5220
@cindex @code{|}, and page motion
 
5221
@cindex absolute position operator (@code{|})
 
5222
@cindex position, absolute, operator (@code{|})
 
5223
Similarly, a leading @samp{|} operator indicates an absolute position.
 
5224
For vertical movements, it specifies the distance from the top of the
 
5225
page; for horizontal movements, it gives the distance from the beginning
 
5226
of the @emph{input} line.
 
5227
 
 
5228
@cindex @code{bp} request, using @code{+} and@tie{}@code{-}
 
5229
@cindex @code{in} request, using @code{+} and@tie{}@code{-}
 
5230
@cindex @code{ll} request, using @code{+} and@tie{}@code{-}
 
5231
@cindex @code{lt} request, using @code{+} and@tie{}@code{-}
 
5232
@cindex @code{nm} request, using @code{+} and@tie{}@code{-}
 
5233
@cindex @code{nr} request, using @code{+} and@tie{}@code{-}
 
5234
@cindex @code{pl} request, using @code{+} and@tie{}@code{-}
 
5235
@cindex @code{pn} request, using @code{+} and@tie{}@code{-}
 
5236
@cindex @code{po} request, using @code{+} and@tie{}@code{-}
 
5237
@cindex @code{ps} request, using @code{+} and@tie{}@code{-}
 
5238
@cindex @code{pvs} request, using @code{+} and@tie{}@code{-}
 
5239
@cindex @code{rt} request, using @code{+} and@tie{}@code{-}
 
5240
@cindex @code{ti} request, using @code{+} and@tie{}@code{-}
 
5241
@cindex @code{\H}, using @code{+} and@tie{}@code{-}
 
5242
@cindex @code{\R}, using @code{+} and@tie{}@code{-}
 
5243
@cindex @code{\s}, using @code{+} and@tie{}@code{-}
 
5244
@samp{+} and @samp{-} are also treated differently by the following
 
5245
requests and escapes: @code{bp}, @code{in}, @code{ll}, @code{lt},
 
5246
@code{nm}, @code{nr}, @code{pl}, @code{pn}, @code{po}, @code{ps},
 
5247
@code{pvs}, @code{rt}, @code{ti}, @code{\H}, @code{\R}, and @code{\s}.
 
5248
Here, leading plus and minus signs indicate increments and decrements.
 
5249
 
 
5250
@xref{Setting Registers}, for some examples.
 
5251
 
 
5252
@Defesc {\\B, ', anything, '}
 
5253
@cindex numeric expression, valid
 
5254
@cindex valid numeric expression
 
5255
Return@tie{}1 if @var{anything} is a valid numeric expression; or@tie{}0
 
5256
if @var{anything} is empty or not a valid numeric expression.
 
5257
@endDefesc
 
5258
 
 
5259
@cindex space characters, in expressions
 
5260
@cindex expressions, and space characters
 
5261
Due to the way arguments are parsed, spaces are not allowed in
 
5262
expressions, unless the entire expression is surrounded by parentheses.
 
5263
 
 
5264
@xref{Request and Macro Arguments}, and @ref{Conditionals and Loops}.
 
5265
 
 
5266
 
 
5267
@c =====================================================================
 
5268
 
 
5269
@node Identifiers, Embedded Commands, Expressions, gtroff Reference
 
5270
@section Identifiers
 
5271
@cindex identifiers
 
5272
 
 
5273
Like any other language, @code{gtroff} has rules for properly formed
 
5274
@dfn{identifiers}.  In @code{gtroff}, an identifier can be made up of
 
5275
almost any printable character, with the exception of the following
 
5276
characters:
 
5277
 
 
5278
@itemize @bullet
 
5279
@item
 
5280
@cindex whitespace characters
 
5281
@cindex newline character
 
5282
@cindex character, whitespace
 
5283
Whitespace characters (spaces, tabs, and newlines).
 
5284
 
 
5285
@item
 
5286
@cindex character, backspace
 
5287
@cindex backspace character
 
5288
@cindex @acronym{EBCDIC} encoding of backspace
 
5289
Backspace (@acronym{ASCII}@tie{}@code{0x08} or
 
5290
@acronym{EBCDIC}@tie{}@code{0x16}) and character code @code{0x01}.
 
5291
 
 
5292
@item
 
5293
@cindex invalid input characters
 
5294
@cindex input characters, invalid
 
5295
@cindex characters, invalid input
 
5296
@cindex Unicode
 
5297
The following input characters are invalid and are ignored if
 
5298
@code{groff} runs on a machine based on @acronym{ASCII}, causing a
 
5299
warning message of type @samp{input} (see @ref{Debugging}, for more
 
5300
details): @code{0x00}, @code{0x0B}, @code{0x0D}-@code{0x1F},
 
5301
@code{0x80}-@code{0x9F}.
 
5302
 
 
5303
And here are the invalid input characters if @code{groff} runs on an
 
5304
@acronym{EBCDIC} host: @code{0x00}, @code{0x08}, @code{0x09},
 
5305
@code{0x0B}, @code{0x0D}-@code{0x14}, @code{0x17}-@code{0x1F},
 
5306
@code{0x30}-@code{0x3F}.
 
5307
 
 
5308
Currently, some of these reserved codepoints are used internally, thus
 
5309
making it non-trivial to extend @code{gtroff} to cover Unicode or other
 
5310
character sets and encodings which use characters of these ranges.
 
5311
 
 
5312
Note that invalid characters are removed before parsing; an identifier
 
5313
@code{foo}, followed by an invalid character, followed by @code{bar} is
 
5314
treated as @code{foobar}.
 
5315
@end itemize
 
5316
 
 
5317
For example, any of the following is valid.
 
5318
 
 
5319
@Example
 
5320
br
 
5321
PP
 
5322
(l
 
5323
end-list
 
5324
@@_
 
5325
@endExample
 
5326
 
 
5327
@cindex @code{]}, as part of an identifier
 
5328
@noindent
 
5329
Note that identifiers longer than two characters with a closing bracket
 
5330
(@samp{]}) in its name can't be accessed with escape sequences which
 
5331
expect an identifier as a parameter.  For example, @samp{\[foo]]}
 
5332
accesses the glyph @samp{foo}, followed by @samp{]}, whereas
 
5333
@samp{\C'foo]'} really asks for glyph @samp{foo]}.
 
5334
 
 
5335
@cindex @code{refer}, and macro names starting with @code{[} or @code{]}
 
5336
@cindex @code{[}, macro names starting with, and @code{refer}
 
5337
@cindex @code{]}, macro names starting with, and @code{refer}
 
5338
@cindex macro names, starting with @code{[} or @code{]}, and @code{refer}
 
5339
To avoid problems with the @code{refer} preprocessor, macro names should
 
5340
not start with @samp{[} or @samp{]}.  Due to backwards compatibility,
 
5341
everything after @samp{.[} and @samp{.]} is handled as a special
 
5342
argument to @code{refer}.  For example, @samp{.[foo} makes @code{refer}
 
5343
to start a reference, using @samp{foo} as a parameter.
 
5344
 
 
5345
@Defesc {\\A, ', ident, '}
 
5346
Test whether an identifier @var{ident} is valid in @code{gtroff}.  It
 
5347
expands to the character@tie{}1 or@tie{}0 according to whether its
 
5348
argument (usually delimited by quotes) is or is not acceptable as the
 
5349
name of a string, macro, diversion, number register, environment, or
 
5350
font.  It returns@tie{}0 if no argument is given.  This is useful for
 
5351
looking up user input in some sort of associative table.
 
5352
 
 
5353
@Example
 
5354
\A'end-list'
 
5355
    @result{} 1
 
5356
@endExample
 
5357
@endDefesc
 
5358
 
 
5359
@xref{Escapes}, for details on parameter delimiting characters.
 
5360
 
 
5361
Identifiers in @code{gtroff} can be any length, but, in some contexts,
 
5362
@code{gtroff} needs to be told where identifiers end and text begins
 
5363
(and in different ways depending on their length):
 
5364
 
 
5365
@itemize @bullet
 
5366
@item
 
5367
Single character.
 
5368
 
 
5369
@cindex @code{(}, starting a two-character identifier
 
5370
@item
 
5371
Two characters.  Must be prefixed with @samp{(} in some situations.
 
5372
 
 
5373
@cindex @code{[}, starting an identifier
 
5374
@cindex @code{]}, ending an identifier
 
5375
@item
 
5376
Arbitrary length (@code{gtroff} only).  Must be bracketed with @samp{[}
 
5377
and@tie{}@samp{]} in some situations.  Any length identifier can be put
 
5378
in brackets.
 
5379
@end itemize
 
5380
 
 
5381
@cindex undefined identifiers
 
5382
@cindex identifiers, undefined
 
5383
Unlike many other programming languages, undefined identifiers are
 
5384
silently ignored or expanded to nothing.  When @code{gtroff} finds an
 
5385
undefined identifier, it emits a warning, doing the following:
 
5386
 
 
5387
@itemize @bullet
 
5388
@item
 
5389
If the identifier is a string, macro, or diversion, @code{gtroff}
 
5390
defines it as empty.
 
5391
 
 
5392
@item
 
5393
If the identifier is a number register, @code{gtroff} defines it with a
 
5394
value of@tie{}0.
 
5395
@end itemize
 
5396
 
 
5397
@xref{Warnings}., @ref{Interpolating Registers}, and @ref{Strings}.
 
5398
 
 
5399
Note that macros, strings, and diversions share the same name space.
 
5400
 
 
5401
@Example
 
5402
.de xxx
 
5403
.  nop foo
 
5404
..
 
5405
.
 
5406
.di xxx
 
5407
bar
 
5408
.br
 
5409
.di
 
5410
.
 
5411
.xxx
 
5412
    @result{} bar
 
5413
@endExample
 
5414
 
 
5415
@noindent
 
5416
As can be seen in the previous example, @code{gtroff} reuses the
 
5417
identifier @samp{xxx}, changing it from a macro to a diversion.  No
 
5418
warning is emitted!  The contents of the first macro definition is lost.
 
5419
 
 
5420
@xref{Interpolating Registers}, and @ref{Strings}.
 
5421
 
 
5422
 
 
5423
@c =====================================================================
 
5424
 
 
5425
@node Embedded Commands, Registers, Identifiers, gtroff Reference
 
5426
@section Embedded Commands
 
5427
@cindex embedded commands
 
5428
@cindex commands, embedded
 
5429
 
 
5430
Most documents need more functionality beyond filling, adjusting and
 
5431
implicit line breaking.  In order to gain further functionality,
 
5432
@code{gtroff} allows commands to be embedded into the text, in two ways.
 
5433
 
 
5434
The first is a @dfn{request} which takes up an entire line, and does
 
5435
some large-scale operation (e.g.@: break lines, start new pages).
 
5436
 
 
5437
The other is an @dfn{escape} which can be usually embedded anywhere in
 
5438
the text; most requests can accept it even as an argument.  Escapes
 
5439
generally do more minor operations like sub- and superscripts, print a
 
5440
symbol, etc.
 
5441
 
 
5442
@menu
 
5443
* Requests::
 
5444
* Macros::
 
5445
* Escapes::
 
5446
@end menu
 
5447
 
 
5448
@c ---------------------------------------------------------------------
 
5449
 
 
5450
@node Requests, Macros, Embedded Commands, Embedded Commands
 
5451
@subsection Requests
 
5452
@cindex requests
 
5453
 
 
5454
@cindex control character (@code{.})
 
5455
@cindex character, control (@code{.})
 
5456
@cindex no-break control character (@code{'})
 
5457
@cindex character, no-break control (@code{'})
 
5458
@cindex control character, no-break (@code{'})
 
5459
A request line begins with a control character, which is either a single
 
5460
quote (@samp{'}, the @dfn{no-break control character}) or a period
 
5461
(@samp{.}, the normal @dfn{control character}).  These can be changed;
 
5462
see @ref{Character Translations}, for details.  After this there may be
 
5463
optional tabs or spaces followed by an identifier which is the name of
 
5464
the request.  This may be followed by any number of space-separated
 
5465
arguments (@emph{no} tabs here).
 
5466
 
 
5467
@cindex structuring source code of documents or macro packages
 
5468
@cindex documents, structuring the source code
 
5469
@cindex macro packages, structuring the source code
 
5470
Since a control character followed by whitespace only is ignored, it is
 
5471
common practice to use this feature for structuring the source code of
 
5472
documents or macro packages.
 
5473
 
 
5474
@Example
 
5475
.de foo
 
5476
.  tm This is foo.
 
5477
..
 
5478
.
 
5479
.
 
5480
.de bar
 
5481
.  tm This is bar.
 
5482
..
 
5483
@endExample
 
5484
 
 
5485
@cindex blank line
 
5486
@cindex blank line macro (@code{blm})
 
5487
Another possibility is to use the blank line macro request @code{blm} by
 
5488
assigning an empty macro to it.
 
5489
 
 
5490
@Example
 
5491
.de do-nothing
 
5492
..
 
5493
.blm do-nothing  \" activate blank line macro
 
5494
 
 
5495
.de foo
 
5496
.  tm This is foo.
 
5497
..
 
5498
 
 
5499
 
 
5500
.de bar
 
5501
.  tm This is bar.
 
5502
..
 
5503
 
 
5504
.blm             \" deactivate blank line macro
 
5505
@endExample
 
5506
 
 
5507
@xref{Blank Line Traps}.
 
5508
 
 
5509
@cindex zero width space character (@code{\&})
 
5510
@cindex character, zero width space (@code{\&})
 
5511
@cindex space character, zero width (@code{\&})
 
5512
@cindex @code{\&}, escaping control characters
 
5513
To begin a line with a control character without it being interpreted,
 
5514
precede it with @code{\&}.  This represents a zero width space, which
 
5515
means it does not affect the output.
 
5516
 
 
5517
In most cases the period is used as a control character.  Several
 
5518
requests cause a break implicitly; using the single quote control
 
5519
character prevents this.
 
5520
 
 
5521
@Defreg {.br}
 
5522
A read-only number register which is set to@tie{}1 if a macro is called
 
5523
with the normal control character (as defined with the @code{cc}
 
5524
request), and set to@tie{}0 otherwise.
 
5525
 
 
5526
@cindex modifying requests
 
5527
@cindex requests, modifying
 
5528
This allows to reliably modify requests.
 
5529
 
 
5530
@Example
 
5531
.als bp*orig bp
 
5532
.de bp
 
5533
.  tm before bp
 
5534
.  ie \\n[.br] .bp*orig
 
5535
.  el 'bp*orig
 
5536
.  tm after bp
 
5537
..
 
5538
@endExample
 
5539
 
 
5540
Using this register outside of a macro makes no sense (it always returns
 
5541
zero in such cases).
 
5542
 
 
5543
If a macro is called as a string (this is, using @code{\*}), the value
 
5544
of the @code{.br} register is inherited from the calling macro.
 
5545
@endDefreg
 
5546
 
 
5547
@menu
 
5548
* Request and Macro Arguments::
 
5549
@end menu
 
5550
 
 
5551
@node Request and Macro Arguments,  , Requests, Requests
 
5552
@subsubsection Request and Macro Arguments
 
5553
@cindex request arguments
 
5554
@cindex macro arguments
 
5555
@cindex arguments to requests and macros
 
5556
 
 
5557
@cindex tabs, and macro arguments
 
5558
@cindex macro arguments, and tabs
 
5559
@cindex arguments to macros, and tabs
 
5560
Arguments to requests and macros are processed much like the shell:
 
5561
The line is split into arguments according to
 
5562
spaces.@footnote{Plan@tie{}9's @code{troff} implementation also allows
 
5563
tabs for argument separation -- @code{gtroff} intentionally doesn't
 
5564
support this.}
 
5565
 
 
5566
@cindex spaces, in a macro argument
 
5567
An argument to a macro which is intended to contain spaces can either be
 
5568
enclosed in double quotes, or have the spaces @dfn{escaped} with
 
5569
backslashes.  This is @emph{not} true for requests.
 
5570
 
 
5571
Here are a few examples for a hypothetical macro @code{uh}:
 
5572
 
 
5573
@Example
 
5574
.uh The Mouse Problem
 
5575
.uh "The Mouse Problem"
 
5576
.uh The\ Mouse\ Problem
 
5577
@endExample
 
5578
 
 
5579
@cindex @code{\~}, difference to @code{\@key{SP}}
 
5580
@cindex @code{\@key{SP}}, difference to @code{\~}
 
5581
@noindent
 
5582
The first line is the @code{uh} macro being called with 3 arguments,
 
5583
@samp{The}, @samp{Mouse}, and @samp{Problem}.  The latter two have the
 
5584
same effect of calling the @code{uh} macro with one argument, @samp{The
 
5585
Mouse Problem}.@footnote{The last solution, i.e., using escaped spaces,
 
5586
is ``classical'' in the sense that it can be found in most @code{troff}
 
5587
documents.  Nevertheless, it is not optimal in all situations, since
 
5588
@w{@samp{\ }} inserts a fixed-width, non-breaking space character which
 
5589
can't stretch.  @code{gtroff} provides a different command @code{\~} to
 
5590
insert a stretchable, non-breaking space.}
 
5591
 
 
5592
@cindex @code{"}, in a macro argument
 
5593
@cindex double quote, in a macro argument
 
5594
A double quote which isn't preceded by a space doesn't start a macro
 
5595
argument.  If not closing a string, it is printed literally.
 
5596
 
 
5597
For example,
 
5598
 
 
5599
@Example
 
5600
.xxx a" "b c" "de"fg"
 
5601
@endExample
 
5602
 
 
5603
@noindent
 
5604
has the arguments @samp{a"}, @w{@samp{b c}}, @samp{de}, and @samp{fg"}.
 
5605
Don't rely on this obscure behaviour!
 
5606
 
 
5607
There are two possibilities to get a double quote reliably.
 
5608
 
 
5609
@itemize @bullet
 
5610
@item
 
5611
Enclose the whole argument with double quotes and use two consecutive
 
5612
double quotes to represent a single one.  This traditional solution has
 
5613
the disadvantage that double quotes don't survive argument expansion
 
5614
again if called in compatibility mode (using the @option{-C} option of
 
5615
@code{groff}):
 
5616
 
 
5617
@Example
 
5618
.de xx
 
5619
.  tm xx: `\\$1' `\\$2' `\\$3'
 
5620
.
 
5621
.  yy "\\$1" "\\$2" "\\$3"
 
5622
..
 
5623
.de yy
 
5624
.  tm yy: `\\$1' `\\$2' `\\$3'
 
5625
..
 
5626
.xx A "test with ""quotes""" .
 
5627
    @result{} xx: `A' `test with "quotes"' `.'
 
5628
    @result{} yy: `A' `test with ' `quotes""'
 
5629
@endExample
 
5630
 
 
5631
@noindent
 
5632
If not in compatibility mode, you get the expected result
 
5633
 
 
5634
@Example
 
5635
xx: `A' `test with "quotes"' `.'
 
5636
yy: `A' `test with "quotes"' `.'
 
5637
@endExample
 
5638
 
 
5639
@noindent
 
5640
since @code{gtroff} preserves the input level.
 
5641
 
 
5642
@item
 
5643
Use the double quote glyph @code{\(dq}.  This works with and without
 
5644
compatibility mode enabled since @code{gtroff} doesn't convert
 
5645
@code{\(dq} back to a double quote input character.
 
5646
 
 
5647
Note that this method won't work with @acronym{UNIX} @code{troff} in
 
5648
general since the glyph `dq' isn't defined normally.
 
5649
@end itemize
 
5650
 
 
5651
@cindex @code{ds} request, and double quotes
 
5652
Double quotes in the @code{ds} request are handled differently.
 
5653
@xref{Strings}, for more details.
 
5654
 
 
5655
@c ---------------------------------------------------------------------
 
5656
 
 
5657
@node Macros, Escapes, Requests, Embedded Commands
 
5658
@subsection Macros
 
5659
@cindex macros
 
5660
 
 
5661
@code{gtroff} has a @dfn{macro} facility for defining a series of lines
 
5662
which can be invoked by name.  They are called in the same manner as
 
5663
requests -- arguments also may be passed basically in the same manner.
 
5664
 
 
5665
@xref{Writing Macros}, and @ref{Request and Macro Arguments}.
 
5666
 
 
5667
@c ---------------------------------------------------------------------
 
5668
 
 
5669
@node Escapes,  , Macros, Embedded Commands
 
5670
@subsection Escapes
 
5671
@cindex escapes
 
5672
 
 
5673
Escapes may occur anywhere in the input to @code{gtroff}.  They usually
 
5674
begin with a backslash and are followed by a single character which
 
5675
indicates the function to be performed.  The escape character can be
 
5676
changed; see @ref{Character Translations}.
 
5677
 
 
5678
Escape sequences which require an identifier as a parameter accept three
 
5679
possible syntax forms.
 
5680
 
 
5681
@itemize @bullet
 
5682
@item
 
5683
The next single character is the identifier.
 
5684
 
 
5685
@cindex @code{(}, starting a two-character identifier
 
5686
@item
 
5687
If this single character is an opening parenthesis, take the following
 
5688
two characters as the identifier.  Note that there is no closing
 
5689
parenthesis after the identifier.
 
5690
 
 
5691
@cindex @code{[}, starting an identifier
 
5692
@cindex @code{]}, ending an identifier
 
5693
@item
 
5694
If this single character is an opening bracket, take all characters
 
5695
until a closing bracket as the identifier.
 
5696
@end itemize
 
5697
 
 
5698
@noindent
 
5699
Examples:
 
5700
 
 
5701
@Example
 
5702
\fB
 
5703
\n(XX
 
5704
\*[TeX]
 
5705
@endExample
 
5706
 
 
5707
@cindex @code{'}, delimiting arguments
 
5708
@cindex argument delimiting characters
 
5709
@cindex characters, argument delimiting
 
5710
@cindex delimiting characters for arguments
 
5711
Other escapes may require several arguments and/or some special format.
 
5712
In such cases the argument is traditionally enclosed in single quotes
 
5713
(and quotes are always used in this manual for the definitions of escape
 
5714
sequences).  The enclosed text is then processed according to what that
 
5715
escape expects.  Example:
 
5716
 
 
5717
@Example
 
5718
\l'1.5i\(bu'
 
5719
@endExample
 
5720
 
 
5721
@cindex @code{\o}, possible quote characters
 
5722
@cindex @code{\b}, possible quote characters
 
5723
@cindex @code{\X}, possible quote characters
 
5724
Note that the quote character can be replaced with any other character
 
5725
which does not occur in the argument (even a newline or a space
 
5726
character) in the following escapes: @code{\o}, @code{\b}, and
 
5727
@code{\X}.  This makes e.g.
 
5728
 
 
5729
@Example
 
5730
A caf
 
5731
\o
 
5732
e\'
 
5733
 
 
5734
 
 
5735
in Paris
 
5736
  @result{} A caf� in Paris
 
5737
@endExample
 
5738
 
 
5739
@noindent
 
5740
possible, but it is better not to use this feature to avoid confusion.
 
5741
 
 
5742
@cindex @code{\%}, used as delimiter
 
5743
@cindex @code{\@key{SP}}, used as delimiter
 
5744
@cindex @code{\|}, used as delimiter
 
5745
@cindex @code{\^}, used as delimiter
 
5746
@cindex @code{\@{}, used as delimiter
 
5747
@cindex @code{\@}}, used as delimiter
 
5748
@cindex @code{\'}, used as delimiter
 
5749
@cindex @code{\`}, used as delimiter
 
5750
@cindex @code{\-}, used as delimiter
 
5751
@cindex @code{\_}, used as delimiter
 
5752
@cindex @code{\!}, used as delimiter
 
5753
@cindex @code{\?}, used as delimiter
 
5754
@cindex @code{\)}, used as delimiter
 
5755
@cindex @code{\/}, used as delimiter
 
5756
@cindex @code{\,}, used as delimiter
 
5757
@cindex @code{\&}, used as delimiter
 
5758
@ifnotinfo
 
5759
@cindex @code{\:}, used as delimiter
 
5760
@end ifnotinfo
 
5761
@ifinfo
 
5762
@cindex @code{\@r{<colon>}}, used as delimiter
 
5763
@end ifinfo
 
5764
@cindex @code{\~}, used as delimiter
 
5765
@cindex @code{\0}, used as delimiter
 
5766
@cindex @code{\a}, used as delimiter
 
5767
@cindex @code{\c}, used as delimiter
 
5768
@cindex @code{\d}, used as delimiter
 
5769
@cindex @code{\e}, used as delimiter
 
5770
@cindex @code{\E}, used as delimiter
 
5771
@cindex @code{\p}, used as delimiter
 
5772
@cindex @code{\r}, used as delimiter
 
5773
@cindex @code{\t}, used as delimiter
 
5774
@cindex @code{\u}, used as delimiter
 
5775
The following escapes sequences (which are handled similarly to
 
5776
characters since they don't take a parameter) are also allowed as
 
5777
delimiters: @code{\%}, @w{@samp{\ }}, @code{\|}, @code{\^}, @code{\@{},
 
5778
@code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
 
5779
@code{\?}, @code{\)}, @code{\/}, @code{\,}, @code{\&}, @code{\:},
 
5780
@code{\~}, @code{\0}, @code{\a}, @code{\c}, @code{\d}, @code{\e},
 
5781
@code{\E}, @code{\p}, @code{\r}, @code{\t}, and @code{\u}.  Again, don't
 
5782
use these if possible.
 
5783
 
 
5784
@cindex @code{\A}, allowed delimiters
 
5785
@cindex @code{\B}, allowed delimiters
 
5786
@cindex @code{\Z}, allowed delimiters
 
5787
@cindex @code{\C}, allowed delimiters
 
5788
@cindex @code{\w}, allowed delimiters
 
5789
No newline characters as delimiters are allowed in the following
 
5790
escapes: @code{\A}, @code{\B}, @code{\Z}, @code{\C}, and @code{\w}.
 
5791
 
 
5792
@cindex @code{\D}, allowed delimiters
 
5793
@cindex @code{\h}, allowed delimiters
 
5794
@cindex @code{\H}, allowed delimiters
 
5795
@cindex @code{\l}, allowed delimiters
 
5796
@cindex @code{\L}, allowed delimiters
 
5797
@cindex @code{\N}, allowed delimiters
 
5798
@cindex @code{\R}, allowed delimiters
 
5799
@cindex @code{\s}, allowed delimiters
 
5800
@cindex @code{\S}, allowed delimiters
 
5801
@cindex @code{\v}, allowed delimiters
 
5802
@cindex @code{\x}, allowed delimiters
 
5803
Finally, the escapes @code{\D}, @code{\h}, @code{\H}, @code{\l},
 
5804
@code{\L}, @code{\N}, @code{\R}, @code{\s}, @code{\S}, @code{\v}, and
 
5805
@code{\x} can't use the following characters as delimiters:
 
5806
 
 
5807
@itemize @bullet
 
5808
@item
 
5809
@cindex numbers, and delimiters
 
5810
@cindex digits, and delimiters
 
5811
The digits @code{0}-@code{9}.
 
5812
 
 
5813
@item
 
5814
@cindex operators, as delimiters
 
5815
@cindex @code{+}, as delimiter
 
5816
@cindex @code{-}, as delimiter
 
5817
@cindex @code{/}, as delimiter
 
5818
@cindex @code{*}, as delimiter
 
5819
@cindex @code{%}, as delimiter
 
5820
@cindex @code{<}, as delimiter
 
5821
@cindex @code{>}, as delimiter
 
5822
@cindex @code{=}, as delimiter
 
5823
@cindex @code{&}, as delimiter
 
5824
@ifnotinfo
 
5825
@cindex @code{:}, as delimiter
 
5826
@end ifnotinfo
 
5827
@ifinfo
 
5828
@cindex <colon>, as delimiter
 
5829
@end ifinfo
 
5830
@cindex @code{(}, as delimiter
 
5831
@cindex @code{)}, as delimiter
 
5832
@cindex @code{.}, as delimiter
 
5833
The (single-character) operators @samp{+-/*%<>=&:().}.
 
5834
 
 
5835
@item
 
5836
@cindex space character
 
5837
@cindex character, space
 
5838
@cindex tab character
 
5839
@cindex character, tab
 
5840
@cindex newline character
 
5841
@cindex character, newline
 
5842
The space, tab, and newline characters.
 
5843
 
 
5844
@item
 
5845
@cindex @code{\%}, used as delimiter
 
5846
@ifnotinfo
 
5847
@cindex @code{\:}, used as delimiter
 
5848
@end ifnotinfo
 
5849
@ifinfo
 
5850
@cindex @code{\@r{<colon>}}, used as delimiter
 
5851
@end ifinfo
 
5852
@cindex @code{\@{}, used as delimiter
 
5853
@cindex @code{\@}}, used as delimiter
 
5854
@cindex @code{\'}, used as delimiter
 
5855
@cindex @code{\`}, used as delimiter
 
5856
@cindex @code{\-}, used as delimiter
 
5857
@cindex @code{\_}, used as delimiter
 
5858
@cindex @code{\!}, used as delimiter
 
5859
@cindex @code{\/}, used as delimiter
 
5860
@cindex @code{\c}, used as delimiter
 
5861
@cindex @code{\e}, used as delimiter
 
5862
@cindex @code{\p}, used as delimiter
 
5863
All escape sequences except @code{\%}, @code{\:}, @code{\@{},
 
5864
@code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
 
5865
@code{\/}, @code{\c}, @code{\e}, and @code{\p}.
 
5866
@end itemize
 
5867
 
 
5868
@cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
 
5869
@cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
 
5870
To have a backslash (actually, the current escape character) appear in
 
5871
the output several escapes are defined: @code{\\}, @code{\e} or
 
5872
@code{\E}.  These are very similar, and only differ with respect to
 
5873
being used in macros or diversions.  @xref{Character Translations}, for
 
5874
an exact description of those escapes.
 
5875
 
 
5876
@xref{Implementation Differences}, @ref{Copy-in Mode}, and
 
5877
@ref{Diversions}, @ref{Identifiers}, for more information.
 
5878
 
 
5879
@menu
 
5880
* Comments::
 
5881
@end menu
 
5882
 
 
5883
@node Comments,  , Escapes, Escapes
 
5884
@subsubsection Comments
 
5885
@cindex comments
 
5886
 
 
5887
Probably one of the most@footnote{Unfortunately, this is a lie.  But
 
5888
hopefully future @code{gtroff} hackers will believe it @code{:-)}}
 
5889
common forms of escapes is the comment.
 
5890
 
 
5891
@Defesc {\\", , , }
 
5892
Start a comment.  Everything to the end of the input line is ignored.
 
5893
 
 
5894
This may sound simple, but it can be tricky to keep the comments from
 
5895
interfering with the appearance of the final output.
 
5896
 
 
5897
@cindex @code{ds}, @code{ds1} requests, and comments
 
5898
@cindex @code{as}, @code{as1} requests, and comments
 
5899
If the escape is to the right of some text or a request, that portion of
 
5900
the line is ignored, but the space leading up to it is noticed by
 
5901
@code{gtroff}.  This only affects the @code{ds} and @code{as} request
 
5902
and its variants.
 
5903
 
 
5904
@cindex tabs, before comments
 
5905
@cindex comments, lining up with tabs
 
5906
One possibly irritating idiosyncracy is that tabs must not be used to
 
5907
line up comments.  Tabs are not treated as whitespace between the
 
5908
request and macro arguments.
 
5909
 
 
5910
@cindex undefined request
 
5911
@cindex request, undefined
 
5912
A comment on a line by itself is treated as a blank line, because after
 
5913
eliminating the comment, that is all that remains:
 
5914
 
 
5915
@Example
 
5916
Test
 
5917
\" comment
 
5918
Test
 
5919
@endExample
 
5920
 
 
5921
@noindent
 
5922
produces
 
5923
 
 
5924
@Example
 
5925
Test
 
5926
 
 
5927
Test
 
5928
@endExample
 
5929
 
 
5930
To avoid this, it is common to start the line with @code{.\"} which
 
5931
causes the line to be treated as an undefined request and thus ignored
 
5932
completely.
 
5933
 
 
5934
@cindex @code{'}, as a comment
 
5935
Another commenting scheme seen sometimes is three consecutive single
 
5936
quotes (@code{'''}) at the beginning of a line.  This works, but
 
5937
@code{gtroff} gives a warning about an undefined macro (namely
 
5938
@code{''}), which is harmless, but irritating.
 
5939
@endDefesc
 
5940
 
 
5941
@Defesc {\\#, , , }
 
5942
To avoid all this, @code{gtroff} has a new comment mechanism using the
 
5943
@code{\#} escape.  This escape works the same as @code{\"} except that
 
5944
the newline is also ignored:
 
5945
 
 
5946
@Example
 
5947
Test
 
5948
\# comment
 
5949
Test
 
5950
@endExample
 
5951
 
 
5952
@noindent
 
5953
produces
 
5954
 
 
5955
@Example
 
5956
Test Test
 
5957
@endExample
 
5958
 
 
5959
@noindent
 
5960
as expected.
 
5961
@endDefesc
 
5962
 
 
5963
@Defreq {ig, [@Var{end}]}
 
5964
Ignore all input until @code{gtroff} encounters the macro named
 
5965
@code{.}@var{end} on a line by itself (or @code{..} if @var{end} is not
 
5966
specified).  This is useful for commenting out large blocks of text:
 
5967
 
 
5968
@Example
 
5969
text text text...
 
5970
.ig
 
5971
This is part of a large block
 
5972
of text that has been
 
5973
temporarily(?) commented out.
 
5974
 
 
5975
We can restore it simply by removing
 
5976
the .ig request and the ".." at the
 
5977
end of the block.
 
5978
..
 
5979
More text text text...
 
5980
@endExample
 
5981
 
 
5982
@noindent
 
5983
produces
 
5984
 
 
5985
@Example
 
5986
text text text@dots{}  More text text text@dots{}
 
5987
@endExample
 
5988
 
 
5989
@noindent
 
5990
Note that the commented-out block of text does not cause a break.
 
5991
 
 
5992
@cindex @code{ig} request, and copy-in mode
 
5993
@cindex copy-in mode, and @code{ig} request
 
5994
@cindex mode, copy-in, and @code{ig} request
 
5995
@cindex @code{ig} request, and auto-increment
 
5996
@cindex auto-increment, and @code{ig} request
 
5997
The input is read in copy-mode; auto-incremented registers @emph{are}
 
5998
affected (@pxref{Auto-increment}).
 
5999
@endDefreq
 
6000
 
 
6001
 
 
6002
@c =====================================================================
 
6003
 
 
6004
@node Registers, Manipulating Filling and Adjusting, Embedded Commands, gtroff Reference
 
6005
@section Registers
 
6006
@cindex registers
 
6007
 
 
6008
Numeric variables in @code{gtroff} are called @dfn{registers}.  There
 
6009
are a number of built-in registers, supplying anything from the date to
 
6010
details of formatting parameters.
 
6011
 
 
6012
@xref{Identifiers}, for details on register identifiers.
 
6013
 
 
6014
@menu
 
6015
* Setting Registers::
 
6016
* Interpolating Registers::
 
6017
* Auto-increment::
 
6018
* Assigning Formats::
 
6019
* Built-in Registers::
 
6020
@end menu
 
6021
 
 
6022
@c ---------------------------------------------------------------------
 
6023
 
 
6024
@node Setting Registers, Interpolating Registers, Registers, Registers
 
6025
@subsection Setting Registers
 
6026
@cindex setting registers (@code{nr}, @code{\R})
 
6027
@cindex registers, setting (@code{nr}, @code{\R})
 
6028
 
 
6029
Define or set registers using the @code{nr} request or the @code{\R}
 
6030
escape.
 
6031
 
 
6032
Although the following requests and escapes can be used to create
 
6033
registers, simply using an undefined register will cause it to be
 
6034
set to zero.
 
6035
 
 
6036
@DefreqList {nr, ident value}
 
6037
@DefescListEnd {\\R, ', ident value, '}
 
6038
Set number register @var{ident} to @var{value}.  If @var{ident} doesn't
 
6039
exist, @code{gtroff} creates it.
 
6040
 
 
6041
The argument to @code{\R} usually has to be enclosed in quotes.
 
6042
@xref{Escapes}, for details on parameter delimiting characters.
 
6043
 
 
6044
The @code{\R} escape doesn't produce an input token in @code{gtroff};
 
6045
in other words, it vanishes completely after @code{gtroff} has
 
6046
processed it.
 
6047
 
 
6048
For example, the following two lines are equivalent:
 
6049
 
 
6050
@Example
 
6051
.nr a (((17 + (3 * 4))) % 4)
 
6052
\R'a (((17 + (3 * 4))) % 4)'
 
6053
    @result{} 1
 
6054
@endExample
 
6055
 
 
6056
Note that the complete transparency of @code{\R} can cause surprising
 
6057
effects if you use number registers like @code{.k} which get evaluated
 
6058
at the time they are accessed.
 
6059
 
 
6060
@Example
 
6061
.ll 1.6i
 
6062
.
 
6063
aaa bbb ccc ddd eee fff ggg hhh\R':k \n[.k]'
 
6064
.tm :k == \n[:k]
 
6065
    @result{} :k == 126950
 
6066
.
 
6067
.br
 
6068
.
 
6069
aaa bbb ccc ddd eee fff ggg hhh\h'0'\R':k \n[.k]'
 
6070
.tm :k == \n[:k]
 
6071
    @result{} :k == 15000
 
6072
@endExample
 
6073
 
 
6074
If you process this with the @sc{PostScript} device (@code{-Tps}),
 
6075
there will be a line break eventually after @code{ggg} in both input
 
6076
lines.  However, after processing the space after @code{ggg}, the
 
6077
partially collected line is not overfull yet, so @code{troff}
 
6078
continues to collect input until it sees the space (or in this case,
 
6079
the newline) after @code{hhh}.  At this point, the line is longer
 
6080
than the line length, and the line gets broken.
 
6081
 
 
6082
In the first input line, since the @code{\R} escape leaves no traces,
 
6083
the check for the overfull line hasn't been done yet at the point where
 
6084
@code{\R} gets handled, and you get a value for the @code{.k} number
 
6085
register which is even greater than the current line length.
 
6086
 
 
6087
In the second input line, the insertion of @code{\h'0'} to emit an
 
6088
invisible zero-width space forces @code{troff} to check the line length
 
6089
which in turn causes the start of a new output line.  Now @code{.k}
 
6090
returns the expected value.
 
6091
@endDefreq
 
6092
 
 
6093
Both @code{nr} and @code{\R} have two additional special forms to
 
6094
increment or decrement a register.
 
6095
 
 
6096
@DefreqList {nr, ident @t{+}@Var{value}}
 
6097
@DefreqItem {nr, ident @t{-}@Var{value}}
 
6098
@DefescItem {\\R, ', ident @t{+}value, '}
 
6099
@DefescListEnd {\\R, ', ident @t{-}value, '}
 
6100
Increment (decrement) register @var{ident} by @var{value}.
 
6101
 
 
6102
@Example
 
6103
.nr a 1
 
6104
.nr a +1
 
6105
\na
 
6106
    @result{} 2
 
6107
@endExample
 
6108
 
 
6109
@cindex negating register values
 
6110
To assign the negated value of a register to another register, some care
 
6111
must be taken to get the desired result:
 
6112
 
 
6113
@Example
 
6114
.nr a 7
 
6115
.nr b 3
 
6116
.nr a -\nb
 
6117
\na
 
6118
    @result{} 4
 
6119
.nr a (-\nb)
 
6120
\na
 
6121
    @result{} -3
 
6122
@endExample
 
6123
 
 
6124
@noindent
 
6125
The surrounding parentheses prevent the interpretation of the minus sign
 
6126
as a decrementing operator.  An alternative is to start the assignment
 
6127
with a @samp{0}:
 
6128
 
 
6129
@Example
 
6130
.nr a 7
 
6131
.nr b -3
 
6132
.nr a \nb
 
6133
\na
 
6134
    @result{} 4
 
6135
.nr a 0\nb
 
6136
\na
 
6137
    @result{} -3
 
6138
@endExample
 
6139
@endDefreq
 
6140
 
 
6141
@Defreq {rr, ident}
 
6142
@cindex removing number register (@code{rr})
 
6143
@cindex number register, removing (@code{rr})
 
6144
@cindex register, removing (@code{rr})
 
6145
Remove number register @var{ident}.  If @var{ident} doesn't exist, the
 
6146
request is ignored.
 
6147
@endDefreq
 
6148
 
 
6149
@Defreq {rnn, ident1 ident2}
 
6150
@cindex renaming number register (@code{rnn})
 
6151
@cindex number register, renaming (@code{rnn})
 
6152
@cindex register, renaming (@code{rnn})
 
6153
Rename number register @var{ident1} to @var{ident2}.  If either
 
6154
@var{ident1} or @var{ident2} doesn't exist, the request is ignored.
 
6155
@endDefreq
 
6156
 
 
6157
@Defreq {aln, ident1 ident2}
 
6158
@cindex alias, number register, creating (@code{aln})
 
6159
@cindex creating alias, for number register (@code{aln})
 
6160
@cindex number register, creating alias (@code{aln})
 
6161
@cindex register, creating alias (@code{aln})
 
6162
Create an alias @var{ident1} for a number register @var{ident2}.  The
 
6163
new name and the old name are exactly equivalent.  If @var{ident1} is
 
6164
undefined, a warning of type @samp{reg} is generated, and the request is
 
6165
ignored.  @xref{Debugging}, for information about warnings.
 
6166
@endDefreq
 
6167
 
 
6168
@c ---------------------------------------------------------------------
 
6169
 
 
6170
@node Interpolating Registers, Auto-increment, Setting Registers, Registers
 
6171
@subsection Interpolating Registers
 
6172
@cindex interpolating registers (@code{\n})
 
6173
@cindex registers, interpolating (@code{\n})
 
6174
 
 
6175
Numeric registers can be accessed via the @code{\n} escape.
 
6176
 
 
6177
@DefescList {\\n, , i, }
 
6178
@DefescItem {\\n, @Lparen{}, id, }
 
6179
@DefescListEnd {\\n, @Lbrack{}, ident, @Rbrack{}}
 
6180
@cindex nested assignments
 
6181
@cindex assignments, nested
 
6182
@cindex indirect assignments
 
6183
@cindex assignments, indirect
 
6184
Interpolate number register with name @var{ident} (one-character
 
6185
name@tie{}@var{i}, two-character name @var{id}).  This means that the
 
6186
value of the register is expanded in-place while @code{gtroff} is
 
6187
parsing the input line.  Nested assignments (also called indirect
 
6188
assignments) are possible.
 
6189
 
 
6190
@Example
 
6191
.nr a 5
 
6192
.nr as \na+\na
 
6193
\n(as
 
6194
    @result{} 10
 
6195
@endExample
 
6196
 
 
6197
@Example
 
6198
.nr a1 5
 
6199
.nr ab 6
 
6200
.ds str b
 
6201
.ds num 1
 
6202
\n[a\n[num]]
 
6203
    @result{} 5
 
6204
\n[a\*[str]]
 
6205
    @result{} 6
 
6206
@endExample
 
6207
@endDefesc
 
6208
 
 
6209
@c ---------------------------------------------------------------------
 
6210
 
 
6211
@node Auto-increment, Assigning Formats, Interpolating Registers, Registers
 
6212
@subsection Auto-increment
 
6213
@cindex auto-increment
 
6214
@cindex increment, automatic
 
6215
 
 
6216
Number registers can also be auto-incremented and auto-decremented.  The
 
6217
increment or decrement value can be specified with a third argument to
 
6218
the @code{nr} request or @code{\R} escape.
 
6219
 
 
6220
@Defreq {nr, ident value incr}
 
6221
@cindex @code{\R}, difference to @code{nr}
 
6222
Set number register @var{ident} to @var{value}; the increment for
 
6223
auto-incrementing is set to @var{incr}.  Note that the @code{\R} escape
 
6224
doesn't support this notation.
 
6225
@endDefreq
 
6226
 
 
6227
To activate auto-incrementing, the escape @code{\n} has a special syntax
 
6228
form.
 
6229
 
 
6230
@DefescList {\\n, +, i, }
 
6231
@DefescItem {\\n, -, i, }
 
6232
@DefescItem {\\n, @Lparen{}+, id, }
 
6233
@DefescItem {\\n, @Lparen{}-, id, }
 
6234
@DefescItem {\\n, +@Lparen{}, id, }
 
6235
@DefescItem {\\n, -@Lparen{}, id, }
 
6236
@DefescItem {\\n, @Lbrack{}+, ident, @Rbrack{}}
 
6237
@DefescItem {\\n, @Lbrack{}-, ident, @Rbrack{}}
 
6238
@DefescItem {\\n, +@Lbrack{}, ident, @Rbrack{}}
 
6239
@DefescListEnd {\\n, -@Lbrack{}, ident, @Rbrack{}}
 
6240
Before interpolating, increment or decrement @var{ident} (one-character
 
6241
name@tie{}@var{i}, two-character name @var{id}) by the auto-increment
 
6242
value as specified with the @code{nr} request (or the @code{\R} escape).
 
6243
If no auto-increment value has been specified, these syntax forms are
 
6244
identical to @code{\n}.
 
6245
@endDefesc
 
6246
 
 
6247
For example,
 
6248
 
 
6249
@Example
 
6250
.nr a 0 1
 
6251
.nr xx 0 5
 
6252
.nr foo 0 -2
 
6253
\n+a, \n+a, \n+a, \n+a, \n+a
 
6254
.br
 
6255
\n-(xx, \n-(xx, \n-(xx, \n-(xx, \n-(xx
 
6256
.br
 
6257
\n+[foo], \n+[foo], \n+[foo], \n+[foo], \n+[foo]
 
6258
@endExample
 
6259
 
 
6260
@noindent
 
6261
produces
 
6262
 
 
6263
@Example
 
6264
1, 2, 3, 4, 5
 
6265
-5, -10, -15, -20, -25
 
6266
-2, -4, -6, -8, -10
 
6267
@endExample
 
6268
 
 
6269
@cindex increment value without changing the register
 
6270
@cindex value, incrementing without changing the register
 
6271
To change the increment value without changing the value of a register
 
6272
(@var{a} in the example), the following can be used:
 
6273
 
 
6274
@Example
 
6275
.nr a \na 10
 
6276
@endExample
 
6277
 
 
6278
@c ---------------------------------------------------------------------
 
6279
 
 
6280
@node Assigning Formats, Built-in Registers, Auto-increment, Registers
 
6281
@subsection Assigning Formats
 
6282
@cindex assigning formats (@code{af})
 
6283
@cindex formats, assigning (@code{af})
 
6284
 
 
6285
When a register is used, it is always textually replaced (or
 
6286
interpolated) with a representation of that number.  This output format
 
6287
can be changed to a variety of formats (numbers, Roman numerals, etc.).
 
6288
This is done using the @code{af} request.
 
6289
 
 
6290
@Defreq {af, ident format}
 
6291
Change the output format of a number register.  The first argument
 
6292
@var{ident} is the name of the number register to be changed, and the
 
6293
second argument @var{format} is the output format.  The following output
 
6294
formats are available:
 
6295
 
 
6296
@table @code
 
6297
@item 1
 
6298
Decimal arabic numbers.  This is the default format: 0, 1, 2,
 
6299
3,@tie{}@enddots{}
 
6300
 
 
6301
@item 0@dots{}0
 
6302
Decimal numbers with as many digits as specified.  So, @samp{00} would
 
6303
result in printing numbers as 01, 02, 03,@tie{}@enddots{}
 
6304
 
 
6305
In fact, any digit instead of zero does work; @code{gtroff} only counts
 
6306
how many digits are specified.  As a consequence, @code{af}'s default
 
6307
format @samp{1} could be specified as @samp{0} also (and exactly this is
 
6308
returned by the @code{\g} escape, see below).
 
6309
 
 
6310
@item I
 
6311
@cindex Roman numerals
 
6312
@cindex numerals, Roman
 
6313
Upper-case Roman numerals: 0, I, II, III, IV,@tie{}@enddots{}
 
6314
 
 
6315
@item i
 
6316
Lower-case Roman numerals: 0, i, ii, iii, iv,@tie{}@enddots{}
 
6317
 
 
6318
@item A
 
6319
Upper-case letters: 0, A, B, C, @dots{},@tie{}Z, AA, AB,@tie{}@enddots{}
 
6320
 
 
6321
@item a
 
6322
Lower-case letters: 0, a, b, c, @dots{},@tie{}z, aa, ab,@tie{}@enddots{}
 
6323
@end table
 
6324
 
 
6325
Omitting the number register format causes a warning of type
 
6326
@samp{missing}.  @xref{Debugging}, for more details.  Specifying a
 
6327
nonexistent format causes an error.
 
6328
 
 
6329
The following example produces @samp{10, X, j, 010}:
 
6330
 
 
6331
@Example
 
6332
.nr a 10
 
6333
.af a 1           \" the default format
 
6334
\na,
 
6335
.af a I
 
6336
\na,
 
6337
.af a a
 
6338
\na,
 
6339
.af a 001
 
6340
\na
 
6341
@endExample
 
6342
 
 
6343
@cindex Roman numerals, maximum and minimum
 
6344
@cindex maximum values of Roman numerals
 
6345
@cindex minimum values of Roman numerals
 
6346
The largest number representable for the @samp{i} and @samp{I} formats
 
6347
is 39999 (or @minus{}39999); @acronym{UNIX} @code{troff} uses @samp{z}
 
6348
and @samp{w} to represent 10000 and 5000 in Roman numerals, and so does
 
6349
@code{gtroff}.  Currently, the correct glyphs of Roman numeral five
 
6350
thousand and Roman numeral ten thousand (Unicode code points
 
6351
@code{U+2182} and @code{U+2181}, respectively) are not available.
 
6352
 
 
6353
If @var{ident} doesn't exist, it is created.
 
6354
 
 
6355
@cindex read-only register, changing format
 
6356
@cindex changing format, and read-only registers
 
6357
Changing the output format of a read-only register causes an error.  It
 
6358
is necessary to first copy the register's value to a writeable register,
 
6359
then apply the @code{af} request to this other register.
 
6360
@endDefreq
 
6361
 
 
6362
@DefescList {\\g, , i, }
 
6363
@DefescItem {\\g, @Lparen{}, id, }
 
6364
@DefescListEnd {\\g, @Lbrack{}, ident, @Rbrack{}}
 
6365
@cindex format of register (@code{\g})
 
6366
@cindex register, format (@code{\g})
 
6367
Return the current format of the specified register @var{ident}
 
6368
(one-character name@tie{}@var{i}, two-character name @var{id}).  For
 
6369
example, @samp{\ga} after the previous example would produce the string
 
6370
@samp{000}.  If the register hasn't been defined yet, nothing is
 
6371
returned.
 
6372
@endDefesc
 
6373
 
 
6374
@c ---------------------------------------------------------------------
 
6375
 
 
6376
@node Built-in Registers,  , Assigning Formats, Registers
 
6377
@subsection Built-in Registers
 
6378
@cindex built-in registers
 
6379
@cindex registers, built-in
 
6380
 
 
6381
The following lists some built-in registers which are not described
 
6382
elsewhere in this manual.  Any register which begins with a @samp{.} is
 
6383
read-only.  A complete listing of all built-in registers can be found in
 
6384
@ref{Register Index}.
 
6385
 
 
6386
@table @code
 
6387
@item \n[.F]
 
6388
@cindex current input file name register (@code{.F})
 
6389
@cindex input file name, current, register (@code{.F})
 
6390
@vindex .F
 
6391
This string-valued register returns the current input file name.
 
6392
 
 
6393
@item \n[.H]
 
6394
@cindex horizontal resolution register (@code{.H})
 
6395
@cindex resolution, horizontal, register (@code{.H})
 
6396
@vindex .H
 
6397
Horizontal resolution in basic units.
 
6398
 
 
6399
@item \n[.R]
 
6400
@cindex number of registers register (@code{.R})
 
6401
@cindex registers, number of, register (@code{.R})
 
6402
@vindex .R
 
6403
The number of number registers available.  This is always 10000 in
 
6404
GNU@tie{}@code{troff}; it exists for backward compatibility.
 
6405
 
 
6406
@item \n[.U]
 
6407
@cindex safer mode
 
6408
@cindex mode, safer
 
6409
@cindex unsafe mode
 
6410
@cindex mode, unsafe
 
6411
@vindex .U
 
6412
If @code{gtroff} is called with the @option{-U} command line option to
 
6413
activate unsafe mode, the number register @code{.U} is set to@tie{}1,
 
6414
and to zero otherwise.  @xref{Groff Options}.
 
6415
 
 
6416
@item \n[.V]
 
6417
@cindex vertical resolution register (@code{.V})
 
6418
@cindex resolution, vertical, register (@code{.V})
 
6419
@vindex .V
 
6420
Vertical resolution in basic units.
 
6421
 
 
6422
@item \n[seconds]
 
6423
@cindex seconds, current time (@code{seconds})
 
6424
@cindex time, current, seconds (@code{seconds})
 
6425
@cindex current time, seconds (@code{seconds})
 
6426
@vindex seconds
 
6427
The number of seconds after the minute, normally in the range@tie{}0
 
6428
to@tie{}59, but can be up to@tie{}61 to allow for leap seconds.
 
6429
Initialized at start-up of @code{gtroff}.
 
6430
 
 
6431
@item \n[minutes]
 
6432
@cindex minutes, current time (@code{minutes})
 
6433
@cindex time, current, minutes (@code{minutes})
 
6434
@cindex current time, minutes (@code{minutes})
 
6435
@vindex minutes
 
6436
The number of minutes after the hour, in the range@tie{}0 to@tie{}59.
 
6437
Initialized at start-up of @code{gtroff}.
 
6438
 
 
6439
@item \n[hours]
 
6440
@cindex hours, current time (@code{hours})
 
6441
@cindex time, current, hours (@code{hours})
 
6442
@cindex current time, hours (@code{hours})
 
6443
@vindex hours
 
6444
The number of hours past midnight, in the range@tie{}0 to@tie{}23.
 
6445
Initialized at start-up of @code{gtroff}.
 
6446
 
 
6447
@item \n[dw]
 
6448
@cindex day of the week register (@code{dw})
 
6449
@cindex date, day of the week register (@code{dw})
 
6450
@vindex dw
 
6451
Day of the week (1-7).
 
6452
 
 
6453
@item \n[dy]
 
6454
@cindex day of the month register (@code{dy})
 
6455
@cindex date, day of the month register (@code{dy})
 
6456
@vindex dy
 
6457
Day of the month (1-31).
 
6458
 
 
6459
@item \n[mo]
 
6460
@cindex month of the year register (@code{mo})
 
6461
@cindex date, month of the year register (@code{mo})
 
6462
@vindex mo
 
6463
Current month (1-12).
 
6464
 
 
6465
@item \n[year]
 
6466
@cindex date, year register (@code{year}, @code{yr})
 
6467
@cindex year, current, register (@code{year}, @code{yr})
 
6468
@vindex year
 
6469
The current year.
 
6470
 
 
6471
@item \n[yr]
 
6472
@vindex yr
 
6473
The current year minus@tie{}1900.  Unfortunately, the documentation of
 
6474
@acronym{UNIX} Version@tie{}7's @code{troff} had a year@tie{}2000 bug:
 
6475
It incorrectly claimed that @code{yr} contains the last two digits of
 
6476
the year.  That claim has never been true of either @acronym{AT&T}
 
6477
@code{troff} or GNU @code{troff}.  Old @code{troff} input that looks
 
6478
like this:
 
6479
 
 
6480
@Example
 
6481
'\" The following line stopped working after 1999
 
6482
This document was formatted in 19\n(yr.
 
6483
@endExample
 
6484
 
 
6485
@noindent
 
6486
can be corrected as follows:
 
6487
 
 
6488
@Example
 
6489
This document was formatted in \n[year].
 
6490
@endExample
 
6491
 
 
6492
@noindent
 
6493
or, to be portable to older @code{troff} versions, as follows:
 
6494
 
 
6495
@Example
 
6496
.nr y4 1900+\n(yr
 
6497
This document was formatted in \n(y4.
 
6498
@endExample
 
6499
 
 
6500
@item \n[.c]
 
6501
@vindex .c
 
6502
@itemx \n[c.]
 
6503
@vindex c.
 
6504
@cindex input line number register (@code{.c}, @code{c.})
 
6505
@cindex line number, input, register (@code{.c}, @code{c.})
 
6506
The current @emph{input} line number.  Register @samp{.c} is read-only,
 
6507
whereas @samp{c.} (a @code{gtroff} extension) is writable also,
 
6508
affecting both @samp{.c} and @samp{c.}.
 
6509
 
 
6510
@item \n[ln]
 
6511
@vindex ln
 
6512
@cindex output line number register (@code{ln})
 
6513
@cindex line number, output, register (@code{ln})
 
6514
The current @emph{output} line number after a call to the @code{nm}
 
6515
request to activate line numbering.
 
6516
 
 
6517
@xref{Miscellaneous}, for more information about line numbering.
 
6518
 
 
6519
@item \n[.x]
 
6520
@vindex .x
 
6521
@cindex major version number register (@code{.x})
 
6522
@cindex version number, major, register (@code{.x})
 
6523
The major version number.  For example, if the version number is 1.03
 
6524
then @code{.x} contains@tie{}@samp{1}.
 
6525
 
 
6526
@item \n[.y]
 
6527
@vindex .y
 
6528
@cindex minor version number register (@code{.y})
 
6529
@cindex version number, minor, register (@code{.y})
 
6530
The minor version number.  For example, if the version number is 1.03
 
6531
then @code{.y} contains@tie{}@samp{03}.
 
6532
 
 
6533
@item \n[.Y]
 
6534
@vindex .Y
 
6535
@cindex revision number register (@code{.Y})
 
6536
The revision number of @code{groff}.
 
6537
 
 
6538
@item \n[$$]
 
6539
@vindex $$
 
6540
@cindex process ID of @code{gtroff} register (@code{$$})
 
6541
@cindex @code{gtroff}, process ID register (@code{$$})
 
6542
The process ID of @code{gtroff}.
 
6543
 
 
6544
@item \n[.g]
 
6545
@vindex .g
 
6546
@cindex @code{gtroff}, identification register (@code{.g})
 
6547
@cindex GNU-specific register (@code{.g})
 
6548
Always@tie{}1.  Macros should use this to determine whether they are
 
6549
running under GNU @code{troff}.
 
6550
 
 
6551
@item \n[.A]
 
6552
@vindex .A
 
6553
@cindex @acronym{ASCII} approximation output register (@code{.A})
 
6554
If the command line option @option{-a} is used to produce an
 
6555
@acronym{ASCII} approximation of the output, this is set to@tie{}1, zero
 
6556
otherwise.  @xref{Groff Options}.
 
6557
 
 
6558
@item \n[.O]
 
6559
@vindex .O
 
6560
This read-only register is set to the suppression nesting level (see
 
6561
escapes @code{\O}).  @xref{Suppressing output}.
 
6562
 
 
6563
@item \n[.P]
 
6564
@vindex .P
 
6565
This register is set to@tie{}1 (and to@tie{}0 otherwise) if the current
 
6566
page is actually being printed, i.e., if the @option{-o} option is being
 
6567
used to only print selected pages.  @xref{Groff Options}, for more
 
6568
information.
 
6569
 
 
6570
@item \n[.T]
 
6571
@vindex .T
 
6572
If @code{gtroff} is called with the @option{-T} command line option, the
 
6573
number register @code{.T} is set to@tie{}1, and zero otherwise.
 
6574
@xref{Groff Options}.
 
6575
 
 
6576
@item \*[.T]
 
6577
@stindex .T
 
6578
@cindex output device name string register (@code{.T})
 
6579
A single read-write string register which contains the current output
 
6580
device (for example, @samp{latin1} or @samp{ps}).  This is the only
 
6581
string register defined by @code{gtroff}.
 
6582
@end table
 
6583
 
 
6584
 
 
6585
@c =====================================================================
 
6586
 
 
6587
@node Manipulating Filling and Adjusting, Manipulating Hyphenation, Registers, gtroff Reference
 
6588
@section Manipulating Filling and Adjusting
 
6589
@cindex manipulating filling and adjusting
 
6590
@cindex filling and adjusting, manipulating
 
6591
@cindex adjusting and filling, manipulating
 
6592
@cindex justifying text
 
6593
@cindex text, justifying
 
6594
 
 
6595
@cindex break
 
6596
@cindex line break
 
6597
@cindex @code{bp} request, causing implicit linebreak
 
6598
@cindex @code{ce} request, causing implicit linebreak
 
6599
@cindex @code{cf} request, causing implicit linebreak
 
6600
@cindex @code{fi} request, causing implicit linebreak
 
6601
@cindex @code{fl} request, causing implicit linebreak
 
6602
@cindex @code{in} request, causing implicit linebreak
 
6603
@cindex @code{nf} request, causing implicit linebreak
 
6604
@cindex @code{rj} request, causing implicit linebreak
 
6605
@cindex @code{sp} request, causing implicit linebreak
 
6606
@cindex @code{ti} request, causing implicit linebreak
 
6607
@cindex @code{trf} request, causing implicit linebreak
 
6608
Various ways of causing @dfn{breaks} were given in @ref{Implicit Line
 
6609
Breaks}.  The @code{br} request likewise causes a break.  Several other
 
6610
requests also cause breaks, but implicitly.  These are @code{bp},
 
6611
@code{ce}, @code{cf}, @code{fi}, @code{fl}, @code{in}, @code{nf},
 
6612
@code{rj}, @code{sp}, @code{ti}, and @code{trf}.
 
6613
 
 
6614
@Defreq {br, }
 
6615
Break the current line, i.e., the input collected so far is emitted
 
6616
without adjustment.
 
6617
 
 
6618
If the no-break control character is used, @code{gtroff} suppresses the
 
6619
break:
 
6620
 
 
6621
@Example
 
6622
a
 
6623
'br
 
6624
b
 
6625
    @result{} a b
 
6626
@endExample
 
6627
@endDefreq
 
6628
 
 
6629
Initially, @code{gtroff} fills and adjusts text to both margins.
 
6630
Filling can be disabled via the @code{nf} request and re-enabled with
 
6631
the @code{fi} request.
 
6632
 
 
6633
@DefreqList {fi, }
 
6634
@DefregListEnd {.u}
 
6635
@cindex fill mode (@code{fi})
 
6636
@cindex mode, fill (@code{fi})
 
6637
Activate fill mode (which is the default).  This request implicitly
 
6638
enables adjusting; it also inserts a break in the text currently being
 
6639
filled.  The read-only number register @code{.u} is set to@tie{}1.
 
6640
 
 
6641
The fill mode status is associated with the current environment
 
6642
(@pxref{Environments}).
 
6643
 
 
6644
See @ref{Line Control}, for interaction with the @code{\c} escape.
 
6645
@endDefreq
 
6646
 
 
6647
@Defreq {nf, }
 
6648
@cindex no-fill mode (@code{nf})
 
6649
@cindex mode, no-fill (@code{nf})
 
6650
Activate no-fill mode.  Input lines are output as-is, retaining line
 
6651
breaks and ignoring the current line length.  This command implicitly
 
6652
disables adjusting; it also causes a break.  The number register
 
6653
@code{.u} is set to@tie{}0.
 
6654
 
 
6655
The fill mode status is associated with the current environment
 
6656
(@pxref{Environments}).
 
6657
 
 
6658
See @ref{Line Control}, for interaction with the @code{\c} escape.
 
6659
@endDefreq
 
6660
 
 
6661
@DefreqList {ad, [@Var{mode}]}
 
6662
@DefregListEnd {.j}
 
6663
Set adjusting mode.
 
6664
 
 
6665
Activation and deactivation of adjusting is done implicitly with calls
 
6666
to the @code{fi} or @code{nf} requests.
 
6667
 
 
6668
@var{mode} can have one of the following values:
 
6669
 
 
6670
@table @code
 
6671
@item l
 
6672
@cindex ragged-right
 
6673
Adjust text to the left margin.  This produces what is traditionally
 
6674
called ragged-right text.
 
6675
 
 
6676
@item r
 
6677
@cindex ragged-left
 
6678
Adjust text to the right margin, producing ragged-left text.
 
6679
 
 
6680
@item c
 
6681
@cindex centered text
 
6682
@cindex @code{ce} request, difference to @samp{.ad@tie{}c}
 
6683
Center filled text.  This is different to the @code{ce} request which
 
6684
only centers text without filling.
 
6685
 
 
6686
@item b
 
6687
@itemx n
 
6688
Justify to both margins.  This is the default used by @code{gtroff}.
 
6689
@end table
 
6690
 
 
6691
Finally, @var{mode} can be the numeric argument returned by the
 
6692
@code{.j} register.
 
6693
 
 
6694
Using @code{ad} without argument is the same as saying
 
6695
@w{@code{.ad \[.j]}}.  In particular, @code{gtroff} adjusts lines
 
6696
in the same way it did before adjusting was deactivated (with a call
 
6697
to @code{na}, say).  For example, this input code
 
6698
 
 
6699
@Example
 
6700
.de AD
 
6701
.  br
 
6702
.  ad \\$1
 
6703
..
 
6704
.
 
6705
.de NA
 
6706
.  br
 
6707
.  na
 
6708
..
 
6709
.
 
6710
textA
 
6711
.AD r
 
6712
.nr ad \n[.j]
 
6713
textB
 
6714
.AD c
 
6715
textC
 
6716
.NA
 
6717
textD
 
6718
.AD         \" back to centering
 
6719
textE
 
6720
.AD \n[ad]  \" back to right justifying
 
6721
textF
 
6722
@endExample
 
6723
 
 
6724
@noindent
 
6725
produces the following output:
 
6726
 
 
6727
@Example
 
6728
textA
 
6729
                                                    textB
 
6730
                          textC
 
6731
textD
 
6732
                          textE
 
6733
                                                    textF
 
6734
@endExample
 
6735
 
 
6736
@cindex adjustment mode register (@code{.j})
 
6737
As just demonstrated, the current adjustment mode is available in the
 
6738
read-only number register @code{.j}; it can be stored and
 
6739
subsequently used to set adjustment.
 
6740
 
 
6741
The adjustment mode status is associated with the current environment
 
6742
(@pxref{Environments}).
 
6743
@endDefreq
 
6744
 
 
6745
@Defreq {na, }
 
6746
Disable adjusting.  This request won't change the current adjustment
 
6747
mode: A subsequent call to @code{ad} uses the previous adjustment
 
6748
setting.
 
6749
 
 
6750
The adjustment mode status is associated with the current environment
 
6751
(@pxref{Environments}).
 
6752
@endDefreq
 
6753
 
 
6754
@DefreqList {brp, }
 
6755
@DefescListEnd {\\p, , , }
 
6756
Adjust the current line and cause a break.
 
6757
 
 
6758
In most cases this produces very ugly results since @code{gtroff}
 
6759
doesn't have a sophisticated paragraph building algorithm (as @TeX{}
 
6760
have, for example); instead, @code{gtroff} fills and adjusts a paragraph
 
6761
line by line:
 
6762
 
 
6763
@Example
 
6764
This is an uninteresting sentence.
 
6765
This is an uninteresting sentence.\p
 
6766
This is an uninteresting sentence.
 
6767
@endExample
 
6768
 
 
6769
@noindent
 
6770
is formatted as
 
6771
 
 
6772
@Example
 
6773
This is  an uninteresting  sentence.   This  is an
 
6774
uninteresting                            sentence.
 
6775
This is an uninteresting sentence.
 
6776
@endExample
 
6777
@endDefreq
 
6778
 
 
6779
@DefreqList {ss, word_space_size [@Var{sentence_space_size}]}
 
6780
@DefregItem {.ss}
 
6781
@DefregListEnd {.sss}
 
6782
@cindex word space size register (@code{.ss})
 
6783
@cindex size of word space register (@code{.ss})
 
6784
@cindex space between words register (@code{.ss})
 
6785
@cindex sentence space size register (@code{.sss})
 
6786
@cindex size of sentence space register (@code{.sss})
 
6787
@cindex space between sentences register (@code{.sss})
 
6788
Change the size of a space between words.  It takes its units as one
 
6789
twelfth of the space width parameter for the current font.  Initially
 
6790
both the @var{word_space_size} and @var{sentence_space_size}
 
6791
are@tie{}12.  In fill mode, the values specify the minimum distance.
 
6792
 
 
6793
@cindex fill mode
 
6794
@cindex mode, fill
 
6795
If two arguments are given to the @code{ss} request, the second argument
 
6796
sets the sentence space size.  If the second argument is not given,
 
6797
sentence space size is set to @var{word_space_size}.  The sentence space
 
6798
size is used in two circumstances: If the end of a sentence occurs at
 
6799
the end of a line in fill mode, then both an inter-word space and a
 
6800
sentence space are added; if two spaces follow the end of a sentence in
 
6801
the middle of a line, then the second space is a sentence space.  If a
 
6802
second argument is never given to the @code{ss} request, the behaviour
 
6803
of @acronym{UNIX} @code{troff} is the same as that exhibited by GNU
 
6804
@code{troff}.  In GNU @code{troff}, as in @acronym{UNIX} @code{troff}, a
 
6805
sentence should always be followed by either a newline or two spaces.
 
6806
 
 
6807
The read-only number registers @code{.ss} and @code{.sss} hold the
 
6808
values of the parameters set by the first and second arguments of the
 
6809
@code{ss} request.
 
6810
 
 
6811
The word space and sentence space values are associated with the current
 
6812
environment (@pxref{Environments}).
 
6813
 
 
6814
Contrary to @acronym{AT&T} @code{troff}, this request is @emph{not}
 
6815
ignored if a TTY output device is used; the given values are then
 
6816
rounded down to a multiple of@tie{}12 (@pxref{Implementation
 
6817
Differences}).
 
6818
 
 
6819
The request is ignored if there is no parameter.
 
6820
 
 
6821
@cindex discardable horizontal space
 
6822
@cindex space, discardable, horizontal
 
6823
@cindex horizontal discardable space
 
6824
Another useful application of the @code{ss} request is to insert
 
6825
discardable horizontal space, i.e., space which is discarded at a line
 
6826
break.  For example, paragraph-style footnotes could be separated this
 
6827
way:
 
6828
 
 
6829
@Example
 
6830
.ll 4.5i
 
6831
1.\ This is the first footnote.\c
 
6832
.ss 48
 
6833
.nop
 
6834
.ss 12
 
6835
2.\ This is the second footnote.
 
6836
@endExample
 
6837
 
 
6838
@noindent
 
6839
The result:
 
6840
 
 
6841
@Example
 
6842
1. This is the first footnote.        2. This
 
6843
is the second footnote.
 
6844
@endExample
 
6845
 
 
6846
@noindent
 
6847
Note that the @code{\h} escape produces unbreakable space.
 
6848
@endDefreq
 
6849
 
 
6850
@DefreqList {ce, [@Var{nnn}]}
 
6851
@DefregListEnd {.ce}
 
6852
@cindex centering lines (@code{ce})
 
6853
@cindex lines, centering (@code{ce})
 
6854
Center text.  While the @w{@samp{.ad c}} request also centers text, it
 
6855
fills the text as well.  @code{ce} does not fill the text it affects.
 
6856
This request causes a break.  The number of lines still to be centered
 
6857
is associated with the current environment (@pxref{Environments}).
 
6858
 
 
6859
The following example demonstrates the differences.  Here the input:
 
6860
 
 
6861
@Example
 
6862
.ll 4i
 
6863
.ce 1000
 
6864
This is a small text fragment which shows the differences
 
6865
between the `.ce' and the `.ad c' request.
 
6866
.ce 0
 
6867
 
 
6868
.ad c
 
6869
This is a small text fragment which shows the differences
 
6870
between the `.ce' and the `.ad c' request.
 
6871
@endExample
 
6872
 
 
6873
@noindent
 
6874
And here the result:
 
6875
 
 
6876
@Example
 
6877
  This is a small text fragment which
 
6878
         shows the differences
 
6879
between the `.ce' and the `.ad c' request.
 
6880
 
 
6881
  This is a small text fragment which
 
6882
shows the differences between the `.ce'
 
6883
        and the `.ad c' request.
 
6884
@endExample
 
6885
 
 
6886
With no arguments, @code{ce} centers the next line of text.  @var{nnn}
 
6887
specifies the number of lines to be centered.  If the argument is zero
 
6888
or negative, centering is disabled.
 
6889
 
 
6890
The basic length for centering text is the line length (as set with the
 
6891
@code{ll} request) minus the indentation (as set with the @code{in}
 
6892
request).  Temporary indentation is ignored.
 
6893
 
 
6894
As can be seen in the previous example, it is a common idiom to turn on
 
6895
centering for a large number of lines, and to turn off centering after
 
6896
text to be centered.  This is useful for any request which takes a
 
6897
number of lines as an argument.
 
6898
 
 
6899
The @code{.ce} read-only number register contains the number of lines
 
6900
remaining to be centered, as set by the @code{ce} request.
 
6901
@endDefreq
 
6902
 
 
6903
@DefreqList {rj, [@Var{nnn}]}
 
6904
@DefregListEnd {.rj}
 
6905
@cindex justifying text (@code{rj})
 
6906
@cindex text, justifying (@code{rj})
 
6907
@cindex right-justifying (@code{rj})
 
6908
Justify unfilled text to the right margin.  Arguments are identical to
 
6909
the @code{ce} request.  The @code{.rj} read-only number register is the
 
6910
number of lines to be right-justified as set by the @code{rj} request.
 
6911
This request causes a break.  The number of lines still to be
 
6912
right-justified is associated with the current environment
 
6913
(@pxref{Environments}).
 
6914
@endDefreq
 
6915
 
 
6916
 
 
6917
@c =====================================================================
 
6918
 
 
6919
@node Manipulating Hyphenation, Manipulating Spacing, Manipulating Filling and Adjusting, gtroff Reference
 
6920
@section Manipulating Hyphenation
 
6921
@cindex manipulating hyphenation
 
6922
@cindex hyphenation, manipulating
 
6923
 
 
6924
Here a description of requests which influence hyphenation.
 
6925
 
 
6926
@DefreqList {hy, [@Var{mode}]}
 
6927
@DefregListEnd {.hy}
 
6928
Enable hyphenation.  The request has an optional numeric argument,
 
6929
@var{mode}, to restrict hyphenation if necessary:
 
6930
 
 
6931
@table @code
 
6932
@item 1
 
6933
The default argument if @var{mode} is omitted.  Hyphenate without
 
6934
restrictions.  This is also the start-up value of @code{gtroff}.
 
6935
 
 
6936
@item 2
 
6937
Do not hyphenate the last word on a page or column.
 
6938
 
 
6939
@item 4
 
6940
Do not hyphenate the last two characters of a word.
 
6941
 
 
6942
@item 8
 
6943
Do not hyphenate the first two characters of a word.
 
6944
@end table
 
6945
 
 
6946
Values in the previous table are additive.  For example, the
 
6947
value@tie{}12 causes @code{gtroff} to neither hyphenate the last two nor
 
6948
the first two characters of a word.
 
6949
 
 
6950
@cindex hyphenation restrictions register (@code{.hy})
 
6951
The current hyphenation restrictions can be found in the read-only
 
6952
number register @samp{.hy}.
 
6953
 
 
6954
The hyphenation mode is associated with the current environment
 
6955
(@pxref{Environments}).
 
6956
@endDefreq
 
6957
 
 
6958
@Defreq {nh, }
 
6959
Disable hyphenation (i.e., set the hyphenation mode to zero).  Note that
 
6960
the hyphenation mode of the last call to @code{hy} is not remembered.
 
6961
 
 
6962
The hyphenation mode is associated with the current environment
 
6963
(@pxref{Environments}).
 
6964
@endDefreq
 
6965
 
 
6966
@DefreqList {hlm, [@Var{nnn}]}
 
6967
@DefregItem {.hlm}
 
6968
@DefregListEnd {.hlc}
 
6969
@cindex explicit hyphen (@code{\%})
 
6970
@cindex hyphen, explicit (@code{\%})
 
6971
@cindex consecutive hyphenated lines (@code{hlm})
 
6972
@cindex lines, consecutive hyphenated (@code{hlm})
 
6973
@cindex hyphenated lines, consecutive (@code{hlm})
 
6974
Set the maximum number of consecutive hyphenated lines to @var{nnn}.  If
 
6975
this number is negative, there is no maximum.  The default value
 
6976
is@tie{}@minus{}1 if @var{nnn} is omitted.  This value is associated
 
6977
with the current environment (@pxref{Environments}).  Only lines output
 
6978
from a given environment count towards the maximum associated with that
 
6979
environment.  Hyphens resulting from @code{\%} are counted; explicit
 
6980
hyphens are not.
 
6981
 
 
6982
The current setting of @code{hlm} is available in the @code{.hlm}
 
6983
read-only number register.  Also the number of immediately preceding
 
6984
consecutive hyphenated lines are available in the read-only number
 
6985
register @samp{.hlc}.
 
6986
@endDefreq
 
6987
 
 
6988
@Defreq {hw, word1 word2 @dots{}}
 
6989
Define how @var{word1}, @var{word2}, etc.@: are to be hyphenated.  The
 
6990
words must be given with hyphens at the hyphenation points.  For
 
6991
example:
 
6992
 
 
6993
@Example
 
6994
.hw in-sa-lub-rious
 
6995
@endExample
 
6996
 
 
6997
@noindent
 
6998
Besides the space character, any character whose hyphenation code value
 
6999
is zero can be used to separate the arguments of @code{hw} (see the
 
7000
documentation for the @code{hcode} request below for more information).
 
7001
In addition, this request can be used more than once.
 
7002
 
 
7003
Hyphenation exceptions specified with the @code{hw} request are
 
7004
associated with the current hyphenation language; it causes an error if
 
7005
there is no current hyphenation language.
 
7006
 
 
7007
This request is ignored if there is no parameter.
 
7008
 
 
7009
In old versions of @code{troff} there was a limited amount of space to
 
7010
store such information; fortunately, with @code{gtroff}, this is no
 
7011
longer a restriction.
 
7012
@endDefreq
 
7013
 
 
7014
@DefescList {\\%, , , }
 
7015
@deffnx Escape @t{\:}
 
7016
@ifnotinfo
 
7017
@esindex \:
 
7018
@end ifnotinfo
 
7019
@ifinfo
 
7020
@esindex \@r{<colon>}
 
7021
@end ifinfo
 
7022
@cindex hyphenation character (@code{\%})
 
7023
@cindex character, hyphenation (@code{\%})
 
7024
@cindex disabling hyphenation (@code{\%})
 
7025
@cindex hyphenation, disabling (@code{\%})
 
7026
To tell @code{gtroff} how to hyphenate words on the fly, use the
 
7027
@code{\%} escape, also known as the @dfn{hyphenation character}.
 
7028
Preceding a word with this character prevents it from being
 
7029
hyphenated; putting it inside a word indicates to @code{gtroff} that
 
7030
the word may be hyphenated at that point.  Note that this mechanism
 
7031
only affects that one occurrence of the word; to change the
 
7032
hyphenation of a word for the entire document, use the @code{hw}
 
7033
request.
 
7034
 
 
7035
The @code{\:} escape inserts a zero-width break point (that is, the word
 
7036
breaks but without adding a hyphen).
 
7037
 
 
7038
@Example
 
7039
... check the /var/log/\:httpd/\:access_log file ...
 
7040
@endExample
 
7041
 
 
7042
@cindex @code{\X}, followed by @code{\%}
 
7043
@cindex @code{\Y}, followed by @code{\%}
 
7044
@cindex @code{\%}, following @code{\X} or @code{\Y}
 
7045
Note that @code{\X} and @code{\Y} start a word, that is, the @code{\%}
 
7046
escape in (say) @w{@samp{\X'...'\%foobar}} and
 
7047
@w{@samp{\Y'...'\%foobar}} no longer prevents hyphenation but inserts a
 
7048
hyphenation point at the beginning of @samp{foobar}; most likely this
 
7049
isn't what you want to do.
 
7050
@endDefesc
 
7051
 
 
7052
@Defreq {hc, [@Var{char}]}
 
7053
Change the hyphenation character to @var{char}.  This character then
 
7054
works the same as the @code{\%} escape, and thus, no longer appears in
 
7055
the output.  Without an argument, @code{hc} resets the hyphenation
 
7056
character to be @code{\%} (the default) only.
 
7057
 
 
7058
The hyphenation character is associated with the current environment
 
7059
(@pxref{Environments}).
 
7060
@endDefreq
 
7061
 
 
7062
@DefreqList {hpf, pattern_file}
 
7063
@DefreqItem {hpfa, pattern_file}
 
7064
@DefreqListEnd {hpfcode, a b [c d @dots{}]}
 
7065
@cindex hyphenation patterns (@code{hpf})
 
7066
@cindex patterns for hyphenation (@code{hpf})
 
7067
Read in a file of hyphenation patterns.  This file is searched for in
 
7068
the same way as @file{@var{name}.tmac} (or @file{tmac.@var{name}}) is
 
7069
searched for if the @option{-m@var{name}} option is specified.
 
7070
 
 
7071
It should have the same format as (simple) @TeX{} patterns files.  More
 
7072
specifically, the following scanning rules are implemented.
 
7073
 
 
7074
@itemize @bullet
 
7075
@item
 
7076
A percent sign starts a comment (up to the end of the line) even if
 
7077
preceded by a backslash.
 
7078
 
 
7079
@item
 
7080
No support for `digraphs' like @code{\$}.
 
7081
 
 
7082
@item
 
7083
@code{^^@var{xx}} (@var{x} is 0-9 or a-f) and @code{^^@var{x}}
 
7084
(character code of @var{x} in the range 0-127) are recognized; other use
 
7085
of @code{^} causes an error.
 
7086
 
 
7087
@item
 
7088
No macro expansion.
 
7089
 
 
7090
@item
 
7091
@code{hpf} checks for the expression @code{\patterns@{@dots{}@}}
 
7092
(possibly with whitespace before and after the braces).  Everything
 
7093
between the braces is taken as hyphenation patterns.  Consequently,
 
7094
@code{@{} and @code{@}} are not allowed in patterns.
 
7095
 
 
7096
@item
 
7097
Similarly, @code{\hyphenation@{@dots{}@}} gives a list of hyphenation
 
7098
exceptions.
 
7099
 
 
7100
@item
 
7101
@code{\endinput} is recognized also.
 
7102
 
 
7103
@item
 
7104
For backwards compatibility, if @code{\patterns} is missing, the whole
 
7105
file is treated as a list of hyphenation patterns (only recognizing the
 
7106
@code{%} character as the start of a comment).
 
7107
@end itemize
 
7108
 
 
7109
If no @code{hpf} request is specified (either in the document or in a
 
7110
macro package), @code{gtroff} won't hyphenate at all.
 
7111
 
 
7112
The @code{hpfa} request appends a file of patterns to the current list.
 
7113
 
 
7114
The @code{hpfcode} request defines mapping values for character codes in
 
7115
hyphenation patterns.  @code{hpf} or @code{hpfa} then apply the mapping
 
7116
(after reading the patterns) before replacing or appending them to the
 
7117
current list of patterns.  Its arguments are pairs of character codes --
 
7118
integers from 0 to@tie{}255.  The request maps character
 
7119
code@tie{}@var{a} to code@tie{}@var{b}, code@tie{}@var{c} to
 
7120
code@tie{}@var{d}, and so on.  You can use character codes which would
 
7121
be invalid otherwise.  By default, everything maps to itself except
 
7122
letters `A' to `Z' which map to `a' to `z'.
 
7123
 
 
7124
 
 
7125
@pindex troffrc
 
7126
@pindex troffrc-end
 
7127
@pindex hyphen.us
 
7128
@pindex hyphenex.us
 
7129
The set of hyphenation patterns is associated with the current language
 
7130
set by the @code{hla} request.  The @code{hpf} request is usually
 
7131
invoked by the @file{troffrc} or @file{troffrc-end} file; by default,
 
7132
@file{troffrc} loads hyphenation patterns and exceptions for American
 
7133
English (in files @file{hyphen.us} and @file{hyphenex.us}).
 
7134
 
 
7135
A second call to @code{hpf} (for the same language) replaces the
 
7136
hyphenation patterns with the new ones.
 
7137
 
 
7138
Invoking @code{hpf} causes an error if there is no current hyphenation
 
7139
language.
 
7140
@endDefreq
 
7141
 
 
7142
@Defreq {hcode, c1 code1 [c2 code2 @dots{}]}
 
7143
@cindex hyphenation code (@code{hcode})
 
7144
@cindex code, hyphenation (@code{hcode})
 
7145
Set the hyphenation code of character @var{c1} to @var{code1}, that of
 
7146
@var{c2} to @var{code2}, etc.  A hyphenation code must be a single input
 
7147
character (not a special character) other than a digit or a space.
 
7148
 
 
7149
To make hyphenation work, hyphenation codes must be set up.  At
 
7150
start-up, groff only assigns hyphenation codes to the letters
 
7151
@samp{a}-@samp{z} (mapped to themselves) and to the letters
 
7152
@samp{A}-@samp{Z} (mapped to @samp{a}-@samp{z}); all other hyphenation
 
7153
codes are set to zero.  Normally, hyphenation patterns contain only
 
7154
lowercase letters which should be applied regardless of case.  In
 
7155
other words, the words `FOO' and `Foo' should be hyphenated exactly the
 
7156
same way as the word `foo' is hyphenated, and this is what @code{hcode}
 
7157
is good for.  Words which contain other letters won't be hyphenated
 
7158
properly if the corresponding hyphenation patterns actually do contain
 
7159
them.  For example, the following @code{hcode} requests are necessary to
 
7160
assign hyphenation codes to the letters @samp{�������} (this is needed
 
7161
for German):
 
7162
 
 
7163
@Example
 
7164
.hcode � �  � �
 
7165
.hcode � �  � �
 
7166
.hcode � �  � �
 
7167
.hcode � �
 
7168
@endExample
 
7169
 
 
7170
Without those assignments, groff treats German words like
 
7171
@w{`Kinderg�rten'} (the plural form of `kindergarten') as two substrings
 
7172
@w{`kinderg'} and @w{`rten'} because the hyphenation code of the
 
7173
umlaut@tie{}a is zero by default.  There is a German hyphenation pattern
 
7174
which covers @w{`kinder'}, so groff finds the hyphenation `kin-der'.
 
7175
The other two hyphenation points (`kin-der-g�r-ten') are missed.
 
7176
 
 
7177
This request is ignored if it has no parameter.
 
7178
@endDefreq
 
7179
 
 
7180
@DefreqList {hym, [@Var{length}]}
 
7181
@DefregListEnd {.hym}
 
7182
@cindex hyphenation margin (@code{hym})
 
7183
@cindex margin for hyphenation (@code{hym})
 
7184
@cindex @code{ad} request, and hyphenation margin
 
7185
Set the (right) hyphenation margin to @var{length}.  If the current
 
7186
adjustment mode is not @samp{b} or @samp{n}, the line is not hyphenated
 
7187
if it is shorter than @var{length}.  Without an argument, the
 
7188
hyphenation margin is reset to its default value, which is@tie{}0.  The
 
7189
default scaling indicator for this request is @samp{m}.  The hyphenation
 
7190
margin is associated with the current environment
 
7191
(@pxref{Environments}).
 
7192
 
 
7193
A negative argument resets the hyphenation margin to zero, emitting a
 
7194
warning of type @samp{range}.
 
7195
 
 
7196
@cindex hyphenation margin register (@code{.hym})
 
7197
The current hyphenation margin is available in the @code{.hym} read-only
 
7198
number register.
 
7199
@endDefreq
 
7200
 
 
7201
@DefreqList {hys, [@Var{hyphenation_space}]}
 
7202
@DefregListEnd {.hys}
 
7203
@cindex hyphenation space (@code{hys})
 
7204
@cindex @code{ad} request, and hyphenation space
 
7205
Set the hyphenation space to @var{hyphenation_space}.  If the current
 
7206
adjustment mode is @samp{b} or @samp{n}, don't hyphenate the line if it
 
7207
can be justified by adding no more than @var{hyphenation_space} extra
 
7208
space to each word space.  Without argument, the hyphenation space is
 
7209
set to its default value, which is@tie{}0.  The default scaling
 
7210
indicator for this request is @samp{m}.  The hyphenation space is
 
7211
associated with the current environment (@pxref{Environments}).
 
7212
 
 
7213
A negative argument resets the hyphenation space to zero, emitting a
 
7214
warning of type @samp{range}.
 
7215
 
 
7216
@cindex hyphenation space register (@code{.hys})
 
7217
The current hyphenation space is available in the @code{.hys} read-only
 
7218
number register.
 
7219
@endDefreq
 
7220
 
 
7221
@Defreq {shc, [@Var{glyph}]}
 
7222
@cindex soft hyphen character, setting (@code{shc})
 
7223
@cindex character, soft hyphen, setting (@code{shc})
 
7224
@cindex glyph, soft hyphen (@code{hy})
 
7225
@cindex soft hyphen glyph (@code{hy})
 
7226
@cindex @code{char} request, and soft hyphen character
 
7227
@cindex @code{tr} request, and soft hyphen character
 
7228
Set the @dfn{soft hyphen character} to @var{glyph}.@footnote{@dfn{Soft
 
7229
hyphen character} is a misnomer since it is an output glyph.}  If the
 
7230
argument is omitted, the soft hyphen character is set to the default
 
7231
glyph @code{\(hy} (this is the start-up value of @code{gtroff} also).
 
7232
The soft hyphen character is the glyph that is inserted when a word is
 
7233
hyphenated at a line break.  If the soft hyphen character does not exist
 
7234
in the font of the character immediately preceding a potential break
 
7235
point, then the line is not broken at that point.  Neither definitions
 
7236
(specified with the @code{char} request) nor translations (specified
 
7237
with the @code{tr} request) are considered when finding the soft hyphen
 
7238
character.
 
7239
@endDefreq
 
7240
 
 
7241
@DefreqList {hla, language}
 
7242
@DefregListEnd {.hla}
 
7243
@cindex @code{hpf} request, and hyphenation language
 
7244
@cindex @code{hw} request, and hyphenation language
 
7245
@pindex troffrc
 
7246
@pindex troffrc-end
 
7247
Set the current hyphenation language to the string @var{language}.
 
7248
Hyphenation exceptions specified with the @code{hw} request and
 
7249
hyphenation patterns specified with the @code{hpf} and @code{hpfa}
 
7250
requests are both associated with the current hyphenation language.  The
 
7251
@code{hla} request is usually invoked by the @file{troffrc} or the
 
7252
@file{troffrc-end} files; @file{troffrc} sets the default language to
 
7253
@samp{us}.
 
7254
 
 
7255
@cindex hyphenation language register (@code{.hla})
 
7256
The current hyphenation language is available as a string in the
 
7257
read-only number register @samp{.hla}.
 
7258
 
 
7259
@Example
 
7260
.ds curr_language \n[.hla]
 
7261
\*[curr_language]
 
7262
    @result{} us
 
7263
@endExample
 
7264
@endDefreq
 
7265
 
 
7266
 
 
7267
@c =====================================================================
 
7268
 
 
7269
@node Manipulating Spacing, Tabs and Fields, Manipulating Hyphenation, gtroff Reference
 
7270
@section Manipulating Spacing
 
7271
@cindex manipulating spacing
 
7272
@cindex spacing, manipulating
 
7273
 
 
7274
@Defreq {sp, [@Var{distance}]}
 
7275
Space downwards @var{distance}.  With no argument it advances
 
7276
1@tie{}line.  A negative argument causes @code{gtroff} to move up the
 
7277
page the specified distance.  If the argument is preceded by a @samp{|}
 
7278
then @code{gtroff} moves that distance from the top of the page.  This
 
7279
request causes a line break, and that adds the current line spacing to
 
7280
the space you have just specified.  The default scaling indicator is
 
7281
@samp{v}.
 
7282
 
 
7283
For convenience you may wish to use the following macros to set the
 
7284
height of the next line at a given distance from the top or the bottom
 
7285
of the page:
 
7286
 
 
7287
@Example
 
7288
.de y-from-top-down
 
7289
.  sp |\\$1-\\n[.v]u
 
7290
..
 
7291
.
 
7292
.de y-from-bot-up
 
7293
.  sp |\\n[.p]u-\\$1-\\n[.v]u
 
7294
..
 
7295
@endExample
 
7296
 
 
7297
@noindent
 
7298
A call to @samp{.y-from-bot-up 10c} means that the bottom of the next
 
7299
line will be at 10@dmn{cm} from the paper edge at the bottom.
 
7300
 
 
7301
If a vertical trap is sprung during execution of @code{sp}, the amount
 
7302
of vertical space after the trap is discarded.  For example, this
 
7303
 
 
7304
@Example
 
7305
.de xxx
 
7306
..
 
7307
.
 
7308
.wh 0 xxx
 
7309
.
 
7310
.pl 5v
 
7311
foo
 
7312
.sp 2
 
7313
bar
 
7314
.sp 50
 
7315
baz
 
7316
@endExample
 
7317
 
 
7318
@noindent
 
7319
results in
 
7320
 
 
7321
@Example
 
7322
foo
 
7323
 
 
7324
 
 
7325
bar
 
7326
 
 
7327
baz
 
7328
@endExample
 
7329
 
 
7330
@cindex @code{sp} request, and traps
 
7331
@cindex discarded space in traps
 
7332
@cindex space, discarded, in traps
 
7333
@cindex traps, and discarded space
 
7334
The amount of discarded space is available in the number register
 
7335
@code{.trunc}.
 
7336
 
 
7337
To protect @code{sp} against vertical traps, use the @code{vpt} request:
 
7338
 
 
7339
@Example
 
7340
.vpt 0
 
7341
.sp -3
 
7342
.vpt 1
 
7343
@endExample
 
7344
@endDefreq
 
7345
 
 
7346
@DefreqList {ls, [@Var{nnn}]}
 
7347
@DefregListEnd {.L}
 
7348
@cindex double-spacing (@code{ls})
 
7349
Output @w{@var{nnn}@minus{}1} blank lines after each line of text.  With
 
7350
no argument, @code{gtroff} uses the previous value before the last
 
7351
@code{ls} call.
 
7352
 
 
7353
@Example
 
7354
.ls 2    \" This causes double-spaced output
 
7355
.ls 3    \" This causes triple-spaced output
 
7356
.ls      \" Again double-spaced
 
7357
@endExample
 
7358
 
 
7359
The line spacing is associated with the current environment
 
7360
(@pxref{Environments}).
 
7361
 
 
7362
@cindex line spacing register (@code{.L})
 
7363
The read-only number register @code{.L} contains the current line
 
7364
spacing setting.
 
7365
@endDefreq
 
7366
 
 
7367
@xref{Changing Type Sizes}, for the requests @code{vs} and @code{pvs} as
 
7368
alternatives to @code{ls}.
 
7369
 
 
7370
@DefescList {\\x, ', spacing, '}
 
7371
@DefregListEnd {.a}
 
7372
Sometimes, extra vertical spacing is only needed occasionally, e.g.@: to
 
7373
allow space for a tall construct (like an equation).  The @code{\x}
 
7374
escape does this.  The escape is given a numerical argument, usually
 
7375
enclosed in quotes (like @samp{\x'3p'}); the default scaling indicator
 
7376
is @samp{v}.  If this number is positive extra vertical space is
 
7377
inserted below the current line.  A negative number adds space above.
 
7378
If this escape is used multiple times on the same line, the maximum of
 
7379
the values is used.
 
7380
 
 
7381
@xref{Escapes}, for details on parameter delimiting characters.
 
7382
 
 
7383
@cindex extra post-vertical line space register (@code{.a})
 
7384
The @code{.a} read-only number register contains the most recent
 
7385
(nonnegative) extra vertical line space.
 
7386
 
 
7387
Using @code{\x} can be necessary in combination with the @code{\b}
 
7388
escape, as the following example shows.
 
7389
 
 
7390
@Example
 
7391
This is a test with the \[rs]b escape.
 
7392
.br
 
7393
This is a test with the \[rs]b escape.
 
7394
.br
 
7395
This is a test with \b'xyz'\x'-1m'\x'1m'.
 
7396
.br
 
7397
This is a test with the \[rs]b escape.
 
7398
.br
 
7399
This is a test with the \[rs]b escape.
 
7400
@endExample
 
7401
 
 
7402
@noindent
 
7403
produces
 
7404
 
 
7405
@Example
 
7406
This is a test with the \b escape.
 
7407
This is a test with the \b escape.
 
7408
                    x
 
7409
This is a test with y.
 
7410
                    z
 
7411
This is a test with the \b escape.
 
7412
This is a test with the \b escape.
 
7413
@endExample
 
7414
@endDefesc
 
7415
 
 
7416
@DefreqList {ns, }
 
7417
@DefreqItem {rs, }
 
7418
@DefregListEnd {.ns}
 
7419
@cindex @code{sp} request, and no-space mode
 
7420
@cindex no-space mode (@code{ns})
 
7421
@cindex mode, no-space (@code{ns})
 
7422
@cindex blank lines, disabling
 
7423
@cindex lines, blank, disabling
 
7424
Enable @dfn{no-space mode}.  In this mode, spacing (either via @code{sp}
 
7425
or via blank lines) is disabled.  The @code{bp} request to advance to
 
7426
the next page is also disabled, except if it is accompanied by a page
 
7427
number (see @ref{Page Control}, for more information).  This mode ends
 
7428
when actual text is output or the @code{rs} request is encountered which
 
7429
ends no-space mode.  The read-only number register @code{.ns} is set
 
7430
to@tie{}1 as long as no-space mode is active.
 
7431
 
 
7432
This request is useful for macros that conditionally insert vertical
 
7433
space before the text starts (for example, a paragraph macro could
 
7434
insert some space except when it is the first paragraph after a section
 
7435
header).
 
7436
@endDefreq
 
7437
 
 
7438
 
 
7439
@c =====================================================================
 
7440
 
 
7441
@node Tabs and Fields, Character Translations, Manipulating Spacing, gtroff Reference
 
7442
@section Tabs and Fields
 
7443
@cindex tabs, and fields
 
7444
@cindex fields, and tabs
 
7445
 
 
7446
@cindex @acronym{EBCDIC} encoding of a tab
 
7447
A tab character (@acronym{ASCII} char@tie{}9, @acronym{EBCDIC}
 
7448
char@tie{}5) causes a horizontal movement to the next tab stop (much
 
7449
like it did on a typewriter).
 
7450
 
 
7451
@Defesc {\\t, , , }
 
7452
@cindex tab character, non-interpreted (@code{\t})
 
7453
@cindex character, tab, non-interpreted (@code{\t})
 
7454
@cindex @code{\t}, and copy-in mode
 
7455
@cindex copy-in mode, and @code{\t}
 
7456
@cindex mode, copy-in, and @code{\t}
 
7457
This escape is a non-interpreted tab character.  In copy mode
 
7458
(@pxref{Copy-in Mode}), @code{\t} is the same as a real tab character.
 
7459
@endDefesc
 
7460
 
 
7461
@DefreqList {ta, [@Var{n1} @Var{n2} @dots{} @Var{nn} @t{T} @Var{r1} @Var{r2} @dots{} @Var{rn}]}
 
7462
@DefregListEnd {.tabs}
 
7463
Change tab stop positions.  This request takes a series of tab
 
7464
specifiers as arguments (optionally divided into two groups with the
 
7465
letter @samp{T}) which indicate where each tab stop is to be (overriding
 
7466
any previous settings).
 
7467
 
 
7468
Tab stops can be specified absolutely, i.e., as the distance from the
 
7469
left margin.  For example, the following sets 6@tie{}tab stops every one
 
7470
inch.
 
7471
 
 
7472
@Example
 
7473
.ta 1i 2i 3i 4i 5i 6i
 
7474
@endExample
 
7475
 
 
7476
Tab stops can also be specified using a leading @samp{+} which means
 
7477
that the specified tab stop is set relative to the previous tab stop.
 
7478
For example, the following is equivalent to the previous example.
 
7479
 
 
7480
@Example
 
7481
.ta 1i +1i +1i +1i +1i +1i
 
7482
@endExample
 
7483
 
 
7484
@code{gtroff} supports an extended syntax to specify repeat values after
 
7485
the @samp{T} mark (these values are always taken as relative) -- this is
 
7486
the usual way to specify tabs set at equal intervals.  The following is,
 
7487
yet again, the same as the previous examples.  It does even more since
 
7488
it defines an infinite number of tab stops separated by one inch.
 
7489
 
 
7490
@Example
 
7491
.ta T 1i
 
7492
@endExample
 
7493
 
 
7494
Now we are ready to interpret the full syntax given at the beginning:
 
7495
Set tabs at positions @var{n1}, @var{n2}, @dots{}, @var{nn} and then set
 
7496
tabs at @var{nn}+@var{r1}, @var{nn}+@var{r2}, @dots{}, @var{nn}+@var{rn}
 
7497
and then at @var{nn}+@var{rn}+@var{r1}, @var{nn}+@var{rn}+@var{r2},
 
7498
@dots{}, @var{nn}+@var{rn}+@var{rn}, and so on.
 
7499
 
 
7500
Example: @samp{4c +6c T 3c 5c 2c} is equivalent to @samp{4c 10c 13c 18c
 
7501
20c 23c 28c 30c @dots{}}.
 
7502
 
 
7503
The material in each tab column (i.e., the column between two tab stops)
 
7504
may be justified to the right or left or centered in the column.  This
 
7505
is specified by appending @samp{R}, @samp{L}, or @samp{C} to the tab
 
7506
specifier.  The default justification is @samp{L}.  Example:
 
7507
 
 
7508
@Example
 
7509
.ta 1i 2iC 3iR
 
7510
@endExample
 
7511
 
 
7512
Some notes:
 
7513
 
 
7514
@itemize @bullet
 
7515
@item
 
7516
The default unit of the @code{ta} request is @samp{m}.
 
7517
 
 
7518
@item
 
7519
A tab stop is converted into a non-breakable horizontal movement which
 
7520
can be neither stretched nor squeezed.  For example,
 
7521
 
 
7522
@Example
 
7523
.ds foo a\tb\tc
 
7524
.ta T 5i
 
7525
\*[foo]
 
7526
@endExample
 
7527
 
 
7528
@noindent
 
7529
creates a single line which is a bit longer than 10@tie{}inches (a
 
7530
string is used to show exactly where the tab characters are).  Now
 
7531
consider the following:
 
7532
 
 
7533
@Example
 
7534
.ds bar a\tb b\tc
 
7535
.ta T 5i
 
7536
\*[bar]
 
7537
@endExample
 
7538
 
 
7539
@noindent
 
7540
@code{gtroff} first converts the tab stops of the line into unbreakable
 
7541
horizontal movements, then splits the line after the second @samp{b}
 
7542
(assuming a sufficiently short line length).  Usually, this isn't what
 
7543
the user wants.
 
7544
 
 
7545
@item
 
7546
Superfluous tabs (i.e., tab characters which do not correspond to a tab
 
7547
stop) are ignored except the first one which delimits the characters
 
7548
belonging to the last tab stop for right-justifying or centering.
 
7549
Consider the following example
 
7550
 
 
7551
@Example
 
7552
.ds Z   foo\tbar\tfoo
 
7553
.ds ZZ  foo\tbar\tfoobar
 
7554
.ds ZZZ foo\tbar\tfoo\tbar
 
7555
.ta 2i 4iR
 
7556
\*[Z]
 
7557
.br
 
7558
\*[ZZ]
 
7559
.br
 
7560
\*[ZZZ]
 
7561
.br
 
7562
@endExample
 
7563
 
 
7564
@noindent
 
7565
which produces the following output:
 
7566
 
 
7567
@Example
 
7568
foo                 bar              foo
 
7569
foo                 bar           foobar
 
7570
foo                 bar              foobar
 
7571
@endExample
 
7572
 
 
7573
@noindent
 
7574
The first line right-justifies the second `foo' relative to the tab
 
7575
stop.  The second line right-justifies `foobar'.  The third line finally
 
7576
right-justifies only `foo' because of the additional tab character which
 
7577
marks the end of the string belonging to the last defined tab stop.
 
7578
 
 
7579
@item
 
7580
Tab stops are associated with the current environment
 
7581
(@pxref{Environments}).
 
7582
 
 
7583
@item
 
7584
Calling @code{ta} without an argument removes all tab stops.
 
7585
 
 
7586
@item
 
7587
@cindex tab stops, for TTY output devices
 
7588
The start-up value of @code{gtroff} is @w{@samp{T 0.8i}}.
 
7589
@end itemize
 
7590
 
 
7591
@cindex tab settings register (@code{.tabs})
 
7592
The read-only number register @code{.tabs} contains a string
 
7593
representation of the current tab settings suitable for use as an
 
7594
argument to the @code{ta} request.
 
7595
 
 
7596
@Example
 
7597
.ds tab-string \n[.tabs]
 
7598
\*[tab-string]
 
7599
    @result{} T120u
 
7600
@endExample
 
7601
 
 
7602
@cindex @code{.S} register, Plan@tie{}9 alias for @code{.tabs}
 
7603
@cindex @code{.tabs} register, Plan@tie{}9 alias (@code{.S})
 
7604
The @code{troff} version of the Plan@tie{}9 operating system uses
 
7605
register @code{.S} for the same purpose.
 
7606
@endDefreq
 
7607
 
 
7608
@Defreq {tc, [@Var{fill-glyph}]}
 
7609
@cindex tab repetition character (@code{tc})
 
7610
@cindex character, tab repetition (@code{tc})
 
7611
@cindex glyph, tab repetition (@code{tc})
 
7612
Normally @code{gtroff} fills the space to the next tab stop with
 
7613
whitespace.  This can be changed with the @code{tc} request.  With no
 
7614
argument @code{gtroff} reverts to using whitespace, which is the
 
7615
default.  The value of this @dfn{tab repetition character} is associated
 
7616
with the current environment (@pxref{Environments}).@footnote{@dfn{Tab
 
7617
repetition character} is a misnomer since it is an output glyph.}
 
7618
@endDefreq
 
7619
 
 
7620
@DefreqList {linetabs, n}
 
7621
@DefregListEnd {.linetabs}
 
7622
@cindex tab, line-tabs mode
 
7623
@cindex line-tabs mode
 
7624
@cindex mode, line-tabs
 
7625
If @var{n} is missing or not zero, enable @dfn{line-tabs} mode, or
 
7626
disable it otherwise (the default).  In line-tabs mode, @code{gtroff}
 
7627
computes tab distances relative to the (current) output line instead of
 
7628
the input line.
 
7629
 
 
7630
For example, the following code:
 
7631
 
 
7632
@Example
 
7633
.ds x a\t\c
 
7634
.ds y b\t\c
 
7635
.ds z c
 
7636
.ta 1i 3i
 
7637
\*x
 
7638
\*y
 
7639
\*z
 
7640
@endExample
 
7641
 
 
7642
@noindent
 
7643
in normal mode, results in the output
 
7644
 
 
7645
@Example
 
7646
a         b         c
 
7647
@endExample
 
7648
 
 
7649
@noindent
 
7650
in line-tabs mode, the same code outputs
 
7651
 
 
7652
@Example
 
7653
a         b                   c
 
7654
@endExample
 
7655
 
 
7656
Line-tabs mode is associated with the current environment.  The
 
7657
read-only register @code{.linetabs} is set to@tie{}1 if in line-tabs
 
7658
mode, and 0 in normal mode.
 
7659
@endDefreq
 
7660
 
 
7661
@menu
 
7662
* Leaders::
 
7663
* Fields::
 
7664
@end menu
 
7665
 
 
7666
@c ---------------------------------------------------------------------
 
7667
 
 
7668
@node Leaders, Fields, Tabs and Fields, Tabs and Fields
 
7669
@subsection Leaders
 
7670
@cindex leaders
 
7671
 
 
7672
Sometimes it may may be desirable to use the @code{tc} request to fill a
 
7673
particular tab stop with a given glyph (for example dots in a table of
 
7674
contents), but also normal tab stops on the rest of the line.  For this
 
7675
@code{gtroff} provides an alternate tab mechanism, called @dfn{leaders}
 
7676
which does just that.
 
7677
 
 
7678
@cindex leader character
 
7679
A leader character (character code@tie{}1) behaves similarly to a tab
 
7680
character: It moves to the next tab stop.  The only difference is that
 
7681
for this movement, the fill glyph defaults to a period character and not
 
7682
to space.
 
7683
 
 
7684
@Defesc {\\a, , , }
 
7685
@cindex leader character, non-interpreted (@code{\a})
 
7686
@cindex character, leader, non-interpreted (@code{\a})
 
7687
@cindex @code{\a}, and copy-in mode
 
7688
@cindex copy-in mode, and @code{\a}
 
7689
@cindex mode, copy-in, and @code{\a}
 
7690
This escape is a non-interpreted leader character.  In copy mode
 
7691
(@pxref{Copy-in Mode}), @code{\a} is the same as a real leader
 
7692
character.
 
7693
@endDefesc
 
7694
 
 
7695
@Defreq {lc, [@Var{fill-glyph}]}
 
7696
@cindex leader repetition character (@code{lc})
 
7697
@cindex character, leader repetition (@code{lc})
 
7698
@cindex glyph, leader repetition (@code{lc})
 
7699
Declare the @dfn{leader repetition character}.@footnote{@dfn{Leader
 
7700
repetition character} is a misnomer since it is an output glyph.}
 
7701
Without an argument, leaders act the same as tabs (i.e., using
 
7702
whitespace for filling).  @code{gtroff}'s start-up value is a dot
 
7703
(@samp{.}).  The value of the leader repetition character is associated
 
7704
with the current environment (@pxref{Environments}).
 
7705
@endDefreq
 
7706
 
 
7707
@cindex table of contents
 
7708
@cindex contents, table of
 
7709
For a table of contents, to name an example, tab stops may be defined so
 
7710
that the section number is one tab stop, the title is the second with
 
7711
the remaining space being filled with a line of dots, and then the page
 
7712
number slightly separated from the dots.
 
7713
 
 
7714
@Example
 
7715
.ds entry 1.1\tFoo\a\t12
 
7716
.lc .
 
7717
.ta 1i 5i +.25i
 
7718
\*[entry]
 
7719
@endExample
 
7720
 
 
7721
@noindent
 
7722
This produces
 
7723
 
 
7724
@Example
 
7725
1.1  Foo..........................................  12
 
7726
@endExample
 
7727
 
 
7728
@c ---------------------------------------------------------------------
 
7729
 
 
7730
@node Fields,  , Leaders, Tabs and Fields
 
7731
@subsection Fields
 
7732
@cindex fields
 
7733
 
 
7734
@cindex field delimiting character (@code{fc})
 
7735
@cindex delimiting character, for fields (@code{fc})
 
7736
@cindex character, field delimiting (@code{fc})
 
7737
@cindex field padding character (@code{fc})
 
7738
@cindex padding character, for fields (@code{fc})
 
7739
@cindex character, field padding (@code{fc})
 
7740
@dfn{Fields} are a more general way of laying out tabular data.  A field
 
7741
is defined as the data between a pair of @dfn{delimiting characters}.
 
7742
It contains substrings which are separated by @dfn{padding characters}.
 
7743
The width of a field is the distance on the @emph{input} line from the
 
7744
position where the field starts to the next tab stop.  A padding
 
7745
character inserts stretchable space similar to @TeX{}'s @code{\hss}
 
7746
command (thus it can even be negative) to make the sum of all substring
 
7747
lengths plus the stretchable space equal to the field width.  If more
 
7748
than one padding character is inserted, the available space is evenly
 
7749
distributed among them.
 
7750
 
 
7751
@Defreq {fc, [@Var{delim-char} [@Var{padding-char}]]}
 
7752
Define a delimiting and a padding character for fields.  If the latter
 
7753
is missing, the padding character defaults to a space character.  If
 
7754
there is no argument at all, the field mechanism is disabled (which is
 
7755
the default).  Note that contrary to e.g.@: the tab repetition
 
7756
character, delimiting and padding characters are @emph{not} associated
 
7757
to the current environment (@pxref{Environments}).
 
7758
 
 
7759
Example:
 
7760
 
 
7761
@Example
 
7762
.fc # ^
 
7763
.ta T 3i
 
7764
#foo^bar^smurf#
 
7765
.br
 
7766
#foo^^bar^smurf#
 
7767
@endExample
 
7768
 
 
7769
@noindent
 
7770
and here the result:
 
7771
 
 
7772
@Example
 
7773
foo         bar          smurf
 
7774
foo            bar       smurf
 
7775
@endExample
 
7776
@endDefreq
 
7777
 
 
7778
 
 
7779
@c =====================================================================
 
7780
 
 
7781
@node Character Translations, Troff and Nroff Mode, Tabs and Fields, gtroff Reference
 
7782
@section Character Translations
 
7783
@cindex character translations
 
7784
@cindex translations of characters
 
7785
 
 
7786
@cindex control character, changing (@code{cc})
 
7787
@cindex character, control, changing (@code{cc})
 
7788
@cindex no-break control character, changing (@code{c2})
 
7789
@cindex character, no-break control, changing (@code{c2})
 
7790
@cindex control character, no-break, changing (@code{c2})
 
7791
The control character (@samp{.}) and the no-break control character
 
7792
(@samp{'}) can be changed with the @code{cc} and @code{c2} requests,
 
7793
respectively.
 
7794
 
 
7795
@Defreq {cc, [@Var{c}]}
 
7796
Set the control character to@tie{}@var{c}.  With no argument the default
 
7797
control character @samp{.} is restored.  The value of the control
 
7798
character is associated with the current environment
 
7799
(@pxref{Environments}).
 
7800
@endDefreq
 
7801
 
 
7802
@Defreq {c2, [@Var{c}]}
 
7803
Set the no-break control character to@tie{}@var{c}.  With no argument
 
7804
the default control character @samp{'} is restored.  The value of the
 
7805
no-break control character is associated with the current environment
 
7806
(@pxref{Environments}).
 
7807
@endDefreq
 
7808
 
 
7809
@xref{Requests}.
 
7810
 
 
7811
@Defreq {eo, }
 
7812
@cindex disabling @code{\} (@code{eo})
 
7813
@cindex @code{\}, disabling (@code{eo})
 
7814
Disable the escape mechanism completely.  After executing this request,
 
7815
the backslash character @samp{\} no longer starts an escape sequence.
 
7816
 
 
7817
This request can be very helpful in writing macros since it is not
 
7818
necessary then to double the escape character.  Here an example:
 
7819
 
 
7820
@Example
 
7821
.\" This is a simplified version of the
 
7822
.\" .BR request from the man macro package
 
7823
.eo
 
7824
.de BR
 
7825
.  ds result \&
 
7826
.  while (\n[.$] >= 2) \@{\
 
7827
.    as result \fB\$1\fR\$2
 
7828
.    shift 2
 
7829
.  \@}
 
7830
.  if \n[.$] .as result \fB\$1
 
7831
\*[result]
 
7832
.  ft R
 
7833
..
 
7834
.ec
 
7835
@endExample
 
7836
@endDefreq
 
7837
 
 
7838
@Defreq {ec, [@Var{c}]}
 
7839
@cindex escape character, changing (@code{ec})
 
7840
@cindex character, escape, changing (@code{ec})
 
7841
Set the escape character to@tie{}@var{c}.  With no argument the default
 
7842
escape character @samp{\} is restored.  It can be also used to re-enable
 
7843
the escape mechanism after an @code{eo} request.
 
7844
 
 
7845
Note that changing the escape character globally likely breaks macro
 
7846
packages since @code{gtroff} has no mechanism to `intern' macros, i.e.,
 
7847
to convert a macro definition into an internal form which is independent
 
7848
of its representation (@TeX{} has this mechanism).  If a macro is
 
7849
called, it is executed literally.
 
7850
@endDefreq
 
7851
 
 
7852
@DefreqList {ecs, }
 
7853
@DefreqListEnd {ecr, }
 
7854
The @code{ecs} request saves the current escape character in an internal
 
7855
register.  Use this request in combination with the @code{ec} request to
 
7856
temporarily change the escape character.
 
7857
 
 
7858
The @code{ecr} request restores the escape character saved with
 
7859
@code{ecs}.  Without a previous call to @code{ecs}, this request sets
 
7860
the escape character to @code{\}.
 
7861
@endDefreq
 
7862
 
 
7863
@DefescList {\\\\, , , }
 
7864
@DefescItem {\\e, , , }
 
7865
@DefescListEnd {\\E, , , }
 
7866
Print the current escape character (which is the backslash character
 
7867
@samp{\} by default).
 
7868
 
 
7869
@code{\\} is a `delayed' backslash; more precisely, it is the default
 
7870
escape character followed by a backslash, which no longer has special
 
7871
meaning due to the leading escape character.  It is @emph{not} an escape
 
7872
sequence in the usual sense!  In any unknown escape sequence
 
7873
@code{\@var{X}} the escape character is ignored and @var{X} is printed.
 
7874
But if @var{X} is equal to the current escape character, no warning is
 
7875
emitted.
 
7876
 
 
7877
@cindex @code{\E}, and copy-in mode
 
7878
@cindex copy-in mode, and @code{\E}
 
7879
@cindex mode, copy-in, and @code{\E}
 
7880
As a consequence, only at top-level or in a diversion a backslash glyph
 
7881
is printed; in copy-in mode, it expands to a single backslash which then
 
7882
combines with the following character to an escape sequence.
 
7883
 
 
7884
The @code{\E} escape differs from @code{\e} by printing an escape
 
7885
character that is not interpreted in copy mode.  Use this to define
 
7886
strings with escapes that work when used in copy mode (for example, as a
 
7887
macro argument).  The following example defines strings to begin and end
 
7888
a superscript:
 
7889
 
 
7890
@Example
 
7891
.ds @{ \v'-.3m'\s'\En[.s]*60/100'
 
7892
.ds @} \s0\v'.3m'
 
7893
@endExample
 
7894
 
 
7895
Another example to demonstrate the differences between the various
 
7896
escape sequences, using a strange escape character, @samp{-}.
 
7897
 
 
7898
@Example
 
7899
.ec -
 
7900
.de xxx
 
7901
--A'123'
 
7902
..
 
7903
.xxx
 
7904
    @result{} -A'foo'
 
7905
@endExample
 
7906
 
 
7907
@noindent
 
7908
The result is surprising for most users, expecting @samp{1} since
 
7909
@samp{foo} is a valid identifier.  What has happened?  As mentioned
 
7910
above, the leading escape character makes the following character
 
7911
ordinary.  Written with the default escape character the sequence
 
7912
@samp{--} becomes @samp{\-} -- this is the minus sign.
 
7913
 
 
7914
If the escape character followed by itself is a valid escape sequence,
 
7915
only @code{\E} yields the expected result:
 
7916
 
 
7917
@Example
 
7918
.ec -
 
7919
.de xxx
 
7920
-EA'123'
 
7921
..
 
7922
.xxx
 
7923
    @result{} 1
 
7924
@endExample
 
7925
@endDefesc
 
7926
 
 
7927
@Defesc {\\., , , }
 
7928
Similar to @code{\\}, the sequence @code{\.} isn't a real escape
 
7929
sequence.  As before, a warning message is suppressed if the escape
 
7930
character is followed by a dot, and the dot itself is printed.
 
7931
 
 
7932
@Example
 
7933
.de foo
 
7934
.  nop foo
 
7935
.
 
7936
.  de bar
 
7937
.    nop bar
 
7938
\\..
 
7939
.
 
7940
..
 
7941
.foo
 
7942
.bar
 
7943
    @result{} foo bar
 
7944
@endExample
 
7945
 
 
7946
@noindent
 
7947
The first backslash is consumed while the macro is read, and the second
 
7948
is swallowed while executing macro @code{foo}.
 
7949
@endDefesc
 
7950
 
 
7951
A @dfn{translation} is a mapping of an input character to an output
 
7952
glyph.  The mapping occurs at output time, i.e., the input character
 
7953
gets assigned the metric information of the mapped output character
 
7954
right before input tokens are converted to nodes (@pxref{Gtroff
 
7955
Internals}, for more on this process).
 
7956
 
 
7957
@DefreqList {tr, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
 
7958
@DefreqListEnd {trin, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
 
7959
Translate character @var{a} to glyph@tie{}@var{b}, character @var{c} to
 
7960
glyph@tie{}@var{d}, etc.  If there is an odd number of arguments, the
 
7961
last one is translated to an unstretchable space (@w{@samp{\ }}).
 
7962
 
 
7963
The @code{trin} request is identical to @code{tr}, but when you unformat
 
7964
a diversion with @code{asciify} it ignores the translation.
 
7965
@xref{Diversions}, for details about the @code{asciify} request.
 
7966
 
 
7967
Some notes:
 
7968
 
 
7969
@itemize @bullet
 
7970
@item
 
7971
@cindex @code{\(}, and translations
 
7972
@cindex @code{\[}, and translations
 
7973
@cindex @code{\'}, and translations
 
7974
@cindex @code{\`}, and translations
 
7975
@cindex @code{\-}, and translations
 
7976
@cindex @code{\_}, and translations
 
7977
@cindex @code{\C}, and translations
 
7978
@cindex @code{\N}, and translations
 
7979
@cindex @code{char} request, and translations
 
7980
@cindex special characters
 
7981
@cindex character, special
 
7982
@cindex numbered glyph (@code{\N})
 
7983
@cindex glyph, numbered (@code{\N})
 
7984
Special characters (@code{\(@var{xx}}, @code{\[@var{xxx}]},
 
7985
@code{\C'@var{xxx}'}, @code{\'}, @code{\`}, @code{\-}, @code{\_}),
 
7986
glyphs defined with the @code{char} request, and numbered glyphs
 
7987
(@code{\N'@var{xxx}'}) can be translated also.
 
7988
 
 
7989
@item
 
7990
@cindex @code{\e}, and translations
 
7991
The @code{\e} escape can be translated also.
 
7992
 
 
7993
@item
 
7994
@cindex @code{\%}, and translations
 
7995
@cindex @code{\~}, and translations
 
7996
Characters can be mapped onto the @code{\%} and @code{\~} escapes (but
 
7997
@code{\%} and @code{\~} can't be mapped onto another glyph).
 
7998
 
 
7999
@item
 
8000
@cindex backspace character, and translations
 
8001
@cindex character, backspace, and translations
 
8002
@cindex leader character, and translations
 
8003
@cindex character, leader, and translations
 
8004
@cindex newline character, and translations
 
8005
@cindex character, newline, and translations
 
8006
@cindex tab character, and translations
 
8007
@cindex character, tab, and translations
 
8008
@cindex @code{\a}, and translations
 
8009
@cindex @code{\t}, and translations
 
8010
The following characters can't be translated: space (with one exception,
 
8011
see below), backspace, newline, leader (and @code{\a}), tab (and
 
8012
@code{\t}).
 
8013
 
 
8014
@item
 
8015
@cindex @code{shc} request, and translations
 
8016
Translations are not considered for finding the soft hyphen character
 
8017
set with the @code{shc} request.
 
8018
 
 
8019
@item
 
8020
@cindex @code{\&}, and translations
 
8021
The pair @samp{@var{c}\&} (this is an arbitrary character@tie{}@var{c}
 
8022
followed by the zero width space character) maps this character to
 
8023
nothing.
 
8024
 
 
8025
@Example
 
8026
.tr a\&
 
8027
foo bar
 
8028
    @result{} foo br
 
8029
@endExample
 
8030
 
 
8031
@noindent
 
8032
It is even possible to map the space character to nothing:
 
8033
 
 
8034
@Example
 
8035
.tr aa \&
 
8036
foo bar
 
8037
    @result{} foobar
 
8038
@endExample
 
8039
 
 
8040
@noindent
 
8041
As shown in the example, the space character can't be the first
 
8042
character/glyph pair as an argument of @code{tr}.  Additionally, it is
 
8043
not possible to map the space character to any other glyph; requests
 
8044
like @w{@samp{.tr aa x}} undo @w{@samp{.tr aa \&}} instead.
 
8045
 
 
8046
If justification is active, lines are justified in spite of the `empty'
 
8047
space character (but there is no minimal distance, i.e.@: the space
 
8048
character, between words).
 
8049
 
 
8050
@item
 
8051
After an output glyph has been constructed (this happens at the moment
 
8052
immediately before the glyph is appended to an output glyph list, either
 
8053
by direct output, in a macro, diversion, or string), it is no longer
 
8054
affected by @code{tr}.
 
8055
 
 
8056
@item
 
8057
Translating character to glyphs where one of them or both are undefined
 
8058
is possible also; @code{tr} does not check whether the entities in its
 
8059
argument do exist.
 
8060
 
 
8061
@xref{Gtroff Internals}.
 
8062
 
 
8063
@item
 
8064
@code{troff} no longer has a hard-coded dependency on @w{Latin-1}; all
 
8065
@code{char@var{XXX}} entities have been removed from the font
 
8066
description files.  This has a notable consequence which shows up in
 
8067
warnings like @code{can't find character with input code @var{XXX}} if
 
8068
the @code{tr} request isn't handled properly.
 
8069
 
 
8070
Consider the following translation:
 
8071
 
 
8072
@Example
 
8073
.tr ��
 
8074
@endExample
 
8075
 
 
8076
@noindent
 
8077
This maps input character @code{�} onto glyph @code{�}, which is
 
8078
identical to glyph @code{char201}.  But this glyph intentionally doesn't
 
8079
exist!  Instead, @code{\[char201]} is treated as an input character
 
8080
entity and is by default mapped onto @code{\['E]}, and @code{gtroff}
 
8081
doesn't handle translations of translations.
 
8082
 
 
8083
The right way to write the above translation is
 
8084
 
 
8085
@Example
 
8086
.tr �\['E]
 
8087
@endExample
 
8088
 
 
8089
@noindent
 
8090
In other words, the first argument of @code{tr} should be an input
 
8091
character or entity, and the second one a glyph entity.
 
8092
 
 
8093
@item
 
8094
Without an argument, the @code{tr} request is ignored.
 
8095
@end itemize
 
8096
@endDefreq
 
8097
 
 
8098
@Defreq {trnt, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
 
8099
@cindex @code{\!}, and @code{trnt}
 
8100
@code{trnt} is the same as the @code{tr} request except that the
 
8101
translations do not apply to text that is transparently throughput into
 
8102
a diversion with @code{\!}.  @xref{Diversions}, for more information.
 
8103
 
 
8104
For example,
 
8105
 
 
8106
@Example
 
8107
.tr ab
 
8108
.di x
 
8109
\!.tm a
 
8110
.di
 
8111
.x
 
8112
@endExample
 
8113
 
 
8114
@noindent
 
8115
prints @samp{b} to the standard error stream; if @code{trnt} is used
 
8116
instead of @code{tr} it prints @samp{a}.
 
8117
@endDefreq
 
8118
 
 
8119
 
 
8120
@c =====================================================================
 
8121
 
 
8122
@node Troff and Nroff Mode, Line Layout, Character Translations, gtroff Reference
 
8123
@section Troff and Nroff Mode
 
8124
@cindex troff mode
 
8125
@cindex mode, troff
 
8126
@cindex nroff mode
 
8127
@cindex mode, nroff
 
8128
 
 
8129
Originally, @code{nroff} and @code{troff} were two separate programs,
 
8130
the former for TTY output, the latter for everything else.  With GNU
 
8131
@code{troff}, both programs are merged into one executable, sending its
 
8132
output to a device driver (@code{grotty} for TTY devices, @code{grops}
 
8133
for @sc{PostScript}, etc.)@: which interprets the intermediate output of
 
8134
@code{gtroff}.  For @acronym{UNIX} @code{troff} it makes sense to talk
 
8135
about @dfn{Nroff mode} and @dfn{Troff mode} since the differences are
 
8136
hardcoded.  For GNU @code{troff}, this distinction is not appropriate
 
8137
because @code{gtroff} simply takes the information given in the font
 
8138
files for a particular device without handling requests specially if a
 
8139
TTY output device is used.
 
8140
 
 
8141
Usually, a macro package can be used with all output devices.
 
8142
Nevertheless, it is sometimes necessary to make a distinction between
 
8143
TTY and non-TTY devices: @code{gtroff} provides two built-in conditions
 
8144
@samp{n} and @samp{t} for the @code{if}, @code{ie}, and @code{while}
 
8145
requests to decide whether @code{gtroff} shall behave like @code{nroff}
 
8146
or like @code{troff}.
 
8147
 
 
8148
@Defreq {troff, }
 
8149
@pindex troffrc
 
8150
@pindex troffrc-end
 
8151
Make the @samp{t} built-in condition true (and the @samp{n} built-in
 
8152
condition false) for @code{if}, @code{ie}, and @code{while} conditional
 
8153
requests.  This is the default if @code{gtroff} (@emph{not}
 
8154
@code{groff}) is started with the @option{-R} switch to avoid loading of
 
8155
the start-up files @file{troffrc} and @file{troffrc-end}.  Without
 
8156
@option{-R}, @code{gtroff} stays in troff mode if the output device is
 
8157
not a TTY (e.g.@: `ps').
 
8158
@endDefreq
 
8159
 
 
8160
@Defreq {nroff, }
 
8161
@pindex tty.tmac
 
8162
Make the @samp{n} built-in condition true (and the @samp{t} built-in
 
8163
condition false) for @code{if}, @code{ie}, and @code{while} conditional
 
8164
requests.  This is the default if @code{gtroff} uses a TTY output
 
8165
device; the code for switching to nroff mode is in the file
 
8166
@file{tty.tmac} which is loaded by the start-up file @code{troffrc}.
 
8167
@endDefreq
 
8168
 
 
8169
@xref{Conditionals and Loops}, for more details on built-in conditions.
 
8170
 
 
8171
 
 
8172
@c =====================================================================
 
8173
 
 
8174
@node Line Layout, Line Control, Troff and Nroff Mode, gtroff Reference
 
8175
@section Line Layout
 
8176
@cindex line layout
 
8177
@cindex layout, line
 
8178
 
 
8179
@cindex dimensions, line
 
8180
@cindex line dimensions
 
8181
The following drawing shows the dimensions which @code{gtroff} uses for
 
8182
placing a line of output onto the page.  They are labeled with the
 
8183
request which manipulates each dimension.
 
8184
 
 
8185
@Example
 
8186
     -->| in |<--
 
8187
        |<-----------ll------------>|
 
8188
   +----+----+----------------------+----+
 
8189
   |    :    :                      :    |
 
8190
   +----+----+----------------------+----+
 
8191
-->| po |<--
 
8192
   |<--------paper width---------------->|
 
8193
@endExample
 
8194
 
 
8195
@noindent
 
8196
These dimensions are:
 
8197
 
 
8198
@ftable @code
 
8199
@item po
 
8200
@cindex left margin (@code{po})
 
8201
@cindex margin, left (@code{po})
 
8202
@cindex page offset (@code{po})
 
8203
@cindex offset, page (@code{po})
 
8204
@dfn{Page offset} -- this is the leftmost position of text on the final
 
8205
output, defining the @dfn{left margin}.
 
8206
 
 
8207
@item in
 
8208
@cindex indentation (@code{in})
 
8209
@cindex line indentation (@code{in})
 
8210
@dfn{Indentation} -- this is the distance from the left margin where
 
8211
text is printed.
 
8212
 
 
8213
@item ll
 
8214
@cindex line length (@code{ll})
 
8215
@cindex length of line (@code{ll})
 
8216
@dfn{Line length} -- this is the distance from the left margin to right
 
8217
margin.
 
8218
@end ftable
 
8219
 
 
8220
A simple demonstration:
 
8221
 
 
8222
@Example
 
8223
.ll 3i
 
8224
This is text without indentation.
 
8225
The line length has been set to 3\~inch.
 
8226
.in +.5i
 
8227
.ll -.5i
 
8228
Now the left and right margins are both increased.
 
8229
.in
 
8230
.ll
 
8231
Calling .in and .ll without parameters restore
 
8232
the previous values.
 
8233
@endExample
 
8234
 
 
8235
Result:
 
8236
 
 
8237
@Example
 
8238
This  is text without indenta-
 
8239
tion.   The  line  length  has
 
8240
been set to 3 inch.
 
8241
     Now   the  left  and
 
8242
     right  margins   are
 
8243
     both increased.
 
8244
Calling  .in  and  .ll without
 
8245
parameters restore the  previ-
 
8246
ous values.
 
8247
@endExample
 
8248
 
 
8249
@DefreqList {po, [@Var{offset}]}
 
8250
@DefreqItem {po, @t{+}@Var{offset}}
 
8251
@DefreqItem {po, @t{-}@Var{offset}}
 
8252
@DefregListEnd {.o}
 
8253
@pindex troffrc
 
8254
Set horizontal page offset to @var{offset} (or increment or decrement
 
8255
the current value by @var{offset}).  Note that this request does not
 
8256
cause a break, so changing the page offset in the middle of text being
 
8257
filled may not yield the expected result.  The initial value is
 
8258
1@dmn{i}.  For TTY output devices, it is set to 0 in the startup file
 
8259
@file{troffrc}; the default scaling indicator is @samp{m} (and not
 
8260
@samp{v} as incorrectly documented in the original @acronym{UNIX} troff
 
8261
manual).
 
8262
 
 
8263
The current page offset can be found in the read-only number register
 
8264
@samp{.o}.
 
8265
 
 
8266
If @code{po} is called without an argument, the page offset is reset to
 
8267
the previous value before the last call to @code{po}.
 
8268
 
 
8269
@Example
 
8270
.po 3i
 
8271
\n[.o]
 
8272
    @result{} 720
 
8273
.po -1i
 
8274
\n[.o]
 
8275
    @result{} 480
 
8276
.po
 
8277
\n[.o]
 
8278
    @result{} 720
 
8279
@endExample
 
8280
@endDefreq
 
8281
 
 
8282
@DefreqList {in, [@Var{indent}]}
 
8283
@DefreqItem {in, @t{+}@Var{indent}}
 
8284
@DefreqItem {in, @t{-}@Var{indent}}
 
8285
@DefregListEnd {.i}
 
8286
Set indentation to @var{indent} (or increment or decrement the current
 
8287
value by @var{indent}).  This request causes a break.  Initially, there
 
8288
is no indentation.
 
8289
 
 
8290
If @code{in} is called without an argument, the indentation is reset to
 
8291
the previous value before the last call to @code{in}.  The default
 
8292
scaling indicator is @samp{m}.
 
8293
 
 
8294
The indentation is associated with the current environment
 
8295
(@pxref{Environments}).
 
8296
 
 
8297
If a negative indentation value is specified (which is not allowed),
 
8298
@code{gtroff} emits a warning of type @samp{range} and sets the
 
8299
indentation to zero.
 
8300
 
 
8301
The effect of @code{in} is delayed until a partially collected line (if
 
8302
it exists) is output.  A temporary indentation value is reset to zero
 
8303
also.
 
8304
 
 
8305
The current indentation (as set by @code{in}) can be found in the
 
8306
read-only number register @samp{.i}.
 
8307
@endDefreq
 
8308
 
 
8309
@DefreqList {ti, offset}
 
8310
@DefreqItem {ti, @t{+}@Var{offset}}
 
8311
@DefreqItem {ti, @t{-}@Var{offset}}
 
8312
@DefregListEnd {.in}
 
8313
Temporarily indent the next output line by @var{offset}.  If an
 
8314
increment or decrement value is specified, adjust the temporary
 
8315
indentation relative to the value set by the @code{in} request.
 
8316
 
 
8317
This request causes a break; its value is associated with the current
 
8318
environment (@pxref{Environments}).  The default scaling indicator is
 
8319
@samp{m}.  A call of @code{ti} without an argument is ignored.
 
8320
 
 
8321
If the total indentation value is negative (which is not allowed),
 
8322
@code{gtroff} emits a warning of type @samp{range} and sets the
 
8323
temporary indentation to zero.  `Total indentation' is either
 
8324
@var{offset} if specified as an absolute value, or the temporary plus
 
8325
normal indentation, if @var{offset} is given as a relative value.
 
8326
 
 
8327
The effect of @code{ti} is delayed until a partially collected line (if
 
8328
it exists) is output.
 
8329
 
 
8330
The read-only number register @code{.in} is the indentation that applies
 
8331
to the current output line.
 
8332
 
 
8333
The difference between @code{.i} and @code{.in} is that the latter takes
 
8334
into account whether a partially collected line still uses the old
 
8335
indentation value or a temporary indentation value is active.
 
8336
@endDefreq
 
8337
 
 
8338
@DefreqList {ll, [@Var{length}]}
 
8339
@DefreqItem {ll, @t{+}@Var{length}}
 
8340
@DefreqItem {ll, @t{-}@Var{length}}
 
8341
@DefregItem {.l}
 
8342
@DefregListEnd {.ll}
 
8343
Set the line length to @var{length} (or increment or decrement the
 
8344
current value by @var{length}).  Initially, the line length is set to
 
8345
6.5@dmn{i}.  The effect of @code{ll} is delayed until a partially
 
8346
collected line (if it exists) is output.  The default scaling indicator
 
8347
is @samp{m}.
 
8348
 
 
8349
If @code{ll} is called without an argument, the line length is reset to
 
8350
the previous value before the last call to @code{ll}.  If a negative
 
8351
line length is specified (which is not allowed), @code{gtroff} emits a
 
8352
warning of type @samp{range} and sets the line length to zero.
 
8353
 
 
8354
The line length is associated with the current environment
 
8355
(@pxref{Environments}).
 
8356
 
 
8357
@cindex line length register (@code{.l})
 
8358
The current line length (as set by @code{ll}) can be found in the
 
8359
read-only number register @samp{.l}.  The read-only number register
 
8360
@code{.ll} is the line length that applies to the current output line.
 
8361
 
 
8362
Similar to @code{.i} and @code{.in}, the difference between @code{.l}
 
8363
and @code{.ll} is that the latter takes into account whether a partially
 
8364
collected line still uses the old line length value.
 
8365
@endDefreq
 
8366
 
 
8367
 
 
8368
@c =====================================================================
 
8369
 
 
8370
@node Line Control, Page Layout, Line Layout, gtroff Reference
 
8371
@section Line Control
 
8372
@cindex line control
 
8373
@cindex control, line
 
8374
 
 
8375
It is important to understand how @code{gtroff} handles input and output
 
8376
lines.
 
8377
 
 
8378
Many escapes use positioning relative to the input line.  For example,
 
8379
this
 
8380
 
 
8381
@Example
 
8382
This is a \h'|1.2i'test.
 
8383
 
 
8384
This is a
 
8385
\h'|1.2i'test.
 
8386
@endExample
 
8387
 
 
8388
@noindent
 
8389
produces
 
8390
 
 
8391
@Example
 
8392
This is a   test.
 
8393
 
 
8394
This is a             test.
 
8395
@endExample
 
8396
 
 
8397
The main usage of this feature is to define macros which act exactly at
 
8398
the place where called.
 
8399
 
 
8400
@Example
 
8401
.\" A simple macro to underline a word
 
8402
.de underline
 
8403
.  nop \\$1\l'|0\[ul]'
 
8404
..
 
8405
@endExample
 
8406
 
 
8407
@noindent
 
8408
In the above example, @samp{|0} specifies a negative distance from the
 
8409
current position (at the end of the just emitted argument @code{\$1})
 
8410
back to the beginning of the input line.  Thus, the @samp{\l} escape
 
8411
draws a line from right to left.
 
8412
 
 
8413
@cindex input line continuation (@code{\})
 
8414
@cindex line, input, continuation (@code{\})
 
8415
@cindex continuation, input line (@code{\})
 
8416
@cindex output line, continuation (@code{\c})
 
8417
@cindex line, output, continuation (@code{\c})
 
8418
@cindex continuation, output line (@code{\c})
 
8419
@cindex interrupted line
 
8420
@cindex line, interrupted
 
8421
@code{gtroff} makes a difference between input and output line
 
8422
continuation; the latter is also called @dfn{interrupting} a line.
 
8423
 
 
8424
@DefescList {\\@key{RET}, , ,}
 
8425
@DefescItem {\\c, , ,}
 
8426
@DefregListEnd {.int}
 
8427
Continue a line.  @code{\@key{RET}} (this is a backslash at the end of a
 
8428
line immediately followed by a newline) works on the input level,
 
8429
suppressing the effects of the following newline in the input.
 
8430
 
 
8431
@Example
 
8432
This is a \
 
8433
.test
 
8434
    @result{} This is a .test
 
8435
@endExample
 
8436
 
 
8437
The @samp{|} operator is also affected.
 
8438
 
 
8439
@cindex @code{\R}, after @code{\c}
 
8440
@code{\c} works on the output level.  Anything after this escape on the
 
8441
same line is ignored, except @code{\R} which works as usual.  Anything
 
8442
before @code{\c} on the same line is appended to the current partial
 
8443
output line.  The next non-command line after an interrupted line counts
 
8444
as a new input line.
 
8445
 
 
8446
The visual results depend on whether no-fill mode is active.
 
8447
 
 
8448
@itemize @bullet
 
8449
@item
 
8450
@cindex @code{\c}, and no-fill mode
 
8451
@cindex no-fill mode, and @code{\c}
 
8452
@cindex mode, no-fill, and @code{\c}
 
8453
If no-fill mode is active (using the @code{nf} request), the next input
 
8454
text line after @code{\c} is handled as a continuation of the same input
 
8455
text line.
 
8456
 
 
8457
@Example
 
8458
.nf
 
8459
This is a \c
 
8460
test.
 
8461
    @result{} This is a test.
 
8462
@endExample
 
8463
 
 
8464
@item
 
8465
@cindex @code{\c}, and fill mode
 
8466
@cindex fill mode, and @code{\c}
 
8467
@cindex mode, fill, and @code{\c}
 
8468
If fill mode is active (using the @code{fi} request), a word interrupted
 
8469
with @code{\c} is continued with the text on the next input text line,
 
8470
without an intervening space.
 
8471
 
 
8472
@Example
 
8473
This is a te\c
 
8474
st.
 
8475
    @result{} This is a test.
 
8476
@endExample
 
8477
@end itemize
 
8478
 
 
8479
Note that an intervening control line which causes a break is stronger
 
8480
than @code{\c}, flushing out the current partial line in the usual way.
 
8481
 
 
8482
@cindex interrupted line register (@code{.int})
 
8483
The @code{.int} register contains a positive value if the last output
 
8484
line was interrupted with @code{\c}; this is associated with the current
 
8485
environment (@pxref{Environments}).
 
8486
@endDefesc
 
8487
 
 
8488
 
 
8489
@c =====================================================================
 
8490
 
 
8491
@node Page Layout, Page Control, Line Control, gtroff Reference
 
8492
@section Page Layout
 
8493
@cindex page layout
 
8494
@cindex layout, page
 
8495
 
 
8496
@code{gtroff} provides some very primitive operations for controlling
 
8497
page layout.
 
8498
 
 
8499
@DefreqList {pl, [@Var{length}]}
 
8500
@DefreqItem {pl, @t{+}@Var{length}}
 
8501
@DefreqItem {pl, @t{-}@Var{length}}
 
8502
@DefregListEnd {.p}
 
8503
@cindex page length (@code{pl})
 
8504
@cindex length of page (@code{pl})
 
8505
Set the @dfn{page length} to @var{length} (or increment or decrement the
 
8506
current value by @var{length}).  This is the length of the physical
 
8507
output page.  The default scaling indicator is @samp{v}.
 
8508
 
 
8509
@cindex page length register (@code{.p})
 
8510
The current setting can be found in the read-only number register
 
8511
@samp{.p}.
 
8512
 
 
8513
@cindex top margin
 
8514
@cindex margin, top
 
8515
@cindex bottom margin
 
8516
@cindex margin, bottom
 
8517
Note that this only specifies the size of the page, not the top and
 
8518
bottom margins.  Those are not set by @code{gtroff} directly.
 
8519
@xref{Traps}, for further information on how to do this.
 
8520
 
 
8521
Negative @code{pl} values are possible also, but not very useful: No
 
8522
trap is sprung, and each line is output on a single page (thus
 
8523
suppressing all vertical spacing).
 
8524
 
 
8525
If no argument or an invalid argument is given, @code{pl} sets the page
 
8526
length to 11@dmn{i}.
 
8527
@endDefreq
 
8528
 
 
8529
@cindex headers
 
8530
@cindex footers
 
8531
@cindex titles
 
8532
@code{gtroff} provides several operations which help in setting up top
 
8533
and bottom titles (or headers and footers).
 
8534
 
 
8535
@Defreq {tl, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}}
 
8536
@cindex title line (@code{tl})
 
8537
@cindex three-part title (@code{tl})
 
8538
@cindex page number character (@code{%})
 
8539
Print a @dfn{title line}.  It consists of three parts: a left justified
 
8540
portion, a centered portion, and a right justified portion.  The
 
8541
argument separator @samp{'} can be replaced with any character not
 
8542
occurring in the title line.  The @samp{%} character is replaced with
 
8543
the current page number.  This character can be changed with the
 
8544
@code{pc} request (see below).
 
8545
 
 
8546
Without argument, @code{tl} is ignored.
 
8547
 
 
8548
Some notes:
 
8549
 
 
8550
@itemize @bullet
 
8551
@item
 
8552
The line length set by the @code{ll} request is not honoured by
 
8553
@code{tl}; use the @code{lt} request (described below) instead, to
 
8554
control line length for text set by @code{tl}.
 
8555
 
 
8556
@item
 
8557
A title line is not restricted to the top or bottom of a page.
 
8558
 
 
8559
@item
 
8560
@code{tl} prints the title line immediately, ignoring a partially filled
 
8561
line (which stays untouched).
 
8562
 
 
8563
@item
 
8564
It is not an error to omit closing delimiters.  For example,
 
8565
@w{@samp{.tl /foo}} is equivalent to @w{@samp{.tl /foo///}}: It prints a
 
8566
title line with the left justified word @samp{foo}; the centered and
 
8567
right justfied parts are empty.
 
8568
 
 
8569
@item
 
8570
@code{tl} accepts the same parameter delimiting characters as the
 
8571
@code{\A} escape; see @ref{Escapes}.
 
8572
@end itemize
 
8573
@endDefreq
 
8574
 
 
8575
@DefreqList {lt, [@Var{length}]}
 
8576
@DefreqItem {lt, @t{+}@Var{length}}
 
8577
@DefreqItem {lt, @t{-}@Var{length}}
 
8578
@DefregListEnd {.lt}
 
8579
@cindex length of title line (@code{lt})
 
8580
@cindex title line, length (@code{lt})
 
8581
@cindex title line length register (@code{.lt})
 
8582
The title line is printed using its own line length, which is specified
 
8583
(or incremented or decremented) with the @code{lt} request.  Initially,
 
8584
the title line length is set to 6.5@dmn{i}.  If a negative line length
 
8585
is specified (which is not allowed), @code{gtroff} emits a warning of
 
8586
type @samp{range} and sets the title line length to zero.  The default
 
8587
scaling indicator is @samp{m}.  If @code{lt} is called without an
 
8588
argument, the title length is reset to the previous value before the
 
8589
last call to @code{lt}.
 
8590
 
 
8591
The current setting of this is available in the @code{.lt} read-only
 
8592
number register; it is associated with the current environment
 
8593
(@pxref{Environments}).
 
8594
@endDefreq
 
8595
 
 
8596
@DefreqList {pn, page}
 
8597
@DefreqItem {pn, @t{+}@Var{page}}
 
8598
@DefreqItem {pn, @t{-}@Var{page}}
 
8599
@DefregListEnd {.pn}
 
8600
@cindex page number (@code{pn})
 
8601
@cindex number, page (@code{pn})
 
8602
Change (increase or decrease) the page number of the @emph{next} page.
 
8603
The only argument is the page number; the request is ignored without a
 
8604
parameter.
 
8605
 
 
8606
The read-only number register @code{.pn} contains the number of the next
 
8607
page: either the value set by a @code{pn} request, or the number of the
 
8608
current page plus@tie{}1.
 
8609
@endDefreq
 
8610
 
 
8611
@Defreq {pc, [@Var{char}]}
 
8612
@cindex changing the page number character (@code{pc})
 
8613
@cindex page number character, changing (@code{pc})
 
8614
@vindex %
 
8615
Change the page number character (used by the @code{tl} request) to a
 
8616
different character.  With no argument, this mechanism is disabled.
 
8617
Note that this doesn't affect the number register@tie{}@code{%}.
 
8618
@endDefreq
 
8619
 
 
8620
@xref{Traps}.
 
8621
 
 
8622
 
 
8623
@c =====================================================================
 
8624
 
 
8625
@node Page Control, Fonts and Symbols, Page Layout, gtroff Reference
 
8626
@section Page Control
 
8627
@cindex page control
 
8628
@cindex control, page
 
8629
 
 
8630
@DefreqList {bp, [@Var{page}]}
 
8631
@DefreqItem {bp, @t{+}@Var{page}}
 
8632
@DefreqItem {bp, @t{-}@Var{page}}
 
8633
@DefregListEnd {%}
 
8634
@cindex new page (@code{bp})
 
8635
@cindex page, new (@code{bp})
 
8636
Stop processing the current page and move to the next page.  This
 
8637
request causes a break.  It can also take an argument to set (increase,
 
8638
decrease) the page number of the next page (which actually becomes the
 
8639
current page after @code{bp} has finished).  The difference between
 
8640
@code{bp} and @code{pn} is that @code{pn} does not cause a break or
 
8641
actually eject a page.  @xref{Page Layout}.
 
8642
 
 
8643
@Example
 
8644
.de newpage                         \" define macro
 
8645
'bp                                 \" begin page
 
8646
'sp .5i                             \" vertical space
 
8647
.tl 'left top'center top'right top' \" title
 
8648
'sp .3i                             \" vertical space
 
8649
..                                  \" end macro
 
8650
@endExample
 
8651
 
 
8652
@cindex @code{bp} request, and top-level diversion
 
8653
@cindex top-level diversion, and @code{bp}
 
8654
@cindex diversion, top-level, and @code{bp}
 
8655
@code{bp} has no effect if not called within the top-level diversion
 
8656
(@pxref{Diversions}).
 
8657
 
 
8658
@cindex page number register (@code{%})
 
8659
@cindex current page number (@code{%})
 
8660
The read-write register@tie{}@code{%} holds the current page number.
 
8661
 
 
8662
The number register @code{.pe} is set to@tie{}1 while @code{bp} is
 
8663
active.  @xref{Page Location Traps}.
 
8664
@endDefreq
 
8665
 
 
8666
@Defreq {ne, [@Var{space}]}
 
8667
@cindex orphan lines, preventing with @code{ne}
 
8668
@cindex conditional page break (@code{ne})
 
8669
@cindex page break, conditional (@code{ne})
 
8670
It is often necessary to force a certain amount of space before a new
 
8671
page occurs.  This is most useful to make sure that there is not a
 
8672
single @dfn{orphan} line left at the bottom of a page.  The @code{ne}
 
8673
request ensures that there is a certain distance, specified by the first
 
8674
argument, before the next page is triggered (see @ref{Traps}, for
 
8675
further information).  The default scaling indicator for @code{ne} is
 
8676
@samp{v}; the default value of @var{space} is@tie{}1@dmn{v} if no
 
8677
argument is given.
 
8678
 
 
8679
For example, to make sure that no fewer than 2@tie{}lines get orphaned,
 
8680
do the following before each paragraph:
 
8681
 
 
8682
@Example
 
8683
.ne 2
 
8684
text text text
 
8685
@endExample
 
8686
 
 
8687
@code{ne} then automatically causes a page break if there is space for
 
8688
one line only.
 
8689
@endDefreq
 
8690
 
 
8691
@DefreqList {sv, [@Var{space}]}
 
8692
@DefreqListEnd {os, }
 
8693
@cindex @code{ne} request, comparison with @code{sv}
 
8694
@code{sv} is similar to the @code{ne} request; it reserves the specified
 
8695
amount of vertical space.  If the desired amount of space exists before
 
8696
the next trap (or the bottom page boundary if no trap is set), the space
 
8697
is output immediately (ignoring a partially filled line which stays
 
8698
untouched).  If there is not enough space, it is stored for later output
 
8699
via the @code{os} request.  The default value is@tie{}1@dmn{v} if no
 
8700
argument is given; the default scaling indicator is @samp{v}.
 
8701
 
 
8702
@cindex @code{sv} request, and no-space mode
 
8703
@cindex @code{os} request, and no-space mode
 
8704
Both @code{sv} and @code{os} ignore no-space mode.  While the @code{sv}
 
8705
request allows negative values for @var{space}, @code{os} ignores them.
 
8706
@endDefreq
 
8707
 
 
8708
@Defreg {nl}
 
8709
@cindex current vertical position (@code{nl})
 
8710
@cindex vertical position, current (@code{nl})
 
8711
@cindex position, vertical, current (@code{nl})
 
8712
This register contains the current vertical position.  If the vertical
 
8713
position is zero and the top of page transition hasn't happened yet,
 
8714
@code{nl} is set to negative value.  @code{gtroff} itself does this at
 
8715
the very beginning of a document before anything has been printed, but
 
8716
the main usage is to plant a header trap on a page if this page has
 
8717
already started.
 
8718
 
 
8719
Consider the following:
 
8720
 
 
8721
@Example
 
8722
.de xxx
 
8723
.  sp
 
8724
.  tl ''Header''
 
8725
.  sp
 
8726
..
 
8727
.
 
8728
First page.
 
8729
.bp
 
8730
.wh 0 xxx
 
8731
.nr nl (-1)
 
8732
Second page.
 
8733
@endExample
 
8734
 
 
8735
@noindent
 
8736
Result:
 
8737
 
 
8738
@Example
 
8739
First page.
 
8740
 
 
8741
...
 
8742
 
 
8743
                             Header
 
8744
 
 
8745
Second page.
 
8746
 
 
8747
...
 
8748
@endExample
 
8749
 
 
8750
@noindent
 
8751
Without resetting @code{nl} to a negative value, the just planted trap
 
8752
would be active beginning with the @emph{next} page, not the current
 
8753
one.
 
8754
 
 
8755
@xref{Diversions}, for a comparison with the @code{.h} and @code{.d}
 
8756
registers.
 
8757
@endDefreg
 
8758
 
 
8759
 
 
8760
@c =====================================================================
 
8761
 
 
8762
@node Fonts and Symbols, Sizes, Page Control, gtroff Reference
 
8763
@section Fonts and Symbols
 
8764
@cindex fonts
 
8765
 
 
8766
@code{gtroff} can switch fonts at any point in the text.
 
8767
 
 
8768
The basic set of fonts is @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
 
8769
These are Times Roman, Italic, Bold, and Bold Italic.  For non-TTY
 
8770
devices, there is also at least one symbol font which contains various
 
8771
special symbols (Greek, mathematics).
 
8772
 
 
8773
@menu
 
8774
* Changing Fonts::
 
8775
* Font Families::
 
8776
* Font Positions::
 
8777
* Using Symbols::
 
8778
* Character Classes::
 
8779
* Special Fonts::
 
8780
* Artificial Fonts::
 
8781
* Ligatures and Kerning::
 
8782
@end menu
 
8783
 
 
8784
@c ---------------------------------------------------------------------
 
8785
 
 
8786
@node Changing Fonts, Font Families, Fonts and Symbols, Fonts and Symbols
 
8787
@subsection Changing Fonts
 
8788
@cindex fonts
 
8789
 
 
8790
@DefreqList {ft, [@Var{font}]}
 
8791
@DefescItem {\\f, , f, }
 
8792
@DefescItem {\\f, @Lparen{}, fn, }
 
8793
@DefescItem {\\f, @Lbrack{}, font, @Rbrack{}}
 
8794
@DefregListEnd {.sty}
 
8795
@cindex changing fonts (@code{ft}, @code{\f})
 
8796
@cindex fonts, changing (@code{ft}, @code{\f})
 
8797
@cindex @code{sty} request, and changing fonts
 
8798
@cindex @code{fam} request, and changing fonts
 
8799
@cindex @code{\F}, and changing fonts
 
8800
@kindex styles
 
8801
@kindex family
 
8802
@pindex DESC
 
8803
The @code{ft} request and the @code{\f} escape change the current font
 
8804
to @var{font} (one-character name@tie{}@var{f}, two-character name
 
8805
@var{fn}).
 
8806
 
 
8807
If @var{font} is a style name (as set with the @code{sty} request or
 
8808
with the @code{styles} command in the @file{DESC} file), use it within
 
8809
the current font family (as set with the @code{fam} request, @code{\F}
 
8810
escape, or with the @code{family} command in the @file{DESC} file).
 
8811
 
 
8812
It is not possible to switch to a font with the name @samp{DESC}
 
8813
(whereas this name could be used as a style name; however, this is not
 
8814
recommended).
 
8815
 
 
8816
@cindex previous font (@code{ft}, @code{\f[]}, @code{\fP})
 
8817
@cindex font, previous (@code{ft}, @code{\f[]}, @code{\fP})
 
8818
With no argument or using @samp{P} as an argument, @code{.ft} switches
 
8819
to the previous font.  Use @code{\f[]} to do this with the escape.  The
 
8820
old syntax forms @code{\fP} or @code{\f[P]} are also supported.
 
8821
 
 
8822
Fonts are generally specified as upper-case strings, which are usually
 
8823
1@tie{}to 4 characters representing an abbreviation or acronym of the
 
8824
font name.  This is no limitation, just a convention.
 
8825
 
 
8826
The example below produces two identical lines.
 
8827
 
 
8828
@Example
 
8829
eggs, bacon,
 
8830
.ft B
 
8831
spam
 
8832
.ft
 
8833
and sausage.
 
8834
 
 
8835
eggs, bacon, \fBspam\fP and sausage.
 
8836
@endExample
 
8837
 
 
8838
Note that @code{\f} doesn't produce an input token in @code{gtroff}.  As
 
8839
a consequence, it can be used in requests like @code{mc} (which expects
 
8840
a single character as an argument) to change the font on the fly:
 
8841
 
 
8842
@Example
 
8843
.mc \f[I]x\f[]
 
8844
@endExample
 
8845
 
 
8846
The current style name is available in the read-only number register
 
8847
@samp{.sty} (this is a string-valued register); if the current font
 
8848
isn't a style, the empty string is returned.  It is associated with the
 
8849
current environment.
 
8850
 
 
8851
@xref{Font Positions}, for an alternative syntax.
 
8852
@endDefreq
 
8853
 
 
8854
@Defreq {ftr, f [@Var{g}]}
 
8855
@cindex font translation (@code{ftr})
 
8856
@cindex @code{ft} request, and font translations
 
8857
@cindex @code{ul} request, and font translations
 
8858
@cindex @code{bd} request, and font translations
 
8859
@cindex @code{\f}, and font translations
 
8860
@cindex @code{cs} request, and font translations
 
8861
@cindex @code{tkf} request, and font translations
 
8862
@cindex @code{special} request, and font translations
 
8863
@cindex @code{fspecial} request, and font translations
 
8864
@cindex @code{fp} request, and font translations
 
8865
@cindex @code{sty} request, and font translations
 
8866
@cindex @code{if} request, and font translations
 
8867
@cindex @code{ie} request, and font translations
 
8868
@cindex @code{while} request, and font translations
 
8869
Translate font@tie{}@var{f} to font@tie{}@var{g}.  Whenever a font
 
8870
named@tie{}@var{f} is referred to in a @code{\f} escape sequence, in the
 
8871
@code{F} and @code{S} conditional operators, or in the @code{ft},
 
8872
@code{ul}, @code{bd}, @code{cs}, @code{tkf}, @code{special},
 
8873
@code{fspecial}, @code{fp}, or @code{sty} requests, font@tie{}@var{g} is
 
8874
used.  If @var{g} is missing or equal to@tie{}@var{f} the translation is
 
8875
undone.
 
8876
 
 
8877
Note that it is not possible to chain font translations.  Example:
 
8878
 
 
8879
@Example
 
8880
.ftr XXX TR
 
8881
.ftr XXX YYY
 
8882
.ft XXX
 
8883
    @result{} warning: can't find font `XXX'
 
8884
@endExample
 
8885
@endDefreq
 
8886
 
 
8887
@DefreqList {fzoom, f [@Var{zoom}]}
 
8888
@DefregListEnd {.zoom}
 
8889
@cindex magnification of a font (@code{fzoom})
 
8890
@cindex font, magnification (@code{fzoom})
 
8891
@cindex zoom factor of a font (@code{fzoom})
 
8892
@cindex factor, zoom, of a font (@code{fzoom})
 
8893
@cindex font, zoom factor (@code{fzoom})
 
8894
@cindex optical size of a font
 
8895
@cindex font, optical size
 
8896
@cindex size, optical, of a font
 
8897
Set magnification of font@tie{}@var{f} to factor @var{zoom}, which must
 
8898
be a non-negative integer multiple of 1/1000th.  This request is useful
 
8899
to adjust the optical size of a font in relation to the others.  In the
 
8900
example below, font @code{CR} is magnified by 10% (the zoom factor is
 
8901
thus 1.1).
 
8902
 
 
8903
@Example
 
8904
.fam P
 
8905
.fzoom CR 1100
 
8906
.ps 12
 
8907
Palatino and \f[CR]Courier\f[]
 
8908
@endExample
 
8909
 
 
8910
A missing or zero value of @var{zoom} is the same as a value of 1000,
 
8911
which means no magnification.  @var{f}@tie{}must be a real font name,
 
8912
not a style.
 
8913
 
 
8914
Note that the magnification of a font is completely transparent to
 
8915
troff; a change of the zoom factor doesn't cause any effect except that
 
8916
the dimensions of glyphs, (word) spaces, kerns, etc., of the affected
 
8917
font are adjusted accordingly.
 
8918
 
 
8919
The zoom factor of the current font is available in the read-only number
 
8920
register @samp{.zoom}, in multiples of 1/1000th.  It returns zero if
 
8921
there is no magnification.
 
8922
@endDefreq
 
8923
 
 
8924
@c ---------------------------------------------------------------------
 
8925
 
 
8926
@node Font Families, Font Positions, Changing Fonts, Fonts and Symbols
 
8927
@subsection Font Families
 
8928
@cindex font families
 
8929
@cindex families, font
 
8930
@cindex font styles
 
8931
@cindex styles, font
 
8932
 
 
8933
Due to the variety of fonts available, @code{gtroff} has added the
 
8934
concept of @dfn{font families} and @dfn{font styles}.  The fonts are
 
8935
specified as the concatenation of the font family and style.  Specifying
 
8936
a font without the family part causes @code{gtroff} to use that style of
 
8937
the current family.
 
8938
 
 
8939
@cindex PostScript fonts
 
8940
@cindex fonts, PostScript
 
8941
Currently, fonts for the devices @option{-Tps}, @option{-Tpdf},
 
8942
@option{-Tdvi}, @option{-Tlj4}, @option{-Tlbp}, and the X11 fonts are
 
8943
set up to this mechanism.  By default, @code{gtroff} uses the Times
 
8944
family with the four styles @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
 
8945
 
 
8946
This way, it is possible to use the basic four fonts and to select a
 
8947
different font family on the command line (@pxref{Groff Options}).
 
8948
 
 
8949
@DefreqList {fam, [@Var{family}]}
 
8950
@DefregItem {.fam}
 
8951
@DefescItem {\\F, , f, }
 
8952
@DefescItem {\\F, @Lparen{}, fm, }
 
8953
@DefescItem {\\F, @Lbrack{}, family, @Rbrack{}}
 
8954
@DefregListEnd {.fn}
 
8955
@cindex changing font family (@code{fam}, @code{\F})
 
8956
@cindex font family, changing (@code{fam}, @code{\F})
 
8957
Switch font family to @var{family} (one-character name@tie{}@var{f},
 
8958
two-character name @var{fm}).  If no argument is given, switch back to
 
8959
the previous font family.  Use @code{\F[]} to do this with the escape.
 
8960
Note that @code{\FP} doesn't work; it selects font family @samp{P}
 
8961
instead.
 
8962
 
 
8963
The value at start-up is @samp{T}.  The current font family is available
 
8964
in the read-only number register @samp{.fam} (this is a string-valued
 
8965
register); it is associated with the current environment.
 
8966
 
 
8967
@Example
 
8968
spam,
 
8969
.fam H    \" helvetica family
 
8970
spam,     \" used font is family H + style R = HR
 
8971
.ft B     \" family H + style B = font HB
 
8972
spam,
 
8973
.fam T    \" times family
 
8974
spam,     \" used font is family T + style B = TB
 
8975
.ft AR    \" font AR (not a style)
 
8976
baked beans,
 
8977
.ft R     \" family T + style R = font TR
 
8978
and spam.
 
8979
@endExample
 
8980
 
 
8981
Note that @code{\F} doesn't produce an input token in @code{gtroff}.  As
 
8982
a consequence, it can be used in requests like @code{mc} (which expects
 
8983
a single character as an argument) to change the font family on the fly:
 
8984
 
 
8985
@Example
 
8986
.mc \F[P]x\F[]
 
8987
@endExample
 
8988
 
 
8989
The @samp{.fn} register contains the current @dfn{real font name} of the
 
8990
current font.  This is a string-valued register.  If the current font is
 
8991
a style, the value of @code{\n[.fn]} is the proper concatenation of
 
8992
family and style name.
 
8993
@endDefreq
 
8994
 
 
8995
@Defreq {sty, n style}
 
8996
@cindex changing font style (@code{sty})
 
8997
@cindex font style, changing (@code{sty})
 
8998
@cindex @code{cs} request, and font styles
 
8999
@cindex @code{bd} request, and font styles
 
9000
@cindex @code{tkf} request, and font styles
 
9001
@cindex @code{uf} request, and font styles
 
9002
@cindex @code{fspecial} request, and font styles
 
9003
Associate @var{style} with font position@tie{}@var{n}.  A font position
 
9004
can be associated either with a font or with a style.  The current font
 
9005
is the index of a font position and so is also either a font or a style.
 
9006
If it is a style, the font that is actually used is the font which name
 
9007
is the concatenation of the name of the current family and the name of
 
9008
the current style.  For example, if the current font is@tie{}1 and font
 
9009
position@tie{}1 is associated with style @samp{R} and the current font
 
9010
family is @samp{T}, then font @samp{TR} is used.  If the current font is
 
9011
not a style, then the current family is ignored.  If the requests
 
9012
@code{cs}, @code{bd}, @code{tkf}, @code{uf}, or @code{fspecial} are
 
9013
applied to a style, they are instead applied to the member of the
 
9014
current family corresponding to that style.
 
9015
 
 
9016
@var{n}@tie{}must be a non-negative integer value.
 
9017
 
 
9018
@pindex DESC
 
9019
@kindex styles
 
9020
The default family can be set with the @option{-f} option (@pxref{Groff
 
9021
Options}).  The @code{styles} command in the @file{DESC} file controls
 
9022
which font positions (if any) are initially associated with styles
 
9023
rather than fonts.  For example, the default setting for @sc{PostScript}
 
9024
fonts
 
9025
 
 
9026
@Example
 
9027
styles R I B BI
 
9028
@endExample
 
9029
 
 
9030
@noindent
 
9031
is equivalent to
 
9032
 
 
9033
@Example
 
9034
.sty 1 R
 
9035
.sty 2 I
 
9036
.sty 3 B
 
9037
.sty 4 BI
 
9038
@endExample
 
9039
 
 
9040
@code{fam} and @code{\F} always check whether the current font position
 
9041
is valid; this can give surprising results if the current font position
 
9042
is associated with a style.
 
9043
 
 
9044
In the following example, we want to access the @sc{PostScript} font
 
9045
@code{FooBar} from the font family @code{Foo}:
 
9046
 
 
9047
@Example
 
9048
.sty \n[.fp] Bar
 
9049
.fam Foo
 
9050
    @result{} warning: can't find font `FooR'
 
9051
@endExample
 
9052
 
 
9053
@noindent
 
9054
The default font position at start-up is@tie{}1; for the @sc{PostScript}
 
9055
device, this is associated with style @samp{R}, so @code{gtroff} tries
 
9056
to open @code{FooR}.
 
9057
 
 
9058
A solution to this problem is to use a dummy font like the following:
 
9059
 
 
9060
@Example
 
9061
.fp 0 dummy TR    \" set up dummy font at position 0
 
9062
.sty \n[.fp] Bar  \" register style `Bar'
 
9063
.ft 0             \" switch to font at position 0
 
9064
.fam Foo          \" activate family `Foo'
 
9065
.ft Bar           \" switch to font `FooBar'
 
9066
@endExample
 
9067
 
 
9068
@xref{Font Positions}.
 
9069
@endDefreq
 
9070
 
 
9071
@c ---------------------------------------------------------------------
 
9072
 
 
9073
@node Font Positions, Using Symbols, Font Families, Fonts and Symbols
 
9074
@subsection Font Positions
 
9075
@cindex font positions
 
9076
@cindex positions, font
 
9077
 
 
9078
For the sake of old phototypesetters and compatibility with old versions
 
9079
of @code{troff}, @code{gtroff} has the concept of font @dfn{positions},
 
9080
on which various fonts are mounted.
 
9081
 
 
9082
@DefreqList {fp, pos font [@Var{external-name}]}
 
9083
@DefregItem {.f}
 
9084
@DefregListEnd {.fp}
 
9085
@cindex mounting font (@code{fp})
 
9086
@cindex font, mounting (@code{fp})
 
9087
Mount font @var{font} at position @var{pos} (which must be a
 
9088
non-negative integer).  This numeric position can then be referred to
 
9089
with font changing commands.  When @code{gtroff} starts it is using font
 
9090
position@tie{}1 (which must exist; position@tie{}0 is unused usually at
 
9091
start-up).
 
9092
 
 
9093
@cindex font position register (@code{.f})
 
9094
The current font in use, as a font position, is available in the
 
9095
read-only number register @samp{.f}.  This can be useful to remember the
 
9096
current font for later recall.  It is associated with the current
 
9097
environment (@pxref{Environments}).
 
9098
 
 
9099
@Example
 
9100
.nr save-font \n[.f]
 
9101
.ft B
 
9102
... text text text ...
 
9103
.ft \n[save-font]
 
9104
@endExample
 
9105
 
 
9106
@cindex next free font position register (@code{.fp})
 
9107
The number of the next free font position is available in the read-only
 
9108
number register @samp{.fp}.  This is useful when mounting a new font,
 
9109
like so:
 
9110
 
 
9111
@Example
 
9112
.fp \n[.fp] NEATOFONT
 
9113
@endExample
 
9114
 
 
9115
@pindex DESC@r{, and font mounting}
 
9116
Fonts not listed in the @file{DESC} file are automatically mounted on
 
9117
the next available font position when they are referenced.  If a font is
 
9118
to be mounted explicitly with the @code{fp} request on an unused font
 
9119
position, it should be mounted on the first unused font position, which
 
9120
can be found in the @code{.fp} register.  Although @code{gtroff} does
 
9121
not enforce this strictly, it is not allowed to mount a font at a
 
9122
position whose number is much greater (approx.@: 1000 positions) than
 
9123
that of any currently used position.
 
9124
 
 
9125
The @code{fp} request has an optional third argument.  This argument
 
9126
gives the external name of the font, which is used for finding the font
 
9127
description file.  The second argument gives the internal name of the
 
9128
font which is used to refer to the font in @code{gtroff} after it has
 
9129
been mounted.  If there is no third argument then the internal name is
 
9130
used as the external name.  This feature makes it possible to use fonts
 
9131
with long names in compatibility mode.
 
9132
@endDefreq
 
9133
 
 
9134
Both the @code{ft} request and the @code{\f} escape have alternative
 
9135
syntax forms to access font positions.
 
9136
 
 
9137
@DefreqList {ft, nnn}
 
9138
@DefescItem {\\f, , n, }
 
9139
@DefescItem {\\f, @Lparen{}, nn, }
 
9140
@DefescListEnd {\\f, @Lbrack{}, nnn, @Rbrack{}}
 
9141
@cindex changing font position (@code{\f})
 
9142
@cindex font position, changing (@code{\f})
 
9143
@cindex @code{sty} request, and font positions
 
9144
@cindex @code{fam} request, and font positions
 
9145
@cindex @code{\F}, and font positions
 
9146
@kindex styles
 
9147
@kindex family
 
9148
@pindex DESC
 
9149
Change the current font position to @var{nnn} (one-digit
 
9150
position@tie{}@var{n}, two-digit position @var{nn}), which must be a
 
9151
non-negative integer.
 
9152
 
 
9153
If @var{nnn} is associated with a style (as set with the @code{sty}
 
9154
request or with the @code{styles} command in the @file{DESC} file), use
 
9155
it within the current font family (as set with the @code{fam} request,
 
9156
the @code{\F} escape, or with the @code{family} command in the
 
9157
@file{DESC} file).
 
9158
 
 
9159
@Example
 
9160
this is font 1
 
9161
.ft 2
 
9162
this is font 2
 
9163
.ft                   \" switch back to font 1
 
9164
.ft 3
 
9165
this is font 3
 
9166
.ft
 
9167
this is font 1 again
 
9168
@endExample
 
9169
 
 
9170
@xref{Changing Fonts}, for the standard syntax form.
 
9171
@endDefreq
 
9172
 
 
9173
@c ---------------------------------------------------------------------
 
9174
 
 
9175
@node Using Symbols, Character Classes, Font Positions, Fonts and Symbols
 
9176
@subsection Using Symbols
 
9177
@cindex using symbols
 
9178
@cindex symbols, using
 
9179
 
 
9180
@cindex glyph
 
9181
@cindex character
 
9182
@cindex ligature
 
9183
A @dfn{glyph} is a graphical representation of a @dfn{character}.  While
 
9184
a character is an abstract entity containing semantic information, a
 
9185
glyph is something which can be actually seen on screen or paper.  It is
 
9186
possible that a character has multiple glyph representation forms (for
 
9187
example, the character `A' can be either written in a roman or an italic
 
9188
font, yielding two different glyphs); sometimes more than one character
 
9189
maps to a single glyph (this is a @dfn{ligature} -- the most common is
 
9190
`fi').
 
9191
 
 
9192
@cindex symbol
 
9193
@cindex special fonts
 
9194
@kindex fonts
 
9195
@pindex DESC
 
9196
@cindex @code{special} request, and glyph search order
 
9197
@cindex @code{fspecial} request, and glyph search order
 
9198
A @dfn{symbol} is simply a named glyph.  Within @code{gtroff}, all glyph
 
9199
names of a particular font are defined in its font file.  If the user
 
9200
requests a glyph not available in this font, @code{gtroff} looks up an
 
9201
ordered list of @dfn{special fonts}.  By default, the @sc{PostScript}
 
9202
output device supports the two special fonts @samp{SS} (slanted symbols)
 
9203
and @samp{S} (symbols) (the former is looked up before the latter).
 
9204
Other output devices use different names for special fonts.  Fonts
 
9205
mounted with the @code{fonts} keyword in the @file{DESC} file are
 
9206
globally available.  To install additional special fonts locally (i.e.@:
 
9207
for a particular font), use the @code{fspecial} request.
 
9208
 
 
9209
Here the exact rules how @code{gtroff} searches a given symbol:
 
9210
 
 
9211
@itemize @bullet
 
9212
@item
 
9213
If the symbol has been defined with the @code{char} request, use it.
 
9214
This hides a symbol with the same name in the current font.
 
9215
 
 
9216
@item
 
9217
Check the current font.
 
9218
 
 
9219
@item
 
9220
If the symbol has been defined with the @code{fchar} request, use it.
 
9221
 
 
9222
@item
 
9223
Check whether the current font has a font-specific list of special
 
9224
fonts; test all fonts in the order of appearance in the last
 
9225
@code{fspecial} call if appropriate.
 
9226
 
 
9227
@item
 
9228
If the symbol has been defined with the @code{fschar} request for the
 
9229
current font, use it.
 
9230
 
 
9231
@item
 
9232
Check all fonts in the order of appearance in the last @code{special}
 
9233
call.
 
9234
 
 
9235
@item
 
9236
If the symbol has been defined with the @code{schar} request, use it.
 
9237
 
 
9238
@item
 
9239
As a last resort, consult all fonts loaded up to now for special fonts
 
9240
and check them, starting with the lowest font number.  Note that this
 
9241
can sometimes lead to surprising results since the @code{fonts} line in
 
9242
the @file{DESC} file often contains empty positions which are filled
 
9243
later on.  For example, consider the following:
 
9244
 
 
9245
@Example
 
9246
fonts 3 0 0 FOO
 
9247
@endExample
 
9248
 
 
9249
@noindent
 
9250
This mounts font @code{foo} at font position@tie{}3.  We assume that
 
9251
@code{FOO} is a special font, containing glyph @code{foo}, and that no
 
9252
font has been loaded yet.  The line
 
9253
 
 
9254
@Example
 
9255
.fspecial BAR BAZ
 
9256
@endExample
 
9257
 
 
9258
@noindent
 
9259
makes font @code{BAZ} special only if font @code{BAR} is active.  We
 
9260
further assume that @code{BAZ} is really a special font, i.e., the font
 
9261
description file contains the @code{special} keyword, and that it also
 
9262
contains glyph @code{foo} with a special shape fitting to font
 
9263
@code{BAR}.  After executing @code{fspecial}, font @code{BAR} is loaded
 
9264
at font position@tie{}1, and @code{BAZ} at position@tie{}2.
 
9265
 
 
9266
We now switch to a new font @code{XXX}, trying to access glyph
 
9267
@code{foo} which is assumed to be missing.  There are neither
 
9268
font-specific special fonts for @code{XXX} nor any other fonts made
 
9269
special with the @code{special} request, so @code{gtroff} starts the
 
9270
search for special fonts in the list of already mounted fonts, with
 
9271
increasing font positions.  Consequently, it finds @code{BAZ} before
 
9272
@code{FOO} even for @code{XXX} which is not the intended behaviour.
 
9273
@end itemize
 
9274
 
 
9275
@xref{Font Files}, and @ref{Special Fonts}, for more details.
 
9276
 
 
9277
@cindex list of available glyphs (@cite{groff_char(7)} man page)
 
9278
@cindex available glyphs, list (@cite{groff_char(7)} man page)
 
9279
@cindex glyphs, available, list (@cite{groff_char(7)} man page)
 
9280
The list of available symbols is device dependent; see the
 
9281
@cite{groff_char(7)} man page for a complete list of all glyphs.  For
 
9282
example, say
 
9283
 
 
9284
@Example
 
9285
man -Tdvi groff_char > groff_char.dvi
 
9286
@endExample
 
9287
 
 
9288
@noindent
 
9289
for a list using the default DVI fonts (not all versions of the
 
9290
@code{man} program support the @option{-T} option).  If you want to use
 
9291
an additional macro package to change the used fonts, @code{groff} must
 
9292
be called directly:
 
9293
 
 
9294
@Example
 
9295
groff -Tdvi -mec -man groff_char.7 > groff_char.dvi
 
9296
@endExample
 
9297
 
 
9298
@cindex composite glyph names
 
9299
@cindex glyph names, composite
 
9300
@cindex groff glyph list (GGL)
 
9301
@cindex GGL (groff glyph list)
 
9302
@cindex adobe glyph list (AGL)
 
9303
@cindex AGL (adobe glyph list)
 
9304
Glyph names not listed in groff_char(7) are derived algorithmically,
 
9305
using a simplified version of the Adobe Glyph List (AGL) algorithm which
 
9306
is described in
 
9307
@uref{http://partners.adobe.com@//public@//developer@//opentype@//index_glyph.html}.
 
9308
The (frozen) set of glyph names which can't be derived algorithmically
 
9309
is called @dfn{groff glyph list (GGL)}.
 
9310
 
 
9311
@itemize @bullet
 
9312
@item
 
9313
A glyph for Unicode character U+@var{XXXX}[@var{X}[@var{X}]] which is
 
9314
not a composite character is named
 
9315
@code{u@var{XXXX}@r{[}@var{X}@r{[}@var{X}@r{]]}}.  @var{X} must be an
 
9316
uppercase hexadecimal digit.  Examples: @code{u1234}, @code{u008E},
 
9317
@code{u12DB8}.  The largest Unicode value is 0x10FFFF.  There must be at
 
9318
least four @code{X} digits; if necessary, add leading zeroes (after the
 
9319
@samp{u}).  No zero padding is allowed for character codes greater than
 
9320
0xFFFF.  Surrogates (i.e., Unicode values greater than 0xFFFF
 
9321
represented with character codes from the surrogate area U+D800-U+DFFF)
 
9322
are not allowed too.
 
9323
 
 
9324
@item
 
9325
A glyph representing more than a single input character is named
 
9326
 
 
9327
@display
 
9328
@samp{u} @var{component1} @samp{_} @var{component2} @samp{_} @var{component3} @dots{}
 
9329
@end display
 
9330
 
 
9331
@noindent
 
9332
Example: @code{u0045_0302_0301}.
 
9333
 
 
9334
For simplicity, all Unicode characters which are composites must be
 
9335
decomposed maximally (this is normalization form@tie{}D in the Unicode
 
9336
standard); for example, @code{u00CA_0301} is not a valid glyph name
 
9337
since U+00CA (@sc{latin capital letter e with circumflex}) can be
 
9338
further decomposed into U+0045 (@sc{latin capital letter e}) and U+0302
 
9339
(@sc{combining circumflex accent}).  @code{u0045_0302_0301} is thus the
 
9340
glyph name for U+1EBE, @sc{latin capital letter e with circumflex and
 
9341
acute}.
 
9342
 
 
9343
@item
 
9344
groff maintains a table to decompose all algorithmically derived glyph
 
9345
names which are composites itself.  For example, @code{u0100} (@sc{latin
 
9346
letter a with macron}) is automatically decomposed into
 
9347
@code{u0041_0304}.  Additionally, a glyph name of the GGL is preferred
 
9348
to an algorithmically derived glyph name; groff also automatically does
 
9349
the mapping.  Example: The glyph @code{u0045_0302} is mapped to
 
9350
@code{^E}.
 
9351
 
 
9352
@item
 
9353
glyph names of the GGL can't be used in composite glyph names; for
 
9354
example, @code{^E_u0301} is invalid.
 
9355
@end itemize
 
9356
 
 
9357
@DefescList {\\, @Lparen{}, nm, }
 
9358
@DefescItem {\\, @Lbrack{}, name, @Rbrack{}}
 
9359
@DefescListEnd {\\, @Lbrack{}, component1 component2 @dots{}, @Rbrack{}}
 
9360
Insert a symbol @var{name} (two-character name @var{nm}) or a composite
 
9361
glyph with component glyphs @var{component1}, @var{component2},
 
9362
@enddots{} There is no special syntax for one-character names -- the
 
9363
natural form @samp{\@var{n}} would collide with escapes.@footnote{Note
 
9364
that a one-character symbol is not the same as an input character, i.e.,
 
9365
the character @code{a} is not the same as @code{\[a]}.  By default,
 
9366
@code{groff} defines only a single one-character symbol, @code{\[-]}; it
 
9367
is usually accessed as @code{\-}.  On the other hand, @code{gtroff} has
 
9368
the special feature that @code{\[char@var{XXX}]} is the same as the
 
9369
input character with character code @var{XXX}.  For example,
 
9370
@code{\[char97]} is identical to the letter @code{a} if @acronym{ASCII}
 
9371
encoding is active.}
 
9372
 
 
9373
If @var{name} is undefined, a warning of type @samp{char} is generated,
 
9374
and the escape is ignored.  @xref{Debugging}, for information about
 
9375
warnings.
 
9376
 
 
9377
groff resolves @code{\[...]} with more than a single component as
 
9378
follows:
 
9379
 
 
9380
@itemize @bullet
 
9381
@item
 
9382
Any component which is found in the GGL is converted to the
 
9383
@code{u@var{XXXX}} form.
 
9384
 
 
9385
@item
 
9386
Any component @code{u@var{XXXX}} which is found in the list of
 
9387
decomposable glyphs is decomposed.
 
9388
 
 
9389
@item
 
9390
The resulting elements are then concatenated with @samp{_} in between,
 
9391
dropping the leading @samp{u} in all elements but the first.
 
9392
@end itemize
 
9393
 
 
9394
No check for the existence of any component (similar to @code{tr}
 
9395
request) is done.
 
9396
 
 
9397
Examples:
 
9398
 
 
9399
@table @code
 
9400
@item \[A ho]
 
9401
@samp{A} maps to @code{u0041}, @samp{ho} maps to @code{u02DB}, thus the
 
9402
final glyph name would be @code{u0041_02DB}.  Note this is not the
 
9403
expected result: The ogonek glyph @samp{ho} is a spacing ogonek, but for
 
9404
a proper composite a non-spacing ogonek (U+0328) is necessary.  Looking
 
9405
into the file @file{composite.tmac} one can find @w{@samp{.composite ho
 
9406
u0328}} which changes the mapping of @samp{ho} while a composite glyph
 
9407
name is constructed, causing the final glyph name to be
 
9408
@code{u0041_0328}.
 
9409
 
 
9410
@item \[^E u0301]
 
9411
@itemx \[^E aa]
 
9412
@itemx \[E a^ aa]
 
9413
@itemx \[E ^ ']
 
9414
@samp{^E} maps to @code{u0045_0302}, thus the final glyph name is
 
9415
@code{u0045_0302_0301} in all forms (assuming proper calls of the
 
9416
@code{composite} request).
 
9417
@end table
 
9418
 
 
9419
It is not possible to define glyphs with names like @w{@samp{A ho}}
 
9420
within a groff font file.  This is not really a limitation; instead, you
 
9421
have to define @code{u0041_0328}.
 
9422
@endDefesc
 
9423
 
 
9424
@Defesc {\\C, ', xxx, '}
 
9425
@cindex named character (@code{\C})
 
9426
@cindex character, named (@code{\C})
 
9427
Typeset the glyph named @var{xxx}.@footnote{@code{\C} is actually a
 
9428
misnomer since it accesses an output glyph.}  Normally it is more
 
9429
convenient to use @code{\[@var{xxx}]}, but @code{\C} has the advantage
 
9430
that it is compatible with newer versions of @acronym{AT&T} @code{troff}
 
9431
and is available in compatibility mode.
 
9432
@endDefesc
 
9433
 
 
9434
@Defreq {composite, from to}
 
9435
@pindex composite.tmac
 
9436
Map glyph name @var{from} to glyph name @var{to} if it is used in
 
9437
@code{\[...]} with more than one component.  See above for examples.
 
9438
 
 
9439
This mapping is based on glyph names only; no check for the existence of
 
9440
either glyph is done.
 
9441
 
 
9442
A set of default mappings for many accents can be found in the file
 
9443
@file{composite.tmac} which is loaded at start-up.
 
9444
@endDefreq
 
9445
 
 
9446
@Defesc {\\N, ', n, '}
 
9447
@cindex numbered glyph (@code{\N})
 
9448
@cindex glyph, numbered (@code{\N})
 
9449
@cindex @code{char} request, used with @code{\N}
 
9450
@cindex Unicode
 
9451
Typeset the glyph with code@tie{}@var{n} in the current font
 
9452
(@code{n}@tie{}is @strong{not} the input character code).  The number
 
9453
@var{n}@tie{}can be any non-negative decimal integer.  Most devices only
 
9454
have glyphs with codes between 0 and@tie{}255; the Unicode output device
 
9455
uses codes in the range 0--65535.  If the current font does not contain
 
9456
a glyph with that code, special fonts are @emph{not} searched.  The
 
9457
@code{\N} escape sequence can be conveniently used in conjunction with
 
9458
the @code{char} request:
 
9459
 
 
9460
@Example
 
9461
.char \[phone] \f[ZD]\N'37'
 
9462
@endExample
 
9463
 
 
9464
@noindent
 
9465
@pindex DESC
 
9466
@cindex unnamed glyphs
 
9467
@cindex glyphs, unnamed
 
9468
The code of each glyph is given in the fourth column in the font
 
9469
description file after the @code{charset} command.  It is possible to
 
9470
include unnamed glyphs in the font description file by using a name of
 
9471
@samp{---}; the @code{\N} escape sequence is the only way to use these.
 
9472
 
 
9473
No kerning is applied to glyphs accessed with @code{\N}.
 
9474
@endDefesc
 
9475
 
 
9476
Some escape sequences directly map onto special glyphs.
 
9477
 
 
9478
@Defesc {\\', , , }
 
9479
This is a backslash followed by the apostrophe character,
 
9480
@acronym{ASCII} character @code{0x27} (@acronym{EBCDIC} character
 
9481
@code{0x7D}).  The same as @code{\[aa]}, the acute accent.
 
9482
@endDefesc
 
9483
 
 
9484
@Defesc {\\`, , , }
 
9485
This is a backslash followed by @acronym{ASCII} character @code{0x60}
 
9486
(@acronym{EBCDIC} character @code{0x79} usually).  The same as
 
9487
@code{\[ga]}, the grave accent.
 
9488
@endDefesc
 
9489
 
 
9490
@Defesc {\\-, , , }
 
9491
This is the same as @code{\[-]}, the minus sign in the current font.
 
9492
@endDefesc
 
9493
 
 
9494
@Defesc {\\_, , , }
 
9495
This is the same as @code{\[ul]}, the underline character.
 
9496
@endDefesc
 
9497
 
 
9498
@Defreq {cflags, n c1 c2 @dots{}}
 
9499
@cindex glyph properties (@code{cflags})
 
9500
@cindex character properties (@code{cflags})
 
9501
@cindex properties of glyphs (@code{cflags})
 
9502
@cindex properties of characters (@code{cflags})
 
9503
Input characters and symbols have certain properties associated with
 
9504
it.@footnote{Note that the output glyphs themselves don't have such
 
9505
properties.  For @code{gtroff}, a glyph is a numbered box with a given
 
9506
width, depth, and height, nothing else.  All manipulations with the
 
9507
@code{cflags} request work on the input level.}  These properties can be
 
9508
modified with the @code{cflags} request.  The first argument is the sum
 
9509
of the desired flags and the remaining arguments are the characters or
 
9510
symbols to have those properties.  It is possible to omit the spaces
 
9511
between the characters or symbols.  Instead of single characters or
 
9512
symbols you can also use character classes (see @ref{Character Classes}
 
9513
for more details).
 
9514
 
 
9515
@table @code
 
9516
@item 1
 
9517
@cindex end-of-sentence characters
 
9518
@cindex characters, end-of-sentence
 
9519
The character ends sentences (initially characters @samp{.?!} have this
 
9520
property).
 
9521
 
 
9522
@item 2
 
9523
@cindex hyphenating characters
 
9524
@cindex characters, hyphenation
 
9525
Lines can be broken before the character (initially no characters have
 
9526
this property).  This only works if both the characters before and after
 
9527
have non-zero hyphenation codes (as set with the @code{hcode} request).
 
9528
Use value@tie{}64 to override this behaviour.
 
9529
 
 
9530
@item 4
 
9531
@cindex @code{hy} glyph, and @code{cflags}
 
9532
@cindex @code{em} glyph, and @code{cflags}
 
9533
Lines can be broken after the character (initially the character
 
9534
@samp{-} and the symbols @samp{\[hy]} and @samp{\[em]} have this
 
9535
property).  This only works if both the characters before and after have
 
9536
non-zero hyphenation codes (as set with the @code{hcode} request).  Use
 
9537
value@tie{}64 to override this behaviour.
 
9538
 
 
9539
@item 8
 
9540
@cindex overlapping characters
 
9541
@cindex characters, overlapping
 
9542
@cindex @code{ul} glyph, and @code{cflags}
 
9543
@cindex @code{rn} glyph, and @code{cflags}
 
9544
@cindex @code{ru} glyph, and @code{cflags}
 
9545
@cindex @code{radicalex} glyph, and @code{cflags}
 
9546
@cindex @code{sqrtex} glyph, and @code{cflags}
 
9547
The character overlaps horizontally if used as a horizontal line
 
9548
building element.  Initially the symbols @samp{\[ul]}, @samp{\[rn]},
 
9549
@samp{\[ru]}, @samp{\[radicalex]}, and @samp{\[sqrtex]} have this
 
9550
property.
 
9551
 
 
9552
@item 16
 
9553
@cindex @code{br} glyph, and @code{cflags}
 
9554
The character overlaps vertically if used as vertical line building
 
9555
element.  Initially symbol @samp{\[br]} has this property.
 
9556
 
 
9557
@item 32
 
9558
@cindex transparent characters
 
9559
@cindex character, transparent
 
9560
@cindex @code{"}, at end of sentence
 
9561
@cindex @code{'}, at end of sentence
 
9562
@cindex @code{)}, at end of sentence
 
9563
@cindex @code{]}, at end of sentence
 
9564
@cindex @code{*}, at end of sentence
 
9565
@cindex @code{dg} glyph, at end of sentence
 
9566
@cindex @code{rq} glyph, at end of sentence
 
9567
An end-of-sentence character followed by any number of characters with
 
9568
this property is treated as the end of a sentence if followed by a
 
9569
newline or two spaces; in other words the character is @dfn{transparent}
 
9570
for the purposes of end-of-sentence recognition -- this is the same as
 
9571
having a zero space factor in @TeX{} (initially characters @samp{"')]*}
 
9572
and the symbols @samp{\[dg]} and @samp{\[rq]} have this property).
 
9573
 
 
9574
@item 64
 
9575
Ignore hyphenation code values of the surrounding characters.  Use this
 
9576
in combination with values 2 and@tie{}4 (initially no characters have
 
9577
this property).  For example, if you need an automatic break point after
 
9578
the hyphen in number ranges like `3000-5000', insert
 
9579
 
 
9580
@Example
 
9581
.cflags 68 -
 
9582
@endExample
 
9583
 
 
9584
@noindent
 
9585
into your document.  Note, however, that this can lead to bad layout if
 
9586
done without thinking; in most situations, a better solution instead of
 
9587
changing the @code{cflags} value is to insert @code{\:} right after the
 
9588
hyphen at the places which really need a break point.
 
9589
 
 
9590
@item 128
 
9591
Prohibit a line break before the character, but allow a line break after
 
9592
the character.  This works only in combination with flags 256 and 512
 
9593
(see below) and has no effect otherwise.
 
9594
 
 
9595
@item 256
 
9596
Prohibit a line break after the character, but allow a line break before
 
9597
the character.  This works only in combination with flags 128 and 512
 
9598
(see below) and has no effect otherwise.
 
9599
 
 
9600
@item 512
 
9601
Allow line break before or after the character.  This works only in
 
9602
combination with flags 128 and 256 and has no effect otherwise.
 
9603
 
 
9604
Contrary to flag values 2 and@tie{}4, the flags 128, 256, and 512 work
 
9605
pairwise.  If, for example, the left character has value 512, and the
 
9606
right character 128, no line break gets inserted.  If we use
 
9607
value@tie{}6 instead for the left character, a line break after the
 
9608
character can't be suppressed since the right neighbour character
 
9609
doesn't get examined.
 
9610
@end table
 
9611
@endDefreq
 
9612
 
 
9613
@DefreqList {char, g [@Var{string}]}
 
9614
@DefreqItem {fchar, g [@Var{string}]}
 
9615
@DefreqItem {fschar, f g [@Var{string}]}
 
9616
@DefreqListEnd {schar, g [@Var{string}]}
 
9617
@cindex defining character (@code{char})
 
9618
@cindex defining fallback character (@code{fchar}, @code{fschar}, @code{schar})
 
9619
@cindex character, defining (@code{char})
 
9620
@cindex character, defining fallback (@code{fchar}, @code{fschar}, @code{schar})
 
9621
@cindex fallback character, defining (@code{fchar}, @code{fschar}, @code{schar})
 
9622
@cindex creating new characters (@code{char})
 
9623
@cindex defining symbol (@code{char})
 
9624
@cindex symbol, defining (@code{char})
 
9625
@cindex defining glyph (@code{char})
 
9626
@cindex glyph, defining (@code{char})
 
9627
@cindex escape character, while defining glyph
 
9628
@cindex character, escape, while defining glyph
 
9629
@cindex @code{tr} request, and glyph definitions
 
9630
@cindex @code{cp} request, and glyph definitions
 
9631
@cindex @code{rc} request, and glyph definitions
 
9632
@cindex @code{lc} request, and glyph definitions
 
9633
@cindex @code{\l}, and glyph definitions
 
9634
@cindex @code{\L}, and glyph definitions
 
9635
@cindex @code{\&}, and glyph definitions
 
9636
@cindex @code{\e}, and glyph definitions
 
9637
@cindex @code{hcode} request, and glyph definitions
 
9638
Define a new glyph@tie{}@var{g} to be @var{string} (which can be
 
9639
empty).@footnote{@code{char} is a misnomer since an output glyph is
 
9640
defined.}  Every time glyph@tie{}@var{g} needs to be printed,
 
9641
@var{string} is processed in a temporary environment and the result is
 
9642
wrapped up into a single object.  Compatibility mode is turned off and
 
9643
the escape character is set to @samp{\} while @var{string} is being
 
9644
processed.  Any emboldening, constant spacing or track kerning is
 
9645
applied to this object rather than to individual characters in
 
9646
@var{string}.
 
9647
 
 
9648
A glyph defined by these requests can be used just like a normal glyph
 
9649
provided by the output device.  In particular, other characters can be
 
9650
translated to it with the @code{tr} or @code{trin} requests; it can be
 
9651
made the leader character by the @code{lc} request; repeated patterns
 
9652
can be drawn with the glyph using the @code{\l} and @code{\L} escape
 
9653
sequences; words containing the glyph can be hyphenated correctly if the
 
9654
@code{hcode} request is used to give the glyph's symbol a hyphenation
 
9655
code.
 
9656
 
 
9657
There is a special anti-recursion feature: Use of @code{g} within the
 
9658
glyph's definition is handled like normal characters and symbols not
 
9659
defined with @code{char}.
 
9660
 
 
9661
Note that the @code{tr} and @code{trin} requests take precedence if
 
9662
@code{char} accesses the same symbol.
 
9663
 
 
9664
@Example
 
9665
.tr XY
 
9666
X
 
9667
    @result{} Y
 
9668
.char X Z
 
9669
X
 
9670
    @result{} Y
 
9671
.tr XX
 
9672
X
 
9673
    @result{} Z
 
9674
@endExample
 
9675
 
 
9676
The @code{fchar} request defines a fallback glyph: @code{gtroff} only
 
9677
checks for glyphs defined with @code{fchar} if it cannot find the glyph
 
9678
in the current font.  @code{gtroff} carries out this test before
 
9679
checking special fonts.
 
9680
 
 
9681
@code{fschar} defines a fallback glyph for font@tie{}@var{f}:
 
9682
@code{gtroff} checks for glyphs defined with @code{fschar} after the
 
9683
list of fonts declared as font-specific special fonts with the
 
9684
@code{fspecial} request, but before the list of fonts declared as global
 
9685
special fonts with the @code{special} request.
 
9686
 
 
9687
Finally, the @code{schar} request defines a global fallback glyph:
 
9688
@code{gtroff} checks for glyphs defined with @code{schar} after the list
 
9689
of fonts declared as global special fonts with the @code{special}
 
9690
request, but before the already mounted special fonts.
 
9691
 
 
9692
@xref{Using Symbols}, for a detailed description of the glyph searching
 
9693
mechanism in @code{gtroff}.
 
9694
@endDefreq
 
9695
 
 
9696
@DefreqList {rchar, c1 c2 @dots{}}
 
9697
@DefreqListEnd {rfschar, f c1 c2 @dots{}}
 
9698
@cindex removing glyph definition (@code{rchar}, @code{rfschar})
 
9699
@cindex glyph, removing definition (@code{rchar}, @code{rfschar})
 
9700
@cindex fallback glyph, removing definition (@code{rchar}, @code{rfschar})
 
9701
Remove the definitions of glyphs @var{c1}, @var{c2},@tie{}@enddots{}
 
9702
This undoes the effect of a @code{char}, @code{fchar}, or @code{schar}
 
9703
request.
 
9704
 
 
9705
It is possible to omit the whitespace between arguments.
 
9706
 
 
9707
The request @code{rfschar} removes glyph definitions defined with
 
9708
@code{fschar} for glyph@tie{}f.
 
9709
@endDefreq
 
9710
 
 
9711
@xref{Special Characters}.
 
9712
 
 
9713
@c ---------------------------------------------------------------------
 
9714
 
 
9715
@node Character Classes, Special Fonts, Using Symbols, Fonts and Symbols
 
9716
@subsection Character Classes
 
9717
@cindex character classes
 
9718
@cindex classes, character
 
9719
 
 
9720
Classes are particularly useful for East Asian languages such as
 
9721
Chinese, Japanese, and Korean, where the number of needed characters is
 
9722
much larger than in European languages, and where large sets of
 
9723
characters share the same properties.
 
9724
 
 
9725
@Defreq {class, n c1 c2 @dots{}}
 
9726
@cindex character class (@code{class})
 
9727
@cindex defining character class (@code{class})
 
9728
@cindex class of characters (@code{class})
 
9729
In @code{groff}, a @dfn{character class} (or simply ``class'') is a set
 
9730
of characters, grouped by some user aspect.  The @code{class} request
 
9731
defines such classes so that other requests can refer to all characters
 
9732
belonging to this set with a single class name.  Currently, only the
 
9733
@code{cflags} request can handle character classes.
 
9734
 
 
9735
A @code{class} request takes a class name followed by a list of
 
9736
entities.  In its simplest form, the entities are characters or symbols:
 
9737
 
 
9738
@Example
 
9739
.class [prepunct] , : ; > @}
 
9740
@endExample
 
9741
 
 
9742
Since class and glyph names share the same namespace, it is recommended
 
9743
to start and end the class name with @code{[} and @code{]},
 
9744
respectively, to avoid collisions with normal @code{groff} symbols (and
 
9745
symbols defined by the user).  In particular, the presence of @code{]}
 
9746
in the symbol name intentionally prevents the usage of @code{\[...]},
 
9747
thus you must use the @code{\C} escape to access a class with such a
 
9748
name.
 
9749
 
 
9750
@cindex GGL (groff glyph list)
 
9751
@cindex groff glyph list (GGL)
 
9752
You can also use a special character range notation, consisting of a
 
9753
start character or symbol, followed by @samp{-}, and an end character or
 
9754
symbol.  Internally, @code{gtroff} converts these two symbol names to
 
9755
Unicode values (according to the groff glyph gist) which then give the
 
9756
start and end value of the range.  If that fails, the class definition
 
9757
is skipped.
 
9758
 
 
9759
Finally, classes can be nested, too.
 
9760
 
 
9761
Here is a more complex example:
 
9762
 
 
9763
@Example
 
9764
.class [prepunctx] \C'[prepunct]' \[u2013]-\[u2016]
 
9765
@endExample
 
9766
 
 
9767
The class @samp{prepunctx} now contains the contents of the class
 
9768
@code{prepunct} as defined above (the set @samp{, : ; > @}}), and
 
9769
characters in the range between @code{U+2013} and @code{U+2016}.
 
9770
 
 
9771
If you want to add @samp{-} to a class, it must be the first character
 
9772
value in the argument list, otherwise it gets misinterpreted as a range.
 
9773
 
 
9774
Note that it is not possible to use class names within range
 
9775
definitions.
 
9776
 
 
9777
Typical use of the @code{class} request is to control line-breaking and
 
9778
hyphenation rules as defined by the @code{cflags} request.  For example,
 
9779
to inhibit line breaks before the characters belonging to the
 
9780
@code{prepunctx} class, you can write:
 
9781
 
 
9782
@Example
 
9783
.cflags 2 \C'[prepunctx]'
 
9784
@endExample
 
9785
 
 
9786
See the @code{cflags} request in @ref{Using Symbols}, for more details.
 
9787
@endDefreq
 
9788
 
 
9789
@c ---------------------------------------------------------------------
 
9790
 
 
9791
@node Special Fonts, Artificial Fonts, Character Classes, Fonts and Symbols
 
9792
@subsection Special Fonts
 
9793
@cindex special fonts
 
9794
@cindex fonts, special
 
9795
 
 
9796
Special fonts are those that @code{gtroff} searches when it cannot find
 
9797
the requested glyph in the current font.  The Symbol font is usually a
 
9798
special font.
 
9799
 
 
9800
@code{gtroff} provides the following two requests to add more special
 
9801
fonts.  @xref{Using Symbols}, for a detailed description of the glyph
 
9802
searching mechanism in @code{gtroff}.
 
9803
 
 
9804
Usually, only non-TTY devices have special fonts.
 
9805
 
 
9806
@DefreqList {special, [@Var{s1} @Var{s2} @dots{}]}
 
9807
@DefreqListEnd {fspecial, f [@Var{s1} @Var{s2} @dots{}]}
 
9808
@kindex fonts
 
9809
@pindex DESC
 
9810
Use the @code{special} request to define special fonts.  Initially, this
 
9811
list is empty.
 
9812
 
 
9813
Use the @code{fspecial} request to designate special fonts only when
 
9814
font@tie{}@var{f} is active.  Initially, this list is empty.
 
9815
 
 
9816
Previous calls to @code{special} or @code{fspecial} are overwritten;
 
9817
without arguments, the particular list of special fonts is set to empty.
 
9818
Special fonts are searched in the order they appear as arguments.
 
9819
 
 
9820
All fonts which appear in a call to @code{special} or @code{fspecial}
 
9821
are loaded.
 
9822
 
 
9823
@xref{Using Symbols}, for the exact search order of glyphs.
 
9824
@endDefreq
 
9825
 
 
9826
@c ---------------------------------------------------------------------
 
9827
 
 
9828
@node Artificial Fonts, Ligatures and Kerning, Special Fonts, Fonts and Symbols
 
9829
@subsection Artificial Fonts
 
9830
@cindex artificial fonts
 
9831
@cindex fonts, artificial
 
9832
 
 
9833
There are a number of requests and escapes for artificially creating
 
9834
fonts.  These are largely vestiges of the days when output devices did
 
9835
not have a wide variety of fonts, and when @code{nroff} and @code{troff}
 
9836
were separate programs.  Most of them are no longer necessary in GNU
 
9837
@code{troff}.  Nevertheless, they are supported.
 
9838
 
 
9839
@DefescList {\\H, ', height, '}
 
9840
@DefescItem {\\H, ', @t{+}height, '}
 
9841
@DefescItem {\\H, ', @t{-}height, '}
 
9842
@DefregListEnd {.height}
 
9843
@cindex changing the font height (@code{\H})
 
9844
@cindex font height, changing (@code{\H})
 
9845
@cindex height, font, changing (@code{\H})
 
9846
Change (increment, decrement) the height of the current font, but not
 
9847
the width.  If @var{height} is zero, restore the original height.
 
9848
Default scaling indicator is @samp{z}.
 
9849
 
 
9850
The read-only number register @code{.height} contains the font height as
 
9851
set by @code{\H}.
 
9852
 
 
9853
Currently, only the @option{-Tps} and @option{-Tpdf} devices support
 
9854
this feature.
 
9855
 
 
9856
Note that @code{\H} doesn't produce an input token in @code{gtroff}.  As
 
9857
a consequence, it can be used in requests like @code{mc} (which expects
 
9858
a single character as an argument) to change the font on the fly:
 
9859
 
 
9860
@Example
 
9861
.mc \H'+5z'x\H'0'
 
9862
@endExample
 
9863
 
 
9864
In compatibility mode, @code{gtroff} behaves differently: If an
 
9865
increment or decrement is used, it is always taken relative to the
 
9866
current point size and not relative to the previously selected font
 
9867
height.  Thus,
 
9868
 
 
9869
@Example
 
9870
.cp 1
 
9871
\H'+5'test \H'+5'test
 
9872
@endExample
 
9873
 
 
9874
@noindent
 
9875
prints the word @samp{test} twice with the same font height (five points
 
9876
larger than the current font size).
 
9877
@endDefesc
 
9878
 
 
9879
@DefescList {\\S, ', slant, '}
 
9880
@DefregListEnd {.slant}
 
9881
@cindex changing the font slant (@code{\S})
 
9882
@cindex font slant, changing (@code{\S})
 
9883
@cindex slant, font, changing (@code{\S})
 
9884
Slant the current font by @var{slant} degrees.  Positive values slant to
 
9885
the right.  Only integer values are possible.
 
9886
 
 
9887
The read-only number register @code{.slant} contains the font slant as
 
9888
set by @code{\S}.
 
9889
 
 
9890
Currently, only the @option{-Tps} and @option{-Tpdf} devices support
 
9891
this feature.
 
9892
 
 
9893
Note that @code{\S} doesn't produce an input token in @code{gtroff}.  As
 
9894
a consequence, it can be used in requests like @code{mc} (which expects
 
9895
a single character as an argument) to change the font on the fly:
 
9896
 
 
9897
@Example
 
9898
.mc \S'20'x\S'0'
 
9899
@endExample
 
9900
 
 
9901
This request is incorrectly documented in the original @acronym{UNIX}
 
9902
troff manual; the slant is always set to an absolute value.
 
9903
@endDefesc
 
9904
 
 
9905
@Defreq {ul, [@Var{lines}]}
 
9906
@cindex underlining (@code{ul})
 
9907
The @code{ul} request normally underlines subsequent lines if a TTY
 
9908
output device is used.  Otherwise, the lines are printed in italics
 
9909
(only the term `underlined' is used in the following).  The single
 
9910
argument is the number of input lines to be underlined; with no
 
9911
argument, the next line is underlined.  If @var{lines} is zero or
 
9912
negative, stop the effects of @code{ul} (if it was active).  Requests
 
9913
and empty lines do not count for computing the number of underlined
 
9914
input lines, even if they produce some output like @code{tl}.  Lines
 
9915
inserted by macros (e.g.@: invoked by a trap) do count.
 
9916
 
 
9917
At the beginning of @code{ul}, the current font is stored and the
 
9918
underline font is activated.  Within the span of a @code{ul} request, it
 
9919
is possible to change fonts, but after the last line affected by
 
9920
@code{ul} the saved font is restored.
 
9921
 
 
9922
This number of lines still to be underlined is associated with the
 
9923
current environment (@pxref{Environments}).  The underline font can be
 
9924
changed with the @code{uf} request.
 
9925
 
 
9926
@c XXX @xref should be changed to grotty
 
9927
 
 
9928
@c @xref{Troff and Nroff Mode}, for a discussion how underlining is
 
9929
@c implemented in for TTY output devices, and which problems can arise.
 
9930
 
 
9931
The @code{ul} request does not underline spaces.
 
9932
@endDefreq
 
9933
 
 
9934
@Defreq {cu, [@Var{lines}]}
 
9935
@cindex continuous underlining (@code{cu})
 
9936
@cindex underlining, continuous (@code{cu})
 
9937
The @code{cu} request is similar to @code{ul} but underlines spaces as
 
9938
well (if a TTY output device is used).
 
9939
@endDefreq
 
9940
 
 
9941
@Defreq {uf, font}
 
9942
@cindex underline font (@code{uf})
 
9943
@cindex font for underlining (@code{uf})
 
9944
Set the underline font (globally) used by @code{ul} and @code{cu}.  By
 
9945
default, this is the font at position@tie{}2.  @var{font} can be either
 
9946
a non-negative font position or the name of a font.
 
9947
@endDefreq
 
9948
 
 
9949
@DefreqList {bd, font [@Var{offset}]}
 
9950
@DefreqItem {bd, font1 font2 [@Var{offset}]}
 
9951
@DefregListEnd {.b}
 
9952
@cindex imitating bold face (@code{bd})
 
9953
@cindex bold face, imitating (@code{bd})
 
9954
Artificially create a bold font by printing each glyph twice, slightly
 
9955
offset.
 
9956
 
 
9957
Two syntax forms are available.
 
9958
 
 
9959
@itemize @bullet
 
9960
@item
 
9961
Imitate a bold font unconditionally.  The first argument specifies the
 
9962
font to embolden, and the second is the number of basic units, minus
 
9963
one, by which the two glyphs are offset.  If the second argument is
 
9964
missing, emboldening is turned off.
 
9965
 
 
9966
@var{font} can be either a non-negative font position or the name of a
 
9967
font.
 
9968
 
 
9969
@var{offset} is available in the @code{.b} read-only register if a
 
9970
special font is active; in the @code{bd} request, its default unit is
 
9971
@samp{u}.
 
9972
 
 
9973
@cindex @code{fspecial} request, and imitating bold
 
9974
@kindex special
 
9975
@cindex embolding of special fonts
 
9976
@cindex special fonts, emboldening
 
9977
@item
 
9978
Imitate a bold form conditionally.  Embolden @var{font1} by @var{offset}
 
9979
only if font @var{font2} is the current font.  This command can be
 
9980
issued repeatedly to set up different emboldening values for different
 
9981
current fonts.  If the second argument is missing, emboldening is turned
 
9982
off for this particular current font.
 
9983
 
 
9984
This affects special fonts only (either set up with the @code{special}
 
9985
command in font files or with the @code{fspecial} request).
 
9986
@end itemize
 
9987
@endDefreq
 
9988
 
 
9989
@Defreq {cs, font [@Var{width} [@Var{em-size}]]}
 
9990
@cindex constant glyph space mode (@code{cs})
 
9991
@cindex mode for constant glyph space (@code{cs})
 
9992
@cindex glyph, constant space
 
9993
@cindex @code{ps} request, and constant glyph space mode
 
9994
Switch to and from @dfn{constant glyph space mode}.  If activated, the
 
9995
width of every glyph is @math{@var{width}/36} ems.  The em size is given
 
9996
absolutely by @var{em-size}; if this argument is missing, the em value
 
9997
is taken from the current font size (as set with the @code{ps} request)
 
9998
when the font is effectively in use.  Without second and third argument,
 
9999
constant glyph space mode is deactivated.
 
10000
 
 
10001
Default scaling indicator for @var{em-size} is @samp{z}; @var{width} is
 
10002
an integer.
 
10003
@endDefreq
 
10004
 
 
10005
@c ---------------------------------------------------------------------
 
10006
 
 
10007
@node Ligatures and Kerning,  , Artificial Fonts, Fonts and Symbols
 
10008
@subsection Ligatures and Kerning
 
10009
@cindex ligatures and kerning
 
10010
@cindex kerning and ligatures
 
10011
 
 
10012
Ligatures are groups of characters that are run together, i.e, producing
 
10013
a single glyph.  For example, the letters `f' and `i' can form a
 
10014
ligature `fi' as in the word `file'.  This produces a cleaner look
 
10015
(albeit subtle) to the printed output.  Usually, ligatures are not
 
10016
available in fonts for TTY output devices.
 
10017
 
 
10018
Most @sc{PostScript} fonts support the fi and fl ligatures.  The C/A/T
 
10019
typesetter that was the target of @acronym{AT&T} @code{troff} also
 
10020
supported `ff', `ffi', and `ffl' ligatures.  Advanced typesetters or
 
10021
`expert' fonts may include ligatures for `ft' and `ct', although GNU
 
10022
@code{troff} does not support these (yet).
 
10023
 
 
10024
Only the current font is checked for ligatures and kerns; neither
 
10025
special fonts nor entities defined with the @code{char} request (and its
 
10026
siblings) are taken into account.
 
10027
 
 
10028
@DefreqList {lg, [@Var{flag}]}
 
10029
@DefregListEnd {.lg}
 
10030
@cindex activating ligatures (@code{lg})
 
10031
@cindex ligatures, activating (@code{lg})
 
10032
@cindex ligatures enabled register (@code{.lg})
 
10033
Switch the ligature mechanism on or off; if the parameter is non-zero or
 
10034
missing, ligatures are enabled, otherwise disabled.  Default is on.  The
 
10035
current ligature mode can be found in the read-only number register
 
10036
@code{.lg} (set to 1 or@tie{}2 if ligatures are enabled,
 
10037
0@tie{}otherwise).
 
10038
 
 
10039
Setting the ligature mode to@tie{}2 enables the two-character ligatures
 
10040
(fi, fl, and ff) and disables the three-character ligatures (ffi and
 
10041
ffl).
 
10042
@endDefreq
 
10043
 
 
10044
@dfn{Pairwise kerning} is another subtle typesetting mechanism that
 
10045
modifies the distance between a glyph pair to improve readability.  In
 
10046
most cases (but not always) the distance is decreased.
 
10047
@iftex
 
10048
For example, compare the combination of the letters `V' and `A'.  With
 
10049
kerning, `VA' is printed.  Without kerning it appears as `V@w{}A'.
 
10050
@end iftex
 
10051
Typewriter-like fonts and fonts for terminals where all glyphs have the
 
10052
same width don't use kerning.
 
10053
 
 
10054
@DefreqList {kern, [@Var{flag}]}
 
10055
@DefregListEnd {.kern}
 
10056
@cindex activating kerning (@code{kern})
 
10057
@cindex kerning, activating (@code{kern})
 
10058
@cindex kerning enabled register (@code{.kern})
 
10059
Switch kerning on or off.  If the parameter is non-zero or missing,
 
10060
enable pairwise kerning, otherwise disable it.  The read-only number
 
10061
register @code{.kern} is set to@tie{}1 if pairwise kerning is enabled,
 
10062
0@tie{}otherwise.
 
10063
 
 
10064
@cindex zero width space character (@code{\&})
 
10065
@cindex character, zero width space (@code{\&})
 
10066
@cindex space character, zero width (@code{\&})
 
10067
If the font description file contains pairwise kerning information,
 
10068
glyphs from that font are kerned.  Kerning between two glyphs can be
 
10069
inhibited by placing @code{\&} between them: @samp{V\&A}.
 
10070
 
 
10071
@xref{Font File Format}.
 
10072
@endDefreq
 
10073
 
 
10074
@cindex track kerning
 
10075
@cindex kerning, track
 
10076
@dfn{Track kerning} expands or reduces the space between glyphs.  This
 
10077
can be handy, for example, if you need to squeeze a long word onto a
 
10078
single line or spread some text to fill a narrow column.  It must be
 
10079
used with great care since it is usually considered bad typography if
 
10080
the reader notices the effect.
 
10081
 
 
10082
@Defreq {tkf, f s1 n1 s2 n2}
 
10083
@cindex activating track kerning (@code{tkf})
 
10084
@cindex track kerning, activating (@code{tkf})
 
10085
Enable track kerning for font@tie{}@var{f}.  If the current font
 
10086
is@tie{}@var{f} the width of every glyph is increased by an amount
 
10087
between @var{n1} and @var{n2} (@var{n1}, @var{n2} can be negative); if
 
10088
the current point size is less than or equal to @var{s1} the width is
 
10089
increased by @var{n1}; if it is greater than or equal to @var{s2} the
 
10090
width is increased by @var{n2}; if the point size is greater than or
 
10091
equal to @var{s1} and less than or equal to @var{s2} the increase in
 
10092
width is a linear function of the point size.
 
10093
 
 
10094
The default scaling indicator is @samp{z} for @var{s1} and @var{s2},
 
10095
@samp{p} for @var{n1} and @var{n2}.
 
10096
 
 
10097
Note that the track kerning amount is added even to the rightmost glyph
 
10098
in a line; for large values it is thus recommended to increase the line
 
10099
length by the same amount to compensate it.
 
10100
@endDefreq
 
10101
 
 
10102
Sometimes, when typesetting letters of different fonts, more or less
 
10103
space at such boundaries are needed.  There are two escapes to help with
 
10104
this.
 
10105
 
 
10106
@Defesc {\\/, , , }
 
10107
@cindex italic correction (@code{\/})
 
10108
@cindex correction, italic (@code{\/})
 
10109
@cindex correction between italic and roman glyph (@code{\/}, @code{\,})
 
10110
@cindex roman glyph, correction after italic glyph (@code{\/})
 
10111
@cindex italic glyph, correction before roman glyph (@code{\/})
 
10112
@cindex glyph, italic correction (@code{\/})
 
10113
Increase the width of the preceding glyph so that the spacing between
 
10114
that glyph and the following glyph is correct if the following glyph is
 
10115
a roman glyph.  For example, if an italic@tie{}@code{f} is immediately
 
10116
followed by a roman right parenthesis, then in many fonts the top right
 
10117
portion of the@tie{}@code{f} overlaps the top left of the right
 
10118
parenthesis.  Use this escape sequence whenever an italic glyph is
 
10119
immediately followed by a roman glyph without any intervening space.
 
10120
This small amount of space is also called @dfn{italic correction}.
 
10121
 
 
10122
@iftex
 
10123
@c can't use @Example...@endExample here
 
10124
@example
 
10125
@group
 
10126
\f[I]f\f[R])
 
10127
    @result{} {@it f}@r{)}
 
10128
\f[I]f\/\f[R])
 
10129
    @result{} @i{f}@r{)}
 
10130
@end group
 
10131
@end example
 
10132
@end iftex
 
10133
@endDefesc
 
10134
 
 
10135
@Defesc {\\\,, , , }
 
10136
@cindex left italic correction (@code{\,})
 
10137
@cindex correction, left italic (@code{\,})
 
10138
@cindex glyph, left italic correction (@code{\,})
 
10139
@cindex roman glyph, correction before italic glyph (@code{\,})
 
10140
@cindex italic glyph, correction after roman glyph (@code{\,})
 
10141
Modify the spacing of the following glyph so that the spacing between
 
10142
that glyph and the preceding glyph is correct if the preceding glyph is
 
10143
a roman glyph.  Use this escape sequence whenever a roman glyph is
 
10144
immediately followed by an italic glyph without any intervening space.
 
10145
In analogy to above, this space could be called @dfn{left italic
 
10146
correction}, but this term isn't used widely.
 
10147
 
 
10148
@iftex
 
10149
@c can't use @Example...@endExample here
 
10150
@example
 
10151
@group
 
10152
q\f[I]f
 
10153
    @result{} @r{q}@i{f}
 
10154
q\,\f[I]f
 
10155
    @result{} @r{q}@math{@ptexcomma}@i{f}
 
10156
@end group
 
10157
@end example
 
10158
@end iftex
 
10159
@endDefesc
 
10160
 
 
10161
@Defesc {\\&, , , }
 
10162
Insert a zero-width character, which is invisible.  Its intended use is
 
10163
to stop interaction of a character with its surrounding.
 
10164
 
 
10165
@itemize @bullet
 
10166
@item
 
10167
It prevents the insertion of extra space after an end-of-sentence
 
10168
character.
 
10169
 
 
10170
@Example
 
10171
Test.
 
10172
Test.
 
10173
    @result{} Test.  Test.
 
10174
Test.\&
 
10175
Test.
 
10176
    @result{} Test. Test.
 
10177
@endExample
 
10178
 
 
10179
@item
 
10180
It prevents interpretation of a control character at the beginning of an
 
10181
input line.
 
10182
 
 
10183
@Example
 
10184
.Test
 
10185
    @result{} warning: `Test' not defined
 
10186
\&.Test
 
10187
    @result{} .Test
 
10188
@endExample
 
10189
 
 
10190
@item
 
10191
It prevents kerning between two glyphs.
 
10192
 
 
10193
@iftex
 
10194
@c can't use @Example...@endExample here
 
10195
@example
 
10196
@group
 
10197
VA
 
10198
    @result{} @r{VA}
 
10199
V\&A
 
10200
    @result{} @r{V@w{}A}
 
10201
@end group
 
10202
@end example
 
10203
@end iftex
 
10204
 
 
10205
@item
 
10206
It is needed to map an arbitrary character to nothing in the @code{tr}
 
10207
request (@pxref{Character Translations}).
 
10208
@end itemize
 
10209
@endDefesc
 
10210
 
 
10211
@Defesc {\\), , , }
 
10212
This escape is similar to @code{\&} except that it behaves like a
 
10213
character declared with the @code{cflags} request to be transparent for
 
10214
the purposes of an end-of-sentence character.
 
10215
 
 
10216
Its main usage is in macro definitions to protect against arguments
 
10217
starting with a control character.
 
10218
 
 
10219
@Example
 
10220
.de xxx
 
10221
\)\\$1
 
10222
..
 
10223
.de yyy
 
10224
\&\\$1
 
10225
..
 
10226
This is a test.\c
 
10227
.xxx '
 
10228
This is a test.
 
10229
    @result{}This is a test.'  This is a test.
 
10230
This is a test.\c
 
10231
.yyy '
 
10232
This is a test.
 
10233
    @result{}This is a test.' This is a test.
 
10234
@endExample
 
10235
@endDefesc
 
10236
 
 
10237
 
 
10238
@c =====================================================================
 
10239
 
 
10240
@node Sizes, Strings, Fonts and Symbols, gtroff Reference
 
10241
@section Sizes
 
10242
@cindex sizes
 
10243
 
 
10244
@cindex baseline
 
10245
@cindex type size
 
10246
@cindex size of type
 
10247
@cindex vertical spacing
 
10248
@cindex spacing, vertical
 
10249
@code{gtroff} uses two dimensions with each line of text, type size and
 
10250
vertical spacing.  The @dfn{type size} is approximately the height of
 
10251
the tallest glyph.@footnote{This is usually the parenthesis.  Note that
 
10252
in most cases the real dimensions of the glyphs in a font are @emph{not}
 
10253
related to its type size!  For example, the standard @sc{PostScript}
 
10254
font families `Times Roman', `Helvetica', and `Courier' can't be used
 
10255
together at 10@dmn{pt}; to get acceptable output, the size of
 
10256
`Helvetica' has to be reduced by one point, and the size of `Courier'
 
10257
must be increased by one point.}  @dfn{Vertical spacing} is the amount
 
10258
of space @code{gtroff} allows for a line of text; normally, this is
 
10259
about 20%@tie{}larger than the current type size.  Ratios smaller than
 
10260
this can result in hard-to-read text; larger than this, it spreads the
 
10261
text out more vertically (useful for term papers).  By default,
 
10262
@code{gtroff} uses 10@tie{}point type on 12@tie{}point spacing.
 
10263
 
 
10264
@cindex leading
 
10265
The difference between type size and vertical spacing is known, by
 
10266
typesetters, as @dfn{leading} (this is pronounced `ledding').
 
10267
 
 
10268
@menu
 
10269
* Changing Type Sizes::
 
10270
* Fractional Type Sizes::
 
10271
@end menu
 
10272
 
 
10273
@c ---------------------------------------------------------------------
 
10274
 
 
10275
@node Changing Type Sizes, Fractional Type Sizes, Sizes, Sizes
 
10276
@subsection Changing Type Sizes
 
10277
 
 
10278
@DefreqList {ps, [@Var{size}]}
 
10279
@DefreqItem {ps, @t{+}@Var{size}}
 
10280
@DefreqItem {ps, @t{-}@Var{size}}
 
10281
@DefescItem {\\s, , size, }
 
10282
@DefregListEnd {.s}
 
10283
@cindex changing type sizes (@code{ps}, @code{\s})
 
10284
@cindex type sizes, changing (@code{ps}, @code{\s})
 
10285
@cindex point sizes, changing (@code{ps}, @code{\s})
 
10286
Use the @code{ps} request or the @code{\s} escape to change (increase,
 
10287
decrease) the type size (in points).  Specify @var{size} as either an
 
10288
absolute point size, or as a relative change from the current size.  The
 
10289
size@tie{}0, or no argument, goes back to the previous size.
 
10290
 
 
10291
Default scaling indicator of @code{size} is @samp{z}.  If @code{size} is
 
10292
zero or negative, it is set to 1@dmn{u}.
 
10293
 
 
10294
@cindex type size registers (@code{.s}, @code{.ps})
 
10295
@cindex point size registers (@code{.s}, @code{.ps})
 
10296
The read-only number register @code{.s} returns the point size in points
 
10297
as a decimal fraction.  This is a string.  To get the point size in
 
10298
scaled points, use the @code{.ps} register instead.
 
10299
 
 
10300
@code{.s} is associated with the current environment
 
10301
(@pxref{Environments}).
 
10302
 
 
10303
@Example
 
10304
snap, snap,
 
10305
.ps +2
 
10306
grin, grin,
 
10307
.ps +2
 
10308
wink, wink, \s+2nudge, nudge,\s+8 say no more!
 
10309
.ps 10
 
10310
@endExample
 
10311
 
 
10312
The @code{\s} escape may be called in a variety of ways.  Much like
 
10313
other escapes there must be a way to determine where the argument ends
 
10314
and the text begins.  Any of the following forms are valid:
 
10315
 
 
10316
@table @code
 
10317
@item \s@var{n}
 
10318
Set the point size to @var{n}@tie{}points.  @var{n}@tie{}must be either
 
10319
0 or in the range 4 to@tie{}39.
 
10320
 
 
10321
@item \s+@var{n}
 
10322
@itemx \s-@var{n}
 
10323
Increase or decrease the point size by @var{n}@tie{}points.
 
10324
@var{n}@tie{}must be exactly one digit.
 
10325
 
 
10326
@item \s(@var{nn}
 
10327
Set the point size to @var{nn}@tie{}points.  @var{nn} must be exactly
 
10328
two digits.
 
10329
 
 
10330
@item \s+(@var{nn}
 
10331
@itemx \s-(@var{nn}
 
10332
@itemx \s(+@var{nn}
 
10333
@itemx \s(-@var{nn}
 
10334
Increase or decrease the point size by @var{nn}@tie{}points.  @var{nn}
 
10335
must be exactly two digits.
 
10336
@end table
 
10337
 
 
10338
Note that @code{\s} doesn't produce an input token in @code{gtroff}.  As
 
10339
a consequence, it can be used in requests like @code{mc} (which expects
 
10340
a single character as an argument) to change the font on the fly:
 
10341
 
 
10342
@Example
 
10343
.mc \s[20]x\s[0]
 
10344
@endExample
 
10345
 
 
10346
@xref{Fractional Type Sizes}, for yet another syntactical form of using
 
10347
the @code{\s} escape.
 
10348
@endDefreq
 
10349
 
 
10350
@Defreq {sizes, s1 s2 @dots{} sn [0]}
 
10351
Some devices may only have certain permissible sizes, in which case
 
10352
@code{gtroff} rounds to the nearest permissible size.  The @file{DESC}
 
10353
file specifies which sizes are permissible for the device.
 
10354
 
 
10355
Use the @code{sizes} request to change the permissible sizes for the
 
10356
current output device.  Arguments are in scaled points; the
 
10357
@code{sizescale} line in the @file{DESC} file for the output device
 
10358
provides the scaling factor.  For example, if the scaling factor is
 
10359
1000, then the value 12000 is 12@tie{}points.
 
10360
 
 
10361
Each argument can be a single point size (such as @samp{12000}), or a
 
10362
range of sizes (such as @samp{4000-72000}).  You can optionally end the
 
10363
list with a zero.
 
10364
@endDefreq
 
10365
 
 
10366
@DefreqList {vs, [@Var{space}]}
 
10367
@DefreqItem {vs, @t{+}@Var{space}}
 
10368
@DefreqItem {vs, @t{-}@Var{space}}
 
10369
@DefregListEnd {.v}
 
10370
@cindex changing vertical line spacing (@code{vs})
 
10371
@cindex vertical line spacing, changing (@code{vs})
 
10372
@cindex vertical line spacing register (@code{.v})
 
10373
Change (increase, decrease) the vertical spacing by @var{space}.  The
 
10374
default scaling indicator is @samp{p}.
 
10375
 
 
10376
If @code{vs} is called without an argument, the vertical spacing is
 
10377
reset to the previous value before the last call to @code{vs}.
 
10378
 
 
10379
@cindex @code{.V} register, and @code{vs}
 
10380
@code{gtroff} creates a warning of type @samp{range} if @var{space} is
 
10381
negative; the vertical spacing is then set to smallest positive value,
 
10382
the vertical resolution (as given in the @code{.V} register).
 
10383
 
 
10384
Note that @w{@samp{.vs 0}} isn't saved in a diversion since it doesn't
 
10385
result in a vertical motion.  You explicitly have to repeat this command
 
10386
before inserting the diversion.
 
10387
 
 
10388
The read-only number register @code{.v} contains the current vertical
 
10389
spacing; it is associated with the current environment
 
10390
(@pxref{Environments}).
 
10391
@endDefreq
 
10392
 
 
10393
@cindex vertical line spacing, effective value
 
10394
The effective vertical line spacing consists of four components.
 
10395
Breaking a line causes the following actions (in the given order).
 
10396
 
 
10397
@itemize @bullet
 
10398
@item
 
10399
@cindex extra pre-vertical line space (@code{\x})
 
10400
@cindex line space, extra pre-vertical (@code{\x})
 
10401
Move the current point vertically by the @dfn{extra pre-vertical line
 
10402
space}.  This is the minimum value of all @code{\x} escapes with a
 
10403
negative argument in the current output line.
 
10404
 
 
10405
@item
 
10406
Move the current point vertically by the vertical line spacing as set
 
10407
with the @code{vs} request.
 
10408
 
 
10409
@item
 
10410
Output the current line.
 
10411
 
 
10412
@item
 
10413
@cindex extra post-vertical line space (@code{\x})
 
10414
@cindex line space, extra post-vertical (@code{\x})
 
10415
Move the current point vertically by the @dfn{extra post-vertical line
 
10416
space}.  This is the maximum value of all @code{\x} escapes with a
 
10417
positive argument in the line which has just been output.
 
10418
 
 
10419
@item
 
10420
@cindex post-vertical line spacing
 
10421
@cindex line spacing, post-vertical (@code{pvs})
 
10422
Move the current point vertically by the @dfn{post-vertical line
 
10423
spacing} as set with the @code{pvs} request.
 
10424
@end itemize
 
10425
 
 
10426
@cindex double-spacing (@code{vs}, @code{pvs})
 
10427
It is usually better to use @code{vs} or @code{pvs} instead of @code{ls}
 
10428
to produce double-spaced documents: @code{vs} and @code{pvs} have a
 
10429
finer granularity for the inserted vertical space compared to @code{ls};
 
10430
furthermore, certain preprocessors assume single-spacing.
 
10431
 
 
10432
@xref{Manipulating Spacing}, for more details on the @code{\x} escape
 
10433
and the @code{ls} request.
 
10434
 
 
10435
@DefreqList {pvs, [@Var{space}]}
 
10436
@DefreqItem {pvs, @t{+}@Var{space}}
 
10437
@DefreqItem {pvs, @t{-}@Var{space}}
 
10438
@DefregListEnd {.pvs}
 
10439
@cindex @code{ls} request, alternative to (@code{pvs})
 
10440
@cindex post-vertical line spacing, changing (@code{pvs})
 
10441
@cindex post-vertical line spacing register (@code{.pvs})
 
10442
Change (increase, decrease) the post-vertical spacing by @var{space}.
 
10443
The default scaling indicator is @samp{p}.
 
10444
 
 
10445
If @code{pvs} is called without an argument, the post-vertical spacing
 
10446
is reset to the previous value before the last call to @code{pvs}.
 
10447
 
 
10448
@code{gtroff} creates a warning of type @samp{range} if @var{space} is
 
10449
zero or negative; the vertical spacing is then set to zero.
 
10450
 
 
10451
The read-only number register @code{.pvs} contains the current
 
10452
post-vertical spacing; it is associated with the current environment
 
10453
(@pxref{Environments}).
 
10454
@endDefreq
 
10455
 
 
10456
@c ---------------------------------------------------------------------
 
10457
 
 
10458
@node Fractional Type Sizes,  , Changing Type Sizes, Sizes
 
10459
@subsection Fractional Type Sizes
 
10460
@cindex fractional type sizes
 
10461
@cindex fractional point sizes
 
10462
@cindex type sizes, fractional
 
10463
@cindex point sizes, fractional
 
10464
@cindex sizes, fractional
 
10465
 
 
10466
@cindex @code{s} unit
 
10467
@cindex unit, @code{s}
 
10468
@cindex @code{z} unit
 
10469
@cindex unit, @code{z}
 
10470
@cindex @code{ps} request, with fractional type sizes
 
10471
@cindex @code{cs} request, with fractional type sizes
 
10472
@cindex @code{tkf} request, with fractional type sizes
 
10473
@cindex @code{\H}, with fractional type sizes
 
10474
@cindex @code{\s}, with fractional type sizes
 
10475
A @dfn{scaled point} is equal to @math{1/@var{sizescale}} points, where
 
10476
@var{sizescale} is specified in the @file{DESC} file (1@tie{}by
 
10477
default).  There is a new scale indicator @samp{z} which has the effect
 
10478
of multiplying by @var{sizescale}.  Requests and escape sequences in
 
10479
@code{gtroff} interpret arguments that represent a point size as being
 
10480
in units of scaled points, but they evaluate each such argument using a
 
10481
default scale indicator of @samp{z}.  Arguments treated in this way are
 
10482
the argument to the @code{ps} request, the third argument to the
 
10483
@code{cs} request, the second and fourth arguments to the @code{tkf}
 
10484
request, the argument to the @code{\H} escape sequence, and those
 
10485
variants of the @code{\s} escape sequence that take a numeric expression
 
10486
as their argument (see below).
 
10487
 
 
10488
For example, suppose @var{sizescale} is@tie{}1000; then a scaled point
 
10489
is equivalent to a millipoint; the request @w{@samp{.ps 10.25}} is
 
10490
equivalent to @w{@samp{.ps 10.25z}} and thus sets the point size to
 
10491
10250@tie{}scaled points, which is equal to 10.25@tie{}points.
 
10492
 
 
10493
@code{gtroff} disallows the use of the @samp{z} scale indicator in
 
10494
instances where it would make no sense, such as a numeric expression
 
10495
whose default scale indicator was neither @samp{u} nor @samp{z}.
 
10496
Similarly it would make no sense to use a scaling indicator other than
 
10497
@samp{z} or @samp{u} in a numeric expression whose default scale
 
10498
indicator was @samp{z}, and so @code{gtroff} disallows this as well.
 
10499
 
 
10500
There is also new scale indicator @samp{s} which multiplies by the
 
10501
number of units in a scaled point.  So, for example, @samp{\n[.ps]s} is
 
10502
equal to @samp{1m}.  Be sure not to confuse the @samp{s} and @samp{z}
 
10503
scale indicators.
 
10504
 
 
10505
@Defreg {.ps}
 
10506
A read-only number register returning the point size in scaled points.
 
10507
 
 
10508
@code{.ps} is associated with the current environment
 
10509
(@pxref{Environments}).
 
10510
@endDefreg
 
10511
 
 
10512
@DefregList {.psr}
 
10513
@DefregListEnd {.sr}
 
10514
@cindex last-requested point size registers (@code{.psr}, @code{.sr})
 
10515
@cindex point size registers, last-requested (@code{.psr}, @code{.sr})
 
10516
@cindex @code{.ps} register, in comparison with @code{.psr}
 
10517
@cindex @code{.s} register, in comparison with @code{.sr}
 
10518
The last-requested point size in scaled points is contained in the
 
10519
@code{.psr} read-only number register.  The last requested point size in
 
10520
points as a decimal fraction can be found in @code{.sr}.  This is a
 
10521
string-valued read-only number register.
 
10522
 
 
10523
Note that the requested point sizes are device-independent, whereas the
 
10524
values returned by the @code{.ps} and @code{.s} registers are not.  For
 
10525
example, if a point size of 11@dmn{pt} is requested, and a @code{sizes}
 
10526
request (or a @code{sizescale} line in a @file{DESC} file) specifies
 
10527
10.95@dmn{pt} instead, this value is actually used.
 
10528
 
 
10529
Both registers are associated with the current environment
 
10530
(@pxref{Environments}).
 
10531
@endDefreg
 
10532
 
 
10533
The @code{\s} escape has the following syntax for working with
 
10534
fractional type sizes:
 
10535
 
 
10536
@table @code
 
10537
@item \s[@var{n}]
 
10538
@itemx \s'@var{n}'
 
10539
Set the point size to @var{n}@tie{}scaled points; @var{n}@tie{}is a
 
10540
numeric expression with a default scale indicator of @samp{z}.
 
10541
 
 
10542
@item \s[+@var{n}]
 
10543
@itemx \s[-@var{n}]
 
10544
@itemx \s+[@var{n}]
 
10545
@itemx \s-[@var{n}]
 
10546
@itemx \s'+@var{n}'
 
10547
@itemx \s'-@var{n}'
 
10548
@itemx \s+'@var{n}'
 
10549
@itemx \s-'@var{n}'
 
10550
Increase or or decrease the point size by @var{n}@tie{}scaled points;
 
10551
@var{n}@tie{}is a numeric expression (which may start with a minus sign)
 
10552
with a default scale indicator of @samp{z}.
 
10553
@end table
 
10554
 
 
10555
@xref{Font Files}.
 
10556
 
 
10557
 
 
10558
@c =====================================================================
 
10559
 
 
10560
@node Strings, Conditionals and Loops, Sizes, gtroff Reference
 
10561
@section Strings
 
10562
@cindex strings
 
10563
 
 
10564
@code{gtroff} has string variables, which are entirely for user
 
10565
convenience (i.e.@: there are no built-in strings exept @code{.T}, but
 
10566
even this is a read-write string variable).
 
10567
 
 
10568
Although the following requests can be used to create strings,
 
10569
simply using an undefined string will cause it to be defined as empty.
 
10570
@xref{Identifiers}.
 
10571
 
 
10572
@DefreqList {ds, name [@Var{string}]}
 
10573
@DefreqItem {ds1, name [@Var{string}]}
 
10574
@DefescItem {\\*, , n, }
 
10575
@DefescItem {\\*, @Lparen{}, nm, }
 
10576
@DefescListEnd {\\*, @Lbrack{}, name arg1 arg2 @dots{}, @Rbrack{}}
 
10577
@cindex string interpolation (@code{\*})
 
10578
@cindex string expansion (@code{\*})
 
10579
@cindex interpolation of strings (@code{\*})
 
10580
@cindex expansion of strings (@code{\*})
 
10581
@cindex string arguments
 
10582
@cindex arguments, of strings
 
10583
Define and access a string variable @var{name} (one-character
 
10584
name@tie{}@var{n}, two-character name @var{nm}).  If @var{name} already
 
10585
exists, @code{ds} overwrites the previous definition.  Only the syntax
 
10586
form using brackets can take arguments which are handled identically to
 
10587
macro arguments; the single exception is that a closing bracket as an
 
10588
argument must be enclosed in double quotes.  @xref{Request and Macro
 
10589
Arguments}, and @ref{Parameters}.
 
10590
 
 
10591
Example:
 
10592
 
 
10593
@Example
 
10594
.ds foo a \\$1 test
 
10595
.
 
10596
This is \*[foo nice].
 
10597
    @result{} This is a nice test.
 
10598
@endExample
 
10599
 
 
10600
The @code{\*} escape @dfn{interpolates} (expands in-place) a
 
10601
previously-defined string variable.  To be more precise, the stored
 
10602
string is pushed onto the input stack which is then parsed by
 
10603
@code{gtroff}.  Similar to number registers, it is possible to nest
 
10604
strings, i.e., string variables can be called within string variables.
 
10605
 
 
10606
If the string named by the @code{\*} escape does not exist, it is
 
10607
defined as empty, and a warning of type @samp{mac} is emitted (see
 
10608
@ref{Debugging}, for more details).
 
10609
 
 
10610
@cindex comments, with @code{ds}
 
10611
@cindex @code{ds} request, and comments
 
10612
@strong{Caution:} Unlike other requests, the second argument to the
 
10613
@code{ds} request takes up the entire line including trailing spaces.
 
10614
This means that comments on a line with such a request can introduce
 
10615
unwanted space into a string.
 
10616
 
 
10617
@Example
 
10618
.ds UX \s-1UNIX\s0\u\s-3tm\s0\d \" UNIX trademark
 
10619
@endExample
 
10620
 
 
10621
@noindent
 
10622
Instead the comment should be put on another line or have the comment
 
10623
escape adjacent with the end of the string.
 
10624
 
 
10625
@Example
 
10626
.ds UX \s-1UNIX\s0\u\s-3tm\s0\d\"  UNIX trademark
 
10627
@endExample
 
10628
 
 
10629
@cindex trailing quotes
 
10630
@cindex quotes, trailing
 
10631
@cindex leading spaces with @code{ds}
 
10632
@cindex spaces with @code{ds}
 
10633
@cindex @code{ds} request, and leading spaces
 
10634
To produce leading space the string can be started with a double quote.
 
10635
No trailing quote is needed; in fact, any trailing quote is included in
 
10636
your string.
 
10637
 
 
10638
@Example
 
10639
.ds sign "           Yours in a white wine sauce,
 
10640
@endExample
 
10641
 
 
10642
@cindex multi-line strings
 
10643
@cindex strings, multi-line
 
10644
@cindex newline character, in strings, escaping
 
10645
@cindex escaping newline characters, in strings
 
10646
Strings are not limited to a single line of text.  A string can span
 
10647
several lines by escaping the newlines with a backslash.  The resulting
 
10648
string is stored @emph{without} the newlines.
 
10649
 
 
10650
@Example
 
10651
.ds foo lots and lots \
 
10652
of text are on these \
 
10653
next several lines
 
10654
@endExample
 
10655
 
 
10656
It is not possible to have real newlines in a string.  To put a single
 
10657
double quote character into a string, use two consecutive double quote
 
10658
characters.
 
10659
 
 
10660
The @code{ds1} request turns off compatibility mode while interpreting a
 
10661
string.  To be more precise, a @dfn{compatibility save} input token is
 
10662
inserted at the beginning of the string, and a @dfn{compatibility
 
10663
restore} input token at the end.
 
10664
 
 
10665
@Example
 
10666
.nr xxx 12345
 
10667
.ds aa The value of xxx is \\n[xxx].
 
10668
.ds1 bb The value of xxx ix \\n[xxx].
 
10669
.
 
10670
.cp 1
 
10671
.
 
10672
\*(aa
 
10673
    @result{} warning: number register `[' not defined
 
10674
    @result{} The value of xxx is 0xxx].
 
10675
\*(bb
 
10676
    @result{} The value of xxx ix 12345.
 
10677
@endExample
 
10678
 
 
10679
@cindex name space, common, of macros, diversions, and strings
 
10680
@cindex common name space of macros, diversions, and strings
 
10681
@cindex macros, shared name space with strings and diversions
 
10682
@cindex strings, shared name space with macros and diversions
 
10683
@cindex diversions, shared name space with macros and strings
 
10684
Strings, macros, and diversions (and boxes) share the same name space.
 
10685
Internally, even the same mechanism is used to store them.  This has
 
10686
some interesting consequences.  For example, it is possible to call a
 
10687
macro with string syntax and vice versa.
 
10688
 
 
10689
@Example
 
10690
.de xxx
 
10691
a funny test.
 
10692
..
 
10693
This is \*[xxx]
 
10694
    @result{} This is a funny test.
 
10695
 
 
10696
.ds yyy a funny test
 
10697
This is
 
10698
.yyy
 
10699
    @result{} This is a funny test.
 
10700
@endExample
 
10701
 
 
10702
In particular, interpolating a string does not hide existing macro
 
10703
arguments.  Thus in a macro, a more efficient way of doing
 
10704
 
 
10705
@Example
 
10706
.xx \\$@@
 
10707
@endExample
 
10708
 
 
10709
@noindent
 
10710
is
 
10711
 
 
10712
@Example
 
10713
\\*[xx]\\
 
10714
@endExample
 
10715
 
 
10716
@noindent
 
10717
Note that the latter calling syntax doesn't change the value of
 
10718
@code{\$0}, which is then inherited from the calling macro.
 
10719
 
 
10720
Diversions and boxes can be also called with string syntax.
 
10721
 
 
10722
Another consequence is that you can copy one-line diversions or boxes to
 
10723
a string.
 
10724
 
 
10725
@Example
 
10726
.di xxx
 
10727
a \fItest\fR
 
10728
.br
 
10729
.di
 
10730
.ds yyy This is \*[xxx]\c
 
10731
\*[yyy].
 
10732
    @result{} @r{This is a }@i{test}.
 
10733
@endExample
 
10734
 
 
10735
@noindent
 
10736
As the previous example shows, it is possible to store formatted output
 
10737
in strings.  The @code{\c} escape prevents the insertion of an
 
10738
additional blank line in the output.
 
10739
 
 
10740
Copying diversions longer than a single output line produces unexpected
 
10741
results.
 
10742
 
 
10743
@Example
 
10744
.di xxx
 
10745
a funny
 
10746
.br
 
10747
test
 
10748
.br
 
10749
.di
 
10750
.ds yyy This is \*[xxx]\c
 
10751
\*[yyy].
 
10752
    @result{} test This is a funny.
 
10753
@endExample
 
10754
 
 
10755
Usually, it is not predictable whether a diversion contains one or more
 
10756
output lines, so this mechanism should be avoided.  With @acronym{UNIX}
 
10757
@code{troff}, this was the only solution to strip off a final newline
 
10758
from a diversion.  Another disadvantage is that the spaces in the copied
 
10759
string are already formatted, making them unstretchable.  This can cause
 
10760
ugly results.
 
10761
 
 
10762
@cindex stripping final newline in diversions
 
10763
@cindex diversion, stripping final newline
 
10764
@cindex final newline, stripping in diversions
 
10765
@cindex newline, final, stripping in diversions
 
10766
@cindex horizontal space, unformatting
 
10767
@cindex space, horizontal, unformatting
 
10768
@cindex unformatting horizontal space
 
10769
A clean solution to this problem is available in GNU @code{troff}, using
 
10770
the requests @code{chop} to remove the final newline of a diversion, and
 
10771
@code{unformat} to make the horizontal spaces stretchable again.
 
10772
 
 
10773
@Example
 
10774
.box xxx
 
10775
a funny
 
10776
.br
 
10777
test
 
10778
.br
 
10779
.box
 
10780
.chop xxx
 
10781
.unformat xxx
 
10782
This is \*[xxx].
 
10783
    @result{} This is a funny test.
 
10784
@endExample
 
10785
 
 
10786
@xref{Gtroff Internals}, for more information.
 
10787
@endDefreq
 
10788
 
 
10789
@DefreqList {as, name [@Var{string}]}
 
10790
@DefreqListEnd {as1, name [@Var{string}]}
 
10791
@cindex appending to a string (@code{as})
 
10792
@cindex string, appending (@code{as})
 
10793
The @code{as} request is similar to @code{ds} but appends @var{string}
 
10794
to the string stored as @var{name} instead of redefining it.  If
 
10795
@var{name} doesn't exist yet, it is created.
 
10796
 
 
10797
@Example
 
10798
.as sign " with shallots, onions and garlic,
 
10799
@endExample
 
10800
 
 
10801
The @code{as1} request is similar to @code{as}, but compatibility mode
 
10802
is switched off while the appended string is interpreted.  To be more
 
10803
precise, a @dfn{compatibility save} input token is inserted at the
 
10804
beginning of the appended string, and a @dfn{compatibility restore}
 
10805
input token at the end.
 
10806
@endDefreq
 
10807
 
 
10808
Rudimentary string manipulation routines are given with the next two
 
10809
requests.
 
10810
 
 
10811
@Defreq {substring, str n1 [@Var{n2}]}
 
10812
@cindex substring (@code{substring})
 
10813
Replace the string named @var{str} with the substring defined by the
 
10814
indices @var{n1} and@tie{}@var{n2}.  The first character in the string
 
10815
has index@tie{}0.  If @var{n2} is omitted, it is taken to be equal to
 
10816
the string's length.  If the index value @var{n1} or @var{n2} is
 
10817
negative, it is counted from the end of the string, going backwards: The
 
10818
last character has index@tie{}@minus{}1, the character before the last
 
10819
character has index@tie{}@minus{}2, etc.
 
10820
 
 
10821
@Example
 
10822
.ds xxx abcdefgh
 
10823
.substring xxx 1 -4
 
10824
\*[xxx]
 
10825
    @result{} bcde
 
10826
@endExample
 
10827
@endDefreq
 
10828
 
 
10829
@Defreq {length, reg str}
 
10830
@cindex length of a string (@code{length})
 
10831
@cindex string, length of (@code{length})
 
10832
@cindex @code{length} request, and copy-in mode
 
10833
@cindex copy-in mode, and @code{length} request
 
10834
@cindex mode, copy-in, and @code{length} request
 
10835
Compute the number of characters of @var{str} and return it in the
 
10836
number register @var{reg}.  If @var{reg} doesn't exist, it is created.
 
10837
@code{str} is read in copy mode.
 
10838
 
 
10839
@Example
 
10840
.ds xxx abcd\h'3i'efgh
 
10841
.length yyy \*[xxx]
 
10842
\n[yyy]
 
10843
    @result{} 14
 
10844
@endExample
 
10845
@endDefreq
 
10846
 
 
10847
@Defreq {rn, xx yy}
 
10848
@cindex renaming request (@code{rn})
 
10849
@cindex request, renaming (@code{rn})
 
10850
@cindex renaming macro (@code{rn})
 
10851
@cindex macro, renaming (@code{rn})
 
10852
@cindex renaming string (@code{rn})
 
10853
@cindex string, renaming (@code{rn})
 
10854
@cindex renaming diversion (@code{rn})
 
10855
@cindex diversion, renaming (@code{rn})
 
10856
Rename the request, macro, diversion, or string @var{xx} to @var{yy}.
 
10857
@endDefreq
 
10858
 
 
10859
@Defreq {rm, xx}
 
10860
@cindex removing request (@code{rm})
 
10861
@cindex request, removing (@code{rm})
 
10862
@cindex removing macro (@code{rm})
 
10863
@cindex macro, removing (@code{rm})
 
10864
@cindex removing string (@code{rm})
 
10865
@cindex string, removing (@code{rm})
 
10866
@cindex removing diversion (@code{rm})
 
10867
@cindex diversion, removing (@code{rm})
 
10868
Remove the request, macro, diversion, or string @var{xx}.  @code{gtroff}
 
10869
treats subsequent invocations as if the object had never been defined.
 
10870
@endDefreq
 
10871
 
 
10872
@anchor{als}
 
10873
@Defreq {als, new old}
 
10874
@cindex alias, string, creating (@code{als})
 
10875
@cindex alias, macro, creating (@code{als})
 
10876
@cindex alias, diversion, creating (@code{als})
 
10877
@cindex creating alias, for string (@code{als})
 
10878
@cindex creating alias, for macro (@code{als})
 
10879
@cindex creating alias, for diversion (@code{als})
 
10880
@cindex string, creating alias (@code{als})
 
10881
@cindex macro, creating alias (@code{als})
 
10882
@cindex diversion, creating alias (@code{als})
 
10883
Create an alias named @var{new} for the request, string, macro, or
 
10884
diversion object named @var{old}.  The new name and the old name are
 
10885
exactly equivalent (it is similar to a hard rather than a soft link).  If
 
10886
@var{old} is undefined, @code{gtroff} generates a warning of type
 
10887
@samp{mac} and ignores the request.
 
10888
 
 
10889
To understand how the @code{als} request works it is probably best to
 
10890
think of two different pools: one pool for objects (macros, strings,
 
10891
etc.), and another one for names.  As soon as an object is defined,
 
10892
@code{gtroff} adds it to the object pool, adds its name to the name
 
10893
pool, and creates a link between them.  When @code{als} creates an
 
10894
alias, it adds a new name to the name pool which gets linked to the same
 
10895
object as the old name.
 
10896
 
 
10897
Now consider this example.
 
10898
 
 
10899
@Example
 
10900
.de foo
 
10901
..
 
10902
.
 
10903
.als bar foo
 
10904
.
 
10905
.de bar
 
10906
.  foo
 
10907
..
 
10908
.
 
10909
.bar
 
10910
    @result{} input stack limit exceeded
 
10911
@endExample
 
10912
 
 
10913
@noindent
 
10914
The definition of macro @code{bar} replaces the old object this name is
 
10915
linked to.  However, the alias to @code{foo} is still active!  In
 
10916
other words, @code{foo} is still linked to the same object as
 
10917
@code{bar}, and the result of calling @code{bar} is an infinite,
 
10918
recursive loop which finally leads to an error.
 
10919
 
 
10920
@cindex alias, string, removing (@code{rm})
 
10921
@cindex alias, macro, removing (@code{rm})
 
10922
@cindex alias, diversion, removing (@code{rm})
 
10923
@cindex removing alias, for string (@code{rm})
 
10924
@cindex removing alias, for macro (@code{rm})
 
10925
@cindex removing alias, for diversion (@code{rm})
 
10926
@cindex string, removing alias (@code{rm})
 
10927
@cindex macro, removing alias (@code{rm})
 
10928
@cindex diversion, removing alias (@code{rm})
 
10929
To undo an alias, simply call @code{rm} on the aliased name.  The object
 
10930
itself is not destroyed until there are no more aliases.
 
10931
@endDefreq
 
10932
 
 
10933
@Defreq {chop, xx}
 
10934
Remove (chop) the last character from the macro, string, or diversion
 
10935
named @var{xx}.  This is useful for removing the newline from the end of
 
10936
diversions that are to be interpolated as strings.  This command can be
 
10937
used repeatedly; see @ref{Gtroff Internals}, for details on nodes
 
10938
inserted additionally by @code{gtroff}.
 
10939
@endDefreq
 
10940
 
 
10941
@xref{Identifiers}, and @ref{Comments}.
 
10942
 
 
10943
 
 
10944
@c =====================================================================
 
10945
 
 
10946
@node Conditionals and Loops, Writing Macros, Strings, gtroff Reference
 
10947
@section Conditionals and Loops
 
10948
@cindex conditionals and loops
 
10949
@cindex loops and conditionals
 
10950
 
 
10951
@menu
 
10952
* Operators in Conditionals::
 
10953
* if-else::
 
10954
* while::
 
10955
@end menu
 
10956
 
 
10957
@c ---------------------------------------------------------------------
 
10958
 
 
10959
@node Operators in Conditionals, if-else, Conditionals and Loops, Conditionals and Loops
 
10960
@subsection Operators in Conditionals
 
10961
 
 
10962
@cindex @code{if} request, operators to use with
 
10963
@cindex @code{ie} request, operators to use with
 
10964
@cindex @code{while} request, operators to use with
 
10965
In @code{if}, @code{ie}, and @code{while} requests, in addition to ordinary
 
10966
@ref{Expressions}, there are several more operators available:
 
10967
 
 
10968
@table @code
 
10969
@item e
 
10970
@itemx o
 
10971
True if the current page is even or odd numbered (respectively).
 
10972
 
 
10973
@item n
 
10974
@cindex conditional output for terminal (TTY)
 
10975
@cindex TTY, conditional output for
 
10976
@cindex terminal, conditional output for
 
10977
True if the document is being processed in nroff mode (i.e., the
 
10978
@code{.nroff} command has been issued).  @xref{Troff and Nroff Mode}.
 
10979
 
 
10980
@item t
 
10981
True if the document is being processed in troff mode (i.e., the
 
10982
@code{.troff} command has been issued).  @xref{Troff and Nroff Mode}.
 
10983
 
 
10984
@item v
 
10985
Always false.  This condition is for compatibility with other
 
10986
@code{troff} versions only (identifying a @code{-Tversatec} device).
 
10987
 
 
10988
@item '@var{xxx}'@var{yyy}'
 
10989
True if the output produced by @var{xxx} is equal to the output produced
 
10990
by @var{yyy}.  Other characters can be used in place of the single
 
10991
quotes; the same set of delimiters as for the @code{\D} escape is used
 
10992
(@pxref{Escapes}).  @code{gtroff} formats @var{xxx} and @var{yyy} in
 
10993
separate environments; after the comparison the resulting data is
 
10994
discarded.
 
10995
 
 
10996
@Example
 
10997
.ie "|"\fR|\fP" \
 
10998
true
 
10999
.el \
 
11000
false
 
11001
    @result{} true
 
11002
@endExample
 
11003
 
 
11004
@noindent
 
11005
The resulting motions, glyph sizes, and fonts have to
 
11006
match,@footnote{The created output nodes must be identical.
 
11007
@xref{Gtroff Internals}.} and not the individual motion, size, and font
 
11008
requests.  In the previous example, @samp{|} and @samp{\fR|\fP} both
 
11009
result in a roman @samp{|} glyph with the same point size and at the
 
11010
same location on the page, so the strings are equal.  If
 
11011
@samp{.ft@tie{}I} had been added before the @samp{.ie}, the result would
 
11012
be ``false'' because (the first) @samp{|} produces an italic @samp{|}
 
11013
rather than a roman one.
 
11014
 
 
11015
@cindex string comparison
 
11016
@cindex comparison of strings
 
11017
To compare strings without processing, surround the data with @code{\?}.
 
11018
 
 
11019
@Example
 
11020
.ie "\?|\?"\?\fR|\fP\?" \
 
11021
true
 
11022
.el \
 
11023
false
 
11024
    @result{} false
 
11025
@endExample
 
11026
 
 
11027
@cindex @code{\?}, and copy-in mode
 
11028
@cindex copy-in mode, and @code{\?}
 
11029
@cindex mode, copy-in, and @code{\?}
 
11030
@noindent
 
11031
Since data protected with @code{\?} is read in copy-in mode it is even
 
11032
possible to use incomplete input without causing an error.
 
11033
 
 
11034
@Example
 
11035
.ds a \[
 
11036
.ds b \[
 
11037
.ie '\?\*a\?'\?\*b\?' \
 
11038
true
 
11039
.el \
 
11040
false
 
11041
    @result{} true
 
11042
@endExample
 
11043
 
 
11044
@item r @var{xxx}
 
11045
True if there is a number register named @var{xxx}.
 
11046
 
 
11047
@item d @var{xxx}
 
11048
True if there is a string, macro, diversion, or request named @var{xxx}.
 
11049
 
 
11050
@item m @var{xxx}
 
11051
True if there is a color named @var{xxx}.
 
11052
 
 
11053
@item c @var{g}
 
11054
True if there is a glyph @var{g} available@footnote{The name of this
 
11055
conditional operator is a misnomer since it tests names of output
 
11056
glyphs.}; @var{g} is either an @acronym{ASCII} character or a special
 
11057
character (@code{\N'@var{xxx}'}, @code{\(@var{gg}} or
 
11058
@code{\[@var{ggg}]}); the condition is also true if @var{g} has been
 
11059
defined by the @code{char} request.
 
11060
 
 
11061
@item F @var{font}
 
11062
True if a font named @var{font} exists.  @var{font} is handled as if it
 
11063
was opened with the @code{ft} request (this is, font translation and
 
11064
styles are applied), without actually mounting it.
 
11065
 
 
11066
This test doesn't load the complete font but only its header to verify
 
11067
its validity.
 
11068
 
 
11069
@item S @var{style}
 
11070
True if style @var{style} has been registered.  Font translation is
 
11071
applied.
 
11072
@end table
 
11073
 
 
11074
Note that these operators can't be combined with other operators like
 
11075
@samp{:} or @samp{&}; only a leading @samp{!} (without whitespace
 
11076
between the exclamation mark and the operator) can be used to negate the
 
11077
result.
 
11078
 
 
11079
@Example
 
11080
.nr xxx 1
 
11081
.ie !r xxx \
 
11082
true
 
11083
.el \
 
11084
false
 
11085
    @result{} false
 
11086
@endExample
 
11087
 
 
11088
A whitespace after @samp{!} always evaluates to zero (this bizarre
 
11089
behaviour is due to compatibility with @acronym{UNIX} @code{troff}).
 
11090
 
 
11091
@Example
 
11092
.nr xxx 1
 
11093
.ie ! r xxx \
 
11094
true
 
11095
.el \
 
11096
false
 
11097
    @result{} r xxx true
 
11098
@endExample
 
11099
 
 
11100
It is possible to omit the whitespace before the argument to the
 
11101
@samp{r}, @samp{d}, and @samp{c} operators.
 
11102
 
 
11103
@xref{Expressions}.
 
11104
 
 
11105
@c ---------------------------------------------------------------------
 
11106
 
 
11107
@node if-else, while, Operators in Conditionals, Conditionals and Loops
 
11108
@subsection if-else
 
11109
@cindex if-else
 
11110
 
 
11111
@code{gtroff} has if-then-else constructs like other languages, although
 
11112
the formatting can be painful.
 
11113
 
 
11114
@Defreq {if, expr anything}
 
11115
 
 
11116
Evaluate the expression @var{expr}, and executes @var{anything} (the
 
11117
remainder of the line) if @var{expr} evaluates to a value greater than
 
11118
zero (true).  @var{anything} is interpreted as though it was on a line
 
11119
by itself (except that leading spaces are swallowed).
 
11120
@xref{Operators in Conditionals}, for more info.
 
11121
 
 
11122
@Example
 
11123
.nr xxx 1
 
11124
.nr yyy 2
 
11125
.if ((\n[xxx] == 1) & (\n[yyy] == 2)) true
 
11126
    @result{} true
 
11127
@endExample
 
11128
@endDefreq
 
11129
 
 
11130
@Defreq {nop, anything}
 
11131
Executes @var{anything}.  This is similar to @code{.if@tie{}1}.
 
11132
@endDefreq
 
11133
 
 
11134
@DefreqList {ie, expr anything}
 
11135
@DefreqListEnd {el, anything}
 
11136
Use the @code{ie} and @code{el} requests to write an if-then-else.  The
 
11137
first request is the `if' part and the latter is the `else' part.
 
11138
 
 
11139
@Example
 
11140
.ie n .ls 2 \" double-spacing in nroff
 
11141
.el   .ls 1 \" single-spacing in troff
 
11142
@endExample
 
11143
@endDefreq
 
11144
 
 
11145
@c there is a bug in makeinfo <= 4.1a: you can't have `@{' as an argument
 
11146
@c to @deffn
 
11147
@c
 
11148
@c and in 4.2 you still can't use @{ in macros.
 
11149
 
 
11150
@c @DefescList {\@{, , , }
 
11151
@c @DefescListEnd {\@}, , , }
 
11152
@deffn Escape @t{\@{}
 
11153
@deffnx Escape @t{\@}}
 
11154
@esindex \@{
 
11155
@esindex \@}
 
11156
@cindex begin of conditional block (@code{\@{})
 
11157
@cindex end of conditional block (@code{\@}})
 
11158
@cindex conditional block, begin (@code{\@{})
 
11159
@cindex conditional block, end (@code{\@}})
 
11160
@cindex block, conditional, begin (@code{\@{})
 
11161
@cindex block, condititional, end (@code{\@}})
 
11162
In many cases, an if (or if-else) construct needs to execute more than
 
11163
one request.  This can be done using the @code{\@{} and @code{\@}}
 
11164
escapes.  The following example shows the possible ways to use these
 
11165
escapes (note the position of the opening and closing braces).
 
11166
 
 
11167
@Example
 
11168
.ie t \@{\
 
11169
.    ds lq ``
 
11170
.    ds rq ''
 
11171
.\@}
 
11172
.el \
 
11173
.\@{\
 
11174
.    ds lq "
 
11175
.    ds rq "\@}
 
11176
@endExample
 
11177
@c @endDefesc
 
11178
@end deffn
 
11179
 
 
11180
@xref{Expressions}.
 
11181
 
 
11182
@c ---------------------------------------------------------------------
 
11183
 
 
11184
@node while,  , if-else, Conditionals and Loops
 
11185
@subsection while
 
11186
@cindex while
 
11187
 
 
11188
@code{gtroff} provides a looping construct using the @code{while}
 
11189
request, which is used much like the @code{if} (and related) requests.
 
11190
 
 
11191
@Defreq {while, expr anything}
 
11192
Evaluate the expression @var{expr}, and repeatedly execute
 
11193
@var{anything} (the remainder of the line) until @var{expr} evaluates
 
11194
to@tie{}0.
 
11195
 
 
11196
@Example
 
11197
.nr a 0 1
 
11198
.while (\na < 9) \@{\
 
11199
\n+a,
 
11200
.\@}
 
11201
\n+a
 
11202
    @result{} 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
 
11203
@endExample
 
11204
 
 
11205
Some remarks.
 
11206
 
 
11207
@cindex @code{de} request, and @code{while}
 
11208
@itemize @bullet
 
11209
@item
 
11210
The body of a @code{while} request is treated like the body of a
 
11211
@code{de} request: @code{gtroff} temporarily stores it in a macro which
 
11212
is deleted after the loop has been exited.  It can considerably slow
 
11213
down a macro if the body of the @code{while} request (within the macro)
 
11214
is large.  Each time the macro is executed, the @code{while} body is
 
11215
parsed and stored again as a temporary macro.
 
11216
 
 
11217
@Example
 
11218
.de xxx
 
11219
.  nr num 10
 
11220
.  while (\\n[num] > 0) \@{\
 
11221
.    \" many lines of code
 
11222
.    nr num -1
 
11223
.  \@}
 
11224
..
 
11225
@endExample
 
11226
 
 
11227
@cindex recursive macros
 
11228
@cindex macros, recursive
 
11229
@noindent
 
11230
The traditional and ofter better solution (@acronym{UNIX} @code{troff}
 
11231
doesn't have the @code{while} request) is to use a recursive macro
 
11232
instead which is parsed only once during its definition.
 
11233
 
 
11234
@Example
 
11235
.de yyy
 
11236
.  if (\\n[num] > 0) \@{\
 
11237
.    \" many lines of code
 
11238
.    nr num -1
 
11239
.    yyy
 
11240
.  \@}
 
11241
..
 
11242
.
 
11243
.de xxx
 
11244
.  nr num 10
 
11245
.  yyy
 
11246
..
 
11247
@endExample
 
11248
 
 
11249
@noindent
 
11250
Note that the number of available recursion levels is set to@tie{}1000
 
11251
(this is a compile-time constant value of @code{gtroff}).
 
11252
 
 
11253
@item
 
11254
The closing brace of a @code{while} body must end a line.
 
11255
 
 
11256
@Example
 
11257
.if 1 \@{\
 
11258
.  nr a 0 1
 
11259
.  while (\n[a] < 10) \@{\
 
11260
.    nop \n+[a]
 
11261
.\@}\@}
 
11262
    @result{} unbalanced \@{ \@}
 
11263
@endExample
 
11264
@end itemize
 
11265
@endDefreq
 
11266
 
 
11267
@Defreq {break, }
 
11268
@cindex @code{while} request, confusing with @code{br}
 
11269
@cindex @code{break} request, in a @code{while} loop
 
11270
@cindex @code{continue} request, in a @code{while} loop
 
11271
Break out of a @code{while} loop.  Be sure not to confuse this with the
 
11272
@code{br} request (causing a line break).
 
11273
@endDefreq
 
11274
 
 
11275
@Defreq {continue, }
 
11276
Finish the current iteration of a @code{while} loop, immediately
 
11277
restarting the next iteration.
 
11278
@endDefreq
 
11279
 
 
11280
@xref{Expressions}.
 
11281
 
 
11282
 
 
11283
@c =====================================================================
 
11284
 
 
11285
@node Writing Macros, Page Motions, Conditionals and Loops, gtroff Reference
 
11286
@section Writing Macros
 
11287
@cindex writing macros
 
11288
@cindex macros, writing
 
11289
 
 
11290
A @dfn{macro} is a collection of text and embedded commands which can be
 
11291
invoked multiple times.  Use macros to define common operations.
 
11292
@xref{Strings}, for a (limited) alternative syntax to call macros.
 
11293
 
 
11294
Although the following requests can be used to create macros,
 
11295
simply using an undefined macro will cause it to be defined as empty.
 
11296
@xref{Identifiers}.
 
11297
 
 
11298
@DefreqList {de, name [@Var{end}]}
 
11299
@DefreqItem {de1, name [@Var{end}]}
 
11300
@DefreqItem {dei, name [@Var{end}]}
 
11301
@DefreqListEnd {dei1, name [@Var{end}]}
 
11302
Define a new macro named @var{name}.  @code{gtroff} copies subsequent
 
11303
lines (starting with the next one) into an internal buffer until it
 
11304
encounters the line @samp{..} (two dots).  If the optional second
 
11305
argument to @code{de} is present it is used as the macro closure
 
11306
request instead of @samp{..}.
 
11307
 
 
11308
There can be whitespace after the first dot in the line containing the
 
11309
ending token (either @samp{.} or macro @samp{@var{end}}).  Don't insert
 
11310
a tab character immediately after the @samp{..}, otherwise it isn't
 
11311
recognized as the end-of-macro symbol.@footnote{While it is possible to
 
11312
define and call a macro @samp{.} with
 
11313
 
 
11314
@Example
 
11315
.de .
 
11316
.  tm foo
 
11317
..
 
11318
.
 
11319
..    \" This calls macro `.'!
 
11320
@endExample
 
11321
 
 
11322
@noindent
 
11323
you can't use this as the end-of-macro macro: during a macro definition,
 
11324
@samp{..} is never handled as a call to @samp{.}, even if you say
 
11325
@samp{.de foo .} explicitly.}
 
11326
 
 
11327
Here a small example macro called @samp{P} which causes a break and
 
11328
inserts some vertical space.  It could be used to separate paragraphs.
 
11329
 
 
11330
@Example
 
11331
.de P
 
11332
.  br
 
11333
.  sp .8v
 
11334
..
 
11335
@endExample
 
11336
 
 
11337
The following example defines a macro within another.  Remember that
 
11338
expansion must be protected twice; once for reading the macro and once
 
11339
for executing.
 
11340
 
 
11341
@Example
 
11342
\# a dummy macro to avoid a warning
 
11343
.de end
 
11344
..
 
11345
.
 
11346
.de foo
 
11347
.  de bar end
 
11348
.    nop \f[B]Hallo \\\\$1!\f[]
 
11349
.  end
 
11350
..
 
11351
.
 
11352
.foo
 
11353
.bar Joe
 
11354
    @result{} @b{Hallo Joe!}
 
11355
@endExample
 
11356
 
 
11357
@noindent
 
11358
Since @code{\f} has no expansion, it isn't necessary to protect its
 
11359
backslash.  Had we defined another macro within @code{bar} which takes a
 
11360
parameter, eight backslashes would be necessary before @samp{$1}.
 
11361
 
 
11362
The @code{de1} request turns off compatibility mode while executing the
 
11363
macro.  On entry, the current compatibility mode is saved and restored
 
11364
at exit.
 
11365
 
 
11366
@Example
 
11367
.nr xxx 12345
 
11368
.
 
11369
.de aa
 
11370
The value of xxx is \\n[xxx].
 
11371
..
 
11372
.de1 bb
 
11373
The value of xxx ix \\n[xxx].
 
11374
..
 
11375
.
 
11376
.cp 1
 
11377
.
 
11378
.aa
 
11379
    @result{} warning: number register `[' not defined
 
11380
    @result{} The value of xxx is 0xxx].
 
11381
.bb
 
11382
    @result{} The value of xxx ix 12345.
 
11383
@endExample
 
11384
 
 
11385
The @code{dei} request defines a macro indirectly.  That is, it expands
 
11386
strings whose names are @var{name} or @var{end} before performing the
 
11387
append.
 
11388
 
 
11389
This:
 
11390
 
 
11391
@Example
 
11392
.ds xx aa
 
11393
.ds yy bb
 
11394
.dei xx yy
 
11395
@endExample
 
11396
 
 
11397
@noindent
 
11398
is equivalent to:
 
11399
 
 
11400
@Example
 
11401
.de aa bb
 
11402
@endExample
 
11403
 
 
11404
The @code{dei1} request is similar to @code{dei} but with compatibility
 
11405
mode switched off during execution of the defined macro.
 
11406
 
 
11407
If compatibility mode is on, @code{de} (and @code{dei}) behave similar
 
11408
to @code{de1} (and @code{dei1}): A `compatibility save' token is
 
11409
inserted at the beginning, and a `compatibility restore' token at the
 
11410
end, with compatibility mode switched on during execution.  @xref{Gtroff
 
11411
Internals}, for more information on switching compatibility mode on and
 
11412
off in a single document.
 
11413
 
 
11414
@pindex trace.tmac
 
11415
Using @file{trace.tmac}, you can trace calls to @code{de} and
 
11416
@code{de1}.
 
11417
 
 
11418
Note that macro identifiers are shared with identifiers for strings and
 
11419
diversions.
 
11420
 
 
11421
@xref{als,,the description of the @code{als} request}, for possible
 
11422
pitfalls if redefining a macro which has been aliased.
 
11423
@endDefreq
 
11424
 
 
11425
@DefreqList {am, name [@Var{end}]}
 
11426
@DefreqItem {am1, name [@Var{end}]}
 
11427
@DefreqItem {ami, name [@Var{end}]}
 
11428
@DefreqListEnd {ami1, name [@Var{end}]}
 
11429
@cindex appending to a macro (@code{am})
 
11430
@cindex macro, appending (@code{am})
 
11431
Works similarly to @code{de} except it appends onto the macro named
 
11432
@var{name}.  So, to make the previously defined @samp{P} macro actually
 
11433
do indented instead of block paragraphs, add the necessary code to the
 
11434
existing macro like this:
 
11435
 
 
11436
@Example
 
11437
.am P
 
11438
.ti +5n
 
11439
..
 
11440
@endExample
 
11441
 
 
11442
The @code{am1} request turns off compatibility mode while executing the
 
11443
appended macro piece.  To be more precise, a @dfn{compatibility save}
 
11444
input token is inserted at the beginning of the appended code, and a
 
11445
@dfn{compatibility restore} input token at the end.
 
11446
 
 
11447
The @code{ami} request appends indirectly, meaning that @code{gtroff}
 
11448
expands strings whose names are @var{name} or @var{end} before
 
11449
performing the append.
 
11450
 
 
11451
The @code{ami1} request is similar to @code{ami} but compatibility mode
 
11452
is switched off during execution of the defined macro.
 
11453
 
 
11454
@pindex trace.tmac
 
11455
Using @file{trace.tmac}, you can trace calls to @code{am} and
 
11456
@code{am1}.
 
11457
@endDefreq
 
11458
 
 
11459
@xref{Strings}, for the @code{als} and @code{rn} request to create an
 
11460
alias and rename a macro, respectively.
 
11461
 
 
11462
The @code{de}, @code{am}, @code{di}, @code{da}, @code{ds}, and @code{as}
 
11463
requests (together with its variants) only create a new object if the
 
11464
name of the macro, diversion or string diversion is currently undefined
 
11465
or if it is defined to be a request; normally they modify the value of
 
11466
an existing object.
 
11467
 
 
11468
@Defreq {return, [@Var{anything}]}
 
11469
Exit a macro, immediately returning to the caller.
 
11470
 
 
11471
If called with an argument, exit twice, namely the current macro and the
 
11472
macro one level higher.  This is used to define a wrapper macro for
 
11473
@code{return} in @file{trace.tmac}.
 
11474
@endDefreq
 
11475
 
 
11476
@menu
 
11477
* Copy-in Mode::
 
11478
* Parameters::
 
11479
@end menu
 
11480
 
 
11481
@c ---------------------------------------------------------------------
 
11482
 
 
11483
@node Copy-in Mode, Parameters, Writing Macros, Writing Macros
 
11484
@subsection Copy-in Mode
 
11485
@cindex copy mode
 
11486
@cindex copy-in mode
 
11487
@cindex mode, copy
 
11488
@cindex mode, copy-in
 
11489
 
 
11490
@cindex @code{\n}, when reading text for a macro
 
11491
@cindex @code{\$}, when reading text for a macro
 
11492
@cindex @code{\*}, when reading text for a macro
 
11493
@cindex @code{\\}, when reading text for a macro
 
11494
@cindex \@key{RET}, when reading text for a macro
 
11495
When @code{gtroff} reads in the text for a macro, string, or diversion,
 
11496
it copies the text (including request lines, but excluding escapes) into
 
11497
an internal buffer.  Escapes are converted into an internal form, except
 
11498
for @code{\n}, @code{\$}, @code{\*}, @code{\\} and @code{\@key{RET}}
 
11499
which are evaluated and inserted into the text where the escape was
 
11500
located.  This is known as @dfn{copy-in} mode or @dfn{copy} mode.
 
11501
 
 
11502
What this means is that you can specify when these escapes are to be
 
11503
evaluated (either at copy-in time or at the time of use) by insulating
 
11504
the escapes with an extra backslash.  Compare this to the @code{\def}
 
11505
and @code{\edef} commands in @TeX{}.
 
11506
 
 
11507
The following example prints the numbers 20 and@tie{}10:
 
11508
 
 
11509
@Example
 
11510
.nr x 20
 
11511
.de y
 
11512
.nr x 10
 
11513
\&\nx
 
11514
\&\\nx
 
11515
..
 
11516
.y
 
11517
@endExample
 
11518
 
 
11519
@c ---------------------------------------------------------------------
 
11520
 
 
11521
@node Parameters,  , Copy-in Mode, Writing Macros
 
11522
@subsection Parameters
 
11523
@cindex parameters
 
11524
 
 
11525
The arguments to a macro or string can be examined using a variety of
 
11526
escapes.
 
11527
 
 
11528
@Defreg {.$}
 
11529
@cindex number of arguments register (@code{.$})
 
11530
The number of arguments passed to a macro or string.  This is a
 
11531
read-only number register.
 
11532
 
 
11533
Note that the @code{shift} request can change its value.
 
11534
@endDefreg
 
11535
 
 
11536
Any individual argument can be retrieved with one of the following
 
11537
escapes:
 
11538
 
 
11539
@DefescList {\\$, , n, }
 
11540
@DefescItem {\\$, @Lparen{}, nn, }
 
11541
@DefescListEnd {\\$, @Lbrack{}, nnn, @Rbrack{}}
 
11542
@cindex copy-in mode, and macro arguments
 
11543
@cindex mode, copy-in, and macro arguments
 
11544
@cindex macro, arguments (@code{\$})
 
11545
@cindex arguments, macro (@code{\$})
 
11546
Retrieve the @var{n}@dmn{th}, @var{nn}@dmn{th} or @var{nnn}@dmn{th}
 
11547
argument.  As usual, the first form only accepts a single number (larger
 
11548
than zero), the second a two-digit number (larger or equal to@tie{}10),
 
11549
and the third any positive integer value (larger than zero).  Macros and
 
11550
strings can have an unlimited number of arguments.  Note that due to
 
11551
copy-in mode, use two backslashes on these in actual use to prevent
 
11552
interpolation until the macro is actually invoked.
 
11553
@endDefesc
 
11554
 
 
11555
@Defreq {shift, [@Var{n}]}
 
11556
Shift the arguments 1@tie{}position, or as many positions as specified
 
11557
by its argument.  After executing this request, argument@tie{}@var{i}
 
11558
becomes argument @math{@var{i}-@var{n}}; arguments 1 to@tie{}@var{n} are
 
11559
no longer available.  Shifting by negative amounts is currently
 
11560
undefined.
 
11561
 
 
11562
The register @code{.$} is adjusted accordingly.
 
11563
@endDefreq
 
11564
 
 
11565
@DefescList {\\$*, , , }
 
11566
@DefescListEnd {\\$@@, , , }
 
11567
In some cases it is convenient to use all of the arguments at once (for
 
11568
example, to pass the arguments along to another macro).  The @code{\$*}
 
11569
escape concatenates all the arguments separated by spaces.  A similar
 
11570
escape is @code{\$@@}, which concatenates all the arguments with each
 
11571
surrounded by double quotes, and separated by spaces.  If not in
 
11572
compatibility mode, the input level of double quotes is preserved (see
 
11573
@ref{Request and Macro Arguments}).
 
11574
@endDefesc
 
11575
 
 
11576
@Defesc {\\$^, , , }
 
11577
Handle the parameters of a macro as if they were an argument to the
 
11578
@code{ds} or similar requests.
 
11579
 
 
11580
@Example
 
11581
.de foo
 
11582
.  tm $1=`\\$1'
 
11583
.  tm $2=`\\$2'
 
11584
.  tm $*=`\\$*'
 
11585
.  tm $@@=`\\$@@'
 
11586
.  tm $^=`\\$^'
 
11587
..
 
11588
.foo " This is a "test"
 
11589
    @result{} $1=` This is a '
 
11590
    @result{} $2=`test"'
 
11591
    @result{} $*=` This is a  test"'
 
11592
    @result{} $@@=`" This is a " "test""'
 
11593
    @result{} $^=`" This is a "test"'
 
11594
@endExample
 
11595
 
 
11596
This escape is useful mainly for macro packages like @file{trace.tmac}
 
11597
which redefines some requests and macros for debugging purposes.
 
11598
@endDefesc
 
11599
 
 
11600
@Defesc {\\$0, , , }
 
11601
@cindex macro name register (@code{\$0})
 
11602
@cindex @code{als} request, and @code{\$0}
 
11603
The name used to invoke the current macro.  The @code{als} request can
 
11604
make a macro have more than one name.
 
11605
 
 
11606
If a macro is called as a string (within another macro), the value of
 
11607
@code{\$0} isn't changed.
 
11608
 
 
11609
@Example
 
11610
.de foo
 
11611
.  tm \\$0
 
11612
..
 
11613
.als foo bar
 
11614
.
 
11615
@endExample
 
11616
@Example
 
11617
.de aaa
 
11618
.  foo
 
11619
..
 
11620
.de bbb
 
11621
.  bar
 
11622
..
 
11623
.de ccc
 
11624
\\*[foo]\\
 
11625
..
 
11626
.de ddd
 
11627
\\*[bar]\\
 
11628
..
 
11629
.
 
11630
@endExample
 
11631
@Example
 
11632
.aaa
 
11633
    @result{} foo
 
11634
.bbb
 
11635
    @result{} bar
 
11636
.ccc
 
11637
    @result{} ccc
 
11638
.ddd
 
11639
    @result{} ddd
 
11640
@endExample
 
11641
@endDefesc
 
11642
 
 
11643
@xref{Request and Macro Arguments}.
 
11644
 
 
11645
 
 
11646
@c =====================================================================
 
11647
 
 
11648
@node Page Motions, Drawing Requests, Writing Macros, gtroff Reference
 
11649
@section Page Motions
 
11650
@cindex page motions
 
11651
@cindex motions, page
 
11652
 
 
11653
@xref{Manipulating Spacing}, for a discussion of the main request for
 
11654
vertical motion, @code{sp}.
 
11655
 
 
11656
@DefreqList {mk, [@Var{reg}]}
 
11657
@DefreqListEnd {rt, [@Var{dist}]}
 
11658
@cindex marking vertical page location (@code{mk})
 
11659
@cindex page location, vertical, marking (@code{mk})
 
11660
@cindex location, vertical, page, marking (@code{mk})
 
11661
@cindex vertical page location, marking (@code{mk})
 
11662
@cindex returning to marked vertical page location (@code{rt})
 
11663
@cindex page location, vertical, returning to marked (@code{rt})
 
11664
@cindex location, vertical, page, returning to marked (@code{rt})
 
11665
@cindex vertical page location, returning to marked (@code{rt})
 
11666
The request @code{mk} can be used to mark a location on a page, for
 
11667
movement to later.  This request takes a register name as an argument in
 
11668
which to store the current page location.  With no argument it stores
 
11669
the location in an internal register.  The results of this can be used
 
11670
later by the @code{rt} or the @code{sp} request (or the @code{\v}
 
11671
escape).
 
11672
 
 
11673
The @code{rt} request returns @emph{upwards} to the location marked with
 
11674
the last @code{mk} request.  If used with an argument, return to a
 
11675
position which distance from the top of the page is @var{dist} (no
 
11676
previous call to @code{mk} is necessary in this case).  Default scaling
 
11677
indicator is @samp{v}.
 
11678
 
 
11679
Here a primitive solution for a two-column macro.
 
11680
 
 
11681
@Example
 
11682
.nr column-length 1.5i
 
11683
.nr column-gap 4m
 
11684
.nr bottom-margin 1m
 
11685
.
 
11686
@endExample
 
11687
@Example
 
11688
.de 2c
 
11689
.  br
 
11690
.  mk
 
11691
.  ll \\n[column-length]u
 
11692
.  wh -\\n[bottom-margin]u 2c-trap
 
11693
.  nr right-side 0
 
11694
..
 
11695
.
 
11696
@endExample
 
11697
@Example
 
11698
.de 2c-trap
 
11699
.  ie \\n[right-side] \@{\
 
11700
.    nr right-side 0
 
11701
.    po -(\\n[column-length]u + \\n[column-gap]u)
 
11702
.    \" remove trap
 
11703
.    wh -\\n[bottom-margin]u
 
11704
.  \@}
 
11705
.  el \@{\
 
11706
.    \" switch to right side
 
11707
.    nr right-side 1
 
11708
.    po +(\\n[column-length]u + \\n[column-gap]u)
 
11709
.    rt
 
11710
.  \@}
 
11711
..
 
11712
.
 
11713
@endExample
 
11714
@Example
 
11715
.pl 1.5i
 
11716
.ll 4i
 
11717
This is a small test which shows how the
 
11718
rt request works in combination with mk.
 
11719
 
 
11720
.2c
 
11721
Starting here, text is typeset in two columns.
 
11722
Note that this implementation isn't robust
 
11723
and thus not suited for a real two-column
 
11724
macro.
 
11725
@endExample
 
11726
 
 
11727
Result:
 
11728
 
 
11729
@Example
 
11730
This is a small test which shows how the
 
11731
rt request works in combination with mk.
 
11732
 
 
11733
Starting  here,    isn't    robust
 
11734
text is typeset    and   thus  not
 
11735
in two columns.    suited  for   a
 
11736
Note that  this    real two-column
 
11737
implementation     macro.
 
11738
@endExample
 
11739
@endDefreq
 
11740
 
 
11741
The following escapes give fine control of movements about the page.
 
11742
 
 
11743
@Defesc {\\v, ', e, '}
 
11744
@cindex vertical motion (@code{\v})
 
11745
@cindex motion, vertical (@code{\v})
 
11746
Move vertically, usually from the current location on the page (if no
 
11747
absolute position operator @samp{|} is used).  The argument@tie{}@var{e}
 
11748
specifies the distance to move; positive is downwards and negative
 
11749
upwards.  The default scaling indicator for this escape is @samp{v}.
 
11750
Beware, however, that @code{gtroff} continues text processing at the
 
11751
point where the motion ends, so you should always balance motions to
 
11752
avoid interference with text processing.
 
11753
 
 
11754
@code{\v} doesn't trigger a trap.  This can be quite useful; for
 
11755
example, consider a page bottom trap macro which prints a marker in the
 
11756
margin to indicate continuation of a footnote or something similar.
 
11757
@endDefesc
 
11758
 
 
11759
There are some special-case escapes for vertical motion.
 
11760
 
 
11761
@Defesc {\\r, , , }
 
11762
Move upwards@tie{}1@dmn{v}.
 
11763
@endDefesc
 
11764
 
 
11765
@Defesc {\\u, , , }
 
11766
Move upwards@tie{}.5@dmn{v}.
 
11767
@endDefesc
 
11768
 
 
11769
@Defesc {\\d, , , }
 
11770
Move down@tie{}.5@dmn{v}.
 
11771
@endDefesc
 
11772
 
 
11773
@Defesc {\\h, ', e, '}
 
11774
@cindex inserting horizontal space (@code{\h})
 
11775
@cindex horizontal space (@code{\h})
 
11776
@cindex space, horizontal (@code{\h})
 
11777
@cindex horizontal motion (@code{\h})
 
11778
@cindex motion, horizontal (@code{\h})
 
11779
Move horizontally, usually from the current location (if no absolute
 
11780
position operator @samp{|} is used).  The expression@tie{}@var{e}
 
11781
indicates how far to move: positive is rightwards and negative
 
11782
leftwards.  The default scaling indicator for this escape is @samp{m}.
 
11783
 
 
11784
This horizontal space is not discarded at the end of a line.  To insert
 
11785
discardable space of a certain length use the @code{ss} request.
 
11786
@endDefesc
 
11787
 
 
11788
There are a number of special-case escapes for horizontal motion.
 
11789
 
 
11790
@Defesc {\\@key{SP}, , , }
 
11791
@cindex space, unbreakable
 
11792
@cindex unbreakable space
 
11793
An unbreakable and unpaddable (i.e.@: not expanded during filling)
 
11794
space.  (Note: This is a backslash followed by a space.)
 
11795
@endDefesc
 
11796
 
 
11797
@Defesc {\\~, , , }
 
11798
An unbreakable space that stretches like a normal inter-word space when
 
11799
a line is adjusted.
 
11800
@endDefesc
 
11801
 
 
11802
@Defesc {\\|, , , }
 
11803
A 1/6@dmn{th} em space.  Ignored for TTY output devices (rounded to
 
11804
zero).
 
11805
 
 
11806
However, if there is a glyph defined in the current font file with name
 
11807
@code{\|} (note the leading backslash), the width of this glyph is used
 
11808
instead (even for TTYs).
 
11809
@endDefesc
 
11810
 
 
11811
@Defesc {\\^, , , }
 
11812
A 1/12@dmn{th} em space.  Ignored for TTY output devices (rounded to
 
11813
zero).
 
11814
 
 
11815
However, if there is a glyph defined in the current font file with name
 
11816
@code{\^} (note the leading backslash), the width of this glyph is used
 
11817
instead (even for TTYs).
 
11818
@endDefesc
 
11819
 
 
11820
@Defesc {\\0, , , }
 
11821
@cindex space, width of a digit (@code{\0})
 
11822
@cindex digit width space (@code{\0})
 
11823
A space the size of a digit.
 
11824
@endDefesc
 
11825
 
 
11826
The following string sets the @TeX{} logo:
 
11827
 
 
11828
@Example
 
11829
.ds TeX T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
 
11830
@endExample
 
11831
 
 
11832
@DefescList {\\w, ', text, '}
 
11833
@DefregItem {st}
 
11834
@DefregItem {sb}
 
11835
@DefregItem {rst}
 
11836
@DefregItem {rsb}
 
11837
@DefregItem {ct}
 
11838
@DefregItem {ssc}
 
11839
@DefregListEnd {skw}
 
11840
@cindex width escape (@code{\w})
 
11841
Return the width of the specified @var{text} in basic units.  This
 
11842
allows horizontal movement based on the width of some arbitrary text
 
11843
(e.g.@: given as an argument to a macro).
 
11844
 
 
11845
@Example
 
11846
The length of the string `abc' is \w'abc'u.
 
11847
    @result{} The length of the string `abc' is 72u.
 
11848
@endExample
 
11849
 
 
11850
Font changes may occur in @var{text} which don't affect current
 
11851
settings.
 
11852
 
 
11853
After use, @code{\w} sets several registers:
 
11854
 
 
11855
@table @code
 
11856
@item st
 
11857
@itemx sb
 
11858
The highest and lowest point of the baseline, respectively, in
 
11859
@var{text}.
 
11860
 
 
11861
@item rst
 
11862
@itemx rsb
 
11863
Like the @code{st} and @code{sb} registers, but takes account of the
 
11864
heights and depths of glyphs.  In other words, this gives the highest
 
11865
and lowest point of @var{text}.  Values below the baseline are negative.
 
11866
 
 
11867
@item ct
 
11868
Defines the kinds of glyphs occurring in @var{text}:
 
11869
 
 
11870
@table @asis
 
11871
@item 0
 
11872
only short glyphs, no descenders or tall glyphs.
 
11873
 
 
11874
@item 1
 
11875
at least one descender.
 
11876
 
 
11877
@item 2
 
11878
at least one tall glyph.
 
11879
 
 
11880
@item 3
 
11881
at least one each of a descender and a tall glyph.
 
11882
@end table
 
11883
 
 
11884
@item ssc
 
11885
The amount of horizontal space (possibly negative) that should be added
 
11886
to the last glyph before a subscript.
 
11887
 
 
11888
@item skw
 
11889
How far to right of the center of the last glyph in the @code{\w}
 
11890
argument, the center of an accent from a roman font should be placed
 
11891
over that glyph.
 
11892
@end table
 
11893
@endDefesc
 
11894
 
 
11895
@DefescList {\\k, , p, }
 
11896
@DefescItem {\\k, @Lparen{}, ps, }
 
11897
@DefescListEnd {\\k, @Lbrack{}, position, @Rbrack{}}
 
11898
@cindex saving horizontal input line position (@code{\k})
 
11899
@cindex horizontal input line position, saving (@code{\k})
 
11900
@cindex input line position, horizontal, saving (@code{\k})
 
11901
@cindex position, horizontal input line, saving (@code{\k})
 
11902
@cindex line, input, horizontal position, saving (@code{\k})
 
11903
Store the current horizontal position in the @emph{input} line in number
 
11904
register with name @var{position} (one-character name@tie{}@var{p},
 
11905
two-character name @var{ps}).  Use this, for example, to return to the
 
11906
beginning of a string for highlighting or other decoration.
 
11907
@endDefesc
 
11908
 
 
11909
@Defreg {hp}
 
11910
@cindex horizontal input line position register (@code{hp})
 
11911
@cindex input line, horizontal position, register (@code{hp})
 
11912
@cindex position, horizontal, in input line, register (@code{hp})
 
11913
@cindex line, input, horizontal position, register (@code{hp})
 
11914
The current horizontal position at the input line.
 
11915
@endDefreg
 
11916
 
 
11917
@Defreg {.k}
 
11918
@cindex horizontal output line position register (@code{.k})
 
11919
@cindex output line, horizontal position, register (@code{.k})
 
11920
@cindex position, horizontal, in output line, register (@code{.k})
 
11921
@cindex line, output, horizontal position, register (@code{.k})
 
11922
A read-only number register containing the current horizontal output
 
11923
position (relative to the current indentation).
 
11924
@endDefreg
 
11925
 
 
11926
@Defesc {\\o, ', abc, '}
 
11927
@cindex overstriking glyphs (@code{\o})
 
11928
@cindex glyphs, overstriking (@code{\o})
 
11929
Overstrike glyphs @var{a}, @var{b}, @var{c}, @dots{}; the glyphs are
 
11930
centered, and the resulting spacing is the largest width of the affected
 
11931
glyphs.
 
11932
@endDefesc
 
11933
 
 
11934
@Defesc {\\z, , g, , }
 
11935
@cindex zero-width printing (@code{\z}, @code{\Z})
 
11936
@cindex printing, zero-width (@code{\z}, @code{\Z})
 
11937
Print glyph @var{g} with zero width, i.e., without spacing.  Use this to
 
11938
overstrike glyphs left-aligned.
 
11939
@endDefesc
 
11940
 
 
11941
@Defesc {\\Z, ', anything, '}
 
11942
@cindex zero-width printing (@code{\z}, @code{\Z})
 
11943
@cindex printing, zero-width (@code{\z}, @code{\Z})
 
11944
Print @var{anything}, then restore the horizontal and vertical position.
 
11945
The argument may not contain tabs or leaders.
 
11946
 
 
11947
The following is an example of a strike-through macro:
 
11948
 
 
11949
@Example
 
11950
.de ST
 
11951
.nr ww \w'\\$1'
 
11952
\Z@@\v'-.25m'\l'\\n[ww]u'@@\\$1
 
11953
..
 
11954
.
 
11955
This is
 
11956
.ST "a test"
 
11957
an actual emergency!
 
11958
@endExample
 
11959
@endDefesc
 
11960
 
 
11961
 
 
11962
@c =====================================================================
 
11963
 
 
11964
@node Drawing Requests, Traps, Page Motions, gtroff Reference
 
11965
@section Drawing Requests
 
11966
@cindex drawing requests
 
11967
@cindex requests for drawing
 
11968
 
 
11969
@code{gtroff} provides a number of ways to draw lines and other figures
 
11970
on the page.  Used in combination with the page motion commands (see
 
11971
@ref{Page Motions}, for more info), a wide variety of figures can be
 
11972
drawn.  However, for complex drawings these operations can be quite
 
11973
cumbersome, and it may be wise to use graphic preprocessors like
 
11974
@code{gpic} or @code{ggrn}.  @xref{gpic}, and @ref{ggrn}, for more
 
11975
information.
 
11976
 
 
11977
All drawing is done via escapes.
 
11978
 
 
11979
@DefescList {\\l, ', l, '}
 
11980
@DefescListEnd {\\l, ', lg, '}
 
11981
@cindex drawing horizontal lines (@code{\l})
 
11982
@cindex horizontal line, drawing (@code{\l})
 
11983
@cindex line, horizontal, drawing (@code{\l})
 
11984
Draw a line horizontally.  @var{l} is the length of the line to be
 
11985
drawn.  If it is positive, start the line at the current location and
 
11986
draw to the right; its end point is the new current location.  Negative
 
11987
values are handled differently: The line starts at the current location
 
11988
and draws to the left, but the current location doesn't move.
 
11989
 
 
11990
@var{l} can also be specified absolutely (i.e.@: with a leading
 
11991
@samp{|}) which draws back to the beginning of the input line.  Default
 
11992
scaling indicator is @samp{m}.
 
11993
 
 
11994
@cindex underscore glyph (@code{\[ru]})
 
11995
@cindex glyph, underscore (@code{\[ru]})
 
11996
@cindex line drawing glyph
 
11997
@cindex glyph, for line drawing
 
11998
The optional second parameter@tie{}@var{g} is a glyph to draw the line
 
11999
with.  If this second argument is not specified, @code{gtroff} uses the
 
12000
underscore glyph, @code{\[ru]}.
 
12001
 
 
12002
@cindex zero width space character (@code{\&})
 
12003
@cindex character, zero width space (@code{\&})
 
12004
@cindex space character, zero width (@code{\&})
 
12005
To separate the two arguments (to prevent @code{gtroff} from
 
12006
interpreting a drawing glyph as a scaling indicator if the glyph is
 
12007
represented by a single character) use @code{\&}.
 
12008
 
 
12009
Here a small useful example:
 
12010
 
 
12011
@Example
 
12012
.de box
 
12013
\[br]\\$*\[br]\l'|0\[rn]'\l'|0\[ul]'
 
12014
..
 
12015
@endExample
 
12016
 
 
12017
@noindent
 
12018
Note that this works by outputting a box rule (a vertical line), then
 
12019
the text given as an argument and then another box rule.  Finally, the
 
12020
line drawing escapes both draw from the current location to the
 
12021
beginning of the @emph{input} line -- this works because the line length
 
12022
is negative, not moving the current point.
 
12023
@endDefesc
 
12024
 
 
12025
@DefescList {\\L, ', l, '}
 
12026
@DefescListEnd {\\L, ', lg, '}
 
12027
@cindex drawing vertical lines (@code{\L})
 
12028
@cindex vertical line drawing (@code{\L})
 
12029
@cindex line, vertical, drawing (@code{\L})
 
12030
@cindex line drawing glyph
 
12031
@cindex glyph for line drawing
 
12032
@cindex box rule glyph (@code{\[br]})
 
12033
@cindex glyph, box rule (@code{\[br]})
 
12034
Draw vertical lines.  Its parameters are similar to the @code{\l}
 
12035
escape, except that the default scaling indicator is @samp{v}.  The
 
12036
movement is downwards for positive values, and upwards for negative
 
12037
values.  The default glyph is the box rule glyph, @code{\[br]}.  As with
 
12038
the vertical motion escapes, text processing blindly continues where the
 
12039
line ends.
 
12040
 
 
12041
@Example
 
12042
This is a \L'3v'test.
 
12043
@endExample
 
12044
 
 
12045
@noindent
 
12046
Here the result, produced with @code{grotty}.
 
12047
 
 
12048
@Example
 
12049
This is a
 
12050
          |
 
12051
          |
 
12052
          |test.
 
12053
@endExample
 
12054
@endDefesc
 
12055
 
 
12056
@Defesc {\\D, ', command arg @dots{}, '}
 
12057
The @code{\D} escape provides a variety of drawing functions.  Note that
 
12058
on character devices, only vertical and horizontal lines are supported
 
12059
within @code{grotty}; other devices may only support a subset of the
 
12060
available drawing functions.
 
12061
 
 
12062
The default scaling indicator for all subcommands of @code{\D} is
 
12063
@samp{m} for horizontal distances and @samp{v} for vertical ones.
 
12064
Exceptions are @w{@code{\D'f @dots{}'}} and @w{@code{\D't @dots{}'}}
 
12065
which use @code{u} as the default, and @w{@code{\D'F@var{x} @dots{}'}}
 
12066
which arguments are treated similar to the @code{defcolor} request.
 
12067
 
 
12068
@table @code
 
12069
@item \D'l @var{dx} @var{dy}'
 
12070
@cindex line, drawing (@w{@code{\D'l @dots{}'}})
 
12071
@cindex drawing a line (@w{@code{\D'l @dots{}'}})
 
12072
Draw a line from the current location to the relative point specified by
 
12073
(@var{dx},@var{dy}), where positive values mean down and right,
 
12074
respectively.  The end point of the line is the new current location.
 
12075
 
 
12076
The following example is a macro for creating a box around a text
 
12077
string; for simplicity, the box margin is taken as a fixed value,
 
12078
0.2@dmn{m}.
 
12079
 
 
12080
@Example
 
12081
.de BOX
 
12082
.  nr @@wd \w'\\$1'
 
12083
\h'.2m'\
 
12084
\h'-.2m'\v'(.2m - \\n[rsb]u)'\
 
12085
\D'l 0 -(\\n[rst]u - \\n[rsb]u + .4m)'\
 
12086
\D'l (\\n[@@wd]u + .4m) 0'\
 
12087
\D'l 0 (\\n[rst]u - \\n[rsb]u + .4m)'\
 
12088
\D'l -(\\n[@@wd]u + .4m) 0'\
 
12089
\h'.2m'\v'-(.2m - \\n[rsb]u)'\
 
12090
\\$1\
 
12091
\h'.2m'
 
12092
..
 
12093
@endExample
 
12094
 
 
12095
@noindent
 
12096
First, the width of the string is stored in register @code{@@wd}.  Then,
 
12097
four lines are drawn to form a box, properly offset by the box margin.
 
12098
The registers @code{rst} and @code{rsb} are set by the @code{\w} escape,
 
12099
containing the largest height and depth of the whole string.
 
12100
 
 
12101
@item \D'c @var{d}'
 
12102
@cindex circle, drawing (@w{@code{\D'c @dots{}'}})
 
12103
@cindex drawing a circle (@w{@code{\D'c @dots{}'}})
 
12104
Draw a circle with a diameter of@tie{}@var{d} with the leftmost point at
 
12105
the current position.  After drawing, the current location is positioned
 
12106
at the rightmost point of the circle.
 
12107
 
 
12108
@item \D'C @var{d}'
 
12109
@cindex circle, solid, drawing (@w{@code{\D'C @dots{}'}})
 
12110
@cindex drawing a solid circle (@w{@code{\D'C @dots{}'}})
 
12111
@cindex solid circle, drawing (@w{@code{\D'C @dots{}'}})
 
12112
Draw a solid circle with the same parameters and behaviour as an
 
12113
outlined circle.  No outline is drawn.
 
12114
 
 
12115
@item \D'e @var{x} @var{y}'
 
12116
@cindex drawing an ellipse (@w{@code{\D'e @dots{}'}})
 
12117
@cindex ellipse, drawing (@w{@code{\D'e @dots{}'}})
 
12118
Draw an ellipse with a horizontal diameter of @var{x} and a vertical
 
12119
diameter of @var{y} with the leftmost point at the current position.
 
12120
After drawing, the current location is positioned at the rightmost point
 
12121
of the ellipse.
 
12122
 
 
12123
@item \D'E @var{x} @var{y}'
 
12124
@cindex ellipse, solid, drawing (@w{@code{\D'E @dots{}'}})
 
12125
@cindex drawing a solid ellipse (@w{@code{\D'E @dots{}'}})
 
12126
@cindex solid ellipse, drawing (@w{@code{\D'E @dots{}'}})
 
12127
Draw a solid ellipse with the same parameters and behaviour as an
 
12128
outlined ellipse.  No outline is drawn.
 
12129
 
 
12130
@item \D'a @var{dx1} @var{dy1} @var{dx2} @var{dy2}'
 
12131
@cindex arc, drawing (@w{@code{\D'a @dots{}'}})
 
12132
@cindex drawing an arc (@w{@code{\D'a @dots{}'}})
 
12133
Draw an arc clockwise from the current location through the two
 
12134
specified relative locations (@var{dx1},@var{dy1}) and
 
12135
(@var{dx2},@var{dy2}).  The coordinates of the first point are relative
 
12136
to the current position, and the coordinates of the second point are
 
12137
relative to the first point.  After drawing, the current position is
 
12138
moved to the final point of the arc.
 
12139
 
 
12140
@item \D'~ @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
 
12141
@cindex drawing a spline (@w{@code{\D'~ @dots{}'}})
 
12142
@cindex spline, drawing (@w{@code{\D'~ @dots{}'}})
 
12143
Draw a spline from the current location to the relative point
 
12144
(@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}), and so on.  The
 
12145
current position is moved to the terminal point of the drawn curve.
 
12146
 
 
12147
@item \D'f @var{n}'
 
12148
@cindex gray shading (@w{@code{\D'f @dots{}'}})
 
12149
@cindex shading filled objects (@w{@code{\D'f @dots{}'}})
 
12150
Set the shade of gray to be used for filling solid objects
 
12151
to@tie{}@var{n}; @var{n}@tie{}must be an integer between 0
 
12152
and@tie{}1000, where 0 corresponds solid white and 1000 to solid black,
 
12153
and values in between correspond to intermediate shades of gray.  This
 
12154
applies only to solid circles, solid ellipses, and solid polygons.  By
 
12155
default, a level of 1000 is used.
 
12156
 
 
12157
Despite of being silly, the current point is moved horizontally to the
 
12158
right by@tie{}@var{n}.
 
12159
 
 
12160
@cindex @w{@code{\D'f @dots{}'}} and horizontal resolution
 
12161
Don't use this command!  It has the serious drawback that it is always
 
12162
rounded to the next integer multiple of the horizontal resolution (the
 
12163
value of the @code{hor} keyword in the @file{DESC} file).  Use @code{\M}
 
12164
(@pxref{Colors}) or @w{@code{\D'Fg @dots{}'}} instead.
 
12165
 
 
12166
@item \D'p @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
 
12167
@cindex drawing a polygon (@w{@code{\D'p @dots{}'}})
 
12168
@cindex polygon, drawing (@w{@code{\D'p @dots{}'}})
 
12169
Draw a polygon from the current location to the relative position
 
12170
(@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}) and so on.  When
 
12171
the specified data points are exhausted, a line is drawn back to the
 
12172
starting point.  The current position is changed by adding the sum of
 
12173
all arguments with odd index to the actual horizontal position and the
 
12174
even ones to the vertical position.
 
12175
 
 
12176
@item \D'P @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
 
12177
@cindex polygon, solid, drawing (@w{@code{\D'P @dots{}'}})
 
12178
@cindex drawing a solid polygon (@w{@code{\D'P @dots{}'}})
 
12179
@cindex solid polygon, drawing (@w{@code{\D'P @dots{}'}})
 
12180
Draw a solid polygon with the same parameters and behaviour as an
 
12181
outlined polygon.  No outline is drawn.
 
12182
 
 
12183
Here a better variant of the box macro to fill the box with some color.
 
12184
Note that the box must be drawn before the text since colors in
 
12185
@code{gtroff} are not transparent; the filled polygon would hide the
 
12186
text completely.
 
12187
 
 
12188
@Example
 
12189
.de BOX
 
12190
.  nr @@wd \w'\\$1'
 
12191
\h'.2m'\
 
12192
\h'-.2m'\v'(.2m - \\n[rsb]u)'\
 
12193
\M[lightcyan]\
 
12194
\D'P 0 -(\\n[rst]u - \\n[rsb]u + .4m) \
 
12195
     (\\n[@@wd]u + .4m) 0 \
 
12196
     0 (\\n[rst]u - \\n[rsb]u + .4m) \
 
12197
     -(\\n[@@wd]u + .4m) 0'\
 
12198
\h'.2m'\v'-(.2m - \\n[rsb]u)'\
 
12199
\M[]\
 
12200
\\$1\
 
12201
\h'.2m'
 
12202
..
 
12203
@endExample
 
12204
 
 
12205
If you want a filled polygon which has exactly the same size as an
 
12206
unfilled one, you must draw both an unfilled and a filled polygon.  A
 
12207
filled polygon is always smaller than an unfilled one because the latter
 
12208
uses straight lines with a given line thickness to connect the polygon's
 
12209
corners, while the former simply fills the area defined by the
 
12210
coordinates.
 
12211
 
 
12212
@Example
 
12213
\h'1i'\v'1i'\
 
12214
\# increase line thickness
 
12215
\Z'\D't 5p''\
 
12216
\# draw unfilled polygon
 
12217
\Z'\D'p 3 3 -6 0''\
 
12218
\# draw filled polygon
 
12219
\Z'\D'P 3 3 -6 0''
 
12220
@endExample
 
12221
 
 
12222
@item \D't @var{n}'
 
12223
@cindex line thickness (@w{@code{\D't @dots{}'}})
 
12224
@cindex thickness of lines (@w{@code{\D't @dots{}'}})
 
12225
Set the current line thickness to @var{n}@tie{}machine units.  A value
 
12226
of zero selects the smallest available line thickness.  A negative value
 
12227
makes the line thickness proportional to the current point size (this is
 
12228
the default behaviour of @acronym{AT&T} @code{troff}).
 
12229
 
 
12230
Despite of being silly, the current point is moved horizontally to the
 
12231
right by@tie{}@var{n}.
 
12232
 
 
12233
@item \D'F@var{scheme} @var{color_components}'
 
12234
@cindex unnamed fill colors (@code{\D'F@dots{}'})
 
12235
@cindex fill colors, unnamed (@code{\D'F@dots{}'})
 
12236
@cindex colors, fill, unnamed (@code{\D'F@dots{}'})
 
12237
Change current fill color.  @var{scheme} is a single letter denoting the
 
12238
color scheme: @samp{r} (rgb), @samp{c} (cmy), @samp{k} (cmyk), @samp{g}
 
12239
(gray), or @samp{d} (default color).  The color components use exactly
 
12240
the same syntax as in the @code{defcolor} request (@pxref{Colors}); the
 
12241
command @code{\D'Fd'} doesn't take an argument.
 
12242
 
 
12243
@emph{No} position changing!
 
12244
 
 
12245
Examples:
 
12246
 
 
12247
@Example
 
12248
@endExample
 
12249
\D'Fg .3'      \" same gray as \D'f 700'
 
12250
\D'Fr #0000ff' \" blue
 
12251
@end table
 
12252
@endDefesc
 
12253
 
 
12254
@xref{Graphics Commands}.
 
12255
 
 
12256
@Defesc {\\b, ', string, '}
 
12257
@cindex pile, glyph (@code{\b})
 
12258
@cindex glyph pile (@code{\b})
 
12259
@cindex stacking glyphs (@code{\b})
 
12260
@dfn{Pile} a sequence of glyphs vertically, and center it vertically on
 
12261
the current line.  Use it to build large brackets and braces.
 
12262
 
 
12263
Here an example how to create a large opening brace:
 
12264
 
 
12265
@Example
 
12266
\b'\[lt]\[bv]\[lk]\[bv]\[lb]'
 
12267
@endExample
 
12268
 
 
12269
@cindex @code{\b}, limitations
 
12270
@cindex limitations of @code{\b} escape
 
12271
The first glyph is on the top, the last glyph in @var{string} is at the
 
12272
bottom.  Note that @code{gtroff} separates the glyphs vertically by
 
12273
1@dmn{m}, and the whole object is centered 0.5@dmn{m} above the current
 
12274
baseline; the largest glyph width is used as the width for the whole
 
12275
object.  This rather unflexible positioning algorithm doesn't work with
 
12276
@option{-Tdvi} since the bracket pieces vary in height for this device.
 
12277
Instead, use the @code{eqn} preprocessor.
 
12278
 
 
12279
@xref{Manipulating Spacing}, how to adjust the vertical spacing with the
 
12280
@code{\x} escape.
 
12281
@endDefesc
 
12282
 
 
12283
 
 
12284
@c =====================================================================
 
12285
 
 
12286
@node Traps, Diversions, Drawing Requests, gtroff Reference
 
12287
@section Traps
 
12288
@cindex traps
 
12289
 
 
12290
@dfn{Traps} are locations, which, when reached, call a specified macro.
 
12291
These traps can occur at a given location on the page, at a given
 
12292
location in the current diversion, at a blank line, after a certain
 
12293
number of input lines, or at the end of input.
 
12294
 
 
12295
@cindex planting a trap
 
12296
@cindex trap, planting
 
12297
Setting a trap is also called @dfn{planting}.
 
12298
@cindex trap, springing
 
12299
@cindex springing a trap
 
12300
It is also said that a trap is @dfn{sprung} if the associated macro is
 
12301
executed.
 
12302
 
 
12303
@menu
 
12304
* Page Location Traps::
 
12305
* Diversion Traps::
 
12306
* Input Line Traps::
 
12307
* Blank Line Traps::
 
12308
* Leading Spaces Traps::
 
12309
* End-of-input Traps::
 
12310
@end menu
 
12311
 
 
12312
@c ---------------------------------------------------------------------
 
12313
 
 
12314
@node Page Location Traps, Diversion Traps, Traps, Traps
 
12315
@subsection Page Location Traps
 
12316
@cindex page location traps
 
12317
@cindex traps, page location
 
12318
 
 
12319
@dfn{Page location traps} perform an action when @code{gtroff} reaches
 
12320
or passes a certain vertical location on the page.  Page location traps
 
12321
have a variety of purposes, including:
 
12322
 
 
12323
@itemize
 
12324
@item
 
12325
setting headers and footers
 
12326
 
 
12327
@item
 
12328
setting body text in multiple columns
 
12329
 
 
12330
@item
 
12331
setting footnotes
 
12332
@end itemize
 
12333
 
 
12334
@DefreqList {vpt, flag}
 
12335
@DefregListEnd {.vpt}
 
12336
@cindex enabling vertical position traps (@code{vpt})
 
12337
@cindex vertical position traps, enabling (@code{vpt})
 
12338
@cindex vertical position trap enable register (@code{.vpt})
 
12339
Enable vertical position traps if @var{flag} is non-zero, or disables
 
12340
them otherwise.  Vertical position traps are traps set by the @code{wh}
 
12341
or @code{dt} requests.  Traps set by the @code{it} request are not
 
12342
vertical position traps.  The parameter that controls whether vertical
 
12343
position traps are enabled is global.  Initially vertical position traps
 
12344
are enabled.  The current setting of this is available in the
 
12345
@code{.vpt} read-only number register.
 
12346
 
 
12347
Note that a page can't be ejected if @code{vpt} is set to zero.
 
12348
@endDefreq
 
12349
 
 
12350
@Defreq {wh, dist [@Var{macro}]}
 
12351
Set a page location trap.  Non-negative values for @var{dist} set the
 
12352
trap relative to the top of the page; negative values set the trap
 
12353
relative to the bottom of the page.  Default scaling indicator is
 
12354
@samp{v}; values of @var{dist} are always rounded to be multiples of the
 
12355
vertical resolution (as given in register @code{.V}).
 
12356
 
 
12357
@var{macro} is the name of the macro to execute when the trap is sprung.
 
12358
If @var{macro} is missing, remove the first trap (if any) at @var{dist}.
 
12359
 
 
12360
@cindex page headers
 
12361
@cindex page footers
 
12362
@cindex headers
 
12363
@cindex footers
 
12364
The following is a simple example of how many macro packages set headers
 
12365
and footers.
 
12366
 
 
12367
@Example
 
12368
.de hd                \" Page header
 
12369
'  sp .5i
 
12370
.  tl 'Title''date'
 
12371
'  sp .3i
 
12372
..
 
12373
.
 
12374
.de fo                \" Page footer
 
12375
'  sp 1v
 
12376
.  tl ''%''
 
12377
'  bp
 
12378
..
 
12379
.
 
12380
.wh 0   hd            \" trap at top of the page
 
12381
.wh -1i fo            \" trap one inch from bottom
 
12382
@endExample
 
12383
 
 
12384
A trap at or below the bottom of the page is ignored; it can be made
 
12385
active by either moving it up or increasing the page length so that the
 
12386
trap is on the page.
 
12387
 
 
12388
Negative trap values always use the @emph{current} page length; they are
 
12389
not converted to an absolute vertical position:
 
12390
 
 
12391
@Example
 
12392
.pl 5i
 
12393
.wh -1i xx
 
12394
.ptr
 
12395
    @result{} xx      -240
 
12396
.pl 100i
 
12397
.ptr
 
12398
    @result{} xx      -240
 
12399
@endExample
 
12400
 
 
12401
It is possible to have more than one trap at the same location; to do
 
12402
so, the traps must be defined at different locations, then moved
 
12403
together with the @code{ch} request; otherwise the second trap would
 
12404
replace the first one.  Earlier defined traps hide later defined traps
 
12405
if moved to the same position (the many empty lines caused by the
 
12406
@code{bp} request are omitted in the following example):
 
12407
 
 
12408
@Example
 
12409
.de a
 
12410
.  nop a
 
12411
..
 
12412
.de b
 
12413
.  nop b
 
12414
..
 
12415
.de c
 
12416
.  nop c
 
12417
..
 
12418
.
 
12419
.wh 1i a
 
12420
.wh 2i b
 
12421
.wh 3i c
 
12422
.bp
 
12423
    @result{} a b c
 
12424
@endExample
 
12425
@Example
 
12426
.ch b 1i
 
12427
.ch c 1i
 
12428
.bp
 
12429
    @result{} a
 
12430
@endExample
 
12431
@Example
 
12432
.ch a 0.5i
 
12433
.bp
 
12434
    @result{} a b
 
12435
@endExample
 
12436
@endDefreq
 
12437
 
 
12438
@Defreg {.t}
 
12439
@cindex distance to next trap register (@code{.t})
 
12440
@cindex trap, distance, register (@code{.t})
 
12441
A read-only number register holding the distance to the next trap.
 
12442
 
 
12443
If there are no traps between the current position and the bottom of the
 
12444
page, it contains the distance to the page bottom.  In a diversion, the
 
12445
distance to the page bottom is infinite (the returned value is the
 
12446
biggest integer which can be represented in @code{groff}) if there are
 
12447
no diversion traps.
 
12448
@endDefreg
 
12449
 
 
12450
@Defreq {ch, macro [@Var{dist}]}
 
12451
@cindex changing trap location (@code{ch})
 
12452
@cindex trap, changing location (@code{ch})
 
12453
Change the location of a trap.  The first argument is the name of the
 
12454
macro to be invoked at the trap, and the second argument is the new
 
12455
location for the trap (note that the parameters are specified in
 
12456
opposite order as in the @code{wh} request).  This is useful for
 
12457
building up footnotes in a diversion to allow more space at the bottom
 
12458
of the page for them.
 
12459
 
 
12460
Default scaling indicator for @var{dist} is @samp{v}.  If @var{dist} is
 
12461
missing, the trap is removed.
 
12462
 
 
12463
@c XXX
 
12464
 
 
12465
@ignore
 
12466
@Example
 
12467
... (simplified) footnote example ...
 
12468
@endExample
 
12469
@end ignore
 
12470
@endDefreq
 
12471
 
 
12472
@Defreg {.ne}
 
12473
The read-only number register @code{.ne} contains the amount of space
 
12474
that was needed in the last @code{ne} request that caused a trap to be
 
12475
sprung.  Useful in conjunction with the @code{.trunc} register.
 
12476
@xref{Page Control}, for more information.
 
12477
 
 
12478
Since the @code{.ne} register is only set by traps it doesn't make much
 
12479
sense to use it outside of trap macros.
 
12480
@endDefreg
 
12481
 
 
12482
@Defreg {.trunc}
 
12483
@cindex @code{ne} request, and the @code{.trunc} register
 
12484
@cindex truncated vertical space register (@code{.trunc})
 
12485
A read-only register containing the amount of vertical space truncated
 
12486
by the most recently sprung vertical position trap, or, if the trap was
 
12487
sprung by an @code{ne} request, minus the amount of vertical motion
 
12488
produced by the @code{ne} request.  In other words, at the point a trap
 
12489
is sprung, it represents the difference of what the vertical position
 
12490
would have been but for the trap, and what the vertical position
 
12491
actually is.
 
12492
 
 
12493
Since the @code{.trunc} register is only set by traps it doesn't make
 
12494
much sense to use it outside of trap macros.
 
12495
@endDefreg
 
12496
 
 
12497
@Defreg {.pe}
 
12498
@cindex @code{bp} request, and traps (@code{.pe})
 
12499
@cindex traps, sprung by @code{bp} request (@code{.pe})
 
12500
@cindex page ejecting register (@code{.pe})
 
12501
A read-only register which is set to@tie{}1 while a page is ejected with
 
12502
the @code{bp} request (or by the end of input).
 
12503
 
 
12504
Outside of traps this register is always zero.  In the following
 
12505
example, only the second call to@tie{}@code{x} is caused by @code{bp}.
 
12506
 
 
12507
@Example
 
12508
.de x
 
12509
\&.pe=\\n[.pe]
 
12510
.br
 
12511
..
 
12512
.wh 1v x
 
12513
.wh 4v x
 
12514
A line.
 
12515
.br
 
12516
Another line.
 
12517
.br
 
12518
    @result{} A line.
 
12519
       .pe=0
 
12520
       Another line.
 
12521
 
 
12522
       .pe=1
 
12523
@endExample
 
12524
@endDefreg
 
12525
 
 
12526
@cindex diversions, and traps
 
12527
@cindex traps, and diversions
 
12528
An important fact to consider while designing macros is that diversions
 
12529
and traps do not interact normally.  For example, if a trap invokes a
 
12530
header macro (while outputting a diversion) which tries to change the
 
12531
font on the current page, the effect is not visible before the diversion
 
12532
has completely been printed (except for input protected with @code{\!}
 
12533
or @code{\?}) since the data in the diversion is already formatted.  In
 
12534
most cases, this is not the expected behaviour.
 
12535
 
 
12536
@c ---------------------------------------------------------------------
 
12537
 
 
12538
@node Diversion Traps, Input Line Traps, Page Location Traps, Traps
 
12539
@subsection Diversion Traps
 
12540
@cindex diversion traps
 
12541
@cindex traps, diversion
 
12542
 
 
12543
@Defreq {dt, [@Var{dist} @Var{macro}]}
 
12544
@cindex @code{.t} register, and diversions
 
12545
@cindex setting diversion trap (@code{dt})
 
12546
@cindex diversion trap, setting (@code{dt})
 
12547
@cindex trap, diversion, setting (@code{dt})
 
12548
Set a trap @emph{within} a diversion.  @var{dist} is the location of the
 
12549
trap (identical to the @code{wh} request; default scaling indicator is
 
12550
@samp{v}) and @var{macro} is the name of the macro to be invoked.  If
 
12551
called without arguments, the diversion trap is removed.
 
12552
 
 
12553
Note that there exists only a single diversion trap.
 
12554
 
 
12555
The number register @code{.t} still works within diversions.
 
12556
@xref{Diversions}, for more information.
 
12557
@endDefreq
 
12558
 
 
12559
@c ---------------------------------------------------------------------
 
12560
 
 
12561
@node Input Line Traps, Blank Line Traps, Diversion Traps, Traps
 
12562
@subsection Input Line Traps
 
12563
@cindex input line traps
 
12564
@cindex traps, input line
 
12565
 
 
12566
@DefreqList {it, n macro}
 
12567
@DefreqItem {itc, n macro}
 
12568
@cindex setting input line trap (@code{it})
 
12569
@cindex input line trap, setting (@code{it})
 
12570
@cindex trap, input line, setting (@code{it})
 
12571
Set an input line trap.  @var{n}@tie{}is the number of lines of input
 
12572
which may be read before springing the trap, @var{macro} is the macro to
 
12573
be invoked.  Request lines are not counted as input lines.
 
12574
 
 
12575
For example, one possible use is to have a macro which prints the next
 
12576
@var{n}@tie{}lines in a bold font.
 
12577
 
 
12578
@Example
 
12579
.de B
 
12580
.  it \\$1 B-end
 
12581
.  ft B
 
12582
..
 
12583
.
 
12584
.de B-end
 
12585
.  ft R
 
12586
..
 
12587
@endExample
 
12588
 
 
12589
@cindex input line traps and interrupted lines (@code{itc})
 
12590
@cindex interrupted lines and input line traps (@code{itc})
 
12591
@cindex traps, input line, and interrupted lines (@code{itc})
 
12592
@cindex lines, interrupted, and input line traps (@code{itc})
 
12593
The @code{itc} request is identical except that an interrupted text line
 
12594
(ending with @code{\c}) is not counted as a separate line.
 
12595
 
 
12596
Both requests are associated with the current environment
 
12597
(@pxref{Environments}); switching to another environment disables the
 
12598
current input trap, and going back reactivates it, restoring the number
 
12599
of already processed lines.
 
12600
@endDefreq
 
12601
 
 
12602
@c ---------------------------------------------------------------------
 
12603
 
 
12604
@node Blank Line Traps, Leading Spaces Traps, Input Line Traps, Traps
 
12605
@subsection Blank Line Traps
 
12606
@cindex blank line traps
 
12607
@cindex traps, blank line
 
12608
 
 
12609
@Defreq {blm, macro}
 
12610
@cindex blank line macro (@code{blm})
 
12611
Set a blank line trap.  @code{gtroff} executes @var{macro} when it
 
12612
encounters a blank line in the input file.
 
12613
@endDefreq
 
12614
 
 
12615
@c ---------------------------------------------------------------------
 
12616
 
 
12617
@node Leading Spaces Traps, End-of-input Traps, Blank Line Traps, Traps
 
12618
@subsection Leading Spaces Traps
 
12619
@cindex leading spaces traps
 
12620
@cindex traps, leading spaces
 
12621
 
 
12622
@DefreqList {lsm, macro}
 
12623
@DefregItem {lsn}
 
12624
@DefregListEnd {lss}
 
12625
@cindex leading spaces macro (@code{lsm})
 
12626
Set a leading spaces trap.  @code{gtroff} executes @var{macro} when it
 
12627
encounters leading spaces in an input line; the implicit line break
 
12628
which normally happens in this case is suppressed.  A line consisting
 
12629
of spaces only, however, is treated as an empty line, possibly subject
 
12630
to an empty line macro set with the @code{blm} request.
 
12631
 
 
12632
Leading spaces are removed from the input line before calling the
 
12633
leading spaces macro.  The number of removed spaces is stored in
 
12634
register @code{lsn}; the horizontal space which would be emitted if
 
12635
there was no leading space macro is stored in register @code{lss}.
 
12636
Note that @code{lsn} and @code{lss} are available even if no leading
 
12637
space macro has been set.
 
12638
 
 
12639
The first thing a leading space macro sees is a token.  However, some
 
12640
escapes like @code{\f} or @code{\m} are handled on the fly (see
 
12641
@ref{Gtroff Internals}, for a complete list) without creating a token
 
12642
at all.  Consider that a line starts with two spaces followed by
 
12643
@code{\fIfoo}.  While skipping the spaces @code{\fI} is handled too so
 
12644
that groff's current font is properly set to @samp{I}, but the leading
 
12645
space macro only sees @code{foo}, without the preceding @code{\fI}.
 
12646
If the macro should see the font escape you have to `protect' it with
 
12647
something which creates a token, for example with @code{\&\fIfoo}.
 
12648
@endDefreq
 
12649
 
 
12650
@c ---------------------------------------------------------------------
 
12651
 
 
12652
@node End-of-input Traps,  , Leading Spaces Traps, Traps
 
12653
@subsection End-of-input Traps
 
12654
@cindex end-of-input traps
 
12655
@cindex traps, end-of-input
 
12656
 
 
12657
@Defreq {em, macro}
 
12658
@cindex setting end-of-input trap (@code{em})
 
12659
@cindex end-of-input trap, setting (@code{em})
 
12660
@cindex trap, end-of-input, setting (@code{em})
 
12661
@cindex end-of-input macro (@code{em})
 
12662
@cindex macro, end-of-input (@code{em})
 
12663
Set a trap at the end of input.  @var{macro} is executed after the last
 
12664
line of the input file has been processed.
 
12665
 
 
12666
For example, if the document had to have a section at the bottom of the
 
12667
last page for someone to approve it, the @code{em} request could be
 
12668
used.
 
12669
 
 
12670
@Example
 
12671
.de approval
 
12672
\c
 
12673
.  ne 3v
 
12674
.  sp (\\n[.t]u - 3v)
 
12675
.  in +4i
 
12676
.  lc _
 
12677
.  br
 
12678
Approved:\t\a
 
12679
.  sp
 
12680
Date:\t\t\a
 
12681
..
 
12682
.
 
12683
.em approval
 
12684
@endExample
 
12685
 
 
12686
The @code{\c} in the above example needs explanation.  For historical
 
12687
reasons (and for compatibility with @acronym{AT&T} @code{troff}), the
 
12688
end macro exits as soon as it causes a page break and no remaining
 
12689
data is in the partially collected line.
 
12690
 
 
12691
Let us assume that there is no @code{\c} in the above @code{approval}
 
12692
macro, and that the page is full and has been ended with, say, a
 
12693
@code{br} request.  The @code{ne} request now causes the start of a new
 
12694
page, which in turn makes @code{troff} exit immediately for the reasons
 
12695
just described.  In most situations this is not intended.
 
12696
 
 
12697
To always force processing the whole end macro independently of this
 
12698
behaviour it is thus advisable to insert something which starts an
 
12699
empty partially filled line (@code{\c}) whenever there is a chance that
 
12700
a page break can happen.  In the above example, the call of the
 
12701
@code{ne} request assures that the remaining code stays on the same
 
12702
page, so we have to insert @code{\c} only once.
 
12703
 
 
12704
The next example shows how to append three lines, then starting a new
 
12705
page unconditionally.  Since @w{@samp{.ne 1}} doesn't give the desired
 
12706
effect -- there is always one line available or we are already at the
 
12707
beginning of the next page -- we temporarily increase the page length
 
12708
by one line so that we can use @w{@samp{.ne 2}}.
 
12709
 
 
12710
@Example
 
12711
.de EM
 
12712
.pl +1v
 
12713
\c
 
12714
.ne 2
 
12715
line one
 
12716
.br
 
12717
\c
 
12718
.ne 2
 
12719
line two
 
12720
.br
 
12721
\c
 
12722
.ne 2
 
12723
line three
 
12724
.br
 
12725
.pl -1v
 
12726
\c
 
12727
'bp
 
12728
..
 
12729
.em EM
 
12730
@endExample
 
12731
 
 
12732
Note that this specific feature affects only the first potential page
 
12733
break caused by the end macro; further page breaks emitted by the end
 
12734
macro are handled normally.
 
12735
 
 
12736
Another possible use of the @code{em} request is to make @code{gtroff}
 
12737
emit a single large page instead of multiple pages.  For example, one
 
12738
may want to produce a long plain-text file for reading on-screen.  The
 
12739
idea is to set the page length at the beginning of the document to a
 
12740
very large value to hold all the text, and automatically adjust it to
 
12741
the exact height of the document after the text has been output.
 
12742
 
 
12743
@Example
 
12744
.de adjust-page-length
 
12745
.  br
 
12746
.  pl \\n[nl]u   \" \n[nl] holds the current page length
 
12747
..
 
12748
.
 
12749
.de single-page-mode
 
12750
.  pl 99999
 
12751
.  em adjust-page-length
 
12752
..
 
12753
.
 
12754
.\" activate the above code
 
12755
.single-page-mode
 
12756
@endExample
 
12757
 
 
12758
Since only one end-of-input trap does exist and other macro packages
 
12759
may already use it, care must be taken not to break the mechanism.  A
 
12760
simple solution would be to append the above macro to the macro
 
12761
package's end-of-input macro using the @code{.am} request.
 
12762
@endDefreq
 
12763
 
 
12764
 
 
12765
@c =====================================================================
 
12766
 
 
12767
@node Diversions, Environments, Traps, gtroff Reference
 
12768
@section Diversions
 
12769
@cindex diversions
 
12770
 
 
12771
In @code{gtroff} it is possible to @dfn{divert} text into a named
 
12772
storage area.  Due to the similarity to defining macros it is sometimes
 
12773
said to be stored in a macro.  This is used for saving text for output
 
12774
at a later time, which is useful for keeping blocks of text on the same
 
12775
page, footnotes, tables of contents, and indices.
 
12776
 
 
12777
@cindex top-level diversion
 
12778
@cindex diversion, top-level
 
12779
For orthogonality it is said that @code{gtroff} is in the @dfn{top-level
 
12780
diversion} if no diversion is active (i.e., the data is diverted to the
 
12781
output device).
 
12782
 
 
12783
Although the following requests can be used to create diversions,
 
12784
simply using an undefined diversion will cause it to be defined as empty.
 
12785
@xref{Identifiers}.
 
12786
 
 
12787
@DefreqList {di, macro}
 
12788
@DefreqListEnd {da, macro}
 
12789
@cindex beginning diversion (@code{di})
 
12790
@cindex diversion, beginning (@code{di})
 
12791
@cindex ending diversion (@code{di})
 
12792
@cindex diversion, ending (@code{di})
 
12793
@cindex appending to a diversion (@code{da})
 
12794
@cindex diversion, appending (@code{da})
 
12795
Begin a diversion.  Like the @code{de} request, it takes an argument of
 
12796
a macro name to divert subsequent text into.  The @code{da} macro
 
12797
appends to an existing diversion.
 
12798
 
 
12799
@code{di} or @code{da} without an argument ends the diversion.
 
12800
 
 
12801
The current partially-filled line is included into the diversion.  See
 
12802
the @code{box} request below for an example.  Note that switching to
 
12803
another (empty) environment (with the @code{ev} request) avoids the
 
12804
inclusion of the current partially-filled line.
 
12805
@endDefreq
 
12806
 
 
12807
@DefreqList {box, macro}
 
12808
@DefreqListEnd {boxa, macro}
 
12809
Begin (or append to) a diversion like the @code{di} and @code{da}
 
12810
requests.  The difference is that @code{box} and @code{boxa} do not
 
12811
include a partially-filled line in the diversion.
 
12812
 
 
12813
Compare this:
 
12814
 
 
12815
@Example
 
12816
Before the box.
 
12817
.box xxx
 
12818
In the box.
 
12819
.br
 
12820
.box
 
12821
After the box.
 
12822
.br
 
12823
    @result{} Before the box.  After the box.
 
12824
.xxx
 
12825
    @result{} In the box.
 
12826
@endExample
 
12827
 
 
12828
@noindent
 
12829
with this:
 
12830
 
 
12831
@Example
 
12832
Before the diversion.
 
12833
.di yyy
 
12834
In the diversion.
 
12835
.br
 
12836
.di
 
12837
After the diversion.
 
12838
.br
 
12839
    @result{} After the diversion.
 
12840
.yyy
 
12841
    @result{} Before the diversion.  In the diversion.
 
12842
@endExample
 
12843
 
 
12844
@code{box} or @code{boxa} without an argument ends the diversion.
 
12845
@endDefreq
 
12846
 
 
12847
@DefregList {.z}
 
12848
@DefregListEnd {.d}
 
12849
@cindex @code{nl} register, and @code{.d}
 
12850
@cindex nested diversions
 
12851
@cindex diversion, nested
 
12852
@cindex diversion name register (@code{.z})
 
12853
@cindex vertical position in diversion register (@code{.d})
 
12854
@cindex position, vertical, in diversion, register (@code{.d})
 
12855
@cindex diversion, vertical position in, register (@code{.d})
 
12856
Diversions may be nested.  The read-only number register @code{.z}
 
12857
contains the name of the current diversion (this is a string-valued
 
12858
register).  The read-only number register @code{.d} contains the current
 
12859
vertical place in the diversion.  If not in a diversion it is the same
 
12860
as register @code{nl}.
 
12861
@endDefreg
 
12862
 
 
12863
@Defreg {.h}
 
12864
@cindex high-water mark register (@code{.h})
 
12865
@cindex mark, high-water, register (@code{.h})
 
12866
@cindex position of lowest text line (@code{.h})
 
12867
@cindex text line, position of lowest (@code{.h})
 
12868
The @dfn{high-water mark} on the current page.  It corresponds to the
 
12869
text baseline of the lowest line on the page.  This is a read-only
 
12870
register.
 
12871
 
 
12872
@Example
 
12873
.tm .h==\n[.h], nl==\n[nl]
 
12874
    @result{} .h==0, nl==-1
 
12875
This is a test.
 
12876
.br
 
12877
.sp 2
 
12878
.tm .h==\n[.h], nl==\n[nl]
 
12879
    @result{} .h==40, nl==120
 
12880
@endExample
 
12881
 
 
12882
@cindex @code{.h} register, difference to @code{nl}
 
12883
@cindex @code{nl} register, difference to @code{.h}
 
12884
@noindent
 
12885
As can be seen in the previous example, empty lines are not considered
 
12886
in the return value of the @code{.h} register.
 
12887
@endDefreg
 
12888
 
 
12889
@DefregList {dn}
 
12890
@DefregListEnd {dl}
 
12891
@cindex @code{dn} register, and @code{da} (@code{boxa})
 
12892
@cindex @code{dl} register, and @code{da} (@code{boxa})
 
12893
@cindex @code{da} request, and @code{dn} (@code{dl})
 
12894
@cindex @code{boxa} request, and @code{dn} (@code{dl})
 
12895
After completing a diversion, the read-write number registers @code{dn}
 
12896
and @code{dl} contain the vertical and horizontal size of the diversion.
 
12897
Note that only the just processed lines are counted: For the computation
 
12898
of @code{dn} and @code{dl}, the requests @code{da} and @code{boxa} are
 
12899
handled as if @code{di} and @code{box} had been used -- lines which have
 
12900
been already stored in a macro are not taken into account.
 
12901
 
 
12902
@Example
 
12903
.\" Center text both horizontally & vertically
 
12904
.
 
12905
.\" Enclose macro definitions in .eo and .ec
 
12906
.\" to avoid the doubling of the backslash
 
12907
.eo
 
12908
.\" macro .(c starts centering mode
 
12909
.de (c
 
12910
.  br
 
12911
.  ev (c
 
12912
.  evc 0
 
12913
.  in 0
 
12914
.  nf
 
12915
.  di @@c
 
12916
..
 
12917
@endExample
 
12918
@Example
 
12919
.\" macro .)c terminates centering mode
 
12920
.de )c
 
12921
.  br
 
12922
.  ev
 
12923
.  di
 
12924
.  nr @@s (((\n[.t]u - \n[dn]u) / 2u) - 1v)
 
12925
.  sp \n[@@s]u
 
12926
.  ce 1000
 
12927
.  @@c
 
12928
.  ce 0
 
12929
.  sp \n[@@s]u
 
12930
.  br
 
12931
.  fi
 
12932
.  rr @@s
 
12933
.  rm @@s
 
12934
.  rm @@c
 
12935
..
 
12936
.\" End of macro definitions, restore escape mechanism
 
12937
.ec
 
12938
@endExample
 
12939
@endDefreg
 
12940
 
 
12941
@DefescList {\\!, , , }
 
12942
@DefescListEnd {\\?, , anything, \\?}
 
12943
@cindex transparent output (@code{\!}, @code{\?})
 
12944
@cindex output, transparent (@code{\!}, @code{\?})
 
12945
Prevent requests, macros, and escapes from being interpreted when read
 
12946
into a diversion.  Both escapes take the given text and
 
12947
@dfn{transparently} embed it into the diversion.  This is useful for
 
12948
macros which shouldn't be invoked until the diverted text is actually
 
12949
output.
 
12950
 
 
12951
The @code{\!} escape transparently embeds text up to and including the
 
12952
end of the line.  The @code{\?} escape transparently embeds text until
 
12953
the next occurrence of the @code{\?} escape.  Example:
 
12954
 
 
12955
@Example
 
12956
\?@var{anything}\?
 
12957
@endExample
 
12958
 
 
12959
@cindex @code{\?}, and copy-in mode
 
12960
@cindex copy-in mode, and @code{\?}
 
12961
@cindex mode, copy-in, and @code{\?}
 
12962
@cindex @code{\!}, and copy-in mode
 
12963
@cindex copy-in mode, and @code{\!}
 
12964
@cindex mode, copy-in, and @code{\!}
 
12965
@noindent
 
12966
@var{anything} may not contain newlines; use @code{\!}  to embed
 
12967
newlines in a diversion.  The escape sequence @code{\?} is also
 
12968
recognized in copy mode and turned into a single internal code; it is
 
12969
this code that terminates @var{anything}.  Thus the following example
 
12970
prints@tie{}4.
 
12971
 
 
12972
@Example
 
12973
.nr x 1
 
12974
.nf
 
12975
.di d
 
12976
\?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
 
12977
.di
 
12978
.nr x 2
 
12979
.di e
 
12980
.d
 
12981
.di
 
12982
.nr x 3
 
12983
.di f
 
12984
.e
 
12985
.di
 
12986
.nr x 4
 
12987
.f
 
12988
@endExample
 
12989
 
 
12990
Both escapes read the data in copy mode.
 
12991
 
 
12992
@cindex @code{\!}, in top-level diversion
 
12993
@cindex top-level diversion, and @code{\!}
 
12994
@cindex diversion, top-level, and @code{\!}
 
12995
If @code{\!} is used in the top-level diversion, its argument is
 
12996
directly embedded into the @code{gtroff} intermediate output.  This can
 
12997
be used for example to control a postprocessor which processes the data
 
12998
before it is sent to the device driver.
 
12999
 
 
13000
@cindex @code{\?}, in top-level diversion
 
13001
@cindex top-level diversion, and @code{\?}
 
13002
@cindex diversion, top-level, and @code{\?}
 
13003
The @code{\?} escape used in the top-level diversion produces no output
 
13004
at all; its argument is simply ignored.
 
13005
@endDefesc
 
13006
 
 
13007
@cindex @code{\!}, and @code{output} request
 
13008
@cindex @code{output} request, and @code{\!}
 
13009
@cindex @code{output} request, and copy-in mode
 
13010
@cindex copy-in mode, and @code{output} request
 
13011
@cindex mode, copy-in, and @code{output} request
 
13012
@Defreq {output, string}
 
13013
Emit @var{string} directly to the @code{gtroff} intermediate output
 
13014
(subject to copy mode interpretation); this is similar to @code{\!} used
 
13015
at the top level.  An initial double quote in @var{string} is stripped
 
13016
off to allow initial blanks.
 
13017
 
 
13018
This request can't be used before the first page has started -- if you
 
13019
get an error, simply insert @code{.br} before the @code{output} request.
 
13020
 
 
13021
Without argument, @code{output} is ignored.
 
13022
 
 
13023
Use with caution!  It is normally only needed for mark-up used by a
 
13024
postprocessor which does something with the output before sending it to
 
13025
the output device, filtering out @var{string} again.
 
13026
@endDefreq
 
13027
 
 
13028
@Defreq {asciify, div}
 
13029
@cindex unformatting diversions (@code{asciify})
 
13030
@cindex diversion, unformatting (@code{asciify})
 
13031
@cindex @code{trin} request, and @code{asciify}
 
13032
@dfn{Unformat} the diversion specified by @var{div} in such a way that
 
13033
@acronym{ASCII} characters, characters translated with the @code{trin}
 
13034
request, space characters, and some escape sequences that were formatted
 
13035
and diverted are treated like ordinary input characters when the
 
13036
diversion is reread.  It can be also used for gross hacks; for example,
 
13037
the following sets register@tie{}@code{n} to@tie{}1.
 
13038
 
 
13039
@Example
 
13040
.tr @@.
 
13041
.di x
 
13042
@@nr n 1
 
13043
.br
 
13044
.di
 
13045
.tr @@@@
 
13046
.asciify x
 
13047
.x
 
13048
@endExample
 
13049
 
 
13050
Note that @code{asciify} cannot return all items in a diversion back
 
13051
to their source equivalent, nodes such as @code{\N[...]} will still
 
13052
remain as nodes, so the result cannot be guaranteed to be a pure string.
 
13053
 
 
13054
@xref{Copy-in Mode}.
 
13055
@endDefreq
 
13056
 
 
13057
@Defreq {unformat, div}
 
13058
Like @code{asciify}, unformat the specified diversion.  However,
 
13059
@code{unformat} only unformats spaces and tabs between words.
 
13060
Unformatted tabs are treated as input tokens, and spaces are stretchable
 
13061
again.
 
13062
 
 
13063
The vertical size of lines is not preserved; glyph information (font,
 
13064
font size, space width, etc.)@: is retained.
 
13065
@endDefreq
 
13066
 
 
13067
 
 
13068
@c =====================================================================
 
13069
 
 
13070
@node Environments, Suppressing output, Diversions, gtroff Reference
 
13071
@section Environments
 
13072
@cindex environments
 
13073
 
 
13074
It happens frequently that some text should be printed in a certain
 
13075
format regardless of what may be in effect at the time, for example, in
 
13076
a trap invoked macro to print headers and footers.  To solve this
 
13077
@code{gtroff} processes text in @dfn{environments}.  An environment
 
13078
contains most of the parameters that control text processing.  It is
 
13079
possible to switch amongst these environments; by default @code{gtroff}
 
13080
processes text in environment@tie{}0.  The following is the information
 
13081
kept in an environment.
 
13082
 
 
13083
@itemize @bullet
 
13084
@item
 
13085
font parameters (size, family, style, glyph height and slant, space and
 
13086
sentence space size)
 
13087
 
 
13088
@item
 
13089
page parameters (line length, title length, vertical spacing, line
 
13090
spacing, indentation, line numbering, centering, right-justifying,
 
13091
underlining, hyphenation data)
 
13092
 
 
13093
@item
 
13094
fill and adjust mode
 
13095
 
 
13096
@item
 
13097
tab stops, tab and leader characters, escape character, no-break and
 
13098
hyphen indicators, margin character data
 
13099
 
 
13100
@item
 
13101
partially collected lines
 
13102
 
 
13103
@item
 
13104
input traps
 
13105
 
 
13106
@item
 
13107
drawing and fill colours
 
13108
@end itemize
 
13109
 
 
13110
These environments may be given arbitrary names (see @ref{Identifiers},
 
13111
for more info).  Old versions of @code{troff} only had environments
 
13112
named @samp{0}, @samp{1}, and @samp{2}.
 
13113
 
 
13114
@DefreqList {ev, [@Var{env}]}
 
13115
@DefregListEnd {.ev}
 
13116
@cindex switching environments (@code{ev})
 
13117
@cindex environment, switching (@code{ev})
 
13118
@cindex environment number/name register (@code{.ev})
 
13119
Switch to another environment.  The argument @var{env} is the name of
 
13120
the environment to switch to.  With no argument, @code{gtroff} switches
 
13121
back to the previous environment.  There is no limit on the number of
 
13122
named environments; they are created the first time that they are
 
13123
referenced.  The @code{.ev} read-only register contains the name or
 
13124
number of the current environment.  This is a string-valued register.
 
13125
 
 
13126
Note that a call to @code{ev} (with argument) pushes the previously
 
13127
active environment onto a stack.  If, say, environments @samp{foo},
 
13128
@samp{bar}, and @samp{zap} are called (in that order), the first
 
13129
@code{ev} request without parameter switches back to environment
 
13130
@samp{bar} (which is popped off the stack), and a second call switches
 
13131
back to environment @samp{foo}.
 
13132
 
 
13133
Here is an example:
 
13134
 
 
13135
@Example
 
13136
.ev footnote-env
 
13137
.fam N
 
13138
.ps 6
 
13139
.vs 8
 
13140
.ll -.5i
 
13141
.ev
 
13142
 
 
13143
...
 
13144
 
 
13145
.ev footnote-env
 
13146
\(dg Note the large, friendly letters.
 
13147
.ev
 
13148
@endExample
 
13149
@endDefreq
 
13150
 
 
13151
@Defreq {evc, env}
 
13152
@cindex copying environment (@code{evc})
 
13153
@cindex environment, copying (@code{evc})
 
13154
Copy the environment @var{env} into the current environment.
 
13155
 
 
13156
The following environment data is not copied:
 
13157
 
 
13158
@itemize @bullet
 
13159
@item
 
13160
Partially filled lines.
 
13161
 
 
13162
@item
 
13163
The status whether the previous line was interrupted.
 
13164
 
 
13165
@item
 
13166
The number of lines still to center, or to right-justify, or to
 
13167
underline (with or without underlined spaces); they are set to zero.
 
13168
 
 
13169
@item
 
13170
The status whether a temporary indentation is active.
 
13171
 
 
13172
@item
 
13173
Input traps and its associated data.
 
13174
 
 
13175
@item
 
13176
Line numbering mode is disabled; it can be reactivated with @w{@samp{.nm
 
13177
+0}}.
 
13178
 
 
13179
@item
 
13180
The number of consecutive hyphenated lines (set to zero).
 
13181
@end itemize
 
13182
@endDefreq
 
13183
 
 
13184
@DefregList {.w}
 
13185
@DefregItem {.cht}
 
13186
@DefregItem {.cdp}
 
13187
@DefregListEnd {.csk}
 
13188
@cindex environment, dimensions of last glyph (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
 
13189
@cindex width, of last glyph (@code{.w})
 
13190
@cindex height, of last glyph (@code{.cht})
 
13191
@cindex depth, of last glyph (@code{.cdp})
 
13192
@cindex skew, of last glyph (@code{.csk})
 
13193
@cindex last glyph, dimensions (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
 
13194
@cindex glyph, last, dimensions (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
 
13195
The @code{\n[.w]} register contains the width of the last glyph added to
 
13196
the current environment.
 
13197
 
 
13198
The @code{\n[.cht]} register contains the height of the last glyph added
 
13199
to the current environment.
 
13200
 
 
13201
The @code{\n[.cdp]} register contains the depth of the last glyph added
 
13202
to the current environment.  It is positive for glyphs extending below
 
13203
the baseline.
 
13204
 
 
13205
The @code{\n[.csk]} register contains the @dfn{skew} (how far to the
 
13206
right of the glyph's center that @code{gtroff} should place an accent)
 
13207
of the last glyph added to the current environment.
 
13208
@endDefreg
 
13209
 
 
13210
@Defreg {.n}
 
13211
@cindex environment, previous line length (@code{.n})
 
13212
@cindex line length, previous (@code{.n})
 
13213
@cindex length of previous line (@code{.n})
 
13214
@cindex previous line length (@code{.n})
 
13215
The @code{\n[.n]} register contains the length of the previous output
 
13216
line in the current environment.
 
13217
@endDefreg
 
13218
 
 
13219
 
 
13220
@c =====================================================================
 
13221
 
 
13222
@node Suppressing output, Colors, Environments, gtroff Reference
 
13223
@section Suppressing output
 
13224
 
 
13225
@Defesc {\\O, , num, }
 
13226
@cindex suppressing output (@code{\O})
 
13227
@cindex output, suppressing (@code{\O})
 
13228
Disable or enable output depending on the value of @var{num}:
 
13229
 
 
13230
@table @samp
 
13231
@item \O0
 
13232
Disable any glyphs from being emitted to the device driver, provided
 
13233
that the escape occurs at the outer level (see @code{\O[3]} and
 
13234
@code{\O[4]}).  Motion is not suppressed so effectively @code{\O[0]}
 
13235
means @emph{pen up}.
 
13236
 
 
13237
@item \O1
 
13238
Enable output of glyphs, provided that the escape occurs at the outer
 
13239
level.
 
13240
@end table
 
13241
 
 
13242
@vindex opminx
 
13243
@vindex opminy
 
13244
@vindex opmaxx
 
13245
@vindex opmaxy
 
13246
@code{\O0} and @code{\O1} also reset the four registers @samp{opminx},
 
13247
@samp{opminy}, @samp{opmaxx}, and @samp{opmaxy} to @minus{}1.
 
13248
@xref{Register Index}.  These four registers mark the top left and
 
13249
bottom right hand corners of a box which encompasses all written glyphs.
 
13250
 
 
13251
For example the input text:
 
13252
 
 
13253
@Example
 
13254
Hello \O[0]world \O[1]this is a test.
 
13255
@endExample
 
13256
 
 
13257
@noindent
 
13258
produces the following output:
 
13259
 
 
13260
@Example
 
13261
Hello       this is a test.
 
13262
@endExample
 
13263
 
 
13264
@table @samp
 
13265
@item \O2
 
13266
Provided that the escape occurs at the outer level, enable output of
 
13267
glyphs and also write out to @code{stderr} the page number and four
 
13268
registers encompassing the glyphs previously written since the last call
 
13269
to @code{\O}.
 
13270
 
 
13271
@item \O3
 
13272
Begin a nesting level.  At start-up, @code{gtroff} is at outer level.
 
13273
The current level is contained within the read-only register @code{.O}.
 
13274
@xref{Built-in Registers}.
 
13275
 
 
13276
@item \O4
 
13277
End a nesting level.  The current level is contained within the
 
13278
read-only register @code{.O}.  @xref{Built-in Registers}.
 
13279
 
 
13280
@item \O[5@var{P}@var{filename}]
 
13281
This escape is @code{grohtml} specific.  Provided that this escape
 
13282
occurs at the outer nesting level write the @code{filename} to
 
13283
@code{stderr}.  The position of the image, @var{P}, must be specified
 
13284
and must be one of @code{l}, @code{r}, @code{c}, or@tie{}@code{i} (left,
 
13285
right, centered, inline).  @var{filename} is associated with the
 
13286
production of the next inline image.
 
13287
@end table
 
13288
@endDefesc
 
13289
 
 
13290
 
 
13291
@c =====================================================================
 
13292
 
 
13293
@node Colors, I/O, Suppressing output, gtroff Reference
 
13294
@section Colors
 
13295
@cindex colors
 
13296
 
 
13297
@DefreqList {color, [@Var{n}]}
 
13298
@DefregListEnd {.color}
 
13299
If @var{n} is missing or non-zero, activate colors (this is the
 
13300
default); otherwise, turn it off.
 
13301
 
 
13302
The read-only number register @code{.color} is@tie{}1 if colors are
 
13303
active, 0@tie{}otherwise.
 
13304
 
 
13305
Internally, @code{color} sets a global flag; it does not produce a
 
13306
token.  Similar to the @code{cp} request, you should use it at the
 
13307
beginning of your document to control color output.
 
13308
 
 
13309
Colors can be also turned off with the @option{-c} command line option.
 
13310
@endDefreq
 
13311
 
 
13312
@Defreq {defcolor, ident scheme color_components}
 
13313
Define color with name @var{ident}.  @var{scheme} can be one of the
 
13314
following values: @code{rgb} (three components), @code{cmy} (three
 
13315
components), @code{cmyk} (four components), and @code{gray} or
 
13316
@code{grey} (one component).
 
13317
 
 
13318
@cindex default color
 
13319
@cindex color, default
 
13320
Color components can be given either as a hexadecimal string or as
 
13321
positive decimal integers in the range 0--65535.  A hexadecimal string
 
13322
contains all color components concatenated.  It must start with either
 
13323
@code{#} or @code{##}; the former specifies hex values in the range
 
13324
0--255 (which are internally multiplied by@tie{}257), the latter in the
 
13325
range 0--65535.  Examples: @code{#FFC0CB} (pink), @code{##ffff0000ffff}
 
13326
(magenta).  The default color name @c{default} can't be redefined; its
 
13327
value is device-specific (usually black).  It is possible that the
 
13328
default color for @code{\m} and @code{\M} is not identical.
 
13329
 
 
13330
@cindex @code{f} unit, and colors
 
13331
@cindex unit, @code{f}, and colors
 
13332
A new scaling indicator@tie{}@code{f} has been introduced which
 
13333
multiplies its value by 65536; this makes it convenient to specify color
 
13334
components as fractions in the range 0 to@tie{}1 (1f equals 65536u).
 
13335
Example:
 
13336
 
 
13337
@Example
 
13338
.defcolor darkgreen rgb 0.1f 0.5f 0.2f
 
13339
@endExample
 
13340
 
 
13341
Note that @code{f} is the default scaling indicator for the
 
13342
@code{defcolor} request, thus the above statement is equivalent to
 
13343
 
 
13344
@Example
 
13345
.defcolor darkgreen rgb 0.1 0.5 0.2
 
13346
@endExample
 
13347
@endDefreq
 
13348
 
 
13349
@DefreqList {gcolor, [@Var{color}]}
 
13350
@DefescItem {\\m, , c, }
 
13351
@DefescItem {\\m, @Lparen{}, co, }
 
13352
@DefescItem {\\m, @Lbrack{}, color, @Rbrack{}}
 
13353
@DefregListEnd {.m}
 
13354
Set (glyph) drawing color.  The following examples show how to turn the
 
13355
next four words red.
 
13356
 
 
13357
@Example
 
13358
.gcolor red
 
13359
these are in red
 
13360
.gcolor
 
13361
and these words are in black.
 
13362
@endExample
 
13363
 
 
13364
@Example
 
13365
\m[red]these are in red\m[] and these words are in black.
 
13366
@endExample
 
13367
 
 
13368
The escape @code{\m[]} returns to the previous color, as does a call to
 
13369
@code{gcolor} without an argument.
 
13370
 
 
13371
@cindex drawing color name register (@code{.m})
 
13372
@cindex name, drawing color, register (@code{.m})
 
13373
@cindex color name, drawing, register (@code{.m})
 
13374
The name of the current drawing color is available in the read-only,
 
13375
string-valued number register @samp{.m}.
 
13376
 
 
13377
The drawing color is associated with the current environment
 
13378
(@pxref{Environments}).
 
13379
 
 
13380
Note that @code{\m} doesn't produce an input token in @code{gtroff}.  As
 
13381
a consequence, it can be used in requests like @code{mc} (which expects
 
13382
a single character as an argument) to change the color on the fly:
 
13383
 
 
13384
@Example
 
13385
.mc \m[red]x\m[]
 
13386
@endExample
 
13387
@endDefesc
 
13388
 
 
13389
@DefreqList {fcolor, [@Var{color}]}
 
13390
@DefescItem {\\M, , c, }
 
13391
@DefescItem {\\M, @Lparen{}, co, }
 
13392
@DefescItem {\\M, @Lbrack{}, color, @Rbrack{}}
 
13393
@DefregListEnd {.M}
 
13394
Set fill (background) color for filled objects drawn with the
 
13395
@code{\D'@dots{}'} commands.
 
13396
 
 
13397
A red ellipse can be created with the following code:
 
13398
 
 
13399
@Example
 
13400
\M[red]\h'0.5i'\D'E 2i 1i'\M[]
 
13401
@endExample
 
13402
 
 
13403
The escape @code{\M[]} returns to the previous fill color, as does a
 
13404
call to @code{fcolor} without an argument.
 
13405
 
 
13406
@cindex background color name register (@code{.M})
 
13407
@cindex name, background color, register (@code{.M})
 
13408
@cindex color name, background, register (@code{.M})
 
13409
@cindex fill color name register (@code{.M})
 
13410
@cindex name, fill color, register (@code{.M})
 
13411
@cindex color name, fill, register (@code{.M})
 
13412
The name of the current fill (background) color is available in the
 
13413
read-only, string-valued number register @samp{.M}.
 
13414
 
 
13415
The fill color is associated with the current environment
 
13416
(@pxref{Environments}).
 
13417
 
 
13418
Note that @code{\M} doesn't produce an input token in @code{gtroff}.
 
13419
@endDefesc
 
13420
 
 
13421
 
 
13422
@c =====================================================================
 
13423
 
 
13424
@node I/O, Postprocessor Access, Colors, gtroff Reference
 
13425
@section I/O
 
13426
@cindex i/o
 
13427
@cindex input and output requests
 
13428
@cindex requests for input and output
 
13429
@cindex output and input requests
 
13430
 
 
13431
@code{gtroff} has several requests for including files:
 
13432
 
 
13433
@Defreq {so, file}
 
13434
@cindex including a file (@code{so})
 
13435
@cindex file, inclusion (@code{so})
 
13436
Read in the specified @var{file} and includes it in place of the
 
13437
@code{so} request.  This is quite useful for large documents, e.g.@:
 
13438
keeping each chapter in a separate file.  @xref{gsoelim}, for more
 
13439
information.
 
13440
 
 
13441
Since @code{gtroff} replaces the @code{so} request with the contents of
 
13442
@code{file}, it makes a difference whether the data is terminated with a
 
13443
newline or not: Assuming that file @file{xxx} contains the word
 
13444
@samp{foo} without a final newline, this
 
13445
 
 
13446
@Example
 
13447
This is
 
13448
.so xxx
 
13449
bar
 
13450
@endExample
 
13451
 
 
13452
@noindent
 
13453
yields @samp{This is foobar}.
 
13454
 
 
13455
The search path for @var{file} can be controlled with the @option{-I}
 
13456
command line option.
 
13457
@endDefreq
 
13458
 
 
13459
@Defreq {pso, command}
 
13460
Read the standard output from the specified @var{command} and includes
 
13461
it in place of the @code{pso} request.
 
13462
 
 
13463
@cindex safer mode
 
13464
@cindex mode, safer
 
13465
@cindex unsafe mode
 
13466
@cindex mode, unsafe
 
13467
This request causes an error if used in safer mode (which is the
 
13468
default).  Use @code{groff}'s or @code{troff}'s @option{-U} option to
 
13469
activate unsafe mode.
 
13470
 
 
13471
The comment regarding a final newline for the @code{so} request is valid
 
13472
for @code{pso} also.
 
13473
@endDefreq
 
13474
 
 
13475
@Defreq {mso, file}
 
13476
Identical to the @code{so} request except that @code{gtroff} searches
 
13477
for the specified @var{file} in the same directories as macro files for
 
13478
the the @option{-m} command line option.  If the file name to be
 
13479
included has the form @file{@var{name}.tmac} and it isn't found,
 
13480
@code{mso} tries to include @file{tmac.@var{name}} and vice versa.
 
13481
If the file does not exist, a warning of type @samp{file} is emitted.
 
13482
@xref{Debugging}, for information about warnings.
 
13483
@endDefreq
 
13484
 
 
13485
@DefreqList {trf, file}
 
13486
@DefreqListEnd {cf, file}
 
13487
@cindex transparent output (@code{cf}, @code{trf})
 
13488
@cindex output, transparent (@code{cf}, @code{trf})
 
13489
@cindex @code{cf} request, and copy-in mode
 
13490
@cindex copy-in mode, and @code{cf} request
 
13491
@cindex mode, copy-in, and @code{cf} request
 
13492
@cindex @code{trf} request, and copy-in mode
 
13493
@cindex copy-in mode, and @code{trf} request
 
13494
@cindex mode, copy-in, and @code{trf} request
 
13495
Transparently output the contents of @var{file}.  Each line is output as
 
13496
if it were preceded by @code{\!}; however, the lines are @emph{not}
 
13497
subject to copy mode interpretation.  If the file does not end with a
 
13498
newline, then a newline is added (@code{trf} only).  For example, to
 
13499
define a macro@tie{}@code{x} containing the contents of
 
13500
file@tie{}@file{f}, use
 
13501
 
 
13502
@Example
 
13503
.ev 1
 
13504
.di x
 
13505
.trf f
 
13506
.di
 
13507
.ev
 
13508
@endExample
 
13509
 
 
13510
@noindent
 
13511
The calls to @code{ev} prevent that the current partial input line
 
13512
becomes part of the diversion.
 
13513
 
 
13514
Both @code{trf} and @code{cf}, when used in a diversion, embeds an
 
13515
object in the diversion which, when reread, causes the contents of
 
13516
@var{file} to be transparently copied through to the output.  In
 
13517
@acronym{UNIX} @code{troff}, the contents of @var{file} is immediately
 
13518
copied through to the output regardless of whether there is a current
 
13519
diversion; this behaviour is so anomalous that it must be considered a
 
13520
bug.
 
13521
 
 
13522
@cindex @code{trf} request, and invalid characters
 
13523
@cindex characters, invalid for @code{trf} request
 
13524
@cindex invalid characters for @code{trf} request
 
13525
 
 
13526
While @code{cf} copies the contents of @var{file} completely
 
13527
unprocessed, @code{trf} disallows characters such as NUL that are not
 
13528
valid @code{gtroff} input characters (@pxref{Identifiers}).
 
13529
 
 
13530
For @code{cf}, within a diversion, `completely unprocessed' means that
 
13531
each line of a file to be inserted is handled as if it were preceded by
 
13532
@code{\!\\!}.
 
13533
 
 
13534
Both requests cause a line break.
 
13535
@endDefreq
 
13536
 
 
13537
@Defreq {nx, [@Var{file}]}
 
13538
@cindex processing next file (@code{nx})
 
13539
@cindex file, processing next (@code{nx})
 
13540
@cindex next file, processing (@code{nx})
 
13541
Force @code{gtroff} to continue processing of the file specified as an
 
13542
argument.  If no argument is given, immediately jump to the end of file.
 
13543
@endDefreq
 
13544
 
 
13545
@Defreq {rd, [@Var{prompt} [@Var{arg1} @Var{arg2} @dots{}]]}
 
13546
@cindex reading from standard input (@code{rd})
 
13547
@cindex standard input, reading from (@code{rd})
 
13548
@cindex input, standard, reading from (@code{rd})
 
13549
Read from standard input, and include what is read as though it were
 
13550
part of the input file.  Text is read until a blank line is encountered.
 
13551
 
 
13552
If standard input is a TTY input device (keyboard), write @var{prompt}
 
13553
to standard error, followed by a colon (or send BEL for a beep if no
 
13554
argument is given).
 
13555
 
 
13556
Arguments after @var{prompt} are available for the input.  For example,
 
13557
the line
 
13558
 
 
13559
@Example
 
13560
.rd data foo bar
 
13561
@endExample
 
13562
 
 
13563
with the input @w{@samp{This is \$2.}} prints
 
13564
 
 
13565
@Example
 
13566
This is bar.
 
13567
@endExample
 
13568
@endDefreq
 
13569
 
 
13570
@cindex form letters
 
13571
@cindex letters, form
 
13572
Using the @code{nx} and @code{rd} requests, it is easy to set up form
 
13573
letters.  The form letter template is constructed like this, putting the
 
13574
following lines into a file called @file{repeat.let}:
 
13575
 
 
13576
@Example
 
13577
.ce
 
13578
\*(td
 
13579
.sp 2
 
13580
.nf
 
13581
.rd
 
13582
.sp
 
13583
.rd
 
13584
.fi
 
13585
Body of letter.
 
13586
.bp
 
13587
.nx repeat.let
 
13588
@endExample
 
13589
 
 
13590
@cindex @code{ex} request, used with @code{nx} and @code{rd}
 
13591
@noindent
 
13592
When this is run, a file containing the following lines should be
 
13593
redirected in.  Note that requests included in this file are executed as
 
13594
though they were part of the form letter.  The last block of input is
 
13595
the @code{ex} request which tells @code{groff} to stop processing.  If
 
13596
this was not there, @code{groff} would not know when to stop.
 
13597
 
 
13598
@Example
 
13599
Trent A. Fisher
 
13600
708 NW 19th Av., #202
 
13601
Portland, OR  97209
 
13602
 
 
13603
Dear Trent,
 
13604
 
 
13605
Len Adollar
 
13606
4315 Sierra Vista
 
13607
San Diego, CA  92103
 
13608
 
 
13609
Dear Mr. Adollar,
 
13610
 
 
13611
.ex
 
13612
@endExample
 
13613
 
 
13614
@Defreq {pi, pipe}
 
13615
Pipe the output of @code{gtroff} to the shell command(s) specified by
 
13616
@var{pipe}.  This request must occur before @code{gtroff} has a chance
 
13617
to print anything.
 
13618
 
 
13619
@cindex safer mode
 
13620
@cindex mode, safer
 
13621
@cindex unsafe mode
 
13622
@cindex mode, unsafe
 
13623
@code{pi} causes an error if used in safer mode (which is the default).
 
13624
Use @code{groff}'s or @code{troff}'s @option{-U} option to activate
 
13625
unsafe mode.
 
13626
 
 
13627
Multiple calls to @code{pi} are allowed, acting as a chain.  For
 
13628
example,
 
13629
 
 
13630
@Example
 
13631
.pi foo
 
13632
.pi bar
 
13633
...
 
13634
@endExample
 
13635
 
 
13636
is the same as @w{@samp{.pi foo | bar}}.
 
13637
 
 
13638
@cindex @code{groff}, and @code{pi} request
 
13639
@cindex @code{pi} request, and @code{groff}
 
13640
Note that the intermediate output format of @code{gtroff} is piped to
 
13641
the specified commands.  Consequently, calling @code{groff} without the
 
13642
@option{-Z} option normally causes a fatal error.
 
13643
@endDefreq
 
13644
 
 
13645
@DefreqList {sy, cmds}
 
13646
@DefregListEnd {systat}
 
13647
Execute the shell command(s) specified by @var{cmds}.  The output is not
 
13648
saved anyplace, so it is up to the user to do so.
 
13649
 
 
13650
@cindex safer mode
 
13651
@cindex mode, safer
 
13652
@cindex unsafe mode
 
13653
@cindex mode, unsafe
 
13654
This request causes an error if used in safer mode (which is the
 
13655
default).  Use @code{groff}'s or @code{troff}'s @option{-U} option to
 
13656
activate unsafe mode.
 
13657
 
 
13658
For example, the following code fragment introduces the current time
 
13659
into a document:
 
13660
 
 
13661
@cindex time, current
 
13662
@cindex current time
 
13663
@pindex perl
 
13664
@Example
 
13665
.sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
 
13666
             (localtime(time))[2,1,0]' > /tmp/x\n[$$]
 
13667
.so /tmp/x\n[$$]
 
13668
.sy rm /tmp/x\n[$$]
 
13669
\nH:\nM:\nS
 
13670
@endExample
 
13671
 
 
13672
@noindent
 
13673
Note that this works by having the @code{perl} script (run by @code{sy})
 
13674
print out the @code{nr} requests which set the number registers
 
13675
@code{H}, @code{M}, and @code{S}, and then reads those commands in with
 
13676
the @code{so} request.
 
13677
 
 
13678
For most practical purposes, the number registers @code{seconds},
 
13679
@code{minutes}, and @code{hours} which are initialized at start-up of
 
13680
@code{gtroff} should be sufficient.  Use the @code{af} request to get a
 
13681
formatted output:
 
13682
 
 
13683
@Example
 
13684
.af hours 00
 
13685
.af minutes 00
 
13686
.af seconds 00
 
13687
\n[hours]:\n[minutes]:\n[seconds]
 
13688
@endExample
 
13689
 
 
13690
@cindex @code{system()} return value register (@code{systat})
 
13691
The @code{systat} read-write number register contains the return value
 
13692
of the @code{system()} function executed by the last @code{sy} request.
 
13693
@endDefreq
 
13694
 
 
13695
@DefreqList {open, stream file}
 
13696
@DefreqListEnd {opena, stream file}
 
13697
@cindex opening file (@code{open})
 
13698
@cindex file, opening (@code{open})
 
13699
@cindex appending to a file (@code{opena})
 
13700
@cindex file, appending to (@code{opena})
 
13701
Open the specified @var{file} for writing and associates the specified
 
13702
@var{stream} with it.
 
13703
 
 
13704
The @code{opena} request is like @code{open}, but if the file exists,
 
13705
append to it instead of truncating it.
 
13706
 
 
13707
@cindex safer mode
 
13708
@cindex mode, safer
 
13709
@cindex unsafe mode
 
13710
@cindex mode, unsafe
 
13711
Both @code{open} and @code{opena} cause an error if used in safer mode
 
13712
(which is the default).  Use @code{groff}'s or @code{troff}'s
 
13713
@option{-U} option to activate unsafe mode.
 
13714
@endDefreq
 
13715
 
 
13716
@DefreqList {write, stream data}
 
13717
@DefreqListEnd {writec, stream data}
 
13718
@cindex copy-in mode, and @code{write} request
 
13719
@cindex @code{write} request, and copy-in mode
 
13720
@cindex mode, copy-in, and @code{write} request
 
13721
@cindex copy-in mode, and @code{writec} request
 
13722
@cindex @code{writec} request, and copy-in mode
 
13723
@cindex mode, copy-in, and @code{writec} request
 
13724
@cindex writing to file (@code{write}, @code{writec})
 
13725
@cindex file, writing to (@code{write}, @code{writec})
 
13726
Write to the file associated with the specified @var{stream}.  The
 
13727
stream must previously have been the subject of an open request.  The
 
13728
remainder of the line is interpreted as the @code{ds} request reads its
 
13729
second argument: A leading @samp{"} is stripped, and it is read in
 
13730
copy-in mode.
 
13731
 
 
13732
The @code{writec} request is like @code{write}, but only @code{write}
 
13733
appends a newline to the data.
 
13734
@endDefreq
 
13735
 
 
13736
@Defreq {writem, stream xx}
 
13737
@cindex @code{asciify} request, and @code{writem}
 
13738
Write the contents of the macro or string @var{xx} to the file
 
13739
associated with the specified @var{stream}.
 
13740
 
 
13741
@cindex @code{writem} request, and copy-in mode
 
13742
@cindex copy-in mode, and @code{writem} request
 
13743
@cindex mode, copy-in, and @code{writem} request
 
13744
@var{xx} is read in copy mode, i.e., already formatted elements are
 
13745
ignored.  Consequently, diversions must be unformatted with the
 
13746
@code{asciify} request before calling @code{writem}.  Usually, this
 
13747
means a loss of information.
 
13748
@endDefreq
 
13749
 
 
13750
@Defreq {close, stream}
 
13751
@cindex closing file (@code{close})
 
13752
@cindex file, closing (@code{close})
 
13753
Close the specified @var{stream}; the stream is no longer an acceptable
 
13754
argument to the @code{write} request.
 
13755
 
 
13756
Here a simple macro to write an index entry.
 
13757
 
 
13758
@Example
 
13759
.open idx test.idx
 
13760
.
 
13761
.de IX
 
13762
.  write idx \\n[%] \\$*
 
13763
..
 
13764
.
 
13765
.IX test entry
 
13766
.
 
13767
.close idx
 
13768
@endExample
 
13769
@endDefreq
 
13770
 
 
13771
@DefescList {\\V, , e, }
 
13772
@DefescItem {\\V, @Lparen{}, ev, }
 
13773
@DefescListEnd {\\V, @Lbrack{}, env, @Rbrack{}}
 
13774
@cindex @code{\V}, and copy-in mode
 
13775
@cindex copy-in mode, and @code{\V}
 
13776
@cindex mode, copy-in, and @code{\V}
 
13777
Interpolate the contents of the specified environment variable @var{env}
 
13778
(one-character name@tie{}@var{e}, two-character name @var{ev}) as
 
13779
returned by the function @code{getenv}.  @code{\V} is interpreted in
 
13780
copy-in mode.
 
13781
@endDefesc
 
13782
 
 
13783
 
 
13784
@c =====================================================================
 
13785
 
 
13786
@node Postprocessor Access, Miscellaneous, I/O, gtroff Reference
 
13787
@section Postprocessor Access
 
13788
@cindex postprocessor access
 
13789
@cindex access of postprocessor
 
13790
 
 
13791
There are two escapes which give information directly to the
 
13792
postprocessor.  This is particularly useful for embedding
 
13793
@sc{PostScript} into the final document.
 
13794
 
 
13795
@DefreqList {device, xxx}
 
13796
@DefescListEnd {\\X, ', xxx, '}
 
13797
Embeds its argument into the @code{gtroff} output preceded with
 
13798
@w{@samp{x X}}.
 
13799
 
 
13800
@cindex @code{\&}, in @code{\X}
 
13801
@cindex @code{\)}, in @code{\X}
 
13802
@cindex @code{\%}, in @code{\X}
 
13803
@ifnotinfo
 
13804
@cindex @code{\:}, in @code{\X}
 
13805
@end ifnotinfo
 
13806
@ifinfo
 
13807
@cindex @code{\@r{<colon>}}, in @code{\X}
 
13808
@end ifinfo
 
13809
The escapes @code{\&}, @code{\)}, @code{\%}, and @code{\:} are ignored
 
13810
within @code{\X}, @w{@samp{\ }} and @code{\~} are converted to single
 
13811
space characters.  All other escapes (except @code{\\} which produces a
 
13812
backslash) cause an error.
 
13813
 
 
13814
@cindex @code{device} request, and copy-in mode
 
13815
@cindex copy-in mode, and @code{device} request
 
13816
@cindex mode, copy-in, and @code{device} request
 
13817
Contrary to @code{\X}, the @code{device} request simply processes its
 
13818
argument in copy mode (@pxref{Copy-in Mode}).
 
13819
 
 
13820
@kindex use_charnames_in_special
 
13821
@pindex DESC@r{, and @code{use_charnames_in_special}}
 
13822
@cindex @code{\X}, and special characters
 
13823
If the @samp{use_charnames_in_special} keyword is set in the @file{DESC}
 
13824
file, special characters no longer cause an error; they are simply
 
13825
output verbatim.  Additionally, the backslash is represented as
 
13826
@code{\\}.
 
13827
 
 
13828
@samp{use_charnames_in_special} is currently used by @code{grohtml}
 
13829
only.
 
13830
@endDefesc
 
13831
 
 
13832
@DefreqList {devicem, xx}
 
13833
@DefescItem {\\Y, , n, }
 
13834
@DefescItem {\\Y, @Lparen{}, nm, }
 
13835
@DefescListEnd {\\Y, @Lbrack{}, name, @Rbrack{}}
 
13836
This is approximately equivalent to @samp{\X'\*[@var{name}]'}
 
13837
(one-character name@tie{}@var{n}, two-character name @var{nm}).
 
13838
However, the contents of the string or macro @var{name} are not
 
13839
interpreted; also it is permitted for @var{name} to have been defined as
 
13840
a macro and thus contain newlines (it is not permitted for the argument
 
13841
to @code{\X} to contain newlines).  The inclusion of newlines requires
 
13842
an extension to the @acronym{UNIX} @code{troff} output format, and
 
13843
confuses drivers that do not know about this extension (@pxref{Device
 
13844
Control Commands}).
 
13845
@endDefesc
 
13846
 
 
13847
@xref{Output Devices}.
 
13848
 
 
13849
 
 
13850
@c =====================================================================
 
13851
 
 
13852
@node Miscellaneous, Gtroff Internals, Postprocessor Access, gtroff Reference
 
13853
@section Miscellaneous
 
13854
 
 
13855
This section documents parts of @code{gtroff} which cannot (yet) be
 
13856
categorized elsewhere in this manual.
 
13857
 
 
13858
@Defreq {nm, [@Var{start} [@Var{inc} [@Var{space} [@Var{indent}]]]]}
 
13859
@cindex printing line numbers (@code{nm})
 
13860
@cindex line numbers, printing (@code{nm})
 
13861
@cindex numbers, line, printing (@code{nm})
 
13862
Print line numbers.  @var{start} is the line number of the @emph{next}
 
13863
output line.  @var{inc} indicates which line numbers are printed.  For
 
13864
example, the value@tie{}5 means to emit only line numbers which are
 
13865
multiples of@tie{}5; this defaults to@tie{}1.  @var{space} is the space
 
13866
to be left between the number and the text; this defaults to one digit
 
13867
space.  The fourth argument is the indentation of the line numbers,
 
13868
defaulting to zero.  Both @var{space} and @var{indent} are given as
 
13869
multiples of digit spaces; they can be negative also.  Without any
 
13870
arguments, line numbers are turned off.
 
13871
 
 
13872
@code{gtroff} reserves three digit spaces for the line number (which is
 
13873
printed right-justified) plus the amount given by @var{indent}; the
 
13874
output lines are concatenated to the line numbers, separated by
 
13875
@var{space}, and @emph{without} reducing the line length.  Depending on
 
13876
the value of the horizontal page offset (as set with the @code{po}
 
13877
request), line numbers which are longer than the reserved space stick
 
13878
out to the left, or the whole line is moved to the right.
 
13879
 
 
13880
Parameters corresponding to missing arguments are not changed; any
 
13881
non-digit argument (to be more precise, any argument starting with a
 
13882
character valid as a delimiter for identifiers) is also treated as
 
13883
missing.
 
13884
 
 
13885
If line numbering has been disabled with a call to @code{nm} without an
 
13886
argument, it can be reactivated with @samp{.nm +0}, using the previously
 
13887
active line numbering parameters.
 
13888
 
 
13889
The parameters of @code{nm} are associated with the current environment
 
13890
(@pxref{Environments}).  The current output line number is available in
 
13891
the number register @code{ln}.
 
13892
 
 
13893
@Example
 
13894
.po 1m
 
13895
.ll 2i
 
13896
This test shows how line numbering works with groff.
 
13897
.nm 999
 
13898
This test shows how line numbering works with groff.
 
13899
.br
 
13900
.nm xxx 3 2
 
13901
.ll -\w'0'u
 
13902
This test shows how line numbering works with groff.
 
13903
.nn 2
 
13904
This test shows how line numbering works with groff.
 
13905
@endExample
 
13906
 
 
13907
@noindent
 
13908
And here the result:
 
13909
 
 
13910
@Example
 
13911
 This  test shows how
 
13912
 line numbering works
 
13913
 999 with   groff.   This
 
13914
1000 test shows how  line
 
13915
1001 numbering works with
 
13916
1002 groff.
 
13917
      This test shows how
 
13918
      line      numbering
 
13919
 works  with  groff.
 
13920
 This test shows how
 
13921
1005  line      numbering
 
13922
      works with groff.
 
13923
@endExample
 
13924
@endDefreq
 
13925
 
 
13926
@Defreq {nn, [@Var{skip}]}
 
13927
Temporarily turn off line numbering.  The argument is the number of
 
13928
lines not to be numbered; this defaults to@tie{}1.
 
13929
@endDefreq
 
13930
 
 
13931
@Defreq {mc, glyph [@Var{dist}]}
 
13932
@cindex margin glyph (@code{mc})
 
13933
@cindex glyph, for margins (@code{mc})
 
13934
Print a @dfn{margin character} to the right of the
 
13935
text.@footnote{@dfn{Margin character} is a misnomer since it is an
 
13936
output glyph.}  The first argument is the glyph to be printed.  The
 
13937
second argument is the distance away from the right margin.  If missing,
 
13938
the previously set value is used; default is 10@dmn{pt}).  For text
 
13939
lines that are too long (that is, longer than the text length plus
 
13940
@var{dist}), the margin character is directly appended to the lines.
 
13941
 
 
13942
With no arguments the margin character is turned off.  If this occurs
 
13943
before a break, no margin character is printed.
 
13944
 
 
13945
For compatibility with @acronym{AT&T} @code{troff}, a call to @code{mc}
 
13946
to set the margin character can't be undone immediately; at least one
 
13947
line gets a margin character.  Thus
 
13948
 
 
13949
@Example
 
13950
.ll 1i
 
13951
.mc \[br]
 
13952
.mc
 
13953
xxx
 
13954
.br
 
13955
xxx
 
13956
@endExample
 
13957
 
 
13958
@noindent
 
13959
produces
 
13960
 
 
13961
@Example
 
13962
xxx        |
 
13963
xxx
 
13964
@endExample
 
13965
 
 
13966
@cindex @code{tl} request, and @code{mc}
 
13967
For empty lines and lines produced by the @code{tl} request no margin
 
13968
character is emitted.
 
13969
 
 
13970
The margin character is associated with the current environment
 
13971
(@pxref{Environments}).
 
13972
 
 
13973
@pindex nrchbar
 
13974
@pindex changebar
 
13975
This is quite useful for indicating text that has changed, and, in fact,
 
13976
there are programs available for doing this (they are called
 
13977
@code{nrchbar} and @code{changebar} and can be found in any
 
13978
@samp{comp.sources.unix} archive).
 
13979
 
 
13980
@Example
 
13981
.ll 3i
 
13982
.mc |
 
13983
This paragraph is highlighted with a margin
 
13984
character.
 
13985
.sp
 
13986
Note that vertical space isn't marked.
 
13987
.br
 
13988
\&
 
13989
.br
 
13990
But we can fake it with `\&'.
 
13991
@endExample
 
13992
 
 
13993
Result:
 
13994
 
 
13995
@Example
 
13996
This  paragraph is highlighted |
 
13997
with a margin character.       |
 
13998
 
 
13999
Note that vertical space isn't |
 
14000
marked.                        |
 
14001
                               |
 
14002
But we can fake it with `\&'.  |
 
14003
@endExample
 
14004
@endDefreq
 
14005
 
 
14006
@DefreqList {psbb, filename}
 
14007
@DefregItem {llx}
 
14008
@DefregItem {lly}
 
14009
@DefregItem {urx}
 
14010
@DefregListEnd {ury}
 
14011
@cindex PostScript, bounding box
 
14012
@cindex bounding box
 
14013
Retrieve the bounding box of the @sc{PostScript} image found in
 
14014
@var{filename}.  The file must conform to Adobe's @dfn{Document
 
14015
Structuring Conventions} (DSC); the command searches for a
 
14016
@code{%%BoundingBox} comment and extracts the bounding box values into
 
14017
the number registers @code{llx}, @code{lly}, @code{urx}, and @code{ury}.
 
14018
If an error occurs (for example, @code{psbb} cannot find the
 
14019
@code{%%BoundingBox} comment), it sets the four number registers to
 
14020
zero.
 
14021
 
 
14022
The search path for @var{filename} can be controlled with the
 
14023
@option{-I} command line option.
 
14024
@endDefreq
 
14025
 
 
14026
 
 
14027
@c =====================================================================
 
14028
 
 
14029
@node Gtroff Internals, Debugging, Miscellaneous, gtroff Reference
 
14030
@section @code{gtroff} Internals
 
14031
 
 
14032
@cindex input token
 
14033
@cindex token, input
 
14034
@cindex output node
 
14035
@cindex node, output
 
14036
@code{gtroff} processes input in three steps.  One or more input
 
14037
characters are converted to an @dfn{input token}.@footnote{Except the
 
14038
escapes @code{\f}, @code{\F}, @code{\H}, @code{\m}, @code{\M},
 
14039
@code{\R}, @code{\s}, and @code{\S} which are processed immediately if
 
14040
not in copy-in mode.}  Then, one or more input tokens are converted to
 
14041
an @dfn{output node}.  Finally, output nodes are converted to the
 
14042
intermediate output language understood by all output devices.
 
14043
 
 
14044
Actually, before step one happens, @code{gtroff} converts certain escape
 
14045
sequences into reserved input characters (not accessible by the user);
 
14046
such reserved characters are used for other internal processing also --
 
14047
this is the very reason why not all characters are valid input.
 
14048
@xref{Identifiers}, for more on this topic.
 
14049
 
 
14050
For example, the input string @samp{fi\[:u]} is converted into a
 
14051
character token @samp{f}, a character token @samp{i}, and a special
 
14052
token @samp{:u} (representing u@tie{}umlaut).  Later on, the character
 
14053
tokens @samp{f} and @samp{i} are merged to a single output node
 
14054
representing the ligature glyph @samp{fi} (provided the current font has
 
14055
a glyph for this ligature); the same happens with @samp{:u}.  All output
 
14056
glyph nodes are `processed' which means that they are invariably
 
14057
associated with a given font, font size, advance width, etc.  During the
 
14058
formatting process, @code{gtroff} itself adds various nodes to control
 
14059
the data flow.
 
14060
 
 
14061
Macros, diversions, and strings collect elements in two chained lists: a
 
14062
list of input tokens which have been passed unprocessed, and a list of
 
14063
output nodes.  Consider the following the diversion.
 
14064
 
 
14065
@Example
 
14066
.di xxx
 
14067
a
 
14068
\!b
 
14069
c
 
14070
.br
 
14071
.di
 
14072
@endExample
 
14073
 
 
14074
@noindent
 
14075
It contains these elements.
 
14076
 
 
14077
@multitable {@i{vertical size node}} {token list} {element number}
 
14078
@item node list               @tab token list @tab element number
 
14079
 
 
14080
@item @i{line start node}     @tab ---        @tab 1
 
14081
@item @i{glyph node @code{a}} @tab ---        @tab 2
 
14082
@item @i{word space node}     @tab ---        @tab 3
 
14083
@item ---                     @tab @code{b}   @tab 4
 
14084
@item ---                     @tab @code{\n}  @tab 5
 
14085
@item @i{glyph node @code{c}} @tab ---        @tab 6
 
14086
@item @i{vertical size node}  @tab ---        @tab 7
 
14087
@item @i{vertical size node}  @tab ---        @tab 8
 
14088
@item ---                     @tab @code{\n}  @tab 9
 
14089
@end multitable
 
14090
 
 
14091
@cindex @code{\v}, internal representation
 
14092
@noindent
 
14093
Elements 1, 7, and@tie{}8 are inserted by @code{gtroff}; the latter two
 
14094
(which are always present) specify the vertical extent of the last line,
 
14095
possibly modified by @code{\x}.  The @code{br} request finishes the
 
14096
current partial line, inserting a newline input token which is
 
14097
subsequently converted to a space when the diversion is reread.  Note
 
14098
that the word space node has a fixed width which isn't stretchable
 
14099
anymore.  To convert horizontal space nodes back to input tokens, use
 
14100
the @code{unformat} request.
 
14101
 
 
14102
Macros only contain elements in the token list (and the node list is
 
14103
empty); diversions and strings can contain elements in both lists.
 
14104
 
 
14105
Note that the @code{chop} request simply reduces the number of elements
 
14106
in a macro, string, or diversion by one.  Exceptions are
 
14107
@dfn{compatibility save} and @dfn{compatibility ignore} input tokens
 
14108
which are ignored.  The @code{substring} request also ignores those
 
14109
input tokens.
 
14110
 
 
14111
Some requests like @code{tr} or @code{cflags} work on glyph identifiers
 
14112
only; this means that the associated glyph can be changed without
 
14113
destroying this association.  This can be very helpful for substituting
 
14114
glyphs.  In the following example, we assume that glyph @samp{foo} isn't
 
14115
available by default, so we provide a substitution using the
 
14116
@code{fchar} request and map it to input character @samp{x}.
 
14117
 
 
14118
@Example
 
14119
.fchar \[foo] foo
 
14120
.tr x \[foo]
 
14121
@endExample
 
14122
 
 
14123
@noindent
 
14124
Now let us assume that we install an additional special font @samp{bar}
 
14125
which has glyph @samp{foo}.
 
14126
 
 
14127
@Example
 
14128
.special bar
 
14129
.rchar \[foo]
 
14130
@endExample
 
14131
 
 
14132
@noindent
 
14133
Since glyphs defined with @code{fchar} are searched before glyphs in
 
14134
special fonts, we must call @code{rchar} to remove the definition of the
 
14135
fallback glyph.  Anyway, the translation is still active; @samp{x} now
 
14136
maps to the real glyph @samp{foo}.
 
14137
 
 
14138
@cindex compatibility mode, and parameters
 
14139
@cindex mode, compatibility, and parameters
 
14140
@cindex arguments, and compatibility mode
 
14141
@cindex parameters, and compatibility mode
 
14142
@cindex macro arguments, and compatibility mode
 
14143
@cindex request arguments, and compatibility mode
 
14144
Macro and request arguments preserve the compatibility mode:
 
14145
 
 
14146
@Example
 
14147
.cp 1     \" switch to compatibility mode
 
14148
.de xx
 
14149
\\$1
 
14150
..
 
14151
.cp 0     \" switch compatibility mode off
 
14152
.xx caf\['e]
 
14153
    @result{} caf�
 
14154
@endExample
 
14155
 
 
14156
@noindent
 
14157
Since compatibility mode is on while @code{de} is called, the macro
 
14158
@code{xx} activates compatibility mode while executing.  Argument
 
14159
@code{$1} can still be handled properly because it inherits the
 
14160
compatibility mode status which was active at the point where @code{xx}
 
14161
is called.
 
14162
 
 
14163
After expansion of the parameters, the compatibility save and restore
 
14164
tokens are removed.
 
14165
 
 
14166
 
 
14167
@c =====================================================================
 
14168
 
 
14169
@node Debugging, Implementation Differences, Gtroff Internals, gtroff Reference
 
14170
@section Debugging
 
14171
@cindex debugging
 
14172
 
 
14173
@code{gtroff} is not easy to debug, but there are some useful features
 
14174
and strategies for debugging.
 
14175
 
 
14176
@Defreq {lf, line [@Var{filename}]}
 
14177
@pindex soelim
 
14178
@cindex multi-file documents
 
14179
@cindex documents, multi-file
 
14180
@cindex setting input line number (@code{lf})
 
14181
@cindex input line number, setting (@code{lf})
 
14182
@cindex number, input line, setting (@code{lf})
 
14183
Change the line number and optionally the file name @code{gtroff} shall
 
14184
use for error and warning messages.  @var{line} is the input line number
 
14185
of the @emph{next} line.
 
14186
 
 
14187
Without argument, the request is ignored.
 
14188
 
 
14189
This is a debugging aid for documents which are split into many files,
 
14190
then put together with @code{soelim} and other preprocessors.  Usually,
 
14191
it isn't invoked manually.
 
14192
 
 
14193
Note that other @code{troff} implementations (including the original
 
14194
@acronym{AT&T} version) handle @code{lf} differently.  For them,
 
14195
@var{line} changes the line number of the @emph{current} line.
 
14196
@endDefreq
 
14197
 
 
14198
@DefreqList {tm, string}
 
14199
@DefreqItem {tm1, string}
 
14200
@DefreqListEnd {tmc, string}
 
14201
@cindex printing to stderr (@code{tm}, @code{tm1}, @code{tmc})
 
14202
@cindex stderr, printing to (@code{tm}, @code{tm1}, @code{tmc})
 
14203
Send @var{string} to the standard error output; this is very useful for
 
14204
printing debugging messages among other things.
 
14205
 
 
14206
@cindex @code{tm} request, and copy-in mode
 
14207
@cindex copy-in mode, and @code{tm} request
 
14208
@cindex mode, copy-in, and @code{tm} request
 
14209
@cindex @code{tm1} request, and copy-in mode
 
14210
@cindex copy-in mode, and @code{tm1} request
 
14211
@cindex mode, copy-in, and @code{tm1} request
 
14212
@cindex @code{tmc} request, and copy-in mode
 
14213
@cindex copy-in mode, and @code{tmc} request
 
14214
@cindex mode, copy-in, and @code{tmc} request
 
14215
@var{string} is read in copy mode.
 
14216
 
 
14217
The @code{tm} request ignores leading spaces of @var{string}; @code{tm1}
 
14218
handles its argument similar to the @code{ds} request: a leading double
 
14219
quote in @var{string} is stripped to allow initial blanks.
 
14220
 
 
14221
The @code{tmc} request is similar to @code{tm1} but does not append a
 
14222
newline (as is done in @code{tm} and @code{tm1}).
 
14223
@endDefreq
 
14224
 
 
14225
@Defreq {ab, [@Var{string}]}
 
14226
@cindex aborting (@code{ab})
 
14227
Similar to the @code{tm} request, except that it causes @code{gtroff} to
 
14228
stop processing.  With no argument it prints @samp{User Abort.} to
 
14229
standard error.
 
14230
@endDefreq
 
14231
 
 
14232
@Defreq {ex, }
 
14233
@cindex @code{ex} request, use in debugging
 
14234
@cindex exiting (@code{ex})
 
14235
The @code{ex} request also causes @code{gtroff} to stop processing; see
 
14236
also @ref{I/O}.
 
14237
@endDefreq
 
14238
 
 
14239
When doing something involved it is useful to leave the debugging
 
14240
statements in the code and have them turned on by a command line flag.
 
14241
 
 
14242
@Example
 
14243
.if \n(DB .tm debugging output
 
14244
@endExample
 
14245
 
 
14246
@noindent
 
14247
To activate these statements say
 
14248
 
 
14249
@Example
 
14250
groff -rDB=1 file
 
14251
@endExample
 
14252
 
 
14253
If it is known in advance that there are many errors and no useful
 
14254
output, @code{gtroff} can be forced to suppress formatted output with
 
14255
the @option{-z} flag.
 
14256
 
 
14257
@Defreq {pev, }
 
14258
@cindex dumping environments (@code{pev})
 
14259
@cindex environments, dumping (@code{pev})
 
14260
Print the contents of the current environment and all the currently
 
14261
defined environments (both named and numbered) on @code{stderr}.
 
14262
@endDefreq
 
14263
 
 
14264
@Defreq {pm, }
 
14265
@cindex dumping symbol table (@code{pm})
 
14266
@cindex symbol table, dumping (@code{pm})
 
14267
Print the entire symbol table on @code{stderr}.  Names of all defined
 
14268
macros, strings, and diversions are print together with their size in
 
14269
bytes.  Since @code{gtroff} sometimes adds nodes by itself, the returned
 
14270
size can be larger than expected.
 
14271
 
 
14272
This request differs from @acronym{UNIX} @code{troff}: @code{gtroff}
 
14273
reports the sizes of diversions, ignores an additional argument to print
 
14274
only the total of the sizes, and the size isn't returned in blocks of
 
14275
128 characters.
 
14276
@endDefreq
 
14277
 
 
14278
@Defreq {pnr, }
 
14279
@cindex dumping number registers (@code{pnr})
 
14280
@cindex number registers, dumping (@code{pnr})
 
14281
Print the names and contents of all currently defined number registers
 
14282
on @code{stderr}.
 
14283
@endDefreq
 
14284
 
 
14285
@Defreq {ptr, }
 
14286
@cindex dumping traps (@code{ptr})
 
14287
@cindex traps, dumping (@code{ptr})
 
14288
Print the names and positions of all traps (not including input line
 
14289
traps and diversion traps) on @code{stderr}.  Empty slots in the page
 
14290
trap list are printed as well, because they can affect the priority of
 
14291
subsequently planted traps.
 
14292
@endDefreq
 
14293
 
 
14294
@Defreq {fl, }
 
14295
@cindex flush output (@code{fl})
 
14296
@cindex output, flush (@code{fl})
 
14297
@cindex interactive use of @code{gtroff}
 
14298
@cindex @code{gtroff}, interactive use
 
14299
Instruct @code{gtroff} to flush its output immediately.  The intent is
 
14300
for interactive use, but this behaviour is currently not implemented in
 
14301
@code{gtroff}.  Contrary to @acronym{UNIX} @code{troff}, TTY output is
 
14302
sent to a device driver also (@code{grotty}), making it non-trivial to
 
14303
communicate interactively.
 
14304
 
 
14305
This request causes a line break.
 
14306
@endDefreq
 
14307
 
 
14308
@Defreq {backtrace, }
 
14309
@cindex backtrace of input stack (@code{backtrace})
 
14310
@cindex input stack, backtrace (@code{backtrace})
 
14311
Print a backtrace of the input stack to the standard error stream.
 
14312
 
 
14313
Consider the following in file @file{test}:
 
14314
 
 
14315
@Example
 
14316
.de xxx
 
14317
.  backtrace
 
14318
..
 
14319
.de yyy
 
14320
.  xxx
 
14321
..
 
14322
.
 
14323
.yyy
 
14324
@endExample
 
14325
 
 
14326
@noindent
 
14327
On execution, @code{gtroff} prints the following:
 
14328
 
 
14329
@Example
 
14330
test:2: backtrace: macro `xxx'
 
14331
test:5: backtrace: macro `yyy'
 
14332
test:8: backtrace: file `test'
 
14333
@endExample
 
14334
 
 
14335
The option @option{-b} of @code{gtroff} internally calls a variant of
 
14336
this request on each error and warning.
 
14337
@endDefreq
 
14338
 
 
14339
@Defreg {slimit}
 
14340
@cindex input stack, setting limit
 
14341
Use the @code{slimit} number register to set the maximum number of
 
14342
objects on the input stack.  If @code{slimit} is less than or equal
 
14343
to@tie{}0, there is no limit set.  With no limit, a buggy recursive
 
14344
macro can exhaust virtual memory.
 
14345
 
 
14346
The default value is 1000; this is a compile-time constant.
 
14347
@endDefreg
 
14348
 
 
14349
@Defreq {warnscale, si}
 
14350
Set the scaling indicator used in warnings to @var{si}.  Valid values
 
14351
for @var{si} are @samp{u}, @samp{i}, @samp{c}, @samp{p}, and @samp{P}.
 
14352
At startup, it is set to @samp{i}.
 
14353
@endDefreq
 
14354
 
 
14355
@Defreq {spreadwarn, [@Var{limit}]}
 
14356
Make @code{gtroff} emit a warning if the additional space inserted for
 
14357
each space between words in an output line is larger or equal to
 
14358
@var{limit}.  A negative value is changed to zero; no argument toggles
 
14359
the warning on and off without changing @var{limit}.  The default
 
14360
scaling indicator is @samp{m}.  At startup, @code{spreadwarn} is
 
14361
deactivated, and @var{limit} is set to 3@dmn{m}.
 
14362
 
 
14363
For example,
 
14364
 
 
14365
@Example
 
14366
.spreadwarn 0.2m
 
14367
@endExample
 
14368
 
 
14369
@noindent
 
14370
causes a warning if @code{gtroff} must add 0.2@dmn{m} or more for each
 
14371
interword space in a line.
 
14372
 
 
14373
This request is active only if text is justified to both margins (using
 
14374
@w{@samp{.ad b}}).
 
14375
@endDefreq
 
14376
 
 
14377
@cindex warnings
 
14378
@code{gtroff} has command line options for printing out more warnings
 
14379
(@option{-w}) and for printing backtraces (@option{-b}) when a warning
 
14380
or an error occurs.  The most verbose level of warnings is @option{-ww}.
 
14381
 
 
14382
@DefreqList {warn, [@Var{flags}]}
 
14383
@DefregListEnd {.warn}
 
14384
@cindex level of warnings (@code{warn})
 
14385
@cindex warnings, level (@code{warn})
 
14386
Control the level of warnings checked for.  The @var{flags} are the sum
 
14387
of the numbers associated with each warning that is to be enabled; all
 
14388
other warnings are disabled.  The number associated with each warning is
 
14389
listed below.  For example, @w{@code{.warn 0}} disables all warnings,
 
14390
and @w{@code{.warn 1}} disables all warnings except that about missing
 
14391
glyphs.  If no argument is given, all warnings are enabled.
 
14392
 
 
14393
The read-only number register @code{.warn} contains the current warning
 
14394
level.
 
14395
@endDefreq
 
14396
 
 
14397
@menu
 
14398
* Warnings::
 
14399
@end menu
 
14400
 
 
14401
@c ---------------------------------------------------------------------
 
14402
 
 
14403
@node Warnings,  , Debugging, Debugging
 
14404
@subsection Warnings
 
14405
@cindex warnings
 
14406
 
 
14407
The warnings that can be given to @code{gtroff} are divided into the
 
14408
following categories.  The name associated with each warning is used by
 
14409
the @option{-w} and @option{-W} options; the number is used by the
 
14410
@code{warn} request and by the @code{.warn} register.
 
14411
 
 
14412
@table @samp
 
14413
@item char
 
14414
@itemx 1
 
14415
Non-existent glyphs.@footnote{@code{char} is a misnomer since it reports
 
14416
missing glyphs -- there aren't missing input characters, only invalid
 
14417
ones.}  This is enabled by default.
 
14418
 
 
14419
@item number
 
14420
@itemx 2
 
14421
Invalid numeric expressions.  This is enabled by default.
 
14422
@xref{Expressions}.
 
14423
 
 
14424
@item break
 
14425
@itemx 4
 
14426
@cindex fill mode
 
14427
@cindex mode, fill
 
14428
In fill mode, lines which could not be broken so that their length was
 
14429
less than the line length.  This is enabled by default.
 
14430
 
 
14431
@item delim
 
14432
@itemx 8
 
14433
Missing or mismatched closing delimiters.
 
14434
 
 
14435
@item el
 
14436
@itemx 16
 
14437
@cindex @code{ie} request, and warnings
 
14438
@cindex @code{el} request, and warnings
 
14439
Use of the @code{el} request with no matching @code{ie} request.
 
14440
@xref{if-else}.
 
14441
 
 
14442
@item scale
 
14443
@itemx 32
 
14444
Meaningless scaling indicators.
 
14445
 
 
14446
@item range
 
14447
@itemx 64
 
14448
Out of range arguments.
 
14449
 
 
14450
@item syntax
 
14451
@itemx 128
 
14452
Dubious syntax in numeric expressions.
 
14453
 
 
14454
@item di
 
14455
@itemx 256
 
14456
@cindex @code{di} request, and warnings
 
14457
@cindex @code{da} request, and warnings
 
14458
Use of @code{di} or @code{da} without an argument when there is no
 
14459
current diversion.
 
14460
 
 
14461
@item mac
 
14462
@itemx 512
 
14463
@cindex @code{de}, @code{de1}, @code{dei} requests, and warnings
 
14464
@cindex @code{am}, @code{am1}, @code{ami} requests, and warnings
 
14465
@cindex @code{ds}, @code{ds1} requests, and warnings
 
14466
@cindex @code{as}, @code{as1} requests, and warnings
 
14467
@cindex @code{di} request, and warnings
 
14468
@cindex @code{da} request, and warnings
 
14469
@cindex @code{box}, @code{boxa} requests, and warnings
 
14470
@cindex @code{\*}, and warnings
 
14471
Use of undefined strings, macros and diversions.  When an undefined
 
14472
string, macro, or diversion is used, that string is automatically
 
14473
defined as empty.  So, in most cases, at most one warning is given for
 
14474
each name.
 
14475
 
 
14476
@item reg
 
14477
@itemx 1024
 
14478
@cindex @code{nr} request, and warnings
 
14479
@cindex @code{\R}, and warnings
 
14480
@cindex @code{\n}, and warnings
 
14481
Use of undefined number registers.  When an undefined number register is
 
14482
used, that register is automatically defined to have a value of@tie{}0.
 
14483
So, in most cases, at most one warning is given for use of a particular
 
14484
name.
 
14485
 
 
14486
@item tab
 
14487
@itemx 2048
 
14488
@cindex @code{\t}, and warnings
 
14489
Use of a tab character where a number was expected.
 
14490
 
 
14491
@item right-brace
 
14492
@itemx 4096
 
14493
@cindex @code{\@}}, and warnings
 
14494
Use of @code{\@}} where a number was expected.
 
14495
 
 
14496
@item missing
 
14497
@itemx 8192
 
14498
Requests that are missing non-optional arguments.
 
14499
 
 
14500
@item input
 
14501
@itemx 16384
 
14502
Invalid input characters.
 
14503
 
 
14504
@item escape
 
14505
@itemx 32768
 
14506
Unrecognized escape sequences.  When an unrecognized escape sequence
 
14507
@code{\@var{X}} is encountered, the escape character is ignored, and
 
14508
@var{X} is printed.
 
14509
 
 
14510
@item space
 
14511
@itemx 65536
 
14512
@cindex compatibility mode
 
14513
Missing space between a request or macro and its argument.  This warning
 
14514
is given when an undefined name longer than two characters is
 
14515
encountered, and the first two characters of the name make a defined
 
14516
name.  The request or macro is not invoked.  When this warning is given,
 
14517
no macro is automatically defined.  This is enabled by default.  This
 
14518
warning never occurs in compatibility mode.
 
14519
 
 
14520
@item font
 
14521
@itemx 131072
 
14522
Non-existent fonts.  This is enabled by default.
 
14523
 
 
14524
@item ig
 
14525
@itemx 262144
 
14526
Invalid escapes in text ignored with the @code{ig} request.  These are
 
14527
conditions that are errors when they do not occur in ignored text.
 
14528
 
 
14529
@item color
 
14530
@itemx 524288
 
14531
Color related warnings.
 
14532
 
 
14533
@item file
 
14534
@itemx 1048576
 
14535
Missing files.  The @code{mso} request gives this warning when the
 
14536
requested macro file does not exist.  This is enabled by default.
 
14537
 
 
14538
@item all
 
14539
All warnings except @samp{di}, @samp{mac} and @samp{reg}.  It is
 
14540
intended that this covers all warnings that are useful with traditional
 
14541
macro packages.
 
14542
 
 
14543
@item w
 
14544
All warnings.
 
14545
@end table
 
14546
 
 
14547
 
 
14548
@c =====================================================================
 
14549
 
 
14550
@node Implementation Differences,  , Debugging, gtroff Reference
 
14551
@section Implementation Differences
 
14552
@cindex implementation differences
 
14553
@cindex differences in implementation
 
14554
@cindex incompatibilities with @acronym{AT&T} @code{troff}
 
14555
@cindex compatibility mode
 
14556
@cindex mode, compatibility
 
14557
 
 
14558
GNU @code{troff} has a number of features which cause incompatibilities
 
14559
with documents written with old versions of @code{troff}.
 
14560
 
 
14561
@cindex long names
 
14562
@cindex names, long
 
14563
Long names cause some incompatibilities.  @acronym{UNIX} @code{troff}
 
14564
interprets
 
14565
 
 
14566
@Example
 
14567
.dsabcd
 
14568
@endExample
 
14569
 
 
14570
@cindex @code{\*}, incompatibilities with @acronym{AT&T} @code{troff}
 
14571
@cindex @code{\n}, incompatibilities with @acronym{AT&T} @code{troff}
 
14572
@noindent
 
14573
as defining a string @samp{ab} with contents @samp{cd}.  Normally, GNU
 
14574
@code{troff} interprets this as a call of a macro named @code{dsabcd}.
 
14575
Also @acronym{UNIX} @code{troff} interprets @code{\*[} or @code{\n[} as
 
14576
references to a string or number register called @samp{[}.  In GNU
 
14577
@code{troff}, however, this is normally interpreted as the start of a
 
14578
long name.  In compatibility mode GNU @code{troff} interprets long names
 
14579
in the traditional way (which means that they are not recognized as
 
14580
names).
 
14581
 
 
14582
@DefreqList {cp, [@Var{n}]}
 
14583
@DefreqItem {do, cmd}
 
14584
@DefregListEnd {.C}
 
14585
If @var{n} is missing or non-zero, turn on compatibility mode;
 
14586
otherwise, turn it off.
 
14587
 
 
14588
The read-only number register @code{.C} is@tie{}1 if compatibility mode
 
14589
is on, 0@tie{}otherwise.
 
14590
 
 
14591
Compatibility mode can be also turned on with the @option{-C} command
 
14592
line option.
 
14593
 
 
14594
The @code{do} request turns off compatibility mode while executing its
 
14595
arguments as a @code{gtroff} command.  However, it does not turn off
 
14596
compatibility mode while processing the macro itself.  To do that, use
 
14597
the @code{de1} request (or manipulate the @code{.C} register manually).
 
14598
@xref{Writing Macros}.
 
14599
 
 
14600
@Example
 
14601
.do fam T
 
14602
@endExample
 
14603
 
 
14604
@noindent
 
14605
executes the @code{fam} request when compatibility mode is enabled.
 
14606
 
 
14607
@code{gtroff} restores the previous compatibility setting before
 
14608
interpreting any files sourced by the @var{cmd}.
 
14609
@endDefreq
 
14610
 
 
14611
@cindex input level in delimited arguments
 
14612
@cindex delimited arguments, incompatibilities with @acronym{AT&T} @code{troff}
 
14613
Two other features are controlled by @option{-C}.  If not in
 
14614
compatibility mode, GNU @code{troff} preserves the input level in
 
14615
delimited arguments:
 
14616
 
 
14617
@Example
 
14618
.ds xx '
 
14619
\w'abc\*(xxdef'
 
14620
@endExample
 
14621
 
 
14622
@noindent
 
14623
In compatibility mode, the string @samp{72def'} is returned; without
 
14624
@option{-C} the resulting string is @samp{168} (assuming a TTY output
 
14625
device).
 
14626
 
 
14627
@cindex @code{\f}, incompatibilities with @acronym{AT&T} @code{troff}
 
14628
@cindex @code{\H}, incompatibilities with @acronym{AT&T} @code{troff}
 
14629
@cindex @code{\s}, incompatibilities with @acronym{AT&T} @code{troff}
 
14630
@cindex @code{\S}, incompatibilities with @acronym{AT&T} @code{troff}
 
14631
Finally, the escapes @code{\f}, @code{\H}, @code{\m}, @code{\M},
 
14632
@code{\R}, @code{\s}, and @code{\S} are transparent for recognizing the
 
14633
beginning of a line only in compatibility mode (this is a rather obscure
 
14634
feature).  For example, the code
 
14635
 
 
14636
@Example
 
14637
.de xx
 
14638
Hallo!
 
14639
..
 
14640
\fB.xx\fP
 
14641
@endExample
 
14642
 
 
14643
@noindent
 
14644
prints @samp{Hallo!} in bold face if in compatibility mode, and
 
14645
@samp{.xx} in bold face otherwise.
 
14646
 
 
14647
@cindex @code{\A}, incompatibilities with @acronym{AT&T} @code{troff}
 
14648
@cindex @code{\|}, incompatibilities with @acronym{AT&T} @code{troff}
 
14649
@cindex @code{\^}, incompatibilities with @acronym{AT&T} @code{troff}
 
14650
@cindex @code{\&}, incompatibilities with @acronym{AT&T} @code{troff}
 
14651
@cindex @code{\@{}, incompatibilities with @acronym{AT&T} @code{troff}
 
14652
@cindex @code{\@}}, incompatibilities with @acronym{AT&T} @code{troff}
 
14653
@cindex @code{\@key{SP}}, incompatibilities with @acronym{AT&T} @code{troff}
 
14654
@cindex @code{\'}, incompatibilities with @acronym{AT&T} @code{troff}
 
14655
@cindex @code{\`}, incompatibilities with @acronym{AT&T} @code{troff}
 
14656
@cindex @code{\-}, incompatibilities with @acronym{AT&T} @code{troff}
 
14657
@cindex @code{\_}, incompatibilities with @acronym{AT&T} @code{troff}
 
14658
@cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
 
14659
@cindex @code{\%}, incompatibilities with @acronym{AT&T} @code{troff}
 
14660
@cindex @code{\c}, incompatibilities with @acronym{AT&T} @code{troff}
 
14661
GNU @code{troff} does not allow the use of the escape sequences
 
14662
@code{\|}, @code{\^}, @code{\&}, @code{\@{}, @code{\@}},
 
14663
@code{\@key{SP}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
 
14664
@code{\%}, and @code{\c} in names of strings, macros, diversions, number
 
14665
registers, fonts or environments; @acronym{UNIX} @code{troff} does.  The
 
14666
@code{\A} escape sequence (@pxref{Identifiers}) may be helpful in
 
14667
avoiding use of these escape sequences in names.
 
14668
 
 
14669
@cindex fractional point sizes
 
14670
@cindex fractional type sizes
 
14671
@cindex point sizes, fractional
 
14672
@cindex type sizes, fractional
 
14673
@cindex sizes, fractional
 
14674
@cindex @code{ps} request, incompatibilities with @acronym{AT&T} @code{troff}
 
14675
Fractional point sizes cause one noteworthy incompatibility.  In
 
14676
@acronym{UNIX} @code{troff} the @code{ps} request ignores scale
 
14677
indicators and thus
 
14678
 
 
14679
@Example
 
14680
.ps 10u
 
14681
@endExample
 
14682
 
 
14683
@noindent
 
14684
sets the point size to 10@tie{}points, whereas in GNU @code{troff} it
 
14685
sets the point size to 10@tie{}scaled points.  @xref{Fractional Type
 
14686
Sizes}, for more information.
 
14687
 
 
14688
@cindex @code{bd} request, incompatibilities with @acronym{AT&T} @code{troff}
 
14689
@cindex @code{cs} request, incompatibilities with @acronym{AT&T} @code{troff}
 
14690
@cindex @code{tr} request, incompatibilities with @acronym{AT&T} @code{troff}
 
14691
@cindex @code{fp} request, incompatibilities with @acronym{AT&T} @code{troff}
 
14692
@cindex input characters and output glyphs, compatibility with @acronym{AT&T} @code{troff}
 
14693
@cindex output glyphs, and input characters,compatibility with @acronym{AT&T} @code{troff}
 
14694
@cindex characters, input, and output glyphs, compatibility with @acronym{AT&T} @code{troff}
 
14695
@cindex glyphs, output, and input characters, compatibility with @acronym{AT&T} @code{troff}
 
14696
In GNU @code{troff} there is a fundamental difference between
 
14697
(unformatted) input characters and (formatted) output glyphs.
 
14698
Everything that affects how a glyph is output is stored with the glyph
 
14699
node; once a glyph node has been constructed it is unaffected by any
 
14700
subsequent requests that are executed, including @code{bd}, @code{cs},
 
14701
@code{tkf}, @code{tr}, or @code{fp} requests.  Normally glyphs are
 
14702
constructed from input characters at the moment immediately before the
 
14703
glyph is added to the current output line.  Macros, diversions and
 
14704
strings are all, in fact, the same type of object; they contain lists of
 
14705
input characters and glyph nodes in any combination.  A glyph node does
 
14706
not behave like an input character for the purposes of macro processing;
 
14707
it does not inherit any of the special properties that the input
 
14708
character from which it was constructed might have had.  For example,
 
14709
 
 
14710
@Example
 
14711
.di x
 
14712
\\\\
 
14713
.br
 
14714
.di
 
14715
.x
 
14716
@endExample
 
14717
 
 
14718
@cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
 
14719
@cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
 
14720
@cindex @code{\e}, incompatibilities with @acronym{AT&T} @code{troff}
 
14721
@cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
 
14722
@cindex @code{\?}, incompatibilities with @acronym{AT&T} @code{troff}
 
14723
@cindex transparent output, incompatibilities with @acronym{AT&T} @code{troff}
 
14724
@cindex output, transparent, incompatibilities with @acronym{AT&T} @code{troff}
 
14725
@noindent
 
14726
prints @samp{\\} in GNU @code{troff}; each pair of input backslashes is
 
14727
turned into one output backslash and the resulting output backslashes
 
14728
are not interpreted as escape characters when they are reread.
 
14729
@acronym{UNIX} @code{troff} would interpret them as escape characters
 
14730
when they were reread and would end up printing one @samp{\}.  The
 
14731
correct way to obtain a printable backslash is to use the @code{\e}
 
14732
escape sequence: This always prints a single instance of the current
 
14733
escape character, regardless of whether or not it is used in a
 
14734
diversion; it also works in both GNU @code{troff} and @acronym{UNIX}
 
14735
@code{troff}.@footnote{To be completely independent of the current
 
14736
escape character, use @code{\(rs} which represents a reverse solidus
 
14737
(backslash) glyph.}  To store, for some reason, an escape sequence in a
 
14738
diversion that is interpreted when the diversion is reread, either use
 
14739
the traditional @code{\!} transparent output facility, or, if this is
 
14740
unsuitable, the new @code{\?} escape sequence.
 
14741
 
 
14742
@xref{Diversions}, and @ref{Gtroff Internals}, for more information.
 
14743
 
 
14744
 
 
14745
 
 
14746
@c =====================================================================
 
14747
@c =====================================================================
 
14748
 
 
14749
@node Preprocessors, Output Devices, gtroff Reference, Top
 
14750
@chapter Preprocessors
 
14751
@cindex preprocessors
 
14752
 
 
14753
This chapter describes all preprocessors that come with @code{groff} or
 
14754
which are freely available.
 
14755
 
 
14756
@menu
 
14757
* geqn::
 
14758
* gtbl::
 
14759
* gpic::
 
14760
* ggrn::
 
14761
* grap::
 
14762
* gchem::
 
14763
* grefer::
 
14764
* gsoelim::
 
14765
* preconv::
 
14766
@end menu
 
14767
 
 
14768
 
 
14769
@c =====================================================================
 
14770
 
 
14771
@node geqn, gtbl, Preprocessors, Preprocessors
 
14772
@section @code{geqn}
 
14773
@cindex @code{eqn}, the program
 
14774
@cindex @code{geqn}, the program
 
14775
 
 
14776
@c XXX
 
14777
 
 
14778
@menu
 
14779
* Invoking geqn::
 
14780
@end menu
 
14781
 
 
14782
@c ---------------------------------------------------------------------
 
14783
 
 
14784
@node Invoking geqn,  , geqn, geqn
 
14785
@subsection Invoking @code{geqn}
 
14786
@cindex invoking @code{geqn}
 
14787
@cindex @code{geqn}, invoking
 
14788
 
 
14789
@c XXX
 
14790
 
 
14791
 
 
14792
@c =====================================================================
 
14793
 
 
14794
@node gtbl, gpic, geqn, Preprocessors
 
14795
@section @code{gtbl}
 
14796
@cindex @code{tbl}, the program
 
14797
@cindex @code{gtbl}, the program
 
14798
 
 
14799
@c XXX
 
14800
 
 
14801
@menu
 
14802
* Invoking gtbl::
 
14803
@end menu
 
14804
 
 
14805
@c ---------------------------------------------------------------------
 
14806
 
 
14807
@node Invoking gtbl,  , gtbl, gtbl
 
14808
@subsection Invoking @code{gtbl}
 
14809
@cindex invoking @code{gtbl}
 
14810
@cindex @code{gtbl}, invoking
 
14811
 
 
14812
@c XXX
 
14813
 
 
14814
 
 
14815
@c =====================================================================
 
14816
 
 
14817
@node gpic, ggrn, gtbl, Preprocessors
 
14818
@section @code{gpic}
 
14819
@cindex @code{pic}, the program
 
14820
@cindex @code{gpic}, the program
 
14821
 
 
14822
@c XXX
 
14823
 
 
14824
@menu
 
14825
* Invoking gpic::
 
14826
@end menu
 
14827
 
 
14828
@c ---------------------------------------------------------------------
 
14829
 
 
14830
@node Invoking gpic,  , gpic, gpic
 
14831
@subsection Invoking @code{gpic}
 
14832
@cindex invoking @code{gpic}
 
14833
@cindex @code{gpic}, invoking
 
14834
 
 
14835
@c XXX
 
14836
 
 
14837
 
 
14838
@c =====================================================================
 
14839
 
 
14840
@node ggrn, grap, gpic, Preprocessors
 
14841
@section @code{ggrn}
 
14842
@cindex @code{grn}, the program
 
14843
@cindex @code{ggrn}, the program
 
14844
 
 
14845
@c XXX
 
14846
 
 
14847
@menu
 
14848
* Invoking ggrn::
 
14849
@end menu
 
14850
 
 
14851
@c ---------------------------------------------------------------------
 
14852
 
 
14853
@node Invoking ggrn,  , ggrn, ggrn
 
14854
@subsection Invoking @code{ggrn}
 
14855
@cindex invoking @code{ggrn}
 
14856
@cindex @code{ggrn}, invoking
 
14857
 
 
14858
@c XXX
 
14859
 
 
14860
 
 
14861
@c =====================================================================
 
14862
 
 
14863
@node grap, gchem, ggrn, Preprocessors
 
14864
@section @code{grap}
 
14865
@cindex @code{grap}, the program
 
14866
 
 
14867
A free implementation of @code{grap}, written by Ted Faber,
 
14868
is available as an extra package from the following address:
 
14869
 
 
14870
@display
 
14871
@uref{http://www.lunabase.org/~faber/Vault/software/grap/}
 
14872
@end display
 
14873
 
 
14874
 
 
14875
@c =====================================================================
 
14876
 
 
14877
@node gchem, grefer, grap, Preprocessors
 
14878
@section @code{gchem}
 
14879
@cindex @code{chem}, the program
 
14880
@cindex @code{gchem}, the program
 
14881
 
 
14882
@c XXX
 
14883
 
 
14884
@menu
 
14885
* Invoking gchem::
 
14886
@end menu
 
14887
 
 
14888
@c ---------------------------------------------------------------------
 
14889
 
 
14890
@node Invoking gchem,  , gchem, gchem
 
14891
@subsection Invoking @code{gchem}
 
14892
@cindex invoking @code{gchem}
 
14893
@cindex @code{gchem}, invoking
 
14894
 
 
14895
@c XXX
 
14896
 
 
14897
 
 
14898
@c =====================================================================
 
14899
 
 
14900
@node grefer, gsoelim, gchem, Preprocessors
 
14901
@section @code{grefer}
 
14902
@cindex @code{refer}, the program
 
14903
@cindex @code{grefer}, the program
 
14904
 
 
14905
@c XXX
 
14906
 
 
14907
@menu
 
14908
* Invoking grefer::
 
14909
@end menu
 
14910
 
 
14911
@c ---------------------------------------------------------------------
 
14912
 
 
14913
@node Invoking grefer,  , grefer, grefer
 
14914
@subsection Invoking @code{grefer}
 
14915
@cindex invoking @code{grefer}
 
14916
@cindex @code{grefer}, invoking
 
14917
 
 
14918
@c XXX
 
14919
 
 
14920
 
 
14921
@c =====================================================================
 
14922
 
 
14923
@node gsoelim, preconv, grefer, Preprocessors
 
14924
@section @code{gsoelim}
 
14925
@cindex @code{soelim}, the program
 
14926
@cindex @code{gsoelim}, the program
 
14927
 
 
14928
@c XXX
 
14929
 
 
14930
@menu
 
14931
* Invoking gsoelim::
 
14932
@end menu
 
14933
 
 
14934
@c ---------------------------------------------------------------------
 
14935
 
 
14936
@node Invoking gsoelim,  , gsoelim, gsoelim
 
14937
@subsection Invoking @code{gsoelim}
 
14938
@cindex invoking @code{gsoelim}
 
14939
@cindex @code{gsoelim}, invoking
 
14940
 
 
14941
@c XXX
 
14942
 
 
14943
 
 
14944
@c =====================================================================
 
14945
 
 
14946
@node preconv,  , gsoelim, Preprocessors
 
14947
@section @code{preconv}
 
14948
@cindex @code{preconv}, the program
 
14949
 
 
14950
@c XXX
 
14951
 
 
14952
@menu
 
14953
* Invoking preconv::
 
14954
@end menu
 
14955
 
 
14956
@c ---------------------------------------------------------------------
 
14957
 
 
14958
@node Invoking preconv,  , preconv, preconv
 
14959
@subsection Invoking @code{preconv}
 
14960
@cindex invoking @code{preconv}
 
14961
@cindex @code{preconv}, invoking
 
14962
 
 
14963
@c XXX
 
14964
 
 
14965
 
 
14966
@c =====================================================================
 
14967
@c =====================================================================
 
14968
 
 
14969
@node Output Devices, File formats, Preprocessors, Top
 
14970
@chapter Output Devices
 
14971
@cindex output devices
 
14972
@cindex devices for output
 
14973
 
 
14974
@c XXX
 
14975
 
 
14976
@menu
 
14977
* Special Characters::
 
14978
* grotty::
 
14979
* grops::
 
14980
* gropdf::
 
14981
* grodvi::
 
14982
* grolj4::
 
14983
* grolbp::
 
14984
* grohtml::
 
14985
* gxditview::
 
14986
@end menu
 
14987
 
 
14988
 
 
14989
@c =====================================================================
 
14990
 
 
14991
@node Special Characters, grotty, Output Devices, Output Devices
 
14992
@section Special Characters
 
14993
@cindex special characters
 
14994
@cindex characters, special
 
14995
 
 
14996
@c XXX
 
14997
 
 
14998
@xref{Font Files}.
 
14999
 
 
15000
 
 
15001
@c =====================================================================
 
15002
 
 
15003
@node grotty, grops, Special Characters, Output Devices
 
15004
@section @code{grotty}
 
15005
@cindex @code{grotty}, the program
 
15006
 
 
15007
The postprocessor @code{grotty} translates the output from GNU
 
15008
@code{troff} into a form suitable for typewriter-like devices.  It is
 
15009
fully documented on its manual page, @cite{grotty(1)}.
 
15010
 
 
15011
@menu
 
15012
* Invoking grotty::
 
15013
@end menu
 
15014
 
 
15015
@c ---------------------------------------------------------------------
 
15016
 
 
15017
@node Invoking grotty,  , grotty, grotty
 
15018
@subsection Invoking @code{grotty}
 
15019
@cindex invoking @code{grotty}
 
15020
@cindex @code{grotty}, invoking
 
15021
 
 
15022
The postprocessor @command{grotty} accepts the following command-line
 
15023
options:
 
15024
 
 
15025
@table @option
 
15026
@item -b
 
15027
Do not overstrike bold glyphs.  Ignored if @option{-c} isn't used.
 
15028
 
 
15029
@item -B
 
15030
Do not underline bold-italic glyphs.  Ignored if @option{-c} isn't
 
15031
used.
 
15032
 
 
15033
@item -c
 
15034
Use overprint and disable colours for printing on legacy Teletype
 
15035
printers (see below).
 
15036
 
 
15037
@item -d
 
15038
Do not render lines (this is, ignore all @code{\D} escapes).
 
15039
 
 
15040
@item -f
 
15041
Use form feed control characters in the output.
 
15042
 
 
15043
@item -F@var{dir}
 
15044
Put the directory @file{@var{dir}/dev@var{name}} in front of the
 
15045
search path for the font and device description files, given the
 
15046
target device @var{name}.
 
15047
 
 
15048
@item -h
 
15049
Use horizontal tabs for sequences of 8 space characters.
 
15050
 
 
15051
@item -i
 
15052
Request italic glyphs from the terminal.  Ignored if @option{-c} is
 
15053
active.
 
15054
 
 
15055
@item -o
 
15056
Do not overstrike.
 
15057
 
 
15058
@item -r
 
15059
Highlight italic glyphs.  Ignored if @option{-c} is active.
 
15060
 
 
15061
@item -u
 
15062
Do not underline italic glyphs.  Ignored if @option{-c} isn't used.
 
15063
 
 
15064
@item -U
 
15065
Do not overstrike bold-italic glyphs.  Ignored if @option{-c} isn't
 
15066
used.
 
15067
 
 
15068
@item -v
 
15069
Print the version number.
 
15070
@end table
 
15071
 
 
15072
@pindex less
 
15073
@cindex Teletype
 
15074
@cindex ISO 6249 SGR
 
15075
@cindex terminal control sequences
 
15076
@cindex control sequences, for terminals
 
15077
The @option{-c} mode for TTY output devices means that underlining is
 
15078
done by emitting sequences of @samp{_} and @samp{^H} (the backspace
 
15079
character) before the actual character.  Literally, this is printing
 
15080
an underline character, then moving the caret back one character
 
15081
position, and printing the actual character at the same position as
 
15082
the underline character (similar to a typewriter).  Usually, a modern
 
15083
terminal can't interpret this (and the original Teletype machines for
 
15084
which this sequence was appropriate are no longer in use).  You need
 
15085
a pager program like @code{less} which translates this into
 
15086
ISO@tie{}6429 SGR sequences to control terminals.
 
15087
 
 
15088
 
 
15089
@c =====================================================================
 
15090
 
 
15091
@node grops, gropdf, grotty, Output Devices
 
15092
@section @code{grops}
 
15093
@cindex @code{grops}, the program
 
15094
 
 
15095
The postprocessor @command{grops} translates the output from GNU
 
15096
@command{troff} into a form suitable for Adobe @sc{PostScript}
 
15097
devices.  It is fully documented on its manual page, @cite{grops(1)}.
 
15098
 
 
15099
 
 
15100
@menu
 
15101
* Invoking grops::
 
15102
* Embedding PostScript::
 
15103
@end menu
 
15104
 
 
15105
@c ---------------------------------------------------------------------
 
15106
 
 
15107
@node Invoking grops, Embedding PostScript, grops, grops
 
15108
@subsection Invoking @code{grops}
 
15109
@cindex invoking @code{grops}
 
15110
@cindex @code{grops}, invoking
 
15111
 
 
15112
The postprocessor @code{grops} accepts the following command-line
 
15113
options:
 
15114
 
 
15115
@table @option
 
15116
@item -b@var{flags}
 
15117
Use backward compatibility settings given by @var{flags} as
 
15118
documented in the @cite{grops(1)} manual page.  Overrides the command
 
15119
@option{broken} in the @file{DESC} file.
 
15120
 
 
15121
@item -c@var{n}
 
15122
Print @var{n} copies of each page.
 
15123
 
 
15124
@item -F@var{dir}
 
15125
Put the directory @file{@var{dir}/dev@var{name}} in front of the
 
15126
search path for the font, prologue and device description files,
 
15127
given the target device @var{name}, usually @strong{ps}.
 
15128
 
 
15129
@item -g
 
15130
Tell the printer to guess the page length.  Useful for printing
 
15131
vertically centered pages when the paper dimensions are determined at
 
15132
print time.
 
15133
 
 
15134
@item -I@var{path} @dots{}
 
15135
Consider the directory @file{@var{path}} for searching included files
 
15136
specified with relative paths.  The current directory is searched as
 
15137
fallback.
 
15138
 
 
15139
@item -l
 
15140
Use landscape orientation.
 
15141
 
 
15142
@item -m
 
15143
Use manual feed.
 
15144
 
 
15145
@item -p@var{papersize}
 
15146
Set the page dimensions.  Overrides the commands @option{papersize},
 
15147
@option{paperlength}, and @option{paperwidth} in the @file{DESC}
 
15148
file.  See the @cite{groff_font(5)} manual page for details.
 
15149
 
 
15150
@item -P@var{prologue}
 
15151
Use the @var{prologue} in the font path as the prologue instead of
 
15152
the default @file{prologue}.  Overrides the environment variable
 
15153
@env{GROPS_PROLOGUE}.
 
15154
 
 
15155
@item -w@var{n}
 
15156
Set the line thickness to @var{n}/1000@dmn{em}.  Overrides the
 
15157
default value @var{n} = 40.
 
15158
 
 
15159
@item -v
 
15160
Print the version number.
 
15161
@end table
 
15162
 
 
15163
@c ---------------------------------------------------------------------
 
15164
 
 
15165
@node Embedding PostScript,  , Invoking grops, grops
 
15166
@subsection Embedding @sc{PostScript}
 
15167
@cindex embedding PostScript
 
15168
@cindex PostScript, embedding
 
15169
 
 
15170
The escape sequence
 
15171
 
 
15172
@code{\X'ps: import @var{file} @var{llx} @var{lly} @var{urx} @var{ury}
 
15173
  @var{width} [@var{height}]'}
 
15174
 
 
15175
@noindent
 
15176
places a rectangle of the specified @var{width} containing the
 
15177
@sc{PostScript} drawing from file @var{file} bound by the box from
 
15178
@var{llx} @var{lly} to @var{urx} @var{ury} (in @sc{PostScript}
 
15179
coordinates) at the insertion point.  If @var{height} is not
 
15180
specified, the embedded drawing is scaled proportionally.
 
15181
 
 
15182
@xref{Miscellaneous}, for the @code{psbb} request which automatically
 
15183
generates the bounding box.
 
15184
 
 
15185
This escape sequence is used internally by the macro @code{PSPIC}
 
15186
(see the @cite{groff_tmac(5)} manual page).
 
15187
 
 
15188
 
 
15189
@c =====================================================================
 
15190
 
 
15191
@node gropdf, grodvi, grops, Output Devices
 
15192
@section @code{gropdf}
 
15193
@cindex @code{gropdf}, the program
 
15194
 
 
15195
The postprocessor @command{gropdf} translates the output from GNU
 
15196
@command{troff} into a form suitable for Adobe PDF devices.  It is fully
 
15197
documented on its manual page, @cite{gropdf(1)}.
 
15198
 
 
15199
@menu
 
15200
* Invoking gropdf::
 
15201
* Embedding PDF::
 
15202
@end menu
 
15203
 
 
15204
@c ---------------------------------------------------------------------
 
15205
 
 
15206
@node Invoking gropdf, Embedding PDF, gropdf, gropdf
 
15207
@subsection Invoking @code{gropdf}
 
15208
@cindex invoking @code{gropdf}
 
15209
@cindex @code{gropdf}, invoking
 
15210
 
 
15211
The postprocessor @code{gropdf} accepts the following command-line
 
15212
options:
 
15213
 
 
15214
@table @option
 
15215
@item -d
 
15216
Produce uncompressed PDFs which include debugging comments.
 
15217
 
 
15218
@item -e
 
15219
This forces @code{gropdf} to embed all used fonts in the PDF,
 
15220
even if they are one of the 14 base Adobe fonts.
 
15221
 
 
15222
@item -F@var{dir}
 
15223
Put the directory @file{@var{dir}/dev@var{name}} in front of the
 
15224
search path for the font, prologue and device description files,
 
15225
given the target device @var{name}, usually @strong{pdf}.
 
15226
 
 
15227
@item -y@var{foundry}
 
15228
This forces the use of a different font foundry.
 
15229
 
 
15230
@item -l
 
15231
Use landscape orientation.
 
15232
 
 
15233
@item -p@var{papersize}
 
15234
Set the page dimensions.  Overrides the commands @option{papersize},
 
15235
@option{paperlength}, and @option{paperwidth} in the @file{DESC}
 
15236
file.  See the @cite{groff_font(5)} manual page for details.
 
15237
 
 
15238
@item -v
 
15239
Print the version number.
 
15240
 
 
15241
@item -s
 
15242
Append a comment line to end of PDF showing statistics, i.e. number of
 
15243
pages in document.  Ghostscript's @cite{ps2pdf(1)} complains about this
 
15244
line if it is included, but works anyway.
 
15245
 
 
15246
@item -u@var{filename}
 
15247
@code{gropdf} normally includes a ToUnicode CMap with any font created
 
15248
using @file{text.enc} as the encoding file, this makes it easier to
 
15249
search for words which contain ligatures.  You can include your own CMap
 
15250
by specifying a @var{filename} or have no CMap at all by omitting the
 
15251
@var{filename}.
 
15252
@end table
 
15253
 
 
15254
@c ---------------------------------------------------------------------
 
15255
 
 
15256
@node Embedding PDF,  , Invoking gropdf, gropdf
 
15257
@subsection Embedding PDF
 
15258
@cindex embedding PDF
 
15259
@cindex PDF, embedding
 
15260
 
 
15261
The escape sequence
 
15262
 
 
15263
@code{\X'pdf: pdfpic @var{file} @var{alignment} @var{width} [@var{height}]
 
15264
  [@var{linelength}]'}
 
15265
 
 
15266
@noindent
 
15267
places a rectangle of the specified @var{width} containing the PDF
 
15268
drawing from file @var{file} of desired @var{width} and @var{height} (if
 
15269
@var{height} is missing or zero then it is scaled proportionally).  If
 
15270
@var{alignment} is @code{-L} the drawing is left aligned.  If it is
 
15271
@code{-C} or @code{-R} a @var{linelength} greater than the width of the
 
15272
drawing is required as well.  If @var{width} is specified as zero then
 
15273
the width is scaled in proportion to the height.
 
15274
 
 
15275
 
 
15276
@c =====================================================================
 
15277
 
 
15278
@node grodvi, grolj4, gropdf, Output Devices
 
15279
@section @code{grodvi}
 
15280
@cindex @code{grodvi}, the program
 
15281
 
 
15282
The postprocessor @command{grodvi} translates the output from GNU
 
15283
@command{troff} into the @strong{DVI} output format compatible with
 
15284
the @strong{@TeX{}} document preparation system.  It is fully
 
15285
documented on its manual page, @cite{grodvi(1)}.
 
15286
 
 
15287
@menu
 
15288
* Invoking grodvi::
 
15289
@end menu
 
15290
 
 
15291
@c ---------------------------------------------------------------------
 
15292
 
 
15293
@node Invoking grodvi,  , grodvi, grodvi
 
15294
@subsection Invoking @code{grodvi}
 
15295
@cindex invoking @code{grodvi}
 
15296
@cindex @code{grodvi}, invoking
 
15297
 
 
15298
The postprocessor @code{grodvi} accepts the following command-line
 
15299
options:
 
15300
 
 
15301
@table @option
 
15302
@item -d
 
15303
Do not use @strong{tpic} specials to implement drawing commands.
 
15304
 
 
15305
@item -F@var{dir}
 
15306
Put the directory @file{@var{dir}/dev@var{name}} in front of the
 
15307
search path for the font and device description files, given the
 
15308
target device @var{name}, usually @strong{dvi}.
 
15309
 
 
15310
@item -l
 
15311
Use landscape orientation.
 
15312
 
 
15313
@item -p@var{papersize}
 
15314
Set the page dimensions.  Overrides the commands @option{papersize},
 
15315
@option{paperlength}, and @option{paperwidth} in the @file{DESC}
 
15316
file.  See @cite{groff_font(5)} manual page for details.
 
15317
 
 
15318
@item -v
 
15319
Print the version number.
 
15320
 
 
15321
@item -w@var{n}
 
15322
Set the line thickness to @var{n}/1000@dmn{em}.  Overrides the
 
15323
default value @var{n} = 40.
 
15324
@end table
 
15325
 
 
15326
 
 
15327
@c =====================================================================
 
15328
 
 
15329
@node grolj4, grolbp, grodvi, Output Devices
 
15330
@section @code{grolj4}
 
15331
@cindex @code{grolj4}, the program
 
15332
 
 
15333
The postprocessor @command{grolj4} translates the output from GNU
 
15334
@command{troff} into the @strong{PCL5} output format suitable for
 
15335
printing on a @strong{HP LaserJet@tie{}4} printer.  It is fully
 
15336
documented on its manual page, @cite{grolj4(1)}.
 
15337
 
 
15338
@menu
 
15339
* Invoking grolj4::
 
15340
@end menu
 
15341
 
 
15342
@c ---------------------------------------------------------------------
 
15343
 
 
15344
@node Invoking grolj4,  , grolj4, grolj4
 
15345
@subsection Invoking @code{grolj4}
 
15346
@cindex invoking @code{grolj4}
 
15347
@cindex @code{grolj4}, invoking
 
15348
 
 
15349
The postprocessor @code{grolj4} accepts the following command-line
 
15350
options:
 
15351
 
 
15352
@table @option
 
15353
@item -c@var{n}
 
15354
Print @var{n} copies of each page.
 
15355
 
 
15356
@item -F@var{dir}
 
15357
Put the directory @file{@var{dir}/dev@var{name}} in front of the
 
15358
search path for the font and device description files, given the
 
15359
target device @var{name}, usually @strong{lj4}.
 
15360
 
 
15361
@item -l
 
15362
Use landscape orientation.
 
15363
 
 
15364
@item -p@var{size}
 
15365
Set the page dimensions.  Valid values for @var{size} are:
 
15366
@code{letter}, @code{legal}, @code{executive}, @code{a4},
 
15367
@code{com10}, @code{monarch}, @code{c5}, @code{b5}, @code{d1}.
 
15368
 
 
15369
@item -v
 
15370
Print the version number.
 
15371
 
 
15372
@item -w@var{n}
 
15373
Set the line thickness to @var{n}/1000@dmn{em}.  Overrides the
 
15374
default value @var{n} = 40.
 
15375
@end table
 
15376
 
 
15377
The special drawing command @code{\D'R @var{dh} @var{dv}'} draws a
 
15378
horizontal rectangle from the current position to the position at
 
15379
offset (@var{dh},@var{dv}).
 
15380
 
 
15381
 
 
15382
@c =====================================================================
 
15383
 
 
15384
@node grolbp, grohtml, grolj4, Output Devices
 
15385
@section @code{grolbp}
 
15386
@cindex @code{grolbp}, the program
 
15387
 
 
15388
The postprocessor @command{grolbp} translates the output from GNU
 
15389
@command{troff} into the @strong{LBP} output format suitable for
 
15390
printing on @strong{Canon CAPSL} printers.  It is fully documented on
 
15391
its manual page, @cite{grolbp(1)}.
 
15392
 
 
15393
@menu
 
15394
* Invoking grolbp::
 
15395
@end menu
 
15396
 
 
15397
@c ---------------------------------------------------------------------
 
15398
 
 
15399
@node Invoking grolbp,  , grolbp, grolbp
 
15400
@subsection Invoking @code{grolbp}
 
15401
@cindex invoking @code{grolbp}
 
15402
@cindex @code{grolbp}, invoking
 
15403
 
 
15404
The postprocessor @code{grolbp} accepts the following command-line
 
15405
options:
 
15406
 
 
15407
@table @option
 
15408
@item -c@var{n}
 
15409
Print @var{n} copies of each page.
 
15410
 
 
15411
@item -F@var{dir}
 
15412
Put the directory @file{@var{dir}/dev@var{name}} in front of the
 
15413
search path for the font, prologue and device description files,
 
15414
given the target device @var{name}, usually @strong{lbp}.
 
15415
 
 
15416
@item -l
 
15417
Use landscape orientation.
 
15418
 
 
15419
@item -o@var{orientation}
 
15420
Use the @var{orientation} specified: @code{portrait} or
 
15421
@code{landscape}.
 
15422
 
 
15423
@item -p@var{papersize}
 
15424
Set the page dimensions.  See @cite{groff_font(5)} manual page for
 
15425
details.
 
15426
 
 
15427
@item -w@var{n}
 
15428
Set the line thickness to @var{n}/1000@dmn{em}.  Overrides the
 
15429
default value @var{n} = 40.
 
15430
 
 
15431
@item -v
 
15432
Print the version number.
 
15433
 
 
15434
@item -h
 
15435
Print command-line help.
 
15436
@end table
 
15437
 
 
15438
 
 
15439
@c =====================================================================
 
15440
 
 
15441
@node grohtml, gxditview, grolbp, Output Devices
 
15442
@section @code{grohtml}
 
15443
@cindex @code{grohtml}, the program
 
15444
 
 
15445
The @code{grohtml} front end (which consists of a preprocessor,
 
15446
@code{pre-grohtml}, and a device driver, @code{post-grohtml}) translates
 
15447
the output of GNU @code{troff} to @acronym{HTML}.  Users should always
 
15448
invoke @code{grohtml} via the @code{groff} command with a @code{\-Thtml}
 
15449
option.  If no files are given, @code{grohtml} will read the standard
 
15450
input.  A filename of @code{-} will also cause @code{grohtml} to read
 
15451
the standard input.  @acronym{HTML} output is written to the standard
 
15452
output.  When @code{grohtml} is run by @code{groff}, options can be
 
15453
passed to @code{grohtml} using @code{groff}'s @option{-P} option.
 
15454
 
 
15455
@code{grohtml} invokes @code{groff} twice.  In the first pass, pictures,
 
15456
equations, and tables are rendered using the @code{ps} device, and in
 
15457
the second pass @acronym{HTML} output is generated by the @code{html}
 
15458
device.
 
15459
 
 
15460
@code{grohtml} always writes output in @code{UTF-8} encoding and has
 
15461
built-in entities for all non-composite unicode characters.  In spite of
 
15462
this, @code{groff} may issue warnings about unknown special characters
 
15463
if they can't be found during the first pass.  Such warnings can be
 
15464
safely ignored unless the special characters appear inside a table or
 
15465
equation, in which case glyphs for these characters must be defined for
 
15466
the @code{ps} device as well.
 
15467
 
 
15468
This output device is fully documented on its manual page,
 
15469
@cite{grohtml(1)}.
 
15470
 
 
15471
@menu
 
15472
* Invoking grohtml::
 
15473
* grohtml specific registers and strings::
 
15474
@end menu
 
15475
 
 
15476
@c ---------------------------------------------------------------------
 
15477
 
 
15478
@node Invoking grohtml, grohtml specific registers and strings, grohtml, grohtml
 
15479
@subsection Invoking @code{grohtml}
 
15480
@cindex invoking @code{grohtml}
 
15481
@cindex @code{grohtml}, invoking
 
15482
 
 
15483
The postprocessor @code{grohtml} accepts the following command-line
 
15484
options:
 
15485
 
 
15486
@table @option
 
15487
@item -a@var{bits}
 
15488
Use this number of @var{bits} (= 1, 2 or 4) for text antialiasing.
 
15489
Default: @var{bits} = 4.
 
15490
 
 
15491
@item -a0
 
15492
Do not use text antialiasing.
 
15493
 
 
15494
@item -b
 
15495
Use white background.
 
15496
 
 
15497
@item -D@var{dir}
 
15498
Store rendered images in the directory @file{@var{dir}}.
 
15499
 
 
15500
@item -F@var{dir}
 
15501
Put the directory @file{@var{dir}/dev@var{name}} in front of the
 
15502
search path for the font, prologue and device description files,
 
15503
given the target device @var{name}, usually @strong{html}.
 
15504
 
 
15505
@item -g@var{bits}
 
15506
Use this number of @var{bits} (= 1, 2 or 4) for antialiasing of
 
15507
drawings.  Default: @var{bits} = 4.
 
15508
 
 
15509
@item -g0
 
15510
Do not use antialiasing for drawings.
 
15511
 
 
15512
@item -h
 
15513
Use the @code{B} element for section headings.
 
15514
 
 
15515
@item -i@var{resolution}
 
15516
Use the @var{resolution} for rendered images.  Default:
 
15517
@var{resolution} = 100@dmn{dpi}.
 
15518
 
 
15519
@item -I@var{stem}
 
15520
Set the images' @var{stem name}.  Default: @var{stem} =
 
15521
@file{grohtml-@var{XXX}} (@var{XXX} is the process ID).
 
15522
 
 
15523
@item -j@var{stem}
 
15524
Place each section in a separate file called
 
15525
@file{@var{stem}-@var{n}.html} (where @var{n} is a generated section
 
15526
number).
 
15527
 
 
15528
@item -l
 
15529
Do not generate the table of contents.
 
15530
 
 
15531
@item -n
 
15532
Generate simple fragment identifiers.
 
15533
 
 
15534
@item -o@var{offset}
 
15535
Use vertical paddding @var{offset} for images.
 
15536
 
 
15537
@item -p
 
15538
Display the page rendering progress to @code{stderr}.
 
15539
 
 
15540
@item -r
 
15541
Do not use horizontal rules to separate headers and footers.
 
15542
 
 
15543
@item -s@var{size}
 
15544
Set the base font size, to be modified using the elements @code{BIG}
 
15545
and @code{SMALL}.
 
15546
 
 
15547
@item -S@var{level}
 
15548
Generate separate files for sections at level @var{level}.
 
15549
 
 
15550
@item -v
 
15551
Print the version number.
 
15552
 
 
15553
@item -V
 
15554
Generate a validator button at the bottom.
 
15555
 
 
15556
@item -y
 
15557
Generate a signature of groff after the validator button, if any.
 
15558
@end table
 
15559
 
 
15560
 
 
15561
@c ---------------------------------------------------------------------
 
15562
 
 
15563
@node grohtml specific registers and strings,  , Invoking grohtml, grohtml
 
15564
@subsection @code{grohtml} specific registers and strings
 
15565
@cindex registers specific to @code{grohtml}
 
15566
@cindex strings specific to @code{grohtml}
 
15567
@cindex @code{grohtml}, registers and strings
 
15568
 
 
15569
@DefmpregList {ps4html, grohtml}
 
15570
@DefstrListEnd {www-image-template, grohtml}
 
15571
The registers @code{ps4html} and @code{www-image-template} are defined
 
15572
by the @code{pre-grohtml} preprocessor.  @code{pre-grohtml} reads in the
 
15573
@code{troff} input, marks up the inline equations and passes the result
 
15574
firstly to
 
15575
 
 
15576
@Example
 
15577
troff -Tps -rps4html=1 -dwww-image-template=@var{template}
 
15578
@endExample
 
15579
 
 
15580
@noindent
 
15581
and secondly to
 
15582
 
 
15583
@Example
 
15584
troff -Thtml
 
15585
@endExample
 
15586
 
 
15587
@noindent
 
15588
or
 
15589
 
 
15590
@Example
 
15591
troff -Txhtml
 
15592
@endExample
 
15593
 
 
15594
@cindex MathML
 
15595
The @sc{PostScript} device is used to create all the image files (for
 
15596
@option{-Thtml}; if @option{-Txhtml} is used, all equations are passed
 
15597
to @code{geqn} to produce @acronym{MathML}, and the register
 
15598
@code{ps4html} enables the macro sets to ignore floating keeps, footers,
 
15599
and headings.
 
15600
 
 
15601
The register @code{www-image-template} is set to the user specified
 
15602
template name or the default name.
 
15603
@endDefmpreg
 
15604
 
 
15605
 
 
15606
@c =====================================================================
 
15607
 
 
15608
@node gxditview,  , grohtml, Output Devices
 
15609
@section @code{gxditview}
 
15610
@cindex @code{gxditview}, the program
 
15611
 
 
15612
@c XXX
 
15613
 
 
15614
@menu
 
15615
* Invoking gxditview::
 
15616
@end menu
 
15617
 
 
15618
@c ---------------------------------------------------------------------
 
15619
 
 
15620
@node Invoking gxditview,  , gxditview, gxditview
 
15621
@subsection Invoking @code{gxditview}
 
15622
@cindex invoking @code{gxditview}
 
15623
@cindex @code{gxditview}, invoking
 
15624
 
 
15625
@c XXX
 
15626
@c X11's xditview
 
15627
 
 
15628
 
 
15629
 
 
15630
@c =====================================================================
 
15631
@c =====================================================================
 
15632
 
 
15633
@node File formats, Installation, Output Devices, Top
 
15634
@chapter File formats
 
15635
@cindex file formats
 
15636
@cindex formats, file
 
15637
 
 
15638
All files read and written by @code{gtroff} are text files.  The
 
15639
following two sections describe their format.
 
15640
 
 
15641
@menu
 
15642
* gtroff Output::
 
15643
* Font Files::
 
15644
@end menu
 
15645
 
 
15646
 
 
15647
@c =====================================================================
 
15648
 
 
15649
@node gtroff Output, Font Files, File formats, File formats
 
15650
@section @code{gtroff} Output
 
15651
@cindex @code{gtroff}, output
 
15652
@cindex output, @code{gtroff}
 
15653
 
 
15654
This section describes the intermediate output format of GNU
 
15655
@code{troff}.  This output is produced by a run of @code{gtroff} before
 
15656
it is fed into a device postprocessor program.
 
15657
 
 
15658
As @code{groff} is a wrapper program around @code{gtroff} that
 
15659
automatically calls a postprocessor, this output does not show up
 
15660
normally.  This is why it is called @dfn{intermediate}.  @code{groff}
 
15661
provides the option @option{-Z} to inhibit postprocessing, such that the
 
15662
produced intermediate output is sent to standard output just like
 
15663
calling @code{gtroff} manually.
 
15664
 
 
15665
@cindex troff output
 
15666
@cindex output, troff
 
15667
@cindex intermediate output
 
15668
@cindex output, intermediate
 
15669
Here, the term @dfn{troff output} describes what is output by
 
15670
@code{gtroff}, while @dfn{intermediate output} refers to the language
 
15671
that is accepted by the parser that prepares this output for the
 
15672
postprocessors.  This parser is smarter on whitespace and implements
 
15673
obsolete elements for compatibility, otherwise both formats are the
 
15674
same.@footnote{The parser and postprocessor for intermediate output can
 
15675
be found in the file@*
 
15676
@file{@var{groff-source-dir}/src/libs/libdriver/input.cpp}.}
 
15677
 
 
15678
The main purpose of the intermediate output concept is to facilitate the
 
15679
development of postprocessors by providing a common programming
 
15680
interface for all devices.  It has a language of its own that is
 
15681
completely different from the @code{gtroff} language.  While the
 
15682
@code{gtroff} language is a high-level programming language for text
 
15683
processing, the intermediate output language is a kind of low-level
 
15684
assembler language by specifying all positions on the page for writing
 
15685
and drawing.
 
15686
 
 
15687
The intermediate output produced by @code{gtroff} is fairly readable,
 
15688
while output from @acronym{AT&T} @code{troff} is rather hard to
 
15689
understand because of strange habits that are still supported, but not
 
15690
used any longer by @code{gtroff}.
 
15691
 
 
15692
@menu
 
15693
* Language Concepts::
 
15694
* Command Reference::
 
15695
* Intermediate Output Examples::
 
15696
* Output Language Compatibility::
 
15697
@end menu
 
15698
 
 
15699
@c ---------------------------------------------------------------------
 
15700
 
 
15701
@node Language Concepts, Command Reference, gtroff Output, gtroff Output
 
15702
@subsection Language Concepts
 
15703
 
 
15704
During the run of @code{gtroff}, the input data is cracked down to the
 
15705
information on what has to be printed at what position on the intended
 
15706
device.  So the language of the intermediate output format can be quite
 
15707
small.  Its only elements are commands with and without arguments.  In
 
15708
this section, the term @dfn{command} always refers to the intermediate
 
15709
output language, and never to the @code{gtroff} language used for
 
15710
document formatting.  There are commands for positioning and text
 
15711
writing, for drawing, and for device controlling.
 
15712
 
 
15713
@menu
 
15714
* Separation::
 
15715
* Argument Units::
 
15716
* Document Parts::
 
15717
@end menu
 
15718
 
 
15719
@node Separation, Argument Units, Language Concepts, Language Concepts
 
15720
@subsubsection Separation
 
15721
 
 
15722
@acronym{AT&T} @code{troff} output has strange requirements on
 
15723
whitespace.  The @code{gtroff} output parser, however, is smart about
 
15724
whitespace by making it maximally optional.  The whitespace characters,
 
15725
i.e., the tab, space, and newline characters, always have a syntactical
 
15726
meaning.  They are never printable because spacing within the output is
 
15727
always done by positioning commands.
 
15728
 
 
15729
Any sequence of space or tab characters is treated as a single
 
15730
@dfn{syntactical space}.  It separates commands and arguments, but is
 
15731
only required when there would occur a clashing between the command code
 
15732
and the arguments without the space.  Most often, this happens when
 
15733
variable-length command names, arguments, argument lists, or command
 
15734
clusters meet.  Commands and arguments with a known, fixed length need
 
15735
not be separated by syntactical space.
 
15736
 
 
15737
A line break is a syntactical element, too.  Every command argument can
 
15738
be followed by whitespace, a comment, or a newline character.  Thus a
 
15739
@dfn{syntactical line break} is defined to consist of optional
 
15740
syntactical space that is optionally followed by a comment, and a
 
15741
newline character.
 
15742
 
 
15743
The normal commands, those for positioning and text, consist of a single
 
15744
letter taking a fixed number of arguments.  For historical reasons, the
 
15745
parser allows to stack such commands on the same line, but fortunately,
 
15746
in @code{gtroff}'s intermediate output, every command with at least one
 
15747
argument is followed by a line break, thus providing excellent
 
15748
readability.
 
15749
 
 
15750
The other commands -- those for drawing and device controlling -- have a
 
15751
more complicated structure; some recognize long command names, and some
 
15752
take a variable number of arguments.  So all @samp{D} and @samp{x}
 
15753
commands were designed to request a syntactical line break after their
 
15754
last argument.  Only one command, @w{@samp{x X}}, has an argument that
 
15755
can stretch over several lines; all other commands must have all of
 
15756
their arguments on the same line as the command, i.e., the arguments may
 
15757
not be split by a line break.
 
15758
 
 
15759
Empty lines (these are lines containing only space and/or a comment),
 
15760
can occur everywhere.  They are just ignored.
 
15761
 
 
15762
@node Argument Units, Document Parts, Separation, Language Concepts
 
15763
@subsubsection Argument Units
 
15764
 
 
15765
Some commands take integer arguments that are assumed to represent
 
15766
values in a measurement unit, but the letter for the corresponding scale
 
15767
indicator is not written with the output command arguments.  Most
 
15768
commands assume the scale indicator @samp{u}, the basic unit of the
 
15769
device, some use @samp{z}, the scaled point unit of the device, while
 
15770
others, such as the color commands, expect plain integers.
 
15771
 
 
15772
Note that single characters can have the eighth bit set, as can the
 
15773
names of fonts and special characters.  The names of characters and
 
15774
fonts can be of arbitrary length.  A character that is to be printed is
 
15775
always in the current font.
 
15776
 
 
15777
A string argument is always terminated by the next whitespace character
 
15778
(space, tab, or newline); an embedded @samp{#} character is regarded as
 
15779
part of the argument, not as the beginning of a comment command.  An
 
15780
integer argument is already terminated by the next non-digit character,
 
15781
which then is regarded as the first character of the next argument or
 
15782
command.
 
15783
 
 
15784
@node Document Parts,  , Argument Units, Language Concepts
 
15785
@subsubsection Document Parts
 
15786
 
 
15787
A correct intermediate output document consists of two parts, the
 
15788
@dfn{prologue} and the @dfn{body}.
 
15789
 
 
15790
The task of the prologue is to set the general device parameters using
 
15791
three exactly specified commands.  @code{gtroff}'s prologue is
 
15792
guaranteed to consist of the following three lines (in that order):
 
15793
 
 
15794
@Example
 
15795
x T @var{device}
 
15796
x res @var{n} @var{h} @var{v}
 
15797
x init
 
15798
@endExample
 
15799
 
 
15800
@noindent
 
15801
with the arguments set as outlined in @ref{Device Control Commands}.
 
15802
Note that the parser for the intermediate output format is able to
 
15803
swallow additional whitespace and comments as well even in the prologue.
 
15804
 
 
15805
The body is the main section for processing the document data.
 
15806
Syntactically, it is a sequence of any commands different from the ones
 
15807
used in the prologue.  Processing is terminated as soon as the first
 
15808
@w{@samp{x stop}} command is encountered; the last line of any
 
15809
@code{gtroff} intermediate output always contains such a command.
 
15810
 
 
15811
Semantically, the body is page oriented.  A new page is started by a
 
15812
@samp{p} command.  Positioning, writing, and drawing commands are always
 
15813
done within the current page, so they cannot occur before the first
 
15814
@samp{p} command.  Absolute positioning (by the @samp{H} and @samp{V}
 
15815
commands) is done relative to the current page; all other positioning is
 
15816
done relative to the current location within this page.
 
15817
 
 
15818
@c ---------------------------------------------------------------------
 
15819
 
 
15820
@node Command Reference, Intermediate Output Examples, Language Concepts, gtroff Output
 
15821
@subsection Command Reference
 
15822
 
 
15823
This section describes all intermediate output commands, both from
 
15824
@acronym{AT&T} @code{troff} as well as the @code{gtroff} extensions.
 
15825
 
 
15826
@menu
 
15827
* Comment Command::
 
15828
* Simple Commands::
 
15829
* Graphics Commands::
 
15830
* Device Control Commands::
 
15831
* Obsolete Command::
 
15832
@end menu
 
15833
 
 
15834
@node Comment Command, Simple Commands, Command Reference, Command Reference
 
15835
@subsubsection Comment Command
 
15836
 
 
15837
@table @code
 
15838
@item #@var{anything}@angles{end of line}
 
15839
A comment.  Ignore any characters from the @samp{#} character up to the
 
15840
next newline character.
 
15841
 
 
15842
This command is the only possibility for commenting in the intermediate
 
15843
output.  Each comment can be preceded by arbitrary syntactical space;
 
15844
every command can be terminated by a comment.
 
15845
@end table
 
15846
 
 
15847
@node Simple Commands, Graphics Commands, Comment Command, Command Reference
 
15848
@subsubsection Simple Commands
 
15849
 
 
15850
The commands in this subsection have a command code consisting of a
 
15851
single character, taking a fixed number of arguments.  Most of them are
 
15852
commands for positioning and text writing.  These commands are smart
 
15853
about whitespace.  Optionally, syntactical space can be inserted before,
 
15854
after, and between the command letter and its arguments.  All of these
 
15855
commands are stackable, i.e., they can be preceded by other simple
 
15856
commands or followed by arbitrary other commands on the same line.  A
 
15857
separating syntactical space is only necessary when two integer
 
15858
arguments would clash or if the preceding argument ends with a string
 
15859
argument.
 
15860
 
 
15861
@table @code
 
15862
@ignore
 
15863
.if (\n[@USE_ENV_STACK] == 1) \{\
 
15864
.command {
 
15865
Open a new environment by copying the actual device configuration data
 
15866
to the environment stack.
 
15867
.
 
15868
The current environment is setup by the device specification and
 
15869
manipulated by the setting commands.
 
15870
.
 
15871
.
 
15872
.command }
 
15873
Close the actual environment (opened by a preceding
 
15874
.BR { \~command)
 
15875
and restore the previous environment from the environment
 
15876
stack as the actual device configuration data.
 
15877
.
 
15878
\}              \" endif @USE_ENV_STACK
 
15879
@end ignore
 
15880
 
 
15881
@item C @var{xxx}@angles{whitespace}
 
15882
Print a special character named @var{xxx}.  The trailing syntactical
 
15883
space or line break is necessary to allow glyph names of arbitrary
 
15884
length.  The glyph is printed at the current print position; the glyph's
 
15885
size is read from the font file.  The print position is not changed.
 
15886
 
 
15887
@item c @var{g}
 
15888
Print glyph@tie{}@var{g} at the current print
 
15889
position;@footnote{@samp{c} is actually a misnomer since it outputs a
 
15890
glyph.} the glyph's size is read from the font file.  The print position
 
15891
is not changed.
 
15892
 
 
15893
@item f @var{n}
 
15894
Set font to font number@tie{}@var{n} (a non-negative integer).
 
15895
 
 
15896
@item H @var{n}
 
15897
Move right to the absolute vertical position@tie{}@var{n} (a
 
15898
non-negative integer in basic units @samp{u} relative to left edge of
 
15899
current page.
 
15900
 
 
15901
@item h @var{n}
 
15902
Move @var{n} (a non-negative integer) basic units @samp{u} horizontally
 
15903
to the right.  The original @acronym{UNIX} troff manual allows negative
 
15904
values for @var{n} also, but @code{gtroff} doesn't use this.
 
15905
 
 
15906
@item m @var{color-scheme} @r{[}@var{component} @dots{}@r{]}
 
15907
Set the color for text (glyphs), line drawing, and the outline of
 
15908
graphic objects using different color schemes; the analoguous command
 
15909
for the filling color of graphic objects is @samp{DF}.  The color
 
15910
components are specified as integer arguments between 0 and 65536.  The
 
15911
number of color components and their meaning vary for the different
 
15912
color schemes.  These commands are generated by @code{gtroff}'s escape
 
15913
sequence @code{\m}.  No position changing.  These commands are a
 
15914
@code{gtroff} extension.
 
15915
 
 
15916
@table @code
 
15917
@item mc @var{cyan} @var{magenta} @var{yellow}
 
15918
Set color using the CMY color scheme, having the 3@tie{}color components
 
15919
@var{cyan}, @var{magenta}, and @var{yellow}.
 
15920
 
 
15921
@item md
 
15922
Set color to the default color value (black in most cases).  No
 
15923
component arguments.
 
15924
 
 
15925
@item mg @var{gray}
 
15926
Set color to the shade of gray given by the argument, an integer between
 
15927
0 (black) and 65536 (white).
 
15928
 
 
15929
@item mk @var{cyan} @var{magenta} @var{yellow} @var{black}
 
15930
Set color using the CMYK color scheme, having the 4@tie{}color
 
15931
components @var{cyan}, @var{magenta}, @var{yellow}, and @var{black}.
 
15932
 
 
15933
@item mr @var{red} @var{green} @var{blue}
 
15934
Set color using the RGB color scheme, having the 3@tie{}color components
 
15935
@var{red}, @var{green}, and @var{blue}.
 
15936
@end table
 
15937
 
 
15938
@item N @var{n}
 
15939
Print glyph with index@tie{}@var{n} (a non-negative integer) of the
 
15940
current font.  This command is a @code{gtroff} extension.
 
15941
 
 
15942
@item n @var{b} @var{a}
 
15943
Inform the device about a line break, but no positioning is done by this
 
15944
command.  In @acronym{AT&T} @code{troff}, the integer arguments @var{b}
 
15945
and@tie{}@var{a} informed about the space before and after the current
 
15946
line to make the intermediate output more human readable without
 
15947
performing any action.  In @code{groff}, they are just ignored, but they
 
15948
must be provided for compatibility reasons.
 
15949
 
 
15950
@item p @var{n}
 
15951
Begin a new page in the outprint.  The page number is set
 
15952
to@tie{}@var{n}.  This page is completely independent of pages formerly
 
15953
processed even if those have the same page number.  The vertical
 
15954
position on the outprint is automatically set to@tie{}0.  All
 
15955
positioning, writing, and drawing is always done relative to a page, so
 
15956
a @samp{p} command must be issued before any of these commands.
 
15957
 
 
15958
@item s @var{n}
 
15959
Set point size to @var{n}@tie{}scaled points (this is unit @samp{z}).
 
15960
@acronym{AT&T} @code{troff} used the unit points (@samp{p}) instead.
 
15961
@xref{Output Language Compatibility}.
 
15962
 
 
15963
@item t @var{xxx}@angles{whitespace}
 
15964
@itemx t @var{xxx} @var{dummy-arg}@angles{whitespace}
 
15965
Print a word, i.e., a sequence of characters @var{xxx} representing
 
15966
output glyphs which names are single characters, terminated by a space
 
15967
character or a line break; an optional second integer argument is
 
15968
ignored (this allows the formatter to generate an even number of
 
15969
arguments).  The first glyph should be printed at the current position,
 
15970
the current horizontal position should then be increased by the width of
 
15971
the first glyph, and so on for each glyph.  The widths of the glyphs are
 
15972
read from the font file, scaled for the current point size, and rounded
 
15973
to a multiple of the horizontal resolution.  Special characters cannot
 
15974
be printed using this command (use the @samp{C} command for special
 
15975
characters).  This command is a @code{gtroff} extension; it is only used
 
15976
for devices whose @file{DESC} file contains the @code{tcommand} keyword
 
15977
(@pxref{DESC File Format}).
 
15978
 
 
15979
@item u @var{n} @var{xxx}@angles{whitespace}
 
15980
Print word with track kerning.  This is the same as the @samp{t} command
 
15981
except that after printing each glyph, the current horizontal position
 
15982
is increased by the sum of the width of that glyph and@tie{}@var{n} (an
 
15983
integer in basic units @samp{u}).  This command is a @code{gtroff}
 
15984
extension; it is only used for devices whose @file{DESC} file contains
 
15985
the @code{tcommand} keyword (@pxref{DESC File Format}).
 
15986
 
 
15987
@item V @var{n}
 
15988
Move down to the absolute vertical position@tie{}@var{n} (a non-negative
 
15989
integer in basic units @samp{u}) relative to upper edge of current page.
 
15990
 
 
15991
@item v @var{n}
 
15992
Move @var{n}@tie{}basic units @samp{u} down (@var{n} is a non-negative
 
15993
integer).  The original @acronym{UNIX} troff manual allows negative
 
15994
values for @var{n} also, but @code{gtroff} doesn't use this.
 
15995
 
 
15996
@item w
 
15997
Informs about a paddable white space to increase readability.  The
 
15998
spacing itself must be performed explicitly by a move command.
 
15999
@end table
 
16000
 
 
16001
@node Graphics Commands, Device Control Commands, Simple Commands, Command Reference
 
16002
@subsubsection Graphics Commands
 
16003
 
 
16004
Each graphics or drawing command in the intermediate output starts with
 
16005
the letter @samp{D}, followed by one or two characters that specify a
 
16006
subcommand; this is followed by a fixed or variable number of integer
 
16007
arguments that are separated by a single space character.  A @samp{D}
 
16008
command may not be followed by another command on the same line (apart
 
16009
from a comment), so each @samp{D} command is terminated by a syntactical
 
16010
line break.
 
16011
 
 
16012
@code{gtroff} output follows the classical spacing rules (no space
 
16013
between command and subcommand, all arguments are preceded by a single
 
16014
space character), but the parser allows optional space between the
 
16015
command letters and makes the space before the first argument optional.
 
16016
As usual, each space can be any sequence of tab and space characters.
 
16017
 
 
16018
Some graphics commands can take a variable number of arguments.  In this
 
16019
case, they are integers representing a size measured in basic units
 
16020
@samp{u}.  The arguments called @var{h1}, @var{h2}, @dots{}, @var{hn}
 
16021
stand for horizontal distances where positive means right, negative
 
16022
left.  The arguments called @var{v1}, @var{v2}, @dots{}, @var{vn} stand
 
16023
for vertical distances where positive means down, negative up.  All
 
16024
these distances are offsets relative to the current location.
 
16025
 
 
16026
Each graphics command directly corresponds to a similar @code{gtroff}
 
16027
@code{\D} escape sequence.  @xref{Drawing Requests}.
 
16028
 
 
16029
Unknown @samp{D} commands are assumed to be device-specific.  Its
 
16030
arguments are parsed as strings; the whole information is then sent to
 
16031
the postprocessor.
 
16032
 
 
16033
In the following command reference, the syntax element @angles{line
 
16034
break} means a syntactical line break as defined above.
 
16035
 
 
16036
@table @code
 
16037
@item D~ @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
 
16038
Draw B-spline from current position to offset (@var{h1},@var{v1}), then
 
16039
to offset (@var{h2},@var{v2}), if given, etc.@: up to
 
16040
(@var{hn},@var{vn}).  This command takes a variable number of argument
 
16041
pairs; the current position is moved to the terminal point of the drawn
 
16042
curve.
 
16043
 
 
16044
@item Da @var{h1} @var{v1} @var{h2} @var{v2}@angles{line break}
 
16045
Draw arc from current position to
 
16046
(@var{h1},@var{v1})@math{+}(@var{h2},@var{v2}) with center at
 
16047
(@var{h1},@var{v1}); then move the current position to the final point
 
16048
of the arc.
 
16049
 
 
16050
@item DC @var{d}@angles{line break}
 
16051
@itemx DC @var{d} @var{dummy-arg}@angles{line break}
 
16052
Draw a solid circle using the current fill color with
 
16053
diameter@tie{}@var{d} (integer in basic units @samp{u}) with leftmost
 
16054
point at the current position; then move the current position to the
 
16055
rightmost point of the circle.  An optional second integer argument is
 
16056
ignored (this allows the formatter to generate an even number of
 
16057
arguments).  This command is a @code{gtroff} extension.
 
16058
 
 
16059
@item Dc @var{d}@angles{line break}
 
16060
Draw circle line with diameter@tie{}@var{d} (integer in basic units
 
16061
@samp{u}) with leftmost point at the current position; then move the
 
16062
current position to the rightmost point of the circle.
 
16063
 
 
16064
@item DE @var{h} @var{v}@angles{line break}
 
16065
Draw a solid ellipse in the current fill color with a horizontal
 
16066
diameter of@tie{}@var{h} and a vertical diameter of@tie{}@var{v} (both
 
16067
integers in basic units @samp{u}) with the leftmost point at the current
 
16068
position; then move to the rightmost point of the ellipse.  This command
 
16069
is a @code{gtroff} extension.
 
16070
 
 
16071
@item De @var{h} @var{v}@angles{line break}
 
16072
Draw an outlined ellipse with a horizontal diameter of@tie{}@var{h} and
 
16073
a vertical diameter of@tie{}@var{v} (both integers in basic units
 
16074
@samp{u}) with the leftmost point at current position; then move to the
 
16075
rightmost point of the ellipse.
 
16076
 
 
16077
@item DF @var{color-scheme} @r{[}@var{component} @dots{}@r{]}@angles{line break}
 
16078
Set fill color for solid drawing objects using different color schemes;
 
16079
the analoguous command for setting the color of text, line graphics, and
 
16080
the outline of graphic objects is @samp{m}.  The color components are
 
16081
specified as integer arguments between 0 and 65536.  The number of color
 
16082
components and their meaning vary for the different color schemes.
 
16083
These commands are generated by @code{gtroff}'s escape sequences
 
16084
@w{@code{\D'F @dots{}'}} and @code{\M} (with no other corresponding
 
16085
graphics commands).  No position changing.  This command is a
 
16086
@code{gtroff} extension.
 
16087
 
 
16088
@table @code
 
16089
@item DFc @var{cyan} @var{magenta} @var{yellow}@angles{line break}
 
16090
Set fill color for solid drawing objects using the CMY color scheme,
 
16091
having the 3@tie{}color components @var{cyan}, @var{magenta}, and
 
16092
@var{yellow}.
 
16093
 
 
16094
@item DFd@angles{line break}
 
16095
Set fill color for solid drawing objects to the default fill color value
 
16096
(black in most cases).  No component arguments.
 
16097
 
 
16098
@item DFg @var{gray}@angles{line break}
 
16099
Set fill color for solid drawing objects to the shade of gray given by
 
16100
the argument, an integer between 0 (black) and 65536 (white).
 
16101
 
 
16102
@item DFk @var{cyan} @var{magenta} @var{yellow} @var{black}@angles{line break}
 
16103
Set fill color for solid drawing objects using the CMYK color scheme,
 
16104
having the 4@tie{}color components @var{cyan}, @var{magenta},
 
16105
@var{yellow}, and @var{black}.
 
16106
 
 
16107
@item DFr @var{red} @var{green} @var{blue}@angles{line break}
 
16108
Set fill color for solid drawing objects using the RGB color scheme,
 
16109
having the 3@tie{}color components @var{red}, @var{green}, and
 
16110
@var{blue}.
 
16111
@end table
 
16112
 
 
16113
@item Df @var{n}@angles{line break}
 
16114
The argument@tie{}@var{n} must be an integer in the range @math{-32767}
 
16115
to 32767.
 
16116
 
 
16117
@table @asis
 
16118
@item @math{0 @LE{} @var{n} @LE{} 1000}
 
16119
Set the color for filling solid drawing objects to a shade of gray,
 
16120
where 0 corresponds to solid white, 1000 (the default) to solid black,
 
16121
and values in between to intermediate shades of gray; this is obsoleted
 
16122
by command @samp{DFg}.
 
16123
 
 
16124
@item @math{@var{n} < 0} or @math{@var{n} > 1000}
 
16125
Set the filling color to the color that is currently being used for the
 
16126
text and the outline, see command @samp{m}.  For example, the command
 
16127
sequence
 
16128
 
 
16129
@Example
 
16130
mg 0 0 65536
 
16131
Df -1
 
16132
@endExample
 
16133
 
 
16134
@noindent
 
16135
sets all colors to blue.
 
16136
@end table
 
16137
 
 
16138
@noindent
 
16139
No position changing.  This command is a @code{gtroff} extension.
 
16140
 
 
16141
@item Dl @var{h} @var{v}@angles{line break}
 
16142
Draw line from current position to offset (@var{h},@var{v}) (integers in
 
16143
basic units @samp{u}); then set current position to the end of the drawn
 
16144
line.
 
16145
 
 
16146
@item Dp @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
 
16147
Draw a polygon line from current position to offset (@var{h1},@var{v1}),
 
16148
from there to offset (@var{h2},@var{v2}), etc.@: up to offset
 
16149
(@var{hn},@var{vn}), and from there back to the starting position.  For
 
16150
historical reasons, the position is changed by adding the sum of all
 
16151
arguments with odd index to the actual horizontal position and the even
 
16152
ones to the vertical position.  Although this doesn't make sense it is
 
16153
kept for compatibility.
 
16154
@ignore
 
16155
As the polygon is closed, the end of drawing is the starting point, so
 
16156
the position doesn't change.
 
16157
@end ignore
 
16158
This command is a @code{gtroff} extension.
 
16159
 
 
16160
@item Dp @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
 
16161
Draw a solid polygon in the current fill color rather than an outlined
 
16162
polygon, using the same arguments and positioning as the corresponding
 
16163
@samp{Dp} command.
 
16164
@ignore
 
16165
No position changing.
 
16166
@end ignore
 
16167
This command is a @code{gtroff} extension.
 
16168
 
 
16169
@item Dt @var{n}@angles{line break}
 
16170
Set the current line thickness to@tie{}@var{n} (an integer in basic
 
16171
units @samp{u}) if @math{@var{n}>0}; if @math{@var{n}=0} select the
 
16172
smallest available line thickness; if @math{@var{n}<0} set the line
 
16173
thickness proportional to the point size (this is the default before the
 
16174
first @samp{Dt} command was specified).  For historical reasons, the
 
16175
horizontal position is changed by adding the argument to the actual
 
16176
horizontal position, while the vertical position is not changed.
 
16177
Although this doesn't make sense it is kept for compatibility.
 
16178
@ignore
 
16179
No position changing.
 
16180
@end ignore
 
16181
This command is a @code{gtroff} extension.
 
16182
@end table
 
16183
 
 
16184
@node Device Control Commands, Obsolete Command, Graphics Commands, Command Reference
 
16185
@subsubsection Device Control Commands
 
16186
 
 
16187
Each device control command starts with the letter @samp{x}, followed by
 
16188
a space character (optional or arbitrary space or tab in @code{gtroff})
 
16189
and a subcommand letter or word; each argument (if any) must be preceded
 
16190
by a syntactical space.  All @samp{x} commands are terminated by a
 
16191
syntactical line break; no device control command can be followed by
 
16192
another command on the same line (except a comment).
 
16193
 
 
16194
The subcommand is basically a single letter, but to increase
 
16195
readability, it can be written as a word, i.e., an arbitrary sequence of
 
16196
characters terminated by the next tab, space, or newline character.  All
 
16197
characters of the subcommand word but the first are simply ignored.  For
 
16198
example, @code{gtroff} outputs the initialization command @w{@samp{x i}}
 
16199
as @w{@samp{x init}} and the resolution command @w{@samp{x r}} as
 
16200
@w{@samp{x res}}.
 
16201
 
 
16202
In the following, the syntax element @angles{line break} means a
 
16203
syntactical line break (@pxref{Separation}).
 
16204
 
 
16205
@table @code
 
16206
@item xF @var{name}@angles{line break}
 
16207
The @samp{F} stands for @var{Filename}.
 
16208
 
 
16209
Use @var{name} as the intended name for the current file in error
 
16210
reports.  This is useful for remembering the original file name when
 
16211
@code{gtroff} uses an internal piping mechanism.  The input file is not
 
16212
changed by this command.  This command is a @code{gtroff} extension.
 
16213
 
 
16214
@item xf @var{n} @var{s}@angles{line break}
 
16215
The @samp{f} stands for @var{font}.
 
16216
 
 
16217
Mount font position@tie{}@var{n} (a non-negative integer) with font
 
16218
named@tie{}@var{s} (a text word).  @xref{Font Positions}.
 
16219
 
 
16220
@item xH @var{n}@angles{line break}
 
16221
The @samp{H} stands for @var{Height}.
 
16222
 
 
16223
Set glyph height to@tie{}@var{n} (a positive integer in scaled points
 
16224
@samp{z}).  @acronym{AT&T} @code{troff} uses the unit points (@samp{p})
 
16225
instead.  @xref{Output Language Compatibility}.
 
16226
 
 
16227
@item xi@angles{line break}
 
16228
The @samp{i} stands for @var{init}.
 
16229
 
 
16230
Initialize device.  This is the third command of the prologue.
 
16231
 
 
16232
@item xp@angles{line break}
 
16233
The @samp{p} stands for @var{pause}.
 
16234
 
 
16235
Parsed but ignored.  The original @acronym{UNIX} troff manual writes
 
16236
 
 
16237
@display
 
16238
pause device, can be restarted
 
16239
@end display
 
16240
 
 
16241
@item xr @var{n} @var{h} @var{v}@angles{line break}
 
16242
The @samp{r} stands for @var{resolution}.
 
16243
 
 
16244
Resolution is@tie{}@var{n}, while @var{h} is the minimal horizontal
 
16245
motion, and @var{v} the minimal vertical motion possible with this
 
16246
device; all arguments are positive integers in basic units @samp{u} per
 
16247
inch.  This is the second command of the prologue.
 
16248
 
 
16249
@item xS @var{n}@angles{line break}
 
16250
The @samp{S} stands for @var{Slant}.
 
16251
 
 
16252
Set slant to@tie{}@var{n} (an integer in basic units @samp{u}).
 
16253
 
 
16254
@item xs@angles{line break}
 
16255
The @samp{s} stands for @var{stop}.
 
16256
 
 
16257
Terminates the processing of the current file; issued as the last
 
16258
command of any intermediate troff output.
 
16259
 
 
16260
@item xt@angles{line break}
 
16261
The @samp{t} stands for @var{trailer}.
 
16262
 
 
16263
Generate trailer information, if any.  In @var{gtroff}, this is actually
 
16264
just ignored.
 
16265
 
 
16266
@item xT @var{xxx}@angles{line break}
 
16267
The @samp{T} stands for @var{Typesetter}.
 
16268
 
 
16269
Set name of device to word @var{xxx}, a sequence of characters ended by
 
16270
the next white space character.  The possible device names coincide with
 
16271
those from the @code{groff} @option{-T} option.  This is the first
 
16272
command of the prologue.
 
16273
 
 
16274
@item xu @var{n}@angles{line break}
 
16275
The @samp{u} stands for @var{underline}.
 
16276
 
 
16277
Configure underlining of spaces.  If @var{n} is@tie{}1, start
 
16278
underlining of spaces; if @var{n} is@tie{}0, stop underlining of spaces.
 
16279
This is needed for the @code{cu} request in nroff mode and is ignored
 
16280
otherwise.  This command is a @code{gtroff} extension.
 
16281
 
 
16282
@item xX @var{anything}@angles{line break}
 
16283
The @samp{x} stands for @var{X-escape}.
 
16284
 
 
16285
Send string @var{anything} uninterpreted to the device.  If the line
 
16286
following this command starts with a @samp{+} character this line is
 
16287
interpreted as a continuation line in the following sense.  The @samp{+}
 
16288
is ignored, but a newline character is sent instead to the device, the
 
16289
rest of the line is sent uninterpreted.  The same applies to all
 
16290
following lines until the first character of a line is not a @samp{+}
 
16291
character.  This command is generated by the @code{gtroff} escape
 
16292
sequence @code{\X}.  The line-continuing feature is a @code{gtroff}
 
16293
extension.
 
16294
@end table
 
16295
 
 
16296
@node Obsolete Command,  , Device Control Commands, Command Reference
 
16297
@subsubsection Obsolete Command
 
16298
In @acronym{AT&T} @code{troff} output, the writing of a single glyph is
 
16299
mostly done by a very strange command that combines a horizontal move
 
16300
and a single character giving the glyph name.  It doesn't have a command
 
16301
code, but is represented by a 3-character argument consisting of exactly
 
16302
2@tie{}digits and a character.
 
16303
 
 
16304
@table @asis
 
16305
@item @var{dd}@var{g}
 
16306
Move right @var{dd} (exactly two decimal digits) basic units @samp{u},
 
16307
then print glyph@tie{}@var{g} (represented as a single character).
 
16308
 
 
16309
In @code{gtroff}, arbitrary syntactical space around and within this
 
16310
command is allowed to be added.  Only when a preceding command on the
 
16311
same line ends with an argument of variable length a separating space is
 
16312
obligatory.  In @acronym{AT&T} @code{troff}, large clusters of these and
 
16313
other commands are used, mostly without spaces; this made such output
 
16314
almost unreadable.
 
16315
@end table
 
16316
 
 
16317
For modern high-resolution devices, this command does not make sense
 
16318
because the width of the glyphs can become much larger than two decimal
 
16319
digits.  In @code{gtroff}, this is only used for the devices @code{X75},
 
16320
@code{X75-12}, @code{X100}, and @code{X100-12}.  For other devices, the
 
16321
commands @samp{t} and @samp{u} provide a better functionality.
 
16322
 
 
16323
@c ---------------------------------------------------------------------
 
16324
 
 
16325
@node Intermediate Output Examples, Output Language Compatibility, Command Reference, gtroff Output
 
16326
@subsection Intermediate Output Examples
 
16327
 
 
16328
This section presents the intermediate output generated from the same
 
16329
input for three different devices.  The input is the sentence @samp{hell
 
16330
world} fed into @code{gtroff} on the command line.
 
16331
 
 
16332
@table @asis
 
16333
@item High-resolution device @code{ps}
 
16334
 
 
16335
This is the standard output of @code{gtroff} if no @option{-T} option is
 
16336
given.
 
16337
 
 
16338
@example
 
16339
@group
 
16340
shell> echo "hell world" | groff -Z -T ps
 
16341
 
 
16342
x T ps
 
16343
x res 72000 1 1
 
16344
x init
 
16345
@end group
 
16346
p1
 
16347
x font 5 TR
 
16348
f5
 
16349
s10000
 
16350
V12000
 
16351
H72000
 
16352
thell
 
16353
wh2500
 
16354
tw
 
16355
H96620
 
16356
torld
 
16357
n12000 0
 
16358
@group
 
16359
x trailer
 
16360
V792000
 
16361
x stop
 
16362
@end group
 
16363
@end example
 
16364
 
 
16365
@noindent
 
16366
This output can be fed into @code{grops} to get its representation as a
 
16367
@sc{PostScript} file.
 
16368
 
 
16369
@item Low-resolution device @code{latin1}
 
16370
 
 
16371
This is similar to the high-resolution device except that the
 
16372
positioning is done at a minor scale.  Some comments (lines starting
 
16373
with @samp{#}) were added for clarification; they were not generated by
 
16374
the formatter.
 
16375
 
 
16376
@example
 
16377
@group
 
16378
shell> echo "hell world" | groff -Z -T latin1
 
16379
 
 
16380
# prologue
 
16381
x T latin1
 
16382
x res 240 24 40
 
16383
x init
 
16384
@end group
 
16385
# begin a new page
 
16386
p1
 
16387
# font setup
 
16388
x font 1 R
 
16389
f1
 
16390
s10
 
16391
# initial positioning on the page
 
16392
V40
 
16393
H0
 
16394
# write text `hell'
 
16395
thell
 
16396
# inform about space, and issue a horizontal jump
 
16397
wh24
 
16398
# write text `world'
 
16399
tworld
 
16400
# announce line break, but do nothing because ...
 
16401
n40 0
 
16402
@group
 
16403
# ... the end of the document has been reached
 
16404
x trailer
 
16405
V2640
 
16406
x stop
 
16407
@end group
 
16408
@end example
 
16409
 
 
16410
@noindent
 
16411
This output can be fed into @code{grotty} to get a formatted text
 
16412
document.
 
16413
 
 
16414
@item @acronym{AT&T} @code{troff} output
 
16415
Since a computer monitor has a very low resolution compared to modern
 
16416
printers the intermediate output for the X@tie{}Window devices can use
 
16417
the jump-and-write command with its 2-digit displacements.
 
16418
 
 
16419
@example
 
16420
@group
 
16421
shell> echo "hell world" | groff -Z -T X100
 
16422
 
 
16423
x T X100
 
16424
x res 100 1 1
 
16425
x init
 
16426
@end group
 
16427
p1
 
16428
x font 5 TR
 
16429
f5
 
16430
s10
 
16431
V16
 
16432
H100
 
16433
# write text with jump-and-write commands
 
16434
ch07e07l03lw06w11o07r05l03dh7
 
16435
n16 0
 
16436
@group
 
16437
x trailer
 
16438
V1100
 
16439
x stop
 
16440
@end group
 
16441
@end example
 
16442
 
 
16443
@noindent
 
16444
This output can be fed into @code{xditview} or @code{gxditview} for
 
16445
displaying in@tie{}X.
 
16446
 
 
16447
Due to the obsolete jump-and-write command, the text clusters in the
 
16448
@acronym{AT&T} @code{troff} output are almost unreadable.
 
16449
@end table
 
16450
 
 
16451
@c ---------------------------------------------------------------------
 
16452
 
 
16453
@node Output Language Compatibility,  , Intermediate Output Examples, gtroff Output
 
16454
@subsection Output Language Compatibility
 
16455
 
 
16456
The intermediate output language of @acronym{AT&T} @code{troff} was
 
16457
first documented in the @acronym{UNIX} troff manual, with later
 
16458
additions documented in @cite{A Typesetter-indenpendent TROFF}, written
 
16459
by Brian Kernighan.
 
16460
 
 
16461
The @code{gtroff} intermediate output format is compatible with this
 
16462
specification except for the following features.
 
16463
 
 
16464
@itemize @bullet
 
16465
@item
 
16466
The classical quasi device independence is not yet implemented.
 
16467
 
 
16468
@item
 
16469
The old hardware was very different from what we use today.  So the
 
16470
@code{groff} devices are also fundamentally different from the ones
 
16471
in @acronym{AT&T} @code{troff}.  For example, the @acronym{AT&T}
 
16472
@sc{PostScript} device is called @code{post} and has a resolution of
 
16473
only 720 units per inch, suitable for printers 20 years ago, while
 
16474
@code{groff}'s @code{ps} device has a resolution of 72000 units per
 
16475
inch.  Maybe, by implementing some rescaling mechanism similar to the
 
16476
classical quasi device independence, @code{groff} could emulate
 
16477
@acronym{AT&T}'s @code{post} device.
 
16478
 
 
16479
@item
 
16480
The B-spline command @samp{D~} is correctly handled by the intermediate
 
16481
output parser, but the drawing routines aren't implemented in some of
 
16482
the postprocessor programs.
 
16483
 
 
16484
@item
 
16485
The argument of the commands @samp{s} and @w{@samp{x H}} has the
 
16486
implicit unit scaled point @samp{z} in @code{gtroff}, while
 
16487
@acronym{AT&T} @code{troff} has point (@samp{p}).  This isn't an
 
16488
incompatibility but a compatible extension, for both units coincide for
 
16489
all devices without a @code{sizescale} parameter in the @file{DESC}
 
16490
file, including all postprocessors from @acronym{AT&T} and
 
16491
@code{groff}'s text devices.  The few @code{groff} devices with a
 
16492
@code{sizescale} parameter either do not exist for @acronym{AT&T}
 
16493
@code{troff}, have a different name, or seem to have a different
 
16494
resolution.  So conflicts are very unlikely.
 
16495
 
 
16496
@item
 
16497
The position changing after the commands @samp{Dp}, @samp{DP}, and
 
16498
@samp{Dt} is illogical, but as old versions of @code{gtroff} used this
 
16499
feature it is kept for compatibility reasons.
 
16500
 
 
16501
@ignore
 
16502
Temporarily, there existed some confusion on the positioning after the
 
16503
@samp{D} commands that are groff extensions.  This has been clarified by
 
16504
establishing the classical rule for all @code{groff} drawing commands:
 
16505
 
 
16506
@itemize
 
16507
@item
 
16508
The position after a graphic object has been drawn is at its end; for
 
16509
circles and ellipses, the `end' is at the right side.
 
16510
 
 
16511
@item
 
16512
From this, the positionings specified for the drawing commands above
 
16513
follow quite naturally.
 
16514
@end itemize
 
16515
@end ignore
 
16516
 
 
16517
@end itemize
 
16518
 
 
16519
 
 
16520
@c =====================================================================
 
16521
 
 
16522
@node Font Files,  , gtroff Output, File formats
 
16523
@section Font Files
 
16524
@cindex font files
 
16525
@cindex files, font
 
16526
 
 
16527
The @code{gtroff} font format is roughly a superset of the
 
16528
@code{ditroff} font format (as used in later versions of @acronym{AT&T}
 
16529
@code{troff} and its descendants).  Unlike the @code{ditroff} font
 
16530
format, there is no associated binary format; all files are text
 
16531
files.@footnote{Plan@tie{}9 @code{troff} has also abandoned the binary
 
16532
format.}  The font files for device @var{name} are stored in a directory
 
16533
@file{dev@var{name}}.  There are two types of file: a device description
 
16534
file called @file{DESC} and for each font@tie{}@var{f} a font file
 
16535
called@tie{}@file{@var{f}}.
 
16536
 
 
16537
@menu
 
16538
* DESC File Format::
 
16539
* Font File Format::
 
16540
@end menu
 
16541
 
 
16542
@c ---------------------------------------------------------------------
 
16543
 
 
16544
@node DESC File Format, Font File Format, Font Files, Font Files
 
16545
@subsection @file{DESC} File Format
 
16546
@cindex @file{DESC} file, format
 
16547
@cindex font description file, format
 
16548
@cindex format of font description file
 
16549
@pindex DESC@r{ file format}
 
16550
 
 
16551
The @file{DESC} file can contain the following types of line.  Except
 
16552
for the @code{charset} keyword which must comes last (if at all), the
 
16553
order of the lines is not important.  Later entries in the file,
 
16554
however, override previous values.
 
16555
 
 
16556
@table @code
 
16557
@item charset
 
16558
@kindex charset
 
16559
This line and everything following in the file are ignored.  It is
 
16560
allowed for the sake of backwards compatibility.
 
16561
 
 
16562
@item family @var{fam}
 
16563
@kindex family
 
16564
The default font family is @var{fam}.
 
16565
 
 
16566
@item fonts @var{n} @var{F1} @var{F2} @var{F3} @dots{} @var{Fn}
 
16567
@kindex fonts
 
16568
Fonts @var{F1} @dots{} @var{Fn} are mounted in the font positions
 
16569
@var{m}+1, @dots{}, @var{m}+@var{n} where @var{m} is the number of
 
16570
styles.  This command may extend over more than one line.  A font name
 
16571
of@tie{}0 means no font is mounted on the corresponding font position.
 
16572
 
 
16573
@item hor @var{n}
 
16574
@kindex hor
 
16575
@cindex horizontal resolution
 
16576
@cindex resolution, horizontal
 
16577
The horizontal resolution is @var{n}@tie{}machine units.  All horizontal
 
16578
quantities are rounded to be multiples of this value.
 
16579
 
 
16580
@item image_generator @var{string}
 
16581
@kindex image_generator
 
16582
@cindex PostScript, PNG image generation
 
16583
@cindex PNG image generation from PostScript
 
16584
Needed for @code{grohtml} only.  It specifies the program to generate
 
16585
PNG images from @sc{PostScript} input.  Under GNU/Linux this is
 
16586
usually @code{gs} but under other systems (notably cygwin) it might
 
16587
be set to another name.
 
16588
 
 
16589
@item paperlength @var{n}
 
16590
@kindex paperlength
 
16591
The physical vertical dimension of the output medium in machine units.
 
16592
This isn't used by @code{troff} itself but by output devices.
 
16593
Deprecated.  Use @code{papersize} instead.
 
16594
 
 
16595
@item papersize @var{string} @dots{}
 
16596
@kindex papersize
 
16597
Select a paper size.  Valid values for @var{string} are the ISO paper
 
16598
types @code{A0}-@code{A7}, @code{B0}-@code{B7}, @code{C0}-@code{C7},
 
16599
@code{D0}-@code{D7}, @code{DL}, and the US paper types @code{letter},
 
16600
@code{legal}, @code{tabloid}, @code{ledger}, @code{statement},
 
16601
@code{executive}, @code{com10}, and @code{monarch}.  Case is not
 
16602
significant for @var{string} if it holds predefined paper types.
 
16603
Alternatively, @var{string} can be a file name (e.g.@:
 
16604
@file{/etc/papersize}); if the file can be opened, @code{groff} reads
 
16605
the first line and tests for the above paper sizes.  Finally,
 
16606
@var{string} can be a custom paper size in the format
 
16607
@code{@var{length},@var{width}} (no spaces before and after the comma).
 
16608
Both @var{length} and @var{width} must have a unit appended; valid
 
16609
values are @samp{i} for inches, @samp{C} for centimeters, @samp{p} for
 
16610
points, and @samp{P} for picas.  Example: @code{12c,235p}.  An argument
 
16611
which starts with a digit is always treated as a custom paper format.
 
16612
@code{papersize} sets both the vertical and horizontal dimension of the
 
16613
output medium.
 
16614
 
 
16615
More than one argument can be specified; @code{groff} scans from left to
 
16616
right and uses the first valid paper specification.
 
16617
 
 
16618
@item paperwidth @var{n}
 
16619
@kindex paperwidth
 
16620
The physical horizontal dimension of the output medium in machine units.
 
16621
This isn't used by @code{troff} itself but by output devices.
 
16622
Deprecated.  Use @code{papersize} instead.
 
16623
 
 
16624
@item pass_filenames
 
16625
@kindex pass_filenames
 
16626
Tell @code{gtroff} to emit the name of the source file currently being
 
16627
processed.  This is achieved by the intermediate output command
 
16628
@samp{F}.  Currently, this is only used by the @code{grohtml} output
 
16629
device.
 
16630
 
 
16631
@item postpro @var{program}
 
16632
@kindex postpro
 
16633
Call @var{program} as a postprocessor.  For example, the line
 
16634
 
 
16635
@Example
 
16636
postpro grodvi
 
16637
@endExample
 
16638
 
 
16639
@noindent
 
16640
in the file @file{devdvi/DESC} makes @code{groff} call @code{grodvi} if
 
16641
option @option{-Tdvi} is given (and @option{-Z} isn't used).
 
16642
 
 
16643
@item prepro @var{program}
 
16644
@kindex prepro
 
16645
Call @var{program} as a preprocessor.  Currently, this keyword is used
 
16646
by @code{groff} with option @option{-Thtml} or @option{-Txhtml} only.
 
16647
 
 
16648
@item print @var{program}
 
16649
@kindex print
 
16650
Use @var{program} as a spooler program for printing.  If omitted, the
 
16651
@option{-l} and @option{-L} options of @code{groff} are ignored.
 
16652
 
 
16653
@item res @var{n}
 
16654
@kindex res
 
16655
@cindex device resolution
 
16656
@cindex resolution, device
 
16657
There are @var{n}@tie{}machine units per inch.
 
16658
 
 
16659
@item sizes @var{s1} @var{s2} @dots{} @var{sn} 0
 
16660
@kindex sizes
 
16661
This means that the device has fonts at @var{s1}, @var{s2}, @dots{}
 
16662
@var{sn} scaled points.  The list of sizes must be terminated by@tie{}0
 
16663
(this is digit zero).  Each @var{si} can also be a range of sizes
 
16664
@var{m}-@var{n}.  The list can extend over more than one line.
 
16665
 
 
16666
@item sizescale @var{n}
 
16667
@kindex sizescale
 
16668
The scale factor for point sizes.  By default this has a value
 
16669
of@tie{}1.  One scaled point is equal to one point/@var{n}.  The
 
16670
arguments to the @code{unitwidth} and @code{sizes} commands are given in
 
16671
scaled points.  @xref{Fractional Type Sizes}, for more information.
 
16672
 
 
16673
@item styles @var{S1} @var{S2} @dots{} @var{Sm}
 
16674
@kindex styles
 
16675
The first @var{m}@tie{}font positions are associated with styles
 
16676
@var{S1} @dots{} @var{Sm}.
 
16677
 
 
16678
@item tcommand
 
16679
@kindex tcommand
 
16680
This means that the postprocessor can handle the @samp{t} and @samp{u}
 
16681
intermediate output commands.
 
16682
 
 
16683
@item unicode
 
16684
@kindex unicode
 
16685
Indicate that the output device supports the complete Unicode
 
16686
repertoire.  Useful only for devices which produce @emph{character
 
16687
entities} instead of glyphs.
 
16688
 
 
16689
If @code{unicode} is present, no @code{charset} section is required in
 
16690
the font description files since the Unicode handling built into
 
16691
@code{groff} is used.  However, if there are entries in a @code{charset}
 
16692
section, they either override the default mappings for those particular
 
16693
characters or add new mappings (normally for composite characters).
 
16694
 
 
16695
This is used for @option{-Tutf8}, @option{-Thtml}, and @option{-Txhtml}.
 
16696
 
 
16697
@item unitwidth @var{n}
 
16698
@kindex unitwidth
 
16699
Quantities in the font files are given in machine units for fonts whose
 
16700
point size is @var{n}@tie{}scaled points.
 
16701
 
 
16702
@item unscaled_charwidths
 
16703
@kindex unscaled_charwidths
 
16704
Make the font handling module always return unscaled character widths.
 
16705
Needed for the @code{grohtml} device.
 
16706
@item use_charnames_in_special
 
16707
@kindex use_charnames_in_special
 
16708
This command indicates that @code{gtroff} should encode special
 
16709
characters inside special commands.  Currently, this is only used by the
 
16710
@code{grohtml} output device.  @xref{Postprocessor Access}.
 
16711
 
 
16712
@item vert @var{n}
 
16713
@kindex vert
 
16714
@cindex vertical resolution
 
16715
@cindex resolution, vertical
 
16716
The vertical resolution is @var{n}@tie{}machine units.  All vertical
 
16717
quantities are rounded to be multiples of this value.
 
16718
@end table
 
16719
 
 
16720
The @code{res}, @code{unitwidth}, @code{fonts}, and @code{sizes} lines
 
16721
are mandatory.  Other commands are ignored by @code{gtroff} but may be
 
16722
used by postprocessors to store arbitrary information about the device
 
16723
in the @file{DESC} file.
 
16724
 
 
16725
@kindex spare1
 
16726
@kindex spare2
 
16727
@kindex biggestfont
 
16728
Here a list of obsolete keywords which are recognized by @code{groff}
 
16729
but completely ignored: @code{spare1}, @code{spare2},
 
16730
@code{biggestfont}.
 
16731
 
 
16732
@c ---------------------------------------------------------------------
 
16733
 
 
16734
@node Font File Format,  , DESC File Format, Font Files
 
16735
@subsection Font File Format
 
16736
@cindex font file, format
 
16737
@cindex font description file, format
 
16738
@cindex format of font files
 
16739
@cindex format of font description files
 
16740
 
 
16741
A @dfn{font file}, also (and probably better) called a @dfn{font
 
16742
description file}, has two sections.  The first section is a sequence of
 
16743
lines each containing a sequence of blank delimited words; the first
 
16744
word in the line is a key, and subsequent words give a value for that
 
16745
key.
 
16746
 
 
16747
@table @code
 
16748
@item name @var{f}
 
16749
@kindex name
 
16750
The name of the font is@tie{}@var{f}.
 
16751
 
 
16752
@item spacewidth @var{n}
 
16753
@kindex spacewidth
 
16754
The normal width of a space is@tie{}@var{n}.
 
16755
 
 
16756
@item slant @var{n}
 
16757
@kindex slant
 
16758
The glyphs of the font have a slant of @var{n}@tie{}degrees.  (Positive
 
16759
means forward.)
 
16760
 
 
16761
@item ligatures @var{lig1} @var{lig2} @dots{} @var{lign} [0]
 
16762
@kindex ligatures
 
16763
Glyphs @var{lig1}, @var{lig2}, @dots{}, @var{lign} are ligatures;
 
16764
possible ligatures are @samp{ff}, @samp{fi}, @samp{fl}, @samp{ffi} and
 
16765
@samp{ffl}.  For backwards compatibility, the list of ligatures may be
 
16766
terminated with a@tie{}0.  The list of ligatures may not extend over
 
16767
more than one line.
 
16768
 
 
16769
@item special
 
16770
@cindex special fonts
 
16771
@kindex special
 
16772
The font is @dfn{special}; this means that when a glyph is requested
 
16773
that is not present in the current font, it is searched for in any
 
16774
special fonts that are mounted.
 
16775
@end table
 
16776
 
 
16777
Other commands are ignored by @code{gtroff} but may be used by
 
16778
postprocessors to store arbitrary information about the font in the font
 
16779
file.
 
16780
 
 
16781
@cindex comments in font files
 
16782
@cindex font files, comments
 
16783
@kindex #
 
16784
The first section can contain comments which start with the @samp{#}
 
16785
character and extend to the end of a line.
 
16786
 
 
16787
The second section contains one or two subsections.  It must contain a
 
16788
@code{charset} subsection and it may also contain a @code{kernpairs}
 
16789
subsection.  These subsections can appear in any order.  Each subsection
 
16790
starts with a word on a line by itself.
 
16791
 
 
16792
@kindex charset
 
16793
The word @code{charset} starts the character set
 
16794
subsection.@footnote{This keyword is misnamed since it starts a list of
 
16795
ordered glyphs, not characters.}  The @code{charset} line is followed by
 
16796
a sequence of lines.  Each line gives information for one glyph.  A line
 
16797
comprises a number of fields separated by blanks or tabs.  The format is
 
16798
 
 
16799
@quotation
 
16800
@var{name} @var{metrics} @var{type} @var{code} [@var{entity-name}]
 
16801
[@code{--} @var{comment}]
 
16802
@end quotation
 
16803
 
 
16804
@cindex 8-bit input
 
16805
@cindex input, 8-bit
 
16806
@cindex accessing unnamed glyphs with @code{\N}
 
16807
@cindex unnamed glyphs, accessing with @code{\N}
 
16808
@cindex characters, unnamed, accessing with @code{\N}
 
16809
@cindex glyphs, unnamed, accessing with @code{\N}
 
16810
@kindex ---
 
16811
@noindent
 
16812
@var{name} identifies the glyph name@footnote{The distinction between
 
16813
input, characters, and output, glyphs, is not clearly separated in the
 
16814
terminology of @code{groff}; for example, the @code{char} request should
 
16815
be called @code{glyph} since it defines an output entity.}: If
 
16816
@var{name} is a single character@tie{}@var{c} then it corresponds to the
 
16817
@code{gtroff} input character@tie{}@var{c}; if it is of the form
 
16818
@samp{\@var{c}} where @var{c} is a single character, then it corresponds
 
16819
to the special character @code{\[@var{c}]}; otherwise it corresponds to
 
16820
the special character @samp{\[@var{name}]}.  If it is exactly two
 
16821
characters @var{xx} it can be entered as @samp{\(@var{xx}}.  Note that
 
16822
single-letter special characters can't be accessed as @samp{\@var{c}};
 
16823
the only exception is @samp{\-} which is identical to @code{\[-]}.
 
16824
 
 
16825
@code{gtroff} supports 8-bit input characters; however some utilities
 
16826
have difficulties with eight-bit characters.  For this reason, there is
 
16827
a convention that the entity name @samp{char@var{n}} is equivalent to
 
16828
the single input character whose code is@tie{}@var{n}.  For example,
 
16829
@samp{char163} would be equivalent to the character with code@tie{}163
 
16830
which is the pounds sterling sign in the ISO@tie{}@w{Latin-1} character
 
16831
set.  You shouldn't use @samp{char@var{n}} entities in font description
 
16832
files since they are related to input, not output.  Otherwise, you get
 
16833
hard-coded connections between input and output encoding which prevents
 
16834
use of different (input) character sets.
 
16835
 
 
16836
The name @samp{---} is special and indicates that the glyph is unnamed;
 
16837
such glyphs can only be used by means of the @code{\N} escape sequence
 
16838
in @code{gtroff}.
 
16839
 
 
16840
The @var{type} field gives the glyph type:
 
16841
 
 
16842
@table @code
 
16843
@item 1
 
16844
the glyph has a descender, for example, @samp{p};
 
16845
 
 
16846
@item 2
 
16847
the glyph has an ascender, for example, @samp{b};
 
16848
 
 
16849
@item 3
 
16850
the glyph has both an ascender and a descender, for example, @samp{(}.
 
16851
@end table
 
16852
 
 
16853
The @var{code} field gives the code which the postprocessor uses to
 
16854
print the glyph.  The glyph can also be input to @code{gtroff} using
 
16855
this code by means of the @code{\N} escape sequence.  @var{code} can be
 
16856
any integer.  If it starts with @samp{0} it is interpreted as octal; if
 
16857
it starts with @samp{0x} or @samp{0X} it is interpreted as hexadecimal.
 
16858
Note, however, that the @code{\N} escape sequence only accepts a decimal
 
16859
integer.
 
16860
 
 
16861
The @var{entity-name} field gives an @acronym{ASCII} string identifying
 
16862
the glyph which the postprocessor uses to print the @code{gtroff} glyph
 
16863
@var{name}.  This field is optional and has been introduced so that the
 
16864
@code{grohtml} device driver can encode its character set.  For example,
 
16865
the glyph @samp{\[Po]} is represented as @samp{&pound;} in
 
16866
@acronym{HTML} 4.0.
 
16867
 
 
16868
Anything on the line after the @var{entity-name} field resp.@: after
 
16869
@samp{--} is ignored.
 
16870
 
 
16871
The @var{metrics} field has the form:
 
16872
 
 
16873
@display
 
16874
@group
 
16875
@var{width}[@code{,}@var{height}[@code{,}@var{depth}[@code{,}@var{italic-correction}
 
16876
  [@code{,}@var{left-italic-correction}[@code{,}@var{subscript-correction}]]]]]
 
16877
@end group
 
16878
@end display
 
16879
 
 
16880
@noindent
 
16881
There must not be any spaces between these subfields (it has been split
 
16882
here into two lines for better legibility only).  Missing subfields are
 
16883
assumed to be@tie{}0.  The subfields are all decimal integers.  Since
 
16884
there is no associated binary format, these values are not required to
 
16885
fit into a variable of type @samp{char} as they are in @code{ditroff}.
 
16886
The @var{width} subfield gives the width of the glyph.  The @var{height}
 
16887
subfield gives the height of the glyph (upwards is positive); if a glyph
 
16888
does not extend above the baseline, it should be given a zero height,
 
16889
rather than a negative height.  The @var{depth} subfield gives the depth
 
16890
of the glyph, that is, the distance from the baseline to the lowest
 
16891
point below the baseline to which the glyph extends (downwards is
 
16892
positive); if a glyph does not extend below the baseline, it should be
 
16893
given a zero depth, rather than a negative depth.  The
 
16894
@var{italic-correction} subfield gives the amount of space that should
 
16895
be added after the glyph when it is immediately to be followed by a
 
16896
glyph from a roman font.  The @var{left-italic-correction} subfield
 
16897
gives the amount of space that should be added before the glyph when it
 
16898
is immediately to be preceded by a glyph from a roman font.  The
 
16899
@var{subscript-correction} gives the amount of space that should be
 
16900
added after a glyph before adding a subscript.  This should be less than
 
16901
the italic correction.
 
16902
 
 
16903
A line in the @code{charset} section can also have the format
 
16904
 
 
16905
@Example
 
16906
@var{name} "
 
16907
@endExample
 
16908
 
 
16909
@noindent
 
16910
This indicates that @var{name} is just another name for the glyph
 
16911
mentioned in the preceding line.
 
16912
 
 
16913
@kindex kernpairs
 
16914
The word @code{kernpairs} starts the kernpairs section.  This contains a
 
16915
sequence of lines of the form:
 
16916
 
 
16917
@Example
 
16918
@var{c1} @var{c2} @var{n}
 
16919
@endExample
 
16920
 
 
16921
@noindent
 
16922
This means that when glyph @var{c1} appears next to glyph @var{c2} the
 
16923
space between them should be increased by@tie{}@var{n}.  Most entries in
 
16924
the kernpairs section have a negative value for@tie{}@var{n}.
 
16925
 
 
16926
 
 
16927
 
 
16928
@c =====================================================================
 
16929
@c =====================================================================
 
16930
 
 
16931
@node Installation, Copying This Manual, File formats, Top
 
16932
@chapter Installation
 
16933
@cindex installation
 
16934
 
 
16935
@c XXX
 
16936
 
 
16937
 
 
16938
 
 
16939
@c =====================================================================
 
16940
@c =====================================================================
 
16941
 
 
16942
@node Copying This Manual, Request Index, Installation, Top
 
16943
@appendix Copying This Manual
 
16944
 
 
16945
@include fdl.texi
 
16946
 
 
16947
 
 
16948
 
 
16949
@c =====================================================================
 
16950
@c =====================================================================
 
16951
 
 
16952
@node Request Index, Escape Index, Copying This Manual, Top
 
16953
@appendix Request Index
 
16954
 
 
16955
Requests appear without the leading control character (normally either
 
16956
@samp{.} or @samp{'}).
 
16957
 
 
16958
@printindex rq
 
16959
 
 
16960
 
 
16961
 
 
16962
@c =====================================================================
 
16963
@c =====================================================================
 
16964
 
 
16965
@node Escape Index, Operator Index, Request Index, Top
 
16966
@appendix Escape Index
 
16967
 
 
16968
Any escape sequence @code{\@var{X}} with @var{X} not in the list below
 
16969
emits a warning, printing glyph @var{X}.
 
16970
 
 
16971
@printindex es
 
16972
 
 
16973
 
 
16974
 
 
16975
@c =====================================================================
 
16976
@c =====================================================================
 
16977
 
 
16978
@node Operator Index, Register Index, Escape Index, Top
 
16979
@appendix Operator Index
 
16980
 
 
16981
@printindex op
 
16982
 
 
16983
 
 
16984
 
 
16985
@c =====================================================================
 
16986
@c =====================================================================
 
16987
 
 
16988
@node Register Index, Macro Index, Operator Index, Top
 
16989
@appendix Register Index
 
16990
 
 
16991
The macro package or program a specific register belongs to is appended in
 
16992
brackets.
 
16993
 
 
16994
A register name@tie{}@code{x} consisting of exactly one character can be
 
16995
accessed as @samp{\nx}.  A register name @code{xx} consisting of exactly
 
16996
two characters can be accessed as @samp{\n(xx}.  Register names
 
16997
@code{xxx} of any length can be accessed as @samp{\n[xxx]}.
 
16998
 
 
16999
@printindex vr
 
17000
 
 
17001
 
 
17002
 
 
17003
@c =====================================================================
 
17004
@c =====================================================================
 
17005
 
 
17006
@node Macro Index, String Index, Register Index, Top
 
17007
@appendix Macro Index
 
17008
 
 
17009
The macro package a specific macro belongs to is appended in brackets.
 
17010
They appear without the leading control character (normally @samp{.}).
 
17011
 
 
17012
@printindex ma
 
17013
 
 
17014
 
 
17015
 
 
17016
@c =====================================================================
 
17017
@c =====================================================================
 
17018
 
 
17019
@node String Index, Glyph Name Index, Macro Index, Top
 
17020
@appendix String Index
 
17021
 
 
17022
The macro package or program a specific string belongs to is appended in
 
17023
brackets.
 
17024
 
 
17025
A string name@tie{}@code{x} consisting of exactly one character can be
 
17026
accessed as @samp{\*x}.  A string name @code{xx} consisting of exactly
 
17027
two characters can be accessed as @samp{\*(xx}.  String names @code{xxx}
 
17028
of any length can be accessed as @samp{\*[xxx]}.
 
17029
 
 
17030
 
 
17031
@printindex st
 
17032
 
 
17033
 
 
17034
 
 
17035
@c =====================================================================
 
17036
@c =====================================================================
 
17037
 
 
17038
@node Glyph Name Index, Font File Keyword Index, String Index, Top
 
17039
@appendix Glyph Name Index
 
17040
 
 
17041
A glyph name @code{xx} consisting of exactly two characters can be
 
17042
accessed as @samp{\(xx}.  Glyph names @code{xxx} of any length can be
 
17043
accessed as @samp{\[xxx]}.
 
17044
 
 
17045
@c XXX
 
17046
 
 
17047
 
 
17048
 
 
17049
@c =====================================================================
 
17050
@c =====================================================================
 
17051
 
 
17052
@node Font File Keyword Index, Program and File Index, Glyph Name Index, Top
 
17053
@appendix Font File Keyword Index
 
17054
 
 
17055
@printindex ky
 
17056
 
 
17057
 
 
17058
 
 
17059
@c =====================================================================
 
17060
@c =====================================================================
 
17061
 
 
17062
@node Program and File Index, Concept Index, Font File Keyword Index, Top
 
17063
@appendix Program and File Index
 
17064
 
 
17065
@printindex pg
 
17066
 
 
17067
 
 
17068
 
 
17069
@c =====================================================================
 
17070
@c =====================================================================
 
17071
 
 
17072
@node Concept Index,  , Program and File Index, Top
 
17073
@appendix Concept Index
 
17074
 
 
17075
@printindex cp
 
17076
 
 
17077
 
 
17078
@bye
 
17079
 
 
17080
@c Local Variables:
 
17081
@c mode: texinfo
 
17082
@c coding: latin-1
 
17083
@c End: