066b52748fd44cd14b2b2dcf4d8811d4c93c7ae9
[platform/upstream/groff.git] / doc / groff.texinfo
1 \input texinfo
2
3 @c
4 @c Please convert this manual with `texi2dvi -e groff.texinfo' due to
5 @c problems in texinfo regarding expansion of user-defined macros.
6 @c
7 @c You need texinfo 4.8 or newer to format this document!
8 @c
9
10 @c %**start of header (This is for running Texinfo on a region.)
11 @setfilename groff.info
12 @settitle The GNU Troff Manual
13 @setchapternewpage odd
14 @footnotestyle separate
15 @c %**end of header (This is for running Texinfo on a region.)
16
17 @documentlanguage en
18 @documentencoding ISO-8859-1
19
20
21 @smallbook
22
23 @finalout
24
25
26 @copying
27 This manual documents GNU @code{troff} version 1.22.3.
28
29 Copyright @copyright{} 1994-2014 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.3
548 @subtitle Autumn 2014
549 @author by Trent A.@tie{}Fisher
550 @author and Werner Lemberg (@email{bug-groff@@gnu.org})
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 @acronym{UNIX}
603 community.
604
605 @menu
606 * What Is groff?::
607 * History::
608 * groff Capabilities::
609 * Macro Package Intro::
610 * Preprocessor Intro::
611 * Output device intro::
612 * Credits::
613 @end menu
614
615
616 @c =====================================================================
617
618 @node What Is groff?, History, Introduction, Introduction
619 @section What Is @code{groff}?
620 @cindex what is @code{groff}?
621 @cindex @code{groff} -- what is it?
622
623 @code{groff} belongs to an older generation of document preparation
624 systems, which operate more like compilers than the more recent
625 interactive @acronym{WYSIWYG}@footnote{What You See Is What You Get}
626 systems.  @code{groff} and its contemporary counterpart, @TeX{}, both
627 work using a @dfn{batch} paradigm: The input (or @dfn{source}) files are
628 normal text files with embedded formatting commands.  These files can
629 then be processed by @code{groff} to produce a typeset document on a
630 variety of devices.
631
632 @code{groff} should not be confused with a @dfn{word processor}, an
633 integrated system of editor and text formatter.  Also, many word
634 processors follow the @acronym{WYSIWYG} paradigm discussed earlier.
635
636 Although @acronym{WYSIWYG} systems may be easier to use, they have a
637 number of disadvantages compared to @code{troff}:
638
639 @itemize @bullet
640 @item
641 They must be used on a graphics display to work on a document.
642
643 @item
644 Most of the @acronym{WYSIWYG} systems are either non-free or are not
645 very portable.
646
647 @item
648 @code{troff} is firmly entrenched in all @acronym{UNIX} systems.
649
650 @item
651 It is difficult to have a wide range of capabilities within the confines
652 of a GUI/window system.
653
654 @item
655 It is more difficult to make global changes to a document.
656 @end itemize
657
658 @quotation
659 ``GUIs normally make it simple to accomplish simple actions and
660 impossible to accomplish complex actions.''  --Doug Gwyn (22/Jun/91 in
661 @code{comp.unix.wizards})
662 @end quotation
663
664
665 @c =====================================================================
666
667 @node History, groff Capabilities, What Is groff?, Introduction
668 @section History
669 @cindex history
670
671 @cindex @code{RUNOFF}, the program
672 @cindex @code{rf}, the program
673 @code{troff} can trace its origins back to a formatting program called
674 @code{RUNOFF}, written by Jerry Saltzer, which ran on the @acronym{CTSS}
675 (@emph{Compatible Time Sharing System}, a project of MIT, the
676 Massachusetts Institute of Technology) in the
677 mid-sixties.@footnote{Jerome H.@: Saltzer, a grad student then, later a
678 Professor of Electrical Engineering, now retired.  Saltzer's PhD thesis
679 was the first application for @code{RUNOFF} and is available from the
680 MIT Libraries.}  The name came from the use of the phrase ``run off a
681 document'', meaning to print it out.
682 @c
683 @c Tom Van Vleck <thvv@multicians.org> writes about the following:
684 @c
685 @c I am not sure about this.. I think the BCPL runoff was the port to
686 @c the 635 architecture, and that the order of events is
687 @c 1. CTSS runoff
688 @c 2. BCPL runoff on Multics
689 @c 3. BCPL runoff on 635
690 @c 4. rf on PDP-7
691 @c
692 Bob Morris ported it to the 635 architecture and called the program
693 @code{roff} (an abbreviation of @code{runoff}).  It was rewritten as
694 @code{rf} for the @w{PDP-7} (before having @acronym{UNIX}), and at the
695 same time (1969), Doug McIllroy rewrote an extended and simplified
696 version of @code{roff} in the @acronym{BCPL} programming language.
697
698 @cindex @code{roff}, the program
699 In 1971, the UNIX developers wanted to get a @w{PDP-11}, and to justify
700 the cost, proposed the development of a document formatting system for
701 the @acronym{AT&T} patents division.  This first formatting program was
702 a reimplementation of McIllroy's @code{roff}, written by J.@tie{}F.@:
703 Ossanna.
704
705 @cindex @code{nroff}, the program
706 When they needed a more flexible language, a new version of @code{roff}
707 called @code{nroff} (``Newer @code{roff}'') was written.  It had a much
708 more complicated syntax, but provided the basis for all future versions.
709 When they got a Graphic Systems CAT Phototypesetter, Ossanna wrote a
710 version of @code{nroff} that would drive it.  It was dubbed
711 @code{troff}, for ``typesetter @code{roff}'', although many people have
712 speculated that it actually means ``Times @code{roff}'' because of the
713 use of the Times font family in @code{troff} by default.  As such, the
714 name @code{troff} is pronounced `@w{t-roff}' rather than `trough'.
715
716 With @code{troff} came @code{nroff} (they were actually the same program
717 except for some @samp{#ifdef}s), which was for producing output for line
718 printers and character terminals.  It understood everything @code{troff}
719 did, and ignored the commands that were not applicable (e.g.@: font
720 changes).
721
722 Since there are several things that cannot be done easily in
723 @code{troff}, work on several preprocessors began.  These programs would
724 transform certain parts of a document into @code{troff}, which made a
725 very natural use of pipes in @acronym{UNIX}.
726
727 The @code{eqn} preprocessor allowed mathematical formulæ to be specified
728 in a much simpler and more intuitive manner.  @code{tbl} is a
729 preprocessor for formatting tables.  The @code{refer} preprocessor (and
730 the similar program, @code{bib}) processes citations in a document
731 according to a bibliographic database.
732
733 Unfortunately, Ossanna's @code{troff} was written in @w{PDP-11} assembly
734 language and produced output specifically for the CAT phototypesetter.
735 He rewrote it in C, although it was now 7000@tie{}lines of uncommented
736 code and still dependent on the CAT@.  As the CAT became less common, and
737 was no longer supported by the manufacturer, the need to make it support
738 other devices became a priority.  However, before this could be done,
739 Ossanna died by a severe heart attack in a hospital while recovering
740 from a previous one.
741
742 @pindex ditroff
743 @cindex @code{ditroff}, the program
744 So, Brian Kernighan took on the task of rewriting @code{troff}.  The
745 newly rewritten version produced device independent code that was very
746 easy for postprocessors to read and translate to the appropriate printer
747 codes.  Also, this new version of @code{troff} (called @code{ditroff}
748 for ``device independent @code{troff}'') had several extensions, which
749 included drawing functions.
750
751 Due to the additional abilities of the new version of @code{troff},
752 several new preprocessors appeared.  The @code{pic} preprocessor
753 provides a wide range of drawing functions.  Likewise the @code{ideal}
754 preprocessor did the same, although via a much different paradigm.  The
755 @code{grap} preprocessor took specifications for graphs, but, unlike
756 other preprocessors, produced @code{pic} code.
757
758 James Clark began work on a GNU implementation of @code{ditroff} in
759 early@tie{}1989.  The first version, @code{groff}@tie{}0.3.1, was
760 released June@tie{}1990.  @code{groff} included:
761
762 @itemize @bullet
763 @item
764 A replacement for @code{ditroff} with many extensions.
765
766 @item
767 The @code{soelim}, @code{pic}, @code{tbl}, and @code{eqn} preprocessors.
768
769 @item
770 Postprocessors for character devices, @sc{PostScript}, @TeX{} DVI, and
771 X@tie{}Windows.  GNU @code{troff} also eliminated the need for a
772 separate @code{nroff} program with a postprocessor that would produce
773 @acronym{ASCII} output.
774
775 @item
776 A version of the @file{me} macros and an implementation of the
777 @file{man} macros.
778 @end itemize
779
780 Also, a front-end was included that could construct the, sometimes
781 painfully long, pipelines required for all the post- and preprocessors.
782
783 Development of GNU @code{troff} progressed rapidly, and saw the
784 additions of a replacement for @code{refer}, an implementation of the
785 @file{ms} and @file{mm} macros, and a program to deduce how to format a
786 document (@code{grog}).
787
788 It was declared a stable (i.e.@: non-beta) package with the release of
789 version@tie{}1.04 around November@tie{}1991.
790
791 Beginning in@tie{}1999, @code{groff} has new maintainers (the package
792 was an orphan for a few years).  As a result, new features and programs
793 like @code{grn}, a preprocessor for gremlin images, and an output device
794 to produce @acronym{HTML} and @acronym{XHTML} have been added.
795
796
797 @c =====================================================================
798
799 @node groff Capabilities, Macro Package Intro, History, Introduction
800 @section @code{groff} Capabilities
801 @cindex @code{groff} capabilities
802 @cindex capabilities of @code{groff}
803
804 So what exactly is @code{groff} capable of doing?  @code{groff} provides
805 a wide range of low-level text formatting operations.  Using these, it
806 is possible to perform a wide range of formatting tasks, such as
807 footnotes, table of contents, multiple columns, etc.  Here's a list of
808 the most important operations supported by @code{groff}:
809
810 @itemize @bullet
811 @item
812 text filling, adjusting, and centering
813
814 @item
815 hyphenation
816
817 @item
818 page control
819
820 @item
821 font and glyph size control
822
823 @item
824 vertical spacing (e.g.@: double-spacing)
825
826 @item
827 line length and indenting
828
829 @item
830 macros, strings, diversions, and traps
831
832 @item
833 number registers
834
835 @item
836 tabs, leaders, and fields
837
838 @item
839 input and output conventions and character translation
840
841 @item
842 overstrike, bracket, line drawing, and zero-width functions
843
844 @item
845 local horizontal and vertical motions and the width function
846
847 @item
848 three-part titles
849
850 @item
851 output line numbering
852
853 @item
854 conditional acceptance of input
855
856 @item
857 environment switching
858
859 @item
860 insertions from the standard input
861
862 @item
863 input/output file switching
864
865 @item
866 output and error messages
867 @end itemize
868
869
870 @c =====================================================================
871
872 @node Macro Package Intro, Preprocessor Intro, groff Capabilities, Introduction
873 @section Macro Packages
874 @cindex macro packages
875
876 Since @code{groff} provides such low-level facilities, it can be quite
877 difficult to use by itself.  However, @code{groff} provides a
878 @dfn{macro} facility to specify how certain routine operations
879 (e.g.@tie{}starting paragraphs, printing headers and footers, etc.)@:
880 should be done.  These macros can be collected together into a
881 @dfn{macro package}.  There are a number of macro packages available;
882 the most common (and the ones described in this manual) are @file{man},
883 @file{mdoc}, @file{me}, @file{ms}, and @file{mm}.
884
885
886 @c =====================================================================
887
888 @node Preprocessor Intro, Output device intro, Macro Package Intro, Introduction
889 @section Preprocessors
890 @cindex preprocessors
891
892 Although @code{groff} provides most functions needed to format a
893 document, some operations would be unwieldy (e.g.@: to draw pictures).
894 Therefore, programs called @dfn{preprocessors} were written that
895 understand their own language and produce the necessary @code{groff}
896 operations.  These preprocessors are able to differentiate their own
897 input from the rest of the document via markers.
898
899 To use a preprocessor, @acronym{UNIX} pipes are used to feed the output
900 from the preprocessor into @code{groff}.  Any number of preprocessors
901 may be used on a given document; in this case, the preprocessors are
902 linked together into one pipeline.  However, with @code{groff}, the user
903 does not need to construct the pipe, but only tell @code{groff} what
904 preprocessors to use.
905
906 @code{groff} currently has preprocessors for producing tables
907 (@code{tbl}), typesetting equations (@code{eqn}), drawing pictures
908 (@code{pic} and @code{grn}), processing bibliographies
909 (@code{refer}), and drawing chemical structures (@code{chem}).  An
910 associated program that is useful when dealing with preprocessors is
911 @code{soelim}.
912
913 A free implementation of @code{grap}, a preprocessor for drawing graphs,
914 can be obtained as an extra package; @code{groff} can use @code{grap}
915 also.
916
917 Unique to @code{groff} is the @code{preconv} preprocessor that enables
918 @code{groff} to handle documents in various input encodings.
919
920 There are other preprocessors in existence, but, unfortunately, no free
921 implementations are available.  Among them is a preprocessor for drawing
922 mathematical pictures (@code{ideal}).
923
924
925 @c =====================================================================
926
927 @node Output device intro, Credits, Preprocessor Intro, Introduction
928 @section Output Devices
929 @cindex postprocessors
930 @cindex output devices
931 @cindex devices for output
932
933 @code{groff} actually produces device independent code that may be fed
934 into a postprocessor to produce output for a particular device.
935 Currently, @code{groff} has postprocessors for @sc{PostScript} devices,
936 character terminals, X@tie{}Windows (for previewing), @TeX{} DVI format,
937 HP LaserJet@tie{}4 and Canon LBP printers (which use @acronym{CAPSL}),
938 @acronym{HTML}, @acronym{XHTML}, and PDF.
939
940
941 @c =====================================================================
942
943 @node Credits,  , Output device intro, Introduction
944 @section Credits
945 @cindex credits
946
947 Large portions of this manual were taken from existing documents, most
948 notably, the manual pages for the @code{groff} package by James Clark,
949 and Eric Allman's papers on the @file{me} macro package.
950
951 The section on the @file{man} macro package is partly based on
952 Susan@tie{}G.@: Kleinmann's @file{groff_man} manual page written for the
953 Debian GNU/Linux system.
954
955 Larry Kollar contributed the section in the @file{ms} macro package.
956
957
958
959 @c =====================================================================
960 @c =====================================================================
961
962 @node Invoking groff, Tutorial for Macro Users, Introduction, Top
963 @chapter Invoking @code{groff}
964 @cindex invoking @code{groff}
965 @cindex @code{groff} invocation
966
967 This section focuses on how to invoke the @code{groff} front end.  This
968 front end takes care of the details of constructing the pipeline among
969 the preprocessors, @code{gtroff} and the postprocessor.
970
971 It has become a tradition that GNU programs get the prefix @samp{g} to
972 distinguish it from its original counterparts provided by the host (see
973 @ref{Environment}, for more details).  Thus, for example, @code{geqn} is
974 GNU @code{eqn}.  On operating systems like GNU/Linux or the Hurd, which
975 don't contain proprietary versions of @code{troff}, and on
976 MS-DOS/MS-Windows, where @code{troff} and associated programs are not
977 available at all, this prefix is omitted since GNU @code{troff} is the
978 only used incarnation of @code{troff}.  Exception: @samp{groff} is never
979 replaced by @samp{roff}.
980
981 In this document, we consequently say @samp{gtroff} when talking about
982 the GNU @code{troff} program.  All other implementations of @code{troff}
983 are called @acronym{AT&T} @code{troff}, which is the common origin of all
984 @code{troff} derivates (with more or less compatible changes).
985 Similarly, we say @samp{gpic}, @samp{geqn}, etc.
986
987 @menu
988 * Groff Options::
989 * Environment::
990 * Macro Directories::
991 * Font Directories::
992 * Paper Size::
993 * Invocation Examples::
994 @end menu
995
996
997 @c =====================================================================
998
999 @node Groff Options, Environment, Invoking groff, Invoking groff
1000 @section Options
1001 @cindex options
1002
1003 @pindex groff
1004 @pindex gtroff
1005 @pindex gpic
1006 @pindex geqn
1007 @pindex ggrn
1008 @pindex grap
1009 @pindex gtbl
1010 @pindex gchem
1011 @pindex grefer
1012 @pindex gsoelim
1013 @pindex preconv
1014 @code{groff} normally runs the @code{gtroff} program and a
1015 postprocessor appropriate for the selected device.  The default device
1016 is @samp{ps} (but it can be changed when @code{groff} is configured and
1017 built).  It can optionally preprocess with any of @code{gpic},
1018 @code{geqn}, @code{gtbl}, @code{ggrn}, @code{grap}, @code{gchem},
1019 @code{grefer}, @code{gsoelim}, or @code{preconv}.
1020
1021 This section only documents options to the @code{groff} front end.  Many
1022 of the arguments to @code{groff} are passed on to @code{gtroff},
1023 therefore those are also included.  Arguments to pre- or postprocessors
1024 can be found in @ref{Invoking gpic}, @ref{Invoking geqn}, @ref{Invoking
1025 gtbl}, @ref{Invoking ggrn}, @ref{Invoking grefer}, @ref{Invoking gchem},
1026 @ref{Invoking gsoelim}, @ref{Invoking preconv}, @ref{Invoking grotty},
1027 @ref{Invoking grops}, @ref{Invoking gropdf}, @ref{Invoking grohtml},
1028 @ref{Invoking grodvi}, @ref{Invoking grolj4}, @ref{Invoking grolbp}, and
1029 @ref{Invoking gxditview}.
1030
1031 The command line format for @code{groff} is:
1032
1033 @Example
1034 groff [ -abceghijklpstvzCEGNRSUVXZ ] [ -d@var{cs} ] [ -D@var{arg} ]
1035       [ -f@var{fam} ] [ -F@var{dir} ] [ -I@var{dir} ] [ -K@var{arg} ]
1036       [ -L@var{arg} ] [ -m@var{name} ] [ -M@var{dir} ] [ -n@var{num} ]
1037       [ -o@var{list} ] [ -P@var{arg} ] [ -r@var{cn} ] [ -T@var{dev} ]
1038       [ -w@var{name} ] [ -W@var{name} ] [ @var{files}@dots{} ]
1039 @endExample
1040
1041 The command line format for @code{gtroff} is as follows.
1042
1043 @Example
1044 gtroff [ -abcivzCERU ] [ -d@var{cs} ] [ -f@var{fam} ] [ -F@var{dir} ]
1045        [ -m@var{name} ] [ -M@var{dir} ] [ -n@var{num} ] [ -o@var{list} ]
1046        [ -r@var{cn} ] [ -T@var{name} ] [ -w@var{name} ] [ -W@var{name} ]
1047        [ @var{files}@dots{} ]
1048 @endExample
1049
1050 @noindent
1051 Obviously, many of the options to @code{groff} are actually passed on to
1052 @code{gtroff}.
1053
1054 Options without an argument can be grouped behind a
1055 single@tie{}@option{-}.  A filename of@tie{}@file{-} denotes the
1056 standard input.  It is possible to have whitespace between an option and
1057 its parameter.
1058
1059 The @code{grog} command can be used to guess the correct @code{groff}
1060 command to format a file.
1061
1062 Here's the description of the command-line options:
1063
1064 @cindex command-line options
1065 @table @samp
1066 @item -a
1067 @cindex @acronym{ASCII} approximation output register (@code{.A})
1068 Generate an @acronym{ASCII} approximation of the typeset output.  The
1069 read-only register @code{.A} is then set to@tie{}1.  @xref{Built-in
1070 Registers}.  A typical example is
1071
1072 @Example
1073 groff -a -man -Tdvi troff.man | less
1074 @endExample
1075
1076 @noindent
1077 which shows how lines are broken for the DVI device.  Note that this
1078 option is rather useless today since graphic output devices are
1079 available virtually everywhere.
1080
1081 @item -b
1082 Print a backtrace with each warning or error message.  This backtrace
1083 should help track down the cause of the error.  The line numbers given
1084 in the backtrace may not always be correct: @code{gtroff} can get
1085 confused by @code{as} or @code{am} requests while counting line numbers.
1086
1087 @item -c
1088 Suppress color output.
1089
1090 @item -C
1091 Enable compatibility mode.  @xref{Implementation Differences}, for the
1092 list of incompatibilities between @code{groff} and @acronym{AT&T}
1093 @code{troff}.
1094
1095 @item -d@var{c}@var{s}
1096 @itemx -d@var{name}=@var{s}
1097 Define @var{c} or @var{name} to be a string@tie{}@var{s}.
1098 @var{c}@tie{}must be a one-letter name; @var{name} can be of arbitrary
1099 length.  All string assignments happen before loading any macro file
1100 (including the start-up file).
1101
1102 @item -D@var{arg}
1103 Set default input encoding used by @code{preconv} to @var{arg}.  Implies
1104 @option{-k}.
1105
1106 @item -e
1107 Preprocess with @code{geqn}.
1108
1109 @item -E
1110 Inhibit all error messages.
1111
1112 @item -f@var{fam}
1113 Use @var{fam} as the default font family.  @xref{Font Families}.
1114
1115 @item -F@var{dir}
1116 Search @file{@var{dir}} for subdirectories @file{dev@var{name}}
1117 (@var{name} is the name of the device), for the @file{DESC} file, and
1118 for font files before looking in the standard directories (@pxref{Font
1119 Directories}).  This option is passed to all pre- and postprocessors
1120 using the @env{GROFF_FONT_PATH} environment variable.
1121
1122 @item -g
1123 Preprocess with @code{ggrn}.
1124
1125 @item -G
1126 Preprocess with @code{grap}.  Implies @option{-p}.
1127
1128 @item -h
1129 Print a help message.
1130
1131 @item -i
1132 Read the standard input after all the named input files have been
1133 processed.
1134
1135 @item -I@var{dir}
1136 This option may be used to specify a directory to search for files.
1137 It is passed to the following programs:
1138
1139 @itemize
1140 @item
1141 @code{gsoelim} (see @ref{gsoelim} for more details);
1142 it also implies @code{groff}'s @option{-s} option.
1143
1144 @item
1145 @code{gtroff}; it is used to search files named in the @code{psbb} and
1146 @code{so} requests.
1147
1148 @item
1149 @code{grops}; it is used to search files named in the
1150 @w{@code{\X'ps: import}} and @w{@code{\X'ps: file}} escapes.
1151 @end itemize
1152
1153 The current directory is always searched first.  This option may be
1154 specified more than once; the directories are searched in the order
1155 specified.  No directory search is performed for files specified using
1156 an absolute path.
1157
1158 @item -j
1159 Preprocess with @code{gchem}.  Implies @option{-p}.
1160
1161 @item -k
1162 Preprocess with @code{preconv}.  This is run before any other
1163 preprocessor.  Please refer to @code{preconv}'s manual page for its
1164 behaviour if no @option{-K} (or @option{-D}) option is specified.
1165
1166 @item -K@var{arg}
1167 Set input encoding used by preconv to @var{arg}.  Implies @option{-k}.
1168
1169 @item -l
1170 Send the output to a spooler for printing.  The command used for this is
1171 specified by the @code{print} command in the device description file
1172 (see @ref{Font Files}, for more info).  If not present, @option{-l} is
1173 ignored.
1174
1175 @item -L@var{arg}
1176 Pass @var{arg} to the spooler.  Each argument should be passed with a
1177 separate @option{-L} option.  Note that @code{groff} does not prepend a
1178 @samp{-} to @var{arg} before passing it to the postprocessor.  If the
1179 @code{print} keyword in the device description file is missing,
1180 @option{-L} is ignored.
1181
1182 @item -m@var{name}
1183 Read in the file @file{@var{name}.tmac}.  Normally @code{groff} searches
1184 for this in its macro directories.  If it isn't found, it tries
1185 @file{tmac.@var{name}} (searching in the same directories).
1186
1187 @item -M@var{dir}
1188 Search directory @file{@var{dir}} for macro files before the standard
1189 directories (@pxref{Macro Directories}).
1190
1191 @item -n@var{num}
1192 Number the first page @var{num}.
1193
1194 @item -N
1195 Don't allow newlines with @code{eqn} delimiters.  This is the same as
1196 the @option{-N} option in @code{geqn}.
1197
1198 @item -o@var{list}
1199 @cindex print current page register (@code{.P})
1200 Output only pages in @var{list}, which is a comma-separated list of page
1201 ranges; @samp{@var{n}} means print page@tie{}@var{n},
1202 @samp{@var{m}-@var{n}} means print every page between @var{m}
1203 and@tie{}@var{n}, @samp{-@var{n}} means print every page up
1204 to@tie{}@var{n}, @samp{@var{n}-} means print every page beginning
1205 with@tie{}@var{n}.  @code{gtroff} exits after printing the last page in
1206 the list.  All the ranges are inclusive on both ends.
1207
1208 Within @code{gtroff}, this information can be extracted with the
1209 @samp{.P} register.  @xref{Built-in Registers}.
1210
1211 If your document restarts page numbering at the beginning of each
1212 chapter, then @code{gtroff} prints the specified page range for each
1213 chapter.
1214
1215 @item -p
1216 Preprocess with @code{gpic}.
1217
1218 @item -P@var{arg}
1219 Pass @var{arg} to the postprocessor.  Each argument should be passed
1220 with a separate @option{-P} option.  Note that @code{groff} does not
1221 prepend @samp{-} to @var{arg} before passing it to the postprocessor.
1222
1223 @item -r@var{c}@var{n}
1224 @itemx -r@var{name}=@var{n}
1225 Set number register@tie{}@var{c} or @var{name} to the
1226 value@tie{}@var{n}.  @var{c}@tie{}must be a one-letter name; @var{name}
1227 can be of arbitrary length.  @var{n}@tie{}can be any @code{gtroff}
1228 numeric expression.  All register assignments happen before loading any
1229 macro file (including the start-up file).
1230
1231 @item -R
1232 Preprocess with @code{grefer}.  No mechanism is provided for passing
1233 arguments to @code{grefer} because most @code{grefer} options have
1234 equivalent commands that can be included in the file.  @xref{grefer},
1235 for more details.
1236
1237 @pindex troffrc
1238 @pindex troffrc-end
1239 Note that @code{gtroff} also accepts a @option{-R} option, which is not
1240 accessible via @code{groff}.  This option prevents the loading of the
1241 @file{troffrc} and @file{troffrc-end} files.
1242
1243 @item -s
1244 Preprocess with @code{gsoelim}.
1245
1246 @item -S
1247 @cindex @code{open} request, and safer mode
1248 @cindex @code{opena} request, and safer mode
1249 @cindex @code{pso} request, and safer mode
1250 @cindex @code{sy} request, and safer mode
1251 @cindex @code{pi} request, and safer mode
1252 @cindex safer mode
1253 @cindex mode, safer
1254 Safer mode.  Pass the @option{-S} option to @code{gpic} and disable the
1255 @code{open}, @code{opena}, @code{pso}, @code{sy}, and @code{pi}
1256 requests.  For security reasons, this is enabled by default.
1257
1258 @item -t
1259 Preprocess with @code{gtbl}.
1260
1261 @item -T@var{dev}
1262 Prepare output for device @var{dev}.  The default device is @samp{ps},
1263 unless changed when @code{groff} was configured and built.  The
1264 following are the output devices currently available:
1265
1266 @table @code
1267 @item ps
1268 For @sc{PostScript} printers and previewers.
1269
1270 @item pdf
1271 For PDF viewers or printers.
1272
1273 @item dvi
1274 For @TeX{} DVI format.
1275
1276 @item X75
1277 For a 75@dmn{dpi} X11 previewer.
1278
1279 @item X75-12
1280 For a 75@dmn{dpi} X11 previewer with a 12@dmn{pt} base font in the
1281 document.
1282
1283 @item X100
1284 For a 100@dmn{dpi} X11 previewer.
1285
1286 @item X100-12
1287 For a 100@dmn{dpi} X11 previewer with a 12@dmn{pt} base font in the
1288 document.
1289
1290 @item ascii
1291 @cindex encoding, output, @acronym{ASCII}
1292 @cindex @acronym{ASCII}, output encoding
1293 @cindex output encoding, @acronym{ASCII}
1294 For typewriter-like devices using the (7-bit) @acronym{ASCII}
1295 character set.
1296
1297 @item latin1
1298 @cindex encoding, output, @w{latin-1} (ISO @w{8859-1})
1299 @cindex @w{latin-1} (ISO @w{8859-1}), output encoding
1300 @cindex ISO @w{8859-1} (@w{latin-1}), output encoding
1301 @cindex output encoding, @w{latin-1} (ISO @w{8859-1})
1302 For typewriter-like devices that support the @w{Latin-1}
1303 (ISO@tie{}@w{8859-1}) character set.
1304
1305 @item utf8
1306 @cindex encoding, output, @w{utf-8}
1307 @cindex @w{utf-8}, output encoding
1308 @cindex output encoding, @w{utf-8}
1309 For typewriter-like devices that use the Unicode (ISO@tie{}10646)
1310 character set with @w{UTF-8} encoding.
1311
1312 @item cp1047
1313 @cindex encoding, output, @acronym{EBCDIC}
1314 @cindex @acronym{EBCDIC}, output encoding
1315 @cindex output encoding, @acronym{EBCDIC}
1316 @cindex encoding, output, cp1047
1317 @cindex cp1047, output encoding
1318 @cindex output encoding, cp1047
1319 @cindex IBM cp1047 output encoding
1320 For typewriter-like devices that use the @acronym{EBCDIC} encoding IBM
1321 cp1047.
1322
1323 @item lj4
1324 For HP LaserJet4-compatible (or other PCL5-compatible) printers.
1325
1326 @item lbp
1327 For Canon @acronym{CAPSL} printers (@w{LBP-4} and @w{LBP-8} series laser
1328 printers).
1329
1330 @pindex pre-grohtml
1331 @pindex post-grohtml
1332 @cindex @code{grohtml}, the program
1333 @item html
1334 @itemx xhtml
1335 To produce @acronym{HTML} and @acronym{XHTML} output, respectively.
1336 Note that this driver consists of two parts, a preprocessor
1337 (@code{pre-grohtml}) and a postprocessor (@code{post-grohtml}).
1338 @end table
1339
1340 @cindex output device name string register (@code{.T})
1341 @cindex output device usage number register (@code{.T})
1342 The predefined @code{gtroff} string register @code{.T} contains the
1343 current output device; the read-only number register @code{.T} is set
1344 to@tie{}1 if this option is used (which is always true if @code{groff}
1345 is used to call @code{gtroff}).  @xref{Built-in Registers}.
1346
1347 The postprocessor to be used for a device is specified by the
1348 @code{postpro} command in the device description file.  (@xref{Font
1349 Files}, for more info.)  This can be overridden with the @option{-X}
1350 option.
1351
1352 @item -U
1353 @cindex mode, unsafe
1354 @cindex unsafe mode
1355 Unsafe mode.  This enables the @code{open}, @code{opena}, @code{pso},
1356 @code{sy}, and @code{pi} requests.
1357
1358 @item -w@var{name}
1359 Enable warning @var{name}.  Available warnings are described in
1360 @ref{Debugging}.  Multiple @option{-w} options are allowed.
1361
1362 @item -W@var{name}
1363 Inhibit warning @var{name}.  Multiple @option{-W} options are allowed.
1364
1365 @item -v
1366 Make programs run by @code{groff} print out their version number.
1367
1368 @item -V
1369 Print the pipeline on @code{stdout} instead of executing it.  If
1370 specified more than once, print the pipeline on @code{stderr} and
1371 execute it.
1372
1373 @item -X
1374 Preview with @code{gxditview} instead of using the usual postprocessor.
1375 This is unlikely to produce good results except with @option{-Tps}.
1376
1377 Note that this is not the same as using @option{-TX75} or
1378 @option{-TX100} to view a document with @code{gxditview}: The former
1379 uses the metrics of the specified device, whereas the latter uses
1380 X-specific fonts and metrics.
1381
1382 @item -z
1383 Suppress output from @code{gtroff}.  Only error messages are printed.
1384
1385 @item -Z
1386 Do not postprocess the output of @code{gtroff}.  Normally @code{groff}
1387 automatically runs the appropriate postprocessor.
1388 @end table
1389
1390
1391 @c =====================================================================
1392
1393 @node Environment, Macro Directories, Groff Options, Invoking groff
1394 @section Environment
1395 @cindex environment variables
1396 @cindex variables in environment
1397
1398 There are also several environment variables (of the operating system,
1399 not within @code{gtroff}) that can modify the behavior of @code{groff}.
1400
1401 @table @code
1402 @item GROFF_BIN_PATH
1403 @tindex GROFF_BIN_PATH@r{, environment variable}
1404 This search path, followed by @code{PATH}, is used for commands executed
1405 by @code{groff}.
1406
1407 @item GROFF_COMMAND_PREFIX
1408 @tindex GROFF_COMMAND_PREFIX@r{, environment variable}
1409 @cindex command prefix
1410 @cindex prefix, for commands
1411 If this is set to@tie{}@var{X}, then @code{groff} runs
1412 @code{@var{X}troff} instead of @code{gtroff}.  This also applies to
1413 @code{tbl}, @code{pic}, @code{eqn}, @code{grn}, @code{chem},
1414 @code{refer}, and @code{soelim}.  It does not apply to @code{grops},
1415 @code{grodvi}, @code{grotty}, @code{pre-grohtml}, @code{post-grohtml},
1416 @code{preconv}, @code{grolj4}, @code{gropdf}, and @code{gxditview}.
1417
1418 The default command prefix is determined during the installation
1419 process.  If a non-GNU troff system is found, prefix @samp{g} is used,
1420 none otherwise.
1421
1422 @item GROFF_ENCODING
1423 @tindex GROFF_ENCODING@r{, environment variable}
1424 The value of this environment value is passed to the @code{preconv}
1425 preprocessor to select the encoding of input files.  Setting this option
1426 implies @code{groff}'s command line option @option{-k} (this is,
1427 @code{groff} actually always calls @code{preconv}).  If set without a
1428 value, @code{groff} calls @code{preconv} without arguments.  An explicit
1429 @option{-K} command line option overrides the value of
1430 @env{GROFF_ENCODING}.  See the manual page of @code{preconv} for details.
1431
1432 @item GROFF_FONT_PATH
1433 @tindex GROFF_FONT_PATH@r{, environment variable}
1434 A colon-separated list of directories in which to search for the
1435 @code{dev}@var{name} directory (before the default directories are
1436 tried).  @xref{Font Directories}.
1437
1438 @item GROFF_TMAC_PATH
1439 @tindex GROFF_TMAC_PATH@r{, environment variable}
1440 A colon-separated list of directories in which to search for macro files
1441 (before the default directories are tried).  @xref{Macro Directories}.
1442
1443 @item GROFF_TMPDIR
1444 @tindex GROFF_TMPDIR@r{, environment variable}
1445 @tindex TMPDIR@r{, environment variable}
1446 The directory in which @code{groff} creates temporary files.  If this is
1447 not set and @env{TMPDIR} is set, temporary files are created in that
1448 directory.  Otherwise temporary files are created in a system-dependent
1449 default directory (on Unix and GNU/Linux systems, this is usually
1450 @file{/tmp}).  @code{grops}, @code{grefer}, @code{pre-grohtml}, and
1451 @code{post-grohtml} can create temporary files in this directory.
1452
1453 @item GROFF_TYPESETTER
1454 @tindex GROFF_TYPESETTER@r{, environment variable}
1455 The default output device.
1456 @end table
1457
1458 Note that MS-DOS and MS-Windows ports of @code{groff} use semi-colons,
1459 rather than colons, to separate the directories in the lists described
1460 above.
1461
1462
1463 @c =====================================================================
1464
1465 @node Macro Directories, Font Directories, Environment, Invoking groff
1466 @section Macro Directories
1467 @cindex macro directories
1468 @cindex directories for macros
1469 @cindex searching macros
1470 @cindex macros, searching
1471
1472 All macro file names must be named @code{@var{name}.tmac} or
1473 @code{tmac.@var{name}} to make the @option{-m@var{name}} command line
1474 option work.  The @code{mso} request doesn't have this restriction; any
1475 file name can be used, and @code{gtroff} won't try to append or prepend
1476 the @samp{tmac} string.
1477
1478 @cindex tmac, directory
1479 @cindex directory, for tmac files
1480 @cindex tmac, path
1481 @cindex path, for tmac files
1482 @cindex searching macro files
1483 @cindex macro files, searching
1484 @cindex files, macro, searching
1485 Macro files are kept in the @dfn{tmac directories}, all of which
1486 constitute the @dfn{tmac path}.  The elements of the search path for
1487 macro files are (in that order):
1488
1489 @itemize @bullet
1490 @item
1491 The directories specified with @code{gtroff}'s or @code{groff}'s
1492 @option{-M} command line option.
1493
1494 @item
1495 @tindex GROFF_TMAC_PATH@r{, environment variable}
1496 The directories given in the @env{GROFF_TMAC_PATH} environment variable.
1497
1498 @item
1499 @cindex safer mode
1500 @cindex mode, safer
1501 @cindex unsafe mode
1502 @cindex mode, unsafe
1503 @cindex current directory
1504 @cindex directory, current
1505 The current directory (only if in unsafe mode using the @option{-U}
1506 command line switch).
1507
1508 @item
1509 @cindex home directory
1510 @cindex directory, home
1511 The home directory.
1512
1513 @item
1514 @cindex site-specific directory
1515 @cindex directory, site-specific
1516 @cindex platform-specific directory
1517 @cindex directory, platform-specific
1518 A platform-dependent directory, a site-specific (platform-independent)
1519 directory, and the main tmac directory; the default locations are
1520
1521 @Example
1522 /usr/local/lib/groff/site-tmac
1523 /usr/local/share/groff/site-tmac
1524 /usr/local/share/groff/1.22.3/tmac
1525 @endExample
1526
1527 @noindent
1528 assuming that the version of @code{groff} is 1.22.3, and the
1529 installation prefix was @file{/usr/local}.  It is possible to fine-tune
1530 those directories during the installation process.
1531 @end itemize
1532
1533
1534 @c =====================================================================
1535
1536 @node Font Directories, Paper Size, Macro Directories, Invoking groff
1537 @section Font Directories
1538 @cindex font directories
1539 @cindex directories for fonts
1540 @cindex searching fonts
1541 @cindex fonts, searching
1542
1543 Basically, there is no restriction how font files for @code{groff} are
1544 named and how long font names are; however, to make the font family
1545 mechanism work (@pxref{Font Families}), fonts within a family should
1546 start with the family name, followed by the shape.  For example, the
1547 Times family uses @samp{T} for the family name and @samp{R}, @samp{B},
1548 @samp{I}, and @samp{BI} to indicate the shapes `roman', `bold',
1549 `italic', and `bold italic', respectively.  Thus the final font names
1550 are @samp{TR}, @samp{TB}, @samp{TI}, and @samp{TBI}.
1551
1552 @cindex font path
1553 @cindex path, for font files
1554 All font files are kept in the @dfn{font directories}, which constitute
1555 the @dfn{font path}.  The file search functions always append the
1556 directory @code{dev}@var{name}, where @var{name} is the name of the
1557 output device.  Assuming, say, DVI output, and @file{/foo/bar} as a font
1558 directory, the font files for @code{grodvi} must be in
1559 @file{/foo/bar/devdvi}.
1560
1561 The elements of the search path for font files are (in that order):
1562
1563 @itemize @bullet
1564 @item
1565 The directories specified with @code{gtroff}'s or @code{groff}'s
1566 @option{-F} command line option.  All device drivers and some
1567 preprocessors also have this option.
1568
1569 @item
1570 @tindex GROFF_FONT_PATH@r{, environment variable}
1571 The directories given in the @env{GROFF_FONT_PATH} environment variable.
1572
1573 @item
1574 @cindex site-specific directory
1575 @cindex directory, site-specific
1576 A site-specific directory and the main font directory; the default
1577 locations are
1578
1579 @Example
1580 /usr/local/share/groff/site-font
1581 /usr/local/share/groff/1.22.3/font
1582 @endExample
1583
1584 @noindent
1585 assuming that the version of @code{groff} is 1.22.3, and the
1586 installation prefix was @file{/usr/local}.  It is possible to fine-tune
1587 those directories during the installation process.
1588 @end itemize
1589
1590
1591 @c =====================================================================
1592
1593 @node Paper Size, Invocation Examples, Font Directories, Invoking groff
1594 @section Paper Size
1595 @cindex paper size
1596 @cindex size, paper
1597 @cindex landscape page orientation
1598 @cindex orientation, landscape
1599 @cindex page orientation, landscape
1600
1601 In groff, the page size for @code{gtroff} and for output devices are
1602 handled separately.  @xref{Page Layout}, for vertical manipulation of
1603 the page size.  @xref{Line Layout}, for horizontal changes.
1604
1605 A default paper size can be set in the device's @file{DESC} file.  Most
1606 output devices also have a command line option @option{-p} to override
1607 the default paper size and option @option{-l} to use landscape
1608 orientation.  @xref{DESC File Format}, for a description of the
1609 @code{papersize} keyword, which takes the same argument as @option{-p}.
1610
1611 @pindex papersize.tmac
1612 @pindex troffrc
1613 A convenient shorthand to set a particular paper size for @code{gtroff}
1614 is command line option @option{-dpaper=@var{size}}.  This defines string
1615 @code{paper}, which is processed in file @file{papersize.tmac} (loaded in
1616 the start-up file @file{troffrc} by default).  Possible values for
1617 @var{size} are the same as the predefined values for the
1618 @code{papersize} keyword (but only in lowercase) except
1619 @code{a7}-@code{d7}.  An appended @samp{l} (ell) character denotes
1620 landscape orientation.
1621
1622 For example, use the following for PS output on A4 paper in landscape
1623 orientation:
1624
1625 @Example
1626 groff -Tps -dpaper=a4l -P-pa4 -P-l -ms foo.ms > foo.ps
1627 @endExample
1628
1629 Note that it is up to the particular macro package to respect default
1630 page dimensions set in this way (most do).
1631
1632
1633 @c =====================================================================
1634
1635 @node Invocation Examples,  , Paper Size, Invoking groff
1636 @section Invocation Examples
1637 @cindex invocation examples
1638 @cindex examples of invocation
1639
1640 This section lists several common uses of @code{groff} and the
1641 corresponding command lines.
1642
1643 @Example
1644 groff file
1645 @endExample
1646
1647 @noindent
1648 This command processes @file{file} without a macro package or a
1649 preprocessor.  The output device is the default, @samp{ps}, and the
1650 output is sent to @code{stdout}.
1651
1652 @Example
1653 groff -t -mandoc -Tascii file | less
1654 @endExample
1655
1656 @noindent
1657 This is basically what a call to the @code{man} program does.
1658 @code{gtroff} processes the manual page @file{file} with the
1659 @file{mandoc} macro file (which in turn either calls the @file{man} or
1660 the @file{mdoc} macro package), using the @code{tbl} preprocessor and
1661 the @acronym{ASCII} output device.  Finally, the @code{less} pager
1662 displays the result.
1663
1664 @Example
1665 groff -X -m me file
1666 @endExample
1667
1668 @noindent
1669 Preview @file{file} with @code{gxditview}, using the @file{me} macro
1670 package.  Since no @option{-T} option is specified, use the default
1671 device (@samp{ps}).  Note that you can either say @w{@samp{-m me}} or
1672 @w{@samp{-me}}; the latter is an anachronism from the early days of
1673 @acronym{UNIX}.@footnote{The same is true for the other main macro
1674 packages that come with @code{groff}: @file{man}, @file{mdoc},
1675 @file{ms}, @file{mm}, and @file{mandoc}.  This won't work in general;
1676 for example, to load @file{trace.tmac}, either @samp{-mtrace} or
1677 @w{@samp{-m trace}} must be used.}
1678
1679 @Example
1680 groff -man -rD1 -z file
1681 @endExample
1682
1683 @noindent
1684 Check @file{file} with the @file{man} macro package, forcing
1685 double-sided printing -- don't produce any output.
1686
1687 @menu
1688 * grog::
1689 @end menu
1690
1691 @c ---------------------------------------------------------------------
1692
1693 @node grog,  , Invocation Examples, Invocation Examples
1694 @subsection @code{grog}
1695
1696 @pindex grog
1697 @code{grog} reads files, guesses which of the @code{groff} preprocessors
1698 and/or macro packages are required for formatting them, and prints the
1699 @code{groff} command including those options on the standard output.  It
1700 generates one or more of the options @option{-e}, @option{-man},
1701 @option{-me}, @option{-mm}, @option{-mom}, @option{-ms}, @option{-mdoc},
1702 @option{-mdoc-old}, @option{-p}, @option{-R}, @option{-g}, @option{-G},
1703 @option{-s}, and @option{-t}.
1704
1705 A special file name@tie{}@file{-} refers to the standard input.
1706 Specifying no files also means to read the standard input.  Any
1707 specified options are included in the printed command.  No space is
1708 allowed between options and their arguments.  The only options
1709 recognized are @option{-C} (which is also passed on) to enable
1710 compatibility mode, and @option{-v} to print the version number and
1711 exit.
1712
1713 For example,
1714
1715 @Example
1716 grog -Tdvi paper.ms
1717 @endExample
1718
1719 @noindent
1720 guesses the appropriate command to print @file{paper.ms} and then prints
1721 it to the command line after adding the @option{-Tdvi} option.  For
1722 direct execution, enclose the call to @code{grog} in backquotes at the
1723 @acronym{UNIX} shell prompt:
1724
1725 @Example
1726 `grog -Tdvi paper.ms` > paper.dvi
1727 @endExample
1728
1729 @noindent
1730 As seen in the example, it is still necessary to redirect the output to
1731 something meaningful (i.e.@: either a file or a pager program like
1732 @code{less}).
1733
1734
1735
1736 @c =====================================================================
1737 @c =====================================================================
1738
1739 @node Tutorial for Macro Users, Macro Packages, Invoking groff, Top
1740 @chapter Tutorial for Macro Users
1741 @cindex tutorial for macro users
1742 @cindex macros, tutorial for users
1743 @cindex user's tutorial for macros
1744 @cindex user's macro tutorial
1745
1746 Most users tend to use a macro package to format their papers.  This
1747 means that the whole breadth of @code{groff} is not necessary for most
1748 people.  This chapter covers the material needed to efficiently use a
1749 macro package.
1750
1751 @menu
1752 * Basics::
1753 * Common Features::
1754 @end menu
1755
1756
1757 @c =====================================================================
1758
1759 @node Basics, Common Features, Tutorial for Macro Users, Tutorial for Macro Users
1760 @section Basics
1761 @cindex basics of macros
1762 @cindex macro basics
1763
1764 This section covers some of the basic concepts necessary to understand
1765 how to use a macro package.@footnote{This section is derived from
1766 @cite{Writing Papers with nroff using -me} by Eric P.@tie{}Allman.}
1767 References are made throughout to more detailed information, if desired.
1768
1769 @code{gtroff} reads an input file prepared by the user and outputs a
1770 formatted document suitable for publication or framing.  The input
1771 consists of text, or words to be printed, and embedded commands
1772 (@dfn{requests} and @dfn{escapes}), which tell @code{gtroff} how to
1773 format the output.  For more detail on this, see @ref{Embedded
1774 Commands}.
1775
1776 The word @dfn{argument} is used in this chapter to mean a word or number
1777 that appears on the same line as a request, and which modifies the
1778 meaning of that request.  For example, the request
1779
1780 @Example
1781 .sp
1782 @endExample
1783
1784 @noindent
1785 spaces one line, but
1786
1787 @Example
1788 .sp 4
1789 @endExample
1790
1791 @noindent
1792 spaces four lines.  The number@tie{}4 is an argument to the @code{sp}
1793 request, which says to space four lines instead of one.  Arguments are
1794 separated from the request and from each other by spaces (@emph{no}
1795 tabs).  More details on this can be found in @ref{Request and Macro
1796 Arguments}.
1797
1798 The primary function of @code{gtroff} is to collect words from input
1799 lines, fill output lines with those words, justify the right-hand margin
1800 by inserting extra spaces in the line, and output the result.  For
1801 example, the input:
1802
1803 @Example
1804 Now is the time
1805 for all good men
1806 to come to the aid
1807 of their party.
1808 Four score and seven
1809 years ago, etc.
1810 @endExample
1811
1812 @noindent
1813 is read, packed onto output lines, and justified to produce:
1814
1815 @quotation
1816 Now is the time for all good men to come to the aid of their party.
1817 Four score and seven years ago, etc.
1818 @end quotation
1819
1820 @cindex break
1821 @cindex line break
1822 Sometimes a new output line should be started even though the current
1823 line is not yet full; for example, at the end of a paragraph.  To do
1824 this it is possible to cause a @dfn{break}, which starts a new output
1825 line.  Some requests cause a break automatically, as normally do blank
1826 input lines and input lines beginning with a space.
1827
1828 Not all input lines are text to be formatted.  Some input lines are
1829 requests that describe how to format the text.  Requests always have a
1830 period (@samp{.}) or an apostrophe (@samp{'}) as the first character of
1831 the input line.
1832
1833 The text formatter also does more complex things, such as automatically
1834 numbering pages, skipping over page boundaries, putting footnotes in the
1835 correct place, and so forth.
1836
1837 Here are a few hints for preparing text for input to @code{gtroff}.
1838
1839 @itemize @bullet
1840 @item
1841 First, keep the input lines short.  Short input lines are easier to
1842 edit, and @code{gtroff} packs words onto longer lines anyhow.
1843
1844 @item
1845 In keeping with this, it is helpful to begin a new line after every
1846 comma or phrase, since common corrections are to add or delete sentences
1847 or phrases.
1848
1849 @item
1850 End each sentence with two spaces -- or better, start each sentence on a
1851 new line.  @code{gtroff} recognizes characters that usually end a
1852 sentence, and inserts sentence space accordingly.
1853
1854 @item
1855 Do not hyphenate words at the end of lines -- @code{gtroff} is smart
1856 enough to hyphenate words as needed, but is not smart enough to take
1857 hyphens out and join a word back together.  Also, words such as
1858 ``mother-in-law'' should not be broken over a line, since then a space
1859 can occur where not wanted, such as ``@w{mother- in}-law''.
1860 @end itemize
1861
1862 @cindex double-spacing (@code{ls})
1863 @cindex spacing
1864 @code{gtroff} double-spaces output text automatically if you use the
1865 request @w{@samp{.ls 2}}.  Reactivate single-spaced mode by typing
1866 @w{@samp{.ls 1}}.@footnote{If you need finer granularity of the vertical
1867 space, use the @code{pvs} request (@pxref{Changing Type Sizes}).}
1868
1869 A number of requests allow to change the way the output looks, sometimes
1870 called the @dfn{layout} of the output page.  Most of these requests
1871 adjust the placing of @dfn{whitespace} (blank lines or spaces).
1872
1873 @cindex new page (@code{bp})
1874 The @code{bp} request starts a new page, causing a line break.
1875
1876 @cindex blank line (@code{sp})
1877 @cindex empty line (@code{sp})
1878 @cindex line, empty (@code{sp})
1879 The request @w{@samp{.sp @var{N}}} leaves @var{N}@tie{}lines of blank
1880 space.  @var{N}@tie{}can be omitted (meaning skip a single line) or can
1881 be of the form @var{N}i (for @var{N}@tie{}inches) or @var{N}c (for
1882 @var{N}@tie{}centimeters).  For example, the input:
1883
1884 @Example
1885 .sp 1.5i
1886 My thoughts on the subject
1887 .sp
1888 @endExample
1889
1890 @noindent
1891 leaves one and a half inches of space, followed by the line ``My
1892 thoughts on the subject'', followed by a single blank line (more
1893 measurement units are available, see @ref{Measurements}).
1894
1895 @cindex centering lines (@code{ce})
1896 @cindex lines, centering (@code{ce})
1897 Text lines can be centered by using the @code{ce} request.  The line
1898 after @code{ce} is centered (horizontally) on the page.  To center more
1899 than one line, use @w{@samp{.ce @var{N}}} (where @var{N} is the number
1900 of lines to center), followed by the @var{N}@tie{}lines.  To center many
1901 lines without counting them, type:
1902
1903 @Example
1904 .ce 1000
1905 lines to center
1906 .ce 0
1907 @endExample
1908
1909 @noindent
1910 The @w{@samp{.ce 0}} request tells @code{groff} to center zero more
1911 lines, in other words, stop centering.
1912
1913 @cindex line break (@code{br})
1914 @cindex break (@code{br})
1915 All of these requests cause a break; that is, they always start a new
1916 line.  To start a new line without performing any other action, use
1917 @code{br}.
1918
1919
1920 @c =====================================================================
1921
1922 @node Common Features,  , Basics, Tutorial for Macro Users
1923 @section Common Features
1924 @cindex common features
1925 @cindex features, common
1926
1927 @code{gtroff} provides very low-level operations for formatting a
1928 document.  There are many common routine operations that are done in
1929 all documents.  These common operations are written into @dfn{macros}
1930 and collected into a @dfn{macro package}.
1931
1932 All macro packages provide certain common capabilities that fall into
1933 the following categories.
1934
1935 @menu
1936 * Paragraphs::
1937 * Sections and Chapters::
1938 * Headers and Footers::
1939 * Page Layout Adjustment::
1940 * Displays::
1941 * Footnotes and Annotations::
1942 * Table of Contents::
1943 * Indices::
1944 * Paper Formats::
1945 * Multiple Columns::
1946 * Font and Size Changes::
1947 * Predefined Strings::
1948 * Preprocessor Support::
1949 * Configuration and Customization::
1950 @end menu
1951
1952 @c ---------------------------------------------------------------------
1953
1954 @node Paragraphs, Sections and Chapters, Common Features, Common Features
1955 @subsection Paragraphs
1956 @cindex paragraphs
1957
1958 One of the most common and most used capability is starting a paragraph.
1959 There are a number of different types of paragraphs, any of which can be
1960 initiated with macros supplied by the macro package.  Normally,
1961 paragraphs start with a blank line and the first line indented, like the
1962 text in this manual.  There are also block style paragraphs, which omit
1963 the indentation:
1964
1965 @Example
1966 Some   men  look   at  constitutions   with  sanctimonious
1967 reverence, and deem them like the ark of the covenant, too
1968 sacred to be touched.
1969 @endExample
1970
1971 @noindent
1972 And there are also indented paragraphs, which begin with a tag or label
1973 at the margin and the remaining text indented.
1974
1975 @Example
1976 one   This is  the first paragraph.  Notice  how the first
1977       line of  the resulting  paragraph lines up  with the
1978       other lines in the paragraph.
1979 @endExample
1980
1981 @Example
1982 longlabel
1983       This  paragraph   had  a  long   label.   The  first
1984       character of text on the first line does not line up
1985       with  the  text  on  second  and  subsequent  lines,
1986       although they line up with each other.
1987 @endExample
1988
1989 A variation of this is a bulleted list.
1990
1991 @Example
1992 .     Bulleted lists start with a bullet.   It is possible
1993       to use other glyphs instead of the bullet.  In nroff
1994       mode using the ASCII character set for output, a dot
1995       is used instead of a real bullet.
1996 @endExample
1997
1998 @c ---------------------------------------------------------------------
1999
2000 @node Sections and Chapters, Headers and Footers, Paragraphs, Common Features
2001 @subsection Sections and Chapters
2002
2003 Most macro packages supply some form of section headers.  The simplest
2004 kind is simply the heading on a line by itself in bold type.  Others
2005 supply automatically numbered section heading or different heading
2006 styles at different levels.  Some, more sophisticated, macro packages
2007 supply macros for starting chapters and appendices.
2008
2009 @c ---------------------------------------------------------------------
2010
2011 @node Headers and Footers, Page Layout Adjustment, Sections and Chapters, Common Features
2012 @subsection Headers and Footers
2013
2014 Every macro package gives some way to manipulate the @dfn{headers} and
2015 @dfn{footers} (also called @dfn{titles}) on each page.  This is text put
2016 at the top and bottom of each page, respectively, which contain data
2017 like the current page number, the current chapter title, and so on.  Its
2018 appearance is not affected by the running text.  Some packages allow for
2019 different ones on the even and odd pages (for material printed in a book
2020 form).
2021
2022 The titles are called @dfn{three-part titles}, that is, there is a
2023 left-justified part, a centered part, and a right-justified part.  An
2024 automatically generated page number may be put in any of these fields
2025 with the @samp{%} character (see @ref{Page Layout}, for more details).
2026
2027 @c ---------------------------------------------------------------------
2028
2029 @node Page Layout Adjustment, Displays, Headers and Footers, Common Features
2030 @subsection Page Layout
2031
2032 Most macro packages let the user specify top and bottom margins and
2033 other details about the appearance of the printed pages.
2034
2035 @c ---------------------------------------------------------------------
2036
2037 @node Displays, Footnotes and Annotations, Page Layout Adjustment, Common Features
2038 @subsection Displays
2039 @cindex displays
2040
2041 @dfn{Displays} are sections of text to be set off from the body of the
2042 paper.  Major quotes, tables, and figures are types of displays, as are
2043 all the examples used in this document.
2044
2045 @cindex quotes, major
2046 @cindex major quotes
2047 @dfn{Major quotes} are quotes that are several lines long, and hence
2048 are set in from the rest of the text without quote marks around them.
2049
2050 @cindex list
2051 A @dfn{list} is an indented, single-spaced, unfilled display.  Lists
2052 should be used when the material to be printed should not be filled and
2053 justified like normal text, such as columns of figures or the examples
2054 used in this paper.
2055
2056 @cindex keep
2057 A @dfn{keep} is a display of lines that are kept on a single page if
2058 possible.  An example for a keep might be a diagram.  Keeps differ from
2059 lists in that lists may be broken over a page boundary whereas keeps are
2060 not.
2061
2062 @cindex keep, floating
2063 @cindex floating keep
2064 @dfn{Floating keeps} move relative to the text.  Hence, they are good
2065 for things that are referred to by name, such as ``See figure@tie{}3''.
2066 A floating keep appears at the bottom of the current page if it fits;
2067 otherwise, it appears at the top of the next page.  Meanwhile, the
2068 surrounding text `flows' around the keep, thus leaving no blank areas.
2069
2070 @c ---------------------------------------------------------------------
2071
2072 @node Footnotes and Annotations, Table of Contents, Displays, Common Features
2073 @subsection Footnotes and Annotations
2074 @cindex footnotes
2075 @cindex annotations
2076
2077 There are a number of requests to save text for later printing.
2078
2079 @dfn{Footnotes} are printed at the bottom of the current page.
2080
2081 @cindex delayed text
2082 @dfn{Delayed text} is very similar to a footnote except that it is
2083 printed when called for explicitly.  This allows a list of references to
2084 appear (for example) at the end of each chapter, as is the convention in
2085 some disciplines.
2086
2087 Most macro packages that supply this functionality also supply a means
2088 of automatically numbering either type of annotation.
2089
2090 @c ---------------------------------------------------------------------
2091
2092 @node Table of Contents, Indices, Footnotes and Annotations, Common Features
2093 @subsection Table of Contents
2094 @cindex table of contents
2095 @cindex contents, table of
2096
2097 @dfn{Tables of contents} are a type of delayed text having a tag
2098 (usually the page number) attached to each entry after a row of dots.
2099 The table accumulates throughout the paper until printed, usually after
2100 the paper has ended.  Many macro packages provide the ability to have
2101 several tables of contents (e.g.@: a standard table of contents, a list
2102 of tables, etc).
2103
2104 @c ---------------------------------------------------------------------
2105
2106 @node Indices, Paper Formats, Table of Contents, Common Features
2107 @subsection Indices
2108 @cindex index, in macro package
2109
2110 While some macro packages use the term @dfn{index}, none actually
2111 provide that functionality.  The facilities they call indices are
2112 actually more appropriate for tables of contents.
2113
2114 @pindex makeindex
2115 To produce a real index in a document, external tools like the
2116 @code{makeindex} program are necessary.
2117
2118 @c ---------------------------------------------------------------------
2119
2120 @node Paper Formats, Multiple Columns, Indices, Common Features
2121 @subsection Paper Formats
2122 @cindex paper formats
2123
2124 Some macro packages provide stock formats for various kinds of
2125 documents.  Many of them provide a common format for the title and
2126 opening pages of a technical paper.  The @file{mm} macros in particular
2127 provide formats for letters and memoranda.
2128
2129 @c ---------------------------------------------------------------------
2130
2131 @node Multiple Columns, Font and Size Changes, Paper Formats, Common Features
2132 @subsection Multiple Columns
2133
2134 Some macro packages (but not @file{man}) provide the ability to have two
2135 or more columns on a page.
2136
2137 @c ---------------------------------------------------------------------
2138
2139 @node Font and Size Changes, Predefined Strings, Multiple Columns, Common Features
2140 @subsection Font and Size Changes
2141
2142 The built-in font and size functions are not always intuitive, so all
2143 macro packages provide macros to make these operations simpler.
2144
2145 @c ---------------------------------------------------------------------
2146
2147 @node Predefined Strings, Preprocessor Support, Font and Size Changes, Common Features
2148 @subsection Predefined Strings
2149
2150 Most macro packages provide various predefined strings for a variety of
2151 uses; examples are sub- and superscripts, printable dates, quotes and
2152 various special characters.
2153
2154 @c ---------------------------------------------------------------------
2155
2156 @node Preprocessor Support, Configuration and Customization, Predefined Strings, Common Features
2157 @subsection Preprocessor Support
2158
2159 All macro packages provide support for various preprocessors and may
2160 extend their functionality.
2161
2162 For example, all macro packages mark tables (which are processed with
2163 @code{gtbl}) by placing them between @code{TS} and @code{TE} macros.
2164 The @file{ms} macro package has an option, @samp{.TS@tie{}H}, that
2165 prints a caption at the top of a new page (when the table is too long to
2166 fit on a single page).
2167
2168 @c ---------------------------------------------------------------------
2169
2170 @node Configuration and Customization,  , Preprocessor Support, Common Features
2171 @subsection Configuration and Customization
2172
2173 Some macro packages provide means of customizing many of the details of
2174 how the package behaves.  This ranges from setting the default type size
2175 to changing the appearance of section headers.
2176
2177
2178
2179 @c =====================================================================
2180 @c =====================================================================
2181
2182 @node Macro Packages, gtroff Reference, Tutorial for Macro Users, Top
2183 @chapter Macro Packages
2184 @cindex macro packages
2185 @cindex packages, macros
2186
2187 This chapter documents the main macro packages that come with
2188 @code{groff}.
2189
2190 Different main macro packages can't be used at the same time; for
2191 example
2192
2193 @Example
2194 groff -m man foo.man -m ms bar.doc
2195 @endExample
2196
2197 @noindent
2198 doesn't work.  Note that option arguments are processed before
2199 non-option arguments; the above (failing) sample is thus reordered to
2200
2201 @Example
2202 groff -m man -m ms foo.man bar.doc
2203 @endExample
2204
2205 @menu
2206 * man::
2207 * mdoc::
2208 * ms::
2209 * me::
2210 * mm::
2211 * mom::
2212 @end menu
2213
2214
2215 @c =====================================================================
2216
2217 @node man, mdoc, Macro Packages, Macro Packages
2218 @section @file{man}
2219 @cindex manual pages
2220 @cindex man pages
2221 @pindex an.tmac
2222 @pindex man.tmac
2223 @pindex man-old.tmac
2224
2225 This is the most popular and probably the most important macro package
2226 of @code{groff}.  It is easy to use, and a vast majority of manual pages
2227 are based on it.
2228
2229 @menu
2230 * Man options::
2231 * Man usage::
2232 * Man font macros::
2233 * Miscellaneous man macros::
2234 * Predefined man strings::
2235 * Preprocessors in man pages::
2236 * Optional man extensions::
2237 @end menu
2238
2239 @c ---------------------------------------------------------------------
2240
2241 @node Man options, Man usage, man, man
2242 @subsection Options
2243
2244 The command line format for using the @file{man} macros with
2245 @code{groff} is:
2246
2247 @Example
2248 groff -m man [ -rLL=@var{length} ] [ -rLT=@var{length} ] [ -rFT=@var{dist} ]
2249       [ -rcR=1 ] [ -rC1 ] [ -rD1 ] [-rHY=@var{flags} ]
2250       [ -rP@var{nnn} ] [ -rS@var{xx} ] [ -rX@var{nnn} ]
2251       [ -rIN=@var{length} ] [ -rSN=@var{length} ] [ @var{files}@dots{} ]
2252 @endExample
2253
2254 @noindent
2255 It is possible to use @samp{-man} instead of @w{@samp{-m man}}.
2256
2257 @table @code
2258 @item -rcR=1
2259 This option (the default if a TTY output device is used) creates a
2260 single, very long page instead of multiple pages.  Use @code{-rcR=0} to
2261 disable it.
2262
2263 @item -rC1
2264 If more than one manual page is given on the command line, number the
2265 pages continuously, rather than starting each at@tie{}1.
2266
2267 @item -rD1
2268 Double-sided printing.  Footers for even and odd pages are formatted
2269 differently.
2270
2271 @item -rFT=@var{dist}
2272 Set the position of the footer text to @var{dist}.  If positive, the
2273 distance is measured relative to the top of the page, otherwise it is
2274 relative to the bottom.  The default is @minus{}0.5@dmn{i}.
2275
2276 @item -rHY=@var{flags}
2277 Set hyphenation flags.  Possible values are 1@tie{}to hyphenate without
2278 restrictions, 2@tie{}to not hyphenate the last word on a page, 4@tie{}to
2279 not hyphenate the last two characters of a word, and 8@tie{}to not
2280 hyphenate the first two characters of a word.  These values are
2281 additive; the default is@tie{}14.
2282
2283 @item -rIN=@var{length}
2284 Set the body text indentation to @var{length}.  If not specified, the
2285 indentation defaults to 7@dmn{n} (7@tie{}characters) in nroff mode and
2286 7.2@dmn{n} otherwise.  For nroff, this value should always be an integer
2287 multiple of unit @samp{n} to get consistent indentation.
2288
2289 @item -rLL=@var{length}
2290 Set line length to @var{length}.  If not specified, the line length is
2291 set to respect any value set by a prior @samp{ll} request (which
2292 @emph{must} be in effect when the @samp{TH} macro is invoked), if this
2293 differs from the built-in default for the formatter; otherwise it
2294 defaults to 78@dmn{n} in nroff mode (this is 78 characters per line) and
2295 6.5@dmn{i} in troff mode.@footnote{Note that the use of a @samp{.ll
2296 @var{length}} request to initialize the line length, prior to use of the
2297 @samp{TH} macro, is supported for backward compatibility with some
2298 versions of the @code{man} program.  @emph{Always} use the
2299 @option{-rLL=@var{length}} option, or an equivalent @samp{.nr LL
2300 @var{length}} request, in preference to such a @samp{.ll @var{length}}
2301 request.  In particular, note that in nroff mode, the request @samp{.ll
2302 65n}, (with any @var{length} expression that evaluates equal to
2303 65@dmn{n}, i.e., the formatter's default line length in nroff mode),
2304 does @emph{not} set the line length to 65@dmn{n} (it is adjusted to the
2305 @code{man} macro package's default setting of 78@dmn{n}), whereas the
2306 use of the @option{-rLL=65n} option, or the @samp{.nr LL 65n} request
2307 @emph{does} establish a line length of 65@dmn{n}.}
2308
2309 @item -rLT=@var{length}
2310 Set title length to @var{length}.  If not specified, the title length
2311 defaults to the line length.
2312
2313 @item -rP@var{nnn}
2314 Page numbering starts with @var{nnn} rather than with@tie{}1.
2315
2316 @item -rS@var{xx}
2317 Use @var{xx} (which can be 10, 11, or@tie{}12@dmn{pt}) as the base
2318 document font size instead of the default value of@tie{}10@dmn{pt}.
2319
2320 @item -rSN=@var{length}
2321 Set the indentation for sub-subheadings to @var{length}.  If not
2322 specified, the indentation defaults to 3@dmn{n}.
2323
2324 @item -rX@var{nnn}
2325 After page @var{nnn}, number pages as @var{nnn}a, @var{nnn}b,
2326 @var{nnn}c, etc.  For example, the option @option{-rX2} produces the
2327 following page numbers: 1, 2, 2a, 2b, 2c, etc.
2328 @end table
2329
2330 @c ---------------------------------------------------------------------
2331
2332 @node Man usage, Man font macros, Man options, man
2333 @subsection Usage
2334 @cindex @code{man} macros
2335 @cindex macros for manual pages [@code{man}]
2336
2337 @pindex man.local
2338 This section describes the available macros for manual pages.  For
2339 further customization, put additional macros and requests into the file
2340 @file{man.local}, which is loaded immediately after the @file{man}
2341 package.
2342
2343 @Defmac {TH, title section [@Var{extra1} [@Var{extra2} [@Var{extra3}]]], man}
2344 Set the title of the man page to @var{title} and the section to
2345 @var{section}, which must have a value between 1 and@tie{}8.  The value
2346 of @var{section} may also have a string appended, e.g.@: @samp{.pm}, to
2347 indicate a specific subsection of the man pages.
2348
2349 Both @var{title} and @var{section} are positioned at the left and right
2350 in the header line (with @var{section} in parentheses immediately
2351 appended to @var{title}.  @var{extra1} is positioned in the middle of
2352 the footer line.  @var{extra2} is positioned at the left in the footer
2353 line (or at the left on even pages and at the right on odd pages if
2354 double-sided printing is active).  @var{extra3} is centered in the
2355 header line.
2356
2357 For @acronym{HTML} and @acronym{XHTML} output, headers and footers are
2358 completely suppressed.
2359
2360 Additionally, this macro starts a new page; the new line number
2361 is@tie{}1 again (except if the @option{-rC1} option is given on the
2362 command line) -- this feature is intended only for formatting multiple
2363 man pages; a single man page should contain exactly one @code{TH} macro
2364 at the beginning of the file.
2365 @endDefmac
2366
2367 @Defmac {SH, [@Var{heading}], man}
2368 Set up an unnumbered section heading sticking out to the left.  Prints
2369 out all the text following @code{SH} up to the end of the line (or the
2370 text in the next line if there is no argument to @code{SH}) in bold face
2371 (or the font specified by the string @code{HF}), one size larger than
2372 the base document size.  Additionally, the left margin and the
2373 indentation for the following text is reset to its default value.
2374 @endDefmac
2375
2376 @Defmac {SS, [@Var{heading}], man}
2377 Set up an unnumbered (sub)section heading.  Prints out all the text
2378 following @code{SS} up to the end of the line (or the text in the next
2379 line if there is no argument to @code{SS}) in bold face (or the font
2380 specified by the string @code{HF}), at the same size as the base
2381 document size.  Additionally, the left margin and the indentation for
2382 the following text is reset to its default value.
2383 @endDefmac
2384
2385 @Defmac {TP, [@Var{nnn}], man}
2386 Set up an indented paragraph with label.  The indentation is set to
2387 @var{nnn} if that argument is supplied (the default unit is @samp{n} if
2388 omitted), otherwise it is set to the previous indentation value
2389 specified with @code{TP}, @code{IP}, or @code{HP} (or to the default
2390 value if none of them have been used yet).
2391
2392 The first line of text following this macro is interpreted as a string
2393 to be printed flush-left, as it is appropriate for a label.  It is not
2394 interpreted as part of a paragraph, so there is no attempt to fill the
2395 first line with text from the following input lines.  Nevertheless, if
2396 the label is not as wide as the indentation the paragraph starts at the
2397 same line (but indented), continuing on the following lines.  If the
2398 label is wider than the indentation the descriptive part of the
2399 paragraph begins on the line following the label, entirely indented.
2400 Note that neither font shape nor font size of the label is set to a
2401 default value; on the other hand, the rest of the text has default font
2402 settings.
2403 @endDefmac
2404
2405 @DefmacList {LP, , man}
2406 @DefmacItemx {PP, , man}
2407 @DefmacListEndx {P, , man}
2408 These macros are mutual aliases.  Any of them causes a line break at the
2409 current position, followed by a vertical space downwards by the amount
2410 specified by the @code{PD} macro.  The font size and shape are reset to
2411 the default value (10@dmn{pt} roman if no @option{-rS} option is given
2412 on the command line).  Finally, the current left margin and the
2413 indentation is restored.
2414 @endDefmac
2415
2416 @Defmac {IP, [@Var{designator} [@Var{nnn}]], man}
2417 Set up an indented paragraph, using @var{designator} as a tag to mark
2418 its beginning.  The indentation is set to @var{nnn} if that argument is
2419 supplied (default unit is @samp{n}), otherwise it is set to the previous
2420 indentation value specified with @code{TP}, @code{IP}, or @code{HP} (or
2421 the default value if none of them have been used yet).  Font size and
2422 face of the paragraph (but not the designator) are reset to their
2423 default values.
2424
2425 To start an indented paragraph with a particular indentation but without
2426 a designator, use @samp{""} (two double quotes) as the first argument of
2427 @code{IP}.
2428
2429 For example, to start a paragraph with bullets as the designator and
2430 4@tie{}en indentation, write
2431
2432 @Example
2433 .IP \(bu 4
2434 @endExample
2435 @endDefmac
2436
2437 @Defmac {HP, [@Var{nnn}], man}
2438 @cindex hanging indentation [@code{man}]
2439 @cindex @code{man} macros, hanging indentation
2440 Set up a paragraph with hanging left indentation.  The indentation is
2441 set to @var{nnn} if that argument is supplied (default unit is
2442 @samp{n}), otherwise it is set to the previous indentation value
2443 specified with @code{TP}, @code{IP}, or @code{HP} (or the default value
2444 if non of them have been used yet).  Font size and face are reset to
2445 their default values.
2446 @endDefmac
2447
2448 @Defmac {RS, [@Var{nnn}], man}
2449 @cindex left margin, how to move [@code{man}]
2450 @cindex @code{man} macros, moving left margin
2451 Move the left margin to the right by the value @var{nnn} if specified
2452 (default unit is @samp{n}); otherwise it is set to the previous
2453 indentation value specified with @code{TP}, @code{IP}, or @code{HP} (or
2454 to the default value if none of them have been used yet).  The
2455 indentation value is then set to the default.
2456
2457 Calls to the @code{RS} macro can be nested.
2458 @endDefmac
2459
2460 @Defmac {RE, [@Var{nnn}], man}
2461 Move the left margin back to level @var{nnn}, restoring the previous
2462 left margin.  If no argument is given, it moves one level back.  The
2463 first level (i.e., no call to @code{RS} yet) has number@tie{}1, and each
2464 call to @code{RS} increases the level by@tie{}1.
2465 @endDefmac
2466
2467 @cindex line breaks, with vertical space [@code{man}]
2468 @cindex @code{man} macros, line breaks with vertical space
2469 To summarize, the following macros cause a line break with the insertion
2470 of vertical space (which amount can be changed with the @code{PD}
2471 macro): @code{SH}, @code{SS}, @code{TP}, @code{LP} (@code{PP},
2472 @code{P}), @code{IP}, and @code{HP}.
2473
2474 @cindex line breaks, without vertical space [@code{man}]
2475 @cindex @code{man} macros, line breaks without vertical space
2476 The macros @code{RS} and @code{RE} also cause a break but do not insert
2477 vertical space.
2478
2479 @cindex default indentation, resetting [@code{man}]
2480 @cindex indentaion, resetting to default [@code{man}]
2481 @cindex @code{man} macros, resetting default indentation
2482 Finally, the macros @code{SH}, @code{SS}, @code{LP} (@code{PP},
2483 @code{P}), and @code{RS} reset the indentation to its default value.
2484
2485 @c ---------------------------------------------------------------------
2486
2487 @node Man font macros, Miscellaneous man macros, Man usage, man
2488 @subsection Macros to set fonts
2489 @cindex font selection [@code{man}]
2490 @cindex @code{man} macros, how to set fonts
2491
2492 The standard font is roman; the default text size is 10@tie{}point.  If
2493 command line option @option{-rS=@var{n}} is given, use @var{n}@dmn{pt}
2494 as the default text size.
2495
2496 @Defmac {SM, [@Var{text}], man}
2497 Set the text on the same line or the text on the next line in a font
2498 that is one point size smaller than the default font.
2499 @endDefmac
2500
2501 @Defmac {SB, [@Var{text}], man}
2502 @cindex bold face [@code{man}]
2503 @cindex @code{man} macros, bold face
2504 Set the text on the same line or the text on the next line in bold face
2505 font, one point size smaller than the default font.
2506 @endDefmac
2507
2508 @Defmac {BI, text, man}
2509 Set its arguments alternately in bold face and italic, without a space
2510 between the arguments.  Thus,
2511
2512 @Example
2513 .BI this "word and" that
2514 @endExample
2515
2516 @noindent
2517 produces ``thisword andthat'' with ``this'' and ``that'' in bold face,
2518 and ``word and'' in italics.
2519 @endDefmac
2520
2521 @Defmac {IB, text, man}
2522 Set its arguments alternately in italic and bold face, without a space
2523 between the arguments.
2524 @endDefmac
2525
2526 @Defmac {RI, text, man}
2527 Set its arguments alternately in roman and italic, without a space
2528 between the arguments.
2529 @endDefmac
2530
2531 @Defmac {IR, text, man}
2532 Set its arguments alternately in italic and roman, without a space
2533 between the arguments.
2534 @endDefmac
2535
2536 @Defmac {BR, text, man}
2537 Set its arguments alternately in bold face and roman, without a space
2538 between the arguments.
2539 @endDefmac
2540
2541 @Defmac {RB, text, man}
2542 Set its arguments alternately in roman and bold face, without a space
2543 between the arguments.
2544 @endDefmac
2545
2546 @Defmac {B, [@Var{text}], man}
2547 Set @var{text} in bold face.  If no text is present on the line where
2548 the macro is called, then the text of the next line appears in bold
2549 face.
2550 @endDefmac
2551
2552 @Defmac {I, [@Var{text}], man}
2553 @cindex italic fonts [@code{man}]
2554 @cindex @code{man} macros, italic fonts
2555 Set @var{text} in italic.  If no text is present on the line where the
2556 macro is called, then the text of the next line appears in italic.
2557 @endDefmac
2558
2559 @c ---------------------------------------------------------------------
2560
2561 @node Miscellaneous man macros, Predefined man strings, Man font macros, man
2562 @subsection Miscellaneous macros
2563
2564 @pindex grohtml
2565 @cindex @code{man} macros, default indentation
2566 @cindex default indentation [@code{man}]
2567 The default indentation is 7.2@dmn{n} in troff mode and 7@dmn{n} in
2568 nroff mode except for @code{grohtml}, which ignores indentation.
2569
2570 @Defmac {DT, , man}
2571 @cindex tab stops [@code{man}]
2572 @cindex @code{man} macros, tab stops
2573 Set tabs every 0.5@tie{}inches.  Since this macro is always executed
2574 during a call to the @code{TH} macro, it makes sense to call it only if
2575 the tab positions have been changed.
2576 @endDefmac
2577
2578 @Defmac {PD, [@Var{nnn}], man}
2579 @cindex empty space before a paragraph [@code{man}]
2580 @cindex @code{man} macros, empty space before a paragraph
2581 Adjust the empty space before a new paragraph (or section).  The
2582 optional argument gives the amount of space (default unit is @samp{v});
2583 without parameter, the value is reset to its default value (1@tie{}line
2584 in nroff mode, 0.4@dmn{v}@tie{}otherwise).
2585
2586 This affects the macros @code{SH}, @code{SS}, @code{TP}, @code{LP} (as
2587 well as @code{PP} and @code{P}), @code{IP}, and @code{HP}.
2588 @endDefmac
2589
2590 The following two macros are included for BSD compatibility.
2591
2592 @Defmac {AT, [@Var{system} [@Var{release}]], man}
2593 @cindex @code{man}macros, BSD compatibility
2594 Alter the footer for use with @acronym{AT&T} manpages.  This command
2595 exists only for compatibility; don't use it.  The first argument
2596 @var{system} can be:
2597
2598 @table @code
2599 @item 3
2600 7th Edition (the default)
2601
2602 @item 4
2603 System III
2604
2605 @item 5
2606 System V
2607 @end table
2608
2609 An optional second argument @var{release} to @code{AT} specifies the
2610 release number (such as ``System V Release 3'').
2611 @endDefmac
2612
2613 @Defmac {UC, [@Var{version}], man}
2614 @cindex @code{man}macros, BSD compatibility
2615 Alters the footer for use with BSD manpages.  This command exists only
2616 for compatibility; don't use it.  The argument can be:
2617
2618 @table @code
2619 @item 3
2620 3rd Berkeley Distribution (the default)
2621
2622 @item 4
2623 4th Berkeley Distribution
2624
2625 @item 5
2626 4.2 Berkeley Distribution
2627
2628 @item 6
2629 4.3 Berkeley Distribution
2630
2631 @item 7
2632 4.4 Berkeley Distribution
2633 @end table
2634 @endDefmac
2635
2636 @c ---------------------------------------------------------------------
2637
2638 @node Predefined man strings, Preprocessors in man pages, Miscellaneous man macros, man
2639 @subsection Predefined strings
2640
2641 The following strings are defined:
2642
2643 @Defstr {S, man}
2644 Switch back to the default font size.
2645 @endDefstr
2646
2647 @Defstr {HF, man}
2648 The typeface used for headings.
2649 The default is @samp{B}.
2650 @endDefstr
2651
2652 @Defstr {R, man}
2653 The `registered' sign.
2654 @endDefstr
2655
2656 @Defstr {Tm, man}
2657 The `trademark' sign.
2658 @endDefstr
2659
2660 @DefstrList {lq, man}
2661 @DefstrListEndx {rq, man}
2662 @cindex @code{lq} glyph, and @code{lq} string [@code{man}]
2663 @cindex @code{rq} glyph, and @code{rq} string [@code{man}]
2664 Left and right quote.  This is equal to @code{\(lq} and @code{\(rq},
2665 respectively.
2666 @endDefstr
2667
2668 @c ---------------------------------------------------------------------
2669
2670 @node Preprocessors in man pages, Optional man extensions, Predefined man strings, man
2671 @subsection Preprocessors in @file{man} pages
2672
2673 @cindex preprocessor, calling convention
2674 @cindex calling convention of preprocessors
2675 If a preprocessor like @code{gtbl} or @code{geqn} is needed, it has
2676 become common usage to make the first line of the man page look like
2677 this:
2678
2679 @Example
2680 '\" @var{word}
2681 @endExample
2682
2683 @pindex geqn@r{, invocation in manual pages}
2684 @pindex grefer@r{, invocation in manual pages}
2685 @pindex gtbl@r{, invocation in manual pages}
2686 @pindex man@r{, invocation of preprocessors}
2687 @noindent
2688 Note the single space character after the double quote.  @var{word}
2689 consists of letters for the needed preprocessors: @samp{e} for
2690 @code{geqn}, @samp{r} for @code{grefer}, @samp{t} for @code{gtbl}.
2691 Modern implementations of the @code{man} program read this first line
2692 and automatically call the right preprocessor(s).
2693
2694 @c ---------------------------------------------------------------------
2695
2696 @node Optional man extensions,  , Preprocessors in man pages, man
2697 @subsection Optional @file{man} extensions
2698
2699 @pindex man.local
2700 Use the file @file{man.local} for local extensions to the @code{man}
2701 macros or for style changes.
2702
2703 @unnumberedsubsubsec Custom headers and footers
2704 @cindex @code{man} macros, custom headers and footers
2705
2706 In groff versions 1.18.2 and later, you can specify custom headers and
2707 footers by redefining the following macros in @file{man.local}.
2708
2709 @Defmac {PT, , man}
2710 Control the content of the headers.  Normally, the header prints the
2711 command name and section number on either side, and the optional fifth
2712 argument to @code{TH} in the center.
2713 @endDefmac
2714
2715 @Defmac {BT, , man}
2716 Control the content of the footers.  Normally, the footer prints the
2717 page number and the third and fourth arguments to @code{TH}.
2718
2719 Use the @code{FT} number register to specify the footer position.  The
2720 default is @minus{}0.5@dmn{i}.
2721 @endDefmac
2722
2723 @unnumberedsubsubsec Ultrix-specific man macros
2724 @cindex Ultrix-specific @code{man} macros
2725 @cindex @code{man} macros, Ultrix-specific
2726
2727 @pindex man.ultrix
2728 The @code{groff} source distribution includes a file named
2729 @file{man.ultrix}, containing macros compatible with the Ultrix variant
2730 of @code{man}.  Copy this file into @file{man.local} (or use the
2731 @code{mso} request to load it) to enable the following macros.
2732
2733 @Defmac {CT, @Var{key}, man}
2734 Print @samp{<CTRL/@var{key}>}.
2735 @endDefmac
2736
2737 @Defmac {CW, , man}
2738 Print subsequent text using the constant width (Courier) typeface.
2739 @endDefmac
2740
2741 @Defmac {Ds, , man}
2742 Begin a non-filled display.
2743 @endDefmac
2744
2745 @Defmac {De, , man}
2746 End a non-filled display started with @code{Ds}.
2747 @endDefmac
2748
2749 @Defmac {EX, [@Var{indent}], man}
2750 Begin a non-filled display using the constant width (Courier) typeface.
2751 Use the optional @var{indent} argument to indent the display.
2752 @endDefmac
2753
2754 @Defmac {EE, , man}
2755 End a non-filled display started with @code{EX}.
2756 @endDefmac
2757
2758 @Defmac {G, [@Var{text}], man}
2759 Set @var{text} in Helvetica.  If no text is present on the line where
2760 the macro is called, then the text of the next line appears in
2761 Helvetica.
2762 @endDefmac
2763
2764 @Defmac {GL, [@Var{text}], man}
2765 Set @var{text} in Helvetica Oblique.  If no text is present on the line
2766 where the macro is called, then the text of the next line appears in
2767 Helvetica Oblique.
2768 @endDefmac
2769
2770 @Defmac {HB, [@Var{text}], man}
2771 Set @var{text} in Helvetica Bold.  If no text is present on the line
2772 where the macro is called, then all text up to the next @code{HB}
2773 appears in Helvetica Bold.
2774 @endDefmac
2775
2776 @Defmac {TB, [@Var{text}], man}
2777 Identical to @code{HB}.
2778 @endDefmac
2779
2780 @Defmac {MS, @Var{title} @Var{sect} [@Var{punct}], man}
2781 Set a manpage reference in Ultrix format.  The @var{title} is in Courier
2782 instead of italic.  Optional punctuation follows the section number
2783 without an intervening space.
2784 @endDefmac
2785
2786 @Defmac {NT, [@code{C}] [@Var{title}], man}
2787 Begin a note.  Print the optional @Var{title}, or the word ``Note'',
2788 centered on the page.  Text following the macro makes up the body of the
2789 note, and is indented on both sides.  If the first argument is @code{C},
2790 the body of the note is printed centered (the second argument replaces
2791 the word ``Note'' if specified).
2792 @endDefmac
2793
2794 @Defmac {NE, , man}
2795 End a note begun with @code{NT}.
2796 @endDefmac
2797
2798 @Defmac {PN, @Var{path} [@Var{punct}], man}
2799 Set the path name in constant width (Courier), followed by optional
2800 punctuation.
2801 @endDefmac
2802
2803 @Defmac {Pn, [@Var{punct}] @Var{path} [@Var{punct}], man}
2804 If called with two arguments, identical to @code{PN}.  If called with
2805 three arguments, set the second argument in constant width (Courier),
2806 bracketed by the first and third arguments in the current font.
2807 @endDefmac
2808
2809 @Defmac {R, , man}
2810 Switch to roman font and turn off any underlining in effect.
2811 @endDefmac
2812
2813 @Defmac {RN, , man}
2814 Print the string @samp{<RETURN>}.
2815 @endDefmac
2816
2817 @Defmac {VS, [@code{4}], man}
2818 Start printing a change bar in the margin if the number@tie{}@code{4} is
2819 specified.  Otherwise, this macro does nothing.
2820 @endDefmac
2821
2822 @Defmac {VE, , man}
2823 End printing the change bar begun by @code{VS}.
2824 @endDefmac
2825
2826 @unnumberedsubsubsec Simple example
2827
2828 The following example @file{man.local} file alters the @code{SH} macro
2829 to add some extra vertical space before printing the heading.  Headings
2830 are printed in Helvetica Bold.
2831
2832 @Example
2833 .\" Make the heading fonts Helvetica
2834 .ds HF HB
2835 .
2836 .\" Put more whitespace in front of headings.
2837 .rn SH SH-orig
2838 .de SH
2839 .  if t .sp (u;\\n[PD]*2)
2840 .  SH-orig \\$*
2841 ..
2842 @endExample
2843
2844
2845 @c =====================================================================
2846
2847 @node mdoc, ms, man, Macro Packages
2848 @section @file{mdoc}
2849 @cindex @code{mdoc} macros
2850
2851 @c XXX documentation
2852 @c XXX this is a placeholder until we get stuff knocked into shape
2853 See the @cite{groff_mdoc(7)} man page (type @command{man groff_mdoc}
2854 at the command line).
2855
2856
2857 @c =====================================================================
2858
2859 @node ms, me, mdoc, Macro Packages
2860 @section @file{ms}
2861 @cindex @code{ms} macros
2862
2863 The @file{-ms} macros are suitable for reports, letters, books, user
2864 manuals, and so forth.  The package provides macros for cover pages,
2865 section headings, paragraphs, lists, footnotes, pagination, and a table
2866 of contents.
2867
2868 @menu
2869 * ms Intro::
2870 * General ms Structure::
2871 * ms Document Control Registers::
2872 * ms Cover Page Macros::
2873 * ms Body Text::
2874 * ms Page Layout::
2875 * Differences from AT&T ms::
2876 * Naming Conventions::
2877 @end menu
2878
2879 @c ---------------------------------------------------------------------
2880
2881 @node ms Intro, General ms Structure, ms, ms
2882 @subsection Introduction to @file{ms}
2883
2884 The original @file{-ms} macros were included with @acronym{AT&T}
2885 @code{troff} as well as the @file{man} macros.  While the @file{man}
2886 package is intended for brief documents that can be read on-line as well
2887 as printed, the @file{ms} macros are suitable for longer documents that
2888 are meant to be printed rather than read on-line.
2889
2890 The @file{ms} macro package included with @code{groff} is a complete,
2891 bottom-up re-implementation.  Several macros (specific to @acronym{AT&T}
2892 or Berkeley) are not included, while several new commands are.
2893 @xref{Differences from AT&T ms}, for more information.
2894
2895 @c ---------------------------------------------------------------------
2896
2897 @node General ms Structure, ms Document Control Registers, ms Intro, ms
2898 @subsection General structure of an @file{ms} document
2899 @cindex @code{ms} macros, general structure
2900
2901 The @file{ms} macro package expects a certain amount of structure, but
2902 not as much as packages such as @file{man} or @file{mdoc}.
2903
2904 The simplest documents can begin with a paragraph macro (such as
2905 @code{LP} or @code{PP}), and consist of text separated by paragraph
2906 macros or even blank lines.  Longer documents have a structure as
2907 follows:
2908
2909 @table @strong
2910 @item Document type
2911 If you invoke the @code{RP} (report) macro on the first line of the
2912 document, @code{groff} prints the cover page information on its own
2913 page; otherwise it prints the information on the first page with your
2914 document text immediately following.  Other document formats found in
2915 @acronym{AT&T} @code{troff} are specific to @acronym{AT&T} or Berkeley,
2916 and are not supported in @code{groff}.
2917
2918 @item Format and layout
2919 By setting number registers, you can change your document's type (font
2920 and size), margins, spacing, headers and footers, and footnotes.
2921 @xref{ms Document Control Registers}, for more details.
2922
2923 @item Cover page
2924 A cover page consists of a title, the author's name and institution, an
2925 abstract, and the date.@footnote{Actually, only the title is required.}
2926 @xref{ms Cover Page Macros}, for more details.
2927
2928 @item Body
2929 Following the cover page is your document.  You can use the @file{ms}
2930 macros to write reports, letters, books, and so forth.  The package is
2931 designed for structured documents, consisting of paragraphs interspersed
2932 with headings and augmented by lists, footnotes, tables, and other
2933 common constructs.  @xref{ms Body Text}, for more details.
2934
2935 @item Table of contents
2936 Longer documents usually include a table of contents, which you can
2937 invoke by placing the @code{TC} macro at the end of your document.  The
2938 @file{ms} macros have minimal indexing facilities, consisting of the
2939 @code{IX} macro, which prints an entry on standard error.  Printing the
2940 table of contents at the end is necessary since @code{groff} is a
2941 single-pass text formatter, thus it cannot determine the page number of
2942 each section until that section has actually been set and printed.
2943 Since @file{ms} output is intended for hardcopy, you can manually
2944 relocate the pages containing the table of contents between the cover
2945 page and the body text after printing.
2946 @end table
2947
2948 @c ---------------------------------------------------------------------
2949
2950 @node ms Document Control Registers, ms Cover Page Macros, General ms Structure, ms
2951 @subsection Document control registers
2952 @cindex @code{ms} macros, document control registers
2953
2954 The following is a list of document control number registers.  For the
2955 sake of consistency, set registers related to margins at the beginning
2956 of your document, or just after the @code{RP} macro.  You can set other
2957 registers later in your document, but you should keep them together at
2958 the beginning to make them easy to find and edit as necessary.
2959
2960 @unnumberedsubsubsec Margin Settings
2961
2962 @Defmpreg {PO, ms}
2963 Defines the page offset (i.e., the left margin).  There is no explicit
2964 right margin setting; the combination of the @code{PO} and @code{LL}
2965 registers implicitly define the right margin width.
2966
2967 Effective: next page.
2968
2969 Default value: 1@dmn{i}.
2970 @endDefmpreg
2971
2972 @Defmpreg {LL, ms}
2973 Defines the line length (i.e., the width of the body text).
2974
2975 Effective: next paragraph.
2976
2977 Default: 6@dmn{i}.
2978 @endDefmpreg
2979
2980 @Defmpreg {LT, ms}
2981 Defines the title length (i.e., the header and footer width).  This
2982 is usually the same as @code{LL}, but not necessarily.
2983
2984 Effective: next paragraph.
2985
2986 Default: 6@dmn{i}.
2987 @endDefmpreg
2988
2989 @Defmpreg {HM, ms}
2990 Defines the header margin height at the top of the page.
2991
2992 Effective: next page.
2993
2994 Default: 1@dmn{i}.
2995 @endDefmpreg
2996
2997 @Defmpreg {FM, ms}
2998 Defines the footer margin height at the bottom of the page.
2999
3000 Effective: next page.
3001
3002 Default: 1@dmn{i}.
3003 @endDefmpreg
3004
3005 @unnumberedsubsubsec Text Settings
3006
3007 @Defmpreg {PS, ms}
3008 Defines the point size of the body text.  If the value is larger than or
3009 equal to 1000, divide it by 1000 to get a fractional point size.  For
3010 example, @samp{.nr PS 10250} sets the document's point size to
3011 10.25@dmn{p}.
3012
3013 Effective: next paragraph.
3014
3015 Default: 10@dmn{p}.
3016 @endDefmpreg
3017
3018 @Defmpreg {VS, ms}
3019 Defines the space between lines (line height plus leading).  If the
3020 value is larger than or equal to 1000, divide it by 1000 to get a
3021 fractional point size.  Due to backwards compatibility, @code{VS} must
3022 be smaller than 40000 (this is 40.0@dmn{p}).
3023
3024 Effective: next paragraph.
3025
3026 Default: 12@dmn{p}.
3027 @endDefmpreg
3028
3029 @Defmpreg {PSINCR, ms}
3030 Defines an increment in point size, which is applied to section headings
3031 at nesting levels below the value specified in @code{GROWPS}.  The value
3032 of @code{PSINCR} should be specified in points, with the @dmn{p} scaling
3033 factor, and may include a fractional component; for example,
3034 @w{@samp{.nr PSINCR 1.5p}} sets a point size increment of 1.5@dmn{p}.
3035
3036 Effective: next section heading.
3037
3038 Default: 1@dmn{p}.
3039 @endDefmpreg
3040
3041 @Defmpreg {GROWPS, ms}
3042 Defines the heading level below which the point size increment set by
3043 @code{PSINCR} becomes effective.  Section headings at and above the
3044 level specified by @code{GROWPS} are printed at the point size set by
3045 @code{PS}; for each level below the value of @code{GROWPS}, the point
3046 size is increased in steps equal to the value of @code{PSINCR}.  Setting
3047 @code{GROWPS} to any value less than@tie{}2 disables the incremental
3048 heading size feature.
3049
3050 Effective: next section heading.
3051
3052 Default: 0.
3053 @endDefmpreg
3054
3055 @Defmpreg {HY, ms}
3056 Defines the hyphenation level.  @code{HY} sets safely the value of the
3057 low-level @code{hy} register.  Setting the value of @code{HY} to@tie{}0
3058 is equivalent to using the @code{nh} request.
3059
3060 Effective: next paragraph.
3061
3062 Default: 14.
3063 @endDefmpreg
3064
3065 @Defmpreg {FAM, ms}
3066 Defines the font family used to typeset the document.
3067
3068 Effective: next paragraph.
3069
3070 Default: as defined in the output device.
3071 @endDefmpreg
3072
3073 @unnumberedsubsubsec Paragraph Settings
3074
3075 @Defmpreg {PI, ms}
3076 Defines the initial indentation of a (@code{PP} macro) paragraph.
3077
3078 Effective: next paragraph.
3079
3080 Default: 5@dmn{n}.
3081 @endDefmpreg
3082
3083 @Defmpreg {PD, ms}
3084 Defines the space between paragraphs.
3085
3086 Effective: next paragraph.
3087
3088 Default: 0.3@dmn{v}.
3089 @endDefmpreg
3090
3091 @Defmpreg {QI, ms}
3092 Defines the indentation on both sides of a quoted (@code{QP} macro)
3093 paragraph.
3094
3095 Effective: next paragraph.
3096
3097 Default: 5@dmn{n}.
3098 @endDefmpreg
3099
3100 @Defmpreg {PORPHANS, ms}
3101 Defines the minimum number of initial lines of any paragraph that
3102 should be kept together, to avoid orphan lines at the bottom of a page.
3103 If a new paragraph is started close to the bottom of a page, and there
3104 is insufficient space to accommodate @code{PORPHANS} lines before an
3105 automatic page break, then the page break is forced, before the start of
3106 the paragraph.
3107
3108 Effective: next paragraph.
3109
3110 Default: 1.
3111 @endDefmpreg
3112
3113 @Defmpreg {HORPHANS, ms}
3114 Defines the minimum number of lines of the following paragraph that
3115 should be kept together with any section heading introduced by the
3116 @code{NH} or @code{SH} macros.  If a section heading is placed close to
3117 the bottom of a page, and there is insufficient space to accommodate
3118 both the heading and at least @code{HORPHANS} lines of the following
3119 paragraph, before an automatic page break, then the page break is forced
3120 before the heading.
3121
3122 Effective: next paragraph.
3123
3124 Default: 1.
3125 @endDefmpreg
3126
3127 @unnumberedsubsubsec Footnote Settings
3128
3129 @Defmpreg {FL, ms}
3130 Defines the length of a footnote.
3131
3132 Effective: next footnote.
3133
3134 Default: @math{@code{@\n[LL]} * 5 / 6}.
3135 @endDefmpreg
3136
3137 @Defmpreg {FI, ms}
3138 Defines the footnote indentation.
3139
3140 Effective: next footnote.
3141
3142 Default: 2@dmn{n}.
3143 @endDefmpreg
3144
3145 @Defmpreg {FF, ms}
3146 The footnote format:
3147 @table @code
3148 @item 0
3149 Print the footnote number as a superscript; indent the footnote
3150 (default).
3151
3152 @item 1
3153 Print the number followed by a period (like 1.@:) and indent the
3154 footnote.
3155
3156 @item 2
3157 Like 1, without an indentation.
3158
3159 @item 3
3160 Like 1, but print the footnote number as a hanging paragraph.
3161 @end table
3162
3163 Effective: next footnote.
3164
3165 Default: 0.
3166 @endDefmpreg
3167
3168 @Defmpreg {FPS, ms}
3169 Defines the footnote point size.  If the value is larger than or equal
3170 to 1000, divide it by 1000 to get a fractional point size.
3171
3172 Effective: next footnote.
3173
3174 Default: @math{@code{@\n[PS]} - 2}.
3175 @endDefmpreg
3176
3177 @Defmpreg {FVS, ms}
3178 Defines the footnote vertical spacing.  If the value is larger than or
3179 equal to 1000, divide it by 1000 to get a fractional point size.
3180
3181 Effective: next footnote.
3182
3183 Default: @math{@code{@\n[FPS]} + 2}.
3184 @endDefmpreg
3185
3186 @Defmpreg {FPD, ms}
3187 Defines the footnote paragraph spacing.
3188
3189 Effective: next footnote.
3190
3191 Default: @math{@code{@\n[PD]} / 2}.
3192 @endDefmpreg
3193
3194 @unnumberedsubsubsec Miscellaneous Number Registers
3195
3196 @Defmpreg {MINGW, ms}
3197 Defines the minimum width between columns in a multi-column document.
3198
3199 Effective: next page.
3200
3201 Default: 2@dmn{n}.
3202 @endDefmpreg
3203
3204 @Defmpreg {DD, ms}
3205 Sets the vertical spacing before and after a display, a @code{tbl} table, an
3206 @code{eqn} equation, or a @code{pic} image.
3207
3208 Effective: next paragraph.
3209
3210 Default: 0.5@dmn{v}.
3211 @endDefmpreg
3212
3213 @c ---------------------------------------------------------------------
3214
3215 @node ms Cover Page Macros, ms Body Text, ms Document Control Registers, ms
3216 @subsection Cover page macros
3217 @cindex @code{ms} macros, cover page
3218 @cindex cover page macros, [@code{ms}]
3219
3220 Use the following macros to create a cover page for your document in the
3221 order shown.
3222
3223 @Defmac {RP, [@code{no}], ms}
3224 Specifies the report format for your document.  The report format
3225 creates a separate cover page.  The default action (no @code{RP} macro)
3226 is to print a subset of the cover page on page@tie{}1 of your document.
3227
3228 If you use the word @code{no} as an optional argument, @code{groff}
3229 prints a title page but does not repeat any of the title page
3230 information (title, author, abstract, etc.@:) on page@tie{}1 of the
3231 document.
3232 @endDefmac
3233
3234 @Defmac {P1, , ms}
3235 (P-one) Prints the header on page@tie{}1.  The default is to suppress
3236 the header.
3237 @endDefmac
3238
3239 @Defmac {DA, [@dots{}], ms}
3240 (optional) Prints the current date, or the arguments to the macro if
3241 any, on the title page (if specified) and in the footers.  This is the
3242 default for @code{nroff}.
3243 @endDefmac
3244
3245 @Defmac {ND, [@dots{}], ms}
3246 (optional) Prints the current date, or the arguments to the macro if
3247 any, on the title page (if specified) but not in the footers.  This is
3248 the default for @code{troff}.
3249 @endDefmac
3250
3251 @Defmac {TL, , ms}
3252 Specifies the document title.  @code{groff} collects text following the
3253 @code{TL} macro into the title, until reaching the author name or
3254 abstract.
3255 @endDefmac
3256
3257 @Defmac {AU, , ms}
3258 Specifies the author's name, which appears on the line (or lines)
3259 immediately following.  You can specify multiple authors as follows:
3260
3261 @Example
3262 .AU
3263 John Doe
3264 .AI
3265 University of West Bumblefuzz
3266 .AU
3267 Martha Buck
3268 .AI
3269 Monolithic Corporation
3270
3271 ...
3272 @endExample
3273 @endDefmac
3274
3275 @Defmac {AI, , ms}
3276 Specifies the author's institution.  You can specify multiple
3277 institutions in the same way that you specify multiple authors.
3278 @endDefmac
3279
3280 @Defmac {AB, [@code{no}], ms}
3281 Begins the abstract.  The default is to print the word
3282 @acronym{ABSTRACT}, centered and in italics, above the text of the
3283 abstract.  The word @code{no} as an optional argument suppresses this
3284 heading.
3285 @endDefmac
3286
3287 @Defmac {AE, , ms}
3288 Ends the abstract.
3289 @endDefmac
3290
3291 The following is example mark-up for a title page.
3292 @cindex title page, example markup
3293 @cindex example markup, title page
3294
3295 @CartoucheExample
3296 .RP
3297 .TL
3298 The Inevitability of Code Bloat
3299 in Commercial and Free Software
3300 .AU
3301 J. Random Luser
3302 .AI
3303 University of West Bumblefuzz
3304 .AB
3305 This report examines the long-term growth
3306 of the code bases in two large, popular software
3307 packages; the free Emacs and the commercial
3308 Microsoft Word.
3309 While differences appear in the type or order
3310 of features added, due to the different
3311 methodologies used, the results are the same
3312 in the end.
3313 .PP
3314 The free software approach is shown to be
3315 superior in that while free software can
3316 become as bloated as commercial offerings,
3317 free software tends to have fewer serious
3318 bugs and the added features are in line with
3319 user demand.
3320 .AE
3321
3322 ... the rest of the paper follows ...
3323 @endCartoucheExample
3324
3325 @c ---------------------------------------------------------------------
3326
3327 @node ms Body Text, ms Page Layout, ms Cover Page Macros, ms
3328 @subsection Body text
3329 @cindex @code{ms} macros, body text
3330
3331 This section describes macros used to mark up the body of your document.
3332 Examples include paragraphs, sections, and other groups.
3333
3334 @menu
3335 * Paragraphs in ms::
3336 * Headings in ms::
3337 * Highlighting in ms::
3338 * Lists in ms::
3339 * Indentation values in ms::
3340 * Tabstops in ms::
3341 * ms Displays and Keeps::
3342 * ms Insertions::
3343 * Example multi-page table::
3344 * ms Footnotes::
3345 @end menu
3346
3347 @c ---------------------------------------------------------------------
3348
3349 @node Paragraphs in ms, Headings in ms, ms Body Text, ms Body Text
3350 @subsubsection Paragraphs
3351 @cindex @code{ms} macros, paragraph handling
3352
3353 The following paragraph types are available.
3354
3355 @Defmac {PP, , ms}
3356 Sets a paragraph with an initial indentation.
3357 @endDefmac
3358
3359 @Defmac {LP, , ms}
3360 Sets a paragraph without an initial indentation.
3361 @endDefmac
3362
3363 @Defmac {QP, , ms}
3364 Sets a paragraph that is indented at both left and right margins.  The
3365 effect is identical to the @acronym{HTML} @code{<BLOCKQUOTE>} element.
3366 The next paragraph or heading returns margins to normal.
3367 @endDefmac
3368
3369 @Defmac {XP, , ms}
3370 Sets a paragraph whose lines are indented, except for the first line.
3371 This is a Berkeley extension.
3372 @endDefmac
3373
3374 The following markup uses all four paragraph macros.
3375
3376 @CartoucheExample
3377 .NH 2
3378 Cases used in the study
3379 .LP
3380 The following software and versions were
3381 considered for this report.
3382 .PP
3383 For commercial software, we chose
3384 .B "Microsoft Word for Windows" ,
3385 starting with version 1.0 through the
3386 current version (Word 2000).
3387 .PP
3388 For free software, we chose
3389 .B Emacs ,
3390 from its first appearance as a standalone
3391 editor through the current version (v20).
3392 See [Bloggs 2002] for details.
3393 .QP
3394 Franklin's Law applied to software:
3395 software expands to outgrow both
3396 RAM and disk space over time.
3397 .LP
3398 Bibliography:
3399 .XP
3400 Bloggs, Joseph R.,
3401 .I "Everyone's a Critic" ,
3402 Underground Press, March 2002.
3403 A definitive work that answers all questions
3404 and criticisms about the quality and usability of
3405 free software.
3406 @endCartoucheExample
3407
3408 The @code{PORPHANS} register (@pxref{ms Document Control Registers})
3409 operates in conjunction with each of these macros, to inhibit the
3410 printing of orphan lines at the bottom of any page.
3411
3412 @c ---------------------------------------------------------------------
3413
3414 @node Headings in ms, Highlighting in ms, Paragraphs in ms, ms Body Text
3415 @subsubsection Headings
3416 @cindex @code{ms} macros, headings
3417
3418 Use headings to create a hierarchical structure for your document.  The
3419 @file{ms} macros print headings in @strong{bold}, using the same font
3420 family and point size as the body text.
3421
3422 The following describes the heading macros:
3423
3424 @DefmacList {NH, @Var{curr-level}, ms}
3425 @DefmacListEnd {NH, @t{S} @Var{level0} @dots{}, ms}
3426 Numbered heading.  The argument is either a numeric argument to indicate
3427 the level of the heading, or the letter@tie{}@code{S} followed by
3428 numeric arguments to set the heading level explicitly.
3429
3430 If you specify heading levels out of sequence, such as invoking
3431 @samp{.NH 3} after @samp{.NH 1}, @code{groff} prints a warning on
3432 standard error.
3433 @endDefmac
3434
3435 @DefstrList {SN, ms}
3436 @DefstrItemx {SN-DOT, ms}
3437 @DefstrListEndx {SN-NO-DOT, ms}
3438 After invocation of @code{NH}, the assigned section number is made
3439 available in the strings @code{SN-DOT} (as it appears in a printed
3440 section heading with default formatting, followed by a terminating
3441 period), and @code{SN-NO-DOT} (with the terminating period omitted).
3442 The string @code{SN} is also defined, as an alias for @code{SN-DOT}; if
3443 preferred, you may redefine it as an alias for @code{SN-NO-DOT}, by
3444 including the initialization
3445 @Example
3446 .als SN SN-NO-DOT
3447 @endExample
3448
3449 @noindent
3450 at any time @strong{before} you would like the change to take effect.
3451 @endDefstr
3452
3453 @Defstr {SN-STYLE, ms}
3454 You may control the style used to print section numbers, within numbered
3455 section headings, by defining an appropriate alias for the string
3456 @code{SN-STYLE}.  The default style, in which the printed section number
3457 is followed by a terminating period, is obtained by defining the alias
3458
3459 @Example
3460 .als SN-STYLE SN-DOT
3461 @endExample
3462
3463 @noindent
3464 If you prefer to omit the terminating period, from section numbers
3465 appearing in numbered section headings, you may define the alias
3466
3467 @Example
3468 .als SN-STYLE SN-NO-DOT
3469 @endExample
3470
3471 @noindent
3472 Any such change in section numbering style becomes effective from the
3473 next use of @code{.NH}, following redefinition of the alias for
3474 @code{SN-STYLE}.
3475 @endDefstr
3476
3477 @Defmac {SH, [@Var{match-level}], ms}
3478 Unnumbered subheading.
3479
3480 The optional @var{match-level} argument is a GNU extension.  It is a
3481 number indicating the level of the heading, in a manner analogous to the
3482 @var{curr-level} argument to @code{.NH}.  Its purpose is to match the
3483 point size, at which the heading is printed, to the size of a numbered
3484 heading at the same level, when the @code{GROWPS} and @code{PSINCR}
3485 heading size adjustment mechanism is in effect.  @xref{ms Document
3486 Control Registers}.
3487 @endDefmac
3488
3489 The @code{HORPHANS} register (@pxref{ms Document Control Registers})
3490 operates in conjunction with the @code{NH} and @code{SH} macros, to
3491 inhibit the printing of orphaned section headings at the bottom of any
3492 page.
3493
3494 @c ---------------------------------------------------------------------
3495
3496 @node Highlighting in ms, Lists in ms, Headings in ms, ms Body Text
3497 @subsubsection Highlighting
3498 @cindex @code{ms} macros, highlighting
3499
3500 The @file{ms} macros provide a variety of methods to highlight or
3501 emphasize text:
3502
3503 @Defmac {B, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3504 Sets its first argument in @strong{bold type}.  If you specify a second
3505 argument, @code{groff} prints it in the previous font after the bold
3506 text, with no intervening space (this allows you to set punctuation
3507 after the highlighted text without highlighting the punctuation).
3508 Similarly, it prints the third argument (if any) in the previous font
3509 @strong{before} the first argument.  For example,
3510
3511 @Example
3512 .B foo ) (
3513 @endExample
3514
3515 prints (@strong{foo}).
3516
3517 If you give this macro no arguments, @code{groff} prints all text
3518 following in bold until the next highlighting, paragraph, or heading
3519 macro.
3520 @endDefmac
3521
3522 @Defmac {R, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3523 Sets its first argument in roman (or regular) type.  It operates
3524 similarly to the @code{B}@tie{}macro otherwise.
3525 @endDefmac
3526
3527 @Defmac {I, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3528 Sets its first argument in @emph{italic type}.  It operates similarly
3529 to the @code{B}@tie{}macro otherwise.
3530 @endDefmac
3531
3532 @Defmac {CW, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3533 Sets its first argument in a @code{constant width face}.  It operates
3534 similarly to the @code{B}@tie{}macro otherwise.
3535 @endDefmac
3536
3537 @Defmac {BI, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3538 Sets its first argument in bold italic type.  It operates similarly to
3539 the @code{B}@tie{}macro otherwise.
3540 @endDefmac
3541
3542 @Defmac {BX, [@Var{txt}], ms}
3543 Prints its argument and draws a box around it.  If you want to box a
3544 string that contains spaces, use a digit-width space (@code{\0}).
3545 @endDefmac
3546
3547 @Defmac {UL, [@Var{txt} [@Var{post}]], ms}
3548 Prints its first argument with an underline.  If you specify a second
3549 argument, @code{groff} prints it in the previous font after the
3550 underlined text, with no intervening space.
3551 @endDefmac
3552
3553 @Defmac {LG, , ms}
3554 Prints all text following in larger type (two points larger than the
3555 current point size) until the next font size, highlighting, paragraph,
3556 or heading macro.  You can specify this macro multiple times to
3557 enlarge the point size as needed.
3558 @endDefmac
3559
3560 @Defmac {SM, , ms}
3561 Prints all text following in smaller type (two points smaller than the
3562 current point size) until the next type size, highlighting, paragraph,
3563 or heading macro.  You can specify this macro multiple times to reduce
3564 the point size as needed.
3565 @endDefmac
3566
3567 @Defmac {NL, , ms}
3568 Prints all text following in the normal point size (that is, the value
3569 of the @code{PS} register).
3570 @endDefmac
3571
3572 @DefstrList {@Lbrace{}, ms}
3573 @DefstrListEndx {@Rbrace{}, ms}
3574 Text enclosed with @code{\*@{} and @code{\*@}} is printed as a
3575 superscript.
3576 @endDefstr
3577
3578 @c ---------------------------------------------------------------------
3579
3580 @node Lists in ms, Indentation values in ms, Highlighting in ms, ms Body Text
3581 @subsubsection Lists
3582 @cindex @code{ms} macros, lists
3583
3584 The @code{IP} macro handles duties for all lists.
3585
3586 @Defmac {IP, [@Var{marker} [@Var{width}]], ms}
3587 The @var{marker} is usually a bullet glyph (@code{\[bu]}) for unordered
3588 lists, a number (or auto-incrementing number register) for numbered
3589 lists, or a word or phrase for indented (glossary-style) lists.
3590
3591 The @var{width} specifies the indentation for the body of each list
3592 item; its default unit is @samp{n}.  Once specified, the indentation
3593 remains the same for all list items in the document until specified
3594 again.
3595
3596 The @code{PORPHANS} register (@pxref{ms Document Control Registers})
3597 operates in conjunction with the @code{IP} macro, to inhibit the
3598 printing of orphaned list markers at the bottom of any page.
3599 @endDefmac
3600
3601 The following is an example of a bulleted list.
3602 @cindex example markup, bulleted list [@code{ms}]
3603 @cindex bulleted list, example markup [@code{ms}]
3604
3605 @Example
3606 A bulleted list:
3607 .IP \[bu] 2
3608 lawyers
3609 .IP \[bu]
3610 guns
3611 .IP \[bu]
3612 money
3613 @endExample
3614
3615 Produces:
3616
3617 @Example
3618 A bulleted list:
3619
3620 o lawyers
3621
3622 o guns
3623
3624 o money
3625 @endExample
3626
3627 The following is an example of a numbered list.
3628 @cindex example markup, numbered list [@code{ms}]
3629 @cindex numbered list, example markup [@code{ms}]
3630
3631 @Example
3632 .nr step 1 1
3633 A numbered list:
3634 .IP \n[step] 3
3635 lawyers
3636 .IP \n+[step]
3637 guns
3638 .IP \n+[step]
3639 money
3640 @endExample
3641
3642 Produces:
3643
3644 @Example
3645 A numbered list:
3646
3647 1. lawyers
3648
3649 2. guns
3650
3651 3. money
3652 @endExample
3653
3654 Note the use of the auto-incrementing number register in this example.
3655
3656 The following is an example of a glossary-style list.
3657 @cindex example markup, glossary-style list [@code{ms}]
3658 @cindex glossary-style list, example markup [@code{ms}]
3659
3660 @Example
3661 A glossary-style list:
3662 .IP lawyers 0.4i
3663 Two or more attorneys.
3664 .IP guns
3665 Firearms, preferably
3666 large-caliber.
3667 .IP money
3668 Gotta pay for those
3669 lawyers and guns!
3670 @endExample
3671
3672 Produces:
3673
3674 @Example
3675 A glossary-style list:
3676
3677 lawyers
3678       Two or more attorneys.
3679
3680 guns  Firearms, preferably large-caliber.
3681
3682 money
3683       Gotta pay for those lawyers and guns!
3684 @endExample
3685
3686 In the last example, the @code{IP} macro places the definition on the
3687 same line as the term if it has enough space; otherwise, it breaks to
3688 the next line and starts the definition below the term.  This may or may
3689 not be the effect you want, especially if some of the definitions break
3690 and some do not.  The following examples show two possible ways to force
3691 a break.
3692
3693 The first workaround uses the @code{br} request to force a break after
3694 printing the term or label.
3695
3696 @CartoucheExample
3697 A glossary-style list:
3698 .IP lawyers 0.4i
3699 Two or more attorneys.
3700 .IP guns
3701 .br
3702 Firearms, preferably large-caliber.
3703 .IP money
3704 Gotta pay for those lawyers and guns!
3705 @endCartoucheExample
3706
3707 The second workaround uses the @code{\p} escape to force the break.
3708 Note the space following the escape; this is important.  If you omit the
3709 space, @code{groff} prints the first word on the same line as the term
3710 or label (if it fits) @strong{then} breaks the line.
3711
3712 @CartoucheExample
3713 A glossary-style list:
3714 .IP lawyers 0.4i
3715 Two or more attorneys.
3716 .IP guns
3717 \p Firearms, preferably large-caliber.
3718 .IP money
3719 Gotta pay for those lawyers and guns!
3720 @endCartoucheExample
3721
3722 To set nested lists, use the @code{RS} and @code{RE} macros.
3723 @xref{Indentation values in ms}, for more information.
3724 @cindex @code{ms} macros, nested lists
3725 @cindex nested lists [@code{ms}]
3726
3727 For example:
3728
3729 @CartoucheExample
3730 .IP \[bu] 2
3731 Lawyers:
3732 .RS
3733 .IP \[bu]
3734 Dewey,
3735 .IP \[bu]
3736 Cheatham,
3737 .IP \[bu]
3738 and Howe.
3739 .RE
3740 .IP \[bu]
3741 Guns
3742 @endCartoucheExample
3743
3744 Produces:
3745
3746 @Example
3747 o Lawyers:
3748
3749   o  Dewey,
3750
3751   o  Cheatham,
3752
3753   o  and Howe.
3754
3755 o Guns
3756 @endExample
3757
3758 @c ---------------------------------------------------------------------
3759
3760 @node Indentation values in ms, Tabstops in ms, Lists in ms, ms Body Text
3761 @subsubsection Indentation values
3762
3763 In many situations, you may need to indentation a section of text while
3764 still wrapping and filling.  @xref{Lists in ms}, for an example of
3765 nested lists.
3766
3767 @DefmacList {RS, , ms}
3768 @DefmacListEndx {RE, , ms}
3769 These macros begin and end an indented section.  The @code{PI} register
3770 controls the amount of indentation, allowing the indented text to line
3771 up under hanging and indented paragraphs.
3772 @endDefmac
3773
3774 @xref{ms Displays and Keeps}, for macros to indentation and turn off
3775 filling.
3776
3777 @c ---------------------------------------------------------------------
3778
3779 @node Tabstops in ms, ms Displays and Keeps, Indentation values in ms, ms Body Text
3780 @subsubsection Tab Stops
3781
3782 Use the @code{ta} request to define tab stops as needed.  @xref{Tabs and
3783 Fields}.
3784
3785 @Defmac {TA, , ms}
3786 Use this macro to reset the tab stops to the default for @file{ms}
3787 (every 5n).  You can redefine the @code{TA} macro to create a different
3788 set of default tab stops.
3789 @endDefmac
3790
3791 @c ---------------------------------------------------------------------
3792
3793 @node ms Displays and Keeps, ms Insertions, Tabstops in ms, ms Body Text
3794 @subsubsection Displays and keeps
3795 @cindex @code{ms} macros, displays
3796 @cindex @code{ms} macros, keeps
3797 @cindex keeps [@code{ms}]
3798 @cindex displays [@code{ms}]
3799
3800 Use displays to show text-based examples or figures (such as code
3801 listings).
3802
3803 Displays turn off filling, so lines of code are displayed as-is without
3804 inserting @code{br} requests in between each line.  Displays can be
3805 @dfn{kept} on a single page, or allowed to break across pages.
3806
3807 @DefmacList {DS, @t{L}, ms}
3808 @DefmacItemx {LD, , ms}
3809 @DefmacListEndx {DE, , ms}
3810 Left-justified display.  The @samp{.DS L} call generates a page break,
3811 if necessary, to keep the entire display on one page.  The @code{LD}
3812 macro allows the display to break across pages.  The @code{DE} macro
3813 ends the display.
3814 @endDefmac
3815
3816 @DefmacList {DS, @t{I}, ms}
3817 @DefmacItemx {ID, , ms}
3818 @DefmacListEndx {DE, , ms}
3819 Indents the display as defined by the @code{DI} register.  The @samp{.DS
3820 I} call generates a page break, if necessary, to keep the entire display
3821 on one page.  The @code{ID} macro allows the display to break across
3822 pages.  The @code{DE} macro ends the display.
3823 @endDefmac
3824
3825 @DefmacList {DS, @t{B}, ms}
3826 @DefmacItemx {BD, , ms}
3827 @DefmacListEndx {DE, , ms}
3828 Sets a block-centered display: the entire display is left-justified, but
3829 indented so that the longest line in the display is centered on the
3830 page.  The @samp{.DS B} call generates a page break, if necessary, to
3831 keep the entire display on one page.  The @code{BD} macro allows the
3832 display to break across pages.  The @code{DE} macro ends the display.
3833 @endDefmac
3834
3835 @DefmacList {DS, @t{C}, ms}
3836 @DefmacItemx {CD, , ms}
3837 @DefmacListEndx {DE, , ms}
3838 Sets a centered display: each line in the display is centered.  The
3839 @samp{.DS C} call generates a page break, if necessary, to keep the
3840 entire display on one page.  The @code{CD} macro allows the display to
3841 break across pages.  The @code{DE} macro ends the display.
3842 @endDefmac
3843
3844 @DefmacList {DS, @t{R}, ms}
3845 @DefmacItemx {RD, , ms}
3846 @DefmacListEndx {DE, , ms}
3847 Right-justifies each line in the display.  The @samp{.DS R} call
3848 generates a page break, if necessary, to keep the entire display on one
3849 page.  The @code{RD} macro allows the display to break across pages.
3850 The @code{DE} macro ends the display.
3851 @endDefmac
3852
3853 @DefmacList {Ds, , ms}
3854 @DefmacListEndx {De, , ms}
3855 These two macros were formerly provided as aliases for @code{DS} and
3856 @code{DE}, respectively.  They have been removed, and should no longer
3857 be used.  The original implementations of @code{DS} and @code{DE} are
3858 retained, and should be used instead.  X11 documents that actually use
3859 @code{Ds} and @code{De} always load a specific macro file from the X11
3860 distribution (@file{macros.t}) that provides proper definitions for the
3861 two macros.
3862 @endDefmac
3863
3864 On occasion, you may want to @dfn{keep} other text together on a page.
3865 For example, you may want to keep two paragraphs together, or a
3866 paragraph that refers to a table (or list, or other item) immediately
3867 following.  The @file{ms} macros provide the @code{KS} and @code{KE}
3868 macros for this purpose.
3869
3870 @DefmacList {KS, , ms}
3871 @DefmacListEndx {KE, , ms}
3872 The @code{KS} macro begins a block of text to be kept on a single page,
3873 and the @code{KE} macro ends the block.
3874 @endDefmac
3875
3876 @DefmacList {KF, , ms}
3877 @DefmacListEndx {KE, , ms}
3878 Specifies a @dfn{floating keep}; if the keep cannot fit on the current
3879 page, @code{groff} holds the contents of the keep and allows text
3880 following the keep (in the source file) to fill in the remainder of the
3881 current page.  When the page breaks, whether by an explicit @code{bp}
3882 request or by reaching the end of the page, @code{groff} prints the
3883 floating keep at the top of the new page.  This is useful for printing
3884 large graphics or tables that do not need to appear exactly where
3885 specified.
3886 @endDefmac
3887
3888 You can also use the @code{ne} request to force a page break if there is
3889 not enough vertical space remaining on the page.
3890
3891 Use the following macros to draw a box around a section of text (such as
3892 a display).
3893
3894 @DefmacList {B1, , ms}
3895 @DefmacListEndx {B2, , ms}
3896 Marks the beginning and ending of text that is to have a box drawn
3897 around it.  The @code{B1} macro begins the box; the @code{B2} macro ends
3898 it.  Text in the box is automatically placed in a diversion (keep).
3899 @endDefmac
3900
3901 @c ---------------------------------------------------------------------
3902
3903 @node ms Insertions, Example multi-page table, ms Displays and Keeps, ms Body Text
3904 @subsubsection Tables, figures, equations, and references
3905 @cindex @code{ms} macros, tables
3906 @cindex @code{ms} macros, figures
3907 @cindex @code{ms} macros, equations
3908 @cindex @code{ms} macros, references
3909 @cindex tables [@code{ms}]
3910 @cindex figures [@code{ms}]
3911 @cindex equations [@code{ms}]
3912 @cindex references [@code{ms}]
3913
3914 The @file{ms} macros support the standard @code{groff} preprocessors:
3915 @code{tbl}, @code{pic}, @code{eqn}, and @code{refer}.
3916 @pindex tbl
3917 @pindex pic
3918 @pindex eqn
3919 @pindex refer
3920 You mark text meant for preprocessors by enclosing it in pairs of tags
3921 as follows.
3922
3923 @DefmacList {TS, [@code{H}], ms}
3924 @DefmacListEndx {TE, , ms}
3925 Denotes a table, to be processed by the @code{tbl} preprocessor.  The
3926 optional argument@tie{}@code{H} to @code{TS} instructs @code{groff} to
3927 create a running header with the information up to the @code{TH} macro.
3928 @code{groff} prints the header at the beginning of the table; if the
3929 table runs onto another page, @code{groff} prints the header on the next
3930 page as well.
3931 @endDefmac
3932
3933 @DefmacList {PS, , ms}
3934 @DefmacListEndx {PE, , ms}
3935 Denotes a graphic, to be processed by the @code{pic} preprocessor.  You
3936 can create a @code{pic} file by hand, using the @acronym{AT&T}
3937 @code{pic} manual available on the Web as a reference, or by using a
3938 graphics program such as @code{xfig}.
3939 @endDefmac
3940
3941 @DefmacList {EQ, [@Var{align}], ms}
3942 @DefmacListEndx {EN, , ms}
3943 Denotes an equation, to be processed by the @code{eqn} preprocessor.
3944 The optional @var{align} argument can be @code{C}, @code{L},
3945 or@tie{}@code{I} to center (the default), left-justify, or indent the
3946 equation.
3947 @endDefmac
3948
3949 @DefmacList {[, , ms}
3950 @DefmacListEndx {], , ms}
3951 Denotes a reference, to be processed by the @code{refer} preprocessor.
3952 The GNU @cite{refer(1)} man page provides a comprehensive reference to
3953 the preprocessor and the format of the bibliographic database.
3954 @endDefmac
3955
3956 @menu
3957 * Example multi-page table::
3958 @end menu
3959
3960 @c ---------------------------------------------------------------------
3961
3962 @node Example multi-page table, ms Footnotes, ms Insertions, ms Body Text
3963 @subsubsection An example multi-page table
3964 @cindex example markup, multi-page table [@code{ms}]
3965 @cindex multi-page table, example markup [@code{ms}]
3966
3967 The following is an example of how to set up a table that may print
3968 across two or more pages.
3969
3970 @CartoucheExample
3971 .TS H
3972 allbox expand;
3973 cb | cb .
3974 Text      ...of heading...
3975 _
3976 .TH
3977 .T&
3978 l | l .
3979 ... the rest of the table follows...
3980 .CW
3981 .TE
3982 @endCartoucheExample
3983
3984 @c ---------------------------------------------------------------------
3985
3986 @node ms Footnotes,  , Example multi-page table, ms Body Text
3987 @subsubsection Footnotes
3988 @cindex @code{ms} macros, footnotes
3989 @cindex footnotes [@code{ms}]
3990
3991 The @file{ms} macro package has a flexible footnote system.  You can
3992 specify either numbered footnotes or symbolic footnotes (that is, using
3993 a marker such as a dagger symbol).
3994
3995 @Defstr {*, ms}
3996 Specifies the location of a numbered footnote marker in the text.
3997 @endDefesc
3998
3999 @DefmacList {FS, , ms}
4000 @DefmacListEndx {FE, , ms}
4001 Specifies the text of the footnote.  The default action is to create a
4002 numbered footnote; you can create a symbolic footnote by specifying a
4003 @dfn{mark} glyph (such as @code{\[dg]} for the dagger glyph) in the body
4004 text and as an argument to the @code{FS} macro, followed by the text of
4005 the footnote and the @code{FE} macro.
4006 @endDefmac
4007
4008 You can control how @code{groff} prints footnote numbers by changing the
4009 value of the @code{FF} register.  @xref{ms Document Control Registers}.
4010
4011 @cindex footnotes, and keeps [@code{ms}]
4012 @cindex keeps, and footnotes [@code{ms}]
4013 @cindex footnotes, and displays [@code{ms}]
4014 @cindex displays, and footnotes [@code{ms}]
4015 Footnotes can be safely used within keeps and displays, but you should
4016 avoid using numbered footnotes within floating keeps.  You can set a
4017 second @code{\**} marker between a @code{\**} and its corresponding
4018 @code{.FS} entry; as long as each @code{FS} macro occurs @emph{after}
4019 the corresponding @code{\**} and the occurrences of @code{.FS} are in
4020 the same order as the corresponding occurrences of @code{\**}.
4021
4022 @c ---------------------------------------------------------------------
4023
4024 @node ms Page Layout, Differences from AT&T ms, ms Body Text, ms
4025 @subsection Page layout
4026 @cindex @code{ms} macros, page layout
4027 @cindex page layout [@code{ms}]
4028
4029 The default output from the @file{ms} macros provides a minimalist page
4030 layout: it prints a single column, with the page number centered at the
4031 top of each page.  It prints no footers.
4032
4033 You can change the layout by setting the proper number registers and
4034 strings.
4035
4036 @menu
4037 * ms Headers and Footers::
4038 * ms Margins::
4039 * ms Multiple Columns::
4040 * ms TOC::
4041 * ms Strings and Special Characters::
4042 @end menu
4043
4044 @c ---------------------------------------------------------------------
4045
4046 @node ms Headers and Footers, ms Margins, ms Page Layout, ms Page Layout
4047 @subsubsection Headers and footers
4048 @cindex @code{ms} macros, headers
4049 @cindex @code{ms} macros, footers
4050 @cindex headers [@code{ms}]
4051 @cindex footers [@code{ms}]
4052
4053 For documents that do not distinguish between odd and even pages, set
4054 the following strings:
4055
4056 @DefstrList {LH, ms}
4057 @DefstrItemx {CH, ms}
4058 @DefstrListEndx {RH, ms}
4059 Sets the left, center, and right headers.
4060 @endDefstr
4061
4062 @DefstrList {LF, ms}
4063 @DefstrItemx {CF, ms}
4064 @DefstrListEndx {RF, ms}
4065 Sets the left, center, and right footers.
4066 @endDefstr
4067
4068 For documents that need different information printed in the even and
4069 odd pages, use the following macros:
4070
4071 @DefmacList {OH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
4072 @DefmacItemx {EH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
4073 @DefmacItemx {OF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
4074 @DefmacListEndx {EF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
4075 The @code{OH} and @code{EH} macros define headers for the odd and even
4076 pages; the @code{OF} and @code{EF} macros define footers for the odd and
4077 even pages.  This is more flexible than defining the individual strings.
4078
4079 You can replace the quote (@code{'}) marks with any character not
4080 appearing in the header or footer text.
4081 @endDefmac
4082
4083 To specify custom header and footer processing, redefine the following
4084 macros:
4085
4086 @DefmacList {PT,, ms}
4087 @DefmacItemx {HD,, ms}
4088 @DefmacListEndx {BT,, ms}
4089 The @code{PT} macro defines a custom header; the @code{BT} macro defines
4090 a custom footer.  These macros must handle odd/even/first page
4091 differences if necessary.
4092
4093 The @code{HD} macro defines additional header processing to take place
4094 after executing the @code{PT} macro.
4095 @endDefmac
4096
4097 @c ---------------------------------------------------------------------
4098
4099 @node ms Margins, ms Multiple Columns, ms Headers and Footers, ms Page Layout
4100 @subsubsection Margins
4101 @cindex @code{ms} macros, margins
4102
4103 You control margins using a set of number registers.  @xref{ms Document
4104 Control Registers}, for details.
4105
4106 @c ---------------------------------------------------------------------
4107
4108 @node ms Multiple Columns, ms TOC, ms Margins, ms Page Layout
4109 @subsubsection Multiple columns
4110 @cindex @code{ms} macros, multiple columns
4111 @cindex multiple columns [@code{ms}]
4112
4113 The @file{ms} macros can set text in as many columns as do reasonably
4114 fit on the page.  The following macros are available; all of them force
4115 a page break if a multi-column mode is already set.  However, if the
4116 current mode is single-column, starting a multi-column mode does
4117 @emph{not} force a page break.
4118
4119 @Defmac {1C, , ms}
4120 Single-column mode.
4121 @endDefmac
4122
4123 @Defmac {2C, , ms}
4124 Two-column mode.
4125 @endDefmac
4126
4127 @Defmac {MC, [@Var{width} [@Var{gutter}]], ms}
4128 Multi-column mode.  If you specify no arguments, it is equivalent to the
4129 @code{2C} macro.  Otherwise, @var{width} is the width of each column and
4130 @var{gutter} is the space between columns.  The @code{MINGW} number
4131 register controls the default gutter width.
4132 @endDefmac
4133
4134 @c ---------------------------------------------------------------------
4135
4136 @node ms TOC, ms Strings and Special Characters, ms Multiple Columns, ms Page Layout
4137 @subsubsection Creating a table of contents
4138 @cindex @code{ms} macros, creating table of contents
4139 @cindex table of contents, creating [@code{ms}]
4140
4141 The facilities in the @file{ms} macro package for creating a table of
4142 contents are semi-automated at best.  Assuming that you want the table
4143 of contents to consist of the document's headings, you need to repeat
4144 those headings wrapped in @code{XS} and @code{XE} macros.
4145
4146 @DefmacList {XS, [@Var{page}], ms}
4147 @DefmacItemx {XA, [@Var{page}], ms}
4148 @DefmacListEndx {XE, , ms}
4149 These macros define a table of contents or an individual entry in the
4150 table of contents, depending on their use.  The macros are very simple;
4151 they cannot indent a heading based on its level.  The easiest way to
4152 work around this is to add tabs to the table of contents string.  The
4153 following is an example:
4154
4155 @CartoucheExample
4156 .NH 1
4157 Introduction
4158 .XS
4159 Introduction
4160 .XE
4161 .LP
4162 ...
4163 .CW
4164 .NH 2
4165 Methodology
4166 .XS
4167 Methodology
4168 .XE
4169 .LP
4170 ...
4171 @endCartoucheExample
4172
4173 You can manually create a table of contents by beginning with the
4174 @code{XS} macro for the first entry, specifying the page number for that
4175 entry as the argument to @code{XS}.  Add subsequent entries using the
4176 @code{XA} macro, specifying the page number for that entry as the
4177 argument to @code{XA}.  The following is an example:
4178
4179 @CartoucheExample
4180 .XS 1
4181 Introduction
4182 .XA 2
4183 A Brief History of the Universe
4184 .XA 729
4185 Details of Galactic Formation
4186 ...
4187 .XE
4188 @endCartoucheExample
4189 @endDefmac
4190
4191 @Defmac {TC, [@code{no}], ms}
4192 Prints the table of contents on a new page, setting the page number
4193 to@tie{}@strong{i} (Roman lowercase numeral one).  You should usually
4194 place this macro at the end of the file, since @code{groff} is a
4195 single-pass formatter and can only print what has been collected up to
4196 the point that the @code{TC} macro appears.
4197
4198 The optional argument @code{no} suppresses printing the title specified
4199 by the string register @code{TOC}.
4200 @endDefmac
4201
4202 @Defmac {PX, [@code{no}], ms}
4203 Prints the table of contents on a new page, using the current page
4204 numbering sequence.  Use this macro to print a manually-generated table
4205 of contents at the beginning of your document.
4206
4207 The optional argument @code{no} suppresses printing the title specified
4208 by the string register @code{TOC}.
4209 @endDefmac
4210
4211 The @cite{Groff and Friends HOWTO} includes a @code{sed} script that
4212 automatically inserts @code{XS} and @code{XE} macro entries after each
4213 heading in a document.
4214
4215 Altering the @code{NH} macro to automatically build the table of
4216 contents is perhaps initially more difficult, but would save a great
4217 deal of time in the long run if you use @file{ms} regularly.
4218
4219 @c ---------------------------------------------------------------------
4220
4221 @node ms Strings and Special Characters,  , ms TOC, ms Page Layout
4222 @subsubsection Strings and Special Characters
4223 @cindex @code{ms} macros, strings
4224 @cindex @code{ms} macros, special characters
4225 @cindex @code{ms} macros, accent marks
4226 @cindex accent marks [@code{ms}]
4227 @cindex special characters [@code{ms}]
4228 @cindex strings [@code{ms}]
4229
4230 The @file{ms} macros provide the following predefined strings.  You can
4231 change the string definitions to help in creating documents in languages
4232 other than English.
4233
4234 @Defstr {REFERENCES, ms}
4235 Contains the string printed at the beginning of the references
4236 (bibliography) page.  The default is @samp{References}.
4237 @endDefstr
4238
4239 @Defstr {ABSTRACT, ms}
4240 Contains the string printed at the beginning of the abstract.  The
4241 default is @samp{ABSTRACT}.
4242 @endDefstr
4243
4244 @Defstr {TOC, ms}
4245 Contains the string printed at the beginning of the table of contents.
4246 @endDefstr
4247
4248 @DefstrList {MONTH1, ms}
4249 @DefstrItemx {MONTH2, ms}
4250 @DefstrItemx {MONTH3, ms}
4251 @DefstrItemx {MONTH4, ms}
4252 @DefstrItemx {MONTH5, ms}
4253 @DefstrItemx {MONTH6, ms}
4254 @DefstrItemx {MONTH7, ms}
4255 @DefstrItemx {MONTH8, ms}
4256 @DefstrItemx {MONTH9, ms}
4257 @DefstrItemx {MONTH10, ms}
4258 @DefstrItemx {MONTH11, ms}
4259 @DefstrListEndx {MONTH12, ms}
4260 Prints the full name of the month in dates.  The default is
4261 @samp{January}, @samp{February}, etc.
4262 @endDefstr
4263
4264 The following special characters are available@footnote{For an
4265 explanation what special characters are see @ref{Special Characters}.}:
4266
4267 @Defstr {-, ms}
4268 Prints an em dash.
4269 @endDefstr
4270
4271 @DefstrList {Q, ms}
4272 @DefstrListEndx {U, ms}
4273 Prints typographer's quotes in troff, and plain quotes in nroff.
4274 @code{\*Q} is the left quote and @code{\*U} is the right quote.
4275 @endDefstr
4276
4277 Improved accent marks are available in the @file{ms} macros.
4278
4279 @Defmac {AM, , ms}
4280 Specify this macro at the beginning of your document to enable extended
4281 accent marks and special characters.  This is a Berkeley extension.
4282
4283 To use the accent marks, place them @strong{after} the character being
4284 accented.
4285
4286 Note that groff's native support for accents is superior to the
4287 following definitions.
4288 @endDefmac
4289
4290 The following accent marks are available after invoking the @code{AM}
4291 macro:
4292
4293 @Defstr {', ms}
4294 Acute accent.
4295 @endDefstr
4296
4297 @Defstr {`, ms}
4298 Grave accent.
4299 @endDefstr
4300
4301 @Defstr {^, ms}
4302 Circumflex.
4303 @endDefstr
4304
4305 @Defstr {\,, ms}
4306 Cedilla.
4307 @endDefstr
4308
4309 @Defstr {~, ms}
4310 Tilde.
4311 @endDefstr
4312
4313 @deffn String @t{\*[:]}
4314 @ifnotinfo
4315 @stindex : @r{[}ms@r{]}
4316 @end ifnotinfo
4317 @ifinfo
4318 @stindex \*[@r{<colon>}] @r{[}ms@r{]}
4319 @end ifinfo
4320 Umlaut.
4321 @end deffn
4322
4323 @Defstr {v, ms}
4324 Hacek.
4325 @endDefstr
4326
4327 @Defstr {_, ms}
4328 Macron (overbar).
4329 @endDefstr
4330
4331 @Defstr {., ms}
4332 Underdot.
4333 @endDefstr
4334
4335 @Defstr {o, ms}
4336 Ring above.
4337 @endDefstr
4338
4339 The following are standalone characters available after invoking the
4340 @code{AM} macro:
4341
4342 @Defstr {?, ms}
4343 Upside-down question mark.
4344 @endDefstr
4345
4346 @Defstr {!, ms}
4347 Upside-down exclamation point.
4348 @endDefstr
4349
4350 @Defstr {8, ms}
4351 German ÃŸ ligature.
4352 @endDefstr
4353
4354 @Defstr {3, ms}
4355 Yogh.
4356 @endDefstr
4357
4358 @Defstr {Th, ms}
4359 Uppercase thorn.
4360 @endDefstr
4361
4362 @Defstr {th, ms}
4363 Lowercase thorn.
4364 @endDefstr
4365
4366 @Defstr {D-, ms}
4367 Uppercase eth.
4368 @endDefstr
4369
4370 @Defstr {d-, ms}
4371 Lowercase eth.
4372 @endDefstr
4373
4374 @Defstr {q, ms}
4375 Hooked o.
4376 @endDefstr
4377
4378 @Defstr {ae, ms}
4379 Lowercase Ã¦ ligature.
4380 @endDefstr
4381
4382 @Defstr {Ae, ms}
4383 Uppercase Ã† ligature.
4384 @endDefstr
4385
4386 @c ---------------------------------------------------------------------
4387
4388 @node Differences from AT&T ms, Naming Conventions, ms Page Layout, ms
4389 @subsection Differences from @acronym{AT&T} @file{ms}
4390 @cindex @code{ms} macros, differences from @acronym{AT&T}
4391 @cindex @acronym{AT&T} @code{troff}, @code{ms} macro package differences
4392
4393 This section lists the (minor) differences between the @code{groff -ms}
4394 macros and @acronym{AT&T} @code{troff -ms} macros.
4395
4396 @itemize @bullet
4397 @item
4398 The internals of @code{groff -ms} differ from the internals of
4399 @acronym{AT&T} @code{troff -ms}.  Documents that depend upon
4400 implementation details of @acronym{AT&T} @code{troff -ms} may not format
4401 properly with @code{groff -ms}.
4402
4403 @item
4404 The general error-handling policy of @code{groff -ms} is to detect and
4405 report errors, rather than silently to ignore them.
4406
4407 @item
4408 @code{groff -ms} does not work in compatibility mode (this is, with the
4409 @option{-C} option).
4410
4411 @item
4412 There is no special support for typewriter-like devices.
4413
4414 @item
4415 @code{groff -ms} does not provide cut marks.
4416
4417 @item
4418 Multiple line spacing is not supported.  Use a larger vertical spacing
4419 instead.
4420
4421 @item
4422 Some @acronym{UNIX} @code{ms} documentation says that the @code{CW} and
4423 @code{GW} number registers can be used to control the column width and
4424 gutter width, respectively.  These number registers are not used in
4425 @code{groff -ms}.
4426
4427 @item
4428 Macros that cause a reset (paragraphs, headings, etc.@:) may change the
4429 indentation.  Macros that change the indentation do not increment or
4430 decrement the indentation, but rather set it absolutely.  This can cause
4431 problems for documents that define additional macros of their own.  The
4432 solution is to use not the @code{in} request but instead the @code{RS}
4433 and @code{RE} macros.
4434
4435 @item
4436 To make @code{groff -ms} use the default page offset (which also
4437 specifies the left margin), the @code{PO} register must stay undefined
4438 until the first @file{-ms} macro is evaluated.  This implies that
4439 @code{PO} should not be used early in the document, unless it is changed
4440 also: Remember that accessing an undefined register automatically
4441 defines it.
4442 @end itemize
4443
4444 @Defmpreg {GS, ms}
4445 This number register is set to@tie{}1 by the @code{groff -ms} macros,
4446 but it is not used by the @code{AT&T} @code{troff -ms} macros.
4447 Documents that need to determine whether they are being formatted with
4448 @code{AT&T} @code{troff -ms} or @code{groff -ms} should use this number
4449 register.
4450 @endDefmpreg
4451
4452 Emulations of a few ancient Bell Labs macros can be re-enabled by
4453 calling the otherwise undocumented @code{SC} section-header macro.
4454 Calling @code{SC} enables @code{UC} for marking up a product or
4455 application name, and the pair @code{P1}/@code{P2} for surrounding code
4456 example displays.
4457
4458 These are not enabled by default because (a)@tie{}they were not
4459 documented, in the original @code{ms} manual, and (b)@tie{}the @code{P1}
4460 and @code{UC} macros collide with different macros with the same names
4461 in the Berkeley version of @code{ms}.
4462
4463 These @code{groff} emulations are sufficient to give back the 1976
4464 Kernighan@tie{}& Cherry paper @cite{Typsetting Mathematics -- User's
4465 Guide} its section headings, and restore some text that had gone missing
4466 as arguments of undefined macros.  No warranty express or implied is
4467 given as to how well the typographic details these produce match the
4468 original Bell Labs macros.
4469
4470 @menu
4471 * Missing ms Macros::
4472 * Additional ms Macros::
4473 @end menu
4474
4475 @c ---------------------------------------------------------------------
4476
4477 @node Missing ms Macros, Additional ms Macros, Differences from AT&T ms, Differences from AT&T ms
4478 @subsubsection @code{troff} macros not appearing in @code{groff}
4479
4480 Macros missing from @code{groff -ms} are cover page macros specific to
4481 Bell Labs and Berkeley.  The macros known to be missing are:
4482
4483 @table @code
4484 @item .TM
4485 Technical memorandum; a cover sheet style
4486
4487 @item .IM
4488 Internal memorandum; a cover sheet style
4489
4490 @item .MR
4491 Memo for record; a cover sheet style
4492
4493 @item .MF
4494 Memo for file; a cover sheet style
4495
4496 @item .EG
4497 Engineer's notes; a cover sheet style
4498
4499 @item .TR
4500 Computing Science Tech Report; a cover sheet style
4501
4502 @item .OK
4503 Other keywords
4504
4505 @item .CS
4506 Cover sheet information
4507
4508 @item .MH
4509 A cover sheet macro
4510 @end table
4511
4512 @c ---------------------------------------------------------------------
4513
4514 @node Additional ms Macros,  , Missing ms Macros, Differences from AT&T ms
4515 @subsubsection @code{groff} macros not appearing in @acronym{AT&T} @code{troff}
4516
4517 The @code{groff -ms} macros have a few minor extensions compared to the
4518 @acronym{AT&T} @code{troff -ms} macros.
4519
4520 @Defmac {AM, , ms}
4521 Improved accent marks.  @xref{ms Strings and Special Characters}, for
4522 details.
4523 @endDefmac
4524
4525 @Defmac {DS, @t{I}, ms}
4526 Indented display.  The default behavior of @acronym{AT&T} @code{troff
4527 -ms} was to indent; the @code{groff} default prints displays flush left
4528 with the body text.
4529 @endDefmac
4530
4531 @Defmac {CW, , ms}
4532 Print text in @code{constant width} (Courier) font.
4533 @endDefmac
4534
4535 @Defmac {IX, , ms}
4536 Indexing term (printed on standard error).  You can write a script to
4537 capture and process an index generated in this manner.
4538 @endDefmac
4539
4540 The following additional number registers
4541 appear in @code{groff -ms}:
4542
4543 @Defmpreg {MINGW, ms}
4544 Specifies a minimum space between columns (for multi-column output);
4545 this takes the place of the @code{GW} register that was documented but
4546 apparently not implemented in @acronym{AT&T} @code{troff}.
4547 @endDefmpreg
4548
4549 Several new string registers are available as well.  You can change
4550 these to handle (for example) the local language.  @xref{ms Strings and
4551 Special Characters}, for details.
4552
4553 @c ---------------------------------------------------------------------
4554
4555 @node Naming Conventions,  , Differences from AT&T ms, ms
4556 @subsection Naming Conventions
4557 @cindex @code{ms} macros, naming conventions
4558 @cindex naming conventions, @code{ms} macros
4559
4560 The following conventions are used for names of macros, strings and
4561 number registers.  External names available to documents that use the
4562 @code{groff -ms} macros contain only uppercase letters and digits.
4563
4564 Internally the macros are divided into modules; naming conventions are
4565 as follows:
4566
4567 @itemize @bullet
4568 @item
4569 Names used only within one module are of the form
4570 @var{module}@code{*}@var{name}.
4571
4572 @item
4573 Names used outside the module in which they are defined are of the form
4574 @var{module}@code{@@}@var{name}.
4575
4576 @item
4577 Names associated with a particular environment are of the form
4578 @var{environment}@code{:}@var{name}; these are used only within the
4579 @code{par} module.
4580
4581 @item
4582 @var{name} does not have a module prefix.
4583
4584 @item
4585 Constructed names used to implement arrays are of the form
4586 @var{array}@code{!}@var{index}.
4587 @end itemize
4588
4589 Thus the groff ms macros reserve the following names:
4590
4591 @itemize @bullet
4592 @item
4593 Names containing the characters @code{*}, @code{@@}, and@tie{}@code{:}.
4594
4595 @item
4596 Names containing only uppercase letters and digits.
4597 @end itemize
4598
4599
4600 @c =====================================================================
4601
4602 @node me, mm, ms, Macro Packages
4603 @section @file{me}
4604 @cindex @code{me} macro package
4605
4606 @c XXX documentation
4607 @c XXX this is a placeholder until we get stuff knocked into shape
4608 See the @file{meintro.me} and @file{meref.me} documents in groff's
4609 @file{doc} directory.
4610
4611
4612 @c =====================================================================
4613
4614 @node mm, mom, me, Macro Packages
4615 @section @file{mm}
4616 @cindex @code{mm} macro package
4617
4618 @c XXX documentation
4619 @c XXX this is a placeholder until we get stuff knocked into shape
4620 See the @cite{groff_mm(7)} man page (type @command{man groff_mm} at the
4621 command line).
4622
4623
4624 @c =====================================================================
4625
4626 @node mom,  , mm, Macro Packages
4627 @section @file{mom}
4628 @cindex @code{mom} macro package
4629
4630 @c XXX documentation
4631 @c XXX this is a placeholder until we get stuff knocked into shape
4632 See the @cite{groff_mom(7)} man page (type @command{man groff_mom} at
4633 the command line), which gives a short overview and a link to its
4634 extensive documentation in HTML format.
4635
4636
4637
4638 @c =====================================================================
4639 @c =====================================================================
4640
4641 @node gtroff Reference, Preprocessors, Macro Packages, Top
4642 @chapter @code{gtroff} Reference
4643 @cindex reference, @code{gtroff}
4644 @cindex @code{gtroff}, reference
4645
4646 This chapter covers @strong{all} of the facilities of @code{gtroff}.
4647 Users of macro packages may skip it if not interested in details.
4648
4649
4650 @menu
4651 * Text::
4652 * Measurements::
4653 * Expressions::
4654 * Identifiers::
4655 * Embedded Commands::
4656 * Registers::
4657 * Manipulating Filling and Adjusting::
4658 * Manipulating Hyphenation::
4659 * Manipulating Spacing::
4660 * Tabs and Fields::
4661 * Character Translations::
4662 * Troff and Nroff Mode::
4663 * Line Layout::
4664 * Line Control::
4665 * Page Layout::
4666 * Page Control::
4667 * Fonts and Symbols::
4668 * Sizes::
4669 * Strings::
4670 * Conditionals and Loops::
4671 * Writing Macros::
4672 * Page Motions::
4673 * Drawing Requests::
4674 * Traps::
4675 * Diversions::
4676 * Environments::
4677 * Suppressing output::
4678 * Colors::
4679 * I/O::
4680 * Postprocessor Access::
4681 * Miscellaneous::
4682 * Gtroff Internals::
4683 * Debugging::
4684 * Implementation Differences::
4685 @end menu
4686
4687
4688 @c =====================================================================
4689
4690 @node Text, Measurements, gtroff Reference, gtroff Reference
4691 @section Text
4692 @cindex text, @code{gtroff} processing
4693
4694 @code{gtroff} input files contain text with control commands
4695 interspersed throughout.  But, even without control codes, @code{gtroff}
4696 still does several things with the input text:
4697
4698 @itemize @bullet
4699 @item
4700 filling and adjusting
4701
4702 @item
4703 adding additional space after sentences
4704
4705 @item
4706 hyphenating
4707
4708 @item
4709 inserting implicit line breaks
4710 @end itemize
4711
4712 @menu
4713 * Filling and Adjusting::
4714 * Hyphenation::
4715 * Sentences::
4716 * Tab Stops::
4717 * Implicit Line Breaks::
4718 * Input Conventions::
4719 * Input Encodings::
4720 @end menu
4721
4722 @c ---------------------------------------------------------------------
4723
4724 @node Filling and Adjusting, Hyphenation, Text, Text
4725 @subsection Filling and Adjusting
4726 @cindex filling
4727 @cindex adjusting
4728
4729 When @code{gtroff} reads text, it collects words from the input and fits
4730 as many of them together on one output line as it can.  This is known as
4731 @dfn{filling}.
4732
4733 @cindex leading spaces
4734 @cindex spaces, leading and trailing
4735 @cindex extra spaces
4736 @cindex trailing spaces
4737 Once @code{gtroff} has a @dfn{filled} line, it tries to @dfn{adjust} it.
4738 This means it widens the spacing between words until the text reaches
4739 the right margin (in the default adjustment mode).  Extra spaces between
4740 words are preserved, but spaces at the end of lines are ignored.  Spaces
4741 at the front of a line cause a @dfn{break} (breaks are explained in
4742 @ref{Implicit Line Breaks}).
4743
4744 @xref{Manipulating Filling and Adjusting}.
4745
4746 @c ---------------------------------------------------------------------
4747
4748 @node Hyphenation, Sentences, Filling and Adjusting, Text
4749 @subsection Hyphenation
4750 @cindex hyphenation
4751
4752 Since the odds are not great for finding a set of words, for every
4753 output line, which fit nicely on a line without inserting excessive
4754 amounts of space between words, @code{gtroff} hyphenates words so that
4755 it can justify lines without inserting too much space between words.  It
4756 uses an internal hyphenation algorithm (a simplified version of the
4757 algorithm used within @TeX{}) to indicate which words can be hyphenated
4758 and how to do so.  When a word is hyphenated, the first part of the word
4759 is added to the current filled line being output (with an attached
4760 hyphen), and the other portion is added to the next line to be filled.
4761
4762 @xref{Manipulating Hyphenation}.
4763
4764 @c ---------------------------------------------------------------------
4765
4766 @node Sentences, Tab Stops, Hyphenation, Text
4767 @subsection Sentences
4768 @cindex sentences
4769
4770 Although it is often debated, some typesetting rules say there should be
4771 different amounts of space after various punctuation marks.  For
4772 example, the @cite{Chicago typsetting manual} says that a period at the
4773 end of a sentence should have twice as much space following it as would
4774 a comma or a period as part of an abbreviation.
4775
4776 @c XXX exact citation of Chicago manual
4777
4778 @cindex sentence space
4779 @cindex space between sentences
4780 @cindex french-spacing
4781 @code{gtroff} does this by flagging certain characters (normally
4782 @samp{!}, @samp{?}, and @samp{.}) as @dfn{end-of-sentence} characters.
4783 When @code{gtroff} encounters one of these characters at the end of a
4784 line, it appends a normal space followed by a @dfn{sentence space} in
4785 the formatted output.  (This justifies one of the conventions mentioned
4786 in @ref{Input Conventions}.)
4787
4788 @cindex transparent characters
4789 @cindex character, transparent
4790 @cindex @code{dg} glyph, at end of sentence
4791 @cindex @code{rq} glyph, at end of sentence
4792 @cindex @code{cq} glyph, at end of sentence
4793 @cindex @code{"}, at end of sentence
4794 @cindex @code{'}, at end of sentence
4795 @cindex @code{)}, at end of sentence
4796 @cindex @code{]}, at end of sentence
4797 @cindex @code{*}, at end of sentence
4798 In addition, the following characters and symbols are treated
4799 transparently while handling end-of-sentence characters: @samp{"},
4800 @samp{'}, @samp{)}, @samp{]}, @samp{*}, @code{\[dg]}, @code{\[rq]}, and
4801 @code{\[cq]}.
4802
4803 See the @code{cflags} request in @ref{Using Symbols}, for more details.
4804
4805 @cindex @code{\&}, at end of sentence
4806 To prevent the insertion of extra space after an end-of-sentence
4807 character (at the end of a line), append @code{\&}.
4808
4809 @c ---------------------------------------------------------------------
4810
4811 @node Tab Stops, Implicit Line Breaks, Sentences, Text
4812 @subsection Tab Stops
4813 @cindex tab stops
4814 @cindex stops, tabulator
4815 @cindex tab character
4816 @cindex character, tabulator
4817
4818 @cindex @acronym{EBCDIC} encoding
4819 @cindex encoding, @acronym{EBCDIC}
4820 @code{gtroff} translates @dfn{tabulator characters}, also called
4821 @dfn{tabs} (normally code point @acronym{ASCII} @code{0x09} or
4822 @acronym{EBCDIC} @code{0x05}), in the input into movements to the next
4823 tabulator stop.  These tab stops are initially located every half inch
4824 across the page.  Using this, simple tables can be made easily.
4825 However, it can often be deceptive as the appearance (and width) of the
4826 text on a terminal and the results from @code{gtroff} can vary greatly.
4827
4828 Also, a possible sticking point is that lines beginning with tab
4829 characters are still filled, again producing unexpected results.  For
4830 example, the following input
4831
4832 @multitable {12345678} {12345678} {12345678} {12345678}
4833 @item
4834 @tab 1 @tab 2 @tab 3
4835 @item
4836 @tab   @tab 4 @tab 5
4837 @end multitable
4838
4839 @noindent
4840 produces
4841
4842 @multitable {12345678} {12345678} {12345678} {12345678} {12345678} {12345678} {12345678}
4843 @item
4844 @tab 1 @tab 2 @tab 3 @tab   @tab 4 @tab 5
4845 @end multitable
4846
4847 @xref{Tabs and Fields}.
4848
4849 @c ---------------------------------------------------------------------
4850
4851 @node Implicit Line Breaks, Input Conventions, Tab Stops, Text
4852 @subsection Implicit Line Breaks
4853 @cindex implicit line breaks
4854 @cindex implicit breaks of lines
4855 @cindex line, implicit breaks
4856 @cindex break, implicit
4857 @cindex line break
4858
4859 An important concept in @code{gtroff} is the @dfn{break}.  When a break
4860 occurs, @code{gtroff} outputs the partially filled line (unjustified),
4861 and resumes collecting and filling text on the next output line.
4862
4863 @cindex blank line
4864 @cindex empty line
4865 @cindex line, blank
4866 @cindex blank line macro (@code{blm})
4867 There are several ways to cause a break in @code{gtroff}.  A blank line
4868 not only causes a break, but it also outputs a one-line vertical space
4869 (effectively a blank line).  Note that this behaviour can be modified
4870 with the blank line macro request @code{blm}.  @xref{Blank Line Traps}.
4871
4872 @cindex fill mode
4873 @cindex mode, fill
4874 @cindex leading spaces macro (@code{lsm})
4875 A line that begins with a space causes a break and the space is output
4876 at the beginning of the next line.  Note that this space isn't adjusted,
4877 even in fill mode; however, the behaviour can be modified with the
4878 leading spaces macro request @code{lsm}.  @xref{Leading Spaces Traps}.
4879
4880 The end of file also causes a break -- otherwise the last line of the
4881 document may vanish!
4882
4883 Certain requests also cause breaks, implicitly or explicitly.  This is
4884 discussed in @ref{Manipulating Filling and Adjusting}.
4885
4886 @c ---------------------------------------------------------------------
4887
4888 @node Input Conventions, Input Encodings, Implicit Line Breaks, Text
4889 @subsection Input Conventions
4890 @cindex input conventions
4891 @cindex conventions for input
4892
4893 Since @code{gtroff} does filling automatically, it is traditional in
4894 @code{groff} not to try and type things in as nicely formatted
4895 paragraphs.  These are some conventions commonly used when typing
4896 @code{gtroff} text:
4897
4898 @itemize @bullet
4899 @item
4900 Break lines after punctuation, particularly at the end of a sentence and
4901 in other logical places.  Keep separate phrases on lines by themselves,
4902 as entire phrases are often added or deleted when editing.
4903
4904 @item
4905 Try to keep lines less than 40-60@tie{}characters, to allow space for
4906 inserting more text.
4907
4908 @item
4909 Do not try to do any formatting in a @acronym{WYSIWYG} manner (i.e.,
4910 don't try using spaces to get proper indentation).
4911 @end itemize
4912
4913 @c ---------------------------------------------------------------------
4914
4915 @node Input Encodings,  , Input Conventions, Text
4916 @subsection Input Encodings
4917
4918 Currently, the following input encodings are available.
4919
4920 @table @asis
4921 @item cp1047
4922 @cindex encoding, input, @acronym{EBCDIC}
4923 @cindex @acronym{EBCDIC}, input encoding
4924 @cindex input encoding, @acronym{EBCDIC}
4925 @cindex encoding, input, cp1047
4926 @cindex cp1047, input encoding
4927 @cindex input encoding, cp1047
4928 @cindex IBM cp1047 input encoding
4929 @pindex cp1047.tmac
4930 This input encoding works only on @acronym{EBCDIC} platforms (and vice
4931 versa, the other input encodings don't work with @acronym{EBCDIC}); the
4932 file @file{cp1047.tmac} is by default loaded at start-up.
4933
4934 @item latin-1
4935 @cindex encoding, input, @w{latin-1} (ISO @w{8859-1})
4936 @cindex @w{latin-1} (ISO @w{8859-1}), input encoding
4937 @cindex ISO @w{8859-1} (@w{latin-1}), input encoding
4938 @cindex input encoding, @w{latin-1} (ISO @w{8859-1})
4939 @pindex latin1.tmac
4940 This is the default input encoding on non-@acronym{EBCDIC} platforms;
4941 the file @file{latin1.tmac} is loaded at start-up.
4942
4943 @item latin-2
4944 @cindex encoding, input, @w{latin-2} (ISO @w{8859-2})
4945 @cindex @w{latin-2} (ISO @w{8859-2}), input encoding
4946 @cindex ISO @w{8859-2} (@w{latin-2}), input encoding
4947 @cindex input encoding, @w{latin-2} (ISO @w{8859-2})
4948 @pindex latin2.tmac
4949 To use this encoding, either say @w{@samp{.mso latin2.tmac}} at the very
4950 beginning of your document or use @samp{-mlatin2} as a command line
4951 argument for @code{groff}.
4952
4953 @item latin-5
4954 @cindex encoding, input, @w{latin-5} (ISO @w{8859-9})
4955 @cindex @w{latin-2} (ISO @w{8859-9}), input encoding
4956 @cindex ISO @w{8859-9} (@w{latin-2}), input encoding
4957 @cindex input encoding, @w{latin-2} (ISO @w{8859-9})
4958 @pindex latin2.tmac
4959 For Turkish.  Either say @w{@samp{.mso latin9.tmac}} at the very
4960 beginning of your document or use @samp{-mlatin9} as a command line
4961 argument for @code{groff}.
4962
4963 @item latin-9 (latin-0)
4964 @cindex encoding, input, @w{latin-9} (@w{latin-0}, ISO @w{8859-15})
4965 @cindex @w{latin-9} (@w{latin-0}, ISO @w{8859-15}), input encoding
4966 @cindex ISO @w{8859-15} (@w{latin-9}, @w{latin-0}), input encoding
4967 @cindex input encoding, @w{latin-9} (@w{latin-9}, ISO @w{8859-15})
4968 @pindex latin9.tmac
4969 This encoding is intended (at least in Europe) to replace @w{latin-1}
4970 encoding.  The main difference to @w{latin-1} is that @w{latin-9}
4971 contains the Euro character.  To use this encoding, either say
4972 @w{@samp{.mso latin9.tmac}} at the very beginning of your document or
4973 use @samp{-mlatin9} as a command line argument for @code{groff}.
4974 @end table
4975
4976 Note that it can happen that some input encoding characters are not
4977 available for a particular output device.  For example, saying
4978
4979 @Example
4980 groff -Tlatin1 -mlatin9 ...
4981 @endExample
4982
4983 @noindent
4984 fails if you use the Euro character in the input.  Usually, this
4985 limitation is present only for devices that have a limited set of
4986 output glyphs (e.g.@: @option{-Tascii} and @option{-Tlatin1}); for other
4987 devices it is usually sufficient to install proper fonts that contain
4988 the necessary glyphs.
4989
4990 @pindex freeeuro.pfa
4991 @pindex ec.tmac
4992 Due to the importance of the Euro glyph in Europe, the groff package now
4993 comes with a @sc{PostScript} font called @file{freeeuro.pfa}, which
4994 provides various glyph shapes for the Euro.  In other words,
4995 @w{latin-9} encoding is supported for the @option{-Tps} device out of
4996 the box (@w{latin-2} isn't).
4997
4998 By its very nature, @option{-Tutf8} supports all input encodings;
4999 @option{-Tdvi} has support for both @w{latin-2} and @w{latin-9} if the
5000 command line @option{-mec} is used also to load the file @file{ec.tmac}
5001 (which flips to the EC fonts).
5002
5003
5004 @c =====================================================================
5005
5006 @node Measurements, Expressions, Text, gtroff Reference
5007 @section Measurements
5008 @cindex measurements
5009 @cindex scaling indicator
5010 @cindex indicator, scaling
5011
5012 @cindex units of measurement
5013 @cindex basic unit (@code{u})
5014 @cindex machine unit (@code{u})
5015 @cindex measurement unit
5016 @cindex @code{u} unit
5017 @cindex unit, @code{u}
5018 @code{gtroff} (like many other programs) requires numeric parameters to
5019 specify various measurements.  Most numeric parameters@footnote{those
5020 that specify vertical or horizontal motion or a type size} may have a
5021 @dfn{measurement unit} attached.  These units are specified as a single
5022 character that immediately follows the number or expression.  Each of
5023 these units are understood, by @code{gtroff}, to be a multiple of its
5024 @dfn{basic unit}.  So, whenever a different measurement unit is
5025 specified @code{gtroff} converts this into its @dfn{basic units}.  This
5026 basic unit, represented by a @samp{u}, is a device dependent measurement,
5027 which is quite small, ranging from 1/75@dmn{th} to 1/72000@dmn{th} of an
5028 inch.  The values may be given as fractional numbers; however,
5029 fractional basic units are always rounded to integers.
5030
5031 Some of the measurement units are completely independent of any of the
5032 current settings (e.g.@: type size) of @code{gtroff}.
5033
5034 @table @code
5035 @item i
5036 @cindex inch unit (@code{i})
5037 @cindex @code{i} unit
5038 @cindex unit, @code{i}
5039 Inches.  An antiquated measurement unit still in use in certain
5040 backwards countries with incredibly low-cost computer equipment.  One
5041 inch is equal to@tie{}2.54@dmn{cm}.
5042
5043 @item c
5044 @cindex centimeter unit (@code{c})
5045 @cindex @code{c} unit
5046 @cindex unit, @code{c}
5047 Centimeters.  One centimeter is equal to@tie{}0.3937@dmn{in}.
5048
5049 @item p
5050 @cindex point unit (@code{p})
5051 @cindex @code{p} unit
5052 @cindex unit, @code{p}
5053 Points.  This is a typesetter's measurement used for measure type size.
5054 It is 72@tie{}points to an inch.
5055
5056 @item P
5057 @cindex pica unit (@code{P})
5058 @cindex @code{P} unit
5059 @cindex unit, @code{P}
5060 Pica.  Another typesetting measurement.  6@tie{}Picas to an inch (and
5061 12@tie{}points to a pica).
5062
5063 @item s
5064 @itemx z
5065 @cindex @code{s} unit
5066 @cindex unit, @code{s}
5067 @cindex @code{z} unit
5068 @cindex unit, @code{z}
5069 @xref{Fractional Type Sizes}, for a discussion of these units.
5070
5071 @item f
5072 @cindex @code{f} unit
5073 @cindex unit, @code{f}
5074 Fractions.  Value is 65536.
5075 @xref{Colors}, for usage.
5076 @end table
5077
5078 The other measurements understood by @code{gtroff} depend on settings
5079 currently in effect in @code{gtroff}.  These are very useful for
5080 specifying measurements that should look proper with any size of text.
5081
5082 @table @code
5083 @item m
5084 @cindex em unit (@code{m})
5085 @cindex @code{m} unit
5086 @cindex unit, @code{m}
5087 Ems.  This unit is equal to the current font size in points.  So called
5088 because it is @emph{approximately} the width of the letter@tie{}@samp{m}
5089 in the current font.
5090
5091 @item n
5092 @cindex en unit (@code{n})
5093 @cindex @code{n} unit
5094 @cindex unit, @code{n}
5095 Ens.  In @code{groff}, this is half of an em.
5096
5097 @item v
5098 @cindex vertical space unit (@code{v})
5099 @cindex space, vertical, unit (@code{v})
5100 @cindex @code{v} unit
5101 @cindex unit, @code{v}
5102 Vertical space.  This is equivalent to the current line spacing.
5103 @xref{Sizes}, for more information about this.
5104
5105 @item M
5106 @cindex @code{M} unit
5107 @cindex unit, @code{M}
5108 100ths of an em.
5109 @end table
5110
5111 @menu
5112 * Default Units::
5113 @end menu
5114
5115 @c ---------------------------------------------------------------------
5116
5117 @node Default Units,  , Measurements, Measurements
5118 @subsection Default Units
5119 @cindex default units
5120 @cindex units, default
5121
5122 Many requests take a default unit.  While this can be helpful at times,
5123 it can cause strange errors in some expressions.  For example, the line
5124 length request expects em units.  Here are several attempts to get a
5125 line length of 3.5@tie{}inches and their results:
5126
5127 @Example
5128 3.5i      @result{}   3.5i
5129 7/2       @result{}   0i
5130 7/2i      @result{}   0i
5131 (7 / 2)u  @result{}   0i
5132 7i/2      @result{}   0.1i
5133 7i/2u     @result{}   3.5i
5134 @endExample
5135
5136 @noindent
5137 Everything is converted to basic units first.  In the above example it
5138 is assumed that 1@dmn{i} equals@tie{}240@dmn{u}, and 1@dmn{m}
5139 equals@tie{}10@dmn{p} (thus 1@dmn{m} equals@tie{}33@dmn{u}).  The value
5140 7@dmn{i}/2 is first handled as 7@dmn{i}/2@dmn{m}, then converted to
5141 1680@dmn{u}/66@dmn{u}, which is 25@dmn{u}, and this is approximately
5142 0.1@dmn{i}.  As can be seen, a scaling indicator after a closing
5143 parenthesis is simply ignored.
5144
5145 @cindex measurements, specifying safely
5146 Thus, the safest way to specify measurements is to always attach a
5147 scaling indicator.  If you want to multiply or divide by a certain
5148 scalar value, use @samp{u} as the unit for that value.
5149
5150
5151 @c =====================================================================
5152
5153 @node Expressions, Identifiers, Measurements, gtroff Reference
5154 @section Expressions
5155 @cindex expressions
5156
5157 @code{gtroff} has most arithmetic operators common to other languages:
5158
5159 @itemize @bullet
5160 @item
5161 @cindex arithmetic operators
5162 @cindex operators, arithmetic
5163 @opindex +
5164 @opindex -
5165 @opindex /
5166 @opindex *
5167 @opindex %
5168 Arithmetic: @samp{+} (addition), @samp{-} (subtraction), @samp{/}
5169 (division), @samp{*} (multiplication), @samp{%} (modulo).
5170
5171 @code{gtroff} only provides integer arithmetic.  The internal type used
5172 for computing results is @samp{int}, which is usually a 32@dmn{bit}
5173 signed integer.
5174
5175 @item
5176 @cindex comparison operators
5177 @cindex operators, comparison
5178 @opindex <
5179 @opindex >
5180 @opindex >=
5181 @opindex <=
5182 @opindex =
5183 @opindex ==
5184 Comparison: @samp{<} (less than), @samp{>} (greater than), @samp{<=}
5185 (less than or equal), @samp{>=} (greater than or equal), @samp{=}
5186 (equal), @samp{==} (the same as @samp{=}).
5187
5188 @item
5189 @cindex logical operators
5190 @cindex operators, logical
5191 @opindex &
5192 @ifnotinfo
5193 @opindex :
5194 @end ifnotinfo
5195 @ifinfo
5196 @opindex @r{<colon>}
5197 @end ifinfo
5198 Logical: @samp{&} (logical and), @samp{:} (logical or).
5199
5200 @item
5201 @cindex unary operators
5202 @cindex operators, unary
5203 @opindex -
5204 @opindex +
5205 @opindex !
5206 @cindex @code{if} request, and the @samp{!} operator
5207 @cindex @code{while} request, and the @samp{!} operator
5208 Unary operators: @samp{-} (negating, i.e.@: changing the sign), @samp{+}
5209 (just for completeness; does nothing in expressions), @samp{!} (logical
5210 not; this works only within @code{if} and @code{while}
5211 requests).@footnote{Note that, for example, @samp{!(-1)} evaluates to
5212 `true' because @code{gtroff} treats both negative numbers and zero as
5213 `false'.}  See below for the use of unary operators in motion requests.
5214
5215 @cindex logical not, limitation in expression
5216 @cindex expression, limitation of logical not in
5217 The logical not operator,
5218 as described above,
5219 works only within @code{if} and @code{while} requests.
5220 Furthermore, it may appear
5221 only at the beginning of an expression,
5222 and negates the entire expression.
5223 Attempting to insert the @samp{!} operator
5224 within the expression results in a
5225 @samp{numeric expression expected} warning.  This
5226 maintains compatibility
5227 with old versions of @code{troff}.
5228
5229 Example:
5230
5231 @Example
5232 .nr X 1
5233 .nr Y 0
5234 .\" This does not work as expected
5235 .if (\n[X])&(!\n[Y]) .nop X only
5236 .
5237 .\" Use this construct instead
5238 .if (\n[X]=1)&(\n[Y]=0) .nop X only
5239 @endExample
5240
5241 @item
5242 @cindex extremum operators (@code{>?}, @code{<?})
5243 @cindex operators, extremum (@code{>?}, @code{<?})
5244 @opindex >?
5245 @opindex <?
5246 Extrema: @samp{>?} (maximum), @samp{<?} (minimum).
5247
5248 Example:
5249
5250 @Example
5251 .nr x 5
5252 .nr y 3
5253 .nr z (\n[x] >? \n[y])
5254 @endExample
5255
5256 @noindent
5257 The register@tie{}@code{z} now contains@tie{}5.
5258
5259 @item
5260 @cindex scaling operator
5261 @cindex operator, scaling
5262 Scaling: @code{(@var{c};@var{e})}.  Evaluate@tie{}@var{e}
5263 using@tie{}@var{c} as the default scaling indicator.  If @var{c} is
5264 missing, ignore scaling indicators in the evaluation of@tie{}@var{e}.
5265 @end itemize
5266
5267 @cindex parentheses
5268 @cindex order of evaluation in expressions
5269 @cindex expression, order of evaluation
5270 @opindex (
5271 @opindex )
5272 Parentheses may be used as in any other language.  However, in
5273 @code{gtroff} they are necessary to ensure order of evaluation.
5274 @code{gtroff} has no operator precedence; expressions are evaluated left
5275 to right.  This means that @code{gtroff} evaluates @samp{3+5*4} as if it
5276 were parenthesized like @samp{(3+5)*4}, not as @samp{3+(5*4)}, as might
5277 be expected.
5278
5279 @cindex @code{+}, and page motion
5280 @cindex @code{-}, and page motion
5281 @cindex motion operators
5282 @cindex operators, motion
5283 For many requests that cause a motion on the page, the unary operators
5284 @samp{+} and @samp{-} work differently if leading an expression.  They
5285 then indicate a motion relative to the current position (down or up,
5286 respectively).
5287
5288 @cindex @code{|}, and page motion
5289 @cindex absolute position operator (@code{|})
5290 @cindex position, absolute, operator (@code{|})
5291 Similarly, a leading @samp{|} operator indicates an absolute position.
5292 For vertical movements, it specifies the distance from the top of the
5293 page; for horizontal movements, it gives the distance from the beginning
5294 of the @emph{input} line.
5295
5296 @cindex @code{bp} request, using @code{+} and@tie{}@code{-}
5297 @cindex @code{in} request, using @code{+} and@tie{}@code{-}
5298 @cindex @code{ll} request, using @code{+} and@tie{}@code{-}
5299 @cindex @code{lt} request, using @code{+} and@tie{}@code{-}
5300 @cindex @code{nm} request, using @code{+} and@tie{}@code{-}
5301 @cindex @code{nr} request, using @code{+} and@tie{}@code{-}
5302 @cindex @code{pl} request, using @code{+} and@tie{}@code{-}
5303 @cindex @code{pn} request, using @code{+} and@tie{}@code{-}
5304 @cindex @code{po} request, using @code{+} and@tie{}@code{-}
5305 @cindex @code{ps} request, using @code{+} and@tie{}@code{-}
5306 @cindex @code{pvs} request, using @code{+} and@tie{}@code{-}
5307 @cindex @code{rt} request, using @code{+} and@tie{}@code{-}
5308 @cindex @code{ti} request, using @code{+} and@tie{}@code{-}
5309 @cindex @code{\H}, using @code{+} and@tie{}@code{-}
5310 @cindex @code{\R}, using @code{+} and@tie{}@code{-}
5311 @cindex @code{\s}, using @code{+} and@tie{}@code{-}
5312 @samp{+} and @samp{-} are also treated differently by the following
5313 requests and escapes: @code{bp}, @code{in}, @code{ll}, @code{lt},
5314 @code{nm}, @code{nr}, @code{pl}, @code{pn}, @code{po}, @code{ps},
5315 @code{pvs}, @code{rt}, @code{ti}, @code{\H}, @code{\R}, and @code{\s}.
5316 Here, leading plus and minus signs indicate increments and decrements.
5317
5318 @xref{Setting Registers}, for some examples.
5319
5320 @Defesc {\\B, ', anything, '}
5321 @cindex numeric expression, valid
5322 @cindex valid numeric expression
5323 Return@tie{}1 if @var{anything} is a valid numeric expression; or@tie{}0
5324 if @var{anything} is empty or not a valid numeric expression.
5325 @endDefesc
5326
5327 @cindex space characters, in expressions
5328 @cindex expressions, and space characters
5329 Due to the way arguments are parsed, spaces are not allowed in
5330 expressions, unless the entire expression is surrounded by parentheses.
5331
5332 @xref{Request and Macro Arguments}, and @ref{Conditionals and Loops}.
5333
5334
5335 @c =====================================================================
5336
5337 @node Identifiers, Embedded Commands, Expressions, gtroff Reference
5338 @section Identifiers
5339 @cindex identifiers
5340
5341 Like any other language, @code{gtroff} has rules for properly formed
5342 @dfn{identifiers}.  In @code{gtroff}, an identifier can be made up of
5343 almost any printable character, with the exception of the following
5344 characters:
5345
5346 @itemize @bullet
5347 @item
5348 @cindex whitespace characters
5349 @cindex newline character
5350 @cindex character, whitespace
5351 Whitespace characters (spaces, tabs, and newlines).
5352
5353 @item
5354 @cindex character, backspace
5355 @cindex backspace character
5356 @cindex @acronym{EBCDIC} encoding of backspace
5357 Backspace (@acronym{ASCII}@tie{}@code{0x08} or
5358 @acronym{EBCDIC}@tie{}@code{0x16}) and character code @code{0x01}.
5359
5360 @item
5361 @cindex invalid input characters
5362 @cindex input characters, invalid
5363 @cindex characters, invalid input
5364 @cindex Unicode
5365 The following input characters are invalid and are ignored if
5366 @code{groff} runs on a machine based on @acronym{ASCII}, causing a
5367 warning message of type @samp{input} (see @ref{Debugging}, for more
5368 details): @code{0x00}, @code{0x0B}, @code{0x0D}-@code{0x1F},
5369 @code{0x80}-@code{0x9F}.
5370
5371 And here are the invalid input characters if @code{groff} runs on an
5372 @acronym{EBCDIC} host: @code{0x00}, @code{0x08}, @code{0x09},
5373 @code{0x0B}, @code{0x0D}-@code{0x14}, @code{0x17}-@code{0x1F},
5374 @code{0x30}-@code{0x3F}.
5375
5376 Currently, some of these reserved codepoints are used internally, thus
5377 making it non-trivial to extend @code{gtroff} to cover Unicode or other
5378 character sets and encodings that use characters of these ranges.
5379
5380 Note that invalid characters are removed before parsing; an identifier
5381 @code{foo}, followed by an invalid character, followed by @code{bar} is
5382 treated as @code{foobar}.
5383 @end itemize
5384
5385 For example, any of the following is valid.
5386
5387 @Example
5388 br
5389 PP
5390 (l
5391 end-list
5392 @@_
5393 @endExample
5394
5395 @cindex @code{]}, as part of an identifier
5396 @noindent
5397 Note that identifiers longer than two characters with a closing bracket
5398 (@samp{]}) in its name can't be accessed with escape sequences that
5399 expect an identifier as a parameter.  For example, @samp{\[foo]]}
5400 accesses the glyph @samp{foo}, followed by @samp{]}, whereas
5401 @samp{\C'foo]'} really asks for glyph @samp{foo]}.
5402
5403 @cindex @code{refer}, and macro names starting with @code{[} or @code{]}
5404 @cindex @code{[}, macro names starting with, and @code{refer}
5405 @cindex @code{]}, macro names starting with, and @code{refer}
5406 @cindex macro names, starting with @code{[} or @code{]}, and @code{refer}
5407 To avoid problems with the @code{refer} preprocessor, macro names should
5408 not start with @samp{[} or @samp{]}.  Due to backwards compatibility,
5409 everything after @samp{.[} and @samp{.]} is handled as a special
5410 argument to @code{refer}.  For example, @samp{.[foo} makes @code{refer}
5411 to start a reference, using @samp{foo} as a parameter.
5412
5413 @Defesc {\\A, ', ident, '}
5414 Test whether an identifier @var{ident} is valid in @code{gtroff}.  It
5415 expands to the character@tie{}1 or@tie{}0 according to whether its
5416 argument (usually delimited by quotes) is or is not acceptable as the
5417 name of a string, macro, diversion, number register, environment, or
5418 font.  It returns@tie{}0 if no argument is given.  This is useful for
5419 looking up user input in some sort of associative table.
5420
5421 @Example
5422 \A'end-list'
5423     @result{} 1
5424 @endExample
5425 @endDefesc
5426
5427 @xref{Escapes}, for details on parameter delimiting characters.
5428
5429 Identifiers in @code{gtroff} can be any length, but, in some contexts,
5430 @code{gtroff} needs to be told where identifiers end and text begins
5431 (and in different ways depending on their length):
5432
5433 @itemize @bullet
5434 @item
5435 Single character.
5436
5437 @cindex @code{(}, starting a two-character identifier
5438 @item
5439 Two characters.  Must be prefixed with @samp{(} in some situations.
5440
5441 @cindex @code{[}, starting an identifier
5442 @cindex @code{]}, ending an identifier
5443 @item
5444 Arbitrary length (@code{gtroff} only).  Must be bracketed with @samp{[}
5445 and@tie{}@samp{]} in some situations.  Any length identifier can be put
5446 in brackets.
5447 @end itemize
5448
5449 @cindex undefined identifiers
5450 @cindex identifiers, undefined
5451 Unlike many other programming languages, undefined identifiers are
5452 silently ignored or expanded to nothing.  When @code{gtroff} finds an
5453 undefined identifier, it emits a warning, doing the following:
5454
5455 @itemize @bullet
5456 @item
5457 If the identifier is a string, macro, or diversion, @code{gtroff}
5458 defines it as empty.
5459
5460 @item
5461 If the identifier is a number register, @code{gtroff} defines it with a
5462 value of@tie{}0.
5463 @end itemize
5464
5465 @xref{Warnings}., @ref{Interpolating Registers}, and @ref{Strings}.
5466
5467 Note that macros, strings, and diversions share the same name space.
5468
5469 @Example
5470 .de xxx
5471 .  nop foo
5472 ..
5473 .
5474 .di xxx
5475 bar
5476 .br
5477 .di
5478 .
5479 .xxx
5480     @result{} bar
5481 @endExample
5482
5483 @noindent
5484 As can be seen in the previous example, @code{gtroff} reuses the
5485 identifier @samp{xxx}, changing it from a macro to a diversion.  No
5486 warning is emitted!  The contents of the first macro definition is lost.
5487
5488 @xref{Interpolating Registers}, and @ref{Strings}.
5489
5490
5491 @c =====================================================================
5492
5493 @node Embedded Commands, Registers, Identifiers, gtroff Reference
5494 @section Embedded Commands
5495 @cindex embedded commands
5496 @cindex commands, embedded
5497
5498 Most documents need more functionality beyond filling, adjusting and
5499 implicit line breaking.  In order to gain further functionality,
5500 @code{gtroff} allows commands to be embedded into the text, in two ways.
5501
5502 The first is a @dfn{request} that takes up an entire line, and does
5503 some large-scale operation (e.g.@: break lines, start new pages).
5504
5505 The other is an @dfn{escape} that can be usually embedded anywhere in
5506 the text; most requests can accept it even as an argument.  Escapes
5507 generally do more minor operations like sub- and superscripts, print a
5508 symbol, etc.
5509
5510 @menu
5511 * Requests::
5512 * Macros::
5513 * Escapes::
5514 @end menu
5515
5516 @c ---------------------------------------------------------------------
5517
5518 @node Requests, Macros, Embedded Commands, Embedded Commands
5519 @subsection Requests
5520 @cindex requests
5521
5522 @cindex control character (@code{.})
5523 @cindex character, control (@code{.})
5524 @cindex no-break control character (@code{'})
5525 @cindex character, no-break control (@code{'})
5526 @cindex control character, no-break (@code{'})
5527 A request line begins with a control character, which is either a single
5528 quote (@samp{'}, the @dfn{no-break control character}) or a period
5529 (@samp{.}, the normal @dfn{control character}).  These can be changed;
5530 see @ref{Character Translations}, for details.  After this there may be
5531 optional tabs or spaces followed by an identifier, which is the name of
5532 the request.  This may be followed by any number of space-separated
5533 arguments (@emph{no} tabs here).
5534
5535 @cindex structuring source code of documents or macro packages
5536 @cindex documents, structuring the source code
5537 @cindex macro packages, structuring the source code
5538 Since a control character followed by whitespace only is ignored, it is
5539 common practice to use this feature for structuring the source code of
5540 documents or macro packages.
5541
5542 @Example
5543 .de foo
5544 .  tm This is foo.
5545 ..
5546 .
5547 .
5548 .de bar
5549 .  tm This is bar.
5550 ..
5551 @endExample
5552
5553 @cindex blank line
5554 @cindex blank line macro (@code{blm})
5555 Another possibility is to use the blank line macro request @code{blm} by
5556 assigning an empty macro to it.
5557
5558 @Example
5559 .de do-nothing
5560 ..
5561 .blm do-nothing  \" activate blank line macro
5562
5563 .de foo
5564 .  tm This is foo.
5565 ..
5566
5567
5568 .de bar
5569 .  tm This is bar.
5570 ..
5571
5572 .blm             \" deactivate blank line macro
5573 @endExample
5574
5575 @xref{Blank Line Traps}.
5576
5577 @cindex zero width space character (@code{\&})
5578 @cindex character, zero width space (@code{\&})
5579 @cindex space character, zero width (@code{\&})
5580 @cindex @code{\&}, escaping control characters
5581 To begin a line with a control character without it being interpreted,
5582 precede it with @code{\&}.  This represents a zero width space, which
5583 means it does not affect the output.
5584
5585 In most cases the period is used as a control character.  Several
5586 requests cause a break implicitly; using the single quote control
5587 character prevents this.
5588
5589 @Defreg {.br}
5590 A read-only number register, which is set to@tie{}1 if a macro is called
5591 with the normal control character (as defined with the @code{cc}
5592 request), and set to@tie{}0 otherwise.
5593
5594 @cindex modifying requests
5595 @cindex requests, modifying
5596 This allows to reliably modify requests.
5597
5598 @Example
5599 .als bp*orig bp
5600 .de bp
5601 .  tm before bp
5602 .  ie \\n[.br] .bp*orig
5603 .  el 'bp*orig
5604 .  tm after bp
5605 ..
5606 @endExample
5607
5608 Using this register outside of a macro makes no sense (it always returns
5609 zero in such cases).
5610
5611 If a macro is called as a string (this is, using @code{\*}), the value
5612 of the @code{.br} register is inherited from the calling macro.
5613 @endDefreg
5614
5615 @menu
5616 * Request and Macro Arguments::
5617 @end menu
5618
5619 @node Request and Macro Arguments,  , Requests, Requests
5620 @subsubsection Request and Macro Arguments
5621 @cindex request arguments
5622 @cindex macro arguments
5623 @cindex arguments to requests and macros
5624
5625 @cindex tabs, and macro arguments
5626 @cindex macro arguments, and tabs
5627 @cindex arguments to macros, and tabs
5628 Arguments to requests and macros are processed much like the shell:
5629 The line is split into arguments according to
5630 spaces.@footnote{Plan@tie{}9's @code{troff} implementation also allows
5631 tabs for argument separation -- @code{gtroff} intentionally doesn't
5632 support this.}
5633
5634 @cindex spaces, in a macro argument
5635 An argument to a macro that is intended to contain spaces can either be
5636 enclosed in double quotes, or have the spaces @dfn{escaped} with
5637 backslashes.  This is @emph{not} true for requests.
5638
5639 Here are a few examples for a hypothetical macro @code{uh}:
5640
5641 @Example
5642 .uh The Mouse Problem
5643 .uh "The Mouse Problem"
5644 .uh The\ Mouse\ Problem
5645 @endExample
5646
5647 @cindex @code{\~}, difference to @code{\@key{SP}}
5648 @cindex @code{\@key{SP}}, difference to @code{\~}
5649 @noindent
5650 The first line is the @code{uh} macro being called with 3 arguments,
5651 @samp{The}, @samp{Mouse}, and @samp{Problem}.  The latter two have the
5652 same effect of calling the @code{uh} macro with one argument, @samp{The
5653 Mouse Problem}.@footnote{The last solution, i.e., using escaped spaces,
5654 is ``classical'' in the sense that it can be found in most @code{troff}
5655 documents.  Nevertheless, it is not optimal in all situations, since
5656 @w{@samp{\ }} inserts a fixed-width, non-breaking space character that
5657 can't stretch.  @code{gtroff} provides a different command @code{\~} to
5658 insert a stretchable, non-breaking space.}
5659
5660 @cindex @code{"}, in a macro argument
5661 @cindex double quote, in a macro argument
5662 A double quote that isn't preceded by a space doesn't start a macro
5663 argument.  If not closing a string, it is printed literally.
5664
5665 For example,
5666
5667 @Example
5668 .xxx a" "b c" "de"fg"
5669 @endExample
5670
5671 @noindent
5672 has the arguments @samp{a"}, @w{@samp{b c}}, @samp{de}, and @samp{fg"}.
5673 Don't rely on this obscure behaviour!
5674
5675 There are two possibilities to get a double quote reliably.
5676
5677 @itemize @bullet
5678 @item
5679 Enclose the whole argument with double quotes and use two consecutive
5680 double quotes to represent a single one.  This traditional solution has
5681 the disadvantage that double quotes don't survive argument expansion
5682 again if called in compatibility mode (using the @option{-C} option of
5683 @code{groff}):
5684
5685 @Example
5686 .de xx
5687 .  tm xx: `\\$1' `\\$2' `\\$3'
5688 .
5689 .  yy "\\$1" "\\$2" "\\$3"
5690 ..
5691 .de yy
5692 .  tm yy: `\\$1' `\\$2' `\\$3'
5693 ..
5694 .xx A "test with ""quotes""" .
5695     @result{} xx: `A' `test with "quotes"' `.'
5696     @result{} yy: `A' `test with ' `quotes""'
5697 @endExample
5698
5699 @noindent
5700 If not in compatibility mode, you get the expected result
5701
5702 @Example
5703 xx: `A' `test with "quotes"' `.'
5704 yy: `A' `test with "quotes"' `.'
5705 @endExample
5706
5707 @noindent
5708 since @code{gtroff} preserves the input level.
5709
5710 @item
5711 Use the double quote glyph @code{\(dq}.  This works with and without
5712 compatibility mode enabled since @code{gtroff} doesn't convert
5713 @code{\(dq} back to a double quote input character.
5714
5715 Note that this method won't work with @acronym{UNIX} @code{troff} in
5716 general since the glyph `dq' isn't defined normally.
5717 @end itemize
5718
5719 @cindex @code{ds} request, and double quotes
5720 Double quotes in the @code{ds} request are handled differently.
5721 @xref{Strings}, for more details.
5722
5723 @c ---------------------------------------------------------------------
5724
5725 @node Macros, Escapes, Requests, Embedded Commands
5726 @subsection Macros
5727 @cindex macros
5728
5729 @code{gtroff} has a @dfn{macro} facility for defining a series of lines
5730 that can be invoked by name.  They are called in the same manner as
5731 requests -- arguments also may be passed basically in the same manner.
5732
5733 @xref{Writing Macros}, and @ref{Request and Macro Arguments}.
5734
5735 @c ---------------------------------------------------------------------
5736
5737 @node Escapes,  , Macros, Embedded Commands
5738 @subsection Escapes
5739 @cindex escapes
5740
5741 Escapes may occur anywhere in the input to @code{gtroff}.  They usually
5742 begin with a backslash and are followed by a single character, which
5743 indicates the function to be performed.  The escape character can be
5744 changed; see @ref{Character Translations}.
5745
5746 Escape sequences that require an identifier as a parameter accept three
5747 possible syntax forms.
5748
5749 @itemize @bullet
5750 @item
5751 The next single character is the identifier.
5752
5753 @cindex @code{(}, starting a two-character identifier
5754 @item
5755 If this single character is an opening parenthesis, take the following
5756 two characters as the identifier.  Note that there is no closing
5757 parenthesis after the identifier.
5758
5759 @cindex @code{[}, starting an identifier
5760 @cindex @code{]}, ending an identifier
5761 @item
5762 If this single character is an opening bracket, take all characters
5763 until a closing bracket as the identifier.
5764 @end itemize
5765
5766 @noindent
5767 Examples:
5768
5769 @Example
5770 \fB
5771 \n(XX
5772 \*[TeX]
5773 @endExample
5774
5775 @cindex @code{'}, delimiting arguments
5776 @cindex argument delimiting characters
5777 @cindex characters, argument delimiting
5778 @cindex delimiting characters for arguments
5779 Other escapes may require several arguments and/or some special format.
5780 In such cases the argument is traditionally enclosed in single quotes
5781 (and quotes are always used in this manual for the definitions of escape
5782 sequences).  The enclosed text is then processed according to what that
5783 escape expects.  Example:
5784
5785 @Example
5786 \l'1.5i\(bu'
5787 @endExample
5788
5789 @cindex @code{\o}, possible quote characters
5790 @cindex @code{\b}, possible quote characters
5791 @cindex @code{\X}, possible quote characters
5792 Note that the quote character can be replaced with any other character
5793 that does not occur in the argument (even a newline or a space
5794 character) in the following escapes: @code{\o}, @code{\b}, and
5795 @code{\X}.  This makes e.g.
5796
5797 @Example
5798 A caf
5799 \o
5800 e\'
5801
5802
5803 in Paris
5804   @result{} A café in Paris
5805 @endExample
5806
5807 @noindent
5808 possible, but it is better not to use this feature to avoid confusion.
5809
5810 @cindex @code{\%}, used as delimiter
5811 @cindex @code{\@key{SP}}, used as delimiter
5812 @cindex @code{\|}, used as delimiter
5813 @cindex @code{\^}, used as delimiter
5814 @cindex @code{\@{}, used as delimiter
5815 @cindex @code{\@}}, used as delimiter
5816 @cindex @code{\'}, used as delimiter
5817 @cindex @code{\`}, used as delimiter
5818 @cindex @code{\-}, used as delimiter
5819 @cindex @code{\_}, used as delimiter
5820 @cindex @code{\!}, used as delimiter
5821 @cindex @code{\?}, used as delimiter
5822 @cindex @code{\)}, used as delimiter
5823 @cindex @code{\/}, used as delimiter
5824 @cindex @code{\,}, used as delimiter
5825 @cindex @code{\&}, used as delimiter
5826 @ifnotinfo
5827 @cindex @code{\:}, used as delimiter
5828 @end ifnotinfo
5829 @ifinfo
5830 @cindex @code{\@r{<colon>}}, used as delimiter
5831 @end ifinfo
5832 @cindex @code{\~}, used as delimiter
5833 @cindex @code{\0}, used as delimiter
5834 @cindex @code{\a}, used as delimiter
5835 @cindex @code{\c}, used as delimiter
5836 @cindex @code{\d}, used as delimiter
5837 @cindex @code{\e}, used as delimiter
5838 @cindex @code{\E}, used as delimiter
5839 @cindex @code{\p}, used as delimiter
5840 @cindex @code{\r}, used as delimiter
5841 @cindex @code{\t}, used as delimiter
5842 @cindex @code{\u}, used as delimiter
5843 The following escapes sequences (which are handled similarly to
5844 characters since they don't take a parameter) are also allowed as
5845 delimiters: @code{\%}, @w{@samp{\ }}, @code{\|}, @code{\^}, @code{\@{},
5846 @code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
5847 @code{\?}, @code{\)}, @code{\/}, @code{\,}, @code{\&}, @code{\:},
5848 @code{\~}, @code{\0}, @code{\a}, @code{\c}, @code{\d}, @code{\e},
5849 @code{\E}, @code{\p}, @code{\r}, @code{\t}, and @code{\u}.  Again, don't
5850 use these if possible.
5851
5852 @cindex @code{\A}, allowed delimiters
5853 @cindex @code{\B}, allowed delimiters
5854 @cindex @code{\Z}, allowed delimiters
5855 @cindex @code{\C}, allowed delimiters
5856 @cindex @code{\w}, allowed delimiters
5857 No newline characters as delimiters are allowed in the following
5858 escapes: @code{\A}, @code{\B}, @code{\Z}, @code{\C}, and @code{\w}.
5859
5860 @cindex @code{\D}, allowed delimiters
5861 @cindex @code{\h}, allowed delimiters
5862 @cindex @code{\H}, allowed delimiters
5863 @cindex @code{\l}, allowed delimiters
5864 @cindex @code{\L}, allowed delimiters
5865 @cindex @code{\N}, allowed delimiters
5866 @cindex @code{\R}, allowed delimiters
5867 @cindex @code{\s}, allowed delimiters
5868 @cindex @code{\S}, allowed delimiters
5869 @cindex @code{\v}, allowed delimiters
5870 @cindex @code{\x}, allowed delimiters
5871 Finally, the escapes @code{\D}, @code{\h}, @code{\H}, @code{\l},
5872 @code{\L}, @code{\N}, @code{\R}, @code{\s}, @code{\S}, @code{\v}, and
5873 @code{\x} can't use the following characters as delimiters:
5874
5875 @itemize @bullet
5876 @item
5877 @cindex numbers, and delimiters
5878 @cindex digits, and delimiters
5879 The digits @code{0}-@code{9}.
5880
5881 @item
5882 @cindex operators, as delimiters
5883 @cindex @code{+}, as delimiter
5884 @cindex @code{-}, as delimiter
5885 @cindex @code{/}, as delimiter
5886 @cindex @code{*}, as delimiter
5887 @cindex @code{%}, as delimiter
5888 @cindex @code{<}, as delimiter
5889 @cindex @code{>}, as delimiter
5890 @cindex @code{=}, as delimiter
5891 @cindex @code{&}, as delimiter
5892 @ifnotinfo
5893 @cindex @code{:}, as delimiter
5894 @end ifnotinfo
5895 @ifinfo
5896 @cindex <colon>, as delimiter
5897 @end ifinfo
5898 @cindex @code{(}, as delimiter
5899 @cindex @code{)}, as delimiter
5900 @cindex @code{.}, as delimiter
5901 The (single-character) operators @samp{+-/*%<>=&:().}.
5902
5903 @item
5904 @cindex space character
5905 @cindex character, space
5906 @cindex tab character
5907 @cindex character, tab
5908 @cindex newline character
5909 @cindex character, newline
5910 The space, tab, and newline characters.
5911
5912 @item
5913 @cindex @code{\%}, used as delimiter
5914 @ifnotinfo
5915 @cindex @code{\:}, used as delimiter
5916 @end ifnotinfo
5917 @ifinfo
5918 @cindex @code{\@r{<colon>}}, used as delimiter
5919 @end ifinfo
5920 @cindex @code{\@{}, used as delimiter
5921 @cindex @code{\@}}, used as delimiter
5922 @cindex @code{\'}, used as delimiter
5923 @cindex @code{\`}, used as delimiter
5924 @cindex @code{\-}, used as delimiter
5925 @cindex @code{\_}, used as delimiter
5926 @cindex @code{\!}, used as delimiter
5927 @cindex @code{\/}, used as delimiter
5928 @cindex @code{\c}, used as delimiter
5929 @cindex @code{\e}, used as delimiter
5930 @cindex @code{\p}, used as delimiter
5931 All escape sequences except @code{\%}, @code{\:}, @code{\@{},
5932 @code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
5933 @code{\/}, @code{\c}, @code{\e}, and @code{\p}.
5934 @end itemize
5935
5936 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
5937 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
5938 To have a backslash (actually, the current escape character) appear in
5939 the output several escapes are defined: @code{\\}, @code{\e} or
5940 @code{\E}.  These are very similar, and only differ with respect to
5941 being used in macros or diversions.  @xref{Character Translations}, for
5942 an exact description of those escapes.
5943
5944 @xref{Implementation Differences}, @ref{Copy-in Mode}, and
5945 @ref{Diversions}, @ref{Identifiers}, for more information.
5946
5947 @menu
5948 * Comments::
5949 @end menu
5950
5951 @node Comments,  , Escapes, Escapes
5952 @subsubsection Comments
5953 @cindex comments
5954
5955 Probably one of the most@footnote{Unfortunately, this is a lie.  But
5956 hopefully future @code{gtroff} hackers will believe it @code{:-)}}
5957 common forms of escapes is the comment.
5958
5959 @Defesc {\\", , , }
5960 Start a comment.  Everything to the end of the input line is ignored.
5961
5962 This may sound simple, but it can be tricky to keep the comments from
5963 interfering with the appearance of the final output.
5964
5965 @cindex @code{ds}, @code{ds1} requests, and comments
5966 @cindex @code{as}, @code{as1} requests, and comments
5967 If the escape is to the right of some text or a request, that portion of
5968 the line is ignored, but the space leading up to it is noticed by
5969 @code{gtroff}.  This only affects the @code{ds} and @code{as} request
5970 and its variants.
5971
5972 @cindex tabs, before comments
5973 @cindex comments, lining up with tabs
5974 One possibly irritating idiosyncracy is that tabs must not be used to
5975 line up comments.  Tabs are not treated as whitespace between the
5976 request and macro arguments.
5977
5978 @cindex undefined request
5979 @cindex request, undefined
5980 A comment on a line by itself is treated as a blank line, because after
5981 eliminating the comment, that is all that remains:
5982
5983 @Example
5984 Test
5985 \" comment
5986 Test
5987 @endExample
5988
5989 @noindent
5990 produces
5991
5992 @Example
5993 Test
5994
5995 Test
5996 @endExample
5997
5998 To avoid this, it is common to start the line with @code{.\"}, which
5999 causes the line to be treated as an undefined request and thus ignored
6000 completely.
6001
6002 @cindex @code{'}, as a comment
6003 Another commenting scheme seen sometimes is three consecutive single
6004 quotes (@code{'''}) at the beginning of a line.  This works, but
6005 @code{gtroff} gives a warning about an undefined macro (namely
6006 @code{''}), which is harmless, but irritating.
6007 @endDefesc
6008
6009 @Defesc {\\#, , , }
6010 To avoid all this, @code{gtroff} has a new comment mechanism using the
6011 @code{\#} escape.  This escape works the same as @code{\"} except that
6012 the newline is also ignored:
6013
6014 @Example
6015 Test
6016 \# comment
6017 Test
6018 @endExample
6019
6020 @noindent
6021 produces
6022
6023 @Example
6024 Test Test
6025 @endExample
6026
6027 @noindent
6028 as expected.
6029 @endDefesc
6030
6031 @Defreq {ig, [@Var{end}]}
6032 Ignore all input until @code{gtroff} encounters the macro named
6033 @code{.}@var{end} on a line by itself (or @code{..} if @var{end} is not
6034 specified).  This is useful for commenting out large blocks of text:
6035
6036 @Example
6037 text text text...
6038 .ig
6039 This is part of a large block
6040 of text that has been
6041 temporarily(?) commented out.
6042
6043 We can restore it simply by removing
6044 the .ig request and the ".." at the
6045 end of the block.
6046 ..
6047 More text text text...
6048 @endExample
6049
6050 @noindent
6051 produces
6052
6053 @Example
6054 text text text@dots{}  More text text text@dots{}
6055 @endExample
6056
6057 @noindent
6058 Note that the commented-out block of text does not cause a break.
6059
6060 @cindex @code{ig} request, and copy-in mode
6061 @cindex copy-in mode, and @code{ig} request
6062 @cindex mode, copy-in, and @code{ig} request
6063 @cindex @code{ig} request, and auto-increment
6064 @cindex auto-increment, and @code{ig} request
6065 The input is read in copy-mode; auto-incremented registers @emph{are}
6066 affected (@pxref{Auto-increment}).
6067 @endDefreq
6068
6069
6070 @c =====================================================================
6071
6072 @node Registers, Manipulating Filling and Adjusting, Embedded Commands, gtroff Reference
6073 @section Registers
6074 @cindex registers
6075
6076 Numeric variables in @code{gtroff} are called @dfn{registers}.  There
6077 are a number of built-in registers, supplying anything from the date to
6078 details of formatting parameters.
6079
6080 @xref{Identifiers}, for details on register identifiers.
6081
6082 @menu
6083 * Setting Registers::
6084 * Interpolating Registers::
6085 * Auto-increment::
6086 * Assigning Formats::
6087 * Built-in Registers::
6088 @end menu
6089
6090 @c ---------------------------------------------------------------------
6091
6092 @node Setting Registers, Interpolating Registers, Registers, Registers
6093 @subsection Setting Registers
6094 @cindex setting registers (@code{nr}, @code{\R})
6095 @cindex registers, setting (@code{nr}, @code{\R})
6096
6097 Define or set registers using the @code{nr} request or the @code{\R}
6098 escape.
6099
6100 Although the following requests and escapes can be used to create
6101 registers, simply using an undefined register will cause it to be
6102 set to zero.
6103
6104 @DefreqList {nr, ident value}
6105 @DefescListEndx {\\R, ', ident value, '}
6106 Set number register @var{ident} to @var{value}.  If @var{ident} doesn't
6107 exist, @code{gtroff} creates it.
6108
6109 The argument to @code{\R} usually has to be enclosed in quotes.
6110 @xref{Escapes}, for details on parameter delimiting characters.
6111
6112 The @code{\R} escape doesn't produce an input token in @code{gtroff};
6113 in other words, it vanishes completely after @code{gtroff} has
6114 processed it.
6115
6116 For example, the following two lines are equivalent:
6117
6118 @Example
6119 .nr a (((17 + (3 * 4))) % 4)
6120 \R'a (((17 + (3 * 4))) % 4)'
6121     @result{} 1
6122 @endExample
6123
6124 Note that the complete transparency of @code{\R} can cause surprising
6125 effects if you use number registers like @code{.k}, which get evaluated
6126 at the time they are accessed.
6127
6128 @Example
6129 .ll 1.6i
6130 .
6131 aaa bbb ccc ddd eee fff ggg hhh\R':k \n[.k]'
6132 .tm :k == \n[:k]
6133     @result{} :k == 126950
6134 .
6135 .br
6136 .
6137 aaa bbb ccc ddd eee fff ggg hhh\h'0'\R':k \n[.k]'
6138 .tm :k == \n[:k]
6139     @result{} :k == 15000
6140 @endExample
6141
6142 If you process this with the @sc{PostScript} device (@code{-Tps}),
6143 there will be a line break eventually after @code{ggg} in both input
6144 lines.  However, after processing the space after @code{ggg}, the
6145 partially collected line is not overfull yet, so @code{troff}
6146 continues to collect input until it sees the space (or in this case,
6147 the newline) after @code{hhh}.  At this point, the line is longer
6148 than the line length, and the line gets broken.
6149
6150 In the first input line, since the @code{\R} escape leaves no traces,
6151 the check for the overfull line hasn't been done yet at the point where
6152 @code{\R} gets handled, and you get a value for the @code{.k} number
6153 register that is even greater than the current line length.
6154
6155 In the second input line, the insertion of @code{\h'0'} to emit an
6156 invisible zero-width space forces @code{troff} to check the line length,
6157 which in turn causes the start of a new output line.  Now @code{.k}
6158 returns the expected value.
6159 @endDefreq
6160
6161 Both @code{nr} and @code{\R} have two additional special forms to
6162 increment or decrement a register.
6163
6164 @DefreqList {nr, ident @t{+}@Var{value}}
6165 @DefreqItem {nr, ident @t{-}@Var{value}}
6166 @DefescItemx {\\R, ', ident @t{+}value, '}
6167 @DefescListEnd {\\R, ', ident @t{-}value, '}
6168 Increment (decrement) register @var{ident} by @var{value}.
6169
6170 @Example
6171 .nr a 1
6172 .nr a +1
6173 \na
6174     @result{} 2
6175 @endExample
6176
6177 @cindex negating register values
6178 To assign the negated value of a register to another register, some care
6179 must be taken to get the desired result:
6180
6181 @Example
6182 .nr a 7
6183 .nr b 3
6184 .nr a -\nb
6185 \na
6186     @result{} 4
6187 .nr a (-\nb)
6188 \na
6189     @result{} -3
6190 @endExample
6191
6192 @noindent
6193 The surrounding parentheses prevent the interpretation of the minus sign
6194 as a decrementing operator.  An alternative is to start the assignment
6195 with a @samp{0}:
6196
6197 @Example
6198 .nr a 7
6199 .nr b -3
6200 .nr a \nb
6201 \na
6202     @result{} 4
6203 .nr a 0\nb
6204 \na
6205     @result{} -3
6206 @endExample
6207 @endDefreq
6208
6209 @Defreq {rr, ident}
6210 @cindex removing number register (@code{rr})
6211 @cindex number register, removing (@code{rr})
6212 @cindex register, removing (@code{rr})
6213 Remove number register @var{ident}.  If @var{ident} doesn't exist, the
6214 request is ignored.
6215 @endDefreq
6216
6217 @Defreq {rnn, ident1 ident2}
6218 @cindex renaming number register (@code{rnn})
6219 @cindex number register, renaming (@code{rnn})
6220 @cindex register, renaming (@code{rnn})
6221 Rename number register @var{ident1} to @var{ident2}.  If either
6222 @var{ident1} or @var{ident2} doesn't exist, the request is ignored.
6223 @endDefreq
6224
6225 @Defreq {aln, ident1 ident2}
6226 @cindex alias, number register, creating (@code{aln})
6227 @cindex creating alias, for number register (@code{aln})
6228 @cindex number register, creating alias (@code{aln})
6229 @cindex register, creating alias (@code{aln})
6230 Create an alias @var{ident1} for a number register @var{ident2}.  The
6231 new name and the old name are exactly equivalent.  If @var{ident1} is
6232 undefined, a warning of type @samp{reg} is generated, and the request is
6233 ignored.  @xref{Debugging}, for information about warnings.
6234 @endDefreq
6235
6236 @c ---------------------------------------------------------------------
6237
6238 @node Interpolating Registers, Auto-increment, Setting Registers, Registers
6239 @subsection Interpolating Registers
6240 @cindex interpolating registers (@code{\n})
6241 @cindex registers, interpolating (@code{\n})
6242
6243 Numeric registers can be accessed via the @code{\n} escape.
6244
6245 @DefescList {\\n, , i, }
6246 @DefescItem {\\n, @Lparen{}, id, }
6247 @DefescListEnd {\\n, @Lbrack{}, ident, @Rbrack{}}
6248 @cindex nested assignments
6249 @cindex assignments, nested
6250 @cindex indirect assignments
6251 @cindex assignments, indirect
6252 Interpolate number register with name @var{ident} (one-character
6253 name@tie{}@var{i}, two-character name @var{id}).  This means that the
6254 value of the register is expanded in-place while @code{gtroff} is
6255 parsing the input line.  Nested assignments (also called indirect
6256 assignments) are possible.
6257
6258 @Example
6259 .nr a 5
6260 .nr as \na+\na
6261 \n(as
6262     @result{} 10
6263 @endExample
6264
6265 @Example
6266 .nr a1 5
6267 .nr ab 6
6268 .ds str b
6269 .ds num 1
6270 \n[a\n[num]]
6271     @result{} 5
6272 \n[a\*[str]]
6273     @result{} 6
6274 @endExample
6275 @endDefesc
6276
6277 @c ---------------------------------------------------------------------
6278
6279 @node Auto-increment, Assigning Formats, Interpolating Registers, Registers
6280 @subsection Auto-increment
6281 @cindex auto-increment
6282 @cindex increment, automatic
6283
6284 Number registers can also be auto-incremented and auto-decremented.  The
6285 increment or decrement value can be specified with a third argument to
6286 the @code{nr} request or @code{\R} escape.
6287
6288 @Defreq {nr, ident value incr}
6289 @cindex @code{\R}, difference to @code{nr}
6290 Set number register @var{ident} to @var{value}; the increment for
6291 auto-incrementing is set to @var{incr}.  Note that the @code{\R} escape
6292 doesn't support this notation.
6293 @endDefreq
6294
6295 To activate auto-incrementing, the escape @code{\n} has a special syntax
6296 form.
6297
6298 @DefescList {\\n, +, i, }
6299 @DefescItem {\\n, -, i, }
6300 @DefescItem {\\n, @Lparen{}+, id, }
6301 @DefescItem {\\n, @Lparen{}-, id, }
6302 @DefescItem {\\n, +@Lparen{}, id, }
6303 @DefescItem {\\n, -@Lparen{}, id, }
6304 @DefescItem {\\n, @Lbrack{}+, ident, @Rbrack{}}
6305 @DefescItem {\\n, @Lbrack{}-, ident, @Rbrack{}}
6306 @DefescItem {\\n, +@Lbrack{}, ident, @Rbrack{}}
6307 @DefescListEnd {\\n, -@Lbrack{}, ident, @Rbrack{}}
6308 Before interpolating, increment or decrement @var{ident} (one-character
6309 name@tie{}@var{i}, two-character name @var{id}) by the auto-increment
6310 value as specified with the @code{nr} request (or the @code{\R} escape).
6311 If no auto-increment value has been specified, these syntax forms are
6312 identical to @code{\n}.
6313 @endDefesc
6314
6315 For example,
6316
6317 @Example
6318 .nr a 0 1
6319 .nr xx 0 5
6320 .nr foo 0 -2
6321 \n+a, \n+a, \n+a, \n+a, \n+a
6322 .br
6323 \n-(xx, \n-(xx, \n-(xx, \n-(xx, \n-(xx
6324 .br
6325 \n+[foo], \n+[foo], \n+[foo], \n+[foo], \n+[foo]
6326 @endExample
6327
6328 @noindent
6329 produces
6330
6331 @Example
6332 1, 2, 3, 4, 5
6333 -5, -10, -15, -20, -25
6334 -2, -4, -6, -8, -10
6335 @endExample
6336
6337 @cindex increment value without changing the register
6338 @cindex value, incrementing without changing the register
6339 To change the increment value without changing the value of a register
6340 (@var{a} in the example), the following can be used:
6341
6342 @Example
6343 .nr a \na 10
6344 @endExample
6345
6346 @c ---------------------------------------------------------------------
6347
6348 @node Assigning Formats, Built-in Registers, Auto-increment, Registers
6349 @subsection Assigning Formats
6350 @cindex assigning formats (@code{af})
6351 @cindex formats, assigning (@code{af})
6352
6353 When a register is used, it is always textually replaced (or
6354 interpolated) with a representation of that number.  This output format
6355 can be changed to a variety of formats (numbers, Roman numerals, etc.).
6356 This is done using the @code{af} request.
6357
6358 @Defreq {af, ident format}
6359 Change the output format of a number register.  The first argument
6360 @var{ident} is the name of the number register to be changed, and the
6361 second argument @var{format} is the output format.  The following output
6362 formats are available:
6363
6364 @table @code
6365 @item 1
6366 Decimal arabic numbers.  This is the default format: 0, 1, 2,
6367 3,@tie{}@enddots{}
6368
6369 @item 0@dots{}0
6370 Decimal numbers with as many digits as specified.  So, @samp{00} would
6371 result in printing numbers as 01, 02, 03,@tie{}@enddots{}
6372
6373 In fact, any digit instead of zero does work; @code{gtroff} only counts
6374 how many digits are specified.  As a consequence, @code{af}'s default
6375 format @samp{1} could be specified as @samp{0} also (and exactly this is
6376 returned by the @code{\g} escape, see below).
6377
6378 @item I
6379 @cindex Roman numerals
6380 @cindex numerals, Roman
6381 Upper-case Roman numerals: 0, I, II, III, IV,@tie{}@enddots{}
6382
6383 @item i
6384 Lower-case Roman numerals: 0, i, ii, iii, iv,@tie{}@enddots{}
6385
6386 @item A
6387 Upper-case letters: 0, A, B, C, @dots{},@tie{}Z, AA, AB,@tie{}@enddots{}
6388
6389 @item a
6390 Lower-case letters: 0, a, b, c, @dots{},@tie{}z, aa, ab,@tie{}@enddots{}
6391 @end table
6392
6393 Omitting the number register format causes a warning of type
6394 @samp{missing}.  @xref{Debugging}, for more details.  Specifying a
6395 nonexistent format causes an error.
6396
6397 The following example produces @samp{10, X, j, 010}:
6398
6399 @Example
6400 .nr a 10
6401 .af a 1           \" the default format
6402 \na,
6403 .af a I
6404 \na,
6405 .af a a
6406 \na,
6407 .af a 001
6408 \na
6409 @endExample
6410
6411 @cindex Roman numerals, maximum and minimum
6412 @cindex maximum values of Roman numerals
6413 @cindex minimum values of Roman numerals
6414 The largest number representable for the @samp{i} and @samp{I} formats
6415 is 39999 (or @minus{}39999); @acronym{UNIX} @code{troff} uses @samp{z}
6416 and @samp{w} to represent 10000 and 5000 in Roman numerals, and so does
6417 @code{gtroff}.  Currently, the correct glyphs of Roman numeral five
6418 thousand and Roman numeral ten thousand (Unicode code points
6419 @code{U+2182} and @code{U+2181}, respectively) are not available.
6420
6421 If @var{ident} doesn't exist, it is created.
6422
6423 @cindex read-only register, changing format
6424 @cindex changing format, and read-only registers
6425 Changing the output format of a read-only register causes an error.  It
6426 is necessary to first copy the register's value to a writeable register,
6427 then apply the @code{af} request to this other register.
6428 @endDefreq
6429
6430 @DefescList {\\g, , i, }
6431 @DefescItem {\\g, @Lparen{}, id, }
6432 @DefescListEnd {\\g, @Lbrack{}, ident, @Rbrack{}}
6433 @cindex format of register (@code{\g})
6434 @cindex register, format (@code{\g})
6435 Return the current format of the specified register @var{ident}
6436 (one-character name@tie{}@var{i}, two-character name @var{id}).  For
6437 example, @samp{\ga} after the previous example would produce the string
6438 @samp{000}.  If the register hasn't been defined yet, nothing is
6439 returned.
6440 @endDefesc
6441
6442 @c ---------------------------------------------------------------------
6443
6444 @node Built-in Registers,  , Assigning Formats, Registers
6445 @subsection Built-in Registers
6446 @cindex built-in registers
6447 @cindex registers, built-in
6448
6449 The following lists some built-in registers that are not described
6450 elsewhere in this manual.  Any register that begins with a @samp{.} is
6451 read-only.  A complete listing of all built-in registers can be found in
6452 @ref{Register Index}.
6453
6454 @table @code
6455 @item \n[.F]
6456 @cindex current input file name register (@code{.F})
6457 @cindex input file name, current, register (@code{.F})
6458 @vindex .F
6459 This string-valued register returns the current input file name.
6460
6461 @item \n[.H]
6462 @cindex horizontal resolution register (@code{.H})
6463 @cindex resolution, horizontal, register (@code{.H})
6464 @vindex .H
6465 Horizontal resolution in basic units.
6466
6467 @item \n[.R]
6468 @cindex number of registers register (@code{.R})
6469 @cindex registers, number of, register (@code{.R})
6470 @vindex .R
6471 The number of number registers available.  This is always 10000 in
6472 GNU@tie{}@code{troff}; it exists for backward compatibility.
6473
6474 @item \n[.U]
6475 @cindex safer mode
6476 @cindex mode, safer
6477 @cindex unsafe mode
6478 @cindex mode, unsafe
6479 @vindex .U
6480 If @code{gtroff} is called with the @option{-U} command line option to
6481 activate unsafe mode, the number register @code{.U} is set to@tie{}1,
6482 and to zero otherwise.  @xref{Groff Options}.
6483
6484 @item \n[.V]
6485 @cindex vertical resolution register (@code{.V})
6486 @cindex resolution, vertical, register (@code{.V})
6487 @vindex .V
6488 Vertical resolution in basic units.
6489
6490 @item \n[seconds]
6491 @cindex seconds, current time (@code{seconds})
6492 @cindex time, current, seconds (@code{seconds})
6493 @cindex current time, seconds (@code{seconds})
6494 @vindex seconds
6495 The number of seconds after the minute, normally in the range@tie{}0
6496 to@tie{}59, but can be up to@tie{}61 to allow for leap seconds.
6497 Initialized at start-up of @code{gtroff}.
6498
6499 @item \n[minutes]
6500 @cindex minutes, current time (@code{minutes})
6501 @cindex time, current, minutes (@code{minutes})
6502 @cindex current time, minutes (@code{minutes})
6503 @vindex minutes
6504 The number of minutes after the hour, in the range@tie{}0 to@tie{}59.
6505 Initialized at start-up of @code{gtroff}.
6506
6507 @item \n[hours]
6508 @cindex hours, current time (@code{hours})
6509 @cindex time, current, hours (@code{hours})
6510 @cindex current time, hours (@code{hours})
6511 @vindex hours
6512 The number of hours past midnight, in the range@tie{}0 to@tie{}23.
6513 Initialized at start-up of @code{gtroff}.
6514
6515 @item \n[dw]
6516 @cindex day of the week register (@code{dw})
6517 @cindex date, day of the week register (@code{dw})
6518 @vindex dw
6519 Day of the week (1-7).
6520
6521 @item \n[dy]
6522 @cindex day of the month register (@code{dy})
6523 @cindex date, day of the month register (@code{dy})
6524 @vindex dy
6525 Day of the month (1-31).
6526
6527 @item \n[mo]
6528 @cindex month of the year register (@code{mo})
6529 @cindex date, month of the year register (@code{mo})
6530 @vindex mo
6531 Current month (1-12).
6532
6533 @item \n[year]
6534 @cindex date, year register (@code{year}, @code{yr})
6535 @cindex year, current, register (@code{year}, @code{yr})
6536 @vindex year
6537 The current year.
6538
6539 @item \n[yr]
6540 @vindex yr
6541 The current year minus@tie{}1900.  Unfortunately, the documentation of
6542 @acronym{UNIX} Version@tie{}7's @code{troff} had a year@tie{}2000 bug:
6543 It incorrectly claimed that @code{yr} contains the last two digits of
6544 the year.  That claim has never been true of either @acronym{AT&T}
6545 @code{troff} or GNU @code{troff}.  Old @code{troff} input that looks
6546 like this:
6547
6548 @Example
6549 '\" The following line stopped working after 1999
6550 This document was formatted in 19\n(yr.
6551 @endExample
6552
6553 @noindent
6554 can be corrected as follows:
6555
6556 @Example
6557 This document was formatted in \n[year].
6558 @endExample
6559
6560 @noindent
6561 or, to be portable to older @code{troff} versions, as follows:
6562
6563 @Example
6564 .nr y4 1900+\n(yr
6565 This document was formatted in \n(y4.
6566 @endExample
6567
6568 @item \n[.c]
6569 @vindex .c
6570 @itemx \n[c.]
6571 @vindex c.
6572 @cindex input line number register (@code{.c}, @code{c.})
6573 @cindex line number, input, register (@code{.c}, @code{c.})
6574 The current @emph{input} line number.  Register @samp{.c} is read-only,
6575 whereas @samp{c.} (a @code{gtroff} extension) is writable also,
6576 affecting both @samp{.c} and @samp{c.}.
6577
6578 @item \n[ln]
6579 @vindex ln
6580 @cindex output line number register (@code{ln})
6581 @cindex line number, output, register (@code{ln})
6582 The current @emph{output} line number after a call to the @code{nm}
6583 request to activate line numbering.
6584
6585 @xref{Miscellaneous}, for more information about line numbering.
6586
6587 @item \n[.x]
6588 @vindex .x
6589 @cindex major version number register (@code{.x})
6590 @cindex version number, major, register (@code{.x})
6591 The major version number.  For example, if the version number is 1.03
6592 then @code{.x} contains@tie{}@samp{1}.
6593
6594 @item \n[.y]
6595 @vindex .y
6596 @cindex minor version number register (@code{.y})
6597 @cindex version number, minor, register (@code{.y})
6598 The minor version number.  For example, if the version number is 1.03
6599 then @code{.y} contains@tie{}@samp{03}.
6600
6601 @item \n[.Y]
6602 @vindex .Y
6603 @cindex revision number register (@code{.Y})
6604 The revision number of @code{groff}.
6605
6606 @item \n[$$]
6607 @vindex $$
6608 @cindex process ID of @code{gtroff} register (@code{$$})
6609 @cindex @code{gtroff}, process ID register (@code{$$})
6610 The process ID of @code{gtroff}.
6611
6612 @item \n[.g]
6613 @vindex .g
6614 @cindex @code{gtroff}, identification register (@code{.g})
6615 @cindex GNU-specific register (@code{.g})
6616 Always@tie{}1.  Macros should use this to determine whether they are
6617 running under GNU @code{troff}.
6618
6619 @item \n[.A]
6620 @vindex .A
6621 @cindex @acronym{ASCII} approximation output register (@code{.A})
6622 If the command line option @option{-a} is used to produce an
6623 @acronym{ASCII} approximation of the output, this is set to@tie{}1, zero
6624 otherwise.  @xref{Groff Options}.
6625
6626 @item \n[.O]
6627 @vindex .O
6628 This read-only register is set to the suppression nesting level (see
6629 escapes @code{\O}).  @xref{Suppressing output}.
6630
6631 @item \n[.P]
6632 @vindex .P
6633 This register is set to@tie{}1 (and to@tie{}0 otherwise) if the current
6634 page is actually being printed, i.e., if the @option{-o} option is being
6635 used to only print selected pages.  @xref{Groff Options}, for more
6636 information.
6637
6638 @item \n[.T]
6639 @vindex .T
6640 If @code{gtroff} is called with the @option{-T} command line option, the
6641 number register @code{.T} is set to@tie{}1, and zero otherwise.
6642 @xref{Groff Options}.
6643
6644 @item \*[.T]
6645 @stindex .T
6646 @cindex output device name string register (@code{.T})
6647 A single read-write string register that contains the current output
6648 device (for example, @samp{latin1} or @samp{ps}).  This is the only
6649 string register defined by @code{gtroff}.
6650 @end table
6651
6652
6653 @c =====================================================================
6654
6655 @node Manipulating Filling and Adjusting, Manipulating Hyphenation, Registers, gtroff Reference
6656 @section Manipulating Filling and Adjusting
6657 @cindex manipulating filling and adjusting
6658 @cindex filling and adjusting, manipulating
6659 @cindex adjusting and filling, manipulating
6660 @cindex justifying text
6661 @cindex text, justifying
6662
6663 @cindex break
6664 @cindex line break
6665 @cindex @code{bp} request, causing implicit linebreak
6666 @cindex @code{ce} request, causing implicit linebreak
6667 @cindex @code{cf} request, causing implicit linebreak
6668 @cindex @code{fi} request, causing implicit linebreak
6669 @cindex @code{fl} request, causing implicit linebreak
6670 @cindex @code{in} request, causing implicit linebreak
6671 @cindex @code{nf} request, causing implicit linebreak
6672 @cindex @code{rj} request, causing implicit linebreak
6673 @cindex @code{sp} request, causing implicit linebreak
6674 @cindex @code{ti} request, causing implicit linebreak
6675 @cindex @code{trf} request, causing implicit linebreak
6676 Various ways of causing @dfn{breaks} were given in @ref{Implicit Line
6677 Breaks}.  The @code{br} request likewise causes a break.  Several other
6678 requests also cause breaks, but implicitly.  These are @code{bp},
6679 @code{ce}, @code{cf}, @code{fi}, @code{fl}, @code{in}, @code{nf},
6680 @code{rj}, @code{sp}, @code{ti}, and @code{trf}.
6681
6682 @Defreq {br, }
6683 Break the current line, i.e., the input collected so far is emitted
6684 without adjustment.
6685
6686 If the no-break control character is used, @code{gtroff} suppresses the
6687 break:
6688
6689 @Example
6690 a
6691 'br
6692 b
6693     @result{} a b
6694 @endExample
6695 @endDefreq
6696
6697 Initially, @code{gtroff} fills and adjusts text to both margins.
6698 Filling can be disabled via the @code{nf} request and re-enabled with
6699 the @code{fi} request.
6700
6701 @DefreqList {fi, }
6702 @DefregListEndx {.u}
6703 @cindex fill mode (@code{fi})
6704 @cindex mode, fill (@code{fi})
6705 Activate fill mode (which is the default).  This request implicitly
6706 enables adjusting; it also inserts a break in the text currently being
6707 filled.  The read-only number register @code{.u} is set to@tie{}1.
6708
6709 The fill mode status is associated with the current environment
6710 (@pxref{Environments}).
6711
6712 See @ref{Line Control}, for interaction with the @code{\c} escape.
6713 @endDefreq
6714
6715 @Defreq {nf, }
6716 @cindex no-fill mode (@code{nf})
6717 @cindex mode, no-fill (@code{nf})
6718 Activate no-fill mode.  Input lines are output as-is, retaining line
6719 breaks and ignoring the current line length.  This command implicitly
6720 disables adjusting; it also causes a break.  The number register
6721 @code{.u} is set to@tie{}0.
6722
6723 The fill mode status is associated with the current environment
6724 (@pxref{Environments}).
6725
6726 See @ref{Line Control}, for interaction with the @code{\c} escape.
6727 @endDefreq
6728
6729 @DefreqList {ad, [@Var{mode}]}
6730 @DefregListEndx {.j}
6731 Set adjusting mode.
6732
6733 Activation and deactivation of adjusting is done implicitly with calls
6734 to the @code{fi} or @code{nf} requests.
6735
6736 @var{mode} can have one of the following values:
6737
6738 @table @code
6739 @item l
6740 @cindex ragged-right
6741 Adjust text to the left margin.  This produces what is traditionally
6742 called ragged-right text.
6743
6744 @item r
6745 @cindex ragged-left
6746 Adjust text to the right margin, producing ragged-left text.
6747
6748 @item c
6749 @cindex centered text
6750 @cindex @code{ce} request, difference to @samp{.ad@tie{}c}
6751 Center filled text.  This is different to the @code{ce} request, which
6752 only centers text without filling.
6753
6754 @item b
6755 @itemx n
6756 Justify to both margins.  This is the default used by @code{gtroff}.
6757 @end table
6758
6759 Finally, @var{mode} can be the numeric argument returned by the
6760 @code{.j} register.
6761
6762 Using @code{ad} without argument is the same as saying
6763 @w{@code{.ad \[.j]}}.  In particular, @code{gtroff} adjusts lines
6764 in the same way it did before adjusting was deactivated (with a call
6765 to @code{na}, say).  For example, this input code
6766
6767 @Example
6768 .de AD
6769 .  br
6770 .  ad \\$1
6771 ..
6772 .
6773 .de NA
6774 .  br
6775 .  na
6776 ..
6777 .
6778 textA
6779 .AD r
6780 .nr ad \n[.j]
6781 textB
6782 .AD c
6783 textC
6784 .NA
6785 textD
6786 .AD         \" back to centering
6787 textE
6788 .AD \n[ad]  \" back to right justifying
6789 textF
6790 @endExample
6791
6792 @noindent
6793 produces the following output:
6794
6795 @Example
6796 textA
6797                                                     textB
6798                           textC
6799 textD
6800                           textE
6801                                                     textF
6802 @endExample
6803
6804 @cindex adjustment mode register (@code{.j})
6805 As just demonstrated, the current adjustment mode is available in the
6806 read-only number register @code{.j}; it can be stored and
6807 subsequently used to set adjustment.
6808
6809 The adjustment mode status is associated with the current environment
6810 (@pxref{Environments}).
6811 @endDefreq
6812
6813 @Defreq {na, }
6814 Disable adjusting.  This request won't change the current adjustment
6815 mode: A subsequent call to @code{ad} uses the previous adjustment
6816 setting.
6817
6818 The adjustment mode status is associated with the current environment
6819 (@pxref{Environments}).
6820 @endDefreq
6821
6822 @DefreqList {brp, }
6823 @DefescListEndx {\\p, , , }
6824 Adjust the current line and cause a break.
6825
6826 In most cases this produces very ugly results since @code{gtroff}
6827 doesn't have a sophisticated paragraph building algorithm (as @TeX{}
6828 have, for example); instead, @code{gtroff} fills and adjusts a paragraph
6829 line by line:
6830
6831 @Example
6832 This is an uninteresting sentence.
6833 This is an uninteresting sentence.\p
6834 This is an uninteresting sentence.
6835 @endExample
6836
6837 @noindent
6838 is formatted as
6839
6840 @Example
6841 This is  an uninteresting  sentence.   This  is an
6842 uninteresting                            sentence.
6843 This is an uninteresting sentence.
6844 @endExample
6845 @endDefreq
6846
6847 @DefreqList {ss, word_space_size [@Var{sentence_space_size}]}
6848 @DefregItemx {.ss}
6849 @DefregListEndx {.sss}
6850 @cindex word space size register (@code{.ss})
6851 @cindex size of word space register (@code{.ss})
6852 @cindex space between words register (@code{.ss})
6853 @cindex sentence space size register (@code{.sss})
6854 @cindex size of sentence space register (@code{.sss})
6855 @cindex space between sentences register (@code{.sss})
6856 Change the size of a space between words.  It takes its units as one
6857 twelfth of the space width parameter for the current font.  Initially
6858 both the @var{word_space_size} and @var{sentence_space_size}
6859 are@tie{}12.  In fill mode, the values specify the minimum distance.
6860
6861 @cindex fill mode
6862 @cindex mode, fill
6863 If two arguments are given to the @code{ss} request, the second argument
6864 sets the sentence space size.  If the second argument is not given,
6865 sentence space size is set to @var{word_space_size}.  The sentence space
6866 size is used in two circumstances: If the end of a sentence occurs at
6867 the end of a line in fill mode, then both an inter-word space and a
6868 sentence space are added; if two spaces follow the end of a sentence in
6869 the middle of a line, then the second space is a sentence space.  If a
6870 second argument is never given to the @code{ss} request, the behaviour
6871 of @acronym{UNIX} @code{troff} is the same as that exhibited by GNU
6872 @code{troff}.  In GNU @code{troff}, as in @acronym{UNIX} @code{troff}, a
6873 sentence should always be followed by either a newline or two spaces.
6874
6875 The read-only number registers @code{.ss} and @code{.sss} hold the
6876 values of the parameters set by the first and second arguments of the
6877 @code{ss} request.
6878
6879 The word space and sentence space values are associated with the current
6880 environment (@pxref{Environments}).
6881
6882 Contrary to @acronym{AT&T} @code{troff}, this request is @emph{not}
6883 ignored if a TTY output device is used; the given values are then
6884 rounded down to a multiple of@tie{}12 (@pxref{Implementation
6885 Differences}).
6886
6887 The request is ignored if there is no parameter.
6888
6889 @cindex discardable horizontal space
6890 @cindex space, discardable, horizontal
6891 @cindex horizontal discardable space
6892 Another useful application of the @code{ss} request is to insert
6893 discardable horizontal space, i.e., space that is discarded at a line
6894 break.  For example, paragraph-style footnotes could be separated this
6895 way:
6896
6897 @Example
6898 .ll 4.5i
6899 1.\ This is the first footnote.\c
6900 .ss 48
6901 .nop
6902 .ss 12
6903 2.\ This is the second footnote.
6904 @endExample
6905
6906 @noindent
6907 The result:
6908
6909 @Example
6910 1. This is the first footnote.        2. This
6911 is the second footnote.
6912 @endExample
6913
6914 @noindent
6915 Note that the @code{\h} escape produces unbreakable space.
6916 @endDefreq
6917
6918 @DefreqList {ce, [@Var{nnn}]}
6919 @DefregListEndx {.ce}
6920 @cindex centering lines (@code{ce})
6921 @cindex lines, centering (@code{ce})
6922 Center text.  While the @w{@samp{.ad c}} request also centers text, it
6923 fills the text as well.  @code{ce} does not fill the text it affects.
6924 This request causes a break.  The number of lines still to be centered
6925 is associated with the current environment (@pxref{Environments}).
6926
6927 The following example demonstrates the differences.  Here the input:
6928
6929 @Example
6930 .ll 4i
6931 .ce 1000
6932 This is a small text fragment that shows the differences
6933 between the `.ce' and the `.ad c' request.
6934 .ce 0
6935
6936 .ad c
6937 This is a small text fragment that shows the differences
6938 between the `.ce' and the `.ad c' request.
6939 @endExample
6940
6941 @noindent
6942 And here the result:
6943
6944 @Example
6945   This is a small text fragment that
6946          shows the differences
6947 between the `.ce' and the `.ad c' request.
6948
6949   This is a small text fragment that
6950 shows the differences between the `.ce'
6951         and the `.ad c' request.
6952 @endExample
6953
6954 With no arguments, @code{ce} centers the next line of text.  @var{nnn}
6955 specifies the number of lines to be centered.  If the argument is zero
6956 or negative, centering is disabled.
6957
6958 The basic length for centering text is the line length (as set with the
6959 @code{ll} request) minus the indentation (as set with the @code{in}
6960 request).  Temporary indentation is ignored.
6961
6962 As can be seen in the previous example, it is a common idiom to turn on
6963 centering for a large number of lines, and to turn off centering after
6964 text to be centered.  This is useful for any request that takes a
6965 number of lines as an argument.
6966
6967 The @code{.ce} read-only number register contains the number of lines
6968 remaining to be centered, as set by the @code{ce} request.
6969 @endDefreq
6970
6971 @DefreqList {rj, [@Var{nnn}]}
6972 @DefregListEndx {.rj}
6973 @cindex justifying text (@code{rj})
6974 @cindex text, justifying (@code{rj})
6975 @cindex right-justifying (@code{rj})
6976 Justify unfilled text to the right margin.  Arguments are identical to
6977 the @code{ce} request.  The @code{.rj} read-only number register is the
6978 number of lines to be right-justified as set by the @code{rj} request.
6979 This request causes a break.  The number of lines still to be
6980 right-justified is associated with the current environment
6981 (@pxref{Environments}).
6982 @endDefreq
6983
6984
6985 @c =====================================================================
6986
6987 @node Manipulating Hyphenation, Manipulating Spacing, Manipulating Filling and Adjusting, gtroff Reference
6988 @section Manipulating Hyphenation
6989 @cindex manipulating hyphenation
6990 @cindex hyphenation, manipulating
6991
6992 Here a description of requests that influence hyphenation.
6993
6994 @DefreqList {hy, [@Var{mode}]}
6995 @DefregListEndx {.hy}
6996 Enable hyphenation.  The request has an optional numeric argument,
6997 @var{mode}, to restrict hyphenation if necessary:
6998
6999 @table @code
7000 @item 1
7001 The default argument if @var{mode} is omitted.  Hyphenate without
7002 restrictions.  This is also the start-up value of @code{gtroff}.
7003
7004 @item 2
7005 Do not hyphenate the last word on a page or column.
7006
7007 @item 4
7008 Do not hyphenate the last two characters of a word.
7009
7010 @item 8
7011 Do not hyphenate the first two characters of a word.
7012 @end table
7013
7014 Values in the previous table are additive.  For example, the
7015 value@tie{}12 causes @code{gtroff} to neither hyphenate the last two nor
7016 the first two characters of a word.
7017
7018 @cindex hyphenation restrictions register (@code{.hy})
7019 The current hyphenation restrictions can be found in the read-only
7020 number register @samp{.hy}.
7021
7022 The hyphenation mode is associated with the current environment
7023 (@pxref{Environments}).
7024 @endDefreq
7025
7026 @Defreq {nh, }
7027 Disable hyphenation (i.e., set the hyphenation mode to zero).  Note that
7028 the hyphenation mode of the last call to @code{hy} is not remembered.
7029
7030 The hyphenation mode is associated with the current environment
7031 (@pxref{Environments}).
7032 @endDefreq
7033
7034 @DefreqList {hlm, [@Var{nnn}]}
7035 @DefregItemx {.hlm}
7036 @DefregListEndx {.hlc}
7037 @cindex explicit hyphen (@code{\%})
7038 @cindex hyphen, explicit (@code{\%})
7039 @cindex consecutive hyphenated lines (@code{hlm})
7040 @cindex lines, consecutive hyphenated (@code{hlm})
7041 @cindex hyphenated lines, consecutive (@code{hlm})
7042 Set the maximum number of consecutive hyphenated lines to @var{nnn}.  If
7043 this number is negative, there is no maximum.  The default value
7044 is@tie{}@minus{}1 if @var{nnn} is omitted.  This value is associated
7045 with the current environment (@pxref{Environments}).  Only lines output
7046 from a given environment count towards the maximum associated with that
7047 environment.  Hyphens resulting from @code{\%} are counted; explicit
7048 hyphens are not.
7049
7050 The current setting of @code{hlm} is available in the @code{.hlm}
7051 read-only number register.  Also the number of immediately preceding
7052 consecutive hyphenated lines are available in the read-only number
7053 register @samp{.hlc}.
7054 @endDefreq
7055
7056 @Defreq {hw, word1 word2 @dots{}}
7057 Define how @var{word1}, @var{word2}, etc.@: are to be hyphenated.  The
7058 words must be given with hyphens at the hyphenation points.  For
7059 example:
7060
7061 @Example
7062 .hw in-sa-lub-rious
7063 @endExample
7064
7065 @noindent
7066 Besides the space character, any character whose hyphenation code value
7067 is zero can be used to separate the arguments of @code{hw} (see the
7068 documentation for the @code{hcode} request below for more information).
7069 In addition, this request can be used more than once.
7070
7071 Hyphenation exceptions specified with the @code{hw} request are
7072 associated with the current hyphenation language; it causes an error if
7073 there is no current hyphenation language.
7074
7075 This request is ignored if there is no parameter.
7076
7077 In old versions of @code{troff} there was a limited amount of space to
7078 store such information; fortunately, with @code{gtroff}, this is no
7079 longer a restriction.
7080 @endDefreq
7081
7082 @DefescList {\\%, , , }
7083 @deffnx Escape @t{\:}
7084 @ifnotinfo
7085 @esindex \:
7086 @end ifnotinfo
7087 @ifinfo
7088 @esindex \@r{<colon>}
7089 @end ifinfo
7090 @cindex hyphenation character (@code{\%})
7091 @cindex character, hyphenation (@code{\%})
7092 @cindex disabling hyphenation (@code{\%})
7093 @cindex hyphenation, disabling (@code{\%})
7094 To tell @code{gtroff} how to hyphenate words on the fly, use the
7095 @code{\%} escape, also known as the @dfn{hyphenation character}.
7096 Preceding a word with this character prevents it from being
7097 hyphenated; putting it inside a word indicates to @code{gtroff} that
7098 the word may be hyphenated at that point.  Note that this mechanism
7099 only affects that one occurrence of the word; to change the
7100 hyphenation of a word for the entire document, use the @code{hw}
7101 request.
7102
7103 The @code{\:} escape inserts a zero-width break point (that is, the word
7104 breaks but without adding a hyphen).
7105
7106 @Example
7107 ... check the /var/log/\:httpd/\:access_log file ...
7108 @endExample
7109
7110 @cindex @code{\X}, followed by @code{\%}
7111 @cindex @code{\Y}, followed by @code{\%}
7112 @cindex @code{\%}, following @code{\X} or @code{\Y}
7113 Note that @code{\X} and @code{\Y} start a word, that is, the @code{\%}
7114 escape in (say) @w{@samp{\X'...'\%foobar}} and
7115 @w{@samp{\Y'...'\%foobar}} no longer prevents hyphenation but inserts a
7116 hyphenation point at the beginning of @samp{foobar}; most likely this
7117 isn't what you want to do.
7118 @endDefesc
7119
7120 @Defreq {hc, [@Var{char}]}
7121 Change the hyphenation character to @var{char}.  This character then
7122 works the same as the @code{\%} escape, and thus, no longer appears in
7123 the output.  Without an argument, @code{hc} resets the hyphenation
7124 character to be @code{\%} (the default) only.
7125
7126 The hyphenation character is associated with the current environment
7127 (@pxref{Environments}).
7128 @endDefreq
7129
7130 @DefreqList {hpf, pattern_file}
7131 @DefreqItemx {hpfa, pattern_file}
7132 @DefreqListEndx {hpfcode, a b [c d @dots{}]}
7133 @cindex hyphenation patterns (@code{hpf})
7134 @cindex patterns for hyphenation (@code{hpf})
7135 Read in a file of hyphenation patterns.  This file is searched for in
7136 the same way as @file{@var{name}.tmac} (or @file{tmac.@var{name}}) is
7137 searched for if the @option{-m@var{name}} option is specified.
7138
7139 It should have the same format as (simple) @TeX{} patterns files.  More
7140 specifically, the following scanning rules are implemented.
7141
7142 @itemize @bullet
7143 @item
7144 A percent sign starts a comment (up to the end of the line) even if
7145 preceded by a backslash.
7146
7147 @item
7148 No support for `digraphs' like @code{\$}.
7149
7150 @item
7151 @code{^^@var{xx}} (@var{x} is 0-9 or a-f) and @code{^^@var{x}}
7152 (character code of @var{x} in the range 0-127) are recognized; other use
7153 of @code{^} causes an error.
7154
7155 @item
7156 No macro expansion.
7157
7158 @item
7159 @code{hpf} checks for the expression @code{\patterns@{@dots{}@}}
7160 (possibly with whitespace before and after the braces).  Everything
7161 between the braces is taken as hyphenation patterns.  Consequently,
7162 @code{@{} and @code{@}} are not allowed in patterns.
7163
7164 @item
7165 Similarly, @code{\hyphenation@{@dots{}@}} gives a list of hyphenation
7166 exceptions.
7167
7168 @item
7169 @code{\endinput} is recognized also.
7170
7171 @item
7172 For backwards compatibility, if @code{\patterns} is missing, the whole
7173 file is treated as a list of hyphenation patterns (only recognizing the
7174 @code{%} character as the start of a comment).
7175 @end itemize
7176
7177 If no @code{hpf} request is specified (either in the document or in a
7178 macro package), @code{gtroff} won't hyphenate at all.
7179
7180 The @code{hpfa} request appends a file of patterns to the current list.
7181
7182 The @code{hpfcode} request defines mapping values for character codes in
7183 hyphenation patterns.  @code{hpf} or @code{hpfa} then apply the mapping
7184 (after reading the patterns) before replacing or appending them to the
7185 current list of patterns.  Its arguments are pairs of character codes --
7186 integers from 0 to@tie{}255.  The request maps character
7187 code@tie{}@var{a} to code@tie{}@var{b}, code@tie{}@var{c} to
7188 code@tie{}@var{d}, and so on.  You can use character codes that would
7189 be invalid otherwise.  By default, everything maps to itself except
7190 letters `A' to `Z', which map to `a' to `z'.
7191
7192
7193 @pindex troffrc
7194 @pindex troffrc-end
7195 @pindex hyphen.us
7196 @pindex hyphenex.us
7197 The set of hyphenation patterns is associated with the current language
7198 set by the @code{hla} request.  The @code{hpf} request is usually
7199 invoked by the @file{troffrc} or @file{troffrc-end} file; by default,
7200 @file{troffrc} loads hyphenation patterns and exceptions for American
7201 English (in files @file{hyphen.us} and @file{hyphenex.us}).
7202
7203 A second call to @code{hpf} (for the same language) replaces the
7204 hyphenation patterns with the new ones.
7205
7206 Invoking @code{hpf} causes an error if there is no current hyphenation
7207 language.
7208 @endDefreq
7209
7210 @Defreq {hcode, c1 code1 [c2 code2 @dots{}]}
7211 @cindex hyphenation code (@code{hcode})
7212 @cindex code, hyphenation (@code{hcode})
7213 Set the hyphenation code of character @var{c1} to @var{code1}, that of
7214 @var{c2} to @var{code2}, etc.  A hyphenation code must be a single input
7215 character (not a special character) other than a digit or a space.
7216
7217 To make hyphenation work, hyphenation codes must be set up.  At
7218 start-up, groff only assigns hyphenation codes to the letters
7219 @samp{a}-@samp{z} (mapped to themselves) and to the letters
7220 @samp{A}-@samp{Z} (mapped to @samp{a}-@samp{z}); all other hyphenation
7221 codes are set to zero.  Normally, hyphenation patterns contain only
7222 lowercase letters, which should be applied regardless of case.  In
7223 other words, the words `FOO' and `Foo' should be hyphenated exactly the
7224 same way as the word `foo' is hyphenated, and this is what @code{hcode}
7225 is good for.  Words that contain other letters won't be hyphenated
7226 properly if the corresponding hyphenation patterns actually do contain
7227 them.  For example, the following @code{hcode} requests are necessary to
7228 assign hyphenation codes to the letters @samp{ÄäÖöÜüß} (this is needed
7229 for German):
7230
7231 @Example
7232 .hcode Ã¤ Ã¤  Ã„ Ã¤
7233 .hcode Ã¶ Ã¶  Ã– Ã¶
7234 .hcode Ã¼ Ã¼  Ãœ Ã¼
7235 .hcode ÃŸ ÃŸ
7236 @endExample
7237
7238 Without those assignments, groff treats German words like
7239 @w{`Kindergärten'} (the plural form of `kindergarten') as two substrings
7240 @w{`kinderg'} and @w{`rten'} because the hyphenation code of the
7241 umlaut@tie{}a is zero by default.  There is a German hyphenation pattern
7242 that covers @w{`kinder'}, so groff finds the hyphenation `kin-der'.
7243 The other two hyphenation points (`kin-der-gär-ten') are missed.
7244
7245 This request is ignored if it has no parameter.
7246 @endDefreq
7247
7248 @DefreqList {hym, [@Var{length}]}
7249 @DefregListEndx {.hym}
7250 @cindex hyphenation margin (@code{hym})
7251 @cindex margin for hyphenation (@code{hym})
7252 @cindex @code{ad} request, and hyphenation margin
7253 Set the (right) hyphenation margin to @var{length}.  If the current
7254 adjustment mode is not @samp{b} or @samp{n}, the line is not hyphenated
7255 if it is shorter than @var{length}.  Without an argument, the
7256 hyphenation margin is reset to its default value, which is@tie{}0.  The
7257 default scaling indicator for this request is @samp{m}.  The hyphenation
7258 margin is associated with the current environment
7259 (@pxref{Environments}).
7260
7261 A negative argument resets the hyphenation margin to zero, emitting a
7262 warning of type @samp{range}.
7263
7264 @cindex hyphenation margin register (@code{.hym})
7265 The current hyphenation margin is available in the @code{.hym} read-only
7266 number register.
7267 @endDefreq
7268
7269 @DefreqList {hys, [@Var{hyphenation_space}]}
7270 @DefregListEndx {.hys}
7271 @cindex hyphenation space (@code{hys})
7272 @cindex @code{ad} request, and hyphenation space
7273 Set the hyphenation space to @var{hyphenation_space}.  If the current
7274 adjustment mode is @samp{b} or @samp{n}, don't hyphenate the line if it
7275 can be justified by adding no more than @var{hyphenation_space} extra
7276 space to each word space.  Without argument, the hyphenation space is
7277 set to its default value, which is@tie{}0.  The default scaling
7278 indicator for this request is @samp{m}.  The hyphenation space is
7279 associated with the current environment (@pxref{Environments}).
7280
7281 A negative argument resets the hyphenation space to zero, emitting a
7282 warning of type @samp{range}.
7283
7284 @cindex hyphenation space register (@code{.hys})
7285 The current hyphenation space is available in the @code{.hys} read-only
7286 number register.
7287 @endDefreq
7288
7289 @Defreq {shc, [@Var{glyph}]}
7290 @cindex soft hyphen character, setting (@code{shc})
7291 @cindex character, soft hyphen, setting (@code{shc})
7292 @cindex glyph, soft hyphen (@code{hy})
7293 @cindex soft hyphen glyph (@code{hy})
7294 @cindex @code{char} request, and soft hyphen character
7295 @cindex @code{tr} request, and soft hyphen character
7296 Set the @dfn{soft hyphen character} to @var{glyph}.@footnote{@dfn{Soft
7297 hyphen character} is a misnomer since it is an output glyph.}  If the
7298 argument is omitted, the soft hyphen character is set to the default
7299 glyph @code{\(hy} (this is the start-up value of @code{gtroff} also).
7300 The soft hyphen character is the glyph that is inserted when a word is
7301 hyphenated at a line break.  If the soft hyphen character does not exist
7302 in the font of the character immediately preceding a potential break
7303 point, then the line is not broken at that point.  Neither definitions
7304 (specified with the @code{char} request) nor translations (specified
7305 with the @code{tr} request) are considered when finding the soft hyphen
7306 character.
7307 @endDefreq
7308
7309 @DefreqList {hla, language}
7310 @DefregListEndx {.hla}
7311 @cindex @code{hpf} request, and hyphenation language
7312 @cindex @code{hw} request, and hyphenation language
7313 @pindex troffrc
7314 @pindex troffrc-end
7315 Set the current hyphenation language to the string @var{language}.
7316 Hyphenation exceptions specified with the @code{hw} request and
7317 hyphenation patterns specified with the @code{hpf} and @code{hpfa}
7318 requests are both associated with the current hyphenation language.  The
7319 @code{hla} request is usually invoked by the @file{troffrc} or the
7320 @file{troffrc-end} files; @file{troffrc} sets the default language to
7321 @samp{us}.
7322
7323 @cindex hyphenation language register (@code{.hla})
7324 The current hyphenation language is available as a string in the
7325 read-only number register @samp{.hla}.
7326
7327 @Example
7328 .ds curr_language \n[.hla]
7329 \*[curr_language]
7330     @result{} us
7331 @endExample
7332 @endDefreq
7333
7334
7335 @c =====================================================================
7336
7337 @node Manipulating Spacing, Tabs and Fields, Manipulating Hyphenation, gtroff Reference
7338 @section Manipulating Spacing
7339 @cindex manipulating spacing
7340 @cindex spacing, manipulating
7341
7342 @Defreq {sp, [@Var{distance}]}
7343 Space downwards @var{distance}.  With no argument it advances
7344 1@tie{}line.  A negative argument causes @code{gtroff} to move up the
7345 page the specified distance.  If the argument is preceded by a @samp{|}
7346 then @code{gtroff} moves that distance from the top of the page.  This
7347 request causes a line break, and that adds the current line spacing to
7348 the space you have just specified.  The default scaling indicator is
7349 @samp{v}.
7350
7351 For convenience you may wish to use the following macros to set the
7352 height of the next line at a given distance from the top or the bottom
7353 of the page:
7354
7355 @Example
7356 .de y-from-top-down
7357 .  sp |\\$1-\\n[.v]u
7358 ..
7359 .
7360 .de y-from-bot-up
7361 .  sp |\\n[.p]u-\\$1-\\n[.v]u
7362 ..
7363 @endExample
7364
7365 @noindent
7366 A call to @samp{.y-from-bot-up 10c} means that the bottom of the next
7367 line will be at 10@dmn{cm} from the paper edge at the bottom.
7368
7369 If a vertical trap is sprung during execution of @code{sp}, the amount
7370 of vertical space after the trap is discarded.  For example, this
7371
7372 @Example
7373 .de xxx
7374 ..
7375 .
7376 .wh 0 xxx
7377 .
7378 .pl 5v
7379 foo
7380 .sp 2
7381 bar
7382 .sp 50
7383 baz
7384 @endExample
7385
7386 @noindent
7387 results in
7388
7389 @Example
7390 foo
7391
7392
7393 bar
7394
7395 baz
7396 @endExample
7397
7398 @cindex @code{sp} request, and traps
7399 @cindex discarded space in traps
7400 @cindex space, discarded, in traps
7401 @cindex traps, and discarded space
7402 The amount of discarded space is available in the number register
7403 @code{.trunc}.
7404
7405 To protect @code{sp} against vertical traps, use the @code{vpt} request:
7406
7407 @Example
7408 .vpt 0
7409 .sp -3
7410 .vpt 1
7411 @endExample
7412 @endDefreq
7413
7414 @DefreqList {ls, [@Var{nnn}]}
7415 @DefregListEndx {.L}
7416 @cindex double-spacing (@code{ls})
7417 Output @w{@var{nnn}@minus{}1} blank lines after each line of text.  With
7418 no argument, @code{gtroff} uses the previous value before the last
7419 @code{ls} call.
7420
7421 @Example
7422 .ls 2    \" This causes double-spaced output
7423 .ls 3    \" This causes triple-spaced output
7424 .ls      \" Again double-spaced
7425 @endExample
7426
7427 The line spacing is associated with the current environment
7428 (@pxref{Environments}).
7429
7430 @cindex line spacing register (@code{.L})
7431 The read-only number register @code{.L} contains the current line
7432 spacing setting.
7433 @endDefreq
7434
7435 @xref{Changing Type Sizes}, for the requests @code{vs} and @code{pvs} as
7436 alternatives to @code{ls}.
7437
7438 @DefescList {\\x, ', spacing, '}
7439 @DefregListEndx {.a}
7440 Sometimes, extra vertical spacing is only needed occasionally, e.g.@: to
7441 allow space for a tall construct (like an equation).  The @code{\x}
7442 escape does this.  The escape is given a numerical argument, usually
7443 enclosed in quotes (like @samp{\x'3p'}); the default scaling indicator
7444 is @samp{v}.  If this number is positive extra vertical space is
7445 inserted below the current line.  A negative number adds space above.
7446 If this escape is used multiple times on the same line, the maximum of
7447 the values is used.
7448
7449 @xref{Escapes}, for details on parameter delimiting characters.
7450
7451 @cindex extra post-vertical line space register (@code{.a})
7452 The @code{.a} read-only number register contains the most recent
7453 (nonnegative) extra vertical line space.
7454
7455 Using @code{\x} can be necessary in combination with the @code{\b}
7456 escape, as the following example shows.
7457
7458 @Example
7459 This is a test with the \[rs]b escape.
7460 .br
7461 This is a test with the \[rs]b escape.
7462 .br
7463 This is a test with \b'xyz'\x'-1m'\x'1m'.
7464 .br
7465 This is a test with the \[rs]b escape.
7466 .br
7467 This is a test with the \[rs]b escape.
7468 @endExample
7469
7470 @noindent
7471 produces
7472
7473 @Example
7474 This is a test with the \b escape.
7475 This is a test with the \b escape.
7476                     x
7477 This is a test with y.
7478                     z
7479 This is a test with the \b escape.
7480 This is a test with the \b escape.
7481 @endExample
7482 @endDefesc
7483
7484 @DefreqList {ns, }
7485 @DefreqItemx {rs, }
7486 @DefregListEndx {.ns}
7487 @cindex @code{sp} request, and no-space mode
7488 @cindex no-space mode (@code{ns})
7489 @cindex mode, no-space (@code{ns})
7490 @cindex blank lines, disabling
7491 @cindex lines, blank, disabling
7492 Enable @dfn{no-space mode}.  In this mode, spacing (either via @code{sp}
7493 or via blank lines) is disabled.  The @code{bp} request to advance to
7494 the next page is also disabled, except if it is accompanied by a page
7495 number (see @ref{Page Control}, for more information).  This mode ends
7496 when actual text is output or the @code{rs} request is encountered, which
7497 ends no-space mode.  The read-only number register @code{.ns} is set
7498 to@tie{}1 as long as no-space mode is active.
7499
7500 This request is useful for macros that conditionally insert vertical
7501 space before the text starts (for example, a paragraph macro could
7502 insert some space except when it is the first paragraph after a section
7503 header).
7504 @endDefreq
7505
7506
7507 @c =====================================================================
7508
7509 @node Tabs and Fields, Character Translations, Manipulating Spacing, gtroff Reference
7510 @section Tabs and Fields
7511 @cindex tabs, and fields
7512 @cindex fields, and tabs
7513
7514 @cindex @acronym{EBCDIC} encoding of a tab
7515 A tab character (@acronym{ASCII} char@tie{}9, @acronym{EBCDIC}
7516 char@tie{}5) causes a horizontal movement to the next tab stop (much
7517 like it did on a typewriter).
7518
7519 @Defesc {\\t, , , }
7520 @cindex tab character, non-interpreted (@code{\t})
7521 @cindex character, tab, non-interpreted (@code{\t})
7522 @cindex @code{\t}, and copy-in mode
7523 @cindex copy-in mode, and @code{\t}
7524 @cindex mode, copy-in, and @code{\t}
7525 This escape is a non-interpreted tab character.  In copy mode
7526 (@pxref{Copy-in Mode}), @code{\t} is the same as a real tab character.
7527 @endDefesc
7528
7529 @DefreqList {ta, [@Var{n1} @Var{n2} @dots{} @Var{nn} @t{T} @Var{r1} @Var{r2} @dots{} @Var{rn}]}
7530 @DefregListEndx {.tabs}
7531 Change tab stop positions.  This request takes a series of tab
7532 specifiers as arguments (optionally divided into two groups with the
7533 letter @samp{T}) that indicate where each tab stop is to be (overriding
7534 any previous settings).
7535
7536 Tab stops can be specified absolutely, i.e., as the distance from the
7537 left margin.  For example, the following sets 6@tie{}tab stops every one
7538 inch.
7539
7540 @Example
7541 .ta 1i 2i 3i 4i 5i 6i
7542 @endExample
7543
7544 Tab stops can also be specified using a leading @samp{+}, which means
7545 that the specified tab stop is set relative to the previous tab stop.
7546 For example, the following is equivalent to the previous example.
7547
7548 @Example
7549 .ta 1i +1i +1i +1i +1i +1i
7550 @endExample
7551
7552 @code{gtroff} supports an extended syntax to specify repeat values after
7553 the @samp{T} mark (these values are always taken as relative) -- this is
7554 the usual way to specify tabs set at equal intervals.  The following is,
7555 yet again, the same as the previous examples.  It does even more since
7556 it defines an infinite number of tab stops separated by one inch.
7557
7558 @Example
7559 .ta T 1i
7560 @endExample
7561
7562 Now we are ready to interpret the full syntax given at the beginning:
7563 Set tabs at positions @var{n1}, @var{n2}, @dots{}, @var{nn} and then set
7564 tabs at @var{nn}+@var{r1}, @var{nn}+@var{r2}, @dots{}, @var{nn}+@var{rn}
7565 and then at @var{nn}+@var{rn}+@var{r1}, @var{nn}+@var{rn}+@var{r2},
7566 @dots{}, @var{nn}+@var{rn}+@var{rn}, and so on.
7567
7568 Example: @samp{4c +6c T 3c 5c 2c} is equivalent to @samp{4c 10c 13c 18c
7569 20c 23c 28c 30c @dots{}}.
7570
7571 The material in each tab column (i.e., the column between two tab stops)
7572 may be justified to the right or left or centered in the column.  This
7573 is specified by appending @samp{R}, @samp{L}, or @samp{C} to the tab
7574 specifier.  The default justification is @samp{L}.  Example:
7575
7576 @Example
7577 .ta 1i 2iC 3iR
7578 @endExample
7579
7580 Some notes:
7581
7582 @itemize @bullet
7583 @item
7584 The default unit of the @code{ta} request is @samp{m}.
7585
7586 @item
7587 A tab stop is converted into a non-breakable horizontal movement that
7588 can be neither stretched nor squeezed.  For example,
7589
7590 @Example
7591 .ds foo a\tb\tc
7592 .ta T 5i
7593 \*[foo]
7594 @endExample
7595
7596 @noindent
7597 creates a single line, which is a bit longer than 10@tie{}inches (a
7598 string is used to show exactly where the tab characters are).  Now
7599 consider the following:
7600
7601 @Example
7602 .ds bar a\tb b\tc
7603 .ta T 5i
7604 \*[bar]
7605 @endExample
7606
7607 @noindent
7608 @code{gtroff} first converts the tab stops of the line into unbreakable
7609 horizontal movements, then splits the line after the second @samp{b}
7610 (assuming a sufficiently short line length).  Usually, this isn't what
7611 the user wants.
7612
7613 @item
7614 Superfluous tabs (i.e., tab characters that do not correspond to a tab
7615 stop) are ignored except the first one, which delimits the characters
7616 belonging to the last tab stop for right-justifying or centering.
7617 Consider the following example
7618
7619 @Example
7620 .ds Z   foo\tbar\tfoo
7621 .ds ZZ  foo\tbar\tfoobar
7622 .ds ZZZ foo\tbar\tfoo\tbar
7623 .ta 2i 4iR
7624 \*[Z]
7625 .br
7626 \*[ZZ]
7627 .br
7628 \*[ZZZ]
7629 .br
7630 @endExample
7631
7632 @noindent
7633 which produces the following output:
7634
7635 @Example
7636 foo                 bar              foo
7637 foo                 bar           foobar
7638 foo                 bar              foobar
7639 @endExample
7640
7641 @noindent
7642 The first line right-justifies the second `foo' relative to the tab
7643 stop.  The second line right-justifies `foobar'.  The third line finally
7644 right-justifies only `foo' because of the additional tab character, which
7645 marks the end of the string belonging to the last defined tab stop.
7646
7647 @item
7648 Tab stops are associated with the current environment
7649 (@pxref{Environments}).
7650
7651 @item
7652 Calling @code{ta} without an argument removes all tab stops.
7653
7654 @item
7655 @cindex tab stops, for TTY output devices
7656 The start-up value of @code{gtroff} is @w{@samp{T 0.8i}}.
7657 @end itemize
7658
7659 @cindex tab settings register (@code{.tabs})
7660 The read-only number register @code{.tabs} contains a string
7661 representation of the current tab settings suitable for use as an
7662 argument to the @code{ta} request.
7663
7664 @Example
7665 .ds tab-string \n[.tabs]
7666 \*[tab-string]
7667     @result{} T120u
7668 @endExample
7669
7670 @cindex @code{.S} register, Plan@tie{}9 alias for @code{.tabs}
7671 @cindex @code{.tabs} register, Plan@tie{}9 alias (@code{.S})
7672 The @code{troff} version of the Plan@tie{}9 operating system uses
7673 register @code{.S} for the same purpose.
7674 @endDefreq
7675
7676 @Defreq {tc, [@Var{fill-glyph}]}
7677 @cindex tab repetition character (@code{tc})
7678 @cindex character, tab repetition (@code{tc})
7679 @cindex glyph, tab repetition (@code{tc})
7680 Normally @code{gtroff} fills the space to the next tab stop with
7681 whitespace.  This can be changed with the @code{tc} request.  With no
7682 argument @code{gtroff} reverts to using whitespace, which is the
7683 default.  The value of this @dfn{tab repetition character} is associated
7684 with the current environment (@pxref{Environments}).@footnote{@dfn{Tab
7685 repetition character} is a misnomer since it is an output glyph.}
7686 @endDefreq
7687
7688 @DefreqList {linetabs, n}
7689 @DefregListEndx {.linetabs}
7690 @cindex tab, line-tabs mode
7691 @cindex line-tabs mode
7692 @cindex mode, line-tabs
7693 If @var{n} is missing or not zero, enable @dfn{line-tabs} mode, or
7694 disable it otherwise (the default).  In line-tabs mode, @code{gtroff}
7695 computes tab distances relative to the (current) output line instead of
7696 the input line.
7697
7698 For example, the following code:
7699
7700 @Example
7701 .ds x a\t\c
7702 .ds y b\t\c
7703 .ds z c
7704 .ta 1i 3i
7705 \*x
7706 \*y
7707 \*z
7708 @endExample
7709
7710 @noindent
7711 in normal mode, results in the output
7712
7713 @Example
7714 a         b         c
7715 @endExample
7716
7717 @noindent
7718 in line-tabs mode, the same code outputs
7719
7720 @Example
7721 a         b                   c
7722 @endExample
7723
7724 Line-tabs mode is associated with the current environment.  The
7725 read-only register @code{.linetabs} is set to@tie{}1 if in line-tabs
7726 mode, and 0 in normal mode.
7727 @endDefreq
7728
7729 @menu
7730 * Leaders::
7731 * Fields::
7732 @end menu
7733
7734 @c ---------------------------------------------------------------------
7735
7736 @node Leaders, Fields, Tabs and Fields, Tabs and Fields
7737 @subsection Leaders
7738 @cindex leaders
7739
7740 Sometimes it may may be desirable to use the @code{tc} request to fill a
7741 particular tab stop with a given glyph (for example dots in a table of
7742 contents), but also normal tab stops on the rest of the line.  For this
7743 @code{gtroff} provides an alternate tab mechanism, called @dfn{leaders},
7744 which does just that.
7745
7746 @cindex leader character
7747 A leader character (character code@tie{}1) behaves similarly to a tab
7748 character: It moves to the next tab stop.  The only difference is that
7749 for this movement, the fill glyph defaults to a period character and not
7750 to space.
7751
7752 @Defesc {\\a, , , }
7753 @cindex leader character, non-interpreted (@code{\a})
7754 @cindex character, leader, non-interpreted (@code{\a})
7755 @cindex @code{\a}, and copy-in mode
7756 @cindex copy-in mode, and @code{\a}
7757 @cindex mode, copy-in, and @code{\a}
7758 This escape is a non-interpreted leader character.  In copy mode
7759 (@pxref{Copy-in Mode}), @code{\a} is the same as a real leader
7760 character.
7761 @endDefesc
7762
7763 @Defreq {lc, [@Var{fill-glyph}]}
7764 @cindex leader repetition character (@code{lc})
7765 @cindex character, leader repetition (@code{lc})
7766 @cindex glyph, leader repetition (@code{lc})
7767 Declare the @dfn{leader repetition character}.@footnote{@dfn{Leader
7768 repetition character} is a misnomer since it is an output glyph.}
7769 Without an argument, leaders act the same as tabs (i.e., using
7770 whitespace for filling).  @code{gtroff}'s start-up value is a dot
7771 (@samp{.}).  The value of the leader repetition character is associated
7772 with the current environment (@pxref{Environments}).
7773 @endDefreq
7774
7775 @cindex table of contents
7776 @cindex contents, table of
7777 For a table of contents, to name an example, tab stops may be defined so
7778 that the section number is one tab stop, the title is the second with
7779 the remaining space being filled with a line of dots, and then the page
7780 number slightly separated from the dots.
7781
7782 @Example
7783 .ds entry 1.1\tFoo\a\t12
7784 .lc .
7785 .ta 1i 5i +.25i
7786 \*[entry]
7787 @endExample
7788
7789 @noindent
7790 This produces
7791
7792 @Example
7793 1.1  Foo..........................................  12
7794 @endExample
7795
7796 @c ---------------------------------------------------------------------
7797
7798 @node Fields,  , Leaders, Tabs and Fields
7799 @subsection Fields
7800 @cindex fields
7801
7802 @cindex field delimiting character (@code{fc})
7803 @cindex delimiting character, for fields (@code{fc})
7804 @cindex character, field delimiting (@code{fc})
7805 @cindex field padding character (@code{fc})
7806 @cindex padding character, for fields (@code{fc})
7807 @cindex character, field padding (@code{fc})
7808 @dfn{Fields} are a more general way of laying out tabular data.  A field
7809 is defined as the data between a pair of @dfn{delimiting characters}.
7810 It contains substrings that are separated by @dfn{padding characters}.
7811 The width of a field is the distance on the @emph{input} line from the
7812 position where the field starts to the next tab stop.  A padding
7813 character inserts stretchable space similar to @TeX{}'s @code{\hss}
7814 command (thus it can even be negative) to make the sum of all substring
7815 lengths plus the stretchable space equal to the field width.  If more
7816 than one padding character is inserted, the available space is evenly
7817 distributed among them.
7818
7819 @Defreq {fc, [@Var{delim-char} [@Var{padding-char}]]}
7820 Define a delimiting and a padding character for fields.  If the latter
7821 is missing, the padding character defaults to a space character.  If
7822 there is no argument at all, the field mechanism is disabled (which is
7823 the default).  Note that contrary to e.g.@: the tab repetition
7824 character, delimiting and padding characters are @emph{not} associated
7825 to the current environment (@pxref{Environments}).
7826
7827 Example:
7828
7829 @Example
7830 .fc # ^
7831 .ta T 3i
7832 #foo^bar^smurf#
7833 .br
7834 #foo^^bar^smurf#
7835 @endExample
7836
7837 @noindent
7838 and here the result:
7839
7840 @Example
7841 foo         bar          smurf
7842 foo            bar       smurf
7843 @endExample
7844 @endDefreq
7845
7846
7847 @c =====================================================================
7848
7849 @node Character Translations, Troff and Nroff Mode, Tabs and Fields, gtroff Reference
7850 @section Character Translations
7851 @cindex character translations
7852 @cindex translations of characters
7853
7854 @cindex control character, changing (@code{cc})
7855 @cindex character, control, changing (@code{cc})
7856 @cindex no-break control character, changing (@code{c2})
7857 @cindex character, no-break control, changing (@code{c2})
7858 @cindex control character, no-break, changing (@code{c2})
7859 The control character (@samp{.}) and the no-break control character
7860 (@samp{'}) can be changed with the @code{cc} and @code{c2} requests,
7861 respectively.
7862
7863 @Defreq {cc, [@Var{c}]}
7864 Set the control character to@tie{}@var{c}.  With no argument the default
7865 control character @samp{.} is restored.  The value of the control
7866 character is associated with the current environment
7867 (@pxref{Environments}).
7868 @endDefreq
7869
7870 @Defreq {c2, [@Var{c}]}
7871 Set the no-break control character to@tie{}@var{c}.  With no argument
7872 the default control character @samp{'} is restored.  The value of the
7873 no-break control character is associated with the current environment
7874 (@pxref{Environments}).
7875 @endDefreq
7876
7877 @xref{Requests}.
7878
7879 @Defreq {eo, }
7880 @cindex disabling @code{\} (@code{eo})
7881 @cindex @code{\}, disabling (@code{eo})
7882 Disable the escape mechanism completely.  After executing this request,
7883 the backslash character @samp{\} no longer starts an escape sequence.
7884
7885 This request can be very helpful in writing macros since it is not
7886 necessary then to double the escape character.  Here an example:
7887
7888 @Example
7889 .\" This is a simplified version of the
7890 .\" .BR request from the man macro package
7891 .eo
7892 .de BR
7893 .  ds result \&
7894 .  while (\n[.$] >= 2) \@{\
7895 .    as result \fB\$1\fR\$2
7896 .    shift 2
7897 .  \@}
7898 .  if \n[.$] .as result \fB\$1
7899 \*[result]
7900 .  ft R
7901 ..
7902 .ec
7903 @endExample
7904 @endDefreq
7905
7906 @Defreq {ec, [@Var{c}]}
7907 @cindex escape character, changing (@code{ec})
7908 @cindex character, escape, changing (@code{ec})
7909 Set the escape character to@tie{}@var{c}.  With no argument the default
7910 escape character @samp{\} is restored.  It can be also used to re-enable
7911 the escape mechanism after an @code{eo} request.
7912
7913 Note that changing the escape character globally likely breaks macro
7914 packages since @code{gtroff} has no mechanism to `intern' macros, i.e.,
7915 to convert a macro definition into an internal form that is independent
7916 of its representation (@TeX{} has this mechanism).  If a macro is
7917 called, it is executed literally.
7918 @endDefreq
7919
7920 @DefreqList {ecs, }
7921 @DefreqListEndx {ecr, }
7922 The @code{ecs} request saves the current escape character in an internal
7923 register.  Use this request in combination with the @code{ec} request to
7924 temporarily change the escape character.
7925
7926 The @code{ecr} request restores the escape character saved with
7927 @code{ecs}.  Without a previous call to @code{ecs}, this request sets
7928 the escape character to @code{\}.
7929 @endDefreq
7930
7931 @DefescList {\\\\, , , }
7932 @DefescItemx {\\e, , , }
7933 @DefescListEndx {\\E, , , }
7934 Print the current escape character (which is the backslash character
7935 @samp{\} by default).
7936
7937 @code{\\} is a `delayed' backslash; more precisely, it is the default
7938 escape character followed by a backslash, which no longer has special
7939 meaning due to the leading escape character.  It is @emph{not} an escape
7940 sequence in the usual sense!  In any unknown escape sequence
7941 @code{\@var{X}} the escape character is ignored and @var{X} is printed.
7942 But if @var{X} is equal to the current escape character, no warning is
7943 emitted.
7944
7945 @cindex @code{\E}, and copy-in mode
7946 @cindex copy-in mode, and @code{\E}
7947 @cindex mode, copy-in, and @code{\E}
7948 As a consequence, only at top-level or in a diversion a backslash glyph
7949 is printed; in copy-in mode, it expands to a single backslash, which then
7950 combines with the following character to an escape sequence.
7951
7952 The @code{\E} escape differs from @code{\e} by printing an escape
7953 character that is not interpreted in copy mode.  Use this to define
7954 strings with escapes that work when used in copy mode (for example, as a
7955 macro argument).  The following example defines strings to begin and end
7956 a superscript:
7957
7958 @Example
7959 .ds @{ \v'-.3m'\s'\En[.s]*60/100'
7960 .ds @} \s0\v'.3m'
7961 @endExample
7962
7963 Another example to demonstrate the differences between the various
7964 escape sequences, using a strange escape character, @samp{-}.
7965
7966 @Example
7967 .ec -
7968 .de xxx
7969 --A'123'
7970 ..
7971 .xxx
7972     @result{} -A'foo'
7973 @endExample
7974
7975 @noindent
7976 The result is surprising for most users, expecting @samp{1} since
7977 @samp{foo} is a valid identifier.  What has happened?  As mentioned
7978 above, the leading escape character makes the following character
7979 ordinary.  Written with the default escape character the sequence
7980 @samp{--} becomes @samp{\-} -- this is the minus sign.
7981
7982 If the escape character followed by itself is a valid escape sequence,
7983 only @code{\E} yields the expected result:
7984
7985 @Example
7986 .ec -
7987 .de xxx
7988 -EA'123'
7989 ..
7990 .xxx
7991     @result{} 1
7992 @endExample
7993 @endDefesc
7994
7995 @Defesc {\\., , , }
7996 Similar to @code{\\}, the sequence @code{\.} isn't a real escape
7997 sequence.  As before, a warning message is suppressed if the escape
7998 character is followed by a dot, and the dot itself is printed.
7999
8000 @Example
8001 .de foo
8002 .  nop foo
8003 .
8004 .  de bar
8005 .    nop bar
8006 \\..
8007 .
8008 ..
8009 .foo
8010 .bar
8011     @result{} foo bar
8012 @endExample
8013
8014 @noindent
8015 The first backslash is consumed while the macro is read, and the second
8016 is swallowed while executing macro @code{foo}.
8017 @endDefesc
8018
8019 A @dfn{translation} is a mapping of an input character to an output
8020 glyph.  The mapping occurs at output time, i.e., the input character
8021 gets assigned the metric information of the mapped output character
8022 right before input tokens are converted to nodes (@pxref{Gtroff
8023 Internals}, for more on this process).
8024
8025 @DefreqList {tr, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
8026 @DefreqListEndx {trin, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
8027 Translate character @var{a} to glyph@tie{}@var{b}, character @var{c} to
8028 glyph@tie{}@var{d}, etc.  If there is an odd number of arguments, the
8029 last one is translated to an unstretchable space (@w{@samp{\ }}).
8030
8031 The @code{trin} request is identical to @code{tr}, but when you unformat
8032 a diversion with @code{asciify} it ignores the translation.
8033 @xref{Diversions}, for details about the @code{asciify} request.
8034
8035 Some notes:
8036
8037 @itemize @bullet
8038 @item
8039 @cindex @code{\(}, and translations
8040 @cindex @code{\[}, and translations
8041 @cindex @code{\'}, and translations
8042 @cindex @code{\`}, and translations
8043 @cindex @code{\-}, and translations
8044 @cindex @code{\_}, and translations
8045 @cindex @code{\C}, and translations
8046 @cindex @code{\N}, and translations
8047 @cindex @code{char} request, and translations
8048 @cindex special characters
8049 @cindex character, special
8050 @cindex numbered glyph (@code{\N})
8051 @cindex glyph, numbered (@code{\N})
8052 Special characters (@code{\(@var{xx}}, @code{\[@var{xxx}]},
8053 @code{\C'@var{xxx}'}, @code{\'}, @code{\`}, @code{\-}, @code{\_}),
8054 glyphs defined with the @code{char} request, and numbered glyphs
8055 (@code{\N'@var{xxx}'}) can be translated also.
8056
8057 @item
8058 @cindex @code{\e}, and translations
8059 The @code{\e} escape can be translated also.
8060
8061 @item
8062 @cindex @code{\%}, and translations
8063 @cindex @code{\~}, and translations
8064 Characters can be mapped onto the @code{\%} and @code{\~} escapes (but
8065 @code{\%} and @code{\~} can't be mapped onto another glyph).
8066
8067 @item
8068 @cindex backspace character, and translations
8069 @cindex character, backspace, and translations
8070 @cindex leader character, and translations
8071 @cindex character, leader, and translations
8072 @cindex newline character, and translations
8073 @cindex character, newline, and translations
8074 @cindex tab character, and translations
8075 @cindex character, tab, and translations
8076 @cindex @code{\a}, and translations
8077 @cindex @code{\t}, and translations
8078 The following characters can't be translated: space (with one exception,
8079 see below), backspace, newline, leader (and @code{\a}), tab (and
8080 @code{\t}).
8081
8082 @item
8083 @cindex @code{shc} request, and translations
8084 Translations are not considered for finding the soft hyphen character
8085 set with the @code{shc} request.
8086
8087 @item
8088 @cindex @code{\&}, and translations
8089 The pair @samp{@var{c}\&} (this is an arbitrary character@tie{}@var{c}
8090 followed by the zero width space character) maps this character to
8091 nothing.
8092
8093 @Example
8094 .tr a\&
8095 foo bar
8096     @result{} foo br
8097 @endExample
8098
8099 @noindent
8100 It is even possible to map the space character to nothing:
8101
8102 @Example
8103 .tr aa \&
8104 foo bar
8105     @result{} foobar
8106 @endExample
8107
8108 @noindent
8109 As shown in the example, the space character can't be the first
8110 character/glyph pair as an argument of @code{tr}.  Additionally, it is
8111 not possible to map the space character to any other glyph; requests
8112 like @w{@samp{.tr aa x}} undo @w{@samp{.tr aa \&}} instead.
8113
8114 If justification is active, lines are justified in spite of the `empty'
8115 space character (but there is no minimal distance, i.e.@: the space
8116 character, between words).
8117
8118 @item
8119 After an output glyph has been constructed (this happens at the moment
8120 immediately before the glyph is appended to an output glyph list, either
8121 by direct output, in a macro, diversion, or string), it is no longer
8122 affected by @code{tr}.
8123
8124 @item
8125 Translating character to glyphs where one of them or both are undefined
8126 is possible also; @code{tr} does not check whether the entities in its
8127 argument do exist.
8128
8129 @xref{Gtroff Internals}.
8130
8131 @item
8132 @code{troff} no longer has a hard-coded dependency on @w{Latin-1}; all
8133 @code{char@var{XXX}} entities have been removed from the font
8134 description files.  This has a notable consequence that shows up in
8135 warnings like @code{can't find character with input code @var{XXX}} if
8136 the @code{tr} request isn't handled properly.
8137
8138 Consider the following translation:
8139
8140 @Example
8141 .tr Ã©Ã‰
8142 @endExample
8143
8144 @noindent
8145 This maps input character @code{é} onto glyph @code{É}, which is
8146 identical to glyph @code{char201}.  But this glyph intentionally doesn't
8147 exist!  Instead, @code{\[char201]} is treated as an input character
8148 entity and is by default mapped onto @code{\['E]}, and @code{gtroff}
8149 doesn't handle translations of translations.
8150
8151 The right way to write the above translation is
8152
8153 @Example
8154 .tr Ã©\['E]
8155 @endExample
8156
8157 @noindent
8158 In other words, the first argument of @code{tr} should be an input
8159 character or entity, and the second one a glyph entity.
8160
8161 @item
8162 Without an argument, the @code{tr} request is ignored.
8163 @end itemize
8164 @endDefreq
8165
8166 @Defreq {trnt, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
8167 @cindex @code{\!}, and @code{trnt}
8168 @code{trnt} is the same as the @code{tr} request except that the
8169 translations do not apply to text that is transparently throughput into
8170 a diversion with @code{\!}.  @xref{Diversions}, for more information.
8171
8172 For example,
8173
8174 @Example
8175 .tr ab
8176 .di x
8177 \!.tm a
8178 .di
8179 .x
8180 @endExample
8181
8182 @noindent
8183 prints @samp{b} to the standard error stream; if @code{trnt} is used
8184 instead of @code{tr} it prints @samp{a}.
8185 @endDefreq
8186
8187
8188 @c =====================================================================
8189
8190 @node Troff and Nroff Mode, Line Layout, Character Translations, gtroff Reference
8191 @section Troff and Nroff Mode
8192 @cindex troff mode
8193 @cindex mode, troff
8194 @cindex nroff mode
8195 @cindex mode, nroff
8196
8197 Originally, @code{nroff} and @code{troff} were two separate programs,
8198 the former for TTY output, the latter for everything else.  With GNU
8199 @code{troff}, both programs are merged into one executable, sending its
8200 output to a device driver (@code{grotty} for TTY devices, @code{grops}
8201 for @sc{PostScript}, etc.)@: which interprets the intermediate output of
8202 @code{gtroff}.  For @acronym{UNIX} @code{troff} it makes sense to talk
8203 about @dfn{Nroff mode} and @dfn{Troff mode} since the differences are
8204 hardcoded.  For GNU @code{troff}, this distinction is not appropriate
8205 because @code{gtroff} simply takes the information given in the font
8206 files for a particular device without handling requests specially if a
8207 TTY output device is used.
8208
8209 Usually, a macro package can be used with all output devices.
8210 Nevertheless, it is sometimes necessary to make a distinction between
8211 TTY and non-TTY devices: @code{gtroff} provides two built-in conditions
8212 @samp{n} and @samp{t} for the @code{if}, @code{ie}, and @code{while}
8213 requests to decide whether @code{gtroff} shall behave like @code{nroff}
8214 or like @code{troff}.
8215
8216 @Defreq {troff, }
8217 @pindex troffrc
8218 @pindex troffrc-end
8219 Make the @samp{t} built-in condition true (and the @samp{n} built-in
8220 condition false) for @code{if}, @code{ie}, and @code{while} conditional
8221 requests.  This is the default if @code{gtroff} (@emph{not}
8222 @code{groff}) is started with the @option{-R} switch to avoid loading of
8223 the start-up files @file{troffrc} and @file{troffrc-end}.  Without
8224 @option{-R}, @code{gtroff} stays in troff mode if the output device is
8225 not a TTY (e.g.@: `ps').
8226 @endDefreq
8227
8228 @Defreq {nroff, }
8229 @pindex tty.tmac
8230 Make the @samp{n} built-in condition true (and the @samp{t} built-in
8231 condition false) for @code{if}, @code{ie}, and @code{while} conditional
8232 requests.  This is the default if @code{gtroff} uses a TTY output
8233 device; the code for switching to nroff mode is in the file
8234 @file{tty.tmac}, which is loaded by the start-up file @code{troffrc}.
8235 @endDefreq
8236
8237 @xref{Conditionals and Loops}, for more details on built-in conditions.
8238
8239
8240 @c =====================================================================
8241
8242 @node Line Layout, Line Control, Troff and Nroff Mode, gtroff Reference
8243 @section Line Layout
8244 @cindex line layout
8245 @cindex layout, line
8246
8247 @cindex dimensions, line
8248 @cindex line dimensions
8249 The following drawing shows the dimensions that @code{gtroff} uses for
8250 placing a line of output onto the page.  They are labeled with the
8251 request that manipulates each dimension.
8252
8253 @Example
8254      -->| in |<--
8255         |<-----------ll------------>|
8256    +----+----+----------------------+----+
8257    |    :    :                      :    |
8258    +----+----+----------------------+----+
8259 -->| po |<--
8260    |<--------paper width---------------->|
8261 @endExample
8262
8263 @noindent
8264 These dimensions are:
8265
8266 @ftable @code
8267 @item po
8268 @cindex left margin (@code{po})
8269 @cindex margin, left (@code{po})
8270 @cindex page offset (@code{po})
8271 @cindex offset, page (@code{po})
8272 @dfn{Page offset} -- this is the leftmost position of text on the final
8273 output, defining the @dfn{left margin}.
8274
8275 @item in
8276 @cindex indentation (@code{in})
8277 @cindex line indentation (@code{in})
8278 @dfn{Indentation} -- this is the distance from the left margin where
8279 text is printed.
8280
8281 @item ll
8282 @cindex line length (@code{ll})
8283 @cindex length of line (@code{ll})
8284 @dfn{Line length} -- this is the distance from the left margin to right
8285 margin.
8286 @end ftable
8287
8288 A simple demonstration:
8289
8290 @Example
8291 .ll 3i
8292 This is text without indentation.
8293 The line length has been set to 3\~inch.
8294 .in +.5i
8295 .ll -.5i
8296 Now the left and right margins are both increased.
8297 .in
8298 .ll
8299 Calling .in and .ll without parameters restore
8300 the previous values.
8301 @endExample
8302
8303 Result:
8304
8305 @Example
8306 This  is text without indenta-
8307 tion.   The  line  length  has
8308 been set to 3 inch.
8309      Now   the  left  and
8310      right  margins   are
8311      both increased.
8312 Calling  .in  and  .ll without
8313 parameters restore the  previ-
8314 ous values.
8315 @endExample
8316
8317 @DefreqList {po, [@Var{offset}]}
8318 @DefreqItem {po, @t{+}@Var{offset}}
8319 @DefreqItem {po, @t{-}@Var{offset}}
8320 @DefregListEndx {.o}
8321 @pindex troffrc
8322 Set horizontal page offset to @var{offset} (or increment or decrement
8323 the current value by @var{offset}).  Note that this request does not
8324 cause a break, so changing the page offset in the middle of text being
8325 filled may not yield the expected result.  The initial value is
8326 1@dmn{i}.  For TTY output devices, it is set to 0 in the startup file
8327 @file{troffrc}; the default scaling indicator is @samp{m} (and not
8328 @samp{v} as incorrectly documented in the original @acronym{UNIX} troff
8329 manual).
8330
8331 The current page offset can be found in the read-only number register
8332 @samp{.o}.
8333
8334 If @code{po} is called without an argument, the page offset is reset to
8335 the previous value before the last call to @code{po}.
8336
8337 @Example
8338 .po 3i
8339 \n[.o]
8340     @result{} 720
8341 .po -1i
8342 \n[.o]
8343     @result{} 480
8344 .po
8345 \n[.o]
8346     @result{} 720
8347 @endExample
8348 @endDefreq
8349
8350 @DefreqList {in, [@Var{indent}]}
8351 @DefreqItem {in, @t{+}@Var{indent}}
8352 @DefreqItem {in, @t{-}@Var{indent}}
8353 @DefregListEndx {.i}
8354 Set indentation to @var{indent} (or increment or decrement the current
8355 value by @var{indent}).  This request causes a break.  Initially, there
8356 is no indentation.
8357
8358 If @code{in} is called without an argument, the indentation is reset to
8359 the previous value before the last call to @code{in}.  The default
8360 scaling indicator is @samp{m}.
8361
8362 The indentation is associated with the current environment
8363 (@pxref{Environments}).
8364
8365 If a negative indentation value is specified (which is not allowed),
8366 @code{gtroff} emits a warning of type @samp{range} and sets the
8367 indentation to zero.
8368
8369 The effect of @code{in} is delayed until a partially collected line (if
8370 it exists) is output.  A temporary indentation value is reset to zero
8371 also.
8372
8373 The current indentation (as set by @code{in}) can be found in the
8374 read-only number register @samp{.i}.
8375 @endDefreq
8376
8377 @DefreqList {ti, offset}
8378 @DefreqItem {ti, @t{+}@Var{offset}}
8379 @DefreqItem {ti, @t{-}@Var{offset}}
8380 @DefregListEndx {.in}
8381 Temporarily indent the next output line by @var{offset}.  If an
8382 increment or decrement value is specified, adjust the temporary
8383 indentation relative to the value set by the @code{in} request.
8384
8385 This request causes a break; its value is associated with the current
8386 environment (@pxref{Environments}).  The default scaling indicator is
8387 @samp{m}.  A call of @code{ti} without an argument is ignored.
8388
8389 If the total indentation value is negative (which is not allowed),
8390 @code{gtroff} emits a warning of type @samp{range} and sets the
8391 temporary indentation to zero.  `Total indentation' is either
8392 @var{offset} if specified as an absolute value, or the temporary plus
8393 normal indentation, if @var{offset} is given as a relative value.
8394
8395 The effect of @code{ti} is delayed until a partially collected line (if
8396 it exists) is output.
8397
8398 The read-only number register @code{.in} is the indentation that applies
8399 to the current output line.
8400
8401 The difference between @code{.i} and @code{.in} is that the latter takes
8402 into account whether a partially collected line still uses the old
8403 indentation value or a temporary indentation value is active.
8404 @endDefreq
8405
8406 @DefreqList {ll, [@Var{length}]}
8407 @DefreqItem {ll, @t{+}@Var{length}}
8408 @DefreqItem {ll, @t{-}@Var{length}}
8409 @DefregItemx {.l}
8410 @DefregListEndx {.ll}
8411 Set the line length to @var{length} (or increment or decrement the
8412 current value by @var{length}).  Initially, the line length is set to
8413 6.5@dmn{i}.  The effect of @code{ll} is delayed until a partially
8414 collected line (if it exists) is output.  The default scaling indicator
8415 is @samp{m}.
8416
8417 If @code{ll} is called without an argument, the line length is reset to
8418 the previous value before the last call to @code{ll}.  If a negative
8419 line length is specified (which is not allowed), @code{gtroff} emits a
8420 warning of type @samp{range} and sets the line length to zero.
8421
8422 The line length is associated with the current environment
8423 (@pxref{Environments}).
8424
8425 @cindex line length register (@code{.l})
8426 The current line length (as set by @code{ll}) can be found in the
8427 read-only number register @samp{.l}.  The read-only number register
8428 @code{.ll} is the line length that applies to the current output line.
8429
8430 Similar to @code{.i} and @code{.in}, the difference between @code{.l}
8431 and @code{.ll} is that the latter takes into account whether a partially
8432 collected line still uses the old line length value.
8433 @endDefreq
8434
8435
8436 @c =====================================================================
8437
8438 @node Line Control, Page Layout, Line Layout, gtroff Reference
8439 @section Line Control
8440 @cindex line control
8441 @cindex control, line
8442
8443 It is important to understand how @code{gtroff} handles input and output
8444 lines.
8445
8446 Many escapes use positioning relative to the input line.  For example,
8447 this
8448
8449 @Example
8450 This is a \h'|1.2i'test.
8451
8452 This is a
8453 \h'|1.2i'test.
8454 @endExample
8455
8456 @noindent
8457 produces
8458
8459 @Example
8460 This is a   test.
8461
8462 This is a             test.
8463 @endExample
8464
8465 The main usage of this feature is to define macros that act exactly at
8466 the place where called.
8467
8468 @Example
8469 .\" A simple macro to underline a word
8470 .de underline
8471 .  nop \\$1\l'|0\[ul]'
8472 ..
8473 @endExample
8474
8475 @noindent
8476 In the above example, @samp{|0} specifies a negative distance from the
8477 current position (at the end of the just emitted argument @code{\$1})
8478 back to the beginning of the input line.  Thus, the @samp{\l} escape
8479 draws a line from right to left.
8480
8481 @cindex input line continuation (@code{\})
8482 @cindex line, input, continuation (@code{\})
8483 @cindex continuation, input line (@code{\})
8484 @cindex output line, continuation (@code{\c})
8485 @cindex line, output, continuation (@code{\c})
8486 @cindex continuation, output line (@code{\c})
8487 @cindex interrupted line
8488 @cindex line, interrupted
8489 @code{gtroff} makes a difference between input and output line
8490 continuation; the latter is also called @dfn{interrupting} a line.
8491
8492 @DefescList {\\@key{RET}, , ,}
8493 @DefescItemx {\\c, , ,}
8494 @DefregListEndx {.int}
8495 Continue a line.  @code{\@key{RET}} (this is a backslash at the end of a
8496 line immediately followed by a newline) works on the input level,
8497 suppressing the effects of the following newline in the input.
8498
8499 @Example
8500 This is a \
8501 .test
8502     @result{} This is a .test
8503 @endExample
8504
8505 The @samp{|} operator is also affected.
8506
8507 @cindex @code{\R}, after @code{\c}
8508 @code{\c} works on the output level.  Anything after this escape on the
8509 same line is ignored except @code{\R}, which works as usual.  Anything
8510 before @code{\c} on the same line is appended to the current partial
8511 output line.  The next non-command line after an interrupted line counts
8512 as a new input line.
8513
8514 The visual results depend on whether no-fill mode is active.
8515
8516 @itemize @bullet
8517 @item
8518 @cindex @code{\c}, and no-fill mode
8519 @cindex no-fill mode, and @code{\c}
8520 @cindex mode, no-fill, and @code{\c}
8521 If no-fill mode is active (using the @code{nf} request), the next input
8522 text line after @code{\c} is handled as a continuation of the same input
8523 text line.
8524
8525 @Example
8526 .nf
8527 This is a \c
8528 test.
8529     @result{} This is a test.
8530 @endExample
8531
8532 @item
8533 @cindex @code{\c}, and fill mode
8534 @cindex fill mode, and @code{\c}
8535 @cindex mode, fill, and @code{\c}
8536 If fill mode is active (using the @code{fi} request), a word interrupted
8537 with @code{\c} is continued with the text on the next input text line,
8538 without an intervening space.
8539
8540 @Example
8541 This is a te\c
8542 st.
8543     @result{} This is a test.
8544 @endExample
8545 @end itemize
8546
8547 Note that an intervening control line that causes a break is stronger
8548 than @code{\c}, flushing out the current partial line in the usual way.
8549
8550 @cindex interrupted line register (@code{.int})
8551 The @code{.int} register contains a positive value if the last output
8552 line was interrupted with @code{\c}; this is associated with the current
8553 environment (@pxref{Environments}).
8554 @endDefesc
8555
8556
8557 @c =====================================================================
8558
8559 @node Page Layout, Page Control, Line Control, gtroff Reference
8560 @section Page Layout
8561 @cindex page layout
8562 @cindex layout, page
8563
8564 @code{gtroff} provides some very primitive operations for controlling
8565 page layout.
8566
8567 @DefreqList {pl, [@Var{length}]}
8568 @DefreqItem {pl, @t{+}@Var{length}}
8569 @DefreqItem {pl, @t{-}@Var{length}}
8570 @DefregListEndx {.p}
8571 @cindex page length (@code{pl})
8572 @cindex length of page (@code{pl})
8573 Set the @dfn{page length} to @var{length} (or increment or decrement the
8574 current value by @var{length}).  This is the length of the physical
8575 output page.  The default scaling indicator is @samp{v}.
8576
8577 @cindex page length register (@code{.p})
8578 The current setting can be found in the read-only number register
8579 @samp{.p}.
8580
8581 @cindex top margin
8582 @cindex margin, top
8583 @cindex bottom margin
8584 @cindex margin, bottom
8585 Note that this only specifies the size of the page, not the top and
8586 bottom margins.  Those are not set by @code{gtroff} directly.
8587 @xref{Traps}, for further information on how to do this.
8588
8589 Negative @code{pl} values are possible also, but not very useful: No
8590 trap is sprung, and each line is output on a single page (thus
8591 suppressing all vertical spacing).
8592
8593 If no argument or an invalid argument is given, @code{pl} sets the page
8594 length to 11@dmn{i}.
8595 @endDefreq
8596
8597 @cindex headers
8598 @cindex footers
8599 @cindex titles
8600 @code{gtroff} provides several operations that help in setting up top
8601 and bottom titles (or headers and footers).
8602
8603 @Defreq {tl, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}}
8604 @cindex title line (@code{tl})
8605 @cindex three-part title (@code{tl})
8606 @cindex page number character (@code{%})
8607 Print a @dfn{title line}.  It consists of three parts: a left justified
8608 portion, a centered portion, and a right justified portion.  The
8609 argument separator @samp{'} can be replaced with any character not
8610 occurring in the title line.  The @samp{%} character is replaced with
8611 the current page number.  This character can be changed with the
8612 @code{pc} request (see below).
8613
8614 Without argument, @code{tl} is ignored.
8615
8616 Some notes:
8617
8618 @itemize @bullet
8619 @item
8620 The line length set by the @code{ll} request is not honoured by
8621 @code{tl}; use the @code{lt} request (described below) instead, to
8622 control line length for text set by @code{tl}.
8623
8624 @item
8625 A title line is not restricted to the top or bottom of a page.
8626
8627 @item
8628 @code{tl} prints the title line immediately, ignoring a partially filled
8629 line (which stays untouched).
8630
8631 @item
8632 It is not an error to omit closing delimiters.  For example,
8633 @w{@samp{.tl /foo}} is equivalent to @w{@samp{.tl /foo///}}: It prints a
8634 title line with the left justified word @samp{foo}; the centered and
8635 right justfied parts are empty.
8636
8637 @item
8638 @code{tl} accepts the same parameter delimiting characters as the
8639 @code{\A} escape; see @ref{Escapes}.
8640 @end itemize
8641 @endDefreq
8642
8643 @DefreqList {lt, [@Var{length}]}
8644 @DefreqItem {lt, @t{+}@Var{length}}
8645 @DefreqItem {lt, @t{-}@Var{length}}
8646 @DefregListEndx {.lt}
8647 @cindex length of title line (@code{lt})
8648 @cindex title line, length (@code{lt})
8649 @cindex title line length register (@code{.lt})
8650 The title line is printed using its own line length, which is specified
8651 (or incremented or decremented) with the @code{lt} request.  Initially,
8652 the title line length is set to 6.5@dmn{i}.  If a negative line length
8653 is specified (which is not allowed), @code{gtroff} emits a warning of
8654 type @samp{range} and sets the title line length to zero.  The default
8655 scaling indicator is @samp{m}.  If @code{lt} is called without an
8656 argument, the title length is reset to the previous value before the
8657 last call to @code{lt}.
8658
8659 The current setting of this is available in the @code{.lt} read-only
8660 number register; it is associated with the current environment
8661 (@pxref{Environments}).
8662 @endDefreq
8663
8664 @DefreqList {pn, page}
8665 @DefreqItem {pn, @t{+}@Var{page}}
8666 @DefreqItem {pn, @t{-}@Var{page}}
8667 @DefregListEndx {.pn}
8668 @cindex page number (@code{pn})
8669 @cindex number, page (@code{pn})
8670 Change (increase or decrease) the page number of the @emph{next} page.
8671 The only argument is the page number; the request is ignored without a
8672 parameter.
8673
8674 The read-only number register @code{.pn} contains the number of the next
8675 page: either the value set by a @code{pn} request, or the number of the
8676 current page plus@tie{}1.
8677 @endDefreq
8678
8679 @Defreq {pc, [@Var{char}]}
8680 @cindex changing the page number character (@code{pc})
8681 @cindex page number character, changing (@code{pc})
8682 @vindex %
8683 Change the page number character (used by the @code{tl} request) to a
8684 different character.  With no argument, this mechanism is disabled.
8685 Note that this doesn't affect the number register@tie{}@code{%}.
8686 @endDefreq
8687
8688 @xref{Traps}.
8689
8690
8691 @c =====================================================================
8692
8693 @node Page Control, Fonts and Symbols, Page Layout, gtroff Reference
8694 @section Page Control
8695 @cindex page control
8696 @cindex control, page
8697
8698 @DefreqList {bp, [@Var{page}]}
8699 @DefreqItem {bp, @t{+}@Var{page}}
8700 @DefreqItem {bp, @t{-}@Var{page}}
8701 @DefregListEndx {%}
8702 @cindex new page (@code{bp})
8703 @cindex page, new (@code{bp})
8704 Stop processing the current page and move to the next page.  This
8705 request causes a break.  It can also take an argument to set (increase,
8706 decrease) the page number of the next page (which actually becomes the
8707 current page after @code{bp} has finished).  The difference between
8708 @code{bp} and @code{pn} is that @code{pn} does not cause a break or
8709 actually eject a page.  @xref{Page Layout}.
8710
8711 @Example
8712 .de newpage                         \" define macro
8713 'bp                                 \" begin page
8714 'sp .5i                             \" vertical space
8715 .tl 'left top'center top'right top' \" title
8716 'sp .3i                             \" vertical space
8717 ..                                  \" end macro
8718 @endExample
8719
8720 @cindex @code{bp} request, and top-level diversion
8721 @cindex top-level diversion, and @code{bp}
8722 @cindex diversion, top-level, and @code{bp}
8723 @code{bp} has no effect if not called within the top-level diversion
8724 (@pxref{Diversions}).
8725
8726 @cindex page number register (@code{%})
8727 @cindex current page number (@code{%})
8728 The read-write register@tie{}@code{%} holds the current page number.
8729
8730 The number register @code{.pe} is set to@tie{}1 while @code{bp} is
8731 active.  @xref{Page Location Traps}.
8732 @endDefreq
8733
8734 @Defreq {ne, [@Var{space}]}
8735 @cindex orphan lines, preventing with @code{ne}
8736 @cindex conditional page break (@code{ne})
8737 @cindex page break, conditional (@code{ne})
8738 It is often necessary to force a certain amount of space before a new
8739 page occurs.  This is most useful to make sure that there is not a
8740 single @dfn{orphan} line left at the bottom of a page.  The @code{ne}
8741 request ensures that there is a certain distance, specified by the first
8742 argument, before the next page is triggered (see @ref{Traps}, for
8743 further information).  The default scaling indicator for @code{ne} is
8744 @samp{v}; the default value of @var{space} is@tie{}1@dmn{v} if no
8745 argument is given.
8746
8747 For example, to make sure that no fewer than 2@tie{}lines get orphaned,
8748 do the following before each paragraph:
8749
8750 @Example
8751 .ne 2
8752 text text text
8753 @endExample
8754
8755 @code{ne} then automatically causes a page break if there is space for
8756 one line only.
8757 @endDefreq
8758
8759 @DefreqList {sv, [@Var{space}]}
8760 @DefreqListEndx {os, }
8761 @cindex @code{ne} request, comparison with @code{sv}
8762 @code{sv} is similar to the @code{ne} request; it reserves the specified
8763 amount of vertical space.  If the desired amount of space exists before
8764 the next trap (or the bottom page boundary if no trap is set), the space
8765 is output immediately (ignoring a partially filled line, which stays
8766 untouched).  If there is not enough space, it is stored for later output
8767 via the @code{os} request.  The default value is@tie{}1@dmn{v} if no
8768 argument is given; the default scaling indicator is @samp{v}.
8769
8770 @cindex @code{sv} request, and no-space mode
8771 @cindex @code{os} request, and no-space mode
8772 Both @code{sv} and @code{os} ignore no-space mode.  While the @code{sv}
8773 request allows negative values for @var{space}, @code{os} ignores them.
8774 @endDefreq
8775
8776 @Defreg {nl}
8777 @cindex current vertical position (@code{nl})
8778 @cindex vertical position, current (@code{nl})
8779 @cindex position, vertical, current (@code{nl})
8780 This register contains the current vertical position.  If the vertical
8781 position is zero and the top of page transition hasn't happened yet,
8782 @code{nl} is set to negative value.  @code{gtroff} itself does this at
8783 the very beginning of a document before anything has been printed, but
8784 the main usage is to plant a header trap on a page if this page has
8785 already started.
8786
8787 Consider the following:
8788
8789 @Example
8790 .de xxx
8791 .  sp
8792 .  tl ''Header''
8793 .  sp
8794 ..
8795 .
8796 First page.
8797 .bp
8798 .wh 0 xxx
8799 .nr nl (-1)
8800 Second page.
8801 @endExample
8802
8803 @noindent
8804 Result:
8805
8806 @Example
8807 First page.
8808
8809 ...
8810
8811                              Header
8812
8813 Second page.
8814
8815 ...
8816 @endExample
8817
8818 @noindent
8819 Without resetting @code{nl} to a negative value, the just planted trap
8820 would be active beginning with the @emph{next} page, not the current
8821 one.
8822
8823 @xref{Diversions}, for a comparison with the @code{.h} and @code{.d}
8824 registers.
8825 @endDefreg
8826
8827
8828 @c =====================================================================
8829
8830 @node Fonts and Symbols, Sizes, Page Control, gtroff Reference
8831 @section Fonts and Symbols
8832 @cindex fonts
8833
8834 @code{gtroff} can switch fonts at any point in the text.
8835
8836 The basic set of fonts is @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
8837 These are Times Roman, Italic, Bold, and Bold Italic.  For non-TTY
8838 devices, there is also at least one symbol font that contains various
8839 special symbols (Greek, mathematics).
8840
8841 @menu
8842 * Changing Fonts::
8843 * Font Families::
8844 * Font Positions::
8845 * Using Symbols::
8846 * Character Classes::
8847 * Special Fonts::
8848 * Artificial Fonts::
8849 * Ligatures and Kerning::
8850 @end menu
8851
8852 @c ---------------------------------------------------------------------
8853
8854 @node Changing Fonts, Font Families, Fonts and Symbols, Fonts and Symbols
8855 @subsection Changing Fonts
8856 @cindex fonts
8857
8858 @DefreqList {ft, [@Var{font}]}
8859 @DefescItemx {\\f, , f, }
8860 @DefescItem {\\f, @Lparen{}, fn, }
8861 @DefescItem {\\f, @Lbrack{}, font, @Rbrack{}}
8862 @DefregListEndx {.sty}
8863 @cindex changing fonts (@code{ft}, @code{\f})
8864 @cindex fonts, changing (@code{ft}, @code{\f})
8865 @cindex @code{sty} request, and changing fonts
8866 @cindex @code{fam} request, and changing fonts
8867 @cindex @code{\F}, and changing fonts
8868 @kindex styles
8869 @kindex family
8870 @pindex DESC
8871 The @code{ft} request and the @code{\f} escape change the current font
8872 to @var{font} (one-character name@tie{}@var{f}, two-character name
8873 @var{fn}).
8874
8875 If @var{font} is a style name (as set with the @code{sty} request or
8876 with the @code{styles} command in the @file{DESC} file), use it within
8877 the current font family (as set with the @code{fam} request, @code{\F}
8878 escape, or with the @code{family} command in the @file{DESC} file).
8879
8880 It is not possible to switch to a font with the name @samp{DESC}
8881 (whereas this name could be used as a style name; however, this is not
8882 recommended).
8883
8884 @cindex previous font (@code{ft}, @code{\f[]}, @code{\fP})
8885 @cindex font, previous (@code{ft}, @code{\f[]}, @code{\fP})
8886 With no argument or using @samp{P} as an argument, @code{.ft} switches
8887 to the previous font.  Use @code{\f[]} to do this with the escape.  The
8888 old syntax forms @code{\fP} or @code{\f[P]} are also supported.
8889
8890 Fonts are generally specified as upper-case strings, which are usually
8891 1@tie{}to 4 characters representing an abbreviation or acronym of the
8892 font name.  This is no limitation, just a convention.
8893
8894 The example below produces two identical lines.
8895
8896 @Example
8897 eggs, bacon,
8898 .ft B
8899 spam
8900 .ft
8901 and sausage.
8902
8903 eggs, bacon, \fBspam\fP and sausage.
8904 @endExample
8905
8906 Note that @code{\f} doesn't produce an input token in @code{gtroff}.  As
8907 a consequence, it can be used in requests like @code{mc} (which expects
8908 a single character as an argument) to change the font on the fly:
8909
8910 @Example
8911 .mc \f[I]x\f[]
8912 @endExample
8913
8914 The current style name is available in the read-only number register
8915 @samp{.sty} (this is a string-valued register); if the current font
8916 isn't a style, the empty string is returned.  It is associated with the
8917 current environment.
8918
8919 @xref{Font Positions}, for an alternative syntax.
8920 @endDefreq
8921
8922 @Defreq {ftr, f [@Var{g}]}
8923 @cindex font translation (@code{ftr})
8924 @cindex @code{ft} request, and font translations
8925 @cindex @code{ul} request, and font translations
8926 @cindex @code{bd} request, and font translations
8927 @cindex @code{\f}, and font translations
8928 @cindex @code{cs} request, and font translations
8929 @cindex @code{tkf} request, and font translations
8930 @cindex @code{special} request, and font translations
8931 @cindex @code{fspecial} request, and font translations
8932 @cindex @code{fp} request, and font translations
8933 @cindex @code{sty} request, and font translations
8934 @cindex @code{if} request, and font translations
8935 @cindex @code{ie} request, and font translations
8936 @cindex @code{while} request, and font translations
8937 Translate font@tie{}@var{f} to font@tie{}@var{g}.  Whenever a font
8938 named@tie{}@var{f} is referred to in a @code{\f} escape sequence, in the
8939 @code{F} and @code{S} conditional operators, or in the @code{ft},
8940 @code{ul}, @code{bd}, @code{cs}, @code{tkf}, @code{special},
8941 @code{fspecial}, @code{fp}, or @code{sty} requests, font@tie{}@var{g} is
8942 used.  If @var{g} is missing or equal to@tie{}@var{f} the translation is
8943 undone.
8944
8945 Note that it is not possible to chain font translations.  Example:
8946
8947 @Example
8948 .ftr XXX TR
8949 .ftr XXX YYY
8950 .ft XXX
8951     @result{} warning: can't find font `XXX'
8952 @endExample
8953 @endDefreq
8954
8955 @DefreqList {fzoom, f [@Var{zoom}]}
8956 @DefregListEndx {.zoom}
8957 @cindex magnification of a font (@code{fzoom})
8958 @cindex font, magnification (@code{fzoom})
8959 @cindex zoom factor of a font (@code{fzoom})
8960 @cindex factor, zoom, of a font (@code{fzoom})
8961 @cindex font, zoom factor (@code{fzoom})
8962 @cindex optical size of a font
8963 @cindex font, optical size
8964 @cindex size, optical, of a font
8965 Set magnification of font@tie{}@var{f} to factor @var{zoom}, which must
8966 be a non-negative integer multiple of 1/1000th.  This request is useful
8967 to adjust the optical size of a font in relation to the others.  In the
8968 example below, font @code{CR} is magnified by 10% (the zoom factor is
8969 thus 1.1).
8970
8971 @Example
8972 .fam P
8973 .fzoom CR 1100
8974 .ps 12
8975 Palatino and \f[CR]Courier\f[]
8976 @endExample
8977
8978 A missing or zero value of @var{zoom} is the same as a value of 1000,
8979 which means no magnification.  @var{f}@tie{}must be a real font name,
8980 not a style.
8981
8982 Note that the magnification of a font is completely transparent to
8983 troff; a change of the zoom factor doesn't cause any effect except that
8984 the dimensions of glyphs, (word) spaces, kerns, etc., of the affected
8985 font are adjusted accordingly.
8986
8987 The zoom factor of the current font is available in the read-only number
8988 register @samp{.zoom}, in multiples of 1/1000th.  It returns zero if
8989 there is no magnification.
8990 @endDefreq
8991
8992 @c ---------------------------------------------------------------------
8993
8994 @node Font Families, Font Positions, Changing Fonts, Fonts and Symbols
8995 @subsection Font Families
8996 @cindex font families
8997 @cindex families, font
8998 @cindex font styles
8999 @cindex styles, font
9000
9001 Due to the variety of fonts available, @code{gtroff} has added the
9002 concept of @dfn{font families} and @dfn{font styles}.  The fonts are
9003 specified as the concatenation of the font family and style.  Specifying
9004 a font without the family part causes @code{gtroff} to use that style of
9005 the current family.
9006
9007 @cindex PostScript fonts
9008 @cindex fonts, PostScript
9009 Currently, fonts for the devices @option{-Tps}, @option{-Tpdf},
9010 @option{-Tdvi}, @option{-Tlj4}, @option{-Tlbp}, and the X11 fonts are
9011 set up to this mechanism.  By default, @code{gtroff} uses the Times
9012 family with the four styles @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
9013
9014 This way, it is possible to use the basic four fonts and to select a
9015 different font family on the command line (@pxref{Groff Options}).
9016
9017 @DefreqList {fam, [@Var{family}]}
9018 @DefregItemx {.fam}
9019 @DefescItemx {\\F, , f, }
9020 @DefescItem {\\F, @Lparen{}, fm, }
9021 @DefescItem {\\F, @Lbrack{}, family, @Rbrack{}}
9022 @DefregListEndx {.fn}
9023 @cindex changing font family (@code{fam}, @code{\F})
9024 @cindex font family, changing (@code{fam}, @code{\F})
9025 Switch font family to @var{family} (one-character name@tie{}@var{f},
9026 two-character name @var{fm}).  If no argument is given, switch back to
9027 the previous font family.  Use @code{\F[]} to do this with the escape.
9028 Note that @code{\FP} doesn't work; it selects font family @samp{P}
9029 instead.
9030
9031 The value at start-up is @samp{T}.  The current font family is available
9032 in the read-only number register @samp{.fam} (this is a string-valued
9033 register); it is associated with the current environment.
9034
9035 @Example
9036 spam,
9037 .fam H    \" helvetica family
9038 spam,     \" used font is family H + style R = HR
9039 .ft B     \" family H + style B = font HB
9040 spam,
9041 .fam T    \" times family
9042 spam,     \" used font is family T + style B = TB
9043 .ft AR    \" font AR (not a style)
9044 baked beans,
9045 .ft R     \" family T + style R = font TR
9046 and spam.
9047 @endExample
9048
9049 Note that @code{\F} doesn't produce an input token in @code{gtroff}.  As
9050 a consequence, it can be used in requests like @code{mc} (which expects
9051 a single character as an argument) to change the font family on the fly:
9052
9053 @Example
9054 .mc \F[P]x\F[]
9055 @endExample
9056
9057 The @samp{.fn} register contains the current @dfn{real font name} of the
9058 current font.  This is a string-valued register.  If the current font is
9059 a style, the value of @code{\n[.fn]} is the proper concatenation of
9060 family and style name.
9061 @endDefreq
9062
9063 @Defreq {sty, n style}
9064 @cindex changing font style (@code{sty})
9065 @cindex font style, changing (@code{sty})
9066 @cindex @code{cs} request, and font styles
9067 @cindex @code{bd} request, and font styles
9068 @cindex @code{tkf} request, and font styles
9069 @cindex @code{uf} request, and font styles
9070 @cindex @code{fspecial} request, and font styles
9071 Associate @var{style} with font position@tie{}@var{n}.  A font position
9072 can be associated either with a font or with a style.  The current font
9073 is the index of a font position and so is also either a font or a style.
9074 If it is a style, the font that is actually used is the font which name
9075 is the concatenation of the name of the current family and the name of
9076 the current style.  For example, if the current font is@tie{}1 and font
9077 position@tie{}1 is associated with style @samp{R} and the current font
9078 family is @samp{T}, then font @samp{TR} is used.  If the current font is
9079 not a style, then the current family is ignored.  If the requests
9080 @code{cs}, @code{bd}, @code{tkf}, @code{uf}, or @code{fspecial} are
9081 applied to a style, they are instead applied to the member of the
9082 current family corresponding to that style.
9083
9084 @var{n}@tie{}must be a non-negative integer value.
9085
9086 @pindex DESC
9087 @kindex styles
9088 The default family can be set with the @option{-f} option (@pxref{Groff
9089 Options}).  The @code{styles} command in the @file{DESC} file controls
9090 which font positions (if any) are initially associated with styles
9091 rather than fonts.  For example, the default setting for @sc{PostScript}
9092 fonts
9093
9094 @Example
9095 styles R I B BI
9096 @endExample
9097
9098 @noindent
9099 is equivalent to
9100
9101 @Example
9102 .sty 1 R
9103 .sty 2 I
9104 .sty 3 B
9105 .sty 4 BI
9106 @endExample
9107
9108 @code{fam} and @code{\F} always check whether the current font position
9109 is valid; this can give surprising results if the current font position
9110 is associated with a style.
9111
9112 In the following example, we want to access the @sc{PostScript} font
9113 @code{FooBar} from the font family @code{Foo}:
9114
9115 @Example
9116 .sty \n[.fp] Bar
9117 .fam Foo
9118     @result{} warning: can't find font `FooR'
9119 @endExample
9120
9121 @noindent
9122 The default font position at start-up is@tie{}1; for the @sc{PostScript}
9123 device, this is associated with style @samp{R}, so @code{gtroff} tries
9124 to open @code{FooR}.
9125
9126 A solution to this problem is to use a dummy font like the following:
9127
9128 @Example
9129 .fp 0 dummy TR    \" set up dummy font at position 0
9130 .sty \n[.fp] Bar  \" register style `Bar'
9131 .ft 0             \" switch to font at position 0
9132 .fam Foo          \" activate family `Foo'
9133 .ft Bar           \" switch to font `FooBar'
9134 @endExample
9135
9136 @xref{Font Positions}.
9137 @endDefreq
9138
9139 @c ---------------------------------------------------------------------
9140
9141 @node Font Positions, Using Symbols, Font Families, Fonts and Symbols
9142 @subsection Font Positions
9143 @cindex font positions
9144 @cindex positions, font
9145
9146 For the sake of old phototypesetters and compatibility with old versions
9147 of @code{troff}, @code{gtroff} has the concept of font @dfn{positions},
9148 on which various fonts are mounted.
9149
9150 @DefreqList {fp, pos font [@Var{external-name}]}
9151 @DefregItemx {.f}
9152 @DefregListEndx {.fp}
9153 @cindex mounting font (@code{fp})
9154 @cindex font, mounting (@code{fp})
9155 Mount font @var{font} at position @var{pos} (which must be a
9156 non-negative integer).  This numeric position can then be referred to
9157 with font changing commands.  When @code{gtroff} starts it is using font
9158 position@tie{}1 (which must exist; position@tie{}0 is unused usually at
9159 start-up).
9160
9161 @cindex font position register (@code{.f})
9162 The current font in use, as a font position, is available in the
9163 read-only number register @samp{.f}.  This can be useful to remember the
9164 current font for later recall.  It is associated with the current
9165 environment (@pxref{Environments}).
9166
9167 @Example
9168 .nr save-font \n[.f]
9169 .ft B
9170 ... text text text ...
9171 .ft \n[save-font]
9172 @endExample
9173
9174 @cindex next free font position register (@code{.fp})
9175 The number of the next free font position is available in the read-only
9176 number register @samp{.fp}.  This is useful when mounting a new font,
9177 like so:
9178
9179 @Example
9180 .fp \n[.fp] NEATOFONT
9181 @endExample
9182
9183 @pindex DESC@r{, and font mounting}
9184 Fonts not listed in the @file{DESC} file are automatically mounted on
9185 the next available font position when they are referenced.  If a font is
9186 to be mounted explicitly with the @code{fp} request on an unused font
9187 position, it should be mounted on the first unused font position, which
9188 can be found in the @code{.fp} register.  Although @code{gtroff} does
9189 not enforce this strictly, it is not allowed to mount a font at a
9190 position whose number is much greater (approx.@: 1000 positions) than
9191 that of any currently used position.
9192
9193 The @code{fp} request has an optional third argument.  This argument
9194 gives the external name of the font, which is used for finding the font
9195 description file.  The second argument gives the internal name of the
9196 font, which is used to refer to the font in @code{gtroff} after it has
9197 been mounted.  If there is no third argument then the internal name is
9198 used as the external name.  This feature makes it possible to use fonts
9199 with long names in compatibility mode.
9200 @endDefreq
9201
9202 Both the @code{ft} request and the @code{\f} escape have alternative
9203 syntax forms to access font positions.
9204
9205 @DefreqList {ft, nnn}
9206 @DefescItemx {\\f, , n, }
9207 @DefescItem {\\f, @Lparen{}, nn, }
9208 @DefescListEnd {\\f, @Lbrack{}, nnn, @Rbrack{}}
9209 @cindex changing font position (@code{\f})
9210 @cindex font position, changing (@code{\f})
9211 @cindex @code{sty} request, and font positions
9212 @cindex @code{fam} request, and font positions
9213 @cindex @code{\F}, and font positions
9214 @kindex styles
9215 @kindex family
9216 @pindex DESC
9217 Change the current font position to @var{nnn} (one-digit
9218 position@tie{}@var{n}, two-digit position @var{nn}), which must be a
9219 non-negative integer.
9220
9221 If @var{nnn} is associated with a style (as set with the @code{sty}
9222 request or with the @code{styles} command in the @file{DESC} file), use
9223 it within the current font family (as set with the @code{fam} request,
9224 the @code{\F} escape, or with the @code{family} command in the
9225 @file{DESC} file).
9226
9227 @Example
9228 this is font 1
9229 .ft 2
9230 this is font 2
9231 .ft                   \" switch back to font 1
9232 .ft 3
9233 this is font 3
9234 .ft
9235 this is font 1 again
9236 @endExample
9237
9238 @xref{Changing Fonts}, for the standard syntax form.
9239 @endDefreq
9240
9241 @c ---------------------------------------------------------------------
9242
9243 @node Using Symbols, Character Classes, Font Positions, Fonts and Symbols
9244 @subsection Using Symbols
9245 @cindex using symbols
9246 @cindex symbols, using
9247
9248 @cindex glyph
9249 @cindex character
9250 @cindex ligature
9251 A @dfn{glyph} is a graphical representation of a @dfn{character}.  While
9252 a character is an abstract entity containing semantic information, a
9253 glyph is something that can be actually seen on screen or paper.  It is
9254 possible that a character has multiple glyph representation forms (for
9255 example, the character `A' can be either written in a roman or an italic
9256 font, yielding two different glyphs); sometimes more than one character
9257 maps to a single glyph (this is a @dfn{ligature} -- the most common is
9258 `fi').
9259
9260 @cindex symbol
9261 @cindex special fonts
9262 @kindex fonts
9263 @pindex DESC
9264 @cindex @code{special} request, and glyph search order
9265 @cindex @code{fspecial} request, and glyph search order
9266 A @dfn{symbol} is simply a named glyph.  Within @code{gtroff}, all glyph
9267 names of a particular font are defined in its font file.  If the user
9268 requests a glyph not available in this font, @code{gtroff} looks up an
9269 ordered list of @dfn{special fonts}.  By default, the @sc{PostScript}
9270 output device supports the two special fonts @samp{SS} (slanted symbols)
9271 and @samp{S} (symbols) (the former is looked up before the latter).
9272 Other output devices use different names for special fonts.  Fonts
9273 mounted with the @code{fonts} keyword in the @file{DESC} file are
9274 globally available.  To install additional special fonts locally (i.e.@:
9275 for a particular font), use the @code{fspecial} request.
9276
9277 Here the exact rules how @code{gtroff} searches a given symbol:
9278
9279 @itemize @bullet
9280 @item
9281 If the symbol has been defined with the @code{char} request, use it.
9282 This hides a symbol with the same name in the current font.
9283
9284 @item
9285 Check the current font.
9286
9287 @item
9288 If the symbol has been defined with the @code{fchar} request, use it.
9289
9290 @item
9291 Check whether the current font has a font-specific list of special
9292 fonts; test all fonts in the order of appearance in the last
9293 @code{fspecial} call if appropriate.
9294
9295 @item
9296 If the symbol has been defined with the @code{fschar} request for the
9297 current font, use it.
9298
9299 @item
9300 Check all fonts in the order of appearance in the last @code{special}
9301 call.
9302
9303 @item
9304 If the symbol has been defined with the @code{schar} request, use it.
9305
9306 @item
9307 As a last resort, consult all fonts loaded up to now for special fonts
9308 and check them, starting with the lowest font number.  Note that this
9309 can sometimes lead to surprising results since the @code{fonts} line in
9310 the @file{DESC} file often contains empty positions, which are filled
9311 later on.  For example, consider the following:
9312
9313 @Example
9314 fonts 3 0 0 FOO
9315 @endExample
9316
9317 @noindent
9318 This mounts font @code{foo} at font position@tie{}3.  We assume that
9319 @code{FOO} is a special font, containing glyph @code{foo}, and that no
9320 font has been loaded yet.  The line
9321
9322 @Example
9323 .fspecial BAR BAZ
9324 @endExample
9325
9326 @noindent
9327 makes font @code{BAZ} special only if font @code{BAR} is active.  We
9328 further assume that @code{BAZ} is really a special font, i.e., the font
9329 description file contains the @code{special} keyword, and that it also
9330 contains glyph @code{foo} with a special shape fitting to font
9331 @code{BAR}.  After executing @code{fspecial}, font @code{BAR} is loaded
9332 at font position@tie{}1, and @code{BAZ} at position@tie{}2.
9333
9334 We now switch to a new font @code{XXX}, trying to access glyph
9335 @code{foo} that is assumed to be missing.  There are neither
9336 font-specific special fonts for @code{XXX} nor any other fonts made
9337 special with the @code{special} request, so @code{gtroff} starts the
9338 search for special fonts in the list of already mounted fonts, with
9339 increasing font positions.  Consequently, it finds @code{BAZ} before
9340 @code{FOO} even for @code{XXX}, which is not the intended behaviour.
9341 @end itemize
9342
9343 @xref{Font Files}, and @ref{Special Fonts}, for more details.
9344
9345 @cindex list of available glyphs (@cite{groff_char(7)} man page)
9346 @cindex available glyphs, list (@cite{groff_char(7)} man page)
9347 @cindex glyphs, available, list (@cite{groff_char(7)} man page)
9348 The list of available symbols is device dependent; see the
9349 @cite{groff_char(7)} man page for a complete list of all glyphs.  For
9350 example, say
9351
9352 @Example
9353 man -Tdvi groff_char > groff_char.dvi
9354 @endExample
9355
9356 @noindent
9357 for a list using the default DVI fonts (not all versions of the
9358 @code{man} program support the @option{-T} option).  If you want to use
9359 an additional macro package to change the used fonts, @code{groff} must
9360 be called directly:
9361
9362 @Example
9363 groff -Tdvi -mec -man groff_char.7 > groff_char.dvi
9364 @endExample
9365
9366 @cindex composite glyph names
9367 @cindex glyph names, composite
9368 @cindex groff glyph list (GGL)
9369 @cindex GGL (groff glyph list)
9370 @cindex adobe glyph list (AGL)
9371 @cindex AGL (adobe glyph list)
9372 Glyph names not listed in groff_char(7) are derived algorithmically,
9373 using a simplified version of the Adobe Glyph List (AGL) algorithm, which
9374 is described in
9375 @uref{http://partners.adobe.com@//public@//developer@//opentype@//index_glyph.html}.
9376 The (frozen) set of glyph names that can't be derived algorithmically
9377 is called @dfn{groff glyph list (GGL)}.
9378
9379 @itemize @bullet
9380 @item
9381 A glyph for Unicode character U+@var{XXXX}[@var{X}[@var{X}]], which is
9382 not a composite character is named
9383 @code{u@var{XXXX}@r{[}@var{X}@r{[}@var{X}@r{]]}}.  @var{X} must be an
9384 uppercase hexadecimal digit.  Examples: @code{u1234}, @code{u008E},
9385 @code{u12DB8}.  The largest Unicode value is 0x10FFFF.  There must be at
9386 least four @code{X} digits; if necessary, add leading zeroes (after the
9387 @samp{u}).  No zero padding is allowed for character codes greater than
9388 0xFFFF.  Surrogates (i.e., Unicode values greater than 0xFFFF
9389 represented with character codes from the surrogate area U+D800-U+DFFF)
9390 are not allowed too.
9391
9392 @item
9393 A glyph representing more than a single input character is named
9394
9395 @display
9396 @samp{u} @var{component1} @samp{_} @var{component2} @samp{_} @var{component3} @dots{}
9397 @end display
9398
9399 @noindent
9400 Example: @code{u0045_0302_0301}.
9401
9402 For simplicity, all Unicode characters that are composites must be
9403 decomposed maximally (this is normalization form@tie{}D in the Unicode
9404 standard); for example, @code{u00CA_0301} is not a valid glyph name
9405 since U+00CA (@sc{latin capital letter e with circumflex}) can be
9406 further decomposed into U+0045 (@sc{latin capital letter e}) and U+0302
9407 (@sc{combining circumflex accent}).  @code{u0045_0302_0301} is thus the
9408 glyph name for U+1EBE, @sc{latin capital letter e with circumflex and
9409 acute}.
9410
9411 @item
9412 groff maintains a table to decompose all algorithmically derived glyph
9413 names that are composites itself.  For example, @code{u0100} (@sc{latin
9414 letter a with macron}) is automatically decomposed into
9415 @code{u0041_0304}.  Additionally, a glyph name of the GGL is preferred
9416 to an algorithmically derived glyph name; groff also automatically does
9417 the mapping.  Example: The glyph @code{u0045_0302} is mapped to
9418 @code{^E}.
9419
9420 @item
9421 glyph names of the GGL can't be used in composite glyph names; for
9422 example, @code{^E_u0301} is invalid.
9423 @end itemize
9424
9425 @DefescList {\\, @Lparen{}, nm, }
9426 @DefescItem {\\, @Lbrack{}, name, @Rbrack{}}
9427 @DefescListEnd {\\, @Lbrack{}, component1 component2 @dots{}, @Rbrack{}}
9428 Insert a symbol @var{name} (two-character name @var{nm}) or a composite
9429 glyph with component glyphs @var{component1}, @var{component2},
9430 @enddots{} There is no special syntax for one-character names -- the
9431 natural form @samp{\@var{n}} would collide with escapes.@footnote{Note
9432 that a one-character symbol is not the same as an input character, i.e.,
9433 the character @code{a} is not the same as @code{\[a]}.  By default,
9434 @code{groff} defines only a single one-character symbol, @code{\[-]}; it
9435 is usually accessed as @code{\-}.  On the other hand, @code{gtroff} has
9436 the special feature that @code{\[char@var{XXX}]} is the same as the
9437 input character with character code @var{XXX}.  For example,
9438 @code{\[char97]} is identical to the letter @code{a} if @acronym{ASCII}
9439 encoding is active.}
9440
9441 If @var{name} is undefined, a warning of type @samp{char} is generated,
9442 and the escape is ignored.  @xref{Debugging}, for information about
9443 warnings.
9444
9445 groff resolves @code{\[...]} with more than a single component as
9446 follows:
9447
9448 @itemize @bullet
9449 @item
9450 Any component that is found in the GGL is converted to the
9451 @code{u@var{XXXX}} form.
9452
9453 @item
9454 Any component @code{u@var{XXXX}} that is found in the list of
9455 decomposable glyphs is decomposed.
9456
9457 @item
9458 The resulting elements are then concatenated with @samp{_} in between,
9459 dropping the leading @samp{u} in all elements but the first.
9460 @end itemize
9461
9462 No check for the existence of any component (similar to @code{tr}
9463 request) is done.
9464
9465 Examples:
9466
9467 @table @code
9468 @item \[A ho]
9469 @samp{A} maps to @code{u0041}, @samp{ho} maps to @code{u02DB}, thus the
9470 final glyph name would be @code{u0041_02DB}.  Note this is not the
9471 expected result: The ogonek glyph @samp{ho} is a spacing ogonek, but for
9472 a proper composite a non-spacing ogonek (U+0328) is necessary.  Looking
9473 into the file @file{composite.tmac} one can find @w{@samp{.composite ho
9474 u0328}}, which changes the mapping of @samp{ho} while a composite glyph
9475 name is constructed, causing the final glyph name to be
9476 @code{u0041_0328}.
9477
9478 @item \[^E u0301]
9479 @itemx \[^E aa]
9480 @itemx \[E a^ aa]
9481 @itemx \[E ^ ']
9482 @samp{^E} maps to @code{u0045_0302}, thus the final glyph name is
9483 @code{u0045_0302_0301} in all forms (assuming proper calls of the
9484 @code{composite} request).
9485 @end table
9486
9487 It is not possible to define glyphs with names like @w{@samp{A ho}}
9488 within a groff font file.  This is not really a limitation; instead, you
9489 have to define @code{u0041_0328}.
9490 @endDefesc
9491
9492 @Defesc {\\C, ', xxx, '}
9493 @cindex named character (@code{\C})
9494 @cindex character, named (@code{\C})
9495 Typeset the glyph named @var{xxx}.@footnote{@code{\C} is actually a
9496 misnomer since it accesses an output glyph.}  Normally it is more
9497 convenient to use @code{\[@var{xxx}]}, but @code{\C} has the advantage
9498 that it is compatible with newer versions of @acronym{AT&T} @code{troff}
9499 and is available in compatibility mode.
9500 @endDefesc
9501
9502 @Defreq {composite, from to}
9503 @pindex composite.tmac
9504 Map glyph name @var{from} to glyph name @var{to} if it is used in
9505 @code{\[...]} with more than one component.  See above for examples.
9506
9507 This mapping is based on glyph names only; no check for the existence of
9508 either glyph is done.
9509
9510 A set of default mappings for many accents can be found in the file
9511 @file{composite.tmac}, which is loaded at start-up.
9512 @endDefreq
9513
9514 @Defesc {\\N, ', n, '}
9515 @cindex numbered glyph (@code{\N})
9516 @cindex glyph, numbered (@code{\N})
9517 @cindex @code{char} request, used with @code{\N}
9518 @cindex Unicode
9519 Typeset the glyph with code@tie{}@var{n} in the current font
9520 (@code{n}@tie{}is @strong{not} the input character code).  The number
9521 @var{n}@tie{}can be any non-negative decimal integer.  Most devices only
9522 have glyphs with codes between 0 and@tie{}255; the Unicode output device
9523 uses codes in the range 0--65535.  If the current font does not contain
9524 a glyph with that code, special fonts are @emph{not} searched.  The
9525 @code{\N} escape sequence can be conveniently used in conjunction with
9526 the @code{char} request:
9527
9528 @Example
9529 .char \[phone] \f[ZD]\N'37'
9530 @endExample
9531
9532 @noindent
9533 @pindex DESC
9534 @cindex unnamed glyphs
9535 @cindex glyphs, unnamed
9536 The code of each glyph is given in the fourth column in the font
9537 description file after the @code{charset} command.  It is possible to
9538 include unnamed glyphs in the font description file by using a name of
9539 @samp{---}; the @code{\N} escape sequence is the only way to use these.
9540
9541 No kerning is applied to glyphs accessed with @code{\N}.
9542 @endDefesc
9543
9544 Some escape sequences directly map onto special glyphs.
9545
9546 @Defesc {\\', , , }
9547 This is a backslash followed by the apostrophe character,
9548 @acronym{ASCII} character @code{0x27} (@acronym{EBCDIC} character
9549 @code{0x7D}).  The same as @code{\[aa]}, the acute accent.
9550 @endDefesc
9551
9552 @Defesc {\\`, , , }
9553 This is a backslash followed by @acronym{ASCII} character @code{0x60}
9554 (@acronym{EBCDIC} character @code{0x79} usually).  The same as
9555 @code{\[ga]}, the grave accent.
9556 @endDefesc
9557
9558 @Defesc {\\-, , , }
9559 This is the same as @code{\[-]}, the minus sign in the current font.
9560 @endDefesc
9561
9562 @Defesc {\\_, , , }
9563 This is the same as @code{\[ul]}, the underline character.
9564 @endDefesc
9565
9566 @Defreq {cflags, n c1 c2 @dots{}}
9567 @cindex glyph properties (@code{cflags})
9568 @cindex character properties (@code{cflags})
9569 @cindex properties of glyphs (@code{cflags})
9570 @cindex properties of characters (@code{cflags})
9571 Input characters and symbols have certain properties associated with
9572 it.@footnote{Note that the output glyphs themselves don't have such
9573 properties.  For @code{gtroff}, a glyph is a numbered box with a given
9574 width, depth, and height, nothing else.  All manipulations with the
9575 @code{cflags} request work on the input level.}  These properties can be
9576 modified with the @code{cflags} request.  The first argument is the sum
9577 of the desired flags and the remaining arguments are the characters or
9578 symbols to have those properties.  It is possible to omit the spaces
9579 between the characters or symbols.  Instead of single characters or
9580 symbols you can also use character classes (see @ref{Character Classes}
9581 for more details).
9582
9583 @table @code
9584 @item 1
9585 @cindex end-of-sentence characters
9586 @cindex characters, end-of-sentence
9587 The character ends sentences (initially characters @samp{.?!} have this
9588 property).
9589
9590 @item 2
9591 @cindex hyphenating characters
9592 @cindex characters, hyphenation
9593 Lines can be broken before the character (initially no characters have
9594 this property).  This only works if both the characters before and after
9595 have non-zero hyphenation codes (as set with the @code{hcode} request).
9596 Use value@tie{}64 to override this behaviour.
9597
9598 @item 4
9599 @cindex @code{hy} glyph, and @code{cflags}
9600 @cindex @code{em} glyph, and @code{cflags}
9601 Lines can be broken after the character (initially the character
9602 @samp{-} and the symbols @samp{\[hy]} and @samp{\[em]} have this
9603 property).  This only works if both the characters before and after have
9604 non-zero hyphenation codes (as set with the @code{hcode} request).  Use
9605 value@tie{}64 to override this behaviour.
9606
9607 @item 8
9608 @cindex overlapping characters
9609 @cindex characters, overlapping
9610 @cindex @code{ul} glyph, and @code{cflags}
9611 @cindex @code{rn} glyph, and @code{cflags}
9612 @cindex @code{ru} glyph, and @code{cflags}
9613 @cindex @code{radicalex} glyph, and @code{cflags}
9614 @cindex @code{sqrtex} glyph, and @code{cflags}
9615 The character overlaps horizontally if used as a horizontal line
9616 building element.  Initially the symbols @samp{\[ul]}, @samp{\[rn]},
9617 @samp{\[ru]}, @samp{\[radicalex]}, and @samp{\[sqrtex]} have this
9618 property.
9619
9620 @item 16
9621 @cindex @code{br} glyph, and @code{cflags}
9622 The character overlaps vertically if used as vertical line building
9623 element.  Initially symbol @samp{\[br]} has this property.
9624
9625 @item 32
9626 @cindex transparent characters
9627 @cindex character, transparent
9628 @cindex @code{"}, at end of sentence
9629 @cindex @code{'}, at end of sentence
9630 @cindex @code{)}, at end of sentence
9631 @cindex @code{]}, at end of sentence
9632 @cindex @code{*}, at end of sentence
9633 @cindex @code{dg} glyph, at end of sentence
9634 @cindex @code{rq} glyph, at end of sentence
9635 @cindex @code{cq} glyph, at end of sentence
9636 An end-of-sentence character followed by any number of characters with
9637 this property is treated as the end of a sentence if followed by a
9638 newline or two spaces; in other words the character is @dfn{transparent}
9639 for the purposes of end-of-sentence recognition -- this is the same as
9640 having a zero space factor in @TeX{} (initially characters @samp{"')]*}
9641 and the symbols @samp{\[dg]}, @samp{\[rq]}, and @samp{\[cq]} have this
9642 property).
9643
9644 @item 64
9645 Ignore hyphenation code values of the surrounding characters.  Use this
9646 in combination with values 2 and@tie{}4 (initially no characters have
9647 this property).  For example, if you need an automatic break point after
9648 the hyphen in number ranges like `3000-5000', insert
9649
9650 @Example
9651 .cflags 68 -
9652 @endExample
9653
9654 @noindent
9655 into your document.  Note, however, that this can lead to bad layout if
9656 done without thinking; in most situations, a better solution instead of
9657 changing the @code{cflags} value is to insert @code{\:} right after the
9658 hyphen at the places that really need a break point.
9659
9660 @item 128
9661 Prohibit a line break before the character, but allow a line break after
9662 the character.  This works only in combination with flags 256 and 512
9663 (see below) and has no effect otherwise.
9664
9665 @item 256
9666 Prohibit a line break after the character, but allow a line break before
9667 the character.  This works only in combination with flags 128 and 512
9668 (see below) and has no effect otherwise.
9669
9670 @item 512
9671 Allow line break before or after the character.  This works only in
9672 combination with flags 128 and 256 and has no effect otherwise.
9673
9674 Contrary to flag values 2 and@tie{}4, the flags 128, 256, and 512 work
9675 pairwise.  If, for example, the left character has value 512, and the
9676 right character 128, no line break gets inserted.  If we use
9677 value@tie{}6 instead for the left character, a line break after the
9678 character can't be suppressed since the right neighbour character
9679 doesn't get examined.
9680 @end table
9681 @endDefreq
9682
9683 @DefreqList {char, g [@Var{string}]}
9684 @DefreqItemx {fchar, g [@Var{string}]}
9685 @DefreqItemx {fschar, f g [@Var{string}]}
9686 @DefreqListEndx {schar, g [@Var{string}]}
9687 @cindex defining character (@code{char})
9688 @cindex defining fallback character (@code{fchar}, @code{fschar}, @code{schar})
9689 @cindex character, defining (@code{char})
9690 @cindex character, defining fallback (@code{fchar}, @code{fschar}, @code{schar})
9691 @cindex fallback character, defining (@code{fchar}, @code{fschar}, @code{schar})
9692 @cindex creating new characters (@code{char})
9693 @cindex defining symbol (@code{char})
9694 @cindex symbol, defining (@code{char})
9695 @cindex defining glyph (@code{char})
9696 @cindex glyph, defining (@code{char})
9697 @cindex escape character, while defining glyph
9698 @cindex character, escape, while defining glyph
9699 @cindex @code{tr} request, and glyph definitions
9700 @cindex @code{cp} request, and glyph definitions
9701 @cindex @code{rc} request, and glyph definitions
9702 @cindex @code{lc} request, and glyph definitions
9703 @cindex @code{\l}, and glyph definitions
9704 @cindex @code{\L}, and glyph definitions
9705 @cindex @code{\&}, and glyph definitions
9706 @cindex @code{\e}, and glyph definitions
9707 @cindex @code{hcode} request, and glyph definitions
9708 Define a new glyph@tie{}@var{g} to be @var{string} (which can be
9709 empty).@footnote{@code{char} is a misnomer since an output glyph is
9710 defined.}  Every time glyph@tie{}@var{g} needs to be printed,
9711 @var{string} is processed in a temporary environment and the result is
9712 wrapped up into a single object.  Compatibility mode is turned off and
9713 the escape character is set to @samp{\} while @var{string} is being
9714 processed.  Any emboldening, constant spacing or track kerning is
9715 applied to this object rather than to individual characters in
9716 @var{string}.
9717
9718 A glyph defined by these requests can be used just like a normal glyph
9719 provided by the output device.  In particular, other characters can be
9720 translated to it with the @code{tr} or @code{trin} requests; it can be
9721 made the leader character by the @code{lc} request; repeated patterns
9722 can be drawn with the glyph using the @code{\l} and @code{\L} escape
9723 sequences; words containing the glyph can be hyphenated correctly if the
9724 @code{hcode} request is used to give the glyph's symbol a hyphenation
9725 code.
9726
9727 There is a special anti-recursion feature: Use of @code{g} within the
9728 glyph's definition is handled like normal characters and symbols not
9729 defined with @code{char}.
9730
9731 Note that the @code{tr} and @code{trin} requests take precedence if
9732 @code{char} accesses the same symbol.
9733
9734 @Example
9735 .tr XY
9736 X
9737     @result{} Y
9738 .char X Z
9739 X
9740     @result{} Y
9741 .tr XX
9742 X
9743     @result{} Z
9744 @endExample
9745
9746 The @code{fchar} request defines a fallback glyph: @code{gtroff} only
9747 checks for glyphs defined with @code{fchar} if it cannot find the glyph
9748 in the current font.  @code{gtroff} carries out this test before
9749 checking special fonts.
9750
9751 @code{fschar} defines a fallback glyph for font@tie{}@var{f}:
9752 @code{gtroff} checks for glyphs defined with @code{fschar} after the
9753 list of fonts declared as font-specific special fonts with the
9754 @code{fspecial} request, but before the list of fonts declared as global
9755 special fonts with the @code{special} request.
9756
9757 Finally, the @code{schar} request defines a global fallback glyph:
9758 @code{gtroff} checks for glyphs defined with @code{schar} after the list
9759 of fonts declared as global special fonts with the @code{special}
9760 request, but before the already mounted special fonts.
9761
9762 @xref{Using Symbols}, for a detailed description of the glyph searching
9763 mechanism in @code{gtroff}.
9764 @endDefreq
9765
9766 @DefreqList {rchar, c1 c2 @dots{}}
9767 @DefreqListEndx {rfschar, f c1 c2 @dots{}}
9768 @cindex removing glyph definition (@code{rchar}, @code{rfschar})
9769 @cindex glyph, removing definition (@code{rchar}, @code{rfschar})
9770 @cindex fallback glyph, removing definition (@code{rchar}, @code{rfschar})
9771 Remove the definitions of glyphs @var{c1}, @var{c2},@tie{}@enddots{}
9772 This undoes the effect of a @code{char}, @code{fchar}, or @code{schar}
9773 request.
9774
9775 It is possible to omit the whitespace between arguments.
9776
9777 The request @code{rfschar} removes glyph definitions defined with
9778 @code{fschar} for glyph@tie{}f.
9779 @endDefreq
9780
9781 @xref{Special Characters}.
9782
9783 @c ---------------------------------------------------------------------
9784
9785 @node Character Classes, Special Fonts, Using Symbols, Fonts and Symbols
9786 @subsection Character Classes
9787 @cindex character classes
9788 @cindex classes, character
9789
9790 Classes are particularly useful for East Asian languages such as
9791 Chinese, Japanese, and Korean, where the number of needed characters is
9792 much larger than in European languages, and where large sets of
9793 characters share the same properties.
9794
9795 @Defreq {class, n c1 c2 @dots{}}
9796 @cindex character class (@code{class})
9797 @cindex defining character class (@code{class})
9798 @cindex class of characters (@code{class})
9799 In @code{groff}, a @dfn{character class} (or simply ``class'') is a set
9800 of characters, grouped by some user aspect.  The @code{class} request
9801 defines such classes so that other requests can refer to all characters
9802 belonging to this set with a single class name.  Currently, only the
9803 @code{cflags} request can handle character classes.
9804
9805 A @code{class} request takes a class name followed by a list of
9806 entities.  In its simplest form, the entities are characters or symbols:
9807
9808 @Example
9809 .class [prepunct] , : ; > @}
9810 @endExample
9811
9812 Since class and glyph names share the same namespace, it is recommended
9813 to start and end the class name with @code{[} and @code{]},
9814 respectively, to avoid collisions with normal @code{groff} symbols (and
9815 symbols defined by the user).  In particular, the presence of @code{]}
9816 in the symbol name intentionally prevents the usage of @code{\[...]},
9817 thus you must use the @code{\C} escape to access a class with such a
9818 name.
9819
9820 @cindex GGL (groff glyph list)
9821 @cindex groff glyph list (GGL)
9822 You can also use a special character range notation, consisting of a
9823 start character or symbol, followed by @samp{-}, and an end character or
9824 symbol.  Internally, @code{gtroff} converts these two symbol names to
9825 Unicode values (according to the groff glyph gist), which then give the
9826 start and end value of the range.  If that fails, the class definition
9827 is skipped.
9828
9829 Finally, classes can be nested, too.
9830
9831 Here is a more complex example:
9832
9833 @Example
9834 .class [prepunctx] \C'[prepunct]' \[u2013]-\[u2016]
9835 @endExample
9836
9837 The class @samp{prepunctx} now contains the contents of the class
9838 @code{prepunct} as defined above (the set @samp{, : ; > @}}), and
9839 characters in the range between @code{U+2013} and @code{U+2016}.
9840
9841 If you want to add @samp{-} to a class, it must be the first character
9842 value in the argument list, otherwise it gets misinterpreted as a range.
9843
9844 Note that it is not possible to use class names within range
9845 definitions.
9846
9847 Typical use of the @code{class} request is to control line-breaking and
9848 hyphenation rules as defined by the @code{cflags} request.  For example,
9849 to inhibit line breaks before the characters belonging to the
9850 @code{prepunctx} class, you can write:
9851
9852 @Example
9853 .cflags 2 \C'[prepunctx]'
9854 @endExample
9855
9856 See the @code{cflags} request in @ref{Using Symbols}, for more details.
9857 @endDefreq
9858
9859 @c ---------------------------------------------------------------------
9860
9861 @node Special Fonts, Artificial Fonts, Character Classes, Fonts and Symbols
9862 @subsection Special Fonts
9863 @cindex special fonts
9864 @cindex fonts, special
9865
9866 Special fonts are those that @code{gtroff} searches when it cannot find
9867 the requested glyph in the current font.  The Symbol font is usually a
9868 special font.
9869
9870 @code{gtroff} provides the following two requests to add more special
9871 fonts.  @xref{Using Symbols}, for a detailed description of the glyph
9872 searching mechanism in @code{gtroff}.
9873
9874 Usually, only non-TTY devices have special fonts.
9875
9876 @DefreqList {special, [@Var{s1} @Var{s2} @dots{}]}
9877 @DefreqListEndx {fspecial, f [@Var{s1} @Var{s2} @dots{}]}
9878 @kindex fonts
9879 @pindex DESC
9880 Use the @code{special} request to define special fonts.  Initially, this
9881 list is empty.
9882
9883 Use the @code{fspecial} request to designate special fonts only when
9884 font@tie{}@var{f} is active.  Initially, this list is empty.
9885
9886 Previous calls to @code{special} or @code{fspecial} are overwritten;
9887 without arguments, the particular list of special fonts is set to empty.
9888 Special fonts are searched in the order they appear as arguments.
9889
9890 All fonts that appear in a call to @code{special} or @code{fspecial}
9891 are loaded.
9892
9893 @xref{Using Symbols}, for the exact search order of glyphs.
9894 @endDefreq
9895
9896 @c ---------------------------------------------------------------------
9897
9898 @node Artificial Fonts, Ligatures and Kerning, Special Fonts, Fonts and Symbols
9899 @subsection Artificial Fonts
9900 @cindex artificial fonts
9901 @cindex fonts, artificial
9902
9903 There are a number of requests and escapes for artificially creating
9904 fonts.  These are largely vestiges of the days when output devices did
9905 not have a wide variety of fonts, and when @code{nroff} and @code{troff}
9906 were separate programs.  Most of them are no longer necessary in GNU
9907 @code{troff}.  Nevertheless, they are supported.
9908
9909 @DefescList {\\H, ', height, '}
9910 @DefescItem {\\H, ', @t{+}height, '}
9911 @DefescItem {\\H, ', @t{-}height, '}
9912 @DefregListEndx {.height}
9913 @cindex changing the font height (@code{\H})
9914 @cindex font height, changing (@code{\H})
9915 @cindex height, font, changing (@code{\H})
9916 Change (increment, decrement) the height of the current font, but not
9917 the width.  If @var{height} is zero, restore the original height.
9918 Default scaling indicator is @samp{z}.
9919
9920 The read-only number register @code{.height} contains the font height as
9921 set by @code{\H}.
9922
9923 Currently, only the @option{-Tps} and @option{-Tpdf} devices support
9924 this feature.
9925
9926 Note that @code{\H} doesn't produce an input token in @code{gtroff}.  As
9927 a consequence, it can be used in requests like @code{mc} (which expects
9928 a single character as an argument) to change the font on the fly:
9929
9930 @Example
9931 .mc \H'+5z'x\H'0'
9932 @endExample
9933
9934 In compatibility mode, @code{gtroff} behaves differently: If an
9935 increment or decrement is used, it is always taken relative to the
9936 current point size and not relative to the previously selected font
9937 height.  Thus,
9938
9939 @Example
9940 .cp 1
9941 \H'+5'test \H'+5'test
9942 @endExample
9943
9944 @noindent
9945 prints the word @samp{test} twice with the same font height (five points
9946 larger than the current font size).
9947 @endDefesc
9948
9949 @DefescList {\\S, ', slant, '}
9950 @DefregListEndx {.slant}
9951 @cindex changing the font slant (@code{\S})
9952 @cindex font slant, changing (@code{\S})
9953 @cindex slant, font, changing (@code{\S})
9954 Slant the current font by @var{slant} degrees.  Positive values slant to
9955 the right.  Only integer values are possible.
9956
9957 The read-only number register @code{.slant} contains the font slant as
9958 set by @code{\S}.
9959
9960 Currently, only the @option{-Tps} and @option{-Tpdf} devices support
9961 this feature.
9962
9963 Note that @code{\S} doesn't produce an input token in @code{gtroff}.  As
9964 a consequence, it can be used in requests like @code{mc} (which expects
9965 a single character as an argument) to change the font on the fly:
9966
9967 @Example
9968 .mc \S'20'x\S'0'
9969 @endExample
9970
9971 This request is incorrectly documented in the original @acronym{UNIX}
9972 troff manual; the slant is always set to an absolute value.
9973 @endDefesc
9974
9975 @Defreq {ul, [@Var{lines}]}
9976 @cindex underlining (@code{ul})
9977 The @code{ul} request normally underlines subsequent lines if a TTY
9978 output device is used.  Otherwise, the lines are printed in italics
9979 (only the term `underlined' is used in the following).  The single
9980 argument is the number of input lines to be underlined; with no
9981 argument, the next line is underlined.  If @var{lines} is zero or
9982 negative, stop the effects of @code{ul} (if it was active).  Requests
9983 and empty lines do not count for computing the number of underlined
9984 input lines, even if they produce some output like @code{tl}.  Lines
9985 inserted by macros (e.g.@: invoked by a trap) do count.
9986
9987 At the beginning of @code{ul}, the current font is stored and the
9988 underline font is activated.  Within the span of a @code{ul} request, it
9989 is possible to change fonts, but after the last line affected by
9990 @code{ul} the saved font is restored.
9991
9992 This number of lines still to be underlined is associated with the
9993 current environment (@pxref{Environments}).  The underline font can be
9994 changed with the @code{uf} request.
9995
9996 @c XXX @xref should be changed to grotty
9997
9998 @c @xref{Troff and Nroff Mode}, for a discussion how underlining is
9999 @c implemented in for TTY output devices, and which problems can arise.
10000
10001 The @code{ul} request does not underline spaces.
10002 @endDefreq
10003
10004 @Defreq {cu, [@Var{lines}]}
10005 @cindex continuous underlining (@code{cu})
10006 @cindex underlining, continuous (@code{cu})
10007 The @code{cu} request is similar to @code{ul} but underlines spaces as
10008 well (if a TTY output device is used).
10009 @endDefreq
10010
10011 @Defreq {uf, font}
10012 @cindex underline font (@code{uf})
10013 @cindex font for underlining (@code{uf})
10014 Set the underline font (globally) used by @code{ul} and @code{cu}.  By
10015 default, this is the font at position@tie{}2.  @var{font} can be either
10016 a non-negative font position or the name of a font.
10017 @endDefreq
10018
10019 @DefreqList {bd, font [@Var{offset}]}
10020 @DefreqItem {bd, font1 font2 [@Var{offset}]}
10021 @DefregListEndx {.b}
10022 @cindex imitating bold face (@code{bd})
10023 @cindex bold face, imitating (@code{bd})
10024 Artificially create a bold font by printing each glyph twice, slightly
10025 offset.
10026
10027 Two syntax forms are available.
10028
10029 @itemize @bullet
10030 @item
10031 Imitate a bold font unconditionally.  The first argument specifies the
10032 font to embolden, and the second is the number of basic units, minus
10033 one, by which the two glyphs are offset.  If the second argument is
10034 missing, emboldening is turned off.
10035
10036 @var{font} can be either a non-negative font position or the name of a
10037 font.
10038
10039 @var{offset} is available in the @code{.b} read-only register if a
10040 special font is active; in the @code{bd} request, its default unit is
10041 @samp{u}.
10042
10043 @cindex @code{fspecial} request, and imitating bold
10044 @kindex special
10045 @cindex embolding of special fonts
10046 @cindex special fonts, emboldening
10047 @item
10048 Imitate a bold form conditionally.  Embolden @var{font1} by @var{offset}
10049 only if font @var{font2} is the current font.  This command can be
10050 issued repeatedly to set up different emboldening values for different
10051 current fonts.  If the second argument is missing, emboldening is turned
10052 off for this particular current font.
10053
10054 This affects special fonts only (either set up with the @code{special}
10055 command in font files or with the @code{fspecial} request).
10056 @end itemize
10057 @endDefreq
10058
10059 @Defreq {cs, font [@Var{width} [@Var{em-size}]]}
10060 @cindex constant glyph space mode (@code{cs})
10061 @cindex mode for constant glyph space (@code{cs})
10062 @cindex glyph, constant space
10063 @cindex @code{ps} request, and constant glyph space mode
10064 Switch to and from @dfn{constant glyph space mode}.  If activated, the
10065 width of every glyph is @math{@var{width}/36} ems.  The em size is given
10066 absolutely by @var{em-size}; if this argument is missing, the em value
10067 is taken from the current font size (as set with the @code{ps} request)
10068 when the font is effectively in use.  Without second and third argument,
10069 constant glyph space mode is deactivated.
10070
10071 Default scaling indicator for @var{em-size} is @samp{z}; @var{width} is
10072 an integer.
10073 @endDefreq
10074
10075 @c ---------------------------------------------------------------------
10076
10077 @node Ligatures and Kerning,  , Artificial Fonts, Fonts and Symbols
10078 @subsection Ligatures and Kerning
10079 @cindex ligatures and kerning
10080 @cindex kerning and ligatures
10081
10082 Ligatures are groups of characters that are run together, i.e, producing
10083 a single glyph.  For example, the letters `f' and `i' can form a
10084 ligature `fi' as in the word `file'.  This produces a cleaner look
10085 (albeit subtle) to the printed output.  Usually, ligatures are not
10086 available in fonts for TTY output devices.
10087
10088 Most @sc{PostScript} fonts support the fi and fl ligatures.  The C/A/T
10089 typesetter that was the target of @acronym{AT&T} @code{troff} also
10090 supported `ff', `ffi', and `ffl' ligatures.  Advanced typesetters or
10091 `expert' fonts may include ligatures for `ft' and `ct', although GNU
10092 @code{troff} does not support these (yet).
10093
10094 Only the current font is checked for ligatures and kerns; neither
10095 special fonts nor entities defined with the @code{char} request (and its
10096 siblings) are taken into account.
10097
10098 @DefreqList {lg, [@Var{flag}]}
10099 @DefregListEndx {.lg}
10100 @cindex activating ligatures (@code{lg})
10101 @cindex ligatures, activating (@code{lg})
10102 @cindex ligatures enabled register (@code{.lg})
10103 Switch the ligature mechanism on or off; if the parameter is non-zero or
10104 missing, ligatures are enabled, otherwise disabled.  Default is on.  The
10105 current ligature mode can be found in the read-only number register
10106 @code{.lg} (set to 1 or@tie{}2 if ligatures are enabled,
10107 0@tie{}otherwise).
10108
10109 Setting the ligature mode to@tie{}2 enables the two-character ligatures
10110 (fi, fl, and ff) and disables the three-character ligatures (ffi and
10111 ffl).
10112 @endDefreq
10113
10114 @dfn{Pairwise kerning} is another subtle typesetting mechanism that
10115 modifies the distance between a glyph pair to improve readability.  In
10116 most cases (but not always) the distance is decreased.
10117 @iftex
10118 For example, compare the combination of the letters `V' and `A'.  With
10119 kerning, `VA' is printed.  Without kerning it appears as `V@w{}A'.
10120 @end iftex
10121 Typewriter-like fonts and fonts for terminals where all glyphs have the
10122 same width don't use kerning.
10123
10124 @DefreqList {kern, [@Var{flag}]}
10125 @DefregListEndx {.kern}
10126 @cindex activating kerning (@code{kern})
10127 @cindex kerning, activating (@code{kern})
10128 @cindex kerning enabled register (@code{.kern})
10129 Switch kerning on or off.  If the parameter is non-zero or missing,
10130 enable pairwise kerning, otherwise disable it.  The read-only number
10131 register @code{.kern} is set to@tie{}1 if pairwise kerning is enabled,
10132 0@tie{}otherwise.
10133
10134 @cindex zero width space character (@code{\&})
10135 @cindex character, zero width space (@code{\&})
10136 @cindex space character, zero width (@code{\&})
10137 If the font description file contains pairwise kerning information,
10138 glyphs from that font are kerned.  Kerning between two glyphs can be
10139 inhibited by placing @code{\&} between them: @samp{V\&A}.
10140
10141 @xref{Font File Format}.
10142 @endDefreq
10143
10144 @cindex track kerning
10145 @cindex kerning, track
10146 @dfn{Track kerning} expands or reduces the space between glyphs.  This
10147 can be handy, for example, if you need to squeeze a long word onto a
10148 single line or spread some text to fill a narrow column.  It must be
10149 used with great care since it is usually considered bad typography if
10150 the reader notices the effect.
10151
10152 @Defreq {tkf, f s1 n1 s2 n2}
10153 @cindex activating track kerning (@code{tkf})
10154 @cindex track kerning, activating (@code{tkf})
10155 Enable track kerning for font@tie{}@var{f}.  If the current font
10156 is@tie{}@var{f} the width of every glyph is increased by an amount
10157 between @var{n1} and @var{n2} (@var{n1}, @var{n2} can be negative); if
10158 the current point size is less than or equal to @var{s1} the width is
10159 increased by @var{n1}; if it is greater than or equal to @var{s2} the
10160 width is increased by @var{n2}; if the point size is greater than or
10161 equal to @var{s1} and less than or equal to @var{s2} the increase in
10162 width is a linear function of the point size.
10163
10164 The default scaling indicator is @samp{z} for @var{s1} and @var{s2},
10165 @samp{p} for @var{n1} and @var{n2}.
10166
10167 Note that the track kerning amount is added even to the rightmost glyph
10168 in a line; for large values it is thus recommended to increase the line
10169 length by the same amount to compensate it.
10170 @endDefreq
10171
10172 Sometimes, when typesetting letters of different fonts, more or less
10173 space at such boundaries are needed.  There are two escapes to help with
10174 this.
10175
10176 @Defesc {\\/, , , }
10177 @cindex italic correction (@code{\/})
10178 @cindex correction, italic (@code{\/})
10179 @cindex correction between italic and roman glyph (@code{\/}, @code{\,})
10180 @cindex roman glyph, correction after italic glyph (@code{\/})
10181 @cindex italic glyph, correction before roman glyph (@code{\/})
10182 @cindex glyph, italic correction (@code{\/})
10183 Increase the width of the preceding glyph so that the spacing between
10184 that glyph and the following glyph is correct if the following glyph is
10185 a roman glyph.  For example, if an italic@tie{}@code{f} is immediately
10186 followed by a roman right parenthesis, then in many fonts the top right
10187 portion of the@tie{}@code{f} overlaps the top left of the right
10188 parenthesis.  Use this escape sequence whenever an italic glyph is
10189 immediately followed by a roman glyph without any intervening space.
10190 This small amount of space is also called @dfn{italic correction}.
10191
10192 @iftex
10193 @c can't use @Example...@endExample here
10194 @example
10195 @group
10196 \f[I]f\f[R])
10197     @result{} {@it f}@r{)}
10198 \f[I]f\/\f[R])
10199     @result{} @i{f}@r{)}
10200 @end group
10201 @end example
10202 @end iftex
10203 @endDefesc
10204
10205 @Defesc {\\\,, , , }
10206 @cindex left italic correction (@code{\,})
10207 @cindex correction, left italic (@code{\,})
10208 @cindex glyph, left italic correction (@code{\,})
10209 @cindex roman glyph, correction before italic glyph (@code{\,})
10210 @cindex italic glyph, correction after roman glyph (@code{\,})
10211 Modify the spacing of the following glyph so that the spacing between
10212 that glyph and the preceding glyph is correct if the preceding glyph is
10213 a roman glyph.  Use this escape sequence whenever a roman glyph is
10214 immediately followed by an italic glyph without any intervening space.
10215 In analogy to above, this space could be called @dfn{left italic
10216 correction}, but this term isn't used widely.
10217
10218 @iftex
10219 @c can't use @Example...@endExample here
10220 @example
10221 @group
10222 q\f[I]f
10223     @result{} @r{q}@i{f}
10224 q\,\f[I]f
10225     @result{} @r{q}@math{@ptexcomma}@i{f}
10226 @end group
10227 @end example
10228 @end iftex
10229 @endDefesc
10230
10231 @Defesc {\\&, , , }
10232 Insert a zero-width character, which is invisible.  Its intended use is
10233 to stop interaction of a character with its surrounding.
10234
10235 @itemize @bullet
10236 @item
10237 It prevents the insertion of extra space after an end-of-sentence
10238 character.
10239
10240 @Example
10241 Test.
10242 Test.
10243     @result{} Test.  Test.
10244 Test.\&
10245 Test.
10246     @result{} Test. Test.
10247 @endExample
10248
10249 @item
10250 It prevents interpretation of a control character at the beginning of an
10251 input line.
10252
10253 @Example
10254 .Test
10255     @result{} warning: `Test' not defined
10256 \&.Test
10257     @result{} .Test
10258 @endExample
10259
10260 @item
10261 It prevents kerning between two glyphs.
10262
10263 @iftex
10264 @c can't use @Example...@endExample here
10265 @example
10266 @group
10267 VA
10268     @result{} @r{VA}
10269 V\&A
10270     @result{} @r{V@w{}A}
10271 @end group
10272 @end example
10273 @end iftex
10274
10275 @item
10276 It is needed to map an arbitrary character to nothing in the @code{tr}
10277 request (@pxref{Character Translations}).
10278 @end itemize
10279 @endDefesc
10280
10281 @Defesc {\\), , , }
10282 This escape is similar to @code{\&} except that it behaves like a
10283 character declared with the @code{cflags} request to be transparent for
10284 the purposes of an end-of-sentence character.
10285
10286 Its main usage is in macro definitions to protect against arguments
10287 starting with a control character.
10288
10289 @Example
10290 .de xxx
10291 \)\\$1
10292 ..
10293 .de yyy
10294 \&\\$1
10295 ..
10296 This is a test.\c
10297 .xxx '
10298 This is a test.
10299     @result{}This is a test.'  This is a test.
10300 This is a test.\c
10301 .yyy '
10302 This is a test.
10303     @result{}This is a test.' This is a test.
10304 @endExample
10305 @endDefesc
10306
10307
10308 @c =====================================================================
10309
10310 @node Sizes, Strings, Fonts and Symbols, gtroff Reference
10311 @section Sizes
10312 @cindex sizes
10313
10314 @cindex baseline
10315 @cindex type size
10316 @cindex size of type
10317 @cindex vertical spacing
10318 @cindex spacing, vertical
10319 @code{gtroff} uses two dimensions with each line of text, type size and
10320 vertical spacing.  The @dfn{type size} is approximately the height of
10321 the tallest glyph.@footnote{This is usually the parenthesis.  Note that
10322 in most cases the real dimensions of the glyphs in a font are @emph{not}
10323 related to its type size!  For example, the standard @sc{PostScript}
10324 font families `Times Roman', `Helvetica', and `Courier' can't be used
10325 together at 10@dmn{pt}; to get acceptable output, the size of
10326 `Helvetica' has to be reduced by one point, and the size of `Courier'
10327 must be increased by one point.}  @dfn{Vertical spacing} is the amount
10328 of space @code{gtroff} allows for a line of text; normally, this is
10329 about 20%@tie{}larger than the current type size.  Ratios smaller than
10330 this can result in hard-to-read text; larger than this, it spreads the
10331 text out more vertically (useful for term papers).  By default,
10332 @code{gtroff} uses 10@tie{}point type on 12@tie{}point spacing.
10333
10334 @cindex leading
10335 The difference between type size and vertical spacing is known, by
10336 typesetters, as @dfn{leading} (this is pronounced `ledding').
10337
10338 @menu
10339 * Changing Type Sizes::
10340 * Fractional Type Sizes::
10341 @end menu
10342
10343 @c ---------------------------------------------------------------------
10344
10345 @node Changing Type Sizes, Fractional Type Sizes, Sizes, Sizes
10346 @subsection Changing Type Sizes
10347
10348 @DefreqList {ps, [@Var{size}]}
10349 @DefreqItem {ps, @t{+}@Var{size}}
10350 @DefreqItem {ps, @t{-}@Var{size}}
10351 @DefescItemx {\\s, , size, }
10352 @DefregListEndx {.s}
10353 @cindex changing type sizes (@code{ps}, @code{\s})
10354 @cindex type sizes, changing (@code{ps}, @code{\s})
10355 @cindex point sizes, changing (@code{ps}, @code{\s})
10356 Use the @code{ps} request or the @code{\s} escape to change (increase,
10357 decrease) the type size (in points).  Specify @var{size} as either an
10358 absolute point size, or as a relative change from the current size.  The
10359 size@tie{}0 (for both @code{.ps} and @code{\s}), or no argument (for
10360 @code{.ps} only), goes back to the previous size.
10361
10362 Default scaling indicator of @code{size} is @samp{z}.  If @code{size} is
10363 negative, it is set to 1@dmn{u}.
10364
10365 @cindex type size registers (@code{.s}, @code{.ps})
10366 @cindex point size registers (@code{.s}, @code{.ps})
10367 The read-only number register @code{.s} returns the point size in points
10368 as a decimal fraction.  This is a string.  To get the point size in
10369 scaled points, use the @code{.ps} register instead.
10370
10371 @code{.s} is associated with the current environment
10372 (@pxref{Environments}).
10373
10374 @Example
10375 snap, snap,
10376 .ps +2
10377 grin, grin,
10378 .ps +2
10379 wink, wink, \s+2nudge, nudge,\s+8 say no more!
10380 .ps 10
10381 @endExample
10382
10383 The @code{\s} escape may be called in a variety of ways.  Much like
10384 other escapes there must be a way to determine where the argument ends
10385 and the text begins.  Any of the following forms are valid:
10386
10387 @table @code
10388 @item \s@var{n}
10389 Set the point size to @var{n}@tie{}points.  @var{n}@tie{}must be either
10390 0 or in the range 4 to@tie{}39.
10391
10392 @item \s+@var{n}
10393 @itemx \s-@var{n}
10394 Increase or decrease the point size by @var{n}@tie{}points.
10395 @var{n}@tie{}must be exactly one digit.
10396
10397 @item \s(@var{nn}
10398 Set the point size to @var{nn}@tie{}points.  @var{nn} must be exactly
10399 two digits.
10400
10401 @item \s+(@var{nn}
10402 @itemx \s-(@var{nn}
10403 @itemx \s(+@var{nn}
10404 @itemx \s(-@var{nn}
10405 Increase or decrease the point size by @var{nn}@tie{}points.  @var{nn}
10406 must be exactly two digits.
10407 @end table
10408
10409 Note that @code{\s} doesn't produce an input token in @code{gtroff}.  As
10410 a consequence, it can be used in requests like @code{mc} (which expects
10411 a single character as an argument) to change the font on the fly:
10412
10413 @Example
10414 .mc \s[20]x\s[0]
10415 @endExample
10416
10417 @xref{Fractional Type Sizes}, for yet another syntactical form of using
10418 the @code{\s} escape.
10419 @endDefreq
10420
10421 @Defreq {sizes, s1 s2 @dots{} sn [0]}
10422 Some devices may only have certain permissible sizes, in which case
10423 @code{gtroff} rounds to the nearest permissible size.  The @file{DESC}
10424 file specifies which sizes are permissible for the device.
10425
10426 Use the @code{sizes} request to change the permissible sizes for the
10427 current output device.  Arguments are in scaled points; the
10428 @code{sizescale} line in the @file{DESC} file for the output device
10429 provides the scaling factor.  For example, if the scaling factor is
10430 1000, then the value 12000 is 12@tie{}points.
10431
10432 Each argument can be a single point size (such as @samp{12000}), or a
10433 range of sizes (such as @samp{4000-72000}).  You can optionally end the
10434 list with a zero.
10435 @endDefreq
10436
10437 @DefreqList {vs, [@Var{space}]}
10438 @DefreqItem {vs, @t{+}@Var{space}}
10439 @DefreqItem {vs, @t{-}@Var{space}}
10440 @DefregListEndx {.v}
10441 @cindex changing vertical line spacing (@code{vs})
10442 @cindex vertical line spacing, changing (@code{vs})
10443 @cindex vertical line spacing register (@code{.v})
10444 Change (increase, decrease) the vertical spacing by @var{space}.  The
10445 default scaling indicator is @samp{p}.
10446
10447 If @code{vs} is called without an argument, the vertical spacing is
10448 reset to the previous value before the last call to @code{vs}.
10449
10450 @cindex @code{.V} register, and @code{vs}
10451 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
10452 negative; the vertical spacing is then set to smallest positive value,
10453 the vertical resolution (as given in the @code{.V} register).
10454
10455 Note that @w{@samp{.vs 0}} isn't saved in a diversion since it doesn't
10456 result in a vertical motion.  You explicitly have to repeat this command
10457 before inserting the diversion.
10458
10459 The read-only number register @code{.v} contains the current vertical
10460 spacing; it is associated with the current environment
10461 (@pxref{Environments}).
10462 @endDefreq
10463
10464 @cindex vertical line spacing, effective value
10465 The effective vertical line spacing consists of four components.
10466 Breaking a line causes the following actions (in the given order).
10467
10468 @itemize @bullet
10469 @item
10470 @cindex extra pre-vertical line space (@code{\x})
10471 @cindex line space, extra pre-vertical (@code{\x})
10472 Move the current point vertically by the @dfn{extra pre-vertical line
10473 space}.  This is the minimum value of all @code{\x} escapes with a
10474 negative argument in the current output line.
10475
10476 @item
10477 Move the current point vertically by the vertical line spacing as set
10478 with the @code{vs} request.
10479
10480 @item
10481 Output the current line.
10482
10483 @item
10484 @cindex extra post-vertical line space (@code{\x})
10485 @cindex line space, extra post-vertical (@code{\x})
10486 Move the current point vertically by the @dfn{extra post-vertical line
10487 space}.  This is the maximum value of all @code{\x} escapes with a
10488 positive argument in the line that has just been output.
10489
10490 @item
10491 @cindex post-vertical line spacing
10492 @cindex line spacing, post-vertical (@code{pvs})
10493 Move the current point vertically by the @dfn{post-vertical line
10494 spacing} as set with the @code{pvs} request.
10495 @end itemize
10496
10497 @cindex double-spacing (@code{vs}, @code{pvs})
10498 It is usually better to use @code{vs} or @code{pvs} instead of @code{ls}
10499 to produce double-spaced documents: @code{vs} and @code{pvs} have a
10500 finer granularity for the inserted vertical space compared to @code{ls};
10501 furthermore, certain preprocessors assume single-spacing.
10502
10503 @xref{Manipulating Spacing}, for more details on the @code{\x} escape
10504 and the @code{ls} request.
10505
10506 @DefreqList {pvs, [@Var{space}]}
10507 @DefreqItem {pvs, @t{+}@Var{space}}
10508 @DefreqItem {pvs, @t{-}@Var{space}}
10509 @DefregListEndx {.pvs}
10510 @cindex @code{ls} request, alternative to (@code{pvs})
10511 @cindex post-vertical line spacing, changing (@code{pvs})
10512 @cindex post-vertical line spacing register (@code{.pvs})
10513 Change (increase, decrease) the post-vertical spacing by @var{space}.
10514 The default scaling indicator is @samp{p}.
10515
10516 If @code{pvs} is called without an argument, the post-vertical spacing
10517 is reset to the previous value before the last call to @code{pvs}.
10518
10519 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
10520 zero or negative; the vertical spacing is then set to zero.
10521
10522 The read-only number register @code{.pvs} contains the current
10523 post-vertical spacing; it is associated with the current environment
10524 (@pxref{Environments}).
10525 @endDefreq
10526
10527 @c ---------------------------------------------------------------------
10528
10529 @node Fractional Type Sizes,  , Changing Type Sizes, Sizes
10530 @subsection Fractional Type Sizes
10531 @cindex fractional type sizes
10532 @cindex fractional point sizes
10533 @cindex type sizes, fractional
10534 @cindex point sizes, fractional
10535 @cindex sizes, fractional
10536
10537 @cindex @code{s} unit
10538 @cindex unit, @code{s}
10539 @cindex @code{z} unit
10540 @cindex unit, @code{z}
10541 @cindex @code{ps} request, with fractional type sizes
10542 @cindex @code{cs} request, with fractional type sizes
10543 @cindex @code{tkf} request, with fractional type sizes
10544 @cindex @code{\H}, with fractional type sizes
10545 @cindex @code{\s}, with fractional type sizes
10546 A @dfn{scaled point} is equal to @math{1/@var{sizescale}} points, where
10547 @var{sizescale} is specified in the @file{DESC} file (1@tie{}by
10548 default).  There is a new scale indicator @samp{z}, which has the effect
10549 of multiplying by @var{sizescale}.  Requests and escape sequences in
10550 @code{gtroff} interpret arguments that represent a point size as being
10551 in units of scaled points, but they evaluate each such argument using a
10552 default scale indicator of @samp{z}.  Arguments treated in this way are
10553 the argument to the @code{ps} request, the third argument to the
10554 @code{cs} request, the second and fourth arguments to the @code{tkf}
10555 request, the argument to the @code{\H} escape sequence, and those
10556 variants of the @code{\s} escape sequence that take a numeric expression
10557 as their argument (see below).
10558
10559 For example, suppose @var{sizescale} is@tie{}1000; then a scaled point
10560 is equivalent to a millipoint; the request @w{@samp{.ps 10.25}} is
10561 equivalent to @w{@samp{.ps 10.25z}} and thus sets the point size to
10562 10250@tie{}scaled points, which is equal to 10.25@tie{}points.
10563
10564 @code{gtroff} disallows the use of the @samp{z} scale indicator in
10565 instances where it would make no sense, such as a numeric expression
10566 whose default scale indicator was neither @samp{u} nor @samp{z}.
10567 Similarly it would make no sense to use a scaling indicator other than
10568 @samp{z} or @samp{u} in a numeric expression whose default scale
10569 indicator was @samp{z}, and so @code{gtroff} disallows this as well.
10570
10571 There is also new scale indicator @samp{s}, which multiplies by the
10572 number of units in a scaled point.  So, for example, @samp{\n[.ps]s} is
10573 equal to @samp{1m}.  Be sure not to confuse the @samp{s} and @samp{z}
10574 scale indicators.
10575
10576 @Defreg {.ps}
10577 A read-only number register returning the point size in scaled points.
10578
10579 @code{.ps} is associated with the current environment
10580 (@pxref{Environments}).
10581 @endDefreg
10582
10583 @DefregList {.psr}
10584 @DefregListEndx {.sr}
10585 @cindex last-requested point size registers (@code{.psr}, @code{.sr})
10586 @cindex point size registers, last-requested (@code{.psr}, @code{.sr})
10587 @cindex @code{.ps} register, in comparison with @code{.psr}
10588 @cindex @code{.s} register, in comparison with @code{.sr}
10589 The last-requested point size in scaled points is contained in the
10590 @code{.psr} read-only number register.  The last requested point size in
10591 points as a decimal fraction can be found in @code{.sr}.  This is a
10592 string-valued read-only number register.
10593
10594 Note that the requested point sizes are device-independent, whereas the
10595 values returned by the @code{.ps} and @code{.s} registers are not.  For
10596 example, if a point size of 11@dmn{pt} is requested, and a @code{sizes}
10597 request (or a @code{sizescale} line in a @file{DESC} file) specifies
10598 10.95@dmn{pt} instead, this value is actually used.
10599
10600 Both registers are associated with the current environment
10601 (@pxref{Environments}).
10602 @endDefreg
10603
10604 The @code{\s} escape has the following syntax for working with
10605 fractional type sizes:
10606
10607 @table @code
10608 @item \s[@var{n}]
10609 @itemx \s'@var{n}'
10610 Set the point size to @var{n}@tie{}scaled points; @var{n}@tie{}is a
10611 numeric expression with a default scale indicator of @samp{z}.
10612
10613 @item \s[+@var{n}]
10614 @itemx \s[-@var{n}]
10615 @itemx \s+[@var{n}]
10616 @itemx \s-[@var{n}]
10617 @itemx \s'+@var{n}'
10618 @itemx \s'-@var{n}'
10619 @itemx \s+'@var{n}'
10620 @itemx \s-'@var{n}'
10621 Increase or or decrease the point size by @var{n}@tie{}scaled points;
10622 @var{n}@tie{}is a numeric expression (which may start with a minus sign)
10623 with a default scale indicator of @samp{z}.
10624 @end table
10625
10626 @xref{Font Files}.
10627
10628
10629 @c =====================================================================
10630
10631 @node Strings, Conditionals and Loops, Sizes, gtroff Reference
10632 @section Strings
10633 @cindex strings
10634
10635 @code{gtroff} has string variables, which are entirely for user
10636 convenience (i.e.@: there are no built-in strings exept @code{.T}, but
10637 even this is a read-write string variable).
10638
10639 Although the following requests can be used to create strings,
10640 simply using an undefined string will cause it to be defined as empty.
10641 @xref{Identifiers}.
10642
10643 @DefreqList {ds, name [@Var{string}]}
10644 @DefreqItemx {ds1, name [@Var{string}]}
10645 @DefescItemx {\\*, , n, }
10646 @DefescItem {\\*, @Lparen{}, nm, }
10647 @DefescListEnd {\\*, @Lbrack{}, name arg1 arg2 @dots{}, @Rbrack{}}
10648 @cindex string interpolation (@code{\*})
10649 @cindex string expansion (@code{\*})
10650 @cindex interpolation of strings (@code{\*})
10651 @cindex expansion of strings (@code{\*})
10652 @cindex string arguments
10653 @cindex arguments, of strings
10654 Define and access a string variable @var{name} (one-character
10655 name@tie{}@var{n}, two-character name @var{nm}).  If @var{name} already
10656 exists, @code{ds} overwrites the previous definition.  Only the syntax
10657 form using brackets can take arguments that are handled identically to
10658 macro arguments; the single exception is that a closing bracket as an
10659 argument must be enclosed in double quotes.  @xref{Request and Macro
10660 Arguments}, and @ref{Parameters}.
10661
10662 Example:
10663
10664 @Example
10665 .ds foo a \\$1 test
10666 .
10667 This is \*[foo nice].
10668     @result{} This is a nice test.
10669 @endExample
10670
10671 The @code{\*} escape @dfn{interpolates} (expands in-place) a
10672 previously-defined string variable.  To be more precise, the stored
10673 string is pushed onto the input stack, which is then parsed by
10674 @code{gtroff}.  Similar to number registers, it is possible to nest
10675 strings, i.e., string variables can be called within string variables.
10676
10677 If the string named by the @code{\*} escape does not exist, it is
10678 defined as empty, and a warning of type @samp{mac} is emitted (see
10679 @ref{Debugging}, for more details).
10680
10681 @cindex comments, with @code{ds}
10682 @cindex @code{ds} request, and comments
10683 @strong{Caution:} Unlike other requests, the second argument to the
10684 @code{ds} request takes up the entire line including trailing spaces.
10685 This means that comments on a line with such a request can introduce
10686 unwanted space into a string.
10687
10688 @Example
10689 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d \" UNIX trademark
10690 @endExample
10691
10692 @noindent
10693 Instead the comment should be put on another line or have the comment
10694 escape adjacent with the end of the string.
10695
10696 @Example
10697 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d\"  UNIX trademark
10698 @endExample
10699
10700 @cindex trailing quotes
10701 @cindex quotes, trailing
10702 @cindex leading spaces with @code{ds}
10703 @cindex spaces with @code{ds}
10704 @cindex @code{ds} request, and leading spaces
10705 To produce leading space the string can be started with a double quote.
10706 No trailing quote is needed; in fact, any trailing quote is included in
10707 your string.
10708
10709 @Example
10710 .ds sign "           Yours in a white wine sauce,
10711 @endExample
10712
10713 @cindex multi-line strings
10714 @cindex strings, multi-line
10715 @cindex newline character, in strings, escaping
10716 @cindex escaping newline characters, in strings
10717 Strings are not limited to a single line of text.  A string can span
10718 several lines by escaping the newlines with a backslash.  The resulting
10719 string is stored @emph{without} the newlines.
10720
10721 @Example
10722 .ds foo lots and lots \
10723 of text are on these \
10724 next several lines
10725 @endExample
10726
10727 It is not possible to have real newlines in a string.  To put a single
10728 double quote character into a string, use two consecutive double quote
10729 characters.
10730
10731 The @code{ds1} request turns off compatibility mode while interpreting a
10732 string.  To be more precise, a @dfn{compatibility save} input token is
10733 inserted at the beginning of the string, and a @dfn{compatibility
10734 restore} input token at the end.
10735
10736 @Example
10737 .nr xxx 12345
10738 .ds aa The value of xxx is \\n[xxx].
10739 .ds1 bb The value of xxx ix \\n[xxx].
10740 .
10741 .cp 1
10742 .
10743 \*(aa
10744     @result{} warning: number register `[' not defined
10745     @result{} The value of xxx is 0xxx].
10746 \*(bb
10747     @result{} The value of xxx ix 12345.
10748 @endExample
10749
10750 @cindex name space, common, of macros, diversions, and strings
10751 @cindex common name space of macros, diversions, and strings
10752 @cindex macros, shared name space with strings and diversions
10753 @cindex strings, shared name space with macros and diversions
10754 @cindex diversions, shared name space with macros and strings
10755 Strings, macros, and diversions (and boxes) share the same name space.
10756 Internally, even the same mechanism is used to store them.  This has
10757 some interesting consequences.  For example, it is possible to call a
10758 macro with string syntax and vice versa.
10759
10760 @Example
10761 .de xxx
10762 a funny test.
10763 ..
10764 This is \*[xxx]
10765     @result{} This is a funny test.
10766
10767 .ds yyy a funny test
10768 This is
10769 .yyy
10770     @result{} This is a funny test.
10771 @endExample
10772
10773 In particular, interpolating a string does not hide existing macro
10774 arguments.  Thus in a macro, a more efficient way of doing
10775
10776 @Example
10777 .xx \\$@@
10778 @endExample
10779
10780 @noindent
10781 is
10782
10783 @Example
10784 \\*[xx]\\
10785 @endExample
10786
10787 @noindent
10788 Note that the latter calling syntax doesn't change the value of
10789 @code{\$0}, which is then inherited from the calling macro.
10790
10791 Diversions and boxes can be also called with string syntax.
10792
10793 Another consequence is that you can copy one-line diversions or boxes to
10794 a string.
10795
10796 @Example
10797 .di xxx
10798 a \fItest\fR
10799 .br
10800 .di
10801 .ds yyy This is \*[xxx]\c
10802 \*[yyy].
10803     @result{} @r{This is a }@i{test}.
10804 @endExample
10805
10806 @noindent
10807 As the previous example shows, it is possible to store formatted output
10808 in strings.  The @code{\c} escape prevents the insertion of an
10809 additional blank line in the output.
10810
10811 Copying diversions longer than a single output line produces unexpected
10812 results.
10813
10814 @Example
10815 .di xxx
10816 a funny
10817 .br
10818 test
10819 .br
10820 .di
10821 .ds yyy This is \*[xxx]\c
10822 \*[yyy].
10823     @result{} test This is a funny.
10824 @endExample
10825
10826 Usually, it is not predictable whether a diversion contains one or more
10827 output lines, so this mechanism should be avoided.  With @acronym{UNIX}
10828 @code{troff}, this was the only solution to strip off a final newline
10829 from a diversion.  Another disadvantage is that the spaces in the copied
10830 string are already formatted, making them unstretchable.  This can cause
10831 ugly results.
10832
10833 @cindex stripping final newline in diversions
10834 @cindex diversion, stripping final newline
10835 @cindex final newline, stripping in diversions
10836 @cindex newline, final, stripping in diversions
10837 @cindex horizontal space, unformatting
10838 @cindex space, horizontal, unformatting
10839 @cindex unformatting horizontal space
10840 A clean solution to this problem is available in GNU @code{troff}, using
10841 the requests @code{chop} to remove the final newline of a diversion, and
10842 @code{unformat} to make the horizontal spaces stretchable again.
10843
10844 @Example
10845 .box xxx
10846 a funny
10847 .br
10848 test
10849 .br
10850 .box
10851 .chop xxx
10852 .unformat xxx
10853 This is \*[xxx].
10854     @result{} This is a funny test.
10855 @endExample
10856
10857 @xref{Gtroff Internals}, for more information.
10858 @endDefreq
10859
10860 @DefreqList {as, name [@Var{string}]}
10861 @DefreqListEndx {as1, name [@Var{string}]}
10862 @cindex appending to a string (@code{as})
10863 @cindex string, appending (@code{as})
10864 The @code{as} request is similar to @code{ds} but appends @var{string}
10865 to the string stored as @var{name} instead of redefining it.  If
10866 @var{name} doesn't exist yet, it is created.
10867
10868 @Example
10869 .as sign " with shallots, onions and garlic,
10870 @endExample
10871
10872 The @code{as1} request is similar to @code{as}, but compatibility mode
10873 is switched off while the appended string is interpreted.  To be more
10874 precise, a @dfn{compatibility save} input token is inserted at the
10875 beginning of the appended string, and a @dfn{compatibility restore}
10876 input token at the end.
10877 @endDefreq
10878
10879 Rudimentary string manipulation routines are given with the next two
10880 requests.
10881
10882 @Defreq {substring, str n1 [@Var{n2}]}
10883 @cindex substring (@code{substring})
10884 Replace the string named @var{str} with the substring defined by the
10885 indices @var{n1} and @var{n2}.  The first character in the string has
10886 index@tie{}0.  If @var{n2} is omitted, it is implicitly set to the
10887 largest valid value (the string length minus one).  If the index value
10888 @var{n1} or @var{n2} is negative, it is counted from the end of the
10889 string, going backwards: The last character has index@tie{}@minus{}1,
10890 the character before the last character has index@tie{}@minus{}2, etc.
10891
10892 @Example
10893 .ds xxx abcdefgh
10894 .substring xxx 1 -4
10895 \*[xxx]
10896     @result{} bcde
10897 .substring xxx 2
10898 \*[xxx]
10899     @result{} de
10900 @endExample
10901 @endDefreq
10902
10903 @Defreq {length, reg str}
10904 @cindex length of a string (@code{length})
10905 @cindex string, length of (@code{length})
10906 @cindex @code{length} request, and copy-in mode
10907 @cindex copy-in mode, and @code{length} request
10908 @cindex mode, copy-in, and @code{length} request
10909 Compute the number of characters of @var{str} and return it in the
10910 number register @var{reg}.  If @var{reg} doesn't exist, it is created.
10911 @code{str} is read in copy mode.
10912
10913 @Example
10914 .ds xxx abcd\h'3i'efgh
10915 .length yyy \*[xxx]
10916 \n[yyy]
10917     @result{} 14
10918 @endExample
10919 @endDefreq
10920
10921 @Defreq {rn, xx yy}
10922 @cindex renaming request (@code{rn})
10923 @cindex request, renaming (@code{rn})
10924 @cindex renaming macro (@code{rn})
10925 @cindex macro, renaming (@code{rn})
10926 @cindex renaming string (@code{rn})
10927 @cindex string, renaming (@code{rn})
10928 @cindex renaming diversion (@code{rn})
10929 @cindex diversion, renaming (@code{rn})
10930 Rename the request, macro, diversion, or string @var{xx} to @var{yy}.
10931 @endDefreq
10932
10933 @Defreq {rm, xx}
10934 @cindex removing request (@code{rm})
10935 @cindex request, removing (@code{rm})
10936 @cindex removing macro (@code{rm})
10937 @cindex macro, removing (@code{rm})
10938 @cindex removing string (@code{rm})
10939 @cindex string, removing (@code{rm})
10940 @cindex removing diversion (@code{rm})
10941 @cindex diversion, removing (@code{rm})
10942 Remove the request, macro, diversion, or string @var{xx}.  @code{gtroff}
10943 treats subsequent invocations as if the object had never been defined.
10944 @endDefreq
10945
10946 @anchor{als}
10947 @Defreq {als, new old}
10948 @cindex alias, string, creating (@code{als})
10949 @cindex alias, macro, creating (@code{als})
10950 @cindex alias, diversion, creating (@code{als})
10951 @cindex creating alias, for string (@code{als})
10952 @cindex creating alias, for macro (@code{als})
10953 @cindex creating alias, for diversion (@code{als})
10954 @cindex string, creating alias (@code{als})
10955 @cindex macro, creating alias (@code{als})
10956 @cindex diversion, creating alias (@code{als})
10957 Create an alias named @var{new} for the request, string, macro, or
10958 diversion object named @var{old}.  The new name and the old name are
10959 exactly equivalent (it is similar to a hard rather than a soft link).  If
10960 @var{old} is undefined, @code{gtroff} generates a warning of type
10961 @samp{mac} and ignores the request.
10962
10963 To understand how the @code{als} request works it is probably best to
10964 think of two different pools: one pool for objects (macros, strings,
10965 etc.), and another one for names.  As soon as an object is defined,
10966 @code{gtroff} adds it to the object pool, adds its name to the name
10967 pool, and creates a link between them.  When @code{als} creates an
10968 alias, it adds a new name to the name pool that gets linked to the same
10969 object as the old name.
10970
10971 Now consider this example.
10972
10973 @Example
10974 .de foo
10975 ..
10976 .
10977 .als bar foo
10978 .
10979 .de bar
10980 .  foo
10981 ..
10982 .
10983 .bar
10984     @result{} input stack limit exceeded
10985 @endExample
10986
10987 @noindent
10988 The definition of macro @code{bar} replaces the old object this name is
10989 linked to.  However, the alias to @code{foo} is still active!  In
10990 other words, @code{foo} is still linked to the same object as
10991 @code{bar}, and the result of calling @code{bar} is an infinite,
10992 recursive loop that finally leads to an error.
10993
10994 @cindex alias, string, removing (@code{rm})
10995 @cindex alias, macro, removing (@code{rm})
10996 @cindex alias, diversion, removing (@code{rm})
10997 @cindex removing alias, for string (@code{rm})
10998 @cindex removing alias, for macro (@code{rm})
10999 @cindex removing alias, for diversion (@code{rm})
11000 @cindex string, removing alias (@code{rm})
11001 @cindex macro, removing alias (@code{rm})
11002 @cindex diversion, removing alias (@code{rm})
11003 To undo an alias, simply call @code{rm} on the aliased name.  The object
11004 itself is not destroyed until there are no more aliases.
11005 @endDefreq
11006
11007 @Defreq {chop, xx}
11008 Remove (chop) the last character from the macro, string, or diversion
11009 named @var{xx}.  This is useful for removing the newline from the end of
11010 diversions that are to be interpolated as strings.  This command can be
11011 used repeatedly; see @ref{Gtroff Internals}, for details on nodes
11012 inserted additionally by @code{gtroff}.
11013 @endDefreq
11014
11015 @xref{Identifiers}, and @ref{Comments}.
11016
11017
11018 @c =====================================================================
11019
11020 @node Conditionals and Loops, Writing Macros, Strings, gtroff Reference
11021 @section Conditionals and Loops
11022 @cindex conditionals and loops
11023 @cindex loops and conditionals
11024
11025 @menu
11026 * Operators in Conditionals::
11027 * if-else::
11028 * while::
11029 @end menu
11030
11031 @c ---------------------------------------------------------------------
11032
11033 @node Operators in Conditionals, if-else, Conditionals and Loops, Conditionals and Loops
11034 @subsection Operators in Conditionals
11035
11036 @cindex @code{if} request, operators to use with
11037 @cindex @code{ie} request, operators to use with
11038 @cindex @code{while} request, operators to use with
11039 In @code{if}, @code{ie}, and @code{while} requests, in addition to ordinary
11040 @ref{Expressions}, there are several more operators available:
11041
11042 @table @code
11043 @item e
11044 @itemx o
11045 True if the current page is even or odd numbered (respectively).
11046
11047 @item n
11048 @cindex conditional output for terminal (TTY)
11049 @cindex TTY, conditional output for
11050 @cindex terminal, conditional output for
11051 True if the document is being processed in nroff mode (i.e., the
11052 @code{.nroff} command has been issued).  @xref{Troff and Nroff Mode}.
11053
11054 @item t
11055 True if the document is being processed in troff mode (i.e., the
11056 @code{.troff} command has been issued).  @xref{Troff and Nroff Mode}.
11057
11058 @item v
11059 Always false.  This condition is for compatibility with other
11060 @code{troff} versions only (identifying a @code{-Tversatec} device).
11061
11062 @item '@var{xxx}'@var{yyy}'
11063 True if the output produced by @var{xxx} is equal to the output produced
11064 by @var{yyy}.  Other characters can be used in place of the single
11065 quotes; the same set of delimiters as for the @code{\D} escape is used
11066 (@pxref{Escapes}).  @code{gtroff} formats @var{xxx} and @var{yyy} in
11067 separate environments; after the comparison the resulting data is
11068 discarded.
11069
11070 @Example
11071 .ie "|"\fR|\fP" \
11072 true
11073 .el \
11074 false
11075     @result{} true
11076 @endExample
11077
11078 @noindent
11079 The resulting motions, glyph sizes, and fonts have to
11080 match,@footnote{The created output nodes must be identical.
11081 @xref{Gtroff Internals}.} and not the individual motion, size, and font
11082 requests.  In the previous example, @samp{|} and @samp{\fR|\fP} both
11083 result in a roman @samp{|} glyph with the same point size and at the
11084 same location on the page, so the strings are equal.  If
11085 @samp{.ft@tie{}I} had been added before the @samp{.ie}, the result would
11086 be ``false'' because (the first) @samp{|} produces an italic @samp{|}
11087 rather than a roman one.
11088
11089 @cindex string comparison
11090 @cindex comparison of strings
11091 To compare strings without processing, surround the data with @code{\?}.
11092
11093 @Example
11094 .ie "\?|\?"\?\fR|\fP\?" \
11095 true
11096 .el \
11097 false
11098     @result{} false
11099 @endExample
11100
11101 @cindex @code{\?}, and copy-in mode
11102 @cindex copy-in mode, and @code{\?}
11103 @cindex mode, copy-in, and @code{\?}
11104 @noindent
11105 Since data protected with @code{\?} is read in copy-in mode it is even
11106 possible to use incomplete input without causing an error.
11107
11108 @Example
11109 .ds a \[
11110 .ds b \[
11111 .ie '\?\*a\?'\?\*b\?' \
11112 true
11113 .el \
11114 false
11115     @result{} true
11116 @endExample
11117
11118 @item r @var{xxx}
11119 True if there is a number register named @var{xxx}.
11120
11121 @item d @var{xxx}
11122 True if there is a string, macro, diversion, or request named @var{xxx}.
11123
11124 @item m @var{xxx}
11125 True if there is a color named @var{xxx}.
11126
11127 @item c @var{g}
11128 True if there is a glyph @var{g} available@footnote{The name of this
11129 conditional operator is a misnomer since it tests names of output
11130 glyphs.}; @var{g} is either an @acronym{ASCII} character or a special
11131 character (@code{\N'@var{xxx}'}, @code{\(@var{gg}} or
11132 @code{\[@var{ggg}]}); the condition is also true if @var{g} has been
11133 defined by the @code{char} request.
11134
11135 @item F @var{font}
11136 True if a font named @var{font} exists.  @var{font} is handled as if it
11137 was opened with the @code{ft} request (this is, font translation and
11138 styles are applied), without actually mounting it.
11139
11140 This test doesn't load the complete font but only its header to verify
11141 its validity.
11142
11143 @item S @var{style}
11144 True if style @var{style} has been registered.  Font translation is
11145 applied.
11146 @end table
11147
11148 Note that these operators can't be combined with other operators like
11149 @samp{:} or @samp{&}; only a leading @samp{!} (without whitespace
11150 between the exclamation mark and the operator) can be used to negate the
11151 result.
11152
11153 @Example
11154 .nr xxx 1
11155 .ie !r xxx \
11156 true
11157 .el \
11158 false
11159     @result{} false
11160 @endExample
11161
11162 A whitespace after @samp{!} always evaluates to zero (this bizarre
11163 behaviour is due to compatibility with @acronym{UNIX} @code{troff}).
11164
11165 @Example
11166 .nr xxx 1
11167 .ie ! r xxx \
11168 true
11169 .el \
11170 false
11171     @result{} r xxx true
11172 @endExample
11173
11174 It is possible to omit the whitespace before the argument to the
11175 @samp{r}, @samp{d}, and @samp{c} operators.
11176
11177 @xref{Expressions}.
11178
11179 @c ---------------------------------------------------------------------
11180
11181 @node if-else, while, Operators in Conditionals, Conditionals and Loops
11182 @subsection if-else
11183 @cindex if-else
11184
11185 @code{gtroff} has if-then-else constructs like other languages, although
11186 the formatting can be painful.
11187
11188 @Defreq {if, expr anything}
11189
11190 Evaluate the expression @var{expr}, and executes @var{anything} (the
11191 remainder of the line) if @var{expr} evaluates to a value greater than
11192 zero (true).  @var{anything} is interpreted as though it was on a line
11193 by itself (except that leading spaces are swallowed).
11194 @xref{Operators in Conditionals}, for more info.
11195
11196 @Example
11197 .nr xxx 1
11198 .nr yyy 2
11199 .if ((\n[xxx] == 1) & (\n[yyy] == 2)) true
11200     @result{} true
11201 @endExample
11202 @endDefreq
11203
11204 @Defreq {nop, anything}
11205 Executes @var{anything}.  This is similar to @code{.if@tie{}1}.
11206 @endDefreq
11207
11208 @DefreqList {ie, expr anything}
11209 @DefreqListEndx {el, anything}
11210 Use the @code{ie} and @code{el} requests to write an if-then-else.  The
11211 first request is the `if' part and the latter is the `else' part.
11212
11213 @Example
11214 .ie n .ls 2 \" double-spacing in nroff
11215 .el   .ls 1 \" single-spacing in troff
11216 @endExample
11217 @endDefreq
11218
11219 @c there is a bug in makeinfo <= 4.1a: you can't have `@{' as an argument
11220 @c to @deffn
11221 @c
11222 @c and in 4.2 you still can't use @{ in macros.
11223
11224 @c @DefescList {\@{, , , }
11225 @c @DefescListEnd {\@}, , , }
11226 @deffn Escape @t{\@{}
11227 @deffnx Escape @t{\@}}
11228 @esindex \@{
11229 @esindex \@}
11230 @cindex begin of conditional block (@code{\@{})
11231 @cindex end of conditional block (@code{\@}})
11232 @cindex conditional block, begin (@code{\@{})
11233 @cindex conditional block, end (@code{\@}})
11234 @cindex block, conditional, begin (@code{\@{})
11235 @cindex block, condititional, end (@code{\@}})
11236 In many cases, an if (or if-else) construct needs to execute more than
11237 one request.  This can be done using the escapes @code{\@{} (which must
11238 start the first line) and @code{\@}} (which must end the last line).
11239
11240 @Example
11241 .ie t \@{\
11242 .    ds lq ``
11243 .    ds rq ''
11244 .\@}
11245 .el \@{\
11246 .    ds lq ""
11247 .    ds rq ""
11248 .\@}
11249 @endExample
11250 @c @endDefesc
11251 @end deffn
11252
11253 @xref{Expressions}.
11254
11255 @c ---------------------------------------------------------------------
11256
11257 @node while,  , if-else, Conditionals and Loops
11258 @subsection while
11259 @cindex while
11260
11261 @code{gtroff} provides a looping construct using the @code{while}
11262 request, which is used much like the @code{if} (and related) requests.
11263
11264 @Defreq {while, expr anything}
11265 Evaluate the expression @var{expr}, and repeatedly execute
11266 @var{anything} (the remainder of the line) until @var{expr} evaluates
11267 to@tie{}0.
11268
11269 @Example
11270 .nr a 0 1
11271 .while (\na < 9) \@{\
11272 \n+a,
11273 .\@}
11274 \n+a
11275     @result{} 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
11276 @endExample
11277
11278 Some remarks.
11279
11280 @cindex @code{de} request, and @code{while}
11281 @itemize @bullet
11282 @item
11283 The body of a @code{while} request is treated like the body of a
11284 @code{de} request: @code{gtroff} temporarily stores it in a macro that
11285 is deleted after the loop has been exited.  It can considerably slow
11286 down a macro if the body of the @code{while} request (within the macro)
11287 is large.  Each time the macro is executed, the @code{while} body is
11288 parsed and stored again as a temporary macro.
11289
11290 @Example
11291 .de xxx
11292 .  nr num 10
11293 .  while (\\n[num] > 0) \@{\
11294 .    \" many lines of code
11295 .    nr num -1
11296 .  \@}
11297 ..
11298 @endExample
11299
11300 @cindex recursive macros
11301 @cindex macros, recursive
11302 @noindent
11303 The traditional and ofter better solution (@acronym{UNIX} @code{troff}
11304 doesn't have the @code{while} request) is to use a recursive macro
11305 instead that is parsed only once during its definition.
11306
11307 @Example
11308 .de yyy
11309 .  if (\\n[num] > 0) \@{\
11310 .    \" many lines of code
11311 .    nr num -1
11312 .    yyy
11313 .  \@}
11314 ..
11315 .
11316 .de xxx
11317 .  nr num 10
11318 .  yyy
11319 ..
11320 @endExample
11321
11322 @noindent
11323 Note that the number of available recursion levels is set to@tie{}1000
11324 (this is a compile-time constant value of @code{gtroff}).
11325
11326 @item
11327 The closing brace of a @code{while} body must end a line.
11328
11329 @Example
11330 .if 1 \@{\
11331 .  nr a 0 1
11332 .  while (\n[a] < 10) \@{\
11333 .    nop \n+[a]
11334 .\@}\@}
11335     @result{} unbalanced \@{ \@}
11336 @endExample
11337 @end itemize
11338 @endDefreq
11339
11340 @Defreq {break, }
11341 @cindex @code{while} request, confusing with @code{br}
11342 @cindex @code{break} request, in a @code{while} loop
11343 @cindex @code{continue} request, in a @code{while} loop
11344 Break out of a @code{while} loop.  Be sure not to confuse this with the
11345 @code{br} request (causing a line break).
11346 @endDefreq
11347
11348 @Defreq {continue, }
11349 Finish the current iteration of a @code{while} loop, immediately
11350 restarting the next iteration.
11351 @endDefreq
11352
11353 @xref{Expressions}.
11354
11355
11356 @c =====================================================================
11357
11358 @node Writing Macros, Page Motions, Conditionals and Loops, gtroff Reference
11359 @section Writing Macros
11360 @cindex writing macros
11361 @cindex macros, writing
11362
11363 A @dfn{macro} is a collection of text and embedded commands that can be
11364 invoked multiple times.  Use macros to define common operations.
11365 @xref{Strings}, for a (limited) alternative syntax to call macros.
11366
11367 Although the following requests can be used to create macros,
11368 simply using an undefined macro will cause it to be defined as empty.
11369 @xref{Identifiers}.
11370
11371 @DefreqList {de, name [@Var{end}]}
11372 @DefreqItemx {de1, name [@Var{end}]}
11373 @DefreqItemx {dei, name [@Var{end}]}
11374 @DefreqListEndx {dei1, name [@Var{end}]}
11375 Define a new macro named @var{name}.  @code{gtroff} copies subsequent
11376 lines (starting with the next one) into an internal buffer until it
11377 encounters the line @samp{..} (two dots).  If the optional second
11378 argument to @code{de} is present it is used as the macro closure
11379 request instead of @samp{..}.
11380
11381 There can be whitespace after the first dot in the line containing the
11382 ending token (either @samp{.} or macro @samp{@var{end}}).  Don't insert
11383 a tab character immediately after the @samp{..}, otherwise it isn't
11384 recognized as the end-of-macro symbol.@footnote{While it is possible to
11385 define and call a macro @samp{.} with
11386
11387 @Example
11388 .de .
11389 .  tm foo
11390 ..
11391 .
11392 ..    \" This calls macro `.'!
11393 @endExample
11394
11395 @noindent
11396 you can't use this as the end-of-macro macro: during a macro definition,
11397 @samp{..} is never handled as a call to @samp{.}, even if you say
11398 @samp{.de foo .} explicitly.}
11399
11400 Here a small example macro called @samp{P} that causes a break and
11401 inserts some vertical space.  It could be used to separate paragraphs.
11402
11403 @Example
11404 .de P
11405 .  br
11406 .  sp .8v
11407 ..
11408 @endExample
11409
11410 The following example defines a macro within another.  Remember that
11411 expansion must be protected twice; once for reading the macro and once
11412 for executing.
11413
11414 @Example
11415 \# a dummy macro to avoid a warning
11416 .de end
11417 ..
11418 .
11419 .de foo
11420 .  de bar end
11421 .    nop \f[B]Hallo \\\\$1!\f[]
11422 .  end
11423 ..
11424 .
11425 .foo
11426 .bar Joe
11427     @result{} @b{Hallo Joe!}
11428 @endExample
11429
11430 @noindent
11431 Since @code{\f} has no expansion, it isn't necessary to protect its
11432 backslash.  Had we defined another macro within @code{bar} that takes a
11433 parameter, eight backslashes would be necessary before @samp{$1}.
11434
11435 The @code{de1} request turns off compatibility mode while executing the
11436 macro.  On entry, the current compatibility mode is saved and restored
11437 at exit.
11438
11439 @Example
11440 .nr xxx 12345
11441 .
11442 .de aa
11443 The value of xxx is \\n[xxx].
11444 ..
11445 .de1 bb
11446 The value of xxx ix \\n[xxx].
11447 ..
11448 .
11449 .cp 1
11450 .
11451 .aa
11452     @result{} warning: number register `[' not defined
11453     @result{} The value of xxx is 0xxx].
11454 .bb
11455     @result{} The value of xxx ix 12345.
11456 @endExample
11457
11458 The @code{dei} request defines a macro indirectly.  That is, it expands
11459 strings whose names are @var{name} or @var{end} before performing the
11460 append.
11461
11462 This:
11463
11464 @Example
11465 .ds xx aa
11466 .ds yy bb
11467 .dei xx yy
11468 @endExample
11469
11470 @noindent
11471 is equivalent to:
11472
11473 @Example
11474 .de aa bb
11475 @endExample
11476
11477 The @code{dei1} request is similar to @code{dei} but with compatibility
11478 mode switched off during execution of the defined macro.
11479
11480 If compatibility mode is on, @code{de} (and @code{dei}) behave similar
11481 to @code{de1} (and @code{dei1}): A `compatibility save' token is
11482 inserted at the beginning, and a `compatibility restore' token at the
11483 end, with compatibility mode switched on during execution.  @xref{Gtroff
11484 Internals}, for more information on switching compatibility mode on and
11485 off in a single document.
11486
11487 @pindex trace.tmac
11488 Using @file{trace.tmac}, you can trace calls to @code{de} and
11489 @code{de1}.
11490
11491 Note that macro identifiers are shared with identifiers for strings and
11492 diversions.
11493
11494 @xref{als,,the description of the @code{als} request}, for possible
11495 pitfalls if redefining a macro that has been aliased.
11496 @endDefreq
11497
11498 @DefreqList {am, name [@Var{end}]}
11499 @DefreqItemx {am1, name [@Var{end}]}
11500 @DefreqItemx {ami, name [@Var{end}]}
11501 @DefreqListEndx {ami1, name [@Var{end}]}
11502 @cindex appending to a macro (@code{am})
11503 @cindex macro, appending (@code{am})
11504 Works similarly to @code{de} except it appends onto the macro named
11505 @var{name}.  So, to make the previously defined @samp{P} macro actually
11506 do indented instead of block paragraphs, add the necessary code to the
11507 existing macro like this:
11508
11509 @Example
11510 .am P
11511 .ti +5n
11512 ..
11513 @endExample
11514
11515 The @code{am1} request turns off compatibility mode while executing the
11516 appended macro piece.  To be more precise, a @dfn{compatibility save}
11517 input token is inserted at the beginning of the appended code, and a
11518 @dfn{compatibility restore} input token at the end.
11519
11520 The @code{ami} request appends indirectly, meaning that @code{gtroff}
11521 expands strings whose names are @var{name} or @var{end} before
11522 performing the append.
11523
11524 The @code{ami1} request is similar to @code{ami} but compatibility mode
11525 is switched off during execution of the defined macro.
11526
11527 @pindex trace.tmac
11528 Using @file{trace.tmac}, you can trace calls to @code{am} and
11529 @code{am1}.
11530 @endDefreq
11531
11532 @xref{Strings}, for the @code{als} and @code{rn} request to create an
11533 alias and rename a macro, respectively.
11534
11535 The @code{de}, @code{am}, @code{di}, @code{da}, @code{ds}, and @code{as}
11536 requests (together with its variants) only create a new object if the
11537 name of the macro, diversion or string diversion is currently undefined
11538 or if it is defined to be a request; normally they modify the value of
11539 an existing object.
11540
11541 @Defreq {return, [@Var{anything}]}
11542 Exit a macro, immediately returning to the caller.
11543
11544 If called with an argument, exit twice, namely the current macro and the
11545 macro one level higher.  This is used to define a wrapper macro for
11546 @code{return} in @file{trace.tmac}.
11547 @endDefreq
11548
11549 @menu
11550 * Copy-in Mode::
11551 * Parameters::
11552 @end menu
11553
11554 @c ---------------------------------------------------------------------
11555
11556 @node Copy-in Mode, Parameters, Writing Macros, Writing Macros
11557 @subsection Copy-in Mode
11558 @cindex copy mode
11559 @cindex copy-in mode
11560 @cindex mode, copy
11561 @cindex mode, copy-in
11562
11563 @cindex @code{\n}, when reading text for a macro
11564 @cindex @code{\$}, when reading text for a macro
11565 @cindex @code{\*}, when reading text for a macro
11566 @cindex @code{\\}, when reading text for a macro
11567 @cindex \@key{RET}, when reading text for a macro
11568 When @code{gtroff} reads in the text for a macro, string, or diversion,
11569 it copies the text (including request lines, but excluding escapes) into
11570 an internal buffer.  Escapes are converted into an internal form, except
11571 for @code{\n}, @code{\$}, @code{\*}, @code{\\} and @code{\@key{RET}},
11572 which are evaluated and inserted into the text where the escape was
11573 located.  This is known as @dfn{copy-in} mode or @dfn{copy} mode.
11574
11575 What this means is that you can specify when these escapes are to be
11576 evaluated (either at copy-in time or at the time of use) by insulating
11577 the escapes with an extra backslash.  Compare this to the @code{\def}
11578 and @code{\edef} commands in @TeX{}.
11579
11580 The following example prints the numbers 20 and@tie{}10:
11581
11582 @Example
11583 .nr x 20
11584 .de y
11585 .nr x 10
11586 \&\nx
11587 \&\\nx
11588 ..
11589 .y
11590 @endExample
11591
11592 @c ---------------------------------------------------------------------
11593
11594 @node Parameters,  , Copy-in Mode, Writing Macros
11595 @subsection Parameters
11596 @cindex parameters
11597
11598 The arguments to a macro or string can be examined using a variety of
11599 escapes.
11600
11601 @Defreg {.$}
11602 @cindex number of arguments register (@code{.$})
11603 The number of arguments passed to a macro or string.  This is a
11604 read-only number register.
11605
11606 Note that the @code{shift} request can change its value.
11607 @endDefreg
11608
11609 Any individual argument can be retrieved with one of the following
11610 escapes:
11611
11612 @DefescList {\\$, , n, }
11613 @DefescItem {\\$, @Lparen{}, nn, }
11614 @DefescListEnd {\\$, @Lbrack{}, nnn, @Rbrack{}}
11615 @cindex copy-in mode, and macro arguments
11616 @cindex mode, copy-in, and macro arguments
11617 @cindex macro, arguments (@code{\$})
11618 @cindex arguments, macro (@code{\$})
11619 Retrieve the @var{n}@dmn{th}, @var{nn}@dmn{th} or @var{nnn}@dmn{th}
11620 argument.  As usual, the first form only accepts a single number (larger
11621 than zero), the second a two-digit number (larger or equal to@tie{}10),
11622 and the third any positive integer value (larger than zero).  Macros and
11623 strings can have an unlimited number of arguments.  Note that due to
11624 copy-in mode, use two backslashes on these in actual use to prevent
11625 interpolation until the macro is actually invoked.
11626 @endDefesc
11627
11628 @Defreq {shift, [@Var{n}]}
11629 Shift the arguments 1@tie{}position, or as many positions as specified
11630 by its argument.  After executing this request, argument@tie{}@var{i}
11631 becomes argument @math{@var{i}-@var{n}}; arguments 1 to@tie{}@var{n} are
11632 no longer available.  Shifting by negative amounts is currently
11633 undefined.
11634
11635 The register @code{.$} is adjusted accordingly.
11636 @endDefreq
11637
11638 @DefescList {\\$*, , , }
11639 @DefescListEndx {\\$@@, , , }
11640 In some cases it is convenient to use all of the arguments at once (for
11641 example, to pass the arguments along to another macro).  The @code{\$*}
11642 escape concatenates all the arguments separated by spaces.  A similar
11643 escape is @code{\$@@}, which concatenates all the arguments with each
11644 surrounded by double quotes, and separated by spaces.  If not in
11645 compatibility mode, the input level of double quotes is preserved (see
11646 @ref{Request and Macro Arguments}).
11647 @endDefesc
11648
11649 @Defesc {\\$^, , , }
11650 Handle the parameters of a macro as if they were an argument to the
11651 @code{ds} or similar requests.
11652
11653 @Example
11654 .de foo
11655 .  tm $1=`\\$1'
11656 .  tm $2=`\\$2'
11657 .  tm $*=`\\$*'
11658 .  tm $@@=`\\$@@'
11659 .  tm $^=`\\$^'
11660 ..
11661 .foo " This is a "test"
11662     @result{} $1=` This is a '
11663     @result{} $2=`test"'
11664     @result{} $*=` This is a  test"'
11665     @result{} $@@=`" This is a " "test""'
11666     @result{} $^=`" This is a "test"'
11667 @endExample
11668
11669 This escape is useful mainly for macro packages like @file{trace.tmac},
11670 which redefines some requests and macros for debugging purposes.
11671 @endDefesc
11672
11673 @Defesc {\\$0, , , }
11674 @cindex macro name register (@code{\$0})
11675 @cindex @code{als} request, and @code{\$0}
11676 The name used to invoke the current macro.  The @code{als} request can
11677 make a macro have more than one name.
11678
11679 If a macro is called as a string (within another macro), the value of
11680 @code{\$0} isn't changed.
11681
11682 @Example
11683 .de foo
11684 .  tm \\$0
11685 ..
11686 .als foo bar
11687 .
11688 @endExample
11689 @Example
11690 .de aaa
11691 .  foo
11692 ..
11693 .de bbb
11694 .  bar
11695 ..
11696 .de ccc
11697 \\*[foo]\\
11698 ..
11699 .de ddd
11700 \\*[bar]\\
11701 ..
11702 .
11703 @endExample
11704 @Example
11705 .aaa
11706     @result{} foo
11707 .bbb
11708     @result{} bar
11709 .ccc
11710     @result{} ccc
11711 .ddd
11712     @result{} ddd
11713 @endExample
11714 @endDefesc
11715
11716 @xref{Request and Macro Arguments}.
11717
11718
11719 @c =====================================================================
11720
11721 @node Page Motions, Drawing Requests, Writing Macros, gtroff Reference
11722 @section Page Motions
11723 @cindex page motions
11724 @cindex motions, page
11725
11726 @xref{Manipulating Spacing}, for a discussion of the main request for
11727 vertical motion, @code{sp}.
11728
11729 @DefreqList {mk, [@Var{reg}]}
11730 @DefreqListEndx {rt, [@Var{dist}]}
11731 @cindex marking vertical page location (@code{mk})
11732 @cindex page location, vertical, marking (@code{mk})
11733 @cindex location, vertical, page, marking (@code{mk})
11734 @cindex vertical page location, marking (@code{mk})
11735 @cindex returning to marked vertical page location (@code{rt})
11736 @cindex page location, vertical, returning to marked (@code{rt})
11737 @cindex location, vertical, page, returning to marked (@code{rt})
11738 @cindex vertical page location, returning to marked (@code{rt})
11739 The request @code{mk} can be used to mark a location on a page, for
11740 movement to later.  This request takes a register name as an argument in
11741 which to store the current page location.  With no argument it stores
11742 the location in an internal register.  The results of this can be used
11743 later by the @code{rt} or the @code{sp} request (or the @code{\v}
11744 escape).
11745
11746 The @code{rt} request returns @emph{upwards} to the location marked with
11747 the last @code{mk} request.  If used with an argument, return to a
11748 position which distance from the top of the page is @var{dist} (no
11749 previous call to @code{mk} is necessary in this case).  Default scaling
11750 indicator is @samp{v}.
11751
11752 Here a primitive solution for a two-column macro.
11753
11754 @Example
11755 .nr column-length 1.5i
11756 .nr column-gap 4m
11757 .nr bottom-margin 1m
11758 .
11759 @endExample
11760 @Example
11761 .de 2c
11762 .  br
11763 .  mk
11764 .  ll \\n[column-length]u
11765 .  wh -\\n[bottom-margin]u 2c-trap
11766 .  nr right-side 0
11767 ..
11768 .
11769 @endExample
11770 @Example
11771 .de 2c-trap
11772 .  ie \\n[right-side] \@{\
11773 .    nr right-side 0
11774 .    po -(\\n[column-length]u + \\n[column-gap]u)
11775 .    \" remove trap
11776 .    wh -\\n[bottom-margin]u
11777 .  \@}
11778 .  el \@{\
11779 .    \" switch to right side
11780 .    nr right-side 1
11781 .    po +(\\n[column-length]u + \\n[column-gap]u)
11782 .    rt
11783 .  \@}
11784 ..
11785 .
11786 @endExample
11787 @Example
11788 .pl 1.5i
11789 .ll 4i
11790 This is a small test that shows how the
11791 rt request works in combination with mk.
11792
11793 .2c
11794 Starting here, text is typeset in two columns.
11795 Note that this implementation isn't robust
11796 and thus not suited for a real two-column
11797 macro.
11798 @endExample
11799
11800 Result:
11801
11802 @Example
11803 This is a small test that shows how the
11804 rt request works in combination with mk.
11805
11806 Starting  here,    isn't    robust
11807 text is typeset    and   thus  not
11808 in two columns.    suited  for   a
11809 Note that  this    real two-column
11810 implementation     macro.
11811 @endExample
11812 @endDefreq
11813
11814 The following escapes give fine control of movements about the page.
11815
11816 @Defesc {\\v, ', e, '}
11817 @cindex vertical motion (@code{\v})
11818 @cindex motion, vertical (@code{\v})
11819 Move vertically, usually from the current location on the page (if no
11820 absolute position operator @samp{|} is used).  The argument@tie{}@var{e}
11821 specifies the distance to move; positive is downwards and negative
11822 upwards.  The default scaling indicator for this escape is @samp{v}.
11823 Beware, however, that @code{gtroff} continues text processing at the
11824 point where the motion ends, so you should always balance motions to
11825 avoid interference with text processing.
11826
11827 @code{\v} doesn't trigger a trap.  This can be quite useful; for
11828 example, consider a page bottom trap macro that prints a marker in the
11829 margin to indicate continuation of a footnote or something similar.
11830 @endDefesc
11831
11832 There are some special-case escapes for vertical motion.
11833
11834 @Defesc {\\r, , , }
11835 Move upwards@tie{}1@dmn{v}.
11836 @endDefesc
11837
11838 @Defesc {\\u, , , }
11839 Move upwards@tie{}.5@dmn{v}.
11840 @endDefesc
11841
11842 @Defesc {\\d, , , }
11843 Move down@tie{}.5@dmn{v}.
11844 @endDefesc
11845
11846 @Defesc {\\h, ', e, '}
11847 @cindex inserting horizontal space (@code{\h})
11848 @cindex horizontal space (@code{\h})
11849 @cindex space, horizontal (@code{\h})
11850 @cindex horizontal motion (@code{\h})
11851 @cindex motion, horizontal (@code{\h})
11852 Move horizontally, usually from the current location (if no absolute
11853 position operator @samp{|} is used).  The expression@tie{}@var{e}
11854 indicates how far to move: positive is rightwards and negative
11855 leftwards.  The default scaling indicator for this escape is @samp{m}.
11856
11857 This horizontal space is not discarded at the end of a line.  To insert
11858 discardable space of a certain length use the @code{ss} request.
11859 @endDefesc
11860
11861 There are a number of special-case escapes for horizontal motion.
11862
11863 @Defesc {\\@key{SP}, , , }
11864 @cindex space, unbreakable
11865 @cindex unbreakable space
11866 An unbreakable and unpaddable (i.e.@: not expanded during filling)
11867 space.  (Note: This is a backslash followed by a space.)
11868 @endDefesc
11869
11870 @Defesc {\\~, , , }
11871 An unbreakable space that stretches like a normal inter-word space when
11872 a line is adjusted.
11873 @endDefesc
11874
11875 @Defesc {\\|, , , }
11876 A 1/6@dmn{th} em space.  Ignored for TTY output devices (rounded to
11877 zero).
11878
11879 However, if there is a glyph defined in the current font file with name
11880 @code{\|} (note the leading backslash), the width of this glyph is used
11881 instead (even for TTYs).
11882 @endDefesc
11883
11884 @Defesc {\\^, , , }
11885 A 1/12@dmn{th} em space.  Ignored for TTY output devices (rounded to
11886 zero).
11887
11888 However, if there is a glyph defined in the current font file with name
11889 @code{\^} (note the leading backslash), the width of this glyph is used
11890 instead (even for TTYs).
11891 @endDefesc
11892
11893 @Defesc {\\0, , , }
11894 @cindex space, width of a digit (@code{\0})
11895 @cindex digit width space (@code{\0})
11896 A space the size of a digit.
11897 @endDefesc
11898
11899 The following string sets the @TeX{} logo:
11900
11901 @Example
11902 .ds TeX T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
11903 @endExample
11904
11905 @DefescList {\\w, ', text, '}
11906 @DefregItemx {st}
11907 @DefregItemx {sb}
11908 @DefregItemx {rst}
11909 @DefregItemx {rsb}
11910 @DefregItemx {ct}
11911 @DefregItemx {ssc}
11912 @DefregListEndx {skw}
11913 @cindex width escape (@code{\w})
11914 Return the width of the specified @var{text} in basic units.  This
11915 allows horizontal movement based on the width of some arbitrary text
11916 (e.g.@: given as an argument to a macro).
11917
11918 @Example
11919 The length of the string `abc' is \w'abc'u.
11920     @result{} The length of the string `abc' is 72u.
11921 @endExample
11922
11923 Font changes may occur in @var{text}, which don't affect current
11924 settings.
11925
11926 After use, @code{\w} sets several registers:
11927
11928 @table @code
11929 @item st
11930 @itemx sb
11931 The highest and lowest point of the baseline, respectively, in
11932 @var{text}.
11933
11934 @item rst
11935 @itemx rsb
11936 Like the @code{st} and @code{sb} registers, but takes account of the
11937 heights and depths of glyphs.  In other words, this gives the highest
11938 and lowest point of @var{text}.  Values below the baseline are negative.
11939
11940 @item ct
11941 Defines the kinds of glyphs occurring in @var{text}:
11942
11943 @table @asis
11944 @item 0
11945 only short glyphs, no descenders or tall glyphs.
11946
11947 @item 1
11948 at least one descender.
11949
11950 @item 2
11951 at least one tall glyph.
11952
11953 @item 3
11954 at least one each of a descender and a tall glyph.
11955 @end table
11956
11957 @item ssc
11958 The amount of horizontal space (possibly negative) that should be added
11959 to the last glyph before a subscript.
11960
11961 @item skw
11962 How far to right of the center of the last glyph in the @code{\w}
11963 argument, the center of an accent from a roman font should be placed
11964 over that glyph.
11965 @end table
11966 @endDefesc
11967
11968 @DefescList {\\k, , p, }
11969 @DefescItem {\\k, @Lparen{}, ps, }
11970 @DefescListEnd {\\k, @Lbrack{}, position, @Rbrack{}}
11971 @cindex saving horizontal input line position (@code{\k})
11972 @cindex horizontal input line position, saving (@code{\k})
11973 @cindex input line position, horizontal, saving (@code{\k})
11974 @cindex position, horizontal input line, saving (@code{\k})
11975 @cindex line, input, horizontal position, saving (@code{\k})
11976 Store the current horizontal position in the @emph{input} line in number
11977 register with name @var{position} (one-character name@tie{}@var{p},
11978 two-character name @var{ps}).  Use this, for example, to return to the
11979 beginning of a string for highlighting or other decoration.
11980 @endDefesc
11981
11982 @Defreg {hp}
11983 @cindex horizontal input line position register (@code{hp})
11984 @cindex input line, horizontal position, register (@code{hp})
11985 @cindex position, horizontal, in input line, register (@code{hp})
11986 @cindex line, input, horizontal position, register (@code{hp})
11987 The current horizontal position at the input line.
11988 @endDefreg
11989
11990 @Defreg {.k}
11991 @cindex horizontal output line position register (@code{.k})
11992 @cindex output line, horizontal position, register (@code{.k})
11993 @cindex position, horizontal, in output line, register (@code{.k})
11994 @cindex line, output, horizontal position, register (@code{.k})
11995 A read-only number register containing the current horizontal output
11996 position (relative to the current indentation).
11997 @endDefreg
11998
11999 @Defesc {\\o, ', abc, '}
12000 @cindex overstriking glyphs (@code{\o})
12001 @cindex glyphs, overstriking (@code{\o})
12002 Overstrike glyphs @var{a}, @var{b}, @var{c}, @dots{}; the glyphs are
12003 centered, and the resulting spacing is the largest width of the affected
12004 glyphs.
12005 @endDefesc
12006
12007 @Defesc {\\z, , g, }
12008 @cindex zero-width printing (@code{\z}, @code{\Z})
12009 @cindex printing, zero-width (@code{\z}, @code{\Z})
12010 Print glyph @var{g} with zero width, i.e., without spacing.  Use this to
12011 overstrike glyphs left-aligned.
12012 @endDefesc
12013
12014 @Defesc {\\Z, ', anything, '}
12015 @cindex zero-width printing (@code{\z}, @code{\Z})
12016 @cindex printing, zero-width (@code{\z}, @code{\Z})
12017 Print @var{anything}, then restore the horizontal and vertical position.
12018 The argument may not contain tabs or leaders.
12019
12020 The following is an example of a strike-through macro:
12021
12022 @Example
12023 .de ST
12024 .nr ww \w'\\$1'
12025 \Z@@\v'-.25m'\l'\\n[ww]u'@@\\$1
12026 ..
12027 .
12028 This is
12029 .ST "a test"
12030 an actual emergency!
12031 @endExample
12032 @endDefesc
12033
12034
12035 @c =====================================================================
12036
12037 @node Drawing Requests, Traps, Page Motions, gtroff Reference
12038 @section Drawing Requests
12039 @cindex drawing requests
12040 @cindex requests for drawing
12041
12042 @code{gtroff} provides a number of ways to draw lines and other figures
12043 on the page.  Used in combination with the page motion commands (see
12044 @ref{Page Motions}, for more info), a wide variety of figures can be
12045 drawn.  However, for complex drawings these operations can be quite
12046 cumbersome, and it may be wise to use graphic preprocessors like
12047 @code{gpic} or @code{ggrn}.  @xref{gpic}, and @ref{ggrn}, for more
12048 information.
12049
12050 All drawing is done via escapes.
12051
12052 @DefescList {\\l, ', l, '}
12053 @DefescListEnd {\\l, ', lg, '}
12054 @cindex drawing horizontal lines (@code{\l})
12055 @cindex horizontal line, drawing (@code{\l})
12056 @cindex line, horizontal, drawing (@code{\l})
12057 Draw a line horizontally.  @var{l} is the length of the line to be
12058 drawn.  If it is positive, start the line at the current location and
12059 draw to the right; its end point is the new current location.  Negative
12060 values are handled differently: The line starts at the current location
12061 and draws to the left, but the current location doesn't move.
12062
12063 @var{l} can also be specified absolutely (i.e.@: with a leading
12064 @samp{|}), which draws back to the beginning of the input line.  Default
12065 scaling indicator is @samp{m}.
12066
12067 @cindex underscore glyph (@code{\[ru]})
12068 @cindex glyph, underscore (@code{\[ru]})
12069 @cindex line drawing glyph
12070 @cindex glyph, for line drawing
12071 The optional second parameter@tie{}@var{g} is a glyph to draw the line
12072 with.  If this second argument is not specified, @code{gtroff} uses the
12073 underscore glyph, @code{\[ru]}.
12074
12075 @cindex zero width space character (@code{\&})
12076 @cindex character, zero width space (@code{\&})
12077 @cindex space character, zero width (@code{\&})
12078 To separate the two arguments (to prevent @code{gtroff} from
12079 interpreting a drawing glyph as a scaling indicator if the glyph is
12080 represented by a single character) use @code{\&}.
12081
12082 Here a small useful example:
12083
12084 @Example
12085 .de box
12086 \[br]\\$*\[br]\l'|0\[rn]'\l'|0\[ul]'
12087 ..
12088 @endExample
12089
12090 @noindent
12091 Note that this works by outputting a box rule (a vertical line), then
12092 the text given as an argument and then another box rule.  Finally, the
12093 line drawing escapes both draw from the current location to the
12094 beginning of the @emph{input} line -- this works because the line length
12095 is negative, not moving the current point.
12096 @endDefesc
12097
12098 @DefescList {\\L, ', l, '}
12099 @DefescListEnd {\\L, ', lg, '}
12100 @cindex drawing vertical lines (@code{\L})
12101 @cindex vertical line drawing (@code{\L})
12102 @cindex line, vertical, drawing (@code{\L})
12103 @cindex line drawing glyph
12104 @cindex glyph for line drawing
12105 @cindex box rule glyph (@code{\[br]})
12106 @cindex glyph, box rule (@code{\[br]})
12107 Draw vertical lines.  Its parameters are similar to the @code{\l}
12108 escape, except that the default scaling indicator is @samp{v}.  The
12109 movement is downwards for positive values, and upwards for negative
12110 values.  The default glyph is the box rule glyph, @code{\[br]}.  As with
12111 the vertical motion escapes, text processing blindly continues where the
12112 line ends.
12113
12114 @Example
12115 This is a \L'3v'test.
12116 @endExample
12117
12118 @noindent
12119 Here the result, produced with @code{grotty}.
12120
12121 @Example
12122 This is a
12123           |
12124           |
12125           |test.
12126 @endExample
12127 @endDefesc
12128
12129 @Defesc {\\D, ', command arg @dots{}, '}
12130 The @code{\D} escape provides a variety of drawing functions.  Note that
12131 on character devices, only vertical and horizontal lines are supported
12132 within @code{grotty}; other devices may only support a subset of the
12133 available drawing functions.
12134
12135 The default scaling indicator for all subcommands of @code{\D} is
12136 @samp{m} for horizontal distances and @samp{v} for vertical ones.
12137 Exceptions are @w{@code{\D'f @dots{}'}} and @w{@code{\D't @dots{}'}},
12138 which use @code{u} as the default, and @w{@code{\D'F@var{x} @dots{}'}},
12139 which arguments are treated similar to the @code{defcolor} request.
12140
12141 @table @code
12142 @item \D'l @var{dx} @var{dy}'
12143 @cindex line, drawing (@w{@code{\D'l @dots{}'}})
12144 @cindex drawing a line (@w{@code{\D'l @dots{}'}})
12145 Draw a line from the current location to the relative point specified by
12146 (@var{dx},@var{dy}), where positive values mean down and right,
12147 respectively.  The end point of the line is the new current location.
12148
12149 The following example is a macro for creating a box around a text
12150 string; for simplicity, the box margin is taken as a fixed value,
12151 0.2@dmn{m}.
12152
12153 @Example
12154 .de BOX
12155 .  nr @@wd \w'\\$1'
12156 \h'.2m'\
12157 \h'-.2m'\v'(.2m - \\n[rsb]u)'\
12158 \D'l 0 -(\\n[rst]u - \\n[rsb]u + .4m)'\
12159 \D'l (\\n[@@wd]u + .4m) 0'\
12160 \D'l 0 (\\n[rst]u - \\n[rsb]u + .4m)'\
12161 \D'l -(\\n[@@wd]u + .4m) 0'\
12162 \h'.2m'\v'-(.2m - \\n[rsb]u)'\
12163 \\$1\
12164 \h'.2m'
12165 ..
12166 @endExample
12167
12168 @noindent
12169 First, the width of the string is stored in register @code{@@wd}.  Then,
12170 four lines are drawn to form a box, properly offset by the box margin.
12171 The registers @code{rst} and @code{rsb} are set by the @code{\w} escape,
12172 containing the largest height and depth of the whole string.
12173
12174 @item \D'c @var{d}'
12175 @cindex circle, drawing (@w{@code{\D'c @dots{}'}})
12176 @cindex drawing a circle (@w{@code{\D'c @dots{}'}})
12177 Draw a circle with a diameter of@tie{}@var{d} with the leftmost point at
12178 the current position.  After drawing, the current location is positioned
12179 at the rightmost point of the circle.
12180
12181 @item \D'C @var{d}'
12182 @cindex circle, solid, drawing (@w{@code{\D'C @dots{}'}})
12183 @cindex drawing a solid circle (@w{@code{\D'C @dots{}'}})
12184 @cindex solid circle, drawing (@w{@code{\D'C @dots{}'}})
12185 Draw a solid circle with the same parameters and behaviour as an
12186 outlined circle.  No outline is drawn.
12187
12188 @item \D'e @var{x} @var{y}'
12189 @cindex drawing an ellipse (@w{@code{\D'e @dots{}'}})
12190 @cindex ellipse, drawing (@w{@code{\D'e @dots{}'}})
12191 Draw an ellipse with a horizontal diameter of @var{x} and a vertical
12192 diameter of @var{y} with the leftmost point at the current position.
12193 After drawing, the current location is positioned at the rightmost point
12194 of the ellipse.
12195
12196 @item \D'E @var{x} @var{y}'
12197 @cindex ellipse, solid, drawing (@w{@code{\D'E @dots{}'}})
12198 @cindex drawing a solid ellipse (@w{@code{\D'E @dots{}'}})
12199 @cindex solid ellipse, drawing (@w{@code{\D'E @dots{}'}})
12200 Draw a solid ellipse with the same parameters and behaviour as an
12201 outlined ellipse.  No outline is drawn.
12202
12203 @item \D'a @var{dx1} @var{dy1} @var{dx2} @var{dy2}'
12204 @cindex arc, drawing (@w{@code{\D'a @dots{}'}})
12205 @cindex drawing an arc (@w{@code{\D'a @dots{}'}})
12206 Draw an arc clockwise from the current location through the two
12207 specified relative locations (@var{dx1},@var{dy1}) and
12208 (@var{dx2},@var{dy2}).  The coordinates of the first point are relative
12209 to the current position, and the coordinates of the second point are
12210 relative to the first point.  After drawing, the current position is
12211 moved to the final point of the arc.
12212
12213 @item \D'~ @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
12214 @cindex drawing a spline (@w{@code{\D'~ @dots{}'}})
12215 @cindex spline, drawing (@w{@code{\D'~ @dots{}'}})
12216 Draw a spline from the current location to the relative point
12217 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}), and so on.  The
12218 current position is moved to the terminal point of the drawn curve.
12219
12220 @item \D'f @var{n}'
12221 @cindex gray shading (@w{@code{\D'f @dots{}'}})
12222 @cindex shading filled objects (@w{@code{\D'f @dots{}'}})
12223 Set the shade of gray to be used for filling solid objects
12224 to@tie{}@var{n}; @var{n}@tie{}must be an integer between 0
12225 and@tie{}1000, where 0 corresponds solid white and 1000 to solid black,
12226 and values in between correspond to intermediate shades of gray.  This
12227 applies only to solid circles, solid ellipses, and solid polygons.  By
12228 default, a level of 1000 is used.
12229
12230 Despite of being silly, the current point is moved horizontally to the
12231 right by@tie{}@var{n}.
12232
12233 @cindex @w{@code{\D'f @dots{}'}} and horizontal resolution
12234 Don't use this command!  It has the serious drawback that it is always
12235 rounded to the next integer multiple of the horizontal resolution (the
12236 value of the @code{hor} keyword in the @file{DESC} file).  Use @code{\M}
12237 (@pxref{Colors}) or @w{@code{\D'Fg @dots{}'}} instead.
12238
12239 @item \D'p @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
12240 @cindex drawing a polygon (@w{@code{\D'p @dots{}'}})
12241 @cindex polygon, drawing (@w{@code{\D'p @dots{}'}})
12242 Draw a polygon from the current location to the relative position
12243 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}) and so on.  When
12244 the specified data points are exhausted, a line is drawn back to the
12245 starting point.  The current position is changed by adding the sum of
12246 all arguments with odd index to the actual horizontal position and the
12247 even ones to the vertical position.
12248
12249 @item \D'P @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
12250 @cindex polygon, solid, drawing (@w{@code{\D'P @dots{}'}})
12251 @cindex drawing a solid polygon (@w{@code{\D'P @dots{}'}})
12252 @cindex solid polygon, drawing (@w{@code{\D'P @dots{}'}})
12253 Draw a solid polygon with the same parameters and behaviour as an
12254 outlined polygon.  No outline is drawn.
12255
12256 Here a better variant of the box macro to fill the box with some color.
12257 Note that the box must be drawn before the text since colors in
12258 @code{gtroff} are not transparent; the filled polygon would hide the
12259 text completely.
12260
12261 @Example
12262 .de BOX
12263 .  nr @@wd \w'\\$1'
12264 \h'.2m'\
12265 \h'-.2m'\v'(.2m - \\n[rsb]u)'\
12266 \M[lightcyan]\
12267 \D'P 0 -(\\n[rst]u - \\n[rsb]u + .4m) \
12268      (\\n[@@wd]u + .4m) 0 \
12269      0 (\\n[rst]u - \\n[rsb]u + .4m) \
12270      -(\\n[@@wd]u + .4m) 0'\
12271 \h'.2m'\v'-(.2m - \\n[rsb]u)'\
12272 \M[]\
12273 \\$1\
12274 \h'.2m'
12275 ..
12276 @endExample
12277
12278 If you want a filled polygon that has exactly the same size as an
12279 unfilled one, you must draw both an unfilled and a filled polygon.  A
12280 filled polygon is always smaller than an unfilled one because the latter
12281 uses straight lines with a given line thickness to connect the polygon's
12282 corners, while the former simply fills the area defined by the
12283 coordinates.
12284
12285 @Example
12286 \h'1i'\v'1i'\
12287 \# increase line thickness
12288 \Z'\D't 5p''\
12289 \# draw unfilled polygon
12290 \Z'\D'p 3 3 -6 0''\
12291 \# draw filled polygon
12292 \Z'\D'P 3 3 -6 0''
12293 @endExample
12294
12295 @item \D't @var{n}'
12296 @cindex line thickness (@w{@code{\D't @dots{}'}})
12297 @cindex thickness of lines (@w{@code{\D't @dots{}'}})
12298 Set the current line thickness to @var{n}@tie{}machine units.  A value
12299 of zero selects the smallest available line thickness.  A negative value
12300 makes the line thickness proportional to the current point size (this is
12301 the default behaviour of @acronym{AT&T} @code{troff}).
12302
12303 Despite of being silly, the current point is moved horizontally to the
12304 right by@tie{}@var{n}.
12305
12306 @item \D'F@var{scheme} @var{color_components}'
12307 @cindex unnamed fill colors (@code{\D'F@dots{}'})
12308 @cindex fill colors, unnamed (@code{\D'F@dots{}'})
12309 @cindex colors, fill, unnamed (@code{\D'F@dots{}'})
12310 Change current fill color.  @var{scheme} is a single letter denoting the
12311 color scheme: @samp{r} (rgb), @samp{c} (cmy), @samp{k} (cmyk), @samp{g}
12312 (gray), or @samp{d} (default color).  The color components use exactly
12313 the same syntax as in the @code{defcolor} request (@pxref{Colors}); the
12314 command @code{\D'Fd'} doesn't take an argument.
12315
12316 @emph{No} position changing!
12317
12318 Examples:
12319
12320 @Example
12321 \D'Fg .3'      \" same gray as \D'f 700'
12322 \D'Fr #0000ff' \" blue
12323 @endExample
12324 @end table
12325 @endDefesc
12326
12327 @xref{Graphics Commands}.
12328
12329 @Defesc {\\b, ', string, '}
12330 @cindex pile, glyph (@code{\b})
12331 @cindex glyph pile (@code{\b})
12332 @cindex stacking glyphs (@code{\b})
12333 @dfn{Pile} a sequence of glyphs vertically, and center it vertically on
12334 the current line.  Use it to build large brackets and braces.
12335
12336 Here an example how to create a large opening brace:
12337
12338 @Example
12339 \b'\[lt]\[bv]\[lk]\[bv]\[lb]'
12340 @endExample
12341
12342 @cindex @code{\b}, limitations
12343 @cindex limitations of @code{\b} escape
12344 The first glyph is on the top, the last glyph in @var{string} is at the
12345 bottom.  Note that @code{gtroff} separates the glyphs vertically by
12346 1@dmn{m}, and the whole object is centered 0.5@dmn{m} above the current
12347 baseline; the largest glyph width is used as the width for the whole
12348 object.  This rather unflexible positioning algorithm doesn't work with
12349 @option{-Tdvi} since the bracket pieces vary in height for this device.
12350 Instead, use the @code{eqn} preprocessor.
12351
12352 @xref{Manipulating Spacing}, how to adjust the vertical spacing with the
12353 @code{\x} escape.
12354 @endDefesc
12355
12356
12357 @c =====================================================================
12358
12359 @node Traps, Diversions, Drawing Requests, gtroff Reference
12360 @section Traps
12361 @cindex traps
12362
12363 @dfn{Traps} are locations that, when reached, call a specified macro.
12364 These traps can occur at a given location on the page, at a given
12365 location in the current diversion, at a blank line, after a certain
12366 number of input lines, or at the end of input.
12367
12368 @cindex planting a trap
12369 @cindex trap, planting
12370 Setting a trap is also called @dfn{planting}.
12371 @cindex trap, springing
12372 @cindex springing a trap
12373 It is also said that a trap is @dfn{sprung} if the associated macro is
12374 executed.
12375
12376 @menu
12377 * Page Location Traps::
12378 * Diversion Traps::
12379 * Input Line Traps::
12380 * Blank Line Traps::
12381 * Leading Spaces Traps::
12382 * End-of-input Traps::
12383 @end menu
12384
12385 @c ---------------------------------------------------------------------
12386
12387 @node Page Location Traps, Diversion Traps, Traps, Traps
12388 @subsection Page Location Traps
12389 @cindex page location traps
12390 @cindex traps, page location
12391
12392 @dfn{Page location traps} perform an action when @code{gtroff} reaches
12393 or passes a certain vertical location on the page.  Page location traps
12394 have a variety of purposes, including:
12395
12396 @itemize
12397 @item
12398 setting headers and footers
12399
12400 @item
12401 setting body text in multiple columns
12402
12403 @item
12404 setting footnotes
12405 @end itemize
12406
12407 @DefreqList {vpt, flag}
12408 @DefregListEndx {.vpt}
12409 @cindex enabling vertical position traps (@code{vpt})
12410 @cindex vertical position traps, enabling (@code{vpt})
12411 @cindex vertical position trap enable register (@code{.vpt})
12412 Enable vertical position traps if @var{flag} is non-zero, or disables
12413 them otherwise.  Vertical position traps are traps set by the @code{wh}
12414 or @code{dt} requests.  Traps set by the @code{it} request are not
12415 vertical position traps.  The parameter that controls whether vertical
12416 position traps are enabled is global.  Initially vertical position traps
12417 are enabled.  The current setting of this is available in the
12418 @code{.vpt} read-only number register.
12419
12420 Note that a page can't be ejected if @code{vpt} is set to zero.
12421 @endDefreq
12422
12423 @Defreq {wh, dist [@Var{macro}]}
12424 Set a page location trap.  Non-negative values for @var{dist} set the
12425 trap relative to the top of the page; negative values set the trap
12426 relative to the bottom of the page.  Default scaling indicator is
12427 @samp{v}; values of @var{dist} are always rounded to be multiples of the
12428 vertical resolution (as given in register @code{.V}).
12429
12430 @var{macro} is the name of the macro to execute when the trap is sprung.
12431 If @var{macro} is missing, remove the first trap (if any) at @var{dist}.
12432
12433 @cindex page headers
12434 @cindex page footers
12435 @cindex headers
12436 @cindex footers
12437 The following is a simple example of how many macro packages set headers
12438 and footers.
12439
12440 @Example
12441 .de hd                \" Page header
12442 '  sp .5i
12443 .  tl 'Title''date'
12444 '  sp .3i
12445 ..
12446 .
12447 .de fo                \" Page footer
12448 '  sp 1v
12449 .  tl ''%''
12450 '  bp
12451 ..
12452 .
12453 .wh 0   hd            \" trap at top of the page
12454 .wh -1i fo            \" trap one inch from bottom
12455 @endExample
12456
12457 A trap at or below the bottom of the page is ignored; it can be made
12458 active by either moving it up or increasing the page length so that the
12459 trap is on the page.
12460
12461 Negative trap values always use the @emph{current} page length; they are
12462 not converted to an absolute vertical position:
12463
12464 @Example
12465 .pl 5i
12466 .wh -1i xx
12467 .ptr
12468     @result{} xx      -240
12469 .pl 100i
12470 .ptr
12471     @result{} xx      -240
12472 @endExample
12473
12474 It is possible to have more than one trap at the same location; to do
12475 so, the traps must be defined at different locations, then moved
12476 together with the @code{ch} request; otherwise the second trap would
12477 replace the first one.  Earlier defined traps hide later defined traps
12478 if moved to the same position (the many empty lines caused by the
12479 @code{bp} request are omitted in the following example):
12480
12481 @Example
12482 .de a
12483 .  nop a
12484 ..
12485 .de b
12486 .  nop b
12487 ..
12488 .de c
12489 .  nop c
12490 ..
12491 .
12492 .wh 1i a
12493 .wh 2i b
12494 .wh 3i c
12495 .bp
12496     @result{} a b c
12497 @endExample
12498 @Example
12499 .ch b 1i
12500 .ch c 1i
12501 .bp
12502     @result{} a
12503 @endExample
12504 @Example
12505 .ch a 0.5i
12506 .bp
12507     @result{} a b
12508 @endExample
12509 @endDefreq
12510
12511 @Defreg {.t}
12512 @cindex distance to next trap register (@code{.t})
12513 @cindex trap, distance, register (@code{.t})
12514 A read-only number register holding the distance to the next trap.
12515
12516 If there are no traps between the current position and the bottom of the
12517 page, it contains the distance to the page bottom.  In a diversion, the
12518 distance to the page bottom is infinite (the returned value is the
12519 biggest integer that can be represented in @code{groff}) if there are
12520 no diversion traps.
12521 @endDefreg
12522
12523 @Defreq {ch, macro [@Var{dist}]}
12524 @cindex changing trap location (@code{ch})
12525 @cindex trap, changing location (@code{ch})
12526 Change the location of a trap.  The first argument is the name of the
12527 macro to be invoked at the trap, and the second argument is the new
12528 location for the trap (note that the parameters are specified in
12529 opposite order as in the @code{wh} request).  This is useful for
12530 building up footnotes in a diversion to allow more space at the bottom
12531 of the page for them.
12532
12533 Default scaling indicator for @var{dist} is @samp{v}.  If @var{dist} is
12534 missing, the trap is removed.
12535
12536 @c XXX
12537
12538 @ignore
12539 @Example
12540 ... (simplified) footnote example ...
12541 @endExample
12542 @end ignore
12543 @endDefreq
12544
12545 @Defreg {.ne}
12546 The read-only number register @code{.ne} contains the amount of space
12547 that was needed in the last @code{ne} request that caused a trap to be
12548 sprung.  Useful in conjunction with the @code{.trunc} register.
12549 @xref{Page Control}, for more information.
12550
12551 Since the @code{.ne} register is only set by traps it doesn't make much
12552 sense to use it outside of trap macros.
12553 @endDefreg
12554
12555 @Defreg {.trunc}
12556 @cindex @code{ne} request, and the @code{.trunc} register
12557 @cindex truncated vertical space register (@code{.trunc})
12558 A read-only register containing the amount of vertical space truncated
12559 by the most recently sprung vertical position trap, or, if the trap was
12560 sprung by an @code{ne} request, minus the amount of vertical motion
12561 produced by the @code{ne} request.  In other words, at the point a trap
12562 is sprung, it represents the difference of what the vertical position
12563 would have been but for the trap, and what the vertical position
12564 actually is.
12565
12566 Since the @code{.trunc} register is only set by traps it doesn't make
12567 much sense to use it outside of trap macros.
12568 @endDefreg
12569
12570 @Defreg {.pe}
12571 @cindex @code{bp} request, and traps (@code{.pe})
12572 @cindex traps, sprung by @code{bp} request (@code{.pe})
12573 @cindex page ejecting register (@code{.pe})
12574 A read-only register that is set to@tie{}1 while a page is ejected with
12575 the @code{bp} request (or by the end of input).
12576
12577 Outside of traps this register is always zero.  In the following
12578 example, only the second call to@tie{}@code{x} is caused by @code{bp}.
12579
12580 @Example
12581 .de x
12582 \&.pe=\\n[.pe]
12583 .br
12584 ..
12585 .wh 1v x
12586 .wh 4v x
12587 A line.
12588 .br
12589 Another line.
12590 .br
12591     @result{} A line.
12592        .pe=0
12593        Another line.
12594
12595        .pe=1
12596 @endExample
12597 @endDefreg
12598
12599 @cindex diversions, and traps
12600 @cindex traps, and diversions
12601 An important fact to consider while designing macros is that diversions
12602 and traps do not interact normally.  For example, if a trap invokes a
12603 header macro (while outputting a diversion) that tries to change the
12604 font on the current page, the effect is not visible before the diversion
12605 has completely been printed (except for input protected with @code{\!}
12606 or @code{\?}) since the data in the diversion is already formatted.  In
12607 most cases, this is not the expected behaviour.
12608
12609 @c ---------------------------------------------------------------------
12610
12611 @node Diversion Traps, Input Line Traps, Page Location Traps, Traps
12612 @subsection Diversion Traps
12613 @cindex diversion traps
12614 @cindex traps, diversion
12615
12616 @Defreq {dt, [@Var{dist} @Var{macro}]}
12617 @cindex @code{.t} register, and diversions
12618 @cindex setting diversion trap (@code{dt})
12619 @cindex diversion trap, setting (@code{dt})
12620 @cindex trap, diversion, setting (@code{dt})
12621 Set a trap @emph{within} a diversion.  @var{dist} is the location of the
12622 trap (identical to the @code{wh} request; default scaling indicator is
12623 @samp{v}) and @var{macro} is the name of the macro to be invoked.  If
12624 called without arguments, the diversion trap is removed.
12625
12626 Note that there exists only a single diversion trap.
12627
12628 The number register @code{.t} still works within diversions.
12629 @xref{Diversions}, for more information.
12630 @endDefreq
12631
12632 @c ---------------------------------------------------------------------
12633
12634 @node Input Line Traps, Blank Line Traps, Diversion Traps, Traps
12635 @subsection Input Line Traps
12636 @cindex input line traps
12637 @cindex traps, input line
12638
12639 @DefreqList {it, n macro}
12640 @DefreqListEndx {itc, n macro}
12641 @cindex setting input line trap (@code{it})
12642 @cindex input line trap, setting (@code{it})
12643 @cindex trap, input line, setting (@code{it})
12644 Set an input line trap.  @var{n}@tie{}is the number of lines of input
12645 that may be read before springing the trap, @var{macro} is the macro to
12646 be invoked.  Request lines are not counted as input lines.
12647
12648 For example, one possible use is to have a macro that prints the next
12649 @var{n}@tie{}lines in a bold font.
12650
12651 @Example
12652 .de B
12653 .  it \\$1 B-end
12654 .  ft B
12655 ..
12656 .
12657 .de B-end
12658 .  ft R
12659 ..
12660 @endExample
12661
12662 @cindex input line traps and interrupted lines (@code{itc})
12663 @cindex interrupted lines and input line traps (@code{itc})
12664 @cindex traps, input line, and interrupted lines (@code{itc})
12665 @cindex lines, interrupted, and input line traps (@code{itc})
12666 The @code{itc} request is identical except that an interrupted text line
12667 (ending with @code{\c}) is not counted as a separate line.
12668
12669 Both requests are associated with the current environment
12670 (@pxref{Environments}); switching to another environment disables the
12671 current input trap, and going back reactivates it, restoring the number
12672 of already processed lines.
12673 @endDefreq
12674
12675 @c ---------------------------------------------------------------------
12676
12677 @node Blank Line Traps, Leading Spaces Traps, Input Line Traps, Traps
12678 @subsection Blank Line Traps
12679 @cindex blank line traps
12680 @cindex traps, blank line
12681
12682 @Defreq {blm, macro}
12683 @cindex blank line macro (@code{blm})
12684 Set a blank line trap.  @code{gtroff} executes @var{macro} when it
12685 encounters a blank line in the input file.
12686 @endDefreq
12687
12688 @c ---------------------------------------------------------------------
12689
12690 @node Leading Spaces Traps, End-of-input Traps, Blank Line Traps, Traps
12691 @subsection Leading Spaces Traps
12692 @cindex leading spaces traps
12693 @cindex traps, leading spaces
12694
12695 @DefreqList {lsm, macro}
12696 @DefregItemx {lsn}
12697 @DefregListEndx {lss}
12698 @cindex leading spaces macro (@code{lsm})
12699 Set a leading spaces trap.  @code{gtroff} executes @var{macro} when it
12700 encounters leading spaces in an input line; the implicit line break
12701 that normally happens in this case is suppressed.  A line consisting
12702 of spaces only, however, is treated as an empty line, possibly subject
12703 to an empty line macro set with the @code{blm} request.
12704
12705 Leading spaces are removed from the input line before calling the
12706 leading spaces macro.  The number of removed spaces is stored in
12707 register @code{lsn}; the horizontal space that would be emitted if
12708 there was no leading space macro is stored in register @code{lss}.
12709 Note that @code{lsn} and @code{lss} are available even if no leading
12710 space macro has been set.
12711
12712 The first thing a leading space macro sees is a token.  However, some
12713 escapes like @code{\f} or @code{\m} are handled on the fly (see
12714 @ref{Gtroff Internals}, for a complete list) without creating a token
12715 at all.  Consider that a line starts with two spaces followed by
12716 @code{\fIfoo}.  While skipping the spaces @code{\fI} is handled too so
12717 that groff's current font is properly set to @samp{I}, but the leading
12718 space macro only sees @code{foo}, without the preceding @code{\fI}.
12719 If the macro should see the font escape you have to `protect' it with
12720 something that creates a token, for example with @code{\&\fIfoo}.
12721 @endDefreq
12722
12723 @c ---------------------------------------------------------------------
12724
12725 @node End-of-input Traps,  , Leading Spaces Traps, Traps
12726 @subsection End-of-input Traps
12727 @cindex end-of-input traps
12728 @cindex traps, end-of-input
12729
12730 @Defreq {em, macro}
12731 @cindex setting end-of-input trap (@code{em})
12732 @cindex end-of-input trap, setting (@code{em})
12733 @cindex trap, end-of-input, setting (@code{em})
12734 @cindex end-of-input macro (@code{em})
12735 @cindex macro, end-of-input (@code{em})
12736 Set a trap at the end of input.  @var{macro} is executed after the last
12737 line of the input file has been processed.
12738
12739 For example, if the document had to have a section at the bottom of the
12740 last page for someone to approve it, the @code{em} request could be
12741 used.
12742
12743 @Example
12744 .de approval
12745 \c
12746 .  ne 3v
12747 .  sp (\\n[.t]u - 3v)
12748 .  in +4i
12749 .  lc _
12750 .  br
12751 Approved:\t\a
12752 .  sp
12753 Date:\t\t\a
12754 ..
12755 .
12756 .em approval
12757 @endExample
12758
12759 The @code{\c} in the above example needs explanation.  For historical
12760 reasons (and for compatibility with @acronym{AT&T} @code{troff}), the
12761 end macro exits as soon as it causes a page break and no remaining
12762 data is in the partially collected line.
12763
12764 Let us assume that there is no @code{\c} in the above @code{approval}
12765 macro, and that the page is full and has been ended with, say, a
12766 @code{br} request.  The @code{ne} request now causes the start of a new
12767 page, which in turn makes @code{troff} exit immediately for the reasons
12768 just described.  In most situations this is not intended.
12769
12770 To always force processing the whole end macro independently of this
12771 behaviour it is thus advisable to insert something that starts an
12772 empty partially filled line (@code{\c}) whenever there is a chance that
12773 a page break can happen.  In the above example, the call of the
12774 @code{ne} request assures that the remaining code stays on the same
12775 page, so we have to insert @code{\c} only once.
12776
12777 The next example shows how to append three lines, then starting a new
12778 page unconditionally.  Since @w{@samp{.ne 1}} doesn't give the desired
12779 effect -- there is always one line available or we are already at the
12780 beginning of the next page -- we temporarily increase the page length
12781 by one line so that we can use @w{@samp{.ne 2}}.
12782
12783 @Example
12784 .de EM
12785 .pl +1v
12786 \c
12787 .ne 2
12788 line one
12789 .br
12790 \c
12791 .ne 2
12792 line two
12793 .br
12794 \c
12795 .ne 2
12796 line three
12797 .br
12798 .pl -1v
12799 \c
12800 'bp
12801 ..
12802 .em EM
12803 @endExample
12804
12805 Note that this specific feature affects only the first potential page
12806 break caused by the end macro; further page breaks emitted by the end
12807 macro are handled normally.
12808
12809 Another possible use of the @code{em} request is to make @code{gtroff}
12810 emit a single large page instead of multiple pages.  For example, one
12811 may want to produce a long plain-text file for reading on-screen.  The
12812 idea is to set the page length at the beginning of the document to a
12813 very large value to hold all the text, and automatically adjust it to
12814 the exact height of the document after the text has been output.
12815
12816 @Example
12817 .de adjust-page-length
12818 .  br
12819 .  pl \\n[nl]u   \" \n[nl] holds the current page length
12820 ..
12821 .
12822 .de single-page-mode
12823 .  pl 99999
12824 .  em adjust-page-length
12825 ..
12826 .
12827 .\" activate the above code
12828 .single-page-mode
12829 @endExample
12830
12831 Since only one end-of-input trap does exist and other macro packages
12832 may already use it, care must be taken not to break the mechanism.  A
12833 simple solution would be to append the above macro to the macro
12834 package's end-of-input macro using the @code{.am} request.
12835 @endDefreq
12836
12837
12838 @c =====================================================================
12839
12840 @node Diversions, Environments, Traps, gtroff Reference
12841 @section Diversions
12842 @cindex diversions
12843
12844 In @code{gtroff} it is possible to @dfn{divert} text into a named
12845 storage area.  Due to the similarity to defining macros it is sometimes
12846 said to be stored in a macro.  This is used for saving text for output
12847 at a later time, which is useful for keeping blocks of text on the same
12848 page, footnotes, tables of contents, and indices.
12849
12850 @cindex top-level diversion
12851 @cindex diversion, top-level
12852 For orthogonality it is said that @code{gtroff} is in the @dfn{top-level
12853 diversion} if no diversion is active (i.e., the data is diverted to the
12854 output device).
12855
12856 Although the following requests can be used to create diversions,
12857 simply using an undefined diversion will cause it to be defined as empty.
12858 @xref{Identifiers}.
12859
12860 @DefreqList {di, macro}
12861 @DefreqListEndx {da, macro}
12862 @cindex beginning diversion (@code{di})
12863 @cindex diversion, beginning (@code{di})
12864 @cindex ending diversion (@code{di})
12865 @cindex diversion, ending (@code{di})
12866 @cindex appending to a diversion (@code{da})
12867 @cindex diversion, appending (@code{da})
12868 Begin a diversion.  Like the @code{de} request, it takes an argument of
12869 a macro name to divert subsequent text into.  The @code{da} macro
12870 appends to an existing diversion.
12871
12872 @code{di} or @code{da} without an argument ends the diversion.
12873
12874 The current partially-filled line is included into the diversion.  See
12875 the @code{box} request below for an example.  Note that switching to
12876 another (empty) environment (with the @code{ev} request) avoids the
12877 inclusion of the current partially-filled line.
12878 @endDefreq
12879
12880 @DefreqList {box, macro}
12881 @DefreqListEndx {boxa, macro}
12882 Begin (or append to) a diversion like the @code{di} and @code{da}
12883 requests.  The difference is that @code{box} and @code{boxa} do not
12884 include a partially-filled line in the diversion.
12885
12886 Compare this:
12887
12888 @Example
12889 Before the box.
12890 .box xxx
12891 In the box.
12892 .br
12893 .box
12894 After the box.
12895 .br
12896     @result{} Before the box.  After the box.
12897 .xxx
12898     @result{} In the box.
12899 @endExample
12900
12901 @noindent
12902 with this:
12903
12904 @Example
12905 Before the diversion.
12906 .di yyy
12907 In the diversion.
12908 .br
12909 .di
12910 After the diversion.
12911 .br
12912     @result{} After the diversion.
12913 .yyy
12914     @result{} Before the diversion.  In the diversion.
12915 @endExample
12916
12917 @code{box} or @code{boxa} without an argument ends the diversion.
12918 @endDefreq
12919
12920 @DefregList {.z}
12921 @DefregListEndx {.d}
12922 @cindex @code{nl} register, and @code{.d}
12923 @cindex nested diversions
12924 @cindex diversion, nested
12925 @cindex diversion name register (@code{.z})
12926 @cindex vertical position in diversion register (@code{.d})
12927 @cindex position, vertical, in diversion, register (@code{.d})
12928 @cindex diversion, vertical position in, register (@code{.d})
12929 Diversions may be nested.  The read-only number register @code{.z}
12930 contains the name of the current diversion (this is a string-valued
12931 register).  The read-only number register @code{.d} contains the current
12932 vertical place in the diversion.  If not in a diversion it is the same
12933 as register @code{nl}.
12934 @endDefreg
12935
12936 @Defreg {.h}
12937 @cindex high-water mark register (@code{.h})
12938 @cindex mark, high-water, register (@code{.h})
12939 @cindex position of lowest text line (@code{.h})
12940 @cindex text line, position of lowest (@code{.h})
12941 The @dfn{high-water mark} on the current page.  It corresponds to the
12942 text baseline of the lowest line on the page.  This is a read-only
12943 register.
12944
12945 @Example
12946 .tm .h==\n[.h], nl==\n[nl]
12947     @result{} .h==0, nl==-1
12948 This is a test.
12949 .br
12950 .sp 2
12951 .tm .h==\n[.h], nl==\n[nl]
12952     @result{} .h==40, nl==120
12953 @endExample
12954
12955 @cindex @code{.h} register, difference to @code{nl}
12956 @cindex @code{nl} register, difference to @code{.h}
12957 @noindent
12958 As can be seen in the previous example, empty lines are not considered
12959 in the return value of the @code{.h} register.
12960 @endDefreg
12961
12962 @DefregList {dn}
12963 @DefregListEndx {dl}
12964 @cindex @code{dn} register, and @code{da} (@code{boxa})
12965 @cindex @code{dl} register, and @code{da} (@code{boxa})
12966 @cindex @code{da} request, and @code{dn} (@code{dl})
12967 @cindex @code{boxa} request, and @code{dn} (@code{dl})
12968 After completing a diversion, the read-write number registers @code{dn}
12969 and @code{dl} contain the vertical and horizontal size of the diversion.
12970 Note that only the just processed lines are counted: For the computation
12971 of @code{dn} and @code{dl}, the requests @code{da} and @code{boxa} are
12972 handled as if @code{di} and @code{box} had been used -- lines that have
12973 been already stored in a macro are not taken into account.
12974
12975 @Example
12976 .\" Center text both horizontally & vertically
12977 .
12978 .\" Enclose macro definitions in .eo and .ec
12979 .\" to avoid the doubling of the backslash
12980 .eo
12981 .\" macro .(c starts centering mode
12982 .de (c
12983 .  br
12984 .  ev (c
12985 .  evc 0
12986 .  in 0
12987 .  nf
12988 .  di @@c
12989 ..
12990 @endExample
12991 @Example
12992 .\" macro .)c terminates centering mode
12993 .de )c
12994 .  br
12995 .  ev
12996 .  di
12997 .  nr @@s (((\n[.t]u - \n[dn]u) / 2u) - 1v)
12998 .  sp \n[@@s]u
12999 .  ce 1000
13000 .  @@c
13001 .  ce 0
13002 .  sp \n[@@s]u
13003 .  br
13004 .  fi
13005 .  rr @@s
13006 .  rm @@s
13007 .  rm @@c
13008 ..
13009 .\" End of macro definitions, restore escape mechanism
13010 .ec
13011 @endExample
13012 @endDefreg
13013
13014 @DefescList {\\!, , , }
13015 @DefescListEndx {\\?, , anything, \\?}
13016 @cindex transparent output (@code{\!}, @code{\?})
13017 @cindex output, transparent (@code{\!}, @code{\?})
13018 Prevent requests, macros, and escapes from being interpreted when read
13019 into a diversion.  Both escapes take the given text and
13020 @dfn{transparently} embed it into the diversion.  This is useful for
13021 macros that shouldn't be invoked until the diverted text is actually
13022 output.
13023
13024 The @code{\!} escape transparently embeds text up to and including the
13025 end of the line.  The @code{\?} escape transparently embeds text until
13026 the next occurrence of the @code{\?} escape.  Example:
13027
13028 @Example
13029 \?@var{anything}\?
13030 @endExample
13031
13032 @cindex @code{\?}, and copy-in mode
13033 @cindex copy-in mode, and @code{\?}
13034 @cindex mode, copy-in, and @code{\?}
13035 @cindex @code{\!}, and copy-in mode
13036 @cindex copy-in mode, and @code{\!}
13037 @cindex mode, copy-in, and @code{\!}
13038 @noindent
13039 @var{anything} may not contain newlines; use @code{\!}  to embed
13040 newlines in a diversion.  The escape sequence @code{\?} is also
13041 recognized in copy mode and turned into a single internal code; it is
13042 this code that terminates @var{anything}.  Thus the following example
13043 prints@tie{}4.
13044
13045 @Example
13046 .nr x 1
13047 .nf
13048 .di d
13049 \?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
13050 .di
13051 .nr x 2
13052 .di e
13053 .d
13054 .di
13055 .nr x 3
13056 .di f
13057 .e
13058 .di
13059 .nr x 4
13060 .f
13061 @endExample
13062
13063 Both escapes read the data in copy mode.
13064
13065 @cindex @code{\!}, in top-level diversion
13066 @cindex top-level diversion, and @code{\!}
13067 @cindex diversion, top-level, and @code{\!}
13068 If @code{\!} is used in the top-level diversion, its argument is
13069 directly embedded into the @code{gtroff} intermediate output.  This can
13070 be used for example to control a postprocessor that processes the data
13071 before it is sent to the device driver.
13072
13073 @cindex @code{\?}, in top-level diversion
13074 @cindex top-level diversion, and @code{\?}
13075 @cindex diversion, top-level, and @code{\?}
13076 The @code{\?} escape used in the top-level diversion produces no output
13077 at all; its argument is simply ignored.
13078 @endDefesc
13079
13080 @cindex @code{\!}, and @code{output} request
13081 @cindex @code{output} request, and @code{\!}
13082 @cindex @code{output} request, and copy-in mode
13083 @cindex copy-in mode, and @code{output} request
13084 @cindex mode, copy-in, and @code{output} request
13085 @Defreq {output, string}
13086 Emit @var{string} directly to the @code{gtroff} intermediate output
13087 (subject to copy mode interpretation); this is similar to @code{\!} used
13088 at the top level.  An initial double quote in @var{string} is stripped
13089 off to allow initial blanks.
13090
13091 This request can't be used before the first page has started -- if you
13092 get an error, simply insert @code{.br} before the @code{output} request.
13093
13094 Without argument, @code{output} is ignored.
13095
13096 Use with caution!  It is normally only needed for mark-up used by a
13097 postprocessor that does something with the output before sending it to
13098 the output device, filtering out @var{string} again.
13099 @endDefreq
13100
13101 @Defreq {asciify, div}
13102 @cindex unformatting diversions (@code{asciify})
13103 @cindex diversion, unformatting (@code{asciify})
13104 @cindex @code{trin} request, and @code{asciify}
13105 @dfn{Unformat} the diversion specified by @var{div} in such a way that
13106 @acronym{ASCII} characters, characters translated with the @code{trin}
13107 request, space characters, and some escape sequences that were formatted
13108 and diverted are treated like ordinary input characters when the
13109 diversion is reread.  It can be also used for gross hacks; for example,
13110 the following sets register@tie{}@code{n} to@tie{}1.
13111
13112 @Example
13113 .tr @@.
13114 .di x
13115 @@nr n 1
13116 .br
13117 .di
13118 .tr @@@@
13119 .asciify x
13120 .x
13121 @endExample
13122
13123 Note that @code{asciify} cannot return all items in a diversion back
13124 to their source equivalent, nodes such as @code{\N[...]} will still
13125 remain as nodes, so the result cannot be guaranteed to be a pure string.
13126
13127 @xref{Copy-in Mode}.
13128 @endDefreq
13129
13130 @Defreq {unformat, div}
13131 Like @code{asciify}, unformat the specified diversion.  However,
13132 @code{unformat} only unformats spaces and tabs between words.
13133 Unformatted tabs are treated as input tokens, and spaces are stretchable
13134 again.
13135
13136 The vertical size of lines is not preserved; glyph information (font,
13137 font size, space width, etc.)@: is retained.
13138 @endDefreq
13139
13140
13141 @c =====================================================================
13142
13143 @node Environments, Suppressing output, Diversions, gtroff Reference
13144 @section Environments
13145 @cindex environments
13146
13147 It happens frequently that some text should be printed in a certain
13148 format regardless of what may be in effect at the time, for example, in
13149 a trap invoked macro to print headers and footers.  To solve this
13150 @code{gtroff} processes text in @dfn{environments}.  An environment
13151 contains most of the parameters that control text processing.  It is
13152 possible to switch amongst these environments; by default @code{gtroff}
13153 processes text in environment@tie{}0.  The following is the information
13154 kept in an environment.
13155
13156 @itemize @bullet
13157 @item
13158 font parameters (size, family, style, glyph height and slant, space and
13159 sentence space size)
13160
13161 @item
13162 page parameters (line length, title length, vertical spacing, line
13163 spacing, indentation, line numbering, centering, right-justifying,
13164 underlining, hyphenation data)
13165
13166 @item
13167 fill and adjust mode
13168
13169 @item
13170 tab stops, tab and leader characters, escape character, no-break and
13171 hyphen indicators, margin character data
13172
13173 @item
13174 partially collected lines
13175
13176 @item
13177 input traps
13178
13179 @item
13180 drawing and fill colours
13181 @end itemize
13182
13183 These environments may be given arbitrary names (see @ref{Identifiers},
13184 for more info).  Old versions of @code{troff} only had environments
13185 named @samp{0}, @samp{1}, and @samp{2}.
13186
13187 @DefreqList {ev, [@Var{env}]}
13188 @DefregListEndx {.ev}
13189 @cindex switching environments (@code{ev})
13190 @cindex environment, switching (@code{ev})
13191 @cindex environment number/name register (@code{.ev})
13192 Switch to another environment.  The argument @var{env} is the name of
13193 the environment to switch to.  With no argument, @code{gtroff} switches
13194 back to the previous environment.  There is no limit on the number of
13195 named environments; they are created the first time that they are
13196 referenced.  The @code{.ev} read-only register contains the name or
13197 number of the current environment.  This is a string-valued register.
13198
13199 Note that a call to @code{ev} (with argument) pushes the previously
13200 active environment onto a stack.  If, say, environments @samp{foo},
13201 @samp{bar}, and @samp{zap} are called (in that order), the first
13202 @code{ev} request without parameter switches back to environment
13203 @samp{bar} (which is popped off the stack), and a second call switches
13204 back to environment @samp{foo}.
13205
13206 Here is an example:
13207
13208 @Example
13209 .ev footnote-env
13210 .fam N
13211 .ps 6
13212 .vs 8
13213 .ll -.5i
13214 .ev
13215
13216 ...
13217
13218 .ev footnote-env
13219 \(dg Note the large, friendly letters.
13220 .ev
13221 @endExample
13222 @endDefreq
13223
13224 @Defreq {evc, env}
13225 @cindex copying environment (@code{evc})
13226 @cindex environment, copying (@code{evc})
13227 Copy the environment @var{env} into the current environment.
13228
13229 The following environment data is not copied:
13230
13231 @itemize @bullet
13232 @item
13233 Partially filled lines.
13234
13235 @item
13236 The status whether the previous line was interrupted.
13237
13238 @item
13239 The number of lines still to center, or to right-justify, or to
13240 underline (with or without underlined spaces); they are set to zero.
13241
13242 @item
13243 The status whether a temporary indentation is active.
13244
13245 @item
13246 Input traps and its associated data.
13247
13248 @item
13249 Line numbering mode is disabled; it can be reactivated with @w{@samp{.nm
13250 +0}}.
13251
13252 @item
13253 The number of consecutive hyphenated lines (set to zero).
13254 @end itemize
13255 @endDefreq
13256
13257 @DefregList {.w}
13258 @DefregItemx {.cht}
13259 @DefregItemx {.cdp}
13260 @DefregListEndx {.csk}
13261 @cindex environment, dimensions of last glyph (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
13262 @cindex width, of last glyph (@code{.w})
13263 @cindex height, of last glyph (@code{.cht})
13264 @cindex depth, of last glyph (@code{.cdp})
13265 @cindex skew, of last glyph (@code{.csk})
13266 @cindex last glyph, dimensions (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
13267 @cindex glyph, last, dimensions (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
13268 The @code{\n[.w]} register contains the width of the last glyph added to
13269 the current environment.
13270
13271 The @code{\n[.cht]} register contains the height of the last glyph added
13272 to the current environment.
13273
13274 The @code{\n[.cdp]} register contains the depth of the last glyph added
13275 to the current environment.  It is positive for glyphs extending below
13276 the baseline.
13277
13278 The @code{\n[.csk]} register contains the @dfn{skew} (how far to the
13279 right of the glyph's center that @code{gtroff} should place an accent)
13280 of the last glyph added to the current environment.
13281 @endDefreg
13282
13283 @Defreg {.n}
13284 @cindex environment, previous line length (@code{.n})
13285 @cindex line length, previous (@code{.n})
13286 @cindex length of previous line (@code{.n})
13287 @cindex previous line length (@code{.n})
13288 The @code{\n[.n]} register contains the length of the previous output
13289 line in the current environment.
13290 @endDefreg
13291
13292
13293 @c =====================================================================
13294
13295 @node Suppressing output, Colors, Environments, gtroff Reference
13296 @section Suppressing output
13297
13298 @Defesc {\\O, , num, }
13299 @cindex suppressing output (@code{\O})
13300 @cindex output, suppressing (@code{\O})
13301 Disable or enable output depending on the value of @var{num}:
13302
13303 @table @samp
13304 @item \O0
13305 Disable any glyphs from being emitted to the device driver, provided
13306 that the escape occurs at the outer level (see @code{\O[3]} and
13307 @code{\O[4]}).  Motion is not suppressed so effectively @code{\O[0]}
13308 means @emph{pen up}.
13309
13310 @item \O1
13311 Enable output of glyphs, provided that the escape occurs at the outer
13312 level.
13313 @end table
13314
13315 @vindex opminx
13316 @vindex opminy
13317 @vindex opmaxx
13318 @vindex opmaxy
13319 @code{\O0} and @code{\O1} also reset the four registers @samp{opminx},
13320 @samp{opminy}, @samp{opmaxx}, and @samp{opmaxy} to @minus{}1.
13321 @xref{Register Index}.  These four registers mark the top left and
13322 bottom right hand corners of a box that encompasses all written glyphs.
13323
13324 For example the input text:
13325
13326 @Example
13327 Hello \O[0]world \O[1]this is a test.
13328 @endExample
13329
13330 @noindent
13331 produces the following output:
13332
13333 @Example
13334 Hello       this is a test.
13335 @endExample
13336
13337 @table @samp
13338 @item \O2
13339 Provided that the escape occurs at the outer level, enable output of
13340 glyphs and also write out to @code{stderr} the page number and four
13341 registers encompassing the glyphs previously written since the last call
13342 to @code{\O}.
13343
13344 @item \O3
13345 Begin a nesting level.  At start-up, @code{gtroff} is at outer level.
13346 The current level is contained within the read-only register @code{.O}.
13347 @xref{Built-in Registers}.
13348
13349 @item \O4
13350 End a nesting level.  The current level is contained within the
13351 read-only register @code{.O}.  @xref{Built-in Registers}.
13352
13353 @item \O[5@var{P}@var{filename}]
13354 This escape is @code{grohtml} specific.  Provided that this escape
13355 occurs at the outer nesting level write the @code{filename} to
13356 @code{stderr}.  The position of the image, @var{P}, must be specified
13357 and must be one of @code{l}, @code{r}, @code{c}, or@tie{}@code{i} (left,
13358 right, centered, inline).  @var{filename} is associated with the
13359 production of the next inline image.
13360 @end table
13361 @endDefesc
13362
13363
13364 @c =====================================================================
13365
13366 @node Colors, I/O, Suppressing output, gtroff Reference
13367 @section Colors
13368 @cindex colors
13369
13370 @DefreqList {color, [@Var{n}]}
13371 @DefregListEndx {.color}
13372 If @var{n} is missing or non-zero, activate colors (this is the
13373 default); otherwise, turn it off.
13374
13375 The read-only number register @code{.color} is@tie{}1 if colors are
13376 active, 0@tie{}otherwise.
13377
13378 Internally, @code{color} sets a global flag; it does not produce a
13379 token.  Similar to the @code{cp} request, you should use it at the
13380 beginning of your document to control color output.
13381
13382 Colors can be also turned off with the @option{-c} command line option.
13383 @endDefreq
13384
13385 @Defreq {defcolor, ident scheme color_components}
13386 Define color with name @var{ident}.  @var{scheme} can be one of the
13387 following values: @code{rgb} (three components), @code{cmy} (three
13388 components), @code{cmyk} (four components), and @code{gray} or
13389 @code{grey} (one component).
13390
13391 @cindex default color
13392 @cindex color, default
13393 Color components can be given either as a hexadecimal string or as
13394 positive decimal integers in the range 0--65535.  A hexadecimal string
13395 contains all color components concatenated.  It must start with either
13396 @code{#} or @code{##}; the former specifies hex values in the range
13397 0--255 (which are internally multiplied by@tie{}257), the latter in the
13398 range 0--65535.  Examples: @code{#FFC0CB} (pink), @code{##ffff0000ffff}
13399 (magenta).  The default color name @c{default} can't be redefined; its
13400 value is device-specific (usually black).  It is possible that the
13401 default color for @code{\m} and @code{\M} is not identical.
13402
13403 @cindex @code{f} unit, and colors
13404 @cindex unit, @code{f}, and colors
13405 A new scaling indicator@tie{}@code{f} has been introduced, which
13406 multiplies its value by 65536; this makes it convenient to specify color
13407 components as fractions in the range 0 to@tie{}1 (1f equals 65536u).
13408 Example:
13409
13410 @Example
13411 .defcolor darkgreen rgb 0.1f 0.5f 0.2f
13412 @endExample
13413
13414 Note that @code{f} is the default scaling indicator for the
13415 @code{defcolor} request, thus the above statement is equivalent to
13416
13417 @Example
13418 .defcolor darkgreen rgb 0.1 0.5 0.2
13419 @endExample
13420 @endDefreq
13421
13422 @DefreqList {gcolor, [@Var{color}]}
13423 @DefescItemx {\\m, , c, }
13424 @DefescItem {\\m, @Lparen{}, co, }
13425 @DefescItem {\\m, @Lbrack{}, color, @Rbrack{}}
13426 @DefregListEndx {.m}
13427 Set (glyph) drawing color.  The following examples show how to turn the
13428 next four words red.
13429
13430 @Example
13431 .gcolor red
13432 these are in red
13433 .gcolor
13434 and these words are in black.
13435 @endExample
13436
13437 @Example
13438 \m[red]these are in red\m[] and these words are in black.
13439 @endExample
13440
13441 The escape @code{\m[]} returns to the previous color, as does a call to
13442 @code{gcolor} without an argument.
13443
13444 @cindex drawing color name register (@code{.m})
13445 @cindex name, drawing color, register (@code{.m})
13446 @cindex color name, drawing, register (@code{.m})
13447 The name of the current drawing color is available in the read-only,
13448 string-valued number register @samp{.m}.
13449
13450 The drawing color is associated with the current environment
13451 (@pxref{Environments}).
13452
13453 Note that @code{\m} doesn't produce an input token in @code{gtroff}.  As
13454 a consequence, it can be used in requests like @code{mc} (which expects
13455 a single character as an argument) to change the color on the fly:
13456
13457 @Example
13458 .mc \m[red]x\m[]
13459 @endExample
13460 @endDefesc
13461
13462 @DefreqList {fcolor, [@Var{color}]}
13463 @DefescItemx {\\M, , c, }
13464 @DefescItem {\\M, @Lparen{}, co, }
13465 @DefescItem {\\M, @Lbrack{}, color, @Rbrack{}}
13466 @DefregListEndx {.M}
13467 Set fill (background) color for filled objects drawn with the
13468 @code{\D'@dots{}'} commands.
13469
13470 A red ellipse can be created with the following code:
13471
13472 @Example
13473 \M[red]\h'0.5i'\D'E 2i 1i'\M[]
13474 @endExample
13475
13476 The escape @code{\M[]} returns to the previous fill color, as does a
13477 call to @code{fcolor} without an argument.
13478
13479 @cindex background color name register (@code{.M})
13480 @cindex name, background color, register (@code{.M})
13481 @cindex color name, background, register (@code{.M})
13482 @cindex fill color name register (@code{.M})
13483 @cindex name, fill color, register (@code{.M})
13484 @cindex color name, fill, register (@code{.M})
13485 The name of the current fill (background) color is available in the
13486 read-only, string-valued number register @samp{.M}.
13487
13488 The fill color is associated with the current environment
13489 (@pxref{Environments}).
13490
13491 Note that @code{\M} doesn't produce an input token in @code{gtroff}.
13492 @endDefesc
13493
13494
13495 @c =====================================================================
13496
13497 @node I/O, Postprocessor Access, Colors, gtroff Reference
13498 @section I/O
13499 @cindex i/o
13500 @cindex input and output requests
13501 @cindex requests for input and output
13502 @cindex output and input requests
13503
13504 @code{gtroff} has several requests for including files:
13505
13506 @Defreq {so, file}
13507 @cindex including a file (@code{so})
13508 @cindex file, inclusion (@code{so})
13509 Read in the specified @var{file} and includes it in place of the
13510 @code{so} request.  This is quite useful for large documents, e.g.@:
13511 keeping each chapter in a separate file.  @xref{gsoelim}, for more
13512 information.
13513
13514 Since @code{gtroff} replaces the @code{so} request with the contents of
13515 @code{file}, it makes a difference whether the data is terminated with a
13516 newline or not: Assuming that file @file{xxx} contains the word
13517 @samp{foo} without a final newline, this
13518
13519 @Example
13520 This is
13521 .so xxx
13522 bar
13523 @endExample
13524
13525 @noindent
13526 yields @samp{This is foobar}.
13527
13528 The search path for @var{file} can be controlled with the @option{-I}
13529 command line option.
13530 @endDefreq
13531
13532 @Defreq {pso, command}
13533 Read the standard output from the specified @var{command} and includes
13534 it in place of the @code{pso} request.
13535
13536 @cindex safer mode
13537 @cindex mode, safer
13538 @cindex unsafe mode
13539 @cindex mode, unsafe
13540 This request causes an error if used in safer mode (which is the
13541 default).  Use @code{groff}'s or @code{troff}'s @option{-U} option to
13542 activate unsafe mode.
13543
13544 The comment regarding a final newline for the @code{so} request is valid
13545 for @code{pso} also.
13546 @endDefreq
13547
13548 @Defreq {mso, file}
13549 Identical to the @code{so} request except that @code{gtroff} searches
13550 for the specified @var{file} in the same directories as macro files for
13551 the the @option{-m} command line option.  If the file name to be
13552 included has the form @file{@var{name}.tmac} and it isn't found,
13553 @code{mso} tries to include @file{tmac.@var{name}} and vice versa.
13554 If the file does not exist, a warning of type @samp{file} is emitted.
13555 @xref{Debugging}, for information about warnings.
13556 @endDefreq
13557
13558 @DefreqList {trf, file}
13559 @DefreqListEndx {cf, file}
13560 @cindex transparent output (@code{cf}, @code{trf})
13561 @cindex output, transparent (@code{cf}, @code{trf})
13562 @cindex @code{cf} request, and copy-in mode
13563 @cindex copy-in mode, and @code{cf} request
13564 @cindex mode, copy-in, and @code{cf} request
13565 @cindex @code{trf} request, and copy-in mode
13566 @cindex copy-in mode, and @code{trf} request
13567 @cindex mode, copy-in, and @code{trf} request
13568 Transparently output the contents of @var{file}.  Each line is output as
13569 if it were preceded by @code{\!}; however, the lines are @emph{not}
13570 subject to copy mode interpretation.  If the file does not end with a
13571 newline, then a newline is added (@code{trf} only).  For example, to
13572 define a macro@tie{}@code{x} containing the contents of
13573 file@tie{}@file{f}, use
13574
13575 @Example
13576 .ev 1
13577 .di x
13578 .trf f
13579 .di
13580 .ev
13581 @endExample
13582
13583 @noindent
13584 The calls to @code{ev} prevent that the current partial input line
13585 becomes part of the diversion.
13586
13587 Both @code{trf} and @code{cf}, when used in a diversion, embeds an
13588 object in the diversion which, when reread, causes the contents of
13589 @var{file} to be transparently copied through to the output.  In
13590 @acronym{UNIX} @code{troff}, the contents of @var{file} is immediately
13591 copied through to the output regardless of whether there is a current
13592 diversion; this behaviour is so anomalous that it must be considered a
13593 bug.
13594
13595 @cindex @code{trf} request, and invalid characters
13596 @cindex characters, invalid for @code{trf} request
13597 @cindex invalid characters for @code{trf} request
13598
13599 While @code{cf} copies the contents of @var{file} completely
13600 unprocessed, @code{trf} disallows characters such as NUL that are not
13601 valid @code{gtroff} input characters (@pxref{Identifiers}).
13602
13603 For @code{cf}, within a diversion, `completely unprocessed' means that
13604 each line of a file to be inserted is handled as if it were preceded by
13605 @code{\!\\!}.
13606
13607 Both requests cause a line break.
13608 @endDefreq
13609
13610 @Defreq {nx, [@Var{file}]}
13611 @cindex processing next file (@code{nx})
13612 @cindex file, processing next (@code{nx})
13613 @cindex next file, processing (@code{nx})
13614 Force @code{gtroff} to continue processing of the file specified as an
13615 argument.  If no argument is given, immediately jump to the end of file.
13616 @endDefreq
13617
13618 @Defreq {rd, [@Var{prompt} [@Var{arg1} @Var{arg2} @dots{}]]}
13619 @cindex reading from standard input (@code{rd})
13620 @cindex standard input, reading from (@code{rd})
13621 @cindex input, standard, reading from (@code{rd})
13622 Read from standard input, and include what is read as though it were
13623 part of the input file.  Text is read until a blank line is encountered.
13624
13625 If standard input is a TTY input device (keyboard), write @var{prompt}
13626 to standard error, followed by a colon (or send BEL for a beep if no
13627 argument is given).
13628
13629 Arguments after @var{prompt} are available for the input.  For example,
13630 the line
13631
13632 @Example
13633 .rd data foo bar
13634 @endExample
13635
13636 with the input @w{@samp{This is \$2.}} prints
13637
13638 @Example
13639 This is bar.
13640 @endExample
13641 @endDefreq
13642
13643 @cindex form letters
13644 @cindex letters, form
13645 Using the @code{nx} and @code{rd} requests, it is easy to set up form
13646 letters.  The form letter template is constructed like this, putting the
13647 following lines into a file called @file{repeat.let}:
13648
13649 @Example
13650 .ce
13651 \*(td
13652 .sp 2
13653 .nf
13654 .rd
13655 .sp
13656 .rd
13657 .fi
13658 Body of letter.
13659 .bp
13660 .nx repeat.let
13661 @endExample
13662
13663 @cindex @code{ex} request, used with @code{nx} and @code{rd}
13664 @noindent
13665 When this is run, a file containing the following lines should be
13666 redirected in.  Note that requests included in this file are executed as
13667 though they were part of the form letter.  The last block of input is
13668 the @code{ex} request, which tells @code{groff} to stop processing.  If
13669 this was not there, @code{groff} would not know when to stop.
13670
13671 @Example
13672 Trent A. Fisher
13673 708 NW 19th Av., #202
13674 Portland, OR  97209
13675
13676 Dear Trent,
13677
13678 Len Adollar
13679 4315 Sierra Vista
13680 San Diego, CA  92103
13681
13682 Dear Mr. Adollar,
13683
13684 .ex
13685 @endExample
13686
13687 @Defreq {pi, pipe}
13688 Pipe the output of @code{gtroff} to the shell command(s) specified by
13689 @var{pipe}.  This request must occur before @code{gtroff} has a chance
13690 to print anything.
13691
13692 @cindex safer mode
13693 @cindex mode, safer
13694 @cindex unsafe mode
13695 @cindex mode, unsafe
13696 @code{pi} causes an error if used in safer mode (which is the default).
13697 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate
13698 unsafe mode.
13699
13700 Multiple calls to @code{pi} are allowed, acting as a chain.  For
13701 example,
13702
13703 @Example
13704 .pi foo
13705 .pi bar
13706 ...
13707 @endExample
13708
13709 is the same as @w{@samp{.pi foo | bar}}.
13710
13711 @cindex @code{groff}, and @code{pi} request
13712 @cindex @code{pi} request, and @code{groff}
13713 Note that the intermediate output format of @code{gtroff} is piped to
13714 the specified commands.  Consequently, calling @code{groff} without the
13715 @option{-Z} option normally causes a fatal error.
13716 @endDefreq
13717
13718 @DefreqList {sy, cmds}
13719 @DefregListEndx {systat}
13720 Execute the shell command(s) specified by @var{cmds}.  The output is not
13721 saved anyplace, so it is up to the user to do so.
13722
13723 @cindex safer mode
13724 @cindex mode, safer
13725 @cindex unsafe mode
13726 @cindex mode, unsafe
13727 This request causes an error if used in safer mode (which is the
13728 default).  Use @code{groff}'s or @code{troff}'s @option{-U} option to
13729 activate unsafe mode.
13730
13731 For example, the following code fragment introduces the current time
13732 into a document:
13733
13734 @cindex time, current
13735 @cindex current time
13736 @pindex perl
13737 @Example
13738 .sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
13739              (localtime(time))[2,1,0]' > /tmp/x\n[$$]
13740 .so /tmp/x\n[$$]
13741 .sy rm /tmp/x\n[$$]
13742 \nH:\nM:\nS
13743 @endExample
13744
13745 @noindent
13746 Note that this works by having the @code{perl} script (run by @code{sy})
13747 print out the @code{nr} requests that set the number registers
13748 @code{H}, @code{M}, and @code{S}, and then reads those commands in with
13749 the @code{so} request.
13750
13751 For most practical purposes, the number registers @code{seconds},
13752 @code{minutes}, and @code{hours}, which are initialized at start-up of
13753 @code{gtroff}, should be sufficient.  Use the @code{af} request to get a
13754 formatted output:
13755
13756 @Example
13757 .af hours 00
13758 .af minutes 00
13759 .af seconds 00
13760 \n[hours]:\n[minutes]:\n[seconds]
13761 @endExample
13762
13763 @cindex @code{system()} return value register (@code{systat})
13764 The @code{systat} read-write number register contains the return value
13765 of the @code{system()} function executed by the last @code{sy} request.
13766 @endDefreq
13767
13768 @DefreqList {open, stream file}
13769 @DefreqListEndx {opena, stream file}
13770 @cindex opening file (@code{open})
13771 @cindex file, opening (@code{open})
13772 @cindex appending to a file (@code{opena})
13773 @cindex file, appending to (@code{opena})
13774 Open the specified @var{file} for writing and associates the specified
13775 @var{stream} with it.
13776
13777 The @code{opena} request is like @code{open}, but if the file exists,
13778 append to it instead of truncating it.
13779
13780 @cindex safer mode
13781 @cindex mode, safer
13782 @cindex unsafe mode
13783 @cindex mode, unsafe
13784 Both @code{open} and @code{opena} cause an error if used in safer mode
13785 (which is the default).  Use @code{groff}'s or @code{troff}'s
13786 @option{-U} option to activate unsafe mode.
13787 @endDefreq
13788
13789 @DefreqList {write, stream data}
13790 @DefreqListEndx {writec, stream data}
13791 @cindex copy-in mode, and @code{write} request
13792 @cindex @code{write} request, and copy-in mode
13793 @cindex mode, copy-in, and @code{write} request
13794 @cindex copy-in mode, and @code{writec} request
13795 @cindex @code{writec} request, and copy-in mode
13796 @cindex mode, copy-in, and @code{writec} request
13797 @cindex writing to file (@code{write}, @code{writec})
13798 @cindex file, writing to (@code{write}, @code{writec})
13799 Write to the file associated with the specified @var{stream}.  The
13800 stream must previously have been the subject of an open request.  The
13801 remainder of the line is interpreted as the @code{ds} request reads its
13802 second argument: A leading @samp{"} is stripped, and it is read in
13803 copy-in mode.
13804
13805 The @code{writec} request is like @code{write}, but only @code{write}
13806 appends a newline to the data.
13807 @endDefreq
13808
13809 @Defreq {writem, stream xx}
13810 @cindex @code{asciify} request, and @code{writem}
13811 Write the contents of the macro or string @var{xx} to the file
13812 associated with the specified @var{stream}.
13813
13814 @cindex @code{writem} request, and copy-in mode
13815 @cindex copy-in mode, and @code{writem} request
13816 @cindex mode, copy-in, and @code{writem} request
13817 @var{xx} is read in copy mode, i.e., already formatted elements are
13818 ignored.  Consequently, diversions must be unformatted with the
13819 @code{asciify} request before calling @code{writem}.  Usually, this
13820 means a loss of information.
13821 @endDefreq
13822
13823 @Defreq {close, stream}
13824 @cindex closing file (@code{close})
13825 @cindex file, closing (@code{close})
13826 Close the specified @var{stream}; the stream is no longer an acceptable
13827 argument to the @code{write} request.
13828
13829 Here a simple macro to write an index entry.
13830
13831 @Example
13832 .open idx test.idx
13833 .
13834 .de IX
13835 .  write idx \\n[%] \\$*
13836 ..
13837 .
13838 .IX test entry
13839 .
13840 .close idx
13841 @endExample
13842 @endDefreq
13843
13844 @DefescList {\\V, , e, }
13845 @DefescItem {\\V, @Lparen{}, ev, }
13846 @DefescListEnd {\\V, @Lbrack{}, env, @Rbrack{}}
13847 @cindex @code{\V}, and copy-in mode
13848 @cindex copy-in mode, and @code{\V}
13849 @cindex mode, copy-in, and @code{\V}
13850 Interpolate the contents of the specified environment variable @var{env}
13851 (one-character name@tie{}@var{e}, two-character name @var{ev}) as
13852 returned by the function @code{getenv}.  @code{\V} is interpreted in
13853 copy-in mode.
13854 @endDefesc
13855
13856
13857 @c =====================================================================
13858
13859 @node Postprocessor Access, Miscellaneous, I/O, gtroff Reference
13860 @section Postprocessor Access
13861 @cindex postprocessor access
13862 @cindex access of postprocessor
13863
13864 There are two escapes that give information directly to the
13865 postprocessor.  This is particularly useful for embedding
13866 @sc{PostScript} into the final document.
13867
13868 @DefreqList {device, xxx}
13869 @DefescListEndx {\\X, ', xxx, '}
13870 Embeds its argument into the @code{gtroff} output preceded with
13871 @w{@samp{x X}}.
13872
13873 @cindex @code{\&}, in @code{\X}
13874 @cindex @code{\)}, in @code{\X}
13875 @cindex @code{\%}, in @code{\X}
13876 @ifnotinfo
13877 @cindex @code{\:}, in @code{\X}
13878 @end ifnotinfo
13879 @ifinfo
13880 @cindex @code{\@r{<colon>}}, in @code{\X}
13881 @end ifinfo
13882 The escapes @code{\&}, @code{\)}, @code{\%}, and @code{\:} are ignored
13883 within @code{\X}, @w{@samp{\ }} and @code{\~} are converted to single
13884 space characters.  All other escapes (except @code{\\}, which produces a
13885 backslash) cause an error.
13886
13887 @cindex @code{device} request, and copy-in mode
13888 @cindex copy-in mode, and @code{device} request
13889 @cindex mode, copy-in, and @code{device} request
13890 Contrary to @code{\X}, the @code{device} request simply processes its
13891 argument in copy mode (@pxref{Copy-in Mode}).
13892
13893 @kindex use_charnames_in_special
13894 @pindex DESC@r{, and @code{use_charnames_in_special}}
13895 @cindex @code{\X}, and special characters
13896 If the @samp{use_charnames_in_special} keyword is set in the @file{DESC}
13897 file, special characters no longer cause an error; they are simply
13898 output verbatim.  Additionally, the backslash is represented as
13899 @code{\\}.
13900
13901 @samp{use_charnames_in_special} is currently used by @code{grohtml}
13902 only.
13903 @endDefesc
13904
13905 @DefreqList {devicem, xx}
13906 @DefescItemx {\\Y, , n, }
13907 @DefescItem {\\Y, @Lparen{}, nm, }
13908 @DefescListEnd {\\Y, @Lbrack{}, name, @Rbrack{}}
13909 This is approximately equivalent to @samp{\X'\*[@var{name}]'}
13910 (one-character name@tie{}@var{n}, two-character name @var{nm}).
13911 However, the contents of the string or macro @var{name} are not
13912 interpreted; also it is permitted for @var{name} to have been defined as
13913 a macro and thus contain newlines (it is not permitted for the argument
13914 to @code{\X} to contain newlines).  The inclusion of newlines requires
13915 an extension to the @acronym{UNIX} @code{troff} output format, and
13916 confuses drivers that do not know about this extension (@pxref{Device
13917 Control Commands}).
13918 @endDefesc
13919
13920 @xref{Output Devices}.
13921
13922
13923 @c =====================================================================
13924
13925 @node Miscellaneous, Gtroff Internals, Postprocessor Access, gtroff Reference
13926 @section Miscellaneous
13927
13928 This section documents parts of @code{gtroff} that cannot (yet) be
13929 categorized elsewhere in this manual.
13930
13931 @Defreq {nm, [@Var{start} [@Var{inc} [@Var{space} [@Var{indent}]]]]}
13932 @cindex printing line numbers (@code{nm})
13933 @cindex line numbers, printing (@code{nm})
13934 @cindex numbers, line, printing (@code{nm})
13935 Print line numbers.  @var{start} is the line number of the @emph{next}
13936 output line.  @var{inc} indicates which line numbers are printed.  For
13937 example, the value@tie{}5 means to emit only line numbers that are
13938 multiples of@tie{}5; this defaults to@tie{}1.  @var{space} is the space
13939 to be left between the number and the text; this defaults to one digit
13940 space.  The fourth argument is the indentation of the line numbers,
13941 defaulting to zero.  Both @var{space} and @var{indent} are given as
13942 multiples of digit spaces; they can be negative also.  Without any
13943 arguments, line numbers are turned off.
13944
13945 @code{gtroff} reserves three digit spaces for the line number (which is
13946 printed right-justified) plus the amount given by @var{indent}; the
13947 output lines are concatenated to the line numbers, separated by
13948 @var{space}, and @emph{without} reducing the line length.  Depending on
13949 the value of the horizontal page offset (as set with the @code{po}
13950 request), line numbers that are longer than the reserved space stick
13951 out to the left, or the whole line is moved to the right.
13952
13953 Parameters corresponding to missing arguments are not changed; any
13954 non-digit argument (to be more precise, any argument starting with a
13955 character valid as a delimiter for identifiers) is also treated as
13956 missing.
13957
13958 If line numbering has been disabled with a call to @code{nm} without an
13959 argument, it can be reactivated with @samp{.nm +0}, using the previously
13960 active line numbering parameters.
13961
13962 The parameters of @code{nm} are associated with the current environment
13963 (@pxref{Environments}).  The current output line number is available in
13964 the number register @code{ln}.
13965
13966 @Example
13967 .po 1m
13968 .ll 2i
13969 This test shows how line numbering works with groff.
13970 .nm 999
13971 This test shows how line numbering works with groff.
13972 .br
13973 .nm xxx 3 2
13974 .ll -\w'0'u
13975 This test shows how line numbering works with groff.
13976 .nn 2
13977 This test shows how line numbering works with groff.
13978 @endExample
13979
13980 @noindent
13981 And here the result:
13982
13983 @Example
13984  This  test shows how
13985  line numbering works
13986  999 with   groff.   This
13987 1000 test shows how  line
13988 1001 numbering works with
13989 1002 groff.
13990       This test shows how
13991       line      numbering
13992  works  with  groff.
13993  This test shows how
13994 1005  line      numbering
13995       works with groff.
13996 @endExample
13997 @endDefreq
13998
13999 @Defreq {nn, [@Var{skip}]}
14000 Temporarily turn off line numbering.  The argument is the number of
14001 lines not to be numbered; this defaults to@tie{}1.
14002 @endDefreq
14003
14004 @Defreq {mc, glyph [@Var{dist}]}
14005 @cindex margin glyph (@code{mc})
14006 @cindex glyph, for margins (@code{mc})
14007 Print a @dfn{margin character} to the right of the
14008 text.@footnote{@dfn{Margin character} is a misnomer since it is an
14009 output glyph.}  The first argument is the glyph to be printed.  The
14010 second argument is the distance away from the right margin.  If missing,
14011 the previously set value is used; default is 10@dmn{pt}).  For text
14012 lines that are too long (that is, longer than the text length plus
14013 @var{dist}), the margin character is directly appended to the lines.
14014
14015 With no arguments the margin character is turned off.  If this occurs
14016 before a break, no margin character is printed.
14017
14018 For compatibility with @acronym{AT&T} @code{troff}, a call to @code{mc}
14019 to set the margin character can't be undone immediately; at least one
14020 line gets a margin character.  Thus
14021
14022 @Example
14023 .ll 1i
14024 .mc \[br]
14025 .mc
14026 xxx
14027 .br
14028 xxx
14029 @endExample
14030
14031 @noindent
14032 produces
14033
14034 @Example
14035 xxx        |
14036 xxx
14037 @endExample
14038
14039 @cindex @code{tl} request, and @code{mc}
14040 For empty lines and lines produced by the @code{tl} request no margin
14041 character is emitted.
14042
14043 The margin character is associated with the current environment
14044 (@pxref{Environments}).
14045
14046 @pindex nrchbar
14047 @pindex changebar
14048 This is quite useful for indicating text that has changed, and, in fact,
14049 there are programs available for doing this (they are called
14050 @code{nrchbar} and @code{changebar} and can be found in any
14051 @samp{comp.sources.unix} archive).
14052
14053 @Example
14054 .ll 3i
14055 .mc |
14056 This paragraph is highlighted with a margin
14057 character.
14058 .sp
14059 Note that vertical space isn't marked.
14060 .br
14061 \&
14062 .br
14063 But we can fake it with `\&'.
14064 @endExample
14065
14066 Result:
14067
14068 @Example
14069 This  paragraph is highlighted |
14070 with a margin character.       |
14071
14072 Note that vertical space isn't |
14073 marked.                        |
14074                                |
14075 But we can fake it with `\&'.  |
14076 @endExample
14077 @endDefreq
14078
14079 @DefreqList {psbb, filename}
14080 @DefregItemx {llx}
14081 @DefregItemx {lly}
14082 @DefregItemx {urx}
14083 @DefregListEndx {ury}
14084 @cindex PostScript, bounding box
14085 @cindex bounding box
14086 Retrieve the bounding box of the @sc{PostScript} image found in
14087 @var{filename}.  The file must conform to Adobe's @dfn{Document
14088 Structuring Conventions} (DSC); the command searches for a
14089 @code{%%BoundingBox} comment and extracts the bounding box values into
14090 the number registers @code{llx}, @code{lly}, @code{urx}, and @code{ury}.
14091 If an error occurs (for example, @code{psbb} cannot find the
14092 @code{%%BoundingBox} comment), it sets the four number registers to
14093 zero.
14094
14095 The search path for @var{filename} can be controlled with the
14096 @option{-I} command line option.
14097 @endDefreq
14098
14099
14100 @c =====================================================================
14101
14102 @node Gtroff Internals, Debugging, Miscellaneous, gtroff Reference
14103 @section @code{gtroff} Internals
14104
14105 @cindex input token
14106 @cindex token, input
14107 @cindex output node
14108 @cindex node, output
14109 @code{gtroff} processes input in three steps.  One or more input
14110 characters are converted to an @dfn{input token}.@footnote{Except the
14111 escapes @code{\f}, @code{\F}, @code{\H}, @code{\m}, @code{\M},
14112 @code{\R}, @code{\s}, and @code{\S}, which are processed immediately if
14113 not in copy-in mode.}  Then, one or more input tokens are converted to
14114 an @dfn{output node}.  Finally, output nodes are converted to the
14115 intermediate output language understood by all output devices.
14116
14117 Actually, before step one happens, @code{gtroff} converts certain escape
14118 sequences into reserved input characters (not accessible by the user);
14119 such reserved characters are used for other internal processing also --
14120 this is the very reason why not all characters are valid input.
14121 @xref{Identifiers}, for more on this topic.
14122
14123 For example, the input string @samp{fi\[:u]} is converted into a
14124 character token @samp{f}, a character token @samp{i}, and a special
14125 token @samp{:u} (representing u@tie{}umlaut).  Later on, the character
14126 tokens @samp{f} and @samp{i} are merged to a single output node
14127 representing the ligature glyph @samp{fi} (provided the current font has
14128 a glyph for this ligature); the same happens with @samp{:u}.  All output
14129 glyph nodes are `processed', which means that they are invariably
14130 associated with a given font, font size, advance width, etc.  During the
14131 formatting process, @code{gtroff} itself adds various nodes to control
14132 the data flow.
14133
14134 Macros, diversions, and strings collect elements in two chained lists: a
14135 list of input tokens that have been passed unprocessed, and a list of
14136 output nodes.  Consider the following the diversion.
14137
14138 @Example
14139 .di xxx
14140 a
14141 \!b
14142 c
14143 .br
14144 .di
14145 @endExample
14146
14147 @noindent
14148 It contains these elements.
14149
14150 @multitable {@i{vertical size node}} {token list} {element number}
14151 @item node list               @tab token list @tab element number
14152
14153 @item @i{line start node}     @tab ---        @tab 1
14154 @item @i{glyph node @code{a}} @tab ---        @tab 2
14155 @item @i{word space node}     @tab ---        @tab 3
14156 @item ---                     @tab @code{b}   @tab 4
14157 @item ---                     @tab @code{\n}  @tab 5
14158 @item @i{glyph node @code{c}} @tab ---        @tab 6
14159 @item @i{vertical size node}  @tab ---        @tab 7
14160 @item @i{vertical size node}  @tab ---        @tab 8
14161 @item ---                     @tab @code{\n}  @tab 9
14162 @end multitable
14163
14164 @cindex @code{\v}, internal representation
14165 @noindent
14166 Elements 1, 7, and@tie{}8 are inserted by @code{gtroff}; the latter two
14167 (which are always present) specify the vertical extent of the last line,
14168 possibly modified by @code{\x}.  The @code{br} request finishes the
14169 current partial line, inserting a newline input token, which is
14170 subsequently converted to a space when the diversion is reread.  Note
14171 that the word space node has a fixed width that isn't stretchable
14172 anymore.  To convert horizontal space nodes back to input tokens, use
14173 the @code{unformat} request.
14174
14175 Macros only contain elements in the token list (and the node list is
14176 empty); diversions and strings can contain elements in both lists.
14177
14178 Note that the @code{chop} request simply reduces the number of elements
14179 in a macro, string, or diversion by one.  Exceptions are
14180 @dfn{compatibility save} and @dfn{compatibility ignore} input tokens,
14181 which are ignored.  The @code{substring} request also ignores those
14182 input tokens.
14183
14184 Some requests like @code{tr} or @code{cflags} work on glyph identifiers
14185 only; this means that the associated glyph can be changed without
14186 destroying this association.  This can be very helpful for substituting
14187 glyphs.  In the following example, we assume that glyph @samp{foo} isn't
14188 available by default, so we provide a substitution using the
14189 @code{fchar} request and map it to input character @samp{x}.
14190
14191 @Example
14192 .fchar \[foo] foo
14193 .tr x \[foo]
14194 @endExample
14195
14196 @noindent
14197 Now let us assume that we install an additional special font @samp{bar}
14198 that has glyph @samp{foo}.
14199
14200 @Example
14201 .special bar
14202 .rchar \[foo]
14203 @endExample
14204
14205 @noindent
14206 Since glyphs defined with @code{fchar} are searched before glyphs in
14207 special fonts, we must call @code{rchar} to remove the definition of the
14208 fallback glyph.  Anyway, the translation is still active; @samp{x} now
14209 maps to the real glyph @samp{foo}.
14210
14211 @cindex compatibility mode, and parameters
14212 @cindex mode, compatibility, and parameters
14213 @cindex arguments, and compatibility mode
14214 @cindex parameters, and compatibility mode
14215 @cindex macro arguments, and compatibility mode
14216 @cindex request arguments, and compatibility mode
14217 Macro and request arguments preserve the compatibility mode:
14218
14219 @Example
14220 .cp 1     \" switch to compatibility mode
14221 .de xx
14222 \\$1
14223 ..
14224 .cp 0     \" switch compatibility mode off
14225 .xx caf\['e]
14226     @result{} café
14227 @endExample
14228
14229 @noindent
14230 Since compatibility mode is on while @code{de} is called, the macro
14231 @code{xx} activates compatibility mode while executing.  Argument
14232 @code{$1} can still be handled properly because it inherits the
14233 compatibility mode status which was active at the point where @code{xx}
14234 is called.
14235
14236 After expansion of the parameters, the compatibility save and restore
14237 tokens are removed.
14238
14239
14240 @c =====================================================================
14241
14242 @node Debugging, Implementation Differences, Gtroff Internals, gtroff Reference
14243 @section Debugging
14244 @cindex debugging
14245
14246 @code{gtroff} is not easy to debug, but there are some useful features
14247 and strategies for debugging.
14248
14249 @Defreq {lf, line [@Var{filename}]}
14250 @pindex soelim
14251 @cindex multi-file documents
14252 @cindex documents, multi-file
14253 @cindex setting input line number (@code{lf})
14254 @cindex input line number, setting (@code{lf})
14255 @cindex number, input line, setting (@code{lf})
14256 Change the line number and optionally the file name @code{gtroff} shall
14257 use for error and warning messages.  @var{line} is the input line number
14258 of the @emph{next} line.
14259
14260 Without argument, the request is ignored.
14261
14262 This is a debugging aid for documents that are split into many files,
14263 then put together with @code{soelim} and other preprocessors.  Usually,
14264 it isn't invoked manually.
14265
14266 Note that other @code{troff} implementations (including the original
14267 @acronym{AT&T} version) handle @code{lf} differently.  For them,
14268 @var{line} changes the line number of the @emph{current} line.
14269 @endDefreq
14270
14271 @DefreqList {tm, string}
14272 @DefreqItemx {tm1, string}
14273 @DefreqListEndx {tmc, string}
14274 @cindex printing to stderr (@code{tm}, @code{tm1}, @code{tmc})
14275 @cindex stderr, printing to (@code{tm}, @code{tm1}, @code{tmc})
14276 Send @var{string} to the standard error output; this is very useful for
14277 printing debugging messages among other things.
14278
14279 @cindex @code{tm} request, and copy-in mode
14280 @cindex copy-in mode, and @code{tm} request
14281 @cindex mode, copy-in, and @code{tm} request
14282 @cindex @code{tm1} request, and copy-in mode
14283 @cindex copy-in mode, and @code{tm1} request
14284 @cindex mode, copy-in, and @code{tm1} request
14285 @cindex @code{tmc} request, and copy-in mode
14286 @cindex copy-in mode, and @code{tmc} request
14287 @cindex mode, copy-in, and @code{tmc} request
14288 @var{string} is read in copy mode.
14289
14290 The @code{tm} request ignores leading spaces of @var{string}; @code{tm1}
14291 handles its argument similar to the @code{ds} request: a leading double
14292 quote in @var{string} is stripped to allow initial blanks.
14293
14294 The @code{tmc} request is similar to @code{tm1} but does not append a
14295 newline (as is done in @code{tm} and @code{tm1}).
14296 @endDefreq
14297
14298 @Defreq {ab, [@Var{string}]}
14299 @cindex aborting (@code{ab})
14300 Similar to the @code{tm} request, except that it causes @code{gtroff} to
14301 stop processing.  With no argument it prints @samp{User Abort.} to
14302 standard error.
14303 @endDefreq
14304
14305 @Defreq {ex, }
14306 @cindex @code{ex} request, use in debugging
14307 @cindex exiting (@code{ex})
14308 The @code{ex} request also causes @code{gtroff} to stop processing; see
14309 also @ref{I/O}.
14310 @endDefreq
14311
14312 When doing something involved it is useful to leave the debugging
14313 statements in the code and have them turned on by a command line flag.
14314
14315 @Example
14316 .if \n(DB .tm debugging output
14317 @endExample
14318
14319 @noindent
14320 To activate these statements say
14321
14322 @Example
14323 groff -rDB=1 file
14324 @endExample
14325
14326 If it is known in advance that there are many errors and no useful
14327 output, @code{gtroff} can be forced to suppress formatted output with
14328 the @option{-z} flag.
14329
14330 @Defreq {pev, }
14331 @cindex dumping environments (@code{pev})
14332 @cindex environments, dumping (@code{pev})
14333 Print the contents of the current environment and all the currently
14334 defined environments (both named and numbered) on @code{stderr}.
14335 @endDefreq
14336
14337 @Defreq {pm, }
14338 @cindex dumping symbol table (@code{pm})
14339 @cindex symbol table, dumping (@code{pm})
14340 Print the entire symbol table on @code{stderr}.  Names of all defined
14341 macros, strings, and diversions are print together with their size in
14342 bytes.  Since @code{gtroff} sometimes adds nodes by itself, the returned
14343 size can be larger than expected.
14344
14345 This request differs from @acronym{UNIX} @code{troff}: @code{gtroff}
14346 reports the sizes of diversions, ignores an additional argument to print
14347 only the total of the sizes, and the size isn't returned in blocks of
14348 128 characters.
14349 @endDefreq
14350
14351 @Defreq {pnr, }
14352 @cindex dumping number registers (@code{pnr})
14353 @cindex number registers, dumping (@code{pnr})
14354 Print the names and contents of all currently defined number registers
14355 on @code{stderr}.
14356 @endDefreq
14357
14358 @Defreq {ptr, }
14359 @cindex dumping traps (@code{ptr})
14360 @cindex traps, dumping (@code{ptr})
14361 Print the names and positions of all traps (not including input line
14362 traps and diversion traps) on @code{stderr}.  Empty slots in the page
14363 trap list are printed as well, because they can affect the priority of
14364 subsequently planted traps.
14365 @endDefreq
14366
14367 @Defreq {fl, }
14368 @cindex flush output (@code{fl})
14369 @cindex output, flush (@code{fl})
14370 @cindex interactive use of @code{gtroff}
14371 @cindex @code{gtroff}, interactive use
14372 Instruct @code{gtroff} to flush its output immediately.  The intent is
14373 for interactive use, but this behaviour is currently not implemented in
14374 @code{gtroff}.  Contrary to @acronym{UNIX} @code{troff}, TTY output is
14375 sent to a device driver also (@code{grotty}), making it non-trivial to
14376 communicate interactively.
14377
14378 This request causes a line break.
14379 @endDefreq
14380
14381 @Defreq {backtrace, }
14382 @cindex backtrace of input stack (@code{backtrace})
14383 @cindex input stack, backtrace (@code{backtrace})
14384 Print a backtrace of the input stack to the standard error stream.
14385
14386 Consider the following in file @file{test}:
14387
14388 @Example
14389 .de xxx
14390 .  backtrace
14391 ..
14392 .de yyy
14393 .  xxx
14394 ..
14395 .
14396 .yyy
14397 @endExample
14398
14399 @noindent
14400 On execution, @code{gtroff} prints the following:
14401
14402 @Example
14403 test:2: backtrace: macro `xxx'
14404 test:5: backtrace: macro `yyy'
14405 test:8: backtrace: file `test'
14406 @endExample
14407
14408 The option @option{-b} of @code{gtroff} internally calls a variant of
14409 this request on each error and warning.
14410 @endDefreq
14411
14412 @Defreg {slimit}
14413 @cindex input stack, setting limit
14414 Use the @code{slimit} number register to set the maximum number of
14415 objects on the input stack.  If @code{slimit} is less than or equal
14416 to@tie{}0, there is no limit set.  With no limit, a buggy recursive
14417 macro can exhaust virtual memory.
14418
14419 The default value is 1000; this is a compile-time constant.
14420 @endDefreg
14421
14422 @Defreq {warnscale, si}
14423 Set the scaling indicator used in warnings to @var{si}.  Valid values
14424 for @var{si} are @samp{u}, @samp{i}, @samp{c}, @samp{p}, and @samp{P}.
14425 At startup, it is set to @samp{i}.
14426 @endDefreq
14427
14428 @Defreq {spreadwarn, [@Var{limit}]}
14429 Make @code{gtroff} emit a warning if the additional space inserted for
14430 each space between words in an output line is larger or equal to
14431 @var{limit}.  A negative value is changed to zero; no argument toggles
14432 the warning on and off without changing @var{limit}.  The default
14433 scaling indicator is @samp{m}.  At startup, @code{spreadwarn} is
14434 deactivated, and @var{limit} is set to 3@dmn{m}.
14435
14436 For example,
14437
14438 @Example
14439 .spreadwarn 0.2m
14440 @endExample
14441
14442 @noindent
14443 causes a warning if @code{gtroff} must add 0.2@dmn{m} or more for each
14444 interword space in a line.
14445
14446 This request is active only if text is justified to both margins (using
14447 @w{@samp{.ad b}}).
14448 @endDefreq
14449
14450 @cindex warnings
14451 @code{gtroff} has command line options for printing out more warnings
14452 (@option{-w}) and for printing backtraces (@option{-b}) when a warning
14453 or an error occurs.  The most verbose level of warnings is @option{-ww}.
14454
14455 @DefreqList {warn, [@Var{flags}]}
14456 @DefregListEndx {.warn}
14457 @cindex level of warnings (@code{warn})
14458 @cindex warnings, level (@code{warn})
14459 Control the level of warnings checked for.  The @var{flags} are the sum
14460 of the numbers associated with each warning that is to be enabled; all
14461 other warnings are disabled.  The number associated with each warning is
14462 listed below.  For example, @w{@code{.warn 0}} disables all warnings,
14463 and @w{@code{.warn 1}} disables all warnings except that about missing
14464 glyphs.  If no argument is given, all warnings are enabled.
14465
14466 The read-only number register @code{.warn} contains the current warning
14467 level.
14468 @endDefreq
14469
14470 @menu
14471 * Warnings::
14472 @end menu
14473
14474 @c ---------------------------------------------------------------------
14475
14476 @node Warnings,  , Debugging, Debugging
14477 @subsection Warnings
14478 @cindex warnings
14479
14480 The warnings that can be given to @code{gtroff} are divided into the
14481 following categories.  The name associated with each warning is used by
14482 the @option{-w} and @option{-W} options; the number is used by the
14483 @code{warn} request and by the @code{.warn} register.
14484
14485 @table @samp
14486 @item char
14487 @itemx 1
14488 Non-existent glyphs.@footnote{@code{char} is a misnomer since it reports
14489 missing glyphs -- there aren't missing input characters, only invalid
14490 ones.}  This is enabled by default.
14491
14492 @item number
14493 @itemx 2
14494 Invalid numeric expressions.  This is enabled by default.
14495 @xref{Expressions}.
14496
14497 @item break
14498 @itemx 4
14499 @cindex fill mode
14500 @cindex mode, fill
14501 In fill mode, lines that could not be broken so that their length was
14502 less than the line length.  This is enabled by default.
14503
14504 @item delim
14505 @itemx 8
14506 Missing or mismatched closing delimiters.
14507
14508 @item el
14509 @itemx 16
14510 @cindex @code{ie} request, and warnings
14511 @cindex @code{el} request, and warnings
14512 Use of the @code{el} request with no matching @code{ie} request.
14513 @xref{if-else}.
14514
14515 @item scale
14516 @itemx 32
14517 Meaningless scaling indicators.
14518
14519 @item range
14520 @itemx 64
14521 Out of range arguments.
14522
14523 @item syntax
14524 @itemx 128
14525 Dubious syntax in numeric expressions.
14526
14527 @item di
14528 @itemx 256
14529 @cindex @code{di} request, and warnings
14530 @cindex @code{da} request, and warnings
14531 Use of @code{di} or @code{da} without an argument when there is no
14532 current diversion.
14533
14534 @item mac
14535 @itemx 512
14536 @cindex @code{de}, @code{de1}, @code{dei} requests, and warnings
14537 @cindex @code{am}, @code{am1}, @code{ami} requests, and warnings
14538 @cindex @code{ds}, @code{ds1} requests, and warnings
14539 @cindex @code{as}, @code{as1} requests, and warnings
14540 @cindex @code{di} request, and warnings
14541 @cindex @code{da} request, and warnings
14542 @cindex @code{box}, @code{boxa} requests, and warnings
14543 @cindex @code{\*}, and warnings
14544 Use of undefined strings, macros and diversions.  When an undefined
14545 string, macro, or diversion is used, that string is automatically
14546 defined as empty.  So, in most cases, at most one warning is given for
14547 each name.
14548
14549 @item reg
14550 @itemx 1024
14551 @cindex @code{nr} request, and warnings
14552 @cindex @code{\R}, and warnings
14553 @cindex @code{\n}, and warnings
14554 Use of undefined number registers.  When an undefined number register is
14555 used, that register is automatically defined to have a value of@tie{}0.
14556 So, in most cases, at most one warning is given for use of a particular
14557 name.
14558
14559 @item tab
14560 @itemx 2048
14561 @cindex @code{\t}, and warnings
14562 Use of a tab character where a number was expected.
14563
14564 @item right-brace
14565 @itemx 4096
14566 @cindex @code{\@}}, and warnings
14567 Use of @code{\@}} where a number was expected.
14568
14569 @item missing
14570 @itemx 8192
14571 Requests that are missing non-optional arguments.
14572
14573 @item input
14574 @itemx 16384
14575 Invalid input characters.
14576
14577 @item escape
14578 @itemx 32768
14579 Unrecognized escape sequences.  When an unrecognized escape sequence
14580 @code{\@var{X}} is encountered, the escape character is ignored, and
14581 @var{X} is printed.
14582
14583 @item space
14584 @itemx 65536
14585 @cindex compatibility mode
14586 Missing space between a request or macro and its argument.  This warning
14587 is given when an undefined name longer than two characters is
14588 encountered, and the first two characters of the name make a defined
14589 name.  The request or macro is not invoked.  When this warning is given,
14590 no macro is automatically defined.  This is enabled by default.  This
14591 warning never occurs in compatibility mode.
14592
14593 @item font
14594 @itemx 131072
14595 Non-existent fonts.  This is enabled by default.
14596
14597 @item ig
14598 @itemx 262144
14599 Invalid escapes in text ignored with the @code{ig} request.  These are
14600 conditions that are errors when they do not occur in ignored text.
14601
14602 @item color
14603 @itemx 524288
14604 Color related warnings.
14605
14606 @item file
14607 @itemx 1048576
14608 Missing files.  The @code{mso} request gives this warning when the
14609 requested macro file does not exist.  This is enabled by default.
14610
14611 @item all
14612 All warnings except @samp{di}, @samp{mac} and @samp{reg}.  It is
14613 intended that this covers all warnings that are useful with traditional
14614 macro packages.
14615
14616 @item w
14617 All warnings.
14618 @end table
14619
14620
14621 @c =====================================================================
14622
14623 @node Implementation Differences,  , Debugging, gtroff Reference
14624 @section Implementation Differences
14625 @cindex implementation differences
14626 @cindex differences in implementation
14627 @cindex incompatibilities with @acronym{AT&T} @code{troff}
14628 @cindex compatibility mode
14629 @cindex mode, compatibility
14630
14631 GNU @code{troff} has a number of features that cause incompatibilities
14632 with documents written with old versions of @code{troff}.
14633
14634 @cindex long names
14635 @cindex names, long
14636 Long names cause some incompatibilities.  @acronym{UNIX} @code{troff}
14637 interprets
14638
14639 @Example
14640 .dsabcd
14641 @endExample
14642
14643 @cindex @code{\*}, incompatibilities with @acronym{AT&T} @code{troff}
14644 @cindex @code{\n}, incompatibilities with @acronym{AT&T} @code{troff}
14645 @noindent
14646 as defining a string @samp{ab} with contents @samp{cd}.  Normally, GNU
14647 @code{troff} interprets this as a call of a macro named @code{dsabcd}.
14648 Also @acronym{UNIX} @code{troff} interprets @code{\*[} or @code{\n[} as
14649 references to a string or number register called @samp{[}.  In GNU
14650 @code{troff}, however, this is normally interpreted as the start of a
14651 long name.  In compatibility mode GNU @code{troff} interprets long names
14652 in the traditional way (which means that they are not recognized as
14653 names).
14654
14655 @DefreqList {cp, [@Var{n}]}
14656 @DefreqItemx {do, cmd}
14657 @DefregListEndx {.C}
14658 If @var{n} is missing or non-zero, turn on compatibility mode;
14659 otherwise, turn it off.
14660
14661 The read-only number register @code{.C} is@tie{}1 if compatibility mode
14662 is on, 0@tie{}otherwise.
14663
14664 Compatibility mode can be also turned on with the @option{-C} command
14665 line option.
14666
14667 The @code{do} request turns off compatibility mode while executing its
14668 arguments as a @code{gtroff} command.  However, it does not turn off
14669 compatibility mode while processing the macro itself.  To do that, use
14670 the @code{de1} request (or manipulate the @code{.C} register manually).
14671 @xref{Writing Macros}.
14672
14673 @Example
14674 .do fam T
14675 @endExample
14676
14677 @noindent
14678 executes the @code{fam} request when compatibility mode is enabled.
14679
14680 @code{gtroff} restores the previous compatibility setting before
14681 interpreting any files sourced by the @var{cmd}.
14682 @endDefreq
14683
14684 @cindex input level in delimited arguments
14685 @cindex delimited arguments, incompatibilities with @acronym{AT&T} @code{troff}
14686 Two other features are controlled by @option{-C}.  If not in
14687 compatibility mode, GNU @code{troff} preserves the input level in
14688 delimited arguments:
14689
14690 @Example
14691 .ds xx '
14692 \w'abc\*(xxdef'
14693 @endExample
14694
14695 @noindent
14696 In compatibility mode, the string @samp{72def'} is returned; without
14697 @option{-C} the resulting string is @samp{168} (assuming a TTY output
14698 device).
14699
14700 @cindex @code{\f}, incompatibilities with @acronym{AT&T} @code{troff}
14701 @cindex @code{\H}, incompatibilities with @acronym{AT&T} @code{troff}
14702 @cindex @code{\s}, incompatibilities with @acronym{AT&T} @code{troff}
14703 @cindex @code{\S}, incompatibilities with @acronym{AT&T} @code{troff}
14704 Finally, the escapes @code{\f}, @code{\H}, @code{\m}, @code{\M},
14705 @code{\R}, @code{\s}, and @code{\S} are transparent for recognizing the
14706 beginning of a line only in compatibility mode (this is a rather obscure
14707 feature).  For example, the code
14708
14709 @Example
14710 .de xx
14711 Hallo!
14712 ..
14713 \fB.xx\fP
14714 @endExample
14715
14716 @noindent
14717 prints @samp{Hallo!} in bold face if in compatibility mode, and
14718 @samp{.xx} in bold face otherwise.
14719
14720 @cindex @code{\A}, incompatibilities with @acronym{AT&T} @code{troff}
14721 @cindex @code{\|}, incompatibilities with @acronym{AT&T} @code{troff}
14722 @cindex @code{\^}, incompatibilities with @acronym{AT&T} @code{troff}
14723 @cindex @code{\&}, incompatibilities with @acronym{AT&T} @code{troff}
14724 @cindex @code{\@{}, incompatibilities with @acronym{AT&T} @code{troff}
14725 @cindex @code{\@}}, incompatibilities with @acronym{AT&T} @code{troff}
14726 @cindex @code{\@key{SP}}, incompatibilities with @acronym{AT&T} @code{troff}
14727 @cindex @code{\'}, incompatibilities with @acronym{AT&T} @code{troff}
14728 @cindex @code{\`}, incompatibilities with @acronym{AT&T} @code{troff}
14729 @cindex @code{\-}, incompatibilities with @acronym{AT&T} @code{troff}
14730 @cindex @code{\_}, incompatibilities with @acronym{AT&T} @code{troff}
14731 @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
14732 @cindex @code{\%}, incompatibilities with @acronym{AT&T} @code{troff}
14733 @cindex @code{\c}, incompatibilities with @acronym{AT&T} @code{troff}
14734 GNU @code{troff} does not allow the use of the escape sequences
14735 @code{\|}, @code{\^}, @code{\&}, @code{\@{}, @code{\@}},
14736 @code{\@key{SP}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
14737 @code{\%}, and @code{\c} in names of strings, macros, diversions, number
14738 registers, fonts or environments; @acronym{UNIX} @code{troff} does.  The
14739 @code{\A} escape sequence (@pxref{Identifiers}) may be helpful in
14740 avoiding use of these escape sequences in names.
14741
14742 @cindex fractional point sizes
14743 @cindex fractional type sizes
14744 @cindex point sizes, fractional
14745 @cindex type sizes, fractional
14746 @cindex sizes, fractional
14747 @cindex @code{ps} request, incompatibilities with @acronym{AT&T} @code{troff}
14748 Fractional point sizes cause one noteworthy incompatibility.  In
14749 @acronym{UNIX} @code{troff} the @code{ps} request ignores scale
14750 indicators and thus
14751
14752 @Example
14753 .ps 10u
14754 @endExample
14755
14756 @noindent
14757 sets the point size to 10@tie{}points, whereas in GNU @code{troff} it
14758 sets the point size to 10@tie{}scaled points.  @xref{Fractional Type
14759 Sizes}, for more information.
14760
14761 @cindex @code{bd} request, incompatibilities with @acronym{AT&T} @code{troff}
14762 @cindex @code{cs} request, incompatibilities with @acronym{AT&T} @code{troff}
14763 @cindex @code{tr} request, incompatibilities with @acronym{AT&T} @code{troff}
14764 @cindex @code{fp} request, incompatibilities with @acronym{AT&T} @code{troff}
14765 @cindex input characters and output glyphs, compatibility with @acronym{AT&T} @code{troff}
14766 @cindex output glyphs, and input characters,compatibility with @acronym{AT&T} @code{troff}
14767 @cindex characters, input, and output glyphs, compatibility with @acronym{AT&T} @code{troff}
14768 @cindex glyphs, output, and input characters, compatibility with @acronym{AT&T} @code{troff}
14769 In GNU @code{troff} there is a fundamental difference between
14770 (unformatted) input characters and (formatted) output glyphs.
14771 Everything that affects how a glyph is output is stored with the glyph
14772 node; once a glyph node has been constructed it is unaffected by any
14773 subsequent requests that are executed, including @code{bd}, @code{cs},
14774 @code{tkf}, @code{tr}, or @code{fp} requests.  Normally glyphs are
14775 constructed from input characters at the moment immediately before the
14776 glyph is added to the current output line.  Macros, diversions and
14777 strings are all, in fact, the same type of object; they contain lists of
14778 input characters and glyph nodes in any combination.  A glyph node does
14779 not behave like an input character for the purposes of macro processing;
14780 it does not inherit any of the special properties that the input
14781 character from which it was constructed might have had.  For example,
14782
14783 @Example
14784 .di x
14785 \\\\
14786 .br
14787 .di
14788 .x
14789 @endExample
14790
14791 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
14792 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
14793 @cindex @code{\e}, incompatibilities with @acronym{AT&T} @code{troff}
14794 @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
14795 @cindex @code{\?}, incompatibilities with @acronym{AT&T} @code{troff}
14796 @cindex transparent output, incompatibilities with @acronym{AT&T} @code{troff}
14797 @cindex output, transparent, incompatibilities with @acronym{AT&T} @code{troff}
14798 @noindent
14799 prints @samp{\\} in GNU @code{troff}; each pair of input backslashes is
14800 turned into one output backslash and the resulting output backslashes
14801 are not interpreted as escape characters when they are reread.
14802 @acronym{UNIX} @code{troff} would interpret them as escape characters
14803 when they were reread and would end up printing one @samp{\}.  The
14804 correct way to obtain a printable backslash is to use the @code{\e}
14805 escape sequence: This always prints a single instance of the current
14806 escape character, regardless of whether or not it is used in a
14807 diversion; it also works in both GNU @code{troff} and @acronym{UNIX}
14808 @code{troff}.@footnote{To be completely independent of the current
14809 escape character, use @code{\(rs}, which represents a reverse solidus
14810 (backslash) glyph.}  To store, for some reason, an escape sequence in a
14811 diversion that is interpreted when the diversion is reread, either use
14812 the traditional @code{\!} transparent output facility, or, if this is
14813 unsuitable, the new @code{\?} escape sequence.
14814
14815 @xref{Diversions}, and @ref{Gtroff Internals}, for more information.
14816
14817
14818
14819 @c =====================================================================
14820 @c =====================================================================
14821
14822 @node Preprocessors, Output Devices, gtroff Reference, Top
14823 @chapter Preprocessors
14824 @cindex preprocessors
14825
14826 This chapter describes all preprocessors that come with @code{groff} or
14827 which are freely available.
14828
14829 @menu
14830 * geqn::
14831 * gtbl::
14832 * gpic::
14833 * ggrn::
14834 * grap::
14835 * gchem::
14836 * grefer::
14837 * gsoelim::
14838 * preconv::
14839 @end menu
14840
14841
14842 @c =====================================================================
14843
14844 @node geqn, gtbl, Preprocessors, Preprocessors
14845 @section @code{geqn}
14846 @cindex @code{eqn}, the program
14847 @cindex @code{geqn}, the program
14848
14849 @c XXX
14850
14851 @menu
14852 * Invoking geqn::
14853 @end menu
14854
14855 @c ---------------------------------------------------------------------
14856
14857 @node Invoking geqn,  , geqn, geqn
14858 @subsection Invoking @code{geqn}
14859 @cindex invoking @code{geqn}
14860 @cindex @code{geqn}, invoking
14861
14862 @c XXX
14863
14864
14865 @c =====================================================================
14866
14867 @node gtbl, gpic, geqn, Preprocessors
14868 @section @code{gtbl}
14869 @cindex @code{tbl}, the program
14870 @cindex @code{gtbl}, the program
14871
14872 @c XXX
14873
14874 @menu
14875 * Invoking gtbl::
14876 @end menu
14877
14878 @c ---------------------------------------------------------------------
14879
14880 @node Invoking gtbl,  , gtbl, gtbl
14881 @subsection Invoking @code{gtbl}
14882 @cindex invoking @code{gtbl}
14883 @cindex @code{gtbl}, invoking
14884
14885 @c XXX
14886
14887
14888 @c =====================================================================
14889
14890 @node gpic, ggrn, gtbl, Preprocessors
14891 @section @code{gpic}
14892 @cindex @code{pic}, the program
14893 @cindex @code{gpic}, the program
14894
14895 @c XXX
14896
14897 @menu
14898 * Invoking gpic::
14899 @end menu
14900
14901 @c ---------------------------------------------------------------------
14902
14903 @node Invoking gpic,  , gpic, gpic
14904 @subsection Invoking @code{gpic}
14905 @cindex invoking @code{gpic}
14906 @cindex @code{gpic}, invoking
14907
14908 @c XXX
14909
14910
14911 @c =====================================================================
14912
14913 @node ggrn, grap, gpic, Preprocessors
14914 @section @code{ggrn}
14915 @cindex @code{grn}, the program
14916 @cindex @code{ggrn}, the program
14917
14918 @c XXX
14919
14920 @menu
14921 * Invoking ggrn::
14922 @end menu
14923
14924 @c ---------------------------------------------------------------------
14925
14926 @node Invoking ggrn,  , ggrn, ggrn
14927 @subsection Invoking @code{ggrn}
14928 @cindex invoking @code{ggrn}
14929 @cindex @code{ggrn}, invoking
14930
14931 @c XXX
14932
14933
14934 @c =====================================================================
14935
14936 @node grap, gchem, ggrn, Preprocessors
14937 @section @code{grap}
14938 @cindex @code{grap}, the program
14939
14940 A free implementation of @code{grap}, written by Ted Faber,
14941 is available as an extra package from the following address:
14942
14943 @display
14944 @uref{http://www.lunabase.org/~faber/Vault/software/grap/}
14945 @end display
14946
14947
14948 @c =====================================================================
14949
14950 @node gchem, grefer, grap, Preprocessors
14951 @section @code{gchem}
14952 @cindex @code{chem}, the program
14953 @cindex @code{gchem}, the program
14954
14955 @c XXX
14956
14957 @menu
14958 * Invoking gchem::
14959 @end menu
14960
14961 @c ---------------------------------------------------------------------
14962
14963 @node Invoking gchem,  , gchem, gchem
14964 @subsection Invoking @code{gchem}
14965 @cindex invoking @code{gchem}
14966 @cindex @code{gchem}, invoking
14967
14968 @c XXX
14969
14970
14971 @c =====================================================================
14972
14973 @node grefer, gsoelim, gchem, Preprocessors
14974 @section @code{grefer}
14975 @cindex @code{refer}, the program
14976 @cindex @code{grefer}, the program
14977
14978 @c XXX
14979
14980 @menu
14981 * Invoking grefer::
14982 @end menu
14983
14984 @c ---------------------------------------------------------------------
14985
14986 @node Invoking grefer,  , grefer, grefer
14987 @subsection Invoking @code{grefer}
14988 @cindex invoking @code{grefer}
14989 @cindex @code{grefer}, invoking
14990
14991 @c XXX
14992
14993
14994 @c =====================================================================
14995
14996 @node gsoelim, preconv, grefer, Preprocessors
14997 @section @code{gsoelim}
14998 @cindex @code{soelim}, the program
14999 @cindex @code{gsoelim}, the program
15000
15001 @c XXX
15002
15003 @menu
15004 * Invoking gsoelim::
15005 @end menu
15006
15007 @c ---------------------------------------------------------------------
15008
15009 @node Invoking gsoelim,  , gsoelim, gsoelim
15010 @subsection Invoking @code{gsoelim}
15011 @cindex invoking @code{gsoelim}
15012 @cindex @code{gsoelim}, invoking
15013
15014 @c XXX
15015
15016
15017 @c =====================================================================
15018
15019 @node preconv,  , gsoelim, Preprocessors
15020 @section @code{preconv}
15021 @cindex @code{preconv}, the program
15022
15023 @c XXX
15024
15025 @menu
15026 * Invoking preconv::
15027 @end menu
15028
15029 @c ---------------------------------------------------------------------
15030
15031 @node Invoking preconv,  , preconv, preconv
15032 @subsection Invoking @code{preconv}
15033 @cindex invoking @code{preconv}
15034 @cindex @code{preconv}, invoking
15035
15036 @c XXX
15037
15038
15039 @c =====================================================================
15040 @c =====================================================================
15041
15042 @node Output Devices, File formats, Preprocessors, Top
15043 @chapter Output Devices
15044 @cindex output devices
15045 @cindex devices for output
15046
15047 @c XXX
15048
15049 @menu
15050 * Special Characters::
15051 * grotty::
15052 * grops::
15053 * gropdf::
15054 * grodvi::
15055 * grolj4::
15056 * grolbp::
15057 * grohtml::
15058 * gxditview::
15059 @end menu
15060
15061
15062 @c =====================================================================
15063
15064 @node Special Characters, grotty, Output Devices, Output Devices
15065 @section Special Characters
15066 @cindex special characters
15067 @cindex characters, special
15068
15069 @c XXX
15070
15071 @xref{Font Files}.
15072
15073
15074 @c =====================================================================
15075
15076 @node grotty, grops, Special Characters, Output Devices
15077 @section @code{grotty}
15078 @cindex @code{grotty}, the program
15079
15080 The postprocessor @code{grotty} translates the output from GNU
15081 @code{troff} into a form suitable for typewriter-like devices.  It is
15082 fully documented on its manual page, @cite{grotty(1)}.
15083
15084 @menu
15085 * Invoking grotty::
15086 @end menu
15087
15088 @c ---------------------------------------------------------------------
15089
15090 @node Invoking grotty,  , grotty, grotty
15091 @subsection Invoking @code{grotty}
15092 @cindex invoking @code{grotty}
15093 @cindex @code{grotty}, invoking
15094
15095 The postprocessor @command{grotty} accepts the following command-line
15096 options:
15097
15098 @table @option
15099 @item -b
15100 Do not overstrike bold glyphs.  Ignored if @option{-c} isn't used.
15101
15102 @item -B
15103 Do not underline bold-italic glyphs.  Ignored if @option{-c} isn't
15104 used.
15105
15106 @item -c
15107 Use overprint and disable colours for printing on legacy Teletype
15108 printers (see below).
15109
15110 @item -d
15111 Do not render lines (this is, ignore all @code{\D} escapes).
15112
15113 @item -f
15114 Use form feed control characters in the output.
15115
15116 @item -F@var{dir}
15117 Put the directory @file{@var{dir}/dev@var{name}} in front of the
15118 search path for the font and device description files, given the
15119 target device @var{name}.
15120
15121 @item -h
15122 Use horizontal tabs for sequences of 8 space characters.
15123
15124 @item -i
15125 Request italic glyphs from the terminal.  Ignored if @option{-c} is
15126 active.
15127
15128 @item -o
15129 Do not overstrike.
15130
15131 @item -r
15132 Highlight italic glyphs.  Ignored if @option{-c} is active.
15133
15134 @item -u
15135 Do not underline italic glyphs.  Ignored if @option{-c} isn't used.
15136
15137 @item -U
15138 Do not overstrike bold-italic glyphs.  Ignored if @option{-c} isn't
15139 used.
15140
15141 @item -v
15142 Print the version number.
15143 @end table
15144
15145 @pindex less
15146 @cindex Teletype
15147 @cindex ISO 6249 SGR
15148 @cindex terminal control sequences
15149 @cindex control sequences, for terminals
15150 The @option{-c} mode for TTY output devices means that underlining is
15151 done by emitting sequences of @samp{_} and @samp{^H} (the backspace
15152 character) before the actual character.  Literally, this is printing
15153 an underline character, then moving the caret back one character
15154 position, and printing the actual character at the same position as
15155 the underline character (similar to a typewriter).  Usually, a modern
15156 terminal can't interpret this (and the original Teletype machines for
15157 which this sequence was appropriate are no longer in use).  You need
15158 a pager program like @code{less} that translates this into
15159 ISO@tie{}6429 SGR sequences to control terminals.
15160
15161
15162 @c =====================================================================
15163
15164 @node grops, gropdf, grotty, Output Devices
15165 @section @code{grops}
15166 @cindex @code{grops}, the program
15167
15168 The postprocessor @command{grops} translates the output from GNU
15169 @command{troff} into a form suitable for Adobe @sc{PostScript}
15170 devices.  It is fully documented on its manual page, @cite{grops(1)}.
15171
15172
15173 @menu
15174 * Invoking grops::
15175 * Embedding PostScript::
15176 @end menu
15177
15178 @c ---------------------------------------------------------------------
15179
15180 @node Invoking grops, Embedding PostScript, grops, grops
15181 @subsection Invoking @code{grops}
15182 @cindex invoking @code{grops}
15183 @cindex @code{grops}, invoking
15184
15185 The postprocessor @code{grops} accepts the following command-line
15186 options:
15187
15188 @table @option
15189 @item -b@var{flags}
15190 Use backward compatibility settings given by @var{flags} as
15191 documented in the @cite{grops(1)} manual page.  Overrides the command
15192 @option{broken} in the @file{DESC} file.
15193
15194 @item -c@var{n}
15195 Print @var{n} copies of each page.
15196
15197 @item -F@var{dir}
15198 Put the directory @file{@var{dir}/dev@var{name}} in front of the
15199 search path for the font, prologue and device description files,
15200 given the target device @var{name}, usually @strong{ps}.
15201
15202 @item -g
15203 Tell the printer to guess the page length.  Useful for printing
15204 vertically centered pages when the paper dimensions are determined at
15205 print time.
15206
15207 @item -I@var{path} @dots{}
15208 Consider the directory @file{@var{path}} for searching included files
15209 specified with relative paths.  The current directory is searched as
15210 fallback.
15211
15212 @item -l
15213 Use landscape orientation.
15214
15215 @item -m
15216 Use manual feed.
15217
15218 @item -p@var{papersize}
15219 Set the page dimensions.  Overrides the commands @option{papersize},
15220 @option{paperlength}, and @option{paperwidth} in the @file{DESC}
15221 file.  See the @cite{groff_font(5)} manual page for details.
15222
15223 @item -P@var{prologue}
15224 Use the @var{prologue} in the font path as the prologue instead of
15225 the default @file{prologue}.  Overrides the environment variable
15226 @env{GROPS_PROLOGUE}.
15227
15228 @item -w@var{n}
15229 Set the line thickness to @var{n}/1000@dmn{em}.  Overrides the
15230 default value @var{n} = 40.
15231
15232 @item -v
15233 Print the version number.
15234 @end table
15235
15236 @c ---------------------------------------------------------------------
15237
15238 @node Embedding PostScript,  , Invoking grops, grops
15239 @subsection Embedding @sc{PostScript}
15240 @cindex embedding PostScript
15241 @cindex PostScript, embedding
15242
15243 The escape sequence
15244
15245 @code{\X'ps: import @var{file} @var{llx} @var{lly} @var{urx} @var{ury}
15246   @var{width} [@var{height}]'}
15247
15248 @noindent
15249 places a rectangle of the specified @var{width} containing the
15250 @sc{PostScript} drawing from file @var{file} bound by the box from
15251 @var{llx} @var{lly} to @var{urx} @var{ury} (in @sc{PostScript}
15252 coordinates) at the insertion point.  If @var{height} is not
15253 specified, the embedded drawing is scaled proportionally.
15254
15255 @xref{Miscellaneous}, for the @code{psbb} request, which automatically
15256 generates the bounding box.
15257
15258 This escape sequence is used internally by the macro @code{PSPIC}
15259 (see the @cite{groff_tmac(5)} manual page).
15260
15261
15262 @c =====================================================================
15263
15264 @node gropdf, grodvi, grops, Output Devices
15265 @section @code{gropdf}
15266 @cindex @code{gropdf}, the program
15267
15268 The postprocessor @command{gropdf} translates the output from GNU
15269 @command{troff} into a form suitable for Adobe PDF devices.  It is fully
15270 documented on its manual page, @cite{gropdf(1)}.
15271
15272 @menu
15273 * Invoking gropdf::
15274 * Embedding PDF::
15275 @end menu
15276
15277 @c ---------------------------------------------------------------------
15278
15279 @node Invoking gropdf, Embedding PDF, gropdf, gropdf
15280 @subsection Invoking @code{gropdf}
15281 @cindex invoking @code{gropdf}
15282 @cindex @code{gropdf}, invoking
15283
15284 The postprocessor @code{gropdf} accepts the following command-line
15285 options:
15286
15287 @table @option
15288 @item -d
15289 Produce uncompressed PDFs that include debugging comments.
15290
15291 @item -e
15292 This forces @code{gropdf} to embed all used fonts in the PDF,
15293 even if they are one of the 14 base Adobe fonts.
15294
15295 @item -F@var{dir}
15296 Put the directory @file{@var{dir}/dev@var{name}} in front of the
15297 search path for the font, prologue and device description files,
15298 given the target device @var{name}, usually @strong{pdf}.
15299
15300 @item -y@var{foundry}
15301 This forces the use of a different font foundry.
15302
15303 @item -l
15304 Use landscape orientation.
15305
15306 @item -p@var{papersize}
15307 Set the page dimensions.  Overrides the commands @option{papersize},
15308 @option{paperlength}, and @option{paperwidth} in the @file{DESC}
15309 file.  See the @cite{groff_font(5)} manual page for details.
15310
15311 @item -v
15312 Print the version number.
15313
15314 @item -s
15315 Append a comment line to end of PDF showing statistics, i.e. number of
15316 pages in document.  Ghostscript's @cite{ps2pdf(1)} complains about this
15317 line if it is included, but works anyway.
15318
15319 @item -u@var{filename}
15320 @code{gropdf} normally includes a ToUnicode CMap with any font created
15321 using @file{text.enc} as the encoding file, this makes it easier to
15322 search for words that contain ligatures.  You can include your own CMap
15323 by specifying a @var{filename} or have no CMap at all by omitting the
15324 @var{filename}.
15325 @end table
15326
15327 @c ---------------------------------------------------------------------
15328
15329 @node Embedding PDF,  , Invoking gropdf, gropdf
15330 @subsection Embedding PDF
15331 @cindex embedding PDF
15332 @cindex PDF, embedding
15333
15334 The escape sequence
15335
15336 @code{\X'pdf: pdfpic @var{file} @var{alignment} @var{width} [@var{height}]
15337   [@var{linelength}]'}
15338
15339 @noindent
15340 places a rectangle of the specified @var{width} containing the PDF
15341 drawing from file @var{file} of desired @var{width} and @var{height} (if
15342 @var{height} is missing or zero then it is scaled proportionally).  If
15343 @var{alignment} is @code{-L} the drawing is left aligned.  If it is
15344 @code{-C} or @code{-R} a @var{linelength} greater than the width of the
15345 drawing is required as well.  If @var{width} is specified as zero then
15346 the width is scaled in proportion to the height.
15347
15348
15349 @c =====================================================================
15350
15351 @node grodvi, grolj4, gropdf, Output Devices
15352 @section @code{grodvi}
15353 @cindex @code{grodvi}, the program
15354
15355 The postprocessor @command{grodvi} translates the output from GNU
15356 @command{troff} into the @strong{DVI} output format compatible with
15357 the @strong{@TeX{}} document preparation system.  It is fully
15358 documented on its manual page, @cite{grodvi(1)}.
15359
15360 @menu
15361 * Invoking grodvi::
15362 @end menu
15363
15364 @c ---------------------------------------------------------------------
15365
15366 @node Invoking grodvi,  , grodvi, grodvi
15367 @subsection Invoking @code{grodvi}
15368 @cindex invoking @code{grodvi}
15369 @cindex @code{grodvi}, invoking
15370
15371 The postprocessor @code{grodvi} accepts the following command-line
15372 options:
15373
15374 @table @option
15375 @item -d
15376 Do not use @strong{tpic} specials to implement drawing commands.
15377
15378 @item -F@var{dir}
15379 Put the directory @file{@var{dir}/dev@var{name}} in front of the
15380 search path for the font and device description files, given the
15381 target device @var{name}, usually @strong{dvi}.
15382
15383 @item -l
15384 Use landscape orientation.
15385
15386 @item -p@var{papersize}
15387 Set the page dimensions.  Overrides the commands @option{papersize},
15388 @option{paperlength}, and @option{paperwidth} in the @file{DESC}
15389 file.  See @cite{groff_font(5)} manual page for details.
15390
15391 @item -v
15392 Print the version number.
15393
15394 @item -w@var{n}
15395 Set the line thickness to @var{n}/1000@dmn{em}.  Overrides the
15396 default value @var{n} = 40.
15397 @end table
15398
15399
15400 @c =====================================================================
15401
15402 @node grolj4, grolbp, grodvi, Output Devices
15403 @section @code{grolj4}
15404 @cindex @code{grolj4}, the program
15405
15406 The postprocessor @command{grolj4} translates the output from GNU
15407 @command{troff} into the @strong{PCL5} output format suitable for
15408 printing on a @strong{HP LaserJet@tie{}4} printer.  It is fully
15409 documented on its manual page, @cite{grolj4(1)}.
15410
15411 @menu
15412 * Invoking grolj4::
15413 @end menu
15414
15415 @c ---------------------------------------------------------------------
15416
15417 @node Invoking grolj4,  , grolj4, grolj4
15418 @subsection Invoking @code{grolj4}
15419 @cindex invoking @code{grolj4}
15420 @cindex @code{grolj4}, invoking
15421
15422 The postprocessor @code{grolj4} accepts the following command-line
15423 options:
15424
15425 @table @option
15426 @item -c@var{n}
15427 Print @var{n} copies of each page.
15428
15429 @item -F@var{dir}
15430 Put the directory @file{@var{dir}/dev@var{name}} in front of the
15431 search path for the font and device description files, given the
15432 target device @var{name}, usually @strong{lj4}.
15433
15434 @item -l
15435 Use landscape orientation.
15436
15437 @item -p@var{size}
15438 Set the page dimensions.  Valid values for @var{size} are:
15439 @code{letter}, @code{legal}, @code{executive}, @code{a4},
15440 @code{com10}, @code{monarch}, @code{c5}, @code{b5}, @code{d1}.
15441
15442 @item -v
15443 Print the version number.
15444
15445 @item -w@var{n}
15446 Set the line thickness to @var{n}/1000@dmn{em}.  Overrides the
15447 default value @var{n} = 40.
15448 @end table
15449
15450 The special drawing command @code{\D'R @var{dh} @var{dv}'} draws a
15451 horizontal rectangle from the current position to the position at
15452 offset (@var{dh},@var{dv}).
15453
15454
15455 @c =====================================================================
15456
15457 @node grolbp, grohtml, grolj4, Output Devices
15458 @section @code{grolbp}
15459 @cindex @code{grolbp}, the program
15460
15461 The postprocessor @command{grolbp} translates the output from GNU
15462 @command{troff} into the @strong{LBP} output format suitable for
15463 printing on @strong{Canon CAPSL} printers.  It is fully documented on
15464 its manual page, @cite{grolbp(1)}.
15465
15466 @menu
15467 * Invoking grolbp::
15468 @end menu
15469
15470 @c ---------------------------------------------------------------------
15471
15472 @node Invoking grolbp,  , grolbp, grolbp
15473 @subsection Invoking @code{grolbp}
15474 @cindex invoking @code{grolbp}
15475 @cindex @code{grolbp}, invoking
15476
15477 The postprocessor @code{grolbp} accepts the following command-line
15478 options:
15479
15480 @table @option
15481 @item -c@var{n}
15482 Print @var{n} copies of each page.
15483
15484 @item -F@var{dir}
15485 Put the directory @file{@var{dir}/dev@var{name}} in front of the
15486 search path for the font, prologue and device description files,
15487 given the target device @var{name}, usually @strong{lbp}.
15488
15489 @item -l
15490 Use landscape orientation.
15491
15492 @item -o@var{orientation}
15493 Use the @var{orientation} specified: @code{portrait} or
15494 @code{landscape}.
15495
15496 @item -p@var{papersize}
15497 Set the page dimensions.  See @cite{groff_font(5)} manual page for
15498 details.
15499
15500 @item -w@var{n}
15501 Set the line thickness to @var{n}/1000@dmn{em}.  Overrides the
15502 default value @var{n} = 40.
15503
15504 @item -v
15505 Print the version number.
15506
15507 @item -h
15508 Print command-line help.
15509 @end table
15510
15511
15512 @c =====================================================================
15513
15514 @node grohtml, gxditview, grolbp, Output Devices
15515 @section @code{grohtml}
15516 @cindex @code{grohtml}, the program
15517
15518 The @code{grohtml} front end (which consists of a preprocessor,
15519 @code{pre-grohtml}, and a device driver, @code{post-grohtml}) translates
15520 the output of GNU @code{troff} to @acronym{HTML}.  Users should always
15521 invoke @code{grohtml} via the @code{groff} command with a @code{\-Thtml}
15522 option.  If no files are given, @code{grohtml} will read the standard
15523 input.  A filename of @code{-} will also cause @code{grohtml} to read
15524 the standard input.  @acronym{HTML} output is written to the standard
15525 output.  When @code{grohtml} is run by @code{groff}, options can be
15526 passed to @code{grohtml} using @code{groff}'s @option{-P} option.
15527
15528 @code{grohtml} invokes @code{groff} twice.  In the first pass, pictures,
15529 equations, and tables are rendered using the @code{ps} device, and in
15530 the second pass @acronym{HTML} output is generated by the @code{html}
15531 device.
15532
15533 @code{grohtml} always writes output in @code{UTF-8} encoding and has
15534 built-in entities for all non-composite unicode characters.  In spite of
15535 this, @code{groff} may issue warnings about unknown special characters
15536 if they can't be found during the first pass.  Such warnings can be
15537 safely ignored unless the special characters appear inside a table or
15538 equation, in which case glyphs for these characters must be defined for
15539 the @code{ps} device as well.
15540
15541 This output device is fully documented on its manual page,
15542 @cite{grohtml(1)}.
15543
15544 @menu
15545 * Invoking grohtml::
15546 * grohtml specific registers and strings::
15547 @end menu
15548
15549 @c ---------------------------------------------------------------------
15550
15551 @node Invoking grohtml, grohtml specific registers and strings, grohtml, grohtml
15552 @subsection Invoking @code{grohtml}
15553 @cindex invoking @code{grohtml}
15554 @cindex @code{grohtml}, invoking
15555
15556 The postprocessor @code{grohtml} accepts the following command-line
15557 options:
15558
15559 @table @option
15560 @item -a@var{bits}
15561 Use this number of @var{bits} (= 1, 2 or 4) for text antialiasing.
15562 Default: @var{bits} = 4.
15563
15564 @item -a0
15565 Do not use text antialiasing.
15566
15567 @item -b
15568 Use white background.
15569
15570 @item -D@var{dir}
15571 Store rendered images in the directory @file{@var{dir}}.
15572
15573 @item -F@var{dir}
15574 Put the directory @file{@var{dir}/dev@var{name}} in front of the
15575 search path for the font, prologue and device description files,
15576 given the target device @var{name}, usually @strong{html}.
15577
15578 @item -g@var{bits}
15579 Use this number of @var{bits} (= 1, 2 or 4) for antialiasing of
15580 drawings.  Default: @var{bits} = 4.
15581
15582 @item -g0
15583 Do not use antialiasing for drawings.
15584
15585 @item -h
15586 Use the @code{B} element for section headings.
15587
15588 @item -i@var{resolution}
15589 Use the @var{resolution} for rendered images.  Default:
15590 @var{resolution} = 100@dmn{dpi}.
15591
15592 @item -I@var{stem}
15593 Set the images' @var{stem name}.  Default: @var{stem} =
15594 @file{grohtml-@var{XXX}} (@var{XXX} is the process ID).
15595
15596 @item -j@var{stem}
15597 Place each section in a separate file called
15598 @file{@var{stem}-@var{n}.html} (where @var{n} is a generated section
15599 number).
15600
15601 @item -l
15602 Do not generate the table of contents.
15603
15604 @item -n
15605 Generate simple fragment identifiers.
15606
15607 @item -o@var{offset}
15608 Use vertical paddding @var{offset} for images.
15609
15610 @item -p
15611 Display the page rendering progress to @code{stderr}.
15612
15613 @item -r
15614 Do not use horizontal rules to separate headers and footers.
15615
15616 @item -s@var{size}
15617 Set the base font size, to be modified using the elements @code{BIG}
15618 and @code{SMALL}.
15619
15620 @item -S@var{level}
15621 Generate separate files for sections at level @var{level}.
15622
15623 @item -v
15624 Print the version number.
15625
15626 @item -V
15627 Generate a validator button at the bottom.
15628
15629 @item -y
15630 Generate a signature of groff after the validator button, if any.
15631 @end table
15632
15633
15634 @c ---------------------------------------------------------------------
15635
15636 @node grohtml specific registers and strings,  , Invoking grohtml, grohtml
15637 @subsection @code{grohtml} specific registers and strings
15638 @cindex registers specific to @code{grohtml}
15639 @cindex strings specific to @code{grohtml}
15640 @cindex @code{grohtml}, registers and strings
15641
15642 @DefmpregList {ps4html, grohtml}
15643 @DefstrListEndx {www-image-template, grohtml}
15644 The registers @code{ps4html} and @code{www-image-template} are defined
15645 by the @code{pre-grohtml} preprocessor.  @code{pre-grohtml} reads in the
15646 @code{troff} input, marks up the inline equations and passes the result
15647 firstly to
15648
15649 @Example
15650 troff -Tps -rps4html=1 -dwww-image-template=@var{template}
15651 @endExample
15652
15653 @noindent
15654 and secondly to
15655
15656 @Example
15657 troff -Thtml
15658 @endExample
15659
15660 @noindent
15661 or
15662
15663 @Example
15664 troff -Txhtml
15665 @endExample
15666
15667 @cindex MathML
15668 The @sc{PostScript} device is used to create all the image files (for
15669 @option{-Thtml}; if @option{-Txhtml} is used, all equations are passed
15670 to @code{geqn} to produce @acronym{MathML}, and the register
15671 @code{ps4html} enables the macro sets to ignore floating keeps, footers,
15672 and headings.
15673
15674 The register @code{www-image-template} is set to the user specified
15675 template name or the default name.
15676 @endDefmpreg
15677
15678
15679 @c =====================================================================
15680
15681 @node gxditview,  , grohtml, Output Devices
15682 @section @code{gxditview}
15683 @cindex @code{gxditview}, the program
15684
15685 @c XXX
15686
15687 @menu
15688 * Invoking gxditview::
15689 @end menu
15690
15691 @c ---------------------------------------------------------------------
15692
15693 @node Invoking gxditview,  , gxditview, gxditview
15694 @subsection Invoking @code{gxditview}
15695 @cindex invoking @code{gxditview}
15696 @cindex @code{gxditview}, invoking
15697
15698 @c XXX
15699 @c X11's xditview
15700
15701
15702
15703 @c =====================================================================
15704 @c =====================================================================
15705
15706 @node File formats, Installation, Output Devices, Top
15707 @chapter File formats
15708 @cindex file formats
15709 @cindex formats, file
15710
15711 All files read and written by @code{gtroff} are text files.  The
15712 following two sections describe their format.
15713
15714 @menu
15715 * gtroff Output::
15716 * Font Files::
15717 @end menu
15718
15719
15720 @c =====================================================================
15721
15722 @node gtroff Output, Font Files, File formats, File formats
15723 @section @code{gtroff} Output
15724 @cindex @code{gtroff}, output
15725 @cindex output, @code{gtroff}
15726
15727 This section describes the intermediate output format of GNU
15728 @code{troff}.  This output is produced by a run of @code{gtroff} before
15729 it is fed into a device postprocessor program.
15730
15731 As @code{groff} is a wrapper program around @code{gtroff} that
15732 automatically calls a postprocessor, this output does not show up
15733 normally.  This is why it is called @dfn{intermediate}.  @code{groff}
15734 provides the option @option{-Z} to inhibit postprocessing, such that the
15735 produced intermediate output is sent to standard output just like
15736 calling @code{gtroff} manually.
15737
15738 @cindex troff output
15739 @cindex output, troff
15740 @cindex intermediate output
15741 @cindex output, intermediate
15742 Here, the term @dfn{troff output} describes what is output by
15743 @code{gtroff}, while @dfn{intermediate output} refers to the language
15744 that is accepted by the parser that prepares this output for the
15745 postprocessors.  This parser is smarter on whitespace and implements
15746 obsolete elements for compatibility, otherwise both formats are the
15747 same.@footnote{The parser and postprocessor for intermediate output can
15748 be found in the file@*
15749 @file{@var{groff-source-dir}/src/libs/libdriver/input.cpp}.}
15750
15751 The main purpose of the intermediate output concept is to facilitate the
15752 development of postprocessors by providing a common programming
15753 interface for all devices.  It has a language of its own that is
15754 completely different from the @code{gtroff} language.  While the
15755 @code{gtroff} language is a high-level programming language for text
15756 processing, the intermediate output language is a kind of low-level
15757 assembler language by specifying all positions on the page for writing
15758 and drawing.
15759
15760 The intermediate output produced by @code{gtroff} is fairly readable,
15761 while output from @acronym{AT&T} @code{troff} is rather hard to
15762 understand because of strange habits that are still supported, but not
15763 used any longer by @code{gtroff}.
15764
15765 @menu
15766 * Language Concepts::
15767 * Command Reference::
15768 * Intermediate Output Examples::
15769 * Output Language Compatibility::
15770 @end menu
15771
15772 @c ---------------------------------------------------------------------
15773
15774 @node Language Concepts, Command Reference, gtroff Output, gtroff Output
15775 @subsection Language Concepts
15776
15777 During the run of @code{gtroff}, the input data is cracked down to the
15778 information on what has to be printed at what position on the intended
15779 device.  So the language of the intermediate output format can be quite
15780 small.  Its only elements are commands with and without arguments.  In
15781 this section, the term @dfn{command} always refers to the intermediate
15782 output language, and never to the @code{gtroff} language used for
15783 document formatting.  There are commands for positioning and text
15784 writing, for drawing, and for device controlling.
15785
15786 @menu
15787 * Separation::
15788 * Argument Units::
15789 * Document Parts::
15790 @end menu
15791
15792 @node Separation, Argument Units, Language Concepts, Language Concepts
15793 @subsubsection Separation
15794
15795 @acronym{AT&T} @code{troff} output has strange requirements on
15796 whitespace.  The @code{gtroff} output parser, however, is smart about
15797 whitespace by making it maximally optional.  The whitespace characters,
15798 i.e., the tab, space, and newline characters, always have a syntactical
15799 meaning.  They are never printable because spacing within the output is
15800 always done by positioning commands.
15801
15802 Any sequence of space or tab characters is treated as a single
15803 @dfn{syntactical space}.  It separates commands and arguments, but is
15804 only required when there would occur a clashing between the command code
15805 and the arguments without the space.  Most often, this happens when
15806 variable-length command names, arguments, argument lists, or command
15807 clusters meet.  Commands and arguments with a known, fixed length need
15808 not be separated by syntactical space.
15809
15810 A line break is a syntactical element, too.  Every command argument can
15811 be followed by whitespace, a comment, or a newline character.  Thus a
15812 @dfn{syntactical line break} is defined to consist of optional
15813 syntactical space that is optionally followed by a comment, and a
15814 newline character.
15815
15816 The normal commands, those for positioning and text, consist of a single
15817 letter taking a fixed number of arguments.  For historical reasons, the
15818 parser allows to stack such commands on the same line, but fortunately,
15819 in @code{gtroff}'s intermediate output, every command with at least one
15820 argument is followed by a line break, thus providing excellent
15821 readability.
15822
15823 The other commands -- those for drawing and device controlling -- have a
15824 more complicated structure; some recognize long command names, and some
15825 take a variable number of arguments.  So all @samp{D} and @samp{x}
15826 commands were designed to request a syntactical line break after their
15827 last argument.  Only one command, @w{@samp{x X}}, has an argument that
15828 can stretch over several lines; all other commands must have all of
15829 their arguments on the same line as the command, i.e., the arguments may
15830 not be split by a line break.
15831
15832 Empty lines (these are lines containing only space and/or a comment),
15833 can occur everywhere.  They are just ignored.
15834
15835 @node Argument Units, Document Parts, Separation, Language Concepts
15836 @subsubsection Argument Units
15837
15838 Some commands take integer arguments that are assumed to represent
15839 values in a measurement unit, but the letter for the corresponding scale
15840 indicator is not written with the output command arguments.  Most
15841 commands assume the scale indicator @samp{u}, the basic unit of the
15842 device, some use @samp{z}, the scaled point unit of the device, while
15843 others, such as the color commands, expect plain integers.
15844
15845 Note that single characters can have the eighth bit set, as can the
15846 names of fonts and special characters.  The names of characters and
15847 fonts can be of arbitrary length.  A character that is to be printed is
15848 always in the current font.
15849
15850 A string argument is always terminated by the next whitespace character
15851 (space, tab, or newline); an embedded @samp{#} character is regarded as
15852 part of the argument, not as the beginning of a comment command.  An
15853 integer argument is already terminated by the next non-digit character,
15854 which then is regarded as the first character of the next argument or
15855 command.
15856
15857 @node Document Parts,  , Argument Units, Language Concepts
15858 @subsubsection Document Parts
15859
15860 A correct intermediate output document consists of two parts, the
15861 @dfn{prologue} and the @dfn{body}.
15862
15863 The task of the prologue is to set the general device parameters using
15864 three exactly specified commands.  @code{gtroff}'s prologue is
15865 guaranteed to consist of the following three lines (in that order):
15866
15867 @Example
15868 x T @var{device}
15869 x res @var{n} @var{h} @var{v}
15870 x init
15871 @endExample
15872
15873 @noindent
15874 with the arguments set as outlined in @ref{Device Control Commands}.
15875 Note that the parser for the intermediate output format is able to
15876 swallow additional whitespace and comments as well even in the prologue.
15877
15878 The body is the main section for processing the document data.
15879 Syntactically, it is a sequence of any commands different from the ones
15880 used in the prologue.  Processing is terminated as soon as the first
15881 @w{@samp{x stop}} command is encountered; the last line of any
15882 @code{gtroff} intermediate output always contains such a command.
15883
15884 Semantically, the body is page oriented.  A new page is started by a
15885 @samp{p} command.  Positioning, writing, and drawing commands are always
15886 done within the current page, so they cannot occur before the first
15887 @samp{p} command.  Absolute positioning (by the @samp{H} and @samp{V}
15888 commands) is done relative to the current page; all other positioning is
15889 done relative to the current location within this page.
15890
15891 @c ---------------------------------------------------------------------
15892
15893 @node Command Reference, Intermediate Output Examples, Language Concepts, gtroff Output
15894 @subsection Command Reference
15895
15896 This section describes all intermediate output commands, both from
15897 @acronym{AT&T} @code{troff} as well as the @code{gtroff} extensions.
15898
15899 @menu
15900 * Comment Command::
15901 * Simple Commands::
15902 * Graphics Commands::
15903 * Device Control Commands::
15904 * Obsolete Command::
15905 @end menu
15906
15907 @node Comment Command, Simple Commands, Command Reference, Command Reference
15908 @subsubsection Comment Command
15909
15910 @table @code
15911 @item #@var{anything}@angles{end of line}
15912 A comment.  Ignore any characters from the @samp{#} character up to the
15913 next newline character.
15914
15915 This command is the only possibility for commenting in the intermediate
15916 output.  Each comment can be preceded by arbitrary syntactical space;
15917 every command can be terminated by a comment.
15918 @end table
15919
15920 @node Simple Commands, Graphics Commands, Comment Command, Command Reference
15921 @subsubsection Simple Commands
15922
15923 The commands in this subsection have a command code consisting of a
15924 single character, taking a fixed number of arguments.  Most of them are
15925 commands for positioning and text writing.  These commands are smart
15926 about whitespace.  Optionally, syntactical space can be inserted before,
15927 after, and between the command letter and its arguments.  All of these
15928 commands are stackable, i.e., they can be preceded by other simple
15929 commands or followed by arbitrary other commands on the same line.  A
15930 separating syntactical space is only necessary when two integer
15931 arguments would clash or if the preceding argument ends with a string
15932 argument.
15933
15934 @table @code
15935 @ignore
15936 .if (\n[@USE_ENV_STACK] == 1) \{\
15937 .command {
15938 Open a new environment by copying the actual device configuration data
15939 to the environment stack.
15940 .
15941 The current environment is setup by the device specification and
15942 manipulated by the setting commands.
15943 .
15944 .
15945 .command }
15946 Close the actual environment (opened by a preceding
15947 .BR { \~command)
15948 and restore the previous environment from the environment
15949 stack as the actual device configuration data.
15950 .
15951 \}              \" endif @USE_ENV_STACK
15952 @end ignore
15953
15954 @item C @var{xxx}@angles{whitespace}
15955 Print a special character named @var{xxx}.  The trailing syntactical
15956 space or line break is necessary to allow glyph names of arbitrary
15957 length.  The glyph is printed at the current print position; the glyph's
15958 size is read from the font file.  The print position is not changed.
15959
15960 @item c @var{g}
15961 Print glyph@tie{}@var{g} at the current print
15962 position;@footnote{@samp{c} is actually a misnomer since it outputs a
15963 glyph.} the glyph's size is read from the font file.  The print position
15964 is not changed.
15965
15966 @item f @var{n}
15967 Set font to font number@tie{}@var{n} (a non-negative integer).
15968
15969 @item H @var{n}
15970 Move right to the absolute vertical position@tie{}@var{n} (a
15971 non-negative integer in basic units @samp{u} relative to left edge of
15972 current page.
15973
15974 @item h @var{n}
15975 Move @var{n} (a non-negative integer) basic units @samp{u} horizontally
15976 to the right.  The original @acronym{UNIX} troff manual allows negative
15977 values for @var{n} also, but @code{gtroff} doesn't use this.
15978
15979 @item m @var{color-scheme} @r{[}@var{component} @dots{}@r{]}
15980 Set the color for text (glyphs), line drawing, and the outline of
15981 graphic objects using different color schemes; the analoguous command
15982 for the filling color of graphic objects is @samp{DF}.  The color
15983 components are specified as integer arguments between 0 and 65536.  The
15984 number of color components and their meaning vary for the different
15985 color schemes.  These commands are generated by @code{gtroff}'s escape
15986 sequence @code{\m}.  No position changing.  These commands are a
15987 @code{gtroff} extension.
15988
15989 @table @code
15990 @item mc @var{cyan} @var{magenta} @var{yellow}
15991 Set color using the CMY color scheme, having the 3@tie{}color components
15992 @var{cyan}, @var{magenta}, and @var{yellow}.
15993
15994 @item md
15995 Set color to the default color value (black in most cases).  No
15996 component arguments.
15997
15998 @item mg @var{gray}
15999 Set color to the shade of gray given by the argument, an integer between
16000 0 (black) and 65536 (white).
16001
16002 @item mk @var{cyan} @var{magenta} @var{yellow} @var{black}
16003 Set color using the CMYK color scheme, having the 4@tie{}color
16004 components @var{cyan}, @var{magenta}, @var{yellow}, and @var{black}.
16005
16006 @item mr @var{red} @var{green} @var{blue}
16007 Set color using the RGB color scheme, having the 3@tie{}color components
16008 @var{red}, @var{green}, and @var{blue}.
16009 @end table
16010
16011 @item N @var{n}
16012 Print glyph with index@tie{}@var{n} (a non-negative integer) of the
16013 current font.  This command is a @code{gtroff} extension.
16014
16015 @item n @var{b} @var{a}
16016 Inform the device about a line break, but no positioning is done by this
16017 command.  In @acronym{AT&T} @code{troff}, the integer arguments @var{b}
16018 and@tie{}@var{a} informed about the space before and after the current
16019 line to make the intermediate output more human readable without
16020 performing any action.  In @code{groff}, they are just ignored, but they
16021 must be provided for compatibility reasons.
16022
16023 @item p @var{n}
16024 Begin a new page in the outprint.  The page number is set
16025 to@tie{}@var{n}.  This page is completely independent of pages formerly
16026 processed even if those have the same page number.  The vertical
16027 position on the outprint is automatically set to@tie{}0.  All
16028 positioning, writing, and drawing is always done relative to a page, so
16029 a @samp{p} command must be issued before any of these commands.
16030
16031 @item s @var{n}
16032 Set point size to @var{n}@tie{}scaled points (this is unit @samp{z}).
16033 @acronym{AT&T} @code{troff} used the unit points (@samp{p}) instead.
16034 @xref{Output Language Compatibility}.
16035
16036 @item t @var{xxx}@angles{whitespace}
16037 @itemx t @var{xxx} @var{dummy-arg}@angles{whitespace}
16038 Print a word, i.e., a sequence of characters @var{xxx} representing
16039 output glyphs which names are single characters, terminated by a space
16040 character or a line break; an optional second integer argument is
16041 ignored (this allows the formatter to generate an even number of
16042 arguments).  The first glyph should be printed at the current position,
16043 the current horizontal position should then be increased by the width of
16044 the first glyph, and so on for each glyph.  The widths of the glyphs are
16045 read from the font file, scaled for the current point size, and rounded
16046 to a multiple of the horizontal resolution.  Special characters cannot
16047 be printed using this command (use the @samp{C} command for special
16048 characters).  This command is a @code{gtroff} extension; it is only used
16049 for devices whose @file{DESC} file contains the @code{tcommand} keyword
16050 (@pxref{DESC File Format}).
16051
16052 @item u @var{n} @var{xxx}@angles{whitespace}
16053 Print word with track kerning.  This is the same as the @samp{t} command
16054 except that after printing each glyph, the current horizontal position
16055 is increased by the sum of the width of that glyph and@tie{}@var{n} (an
16056 integer in basic units @samp{u}).  This command is a @code{gtroff}
16057 extension; it is only used for devices whose @file{DESC} file contains
16058 the @code{tcommand} keyword (@pxref{DESC File Format}).
16059
16060 @item V @var{n}
16061 Move down to the absolute vertical position@tie{}@var{n} (a non-negative
16062 integer in basic units @samp{u}) relative to upper edge of current page.
16063
16064 @item v @var{n}
16065 Move @var{n}@tie{}basic units @samp{u} down (@var{n} is a non-negative
16066 integer).  The original @acronym{UNIX} troff manual allows negative
16067 values for @var{n} also, but @code{gtroff} doesn't use this.
16068
16069 @item w
16070 Informs about a paddable white space to increase readability.  The
16071 spacing itself must be performed explicitly by a move command.
16072 @end table
16073
16074 @node Graphics Commands, Device Control Commands, Simple Commands, Command Reference
16075 @subsubsection Graphics Commands
16076
16077 Each graphics or drawing command in the intermediate output starts with
16078 the letter @samp{D}, followed by one or two characters that specify a
16079 subcommand; this is followed by a fixed or variable number of integer
16080 arguments that are separated by a single space character.  A @samp{D}
16081 command may not be followed by another command on the same line (apart
16082 from a comment), so each @samp{D} command is terminated by a syntactical
16083 line break.
16084
16085 @code{gtroff} output follows the classical spacing rules (no space
16086 between command and subcommand, all arguments are preceded by a single
16087 space character), but the parser allows optional space between the
16088 command letters and makes the space before the first argument optional.
16089 As usual, each space can be any sequence of tab and space characters.
16090
16091 Some graphics commands can take a variable number of arguments.  In this
16092 case, they are integers representing a size measured in basic units
16093 @samp{u}.  The arguments called @var{h1}, @var{h2}, @dots{}, @var{hn}
16094 stand for horizontal distances where positive means right, negative
16095 left.  The arguments called @var{v1}, @var{v2}, @dots{}, @var{vn} stand
16096 for vertical distances where positive means down, negative up.  All
16097 these distances are offsets relative to the current location.
16098
16099 Each graphics command directly corresponds to a similar @code{gtroff}
16100 @code{\D} escape sequence.  @xref{Drawing Requests}.
16101
16102 Unknown @samp{D} commands are assumed to be device-specific.  Its
16103 arguments are parsed as strings; the whole information is then sent to
16104 the postprocessor.
16105
16106 In the following command reference, the syntax element @angles{line
16107 break} means a syntactical line break as defined above.
16108
16109 @table @code
16110 @item D~ @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
16111 Draw B-spline from current position to offset (@var{h1},@var{v1}), then
16112 to offset (@var{h2},@var{v2}), if given, etc.@: up to
16113 (@var{hn},@var{vn}).  This command takes a variable number of argument
16114 pairs; the current position is moved to the terminal point of the drawn
16115 curve.
16116
16117 @item Da @var{h1} @var{v1} @var{h2} @var{v2}@angles{line break}
16118 Draw arc from current position to
16119 (@var{h1},@var{v1})@math{+}(@var{h2},@var{v2}) with center at
16120 (@var{h1},@var{v1}); then move the current position to the final point
16121 of the arc.
16122
16123 @item DC @var{d}@angles{line break}
16124 @itemx DC @var{d} @var{dummy-arg}@angles{line break}
16125 Draw a solid circle using the current fill color with
16126 diameter@tie{}@var{d} (integer in basic units @samp{u}) with leftmost
16127 point at the current position; then move the current position to the
16128 rightmost point of the circle.  An optional second integer argument is
16129 ignored (this allows the formatter to generate an even number of
16130 arguments).  This command is a @code{gtroff} extension.
16131
16132 @item Dc @var{d}@angles{line break}
16133 Draw circle line with diameter@tie{}@var{d} (integer in basic units
16134 @samp{u}) with leftmost point at the current position; then move the
16135 current position to the rightmost point of the circle.
16136
16137 @item DE @var{h} @var{v}@angles{line break}
16138 Draw a solid ellipse in the current fill color with a horizontal
16139 diameter of@tie{}@var{h} and a vertical diameter of@tie{}@var{v} (both
16140 integers in basic units @samp{u}) with the leftmost point at the current
16141 position; then move to the rightmost point of the ellipse.  This command
16142 is a @code{gtroff} extension.
16143
16144 @item De @var{h} @var{v}@angles{line break}
16145 Draw an outlined ellipse with a horizontal diameter of@tie{}@var{h} and
16146 a vertical diameter of@tie{}@var{v} (both integers in basic units
16147 @samp{u}) with the leftmost point at current position; then move to the
16148 rightmost point of the ellipse.
16149
16150 @item DF @var{color-scheme} @r{[}@var{component} @dots{}@r{]}@angles{line break}
16151 Set fill color for solid drawing objects using different color schemes;
16152 the analoguous command for setting the color of text, line graphics, and
16153 the outline of graphic objects is @samp{m}.  The color components are
16154 specified as integer arguments between 0 and 65536.  The number of color
16155 components and their meaning vary for the different color schemes.
16156 These commands are generated by @code{gtroff}'s escape sequences
16157 @w{@code{\D'F @dots{}'}} and @code{\M} (with no other corresponding
16158 graphics commands).  No position changing.  This command is a
16159 @code{gtroff} extension.
16160
16161 @table @code
16162 @item DFc @var{cyan} @var{magenta} @var{yellow}@angles{line break}
16163 Set fill color for solid drawing objects using the CMY color scheme,
16164 having the 3@tie{}color components @var{cyan}, @var{magenta}, and
16165 @var{yellow}.
16166
16167 @item DFd@angles{line break}
16168 Set fill color for solid drawing objects to the default fill color value
16169 (black in most cases).  No component arguments.
16170
16171 @item DFg @var{gray}@angles{line break}
16172 Set fill color for solid drawing objects to the shade of gray given by
16173 the argument, an integer between 0 (black) and 65536 (white).
16174
16175 @item DFk @var{cyan} @var{magenta} @var{yellow} @var{black}@angles{line break}
16176 Set fill color for solid drawing objects using the CMYK color scheme,
16177 having the 4@tie{}color components @var{cyan}, @var{magenta},
16178 @var{yellow}, and @var{black}.
16179
16180 @item DFr @var{red} @var{green} @var{blue}@angles{line break}
16181 Set fill color for solid drawing objects using the RGB color scheme,
16182 having the 3@tie{}color components @var{red}, @var{green}, and
16183 @var{blue}.
16184 @end table
16185
16186 @item Df @var{n}@angles{line break}
16187 The argument@tie{}@var{n} must be an integer in the range @math{-32767}
16188 to 32767.
16189
16190 @table @asis
16191 @item @math{0 @value{LE} @var{n} @value{LE} 1000}
16192 Set the color for filling solid drawing objects to a shade of gray,
16193 where 0 corresponds to solid white, 1000 (the default) to solid black,
16194 and values in between to intermediate shades of gray; this is obsoleted
16195 by command @samp{DFg}.
16196
16197 @item @math{@var{n} < 0} or @math{@var{n} > 1000}
16198 Set the filling color to the color that is currently being used for the
16199 text and the outline, see command @samp{m}.  For example, the command
16200 sequence
16201
16202 @Example
16203 mg 0 0 65536
16204 Df -1
16205 @endExample
16206
16207 @noindent
16208 sets all colors to blue.
16209 @end table
16210
16211 @noindent
16212 No position changing.  This command is a @code{gtroff} extension.
16213
16214 @item Dl @var{h} @var{v}@angles{line break}
16215 Draw line from current position to offset (@var{h},@var{v}) (integers in
16216 basic units @samp{u}); then set current position to the end of the drawn
16217 line.
16218
16219 @item Dp @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
16220 Draw a polygon line from current position to offset (@var{h1},@var{v1}),
16221 from there to offset (@var{h2},@var{v2}), etc.@: up to offset
16222 (@var{hn},@var{vn}), and from there back to the starting position.  For
16223 historical reasons, the position is changed by adding the sum of all
16224 arguments with odd index to the actual horizontal position and the even
16225 ones to the vertical position.  Although this doesn't make sense it is
16226 kept for compatibility.
16227 @ignore
16228 As the polygon is closed, the end of drawing is the starting point, so
16229 the position doesn't change.
16230 @end ignore
16231 This command is a @code{gtroff} extension.
16232
16233 @item Dp @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
16234 Draw a solid polygon in the current fill color rather than an outlined
16235 polygon, using the same arguments and positioning as the corresponding
16236 @samp{Dp} command.
16237 @ignore
16238 No position changing.
16239 @end ignore
16240 This command is a @code{gtroff} extension.
16241
16242 @item Dt @var{n}@angles{line break}
16243 Set the current line thickness to@tie{}@var{n} (an integer in basic
16244 units @samp{u}) if @math{@var{n}>0}; if @math{@var{n}=0} select the
16245 smallest available line thickness; if @math{@var{n}<0} set the line
16246 thickness proportional to the point size (this is the default before the
16247 first @samp{Dt} command was specified).  For historical reasons, the
16248 horizontal position is changed by adding the argument to the actual
16249 horizontal position, while the vertical position is not changed.
16250 Although this doesn't make sense it is kept for compatibility.
16251 @ignore
16252 No position changing.
16253 @end ignore
16254 This command is a @code{gtroff} extension.
16255 @end table
16256
16257 @node Device Control Commands, Obsolete Command, Graphics Commands, Command Reference
16258 @subsubsection Device Control Commands
16259
16260 Each device control command starts with the letter @samp{x}, followed by
16261 a space character (optional or arbitrary space or tab in @code{gtroff})
16262 and a subcommand letter or word; each argument (if any) must be preceded
16263 by a syntactical space.  All @samp{x} commands are terminated by a
16264 syntactical line break; no device control command can be followed by
16265 another command on the same line (except a comment).
16266
16267 The subcommand is basically a single letter, but to increase
16268 readability, it can be written as a word, i.e., an arbitrary sequence of
16269 characters terminated by the next tab, space, or newline character.  All
16270 characters of the subcommand word but the first are simply ignored.  For
16271 example, @code{gtroff} outputs the initialization command @w{@samp{x i}}
16272 as @w{@samp{x init}} and the resolution command @w{@samp{x r}} as
16273 @w{@samp{x res}}.
16274
16275 In the following, the syntax element @angles{line break} means a
16276 syntactical line break (@pxref{Separation}).
16277
16278 @table @code
16279 @item xF @var{name}@angles{line break}
16280 The @samp{F} stands for @var{Filename}.
16281
16282 Use @var{name} as the intended name for the current file in error
16283 reports.  This is useful for remembering the original file name when
16284 @code{gtroff} uses an internal piping mechanism.  The input file is not
16285 changed by this command.  This command is a @code{gtroff} extension.
16286
16287 @item xf @var{n} @var{s}@angles{line break}
16288 The @samp{f} stands for @var{font}.
16289
16290 Mount font position@tie{}@var{n} (a non-negative integer) with font
16291 named@tie{}@var{s} (a text word).  @xref{Font Positions}.
16292
16293 @item xH @var{n}@angles{line break}
16294 The @samp{H} stands for @var{Height}.
16295
16296 Set glyph height to@tie{}@var{n} (a positive integer in scaled points
16297 @samp{z}).  @acronym{AT&T} @code{troff} uses the unit points (@samp{p})
16298 instead.  @xref{Output Language Compatibility}.
16299
16300 @item xi@angles{line break}
16301 The @samp{i} stands for @var{init}.
16302
16303 Initialize device.  This is the third command of the prologue.
16304
16305 @item xp@angles{line break}
16306 The @samp{p} stands for @var{pause}.
16307
16308 Parsed but ignored.  The original @acronym{UNIX} troff manual writes
16309
16310 @display
16311 pause device, can be restarted
16312 @end display
16313
16314 @item xr @var{n} @var{h} @var{v}@angles{line break}
16315 The @samp{r} stands for @var{resolution}.
16316
16317 Resolution is@tie{}@var{n}, while @var{h} is the minimal horizontal
16318 motion, and @var{v} the minimal vertical motion possible with this
16319 device; all arguments are positive integers in basic units @samp{u} per
16320 inch.  This is the second command of the prologue.
16321
16322 @item xS @var{n}@angles{line break}
16323 The @samp{S} stands for @var{Slant}.
16324
16325 Set slant to@tie{}@var{n} (an integer in basic units @samp{u}).
16326
16327 @item xs@angles{line break}
16328 The @samp{s} stands for @var{stop}.
16329
16330 Terminates the processing of the current file; issued as the last
16331 command of any intermediate troff output.
16332
16333 @item xt@angles{line break}
16334 The @samp{t} stands for @var{trailer}.
16335
16336 Generate trailer information, if any.  In @var{gtroff}, this is actually
16337 just ignored.
16338
16339 @item xT @var{xxx}@angles{line break}
16340 The @samp{T} stands for @var{Typesetter}.
16341
16342 Set name of device to word @var{xxx}, a sequence of characters ended by
16343 the next white space character.  The possible device names coincide with
16344 those from the @code{groff} @option{-T} option.  This is the first
16345 command of the prologue.
16346
16347 @item xu @var{n}@angles{line break}
16348 The @samp{u} stands for @var{underline}.
16349
16350 Configure underlining of spaces.  If @var{n} is@tie{}1, start
16351 underlining of spaces; if @var{n} is@tie{}0, stop underlining of spaces.
16352 This is needed for the @code{cu} request in nroff mode and is ignored
16353 otherwise.  This command is a @code{gtroff} extension.
16354
16355 @item xX @var{anything}@angles{line break}
16356 The @samp{x} stands for @var{X-escape}.
16357
16358 Send string @var{anything} uninterpreted to the device.  If the line
16359 following this command starts with a @samp{+} character this line is
16360 interpreted as a continuation line in the following sense.  The @samp{+}
16361 is ignored, but a newline character is sent instead to the device, the
16362 rest of the line is sent uninterpreted.  The same applies to all
16363 following lines until the first character of a line is not a @samp{+}
16364 character.  This command is generated by the @code{gtroff} escape
16365 sequence @code{\X}.  The line-continuing feature is a @code{gtroff}
16366 extension.
16367 @end table
16368
16369 @node Obsolete Command,  , Device Control Commands, Command Reference
16370 @subsubsection Obsolete Command
16371 In @acronym{AT&T} @code{troff} output, the writing of a single glyph is
16372 mostly done by a very strange command that combines a horizontal move
16373 and a single character giving the glyph name.  It doesn't have a command
16374 code, but is represented by a 3-character argument consisting of exactly
16375 2@tie{}digits and a character.
16376
16377 @table @asis
16378 @item @var{dd}@var{g}
16379 Move right @var{dd} (exactly two decimal digits) basic units @samp{u},
16380 then print glyph@tie{}@var{g} (represented as a single character).
16381
16382 In @code{gtroff}, arbitrary syntactical space around and within this
16383 command is allowed to be added.  Only when a preceding command on the
16384 same line ends with an argument of variable length a separating space is
16385 obligatory.  In @acronym{AT&T} @code{troff}, large clusters of these and
16386 other commands are used, mostly without spaces; this made such output
16387 almost unreadable.
16388 @end table
16389
16390 For modern high-resolution devices, this command does not make sense
16391 because the width of the glyphs can become much larger than two decimal
16392 digits.  In @code{gtroff}, this is only used for the devices @code{X75},
16393 @code{X75-12}, @code{X100}, and @code{X100-12}.  For other devices, the
16394 commands @samp{t} and @samp{u} provide a better functionality.
16395
16396 @c ---------------------------------------------------------------------
16397
16398 @node Intermediate Output Examples, Output Language Compatibility, Command Reference, gtroff Output
16399 @subsection Intermediate Output Examples
16400
16401 This section presents the intermediate output generated from the same
16402 input for three different devices.  The input is the sentence @samp{hell
16403 world} fed into @code{gtroff} on the command line.
16404
16405 @table @asis
16406 @item High-resolution device @code{ps}
16407
16408 This is the standard output of @code{gtroff} if no @option{-T} option is
16409 given.
16410
16411 @example
16412 @group
16413 shell> echo "hell world" | groff -Z -T ps
16414
16415 x T ps
16416 x res 72000 1 1
16417 x init
16418 @end group
16419 p1
16420 x font 5 TR
16421 f5
16422 s10000
16423 V12000
16424 H72000
16425 thell
16426 wh2500
16427 tw
16428 H96620
16429 torld
16430 n12000 0
16431 @group
16432 x trailer
16433 V792000
16434 x stop
16435 @end group
16436 @end example
16437
16438 @noindent
16439 This output can be fed into @code{grops} to get its representation as a
16440 @sc{PostScript} file.
16441
16442 @item Low-resolution device @code{latin1}
16443
16444 This is similar to the high-resolution device except that the
16445 positioning is done at a minor scale.  Some comments (lines starting
16446 with @samp{#}) were added for clarification; they were not generated by
16447 the formatter.
16448
16449 @example
16450 @group
16451 shell> echo "hell world" | groff -Z -T latin1
16452
16453 # prologue
16454 x T latin1
16455 x res 240 24 40
16456 x init
16457 @end group
16458 # begin a new page
16459 p1
16460 # font setup
16461 x font 1 R
16462 f1
16463 s10
16464 # initial positioning on the page
16465 V40
16466 H0
16467 # write text `hell'
16468 thell
16469 # inform about space, and issue a horizontal jump
16470 wh24
16471 # write text `world'
16472 tworld
16473 # announce line break, but do nothing because ...
16474 n40 0
16475 @group
16476 # ... the end of the document has been reached
16477 x trailer
16478 V2640
16479 x stop
16480 @end group
16481 @end example
16482
16483 @noindent
16484 This output can be fed into @code{grotty} to get a formatted text
16485 document.
16486
16487 @item @acronym{AT&T} @code{troff} output
16488 Since a computer monitor has a very low resolution compared to modern
16489 printers the intermediate output for the X@tie{}Window devices can use
16490 the jump-and-write command with its 2-digit displacements.
16491
16492 @example
16493 @group
16494 shell> echo "hell world" | groff -Z -T X100
16495
16496 x T X100
16497 x res 100 1 1
16498 x init
16499 @end group
16500 p1
16501 x font 5 TR
16502 f5
16503 s10
16504 V16
16505 H100
16506 # write text with jump-and-write commands
16507 ch07e07l03lw06w11o07r05l03dh7
16508 n16 0
16509 @group
16510 x trailer
16511 V1100
16512 x stop
16513 @end group
16514 @end example
16515
16516 @noindent
16517 This output can be fed into @code{xditview} or @code{gxditview} for
16518 displaying in@tie{}X.
16519
16520 Due to the obsolete jump-and-write command, the text clusters in the
16521 @acronym{AT&T} @code{troff} output are almost unreadable.
16522 @end table
16523
16524 @c ---------------------------------------------------------------------
16525
16526 @node Output Language Compatibility,  , Intermediate Output Examples, gtroff Output
16527 @subsection Output Language Compatibility
16528
16529 The intermediate output language of @acronym{AT&T} @code{troff} was
16530 first documented in the @acronym{UNIX} troff manual, with later
16531 additions documented in @cite{A Typesetter-indenpendent TROFF}, written
16532 by Brian Kernighan.
16533
16534 The @code{gtroff} intermediate output format is compatible with this
16535 specification except for the following features.
16536
16537 @itemize @bullet
16538 @item
16539 The classical quasi device independence is not yet implemented.
16540
16541 @item
16542 The old hardware was very different from what we use today.  So the
16543 @code{groff} devices are also fundamentally different from the ones
16544 in @acronym{AT&T} @code{troff}.  For example, the @acronym{AT&T}
16545 @sc{PostScript} device is called @code{post} and has a resolution of
16546 only 720 units per inch, suitable for printers 20 years ago, while
16547 @code{groff}'s @code{ps} device has a resolution of 72000 units per
16548 inch.  Maybe, by implementing some rescaling mechanism similar to the
16549 classical quasi device independence, @code{groff} could emulate
16550 @acronym{AT&T}'s @code{post} device.
16551
16552 @item
16553 The B-spline command @samp{D~} is correctly handled by the intermediate
16554 output parser, but the drawing routines aren't implemented in some of
16555 the postprocessor programs.
16556
16557 @item
16558 The argument of the commands @samp{s} and @w{@samp{x H}} has the
16559 implicit unit scaled point @samp{z} in @code{gtroff}, while
16560 @acronym{AT&T} @code{troff} has point (@samp{p}).  This isn't an
16561 incompatibility but a compatible extension, for both units coincide for
16562 all devices without a @code{sizescale} parameter in the @file{DESC}
16563 file, including all postprocessors from @acronym{AT&T} and
16564 @code{groff}'s text devices.  The few @code{groff} devices with a
16565 @code{sizescale} parameter either do not exist for @acronym{AT&T}
16566 @code{troff}, have a different name, or seem to have a different
16567 resolution.  So conflicts are very unlikely.
16568
16569 @item
16570 The position changing after the commands @samp{Dp}, @samp{DP}, and
16571 @samp{Dt} is illogical, but as old versions of @code{gtroff} used this
16572 feature it is kept for compatibility reasons.
16573
16574 @ignore
16575 Temporarily, there existed some confusion on the positioning after the
16576 @samp{D} commands that are groff extensions.  This has been clarified by
16577 establishing the classical rule for all @code{groff} drawing commands:
16578
16579 @itemize
16580 @item
16581 The position after a graphic object has been drawn is at its end; for
16582 circles and ellipses, the `end' is at the right side.
16583
16584 @item
16585 From this, the positionings specified for the drawing commands above
16586 follow quite naturally.
16587 @end itemize
16588 @end ignore
16589
16590 @end itemize
16591
16592
16593 @c =====================================================================
16594
16595 @node Font Files,  , gtroff Output, File formats
16596 @section Font Files
16597 @cindex font files
16598 @cindex files, font
16599
16600 The @code{gtroff} font format is roughly a superset of the
16601 @code{ditroff} font format (as used in later versions of @acronym{AT&T}
16602 @code{troff} and its descendants).  Unlike the @code{ditroff} font
16603 format, there is no associated binary format; all files are text
16604 files.@footnote{Plan@tie{}9 @code{troff} has also abandoned the binary
16605 format.}  The font files for device @var{name} are stored in a directory
16606 @file{dev@var{name}}.  There are two types of file: a device description
16607 file called @file{DESC} and for each font@tie{}@var{f} a font file
16608 called@tie{}@file{@var{f}}.
16609
16610 @menu
16611 * DESC File Format::
16612 * Font File Format::
16613 @end menu
16614
16615 @c ---------------------------------------------------------------------
16616
16617 @node DESC File Format, Font File Format, Font Files, Font Files
16618 @subsection @file{DESC} File Format
16619 @cindex @file{DESC} file, format
16620 @cindex font description file, format
16621 @cindex format of font description file
16622 @pindex DESC@r{ file format}
16623
16624 The @file{DESC} file can contain the following types of line.  Except
16625 for the @code{charset} keyword, which must comes last (if at all), the
16626 order of the lines is not important.  Later entries in the file,
16627 however, override previous values.
16628
16629 @table @code
16630 @item charset
16631 @kindex charset
16632 This line and everything following in the file are ignored.  It is
16633 allowed for the sake of backwards compatibility.
16634
16635 @item family @var{fam}
16636 @kindex family
16637 The default font family is @var{fam}.
16638
16639 @item fonts @var{n} @var{F1} @var{F2} @var{F3} @dots{} @var{Fn}
16640 @kindex fonts
16641 Fonts @var{F1} @dots{} @var{Fn} are mounted in the font positions
16642 @var{m}+1, @dots{}, @var{m}+@var{n} where @var{m} is the number of
16643 styles.  This command may extend over more than one line.  A font name
16644 of@tie{}0 means no font is mounted on the corresponding font position.
16645
16646 @item hor @var{n}
16647 @kindex hor
16648 @cindex horizontal resolution
16649 @cindex resolution, horizontal
16650 The horizontal resolution is @var{n}@tie{}machine units.  All horizontal
16651 quantities are rounded to be multiples of this value.
16652
16653 @item image_generator @var{string}
16654 @kindex image_generator
16655 @cindex PostScript, PNG image generation
16656 @cindex PNG image generation from PostScript
16657 Needed for @code{grohtml} only.  It specifies the program to generate
16658 PNG images from @sc{PostScript} input.  Under GNU/Linux this is
16659 usually @code{gs} but under other systems (notably cygwin) it might
16660 be set to another name.
16661
16662 @item paperlength @var{n}
16663 @kindex paperlength
16664 The physical vertical dimension of the output medium in machine units.
16665 This isn't used by @code{troff} itself but by output devices.
16666 Deprecated.  Use @code{papersize} instead.
16667
16668 @item papersize @var{string} @dots{}
16669 @kindex papersize
16670 Select a paper size.  Valid values for @var{string} are the ISO paper
16671 types @code{A0}-@code{A7}, @code{B0}-@code{B7}, @code{C0}-@code{C7},
16672 @code{D0}-@code{D7}, @code{DL}, and the US paper types @code{letter},
16673 @code{legal}, @code{tabloid}, @code{ledger}, @code{statement},
16674 @code{executive}, @code{com10}, and @code{monarch}.  Case is not
16675 significant for @var{string} if it holds predefined paper types.
16676 Alternatively, @var{string} can be a file name (e.g.@:
16677 @file{/etc/papersize}); if the file can be opened, @code{groff} reads
16678 the first line and tests for the above paper sizes.  Finally,
16679 @var{string} can be a custom paper size in the format
16680 @code{@var{length},@var{width}} (no spaces before and after the comma).
16681 Both @var{length} and @var{width} must have a unit appended; valid
16682 values are @samp{i} for inches, @samp{C} for centimeters, @samp{p} for
16683 points, and @samp{P} for picas.  Example: @code{12c,235p}.  An argument
16684 that starts with a digit is always treated as a custom paper format.
16685 @code{papersize} sets both the vertical and horizontal dimension of the
16686 output medium.
16687
16688 More than one argument can be specified; @code{groff} scans from left to
16689 right and uses the first valid paper specification.
16690
16691 @item paperwidth @var{n}
16692 @kindex paperwidth
16693 The physical horizontal dimension of the output medium in machine units.
16694 This isn't used by @code{troff} itself but by output devices.
16695 Deprecated.  Use @code{papersize} instead.
16696
16697 @item pass_filenames
16698 @kindex pass_filenames
16699 Tell @code{gtroff} to emit the name of the source file currently being
16700 processed.  This is achieved by the intermediate output command
16701 @samp{F}.  Currently, this is only used by the @code{grohtml} output
16702 device.
16703
16704 @item postpro @var{program}
16705 @kindex postpro
16706 Call @var{program} as a postprocessor.  For example, the line
16707
16708 @Example
16709 postpro grodvi
16710 @endExample
16711
16712 @noindent
16713 in the file @file{devdvi/DESC} makes @code{groff} call @code{grodvi} if
16714 option @option{-Tdvi} is given (and @option{-Z} isn't used).
16715
16716 @item prepro @var{program}
16717 @kindex prepro
16718 Call @var{program} as a preprocessor.  Currently, this keyword is used
16719 by @code{groff} with option @option{-Thtml} or @option{-Txhtml} only.
16720
16721 @item print @var{program}
16722 @kindex print
16723 Use @var{program} as a spooler program for printing.  If omitted, the
16724 @option{-l} and @option{-L} options of @code{groff} are ignored.
16725
16726 @item res @var{n}
16727 @kindex res
16728 @cindex device resolution
16729 @cindex resolution, device
16730 There are @var{n}@tie{}machine units per inch.
16731
16732 @item sizes @var{s1} @var{s2} @dots{} @var{sn} 0
16733 @kindex sizes
16734 This means that the device has fonts at @var{s1}, @var{s2}, @dots{}
16735 @var{sn} scaled points.  The list of sizes must be terminated by@tie{}0
16736 (this is digit zero).  Each @var{si} can also be a range of sizes
16737 @var{m}-@var{n}.  The list can extend over more than one line.
16738
16739 @item sizescale @var{n}
16740 @kindex sizescale
16741 The scale factor for point sizes.  By default this has a value
16742 of@tie{}1.  One scaled point is equal to one point/@var{n}.  The
16743 arguments to the @code{unitwidth} and @code{sizes} commands are given in
16744 scaled points.  @xref{Fractional Type Sizes}, for more information.
16745
16746 @item styles @var{S1} @var{S2} @dots{} @var{Sm}
16747 @kindex styles
16748 The first @var{m}@tie{}font positions are associated with styles
16749 @var{S1} @dots{} @var{Sm}.
16750
16751 @item tcommand
16752 @kindex tcommand
16753 This means that the postprocessor can handle the @samp{t} and @samp{u}
16754 intermediate output commands.
16755
16756 @item unicode
16757 @kindex unicode
16758 Indicate that the output device supports the complete Unicode
16759 repertoire.  Useful only for devices that produce @emph{character
16760 entities} instead of glyphs.
16761
16762 If @code{unicode} is present, no @code{charset} section is required in
16763 the font description files since the Unicode handling built into
16764 @code{groff} is used.  However, if there are entries in a @code{charset}
16765 section, they either override the default mappings for those particular
16766 characters or add new mappings (normally for composite characters).
16767
16768 This is used for @option{-Tutf8}, @option{-Thtml}, and @option{-Txhtml}.
16769
16770 @item unitwidth @var{n}
16771 @kindex unitwidth
16772 Quantities in the font files are given in machine units for fonts whose
16773 point size is @var{n}@tie{}scaled points.
16774
16775 @item unscaled_charwidths
16776 @kindex unscaled_charwidths
16777 Make the font handling module always return unscaled character widths.
16778 Needed for the @code{grohtml} device.
16779
16780 @item use_charnames_in_special
16781 @kindex use_charnames_in_special
16782 This command indicates that @code{gtroff} should encode special
16783 characters inside special commands.  Currently, this is only used by the
16784 @code{grohtml} output device.  @xref{Postprocessor Access}.
16785
16786 @item vert @var{n}
16787 @kindex vert
16788 @cindex vertical resolution
16789 @cindex resolution, vertical
16790 The vertical resolution is @var{n}@tie{}machine units.  All vertical
16791 quantities are rounded to be multiples of this value.
16792 @end table
16793
16794 The @code{res}, @code{unitwidth}, @code{fonts}, and @code{sizes} lines
16795 are mandatory.  Other commands are ignored by @code{gtroff} but may be
16796 used by postprocessors to store arbitrary information about the device
16797 in the @file{DESC} file.
16798
16799 @kindex spare1
16800 @kindex spare2
16801 @kindex biggestfont
16802 Here a list of obsolete keywords that are recognized by @code{groff}
16803 but completely ignored: @code{spare1}, @code{spare2},
16804 @code{biggestfont}.
16805
16806 @c ---------------------------------------------------------------------
16807
16808 @node Font File Format,  , DESC File Format, Font Files
16809 @subsection Font File Format
16810 @cindex font file, format
16811 @cindex font description file, format
16812 @cindex format of font files
16813 @cindex format of font description files
16814
16815 A @dfn{font file}, also (and probably better) called a @dfn{font
16816 description file}, has two sections.  The first section is a sequence of
16817 lines each containing a sequence of blank delimited words; the first
16818 word in the line is a key, and subsequent words give a value for that
16819 key.
16820
16821 @table @code
16822 @item name @var{f}
16823 @kindex name
16824 The name of the font is@tie{}@var{f}.
16825
16826 @item spacewidth @var{n}
16827 @kindex spacewidth
16828 The normal width of a space is@tie{}@var{n}.
16829
16830 @item slant @var{n}
16831 @kindex slant
16832 The glyphs of the font have a slant of @var{n}@tie{}degrees.  (Positive
16833 means forward.)
16834
16835 @item ligatures @var{lig1} @var{lig2} @dots{} @var{lign} [0]
16836 @kindex ligatures
16837 Glyphs @var{lig1}, @var{lig2}, @dots{}, @var{lign} are ligatures;
16838 possible ligatures are @samp{ff}, @samp{fi}, @samp{fl}, @samp{ffi} and
16839 @samp{ffl}.  For backwards compatibility, the list of ligatures may be
16840 terminated with a@tie{}0.  The list of ligatures may not extend over
16841 more than one line.
16842
16843 @item special
16844 @cindex special fonts
16845 @kindex special
16846 The font is @dfn{special}; this means that when a glyph is requested
16847 that is not present in the current font, it is searched for in any
16848 special fonts that are mounted.
16849 @end table
16850
16851 Other commands are ignored by @code{gtroff} but may be used by
16852 postprocessors to store arbitrary information about the font in the font
16853 file.
16854
16855 @cindex comments in font files
16856 @cindex font files, comments
16857 @kindex #
16858 The first section can contain comments, which start with the @samp{#}
16859 character and extend to the end of a line.
16860
16861 The second section contains one or two subsections.  It must contain a
16862 @code{charset} subsection and it may also contain a @code{kernpairs}
16863 subsection.  These subsections can appear in any order.  Each subsection
16864 starts with a word on a line by itself.
16865
16866 @kindex charset
16867 The word @code{charset} starts the character set
16868 subsection.@footnote{This keyword is misnamed since it starts a list of
16869 ordered glyphs, not characters.}  The @code{charset} line is followed by
16870 a sequence of lines.  Each line gives information for one glyph.  A line
16871 comprises a number of fields separated by blanks or tabs.  The format is
16872
16873 @quotation
16874 @var{name} @var{metrics} @var{type} @var{code} [@var{entity-name}]
16875 [@code{--} @var{comment}]
16876 @end quotation
16877
16878 @cindex 8-bit input
16879 @cindex input, 8-bit
16880 @cindex accessing unnamed glyphs with @code{\N}
16881 @cindex unnamed glyphs, accessing with @code{\N}
16882 @cindex characters, unnamed, accessing with @code{\N}
16883 @cindex glyphs, unnamed, accessing with @code{\N}
16884 @kindex ---
16885 @noindent
16886 @var{name} identifies the glyph name@footnote{The distinction between
16887 input, characters, and output, glyphs, is not clearly separated in the
16888 terminology of @code{groff}; for example, the @code{char} request should
16889 be called @code{glyph} since it defines an output entity.}: If
16890 @var{name} is a single character@tie{}@var{c} then it corresponds to the
16891 @code{gtroff} input character@tie{}@var{c}; if it is of the form
16892 @samp{\@var{c}} where @var{c} is a single character, then it corresponds
16893 to the special character @code{\[@var{c}]}; otherwise it corresponds to
16894 the special character @samp{\[@var{name}]}.  If it is exactly two
16895 characters @var{xx} it can be entered as @samp{\(@var{xx}}.  Note that
16896 single-letter special characters can't be accessed as @samp{\@var{c}};
16897 the only exception is @samp{\-}, which is identical to @code{\[-]}.
16898
16899 @code{gtroff} supports 8-bit input characters; however some utilities
16900 have difficulties with eight-bit characters.  For this reason, there is
16901 a convention that the entity name @samp{char@var{n}} is equivalent to
16902 the single input character whose code is@tie{}@var{n}.  For example,
16903 @samp{char163} would be equivalent to the character with code@tie{}163,
16904 which is the pounds sterling sign in the ISO@tie{}@w{Latin-1} character
16905 set.  You shouldn't use @samp{char@var{n}} entities in font description
16906 files since they are related to input, not output.  Otherwise, you get
16907 hard-coded connections between input and output encoding, which prevents
16908 use of different (input) character sets.
16909
16910 The name @samp{---} is special and indicates that the glyph is unnamed;
16911 such glyphs can only be used by means of the @code{\N} escape sequence
16912 in @code{gtroff}.
16913
16914 The @var{type} field gives the glyph type:
16915
16916 @table @code
16917 @item 1
16918 the glyph has a descender, for example, @samp{p};
16919
16920 @item 2
16921 the glyph has an ascender, for example, @samp{b};
16922
16923 @item 3
16924 the glyph has both an ascender and a descender, for example, @samp{(}.
16925 @end table
16926
16927 The @var{code} field gives the code that the postprocessor uses to
16928 print the glyph.  The glyph can also be input to @code{gtroff} using
16929 this code by means of the @code{\N} escape sequence.  @var{code} can be
16930 any integer.  If it starts with @samp{0} it is interpreted as octal; if
16931 it starts with @samp{0x} or @samp{0X} it is interpreted as hexadecimal.
16932 Note, however, that the @code{\N} escape sequence only accepts a decimal
16933 integer.
16934
16935 The @var{entity-name} field gives an @acronym{ASCII} string identifying
16936 the glyph that the postprocessor uses to print the @code{gtroff} glyph
16937 @var{name}.  This field is optional and has been introduced so that the
16938 @code{grohtml} device driver can encode its character set.  For example,
16939 the glyph @samp{\[Po]} is represented as @samp{&pound;} in
16940 @acronym{HTML} 4.0.
16941
16942 Anything on the line after the @var{entity-name} field resp.@: after
16943 @samp{--} is ignored.
16944
16945 The @var{metrics} field has the form:
16946
16947 @display
16948 @group
16949 @var{width}[@code{,}@var{height}[@code{,}@var{depth}[@code{,}@var{italic-correction}
16950   [@code{,}@var{left-italic-correction}[@code{,}@var{subscript-correction}]]]]]
16951 @end group
16952 @end display
16953
16954 @noindent
16955 There must not be any spaces between these subfields (it has been split
16956 here into two lines for better legibility only).  Missing subfields are
16957 assumed to be@tie{}0.  The subfields are all decimal integers.  Since
16958 there is no associated binary format, these values are not required to
16959 fit into a variable of type @samp{char} as they are in @code{ditroff}.
16960 The @var{width} subfield gives the width of the glyph.  The @var{height}
16961 subfield gives the height of the glyph (upwards is positive); if a glyph
16962 does not extend above the baseline, it should be given a zero height,
16963 rather than a negative height.  The @var{depth} subfield gives the depth
16964 of the glyph, that is, the distance from the baseline to the lowest
16965 point below the baseline to which the glyph extends (downwards is
16966 positive); if a glyph does not extend below the baseline, it should be
16967 given a zero depth, rather than a negative depth.  The
16968 @var{italic-correction} subfield gives the amount of space that should
16969 be added after the glyph when it is immediately to be followed by a
16970 glyph from a roman font.  The @var{left-italic-correction} subfield
16971 gives the amount of space that should be added before the glyph when it
16972 is immediately to be preceded by a glyph from a roman font.  The
16973 @var{subscript-correction} gives the amount of space that should be
16974 added after a glyph before adding a subscript.  This should be less than
16975 the italic correction.
16976
16977 A line in the @code{charset} section can also have the format
16978
16979 @Example
16980 @var{name} "
16981 @endExample
16982
16983 @noindent
16984 This indicates that @var{name} is just another name for the glyph
16985 mentioned in the preceding line.
16986
16987 @kindex kernpairs
16988 The word @code{kernpairs} starts the kernpairs section.  This contains a
16989 sequence of lines of the form:
16990
16991 @Example
16992 @var{c1} @var{c2} @var{n}
16993 @endExample
16994
16995 @noindent
16996 This means that when glyph @var{c1} appears next to glyph @var{c2} the
16997 space between them should be increased by@tie{}@var{n}.  Most entries in
16998 the kernpairs section have a negative value for@tie{}@var{n}.
16999
17000
17001
17002 @c =====================================================================
17003 @c =====================================================================
17004
17005 @node Installation, Copying This Manual, File formats, Top
17006 @chapter Installation
17007 @cindex installation
17008
17009 @c XXX
17010
17011
17012
17013 @c =====================================================================
17014 @c =====================================================================
17015
17016 @node Copying This Manual, Request Index, Installation, Top
17017 @appendix Copying This Manual
17018
17019 @include fdl.texi
17020
17021
17022
17023 @c =====================================================================
17024 @c =====================================================================
17025
17026 @node Request Index, Escape Index, Copying This Manual, Top
17027 @appendix Request Index
17028
17029 Requests appear without the leading control character (normally either
17030 @samp{.} or @samp{'}).
17031
17032 @printindex rq
17033
17034
17035
17036 @c =====================================================================
17037 @c =====================================================================
17038
17039 @node Escape Index, Operator Index, Request Index, Top
17040 @appendix Escape Index
17041
17042 Any escape sequence @code{\@var{X}} with @var{X} not in the list below
17043 emits a warning, printing glyph @var{X}.
17044
17045 @printindex es
17046
17047
17048
17049 @c =====================================================================
17050 @c =====================================================================
17051
17052 @node Operator Index, Register Index, Escape Index, Top
17053 @appendix Operator Index
17054
17055 @printindex op
17056
17057
17058
17059 @c =====================================================================
17060 @c =====================================================================
17061
17062 @node Register Index, Macro Index, Operator Index, Top
17063 @appendix Register Index
17064
17065 The macro package or program a specific register belongs to is appended in
17066 brackets.
17067
17068 A register name@tie{}@code{x} consisting of exactly one character can be
17069 accessed as @samp{\nx}.  A register name @code{xx} consisting of exactly
17070 two characters can be accessed as @samp{\n(xx}.  Register names
17071 @code{xxx} of any length can be accessed as @samp{\n[xxx]}.
17072
17073 @printindex vr
17074
17075
17076
17077 @c =====================================================================
17078 @c =====================================================================
17079
17080 @node Macro Index, String Index, Register Index, Top
17081 @appendix Macro Index
17082
17083 The macro package a specific macro belongs to is appended in brackets.
17084 They appear without the leading control character (normally @samp{.}).
17085
17086 @printindex ma
17087
17088
17089
17090 @c =====================================================================
17091 @c =====================================================================
17092
17093 @node String Index, Glyph Name Index, Macro Index, Top
17094 @appendix String Index
17095
17096 The macro package or program a specific string belongs to is appended in
17097 brackets.
17098
17099 A string name@tie{}@code{x} consisting of exactly one character can be
17100 accessed as @samp{\*x}.  A string name @code{xx} consisting of exactly
17101 two characters can be accessed as @samp{\*(xx}.  String names @code{xxx}
17102 of any length can be accessed as @samp{\*[xxx]}.
17103
17104
17105 @printindex st
17106
17107
17108
17109 @c =====================================================================
17110 @c =====================================================================
17111
17112 @node Glyph Name Index, Font File Keyword Index, String Index, Top
17113 @appendix Glyph Name Index
17114
17115 A glyph name @code{xx} consisting of exactly two characters can be
17116 accessed as @samp{\(xx}.  Glyph names @code{xxx} of any length can be
17117 accessed as @samp{\[xxx]}.
17118
17119 @c XXX
17120
17121
17122
17123 @c =====================================================================
17124 @c =====================================================================
17125
17126 @node Font File Keyword Index, Program and File Index, Glyph Name Index, Top
17127 @appendix Font File Keyword Index
17128
17129 @printindex ky
17130
17131
17132
17133 @c =====================================================================
17134 @c =====================================================================
17135
17136 @node Program and File Index, Concept Index, Font File Keyword Index, Top
17137 @appendix Program and File Index
17138
17139 @printindex pg
17140
17141
17142
17143 @c =====================================================================
17144 @c =====================================================================
17145
17146 @node Concept Index,  , Program and File Index, Top
17147 @appendix Concept Index
17148
17149 @printindex cp
17150
17151
17152 @bye
17153
17154 @c Local Variables:
17155 @c mode: texinfo
17156 @c coding: latin-1
17157 @c End: