Imported Upstream version 1.22.4
[platform/upstream/groff.git] / doc / groff.texi
1 \input texinfo
2
3 @c
4 @c Please convert this manual with `texi2dvi -e groff.texi' 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.4.
28
29 Copyright @copyright{} 1994--2018 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 @c
108 @c By default, only the first item generates an index entry.  To
109 @c override this, use a variant with a trailing `x' (like
110 @c `@DefmacItemx').
111
112
113 @c a dummy macro to assure the `@def...'
114
115 @macro defdummy
116 @c
117 @end macro
118
119
120 @c definition of requests
121
122 @macro Defreq{name, arg}
123 @deffn Request @t{.\name\} \arg\
124 @rqindex \name\
125 @c
126 @end macro
127
128 @macro DefreqList{name, arg}
129 @deffn Request @t{.\name\} \arg\
130 @defdummy
131 @rqindex \name\
132 @c
133 @end macro
134
135 @macro DefreqItem{name, arg}
136 @deffnx Request @t{.\name\} \arg\
137 @defdummy
138 @c
139 @end macro
140
141 @macro DefreqItemx{name, arg}
142 @deffnx Request @t{.\name\} \arg\
143 @defdummy
144 @rqindex \name\
145 @c
146 @end macro
147
148 @macro DefreqListEnd{name, arg}
149 @deffnx Request @t{.\name\} \arg\
150 @c
151 @end macro
152
153 @macro DefreqListEndx{name, arg}
154 @deffnx Request @t{.\name\} \arg\
155 @rqindex \name\
156 @c
157 @end macro
158
159 @macro endDefreq
160 @end deffn
161 @end macro
162
163
164 @c definition of escapes
165
166 @macro Defesc{name, delimI, arg, delimII}
167 @deffn Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
168 @esindex \name\
169 @c
170 @end macro
171
172 @macro DefescList{name, delimI, arg, delimII}
173 @deffn Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
174 @defdummy
175 @esindex \name\
176 @c
177 @end macro
178
179 @macro DefescItem{name, delimI, arg, delimII}
180 @deffnx Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
181 @defdummy
182 @c
183 @end macro
184
185 @macro DefescItemx{name, delimI, arg, delimII}
186 @deffnx Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
187 @defdummy
188 @esindex \name\
189 @c
190 @end macro
191
192 @macro DefescListEnd{name, delimI, arg, delimII}
193 @deffnx Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
194 @c
195 @end macro
196
197 @macro DefescListEndx{name, delimI, arg, delimII}
198 @deffnx Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
199 @esindex \name\
200 @c
201 @end macro
202
203 @macro endDefesc
204 @end deffn
205 @end macro
206
207
208 @c definition of registers
209
210 @macro Defreg{name}
211 @deffn Register @t{\\n[\name\]}
212 @vindex \name\
213 @c
214 @end macro
215
216 @macro DefregList{name}
217 @deffn Register @t{\\n[\name\]}
218 @defdummy
219 @vindex \name\
220 @c
221 @end macro
222
223 @macro DefregItem{name}
224 @deffnx Register @t{\\n[\name\]}
225 @defdummy
226 @c
227 @end macro
228
229 @macro DefregItemx{name}
230 @deffnx Register @t{\\n[\name\]}
231 @defdummy
232 @vindex \name\
233 @c
234 @end macro
235
236 @macro DefregListEnd{name}
237 @deffnx Register @t{\\n[\name\]}
238 @c
239 @end macro
240
241 @macro DefregListEndx{name}
242 @deffnx Register @t{\\n[\name\]}
243 @vindex \name\
244 @c
245 @end macro
246
247 @macro endDefreg
248 @end deffn
249 @end macro
250
251
252 @c definition of registers specific to macro packages, preprocessors, etc.
253
254 @macro Defmpreg{name, package}
255 @deffn Register @t{\\n[\name\]}
256 @vindex \name\ @r{[}\package\@r{]}
257 @c
258 @end macro
259
260 @macro DefmpregList{name, package}
261 @deffn Register @t{\\n[\name\]}
262 @defdummy
263 @vindex \name\ @r{[}\package\@r{]}
264 @c
265 @end macro
266
267 @macro DefmpregItem{name, package}
268 @deffnx Register @t{\\n[\name\]}
269 @defdummy
270 @c
271 @end macro
272
273 @macro DefmpregItemx{name, package}
274 @deffnx Register @t{\\n[\name\]}
275 @defdummy
276 @vindex \name\ @r{[}\package\@r{]}
277 @c
278 @end macro
279
280 @macro DefmpregListEnd{name, package}
281 @deffnx Register @t{\\n[\name\]}
282 @c
283 @end macro
284
285 @macro DefmpregListEndx{name, package}
286 @deffnx Register @t{\\n[\name\]}
287 @vindex \name\ @r{[}\package\@r{]}
288 @c
289 @end macro
290
291 @macro endDefmpreg
292 @end deffn
293 @end macro
294
295
296 @c definition of macros
297
298 @macro Defmac{name, arg, package}
299 @defmac @t{.\name\} \arg\
300 @maindex \name\ @r{[}\package\@r{]}
301 @c
302 @end macro
303
304 @macro DefmacList{name, arg, package}
305 @defmac @t{.\name\} \arg\
306 @defdummy
307 @maindex \name\ @r{[}\package\@r{]}
308 @c
309 @end macro
310
311 @macro DefmacItem{name, arg, package}
312 @defmacx @t{.\name\} \arg\
313 @defdummy
314 @c
315 @end macro
316
317 @macro DefmacItemx{name, arg, package}
318 @defmacx @t{.\name\} \arg\
319 @defdummy
320 @maindex \name\ @r{[}\package\@r{]}
321 @c
322 @end macro
323
324 @macro DefmacListEnd{name, arg, package}
325 @defmacx @t{.\name\} \arg\
326 @c
327 @end macro
328
329 @macro DefmacListEndx{name, arg, package}
330 @defmacx @t{.\name\} \arg\
331 @maindex \name\ @r{[}\package\@r{]}
332 @c
333 @end macro
334
335 @macro endDefmac
336 @end defmac
337 @end macro
338
339
340 @c definition of strings
341
342 @macro Defstr{name, package}
343 @deffn String @t{\\*[\name\]}
344 @stindex \name\ @r{[}\package\@r{]}
345 @c
346 @end macro
347
348 @macro DefstrList{name, package}
349 @deffn String @t{\\*[\name\]}
350 @defdummy
351 @stindex \name\ @r{[}\package\@r{]}
352 @c
353 @end macro
354
355 @macro DefstrItem{name, package}
356 @deffnx String @t{\\*[\name\]}
357 @defdummy
358 @c
359 @end macro
360
361 @macro DefstrItemx{name, package}
362 @deffnx String @t{\\*[\name\]}
363 @defdummy
364 @stindex \name\ @r{[}\package\@r{]}
365 @c
366 @end macro
367
368 @macro DefstrListEnd{name, package}
369 @deffnx String @t{\\*[\name\]}
370 @c
371 @end macro
372
373 @macro DefstrListEndx{name, package}
374 @deffnx String @t{\\*[\name\]}
375 @stindex \name\ @r{[}\package\@r{]}
376 @c
377 @end macro
378
379 @macro endDefstr
380 @end deffn
381 @end macro
382
383
384 @c our example macros
385
386 @macro Example
387 @example
388 @group
389 @end macro
390
391 @macro endExample
392 @end group
393 @end example
394 @end macro
395
396 @macro CartoucheExample
397 @cartouche
398 @example
399 @end macro
400
401 @macro endCartoucheExample
402 @end example
403 @end cartouche
404 @end macro
405
406
407 @c <text>
408
409 @tex
410 \gdef\Langlemacro{\angleleft}
411 \gdef\Ranglemacro{\angleright}
412 @end tex
413
414 @iftex
415 @set Langlemacro @Langlemacro
416 @set Ranglemacro @Ranglemacro
417 @end iftex
418
419 @ifnottex
420 @set Langlemacro <
421 @set Ranglemacro >
422 @end ifnottex
423
424 @macro angles{text}
425 @value{Langlemacro}@r{\text\}@value{Ranglemacro}
426 @end macro
427
428
429 @c a <= sign
430 @c
431 @c Since expansion of macros has changed between texinfo 4.x and 5.x,
432 @c we can't define a macro but have to use @value directly.
433
434 @tex
435 \gdef\LE{\le}
436 @end tex
437
438 @iftex
439 @set LE @LE
440 @end iftex
441
442 @ifnottex
443 @set LE <=
444 @end ifnottex
445
446
447 @c Special care is required with parentheses, brackets, and braces:
448 @c
449 @c . Real parentheses in @deffn produce an error while compiling with
450 @c   TeX.
451 @c . Real brackets use the wrong font in @deffn, overriding @t{}.
452 @c
453 @c . @{ and @} fail with info if used in a macro.
454 @c
455 @c Since macros aren't expanded in @deffn during -E, the following
456 @c definitions are for non-TeX only.
457 @c
458 @c This is true for texinfo 4.0 and above.
459
460 @iftex
461 @set Lparenmacro @lparen
462 @set Rparenmacro @rparen
463 @set Lbrackmacro @lbrack
464 @set Rbrackmacro @rbrack
465 @set Lbracemacro @{
466 @set Rbracemacro @}
467 @end iftex
468
469 @ifnottex
470 @set Lparenmacro (
471 @set Rparenmacro )
472 @set Lbrackmacro [
473 @set Rbrackmacro ]
474 @set Lbracemacro @{
475 @set Rbracemacro @}
476 @end ifnottex
477
478 @macro Lparen{}
479 @value{Lparenmacro}
480 @end macro
481 @macro Rparen{}
482 @value{Rparenmacro}
483 @end macro
484 @macro Lbrack{}
485 @value{Lbrackmacro}
486 @end macro
487 @macro Rbrack{}
488 @value{Rbrackmacro}
489 @end macro
490 @macro Lbrace{}
491 @value{Lbracemacro}
492 @end macro
493 @macro Rbrace{}
494 @value{Rbracemacro}
495 @end macro
496
497
498 @c This suppresses the word `Appendix' in the appendix headers.
499
500 @tex
501 \gdef\gobblefirst#1#2{#2}
502 \gdef\putwordAppendix{\gobblefirst}
503 @end tex
504
505
506 @c We map some latin-1 characters to corresponding texinfo macros.
507 @c Newer versions of texinfo.tex have similar code included already.
508
509 @tex
510 \global\catcode`^^e4\active % Ã¤
511 \gdef^^e4{\"a}
512 \global\catcode`^^c4\active % Ã„
513 \gdef^^c4{\"A}
514 \global\catcode`^^e9\active % Ã©
515 \gdef^^e9{\'e}
516 \global\catcode`^^c9\active % Ã‰
517 \gdef^^c9{\'E}
518 \global\catcode`^^f6\active % Ã¶
519 \gdef^^f6{\"o}
520 \global\catcode`^^d6\active % Ã–
521 \gdef^^d6{\"O}
522 \global\catcode`^^fc\active % Ã¼
523 \gdef^^fc{\"u}
524 \global\catcode`^^dc\active % Ãœ
525 \gdef^^dc{\"U}
526 \global\catcode`^^e6\active % Ã¦
527 \gdef^^e6{\ae}
528 \global\catcode`^^c6\active % Ã†
529 \gdef^^c6{\AE}
530 \global\catcode`^^df\active % ÃŸ
531 \gdef^^df{\ss}
532 @end tex
533
534
535 @c Note: We say `Roman numerals' but `roman font'.
536
537
538 @dircategory Typesetting
539 @direntry
540 * Groff: (groff).               The GNU troff document formatting system.
541 @end direntry
542
543
544 @titlepage
545 @title groff
546 @subtitle The GNU implementation of @code{troff}
547 @subtitle Edition 1.22.4
548 @subtitle Autumn 2018
549 @author by Trent A.@tie{}Fisher
550 @author and Werner Lemberg
551
552 @page
553 @vskip 0pt plus 1filll
554 @insertcopying
555 @end titlepage
556
557 @contents
558
559 @ifnottex
560 @node Top, Introduction, (dir), (dir)
561 @top GNU troff
562 @end ifnottex
563
564 @menu
565 * Introduction::
566 * Invoking groff::
567 * Tutorial for Macro Users::
568 * Macro Packages::
569 * gtroff Reference::
570 * Preprocessors::
571 * Output Devices::
572 * File formats::
573 * Installation::
574 * Copying This Manual::
575 * Request Index::
576 * Escape Index::
577 * Operator Index::
578 * Register Index::
579 * Macro Index::
580 * String Index::
581 * Glyph Name Index::
582 * Font File Keyword Index::
583 * Program and File Index::
584 * Concept Index::
585 @end menu
586
587 @ifnottex
588 @insertcopying
589 @end ifnottex
590
591
592
593 @c =====================================================================
594 @c =====================================================================
595
596 @node Introduction, Invoking groff, Top, Top
597 @chapter Introduction
598 @cindex introduction
599
600 GNU @code{troff} (or @code{groff}) is a system for typesetting
601 documents.  @code{troff} is very flexible and has been used extensively
602 for some thirty years.  It is well entrenched in the Unix community.
603
604 @menu
605 * What Is groff?::
606 * History::
607 * groff Capabilities::
608 * Macro Package Intro::
609 * Preprocessor Intro::
610 * Output device intro::
611 * Credits::
612 @end menu
613
614
615 @c =====================================================================
616
617 @node What Is groff?, History, Introduction, Introduction
618 @section What Is @code{groff}?
619 @cindex what is @code{groff}?
620 @cindex @code{groff} -- what is it?
621
622 @code{groff} belongs to an older generation of document preparation
623 systems, which operate more like compilers than the more recent
624 interactive @acronym{WYSIWYG}@footnote{What You See Is What You Get}
625 systems.  @code{groff} and its contemporary counterpart, @TeX{}, both
626 work using a @dfn{batch} paradigm: The input (or @dfn{source}) files are
627 normal text files with embedded formatting commands.  These files can
628 then be processed by @code{groff} to produce a typeset document on a
629 variety of devices.
630
631 @code{groff} should not be confused with a @dfn{word processor}, an
632 integrated system of editor and text formatter.  Also, many word
633 processors follow the @acronym{WYSIWYG} paradigm discussed earlier.
634
635 Although @acronym{WYSIWYG} systems may be easier to use, they have a
636 number of disadvantages compared to @code{troff}:
637
638 @itemize @bullet
639 @item
640 They must be used on a graphics display to work on a document.
641
642 @item
643 Most of the @acronym{WYSIWYG} systems are either non-free or are not
644 very portable.
645
646 @item
647 @code{troff} is firmly entrenched in all Unix systems.
648
649 @item
650 It is difficult to have a wide range of capabilities within the confines
651 of a GUI/window system.
652
653 @item
654 It is more difficult to make global changes to a document.
655 @end itemize
656
657 @quotation
658 ``GUIs normally make it simple to accomplish simple actions and
659 impossible to accomplish complex actions.''  --Doug Gwyn (22/Jun/91 in
660 @code{comp.unix.wizards})
661 @end quotation
662
663
664 @c =====================================================================
665
666 @node History, groff Capabilities, What Is groff?, Introduction
667 @section History
668 @cindex history
669
670 @cindex @code{RUNOFF}, the program
671 @cindex @code{rf}, the program
672 @code{troff} can trace its origins back to a formatting program called
673 @code{RUNOFF}, written by Jerry Saltzer, which ran on the @acronym{CTSS}
674 (@emph{Compatible Time Sharing System}, a project of MIT, the
675 Massachusetts Institute of Technology) in the
676 mid-sixties.@footnote{Jerome H.@: Saltzer, a grad student then, later a
677 Professor of Electrical Engineering, now retired.  Saltzer's PhD thesis
678 was the first application for @code{RUNOFF} and is available from the
679 MIT Libraries.}  The name came from the use of the phrase ``run off a
680 document'', meaning to print it out.
681 @c
682 @c Tom Van Vleck <thvv@multicians.org> writes about the following:
683 @c
684 @c I am not sure about this.. I think the BCPL runoff was the port to
685 @c the 635 architecture, and that the order of events is
686 @c 1. CTSS runoff
687 @c 2. BCPL runoff on Multics
688 @c 3. BCPL runoff on 635
689 @c 4. rf on PDP-7
690 @c
691 Bob Morris ported it to the 635 architecture and called the program
692 @code{roff} (an abbreviation of @code{runoff}).  It was rewritten as
693 @code{rf} for the @w{PDP-7} (before having Unix), and at the
694 same time (1969), Doug McIlroy rewrote an extended and simplified
695 version of @code{roff} in the @acronym{BCPL} programming language.
696
697 @cindex @code{roff}, the program
698 In 1971, the Unix developers wanted to get a @w{PDP-11}, and to justify
699 the cost, proposed the development of a document formatting system for
700 the @acronym{AT&T} patents division.  This first formatting program was
701 a reimplementation of McIlroy's @code{roff}, written by J.@tie{}F.@:
702 Ossanna.
703
704 @cindex @code{nroff}, the program
705 When they needed a more flexible language, a new version of @code{roff}
706 called @code{nroff} (``Newer @code{roff}'') was written.  It had a much
707 more complicated syntax, but provided the basis for all future versions.
708 When they got a Graphic Systems CAT Phototypesetter, Ossanna wrote a
709 version of @code{nroff} that would drive it.  It was dubbed
710 @code{troff}, for ``typesetter @code{roff}'', although many people have
711 speculated that it actually means ``Times @code{roff}'' because of the
712 use of the Times font family in @code{troff} by default.  As such, the
713 name @code{troff} is pronounced `@w{t-roff}' rather than `trough'.
714
715 With @code{troff} came @code{nroff} (they were actually the same program
716 except for some @samp{#ifdef}s), which was for producing output for line
717 printers and character terminals.  It understood everything @code{troff}
718 did, and ignored the commands that were not applicable (e.g.@: font
719 changes).
720
721 Since there are several things that cannot be done easily in
722 @code{troff}, work on several preprocessors began.  These programs would
723 transform certain parts of a document into @code{troff}, which made a
724 very natural use of pipes in Unix.
725
726 The @code{eqn} preprocessor allowed mathematical formulae to be specified
727 in a much simpler and more intuitive manner.  @code{tbl} is a
728 preprocessor for formatting tables.  The @code{refer} preprocessor (and
729 the similar program, @code{bib}) processes citations in a document
730 according to a bibliographic database.
731
732 Unfortunately, Ossanna's @code{troff} was written in @w{PDP-11} assembly
733 language and produced output specifically for the CAT phototypesetter.
734 He rewrote it in C, although it was now 7000@tie{}lines of uncommented
735 code and still dependent on the CAT@.  As the CAT became less common, and
736 was no longer supported by the manufacturer, the need to make it support
737 other devices became a priority.  However, before this could be done,
738 Ossanna died by a severe heart attack in a hospital while recovering
739 from a previous one.
740
741 @pindex ditroff
742 @cindex @code{ditroff}, the program
743 So, Brian Kernighan took on the task of rewriting @code{troff}.  The
744 newly rewritten version produced device independent code that was very
745 easy for postprocessors to read and translate to the appropriate printer
746 codes.  Also, this new version of @code{troff} (called @code{ditroff}
747 for ``device independent @code{troff}'') had several extensions, which
748 included drawing functions.
749
750 Due to the additional abilities of the new version of @code{troff},
751 several new preprocessors appeared.  The @code{pic} preprocessor
752 provides a wide range of drawing functions.  Likewise the @code{ideal}
753 preprocessor did the same, although via a much different paradigm.  The
754 @code{grap} preprocessor took specifications for graphs, but, unlike
755 other preprocessors, produced @code{pic} code.
756
757 James Clark began work on a GNU implementation of @code{ditroff} in
758 early@tie{}1989.  The first version, @code{groff}@tie{}0.3.1, was
759 released June@tie{}1990.  @code{groff} included:
760
761 @itemize @bullet
762 @item
763 A replacement for @code{ditroff} with many extensions.
764
765 @item
766 The @code{soelim}, @code{pic}, @code{tbl}, and @code{eqn} preprocessors.
767
768 @item
769 Postprocessors for character devices, @sc{PostScript}, @TeX{} DVI, and
770 X@tie{}Windows.  GNU @code{troff} also eliminated the need for a
771 separate @code{nroff} program with a postprocessor that would produce
772 @acronym{ASCII} output.
773
774 @item
775 A version of the @file{me} macros and an implementation of the
776 @file{man} macros.
777 @end itemize
778
779 Also, a front-end was included that could construct the, sometimes
780 painfully long, pipelines required for all the post- and preprocessors.
781
782 Development of GNU @code{troff} progressed rapidly, and saw the
783 additions of a replacement for @code{refer}, an implementation of the
784 @file{ms} and @file{mm} macros, and a program to deduce how to format a
785 document (@code{grog}).
786
787 It was declared a stable (i.e.@: non-beta) package with the release of
788 version@tie{}1.04 around November@tie{}1991.
789
790 Beginning in@tie{}1999, @code{groff} has new maintainers (the package
791 was an orphan for a few years).  As a result, new features and programs
792 like @code{grn}, a preprocessor for gremlin images, and an output device
793 to produce @acronym{HTML} and @acronym{XHTML} have been added.
794
795
796 @c =====================================================================
797
798 @node groff Capabilities, Macro Package Intro, History, Introduction
799 @section @code{groff} Capabilities
800 @cindex @code{groff} capabilities
801 @cindex capabilities of @code{groff}
802
803 So what exactly is @code{groff} capable of doing?  @code{groff} provides
804 a wide range of low-level text formatting operations.  Using these, it
805 is possible to perform a wide range of formatting tasks, such as
806 footnotes, table of contents, multiple columns, etc.  Here's a list of
807 the most important operations supported by @code{groff}:
808
809 @itemize @bullet
810 @item
811 text filling, adjusting, and centering
812
813 @item
814 hyphenation
815
816 @item
817 page control
818
819 @item
820 font and glyph size control
821
822 @item
823 vertical spacing (e.g.@: double-spacing)
824
825 @item
826 line length and indenting
827
828 @item
829 macros, strings, diversions, and traps
830
831 @item
832 number registers
833
834 @item
835 tabs, leaders, and fields
836
837 @item
838 input and output conventions and character translation
839
840 @item
841 overstrike, bracket, line drawing, and zero-width functions
842
843 @item
844 local horizontal and vertical motions and the width function
845
846 @item
847 three-part titles
848
849 @item
850 output line numbering
851
852 @item
853 conditional acceptance of input
854
855 @item
856 environment switching
857
858 @item
859 insertions from the standard input
860
861 @item
862 input/output file switching
863
864 @item
865 output and error messages
866 @end itemize
867
868
869 @c =====================================================================
870
871 @node Macro Package Intro, Preprocessor Intro, groff Capabilities, Introduction
872 @section Macro Packages
873 @cindex macro packages
874
875 Since @code{groff} provides such low-level facilities, it can be quite
876 difficult to use by itself.  However, @code{groff} provides a
877 @dfn{macro} facility to specify how certain routine operations
878 (e.g.@tie{}starting paragraphs, printing headers and footers, etc.)@:
879 should be done.  These macros can be collected together into a
880 @dfn{macro package}.  There are a number of macro packages available;
881 the most common (and the ones described in this manual) are @file{man},
882 @file{mdoc}, @file{me}, @file{ms}, and @file{mm}.
883
884
885 @c =====================================================================
886
887 @node Preprocessor Intro, Output device intro, Macro Package Intro, Introduction
888 @section Preprocessors
889 @cindex preprocessors
890
891 Although @code{groff} provides most functions needed to format a
892 document, some operations would be unwieldy (e.g.@: to draw pictures).
893 Therefore, programs called @dfn{preprocessors} were written that
894 understand their own language and produce the necessary @code{groff}
895 operations.  These preprocessors are able to differentiate their own
896 input from the rest of the document via markers.
897
898 To use a preprocessor, Unix pipes are used to feed the output from the
899 preprocessor into @code{groff}.  Any number of preprocessors may be used
900 on a given document; in this case, the preprocessors are linked together
901 into one pipeline.  However, with @code{groff}, the user does not need
902 to construct the pipe, but only tell @code{groff} what preprocessors to
903 use.
904
905 @code{groff} currently has preprocessors for producing tables
906 (@code{tbl}), typesetting equations (@code{eqn}), drawing pictures
907 (@code{pic} and @code{grn}), processing bibliographies
908 (@code{refer}), and drawing chemical structures (@code{chem}).  An
909 associated program that is useful when dealing with preprocessors is
910 @code{soelim}.
911
912 A free implementation of @code{grap}, a preprocessor for drawing graphs,
913 can be obtained as an extra package; @code{groff} can use @code{grap}
914 also.
915
916 Unique to @code{groff} is the @code{preconv} preprocessor that enables
917 @code{groff} to handle documents in various input encodings.
918
919 There are other preprocessors in existence, but, unfortunately, no free
920 implementations are available.  Among them is a preprocessor for drawing
921 mathematical pictures (@code{ideal}).
922
923
924 @c =====================================================================
925
926 @node Output device intro, Credits, Preprocessor Intro, Introduction
927 @section Output Devices
928 @cindex postprocessors
929 @cindex output devices
930 @cindex devices for output
931
932 @code{groff} actually produces device independent code that may be fed
933 into a postprocessor to produce output for a particular device.
934 Currently, @code{groff} has postprocessors for @sc{PostScript} devices,
935 character terminals, X@tie{}Windows (for previewing), @TeX{} DVI format,
936 HP LaserJet@tie{}4 and Canon LBP printers (which use @acronym{CAPSL}),
937 @acronym{HTML}, @acronym{XHTML}, and PDF.
938
939
940 @c =====================================================================
941
942 @node Credits,  , Output device intro, Introduction
943 @section Credits
944 @cindex credits
945
946 Large portions of this manual were taken from existing documents, most
947 notably, the manual pages for the @code{groff} package by James Clark,
948 and Eric Allman's papers on the @file{me} macro package.
949
950 The section on the @file{man} macro package is partly based on
951 Susan@tie{}G.@: Kleinmann's @file{groff_man} manual page written for the
952 Debian GNU/Linux system.
953
954 Larry Kollar contributed the section on the @file{ms} macro package.
955
956
957
958 @c =====================================================================
959 @c =====================================================================
960
961 @node Invoking groff, Tutorial for Macro Users, Introduction, Top
962 @chapter Invoking @code{groff}
963 @cindex invoking @code{groff}
964 @cindex @code{groff} invocation
965
966 This section focuses on how to invoke the @code{groff} front end.  This
967 front end takes care of the details of constructing the pipeline among
968 the preprocessors, @code{gtroff} and the postprocessor.
969
970 It has become a tradition that GNU programs get the prefix @samp{g} to
971 distinguish it from its original counterparts provided by the host (see
972 @ref{Environment}, for more details).  Thus, for example, @code{geqn} is
973 GNU @code{eqn}.  On operating systems like GNU/Linux or the Hurd, which
974 don't contain proprietary versions of @code{troff}, and on
975 MS-DOS/MS-Windows, where @code{troff} and associated programs are not
976 available at all, this prefix is omitted since GNU @code{troff} is the
977 only used incarnation of @code{troff}.  Exception: @samp{groff} is never
978 replaced by @samp{roff}.
979
980 In this document, we consequently say @samp{gtroff} when talking about
981 the GNU @code{troff} program.  All other implementations of @code{troff}
982 are called @acronym{AT&T} @code{troff}, which is the common origin of all
983 @code{troff} derivates (with more or less compatible changes).
984 Similarly, we say @samp{gpic}, @samp{geqn}, etc.
985
986 @menu
987 * Groff Options::
988 * Environment::
989 * Macro Directories::
990 * Font Directories::
991 * Paper Size::
992 * Invocation Examples::
993 @end menu
994
995
996 @c =====================================================================
997
998 @node Groff Options, Environment, Invoking groff, Invoking groff
999 @section Options
1000 @cindex options
1001
1002 @pindex groff
1003 @pindex gtroff
1004 @pindex gpic
1005 @pindex geqn
1006 @pindex ggrn
1007 @pindex grap
1008 @pindex gtbl
1009 @pindex gchem
1010 @pindex grefer
1011 @pindex gsoelim
1012 @pindex preconv
1013 @code{groff} normally runs the @code{gtroff} program and a
1014 postprocessor appropriate for the selected device.  The default device
1015 is @samp{ps} (but it can be changed when @code{groff} is configured and
1016 built).  It can optionally preprocess with any of @code{gpic},
1017 @code{geqn}, @code{gtbl}, @code{ggrn}, @code{grap}, @code{gchem},
1018 @code{grefer}, @code{gsoelim}, or @code{preconv}.
1019
1020 This section only documents options to the @code{groff} front end.  Many
1021 of the arguments to @code{groff} are passed on to @code{gtroff},
1022 therefore those are also included.  Arguments to pre- or postprocessors
1023 can be found in @ref{Invoking gpic}, @ref{Invoking geqn}, @ref{Invoking
1024 gtbl}, @ref{Invoking ggrn}, @ref{Invoking grefer}, @ref{Invoking gchem},
1025 @ref{Invoking gsoelim}, @ref{Invoking preconv}, @ref{Invoking grotty},
1026 @ref{Invoking grops}, @ref{Invoking gropdf}, @ref{Invoking grohtml},
1027 @ref{Invoking grodvi}, @ref{Invoking grolj4}, @ref{Invoking grolbp}, and
1028 @ref{Invoking gxditview}.
1029
1030 The command-line format for @code{groff} is:
1031
1032 @Example
1033 groff [ -abceghijklpstvzCEGNRSUVXZ ] [ -d@var{cs} ] [ -D@var{arg} ]
1034       [ -f@var{fam} ] [ -F@var{dir} ] [ -I@var{dir} ] [ -K@var{arg} ]
1035       [ -L@var{arg} ] [ -m@var{name} ] [ -M@var{dir} ] [ -n@var{num} ]
1036       [ -o@var{list} ] [ -P@var{arg} ] [ -r@var{cn} ] [ -T@var{dev} ]
1037       [ -w@var{name} ] [ -W@var{name} ] [ @var{files}@dots{} ]
1038 @endExample
1039
1040 The command-line format for @code{gtroff} is as follows.
1041
1042 @Example
1043 gtroff [ -abcivzCERU ] [ -d@var{cs} ] [ -f@var{fam} ] [ -F@var{dir} ]
1044        [ -m@var{name} ] [ -M@var{dir} ] [ -n@var{num} ] [ -o@var{list} ]
1045        [ -r@var{cn} ] [ -T@var{name} ] [ -w@var{name} ] [ -W@var{name} ]
1046        [ @var{files}@dots{} ]
1047 @endExample
1048
1049 @noindent
1050 Obviously, many of the options to @code{groff} are actually passed on to
1051 @code{gtroff}.
1052
1053 Options without an argument can be grouped behind a
1054 single@tie{}@option{-}.  A filename of@tie{}@file{-} denotes the
1055 standard input.  It is possible to have whitespace between an option and
1056 its parameter.
1057
1058 The @code{grog} command can be used to guess the correct @code{groff}
1059 command to format a file.
1060
1061 Here's the description of the command-line options:
1062
1063 @cindex command-line options
1064 @table @samp
1065 @item -a
1066 @cindex @acronym{ASCII} approximation output register (@code{.A})
1067 Generate an @acronym{ASCII} approximation of the typeset output.  The
1068 read-only register @code{.A} is then set to@tie{}1.  @xref{Built-in
1069 Registers}.  A typical example is
1070
1071 @Example
1072 groff -a -man -Tdvi troff.man | less
1073 @endExample
1074
1075 @noindent
1076 which shows how lines are broken for the DVI device.  Note that this
1077 option is rather useless today since graphic output devices are
1078 available virtually everywhere.
1079
1080 @item -b
1081 Print a backtrace with each warning or error message.  This backtrace
1082 should help track down the cause of the error.  The line numbers given
1083 in the backtrace may not always be correct: @code{gtroff} can get
1084 confused by @code{as} or @code{am} requests while counting line numbers.
1085
1086 @item -c
1087 Suppress color output.
1088
1089 @item -C
1090 Enable compatibility mode.  @xref{Implementation Differences}, for the
1091 list of incompatibilities between @code{groff} and @acronym{AT&T}
1092 @code{troff}.
1093
1094 @item -d@var{c}@var{s}
1095 @itemx -d@var{name}=@var{s}
1096 Define @var{c} or @var{name} to be a string@tie{}@var{s}.
1097 @var{c}@tie{}must be a one-letter name; @var{name} can be of arbitrary
1098 length.  All string assignments happen before loading any macro file
1099 (including the start-up file).
1100
1101 @item -D@var{arg}
1102 Set default input encoding used by @code{preconv} to @var{arg}.  Implies
1103 @option{-k}.
1104
1105 @item -e
1106 Preprocess with @code{geqn}.
1107
1108 @item -E
1109 Inhibit all error messages.
1110
1111 @item -f@var{fam}
1112 Use @var{fam} as the default font family.  @xref{Font Families}.
1113
1114 @item -F@var{dir}
1115 Search @file{@var{dir}} for subdirectories @file{dev@var{name}}
1116 (@var{name} is the name of the device), for the @file{DESC} file, and
1117 for font files before looking in the standard directories (@pxref{Font
1118 Directories}).  This option is passed to all pre- and postprocessors
1119 using the @env{GROFF_FONT_PATH} environment variable.
1120
1121 @item -g
1122 Preprocess with @code{ggrn}.
1123
1124 @item -G
1125 Preprocess with @code{grap}.  Implies @option{-p}.
1126
1127 @item -h
1128 Print a help message.
1129
1130 @item -i
1131 Read the standard input after all the named input files have been
1132 processed.
1133
1134 @item -I@var{dir}
1135 This option may be used to specify a directory to search for files.
1136 It is passed to the following programs:
1137
1138 @itemize
1139 @item
1140 @code{gsoelim} (see @ref{gsoelim} for more details);
1141 it also implies @code{groff}'s @option{-s} option.
1142
1143 @item
1144 @code{gtroff}; it is used to search files named in the @code{psbb} and
1145 @code{so} requests.
1146
1147 @item
1148 @code{grops}; it is used to search files named in the
1149 @w{@code{\X'ps: import}} and @w{@code{\X'ps: file}} escapes.
1150 @end itemize
1151
1152 The current directory is always searched first.  This option may be
1153 specified more than once; the directories are searched in the order
1154 specified.  No directory search is performed for files specified using
1155 an absolute path.
1156
1157 @item -j
1158 Preprocess with @code{gchem}.  Implies @option{-p}.
1159
1160 @item -k
1161 Preprocess with @code{preconv}.  This is run before any other
1162 preprocessor.  Please refer to @code{preconv}'s manual page for its
1163 behaviour if no @option{-K} (or @option{-D}) option is specified.
1164
1165 @item -K@var{arg}
1166 Set input encoding used by preconv to @var{arg}.  Implies @option{-k}.
1167
1168 @item -l
1169 Send the output to a spooler for printing.  The command used for this is
1170 specified by the @code{print} command in the device description file
1171 (see @ref{Font Files}, for more info).  If not present, @option{-l} is
1172 ignored.
1173
1174 @item -L@var{arg}
1175 Pass @var{arg} to the spooler.  Each argument should be passed with a
1176 separate @option{-L} option.  Note that @code{groff} does not prepend a
1177 @samp{-} to @var{arg} before passing it to the postprocessor.  If the
1178 @code{print} keyword in the device description file is missing,
1179 @option{-L} is ignored.
1180
1181 @item -m@var{name}
1182 Read in the file @file{@var{name}.tmac}.  Normally @code{groff} searches
1183 for this in its macro directories.  If it isn't found, it tries
1184 @file{tmac.@var{name}} (searching in the same directories).
1185
1186 @item -M@var{dir}
1187 Search directory @file{@var{dir}} for macro files before the standard
1188 directories (@pxref{Macro Directories}).
1189
1190 @item -n@var{num}
1191 Number the first page @var{num}.
1192
1193 @item -N
1194 Don't allow newlines with @code{eqn} delimiters.  This is the same as
1195 the @option{-N} option in @code{geqn}.
1196
1197 @item -o@var{list}
1198 @cindex print current page register (@code{.P})
1199 Output only pages in @var{list}, which is a comma-separated list of page
1200 ranges; @samp{@var{n}} means print page@tie{}@var{n},
1201 @samp{@var{m}-@var{n}} means print every page between @var{m}
1202 and@tie{}@var{n}, @samp{-@var{n}} means print every page up
1203 to@tie{}@var{n}, @samp{@var{n}-} means print every page beginning
1204 with@tie{}@var{n}.  @code{gtroff} exits after printing the last page in
1205 the list.  All the ranges are inclusive on both ends.
1206
1207 Within @code{gtroff}, this information can be extracted with the
1208 @samp{.P} register.  @xref{Built-in Registers}.
1209
1210 If your document restarts page numbering at the beginning of each
1211 chapter, then @code{gtroff} prints the specified page range for each
1212 chapter.
1213
1214 @item -p
1215 Preprocess with @code{gpic}.
1216
1217 @item -P@var{arg}
1218 Pass @var{arg} to the postprocessor.  Each argument should be passed
1219 with a separate @option{-P} option.  Note that @code{groff} does not
1220 prepend @samp{-} to @var{arg} before passing it to the postprocessor.
1221
1222 @item -r@var{c}@var{n}
1223 @itemx -r@var{name}=@var{n}
1224 Set number register@tie{}@var{c} or @var{name} to the
1225 value@tie{}@var{n}.  @var{c}@tie{}must be a one-letter name; @var{name}
1226 can be of arbitrary length.  @var{n}@tie{}can be any @code{gtroff}
1227 numeric expression.  All register assignments happen before loading any
1228 macro file (including the start-up file).
1229
1230 @item -R
1231 Preprocess with @code{grefer}.  No mechanism is provided for passing
1232 arguments to @code{grefer} because most @code{grefer} options have
1233 equivalent commands that can be included in the file.  @xref{grefer},
1234 for more details.
1235
1236 @pindex troffrc
1237 @pindex troffrc-end
1238 Note that @code{gtroff} also accepts a @option{-R} option, which is not
1239 accessible via @code{groff}.  This option prevents the loading of the
1240 @file{troffrc} and @file{troffrc-end} files.
1241
1242 @item -s
1243 Preprocess with @code{gsoelim}.
1244
1245 @item -S
1246 @cindex @code{open} request, and safer mode
1247 @cindex @code{opena} request, and safer mode
1248 @cindex @code{pso} request, and safer mode
1249 @cindex @code{sy} request, and safer mode
1250 @cindex @code{pi} request, and safer mode
1251 @cindex safer mode
1252 @cindex mode, safer
1253 Safer mode.  Pass the @option{-S} option to @code{gpic} and disable the
1254 @code{open}, @code{opena}, @code{pso}, @code{sy}, and @code{pi}
1255 requests.  For security reasons, this is enabled by default.
1256
1257 @item -t
1258 Preprocess with @code{gtbl}.
1259
1260 @item -T@var{dev}
1261 Prepare output for device @var{dev}.  The default device is @samp{ps},
1262 unless changed when @code{groff} was configured and built.  The
1263 following are the output devices currently available:
1264
1265 @table @code
1266 @item ps
1267 For @sc{PostScript} printers and previewers.
1268
1269 @item pdf
1270 For PDF viewers or printers.
1271
1272 @item dvi
1273 For @TeX{} DVI format.
1274
1275 @item X75
1276 For a 75@dmn{dpi} X11 previewer.
1277
1278 @item X75-12
1279 For a 75@dmn{dpi} X11 previewer with a 12@dmn{pt} base font in the
1280 document.
1281
1282 @item X100
1283 For a 100@dmn{dpi} X11 previewer.
1284
1285 @item X100-12
1286 For a 100@dmn{dpi} X11 previewer with a 12@dmn{pt} base font in the
1287 document.
1288
1289 @item ascii
1290 @cindex encoding, output, @acronym{ASCII}
1291 @cindex @acronym{ASCII}, output encoding
1292 @cindex output encoding, @acronym{ASCII}
1293 For typewriter-like devices using the (7-bit) @acronym{ASCII}
1294 character set.
1295
1296 @item latin1
1297 @cindex encoding, output, @w{latin-1} (ISO @w{8859-1})
1298 @cindex @w{latin-1} (ISO @w{8859-1}), output encoding
1299 @cindex ISO @w{8859-1} (@w{latin-1}), output encoding
1300 @cindex output encoding, @w{latin-1} (ISO @w{8859-1})
1301 For typewriter-like devices that support the @w{Latin-1}
1302 (ISO@tie{}@w{8859-1}) character set.
1303
1304 @item utf8
1305 @cindex encoding, output, @w{utf-8}
1306 @cindex @w{utf-8}, output encoding
1307 @cindex output encoding, @w{utf-8}
1308 For typewriter-like devices that use the Unicode (ISO@tie{}10646)
1309 character set with @w{UTF-8} encoding.
1310
1311 @item cp1047
1312 @cindex encoding, output, @acronym{EBCDIC}
1313 @cindex @acronym{EBCDIC}, output encoding
1314 @cindex output encoding, @acronym{EBCDIC}
1315 @cindex encoding, output, cp1047
1316 @cindex cp1047, output encoding
1317 @cindex output encoding, cp1047
1318 @cindex IBM cp1047 output encoding
1319 For typewriter-like devices that use the @acronym{EBCDIC} encoding IBM
1320 cp1047.
1321
1322 @item lj4
1323 For HP LaserJet4-compatible (or other PCL5-compatible) printers.
1324
1325 @item lbp
1326 For Canon @acronym{CAPSL} printers (@w{LBP-4} and @w{LBP-8} series laser
1327 printers).
1328
1329 @pindex pre-grohtml
1330 @pindex post-grohtml
1331 @cindex @code{grohtml}, the program
1332 @item html
1333 @itemx xhtml
1334 To produce @acronym{HTML} and @acronym{XHTML} output, respectively.
1335 Note that this driver consists of two parts, a preprocessor
1336 (@code{pre-grohtml}) and a postprocessor (@code{post-grohtml}).
1337 @end table
1338
1339 @cindex output device name string register (@code{.T})
1340 @cindex output device usage number register (@code{.T})
1341 The predefined @code{gtroff} string register @code{.T} contains the
1342 current output device; the read-only number register @code{.T} is set
1343 to@tie{}1 if this option is used (which is always true if @code{groff}
1344 is used to call @code{gtroff}).  @xref{Built-in Registers}.
1345
1346 The postprocessor to be used for a device is specified by the
1347 @code{postpro} command in the device description file.  (@xref{Font
1348 Files}, for more info.)  This can be overridden with the @option{-X}
1349 option.
1350
1351 @item -U
1352 @cindex mode, unsafe
1353 @cindex unsafe mode
1354 Unsafe mode.  This enables the @code{open}, @code{opena}, @code{pso},
1355 @code{sy}, and @code{pi} requests.
1356
1357 @item -w@var{name}
1358 Enable warning @var{name}.  Available warnings are described in
1359 @ref{Debugging}.  Multiple @option{-w} options are allowed.
1360
1361 @item -W@var{name}
1362 Inhibit warning @var{name}.  Multiple @option{-W} options are allowed.
1363
1364 @item -v
1365 Make programs run by @code{groff} print out their version number.
1366
1367 @item -V
1368 Print the pipeline on @code{stdout} instead of executing it.  If
1369 specified more than once, print the pipeline on @code{stderr} and
1370 execute it.
1371
1372 @item -X
1373 Preview with @code{gxditview} instead of using the usual postprocessor.
1374 This is unlikely to produce good results except with @option{-Tps}.
1375
1376 Note that this is not the same as using @option{-TX75} or
1377 @option{-TX100} to view a document with @code{gxditview}: The former
1378 uses the metrics of the specified device, whereas the latter uses
1379 X-specific fonts and metrics.
1380
1381 @item -z
1382 Suppress output from @code{gtroff}.  Only error messages are printed.
1383
1384 @item -Z
1385 Do not postprocess the output of @code{gtroff}.  Normally @code{groff}
1386 automatically runs the appropriate postprocessor.
1387 @end table
1388
1389
1390 @c =====================================================================
1391
1392 @node Environment, Macro Directories, Groff Options, Invoking groff
1393 @section Environment
1394 @cindex environment variables
1395 @cindex variables in environment
1396
1397 There are also several environment variables (of the operating system,
1398 not within @code{gtroff}) that can modify the behavior of @code{groff}.
1399
1400 @table @code
1401 @item GROFF_BIN_PATH
1402 @tindex GROFF_BIN_PATH@r{, environment variable}
1403 This search path, followed by @code{PATH}, is used for commands executed
1404 by @code{groff}.
1405
1406 @item GROFF_COMMAND_PREFIX
1407 @tindex GROFF_COMMAND_PREFIX@r{, environment variable}
1408 @cindex command prefix
1409 @cindex prefix, for commands
1410 If this is set to@tie{}@var{X}, then @code{groff} runs
1411 @code{@var{X}troff} instead of @code{gtroff}.  This also applies to
1412 @code{tbl}, @code{pic}, @code{eqn}, @code{grn}, @code{chem},
1413 @code{refer}, and @code{soelim}.  It does not apply to @code{grops},
1414 @code{grodvi}, @code{grotty}, @code{pre-grohtml}, @code{post-grohtml},
1415 @code{preconv}, @code{grolj4}, @code{gropdf}, and @code{gxditview}.
1416
1417 The default command prefix is determined during the installation
1418 process.  If a non-GNU troff system is found, prefix @samp{g} is used,
1419 none otherwise.
1420
1421 @item GROFF_ENCODING
1422 @tindex GROFF_ENCODING@r{, environment variable}
1423 The value of this environment value is passed to the @code{preconv}
1424 preprocessor to select the encoding of input files.  Setting this option
1425 implies @code{groff}'s command-line option @option{-k} (that is,
1426 @code{groff} actually always calls @code{preconv}).  If set without a
1427 value, @code{groff} calls @code{preconv} without arguments.  An explicit
1428 @option{-K} command-line option overrides the value of
1429 @env{GROFF_ENCODING}.  See the manual page of @code{preconv} for details.
1430
1431 @item GROFF_FONT_PATH
1432 @tindex GROFF_FONT_PATH@r{, environment variable}
1433 A colon-separated list of directories in which to search for the
1434 @code{dev}@var{name} directory (before the default directories are
1435 tried).  @xref{Font Directories}.
1436
1437 @item GROFF_TMAC_PATH
1438 @tindex GROFF_TMAC_PATH@r{, environment variable}
1439 A colon-separated list of directories in which to search for macro files
1440 (before the default directories are tried).  @xref{Macro Directories}.
1441
1442 @item GROFF_TMPDIR
1443 @tindex GROFF_TMPDIR@r{, environment variable}
1444 @tindex TMPDIR@r{, environment variable}
1445 The directory in which @code{groff} creates temporary files.  If this is
1446 not set and @env{TMPDIR} is set, temporary files are created in that
1447 directory.  Otherwise temporary files are created in a system-dependent
1448 default directory (on Unix and GNU/Linux systems, this is usually
1449 @file{/tmp}).  @code{grops}, @code{grefer}, @code{pre-grohtml}, and
1450 @code{post-grohtml} can create temporary files in this directory.
1451
1452 @item GROFF_TYPESETTER
1453 @tindex GROFF_TYPESETTER@r{, environment variable}
1454 The default output device.
1455
1456 @item SOURCE_DATE_EPOCH
1457 @tindex SOURCE_DATE_EPOCH@r{, environment variable}
1458 A timestamp (expressed as seconds since the Unix epoch) to use in place of
1459 the current time when initializing time-based built-in registers such as
1460 @code{\n[seconds]}.
1461 @end table
1462
1463 Note that MS-DOS and MS-Windows ports of @code{groff} use semi-colons,
1464 rather than colons, to separate the directories in the lists described
1465 above.
1466
1467
1468 @c =====================================================================
1469
1470 @node Macro Directories, Font Directories, Environment, Invoking groff
1471 @section Macro Directories
1472 @cindex macro directories
1473 @cindex directories for macros
1474 @cindex searching macros
1475 @cindex macros, searching
1476
1477 All macro file names must be named @code{@var{name}.tmac} or
1478 @code{tmac.@var{name}} to make the @option{-m@var{name}} command-line
1479 option work.  The @code{mso} request doesn't have this restriction; any
1480 file name can be used, and @code{gtroff} won't try to append or prepend
1481 the @samp{tmac} string.
1482
1483 @cindex tmac, directory
1484 @cindex directory, for tmac files
1485 @cindex tmac, path
1486 @cindex path, for tmac files
1487 @cindex searching macro files
1488 @cindex macro files, searching
1489 @cindex files, macro, searching
1490 Macro files are kept in the @dfn{tmac directories}, all of which
1491 constitute the @dfn{tmac path}.  The elements of the search path for
1492 macro files are (in that order):
1493
1494 @itemize @bullet
1495 @item
1496 The directories specified with @code{gtroff}'s or @code{groff}'s
1497 @option{-M} command-line option.
1498
1499 @item
1500 @tindex GROFF_TMAC_PATH@r{, environment variable}
1501 The directories given in the @env{GROFF_TMAC_PATH} environment variable.
1502
1503 @item
1504 @cindex safer mode
1505 @cindex mode, safer
1506 @cindex unsafe mode
1507 @cindex mode, unsafe
1508 @cindex current directory
1509 @cindex directory, current
1510 The current directory (only if in unsafe mode using the @option{-U}
1511 command-line switch).
1512
1513 @item
1514 @cindex home directory
1515 @cindex directory, home
1516 The home directory.
1517
1518 @item
1519 @cindex site-specific directory
1520 @cindex directory, site-specific
1521 @cindex platform-specific directory
1522 @cindex directory, platform-specific
1523 A platform-dependent directory, a site-specific (platform-independent)
1524 directory, and the main tmac directory; the default locations are
1525
1526 @Example
1527 /usr/local/lib/groff/site-tmac
1528 /usr/local/share/groff/site-tmac
1529 /usr/local/share/groff/1.22.3/tmac
1530 @endExample
1531
1532 @noindent
1533 assuming that the version of @code{groff} is 1.22.3, and the
1534 installation prefix was @file{/usr/local}.  It is possible to fine-tune
1535 those directories during the installation process.
1536 @end itemize
1537
1538
1539 @c =====================================================================
1540
1541 @node Font Directories, Paper Size, Macro Directories, Invoking groff
1542 @section Font Directories
1543 @cindex font directories
1544 @cindex directories for fonts
1545 @cindex searching fonts
1546 @cindex fonts, searching
1547
1548 Basically, there is no restriction how font files for @code{groff} are
1549 named and how long font names are; however, to make the font family
1550 mechanism work (@pxref{Font Families}), fonts within a family should
1551 start with the family name, followed by the shape.  For example, the
1552 Times family uses @samp{T} for the family name and @samp{R}, @samp{B},
1553 @samp{I}, and @samp{BI} to indicate the shapes `roman', `bold',
1554 `italic', and `bold italic', respectively.  Thus the final font names
1555 are @samp{TR}, @samp{TB}, @samp{TI}, and @samp{TBI}.
1556
1557 @cindex font path
1558 @cindex path, for font files
1559 All font files are kept in the @dfn{font directories}, which constitute
1560 the @dfn{font path}.  The file search functions always append the
1561 directory @code{dev}@var{name}, where @var{name} is the name of the
1562 output device.  Assuming, say, DVI output, and @file{/foo/bar} as a font
1563 directory, the font files for @code{grodvi} must be in
1564 @file{/foo/bar/devdvi}.
1565
1566 The elements of the search path for font files are (in that order):
1567
1568 @itemize @bullet
1569 @item
1570 The directories specified with @code{gtroff}'s or @code{groff}'s
1571 @option{-F} command-line option.  All device drivers and some
1572 preprocessors also have this option.
1573
1574 @item
1575 @tindex GROFF_FONT_PATH@r{, environment variable}
1576 The directories given in the @env{GROFF_FONT_PATH} environment variable.
1577
1578 @item
1579 @cindex site-specific directory
1580 @cindex directory, site-specific
1581 A site-specific directory and the main font directory; the default
1582 locations are
1583
1584 @Example
1585 /usr/local/share/groff/site-font
1586 /usr/local/share/groff/1.22.3/font
1587 @endExample
1588
1589 @noindent
1590 assuming that the version of @code{groff} is 1.22.3, and the
1591 installation prefix was @file{/usr/local}.  It is possible to fine-tune
1592 those directories during the installation process.
1593 @end itemize
1594
1595
1596 @c =====================================================================
1597
1598 @node Paper Size, Invocation Examples, Font Directories, Invoking groff
1599 @section Paper Size
1600 @cindex paper size
1601 @cindex size, paper
1602 @cindex landscape page orientation
1603 @cindex orientation, landscape
1604 @cindex page orientation, landscape
1605
1606 In groff, the page size for @code{gtroff} and for output devices are
1607 handled separately.  @xref{Page Layout}, for vertical manipulation of
1608 the page size.  @xref{Line Layout}, for horizontal changes.
1609
1610 A default paper size can be set in the device's @file{DESC} file.  Most
1611 output devices also have a command-line option @option{-p} to override
1612 the default paper size and option @option{-l} to use landscape
1613 orientation.  @xref{DESC File Format}, for a description of the
1614 @code{papersize} keyword, which takes the same argument as @option{-p}.
1615
1616 @pindex papersize.tmac
1617 @pindex troffrc
1618 A convenient shorthand to set a particular paper size for @code{gtroff}
1619 is command-line option @option{-dpaper=@var{size}}.  This defines string
1620 @code{paper}, which is processed in file @file{papersize.tmac} (loaded in
1621 the start-up file @file{troffrc} by default).  Possible values for
1622 @var{size} are the same as the predefined values for the
1623 @code{papersize} keyword (but only in lowercase) except
1624 @code{a7}--@code{d7}.  An appended @samp{l} (ell) character denotes
1625 landscape orientation.
1626
1627 For example, use the following for PS output on A4 paper in landscape
1628 orientation:
1629
1630 @Example
1631 groff -Tps -dpaper=a4l -P-pa4 -P-l -ms foo.ms > foo.ps
1632 @endExample
1633
1634 Note that it is up to the particular macro package to respect default
1635 page dimensions set in this way (most do).
1636
1637
1638 @c =====================================================================
1639
1640 @node Invocation Examples,  , Paper Size, Invoking groff
1641 @section Invocation Examples
1642 @cindex invocation examples
1643 @cindex examples of invocation
1644
1645 This section lists several common uses of @code{groff} and the
1646 corresponding command lines.
1647
1648 @Example
1649 groff file
1650 @endExample
1651
1652 @noindent
1653 This command processes @file{file} without a macro package or a
1654 preprocessor.  The output device is the default, @samp{ps}, and the
1655 output is sent to @code{stdout}.
1656
1657 @Example
1658 groff -t -mandoc -Tascii file | less
1659 @endExample
1660
1661 @noindent
1662 This is basically what a call to the @code{man} program does.
1663 @code{gtroff} processes the manual page @file{file} with the
1664 @file{mandoc} macro file (which in turn either calls the @file{man} or
1665 the @file{mdoc} macro package), using the @code{tbl} preprocessor and
1666 the @acronym{ASCII} output device.  Finally, the @code{less} pager
1667 displays the result.
1668
1669 @Example
1670 groff -X -m me file
1671 @endExample
1672
1673 @noindent
1674 Preview @file{file} with @code{gxditview}, using the @file{me} macro
1675 package.  Since no @option{-T} option is specified, use the default
1676 device (@samp{ps}).  Note that you can either say @w{@samp{-m me}} or
1677 @w{@samp{-me}}; the latter is an anachronism from the early days of
1678 Unix.@footnote{The same is true for the other main macro packages that
1679 come with @code{groff}: @file{man}, @file{mdoc}, @file{ms}, @file{mm},
1680 and @file{mandoc}.  This won't work in general; for example, to load
1681 @file{trace.tmac}, either @samp{-mtrace} or @w{@samp{-m trace}} must be
1682 used.}
1683
1684 @Example
1685 groff -man -rD1 -z file
1686 @endExample
1687
1688 @noindent
1689 Check @file{file} with the @file{man} macro package, forcing
1690 double-sided printing -- don't produce any output.
1691
1692 @menu
1693 * grog::
1694 @end menu
1695
1696 @c ---------------------------------------------------------------------
1697
1698 @node grog,  , Invocation Examples, Invocation Examples
1699 @subsection @code{grog}
1700
1701 @pindex grog
1702 @code{grog} reads files, guesses which of the @code{groff} preprocessors
1703 and/or macro packages are required for formatting them, and prints the
1704 @code{groff} command including those options on the standard output.  It
1705 generates one or more of the options @option{-e}, @option{-man},
1706 @option{-me}, @option{-mm}, @option{-mom}, @option{-ms}, @option{-mdoc},
1707 @option{-mdoc-old}, @option{-p}, @option{-R}, @option{-g}, @option{-G},
1708 @option{-s}, and @option{-t}.
1709
1710 A special file name@tie{}@file{-} refers to the standard input.
1711 Specifying no files also means to read the standard input.  Any
1712 specified options are included in the printed command.  No space is
1713 allowed between options and their arguments.  The only options
1714 recognized are @option{-C} (which is also passed on) to enable
1715 compatibility mode, and @option{-v} to print the version number and
1716 exit.
1717
1718 For example,
1719
1720 @Example
1721 grog -Tdvi paper.ms
1722 @endExample
1723
1724 @noindent
1725 guesses the appropriate command to print @file{paper.ms} and then prints
1726 it to the command line after adding the @option{-Tdvi} option.  For
1727 direct execution, enclose the call to @code{grog} in backquotes at the
1728 Unix shell prompt:
1729
1730 @Example
1731 `grog -Tdvi paper.ms` > paper.dvi
1732 @endExample
1733
1734 @noindent
1735 As seen in the example, it is still necessary to redirect the output to
1736 something meaningful (i.e.@: either a file or a pager program like
1737 @code{less}).
1738
1739
1740
1741 @c =====================================================================
1742 @c =====================================================================
1743
1744 @node Tutorial for Macro Users, Macro Packages, Invoking groff, Top
1745 @chapter Tutorial for Macro Users
1746 @cindex tutorial for macro users
1747 @cindex macros, tutorial for users
1748 @cindex user's tutorial for macros
1749 @cindex user's macro tutorial
1750
1751 Most users tend to use a macro package to format their papers.  This
1752 means that the whole breadth of @code{groff} is not necessary for most
1753 people.  This chapter covers the material needed to efficiently use a
1754 macro package.
1755
1756 @menu
1757 * Basics::
1758 * Common Features::
1759 @end menu
1760
1761
1762 @c =====================================================================
1763
1764 @node Basics, Common Features, Tutorial for Macro Users, Tutorial for Macro Users
1765 @section Basics
1766 @cindex basics of macros
1767 @cindex macro basics
1768
1769 This section covers some of the basic concepts necessary to understand
1770 how to use a macro package.@footnote{This section is derived from
1771 @cite{Writing Papers with nroff using -me} by Eric P.@tie{}Allman.}
1772 References are made throughout to more detailed information, if desired.
1773
1774 @code{gtroff} reads an input file prepared by the user and outputs a
1775 formatted document suitable for publication or framing.  The input
1776 consists of text, or words to be printed, and embedded commands
1777 (@dfn{requests} and @dfn{escapes}), which tell @code{gtroff} how to
1778 format the output.  For more detail on this, see @ref{Embedded
1779 Commands}.
1780
1781 The word @dfn{argument} is used in this chapter to mean a word or number
1782 that appears on the same line as a request, and which modifies the
1783 meaning of that request.  For example, the request
1784
1785 @Example
1786 .sp
1787 @endExample
1788
1789 @noindent
1790 spaces one line, but
1791
1792 @Example
1793 .sp 4
1794 @endExample
1795
1796 @noindent
1797 spaces four lines.  The number@tie{}4 is an argument to the @code{sp}
1798 request, which says to space four lines instead of one.  Arguments are
1799 separated from the request and from each other by spaces (@emph{no}
1800 tabs).  More details on this can be found in @ref{Request and Macro
1801 Arguments}.
1802
1803 The primary function of @code{gtroff} is to collect words from input
1804 lines, fill output lines with those words, justify the right-hand margin
1805 by inserting extra spaces in the line, and output the result.  For
1806 example, the input:
1807
1808 @Example
1809 Now is the time
1810 for all good men
1811 to come to the aid
1812 of their party.
1813 Four score and seven
1814 years ago, etc.
1815 @endExample
1816
1817 @noindent
1818 is read, packed onto output lines, and justified to produce:
1819
1820 @quotation
1821 Now is the time for all good men to come to the aid of their party.
1822 Four score and seven years ago, etc.
1823 @end quotation
1824
1825 @cindex break
1826 @cindex line break
1827 Sometimes a new output line should be started even though the current
1828 line is not yet full; for example, at the end of a paragraph.  To do
1829 this it is possible to cause a @dfn{break}, which starts a new output
1830 line.  Some requests cause a break automatically, as normally do blank
1831 input lines and input lines beginning with a space.
1832
1833 Not all input lines are text to be formatted.  Some input lines are
1834 requests that describe how to format the text.  Requests always have a
1835 period (@samp{.}) or an apostrophe (@samp{'}) as the first character of
1836 the input line.
1837
1838 The text formatter also does more complex things, such as automatically
1839 numbering pages, skipping over page boundaries, putting footnotes in the
1840 correct place, and so forth.
1841
1842 Here are a few hints for preparing text for input to @code{gtroff}.
1843
1844 @itemize @bullet
1845 @item
1846 First, keep the input lines short.  Short input lines are easier to
1847 edit, and @code{gtroff} packs words onto longer lines anyhow.
1848
1849 @item
1850 In keeping with this, it is helpful to begin a new line after every
1851 comma or phrase, since common corrections are to add or delete sentences
1852 or phrases.
1853
1854 @item
1855 End each sentence with two spaces -- or better, start each sentence on a
1856 new line.  @code{gtroff} recognizes characters that usually end a
1857 sentence, and inserts sentence space accordingly.
1858
1859 @item
1860 Do not hyphenate words at the end of lines -- @code{gtroff} is smart
1861 enough to hyphenate words as needed, but is not smart enough to take
1862 hyphens out and join a word back together.  Also, words such as
1863 ``mother-in-law'' should not be broken over a line, since then a space
1864 can occur where not wanted, such as ``@w{mother- in}-law''.
1865 @end itemize
1866
1867 @cindex double-spacing (@code{ls})
1868 @cindex spacing
1869 @code{gtroff} double-spaces output text automatically if you use the
1870 request @w{@samp{.ls 2}}.  Reactivate single-spaced mode by typing
1871 @w{@samp{.ls 1}}.@footnote{If you need finer granularity of the vertical
1872 space, use the @code{pvs} request (@pxref{Changing Type Sizes}).}
1873
1874 A number of requests allow to change the way the output looks, sometimes
1875 called the @dfn{layout} of the output page.  Most of these requests
1876 adjust the placing of @dfn{whitespace} (blank lines or spaces).
1877
1878 @cindex new page (@code{bp})
1879 The @code{bp} request starts a new page, causing a line break.
1880
1881 @cindex blank line (@code{sp})
1882 @cindex empty line (@code{sp})
1883 @cindex line, empty (@code{sp})
1884 The request @w{@samp{.sp @var{N}}} leaves @var{N}@tie{}lines of blank
1885 space.  @var{N}@tie{}can be omitted (meaning skip a single line) or can
1886 be of the form @var{N}i (for @var{N}@tie{}inches) or @var{N}c (for
1887 @var{N}@tie{}centimeters).  For example, the input:
1888
1889 @Example
1890 .sp 1.5i
1891 My thoughts on the subject
1892 .sp
1893 @endExample
1894
1895 @noindent
1896 leaves one and a half inches of space, followed by the line ``My
1897 thoughts on the subject'', followed by a single blank line (more
1898 measurement units are available, see @ref{Measurements}).
1899
1900 @cindex centering lines (@code{ce})
1901 @cindex lines, centering (@code{ce})
1902 Text lines can be centered by using the @code{ce} request.  The line
1903 after @code{ce} is centered (horizontally) on the page.  To center more
1904 than one line, use @w{@samp{.ce @var{N}}} (where @var{N} is the number
1905 of lines to center), followed by the @var{N}@tie{}lines.  To center many
1906 lines without counting them, type:
1907
1908 @Example
1909 .ce 1000
1910 lines to center
1911 .ce 0
1912 @endExample
1913
1914 @noindent
1915 The @w{@samp{.ce 0}} request tells @code{groff} to center zero more
1916 lines, in other words, stop centering.
1917
1918 @cindex line break (@code{br})
1919 @cindex break (@code{br})
1920 All of these requests cause a break; that is, they always start a new
1921 line.  To start a new line without performing any other action, use
1922 @code{br}.
1923
1924
1925 @c =====================================================================
1926
1927 @node Common Features,  , Basics, Tutorial for Macro Users
1928 @section Common Features
1929 @cindex common features
1930 @cindex features, common
1931
1932 @code{gtroff} provides very low-level operations for formatting a
1933 document.  There are many common routine operations that are done in
1934 all documents.  These common operations are written into @dfn{macros}
1935 and collected into a @dfn{macro package}.
1936
1937 All macro packages provide certain common capabilities that fall into
1938 the following categories.
1939
1940 @menu
1941 * Paragraphs::
1942 * Sections and Chapters::
1943 * Headers and Footers::
1944 * Page Layout Adjustment::
1945 * Displays::
1946 * Footnotes and Annotations::
1947 * Table of Contents::
1948 * Indices::
1949 * Paper Formats::
1950 * Multiple Columns::
1951 * Font and Size Changes::
1952 * Predefined Strings::
1953 * Preprocessor Support::
1954 * Configuration and Customization::
1955 @end menu
1956
1957 @c ---------------------------------------------------------------------
1958
1959 @node Paragraphs, Sections and Chapters, Common Features, Common Features
1960 @subsection Paragraphs
1961 @cindex paragraphs
1962
1963 One of the most common and most used capability is starting a paragraph.
1964 There are a number of different types of paragraphs, any of which can be
1965 initiated with macros supplied by the macro package.  Normally,
1966 paragraphs start with a blank line and the first line indented, like the
1967 text in this manual.  There are also block style paragraphs, which omit
1968 the indentation:
1969
1970 @Example
1971 Some   men  look   at  constitutions   with  sanctimonious
1972 reverence, and deem them like the ark of the covenant, too
1973 sacred to be touched.
1974 @endExample
1975
1976 @noindent
1977 And there are also indented paragraphs, which begin with a tag or label
1978 at the margin and the remaining text indented.
1979
1980 @Example
1981 one   This is  the first paragraph.  Notice  how the first
1982       line of  the resulting  paragraph lines up  with the
1983       other lines in the paragraph.
1984 @endExample
1985
1986 @Example
1987 longlabel
1988       This  paragraph   had  a  long   label.   The  first
1989       character of text on the first line does not line up
1990       with  the  text  on  second  and  subsequent  lines,
1991       although they line up with each other.
1992 @endExample
1993
1994 A variation of this is a bulleted list.
1995
1996 @Example
1997 .     Bulleted lists start with a bullet.   It is possible
1998       to use other glyphs instead of the bullet.  In nroff
1999       mode using the ASCII character set for output, a dot
2000       is used instead of a real bullet.
2001 @endExample
2002
2003 @c ---------------------------------------------------------------------
2004
2005 @node Sections and Chapters, Headers and Footers, Paragraphs, Common Features
2006 @subsection Sections and Chapters
2007
2008 Most macro packages supply some form of section headers.  The simplest
2009 kind is simply the heading on a line by itself in bold type.  Others
2010 supply automatically numbered section heading or different heading
2011 styles at different levels.  Some, more sophisticated, macro packages
2012 supply macros for starting chapters and appendices.
2013
2014 @c ---------------------------------------------------------------------
2015
2016 @node Headers and Footers, Page Layout Adjustment, Sections and Chapters, Common Features
2017 @subsection Headers and Footers
2018
2019 Every macro package gives some way to manipulate the @dfn{headers} and
2020 @dfn{footers} (also called @dfn{titles}) on each page.  This is text put
2021 at the top and bottom of each page, respectively, which contain data
2022 like the current page number, the current chapter title, and so on.  Its
2023 appearance is not affected by the running text.  Some packages allow for
2024 different ones on the even and odd pages (for material printed in a book
2025 form).
2026
2027 The titles are called @dfn{three-part titles}, that is, there is a
2028 left-justified part, a centered part, and a right-justified part.  An
2029 automatically generated page number may be put in any of these fields
2030 with the @samp{%} character (see @ref{Page Layout}, for more details).
2031
2032 @c ---------------------------------------------------------------------
2033
2034 @node Page Layout Adjustment, Displays, Headers and Footers, Common Features
2035 @subsection Page Layout
2036
2037 Most macro packages let the user specify top and bottom margins and
2038 other details about the appearance of the printed pages.
2039
2040 @c ---------------------------------------------------------------------
2041
2042 @node Displays, Footnotes and Annotations, Page Layout Adjustment, Common Features
2043 @subsection Displays
2044 @cindex displays
2045
2046 @dfn{Displays} are sections of text to be set off from the body of the
2047 paper.  Major quotes, tables, and figures are types of displays, as are
2048 all the examples used in this document.
2049
2050 @cindex quotes, major
2051 @cindex major quotes
2052 @dfn{Major quotes} are quotes that are several lines long, and hence
2053 are set in from the rest of the text without quote marks around them.
2054
2055 @cindex list
2056 A @dfn{list} is an indented, single-spaced, unfilled display.  Lists
2057 should be used when the material to be printed should not be filled and
2058 justified like normal text, such as columns of figures or the examples
2059 used in this paper.
2060
2061 @cindex keep
2062 A @dfn{keep} is a display of lines that are kept on a single page if
2063 possible.  An example for a keep might be a diagram.  Keeps differ from
2064 lists in that lists may be broken over a page boundary whereas keeps are
2065 not.
2066
2067 @cindex keep, floating
2068 @cindex floating keep
2069 @dfn{Floating keeps} move relative to the text.  Hence, they are good
2070 for things that are referred to by name, such as ``See figure@tie{}3''.
2071 A floating keep appears at the bottom of the current page if it fits;
2072 otherwise, it appears at the top of the next page.  Meanwhile, the
2073 surrounding text `flows' around the keep, thus leaving no blank areas.
2074
2075 @c ---------------------------------------------------------------------
2076
2077 @node Footnotes and Annotations, Table of Contents, Displays, Common Features
2078 @subsection Footnotes and Annotations
2079 @cindex footnotes
2080 @cindex annotations
2081
2082 There are a number of requests to save text for later printing.
2083
2084 @dfn{Footnotes} are printed at the bottom of the current page.
2085
2086 @cindex delayed text
2087 @dfn{Delayed text} is very similar to a footnote except that it is
2088 printed when called for explicitly.  This allows a list of references to
2089 appear (for example) at the end of each chapter, as is the convention in
2090 some disciplines.
2091
2092 Most macro packages that supply this functionality also supply a means
2093 of automatically numbering either type of annotation.
2094
2095 @c ---------------------------------------------------------------------
2096
2097 @node Table of Contents, Indices, Footnotes and Annotations, Common Features
2098 @subsection Table of Contents
2099 @cindex table of contents
2100 @cindex contents, table of
2101
2102 @dfn{Tables of contents} are a type of delayed text having a tag
2103 (usually the page number) attached to each entry after a row of dots.
2104 The table accumulates throughout the paper until printed, usually after
2105 the paper has ended.  Many macro packages provide the ability to have
2106 several tables of contents (e.g.@: a standard table of contents, a list
2107 of tables, etc).
2108
2109 @c ---------------------------------------------------------------------
2110
2111 @node Indices, Paper Formats, Table of Contents, Common Features
2112 @subsection Indices
2113 @cindex index, in macro package
2114
2115 While some macro packages use the term @dfn{index}, none actually
2116 provide that functionality.  The facilities they call indices are
2117 actually more appropriate for tables of contents.
2118
2119 @pindex makeindex
2120 To produce a real index in a document, external tools like the
2121 @code{makeindex} program are necessary.
2122
2123 @c ---------------------------------------------------------------------
2124
2125 @node Paper Formats, Multiple Columns, Indices, Common Features
2126 @subsection Paper Formats
2127 @cindex paper formats
2128
2129 Some macro packages provide stock formats for various kinds of
2130 documents.  Many of them provide a common format for the title and
2131 opening pages of a technical paper.  The @file{mm} macros in particular
2132 provide formats for letters and memoranda.
2133
2134 @c ---------------------------------------------------------------------
2135
2136 @node Multiple Columns, Font and Size Changes, Paper Formats, Common Features
2137 @subsection Multiple Columns
2138
2139 Some macro packages (but not @file{man}) provide the ability to have two
2140 or more columns on a page.
2141
2142 @c ---------------------------------------------------------------------
2143
2144 @node Font and Size Changes, Predefined Strings, Multiple Columns, Common Features
2145 @subsection Font and Size Changes
2146
2147 The built-in font and size functions are not always intuitive, so all
2148 macro packages provide macros to make these operations simpler.
2149
2150 @c ---------------------------------------------------------------------
2151
2152 @node Predefined Strings, Preprocessor Support, Font and Size Changes, Common Features
2153 @subsection Predefined Strings
2154
2155 Most macro packages provide various predefined strings for a variety of
2156 uses; examples are sub- and superscripts, printable dates, quotes and
2157 various special characters.
2158
2159 @c ---------------------------------------------------------------------
2160
2161 @node Preprocessor Support, Configuration and Customization, Predefined Strings, Common Features
2162 @subsection Preprocessor Support
2163
2164 All macro packages provide support for various preprocessors and may
2165 extend their functionality.
2166
2167 For example, all macro packages mark tables (which are processed with
2168 @code{gtbl}) by placing them between @code{TS} and @code{TE} macros.
2169 The @file{ms} macro package has an option, @samp{.TS@tie{}H}, that
2170 prints a caption at the top of a new page (when the table is too long to
2171 fit on a single page).
2172
2173 @c ---------------------------------------------------------------------
2174
2175 @node Configuration and Customization,  , Preprocessor Support, Common Features
2176 @subsection Configuration and Customization
2177
2178 Some macro packages provide means of customizing many of the details of
2179 how the package behaves.  This ranges from setting the default type size
2180 to changing the appearance of section headers.
2181
2182
2183
2184 @c =====================================================================
2185 @c =====================================================================
2186
2187 @node Macro Packages, gtroff Reference, Tutorial for Macro Users, Top
2188 @chapter Macro Packages
2189 @cindex macro packages
2190 @cindex packages, macros
2191
2192 This chapter documents the main macro packages that come with
2193 @code{groff}.
2194
2195 Different main macro packages can't be used at the same time; for
2196 example
2197
2198 @Example
2199 groff -m man foo.man -m ms bar.doc
2200 @endExample
2201
2202 @noindent
2203 doesn't work.  Note that option arguments are processed before
2204 non-option arguments; the above (failing) sample is thus reordered to
2205
2206 @Example
2207 groff -m man -m ms foo.man bar.doc
2208 @endExample
2209
2210 @menu
2211 * man::
2212 * mdoc::
2213 * ms::
2214 * me::
2215 * mm::
2216 * mom::
2217 @end menu
2218
2219
2220 @c =====================================================================
2221
2222 @node man, mdoc, Macro Packages, Macro Packages
2223 @section @file{man}
2224 @cindex manual pages
2225 @cindex man pages
2226 @pindex an.tmac
2227 @pindex man.tmac
2228 @pindex man-old.tmac
2229
2230 This is the most popular and probably the most important macro package
2231 of @code{groff}.  It is easy to use, and a vast majority of manual pages
2232 are based on it.
2233
2234 @menu
2235 * Man options::
2236 * Man usage::
2237 * Man font macros::
2238 * Miscellaneous man macros::
2239 * Predefined man strings::
2240 * Preprocessors in man pages::
2241 * Optional man extensions::
2242 @end menu
2243
2244 @c ---------------------------------------------------------------------
2245
2246 @node Man options, Man usage, man, man
2247 @subsection Options
2248
2249 The command-line format for using the @file{man} macros with
2250 @code{groff} is:
2251
2252 @Example
2253 groff -m man [ -rLL=@var{length} ] [ -rLT=@var{length} ] [ -rFT=@var{dist} ]
2254       [ -rcR=1 ] [ -rC1 ] [ -rD1 ] [-rHY=@var{flags} ]
2255       [ -rP@var{nnn} ] [ -rS@var{xx} ] [ -rX@var{nnn} ]
2256       [ -rIN=@var{length} ] [ -rSN=@var{length} ] [ @var{files}@dots{} ]
2257 @endExample
2258
2259 @noindent
2260 It is possible to use @samp{-man} instead of @w{@samp{-m man}}.
2261
2262 @table @code
2263 @item -rcR=1
2264 This option (the default if a TTY output device is used) creates a
2265 single, very long page instead of multiple pages.  Use @code{-rcR=0} to
2266 disable it.
2267
2268 @item -rC1
2269 If more than one manual page is given on the command line, number the
2270 pages continuously, rather than starting each at@tie{}1.
2271
2272 @item -rD1
2273 Double-sided printing.  Footers for even and odd pages are formatted
2274 differently.
2275
2276 @item -rFT=@var{dist}
2277 Set the position of the footer text to @var{dist}.  If positive, the
2278 distance is measured relative to the top of the page, otherwise it is
2279 relative to the bottom.  The default is @minus{}0.5@dmn{i}.
2280
2281 @item -rHY=@var{flags}
2282 Set hyphenation flags.  Possible values are 1@tie{}to hyphenate without
2283 restrictions, 2@tie{}to not hyphenate the last word on a page, 4@tie{}to
2284 not hyphenate the last two characters of a word, and 8@tie{}to not
2285 hyphenate the first two characters of a word.  These values are
2286 additive; the default is@tie{}8.
2287
2288 @item -rIN=@var{length}
2289 Set the body text indentation to @var{length}.  If not specified, the
2290 indentation defaults to 7@dmn{n} (7@tie{}characters) in nroff mode and
2291 7.2@dmn{n} otherwise.  For nroff, this value should always be an integer
2292 multiple of unit @samp{n} to get consistent indentation.
2293
2294 @item -rLL=@var{length}
2295 Set line length to @var{length}.  If not specified, the line length is
2296 set to respect any value set by a prior @samp{ll} request (which
2297 @emph{must} be in effect when the @samp{TH} macro is invoked), if this
2298 differs from the built-in default for the formatter; otherwise it
2299 defaults to 78@dmn{n} in nroff mode (this is 78 characters per line) and
2300 6.5@dmn{i} in troff mode.@footnote{Note that the use of a @samp{.ll
2301 @var{length}} request to initialize the line length, prior to use of the
2302 @samp{TH} macro, is supported for backward compatibility with some
2303 versions of the @code{man} program.  @emph{Always} use the
2304 @option{-rLL=@var{length}} option, or an equivalent @samp{.nr LL
2305 @var{length}} request, in preference to such a @samp{.ll @var{length}}
2306 request.  In particular, note that in nroff mode, the request @samp{.ll
2307 65n}, (with any @var{length} expression that evaluates equal to
2308 65@dmn{n}, i.e., the formatter's default line length in nroff mode),
2309 does @emph{not} set the line length to 65@dmn{n} (it is adjusted to the
2310 @code{man} macro package's default setting of 78@dmn{n}), whereas the
2311 use of the @option{-rLL=65n} option, or the @samp{.nr LL 65n} request
2312 @emph{does} establish a line length of 65@dmn{n}.}
2313
2314 @item -rLT=@var{length}
2315 Set title length to @var{length}.  If not specified, the title length
2316 defaults to the line length.
2317
2318 @item -rP@var{nnn}
2319 Page numbering starts with @var{nnn} rather than with@tie{}1.
2320
2321 @item -rS@var{xx}
2322 Use @var{xx} (which can be 10, 11, or@tie{}12@dmn{pt}) as the base
2323 document font size instead of the default value of@tie{}10@dmn{pt}.
2324
2325 @item -rSN=@var{length}
2326 Set the indentation for sub-subheadings to @var{length}.  If not
2327 specified, the indentation defaults to 3@dmn{n}.
2328
2329 @item -rX@var{nnn}
2330 After page @var{nnn}, number pages as @var{nnn}a, @var{nnn}b,
2331 @var{nnn}c, etc.  For example, the option @option{-rX2} produces the
2332 following page numbers: 1, 2, 2a, 2b, 2c, etc.
2333 @end table
2334
2335 @c ---------------------------------------------------------------------
2336
2337 @node Man usage, Man font macros, Man options, man
2338 @subsection Usage
2339 @cindex @code{man} macros
2340 @cindex macros for manual pages [@code{man}]
2341
2342 @pindex man.local
2343 This section describes the available macros for manual pages.  For
2344 further customization, put additional macros and requests into the file
2345 @file{man.local}, which is loaded immediately after the @file{man}
2346 package.
2347
2348 @Defmac {TH, title section [@Var{extra1} [@Var{extra2} [@Var{extra3}]]], man}
2349 Set the title of the man page to @var{title} and the section to
2350 @var{section}, which must have a value between 1 and@tie{}8.  The value
2351 of @var{section} may also have a string appended, e.g.@: @samp{.pm}, to
2352 indicate a specific subsection of the man pages.
2353
2354 Both @var{title} and @var{section} are positioned at the left and right
2355 in the header line (with @var{section} in parentheses immediately
2356 appended to @var{title}.  @var{extra1} is positioned in the middle of
2357 the footer line.  @var{extra2} is positioned at the left in the footer
2358 line (or at the left on even pages and at the right on odd pages if
2359 double-sided printing is active).  @var{extra3} is centered in the
2360 header line.
2361
2362 For @acronym{HTML} and @acronym{XHTML} output, headers and footers are
2363 completely suppressed.
2364
2365 Additionally, this macro starts a new page; the new line number
2366 is@tie{}1 again (except if the @option{-rC1} option is given on the
2367 command line) -- this feature is intended only for formatting multiple
2368 man pages; a single man page should contain exactly one @code{TH} macro
2369 at the beginning of the file.
2370 @endDefmac
2371
2372 @Defmac {SH, [@Var{heading}], man}
2373 Set up an unnumbered section heading sticking out to the left.  Prints
2374 out all the text following @code{SH} up to the end of the line (or the
2375 text in the next line if there is no argument to @code{SH}) in bold face
2376 (or the font specified by the string @code{HF}), one size larger than
2377 the base document size.  Additionally, the left margin and the
2378 indentation for the following text is reset to its default value.
2379 @endDefmac
2380
2381 @Defmac {SS, [@Var{heading}], man}
2382 Set up an unnumbered (sub)section heading.  Prints out all the text
2383 following @code{SS} up to the end of the line (or the text in the next
2384 line if there is no argument to @code{SS}) in bold face (or the font
2385 specified by the string @code{HF}), at the same size as the base
2386 document size.  Additionally, the left margin and the indentation for
2387 the following text is reset to its default value.
2388 @endDefmac
2389
2390 @Defmac {TP, [@Var{nnn}], man}
2391 Set up an indented paragraph with label.  The indentation is set to
2392 @var{nnn} if that argument is supplied (the default unit is @samp{n} if
2393 omitted), otherwise it is set to the previous indentation value
2394 specified with @code{TP}, @code{IP}, or @code{HP} (or to the default
2395 value if none of them have been used yet).
2396
2397 The first line of text following this macro is interpreted as a string
2398 to be printed flush-left, as it is appropriate for a label.  It is not
2399 interpreted as part of a paragraph, so there is no attempt to fill the
2400 first line with text from the following input lines.  Nevertheless, if
2401 the label is not as wide as the indentation the paragraph starts at the
2402 same line (but indented), continuing on the following lines.  If the
2403 label is wider than the indentation the descriptive part of the
2404 paragraph begins on the line following the label, entirely indented.
2405 Note that neither font shape nor font size of the label is set to a
2406 default value; on the other hand, the rest of the text has default font
2407 settings.
2408 @endDefmac
2409
2410 @DefmacList {LP, , man}
2411 @DefmacItemx {PP, , man}
2412 @DefmacListEndx {P, , man}
2413 These macros are mutual aliases.  Any of them causes a line break at the
2414 current position, followed by a vertical space downwards by the amount
2415 specified by the @code{PD} macro.  The font size and shape are reset to
2416 the default value (10@dmn{pt} roman if no @option{-rS} option is given
2417 on the command line).  Finally, the current left margin and the
2418 indentation is restored.
2419 @endDefmac
2420
2421 @Defmac {IP, [@Var{designator} [@Var{nnn}]], man}
2422 Set up an indented paragraph, using @var{designator} as a tag to mark
2423 its beginning.  The indentation is set to @var{nnn} if that argument is
2424 supplied (default unit is @samp{n}), otherwise it is set to the previous
2425 indentation value specified with @code{TP}, @code{IP}, or @code{HP} (or
2426 the default value if none of them have been used yet).  Font size and
2427 face of the paragraph (but not the designator) are reset to their
2428 default values.
2429
2430 To start an indented paragraph with a particular indentation but without
2431 a designator, use @samp{""} (two double quotes) as the first argument of
2432 @code{IP}.
2433
2434 For example, to start a paragraph with bullets as the designator and
2435 4@tie{}en indentation, write
2436
2437 @Example
2438 .IP \(bu 4
2439 @endExample
2440 @endDefmac
2441
2442 @Defmac {HP, [@Var{nnn}], man}
2443 @cindex hanging indentation [@code{man}]
2444 @cindex @code{man} macros, hanging indentation
2445 Set up a paragraph with hanging left indentation.  The indentation is
2446 set to @var{nnn} if that argument is supplied (default unit is
2447 @samp{n}), otherwise it is set to the previous indentation value
2448 specified with @code{TP}, @code{IP}, or @code{HP} (or the default value
2449 if non of them have been used yet).  Font size and face are reset to
2450 their default values.
2451 @endDefmac
2452
2453 @Defmac {RS, [@Var{nnn}], man}
2454 @cindex left margin, how to move [@code{man}]
2455 @cindex @code{man} macros, moving left margin
2456 Move the left margin to the right by the value @var{nnn} if specified
2457 (default unit is @samp{n}); otherwise it is set to the previous
2458 indentation value specified with @code{TP}, @code{IP}, or @code{HP} (or
2459 to the default value if none of them have been used yet).  The
2460 indentation value is then set to the default.
2461
2462 Calls to the @code{RS} macro can be nested.
2463 @endDefmac
2464
2465 @Defmac {RE, [@Var{nnn}], man}
2466 Move the left margin back to level @var{nnn}, restoring the previous
2467 left margin.  If no argument is given, it moves one level back.  The
2468 first level (i.e., no call to @code{RS} yet) has number@tie{}1, and each
2469 call to @code{RS} increases the level by@tie{}1.
2470 @endDefmac
2471
2472 @cindex line breaks, with vertical space [@code{man}]
2473 @cindex @code{man} macros, line breaks with vertical space
2474 To summarize, the following macros cause a line break with the insertion
2475 of vertical space (which amount can be changed with the @code{PD}
2476 macro): @code{SH}, @code{SS}, @code{TP}, @code{LP} (@code{PP},
2477 @code{P}), @code{IP}, and @code{HP}.
2478
2479 @cindex line breaks, without vertical space [@code{man}]
2480 @cindex @code{man} macros, line breaks without vertical space
2481 The macros @code{RS} and @code{RE} also cause a break but do not insert
2482 vertical space.
2483
2484 @cindex default indentation, resetting [@code{man}]
2485 @cindex indentation, resetting to default [@code{man}]
2486 @cindex @code{man} macros, resetting default indentation
2487 Finally, the macros @code{SH}, @code{SS}, @code{LP} (@code{PP},
2488 @code{P}), and @code{RS} reset the indentation to its default value.
2489
2490 @c ---------------------------------------------------------------------
2491
2492 @node Man font macros, Miscellaneous man macros, Man usage, man
2493 @subsection Macros to set fonts
2494 @cindex font selection [@code{man}]
2495 @cindex @code{man} macros, how to set fonts
2496
2497 The standard font is roman; the default text size is 10@tie{}points.  If
2498 command-line option @option{-rS=@var{n}} is given, use
2499 @var{n}@tie{}points as the default text size.
2500
2501 @Defmac {SM, [@Var{text}], man}
2502 Set the text on the same line or the text on the next line in a font
2503 that is one point size smaller than the default font.
2504 @endDefmac
2505
2506 @Defmac {SB, [@Var{text}], man}
2507 @cindex bold face [@code{man}]
2508 @cindex @code{man} macros, bold face
2509 Set the text on the same line or the text on the next line in bold face
2510 font, one point size smaller than the default font.
2511 @endDefmac
2512
2513 @Defmac {BI, text, man}
2514 Set its arguments alternately in bold face and italic, without a space
2515 between the arguments.  Thus,
2516
2517 @Example
2518 .BI this "word and" that
2519 @endExample
2520
2521 @noindent
2522 produces ``thisword andthat'' with ``this'' and ``that'' in bold face,
2523 and ``word and'' in italics.
2524 @endDefmac
2525
2526 @Defmac {IB, text, man}
2527 Set its arguments alternately in italic and bold face, without a space
2528 between the arguments.
2529 @endDefmac
2530
2531 @Defmac {RI, text, man}
2532 Set its arguments alternately in roman and italic, without a space
2533 between the arguments.
2534 @endDefmac
2535
2536 @Defmac {IR, text, man}
2537 Set its arguments alternately in italic and roman, without a space
2538 between the arguments.
2539 @endDefmac
2540
2541 @Defmac {BR, text, man}
2542 Set its arguments alternately in bold face and roman, without a space
2543 between the arguments.
2544 @endDefmac
2545
2546 @Defmac {RB, text, man}
2547 Set its arguments alternately in roman and bold face, without a space
2548 between the arguments.
2549 @endDefmac
2550
2551 @Defmac {B, [@Var{text}], man}
2552 Set @var{text} in bold face.  If no text is present on the line where
2553 the macro is called, then the text of the next line appears in bold
2554 face.
2555 @endDefmac
2556
2557 @Defmac {I, [@Var{text}], man}
2558 @cindex italic fonts [@code{man}]
2559 @cindex @code{man} macros, italic fonts
2560 Set @var{text} in italic.  If no text is present on the line where the
2561 macro is called, then the text of the next line appears in italic.
2562 @endDefmac
2563
2564 @c ---------------------------------------------------------------------
2565
2566 @node Miscellaneous man macros, Predefined man strings, Man font macros, man
2567 @subsection Miscellaneous macros
2568
2569 @pindex grohtml
2570 @cindex @code{man} macros, default indentation
2571 @cindex default indentation [@code{man}]
2572 The default indentation is 7.2@dmn{n} in troff mode and 7@dmn{n} in
2573 nroff mode except for @code{grohtml}, which ignores indentation.
2574
2575 @Defmac {DT, , man}
2576 @cindex tab stops [@code{man}]
2577 @cindex @code{man} macros, tab stops
2578 Set tabs every 0.5@tie{}inches.  Since this macro is always executed
2579 during a call to the @code{TH} macro, it makes sense to call it only if
2580 the tab positions have been changed.
2581 @endDefmac
2582
2583 @Defmac {PD, [@Var{nnn}], man}
2584 @cindex empty space before a paragraph [@code{man}]
2585 @cindex @code{man} macros, empty space before a paragraph
2586 Adjust the empty space before a new paragraph (or section).  The
2587 optional argument gives the amount of space (default unit is @samp{v});
2588 without parameter, the value is reset to its default value (1@tie{}line
2589 in nroff mode, 0.4@dmn{v}@tie{}otherwise).
2590
2591 This affects the macros @code{SH}, @code{SS}, @code{TP}, @code{LP} (as
2592 well as @code{PP} and @code{P}), @code{IP}, and @code{HP}.
2593 @endDefmac
2594
2595 The following two macros are included for BSD compatibility.
2596
2597 @Defmac {AT, [@Var{system} [@Var{release}]], man}
2598 @cindex @code{man}macros, BSD compatibility
2599 Alter the footer for use with @acronym{AT&T} manpages.  This command
2600 exists only for compatibility; don't use it.  The first argument
2601 @var{system} can be:
2602
2603 @table @code
2604 @item 3
2605 7th Edition (the default)
2606
2607 @item 4
2608 System III
2609
2610 @item 5
2611 System V
2612 @end table
2613
2614 An optional second argument @var{release} to @code{AT} specifies the
2615 release number (such as ``System V Release 3'').
2616 @endDefmac
2617
2618 @Defmac {UC, [@Var{version}], man}
2619 @cindex @code{man}macros, BSD compatibility
2620 Alters the footer for use with BSD manpages.  This command exists only
2621 for compatibility; don't use it.  The argument can be:
2622
2623 @table @code
2624 @item 3
2625 3rd Berkeley Distribution (the default)
2626
2627 @item 4
2628 4th Berkeley Distribution
2629
2630 @item 5
2631 4.2 Berkeley Distribution
2632
2633 @item 6
2634 4.3 Berkeley Distribution
2635
2636 @item 7
2637 4.4 Berkeley Distribution
2638 @end table
2639 @endDefmac
2640
2641 @c ---------------------------------------------------------------------
2642
2643 @node Predefined man strings, Preprocessors in man pages, Miscellaneous man macros, man
2644 @subsection Predefined strings
2645
2646 The following strings are defined:
2647
2648 @Defstr {S, man}
2649 Switch back to the default font size.
2650 @endDefstr
2651
2652 @Defstr {HF, man}
2653 The typeface used for headings.
2654 The default is @samp{B}.
2655 @endDefstr
2656
2657 @Defstr {R, man}
2658 The `registered' sign.
2659 @endDefstr
2660
2661 @Defstr {Tm, man}
2662 The `trademark' sign.
2663 @endDefstr
2664
2665 @DefstrList {lq, man}
2666 @DefstrListEndx {rq, man}
2667 @cindex @code{lq} glyph, and @code{lq} string [@code{man}]
2668 @cindex @code{rq} glyph, and @code{rq} string [@code{man}]
2669 Left and right quote.  This is equal to @code{\(lq} and @code{\(rq},
2670 respectively.
2671 @endDefstr
2672
2673 @c ---------------------------------------------------------------------
2674
2675 @node Preprocessors in man pages, Optional man extensions, Predefined man strings, man
2676 @subsection Preprocessors in @file{man} pages
2677
2678 @cindex preprocessor, calling convention
2679 @cindex calling convention of preprocessors
2680 If a preprocessor like @code{gtbl} or @code{geqn} is needed, it has
2681 become common usage to make the first line of the man page look like
2682 this:
2683
2684 @Example
2685 '\" @var{word}
2686 @endExample
2687
2688 @pindex geqn@r{, invocation in manual pages}
2689 @pindex grefer@r{, invocation in manual pages}
2690 @pindex gtbl@r{, invocation in manual pages}
2691 @pindex man@r{, invocation of preprocessors}
2692 @noindent
2693 Note the single space character after the double quote.  @var{word}
2694 consists of letters for the needed preprocessors: @samp{e} for
2695 @code{geqn}, @samp{r} for @code{grefer}, @samp{t} for @code{gtbl}.
2696 Modern implementations of the @code{man} program read this first line
2697 and automatically call the right preprocessor(s).
2698
2699 @c ---------------------------------------------------------------------
2700
2701 @node Optional man extensions,  , Preprocessors in man pages, man
2702 @subsection Optional @file{man} extensions
2703
2704 @pindex man.local
2705 Use the file @file{man.local} for local extensions to the @code{man}
2706 macros or for style changes.
2707
2708 @unnumberedsubsubsec Custom headers and footers
2709 @cindex @code{man} macros, custom headers and footers
2710
2711 In groff versions 1.18.2 and later, you can specify custom headers and
2712 footers by redefining the following macros in @file{man.local}.
2713
2714 @Defmac {PT, , man}
2715 Control the content of the headers.  Normally, the header prints the
2716 command name and section number on either side, and the optional fifth
2717 argument to @code{TH} in the center.
2718 @endDefmac
2719
2720 @Defmac {BT, , man}
2721 Control the content of the footers.  Normally, the footer prints the
2722 page number and the third and fourth arguments to @code{TH}.
2723
2724 Use the @code{FT} number register to specify the footer position.  The
2725 default is @minus{}0.5@dmn{i}.
2726 @endDefmac
2727
2728 @unnumberedsubsubsec Ultrix-specific man macros
2729 @cindex Ultrix-specific @code{man} macros
2730 @cindex @code{man} macros, Ultrix-specific
2731
2732 @pindex man.ultrix
2733 The @code{groff} source distribution includes a file named
2734 @file{man.ultrix}, containing macros compatible with the Ultrix variant
2735 of @code{man}.  Copy this file into @file{man.local} (or use the
2736 @code{mso} request to load it) to enable the following macros.
2737
2738 @Defmac {CT, @Var{key}, man}
2739 Print @samp{<CTRL/@var{key}>}.
2740 @endDefmac
2741
2742 @Defmac {CW, , man}
2743 Print subsequent text using the constant width (Courier) typeface.
2744 @endDefmac
2745
2746 @Defmac {Ds, , man}
2747 Begin a non-filled display.
2748 @endDefmac
2749
2750 @Defmac {De, , man}
2751 End a non-filled display started with @code{Ds}.
2752 @endDefmac
2753
2754 @Defmac {EX, [@Var{indent}], man}
2755 Begin a non-filled display using the constant width (Courier) typeface.
2756 Use the optional @var{indent} argument to indent the display.
2757 @endDefmac
2758
2759 @Defmac {EE, , man}
2760 End a non-filled display started with @code{EX}.
2761 @endDefmac
2762
2763 @Defmac {G, [@Var{text}], man}
2764 Set @var{text} in Helvetica.  If no text is present on the line where
2765 the macro is called, then the text of the next line appears in
2766 Helvetica.
2767 @endDefmac
2768
2769 @Defmac {GL, [@Var{text}], man}
2770 Set @var{text} in Helvetica Oblique.  If no text is present on the line
2771 where the macro is called, then the text of the next line appears in
2772 Helvetica Oblique.
2773 @endDefmac
2774
2775 @Defmac {HB, [@Var{text}], man}
2776 Set @var{text} in Helvetica Bold.  If no text is present on the line
2777 where the macro is called, then all text up to the next @code{HB}
2778 appears in Helvetica Bold.
2779 @endDefmac
2780
2781 @Defmac {TB, [@Var{text}], man}
2782 Identical to @code{HB}.
2783 @endDefmac
2784
2785 @Defmac {MS, @Var{title} @Var{sect} [@Var{punct}], man}
2786 Set a manpage reference in Ultrix format.  The @var{title} is in Courier
2787 instead of italic.  Optional punctuation follows the section number
2788 without an intervening space.
2789 @endDefmac
2790
2791 @Defmac {NT, [@code{C}] [@Var{title}], man}
2792 Begin a note.  Print the optional @Var{title}, or the word ``Note'',
2793 centered on the page.  Text following the macro makes up the body of the
2794 note, and is indented on both sides.  If the first argument is @code{C},
2795 the body of the note is printed centered (the second argument replaces
2796 the word ``Note'' if specified).
2797 @endDefmac
2798
2799 @Defmac {NE, , man}
2800 End a note begun with @code{NT}.
2801 @endDefmac
2802
2803 @Defmac {PN, @Var{path} [@Var{punct}], man}
2804 Set the path name in constant width (Courier), followed by optional
2805 punctuation.
2806 @endDefmac
2807
2808 @Defmac {Pn, [@Var{punct}] @Var{path} [@Var{punct}], man}
2809 If called with two arguments, identical to @code{PN}.  If called with
2810 three arguments, set the second argument in constant width (Courier),
2811 bracketed by the first and third arguments in the current font.
2812 @endDefmac
2813
2814 @Defmac {R, , man}
2815 Switch to roman font and turn off any underlining in effect.
2816 @endDefmac
2817
2818 @Defmac {RN, , man}
2819 Print the string @samp{<RETURN>}.
2820 @endDefmac
2821
2822 @Defmac {VS, [@code{4}], man}
2823 Start printing a change bar in the margin if the number@tie{}@code{4} is
2824 specified.  Otherwise, this macro does nothing.
2825 @endDefmac
2826
2827 @Defmac {VE, , man}
2828 End printing the change bar begun by @code{VS}.
2829 @endDefmac
2830
2831 @unnumberedsubsubsec Simple example
2832
2833 The following example @file{man.local} file alters the @code{SH} macro
2834 to add some extra vertical space before printing the heading.  Headings
2835 are printed in Helvetica Bold.
2836
2837 @Example
2838 .\" Make the heading fonts Helvetica
2839 .ds HF HB
2840 .
2841 .\" Put more whitespace in front of headings.
2842 .rn SH SH-orig
2843 .de SH
2844 .  if t .sp (u;\\n[PD]*2)
2845 .  SH-orig \\$*
2846 ..
2847 @endExample
2848
2849
2850 @c =====================================================================
2851
2852 @node mdoc, ms, man, Macro Packages
2853 @section @file{mdoc}
2854 @cindex @code{mdoc} macros
2855
2856 @c XXX documentation
2857 @c XXX this is a placeholder until we get stuff knocked into shape
2858 See the @cite{groff_mdoc(7)} man page (type @command{man groff_mdoc}
2859 at the command line).
2860
2861
2862 @c =====================================================================
2863
2864 @node ms, me, mdoc, Macro Packages
2865 @section @file{ms}
2866 @cindex @code{ms} macros
2867
2868 The @file{-ms} macros are suitable for reports, letters, books, user
2869 manuals, and so forth.  The package provides macros for cover pages,
2870 section headings, paragraphs, lists, footnotes, pagination, and a table
2871 of contents.
2872
2873 @menu
2874 * ms Intro::
2875 * General ms Structure::
2876 * ms Document Control Registers::
2877 * ms Cover Page Macros::
2878 * ms Body Text::
2879 * ms Page Layout::
2880 * Differences from AT&T ms::
2881 * Naming Conventions::
2882 @end menu
2883
2884 @c ---------------------------------------------------------------------
2885
2886 @node ms Intro, General ms Structure, ms, ms
2887 @subsection Introduction to @file{ms}
2888
2889 The original @file{-ms} macros were included with @acronym{AT&T}
2890 @code{troff} as well as the @file{man} macros.  While the @file{man}
2891 package is intended for brief documents that can be read on-line as well
2892 as printed, the @file{ms} macros are suitable for longer documents that
2893 are meant to be printed rather than read on-line.
2894
2895 The @file{ms} macro package included with @code{groff} is a complete,
2896 bottom-up re-implementation.  Several macros (specific to @acronym{AT&T}
2897 or Berkeley) are not included, while several new commands are.
2898 @xref{Differences from AT&T ms}, for more information.
2899
2900 @c ---------------------------------------------------------------------
2901
2902 @node General ms Structure, ms Document Control Registers, ms Intro, ms
2903 @subsection General structure of an @file{ms} document
2904 @cindex @code{ms} macros, general structure
2905
2906 The @file{ms} macro package expects a certain amount of structure, but
2907 not as much as packages such as @file{man} or @file{mdoc}.
2908
2909 The simplest documents can begin with a paragraph macro (such as
2910 @code{LP} or @code{PP}), and consist of text separated by paragraph
2911 macros or even blank lines.  Longer documents have a structure as
2912 follows:
2913
2914 @table @strong
2915 @item Document type
2916 If you invoke the @code{RP} (report) macro on the first line of the
2917 document, @code{groff} prints the cover page information on its own
2918 page; otherwise it prints the information on the first page with your
2919 document text immediately following.  Other document formats found in
2920 @acronym{AT&T} @code{troff} are specific to @acronym{AT&T} or Berkeley,
2921 and are not supported in @code{groff}.
2922
2923 @item Format and layout
2924 By setting number registers, you can change your document's type (font
2925 and size), margins, spacing, headers and footers, and footnotes.
2926 @xref{ms Document Control Registers}, for more details.
2927
2928 @item Cover page
2929 A cover page consists of a title, the author's name and institution, an
2930 abstract, and the date.@footnote{Actually, only the title is required.}
2931 @xref{ms Cover Page Macros}, for more details.
2932
2933 @item Body
2934 Following the cover page is your document.  You can use the @file{ms}
2935 macros to write reports, letters, books, and so forth.  The package is
2936 designed for structured documents, consisting of paragraphs interspersed
2937 with headings and augmented by lists, footnotes, tables, and other
2938 common constructs.  @xref{ms Body Text}, for more details.
2939
2940 @item Table of contents
2941 Longer documents usually include a table of contents, which you can
2942 invoke by placing the @code{TC} macro at the end of your document.  The
2943 @file{ms} macros have minimal indexing facilities, consisting of the
2944 @code{IX} macro, which prints an entry on standard error.  Printing the
2945 table of contents at the end is necessary since @code{groff} is a
2946 single-pass text formatter, thus it cannot determine the page number of
2947 each section until that section has actually been set and printed.
2948 Since @file{ms} output is intended for hardcopy, you can manually
2949 relocate the pages containing the table of contents between the cover
2950 page and the body text after printing.
2951 @end table
2952
2953 @c ---------------------------------------------------------------------
2954
2955 @node ms Document Control Registers, ms Cover Page Macros, General ms Structure, ms
2956 @subsection Document control registers
2957 @cindex @code{ms} macros, document control registers
2958
2959 The following is a list of document control number registers.  For the
2960 sake of consistency, set registers related to margins at the beginning
2961 of your document, or just after the @code{RP} macro.  You can set other
2962 registers later in your document, but you should keep them together at
2963 the beginning to make them easy to find and edit as necessary.
2964
2965 @unnumberedsubsubsec Margin Settings
2966
2967 @Defmpreg {PO, ms}
2968 Defines the page offset (i.e., the left margin).  There is no explicit
2969 right margin setting; the combination of the @code{PO} and @code{LL}
2970 registers implicitly define the right margin width.
2971
2972 Effective: next page.
2973
2974 Default value: 1@dmn{i}.
2975 @endDefmpreg
2976
2977 @Defmpreg {LL, ms}
2978 Defines the line length (i.e., the width of the body text).
2979
2980 Effective: next paragraph.
2981
2982 Default: 6@dmn{i}.
2983 @endDefmpreg
2984
2985 @Defmpreg {LT, ms}
2986 Defines the title length (i.e., the header and footer width).  This
2987 is usually the same as @code{LL}, but not necessarily.
2988
2989 Effective: next paragraph.
2990
2991 Default: 6@dmn{i}.
2992 @endDefmpreg
2993
2994 @Defmpreg {HM, ms}
2995 Defines the header margin height at the top of the page.
2996
2997 Effective: next page.
2998
2999 Default: 1@dmn{i}.
3000 @endDefmpreg
3001
3002 @Defmpreg {FM, ms}
3003 Defines the footer margin height at the bottom of the page.
3004
3005 Effective: next page.
3006
3007 Default: 1@dmn{i}.
3008 @endDefmpreg
3009
3010 @unnumberedsubsubsec Text Settings
3011
3012 @Defmpreg {PS, ms}
3013 Defines the point size of the body text.  If the value is larger than or
3014 equal to 1000, divide it by 1000 to get a fractional point size.  For
3015 example, @samp{.nr PS 10250} sets the document's point size to
3016 10.25@dmn{p}.
3017
3018 Effective: next paragraph.
3019
3020 Default: 10@dmn{p}.
3021 @endDefmpreg
3022
3023 @Defmpreg {VS, ms}
3024 Defines the space between lines (line height plus leading).  If the
3025 value is larger than or equal to 1000, divide it by 1000 to get a
3026 fractional point size.  Due to backwards compatibility, @code{VS} must
3027 be smaller than 40000 (this is 40.0@dmn{p}).
3028
3029 Effective: next paragraph.
3030
3031 Default: 12@dmn{p}.
3032 @endDefmpreg
3033
3034 @Defmpreg {PSINCR, ms}
3035 Defines an increment in point size, which is applied to section headings
3036 at nesting levels below the value specified in @code{GROWPS}.  The value
3037 of @code{PSINCR} should be specified in points, with the @dmn{p} scaling
3038 factor, and may include a fractional component; for example,
3039 @w{@samp{.nr PSINCR 1.5p}} sets a point size increment of 1.5@dmn{p}.
3040
3041 Effective: next section heading.
3042
3043 Default: 1@dmn{p}.
3044 @endDefmpreg
3045
3046 @Defmpreg {GROWPS, ms}
3047 Defines the heading level below which the point size increment set by
3048 @code{PSINCR} becomes effective.  Section headings at and above the
3049 level specified by @code{GROWPS} are printed at the point size set by
3050 @code{PS}; for each level below the value of @code{GROWPS}, the point
3051 size is increased in steps equal to the value of @code{PSINCR}.  Setting
3052 @code{GROWPS} to any value less than@tie{}2 disables the incremental
3053 heading size feature.
3054
3055 Effective: next section heading.
3056
3057 Default: 0.
3058 @endDefmpreg
3059
3060 @Defmpreg {HY, ms}
3061 Defines the hyphenation level.  @code{HY} sets safely the value of the
3062 low-level @code{hy} register.  Setting the value of @code{HY} to@tie{}0
3063 is equivalent to using the @code{nh} request.
3064
3065 Effective: next paragraph.
3066
3067 Default: 6.
3068 @endDefmpreg
3069
3070 @Defmpreg {FAM, ms}
3071 Defines the font family used to typeset the document.
3072
3073 Effective: next paragraph.
3074
3075 Default: as defined in the output device.
3076 @endDefmpreg
3077
3078 @unnumberedsubsubsec Paragraph Settings
3079
3080 @Defmpreg {PI, ms}
3081 Defines the initial indentation of a (@code{PP} macro) paragraph.
3082
3083 Effective: next paragraph.
3084
3085 Default: 5@dmn{n}.
3086 @endDefmpreg
3087
3088 @Defmpreg {PD, ms}
3089 Defines the space between paragraphs.
3090
3091 Effective: next paragraph.
3092
3093 Default: 0.3@dmn{v}.
3094 @endDefmpreg
3095
3096 @Defmpreg {QI, ms}
3097 Defines the indentation on both sides of a quoted (@code{QP},
3098 @code{QS}, and @code{QE} macros)
3099 paragraph.
3100
3101 Effective: next paragraph.
3102
3103 Default: 5@dmn{n}.
3104 @endDefmpreg
3105
3106 @Defmpreg {PORPHANS, ms}
3107 Defines the minimum number of initial lines of any paragraph that
3108 should be kept together, to avoid orphan lines at the bottom of a page.
3109 If a new paragraph is started close to the bottom of a page, and there
3110 is insufficient space to accommodate @code{PORPHANS} lines before an
3111 automatic page break, then the page break is forced, before the start of
3112 the paragraph.
3113
3114 Effective: next paragraph.
3115
3116 Default: 1.
3117 @endDefmpreg
3118
3119 @Defmpreg {HORPHANS, ms}
3120 Defines the minimum number of lines of the following paragraph that
3121 should be kept together with any section heading introduced by the
3122 @code{NH} or @code{SH} macros.  If a section heading is placed close to
3123 the bottom of a page, and there is insufficient space to accommodate
3124 both the heading and at least @code{HORPHANS} lines of the following
3125 paragraph, before an automatic page break, then the page break is forced
3126 before the heading.
3127
3128 Effective: next paragraph.
3129
3130 Default: 1.
3131 @endDefmpreg
3132
3133 @unnumberedsubsubsec Footnote Settings
3134
3135 @Defmpreg {FL, ms}
3136 Defines the length of a footnote.
3137
3138 Effective: next footnote.
3139
3140 Default: @math{@code{@\n[LL]} * 5 / 6}.
3141 @endDefmpreg
3142
3143 @Defmpreg {FI, ms}
3144 Defines the footnote indentation.
3145
3146 Effective: next footnote.
3147
3148 Default: 2@dmn{n}.
3149 @endDefmpreg
3150
3151 @Defmpreg {FF, ms}
3152 The footnote format:
3153 @table @code
3154 @item 0
3155 Print the footnote number as a superscript; indent the footnote
3156 (default).
3157
3158 @item 1
3159 Print the number followed by a period (like 1.@:) and indent the
3160 footnote.
3161
3162 @item 2
3163 Like 1, without an indentation.
3164
3165 @item 3
3166 Like 1, but print the footnote number as a hanging paragraph.
3167 @end table
3168
3169 Effective: next footnote.
3170
3171 Default: 0.
3172 @endDefmpreg
3173
3174 @Defmpreg {FPS, ms}
3175 Defines the footnote point size.  If the value is larger than or equal
3176 to 1000, divide it by 1000 to get a fractional point size.
3177
3178 Effective: next footnote.
3179
3180 Default: @math{@code{@\n[PS]} - 2}.
3181 @endDefmpreg
3182
3183 @Defmpreg {FVS, ms}
3184 Defines the footnote vertical spacing.  If the value is larger than or
3185 equal to 1000, divide it by 1000 to get a fractional point size.
3186
3187 Effective: next footnote.
3188
3189 Default: @math{@code{@\n[FPS]} + 2}.
3190 @endDefmpreg
3191
3192 @Defmpreg {FPD, ms}
3193 Defines the footnote paragraph spacing.
3194
3195 Effective: next footnote.
3196
3197 Default: @math{@code{@\n[PD]} / 2}.
3198 @endDefmpreg
3199
3200 @unnumberedsubsubsec Miscellaneous Number Registers
3201
3202 @Defmpreg {MINGW, ms}
3203 Defines the minimum width between columns in a multi-column document.
3204
3205 Effective: next page.
3206
3207 Default: 2@dmn{n}.
3208 @endDefmpreg
3209
3210 @Defmpreg {DD, ms}
3211 Sets the vertical spacing before and after a display, a @code{tbl} table, an
3212 @code{eqn} equation, or a @code{pic} image.
3213
3214 Effective: next paragraph.
3215
3216 Default: 0.5@dmn{v}.
3217 @endDefmpreg
3218
3219 @c ---------------------------------------------------------------------
3220
3221 @node ms Cover Page Macros, ms Body Text, ms Document Control Registers, ms
3222 @subsection Cover page macros
3223 @cindex @code{ms} macros, cover page
3224 @cindex cover page macros, [@code{ms}]
3225
3226 Use the following macros to create a cover page for your document in the
3227 order shown.
3228
3229 @Defmac {RP, [@code{no}], ms}
3230 Specifies the report format for your document.  The report format
3231 creates a separate cover page.  The default action (no @code{RP} macro)
3232 is to print a subset of the cover page on page@tie{}1 of your document.
3233
3234 If you use the word @code{no} as an optional argument, @code{groff}
3235 prints a title page but does not repeat any of the title page
3236 information (title, author, abstract, etc.@:) on page@tie{}1 of the
3237 document.
3238 @endDefmac
3239
3240 @Defmac {P1, , ms}
3241 (P-one) Prints the header on page@tie{}1.  The default is to suppress
3242 the header.
3243 @endDefmac
3244
3245 @Defmac {DA, [@dots{}], ms}
3246 (optional) Prints the current date, or the arguments to the macro if
3247 any, on the title page (if specified) and in the footers.  This is the
3248 default for @code{nroff}.
3249 @endDefmac
3250
3251 @Defmac {ND, [@dots{}], ms}
3252 (optional) Prints the current date, or the arguments to the macro if
3253 any, on the title page (if specified) but not in the footers.  This is
3254 the default for @code{troff}.
3255 @endDefmac
3256
3257 @Defmac {TL, , ms}
3258 Specifies the document title.  @code{groff} collects text following the
3259 @code{TL} macro into the title, until reaching the author name or
3260 abstract.
3261 @endDefmac
3262
3263 @Defmac {AU, , ms}
3264 Specifies the author's name, which appears on the line (or lines)
3265 immediately following.  You can specify multiple authors as follows:
3266
3267 @Example
3268 .AU
3269 John Doe
3270 .AI
3271 University of West Bumblefuzz
3272 .AU
3273 Martha Buck
3274 .AI
3275 Monolithic Corporation
3276
3277 ...
3278 @endExample
3279 @endDefmac
3280
3281 @Defmac {AI, , ms}
3282 Specifies the author's institution.  You can specify multiple
3283 institutions in the same way that you specify multiple authors.
3284 @endDefmac
3285
3286 @Defmac {AB, [@code{no}], ms}
3287 Begins the abstract.  The default is to print the word
3288 @acronym{ABSTRACT}, centered and in italics, above the text of the
3289 abstract.  The word @code{no} as an optional argument suppresses this
3290 heading.
3291 @endDefmac
3292
3293 @Defmac {AE, , ms}
3294 Ends the abstract.
3295 @endDefmac
3296
3297 The following is example mark-up for a title page.
3298 @cindex title page, example markup
3299 @cindex example markup, title page
3300
3301 @CartoucheExample
3302 .RP
3303 .TL
3304 The Inevitability of Code Bloat
3305 in Commercial and Free Software
3306 .AU
3307 J. Random Luser
3308 .AI
3309 University of West Bumblefuzz
3310 .AB
3311 This report examines the long-term growth
3312 of the code bases in two large, popular software
3313 packages; the free Emacs and the commercial
3314 Microsoft Word.
3315 While differences appear in the type or order
3316 of features added, due to the different
3317 methodologies used, the results are the same
3318 in the end.
3319 .PP
3320 The free software approach is shown to be
3321 superior in that while free software can
3322 become as bloated as commercial offerings,
3323 free software tends to have fewer serious
3324 bugs and the added features are in line with
3325 user demand.
3326 .AE
3327
3328 ... the rest of the paper follows ...
3329 @endCartoucheExample
3330
3331 @c ---------------------------------------------------------------------
3332
3333 @node ms Body Text, ms Page Layout, ms Cover Page Macros, ms
3334 @subsection Body text
3335 @cindex @code{ms} macros, body text
3336
3337 This section describes macros used to mark up the body of your document.
3338 Examples include paragraphs, sections, and other groups.
3339
3340 @menu
3341 * Paragraphs in ms::
3342 * Headings in ms::
3343 * Highlighting in ms::
3344 * Lists in ms::
3345 * Indentation values in ms::
3346 * Tabstops in ms::
3347 * ms Displays and Keeps::
3348 * ms Insertions::
3349 * Example multi-page table::
3350 * ms Footnotes::
3351 @end menu
3352
3353 @c ---------------------------------------------------------------------
3354
3355 @node Paragraphs in ms, Headings in ms, ms Body Text, ms Body Text
3356 @subsubsection Paragraphs
3357 @cindex @code{ms} macros, paragraph handling
3358
3359 The following paragraph types are available.
3360
3361 @Defmac {PP, , ms}
3362 Sets a paragraph with an initial indentation.
3363 @endDefmac
3364
3365 @Defmac {LP, , ms}
3366 Sets a paragraph without an initial indentation.
3367 @endDefmac
3368
3369 @Defmac {QP, , ms}
3370 Sets a paragraph that is indented at both left and right margins
3371 by the amount of the register @code{QI}.
3372 The effect is identical to the @acronym{HTML} @code{<BLOCKQUOTE>} element.
3373 The next paragraph or heading returns margins to normal.
3374 @code{QP} inserts vertical space of amount set by register @code{PD}
3375 before the paragraph.
3376 @endDefmac
3377
3378 @DefmacList {QS, , ms}
3379 @DefmacListEndx {QE, , ms}
3380 These macros begin and end a quoted section.
3381 The @code{QI} register
3382 controls the amount of indentation.
3383 Both @code{QS} and @code{QE} insert inter-paragraph vertical space
3384 set by register @code{PD}.
3385 The text between @code{QS} and @code{QE} can be structured further
3386 by use of the macros @code{LP} or @code{PP}.
3387 @endDefmac
3388
3389 @Defmac {XP, , ms}
3390 Sets a paragraph whose lines are indented, except for the first line.
3391 This is a Berkeley extension.
3392 @endDefmac
3393
3394 The following markup uses all four paragraph macros.
3395
3396 @CartoucheExample
3397 .NH 2
3398 Cases used in the study
3399 .LP
3400 The following software and versions were
3401 considered for this report.
3402 .PP
3403 For commercial software, we chose
3404 .B "Microsoft Word for Windows" ,
3405 starting with version 1.0 through the
3406 current version (Word 2000).
3407 .PP
3408 For free software, we chose
3409 .B Emacs ,
3410 from its first appearance as a standalone
3411 editor through the current version (v20).
3412 See [Bloggs 2002] for details.
3413 .QP
3414 Franklin's Law applied to software:
3415 software expands to outgrow both
3416 RAM and disk space over time.
3417 .LP
3418 Bibliography:
3419 .XP
3420 Bloggs, Joseph R.,
3421 .I "Everyone's a Critic" ,
3422 Underground Press, March 2002.
3423 A definitive work that answers all questions
3424 and criticisms about the quality and usability of
3425 free software.
3426 @endCartoucheExample
3427
3428 The @code{PORPHANS} register (@pxref{ms Document Control Registers})
3429 operates in conjunction with each of these macros, to inhibit the
3430 printing of orphan lines at the bottom of any page.
3431
3432 @c ---------------------------------------------------------------------
3433
3434 @node Headings in ms, Highlighting in ms, Paragraphs in ms, ms Body Text
3435 @subsubsection Headings
3436 @cindex @code{ms} macros, headings
3437
3438 Use headings to create a hierarchical structure for your document.  The
3439 @file{ms} macros print headings in @strong{bold}, using the same font
3440 family and point size as the body text.
3441
3442 The following describes the heading macros:
3443
3444 @DefmacList {NH, @Var{curr-level}, ms}
3445 @DefmacListEnd {NH, @t{S} @Var{level0} @dots{}, ms}
3446 Numbered heading.  The argument is either a numeric argument to indicate
3447 the level of the heading, or the letter@tie{}@code{S} followed by
3448 numeric arguments to set the heading level explicitly.
3449
3450 If you specify heading levels out of sequence, such as invoking
3451 @samp{.NH 3} after @samp{.NH 1}, @code{groff} prints a warning on
3452 standard error.
3453 @endDefmac
3454
3455 @DefstrList {SN, ms}
3456 @DefstrItemx {SN-DOT, ms}
3457 @DefstrListEndx {SN-NO-DOT, ms}
3458 After invocation of @code{NH}, the assigned section number is made
3459 available in the strings @code{SN-DOT} (as it appears in a printed
3460 section heading with default formatting, followed by a terminating
3461 period), and @code{SN-NO-DOT} (with the terminating period omitted).
3462 The string @code{SN} is also defined, as an alias for @code{SN-DOT}; if
3463 preferred, you may redefine it as an alias for @code{SN-NO-DOT}, by
3464 including the initialization
3465 @Example
3466 .als SN SN-NO-DOT
3467 @endExample
3468
3469 @noindent
3470 at any time @strong{before} you would like the change to take effect.
3471 @endDefstr
3472
3473 @Defstr {SN-STYLE, ms}
3474 You may control the style used to print section numbers, within numbered
3475 section headings, by defining an appropriate alias for the string
3476 @code{SN-STYLE}.  The default style, in which the printed section number
3477 is followed by a terminating period, is obtained by defining the alias
3478
3479 @Example
3480 .als SN-STYLE SN-DOT
3481 @endExample
3482
3483 @noindent
3484 If you prefer to omit the terminating period, from section numbers
3485 appearing in numbered section headings, you may define the alias
3486
3487 @Example
3488 .als SN-STYLE SN-NO-DOT
3489 @endExample
3490
3491 @noindent
3492 Any such change in section numbering style becomes effective from the
3493 next use of @code{.NH}, following redefinition of the alias for
3494 @code{SN-STYLE}.
3495 @endDefstr
3496
3497 @Defmac {SH, [@Var{match-level}], ms}
3498 Unnumbered subheading.
3499
3500 The optional @var{match-level} argument is a GNU extension.  It is a
3501 number indicating the level of the heading, in a manner analogous to the
3502 @var{curr-level} argument to @code{.NH}.  Its purpose is to match the
3503 point size, at which the heading is printed, to the size of a numbered
3504 heading at the same level, when the @code{GROWPS} and @code{PSINCR}
3505 heading size adjustment mechanism is in effect.  @xref{ms Document
3506 Control Registers}.
3507 @endDefmac
3508
3509 The @code{HORPHANS} register (@pxref{ms Document Control Registers})
3510 operates in conjunction with the @code{NH} and @code{SH} macros, to
3511 inhibit the printing of orphaned section headings at the bottom of any
3512 page.
3513
3514 @c ---------------------------------------------------------------------
3515
3516 @node Highlighting in ms, Lists in ms, Headings in ms, ms Body Text
3517 @subsubsection Highlighting
3518 @cindex @code{ms} macros, highlighting
3519
3520 The @file{ms} macros provide a variety of methods to highlight or
3521 emphasize text:
3522
3523 @Defmac {B, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3524 Sets its first argument in @strong{bold type}.  If you specify a second
3525 argument, @code{groff} prints it in the previous font after the bold
3526 text, with no intervening space (this allows you to set punctuation
3527 after the highlighted text without highlighting the punctuation).
3528 Similarly, it prints the third argument (if any) in the previous font
3529 @strong{before} the first argument.  For example,
3530
3531 @Example
3532 .B foo ) (
3533 @endExample
3534
3535 prints (@strong{foo}).
3536
3537 If you give this macro no arguments, @code{groff} prints all text
3538 following in bold until the next highlighting, paragraph, or heading
3539 macro.
3540 @endDefmac
3541
3542 @Defmac {R, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3543 Sets its first argument in roman (or regular) type.  It operates
3544 similarly to the @code{B}@tie{}macro otherwise.
3545 @endDefmac
3546
3547 @Defmac {I, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3548 Sets its first argument in @emph{italic type}.  It operates similarly
3549 to the @code{B}@tie{}macro otherwise.
3550 @endDefmac
3551
3552 @Defmac {CW, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3553 Sets its first argument in a @code{constant width face}.  It operates
3554 similarly to the @code{B}@tie{}macro otherwise.
3555 @endDefmac
3556
3557 @Defmac {BI, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3558 Sets its first argument in bold italic type.  It operates similarly to
3559 the @code{B}@tie{}macro otherwise.
3560 @endDefmac
3561
3562 @Defmac {BX, [@Var{txt}], ms}
3563 Prints its argument and draws a box around it.  If you want to box a
3564 string that contains spaces, use a digit-width space (@code{\0}).
3565 @endDefmac
3566
3567 @Defmac {UL, [@Var{txt} [@Var{post}]], ms}
3568 Prints its first argument with an underline.  If you specify a second
3569 argument, @code{groff} prints it in the previous font after the
3570 underlined text, with no intervening space.
3571 @endDefmac
3572
3573 @Defmac {LG, , ms}
3574 Prints all text following in larger type (two points larger than the
3575 current point size) until the next font size, highlighting, paragraph,
3576 or heading macro.  You can specify this macro multiple times to
3577 enlarge the point size as needed.
3578 @endDefmac
3579
3580 @Defmac {SM, , ms}
3581 Prints all text following in smaller type (two points smaller than the
3582 current point size) until the next type size, highlighting, paragraph,
3583 or heading macro.  You can specify this macro multiple times to reduce
3584 the point size as needed.
3585 @endDefmac
3586
3587 @Defmac {NL, , ms}
3588 Prints all text following in the normal point size (that is, the value
3589 of the @code{PS} register).
3590 @endDefmac
3591
3592 @DefstrList {@Lbrace{}, ms}
3593 @DefstrListEndx {@Rbrace{}, ms}
3594 Text enclosed with @code{\*@{} and @code{\*@}} is printed as a
3595 superscript.
3596 @endDefstr
3597
3598 @c ---------------------------------------------------------------------
3599
3600 @node Lists in ms, Indentation values in ms, Highlighting in ms, ms Body Text
3601 @subsubsection Lists
3602 @cindex @code{ms} macros, lists
3603
3604 The @code{IP} macro handles duties for all lists.
3605
3606 @Defmac {IP, [@Var{marker} [@Var{width}]], ms}
3607 The @var{marker} is usually a bullet glyph (@code{\[bu]}) for unordered
3608 lists, a number (or auto-incrementing number register) for numbered
3609 lists, or a word or phrase for indented (glossary-style) lists.
3610
3611 The @var{width} specifies the indentation for the body of each list
3612 item; its default unit is @samp{n}.  Once specified, the indentation
3613 remains the same for all list items in the document until specified
3614 again.
3615
3616 The @code{PORPHANS} register (@pxref{ms Document Control Registers})
3617 operates in conjunction with the @code{IP} macro, to inhibit the
3618 printing of orphaned list markers at the bottom of any page.
3619 @endDefmac
3620
3621 The following is an example of a bulleted list.
3622 @cindex example markup, bulleted list [@code{ms}]
3623 @cindex bulleted list, example markup [@code{ms}]
3624
3625 @Example
3626 A bulleted list:
3627 .IP \[bu] 2
3628 lawyers
3629 .IP \[bu]
3630 guns
3631 .IP \[bu]
3632 money
3633 @endExample
3634
3635 Produces:
3636
3637 @Example
3638 A bulleted list:
3639
3640 o lawyers
3641
3642 o guns
3643
3644 o money
3645 @endExample
3646
3647 The following is an example of a numbered list.
3648 @cindex example markup, numbered list [@code{ms}]
3649 @cindex numbered list, example markup [@code{ms}]
3650
3651 @Example
3652 .nr step 1 1
3653 A numbered list:
3654 .IP \n[step] 3
3655 lawyers
3656 .IP \n+[step]
3657 guns
3658 .IP \n+[step]
3659 money
3660 @endExample
3661
3662 Produces:
3663
3664 @Example
3665 A numbered list:
3666
3667 1. lawyers
3668
3669 2. guns
3670
3671 3. money
3672 @endExample
3673
3674 Note the use of the auto-incrementing number register in this example.
3675
3676 The following is an example of a glossary-style list.
3677 @cindex example markup, glossary-style list [@code{ms}]
3678 @cindex glossary-style list, example markup [@code{ms}]
3679
3680 @Example
3681 A glossary-style list:
3682 .IP lawyers 0.4i
3683 Two or more attorneys.
3684 .IP guns
3685 Firearms, preferably
3686 large-caliber.
3687 .IP money
3688 Gotta pay for those
3689 lawyers and guns!
3690 @endExample
3691
3692 Produces:
3693
3694 @Example
3695 A glossary-style list:
3696
3697 lawyers
3698       Two or more attorneys.
3699
3700 guns  Firearms, preferably large-caliber.
3701
3702 money
3703       Gotta pay for those lawyers and guns!
3704 @endExample
3705
3706 In the last example, the @code{IP} macro places the definition on the
3707 same line as the term if it has enough space; otherwise, it breaks to
3708 the next line and starts the definition below the term.  This may or may
3709 not be the effect you want, especially if some of the definitions break
3710 and some do not.  The following examples show two possible ways to force
3711 a break.
3712
3713 The first workaround uses the @code{br} request to force a break after
3714 printing the term or label.
3715
3716 @CartoucheExample
3717 A glossary-style list:
3718 .IP lawyers 0.4i
3719 Two or more attorneys.
3720 .IP guns
3721 .br
3722 Firearms, preferably large-caliber.
3723 .IP money
3724 Gotta pay for those lawyers and guns!
3725 @endCartoucheExample
3726
3727 The second workaround uses the @code{\p} escape to force the break.
3728 Note the space following the escape; this is important.  If you omit the
3729 space, @code{groff} prints the first word on the same line as the term
3730 or label (if it fits) @strong{then} breaks the line.
3731
3732 @CartoucheExample
3733 A glossary-style list:
3734 .IP lawyers 0.4i
3735 Two or more attorneys.
3736 .IP guns
3737 \p Firearms, preferably large-caliber.
3738 .IP money
3739 Gotta pay for those lawyers and guns!
3740 @endCartoucheExample
3741
3742 To set nested lists, use the @code{RS} and @code{RE} macros.
3743 @xref{Indentation values in ms}, for more information.
3744 @cindex @code{ms} macros, nested lists
3745 @cindex nested lists [@code{ms}]
3746
3747 For example:
3748
3749 @CartoucheExample
3750 .IP \[bu] 2
3751 Lawyers:
3752 .RS
3753 .IP \[bu]
3754 Dewey,
3755 .IP \[bu]
3756 Cheatham,
3757 .IP \[bu]
3758 and Howe.
3759 .RE
3760 .IP \[bu]
3761 Guns
3762 @endCartoucheExample
3763
3764 Produces:
3765
3766 @Example
3767 o Lawyers:
3768
3769   o  Dewey,
3770
3771   o  Cheatham,
3772
3773   o  and Howe.
3774
3775 o Guns
3776 @endExample
3777
3778 @c ---------------------------------------------------------------------
3779
3780 @node Indentation values in ms, Tabstops in ms, Lists in ms, ms Body Text
3781 @subsubsection Indentation values
3782
3783 In many situations, you may need to indentation a section of text while
3784 still wrapping and filling.  @xref{Lists in ms}, for an example of
3785 nested lists.
3786
3787 @DefmacList {RS, , ms}
3788 @DefmacListEndx {RE, , ms}
3789 These macros begin and end an indented section.  The @code{PI} register
3790 controls the amount of indentation, allowing the indented text to line
3791 up under hanging and indented paragraphs.
3792 @endDefmac
3793
3794 @xref{ms Displays and Keeps}, for macros to indentation and turn off
3795 filling.
3796
3797 @c ---------------------------------------------------------------------
3798
3799 @node Tabstops in ms, ms Displays and Keeps, Indentation values in ms, ms Body Text
3800 @subsubsection Tab Stops
3801
3802 Use the @code{ta} request to define tab stops as needed.  @xref{Tabs and
3803 Fields}.
3804
3805 @Defmac {TA, , ms}
3806 Use this macro to reset the tab stops to the default for @file{ms}
3807 (every 5n).  You can redefine the @code{TA} macro to create a different
3808 set of default tab stops.
3809 @endDefmac
3810
3811 @c ---------------------------------------------------------------------
3812
3813 @node ms Displays and Keeps, ms Insertions, Tabstops in ms, ms Body Text
3814 @subsubsection Displays and keeps
3815 @cindex @code{ms} macros, displays
3816 @cindex @code{ms} macros, keeps
3817 @cindex keeps [@code{ms}]
3818 @cindex displays [@code{ms}]
3819
3820 Use displays to show text-based examples or figures (such as code
3821 listings).
3822
3823 Displays turn off filling, so lines of code are displayed as-is without
3824 inserting @code{br} requests in between each line.  Displays can be
3825 @dfn{kept} on a single page, or allowed to break across pages.
3826
3827 @DefmacList {DS, @t{L}, ms}
3828 @DefmacItemx {LD, , ms}
3829 @DefmacListEndx {DE, , ms}
3830 Left-justified display.  The @samp{.DS L} call generates a page break,
3831 if necessary, to keep the entire display on one page.  The @code{LD}
3832 macro allows the display to break across pages.  The @code{DE} macro
3833 ends the display.
3834 @endDefmac
3835
3836 @DefmacList {DS, @t{I}, ms}
3837 @DefmacItemx {ID, , ms}
3838 @DefmacListEndx {DE, , ms}
3839 Indents the display as defined by the @code{DI} register.  The @samp{.DS
3840 I} call generates a page break, if necessary, to keep the entire display
3841 on one page.  The @code{ID} macro allows the display to break across
3842 pages.  The @code{DE} macro ends the display.
3843 @endDefmac
3844
3845 @DefmacList {DS, @t{B}, ms}
3846 @DefmacItemx {BD, , ms}
3847 @DefmacListEndx {DE, , ms}
3848 Sets a block-centered display: the entire display is left-justified, but
3849 indented so that the longest line in the display is centered on the
3850 page.  The @samp{.DS B} call generates a page break, if necessary, to
3851 keep the entire display on one page.  The @code{BD} macro allows the
3852 display to break across pages.  The @code{DE} macro ends the display.
3853 @endDefmac
3854
3855 @DefmacList {DS, @t{C}, ms}
3856 @DefmacItemx {CD, , ms}
3857 @DefmacListEndx {DE, , ms}
3858 Sets a centered display: each line in the display is centered.  The
3859 @samp{.DS C} call generates a page break, if necessary, to keep the
3860 entire display on one page.  The @code{CD} macro allows the display to
3861 break across pages.  The @code{DE} macro ends the display.
3862 @endDefmac
3863
3864 @DefmacList {DS, @t{R}, ms}
3865 @DefmacItemx {RD, , ms}
3866 @DefmacListEndx {DE, , ms}
3867 Right-justifies each line in the display.  The @samp{.DS R} call
3868 generates a page break, if necessary, to keep the entire display on one
3869 page.  The @code{RD} macro allows the display to break across pages.
3870 The @code{DE} macro ends the display.
3871 @endDefmac
3872
3873 @DefmacList {Ds, , ms}
3874 @DefmacListEndx {De, , ms}
3875 These two macros were formerly provided as aliases for @code{DS} and
3876 @code{DE}, respectively.  They have been removed, and should no longer
3877 be used.  The original implementations of @code{DS} and @code{DE} are
3878 retained, and should be used instead.  X11 documents that actually use
3879 @code{Ds} and @code{De} always load a specific macro file from the X11
3880 distribution (@file{macros.t}) that provides proper definitions for the
3881 two macros.
3882 @endDefmac
3883
3884 On occasion, you may want to @dfn{keep} other text together on a page.
3885 For example, you may want to keep two paragraphs together, or a
3886 paragraph that refers to a table (or list, or other item) immediately
3887 following.  The @file{ms} macros provide the @code{KS} and @code{KE}
3888 macros for this purpose.
3889
3890 @DefmacList {KS, , ms}
3891 @DefmacListEndx {KE, , ms}
3892 The @code{KS} macro begins a block of text to be kept on a single page,
3893 and the @code{KE} macro ends the block.
3894 @endDefmac
3895
3896 @DefmacList {KF, , ms}
3897 @DefmacListEndx {KE, , ms}
3898 Specifies a @dfn{floating keep}; if the keep cannot fit on the current
3899 page, @code{groff} holds the contents of the keep and allows text
3900 following the keep (in the source file) to fill in the remainder of the
3901 current page.  When the page breaks, whether by an explicit @code{bp}
3902 request or by reaching the end of the page, @code{groff} prints the
3903 floating keep at the top of the new page.  This is useful for printing
3904 large graphics or tables that do not need to appear exactly where
3905 specified.
3906 @endDefmac
3907
3908 You can also use the @code{ne} request to force a page break if there is
3909 not enough vertical space remaining on the page.
3910
3911 Use the following macros to draw a box around a section of text (such as
3912 a display).
3913
3914 @DefmacList {B1, , ms}
3915 @DefmacListEndx {B2, , ms}
3916 Marks the beginning and ending of text that is to have a box drawn
3917 around it.  The @code{B1} macro begins the box; the @code{B2} macro ends
3918 it.  Text in the box is automatically placed in a diversion (keep).
3919 @endDefmac
3920
3921 @c ---------------------------------------------------------------------
3922
3923 @node ms Insertions, Example multi-page table, ms Displays and Keeps, ms Body Text
3924 @subsubsection Tables, figures, equations, and references
3925 @cindex @code{ms} macros, tables
3926 @cindex @code{ms} macros, figures
3927 @cindex @code{ms} macros, equations
3928 @cindex @code{ms} macros, references
3929 @cindex tables [@code{ms}]
3930 @cindex figures [@code{ms}]
3931 @cindex equations [@code{ms}]
3932 @cindex references [@code{ms}]
3933
3934 The @file{ms} macros support the standard @code{groff} preprocessors:
3935 @code{tbl}, @code{pic}, @code{eqn}, and @code{refer}.
3936 @pindex tbl
3937 @pindex pic
3938 @pindex eqn
3939 @pindex refer
3940 You mark text meant for preprocessors by enclosing it in pairs of tags
3941 as follows.
3942
3943 @DefmacList {TS, [@code{H}], ms}
3944 @DefmacListEndx {TE, , ms}
3945 Denotes a table, to be processed by the @code{tbl} preprocessor.  The
3946 optional argument@tie{}@code{H} to @code{TS} instructs @code{groff} to
3947 create a running header with the information up to the @code{TH} macro.
3948 @code{groff} prints the header at the beginning of the table; if the
3949 table runs onto another page, @code{groff} prints the header on the next
3950 page as well.
3951 @endDefmac
3952
3953 @DefmacList {PS, , ms}
3954 @DefmacListEndx {PE, , ms}
3955 Denotes a graphic, to be processed by the @code{pic} preprocessor.  You
3956 can create a @code{pic} file by hand, using the @acronym{AT&T}
3957 @code{pic} manual available on the Web as a reference, or by using a
3958 graphics program such as @code{xfig}.
3959 @endDefmac
3960
3961 @DefmacList {EQ, [@Var{align}], ms}
3962 @DefmacListEndx {EN, , ms}
3963 Denotes an equation, to be processed by the @code{eqn} preprocessor.
3964 The optional @var{align} argument can be @code{C}, @code{L},
3965 or@tie{}@code{I} to center (the default), left-justify, or indent the
3966 equation.
3967 @endDefmac
3968
3969 @DefmacList {[, , ms}
3970 @DefmacListEndx {], , ms}
3971 Denotes a reference, to be processed by the @code{refer} preprocessor.
3972 The GNU @cite{refer(1)} man page provides a comprehensive reference to
3973 the preprocessor and the format of the bibliographic database.
3974 @endDefmac
3975
3976 @menu
3977 * Example multi-page table::
3978 @end menu
3979
3980 @c ---------------------------------------------------------------------
3981
3982 @node Example multi-page table, ms Footnotes, ms Insertions, ms Body Text
3983 @subsubsection An example multi-page table
3984 @cindex example markup, multi-page table [@code{ms}]
3985 @cindex multi-page table, example markup [@code{ms}]
3986
3987 The following is an example of how to set up a table that may print
3988 across two or more pages.
3989
3990 @CartoucheExample
3991 .TS H
3992 allbox expand;
3993 cb | cb .
3994 Text      ...of heading...
3995 _
3996 .TH
3997 .T&
3998 l | l .
3999 ... the rest of the table follows...
4000 .CW
4001 .TE
4002 @endCartoucheExample
4003
4004 @c ---------------------------------------------------------------------
4005
4006 @node ms Footnotes,  , Example multi-page table, ms Body Text
4007 @subsubsection Footnotes
4008 @cindex @code{ms} macros, footnotes
4009 @cindex footnotes [@code{ms}]
4010
4011 The @file{ms} macro package has a flexible footnote system.  You can
4012 specify either numbered footnotes or symbolic footnotes (that is, using
4013 a marker such as a dagger symbol).
4014
4015 @Defstr {*, ms}
4016 Specifies the location of a numbered footnote marker in the text.
4017 @endDefesc
4018
4019 @DefmacList {FS, , ms}
4020 @DefmacListEndx {FE, , ms}
4021 Specifies the text of the footnote.  The default action is to create a
4022 numbered footnote; you can create a symbolic footnote by specifying a
4023 @dfn{mark} glyph (such as @code{\[dg]} for the dagger glyph) in the body
4024 text and as an argument to the @code{FS} macro, followed by the text of
4025 the footnote and the @code{FE} macro.
4026 @endDefmac
4027
4028 You can control how @code{groff} prints footnote numbers by changing the
4029 value of the @code{FF} register.  @xref{ms Document Control Registers}.
4030
4031 @cindex footnotes, and keeps [@code{ms}]
4032 @cindex keeps, and footnotes [@code{ms}]
4033 @cindex footnotes, and displays [@code{ms}]
4034 @cindex displays, and footnotes [@code{ms}]
4035 Footnotes can be safely used within keeps and displays, but you should
4036 avoid using numbered footnotes within floating keeps.  You can set a
4037 second @code{\**} marker between a @code{\**} and its corresponding
4038 @code{.FS} entry; as long as each @code{FS} macro occurs @emph{after}
4039 the corresponding @code{\**} and the occurrences of @code{.FS} are in
4040 the same order as the corresponding occurrences of @code{\**}.
4041
4042 @c ---------------------------------------------------------------------
4043
4044 @node ms Page Layout, Differences from AT&T ms, ms Body Text, ms
4045 @subsection Page layout
4046 @cindex @code{ms} macros, page layout
4047 @cindex page layout [@code{ms}]
4048
4049 The default output from the @file{ms} macros provides a minimalist page
4050 layout: it prints a single column, with the page number centered at the
4051 top of each page.  It prints no footers.
4052
4053 You can change the layout by setting the proper number registers and
4054 strings.
4055
4056 @menu
4057 * ms Headers and Footers::
4058 * ms Margins::
4059 * ms Multiple Columns::
4060 * ms TOC::
4061 * ms Strings and Special Characters::
4062 @end menu
4063
4064 @c ---------------------------------------------------------------------
4065
4066 @node ms Headers and Footers, ms Margins, ms Page Layout, ms Page Layout
4067 @subsubsection Headers and footers
4068 @cindex @code{ms} macros, headers
4069 @cindex @code{ms} macros, footers
4070 @cindex headers [@code{ms}]
4071 @cindex footers [@code{ms}]
4072
4073 For documents that do not distinguish between odd and even pages, set
4074 the following strings:
4075
4076 @DefstrList {LH, ms}
4077 @DefstrItemx {CH, ms}
4078 @DefstrListEndx {RH, ms}
4079 Sets the left, center, and right headers.
4080 @endDefstr
4081
4082 @DefstrList {LF, ms}
4083 @DefstrItemx {CF, ms}
4084 @DefstrListEndx {RF, ms}
4085 Sets the left, center, and right footers.
4086 @endDefstr
4087
4088 For documents that need different information printed in the even and
4089 odd pages, use the following macros:
4090
4091 @DefmacList {OH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
4092 @DefmacItemx {EH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
4093 @DefmacItemx {OF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
4094 @DefmacListEndx {EF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
4095 The @code{OH} and @code{EH} macros define headers for the odd and even
4096 pages; the @code{OF} and @code{EF} macros define footers for the odd and
4097 even pages.  This is more flexible than defining the individual strings.
4098
4099 You can replace the quote (@code{'}) marks with any character not
4100 appearing in the header or footer text.
4101 @endDefmac
4102
4103 To specify custom header and footer processing, redefine the following
4104 macros:
4105
4106 @DefmacList {PT,, ms}
4107 @DefmacItemx {HD,, ms}
4108 @DefmacListEndx {BT,, ms}
4109 The @code{PT} macro defines a custom header; the @code{BT} macro defines
4110 a custom footer.  These macros must handle odd/even/first page
4111 differences if necessary.
4112
4113 The @code{HD} macro defines additional header processing to take place
4114 after executing the @code{PT} macro.
4115 @endDefmac
4116
4117 @c ---------------------------------------------------------------------
4118
4119 @node ms Margins, ms Multiple Columns, ms Headers and Footers, ms Page Layout
4120 @subsubsection Margins
4121 @cindex @code{ms} macros, margins
4122
4123 You control margins using a set of number registers.  @xref{ms Document
4124 Control Registers}, for details.
4125
4126 @c ---------------------------------------------------------------------
4127
4128 @node ms Multiple Columns, ms TOC, ms Margins, ms Page Layout
4129 @subsubsection Multiple columns
4130 @cindex @code{ms} macros, multiple columns
4131 @cindex multiple columns [@code{ms}]
4132
4133 The @file{ms} macros can set text in as many columns as do reasonably
4134 fit on the page.  The following macros are available; all of them force
4135 a page break if a multi-column mode is already set.  However, if the
4136 current mode is single-column, starting a multi-column mode does
4137 @emph{not} force a page break.
4138
4139 @Defmac {1C, , ms}
4140 Single-column mode.
4141 @endDefmac
4142
4143 @Defmac {2C, , ms}
4144 Two-column mode.
4145 @endDefmac
4146
4147 @Defmac {MC, [@Var{width} [@Var{gutter}]], ms}
4148 Multi-column mode.  If you specify no arguments, it is equivalent to the
4149 @code{2C} macro.  Otherwise, @var{width} is the width of each column and
4150 @var{gutter} is the space between columns.  The @code{MINGW} number
4151 register controls the default gutter width.
4152 @endDefmac
4153
4154 @c ---------------------------------------------------------------------
4155
4156 @node ms TOC, ms Strings and Special Characters, ms Multiple Columns, ms Page Layout
4157 @subsubsection Creating a table of contents
4158 @cindex @code{ms} macros, creating table of contents
4159 @cindex table of contents, creating [@code{ms}]
4160
4161 The facilities in the @file{ms} macro package for creating a table of
4162 contents are semi-automated at best.  Assuming that you want the table
4163 of contents to consist of the document's headings, you need to repeat
4164 those headings wrapped in @code{XS} and @code{XE} macros.
4165
4166 @DefmacList {XS, [@Var{page}], ms}
4167 @DefmacItemx {XA, [@Var{page}], ms}
4168 @DefmacListEndx {XE, , ms}
4169 These macros define a table of contents or an individual entry in the
4170 table of contents, depending on their use.  The macros are very simple;
4171 they cannot indent a heading based on its level.  The easiest way to
4172 work around this is to add tabs to the table of contents string.  The
4173 following is an example:
4174
4175 @CartoucheExample
4176 .NH 1
4177 Introduction
4178 .XS
4179 Introduction
4180 .XE
4181 .LP
4182 ...
4183 .CW
4184 .NH 2
4185 Methodology
4186 .XS
4187 Methodology
4188 .XE
4189 .LP
4190 ...
4191 @endCartoucheExample
4192
4193 You can manually create a table of contents by beginning with the
4194 @code{XS} macro for the first entry, specifying the page number for that
4195 entry as the argument to @code{XS}.  Add subsequent entries using the
4196 @code{XA} macro, specifying the page number for that entry as the
4197 argument to @code{XA}.  The following is an example:
4198
4199 @CartoucheExample
4200 .XS 1
4201 Introduction
4202 .XA 2
4203 A Brief History of the Universe
4204 .XA 729
4205 Details of Galactic Formation
4206 ...
4207 .XE
4208 @endCartoucheExample
4209 @endDefmac
4210
4211 @Defmac {TC, [@code{no}], ms}
4212 Prints the table of contents on a new page, setting the page number
4213 to@tie{}@strong{i} (Roman lowercase numeral one).  You should usually
4214 place this macro at the end of the file, since @code{groff} is a
4215 single-pass formatter and can only print what has been collected up to
4216 the point that the @code{TC} macro appears.
4217
4218 The optional argument @code{no} suppresses printing the title specified
4219 by the string register @code{TOC}.
4220 @endDefmac
4221
4222 @Defmac {PX, [@code{no}], ms}
4223 Prints the table of contents on a new page, using the current page
4224 numbering sequence.  Use this macro to print a manually generated table
4225 of contents at the beginning of your document.
4226
4227 The optional argument @code{no} suppresses printing the title specified
4228 by the string register @code{TOC}.
4229 @endDefmac
4230
4231 The @cite{Groff and Friends HOWTO} includes a @code{sed} script that
4232 automatically inserts @code{XS} and @code{XE} macro entries after each
4233 heading in a document.
4234
4235 Altering the @code{NH} macro to automatically build the table of
4236 contents is perhaps initially more difficult, but would save a great
4237 deal of time in the long run if you use @file{ms} regularly.
4238
4239 @c ---------------------------------------------------------------------
4240
4241 @node ms Strings and Special Characters,  , ms TOC, ms Page Layout
4242 @subsubsection Strings and Special Characters
4243 @cindex @code{ms} macros, strings
4244 @cindex @code{ms} macros, special characters
4245 @cindex @code{ms} macros, accent marks
4246 @cindex accent marks [@code{ms}]
4247 @cindex special characters [@code{ms}]
4248 @cindex strings [@code{ms}]
4249
4250 The @file{ms} macros provide the following predefined strings.  You can
4251 change the string definitions to help in creating documents in languages
4252 other than English.
4253
4254 @Defstr {REFERENCES, ms}
4255 Contains the string printed at the beginning of the references
4256 (bibliography) page.  The default is @samp{References}.
4257 @endDefstr
4258
4259 @Defstr {ABSTRACT, ms}
4260 Contains the string printed at the beginning of the abstract.  The
4261 default is @samp{ABSTRACT}.
4262 @endDefstr
4263
4264 @Defstr {TOC, ms}
4265 Contains the string printed at the beginning of the table of contents.
4266 @endDefstr
4267
4268 @DefstrList {MONTH1, ms}
4269 @DefstrItemx {MONTH2, ms}
4270 @DefstrItemx {MONTH3, ms}
4271 @DefstrItemx {MONTH4, ms}
4272 @DefstrItemx {MONTH5, ms}
4273 @DefstrItemx {MONTH6, ms}
4274 @DefstrItemx {MONTH7, ms}
4275 @DefstrItemx {MONTH8, ms}
4276 @DefstrItemx {MONTH9, ms}
4277 @DefstrItemx {MONTH10, ms}
4278 @DefstrItemx {MONTH11, ms}
4279 @DefstrListEndx {MONTH12, ms}
4280 Prints the full name of the month in dates.  The default is
4281 @samp{January}, @samp{February}, etc.
4282 @endDefstr
4283
4284 The following special characters are available@footnote{For an
4285 explanation what special characters are see @ref{Special Characters}.}:
4286
4287 @Defstr {-, ms}
4288 Prints an em dash.
4289 @endDefstr
4290
4291 @DefstrList {Q, ms}
4292 @DefstrListEndx {U, ms}
4293 Prints typographer's quotes in troff, and plain quotes in nroff.
4294 @code{\*Q} is the left quote and @code{\*U} is the right quote.
4295 @endDefstr
4296
4297 Improved accent marks are available in the @file{ms} macros.
4298
4299 @Defmac {AM, , ms}
4300 Specify this macro at the beginning of your document to enable extended
4301 accent marks and special characters.  This is a Berkeley extension.
4302
4303 To use the accent marks, place them @strong{after} the character being
4304 accented.
4305
4306 Note that groff's native support for accents is superior to the
4307 following definitions.
4308 @endDefmac
4309
4310 The following accent marks are available after invoking the @code{AM}
4311 macro:
4312
4313 @Defstr {', ms}
4314 Acute accent.
4315 @endDefstr
4316
4317 @Defstr {`, ms}
4318 Grave accent.
4319 @endDefstr
4320
4321 @Defstr {^, ms}
4322 Circumflex.
4323 @endDefstr
4324
4325 @Defstr {\,, ms}
4326 Cedilla.
4327 @endDefstr
4328
4329 @Defstr {~, ms}
4330 Tilde.
4331 @endDefstr
4332
4333 @deffn String @t{\*[:]}
4334 @ifnotinfo
4335 @stindex : @r{[}ms@r{]}
4336 @end ifnotinfo
4337 @ifinfo
4338 @stindex \*[@r{<colon>}] @r{[}ms@r{]}
4339 @end ifinfo
4340 Umlaut.
4341 @end deffn
4342
4343 @Defstr {v, ms}
4344 Hacek.
4345 @endDefstr
4346
4347 @Defstr {_, ms}
4348 Macron (overbar).
4349 @endDefstr
4350
4351 @Defstr {., ms}
4352 Underdot.
4353 @endDefstr
4354
4355 @Defstr {o, ms}
4356 Ring above.
4357 @endDefstr
4358
4359 The following are standalone characters available after invoking the
4360 @code{AM} macro:
4361
4362 @Defstr {?, ms}
4363 Upside-down question mark.
4364 @endDefstr
4365
4366 @Defstr {!, ms}
4367 Upside-down exclamation point.
4368 @endDefstr
4369
4370 @Defstr {8, ms}
4371 German ÃŸ ligature.
4372 @endDefstr
4373
4374 @Defstr {3, ms}
4375 Yogh.
4376 @endDefstr
4377
4378 @Defstr {Th, ms}
4379 Uppercase thorn.
4380 @endDefstr
4381
4382 @Defstr {th, ms}
4383 Lowercase thorn.
4384 @endDefstr
4385
4386 @Defstr {D-, ms}
4387 Uppercase eth.
4388 @endDefstr
4389
4390 @Defstr {d-, ms}
4391 Lowercase eth.
4392 @endDefstr
4393
4394 @Defstr {q, ms}
4395 Hooked o.
4396 @endDefstr
4397
4398 @Defstr {ae, ms}
4399 Lowercase Ã¦ ligature.
4400 @endDefstr
4401
4402 @Defstr {Ae, ms}
4403 Uppercase Ã† ligature.
4404 @endDefstr
4405
4406 @c ---------------------------------------------------------------------
4407
4408 @node Differences from AT&T ms, Naming Conventions, ms Page Layout, ms
4409 @subsection Differences from @acronym{AT&T} @file{ms}
4410 @cindex @code{ms} macros, differences from @acronym{AT&T}
4411 @cindex @acronym{AT&T} @code{troff}, @code{ms} macro package differences
4412
4413 This section lists the (minor) differences between the @code{groff -ms}
4414 macros and @acronym{AT&T} @code{troff -ms} macros.
4415
4416 @itemize @bullet
4417 @item
4418 The internals of @code{groff -ms} differ from the internals of
4419 @acronym{AT&T} @code{troff -ms}.  Documents that depend upon
4420 implementation details of @acronym{AT&T} @code{troff -ms} may not format
4421 properly with @code{groff -ms}.
4422
4423 @item
4424 The general error-handling policy of @code{groff -ms} is to detect and
4425 report errors, rather than silently to ignore them.
4426
4427 @item
4428 @code{groff -ms} does not work in compatibility mode (that is, with the
4429 @option{-C} option).
4430
4431 @item
4432 There is no special support for typewriter-like devices.
4433
4434 @item
4435 @code{groff -ms} does not provide cut marks.
4436
4437 @item
4438 Multiple line spacing is not supported.  Use a larger vertical spacing
4439 instead.
4440
4441 @item
4442 Some Unix @code{ms} documentation says that the @code{CW} and @code{GW}
4443 number registers can be used to control the column width and gutter
4444 width, respectively.  These number registers are not used in @code{groff
4445 -ms}.
4446
4447 @item
4448 Macros that cause a reset (paragraphs, headings, etc.@:) may change the
4449 indentation.  Macros that change the indentation do not increment or
4450 decrement the indentation, but rather set it absolutely.  This can cause
4451 problems for documents that define additional macros of their own.  The
4452 solution is to use not the @code{in} request but instead the @code{RS}
4453 and @code{RE} macros.
4454
4455 @item
4456 To make @code{groff -ms} use the default page offset (which also
4457 specifies the left margin), the @code{PO} register must stay undefined
4458 until the first @file{-ms} macro is evaluated.  This implies that
4459 @code{PO} should not be used early in the document, unless it is changed
4460 also: Remember that accessing an undefined register automatically
4461 defines it.
4462 @end itemize
4463
4464 @Defmpreg {GS, ms}
4465 This number register is set to@tie{}1 by the @code{groff -ms} macros,
4466 but it is not used by the @code{AT&T} @code{troff -ms} macros.
4467 Documents that need to determine whether they are being formatted with
4468 @code{AT&T} @code{troff -ms} or @code{groff -ms} should use this number
4469 register.
4470 @endDefmpreg
4471
4472 Emulations of a few ancient Bell Labs macros can be re-enabled by
4473 calling the otherwise undocumented @code{SC} section-header macro.
4474 Calling @code{SC} enables @code{UC} for marking up a product or
4475 application name, and the pair @code{P1}/@code{P2} for surrounding code
4476 example displays.
4477
4478 These are not enabled by default because (a)@tie{}they were not
4479 documented, in the original @code{ms} manual, and (b)@tie{}the @code{P1}
4480 and @code{UC} macros collide with different macros with the same names
4481 in the Berkeley version of @code{ms}.
4482
4483 These @code{groff} emulations are sufficient to give back the 1976
4484 Kernighan@tie{}& Cherry paper @cite{Typesetting Mathematics -- User's
4485 Guide} its section headings, and restore some text that had gone missing
4486 as arguments of undefined macros.  No warranty express or implied is
4487 given as to how well the typographic details these produce match the
4488 original Bell Labs macros.
4489
4490 @menu
4491 * Missing ms Macros::
4492 * Additional ms Macros::
4493 @end menu
4494
4495 @c ---------------------------------------------------------------------
4496
4497 @node Missing ms Macros, Additional ms Macros, Differences from AT&T ms, Differences from AT&T ms
4498 @subsubsection @code{troff} macros not appearing in @code{groff}
4499
4500 Macros missing from @code{groff -ms} are cover page macros specific to
4501 Bell Labs and Berkeley.  The macros known to be missing are:
4502
4503 @table @code
4504 @item .TM
4505 Technical memorandum; a cover sheet style
4506
4507 @item .IM
4508 Internal memorandum; a cover sheet style
4509
4510 @item .MR
4511 Memo for record; a cover sheet style
4512
4513 @item .MF
4514 Memo for file; a cover sheet style
4515
4516 @item .EG
4517 Engineer's notes; a cover sheet style
4518
4519 @item .TR
4520 Computing Science Tech Report; a cover sheet style
4521
4522 @item .OK
4523 Other keywords
4524
4525 @item .CS
4526 Cover sheet information
4527
4528 @item .MH
4529 A cover sheet macro
4530 @end table
4531
4532 @c ---------------------------------------------------------------------
4533
4534 @node Additional ms Macros,  , Missing ms Macros, Differences from AT&T ms
4535 @subsubsection @code{groff} macros not appearing in @acronym{AT&T} @code{troff}
4536
4537 The @code{groff -ms} macros have a few minor extensions compared to the
4538 @acronym{AT&T} @code{troff -ms} macros.
4539
4540 @Defmac {AM, , ms}
4541 Improved accent marks.  @xref{ms Strings and Special Characters}, for
4542 details.
4543 @endDefmac
4544
4545 @Defmac {DS, @t{I}, ms}
4546 Indented display.  The default behavior of @acronym{AT&T} @code{troff
4547 -ms} was to indent; the @code{groff} default prints displays flush left
4548 with the body text.
4549 @endDefmac
4550
4551 @Defmac {CW, , ms}
4552 Print text in @code{constant width} (Courier) font.
4553 @endDefmac
4554
4555 @Defmac {IX, , ms}
4556 Indexing term (printed on standard error).  You can write a script to
4557 capture and process an index generated in this manner.
4558 @endDefmac
4559
4560 The following additional number registers
4561 appear in @code{groff -ms}:
4562
4563 @Defmpreg {MINGW, ms}
4564 Specifies a minimum space between columns (for multi-column output);
4565 this takes the place of the @code{GW} register that was documented but
4566 apparently not implemented in @acronym{AT&T} @code{troff}.
4567 @endDefmpreg
4568
4569 Several new string registers are available as well.  You can change
4570 these to handle (for example) the local language.  @xref{ms Strings and
4571 Special Characters}, for details.
4572
4573 @c ---------------------------------------------------------------------
4574
4575 @node Naming Conventions,  , Differences from AT&T ms, ms
4576 @subsection Naming Conventions
4577 @cindex @code{ms} macros, naming conventions
4578 @cindex naming conventions, @code{ms} macros
4579
4580 The following conventions are used for names of macros, strings and
4581 number registers.  External names available to documents that use the
4582 @code{groff -ms} macros contain only uppercase letters and digits.
4583
4584 Internally the macros are divided into modules; naming conventions are
4585 as follows:
4586
4587 @itemize @bullet
4588 @item
4589 Names used only within one module are of the form
4590 @var{module}@code{*}@var{name}.
4591
4592 @item
4593 Names used outside the module in which they are defined are of the form
4594 @var{module}@code{@@}@var{name}.
4595
4596 @item
4597 Names associated with a particular environment are of the form
4598 @var{environment}@code{:}@var{name}; these are used only within the
4599 @code{par} module.
4600
4601 @item
4602 @var{name} does not have a module prefix.
4603
4604 @item
4605 Constructed names used to implement arrays are of the form
4606 @var{array}@code{!}@var{index}.
4607 @end itemize
4608
4609 Thus the groff ms macros reserve the following names:
4610
4611 @itemize @bullet
4612 @item
4613 Names containing the characters @code{*}, @code{@@}, and@tie{}@code{:}.
4614
4615 @item
4616 Names containing only uppercase letters and digits.
4617 @end itemize
4618
4619
4620 @c =====================================================================
4621
4622 @node me, mm, ms, Macro Packages
4623 @section @file{me}
4624 @cindex @code{me} macro package
4625
4626 @c XXX documentation
4627 @c XXX this is a placeholder until we get stuff knocked into shape
4628 See the @file{meintro.me} and @file{meref.me} documents in groff's
4629 @file{doc} directory.
4630
4631
4632 @c =====================================================================
4633
4634 @node mm, mom, me, Macro Packages
4635 @section @file{mm}
4636 @cindex @code{mm} macro package
4637
4638 @c XXX documentation
4639 @c XXX this is a placeholder until we get stuff knocked into shape
4640 See the @cite{groff_mm(7)} man page (type @command{man groff_mm} at the
4641 command line).
4642
4643
4644 @c =====================================================================
4645
4646 @node mom,  , mm, Macro Packages
4647 @section @file{mom}
4648 @cindex @code{mom} macro package
4649
4650 @c XXX documentation
4651 @c XXX this is a placeholder until we get stuff knocked into shape
4652 The main documentation files for the @file{mom} macros are in
4653 @acronym{HTML} format.  Additional, useful documentation is in PDF
4654 format.  See the @cite{groff(1)} man page, section ``Installation
4655 Directories'', for their location.
4656
4657 @itemize @bullet
4658 @item
4659 @file{toc.html}
4660 @noindent
4661 Entry point to the full mom manual.
4662
4663 @item
4664 @file{macrolist.html}
4665 @noindent
4666 Hyperlinked index of macros with brief descriptions, arranged by
4667 category.
4668
4669 @item
4670 @file{mom-pdf.pdf}
4671 @noindent
4672 PDF features and usage.
4673 @end itemize
4674
4675 The mom macros are in active development between groff releases.
4676 The most recent version, along with up-to-date documentation, is
4677 available at @uref{http://www.schaffter.ca/mom/mom-05.html}.
4678
4679 The @cite{groff_mom(7)} man page (type @command{man groff_mom} at the
4680 command line) contains a partial list of available macros, however their
4681 usage is best understood by consulting the @acronym{HTML} documentation.
4682
4683 @c =====================================================================
4684 @c =====================================================================
4685
4686 @node gtroff Reference, Preprocessors, Macro Packages, Top
4687 @chapter @code{gtroff} Reference
4688 @cindex reference, @code{gtroff}
4689 @cindex @code{gtroff}, reference
4690
4691 This chapter covers @strong{all} of the facilities of @code{gtroff}.
4692 Users of macro packages may skip it if not interested in details.
4693
4694
4695 @menu
4696 * Text::
4697 * Measurements::
4698 * Expressions::
4699 * Identifiers::
4700 * Embedded Commands::
4701 * Registers::
4702 * Manipulating Filling and Adjusting::
4703 * Manipulating Hyphenation::
4704 * Manipulating Spacing::
4705 * Tabs and Fields::
4706 * Character Translations::
4707 * Troff and Nroff Mode::
4708 * Line Layout::
4709 * Line Control::
4710 * Page Layout::
4711 * Page Control::
4712 * Fonts and Symbols::
4713 * Sizes::
4714 * Strings::
4715 * Conditionals and Loops::
4716 * Writing Macros::
4717 * Page Motions::
4718 * Drawing Requests::
4719 * Traps::
4720 * Diversions::
4721 * Environments::
4722 * Suppressing output::
4723 * Colors::
4724 * I/O::
4725 * Postprocessor Access::
4726 * Miscellaneous::
4727 * Gtroff Internals::
4728 * Debugging::
4729 * Implementation Differences::
4730 @end menu
4731
4732
4733 @c =====================================================================
4734
4735 @node Text, Measurements, gtroff Reference, gtroff Reference
4736 @section Text
4737 @cindex text, @code{gtroff} processing
4738
4739 @code{gtroff} input files contain text with control commands
4740 interspersed throughout.  But, even without control codes, @code{gtroff}
4741 still does several things with the input text:
4742
4743 @itemize @bullet
4744 @item
4745 filling and adjusting
4746
4747 @item
4748 adding additional space after sentences
4749
4750 @item
4751 hyphenating
4752
4753 @item
4754 inserting implicit line breaks
4755 @end itemize
4756
4757 @menu
4758 * Filling and Adjusting::
4759 * Hyphenation::
4760 * Sentences::
4761 * Tab Stops::
4762 * Implicit Line Breaks::
4763 * Input Conventions::
4764 * Input Encodings::
4765 @end menu
4766
4767 @c ---------------------------------------------------------------------
4768
4769 @node Filling and Adjusting, Hyphenation, Text, Text
4770 @subsection Filling and Adjusting
4771 @cindex filling
4772 @cindex adjusting
4773
4774 When @code{gtroff} reads text, it collects words from the input and fits
4775 as many of them together on one output line as it can.  This is known as
4776 @dfn{filling}.
4777
4778 @cindex leading spaces
4779 @cindex spaces, leading and trailing
4780 @cindex extra spaces
4781 @cindex trailing spaces
4782 Once @code{gtroff} has a @dfn{filled} line, it tries to @dfn{adjust} it.
4783 This means it widens the spacing between words until the text reaches
4784 the right margin (in the default adjustment mode).  Extra spaces between
4785 words are preserved, but spaces at the end of lines are ignored.  Spaces
4786 at the front of a line cause a @dfn{break} (breaks are explained in
4787 @ref{Implicit Line Breaks}).
4788
4789 @xref{Manipulating Filling and Adjusting}.
4790
4791 @c ---------------------------------------------------------------------
4792
4793 @node Hyphenation, Sentences, Filling and Adjusting, Text
4794 @subsection Hyphenation
4795 @cindex hyphenation
4796
4797 Since the odds are not great for finding a set of words, for every
4798 output line, which fit nicely on a line without inserting excessive
4799 amounts of space between words, @code{gtroff} hyphenates words so that
4800 it can justify lines without inserting too much space between words.  It
4801 uses an internal hyphenation algorithm (a simplified version of the
4802 algorithm used within @TeX{}) to indicate which words can be hyphenated
4803 and how to do so.  When a word is hyphenated, the first part of the word
4804 is added to the current filled line being output (with an attached
4805 hyphen), and the other portion is added to the next line to be filled.
4806
4807 @xref{Manipulating Hyphenation}.
4808
4809 @c ---------------------------------------------------------------------
4810
4811 @node Sentences, Tab Stops, Hyphenation, Text
4812 @subsection Sentences
4813 @cindex sentences
4814
4815 Although it is often debated, some typesetting rules say there should be
4816 different amounts of space after various punctuation marks.  For
4817 example, the @cite{Chicago typesetting manual} says that a period at the
4818 end of a sentence should have twice as much space following it as would
4819 a comma or a period as part of an abbreviation.
4820
4821 @c XXX exact citation of Chicago manual
4822
4823 @cindex sentence space
4824 @cindex space between sentences
4825 @cindex french-spacing
4826 @code{gtroff} does this by flagging certain characters (normally
4827 @samp{!}, @samp{?}, and @samp{.}) as @dfn{end-of-sentence} characters.
4828 When @code{gtroff} encounters one of these characters at the end of a
4829 line, it appends a normal space followed by a @dfn{sentence space} in
4830 the formatted output.  (This justifies one of the conventions mentioned
4831 in @ref{Input Conventions}.)
4832
4833 @cindex transparent characters
4834 @cindex character, transparent
4835 @cindex @code{dg} glyph, at end of sentence
4836 @cindex @code{rq} glyph, at end of sentence
4837 @cindex @code{cq} glyph, at end of sentence
4838 @cindex @code{"}, at end of sentence
4839 @cindex @code{'}, at end of sentence
4840 @cindex @code{)}, at end of sentence
4841 @cindex @code{]}, at end of sentence
4842 @cindex @code{*}, at end of sentence
4843 In addition, the following characters and symbols are treated
4844 transparently while handling end-of-sentence characters: @samp{"},
4845 @samp{'}, @samp{)}, @samp{]}, @samp{*}, @code{\[dg]}, @code{\[rq]}, and
4846 @code{\[cq]}.
4847
4848 See the @code{cflags} request in @ref{Using Symbols}, for more details.
4849
4850 @cindex @code{\&}, at end of sentence
4851 To prevent the insertion of extra space after an end-of-sentence
4852 character (at the end of a line), append @code{\&}.
4853
4854 @c ---------------------------------------------------------------------
4855
4856 @node Tab Stops, Implicit Line Breaks, Sentences, Text
4857 @subsection Tab Stops
4858 @cindex tab stops
4859 @cindex stops, tabulator
4860 @cindex tab character
4861 @cindex character, tabulator
4862
4863 @cindex @acronym{EBCDIC} encoding
4864 @cindex encoding, @acronym{EBCDIC}
4865 @code{gtroff} translates @dfn{tabulator characters}, also called
4866 @dfn{tabs} (normally code point @acronym{ASCII} @code{0x09} or
4867 @acronym{EBCDIC} @code{0x05}), in the input into movements to the next
4868 tabulator stop.  These tab stops are initially located every half inch
4869 across the page.  Using this, simple tables can be made easily.
4870 However, it can often be deceptive as the appearance (and width) of the
4871 text on a terminal and the results from @code{gtroff} can vary greatly.
4872
4873 Also, a possible sticking point is that lines beginning with tab
4874 characters are still filled, again producing unexpected results.  For
4875 example, the following input
4876
4877 @multitable {12345678} {12345678} {12345678} {12345678}
4878 @item
4879 @tab 1 @tab 2 @tab 3
4880 @item
4881 @tab   @tab 4 @tab 5
4882 @end multitable
4883
4884 @noindent
4885 produces
4886
4887 @multitable {12345678} {12345678} {12345678} {12345678} {12345678} {12345678} {12345678}
4888 @item
4889 @tab 1 @tab 2 @tab 3 @tab   @tab 4 @tab 5
4890 @end multitable
4891
4892 @xref{Tabs and Fields}.
4893
4894 @c ---------------------------------------------------------------------
4895
4896 @node Implicit Line Breaks, Input Conventions, Tab Stops, Text
4897 @subsection Implicit Line Breaks
4898 @cindex implicit line breaks
4899 @cindex implicit breaks of lines
4900 @cindex line, implicit breaks
4901 @cindex break, implicit
4902 @cindex line break
4903
4904 An important concept in @code{gtroff} is the @dfn{break}.  When a break
4905 occurs, @code{gtroff} outputs the partially filled line (unjustified),
4906 and resumes collecting and filling text on the next output line.
4907
4908 @cindex blank line
4909 @cindex empty line
4910 @cindex line, blank
4911 @cindex blank line macro (@code{blm})
4912 There are several ways to cause a break in @code{gtroff}.  A blank line
4913 not only causes a break, but it also outputs a one-line vertical space
4914 (effectively a blank line).  Note that this behaviour can be modified
4915 with the blank line macro request @code{blm}.  @xref{Blank Line Traps}.
4916
4917 @cindex fill mode
4918 @cindex mode, fill
4919 @cindex leading spaces macro (@code{lsm})
4920 A line that begins with a space causes a break and the space is output
4921 at the beginning of the next line.  Note that this space isn't adjusted,
4922 even in fill mode; however, the behaviour can be modified with the
4923 leading spaces macro request @code{lsm}.  @xref{Leading Spaces Traps}.
4924
4925 The end of file also causes a break -- otherwise the last line of the
4926 document may vanish!
4927
4928 Certain requests also cause breaks, implicitly or explicitly.  This is
4929 discussed in @ref{Manipulating Filling and Adjusting}.
4930
4931 @c ---------------------------------------------------------------------
4932
4933 @node Input Conventions, Input Encodings, Implicit Line Breaks, Text
4934 @subsection Input Conventions
4935 @cindex input conventions
4936 @cindex conventions for input
4937
4938 Since @code{gtroff} does filling automatically, it is traditional in
4939 @code{groff} not to try and type things in as nicely formatted
4940 paragraphs.  These are some conventions commonly used when typing
4941 @code{gtroff} text:
4942
4943 @itemize @bullet
4944 @item
4945 Break lines after punctuation, particularly at the end of a sentence and
4946 in other logical places.  Keep separate phrases on lines by themselves,
4947 as entire phrases are often added or deleted when editing.
4948
4949 @item
4950 Try to keep lines less than 40--60@tie{}characters, to allow space for
4951 inserting more text.
4952
4953 @item
4954 Do not try to do any formatting in a @acronym{WYSIWYG} manner (i.e.,
4955 don't try using spaces to get proper indentation).
4956 @end itemize
4957
4958 @c ---------------------------------------------------------------------
4959
4960 @node Input Encodings,  , Input Conventions, Text
4961 @subsection Input Encodings
4962
4963 Currently, the following input encodings are available.
4964
4965 @table @asis
4966 @item cp1047
4967 @cindex encoding, input, @acronym{EBCDIC}
4968 @cindex @acronym{EBCDIC}, input encoding
4969 @cindex input encoding, @acronym{EBCDIC}
4970 @cindex encoding, input, cp1047
4971 @cindex cp1047, input encoding
4972 @cindex input encoding, cp1047
4973 @cindex IBM cp1047 input encoding
4974 @pindex cp1047.tmac
4975 This input encoding works only on @acronym{EBCDIC} platforms (and vice
4976 versa, the other input encodings don't work with @acronym{EBCDIC}); the
4977 file @file{cp1047.tmac} is by default loaded at start-up.
4978
4979 @item latin-1
4980 @cindex encoding, input, @w{latin-1} (ISO @w{8859-1})
4981 @cindex @w{latin-1} (ISO @w{8859-1}), input encoding
4982 @cindex ISO @w{8859-1} (@w{latin-1}), input encoding
4983 @cindex input encoding, @w{latin-1} (ISO @w{8859-1})
4984 @pindex latin1.tmac
4985 This is the default input encoding on non-@acronym{EBCDIC} platforms;
4986 the file @file{latin1.tmac} is loaded at start-up.
4987
4988 @item latin-2
4989 @cindex encoding, input, @w{latin-2} (ISO @w{8859-2})
4990 @cindex @w{latin-2} (ISO @w{8859-2}), input encoding
4991 @cindex ISO @w{8859-2} (@w{latin-2}), input encoding
4992 @cindex input encoding, @w{latin-2} (ISO @w{8859-2})
4993 @pindex latin2.tmac
4994 To use this encoding, either say @w{@samp{.mso latin2.tmac}} at the very
4995 beginning of your document or use @samp{-mlatin2} as a command-line
4996 argument for @code{groff}.
4997
4998 @item latin-5
4999 @cindex encoding, input, @w{latin-5} (ISO @w{8859-9})
5000 @cindex @w{latin-5} (ISO @w{8859-9}), input encoding
5001 @cindex ISO @w{8859-9} (@w{latin-5}), input encoding
5002 @cindex input encoding, @w{latin-5} (ISO @w{8859-9})
5003 @pindex latin5.tmac
5004 For Turkish.  Either say @w{@samp{.mso latin5.tmac}} at the very
5005 beginning of your document or use @samp{-mlatin5} as a command-line
5006 argument for @code{groff}.
5007
5008 @item latin-9 (latin-0)
5009 @cindex encoding, input, @w{latin-9} (@w{latin-0}, ISO @w{8859-15})
5010 @cindex @w{latin-9} (@w{latin-0}, ISO @w{8859-15}), input encoding
5011 @cindex ISO @w{8859-15} (@w{latin-9}, @w{latin-0}), input encoding
5012 @cindex input encoding, @w{latin-9} (@w{latin-9}, ISO @w{8859-15})
5013 @pindex latin9.tmac
5014 This encoding is intended (at least in Europe) to replace @w{latin-1}
5015 encoding.  The main difference to @w{latin-1} is that @w{latin-9}
5016 contains the Euro character.  To use this encoding, either say
5017 @w{@samp{.mso latin9.tmac}} at the very beginning of your document or
5018 use @samp{-mlatin9} as a command-line argument for @code{groff}.
5019 @end table
5020
5021 Note that it can happen that some input encoding characters are not
5022 available for a particular output device.  For example, saying
5023
5024 @Example
5025 groff -Tlatin1 -mlatin9 ...
5026 @endExample
5027
5028 @noindent
5029 fails if you use the Euro character in the input.  Usually, this
5030 limitation is present only for devices that have a limited set of
5031 output glyphs (e.g.@: @option{-Tascii} and @option{-Tlatin1}); for other
5032 devices it is usually sufficient to install proper fonts that contain
5033 the necessary glyphs.
5034
5035 @pindex freeeuro.pfa
5036 @pindex ec.tmac
5037 Due to the importance of the Euro glyph in Europe, the groff package now
5038 comes with a @sc{PostScript} font called @file{freeeuro.pfa}, which
5039 provides various glyph shapes for the Euro.  In other words,
5040 @w{latin-9} encoding is supported for the @option{-Tps} device out of
5041 the box (@w{latin-2} isn't).
5042
5043 By its very nature, @option{-Tutf8} supports all input encodings;
5044 @option{-Tdvi} has support for both @w{latin-2} and @w{latin-9} if the
5045 command-line @option{-mec} is used also to load the file @file{ec.tmac}
5046 (which flips to the EC fonts).
5047
5048
5049 @c =====================================================================
5050
5051 @node Measurements, Expressions, Text, gtroff Reference
5052 @section Measurements
5053 @cindex measurements
5054 @cindex scaling indicator
5055 @cindex indicator, scaling
5056
5057 @cindex units of measurement
5058 @cindex basic unit (@code{u})
5059 @cindex machine unit (@code{u})
5060 @cindex measurement unit
5061 @cindex @code{u} unit
5062 @cindex unit, @code{u}
5063 @code{gtroff} (like many other programs) requires numeric parameters to
5064 specify various measurements.  Most numeric parameters@footnote{those
5065 that specify vertical or horizontal motion or a type size} may have a
5066 @dfn{measurement unit} attached.  These units are specified as a single
5067 character that immediately follows the number or expression.  Each of
5068 these units are understood, by @code{gtroff}, to be a multiple of its
5069 @dfn{basic unit}.  So, whenever a different measurement unit is
5070 specified @code{gtroff} converts this into its @dfn{basic units}.  This
5071 basic unit, represented by a @samp{u}, is a device dependent measurement,
5072 which is quite small, ranging from 1/75@dmn{th} to 1/72000@dmn{th} of an
5073 inch.  The values may be given as fractional numbers; however,
5074 fractional basic units are always rounded to integers.
5075
5076 Some of the measurement units are completely independent of any of the
5077 current settings (e.g.@: type size) of @code{gtroff}.
5078
5079 Although groff's basic unit is device-dependent, it may still be smaller
5080 than the smallest unit the device is capable of producing.  The register
5081 @code{.H} specifies how many groff basic units constitute the current
5082 device's basic unit horizontally, and the register @code{.V} specifies
5083 this value vertically.
5084
5085 @table @code
5086 @item i
5087 @cindex inch unit (@code{i})
5088 @cindex @code{i} unit
5089 @cindex unit, @code{i}
5090 Inches.  An antiquated measurement unit still in use in certain
5091 backwards countries with incredibly low-cost computer equipment.  One
5092 inch is defined to be 2.54@tie{}cm (worldwide since 1964).
5093
5094 @item c
5095 @cindex centimeter unit (@code{c})
5096 @cindex @code{c} unit
5097 @cindex unit, @code{c}
5098 Centimeters.  One centimeter is about 0.3937@tie{}in.
5099
5100 @item p
5101 @cindex point unit (@code{p})
5102 @cindex @code{p} unit
5103 @cindex unit, @code{p}
5104 Points.  This is a typesetter's measurement used for measure type size.
5105 It is 72@tie{}points to an inch.
5106
5107 @item P
5108 @cindex pica unit (@code{P})
5109 @cindex @code{P} unit
5110 @cindex unit, @code{P}
5111 Pica.  Another typesetting measurement.  6@tie{}picas to an inch (and
5112 12@tie{}points to a pica).
5113
5114 @item s
5115 @itemx z
5116 @cindex @code{s} unit
5117 @cindex unit, @code{s}
5118 @cindex @code{z} unit
5119 @cindex unit, @code{z}
5120 @xref{Fractional Type Sizes}, for a discussion of these units.
5121
5122 @item f
5123 @cindex @code{f} unit
5124 @cindex unit, @code{f}
5125 Fractions.  Value is 65536.
5126 @xref{Colors}, for usage.
5127 @end table
5128
5129 The other measurements understood by @code{gtroff} depend on settings
5130 currently in effect in @code{gtroff}.  These are very useful for
5131 specifying measurements that should look proper with any size of text.
5132
5133 @table @code
5134 @item m
5135 @cindex em unit (@code{m})
5136 @cindex @code{m} unit
5137 @cindex unit, @code{m}
5138 Ems.  This unit is equal to the current font size in points.  So called
5139 because it is @emph{approximately} the width of the letter@tie{}@samp{m}
5140 in the current font.
5141
5142 @item n
5143 @cindex en unit (@code{n})
5144 @cindex @code{n} unit
5145 @cindex unit, @code{n}
5146 Ens.  In @code{groff}, this is half of an em.
5147
5148 @item v
5149 @cindex vertical space unit (@code{v})
5150 @cindex space, vertical, unit (@code{v})
5151 @cindex @code{v} unit
5152 @cindex unit, @code{v}
5153 Vertical space.  This is equivalent to the current line spacing.
5154 @xref{Sizes}, for more information about this.
5155
5156 @item M
5157 @cindex @code{M} unit
5158 @cindex unit, @code{M}
5159 100ths of an em.
5160 @end table
5161
5162 @menu
5163 * Default Units::
5164 @end menu
5165
5166 @c ---------------------------------------------------------------------
5167
5168 @node Default Units,  , Measurements, Measurements
5169 @subsection Default Units
5170 @cindex default units
5171 @cindex units, default
5172
5173 Many requests take a default unit.  While this can be helpful at times,
5174 it can cause strange errors in some expressions.  For example, the line
5175 length request expects em units.  Here are several attempts to get a
5176 line length of 3.5@tie{}inches and their results:
5177
5178 @Example
5179 3.5i      @result{}   3.5i
5180 7/2       @result{}   0i
5181 7/2i      @result{}   0i
5182 (7 / 2)u  @result{}   0i
5183 7i/2      @result{}   0.1i
5184 7i/2u     @result{}   3.5i
5185 @endExample
5186
5187 @noindent
5188 Everything is converted to basic units first.  In the above example it
5189 is assumed that 1@dmn{i} equals@tie{}240@dmn{u}, and 1@dmn{m}
5190 equals@tie{}10@dmn{p} (thus 1@dmn{m} equals@tie{}33@dmn{u}).  The value
5191 7@dmn{i}/2 is first handled as 7@dmn{i}/2@dmn{m}, then converted to
5192 1680@dmn{u}/66@dmn{u}, which is 25@dmn{u}, and this is approximately
5193 0.1@dmn{i}.  As can be seen, a scaling indicator after a closing
5194 parenthesis is simply ignored.
5195
5196 @cindex measurements, specifying safely
5197 Thus, the safest way to specify measurements is to always attach a
5198 scaling indicator.  If you want to multiply or divide by a certain
5199 scalar value, use @samp{u} as the unit for that value.
5200
5201
5202 @c =====================================================================
5203
5204 @node Expressions, Identifiers, Measurements, gtroff Reference
5205 @section Expressions
5206 @cindex expressions
5207
5208 @code{gtroff} has most arithmetic operators common to other languages:
5209
5210 @itemize @bullet
5211 @item
5212 @cindex arithmetic operators
5213 @cindex operators, arithmetic
5214 @opindex +
5215 @opindex -
5216 @opindex /
5217 @opindex *
5218 @opindex %
5219 Arithmetic: @samp{+} (addition), @samp{-} (subtraction), @samp{/}
5220 (division), @samp{*} (multiplication), @samp{%} (modulo).
5221
5222 @code{gtroff} only provides integer arithmetic.  The internal type used
5223 for computing results is @samp{int}, which is usually a 32-bit signed
5224 integer.
5225
5226 @item
5227 @cindex comparison operators
5228 @cindex operators, comparison
5229 @opindex <
5230 @opindex >
5231 @opindex >=
5232 @opindex <=
5233 @opindex =
5234 @opindex ==
5235 Comparison: @samp{<} (less than), @samp{>} (greater than), @samp{<=}
5236 (less than or equal), @samp{>=} (greater than or equal), @samp{=}
5237 (equal), @samp{==} (the same as @samp{=}).
5238
5239 @item
5240 @cindex logical operators
5241 @cindex operators, logical
5242 @opindex &
5243 @ifnotinfo
5244 @opindex :
5245 @end ifnotinfo
5246 @ifinfo
5247 @opindex @r{<colon>}
5248 @end ifinfo
5249 Logical: @samp{&} (logical and), @samp{:} (logical or).
5250
5251 @item
5252 @cindex unary operators
5253 @cindex operators, unary
5254 @opindex -
5255 @opindex +
5256 @opindex !
5257 @cindex @code{if} request, and the @samp{!} operator
5258 @cindex @code{while} request, and the @samp{!} operator
5259 Unary operators: @samp{-} (negating, i.e.@: changing the sign), @samp{+}
5260 (just for completeness; does nothing in expressions), @samp{!} (logical
5261 not; this works only within @code{if} and @code{while}
5262 requests).@footnote{Note that, for example, @samp{!(-1)} evaluates to
5263 `true' because @code{gtroff} treats both negative numbers and zero as
5264 `false'.}  See below for the use of unary operators in motion requests.
5265
5266 @cindex logical not, limitation in expression
5267 @cindex expression, limitation of logical not in
5268 The logical not operator,
5269 as described above,
5270 works only within @code{if} and @code{while} requests.
5271 Furthermore, it may appear
5272 only at the beginning of an expression,
5273 and negates the entire expression.
5274 Attempting to insert the @samp{!} operator
5275 within the expression results in a
5276 @samp{numeric expression expected} warning.  This
5277 maintains compatibility
5278 with old versions of @code{troff}.
5279
5280 Example:
5281
5282 @Example
5283 .nr X 1
5284 .nr Y 0
5285 .\" This does not work as expected
5286 .if (\n[X])&(!\n[Y]) .nop X only
5287 .
5288 .\" Use this construct instead
5289 .if (\n[X]=1)&(\n[Y]=0) .nop X only
5290 @endExample
5291
5292 @item
5293 @cindex extremum operators (@code{>?}, @code{<?})
5294 @cindex operators, extremum (@code{>?}, @code{<?})
5295 @opindex >?
5296 @opindex <?
5297 Extrema: @samp{>?} (maximum), @samp{<?} (minimum).
5298
5299 Example:
5300
5301 @Example
5302 .nr x 5
5303 .nr y 3
5304 .nr z (\n[x] >? \n[y])
5305 @endExample
5306
5307 @noindent
5308 The register@tie{}@code{z} now contains@tie{}5.
5309
5310 @item
5311 @cindex scaling operator
5312 @cindex operator, scaling
5313 Scaling: @code{(@var{c};@var{e})}.  Evaluate@tie{}@var{e}
5314 using@tie{}@var{c} as the default scaling indicator.  If @var{c} is
5315 missing, ignore scaling indicators in the evaluation of@tie{}@var{e}.
5316 @end itemize
5317
5318 @cindex parentheses
5319 @cindex order of evaluation in expressions
5320 @cindex expression, order of evaluation
5321 @opindex (
5322 @opindex )
5323 Parentheses may be used as in any other language.  However, in
5324 @code{gtroff} they are necessary to ensure order of evaluation.
5325 @code{gtroff} has no operator precedence; expressions are evaluated left
5326 to right.  This means that @code{gtroff} evaluates @samp{3+5*4} as if it
5327 were parenthesized like @samp{(3+5)*4}, not as @samp{3+(5*4)}, as might
5328 be expected.
5329
5330 @cindex @code{+}, and page motion
5331 @cindex @code{-}, and page motion
5332 @cindex motion operators
5333 @cindex operators, motion
5334 For many requests that cause a motion on the page, the unary operators
5335 @samp{+} and @samp{-} work differently if leading an expression.  They
5336 then indicate a motion relative to the current position (down or up,
5337 respectively).
5338
5339 @cindex @code{|}, and page motion
5340 @cindex absolute position operator (@code{|})
5341 @cindex position, absolute, operator (@code{|})
5342 Similarly, a leading @samp{|} operator indicates an absolute position.
5343 For vertical movements, it specifies the distance from the top of the
5344 page; for horizontal movements, it gives the distance from the beginning
5345 of the @emph{input} line.
5346
5347 @cindex @code{bp} request, using @code{+} and@tie{}@code{-}
5348 @cindex @code{in} request, using @code{+} and@tie{}@code{-}
5349 @cindex @code{ll} request, using @code{+} and@tie{}@code{-}
5350 @cindex @code{lt} request, using @code{+} and@tie{}@code{-}
5351 @cindex @code{nm} request, using @code{+} and@tie{}@code{-}
5352 @cindex @code{nr} request, using @code{+} and@tie{}@code{-}
5353 @cindex @code{pl} request, using @code{+} and@tie{}@code{-}
5354 @cindex @code{pn} request, using @code{+} and@tie{}@code{-}
5355 @cindex @code{po} request, using @code{+} and@tie{}@code{-}
5356 @cindex @code{ps} request, using @code{+} and@tie{}@code{-}
5357 @cindex @code{pvs} request, using @code{+} and@tie{}@code{-}
5358 @cindex @code{rt} request, using @code{+} and@tie{}@code{-}
5359 @cindex @code{ti} request, using @code{+} and@tie{}@code{-}
5360 @cindex @code{\H}, using @code{+} and@tie{}@code{-}
5361 @cindex @code{\R}, using @code{+} and@tie{}@code{-}
5362 @cindex @code{\s}, using @code{+} and@tie{}@code{-}
5363 @samp{+} and @samp{-} are also treated differently by the following
5364 requests and escapes: @code{bp}, @code{in}, @code{ll}, @code{lt},
5365 @code{nm}, @code{nr}, @code{pl}, @code{pn}, @code{po}, @code{ps},
5366 @code{pvs}, @code{rt}, @code{ti}, @code{\H}, @code{\R}, and @code{\s}.
5367 Here, leading plus and minus signs indicate increments and decrements.
5368
5369 @xref{Setting Registers}, for some examples.
5370
5371 @Defesc {\\B, ', anything, '}
5372 @cindex numeric expression, valid
5373 @cindex valid numeric expression
5374 Return@tie{}1 if @var{anything} is a valid numeric expression; or@tie{}0
5375 if @var{anything} is empty or not a valid numeric expression.
5376 @endDefesc
5377
5378 @cindex space characters, in expressions
5379 @cindex expressions, and space characters
5380 Due to the way arguments are parsed, spaces are not allowed in
5381 expressions, unless the entire expression is surrounded by parentheses.
5382
5383 @xref{Request and Macro Arguments}, and @ref{Conditionals and Loops}.
5384
5385
5386 @c =====================================================================
5387
5388 @node Identifiers, Embedded Commands, Expressions, gtroff Reference
5389 @section Identifiers
5390 @cindex identifiers
5391
5392 Like any other language, @code{gtroff} has rules for properly formed
5393 @dfn{identifiers}.  In @code{gtroff}, an identifier can be made up of
5394 almost any printable character, with the exception of the following
5395 characters:
5396
5397 @itemize @bullet
5398 @item
5399 @cindex whitespace characters
5400 @cindex newline character
5401 @cindex character, whitespace
5402 Whitespace characters (spaces, tabs, and newlines).
5403
5404 @item
5405 @cindex character, backspace
5406 @cindex backspace character
5407 @cindex @acronym{EBCDIC} encoding of backspace
5408 Backspace (@acronym{ASCII}@tie{}@code{0x08} or
5409 @acronym{EBCDIC}@tie{}@code{0x16}) and character code @code{0x01}.
5410
5411 @item
5412 @cindex invalid input characters
5413 @cindex input characters, invalid
5414 @cindex characters, invalid input
5415 @cindex Unicode
5416 The following input characters are invalid and are ignored if
5417 @code{groff} runs on a machine based on @acronym{ASCII}, causing a
5418 warning message of type @samp{input} (see @ref{Debugging}, for more
5419 details): @code{0x00}, @code{0x0B}, @code{0x0D}--@code{0x1F},
5420 @code{0x80}--@code{0x9F}.
5421
5422 And here are the invalid input characters if @code{groff} runs on an
5423 @acronym{EBCDIC} host: @code{0x00}, @code{0x08}, @code{0x09},
5424 @code{0x0B}, @code{0x0D}--@code{0x14}, @code{0x17}--@code{0x1F},
5425 @code{0x30}--@code{0x3F}.
5426
5427 Currently, some of these reserved codepoints are used internally, thus
5428 making it non-trivial to extend @code{gtroff} to cover Unicode or other
5429 character sets and encodings that use characters of these ranges.
5430
5431 Note that invalid characters are removed before parsing; an identifier
5432 @code{foo}, followed by an invalid character, followed by @code{bar} is
5433 treated as @code{foobar}.
5434 @end itemize
5435
5436 For example, any of the following is valid.
5437
5438 @Example
5439 br
5440 PP
5441 (l
5442 end-list
5443 @@_
5444 @endExample
5445
5446 @cindex @code{]}, as part of an identifier
5447 @noindent
5448 Note that identifiers longer than two characters with a closing bracket
5449 (@samp{]}) in its name can't be accessed with escape sequences that
5450 expect an identifier as a parameter.  For example, @samp{\[foo]]}
5451 accesses the glyph @samp{foo}, followed by @samp{]}, whereas
5452 @samp{\C'foo]'} really asks for glyph @samp{foo]}.
5453
5454 @cindex @code{refer}, and macro names starting with @code{[} or @code{]}
5455 @cindex @code{[}, macro names starting with, and @code{refer}
5456 @cindex @code{]}, macro names starting with, and @code{refer}
5457 @cindex macro names, starting with @code{[} or @code{]}, and @code{refer}
5458 To avoid problems with the @code{refer} preprocessor, macro names should
5459 not start with @samp{[} or @samp{]}.  Due to backwards compatibility,
5460 everything after @samp{.[} and @samp{.]} is handled as a special
5461 argument to @code{refer}.  For example, @samp{.[foo} makes @code{refer}
5462 to start a reference, using @samp{foo} as a parameter.
5463
5464 @Defesc {\\A, ', ident, '}
5465 Test whether an identifier @var{ident} is valid in @code{gtroff}.  It
5466 expands to the character@tie{}1 or@tie{}0 according to whether its
5467 argument (usually delimited by quotes) is or is not acceptable as the
5468 name of a string, macro, diversion, number register, environment, or
5469 font.  It returns@tie{}0 if no argument is given.  This is useful for
5470 looking up user input in some sort of associative table.
5471
5472 @Example
5473 \A'end-list'
5474     @result{} 1
5475 @endExample
5476 @endDefesc
5477
5478 @xref{Escapes}, for details on parameter delimiting characters.
5479
5480 Identifiers in @code{gtroff} can be any length, but, in some contexts,
5481 @code{gtroff} needs to be told where identifiers end and text begins
5482 (and in different ways depending on their length):
5483
5484 @itemize @bullet
5485 @item
5486 Single character.
5487
5488 @cindex @code{(}, starting a two-character identifier
5489 @item
5490 Two characters.  Must be prefixed with @samp{(} in some situations.
5491
5492 @cindex @code{[}, starting an identifier
5493 @cindex @code{]}, ending an identifier
5494 @item
5495 Arbitrary length (@code{gtroff} only).  Must be bracketed with @samp{[}
5496 and@tie{}@samp{]} in some situations.  Any length identifier can be put
5497 in brackets.
5498 @end itemize
5499
5500 @cindex undefined identifiers
5501 @cindex identifiers, undefined
5502 Unlike many other programming languages, undefined identifiers are
5503 silently ignored or expanded to nothing.  When @code{gtroff} finds an
5504 undefined identifier, it emits a warning, doing the following:
5505
5506 @itemize @bullet
5507 @item
5508 If the identifier is a string, macro, or diversion, @code{gtroff}
5509 defines it as empty.
5510
5511 @item
5512 If the identifier is a number register, @code{gtroff} defines it with a
5513 value of@tie{}0.
5514 @end itemize
5515
5516 @xref{Warnings}., @ref{Interpolating Registers}, and @ref{Strings}.
5517
5518 Note that macros, strings, and diversions share the same name space.
5519
5520 @Example
5521 .de xxx
5522 .  nop foo
5523 ..
5524 .
5525 .di xxx
5526 bar
5527 .br
5528 .di
5529 .
5530 .xxx
5531     @result{} bar
5532 @endExample
5533
5534 @noindent
5535 As can be seen in the previous example, @code{gtroff} reuses the
5536 identifier @samp{xxx}, changing it from a macro to a diversion.  No
5537 warning is emitted!  The contents of the first macro definition is lost.
5538
5539 @xref{Interpolating Registers}, and @ref{Strings}.
5540
5541
5542 @c =====================================================================
5543
5544 @node Embedded Commands, Registers, Identifiers, gtroff Reference
5545 @section Embedded Commands
5546 @cindex embedded commands
5547 @cindex commands, embedded
5548
5549 Most documents need more functionality beyond filling, adjusting and
5550 implicit line breaking.  In order to gain further functionality,
5551 @code{gtroff} allows commands to be embedded into the text, in two ways.
5552
5553 The first is a @dfn{request} that takes up an entire line, and does
5554 some large-scale operation (e.g.@: break lines, start new pages).
5555
5556 The other is an @dfn{escape} that can be usually embedded anywhere in
5557 the text; most requests can accept it even as an argument.  Escapes
5558 generally do more minor operations like sub- and superscripts, print a
5559 symbol, etc.
5560
5561 @menu
5562 * Requests::
5563 * Macros::
5564 * Escapes::
5565 @end menu
5566
5567 @c ---------------------------------------------------------------------
5568
5569 @node Requests, Macros, Embedded Commands, Embedded Commands
5570 @subsection Requests
5571 @cindex requests
5572
5573 @cindex control character (@code{.})
5574 @cindex character, control (@code{.})
5575 @cindex no-break control character (@code{'})
5576 @cindex character, no-break control (@code{'})
5577 @cindex control character, no-break (@code{'})
5578 A request line begins with a control character, which is either a single
5579 quote (@samp{'}, the @dfn{no-break control character}) or a period
5580 (@samp{.}, the normal @dfn{control character}).  These can be changed;
5581 see @ref{Character Translations}, for details.  After this there may be
5582 optional tabs or spaces followed by an identifier, which is the name of
5583 the request.  This may be followed by any number of space-separated
5584 arguments (@emph{no} tabs here).
5585
5586 @cindex structuring source code of documents or macro packages
5587 @cindex documents, structuring the source code
5588 @cindex macro packages, structuring the source code
5589 Since a control character followed by whitespace only is ignored, it is
5590 common practice to use this feature for structuring the source code of
5591 documents or macro packages.
5592
5593 @Example
5594 .de foo
5595 .  tm This is foo.
5596 ..
5597 .
5598 .
5599 .de bar
5600 .  tm This is bar.
5601 ..
5602 @endExample
5603
5604 @cindex blank line
5605 @cindex blank line macro (@code{blm})
5606 Another possibility is to use the blank line macro request @code{blm} by
5607 assigning an empty macro to it.
5608
5609 @Example
5610 .de do-nothing
5611 ..
5612 .blm do-nothing  \" activate blank line macro
5613
5614 .de foo
5615 .  tm This is foo.
5616 ..
5617
5618
5619 .de bar
5620 .  tm This is bar.
5621 ..
5622
5623 .blm             \" deactivate blank line macro
5624 @endExample
5625
5626 @xref{Blank Line Traps}.
5627
5628 @cindex zero width space character (@code{\&})
5629 @cindex character, zero width space (@code{\&})
5630 @cindex space character, zero width (@code{\&})
5631 @cindex @code{\&}, escaping control characters
5632 To begin a line with a control character without it being interpreted,
5633 precede it with @code{\&}.  This represents a zero width space, which
5634 means it does not affect the output.
5635
5636 In most cases the period is used as a control character.  Several
5637 requests cause a break implicitly; using the single quote control
5638 character prevents this.
5639
5640 @Defreg {.br}
5641 A read-only number register, which is set to@tie{}1 if a macro is called
5642 with the normal control character (as defined with the @code{cc}
5643 request), and set to@tie{}0 otherwise.
5644
5645 @cindex modifying requests
5646 @cindex requests, modifying
5647 This allows reliable modification of requests.
5648
5649 @Example
5650 .als bp*orig bp
5651 .de bp
5652 .  tm before bp
5653 .  ie \\n[.br] .bp*orig
5654 .  el 'bp*orig
5655 .  tm after bp
5656 ..
5657 @endExample
5658
5659 Using this register outside of a macro makes no sense (it always returns
5660 zero in such cases).
5661
5662 If a macro is called as a string (that is, using @code{\*}), the value
5663 of the @code{.br} register is inherited from the caller.
5664 @endDefreg
5665
5666 @menu
5667 * Request and Macro Arguments::
5668 @end menu
5669
5670 @node Request and Macro Arguments,  , Requests, Requests
5671 @subsubsection Request and Macro Arguments
5672 @cindex request arguments
5673 @cindex macro arguments
5674 @cindex arguments to requests and macros
5675
5676 @cindex tabs, and macro arguments
5677 @cindex macro arguments, and tabs
5678 @cindex arguments to macros, and tabs
5679 Arguments to requests and macros are processed much like the shell:
5680 The line is split into arguments according to
5681 spaces.@footnote{Plan@tie{}9's @code{troff} implementation also allows
5682 tabs for argument separation -- @code{gtroff} intentionally doesn't
5683 support this.}
5684
5685 @cindex spaces, in a macro argument
5686 An argument to a macro that is intended to contain spaces can either be
5687 enclosed in double quotes, or have the spaces @dfn{escaped} with
5688 backslashes.  This is @emph{not} true for requests.
5689
5690 Here are a few examples for a hypothetical macro @code{uh}:
5691
5692 @Example
5693 .uh The Mouse Problem
5694 .uh "The Mouse Problem"
5695 .uh The\ Mouse\ Problem
5696 @endExample
5697
5698 @cindex @code{\~}, difference to @code{\@key{SP}}
5699 @cindex @code{\@key{SP}}, difference to @code{\~}
5700 @noindent
5701 The first line is the @code{uh} macro being called with 3 arguments,
5702 @samp{The}, @samp{Mouse}, and @samp{Problem}.  The latter two have the
5703 same effect of calling the @code{uh} macro with one argument, @samp{The
5704 Mouse Problem}.@footnote{The last solution, i.e., using escaped spaces,
5705 is ``classical'' in the sense that it can be found in most @code{troff}
5706 documents.  Nevertheless, it is not optimal in all situations, since
5707 @w{@samp{\ }} inserts a fixed-width, non-breaking space character that
5708 can't stretch.  @code{gtroff} provides a different command @code{\~} to
5709 insert a stretchable, non-breaking space.}
5710
5711 @cindex @code{"}, in a macro argument
5712 @cindex double quote, in a macro argument
5713 A double quote that isn't preceded by a space doesn't start a macro
5714 argument.  If not closing a string, it is printed literally.
5715
5716 For example,
5717
5718 @Example
5719 .xxx a" "b c" "de"fg"
5720 @endExample
5721
5722 @noindent
5723 has the arguments @samp{a"}, @w{@samp{b c}}, @samp{de}, and @samp{fg"}.
5724 Don't rely on this obscure behaviour!
5725
5726 There are two possibilities to get a double quote reliably.
5727
5728 @itemize @bullet
5729 @item
5730 Enclose the whole argument with double quotes and use two consecutive
5731 double quotes to represent a single one.  This traditional solution has
5732 the disadvantage that double quotes don't survive argument expansion
5733 again if called in compatibility mode (using the @option{-C} option of
5734 @code{groff}):
5735
5736 @Example
5737 .de xx
5738 .  tm xx: `\\$1' `\\$2' `\\$3'
5739 .
5740 .  yy "\\$1" "\\$2" "\\$3"
5741 ..
5742 .de yy
5743 .  tm yy: `\\$1' `\\$2' `\\$3'
5744 ..
5745 .xx A "test with ""quotes""" .
5746     @result{} xx: `A' `test with "quotes"' `.'
5747     @result{} yy: `A' `test with ' `quotes""'
5748 @endExample
5749
5750 @noindent
5751 If not in compatibility mode, you get the expected result
5752
5753 @Example
5754 xx: `A' `test with "quotes"' `.'
5755 yy: `A' `test with "quotes"' `.'
5756 @endExample
5757
5758 @noindent
5759 since @code{gtroff} preserves the input level.
5760
5761 @item
5762 Use the double quote glyph @code{\(dq}.  This works with and without
5763 compatibility mode enabled since @code{gtroff} doesn't convert
5764 @code{\(dq} back to a double quote input character.
5765
5766 Note that this method won't work with Unix @code{troff} in general since
5767 the glyph `dq' isn't defined normally.
5768 @end itemize
5769
5770 @cindex @code{ds} request, and double quotes
5771 Double quotes in the @code{ds} request are handled differently.
5772 @xref{Strings}, for more details.
5773
5774 @c ---------------------------------------------------------------------
5775
5776 @node Macros, Escapes, Requests, Embedded Commands
5777 @subsection Macros
5778 @cindex macros
5779
5780 @code{gtroff} has a @dfn{macro} facility for defining a series of lines
5781 that can be invoked by name.  They are called in the same manner as
5782 requests -- arguments also may be passed basically in the same manner.
5783
5784 @xref{Writing Macros}, and @ref{Request and Macro Arguments}.
5785
5786 @c ---------------------------------------------------------------------
5787
5788 @node Escapes,  , Macros, Embedded Commands
5789 @subsection Escapes
5790 @cindex escapes
5791
5792 Escapes may occur anywhere in the input to @code{gtroff}.  They usually
5793 begin with a backslash and are followed by a single character, which
5794 indicates the function to be performed.  The escape character can be
5795 changed; see @ref{Character Translations}.
5796
5797 Escape sequences that require an identifier as a parameter accept three
5798 possible syntax forms.
5799
5800 @itemize @bullet
5801 @item
5802 The next single character is the identifier.
5803
5804 @cindex @code{(}, starting a two-character identifier
5805 @item
5806 If this single character is an opening parenthesis, take the following
5807 two characters as the identifier.  Note that there is no closing
5808 parenthesis after the identifier.
5809
5810 @cindex @code{[}, starting an identifier
5811 @cindex @code{]}, ending an identifier
5812 @item
5813 If this single character is an opening bracket, take all characters
5814 until a closing bracket as the identifier.
5815 @end itemize
5816
5817 @noindent
5818 Examples:
5819
5820 @Example
5821 \fB
5822 \n(XX
5823 \*[TeX]
5824 @endExample
5825
5826 @cindex @code{'}, delimiting arguments
5827 @cindex argument delimiting characters
5828 @cindex characters, argument delimiting
5829 @cindex delimiting characters for arguments
5830 Other escapes may require several arguments and/or some special format.
5831 In such cases the argument is traditionally enclosed in single quotes
5832 (and quotes are always used in this manual for the definitions of escape
5833 sequences).  The enclosed text is then processed according to what that
5834 escape expects.  Example:
5835
5836 @Example
5837 \l'1.5i\(bu'
5838 @endExample
5839
5840 @cindex @code{\o}, possible quote characters
5841 @cindex @code{\b}, possible quote characters
5842 @cindex @code{\X}, possible quote characters
5843 Note that the quote character can be replaced with any other character
5844 that does not occur in the argument (even a newline or a space
5845 character) in the following escapes: @code{\o}, @code{\b}, and
5846 @code{\X}.  This makes e.g.
5847
5848 @Example
5849 A caf
5850 \o
5851 e\'
5852
5853
5854 in Paris
5855   @result{} A café in Paris
5856 @endExample
5857
5858 @noindent
5859 possible, but it is better not to use this feature to avoid confusion.
5860
5861 @cindex @code{\%}, used as delimiter
5862 @cindex @code{\@key{SP}}, used as delimiter
5863 @cindex @code{\|}, used as delimiter
5864 @cindex @code{\^}, used as delimiter
5865 @cindex @code{\@{}, used as delimiter
5866 @cindex @code{\@}}, used as delimiter
5867 @cindex @code{\'}, used as delimiter
5868 @cindex @code{\`}, used as delimiter
5869 @cindex @code{\-}, used as delimiter
5870 @cindex @code{\_}, used as delimiter
5871 @cindex @code{\!}, used as delimiter
5872 @cindex @code{\?}, used as delimiter
5873 @cindex @code{\)}, used as delimiter
5874 @cindex @code{\/}, used as delimiter
5875 @cindex @code{\,}, used as delimiter
5876 @cindex @code{\&}, used as delimiter
5877 @ifnotinfo
5878 @cindex @code{\:}, used as delimiter
5879 @end ifnotinfo
5880 @ifinfo
5881 @cindex @code{\@r{<colon>}}, used as delimiter
5882 @end ifinfo
5883 @cindex @code{\~}, used as delimiter
5884 @cindex @code{\0}, used as delimiter
5885 @cindex @code{\a}, used as delimiter
5886 @cindex @code{\c}, used as delimiter
5887 @cindex @code{\d}, used as delimiter
5888 @cindex @code{\e}, used as delimiter
5889 @cindex @code{\E}, used as delimiter
5890 @cindex @code{\p}, used as delimiter
5891 @cindex @code{\r}, used as delimiter
5892 @cindex @code{\t}, used as delimiter
5893 @cindex @code{\u}, used as delimiter
5894 The following escape sequences (which are handled similarly to
5895 characters since they don't take a parameter) are also allowed as
5896 delimiters: @code{\%}, @w{@samp{\ }}, @code{\|}, @code{\^}, @code{\@{},
5897 @code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
5898 @code{\?}, @code{\)}, @code{\/}, @code{\,}, @code{\&}, @code{\:},
5899 @code{\~}, @code{\0}, @code{\a}, @code{\c}, @code{\d}, @code{\e},
5900 @code{\E}, @code{\p}, @code{\r}, @code{\t}, and @code{\u}.  Again, don't
5901 use these if possible.
5902
5903 @cindex @code{\A}, allowed delimiters
5904 @cindex @code{\B}, allowed delimiters
5905 @cindex @code{\Z}, allowed delimiters
5906 @cindex @code{\C}, allowed delimiters
5907 @cindex @code{\w}, allowed delimiters
5908 No newline characters as delimiters are allowed in the following
5909 escapes: @code{\A}, @code{\B}, @code{\Z}, @code{\C}, and @code{\w}.
5910
5911 @cindex @code{\D}, allowed delimiters
5912 @cindex @code{\h}, allowed delimiters
5913 @cindex @code{\H}, allowed delimiters
5914 @cindex @code{\l}, allowed delimiters
5915 @cindex @code{\L}, allowed delimiters
5916 @cindex @code{\N}, allowed delimiters
5917 @cindex @code{\R}, allowed delimiters
5918 @cindex @code{\s}, allowed delimiters
5919 @cindex @code{\S}, allowed delimiters
5920 @cindex @code{\v}, allowed delimiters
5921 @cindex @code{\x}, allowed delimiters
5922 Finally, the escapes @code{\D}, @code{\h}, @code{\H}, @code{\l},
5923 @code{\L}, @code{\N}, @code{\R}, @code{\s}, @code{\S}, @code{\v}, and
5924 @code{\x} can't use the following characters as delimiters:
5925
5926 @itemize @bullet
5927 @item
5928 @cindex numbers, and delimiters
5929 @cindex digits, and delimiters
5930 The digits @code{0}-@code{9}.
5931
5932 @item
5933 @cindex operators, as delimiters
5934 @cindex @code{+}, as delimiter
5935 @cindex @code{-}, as delimiter
5936 @cindex @code{/}, as delimiter
5937 @cindex @code{*}, as delimiter
5938 @cindex @code{%}, as delimiter
5939 @cindex @code{<}, as delimiter
5940 @cindex @code{>}, as delimiter
5941 @cindex @code{=}, as delimiter
5942 @cindex @code{&}, as delimiter
5943 @ifnotinfo
5944 @cindex @code{:}, as delimiter
5945 @end ifnotinfo
5946 @ifinfo
5947 @cindex <colon>, as delimiter
5948 @end ifinfo
5949 @cindex @code{(}, as delimiter
5950 @cindex @code{)}, as delimiter
5951 @cindex @code{.}, as delimiter
5952 The (single-character) operators @samp{+-/*%<>=&:().}.
5953
5954 @item
5955 @cindex space character
5956 @cindex character, space
5957 @cindex tab character
5958 @cindex character, tab
5959 @cindex newline character
5960 @cindex character, newline
5961 The space, tab, and newline characters.
5962
5963 @item
5964 @cindex @code{\%}, used as delimiter
5965 @ifnotinfo
5966 @cindex @code{\:}, used as delimiter
5967 @end ifnotinfo
5968 @ifinfo
5969 @cindex @code{\@r{<colon>}}, used as delimiter
5970 @end ifinfo
5971 @cindex @code{\@{}, used as delimiter
5972 @cindex @code{\@}}, used as delimiter
5973 @cindex @code{\'}, used as delimiter
5974 @cindex @code{\`}, used as delimiter
5975 @cindex @code{\-}, used as delimiter
5976 @cindex @code{\_}, used as delimiter
5977 @cindex @code{\!}, used as delimiter
5978 @cindex @code{\/}, used as delimiter
5979 @cindex @code{\c}, used as delimiter
5980 @cindex @code{\e}, used as delimiter
5981 @cindex @code{\p}, used as delimiter
5982 All escape sequences except @code{\%}, @code{\:}, @code{\@{},
5983 @code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
5984 @code{\/}, @code{\c}, @code{\e}, and @code{\p}.
5985 @end itemize
5986
5987 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
5988 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
5989 To have a backslash (actually, the current escape character) appear in
5990 the output several escapes are defined: @code{\\}, @code{\e} or
5991 @code{\E}.  These are very similar, and only differ with respect to
5992 being used in macros or diversions.  @xref{Character Translations}, for
5993 an exact description of those escapes.
5994
5995 @xref{Implementation Differences}, @ref{Copy-in Mode}, and
5996 @ref{Diversions}, @ref{Identifiers}, for more information.
5997
5998 @menu
5999 * Comments::
6000 @end menu
6001
6002 @node Comments,  , Escapes, Escapes
6003 @subsubsection Comments
6004 @cindex comments
6005
6006 Probably one of the most@footnote{Unfortunately, this is a lie.  But
6007 hopefully future @code{gtroff} hackers will believe it @code{:-)}}
6008 common forms of escapes is the comment.
6009
6010 @Defesc {\\", , , }
6011 Start a comment.  Everything to the end of the input line is ignored.
6012
6013 This may sound simple, but it can be tricky to keep the comments from
6014 interfering with the appearance of the final output.
6015
6016 @cindex @code{ds}, @code{ds1} requests, and comments
6017 @cindex @code{as}, @code{as1} requests, and comments
6018 If the escape is to the right of some text or a request, that portion of
6019 the line is ignored, but the space leading up to it is noticed by
6020 @code{gtroff}.  This only affects the @code{ds} and @code{as} request
6021 and its variants.
6022
6023 @cindex tabs, before comments
6024 @cindex comments, lining up with tabs
6025 One possibly irritating idiosyncracy is that tabs must not be used to
6026 line up comments.  Tabs are not treated as whitespace between the
6027 request and macro arguments.
6028
6029 @cindex undefined request
6030 @cindex request, undefined
6031 A comment on a line by itself is treated as a blank line, because after
6032 eliminating the comment, that is all that remains:
6033
6034 @Example
6035 Test
6036 \" comment
6037 Test
6038 @endExample
6039
6040 @noindent
6041 produces
6042
6043 @Example
6044 Test
6045
6046 Test
6047 @endExample
6048
6049 To avoid this, it is common to start the line with @code{.\"}, which
6050 causes the line to be treated as an undefined request and thus ignored
6051 completely.
6052
6053 @cindex @code{'}, as a comment
6054 Another commenting scheme seen sometimes is three consecutive single
6055 quotes (@code{'''}) at the beginning of a line.  This works, but
6056 @code{gtroff} gives a warning about an undefined macro (namely
6057 @code{''}), which is harmless, but irritating.
6058 @endDefesc
6059
6060 @Defesc {\\#, , , }
6061 To avoid all this, @code{gtroff} has a new comment mechanism using the
6062 @code{\#} escape.  This escape works the same as @code{\"} except that
6063 the newline is also ignored:
6064
6065 @Example
6066 Test
6067 \# comment
6068 Test
6069 @endExample
6070
6071 @noindent
6072 produces
6073
6074 @Example
6075 Test Test
6076 @endExample
6077
6078 @noindent
6079 as expected.
6080 @endDefesc
6081
6082 @Defreq {ig, [@Var{end}]}
6083 Ignore all input until @code{gtroff} encounters the macro named
6084 @code{.}@var{end} on a line by itself (or @code{..} if @var{end} is not
6085 specified).  This is useful for commenting out large blocks of text:
6086
6087 @Example
6088 text text text...
6089 .ig
6090 This is part of a large block
6091 of text that has been
6092 temporarily(?) commented out.
6093
6094 We can restore it simply by removing
6095 the .ig request and the ".." at the
6096 end of the block.
6097 ..
6098 More text text text...
6099 @endExample
6100
6101 @noindent
6102 produces
6103
6104 @Example
6105 text text text@dots{}  More text text text@dots{}
6106 @endExample
6107
6108 @noindent
6109 Note that the commented-out block of text does not cause a break.
6110
6111 @cindex @code{ig} request, and copy-in mode
6112 @cindex copy-in mode, and @code{ig} request
6113 @cindex mode, copy-in, and @code{ig} request
6114 @cindex @code{ig} request, and auto-increment
6115 @cindex auto-increment, and @code{ig} request
6116 The input is read in copy-mode; auto-incremented registers @emph{are}
6117 affected (@pxref{Auto-increment}).
6118 @endDefreq
6119
6120
6121 @c =====================================================================
6122
6123 @node Registers, Manipulating Filling and Adjusting, Embedded Commands, gtroff Reference
6124 @section Registers
6125 @cindex registers
6126
6127 Numeric variables in @code{gtroff} are called @dfn{registers}.  There
6128 are a number of built-in registers, supplying anything from the date to
6129 details of formatting parameters.
6130
6131 @xref{Identifiers}, for details on register identifiers.
6132
6133 @menu
6134 * Setting Registers::
6135 * Interpolating Registers::
6136 * Auto-increment::
6137 * Assigning Formats::
6138 * Built-in Registers::
6139 @end menu
6140
6141 @c ---------------------------------------------------------------------
6142
6143 @node Setting Registers, Interpolating Registers, Registers, Registers
6144 @subsection Setting Registers
6145 @cindex setting registers (@code{nr}, @code{\R})
6146 @cindex registers, setting (@code{nr}, @code{\R})
6147
6148 Define or set registers using the @code{nr} request or the @code{\R}
6149 escape.
6150
6151 Although the following requests and escapes can be used to create
6152 registers, simply using an undefined register will cause it to be
6153 set to zero.
6154
6155 @DefreqList {nr, ident value}
6156 @DefescListEndx {\\R, ', ident value, '}
6157 Set number register @var{ident} to @var{value}.  If @var{ident} doesn't
6158 exist, @code{gtroff} creates it.
6159
6160 The argument to @code{\R} usually has to be enclosed in quotes.
6161 @xref{Escapes}, for details on parameter delimiting characters.
6162
6163 The @code{\R} escape doesn't produce an input token in @code{gtroff};
6164 in other words, it vanishes completely after @code{gtroff} has
6165 processed it.
6166
6167 For example, the following two lines are equivalent:
6168
6169 @Example
6170 .nr a (((17 + (3 * 4))) % 4)
6171 \R'a (((17 + (3 * 4))) % 4)'
6172     @result{} 1
6173 @endExample
6174
6175 Note that the complete transparency of @code{\R} can cause surprising
6176 effects if you use number registers like @code{.k}, which get evaluated
6177 at the time they are accessed.
6178
6179 @Example
6180 .ll 1.6i
6181 .
6182 aaa bbb ccc ddd eee fff ggg hhh\R':k \n[.k]'
6183 .tm :k == \n[:k]
6184     @result{} :k == 126950
6185 .
6186 .br
6187 .
6188 aaa bbb ccc ddd eee fff ggg hhh\h'0'\R':k \n[.k]'
6189 .tm :k == \n[:k]
6190     @result{} :k == 15000
6191 @endExample
6192
6193 If you process this with the @sc{PostScript} device (@code{-Tps}),
6194 there will be a line break eventually after @code{ggg} in both input
6195 lines.  However, after processing the space after @code{ggg}, the
6196 partially collected line is not overfull yet, so @code{troff}
6197 continues to collect input until it sees the space (or in this case,
6198 the newline) after @code{hhh}.  At this point, the line is longer
6199 than the line length, and the line gets broken.
6200
6201 In the first input line, since the @code{\R} escape leaves no traces,
6202 the check for the overfull line hasn't been done yet at the point where
6203 @code{\R} gets handled, and you get a value for the @code{.k} number
6204 register that is even greater than the current line length.
6205
6206 In the second input line, the insertion of @code{\h'0'} to emit an
6207 invisible zero-width space forces @code{troff} to check the line length,
6208 which in turn causes the start of a new output line.  Now @code{.k}
6209 returns the expected value.
6210 @endDefreq
6211
6212 Both @code{nr} and @code{\R} have two additional special forms to
6213 increment or decrement a register.
6214
6215 @DefreqList {nr, ident @t{+}@Var{value}}
6216 @DefreqItem {nr, ident @t{-}@Var{value}}
6217 @DefescItemx {\\R, ', ident @t{+}value, '}
6218 @DefescListEnd {\\R, ', ident @t{-}value, '}
6219 Increment (decrement) register @var{ident} by @var{value}.
6220
6221 @Example
6222 .nr a 1
6223 .nr a +1
6224 \na
6225     @result{} 2
6226 @endExample
6227
6228 @cindex negating register values
6229 To assign the negated value of a register to another register, some care
6230 must be taken to get the desired result:
6231
6232 @Example
6233 .nr a 7
6234 .nr b 3
6235 .nr a -\nb
6236 \na
6237     @result{} 4
6238 .nr a (-\nb)
6239 \na
6240     @result{} -3
6241 @endExample
6242
6243 @noindent
6244 The surrounding parentheses prevent the interpretation of the minus sign
6245 as a decrementing operator.  An alternative is to start the assignment
6246 with a @samp{0}:
6247
6248 @Example
6249 .nr a 7
6250 .nr b -3
6251 .nr a \nb
6252 \na
6253     @result{} 4
6254 .nr a 0\nb
6255 \na
6256     @result{} -3
6257 @endExample
6258 @endDefreq
6259
6260 @Defreq {rr, ident}
6261 @cindex removing number register (@code{rr})
6262 @cindex number register, removing (@code{rr})
6263 @cindex register, removing (@code{rr})
6264 Remove number register @var{ident}.  If @var{ident} doesn't exist, the
6265 request is ignored.
6266 @endDefreq
6267
6268 @Defreq {rnn, ident1 ident2}
6269 @cindex renaming number register (@code{rnn})
6270 @cindex number register, renaming (@code{rnn})
6271 @cindex register, renaming (@code{rnn})
6272 Rename number register @var{ident1} to @var{ident2}.  If either
6273 @var{ident1} or @var{ident2} doesn't exist, the request is ignored.
6274 @endDefreq
6275
6276 @Defreq {aln, ident1 ident2}
6277 @cindex alias, number register, creating (@code{aln})
6278 @cindex creating alias, for number register (@code{aln})
6279 @cindex number register, creating alias (@code{aln})
6280 @cindex register, creating alias (@code{aln})
6281 Create an alias @var{ident1} for a number register @var{ident2}.  The
6282 new name and the old name are exactly equivalent.  If @var{ident1} is
6283 undefined, a warning of type @samp{reg} is generated, and the request is
6284 ignored.  @xref{Debugging}, for information about warnings.
6285 @endDefreq
6286
6287 @c ---------------------------------------------------------------------
6288
6289 @node Interpolating Registers, Auto-increment, Setting Registers, Registers
6290 @subsection Interpolating Registers
6291 @cindex interpolating registers (@code{\n})
6292 @cindex registers, interpolating (@code{\n})
6293
6294 Numeric registers can be accessed via the @code{\n} escape.
6295
6296 @DefescList {\\n, , i, }
6297 @DefescItem {\\n, @Lparen{}, id, }
6298 @DefescListEnd {\\n, @Lbrack{}, ident, @Rbrack{}}
6299 @cindex nested assignments
6300 @cindex assignments, nested
6301 @cindex indirect assignments
6302 @cindex assignments, indirect
6303 Interpolate number register with name @var{ident} (one-character
6304 name@tie{}@var{i}, two-character name @var{id}).  This means that the
6305 value of the register is expanded in-place while @code{gtroff} is
6306 parsing the input line.  Nested assignments (also called indirect
6307 assignments) are possible.
6308
6309 @Example
6310 .nr a 5
6311 .nr as \na+\na
6312 \n(as
6313     @result{} 10
6314 @endExample
6315
6316 @Example
6317 .nr a1 5
6318 .nr ab 6
6319 .ds str b
6320 .ds num 1
6321 \n[a\n[num]]
6322     @result{} 5
6323 \n[a\*[str]]
6324     @result{} 6
6325 @endExample
6326 @endDefesc
6327
6328 @c ---------------------------------------------------------------------
6329
6330 @node Auto-increment, Assigning Formats, Interpolating Registers, Registers
6331 @subsection Auto-increment
6332 @cindex auto-increment
6333 @cindex increment, automatic
6334
6335 Number registers can also be auto-incremented and auto-decremented.  The
6336 increment or decrement value can be specified with a third argument to
6337 the @code{nr} request or @code{\R} escape.
6338
6339 @Defreq {nr, ident value incr}
6340 @cindex @code{\R}, difference to @code{nr}
6341 Set number register @var{ident} to @var{value}; the increment for
6342 auto-incrementing is set to @var{incr}.  Note that the @code{\R} escape
6343 doesn't support this notation.
6344 @endDefreq
6345
6346 To activate auto-incrementing, the escape @code{\n} has a special syntax
6347 form.
6348
6349 @DefescList {\\n, +, i, }
6350 @DefescItem {\\n, -, i, }
6351 @DefescItem {\\n, +@Lparen{}, id, }
6352 @DefescItem {\\n, -@Lparen{}, id, }
6353 @DefescItem {\\n, +@Lbrack{}, ident, @Rbrack{}}
6354 @DefescListEnd {\\n, -@Lbrack{}, ident, @Rbrack{}}
6355 Before interpolating, increment or decrement @var{ident} (one-character
6356 name@tie{}@var{i}, two-character name @var{id}) by the auto-increment
6357 value as specified with the @code{nr} request (or the @code{\R} escape).
6358 If no auto-increment value has been specified, these syntax forms are
6359 identical to @code{\n}.
6360 @endDefesc
6361
6362 For example,
6363
6364 @Example
6365 .nr a 0 1
6366 .nr xx 0 5
6367 .nr foo 0 -2
6368 \n+a, \n+a, \n+a, \n+a, \n+a
6369 .br
6370 \n-(xx, \n-(xx, \n-(xx, \n-(xx, \n-(xx
6371 .br
6372 \n+[foo], \n+[foo], \n+[foo], \n+[foo], \n+[foo]
6373 @endExample
6374
6375 @noindent
6376 produces
6377
6378 @Example
6379 1, 2, 3, 4, 5
6380 -5, -10, -15, -20, -25
6381 -2, -4, -6, -8, -10
6382 @endExample
6383
6384 @cindex increment value without changing the register
6385 @cindex value, incrementing without changing the register
6386 To change the increment value without changing the value of a register
6387 (@var{a} in the example), the following can be used:
6388
6389 @Example
6390 .nr a \na 10
6391 @endExample
6392
6393 @c ---------------------------------------------------------------------
6394
6395 @node Assigning Formats, Built-in Registers, Auto-increment, Registers
6396 @subsection Assigning Formats
6397 @cindex assigning formats (@code{af})
6398 @cindex formats, assigning (@code{af})
6399
6400 When a register is used, it is always textually replaced (or
6401 interpolated) with a representation of that number.  This output format
6402 can be changed to a variety of formats (numbers, Roman numerals, etc.).
6403 This is done using the @code{af} request.
6404
6405 @Defreq {af, ident format}
6406 Change the output format of a number register.  The first argument
6407 @var{ident} is the name of the number register to be changed, and the
6408 second argument @var{format} is the output format.  The following output
6409 formats are available:
6410
6411 @table @code
6412 @item 1
6413 Decimal arabic numbers.  This is the default format: 0, 1, 2,
6414 3,@tie{}@enddots{}
6415
6416 @item 0@dots{}0
6417 Decimal numbers with as many digits as specified.  So, @samp{00} would
6418 result in printing numbers as 01, 02, 03,@tie{}@enddots{}
6419
6420 In fact, any digit instead of zero does work; @code{gtroff} only counts
6421 how many digits are specified.  As a consequence, @code{af}'s default
6422 format @samp{1} could be specified as @samp{0} also (and exactly this is
6423 returned by the @code{\g} escape, see below).
6424
6425 @item I
6426 @cindex Roman numerals
6427 @cindex numerals, Roman
6428 Upper-case Roman numerals: 0, I, II, III, IV,@tie{}@enddots{}
6429
6430 @item i
6431 Lower-case Roman numerals: 0, i, ii, iii, iv,@tie{}@enddots{}
6432
6433 @item A
6434 Upper-case letters: 0, A, B, C, @dots{},@tie{}Z, AA, AB,@tie{}@enddots{}
6435
6436 @item a
6437 Lower-case letters: 0, a, b, c, @dots{},@tie{}z, aa, ab,@tie{}@enddots{}
6438 @end table
6439
6440 Omitting the number register format causes a warning of type
6441 @samp{missing}.  @xref{Debugging}, for more details.  Specifying a
6442 nonexistent format causes an error.
6443
6444 The following example produces @samp{10, X, j, 010}:
6445
6446 @Example
6447 .nr a 10
6448 .af a 1           \" the default format
6449 \na,
6450 .af a I
6451 \na,
6452 .af a a
6453 \na,
6454 .af a 001
6455 \na
6456 @endExample
6457
6458 @cindex Roman numerals, maximum and minimum
6459 @cindex maximum values of Roman numerals
6460 @cindex minimum values of Roman numerals
6461 The largest number representable for the @samp{i} and @samp{I} formats
6462 is 39999 (or @minus{}39999); Unix @code{troff} uses @samp{z} and
6463 @samp{w} to represent 10000 and 5000 in Roman numerals, and so does
6464 @code{gtroff}.  Currently, the correct glyphs of Roman numeral five
6465 thousand and Roman numeral ten thousand (Unicode code points
6466 @code{U+2182} and @code{U+2181}, respectively) are not available.
6467
6468 If @var{ident} doesn't exist, it is created.
6469
6470 @cindex read-only register, changing format
6471 @cindex changing format, and read-only registers
6472 Changing the output format of a read-only register causes an error.  It
6473 is necessary to first copy the register's value to a writeable register,
6474 then apply the @code{af} request to this other register.
6475 @endDefreq
6476
6477 @DefescList {\\g, , i, }
6478 @DefescItem {\\g, @Lparen{}, id, }
6479 @DefescListEnd {\\g, @Lbrack{}, ident, @Rbrack{}}
6480 @cindex format of register (@code{\g})
6481 @cindex register, format (@code{\g})
6482 Return the current format of the specified register @var{ident}
6483 (one-character name@tie{}@var{i}, two-character name @var{id}).  For
6484 example, @samp{\ga} after the previous example would produce the string
6485 @samp{000}.  If the register hasn't been defined yet, nothing is
6486 returned.
6487 @endDefesc
6488
6489 @c ---------------------------------------------------------------------
6490
6491 @node Built-in Registers,  , Assigning Formats, Registers
6492 @subsection Built-in Registers
6493 @cindex built-in registers
6494 @cindex registers, built-in
6495
6496 The following lists some built-in registers that are not described
6497 elsewhere in this manual.  Any register that begins with a @samp{.} is
6498 read-only.  A complete listing of all built-in registers can be found in
6499 @ref{Register Index}.
6500
6501 @table @code
6502 @item \n[.F]
6503 @cindex current input file name register (@code{.F})
6504 @cindex input file name, current, register (@code{.F})
6505 @vindex .F
6506 This string-valued register returns the current input file name.
6507
6508 @item \n[.H]
6509 @cindex horizontal resolution register (@code{.H})
6510 @cindex resolution, horizontal, register (@code{.H})
6511 @vindex .H
6512 Number of basic units per horizontal unit of output device resolution.
6513 @xref{Measurements}.
6514
6515 @item \n[.R]
6516 @cindex number of registers register (@code{.R})
6517 @cindex registers, number of, register (@code{.R})
6518 @vindex .R
6519 The number of number registers available.  This is always 10000 in
6520 GNU@tie{}@code{troff}; it exists for backward compatibility.
6521
6522 @item \n[.U]
6523 @cindex safer mode
6524 @cindex mode, safer
6525 @cindex unsafe mode
6526 @cindex mode, unsafe
6527 @vindex .U
6528 If @code{gtroff} is called with the @option{-U} command-line option to
6529 activate unsafe mode, the number register @code{.U} is set to@tie{}1,
6530 and to zero otherwise.  @xref{Groff Options}.
6531
6532 @item \n[.V]
6533 @cindex vertical resolution register (@code{.V})
6534 @cindex resolution, vertical, register (@code{.V})
6535 @vindex .V
6536 Number of basic units per vertical unit of output device resolution.
6537 @xref{Measurements}.
6538
6539 @item \n[seconds]
6540 @cindex seconds, current time (@code{seconds})
6541 @cindex time, current, seconds (@code{seconds})
6542 @cindex current time, seconds (@code{seconds})
6543 @vindex seconds
6544 The number of seconds after the minute, normally in the range@tie{}0
6545 to@tie{}59, but can be up to@tie{}61 to allow for leap seconds.
6546 Initialized at start-up of @code{gtroff}.
6547
6548 @item \n[minutes]
6549 @cindex minutes, current time (@code{minutes})
6550 @cindex time, current, minutes (@code{minutes})
6551 @cindex current time, minutes (@code{minutes})
6552 @vindex minutes
6553 The number of minutes after the hour, in the range@tie{}0 to@tie{}59.
6554 Initialized at start-up of @code{gtroff}.
6555
6556 @item \n[hours]
6557 @cindex hours, current time (@code{hours})
6558 @cindex time, current, hours (@code{hours})
6559 @cindex current time, hours (@code{hours})
6560 @vindex hours
6561 The number of hours past midnight, in the range@tie{}0 to@tie{}23.
6562 Initialized at start-up of @code{gtroff}.
6563
6564 @item \n[dw]
6565 @cindex day of the week register (@code{dw})
6566 @cindex date, day of the week register (@code{dw})
6567 @vindex dw
6568 Day of the week (1--7).
6569
6570 @item \n[dy]
6571 @cindex day of the month register (@code{dy})
6572 @cindex date, day of the month register (@code{dy})
6573 @vindex dy
6574 Day of the month (1--31).
6575
6576 @item \n[mo]
6577 @cindex month of the year register (@code{mo})
6578 @cindex date, month of the year register (@code{mo})
6579 @vindex mo
6580 Current month (1--12).
6581
6582 @item \n[year]
6583 @cindex date, year register (@code{year}, @code{yr})
6584 @cindex year, current, register (@code{year}, @code{yr})
6585 @vindex year
6586 The current year.
6587
6588 @item \n[yr]
6589 @vindex yr
6590 The current year minus@tie{}1900.  Unfortunately, the documentation of
6591 Unix Version@tie{}7's @code{troff} had a year@tie{}2000 bug: It
6592 incorrectly claimed that @code{yr} contains the last two digits of the
6593 year.  That claim has never been true of either @acronym{AT&T}
6594 @code{troff} or GNU @code{troff}.  Old @code{troff} input that looks
6595 like this:
6596
6597 @Example
6598 '\" The following line stopped working after 1999
6599 This document was formatted in 19\n(yr.
6600 @endExample
6601
6602 @noindent
6603 can be corrected as follows:
6604
6605 @Example
6606 This document was formatted in \n[year].
6607 @endExample
6608
6609 @noindent
6610 or, to be portable to older @code{troff} versions, as follows:
6611
6612 @Example
6613 .nr y4 1900+\n(yr
6614 This document was formatted in \n(y4.
6615 @endExample
6616
6617 @item \n[.c]
6618 @vindex .c
6619 @itemx \n[c.]
6620 @vindex c.
6621 @cindex input line number register (@code{.c}, @code{c.})
6622 @cindex line number, input, register (@code{.c}, @code{c.})
6623 The current @emph{input} line number.  Register @samp{.c} is read-only,
6624 whereas @samp{c.} (a @code{gtroff} extension) is writable also,
6625 affecting both @samp{.c} and @samp{c.}.
6626
6627 @item \n[ln]
6628 @vindex ln
6629 @cindex output line number register (@code{ln})
6630 @cindex line number, output, register (@code{ln})
6631 The current @emph{output} line number after a call to the @code{nm}
6632 request to activate line numbering.
6633
6634 @xref{Miscellaneous}, for more information about line numbering.
6635
6636 @item \n[.x]
6637 @vindex .x
6638 @cindex major version number register (@code{.x})
6639 @cindex version number, major, register (@code{.x})
6640 The major version number.  For example, if the version number is 1.03
6641 then @code{.x} contains@tie{}@samp{1}.
6642
6643 @item \n[.y]
6644 @vindex .y
6645 @cindex minor version number register (@code{.y})
6646 @cindex version number, minor, register (@code{.y})
6647 The minor version number.  For example, if the version number is 1.03
6648 then @code{.y} contains@tie{}@samp{03}.
6649
6650 @item \n[.Y]
6651 @vindex .Y
6652 @cindex revision number register (@code{.Y})
6653 The revision number of @code{groff}.
6654
6655 @item \n[$$]
6656 @vindex $$
6657 @cindex process ID of @code{gtroff} register (@code{$$})
6658 @cindex @code{gtroff}, process ID register (@code{$$})
6659 The process ID of @code{gtroff}.
6660
6661 @item \n[.g]
6662 @vindex .g
6663 @cindex @code{gtroff}, identification register (@code{.g})
6664 @cindex GNU-specific register (@code{.g})
6665 Always@tie{}1.  Macros should use this to determine whether they are
6666 running under GNU @code{troff}.
6667
6668 @item \n[.A]
6669 @vindex .A
6670 @cindex @acronym{ASCII} approximation output register (@code{.A})
6671 If the command-line option @option{-a} is used to produce an
6672 @acronym{ASCII} approximation of the output, this is set to@tie{}1, zero
6673 otherwise.  @xref{Groff Options}.
6674
6675 @item \n[.O]
6676 @vindex .O
6677 This read-only register is set to the suppression nesting level (see
6678 escapes @code{\O}).  @xref{Suppressing output}.
6679
6680 @item \n[.P]
6681 @vindex .P
6682 This register is set to@tie{}1 (and to@tie{}0 otherwise) if the current
6683 page is actually being printed, i.e., if the @option{-o} option is being
6684 used to only print selected pages.  @xref{Groff Options}, for more
6685 information.
6686
6687 @item \n[.T]
6688 @vindex .T
6689 If @code{gtroff} is called with the @option{-T} command-line option, the
6690 number register @code{.T} is set to@tie{}1, and zero otherwise.
6691 @xref{Groff Options}.
6692
6693 @item \*[.T]
6694 @stindex .T
6695 @cindex output device name string register (@code{.T})
6696 A single read-write string register that contains the current output
6697 device (for example, @samp{latin1} or @samp{ps}).  This is the only
6698 string register defined by @code{gtroff}.
6699 @end table
6700
6701
6702 @c =====================================================================
6703
6704 @node Manipulating Filling and Adjusting, Manipulating Hyphenation, Registers, gtroff Reference
6705 @section Manipulating Filling and Adjusting
6706 @cindex manipulating filling and adjusting
6707 @cindex filling and adjusting, manipulating
6708 @cindex adjusting and filling, manipulating
6709 @cindex justifying text
6710 @cindex text, justifying
6711
6712 @cindex break
6713 @cindex line break
6714 @cindex @code{bp} request, causing implicit linebreak
6715 @cindex @code{ce} request, causing implicit linebreak
6716 @cindex @code{cf} request, causing implicit linebreak
6717 @cindex @code{fi} request, causing implicit linebreak
6718 @cindex @code{fl} request, causing implicit linebreak
6719 @cindex @code{in} request, causing implicit linebreak
6720 @cindex @code{nf} request, causing implicit linebreak
6721 @cindex @code{rj} request, causing implicit linebreak
6722 @cindex @code{sp} request, causing implicit linebreak
6723 @cindex @code{ti} request, causing implicit linebreak
6724 @cindex @code{trf} request, causing implicit linebreak
6725 Various ways of causing @dfn{breaks} were given in @ref{Implicit Line
6726 Breaks}.  The @code{br} request likewise causes a break.  Several other
6727 requests also cause breaks, but implicitly.  These are @code{bp},
6728 @code{ce}, @code{cf}, @code{fi}, @code{fl}, @code{in}, @code{nf},
6729 @code{rj}, @code{sp}, @code{ti}, and @code{trf}.
6730
6731 @Defreq {br, }
6732 Break the current line, i.e., the input collected so far is emitted
6733 without adjustment.
6734
6735 If the no-break control character is used, @code{gtroff} suppresses the
6736 break:
6737
6738 @Example
6739 a
6740 'br
6741 b
6742     @result{} a b
6743 @endExample
6744 @endDefreq
6745
6746 Initially, @code{gtroff} fills and adjusts text to both margins.
6747 Filling can be disabled via the @code{nf} request and re-enabled with
6748 the @code{fi} request.
6749
6750 @DefreqList {fi, }
6751 @DefregListEndx {.u}
6752 @cindex fill mode (@code{fi})
6753 @cindex mode, fill (@code{fi})
6754 Activate fill mode (which is the default).  This request implicitly
6755 enables adjusting; it also inserts a break in the text currently being
6756 filled.  The read-only number register @code{.u} is set to@tie{}1.
6757
6758 The fill mode status is associated with the current environment
6759 (@pxref{Environments}).
6760
6761 See @ref{Line Control}, for interaction with the @code{\c} escape.
6762 @endDefreq
6763
6764 @Defreq {nf, }
6765 @cindex no-fill mode (@code{nf})
6766 @cindex mode, no-fill (@code{nf})
6767 Activate no-fill mode.  Input lines are output as-is, retaining line
6768 breaks and ignoring the current line length.  This command implicitly
6769 disables adjusting; it also causes a break.  The number register
6770 @code{.u} is set to@tie{}0.
6771
6772 The fill mode status is associated with the current environment
6773 (@pxref{Environments}).
6774
6775 See @ref{Line Control}, for interaction with the @code{\c} escape.
6776 @endDefreq
6777
6778 @DefreqList {ad, [@Var{mode}]}
6779 @DefregListEndx {.j}
6780 Set adjusting mode.
6781
6782 Activation and deactivation of adjusting is done implicitly with calls
6783 to the @code{fi} or @code{nf} requests.
6784
6785 @var{mode} can have one of the following values:
6786
6787 @table @code
6788 @item l
6789 @cindex ragged-right
6790 Adjust text to the left margin.  This produces what is traditionally
6791 called ragged-right text.
6792
6793 @item r
6794 @cindex ragged-left
6795 Adjust text to the right margin, producing ragged-left text.
6796
6797 @item c
6798 @cindex centered text
6799 @cindex @code{ce} request, difference to @samp{.ad@tie{}c}
6800 Center filled text.  This is different to the @code{ce} request, which
6801 only centers text without filling.
6802
6803 @item b
6804 @itemx n
6805 Justify to both margins.  This is the default used by @code{gtroff}.
6806 @end table
6807
6808 Finally, @var{mode} can be the numeric argument returned by the
6809 @code{.j} register.
6810
6811 Using @code{ad} without argument is the same as saying
6812 @w{@code{.ad \[.j]}}.  In particular, @code{gtroff} adjusts lines
6813 in the same way it did before adjusting was deactivated (with a call
6814 to @code{na}, say).  For example, this input code
6815
6816 @Example
6817 .de AD
6818 .  br
6819 .  ad \\$1
6820 ..
6821 .
6822 .de NA
6823 .  br
6824 .  na
6825 ..
6826 .
6827 textA
6828 .AD r
6829 .nr ad \n[.j]
6830 textB
6831 .AD c
6832 textC
6833 .NA
6834 textD
6835 .AD         \" back to centering
6836 textE
6837 .AD \n[ad]  \" back to right justifying
6838 textF
6839 @endExample
6840
6841 @noindent
6842 produces the following output:
6843
6844 @Example
6845 textA
6846                                                     textB
6847                           textC
6848 textD
6849                           textE
6850                                                     textF
6851 @endExample
6852
6853 @cindex adjustment mode register (@code{.j})
6854 As just demonstrated, the current adjustment mode is available in the
6855 read-only number register @code{.j}; it can be stored and
6856 subsequently used to set adjustment.
6857
6858 The adjustment mode status is associated with the current environment
6859 (@pxref{Environments}).
6860 @endDefreq
6861
6862 @Defreq {na, }
6863 Disable adjusting.  This request won't change the current adjustment
6864 mode: A subsequent call to @code{ad} uses the previous adjustment
6865 setting.
6866
6867 The adjustment mode status is associated with the current environment
6868 (@pxref{Environments}).
6869 @endDefreq
6870
6871 @DefreqList {brp, }
6872 @DefescListEndx {\\p, , , }
6873 Break, adjusting the current line per the current adjustment mode.
6874
6875 With @code{\p}, this break will happen at the next word boundary.  The
6876 @code{\p} itself is removed entirely, adding neither a break nor a space
6877 where it appears in input; it can thus be placed in the middle of a word
6878 to cause a break at the end of that word.
6879
6880 In most cases this produces very ugly results since @code{gtroff}
6881 doesn't have a sophisticated paragraph building algorithm (as @TeX{}
6882 has, for example); instead, @code{gtroff} fills and adjusts a paragraph
6883 line by line:
6884
6885 @Example
6886 This is an uninteresting sentence.
6887 This is an uninteresting sentence.\p
6888 This is an uninteresting sentence.
6889 @endExample
6890
6891 @noindent
6892 is formatted as
6893
6894 @Example
6895 This is  an uninteresting  sentence.   This  is an
6896 uninteresting                            sentence.
6897 This is an uninteresting sentence.
6898 @endExample
6899 @endDefreq
6900
6901 @DefreqList {ss, word_space_size [@Var{sentence_space_size}]}
6902 @DefregItemx {.ss}
6903 @DefregListEndx {.sss}
6904 @cindex word space size register (@code{.ss})
6905 @cindex size of word space register (@code{.ss})
6906 @cindex space between words register (@code{.ss})
6907 @cindex sentence space size register (@code{.sss})
6908 @cindex size of sentence space register (@code{.sss})
6909 @cindex space between sentences register (@code{.sss})
6910 Change the size of a space between words.  It takes its units as one
6911 twelfth of the space width parameter for the current font.  Initially
6912 both the @var{word_space_size} and @var{sentence_space_size}
6913 are@tie{}12.  In fill mode, the values specify the minimum distance.
6914
6915 @cindex fill mode
6916 @cindex mode, fill
6917 If two arguments are given to the @code{ss} request, the second argument
6918 sets the sentence space size.  If the second argument is not given,
6919 sentence space size is set to @var{word_space_size}.  The sentence space
6920 size is used in two circumstances: If the end of a sentence occurs at
6921 the end of a line in fill mode, then both an inter-word space and a
6922 sentence space are added; if two spaces follow the end of a sentence in
6923 the middle of a line, then the second space is a sentence space.  If a
6924 second argument is never given to the @code{ss} request, the behaviour
6925 of Unix @code{troff} is the same as that exhibited by GNU @code{troff}.
6926 In GNU @code{troff}, as in Unix @code{troff}, a sentence should always
6927 be followed by either a newline or two spaces.
6928
6929 The read-only number registers @code{.ss} and @code{.sss} hold the
6930 values of the parameters set by the first and second arguments of the
6931 @code{ss} request.
6932
6933 The word space and sentence space values are associated with the current
6934 environment (@pxref{Environments}).
6935
6936 Contrary to @acronym{AT&T} @code{troff}, this request is @emph{not}
6937 ignored if a TTY output device is used; the given values are then
6938 rounded down to a multiple of@tie{}12 (@pxref{Implementation
6939 Differences}).
6940
6941 The request is ignored if there is no parameter.
6942
6943 @cindex discardable horizontal space
6944 @cindex space, discardable, horizontal
6945 @cindex horizontal discardable space
6946 Another useful application of the @code{ss} request is to insert
6947 discardable horizontal space, i.e., space that is discarded at a line
6948 break.  For example, paragraph-style footnotes could be separated this
6949 way:
6950
6951 @Example
6952 .ll 4.5i
6953 1.\ This is the first footnote.\c
6954 .ss 48
6955 .nop
6956 .ss 12
6957 2.\ This is the second footnote.
6958 @endExample
6959
6960 @noindent
6961 The result:
6962
6963 @Example
6964 1. This is the first footnote.        2. This
6965 is the second footnote.
6966 @endExample
6967
6968 @noindent
6969 Note that the @code{\h} escape produces unbreakable space.
6970 @endDefreq
6971
6972 @DefreqList {ce, [@Var{nnn}]}
6973 @DefregListEndx {.ce}
6974 @cindex centering lines (@code{ce})
6975 @cindex lines, centering (@code{ce})
6976 Center text.  While the @w{@samp{.ad c}} request also centers text, it
6977 fills the text as well.  @code{ce} does not fill the text it affects.
6978 This request causes a break.  The number of lines still to be centered
6979 is associated with the current environment (@pxref{Environments}).
6980
6981 The following example demonstrates the differences.  Here is the input:
6982
6983 @Example
6984 .ll 4i
6985 .ce 1000
6986 This is a small text fragment that shows the differences
6987 between the `.ce' and the `.ad c' request.
6988 .ce 0
6989
6990 .ad c
6991 This is a small text fragment that shows the differences
6992 between the `.ce' and the `.ad c' request.
6993 @endExample
6994
6995 @noindent
6996 And here the result:
6997
6998 @Example
6999   This is a small text fragment that
7000          shows the differences
7001 between the `.ce' and the `.ad c' request.
7002
7003   This is a small text fragment that
7004 shows the differences between the `.ce'
7005         and the `.ad c' request.
7006 @endExample
7007
7008 With no arguments, @code{ce} centers the next line of text.  @var{nnn}
7009 specifies the number of lines to be centered.  If the argument is zero
7010 or negative, centering is disabled.
7011
7012 The basic length for centering text is the line length (as set with the
7013 @code{ll} request) minus the indentation (as set with the @code{in}
7014 request).  Temporary indentation is ignored.
7015
7016 As can be seen in the previous example, it is a common idiom to turn on
7017 centering for a large number of lines, and to turn off centering after
7018 text to be centered.  This is useful for any request that takes a
7019 number of lines as an argument.
7020
7021 The @code{.ce} read-only number register contains the number of lines
7022 remaining to be centered, as set by the @code{ce} request.
7023 @endDefreq
7024
7025 @DefreqList {rj, [@Var{nnn}]}
7026 @DefregListEndx {.rj}
7027 @cindex justifying text (@code{rj})
7028 @cindex text, justifying (@code{rj})
7029 @cindex right-justifying (@code{rj})
7030 Justify unfilled text to the right margin.  Arguments are identical to
7031 the @code{ce} request.  The @code{.rj} read-only number register is the
7032 number of lines to be right-justified as set by the @code{rj} request.
7033 This request causes a break.  The number of lines still to be
7034 right-justified is associated with the current environment
7035 (@pxref{Environments}).
7036 @endDefreq
7037
7038
7039 @c =====================================================================
7040
7041 @node Manipulating Hyphenation, Manipulating Spacing, Manipulating Filling and Adjusting, gtroff Reference
7042 @section Manipulating Hyphenation
7043 @cindex manipulating hyphenation
7044 @cindex hyphenation, manipulating
7045
7046 Here a description of requests that influence hyphenation.
7047
7048 @DefreqList {hy, [@Var{mode}]}
7049 @DefregListEndx {.hy}
7050 Enable hyphenation.  The request has an optional numeric argument,
7051 @var{mode}, to restrict hyphenation if necessary:
7052
7053 @table @code
7054 @item 1
7055 The default argument if @var{mode} is omitted: hyphenation is enabled,
7056 and the first and the last characters of a word are not hyphenated.
7057 This is also the start-up value of @code{gtroff}.
7058
7059 @item 2
7060 Do not hyphenate the last word on a page or column.
7061
7062 @item 4
7063 Do not hyphenate the last two characters of a word.
7064
7065 @item 8
7066 Do not hyphenate the first two characters of a word.
7067
7068 @item 16
7069 Allow hyphenation before the last character of a word.
7070
7071 @item 32
7072 Allow hyphenation after the first character of a word.
7073 @end table
7074
7075 The values in the previous table are additive.  For example,
7076 value@tie{}12 causes @code{gtroff} to neither hyphenate the last two nor
7077 the first two characters of a word.  Note that value@tie{}13 would do
7078 exactly the same; in other words, value@tie{}1 need not be added if the
7079 value is larger than@tie{}1.
7080
7081 Some values cannot be used together because they contradict; for
7082 instance, values 4 and@tie{}16, and values 8 and@tie{}32.
7083
7084 The number of characters at the beginning of a word after which the
7085 first hyphenation point should be inserted is determined by the patterns
7086 themselves; it can't be reduced further without introducing additional,
7087 invalid hyphenation points (unfortunately, this information is not part
7088 of a pattern file, you have to know it in advance).  The same is true
7089 for the number of characters at the end of word before the last
7090 hyphenation point should be inserted.  For example, the code
7091
7092 @Example
7093 .ll 1
7094 .hy 48
7095 splitting
7096 @endExample
7097
7098 returns
7099
7100 @Example
7101 s-
7102 plit-
7103 t-
7104 in-
7105 g
7106 @endExample
7107
7108 instead of the correct `split-ting'.  US-English patterns as distributed
7109 with groff need two characters at the beginning and three characters at
7110 the end; this means that value@tie{}4 of @code{hy} is mandatory.
7111 Value@tie{}8 is possible as an additional restriction, but values@tie{}1
7112 (the default!), 16, and@tie{}32 should be avoided.
7113
7114 Here is a table of left and right minimum values for hyphenation as needed
7115 by the patterns distributed with groff; see the @cite{groff_tmac(5) man
7116 page} (type @command{man groff_tmac} at the command line) for more
7117 information on groff's language macro files.
7118
7119 @multitable {German traditional}    {pattern name}    {left min}    {right min}
7120 @headitem    language           @tab pattern name @tab left min @tab right min
7121 @item        Czech              @tab cs           @tab 2        @tab 2
7122 @item        US English         @tab us           @tab 2        @tab 3
7123 @item        French             @tab fr           @tab 2        @tab 3
7124 @item        German traditional @tab det          @tab 2        @tab 2
7125 @item        German reformed    @tab den          @tab 2        @tab 2
7126 @item        Swedish            @tab sv           @tab 1        @tab 2
7127 @end multitable
7128
7129 Hyphenation exceptions within pattern files (i.e., the words within a
7130 @code{\hyphenation} group) also obey the hyphenation restrictions given
7131 by @code{hy}.  However, exceptions specified with the @code{hw} do not.
7132
7133 @cindex hyphenation restrictions register (@code{.hy})
7134 The current hyphenation restrictions can be found in the read-only
7135 number register @samp{.hy}.
7136
7137 The hyphenation mode is associated with the current environment
7138 (@pxref{Environments}).
7139 @endDefreq
7140
7141 @Defreq {nh, }
7142 Disable hyphenation (i.e., set the hyphenation mode to zero).  Note that
7143 the hyphenation mode of the last call to @code{hy} is not remembered.
7144
7145 The hyphenation mode is associated with the current environment
7146 (@pxref{Environments}).
7147 @endDefreq
7148
7149 @DefreqList {hlm, [@Var{nnn}]}
7150 @DefregItemx {.hlm}
7151 @DefregListEndx {.hlc}
7152 @cindex explicit hyphen (@code{\%})
7153 @cindex hyphen, explicit (@code{\%})
7154 @cindex consecutive hyphenated lines (@code{hlm})
7155 @cindex lines, consecutive hyphenated (@code{hlm})
7156 @cindex hyphenated lines, consecutive (@code{hlm})
7157 Set the maximum number of consecutive hyphenated lines to @var{nnn}.  If
7158 this number is negative, there is no maximum.  The default value
7159 is@tie{}@minus{}1 if @var{nnn} is omitted.  This value is associated
7160 with the current environment (@pxref{Environments}).  Only lines output
7161 from a given environment count towards the maximum associated with that
7162 environment.  Hyphens resulting from @code{\%} are counted; explicit
7163 hyphens are not.
7164
7165 The current setting of @code{hlm} is available in the @code{.hlm}
7166 read-only number register.  Also the number of immediately preceding
7167 consecutive hyphenated lines are available in the read-only number
7168 register @samp{.hlc}.
7169 @endDefreq
7170
7171 @Defreq {hw, word1 word2 @dots{}}
7172 Define how @var{word1}, @var{word2}, etc.@: are to be hyphenated.  The
7173 words must be given with hyphens at the hyphenation points.  For
7174 example:
7175
7176 @Example
7177 .hw in-sa-lub-rious
7178 @endExample
7179
7180 @noindent
7181 Besides the space character, any character whose hyphenation code value
7182 is zero can be used to separate the arguments of @code{hw} (see the
7183 documentation for the @code{hcode} request below for more information).
7184 In addition, this request can be used more than once.
7185
7186 @cindex @code{hw} request, and @code{hy} restrictions
7187 Hyphenation points specified with @code{hw} are not subject to the
7188 restrictions given by the @code{hy} request.
7189
7190 Hyphenation exceptions specified with the @code{hw} request are
7191 associated with the current hyphenation language; it causes an error if
7192 there is no current hyphenation language.
7193
7194 This request is ignored if there is no parameter.
7195
7196 In old versions of @code{troff} there was a limited amount of space to
7197 store such information; fortunately, with @code{gtroff}, this is no
7198 longer a restriction.
7199 @endDefreq
7200
7201 @DefescList {\\%, , , }
7202 @deffnx Escape @t{\:}
7203 @ifnotinfo
7204 @esindex \:
7205 @end ifnotinfo
7206 @ifinfo
7207 @esindex \@r{<colon>}
7208 @end ifinfo
7209 @cindex hyphenation character (@code{\%})
7210 @cindex character, hyphenation (@code{\%})
7211 @cindex disabling hyphenation (@code{\%})
7212 @cindex hyphenation, disabling (@code{\%})
7213 To tell @code{gtroff} how to hyphenate words on the fly, use the
7214 @code{\%} escape, also known as the @dfn{hyphenation character}.
7215 Preceding a word with this character prevents it from being
7216 hyphenated; putting it inside a word indicates to @code{gtroff} that
7217 the word may be hyphenated at that point.  Note that this mechanism
7218 only affects that one occurrence of the word; to change the
7219 hyphenation of a word for the entire document, use the @code{hw}
7220 request.
7221
7222 The @code{\:} escape inserts a zero-width break point (that is, the word
7223 breaks but without adding a hyphen).
7224
7225 @Example
7226 ... check the /var/log/\:httpd/\:access_log file ...
7227 @endExample
7228
7229 @cindex @code{\X}, followed by @code{\%}
7230 @cindex @code{\Y}, followed by @code{\%}
7231 @cindex @code{\%}, following @code{\X} or @code{\Y}
7232 Note that @code{\X} and @code{\Y} start a word, that is, the @code{\%}
7233 escape in (say) @w{@samp{\X'...'\%foobar}} and
7234 @w{@samp{\Y'...'\%foobar}} no longer prevents hyphenation but inserts a
7235 hyphenation point at the beginning of @samp{foobar}; most likely this
7236 isn't what you want to do.
7237 @endDefesc
7238
7239 @Defreq {hc, [@Var{char}]}
7240 Change the hyphenation character to @var{char}.  This character then
7241 works the same as the @code{\%} escape, and thus, no longer appears in
7242 the output.  Without an argument, @code{hc} resets the hyphenation
7243 character to be @code{\%} (the default) only.
7244
7245 The hyphenation character is associated with the current environment
7246 (@pxref{Environments}).
7247 @endDefreq
7248
7249 @DefreqList {hpf, pattern_file}
7250 @DefreqItemx {hpfa, pattern_file}
7251 @DefreqListEndx {hpfcode, a b [c d @dots{}]}
7252 @cindex hyphenation patterns (@code{hpf})
7253 @cindex patterns for hyphenation (@code{hpf})
7254 Read in a file of hyphenation patterns.  This file is searched for in
7255 the same way as @file{@var{name}.tmac} (or @file{tmac.@var{name}}) is
7256 searched for if the @option{-m@var{name}} option is specified.
7257
7258 It should have the same format as (simple) @TeX{} patterns files.  More
7259 specifically, the following scanning rules are implemented.
7260
7261 @itemize @bullet
7262 @item
7263 A percent sign starts a comment (up to the end of the line) even if
7264 preceded by a backslash.
7265
7266 @item
7267 No support for `digraphs' like @code{\$}.
7268
7269 @item
7270 @code{^^@var{xx}} (@var{x} is 0--9 or a--f) and @code{^^@var{x}}
7271 (character code of @var{x} in the range 0--127) are recognized; other use
7272 of @code{^} causes an error.
7273
7274 @item
7275 No macro expansion.
7276
7277 @item
7278 @code{hpf} checks for the expression @code{\patterns@{@dots{}@}}
7279 (possibly with whitespace before and after the braces).  Everything
7280 between the braces is taken as hyphenation patterns.  Consequently,
7281 @code{@{} and @code{@}} are not allowed in patterns.
7282
7283 @item
7284 Similarly, @code{\hyphenation@{@dots{}@}} gives a list of hyphenation
7285 exceptions.
7286
7287 @item
7288 @code{\endinput} is recognized also.
7289
7290 @item
7291 For backwards compatibility, if @code{\patterns} is missing, the whole
7292 file is treated as a list of hyphenation patterns (only recognizing the
7293 @code{%} character as the start of a comment).
7294 @end itemize
7295
7296 If no @code{hpf} request is specified (either in the document or in a
7297 macro package), @code{gtroff} won't hyphenate at all.
7298
7299 The @code{hpfa} request appends a file of patterns to the current list.
7300
7301 The @code{hpfcode} request defines mapping values for character codes in
7302 hyphenation patterns.  @code{hpf} or @code{hpfa} then apply the mapping
7303 (after reading the patterns) before replacing or appending them to the
7304 current list of patterns.  Its arguments are pairs of character codes --
7305 integers from 0 to@tie{}255.  The request maps character
7306 code@tie{}@var{a} to code@tie{}@var{b}, code@tie{}@var{c} to
7307 code@tie{}@var{d}, and so on.  You can use character codes that would
7308 be invalid otherwise.  By default, everything maps to itself except
7309 letters `A' to `Z', which map to `a' to `z'.
7310
7311
7312 @pindex troffrc
7313 @pindex troffrc-end
7314 @pindex hyphen.us
7315 @pindex hyphenex.us
7316 The set of hyphenation patterns is associated with the current language
7317 set by the @code{hla} request.  The @code{hpf} request is usually
7318 invoked by the @file{troffrc} or @file{troffrc-end} file; by default,
7319 @file{troffrc} loads hyphenation patterns and exceptions for American
7320 English (in files @file{hyphen.us} and @file{hyphenex.us}).
7321
7322 A second call to @code{hpf} (for the same language) replaces the
7323 hyphenation patterns with the new ones.
7324
7325 Invoking @code{hpf} causes an error if there is no current hyphenation
7326 language.
7327 @endDefreq
7328
7329 @Defreq {hcode, c1 code1 [c2 code2 @dots{}]}
7330 @cindex hyphenation code (@code{hcode})
7331 @cindex code, hyphenation (@code{hcode})
7332 Set the hyphenation code of character @var{c1} to @var{code1}, that of
7333 @var{c2} to @var{code2}, etc.  A hyphenation code must be a single input
7334 character (not a special character) other than a digit or a space.
7335
7336 To make hyphenation work, hyphenation codes must be set up.  At
7337 start-up, groff only assigns hyphenation codes to the letters
7338 @samp{a}--@samp{z} (mapped to themselves) and to the letters
7339 @samp{A}--@samp{Z} (mapped to @samp{a}--@samp{z}); all other hyphenation
7340 codes are set to zero.  Normally, hyphenation patterns contain only
7341 lowercase letters, which should be applied regardless of case.  In
7342 other words, the words `FOO' and `Foo' should be hyphenated exactly the
7343 same way as the word `foo' is hyphenated, and this is what @code{hcode}
7344 is good for.  Words that contain other letters won't be hyphenated
7345 properly if the corresponding hyphenation patterns actually do contain
7346 them.  For example, the following @code{hcode} requests are necessary to
7347 assign hyphenation codes to the letters @samp{ÄäÖöÜüß} (this is needed
7348 for German):
7349
7350 @Example
7351 .hcode Ã¤ Ã¤  Ã„ Ã¤
7352 .hcode Ã¶ Ã¶  Ã– Ã¶
7353 .hcode Ã¼ Ã¼  Ãœ Ã¼
7354 .hcode ÃŸ ÃŸ
7355 @endExample
7356
7357 Without those assignments, groff treats German words like
7358 @w{`Kindergärten'} (the plural form of `kindergarten') as two substrings
7359 @w{`kinderg'} and @w{`rten'} because the hyphenation code of the
7360 umlaut@tie{}a is zero by default.  There is a German hyphenation pattern
7361 that covers @w{`kinder'}, so groff finds the hyphenation `kin-der'.
7362 The other two hyphenation points (`kin-der-gär-ten') are missed.
7363
7364 This request is ignored if it has no parameter.
7365 @endDefreq
7366
7367 @DefreqList {hym, [@Var{length}]}
7368 @DefregListEndx {.hym}
7369 @cindex hyphenation margin (@code{hym})
7370 @cindex margin for hyphenation (@code{hym})
7371 @cindex @code{ad} request, and hyphenation margin
7372 Set the (right) hyphenation margin to @var{length}.  If the current
7373 adjustment mode is not @samp{b} or @samp{n}, the line is not hyphenated
7374 if it is shorter than @var{length}.  Without an argument, the
7375 hyphenation margin is reset to its default value, which is@tie{}0.  The
7376 default scaling indicator for this request is @samp{m}.  The hyphenation
7377 margin is associated with the current environment
7378 (@pxref{Environments}).
7379
7380 A negative argument resets the hyphenation margin to zero, emitting a
7381 warning of type @samp{range}.
7382
7383 @cindex hyphenation margin register (@code{.hym})
7384 The current hyphenation margin is available in the @code{.hym} read-only
7385 number register.
7386 @endDefreq
7387
7388 @DefreqList {hys, [@Var{hyphenation_space}]}
7389 @DefregListEndx {.hys}
7390 @cindex hyphenation space (@code{hys})
7391 @cindex @code{ad} request, and hyphenation space
7392 Set the hyphenation space to @var{hyphenation_space}.  If the current
7393 adjustment mode is @samp{b} or @samp{n}, don't hyphenate the line if it
7394 can be justified by adding no more than @var{hyphenation_space} extra
7395 space to each word space.  Without argument, the hyphenation space is
7396 set to its default value, which is@tie{}0.  The default scaling
7397 indicator for this request is @samp{m}.  The hyphenation space is
7398 associated with the current environment (@pxref{Environments}).
7399
7400 A negative argument resets the hyphenation space to zero, emitting a
7401 warning of type @samp{range}.
7402
7403 @cindex hyphenation space register (@code{.hys})
7404 The current hyphenation space is available in the @code{.hys} read-only
7405 number register.
7406 @endDefreq
7407
7408 @Defreq {shc, [@Var{glyph}]}
7409 @cindex soft hyphen character, setting (@code{shc})
7410 @cindex character, soft hyphen, setting (@code{shc})
7411 @cindex glyph, soft hyphen (@code{hy})
7412 @cindex soft hyphen glyph (@code{hy})
7413 @cindex @code{char} request, and soft hyphen character
7414 @cindex @code{tr} request, and soft hyphen character
7415 Set the @dfn{soft hyphen character} to @var{glyph}.@footnote{@dfn{Soft
7416 hyphen character} is a misnomer since it is an output glyph.}  If the
7417 argument is omitted, the soft hyphen character is set to the default
7418 glyph @code{\(hy} (this is the start-up value of @code{gtroff} also).
7419 The soft hyphen character is the glyph that is inserted when a word is
7420 hyphenated at a line break.  If the soft hyphen character does not exist
7421 in the font of the character immediately preceding a potential break
7422 point, then the line is not broken at that point.  Neither definitions
7423 (specified with the @code{char} request) nor translations (specified
7424 with the @code{tr} request) are considered when finding the soft hyphen
7425 character.
7426 @endDefreq
7427
7428 @DefreqList {hla, language}
7429 @DefregListEndx {.hla}
7430 @cindex @code{hpf} request, and hyphenation language
7431 @cindex @code{hw} request, and hyphenation language
7432 @pindex troffrc
7433 @pindex troffrc-end
7434 Set the current hyphenation language to the string @var{language}.
7435 Hyphenation exceptions specified with the @code{hw} request and
7436 hyphenation patterns specified with the @code{hpf} and @code{hpfa}
7437 requests are both associated with the current hyphenation language.  The
7438 @code{hla} request is usually invoked by the @file{troffrc} or the
7439 @file{troffrc-end} files; @file{troffrc} sets the default language to
7440 @samp{us}.
7441
7442 @cindex hyphenation language register (@code{.hla})
7443 The current hyphenation language is available as a string in the
7444 read-only number register @samp{.hla}.
7445
7446 @Example
7447 .ds curr_language \n[.hla]
7448 \*[curr_language]
7449     @result{} us
7450 @endExample
7451 @endDefreq
7452
7453
7454 @c =====================================================================
7455
7456 @node Manipulating Spacing, Tabs and Fields, Manipulating Hyphenation, gtroff Reference
7457 @section Manipulating Spacing
7458 @cindex manipulating spacing
7459 @cindex spacing, manipulating
7460
7461 @Defreq {sp, [@Var{distance}]}
7462 Space downwards @var{distance}.  With no argument it advances
7463 1@tie{}line.  A negative argument causes @code{gtroff} to move up the
7464 page the specified distance.  If the argument is preceded by a @samp{|}
7465 then @code{gtroff} moves that distance from the top of the page.  This
7466 request causes a line break, and that adds the current line spacing to
7467 the space you have just specified.  The default scaling indicator is
7468 @samp{v}.
7469
7470 For convenience you may wish to use the following macros to set the
7471 height of the next line at a given distance from the top or the bottom
7472 of the page:
7473
7474 @Example
7475 .de y-from-top-down
7476 .  sp |\\$1-\\n[.v]u
7477 ..
7478 .
7479 .de y-from-bot-up
7480 .  sp |\\n[.p]u-\\$1-\\n[.v]u
7481 ..
7482 @endExample
7483
7484 @noindent
7485 A call to @samp{.y-from-bot-up 10c} means that the bottom of the next
7486 line will be at 10@tie{}cm from the paper edge at the bottom.
7487
7488 If a vertical trap is sprung during execution of @code{sp}, the amount
7489 of vertical space after the trap is discarded.  For example, this
7490
7491 @Example
7492 .de xxx
7493 ..
7494 .
7495 .wh 0 xxx
7496 .
7497 .pl 5v
7498 foo
7499 .sp 2
7500 bar
7501 .sp 50
7502 baz
7503 @endExample
7504
7505 @noindent
7506 results in
7507
7508 @Example
7509 foo
7510
7511
7512 bar
7513
7514 baz
7515 @endExample
7516
7517 @cindex @code{sp} request, and traps
7518 @cindex discarded space in traps
7519 @cindex space, discarded, in traps
7520 @cindex traps, and discarded space
7521 The amount of discarded space is available in the number register
7522 @code{.trunc}.
7523
7524 To protect @code{sp} against vertical traps, use the @code{vpt} request:
7525
7526 @Example
7527 .vpt 0
7528 .sp -3
7529 .vpt 1
7530 @endExample
7531 @endDefreq
7532
7533 @DefreqList {ls, [@Var{nnn}]}
7534 @DefregListEndx {.L}
7535 @cindex double-spacing (@code{ls})
7536 Output @w{@var{nnn}@minus{}1} blank lines after each line of text.  With
7537 no argument, @code{gtroff} uses the previous value before the last
7538 @code{ls} call.
7539
7540 @Example
7541 .ls 2    \" This causes double-spaced output
7542 .ls 3    \" This causes triple-spaced output
7543 .ls      \" Again double-spaced
7544 @endExample
7545
7546 The line spacing is associated with the current environment
7547 (@pxref{Environments}).
7548
7549 @cindex line spacing register (@code{.L})
7550 The read-only number register @code{.L} contains the current line
7551 spacing setting.
7552 @endDefreq
7553
7554 @xref{Changing Type Sizes}, for the requests @code{vs} and @code{pvs} as
7555 alternatives to @code{ls}.
7556
7557 @DefescList {\\x, ', spacing, '}
7558 @DefregListEndx {.a}
7559 Sometimes, extra vertical spacing is only needed occasionally, e.g.@: to
7560 allow space for a tall construct (like an equation).  The @code{\x}
7561 escape does this.  The escape is given a numerical argument, usually
7562 enclosed in quotes (like @samp{\x'3p'}); the default scaling indicator
7563 is @samp{v}.  If this number is positive extra vertical space is
7564 inserted below the current line.  A negative number adds space above.
7565 If this escape is used multiple times on the same line, the maximum of
7566 the values is used.
7567
7568 @xref{Escapes}, for details on parameter delimiting characters.
7569
7570 @cindex extra post-vertical line space register (@code{.a})
7571 The @code{.a} read-only number register contains the most recent
7572 (non-negative) extra vertical line space.
7573
7574 Using @code{\x} can be necessary in combination with the @code{\b}
7575 escape, as the following example shows.
7576
7577 @Example
7578 This is a test with the \[rs]b escape.
7579 .br
7580 This is a test with the \[rs]b escape.
7581 .br
7582 This is a test with \b'xyz'\x'-1m'\x'1m'.
7583 .br
7584 This is a test with the \[rs]b escape.
7585 .br
7586 This is a test with the \[rs]b escape.
7587 @endExample
7588
7589 @noindent
7590 produces
7591
7592 @Example
7593 This is a test with the \b escape.
7594 This is a test with the \b escape.
7595                     x
7596 This is a test with y.
7597                     z
7598 This is a test with the \b escape.
7599 This is a test with the \b escape.
7600 @endExample
7601 @endDefesc
7602
7603 @DefreqList {ns, }
7604 @DefreqItemx {rs, }
7605 @DefregListEndx {.ns}
7606 @cindex @code{sp} request, and no-space mode
7607 @cindex no-space mode (@code{ns})
7608 @cindex mode, no-space (@code{ns})
7609 @cindex blank lines, disabling
7610 @cindex lines, blank, disabling
7611 Enable @dfn{no-space mode}.  In this mode, spacing (either via @code{sp}
7612 or via blank lines) is disabled.  The @code{bp} request to advance to
7613 the next page is also disabled, except if it is accompanied by a page
7614 number (see @ref{Page Control}, for more information).  This mode ends
7615 when actual text is output or the @code{rs} request is encountered, which
7616 ends no-space mode.  The read-only number register @code{.ns} is set
7617 to@tie{}1 as long as no-space mode is active.
7618
7619 This request is useful for macros that conditionally insert vertical
7620 space before the text starts (for example, a paragraph macro could
7621 insert some space except when it is the first paragraph after a section
7622 header).
7623 @endDefreq
7624
7625
7626 @c =====================================================================
7627
7628 @node Tabs and Fields, Character Translations, Manipulating Spacing, gtroff Reference
7629 @section Tabs and Fields
7630 @cindex tabs, and fields
7631 @cindex fields, and tabs
7632
7633 @cindex @acronym{EBCDIC} encoding of a tab
7634 A tab character (@acronym{ASCII} char@tie{}9, @acronym{EBCDIC}
7635 char@tie{}5) causes a horizontal movement to the next tab stop (much
7636 like it did on a typewriter).
7637
7638 @Defesc {\\t, , , }
7639 @cindex tab character, non-interpreted (@code{\t})
7640 @cindex character, tab, non-interpreted (@code{\t})
7641 @cindex @code{\t}, and copy-in mode
7642 @cindex copy-in mode, and @code{\t}
7643 @cindex mode, copy-in, and @code{\t}
7644 This escape is a non-interpreted tab character.  In copy mode
7645 (@pxref{Copy-in Mode}), @code{\t} is the same as a real tab character.
7646 @endDefesc
7647
7648 @DefreqList {ta, [@Var{n1} @Var{n2} @dots{} @Var{nn} @t{T} @Var{r1} @Var{r2} @dots{} @Var{rn}]}
7649 @DefregListEndx {.tabs}
7650 Change tab stop positions.  This request takes a series of tab
7651 specifiers as arguments (optionally divided into two groups with the
7652 letter @samp{T}) that indicate where each tab stop is to be (overriding
7653 any previous settings).
7654
7655 Tab stops can be specified absolutely, i.e., as the distance from the
7656 left margin.  For example, the following sets 6@tie{}tab stops every one
7657 inch.
7658
7659 @Example
7660 .ta 1i 2i 3i 4i 5i 6i
7661 @endExample
7662
7663 Tab stops can also be specified using a leading @samp{+}, which means
7664 that the specified tab stop is set relative to the previous tab stop.
7665 For example, the following is equivalent to the previous example.
7666
7667 @Example
7668 .ta 1i +1i +1i +1i +1i +1i
7669 @endExample
7670
7671 @code{gtroff} supports an extended syntax to specify repeat values after
7672 the @samp{T} mark (these values are always taken as relative) -- this is
7673 the usual way to specify tabs set at equal intervals.  The following is,
7674 yet again, the same as the previous examples.  It does even more since
7675 it defines an infinite number of tab stops separated by one inch.
7676
7677 @Example
7678 .ta T 1i
7679 @endExample
7680
7681 Now we are ready to interpret the full syntax given at the beginning:
7682 Set tabs at positions @var{n1}, @var{n2}, @dots{}, @var{nn} and then set
7683 tabs at @var{nn}+@var{r1}, @var{nn}+@var{r2}, @dots{}, @var{nn}+@var{rn}
7684 and then at @var{nn}+@var{rn}+@var{r1}, @var{nn}+@var{rn}+@var{r2},
7685 @dots{}, @var{nn}+@var{rn}+@var{rn}, and so on.
7686
7687 Example: @samp{4c +6c T 3c 5c 2c} is equivalent to @samp{4c 10c 13c 18c
7688 20c 23c 28c 30c @dots{}}.
7689
7690 The material in each tab column (i.e., the column between two tab stops)
7691 may be justified to the right or left or centered in the column.  This
7692 is specified by appending @samp{R}, @samp{L}, or @samp{C} to the tab
7693 specifier.  The default justification is @samp{L}.  Example:
7694
7695 @Example
7696 .ta 1i 2iC 3iR
7697 @endExample
7698
7699 Some notes:
7700
7701 @itemize @bullet
7702 @item
7703 The default unit of the @code{ta} request is @samp{m}.
7704
7705 @item
7706 A tab stop is converted into a non-breakable horizontal movement that
7707 can be neither stretched nor squeezed.  For example,
7708
7709 @Example
7710 .ds foo a\tb\tc
7711 .ta T 5i
7712 \*[foo]
7713 @endExample
7714
7715 @noindent
7716 creates a single line, which is a bit longer than 10@tie{}inches (a
7717 string is used to show exactly where the tab characters are).  Now
7718 consider the following:
7719
7720 @Example
7721 .ds bar a\tb b\tc
7722 .ta T 5i
7723 \*[bar]
7724 @endExample
7725
7726 @noindent
7727 @code{gtroff} first converts the tab stops of the line into unbreakable
7728 horizontal movements, then splits the line after the second @samp{b}
7729 (assuming a sufficiently short line length).  Usually, this isn't what
7730 the user wants.
7731
7732 @item
7733 Superfluous tabs (i.e., tab characters that do not correspond to a tab
7734 stop) are ignored except the first one, which delimits the characters
7735 belonging to the last tab stop for right-justifying or centering.
7736 Consider the following example
7737
7738 @Example
7739 .ds Z   foo\tbar\tfoo
7740 .ds ZZ  foo\tbar\tfoobar
7741 .ds ZZZ foo\tbar\tfoo\tbar
7742 .ta 2i 4iR
7743 \*[Z]
7744 .br
7745 \*[ZZ]
7746 .br
7747 \*[ZZZ]
7748 .br
7749 @endExample
7750
7751 @noindent
7752 which produces the following output:
7753
7754 @Example
7755 foo                 bar              foo
7756 foo                 bar           foobar
7757 foo                 bar              foobar
7758 @endExample
7759
7760 @noindent
7761 The first line right-justifies the second `foo' relative to the tab
7762 stop.  The second line right-justifies `foobar'.  The third line finally
7763 right-justifies only `foo' because of the additional tab character, which
7764 marks the end of the string belonging to the last defined tab stop.
7765
7766 @item
7767 Tab stops are associated with the current environment
7768 (@pxref{Environments}).
7769
7770 @item
7771 Calling @code{ta} without an argument removes all tab stops.
7772
7773 @item
7774 @cindex tab stops, for TTY output devices
7775 The start-up value of @code{gtroff} is @w{@samp{T 0.5i}}.
7776 @end itemize
7777
7778 @cindex tab settings register (@code{.tabs})
7779 The read-only number register @code{.tabs} contains a string
7780 representation of the current tab settings suitable for use as an
7781 argument to the @code{ta} request.
7782
7783 @Example
7784 .ds tab-string \n[.tabs]
7785 \*[tab-string]
7786     @result{} T120u
7787 @endExample
7788
7789 @cindex @code{.S} register, Plan@tie{}9 alias for @code{.tabs}
7790 @cindex @code{.tabs} register, Plan@tie{}9 alias (@code{.S})
7791 The @code{troff} version of the Plan@tie{}9 operating system uses
7792 register @code{.S} for the same purpose.
7793 @endDefreq
7794
7795 @Defreq {tc, [@Var{fill-glyph}]}
7796 @cindex tab repetition character (@code{tc})
7797 @cindex character, tab repetition (@code{tc})
7798 @cindex glyph, tab repetition (@code{tc})
7799 Normally @code{gtroff} fills the space to the next tab stop with
7800 whitespace.  This can be changed with the @code{tc} request.  With no
7801 argument @code{gtroff} reverts to using whitespace, which is the
7802 default.  The value of this @dfn{tab repetition character} is associated
7803 with the current environment (@pxref{Environments}).@footnote{@dfn{Tab
7804 repetition character} is a misnomer since it is an output glyph.}
7805 @endDefreq
7806
7807 @DefreqList {linetabs, n}
7808 @DefregListEndx {.linetabs}
7809 @cindex tab, line-tabs mode
7810 @cindex line-tabs mode
7811 @cindex mode, line-tabs
7812 If @var{n} is missing or not zero, enable @dfn{line-tabs} mode, or
7813 disable it otherwise (the default).  In line-tabs mode, @code{gtroff}
7814 computes tab distances relative to the (current) output line instead of
7815 the input line.
7816
7817 For example, the following code:
7818
7819 @Example
7820 .ds x a\t\c
7821 .ds y b\t\c
7822 .ds z c
7823 .ta 1i 3i
7824 \*x
7825 \*y
7826 \*z
7827 @endExample
7828
7829 @noindent
7830 in normal mode, results in the output
7831
7832 @Example
7833 a         b         c
7834 @endExample
7835
7836 @noindent
7837 in line-tabs mode, the same code outputs
7838
7839 @Example
7840 a         b                   c
7841 @endExample
7842
7843 Line-tabs mode is associated with the current environment.  The
7844 read-only register @code{.linetabs} is set to@tie{}1 if in line-tabs
7845 mode, and 0 in normal mode.
7846 @endDefreq
7847
7848 @menu
7849 * Leaders::
7850 * Fields::
7851 @end menu
7852
7853 @c ---------------------------------------------------------------------
7854
7855 @node Leaders, Fields, Tabs and Fields, Tabs and Fields
7856 @subsection Leaders
7857 @cindex leaders
7858
7859 Sometimes it may be desirable to use the @code{tc} request to fill a
7860 particular tab stop with a given glyph (for example dots in a table of
7861 contents), but also normal tab stops on the rest of the line.
7862 For this @code{gtroff} provides an alternate tab mechanism, called
7863 @dfn{leaders}, which does just that.
7864
7865 @cindex leader character
7866 A leader character (character code@tie{}1) behaves similarly to a tab
7867 character: It moves to the next tab stop.  The only difference is that
7868 for this movement, the fill glyph defaults to a period character and not
7869 to space.
7870
7871 @Defesc {\\a, , , }
7872 @cindex leader character, non-interpreted (@code{\a})
7873 @cindex character, leader, non-interpreted (@code{\a})
7874 @cindex @code{\a}, and copy-in mode
7875 @cindex copy-in mode, and @code{\a}
7876 @cindex mode, copy-in, and @code{\a}
7877 This escape is a non-interpreted leader character.  In copy mode
7878 (@pxref{Copy-in Mode}), @code{\a} is the same as a real leader
7879 character.
7880 @endDefesc
7881
7882 @Defreq {lc, [@Var{fill-glyph}]}
7883 @cindex leader repetition character (@code{lc})
7884 @cindex character, leader repetition (@code{lc})
7885 @cindex glyph, leader repetition (@code{lc})
7886 Declare the @dfn{leader repetition character}.@footnote{@dfn{Leader
7887 repetition character} is a misnomer since it is an output glyph.}
7888 Without an argument, leaders act the same as tabs (i.e., using
7889 whitespace for filling).  @code{gtroff}'s start-up value is a dot
7890 (@samp{.}).  The value of the leader repetition character is associated
7891 with the current environment (@pxref{Environments}).
7892 @endDefreq
7893
7894 @cindex table of contents
7895 @cindex contents, table of
7896 For a table of contents, to name an example, tab stops may be defined so
7897 that the section number is one tab stop, the title is the second with
7898 the remaining space being filled with a line of dots, and then the page
7899 number slightly separated from the dots.
7900
7901 @Example
7902 .ds entry 1.1\tFoo\a\t12
7903 .lc .
7904 .ta 1i 5i +.25i
7905 \*[entry]
7906 @endExample
7907
7908 @noindent
7909 This produces
7910
7911 @Example
7912 1.1  Foo..........................................  12
7913 @endExample
7914
7915 @c ---------------------------------------------------------------------
7916
7917 @node Fields,  , Leaders, Tabs and Fields
7918 @subsection Fields
7919 @cindex fields
7920
7921 @cindex field delimiting character (@code{fc})
7922 @cindex delimiting character, for fields (@code{fc})
7923 @cindex character, field delimiting (@code{fc})
7924 @cindex field padding character (@code{fc})
7925 @cindex padding character, for fields (@code{fc})
7926 @cindex character, field padding (@code{fc})
7927 @dfn{Fields} are a more general way of laying out tabular data.  A field
7928 is defined as the data between a pair of @dfn{delimiting characters}.
7929 It contains substrings that are separated by @dfn{padding characters}.
7930 The width of a field is the distance on the @emph{input} line from the
7931 position where the field starts to the next tab stop.  A padding
7932 character inserts stretchable space similar to @TeX{}'s @code{\hss}
7933 command (thus it can even be negative) to make the sum of all substring
7934 lengths plus the stretchable space equal to the field width.  If more
7935 than one padding character is inserted, the available space is evenly
7936 distributed among them.
7937
7938 @Defreq {fc, [@Var{delim-char} [@Var{padding-char}]]}
7939 Define a delimiting and a padding character for fields.  If the latter
7940 is missing, the padding character defaults to a space character.  If
7941 there is no argument at all, the field mechanism is disabled (which is
7942 the default).  Note that contrary to e.g.@: the tab repetition
7943 character, delimiting and padding characters are @emph{not} associated
7944 to the current environment (@pxref{Environments}).
7945
7946 Example:
7947
7948 @Example
7949 .fc # ^
7950 .ta T 3i
7951 #foo^bar^smurf#
7952 .br
7953 #foo^^bar^smurf#
7954 @endExample
7955
7956 @noindent
7957 and here the result:
7958
7959 @Example
7960 foo         bar          smurf
7961 foo            bar       smurf
7962 @endExample
7963 @endDefreq
7964
7965
7966 @c =====================================================================
7967
7968 @node Character Translations, Troff and Nroff Mode, Tabs and Fields, gtroff Reference
7969 @section Character Translations
7970 @cindex character translations
7971 @cindex translations of characters
7972
7973 @cindex control character, changing (@code{cc})
7974 @cindex character, control, changing (@code{cc})
7975 @cindex no-break control character, changing (@code{c2})
7976 @cindex character, no-break control, changing (@code{c2})
7977 @cindex control character, no-break, changing (@code{c2})
7978 The control character (@samp{.}) and the no-break control character
7979 (@samp{'}) can be changed with the @code{cc} and @code{c2} requests,
7980 respectively.
7981
7982 @Defreq {cc, [@Var{c}]}
7983 Set the control character to@tie{}@var{c}.  With no argument the default
7984 control character @samp{.} is restored.  The value of the control
7985 character is associated with the current environment
7986 (@pxref{Environments}).
7987 @endDefreq
7988
7989 @Defreq {c2, [@Var{c}]}
7990 Set the no-break control character to@tie{}@var{c}.  With no argument
7991 the default control character @samp{'} is restored.  The value of the
7992 no-break control character is associated with the current environment
7993 (@pxref{Environments}).
7994 @endDefreq
7995
7996 @xref{Requests}.
7997
7998 @Defreq {eo, }
7999 @cindex disabling @code{\} (@code{eo})
8000 @cindex @code{\}, disabling (@code{eo})
8001 Disable the escape mechanism completely.  After executing this request,
8002 the backslash character @samp{\} no longer starts an escape sequence.
8003
8004 This request can be very helpful in writing macros since it is not
8005 necessary then to double the escape character.  Here an example:
8006
8007 @Example
8008 .\" This is a simplified version of the
8009 .\" .BR request from the man macro package
8010 .eo
8011 .de BR
8012 .  ds result \&
8013 .  while (\n[.$] >= 2) \@{\
8014 .    as result \fB\$1\fR\$2
8015 .    shift 2
8016 .  \@}
8017 .  if \n[.$] .as result \fB\$1
8018 \*[result]
8019 .  ft R
8020 ..
8021 .ec
8022 @endExample
8023 @endDefreq
8024
8025 @Defreq {ec, [@Var{c}]}
8026 @cindex escape character, changing (@code{ec})
8027 @cindex character, escape, changing (@code{ec})
8028 Set the escape character to@tie{}@var{c}.  With no argument the default
8029 escape character @samp{\} is restored.  It can be also used to re-enable
8030 the escape mechanism after an @code{eo} request.
8031
8032 Note that changing the escape character globally likely breaks macro
8033 packages since @code{gtroff} has no mechanism to `intern' macros, i.e.,
8034 to convert a macro definition into an internal form that is independent
8035 of its representation (@TeX{} has this mechanism).  If a macro is
8036 called, it is executed literally.
8037 @endDefreq
8038
8039 @DefreqList {ecs, }
8040 @DefreqListEndx {ecr, }
8041 The @code{ecs} request saves the current escape character in an internal
8042 register.  Use this request in combination with the @code{ec} request to
8043 temporarily change the escape character.
8044
8045 The @code{ecr} request restores the escape character saved with
8046 @code{ecs}.  Without a previous call to @code{ecs}, this request sets
8047 the escape character to @code{\}.
8048 @endDefreq
8049
8050 @DefescList {\\\\, , , }
8051 @DefescItemx {\\e, , , }
8052 @DefescListEndx {\\E, , , }
8053 Print the current escape character (which is the backslash character
8054 @samp{\} by default).
8055
8056 @code{\\} is a `delayed' backslash; more precisely, it is the default
8057 escape character followed by a backslash, which no longer has special
8058 meaning due to the leading escape character.  It is @emph{not} an escape
8059 sequence in the usual sense!  In any unknown escape sequence
8060 @code{\@var{X}} the escape character is ignored and @var{X} is printed.
8061 But if @var{X} is equal to the current escape character, no warning is
8062 emitted.
8063
8064 @cindex @code{\E}, and copy-in mode
8065 @cindex copy-in mode, and @code{\E}
8066 @cindex mode, copy-in, and @code{\E}
8067 As a consequence, only at top-level or in a diversion a backslash glyph
8068 is printed; in copy-in mode, it expands to a single backslash, which then
8069 combines with the following character to an escape sequence.
8070
8071 The @code{\E} escape differs from @code{\e} by printing an escape
8072 character that is not interpreted in copy mode.  Use this to define
8073 strings with escapes that work when used in copy mode (for example, as a
8074 macro argument).  The following example defines strings to begin and end
8075 a superscript:
8076
8077 @Example
8078 .ds @{ \v'-.3m'\s'\En[.s]*60/100'
8079 .ds @} \s0\v'.3m'
8080 @endExample
8081
8082 Another example to demonstrate the differences between the various
8083 escape sequences, using a strange escape character, @samp{-}.
8084
8085 @Example
8086 .ec -
8087 .de xxx
8088 --A'foo'
8089 ..
8090 .xxx
8091     @result{} -A'foo'
8092 @endExample
8093
8094 @noindent
8095 The result is surprising for most users, expecting @samp{1} since
8096 @samp{foo} is a valid identifier.  What has happened?  As mentioned
8097 above, the leading escape character makes the following character
8098 ordinary.  Written with the default escape character the sequence
8099 @samp{--} becomes @samp{\-} -- this is the minus sign.
8100
8101 If the escape character followed by itself is a valid escape sequence,
8102 only @code{\E} yields the expected result:
8103
8104 @Example
8105 .ec -
8106 .de xxx
8107 -EA'foo'
8108 ..
8109 .xxx
8110     @result{} 1
8111 @endExample
8112 @endDefesc
8113
8114 @Defesc {\\., , , }
8115 Similar to @code{\\}, the sequence @code{\.} isn't a real escape
8116 sequence.  As before, a warning message is suppressed if the escape
8117 character is followed by a dot, and the dot itself is printed.
8118
8119 @Example
8120 .de foo
8121 .  nop foo
8122 .
8123 .  de bar
8124 .    nop bar
8125 \\..
8126 .
8127 ..
8128 .foo
8129 .bar
8130     @result{} foo bar
8131 @endExample
8132
8133 @noindent
8134 The first backslash is consumed while the macro is read, and the second
8135 is swallowed while executing macro @code{foo}.
8136 @endDefesc
8137
8138 A @dfn{translation} is a mapping of an input character to an output
8139 glyph.  The mapping occurs at output time, i.e., the input character
8140 gets assigned the metric information of the mapped output character
8141 right before input tokens are converted to nodes (@pxref{Gtroff
8142 Internals}, for more on this process).
8143
8144 @DefreqList {tr, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
8145 @DefreqListEndx {trin, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
8146 Translate character @var{a} to glyph@tie{}@var{b}, character @var{c} to
8147 glyph@tie{}@var{d}, etc.  If there is an odd number of arguments, the
8148 last one is translated to an unstretchable space (@w{@samp{\ }}).
8149
8150 The @code{trin} request is identical to @code{tr}, but when you unformat
8151 a diversion with @code{asciify} it ignores the translation.
8152 @xref{Diversions}, for details about the @code{asciify} request.
8153
8154 Some notes:
8155
8156 @itemize @bullet
8157 @item
8158 @cindex @code{\(}, and translations
8159 @cindex @code{\[}, and translations
8160 @cindex @code{\'}, and translations
8161 @cindex @code{\`}, and translations
8162 @cindex @code{\-}, and translations
8163 @cindex @code{\_}, and translations
8164 @cindex @code{\C}, and translations
8165 @cindex @code{\N}, and translations
8166 @cindex @code{char} request, and translations
8167 @cindex special characters
8168 @cindex character, special
8169 @cindex numbered glyph (@code{\N})
8170 @cindex glyph, numbered (@code{\N})
8171 Special characters (@code{\(@var{xx}}, @code{\[@var{xxx}]},
8172 @code{\C'@var{xxx}'}, @code{\'}, @code{\`}, @code{\-}, @code{\_}),
8173 glyphs defined with the @code{char} request, and numbered glyphs
8174 (@code{\N'@var{xxx}'}) can be translated also.
8175
8176 @item
8177 @cindex @code{\e}, and translations
8178 The @code{\e} escape can be translated also.
8179
8180 @item
8181 @cindex @code{\%}, and translations
8182 @cindex @code{\~}, and translations
8183 Characters can be mapped onto the @code{\%} and @code{\~} escapes (but
8184 @code{\%} and @code{\~} can't be mapped onto another glyph).
8185
8186 @item
8187 @cindex backspace character, and translations
8188 @cindex character, backspace, and translations
8189 @cindex leader character, and translations
8190 @cindex character, leader, and translations
8191 @cindex newline character, and translations
8192 @cindex character, newline, and translations
8193 @cindex tab character, and translations
8194 @cindex character, tab, and translations
8195 @cindex @code{\a}, and translations
8196 @cindex @code{\t}, and translations
8197 The following characters can't be translated: space (with one exception,
8198 see below), backspace, newline, leader (and @code{\a}), tab (and
8199 @code{\t}).
8200
8201 @item
8202 @cindex @code{shc} request, and translations
8203 Translations are not considered for finding the soft hyphen character
8204 set with the @code{shc} request.
8205
8206 @item
8207 @cindex @code{\&}, and translations
8208 The pair @samp{@var{c}\&} (this is an arbitrary character@tie{}@var{c}
8209 followed by the zero width space character) maps this character to
8210 nothing.
8211
8212 @Example
8213 .tr a\&
8214 foo bar
8215     @result{} foo br
8216 @endExample
8217
8218 @noindent
8219 It is even possible to map the space character to nothing:
8220
8221 @Example
8222 .tr aa \&
8223 foo bar
8224     @result{} foobar
8225 @endExample
8226
8227 @noindent
8228 As shown in the example, the space character can't be the first
8229 character/glyph pair as an argument of @code{tr}.  Additionally, it is
8230 not possible to map the space character to any other glyph; requests
8231 like @w{@samp{.tr aa x}} undo @w{@samp{.tr aa \&}} instead.
8232
8233 If justification is active, lines are justified in spite of the `empty'
8234 space character (but there is no minimal distance, i.e.@: the space
8235 character, between words).
8236
8237 @item
8238 After an output glyph has been constructed (this happens at the moment
8239 immediately before the glyph is appended to an output glyph list, either
8240 by direct output, in a macro, diversion, or string), it is no longer
8241 affected by @code{tr}.
8242
8243 @item
8244 Translating character to glyphs where one of them or both are undefined
8245 is possible also; @code{tr} does not check whether the entities in its
8246 argument do exist.
8247
8248 @xref{Gtroff Internals}.
8249
8250 @item
8251 @code{troff} no longer has a hard-coded dependency on @w{Latin-1}; all
8252 @code{char@var{XXX}} entities have been removed from the font
8253 description files.  This has a notable consequence that shows up in
8254 warnings like @code{can't find character with input code @var{XXX}} if
8255 the @code{tr} request isn't handled properly.
8256
8257 Consider the following translation:
8258
8259 @Example
8260 .tr Ã©Ã‰
8261 @endExample
8262
8263 @noindent
8264 This maps input character @code{é} onto glyph @code{É}, which is
8265 identical to glyph @code{char201}.  But this glyph intentionally doesn't
8266 exist!  Instead, @code{\[char201]} is treated as an input character
8267 entity and is by default mapped onto @code{\['E]}, and @code{gtroff}
8268 doesn't handle translations of translations.
8269
8270 The right way to write the above translation is
8271
8272 @Example
8273 .tr Ã©\['E]
8274 @endExample
8275
8276 @noindent
8277 In other words, the first argument of @code{tr} should be an input
8278 character or entity, and the second one a glyph entity.
8279
8280 @item
8281 Without an argument, the @code{tr} request is ignored.
8282 @end itemize
8283 @endDefreq
8284
8285 @Defreq {trnt, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
8286 @cindex @code{\!}, and @code{trnt}
8287 @code{trnt} is the same as the @code{tr} request except that the
8288 translations do not apply to text that is transparently throughput into
8289 a diversion with @code{\!}.  @xref{Diversions}, for more information.
8290
8291 For example,
8292
8293 @Example
8294 .tr ab
8295 .di x
8296 \!.tm a
8297 .di
8298 .x
8299 @endExample
8300
8301 @noindent
8302 prints @samp{b} to the standard error stream; if @code{trnt} is used
8303 instead of @code{tr} it prints @samp{a}.
8304 @endDefreq
8305
8306
8307 @c =====================================================================
8308
8309 @node Troff and Nroff Mode, Line Layout, Character Translations, gtroff Reference
8310 @section Troff and Nroff Mode
8311 @cindex troff mode
8312 @cindex mode, troff
8313 @cindex nroff mode
8314 @cindex mode, nroff
8315
8316 Originally, @code{nroff} and @code{troff} were two separate programs,
8317 the former for TTY output, the latter for everything else.  With GNU
8318 @code{troff}, both programs are merged into one executable, sending its
8319 output to a device driver (@code{grotty} for TTY devices, @code{grops}
8320 for @sc{PostScript}, etc.)@: which interprets the intermediate output of
8321 @code{gtroff}.  For Unix @code{troff} it makes sense to talk about
8322 @dfn{Nroff mode} and @dfn{Troff mode} since the differences are
8323 hardcoded.  For GNU @code{troff}, this distinction is not appropriate
8324 because @code{gtroff} simply takes the information given in the font
8325 files for a particular device without handling requests specially if a
8326 TTY output device is used.
8327
8328 Usually, a macro package can be used with all output devices.
8329 Nevertheless, it is sometimes necessary to make a distinction between
8330 TTY and non-TTY devices: @code{gtroff} provides two built-in conditions
8331 @samp{n} and @samp{t} for the @code{if}, @code{ie}, and @code{while}
8332 requests to decide whether @code{gtroff} shall behave like @code{nroff}
8333 or like @code{troff}.
8334
8335 @Defreq {troff, }
8336 @pindex troffrc
8337 @pindex troffrc-end
8338 Make the @samp{t} built-in condition true (and the @samp{n} built-in
8339 condition false) for @code{if}, @code{ie}, and @code{while} conditional
8340 requests.  This is the default if @code{gtroff} (@emph{not}
8341 @code{groff}) is started with the @option{-R} switch to avoid loading of
8342 the start-up files @file{troffrc} and @file{troffrc-end}.  Without
8343 @option{-R}, @code{gtroff} stays in troff mode if the output device is
8344 not a TTY (e.g.@: `ps').
8345 @endDefreq
8346
8347 @Defreq {nroff, }
8348 @pindex tty.tmac
8349 Make the @samp{n} built-in condition true (and the @samp{t} built-in
8350 condition false) for @code{if}, @code{ie}, and @code{while} conditional
8351 requests.  This is the default if @code{gtroff} uses a TTY output
8352 device; the code for switching to nroff mode is in the file
8353 @file{tty.tmac}, which is loaded by the start-up file @code{troffrc}.
8354 @endDefreq
8355
8356 @xref{Conditionals and Loops}, for more details on built-in conditions.
8357
8358
8359 @c =====================================================================
8360
8361 @node Line Layout, Line Control, Troff and Nroff Mode, gtroff Reference
8362 @section Line Layout
8363 @cindex line layout
8364 @cindex layout, line
8365
8366 @cindex dimensions, line
8367 @cindex line dimensions
8368 The following drawing shows the dimensions that @code{gtroff} uses for
8369 placing a line of output onto the page.  They are labeled with the
8370 request that manipulates each dimension.
8371
8372 @Example
8373      -->| in |<--
8374         |<-----------ll------------>|
8375    +----+----+----------------------+----+
8376    |    :    :                      :    |
8377    +----+----+----------------------+----+
8378 -->| po |<--
8379    |<--------paper width---------------->|
8380 @endExample
8381
8382 @noindent
8383 These dimensions are:
8384
8385 @ftable @code
8386 @item po
8387 @cindex left margin (@code{po})
8388 @cindex margin, left (@code{po})
8389 @cindex page offset (@code{po})
8390 @cindex offset, page (@code{po})
8391 @dfn{Page offset} -- this is the leftmost position of text on the final
8392 output, defining the @dfn{left margin}.
8393
8394 @item in
8395 @cindex indentation (@code{in})
8396 @cindex line indentation (@code{in})
8397 @dfn{Indentation} -- this is the distance from the left margin where
8398 text is printed.
8399
8400 @item ll
8401 @cindex line length (@code{ll})
8402 @cindex length of line (@code{ll})
8403 @dfn{Line length} -- this is the distance from the left margin to right
8404 margin.
8405 @end ftable
8406
8407 A simple demonstration:
8408
8409 @Example
8410 .ll 3i
8411 This is text without indentation.
8412 The line length has been set to 3\~inch.
8413 .in +.5i
8414 .ll -.5i
8415 Now the left and right margins are both increased.
8416 .in
8417 .ll
8418 Calling .in and .ll without parameters restore
8419 the previous values.
8420 @endExample
8421
8422 Result:
8423
8424 @Example
8425 This  is text without indenta-
8426 tion.   The  line  length  has
8427 been set to 3 inch.
8428      Now   the  left  and
8429      right  margins   are
8430      both increased.
8431 Calling  .in  and  .ll without
8432 parameters restore the  previ-
8433 ous values.
8434 @endExample
8435
8436 @DefreqList {po, [@Var{offset}]}
8437 @DefreqItem {po, @t{+}@Var{offset}}
8438 @DefreqItem {po, @t{-}@Var{offset}}
8439 @DefregListEndx {.o}
8440 @pindex troffrc
8441 Set horizontal page offset to @var{offset} (or increment or decrement
8442 the current value by @var{offset}).  Note that this request does not
8443 cause a break, so changing the page offset in the middle of text being
8444 filled may not yield the expected result.  The initial value is
8445 1@dmn{i}.  For TTY output devices, it is set to 0 in the startup file
8446 @file{troffrc}; the default scaling indicator is @samp{m} (and not
8447 @samp{v} as incorrectly documented in the original Unix troff manual).
8448
8449 The current page offset can be found in the read-only number register
8450 @samp{.o}.
8451
8452 If @code{po} is called without an argument, the page offset is reset to
8453 the previous value before the last call to @code{po}.
8454
8455 @Example
8456 .po 3i
8457 \n[.o]
8458     @result{} 720
8459 .po -1i
8460 \n[.o]
8461     @result{} 480
8462 .po
8463 \n[.o]
8464     @result{} 720
8465 @endExample
8466 @endDefreq
8467
8468 @DefreqList {in, [@Var{indent}]}
8469 @DefreqItem {in, @t{+}@Var{indent}}
8470 @DefreqItem {in, @t{-}@Var{indent}}
8471 @DefregListEndx {.i}
8472 Set indentation to @var{indent} (or increment or decrement the current
8473 value by @var{indent}).  This request causes a break.  Initially, there
8474 is no indentation.
8475
8476 If @code{in} is called without an argument, the indentation is reset to
8477 the previous value before the last call to @code{in}.  The default
8478 scaling indicator is @samp{m}.
8479
8480 The indentation is associated with the current environment
8481 (@pxref{Environments}).
8482
8483 If a negative indentation value is specified (which is not allowed),
8484 @code{gtroff} emits a warning of type @samp{range} and sets the
8485 indentation to zero.
8486
8487 The effect of @code{in} is delayed until a partially collected line (if
8488 it exists) is output.  A temporary indentation value is reset to zero
8489 also.
8490
8491 The current indentation (as set by @code{in}) can be found in the
8492 read-only number register @samp{.i}.
8493 @endDefreq
8494
8495 @DefreqList {ti, offset}
8496 @DefreqItem {ti, @t{+}@Var{offset}}
8497 @DefreqItem {ti, @t{-}@Var{offset}}
8498 @DefregListEndx {.in}
8499 Temporarily indent the next output line by @var{offset}.  If an
8500 increment or decrement value is specified, adjust the temporary
8501 indentation relative to the value set by the @code{in} request.
8502
8503 This request causes a break; its value is associated with the current
8504 environment (@pxref{Environments}).  The default scaling indicator is
8505 @samp{m}.  A call of @code{ti} without an argument is ignored.
8506
8507 If the total indentation value is negative (which is not allowed),
8508 @code{gtroff} emits a warning of type @samp{range} and sets the
8509 temporary indentation to zero.  `Total indentation' is either
8510 @var{offset} if specified as an absolute value, or the temporary plus
8511 normal indentation, if @var{offset} is given as a relative value.
8512
8513 The effect of @code{ti} is delayed until a partially collected line (if
8514 it exists) is output.
8515
8516 The read-only number register @code{.in} is the indentation that applies
8517 to the current output line.
8518
8519 The difference between @code{.i} and @code{.in} is that the latter takes
8520 into account whether a partially collected line still uses the old
8521 indentation value or a temporary indentation value is active.
8522 @endDefreq
8523
8524 @DefreqList {ll, [@Var{length}]}
8525 @DefreqItem {ll, @t{+}@Var{length}}
8526 @DefreqItem {ll, @t{-}@Var{length}}
8527 @DefregItemx {.l}
8528 @DefregListEndx {.ll}
8529 Set the line length to @var{length} (or increment or decrement the
8530 current value by @var{length}).  Initially, the line length is set to
8531 6.5@dmn{i}.  The effect of @code{ll} is delayed until a partially
8532 collected line (if it exists) is output.  The default scaling indicator
8533 is @samp{m}.
8534
8535 If @code{ll} is called without an argument, the line length is reset to
8536 the previous value before the last call to @code{ll}.  If a negative
8537 line length is specified (which is not allowed), @code{gtroff} emits a
8538 warning of type @samp{range} and sets the line length to zero.
8539
8540 The line length is associated with the current environment
8541 (@pxref{Environments}).
8542
8543 @cindex line length register (@code{.l})
8544 The current line length (as set by @code{ll}) can be found in the
8545 read-only number register @samp{.l}.  The read-only number register
8546 @code{.ll} is the line length that applies to the current output line.
8547
8548 Similar to @code{.i} and @code{.in}, the difference between @code{.l}
8549 and @code{.ll} is that the latter takes into account whether a partially
8550 collected line still uses the old line length value.
8551 @endDefreq
8552
8553
8554 @c =====================================================================
8555
8556 @node Line Control, Page Layout, Line Layout, gtroff Reference
8557 @section Line Control
8558 @cindex line control
8559 @cindex control, line
8560
8561 It is important to understand how @code{gtroff} handles input and output
8562 lines.
8563
8564 Many escapes use positioning relative to the input line.  For example,
8565 this
8566
8567 @Example
8568 This is a \h'|1.2i'test.
8569
8570 This is a
8571 \h'|1.2i'test.
8572 @endExample
8573
8574 @noindent
8575 produces
8576
8577 @Example
8578 This is a   test.
8579
8580 This is a             test.
8581 @endExample
8582
8583 The main usage of this feature is to define macros that act exactly at
8584 the place where called.
8585
8586 @Example
8587 .\" A simple macro to underline a word
8588 .de underline
8589 .  nop \\$1\l'|0\[ul]'
8590 ..
8591 @endExample
8592
8593 @noindent
8594 In the above example, @samp{|0} specifies a negative distance from the
8595 current position (at the end of the just emitted argument @code{\$1})
8596 back to the beginning of the input line.  Thus, the @samp{\l} escape
8597 draws a line from right to left.
8598
8599 @cindex input line continuation (@code{\})
8600 @cindex line, input, continuation (@code{\})
8601 @cindex continuation, input line (@code{\})
8602 @cindex output line, continuation (@code{\c})
8603 @cindex line, output, continuation (@code{\c})
8604 @cindex continuation, output line (@code{\c})
8605 @cindex interrupted line
8606 @cindex line, interrupted
8607 @code{gtroff} makes a difference between input and output line
8608 continuation; the latter is also called @dfn{interrupting} a line.
8609
8610 @DefescList {\\@key{RET}, , ,}
8611 @DefescItemx {\\c, , ,}
8612 @DefregListEndx {.int}
8613 Continue a line.  @code{\@key{RET}} (this is a backslash at the end of a
8614 line immediately followed by a newline) works on the input level,
8615 suppressing the effects of the following newline in the input.
8616
8617 @Example
8618 This is a \
8619 .test
8620     @result{} This is a .test
8621 @endExample
8622
8623 The @samp{|} operator is also affected.
8624
8625 @cindex @code{\R}, after @code{\c}
8626 @code{\c} works on the output level.  Anything after this escape on the
8627 same line is ignored except @code{\R}, which works as usual.  Anything
8628 before @code{\c} on the same line is appended to the current partial
8629 output line.  The next non-command line after an interrupted line counts
8630 as a new input line.
8631
8632 The visual results depend on whether no-fill mode is active.
8633
8634 @itemize @bullet
8635 @item
8636 @cindex @code{\c}, and no-fill mode
8637 @cindex no-fill mode, and @code{\c}
8638 @cindex mode, no-fill, and @code{\c}
8639 If no-fill mode is active (using the @code{nf} request), the next input
8640 text line after @code{\c} is handled as a continuation of the same input
8641 text line.
8642
8643 @Example
8644 .nf
8645 This is a \c
8646 test.
8647     @result{} This is a test.
8648 @endExample
8649
8650 @item
8651 @cindex @code{\c}, and fill mode
8652 @cindex fill mode, and @code{\c}
8653 @cindex mode, fill, and @code{\c}
8654 If fill mode is active (using the @code{fi} request), a word interrupted
8655 with @code{\c} is continued with the text on the next input text line,
8656 without an intervening space.
8657
8658 @Example
8659 This is a te\c
8660 st.
8661     @result{} This is a test.
8662 @endExample
8663 @end itemize
8664
8665 Note that an intervening control line that causes a break is stronger
8666 than @code{\c}, flushing out the current partial line in the usual way.
8667
8668 @cindex interrupted line register (@code{.int})
8669 The @code{.int} register contains a positive value if the last output
8670 line was interrupted with @code{\c}; this is associated with the current
8671 environment (@pxref{Environments}).
8672 @endDefesc
8673
8674
8675 @c =====================================================================
8676
8677 @node Page Layout, Page Control, Line Control, gtroff Reference
8678 @section Page Layout
8679 @cindex page layout
8680 @cindex layout, page
8681
8682 @code{gtroff} provides some very primitive operations for controlling
8683 page layout.
8684
8685 @DefreqList {pl, [@Var{length}]}
8686 @DefreqItem {pl, @t{+}@Var{length}}
8687 @DefreqItem {pl, @t{-}@Var{length}}
8688 @DefregListEndx {.p}
8689 @cindex page length (@code{pl})
8690 @cindex length of page (@code{pl})
8691 Set the @dfn{page length} to @var{length} (or increment or decrement the
8692 current value by @var{length}).  This is the length of the physical
8693 output page.  The default scaling indicator is @samp{v}.
8694
8695 @cindex page length register (@code{.p})
8696 The current setting can be found in the read-only number register
8697 @samp{.p}.
8698
8699 @cindex top margin
8700 @cindex margin, top
8701 @cindex bottom margin
8702 @cindex margin, bottom
8703 Note that this only specifies the size of the page, not the top and
8704 bottom margins.  Those are not set by @code{gtroff} directly.
8705 @xref{Traps}, for further information on how to do this.
8706
8707 Negative @code{pl} values are possible also, but not very useful: No
8708 trap is sprung, and each line is output on a single page (thus
8709 suppressing all vertical spacing).
8710
8711 If no argument or an invalid argument is given, @code{pl} sets the page
8712 length to 11@dmn{i}.
8713 @endDefreq
8714
8715 @cindex headers
8716 @cindex footers
8717 @cindex titles
8718 @code{gtroff} provides several operations that help in setting up top
8719 and bottom titles (or headers and footers).
8720
8721 @Defreq {tl, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}}
8722 @cindex title line (@code{tl})
8723 @cindex three-part title (@code{tl})
8724 @cindex page number character (@code{%})
8725 Print a @dfn{title line}.  It consists of three parts: a left justified
8726 portion, a centered portion, and a right justified portion.  The
8727 argument separator @samp{'} can be replaced with any character not
8728 occurring in the title line.  The @samp{%} character is replaced with
8729 the current page number.  This character can be changed with the
8730 @code{pc} request (see below).
8731
8732 Without argument, @code{tl} is ignored.
8733
8734 Some notes:
8735
8736 @itemize @bullet
8737 @item
8738 The line length set by the @code{ll} request is not honoured by
8739 @code{tl}; use the @code{lt} request (described below) instead, to
8740 control line length for text set by @code{tl}.
8741
8742 @item
8743 A title line is not restricted to the top or bottom of a page.
8744
8745 @item
8746 @code{tl} prints the title line immediately, ignoring a partially filled
8747 line (which stays untouched).
8748
8749 @item
8750 It is not an error to omit closing delimiters.  For example,
8751 @w{@samp{.tl /foo}} is equivalent to @w{@samp{.tl /foo///}}: It prints a
8752 title line with the left justified word @samp{foo}; the centered and
8753 right justified parts are empty.
8754
8755 @item
8756 @code{tl} accepts the same parameter delimiting characters as the
8757 @code{\A} escape; see @ref{Escapes}.
8758 @end itemize
8759 @endDefreq
8760
8761 @DefreqList {lt, [@Var{length}]}
8762 @DefreqItem {lt, @t{+}@Var{length}}
8763 @DefreqItem {lt, @t{-}@Var{length}}
8764 @DefregListEndx {.lt}
8765 @cindex length of title line (@code{lt})
8766 @cindex title line, length (@code{lt})
8767 @cindex title line length register (@code{.lt})
8768 The title line is printed using its own line length, which is specified
8769 (or incremented or decremented) with the @code{lt} request.  Initially,
8770 the title line length is set to 6.5@dmn{i}.  If a negative line length
8771 is specified (which is not allowed), @code{gtroff} emits a warning of
8772 type @samp{range} and sets the title line length to zero.  The default
8773 scaling indicator is @samp{m}.  If @code{lt} is called without an
8774 argument, the title length is reset to the previous value before the
8775 last call to @code{lt}.
8776
8777 The current setting of this is available in the @code{.lt} read-only
8778 number register; it is associated with the current environment
8779 (@pxref{Environments}).
8780 @endDefreq
8781
8782 @DefreqList {pn, page}
8783 @DefreqItem {pn, @t{+}@Var{page}}
8784 @DefreqItem {pn, @t{-}@Var{page}}
8785 @DefregListEndx {.pn}
8786 @cindex page number (@code{pn})
8787 @cindex number, page (@code{pn})
8788 Change (increase or decrease) the page number of the @emph{next} page.
8789 The only argument is the page number; the request is ignored without a
8790 parameter.
8791
8792 The read-only number register @code{.pn} contains the number of the next
8793 page: either the value set by a @code{pn} request, or the number of the
8794 current page plus@tie{}1.
8795 @endDefreq
8796
8797 @Defreq {pc, [@Var{char}]}
8798 @cindex changing the page number character (@code{pc})
8799 @cindex page number character, changing (@code{pc})
8800 @vindex %
8801 Change the page number character (used by the @code{tl} request) to a
8802 different character.  With no argument, this mechanism is disabled.
8803 Note that this doesn't affect the number register@tie{}@code{%}.
8804 @endDefreq
8805
8806 @xref{Traps}.
8807
8808
8809 @c =====================================================================
8810
8811 @node Page Control, Fonts and Symbols, Page Layout, gtroff Reference
8812 @section Page Control
8813 @cindex page control
8814 @cindex control, page
8815
8816 @DefreqList {bp, [@Var{page}]}
8817 @DefreqItem {bp, @t{+}@Var{page}}
8818 @DefreqItem {bp, @t{-}@Var{page}}
8819 @DefregListEndx {%}
8820 @cindex new page (@code{bp})
8821 @cindex page, new (@code{bp})
8822 Stop processing the current page and move to the next page.  This
8823 request causes a break.  It can also take an argument to set (increase,
8824 decrease) the page number of the next page (which actually becomes the
8825 current page after @code{bp} has finished).  The difference between
8826 @code{bp} and @code{pn} is that @code{pn} does not cause a break or
8827 actually eject a page.  @xref{Page Layout}.
8828
8829 @Example
8830 .de newpage                         \" define macro
8831 'bp                                 \" begin page
8832 'sp .5i                             \" vertical space
8833 .tl 'left top'center top'right top' \" title
8834 'sp .3i                             \" vertical space
8835 ..                                  \" end macro
8836 @endExample
8837
8838 @cindex @code{bp} request, and top-level diversion
8839 @cindex top-level diversion, and @code{bp}
8840 @cindex diversion, top-level, and @code{bp}
8841 @code{bp} has no effect if not called within the top-level diversion
8842 (@pxref{Diversions}).
8843
8844 @cindex page number register (@code{%})
8845 @cindex current page number (@code{%})
8846 The read-write register@tie{}@code{%} holds the current page number.
8847
8848 The number register @code{.pe} is set to@tie{}1 while @code{bp} is
8849 active.  @xref{Page Location Traps}.
8850 @endDefreq
8851
8852 @Defreq {ne, [@Var{space}]}
8853 @cindex orphan lines, preventing with @code{ne}
8854 @cindex conditional page break (@code{ne})
8855 @cindex page break, conditional (@code{ne})
8856 It is often necessary to force a certain amount of space before a new
8857 page occurs.  This is most useful to make sure that there is not a
8858 single @dfn{orphan} line left at the bottom of a page.  The @code{ne}
8859 request ensures that there is a certain distance, specified by the first
8860 argument, before the next page is triggered (see @ref{Traps}, for
8861 further information).  The default scaling indicator for @code{ne} is
8862 @samp{v}; the default value of @var{space} is@tie{}1@dmn{v} if no
8863 argument is given.
8864
8865 For example, to make sure that no fewer than 2@tie{}lines get orphaned,
8866 do the following before each paragraph:
8867
8868 @Example
8869 .ne 2
8870 text text text
8871 @endExample
8872
8873 @code{ne} then automatically causes a page break if there is space for
8874 one line only.
8875 @endDefreq
8876
8877 @DefreqList {sv, [@Var{space}]}
8878 @DefreqListEndx {os, }
8879 @cindex @code{ne} request, comparison with @code{sv}
8880 @code{sv} is similar to the @code{ne} request; it reserves the specified
8881 amount of vertical space.  If the desired amount of space exists before
8882 the next trap (or the bottom page boundary if no trap is set), the space
8883 is output immediately (ignoring a partially filled line, which stays
8884 untouched).  If there is not enough space, it is stored for later output
8885 via the @code{os} request.  The default value is@tie{}1@dmn{v} if no
8886 argument is given; the default scaling indicator is @samp{v}.
8887
8888 @cindex @code{sv} request, and no-space mode
8889 @cindex @code{os} request, and no-space mode
8890 Both @code{sv} and @code{os} ignore no-space mode.  While the @code{sv}
8891 request allows negative values for @var{space}, @code{os} ignores them.
8892 @endDefreq
8893
8894 @Defreg {nl}
8895 @cindex current vertical position (@code{nl})
8896 @cindex vertical position, current (@code{nl})
8897 @cindex position, vertical, current (@code{nl})
8898 This register contains the current vertical position.  If the vertical
8899 position is zero and the top of page transition hasn't happened yet,
8900 @code{nl} is set to negative value.  @code{gtroff} itself does this at
8901 the very beginning of a document before anything has been printed, but
8902 the main usage is to plant a header trap on a page if this page has
8903 already started.
8904
8905 Consider the following:
8906
8907 @Example
8908 .de xxx
8909 .  sp
8910 .  tl ''Header''
8911 .  sp
8912 ..
8913 .
8914 First page.
8915 .bp
8916 .wh 0 xxx
8917 .nr nl (-1)
8918 Second page.
8919 @endExample
8920
8921 @noindent
8922 Result:
8923
8924 @Example
8925 First page.
8926
8927 ...
8928
8929                              Header
8930
8931 Second page.
8932
8933 ...
8934 @endExample
8935
8936 @noindent
8937 Without resetting @code{nl} to a negative value, the just planted trap
8938 would be active beginning with the @emph{next} page, not the current
8939 one.
8940
8941 @xref{Diversions}, for a comparison with the @code{.h} and @code{.d}
8942 registers.
8943 @endDefreg
8944
8945
8946 @c =====================================================================
8947
8948 @node Fonts and Symbols, Sizes, Page Control, gtroff Reference
8949 @section Fonts and Symbols
8950 @cindex fonts
8951
8952 @code{gtroff} can switch fonts at any point in the text.
8953
8954 The basic set of fonts is @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
8955 These are Times Roman, Italic, Bold, and Bold Italic.  For non-TTY
8956 devices, there is also at least one symbol font that contains various
8957 special symbols (Greek, mathematics).
8958
8959 @menu
8960 * Changing Fonts::
8961 * Font Families::
8962 * Font Positions::
8963 * Using Symbols::
8964 * Character Classes::
8965 * Special Fonts::
8966 * Artificial Fonts::
8967 * Ligatures and Kerning::
8968 @end menu
8969
8970 @c ---------------------------------------------------------------------
8971
8972 @node Changing Fonts, Font Families, Fonts and Symbols, Fonts and Symbols
8973 @subsection Changing Fonts
8974 @cindex fonts
8975
8976 @DefreqList {ft, [@Var{font}]}
8977 @DefescItemx {\\f, , f, }
8978 @DefescItem {\\f, @Lparen{}, fn, }
8979 @DefescItem {\\f, @Lbrack{}, font, @Rbrack{}}
8980 @DefregListEndx {.sty}
8981 @cindex changing fonts (@code{ft}, @code{\f})
8982 @cindex fonts, changing (@code{ft}, @code{\f})
8983 @cindex @code{sty} request, and changing fonts
8984 @cindex @code{fam} request, and changing fonts
8985 @cindex @code{\F}, and changing fonts
8986 @kindex styles
8987 @kindex family
8988 @pindex DESC
8989 The @code{ft} request and the @code{\f} escape change the current font
8990 to @var{font} (one-character name@tie{}@var{f}, two-character name
8991 @var{fn}).
8992
8993 If @var{font} is a style name (as set with the @code{sty} request or
8994 with the @code{styles} command in the @file{DESC} file), use it within
8995 the current font family (as set with the @code{fam} request, the
8996 @code{\F} escape, or the @code{family} command in the @file{DESC} file).
8997
8998 It is not possible to switch to a font with the name @samp{DESC}
8999 (whereas this name could be used as a style name; however, this is not
9000 recommended).
9001
9002 @cindex previous font (@code{ft}, @code{\f[]}, @code{\fP})
9003 @cindex font, previous (@code{ft}, @code{\f[]}, @code{\fP})
9004 With no argument or using @samp{P} as an argument, @code{.ft} switches
9005 to the previous font.  Use @code{\f[]} to do this with the escape.  The
9006 old syntax forms @code{\fP} or @code{\f[P]} are also supported.
9007
9008 Fonts are generally specified as upper-case strings, which are usually
9009 1@tie{}to 4 characters representing an abbreviation or acronym of the
9010 font name.  This is no limitation, just a convention.
9011
9012 The example below produces two identical lines.
9013
9014 @Example
9015 eggs, bacon,
9016 .ft B
9017 spam
9018 .ft
9019 and sausage.
9020
9021 eggs, bacon, \fBspam\fP and sausage.
9022 @endExample
9023
9024 Note that @code{\f} doesn't produce an input token in @code{gtroff}.  As
9025 a consequence, it can be used in requests like @code{mc} (which expects
9026 a single character as an argument) to change the font on the fly:
9027
9028 @Example
9029 .mc \f[I]x\f[]
9030 @endExample
9031
9032 The current style name is available in the read-only number register
9033 @samp{.sty} (this is a string-valued register); if the current font
9034 isn't a style, the empty string is returned.  It is associated with the
9035 current environment.
9036
9037 @xref{Font Positions}, for an alternative syntax.
9038 @endDefreq
9039
9040 @Defreq {ftr, f [@Var{g}]}
9041 @cindex font translation (@code{ftr})
9042 @cindex @code{ft} request, and font translations
9043 @cindex @code{ul} request, and font translations
9044 @cindex @code{bd} request, and font translations
9045 @cindex @code{\f}, and font translations
9046 @cindex @code{cs} request, and font translations
9047 @cindex @code{tkf} request, and font translations
9048 @cindex @code{special} request, and font translations
9049 @cindex @code{fspecial} request, and font translations
9050 @cindex @code{fp} request, and font translations
9051 @cindex @code{sty} request, and font translations
9052 @cindex @code{if} request, and font translations
9053 @cindex @code{ie} request, and font translations
9054 @cindex @code{while} request, and font translations
9055 Translate font@tie{}@var{f} to font@tie{}@var{g}.  Whenever a font
9056 named@tie{}@var{f} is referred to in a @code{\f} escape sequence, in the
9057 @code{F} and @code{S} conditional operators, or in the @code{ft},
9058 @code{ul}, @code{bd}, @code{cs}, @code{tkf}, @code{special},
9059 @code{fspecial}, @code{fp}, or @code{sty} requests, font@tie{}@var{g} is
9060 used.  If @var{g} is missing or equal to@tie{}@var{f} the translation is
9061 undone.
9062
9063 Note that it is not possible to chain font translations.  Example:
9064
9065 @Example
9066 .ftr XXX TR
9067 .ftr XXX YYY
9068 .ft XXX
9069     @result{} warning: can't find font `XXX'
9070 @endExample
9071 @endDefreq
9072
9073 @DefreqList {fzoom, f [@Var{zoom}]}
9074 @DefregListEndx {.zoom}
9075 @cindex magnification of a font (@code{fzoom})
9076 @cindex font, magnification (@code{fzoom})
9077 @cindex zoom factor of a font (@code{fzoom})
9078 @cindex factor, zoom, of a font (@code{fzoom})
9079 @cindex font, zoom factor (@code{fzoom})
9080 @cindex optical size of a font
9081 @cindex font, optical size
9082 @cindex size, optical, of a font
9083 Set magnification of font@tie{}@var{f} to factor @var{zoom}, which must
9084 be a non-negative integer multiple of 1/1000th.  This request is useful
9085 to adjust the optical size of a font in relation to the others.  In the
9086 example below, font @code{CR} is magnified by 10% (the zoom factor is
9087 thus 1.1).
9088
9089 @Example
9090 .fam P
9091 .fzoom CR 1100
9092 .ps 12
9093 Palatino and \f[CR]Courier\f[]
9094 @endExample
9095
9096 A missing or zero value of @var{zoom} is the same as a value of 1000,
9097 which means no magnification.  @var{f}@tie{}must be a real font name,
9098 not a style.
9099
9100 Note that the magnification of a font is completely transparent to
9101 troff; a change of the zoom factor doesn't cause any effect except that
9102 the dimensions of glyphs, (word) spaces, kerns, etc., of the affected
9103 font are adjusted accordingly.
9104
9105 The zoom factor of the current font is available in the read-only number
9106 register @samp{.zoom}, in multiples of 1/1000th.  It returns zero if
9107 there is no magnification.
9108 @endDefreq
9109
9110 @c ---------------------------------------------------------------------
9111
9112 @node Font Families, Font Positions, Changing Fonts, Fonts and Symbols
9113 @subsection Font Families
9114 @cindex font families
9115 @cindex families, font
9116 @cindex font styles
9117 @cindex styles, font
9118
9119 Due to the variety of fonts available, @code{gtroff} has added the
9120 concept of @dfn{font families} and @dfn{font styles}.  The fonts are
9121 specified as the concatenation of the font family and style.  Specifying
9122 a font without the family part causes @code{gtroff} to use that style of
9123 the current family.
9124
9125 @cindex PostScript fonts
9126 @cindex fonts, PostScript
9127 Currently, fonts for the devices @option{-Tps}, @option{-Tpdf},
9128 @option{-Tdvi}, @option{-Tlj4}, @option{-Tlbp}, and the X11 fonts are
9129 set up to this mechanism.  By default, @code{gtroff} uses the Times
9130 family with the four styles @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
9131
9132 This way, it is possible to use the basic four fonts and to select a
9133 different font family on the command line (@pxref{Groff Options}).
9134
9135 @DefreqList {fam, [@Var{family}]}
9136 @DefregItemx {.fam}
9137 @DefescItemx {\\F, , f, }
9138 @DefescItem {\\F, @Lparen{}, fm, }
9139 @DefescItem {\\F, @Lbrack{}, family, @Rbrack{}}
9140 @DefregListEndx {.fn}
9141 @cindex changing font family (@code{fam}, @code{\F})
9142 @cindex font family, changing (@code{fam}, @code{\F})
9143 Switch font family to @var{family} (one-character name@tie{}@var{f},
9144 two-character name @var{fm}).  If no argument is given, switch back to
9145 the previous font family.  Use @code{\F[]} to do this with the escape.
9146 Note that @code{\FP} doesn't work; it selects font family @samp{P}
9147 instead.
9148
9149 The value at start-up is @samp{T}.  The current font family is available
9150 in the read-only number register @samp{.fam} (this is a string-valued
9151 register); it is associated with the current environment.
9152
9153 @Example
9154 spam,
9155 .fam H    \" helvetica family
9156 spam,     \" used font is family H + style R = HR
9157 .ft B     \" family H + style B = font HB
9158 spam,
9159 .fam T    \" times family
9160 spam,     \" used font is family T + style B = TB
9161 .ft AR    \" font AR (not a style)
9162 baked beans,
9163 .ft R     \" family T + style R = font TR
9164 and spam.
9165 @endExample
9166
9167 Note that @code{\F} doesn't produce an input token in @code{gtroff}.  As
9168 a consequence, it can be used in requests like @code{mc} (which expects
9169 a single character as an argument) to change the font family on the fly:
9170
9171 @Example
9172 .mc \F[P]x\F[]
9173 @endExample
9174
9175 The @samp{.fn} register contains the current @dfn{real font name} of the
9176 current font.  This is a string-valued register.  If the current font is
9177 a style, the value of @code{\n[.fn]} is the proper concatenation of
9178 family and style name.
9179 @endDefreq
9180
9181 @Defreq {sty, n style}
9182 @cindex changing font style (@code{sty})
9183 @cindex font style, changing (@code{sty})
9184 @cindex @code{cs} request, and font styles
9185 @cindex @code{bd} request, and font styles
9186 @cindex @code{tkf} request, and font styles
9187 @cindex @code{uf} request, and font styles
9188 @cindex @code{fspecial} request, and font styles
9189 Associate @var{style} with font position@tie{}@var{n}.  A font position
9190 can be associated either with a font or with a style.  The current font
9191 is the index of a font position and so is also either a font or a style.
9192 If it is a style, the font that is actually used is the font which name
9193 is the concatenation of the name of the current family and the name of
9194 the current style.  For example, if the current font is@tie{}1 and font
9195 position@tie{}1 is associated with style @samp{R} and the current font
9196 family is @samp{T}, then font @samp{TR} is used.  If the current font is
9197 not a style, then the current family is ignored.  If the requests
9198 @code{cs}, @code{bd}, @code{tkf}, @code{uf}, or @code{fspecial} are
9199 applied to a style, they are instead applied to the member of the
9200 current family corresponding to that style.
9201
9202 @var{n}@tie{}must be a non-negative integer value.
9203
9204 @pindex DESC
9205 @kindex styles
9206 The default family can be set with the @option{-f} option (@pxref{Groff
9207 Options}).  The @code{styles} command in the @file{DESC} file controls
9208 which font positions (if any) are initially associated with styles
9209 rather than fonts.  For example, the default setting for @sc{PostScript}
9210 fonts
9211
9212 @Example
9213 styles R I B BI
9214 @endExample
9215
9216 @noindent
9217 is equivalent to
9218
9219 @Example
9220 .sty 1 R
9221 .sty 2 I
9222 .sty 3 B
9223 .sty 4 BI
9224 @endExample
9225
9226 @code{fam} and @code{\F} always check whether the current font position
9227 is valid; this can give surprising results if the current font position
9228 is associated with a style.
9229
9230 In the following example, we want to access the @sc{PostScript} font
9231 @code{FooBar} from the font family @code{Foo}:
9232
9233 @Example
9234 .sty \n[.fp] Bar
9235 .fam Foo
9236     @result{} warning: can't find font `FooR'
9237 @endExample
9238
9239 @noindent
9240 The default font position at start-up is@tie{}1; for the @sc{PostScript}
9241 device, this is associated with style @samp{R}, so @code{gtroff} tries
9242 to open @code{FooR}.
9243
9244 A solution to this problem is to use a dummy font like the following:
9245
9246 @Example
9247 .fp 0 dummy TR    \" set up dummy font at position 0
9248 .sty \n[.fp] Bar  \" register style `Bar'
9249 .ft 0             \" switch to font at position 0
9250 .fam Foo          \" activate family `Foo'
9251 .ft Bar           \" switch to font `FooBar'
9252 @endExample
9253
9254 @xref{Font Positions}.
9255 @endDefreq
9256
9257 @c ---------------------------------------------------------------------
9258
9259 @node Font Positions, Using Symbols, Font Families, Fonts and Symbols
9260 @subsection Font Positions
9261 @cindex font positions
9262 @cindex positions, font
9263
9264 For the sake of old phototypesetters and compatibility with old versions
9265 of @code{troff}, @code{gtroff} has the concept of font @dfn{positions},
9266 on which various fonts are mounted.
9267
9268 @DefreqList {fp, pos font [@Var{external-name}]}
9269 @DefregItemx {.f}
9270 @DefregListEndx {.fp}
9271 @cindex mounting font (@code{fp})
9272 @cindex font, mounting (@code{fp})
9273 Mount font @var{font} at position @var{pos} (which must be a
9274 non-negative integer).  This numeric position can then be referred to
9275 with font changing commands.  When @code{gtroff} starts it is using font
9276 position@tie{}1 (which must exist; position@tie{}0 is unused usually at
9277 start-up).
9278
9279 @cindex font position register (@code{.f})
9280 The current font in use, as a font position, is available in the
9281 read-only number register @samp{.f}.  This can be useful to remember the
9282 current font for later recall.  It is associated with the current
9283 environment (@pxref{Environments}).
9284
9285 @Example
9286 .nr save-font \n[.f]
9287 .ft B
9288 ... text text text ...
9289 .ft \n[save-font]
9290 @endExample
9291
9292 @cindex next free font position register (@code{.fp})
9293 The number of the next free font position is available in the read-only
9294 number register @samp{.fp}.  This is useful when mounting a new font,
9295 like so:
9296
9297 @Example
9298 .fp \n[.fp] NEATOFONT
9299 @endExample
9300
9301 @pindex DESC@r{, and font mounting}
9302 Fonts not listed in the @file{DESC} file are automatically mounted on
9303 the next available font position when they are referenced.  If a font is
9304 to be mounted explicitly with the @code{fp} request on an unused font
9305 position, it should be mounted on the first unused font position, which
9306 can be found in the @code{.fp} register.  Although @code{gtroff} does
9307 not enforce this strictly, it is not allowed to mount a font at a
9308 position whose number is much greater (approx.@: 1000 positions) than
9309 that of any currently used position.
9310
9311 The @code{fp} request has an optional third argument.  This argument
9312 gives the external name of the font, which is used for finding the font
9313 description file.  The second argument gives the internal name of the
9314 font, which is used to refer to the font in @code{gtroff} after it has
9315 been mounted.  If there is no third argument then the internal name is
9316 used as the external name.  This feature makes it possible to use fonts
9317 with long names in compatibility mode.
9318 @endDefreq
9319
9320 Both the @code{ft} request and the @code{\f} escape have alternative
9321 syntax forms to access font positions.
9322
9323 @DefreqList {ft, nnn}
9324 @DefescItemx {\\f, , n, }
9325 @DefescItem {\\f, @Lparen{}, nn, }
9326 @DefescListEnd {\\f, @Lbrack{}, nnn, @Rbrack{}}
9327 @cindex changing font position (@code{\f})
9328 @cindex font position, changing (@code{\f})
9329 @cindex @code{sty} request, and font positions
9330 @cindex @code{fam} request, and font positions
9331 @cindex @code{\F}, and font positions
9332 @kindex styles
9333 @kindex family
9334 @pindex DESC
9335 Change the current font position to @var{nnn} (one-digit
9336 position@tie{}@var{n}, two-digit position @var{nn}), which must be a
9337 non-negative integer.
9338
9339 If @var{nnn} is associated with a style (as set with the @code{sty}
9340 request or with the @code{styles} command in the @file{DESC} file), use
9341 it within the current font family (as set with the @code{fam} request,
9342 the @code{\F} escape, or the @code{family} command in the
9343 @file{DESC} file).
9344
9345 @Example
9346 this is font 1
9347 .ft 2
9348 this is font 2
9349 .ft                   \" switch back to font 1
9350 .ft 3
9351 this is font 3
9352 .ft
9353 this is font 1 again
9354 @endExample
9355
9356 @xref{Changing Fonts}, for the standard syntax form.
9357 @endDefreq
9358
9359 @c ---------------------------------------------------------------------
9360
9361 @node Using Symbols, Character Classes, Font Positions, Fonts and Symbols
9362 @subsection Using Symbols
9363 @cindex using symbols
9364 @cindex symbols, using
9365
9366 @cindex glyph
9367 @cindex character
9368 @cindex ligature
9369 A @dfn{glyph} is a graphical representation of a @dfn{character}.  While
9370 a character is an abstract entity containing semantic information, a
9371 glyph is something that can be actually seen on screen or paper.  It is
9372 possible that a character has multiple glyph representation forms (for
9373 example, the character `A' can be either written in a roman or an italic
9374 font, yielding two different glyphs); sometimes more than one character
9375 maps to a single glyph (this is a @dfn{ligature} -- the most common is
9376 `fi').
9377
9378 @cindex symbol
9379 @cindex special fonts
9380 @kindex fonts
9381 @pindex DESC
9382 @cindex @code{special} request, and glyph search order
9383 @cindex @code{fspecial} request, and glyph search order
9384 A @dfn{symbol} is simply a named glyph.  Within @code{gtroff}, all glyph
9385 names of a particular font are defined in its font file.  If the user
9386 requests a glyph not available in this font, @code{gtroff} looks up an
9387 ordered list of @dfn{special fonts}.  By default, the @sc{PostScript}
9388 output device supports the two special fonts @samp{SS} (slanted symbols)
9389 and @samp{S} (symbols) (the former is looked up before the latter).
9390 Other output devices use different names for special fonts.  Fonts
9391 mounted with the @code{fonts} keyword in the @file{DESC} file are
9392 globally available.  To install additional special fonts locally (i.e.@:
9393 for a particular font), use the @code{fspecial} request.
9394
9395 Here are the exact rules how @code{gtroff} searches a given symbol:
9396
9397 @itemize @bullet
9398 @item
9399 If the symbol has been defined with the @code{char} request, use it.
9400 This hides a symbol with the same name in the current font.
9401
9402 @item
9403 Check the current font.
9404
9405 @item
9406 If the symbol has been defined with the @code{fchar} request, use it.
9407
9408 @item
9409 Check whether the current font has a font-specific list of special
9410 fonts; test all fonts in the order of appearance in the last
9411 @code{fspecial} call if appropriate.
9412
9413 @item
9414 If the symbol has been defined with the @code{fschar} request for the
9415 current font, use it.
9416
9417 @item
9418 Check all fonts in the order of appearance in the last @code{special}
9419 call.
9420
9421 @item
9422 If the symbol has been defined with the @code{schar} request, use it.
9423
9424 @item
9425 As a last resort, consult all fonts loaded up to now for special fonts
9426 and check them, starting with the lowest font number.  Note that this
9427 can sometimes lead to surprising results since the @code{fonts} line in
9428 the @file{DESC} file often contains empty positions, which are filled
9429 later on.  For example, consider the following:
9430
9431 @Example
9432 fonts 3 0 0 FOO
9433 @endExample
9434
9435 @noindent
9436 This mounts font @code{foo} at font position@tie{}3.  We assume that
9437 @code{FOO} is a special font, containing glyph @code{foo}, and that no
9438 font has been loaded yet.  The line
9439
9440 @Example
9441 .fspecial BAR BAZ
9442 @endExample
9443
9444 @noindent
9445 makes font @code{BAZ} special only if font @code{BAR} is active.  We
9446 further assume that @code{BAZ} is really a special font, i.e., the font
9447 description file contains the @code{special} keyword, and that it also
9448 contains glyph @code{foo} with a special shape fitting to font
9449 @code{BAR}.  After executing @code{fspecial}, font @code{BAR} is loaded
9450 at font position@tie{}1, and @code{BAZ} at position@tie{}2.
9451
9452 We now switch to a new font @code{XXX}, trying to access glyph
9453 @code{foo} that is assumed to be missing.  There are neither
9454 font-specific special fonts for @code{XXX} nor any other fonts made
9455 special with the @code{special} request, so @code{gtroff} starts the
9456 search for special fonts in the list of already mounted fonts, with
9457 increasing font positions.  Consequently, it finds @code{BAZ} before
9458 @code{FOO} even for @code{XXX}, which is not the intended behaviour.
9459 @end itemize
9460
9461 @xref{Font Files}, and @ref{Special Fonts}, for more details.
9462
9463 @cindex list of available glyphs (@cite{groff_char(7)} man page)
9464 @cindex available glyphs, list (@cite{groff_char(7)} man page)
9465 @cindex glyphs, available, list (@cite{groff_char(7)} man page)
9466 The list of available symbols is device dependent; see the
9467 @cite{groff_char(7)} man page for a complete list of all glyphs.  For
9468 example, say
9469
9470 @Example
9471 man -Tdvi groff_char > groff_char.dvi
9472 @endExample
9473
9474 @noindent
9475 for a list using the default DVI fonts (not all versions of the
9476 @code{man} program support the @option{-T} option).  If you want to use
9477 an additional macro package to change the used fonts, @code{groff} must
9478 be called directly:
9479
9480 @Example
9481 groff -Tdvi -mec -man groff_char.7 > groff_char.dvi
9482 @endExample
9483
9484 @cindex composite glyph names
9485 @cindex glyph names, composite
9486 @cindex groff glyph list (GGL)
9487 @cindex GGL (groff glyph list)
9488 @cindex adobe glyph list (AGL)
9489 @cindex AGL (adobe glyph list)
9490 Glyph names not listed in groff_char(7) are derived algorithmically,
9491 using a simplified version of the Adobe Glyph List (AGL) algorithm, which
9492 is described in @uref{https://github.com@//adobe-type-tools@//agl-aglfn}.
9493 The (frozen) set of glyph names that can't be derived algorithmically
9494 is called @dfn{groff glyph list (GGL)}.
9495
9496 @itemize @bullet
9497 @item
9498 A glyph for Unicode character U+@var{XXXX}[@var{X}[@var{X}]], which is
9499 not a composite character is named
9500 @code{u@var{XXXX}@r{[}@var{X}@r{[}@var{X}@r{]]}}.  @var{X} must be an
9501 uppercase hexadecimal digit.  Examples: @code{u1234}, @code{u008E},
9502 @code{u12DB8}.  The largest Unicode value is 0x10FFFF.  There must be at
9503 least four @code{X} digits; if necessary, add leading zeroes (after the
9504 @samp{u}).  No zero padding is allowed for character codes greater than
9505 0xFFFF.  Surrogates (i.e., Unicode values greater than 0xFFFF
9506 represented with character codes from the surrogate area U+D800-U+DFFF)
9507 are not allowed too.
9508
9509 @item
9510 A glyph representing more than a single input character is named
9511
9512 @display
9513 @samp{u} @var{component1} @samp{_} @var{component2} @samp{_} @var{component3} @dots{}
9514 @end display
9515
9516 @noindent
9517 Example: @code{u0045_0302_0301}.
9518
9519 For simplicity, all Unicode characters that are composites must be
9520 decomposed maximally (this is normalization form@tie{}D in the Unicode
9521 standard); for example, @code{u00CA_0301} is not a valid glyph name
9522 since U+00CA (@sc{latin capital letter e with circumflex}) can be
9523 further decomposed into U+0045 (@sc{latin capital letter e}) and U+0302
9524 (@sc{combining circumflex accent}).  @code{u0045_0302_0301} is thus the
9525 glyph name for U+1EBE, @sc{latin capital letter e with circumflex and
9526 acute}.
9527
9528 @item
9529 groff maintains a table to decompose all algorithmically derived glyph
9530 names that are composites itself.  For example, @code{u0100} (@sc{latin
9531 letter a with macron}) is automatically decomposed into
9532 @code{u0041_0304}.  Additionally, a glyph name of the GGL is preferred
9533 to an algorithmically derived glyph name; groff also automatically does
9534 the mapping.  Example: The glyph @code{u0045_0302} is mapped to
9535 @code{^E}.
9536
9537 @item
9538 glyph names of the GGL can't be used in composite glyph names; for
9539 example, @code{^E_u0301} is invalid.
9540 @end itemize
9541
9542 @DefescList {\\, @Lparen{}, nm, }
9543 @DefescItem {\\, @Lbrack{}, name, @Rbrack{}}
9544 @DefescListEnd {\\, @Lbrack{}, component1 component2 @dots{}, @Rbrack{}}
9545 Insert a symbol @var{name} (two-character name @var{nm}) or a composite
9546 glyph with component glyphs @var{component1}, @var{component2},
9547 @enddots{} There is no special syntax for one-character names -- the
9548 natural form @samp{\@var{n}} would collide with escapes.@footnote{Note
9549 that a one-character symbol is not the same as an input character, i.e.,
9550 the character @code{a} is not the same as @code{\[a]}.  By default,
9551 @code{groff} defines only a single one-character symbol, @code{\[-]}; it
9552 is usually accessed as @code{\-}.  On the other hand, @code{gtroff} has
9553 the special feature that @code{\[char@var{XXX}]} is the same as the
9554 input character with character code @var{XXX}.  For example,
9555 @code{\[char97]} is identical to the letter @code{a} if @acronym{ASCII}
9556 encoding is active.}
9557
9558 If @var{name} is undefined, a warning of type @samp{char} is generated,
9559 and the escape is ignored.  @xref{Debugging}, for information about
9560 warnings.
9561
9562 groff resolves @code{\[...]} with more than a single component as
9563 follows:
9564
9565 @itemize @bullet
9566 @item
9567 Any component that is found in the GGL is converted to the
9568 @code{u@var{XXXX}} form.
9569
9570 @item
9571 Any component @code{u@var{XXXX}} that is found in the list of
9572 decomposable glyphs is decomposed.
9573
9574 @item
9575 The resulting elements are then concatenated with @samp{_} in between,
9576 dropping the leading @samp{u} in all elements but the first.
9577 @end itemize
9578
9579 No check for the existence of any component (similar to @code{tr}
9580 request) is done.
9581
9582 Examples:
9583
9584 @table @code
9585 @item \[A ho]
9586 @samp{A} maps to @code{u0041}, @samp{ho} maps to @code{u02DB}, thus the
9587 final glyph name would be @code{u0041_02DB}.  Note this is not the
9588 expected result: The ogonek glyph @samp{ho} is a spacing ogonek, but for
9589 a proper composite a non-spacing ogonek (U+0328) is necessary.  Looking
9590 into the file @file{composite.tmac} one can find @w{@samp{.composite ho
9591 u0328}}, which changes the mapping of @samp{ho} while a composite glyph
9592 name is constructed, causing the final glyph name to be
9593 @code{u0041_0328}.
9594
9595 @item \[^E u0301]
9596 @itemx \[^E aa]
9597 @itemx \[E a^ aa]
9598 @itemx \[E ^ ']
9599 @samp{^E} maps to @code{u0045_0302}, thus the final glyph name is
9600 @code{u0045_0302_0301} in all forms (assuming proper calls of the
9601 @code{composite} request).
9602 @end table
9603
9604 It is not possible to define glyphs with names like @w{@samp{A ho}}
9605 within a groff font file.  This is not really a limitation; instead, you
9606 have to define @code{u0041_0328}.
9607 @endDefesc
9608
9609 @Defesc {\\C, ', xxx, '}
9610 @cindex named character (@code{\C})
9611 @cindex character, named (@code{\C})
9612 Typeset the glyph named @var{xxx}.@footnote{@code{\C} is actually a
9613 misnomer since it accesses an output glyph.}  Normally it is more
9614 convenient to use @code{\[@var{xxx}]}, but @code{\C} has the advantage
9615 that it is compatible with newer versions of @acronym{AT&T} @code{troff}
9616 and is available in compatibility mode.
9617 @endDefesc
9618
9619 @Defreq {composite, from to}
9620 @pindex composite.tmac
9621 Map glyph name @var{from} to glyph name @var{to} if it is used in
9622 @code{\[...]} with more than one component.  See above for examples.
9623
9624 This mapping is based on glyph names only; no check for the existence of
9625 either glyph is done.
9626
9627 A set of default mappings for many accents can be found in the file
9628 @file{composite.tmac}, which is loaded at start-up.
9629 @endDefreq
9630
9631 @Defesc {\\N, ', n, '}
9632 @cindex numbered glyph (@code{\N})
9633 @cindex glyph, numbered (@code{\N})
9634 @cindex @code{char} request, used with @code{\N}
9635 @cindex Unicode
9636 Typeset the glyph with code@tie{}@var{n} in the current font
9637 (@code{n}@tie{}is @strong{not} the input character code).  The number
9638 @var{n}@tie{}can be any non-negative decimal integer.  Most devices only
9639 have glyphs with codes between 0 and@tie{}255; the Unicode output device
9640 uses codes in the range 0--65535.  If the current font does not contain
9641 a glyph with that code, special fonts are @emph{not} searched.  The
9642 @code{\N} escape sequence can be conveniently used in conjunction with
9643 the @code{char} request:
9644
9645 @Example
9646 .char \[phone] \f[ZD]\N'37'
9647 @endExample
9648
9649 @noindent
9650 @pindex DESC
9651 @cindex unnamed glyphs
9652 @cindex glyphs, unnamed
9653 The code of each glyph is given in the fourth column in the font
9654 description file after the @code{charset} command.  It is possible to
9655 include unnamed glyphs in the font description file by using a name of
9656 @samp{---}; the @code{\N} escape sequence is the only way to use these.
9657
9658 No kerning is applied to glyphs accessed with @code{\N}.
9659 @endDefesc
9660
9661 Some escape sequences directly map onto special glyphs.
9662
9663 @Defesc {\\', , , }
9664 This is a backslash followed by the apostrophe character,
9665 @acronym{ASCII} character @code{0x27} (@acronym{EBCDIC} character
9666 @code{0x7D}).  The same as @code{\[aa]}, the acute accent.
9667 @endDefesc
9668
9669 @Defesc {\\`, , , }
9670 This is a backslash followed by @acronym{ASCII} character @code{0x60}
9671 (@acronym{EBCDIC} character @code{0x79} usually).  The same as
9672 @code{\[ga]}, the grave accent.
9673 @endDefesc
9674
9675 @Defesc {\\-, , , }
9676 This is the same as @code{\[-]}, the minus sign in the current font.
9677 @endDefesc
9678
9679 @Defesc {\\_, , , }
9680 This is the same as @code{\[ul]}, the underline character.
9681 @endDefesc
9682
9683 @Defreq {cflags, n c1 c2 @dots{}}
9684 @cindex glyph properties (@code{cflags})
9685 @cindex character properties (@code{cflags})
9686 @cindex properties of glyphs (@code{cflags})
9687 @cindex properties of characters (@code{cflags})
9688 Input characters and symbols have certain properties associated with
9689 it.@footnote{Note that the output glyphs themselves don't have such
9690 properties.  For @code{gtroff}, a glyph is a numbered box with a given
9691 width, depth, and height, nothing else.  All manipulations with the
9692 @code{cflags} request work on the input level.}  These properties can be
9693 modified with the @code{cflags} request.  The first argument is the sum
9694 of the desired flags and the remaining arguments are the characters or
9695 symbols to have those properties.  It is possible to omit the spaces
9696 between the characters or symbols.  Instead of single characters or
9697 symbols you can also use character classes (see @ref{Character Classes}
9698 for more details).
9699
9700 @table @code
9701 @item 1
9702 @cindex end-of-sentence characters
9703 @cindex characters, end-of-sentence
9704 The character ends sentences (initially characters @samp{.?!} have this
9705 property).
9706
9707 @item 2
9708 @cindex hyphenating characters
9709 @cindex characters, hyphenation
9710 Lines can be broken before the character (initially no characters have
9711 this property).  This only works if both the characters before and after
9712 have non-zero hyphenation codes (as set with the @code{hcode} request).
9713 Use value@tie{}64 to override this behaviour.
9714
9715 @item 4
9716 @cindex @code{hy} glyph, and @code{cflags}
9717 @cindex @code{em} glyph, and @code{cflags}
9718 Lines can be broken after the character (initially the character
9719 @samp{-} and the symbols @samp{\[hy]} and @samp{\[em]} have this
9720 property).  This only works if both the characters before and after have
9721 non-zero hyphenation codes (as set with the @code{hcode} request).  Use
9722 value@tie{}64 to override this behaviour.
9723
9724 @item 8
9725 @cindex overlapping characters
9726 @cindex characters, overlapping
9727 @cindex @code{ul} glyph, and @code{cflags}
9728 @cindex @code{rn} glyph, and @code{cflags}
9729 @cindex @code{ru} glyph, and @code{cflags}
9730 @cindex @code{radicalex} glyph, and @code{cflags}
9731 @cindex @code{sqrtex} glyph, and @code{cflags}
9732 The character overlaps horizontally if used as a horizontal line
9733 building element.  Initially the symbols @samp{\[ul]}, @samp{\[rn]},
9734 @samp{\[ru]}, @samp{\[radicalex]}, and @samp{\[sqrtex]} have this
9735 property.
9736
9737 @item 16
9738 @cindex @code{br} glyph, and @code{cflags}
9739 The character overlaps vertically if used as vertical line building
9740 element.  Initially symbol @samp{\[br]} has this property.
9741
9742 @item 32
9743 @cindex transparent characters
9744 @cindex character, transparent
9745 @cindex @code{"}, at end of sentence
9746 @cindex @code{'}, at end of sentence
9747 @cindex @code{)}, at end of sentence
9748 @cindex @code{]}, at end of sentence
9749 @cindex @code{*}, at end of sentence
9750 @cindex @code{dg} glyph, at end of sentence
9751 @cindex @code{rq} glyph, at end of sentence
9752 @cindex @code{cq} glyph, at end of sentence
9753 An end-of-sentence character followed by any number of characters with
9754 this property is treated as the end of a sentence if followed by a
9755 newline or two spaces; in other words the character is @dfn{transparent}
9756 for the purposes of end-of-sentence recognition -- this is the same as
9757 having a zero space factor in @TeX{} (initially characters @samp{"')]*}
9758 and the symbols @samp{\[dg]}, @samp{\[rq]}, and @samp{\[cq]} have this
9759 property).
9760
9761 @item 64
9762 Ignore hyphenation code values of the surrounding characters.  Use this
9763 in combination with values 2 and@tie{}4 (initially no characters have
9764 this property).  For example, if you need an automatic break point after
9765 the en-dash in number ranges like `3000--5000', insert
9766
9767 @Example
9768 .cflags 68 \(en
9769 @endExample
9770
9771 @noindent
9772 into your document.  Note, however, that this can lead to bad layout if
9773 done without thinking; in most situations, a better solution instead of
9774 changing the @code{cflags} value is to insert @code{\:} right after the
9775 hyphen at the places that really need a break point.
9776
9777 @item 128
9778 Prohibit a line break before the character, but allow a line break after
9779 the character.  This works only in combination with flags 256 and 512
9780 (see below) and has no effect otherwise.
9781
9782 @item 256
9783 Prohibit a line break after the character, but allow a line break before
9784 the character.  This works only in combination with flags 128 and 512
9785 (see below) and has no effect otherwise.
9786
9787 @item 512
9788 Allow line break before or after the character.  This works only in
9789 combination with flags 128 and 256 and has no effect otherwise.
9790
9791 Contrary to flag values 2 and@tie{}4, the flags 128, 256, and 512 work
9792 pairwise.  If, for example, the left character has value 512, and the
9793 right character 128, no line break gets inserted.  If we use
9794 value@tie{}6 instead for the left character, a line break after the
9795 character can't be suppressed since the right neighbour character
9796 doesn't get examined.
9797 @end table
9798 @endDefreq
9799
9800 @DefreqList {char, g [@Var{string}]}
9801 @DefreqItemx {fchar, g [@Var{string}]}
9802 @DefreqItemx {fschar, f g [@Var{string}]}
9803 @DefreqListEndx {schar, g [@Var{string}]}
9804 @cindex defining character (@code{char})
9805 @cindex defining fallback character (@code{fchar}, @code{fschar}, @code{schar})
9806 @cindex character, defining (@code{char})
9807 @cindex character, defining fallback (@code{fchar}, @code{fschar}, @code{schar})
9808 @cindex fallback character, defining (@code{fchar}, @code{fschar}, @code{schar})
9809 @cindex creating new characters (@code{char})
9810 @cindex defining symbol (@code{char})
9811 @cindex symbol, defining (@code{char})
9812 @cindex defining glyph (@code{char})
9813 @cindex glyph, defining (@code{char})
9814 @cindex escape character, while defining glyph
9815 @cindex character, escape, while defining glyph
9816 @cindex @code{tr} request, and glyph definitions
9817 @cindex @code{cp} request, and glyph definitions
9818 @cindex @code{rc} request, and glyph definitions
9819 @cindex @code{lc} request, and glyph definitions
9820 @cindex @code{\l}, and glyph definitions
9821 @cindex @code{\L}, and glyph definitions
9822 @cindex @code{\&}, and glyph definitions
9823 @cindex @code{\e}, and glyph definitions
9824 @cindex @code{hcode} request, and glyph definitions
9825 Define a new glyph@tie{}@var{g} to be @var{string} (which can be
9826 empty).@footnote{@code{char} is a misnomer since an output glyph is
9827 defined.}  Every time glyph@tie{}@var{g} needs to be printed,
9828 @var{string} is processed in a temporary environment and the result is
9829 wrapped up into a single object.  Compatibility mode is turned off and
9830 the escape character is set to @samp{\} while @var{string} is being
9831 processed.  Any emboldening, constant spacing or track kerning is
9832 applied to this object rather than to individual characters in
9833 @var{string}.
9834
9835 A glyph defined by these requests can be used just like a normal glyph
9836 provided by the output device.  In particular, other characters can be
9837 translated to it with the @code{tr} or @code{trin} requests; it can be
9838 made the leader character by the @code{lc} request; repeated patterns
9839 can be drawn with the glyph using the @code{\l} and @code{\L} escape
9840 sequences; words containing the glyph can be hyphenated correctly if the
9841 @code{hcode} request is used to give the glyph's symbol a hyphenation
9842 code.
9843
9844 There is a special anti-recursion feature: Use of @code{g} within the
9845 glyph's definition is handled like normal characters and symbols not
9846 defined with @code{char}.
9847
9848 Note that the @code{tr} and @code{trin} requests take precedence if
9849 @code{char} accesses the same symbol.
9850
9851 @Example
9852 .tr XY
9853 X
9854     @result{} Y
9855 .char X Z
9856 X
9857     @result{} Y
9858 .tr XX
9859 X
9860     @result{} Z
9861 @endExample
9862
9863 The @code{fchar} request defines a fallback glyph: @code{gtroff} only
9864 checks for glyphs defined with @code{fchar} if it cannot find the glyph
9865 in the current font.  @code{gtroff} carries out this test before
9866 checking special fonts.
9867
9868 @code{fschar} defines a fallback glyph for font@tie{}@var{f}:
9869 @code{gtroff} checks for glyphs defined with @code{fschar} after the
9870 list of fonts declared as font-specific special fonts with the
9871 @code{fspecial} request, but before the list of fonts declared as global
9872 special fonts with the @code{special} request.
9873
9874 Finally, the @code{schar} request defines a global fallback glyph:
9875 @code{gtroff} checks for glyphs defined with @code{schar} after the list
9876 of fonts declared as global special fonts with the @code{special}
9877 request, but before the already mounted special fonts.
9878
9879 @xref{Using Symbols}, for a detailed description of the glyph searching
9880 mechanism in @code{gtroff}.
9881 @endDefreq
9882
9883 @DefreqList {rchar, c1 c2 @dots{}}
9884 @DefreqListEndx {rfschar, f c1 c2 @dots{}}
9885 @cindex removing glyph definition (@code{rchar}, @code{rfschar})
9886 @cindex glyph, removing definition (@code{rchar}, @code{rfschar})
9887 @cindex fallback glyph, removing definition (@code{rchar}, @code{rfschar})
9888 Remove the definitions of glyphs @var{c1}, @var{c2},@tie{}@enddots{}
9889 This undoes the effect of a @code{char}, @code{fchar}, or @code{schar}
9890 request.
9891
9892 It is possible to omit the whitespace between arguments.
9893
9894 The request @code{rfschar} removes glyph definitions defined with
9895 @code{fschar} for glyph@tie{}f.
9896 @endDefreq
9897
9898 @xref{Special Characters}.
9899
9900 @c ---------------------------------------------------------------------
9901
9902 @node Character Classes, Special Fonts, Using Symbols, Fonts and Symbols
9903 @subsection Character Classes
9904 @cindex character classes
9905 @cindex classes, character
9906
9907 Classes are particularly useful for East Asian languages such as
9908 Chinese, Japanese, and Korean, where the number of needed characters is
9909 much larger than in European languages, and where large sets of
9910 characters share the same properties.
9911
9912 @Defreq {class, n c1 c2 @dots{}}
9913 @cindex character class (@code{class})
9914 @cindex defining character class (@code{class})
9915 @cindex class of characters (@code{class})
9916 In @code{groff}, a @dfn{character class} (or simply ``class'') is a set
9917 of characters, grouped by some user aspect.  The @code{class} request
9918 defines such classes so that other requests can refer to all characters
9919 belonging to this set with a single class name.  Currently, only the
9920 @code{cflags} request can handle character classes.
9921
9922 A @code{class} request takes a class name followed by a list of
9923 entities.  In its simplest form, the entities are characters or symbols:
9924
9925 @Example
9926 .class [prepunct] , : ; > @}
9927 @endExample
9928
9929 Since class and glyph names share the same namespace, it is recommended
9930 to start and end the class name with @code{[} and @code{]},
9931 respectively, to avoid collisions with normal @code{groff} symbols (and
9932 symbols defined by the user).  In particular, the presence of @code{]}
9933 in the symbol name intentionally prevents the usage of @code{\[...]},
9934 thus you must use the @code{\C} escape to access a class with such a
9935 name.
9936
9937 @cindex GGL (groff glyph list)
9938 @cindex groff glyph list (GGL)
9939 You can also use a special character range notation, consisting of a
9940 start character or symbol, followed by @samp{-}, and an end character or
9941 symbol.  Internally, @code{gtroff} converts these two symbol names to
9942 Unicode values (according to the groff glyph gist), which then give the
9943 start and end value of the range.  If that fails, the class definition
9944 is skipped.
9945
9946 Finally, classes can be nested, too.
9947
9948 Here is a more complex example:
9949
9950 @Example
9951 .class [prepunctx] \C'[prepunct]' \[u2013]-\[u2016]
9952 @endExample
9953
9954 The class @samp{prepunctx} now contains the contents of the class
9955 @code{prepunct} as defined above (the set @samp{, : ; > @}}), and
9956 characters in the range between @code{U+2013} and @code{U+2016}.
9957
9958 If you want to add @samp{-} to a class, it must be the first character
9959 value in the argument list, otherwise it gets misinterpreted as a range.
9960
9961 Note that it is not possible to use class names within range
9962 definitions.
9963
9964 Typical use of the @code{class} request is to control line-breaking and
9965 hyphenation rules as defined by the @code{cflags} request.  For example,
9966 to inhibit line breaks before the characters belonging to the
9967 @code{prepunctx} class, you can write:
9968
9969 @Example
9970 .cflags 2 \C'[prepunctx]'
9971 @endExample
9972
9973 See the @code{cflags} request in @ref{Using Symbols}, for more details.
9974 @endDefreq
9975
9976 @c ---------------------------------------------------------------------
9977
9978 @node Special Fonts, Artificial Fonts, Character Classes, Fonts and Symbols
9979 @subsection Special Fonts
9980 @cindex special fonts
9981 @cindex fonts, special
9982
9983 Special fonts are those that @code{gtroff} searches when it cannot find
9984 the requested glyph in the current font.  The Symbol font is usually a
9985 special font.
9986
9987 @code{gtroff} provides the following two requests to add more special
9988 fonts.  @xref{Using Symbols}, for a detailed description of the glyph
9989 searching mechanism in @code{gtroff}.
9990
9991 Usually, only non-TTY devices have special fonts.
9992
9993 @DefreqList {special, [@Var{s1} @Var{s2} @dots{}]}
9994 @DefreqListEndx {fspecial, f [@Var{s1} @Var{s2} @dots{}]}
9995 @kindex fonts
9996 @pindex DESC
9997 Use the @code{special} request to define special fonts.  Initially, this
9998 list is empty.
9999
10000 Use the @code{fspecial} request to designate special fonts only when
10001 font@tie{}@var{f} is active.  Initially, this list is empty.
10002
10003 Previous calls to @code{special} or @code{fspecial} are overwritten;
10004 without arguments, the particular list of special fonts is set to empty.
10005 Special fonts are searched in the order they appear as arguments.
10006
10007 All fonts that appear in a call to @code{special} or @code{fspecial}
10008 are loaded.
10009
10010 @xref{Using Symbols}, for the exact search order of glyphs.
10011 @endDefreq
10012
10013 @c ---------------------------------------------------------------------
10014
10015 @node Artificial Fonts, Ligatures and Kerning, Special Fonts, Fonts and Symbols
10016 @subsection Artificial Fonts
10017 @cindex artificial fonts
10018 @cindex fonts, artificial
10019
10020 There are a number of requests and escapes for artificially creating
10021 fonts.  These are largely vestiges of the days when output devices did
10022 not have a wide variety of fonts, and when @code{nroff} and @code{troff}
10023 were separate programs.  Most of them are no longer necessary in GNU
10024 @code{troff}.  Nevertheless, they are supported.
10025
10026 @DefescList {\\H, ', height, '}
10027 @DefescItem {\\H, ', @t{+}height, '}
10028 @DefescItem {\\H, ', @t{-}height, '}
10029 @DefregListEndx {.height}
10030 @cindex changing the font height (@code{\H})
10031 @cindex font height, changing (@code{\H})
10032 @cindex height, font, changing (@code{\H})
10033 Change (increment, decrement) the height of the current font, but not
10034 the width.  If @var{height} is zero, restore the original height.
10035 Default scaling indicator is @samp{z}.
10036
10037 The read-only number register @code{.height} contains the font height as
10038 set by @code{\H}.
10039
10040 Currently, only the @option{-Tps} and @option{-Tpdf} devices support
10041 this feature.
10042
10043 Note that @code{\H} doesn't produce an input token in @code{gtroff}.  As
10044 a consequence, it can be used in requests like @code{mc} (which expects
10045 a single character as an argument) to change the font on the fly:
10046
10047 @Example
10048 .mc \H'+5z'x\H'0'
10049 @endExample
10050
10051 In compatibility mode, @code{gtroff} behaves differently: If an
10052 increment or decrement is used, it is always taken relative to the
10053 current point size and not relative to the previously selected font
10054 height.  Thus,
10055
10056 @Example
10057 .cp 1
10058 \H'+5'test \H'+5'test
10059 @endExample
10060
10061 @noindent
10062 prints the word @samp{test} twice with the same font height (five points
10063 larger than the current font size).
10064 @endDefesc
10065
10066 @DefescList {\\S, ', slant, '}
10067 @DefregListEndx {.slant}
10068 @cindex changing the font slant (@code{\S})
10069 @cindex font slant, changing (@code{\S})
10070 @cindex slant, font, changing (@code{\S})
10071 Slant the current font by @var{slant} degrees.  Positive values slant to
10072 the right.  Only integer values are possible.
10073
10074 The read-only number register @code{.slant} contains the font slant as
10075 set by @code{\S}.
10076
10077 Currently, only the @option{-Tps} and @option{-Tpdf} devices support
10078 this feature.
10079
10080 Note that @code{\S} doesn't produce an input token in @code{gtroff}.  As
10081 a consequence, it can be used in requests like @code{mc} (which expects
10082 a single character as an argument) to change the font on the fly:
10083
10084 @Example
10085 .mc \S'20'x\S'0'
10086 @endExample
10087
10088 This request is incorrectly documented in the original Unix troff
10089 manual; the slant is always set to an absolute value.
10090 @endDefesc
10091
10092 @Defreq {ul, [@Var{lines}]}
10093 @cindex underlining (@code{ul})
10094 The @code{ul} request normally underlines subsequent lines if a TTY
10095 output device is used.  Otherwise, the lines are printed in italics
10096 (only the term `underlined' is used in the following).  The single
10097 argument is the number of input lines to be underlined; with no
10098 argument, the next line is underlined.  If @var{lines} is zero or
10099 negative, stop the effects of @code{ul} (if it was active).  Requests
10100 and empty lines do not count for computing the number of underlined
10101 input lines, even if they produce some output like @code{tl}.  Lines
10102 inserted by macros (e.g.@: invoked by a trap) do count.
10103
10104 At the beginning of @code{ul}, the current font is stored and the
10105 underline font is activated.  Within the span of a @code{ul} request, it
10106 is possible to change fonts, but after the last line affected by
10107 @code{ul} the saved font is restored.
10108
10109 This number of lines still to be underlined is associated with the
10110 current environment (@pxref{Environments}).  The underline font can be
10111 changed with the @code{uf} request.
10112
10113 @c XXX @xref should be changed to grotty
10114
10115 @c @xref{Troff and Nroff Mode}, for a discussion how underlining is
10116 @c implemented in for TTY output devices, and which problems can arise.
10117
10118 The @code{ul} request does not underline spaces.
10119 @endDefreq
10120
10121 @Defreq {cu, [@Var{lines}]}
10122 @cindex continuous underlining (@code{cu})
10123 @cindex underlining, continuous (@code{cu})
10124 The @code{cu} request is similar to @code{ul} but underlines spaces as
10125 well (if a TTY output device is used).
10126 @endDefreq
10127
10128 @Defreq {uf, font}
10129 @cindex underline font (@code{uf})
10130 @cindex font for underlining (@code{uf})
10131 Set the underline font (globally) used by @code{ul} and @code{cu}.  By
10132 default, this is the font at position@tie{}2.  @var{font} can be either
10133 a non-negative font position or the name of a font.
10134 @endDefreq
10135
10136 @DefreqList {bd, font [@Var{offset}]}
10137 @DefreqItem {bd, font1 font2 [@Var{offset}]}
10138 @DefregListEndx {.b}
10139 @cindex imitating bold face (@code{bd})
10140 @cindex bold face, imitating (@code{bd})
10141 Artificially create a bold font by printing each glyph twice, slightly
10142 offset.
10143
10144 Two syntax forms are available.
10145
10146 @itemize @bullet
10147 @item
10148 Imitate a bold font unconditionally.  The first argument specifies the
10149 font to embolden, and the second is the number of basic units, minus
10150 one, by which the two glyphs are offset.  If the second argument is
10151 missing, emboldening is turned off.
10152
10153 @var{font} can be either a non-negative font position or the name of a
10154 font.
10155
10156 @var{offset} is available in the @code{.b} read-only register if a
10157 special font is active; in the @code{bd} request, its default unit is
10158 @samp{u}.
10159
10160 @cindex @code{fspecial} request, and imitating bold
10161 @kindex special
10162 @cindex embolding of special fonts
10163 @cindex special fonts, emboldening
10164 @item
10165 Imitate a bold form conditionally.  Embolden @var{font1} by @var{offset}
10166 only if font @var{font2} is the current font.  This command can be
10167 issued repeatedly to set up different emboldening values for different
10168 current fonts.  If the second argument is missing, emboldening is turned
10169 off for this particular current font.
10170
10171 This affects special fonts only (either set up with the @code{special}
10172 command in font files or with the @code{fspecial} request).
10173 @end itemize
10174 @endDefreq
10175
10176 @Defreq {cs, font [@Var{width} [@Var{em-size}]]}
10177 @cindex constant glyph space mode (@code{cs})
10178 @cindex mode for constant glyph space (@code{cs})
10179 @cindex glyph, constant space
10180 @cindex @code{ps} request, and constant glyph space mode
10181 Switch to and from @dfn{constant glyph space mode}.  If activated, the
10182 width of every glyph is @math{@var{width}/36} ems.  The em size is given
10183 absolutely by @var{em-size}; if this argument is missing, the em value
10184 is taken from the current font size (as set with the @code{ps} request)
10185 when the font is effectively in use.  Without second and third argument,
10186 constant glyph space mode is deactivated.
10187
10188 Default scaling indicator for @var{em-size} is @samp{z}; @var{width} is
10189 an integer.
10190 @endDefreq
10191
10192 @c ---------------------------------------------------------------------
10193
10194 @node Ligatures and Kerning,  , Artificial Fonts, Fonts and Symbols
10195 @subsection Ligatures and Kerning
10196 @cindex ligatures and kerning
10197 @cindex kerning and ligatures
10198
10199 Ligatures are groups of characters that are run together, i.e, producing
10200 a single glyph.  For example, the letters `f' and `i' can form a
10201 ligature `fi' as in the word `file'.  This produces a cleaner look
10202 (albeit subtle) to the printed output.  Usually, ligatures are not
10203 available in fonts for TTY output devices.
10204
10205 Most @sc{PostScript} fonts support the fi and fl ligatures.  The C/A/T
10206 typesetter that was the target of @acronym{AT&T} @code{troff} also
10207 supported `ff', `ffi', and `ffl' ligatures.  Advanced typesetters or
10208 `expert' fonts may include ligatures for `ft' and `ct', although GNU
10209 @code{troff} does not support these (yet).
10210
10211 Only the current font is checked for ligatures and kerns; neither
10212 special fonts nor entities defined with the @code{char} request (and its
10213 siblings) are taken into account.
10214
10215 @DefreqList {lg, [@Var{flag}]}
10216 @DefregListEndx {.lg}
10217 @cindex activating ligatures (@code{lg})
10218 @cindex ligatures, activating (@code{lg})
10219 @cindex ligatures enabled register (@code{.lg})
10220 Switch the ligature mechanism on or off; if the parameter is non-zero or
10221 missing, ligatures are enabled, otherwise disabled.  Default is on.  The
10222 current ligature mode can be found in the read-only number register
10223 @code{.lg} (set to 1 or@tie{}2 if ligatures are enabled,
10224 0@tie{}otherwise).
10225
10226 Setting the ligature mode to@tie{}2 enables the two-character ligatures
10227 (fi, fl, and ff) and disables the three-character ligatures (ffi and
10228 ffl).
10229 @endDefreq
10230
10231 @dfn{Pairwise kerning} is another subtle typesetting mechanism that
10232 modifies the distance between a glyph pair to improve readability.  In
10233 most cases (but not always) the distance is decreased.
10234 @iftex
10235 For example, compare the combination of the letters `V' and `A'.  With
10236 kerning, `VA' is printed.  Without kerning it appears as `V@w{}A'.
10237 @end iftex
10238 Typewriter-like fonts and fonts for terminals where all glyphs have the
10239 same width don't use kerning.
10240
10241 @DefreqList {kern, [@Var{flag}]}
10242 @DefregListEndx {.kern}
10243 @cindex activating kerning (@code{kern})
10244 @cindex kerning, activating (@code{kern})
10245 @cindex kerning enabled register (@code{.kern})
10246 Switch kerning on or off.  If the parameter is non-zero or missing,
10247 enable pairwise kerning, otherwise disable it.  The read-only number
10248 register @code{.kern} is set to@tie{}1 if pairwise kerning is enabled,
10249 0@tie{}otherwise.
10250
10251 @cindex zero width space character (@code{\&})
10252 @cindex character, zero width space (@code{\&})
10253 @cindex space character, zero width (@code{\&})
10254 If the font description file contains pairwise kerning information,
10255 glyphs from that font are kerned.  Kerning between two glyphs can be
10256 inhibited by placing @code{\&} between them: @samp{V\&A}.
10257
10258 @xref{Font File Format}.
10259 @endDefreq
10260
10261 @cindex track kerning
10262 @cindex kerning, track
10263 @dfn{Track kerning} expands or reduces the space between glyphs.  This
10264 can be handy, for example, if you need to squeeze a long word onto a
10265 single line or spread some text to fill a narrow column.  It must be
10266 used with great care since it is usually considered bad typography if
10267 the reader notices the effect.
10268
10269 @Defreq {tkf, f s1 n1 s2 n2}
10270 @cindex activating track kerning (@code{tkf})
10271 @cindex track kerning, activating (@code{tkf})
10272 Enable track kerning for font@tie{}@var{f}.  If the current font
10273 is@tie{}@var{f} the width of every glyph is increased by an amount
10274 between @var{n1} and @var{n2} (@var{n1}, @var{n2} can be negative); if
10275 the current point size is less than or equal to @var{s1} the width is
10276 increased by @var{n1}; if it is greater than or equal to @var{s2} the
10277 width is increased by @var{n2}; if the point size is greater than or
10278 equal to @var{s1} and less than or equal to @var{s2} the increase in
10279 width is a linear function of the point size.
10280
10281 The default scaling indicator is @samp{z} for @var{s1} and @var{s2},
10282 @samp{p} for @var{n1} and @var{n2}.
10283
10284 Note that the track kerning amount is added even to the rightmost glyph
10285 in a line; for large values it is thus recommended to increase the line
10286 length by the same amount to compensate it.
10287 @endDefreq
10288
10289 Sometimes, when typesetting letters of different fonts, more or less
10290 space at such boundaries is needed.  There are two escapes to help with
10291 this.
10292
10293 @Defesc {\\/, , , }
10294 @cindex italic correction (@code{\/})
10295 @cindex correction, italic (@code{\/})
10296 @cindex correction between italic and roman glyph (@code{\/}, @code{\,})
10297 @cindex roman glyph, correction after italic glyph (@code{\/})
10298 @cindex italic glyph, correction before roman glyph (@code{\/})
10299 @cindex glyph, italic correction (@code{\/})
10300 Increase the width of the preceding glyph so that the spacing between
10301 that glyph and the following glyph is correct if the following glyph is
10302 a roman glyph.  For example, if an italic@tie{}@code{f} is immediately
10303 followed by a roman right parenthesis, then in many fonts the top right
10304 portion of the@tie{}@code{f} overlaps the top left of the right
10305 parenthesis.  Use this escape sequence whenever an italic glyph is
10306 immediately followed by a roman glyph without any intervening space.
10307 This small amount of space is also called @dfn{italic correction}.
10308
10309 @iftex
10310 @c can't use @Example...@endExample here
10311 @example
10312 @group
10313 \f[I]f\f[R])
10314     @result{} {@it f}@r{)}
10315 \f[I]f\/\f[R])
10316     @result{} @i{f}@r{)}
10317 @end group
10318 @end example
10319 @end iftex
10320 @endDefesc
10321
10322 @Defesc {\\\,, , , }
10323 @cindex left italic correction (@code{\,})
10324 @cindex correction, left italic (@code{\,})
10325 @cindex glyph, left italic correction (@code{\,})
10326 @cindex roman glyph, correction before italic glyph (@code{\,})
10327 @cindex italic glyph, correction after roman glyph (@code{\,})
10328 Modify the spacing of the following glyph so that the spacing between
10329 that glyph and the preceding glyph is correct if the preceding glyph is
10330 a roman glyph.  Use this escape sequence whenever a roman glyph is
10331 immediately followed by an italic glyph without any intervening space.
10332 In analogy to above, this space could be called @dfn{left italic
10333 correction}, but this term isn't used widely.
10334
10335 @iftex
10336 @c can't use @Example...@endExample here
10337 @example
10338 @group
10339 q\f[I]f
10340     @result{} @r{q}@i{f}
10341 q\,\f[I]f
10342     @result{} @r{q}@math{@ptexcomma}@i{f}
10343 @end group
10344 @end example
10345 @end iftex
10346 @endDefesc
10347
10348 @Defesc {\\&, , , }
10349 Insert a zero-width character, which is invisible.  Its intended use is
10350 to stop interaction of a character with its surroundings.
10351
10352 @itemize @bullet
10353 @item
10354 It prevents the insertion of extra space after an end-of-sentence
10355 character.
10356
10357 @Example
10358 Test.
10359 Test.
10360     @result{} Test.  Test.
10361 Test.\&
10362 Test.
10363     @result{} Test. Test.
10364 @endExample
10365
10366 @item
10367 It prevents interpretation of a control character at the beginning of an
10368 input line.
10369
10370 @Example
10371 .Test
10372     @result{} warning: `Test' not defined
10373 \&.Test
10374     @result{} .Test
10375 @endExample
10376
10377 @item
10378 It prevents kerning between two glyphs.
10379
10380 @iftex
10381 @c can't use @Example...@endExample here
10382 @example
10383 @group
10384 VA
10385     @result{} @r{VA}
10386 V\&A
10387     @result{} @r{V@w{}A}
10388 @end group
10389 @end example
10390 @end iftex
10391
10392 @item
10393 It is needed to map an arbitrary character to nothing in the @code{tr}
10394 request (@pxref{Character Translations}).
10395 @end itemize
10396 @endDefesc
10397
10398 @Defesc {\\), , , }
10399 This escape is similar to @code{\&} except that it behaves like a
10400 character declared with the @code{cflags} request to be transparent for
10401 the purposes of an end-of-sentence character.
10402
10403 Its main usage is in macro definitions to protect against arguments
10404 starting with a control character.
10405
10406 @Example
10407 .de xxx
10408 \)\\$1
10409 ..
10410 .de yyy
10411 \&\\$1
10412 ..
10413 This is a test.\c
10414 .xxx '
10415 This is a test.
10416     @result{}This is a test.'  This is a test.
10417 This is a test.\c
10418 .yyy '
10419 This is a test.
10420     @result{}This is a test.' This is a test.
10421 @endExample
10422 @endDefesc
10423
10424
10425 @c =====================================================================
10426
10427 @node Sizes, Strings, Fonts and Symbols, gtroff Reference
10428 @section Sizes
10429 @cindex sizes
10430
10431 @cindex baseline
10432 @cindex type size
10433 @cindex size of type
10434 @cindex vertical spacing
10435 @cindex spacing, vertical
10436 @code{gtroff} uses two dimensions with each line of text, type size and
10437 vertical spacing.  The @dfn{type size} is approximately the height of
10438 the tallest glyph.@footnote{This is usually the parenthesis.  Note that
10439 in most cases the real dimensions of the glyphs in a font are @emph{not}
10440 related to its type size!  For example, the standard @sc{PostScript}
10441 font families `Times Roman', `Helvetica', and `Courier' can't be used
10442 together at 10@dmn{pt}; to get acceptable output, the size of
10443 `Helvetica' has to be reduced by one point, and the size of `Courier'
10444 must be increased by one point.}  @dfn{Vertical spacing} is the amount
10445 of space @code{gtroff} allows for a line of text; normally, this is
10446 about 20%@tie{}larger than the current type size.  Ratios smaller than
10447 this can result in hard-to-read text; larger than this, it spreads the
10448 text out more vertically (useful for term papers).  By default,
10449 @code{gtroff} uses 10@tie{}point type on 12@tie{}point spacing.
10450
10451 @cindex leading
10452 The difference between type size and vertical spacing is known, by
10453 typesetters, as @dfn{leading} (this is pronounced `ledding').
10454
10455 @menu
10456 * Changing Type Sizes::
10457 * Fractional Type Sizes::
10458 @end menu
10459
10460 @c ---------------------------------------------------------------------
10461
10462 @node Changing Type Sizes, Fractional Type Sizes, Sizes, Sizes
10463 @subsection Changing Type Sizes
10464
10465 @DefreqList {ps, [@Var{size}]}
10466 @DefreqItem {ps, @t{+}@Var{size}}
10467 @DefreqItem {ps, @t{-}@Var{size}}
10468 @DefescItemx {\\s, , size, }
10469 @DefregListEndx {.s}
10470 @cindex changing type sizes (@code{ps}, @code{\s})
10471 @cindex type sizes, changing (@code{ps}, @code{\s})
10472 @cindex point sizes, changing (@code{ps}, @code{\s})
10473 Use the @code{ps} request or the @code{\s} escape to change (increase,
10474 decrease) the type size (in points).  Specify @var{size} as either an
10475 absolute point size, or as a relative change from the current size.  The
10476 size@tie{}0 (for both @code{.ps} and @code{\s}), or no argument (for
10477 @code{.ps} only), goes back to the previous size.
10478
10479 Default scaling indicator of @code{size} is @samp{z}.  If @code{size} is
10480 negative, it is set to 1@dmn{u}.
10481
10482 @cindex type size registers (@code{.s}, @code{.ps})
10483 @cindex point size registers (@code{.s}, @code{.ps})
10484 The read-only number register @code{.s} returns the point size in points
10485 as a decimal fraction.  This is a string.  To get the point size in
10486 scaled points, use the @code{.ps} register instead.
10487
10488 @code{.s} is associated with the current environment
10489 (@pxref{Environments}).
10490
10491 @Example
10492 snap, snap,
10493 .ps +2
10494 grin, grin,
10495 .ps +2
10496 wink, wink, \s+2nudge, nudge,\s+8 say no more!
10497 .ps 10
10498 @endExample
10499
10500 The @code{\s} escape may be called in a variety of ways.  Much like
10501 other escapes there must be a way to determine where the argument ends
10502 and the text begins.  Any of the following forms are valid:
10503
10504 @table @code
10505 @item \s@var{n}
10506 Set the point size to @var{n}@tie{}points.  @var{n}@tie{}must be either
10507 0 or in the range 4 to@tie{}39.
10508
10509 @item \s+@var{n}
10510 @itemx \s-@var{n}
10511 Increase or decrease the point size by @var{n}@tie{}points.
10512 @var{n}@tie{}must be exactly one digit.
10513
10514 @item \s(@var{nn}
10515 Set the point size to @var{nn}@tie{}points.  @var{nn} must be exactly
10516 two digits.
10517
10518 @item \s+(@var{nn}
10519 @itemx \s-(@var{nn}
10520 @itemx \s(+@var{nn}
10521 @itemx \s(-@var{nn}
10522 Increase or decrease the point size by @var{nn}@tie{}points.  @var{nn}
10523 must be exactly two digits.
10524 @end table
10525
10526 Note that @code{\s} doesn't produce an input token in @code{gtroff}.  As
10527 a consequence, it can be used in requests like @code{mc} (which expects
10528 a single character as an argument) to change the font on the fly:
10529
10530 @Example
10531 .mc \s[20]x\s[0]
10532 @endExample
10533
10534 @xref{Fractional Type Sizes}, for yet another syntactical form of using
10535 the @code{\s} escape.
10536 @endDefreq
10537
10538 @Defreq {sizes, s1 s2 @dots{} sn [0]}
10539 Some devices may only have certain permissible sizes, in which case
10540 @code{gtroff} rounds to the nearest permissible size.  The @file{DESC}
10541 file specifies which sizes are permissible for the device.
10542
10543 Use the @code{sizes} request to change the permissible sizes for the
10544 current output device.  Arguments are in scaled points; the
10545 @code{sizescale} line in the @file{DESC} file for the output device
10546 provides the scaling factor.  For example, if the scaling factor is
10547 1000, then the value 12000 is 12@tie{}points.
10548
10549 Each argument can be a single point size (such as @samp{12000}), or a
10550 range of sizes (such as @samp{4000-72000}).  You can optionally end the
10551 list with a zero.
10552 @endDefreq
10553
10554 @DefreqList {vs, [@Var{space}]}
10555 @DefreqItem {vs, @t{+}@Var{space}}
10556 @DefreqItem {vs, @t{-}@Var{space}}
10557 @DefregListEndx {.v}
10558 @cindex changing vertical line spacing (@code{vs})
10559 @cindex vertical line spacing, changing (@code{vs})
10560 @cindex vertical line spacing register (@code{.v})
10561 Change (increase, decrease) the vertical spacing by @var{space}.  The
10562 default scaling indicator is @samp{p}.
10563
10564 If @code{vs} is called without an argument, the vertical spacing is
10565 reset to the previous value before the last call to @code{vs}.
10566
10567 @cindex @code{.V} register, and @code{vs}
10568 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
10569 negative; the vertical spacing is then set to smallest positive value,
10570 the vertical resolution (as given in the @code{.V} register).
10571
10572 Note that @w{@samp{.vs 0}} isn't saved in a diversion since it doesn't
10573 result in a vertical motion.  You explicitly have to repeat this command
10574 before inserting the diversion.
10575
10576 The read-only number register @code{.v} contains the current vertical
10577 spacing; it is associated with the current environment
10578 (@pxref{Environments}).
10579 @endDefreq
10580
10581 @cindex vertical line spacing, effective value
10582 The effective vertical line spacing consists of four components.
10583 Breaking a line causes the following actions (in the given order).
10584
10585 @itemize @bullet
10586 @item
10587 @cindex extra pre-vertical line space (@code{\x})
10588 @cindex line space, extra pre-vertical (@code{\x})
10589 Move the current point vertically by the @dfn{extra pre-vertical line
10590 space}.  This is the minimum value of all @code{\x} escapes with a
10591 negative argument in the current output line.
10592
10593 @item
10594 Move the current point vertically by the vertical line spacing as set
10595 with the @code{vs} request.
10596
10597 @item
10598 Output the current line.
10599
10600 @item
10601 @cindex extra post-vertical line space (@code{\x})
10602 @cindex line space, extra post-vertical (@code{\x})
10603 Move the current point vertically by the @dfn{extra post-vertical line
10604 space}.  This is the maximum value of all @code{\x} escapes with a
10605 positive argument in the line that has just been output.
10606
10607 @item
10608 @cindex post-vertical line spacing
10609 @cindex line spacing, post-vertical (@code{pvs})
10610 Move the current point vertically by the @dfn{post-vertical line
10611 spacing} as set with the @code{pvs} request.
10612 @end itemize
10613
10614 @cindex double-spacing (@code{vs}, @code{pvs})
10615 It is usually better to use @code{vs} or @code{pvs} instead of @code{ls}
10616 to produce double-spaced documents: @code{vs} and @code{pvs} have a
10617 finer granularity for the inserted vertical space compared to @code{ls};
10618 furthermore, certain preprocessors assume single-spacing.
10619
10620 @xref{Manipulating Spacing}, for more details on the @code{\x} escape
10621 and the @code{ls} request.
10622
10623 @DefreqList {pvs, [@Var{space}]}
10624 @DefreqItem {pvs, @t{+}@Var{space}}
10625 @DefreqItem {pvs, @t{-}@Var{space}}
10626 @DefregListEndx {.pvs}
10627 @cindex @code{ls} request, alternative to (@code{pvs})
10628 @cindex post-vertical line spacing, changing (@code{pvs})
10629 @cindex post-vertical line spacing register (@code{.pvs})
10630 Change (increase, decrease) the post-vertical spacing by @var{space}.
10631 The default scaling indicator is @samp{p}.
10632
10633 If @code{pvs} is called without an argument, the post-vertical spacing
10634 is reset to the previous value before the last call to @code{pvs}.
10635
10636 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
10637 zero or negative; the vertical spacing is then set to zero.
10638
10639 The read-only number register @code{.pvs} contains the current
10640 post-vertical spacing; it is associated with the current environment
10641 (@pxref{Environments}).
10642 @endDefreq
10643
10644 @c ---------------------------------------------------------------------
10645
10646 @node Fractional Type Sizes,  , Changing Type Sizes, Sizes
10647 @subsection Fractional Type Sizes
10648 @cindex fractional type sizes
10649 @cindex fractional point sizes
10650 @cindex type sizes, fractional
10651 @cindex point sizes, fractional
10652 @cindex sizes, fractional
10653
10654 @cindex @code{s} unit
10655 @cindex unit, @code{s}
10656 @cindex @code{z} unit
10657 @cindex unit, @code{z}
10658 @cindex @code{ps} request, with fractional type sizes
10659 @cindex @code{cs} request, with fractional type sizes
10660 @cindex @code{tkf} request, with fractional type sizes
10661 @cindex @code{\H}, with fractional type sizes
10662 @cindex @code{\s}, with fractional type sizes
10663 A @dfn{scaled point} is equal to @math{1/@var{sizescale}} points, where
10664 @var{sizescale} is specified in the @file{DESC} file (1@tie{}by
10665 default).  There is a new scale indicator @samp{z}, which has the effect
10666 of multiplying by @var{sizescale}.  Requests and escape sequences in
10667 @code{gtroff} interpret arguments that represent a point size as being
10668 in units of scaled points, but they evaluate each such argument using a
10669 default scale indicator of @samp{z}.  Arguments treated in this way are
10670 the argument to the @code{ps} request, the third argument to the
10671 @code{cs} request, the second and fourth arguments to the @code{tkf}
10672 request, the argument to the @code{\H} escape sequence, and those
10673 variants of the @code{\s} escape sequence that take a numeric expression
10674 as their argument (see below).
10675
10676 For example, suppose @var{sizescale} is@tie{}1000; then a scaled point
10677 is equivalent to a millipoint; the request @w{@samp{.ps 10.25}} is
10678 equivalent to @w{@samp{.ps 10.25z}} and thus sets the point size to
10679 10250@tie{}scaled points, which is equal to 10.25@tie{}points.
10680
10681 @code{gtroff} disallows the use of the @samp{z} scale indicator in
10682 instances where it would make no sense, such as a numeric expression
10683 whose default scale indicator was neither @samp{u} nor @samp{z}.
10684 Similarly it would make no sense to use a scaling indicator other than
10685 @samp{z} or @samp{u} in a numeric expression whose default scale
10686 indicator was @samp{z}, and so @code{gtroff} disallows this as well.
10687
10688 There is also new scale indicator @samp{s}, which multiplies by the
10689 number of units in a scaled point.  So, for example, @samp{\n[.ps]s} is
10690 equal to @samp{1m}.  Be sure not to confuse the @samp{s} and @samp{z}
10691 scale indicators.
10692
10693 @Defreg {.ps}
10694 A read-only number register returning the point size in scaled points.
10695
10696 @code{.ps} is associated with the current environment
10697 (@pxref{Environments}).
10698 @endDefreg
10699
10700 @DefregList {.psr}
10701 @DefregListEndx {.sr}
10702 @cindex last-requested point size registers (@code{.psr}, @code{.sr})
10703 @cindex point size registers, last-requested (@code{.psr}, @code{.sr})
10704 @cindex @code{.ps} register, in comparison with @code{.psr}
10705 @cindex @code{.s} register, in comparison with @code{.sr}
10706 The last-requested point size in scaled points is contained in the
10707 @code{.psr} read-only number register.  The last requested point size in
10708 points as a decimal fraction can be found in @code{.sr}.  This is a
10709 string-valued read-only number register.
10710
10711 Note that the requested point sizes are device-independent, whereas the
10712 values returned by the @code{.ps} and @code{.s} registers are not.  For
10713 example, if a point size of 11@dmn{pt} is requested, and a @code{sizes}
10714 request (or a @code{sizescale} line in a @file{DESC} file) specifies
10715 10.95@dmn{pt} instead, this value is actually used.
10716
10717 Both registers are associated with the current environment
10718 (@pxref{Environments}).
10719 @endDefreg
10720
10721 The @code{\s} escape has the following syntax for working with
10722 fractional type sizes:
10723
10724 @table @code
10725 @item \s[@var{n}]
10726 @itemx \s'@var{n}'
10727 Set the point size to @var{n}@tie{}scaled points; @var{n}@tie{}is a
10728 numeric expression with a default scale indicator of @samp{z}.
10729
10730 @item \s[+@var{n}]
10731 @itemx \s[-@var{n}]
10732 @itemx \s+[@var{n}]
10733 @itemx \s-[@var{n}]
10734 @itemx \s'+@var{n}'
10735 @itemx \s'-@var{n}'
10736 @itemx \s+'@var{n}'
10737 @itemx \s-'@var{n}'
10738 Increase or decrease the point size by @var{n}@tie{}scaled points;
10739 @var{n}@tie{}is a numeric expression (which may start with a minus sign)
10740 with a default scale indicator of @samp{z}.
10741 @end table
10742
10743 @xref{Font Files}.
10744
10745
10746 @c =====================================================================
10747
10748 @node Strings, Conditionals and Loops, Sizes, gtroff Reference
10749 @section Strings
10750 @cindex strings
10751
10752 @code{gtroff} has string variables, which are entirely for user
10753 convenience (i.e.@: there are no built-in strings except @code{.T}, but
10754 even this is a read-write string variable).
10755
10756 Although the following requests can be used to create strings,
10757 simply using an undefined string will cause it to be defined as empty.
10758 @xref{Identifiers}.
10759
10760 @DefreqList {ds, name [@Var{string}]}
10761 @DefreqItemx {ds1, name [@Var{string}]}
10762 @DefescItemx {\\*, , n, }
10763 @DefescItem {\\*, @Lparen{}, nm, }
10764 @DefescListEnd {\\*, @Lbrack{}, name arg1 arg2 @dots{}, @Rbrack{}}
10765 @cindex string interpolation (@code{\*})
10766 @cindex string expansion (@code{\*})
10767 @cindex interpolation of strings (@code{\*})
10768 @cindex expansion of strings (@code{\*})
10769 @cindex string arguments
10770 @cindex arguments, of strings
10771 Define and access a string variable @var{name} (one-character
10772 name@tie{}@var{n}, two-character name @var{nm}).  If @var{name} already
10773 exists, @code{ds} overwrites the previous definition.  Only the syntax
10774 form using brackets can take arguments that are handled identically to
10775 macro arguments; the single exception is that a closing bracket as an
10776 argument must be enclosed in double quotes.  @xref{Request and Macro
10777 Arguments}, and @ref{Parameters}.
10778
10779 Example:
10780
10781 @Example
10782 .ds foo a \\$1 test
10783 .
10784 This is \*[foo nice].
10785     @result{} This is a nice test.
10786 @endExample
10787
10788 The @code{\*} escape @dfn{interpolates} (expands in-place) a
10789 previously defined string variable.  To be more precise, the stored
10790 string is pushed onto the input stack, which is then parsed by
10791 @code{gtroff}.  Similar to number registers, it is possible to nest
10792 strings, i.e., string variables can be called within string variables.
10793
10794 If the string named by the @code{\*} escape does not exist, it is
10795 defined as empty, and a warning of type @samp{mac} is emitted (see
10796 @ref{Debugging}, for more details).
10797
10798 @cindex comments, with @code{ds}
10799 @cindex @code{ds} request, and comments
10800 @strong{Caution:} Unlike other requests, the second argument to the
10801 @code{ds} request takes up the entire line including trailing spaces.
10802 This means that comments on a line with such a request can introduce
10803 unwanted space into a string.
10804
10805 @Example
10806 .ds TeX T\h'-.2m'\v'.2m'E\v'-.2m'\h'-.1m'X \" Knuth's TeX
10807 @endExample
10808
10809 @noindent
10810 Instead the comment should be put on another line or have the comment
10811 escape adjacent with the end of the string.
10812
10813 @Example
10814 .ds TeX T\h'-.2m'\v'.2m'E\v'-.2m'\h'-.1m'X\" Knuth's TeX
10815 @endExample
10816
10817 @cindex trailing quotes
10818 @cindex quotes, trailing
10819 @cindex leading spaces with @code{ds}
10820 @cindex spaces with @code{ds}
10821 @cindex @code{ds} request, and leading spaces
10822 To produce leading space the string can be started with a double quote.
10823 No trailing quote is needed; in fact, any trailing quote is included in
10824 your string.
10825
10826 @Example
10827 .ds sign "           Yours in a white wine sauce,
10828 @endExample
10829
10830 @cindex multi-line strings
10831 @cindex strings, multi-line
10832 @cindex newline character, in strings, escaping
10833 @cindex escaping newline characters, in strings
10834 Strings are not limited to a single line of text.  A string can span
10835 several lines by escaping the newlines with a backslash.  The resulting
10836 string is stored @emph{without} the newlines.
10837
10838 @Example
10839 .ds foo lots and lots \
10840 of text are on these \
10841 next several lines
10842 @endExample
10843
10844 It is not possible to have real newlines in a string.  To put a single
10845 double quote character into a string, use two consecutive double quote
10846 characters.
10847
10848 The @code{ds1} request turns off compatibility mode while interpreting a
10849 string.  To be more precise, a @dfn{compatibility save} input token is
10850 inserted at the beginning of the string, and a @dfn{compatibility
10851 restore} input token at the end.
10852
10853 @Example
10854 .nr xxx 12345
10855 .ds aa The value of xxx is \\n[xxx].
10856 .ds1 bb The value of xxx is \\n[xxx].
10857 .
10858 .cp 1
10859 .
10860 \*(aa
10861     @result{} warning: number register `[' not defined
10862     @result{} The value of xxx is 0xxx].
10863 \*(bb
10864     @result{} The value of xxx is 12345.
10865 @endExample
10866
10867 @cindex name space, common, of macros, diversions, and strings
10868 @cindex common name space of macros, diversions, and strings
10869 @cindex macros, shared name space with strings and diversions
10870 @cindex strings, shared name space with macros and diversions
10871 @cindex diversions, shared name space with macros and strings
10872 Strings, macros, and diversions (and boxes) share the same name space.
10873 Internally, even the same mechanism is used to store them.  This has
10874 some interesting consequences.  For example, it is possible to call a
10875 macro with string syntax and vice versa.
10876
10877 @Example
10878 .de xxx
10879 a funny test.
10880 ..
10881 This is \*[xxx]
10882     @result{} This is a funny test.
10883
10884 .ds yyy a funny test
10885 This is
10886 .yyy
10887     @result{} This is a funny test.
10888 @endExample
10889
10890 In particular, interpolating a string does not hide existing macro
10891 arguments.  Thus in a macro, a more efficient way of doing
10892
10893 @Example
10894 .xx \\$@@
10895 @endExample
10896
10897 @noindent
10898 is
10899
10900 @Example
10901 \\*[xx]\\
10902 @endExample
10903
10904 @noindent
10905 Note that the latter calling syntax doesn't change the value of
10906 @code{\$0}, which is then inherited from the calling macro.
10907
10908 Diversions and boxes can be also called with string syntax.
10909
10910 Another consequence is that you can copy one-line diversions or boxes to
10911 a string.
10912
10913 @Example
10914 .di xxx
10915 a \fItest\fR
10916 .br
10917 .di
10918 .ds yyy This is \*[xxx]\c
10919 \*[yyy].
10920     @result{} @r{This is a }@i{test}.
10921 @endExample
10922
10923 @noindent
10924 As the previous example shows, it is possible to store formatted output
10925 in strings.  The @code{\c} escape prevents the insertion of an
10926 additional blank line in the output.
10927
10928 Copying diversions longer than a single output line produces unexpected
10929 results.
10930
10931 @Example
10932 .di xxx
10933 a funny
10934 .br
10935 test
10936 .br
10937 .di
10938 .ds yyy This is \*[xxx]\c
10939 \*[yyy].
10940     @result{} test This is a funny.
10941 @endExample
10942
10943 Usually, it is not predictable whether a diversion contains one or more
10944 output lines, so this mechanism should be avoided.  With Unix
10945 @code{troff}, this was the only solution to strip off a final newline
10946 from a diversion.  Another disadvantage is that the spaces in the copied
10947 string are already formatted, making them unstretchable.  This can cause
10948 ugly results.
10949
10950 @cindex stripping final newline in diversions
10951 @cindex diversion, stripping final newline
10952 @cindex final newline, stripping in diversions
10953 @cindex newline, final, stripping in diversions
10954 @cindex horizontal space, unformatting
10955 @cindex space, horizontal, unformatting
10956 @cindex unformatting horizontal space
10957 A clean solution to this problem is available in GNU @code{troff}, using
10958 the requests @code{chop} to remove the final newline of a diversion, and
10959 @code{unformat} to make the horizontal spaces stretchable again.
10960
10961 @Example
10962 .box xxx
10963 a funny
10964 .br
10965 test
10966 .br
10967 .box
10968 .chop xxx
10969 .unformat xxx
10970 This is \*[xxx].
10971     @result{} This is a funny test.
10972 @endExample
10973
10974 @xref{Gtroff Internals}, for more information.
10975 @endDefreq
10976
10977 @DefreqList {as, name [@Var{string}]}
10978 @DefreqListEndx {as1, name [@Var{string}]}
10979 @cindex appending to a string (@code{as})
10980 @cindex string, appending (@code{as})
10981 The @code{as} request is similar to @code{ds} but appends @var{string}
10982 to the string stored as @var{name} instead of redefining it.  If
10983 @var{name} doesn't exist yet, it is created.
10984
10985 @Example
10986 .as sign " with shallots, onions and garlic,
10987 @endExample
10988
10989 The @code{as1} request is similar to @code{as}, but compatibility mode
10990 is switched off while the appended string is interpreted.  To be more
10991 precise, a @dfn{compatibility save} input token is inserted at the
10992 beginning of the appended string, and a @dfn{compatibility restore}
10993 input token at the end.
10994 @endDefreq
10995
10996 Rudimentary string manipulation routines are given with the next two
10997 requests.
10998
10999 @Defreq {substring, str n1 [@Var{n2}]}
11000 @cindex substring (@code{substring})
11001 Replace the string named @var{str} with the substring defined by the
11002 indices @var{n1} and @var{n2}.  The first character in the string has
11003 index@tie{}0.  If @var{n2} is omitted, it is implicitly set to the
11004 largest valid value (the string length minus one).  If the index value
11005 @var{n1} or @var{n2} is negative, it is counted from the end of the
11006 string, going backwards: The last character has index@tie{}@minus{}1,
11007 the character before the last character has index@tie{}@minus{}2, etc.
11008
11009 @Example
11010 .ds xxx abcdefgh
11011 .substring xxx 1 -4
11012 \*[xxx]
11013     @result{} bcde
11014 .substring xxx 2
11015 \*[xxx]
11016     @result{} de
11017 @endExample
11018 @endDefreq
11019
11020 @Defreq {length, reg str}
11021 @cindex length of a string (@code{length})
11022 @cindex string, length of (@code{length})
11023 @cindex @code{length} request, and copy-in mode
11024 @cindex copy-in mode, and @code{length} request
11025 @cindex mode, copy-in, and @code{length} request
11026 Compute the number of characters of @var{str} and return it in the
11027 number register @var{reg}.  If @var{reg} doesn't exist, it is created.
11028 @code{str} is read in copy mode.
11029
11030 @Example
11031 .ds xxx abcd\h'3i'efgh
11032 .length yyy \*[xxx]
11033 \n[yyy]
11034     @result{} 14
11035 @endExample
11036 @endDefreq
11037
11038 @Defreq {rn, xx yy}
11039 @cindex renaming request (@code{rn})
11040 @cindex request, renaming (@code{rn})
11041 @cindex renaming macro (@code{rn})
11042 @cindex macro, renaming (@code{rn})
11043 @cindex renaming string (@code{rn})
11044 @cindex string, renaming (@code{rn})
11045 @cindex renaming diversion (@code{rn})
11046 @cindex diversion, renaming (@code{rn})
11047 Rename the request, macro, diversion, or string @var{xx} to @var{yy}.
11048 @endDefreq
11049
11050 @Defreq {rm, xx}
11051 @cindex removing request (@code{rm})
11052 @cindex request, removing (@code{rm})
11053 @cindex removing macro (@code{rm})
11054 @cindex macro, removing (@code{rm})
11055 @cindex removing string (@code{rm})
11056 @cindex string, removing (@code{rm})
11057 @cindex removing diversion (@code{rm})
11058 @cindex diversion, removing (@code{rm})
11059 Remove the request, macro, diversion, or string @var{xx}.  @code{gtroff}
11060 treats subsequent invocations as if the object had never been defined.
11061 @endDefreq
11062
11063 @anchor{als}
11064 @Defreq {als, new old}
11065 @cindex alias, string, creating (@code{als})
11066 @cindex alias, macro, creating (@code{als})
11067 @cindex alias, diversion, creating (@code{als})
11068 @cindex creating alias, for string (@code{als})
11069 @cindex creating alias, for macro (@code{als})
11070 @cindex creating alias, for diversion (@code{als})
11071 @cindex string, creating alias (@code{als})
11072 @cindex macro, creating alias (@code{als})
11073 @cindex diversion, creating alias (@code{als})
11074 Create an alias named @var{new} for the request, string, macro, or
11075 diversion object named @var{old}.  The new name and the old name are
11076 exactly equivalent (it is similar to a hard rather than a soft link).  If
11077 @var{old} is undefined, @code{gtroff} generates a warning of type
11078 @samp{mac} and ignores the request.
11079
11080 To understand how the @code{als} request works it is probably best to
11081 think of two different pools: one pool for objects (macros, strings,
11082 etc.), and another one for names.  As soon as an object is defined,
11083 @code{gtroff} adds it to the object pool, adds its name to the name
11084 pool, and creates a link between them.  When @code{als} creates an
11085 alias, it adds a new name to the name pool that gets linked to the same
11086 object as the old name.
11087
11088 Now consider this example.
11089
11090 @Example
11091 .de foo
11092 ..
11093 .
11094 .als bar foo
11095 .
11096 .de bar
11097 .  foo
11098 ..
11099 .
11100 .bar
11101     @result{} input stack limit exceeded
11102 @endExample
11103
11104 @noindent
11105 The definition of macro @code{bar} replaces the old object this name is
11106 linked to.  However, the alias to @code{foo} is still active!  In
11107 other words, @code{foo} is still linked to the same object as
11108 @code{bar}, and the result of calling @code{bar} is an infinite,
11109 recursive loop that finally leads to an error.
11110
11111 @cindex alias, string, removing (@code{rm})
11112 @cindex alias, macro, removing (@code{rm})
11113 @cindex alias, diversion, removing (@code{rm})
11114 @cindex removing alias, for string (@code{rm})
11115 @cindex removing alias, for macro (@code{rm})
11116 @cindex removing alias, for diversion (@code{rm})
11117 @cindex string, removing alias (@code{rm})
11118 @cindex macro, removing alias (@code{rm})
11119 @cindex diversion, removing alias (@code{rm})
11120 To undo an alias, simply call @code{rm} on the aliased name.  The object
11121 itself is not destroyed until there are no more aliases.
11122 @endDefreq
11123
11124 @Defreq {chop, xx}
11125 Remove (chop) the last character from the macro, string, or diversion
11126 named @var{xx}.  This is useful for removing the newline from the end of
11127 diversions that are to be interpolated as strings.  This command can be
11128 used repeatedly; see @ref{Gtroff Internals}, for details on nodes
11129 inserted additionally by @code{gtroff}.
11130 @endDefreq
11131
11132 @xref{Identifiers}, and @ref{Comments}.
11133
11134
11135 @c =====================================================================
11136
11137 @node Conditionals and Loops, Writing Macros, Strings, gtroff Reference
11138 @section Conditionals and Loops
11139 @cindex conditionals and loops
11140 @cindex loops and conditionals
11141
11142 @menu
11143 * Operators in Conditionals::
11144 * if-else::
11145 * while::
11146 @end menu
11147
11148 @c ---------------------------------------------------------------------
11149
11150 @node Operators in Conditionals, if-else, Conditionals and Loops, Conditionals and Loops
11151 @subsection Operators in Conditionals
11152
11153 @cindex @code{if} request, operators to use with
11154 @cindex @code{ie} request, operators to use with
11155 @cindex @code{while} request, operators to use with
11156 In @code{if}, @code{ie}, and @code{while} requests, in addition to ordinary
11157 @ref{Expressions}, there are several more operators available:
11158
11159 @table @code
11160 @item e
11161 @itemx o
11162 True if the current page is even or odd numbered (respectively).
11163
11164 @item n
11165 @cindex conditional output for terminal (TTY)
11166 @cindex TTY, conditional output for
11167 @cindex terminal, conditional output for
11168 True if the document is being processed in nroff mode (i.e., the
11169 @code{.nroff} command has been issued).  @xref{Troff and Nroff Mode}.
11170
11171 @item t
11172 True if the document is being processed in troff mode (i.e., the
11173 @code{.troff} command has been issued).  @xref{Troff and Nroff Mode}.
11174
11175 @item v
11176 Always false.  This condition is for compatibility with other
11177 @code{troff} versions only (identifying a @code{-Tversatec} device).
11178
11179 @item '@var{xxx}'@var{yyy}'
11180 True if the output produced by @var{xxx} is equal to the output produced
11181 by @var{yyy}.  Other characters can be used in place of the single
11182 quotes; the same set of delimiters as for the @code{\D} escape is used
11183 (@pxref{Escapes}).  @code{gtroff} formats @var{xxx} and @var{yyy} in
11184 separate environments; after the comparison the resulting data is
11185 discarded.
11186
11187 @Example
11188 .ie "|"\fR|\fP" \
11189 true
11190 .el \
11191 false
11192     @result{} true
11193 @endExample
11194
11195 @noindent
11196 The resulting motions, glyph sizes, and fonts have to
11197 match,@footnote{The created output nodes must be identical.
11198 @xref{Gtroff Internals}.} and not the individual motion, size, and font
11199 requests.  In the previous example, @samp{|} and @samp{\fR|\fP} both
11200 result in a roman @samp{|} glyph with the same point size and at the
11201 same location on the page, so the strings are equal.  If
11202 @samp{.ft@tie{}I} had been added before the @samp{.ie}, the result would
11203 be ``false'' because (the first) @samp{|} produces an italic @samp{|}
11204 rather than a roman one.
11205
11206 @cindex string comparison
11207 @cindex comparison of strings
11208 To compare strings without processing, surround the data with @code{\?}.
11209
11210 @Example
11211 .ie "\?|\?"\?\fR|\fP\?" \
11212 true
11213 .el \
11214 false
11215     @result{} false
11216 @endExample
11217
11218 @cindex @code{\?}, and copy-in mode
11219 @cindex copy-in mode, and @code{\?}
11220 @cindex mode, copy-in, and @code{\?}
11221 @noindent
11222 Since data protected with @code{\?} is read in copy-in mode it is even
11223 possible to use incomplete input without causing an error.
11224
11225 @Example
11226 .ds a \[
11227 .ds b \[
11228 .ie '\?\*a\?'\?\*b\?' \
11229 true
11230 .el \
11231 false
11232     @result{} true
11233 @endExample
11234
11235 @item r @var{xxx}
11236 True if there is a number register named @var{xxx}.
11237
11238 @item d @var{xxx}
11239 True if there is a string, macro, diversion, or request named @var{xxx}.
11240
11241 @item m @var{xxx}
11242 True if there is a color named @var{xxx}.
11243
11244 @item c @var{g}
11245 True if there is a glyph @var{g} available@footnote{The name of this
11246 conditional operator is a misnomer since it tests names of output
11247 glyphs.}; @var{g} is either an @acronym{ASCII} character or a special
11248 character (@code{\N'@var{xxx}'}, @code{\(@var{gg}} or
11249 @code{\[@var{ggg}]}); the condition is also true if @var{g} has been
11250 defined by the @code{char} request.
11251
11252 @item F @var{font}
11253 True if a font named @var{font} exists.  @var{font} is handled as if it
11254 was opened with the @code{ft} request (that is, font translation and
11255 styles are applied), without actually mounting it.
11256
11257 This test doesn't load the complete font but only its header to verify
11258 its validity.
11259
11260 @item S @var{style}
11261 True if style @var{style} has been registered.  Font translation is
11262 applied.
11263 @end table
11264
11265 Note that these operators can't be combined with other operators like
11266 @samp{:} or @samp{&}; only a leading @samp{!} (without whitespace
11267 between the exclamation mark and the operator) can be used to negate the
11268 result.
11269
11270 @Example
11271 .nr xxx 1
11272 .ie !r xxx \
11273 true
11274 .el \
11275 false
11276     @result{} false
11277 @endExample
11278
11279 A whitespace after @samp{!} always evaluates to zero (this bizarre
11280 behaviour is due to compatibility with Unix @code{troff}).
11281
11282 @Example
11283 .nr xxx 1
11284 .ie ! r xxx \
11285 true
11286 .el \
11287 false
11288     @result{} r xxx true
11289 @endExample
11290
11291 It is possible to omit the whitespace before the argument to the
11292 @samp{r}, @samp{d}, and @samp{c} operators.
11293
11294 @xref{Expressions}.
11295
11296 @c ---------------------------------------------------------------------
11297
11298 @node if-else, while, Operators in Conditionals, Conditionals and Loops
11299 @subsection if-else
11300 @cindex if-else
11301
11302 @code{gtroff} has if-then-else constructs like other languages, although
11303 the formatting can be painful.
11304
11305 @Defreq {if, expr anything}
11306
11307 Evaluate the expression @var{expr}, and executes @var{anything} (the
11308 remainder of the line) if @var{expr} evaluates to a value greater than
11309 zero (true).  @var{anything} is interpreted as though it was on a line
11310 by itself (except that leading spaces are swallowed).
11311 @xref{Operators in Conditionals}, for more info.
11312
11313 @Example
11314 .nr xxx 1
11315 .nr yyy 2
11316 .if ((\n[xxx] == 1) & (\n[yyy] == 2)) true
11317     @result{} true
11318 @endExample
11319 @endDefreq
11320
11321 @Defreq {nop, anything}
11322 Executes @var{anything}.  This is similar to @code{.if@tie{}1}.
11323 @endDefreq
11324
11325 @DefreqList {ie, expr anything}
11326 @DefreqListEndx {el, anything}
11327 Use the @code{ie} and @code{el} requests to write an if-then-else.  The
11328 first request is the `if' part and the latter is the `else' part.
11329
11330 @Example
11331 .ie n .ls 2 \" double-spacing in nroff
11332 .el   .ls 1 \" single-spacing in troff
11333 @endExample
11334 @endDefreq
11335
11336 @c there is a bug in makeinfo <= 4.1a: you can't have `@{' as an argument
11337 @c to @deffn
11338 @c
11339 @c and in 4.2 you still can't use @{ in macros.
11340
11341 @c @DefescList {\@{, , , }
11342 @c @DefescListEnd {\@}, , , }
11343 @deffn Escape @t{\@{}
11344 @deffnx Escape @t{\@}}
11345 @esindex \@{
11346 @esindex \@}
11347 @cindex begin of conditional block (@code{\@{})
11348 @cindex end of conditional block (@code{\@}})
11349 @cindex conditional block, begin (@code{\@{})
11350 @cindex conditional block, end (@code{\@}})
11351 @cindex block, conditional, begin (@code{\@{})
11352 @cindex block, conditional, end (@code{\@}})
11353 In many cases, an if (or if-else) construct needs to execute more than
11354 one request.  This can be done using the escapes @code{\@{} (which must
11355 start the first line) and @code{\@}} (which must end the last line).
11356
11357 @Example
11358 .ie t \@{\
11359 .    ds lq ``
11360 .    ds rq ''
11361 .\@}
11362 .el \@{\
11363 .    ds lq ""
11364 .    ds rq ""
11365 .\@}
11366 @endExample
11367 @c @endDefesc
11368 @end deffn
11369
11370 @xref{Expressions}.
11371
11372 @c ---------------------------------------------------------------------
11373
11374 @node while,  , if-else, Conditionals and Loops
11375 @subsection while
11376 @cindex while
11377
11378 @code{gtroff} provides a looping construct using the @code{while}
11379 request, which is used much like the @code{if} (and related) requests.
11380
11381 @Defreq {while, expr anything}
11382 Evaluate the expression @var{expr}, and repeatedly execute
11383 @var{anything} (the remainder of the line) until @var{expr} evaluates
11384 to@tie{}0.
11385
11386 @Example
11387 .nr a 0 1
11388 .while (\na < 9) \@{\
11389 \n+a,
11390 .\@}
11391 \n+a
11392     @result{} 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
11393 @endExample
11394
11395 Some remarks.
11396
11397 @cindex @code{de} request, and @code{while}
11398 @itemize @bullet
11399 @item
11400 The body of a @code{while} request is treated like the body of a
11401 @code{de} request: @code{gtroff} temporarily stores it in a macro that
11402 is deleted after the loop has been exited.  It can considerably slow
11403 down a macro if the body of the @code{while} request (within the macro)
11404 is large.  Each time the macro is executed, the @code{while} body is
11405 parsed and stored again as a temporary macro.
11406
11407 @Example
11408 .de xxx
11409 .  nr num 10
11410 .  while (\\n[num] > 0) \@{\
11411 .    \" many lines of code
11412 .    nr num -1
11413 .  \@}
11414 ..
11415 @endExample
11416
11417 @cindex recursive macros
11418 @cindex macros, recursive
11419 @noindent
11420 The traditional and often better solution (Unix @code{troff} doesn't
11421 have the @code{while} request) is to use a recursive macro instead that
11422 is parsed only once during its definition.
11423
11424 @Example
11425 .de yyy
11426 .  if (\\n[num] > 0) \@{\
11427 .    \" many lines of code
11428 .    nr num -1
11429 .    yyy
11430 .  \@}
11431 ..
11432 .
11433 .de xxx
11434 .  nr num 10
11435 .  yyy
11436 ..
11437 @endExample
11438
11439 @noindent
11440 Note that the number of available recursion levels is set to@tie{}1000
11441 (this is a compile-time constant value of @code{gtroff}).
11442
11443 @item
11444 The closing brace of a @code{while} body must end a line.
11445
11446 @Example
11447 .if 1 \@{\
11448 .  nr a 0 1
11449 .  while (\n[a] < 10) \@{\
11450 .    nop \n+[a]
11451 .\@}\@}
11452     @result{} unbalanced \@{ \@}
11453 @endExample
11454 @end itemize
11455 @endDefreq
11456
11457 @Defreq {break, }
11458 @cindex @code{while} request, confusing with @code{br}
11459 @cindex @code{break} request, in a @code{while} loop
11460 @cindex @code{continue} request, in a @code{while} loop
11461 Break out of a @code{while} loop.  Be sure not to confuse this with the
11462 @code{br} request (causing a line break).
11463 @endDefreq
11464
11465 @Defreq {continue, }
11466 Finish the current iteration of a @code{while} loop, immediately
11467 restarting the next iteration.
11468 @endDefreq
11469
11470 @xref{Expressions}.
11471
11472
11473 @c =====================================================================
11474
11475 @node Writing Macros, Page Motions, Conditionals and Loops, gtroff Reference
11476 @section Writing Macros
11477 @cindex writing macros
11478 @cindex macros, writing
11479
11480 A @dfn{macro} is a collection of text and embedded commands that can be
11481 invoked multiple times.  Use macros to define common operations.
11482 @xref{Strings}, for a (limited) alternative syntax to call macros.
11483
11484 Although the following requests can be used to create macros,
11485 simply using an undefined macro will cause it to be defined as empty.
11486 @xref{Identifiers}.
11487
11488 @DefreqList {de, name [@Var{end}]}
11489 @DefreqItemx {de1, name [@Var{end}]}
11490 @DefreqItemx {dei, name [@Var{end}]}
11491 @DefreqListEndx {dei1, name [@Var{end}]}
11492 Define a new macro named @var{name}.  @code{gtroff} copies subsequent
11493 lines (starting with the next one) into an internal buffer until it
11494 encounters the line @samp{..} (two dots).  If the optional second
11495 argument to @code{de} is present it is used as the macro closure
11496 request instead of @samp{..}.
11497
11498 There can be whitespace after the first dot in the line containing the
11499 ending token (either @samp{.} or macro @samp{@var{end}}).  Don't insert
11500 a tab character immediately after the @samp{..}, otherwise it isn't
11501 recognized as the end-of-macro symbol.@footnote{While it is possible to
11502 define and call a macro @samp{.} with
11503
11504 @Example
11505 .de .
11506 .  tm foo
11507 ..
11508 .
11509 ..    \" This calls macro `.'!
11510 @endExample
11511
11512 @noindent
11513 you can't use this as the end-of-macro macro: during a macro definition,
11514 @samp{..} is never handled as a call to @samp{.}, even if you say
11515 @samp{.de foo .} explicitly.}
11516
11517 Here a small example macro called @samp{P} that causes a break and
11518 inserts some vertical space.  It could be used to separate paragraphs.
11519
11520 @Example
11521 .de P
11522 .  br
11523 .  sp .8v
11524 ..
11525 @endExample
11526
11527 The following example defines a macro within another.  Remember that
11528 expansion must be protected twice; once for reading the macro and once
11529 for executing.
11530
11531 @Example
11532 \# a dummy macro to avoid a warning
11533 .de end
11534 ..
11535 .
11536 .de foo
11537 .  de bar end
11538 .    nop \f[B]Hello \\\\$1!\f[]
11539 .  end
11540 ..
11541 .
11542 .foo
11543 .bar Joe
11544     @result{} @b{Hello Joe!}
11545 @endExample
11546
11547 @noindent
11548 Since @code{\f} has no expansion, it isn't necessary to protect its
11549 backslash.  Had we defined another macro within @code{bar} that takes a
11550 parameter, eight backslashes would be necessary before @samp{$1}.
11551
11552 The @code{de1} request turns off compatibility mode while executing the
11553 macro.  On entry, the current compatibility mode is saved and restored
11554 at exit.
11555
11556 @Example
11557 .nr xxx 12345
11558 .
11559 .de aa
11560 The value of xxx is \\n[xxx].
11561 ..
11562 .de1 bb
11563 The value of xxx is \\n[xxx].
11564 ..
11565 .
11566 .cp 1
11567 .
11568 .aa
11569     @result{} warning: number register `[' not defined
11570     @result{} The value of xxx is 0xxx].
11571 .bb
11572     @result{} The value of xxx is 12345.
11573 @endExample
11574
11575 The @code{dei} request defines a macro indirectly.  That is, it expands
11576 strings whose names are @var{name} or @var{end} before performing the
11577 append.
11578
11579 This:
11580
11581 @Example
11582 .ds xx aa
11583 .ds yy bb
11584 .dei xx yy
11585 @endExample
11586
11587 @noindent
11588 is equivalent to:
11589
11590 @Example
11591 .de aa bb
11592 @endExample
11593
11594 The @code{dei1} request is similar to @code{dei} but with compatibility
11595 mode switched off during execution of the defined macro.
11596
11597 If compatibility mode is on, @code{de} (and @code{dei}) behave similar
11598 to @code{de1} (and @code{dei1}): A `compatibility save' token is
11599 inserted at the beginning, and a `compatibility restore' token at the
11600 end, with compatibility mode switched on during execution.  @xref{Gtroff
11601 Internals}, for more information on switching compatibility mode on and
11602 off in a single document.
11603
11604 @pindex trace.tmac
11605 Using @file{trace.tmac}, you can trace calls to @code{de} and
11606 @code{de1}.
11607
11608 Note that macro identifiers are shared with identifiers for strings and
11609 diversions.
11610
11611 @xref{als,,the description of the @code{als} request}, for possible
11612 pitfalls if redefining a macro that has been aliased.
11613 @endDefreq
11614
11615 @DefreqList {am, name [@Var{end}]}
11616 @DefreqItemx {am1, name [@Var{end}]}
11617 @DefreqItemx {ami, name [@Var{end}]}
11618 @DefreqListEndx {ami1, name [@Var{end}]}
11619 @cindex appending to a macro (@code{am})
11620 @cindex macro, appending (@code{am})
11621 Works similarly to @code{de} except it appends onto the macro named
11622 @var{name}.  So, to make the previously defined @samp{P} macro actually
11623 do indented instead of block paragraphs, add the necessary code to the
11624 existing macro like this:
11625
11626 @Example
11627 .am P
11628 .ti +5n
11629 ..
11630 @endExample
11631
11632 The @code{am1} request turns off compatibility mode while executing the
11633 appended macro piece.  To be more precise, a @dfn{compatibility save}
11634 input token is inserted at the beginning of the appended code, and a
11635 @dfn{compatibility restore} input token at the end.
11636
11637 The @code{ami} request appends indirectly, meaning that @code{gtroff}
11638 expands strings whose names are @var{name} or @var{end} before
11639 performing the append.
11640
11641 The @code{ami1} request is similar to @code{ami} but compatibility mode
11642 is switched off during execution of the defined macro.
11643
11644 @pindex trace.tmac
11645 Using @file{trace.tmac}, you can trace calls to @code{am} and
11646 @code{am1}.
11647 @endDefreq
11648
11649 @xref{Strings}, for the @code{als} and @code{rn} request to create an
11650 alias and rename a macro, respectively.
11651
11652 The @code{de}, @code{am}, @code{di}, @code{da}, @code{ds}, and @code{as}
11653 requests (together with their variants) only create a new object if the
11654 name of the macro, diversion or string is currently undefined
11655 or if it is defined to be a request; normally they modify the value of
11656 an existing object.
11657
11658 @Defreq {return, [@Var{anything}]}
11659 Exit a macro, immediately returning to the caller.
11660
11661 If called with an argument, exit twice, namely the current macro and the
11662 macro one level higher.  This is used to define a wrapper macro for
11663 @code{return} in @file{trace.tmac}.
11664 @endDefreq
11665
11666 @menu
11667 * Copy-in Mode::
11668 * Parameters::
11669 @end menu
11670
11671 @c ---------------------------------------------------------------------
11672
11673 @node Copy-in Mode, Parameters, Writing Macros, Writing Macros
11674 @subsection Copy-in Mode
11675 @cindex copy mode
11676 @cindex copy-in mode
11677 @cindex mode, copy
11678 @cindex mode, copy-in
11679
11680 @cindex @code{\n}, when reading text for a macro
11681 @cindex @code{\$}, when reading text for a macro
11682 @cindex @code{\*}, when reading text for a macro
11683 @cindex @code{\\}, when reading text for a macro
11684 @cindex \@key{RET}, when reading text for a macro
11685 When @code{gtroff} reads in the text for a macro, string, or diversion,
11686 it copies the text (including request lines, but excluding escapes) into
11687 an internal buffer.
11688 Escapes are converted into an internal form, except for @code{\n},
11689 @code{\$}, @code{\*}, @code{\\} and @code{\@key{RET}}, which are evaluated
11690 and inserted into the text where the escape was located.
11691 This is known as @dfn{copy-in} mode or @dfn{copy} mode.
11692
11693 What this means is that you can specify when these escapes are to be
11694 evaluated (either at copy-in time or at the time of use) by insulating
11695 the escapes with an extra backslash.  Compare this to the @code{\def}
11696 and @code{\edef} commands in @TeX{}.
11697
11698 The following example prints the numbers 20 and@tie{}10:
11699
11700 @Example
11701 .nr x 20
11702 .de y
11703 .nr x 10
11704 \&\nx
11705 \&\\nx
11706 ..
11707 .y
11708 @endExample
11709
11710 @c ---------------------------------------------------------------------
11711
11712 @node Parameters,  , Copy-in Mode, Writing Macros
11713 @subsection Parameters
11714 @cindex parameters
11715
11716 The arguments to a macro or string can be examined using a variety of
11717 escapes.
11718
11719 @Defreg {.$}
11720 @cindex number of arguments register (@code{.$})
11721 The number of arguments passed to a macro or string.  This is a
11722 read-only number register.
11723
11724 Note that the @code{shift} request can change its value.
11725 @endDefreg
11726
11727 Any individual argument can be retrieved with one of the following
11728 escapes:
11729
11730 @DefescList {\\$, , n, }
11731 @DefescItem {\\$, @Lparen{}, nn, }
11732 @DefescListEnd {\\$, @Lbrack{}, nnn, @Rbrack{}}
11733 @cindex copy-in mode, and macro arguments
11734 @cindex mode, copy-in, and macro arguments
11735 @cindex macro, arguments (@code{\$})
11736 @cindex arguments, macro (@code{\$})
11737 Retrieve the @var{n}@dmn{th}, @var{nn}@dmn{th} or @var{nnn}@dmn{th}
11738 argument.  As usual, the first form only accepts a single number (larger
11739 than zero), the second a two-digit number (larger or equal to@tie{}10),
11740 and the third any positive integer value (larger than zero).  Macros and
11741 strings can have an unlimited number of arguments.  Note that due to
11742 copy-in mode, use two backslashes on these in actual use to prevent
11743 interpolation until the macro is actually invoked.
11744 @endDefesc
11745
11746 @Defreq {shift, [@Var{n}]}
11747 Shift the arguments 1@tie{}position, or as many positions as specified
11748 by its argument.  After executing this request, argument@tie{}@var{i}
11749 becomes argument @math{@var{i}-@var{n}}; arguments 1 to@tie{}@var{n} are
11750 no longer available.  Shifting by negative amounts is currently
11751 undefined.
11752
11753 The register @code{.$} is adjusted accordingly.
11754 @endDefreq
11755
11756 @DefescList {\\$*, , , }
11757 @DefescListEndx {\\$@@, , , }
11758 In some cases it is convenient to use all of the arguments at once (for
11759 example, to pass the arguments along to another macro).  The @code{\$*}
11760 escape concatenates all the arguments separated by spaces.  A similar
11761 escape is @code{\$@@}, which concatenates all the arguments with each
11762 surrounded by double quotes, and separated by spaces.  If not in
11763 compatibility mode, the input level of double quotes is preserved (see
11764 @ref{Request and Macro Arguments}).
11765 @endDefesc
11766
11767 @Defesc {\\$^, , , }
11768 Handle the parameters of a macro as if they were an argument to the
11769 @code{ds} or similar requests.
11770
11771 @Example
11772 .de foo
11773 .  tm $1=`\\$1'
11774 .  tm $2=`\\$2'
11775 .  tm $*=`\\$*'
11776 .  tm $@@=`\\$@@'
11777 .  tm $^=`\\$^'
11778 ..
11779 .foo " This is a "test"
11780     @result{} $1=` This is a '
11781     @result{} $2=`test"'
11782     @result{} $*=` This is a  test"'
11783     @result{} $@@=`" This is a " "test""'
11784     @result{} $^=`" This is a "test"'
11785 @endExample
11786
11787 This escape is useful mainly for macro packages like @file{trace.tmac},
11788 which redefines some requests and macros for debugging purposes.
11789 @endDefesc
11790
11791 @Defesc {\\$0, , , }
11792 @cindex macro name register (@code{\$0})
11793 @cindex @code{als} request, and @code{\$0}
11794 The name used to invoke the current macro.  The @code{als} request can
11795 make a macro have more than one name.
11796
11797 If a macro is called as a string (within another macro), the value of
11798 @code{\$0} isn't changed.
11799
11800 @Example
11801 .de foo
11802 .  tm \\$0
11803 ..
11804 .als foo bar
11805 .
11806 @endExample
11807 @Example
11808 .de aaa
11809 .  foo
11810 ..
11811 .de bbb
11812 .  bar
11813 ..
11814 .de ccc
11815 \\*[foo]\\
11816 ..
11817 .de ddd
11818 \\*[bar]\\
11819 ..
11820 .
11821 @endExample
11822 @Example
11823 .aaa
11824     @result{} foo
11825 .bbb
11826     @result{} bar
11827 .ccc
11828     @result{} ccc
11829 .ddd
11830     @result{} ddd
11831 @endExample
11832 @endDefesc
11833
11834 @xref{Request and Macro Arguments}.
11835
11836
11837 @c =====================================================================
11838
11839 @node Page Motions, Drawing Requests, Writing Macros, gtroff Reference
11840 @section Page Motions
11841 @cindex page motions
11842 @cindex motions, page
11843
11844 @xref{Manipulating Spacing}, for a discussion of the main request for
11845 vertical motion, @code{sp}.
11846
11847 @DefreqList {mk, [@Var{reg}]}
11848 @DefreqListEndx {rt, [@Var{dist}]}
11849 @cindex marking vertical page location (@code{mk})
11850 @cindex page location, vertical, marking (@code{mk})
11851 @cindex location, vertical, page, marking (@code{mk})
11852 @cindex vertical page location, marking (@code{mk})
11853 @cindex returning to marked vertical page location (@code{rt})
11854 @cindex page location, vertical, returning to marked (@code{rt})
11855 @cindex location, vertical, page, returning to marked (@code{rt})
11856 @cindex vertical page location, returning to marked (@code{rt})
11857 The request @code{mk} can be used to mark a location on a page, for
11858 movement to later.  This request takes a register name as an argument in
11859 which to store the current page location.  With no argument it stores
11860 the location in an internal register.  The results of this can be used
11861 later by the @code{rt} or the @code{sp} request (or the @code{\v}
11862 escape).
11863
11864 The @code{rt} request returns @emph{upwards} to the location marked with
11865 the last @code{mk} request.  If used with an argument, return to a
11866 position which distance from the top of the page is @var{dist} (no
11867 previous call to @code{mk} is necessary in this case).  Default scaling
11868 indicator is @samp{v}.
11869
11870 If a page break occurs between a @code{mk} request and its
11871 matching @code{rt} request, the @code{rt} is silently ignored.
11872
11873 Here a primitive solution for a two-column macro.
11874
11875 @Example
11876 .nr column-length 1.5i
11877 .nr column-gap 4m
11878 .nr bottom-margin 1m
11879 .
11880 @endExample
11881 @Example
11882 .de 2c
11883 .  br
11884 .  mk
11885 .  ll \\n[column-length]u
11886 .  wh -\\n[bottom-margin]u 2c-trap
11887 .  nr right-side 0
11888 ..
11889 .
11890 @endExample
11891 @Example
11892 .de 2c-trap
11893 .  ie \\n[right-side] \@{\
11894 .    nr right-side 0
11895 .    po -(\\n[column-length]u + \\n[column-gap]u)
11896 .    \" remove trap
11897 .    wh -\\n[bottom-margin]u
11898 .  \@}
11899 .  el \@{\
11900 .    \" switch to right side
11901 .    nr right-side 1
11902 .    po +(\\n[column-length]u + \\n[column-gap]u)
11903 .    rt
11904 .  \@}
11905 ..
11906 .
11907 @endExample
11908 @Example
11909 .pl 1.5i
11910 .ll 4i
11911 This is a small test that shows how the
11912 rt request works in combination with mk.
11913
11914 .2c
11915 Starting here, text is typeset in two columns.
11916 Note that this implementation isn't robust
11917 and thus not suited for a real two-column
11918 macro.
11919 @endExample
11920
11921 Result:
11922
11923 @Example
11924 This is a small test that shows how the
11925 rt request works in combination with mk.
11926
11927 Starting  here,    isn't    robust
11928 text is typeset    and   thus  not
11929 in two columns.    suited  for   a
11930 Note that  this    real two-column
11931 implementation     macro.
11932 @endExample
11933 @endDefreq
11934
11935 The following escapes give fine control of movements about the page.
11936
11937 @Defesc {\\v, ', e, '}
11938 @cindex vertical motion (@code{\v})
11939 @cindex motion, vertical (@code{\v})
11940 Move vertically, usually from the current location on the page (if no
11941 absolute position operator @samp{|} is used).  The argument@tie{}@var{e}
11942 specifies the distance to move; positive is downwards and negative
11943 upwards.  The default scaling indicator for this escape is @samp{v}.
11944 Beware, however, that @code{gtroff} continues text processing at the
11945 point where the motion ends, so you should always balance motions to
11946 avoid interference with text processing.
11947
11948 @code{\v} doesn't trigger a trap.  This can be quite useful; for
11949 example, consider a page bottom trap macro that prints a marker in the
11950 margin to indicate continuation of a footnote or something similar.
11951 @endDefesc
11952
11953 There are some special-case escapes for vertical motion.
11954
11955 @Defesc {\\r, , , }
11956 Move upwards@tie{}1@dmn{v}.
11957 @endDefesc
11958
11959 @Defesc {\\u, , , }
11960 Move upwards@tie{}.5@dmn{v}.
11961 @endDefesc
11962
11963 @Defesc {\\d, , , }
11964 Move down@tie{}.5@dmn{v}.
11965 @endDefesc
11966
11967 @Defesc {\\h, ', e, '}
11968 @cindex inserting horizontal space (@code{\h})
11969 @cindex horizontal space (@code{\h})
11970 @cindex space, horizontal (@code{\h})
11971 @cindex horizontal motion (@code{\h})
11972 @cindex motion, horizontal (@code{\h})
11973 Move horizontally, usually from the current location (if no absolute
11974 position operator @samp{|} is used).  The expression@tie{}@var{e}
11975 indicates how far to move: positive is rightwards and negative
11976 leftwards.  The default scaling indicator for this escape is @samp{m}.
11977
11978 This horizontal space is not discarded at the end of a line.  To insert
11979 discardable space of a certain length use the @code{ss} request.
11980 @endDefesc
11981
11982 There are a number of special-case escapes for horizontal motion.
11983
11984 @Defesc {\\@key{SP}, , , }
11985 @cindex space, unbreakable
11986 @cindex unbreakable space
11987 An unbreakable and unpaddable (i.e.@: not expanded during filling)
11988 space.  (Note: This is a backslash followed by a space.)
11989 @endDefesc
11990
11991 @Defesc {\\~, , , }
11992 An unbreakable space that stretches like a normal inter-word space when
11993 a line is adjusted.
11994 @endDefesc
11995
11996 @Defesc {\\|, , , }
11997 A 1/6@dmn{th} em space.  Ignored for TTY output devices (rounded to
11998 zero).
11999
12000 However, if there is a glyph defined in the current font file with name
12001 @code{\|} (note the leading backslash), the width of this glyph is used
12002 instead (even for TTYs).
12003 @endDefesc
12004
12005 @Defesc {\\^, , , }
12006 A 1/12@dmn{th} em space.  Ignored for TTY output devices (rounded to
12007 zero).
12008
12009 However, if there is a glyph defined in the current font file with name
12010 @code{\^} (note the leading backslash), the width of this glyph is used
12011 instead (even for TTYs).
12012 @endDefesc
12013
12014 @Defesc {\\0, , , }
12015 @cindex space, width of a digit (@code{\0})
12016 @cindex digit width space (@code{\0})
12017 A space the size of a digit.
12018 @endDefesc
12019
12020 The following string sets the @TeX{} logo:
12021
12022 @Example
12023 .ds TeX T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
12024 @endExample
12025
12026 @DefescList {\\w, ', text, '}
12027 @DefregItemx {st}
12028 @DefregItemx {sb}
12029 @DefregItemx {rst}
12030 @DefregItemx {rsb}
12031 @DefregItemx {ct}
12032 @DefregItemx {ssc}
12033 @DefregListEndx {skw}
12034 @cindex width escape (@code{\w})
12035 Return the width of the specified @var{text} in basic units.  This
12036 allows horizontal movement based on the width of some arbitrary text
12037 (e.g.@: given as an argument to a macro).
12038
12039 @Example
12040 The length of the string `abc' is \w'abc'u.
12041     @result{} The length of the string `abc' is 72u.
12042 @endExample
12043
12044 Font changes may occur in @var{text}, which don't affect current
12045 settings.
12046
12047 After use, @code{\w} sets several registers:
12048
12049 @table @code
12050 @item st
12051 @itemx sb
12052 The highest and lowest point of the baseline, respectively, in
12053 @var{text}.
12054
12055 @item rst
12056 @itemx rsb
12057 Like the @code{st} and @code{sb} registers, but takes account of the
12058 heights and depths of glyphs.  In other words, this gives the highest
12059 and lowest point of @var{text}.  Values below the baseline are negative.
12060
12061 @item ct
12062 Defines the kinds of glyphs occurring in @var{text}:
12063
12064 @table @asis
12065 @item 0
12066 only short glyphs, no descenders or tall glyphs.
12067
12068 @item 1
12069 at least one descender.
12070
12071 @item 2
12072 at least one tall glyph.
12073
12074 @item 3
12075 at least one each of a descender and a tall glyph.
12076 @end table
12077
12078 @item ssc
12079 The amount of horizontal space (possibly negative) that should be added
12080 to the last glyph before a subscript.
12081
12082 @item skw
12083 How far to right of the center of the last glyph in the @code{\w}
12084 argument, the center of an accent from a roman font should be placed
12085 over that glyph.
12086 @end table
12087 @endDefesc
12088
12089 @DefescList {\\k, , p, }
12090 @DefescItem {\\k, @Lparen{}, ps, }
12091 @DefescListEnd {\\k, @Lbrack{}, position, @Rbrack{}}
12092 @cindex saving horizontal input line position (@code{\k})
12093 @cindex horizontal input line position, saving (@code{\k})
12094 @cindex input line position, horizontal, saving (@code{\k})
12095 @cindex position, horizontal input line, saving (@code{\k})
12096 @cindex line, input, horizontal position, saving (@code{\k})
12097 Store the current horizontal position in the @emph{input} line in number
12098 register with name @var{position} (one-character name@tie{}@var{p},
12099 two-character name @var{ps}).  Use this, for example, to return to the
12100 beginning of a string for highlighting or other decoration.
12101 @endDefesc
12102
12103 @Defreg {hp}
12104 @cindex horizontal input line position register (@code{hp})
12105 @cindex input line, horizontal position, register (@code{hp})
12106 @cindex position, horizontal, in input line, register (@code{hp})
12107 @cindex line, input, horizontal position, register (@code{hp})
12108 The current horizontal position at the input line.
12109 @endDefreg
12110
12111 @Defreg {.k}
12112 @cindex horizontal output line position register (@code{.k})
12113 @cindex output line, horizontal position, register (@code{.k})
12114 @cindex position, horizontal, in output line, register (@code{.k})
12115 @cindex line, output, horizontal position, register (@code{.k})
12116 A read-only number register containing the current horizontal output
12117 position (relative to the current indentation).
12118 @endDefreg
12119
12120 @Defesc {\\o, ', abc, '}
12121 @cindex overstriking glyphs (@code{\o})
12122 @cindex glyphs, overstriking (@code{\o})
12123 Overstrike glyphs @var{a}, @var{b}, @var{c}, @dots{}; the glyphs are
12124 centered, and the resulting spacing is the largest width of the affected
12125 glyphs.
12126 @endDefesc
12127
12128 @Defesc {\\z, , g, }
12129 @cindex zero-width printing (@code{\z}, @code{\Z})
12130 @cindex printing, zero-width (@code{\z}, @code{\Z})
12131 Print glyph @var{g} with zero width, i.e., without spacing.  Use this to
12132 overstrike glyphs left-aligned.
12133 @endDefesc
12134
12135 @Defesc {\\Z, ', anything, '}
12136 @cindex zero-width printing (@code{\z}, @code{\Z})
12137 @cindex printing, zero-width (@code{\z}, @code{\Z})
12138 Print @var{anything}, then restore the horizontal and vertical position.
12139 The argument may not contain tabs or leaders.
12140
12141 The following is an example of a strike-through macro:
12142
12143 @Example
12144 .de ST
12145 .nr ww \w'\\$1'
12146 \Z@@\v'-.25m'\l'\\n[ww]u'@@\\$1
12147 ..
12148 .
12149 This is
12150 .ST "a test"
12151 an actual emergency!
12152 @endExample
12153 @endDefesc
12154
12155
12156 @c =====================================================================
12157
12158 @node Drawing Requests, Traps, Page Motions, gtroff Reference
12159 @section Drawing Requests
12160 @cindex drawing requests
12161 @cindex requests for drawing
12162
12163 @code{gtroff} provides a number of ways to draw lines and other figures
12164 on the page.  Used in combination with the page motion commands (see
12165 @ref{Page Motions}, for more info), a wide variety of figures can be
12166 drawn.  However, for complex drawings these operations can be quite
12167 cumbersome, and it may be wise to use graphic preprocessors like
12168 @code{gpic} or @code{ggrn}.  @xref{gpic}, and @ref{ggrn}, for more
12169 information.
12170
12171 All drawing is done via escapes.
12172
12173 @DefescList {\\l, ', l, '}
12174 @DefescListEnd {\\l, ', lg, '}
12175 @cindex drawing horizontal lines (@code{\l})
12176 @cindex horizontal line, drawing (@code{\l})
12177 @cindex line, horizontal, drawing (@code{\l})
12178 Draw a line horizontally.  @var{l} is the length of the line to be
12179 drawn.  If it is positive, start the line at the current location and
12180 draw to the right; its end point is the new current location.  Negative
12181 values are handled differently: The line starts at the current location
12182 and draws to the left, but the current location doesn't move.
12183
12184 @var{l} can also be specified absolutely (i.e.@: with a leading
12185 @samp{|}), which draws back to the beginning of the input line.  Default
12186 scaling indicator is @samp{m}.
12187
12188 @cindex underscore glyph (@code{\[ru]})
12189 @cindex glyph, underscore (@code{\[ru]})
12190 @cindex line drawing glyph
12191 @cindex glyph, for line drawing
12192 The optional second parameter@tie{}@var{g} is a glyph to draw the line
12193 with.  If this second argument is not specified, @code{gtroff} uses the
12194 underscore glyph, @code{\[ru]}.
12195
12196 @cindex zero width space character (@code{\&})
12197 @cindex character, zero width space (@code{\&})
12198 @cindex space character, zero width (@code{\&})
12199 To separate the two arguments (to prevent @code{gtroff} from
12200 interpreting a drawing glyph as a scaling indicator if the glyph is
12201 represented by a single character) use @code{\&}.
12202
12203 Here a small useful example:
12204
12205 @Example
12206 .de box
12207 \[br]\\$*\[br]\l'|0\[rn]'\l'|0\[ul]'
12208 ..
12209 @endExample
12210
12211 @noindent
12212 Note that this works by outputting a box rule (a vertical line), then
12213 the text given as an argument and then another box rule.  Finally, the
12214 line drawing escapes both draw from the current location to the
12215 beginning of the @emph{input} line -- this works because the line length
12216 is negative, not moving the current point.
12217 @endDefesc
12218
12219 @DefescList {\\L, ', l, '}
12220 @DefescListEnd {\\L, ', lg, '}
12221 @cindex drawing vertical lines (@code{\L})
12222 @cindex vertical line drawing (@code{\L})
12223 @cindex line, vertical, drawing (@code{\L})
12224 @cindex line drawing glyph
12225 @cindex glyph for line drawing
12226 @cindex box rule glyph (@code{\[br]})
12227 @cindex glyph, box rule (@code{\[br]})
12228 Draw vertical lines.  Its parameters are similar to the @code{\l}
12229 escape, except that the default scaling indicator is @samp{v}.  The
12230 movement is downwards for positive values, and upwards for negative
12231 values.  The default glyph is the box rule glyph, @code{\[br]}.  As with
12232 the vertical motion escapes, text processing blindly continues where the
12233 line ends.
12234
12235 @Example
12236 This is a \L'3v'test.
12237 @endExample
12238
12239 @noindent
12240 Here is the result, produced with @code{grotty}.
12241
12242 @Example
12243 This is a
12244           |
12245           |
12246           |test.
12247 @endExample
12248 @endDefesc
12249
12250 @Defesc {\\D, ', command arg @dots{}, '}
12251 The @code{\D} escape provides a variety of drawing functions.  Note that
12252 on character devices, only vertical and horizontal lines are supported
12253 within @code{grotty}; other devices may only support a subset of the
12254 available drawing functions.
12255
12256 The default scaling indicator for all subcommands of @code{\D} is
12257 @samp{m} for horizontal distances and @samp{v} for vertical ones.
12258 Exceptions are @w{@code{\D'f @dots{}'}} and @w{@code{\D't @dots{}'}},
12259 which use @code{u} as the default, and @w{@code{\D'F@var{x} @dots{}'}},
12260 which arguments are treated similar to the @code{defcolor} request.
12261
12262 @table @code
12263 @item \D'l @var{dx} @var{dy}'
12264 @cindex line, drawing (@w{@code{\D'l @dots{}'}})
12265 @cindex drawing a line (@w{@code{\D'l @dots{}'}})
12266 Draw a line from the current location to the relative point specified by
12267 (@var{dx},@var{dy}), where positive values mean right and down,
12268 respectively.  The end point of the line is the new current location.
12269
12270 The following example is a macro for creating a box around a text
12271 string; for simplicity, the box margin is taken as a fixed value,
12272 0.2@dmn{m}.
12273
12274 @Example
12275 .de BOX
12276 .  nr @@wd \w'\\$1'
12277 \h'.2m'\
12278 \h'-.2m'\v'(.2m - \\n[rsb]u)'\
12279 \D'l 0 -(\\n[rst]u - \\n[rsb]u + .4m)'\
12280 \D'l (\\n[@@wd]u + .4m) 0'\
12281 \D'l 0 (\\n[rst]u - \\n[rsb]u + .4m)'\
12282 \D'l -(\\n[@@wd]u + .4m) 0'\
12283 \h'.2m'\v'-(.2m - \\n[rsb]u)'\
12284 \\$1\
12285 \h'.2m'
12286 ..
12287 @endExample
12288
12289 @noindent
12290 First, the width of the string is stored in register @code{@@wd}.  Then,
12291 four lines are drawn to form a box, properly offset by the box margin.
12292 The registers @code{rst} and @code{rsb} are set by the @code{\w} escape,
12293 containing the largest height and depth of the whole string.
12294
12295 @item \D'c @var{d}'
12296 @cindex circle, drawing (@w{@code{\D'c @dots{}'}})
12297 @cindex drawing a circle (@w{@code{\D'c @dots{}'}})
12298 Draw a circle with a diameter of@tie{}@var{d} with the leftmost point at
12299 the current position.  After drawing, the current location is positioned
12300 at the rightmost point of the circle.
12301
12302 @item \D'C @var{d}'
12303 @cindex circle, solid, drawing (@w{@code{\D'C @dots{}'}})
12304 @cindex drawing a solid circle (@w{@code{\D'C @dots{}'}})
12305 @cindex solid circle, drawing (@w{@code{\D'C @dots{}'}})
12306 Draw a solid circle with the same parameters and behaviour as an
12307 outlined circle.  No outline is drawn.
12308
12309 @item \D'e @var{x} @var{y}'
12310 @cindex drawing an ellipse (@w{@code{\D'e @dots{}'}})
12311 @cindex ellipse, drawing (@w{@code{\D'e @dots{}'}})
12312 Draw an ellipse with a horizontal diameter of @var{x} and a vertical
12313 diameter of @var{y} with the leftmost point at the current position.
12314 After drawing, the current location is positioned at the rightmost point
12315 of the ellipse.
12316
12317 @item \D'E @var{x} @var{y}'
12318 @cindex ellipse, solid, drawing (@w{@code{\D'E @dots{}'}})
12319 @cindex drawing a solid ellipse (@w{@code{\D'E @dots{}'}})
12320 @cindex solid ellipse, drawing (@w{@code{\D'E @dots{}'}})
12321 Draw a solid ellipse with the same parameters and behaviour as an
12322 outlined ellipse.  No outline is drawn.
12323
12324 @item \D'a @var{dx1} @var{dy1} @var{dx2} @var{dy2}'
12325 @cindex arc, drawing (@w{@code{\D'a @dots{}'}})
12326 @cindex drawing an arc (@w{@code{\D'a @dots{}'}})
12327 Draw an arc clockwise from the current location through the two
12328 specified relative locations (@var{dx1},@var{dy1}) and
12329 (@var{dx2},@var{dy2}).  The coordinates of the first point are relative
12330 to the current position, and the coordinates of the second point are
12331 relative to the first point.  After drawing, the current position is
12332 moved to the final point of the arc.
12333
12334 @item \D'~ @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
12335 @cindex drawing a spline (@w{@code{\D'~ @dots{}'}})
12336 @cindex spline, drawing (@w{@code{\D'~ @dots{}'}})
12337 Draw a spline from the current location to the relative point
12338 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}), and so on.  The
12339 current position is moved to the terminal point of the drawn curve.
12340
12341 @item \D'f @var{n}'
12342 @cindex gray shading (@w{@code{\D'f @dots{}'}})
12343 @cindex shading filled objects (@w{@code{\D'f @dots{}'}})
12344 Set the shade of gray to be used for filling solid objects
12345 to@tie{}@var{n}; @var{n}@tie{}must be an integer between 0
12346 and@tie{}1000, where 0 corresponds solid white and 1000 to solid black,
12347 and values in between correspond to intermediate shades of gray.  This
12348 applies only to solid circles, solid ellipses, and solid polygons.  By
12349 default, a level of 1000 is used.
12350
12351 Despite of being silly, the current point is moved horizontally to the
12352 right by@tie{}@var{n}.
12353
12354 @cindex @w{@code{\D'f @dots{}'}} and horizontal resolution
12355 Don't use this command!  It has the serious drawback that it is always
12356 rounded to the next integer multiple of the horizontal resolution (the
12357 value of the @code{hor} keyword in the @file{DESC} file).  Use @code{\M}
12358 (@pxref{Colors}) or @w{@code{\D'Fg @dots{}'}} instead.
12359
12360 @item \D'p @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
12361 @cindex drawing a polygon (@w{@code{\D'p @dots{}'}})
12362 @cindex polygon, drawing (@w{@code{\D'p @dots{}'}})
12363 Draw a polygon from the current location to the relative position
12364 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}) and so on.  When
12365 the specified data points are exhausted, a line is drawn back to the
12366 starting point.  The current position is changed by adding the sum of
12367 all arguments with odd index to the actual horizontal position and the
12368 even ones to the vertical position.
12369
12370 @item \D'P @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
12371 @cindex polygon, solid, drawing (@w{@code{\D'P @dots{}'}})
12372 @cindex drawing a solid polygon (@w{@code{\D'P @dots{}'}})
12373 @cindex solid polygon, drawing (@w{@code{\D'P @dots{}'}})
12374 Draw a solid polygon with the same parameters and behaviour as an
12375 outlined polygon.  No outline is drawn.
12376
12377 Here a better variant of the box macro to fill the box with some color.
12378 Note that the box must be drawn before the text since colors in
12379 @code{gtroff} are not transparent; the filled polygon would hide the
12380 text completely.
12381
12382 @Example
12383 .de BOX
12384 .  nr @@wd \w'\\$1'
12385 \h'.2m'\
12386 \h'-.2m'\v'(.2m - \\n[rsb]u)'\
12387 \M[lightcyan]\
12388 \D'P 0 -(\\n[rst]u - \\n[rsb]u + .4m) \
12389      (\\n[@@wd]u + .4m) 0 \
12390      0 (\\n[rst]u - \\n[rsb]u + .4m) \
12391      -(\\n[@@wd]u + .4m) 0'\
12392 \h'.2m'\v'-(.2m - \\n[rsb]u)'\
12393 \M[]\
12394 \\$1\
12395 \h'.2m'
12396 ..
12397 @endExample
12398
12399 If you want a filled polygon that has exactly the same size as an
12400 unfilled one, you must draw both an unfilled and a filled polygon.  A
12401 filled polygon is always smaller than an unfilled one because the latter
12402 uses straight lines with a given line thickness to connect the polygon's
12403 corners, while the former simply fills the area defined by the
12404 coordinates.
12405
12406 @Example
12407 \h'1i'\v'1i'\
12408 \# increase line thickness
12409 \Z'\D't 5p''\
12410 \# draw unfilled polygon
12411 \Z'\D'p 3 3 -6 0''\
12412 \# draw filled polygon
12413 \Z'\D'P 3 3 -6 0''
12414 @endExample
12415
12416 @item \D't @var{n}'
12417 @cindex line thickness (@w{@code{\D't @dots{}'}})
12418 @cindex thickness of lines (@w{@code{\D't @dots{}'}})
12419 Set the current line thickness to @var{n}@tie{}machine units.  A value
12420 of zero selects the smallest available line thickness.  A negative value
12421 makes the line thickness proportional to the current point size (this is
12422 the default behaviour of @acronym{AT&T} @code{troff}).
12423
12424 Despite of being silly, the current point is moved horizontally to the
12425 right by@tie{}@var{n}.
12426
12427 @item \D'F@var{scheme} @var{color_components}'
12428 @cindex unnamed fill colors (@code{\D'F@dots{}'})
12429 @cindex fill colors, unnamed (@code{\D'F@dots{}'})
12430 @cindex colors, fill, unnamed (@code{\D'F@dots{}'})
12431 Change current fill color.  @var{scheme} is a single letter denoting the
12432 color scheme: @samp{r} (rgb), @samp{c} (cmy), @samp{k} (cmyk), @samp{g}
12433 (gray), or @samp{d} (default color).  The color components use exactly
12434 the same syntax as in the @code{defcolor} request (@pxref{Colors}); the
12435 command @code{\D'Fd'} doesn't take an argument.
12436
12437 @emph{No} position changing!
12438
12439 Examples:
12440
12441 @Example
12442 \D'Fg .3'      \" same gray as \D'f 700'
12443 \D'Fr #0000ff' \" blue
12444 @endExample
12445 @end table
12446 @endDefesc
12447
12448 @xref{Graphics Commands}.
12449
12450 @Defesc {\\b, ', string, '}
12451 @cindex pile, glyph (@code{\b})
12452 @cindex glyph pile (@code{\b})
12453 @cindex stacking glyphs (@code{\b})
12454 @dfn{Pile} a sequence of glyphs vertically, and center it vertically on
12455 the current line.  Use it to build large brackets and braces.
12456
12457 Here an example how to create a large opening brace:
12458
12459 @Example
12460 \b'\[lt]\[bv]\[lk]\[bv]\[lb]'
12461 @endExample
12462
12463 @cindex @code{\b}, limitations
12464 @cindex limitations of @code{\b} escape
12465 The first glyph is on the top, the last glyph in @var{string} is at the
12466 bottom.  Note that @code{gtroff} separates the glyphs vertically by
12467 1@dmn{m}, and the whole object is centered 0.5@dmn{m} above the current
12468 baseline; the largest glyph width is used as the width for the whole
12469 object.  This rather unflexible positioning algorithm doesn't work with
12470 @option{-Tdvi} since the bracket pieces vary in height for this device.
12471 Instead, use the @code{eqn} preprocessor.
12472
12473 @xref{Manipulating Spacing}, how to adjust the vertical spacing with the
12474 @code{\x} escape.
12475 @endDefesc
12476
12477
12478 @c =====================================================================
12479
12480 @node Traps, Diversions, Drawing Requests, gtroff Reference
12481 @section Traps
12482 @cindex traps
12483
12484 @dfn{Traps} are locations that, when reached, call a specified macro.
12485 These traps can occur at a given location on the page, at a given
12486 location in the current diversion, at a blank line, after a certain
12487 number of input lines, or at the end of input.
12488
12489 @cindex planting a trap
12490 @cindex trap, planting
12491 Setting a trap is also called @dfn{planting}.
12492 @cindex trap, springing
12493 @cindex springing a trap
12494 It is also said that a trap is @dfn{sprung} if the associated macro is
12495 executed.
12496
12497 @menu
12498 * Page Location Traps::
12499 * Diversion Traps::
12500 * Input Line Traps::
12501 * Blank Line Traps::
12502 * Leading Spaces Traps::
12503 * End-of-input Traps::
12504 @end menu
12505
12506 @c ---------------------------------------------------------------------
12507
12508 @node Page Location Traps, Diversion Traps, Traps, Traps
12509 @subsection Page Location Traps
12510 @cindex page location traps
12511 @cindex traps, page location
12512
12513 @dfn{Page location traps} perform an action when @code{gtroff} reaches
12514 or passes a certain vertical location on the page.  Page location traps
12515 have a variety of purposes, including:
12516
12517 @itemize
12518 @item
12519 setting headers and footers
12520
12521 @item
12522 setting body text in multiple columns
12523
12524 @item
12525 setting footnotes
12526 @end itemize
12527
12528 @DefreqList {vpt, flag}
12529 @DefregListEndx {.vpt}
12530 @cindex enabling vertical position traps (@code{vpt})
12531 @cindex vertical position traps, enabling (@code{vpt})
12532 @cindex vertical position trap enable register (@code{.vpt})
12533 Enable vertical position traps if @var{flag} is non-zero, or disables
12534 them otherwise.  Vertical position traps are traps set by the @code{wh}
12535 or @code{dt} requests.  Traps set by the @code{it} request are not
12536 vertical position traps.  The parameter that controls whether vertical
12537 position traps are enabled is global.  Initially vertical position traps
12538 are enabled.  The current setting of this is available in the
12539 @code{.vpt} read-only number register.
12540
12541 Note that a page can't be ejected if @code{vpt} is set to zero.
12542 @endDefreq
12543
12544 @Defreq {wh, dist [@Var{macro}]}
12545 Set a page location trap.  Non-negative values for @var{dist} set the
12546 trap relative to the top of the page; negative values set the trap
12547 relative to the bottom of the page.  Default scaling indicator is
12548 @samp{v}; values of @var{dist} are always rounded to be multiples of the
12549 vertical resolution (as given in register @code{.V}).
12550
12551 @var{macro} is the name of the macro to execute when the trap is sprung.
12552 If @var{macro} is missing, remove the first trap (if any) at @var{dist}.
12553
12554 @cindex page headers
12555 @cindex page footers
12556 @cindex headers
12557 @cindex footers
12558 The following is a simple example of how many macro packages set headers
12559 and footers.
12560
12561 @Example
12562 .de hd                \" Page header
12563 '  sp .5i
12564 .  tl 'Title''date'
12565 '  sp .3i
12566 ..
12567 .
12568 .de fo                \" Page footer
12569 '  sp 1v
12570 .  tl ''%''
12571 '  bp
12572 ..
12573 .
12574 .wh 0   hd            \" trap at top of the page
12575 .wh -1i fo            \" trap one inch from bottom
12576 @endExample
12577
12578 A trap at or below the bottom of the page is ignored; it can be made
12579 active by either moving it up or increasing the page length so that the
12580 trap is on the page.
12581
12582 Negative trap values always use the @emph{current} page length; they are
12583 not converted to an absolute vertical position:
12584
12585 @Example
12586 .pl 5i
12587 .wh -1i xx
12588 .ptr
12589     @result{} xx      -240
12590 .pl 100i
12591 .ptr
12592     @result{} xx      -240
12593 @endExample
12594
12595 It is possible to have more than one trap at the same location; to do
12596 so, the traps must be defined at different locations, then moved
12597 together with the @code{ch} request; otherwise the second trap would
12598 replace the first one.  Earlier defined traps hide later defined traps
12599 if moved to the same position (the many empty lines caused by the
12600 @code{bp} request are omitted in the following example):
12601
12602 @Example
12603 .de a
12604 .  nop a
12605 ..
12606 .de b
12607 .  nop b
12608 ..
12609 .de c
12610 .  nop c
12611 ..
12612 .
12613 .wh 1i a
12614 .wh 2i b
12615 .wh 3i c
12616 .bp
12617     @result{} a b c
12618 @endExample
12619 @Example
12620 .ch b 1i
12621 .ch c 1i
12622 .bp
12623     @result{} a
12624 @endExample
12625 @Example
12626 .ch a 0.5i
12627 .bp
12628     @result{} a b
12629 @endExample
12630 @endDefreq
12631
12632 @Defreg {.t}
12633 @cindex distance to next trap register (@code{.t})
12634 @cindex trap, distance, register (@code{.t})
12635 A read-only number register holding the distance to the next trap.
12636
12637 If there are no traps between the current position and the bottom of the
12638 page, it contains the distance to the page bottom.  In a diversion, the
12639 distance to the page bottom is infinite (the returned value is the
12640 biggest integer that can be represented in @code{groff}) if there are
12641 no diversion traps.
12642 @endDefreg
12643
12644 @Defreq {ch, macro [@Var{dist}]}
12645 @cindex changing trap location (@code{ch})
12646 @cindex trap, changing location (@code{ch})
12647 Change the location of a trap.  The first argument is the name of the
12648 macro to be invoked at the trap, and the second argument is the new
12649 location for the trap (note that the parameters are specified in
12650 opposite order as in the @code{wh} request).  This is useful for
12651 building up footnotes in a diversion to allow more space at the bottom
12652 of the page for them.
12653
12654 Default scaling indicator for @var{dist} is @samp{v}.  If @var{dist} is
12655 missing, the trap is removed.
12656
12657 @c XXX
12658
12659 @ignore
12660 @Example
12661 ... (simplified) footnote example ...
12662 @endExample
12663 @end ignore
12664 @endDefreq
12665
12666 @Defreg {.ne}
12667 The read-only number register @code{.ne} contains the amount of space
12668 that was needed in the last @code{ne} request that caused a trap to be
12669 sprung.  Useful in conjunction with the @code{.trunc} register.
12670 @xref{Page Control}, for more information.
12671
12672 Since the @code{.ne} register is only set by traps it doesn't make much
12673 sense to use it outside of trap macros.
12674 @endDefreg
12675
12676 @Defreg {.trunc}
12677 @cindex @code{ne} request, and the @code{.trunc} register
12678 @cindex truncated vertical space register (@code{.trunc})
12679 A read-only register containing the amount of vertical space truncated
12680 from an @code{sp} request by the most recently sprung vertical
12681 position trap, or, if the trap was sprung by an @code{ne} request,
12682 minus the amount of vertical motion produced by the @code{ne}
12683 request.  In other words, at the point a trap is sprung, it
12684 represents the difference of what the vertical position would have
12685 been but for the trap, and what the vertical position actually is.
12686
12687 Since the @code{.trunc} register is only set by traps it doesn't make
12688 much sense to use it outside of trap macros.
12689 @endDefreg
12690
12691 @Defreg {.pe}
12692 @cindex @code{bp} request, and traps (@code{.pe})
12693 @cindex traps, sprung by @code{bp} request (@code{.pe})
12694 @cindex page ejecting register (@code{.pe})
12695 A read-only register that is set to@tie{}1 while a page is ejected with
12696 the @code{bp} request (or by the end of input).
12697
12698 Outside of traps this register is always zero.  In the following
12699 example, only the second call to@tie{}@code{x} is caused by @code{bp}.
12700
12701 @Example
12702 .de x
12703 \&.pe=\\n[.pe]
12704 .br
12705 ..
12706 .wh 1v x
12707 .wh 4v x
12708 A line.
12709 .br
12710 Another line.
12711 .br
12712     @result{} A line.
12713        .pe=0
12714        Another line.
12715
12716        .pe=1
12717 @endExample
12718 @endDefreg
12719
12720 @cindex diversions, and traps
12721 @cindex traps, and diversions
12722 An important fact to consider while designing macros is that diversions
12723 and traps do not interact normally.  For example, if a trap invokes a
12724 header macro (while outputting a diversion) that tries to change the
12725 font on the current page, the effect is not visible before the diversion
12726 has completely been printed (except for input protected with @code{\!}
12727 or @code{\?}) since the data in the diversion is already formatted.  In
12728 most cases, this is not the expected behaviour.
12729
12730 @c ---------------------------------------------------------------------
12731
12732 @node Diversion Traps, Input Line Traps, Page Location Traps, Traps
12733 @subsection Diversion Traps
12734 @cindex diversion traps
12735 @cindex traps, diversion
12736
12737 @Defreq {dt, [@Var{dist} @Var{macro}]}
12738 @cindex @code{.t} register, and diversions
12739 @cindex setting diversion trap (@code{dt})
12740 @cindex diversion trap, setting (@code{dt})
12741 @cindex trap, diversion, setting (@code{dt})
12742 Set a trap @emph{within} a diversion.  @var{dist} is the location of the
12743 trap (identical to the @code{wh} request; default scaling indicator is
12744 @samp{v}) and @var{macro} is the name of the macro to be invoked.  If
12745 called without arguments, the diversion trap is removed.
12746
12747 Note that there exists only a single diversion trap.
12748
12749 The number register @code{.t} still works within diversions.
12750 @xref{Diversions}, for more information.
12751 @endDefreq
12752
12753 @c ---------------------------------------------------------------------
12754
12755 @node Input Line Traps, Blank Line Traps, Diversion Traps, Traps
12756 @subsection Input Line Traps
12757 @cindex input line traps
12758 @cindex traps, input line
12759
12760 @DefreqList {it, n macro}
12761 @DefreqListEndx {itc, n macro}
12762 @cindex setting input line trap (@code{it})
12763 @cindex input line trap, setting (@code{it})
12764 @cindex trap, input line, setting (@code{it})
12765 Set an input line trap.  @var{n}@tie{}is the number of lines of input
12766 that may be read before springing the trap, @var{macro} is the macro to
12767 be invoked.  Request lines are not counted as input lines.
12768
12769 For example, one possible use is to have a macro that prints the next
12770 @var{n}@tie{}lines in a bold font.
12771
12772 @Example
12773 .de B
12774 .  it \\$1 B-end
12775 .  ft B
12776 ..
12777 .
12778 .de B-end
12779 .  ft R
12780 ..
12781 @endExample
12782
12783 @cindex input line traps and interrupted lines (@code{itc})
12784 @cindex interrupted lines and input line traps (@code{itc})
12785 @cindex traps, input line, and interrupted lines (@code{itc})
12786 @cindex lines, interrupted, and input line traps (@code{itc})
12787 The @code{itc} request is identical except that an interrupted text line
12788 (ending with @code{\c}) is not counted as a separate line.
12789
12790 Both requests are associated with the current environment
12791 (@pxref{Environments}); switching to another environment disables the
12792 current input trap, and going back reactivates it, restoring the number
12793 of already processed lines.
12794 @endDefreq
12795
12796 @c ---------------------------------------------------------------------
12797
12798 @node Blank Line Traps, Leading Spaces Traps, Input Line Traps, Traps
12799 @subsection Blank Line Traps
12800 @cindex blank line traps
12801 @cindex traps, blank line
12802
12803 @Defreq {blm, macro}
12804 @cindex blank line macro (@code{blm})
12805 Set a blank line trap.  @code{gtroff} executes @var{macro} when it
12806 encounters a blank line in the input file.
12807 @endDefreq
12808
12809 @c ---------------------------------------------------------------------
12810
12811 @node Leading Spaces Traps, End-of-input Traps, Blank Line Traps, Traps
12812 @subsection Leading Spaces Traps
12813 @cindex leading spaces traps
12814 @cindex traps, leading spaces
12815
12816 @DefreqList {lsm, macro}
12817 @DefregItemx {lsn}
12818 @DefregListEndx {lss}
12819 @cindex leading spaces macro (@code{lsm})
12820 Set a leading spaces trap.  @code{gtroff} executes @var{macro} when it
12821 encounters leading spaces in an input line; the implicit line break
12822 that normally happens in this case is suppressed.  A line consisting
12823 of spaces only, however, is treated as an empty line, possibly subject
12824 to an empty line macro set with the @code{blm} request.
12825
12826 Leading spaces are removed from the input line before calling the
12827 leading spaces macro.  The number of removed spaces is stored in
12828 register @code{lsn}; the horizontal space that would be emitted if
12829 there was no leading space macro is stored in register @code{lss}.
12830 Note that @code{lsn} and @code{lss} are available even if no leading
12831 space macro has been set.
12832
12833 The first thing a leading space macro sees is a token.  However, some
12834 escapes like @code{\f} or @code{\m} are handled on the fly (see
12835 @ref{Gtroff Internals}, for a complete list) without creating a token
12836 at all.  Consider that a line starts with two spaces followed by
12837 @code{\fIfoo}.  While skipping the spaces @code{\fI} is handled too so
12838 that groff's current font is properly set to @samp{I}, but the leading
12839 space macro only sees @code{foo}, without the preceding @code{\fI}.
12840 If the macro should see the font escape you have to `protect' it with
12841 something that creates a token, for example with @code{\&\fIfoo}.
12842 @endDefreq
12843
12844 @c ---------------------------------------------------------------------
12845
12846 @node End-of-input Traps,  , Leading Spaces Traps, Traps
12847 @subsection End-of-input Traps
12848 @cindex end-of-input traps
12849 @cindex traps, end-of-input
12850
12851 @Defreq {em, macro}
12852 @cindex setting end-of-input trap (@code{em})
12853 @cindex end-of-input trap, setting (@code{em})
12854 @cindex trap, end-of-input, setting (@code{em})
12855 @cindex end-of-input macro (@code{em})
12856 @cindex macro, end-of-input (@code{em})
12857 Set a trap at the end of input.  @var{macro} is executed after the last
12858 line of the input file has been processed.
12859
12860 For example, if the document had to have a section at the bottom of the
12861 last page for someone to approve it, the @code{em} request could be
12862 used.
12863
12864 @Example
12865 .de approval
12866 \c
12867 .  ne 3v
12868 .  sp (\\n[.t]u - 3v)
12869 .  in +4i
12870 .  lc _
12871 .  br
12872 Approved:\t\a
12873 .  sp
12874 Date:\t\t\a
12875 ..
12876 .
12877 .em approval
12878 @endExample
12879
12880 The @code{\c} in the above example needs explanation.  For historical
12881 reasons (and for compatibility with @acronym{AT&T} @code{troff}), the
12882 end macro exits as soon as it causes a page break and no remaining
12883 data is in the partially collected line.
12884
12885 Let us assume that there is no @code{\c} in the above @code{approval}
12886 macro, and that the page is full and has been ended with, say, a
12887 @code{br} request.  The @code{ne} request now causes the start of a new
12888 page, which in turn makes @code{troff} exit immediately for the reasons
12889 just described.  In most situations this is not intended.
12890
12891 To always force processing the whole end macro independently of this
12892 behaviour it is thus advisable to insert something that starts an
12893 empty partially filled line (@code{\c}) whenever there is a chance that
12894 a page break can happen.  In the above example, the call of the
12895 @code{ne} request assures that the remaining code stays on the same
12896 page, so we have to insert @code{\c} only once.
12897
12898 The next example shows how to append three lines, then starting a new
12899 page unconditionally.  Since @w{@samp{.ne 1}} doesn't give the desired
12900 effect -- there is always one line available or we are already at the
12901 beginning of the next page -- we temporarily increase the page length
12902 by one line so that we can use @w{@samp{.ne 2}}.
12903
12904 @Example
12905 .de EM
12906 .pl +1v
12907 \c
12908 .ne 2
12909 line one
12910 .br
12911 \c
12912 .ne 2
12913 line two
12914 .br
12915 \c
12916 .ne 2
12917 line three
12918 .br
12919 .pl -1v
12920 \c
12921 'bp
12922 ..
12923 .em EM
12924 @endExample
12925
12926 Note that this specific feature affects only the first potential page
12927 break caused by the end macro; further page breaks emitted by the end
12928 macro are handled normally.
12929
12930 Another possible use of the @code{em} request is to make @code{gtroff}
12931 emit a single large page instead of multiple pages.  For example, one
12932 may want to produce a long plain-text file for reading on-screen.  The
12933 idea is to set the page length at the beginning of the document to a
12934 very large value to hold all the text, and automatically adjust it to
12935 the exact height of the document after the text has been output.
12936
12937 @Example
12938 .de adjust-page-length
12939 .  br
12940 .  pl \\n[nl]u \" \n[nl] holds the current vert. position
12941 ..
12942 .
12943 .de single-page-mode
12944 .  pl 99999
12945 .  em adjust-page-length
12946 ..
12947 .
12948 .\" activate the above code
12949 .single-page-mode
12950 @endExample
12951
12952 Since only one end-of-input trap does exist and other macro packages
12953 may already use it, care must be taken not to break the mechanism.  A
12954 simple solution would be to append the above macro to the macro
12955 package's end-of-input macro using the @code{.am} request.
12956 @endDefreq
12957
12958
12959 @c =====================================================================
12960
12961 @node Diversions, Environments, Traps, gtroff Reference
12962 @section Diversions
12963 @cindex diversions
12964
12965 In @code{gtroff} it is possible to @dfn{divert} text into a named
12966 storage area.  Due to the similarity to defining macros it is sometimes
12967 said to be stored in a macro.  This is used for saving text for output
12968 at a later time, which is useful for keeping blocks of text on the same
12969 page, footnotes, tables of contents, and indices.
12970
12971 @cindex top-level diversion
12972 @cindex diversion, top-level
12973 For orthogonality it is said that @code{gtroff} is in the @dfn{top-level
12974 diversion} if no diversion is active (i.e., the data is diverted to the
12975 output device).
12976
12977 Although the following requests can be used to create diversions,
12978 simply using an undefined diversion will cause it to be defined as empty.
12979 @xref{Identifiers}.
12980
12981 @DefreqList {di, macro}
12982 @DefreqListEndx {da, macro}
12983 @cindex beginning diversion (@code{di})
12984 @cindex diversion, beginning (@code{di})
12985 @cindex ending diversion (@code{di})
12986 @cindex diversion, ending (@code{di})
12987 @cindex appending to a diversion (@code{da})
12988 @cindex diversion, appending (@code{da})
12989 Begin a diversion.  Like the @code{de} request, it takes an argument of
12990 a macro name to divert subsequent text into.  The @code{da} macro
12991 appends to an existing diversion.
12992
12993 @code{di} or @code{da} without an argument ends the diversion.
12994
12995 The current partially filled line is included into the diversion.  See
12996 the @code{box} request below for an example.  Note that switching to
12997 another (empty) environment (with the @code{ev} request) avoids the
12998 inclusion of the current partially filled line.
12999 @endDefreq
13000
13001 @DefreqList {box, macro}
13002 @DefreqListEndx {boxa, macro}
13003 Begin (or append to) a diversion like the @code{di} and @code{da}
13004 requests.  The difference is that @code{box} and @code{boxa} do not
13005 include a partially filled line in the diversion.
13006
13007 Compare this:
13008
13009 @Example
13010 Before the box.
13011 .box xxx
13012 In the box.
13013 .br
13014 .box
13015 After the box.
13016 .br
13017     @result{} Before the box.  After the box.
13018 .xxx
13019     @result{} In the box.
13020 @endExample
13021
13022 @noindent
13023 with this:
13024
13025 @Example
13026 Before the diversion.
13027 .di yyy
13028 In the diversion.
13029 .br
13030 .di
13031 After the diversion.
13032 .br
13033     @result{} After the diversion.
13034 .yyy
13035     @result{} Before the diversion.  In the diversion.
13036 @endExample
13037
13038 @code{box} or @code{boxa} without an argument ends the diversion.
13039 @endDefreq
13040
13041 @DefregList {.z}
13042 @DefregListEndx {.d}
13043 @cindex @code{nl} register, and @code{.d}
13044 @cindex nested diversions
13045 @cindex diversion, nested
13046 @cindex diversion name register (@code{.z})
13047 @cindex vertical position in diversion register (@code{.d})
13048 @cindex position, vertical, in diversion, register (@code{.d})
13049 @cindex diversion, vertical position in, register (@code{.d})
13050 Diversions may be nested.  The read-only number register @code{.z}
13051 contains the name of the current diversion (this is a string-valued
13052 register).  The read-only number register @code{.d} contains the current
13053 vertical place in the diversion.  If not in a diversion it is the same
13054 as register @code{nl}.
13055 @endDefreg
13056
13057 @Defreg {.h}
13058 @cindex high-water mark register (@code{.h})
13059 @cindex mark, high-water, register (@code{.h})
13060 @cindex position of lowest text line (@code{.h})
13061 @cindex text line, position of lowest (@code{.h})
13062 The @dfn{high-water mark} on the current page or in the current
13063 diversion.  It corresponds to the text baseline of the lowest line
13064 on the page.  This is a read-only register.
13065
13066 @Example
13067 .tm .h==\n[.h], nl==\n[nl]
13068     @result{} .h==0, nl==-1
13069 This is a test.
13070 .br
13071 .sp 2
13072 .tm .h==\n[.h], nl==\n[nl]
13073     @result{} .h==40, nl==120
13074 @endExample
13075
13076 @cindex @code{.h} register, difference to @code{nl}
13077 @cindex @code{nl} register, difference to @code{.h}
13078 @noindent
13079 As can be seen in the previous example, empty lines are not considered
13080 in the return value of the @code{.h} register.
13081 @endDefreg
13082
13083 @DefregList {dn}
13084 @DefregListEndx {dl}
13085 @cindex @code{dn} register, and @code{da} (@code{boxa})
13086 @cindex @code{dl} register, and @code{da} (@code{boxa})
13087 @cindex @code{da} request, and @code{dn} (@code{dl})
13088 @cindex @code{boxa} request, and @code{dn} (@code{dl})
13089 After completing a diversion, the read-write number registers @code{dn}
13090 and @code{dl} contain the vertical and horizontal size of the diversion.
13091 Note that only the just processed lines are counted: For the computation
13092 of @code{dn} and @code{dl}, the requests @code{da} and @code{boxa} are
13093 handled as if @code{di} and @code{box} had been used -- lines that have
13094 been already stored in a macro are not taken into account.
13095
13096 @Example
13097 .\" Center text both horizontally & vertically
13098 .
13099 .\" Enclose macro definitions in .eo and .ec
13100 .\" to avoid the doubling of the backslash
13101 .eo
13102 .\" macro .(c starts centering mode
13103 .de (c
13104 .  br
13105 .  ev (c
13106 .  evc 0
13107 .  in 0
13108 .  nf
13109 .  di @@c
13110 ..
13111 @endExample
13112 @Example
13113 .\" macro .)c terminates centering mode
13114 .de )c
13115 .  br
13116 .  ev
13117 .  di
13118 .  nr @@s (((\n[.t]u - \n[dn]u) / 2u) - 1v)
13119 .  sp \n[@@s]u
13120 .  ce 1000
13121 .  @@c
13122 .  ce 0
13123 .  sp \n[@@s]u
13124 .  br
13125 .  fi
13126 .  rr @@s
13127 .  rm @@c
13128 ..
13129 .\" End of macro definitions, restore escape mechanism
13130 .ec
13131 @endExample
13132 @endDefreg
13133
13134 @DefescList {\\!, , , }
13135 @DefescListEndx {\\?, , anything, \\?}
13136 @cindex transparent output (@code{\!}, @code{\?})
13137 @cindex output, transparent (@code{\!}, @code{\?})
13138 Prevent requests, macros, and escapes from being interpreted when read
13139 into a diversion.  Both escapes take the given text and
13140 @dfn{transparently} embed it into the diversion.  This is useful for
13141 macros that shouldn't be invoked until the diverted text is actually
13142 output.
13143
13144 The @code{\!} escape transparently embeds text up to and including the
13145 end of the line.  The @code{\?} escape transparently embeds text until
13146 the next occurrence of the @code{\?} escape.  Example:
13147
13148 @Example
13149 \?@var{anything}\?
13150 @endExample
13151
13152 @cindex @code{\?}, and copy-in mode
13153 @cindex copy-in mode, and @code{\?}
13154 @cindex mode, copy-in, and @code{\?}
13155 @cindex @code{\!}, and copy-in mode
13156 @cindex copy-in mode, and @code{\!}
13157 @cindex mode, copy-in, and @code{\!}
13158 @noindent
13159 @var{anything} may not contain newlines; use @code{\!}  to embed
13160 newlines in a diversion.  The escape sequence @code{\?} is also
13161 recognized in copy mode and turned into a single internal code; it is
13162 this code that terminates @var{anything}.  Thus the following example
13163 prints@tie{}4.
13164
13165 @Example
13166 .nr x 1
13167 .nf
13168 .di d
13169 \?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
13170 .di
13171 .nr x 2
13172 .di e
13173 .d
13174 .di
13175 .nr x 3
13176 .di f
13177 .e
13178 .di
13179 .nr x 4
13180 .f
13181 @endExample
13182
13183 Both escapes read the data in copy mode.
13184
13185 @cindex @code{\!}, in top-level diversion
13186 @cindex top-level diversion, and @code{\!}
13187 @cindex diversion, top-level, and @code{\!}
13188 If @code{\!} is used in the top-level diversion, its argument is
13189 directly embedded into the @code{gtroff} intermediate output.  This can
13190 be used for example to control a postprocessor that processes the data
13191 before it is sent to the device driver.
13192
13193 @cindex @code{\?}, in top-level diversion
13194 @cindex top-level diversion, and @code{\?}
13195 @cindex diversion, top-level, and @code{\?}
13196 The @code{\?} escape used in the top-level diversion produces no output
13197 at all; its argument is simply ignored.
13198 @endDefesc
13199
13200 @cindex @code{\!}, and @code{output} request
13201 @cindex @code{output} request, and @code{\!}
13202 @cindex @code{output} request, and copy-in mode
13203 @cindex copy-in mode, and @code{output} request
13204 @cindex mode, copy-in, and @code{output} request
13205 @Defreq {output, string}
13206 Emit @var{string} directly to the @code{gtroff} intermediate output
13207 (subject to copy mode interpretation); this is similar to @code{\!} used
13208 at the top level.  An initial double quote in @var{string} is stripped
13209 off to allow initial blanks.
13210
13211 This request can't be used before the first page has started -- if you
13212 get an error, simply insert @code{.br} before the @code{output} request.
13213
13214 Without argument, @code{output} is ignored.
13215
13216 Use with caution!  It is normally only needed for mark-up used by a
13217 postprocessor that does something with the output before sending it to
13218 the output device, filtering out @var{string} again.
13219 @endDefreq
13220
13221 @Defreq {asciify, div}
13222 @cindex unformatting diversions (@code{asciify})
13223 @cindex diversion, unformatting (@code{asciify})
13224 @cindex @code{trin} request, and @code{asciify}
13225 @dfn{Unformat} the diversion specified by @var{div} in such a way that
13226 @acronym{ASCII} characters, characters translated with the @code{trin}
13227 request, space characters, and some escape sequences that were formatted
13228 and diverted are treated like ordinary input characters when the
13229 diversion is reread.  It can be also used for gross hacks; for example,
13230 the following sets register@tie{}@code{n} to@tie{}1.
13231
13232 @Example
13233 .tr @@.
13234 .di x
13235 @@nr n 1
13236 .br
13237 .di
13238 .tr @@@@
13239 .asciify x
13240 .x
13241 @endExample
13242
13243 Note that @code{asciify} cannot return all items in a diversion back
13244 to their source equivalent, nodes such as @code{\N[...]} will still
13245 remain as nodes, so the result cannot be guaranteed to be a pure string.
13246
13247 @xref{Copy-in Mode}.
13248 @endDefreq
13249
13250 @Defreq {unformat, div}
13251 Like @code{asciify}, unformat the specified diversion.  However,
13252 @code{unformat} only unformats spaces and tabs between words.
13253 Unformatted tabs are treated as input tokens, and spaces are stretchable
13254 again.
13255
13256 The vertical size of lines is not preserved; glyph information (font,
13257 font size, space width, etc.)@: is retained.
13258 @endDefreq
13259
13260
13261 @c =====================================================================
13262
13263 @node Environments, Suppressing output, Diversions, gtroff Reference
13264 @section Environments
13265 @cindex environments
13266
13267 It happens frequently that some text should be printed in a certain
13268 format regardless of what may be in effect at the time, for example, in
13269 a trap invoked macro to print headers and footers.  To solve this
13270 @code{gtroff} processes text in @dfn{environments}.  An environment
13271 contains most of the parameters that control text processing.  It is
13272 possible to switch amongst these environments; by default @code{gtroff}
13273 processes text in environment@tie{}0.  The following is the information
13274 kept in an environment.
13275
13276 @itemize @bullet
13277 @item
13278 font parameters (size, family, style, glyph height and slant, space and
13279 sentence space size)
13280
13281 @item
13282 page parameters (line length, title length, vertical spacing, line
13283 spacing, indentation, line numbering, centering, right-justifying,
13284 underlining, hyphenation data)
13285
13286 @item
13287 fill and adjust mode
13288
13289 @item
13290 tab stops, tab and leader characters, escape character, no-break and
13291 hyphen indicators, margin character data
13292
13293 @item
13294 partially collected lines
13295
13296 @item
13297 input traps
13298
13299 @item
13300 drawing and fill colours
13301 @end itemize
13302
13303 These environments may be given arbitrary names (see @ref{Identifiers},
13304 for more info).  Old versions of @code{troff} only had environments
13305 named @samp{0}, @samp{1}, and @samp{2}.
13306
13307 @DefreqList {ev, [@Var{env}]}
13308 @DefregListEndx {.ev}
13309 @cindex switching environments (@code{ev})
13310 @cindex environment, switching (@code{ev})
13311 @cindex environment number/name register (@code{.ev})
13312 Switch to another environment.  The argument @var{env} is the name of
13313 the environment to switch to.  With no argument, @code{gtroff} switches
13314 back to the previous environment.  There is no limit on the number of
13315 named environments; they are created the first time that they are
13316 referenced.  The @code{.ev} read-only register contains the name or
13317 number of the current environment.  This is a string-valued register.
13318
13319 Note that a call to @code{ev} (with argument) pushes the previously
13320 active environment onto a stack.  If, say, environments @samp{foo},
13321 @samp{bar}, and @samp{zap} are called (in that order), the first
13322 @code{ev} request without parameter switches back to environment
13323 @samp{bar} (which is popped off the stack), and a second call switches
13324 back to environment @samp{foo}.
13325
13326 Here is an example:
13327
13328 @Example
13329 .ev footnote-env
13330 .fam N
13331 .ps 6
13332 .vs 8
13333 .ll -.5i
13334 .ev
13335
13336 ...
13337
13338 .ev footnote-env
13339 \(dg Note the large, friendly letters.
13340 .ev
13341 @endExample
13342 @endDefreq
13343
13344 @Defreq {evc, env}
13345 @cindex copying environment (@code{evc})
13346 @cindex environment, copying (@code{evc})
13347 Copy the environment @var{env} into the current environment.
13348
13349 The following environment data is not copied:
13350
13351 @itemize @bullet
13352 @item
13353 Partially filled lines.
13354
13355 @item
13356 The status whether the previous line was interrupted.
13357
13358 @item
13359 The number of lines still to center, or to right-justify, or to
13360 underline (with or without underlined spaces); they are set to zero.
13361
13362 @item
13363 The status whether a temporary indentation is active.
13364
13365 @item
13366 Input traps and its associated data.
13367
13368 @item
13369 Line numbering mode is disabled; it can be reactivated with @w{@samp{.nm
13370 +0}}.
13371
13372 @item
13373 The number of consecutive hyphenated lines (set to zero).
13374 @end itemize
13375 @endDefreq
13376
13377 @DefregList {.w}
13378 @DefregItemx {.cht}
13379 @DefregItemx {.cdp}
13380 @DefregListEndx {.csk}
13381 @cindex environment, dimensions of last glyph (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
13382 @cindex width, of last glyph (@code{.w})
13383 @cindex height, of last glyph (@code{.cht})
13384 @cindex depth, of last glyph (@code{.cdp})
13385 @cindex skew, of last glyph (@code{.csk})
13386 @cindex last glyph, dimensions (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
13387 @cindex glyph, last, dimensions (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
13388 The @code{\n[.w]} register contains the width of the last glyph added to
13389 the current environment.
13390
13391 The @code{\n[.cht]} register contains the height of the last glyph added
13392 to the current environment.
13393
13394 The @code{\n[.cdp]} register contains the depth of the last glyph added
13395 to the current environment.  It is positive for glyphs extending below
13396 the baseline.
13397
13398 The @code{\n[.csk]} register contains the @dfn{skew} (how far to the
13399 right of the glyph's center that @code{gtroff} should place an accent)
13400 of the last glyph added to the current environment.
13401 @endDefreg
13402
13403 @Defreg {.n}
13404 @cindex environment, previous line length (@code{.n})
13405 @cindex line length, previous (@code{.n})
13406 @cindex length of previous line (@code{.n})
13407 @cindex previous line length (@code{.n})
13408 The @code{\n[.n]} register contains the length of the previous output
13409 line in the current environment.
13410 @endDefreg
13411
13412
13413 @c =====================================================================
13414
13415 @node Suppressing output, Colors, Environments, gtroff Reference
13416 @section Suppressing output
13417
13418 @Defesc {\\O, , num, }
13419 @cindex suppressing output (@code{\O})
13420 @cindex output, suppressing (@code{\O})
13421 Disable or enable output depending on the value of @var{num}:
13422
13423 @table @samp
13424 @item \O0
13425 Disable any glyphs from being emitted to the device driver, provided
13426 that the escape occurs at the outer level (see @code{\O[3]} and
13427 @code{\O[4]}).  Motion is not suppressed so effectively @code{\O[0]}
13428 means @emph{pen up}.
13429
13430 @item \O1
13431 Enable output of glyphs, provided that the escape occurs at the outer
13432 level.
13433 @end table
13434
13435 @vindex opminx
13436 @vindex opminy
13437 @vindex opmaxx
13438 @vindex opmaxy
13439 @code{\O0} and @code{\O1} also reset the four registers @samp{opminx},
13440 @samp{opminy}, @samp{opmaxx}, and @samp{opmaxy} to @minus{}1.
13441 @xref{Register Index}.  These four registers mark the top left and
13442 bottom right hand corners of a box that encompasses all written glyphs.
13443
13444 For example the input text:
13445
13446 @Example
13447 Hello \O[0]world \O[1]this is a test.
13448 @endExample
13449
13450 @noindent
13451 produces the following output:
13452
13453 @Example
13454 Hello       this is a test.
13455 @endExample
13456
13457 @table @samp
13458 @item \O2
13459 Provided that the escape occurs at the outer level, enable output of
13460 glyphs and also write out to @code{stderr} the page number and four
13461 registers encompassing the glyphs previously written since the last call
13462 to @code{\O}.
13463
13464 @item \O3
13465 Begin a nesting level.  At start-up, @code{gtroff} is at outer level.
13466 The current level is contained within the read-only register @code{.O}.
13467 @xref{Built-in Registers}.
13468
13469 @item \O4
13470 End a nesting level.  The current level is contained within the
13471 read-only register @code{.O}.  @xref{Built-in Registers}.
13472
13473 @item \O[5@var{P}@var{filename}]
13474 This escape is @code{grohtml} specific.  Provided that this escape
13475 occurs at the outer nesting level write the @code{filename} to
13476 @code{stderr}.  The position of the image, @var{P}, must be specified
13477 and must be one of @code{l}, @code{r}, @code{c}, or@tie{}@code{i} (left,
13478 right, centered, inline).  @var{filename} is associated with the
13479 production of the next inline image.
13480 @end table
13481 @endDefesc
13482
13483
13484 @c =====================================================================
13485
13486 @node Colors, I/O, Suppressing output, gtroff Reference
13487 @section Colors
13488 @cindex colors
13489
13490 @DefreqList {color, [@Var{n}]}
13491 @DefregListEndx {.color}
13492 If @var{n} is missing or non-zero, activate colors (this is the
13493 default); otherwise, turn it off.
13494
13495 The read-only number register @code{.color} is@tie{}1 if colors are
13496 active, 0@tie{}otherwise.
13497
13498 Internally, @code{color} sets a global flag; it does not produce a
13499 token.  Similar to the @code{cp} request, you should use it at the
13500 beginning of your document to control color output.
13501
13502 Colors can be also turned off with the @option{-c} command-line option.
13503 @endDefreq
13504
13505 @Defreq {defcolor, ident scheme color_components}
13506 Define color with name @var{ident}.  @var{scheme} can be one of the
13507 following values: @code{rgb} (three components), @code{cmy} (three
13508 components), @code{cmyk} (four components), and @code{gray} or
13509 @code{grey} (one component).
13510
13511 @cindex default color
13512 @cindex color, default
13513 Color components can be given either as a hexadecimal string or as
13514 positive decimal integers in the range 0--65535.  A hexadecimal string
13515 contains all color components concatenated.  It must start with either
13516 @code{#} or @code{##}; the former specifies hex values in the range
13517 0--255 (which are internally multiplied by@tie{}257), the latter in the
13518 range 0--65535.  Examples: @code{#FFC0CB} (pink), @code{##ffff0000ffff}
13519 (magenta).  The default color name @c{default} can't be redefined; its
13520 value is device-specific (usually black).  It is possible that the
13521 default color for @code{\m} and @code{\M} is not identical.
13522
13523 @cindex @code{f} unit, and colors
13524 @cindex unit, @code{f}, and colors
13525 A new scaling indicator@tie{}@code{f} has been introduced, which
13526 multiplies its value by 65536; this makes it convenient to specify color
13527 components as fractions in the range 0 to@tie{}1 (1f equals 65536u).
13528 Example:
13529
13530 @Example
13531 .defcolor darkgreen rgb 0.1f 0.5f 0.2f
13532 @endExample
13533
13534 Note that @code{f} is the default scaling indicator for the
13535 @code{defcolor} request, thus the above statement is equivalent to
13536
13537 @Example
13538 .defcolor darkgreen rgb 0.1 0.5 0.2
13539 @endExample
13540 @endDefreq
13541
13542 @DefreqList {gcolor, [@Var{color}]}
13543 @DefescItemx {\\m, , c, }
13544 @DefescItem {\\m, @Lparen{}, co, }
13545 @DefescItem {\\m, @Lbrack{}, color, @Rbrack{}}
13546 @DefregListEndx {.m}
13547 Set (glyph) drawing color.  The following examples show how to turn the
13548 next four words red.
13549
13550 @Example
13551 .gcolor red
13552 these are in red
13553 .gcolor
13554 and these words are in black.
13555 @endExample
13556
13557 @Example
13558 \m[red]these are in red\m[] and these words are in black.
13559 @endExample
13560
13561 The escape @code{\m[]} returns to the previous color, as does a call to
13562 @code{gcolor} without an argument.
13563
13564 @cindex drawing color name register (@code{.m})
13565 @cindex name, drawing color, register (@code{.m})
13566 @cindex color name, drawing, register (@code{.m})
13567 The name of the current drawing color is available in the read-only,
13568 string-valued number register @samp{.m}.
13569
13570 The drawing color is associated with the current environment
13571 (@pxref{Environments}).
13572
13573 Note that @code{\m} doesn't produce an input token in @code{gtroff}.  As
13574 a consequence, it can be used in requests like @code{mc} (which expects
13575 a single character as an argument) to change the color on the fly:
13576
13577 @Example
13578 .mc \m[red]x\m[]
13579 @endExample
13580 @endDefesc
13581
13582 @DefreqList {fcolor, [@Var{color}]}
13583 @DefescItemx {\\M, , c, }
13584 @DefescItem {\\M, @Lparen{}, co, }
13585 @DefescItem {\\M, @Lbrack{}, color, @Rbrack{}}
13586 @DefregListEndx {.M}
13587 Set fill (background) color for filled objects drawn with the
13588 @code{\D'@dots{}'} commands.
13589
13590 A red ellipse can be created with the following code:
13591
13592 @Example
13593 \M[red]\h'0.5i'\D'E 2i 1i'\M[]
13594 @endExample
13595
13596 The escape @code{\M[]} returns to the previous fill color, as does a
13597 call to @code{fcolor} without an argument.
13598
13599 @cindex background color name register (@code{.M})
13600 @cindex name, background color, register (@code{.M})
13601 @cindex color name, background, register (@code{.M})
13602 @cindex fill color name register (@code{.M})
13603 @cindex name, fill color, register (@code{.M})
13604 @cindex color name, fill, register (@code{.M})
13605 The name of the current fill (background) color is available in the
13606 read-only, string-valued number register @samp{.M}.
13607
13608 The fill color is associated with the current environment
13609 (@pxref{Environments}).
13610
13611 Note that @code{\M} doesn't produce an input token in @code{gtroff}.
13612 @endDefesc
13613
13614
13615 @c =====================================================================
13616
13617 @node I/O, Postprocessor Access, Colors, gtroff Reference
13618 @section I/O
13619 @cindex i/o
13620 @cindex input and output requests
13621 @cindex requests for input and output
13622 @cindex output and input requests
13623
13624 @code{gtroff} has several requests for including files:
13625
13626 @Defreq {so, file}
13627 @cindex including a file (@code{so})
13628 @cindex file, inclusion (@code{so})
13629 Read in the specified @var{file} and includes it in place of the
13630 @code{so} request.  This is quite useful for large documents, e.g.@:
13631 keeping each chapter in a separate file.  @xref{gsoelim}, for more
13632 information.
13633
13634 Since @code{gtroff} replaces the @code{so} request with the contents of
13635 @code{file}, it makes a difference whether the data is terminated with a
13636 newline or not: Assuming that file @file{xxx} contains the word
13637 @samp{foo} without a final newline, this
13638
13639 @Example
13640 This is
13641 .so xxx
13642 bar
13643 @endExample
13644
13645 @noindent
13646 yields @samp{This is foobar}.
13647
13648 The search path for @var{file} can be controlled with the @option{-I}
13649 command-line option.
13650 @endDefreq
13651
13652 @Defreq {pso, command}
13653 Read the standard output from the specified @var{command} and includes
13654 it in place of the @code{pso} request.
13655
13656 @cindex safer mode
13657 @cindex mode, safer
13658 @cindex unsafe mode
13659 @cindex mode, unsafe
13660 This request causes an error if used in safer mode (which is the
13661 default).  Use @code{groff}'s or @code{troff}'s @option{-U} option to
13662 activate unsafe mode.
13663
13664 The comment regarding a final newline for the @code{so} request is valid
13665 for @code{pso} also.
13666 @endDefreq
13667
13668 @Defreq {mso, file}
13669 Identical to the @code{so} request except that @code{gtroff} searches
13670 for the specified @var{file} in the same directories as macro files for
13671 the @option{-m} command-line option.
13672 If the file name to be included has the form @file{@var{name}.tmac} and it
13673 isn't found, @code{mso} tries to include @file{tmac.@var{name}} and vice
13674 versa.
13675 If the file does not exist, a warning of type @samp{file} is emitted.
13676 @xref{Debugging}, for information about warnings.
13677 @endDefreq
13678
13679 @DefreqList {trf, file}
13680 @DefreqListEndx {cf, file}
13681 @cindex transparent output (@code{cf}, @code{trf})
13682 @cindex output, transparent (@code{cf}, @code{trf})
13683 @cindex @code{cf} request, and copy-in mode
13684 @cindex copy-in mode, and @code{cf} request
13685 @cindex mode, copy-in, and @code{cf} request
13686 @cindex @code{trf} request, and copy-in mode
13687 @cindex copy-in mode, and @code{trf} request
13688 @cindex mode, copy-in, and @code{trf} request
13689 Transparently output the contents of @var{file}.  Each line is output as
13690 if it were preceded by @code{\!}; however, the lines are @emph{not}
13691 subject to copy mode interpretation.  If the file does not end with a
13692 newline, then a newline is added (@code{trf} only).  For example, to
13693 define a macro@tie{}@code{x} containing the contents of
13694 file@tie{}@file{f}, use
13695
13696 @Example
13697 .ev 1
13698 .di x
13699 .trf f
13700 .di
13701 .ev
13702 @endExample
13703
13704 @noindent
13705 The calls to @code{ev} prevent that the current partial input line
13706 becomes part of the diversion.
13707
13708 Both @code{trf} and @code{cf}, when used in a diversion, embeds an
13709 object in the diversion which, when reread, causes the contents of
13710 @var{file} to be transparently copied through to the output.  In
13711 Unix @code{troff}, the contents of @var{file} is immediately copied
13712 through to the output regardless of whether there is a current
13713 diversion; this behaviour is so anomalous that it must be considered a
13714 bug.
13715
13716 @cindex @code{trf} request, and invalid characters
13717 @cindex characters, invalid for @code{trf} request
13718 @cindex invalid characters for @code{trf} request
13719
13720 While @code{cf} copies the contents of @var{file} completely
13721 unprocessed, @code{trf} disallows characters such as NUL that are not
13722 valid @code{gtroff} input characters (@pxref{Identifiers}).
13723
13724 For @code{cf}, within a diversion, `completely unprocessed' means that
13725 each line of a file to be inserted is handled as if it were preceded by
13726 @code{\!\\!}.
13727
13728 Both requests cause a line break.
13729 @endDefreq
13730
13731 @Defreq {nx, [@Var{file}]}
13732 @cindex processing next file (@code{nx})
13733 @cindex file, processing next (@code{nx})
13734 @cindex next file, processing (@code{nx})
13735 Force @code{gtroff} to continue processing of the file specified as an
13736 argument.  If no argument is given, immediately jump to the end of file.
13737 @endDefreq
13738
13739 @Defreq {rd, [@Var{prompt} [@Var{arg1} @Var{arg2} @dots{}]]}
13740 @cindex reading from standard input (@code{rd})
13741 @cindex standard input, reading from (@code{rd})
13742 @cindex input, standard, reading from (@code{rd})
13743 Read from standard input, and include what is read as though it were
13744 part of the input file.  Text is read until a blank line is encountered.
13745
13746 If standard input is a TTY input device (keyboard), write @var{prompt}
13747 to standard error, followed by a colon (or send BEL for a beep if no
13748 argument is given).
13749
13750 Arguments after @var{prompt} are available for the input.  For example,
13751 the line
13752
13753 @Example
13754 .rd data foo bar
13755 @endExample
13756
13757 with the input @w{@samp{This is \$2.}} prints
13758
13759 @Example
13760 This is bar.
13761 @endExample
13762 @endDefreq
13763
13764 @cindex form letters
13765 @cindex letters, form
13766 Using the @code{nx} and @code{rd} requests, it is easy to set up form
13767 letters.  The form letter template is constructed like this, putting the
13768 following lines into a file called @file{repeat.let}:
13769
13770 @Example
13771 .ce
13772 \*(td
13773 .sp 2
13774 .nf
13775 .rd
13776 .sp
13777 .rd
13778 .fi
13779 Body of letter.
13780 .bp
13781 .nx repeat.let
13782 @endExample
13783
13784 @cindex @code{ex} request, used with @code{nx} and @code{rd}
13785 @noindent
13786 When this is run, a file containing the following lines should be
13787 redirected in.  Note that requests included in this file are executed as
13788 though they were part of the form letter.  The last block of input is
13789 the @code{ex} request, which tells @code{groff} to stop processing.  If
13790 this was not there, @code{groff} would not know when to stop.
13791
13792 @Example
13793 Trent A. Fisher
13794 708 NW 19th Av., #202
13795 Portland, OR  97209
13796
13797 Dear Trent,
13798
13799 Len Adollar
13800 4315 Sierra Vista
13801 San Diego, CA  92103
13802
13803 Dear Mr. Adollar,
13804
13805 .ex
13806 @endExample
13807
13808 @Defreq {pi, pipe}
13809 Pipe the output of @code{gtroff} to the shell command(s) specified by
13810 @var{pipe}.  This request must occur before @code{gtroff} has a chance
13811 to print anything.
13812
13813 @cindex safer mode
13814 @cindex mode, safer
13815 @cindex unsafe mode
13816 @cindex mode, unsafe
13817 @code{pi} causes an error if used in safer mode (which is the default).
13818 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate
13819 unsafe mode.
13820
13821 Multiple calls to @code{pi} are allowed, acting as a chain.  For
13822 example,
13823
13824 @Example
13825 .pi foo
13826 .pi bar
13827 ...
13828 @endExample
13829
13830 is the same as @w{@samp{.pi foo | bar}}.
13831
13832 @cindex @code{groff}, and @code{pi} request
13833 @cindex @code{pi} request, and @code{groff}
13834 Note that the intermediate output format of @code{gtroff} is piped to
13835 the specified commands.  Consequently, calling @code{groff} without the
13836 @option{-Z} option normally causes a fatal error.
13837 @endDefreq
13838
13839 @DefreqList {sy, cmds}
13840 @DefregListEndx {systat}
13841 Execute the shell command(s) specified by @var{cmds}.  The output is not
13842 saved anyplace, so it is up to the user to do so.
13843
13844 @cindex safer mode
13845 @cindex mode, safer
13846 @cindex unsafe mode
13847 @cindex mode, unsafe
13848 This request causes an error if used in safer mode (which is the
13849 default).  Use @code{groff}'s or @code{troff}'s @option{-U} option to
13850 activate unsafe mode.
13851
13852 For example, the following code fragment introduces the current time
13853 into a document:
13854
13855 @cindex time, current
13856 @cindex current time
13857 @pindex perl
13858 @Example
13859 .sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
13860              (localtime(time))[2,1,0]' > /tmp/x\n[$$]
13861 .so /tmp/x\n[$$]
13862 .sy rm /tmp/x\n[$$]
13863 \nH:\nM:\nS
13864 @endExample
13865
13866 @noindent
13867 Note that this works by having the @code{perl} script (run by @code{sy})
13868 print out the @code{nr} requests that set the number registers
13869 @code{H}, @code{M}, and @code{S}, and then reads those commands in with
13870 the @code{so} request.
13871
13872 For most practical purposes, the number registers @code{seconds},
13873 @code{minutes}, and @code{hours}, which are initialized at start-up of
13874 @code{gtroff}, should be sufficient.  Use the @code{af} request to get a
13875 formatted output:
13876
13877 @Example
13878 .af hours 00
13879 .af minutes 00
13880 .af seconds 00
13881 \n[hours]:\n[minutes]:\n[seconds]
13882 @endExample
13883
13884 @cindex @code{system()} return value register (@code{systat})
13885 The @code{systat} read-write number register contains the return value
13886 of the @code{system()} function executed by the last @code{sy} request.
13887 @endDefreq
13888
13889 @DefreqList {open, stream file}
13890 @DefreqListEndx {opena, stream file}
13891 @cindex opening file (@code{open})
13892 @cindex file, opening (@code{open})
13893 @cindex appending to a file (@code{opena})
13894 @cindex file, appending to (@code{opena})
13895 Open the specified @var{file} for writing and associates the specified
13896 @var{stream} with it.
13897
13898 The @code{opena} request is like @code{open}, but if the file exists,
13899 append to it instead of truncating it.
13900
13901 @cindex safer mode
13902 @cindex mode, safer
13903 @cindex unsafe mode
13904 @cindex mode, unsafe
13905 Both @code{open} and @code{opena} cause an error if used in safer mode
13906 (which is the default).  Use @code{groff}'s or @code{troff}'s
13907 @option{-U} option to activate unsafe mode.
13908 @endDefreq
13909
13910 @DefreqList {write, stream data}
13911 @DefreqListEndx {writec, stream data}
13912 @cindex copy-in mode, and @code{write} request
13913 @cindex @code{write} request, and copy-in mode
13914 @cindex mode, copy-in, and @code{write} request
13915 @cindex copy-in mode, and @code{writec} request
13916 @cindex @code{writec} request, and copy-in mode
13917 @cindex mode, copy-in, and @code{writec} request
13918 @cindex writing to file (@code{write}, @code{writec})
13919 @cindex file, writing to (@code{write}, @code{writec})
13920 Write to the file associated with the specified @var{stream}.  The
13921 stream must previously have been the subject of an open request.  The
13922 remainder of the line is interpreted as the @code{ds} request reads its
13923 second argument: A leading @samp{"} is stripped, and it is read in
13924 copy-in mode.
13925
13926 The @code{writec} request is like @code{write}, but only @code{write}
13927 appends a newline to the data.
13928 @endDefreq
13929
13930 @Defreq {writem, stream xx}
13931 @cindex @code{asciify} request, and @code{writem}
13932 Write the contents of the macro or string @var{xx} to the file
13933 associated with the specified @var{stream}.
13934
13935 @cindex @code{writem} request, and copy-in mode
13936 @cindex copy-in mode, and @code{writem} request
13937 @cindex mode, copy-in, and @code{writem} request
13938 @var{xx} is read in copy mode, i.e., already formatted elements are
13939 ignored.  Consequently, diversions must be unformatted with the
13940 @code{asciify} request before calling @code{writem}.  Usually, this
13941 means a loss of information.
13942 @endDefreq
13943
13944 @Defreq {close, stream}
13945 @cindex closing file (@code{close})
13946 @cindex file, closing (@code{close})
13947 Close the specified @var{stream}; the stream is no longer an acceptable
13948 argument to the @code{write} request.
13949
13950 Here a simple macro to write an index entry.
13951
13952 @Example
13953 .open idx test.idx
13954 .
13955 .de IX
13956 .  write idx \\n[%] \\$*
13957 ..
13958 .
13959 .IX test entry
13960 .
13961 .close idx
13962 @endExample
13963 @endDefreq
13964
13965 @DefescList {\\V, , e, }
13966 @DefescItem {\\V, @Lparen{}, ev, }
13967 @DefescListEnd {\\V, @Lbrack{}, env, @Rbrack{}}
13968 @cindex @code{\V}, and copy-in mode
13969 @cindex copy-in mode, and @code{\V}
13970 @cindex mode, copy-in, and @code{\V}
13971 Interpolate the contents of the specified environment variable @var{env}
13972 (one-character name@tie{}@var{e}, two-character name @var{ev}) as
13973 returned by the function @code{getenv}.  @code{\V} is interpreted in
13974 copy-in mode.
13975 @endDefesc
13976
13977
13978 @c =====================================================================
13979
13980 @node Postprocessor Access, Miscellaneous, I/O, gtroff Reference
13981 @section Postprocessor Access
13982 @cindex postprocessor access
13983 @cindex access of postprocessor
13984
13985 There are two escapes that give information directly to the
13986 postprocessor.  This is particularly useful for embedding
13987 @sc{PostScript} into the final document.
13988
13989 @DefreqList {device, xxx}
13990 @DefescListEndx {\\X, ', xxx, '}
13991 Embeds its argument into the @code{gtroff} output preceded with
13992 @w{@samp{x X}}.
13993
13994 @cindex @code{\&}, in @code{\X}
13995 @cindex @code{\)}, in @code{\X}
13996 @cindex @code{\%}, in @code{\X}
13997 @ifnotinfo
13998 @cindex @code{\:}, in @code{\X}
13999 @end ifnotinfo
14000 @ifinfo
14001 @cindex @code{\@r{<colon>}}, in @code{\X}
14002 @end ifinfo
14003 The escapes @code{\&}, @code{\)}, @code{\%}, and @code{\:} are ignored
14004 within @code{\X}, @w{@samp{\ }} and @code{\~} are converted to single
14005 space characters.  All other escapes (except @code{\\}, which produces a
14006 backslash) cause an error.
14007
14008 @cindex @code{device} request, and copy-in mode
14009 @cindex copy-in mode, and @code{device} request
14010 @cindex mode, copy-in, and @code{device} request
14011 Contrary to @code{\X}, the @code{device} request simply processes its
14012 argument in copy mode (@pxref{Copy-in Mode}).
14013
14014 @kindex use_charnames_in_special
14015 @pindex DESC@r{, and @code{use_charnames_in_special}}
14016 @cindex @code{\X}, and special characters
14017 If the @samp{use_charnames_in_special} keyword is set in the @file{DESC}
14018 file, special characters no longer cause an error; they are simply
14019 output verbatim.  Additionally, the backslash is represented as
14020 @code{\\}.
14021
14022 @samp{use_charnames_in_special} is currently used by @code{grohtml}
14023 only.
14024 @endDefesc
14025
14026 @DefreqList {devicem, xx}
14027 @DefescItemx {\\Y, , n, }
14028 @DefescItem {\\Y, @Lparen{}, nm, }
14029 @DefescListEnd {\\Y, @Lbrack{}, name, @Rbrack{}}
14030 This is approximately equivalent to @samp{\X'\*[@var{name}]'}
14031 (one-character name@tie{}@var{n}, two-character name @var{nm}).
14032 However, the contents of the string or macro @var{name} are not
14033 interpreted; also it is permitted for @var{name} to have been defined as
14034 a macro and thus contain newlines (it is not permitted for the argument
14035 to @code{\X} to contain newlines).  The inclusion of newlines requires
14036 an extension to the Unix @code{troff} output format, and confuses
14037 drivers that do not know about this extension (@pxref{Device Control
14038 Commands}).
14039 @endDefesc
14040
14041 @xref{Output Devices}.
14042
14043
14044 @c =====================================================================
14045
14046 @node Miscellaneous, Gtroff Internals, Postprocessor Access, gtroff Reference
14047 @section Miscellaneous
14048
14049 This section documents parts of @code{gtroff} that cannot (yet) be
14050 categorized elsewhere in this manual.
14051
14052 @Defreq {nm, [@Var{start} [@Var{inc} [@Var{space} [@Var{indent}]]]]}
14053 @cindex printing line numbers (@code{nm})
14054 @cindex line numbers, printing (@code{nm})
14055 @cindex numbers, line, printing (@code{nm})
14056 Print line numbers.  @var{start} is the line number of the @emph{next}
14057 output line.  @var{inc} indicates which line numbers are printed.  For
14058 example, the value@tie{}5 means to emit only line numbers that are
14059 multiples of@tie{}5; this defaults to@tie{}1.  @var{space} is the space
14060 to be left between the number and the text; this defaults to one digit
14061 space.  The fourth argument is the indentation of the line numbers,
14062 defaulting to zero.  Both @var{space} and @var{indent} are given as
14063 multiples of digit spaces; they can be negative also.  Without any
14064 arguments, line numbers are turned off.
14065
14066 @code{gtroff} reserves three digit spaces for the line number (which is
14067 printed right-justified) plus the amount given by @var{indent}; the
14068 output lines are concatenated to the line numbers, separated by
14069 @var{space}, and @emph{without} reducing the line length.  Depending on
14070 the value of the horizontal page offset (as set with the @code{po}
14071 request), line numbers that are longer than the reserved space stick
14072 out to the left, or the whole line is moved to the right.
14073
14074 Parameters corresponding to missing arguments are not changed; any
14075 non-digit argument (to be more precise, any argument starting with a
14076 character valid as a delimiter for identifiers) is also treated as
14077 missing.
14078
14079 If line numbering has been disabled with a call to @code{nm} without an
14080 argument, it can be reactivated with @samp{.nm +0}, using the previously
14081 active line numbering parameters.
14082
14083 The parameters of @code{nm} are associated with the current environment
14084 (@pxref{Environments}).  The current output line number is available in
14085 the number register @code{ln}.
14086
14087 @Example
14088 .po 1m
14089 .ll 2i
14090 This test shows how line numbering works with groff.
14091 .nm 999
14092 This test shows how line numbering works with groff.
14093 .br
14094 .nm xxx 3 2
14095 .ll -\w'0'u
14096 This test shows how line numbering works with groff.
14097 .nn 2
14098 This test shows how line numbering works with groff.
14099 @endExample
14100
14101 @noindent
14102 And here the result:
14103
14104 @Example
14105  This  test shows how
14106  line numbering works
14107  999 with   groff.   This
14108 1000 test shows how  line
14109 1001 numbering works with
14110 1002 groff.
14111       This test shows how
14112       line      numbering
14113  works  with  groff.
14114  This test shows how
14115 1005  line      numbering
14116       works with groff.
14117 @endExample
14118 @endDefreq
14119
14120 @Defreq {nn, [@Var{skip}]}
14121 Temporarily turn off line numbering.  The argument is the number of
14122 lines not to be numbered; this defaults to@tie{}1.
14123 @endDefreq
14124
14125 @Defreq {mc, glyph [@Var{dist}]}
14126 @cindex margin glyph (@code{mc})
14127 @cindex glyph, for margins (@code{mc})
14128 Print a @dfn{margin character} to the right of the
14129 text.@footnote{@dfn{Margin character} is a misnomer since it is an
14130 output glyph.}  The first argument is the glyph to be printed.  The
14131 second argument is the distance away from the right margin.  If missing,
14132 the previously set value is used; default is 10@dmn{pt}).  For text
14133 lines that are too long (that is, longer than the text length plus
14134 @var{dist}), the margin character is directly appended to the lines.
14135
14136 With no arguments the margin character is turned off.  If this occurs
14137 before a break, no margin character is printed.
14138
14139 For compatibility with @acronym{AT&T} @code{troff}, a call to @code{mc}
14140 to set the margin character can't be undone immediately; at least one
14141 line gets a margin character.  Thus
14142
14143 @Example
14144 .ll 1i
14145 .mc \[br]
14146 .mc
14147 xxx
14148 .br
14149 xxx
14150 @endExample
14151
14152 @noindent
14153 produces
14154
14155 @Example
14156 xxx        |
14157 xxx
14158 @endExample
14159
14160 @cindex @code{tl} request, and @code{mc}
14161 For empty lines and lines produced by the @code{tl} request no margin
14162 character is emitted.
14163
14164 The margin character is associated with the current environment
14165 (@pxref{Environments}).
14166
14167 @pindex nrchbar
14168 @pindex changebar
14169 This is quite useful for indicating text that has changed, and, in fact,
14170 there are programs available for doing this (they are called
14171 @code{nrchbar} and @code{changebar} and can be found in any
14172 @samp{comp.sources.unix} archive).
14173
14174 @Example
14175 .ll 3i
14176 .mc |
14177 This paragraph is highlighted with a margin
14178 character.
14179 .sp
14180 Note that vertical space isn't marked.
14181 .br
14182 \&
14183 .br
14184 But we can fake it with `\&'.
14185 @endExample
14186
14187 Result:
14188
14189 @Example
14190 This  paragraph is highlighted |
14191 with a margin character.       |
14192
14193 Note that vertical space isn't |
14194 marked.                        |
14195                                |
14196 But we can fake it with `\&'.  |
14197 @endExample
14198 @endDefreq
14199
14200 @DefreqList {psbb, filename}
14201 @DefregItemx {llx}
14202 @DefregItemx {lly}
14203 @DefregItemx {urx}
14204 @DefregListEndx {ury}
14205 @cindex PostScript, bounding box
14206 @cindex bounding box
14207 Retrieve the bounding box of the @sc{PostScript} image found in
14208 @var{filename}.  The file must conform to Adobe's @dfn{Document
14209 Structuring Conventions} (DSC); the command searches for a
14210 @code{%%BoundingBox} comment and extracts the bounding box values into
14211 the number registers @code{llx}, @code{lly}, @code{urx}, and @code{ury}.
14212 If an error occurs (for example, @code{psbb} cannot find the
14213 @code{%%BoundingBox} comment), it sets the four number registers to
14214 zero.
14215
14216 The search path for @var{filename} can be controlled with the
14217 @option{-I} command-line option.
14218 @endDefreq
14219
14220
14221 @c =====================================================================
14222
14223 @node Gtroff Internals, Debugging, Miscellaneous, gtroff Reference
14224 @section @code{gtroff} Internals
14225
14226 @cindex input token
14227 @cindex token, input
14228 @cindex output node
14229 @cindex node, output
14230 @code{gtroff} processes input in three steps.  One or more input
14231 characters are converted to an @dfn{input token}.@footnote{Except the
14232 escapes @code{\f}, @code{\F}, @code{\H}, @code{\m}, @code{\M},
14233 @code{\R}, @code{\s}, and @code{\S}, which are processed immediately if
14234 not in copy-in mode.}  Then, one or more input tokens are converted to
14235 an @dfn{output node}.  Finally, output nodes are converted to the
14236 intermediate output language understood by all output devices.
14237
14238 Actually, before step one happens, @code{gtroff} converts certain escape
14239 sequences into reserved input characters (not accessible by the user);
14240 such reserved characters are used for other internal processing also --
14241 this is the very reason why not all characters are valid input.
14242 @xref{Identifiers}, for more on this topic.
14243
14244 For example, the input string @samp{fi\[:u]} is converted into a
14245 character token @samp{f}, a character token @samp{i}, and a special
14246 token @samp{:u} (representing u@tie{}umlaut).  Later on, the character
14247 tokens @samp{f} and @samp{i} are merged to a single output node
14248 representing the ligature glyph @samp{fi} (provided the current font has
14249 a glyph for this ligature); the same happens with @samp{:u}.  All output
14250 glyph nodes are `processed', which means that they are invariably
14251 associated with a given font, font size, advance width, etc.  During the
14252 formatting process, @code{gtroff} itself adds various nodes to control
14253 the data flow.
14254
14255 Macros, diversions, and strings collect elements in two chained lists: a
14256 list of input tokens that have been passed unprocessed, and a list of
14257 output nodes.  Consider the following the diversion.
14258
14259 @Example
14260 .di xxx
14261 a
14262 \!b
14263 c
14264 .br
14265 .di
14266 @endExample
14267
14268 @noindent
14269 It contains these elements.
14270
14271 @multitable {@i{vertical size node}} {token list} {element number}
14272 @item node list               @tab token list @tab element number
14273
14274 @item @i{line start node}     @tab ---        @tab 1
14275 @item @i{glyph node @code{a}} @tab ---        @tab 2
14276 @item @i{word space node}     @tab ---        @tab 3
14277 @item ---                     @tab @code{b}   @tab 4
14278 @item ---                     @tab @code{\n}  @tab 5
14279 @item @i{glyph node @code{c}} @tab ---        @tab 6
14280 @item @i{vertical size node}  @tab ---        @tab 7
14281 @item @i{vertical size node}  @tab ---        @tab 8
14282 @item ---                     @tab @code{\n}  @tab 9
14283 @end multitable
14284
14285 @cindex @code{\v}, internal representation
14286 @noindent
14287 Elements 1, 7, and@tie{}8 are inserted by @code{gtroff}; the latter two
14288 (which are always present) specify the vertical extent of the last line,
14289 possibly modified by @code{\x}.  The @code{br} request finishes the
14290 current partial line, inserting a newline input token, which is
14291 subsequently converted to a space when the diversion is reread.  Note
14292 that the word space node has a fixed width that isn't stretchable
14293 anymore.  To convert horizontal space nodes back to input tokens, use
14294 the @code{unformat} request.
14295
14296 Macros only contain elements in the token list (and the node list is
14297 empty); diversions and strings can contain elements in both lists.
14298
14299 Note that the @code{chop} request simply reduces the number of elements
14300 in a macro, string, or diversion by one.  Exceptions are
14301 @dfn{compatibility save} and @dfn{compatibility ignore} input tokens,
14302 which are ignored.  The @code{substring} request also ignores those
14303 input tokens.
14304
14305 Some requests like @code{tr} or @code{cflags} work on glyph identifiers
14306 only; this means that the associated glyph can be changed without
14307 destroying this association.  This can be very helpful for substituting
14308 glyphs.  In the following example, we assume that glyph @samp{foo} isn't
14309 available by default, so we provide a substitution using the
14310 @code{fchar} request and map it to input character @samp{x}.
14311
14312 @Example
14313 .fchar \[foo] foo
14314 .tr x \[foo]
14315 @endExample
14316
14317 @noindent
14318 Now let us assume that we install an additional special font @samp{bar}
14319 that has glyph @samp{foo}.
14320
14321 @Example
14322 .special bar
14323 .rchar \[foo]
14324 @endExample
14325
14326 @noindent
14327 Since glyphs defined with @code{fchar} are searched before glyphs in
14328 special fonts, we must call @code{rchar} to remove the definition of the
14329 fallback glyph.  Anyway, the translation is still active; @samp{x} now
14330 maps to the real glyph @samp{foo}.
14331
14332 @cindex compatibility mode, and parameters
14333 @cindex mode, compatibility, and parameters
14334 @cindex arguments, and compatibility mode
14335 @cindex parameters, and compatibility mode
14336 @cindex macro arguments, and compatibility mode
14337 @cindex request arguments, and compatibility mode
14338 Macro and request arguments preserve the compatibility mode:
14339
14340 @Example
14341 .cp 1     \" switch to compatibility mode
14342 .de xx
14343 \\$1
14344 ..
14345 .cp 0     \" switch compatibility mode off
14346 .xx caf\['e]
14347     @result{} café
14348 @endExample
14349
14350 @noindent
14351 Since compatibility mode is on while @code{de} is called, the macro
14352 @code{xx} activates compatibility mode while executing.  Argument
14353 @code{$1} can still be handled properly because it inherits the
14354 compatibility mode status which was active at the point where @code{xx}
14355 is called.
14356
14357 After expansion of the parameters, the compatibility save and restore
14358 tokens are removed.
14359
14360
14361 @c =====================================================================
14362
14363 @node Debugging, Implementation Differences, Gtroff Internals, gtroff Reference
14364 @section Debugging
14365 @cindex debugging
14366
14367 @code{gtroff} is not easy to debug, but there are some useful features
14368 and strategies for debugging.
14369
14370 @Defreq {lf, line [@Var{filename}]}
14371 @pindex soelim
14372 @cindex multi-file documents
14373 @cindex documents, multi-file
14374 @cindex setting input line number (@code{lf})
14375 @cindex input line number, setting (@code{lf})
14376 @cindex number, input line, setting (@code{lf})
14377 Change the line number and optionally the file name @code{gtroff} shall
14378 use for error and warning messages.  @var{line} is the input line number
14379 of the @emph{next} line.
14380
14381 Without argument, the request is ignored.
14382
14383 This is a debugging aid for documents that are split into many files,
14384 then put together with @code{soelim} and other preprocessors.  Usually,
14385 it isn't invoked manually.
14386
14387 Note that other @code{troff} implementations (including the original
14388 @acronym{AT&T} version) handle @code{lf} differently.  For them,
14389 @var{line} changes the line number of the @emph{current} line.
14390 @endDefreq
14391
14392 @DefreqList {tm, string}
14393 @DefreqItemx {tm1, string}
14394 @DefreqListEndx {tmc, string}
14395 @cindex printing to stderr (@code{tm}, @code{tm1}, @code{tmc})
14396 @cindex stderr, printing to (@code{tm}, @code{tm1}, @code{tmc})
14397 Send @var{string} to the standard error output; this is very useful for
14398 printing debugging messages among other things.
14399
14400 @cindex @code{tm} request, and copy-in mode
14401 @cindex copy-in mode, and @code{tm} request
14402 @cindex mode, copy-in, and @code{tm} request
14403 @cindex @code{tm1} request, and copy-in mode
14404 @cindex copy-in mode, and @code{tm1} request
14405 @cindex mode, copy-in, and @code{tm1} request
14406 @cindex @code{tmc} request, and copy-in mode
14407 @cindex copy-in mode, and @code{tmc} request
14408 @cindex mode, copy-in, and @code{tmc} request
14409 @var{string} is read in copy mode.
14410
14411 The @code{tm} request ignores leading spaces of @var{string}; @code{tm1}
14412 handles its argument similar to the @code{ds} request: a leading double
14413 quote in @var{string} is stripped to allow initial blanks.
14414
14415 The @code{tmc} request is similar to @code{tm1} but does not append a
14416 newline (as is done in @code{tm} and @code{tm1}).
14417 @endDefreq
14418
14419 @Defreq {ab, [@Var{string}]}
14420 @cindex aborting (@code{ab})
14421 Similar to the @code{tm} request, except that it causes @code{gtroff} to
14422 stop processing.  With no argument it prints @samp{User Abort.} to
14423 standard error.
14424 @endDefreq
14425
14426 @Defreq {ex, }
14427 @cindex @code{ex} request, use in debugging
14428 @cindex exiting (@code{ex})
14429 The @code{ex} request also causes @code{gtroff} to stop processing; see
14430 also @ref{I/O}.
14431 @endDefreq
14432
14433 When doing something involved it is useful to leave the debugging
14434 statements in the code and have them turned on by a command-line flag.
14435
14436 @Example
14437 .if \n(DB .tm debugging output
14438 @endExample
14439
14440 @noindent
14441 To activate these statements say
14442
14443 @Example
14444 groff -rDB=1 file
14445 @endExample
14446
14447 If it is known in advance that there are many errors and no useful
14448 output, @code{gtroff} can be forced to suppress formatted output with
14449 the @option{-z} flag.
14450
14451 @Defreq {pev, }
14452 @cindex dumping environments (@code{pev})
14453 @cindex environments, dumping (@code{pev})
14454 Print the contents of the current environment and all the currently
14455 defined environments (both named and numbered) on @code{stderr}.
14456 @endDefreq
14457
14458 @Defreq {pm, }
14459 @cindex dumping symbol table (@code{pm})
14460 @cindex symbol table, dumping (@code{pm})
14461 Print the entire symbol table on @code{stderr}.  Names of all defined
14462 macros, strings, and diversions are print together with their size in
14463 bytes.  Since @code{gtroff} sometimes adds nodes by itself, the returned
14464 size can be larger than expected.
14465
14466 This request differs from Unix @code{troff}: @code{gtroff} reports the
14467 sizes of diversions, ignores an additional argument to print only the
14468 total of the sizes, and the size isn't returned in blocks of 128
14469 characters.
14470 @endDefreq
14471
14472 @Defreq {pnr, }
14473 @cindex dumping number registers (@code{pnr})
14474 @cindex number registers, dumping (@code{pnr})
14475 Print the names and contents of all currently defined number registers
14476 on @code{stderr}.
14477 @endDefreq
14478
14479 @Defreq {ptr, }
14480 @cindex dumping traps (@code{ptr})
14481 @cindex traps, dumping (@code{ptr})
14482 Print the names and positions of all traps (not including input line
14483 traps and diversion traps) on @code{stderr}.  Empty slots in the page
14484 trap list are printed as well, because they can affect the priority of
14485 subsequently planted traps.
14486 @endDefreq
14487
14488 @Defreq {fl, }
14489 @cindex flush output (@code{fl})
14490 @cindex output, flush (@code{fl})
14491 @cindex interactive use of @code{gtroff}
14492 @cindex @code{gtroff}, interactive use
14493 Instruct @code{gtroff} to flush its output immediately.  The intent is
14494 for interactive use, but this behaviour is currently not implemented in
14495 @code{gtroff}.  Contrary to Unix @code{troff}, TTY output is sent to a
14496 device driver also (@code{grotty}), making it non-trivial to communicate
14497 interactively.
14498
14499 This request causes a line break.
14500 @endDefreq
14501
14502 @Defreq {backtrace, }
14503 @cindex backtrace of input stack (@code{backtrace})
14504 @cindex input stack, backtrace (@code{backtrace})
14505 Print a backtrace of the input stack to the standard error stream.
14506
14507 Consider the following in file @file{test}:
14508
14509 @Example
14510 .de xxx
14511 .  backtrace
14512 ..
14513 .de yyy
14514 .  xxx
14515 ..
14516 .
14517 .yyy
14518 @endExample
14519
14520 @noindent
14521 On execution, @code{gtroff} prints the following:
14522
14523 @Example
14524 test:2: backtrace: macro `xxx'
14525 test:5: backtrace: macro `yyy'
14526 test:8: backtrace: file `test'
14527 @endExample
14528
14529 The option @option{-b} of @code{gtroff} internally calls a variant of
14530 this request on each error and warning.
14531 @endDefreq
14532
14533 @Defreg {slimit}
14534 @cindex input stack, setting limit
14535 Use the @code{slimit} number register to set the maximum number of
14536 objects on the input stack.  If @code{slimit} is less than or equal
14537 to@tie{}0, there is no limit set.  With no limit, a buggy recursive
14538 macro can exhaust virtual memory.
14539
14540 The default value is 1000; this is a compile-time constant.
14541 @endDefreg
14542
14543 @Defreq {warnscale, si}
14544 Set the scaling indicator used in warnings to @var{si}.  Valid values
14545 for @var{si} are @samp{u}, @samp{i}, @samp{c}, @samp{p}, and @samp{P}.
14546 At startup, it is set to @samp{i}.
14547 @endDefreq
14548
14549 @Defreq {spreadwarn, [@Var{limit}]}
14550 Make @code{gtroff} emit a warning if the additional space inserted for
14551 each space between words in an output line is larger or equal to
14552 @var{limit}.  A negative value is changed to zero; no argument toggles
14553 the warning on and off without changing @var{limit}.  The default
14554 scaling indicator is @samp{m}.  At startup, @code{spreadwarn} is
14555 deactivated, and @var{limit} is set to 3@dmn{m}.
14556
14557 For example,
14558
14559 @Example
14560 .spreadwarn 0.2m
14561 @endExample
14562
14563 @noindent
14564 causes a warning if @code{gtroff} must add 0.2@dmn{m} or more for each
14565 interword space in a line.
14566
14567 This request is active only if text is justified to both margins (using
14568 @w{@samp{.ad b}}).
14569 @endDefreq
14570
14571 @cindex warnings
14572 @code{gtroff} has command-line options for printing out more warnings
14573 (@option{-w}) and for printing backtraces (@option{-b}) when a warning
14574 or an error occurs.  The most verbose level of warnings is @option{-ww}.
14575
14576 @DefreqList {warn, [@Var{flags}]}
14577 @DefregListEndx {.warn}
14578 @cindex level of warnings (@code{warn})
14579 @cindex warnings, level (@code{warn})
14580 Control the level of warnings checked for.  The @var{flags} are the sum
14581 of the numbers associated with each warning that is to be enabled; all
14582 other warnings are disabled.  The number associated with each warning is
14583 listed below.  For example, @w{@code{.warn 0}} disables all warnings,
14584 and @w{@code{.warn 1}} disables all warnings except that about missing
14585 glyphs.  If no argument is given, all warnings are enabled.
14586
14587 The read-only number register @code{.warn} contains the current warning
14588 level.
14589 @endDefreq
14590
14591 @menu
14592 * Warnings::
14593 @end menu
14594
14595 @c ---------------------------------------------------------------------
14596
14597 @node Warnings,  , Debugging, Debugging
14598 @subsection Warnings
14599 @cindex warnings
14600
14601 The warnings that can be given to @code{gtroff} are divided into the
14602 following categories.  The name associated with each warning is used by
14603 the @option{-w} and @option{-W} options; the number is used by the
14604 @code{warn} request and by the @code{.warn} register.
14605
14606 @table @samp
14607 @item char
14608 @itemx 1
14609 Non-existent glyphs.@footnote{@code{char} is a misnomer since it reports
14610 missing glyphs -- there aren't missing input characters, only invalid
14611 ones.}  This is enabled by default.
14612
14613 @item number
14614 @itemx 2
14615 Invalid numeric expressions.  This is enabled by default.
14616 @xref{Expressions}.
14617
14618 @item break
14619 @itemx 4
14620 @cindex fill mode
14621 @cindex mode, fill
14622 In fill mode, lines that could not be broken so that their length was
14623 less than the line length.  This is enabled by default.
14624
14625 @item delim
14626 @itemx 8
14627 Missing or mismatched closing delimiters.
14628
14629 @item el
14630 @itemx 16
14631 @cindex @code{ie} request, and warnings
14632 @cindex @code{el} request, and warnings
14633 Use of the @code{el} request with no matching @code{ie} request.
14634 @xref{if-else}.
14635
14636 @item scale
14637 @itemx 32
14638 Meaningless scaling indicators.
14639
14640 @item range
14641 @itemx 64
14642 Out of range arguments.
14643
14644 @item syntax
14645 @itemx 128
14646 Dubious syntax in numeric expressions.
14647
14648 @item di
14649 @itemx 256
14650 @cindex @code{di} request, and warnings
14651 @cindex @code{da} request, and warnings
14652 Use of @code{di} or @code{da} without an argument when there is no
14653 current diversion.
14654
14655 @item mac
14656 @itemx 512
14657 @cindex @code{de}, @code{de1}, @code{dei} requests, and warnings
14658 @cindex @code{am}, @code{am1}, @code{ami} requests, and warnings
14659 @cindex @code{ds}, @code{ds1} requests, and warnings
14660 @cindex @code{as}, @code{as1} requests, and warnings
14661 @cindex @code{di} request, and warnings
14662 @cindex @code{da} request, and warnings
14663 @cindex @code{box}, @code{boxa} requests, and warnings
14664 @cindex @code{\*}, and warnings
14665 Use of undefined strings, macros and diversions.  When an undefined
14666 string, macro, or diversion is used, that string is automatically
14667 defined as empty.  So, in most cases, at most one warning is given for
14668 each name.
14669
14670 @item reg
14671 @itemx 1024
14672 @cindex @code{nr} request, and warnings
14673 @cindex @code{\R}, and warnings
14674 @cindex @code{\n}, and warnings
14675 Use of undefined number registers.  When an undefined number register is
14676 used, that register is automatically defined to have a value of@tie{}0.
14677 So, in most cases, at most one warning is given for use of a particular
14678 name.
14679
14680 @item tab
14681 @itemx 2048
14682 @cindex @code{\t}, and warnings
14683 Use of a tab character where a number was expected.
14684
14685 @item right-brace
14686 @itemx 4096
14687 @cindex @code{\@}}, and warnings
14688 Use of @code{\@}} where a number was expected.
14689
14690 @item missing
14691 @itemx 8192
14692 Requests that are missing non-optional arguments.
14693
14694 @item input
14695 @itemx 16384
14696 Invalid input characters.
14697
14698 @item escape
14699 @itemx 32768
14700 Unrecognized escape sequences.  When an unrecognized escape sequence
14701 @code{\@var{X}} is encountered, the escape character is ignored, and
14702 @var{X} is printed.
14703
14704 @item space
14705 @itemx 65536
14706 @cindex compatibility mode
14707 Missing space between a request or macro and its argument.  This warning
14708 is given when an undefined name longer than two characters is
14709 encountered, and the first two characters of the name make a defined
14710 name.  The request or macro is not invoked.  When this warning is given,
14711 no macro is automatically defined.  This is enabled by default.  This
14712 warning never occurs in compatibility mode.
14713
14714 @item font
14715 @itemx 131072
14716 Non-existent fonts.  This is enabled by default.
14717
14718 @item ig
14719 @itemx 262144
14720 Invalid escapes in text ignored with the @code{ig} request.  These are
14721 conditions that are errors when they do not occur in ignored text.
14722
14723 @item color
14724 @itemx 524288
14725 Color related warnings.
14726
14727 @item file
14728 @itemx 1048576
14729 Missing files.  The @code{mso} request gives this warning when the
14730 requested macro file does not exist.  This is enabled by default.
14731
14732 @item all
14733 All warnings except @samp{di}, @samp{mac} and @samp{reg}.  It is
14734 intended that this covers all warnings that are useful with traditional
14735 macro packages.
14736
14737 @item w
14738 All warnings.
14739 @end table
14740
14741
14742 @c =====================================================================
14743
14744 @node Implementation Differences,  , Debugging, gtroff Reference
14745 @section Implementation Differences
14746 @cindex implementation differences
14747 @cindex differences in implementation
14748 @cindex incompatibilities with @acronym{AT&T} @code{troff}
14749 @cindex compatibility mode
14750 @cindex mode, compatibility
14751
14752 GNU @code{troff} has a number of features that cause incompatibilities
14753 with documents written with old versions of @code{troff}.
14754
14755 @cindex long names
14756 @cindex names, long
14757 Long names cause some incompatibilities.  Unix @code{troff} interprets
14758
14759 @Example
14760 .dsabcd
14761 @endExample
14762
14763 @cindex @code{\*}, incompatibilities with @acronym{AT&T} @code{troff}
14764 @cindex @code{\n}, incompatibilities with @acronym{AT&T} @code{troff}
14765 @noindent
14766 as defining a string @samp{ab} with contents @samp{cd}.  Normally, GNU
14767 @code{troff} interprets this as a call of a macro named @code{dsabcd}.
14768 Also Unix @code{troff} interprets @code{\*[} or @code{\n[} as references
14769 to a string or number register called @samp{[}.  In GNU @code{troff},
14770 however, this is normally interpreted as the start of a long name.  In
14771 compatibility mode GNU @code{troff} interprets long names in the
14772 traditional way (which means that they are not recognized as names).
14773
14774 @DefreqList {cp, [@Var{n}]}
14775 @DefreqItemx {do, cmd}
14776 @DefregListEndx {.C}
14777 If @var{n} is missing or non-zero, turn on compatibility mode;
14778 otherwise, turn it off.
14779
14780 The read-only number register @code{.C} is@tie{}1 if compatibility mode
14781 is on, 0@tie{}otherwise.
14782
14783 Compatibility mode can be also turned on with the @option{-C}
14784 command-line option.
14785
14786 The @code{do} request turns off compatibility mode while executing its
14787 arguments as a @code{gtroff} command.  However, it does not turn off
14788 compatibility mode while processing the macro itself.  To do that, use
14789 the @code{de1} request (or manipulate the @code{.C} register manually).
14790 @xref{Writing Macros}.
14791
14792 @Example
14793 .do fam T
14794 @endExample
14795
14796 @noindent
14797 executes the @code{fam} request when compatibility mode is enabled.
14798
14799 @code{gtroff} restores the previous compatibility setting before
14800 interpreting any files sourced by the @var{cmd}.
14801 @endDefreq
14802
14803 @cindex input level in delimited arguments
14804 @cindex delimited arguments, incompatibilities with @acronym{AT&T} @code{troff}
14805 Two other features are controlled by @option{-C}.  If not in
14806 compatibility mode, GNU @code{troff} preserves the input level in
14807 delimited arguments:
14808
14809 @Example
14810 .ds xx '
14811 \w'abc\*(xxdef'
14812 @endExample
14813
14814 @noindent
14815 In compatibility mode, the string @samp{72def'} is returned; without
14816 @option{-C} the resulting string is @samp{168} (assuming a TTY output
14817 device).
14818
14819 @cindex @code{\f}, incompatibilities with @acronym{AT&T} @code{troff}
14820 @cindex @code{\H}, incompatibilities with @acronym{AT&T} @code{troff}
14821 @cindex @code{\s}, incompatibilities with @acronym{AT&T} @code{troff}
14822 @cindex @code{\S}, incompatibilities with @acronym{AT&T} @code{troff}
14823 Finally, the escapes @code{\f}, @code{\H}, @code{\m}, @code{\M},
14824 @code{\R}, @code{\s}, and @code{\S} are transparent for recognizing the
14825 beginning of a line only in compatibility mode (this is a rather obscure
14826 feature).  For example, the code
14827
14828 @Example
14829 .de xx
14830 Hello!
14831 ..
14832 \fB.xx\fP
14833 @endExample
14834
14835 @noindent
14836 prints @samp{Hello!} in bold face if in compatibility mode, and
14837 @samp{.xx} in bold face otherwise.
14838
14839 @cindex @code{\A}, incompatibilities with @acronym{AT&T} @code{troff}
14840 @cindex @code{\|}, incompatibilities with @acronym{AT&T} @code{troff}
14841 @cindex @code{\^}, incompatibilities with @acronym{AT&T} @code{troff}
14842 @cindex @code{\&}, incompatibilities with @acronym{AT&T} @code{troff}
14843 @cindex @code{\@{}, incompatibilities with @acronym{AT&T} @code{troff}
14844 @cindex @code{\@}}, incompatibilities with @acronym{AT&T} @code{troff}
14845 @cindex @code{\@key{SP}}, incompatibilities with @acronym{AT&T} @code{troff}
14846 @cindex @code{\'}, incompatibilities with @acronym{AT&T} @code{troff}
14847 @cindex @code{\`}, incompatibilities with @acronym{AT&T} @code{troff}
14848 @cindex @code{\-}, incompatibilities with @acronym{AT&T} @code{troff}
14849 @cindex @code{\_}, incompatibilities with @acronym{AT&T} @code{troff}
14850 @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
14851 @cindex @code{\%}, incompatibilities with @acronym{AT&T} @code{troff}
14852 @cindex @code{\c}, incompatibilities with @acronym{AT&T} @code{troff}
14853 GNU @code{troff} does not allow the use of the escape sequences
14854 @code{\|}, @code{\^}, @code{\&}, @code{\@{}, @code{\@}},
14855 @code{\@key{SP}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
14856 @code{\%}, and @code{\c} in names of strings, macros, diversions, number
14857 registers, fonts or environments; Unix @code{troff} does.  The @code{\A}
14858 escape sequence (@pxref{Identifiers}) may be helpful in avoiding use of
14859 these escape sequences in names.
14860
14861 @cindex fractional point sizes
14862 @cindex fractional type sizes
14863 @cindex point sizes, fractional
14864 @cindex type sizes, fractional
14865 @cindex sizes, fractional
14866 @cindex @code{ps} request, incompatibilities with @acronym{AT&T} @code{troff}
14867 Fractional point sizes cause one noteworthy incompatibility.  In
14868 Unix @code{troff} the @code{ps} request ignores scale indicators and
14869 thus
14870
14871 @Example
14872 .ps 10u
14873 @endExample
14874
14875 @noindent
14876 sets the point size to 10@tie{}points, whereas in GNU @code{troff} it
14877 sets the point size to 10@tie{}scaled points.  @xref{Fractional Type
14878 Sizes}, for more information.
14879
14880 @cindex @code{bd} request, incompatibilities with @acronym{AT&T} @code{troff}
14881 @cindex @code{cs} request, incompatibilities with @acronym{AT&T} @code{troff}
14882 @cindex @code{tr} request, incompatibilities with @acronym{AT&T} @code{troff}
14883 @cindex @code{fp} request, incompatibilities with @acronym{AT&T} @code{troff}
14884 @cindex input characters and output glyphs, compatibility with @acronym{AT&T} @code{troff}
14885 @cindex output glyphs, and input characters,compatibility with @acronym{AT&T} @code{troff}
14886 @cindex characters, input, and output glyphs, compatibility with @acronym{AT&T} @code{troff}
14887 @cindex glyphs, output, and input characters, compatibility with @acronym{AT&T} @code{troff}
14888 In GNU @code{troff} there is a fundamental difference between
14889 (unformatted) input characters and (formatted) output glyphs.
14890 Everything that affects how a glyph is output is stored with the glyph
14891 node; once a glyph node has been constructed it is unaffected by any
14892 subsequent requests that are executed, including @code{bd}, @code{cs},
14893 @code{tkf}, @code{tr}, or @code{fp} requests.  Normally glyphs are
14894 constructed from input characters at the moment immediately before the
14895 glyph is added to the current output line.  Macros, diversions and
14896 strings are all, in fact, the same type of object; they contain lists of
14897 input characters and glyph nodes in any combination.  A glyph node does
14898 not behave like an input character for the purposes of macro processing;
14899 it does not inherit any of the special properties that the input
14900 character from which it was constructed might have had.  For example,
14901
14902 @Example
14903 .di x
14904 \\\\
14905 .br
14906 .di
14907 .x
14908 @endExample
14909
14910 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
14911 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
14912 @cindex @code{\e}, incompatibilities with @acronym{AT&T} @code{troff}
14913 @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
14914 @cindex @code{\?}, incompatibilities with @acronym{AT&T} @code{troff}
14915 @cindex transparent output, incompatibilities with @acronym{AT&T} @code{troff}
14916 @cindex output, transparent, incompatibilities with @acronym{AT&T} @code{troff}
14917 @noindent
14918 prints @samp{\\} in GNU @code{troff}; each pair of input backslashes is
14919 turned into one output backslash and the resulting output backslashes
14920 are not interpreted as escape characters when they are reread.
14921 Unix @code{troff} would interpret them as escape characters when they
14922 were reread and would end up printing one @samp{\}.  The correct way to
14923 obtain a printable backslash is to use the @code{\e} escape sequence:
14924 This always prints a single instance of the current escape character,
14925 regardless of whether or not it is used in a diversion; it also works in
14926 both GNU @code{troff} and Unix @code{troff}.@footnote{To be completely
14927 independent of the current escape character, use @code{\(rs}, which
14928 represents a reverse solidus (backslash) glyph.}  To store, for some
14929 reason, an escape sequence in a diversion that is interpreted when the
14930 diversion is reread, either use the traditional @code{\!} transparent
14931 output facility, or, if this is unsuitable, the new @code{\?} escape
14932 sequence.
14933
14934 @xref{Diversions}, and @ref{Gtroff Internals}, for more information.
14935
14936
14937
14938 @c =====================================================================
14939 @c =====================================================================
14940
14941 @node Preprocessors, Output Devices, gtroff Reference, Top
14942 @chapter Preprocessors
14943 @cindex preprocessors
14944
14945 This chapter describes all preprocessors that come with @code{groff} or
14946 which are freely available.
14947
14948 @menu
14949 * geqn::
14950 * gtbl::
14951 * gpic::
14952 * ggrn::
14953 * grap::
14954 * gchem::
14955 * grefer::
14956 * gsoelim::
14957 * preconv::
14958 @end menu
14959
14960
14961 @c =====================================================================
14962
14963 @node geqn, gtbl, Preprocessors, Preprocessors
14964 @section @code{geqn}
14965 @cindex @code{eqn}, the program
14966 @cindex @code{geqn}, the program
14967
14968 @c XXX
14969
14970 @menu
14971 * Invoking geqn::
14972 @end menu
14973
14974 @c ---------------------------------------------------------------------
14975
14976 @node Invoking geqn,  , geqn, geqn
14977 @subsection Invoking @code{geqn}
14978 @cindex invoking @code{geqn}
14979 @cindex @code{geqn}, invoking
14980
14981 @c XXX
14982
14983
14984 @c =====================================================================
14985
14986 @node gtbl, gpic, geqn, Preprocessors
14987 @section @code{gtbl}
14988 @cindex @code{tbl}, the program
14989 @cindex @code{gtbl}, the program
14990
14991 @c XXX
14992
14993 @menu
14994 * Invoking gtbl::
14995 @end menu
14996
14997 @c ---------------------------------------------------------------------
14998
14999 @node Invoking gtbl,  , gtbl, gtbl
15000 @subsection Invoking @code{gtbl}
15001 @cindex invoking @code{gtbl}
15002 @cindex @code{gtbl}, invoking
15003
15004 @c XXX
15005
15006
15007 @c =====================================================================
15008
15009 @node gpic, ggrn, gtbl, Preprocessors
15010 @section @code{gpic}
15011 @cindex @code{pic}, the program
15012 @cindex @code{gpic}, the program
15013
15014 @c XXX
15015
15016 @menu
15017 * Invoking gpic::
15018 @end menu
15019
15020 @c ---------------------------------------------------------------------
15021
15022 @node Invoking gpic,  , gpic, gpic
15023 @subsection Invoking @code{gpic}
15024 @cindex invoking @code{gpic}
15025 @cindex @code{gpic}, invoking
15026
15027 @c XXX
15028
15029
15030 @c =====================================================================
15031
15032 @node ggrn, grap, gpic, Preprocessors
15033 @section @code{ggrn}
15034 @cindex @code{grn}, the program
15035 @cindex @code{ggrn}, the program
15036
15037 @c XXX
15038
15039 @menu
15040 * Invoking ggrn::
15041 @end menu
15042
15043 @c ---------------------------------------------------------------------
15044
15045 @node Invoking ggrn,  , ggrn, ggrn
15046 @subsection Invoking @code{ggrn}
15047 @cindex invoking @code{ggrn}
15048 @cindex @code{ggrn}, invoking
15049
15050 @c XXX
15051
15052
15053 @c =====================================================================
15054
15055 @node grap, gchem, ggrn, Preprocessors
15056 @section @code{grap}
15057 @cindex @code{grap}, the program
15058
15059 A free implementation of @code{grap}, written by Ted Faber,
15060 is available as an extra package from the following address:
15061
15062 @display
15063 @uref{http://www.lunabase.org/~faber/Vault/software/grap/}
15064 @end display
15065
15066
15067 @c =====================================================================
15068
15069 @node gchem, grefer, grap, Preprocessors
15070 @section @code{gchem}
15071 @cindex @code{chem}, the program
15072 @cindex @code{gchem}, the program
15073
15074 @c XXX
15075
15076 @menu
15077 * Invoking gchem::
15078 @end menu
15079
15080 @c ---------------------------------------------------------------------
15081
15082 @node Invoking gchem,  , gchem, gchem
15083 @subsection Invoking @code{gchem}
15084 @cindex invoking @code{gchem}
15085 @cindex @code{gchem}, invoking
15086
15087 @c XXX
15088
15089
15090 @c =====================================================================
15091
15092 @node grefer, gsoelim, gchem, Preprocessors
15093 @section @code{grefer}
15094 @cindex @code{refer}, the program
15095 @cindex @code{grefer}, the program
15096
15097 @c XXX
15098
15099 @menu
15100 * Invoking grefer::
15101 @end menu
15102
15103 @c ---------------------------------------------------------------------
15104
15105 @node Invoking grefer,  , grefer, grefer
15106 @subsection Invoking @code{grefer}
15107 @cindex invoking @code{grefer}
15108 @cindex @code{grefer}, invoking
15109
15110 @c XXX
15111
15112
15113 @c =====================================================================
15114
15115 @node gsoelim, preconv, grefer, Preprocessors
15116 @section @code{gsoelim}
15117 @cindex @code{soelim}, the program
15118 @cindex @code{gsoelim}, the program
15119
15120 @c XXX
15121
15122 @menu
15123 * Invoking gsoelim::
15124 @end menu
15125
15126 @c ---------------------------------------------------------------------
15127
15128 @node Invoking gsoelim,  , gsoelim, gsoelim
15129 @subsection Invoking @code{gsoelim}
15130 @cindex invoking @code{gsoelim}
15131 @cindex @code{gsoelim}, invoking
15132
15133 @c XXX
15134
15135
15136 @c =====================================================================
15137
15138 @node preconv,  , gsoelim, Preprocessors
15139 @section @code{preconv}
15140 @cindex @code{preconv}, the program
15141
15142 @c XXX
15143
15144 @menu
15145 * Invoking preconv::
15146 @end menu
15147
15148 @c ---------------------------------------------------------------------
15149
15150 @node Invoking preconv,  , preconv, preconv
15151 @subsection Invoking @code{preconv}
15152 @cindex invoking @code{preconv}
15153 @cindex @code{preconv}, invoking
15154
15155 @c XXX
15156
15157
15158 @c =====================================================================
15159 @c =====================================================================
15160
15161 @node Output Devices, File formats, Preprocessors, Top
15162 @chapter Output Devices
15163 @cindex output devices
15164 @cindex devices for output
15165
15166 @c XXX
15167
15168 @menu
15169 * Special Characters::
15170 * grotty::
15171 * grops::
15172 * gropdf::
15173 * grodvi::
15174 * grolj4::
15175 * grolbp::
15176 * grohtml::
15177 * gxditview::
15178 @end menu
15179
15180
15181 @c =====================================================================
15182
15183 @node Special Characters, grotty, Output Devices, Output Devices
15184 @section Special Characters
15185 @cindex special characters
15186 @cindex characters, special
15187
15188 @c XXX
15189
15190 @xref{Font Files}.
15191
15192
15193 @c =====================================================================
15194
15195 @node grotty, grops, Special Characters, Output Devices
15196 @section @code{grotty}
15197 @cindex @code{grotty}, the program
15198
15199 The postprocessor @code{grotty} translates the output from GNU
15200 @code{troff} into a form suitable for typewriter-like devices.  It is
15201 fully documented on its manual page, @cite{grotty(1)}.
15202
15203 @menu
15204 * Invoking grotty::
15205 @end menu
15206
15207 @c ---------------------------------------------------------------------
15208
15209 @node Invoking grotty,  , grotty, grotty
15210 @subsection Invoking @code{grotty}
15211 @cindex invoking @code{grotty}
15212 @cindex @code{grotty}, invoking
15213
15214 The postprocessor @command{grotty} accepts the following command-line
15215 options:
15216
15217 @table @option
15218 @item -b
15219 Do not overstrike bold glyphs.  Ignored if @option{-c} isn't used.
15220
15221 @item -B
15222 Do not underline bold-italic glyphs.  Ignored if @option{-c} isn't
15223 used.
15224
15225 @item -c
15226 Use overprint and disable colours for printing on legacy Teletype
15227 printers (see below).
15228
15229 @item -d
15230 Do not render lines (that is, ignore all @code{\D} escapes).
15231
15232 @item -f
15233 Use form feed control characters in the output.
15234
15235 @item -F@var{dir}
15236 Put the directory @file{@var{dir}/dev@var{name}} in front of the
15237 search path for the font and device description files, given the
15238 target device @var{name}.
15239
15240 @item -h
15241 Use horizontal tabs for sequences of 8 space characters.
15242
15243 @item -i
15244 Request italic glyphs from the terminal.  Ignored if @option{-c} is
15245 active.
15246
15247 @item -o
15248 Do not overstrike.
15249
15250 @item -r
15251 Highlight italic glyphs.  Ignored if @option{-c} is active.
15252
15253 @item -u
15254 Do not underline italic glyphs.  Ignored if @option{-c} isn't used.
15255
15256 @item -U
15257 Do not overstrike bold-italic glyphs.  Ignored if @option{-c} isn't
15258 used.
15259
15260 @item -v
15261 Print the version number.
15262 @end table
15263
15264 @pindex less
15265 @cindex Teletype
15266 @cindex ISO 6249 SGR
15267 @cindex terminal control sequences
15268 @cindex control sequences, for terminals
15269 The @option{-c} mode for TTY output devices means that underlining is
15270 done by emitting sequences of @samp{_} and @samp{^H} (the backspace
15271 character) before the actual character.  Literally, this is printing
15272 an underline character, then moving the caret back one character
15273 position, and printing the actual character at the same position as
15274 the underline character (similar to a typewriter).  Usually, a modern
15275 terminal can't interpret this (and the original Teletype machines for
15276 which this sequence was appropriate are no longer in use).  You need
15277 a pager program like @code{less} that translates this into
15278 ISO@tie{}6429 SGR sequences to control terminals.
15279
15280
15281 @c =====================================================================
15282
15283 @node grops, gropdf, grotty, Output Devices
15284 @section @code{grops}
15285 @cindex @code{grops}, the program
15286
15287 The postprocessor @command{grops} translates the output from GNU
15288 @command{troff} into a form suitable for Adobe @sc{PostScript}
15289 devices.  It is fully documented on its manual page, @cite{grops(1)}.
15290
15291
15292 @menu
15293 * Invoking grops::
15294 * Embedding PostScript::
15295 @end menu
15296
15297 @c ---------------------------------------------------------------------
15298
15299 @node Invoking grops, Embedding PostScript, grops, grops
15300 @subsection Invoking @code{grops}
15301 @cindex invoking @code{grops}
15302 @cindex @code{grops}, invoking
15303
15304 The postprocessor @code{grops} accepts the following command-line
15305 options:
15306
15307 @table @option
15308 @item -b@var{flags}
15309 Use backward compatibility settings given by @var{flags} as
15310 documented in the @cite{grops(1)} manual page.  Overrides the command
15311 @option{broken} in the @file{DESC} file.
15312
15313 @item -c@var{n}
15314 Print @var{n} copies of each page.
15315
15316 @item -F@var{dir}
15317 Put the directory @file{@var{dir}/dev@var{name}} in front of the
15318 search path for the font, prologue and device description files,
15319 given the target device @var{name}, usually @strong{ps}.
15320
15321 @item -g
15322 Tell the printer to guess the page length.  Useful for printing
15323 vertically centered pages when the paper dimensions are determined at
15324 print time.
15325
15326 @item -I@var{path} @dots{}
15327 Consider the directory @file{@var{path}} for searching included files
15328 specified with relative paths.  The current directory is searched as
15329 fallback.
15330
15331 @item -l
15332 Use landscape orientation.
15333
15334 @item -m
15335 Use manual feed.
15336
15337 @item -p@var{papersize}
15338 Set the page dimensions.  Overrides the commands @option{papersize},
15339 @option{paperlength}, and @option{paperwidth} in the @file{DESC}
15340 file.  See the @cite{groff_font(5)} manual page for details.
15341
15342 @item -P@var{prologue}
15343 Use the @var{prologue} in the font path as the prologue instead of
15344 the default @file{prologue}.  Overrides the environment variable
15345 @env{GROPS_PROLOGUE}.
15346
15347 @item -w@var{n}
15348 Set the line thickness to @var{n}/1000@dmn{em}.  Overrides the
15349 default value @var{n} = 40.
15350
15351 @item -v
15352 Print the version number.
15353 @end table
15354
15355 @c ---------------------------------------------------------------------
15356
15357 @node Embedding PostScript,  , Invoking grops, grops
15358 @subsection Embedding @sc{PostScript}
15359 @cindex embedding PostScript
15360 @cindex PostScript, embedding
15361
15362 The escape sequence
15363
15364 @code{\X'ps: import @var{file} @var{llx} @var{lly} @var{urx} @var{ury}
15365   @var{width} [@var{height}]'}
15366
15367 @noindent
15368 places a rectangle of the specified @var{width} containing the
15369 @sc{PostScript} drawing from file @var{file} bound by the box from
15370 @var{llx} @var{lly} to @var{urx} @var{ury} (in @sc{PostScript}
15371 coordinates) at the insertion point.  If @var{height} is not
15372 specified, the embedded drawing is scaled proportionally.
15373
15374 @xref{Miscellaneous}, for the @code{psbb} request, which automatically
15375 generates the bounding box.
15376
15377 This escape sequence is used internally by the macro @code{PSPIC}
15378 (see the @cite{groff_tmac(5)} manual page).
15379
15380
15381 @c =====================================================================
15382
15383 @node gropdf, grodvi, grops, Output Devices
15384 @section @code{gropdf}
15385 @cindex @code{gropdf}, the program
15386
15387 The postprocessor @command{gropdf} translates the output from GNU
15388 @command{troff} into a form suitable for Adobe PDF devices.  It is fully
15389 documented on its manual page, @cite{gropdf(1)}.
15390
15391 @menu
15392 * Invoking gropdf::
15393 * Embedding PDF::
15394 @end menu
15395
15396 @c ---------------------------------------------------------------------
15397
15398 @node Invoking gropdf, Embedding PDF, gropdf, gropdf
15399 @subsection Invoking @code{gropdf}
15400 @cindex invoking @code{gropdf}
15401 @cindex @code{gropdf}, invoking
15402
15403 The postprocessor @code{gropdf} accepts the following command-line
15404 options:
15405
15406 @table @option
15407 @item -d
15408 Produce uncompressed PDFs that include debugging comments.
15409
15410 @item -e
15411 This forces @code{gropdf} to embed all used fonts in the PDF,
15412 even if they are one of the 14 base Adobe fonts.
15413
15414 @item -F@var{dir}
15415 Put the directory @file{@var{dir}/dev@var{name}} in front of the
15416 search path for the font, prologue and device description files,
15417 given the target device @var{name}, usually @strong{pdf}.
15418
15419 @item -y@var{foundry}
15420 This forces the use of a different font foundry.
15421
15422 @item -l
15423 Use landscape orientation.
15424
15425 @item -p@var{papersize}
15426 Set the page dimensions.  Overrides the commands @option{papersize},
15427 @option{paperlength}, and @option{paperwidth} in the @file{DESC}
15428 file.  See the @cite{groff_font(5)} manual page for details.
15429
15430 @item -v
15431 Print the version number.
15432
15433 @item -s
15434 Append a comment line to end of PDF showing statistics, i.e. number of
15435 pages in document.  Ghostscript's @cite{ps2pdf(1)} complains about this
15436 line if it is included, but works anyway.
15437
15438 @item -u@var{filename}
15439 @code{gropdf} normally includes a ToUnicode CMap with any font created
15440 using @file{text.enc} as the encoding file, this makes it easier to
15441 search for words that contain ligatures.  You can include your own CMap
15442 by specifying a @var{filename} or have no CMap at all by omitting the
15443 @var{filename}.
15444 @end table
15445
15446 @c ---------------------------------------------------------------------
15447
15448 @node Embedding PDF,  , Invoking gropdf, gropdf
15449 @subsection Embedding PDF
15450 @cindex embedding PDF
15451 @cindex PDF, embedding
15452
15453 The escape sequence
15454
15455 @code{\X'pdf: pdfpic @var{file} @var{alignment} @var{width} [@var{height}]
15456   [@var{linelength}]'}
15457
15458 @noindent
15459 places a rectangle of the specified @var{width} containing the PDF
15460 drawing from file @var{file} of desired @var{width} and @var{height} (if
15461 @var{height} is missing or zero then it is scaled proportionally).  If
15462 @var{alignment} is @code{-L} the drawing is left aligned.  If it is
15463 @code{-C} or @code{-R} a @var{linelength} greater than the width of the
15464 drawing is required as well.  If @var{width} is specified as zero then
15465 the width is scaled in proportion to the height.
15466
15467
15468 @c =====================================================================
15469
15470 @node grodvi, grolj4, gropdf, Output Devices
15471 @section @code{grodvi}
15472 @cindex @code{grodvi}, the program
15473
15474 The postprocessor @command{grodvi} translates the output from GNU
15475 @command{troff} into the @strong{DVI} output format compatible with
15476 the @strong{@TeX{}} document preparation system.  It is fully
15477 documented on its manual page, @cite{grodvi(1)}.
15478
15479 @menu
15480 * Invoking grodvi::
15481 @end menu
15482
15483 @c ---------------------------------------------------------------------
15484
15485 @node Invoking grodvi,  , grodvi, grodvi
15486 @subsection Invoking @code{grodvi}
15487 @cindex invoking @code{grodvi}
15488 @cindex @code{grodvi}, invoking
15489
15490 The postprocessor @code{grodvi} accepts the following command-line
15491 options:
15492
15493 @table @option
15494 @item -d
15495 Do not use @strong{tpic} specials to implement drawing commands.
15496
15497 @item -F@var{dir}
15498 Put the directory @file{@var{dir}/dev@var{name}} in front of the
15499 search path for the font and device description files, given the
15500 target device @var{name}, usually @strong{dvi}.
15501
15502 @item -l
15503 Use landscape orientation.
15504
15505 @item -p@var{papersize}
15506 Set the page dimensions.  Overrides the commands @option{papersize},
15507 @option{paperlength}, and @option{paperwidth} in the @file{DESC}
15508 file.  See @cite{groff_font(5)} manual page for details.
15509
15510 @item -v
15511 Print the version number.
15512
15513 @item -w@var{n}
15514 Set the line thickness to @var{n}/1000@dmn{em}.  Overrides the
15515 default value @var{n} = 40.
15516 @end table
15517
15518
15519 @c =====================================================================
15520
15521 @node grolj4, grolbp, grodvi, Output Devices
15522 @section @code{grolj4}
15523 @cindex @code{grolj4}, the program
15524
15525 The postprocessor @command{grolj4} translates the output from GNU
15526 @command{troff} into the @strong{PCL5} output format suitable for
15527 printing on a @strong{HP LaserJet@tie{}4} printer.  It is fully
15528 documented on its manual page, @cite{grolj4(1)}.
15529
15530 @menu
15531 * Invoking grolj4::
15532 @end menu
15533
15534 @c ---------------------------------------------------------------------
15535
15536 @node Invoking grolj4,  , grolj4, grolj4
15537 @subsection Invoking @code{grolj4}
15538 @cindex invoking @code{grolj4}
15539 @cindex @code{grolj4}, invoking
15540
15541 The postprocessor @code{grolj4} accepts the following command-line
15542 options:
15543
15544 @table @option
15545 @item -c@var{n}
15546 Print @var{n} copies of each page.
15547
15548 @item -F@var{dir}
15549 Put the directory @file{@var{dir}/dev@var{name}} in front of the
15550 search path for the font and device description files, given the
15551 target device @var{name}, usually @strong{lj4}.
15552
15553 @item -l
15554 Use landscape orientation.
15555
15556 @item -p@var{size}
15557 Set the page dimensions.  Valid values for @var{size} are:
15558 @code{letter}, @code{legal}, @code{executive}, @code{a4},
15559 @code{com10}, @code{monarch}, @code{c5}, @code{b5}, @code{d1}.
15560
15561 @item -v
15562 Print the version number.
15563
15564 @item -w@var{n}
15565 Set the line thickness to @var{n}/1000@dmn{em}.  Overrides the
15566 default value @var{n} = 40.
15567 @end table
15568
15569 The special drawing command @code{\D'R @var{dh} @var{dv}'} draws a
15570 horizontal rectangle from the current position to the position at
15571 offset (@var{dh},@var{dv}).
15572
15573
15574 @c =====================================================================
15575
15576 @node grolbp, grohtml, grolj4, Output Devices
15577 @section @code{grolbp}
15578 @cindex @code{grolbp}, the program
15579
15580 The postprocessor @command{grolbp} translates the output from GNU
15581 @command{troff} into the @strong{LBP} output format suitable for
15582 printing on @strong{Canon CAPSL} printers.  It is fully documented on
15583 its manual page, @cite{grolbp(1)}.
15584
15585 @menu
15586 * Invoking grolbp::
15587 @end menu
15588
15589 @c ---------------------------------------------------------------------
15590
15591 @node Invoking grolbp,  , grolbp, grolbp
15592 @subsection Invoking @code{grolbp}
15593 @cindex invoking @code{grolbp}
15594 @cindex @code{grolbp}, invoking
15595
15596 The postprocessor @code{grolbp} accepts the following command-line
15597 options:
15598
15599 @table @option
15600 @item -c@var{n}
15601 Print @var{n} copies of each page.
15602
15603 @item -F@var{dir}
15604 Put the directory @file{@var{dir}/dev@var{name}} in front of the
15605 search path for the font, prologue and device description files,
15606 given the target device @var{name}, usually @strong{lbp}.
15607
15608 @item -l
15609 Use landscape orientation.
15610
15611 @item -o@var{orientation}
15612 Use the @var{orientation} specified: @code{portrait} or
15613 @code{landscape}.
15614
15615 @item -p@var{papersize}
15616 Set the page dimensions.  See @cite{groff_font(5)} manual page for
15617 details.
15618
15619 @item -w@var{n}
15620 Set the line thickness to @var{n}/1000@dmn{em}.  Overrides the
15621 default value @var{n} = 40.
15622
15623 @item -v
15624 Print the version number.
15625
15626 @item -h
15627 Print command-line help.
15628 @end table
15629
15630
15631 @c =====================================================================
15632
15633 @node grohtml, gxditview, grolbp, Output Devices
15634 @section @code{grohtml}
15635 @cindex @code{grohtml}, the program
15636
15637 The @code{grohtml} front end (which consists of a preprocessor,
15638 @code{pre-grohtml}, and a device driver, @code{post-grohtml}) translates
15639 the output of GNU @code{troff} to @acronym{HTML}.  Users should always
15640 invoke @code{grohtml} via the @code{groff} command with a @code{\-Thtml}
15641 option.  If no files are given, @code{grohtml} will read the standard
15642 input.  A filename of @code{-} will also cause @code{grohtml} to read
15643 the standard input.  @acronym{HTML} output is written to the standard
15644 output.  When @code{grohtml} is run by @code{groff}, options can be
15645 passed to @code{grohtml} using @code{groff}'s @option{-P} option.
15646
15647 @code{grohtml} invokes @code{groff} twice.  In the first pass, pictures,
15648 equations, and tables are rendered using the @code{ps} device, and in
15649 the second pass @acronym{HTML} output is generated by the @code{html}
15650 device.
15651
15652 @code{grohtml} always writes output in @code{UTF-8} encoding and has
15653 built-in entities for all non-composite unicode characters.  In spite of
15654 this, @code{groff} may issue warnings about unknown special characters
15655 if they can't be found during the first pass.  Such warnings can be
15656 safely ignored unless the special characters appear inside a table or
15657 equation, in which case glyphs for these characters must be defined for
15658 the @code{ps} device as well.
15659
15660 This output device is fully documented on its manual page,
15661 @cite{grohtml(1)}.
15662
15663 @menu
15664 * Invoking grohtml::
15665 * grohtml specific registers and strings::
15666 @end menu
15667
15668 @c ---------------------------------------------------------------------
15669
15670 @node Invoking grohtml, grohtml specific registers and strings, grohtml, grohtml
15671 @subsection Invoking @code{grohtml}
15672 @cindex invoking @code{grohtml}
15673 @cindex @code{grohtml}, invoking
15674
15675 The postprocessor @code{grohtml} accepts the following command-line
15676 options:
15677
15678 @table @option
15679 @item -a@var{bits}
15680 Use this number of @var{bits} (= 1, 2 or 4) for text antialiasing.
15681 Default: @var{bits} = 4.
15682
15683 @item -a0
15684 Do not use text antialiasing.
15685
15686 @item -b
15687 Use white background.
15688
15689 @item -D@var{dir}
15690 Store rendered images in the directory @file{@var{dir}}.
15691
15692 @item -F@var{dir}
15693 Put the directory @file{@var{dir}/dev@var{name}} in front of the
15694 search path for the font, prologue and device description files,
15695 given the target device @var{name}, usually @strong{html}.
15696
15697 @item -g@var{bits}
15698 Use this number of @var{bits} (= 1, 2 or 4) for antialiasing of
15699 drawings.  Default: @var{bits} = 4.
15700
15701 @item -g0
15702 Do not use antialiasing for drawings.
15703
15704 @item -h
15705 Use the @code{B} element for section headings.
15706
15707 @item -i@var{resolution}
15708 Use the @var{resolution} for rendered images.  Default:
15709 @var{resolution} = 100@dmn{dpi}.
15710
15711 @item -I@var{stem}
15712 Set the images' @var{stem name}.  Default: @var{stem} =
15713 @file{grohtml-@var{XXX}} (@var{XXX} is the process ID).
15714
15715 @item -j@var{stem}
15716 Place each section in a separate file called
15717 @file{@var{stem}-@var{n}.html} (where @var{n} is a generated section
15718 number).
15719
15720 @item -l
15721 Do not generate the table of contents.
15722
15723 @item -n
15724 Generate simple fragment identifiers.
15725
15726 @item -o@var{offset}
15727 Use vertical padding @var{offset} for images.
15728
15729 @item -p
15730 Display the page rendering progress to @code{stderr}.
15731
15732 @item -r
15733 Do not use horizontal rules to separate headers and footers.
15734
15735 @item -s@var{size}
15736 Set the base font size, to be modified using the elements @code{BIG}
15737 and @code{SMALL}.
15738
15739 @item -S@var{level}
15740 Generate separate files for sections at level @var{level}.
15741
15742 @item -v
15743 Print the version number.
15744
15745 @item -V
15746 Generate a validator button at the bottom.
15747
15748 @item -y
15749 Generate a signature of groff after the validator button, if any.
15750 @end table
15751
15752
15753 @c ---------------------------------------------------------------------
15754
15755 @node grohtml specific registers and strings,  , Invoking grohtml, grohtml
15756 @subsection @code{grohtml} specific registers and strings
15757 @cindex registers specific to @code{grohtml}
15758 @cindex strings specific to @code{grohtml}
15759 @cindex @code{grohtml}, registers and strings
15760
15761 @DefmpregList {ps4html, grohtml}
15762 @DefstrListEndx {www-image-template, grohtml}
15763 The registers @code{ps4html} and @code{www-image-template} are defined
15764 by the @code{pre-grohtml} preprocessor.  @code{pre-grohtml} reads in the
15765 @code{troff} input, marks up the inline equations and passes the result
15766 firstly to
15767
15768 @Example
15769 troff -Tps -rps4html=1 -dwww-image-template=@var{template}
15770 @endExample
15771
15772 @noindent
15773 and secondly to
15774
15775 @Example
15776 troff -Thtml
15777 @endExample
15778
15779 @noindent
15780 or
15781
15782 @Example
15783 troff -Txhtml
15784 @endExample
15785
15786 @cindex MathML
15787 The @sc{PostScript} device is used to create all the image files (for
15788 @option{-Thtml}; if @option{-Txhtml} is used, all equations are passed
15789 to @code{geqn} to produce @acronym{MathML}, and the register
15790 @code{ps4html} enables the macro sets to ignore floating keeps, footers,
15791 and headings.
15792
15793 The register @code{www-image-template} is set to the user specified
15794 template name or the default name.
15795 @endDefmpreg
15796
15797
15798 @c =====================================================================
15799
15800 @node gxditview,  , grohtml, Output Devices
15801 @section @code{gxditview}
15802 @cindex @code{gxditview}, the program
15803
15804 @c XXX
15805
15806 @menu
15807 * Invoking gxditview::
15808 @end menu
15809
15810 @c ---------------------------------------------------------------------
15811
15812 @node Invoking gxditview,  , gxditview, gxditview
15813 @subsection Invoking @code{gxditview}
15814 @cindex invoking @code{gxditview}
15815 @cindex @code{gxditview}, invoking
15816
15817 @c XXX
15818 @c X11's xditview
15819
15820
15821
15822 @c =====================================================================
15823 @c =====================================================================
15824
15825 @node File formats, Installation, Output Devices, Top
15826 @chapter File formats
15827 @cindex file formats
15828 @cindex formats, file
15829
15830 All files read and written by @code{gtroff} are text files.  The
15831 following two sections describe their format.
15832
15833 @menu
15834 * gtroff Output::
15835 * Font Files::
15836 @end menu
15837
15838
15839 @c =====================================================================
15840
15841 @node gtroff Output, Font Files, File formats, File formats
15842 @section @code{gtroff} Output
15843 @cindex @code{gtroff}, output
15844 @cindex output, @code{gtroff}
15845
15846 This section describes the intermediate output format of GNU
15847 @code{troff}.  This output is produced by a run of @code{gtroff} before
15848 it is fed into a device postprocessor program.
15849
15850 As @code{groff} is a wrapper program around @code{gtroff} that
15851 automatically calls a postprocessor, this output does not show up
15852 normally.  This is why it is called @dfn{intermediate}.  @code{groff}
15853 provides the option @option{-Z} to inhibit postprocessing, such that the
15854 produced intermediate output is sent to standard output just like
15855 calling @code{gtroff} manually.
15856
15857 @cindex troff output
15858 @cindex output, troff
15859 @cindex intermediate output
15860 @cindex output, intermediate
15861 Here, the term @dfn{troff output} describes what is output by
15862 @code{gtroff}, while @dfn{intermediate output} refers to the language
15863 that is accepted by the parser that prepares this output for the
15864 postprocessors.  This parser is smarter on whitespace and implements
15865 obsolete elements for compatibility, otherwise both formats are the
15866 same.@footnote{The parser and postprocessor for intermediate output can
15867 be found in the file@*
15868 @file{@var{groff-source-dir}/src/libs/libdriver/input.cpp}.}
15869
15870 The main purpose of the intermediate output concept is to facilitate the
15871 development of postprocessors by providing a common programming
15872 interface for all devices.  It has a language of its own that is
15873 completely different from the @code{gtroff} language.  While the
15874 @code{gtroff} language is a high-level programming language for text
15875 processing, the intermediate output language is a kind of low-level
15876 assembler language by specifying all positions on the page for writing
15877 and drawing.
15878
15879 The intermediate output produced by @code{gtroff} is fairly readable,
15880 while output from @acronym{AT&T} @code{troff} is rather hard to
15881 understand because of strange habits that are still supported, but not
15882 used any longer by @code{gtroff}.
15883
15884 @menu
15885 * Language Concepts::
15886 * Command Reference::
15887 * Intermediate Output Examples::
15888 * Output Language Compatibility::
15889 @end menu
15890
15891 @c ---------------------------------------------------------------------
15892
15893 @node Language Concepts, Command Reference, gtroff Output, gtroff Output
15894 @subsection Language Concepts
15895
15896 During the run of @code{gtroff}, the input data is cracked down to the
15897 information on what has to be printed at what position on the intended
15898 device.  So the language of the intermediate output format can be quite
15899 small.  Its only elements are commands with and without arguments.  In
15900 this section, the term @dfn{command} always refers to the intermediate
15901 output language, and never to the @code{gtroff} language used for
15902 document formatting.  There are commands for positioning and text
15903 writing, for drawing, and for device controlling.
15904
15905 @menu
15906 * Separation::
15907 * Argument Units::
15908 * Document Parts::
15909 @end menu
15910
15911 @node Separation, Argument Units, Language Concepts, Language Concepts
15912 @subsubsection Separation
15913
15914 @acronym{AT&T} @code{troff} output has strange requirements on
15915 whitespace.  The @code{gtroff} output parser, however, is smart about
15916 whitespace by making it maximally optional.  The whitespace characters,
15917 i.e., the tab, space, and newline characters, always have a syntactical
15918 meaning.  They are never printable because spacing within the output is
15919 always done by positioning commands.
15920
15921 Any sequence of space or tab characters is treated as a single
15922 @dfn{syntactical space}.  It separates commands and arguments, but is
15923 only required when there would occur a clashing between the command code
15924 and the arguments without the space.  Most often, this happens when
15925 variable-length command names, arguments, argument lists, or command
15926 clusters meet.  Commands and arguments with a known, fixed length need
15927 not be separated by syntactical space.
15928
15929 A line break is a syntactical element, too.  Every command argument can
15930 be followed by whitespace, a comment, or a newline character.  Thus a
15931 @dfn{syntactical line break} is defined to consist of optional
15932 syntactical space that is optionally followed by a comment, and a
15933 newline character.
15934
15935 The normal commands, those for positioning and text, consist of a single
15936 letter taking a fixed number of arguments.  For historical reasons, the
15937 parser allows stacking of such commands on the same line, but
15938 fortunately, in @code{gtroff}'s intermediate output, every command with
15939 at least one argument is followed by a line break, thus providing
15940 excellent readability.
15941
15942 The other commands -- those for drawing and device controlling -- have a
15943 more complicated structure; some recognize long command names, and some
15944 take a variable number of arguments.  So all @samp{D} and @samp{x}
15945 commands were designed to request a syntactical line break after their
15946 last argument.  Only one command, @w{@samp{x X}}, has an argument that
15947 can stretch over several lines; all other commands must have all of
15948 their arguments on the same line as the command, i.e., the arguments may
15949 not be split by a line break.
15950
15951 Empty lines (these are lines containing only space and/or a comment),
15952 can occur everywhere.  They are just ignored.
15953
15954 @node Argument Units, Document Parts, Separation, Language Concepts
15955 @subsubsection Argument Units
15956
15957 Some commands take integer arguments that are assumed to represent
15958 values in a measurement unit, but the letter for the corresponding scale
15959 indicator is not written with the output command arguments.  Most
15960 commands assume the scale indicator @samp{u}, the basic unit of the
15961 device, some use @samp{z}, the scaled point unit of the device, while
15962 others, such as the color commands, expect plain integers.
15963
15964 Note that single characters can have the eighth bit set, as can the
15965 names of fonts and special characters.  The names of characters and
15966 fonts can be of arbitrary length.  A character that is to be printed is
15967 always in the current font.
15968
15969 A string argument is always terminated by the next whitespace character
15970 (space, tab, or newline); an embedded @samp{#} character is regarded as
15971 part of the argument, not as the beginning of a comment command.  An
15972 integer argument is already terminated by the next non-digit character,
15973 which then is regarded as the first character of the next argument or
15974 command.
15975
15976 @node Document Parts,  , Argument Units, Language Concepts
15977 @subsubsection Document Parts
15978
15979 A correct intermediate output document consists of two parts, the
15980 @dfn{prologue} and the @dfn{body}.
15981
15982 The task of the prologue is to set the general device parameters using
15983 three exactly specified commands.  @code{gtroff}'s prologue is
15984 guaranteed to consist of the following three lines (in that order):
15985
15986 @Example
15987 x T @var{device}
15988 x res @var{n} @var{h} @var{v}
15989 x init
15990 @endExample
15991
15992 @noindent
15993 with the arguments set as outlined in @ref{Device Control Commands}.
15994 Note that the parser for the intermediate output format is able to
15995 swallow additional whitespace and comments as well even in the prologue.
15996
15997 The body is the main section for processing the document data.
15998 Syntactically, it is a sequence of any commands different from the ones
15999 used in the prologue.  Processing is terminated as soon as the first
16000 @w{@samp{x stop}} command is encountered; the last line of any
16001 @code{gtroff} intermediate output always contains such a command.
16002
16003 Semantically, the body is page oriented.  A new page is started by a
16004 @samp{p} command.  Positioning, writing, and drawing commands are always
16005 done within the current page, so they cannot occur before the first
16006 @samp{p} command.  Absolute positioning (by the @samp{H} and @samp{V}
16007 commands) is done relative to the current page; all other positioning is
16008 done relative to the current location within this page.
16009
16010 @c ---------------------------------------------------------------------
16011
16012 @node Command Reference, Intermediate Output Examples, Language Concepts, gtroff Output
16013 @subsection Command Reference
16014
16015 This section describes all intermediate output commands, both from
16016 @acronym{AT&T} @code{troff} as well as the @code{gtroff} extensions.
16017
16018 @menu
16019 * Comment Command::
16020 * Simple Commands::
16021 * Graphics Commands::
16022 * Device Control Commands::
16023 * Obsolete Command::
16024 @end menu
16025
16026 @node Comment Command, Simple Commands, Command Reference, Command Reference
16027 @subsubsection Comment Command
16028
16029 @table @code
16030 @item #@var{anything}@angles{end of line}
16031 A comment.  Ignore any characters from the @samp{#} character up to the
16032 next newline character.
16033
16034 This command is the only possibility for commenting in the intermediate
16035 output.  Each comment can be preceded by arbitrary syntactical space;
16036 every command can be terminated by a comment.
16037 @end table
16038
16039 @node Simple Commands, Graphics Commands, Comment Command, Command Reference
16040 @subsubsection Simple Commands
16041
16042 The commands in this subsection have a command code consisting of a
16043 single character, taking a fixed number of arguments.  Most of them are
16044 commands for positioning and text writing.  These commands are smart
16045 about whitespace.  Optionally, syntactical space can be inserted before,
16046 after, and between the command letter and its arguments.  All of these
16047 commands are stackable, i.e., they can be preceded by other simple
16048 commands or followed by arbitrary other commands on the same line.  A
16049 separating syntactical space is only necessary when two integer
16050 arguments would clash or if the preceding argument ends with a string
16051 argument.
16052
16053 @table @code
16054 @ignore
16055 .if (\n[@USE_ENV_STACK] == 1) \{\
16056 .command {
16057 Open a new environment by copying the actual device configuration data
16058 to the environment stack.
16059 .
16060 The current environment is setup by the device specification and
16061 manipulated by the setting commands.
16062 .
16063 .
16064 .command }
16065 Close the actual environment (opened by a preceding
16066 .BR { \~command)
16067 and restore the previous environment from the environment
16068 stack as the actual device configuration data.
16069 .
16070 \}              \" endif @USE_ENV_STACK
16071 @end ignore
16072
16073 @item C @var{xxx}@angles{whitespace}
16074 Print a special character named @var{xxx}.  The trailing syntactical
16075 space or line break is necessary to allow glyph names of arbitrary
16076 length.  The glyph is printed at the current print position; the glyph's
16077 size is read from the font file.  The print position is not changed.
16078
16079 @item c @var{g}
16080 Print glyph@tie{}@var{g} at the current print
16081 position;@footnote{@samp{c} is actually a misnomer since it outputs a
16082 glyph.} the glyph's size is read from the font file.  The print position
16083 is not changed.
16084
16085 @item f @var{n}
16086 Set font to font number@tie{}@var{n} (a non-negative integer).
16087
16088 @item H @var{n}
16089 Move right to the absolute vertical position@tie{}@var{n} (a
16090 non-negative integer in basic units @samp{u} relative to left edge of
16091 current page.
16092
16093 @item h @var{n}
16094 Move @var{n} (a non-negative integer) basic units @samp{u} horizontally
16095 to the right.  The original Unix troff manual allows negative
16096 values for @var{n} also, but @code{gtroff} doesn't use this.
16097
16098 @item m @var{color-scheme} @r{[}@var{component} @dots{}@r{]}
16099 Set the color for text (glyphs), line drawing, and the outline of
16100 graphic objects using different color schemes; the analogous command
16101 for the filling color of graphic objects is @samp{DF}.  The color
16102 components are specified as integer arguments between 0 and 65536.  The
16103 number of color components and their meaning vary for the different
16104 color schemes.  These commands are generated by @code{gtroff}'s escape
16105 sequence @code{\m}.  No position changing.  These commands are a
16106 @code{gtroff} extension.
16107
16108 @table @code
16109 @item mc @var{cyan} @var{magenta} @var{yellow}
16110 Set color using the CMY color scheme, having the 3@tie{}color components
16111 @var{cyan}, @var{magenta}, and @var{yellow}.
16112
16113 @item md
16114 Set color to the default color value (black in most cases).  No
16115 component arguments.
16116
16117 @item mg @var{gray}
16118 Set color to the shade of gray given by the argument, an integer between
16119 0 (black) and 65536 (white).
16120
16121 @item mk @var{cyan} @var{magenta} @var{yellow} @var{black}
16122 Set color using the CMYK color scheme, having the 4@tie{}color
16123 components @var{cyan}, @var{magenta}, @var{yellow}, and @var{black}.
16124
16125 @item mr @var{red} @var{green} @var{blue}
16126 Set color using the RGB color scheme, having the 3@tie{}color components
16127 @var{red}, @var{green}, and @var{blue}.
16128 @end table
16129
16130 @item N @var{n}
16131 Print glyph with index@tie{}@var{n} (a non-negative integer) of the
16132 current font.  This command is a @code{gtroff} extension.
16133
16134 @item n @var{b} @var{a}
16135 Inform the device about a line break, but no positioning is done by this
16136 command.  In @acronym{AT&T} @code{troff}, the integer arguments @var{b}
16137 and@tie{}@var{a} informed about the space before and after the current
16138 line to make the intermediate output more human readable without
16139 performing any action.  In @code{groff}, they are just ignored, but they
16140 must be provided for compatibility reasons.
16141
16142 @item p @var{n}
16143 Begin a new page in the outprint.  The page number is set
16144 to@tie{}@var{n}.  This page is completely independent of pages formerly
16145 processed even if those have the same page number.  The vertical
16146 position on the outprint is automatically set to@tie{}0.  All
16147 positioning, writing, and drawing is always done relative to a page, so
16148 a @samp{p} command must be issued before any of these commands.
16149
16150 @item s @var{n}
16151 Set point size to @var{n}@tie{}scaled points (this is unit @samp{z}).
16152 @acronym{AT&T} @code{troff} used the unit points (@samp{p}) instead.
16153 @xref{Output Language Compatibility}.
16154
16155 @item t @var{xxx}@angles{whitespace}
16156 @itemx t @var{xxx} @var{dummy-arg}@angles{whitespace}
16157 Print a word, i.e., a sequence of characters @var{xxx} representing
16158 output glyphs which names are single characters, terminated by a space
16159 character or a line break; an optional second integer argument is
16160 ignored (this allows the formatter to generate an even number of
16161 arguments).  The first glyph should be printed at the current position,
16162 the current horizontal position should then be increased by the width of
16163 the first glyph, and so on for each glyph.  The widths of the glyphs are
16164 read from the font file, scaled for the current point size, and rounded
16165 to a multiple of the horizontal resolution.  Special characters cannot
16166 be printed using this command (use the @samp{C} command for special
16167 characters).  This command is a @code{gtroff} extension; it is only used
16168 for devices whose @file{DESC} file contains the @code{tcommand} keyword
16169 (@pxref{DESC File Format}).
16170
16171 @item u @var{n} @var{xxx}@angles{whitespace}
16172 Print word with track kerning.  This is the same as the @samp{t} command
16173 except that after printing each glyph, the current horizontal position
16174 is increased by the sum of the width of that glyph and@tie{}@var{n} (an
16175 integer in basic units @samp{u}).  This command is a @code{gtroff}
16176 extension; it is only used for devices whose @file{DESC} file contains
16177 the @code{tcommand} keyword (@pxref{DESC File Format}).
16178
16179 @item V @var{n}
16180 Move down to the absolute vertical position@tie{}@var{n} (a non-negative
16181 integer in basic units @samp{u}) relative to upper edge of current page.
16182
16183 @item v @var{n}
16184 Move @var{n}@tie{}basic units @samp{u} down (@var{n} is a non-negative
16185 integer).  The original Unix troff manual allows negative values for
16186 @var{n} also, but @code{gtroff} doesn't use this.
16187
16188 @item w
16189 Informs about a paddable white space to increase readability.  The
16190 spacing itself must be performed explicitly by a move command.
16191 @end table
16192
16193 @node Graphics Commands, Device Control Commands, Simple Commands, Command Reference
16194 @subsubsection Graphics Commands
16195
16196 Each graphics or drawing command in the intermediate output starts with
16197 the letter @samp{D}, followed by one or two characters that specify a
16198 subcommand; this is followed by a fixed or variable number of integer
16199 arguments that are separated by a single space character.  A @samp{D}
16200 command may not be followed by another command on the same line (apart
16201 from a comment), so each @samp{D} command is terminated by a syntactical
16202 line break.
16203
16204 @code{gtroff} output follows the classical spacing rules (no space
16205 between command and subcommand, all arguments are preceded by a single
16206 space character), but the parser allows optional space between the
16207 command letters and makes the space before the first argument optional.
16208 As usual, each space can be any sequence of tab and space characters.
16209
16210 Some graphics commands can take a variable number of arguments.  In this
16211 case, they are integers representing a size measured in basic units
16212 @samp{u}.  The arguments called @var{h1}, @var{h2}, @dots{}, @var{hn}
16213 stand for horizontal distances where positive means right, negative
16214 left.  The arguments called @var{v1}, @var{v2}, @dots{}, @var{vn} stand
16215 for vertical distances where positive means down, negative up.  All
16216 these distances are offsets relative to the current location.
16217
16218 Each graphics command directly corresponds to a similar @code{gtroff}
16219 @code{\D} escape sequence.  @xref{Drawing Requests}.
16220
16221 Unknown @samp{D} commands are assumed to be device-specific.  Its
16222 arguments are parsed as strings; the whole information is then sent to
16223 the postprocessor.
16224
16225 In the following command reference, the syntax element @angles{line
16226 break} means a syntactical line break as defined above.
16227
16228 @table @code
16229 @item D~ @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
16230 Draw B-spline from current position to offset (@var{h1},@var{v1}), then
16231 to offset (@var{h2},@var{v2}), if given, etc.@: up to
16232 (@var{hn},@var{vn}).  This command takes a variable number of argument
16233 pairs; the current position is moved to the terminal point of the drawn
16234 curve.
16235
16236 @item Da @var{h1} @var{v1} @var{h2} @var{v2}@angles{line break}
16237 Draw arc from current position to
16238 (@var{h1},@var{v1})@math{+}(@var{h2},@var{v2}) with center at
16239 (@var{h1},@var{v1}); then move the current position to the final point
16240 of the arc.
16241
16242 @item DC @var{d}@angles{line break}
16243 @itemx DC @var{d} @var{dummy-arg}@angles{line break}
16244 Draw a solid circle using the current fill color with
16245 diameter@tie{}@var{d} (integer in basic units @samp{u}) with leftmost
16246 point at the current position; then move the current position to the
16247 rightmost point of the circle.  An optional second integer argument is
16248 ignored (this allows the formatter to generate an even number of
16249 arguments).  This command is a @code{gtroff} extension.
16250
16251 @item Dc @var{d}@angles{line break}
16252 Draw circle line with diameter@tie{}@var{d} (integer in basic units
16253 @samp{u}) with leftmost point at the current position; then move the
16254 current position to the rightmost point of the circle.
16255
16256 @item DE @var{h} @var{v}@angles{line break}
16257 Draw a solid ellipse in the current fill color with a horizontal
16258 diameter of@tie{}@var{h} and a vertical diameter of@tie{}@var{v} (both
16259 integers in basic units @samp{u}) with the leftmost point at the current
16260 position; then move to the rightmost point of the ellipse.  This command
16261 is a @code{gtroff} extension.
16262
16263 @item De @var{h} @var{v}@angles{line break}
16264 Draw an outlined ellipse with a horizontal diameter of@tie{}@var{h} and
16265 a vertical diameter of@tie{}@var{v} (both integers in basic units
16266 @samp{u}) with the leftmost point at current position; then move to the
16267 rightmost point of the ellipse.
16268
16269 @item DF @var{color-scheme} @r{[}@var{component} @dots{}@r{]}@angles{line break}
16270 Set fill color for solid drawing objects using different color schemes;
16271 the analogous command for setting the color of text, line graphics, and
16272 the outline of graphic objects is @samp{m}.  The color components are
16273 specified as integer arguments between 0 and 65536.  The number of color
16274 components and their meaning vary for the different color schemes.
16275 These commands are generated by @code{gtroff}'s escape sequences
16276 @w{@code{\D'F @dots{}'}} and @code{\M} (with no other corresponding
16277 graphics commands).  No position changing.  This command is a
16278 @code{gtroff} extension.
16279
16280 @table @code
16281 @item DFc @var{cyan} @var{magenta} @var{yellow}@angles{line break}
16282 Set fill color for solid drawing objects using the CMY color scheme,
16283 having the 3@tie{}color components @var{cyan}, @var{magenta}, and
16284 @var{yellow}.
16285
16286 @item DFd@angles{line break}
16287 Set fill color for solid drawing objects to the default fill color value
16288 (black in most cases).  No component arguments.
16289
16290 @item DFg @var{gray}@angles{line break}
16291 Set fill color for solid drawing objects to the shade of gray given by
16292 the argument, an integer between 0 (black) and 65536 (white).
16293
16294 @item DFk @var{cyan} @var{magenta} @var{yellow} @var{black}@angles{line break}
16295 Set fill color for solid drawing objects using the CMYK color scheme,
16296 having the 4@tie{}color components @var{cyan}, @var{magenta},
16297 @var{yellow}, and @var{black}.
16298
16299 @item DFr @var{red} @var{green} @var{blue}@angles{line break}
16300 Set fill color for solid drawing objects using the RGB color scheme,
16301 having the 3@tie{}color components @var{red}, @var{green}, and
16302 @var{blue}.
16303 @end table
16304
16305 @item Df @var{n}@angles{line break}
16306 The argument@tie{}@var{n} must be an integer in the range @math{-32767}
16307 to 32767.
16308
16309 @table @asis
16310 @item @math{0 @value{LE} @var{n} @value{LE} 1000}
16311 Set the color for filling solid drawing objects to a shade of gray,
16312 where 0 corresponds to solid white, 1000 (the default) to solid black,
16313 and values in between to intermediate shades of gray; this is obsoleted
16314 by command @samp{DFg}.
16315
16316 @item @math{@var{n} < 0} or @math{@var{n} > 1000}
16317 Set the filling color to the color that is currently being used for the
16318 text and the outline, see command @samp{m}.  For example, the command
16319 sequence
16320
16321 @Example
16322 mg 0 0 65536
16323 Df -1
16324 @endExample
16325
16326 @noindent
16327 sets all colors to blue.
16328 @end table
16329
16330 @noindent
16331 No position changing.  This command is a @code{gtroff} extension.
16332
16333 @item Dl @var{h} @var{v}@angles{line break}
16334 Draw line from current position to offset (@var{h},@var{v}) (integers in
16335 basic units @samp{u}); then set current position to the end of the drawn
16336 line.
16337
16338 @item Dp @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
16339 Draw a polygon line from current position to offset (@var{h1},@var{v1}),
16340 from there to offset (@var{h2},@var{v2}), etc.@: up to offset
16341 (@var{hn},@var{vn}), and from there back to the starting position.  For
16342 historical reasons, the position is changed by adding the sum of all
16343 arguments with odd index to the actual horizontal position and the even
16344 ones to the vertical position.  Although this doesn't make sense it is
16345 kept for compatibility.
16346 @ignore
16347 As the polygon is closed, the end of drawing is the starting point, so
16348 the position doesn't change.
16349 @end ignore
16350 This command is a @code{gtroff} extension.
16351
16352 @item DP @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
16353 Draw a solid polygon in the current fill color rather than an outlined
16354 polygon, using the same arguments and positioning as the corresponding
16355 @samp{Dp} command.
16356 @ignore
16357 No position changing.
16358 @end ignore
16359 This command is a @code{gtroff} extension.
16360
16361 @item Dt @var{n}@angles{line break}
16362 Set the current line thickness to@tie{}@var{n} (an integer in basic
16363 units @samp{u}) if @math{@var{n}>0}; if @math{@var{n}=0} select the
16364 smallest available line thickness; if @math{@var{n}<0} set the line
16365 thickness proportional to the point size (this is the default before the
16366 first @samp{Dt} command was specified).  For historical reasons, the
16367 horizontal position is changed by adding the argument to the actual
16368 horizontal position, while the vertical position is not changed.
16369 Although this doesn't make sense it is kept for compatibility.
16370 @ignore
16371 No position changing.
16372 @end ignore
16373 This command is a @code{gtroff} extension.
16374 @end table
16375
16376 @node Device Control Commands, Obsolete Command, Graphics Commands, Command Reference
16377 @subsubsection Device Control Commands
16378
16379 Each device control command starts with the letter @samp{x}, followed by
16380 a space character (optional or arbitrary space or tab in @code{gtroff})
16381 and a subcommand letter or word; each argument (if any) must be preceded
16382 by a syntactical space.  All @samp{x} commands are terminated by a
16383 syntactical line break; no device control command can be followed by
16384 another command on the same line (except a comment).
16385
16386 The subcommand is basically a single letter, but to increase
16387 readability, it can be written as a word, i.e., an arbitrary sequence of
16388 characters terminated by the next tab, space, or newline character.  All
16389 characters of the subcommand word but the first are simply ignored.  For
16390 example, @code{gtroff} outputs the initialization command @w{@samp{x i}}
16391 as @w{@samp{x init}} and the resolution command @w{@samp{x r}} as
16392 @w{@samp{x res}}.
16393
16394 In the following, the syntax element @angles{line break} means a
16395 syntactical line break (@pxref{Separation}).
16396
16397 @table @code
16398 @item xF @var{name}@angles{line break}
16399 The @samp{F} stands for @var{Filename}.
16400
16401 Use @var{name} as the intended name for the current file in error
16402 reports.  This is useful for remembering the original file name when
16403 @code{gtroff} uses an internal piping mechanism.  The input file is not
16404 changed by this command.  This command is a @code{gtroff} extension.
16405
16406 @item xf @var{n} @var{s}@angles{line break}
16407 The @samp{f} stands for @var{font}.
16408
16409 Mount font position@tie{}@var{n} (a non-negative integer) with font
16410 named@tie{}@var{s} (a text word).  @xref{Font Positions}.
16411
16412 @item xH @var{n}@angles{line break}
16413 The @samp{H} stands for @var{Height}.
16414
16415 Set glyph height to@tie{}@var{n} (a positive integer in scaled points
16416 @samp{z}).  @acronym{AT&T} @code{troff} uses the unit points (@samp{p})
16417 instead.  @xref{Output Language Compatibility}.
16418
16419 @item xi@angles{line break}
16420 The @samp{i} stands for @var{init}.
16421
16422 Initialize device.  This is the third command of the prologue.
16423
16424 @item xp@angles{line break}
16425 The @samp{p} stands for @var{pause}.
16426
16427 Parsed but ignored.  The original Unix troff manual writes
16428
16429 @display
16430 pause device, can be restarted
16431 @end display
16432
16433 @item xr @var{n} @var{h} @var{v}@angles{line break}
16434 The @samp{r} stands for @var{resolution}.
16435
16436 Resolution is@tie{}@var{n}, while @var{h} is the minimal horizontal
16437 motion, and @var{v} the minimal vertical motion possible with this
16438 device; all arguments are positive integers in basic units @samp{u} per
16439 inch.  This is the second command of the prologue.
16440
16441 @item xS @var{n}@angles{line break}
16442 The @samp{S} stands for @var{Slant}.
16443
16444 Set slant to@tie{}@var{n} (an integer in basic units @samp{u}).
16445
16446 @item xs@angles{line break}
16447 The @samp{s} stands for @var{stop}.
16448
16449 Terminates the processing of the current file; issued as the last
16450 command of any intermediate troff output.
16451
16452 @item xt@angles{line break}
16453 The @samp{t} stands for @var{trailer}.
16454
16455 Generate trailer information, if any.  In @var{gtroff}, this is actually
16456 just ignored.
16457
16458 @item xT @var{xxx}@angles{line break}
16459 The @samp{T} stands for @var{Typesetter}.
16460
16461 Set name of device to word @var{xxx}, a sequence of characters ended by
16462 the next white space character.  The possible device names coincide with
16463 those from the @code{groff} @option{-T} option.  This is the first
16464 command of the prologue.
16465
16466 @item xu @var{n}@angles{line break}
16467 The @samp{u} stands for @var{underline}.
16468
16469 Configure underlining of spaces.  If @var{n} is@tie{}1, start
16470 underlining of spaces; if @var{n} is@tie{}0, stop underlining of spaces.
16471 This is needed for the @code{cu} request in nroff mode and is ignored
16472 otherwise.  This command is a @code{gtroff} extension.
16473
16474 @item xX @var{anything}@angles{line break}
16475 The @samp{x} stands for @var{X-escape}.
16476
16477 Send string @var{anything} uninterpreted to the device.  If the line
16478 following this command starts with a @samp{+} character this line is
16479 interpreted as a continuation line in the following sense.  The @samp{+}
16480 is ignored, but a newline character is sent instead to the device, the
16481 rest of the line is sent uninterpreted.  The same applies to all
16482 following lines until the first character of a line is not a @samp{+}
16483 character.  This command is generated by the @code{gtroff} escape
16484 sequence @code{\X}.  The line-continuing feature is a @code{gtroff}
16485 extension.
16486 @end table
16487
16488 @node Obsolete Command,  , Device Control Commands, Command Reference
16489 @subsubsection Obsolete Command
16490 In @acronym{AT&T} @code{troff} output, the writing of a single glyph is
16491 mostly done by a very strange command that combines a horizontal move
16492 and a single character giving the glyph name.  It doesn't have a command
16493 code, but is represented by a 3-character argument consisting of exactly
16494 2@tie{}digits and a character.
16495
16496 @table @asis
16497 @item @var{dd}@var{g}
16498 Move right @var{dd} (exactly two decimal digits) basic units @samp{u},
16499 then print glyph@tie{}@var{g} (represented as a single character).
16500
16501 In @code{gtroff}, arbitrary syntactical space around and within this
16502 command is allowed to be added.  Only when a preceding command on the
16503 same line ends with an argument of variable length a separating space is
16504 obligatory.  In @acronym{AT&T} @code{troff}, large clusters of these and
16505 other commands are used, mostly without spaces; this made such output
16506 almost unreadable.
16507 @end table
16508
16509 For modern high-resolution devices, this command does not make sense
16510 because the width of the glyphs can become much larger than two decimal
16511 digits.  In @code{gtroff}, this is only used for the devices @code{X75},
16512 @code{X75-12}, @code{X100}, and @code{X100-12}.  For other devices, the
16513 commands @samp{t} and @samp{u} provide a better functionality.
16514
16515 @c ---------------------------------------------------------------------
16516
16517 @node Intermediate Output Examples, Output Language Compatibility, Command Reference, gtroff Output
16518 @subsection Intermediate Output Examples
16519
16520 This section presents the intermediate output generated from the same
16521 input for three different devices.  The input is the sentence @samp{hell
16522 world} fed into @code{gtroff} on the command line.
16523
16524 @table @asis
16525 @item High-resolution device @code{ps}
16526
16527 This is the standard output of @code{gtroff} if no @option{-T} option is
16528 given.
16529
16530 @example
16531 @group
16532 shell> echo "hell world" | groff -Z -T ps
16533
16534 x T ps
16535 x res 72000 1 1
16536 x init
16537 @end group
16538 p1
16539 x font 5 TR
16540 f5
16541 s10000
16542 V12000
16543 H72000
16544 thell
16545 wh2500
16546 tw
16547 H96620
16548 torld
16549 n12000 0
16550 @group
16551 x trailer
16552 V792000
16553 x stop
16554 @end group
16555 @end example
16556
16557 @noindent
16558 This output can be fed into @code{grops} to get its representation as a
16559 @sc{PostScript} file.
16560
16561 @item Low-resolution device @code{latin1}
16562
16563 This is similar to the high-resolution device except that the
16564 positioning is done at a minor scale.  Some comments (lines starting
16565 with @samp{#}) were added for clarification; they were not generated by
16566 the formatter.
16567
16568 @example
16569 @group
16570 shell> echo "hell world" | groff -Z -T latin1
16571
16572 # prologue
16573 x T latin1
16574 x res 240 24 40
16575 x init
16576 @end group
16577 # begin a new page
16578 p1
16579 # font setup
16580 x font 1 R
16581 f1
16582 s10
16583 # initial positioning on the page
16584 V40
16585 H0
16586 # write text `hell'
16587 thell
16588 # inform about space, and issue a horizontal jump
16589 wh24
16590 # write text `world'
16591 tworld
16592 # announce line break, but do nothing because ...
16593 n40 0
16594 @group
16595 # ... the end of the document has been reached
16596 x trailer
16597 V2640
16598 x stop
16599 @end group
16600 @end example
16601
16602 @noindent
16603 This output can be fed into @code{grotty} to get a formatted text
16604 document.
16605
16606 @item @acronym{AT&T} @code{troff} output
16607 Since a computer monitor has a very low resolution compared to modern
16608 printers the intermediate output for the X@tie{}Window devices can use
16609 the jump-and-write command with its 2-digit displacements.
16610
16611 @example
16612 @group
16613 shell> echo "hell world" | groff -Z -T X100
16614
16615 x T X100
16616 x res 100 1 1
16617 x init
16618 @end group
16619 p1
16620 x font 5 TR
16621 f5
16622 s10
16623 V16
16624 H100
16625 # write text with jump-and-write commands
16626 ch07e07l03lw06w11o07r05l03dh7
16627 n16 0
16628 @group
16629 x trailer
16630 V1100
16631 x stop
16632 @end group
16633 @end example
16634
16635 @noindent
16636 This output can be fed into @code{xditview} or @code{gxditview} for
16637 displaying in@tie{}X.
16638
16639 Due to the obsolete jump-and-write command, the text clusters in the
16640 @acronym{AT&T} @code{troff} output are almost unreadable.
16641 @end table
16642
16643 @c ---------------------------------------------------------------------
16644
16645 @node Output Language Compatibility,  , Intermediate Output Examples, gtroff Output
16646 @subsection Output Language Compatibility
16647
16648 The intermediate output language of @acronym{AT&T} @code{troff} was
16649 first documented in the Unix troff manual, with later additions
16650 documented in @cite{A Typesetter-independent TROFF}, written by Brian
16651 Kernighan.
16652
16653 The @code{gtroff} intermediate output format is compatible with this
16654 specification except for the following features.
16655
16656 @itemize @bullet
16657 @item
16658 The classical quasi device independence is not yet implemented.
16659
16660 @item
16661 The old hardware was very different from what we use today.  So the
16662 @code{groff} devices are also fundamentally different from the ones
16663 in @acronym{AT&T} @code{troff}.  For example, the @acronym{AT&T}
16664 @sc{PostScript} device is called @code{post} and has a resolution of
16665 only 720 units per inch, suitable for printers 20 years ago, while
16666 @code{groff}'s @code{ps} device has a resolution of 72000 units per
16667 inch.  Maybe, by implementing some rescaling mechanism similar to the
16668 classical quasi device independence, @code{groff} could emulate
16669 @acronym{AT&T}'s @code{post} device.
16670
16671 @item
16672 The B-spline command @samp{D~} is correctly handled by the intermediate
16673 output parser, but the drawing routines aren't implemented in some of
16674 the postprocessor programs.
16675
16676 @item
16677 The argument of the commands @samp{s} and @w{@samp{x H}} has the
16678 implicit unit scaled point @samp{z} in @code{gtroff}, while
16679 @acronym{AT&T} @code{troff} has point (@samp{p}).  This isn't an
16680 incompatibility but a compatible extension, for both units coincide for
16681 all devices without a @code{sizescale} parameter in the @file{DESC}
16682 file, including all postprocessors from @acronym{AT&T} and
16683 @code{groff}'s text devices.  The few @code{groff} devices with a
16684 @code{sizescale} parameter either do not exist for @acronym{AT&T}
16685 @code{troff}, have a different name, or seem to have a different
16686 resolution.  So conflicts are very unlikely.
16687
16688 @item
16689 The position changing after the commands @samp{Dp}, @samp{DP}, and
16690 @samp{Dt} is illogical, but as old versions of @code{gtroff} used this
16691 feature it is kept for compatibility reasons.
16692
16693 @ignore
16694 Temporarily, there existed some confusion on the positioning after the
16695 @samp{D} commands that are groff extensions.  This has been clarified by
16696 establishing the classical rule for all @code{groff} drawing commands:
16697
16698 @itemize
16699 @item
16700 The position after a graphic object has been drawn is at its end; for
16701 circles and ellipses, the `end' is at the right side.
16702
16703 @item
16704 From this, the positionings specified for the drawing commands above
16705 follow quite naturally.
16706 @end itemize
16707 @end ignore
16708
16709 @end itemize
16710
16711
16712 @c =====================================================================
16713
16714 @node Font Files,  , gtroff Output, File formats
16715 @section Font Files
16716 @cindex font files
16717 @cindex files, font
16718
16719 The @code{gtroff} font format is roughly a superset of the
16720 @code{ditroff} font format (as used in later versions of @acronym{AT&T}
16721 @code{troff} and its descendants).  Unlike the @code{ditroff} font
16722 format, there is no associated binary format; all files are text
16723 files.@footnote{Plan@tie{}9 @code{troff} has also abandoned the binary
16724 format.}  The font files for device @var{name} are stored in a directory
16725 @file{dev@var{name}}.  There are two types of file: a device description
16726 file called @file{DESC} and for each font@tie{}@var{f} a font file
16727 called@tie{}@file{@var{f}}.
16728
16729 @menu
16730 * DESC File Format::
16731 * Font File Format::
16732 @end menu
16733
16734 @c ---------------------------------------------------------------------
16735
16736 @node DESC File Format, Font File Format, Font Files, Font Files
16737 @subsection @file{DESC} File Format
16738 @cindex @file{DESC} file, format
16739 @cindex font description file, format
16740 @cindex format of font description file
16741 @pindex DESC@r{ file format}
16742
16743 The @file{DESC} file can contain the following types of line.  Except
16744 for the @code{charset} keyword, which must come last (if at all), the
16745 order of the lines is not important.  Later entries in the file,
16746 however, override previous values.
16747
16748 @table @code
16749 @item charset
16750 @kindex charset
16751 This line and everything following in the file are ignored.  It is
16752 allowed for the sake of backwards compatibility.
16753
16754 @item family @var{fam}
16755 @kindex family
16756 The default font family is @var{fam}.
16757
16758 @item fonts @var{n} @var{F1} @var{F2} @var{F3} @dots{} @var{Fn}
16759 @kindex fonts
16760 Fonts @var{F1} @dots{} @var{Fn} are mounted in the font positions
16761 @var{m}+1, @dots{}, @var{m}+@var{n} where @var{m} is the number of
16762 styles.  This command may extend over more than one line.  A font name
16763 of@tie{}0 means no font is mounted on the corresponding font position.
16764
16765 @item hor @var{n}
16766 @kindex hor
16767 @cindex horizontal resolution
16768 @cindex resolution, horizontal
16769 The horizontal resolution is @var{n}@tie{}machine units.  All horizontal
16770 quantities are rounded to be multiples of this value.
16771
16772 @item image_generator @var{string}
16773 @kindex image_generator
16774 @cindex PostScript, PNG image generation
16775 @cindex PNG image generation from PostScript
16776 Needed for @code{grohtml} only.  It specifies the program to generate
16777 PNG images from @sc{PostScript} input.  Under GNU/Linux this is
16778 usually @code{gs} but under other systems (notably cygwin) it might
16779 be set to another name.
16780
16781 @item paperlength @var{n}
16782 @kindex paperlength
16783 The physical vertical dimension of the output medium in machine units.
16784 This isn't used by @code{troff} itself but by output devices.
16785 Deprecated.  Use @code{papersize} instead.
16786
16787 @item papersize @var{string} @dots{}
16788 @kindex papersize
16789 Select a paper size.  Valid values for @var{string} are the ISO paper
16790 types @code{A0}--@code{A7}, @code{B0}--@code{B7}, @code{C0}--@code{C7},
16791 @code{D0}--@code{D7}, @code{DL}, and the US paper types @code{letter},
16792 @code{legal}, @code{tabloid}, @code{ledger}, @code{statement},
16793 @code{executive}, @code{com10}, and @code{monarch}.  Case is not
16794 significant for @var{string} if it holds predefined paper types.
16795 Alternatively, @var{string} can be a file name (e.g.@:
16796 @file{/etc/papersize}); if the file can be opened, @code{groff} reads
16797 the first line and tests for the above paper sizes.  Finally,
16798 @var{string} can be a custom paper size in the format
16799 @code{@var{length},@var{width}} (no spaces before and after the comma).
16800 Both @var{length} and @var{width} must have a unit appended; valid
16801 values are @samp{i} for inches, @samp{c} for centimeters, @samp{p} for
16802 points, and @samp{P} for picas.  Example: @code{12c,235p}.  An argument
16803 that starts with a digit is always treated as a custom paper format.
16804 @code{papersize} sets both the vertical and horizontal dimension of the
16805 output medium.
16806
16807 More than one argument can be specified; @code{groff} scans from left to
16808 right and uses the first valid paper specification.
16809
16810 @item paperwidth @var{n}
16811 @kindex paperwidth
16812 The physical horizontal dimension of the output medium in machine units.
16813 This isn't used by @code{troff} itself but by output devices.
16814 Deprecated.  Use @code{papersize} instead.
16815
16816 @item pass_filenames
16817 @kindex pass_filenames
16818 Tell @code{gtroff} to emit the name of the source file currently being
16819 processed.  This is achieved by the intermediate output command
16820 @samp{F}.  Currently, this is only used by the @code{grohtml} output
16821 device.
16822
16823 @item postpro @var{program}
16824 @kindex postpro
16825 Call @var{program} as a postprocessor.  For example, the line
16826
16827 @Example
16828 postpro grodvi
16829 @endExample
16830
16831 @noindent
16832 in the file @file{devdvi/DESC} makes @code{groff} call @code{grodvi} if
16833 option @option{-Tdvi} is given (and @option{-Z} isn't used).
16834
16835 @item prepro @var{program}
16836 @kindex prepro
16837 Call @var{program} as a preprocessor.  Currently, this keyword is used
16838 by @code{groff} with option @option{-Thtml} or @option{-Txhtml} only.
16839
16840 @item print @var{program}
16841 @kindex print
16842 Use @var{program} as a spooler program for printing.  If omitted, the
16843 @option{-l} and @option{-L} options of @code{groff} are ignored.
16844
16845 @item res @var{n}
16846 @kindex res
16847 @cindex device resolution
16848 @cindex resolution, device
16849 There are @var{n}@tie{}machine units per inch.
16850
16851 @item sizes @var{s1} @var{s2} @dots{} @var{sn} 0
16852 @kindex sizes
16853 This means that the device has fonts at @var{s1}, @var{s2}, @dots{}
16854 @var{sn} scaled points.  The list of sizes must be terminated by@tie{}0
16855 (this is digit zero).  Each @var{si} can also be a range of sizes
16856 @var{m}--@var{n}.  The list can extend over more than one line.
16857
16858 @item sizescale @var{n}
16859 @kindex sizescale
16860 The scale factor for point sizes.  By default this has a value
16861 of@tie{}1.  One scaled point is equal to one point/@var{n}.  The
16862 arguments to the @code{unitwidth} and @code{sizes} commands are given in
16863 scaled points.  @xref{Fractional Type Sizes}, for more information.
16864
16865 @item styles @var{S1} @var{S2} @dots{} @var{Sm}
16866 @kindex styles
16867 The first @var{m}@tie{}font positions are associated with styles
16868 @var{S1} @dots{} @var{Sm}.
16869
16870 @item tcommand
16871 @kindex tcommand
16872 This means that the postprocessor can handle the @samp{t} and @samp{u}
16873 intermediate output commands.
16874
16875 @item unicode
16876 @kindex unicode
16877 Indicate that the output device supports the complete Unicode
16878 repertoire.  Useful only for devices that produce @emph{character
16879 entities} instead of glyphs.
16880
16881 If @code{unicode} is present, no @code{charset} section is required in
16882 the font description files since the Unicode handling built into
16883 @code{groff} is used.  However, if there are entries in a @code{charset}
16884 section, they either override the default mappings for those particular
16885 characters or add new mappings (normally for composite characters).
16886
16887 This is used for @option{-Tutf8}, @option{-Thtml}, and @option{-Txhtml}.
16888
16889 @item unitwidth @var{n}
16890 @kindex unitwidth
16891 Quantities in the font files are given in machine units for fonts whose
16892 point size is @var{n}@tie{}scaled points.
16893
16894 @item unscaled_charwidths
16895 @kindex unscaled_charwidths
16896 Make the font handling module always return unscaled character widths.
16897 Needed for the @code{grohtml} device.
16898
16899 @item use_charnames_in_special
16900 @kindex use_charnames_in_special
16901 This command indicates that @code{gtroff} should encode special
16902 characters inside special commands.  Currently, this is only used by the
16903 @code{grohtml} output device.  @xref{Postprocessor Access}.
16904
16905 @item vert @var{n}
16906 @kindex vert
16907 @cindex vertical resolution
16908 @cindex resolution, vertical
16909 The vertical resolution is @var{n}@tie{}machine units.  All vertical
16910 quantities are rounded to be multiples of this value.
16911 @end table
16912
16913 The @code{res}, @code{unitwidth}, @code{fonts}, and @code{sizes} lines
16914 are mandatory.  Other commands are ignored by @code{gtroff} but may be
16915 used by postprocessors to store arbitrary information about the device
16916 in the @file{DESC} file.
16917
16918 @kindex spare1
16919 @kindex spare2
16920 @kindex biggestfont
16921 Here a list of obsolete keywords that are recognized by @code{groff}
16922 but completely ignored: @code{spare1}, @code{spare2},
16923 @code{biggestfont}.
16924
16925 @c ---------------------------------------------------------------------
16926
16927 @node Font File Format,  , DESC File Format, Font Files
16928 @subsection Font File Format
16929 @cindex font file, format
16930 @cindex font description file, format
16931 @cindex format of font files
16932 @cindex format of font description files
16933
16934 A @dfn{font file}, also (and probably better) called a @dfn{font
16935 description file}, has two sections.  The first section is a sequence of
16936 lines each containing a sequence of blank delimited words; the first
16937 word in the line is a key, and subsequent words give a value for that
16938 key.
16939
16940 @table @code
16941 @item name @var{f}
16942 @kindex name
16943 The name of the font is@tie{}@var{f}.
16944
16945 @item spacewidth @var{n}
16946 @kindex spacewidth
16947 The normal width of a space is@tie{}@var{n}.
16948
16949 @item slant @var{n}
16950 @kindex slant
16951 The glyphs of the font have a slant of @var{n}@tie{}degrees.  (Positive
16952 means forward.)
16953
16954 @item ligatures @var{lig1} @var{lig2} @dots{} @var{lign} [0]
16955 @kindex ligatures
16956 Glyphs @var{lig1}, @var{lig2}, @dots{}, @var{lign} are ligatures;
16957 possible ligatures are @samp{ff}, @samp{fi}, @samp{fl}, @samp{ffi} and
16958 @samp{ffl}.  For backwards compatibility, the list of ligatures may be
16959 terminated with a@tie{}0.  The list of ligatures may not extend over
16960 more than one line.
16961
16962 @item special
16963 @cindex special fonts
16964 @kindex special
16965 The font is @dfn{special}; this means that when a glyph is requested
16966 that is not present in the current font, it is searched for in any
16967 special fonts that are mounted.
16968 @end table
16969
16970 Other commands are ignored by @code{gtroff} but may be used by
16971 postprocessors to store arbitrary information about the font in the font
16972 file.
16973
16974 @cindex comments in font files
16975 @cindex font files, comments
16976 @kindex #
16977 The first section can contain comments, which start with the @samp{#}
16978 character and extend to the end of a line.
16979
16980 The second section contains one or two subsections.  It must contain a
16981 @code{charset} subsection and it may also contain a @code{kernpairs}
16982 subsection.  These subsections can appear in any order.  Each subsection
16983 starts with a word on a line by itself.
16984
16985 @kindex charset
16986 The word @code{charset} starts the character set
16987 subsection.@footnote{This keyword is misnamed since it starts a list of
16988 ordered glyphs, not characters.}  The @code{charset} line is followed by
16989 a sequence of lines.  Each line gives information for one glyph.  A line
16990 comprises a number of fields separated by blanks or tabs.  The format is
16991
16992 @quotation
16993 @var{name} @var{metrics} @var{type} @var{code} [@var{entity-name}]
16994 [@code{--} @var{comment}]
16995 @end quotation
16996
16997 @cindex 8-bit input
16998 @cindex input, 8-bit
16999 @cindex accessing unnamed glyphs with @code{\N}
17000 @cindex unnamed glyphs, accessing with @code{\N}
17001 @cindex characters, unnamed, accessing with @code{\N}
17002 @cindex glyphs, unnamed, accessing with @code{\N}
17003 @kindex ---
17004 @noindent
17005 @var{name} identifies the glyph name@footnote{The distinction between
17006 input, characters, and output, glyphs, is not clearly separated in the
17007 terminology of @code{groff}; for example, the @code{char} request should
17008 be called @code{glyph} since it defines an output entity.}: If
17009 @var{name} is a single character@tie{}@var{c} then it corresponds to the
17010 @code{gtroff} input character@tie{}@var{c}; if it is of the form
17011 @samp{\@var{c}} where @var{c} is a single character, then it corresponds
17012 to the special character @code{\[@var{c}]}; otherwise it corresponds to
17013 the special character @samp{\[@var{name}]}.  If it is exactly two
17014 characters @var{xx} it can be entered as @samp{\(@var{xx}}.  Note that
17015 single-letter special characters can't be accessed as @samp{\@var{c}};
17016 the only exception is @samp{\-}, which is identical to @code{\[-]}.
17017
17018 @code{gtroff} supports 8-bit input characters; however some utilities
17019 have difficulties with eight-bit characters.  For this reason, there is
17020 a convention that the entity name @samp{char@var{n}} is equivalent to
17021 the single input character whose code is@tie{}@var{n}.  For example,
17022 @samp{char163} would be equivalent to the character with code@tie{}163,
17023 which is the pounds sterling sign in the ISO@tie{}@w{Latin-1} character
17024 set.  You shouldn't use @samp{char@var{n}} entities in font description
17025 files since they are related to input, not output.  Otherwise, you get
17026 hard-coded connections between input and output encoding, which prevents
17027 use of different (input) character sets.
17028
17029 The name @samp{---} is special and indicates that the glyph is unnamed;
17030 such glyphs can only be used by means of the @code{\N} escape sequence
17031 in @code{gtroff}.
17032
17033 The @var{type} field gives the glyph type:
17034
17035 @table @code
17036 @item 1
17037 the glyph has a descender, for example, @samp{p};
17038
17039 @item 2
17040 the glyph has an ascender, for example, @samp{b};
17041
17042 @item 3
17043 the glyph has both an ascender and a descender, for example, @samp{(}.
17044 @end table
17045
17046 The @var{code} field gives the code that the postprocessor uses to
17047 print the glyph.  The glyph can also be input to @code{gtroff} using
17048 this code by means of the @code{\N} escape sequence.  @var{code} can be
17049 any integer.  If it starts with @samp{0} it is interpreted as octal; if
17050 it starts with @samp{0x} or @samp{0X} it is interpreted as hexadecimal.
17051 Note, however, that the @code{\N} escape sequence only accepts a decimal
17052 integer.
17053
17054 The @var{entity-name} field gives an @acronym{ASCII} string identifying
17055 the glyph that the postprocessor uses to print the @code{gtroff} glyph
17056 @var{name}.  This field is optional and has been introduced so that the
17057 @code{grohtml} device driver can encode its character set.  For example,
17058 the glyph @samp{\[Po]} is represented as @samp{&pound;} in
17059 @acronym{HTML} 4.0.
17060
17061 Anything on the line after the @var{entity-name} field resp.@: after
17062 @samp{--} is ignored.
17063
17064 The @var{metrics} field has the form:
17065
17066 @display
17067 @group
17068 @var{width}[@code{,}@var{height}[@code{,}@var{depth}[@code{,}@var{italic-correction}
17069   [@code{,}@var{left-italic-correction}[@code{,}@var{subscript-correction}]]]]]
17070 @end group
17071 @end display
17072
17073 @noindent
17074 There must not be any spaces between these subfields (it has been split
17075 here into two lines for better legibility only).  Missing subfields are
17076 assumed to be@tie{}0.  The subfields are all decimal integers.  Since
17077 there is no associated binary format, these values are not required to
17078 fit into a variable of type @samp{char} as they are in @code{ditroff}.
17079 The @var{width} subfield gives the width of the glyph.  The @var{height}
17080 subfield gives the height of the glyph (upwards is positive); if a glyph
17081 does not extend above the baseline, it should be given a zero height,
17082 rather than a negative height.  The @var{depth} subfield gives the depth
17083 of the glyph, that is, the distance from the baseline to the lowest
17084 point below the baseline to which the glyph extends (downwards is
17085 positive); if a glyph does not extend below the baseline, it should be
17086 given a zero depth, rather than a negative depth.  The
17087 @var{italic-correction} subfield gives the amount of space that should
17088 be added after the glyph when it is immediately to be followed by a
17089 glyph from a roman font.  The @var{left-italic-correction} subfield
17090 gives the amount of space that should be added before the glyph when it
17091 is immediately to be preceded by a glyph from a roman font.  The
17092 @var{subscript-correction} gives the amount of space that should be
17093 added after a glyph before adding a subscript.  This should be less than
17094 the italic correction.
17095
17096 A line in the @code{charset} section can also have the format
17097
17098 @Example
17099 @var{name} "
17100 @endExample
17101
17102 @noindent
17103 This indicates that @var{name} is just another name for the glyph
17104 mentioned in the preceding line.
17105
17106 @kindex kernpairs
17107 The word @code{kernpairs} starts the kernpairs section.  This contains a
17108 sequence of lines of the form:
17109
17110 @Example
17111 @var{c1} @var{c2} @var{n}
17112 @endExample
17113
17114 @noindent
17115 This means that when glyph @var{c1} appears next to glyph @var{c2} the
17116 space between them should be increased by@tie{}@var{n}.  Most entries in
17117 the kernpairs section have a negative value for@tie{}@var{n}.
17118
17119
17120
17121 @c =====================================================================
17122 @c =====================================================================
17123
17124 @node Installation, Copying This Manual, File formats, Top
17125 @chapter Installation
17126 @cindex installation
17127
17128 @c XXX
17129
17130
17131
17132 @c =====================================================================
17133 @c =====================================================================
17134
17135 @node Copying This Manual, Request Index, Installation, Top
17136 @appendix Copying This Manual
17137
17138 @include fdl.texi
17139
17140
17141
17142 @c =====================================================================
17143 @c =====================================================================
17144
17145 @node Request Index, Escape Index, Copying This Manual, Top
17146 @appendix Request Index
17147
17148 Requests appear without the leading control character (normally either
17149 @samp{.} or @samp{'}).
17150
17151 @printindex rq
17152
17153
17154
17155 @c =====================================================================
17156 @c =====================================================================
17157
17158 @node Escape Index, Operator Index, Request Index, Top
17159 @appendix Escape Index
17160
17161 Any escape sequence @code{\@var{X}} with @var{X} not in the list below
17162 emits a warning, printing glyph @var{X}.
17163
17164 @printindex es
17165
17166
17167
17168 @c =====================================================================
17169 @c =====================================================================
17170
17171 @node Operator Index, Register Index, Escape Index, Top
17172 @appendix Operator Index
17173
17174 @printindex op
17175
17176
17177
17178 @c =====================================================================
17179 @c =====================================================================
17180
17181 @node Register Index, Macro Index, Operator Index, Top
17182 @appendix Register Index
17183
17184 The macro package or program a specific register belongs to is appended in
17185 brackets.
17186
17187 A register name@tie{}@code{x} consisting of exactly one character can be
17188 accessed as @samp{\nx}.  A register name @code{xx} consisting of exactly
17189 two characters can be accessed as @samp{\n(xx}.  Register names
17190 @code{xxx} of any length can be accessed as @samp{\n[xxx]}.
17191
17192 @printindex vr
17193
17194
17195
17196 @c =====================================================================
17197 @c =====================================================================
17198
17199 @node Macro Index, String Index, Register Index, Top
17200 @appendix Macro Index
17201
17202 The macro package a specific macro belongs to is appended in brackets.
17203 They appear without the leading control character (normally @samp{.}).
17204
17205 @printindex ma
17206
17207
17208
17209 @c =====================================================================
17210 @c =====================================================================
17211
17212 @node String Index, Glyph Name Index, Macro Index, Top
17213 @appendix String Index
17214
17215 The macro package or program a specific string belongs to is appended in
17216 brackets.
17217
17218 A string name@tie{}@code{x} consisting of exactly one character can be
17219 accessed as @samp{\*x}.  A string name @code{xx} consisting of exactly
17220 two characters can be accessed as @samp{\*(xx}.  String names @code{xxx}
17221 of any length can be accessed as @samp{\*[xxx]}.
17222
17223
17224 @printindex st
17225
17226
17227
17228 @c =====================================================================
17229 @c =====================================================================
17230
17231 @node Glyph Name Index, Font File Keyword Index, String Index, Top
17232 @appendix Glyph Name Index
17233
17234 A glyph name @code{xx} consisting of exactly two characters can be
17235 accessed as @samp{\(xx}.  Glyph names @code{xxx} of any length can be
17236 accessed as @samp{\[xxx]}.
17237
17238 @c XXX
17239
17240
17241
17242 @c =====================================================================
17243 @c =====================================================================
17244
17245 @node Font File Keyword Index, Program and File Index, Glyph Name Index, Top
17246 @appendix Font File Keyword Index
17247
17248 @printindex ky
17249
17250
17251
17252 @c =====================================================================
17253 @c =====================================================================
17254
17255 @node Program and File Index, Concept Index, Font File Keyword Index, Top
17256 @appendix Program and File Index
17257
17258 @printindex pg
17259
17260
17261
17262 @c =====================================================================
17263 @c =====================================================================
17264
17265 @node Concept Index,  , Program and File Index, Top
17266 @appendix Concept Index
17267
17268 @printindex cp
17269
17270
17271 @bye
17272
17273 @c Local Variables:
17274 @c mode: texinfo
17275 @c coding: latin-1
17276 @c fill-column: 72
17277 @c End:
17278 @c vim: set textwidth=72: