* tmac/s.tmac (pg@top): Don't save PO register.
[s-roff.git] / doc / groff.texinfo
blob6c60bba7e60384f2b277fee9eba081c36cb68a67
1 \input texinfo   @c -*-texinfo-*-
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.6 or newer to format this document!
8 @c
10 @c %**start of header (This is for running Texinfo on a region.)
11 @setfilename groff
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.)
17 @documentlanguage en
18 @documentencoding ISO-8859-1
21 @smallbook
23 @finalout
26 @copying
27 This manual documents GNU @code{troff} version 1.19.
29 Copyright @copyright{} 1994-2000, 2001, 2002, 2003, 2004
30 Free Software Foundation, Inc.
32 @quotation
33 Permission is granted to copy, distribute and/or modify this document
34 under the terms of the GNU Free Documentation License, Version 1.1 or
35 any later version published by the Free Software Foundation; with no
36 Invariant Sections, with the Front-Cover texts being `A GNU Manual,''
37 and with the Back-Cover Texts as in (a) below.  A copy of the
38 license is included in the section entitled `GNU Free Documentation
39 License.''
41 (a) The FSF's Back-Cover Text is: `You have freedom to copy and modify
42 this GNU Manual, like GNU software.  Copies published by the Free
43 Software Foundation raise funds for GNU development.''
44 @end quotation
45 @end copying
48 @c We use the following indices:
50 @c   cindex: concepts
51 @c   rqindex: requests
52 @c   esindex: escapes
53 @c   vindex: registers
54 @c   kindex: commands in font files
55 @c   pindex: programs and files
56 @c   tindex: environment variables
57 @c   maindex: macros
58 @c   stindex: strings
59 @c   opindex: operators
61 @c tindex and cindex are merged.
63 @defcodeindex rq
64 @defcodeindex es
65 @defcodeindex ma
66 @defcodeindex st
67 @defcodeindex op
68 @syncodeindex tp cp
71 @c To avoid uppercasing in @deffn while converting to info, we define
72 @c our special @Var{}.
74 @c Due to a (not officially documented) `feature' in makeinfo 4.0,
75 @c macros are not expanded in @deffn (but the macro definition is
76 @c properly removed), so we have to define @Var{} directly in TeX also.
78 @macro Var{arg}
79 \arg\
80 @end macro
81 @tex
82 \gdef\Var#1{\var{#1}}
83 @end tex
86 @c To assure correct HTML translation, some ugly hacks are necessary.
87 @c While processing a @def... request, the HTML translator looks at the
88 @c next line to decide whether it should start indentation or not.  If
89 @c it is something starting with @def... (e.g. @deffnx), it doesn't.
90 @c So we must assure during macro expansion that a @def... is seen.
92 @c The following macros have to be used:
94 @c One item:
96 @c   @Def...
98 @c Two items:
100 @c   @Def...List
101 @c   @Def...ListEnd
103 @c More than two:
105 @c   @Def...List
106 @c   @Def...Item
107 @c   @Def...Item
108 @c   ...
109 @c   @Def...ListEnd
111 @c The definition block must end with
113 @c   @endDef...
115 @c The above is valid for texinfo 4.0f and above.
118 @c a dummy macro to assure the `@def...'
120 @macro defdummy
121 @end macro
124 @c definition of requests
126 @macro Defreq{name, arg}
127 @deffn Request @t{.\name\} \arg\
128 @rqindex \name\
129 @end macro
131 @macro DefreqList{name, arg}
132 @deffn Request @t{.\name\} \arg\
133 @defdummy
134 @rqindex \name\
135 @end macro
137 @macro DefreqItem{name, arg}
138 @deffnx Request @t{.\name\} \arg\
139 @defdummy
140 @rqindex \name\
141 @end macro
143 @macro DefreqListEnd{name, arg}
144 @deffnx Request @t{.\name\} \arg\
145 @rqindex \name\
146 @end macro
148 @macro endDefreq
149 @end deffn
150 @end macro
153 @c definition of escapes
155 @macro Defesc{name, delimI, arg, delimII}
156 @deffn Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
157 @esindex \name\
158 @end macro
160 @macro DefescList{name, delimI, arg, delimII}
161 @deffn Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
162 @defdummy
163 @esindex \name\
164 @end macro
166 @macro DefescItem{name, delimI, arg, delimII}
167 @deffnx Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
168 @defdummy
169 @esindex \name\
170 @end macro
172 @macro DefescListEnd{name, delimI, arg, delimII}
173 @deffnx Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
174 @esindex \name\
175 @end macro
177 @macro endDefesc
178 @end deffn
179 @end macro
182 @c definition of registers
184 @macro Defreg{name}
185 @deffn Register @t{\\n[\name\]}
186 @vindex \name\
187 @end macro
189 @macro DefregList{name}
190 @deffn Register @t{\\n[\name\]}
191 @defdummy
192 @vindex \name\
193 @end macro
195 @macro DefregItem{name}
196 @deffnx Register @t{\\n[\name\]}
197 @defdummy
198 @vindex \name\
199 @end macro
201 @macro DefregListEnd{name}
202 @deffnx Register @t{\\n[\name\]}
203 @vindex \name\
204 @end macro
206 @macro endDefreg
207 @end deffn
208 @end macro
211 @c definition of registers specific to macro packages, preprocessors, etc.
213 @macro Defmpreg{name, package}
214 @deffn Register @t{\\n[\name\]}
215 @vindex \name\ @r{[}\package\@r{]}
216 @end macro
218 @macro DefmpregList{name, package}
219 @deffn Register @t{\\n[\name\]}
220 @defdummy
221 @vindex \name\ @r{[}\package\@r{]}
222 @end macro
224 @macro DefmpregItem{name, package}
225 @deffnx Register @t{\\n[\name\]}
226 @defdummy
227 @vindex \name\ @r{[}\package\@r{]}
228 @end macro
230 @macro DefmpregListEnd{name, package}
231 @deffnx Register @t{\\n[\name\]}
232 @vindex \name\ @r{[}\package\@r{]}
233 @end macro
235 @macro endDefmpreg
236 @end deffn
237 @end macro
240 @c definition of macros
242 @macro Defmac{name, arg, package}
243 @defmac @t{.\name\} \arg\
244 @maindex \name\ @r{[}\package\@r{]}
245 @end macro
247 @macro DefmacList{name, arg, package}
248 @defmac @t{.\name\} \arg\
249 @defdummy
250 @maindex \name\ @r{[}\package\@r{]}
251 @end macro
253 @macro DefmacItem{name, arg, package}
254 @defmacx @t{.\name\} \arg\
255 @defdummy
256 @maindex \name\ @r{[}\package\@r{]}
257 @end macro
259 @macro DefmacListEnd{name, arg, package}
260 @defmacx @t{.\name\} \arg\
261 @maindex \name\ @r{[}\package\@r{]}
262 @end macro
264 @macro endDefmac
265 @end defmac
266 @end macro
269 @c definition of strings
271 @macro Defstr{name, package}
272 @deffn String @t{\\*[\name\]}
273 @stindex \name\ @r{[}\package\@r{]}
274 @end macro
276 @macro DefstrList{name, package}
277 @deffn String @t{\\*[\name\]}
278 @defdummy
279 @stindex \name\ @r{[}\package\@r{]}
280 @end macro
282 @macro DefstrItem{name, package}
283 @deffnx String @t{\\*[\name\]}
284 @defdummy
285 @stindex \name\ @r{[}\package\@r{]}
286 @end macro
288 @macro DefstrListEnd{name, package}
289 @deffnx String @t{\\*[\name\]}
290 @stindex \name\ @r{[}\package\@r{]}
291 @end macro
293 @macro endDefstr
294 @end deffn
295 @end macro
298 @c our example macro
300 @macro Example
301 @example
302 @group
303 @end macro
305 @macro endExample
306 @end group
307 @end example
308 @end macro
311 @c <text>
313 @tex
314 \gdef\angles#1{\angleleft{}\r{#1}\angleright{}}
315 @end tex
317 @macro angles{text}
318 <\text\>
319 @end macro
322 @c a <= sign
324 @tex
325 \gdef\LE{\le}
326 @end tex
328 @macro LE
330 @end macro
333 @c We need special parentheses and brackets:
335 @c . Real parentheses in @deffn produce an error while compiling with
336 @c   TeX.
337 @c . Real brackets use the wrong font in @deffn, overriding @t{}.
339 @c Since macros aren't expanded in @deffn during -E, the following
340 @c definitions are for non-TeX only.
342 @c This is true for texinfo 4.0.
344 @macro lparen
346 @end macro
347 @macro rparen
349 @end macro
350 @macro lbrack
352 @end macro
353 @macro rbrack
355 @end macro
358 @c This suppresses the word `Appendix' in the appendix headers.
360 @tex
361 \gdef\gobblefirst#1#2{#2}
362 \gdef\putwordAppendix{\gobblefirst}
363 @end tex
366 @c We map some latin-1 characters to corresponding texinfo macros.
368 @tex
369 \global\catcode`^^e4\active % Ã¤
370 \gdef^^e4{\"a}
371 \global\catcode`^^c4\active % Ã„
372 \gdef^^c4{\"A}
373 \global\catcode`^^e9\active % Ã©
374 \gdef^^e9{\'e}
375 \global\catcode`^^c9\active % Ã‰
376 \gdef^^c9{\'E}
377 \global\catcode`^^f6\active % Ã¶
378 \gdef^^f6{\"o}
379 \global\catcode`^^d6\active % Ã–
380 \gdef^^d6{\"O}
381 \global\catcode`^^fc\active % Ã¼
382 \gdef^^fc{\"u}
383 \global\catcode`^^dc\active % Ãœ
384 \gdef^^dc{\"U}
385 \global\catcode`^^e6\active % Ã¦
386 \gdef^^e6{\ae}
387 \global\catcode`^^c6\active % Ã†
388 \gdef^^c6{\AE}
389 \global\catcode`^^df\active % ÃŸ
390 \gdef^^df{\ss}
391 @end tex
394 @c Note: We say `Roman numerals' but `roman font'.
397 @dircategory Typesetting
398 @direntry
399 * Groff: (groff).               The GNU troff document formatting system.
400 @end direntry
403 @titlepage
404 @title groff
405 @subtitle The GNU implementation of @code{troff}
406 @subtitle Edition 1.19.1
407 @subtitle Spring 2004
408 @author by Trent A.@tie{}Fisher
409 @author and Werner Lemberg (@email{bug-groff@@gnu.org})
411 @page
412 @vskip 0pt plus 1filll
413 @insertcopying
414 @end titlepage
417 @contents
419 @ifinfo
420 @node Top, Introduction, (dir), (dir)
421 @top GNU troff
423 @insertcopying
424 @end ifinfo
426 @ifhtml
427 @node Top, Introduction, (dir), (dir)
428 @top GNU troff
430 @insertcopying
431 @end ifhtml
433 @menu
434 * Introduction::
435 * Invoking groff::
436 * Tutorial for Macro Users::
437 * Macro Packages::
438 * gtroff Reference::
439 * Preprocessors::
440 * Output Devices::
441 * File formats::
442 * Installation::
443 * Copying This Manual::
444 * Request Index::
445 * Escape Index::
446 * Operator Index::
447 * Register Index::
448 * Macro Index::
449 * String Index::
450 * Glyph Name Index::
451 * Font File Keyword Index::
452 * Program and File Index::
453 * Concept Index::
454 @end menu
458 @c =====================================================================
459 @c =====================================================================
461 @node Introduction, Invoking groff, Top, Top
462 @chapter Introduction
463 @cindex introduction
465 GNU @code{troff} (or @code{groff}) is a system for typesetting
466 documents.  @code{troff} is very flexible and has been in existence (and
467 use) for about 3@tie{}decades.  It is quite widespread and firmly
468 entrenched in the @acronym{UNIX} community.
470 @menu
471 * What Is groff?::
472 * History::
473 * groff Capabilities::
474 * Macro Package Intro::
475 * Preprocessor Intro::
476 * Output device intro::
477 * Credits::
478 @end menu
481 @c =====================================================================
483 @node What Is groff?, History, Introduction, Introduction
484 @section What Is @code{groff}?
485 @cindex what is @code{groff}?
486 @cindex @code{groff} -- what is it?
488 @code{groff} belongs to an older generation of document preparation
489 systems, which operate more like compilers than the more recent
490 interactive @acronym{WYSIWYG}@footnote{What You See Is What You Get}
491 systems.  @code{groff} and its contemporary counterpart, @TeX{}, both
492 work using a @dfn{batch} paradigm: The input (or @dfn{source}) files are
493 normal text files with embedded formatting commands.  These files can
494 then be processed by @code{groff} to produce a typeset document on a
495 variety of devices.
497 Likewise, @code{groff} should not be confused with a @dfn{word
498 processor}, since that term connotes an integrated system that includes
499 an editor and a text formatter.  Also, many word processors follow the
500 @acronym{WYSIWYG} paradigm discussed earlier.
502 Although @acronym{WYSIWYG} systems may be easier to use, they have a
503 number of disadvantages compared to @code{troff}:
505 @itemize @bullet
506 @item
507 They must be used on a graphics display to work on a document.
509 @item
510 Most of the @acronym{WYSIWYG} systems are either non-free or are not
511 very portable.
513 @item
514 @code{troff} is firmly entrenched in all @acronym{UNIX} systems.
516 @item
517 It is difficult to have a wide range of capabilities available within
518 the confines of a GUI/window system.
520 @item
521 It is more difficult to make global changes to a document.
522 @end itemize
524 @quotation
525 ``GUIs normally make it simple to accomplish simple actions and
526 impossible to accomplish complex actions.''  --Doug Gwyn (22/Jun/91 in
527 @code{comp.unix.wizards})
528 @end quotation
531 @c =====================================================================
533 @node History, groff Capabilities, What Is groff?, Introduction
534 @section History
535 @cindex history
537 @cindex @code{runoff}, the program
538 @cindex @code{rf}, the program
539 @code{troff} can trace its origins back to a formatting program called
540 @code{runoff}, written by J.@tie{}E.@tie{}Saltzer, which ran on MIT's CTSS
541 operating system in the mid-sixties.  This name came from the common
542 phrase of the time ``I'll run off a document.''  Bob Morris ported it to
543 the 635 architecture and called the program @code{roff} (an abbreviation
544 of @code{runoff}).  It was rewritten as @code{rf} for the @w{PDP-7}
545 (before having @acronym{UNIX}), and at the same time (1969), Doug
546 McIllroy rewrote an extended and simplified version of @code{roff} in
547 the @acronym{BCPL} programming language.
549 @cindex @code{roff}, the program
550 The first version of @acronym{UNIX} was developed on a @w{PDP-7} which
551 was sitting around Bell Labs.  In 1971 the developers wanted to get a
552 @w{PDP-11} for further work on the operating system.  In order to
553 justify the cost for this system, they proposed that they would
554 implement a document formatting system for the @acronym{AT&T} patents
555 division.  This first formatting program was a reimplementation of
556 McIllroy's @code{roff}, written by J.@tie{}F.@tie{}Ossanna.
558 @cindex @code{nroff}, the program
559 When they needed a more flexible language, a new version of @code{roff}
560 called @code{nroff} (``Newer @code{roff}'') was written.  It had a much
561 more complicated syntax, but provided the basis for all future versions.
562 When they got a Graphic Systems CAT Phototypesetter, Ossanna wrote a
563 version of @code{nroff} that would drive it.  It was dubbed
564 @code{troff}, for ``typesetter @code{roff}'', although many people have
565 speculated that it actually means ``Times @code{roff}'' because of the
566 use of the Times font family in @code{troff} by default.  As such, the
567 name @code{troff} is pronounced `@w{t-roff}' rather than `trough'.
569 With @code{troff} came @code{nroff} (they were actually the same program
570 except for some @samp{#ifdef}s), which was for producing output for line
571 printers and character terminals.  It understood everything @code{troff}
572 did, and ignored the commands which were not applicable (e.g.@: font
573 changes).
575 Since there are several things which cannot be done easily in
576 @code{troff}, work on several preprocessors began.  These programs would
577 transform certain parts of a document into @code{troff}, which made a
578 very natural use of pipes in @acronym{UNIX}.
580 The @code{eqn} preprocessor allowed mathematical formulæ to be
581 specified in a much simpler and more intuitive manner.  @code{tbl} is a
582 preprocessor for formatting tables.  The @code{refer} preprocessor (and
583 the similar program, @code{bib}) processes citations in a document
584 according to a bibliographic database.
586 Unfortunately, Ossanna's @code{troff} was written in @w{PDP-11} assembly
587 language and produced output specifically for the CAT phototypesetter.
588 He rewrote it in C, although it was now 7000@tie{}lines of uncommented
589 code and still dependent on the CAT.  As the CAT became less common, and
590 was no longer supported by the manufacturer, the need to make it support
591 other devices became a priority.  However, before this could be done,
592 Ossanna was killed in a car accident.
594 @pindex ditroff
595 @cindex @code{ditroff}, the program
596 So, Brian Kernighan took on the task of rewriting @code{troff}.  The
597 newly rewritten version produced device independent code which was
598 very easy for postprocessors to read and translate to the appropriate
599 printer codes.  Also, this new version of @code{troff} (called
600 @code{ditroff} for ``device independent @code{troff}'') had several
601 extensions, which included drawing functions.
603 Due to the additional abilities of the new version of @code{troff},
604 several new preprocessors appeared.  The @code{pic} preprocessor
605 provides a wide range of drawing functions.  Likewise the @code{ideal}
606 preprocessor did the same, although via a much different paradigm.  The
607 @code{grap} preprocessor took specifications for graphs, but, unlike
608 other preprocessors, produced @code{pic} code.
610 James Clark began work on a GNU implementation of @code{ditroff} in
611 early@tie{}1989.  The first version, @code{groff}@tie{}0.3.1, was released
612 June@tie{}1990.  @code{groff} included:
614 @itemize @bullet
615 @item
616 A replacement for @code{ditroff} with many extensions.
618 @item
619 The @code{soelim}, @code{pic}, @code{tbl}, and @code{eqn} preprocessors.
621 @item
622 Postprocessors for character devices, @sc{PostScript}, @TeX{} DVI, and
623 X@tie{}Windows.  GNU @code{troff} also eliminated the need for a
624 separate @code{nroff} program with a postprocessor which would produce
625 @acronym{ASCII} output.
627 @item
628 A version of the @file{me} macros and an implementation of the
629 @file{man} macros.
630 @end itemize
632 Also, a front-end was included which could construct the, sometimes
633 painfully long, pipelines required for all the post- and preprocessors.
635 Development of GNU @code{troff} progressed rapidly, and saw the
636 additions of a replacement for @code{refer}, an implementation of the
637 @file{ms} and @file{mm} macros, and a program to deduce how to format a
638 document (@code{grog}).
640 It was declared a stable (i.e.@: non-beta) package with the release of
641 version@tie{}1.04 around November@tie{}1991.
643 Beginning in@tie{}1999, @code{groff} has new maintainers (the package was
644 an orphan for a few years).  As a result, new features and programs like
645 @code{grn}, a preprocessor for gremlin images, and an output device to
646 produce @acronym{HTML} output have been added.
649 @c =====================================================================
651 @node groff Capabilities, Macro Package Intro, History, Introduction
652 @section @code{groff} Capabilities
653 @cindex @code{groff} capabilities
654 @cindex capabilities of @code{groff}
656 So what exactly is @code{groff} capable of doing?  @code{groff} provides
657 a wide range of low-level text formatting operations.  Using these, it
658 is possible to perform a wide range of formatting tasks, such as
659 footnotes, table of contents, multiple columns, etc.  Here's a list of
660 the most important operations supported by @code{groff}:
662 @itemize @bullet
663 @item
664 text filling, adjusting, and centering
666 @item
667 hyphenation
669 @item
670 page control
672 @item
673 font and glyph size control
675 @item
676 vertical spacing (e.g.@: double-spacing)
678 @item
679 line length and indenting
681 @item
682 macros, strings, diversions, and traps
684 @item
685 number registers
687 @item
688 tabs, leaders, and fields
690 @item
691 input and output conventions and character translation
693 @item
694 overstrike, bracket, line drawing, and zero-width functions
696 @item
697 local horizontal and vertical motions and the width function
699 @item
700 three-part titles
702 @item
703 output line numbering
705 @item
706 conditional acceptance of input
708 @item
709 environment switching
711 @item
712 insertions from the standard input
714 @item
715 input/output file switching
717 @item
718 output and error messages
719 @end itemize
722 @c =====================================================================
724 @node Macro Package Intro, Preprocessor Intro, groff Capabilities, Introduction
725 @section Macro Packages
726 @cindex macro packages
728 Since @code{groff} provides such low-level facilities, it can be quite
729 difficult to use by itself.  However, @code{groff} provides a
730 @dfn{macro} facility to specify how certain routine operations
731 (e.g.@tie{}starting paragraphs, printing headers and footers, etc.)@:
732 should be done.  These macros can be collected together into a @dfn{macro
733 package}.  There are a number of macro packages available; the most
734 common (and the ones described in this manual) are @file{man},
735 @file{mdoc}, @file{me}, @file{ms}, and @file{mm}.
738 @c =====================================================================
740 @node Preprocessor Intro, Output device intro, Macro Package Intro, Introduction
741 @section Preprocessors
742 @cindex preprocessors
744 Although @code{groff} provides most functions needed to format a
745 document, some operations would be unwieldy (e.g.@: to draw pictures).
746 Therefore, programs called @dfn{preprocessors} were written which
747 understand their own language and produce the necessary @code{groff}
748 operations.  These preprocessors are able to differentiate their own
749 input from the rest of the document via markers.
751 To use a preprocessor, @acronym{UNIX} pipes are used to feed the output
752 from the preprocessor into @code{groff}.  Any number of preprocessors
753 may be used on a given document; in this case, the preprocessors are
754 linked together into one pipeline.  However, with @code{groff}, the user
755 does not need to construct the pipe, but only tell @code{groff} what
756 preprocessors to use.
758 @code{groff} currently has preprocessors for producing tables
759 (@code{tbl}), typesetting equations (@code{eqn}), drawing pictures
760 (@code{pic} and @code{grn}), and for processing bibliographies
761 (@code{refer}).  An associated program which is useful when dealing with
762 preprocessors is @code{soelim}.
764 A free implementation of @code{grap}, a preprocessor for drawing graphs,
765 can be obtained as an extra package; @code{groff} can use @code{grap}
766 also.
768 There are other preprocessors in existence, but, unfortunately, no free
769 implementations are available.  Among them are preprocessors for drawing
770 mathematical pictures (@code{ideal}) and chemical structures
771 (@code{chem}).
774 @c =====================================================================
776 @node Output device intro, Credits, Preprocessor Intro, Introduction
777 @section Output Devices
778 @cindex postprocessors
779 @cindex output devices
780 @cindex devices for output
782 @code{groff} actually produces device independent code which may be
783 fed into a postprocessor to produce output for a particular device.
784 Currently, @code{groff} has postprocessors for @sc{PostScript}
785 devices, character terminals, X@tie{}Windows (for previewing), @TeX{}
786 DVI format, HP LaserJet@tie{}4 and Canon LBP printers (which use
787 @acronym{CAPSL}), and @acronym{HTML}.
790 @c =====================================================================
792 @node Credits,  , Output device intro, Introduction
793 @section Credits
794 @cindex credits
796 Large portions of this manual were taken from existing documents, most
797 notably, the manual pages for the @code{groff} package by James Clark,
798 and Eric Allman's papers on the @file{me} macro package.
800 The section on the @file{man} macro package is partly based on
801 Susan@tie{}G.@: Kleinmann's @file{groff_man} manual page written for the
802 Debian GNU/Linux system.
804 Larry Kollar contributed the section in the @file{ms} macro package.
808 @c =====================================================================
809 @c =====================================================================
811 @node Invoking groff, Tutorial for Macro Users, Introduction, Top
812 @chapter Invoking @code{groff}
813 @cindex invoking @code{groff}
814 @cindex @code{groff} invocation
816 This section focuses on how to invoke the @code{groff} front end.  This
817 front end takes care of the details of constructing the pipeline among
818 the preprocessors, @code{gtroff} and the postprocessor.
820 It has become a tradition that GNU programs get the prefix @samp{g} to
821 distinguish it from its original counterparts provided by the host (see
822 @ref{Environment}, for more details).  Thus, for example, @code{geqn} is
823 GNU @code{eqn}.  On operating systems like GNU/Linux or the Hurd, which
824 don't contain proprietary versions of @code{troff}, and on
825 MS-DOS/MS-Windows, where @code{troff} and associated programs are not
826 available at all, this prefix is omitted since GNU @code{troff} is the
827 only used incarnation of @code{troff}.  Exception: @samp{groff} is never
828 replaced by @samp{roff}.
830 In this document, we consequently say @samp{gtroff} when talking about
831 the GNU @code{troff} program.  All other implementations of @code{troff}
832 are called @acronym{AT&T} @code{troff} which is the common origin of
833 all @code{troff} derivates (with more or less compatible changes).
834 Similarly, we say @samp{gpic}, @samp{geqn}, etc.
836 @menu
837 * Groff Options::
838 * Environment::
839 * Macro Directories::
840 * Font Directories::
841 * Paper Size::
842 * Invocation Examples::
843 @end menu
846 @c =====================================================================
848 @node Groff Options, Environment, Invoking groff, Invoking groff
849 @section Options
850 @cindex options
852 @pindex groff
853 @pindex gtroff
854 @pindex gpic
855 @pindex geqn
856 @pindex ggrn
857 @pindex grap
858 @pindex gtbl
859 @pindex grefer
860 @pindex gsoelim
861 @code{groff} normally runs the @code{gtroff} program and a postprocessor
862 appropriate for the selected device.  The default device is @samp{ps}
863 (but it can be changed when @code{groff} is configured and built).  It
864 can optionally preprocess with any of @code{gpic}, @code{geqn},
865 @code{gtbl}, @code{ggrn}, @code{grap}, @code{grefer}, or @code{gsoelim}.
867 This section only documents options to the @code{groff} front end.  Many
868 of the arguments to @code{groff} are passed on to @code{gtroff},
869 therefore those are also included.  Arguments to pre- or postprocessors
870 can be found in @ref{Invoking gpic}, @ref{Invoking geqn}, @ref{Invoking
871 gtbl}, @ref{Invoking ggrn}, @ref{Invoking grefer}, @ref{Invoking
872 gsoelim}, @ref{Invoking grotty}, @ref{Invoking grops}, @ref{Invoking
873 grohtml}, @ref{Invoking grodvi}, @ref{Invoking grolj4}, @ref{Invoking
874 grolbp}, and @ref{Invoking gxditview}.
876 The command line format for @code{groff} is:
878 @Example
879 groff [ -abceghilpstvzCEGNRSUVXZ ] [ -F@var{dir} ] [ -m@var{name} ]
880       [ -T@var{def} ] [ -f@var{fam} ] [ -w@var{name} ] [ -W@var{name} ]
881       [ -M@var{dir} ] [ -d@var{cs} ] [ -r@var{cn} ] [ -n@var{num} ]
882       [ -o@var{list} ] [ -P@var{arg} ] [ -L@var{arg} ] [ -I@var{dir} ]
883       [ @var{files}@dots{} ]
884 @endExample
886 The command line format for @code{gtroff} is as follows.
888 @Example
889 gtroff [ -abcivzCERU ] [ -w@var{name} ] [ -W@var{name} ] [ -d@var{cs} ]
890        [ -f@var{fam} ] [ -m@var{name} ] [ -n@var{num} ]
891        [ -o@var{list} ] [ -r@var{cn} ] [ -T@var{name} ]
892        [ -F@var{dir} ] [ -M@var{dir} ] [ @var{files}@dots{} ]
893 @endExample
895 @noindent
896 Obviously, many of the options to @code{groff} are actually passed on to
897 @code{gtroff}.
899 Options without an argument can be grouped behind a single@tie{}@option{-}.
900 A filename of@tie{}@file{-} denotes the standard input.  It is possible to
901 have whitespace between an option and its parameter.
903 The @code{grog} command can be used to guess the correct @code{groff}
904 command to format a file.
906 Here's the description of the command-line options:
908 @cindex command-line options
909 @table @samp
910 @item -h
911 Print a help message.
913 @item -e
914 Preprocess with @code{geqn}.
916 @item -t
917 Preprocess with @code{gtbl}.
919 @item -g
920 Preprocess with @code{ggrn}.
922 @item -G
923 Preprocess with @code{grap}.
925 @item -p
926 Preprocess with @code{gpic}.
928 @item -s
929 Preprocess with @code{gsoelim}.
931 @item -c
932 Suppress color output.
934 @item -R
935 Preprocess with @code{grefer}.  No mechanism is provided for passing
936 arguments to @code{grefer} because most @code{grefer} options have
937 equivalent commands which can be included in the file.  @xref{grefer},
938 for more details.
940 @pindex troffrc
941 @pindex troffrc-end
942 Note that @code{gtroff} also accepts a @option{-R} option, which is not
943 accessible via @code{groff}.  This option prevents the loading of the
944 @file{troffrc} and @file{troffrc-end} files.
946 @item -v
947 Make programs run by @code{groff} print out their version number.
949 @item -V
950 Print the pipeline on @code{stdout} instead of executing it.  If specified
951 more than once, print the pipeline on @code{stderr} and execute it.
953 @item -z
954 Suppress output from @code{gtroff}.  Only error messages are printed.
956 @item -Z
957 Do not postprocess the output of @code{gtroff}.  Normally @code{groff}
958 automatically runs the appropriate postprocessor.
960 @item -P@var{arg}
961 Pass @var{arg} to the postprocessor.  Each argument should be passed
962 with a separate @option{-P} option.  Note that @code{groff} does not
963 prepend @samp{-} to @var{arg} before passing it to the postprocessor.
965 @item -l
966 Send the output to a spooler for printing.  The command used for this is
967 specified by the @code{print} command in the device description file
968 (see @ref{Font Files}, for more info).  If not present, @option{-l} is
969 ignored.
971 @item -L@var{arg}
972 Pass @var{arg} to the spooler.  Each argument should be passed with a
973 separate @option{-L} option.  Note that @code{groff} does not prepend
974 a @samp{-} to @var{arg} before passing it to the postprocessor.
975 If the @code{print} keyword in the device description file is missing,
976 @option{-L} is ignored.
978 @item -T@var{dev}
979 Prepare output for device @var{dev}.  The default device is @samp{ps},
980 unless changed when @code{groff} was configured and built.  The
981 following are the output devices currently available:
983 @table @code
984 @item ps
985 For @sc{PostScript} printers and previewers.
987 @item dvi
988 For @TeX{} DVI format.
990 @item X75
991 For a 75@dmn{dpi} X11 previewer.
993 @item X75-12
994 For a 75@dmn{dpi} X11 previewer with a 12@dmn{pt} base font in the
995 document.
997 @item X100
998 For a 100@dmn{dpi} X11 previewer.
1000 @item X100-12
1001 For a 100@dmn{dpi} X11 previewer with a 12@dmn{pt} base font in the
1002 document.
1004 @item ascii
1005 @cindex encoding, output, @acronym{ASCII}
1006 @cindex @acronym{ASCII}, output encoding
1007 @cindex output encoding, @acronym{ASCII}
1008 For typewriter-like devices using the (7-bit) @acronym{ASCII}
1009 character set.
1011 @item latin1
1012 @cindex encoding, output, @w{latin-1} (ISO @w{8859-1})
1013 @cindex @w{latin-1} (ISO @w{8859-1}), output encoding
1014 @cindex ISO @w{8859-1} (@w{latin-1}), output encoding
1015 @cindex output encoding, @w{latin-1} (ISO @w{8859-1})
1016 For typewriter-like devices that support the @w{Latin-1}
1017 (ISO@tie{}@w{8859-1}) character set.
1019 @item utf8
1020 @cindex encoding, output, @w{utf-8}
1021 @cindex @w{utf-8}, output encoding
1022 @cindex output encoding, @w{utf-8}
1023 For typewriter-like devices which use the Unicode (ISO@tie{}10646)
1024 character set with @w{UTF-8} encoding.
1026 @item cp1047
1027 @cindex encoding, output, @acronym{EBCDIC}
1028 @cindex @acronym{EBCDIC}, output encoding
1029 @cindex output encoding, @acronym{EBCDIC}
1030 @cindex encoding, output, cp1047
1031 @cindex cp1047, output encoding
1032 @cindex output encoding, cp1047
1033 @cindex IBM cp1047 output encoding
1034 For typewriter-like devices which use the @acronym{EBCDIC} encoding IBM
1035 cp1047.
1037 @item lj4
1038 For HP LaserJet4-compatible (or other PCL5-compatible) printers.
1040 @item lbp
1041 For Canon @acronym{CAPSL} printers (@w{LBP-4} and @w{LBP-8} series laser
1042 printers).
1044 @pindex pre-grohtml
1045 @pindex post-grohtml
1046 @cindex @code{grohtml}, the program
1047 @item html
1048 To produce @acronym{HTML} output.  Note that the @acronym{HTML} driver
1049 consists of two parts, a preprocessor (@code{pre-grohtml}) and a
1050 postprocessor (@code{post-grohtml}).
1051 @end table
1053 @cindex output device name string register (@code{.T})
1054 @cindex output device usage number register (@code{.T})
1055 The predefined @code{gtroff} string register @code{.T} contains the
1056 current output device; the read-only number register @code{.T} is set
1057 to@tie{}1 if this option is used (which is always true if @code{groff} is
1058 used to call @code{gtroff}).  @xref{Built-in Registers}.
1060 The postprocessor to be used for a device is specified by the
1061 @code{postpro} command in the device description file.  (@xref{Font
1062 Files}, for more info.)  This can be overridden with the @option{-X}
1063 option.
1065 @item -X
1066 Preview with @code{gxditview} instead of using the usual postprocessor.
1067 This is unlikely to produce good results except with @option{-Tps}.
1069 Note that this is not the same as using @option{-TX75} or
1070 @option{-TX100} to view a document with @code{gxditview}: The former
1071 uses the metrics of the specified device, whereas the latter uses
1072 X-specific fonts and metrics.
1074 @item -N
1075 Don't allow newlines with @code{eqn} delimiters.  This is the same as
1076 the @option{-N} option in @code{geqn}.
1078 @item -S
1079 @cindex @code{open} request, and safer mode
1080 @cindex @code{opena} request, and safer mode
1081 @cindex @code{pso} request, and safer mode
1082 @cindex @code{sy} request, and safer mode
1083 @cindex @code{pi} request, and safer mode
1084 @cindex safer mode
1085 @cindex mode, safer
1086 Safer mode.  Pass the @option{-S} option to @code{gpic} and disable the
1087 @code{open}, @code{opena}, @code{pso}, @code{sy}, and @code{pi}
1088 requests.  For security reasons, this is enabled by default.
1090 @item -U
1091 @cindex mode, unsafe
1092 @cindex unsafe mode
1093 Unsafe mode.  This enables the @code{open}, @code{opena}, @code{pso},
1094 @code{sy}, and @code{pi} requests.
1096 @item -a
1097 @cindex @acronym{ASCII} approximation output register (@code{.A})
1098 Generate an @acronym{ASCII} approximation of the typeset output.  The
1099 read-only register @code{.A} is then set to@tie{}1.  @xref{Built-in
1100 Registers}.  A typical example is
1102 @Example
1103 groff -a -man -Tdvi troff.man | less
1104 @endExample
1106 @noindent
1107 which shows how lines are broken for the DVI device.  Note that this
1108 option is rather useless today since graphic output devices are
1109 available virtually everywhere.
1111 @item -b
1112 Print a backtrace with each warning or error message.  This backtrace
1113 should help track down the cause of the error.  The line numbers given
1114 in the backtrace may not always be correct: @code{gtroff} can get
1115 confused by @code{as} or @code{am} requests while counting line numbers.
1117 @item -i
1118 Read the standard input after all the named input files have been
1119 processed.
1121 @item -w@var{name}
1122 Enable warning @var{name}.  Available warnings are described in
1123 @ref{Debugging}.  Multiple @option{-w} options are allowed.
1125 @item -W@var{name}
1126 Inhibit warning @var{name}.  Multiple @option{-W} options are allowed.
1128 @item -E
1129 Inhibit all error messages.
1131 @item -C
1132 Enable compatibility mode.  @xref{Implementation Differences}, for the
1133 list of incompatibilities between @code{groff} and @acronym{AT&T}
1134 @code{troff}.
1136 @item -d@var{c}@var{s}
1137 @itemx -d@var{name}=@var{s}
1138 Define @var{c} or @var{name} to be a string@tie{}@var{s}.  @var{c}@tie{}must
1139 be a one-letter name; @var{name} can be of arbitrary length.  All string
1140 assignments happen before loading any macro file (including the start-up
1141 file).
1143 @item -f@var{fam}
1144 Use @var{fam} as the default font family.  @xref{Font Families}.
1146 @item -m@var{name}
1147 Read in the file @file{@var{name}.tmac}.  Normally @code{groff} searches
1148 for this in its macro directories.  If it isn't found, it tries
1149 @file{tmac.@var{name}} (searching in the same directories).
1151 @item -n@var{num}
1152 Number the first page @var{num}.
1154 @item -o@var{list}
1155 @cindex print current page register (@code{.P})
1156 Output only pages in @var{list}, which is a comma-separated list of page
1157 ranges; @samp{@var{n}} means print page@tie{}@var{n}, @samp{@var{m}-@var{n}}
1158 means print every page between @var{m} and@tie{}@var{n}, @samp{-@var{n}}
1159 means print every page up to@tie{}@var{n}, @samp{@var{n}-} means print every
1160 page beginning with@tie{}@var{n}.  @code{gtroff} exits after printing the
1161 last page in the list.  All the ranges are inclusive on both ends.
1163 Within @code{gtroff}, this information can be extracted with the
1164 @samp{.P} register.  @xref{Built-in Registers}.
1166 If your document restarts page numbering at the beginning of each
1167 chapter, then @code{gtroff} prints the specified page range for each
1168 chapter.
1170 @item -r@var{c}@var{n}
1171 @itemx -r@var{name}=@var{n}
1172 Set number register@tie{}@var{c} or @var{name} to the value@tie{}@var{n}.
1173 @var{c}@tie{}must be a one-letter name; @var{name} can be of arbitrary
1174 length.  @var{n}@tie{}can be any @code{gtroff} numeric expression.  All
1175 register assignments happen before loading any macro file (including
1176 the start-up file).
1178 @item -F@var{dir}
1179 Search @file{@var{dir}} for subdirectories @file{dev@var{name}}
1180 (@var{name} is the name of the device), for the @file{DESC} file, and
1181 for font files before looking in the standard directories (@pxref{Font
1182 Directories}).  This option is passed to all pre- and postprocessors
1183 using the @env{GROFF_FONT_PATH} environment variable.
1185 @item -M@var{dir}
1186 Search directory @file{@var{dir}} for macro files before the standard
1187 directories (@pxref{Macro Directories}).
1189 @item -I@var{dir}
1190 This option may be used to specify a directory to search for files.
1191 It is passed to the following programs:
1193 @itemize
1194 @item
1195 @code{gsoelim} (see @ref{gsoelim} for more details);
1196 it also implies @code{groff}'s @option{-s} option.
1198 @item
1199 @code{gtroff}; it is used to search files named in the @code{psbb} and
1200 @code{so} requests.
1202 @item
1203 @code{grops}; it is used to search files named in the
1204 @w{@code{\X'ps: import}} and @w{@code{\X'ps: file}} escapes.
1205 @end itemize
1207 The current directory is always searched first. This option may be specified
1208 more than once; the directories will be searched in the order specified. No
1209 directory search is performed for files specified using an absolute path.
1210 @end table
1213 @c =====================================================================
1215 @node Environment, Macro Directories, Groff Options, Invoking groff
1216 @section Environment
1217 @cindex environment variables
1218 @cindex variables in environment
1220 There are also several environment variables (of the operating system,
1221 not within @code{gtroff}) which can modify the behavior of @code{groff}.
1223 @table @code
1224 @item GROFF_COMMAND_PREFIX
1225 @tindex GROFF_COMMAND_PREFIX@r{, environment variable}
1226 @cindex command prefix
1227 @cindex prefix, for commands
1228 If this is set to@tie{}@var{X}, then @code{groff} runs @code{@var{X}troff}
1229 instead of @code{gtroff}.  This also applies to @code{tbl}, @code{pic},
1230 @code{eqn}, @code{grn}, @code{refer}, and @code{soelim}.  It does not
1231 apply to @code{grops}, @code{grodvi}, @code{grotty}, @code{pre-grohtml},
1232 @code{post-grohtml}, @code{grolj4}, and @code{gxditview}.
1234 The default command prefix is determined during the installation process.
1235 If a non-GNU troff system is found, prefix @samp{g} is used, none
1236 otherwise.
1238 @item GROFF_TMAC_PATH
1239 @tindex GROFF_TMAC_PATH@r{, environment variable}
1240 A colon-separated list of directories in which to search for macro files
1241 (before the default directories are tried).  @xref{Macro Directories}.
1243 @item GROFF_TYPESETTER
1244 @tindex GROFF_TYPESETTER@r{, environment variable}
1245 The default output device.
1247 @item GROFF_FONT_PATH
1248 @tindex GROFF_FONT_PATH@r{, environment variable}
1249 A colon-separated list of directories in which to search for the
1250 @code{dev}@var{name} directory (before the default directories are
1251 tried).  @xref{Font Directories}.
1253 @item GROFF_BIN_PATH
1254 @tindex GROFF_BIN_PATH@r{, environment variable}
1255 This search path, followed by @code{PATH}, is used for commands executed
1256 by @code{groff}.
1258 @item GROFF_TMPDIR
1259 @tindex GROFF_TMPDIR@r{, environment variable}
1260 @tindex TMPDIR@r{, environment variable}
1261 The directory in which @code{groff} creates temporary files.  If this is
1262 not set and @env{TMPDIR} is set, temporary files are created in that
1263 directory.  Otherwise temporary files are created in a system-dependent
1264 default directory (on Unix and GNU/Linux systems, this is usually
1265 @file{/tmp}).  @code{grops}, @code{grefer}, @code{pre-grohtml}, and
1266 @code{post-grohtml} can create temporary files in this directory.
1267 @end table
1269 Note that MS-DOS and MS-Windows ports of @code{groff} use semi-colons,
1270 rather than colons, to separate the directories in the lists described
1271 above.
1274 @c =====================================================================
1276 @node Macro Directories, Font Directories, Environment, Invoking groff
1277 @section Macro Directories
1278 @cindex macro directories
1279 @cindex directories for macros
1280 @cindex searching macros
1281 @cindex macros, searching
1283 All macro file names must be named @code{@var{name}.tmac} or
1284 @code{tmac.@var{name}} to make the @option{-m@var{name}} command line
1285 option work.  The @code{mso} request doesn't have this restriction; any
1286 file name can be used, and @code{gtroff} won't try to append or prepend
1287 the @samp{tmac} string.
1289 @cindex tmac, directory
1290 @cindex directory, for tmac files
1291 @cindex tmac, path
1292 @cindex path, for tmac files
1293 @cindex searching macro files
1294 @cindex macro files, searching
1295 @cindex files, macro, searching
1296 Macro files are kept in the @dfn{tmac directories}, all of which
1297 constitute the @dfn{tmac path}.  The elements of the search path for
1298 macro files are (in that order):
1300 @itemize @bullet
1301 @item
1302 The directories specified with @code{gtroff}'s or @code{groff}'s
1303 @option{-M} command line option.
1305 @item
1306 @tindex GROFF_TMAC_PATH@r{, environment variable}
1307 The directories given in the @env{GROFF_TMAC_PATH} environment
1308 variable.
1310 @item
1311 @cindex safer mode
1312 @cindex mode, safer
1313 @cindex unsafe mode
1314 @cindex mode, unsafe
1315 @cindex current directory
1316 @cindex directory, current
1317 The current directory (only if in unsafe mode using the @option{-U}
1318 command line switch).
1320 @item
1321 @cindex home directory
1322 @cindex directory, home
1323 The home directory.
1325 @item
1326 @cindex site-specific directory
1327 @cindex directory, site-specific
1328 @cindex platform-specific directory
1329 @cindex directory, platform-specific
1330 A platform-dependent directory, a site-specific (platform-independent)
1331 directory, and the main tmac directory; the default locations are
1333 @Example
1334 /usr/local/lib/groff/site-tmac
1335 /usr/local/share/groff/site-tmac
1336 /usr/local/share/groff/1.18.2/tmac
1337 @endExample
1339 @noindent
1340 assuming that the version of @code{groff} is 1.18.2, and the installation
1341 prefix was @file{/usr/local}.  It is possible to fine-tune those
1342 directories during the installation process.
1343 @end itemize
1346 @c =====================================================================
1348 @node Font Directories, Paper Size, Macro Directories, Invoking groff
1349 @section Font Directories
1350 @cindex font directories
1351 @cindex directories for fonts
1352 @cindex searching fonts
1353 @cindex fonts, searching
1355 Basically, there is no restriction how font files for @code{groff} are
1356 named and how long font names are; however, to make the font family
1357 mechanism work (@pxref{Font Families}), fonts within a family should
1358 start with the family name, followed by the shape.  For example, the
1359 Times family uses @samp{T} for the family name and @samp{R}, @samp{B},
1360 @samp{I}, and @samp{BI} to indicate the shapes `roman', `bold',
1361 `italic', and `bold italic', respectively.  Thus the final font names
1362 are @samp{TR}, @samp{TB}, @samp{TI}, and @samp{TBI}.
1364 @cindex font path
1365 @cindex path, for font files
1366 All font files are kept in the @dfn{font directories} which constitute
1367 the @dfn{font path}.  The file search functions will always append the
1368 directory @code{dev}@var{name}, where @var{name} is the name of the
1369 output device.  Assuming, say, DVI output, and @file{/foo/bar} as a
1370 font directory, the font files for @code{grodvi} must be in
1371 @file{/foo/bar/devdvi}.
1373 The elements of the search path for font files are (in that order):
1375 @itemize @bullet
1376 @item
1377 The directories specified with @code{gtroff}'s or @code{groff}'s
1378 @option{-F} command line option.  All device drivers and some
1379 preprocessors also have this option.
1381 @item
1382 @tindex GROFF_FONT_PATH@r{, environment variable}
1383 The directories given in the @env{GROFF_FONT_PATH} environment
1384 variable.
1386 @item
1387 @cindex site-specific directory
1388 @cindex directory, site-specific
1389 A site-specific directory and the main font directory; the default
1390 locations are
1392 @Example
1393 /usr/local/share/groff/site-font
1394 /usr/local/share/groff/1.18.2/font
1395 @endExample
1397 @noindent
1398 assuming that the version of @code{groff} is 1.18.2, and the installation
1399 prefix was @file{/usr/local}.  It is possible to fine-tune those
1400 directories during the installation process.
1401 @end itemize
1404 @c =====================================================================
1406 @node Paper Size, Invocation Examples, Font Directories, Invoking groff
1407 @section Paper Size
1408 @cindex paper size
1409 @cindex size, paper
1410 @cindex landscape page orientation
1411 @cindex orientation, landscape
1412 @cindex page orientation, landscape
1414 In groff, the page size for @code{gtroff} and for output devices are
1415 handled separately.  @xref{Page Layout}, for vertical manipulation of
1416 the page size.  @xref{Line Layout}, for horizontal changes.
1418 A default paper size can be set in the device's @file{DESC} file.  Most
1419 output devices also have a command line option @option{-p} to override
1420 the default paper size and option @option{-l} to use landscape
1421 orientation.  @xref{DESC File Format}, for a description of the
1422 @code{papersize} keyword which takes the same argument as @option{-p}.
1424 @pindex papersize.tmac
1425 @pindex troffrc
1426 A convenient shorthand to set a particular paper size for @code{gtroff}
1427 is command line option @option{-dpaper=@var{size}}.  This defines string
1428 @code{paper} which is processed in file @file{papersize.tmac} (loaded in
1429 the start-up file @file{troffrc} by default).  Possible values for
1430 @var{size} are the same as the predefined values for the
1431 @code{papersize} keyword (but only in lowercase) except
1432 @code{a7}-@code{d7}.  An appended @samp{l} (ell) character denotes
1433 landscape orientation.
1435 For example, use the following for PS output on A4 paper in landscape
1436 orientation:
1438 @Example
1439 groff -Tps -dpaper=a4l -P-pa4 -P-l -ms foo.ms > foo.ps
1440 @endExample
1442 Note that it is up to the particular macro package to respect default
1443 page dimensions set in this way (most do).
1446 @c =====================================================================
1448 @node Invocation Examples,  , Paper Size, Invoking groff
1449 @section Invocation Examples
1450 @cindex invocation examples
1451 @cindex examples of invocation
1453 This section lists several common uses of @code{groff} and the
1454 corresponding command lines.
1456 @Example
1457 groff file
1458 @endExample
1460 @noindent
1461 This command processes @file{file} without a macro package or a
1462 preprocessor.  The output device is the default, @samp{ps}, and the
1463 output is sent to @code{stdout}.
1465 @Example
1466 groff -t -mandoc -Tascii file | less
1467 @endExample
1469 @noindent
1470 This is basically what a call to the @code{man} program does.
1471 @code{gtroff} processes the manual page @file{file} with the
1472 @file{mandoc} macro file (which in turn either calls the @file{man} or
1473 the @file{mdoc} macro package), using the @code{tbl} preprocessor and
1474 the @acronym{ASCII} output device.  Finally, the @code{less} pager
1475 displays the result.
1477 @Example
1478 groff -X -m me file
1479 @endExample
1481 @noindent
1482 Preview @file{file} with @code{gxditview}, using the @file{me} macro
1483 package.  Since no @option{-T} option is specified, use the default
1484 device (@samp{ps}).  Note that you can either say @w{@samp{-m me}} or
1485 @w{@samp{-me}}; the latter is an anachronism from the early days of
1486 @acronym{UNIX}.@footnote{The same is true for the other main macro
1487 packages that come with @code{groff}: @file{man}, @file{mdoc},
1488 @file{ms}, @file{mm}, and @file{mandoc}.  This won't work in general;
1489 for example, to load @file{trace.tmac}, either @samp{-mtrace} or
1490 @w{@samp{-m trace}} must be used.}
1492 @Example
1493 groff -man -rD1 -z file
1494 @endExample
1496 @noindent
1497 Check @file{file} with the @file{man} macro package, forcing
1498 double-sided printing -- don't produce any output.
1500 @menu
1501 * grog::
1502 @end menu
1504 @c ---------------------------------------------------------------------
1506 @node grog,  , Invocation Examples, Invocation Examples
1507 @subsection @code{grog}
1509 @pindex grog
1510 @code{grog} reads files, guesses which of the @code{groff} preprocessors
1511 and/or macro packages are required for formatting them, and prints the
1512 @code{groff} command including those options on the standard output.  It
1513 generates one or more of the options @option{-e}, @option{-man},
1514 @option{-me}, @option{-mm}, @option{-mom}, @option{-ms}, @option{-mdoc},
1515 @option{-mdoc-old}, @option{-p}, @option{-R}, @option{-g}, @option{-G},
1516 @option{-s}, and @option{-t}.
1518 A special file name@tie{}@file{-} refers to the standard input.  Specifying
1519 no files also means to read the standard input.  Any specified options
1520 are included in the printed command.  No space is allowed between
1521 options and their arguments.  The only options recognized are
1522 @option{-C} (which is also passed on) to enable compatibility mode, and
1523 @option{-v} to print the version number and exit.
1525 For example,
1527 @Example
1528 grog -Tdvi paper.ms
1529 @endExample
1531 @noindent
1532 guesses the appropriate command to print @file{paper.ms} and then prints
1533 it to the command line after adding the @option{-Tdvi} option.  For
1534 direct execution, enclose the call to @code{grog} in backquotes at the
1535 @acronym{UNIX} shell prompt:
1537 @Example
1538 `grog -Tdvi paper.ms` > paper.dvi
1539 @endExample
1541 @noindent
1542 As seen in the example, it is still necessary to redirect the output to
1543 something meaningful (i.e.@: either a file or a pager program like
1544 @code{less}).
1548 @c =====================================================================
1549 @c =====================================================================
1551 @node Tutorial for Macro Users, Macro Packages, Invoking groff, Top
1552 @chapter Tutorial for Macro Users
1553 @cindex tutorial for macro users
1554 @cindex macros, tutorial for users
1555 @cindex user's tutorial for macros
1556 @cindex user's macro tutorial
1558 Most users tend to use a macro package to format their papers.  This
1559 means that the whole breadth of @code{groff} is not necessary for most
1560 people.  This chapter covers the material needed to efficiently use a
1561 macro package.
1563 @menu
1564 * Basics::
1565 * Common Features::
1566 @end menu
1569 @c =====================================================================
1571 @node Basics, Common Features, Tutorial for Macro Users, Tutorial for Macro Users
1572 @section Basics
1573 @cindex basics of macros
1574 @cindex macro basics
1576 This section covers some of the basic concepts necessary to understand
1577 how to use a macro package.@footnote{This section is derived from
1578 @cite{Writing Papers with nroff using -me} by Eric P.@tie{}Allman.}
1579 References are made throughout to more detailed information, if desired.
1581 @code{gtroff} reads an input file prepared by the user and outputs a
1582 formatted document suitable for publication or framing.  The input
1583 consists of text, or words to be printed, and embedded commands
1584 (@dfn{requests} and @dfn{escapes}), which tell @code{gtroff} how to
1585 format the output.  For more detail on this, see @ref{Embedded
1586 Commands}.
1588 The word @dfn{argument} is used in this chapter to mean a word or number
1589 which appears on the same line as a request, and which modifies the
1590 meaning of that request.  For example, the request
1592 @Example
1594 @endExample
1596 @noindent
1597 spaces one line, but
1599 @Example
1600 .sp 4
1601 @endExample
1603 @noindent
1604 spaces four lines.  The number@tie{}4 is an argument to the @code{sp}
1605 request which says to space four lines instead of one.  Arguments are
1606 separated from the request and from each other by spaces (@emph{no}
1607 tabs).  More details on this can be found in @ref{Request and Macro
1608 Arguments}.
1610 The primary function of @code{gtroff} is to collect words from input
1611 lines, fill output lines with those words, justify the right-hand margin
1612 by inserting extra spaces in the line, and output the result.  For
1613 example, the input:
1615 @Example
1616 Now is the time
1617 for all good men
1618 to come to the aid
1619 of their party.
1620 Four score and seven
1621 years ago, etc.
1622 @endExample
1624 @noindent
1625 is read, packed onto output lines, and justified to produce:
1627 @quotation
1628 Now is the time for all good men to come to the aid of their party.
1629 Four score and seven years ago, etc.
1630 @end quotation
1632 @cindex break
1633 @cindex line break
1634 Sometimes a new output line should be started even though the current
1635 line is not yet full; for example, at the end of a paragraph.  To do
1636 this it is possible to cause a @dfn{break}, which starts a new output
1637 line.  Some requests cause a break automatically, as normally do blank
1638 input lines and input lines beginning with a space.
1640 Not all input lines are text to be formatted.  Some input lines are
1641 requests which describe how to format the text.  Requests always have a
1642 period (@samp{.}) or an apostrophe (@samp{'}) as the first character of
1643 the input line.
1645 The text formatter also does more complex things, such as automatically
1646 numbering pages, skipping over page boundaries, putting footnotes in the
1647 correct place, and so forth.
1649 Here are a few hints for preparing text for input to @code{gtroff}.
1651 @itemize @bullet
1652 @item
1653 First, keep the input lines short.  Short input lines are easier to
1654 edit, and @code{gtroff} packs words onto longer lines anyhow.
1656 @item
1657 In keeping with this, it is helpful to begin a new line after every
1658 comma or phrase, since common corrections are to add or delete sentences
1659 or phrases.
1661 @item
1662 End each sentence with two spaces -- or better, start each sentence on a
1663 new line.  @code{gtroff} recognizes characters that usually end a
1664 sentence, and inserts sentence space accordingly.
1666 @item
1667 Do not hyphenate words at the end of lines -- @code{gtroff} is smart
1668 enough to hyphenate words as needed, but is not smart enough to take
1669 hyphens out and join a word back together.  Also, words such as
1670 ``mother-in-law'' should not be broken over a line, since then a space
1671 can occur where not wanted, such as ``@w{mother- in}-law''.
1672 @end itemize
1674 @cindex double-spacing (@code{ls})
1675 @cindex spacing
1676 @code{gtroff} double-spaces output text automatically if you use the
1677 request @w{@samp{.ls 2}}.  Reactivate single-spaced mode by typing
1678 @w{@samp{.ls 1}}.@footnote{If you need finer granularity of the
1679 vertical space, use the @code{pvs} request (@pxref{Changing Type
1680 Sizes}).}
1682 A number of requests allow to change the way the output looks,
1683 sometimes called the @dfn{layout} of the output page.  Most of these
1684 requests adjust the placing of @dfn{whitespace} (blank lines or
1685 spaces).
1687 @cindex new page (@code{bp})
1688 The @code{bp} request starts a new page, causing a line break.
1690 @cindex blank line (@code{sp})
1691 @cindex empty line (@code{sp})
1692 @cindex line, empty (@code{sp})
1693 The request @w{@samp{.sp @var{N}}} leaves @var{N}@tie{}lines of blank
1694 space.  @var{N}@tie{}can be omitted (meaning skip a single line) or can
1695 be of the form @var{N}i (for @var{N}@tie{}inches) or @var{N}c (for
1696 @var{N}@tie{}centimeters).  For example, the input:
1698 @Example
1699 .sp 1.5i
1700 My thoughts on the subject
1702 @endExample
1704 @noindent
1705 leaves one and a half inches of space, followed by the line ``My
1706 thoughts on the subject'', followed by a single blank line (more
1707 measurement units are available, see @ref{Measurements}).
1709 @cindex centering lines (@code{ce})
1710 @cindex lines, centering (@code{ce})
1711 Text lines can be centered by using the @code{ce} request.  The line
1712 after @code{ce} is centered (horizontally) on the page.  To center more
1713 than one line, use @w{@samp{.ce @var{N}}} (where @var{N} is the number
1714 of lines to center), followed by the @var{N}@tie{}lines.  To center many
1715 lines without counting them, type:
1717 @Example
1718 .ce 1000
1719 lines to center
1720 .ce 0
1721 @endExample
1723 @noindent
1724 The @w{@samp{.ce 0}} request tells @code{groff} to center zero more
1725 lines, in other words, stop centering.
1727 @cindex line break (@code{br})
1728 @cindex break (@code{br})
1729 All of these requests cause a break; that is, they always start a new
1730 line.  To start a new line without performing any other action, use
1731 @code{br}.
1734 @c =====================================================================
1736 @node Common Features,  , Basics, Tutorial for Macro Users
1737 @section Common Features
1738 @cindex common features
1739 @cindex features, common
1741 @code{gtroff} provides very low-level operations for formatting a
1742 document.  There are many common routine operations which are done in
1743 all documents.  These common operations are written into @dfn{macros}
1744 and collected into a @dfn{macro package}.
1746 All macro packages provide certain common capabilities which fall into
1747 the following categories.
1749 @menu
1750 * Paragraphs::
1751 * Sections and Chapters::
1752 * Headers and Footers::
1753 * Page Layout Adjustment::
1754 * Displays::
1755 * Footnotes and Annotations::
1756 * Table of Contents::
1757 * Indices::
1758 * Paper Formats::
1759 * Multiple Columns::
1760 * Font and Size Changes::
1761 * Predefined Strings::
1762 * Preprocessor Support::
1763 * Configuration and Customization::
1764 @end menu
1766 @c ---------------------------------------------------------------------
1768 @node Paragraphs, Sections and Chapters, Common Features, Common Features
1769 @subsection Paragraphs
1770 @cindex paragraphs
1772 One of the most common and most used capability is starting a
1773 paragraph.  There are a number of different types of paragraphs, any
1774 of which can be initiated with macros supplied by the macro package.
1775 Normally, paragraphs start with a blank line and the first line
1776 indented, like the text in this manual.  There are also block style
1777 paragraphs, which omit the indentation:
1779 @Example
1780 Some   men  look   at  constitutions   with  sanctimonious
1781 reverence, and deem them like the ark of the covenant, too
1782 sacred to be touched.
1783 @endExample
1785 @noindent
1786 And there are also indented paragraphs which begin with a tag or label
1787 at the margin and the remaining text indented.
1789 @Example
1790 one   This is  the first paragraph.  Notice  how the first
1791       line of  the resulting  paragraph lines up  with the
1792       other lines in the paragraph.
1793 @endExample
1794 @Example
1795 longlabel
1796       This  paragraph   had  a  long   label.   The  first
1797       character of text on the first line does not line up
1798       with  the  text  on  second  and  subsequent  lines,
1799       although they line up with each other.
1800 @endExample
1802 A variation of this is a bulleted list.
1804 @Example
1805 .     Bulleted lists start with a bullet.   It is possible
1806       to use other glyphs instead of the bullet.  In nroff
1807       mode using the ASCII character set for output, a dot
1808       is used instead of a real bullet.
1809 @endExample
1811 @c ---------------------------------------------------------------------
1813 @node Sections and Chapters, Headers and Footers, Paragraphs, Common Features
1814 @subsection Sections and Chapters
1816 Most macro packages supply some form of section headers.  The simplest
1817 kind is simply the heading on a line by itself in bold type.  Others
1818 supply automatically numbered section heading or different heading
1819 styles at different levels.  Some, more sophisticated, macro packages
1820 supply macros for starting chapters and appendices.
1822 @c ---------------------------------------------------------------------
1824 @node Headers and Footers, Page Layout Adjustment, Sections and Chapters, Common Features
1825 @subsection Headers and Footers
1827 Every macro package gives some way to manipulate the @dfn{headers} and
1828 @dfn{footers} (also called @dfn{titles}) on each page.  This is text
1829 put at the top and bottom of each page, respectively, which contain
1830 data like the current page number, the current chapter title, and so
1831 on.  Its appearance is not affected by the running text.  Some packages
1832 allow for different ones on the even and odd pages (for material printed
1833 in a book form).
1835 The titles are called @dfn{three-part titles}, that is, there is a
1836 left-justified part, a centered part, and a right-justified part.  An
1837 automatically generated page number may be put in any of these fields
1838 with the @samp{%} character (see @ref{Page Layout}, for more details).
1840 @c ---------------------------------------------------------------------
1842 @node Page Layout Adjustment, Displays, Headers and Footers, Common Features
1843 @subsection Page Layout
1845 Most macro packages let the user specify top and bottom margins and
1846 other details about the appearance of the printed pages.
1848 @c ---------------------------------------------------------------------
1850 @node Displays, Footnotes and Annotations, Page Layout Adjustment, Common Features
1851 @subsection Displays
1852 @cindex displays
1854 @dfn{Displays} are sections of text to be set off from the body of
1855 the paper.  Major quotes, tables, and figures are types of displays, as
1856 are all the examples used in this document.
1858 @cindex quotes, major
1859 @cindex major quotes
1860 @dfn{Major quotes} are quotes which are several lines long, and hence
1861 are set in from the rest of the text without quote marks around them.
1863 @cindex list
1864 A @dfn{list} is an indented, single-spaced, unfilled display.  Lists
1865 should be used when the material to be printed should not be filled and
1866 justified like normal text, such as columns of figures or the examples
1867 used in this paper.
1869 @cindex keep
1870 A @dfn{keep} is a display of lines which are kept on a single page if
1871 possible.  An example for a keep might be a diagram.  Keeps differ from
1872 lists in that lists may be broken over a page boundary whereas keeps are
1873 not.
1875 @cindex keep, floating
1876 @cindex floating keep
1877 @dfn{Floating keeps} move relative to the text.  Hence, they are good for
1878 things which are referred to by name, such as ``See figure@tie{}3''.  A
1879 floating keep appears at the bottom of the current page if it fits;
1880 otherwise, it appears at the top of the next page.  Meanwhile, the
1881 surrounding text `flows' around the keep, thus leaving no blank areas.
1883 @c ---------------------------------------------------------------------
1885 @node Footnotes and Annotations, Table of Contents, Displays, Common Features
1886 @subsection Footnotes and Annotations
1887 @cindex footnotes
1888 @cindex annotations
1890 There are a number of requests to save text for later printing.
1892 @dfn{Footnotes} are printed at the bottom of the current page.
1894 @cindex delayed text
1895 @dfn{Delayed text} is very similar to a footnote except that it is
1896 printed when called for explicitly.  This allows a list of references to
1897 appear (for example) at the end of each chapter, as is the convention in
1898 some disciplines.
1900 Most macro packages which supply this functionality also supply a means
1901 of automatically numbering either type of annotation.
1903 @c ---------------------------------------------------------------------
1905 @node Table of Contents, Indices, Footnotes and Annotations, Common Features
1906 @subsection Table of Contents
1907 @cindex table of contents
1908 @cindex contents, table of
1910 @dfn{Tables of contents} are a type of delayed text having a tag
1911 (usually the page number) attached to each entry after a row of dots.
1912 The table accumulates throughout the paper until printed, usually after
1913 the paper has ended.  Many macro packages provide the ability to have
1914 several tables of contents (e.g.@: a standard table of contents, a list
1915 of tables, etc).
1917 @c ---------------------------------------------------------------------
1919 @node Indices, Paper Formats, Table of Contents, Common Features
1920 @subsection Indices
1921 @cindex index, in macro package
1923 While some macro packages use the term @dfn{index}, none actually
1924 provide that functionality.  The facilities they call indices are
1925 actually more appropriate for tables of contents.
1927 @pindex makeindex
1928 To produce a real index in a document, external tools like the
1929 @code{makeindex} program are necessary.
1931 @c ---------------------------------------------------------------------
1933 @node Paper Formats, Multiple Columns, Indices, Common Features
1934 @subsection Paper Formats
1935 @cindex paper formats
1937 Some macro packages provide stock formats for various kinds of
1938 documents.  Many of them provide a common format for the title and
1939 opening pages of a technical paper.  The @file{mm} macros in particular
1940 provide formats for letters and memoranda.
1942 @c ---------------------------------------------------------------------
1944 @node Multiple Columns, Font and Size Changes, Paper Formats, Common Features
1945 @subsection Multiple Columns
1947 Some macro packages (but not @file{man}) provide the ability to have two
1948 or more columns on a page.
1950 @c ---------------------------------------------------------------------
1952 @node Font and Size Changes, Predefined Strings, Multiple Columns, Common Features
1953 @subsection Font and Size Changes
1955 The built-in font and size functions are not always intuitive, so all
1956 macro packages provide macros to make these operations simpler.
1958 @c ---------------------------------------------------------------------
1960 @node Predefined Strings, Preprocessor Support, Font and Size Changes, Common Features
1961 @subsection Predefined Strings
1963 Most macro packages provide various predefined strings for a variety of
1964 uses; examples are sub- and superscripts, printable dates, quotes and
1965 various special characters.
1967 @c ---------------------------------------------------------------------
1969 @node Preprocessor Support, Configuration and Customization, Predefined Strings, Common Features
1970 @subsection Preprocessor Support
1972 All macro packages provide support for various preprocessors and may
1973 extend their functionality.
1975 For example, all macro packages mark tables (which are processed with
1976 @code{gtbl}) by placing them between @code{TS} and @code{TE} macros.
1977 The @file{ms} macro package has an option, @samp{.TS@tie{}H}, that prints
1978 a caption at the top of a new page (when the table is too long to fit on
1979 a single page).
1981 @c ---------------------------------------------------------------------
1983 @node Configuration and Customization,  , Preprocessor Support, Common Features
1984 @subsection Configuration and Customization
1986 Some macro packages provide means of customizing many of the details of
1987 how the package behaves.  This ranges from setting the default type size
1988 to changing the appearance of section headers.
1992 @c =====================================================================
1993 @c =====================================================================
1995 @node Macro Packages, gtroff Reference, Tutorial for Macro Users, Top
1996 @chapter Macro Packages
1997 @cindex macro packages
1998 @cindex packages, macros
2000 This chapter documents the main macro packages that come with
2001 @code{groff}.
2003 Different main macro packages can't be used at the same time; for example
2005 @Example
2006 groff -m man foo.man -m ms bar.doc
2007 @endExample
2009 @noindent
2010 doesn't work.  Note that option arguments are processed before non-option
2011 arguments; the above (failing) sample is thus reordered to
2013 @Example
2014 groff -m man -m ms foo.man bar.doc
2015 @endExample
2017 @menu
2018 * man::
2019 * mdoc::
2020 * ms::
2021 * me::
2022 * mm::
2023 @end menu
2026 @c =====================================================================
2028 @node man, mdoc, Macro Packages, Macro Packages
2029 @section @file{man}
2030 @cindex manual pages
2031 @cindex man pages
2032 @pindex an.tmac
2033 @pindex man.tmac
2034 @pindex man-old.tmac
2036 This is the most popular and probably the most important macro package
2037 of @code{groff}.  It is easy to use, and a vast majority of manual pages
2038 are based on it.
2040 @menu
2041 * Man options::
2042 * Man usage::
2043 * Man font macros::
2044 * Miscellaneous man macros::
2045 * Predefined man strings::
2046 * Preprocessors in man pages::
2047 * Optional man extensions::
2048 @end menu
2050 @c ---------------------------------------------------------------------
2052 @node Man options, Man usage, man, man
2053 @subsection Options
2055 The command line format for using the @file{man} macros with
2056 @code{groff} is:
2058 @Example
2059 groff -m man [ -rLL=@var{length} ] [ -rLT=@var{length} ] [ -rFT=@var{dist} ]
2060       [ -rcR=1 ] [ -rC1 ] [ -rD1 ] [-rHY=@var{flags} ]
2061       [ -rP@var{nnn} ] [ -rS@var{xx} ] [ -rX@var{nnn} ]
2062       [ -rIN=@var{length} ] [ -rSN=@var{length} ] [ @var{files}@dots{} ]
2063 @endExample
2065 @noindent
2066 It is possible to use @samp{-man} instead of @w{@samp{-m man}}.
2068 @table @code
2069 @item -rcR=1
2070 This option (the default if a TTY output device is used) creates a
2071 single, very long page instead of multiple pages.  Use @code{-rcR=0}
2072 to disable it.
2074 @item -rC1
2075 If more than one manual page is given on the command line, number the
2076 pages continuously, rather than starting each at@tie{}1.
2078 @item -rD1
2079 Double-sided printing.  Footers for even and odd pages are formatted
2080 differently.
2082 @item -rFT=@var{dist}
2083 Set the position of the footer text to @var{dist}.  If positive, the
2084 distance is measured relative to the top of the page, otherwise it is
2085 relative to the bottom.  The default is @minus{}0.5@dmn{i}.
2087 @item -rHY=@var{flags}
2088 Set hyphenation flags.  Possible values are 1@tie{}to hyphenate without
2089 restrictions, 2@tie{} to not hyphenate the last word on a page,
2090 4@tie{}to not hyphenate the last two characters of a word, and
2091 8@tie{}to not hyphenate the first two characters of a word.  These
2092 values are additive; the default is@tie{}14.
2094 @item -rIN=@var{length}
2095 Set the body text indent to @var{length}.
2096 If not specified, the indent defaults to 7@dmn{n}
2097 (7@tie{}characters) in nroff mode and 7.2@dmn{n} otherwise.
2098 For nroff, this value should always be an integer multiple of unit @samp{n}
2099 to get consistent indentation.
2101 @item -rLL=@var{length}
2102 Set line length to @var{length}.  If not specified, the line length
2103 defaults to 78@tie{}en in nroff mode (this is 78@tie{}characters per
2104 line) and 6.5@tie{}inch otherwise.
2106 @item -rLT=@var{length}
2107 Set title length to @var{length}.  If not specified, the title length
2108 defaults to the line length.
2110 @item -rP@var{nnn}
2111 Page numbering starts with @var{nnn} rather than with@tie{}1.
2113 @item -rS@var{xx}
2114 Use @var{xx} (which can be 10, 11, or@tie{}12@dmn{pt}) as the base
2115 document font size instead of the default value of@tie{}10@dmn{pt}.
2117 @item -rSN=@var{length}
2118 Set the indent for sub-subheadings to @var{length}.
2119 If not specified, the indent defaults to 3@dmn{n}.
2121 @item -rX@var{nnn}
2122 After page @var{nnn}, number pages as @var{nnn}a, @var{nnn}b,
2123 @var{nnn}c, etc.  For example, the option @option{-rX2} produces the
2124 following page numbers: 1, 2, 2a, 2b, 2c, etc.
2125 @end table
2127 @c ---------------------------------------------------------------------
2129 @node Man usage, Man font macros, Man options, man
2130 @subsection Usage
2131 @cindex @code{man} macros
2132 @cindex macros for manual pages [@code{man}]
2134 @pindex man.local
2135 This section describes the available macros for manual pages.  For
2136 further customization, put additional macros and requests into the file
2137 @file{man.local} which is loaded immediately after the @file{man}
2138 package.
2140 @Defmac {TH, title section [@Var{extra1} [@Var{extra2} [@Var{extra3}]]], man}
2141 Set the title of the man page to @var{title} and the section to
2142 @var{section}, which must have a value between 1 and@tie{}8.  The value
2143 of @var{section} may also have a string appended, e.g.@: @samp{.pm},
2144 to indicate a specific subsection of the man pages.
2146 Both @var{title} and @var{section} are positioned at the left and right
2147 in the header line (with @var{section} in parentheses immediately
2148 appended to @var{title}.  @var{extra1} is positioned in the middle of
2149 the footer line.  @var{extra2} is positioned at the left in the footer
2150 line (or at the left on even pages and at the right on odd pages if
2151 double-sided printing is active).  @var{extra3} is centered in the
2152 header line.
2154 For @acronym{HTML} output, headers and footers are completely suppressed.
2156 Additionally, this macro starts a new page; the new line number is@tie{}1
2157 again (except if the @option{-rC1} option is given on the command line)
2158 -- this feature is intended only for formatting multiple man pages; a
2159 single man page should contain exactly one @code{TH} macro at the
2160 beginning of the file.
2161 @endDefmac
2163 @Defmac {SH, [@Var{heading}], man}
2164 Set up an unnumbered section heading sticking out to the left.  Prints
2165 out all the text following @code{SH} up to the end of the line (or the
2166 text in the next line if there is no argument to @code{SH}) in bold
2167 face (or the font specified by the string @code{HF}), one size larger than
2168 the base document size.  Additionally, the left margin and the indentation
2169 for the following text is reset to its default value.
2170 @endDefmac
2172 @Defmac {SS, [@Var{heading}], man}
2173 Set up an unnumbered (sub)section heading.  Prints out all the text
2174 following @code{SS} up to the end of the line (or the text in the next
2175 line if there is no argument to @code{SS}) in bold face (or the font
2176 specified by the string @code{HF}), at the same size as the base document
2177 size.  Additionally, the left margin and the indentation for the
2178 following text is reset to its default value.
2179 @endDefmac
2181 @Defmac {TP, [@Var{nnn}], man}
2182 Set up an indented paragraph with label.  The indentation is set to
2183 @var{nnn} if that argument is supplied (the default unit is @samp{n}
2184 if omitted), otherwise it is set to the previous indentation value
2185 specified with @code{TP}, @code{IP}, or @code{HP} (or to the default
2186 value if none of them have been used yet).
2188 The first line of text following this macro is interpreted as a string
2189 to be printed flush-left, as it is appropriate for a label.  It is not
2190 interpreted as part of a paragraph, so there is no attempt to fill the
2191 first line with text from the following input lines.  Nevertheless, if
2192 the label is not as wide as the indentation the paragraph starts
2193 at the same line (but indented), continuing on the following lines.
2194 If the label is wider than the indentation the descriptive part
2195 of the paragraph begins on the line following the label, entirely
2196 indented.  Note that neither font shape nor font size of the label is
2197 set to a default value; on the other hand, the rest of the text has
2198 default font settings.
2199 @endDefmac
2201 @DefmacList {LP, , man}
2202 @DefmacItem {PP, , man}
2203 @DefmacListEnd {P, , man}
2204 These macros are mutual aliases.  Any of them causes a line break at
2205 the current position, followed by a vertical space downwards by the
2206 amount specified by the @code{PD} macro.  The font size and shape are
2207 reset to the default value (10@dmn{pt} roman if no @option{-rS} option
2208 is given on the command line).  Finally, the current left margin and the
2209 indentation is restored.
2210 @endDefmac
2212 @Defmac {IP, [@Var{designator} [@Var{nnn}]], man}
2213 Set up an indented paragraph, using @var{designator} as a tag to mark
2214 its beginning.  The indentation is set to @var{nnn} if that argument
2215 is supplied (default unit is @samp{n}), otherwise it is set to the
2216 previous indentation value specified with @code{TP}, @code{IP}, or
2217 @code{HP} (or the default value if none of them have been used yet).
2218 Font size and face of the paragraph (but not the designator) are reset
2219 to their default values.
2221 To start an indented paragraph with a particular indentation but without
2222 a designator, use @samp{""} (two double quotes) as the first argument of
2223 @code{IP}.
2225 For example, to start a paragraph with bullets as the designator and
2226 4@tie{}en indentation, write
2228 @Example
2229 .IP \(bu 4
2230 @endExample
2231 @endDefmac
2233 @Defmac {HP, [@Var{nnn}], man}
2234 @cindex hanging indentation [@code{man}]
2235 @cindex @code{man} macros, hanging indentation
2236 Set up a paragraph with hanging left indentation.  The indentation is
2237 set to @var{nnn} if that argument is supplied (default unit is
2238 @samp{n}), otherwise it is set to the previous indentation value
2239 specified with @code{TP}, @code{IP}, or @code{HP} (or the default
2240 value if non of them have been used yet).  Font size and face are reset
2241 to their default values.
2242 @endDefmac
2244 @Defmac {RS, [@Var{nnn}], man}
2245 @cindex left margin, how to move [@code{man}]
2246 @cindex @code{man} macros, moving left margin
2247 Move the left margin to the right by the value @var{nnn} if specified
2248 (default unit is @samp{n}); otherwise it is set to the previous
2249 indentation value specified with @code{TP}, @code{IP}, or @code{HP}
2250 (or to the default value if none of them have been used yet).  The
2251 indentation value is then set to the default.
2253 Calls to the @code{RS} macro can be nested.
2254 @endDefmac
2256 @Defmac {RE, [@Var{nnn}], man}
2257 Move the left margin back to level @var{nnn}, restoring the previous left
2258 margin.  If no argument is given, it moves one level back.  The first
2259 level (i.e., no call to @code{RS} yet) has number@tie{}1, and each call
2260 to @code{RS} increases the level by@tie{}1.
2261 @endDefmac
2263 @cindex line breaks, with vertical space [@code{man}]
2264 @cindex @code{man} macros, line breaks with vertical space
2265 To summarize, the following macros cause a line break with the insertion
2266 of vertical space (which amount can be changed with the @code{PD}
2267 macro): @code{SH}, @code{SS}, @code{TP}, @code{LP} (@code{PP},
2268 @code{P}), @code{IP}, and @code{HP}.
2270 @cindex line breaks, without vertical space [@code{man}]
2271 @cindex @code{man} macros, line breaks without vertical space
2272 The macros @code{RS} and @code{RE} also cause a break but do not insert
2273 vertical space.
2275 @cindex default indentation, resetting [@code{man}]
2276 @cindex indentaion, resetting to default [@code{man}]
2277 @cindex @code{man} macros, resetting default indentation
2278 Finally, the macros @code{SH}, @code{SS}, @code{LP} (@code{PP}, @code{P}),
2279 and @code{RS} reset the indentation to its default value.
2281 @c ---------------------------------------------------------------------
2283 @node Man font macros, Miscellaneous man macros, Man usage, man
2284 @subsection Macros to set fonts
2285 @cindex font selection [@code{man}]
2286 @cindex @code{man} macros, how to set fonts
2288 The standard font is roman; the default text size is 10@tie{}point.
2289 If command line option @option{-rS=@var{n}} is given, use
2290 @var{n}@dmn{pt} as the default text size.
2292 @Defmac {SM, [@Var{text}], man}
2293 Set the text on the same line or the text on the next line in a font
2294 that is one point size smaller than the default font.
2295 @endDefmac
2297 @Defmac {SB, [@Var{text}], man}
2298 @cindex bold face [@code{man}]
2299 @cindex @code{man} macros, bold face
2300 Set the text on the same line or the text on the next line in bold face
2301 font, one point size smaller than the default font.
2302 @endDefmac
2304 @Defmac {BI, text, man}
2305 Set its arguments alternately in bold face and italic, without a space
2306 between the arguments.  Thus,
2308 @Example
2309 .BI this "word and" that
2310 @endExample
2312 @noindent
2313 produces ``thisword andthat'' with ``this'' and ``that'' in bold face,
2314 and ``word and'' in italics.
2315 @endDefmac
2317 @Defmac {IB, text, man}
2318 Set its arguments alternately in italic and bold face, without a space
2319 between the arguments.
2320 @endDefmac
2322 @Defmac {RI, text, man}
2323 Set its arguments alternately in roman and italic, without a space between
2324 the arguments.
2325 @endDefmac
2327 @Defmac {IR, text, man}
2328 Set its arguments alternately in italic and roman, without a space between
2329 the arguments.
2330 @endDefmac
2332 @Defmac {BR, text, man}
2333 Set its arguments alternately in bold face and roman, without a space
2334 between the arguments.
2335 @endDefmac
2337 @Defmac {RB, text, man}
2338 Set its arguments alternately in roman and bold face, without a space
2339 between the arguments.
2340 @endDefmac
2342 @Defmac {B, [@Var{text}], man}
2343 Set @var{text} in bold face.  If no text is present on the line where
2344 the macro is called, then the text of the next line appears in bold
2345 face.
2346 @endDefmac
2348 @Defmac {I, [@Var{text}], man}
2349 @cindex italic fonts [@code{man}]
2350 @cindex @code{man} macros, italic fonts
2351 Set @var{text} in italic.  If no text is present on the line where the
2352 macro is called, then the text of the next line appears in italic.
2353 @endDefmac
2355 @c ---------------------------------------------------------------------
2357 @node Miscellaneous man macros, Predefined man strings, Man font macros, man
2358 @subsection Miscellaneous macros
2360 @pindex grohtml
2361 @cindex @code{man} macros, default indentation
2362 @cindex default indentation [@code{man}]
2363 The default indentation is 7.2@dmn{n} in troff mode and 7@dmn{n} in
2364 nroff mode except for @code{grohtml} which ignores indentation.
2366 @Defmac {DT, , man}
2367 @cindex tab stops [@code{man}]
2368 @cindex @code{man} macros, tab stops
2369 Set tabs every 0.5@tie{}inches.  Since this macro is always executed
2370 during a call to the @code{TH} macro, it makes sense to call it only if
2371 the tab positions have been changed.
2372 @endDefmac
2374 @Defmac {PD, [@Var{nnn}], man}
2375 @cindex empty space before a paragraph [@code{man}]
2376 @cindex @code{man} macros, empty space before a paragraph
2377 Adjust the empty space before a new paragraph (or section).  The
2378 optional argument gives the amount of space (default unit is
2379 @samp{v}); without parameter, the value is reset to its default value
2380 (1@tie{}line in nroff mode, 0.4@dmn{v}@tie{}otherwise).
2382 This affects the macros @code{SH}, @code{SS}, @code{TP}, @code{LP} (as
2383 well as @code{PP} and @code{P}), @code{IP}, and @code{HP}.
2384 @endDefmac
2386 The following two macros are included for
2387 BSD compatibility.
2389 @Defmac {AT, [@Var{system} [@Var{release}]], man}
2390 @cindex @code{man}macros, BSD compatibility
2391 Alter the footer for use with @acronym{AT&T} manpages.
2392 This command exists only for compatibility; don't use it.
2393 The first argument @var{system} can be:
2395 @table @code
2396 @item 3
2397 7th Edition (the default)
2399 @item 4
2400 System III
2402 @item 5
2403 System V
2404 @end table
2406 An optional second argument @var{release} to @code{AT} specifies the
2407 release number (such as ``System V Release 3'').
2408 @endDefmac
2410 @Defmac {UC, [@Var{version}], man}
2411 @cindex @code{man}macros, BSD compatibility
2412 Alters the footer for use with @acronym{BSD} manpages.
2413 This command exists only for compatibility; don't use it.
2414 The argument can be:
2416 @table @code
2417 @item 3
2418 3rd Berkeley Distribution (the default)
2420 @item 4
2421 4th Berkeley Distribution
2423 @item 5
2424 4.2 Berkeley Distribution
2426 @item 6
2427 4.3 Berkeley Distribution
2429 @item 7
2430 4.4 Berkeley Distribution
2431 @end table
2432 @endDefmac
2434 @c ---------------------------------------------------------------------
2436 @node Predefined man strings, Preprocessors in man pages, Miscellaneous man macros, man
2437 @subsection Predefined strings
2439 The following strings are defined:
2441 @Defstr {S, man}
2442 Switch back to the default font size.
2443 @endDefstr
2445 @Defstr {HF, man}
2446 The typeface used for headings.
2447 The default is @samp{B}.
2448 @endDefstr
2450 @Defstr {R, man}
2451 The `registered' sign.
2452 @endDefstr
2454 @Defstr {Tm, man}
2455 The `trademark' sign.
2456 @endDefstr
2458 @DefstrList {lq, man}
2459 @DefstrListEnd {rq, man}
2460 @cindex @code{lq} glyph, and @code{lq} string [@code{man}]
2461 @cindex @code{rq} glyph, and @code{rq} string [@code{man}]
2462 Left and right quote.  This is equal to @code{\(lq} and @code{\(rq},
2463 respectively.
2464 @endDefstr
2466 @c ---------------------------------------------------------------------
2468 @node Preprocessors in man pages, Optional man extensions, Predefined man strings, man
2469 @subsection Preprocessors in @file{man} pages
2471 @cindex preprocessor, calling convention
2472 @cindex calling convention of preprocessors
2473 If a preprocessor like @code{gtbl} or @code{geqn} is needed, it has
2474 become common usage to make the first line of the man page look like
2475 this:
2477 @Example
2478 '\" @var{word}
2479 @endExample
2481 @pindex geqn@r{, invocation in manual pages}
2482 @pindex grefer@r{, invocation in manual pages}
2483 @pindex gtbl@r{, invocation in manual pages}
2484 @pindex man@r{, invocation of preprocessors}
2485 @noindent
2486 Note the single space character after the double quote.  @var{word}
2487 consists of letters for the needed preprocessors: @samp{e} for
2488 @code{geqn}, @samp{r} for @code{grefer}, @samp{t} for @code{gtbl}.
2489 Modern implementations of the @code{man} program read this first line
2490 and automatically call the right preprocessor(s).
2492 @c ---------------------------------------------------------------------
2494 @node Optional man extensions,  , Preprocessors in man pages, man
2495 @subsection Optional @file{man} extensions
2497 @pindex man.local
2498 Use the file @file{man.local} for local extensions
2499 to the @code{man} macros or for style changes.
2501 @unnumberedsubsubsec Custom headers and footers
2502 @cindex @code{man} macros, custom headers and footers
2504 In groff versions 1.18.2 and later, you can specify custom
2505 headers and footers by redefining the following macros in
2506 @file{man.local}.
2508 @Defmac {PT, , man}
2509 Control the content of the headers.
2510 Normally, the header prints the command name
2511 and section number on either side, and the
2512 optional fifth argument to @code{TH} in the center.
2513 @endDefmac
2515 @Defmac {BT, , man}
2516 Control the content of the footers.
2517 Normally, the footer prints the page number
2518 and the third and fourth arguments to @code{TH}.
2520 Use the @code{FT} number register to specify the
2521 footer position.
2522 The default is @minus{}0.5@dmn{i}.
2523 @endDefmac
2525 @unnumberedsubsubsec Ultrix-specific man macros
2526 @cindex Ultrix-specific @code{man} macros
2527 @cindex @code{man} macros, Ultrix-specific
2529 @pindex man.ultrix
2530 The @code{groff} source distribution includes
2531 a file named @file{man.ultrix}, containing
2532 macros compatible with the Ultrix variant of
2533 @code{man}.
2534 Copy this file into @file{man.local} (or use the @code{mso} request to
2535 load it) to enable the following macros.
2537 @Defmac {CT, @Var{key}, man}
2538 Print @samp{<CTRL/@var{key}>}.
2539 @endDefmac
2541 @Defmac {CW, , man}
2542 Print subsequent text using the constant width (Courier) typeface.
2543 @endDefmac
2545 @Defmac {Ds, , man}
2546 Begin a non-filled display.
2547 @endDefmac
2549 @Defmac {De, , man}
2550 End a non-filled display started with @code{Ds}.
2551 @endDefmac
2553 @Defmac {EX, [@Var{indent}], man}
2554 Begins a non-filled display
2555 using the constant width (Courier) typeface.
2556 Use the optional @var{indent} argument to
2557 indent the display.
2558 @endDefmac
2560 @Defmac {EE, , man}
2561 End a non-filled display started with @code{EX}.
2562 @endDefmac
2564 @Defmac {G, [@Var{text}], man}
2565 Sets @var{text} in Helvetica.
2566 If no text is present on the line where
2567 the macro is called, then the text of the
2568 next line appears in Helvetica.
2569 @endDefmac
2571 @Defmac {GL, [@Var{text}], man}
2572 Sets @var{text} in Helvetica Oblique.
2573 If no text is present on the line where
2574 the macro is called, then the text of the
2575 next line appears in Helvetica Oblique.
2576 @endDefmac
2578 @Defmac {HB, [@Var{text}], man}
2579 Sets @var{text} in Helvetica Bold.
2580 If no text is present on the line where
2581 the macro is called, then all text up to
2582 the next @code{HB} appears in Helvetica Bold.
2583 @endDefmac
2585 @Defmac {TB, [@Var{text}], man}
2586 Identical to @code{HB}.
2587 @endDefmac
2589 @Defmac {MS, @Var{title} @Var{sect} [@Var{punct}], man}
2590 Set a manpage reference in Ultrix format.
2591 The @var{title} is in Courier instead of italic.
2592 Optional punctuation follows the section number without
2593 an intervening space.
2594 @endDefmac
2596 @Defmac {NT, [@code{C}] [@Var{title}], man}
2597 Begin a note.
2598 Print the optional @Var{title}, or the word ``Note'',
2599 centered on the page.
2600 Text following the macro makes up the body of the note,
2601 and is indented on both sides.
2602 If the first argument is @code{C}, the body of the
2603 note is printed centered (the second argument replaces
2604 the word ``Note'' if specified).
2605 @endDefmac
2607 @Defmac {NE, , man}
2608 End a note begun with @code{NT}.
2609 @endDefmac
2611 @Defmac {PN, @Var{path} [@Var{punct}], man}
2612 Set the path name in constant width (Courier),
2613 followed by optional punctuation.
2614 @endDefmac
2616 @Defmac {Pn, [@Var{punct}] @Var{path} [@Var{punct}], man}
2617 When called with two arguments, identical to @code{PN}.
2618 When called with three arguments,
2619 set the second argument in constant width (Courier),
2620 bracketed by the first and third arguments in the current font.
2621 @endDefmac
2623 @Defmac {R, , man}
2624 Switch to roman font and turn off any underlining in effect.
2625 @endDefmac
2627 @Defmac {RN, , man}
2628 Print the string @samp{<RETURN>}.
2629 @endDefmac
2631 @Defmac {VS, [@code{4}], man}
2632 Start printing a change bar in the margin if
2633 the number @code{4} is specified.
2634 Otherwise, this macro does nothing.
2635 @endDefmac
2637 @Defmac {VE, , man}
2638 End printing the change bar begun by @code{VS}.
2639 @endDefmac
2641 @unnumberedsubsubsec Simple example
2643 The following example @file{man.local} file
2644 alters the @code{SH} macro to add some extra
2645 vertical space before printing the heading.
2646 Headings are printed in Helvetica Bold.
2648 @Example
2649 .\" Make the heading fonts Helvetica
2650 .ds HF HB
2652 .\" Put more whitespace in front of headings.
2653 .rn SH SH-orig
2654 .de SH
2655 .  if t .sp (u;\\n[PD]*2)
2656 .  SH-orig \\$*
2658 @endExample
2660 @c =====================================================================
2662 @node mdoc, ms, man, Macro Packages
2663 @section @file{mdoc}
2664 @cindex @code{mdoc} macros
2666 @c XXX documentation
2667 @c XXX this is a placeholder until we get stuff knocked into shape
2668 See the @cite{groff_mdoc(7)} man page (type @command{man groff_mdoc}
2669 at the command line).
2672 @c =====================================================================
2674 @node ms, me, mdoc, Macro Packages
2675 @section @file{ms}
2676 @cindex @code{ms} macros
2678 The @file{-ms}
2679 macros are suitable for reports, letters, books,
2680 user manuals, and so forth.
2681 The package provides macros for cover pages, section headings,
2682 paragraphs, lists, footnotes, pagination,
2683 and a table of contents.
2685 @menu
2686 * ms Intro::
2687 * General ms Structure::
2688 * ms Document Control Registers::
2689 * ms Cover Page Macros::
2690 * ms Body Text::
2691 * ms Page Layout::
2692 * Differences from AT&T ms::
2693 @end menu
2695 @c ---------------------------------------------------------------------
2697 @node ms Intro, General ms Structure, ms, ms
2698 @subsection Introduction to @file{ms}
2700 The original @file{-ms} macros were included with
2701 @acronym{AT&T} @code{troff} as well as the
2702 @file{man} macros.
2703 While the @file{man} package is intended for brief documents
2704 that can be read on-line as well as printed, the @file{ms}
2705 macros are suitable for longer documents that are meant to be
2706 printed rather than read on-line.
2708 The @file{ms} macro package included with @code{groff}
2709 is a complete, bottom-up re-implementation.
2710 Several macros (specific to @acronym{AT&T}
2711 or Berkeley) are not included, while several new commands are.
2712 @xref{Differences from AT&T ms}, for more information.
2714 @c ---------------------------------------------------------------------
2716 @node General ms Structure, ms Document Control Registers, ms Intro, ms
2717 @subsection General structure of an @file{ms} document
2718 @cindex @code{ms} macros, general structure
2720 The @file{ms} macro package expects a certain amount of structure,
2721 but not as much as packages such as @file{man} or @file{mdoc}.
2723 The simplest documents can begin with a paragraph macro
2724 (such as @code{LP} or @code{PP}),
2725 and consist of text separated by paragraph macros
2726 or even blank lines.
2727 Longer documents have a structure as follows:
2729 @table @strong
2730 @item Document type
2731 If you invoke the @code{RP}
2732 (report) macro on the first line of the document,
2733 @code{groff} prints the cover page information on its own page;
2734 otherwise it prints the information on the
2735 first page with your document text immediately following.
2736 Other document formats found in @acronym{AT&T} @code{troff}
2737 are specific to @acronym{AT&T} or Berkeley, and are not supported in
2738 @code{groff}.
2740 @item Format and layout
2741 By setting number registers,
2742 you can change your document's type (font and size),
2743 margins, spacing, headers and footers, and footnotes.
2744 @xref{ms Document Control Registers}, for more details.
2746 @item Cover page
2747 A cover page consists of a title, the author's name and institution,
2748 an abstract, and the date.
2749 @footnote{Actually, only the title is required.}
2750 @xref{ms Cover Page Macros}, for more details.
2752 @item Body
2753 Following the cover page is your document.
2754 You can use the @file{ms}
2755 macros to write reports, letters, books, and so forth.
2756 The package is designed for structured documents,
2757 consisting of paragraphs interspersed with headings
2758 and augmented by lists, footnotes, tables, and other
2759 common constructs.
2760 @xref{ms Body Text}, for more details.
2762 @item Table of contents
2763 Longer documents usually include a table of contents,
2764 which you can invoke by placing the
2765 @code{TC}
2766 macro at the end of your document.
2767 The @file{ms}
2768 macros have minimal indexing facilities, consisting of the
2769 @code{IX} macro, which prints an entry on standard error.
2770 Printing the table of contents at the end is necessary since
2771 @code{groff} is a single-pass text formatter,
2772 thus it cannot determine the page number of each section
2773 until that section has actually been set and printed.
2774 Since @file{ms} output is intended for hardcopy,
2775 you can manually relocate the pages containing
2776 the table of contents between the cover page and the
2777 body text after printing.
2778 @end table
2780 @c ---------------------------------------------------------------------
2782 @node ms Document Control Registers, ms Cover Page Macros, General ms Structure, ms
2783 @subsection Document control registers
2784 @cindex @code{ms} macros, document control registers
2786 The following is a list of document control number registers.
2787 For the sake of consistency,
2788 set registers related to margins at the beginning of your document,
2789 or just after the @code{RP} macro.
2790 You can set other registers later in your document,
2791 but you should keep them together at the beginning
2792 to make them easy to find and edit as necessary.
2794 @unnumberedsubsubsec Margin Settings
2796 @Defmpreg {PO, ms}
2797 Defines the page offset (i.e.@: the left margin).
2798 There is no explicit right margin setting; the combination of
2799 the @code{PO} and @code{LL} registers implicitly define the
2800 right margin width.
2802 Effective: next page.
2804 Default value: 1@dmn{i}.
2805 @endDefmpreg
2807 @Defmpreg {LL, ms}
2808 Defines the line length (i.e.@: the width of the body text).
2810 Effective: next paragraph.
2812 Default: 6@dmn{i}.
2813 @endDefmpreg
2815 @Defmpreg {LT, ms}
2816 Defines the title length (i.e.@: the header and footer width).
2817 This is usually the same as @code{LL}, but not necessarily.
2819 Effective: next paragraph.
2821 Default: 6@dmn{i}.
2822 @endDefmpreg
2824 @Defmpreg {HM, ms}
2825 Defines the header margin height at the top of the page.
2827 Effective: next page.
2829 Default: 1@dmn{i}.
2830 @endDefmpreg
2832 @Defmpreg {FM, ms}
2833 Defines the footer margin height at the bottom of the page.
2835 Effective: next page.
2837 Default: 1@dmn{i}.
2838 @endDefmpreg
2840 @unnumberedsubsubsec Text Settings
2842 @Defmpreg {PS, ms}
2843 Defines the point size of the body text.  If the value is larger than or
2844 equal to 1000, divide it by 1000 to get a fractional point size.  For
2845 example, @samp{.nr PS 10250} sets the document's point size to 10.25@dmn{p}.
2847 Effective: next paragraph.
2849 Default: 10@dmn{p}.
2850 @endDefmpreg
2852 @Defmpreg {VS, ms}
2853 Defines the space between lines (line height plus leading).  If the value
2854 is larger than or equal to 1000, divide it by 1000 to get a fractional point
2855 size.  Due to backwards compatibility, @code{VS} must be smaller than
2856 40000 (this is 40.0@dmn{p}).
2858 Effective: next paragraph.
2860 Default: 12@dmn{p}.
2861 @endDefmpreg
2863 @unnumberedsubsubsec Paragraph Settings
2865 @Defmpreg {PI, ms}
2866 Defines the initial indent of a @code{.PP} paragraph.
2868 Effective: next paragraph.
2870 Default: 5@dmn{n}.
2871 @endDefmpreg
2873 @Defmpreg {PD, ms}
2874 Defines the space between paragraphs.
2876 Effective: next paragraph.
2878 Default: 0.3@dmn{v}.
2879 @endDefmpreg
2881 @Defmpreg {QI, ms}
2882 Defines the indent on both sides of a quoted (@code{.QP}) paragraph.
2884 Effective: next paragraph.
2886 Default: 5@dmn{n}.
2887 @endDefmpreg
2889 @unnumberedsubsubsec Footnote Settings
2891 @Defmpreg {FL, ms}
2892 Defines the length of a footnote.
2894 Effective: next footnote.
2896 Default: @math{@code{@\n[LL]} * 5 / 6}.
2897 @endDefmpreg
2899 @Defmpreg {FI, ms}
2900 Defines the footnote indent.
2902 Effective: next footnote.
2904 Default: 2@dmn{n}.
2905 @endDefmpreg
2907 @Defmpreg {FF, ms}
2908 The footnote format:
2909 @table @code
2910 @item 0
2911 Prints the footnote number as a superscript; indents the footnote (default).
2913 @item 1
2914 Prints the number followed by a period (like 1.)
2915 and indents the footnote.
2917 @item 2
2918 Like 1, without an indent.
2920 @item 3
2921 Like 1, but prints the footnote number as a hanging paragraph.
2922 @end table
2924 Effective: next footnote.
2926 Default: 0.
2927 @endDefmpreg
2929 @Defmpreg {FPS, ms}
2930 Defines the footnote point size.  If the value is larger than or equal to
2931 1000, divide it by 1000 to get a fractional point size.
2933 Effective: next footnote.
2935 Default: @math{@code{@\n[PS]} - 2}.
2936 @endDefmpreg
2938 @Defmpreg {FVS, ms}
2939 Defines the footnote vertical spacing.  If the value is larger than or equal
2940 to 1000, divide it by 1000 to get a fractional point size.
2942 Effective: next footnote.
2944 Default: @math{@code{@\n[FPS]} + 2}.
2945 @endDefmpreg
2947 @Defmpreg {FPD, ms}
2948 Defines the footnote paragraph spacing.
2950 Effective: next footnote.
2952 Default: @math{@code{@\n[PD]} / 2}.
2953 @endDefmpreg
2955 @unnumberedsubsubsec Miscellaneous Number Registers
2957 @Defmpreg {MINGW, ms}
2958 Defines the minimum width between columns in a multi-column document.
2960 Effective: next page.
2962 Default: 2@dmn{n}.
2963 @endDefmpreg
2965 @c ---------------------------------------------------------------------
2967 @node ms Cover Page Macros, ms Body Text, ms Document Control Registers, ms
2968 @subsection Cover page macros
2969 @cindex @code{ms} macros, cover page
2970 @cindex cover page macros, [@code{ms}]
2972 Use the following macros to create a cover page for your document
2973 in the order shown.
2975 @Defmac {RP, [@code{no}], ms}
2976 Specifies the report format for your document.
2977 The report format creates a separate cover page.
2978 The default action (no @code{.RP}
2979 macro) is to print a subset of the
2980 cover page on page 1 of your document.
2982 If you use the word @code{no} as an optional argument,
2983 @code{groff} prints a title page but
2984 does not repeat any of the title page information
2985 (title, author, abstract, etc.)
2986 on page 1 of the document.
2987 @endDefmac
2989 @Defmac {DA, [@dots{}], ms}
2990 (optional) Print the current date, or the arguments to the macro if any,
2991 on the title page (if specified) and in the footers.
2992 This is the default for @code{nroff}.
2993 @endDefmac
2995 @Defmac {ND, [@dots{}], ms}
2996 (optional) Print the current date, or the arguments to the macro if any,
2997 on the title page (if specified) but not in the footers.
2998 This is the default for @code{troff}.
2999 @endDefmac
3001 @Defmac {TL, , ms}
3002 Specifies the document title.
3003 @code{groff} collects text following the @code{.TL}
3004 macro into the title, until reaching the author name or abstract.
3005 @endDefmac
3007 @Defmac {AU, , ms}
3008 Specifies the author's name, which appears on the
3009 line (or lines) immediately following.
3010 You can specify multiple authors as follows:
3012 @Example
3014 John Doe
3016 University of West Bumblefuzz
3018 Martha Buck
3020 Monolithic Corporation
3023 @endExample
3024 @endDefmac
3026 @Defmac {AI, , ms}
3027 Specifies the author's institution.
3028 You can specify multiple institutions in the same way
3029 that you specify multiple authors.
3030 @endDefmac
3032 @Defmac {AB, [@code{no}], ms}
3033 Begins the abstract.
3034 The default is to print the word @acronym{ABSTRACT},
3035 centered and in italics, above the text of the abstract.
3036 The word @code{no} as an optional argument suppresses this heading.
3037 @endDefmac
3039 @Defmac {AE, , ms}
3040 End the abstract.
3041 @endDefmac
3043 The following is example mark-up for a title page.
3044 @cindex title page, example markup
3045 @cindex example markup, title page
3047 @Example
3048 @cartouche
3051 The Inevitability of Code Bloat
3052 in Commercial and Free Software
3054 J. Random Luser
3056 University of West Bumblefuzz
3058 This report examines the long-term growth
3059 of the code bases in two large, popular software
3060 packages; the free Emacs and the commercial
3061 Microsoft Word.
3062 While differences appear in the type or order
3063 of features added, due to the different
3064 methodologies used, the results are the same
3065 in the end.
3067 The free software approach is shown to be
3068 superior in that while free software can
3069 become as bloated as commercial offerings,
3070 free software tends to have fewer serious
3071 bugs and the added features are in line with
3072 user demand.
3075 ... the rest of the paper follows ...
3076 @end cartouche
3077 @endExample
3079 @c ---------------------------------------------------------------------
3081 @node ms Body Text, ms Page Layout, ms Cover Page Macros, ms
3082 @subsection Body text
3083 @cindex @code{ms} macros, body text
3085 This section describes macros used to mark up the body of your document.
3086 Examples include paragraphs, sections, and other groups.
3088 @menu
3089 * Paragraphs in ms::
3090 * Headings in ms::
3091 * Highlighting in ms::
3092 * Lists in ms::
3093 * Indents in ms::
3094 * Tabstops in ms::
3095 * ms Displays and Keeps::
3096 * ms Insertions::
3097 * Example multi-page table::
3098 * ms Footnotes::
3099 @end menu
3101 @c ---------------------------------------------------------------------
3103 @node Paragraphs in ms, Headings in ms, ms Body Text, ms Body Text
3104 @subsubsection Paragraphs
3105 @cindex @code{ms} macros, paragraph handling
3107 The following paragraph types are available.
3109 @Defmac {PP, , ms}
3110 Sets a paragraph with an initial indent.
3111 @endDefmac
3113 @Defmac {LP, , ms}
3114 Sets a paragraph with no initial indent.
3115 @endDefmac
3117 @Defmac {QP, , ms}
3118 Sets a paragraph that is indented at both left and right margins.
3119 The effect is identical to the @acronym{HTML} @code{<BLOCKQUOTE>} element.
3120 The next paragraph or heading returns margins to normal.
3121 @endDefmac
3123 @Defmac {XP, , ms}
3124 Sets a paragraph whose lines are indented,
3125 except for the first line.
3126 This is a Berkeley extension.
3127 @endDefmac
3129 The following markup uses all four paragraph macros.
3131 @Example
3132 @cartouche
3133 .NH 2
3134 Cases used in the study
3136 The following software and versions were
3137 considered for this report.
3139 For commercial software, we chose
3140 .B "Microsoft Word for Windows" ,
3141 starting with version 1.0 through the
3142 current version (Word 2000).
3144 For free software, we chose
3145 .B Emacs ,
3146 from its first appearance as a standalone
3147 editor through the current version (v20).
3148 See [Bloggs 2002] for details.
3150 Franklin's Law applied to software:
3151 software expands to outgrow both
3152 RAM and disk space over time.
3154 Bibliography:
3156 Bloggs, Joseph R.,
3157 .I "Everyone's a Critic" ,
3158 Underground Press, March 2002.
3159 A definitive work that answers all questions
3160 and criticisms about the quality and usability of
3161 free software.
3162 @end cartouche
3163 @endExample
3165 @c ---------------------------------------------------------------------
3167 @node Headings in ms, Highlighting in ms, Paragraphs in ms, ms Body Text
3168 @subsubsection Headings
3169 @cindex @code{ms} macros, headings
3171 Use headings to create a hierarchical structure for your document.
3172 The @file{ms} macros print headings in @strong{bold},
3173 using the same font family and point size as the body text.
3175 The following describes the heading macros:
3177 @DefmacList {NH, @Var{curr-level}, ms}
3178 @DefmacListEnd {NH, @t{S} @Var{level0} @dots{}, ms}
3179 Numbered heading.
3180 The argument is either a numeric argument to indicate the
3181 level of the heading, or the letter@tie{}@code{S} followed by numeric
3182 arguments to set the heading level explicitly.
3184 If you specify heading levels out of sequence, such as invoking
3185 @samp{.NH 3} after @samp{.NH 1}, @code{groff}
3186 prints a warning on standard error.
3187 @endDefmac
3189 @Defmac {SH, , ms}
3190 Unnumbered subheading.
3191 @endDefmac
3193 @c ---------------------------------------------------------------------
3195 @node Highlighting in ms, Lists in ms, Headings in ms, ms Body Text
3196 @subsubsection Highlighting
3197 @cindex @code{ms} macros, highlighting
3199 The @file{ms} macros provide a variety of methods to highlight
3200 or emphasize text:
3202 @Defmac {B, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3203 Sets its first argument in @strong{bold type}.
3204 If you specify a second argument, @code{groff} prints it in the
3205 previous font after the bold text, with no intervening space
3206 (this allows you to set punctuation after the highlighted text
3207 without highlighting the punctuation).
3208 Similarly, it prints the third argument (if any) in the previous
3209 font @strong{before} the first argument.
3210 For example,
3212 @Example
3213 .B foo ) (
3214 @endExample
3216 prints (@strong{foo}).
3218 If you give this macro no arguments, @code{groff}
3219 prints all text following in bold until
3220 the next highlighting, paragraph, or heading macro.
3221 @endDefmac
3223 @Defmac {R, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3224 Sets its first argument in roman (or regular) type.
3225 It operates similarly to the @code{B}@tie{}macro otherwise.
3226 @endDefmac
3228 @Defmac {I, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3229 Sets its first argument in @emph{italic type}.
3230 It operates similarly to the @code{B}@tie{}macro otherwise.
3231 @endDefmac
3233 @Defmac {CW, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3234 Sets its first argument in a @code{constant width face}.
3235 It operates similarly to the @code{B}@tie{}macro otherwise.
3236 @endDefmac
3238 @Defmac {BI, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3239 Sets its first argument in bold italic type.
3240 It operates similarly to the @code{B}@tie{}macro otherwise.
3241 @endDefmac
3243 @Defmac {BX, [@Var{txt}], ms}
3244 Prints its argument and draws a box around it.
3245 If you want to box a string that contains spaces,
3246 use a digit-width space (@code{\0}).
3247 @endDefmac
3249 @Defmac {UL, [@Var{txt} [@Var{post}]], ms}
3250 Prints its first argument with an underline.
3251 If you specify a second argument, @code{groff}
3252 prints it in the previous font after
3253 the underlined text, with no intervening space.
3254 @endDefmac
3256 @Defmac {LG, , ms}
3257 Prints all text following in larger type
3258 (two points larger than the current point size) until
3259 the next font size, highlighting, paragraph, or heading macro.
3260 You can specify this macro multiple times
3261 to enlarge the point size as needed.
3262 @endDefmac
3264 @Defmac {SM, , ms}
3265 Prints all text following in smaller type
3266 (two points smaller than the current point size) until
3267 the next type size, highlighting, paragraph, or heading macro.
3268 You can specify this macro multiple times
3269 to reduce the point size as needed.
3270 @endDefmac
3272 @Defmac {NL, , ms}
3273 Prints all text following in the normal point size
3274 (that is, the value of the @code{PS} register).
3275 @endDefmac
3277 @c ---------------------------------------------------------------------
3279 @node Lists in ms, Indents in ms, Highlighting in ms, ms Body Text
3280 @subsubsection Lists
3281 @cindex @code{ms} macros, lists
3283 The @code{.IP} macro handles duties for all lists.
3285 @Defmac {IP, [@Var{marker} [@Var{width}]], ms}
3286 The @var{marker} is usually a bullet glyph (@code{\[bu]})
3287 for unordered lists, a number (or auto-incrementing number
3288 register) for numbered lists, or a word or phrase for indented
3289 (glossary-style) lists.
3291 The @var{width} specifies the indent for the body of each list item;
3292 its default unit is @samp{n}.
3293 Once specified, the indent remains the same for all
3294 list items in the document until specified again.
3295 @endDefmac
3297 The following is an example of a bulleted list.
3298 @cindex example markup, bulleted list [@code{ms}]
3299 @cindex bulleted list, example markup [@code{ms}]
3301 @Example
3302 A bulleted list:
3303 .IP \[bu] 2
3304 lawyers
3305 .IP \[bu]
3306 guns
3307 .IP \[bu]
3308 money
3309 @endExample
3311 Produces:
3313 @Example
3314 A bulleted list:
3316 o lawyers
3318 o guns
3320 o money
3321 @endExample
3323 @sp 1
3325 The following is an example of a numbered list.
3326 @cindex example markup, numbered list [@code{ms}]
3327 @cindex numbered list, example markup [@code{ms}]
3329 @Example
3330 .nr step 1 1
3331 A numbered list:
3332 .IP \n[step] 3
3333 lawyers
3334 .IP \n+[step]
3335 guns
3336 .IP \n+[step]
3337 money
3338 @endExample
3340 Produces:
3342 @Example
3343 A numbered list:
3345 1. lawyers
3347 2. guns
3349 3. money
3350 @endExample
3352 Note the use of the auto-incrementing number
3353 register in this example.
3355 @sp 1
3356 The following is an example of a glossary-style list.
3357 @cindex example markup, glossary-style list [@code{ms}]
3358 @cindex glossary-style list, example markup [@code{ms}]
3360 @Example
3361 A glossary-style list:
3362 .IP lawyers 0.4i
3363 Two or more attorneys.
3364 .IP guns
3365 Firearms, preferably
3366 large-caliber.
3367 .IP money
3368 Gotta pay for those
3369 lawyers and guns!
3370 @endExample
3372 Produces:
3374 @Example
3375 A glossary-style list:
3377 lawyers
3378       Two or more attorneys.
3380 guns  Firearms, preferably large-caliber.
3382 money
3383       Gotta pay for those lawyers and guns!
3384 @endExample
3386 In the last example, the @code{IP} macro places the definition
3387 on the same line as the term if it has enough space; otherwise,
3388 it breaks to the next line and starts the definition below the
3389 term.
3390 This may or may not be the effect you want, especially if some
3391 of the definitions break and some do not.
3392 The following examples show two possible ways to force a break.
3394 The first workaround uses the @code{br}
3395 request to force a break after printing the term or label.
3397 @Example
3398 @cartouche
3399 A glossary-style list:
3400 .IP lawyers 0.4i
3401 Two or more attorneys.
3402 .IP guns
3404 Firearms, preferably large-caliber.
3405 .IP money
3406 Gotta pay for those lawyers and guns!
3407 @end cartouche
3408 @endExample
3410 @sp 1
3411 The second workaround uses the @code{\p} escape to force the break.
3412 Note the space following the escape; this is important.
3413 If you omit the space, @code{groff} prints the first word on
3414 the same line as the term or label (if it fits) @strong{then}
3415 breaks the line.
3417 @Example
3418 @cartouche
3419 A glossary-style list:
3420 .IP lawyers 0.4i
3421 Two or more attorneys.
3422 .IP guns
3423 \p Firearms, preferably large-caliber.
3424 .IP money
3425 Gotta pay for those lawyers and guns!
3426 @end cartouche
3427 @endExample
3429 @sp 1
3430 To set nested lists, use the @code{RS} and @code{RE} macros.
3431 @xref{Indents in ms}, for more information.
3432 @cindex @code{ms} macros, nested lists
3433 @cindex nested lists [@code{ms}]
3435 For example:
3437 @Example
3438 @cartouche
3439 .IP \[bu] 2
3440 Lawyers:
3442 .IP \[bu]
3443 Dewey,
3444 .IP \[bu]
3445 Cheatham,
3446 .IP \[bu]
3447 and Howe.
3449 .IP \[bu]
3450 Guns
3451 @end cartouche
3452 @endExample
3454 Produces:
3456 @Example
3457 o Lawyers:
3459   o  Dewey,
3461   o  Cheatham,
3463   o  and Howe.
3465 o Guns
3466 @endExample
3468 @c ---------------------------------------------------------------------
3470 @node Indents in ms, Tabstops in ms, Lists in ms, ms Body Text
3471 @subsubsection Indents
3473 In many situations,
3474 you may need to indent a section of text
3475 while still wrapping and filling.
3476 @xref{Lists in ms},
3477 for an example of nested lists.
3479 @DefmacList {RS, , ms}
3480 @DefmacListEnd {RE, , ms}
3481 These macros begin and end an indented section.
3482 The @code{PI} register controls the amount of indent,
3483 allowing the indented text to line up under hanging
3484 and indented paragraphs.
3485 @endDefmac
3487 @xref{ms Displays and Keeps},
3488 for macros to indent and turn off filling.
3490 @c ---------------------------------------------------------------------
3492 @node Tabstops in ms, ms Displays and Keeps, Indents in ms, ms Body Text
3493 @subsubsection Tab Stops
3495 Use the @code{ta} request to define tab stops as needed.
3496 @xref{Tabs and Fields}.
3498 @Defmac{TA, , ms}
3499 Use this macro to reset the tab stops to the default for @file{ms}
3500 (every 5n).
3501 You can redefine the @code{TA} macro to create a different set
3502 of default tab stops.
3503 @endDefmac
3505 @c ---------------------------------------------------------------------
3507 @node ms Displays and Keeps, ms Insertions, Tabstops in ms, ms Body Text
3508 @subsubsection Displays and keeps
3509 @cindex @code{ms} macros, displays
3510 @cindex @code{ms} macros, keeps
3511 @cindex keeps [@code{ms}]
3512 @cindex displays [@code{ms}]
3514 Use displays to show text-based examples or figures
3515 (such as code listings).
3517 Displays turn off filling, so lines of code are displayed
3518 as-is without inserting @code{br} requests in between each line.
3519 Displays can be @dfn{kept} on a single page, or allowed
3520 to break across pages.
3522 @DefmacList {DS, @t{L}, ms}
3523 @DefmacItem {LD, , ms}
3524 @DefmacListEnd {DE, , ms}
3525 Left-justified display.
3526 The @samp{.DS L} call generates a page break, if necessary,
3527 to keep the entire display on one page.
3528 The @code{LD} macro allows the display to break across pages.
3529 The @code{DE} macro ends the display.
3530 @endDefmac
3532 @DefmacList {DS, @t{I}, ms}
3533 @DefmacItem {ID, , ms}
3534 @DefmacListEnd {DE, , ms}
3535 Indents the display as defined by the @code{DI} register.
3536 The @samp{.DS I} call generates a page break, if necessary,
3537 to keep the entire display on one page.
3538 The @code{ID} macro allows the display to break across pages.
3539 The @code{DE} macro ends the display.
3540 @endDefmac
3542 @DefmacList {DS, @t{B}, ms}
3543 @DefmacItem {BD, , ms}
3544 @DefmacListEnd {DE, , ms}
3545 Sets a block-centered display: the entire display is left-justified,
3546 but indented so that the longest line in the display is centered
3547 on the page.
3548 The @samp{.DS B} call generates a page break, if necessary,
3549 to keep the entire display on one page.
3550 The @code{BD} macro allows the display to break across pages.
3551 The @code{DE} macro ends the display.
3552 @endDefmac
3554 @DefmacList {DS, @t{C}, ms}
3555 @DefmacItem {CD, , ms}
3556 @DefmacListEnd {DE, , ms}
3557 Sets a centered display: each line in the display is centered.
3558 The @samp{.DS C} call generates a page break, if necessary,
3559 to keep the entire display on one page.
3560 The @code{CD} macro allows the display to break across pages.
3561 The @code{DE} macro ends the display.
3562 @endDefmac
3564 @DefmacList {DS, @t{R}, ms}
3565 @DefmacItem {RD, , ms}
3566 @DefmacListEnd {DE, , ms}
3567 Right-justifies each line in the display.
3568 The @samp{.DS R} call generates a page break, if necessary,
3569 to keep the entire display on one page.
3570 The @code{RD} macro allows the display to break across pages.
3571 The @code{DE} macro ends the display.
3572 @endDefmac
3574 @DefmacList {Ds, , ms}
3575 @DefmacListEnd {De, , ms}
3576 These two macros are aliases for @code{DS} and @code{DE}, respectively.
3577 @endDefmac
3579 @sp 1
3580 On occasion, you may want to @dfn{keep} other text together on a page.
3581 For example, you may want to keep two paragraphs together, or
3582 a paragraph that refers to a table (or list, or other item)
3583 immediately following.
3584 The @file{ms} macros provide the @code{KS} and @code{KE}
3585 macros for this purpose.
3587 @DefmacList {KS, , ms}
3588 @DefmacListEnd {KE, , ms}
3589 The @code{KS} macro begins a block of text to be kept on a
3590 single page, and the @code{KE} macro ends the block.
3591 @endDefmac
3593 @DefmacList {KF, , ms}
3594 @DefmacListEnd {KE, , ms}
3595 Specifies a @dfn{floating keep};
3596 if the keep cannot fit on the current page, @code{groff}
3597 holds the contents of the keep and allows text following
3598 the keep (in the source file) to fill in the remainder of
3599 the current page.
3600 When the page breaks, whether by an explicit @code{bp}
3601 request or by reaching the end of the page, @code{groff}
3602 prints the floating keep at the top of the new page.
3603 This is useful for printing large graphics or tables
3604 that do not need to appear exactly where specified.
3605 @endDefmac
3607 You can also use the @code{ne} request to force a page break if
3608 there is not enough vertical space remaining on the page.
3610 @sp 1
3611 Use the following macros to draw a box around a section of
3612 text (such as a display).
3614 @DefmacList {B1, , ms}
3615 @DefmacListEnd {B2, , ms}
3616 Marks the beginning and ending of text that is to have a
3617 box drawn around it.
3618 The @code{B1} macro begins the box; the @code{B2} macro ends it.
3619 Text in the box is automatically placed in a diversion (keep).
3620 @endDefmac
3622 @c ---------------------------------------------------------------------
3624 @node ms Insertions, Example multi-page table, ms Displays and Keeps, ms Body Text
3625 @subsubsection Tables, figures, equations, and references
3626 @cindex @code{ms} macros, tables
3627 @cindex @code{ms} macros, figures
3628 @cindex @code{ms} macros, equations
3629 @cindex @code{ms} macros, references
3630 @cindex tables [@code{ms}]
3631 @cindex figures [@code{ms}]
3632 @cindex equations [@code{ms}]
3633 @cindex references [@code{ms}]
3635 The @file{ms} macros support the standard
3636 @code{groff} preprocessors:
3637 @code{tbl}, @code{pic}, @code{eqn}, and @code{refer}.
3638 @pindex tbl
3639 @pindex pic
3640 @pindex eqn
3641 @pindex refer
3642 You mark text meant for preprocessors by enclosing it
3643 in pairs of tags as follows.
3645 @DefmacList {TS, [@code{H}], ms}
3646 @DefmacListEnd {TE, , ms}
3647 Denotes a table, to be processed by the @code{tbl} preprocessor.
3648 The optional argument@tie{}@code{H} to @code{TS} instructs @code{groff}
3649 to create a running header with the information
3650 up to the @code{TH} macro.
3651 @code{groff} prints the header at the beginning of the
3652 table; if the table runs onto another page, @code{groff}
3653 prints the header on the next page as well.
3654 @endDefmac
3656 @DefmacList {PS, , ms}
3657 @DefmacListEnd {PE, , ms}
3658 Denotes a graphic, to be processed by the @code{pic} preprocessor.
3659 You can create a @code{pic} file by hand, using the @acronym{AT&T}
3660 @code{pic} manual available on the Web as a reference, or by using
3661 a graphics program such as @code{xfig}.
3662 @endDefmac
3664 @DefmacList {EQ, [@Var{align}], ms}
3665 @DefmacListEnd {EN, , ms}
3666 Denotes an equation, to be processed by the @code{eqn} preprocessor.
3667 The optional @var{align} argument can be @code{C}, @code{L},
3668 or@tie{}@code{I} to center (the default), left-justify, or indent the
3669 equation.
3670 @endDefmac
3672 @DefmacList {[, , ms}
3673 @DefmacListEnd {], , ms}
3674 Denotes a reference, to be processed by the @code{refer} preprocessor.
3675 The @acronym{GNU} @cite{refer(1)} man page provides a comprehensive
3676 reference to the preprocessor and the format of the bibliographic
3677 database.
3678 @endDefmac
3680 @menu
3681 * Example multi-page table::
3682 @end menu
3684 @c ---------------------------------------------------------------------
3686 @node Example multi-page table, ms Footnotes, ms Insertions, ms Body Text
3687 @subsubsection An example multi-page table
3688 @cindex example markup, multi-page table [@code{ms}]
3689 @cindex multi-page table, example markup [@code{ms}]
3691 The following is an example of how to set up a
3692 table that may print across two or more pages.
3694 @Example
3695 @cartouche
3696 .TS H
3697 allbox expand;
3698 cb | cb .
3699 Text      ...of heading...
3703 l | l .
3704 ... the rest of the table follows...
3707 @end cartouche
3708 @endExample
3710 @c ---------------------------------------------------------------------
3712 @node ms Footnotes,  , Example multi-page table, ms Body Text
3713 @subsubsection Footnotes
3714 @cindex @code{ms} macros, footnotes
3715 @cindex footnotes [@code{ms}]
3717 The @file{ms} macro package has a flexible footnote system.
3718 You can specify either numbered footnotes or symbolic footnotes
3719 (that is, using a marker such as a dagger symbol).
3721 @Defstr {*, ms}
3722 Specifies the location of a numbered footnote marker in the text.
3723 @endDefesc
3725 @DefmacList {FS, , ms}
3726 @DefmacListEnd {FE, , ms}
3727 Specifies the text of the footnote.
3728 The default action is to create a numbered footnote;
3729 you can create a symbolic footnote by specifying
3730 a @dfn{mark} glyph
3731 (such as @code{\[dg]} for the dagger glyph)
3732 in the body text and as an argument to the @code{FS} macro,
3733 followed by the text of the footnote
3734 and the @code{FE} macro.
3735 @endDefmac
3737 You can control how @code{groff}
3738 prints footnote numbers by changing the value of the
3739 @code{FF} register.  @xref{ms Document Control Registers}.
3741 @c ---------------------------------------------------------------------
3743 @node ms Page Layout, Differences from AT&T ms, ms Body Text, ms
3744 @subsection Page layout
3745 @cindex @code{ms} macros, page layout
3746 @cindex page layout [@code{ms}]
3748 The default output from the @file{ms}
3749 macros provides a minimalist page layout:
3750 it prints a single column, with the page number centered at the top
3751 of each page.
3752 It prints no footers.
3754 You can change the layout by setting
3755 the proper number registers and strings.
3757 @menu
3758 * ms Headers and Footers::
3759 * ms Margins::
3760 * ms Multiple Columns::
3761 * ms TOC::
3762 * ms Strings and Special Characters::
3763 @end menu
3765 @c ---------------------------------------------------------------------
3767 @node ms Headers and Footers, ms Margins, ms Page Layout, ms Page Layout
3768 @subsubsection Headers and footers
3769 @cindex @code{ms} macros, headers
3770 @cindex @code{ms} macros, footers
3771 @cindex headers [@code{ms}]
3772 @cindex footers [@code{ms}]
3774 For documents that do not distinguish between odd and even pages,
3775 set the following strings:
3777 @DefstrList {LH, ms}
3778 @DefstrItem {CH, ms}
3779 @DefstrListEnd {RH, ms}
3780 Sets the left, center, and right headers.
3781 @endDefstr
3783 @DefstrList {LF, ms}
3784 @DefstrItem {CF, ms}
3785 @DefstrListEnd {RF, ms}
3786 Sets the left, center, and right footers.
3787 @endDefstr
3789 @sp 1
3790 For documents that need different information printed in the
3791 even and odd pages, use the following macros:
3793 @DefmacList {OH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3794 @DefmacItem {EH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3795 @DefmacItem {OF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3796 @DefmacListEnd {EF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3797 The @code{OH} and @code{EH} macros define headers for the odd and even pages;
3798 the @code{OF} and @code{EF} macros define footers for the odd and even pages.
3799 This is more flexible than defining the individual strings.
3801 You can replace the quote (@code{'}) marks with any character not
3802 appearing in the header or footer text.
3803 @endDefmac
3805 @c ---------------------------------------------------------------------
3807 @node ms Margins, ms Multiple Columns, ms Headers and Footers, ms Page Layout
3808 @subsubsection Margins
3809 @cindex @code{ms} macros, margins
3811 You control margins using a set of number registers.
3812 @xref{ms Document Control Registers}, for details.
3814 @c ---------------------------------------------------------------------
3816 @node ms Multiple Columns, ms TOC, ms Margins, ms Page Layout
3817 @subsubsection Multiple columns
3818 @cindex @code{ms} macros, multiple columns
3819 @cindex multiple columns [@code{ms}]
3821 The @file{ms} macros can set text in as many columns as will
3822 reasonably fit on the page.
3823 The following macros are available;
3824 all of them force a page break if a multi-column mode is already set.
3825 However, if the current mode is single-column, starting a multi-column
3826 mode does @strong{not} force a page break.
3828 @Defmac {1C, , ms}
3829 Single-column mode.
3830 @endDefmac
3832 @Defmac {2C, , ms}
3833 Two-column mode.
3834 @endDefmac
3836 @Defmac {MC, [@Var{width} [@Var{gutter}]], ms}
3837 Multi-column mode.
3838 If you specify no arguments, it is equivalent to the
3839 @code{2C} macro.
3840 Otherwise, @var{width} is the width of each column and
3841 @var{gutter} is the space between columns.
3842 The @code{MINGW} number register controls the default gutter width.
3843 @endDefmac
3845 @c ---------------------------------------------------------------------
3847 @node ms TOC, ms Strings and Special Characters, ms Multiple Columns, ms Page Layout
3848 @subsubsection Creating a table of contents
3849 @cindex @code{ms} macros, creating table of contents
3850 @cindex table of contents, creating [@code{ms}]
3852 The facilities in the @file{ms} macro package for creating
3853 a table of contents are semi-automated at best.
3854 Assuming that you want the table of contents to consist of
3855 the document's headings, you need to repeat those headings
3856 wrapped in @code{XS} and @code{XE} macros.
3858 @DefmacList {XS, [@Var{page}], ms}
3859 @DefmacItem {XA, [@Var{page}], ms}
3860 @DefmacListEnd {XE, , ms}
3861 These macros define a table of contents
3862 or an individual entry in the table of contents,
3863 depending on their use.
3864 The macros are very simple; they cannot indent a heading based on its level.
3865 The easiest way to work around this is to add tabs
3866 to the table of contents string.
3867 The following is an example:
3869 @Example
3870 @cartouche
3871 .NH 1
3872 Introduction
3874 Introduction
3879 .NH 2
3880 Methodology
3882 Methodology
3886 @end cartouche
3887 @endExample
3889 You can manually create a table of contents
3890 by beginning with the @code{XS} macro for the first entry,
3891 specifying the page number for that entry as the argument to @code{XS}.
3892 Add subsequent entries using the @code{XA} macro,
3893 specifying the page number for that entry as the argument to @code{XA}.
3894 The following is an example:
3896 @Example
3897 @cartouche
3898 .XS 1
3899 Introduction
3900 .XA 2
3901 A Brief History of the Universe
3902 .XA 729
3903 Details of Galactic Formation
3906 @end cartouche
3907 @endExample
3908 @endDefmac
3910 @Defmac {TC, [@code{no}], ms}
3911 Prints the table of contents on a new page,
3912 setting the page number to@tie{}@strong{i} (Roman numeral one).
3913 You should usually place this macro at the end of the
3914 file, since @code{groff} is a single-pass formatter and
3915 can only print what has been collected up to the point
3916 that the @code{TC} macro appears.
3918 The optional argument @code{no} suppresses printing
3919 the title specified by the string register @code{TOC}.
3920 @endDefmac
3922 @Defmac{PX, [@code{no}], ms}
3923 Prints the table of contents on a new page,
3924 using the current page numbering sequence.
3925 Use this macro to print a manually-generated table of contents
3926 at the beginning of your document.
3928 The optional argument @code{no} suppresses printing
3929 the title specified by the string register @code{TOC}.
3930 @endDefmac
3932 The @cite{Groff and Friends HOWTO}
3933 includes a @code{sed} script that automatically inserts
3934 @code{XS} and @code{XE} macro entries after each heading in a document.
3936 Altering the @code{NH} macro to automatically build the table
3937 of contents is perhaps initially more difficult, but would save
3938 a great deal of time in the long run if you use @file{ms} regularly.
3940 @c ---------------------------------------------------------------------
3942 @node ms Strings and Special Characters,  , ms TOC, ms Page Layout
3943 @subsubsection Strings and Special Characters
3944 @cindex @code{ms} macros, strings
3945 @cindex @code{ms} macros, special characters
3946 @cindex @code{ms} macros, accent marks
3947 @cindex accent marks [@code{ms}]
3948 @cindex special characters [@code{ms}]
3949 @cindex strings [@code{ms}]
3951 The @file{ms} macros provide the following predefined strings.
3952 You can change the string definitions to help in creating
3953 documents in languages other than English.
3955 @Defstr {REFERENCES, ms}
3956 Contains the string printed at the beginning of the
3957 references (bibliography) page.
3958 The default is @samp{References}.
3959 @endDefstr
3961 @Defstr {ABSTRACT, ms}
3962 Contains the string printed at the beginning of the abstract.
3963 The default is @samp{ABSTRACT}.
3964 @endDefstr
3966 @Defstr {TOC, ms}
3967 Contains the string printed at the beginning of the table of contents.
3968 @endDefstr
3970 @DefstrList {MONTH1, ms}
3971 @DefstrItem {MONTH2, ms}
3972 @DefstrItem {MONTH3, ms}
3973 @DefstrItem {MONTH4, ms}
3974 @DefstrItem {MONTH5, ms}
3975 @DefstrItem {MONTH6, ms}
3976 @DefstrItem {MONTH7, ms}
3977 @DefstrItem {MONTH8, ms}
3978 @DefstrItem {MONTH9, ms}
3979 @DefstrItem {MONTH10, ms}
3980 @DefstrItem {MONTH11, ms}
3981 @DefstrListEnd {MONTH12, ms}
3982 Prints the full name of the month in dates.
3983 The default is @samp{January}, @samp{February}, etc.
3984 @endDefstr
3986 The following special characters are available@footnote{For an
3987 explanation what special characters are see @ref{Special Characters}.}:
3989 @Defstr {-, ms}
3990 Prints an em dash.
3991 @endDefstr
3993 @DefstrList {*Q, ms}
3994 @DefstrListEnd {*U, ms}
3995 Prints typographer's quotes in troff,
3996 plain quotes in nroff.
3997 @code{*Q} is the left quote and @code{*U} is the right quote.
3998 @endDefstr
4000 Improved accent marks are available in the @file{ms} macros.
4002 @Defmac {AM, , ms}
4003 Specify this macro at the beginning of your document
4004 to enable extended accent marks and special characters.
4005 This is a Berkeley extension.
4007 To use the accent marks, place them @strong{after}
4008 the character being accented.
4009 @endDefmac
4011 The following accent marks are available
4012 after invoking the @code{AM} macro:
4014 @Defstr {\', ms}
4015 Acute accent.
4016 @endDefstr
4018 @Defstr {\`, ms}
4019 Grave accent.
4020 @endDefstr
4022 @Defstr {^, ms}
4023 Circumflex.
4024 @endDefstr
4026 @Defstr {\,, ms}
4027 Cedilla.
4028 @endDefstr
4030 @Defstr {~, ms}
4031 Tilde.
4032 @endDefstr
4034 @deffn String @t{\*[:]}
4035 @ifnotinfo
4036 @stindex : @r{[}ms@r{]}
4037 @end ifnotinfo
4038 @ifinfo
4039 @stindex \*[@r{<colon>}] @r{[}ms@r{]}
4040 @end ifinfo
4041 Umlaut.
4042 @end deffn
4044 @Defstr {v, ms}
4045 Hacek.
4046 @endDefstr
4048 @Defstr {_, ms}
4049 Macron (overbar).
4050 @endDefstr
4052 @Defstr {., ms}
4053 Underdot.
4054 @endDefstr
4056 @Defstr {o, ms}
4057 Ring above.
4058 @endDefstr
4060 The following are standalone characters
4061 available after invoking the @code{AM} macro:
4063 @Defstr {?, ms}
4064 Upside-down question mark.
4065 @endDefstr
4067 @Defstr {!, ms}
4068 Upside-down exclamation point.
4069 @endDefstr
4071 @Defstr {8, ms}
4072 German ÃŸ ligature.
4073 @endDefstr
4075 @Defstr {3, ms}
4076 Yogh.
4077 @endDefstr
4079 @Defstr {Th, ms}
4080 Uppercase thorn.
4081 @endDefstr
4083 @Defstr {th, ms}
4084 Lowercase thorn.
4085 @endDefstr
4087 @Defstr {D-, ms}
4088 Uppercase eth.
4089 @endDefstr
4091 @Defstr {d-, ms}
4092 Lowercase eth.
4093 @endDefstr
4095 @Defstr {q, ms}
4096 Hooked o.
4097 @endDefstr
4099 @Defstr {ae, ms}
4100 Lowercase Ã¦ ligature.
4101 @endDefstr
4103 @Defstr {Ae, ms}
4104 Uppercase Ã† ligature.
4105 @endDefstr
4107 @c ---------------------------------------------------------------------
4109 @node Differences from AT&T ms,  , ms Page Layout, ms
4110 @subsection Differences from @acronym{AT&T} @file{ms}
4111 @cindex @code{ms} macros, differences from @acronym{AT&T}
4112 @cindex @acronym{AT&T} @code{troff}, @code{ms} macro package differences
4114 This section lists the (minor) differences between the
4115 @code{groff -ms} macros and @acronym{AT&T}
4116 @code{troff -ms} macros.
4118 @menu
4119 * Missing ms Macros::
4120 * Additional ms Macros::
4121 @end menu
4123 @c ---------------------------------------------------------------------
4125 @node Missing ms Macros, Additional ms Macros, Differences from AT&T ms, Differences from AT&T ms
4126 @subsubsection @code{troff} macros not appearing in @code{groff}
4128 Macros missing from @code{groff -ms}
4129 are cover page macros specific to Bell Labs.
4130 The macros known to be missing are:
4132 @table @code
4133 @item .TM
4134 Technical memorandum; a cover sheet style
4136 @item .IM
4137 Internal memorandum; a cover sheet style
4139 @item .MR
4140 Memo for record; a cover sheet style
4142 @item .MF
4143 Memo for file; a cover sheet style
4145 @item .EG
4146 Engineer's notes; a cover sheet style
4148 @item .TR
4149 Computing Science Tech Report; a cover sheet style
4151 @item .OK
4152 Other keywords
4154 @item .CS
4155 Cover sheet information
4157 @item .MH
4158 A cover sheet macro
4159 @end table
4161 @c ---------------------------------------------------------------------
4163 @node Additional ms Macros,  , Missing ms Macros, Differences from AT&T ms
4164 @subsubsection @code{groff} macros not appearing in @acronym{AT&T} @code{troff}
4166 The @code{groff -ms} macros have a few minor extensions
4167 compared to the @acronym{AT&T} @code{troff -ms} macros.
4169 @Defmac {AM, , ms}
4170 Improved accent marks.
4171 @xref{ms Strings and Special Characters}, for details.
4172 @endDefmac
4174 @Defmac {DS, @t{I}, ms}
4175 Indented display.
4176 The default behavior of @acronym{AT&T} @code{troff -ms}
4177 was to indent; the @code{groff} default prints displays
4178 flush left with the body text.
4179 @endDefmac
4181 @Defmac {CW, , ms}
4182 Print text in @code{constant width} (Courier) font.
4183 @endDefmac
4185 @Defmac {IX, , ms}
4186 Indexing term (printed on standard error).
4187 You can write a script to capture and process an index
4188 generated in this manner.
4189 @endDefmac
4191 @sp 1
4192 The following additional number registers
4193 appear in @code{groff -ms}:
4195 @Defmpreg {MINGW, ms}
4196 Specifies a minimum space
4197 between columns (for multi-column output); this takes the
4198 place of the @code{GW} register that was documented but apparently
4199 not implemented in @acronym{AT&T} @code{troff}.
4200 @endDefmpreg
4202 @sp 1
4203 Several new string registers are available as well.
4204 You can change these to handle (for example) the local language.
4205 @xref{ms Strings and Special Characters}, for details.
4208 @c =====================================================================
4210 @node me, mm, ms, Macro Packages
4211 @section @file{me}
4212 @cindex @code{me} macro package
4214 @c XXX documentation
4215 @c XXX this is a placeholder until we get stuff knocked into shape
4216 See the @file{meintro.me} and @file{meref.me} documents in
4217 groff's @file{doc} directory.
4220 @c =====================================================================
4222 @node mm,  , me, Macro Packages
4223 @section @file{mm}
4224 @cindex @code{mm} macro package
4226 @c XXX documentation
4227 @c XXX this is a placeholder until we get stuff knocked into shape
4228 See the @cite{groff_mm(7)} man page (type @command{man groff_mm} at
4229 the command line).
4232 @c =====================================================================
4233 @c =====================================================================
4235 @node gtroff Reference, Preprocessors, Macro Packages, Top
4236 @chapter @code{gtroff} Reference
4237 @cindex reference, @code{gtroff}
4238 @cindex @code{gtroff}, reference
4240 This chapter covers @strong{all} of the facilities of @code{gtroff}.
4241 Users of macro packages may skip it if not interested in details.
4244 @menu
4245 * Text::
4246 * Measurements::
4247 * Expressions::
4248 * Identifiers::
4249 * Embedded Commands::
4250 * Registers::
4251 * Manipulating Filling and Adjusting::
4252 * Manipulating Hyphenation::
4253 * Manipulating Spacing::
4254 * Tabs and Fields::
4255 * Character Translations::
4256 * Troff and Nroff Mode::
4257 * Line Layout::
4258 * Line Control::
4259 * Page Layout::
4260 * Page Control::
4261 * Fonts and Symbols::
4262 * Sizes::
4263 * Strings::
4264 * Conditionals and Loops::
4265 * Writing Macros::
4266 * Page Motions::
4267 * Drawing Requests::
4268 * Traps::
4269 * Diversions::
4270 * Environments::
4271 * Suppressing output::
4272 * Colors::
4273 * I/O::
4274 * Postprocessor Access::
4275 * Miscellaneous::
4276 * Gtroff Internals::
4277 * Debugging::
4278 * Implementation Differences::
4279 @end menu
4282 @c =====================================================================
4284 @node Text, Measurements, gtroff Reference, gtroff Reference
4285 @section Text
4286 @cindex text, @code{gtroff} processing
4288 @code{gtroff} input files contain text with control commands
4289 interspersed throughout.  But, even without control codes, @code{gtroff}
4290 still does several things with the input text:
4292 @itemize @bullet
4293 @item
4294 filling and adjusting
4296 @item
4297 adding additional space after sentences
4299 @item
4300 hyphenating
4302 @item
4303 inserting implicit line breaks
4304 @end itemize
4306 @menu
4307 * Filling and Adjusting::
4308 * Hyphenation::
4309 * Sentences::
4310 * Tab Stops::
4311 * Implicit Line Breaks::
4312 * Input Conventions::
4313 * Input Encodings::
4314 @end menu
4316 @c ---------------------------------------------------------------------
4318 @node Filling and Adjusting, Hyphenation, Text, Text
4319 @subsection Filling and Adjusting
4320 @cindex filling
4321 @cindex adjusting
4323 When @code{gtroff} reads text, it collects words from the input and fits
4324 as many of them together on one output line as it can.  This is known as
4325 @dfn{filling}.
4327 @cindex leading spaces
4328 @cindex spaces, leading and trailing
4329 @cindex extra spaces
4330 @cindex trailing spaces
4331 Once @code{gtroff} has a @dfn{filled} line, it tries to @dfn{adjust}
4332 it.  This means it widens the spacing between words until the text
4333 reaches the right margin (in the default adjustment mode).  Extra spaces
4334 between words are preserved, but spaces at the end of lines are ignored.
4335 Spaces at the front of a line cause a @dfn{break} (breaks are
4336 explained in @ref{Implicit Line Breaks}).
4338 @xref{Manipulating Filling and Adjusting}.
4340 @c ---------------------------------------------------------------------
4342 @node Hyphenation, Sentences, Filling and Adjusting, Text
4343 @subsection Hyphenation
4344 @cindex hyphenation
4346 Since the odds are not great for finding a set of words, for every
4347 output line, which fit nicely on a line without inserting excessive
4348 amounts of space between words, @code{gtroff} hyphenates words so
4349 that it can justify lines without inserting too much space between
4350 words.  It uses an internal hyphenation algorithm (a simplified version
4351 of the algorithm used within @TeX{}) to indicate which words can be
4352 hyphenated and how to do so.  When a word is hyphenated, the first part
4353 of the word is added to the current filled line being output (with
4354 an attached hyphen), and the other portion is added to the next
4355 line to be filled.
4357 @xref{Manipulating Hyphenation}.
4359 @c ---------------------------------------------------------------------
4361 @node Sentences, Tab Stops, Hyphenation, Text
4362 @subsection Sentences
4363 @cindex sentences
4365 Although it is often debated, some typesetting rules say there should be
4366 different amounts of space after various punctuation marks.  For
4367 example, the @cite{Chicago typsetting manual} says that a period at the
4368 end of a sentence should have twice as much space following it as would
4369 a comma or a period as part of an abbreviation.
4371 @c XXX exact citation of Chicago manual
4373 @cindex sentence space
4374 @cindex space between sentences
4375 @cindex french-spacing
4376 @code{gtroff} does this by flagging certain characters (normally
4377 @samp{!}, @samp{?}, and @samp{.}) as @dfn{end-of-sentence} characters.
4378 When @code{gtroff} encounters one of these characters at the end of a
4379 line, it appends a normal space followed by a @dfn{sentence space} in
4380 the formatted output.  (This justifies one of the conventions mentioned
4381 in @ref{Input Conventions}.)
4383 @cindex transparent characters
4384 @cindex character, transparent
4385 @cindex @code{dg} glyph, at end of sentence
4386 @cindex @code{rq} glyph, at end of sentence
4387 @cindex @code{"}, at end of sentence
4388 @cindex @code{'}, at end of sentence
4389 @cindex @code{)}, at end of sentence
4390 @cindex @code{]}, at end of sentence
4391 @cindex @code{*}, at end of sentence
4392 In addition, the following characters and symbols are treated
4393 transparently while handling end-of-sentence characters: @samp{"},
4394 @samp{'}, @samp{)}, @samp{]}, @samp{*}, @code{\[dg]}, and @code{\[rq]}.
4396 See the @code{cflags} request in @ref{Using Symbols}, for more details.
4398 @cindex @code{\&}, at end of sentence
4399 To prevent the insertion of extra space after an end-of-sentence
4400 character (at the end of a line), append @code{\&}.
4402 @c ---------------------------------------------------------------------
4404 @node Tab Stops, Implicit Line Breaks, Sentences, Text
4405 @subsection Tab Stops
4406 @cindex tab stops
4407 @cindex stops, tabulator
4408 @cindex tab character
4409 @cindex character, tabulator
4411 @cindex @acronym{EBCDIC} encoding
4412 @cindex encoding, @acronym{EBCDIC}
4413 @code{gtroff} translates @dfn{tabulator characters}, also called
4414 @dfn{tabs} (normally code point @acronym{ASCII} @code{0x09} or
4415 @acronym{EBCDIC} @code{0x05}), in the input into movements to the next
4416 tabulator stop.  These tab stops are initially located every half inch
4417 across the page.  Using this, simple tables can be made easily.
4418 However, it can often be deceptive as the appearance (and width) of the
4419 text on a terminal and the results from @code{gtroff} can vary greatly.
4421 Also, a possible sticking point is that lines beginning with tab
4422 characters are still filled, again producing unexpected results.
4423 For example, the following input
4425 @multitable {12345678} {12345678} {12345678} {12345678}
4426 @item
4427 @tab 1 @tab 2 @tab 3
4428 @item
4429 @tab   @tab 4 @tab 5
4430 @end multitable
4432 @noindent
4433 produces
4435 @multitable {12345678} {12345678} {12345678} {12345678} {12345678} {12345678} {12345678}
4436 @item
4437 @tab 1 @tab 2 @tab 3 @tab   @tab 4 @tab 5
4438 @end multitable
4440 @xref{Tabs and Fields}.
4442 @c ---------------------------------------------------------------------
4444 @node Implicit Line Breaks, Input Conventions, Tab Stops, Text
4445 @subsection Implicit Line Breaks
4446 @cindex implicit line breaks
4447 @cindex implicit breaks of lines
4448 @cindex line, implicit breaks
4449 @cindex break, implicit
4450 @cindex line break
4452 An important concept in @code{gtroff} is the @dfn{break}.  When a break
4453 occurs, @code{gtroff} outputs the partially filled line
4454 (unjustified), and resumes collecting and filling text on the next output
4455 line.
4457 @cindex blank line
4458 @cindex empty line
4459 @cindex line, blank
4460 @cindex blank line macro (@code{blm})
4461 There are several ways to cause a break in @code{gtroff}.  A blank
4462 line not only causes a break, but it also outputs a one-line vertical
4463 space (effectively a blank line).  Note that this behaviour can be
4464 modified with the blank line macro request @code{blm}.
4465 @xref{Blank Line Traps}.
4467 @cindex fill mode
4468 @cindex mode, fill
4469 A line that begins with a space causes a break and the space is
4470 output at the beginning of the next line.  Note that this space isn't
4471 adjusted, even in fill mode.
4473 The end of file also causes a break -- otherwise the last line of
4474 the document may vanish!
4476 Certain requests also cause breaks, implicitly or explicitly.  This is
4477 discussed in @ref{Manipulating Filling and Adjusting}.
4479 @c ---------------------------------------------------------------------
4481 @node Input Conventions, Input Encodings, Implicit Line Breaks, Text
4482 @subsection Input Conventions
4483 @cindex input conventions
4484 @cindex conventions for input
4486 Since @code{gtroff} does filling automatically, it is traditional in
4487 @code{groff} not to try and type things in as nicely formatted
4488 paragraphs.  These are some conventions commonly used when typing
4489 @code{gtroff} text:
4491 @itemize @bullet
4492 @item
4493 Break lines after punctuation, particularly at the end of a sentence
4494 and in other logical places.  Keep separate phrases on lines by
4495 themselves, as entire phrases are often added or deleted when editing.
4497 @item
4498 Try to keep lines less than 40-60@tie{}characters, to allow space for
4499 inserting more text.
4501 @item
4502 Do not try to do any formatting in a @acronym{WYSIWYG} manner (i.e.,
4503 don't try using spaces to get proper indentation).
4504 @end itemize
4506 @c ---------------------------------------------------------------------
4508 @node Input Encodings,  , Input Conventions, Text
4509 @subsection Input Encodings
4511 Currently, the following input encodings are available.
4513 @table @asis
4514 @item cp1047
4515 @cindex encoding, input, @acronym{EBCDIC}
4516 @cindex @acronym{EBCDIC}, input encoding
4517 @cindex input encoding, @acronym{EBCDIC}
4518 @cindex encoding, input, cp1047
4519 @cindex cp1047, input encoding
4520 @cindex input encoding, cp1047
4521 @cindex IBM cp1047 input encoding
4522 @pindex cp1047.tmac
4523 This input encoding works only on @acronym{EBCDIC} platforms (and vice
4524 versa, the other input encodings don't work with @acronym{EBCDIC}); the
4525 file @file{cp1047.tmac} is by default loaded at start-up.
4527 @item latin-1
4528 @cindex encoding, input, @w{latin-1} (ISO @w{8859-1})
4529 @cindex @w{latin-1} (ISO @w{8859-1}), input encoding
4530 @cindex ISO @w{8859-1} (@w{latin-1}), input encoding
4531 @cindex input encoding, @w{latin-1} (ISO @w{8859-1})
4532 @pindex latin1.tmac
4533 This is the default input encoding on non-@acronym{EBCDIC} platforms;
4534 the file @file{latin1.tmac} is loaded at start-up.
4536 @item latin-2
4537 @cindex encoding, input, @w{latin-2} (ISO @w{8859-2})
4538 @cindex @w{latin-2} (ISO @w{8859-2}), input encoding
4539 @cindex ISO @w{8859-2} (@w{latin-2}), input encoding
4540 @cindex input encoding, @w{latin-2} (ISO @w{8859-2})
4541 @pindex latin2.tmac
4542 To use this encoding, either say @w{@samp{.mso latin2.tmac}} at the very
4543 beginning of your document or use @samp{-mlatin2} as a command line
4544 argument for @code{groff}.
4546 @item latin-9 (latin-0)
4547 @cindex encoding, input, @w{latin-9} (@w{latin-0}, ISO @w{8859-15})
4548 @cindex @w{latin-9} (@w{latin-0}, ISO @w{8859-15}), input encoding
4549 @cindex ISO @w{8859-15} (@w{latin-9}, @w{latin-0}), input encoding
4550 @cindex input encoding, @w{latin-9} (@w{latin-9}, ISO @w{8859-15})
4551 @pindex latin9.tmac
4552 This encoding is intended (at least in Europe) to replace @w{latin-1}
4553 encoding.  The main difference to @w{latin-1} is that @w{latin-9}
4554 contains the Euro character.  To use this encoding, either say
4555 @w{@samp{.mso latin9.tmac}} at the very beginning of your document or
4556 use @samp{-mlatin9} as a command line argument for @code{groff}.
4557 @end table
4559 Note that it can happen that some input encoding characters are not
4560 available for a particular output device.  For example, saying
4562 @Example
4563 groff -Tlatin1 -mlatin9 ...
4564 @endExample
4566 @noindent
4567 will fail if you use the Euro character in the input.  Usually, this
4568 limitation is present only for devices which have a limited set of
4569 output glyphs (e.g.@: @option{-Tascii} and @option{-Tlatin1}); for other
4570 devices it is usually sufficient to install proper fonts which contain
4571 the necessary glyphs.
4573 @pindex freeeuro.pfa
4574 @pindex ec.tmac
4575 Due to the importance of the Euro glyph in Europe, the groff package now
4576 comes with a @sc{PostScript} font called @file{freeeuro.pfa} which
4577 provides various glyph shapes for the Euro.  With other words,
4578 @w{latin-9} encoding is supported for the @option{-Tps} device out of
4579 the box (@w{latin-2} isn't).
4581 By its very nature, @option{-Tutf8} supports all input encodings;
4582 @option{-Tdvi} has support for both @w{latin-2} and @w{latin-9} if the
4583 command line @option{-mec} is used also to load the file @file{ec.tmac}
4584 (which flips to the EC fonts).
4587 @c =====================================================================
4589 @node Measurements, Expressions, Text, gtroff Reference
4590 @section Measurements
4591 @cindex measurements
4593 @cindex units of measurement
4594 @cindex basic unit (@code{u})
4595 @cindex machine unit (@code{u})
4596 @cindex measurement unit
4597 @cindex @code{u} unit
4598 @cindex unit, @code{u}
4599 @code{gtroff} (like many other programs) requires numeric parameters to
4600 specify various measurements.  Most numeric parameters@footnote{those
4601 that specify vertical or horizontal motion or a type size} may have a
4602 @dfn{measurement unit} attached.  These units are specified as a single
4603 character which immediately follows the number or expression.  Each of
4604 these units are understood, by @code{gtroff}, to be a multiple of its
4605 @dfn{basic unit}.  So, whenever a different measurement unit is
4606 specified @code{gtroff} converts this into its @dfn{basic units}.  This
4607 basic unit, represented by a @samp{u}, is a device dependent measurement
4608 which is quite small, ranging from 1/75@dmn{th} to 1/72000@dmn{th} of an
4609 inch.  The values may be given as fractional numbers; however,
4610 fractional basic units are always rounded to integers.
4612 Some of the measurement units are completely independent of any of the
4613 current settings (e.g.@: type size) of @code{gtroff}.
4615 @table @code
4616 @item i
4617 @cindex inch unit (@code{i})
4618 @cindex @code{i} unit
4619 @cindex unit, @code{i}
4620 Inches.  An antiquated measurement unit still in use in certain
4621 backwards countries with incredibly low-cost computer equipment.  One
4622 inch is equal to@tie{}2.54@dmn{cm}.
4624 @item c
4625 @cindex centimeter unit (@code{c})
4626 @cindex @code{c} unit
4627 @cindex unit, @code{c}
4628 Centimeters.  One centimeter is equal to@tie{}0.3937@dmn{in}.
4630 @item p
4631 @cindex point unit (@code{p})
4632 @cindex @code{p} unit
4633 @cindex unit, @code{p}
4634 Points.  This is a typesetter's measurement used for measure type size.
4635 It is 72@tie{}points to an inch.
4637 @item P
4638 @cindex pica unit (@code{P})
4639 @cindex @code{P} unit
4640 @cindex unit, @code{P}
4641 Pica.  Another typesetting measurement.  6@tie{}Picas to an inch (and
4642 12@tie{}points to a pica).
4644 @item s
4645 @itemx z
4646 @cindex @code{s} unit
4647 @cindex unit, @code{s}
4648 @cindex @code{z} unit
4649 @cindex unit, @code{z}
4650 @xref{Fractional Type Sizes}, for a discussion of these units.
4652 @item f
4653 @cindex @code{f} unit
4654 @cindex unit, @code{f}
4655 Fractions. Value is 65536.
4656 @xref{Colors}, for usage.
4657 @end table
4659 The other measurements understood by @code{gtroff} depend on
4660 settings currently in effect in @code{gtroff}.  These are very useful
4661 for specifying measurements which should look proper with any size of
4662 text.
4664 @table @code
4665 @item m
4666 @cindex em unit (@code{m})
4667 @cindex @code{m} unit
4668 @cindex unit, @code{m}
4669 Ems.  This unit is equal to the current font size in points.  So called
4670 because it is @emph{approximately} the width of the letter@tie{}@samp{m}
4671 in the current font.
4673 @item n
4674 @cindex en unit (@code{n})
4675 @cindex @code{n} unit
4676 @cindex unit, @code{n}
4677 Ens.  In @code{groff}, this is half of an em.
4679 @item v
4680 @cindex vertical space unit (@code{v})
4681 @cindex space, vertical, unit (@code{v})
4682 @cindex @code{v} unit
4683 @cindex unit, @code{v}
4684 Vertical space.  This is equivalent to the current line spacing.
4685 @xref{Sizes}, for more information about this.
4687 @item M
4688 @cindex @code{M} unit
4689 @cindex unit, @code{M}
4690 100ths of an em.
4691 @end table
4693 @menu
4694 * Default Units::
4695 @end menu
4697 @c ---------------------------------------------------------------------
4699 @node Default Units,  , Measurements, Measurements
4700 @subsection Default Units
4701 @cindex default units
4702 @cindex units, default
4704 Many requests take a default unit.  While this can be helpful at times,
4705 it can cause strange errors in some expressions.  For example, the line
4706 length request expects em units.  Here are several attempts to get a
4707 line length of 3.5@tie{}inches and their results:
4709 @Example
4710 3.5i      @result{}   3.5i
4711 7/2       @result{}   0i
4712 7/2i      @result{}   0i
4713 (7 / 2)u  @result{}   0i
4714 7i/2      @result{}   0.1i
4715 7i/2u     @result{}   3.5i
4716 @endExample
4718 @noindent
4719 Everything is converted to basic units first.  In the above example it
4720 is assumed that 1@dmn{i} equals@tie{}240@dmn{u}, and 1@dmn{m}
4721 equals@tie{}10@dmn{p} (thus 1@dmn{m} equals@tie{}33@dmn{u}).  The value
4722 7@dmn{i}/2 is first handled as 7@dmn{i}/2@dmn{m}, then converted to
4723 1680@dmn{u}/66@dmn{u} which is 25@dmn{u}, and this is approximately
4724 0.1@dmn{i}.  As can be seen, a scaling indicator after a closing
4725 parenthesis is simply ignored.
4727 @cindex measurements, specifying safely
4728 Thus, the safest way to specify measurements is to always
4729 attach a scaling indicator.  If you want to multiply or divide by a
4730 certain scalar value, use @samp{u} as the unit for that value.
4733 @c =====================================================================
4735 @node Expressions, Identifiers, Measurements, gtroff Reference
4736 @section Expressions
4737 @cindex expressions
4739 @code{gtroff} has most arithmetic operators common to other languages:
4741 @itemize @bullet
4742 @item
4743 @cindex arithmetic operators
4744 @cindex operators, arithmetic
4745 @opindex +
4746 @opindex -
4747 @opindex /
4748 @opindex *
4749 @opindex %
4750 Arithmetic: @samp{+} (addition), @samp{-} (subtraction), @samp{/}
4751 (division), @samp{*} (multiplication), @samp{%} (modulo).
4753 @code{gtroff} only provides integer arithmetic.  The internal type used
4754 for computing results is @samp{int}, which is usually a 32@dmn{bit}
4755 signed integer.
4757 @item
4758 @cindex comparison operators
4759 @cindex operators, comparison
4760 @opindex <
4761 @opindex >
4762 @opindex >=
4763 @opindex <=
4764 @opindex =
4765 @opindex ==
4766 Comparison: @samp{<} (less than), @samp{>} (greater than), @samp{<=}
4767 (less than or equal), @samp{>=} (greater than or equal), @samp{=}
4768 (equal), @samp{==} (the same as @samp{=}).
4770 @item
4771 @cindex logical operators
4772 @cindex operators, logical
4773 @opindex &
4774 @ifnotinfo
4775 @opindex :
4776 @end ifnotinfo
4777 @ifinfo
4778 @opindex @r{<colon>}
4779 @end ifinfo
4780 Logical: @samp{&} (logical and), @samp{:} (logical or).
4782 @item
4783 @cindex unary operators
4784 @cindex operators, unary
4785 @opindex -
4786 @opindex +
4787 @opindex !
4788 @cindex @code{if} request, and the @samp{!} operator
4789 @cindex @code{while} request, and the @samp{!} operator
4790 Unary operators: @samp{-} (negating, i.e.@: changing the sign), @samp{+}
4791 (just for completeness; does nothing in expressions), @samp{!} (logical
4792 not; this works only within @code{if} and @code{while} requests).  See
4793 below for the use of unary operators in motion requests.
4795 @item
4796 @cindex extremum operators (@code{>?}, @code{<?})
4797 @cindex operators, extremum (@code{>?}, @code{<?})
4798 @opindex >?
4799 @opindex <?
4800 Extrema: @samp{>?} (maximum), @samp{<?} (minimum).
4802 Example:
4804 @Example
4805 .nr x 5
4806 .nr y 3
4807 .nr z (\n[x] >? \n[y])
4808 @endExample
4810 @noindent
4811 The register@tie{}@code{z} now contains@tie{}5.
4813 @item
4814 @cindex scaling operator
4815 @cindex operator, scaling
4816 Scaling: @code{(@var{c};@var{e})}.  Evaluate@tie{}@var{e} using@tie{}@var{c}
4817 as the default scaling indicator.  If @var{c} is missing, ignore scaling
4818 indicators in the evaluation of@tie{}@var{e}.
4819 @end itemize
4821 @cindex parentheses
4822 @cindex order of evaluation in expressions
4823 @cindex expression, order of evaluation
4824 @opindex (
4825 @opindex )
4826 Parentheses may be used as in any other language.  However, in
4827 @code{gtroff} they are necessary to ensure order of evaluation.
4828 @code{gtroff} has no operator precedence; expressions are evaluated left
4829 to right.  This means that @code{gtroff} evaluates @samp{3+5*4} as if it were
4830 parenthesized like @samp{(3+5)*4}, not as @samp{3+(5*4)}, as might be
4831 expected.
4833 @cindex @code{+}, and page motion
4834 @cindex @code{-}, and page motion
4835 @cindex motion operators
4836 @cindex operators, motion
4837 For many requests which cause a motion on the page, the unary operators
4838 @samp{+} and @samp{-} work differently if leading an expression.  They
4839 then indicate a motion relative to the current position (down or up,
4840 respectively).
4842 @cindex @code{|}, and page motion
4843 @cindex absolute position operator (@code{|})
4844 @cindex position, absolute, operator (@code{|})
4845 Similarly, a leading @samp{|} operator indicates an absolute position.
4846 For vertical movements, it specifies the distance from the top of the
4847 page; for horizontal movements, it gives the distance from the beginning
4848 of the @emph{input} line.
4850 @cindex @code{bp} request, using @code{+} and@tie{}@code{-}
4851 @cindex @code{in} request, using @code{+} and@tie{}@code{-}
4852 @cindex @code{ll} request, using @code{+} and@tie{}@code{-}
4853 @cindex @code{lt} request, using @code{+} and@tie{}@code{-}
4854 @cindex @code{nm} request, using @code{+} and@tie{}@code{-}
4855 @cindex @code{nr} request, using @code{+} and@tie{}@code{-}
4856 @cindex @code{pl} request, using @code{+} and@tie{}@code{-}
4857 @cindex @code{pn} request, using @code{+} and@tie{}@code{-}
4858 @cindex @code{po} request, using @code{+} and@tie{}@code{-}
4859 @cindex @code{ps} request, using @code{+} and@tie{}@code{-}
4860 @cindex @code{pvs} request, using @code{+} and@tie{}@code{-}
4861 @cindex @code{rt} request, using @code{+} and@tie{}@code{-}
4862 @cindex @code{ti} request, using @code{+} and@tie{}@code{-}
4863 @cindex @code{\H}, using @code{+} and@tie{}@code{-}
4864 @cindex @code{\R}, using @code{+} and@tie{}@code{-}
4865 @cindex @code{\s}, using @code{+} and@tie{}@code{-}
4866 @samp{+} and @samp{-} are also treated differently by the following
4867 requests and escapes: @code{bp}, @code{in}, @code{ll}, @code{lt},
4868 @code{nm}, @code{nr}, @code{pl}, @code{pn}, @code{po}, @code{ps},
4869 @code{pvs}, @code{rt}, @code{ti}, @code{\H}, @code{\R}, and @code{\s}.
4870 Here, leading plus and minus signs indicate increments and decrements.
4872 @xref{Setting Registers}, for some examples.
4874 @Defesc {\\B, ', anything, '}
4875 @cindex numeric expression, valid
4876 @cindex valid numeric expression
4877 Return@tie{}1 if @var{anything} is a valid numeric expression;
4878 or@tie{}0 if @var{anything} is empty or not a valid numeric expression.
4879 @endDefesc
4881 @cindex space characters, in expressions
4882 @cindex expressions, and space characters
4883 Due to the way arguments are parsed, spaces are not allowed in
4884 expressions, unless the entire expression is surrounded by parentheses.
4886 @xref{Request and Macro Arguments}, and @ref{Conditionals and Loops}.
4889 @c =====================================================================
4891 @node Identifiers, Embedded Commands, Expressions, gtroff Reference
4892 @section Identifiers
4893 @cindex identifiers
4895 Like any other language, @code{gtroff} has rules for properly formed
4896 @dfn{identifiers}.  In @code{gtroff}, an identifier can be made up of
4897 almost any printable character, with the exception of the following
4898 characters:
4900 @itemize @bullet
4901 @item
4902 @cindex whitespace characters
4903 @cindex newline character
4904 @cindex character, whitespace
4905 Whitespace characters (spaces, tabs, and newlines).
4907 @item
4908 @cindex character, backspace
4909 @cindex backspace character
4910 @cindex @acronym{EBCDIC} encoding of backspace
4911 Backspace (@acronym{ASCII}@tie{}@code{0x08} or
4912 @acronym{EBCDIC}@tie{}@code{0x16}) and character code @code{0x01}.
4914 @item
4915 @cindex invalid input characters
4916 @cindex input characters, invalid
4917 @cindex characters, invalid input
4918 @cindex Unicode
4919 The following input characters are invalid and are ignored if
4920 @code{groff} runs on a machine based on @acronym{ASCII}, causing a
4921 warning message of type @samp{input} (see @ref{Debugging}, for more
4922 details): @code{0x00}, @code{0x0B}, @code{0x0D}-@code{0x1F},
4923 @code{0x80}-@code{0x9F}.
4925 And here are the invalid input characters if @code{groff} runs on an
4926 @acronym{EBCDIC} host: @code{0x00}, @code{0x08}, @code{0x09},
4927 @code{0x0B}, @code{0x0D}-@code{0x14}, @code{0x17}-@code{0x1F},
4928 @code{0x30}-@code{0x3F}.
4930 Currently, some of these reserved codepoints are used internally, thus
4931 making it non-trivial to extend @code{gtroff} to cover Unicode or other
4932 character sets and encodings which use characters of these ranges.
4934 Note that invalid characters are removed before parsing; an
4935 identifier @code{foo}, followed by an invalid character, followed by
4936 @code{bar} is treated as @code{foobar}.
4937 @end itemize
4939 For example, any of the following is valid.
4941 @Example
4945 end-list
4947 @endExample
4949 @cindex @code{]}, as part of an identifier
4950 @noindent
4951 Note that identifiers longer than two characters with a closing bracket
4952 (@samp{]}) in its name can't be accessed with escape sequences which
4953 expect an identifier as a parameter.  For example, @samp{\[foo]]}
4954 accesses the glyph @samp{foo}, followed by @samp{]}, whereas
4955 @samp{\C'foo]'} really asks for glyph @samp{foo]}.
4957 @cindex @code{refer}, and macro names starting with @code{[} or @code{]}
4958 @cindex @code{[}, macro names starting with, and @code{refer}
4959 @cindex @code{]}, macro names starting with, and @code{refer}
4960 @cindex macro names, starting with @code{[} or @code{]}, and @code{refer}
4961 To avoid problems with the @code{refer} preprocessor, macro names
4962 should not start with @samp{[} or @samp{]}.  Due to backwards
4963 compatibility, everything after @samp{.[} and @samp{.]} is handled as
4964 a special argument to @code{refer}.  For example, @samp{.[foo} makes
4965 @code{refer} to start a reference, using @samp{foo} as a parameter.
4967 @Defesc {\\A, ', ident, '}
4968 Test whether an identifier @var{ident} is valid in @code{gtroff}.  It
4969 expands to the character@tie{}1 or@tie{}0 according to whether its
4970 argument (usually delimited by quotes) is or is not acceptable as the
4971 name of a string, macro, diversion, number register, environment, or
4972 font.  It returns@tie{}0 if no argument is given.  This is useful for
4973 looking up user input in some sort of associative table.
4975 @Example
4976 \A'end-list'
4977     @result{} 1
4978 @endExample
4979 @endDefesc
4981 @xref{Escapes}, for details on parameter delimiting characters.
4983 Identifiers in @code{gtroff} can be any length, but, in some contexts,
4984 @code{gtroff} needs to be told where identifiers end and text begins
4985 (and in different ways depending on their length):
4987 @itemize @bullet
4988 @item
4989 Single character.
4991 @cindex @code{(}, starting a two-character identifier
4992 @item
4993 Two characters.  Must be prefixed with @samp{(} in some situations.
4995 @cindex @code{[}, starting an identifier
4996 @cindex @code{]}, ending an identifier
4997 @item
4998 Arbitrary length (@code{gtroff} only).  Must be bracketed with @samp{[}
4999 and@tie{}@samp{]} in some situations.  Any length identifier can be put
5000 in brackets.
5001 @end itemize
5003 @cindex undefined identifiers
5004 @cindex identifiers, undefined
5005 Unlike many other programming languages, undefined identifiers are
5006 silently ignored or expanded to nothing.
5007 When @code{gtroff} finds an undefined identifier, it emits a
5008 warning, doing the following:
5010 @itemize @bullet
5011 @item
5012 If the identifier is a string, macro, or diversion,
5013 @code{gtroff} defines it as empty.
5015 @item
5016 If the identifier is a number register, @code{gtroff}
5017 defines it with a value of@tie{}0.
5018 @end itemize
5020 @xref{Warnings}., @ref{Interpolating Registers}, and @ref{Strings}.
5022 Note that macros, strings, and diversions share the same name space.
5024 @Example
5025 .de xxx
5026 .  nop foo
5029 .di xxx
5034 .xxx
5035     @result{} bar
5036 @endExample
5038 @noindent
5039 As can be seen in the previous example, @code{gtroff} reuses the
5040 identifier @samp{xxx}, changing it from a macro to a diversion.
5041 No warning is emitted!  The contents of the first macro definition is
5042 lost.
5044 @xref{Interpolating Registers}, and @ref{Strings}.
5047 @c =====================================================================
5049 @node Embedded Commands, Registers, Identifiers, gtroff Reference
5050 @section Embedded Commands
5051 @cindex embedded commands
5052 @cindex commands, embedded
5054 Most documents need more functionality beyond filling, adjusting and
5055 implicit line breaking.  In order to gain further functionality,
5056 @code{gtroff} allows commands to be embedded into the text, in two ways.
5058 The first is a @dfn{request} which takes up an entire line, and does
5059 some large-scale operation (e.g.@: break lines, start new pages).
5061 The other is an @dfn{escape} which can be usually embedded anywhere
5062 in the text; most requests can accept it even as an argument.
5063 Escapes generally do more minor operations like sub- and superscripts,
5064 print a symbol, etc.
5066 @menu
5067 * Requests::
5068 * Macros::
5069 * Escapes::
5070 @end menu
5072 @c ---------------------------------------------------------------------
5074 @node Requests, Macros, Embedded Commands, Embedded Commands
5075 @subsection Requests
5076 @cindex requests
5078 @cindex control character (@code{.})
5079 @cindex character, control (@code{.})
5080 @cindex no-break control character (@code{'})
5081 @cindex character, no-break control (@code{'})
5082 @cindex control character, no-break (@code{'})
5083 A request line begins with a control character, which is either a single
5084 quote (@samp{'}, the @dfn{no-break control character}) or a period
5085 (@samp{.}, the normal @dfn{control character}).  These can be changed;
5086 see @ref{Character Translations}, for details.  After this there may be
5087 optional tabs or spaces followed by an identifier which is the name of
5088 the request.  This may be followed by any number of space-separated
5089 arguments (@emph{no} tabs here).
5091 @cindex structuring source code of documents or macro packages
5092 @cindex documents, structuring the source code
5093 @cindex macro packages, structuring the source code
5094 Since a control character followed by whitespace only is ignored, it
5095 is common practice to use this feature for structuring the source code
5096 of documents or macro packages.
5098 @Example
5099 .de foo
5100 .  tm This is foo.
5104 .de bar
5105 .  tm This is bar.
5107 @endExample
5109 @cindex blank line
5110 @cindex blank line macro (@code{blm})
5111 Another possibility is to use the blank line macro request @code{blm}
5112 by assigning an empty macro to it.
5114 @Example
5115 .de do-nothing
5117 .blm do-nothing  \" activate blank line macro
5119 .de foo
5120 .  tm This is foo.
5124 .de bar
5125 .  tm This is bar.
5128 .blm             \" deactivate blank line macro
5129 @endExample
5131 @xref{Blank Line Traps}.
5133 @cindex zero width space character (@code{\&})
5134 @cindex character, zero width space (@code{\&})
5135 @cindex space character, zero width (@code{\&})
5136 @cindex @code{\&}, escaping control characters
5137 To begin a line with a control character without it being interpreted,
5138 precede it with @code{\&}.  This represents a zero width space, which
5139 means it does not affect the output.
5141 In most cases the period is used as a control character.  Several
5142 requests cause a break implicitly; using the single quote control
5143 character prevents this.
5145 @menu
5146 * Request and Macro Arguments::
5147 @end menu
5149 @node Request and Macro Arguments,  , Requests, Requests
5150 @subsubsection Request and Macro Arguments
5151 @cindex request arguments
5152 @cindex macro arguments
5153 @cindex arguments to requests and macros
5155 Arguments to requests and macros are processed much like the shell:
5156 The line is split into arguments according to
5157 spaces.@footnote{Plan@tie{}9's @code{troff} implementation also allows
5158 tabs for argument separation -- @code{gtroff} intentionally doesn't
5159 support this.}
5161 @cindex spaces, in a macro argument
5162 An argument to a macro which is intended to contain spaces can either be
5163 enclosed in double quotes, or have the spaces @dfn{escaped} with
5164 backslashes.  This is @emph{not} true for requests.
5166 Here are a few examples for a hypothetical macro @code{uh}:
5168 @Example
5169 .uh The Mouse Problem
5170 .uh "The Mouse Problem"
5171 .uh The\ Mouse\ Problem
5172 @endExample
5174 @cindex @code{\~}, difference to @code{\@key{SP}}
5175 @cindex @code{\@key{SP}}, difference to @code{\~}
5176 @noindent
5177 The first line is the @code{uh} macro being called with 3 arguments,
5178 @samp{The}, @samp{Mouse}, and @samp{Problem}.  The latter two have the
5179 same effect of calling the @code{uh} macro with one argument, @samp{The
5180 Mouse Problem}.@footnote{The last solution, i.e., using escaped spaces,
5181 is ``classical'' in the sense that it can be found in most @code{troff}
5182 documents.  Nevertheless, it is not optimal in all situations, since
5183 @w{@samp{\ }} inserts a fixed-width, non-breaking space character which
5184 can't stretch.  @code{gtroff} provides a different command @code{\~} to
5185 insert a stretchable, non-breaking space.}
5187 @cindex @code{"}, in a macro argument
5188 @cindex double quote, in a macro argument
5189 A double quote which isn't preceded by a space doesn't start a macro
5190 argument.  If not closing a string, it is printed literally.
5192 For example,
5194 @Example
5195 .xxx a" "b c" "de"fg"
5196 @endExample
5198 @noindent
5199 has the arguments @samp{a"}, @w{@samp{b c}}, @samp{de}, and @samp{fg"}.
5200 Don't rely on this obscure behaviour!
5202 There are two possibilities to get a double quote reliably.
5204 @itemize @bullet
5205 @item
5206 Enclose the whole argument with double quotes and use two consecutive double
5207 quotes to represent a single one.  This traditional solution has the
5208 disadvantage that double quotes don't survive argument expansion again if
5209 called in compatibility mode (using the @option{-C} option of @code{groff}):
5211 @Example
5212 .de xx
5213 .  tm xx: `\\$1' `\\$2' `\\$3'
5215 .  yy "\\$1" "\\$2" "\\$3"
5217 .de yy
5218 .  tm yy: `\\$1' `\\$2' `\\$3'
5220 .xx A "test with ""quotes""" .
5221     @result{} xx: `A' `test with "quotes"' `.'
5222     @result{} yy: `A' `test with ' `quotes""'
5223 @endExample
5225 @noindent
5226 If not in compatibility mode, you get the expected result
5228 @Example
5229 xx: `A' `test with "quotes"' `.'
5230 yy: `A' `test with "quotes"' `.'
5231 @endExample
5233 @noindent
5234 since @code{gtroff} preserves the input level.
5236 @item
5237 Use the double quote glyph @code{\(dq}.  This works with and without
5238 compatibility mode enabled since @code{gtroff} doesn't convert @code{\(dq}
5239 back to a double quote input character.
5241 Not that this method won't work with @acronym{UNIX} @code{troff} in general
5242 since the glyph `dq' isn't defined normally.
5243 @end itemize
5245 @cindex @code{ds} request, and double quotes
5246 Double quotes in the @code{ds} request are handled differently.
5247 @xref{Strings}, for more details.
5249 @c ---------------------------------------------------------------------
5251 @node Macros, Escapes, Requests, Embedded Commands
5252 @subsection Macros
5253 @cindex macros
5255 @code{gtroff} has a @dfn{macro} facility for defining a series of lines
5256 which can be invoked by name.  They are called in the same manner as
5257 requests -- arguments also may be passed basically in the same manner.
5259 @xref{Writing Macros}, and @ref{Request and Macro Arguments}.
5261 @c ---------------------------------------------------------------------
5263 @node Escapes,  , Macros, Embedded Commands
5264 @subsection Escapes
5265 @cindex escapes
5267 Escapes may occur anywhere in the input to @code{gtroff}.  They usually
5268 begin with a backslash and are followed by a single character which
5269 indicates the function to be performed.  The escape character can be
5270 changed; see @ref{Character Translations}.
5272 Escape sequences which require an identifier as a parameter accept three
5273 possible syntax forms.
5275 @itemize @bullet
5276 @item
5277 The next single character is the identifier.
5279 @cindex @code{(}, starting a two-character identifier
5280 @item
5281 If this single character is an opening parenthesis, take the following
5282 two characters as the identifier.  Note that there is no closing
5283 parenthesis after the identifier.
5285 @cindex @code{[}, starting an identifier
5286 @cindex @code{]}, ending an identifier
5287 @item
5288 If this single character is an opening bracket, take all characters
5289 until a closing bracket as the identifier.
5290 @end itemize
5292 @noindent
5293 Examples:
5295 @Example
5297 \n(XX
5298 \*[TeX]
5299 @endExample
5301 @cindex @code{'}, delimiting arguments
5302 @cindex argument delimiting characters
5303 @cindex characters, argument delimiting
5304 @cindex delimiting characters for arguments
5305 Other escapes may require several arguments and/or some special format.
5306 In such cases the argument is traditionally enclosed in single quotes
5307 (and quotes are always used in this manual for the definitions of escape
5308 sequences).  The enclosed text is then processed according to what that
5309 escape expects.  Example:
5311 @Example
5312 \l'1.5i\(bu'
5313 @endExample
5315 @cindex @code{\o}, possible quote characters
5316 @cindex @code{\b}, possible quote characters
5317 @cindex @code{\X}, possible quote characters
5318 Note that the quote character can be replaced with any other character
5319 which does not occur in the argument (even a newline or a space
5320 character) in the following escapes: @code{\o}, @code{\b}, and
5321 @code{\X}.  This makes e.g.
5323 @Example
5324 A caf
5329 in Paris
5330   @result{} A café in Paris
5331 @endExample
5333 @noindent
5334 possible, but it is better not to use this feature to avoid confusion.
5336 @cindex @code{\%}, used as delimiter
5337 @cindex @code{\@key{SP}}, used as delimiter
5338 @cindex @code{\|}, used as delimiter
5339 @cindex @code{\^}, used as delimiter
5340 @cindex @code{\@{}, used as delimiter
5341 @cindex @code{\@}}, used as delimiter
5342 @cindex @code{\'}, used as delimiter
5343 @cindex @code{\`}, used as delimiter
5344 @cindex @code{\-}, used as delimiter
5345 @cindex @code{\_}, used as delimiter
5346 @cindex @code{\!}, used as delimiter
5347 @cindex @code{\?}, used as delimiter
5348 @cindex @code{\@@}, used as delimiter
5349 @cindex @code{\)}, used as delimiter
5350 @cindex @code{\/}, used as delimiter
5351 @cindex @code{\,}, used as delimiter
5352 @cindex @code{\&}, used as delimiter
5353 @ifnotinfo
5354 @cindex @code{\:}, used as delimiter
5355 @end ifnotinfo
5356 @ifinfo
5357 @cindex @code{\@r{<colon>}}, used as delimiter
5358 @end ifinfo
5359 @cindex @code{\~}, used as delimiter
5360 @cindex @code{\0}, used as delimiter
5361 @cindex @code{\a}, used as delimiter
5362 @cindex @code{\c}, used as delimiter
5363 @cindex @code{\d}, used as delimiter
5364 @cindex @code{\e}, used as delimiter
5365 @cindex @code{\E}, used as delimiter
5366 @cindex @code{\p}, used as delimiter
5367 @cindex @code{\r}, used as delimiter
5368 @cindex @code{\t}, used as delimiter
5369 @cindex @code{\u}, used as delimiter
5370 The following escapes sequences (which are handled similarly to
5371 characters since they don't take a parameter) are also allowed as
5372 delimiters: @code{\%}, @w{@samp{\ }}, @code{\|}, @code{\^}, @code{\@{},
5373 @code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
5374 @code{\?}, @code{\@@}, @code{\)}, @code{\/}, @code{\,}, @code{\&},
5375 @code{\:}, @code{\~}, @code{\0}, @code{\a}, @code{\c}, @code{\d},
5376 @code{\e}, @code{\E}, @code{\p}, @code{\r}, @code{\t}, and @code{\u}.
5377 Again, don't use these if possible.
5379 @cindex @code{\A}, allowed delimiters
5380 @cindex @code{\B}, allowed delimiters
5381 @cindex @code{\Z}, allowed delimiters
5382 @cindex @code{\C}, allowed delimiters
5383 @cindex @code{\w}, allowed delimiters
5384 No newline characters as delimiters are allowed in the following
5385 escapes: @code{\A}, @code{\B}, @code{\Z}, @code{\C}, and @code{\w}.
5387 @cindex @code{\D}, allowed delimiters
5388 @cindex @code{\h}, allowed delimiters
5389 @cindex @code{\H}, allowed delimiters
5390 @cindex @code{\l}, allowed delimiters
5391 @cindex @code{\L}, allowed delimiters
5392 @cindex @code{\N}, allowed delimiters
5393 @cindex @code{\R}, allowed delimiters
5394 @cindex @code{\s}, allowed delimiters
5395 @cindex @code{\S}, allowed delimiters
5396 @cindex @code{\v}, allowed delimiters
5397 @cindex @code{\x}, allowed delimiters
5398 Finally, the escapes @code{\D}, @code{\h}, @code{\H}, @code{\l},
5399 @code{\L}, @code{\N}, @code{\R}, @code{\s}, @code{\S}, @code{\v},
5400 and @code{\x} can't use the following characters as delimiters:
5402 @itemize @bullet
5403 @item
5404 @cindex numbers, and delimiters
5405 @cindex digits, and delimiters
5406 The digits @code{0}-@code{9}.
5408 @item
5409 @cindex operators, as delimiters
5410 @cindex @code{+}, as delimiter
5411 @cindex @code{-}, as delimiter
5412 @cindex @code{/}, as delimiter
5413 @cindex @code{*}, as delimiter
5414 @cindex @code{%}, as delimiter
5415 @cindex @code{<}, as delimiter
5416 @cindex @code{>}, as delimiter
5417 @cindex @code{=}, as delimiter
5418 @cindex @code{&}, as delimiter
5419 @ifnotinfo
5420 @cindex @code{:}, as delimiter
5421 @end ifnotinfo
5422 @ifinfo
5423 @cindex <colon>, as delimiter
5424 @end ifinfo
5425 @cindex @code{(}, as delimiter
5426 @cindex @code{)}, as delimiter
5427 @cindex @code{.}, as delimiter
5428 The (single-character) operators @samp{+-/*%<>=&:().}.
5430 @item
5431 @cindex space character
5432 @cindex character, space
5433 @cindex tab character
5434 @cindex character, tab
5435 @cindex newline character
5436 @cindex character, newline
5437 The space, tab, and newline characters.
5439 @item
5440 @cindex @code{\%}, used as delimiter
5441 @ifnotinfo
5442 @cindex @code{\:}, used as delimiter
5443 @end ifnotinfo
5444 @ifinfo
5445 @cindex @code{\@r{<colon>}}, used as delimiter
5446 @end ifinfo
5447 @cindex @code{\@{}, used as delimiter
5448 @cindex @code{\@}}, used as delimiter
5449 @cindex @code{\'}, used as delimiter
5450 @cindex @code{\`}, used as delimiter
5451 @cindex @code{\-}, used as delimiter
5452 @cindex @code{\_}, used as delimiter
5453 @cindex @code{\!}, used as delimiter
5454 @cindex @code{\@@}, used as delimiter
5455 @cindex @code{\/}, used as delimiter
5456 @cindex @code{\c}, used as delimiter
5457 @cindex @code{\e}, used as delimiter
5458 @cindex @code{\p}, used as delimiter
5459 All escape sequences except @code{\%}, @code{\:}, @code{\@{}, @code{\@}},
5460 @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!}, @code{\@@},
5461 @code{\/}, @code{\c}, @code{\e}, and @code{\p}.
5462 @end itemize
5464 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
5465 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
5466 To have a backslash (actually, the current escape character) appear in the
5467 output several escapes are defined: @code{\\}, @code{\e} or @code{\E}.
5468 These are very similar, and only differ with respect to being used in
5469 macros or diversions.  @xref{Character Translations}, for an exact
5470 description of those escapes.
5472 @xref{Implementation Differences}, @ref{Copy-in Mode}, and @ref{Diversions},
5473 @ref{Identifiers}, for more information.
5475 @menu
5476 * Comments::
5477 @end menu
5479 @node Comments,  , Escapes, Escapes
5480 @subsubsection Comments
5481 @cindex comments
5483 Probably one of the most@footnote{Unfortunately, this is a lie.  But
5484 hopefully future @code{gtroff} hackers will believe it @code{:-)}}
5485 common forms of escapes is the comment.
5487 @Defesc {\\", , , }
5488 Start a comment.  Everything to the end of the input line is ignored.
5490 This may sound simple, but it can be tricky to keep the comments from
5491 interfering with the appearance of the final output.
5493 @cindex @code{ds}, @code{ds1} requests, and comments
5494 @cindex @code{as}, @code{as1} requests, and comments
5495 If the escape is to the right of some text or a request, that portion
5496 of the line is ignored, but the space leading up to it is noticed by
5497 @code{gtroff}.  This only affects the @code{ds} and @code{as}
5498 request and its variants.
5500 @cindex tabs, before comments
5501 @cindex comments, lining up with tabs
5502 One possibly irritating idiosyncracy is that tabs must not be used to
5503 line up comments.  Tabs are not treated as whitespace between the
5504 request and macro arguments.
5506 @cindex undefined request
5507 @cindex request, undefined
5508 A comment on a line by itself is treated as a blank line, because
5509 after eliminating the comment, that is all that remains:
5511 @Example
5512 Test
5513 \" comment
5514 Test
5515 @endExample
5517 @noindent
5518 produces
5520 @Example
5521 Test
5523 Test
5524 @endExample
5526 To avoid this, it is common to start the line with @code{.\"} which
5527 causes the line to be treated as an undefined request and thus ignored
5528 completely.
5530 @cindex @code{'}, as a comment
5531 Another commenting scheme seen sometimes is three consecutive single
5532 quotes (@code{'''}) at the beginning of a line.  This works, but
5533 @code{gtroff} gives a warning about an undefined macro (namely
5534 @code{''}), which is harmless, but irritating.
5535 @endDefesc
5537 @Defesc {\\#, , , }
5538 To avoid all this, @code{gtroff} has a new comment mechanism using the
5539 @code{\#} escape.  This escape works the same as @code{\"} except that
5540 the newline is also ignored:
5542 @Example
5543 Test
5544 \# comment
5545 Test
5546 @endExample
5548 @noindent
5549 produces
5551 @Example
5552 Test Test
5553 @endExample
5555 @noindent
5556 as expected.
5557 @endDefesc
5559 @Defreq {ig, [@Var{end}]}
5560 Ignore all input until @code{gtroff} encounters the macro named
5561 @code{.}@var{end} on a line by itself (or @code{..} if @var{end} is not
5562 specified).  This is useful for commenting out large blocks of text:
5564 @Example
5565 text text text...
5567 This is part of a large block
5568 of text that has been
5569 temporarily(?) commented out.
5571 We can restore it simply by removing
5572 the .ig request and the ".." at the
5573 end of the block.
5575 More text text text...
5576 @endExample
5578 @noindent
5579 produces
5581 @Example
5582 text text text@dots{}  More text text text@dots{}
5583 @endExample
5585 @noindent
5586 Note that the commented-out block of text does not
5587 cause a break.
5589 The input is read in copy-mode; auto-incremented registers @emph{are}
5590 affected (@pxref{Auto-increment}).
5591 @endDefreq
5594 @c =====================================================================
5596 @node Registers, Manipulating Filling and Adjusting, Embedded Commands, gtroff Reference
5597 @section Registers
5598 @cindex registers
5600 Numeric variables in @code{gtroff} are called @dfn{registers}.  There
5601 are a number of built-in registers, supplying anything from the date to
5602 details of formatting parameters.
5604 @xref{Identifiers}, for details on register identifiers.
5606 @menu
5607 * Setting Registers::
5608 * Interpolating Registers::
5609 * Auto-increment::
5610 * Assigning Formats::
5611 * Built-in Registers::
5612 @end menu
5614 @c ---------------------------------------------------------------------
5616 @node Setting Registers, Interpolating Registers, Registers, Registers
5617 @subsection Setting Registers
5618 @cindex setting registers (@code{nr}, @code{\R})
5619 @cindex registers, setting (@code{nr}, @code{\R})
5621 Define or set registers using the @code{nr} request or the
5622 @code{\R} escape.
5624 @DefreqList {nr, ident value}
5625 @DefescListEnd {\\R, ', ident value, '}
5626 Set number register @var{ident} to @var{value}.  If @var{ident}
5627 doesn't exist, @code{gtroff} creates it.
5629 The argument to @code{\R} usually has to be enclosed in quotes.
5630 @xref{Escapes}, for details on parameter delimiting characters.
5632 The @code{\R} escape doesn't produce an input token in @code{gtroff};
5633 with other words, it vanishes completely after @code{gtroff} has
5634 processed it.
5635 @endDefreq
5637 For example, the following two lines are equivalent:
5639 @Example
5640 .nr a (((17 + (3 * 4))) % 4)
5641 \R'a (((17 + (3 * 4))) % 4)'
5642     @result{} 1
5643 @endExample
5645 Both @code{nr} and @code{\R} have two additional special forms to
5646 increment or decrement a register.
5648 @DefreqList {nr, ident @t{+}@Var{value}}
5649 @DefreqItem {nr, ident @t{-}@Var{value}}
5650 @DefescItem {\\R, ', ident @t{+}value, '}
5651 @DefescListEnd {\\R, ', ident @t{-}value, '}
5652 Increment (decrement) register @var{ident} by @var{value}.
5654 @Example
5655 .nr a 1
5656 .nr a +1
5658     @result{} 2
5659 @endExample
5661 @cindex negating register values
5662 To assign the negated value of a register to another register, some care
5663 must be taken to get the desired result:
5665 @Example
5666 .nr a 7
5667 .nr b 3
5668 .nr a -\nb
5670     @result{} 4
5671 .nr a (-\nb)
5673     @result{} -3
5674 @endExample
5676 @noindent
5677 The surrounding parentheses prevent the interpretation of the minus sign
5678 as a decrementing operator.  An alternative is to start the assignment
5679 with a @samp{0}:
5681 @Example
5682 .nr a 7
5683 .nr b -3
5684 .nr a \nb
5686     @result{} 4
5687 .nr a 0\nb
5689     @result{} -3
5690 @endExample
5691 @endDefreq
5693 @Defreq {rr, ident}
5694 @cindex removing number register (@code{rr})
5695 @cindex number register, removing (@code{rr})
5696 @cindex register, removing (@code{rr})
5697 Remove number register @var{ident}.  If @var{ident} doesn't exist, the
5698 request is ignored.
5699 @endDefreq
5701 @Defreq {rnn, ident1 ident2}
5702 @cindex renaming number register (@code{rnn})
5703 @cindex number register, renaming (@code{rnn})
5704 @cindex register, renaming (@code{rnn})
5705 Rename number register @var{ident1} to @var{ident2}.  If either
5706 @var{ident1} or @var{ident2} doesn't exist, the request is ignored.
5707 @endDefreq
5709 @Defreq {aln, ident1 ident2}
5710 @cindex alias, number register, creating (@code{aln})
5711 @cindex creating alias, for number register (@code{aln})
5712 @cindex number register, creating alias (@code{aln})
5713 @cindex register, creating alias (@code{aln})
5714 Create an alias @var{ident1} for a number register @var{ident2}.  The
5715 new name and the old name are exactly equivalent.  If @var{ident1} is
5716 undefined, a warning of type @samp{reg} is generated, and the request
5717 is ignored.  @xref{Debugging}, for information about warnings.
5718 @endDefreq
5720 @c ---------------------------------------------------------------------
5722 @node Interpolating Registers, Auto-increment, Setting Registers, Registers
5723 @subsection Interpolating Registers
5724 @cindex interpolating registers (@code{\n})
5725 @cindex registers, interpolating (@code{\n})
5727 Numeric registers can be accessed via the @code{\n} escape.
5729 @DefescList {\\n, , i, }
5730 @DefescItem {\\n, @lparen{}, id, }
5731 @DefescListEnd {\\n, @lbrack{}, ident, @rbrack}
5732 @cindex nested assignments
5733 @cindex assignments, nested
5734 @cindex indirect assignments
5735 @cindex assignments, indirect
5736 Interpolate number register with name @var{ident} (one-character
5737 name@tie{}@var{i}, two-character name @var{id}).  This means that the value
5738 of the register is expanded in-place while @code{gtroff} is parsing the
5739 input line.  Nested assignments (also called indirect assignments) are
5740 possible.
5742 @Example
5743 .nr a 5
5744 .nr as \na+\na
5745 \n(as
5746     @result{} 10
5747 @endExample
5749 @Example
5750 .nr a1 5
5751 .nr ab 6
5752 .ds str b
5753 .ds num 1
5754 \n[a\n[num]]
5755     @result{} 5
5756 \n[a\*[str]]
5757     @result{} 6
5758 @endExample
5759 @endDefesc
5761 @c ---------------------------------------------------------------------
5763 @node Auto-increment, Assigning Formats, Interpolating Registers, Registers
5764 @subsection Auto-increment
5765 @cindex auto-increment
5766 @cindex increment, automatic
5768 Number registers can also be auto-incremented and auto-decremented.
5769 The increment or decrement value can be specified with a third
5770 argument to the @code{nr} request or @code{\R} escape.
5772 @Defreq {nr, ident value incr}
5773 @cindex @code{\R}, difference to @code{nr}
5774 Set number register @var{ident} to @var{value}; the increment for
5775 auto-incrementing is set to @var{incr}.  Note that the @code{\R}
5776 escape doesn't support this notation.
5777 @endDefreq
5779 To activate auto-incrementing, the escape @code{\n} has a special
5780 syntax form.
5782 @DefescList {\\n, +, i, }
5783 @DefescItem {\\n, -, i, }
5784 @DefescItem {\\n, @lparen{}+, id, }
5785 @DefescItem {\\n, @lparen{}-, id, }
5786 @DefescItem {\\n, +@lparen{}, id, }
5787 @DefescItem {\\n, -@lparen{}, id, }
5788 @DefescItem {\\n, @lbrack{}+, ident, @rbrack{}}
5789 @DefescItem {\\n, @lbrack{}-, ident, @rbrack{}}
5790 @DefescItem {\\n, +@lbrack{}, ident, @rbrack{}}
5791 @DefescListEnd {\\n, -@lbrack{}, ident, @rbrack{}}
5792 Before interpolating, increment or decrement @var{ident}
5793 (one-character name@tie{}@var{i}, two-character name @var{id}) by the
5794 auto-increment value as specified with the @code{nr} request (or the
5795 @code{\R} escape).  If no auto-increment value has been specified,
5796 these syntax forms are identical to @code{\n}.
5797 @endDefesc
5799 For example,
5801 @Example
5802 .nr a 0 1
5803 .nr xx 0 5
5804 .nr foo 0 -2
5805 \n+a, \n+a, \n+a, \n+a, \n+a
5807 \n-(xx, \n-(xx, \n-(xx, \n-(xx, \n-(xx
5809 \n+[foo], \n+[foo], \n+[foo], \n+[foo], \n+[foo]
5810 @endExample
5812 @noindent
5813 produces
5815 @Example
5816 1, 2, 3, 4, 5
5817 -5, -10, -15, -20, -25
5818 -2, -4, -6, -8, -10
5819 @endExample
5821 @cindex increment value without changing the register
5822 @cindex value, incrementing without changing the register
5823 To change the increment value without changing the value of a register
5824 (@var{a} in the example), the following can be used:
5826 @Example
5827 .nr a \na 10
5828 @endExample
5830 @c ---------------------------------------------------------------------
5832 @node Assigning Formats, Built-in Registers, Auto-increment, Registers
5833 @subsection Assigning Formats
5834 @cindex assigning formats (@code{af})
5835 @cindex formats, assigning (@code{af})
5837 When a register is used in the text of an input file (as opposed to
5838 part of an expression), it is textually replaced (or interpolated)
5839 with a representation of that number.  This output format can be
5840 changed to a variety of formats (numbers, Roman numerals, etc.).  This
5841 is done using the @code{af} request.
5843 @Defreq {af, ident format}
5844 Change the output format of a number register.  The first argument
5845 @var{ident} is the name of the number register to be changed, and the
5846 second argument @var{format} is the output format.  The following
5847 output formats are available:
5849 @table @code
5850 @item 1
5851 Decimal arabic numbers.  This is the default format: 0, 1, 2,
5852 3,@tie{}@enddots{}
5854 @item 0@dots{}0
5855 Decimal numbers with as many digits as specified.  So, @samp{00} would
5856 result in printing numbers as 01, 02, 03,@tie{}@enddots{}
5858 In fact, any digit instead of zero will do; @code{gtroff} only counts
5859 how many digits are specified.  As a consequence, @code{af}'s default
5860 format @samp{1} could be specified as @samp{0} also (and exactly this is
5861 returned by the @code{\g} escape, see below).
5863 @item I
5864 @cindex Roman numerals
5865 @cindex numerals, Roman
5866 Upper-case Roman numerals: 0, I, II, III, IV,@tie{}@enddots{}
5868 @item i
5869 Lower-case Roman numerals: 0, i, ii, iii, iv,@tie{}@enddots{}
5871 @item A
5872 Upper-case letters: 0, A, B, C, @dots{},@tie{}Z, AA, AB,@tie{}@enddots{}
5874 @item a
5875 Lower-case letters: 0, a, b, c, @dots{},@tie{}z, aa, ab,@tie{}@enddots{}
5876 @end table
5878 Omitting the number register format causes a warning of type
5879 @samp{missing}.  @xref{Debugging}, for more details.  Specifying a
5880 nonexistent format causes an error.
5882 The following example produces @samp{10, X, j, 010}:
5884 @Example
5885 .nr a 10
5886 .af a 1           \" the default format
5887 \na,
5888 .af a I
5889 \na,
5890 .af a a
5891 \na,
5892 .af a 001
5894 @endExample
5896 @cindex Roman numerals, maximum and minimum
5897 @cindex maximum values of Roman numerals
5898 @cindex minimum values of Roman numerals
5899 The largest number representable for the @samp{i} and @samp{I} formats
5900 is 39999 (or @minus{}39999); @acronym{UNIX} @code{troff} uses @samp{z}
5901 and @samp{w} to represent 10000 and 5000 in Roman numerals, and so does
5902 @code{gtroff}.  Currently, the correct glyphs of Roman numeral five
5903 thousand and Roman numeral ten thousand (Unicode code points
5904 @code{U+2182} and @code{U+2181}, respectively) are not available.
5906 If @var{ident} doesn't exist, it is created.
5908 @cindex read-only register, changing format
5909 @cindex changing format, and read-only registers
5910 Changing the output format of a read-only register causes an error.  It
5911 is necessary to first copy the register's value to a writeable register,
5912 then apply the @code{af} request to this other register.
5913 @endDefreq
5915 @DefescList {\\g, , i, }
5916 @DefescItem {\\g, @lparen{}, id, }
5917 @DefescListEnd {\\g, @lbrack{}, ident, @rbrack{}}
5918 @cindex format of register (@code{\g})
5919 @cindex register, format (@code{\g})
5920 Return the current format of the specified register @var{ident}
5921 (one-character name@tie{}@var{i}, two-character name @var{id}).  For
5922 example, @samp{\ga} after the previous example would produce the
5923 string @samp{000}.  If the register hasn't been defined yet, nothing
5924 is returned.
5925 @endDefesc
5927 @c ---------------------------------------------------------------------
5929 @node Built-in Registers,  , Assigning Formats, Registers
5930 @subsection Built-in Registers
5931 @cindex built-in registers
5932 @cindex registers, built-in
5934 The following lists some built-in registers which are not described
5935 elsewhere in this manual.  Any register which begins with a @samp{.} is
5936 read-only.  A complete listing of all built-in registers can be found in
5937 @ref{Register Index}.
5939 @table @code
5940 @item \n[.F]
5941 @cindex current input file name register (@code{.F})
5942 @cindex input file name, current, register (@code{.F})
5943 @vindex \n[.F]
5944 This string-valued register returns the current input file name.
5946 @item \n[.H]
5947 @cindex horizontal resolution register (@code{.H})
5948 @cindex resolution, horizontal, register (@code{.H})
5949 @vindex .H
5950 Horizontal resolution in basic units.
5952 @item \n[.U]
5953 @cindex safer mode
5954 @cindex mode, safer
5955 @cindex unsafe mode
5956 @cindex mode, unsafe
5957 If @code{gtroff} is called with the @option{-U} command line option, the
5958 number register @code{.U} is set to@tie{}1, and zero otherwise.
5959 @xref{Groff Options}.
5961 @item \n[.V]
5962 @cindex vertical resolution register (@code{.V})
5963 @cindex resolution, vertical, register (@code{.V})
5964 @vindex .V
5965 Vertical resolution in basic units.
5967 @item \n[seconds]
5968 @cindex seconds, current time (@code{seconds})
5969 @cindex time, current, seconds (@code{seconds})
5970 @cindex current time, seconds (@code{seconds})
5971 @vindex seconds
5972 The number of seconds after the minute, normally in the range@tie{}0
5973 to@tie{}59, but can be up to@tie{}61 to allow for leap seconds.  Initialized
5974 at start-up of @code{gtroff}.
5976 @item \n[minutes]
5977 @cindex minutes, current time (@code{minutes})
5978 @cindex time, current, minutes (@code{minutes})
5979 @cindex current time, minutes (@code{minutes})
5980 @vindex minutes
5981 The number of minutes after the hour, in the range@tie{}0 to@tie{}59.
5982 Initialized at start-up of @code{gtroff}.
5984 @item \n[hours]
5985 @cindex hours, current time (@code{hours})
5986 @cindex time, current, hours (@code{hours})
5987 @cindex current time, hours (@code{hours})
5988 @vindex hours
5989 The number of hours past midnight, in the range@tie{}0 to@tie{}23.
5990 Initialized at start-up of @code{gtroff}.
5992 @item \n[dw]
5993 @cindex day of the week register (@code{dw})
5994 @cindex date, day of the week register (@code{dw})
5995 @vindex dw
5996 Day of the week (1-7).
5998 @item \n[dy]
5999 @cindex day of the month register (@code{dy})
6000 @cindex date, day of the month register (@code{dy})
6001 @vindex dy
6002 Day of the month (1-31).
6004 @item \n[mo]
6005 @cindex month of the year register (@code{mo})
6006 @cindex date, month of the year register (@code{mo})
6007 @vindex mo
6008 Current month (1-12).
6010 @item \n[year]
6011 @cindex date, year register (@code{year}, @code{yr})
6012 @cindex year, current, register (@code{year}, @code{yr})
6013 @vindex year
6014 The current year.
6016 @item \n[yr]
6017 @vindex \n[yr]
6018 The current year minus@tie{}1900.  Unfortunately, the documentation of
6019 @acronym{UNIX} Version@tie{}7's @code{troff} had a year@tie{}2000 bug: It
6020 incorrectly claimed that @code{yr} contains the last two digits of the
6021 year.  That claim has never been true of either @acronym{AT&T}
6022 @code{troff} or GNU @code{troff}.  Old @code{troff} input that looks
6023 like this:
6025 @Example
6026 '\" The following line stopped working after 1999
6027 This document was formatted in 19\n(yr.
6028 @endExample
6030 @noindent
6031 can be corrected as follows:
6033 @Example
6034 This document was formatted in \n[year].
6035 @endExample
6037 @noindent
6038 or, to be portable to older @code{troff} versions, as follows:
6040 @Example
6041 .nr y4 1900+\n(yr
6042 This document was formatted in \n(y4.
6043 @endExample
6045 @item \n[.c]
6046 @vindex .c
6047 @itemx \n[c.]
6048 @vindex c.
6049 @cindex input line number register (@code{.c}, @code{c.})
6050 @cindex line number, input, register (@code{.c}, @code{c.})
6051 The current @emph{input} line number.  Register @samp{.c} is read-only,
6052 whereas @samp{c.} (a @code{gtroff} extension) is writable also,
6053 affecting both @samp{.c} and @samp{c.}.
6055 @item \n[ln]
6056 @vindex ln
6057 @cindex output line number register (@code{ln})
6058 @cindex line number, output, register (@code{ln})
6059 The current @emph{output} line number after a call to the @code{nm}
6060 request to activate line numbering.
6062 @xref{Miscellaneous}, for more information about line numbering.
6064 @item \n[.x]
6065 @vindex .x
6066 @cindex major version number register (@code{.x})
6067 @cindex version number, major, register (@code{.x})
6068 The major version number.  For example, if the version number
6069 is 1.03 then @code{.x} contains@tie{}@samp{1}.
6071 @item \n[.y]
6072 @vindex .y
6073 @cindex minor version number register (@code{.y})
6074 @cindex version number, minor, register (@code{.y})
6075 The minor version number.  For example, if the version number
6076 is 1.03 then @code{.y} contains@tie{}@samp{03}.
6078 @item \n[.Y]
6079 @vindex .Y
6080 @cindex revision number register (@code{.Y})
6081 The revision number of @code{groff}.
6083 @item \n[$$]
6084 @vindex $$
6085 @cindex process ID of @code{gtroff} register (@code{$$})
6086 @cindex @code{gtroff}, process ID register (@code{$$})
6087 The process ID of @code{gtroff}.
6089 @item \n[.g]
6090 @vindex .g
6091 @cindex @code{gtroff}, identification register (@code{.g})
6092 @cindex GNU-specific register (@code{.g})
6093 Always@tie{}1.  Macros should use this to determine whether they are
6094 running under GNU @code{troff}.
6096 @item \n[.A]
6097 @vindex .A
6098 @cindex @acronym{ASCII} approximation output register (@code{.A})
6099 If the command line option @option{-a} is used to produce an
6100 @acronym{ASCII} approximation of the output, this is set to@tie{}1, zero
6101 otherwise.  @xref{Groff Options}.
6103 @item \n[.P]
6104 @vindex .P
6105 This register is set to@tie{}1 (and to@tie{}0 otherwise) if the current
6106 page is actually being printed, i.e., if the @option{-o} option is being
6107 used to only print selected pages.  @xref{Groff Options}, for more
6108 information.
6110 @item \n[.T]
6111 @vindex .T
6112 If @code{gtroff} is called with the @option{-T} command line option, the
6113 number register @code{.T} is set to@tie{}1, and zero otherwise.
6114 @xref{Groff Options}.
6116 @item \*[.T]
6117 @stindex .T
6118 @cindex output device name string register (@code{.T})
6119 A single read-write string register which contains the current output
6120 device (for example, @samp{latin1} or @samp{ps}).  This is the only
6121 string register defined by @code{gtroff}.
6122 @end table
6125 @c =====================================================================
6127 @node Manipulating Filling and Adjusting, Manipulating Hyphenation, Registers, gtroff Reference
6128 @section Manipulating Filling and Adjusting
6129 @cindex manipulating filling and adjusting
6130 @cindex filling and adjusting, manipulating
6131 @cindex adjusting and filling, manipulating
6132 @cindex justifying text
6133 @cindex text, justifying
6135 @cindex break
6136 @cindex line break
6137 @cindex @code{bp} request, causing implicit linebreak
6138 @cindex @code{ce} request, causing implicit linebreak
6139 @cindex @code{cf} request, causing implicit linebreak
6140 @cindex @code{fi} request, causing implicit linebreak
6141 @cindex @code{fl} request, causing implicit linebreak
6142 @cindex @code{in} request, causing implicit linebreak
6143 @cindex @code{nf} request, causing implicit linebreak
6144 @cindex @code{rj} request, causing implicit linebreak
6145 @cindex @code{sp} request, causing implicit linebreak
6146 @cindex @code{ti} request, causing implicit linebreak
6147 @cindex @code{trf} request, causing implicit linebreak
6148 Various ways of causing @dfn{breaks} were given in @ref{Implicit Line
6149 Breaks}.  The @code{br} request likewise causes a break.  Several
6150 other requests also cause breaks, but implicitly.  These are
6151 @code{bp}, @code{ce}, @code{cf}, @code{fi}, @code{fl}, @code{in},
6152 @code{nf}, @code{rj}, @code{sp}, @code{ti}, and @code{trf}.
6154 @Defreq {br, }
6155 Break the current line, i.e., the input collected so far is emitted
6156 without adjustment.
6158 If the no-break control character is used, @code{gtroff} suppresses
6159 the break:
6161 @Example
6165     @result{} a b
6166 @endExample
6167 @endDefreq
6169 Initially, @code{gtroff} fills and adjusts text to both margins.
6170 Filling can be disabled via the @code{nf} request and re-enabled with
6171 the @code{fi} request.
6173 @DefreqList {fi, }
6174 @DefregListEnd {.u}
6175 @cindex fill mode (@code{fi})
6176 @cindex mode, fill (@code{fi})
6177 Activate fill mode (which is the default).  This request implicitly
6178 enables adjusting; it also inserts a break in the text currently being
6179 filled.  The read-only number register @code{.u} is set to@tie{}1.
6181 The fill mode status is associated with the current environment
6182 (@pxref{Environments}).
6184 See @ref{Line Control}, for interaction with the @code{\c} escape.
6185 @endDefreq
6187 @Defreq {nf, }
6188 @cindex no-fill mode (@code{nf})
6189 @cindex mode, no-fill (@code{nf})
6190 Activate no-fill mode.  Input lines are output as-is, retaining line
6191 breaks and ignoring the current line length.  This command implicitly
6192 disables adjusting; it also causes a break.  The number register
6193 @code{.u} is set to@tie{}0.
6195 The fill mode status is associated with the current environment
6196 (@pxref{Environments}).
6198 See @ref{Line Control}, for interaction with the @code{\c} escape.
6199 @endDefreq
6201 @DefreqList {ad, [@Var{mode}]}
6202 @DefregListEnd {.j}
6203 Set adjusting mode.
6205 Activation and deactivation of adjusting is done implicitly with
6206 calls to the @code{fi} or @code{nf} requests.
6208 @var{mode} can have one of the following values:
6210 @table @code
6211 @item l
6212 @cindex ragged-right
6213 Adjust text to the left margin.  This produces what is traditionally
6214 called ragged-right text.
6216 @item r
6217 @cindex ragged-left
6218 Adjust text to the right margin, producing ragged-left text.
6220 @item c
6221 @cindex centered text
6222 @cindex @code{ce} request, difference to @samp{.ad@tie{}c}
6223 Center filled text.  This is different to the @code{ce} request which
6224 only centers text without filling.
6226 @item b
6227 @itemx n
6228 Justify to both margins.  This is the default used by @code{gtroff}.
6229 @end table
6231 Finally, @var{mode} can be the numeric argument returned by the @code{.j}
6232 register.
6234 With no argument, @code{gtroff} adjusts lines in the same way it did
6235 before adjusting was deactivated (with a call to @code{na}, for
6236 example).
6238 @Example
6239 text
6240 .ad r
6241 .nr ad \n[.j]
6242 text
6243 .ad c
6244 text
6246 text
6247 .ad         \" back to centering
6248 text
6249 .ad \n[ad]  \" back to right justifying
6250 @endExample
6252 @cindex adjustment mode register (@code{.j})
6253 The current adjustment mode is available in the read-only number
6254 register @code{.j}; it can be stored and subsequently used to set
6255 adjustment.
6257 The adjustment mode status is associated with the current environment
6258 (@pxref{Environments}).
6259 @endDefreq
6261 @Defreq {na, }
6262 Disable adjusting.  This request won't change the current adjustment
6263 mode: A subsequent call to @code{ad} uses the previous adjustment
6264 setting.
6266 The adjustment mode status is associated with the current environment
6267 (@pxref{Environments}).
6268 @endDefreq
6270 @DefreqList {brp, }
6271 @DefescListEnd {\\p, , , }
6272 Adjust the current line and cause a break.
6274 In most cases this produces very ugly results since @code{gtroff}
6275 doesn't have a sophisticated paragraph building algorithm (as @TeX{}
6276 have, for example); instead, @code{gtroff} fills and adjusts a paragraph
6277 line by line:
6279 @Example
6280   This is an uninteresting sentence.
6281   This is an uninteresting sentence.\p
6282   This is an uninteresting sentence.
6283 @endExample
6285 @noindent
6286 is formatted as
6288 @Example
6289   This is  an uninteresting  sentence.   This  is an
6290   uninteresting                            sentence.
6291   This is an uninteresting sentence.
6292 @endExample
6293 @endDefreq
6295 @DefreqList {ss, word_space_size [@Var{sentence_space_size}]}
6296 @DefregItem {.ss}
6297 @DefregListEnd {.sss}
6298 @cindex word space size register (@code{.ss})
6299 @cindex size of word space register (@code{.ss})
6300 @cindex space between words register (@code{.ss})
6301 @cindex sentence space size register (@code{.sss})
6302 @cindex size of sentence space register (@code{.sss})
6303 @cindex space between sentences register (@code{.sss})
6304 Change the size of a space between words.  It takes its units as one
6305 twelfth of the space width parameter for the current font.
6306 Initially both the @var{word_space_size} and @var{sentence_space_size}
6307 are@tie{}12.  In fill mode, the values specify the minimum distance.
6309 @cindex fill mode
6310 @cindex mode, fill
6311 If two arguments are given to the @code{ss} request, the second
6312 argument sets the sentence space size.  If the second argument is not
6313 given, sentence space size is set to @var{word_space_size}.  The
6314 sentence space size is used in two circumstances: If the end of a
6315 sentence occurs at the end of a line in fill mode, then both an
6316 inter-word space and a sentence space are added; if two spaces follow
6317 the end of a sentence in the middle of a line, then the second space
6318 is a sentence space.  If a second argument is never given to the
6319 @code{ss} request, the behaviour of @acronym{UNIX} @code{troff} is the
6320 same as that exhibited by GNU @code{troff}.  In GNU @code{troff}, as
6321 in @acronym{UNIX} @code{troff}, a sentence should always be followed
6322 by either a newline or two spaces.
6324 The read-only number registers @code{.ss} and @code{.sss} hold the
6325 values of the parameters set by the first and second arguments of the
6326 @code{ss} request.
6328 The word space and sentence space values are associated with the current
6329 environment (@pxref{Environments}).
6331 Contrary to @acronym{AT&T} @code{troff}, this request is @emph{not}
6332 ignored if a TTY output device is used; the given values are then
6333 rounded down to a multiple of@tie{}12 (@pxref{Implementation Differences}).
6335 The request is ignored if there is no parameter.
6337 @cindex discardable horizontal space
6338 @cindex space, discardable, horizontal
6339 @cindex horizontal discardable space
6340 Another useful application of the @code{ss} request is to insert
6341 discardable horizontal space, i.e., space which is discarded at a line
6342 break.  For example, paragraph-style footnotes could be separated this
6343 way:
6345 @Example
6346 .ll 4.5i
6347 1.\ This is the first footnote.\c
6348 .ss 48
6349 .nop
6350 .ss 12
6351 2.\ This is the second footnote.
6352 @endExample
6354 @noindent
6355 The result:
6357 @Example
6358 1. This is the first footnote.        2. This
6359 is the second footnote.
6360 @endExample
6362 @noindent
6363 Note that the @code{\h} escape produces unbreakable space.
6364 @endDefreq
6366 @DefreqList {ce, [@Var{nnn}]}
6367 @DefregListEnd {.ce}
6368 @cindex centering lines (@code{ce})
6369 @cindex lines, centering (@code{ce})
6370 Center text.  While the @w{@samp{.ad c}} request also centers text,
6371 it fills the text as well.  @code{ce} does not fill the
6372 text it affects.  This request causes a break.  The number of lines
6373 still to be centered is associated with the current environment
6374 (@pxref{Environments}).
6376 The following example demonstrates the differences.
6377 Here the input:
6379 @Example
6380 .ll 4i
6381 .ce 1000
6382 This is a small text fragment which shows the differences
6383 between the `.ce' and the `.ad c' request.
6384 .ce 0
6386 .ad c
6387 This is a small text fragment which shows the differences
6388 between the `.ce' and the `.ad c' request.
6389 @endExample
6391 @noindent
6392 And here the result:
6394 @Example
6395   This is a small text fragment which
6396          shows the differences
6397 between the `.ce' and the `.ad c' request.
6399   This is a small text fragment which
6400 shows the differences between the `.ce'
6401         and the `.ad c' request.
6402 @endExample
6404 With no arguments, @code{ce} centers the next line of text.  @var{nnn}
6405 specifies the number of lines to be centered.  If the argument is zero
6406 or negative, centering is disabled.
6408 The basic length for centering text is the line length (as set with the
6409 @code{ll} request) minus the indentation (as set with the @code{in}
6410 request).  Temporary indentation is ignored.
6412 As can be seen in the previous example, it is a common idiom to turn
6413 on centering for a large number of lines, and to turn off centering
6414 after text to be centered.  This is useful for any request which takes
6415 a number of lines as an argument.
6417 The @code{.ce} read-only number register contains the number of lines
6418 remaining to be centered, as set by the @code{ce} request.
6419 @endDefreq
6421 @DefreqList {rj, [@Var{nnn}]}
6422 @DefregListEnd {.rj}
6423 @cindex justifying text (@code{rj})
6424 @cindex text, justifying (@code{rj})
6425 @cindex right-justifying (@code{rj})
6426 Justify unfilled text to the right margin.  Arguments are identical to
6427 the @code{ce} request.  The @code{.rj} read-only number register is
6428 the number of lines to be right-justified as set by the @code{rj}
6429 request.  This request causes a break.  The number of lines still to be
6430 right-justified is associated with the current environment
6431 (@pxref{Environments}).
6432 @endDefreq
6435 @c =====================================================================
6437 @node Manipulating Hyphenation, Manipulating Spacing, Manipulating Filling and Adjusting, gtroff Reference
6438 @section Manipulating Hyphenation
6439 @cindex manipulating hyphenation
6440 @cindex hyphenation, manipulating
6443 Here a description of requests which influence hyphenation.
6445 @DefreqList {hy, [@Var{mode}]}
6446 @DefregListEnd {.hy}
6447 Enable hyphenation.  The request has an optional numeric argument,
6448 @var{mode}, to restrict hyphenation if necessary:
6450 @table @code
6451 @item 1
6452 The default argument if @var{mode} is omitted.  Hyphenate without
6453 restrictions.  This is also the start-up value of @code{gtroff}.
6455 @item 2
6456 Do not hyphenate the last word on a page or column.
6458 @item 4
6459 Do not hyphenate the last two characters of a word.
6461 @item 8
6462 Do not hyphenate the first two characters of a word.
6463 @end table
6465 Values in the previous table are additive.  For example, the
6466 value@tie{}12 causes @code{gtroff} to neither hyphenate the last
6467 two nor the first two characters of a word.
6469 @cindex hyphenation restrictions register (@code{.hy})
6470 The current hyphenation restrictions can be found in the read-only
6471 number register @samp{.hy}.
6473 The hyphenation mode is associated with the current environment
6474 (@pxref{Environments}).
6475 @endDefreq
6477 @Defreq {nh, }
6478 Disable hyphenation (i.e., set the hyphenation mode to zero).  Note
6479 that the hyphenation mode of the last call to @code{hy} is not
6480 remembered.
6482 The hyphenation mode is associated with the current environment
6483 (@pxref{Environments}).
6484 @endDefreq
6486 @DefreqList {hlm, [@Var{nnn}]}
6487 @DefregItem {.hlm}
6488 @DefregListEnd {.hlc}
6489 @cindex explicit hyphen (@code{\%})
6490 @cindex hyphen, explicit (@code{\%})
6491 @cindex consecutive hyphenated lines (@code{hlm})
6492 @cindex lines, consecutive hyphenated (@code{hlm})
6493 @cindex hyphenated lines, consecutive (@code{hlm})
6494 Set the maximum number of consecutive hyphenated lines to @var{nnn}.
6495 If this number is negative, there is no maximum.  The default value
6496 is@tie{}@minus{}1 if @var{nnn} is omitted.  This value is associated
6497 with the current environment (@pxref{Environments}).  Only lines
6498 output from a given environment count towards the maximum associated
6499 with that environment.  Hyphens resulting from @code{\%} are counted;
6500 explicit hyphens are not.
6502 The current setting of @code{hlm} is available in the @code{.hlm}
6503 read-only number register.  Also the number of immediately preceding
6504 consecutive hyphenated lines are available in the read-only number
6505 register @samp{.hlc}.
6506 @endDefreq
6508 @Defreq {hw, word1 word2 @dots{}}
6509 Define how @var{word1}, @var{word2}, etc.@: are to be hyphenated.  The
6510 words must be given with hyphens at the hyphenation points.  For
6511 example:
6513 @Example
6514 .hw in-sa-lub-rious
6515 @endExample
6517 @noindent
6518 Besides the space character, any character whose hyphenation code value
6519 is zero can be used to separate the arguments of @code{hw} (see the
6520 documentation for the @code{hcode} request below for more information).
6521 In addition, this request can be used more than once.
6523 Hyphenation exceptions specified with the @code{hw} request are
6524 associated with the current hyphenation language; it causes an error
6525 if there is no current hyphenation language.
6527 This request is ignored if there is no parameter.
6529 In old versions of @code{troff} there was a limited amount of space to
6530 store such information; fortunately, with @code{gtroff}, this is no
6531 longer a restriction.
6532 @endDefreq
6534 @DefescList {\\%, , , }
6535 @deffnx Escape @t{\:}
6536 @ifnotinfo
6537 @esindex \:
6538 @end ifnotinfo
6539 @ifinfo
6540 @esindex \@r{<colon>}
6541 @end ifinfo
6542 @cindex hyphenation character (@code{\%})
6543 @cindex character, hyphenation (@code{\%})
6544 @cindex disabling hyphenation (@code{\%})
6545 @cindex hyphenation, disabling (@code{\%})
6546 To tell @code{gtroff} how to hyphenate words on the fly, use the
6547 @code{\%} escape, also known as the @dfn{hyphenation character}.
6548 Preceding a word with this character prevents it from being
6549 hyphenated; putting it inside a word indicates to @code{gtroff} that
6550 the word may be hyphenated at that point.  Note that this mechanism
6551 only affects that one occurrence of the word; to change the
6552 hyphenation of a word for the entire document, use the @code{hw}
6553 request.
6555 The @code{\:} escape inserts a zero-width break point
6556 (that is, the word breaks but without adding a hyphen).
6558 @Example
6559 ... check the /var/log/\:httpd/\:access_log file ...
6560 @endExample
6562 @cindex @code{\X}, followed by @code{\%}
6563 @cindex @code{\Y}, followed by @code{\%}
6564 @cindex @code{\%}, following @code{\X} or @code{\Y}
6565 Note that @code{\X} and @code{\Y} start a word, that is, the @code{\%}
6566 escape in (say) @w{@samp{\X'...'\%foobar}} and
6567 @w{@samp{\Y'...'\%foobar}} no longer prevents hyphenation but inserts
6568 a hyphenation point at the beginning of @samp{foobar}; most likely
6569 this isn't what you want to do.
6570 @endDefesc
6572 @Defreq {hc, [@Var{char}]}
6573 Change the hyphenation character to @var{char}.  This character then
6574 works the same as the @code{\%} escape, and thus, no longer appears in
6575 the output.  Without an argument, @code{hc} resets the hyphenation
6576 character to be @code{\%} (the default) only.
6578 The hyphenation character is associated with the current environment
6579 (@pxref{Environments}).
6580 @endDefreq
6582 @DefreqList {hpf, pattern_file}
6583 @DefreqItem {hpfa, pattern_file}
6584 @DefreqListEnd {hpfcode, a b [c d @dots{}]}
6585 @cindex hyphenation patterns (@code{hpf})
6586 @cindex patterns for hyphenation (@code{hpf})
6587 Read in a file of hyphenation patterns.  This file is searched for in
6588 the same way as @file{@var{name}.tmac} (or @file{tmac.@var{name}}) is
6589 searched for if the @option{-m@var{name}} option is specified.
6591 It should have the same format as (simple) @TeX{} patterns files.
6592 More specifically, the following scanning rules are implemented.
6594 @itemize @bullet
6595 @item
6596 A percent sign starts a comment (up to the end of the line)
6597 even if preceded by a backslash.
6599 @item
6600 No support for `digraphs' like @code{\$}.
6602 @item
6603 @code{^^@var{xx}} (@var{x} is 0-9 or a-f) and @code{^^@var{x}} (character
6604 code of @var{x} in the range 0-127) are recognized; other use of @code{^}
6605 causes an error.
6607 @item
6608 No macro expansion.
6610 @item
6611 @code{hpf} checks for the expression @code{\patterns@{@dots{}@}}
6612 (possibly with whitespace before and after the braces).
6613 Everything between the braces is taken as hyphenation patterns.
6614 Consequently, @code{@{} and @code{@}} are not allowed in patterns.
6616 @item
6617 Similarly, @code{\hyphenation@{@dots{}@}} gives a list of hyphenation
6618 exceptions.
6620 @item
6621 @code{\endinput} is recognized also.
6623 @item
6624 For backwards compatibility, if @code{\patterns} is missing,
6625 the whole file is treated as a list of hyphenation patterns
6626 (only recognizing the @code{%} character as the start of a comment).
6627 @end itemize
6629 If no @code{hpf} request is specified (either in the document or in a
6630 macro package), @code{gtroff} won't hyphenate at all.
6632 The @code{hpfa} request appends a file of patterns to the current list.
6634 The @code{hpfcode} request defines mapping values for character codes in
6635 hyphenation patterns.  @code{hpf} or @code{hpfa} then apply the mapping
6636 (after reading the patterns) before replacing or appending them to
6637 the current list of patterns.  Its arguments are pairs of character codes
6638 -- integers from 0 to@tie{}255.  The request maps character code@tie{}@var{a}
6639 to code@tie{}@var{b}, code@tie{}@var{c} to code@tie{}@var{d}, and so on.  You
6640 can use character codes which would be invalid otherwise.
6642 @pindex troffrc
6643 @pindex troffrc-end
6644 @pindex hyphen.us
6645 @pindex hyphenex.us
6646 The set of hyphenation patterns is associated with the current language
6647 set by the @code{hla} request.  The @code{hpf} request is usually
6648 invoked by the @file{troffrc} or @file{troffrc-end} file; by default,
6649 @file{troffrc} loads hyphenation patterns and exceptions for American
6650 English (in files @file{hyphen.us} and @file{hyphenex.us}).
6652 A second call to @code{hpf} (for the same language) will replace the
6653 hyphenation patterns with the new ones.
6655 Invoking @code{hpf} causes an error if there is no current hyphenation
6656 language.
6657 @endDefreq
6659 @Defreq {hcode, c1 code1 c2 code2 @dots{}}
6660 @cindex hyphenation code (@code{hcode})
6661 @cindex code, hyphenation (@code{hcode})
6662 Set the hyphenation code of character @var{c1} to @var{code1}, that of
6663 @var{c2} to @var{code2}, etc.  A hyphenation code must be a single
6664 input character (not a special character) other than a digit or a
6665 space.
6667 To make hyphenation work, hyphenation codes must be set up.  At
6668 start-up, groff only assigns hyphenation codes to the letters
6669 @samp{a}-@samp{z} (mapped to themselves) and to the letters
6670 @samp{A}-@samp{Z} (mapped to @samp{a}-@samp{z}); all other hyphenation
6671 codes are set to zero.  Normally, hyphenation patterns contain only
6672 lowercase letters which should be applied regardless of case.  With
6673 other words, the words `FOO' and `Foo' should be hyphenated exactly the
6674 same way as the word `foo' is hyphenated, and this is what @code{hcode}
6675 is good for.  Words which contain other letters won't be hyphenated
6676 properly if the corresponding hyphenation patterns actually do contain
6677 them.  For example, the following @code{hcode} requests are necessary to
6678 assign hyphenation codes to the letters @samp{ÄäÖöÜüß} (this is needed
6679 for German):
6681 @Example
6682 .hcode Ã¤ Ã¤  Ã„ Ã¤
6683 .hcode Ã¶ Ã¶  Ã– Ã¶
6684 .hcode Ã¼ Ã¼  Ãœ Ã¼
6685 .hcode ÃŸ ÃŸ
6686 @endExample
6688 Without those assignments, groff treats German words like
6689 @w{`Kindergärten'} (the plural form of `kindergarten') as two
6690 substrings @w{`kinderg'} and @w{`rten'} because the hyphenation code
6691 of the umlaut@tie{}a is zero by default.  There is a German
6692 hyphenation pattern which covers @w{`kinder'}, so groff finds the
6693 hyphenation `kin-der'.  The other two hyphenation points
6694 (`kin-der-gär-ten') are missed.
6696 This request is ignored if it has no parameter.
6697 @endDefreq
6699 @DefreqList {hym, [@Var{length}]}
6700 @DefregListEnd {.hym}
6701 @cindex hyphenation margin (@code{hym})
6702 @cindex margin for hyphenation (@code{hym})
6703 @cindex @code{ad} request, and hyphenation margin
6704 Set the (right) hyphenation margin to @var{length}.  If the current
6705 adjustment mode is not @samp{b} or @samp{n}, the line is not
6706 hyphenated if it is shorter than @var{length}.  Without an argument,
6707 the hyphenation margin is reset to its default value, which is@tie{}0.
6708 The default scaling indicator for this request is @samp{m}.  The
6709 hyphenation margin is associated with the current environment
6710 (@pxref{Environments}).
6712 A negative argument resets the hyphenation margin to zero, emitting
6713 a warning of type @samp{range}.
6715 @cindex hyphenation margin register (@code{.hym})
6716 The current hyphenation margin is available in the @code{.hym} read-only
6717 number register.
6718 @endDefreq
6720 @DefreqList {hys, [@Var{hyphenation_space}]}
6721 @DefregListEnd {.hys}
6722 @cindex hyphenation space (@code{hys})
6723 @cindex @code{ad} request, and hyphenation space
6724 Set the hyphenation space to @var{hyphenation_space}.  If the current
6725 adjustment mode is @samp{b} or @samp{n}, don't hyphenate the line
6726 if it can be justified by adding no more than @var{hyphenation_space}
6727 extra space to each word space.  Without argument, the hyphenation
6728 space is set to its default value, which is@tie{}0.  The default
6729 scaling indicator for this request is @samp{m}.  The hyphenation
6730 space is associated with the current environment
6731 (@pxref{Environments}).
6733 A negative argument resets the hyphenation space to zero, emitting a
6734 warning of type @samp{range}.
6736 @cindex hyphenation space register (@code{.hys})
6737 The current hyphenation space is available in the @code{.hys} read-only
6738 number register.
6739 @endDefreq
6741 @Defreq {shc, [@Var{glyph}]}
6742 @cindex soft hyphen character, setting (@code{shc})
6743 @cindex character, soft hyphen, setting (@code{shc})
6744 @cindex glyph, soft hyphen (@code{hy})
6745 @cindex soft hyphen glyph (@code{hy})
6746 @cindex @code{char} request, and soft hyphen character
6747 @cindex @code{tr} request, and soft hyphen character
6748 Set the @dfn{soft hyphen character} to @var{glyph}.@footnote{@dfn{Soft
6749 hyphen character} is a misnomer since it is an output glyph.}  If the
6750 argument is omitted, the soft hyphen character is set to the default
6751 glyph @code{\(hy} (this is the start-up value of @code{gtroff} also).
6752 The soft hyphen character is the glyph that is inserted when a word is
6753 hyphenated at a line break.  If the soft hyphen character does not
6754 exist in the font of the character immediately preceding a potential
6755 break point, then the line is not broken at that point.  Neither
6756 definitions (specified with the @code{char} request) nor translations
6757 (specified with the @code{tr} request) are considered when finding the
6758 soft hyphen character.
6759 @endDefreq
6761 @DefreqList {hla, language}
6762 @DefregListEnd {.hla}
6763 @cindex @code{hpf} request, and hyphenation language
6764 @cindex @code{hw} request, and hyphenation language
6765 @pindex troffrc
6766 @pindex troffrc-end
6767 Set the current hyphenation language to the string @var{language}.
6768 Hyphenation exceptions specified with the @code{hw} request and
6769 hyphenation patterns specified with the @code{hpf} and @code{hpfa}
6770 requests are both associated with the current hyphenation language.
6771 The @code{hla} request is usually invoked by the @file{troffrc} or the
6772 @file{troffrc-end} files; @file{troffrc} sets the default language to
6773 @samp{us}.
6775 @cindex hyphenation language register (@code{.hla})
6776 The current hyphenation language is available as a string in the
6777 read-only number register @samp{.hla}.
6779 @Example
6780 .ds curr_language \n[.hla]
6781 \*[curr_language]
6782     @result{} us
6783 @endExample
6784 @endDefreq
6787 @c =====================================================================
6789 @node Manipulating Spacing, Tabs and Fields, Manipulating Hyphenation, gtroff Reference
6790 @section Manipulating Spacing
6791 @cindex manipulating spacing
6792 @cindex spacing, manipulating
6794 @Defreq {sp, [@Var{distance}]}
6795 Space downwards @var{distance}.  With no argument it advances
6796 1@tie{}line.  A negative argument causes @code{gtroff} to move up the page
6797 the specified distance.  If the argument is preceded by a @samp{|}
6798 then @code{gtroff} moves that distance from the top of the page.  This
6799 request causes a line break.  The default scaling indicator is @samp{v}.
6801 If a vertical trap is sprung during execution of @code{sp}, the amount of
6802 vertical space after the trap is discarded.  For example, this
6804 @Example
6805 .de xxx
6808 .wh 0 xxx
6810 .pl 5v
6812 .sp 2
6814 .sp 50
6816 @endExample
6818 @noindent
6819 results in
6821 @Example
6828 @endExample
6830 @cindex @code{sp} request, and traps
6831 @cindex discarded space in traps
6832 @cindex space, discarded, in traps
6833 @cindex traps, and discarded space
6834 The amount of discarded space is available in the number register
6835 @code{.trunc}.
6837 To protect @code{sp} against vertical traps, use the @code{vpt} request:
6839 @Example
6840 .vpt 0
6841 .sp -3
6842 .vpt 1
6843 @endExample
6844 @endDefreq
6846 @DefreqList {ls, [@Var{nnn}]}
6847 @DefregListEnd {.L}
6848 @cindex double-spacing (@code{ls})
6849 Output @w{@var{nnn}@minus{}1} blank lines after each line of text.
6850 With no argument, @code{gtroff} uses the previous value before the
6851 last @code{ls} call.
6853 @Example
6854 .ls 2    \" This causes double-spaced output
6855 .ls 3    \" This causes triple-spaced output
6856 .ls      \" Again double-spaced
6857 @endExample
6859 The line spacing is associated with the current environment
6860 (@pxref{Environments}).
6862 @cindex line spacing register (@code{.L})
6863 The read-only number register @code{.L} contains the current line
6864 spacing setting.
6865 @endDefreq
6867 @xref{Changing Type Sizes}, for the requests @code{vs} and @code{pvs}
6868 as alternatives to @code{ls}.
6870 @DefescList {\\x, ', spacing, '}
6871 @DefregListEnd {.a}
6872 Sometimes, extra vertical spacing is only needed occasionally, e.g.@:
6873 to allow space for a tall construct (like an equation).  The @code{\x}
6874 escape does this.  The escape is given a numerical argument, usually
6875 enclosed in quotes (like @samp{\x'3p'}); the default scaling indicator
6876 is @samp{v}.  If this number is positive extra vertical space is
6877 inserted below the current line.  A negative number adds space above.
6878 If this escape is used multiple times on the same line, the maximum of
6879 the values is used.
6881 @xref{Escapes}, for details on parameter delimiting characters.
6883 @cindex extra post-vertical line space register (@code{.a})
6884 The @code{.a} read-only number register contains the most recent
6885 (nonnegative) extra vertical line space.
6887 Using @code{\x} can be necessary in combination with the @code{\b}
6888 escape, as the following example shows.
6890 @Example
6891 This is a test with the \[rs]b escape.
6893 This is a test with the \[rs]b escape.
6895 This is a test with \b'xyz'\x'-1m'\x'1m'.
6897 This is a test with the \[rs]b escape.
6899 This is a test with the \[rs]b escape.
6900 @endExample
6902 @noindent
6903 produces
6905 @Example
6906 This is a test with the \b escape.
6907 This is a test with the \b escape.
6908                     x
6909 This is a test with y.
6910                     z
6911 This is a test with the \b escape.
6912 This is a test with the \b escape.
6913 @endExample
6914 @endDefesc
6916 @DefreqList {ns, }
6917 @DefreqItem {rs, }
6918 @DefregListEnd {.ns}
6919 @cindex @code{sp} request, and no-space mode
6920 @cindex no-space mode (@code{ns})
6921 @cindex mode, no-space (@code{ns})
6922 @cindex blank lines, disabling
6923 @cindex lines, blank, disabling
6924 Enable @dfn{no-space mode}.  In this mode, spacing (either via
6925 @code{sp} or via blank lines) is disabled.  The @code{bp} request to
6926 advance to the next page is also disabled, except if it is accompanied
6927 by a page number (see @ref{Page Control}, for more information).  This
6928 mode ends when actual text is output or the @code{rs} request is
6929 encountered which ends no-space mode.  The read-only number register
6930 @code{.ns} is set to@tie{}1 as long as no-space mode is active.
6932 This request is useful for macros that conditionally
6933 insert vertical space before the text starts
6934 (for example, a paragraph macro could insert some space
6935 except when it is the first paragraph after a section header).
6936 @endDefreq
6939 @c =====================================================================
6941 @node Tabs and Fields, Character Translations, Manipulating Spacing, gtroff Reference
6942 @section Tabs and Fields
6943 @cindex tabs, and fields
6944 @cindex fields, and tabs
6946 @cindex @acronym{EBCDIC} encoding of a tab
6947 A tab character (@acronym{ASCII} char@tie{}9, @acronym{EBCDIC}
6948 char@tie{}5) causes a horizontal movement to the next tab stop (much
6949 like it did on a typewriter).
6951 @Defesc {\\t, , , }
6952 @cindex tab character, non-interpreted (@code{\t})
6953 @cindex character, tab, non-interpreted (@code{\t})
6954 This escape is a non-interpreted tab character.  In copy mode
6955 (@pxref{Copy-in Mode}), @code{\t} is the same as a real tab character.
6956 @endDefesc
6958 @DefreqList {ta, [@Var{n1} @Var{n2} @dots{} @Var{nn} @t{T} @Var{r1} @Var{r2} @dots{} @Var{rn}]}
6959 @DefregListEnd {.tabs}
6960 Change tab stop positions.  This request takes a series of tab
6961 specifiers as arguments (optionally divided into two groups with the
6962 letter @samp{T}) which indicate where each tab stop is to be
6963 (overriding any previous settings).
6965 Tab stops can be specified absolutely, i.e., as the distance from the
6966 left margin.  For example, the following sets 6@tie{}tab stops every
6967 one inch.
6969 @Example
6970 .ta 1i 2i 3i 4i 5i 6i
6971 @endExample
6973 Tab stops can also be specified using a leading @samp{+}
6974 which means that the specified tab stop is set relative to
6975 the previous tab stop.  For example, the following is equivalent to the
6976 previous example.
6978 @Example
6979 .ta 1i +1i +1i +1i +1i +1i
6980 @endExample
6982 @code{gtroff} supports an extended syntax to specify repeat values after
6983 the @samp{T} mark (these values are always taken as relative) -- this is
6984 the usual way to specify tabs set at equal intervals.  The following is,
6985 yet again, the same as the previous examples.  It does even more since
6986 it defines an infinite number of tab stops separated by one inch.
6988 @Example
6989 .ta T 1i
6990 @endExample
6992 Now we are ready to interpret the full syntax given at the beginning:
6993 Set tabs at positions @var{n1}, @var{n2}, @dots{}, @var{nn} and then set
6994 tabs at @var{nn}+@var{r1}, @var{nn}+@var{r2}, @dots{}, @var{nn}+@var{rn}
6995 and then at @var{nn}+@var{rn}+@var{r1}, @var{nn}+@var{rn}+@var{r2},
6996 @dots{}, @var{nn}+@var{rn}+@var{rn}, and so on.
6998 Example: @samp{4c +6c T 3c 5c 2c} is equivalent to @samp{4c 10c 13c 18c
6999 20c 23c 28c 30c @dots{}}.
7001 The material in each tab column (i.e., the column between two tab stops)
7002 may be justified to the right or left or centered in the column.  This
7003 is specified by appending @samp{R}, @samp{L}, or @samp{C} to the tab
7004 specifier.  The default justification is @samp{L}.  Example:
7006 @Example
7007 .ta 1i 2iC 3iR
7008 @endExample
7010 Some notes:
7012 @itemize @bullet
7013 @item
7014 The default unit of the @code{ta} request is @samp{m}.
7016 @item
7017 A tab stop is converted into a non-breakable horizontal movement which
7018 can be neither stretched nor squeezed.  For example,
7020 @Example
7021 .ds foo a\tb\tc
7022 .ta T 5i
7023 \*[foo]
7024 @endExample
7026 @noindent
7027 creates a single line which is a bit longer than 10@tie{}inches (a string
7028 is used to show exactly where the tab characters are).  Now consider the
7029 following:
7031 @Example
7032 .ds bar a\tb b\tc
7033 .ta T 5i
7034 \*[bar]
7035 @endExample
7037 @noindent
7038 @code{gtroff} first converts the tab stops of the line into unbreakable
7039 horizontal movements, then splits the line after the second @samp{b}
7040 (assuming a sufficiently short line length).  Usually, this isn't what
7041 the user wants.
7043 @item
7044 Superfluous tabs (i.e., tab characters which do not correspond to a tab
7045 stop) are ignored except the first one which delimits the characters
7046 belonging to the last tab stop for right-justifying or centering.
7047 Consider the following example
7049 @Example
7050 .ds Z   foo\tbar\tfoo
7051 .ds ZZ  foo\tbar\tfoobar
7052 .ds ZZZ foo\tbar\tfoo\tbar
7053 .ta 2i 4iR
7054 \*[Z]
7056 \*[ZZ]
7058 \*[ZZZ]
7060 @endExample
7062 @noindent
7063 which produces the following output:
7065 @Example
7066 foo                 bar              foo
7067 foo                 bar           foobar
7068 foo                 bar              foobar
7069 @endExample
7071 @noindent
7072 The first line right-justifies the second `foo' relative to the tab
7073 stop.  The second line right-justifies `foobar'.  The third line finally
7074 right-justifies only `foo' because of the additional tab character which
7075 marks the end of the string belonging to the last defined tab stop.
7077 @item
7078 Tab stops are associated with the current environment
7079 (@pxref{Environments}).
7081 @item
7082 Calling @code{ta} without an argument removes all tab stops.
7084 @item
7085 @cindex tab stops, for TTY output devices
7086 The start-up value of @code{gtroff} is @w{@samp{T 0.8i}}.
7087 @end itemize
7089 @cindex tab settings register (@code{.tabs})
7090 The read-only number register @code{.tabs} contains a string
7091 representation of the current tab settings suitable for use as an
7092 argument to the @code{ta} request.
7094 @Example
7095 .ds tab-string \n[.tabs]
7096 \*[tab-string]
7097     @result{} T120u
7098 @endExample
7100 @cindex @code{.S} register, Plan@tie{}9 alias for @code{.tabs}
7101 @cindex @code{.tabs} register, Plan@tie{}9 alias (@code{.S})
7102 The @code{troff} version of the Plan@tie{}9 operating system uses
7103 register @code{.S} for the same purpose.
7104 @endDefreq
7106 @Defreq {tc, [@Var{fill-glyph}]}
7107 @cindex tab repetition character (@code{tc})
7108 @cindex character, tab repetition (@code{tc})
7109 @cindex glyph, tab repetition (@code{tc})
7110 Normally @code{gtroff} fills the space to the next tab stop with
7111 whitespace.  This can be changed with the @code{tc} request.  With no
7112 argument @code{gtroff} reverts to using whitespace, which is the
7113 default.  The value of this @dfn{tab repetition character} is
7114 associated with the current environment
7115 (@pxref{Environments}).@footnote{@dfn{Tab repetition character} is a
7116 misnomer since it is an output glyph.}
7117 @endDefreq
7119 @DefreqList {linetabs, n}
7120 @DefregListEnd {.linetabs}
7121 @cindex tab, line-tabs mode
7122 @cindex line-tabs mode
7123 @cindex mode, line-tabs
7124 If @var{n} is missing or not zero, enable @dfn{line-tabs} mode,
7125 or disable it otherwise (the default).
7126 In line-tabs mode, @code{gtroff} computes tab distances
7127 relative to the (current) output line instead of the input line.
7129 For example, the following code:
7131 @Example
7132 .ds x a\t\c
7133 .ds y b\t\c
7134 .ds z c
7135 .ta 1i 3i
7139 @endExample
7141 @noindent
7142 in normal mode, results in the output
7144 @Example
7145 a         b         c
7146 @endExample
7148 @noindent
7149 in line-tabs mode, the same code outputs
7151 @Example
7152 a         b                   c
7153 @endExample
7155 Line-tabs mode is associated with the current environment.
7156 The read-only register @code{.linetabs} is set to@tie{}1 if in line-tabs
7157 mode, and 0 in normal mode.
7158 @endDefreq
7160 @menu
7161 * Leaders::
7162 * Fields::
7163 @end menu
7165 @c ---------------------------------------------------------------------
7167 @node Leaders, Fields, Tabs and Fields, Tabs and Fields
7168 @subsection Leaders
7169 @cindex leaders
7171 Sometimes it may may be desirable to use the @code{tc} request to fill a
7172 particular tab stop with a given glyph (for example dots in a table
7173 of contents), but also normal tab stops on the rest of the line.  For
7174 this @code{gtroff} provides an alternate tab mechanism, called
7175 @dfn{leaders} which does just that.
7177 @cindex leader character
7178 A leader character (character code@tie{}1) behaves similarly to a tab
7179 character: It moves to the next tab stop.  The only difference is that
7180 for this movement, the fill glyph defaults to a period character and
7181 not to space.
7183 @Defesc {\\a, , , }
7184 @cindex leader character, non-interpreted (@code{\a})
7185 @cindex character, leader, non-interpreted (@code{\a})
7186 This escape is a non-interpreted leader character.  In copy mode
7187 (@pxref{Copy-in Mode}), @code{\a} is the same as a real leader
7188 character.
7189 @endDefesc
7191 @Defreq {lc, [@Var{fill-glyph}]}
7192 @cindex leader repetition character (@code{lc})
7193 @cindex character, leader repetition (@code{lc})
7194 @cindex glyph, leader repetition (@code{lc})
7195 Declare the @dfn{leader repetition character}.@footnote{@dfn{Leader
7196 repetition character} is a misnomer since it is an output glyph.}
7197 Without an argument, leaders act the same as tabs (i.e., using
7198 whitespace for filling).  @code{gtroff}'s start-up value is a dot
7199 (@samp{.}).  The value of the leader repetition character is
7200 associated with the current environment (@pxref{Environments}).
7201 @endDefreq
7203 @cindex table of contents
7204 @cindex contents, table of
7205 For a table of contents, to name an example, tab stops may be defined so
7206 that the section number is one tab stop, the title is the second with
7207 the remaining space being filled with a line of dots, and then the page
7208 number slightly separated from the dots.
7210 @Example
7211 .ds entry 1.1\tFoo\a\t12
7212 .lc .
7213 .ta 1i 5i +.25i
7214 \*[entry]
7215 @endExample
7217 @noindent
7218 This produces
7220 @Example
7221 1.1  Foo..........................................  12
7222 @endExample
7224 @c ---------------------------------------------------------------------
7226 @node Fields,  , Leaders, Tabs and Fields
7227 @subsection Fields
7228 @cindex fields
7230 @cindex field delimiting character (@code{fc})
7231 @cindex delimiting character, for fields (@code{fc})
7232 @cindex character, field delimiting (@code{fc})
7233 @cindex field padding character (@code{fc})
7234 @cindex padding character, for fields (@code{fc})
7235 @cindex character, field padding (@code{fc})
7236 @dfn{Fields} are a more general way of laying out tabular data.  A field
7237 is defined as the data between a pair of @dfn{delimiting characters}.
7238 It contains substrings which are separated by @dfn{padding characters}.
7239 The width of a field is the distance on the @emph{input} line from the
7240 position where the field starts to the next tab stop.  A padding
7241 character inserts stretchable space similar to @TeX{}'s @code{\hss}
7242 command (thus it can even be negative) to make the sum of all substring
7243 lengths plus the stretchable space equal to the field width.  If more
7244 than one padding character is inserted, the available space is evenly
7245 distributed among them.
7247 @Defreq {fc, [@Var{delim-char} [@Var{padding-char}]]}
7248 Define a delimiting and a padding character for fields.  If the latter
7249 is missing, the padding character defaults to a space character.  If
7250 there is no argument at all, the field mechanism is disabled (which is
7251 the default).  Note that contrary to e.g.@: the tab repetition
7252 character, delimiting and padding characters are @emph{not} associated
7253 to the current environment (@pxref{Environments}).
7255 Example:
7257 @Example
7258 .fc # ^
7259 .ta T 3i
7260 #foo^bar^smurf#
7262 #foo^^bar^smurf#
7263 @endExample
7265 @noindent
7266 and here the result:
7268 @Example
7269 foo         bar          smurf
7270 foo            bar       smurf
7271 @endExample
7272 @endDefreq
7275 @c =====================================================================
7277 @node Character Translations, Troff and Nroff Mode, Tabs and Fields, gtroff Reference
7278 @section Character Translations
7279 @cindex character translations
7280 @cindex translations of characters
7282 @cindex control character, changing (@code{cc})
7283 @cindex character, control, changing (@code{cc})
7284 @cindex no-break control character, changing (@code{c2})
7285 @cindex character, no-break control, changing (@code{c2})
7286 @cindex control character, no-break, changing (@code{c2})
7287 The control character (@samp{.}) and the no-break control character
7288 (@samp{'}) can be changed with the @code{cc} and @code{c2} requests,
7289 respectively.
7291 @Defreq {cc, [@Var{c}]}
7292 Set the control character to@tie{}@var{c}.  With no argument the default
7293 control character @samp{.} is restored.  The value of the control
7294 character is associated with the current environment
7295 (@pxref{Environments}).
7296 @endDefreq
7298 @Defreq {c2, [@Var{c}]}
7299 Set the no-break control character to@tie{}@var{c}.  With no argument the
7300 default control character @samp{'} is restored.  The value of the
7301 no-break control character is associated with the current environment
7302 (@pxref{Environments}).
7303 @endDefreq
7305 @Defreq {eo, }
7306 @cindex disabling @code{\} (@code{eo})
7307 @cindex @code{\}, disabling (@code{eo})
7308 Disable the escape mechanism completely.  After executing this
7309 request, the backslash character @samp{\} no longer starts an escape
7310 sequence.
7312 This request can be very helpful in writing macros since it is not
7313 necessary then to double the escape character.  Here an example:
7315 @Example
7316 .\" This is a simplified version of the
7317 .\" .BR request from the man macro package
7319 .de BR
7320 .  ds result \&
7321 .  while (\n[.$] >= 2) \@{\
7322 .    as result \fB\$1\fR\$2
7323 .    shift 2
7324 .  \@}
7325 .  if \n[.$] .as result \fB\$1
7326 \*[result]
7327 .  ft R
7330 @endExample
7331 @endDefreq
7333 @Defreq {ec, [@Var{c}]}
7334 @cindex escape character, changing (@code{ec})
7335 @cindex character, escape, changing (@code{ec})
7336 Set the escape character to@tie{}@var{c}.  With no argument the default
7337 escape character @samp{\} is restored.  It can be also used to
7338 re-enable the escape mechanism after an @code{eo} request.
7340 Note that changing the escape character globally will likely break
7341 macro packages since @code{gtroff} has no mechanism to `intern' macros,
7342 i.e., to convert a macro definition into an internal form which is
7343 independent of its representation (@TeX{} has this mechanism).
7344 If a macro is called, it is executed literally.
7345 @endDefreq
7347 @DefreqList {ecs, }
7348 @DefreqListEnd {ecr, }
7349 The @code{ecs} request saves the current escape character
7350 in an internal register.
7351 Use this request in combination with the @code{ec} request to
7352 temporarily change the escape character.
7354 The @code{ecr} request restores the escape character
7355 saved with @code{ecs}.
7356 Without a previous call to @code{ecs}, this request
7357 sets the escape character to @code{\}.
7358 @endDefreq
7360 @DefescList {\\\\, , , }
7361 @DefescItem {\\e, , , }
7362 @DefescListEnd {\\E, , , }
7363 Print the current escape character (which is the backslash character
7364 @samp{\} by default).
7366 @code{\\} is a `delayed' backslash; more precisely, it is the default
7367 escape character followed by a backslash, which no longer has special
7368 meaning due to the leading escape character.  It is @emph{not} an escape
7369 sequence in the usual sense!  In any unknown escape sequence
7370 @code{\@var{X}} the escape character is ignored and @var{X} is printed.
7371 But if @var{X} is equal to the current escape character, no warning is
7372 emitted.
7374 As a consequence, only at top-level or in a diversion a backslash glyph is
7375 printed; in copy-in mode, it expands to a single backslash which then
7376 combines with the following character to an escape sequence.
7378 The @code{\E} escape differs from @code{\e} by printing an escape
7379 character that is not interpreted in copy mode.
7380 Use this to define strings with escapes that work
7381 when used in copy mode (for example, as a macro argument).
7382 The following example defines strings to begin and end
7383 a superscript:
7385 @Example
7386 .ds @{ \v'-.3m'\s'\En[.s]*60/100'
7387 .ds @} \s0\v'.3m'
7388 @endExample
7390 Another example to demonstrate the differences between the various escape
7391 sequences, using a strange escape character, @samp{-}.
7393 @Example
7394 .ec -
7395 .de xxx
7396 --A'123'
7398 .xxx
7399     @result{} -A'foo'
7400 @endExample
7402 @noindent
7403 The result is surprising for most users, expecting @samp{1} since
7404 @samp{foo} is a valid identifier.  What has happened?  As mentioned
7405 above, the leading escape character makes the following character
7406 ordinary.  Written with the default escape character the sequence
7407 @samp{--} becomes @samp{\-} -- this is the minus sign.
7409 If the escape character followed by itself is a valid escape sequence,
7410 only @code{\E} yields the expected result:
7412 @Example
7413 .ec -
7414 .de xxx
7415 -EA'123'
7417 .xxx
7418     @result{} 1
7419 @endExample
7420 @endDefesc
7422 @Defesc {\\., , , }
7423 Similar to @code{\\}, the sequence @code{\.} isn't a real escape sequence.
7424 As before, a warning message is suppressed if the escape character is
7425 followed by a dot, and the dot itself is printed.
7427 @Example
7428 .de foo
7429 .  nop foo
7431 .  de bar
7432 .    nop bar
7433 \\..
7436 .foo
7437 .bar
7438     @result{} foo bar
7439 @endExample
7441 @noindent
7442 The first backslash is consumed while the macro is read, and the second
7443 is swallowed while exexuting macro @code{foo}.
7444 @endDefesc
7446 A @dfn{translation} is a mapping of an input character to an output
7447 glyph.  The mapping occurs at output time, i.e., the input character
7448 gets assigned the metric information of the mapped output character
7449 right before input tokens are converted to nodes (@pxref{Gtroff
7450 Internals}, for more on this process).
7452 @DefreqList {tr, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
7453 @DefreqListEnd {trin, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
7454 Translate character @var{a} to glyph@tie{}@var{b}, character @var{c} to
7455 glyph@tie{}@var{d}, etc.  If there is an odd number of arguments, the
7456 last one is translated to an unstretchable space (@w{@samp{\ }}).
7458 The @code{trin} request is identical to @code{tr},
7459 but when you unformat a diversion with @code{asciify}
7460 it ignores the translation.
7461 @xref{Diversions}, for details about the @code{asciify} request.
7463 Some notes:
7465 @itemize @bullet
7466 @item
7467 @cindex @code{\(}, and translations
7468 @cindex @code{\[}, and translations
7469 @cindex @code{\'}, and translations
7470 @cindex @code{\`}, and translations
7471 @cindex @code{\-}, and translations
7472 @cindex @code{\_}, and translations
7473 @cindex @code{\C}, and translations
7474 @cindex @code{\N}, and translations
7475 @cindex @code{char} request, and translations
7476 @cindex special characters
7477 @cindex character, special
7478 @cindex numbered glyph (@code{\N})
7479 @cindex glyph, numbered (@code{\N})
7480 Special characters (@code{\(@var{xx}}, @code{\[@var{xxx}]},
7481 @code{\C'@var{xxx}'}, @code{\'}, @code{\`}, @code{\-}, @code{\_}),
7482 glyphs defined with the @code{char} request, and numbered glyphs
7483 (@code{\N'@var{xxx}'}) can be translated also.
7485 @item
7486 @cindex @code{\e}, and translations
7487 The @code{\e} escape can be translated also.
7489 @item
7490 @cindex @code{\%}, and translations
7491 @cindex @code{\~}, and translations
7492 Characters can be mapped onto the @code{\%} and @code{\~} escapes (but
7493 @code{\%} and @code{\~} can't be mapped onto another glyph).
7495 @item
7496 @cindex backspace character, and translations
7497 @cindex character, backspace, and translations
7498 @cindex leader character, and translations
7499 @cindex character, leader, and translations
7500 @cindex newline character, and translations
7501 @cindex character, newline, and translations
7502 @cindex tab character, and translations
7503 @cindex character, tab, and translations
7504 @cindex @code{\a}, and translations
7505 @cindex @code{\t}, and translations
7506 The following characters can't be translated: space (with one exception,
7507 see below), backspace, newline, leader (and @code{\a}), tab (and
7508 @code{\t}).
7510 @item
7511 @cindex @code{shc} request, and translations
7512 Translations are not considered for finding the soft hyphen character
7513 set with the @code{shc} request.
7515 @item
7516 @cindex @code{\&}, and translations
7517 The pair @samp{@var{c}\&} (this is an arbitrary character@tie{}@var{c}
7518 followed by the zero width space character) maps this character to nothing.
7520 @Example
7521 .tr a\&
7522 foo bar
7523     @result{} foo br
7524 @endExample
7526 @noindent
7527 It is even possible to map the space character to nothing:
7529 @Example
7530 .tr aa \&
7531 foo bar
7532     @result{} foobar
7533 @endExample
7535 @noindent
7536 As shown in the example, the space character can't be the first
7537 character/glyph pair as an argument of @code{tr}.  Additionally, it is
7538 not possible to map the space character to any other glyph; requests
7539 like @w{@samp{.tr aa x}} undo @w{@samp{.tr aa \&}} instead.
7541 If justification is active, lines are justified in spite of the
7542 `empty' space character (but there is no minimal distance, i.e.@: the
7543 space character, between words).
7545 @item
7546 After an output glyph has been constructed (this happens at the
7547 moment immediately before the glyph is appended to an output
7548 glyph list, either by direct output, in a macro, diversion, or
7549 string), it is no longer affected by @code{tr}.
7551 @item
7552 Translating character to glyphs where one of them or both are
7553 undefined is possible also; @code{tr} does not check whether the
7554 entities in its argument do exist.
7556 @xref{Gtroff Internals}.
7558 @item
7559 @code{troff} no longer has a hard-coded dependency on @w{Latin-1};
7560 all @code{char@var{XXX}} entities have been removed from the font
7561 description files.  This has a notable consequence which shows up in
7562 warnings like @code{can't find character with input code @var{XXX}}
7563 if the @code{tr} request isn't handled properly.
7565 Consider the following translation:
7567 @Example
7568 .tr Ã©Ã‰
7569 @endExample
7571 @noindent
7572 This maps input character @code{é} onto glyph @code{É}, which is
7573 identical to glyph @code{char201}.  But this glyph intentionally
7574 doesn't exist!  Instead, @code{\[char201]} is treated as an input
7575 character entity and is by default mapped onto @code{\['E]}, and
7576 @code{gtroff} doesn't handle translations of translations.
7578 The right way to write the above translation is
7580 @Example
7581 .tr Ã©\['E]
7582 @endExample
7584 @noindent
7585 With other words, the first argument of @code{tr} should be an input
7586 character or entity, and the second one a glyph entity.
7588 @item
7589 Without an argument, the @code{tr} request is ignored.
7590 @end itemize
7591 @endDefreq
7593 @Defreq {trnt, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
7594 @cindex @code{\!}, and @code{trnt}
7595 @code{trnt} is the same as the @code{tr} request except that the
7596 translations do not apply to text that is transparently throughput
7597 into a diversion with @code{\!}.  @xref{Diversions}, for more
7598 information.
7600 For example,
7602 @Example
7603 .tr ab
7604 .di x
7605 \!.tm a
7608 @endExample
7610 @noindent
7611 prints @samp{b} to the standard error stream; if @code{trnt} is used
7612 instead of @code{tr} it prints @samp{a}.
7613 @endDefreq
7616 @c =====================================================================
7618 @node Troff and Nroff Mode, Line Layout, Character Translations, gtroff Reference
7619 @section Troff and Nroff Mode
7620 @cindex troff mode
7621 @cindex mode, troff
7622 @cindex nroff mode
7623 @cindex mode, nroff
7625 Originally, @code{nroff} and @code{troff} were two separate programs,
7626 the former for TTY output, the latter for everything else.  With GNU
7627 @code{troff}, both programs are merged into one executable, sending
7628 its output to a device driver (@code{grotty} for TTY devices,
7629 @code{grops} for @sc{PostScript}, etc.) which interprets the
7630 intermediate output of @code{gtroff}.  For @acronym{UNIX} @code{troff}
7631 it makes sense to talk about @dfn{Nroff mode} and @dfn{Troff mode}
7632 since the differences are hardcoded.  For GNU @code{troff}, this
7633 distinction is not appropriate because @code{gtroff} simply takes the
7634 information given in the font files for a particular device without
7635 handling requests specially if a TTY output device is used.
7637 Usually, a macro package can be used with all output devices.
7638 Nevertheless, it is sometimes necessary to make a distinction between
7639 TTY and non-TTY devices: @code{gtroff} provides two built-in
7640 conditions @samp{n} and @samp{t} for the @code{if}, @code{ie}, and
7641 @code{while} requests to decide whether @code{gtroff} shall behave
7642 like @code{nroff} or like @code{troff}.
7644 @Defreq {troff, }
7645 @pindex troffrc
7646 @pindex troffrc-end
7647 Make the @samp{t} built-in condition true (and the @samp{n} built-in
7648 condition false) for @code{if}, @code{ie}, and @code{while}
7649 conditional requests.  This is the default if @code{gtroff}
7650 (@emph{not} @code{groff}) is started with the @option{-R} switch to
7651 avoid loading of the start-up files @file{troffrc} and
7652 @file{troffrc-end}.  Without @option{-R}, @code{gtroff} stays in troff
7653 mode if the output device is not a TTY (e.g.@: `ps').
7654 @endDefreq
7656 @Defreq {nroff, }
7657 @pindex tty.tmac
7658 Make the @samp{n} built-in condition true (and the @samp{t} built-in
7659 condition false) for @code{if}, @code{ie}, and @code{while}
7660 conditional requests.  This is the default if @code{gtroff} uses a TTY
7661 output device; the code for switching to nroff mode is in the file
7662 @file{tty.tmac} which is loaded by the start-up file @code{troffrc}.
7663 @endDefreq
7665 @xref{Conditionals and Loops}, for more details on built-in
7666 conditions.
7669 @c =====================================================================
7671 @node Line Layout, Line Control, Troff and Nroff Mode, gtroff Reference
7672 @section Line Layout
7673 @cindex line layout
7674 @cindex layout, line
7676 @cindex dimensions, line
7677 @cindex line dimensions
7678 The following drawing shows the dimensions which @code{gtroff} uses for
7679 placing a line of output onto the page.  They are labeled with the
7680 request which manipulates each dimension.
7682 @Example
7683                 -->| in |<--
7684                    |<-----------ll------------>|
7685               +----+----+----------------------+----+
7686               |    :    :                      :    |
7687               +----+----+----------------------+----+
7688            -->| po |<--
7689               |<--------paper width---------------->|
7690 @endExample
7692 @noindent
7693 These dimensions are:
7695 @ftable @code
7696 @item po
7697 @cindex left margin (@code{po})
7698 @cindex margin, left (@code{po})
7699 @cindex page offset (@code{po})
7700 @cindex offset, page (@code{po})
7701 @dfn{Page offset} -- this is the leftmost position of text on the final
7702 output, defining the @dfn{left margin}.
7704 @item in
7705 @cindex indentation (@code{in})
7706 @cindex line indentation (@code{in})
7707 @dfn{Indentation} -- this is the distance from the left margin where
7708 text is printed.
7710 @item ll
7711 @cindex line length (@code{ll})
7712 @cindex length of line (@code{ll})
7713 @dfn{Line length} -- this is the distance from the left margin to right
7714 margin.
7715 @end ftable
7717 A simple demonstration:
7719 @Example
7720 .ll 3i
7721 This is text without indentation.
7722 The line length has been set to 3\~inch.
7723 .in +.5i
7724 .ll -.5i
7725 Now the left and right margins are both increased.
7728 Calling .in and .ll without parameters restore
7729 the previous values.
7730 @endExample
7732 Result:
7734 @Example
7735 This  is text without indenta-
7736 tion.   The  line  length  has
7737 been set to 3 inch.
7738      Now   the  left  and
7739      right  margins   are
7740      both increased.
7741 Calling  .in  and  .ll without
7742 parameters restore the  previ-
7743 ous values.
7744 @endExample
7746 @DefreqList {po, [@Var{offset}]}
7747 @DefreqItem {po, @t{+}@Var{offset}}
7748 @DefreqItem {po, @t{-}@Var{offset}}
7749 @DefregListEnd {.o}
7750 @pindex troffrc
7751 Set horizontal page offset to @var{offset} (or increment or decrement
7752 the current value by @var{offset}).  Note that this request does not
7753 cause a break, so changing the page offset in the middle of text being
7754 filled may not yield the expected result.  The initial value is
7755 1@dmn{i}.  For TTY output devices, it is set to 0 in the startup file
7756 @file{troffrc}; the default scaling indicator is @samp{m} (and
7757 not @samp{v} as incorrectly documented in the original
7758 @acronym{UNIX} troff manual).
7760 The current page offset can be found in the read-only number register
7761 @samp{.o}.
7763 If @code{po} is called without an argument, the page offset is reset to
7764 the previous value before the last call to @code{po}.
7766 @Example
7767 .po 3i
7768 \n[.o]
7769     @result{} 720
7770 .po -1i
7771 \n[.o]
7772     @result{} 480
7774 \n[.o]
7775     @result{} 720
7776 @endExample
7777 @endDefreq
7779 @DefreqList {in, [@Var{indent}]}
7780 @DefreqItem {in, @t{+}@Var{indent}}
7781 @DefreqItem {in, @t{-}@Var{indent}}
7782 @DefregListEnd {.i}
7783 Set indentation to @var{indent} (or increment or decrement the
7784 current value by @var{indent}).  This request causes a break.
7785 Initially, there is no indentation.
7787 If @code{in} is called without an argument, the indentation is reset to
7788 the previous value before the last call to @code{in}.  The default
7789 scaling indicator is @samp{m}.
7791 The indentation is associated with the current environment
7792 (@pxref{Environments}).
7794 If a negative indentation value is specified (which is not allowed),
7795 @code{gtroff} emits a warning of type @samp{range} and sets the
7796 indentation to zero.
7798 The effect of @code{in} is delayed until a partially collected line (if
7799 it exists) is output.  A temporary indent value is reset to zero also.
7801 The current indentation (as set by @code{in}) can be found in the
7802 read-only number register @samp{.i}.
7803 @endDefreq
7805 @DefreqList {ti, offset}
7806 @DefreqItem {ti, @t{+}@Var{offset}}
7807 @DefreqItem {ti, @t{-}@Var{offset}}
7808 @DefregListEnd {.in}
7809 Temporarily indent the next output line by @var{offset}.  If an
7810 increment or decrement value is specified, adjust the temporary
7811 indentation relative to the value set by the @code{in} request.
7813 This request causes a break; its value is associated with the current
7814 environment (@pxref{Environments}).  The default scaling indicator
7815 is @samp{m}.  A call of @code{ti} without an argument is ignored.
7817 If the total indentation value is negative (which is not allowed),
7818 @code{gtroff} emits a warning of type @samp{range} and sets the
7819 temporary indentation to zero.  `Total indentation' is either
7820 @var{offset} if specified as an absolute value, or the temporary plus
7821 normal indentation, if @var{offset} is given as a relative value.
7823 The effect of @code{ti} is delayed until a partially collected line (if
7824 it exists) is output.
7826 The read-only number register @code{.in} is the indentation that applies
7827 to the current output line.
7829 The difference between @code{.i} and @code{.in} is that the latter takes
7830 into account whether a partially collected line still uses the old
7831 indentation value or a temporary indentation value is active.
7832 @endDefreq
7834 @DefreqList {ll, [@Var{length}]}
7835 @DefreqItem {ll, @t{+}@Var{length}}
7836 @DefreqItem {ll, @t{-}@Var{length}}
7837 @DefregItem {.l}
7838 @DefregListEnd {.ll}
7839 Set the line length to @var{length} (or increment or decrement the
7840 current value by @var{length}).  Initially, the line length is set to
7841 6.5@dmn{i}.  The effect of @code{ll} is delayed until a partially
7842 collected line (if it exists) is output.  The default scaling
7843 indicator is @samp{m}.
7845 If @code{ll} is called without an argument, the line length is reset to
7846 the previous value before the last call to @code{ll}.  If a negative
7847 line length is specified (which is not allowed), @code{gtroff} emits a
7848 warning of type @samp{range} and sets the line length to zero.
7850 The line length is associated with the current environment
7851 (@pxref{Environments}).
7853 @cindex line length register (@code{.l})
7854 The current line length (as set by @code{ll}) can be found in the
7855 read-only number register @samp{.l}.  The read-only number register
7856 @code{.ll} is the line length that applies to the current output line.
7858 Similar to @code{.i} and @code{.in}, the difference between @code{.l}
7859 and @code{.ll} is that the latter takes into account whether a partially
7860 collected line still uses the old line length value.
7861 @endDefreq
7864 @c =====================================================================
7866 @node Line Control, Page Layout, Line Layout, gtroff Reference
7867 @section Line Control
7868 @cindex line control
7869 @cindex control, line
7871 It is important to understand how @code{gtroff} handles input and output
7872 lines.
7874 Many escapes use positioning relative to the input line.  For example,
7875 this
7877 @Example
7878 This is a \h'|1.2i'test.
7880 This is a
7881 \h'|1.2i'test.
7882 @endExample
7884 @noindent
7885 produces
7887 @Example
7888 This is a   test.
7890 This is a             test.
7891 @endExample
7893 The main usage of this feature is to define macros which act exactly
7894 at the place where called.
7896 @Example
7897 .\" A simple macro to underline a word
7898 .de underline
7899 .  nop \\$1\l'|0\[ul]'
7901 @endExample
7903 @noindent
7904 In the above example, @samp{|0} specifies a negative distance from the
7905 current position (at the end of the just emitted argument @code{\$1}) back
7906 to the beginning of the input line.  Thus, the @samp{\l} escape draws a
7907 line from right to left.
7909 @cindex input line continuation (@code{\})
7910 @cindex line, input, continuation (@code{\})
7911 @cindex continuation, input line (@code{\})
7912 @cindex output line, continuation (@code{\c})
7913 @cindex line, output, continuation (@code{\c})
7914 @cindex continuation, output line (@code{\c})
7915 @cindex interrupted line
7916 @cindex line, interrupted
7917 @code{gtroff} makes a difference between input and output line
7918 continuation; the latter is also called @dfn{interrupting} a line.
7920 @DefescList {\\@key{RET}, , ,}
7921 @DefescItem {\\c, , ,}
7922 @DefregListEnd{.int}
7923 Continue a line.  @code{\@key{RET}} (this is a backslash at the end
7924 of a line immediately followed by a newline) works on the input level,
7925 suppressing the effects of the following newline in the input.
7927 @Example
7928 This is a \
7929 .test
7930     @result{} This is a .test
7931 @endExample
7933 The @samp{|} operator is also affected.
7935 @cindex @code{\R}, after @code{\c}
7936 @code{\c} works on the output level.  Anything after this escape on the
7937 same line is ignored, except @code{\R} which works as usual.  Anything
7938 before @code{\c} on the same line will be appended to the current partial
7939 output line.  The next non-command line after an interrupted line counts
7940 as a new input line.
7942 The visual results depend on whether no-fill mode is active.
7944 @itemize @bullet
7945 @item
7946 @cindex @code{\c}, and no-fill mode
7947 @cindex no-fill mode, and @code{\c}
7948 @cindex mode, no-fill, and @code{\c}
7949 If no-fill mode is active (using the @code{nf} request), the next input
7950 text line after @code{\c} will be handled as a continuation of the same
7951 input text line.
7953 @Example
7955 This is a \c
7956 test.
7957     @result{} This is a test.
7958 @endExample
7960 @item
7961 @cindex @code{\c}, and fill mode
7962 @cindex fill mode, and @code{\c}
7963 @cindex mode, fill, and @code{\c}
7964 If fill mode is active (using the @code{fi} request), a word interrupted
7965 with @code{\c} will be continued with the text on the next input text line,
7966 without an intervening space.
7968 @Example
7969 This is a te\c
7971     @result{} This is a test.
7972 @endExample
7973 @end itemize
7975 Note that an intervening control line which causes a break is stronger
7976 than @code{\c}, flushing out the current partial line in the usual way.
7978 @cindex interrupted line register (@code{.int})
7979 The @code{.int} register contains a positive value
7980 if the last output line was interrupted with @code{\c}; this is
7981 associated with the current environment (@pxref{Environments}).
7982 @endDefesc
7984 @c =====================================================================
7986 @node Page Layout, Page Control, Line Control, gtroff Reference
7987 @section Page Layout
7988 @cindex page layout
7989 @cindex layout, page
7991 @code{gtroff} provides some very primitive operations for controlling
7992 page layout.
7994 @DefreqList {pl, [@Var{length}]}
7995 @DefreqItem {pl, @t{+}@Var{length}}
7996 @DefreqItem {pl, @t{-}@Var{length}}
7997 @DefregListEnd {.p}
7998 @cindex page length (@code{pl})
7999 @cindex length of page (@code{pl})
8000 Set the @dfn{page length} to @var{length} (or increment or decrement
8001 the current value by @var{length}).  This is the length of the
8002 physical output page.  The default scaling indicator is @samp{v}.
8004 @cindex page length register (@code{.p})
8005 The current setting can be found in the read-only number register
8006 @samp{.p}.
8008 @cindex top margin
8009 @cindex margin, top
8010 @cindex bottom margin
8011 @cindex margin, bottom
8012 Note that this only specifies the size of the page, not the top and
8013 bottom margins.  Those are not set by @code{gtroff} directly.
8014 @xref{Traps}, for further information on how to do this.
8016 Negative @code{pl} values are possible also, but not very useful: No
8017 trap is sprung, and each line is output on a single page (thus
8018 suppressing all vertical spacing).
8020 If no argument or an invalid argument is given, @code{pl} sets the page
8021 length to 11@dmn{i}.
8022 @endDefreq
8024 @cindex headers
8025 @cindex footers
8026 @cindex titles
8027 @code{gtroff} provides several operations which help in setting up top
8028 and bottom titles (or headers and footers).
8030 @Defreq {tl, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}}
8031 @cindex title line (@code{tl})
8032 @cindex three-part title (@code{tl})
8033 @cindex page number character (@code{%})
8034 Print a @dfn{title line}.  It consists of three parts: a left
8035 justified portion, a centered portion, and a right justified portion.
8036 The argument separator @samp{'} can be replaced with any character not
8037 occurring in the title line.  The @samp{%} character is replaced with
8038 the current page number.  This character can be changed with the
8039 @code{pc} request (see below).
8041 Without argument, @code{tl} is ignored.
8043 Some notes:
8045 @itemize @bullet
8046 @item
8047 A title line is not restricted to the top or bottom of a page.
8049 @item
8050 @code{tl} prints the title line immediately, ignoring a partially filled
8051 line (which stays untouched).
8053 @item
8054 It is not an error to omit closing delimiters.  For example,
8055 @w{@samp{.tl /foo}} is equivalent to @w{@samp{.tl /foo///}}: It prints a
8056 title line with the left justified word @samp{foo}; the centered and
8057 right justfied parts are empty.
8059 @item
8060 @code{tl} accepts the same parameter delimiting characters as the
8061 @code{\A} escape; see @ref{Escapes}.
8062 @end itemize
8063 @endDefreq
8065 @DefreqList {lt, [@Var{length}]}
8066 @DefreqItem {lt, @t{+}@Var{length}}
8067 @DefreqItem {lt, @t{-}@Var{length}}
8068 @DefregListEnd {.lt}
8069 @cindex length of title line (@code{lt})
8070 @cindex title line, length (@code{lt})
8071 @cindex title line length register (@code{.lt})
8072 The title line is printed using its own line length, which is
8073 specified (or incremented or decremented) with the @code{lt} request.
8074 Initially, the title line length is set to 6.5@dmn{i}.  If a negative
8075 line length is specified (which is not allowed), @code{gtroff} emits a
8076 warning of type @samp{range} and sets the title line length to zero.
8077 The default scaling indicator is @samp{m}.  If @code{lt} is called
8078 without an argument, the title length is reset to the previous value
8079 before the last call to @code{lt}.
8081 The current setting of this is available in the @code{.lt} read-only
8082 number register; it is associated with the current environment
8083 (@pxref{Environments}).
8084 @endDefreq
8086 @DefreqList {pn, page}
8087 @DefreqItem {pn, @t{+}@Var{page}}
8088 @DefreqItem {pn, @t{-}@Var{page}}
8089 @DefregListEnd {.pn}
8090 @cindex page number (@code{pn})
8091 @cindex number, page (@code{pn})
8092 Change (increase or decrease) the page number of the @emph{next} page.
8093 The only argument is the page number; the request is ignored without a
8094 parameter.
8096 The read-only number register @code{.pn} contains the number of the next
8097 page: either the value set by a @code{pn} request, or the number of the
8098 current page plus@tie{}1.
8099 @endDefreq
8101 @Defreq {pc, [@Var{char}]}
8102 @cindex changing the page number character (@code{pc})
8103 @cindex page number character, changing (@code{pc})
8104 @vindex %
8105 Change the page number character (used by the @code{tl} request) to a
8106 different character.  With no argument, this mechanism is disabled.
8107 Note that this doesn't affect the number register@tie{}@code{%}.
8108 @endDefreq
8110 @xref{Traps}.
8113 @c =====================================================================
8115 @node Page Control, Fonts and Symbols, Page Layout, gtroff Reference
8116 @section Page Control
8117 @cindex page control
8118 @cindex control, page
8120 @DefreqList {bp, [@Var{page}]}
8121 @DefreqItem {bp, @t{+}@Var{page}}
8122 @DefreqItem {bp, @t{-}@Var{page}}
8123 @DefregListEnd {%}
8124 @cindex new page (@code{bp})
8125 @cindex page, new (@code{bp})
8126 Stop processing the current page and move to the next page.  This
8127 request causes a break.  It can also take an argument to set
8128 (increase, decrease) the page number of the next page (which actually
8129 becomes the current page after @code{bp} has finished).  The
8130 difference between @code{bp} and @code{pn} is that @code{pn} does not
8131 cause a break or actually eject a page.  @xref{Page Layout}.
8133 @Example
8134 .de newpage                         \" define macro
8135 'bp                                 \" begin page
8136 'sp .5i                             \" vertical space
8137 .tl 'left top'center top'right top' \" title
8138 'sp .3i                             \" vertical space
8139 ..                                  \" end macro
8140 @endExample
8142 @cindex @code{bp} request, and top-level diversion
8143 @cindex top-level diversion, and @code{bp}
8144 @cindex diversion, top-level, and @code{bp}
8145 @code{bp} has no effect if not called within the top-level diversion
8146 (@pxref{Diversions}).
8148 @cindex page number register (@code{%})
8149 @cindex current page number (@code{%})
8150 The read-write register@tie{}@code{%} holds the current page number.
8152 The number register @code{.pe} is set to@tie{}1 while @code{bp} is
8153 active.  @xref{Page Location Traps}.
8154 @endDefreq
8156 @Defreq {ne, [@Var{space}]}
8157 @cindex orphan lines, preventing with @code{ne}
8158 @cindex conditional page break (@code{ne})
8159 @cindex page break, conditional (@code{ne})
8160 It is often necessary to force a certain amount of space before a new
8161 page occurs.  This is most useful to make sure that there is not a
8162 single @dfn{orphan} line left at the bottom of a page.  The @code{ne}
8163 request ensures that there is a certain distance, specified by the
8164 first argument, before the next page is triggered (see @ref{Traps},
8165 for further information).  The default scaling indicator for @code{ne}
8166 is @samp{v}; the default value of @var{space} is@tie{}1@dmn{v} if no
8167 argument is given.
8169 For example, to make sure that no fewer than 2@tie{}lines get orphaned,
8170 do the following before each paragraph:
8172 @Example
8173 .ne 2
8174 text text text
8175 @endExample
8177 @code{ne} will then automatically cause a page break if there is space
8178 for one line only.
8179 @endDefreq
8181 @DefreqList {sv, [@Var{space}]}
8182 @DefreqListEnd {os, }
8183 @cindex @code{ne} request, comparison with @code{sv}
8184 @code{sv} is similar to the @code{ne} request; it reserves the
8185 specified amount of vertical space.  If the desired amount of space
8186 exists before the next trap (or the bottom page boundary if no trap is
8187 set), the space is output immediately (ignoring a partially filled line
8188 which stays untouched).  If there is not enough space, it is stored for
8189 later output via the @code{os} request.  The default value is@tie{}1@dmn{v}
8190 if no argument is given; the default scaling indicator is @samp{v}.
8192 @cindex @code{sv} request, and no-space mode
8193 @cindex @code{os} request, and no-space mode
8194 Both @code{sv} and @code{os} ignore no-space mode.  While the @code{sv}
8195 request allows negative values for @var{space}, @code{os} will ignore
8196 them.
8197 @endDefreq
8199 @Defreg {nl}
8200 @cindex current vertical position (@code{nl})
8201 @cindex vertical position, current (@code{nl})
8202 @cindex position, vertical, current (@code{nl})
8203 This register contains the current vertical position.  If the vertical
8204 position is zero and the top of page transition hasn't happened yet,
8205 @code{nl} is set to negative value.  @code{gtroff} itself does this at
8206 the very beginning of a document before anything has been printed, but
8207 the main usage is to plant a header trap on a page if this page has
8208 already started.
8210 Consider the following:
8212 @Example
8213 .de xxx
8214 .  sp
8215 .  tl ''Header''
8216 .  sp
8219 First page.
8221 .wh 0 xxx
8222 .nr nl (-1)
8223 Second page.
8224 @endExample
8226 @noindent
8227 Result:
8229 @Example
8230 First page.
8234                              Header
8236 Second page.
8239 @endExample
8241 @noindent
8242 Without resetting @code{nl} to a negative value, the just planted trap
8243 would be active beginning with the @emph{next} page, not the current
8244 one.
8246 @xref{Diversions}, for a comparison with the @code{.h} and @code{.d}
8247 registers.
8248 @endDefreg
8250 @c =====================================================================
8252 @node Fonts and Symbols, Sizes, Page Control, gtroff Reference
8253 @section Fonts and Symbols
8254 @cindex fonts
8256 @code{gtroff} can switch fonts at any point in the text.
8258 The basic set of fonts is @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
8259 These are Times Roman, Italic, Bold, and Bold Italic.  For non-TTY
8260 devices, there is also at least one symbol font which contains various
8261 special symbols (Greek, mathematics).
8263 @menu
8264 * Changing Fonts::
8265 * Font Families::
8266 * Font Positions::
8267 * Using Symbols::
8268 * Special Fonts::
8269 * Artificial Fonts::
8270 * Ligatures and Kerning::
8271 @end menu
8273 @c ---------------------------------------------------------------------
8275 @node Changing Fonts, Font Families, Fonts and Symbols, Fonts and Symbols
8276 @subsection Changing Fonts
8277 @cindex fonts
8279 @DefreqList {ft, [@Var{font}]}
8280 @DefescItem {\\f, , f, }
8281 @DefescItem {\\f, @lparen{}, fn, }
8282 @DefescItem {\\f, @lbrack{}, font, @rbrack}
8283 @DefregListEnd {.sty}
8284 @cindex changing fonts (@code{ft}, @code{\f})
8285 @cindex fonts, changing (@code{ft}, @code{\f})
8286 @cindex @code{sty} request, and changing fonts
8287 @cindex @code{fam} request, and changing fonts
8288 @cindex @code{\F}, and changing fonts
8289 @kindex styles
8290 @kindex family
8291 @pindex DESC
8292 The @code{ft} request and the @code{\f} escape change the current font
8293 to @var{font} (one-character name@tie{}@var{f}, two-character name
8294 @var{fn}).
8296 If @var{font} is a style name (as set with the @code{sty} request or
8297 with the @code{styles} command in the @file{DESC} file), use it within
8298 the current font family (as set with the @code{fam} request, @code{\F}
8299 escape, or with the @code{family} command in the @file{DESC} file).
8301 @cindex previous font (@code{ft}, @code{\f[]}, @code{\fP})
8302 @cindex font, previous (@code{ft}, @code{\f[]}, @code{\fP})
8303 With no argument or using @samp{P} as an argument, @code{.ft} switches
8304 to the previous font.  Use @code{\f[]} to do this with the escape.  The
8305 old syntax forms @code{\fP} or @code{\f[P]} are also supported.
8307 Fonts are generally specified as upper-case strings, which are usually
8308 1@tie{}to 4 characters representing an abbreviation or acronym of the
8309 font name.  This is no limitation, just a convention.
8311 The example below produces two identical lines.
8313 @Example
8314 eggs, bacon,
8315 .ft B
8316 spam
8318 and sausage.
8320 eggs, bacon, \fBspam\fP and sausage.
8321 @endExample
8323 Note that @code{\f} doesn't produce an input token in @code{gtroff}.
8324 As a consequence, it can be used in requests like @code{mc} (which
8325 expects a single character as an argument) to change the font on
8326 the fly:
8328 @Example
8329 .mc \f[I]x\f[]
8330 @endExample
8332 The current style name is available in the read-only number register
8333 @samp{.sty} (this is a string-valued register); if the current font
8334 isn't a style, the empty string is returned.  It is associated with
8335 the current environment.
8337 @xref{Font Positions}, for an alternative syntax.
8338 @endDefreq
8340 @Defreq {ftr, f [@Var{g}]}
8341 @cindex @code{ft} request, and font translations
8342 @cindex @code{ul} request, and font translations
8343 @cindex @code{bd} request, and font translations
8344 @cindex @code{\f}, and font translations
8345 @cindex @code{cs} request, and font translations
8346 @cindex @code{tkf} request, and font translations
8347 @cindex @code{special} request, and font translations
8348 @cindex @code{fspecial} request, and font translations
8349 @cindex @code{fp} request, and font translations
8350 @cindex @code{sty} request, and font translations
8351 @cindex @code{if} request, and font translations
8352 @cindex @code{ie} request, and font translations
8353 @cindex @code{while} request, and font translations
8354 Translate font@tie{}@var{f} to font@tie{}@var{g}.  Whenever a font
8355 named@tie{}@var{f} is referred to in a @code{\f} escape sequence,
8356 in the @code{F} and @code{S} conditional operators, or in the
8357 @code{ft}, @code{ul}, @code{bd}, @code{cs}, @code{tkf},
8358 @code{special}, @code{fspecial}, @code{fp}, or @code{sty} requests,
8359 font@tie{}@var{g} is used.  If @var{g} is missing or equal to@tie{}@var{f}
8360 the translation is undone.
8361 @endDefreq
8363 @c ---------------------------------------------------------------------
8365 @node Font Families, Font Positions, Changing Fonts, Fonts and Symbols
8366 @subsection Font Families
8367 @cindex font families
8368 @cindex families, font
8369 @cindex font styles
8370 @cindex styles, font
8372 Due to the variety of fonts available, @code{gtroff} has added the
8373 concept of @dfn{font families} and @dfn{font styles}.  The fonts are
8374 specified as the concatenation of the font family and style.  Specifying
8375 a font without the family part causes @code{gtroff} to use that style of
8376 the current family.
8378 @cindex PostScript fonts
8379 @cindex fonts, PostScript
8380 Currently, fonts for the devices @option{-Tps}, @option{-Tdvi},
8381 @option{-Tlj4}, @option{-Tlbp}, and the X11 fonts are set up to this
8382 mechanism.  By default, @code{gtroff} uses the Times family with the four
8383 styles @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
8385 This way, it is possible to use the basic four fonts and to select a
8386 different font family on the command line (@pxref{Groff Options}).
8388 @DefreqList {fam, [@Var{family}]}
8389 @DefregItem {.fam}
8390 @DefescItem {\\F, , f, }
8391 @DefescItem {\\F, @lparen{}, fm, }
8392 @DefescItem {\\F, @lbrack{}, family, @rbrack}
8393 @DefregListEnd {.fn}
8394 @cindex changing font family (@code{fam}, @code{\F})
8395 @cindex font family, changing (@code{fam}, @code{\F})
8396 Switch font family to @var{family} (one-character name@tie{}@var{f},
8397 two-character name @var{fm}).  If no argument is given, switch
8398 back to the previous font family.  Use @code{\F[]} to do this with the
8399 escape.  Note that @code{\FP} doesn't work; it selects font family
8400 @samp{P} instead.
8402 The value at start-up is @samp{T}.
8403 The current font family is available in the read-only number register
8404 @samp{.fam} (this is a string-valued register); it is associated with
8405 the current environment.
8407 @Example
8408 spam,
8409 .fam H    \" helvetica family
8410 spam,     \" used font is family H + style R = HR
8411 .ft B     \" family H + style B = font HB
8412 spam,
8413 .fam T    \" times family
8414 spam,     \" used font is family T + style B = TB
8415 .ft AR    \" font AR (not a style)
8416 baked beans,
8417 .ft R     \" family T + style R = font TR
8418 and spam.
8419 @endExample
8421 Note that @code{\F} doesn't produce an input token in @code{gtroff}.
8422 As a consequence, it can be used in requests like @code{mc} (which
8423 expects a single character as an argument) to change the font family on
8424 the fly:
8426 @Example
8427 .mc \F[P]x\F[]
8428 @endExample
8430 The @samp{.fn} register contains the current @dfn{real font name}
8431 of the current font.
8432 This is a string-valued register.
8433 If the current font is a style, the value of @code{\n[.fn]}
8434 is the proper concatenation of family and style name.
8435 @endDefreq
8437 @Defreq {sty, n style}
8438 @cindex changing font style (@code{sty})
8439 @cindex font style, changing (@code{sty})
8440 @cindex @code{cs} request, and font styles
8441 @cindex @code{bd} request, and font styles
8442 @cindex @code{tkf} request, and font styles
8443 @cindex @code{uf} request, and font styles
8444 @cindex @code{fspecial} request, and font styles
8445 Associate @var{style} with font position@tie{}@var{n}.  A font position
8446 can be associated either with a font or with a style.  The current
8447 font is the index of a font position and so is also either a font or a
8448 style.  If it is a style, the font that is actually used is the font
8449 which name is the concatenation of the name of the current
8450 family and the name of the current style.  For example, if the current
8451 font is@tie{}1 and font position@tie{}1 is associated with style
8452 @samp{R} and the current font family is @samp{T}, then font
8453 @samp{TR} will be used.  If the current font is not a style, then the
8454 current family is ignored.  If the requests @code{cs}, @code{bd},
8455 @code{tkf}, @code{uf}, or @code{fspecial} are applied to a style,
8456 they will instead be applied to the member of the current family
8457 corresponding to that style.
8459 @var{n}@tie{}must be a non-negative integer value.
8461 @pindex DESC
8462 @kindex styles
8463 The default family can be set with the @option{-f} option
8464 (@pxref{Groff Options}).  The @code{styles} command in the @file{DESC}
8465 file controls which font positions (if any) are initially associated
8466 with styles rather than fonts.  For example, the default setting for
8467 @sc{PostScript} fonts
8469 @Example
8470 styles R I B BI
8471 @endExample
8473 @noindent
8474 is equivalent to
8476 @Example
8477 .sty 1 R
8478 .sty 2 I
8479 .sty 3 B
8480 .sty 4 BI
8481 @endExample
8483 @code{fam} and @code{\F} always check whether the current font position
8484 is valid; this can give surprising results if the current font position is
8485 associated with a style.
8487 In the following example, we want to access the @sc{PostScript} font
8488 @code{FooBar} from the font family @code{Foo}:
8490 @Example
8491 .sty \n[.fp] Bar
8492 .fam Foo
8493     @result{} warning: can't find font `FooR'
8494 @endExample
8496 @noindent
8497 The default font position at start-up is@tie{}1; for the
8498 @sc{PostScript} device, this is associated with style @samp{R}, so
8499 @code{gtroff} tries to open @code{FooR}.
8501 A solution to this problem is to use a dummy font like the following:
8503 @Example
8504 .fp 0 dummy TR    \" set up dummy font at position 0
8505 .sty \n[.fp] Bar  \" register style `Bar'
8506 .ft 0             \" switch to font at position 0
8507 .fam Foo          \" activate family `Foo'
8508 .ft Bar           \" switch to font `FooBar'
8509 @endExample
8511 @xref{Font Positions}.
8512 @endDefreq
8514 @c ---------------------------------------------------------------------
8516 @node Font Positions, Using Symbols, Font Families, Fonts and Symbols
8517 @subsection Font Positions
8518 @cindex font positions
8519 @cindex positions, font
8521 For the sake of old phototypesetters and compatibility with old versions
8522 of @code{troff}, @code{gtroff} has the concept of font @dfn{positions},
8523 on which various fonts are mounted.
8525 @DefreqList {fp, pos font [@Var{external-name}]}
8526 @DefregItem {.f}
8527 @DefregListEnd {.fp}
8528 @cindex mounting font (@code{fp})
8529 @cindex font, mounting (@code{fp})
8530 Mount font @var{font} at position @var{pos} (which must be a
8531 non-negative integer).  This numeric position can then be referred to
8532 with font changing commands.  When @code{gtroff} starts it is using
8533 font position@tie{}1 (which must exist; position@tie{}0 is unused
8534 usually at start-up).
8536 @cindex font position register (@code{.f})
8537 The current font in use, as a font position, is available in the
8538 read-only number register @samp{.f}.  This can be useful to remember the
8539 current font for later recall.  It is associated with the current
8540 environment (@pxref{Environments}).
8542 @Example
8543 .nr save-font \n[.f]
8544 .ft B
8545 ... text text text ...
8546 .ft \n[save-font]
8547 @endExample
8549 @cindex next free font position register (@code{.fp})
8550 The number of the next free font position is available in the read-only
8551 number register @samp{.fp}.  This is useful when mounting a new font,
8552 like so:
8554 @Example
8555 .fp \n[.fp] NEATOFONT
8556 @endExample
8558 @pindex DESC@r{, and font mounting}
8559 Fonts not listed in the @file{DESC} file are automatically mounted on
8560 the next available font position when they are referenced.  If a font
8561 is to be mounted explicitly with the @code{fp} request on an unused
8562 font position, it should be mounted on the first unused font position,
8563 which can be found in the @code{.fp} register.  Although @code{gtroff}
8564 does not enforce this strictly, it is not allowed to mount a font at a
8565 position whose number is much greater (approx.@: 1000 positions) than
8566 that of any currently used position.
8568 The @code{fp} request has an optional third argument.  This argument
8569 gives the external name of the font, which is used for finding the font
8570 description file.  The second argument gives the internal name of the
8571 font which is used to refer to the font in @code{gtroff} after it has
8572 been mounted.  If there is no third argument then the internal name is
8573 used as the external name.  This feature makes it possible to use
8574 fonts with long names in compatibility mode.
8575 @endDefreq
8577 Both the @code{ft} request and the @code{\f} escape have alternative
8578 syntax forms to access font positions.
8580 @DefreqList {ft, nnn}
8581 @DefescItem {\\f, , n, }
8582 @DefescItem {\\f, @lparen{}, nn, }
8583 @DefescListEnd {\\f, @lbrack{}, nnn, @rbrack}
8584 @cindex changing font position (@code{\f})
8585 @cindex font position, changing (@code{\f})
8586 @cindex @code{sty} request, and font positions
8587 @cindex @code{fam} request, and font positions
8588 @cindex @code{\F}, and font positions
8589 @kindex styles
8590 @kindex family
8591 @pindex DESC
8592 Change the current font position to @var{nnn} (one-digit
8593 position@tie{}@var{n}, two-digit position @var{nn}), which must be a
8594 non-negative integer.
8596 If @var{nnn} is associated with a style (as set with the @code{sty}
8597 request or with the @code{styles} command in the @file{DESC} file), use
8598 it within the current font family (as set with the @code{fam} request,
8599 the @code{\F} escape, or with the @code{family} command in the @file{DESC}
8600 file).
8602 @Example
8603 this is font 1
8604 .ft 2
8605 this is font 2
8606 .ft                   \" switch back to font 1
8607 .ft 3
8608 this is font 3
8610 this is font 1 again
8611 @endExample
8613 @xref{Changing Fonts}, for the standard syntax form.
8614 @endDefreq
8616 @c ---------------------------------------------------------------------
8618 @node Using Symbols, Special Fonts, Font Positions, Fonts and Symbols
8619 @subsection Using Symbols
8620 @cindex using symbols
8621 @cindex symbols, using
8623 @cindex glyph
8624 @cindex character
8625 @cindex ligature
8626 A @dfn{glyph} is a graphical representation of a @dfn{character}.
8627 While a character is an abstract entity containing semantic
8628 information, a glyph is something which can be actually seen on screen
8629 or paper.  It is possible that a character has multiple glyph
8630 representation forms (for example, the character `A' can be either
8631 written in a roman or an italic font, yielding two different glyphs);
8632 sometimes more than one character maps to a single glyph (this is a
8633 @dfn{ligature} -- the most common is `fi').
8635 @cindex symbol
8636 @cindex special fonts
8637 @kindex fonts
8638 @pindex DESC
8639 @cindex @code{special} request, and glyph search order
8640 @cindex @code{fspecial} request, and glyph search order
8641 A @dfn{symbol} is simply a named glyph.  Within @code{gtroff}, all
8642 glyph names of a particular font are defined in its font file.  If the
8643 user requests a glyph not available in this font, @code{gtroff} looks
8644 up an ordered list of @dfn{special fonts}.  By default, the
8645 @sc{PostScript} output device supports the two special fonts @samp{SS}
8646 (slanted symbols) and @samp{S} (symbols) (the former is looked up
8647 before the latter).  Other output devices use different names for
8648 special fonts.  Fonts mounted with the @code{fonts} keyword in the
8649 @file{DESC} file are globally available.  To install additional
8650 special fonts locally (i.e.@: for a particular font), use the
8651 @code{fspecial} request.
8653 Here the exact rules how @code{gtroff} searches a given symbol:
8655 @itemize @bullet
8656 @item
8657 If the symbol has been defined with the @code{char} request, use it.
8658 This hides a symbol with the same name in the current font.
8660 @item
8661 Check the current font.
8663 @item
8664 If the symbol has been defined with the @code{fchar} request, use it.
8666 @item
8667 Check whether the current font has a font-specific list of special fonts;
8668 test all fonts in the order of appearance in the last @code{fspecial}
8669 call if appropriate.
8671 @item
8672 If the symbol has been defined with the @code{fschar} request for the
8673 current font, use it.
8675 @item
8676 Check all fonts in the order of appearance in the last @code{special}
8677 call.
8679 @item
8680 If the symbol has been defined with the @code{schar} request, use it.
8682 @item
8683 As a last resort, consult all fonts loaded up to now for special fonts
8684 and check them, starting with the lowest font number.  Note that this can
8685 sometimes lead to surprising results since the @code{fonts} line in the
8686 @file{DESC} file often contains empty positions which are filled later
8687 on.  For example, consider the following:
8689 @Example
8690 fonts 3 0 0 FOO
8691 @endExample
8693 @noindent
8694 This mounts font @code{foo} at font position@tie{}3.  We assume that
8695 @code{FOO} is a special font, containing glyph @code{foo},
8696 and that no font has been loaded yet.  The line
8698 @Example
8699 .fspecial BAR BAZ
8700 @endExample
8702 @noindent
8703 makes font @code{BAZ} special only if font @code{BAR} is active.  We
8704 further assume that @code{BAZ} is really a special font, i.e., the font
8705 description file contains the @code{special} keyword, and that it
8706 also contains glyph @code{foo} with a special shape fitting to font
8707 @code{BAR}.  After executing @code{fspecial}, font @code{BAR} is loaded at
8708 font position@tie{}1, and @code{BAZ} at position@tie{}2.
8710 We now switch to a new font @code{XXX}, trying to access glyph @code{foo}
8711 which is assumed to be missing.  There are neither font-specific special
8712 fonts for @code{XXX} nor any other fonts made special with the
8713 @code{special} request, so @code{gtroff} starts the search for special
8714 fonts in the list of already mounted fonts, with increasing font
8715 positions.  Consequently, it finds @code{BAZ} before @code{FOO} even for
8716 @code{XXX} which is not the intended behaviour.
8717 @end itemize
8719 @xref{Font Files}, and @ref{Special Fonts}, for more details.
8721 @cindex list of available glyphs (@cite{groff_char(7)} man page)
8722 @cindex available glyphs, list (@cite{groff_char(7)} man page)
8723 @cindex glyphs, available, list (@cite{groff_char(7)} man page)
8724 The list of available symbols is device dependent; see the
8725 @cite{groff_char(7)} man page for a complete list of all glyphs.  For
8726 example, say
8728 @Example
8729 man -Tdvi groff_char > groff_char.dvi
8730 @endExample
8732 @noindent
8733 for a list using the default DVI fonts (not all versions of the
8734 @code{man} program support the @option{-T} option).  If you want to
8735 use an additional macro package to change the used fonts, @code{groff}
8736 must be called directly:
8738 @Example
8739 groff -Tdvi -mec -man groff_char.7 > groff_char.dvi
8740 @endExample
8742 @cindex composite glyph names
8743 @cindex glyph names, composite
8744 @cindex groff glyph list (GGL)
8745 @cindex GGL (groff glyph list)
8746 @cindex adobe glyph list (AGL)
8747 @cindex AGL (adobe glyph list)
8748 Glyph names not listed in groff_char(7) are derived algorithmically,
8749 using a simplified version of the Adobe Glyph List (AGL) algorithm
8750 which is described in
8751 @uref{http://partners.adobe.com@//asn@//tech@//type@//unicodegn.jsp}.
8752 The (frozen) set of glyph names which can't be derived algorithmically
8753 is called @dfn{groff glyph list (GGL)}.
8755 @itemize @bullet
8756 @item
8757 A glyph for Unicode character U+@var{XXXX}[@var{X}[@var{X}]] which is
8758 not a composite character will be named
8759 @code{u@var{XXXX}@r{[}@var{X}@r{[}@var{X}@r{]]}}.  @var{X} must be an
8760 uppercase hexadecimal digit.  Examples: @code{u1234}, @code{u008E},
8761 @code{u12DB8}.  The largest Unicode value is 0x10FFFF.  There must be at
8762 least four @code{X} digits; if necessary, add leading zeroes (after the
8763 @samp{u}).  No zero padding is allowed for character codes greater than
8764 0xFFFF.  Surrogates (i.e., Unicode values greater than 0xFFFF
8765 represented with character codes from the surrogate area U+D800-U+DFFF)
8766 are not allowed too.
8768 @item
8769 A glyph representing more than a single input character will be named
8771 @display
8772 @samp{u} @var{component1} @samp{_} @var{component2} @samp{_} @var{component3} @dots{}
8773 @end display
8775 @noindent
8776 Example: @code{u0045_0302_0301}.
8778 For simplicity, all Unicode characters which are composites must be
8779 decomposed maximally (this is normalization form@tie{}D in the Unicode
8780 standard); for example, @code{u00CA_0301} is not a valid glyph name
8781 since U+00CA (@sc{latin capital letter e with circumflex}) can be
8782 further decomposed into U+0045 (@sc{latin capital letter e}) and U+0302
8783 (@sc{combining circumflex accent}).  @code{u0045_0302_0301} is thus the
8784 glyph name for U+1EBE, @sc{latin capital letter e with circumflex and
8785 acute}.
8787 @item
8788 groff maintains a table to decompose all algorithmically derived glyph
8789 names which are composites itself.  For example, @code{u0100} (@sc{latin
8790 letter a with macron}) will be automatically decomposed into
8791 @code{u0041_0304}.  Additionally, a glyph name of the GGL is preferred
8792 to an algorithmically derived glyph name; groff also automatically does
8793 the mapping.  Example: The glyph @code{u0045_0302} will be mapped to
8794 @code{^E}.
8796 @item
8797 glyph names of the GGL can't be used in composite glyph names; for
8798 example, @code{^E_u0301} is invalid.
8799 @end itemize
8801 @DefescList {\\, @lparen{}, nm, }
8802 @DefescItem {\\, @lbrack{}, name, @rbrack}
8803 @DefescListEnd {\\, @lbrack{}, component1 component2 @dots{}, @rbrack}
8804 Insert a symbol @var{name} (two-character name @var{nm}) or a composite
8805 glyph with component glyphs @var{component1}, @var{component2},
8806 @enddots{} There is no special syntax for one-character names -- the
8807 natural form @samp{\@var{n}} would collide with escapes.@footnote{Note
8808 that a one-character symbol is not the same as an input character, i.e.,
8809 the character @code{a} is not the same as @code{\[a]}.  By default,
8810 @code{groff} defines only a single one-character symbol, @code{\[-]}; it
8811 is usually accessed as @code{\-}.  On the other hand, @code{gtroff} has
8812 the special feature that @code{\[char@var{XXX}]} is the same as the
8813 input character with character code @var{XXX}.  For example,
8814 @code{\[char97]} is identical to the letter @code{a} if @acronym{ASCII}
8815 encoding is active.}
8817 If @var{name} is undefined, a warning of type @samp{char} is generated,
8818 and the escape is ignored.  @xref{Debugging}, for information about
8819 warnings.
8821 groff resolves @code{\[...]} with more than a single component as
8822 follows:
8824 @itemize @bullet
8825 @item
8826 Any component which is found in the GGL will be converted to the
8827 @code{u@var{XXXX}} form.
8829 @item
8830 Any component @code{u@var{XXXX}} which is found in the list of
8831 decomposable glyphs will be decomposed.
8833 @item
8834 The resulting elements are then concatenated with @samp{_} inbetween,
8835 dropping the leading @samp{u} in all elements but the first.
8836 @end itemize
8838 No check for the existence of any component (similar to @code{tr}
8839 request) will be done.
8841 Examples:
8843 @table @code
8844 @item \[A ho]
8845 @samp{A} maps to @code{u0041}, @samp{ho} maps to @code{u02DB}, thus the
8846 final glyph name would be @code{u0041_02DB}.  Note this is not the
8847 expected result: The ogonek glyph @samp{ho} is a spacing ogonek, but for
8848 a proper composite a non-spacing ogonek (U+0328) is necessary.  Looking
8849 into the file @file{composite.tmac} one can find @w{@samp{.composite ho
8850 u0328}} which changes the mapping of @samp{ho} while a composite glyph
8851 name is constructed, causing the final glyph name to be
8852 @code{u0041_0328}.
8854 @item \[^E u0301]
8855 @itemx \[^E aa]
8856 @itemx \[E a^ aa]
8857 @itemx \[E ^ ']
8858 @samp{^E} maps to @code{u0045_0302}, thus the final glyph name is
8859 @code{u0045_0302_0301} in all forms (assuming proper calls of the
8860 @code{composite} request).
8861 @end table
8863 It is not possible to define glyphs with names like @w{@samp{A ho}}
8864 within a groff font file.  This is not really a limitation; instead, you
8865 have to define @code{u0041_0328}.
8866 @endDefesc
8868 @Defesc {\\C, ', xxx, '}
8869 @cindex named character (@code{\C})
8870 @cindex character, named (@code{\C})
8871 Typeset the glyph named @var{xxx}.@footnote{@code{\C} is actually a
8872 misnomer since it accesses an output glyph.}  Normally it is more
8873 convenient to use @code{\[@var{xxx}]}, but @code{\C} has the advantage
8874 that it is compatible with newer versions of @acronym{AT&T}
8875 @code{troff} and is available in compatibility mode.
8876 @endDefesc
8878 @Defreq {composite, from to}
8879 @pindex composite.tmac
8880 Map glyph name @var{from} to glyph name @var{to} if it is used in
8881 @code{\[...]} with more than one component.  See above for examples.
8883 This mapping is based on glyph names only; no check for the existence of
8884 either glyph is done.
8886 A set of default mappings for many accents can be found in the file
8887 @file{composite.tmac} which is loaded at start-up.
8888 @endDefreq
8890 @Defesc {\\N, ', n, '}
8891 @cindex numbered glyph (@code{\N})
8892 @cindex glyph, numbered (@code{\N})
8893 @cindex @code{char} request, used with @code{\N}
8894 @cindex Unicode
8895 Typeset the glyph with code@tie{}@var{n} in the current font
8896 (@code{n}@tie{}is @strong{not} the input character code).  The
8897 number @var{n}@tie{}can be any non-negative decimal integer.  Most devices
8898 only have glyphs with codes between 0 and@tie{}255; the Unicode
8899 output device uses codes in the range 0--65535.  If the current
8900 font does not contain a glyph with that code, special fonts are
8901 @emph{not} searched.  The @code{\N} escape sequence can be
8902 conveniently used in conjunction with the @code{char} request:
8904 @Example
8905 .char \[phone] \f[ZD]\N'37'
8906 @endExample
8908 @noindent
8909 @pindex DESC
8910 @cindex unnamed glyphs
8911 @cindex glyphs, unnamed
8912 The code of each glyph is given in the fourth column in the font
8913 description file after the @code{charset} command.  It is possible to
8914 include unnamed glyphs in the font description file by using a
8915 name of @samp{---}; the @code{\N} escape sequence is the only way to
8916 use these.
8918 No kerning is applied to glyphs accessed with @code{\N}.
8919 @endDefesc
8921 Some escape sequences directly map onto special glyphs.
8923 @Defesc {\\', , , }
8924 This is a backslash followed by the apostrophe character, @acronym{ASCII}
8925 character @code{0x27} (@acronym{EBCDIC} character @code{0x7D}).  The same
8926 as @code{\[aa]}, the acute accent.
8927 @endDefesc
8929 @Defesc {\\`, , , }
8930 This is a backslash followed by @acronym{ASCII} character @code{0x60}
8931 (@acronym{EBCDIC} character @code{0x79} usually).  The same as
8932 @code{\[ga]}, the grave accent.
8933 @endDefesc
8935 @Defesc {\\-, , , }
8936 This is the same as @code{\[-]}, the minus sign in the current font.
8937 @endDefesc
8939 @Defreq {cflags, n c1 c2 @dots{}}
8940 @cindex glyph properties (@code{cflags})
8941 @cindex character properties (@code{cflags})
8942 @cindex properties of glyphs (@code{cflags})
8943 @cindex properties of characters (@code{cflags})
8944 Input characters and symbols have certain properties associated
8945 with it.@footnote{Note that the output glyphs themselves don't have
8946 such properties.  For @code{gtroff}, a glyph is a numbered box with
8947 a given width, depth, and height, nothing else.  All manipulations
8948 with the @code{cflags} request work on the input level.}  These
8949 properties can be modified with the @code{cflags} request.  The
8950 first argument is the sum of the desired flags and the remaining
8951 arguments are the characters or symbols to have those properties.
8952 It is possible to omit the spaces between the characters or symbols.
8954 @table @code
8955 @item 1
8956 @cindex end-of-sentence characters
8957 @cindex characters, end-of-sentence
8958 The character ends sentences (initially characters @samp{.?!} have this
8959 property).
8961 @item 2
8962 @cindex hyphenating characters
8963 @cindex characters, hyphenation
8964 Lines can be broken before the character (initially no characters have
8965 this property).
8967 @item 4
8968 @cindex @code{hy} glyph, and @code{cflags}
8969 @cindex @code{em} glyph, and @code{cflags}
8970 Lines can be broken after the character (initially the character
8971 @samp{-} and the symbols @samp{\[hy]} and @samp{\[em]} have this property).
8973 @item 8
8974 @cindex overlapping characters
8975 @cindex characters, overlapping
8976 @cindex @code{ul} glyph, and @code{cflags}
8977 @cindex @code{rn} glyph, and @code{cflags}
8978 @cindex @code{ru} glyph, and @code{cflags}
8979 @cindex @code{radicalex} glyph, and @code{cflags}
8980 @cindex @code{sqrtex} glyph, and @code{cflags}
8981 The character overlaps horizontally if used as a horizontal line building
8982 element.  Initially the symbols @samp{\[ul]}, @samp{\[rn]}, @samp{\[ru]},
8983 @samp{\[radicalex]}, and @samp{\[sqrtex]} have this property.
8985 @item 16
8986 @cindex @code{br} glyph, and @code{cflags}
8987 The character overlaps vertically if used as vertical line building element.
8988 Initially symbol @samp{\[br]} has this property.
8990 @item 32
8991 @cindex transparent characters
8992 @cindex character, transparent
8993 @cindex @code{"}, at end of sentence
8994 @cindex @code{'}, at end of sentence
8995 @cindex @code{)}, at end of sentence
8996 @cindex @code{]}, at end of sentence
8997 @cindex @code{*}, at end of sentence
8998 @cindex @code{dg} glyph, at end of sentence
8999 @cindex @code{rq} glyph, at end of sentence
9000 An end-of-sentence character followed by any number of characters with
9001 this property is treated as the end of a sentence if followed by a
9002 newline or two spaces; in other words the character is
9003 @dfn{transparent} for the purposes of end-of-sentence recognition --
9004 this is the same as having a zero space factor in @TeX{} (initially
9005 characters @samp{"')]*} and the symbols @samp{\[dg]} and @samp{\[rq]} have
9006 this property).
9007 @end table
9008 @endDefreq
9010 @DefreqList {char, g [@Var{string}]}
9011 @DefreqItem {fchar, g [@Var{string}]}
9012 @DefreqItem {fschar, f g [@Var{string}]}
9013 @DefreqListEnd {schar, g [@Var{string}]}
9014 @cindex defining character (@code{char})
9015 @cindex defining fallback character (@code{fchar}, @code{fschar}, @code{schar})
9016 @cindex character, defining (@code{char})
9017 @cindex character, defining fallback (@code{fchar}, @code{fschar}, @code{schar})
9018 @cindex fallback character, defining (@code{fchar}, @code{fschar}, @code{schar})
9019 @cindex creating new characters (@code{char})
9020 @cindex defining symbol (@code{char})
9021 @cindex symbol, defining (@code{char})
9022 @cindex defining glyph (@code{char})
9023 @cindex glyph, defining (@code{char})
9024 @cindex escape character, while defining glyph
9025 @cindex character, escape, while defining glyph
9026 @cindex @code{tr} request, and glyph definitions
9027 @cindex @code{cp} request, and glyph definitions
9028 @cindex @code{rc} request, and glyph definitions
9029 @cindex @code{lc} request, and glyph definitions
9030 @cindex @code{\l}, and glyph definitions
9031 @cindex @code{\L}, and glyph definitions
9032 @cindex @code{\&}, and glyph definitions
9033 @cindex @code{\e}, and glyph definitions
9034 @cindex @code{hcode} request, and glyph definitions
9035 Define a new glyph@tie{}@var{g} to be @var{string} (which can be
9036 empty).@footnote{@code{char} is a misnomer since an output glyph is
9037 defined.}  Every time glyph@tie{}@var{g} needs to be printed,
9038 @var{string} is processed in a temporary environment and the result is
9039 wrapped up into a single object.  Compatibility mode is turned off and
9040 the escape character is set to @samp{\} while @var{string} is being
9041 processed.  Any emboldening, constant spacing or track kerning is
9042 applied to this object rather than to individual characters in
9043 @var{string}.
9045 A glyph defined by these requests can be used just
9046 like a normal glyph provided by the output device.  In particular,
9047 other characters can be translated to it with the @code{tr} or
9048 @code{trin} requests; it can be made the leader character by the
9049 @code{lc} request; repeated patterns can be drawn with the glyph
9050 using the @code{\l} and @code{\L} escape sequences; words containing
9051 the glyph can be hyphenated correctly if the @code{hcode} request
9052 is used to give the glyph's symbol a hyphenation code.
9054 There is a special anti-recursion feature: Use of @code{g} within
9055 the glyph's definition is handled like normal characters and symbols
9056 not defined with @code{char}.
9058 Note that the @code{tr} and @code{trin} requests take precedence if
9059 @code{char} accesses the same symbol.
9061 @Example
9062 .tr XY
9064     @result{} Y
9065 .char X Z
9067     @result{} Y
9068 .tr XX
9070     @result{} Z
9071 @endExample
9073 The @code{fchar} request defines a fallback glyph:
9074 @code{gtroff} only checks for glyphs defined with @code{fchar}
9075 if it cannot find the glyph in the current font.
9076 @code{gtroff} carries out this test before checking special fonts.
9078 @code{fschar} defines a fallback glyph for font@tie{}@var{f}: @code{gtroff}
9079 checks for glyphs defined with @code{fschar} after the list of fonts
9080 declared as font-specific special fonts with the @code{fspecial} request,
9081 but before the list of fonts declared as global special fonts with the
9082 @code{special} request.
9084 Finally, the @code{schar} request defines a global fallback glyph:
9085 @code{gtroff} checks for glyphs defined with @code{schar} after the list
9086 of fonts declared as global special fonts with the @code{special} request,
9087 but before the already mounted special fonts.
9089 @xref{Using Symbols}, for a detailed description of the glyph
9090 searching mechanism in @code{gtroff}.
9091 @endDefreq
9093 @DefreqList {rchar, c1 c2 @dots{}}
9094 @DefreqListEnd {rfschar, f c1 c2 @dots{}}
9095 @cindex removing glyph definition (@code{rchar}, @code{rfschar})
9096 @cindex glyph, removing definition (@code{rchar}, @code{rfschar})
9097 @cindex fallback glyph, removing definition (@code{rchar}, @code{rfschar})
9098 Remove the definitions of glyphs @var{c1}, @var{c2},@tie{}@enddots{}
9099 This undoes the effect of a @code{char}, @code{fchar}, or
9100 @code{schar} request.
9102 It is possible to omit the whitespace between arguments.
9104 The request @code{rfschar} removes glyph definitions defined with
9105 @code{fschar} for glyph@tie{}f.
9106 @endDefreq
9108 @xref{Special Characters}.
9110 @c ---------------------------------------------------------------------
9112 @node Special Fonts, Artificial Fonts, Using Symbols, Fonts and Symbols
9113 @subsection Special Fonts
9114 @cindex special fonts
9115 @cindex fonts, special
9117 Special fonts are those that @code{gtroff} searches
9118 when it cannot find the requested glyph in the current font.
9119 The Symbol font is usually a special font.
9121 @code{gtroff} provides the following two requests to add more special
9122 fonts.  @xref{Using Symbols}, for a detailed description of the glyph
9123 searching mechanism in @code{gtroff}.
9125 Usually, only non-TTY devices have special fonts.
9127 @DefreqList {special, [@Var{s1} @Var{s2} @dots{}]}
9128 @DefreqListEnd {fspecial, f [@Var{s1} @Var{s2} @dots{}]}
9129 @kindex fonts
9130 @pindex DESC
9131 Use the @code{special} request to define special fonts.  Initially, this
9132 list is empty.
9134 Use the @code{fspecial} request to designate special fonts only when
9135 font@tie{}@var{f} is active.  Initially, this list is empty.
9137 Previous calls to @code{special} or @code{fspecial} are overwritten;
9138 without arguments, the particular list of special fonts is set to empty.
9139 Special fonts are searched in the order they appear as arguments.
9141 All fonts which appear in a call to @code{special} or @code{fspecial} are
9142 loaded.
9144 @xref{Using Symbols}, for the exact search order of glyphs.
9145 @endDefreq
9147 @c ---------------------------------------------------------------------
9149 @node Artificial Fonts, Ligatures and Kerning, Special Fonts, Fonts and Symbols
9150 @subsection Artificial Fonts
9151 @cindex artificial fonts
9152 @cindex fonts, artificial
9154 There are a number of requests and escapes for artificially creating
9155 fonts.  These are largely vestiges of the days when output devices
9156 did not have a wide variety of fonts, and when @code{nroff} and
9157 @code{troff} were separate programs.  Most of them are no longer
9158 necessary in GNU @code{troff}.  Nevertheless, they are supported.
9160 @DefescList {\\H, ', height, '}
9161 @DefescItem {\\H, ', @t{+}height, '}
9162 @DefescItem {\\H, ', @t{-}height, '}
9163 @DefregListEnd {.height}
9164 @cindex changing the font height (@code{\H})
9165 @cindex font height, changing (@code{\H})
9166 @cindex height, font, changing (@code{\H})
9167 Change (increment, decrement) the height of the current font, but not
9168 the width.  If @var{height} is zero, restore the original height.
9169 Default scaling indicator is @samp{z}.
9171 The read-only number register @code{.height} contains the font height as
9172 set by @code{\H}.
9174 Currently, only the @option{-Tps} device supports this feature.
9176 Note that @code{\H} doesn't produce an input token in @code{gtroff}.
9177 As a consequence, it can be used in requests like @code{mc} (which
9178 expects a single character as an argument) to change the font on
9179 the fly:
9181 @Example
9182 .mc \H'+5z'x\H'0'
9183 @endExample
9185 In compatibility mode, @code{gtroff} behaves differently:  If an
9186 increment or decrement is used, it is always taken relative to the
9187 current point size and not relative to the previously selected font
9188 height.  Thus,
9190 @Example
9191 .cp 1
9192 \H'+5'test \H'+5'test
9193 @endExample
9195 @noindent
9196 prints the word @samp{test} twice with the same font height (five
9197 points larger than the current font size).
9198 @endDefesc
9200 @DefescList {\\S, ', slant, '}
9201 @DefregListEnd {.slant}
9202 @cindex changing the font slant (@code{\S})
9203 @cindex font slant, changing (@code{\S})
9204 @cindex slant, font, changing (@code{\S})
9205 Slant the current font by @var{slant} degrees.  Positive values slant
9206 to the right.  Only integer values are possible.
9208 The read-only number register @code{.slant} contains the font slant as
9209 set by @code{\S}.
9211 Currently, only the @option{-Tps} device supports this feature.
9213 Note that @code{\S} doesn't produce an input token in @code{gtroff}.
9214 As a consequence, it can be used in requests like @code{mc} (which
9215 expects a single character as an argument) to change the font on
9216 the fly:
9218 @Example
9219 .mc \S'20'x\S'0'
9220 @endExample
9222 This request is incorrectly documented in the original @acronym{UNIX}
9223 troff manual; the slant is always set to an absolute value.
9224 @endDefesc
9226 @Defreq {ul, [@Var{lines}]}
9227 @cindex underlining (@code{ul})
9228 The @code{ul} request normally underlines subsequent lines if a TTY
9229 output device is used.  Otherwise, the lines are printed in italics
9230 (only the term `underlined' is used in the following).  The single
9231 argument is the number of input lines to be underlined; with no
9232 argument, the next line is underlined.  If @var{lines} is zero or
9233 negative, stop the effects of @code{ul} (if it was active).  Requests
9234 and empty lines do not count for computing the number of underlined
9235 input lines, even if they produce some output like @code{tl}.  Lines
9236 inserted by macros (e.g.@: invoked by a trap) do count.
9238 At the beginning of @code{ul}, the current font is stored and the
9239 underline font is activated.  Within the span of a @code{ul} request,
9240 it is possible to change fonts, but after the last line affected by
9241 @code{ul} the saved font is restored.
9243 This number of lines still to be underlined is associated with the
9244 current environment (@pxref{Environments}).  The underline font can be
9245 changed with the @code{uf} request.
9247 @c XXX @xref should be changed to grotty
9249 @c @xref{Troff and Nroff Mode}, for a discussion how underlining is
9250 @c implemented in for TTY output devices, and which problems can arise.
9252 The @code{ul} request does not underline spaces.
9253 @endDefreq
9255 @Defreq {cu, [@Var{lines}]}
9256 @cindex continuous underlining (@code{cu})
9257 @cindex underlining, continuous (@code{cu})
9258 The @code{cu} request is similar to @code{ul} but underlines spaces as
9259 well (if a TTY output device is used).
9260 @endDefreq
9262 @Defreq {uf, font}
9263 @cindex underline font (@code{uf})
9264 @cindex font for underlining (@code{uf})
9265 Set the underline font (globally) used by @code{ul} and @code{cu}.  By
9266 default, this is the font at position@tie{}2.  @var{font} can be either
9267 a non-negative font position or the name of a font.
9268 @endDefreq
9270 @DefreqList {bd, font [@Var{offset}]}
9271 @DefreqItem {bd, font1 font2 [@Var{offset}]}
9272 @DefregListEnd {.b}
9273 @cindex imitating bold face (@code{bd})
9274 @cindex bold face, imitating (@code{bd})
9275 Artificially create a bold font by printing each glyph twice,
9276 slightly offset.
9278 Two syntax forms are available.
9280 @itemize @bullet
9281 @item
9282 Imitate a bold font unconditionally.  The first argument specifies the
9283 font to embolden, and the second is the number of basic units, minus
9284 one, by which the two glyphs are offset.  If the second argument is
9285 missing, emboldening is turned off.
9287 @var{font} can be either a non-negative font position or the name of a
9288 font.
9290 @var{offset} is available in the @code{.b} read-only register if a
9291 special font is active; in the @code{bd} request, its default unit is
9292 @samp{u}.
9294 @cindex @code{fspecial} request, and imitating bold
9295 @kindex special
9296 @cindex embolding of special fonts
9297 @cindex special fonts, emboldening
9298 @item
9299 Imitate a bold form conditionally.  Embolden @var{font1} by
9300 @var{offset} only if font @var{font2} is the current font.  This
9301 command can be issued repeatedly to set up different emboldening
9302 values for different current fonts.  If the second argument is
9303 missing, emboldening is turned off for this particular current font.
9305 This affects special fonts only (either set up with the @code{special}
9306 command in font files or with the @code{fspecial} request).
9307 @end itemize
9308 @endDefreq
9310 @Defreq {cs, font [@Var{width} [@Var{em-size}]]}
9311 @cindex constant glyph space mode (@code{cs})
9312 @cindex mode for constant glyph space (@code{cs})
9313 @cindex glyph, constant space
9314 @cindex @code{ps} request, and constant glyph space mode
9315 Switch to and from @dfn{constant glyph space mode}.  If activated, the
9316 width of every glyph is @math{@var{width}/36} ems.  The em size is
9317 given absolutely by @var{em-size}; if this argument is missing, the em
9318 value is taken from the current font size (as set with the @code{ps}
9319 request) when the font is effectively in use.  Without second and
9320 third argument, constant glyph space mode is deactivated.
9322 Default scaling indicator for @var{em-size} is @samp{z}; @var{width} is
9323 an integer.
9324 @endDefreq
9326 @c ---------------------------------------------------------------------
9328 @node Ligatures and Kerning,  , Artificial Fonts, Fonts and Symbols
9329 @subsection Ligatures and Kerning
9330 @cindex ligatures and kerning
9331 @cindex kerning and ligatures
9333 Ligatures are groups of characters that are run together, i.e, producing
9334 a single glyph.  For example, the letters `f' and `i' can form a
9335 ligature `fi' as in the word `file'.  This produces a cleaner look
9336 (albeit subtle) to the printed output.  Usually, ligatures are not
9337 available in fonts for TTY output devices.
9339 Most @sc{PostScript} fonts support the fi and fl ligatures.  The C/A/T
9340 typesetter that was the target of @acronym{AT&T} @code{troff} also
9341 supported `ff', `ffi', and `ffl' ligatures.  Advanced typesetters or
9342 `expert' fonts may include ligatures for `ft' and `ct', although GNU
9343 @code{troff} does not support these (yet).
9345 Only the current font is checked for ligatures and kerns; neither special
9346 fonts nor entities defined with the @code{char} request (and its siblings)
9347 are taken into account.
9349 @DefreqList {lg, [@Var{flag}]}
9350 @DefregListEnd {.lg}
9351 @cindex activating ligatures (@code{lg})
9352 @cindex ligatures, activating (@code{lg})
9353 @cindex ligatures enabled register (@code{.lg})
9354 Switch the ligature mechanism on or off; if the parameter is non-zero
9355 or missing, ligatures are enabled, otherwise disabled.  Default is on.
9356 The current ligature mode can be found in the read-only number register
9357 @code{.lg} (set to 1 or@tie{}2 if ligatures are enabled, 0@tie{}otherwise).
9359 Setting the ligature mode to@tie{}2 enables the two-character ligatures
9360 (fi, fl, and ff) and disables the three-character ligatures (ffi and
9361 ffl).
9362 @endDefreq
9364 @dfn{Pairwise kerning} is another subtle typesetting mechanism that
9365 modifies the distance between a glyph pair to improve readability.
9366 In most cases (but not always) the distance is decreased.
9367 @ifnotinfo
9368 For example, compare the combination of the letters `V' and `A'.  With
9369 kerning, `VA' is printed.  Without kerning it appears as `V@w{}A'.
9370 @end ifnotinfo
9371 Typewriter-like fonts and fonts for terminals where all glyphs
9372 have the same width don't use kerning.
9374 @DefreqList {kern, [@Var{flag}]}
9375 @DefregListEnd {.kern}
9376 @cindex activating kerning (@code{kern})
9377 @cindex kerning, activating (@code{kern})
9378 @cindex kerning enabled register (@code{.kern})
9379 Switch kerning on or off.  If the parameter is non-zero or missing,
9380 enable pairwise kerning, otherwise disable it.  The read-only number
9381 register @code{.kern} is set to@tie{}1 if pairwise kerning is enabled,
9382 0@tie{}otherwise.
9384 @cindex zero width space character (@code{\&})
9385 @cindex character, zero width space (@code{\&})
9386 @cindex space character, zero width (@code{\&})
9387 If the font description file contains pairwise kerning information,
9388 glyphs from that font are kerned.  Kerning between two glyphs
9389 can be inhibited by placing @code{\&} between them: @samp{V\&A}.
9391 @xref{Font File Format}.
9392 @endDefreq
9394 @cindex track kerning
9395 @cindex kerning, track
9396 @dfn{Track kerning} expands or reduces the space between glyphs.
9397 This can be handy, for example, if you need to squeeze a long word
9398 onto a single line or spread some text to fill a narrow column.  It
9399 must be used with great care since it is usually considered bad
9400 typography if the reader notices the effect.
9402 @Defreq {tkf, f s1 n1 s2 n2}
9403 @cindex activating track kerning (@code{tkf})
9404 @cindex track kerning, activating (@code{tkf})
9405 Enable track kerning for font@tie{}@var{f}.  If the current font
9406 is@tie{}@var{f} the width of every glyph is increased by an amount
9407 between @var{n1} and @var{n2} (@var{n1}, @var{n2} can be negative); if
9408 the current point size is less than or equal to @var{s1} the width is
9409 increased by @var{n1}; if it is greater than or equal to @var{s2} the
9410 width is increased by @var{n2}; if the point size is greater than or
9411 equal to @var{s1} and less than or equal to @var{s2} the increase in
9412 width is a linear function of the point size.
9414 The default scaling indicator is @samp{z} for @var{s1} and @var{s2},
9415 @samp{p} for @var{n1} and @var{n2}.
9417 Note that the track kerning amount is added even to the rightmost glyph
9418 in a line; for large values it is thus recommended to increase the line
9419 length by the same amount to compensate it.
9420 @endDefreq
9422 Sometimes, when typesetting letters of different fonts, more or less
9423 space at such boundaries are needed.  There are two escapes to help
9424 with this.
9426 @Defesc {\\/, , , }
9427 @cindex italic correction (@code{\/})
9428 @cindex correction, italic (@code{\/})
9429 @cindex correction between italic and roman glyph (@code{\/}, @code{\,})
9430 @cindex roman glyph, correction after italic glyph (@code{\/})
9431 @cindex italic glyph, correction before roman glyph (@code{\/})
9432 @cindex glyph, italic correction (@code{\/})
9433 Increase the width of the preceding glyph so that the spacing
9434 between that glyph and the following glyph is correct if the
9435 following glyph is a roman glyph.  For example, if an
9436 italic@tie{}@code{f} is immediately followed by a roman right
9437 parenthesis, then in many fonts the top right portion of the@tie{}@code{f}
9438 overlaps the top left of the right parenthesis.  Use this escape
9439 sequence whenever an italic glyph is immediately followed by a
9440 roman glyph without any intervening space.  This small amount of
9441 space is also called @dfn{italic correction}.
9443 @iftex
9444 @c can't use @Example...@endExample here
9445 @example
9446 @group
9447 \f[I]f\f[R])
9448     @result{} {@it f}@r{)}
9449 \f[I]f\/\f[R])
9450     @result{} @i{f}@r{)}
9451 @end group
9452 @end example
9453 @end iftex
9454 @endDefesc
9456 @Defesc {\\\,, , , }
9457 @cindex left italic correction (@code{\,})
9458 @cindex correction, left italic (@code{\,})
9459 @cindex glyph, left italic correction (@code{\,})
9460 @cindex roman glyph, correction before italic glyph (@code{\,})
9461 @cindex italic glyph, correction after roman glyph (@code{\,})
9462 Modify the spacing of the following glyph so that the spacing
9463 between that glyph and the preceding glyph is correct if the
9464 preceding glyph is a roman glyph.  Use this escape sequence
9465 whenever a roman glyph is immediately followed by an italic
9466 glyph without any intervening space.  In analogy to above, this
9467 space could be called @dfn{left italic correction}, but this term
9468 isn't used widely.
9470 @iftex
9471 @c can't use @Example...@endExample here
9472 @example
9473 @group
9474 q\f[I]f
9475     @result{} @r{q}@i{f}
9476 q\,\f[I]f
9477     @result{} @r{q}@math{@ptexcomma}@i{f}
9478 @end group
9479 @end example
9480 @end iftex
9481 @endDefesc
9483 @Defesc {\\&, , , }
9484 Insert a zero-width character, which is invisible.  Its intended use
9485 is to stop interaction of a character with its surrounding.
9487 @itemize @bullet
9488 @item
9489 It prevents the insertion of extra space after an end-of-sentence
9490 character.
9492 @Example
9493 Test.
9494 Test.
9495     @result{} Test.  Test.
9496 Test.\&
9497 Test.
9498     @result{} Test. Test.
9499 @endExample
9501 @item
9502 It prevents interpretation of a control character at the beginning of
9503 an input line.
9505 @Example
9506 .Test
9507     @result{} warning: `Test' not defined
9508 \&.Test
9509     @result{} .Test
9510 @endExample
9512 @item
9513 It prevents kerning between two glyphs.
9515 @ifnotinfo
9516 @Example
9518     @result{} @r{VA}
9519 V\&A
9520     @result{} @r{V@w{}A}
9521 @endExample
9522 @end ifnotinfo
9524 @item
9525 It is needed to map an arbitrary character to nothing in the @code{tr}
9526 request (@pxref{Character Translations}).
9527 @end itemize
9528 @endDefesc
9530 @Defesc {\\), , , }
9531 This escape is similar to @code{\&} except that it behaves like a
9532 character declared with the @code{cflags} request to be transparent
9533 for the purposes of an end-of-sentence character.
9535 Its main usage is in macro definitions to protect against arguments
9536 starting with a control character.
9538 @Example
9539 .de xxx
9540 \)\\$1
9542 .de yyy
9543 \&\\$1
9545 This is a test.\c
9546 .xxx '
9547 This is a test.
9548     @result{}This is a test.'  This is a test.
9549 This is a test.\c
9550 .yyy '
9551 This is a test.
9552     @result{}This is a test.' This is a test.
9553 @endExample
9554 @endDefesc
9557 @c =====================================================================
9559 @node Sizes, Strings, Fonts and Symbols, gtroff Reference
9560 @section Sizes
9561 @cindex sizes
9563 @cindex baseline
9564 @cindex type size
9565 @cindex size of type
9566 @cindex vertical spacing
9567 @cindex spacing, vertical
9568 @code{gtroff} uses two dimensions with each line of text, type size
9569 and vertical spacing.  The @dfn{type size} is approximately the height
9570 of the tallest glyph.@footnote{This is usually the parenthesis.
9571 Note that in most cases the real dimensions of the glyphs in a font
9572 are @emph{not} related to its type size!  For example, the standard
9573 @sc{PostScript} font families `Times Roman', `Helvetica', and
9574 `Courier' can't be used together at 10@dmn{pt}; to get acceptable
9575 output, the size of `Helvetica' has to be reduced by one point, and
9576 the size of `Courier' must be increased by one point.}  @dfn{Vertical
9577 spacing} is the amount of space @code{gtroff} allows for a line of
9578 text; normally, this is about 20%@tie{}larger than the current type
9579 size.  Ratios smaller than this can result in hard-to-read text;
9580 larger than this, it spreads the text out more vertically (useful for
9581 term papers).  By default, @code{gtroff} uses 10@tie{}point type on
9582 12@tie{}point spacing.
9584 @cindex leading
9585 The difference between type size and vertical spacing is known, by
9586 typesetters, as @dfn{leading} (this is pronounced `ledding').
9588 @menu
9589 * Changing Type Sizes::
9590 * Fractional Type Sizes::
9591 @end menu
9593 @c ---------------------------------------------------------------------
9595 @node Changing Type Sizes, Fractional Type Sizes, Sizes, Sizes
9596 @subsection Changing Type Sizes
9598 @DefreqList {ps, [@Var{size}]}
9599 @DefreqItem {ps, @t{+}@Var{size}}
9600 @DefreqItem {ps, @t{-}@Var{size}}
9601 @DefescItem {\\s, , size, }
9602 @DefregListEnd {.s}
9603 @cindex changing type sizes (@code{ps}, @code{\s})
9604 @cindex type sizes, changing (@code{ps}, @code{\s})
9605 @cindex point sizes, changing (@code{ps}, @code{\s})
9606 Use the @code{ps} request or the @code{\s} escape to change (increase,
9607 decrease) the type size (in points).  Specify @var{size} as either an
9608 absolute point size, or as a relative change from the current size.
9609 The size@tie{}0, or no argument, goes back to the previous size.
9611 Default scaling indicator of @code{size} is @samp{z}.  If @code{size}
9612 is zero or negative, it is set to 1@dmn{u}.
9614 @cindex type size registers (@code{.s}, @code{.ps})
9615 @cindex point size registers (@code{.s}, @code{.ps})
9616 The read-only number register @code{.s} returns the point size in
9617 points as a decimal fraction.  This is a string.  To get the point
9618 size in scaled points, use the @code{.ps} register instead.
9620 @code{.s} is associated with the current environment
9621 (@pxref{Environments}).
9623 @Example
9624 snap, snap,
9625 .ps +2
9626 grin, grin,
9627 .ps +2
9628 wink, wink, \s+2nudge, nudge,\s+8 say no more!
9629 .ps 10
9630 @endExample
9632 The @code{\s} escape may be called in a variety of ways.  Much like
9633 other escapes there must be a way to determine where the argument ends
9634 and the text begins.  Any of the following forms are valid:
9636 @table @code
9637 @item \s@var{n}
9638 Set the point size to @var{n}@tie{}points.  @var{n}@tie{}must be either
9639 0 or in the range 4 to@tie{}39.
9641 @item \s+@var{n}
9642 @itemx \s-@var{n}
9643 Increase or decrease the point size by @var{n}@tie{}points.
9644 @var{n}@tie{}must be exactly one digit.
9646 @item \s(@var{nn}
9647 Set the point size to @var{nn}@tie{}points.  @var{nn} must be exactly
9648 two digits.
9650 @item \s+(@var{nn}
9651 @itemx \s-(@var{nn}
9652 @itemx \s(+@var{nn}
9653 @itemx \s(-@var{nn}
9654 Increase or decrease the point size by @var{nn}@tie{}points.  @var{nn}
9655 must be exactly two digits.
9656 @end table
9658 Note that @code{\s} doesn't produce an input token in @code{gtroff}.
9659 As a consequence, it can be used in requests like @code{mc} (which
9660 expects a single character as an argument) to change the font on
9661 the fly:
9663 @Example
9664 .mc \s[20]x\s[0]
9665 @endExample
9667 @xref{Fractional Type Sizes}, for yet another syntactical form of
9668 using the @code{\s} escape.
9669 @endDefreq
9671 @Defreq {sizes, s1 s2 @dots{} sn [0]}
9672 Some devices may only have certain permissible sizes, in which case
9673 @code{gtroff} rounds to the nearest permissible size.
9674 The @file{DESC} file specifies which sizes are permissible for the device.
9676 Use the @code{sizes} request to change the permissible sizes
9677 for the current output device.
9678 Arguments are in scaled points;
9679 the @code{sizescale} line in the
9680 @file{DESC} file for the output device
9681 provides the scaling factor.
9682 For example, if the scaling factor is 1000,
9683 then the value 12000 is 12@tie{}points.
9685 Each argument can be a single point size (such as @samp{12000}),
9686 or a range of sizes (such as @samp{4000-72000}).
9687 You can optionally end the list with a zero.
9688 @endDefreq
9690 @DefreqList {vs, [@Var{space}]}
9691 @DefreqItem {vs, @t{+}@Var{space}}
9692 @DefreqItem {vs, @t{-}@Var{space}}
9693 @DefregListEnd {.v}
9694 @cindex changing vertical line spacing (@code{vs})
9695 @cindex vertical line spacing, changing (@code{vs})
9696 @cindex vertical line spacing register (@code{.v})
9697 Change (increase, decrease) the vertical spacing by @var{space}.  The
9698 default scaling indicator is @samp{p}.
9700 If @code{vs} is called without an argument, the vertical spacing is
9701 reset to the previous value before the last call to @code{vs}.
9703 @cindex @code{.V} register, and @code{vs}
9704 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
9705 negative; the vertical spacing is then set to smallest positive value,
9706 the vertical resolution (as given in the @code{.V} register).
9708 Note that @w{@samp{.vs 0}} isn't saved in a diversion since it doesn't
9709 result in a vertical motion.  You explicitly have to repeat this command
9710 before inserting the diversion.
9712 The read-only number register @code{.v} contains the current vertical
9713 spacing; it is associated with the current environment
9714 (@pxref{Environments}).
9715 @endDefreq
9717 @cindex vertical line spacing, effective value
9718 The effective vertical line spacing consists of four components.  Breaking
9719 a line causes the following actions (in the given order).
9721 @itemize @bullet
9722 @item
9723 @cindex extra pre-vertical line space (@code{\x})
9724 @cindex line space, extra pre-vertical (@code{\x})
9725 Move the current point vertically by the @dfn{extra pre-vertical line
9726 space}.  This is the minimum value of all @code{\x} escapes with a
9727 negative argument in the current output line.
9729 @item
9730 Move the current point vertically by the vertical line spacing as set with
9731 the @code{vs} request.
9733 @item
9734 Output the current line.
9736 @item
9737 @cindex extra post-vertical line space (@code{\x})
9738 @cindex line space, extra post-vertical (@code{\x})
9739 Move the current point vertically by the @dfn{extra post-vertical line
9740 space}.  This is the maximum value of all @code{\x} escapes with a
9741 positive argument in the line which has just been output.
9743 @item
9744 @cindex post-vertical line spacing
9745 @cindex line spacing, post-vertical (@code{pvs})
9746 Move the current point vertically by the @dfn{post-vertical line spacing}
9747 as set with the @code{pvs} request.
9748 @end itemize
9750 @cindex double-spacing (@code{vs}, @code{pvs})
9751 It is usually better to use @code{vs} or @code{pvs} instead of @code{ls}
9752 to produce double-spaced documents: @code{vs} and @code{pvs} have a finer
9753 granularity for the inserted vertical space compared to @code{ls};
9754 furthermore, certain preprocessors assume single-spacing.
9756 @xref{Manipulating Spacing}, for more details on the @code{\x} escape
9757 and the @code{ls} request.
9759 @DefreqList {pvs, [@Var{space}]}
9760 @DefreqItem {pvs, @t{+}@Var{space}}
9761 @DefreqItem {pvs, @t{-}@Var{space}}
9762 @DefregListEnd {.pvs}
9763 @cindex @code{ls} request, alternative to (@code{pvs})
9764 @cindex post-vertical line spacing, changing (@code{pvs})
9765 @cindex post-vertical line spacing register (@code{.pvs})
9766 Change (increase, decrease) the post-vertical spacing by
9767 @var{space}.  The default scaling indicator is @samp{p}.
9769 If @code{pvs} is called without an argument, the post-vertical spacing is
9770 reset to the previous value before the last call to @code{pvs}.
9772 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
9773 zero or negative; the vertical spacing is then set to zero.
9775 The read-only number register @code{.pvs} contains the current
9776 post-vertical spacing; it is associated with the current environment
9777 (@pxref{Environments}).
9778 @endDefreq
9780 @c ---------------------------------------------------------------------
9782 @node Fractional Type Sizes,  , Changing Type Sizes, Sizes
9783 @subsection Fractional Type Sizes
9784 @cindex fractional type sizes
9785 @cindex fractional point sizes
9786 @cindex type sizes, fractional
9787 @cindex point sizes, fractional
9788 @cindex sizes, fractional
9790 @cindex @code{s} unit
9791 @cindex unit, @code{s}
9792 @cindex @code{z} unit
9793 @cindex unit, @code{z}
9794 @cindex @code{ps} request, with fractional type sizes
9795 @cindex @code{cs} request, with fractional type sizes
9796 @cindex @code{tkf} request, with fractional type sizes
9797 @cindex @code{\H}, with fractional type sizes
9798 @cindex @code{\s}, with fractional type sizes
9799 A @dfn{scaled point} is equal to @math{1/@var{sizescale}} points,
9800 where @var{sizescale} is specified in the @file{DESC} file (1@tie{}by
9801 default).  There is a new scale indicator @samp{z} which has the
9802 effect of multiplying by @var{sizescale}.  Requests and escape
9803 sequences in @code{gtroff} interpret arguments that represent a point
9804 size as being in units of scaled points, but they evaluate each such
9805 argument using a default scale indicator of @samp{z}.  Arguments
9806 treated in this way are the argument to the @code{ps} request, the
9807 third argument to the @code{cs} request, the second and fourth
9808 arguments to the @code{tkf} request, the argument to the @code{\H}
9809 escape sequence, and those variants of the @code{\s} escape sequence
9810 that take a numeric expression as their argument (see below).
9812 For example, suppose @var{sizescale} is@tie{}1000; then a scaled point
9813 is equivalent to a millipoint; the request @w{@samp{.ps 10.25}} is
9814 equivalent to @w{@samp{.ps 10.25z}} and thus sets the point size to
9815 10250@tie{}scaled points, which is equal to 10.25@tie{}points.
9817 @code{gtroff} disallows the use of the @samp{z} scale indicator in
9818 instances where it would make no sense, such as a numeric
9819 expression whose default scale indicator was neither @samp{u} nor
9820 @samp{z}.  Similarly it would make
9821 no sense to use a scaling indicator other than @samp{z} or @samp{u} in a
9822 numeric expression whose default scale indicator was @samp{z}, and so
9823 @code{gtroff} disallows this as well.
9825 There is also new scale indicator @samp{s} which multiplies by the
9826 number of units in a scaled point.  So, for example, @samp{\n[.ps]s} is
9827 equal to @samp{1m}.  Be sure not to confuse the @samp{s} and @samp{z}
9828 scale indicators.
9830 @Defreg {.ps}
9831 A read-only number register returning the point size in scaled points.
9833 @code{.ps} is associated with the current environment
9834 (@pxref{Environments}).
9835 @endDefreg
9837 @DefregList {.psr}
9838 @DefregListEnd {.sr}
9839 @cindex last-requested point size registers (@code{.psr}, @code{.sr})
9840 @cindex point size registers, last-requested (@code{.psr}, @code{.sr})
9841 @cindex @code{.ps} register, in comparison with @code{.psr}
9842 @cindex @code{.s} register, in comparison with @code{.sr}
9843 The last-requested point size in scaled points is contained in the
9844 @code{.psr} read-only number register.  The last requested point size
9845 in points as a decimal fraction can be found in @code{.sr}.  This is a
9846 string-valued read-only number register.
9848 Note that the requested point sizes are device-independent, whereas
9849 the values returned by the @code{.ps} and @code{.s} registers are not.
9850 For example, if a point size of 11@dmn{pt} is requested, and a
9851 @code{sizes} request (or a @code{sizescale} line in a @file{DESC} file)
9852 specifies 10.95@dmn{pt} instead, this value is actually used.
9854 Both registers are associated with the current environment
9855 (@pxref{Environments}).
9856 @endDefreg
9858 The @code{\s} escape has the following syntax for working with
9859 fractional type sizes:
9861 @table @code
9862 @item \s[@var{n}]
9863 @itemx \s'@var{n}'
9864 Set the point size to @var{n}@tie{}scaled points; @var{n}@tie{}is a numeric
9865 expression with a default scale indicator of @samp{z}.
9867 @item \s[+@var{n}]
9868 @itemx \s[-@var{n}]
9869 @itemx \s+[@var{n}]
9870 @itemx \s-[@var{n}]
9871 @itemx \s'+@var{n}'
9872 @itemx \s'-@var{n}'
9873 @itemx \s+'@var{n}'
9874 @itemx \s-'@var{n}'
9875 Increase or or decrease the point size by @var{n}@tie{}scaled points;
9876 @var{n}@tie{}is a numeric expression with a default scale indicator of
9877 @samp{z}.
9878 @end table
9880 @xref{Font Files}.
9883 @c =====================================================================
9885 @node Strings, Conditionals and Loops, Sizes, gtroff Reference
9886 @section Strings
9887 @cindex strings
9889 @code{gtroff} has string variables, which are entirely for user
9890 convenience (i.e.@: there are no built-in strings exept @code{.T}, but
9891 even this is a read-write string variable).
9893 @DefreqList {ds, name [@Var{string}]}
9894 @DefreqItem {ds1, name [@Var{string}]}
9895 @DefescItem {\\*, , n, }
9896 @DefescItem {\\*, @lparen{}, nm, }
9897 @DefescListEnd {\\*, @lbrack{}, name arg1 arg2 @dots{}, @rbrack{}}
9898 @cindex string interpolation (@code{\*})
9899 @cindex string expansion (@code{\*})
9900 @cindex interpolation of strings (@code{\*})
9901 @cindex expansion of strings (@code{\*})
9902 @cindex string arguments
9903 @cindex arguments, of strings
9904 Define and access a string variable @var{name} (one-character
9905 name@tie{}@var{n}, two-character name @var{nm}).  If @var{name} already
9906 exists, @code{ds} overwrites the previous definition.  Only the syntax form
9907 using brackets can take arguments which are handled identically to
9908 macro arguments; the single exception is that a closing bracket as an
9909 argument must be enclosed in double quotes.  @xref{Request and Macro
9910 Arguments}, and @ref{Parameters}.
9912 Example:
9914 @Example
9915 .ds foo a \\$1 test
9917 This is \*[foo nice].
9918     @result{} This is a nice test.
9919 @endExample
9921 The @code{\*} escape @dfn{interpolates} (expands in-place) a
9922 previously-defined string variable.  To be more precise, the stored
9923 string is pushed onto the input stack which is then parsed by
9924 @code{gtroff}.  Similar to number registers, it is possible to nest
9925 strings, i.e. string variables can be called within string variables.
9927 If the string named by the @code{\*} escape does not exist, it is
9928 defined as empty, and a warning of type @samp{mac} is emitted (see
9929 @ref{Debugging}, for more details).
9931 @cindex comments, with @code{ds}
9932 @cindex @code{ds} request, and comments
9933 @strong{Caution:} Unlike other requests, the second argument to the
9934 @code{ds} request takes up the entire line including trailing spaces.
9935 This means that comments on a line with such a request can introduce
9936 unwanted space into a string.
9938 @Example
9939 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d \" UNIX trademark
9940 @endExample
9942 @noindent
9943 Instead the comment should be put on another line or have the comment
9944 escape adjacent with the end of the string.
9946 @Example
9947 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d\"  UNIX trademark
9948 @endExample
9950 @cindex trailing quotes
9951 @cindex quotes, trailing
9952 @cindex leading spaces with @code{ds}
9953 @cindex spaces with @code{ds}
9954 @cindex @code{ds} request, and leading spaces
9955 To produce leading space the string can be started with a double
9956 quote.  No trailing quote is needed; in fact, any trailing quote is
9957 included in your string.
9959 @Example
9960 .ds sign "           Yours in a white wine sauce,
9961 @endExample
9963 @cindex multi-line strings
9964 @cindex strings, multi-line
9965 @cindex newline character, in strings, escaping
9966 @cindex escaping newline characters, in strings
9967 Strings are not limited to a single line of text.  A string can span
9968 several lines by escaping the newlines with a backslash.  The
9969 resulting string is stored @emph{without} the newlines.
9971 @Example
9972 .ds foo lots and lots \
9973 of text are on these \
9974 next several lines
9975 @endExample
9977 It is not possible to have real newlines in a string.  To put a single
9978 double quote character into a string, use two consecutive double quote
9979 characters.
9981 The @code{ds1} request turns off compatibility mode
9982 while interpreting a string.  To be more precise, a @dfn{compatibility
9983 save} input token is inserted at the beginning of  the string, and a
9984 @dfn{compatibility restore} input token at the end.
9986 @Example
9987 .nr xxx 12345
9988 .ds aa The value of xxx is \\n[xxx].
9989 .ds1 bb The value of xxx ix \\n[xxx].
9991 .cp 1
9993 \*(aa
9994     @result{} warning: number register `[' not defined
9995     @result{} The value of xxx is 0xxx].
9996 \*(bb
9997     @result{} The value of xxx ix 12345.
9998 @endExample
10000 @cindex name space, common, of macros, diversions, and strings
10001 @cindex common name space of macros, diversions, and strings
10002 @cindex macros, shared name space with strings and diversions
10003 @cindex strings, shared name space with macros and diversions
10004 @cindex diversions, shared name space with macros and strings
10005 Strings, macros, and diversions (and boxes) share the same name space.
10006 Internally, even the same mechanism is used to store them.  This has
10007 some interesting consequences.  For example, it is possible to call a
10008 macro with string syntax and vice versa.
10010 @Example
10011 .de xxx
10012 a funny test.
10014 This is \*[xxx]
10015     @result{} This is a funny test.
10017 .ds yyy a funny test
10018 This is
10019 .yyy
10020     @result{} This is a funny test.
10021 @endExample
10023 Diversions and boxes can be also called with string syntax.
10025 Another consequence is that you can copy one-line diversions or boxes
10026 to a string.
10028 @Example
10029 .di xxx
10030 a \fItest\fR
10033 .ds yyy This is \*[xxx]\c
10034 \*[yyy].
10035     @result{} @r{This is a }@i{test}.
10036 @endExample
10038 @noindent
10039 As the previous example shows, it is possible to store formatted
10040 output in strings.  The @code{\c} escape prevents the insertion of an
10041 additional blank line in the output.
10043 Copying diversions longer than a single output line produces
10044 unexpected results.
10046 @Example
10047 .di xxx
10048 a funny
10050 test
10053 .ds yyy This is \*[xxx]\c
10054 \*[yyy].
10055     @result{} test This is a funny.
10056 @endExample
10058 Usually, it is not predictable whether a diversion contains one or
10059 more output lines, so this mechanism should be avoided.  With
10060 @acronym{UNIX} @code{troff}, this was the only solution to strip off a
10061 final newline from a diversion.  Another disadvantage is that the
10062 spaces in the copied string are already formatted, making them
10063 unstretchable.  This can cause ugly results.
10065 @cindex stripping final newline in diversions
10066 @cindex diversion, stripping final newline
10067 @cindex final newline, stripping in diversions
10068 @cindex newline, final, stripping in diversions
10069 @cindex horizontal space, unformatting
10070 @cindex space, horizontal, unformatting
10071 @cindex unformatting horizontal space
10072 A clean solution to this problem is available in GNU @code{troff},
10073 using the requests @code{chop} to remove the final newline of a
10074 diversion, and @code{unformat} to make the horizontal spaces
10075 stretchable again.
10077 @Example
10078 .box xxx
10079 a funny
10081 test
10083 .box
10084 .chop xxx
10085 .unformat xxx
10086 This is \*[xxx].
10087     @result{} This is a funny test.
10088 @endExample
10090 @xref{Gtroff Internals}, for more information.
10091 @endDefreq
10093 @DefreqList {as, name [@Var{string}]}
10094 @DefreqListEnd {as1, name [@Var{string}]}
10095 @cindex appending to a string (@code{as})
10096 @cindex string, appending (@code{as})
10097 The @code{as} request is similar to @code{ds} but appends @var{string}
10098 to the string stored as @var{name} instead of redefining it.  If
10099 @var{name} doesn't exist yet, it is created.
10101 @Example
10102 .as sign " with shallots, onions and garlic,
10103 @endExample
10105 The @code{as1} request is similar to @code{as}, but compatibility mode
10106 is switched off while the appended string is interpreted.  To be more
10107 precise, a @dfn{compatibility save} input token is inserted at the
10108 beginning of the appended string, and a @dfn{compatibility restore}
10109 input token at the end.
10110 @endDefreq
10112 Rudimentary string manipulation routines are given with the next two
10113 requests.
10115 @Defreq {substring, str n1 [@Var{n2}]}
10116 @cindex substring (@code{substring})
10117 Replace the string named @var{str} with the substring
10118 defined by the indices @var{n1} and@tie{}@var{n2}.  The first character
10119 in the string has index@tie{}0.  If @var{n2} is omitted, it is taken to
10120 be equal to the string's length.  If the index value @var{n1} or
10121 @var{n2} is negative, it is counted from the end of the
10122 string, going backwards: The last character has index@tie{}@minus{}1, the
10123 character before the last character has index@tie{}@minus{}2, etc.
10125 @Example
10126 .ds xxx abcdefgh
10127 .substring xxx 1 -4
10128 \*[xxx]
10129     @result{} bcde
10130 @endExample
10131 @endDefreq
10133 @Defreq {length, reg str}
10134 @cindex length of a string (@code{length})
10135 @cindex string, length of (@code{length})
10136 Compute the number of characters of @var{str} and return it in the
10137 number register @var{reg}.  If @var{reg} doesn't exist, it is created.
10138 @code{str} is read in copy mode.
10140 @Example
10141 .ds xxx abcd\h'3i'efgh
10142 .length yyy \*[xxx]
10143 \n[yyy]
10144     @result{} 14
10145 @endExample
10146 @endDefreq
10148 @Defreq {rn, xx yy}
10149 @cindex renaming request (@code{rn})
10150 @cindex request, renaming (@code{rn})
10151 @cindex renaming macro (@code{rn})
10152 @cindex macro, renaming (@code{rn})
10153 @cindex renaming string (@code{rn})
10154 @cindex string, renaming (@code{rn})
10155 @cindex renaming diversion (@code{rn})
10156 @cindex diversion, renaming (@code{rn})
10157 Rename the request, macro, diversion, or string @var{xx} to @var{yy}.
10158 @endDefreq
10160 @Defreq {rm, xx}
10161 @cindex removing request (@code{rm})
10162 @cindex request, removing (@code{rm})
10163 @cindex removing macro (@code{rm})
10164 @cindex macro, removing (@code{rm})
10165 @cindex removing string (@code{rm})
10166 @cindex string, removing (@code{rm})
10167 @cindex removing diversion (@code{rm})
10168 @cindex diversion, removing (@code{rm})
10169 Remove the request, macro, diversion, or string @var{xx}.  @code{gtroff}
10170 treats subsequent invocations as if the object had never been defined.
10171 @endDefreq
10173 @Defreq {als, new old}
10174 @cindex alias, string, creating (@code{als})
10175 @cindex alias, macro, creating (@code{als})
10176 @cindex alias, diversion, creating (@code{als})
10177 @cindex creating alias, for string (@code{als})
10178 @cindex creating alias, for macro (@code{als})
10179 @cindex creating alias, for diversion (@code{als})
10180 @cindex string, creating alias (@code{als})
10181 @cindex macro, creating alias (@code{als})
10182 @cindex diversion, creating alias (@code{als})
10183 Create an alias named @var{new} for the request, string, macro, or
10184 diversion object named @var{old}.  The new name and the old name are
10185 exactly equivalent (it is similar to a hard rather than a soft
10186 link). If @var{old} is undefined, @code{gtroff} generates a warning of
10187 type @samp{mac} and ignores the request.
10188 @endDefreq
10190 @Defreq {chop, xx}
10191 Remove (chop) the last character from the macro, string, or diversion
10192 named @var{xx}.  This is useful for removing the newline from the end
10193 of diversions that are to be interpolated as strings.  This command
10194 can be used repeatedly; see @ref{Gtroff Internals}, for details on
10195 nodes inserted additionally by @code{gtroff}.
10196 @endDefreq
10198 @xref{Identifiers}, and @ref{Comments}.
10201 @c =====================================================================
10203 @node Conditionals and Loops, Writing Macros, Strings, gtroff Reference
10204 @section Conditionals and Loops
10205 @cindex conditionals and loops
10206 @cindex loops and conditionals
10208 @menu
10209 * Operators in Conditionals::
10210 * if-else::
10211 * while::
10212 @end menu
10214 @c ---------------------------------------------------------------------
10216 @node Operators in Conditionals, if-else, Conditionals and Loops, Conditionals and Loops
10217 @subsection Operators in Conditionals
10219 @cindex @code{if} request, operators to use with
10220 @cindex @code{while} request, operators to use with
10221 In @code{if} and @code{while} requests, there are several more
10222 operators available:
10224 @table @code
10225 @item e
10226 @itemx o
10227 True if the current page is even or odd numbered (respectively).
10229 @item n
10230 True if the document is being processed in nroff mode (i.e., the
10231 @code{.nroff} command has been issued).
10233 @item t
10234 True if the document is being processed in troff mode (i.e., the
10235 @code{.troff} command has been issued).
10237 @item v
10238 Always false.  This condition is for compatibility with other
10239 @code{troff} versions only (identifying a @code{-Tversatec} device).
10241 @item '@var{xxx}'@var{yyy}'
10242 True if the string @var{xxx} is equal to the string @var{yyy}.  Other
10243 characters can be used in place of the single quotes; the same set of
10244 delimiters as for the @code{\D} escape is used (@pxref{Escapes}).
10245 @code{gtroff} formats the strings before being compared:
10247 @Example
10248 .ie "|"\fR|\fP" \
10249 true
10250 .el \
10251 false
10252     @result{} true
10253 @endExample
10255 @noindent
10256 The resulting motions, glyph sizes, and fonts have to
10257 match,@footnote{The created output nodes must be identical.
10258 @xref{Gtroff Internals}.} and not the individual motion, size, and
10259 font requests.  In the previous example, @samp{|} and @samp{\fR|\fP}
10260 both result in a roman @samp{|} glyph with the same point size and
10261 at the same location on the page, so the strings are equal.  If
10262 @samp{.ft@tie{}I} had been added before the @samp{.ie}, the result
10263 would be ``false'' because (the first) @samp{|} produces an italic
10264 @samp{|} rather than a roman one.
10266 @item r @var{xxx}
10267 True if there is a number register named @var{xxx}.
10269 @item d @var{xxx}
10270 True if there is a string, macro, diversion, or request named @var{xxx}.
10272 @item m @var{xxx}
10273 True if there is a color named @var{xxx}.
10275 @item c @var{g}
10276 True if there is a glyph @var{g} available@footnote{The name of this
10277 conditional operator is a misnomer since it tests names of output
10278 glyphs.}; @var{g} is either an @acronym{ASCII} character or a special
10279 character (@code{\(@var{gg}} or @code{\[@var{ggg}]}); the condition
10280 is also true if @var{g} has been defined by the @code{char} request.
10282 @item F @var{font}
10283 True if a font named @var{font} exists.  @var{font} is handled as if it was
10284 opened with the @code{ft} request (this is, font translation and styles are
10285 applied), without actually mounting it.
10287 This test doesn't load the complete font but only its header to verify
10288 its validity.
10290 @item S @var{style}
10291 True if style @var{style} has been registered.  Font translation is applied.
10292 @end table
10294 Note that these operators can't be combined with other operators like
10295 @samp{:} or @samp{&}; only a leading @samp{!} (without whitespace
10296 between the exclamation mark and the operator) can be used to negate
10297 the result.
10299 @Example
10300 .nr xxx 1
10301 .ie !r xxx \
10302 true
10303 .el \
10304 false
10305     @result{} false
10306 @endExample
10308 A whitespace after @samp{!} always evaluates to zero (this bizarre
10309 behaviour is due to compatibility with @acronym{UNIX} @code{troff}).
10311 @Example
10312 .nr xxx 1
10313 .ie ! r xxx \
10314 true
10315 .el \
10316 false
10317     @result{} r xxx true
10318 @endExample
10320 It is possible to omit the whitespace before the argument to the
10321 @samp{r}, @samp{d}, and @samp{c} operators.
10323 @xref{Expressions}.
10325 @c ---------------------------------------------------------------------
10327 @node if-else, while, Operators in Conditionals, Conditionals and Loops
10328 @subsection if-else
10329 @cindex if-else
10331 @code{gtroff} has if-then-else constructs like other languages, although
10332 the formatting can be painful.
10334 @Defreq {if, expr anything}
10336 Evaluate the expression @var{expr}, and executes @var{anything} (the
10337 remainder of the line) if @var{expr} evaluates to a value greater than
10338 zero (true).  @var{anything} is interpreted as though it was on a line
10339 by itself (except that leading spaces are swallowed).
10340 @xref{Expressions}, for more info.
10342 @Example
10343 .nr xxx 1
10344 .nr yyy 2
10345 .if ((\n[xxx] == 1) & (\n[yyy] == 2)) true
10346     @result{} true
10347 @endExample
10348 @endDefreq
10350 @Defreq{nop, anything}
10351 Executes @var{anything}.
10352 This is similar to @code{.if@tie{}1}.
10353 @endDefreq
10355 @DefreqList {ie, expr anything}
10356 @DefreqListEnd {el, anything}
10357 Use the @code{ie} and @code{el} requests to write an if-then-else.
10358 The first request is the `if' part and the latter is the `else' part.
10360 @Example
10361 .ie n .ls 2 \" double-spacing in nroff
10362 .el   .ls 1 \" single-spacing in troff
10363 @endExample
10364 @endDefreq
10366 @c there is a bug in makeinfo <= 4.1a: you can't have `@{' as an argument
10367 @c to @deffn
10369 @c and in 4.2 you still can't use @{ in macros.
10371 @c @DefescList {\@{, , , }
10372 @c @DefescListEnd {\@}, , , }
10373 @deffn Escape @t{\@{}
10374 @deffnx Escape @t{\@}}
10375 @esindex \@{
10376 @esindex \@}
10377 @cindex begin of conditional block (@code{\@{})
10378 @cindex end of conditional block (@code{\@}})
10379 @cindex conditional block, begin (@code{\@{})
10380 @cindex conditional block, end (@code{\@}})
10381 @cindex block, conditional, begin (@code{\@{})
10382 @cindex block, condititional, end (@code{\@}})
10383 In many cases, an if (or if-else) construct needs to execute more than
10384 one request.  This can be done using the @code{\@{} and @code{\@}}
10385 escapes.  The following example shows the possible ways to use these
10386 escapes (note the position of the opening and closing braces).
10388 @Example
10389 .ie t \@{\
10390 .    ds lq ``
10391 .    ds rq ''
10392 .\@}
10393 .el \
10394 .\@{\
10395 .    ds lq "
10396 .    ds rq "\@}
10397 @endExample
10398 @c @endDefesc
10399 @end deffn
10401 @xref{Expressions}.
10403 @c ---------------------------------------------------------------------
10405 @node while,  , if-else, Conditionals and Loops
10406 @subsection while
10407 @cindex while
10409 @code{gtroff} provides a looping construct using the @code{while}
10410 request, which is used much like the @code{if} (and related) requests.
10412 @Defreq {while, expr anything}
10413 Evaluate the expression @var{expr}, and repeatedly execute
10414 @var{anything} (the remainder of the line) until @var{expr} evaluates
10415 to@tie{}0.
10417 @Example
10418 .nr a 0 1
10419 .while (\na < 9) \@{\
10420 \n+a,
10421 .\@}
10422 \n+a
10423     @result{} 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
10424 @endExample
10426 Some remarks.
10428 @cindex @code{de} request, and @code{while}
10429 @itemize @bullet
10430 @item
10431 The body of a @code{while} request is treated like the body of a
10432 @code{de} request: @code{gtroff} temporarily stores it in a macro
10433 which is deleted after the loop has been exited.  It can considerably
10434 slow down a macro if the body of the @code{while} request (within the
10435 macro) is large.  Each time the macro is executed, the @code{while}
10436 body is parsed and stored again as a temporary macro.
10438 @Example
10439 .de xxx
10440 .  nr num 10
10441 .  while (\\n[num] > 0) \@{\
10442 .    \" many lines of code
10443 .    nr num -1
10444 .  \@}
10446 @endExample
10448 @cindex recursive macros
10449 @cindex macros, recursive
10450 @noindent
10451 The traditional and ofter better solution (@acronym{UNIX} @code{troff}
10452 doesn't have the @code{while} request) is to use a recursive macro
10453 instead which is parsed only once during its definition.
10455 @Example
10456 .de yyy
10457 .  if (\\n[num] > 0) \@{\
10458 .    \" many lines of code
10459 .    nr num -1
10460 .    yyy
10461 .  \@}
10464 .de xxx
10465 .  nr num 10
10466 .  yyy
10468 @endExample
10470 @noindent
10471 Note that the number of available recursion levels is set to@tie{}1000
10472 (this is a compile-time constant value of @code{gtroff}).
10474 @item
10475 The closing brace of a @code{while} body must end a line.
10477 @Example
10478 .if 1 \@{\
10479 .  nr a 0 1
10480 .  while (\n[a] < 10) \@{\
10481 .    nop \n+[a]
10482 .\@}\@}
10483     @result{} unbalanced \@{ \@}
10484 @endExample
10485 @end itemize
10486 @endDefreq
10488 @Defreq {break, }
10489 @cindex @code{while} request, confusing with @code{br}
10490 @cindex @code{break} request, in a @code{while} loop
10491 @cindex @code{continue} request, in a @code{while} loop
10492 Break out of a @code{while} loop.  Be sure not to confuse this with
10493 the @code{br} request (causing a line break).
10494 @endDefreq
10496 @Defreq {continue, }
10497 Finish the current iteration of a @code{while} loop, immediately
10498 restarting the next iteration.
10499 @endDefreq
10501 @xref{Expressions}.
10504 @c =====================================================================
10506 @node Writing Macros, Page Motions, Conditionals and Loops, gtroff Reference
10507 @section Writing Macros
10508 @cindex writing macros
10509 @cindex macros, writing
10511 A @dfn{macro} is a collection of text and embedded commands which can
10512 be invoked multiple times.  Use macros to define common operations.
10514 @DefreqList {de, name [@Var{end}]}
10515 @DefreqItem {de1, name [@Var{end}]}
10516 @DefreqItem {dei, name [@Var{end}]}
10517 @DefreqListEnd {dei1, name [@Var{end}]}
10518 Define a new macro named @var{name}.  @code{gtroff} copies subsequent
10519 lines (starting with the next one) into an internal buffer until it
10520 encounters the line @samp{..} (two dots).  The optional second
10521 argument to @code{de} changes this to a macro to @samp{.@var{end}}.
10523 There can be whitespace after the first dot in the line containing the
10524 ending token (either @samp{.} or macro @samp{@var{end}}).
10526 Here a small example macro called @samp{P} which causes a break and
10527 inserts some vertical space.  It could be used to separate paragraphs.
10529 @Example
10530 .de P
10531 .  br
10532 .  sp .8v
10534 @endExample
10536 The following example defines a macro within another.  Remember that
10537 expansion must be protected twice; once for reading the macro and
10538 once for executing.
10540 @Example
10541 \# a dummy macro to avoid a warning
10542 .de end
10545 .de foo
10546 .  de bar end
10547 .    nop \f[B]Hallo \\\\$1!\f[]
10548 .  end
10551 .foo
10552 .bar Joe
10553     @result{} @b{Hallo Joe!}
10554 @endExample
10556 @noindent
10557 Since @code{\f} has no expansion, it isn't necessary to protect its
10558 backslash.  Had we defined another macro within @code{bar} which takes
10559 a parameter, eight backslashes would be necessary before @samp{$1}.
10561 The @code{de1} request turns off compatibility mode
10562 while executing the macro.  On entry, the current compatibility mode
10563 is saved and restored at exit.
10565 @Example
10566 .nr xxx 12345
10568 .de aa
10569 The value of xxx is \\n[xxx].
10571 .de1 bb
10572 The value of xxx ix \\n[xxx].
10575 .cp 1
10578     @result{} warning: number register `[' not defined
10579     @result{} The value of xxx is 0xxx].
10581     @result{} The value of xxx ix 12345.
10582 @endExample
10584 The @code{dei} request defines a macro indirectly.
10585 That is, it expands strings whose names
10586 are @var{name} or @var{end} before performing the append.
10588 This:
10590 @Example
10591 .ds xx aa
10592 .ds yy bb
10593 .dei xx yy
10594 @endExample
10596 @noindent
10597 is equivalent to:
10599 @Example
10600 .de aa bb
10601 @endExample
10603 The @code{dei1} request is similar to @code{dei} but with compatibility
10604 mode switched off during execution of the defined macro.
10606 If compatibility mode is on, @code{de} (and @code{dei}) behave similar to
10607 @code{de1} (and @code{dei1}): A `compatibility save' token is inserted at
10608 the beginning, and a `compatibility restore' token at the end, with
10609 compatibility mode switched on during execution.  @xref{Gtroff Internals},
10610 for more information on switching compatibility mode on and off in a
10611 single document.
10613 @pindex trace.tmac
10614 Using @file{trace.tmac}, you can trace calls to @code{de} and @code{de1}.
10616 Note that macro identifiers are shared with identifiers for strings and
10617 diversions.
10618 @endDefreq
10620 @DefreqList {am, name [@Var{end}]}
10621 @DefreqItem {am1, name [@Var{end}]}
10622 @DefreqItem {ami, name [@Var{end}]}
10623 @DefreqListEnd {ami1, name [@Var{end}]}
10624 @cindex appending to a macro (@code{am})
10625 @cindex macro, appending (@code{am})
10626 Works similarly to @code{de} except it appends onto the macro named
10627 @var{name}.  So, to make the previously defined @samp{P} macro actually
10628 do indented instead of block paragraphs, add the necessary code to the
10629 existing macro like this:
10631 @Example
10632 .am P
10633 .ti +5n
10635 @endExample
10637 The @code{am1} request turns off compatibility mode
10638 while executing the appended macro piece.  To be more precise, a
10639 @dfn{compatibility save} input token is inserted at the beginning of
10640 the appended code, and a @dfn{compatibility restore} input token at
10641 the end.
10643 The @code{ami} request appends indirectly,
10644 meaning that @code{gtroff} expands strings whose names
10645 are @var{name} or @var{end} before performing the append.
10647 The @code{ami1} request is similar to @code{ami} but compatibility mode
10648 is switched off during execution of the defined macro.
10650 @pindex trace.tmac
10651 Using @file{trace.tmac}, you can trace calls to @code{am} and @code{am1}.
10652 @endDefreq
10654 @xref{Strings}, for the @code{als} request to rename a macro.
10656 The @code{de}, @code{am}, @code{di}, @code{da}, @code{ds}, and
10657 @code{as} requests (together with its variants) only create a new object
10658 if the name of the macro, diversion or string diversion is currently
10659 undefined or if it is defined to be a request; normally they modify the
10660 value of an existing object.
10662 @Defreq {return, [@Var{anything}]}
10663 Exit a macro, immediately returning to the caller.
10665 If called with an argument, exit twice, namely the current macro and the
10666 macro one level higher.  This is used to define a wrapper macro for
10667 @code{return} in @file{trace.tmac}.
10668 @endDefreq
10670 @menu
10671 * Copy-in Mode::
10672 * Parameters::
10673 @end menu
10675 @c ---------------------------------------------------------------------
10677 @node Copy-in Mode, Parameters, Writing Macros, Writing Macros
10678 @subsection Copy-in Mode
10679 @cindex copy-in mode
10680 @cindex mode, copy-in
10682 @cindex @code{\n}, when reading text for a macro
10683 @cindex @code{\$}, when reading text for a macro
10684 @cindex @code{\*}, when reading text for a macro
10685 @cindex @code{\\}, when reading text for a macro
10686 @cindex \@key{RET}, when reading text for a macro
10687 When @code{gtroff} reads in the text for a macro, string, or diversion,
10688 it copies the text (including request lines, but excluding escapes) into
10689 an internal buffer.  Escapes are converted into an internal form,
10690 except for @code{\n}, @code{\$}, @code{\*}, @code{\\} and
10691 @code{\@key{RET}} which are evaluated and inserted into the text where
10692 the escape was located.  This is known as @dfn{copy-in} mode or
10693 @dfn{copy} mode.
10695 What this means is that you can specify when these escapes are to be
10696 evaluated (either at copy-in time or at the time of use) by insulating
10697 the escapes with an extra backslash.  Compare this to the @code{\def}
10698 and @code{\edef} commands in @TeX{}.
10700 The following example prints the numbers 20 and@tie{}10:
10702 @Example
10703 .nr x 20
10704 .de y
10705 .nr x 10
10706 \&\nx
10707 \&\\nx
10710 @endExample
10712 @c ---------------------------------------------------------------------
10714 @node Parameters,  , Copy-in Mode, Writing Macros
10715 @subsection Parameters
10716 @cindex parameters
10718 The arguments to a macro or string can be examined using a variety of
10719 escapes.
10721 @Defreg {.$}
10722 @cindex number of arguments register (@code{.$})
10723 The number of arguments passed to a macro or string.  This is a read-only
10724 number register.
10726 Note that the @code{shift} request can change its value.
10727 @endDefreg
10729 Any individual argument can be retrieved with one of the following
10730 escapes:
10732 @DefescList {\\$, , n, }
10733 @DefescItem {\\$, @lparen{}, nn, }
10734 @DefescListEnd {\\$, @lbrack{}, nnn, @rbrack{}}
10735 @cindex copy-in mode, and macro arguments
10736 @cindex macro, arguments (@code{\$})
10737 @cindex arguments, macro (@code{\$})
10738 Retrieve the @var{n}@dmn{th}, @var{nn}@dmn{th} or @var{nnn}@dmn{th}
10739 argument.  As usual, the first form only accepts a single number
10740 (larger than zero), the second a two-digit number (larger or equal
10741 to@tie{}10), and the third any positive integer value (larger
10742 than zero).  Macros and strings can have an unlimited number of arguments.
10743 Note that due to copy-in mode, use two backslashes on these in actual use
10744 to prevent interpolation until the macro is actually invoked.
10745 @endDefesc
10747 @Defreq {shift, [@Var{n}]}
10748 Shift the arguments 1@tie{}position, or as
10749 many positions as specified by its argument.  After executing this
10750 request, argument@tie{}@var{i} becomes argument @math{@var{i}-@var{n}};
10751 arguments 1 to@tie{}@var{n} are no longer available.  Shifting by
10752 negative amounts is currently undefined.
10754 The register @code{.$} is adjusted accordingly.
10755 @endDefreq
10757 @DefescList {\\$*, , , }
10758 @DefescListEnd {\\$@@, , , }
10759 In some cases it is convenient to use all of the arguments at once (for
10760 example, to pass the arguments along to another macro).  The @code{\$*}
10761 escape concatenates all the arguments separated by spaces.  A
10762 similar escape is @code{\$@@}, which concatenates all the
10763 arguments with each surrounded by double quotes, and separated by
10764 spaces.  If not in compatibility mode, the input level of double quotes
10765 is preserved (see @ref{Request and Macro Arguments}).
10766 @endDefesc
10768 @Defesc {\\$0, , , }
10769 @cindex macro name register (@code{\$0})
10770 @cindex @code{als} request, and @code{\$0}
10771 The name used to invoke the current macro.
10772 The @code{als} request can make a macro have more than one name.
10774 @Example
10775 .de generic-macro
10776 .  ...
10777 .  if \\n[error] \@{\
10778 .    tm \\$0: Houston, we have a problem.
10779 .    return
10780 .  \@}
10783 .als foo generic-macro
10784 .als bar generic-macro
10785 @endExample
10786 @endDefesc
10788 @xref{Request and Macro Arguments}.
10791 @c =====================================================================
10793 @node Page Motions, Drawing Requests, Writing Macros, gtroff Reference
10794 @section Page Motions
10795 @cindex page motions
10796 @cindex motions, page
10798 @xref{Manipulating Spacing}, for a discussion of the main request for
10799 vertical motion, @code{sp}.
10801 @DefreqList {mk, [@Var{reg}]}
10802 @DefreqListEnd {rt, [@Var{dist}]}
10803 @cindex marking vertical page location (@code{mk})
10804 @cindex page location, vertical, marking (@code{mk})
10805 @cindex location, vertical, page, marking (@code{mk})
10806 @cindex vertical page location, marking (@code{mk})
10807 @cindex returning to marked vertical page location (@code{rt})
10808 @cindex page location, vertical, returning to marked (@code{rt})
10809 @cindex location, vertical, page, returning to marked (@code{rt})
10810 @cindex vertical page location, returning to marked (@code{rt})
10811 The request @code{mk} can be used to mark a location on a page, for
10812 movement to later.  This request takes a register name as an argument
10813 in which to store the current page location.  With no argument it
10814 stores the location in an internal register.  The results of this can
10815 be used later by the @code{rt} or the @code{sp} request (or the
10816 @code{\v} escape).
10818 The @code{rt} request returns @emph{upwards} to the location marked
10819 with the last @code{mk} request.  If used with an argument, return to
10820 a position which distance from the top of the page is @var{dist} (no
10821 previous call to @code{mk} is necessary in this case).  Default scaling
10822 indicator is @samp{v}.
10824 Here a primitive solution for a two-column macro.
10826 @Example
10827 .nr column-length 1.5i
10828 .nr column-gap 4m
10829 .nr bottom-margin 1m
10831 @endExample
10832 @Example
10833 .de 2c
10834 .  br
10835 .  mk
10836 .  ll \\n[column-length]u
10837 .  wh -\\n[bottom-margin]u 2c-trap
10838 .  nr right-side 0
10841 @endExample
10842 @Example
10843 .de 2c-trap
10844 .  ie \\n[right-side] \@{\
10845 .    nr right-side 0
10846 .    po -(\\n[column-length]u + \\n[column-gap]u)
10847 .    \" remove trap
10848 .    wh -\\n[bottom-margin]u
10849 .  \@}
10850 .  el \@{\
10851 .    \" switch to right side
10852 .    nr right-side 1
10853 .    po +(\\n[column-length]u + \\n[column-gap]u)
10854 .    rt
10855 .  \@}
10858 @endExample
10859 @Example
10860 .pl 1.5i
10861 .ll 4i
10862 This is a small test which shows how the
10863 rt request works in combination with mk.
10866 Starting here, text is typeset in two columns.
10867 Note that this implementation isn't robust
10868 and thus not suited for a real two-column
10869 macro.
10870 @endExample
10872 Result:
10874 @Example
10875 This is a small test which shows how the
10876 rt request works in combination with mk.
10878 Starting  here,    isn't    robust
10879 text is typeset    and   thus  not
10880 in two columns.    suited  for   a
10881 Note that  this    real two-column
10882 implementation     macro.
10883 @endExample
10884 @endDefreq
10886 The following escapes give fine control of movements about the page.
10888 @Defesc {\\v, ', e, '}
10889 @cindex vertical motion (@code{\v})
10890 @cindex motion, vertical (@code{\v})
10891 Move vertically, usually from the current location on the page (if no
10892 absolute position operator @samp{|} is used).  The
10893 argument@tie{}@var{e} specifies the distance to move; positive is
10894 downwards and negative upwards.  The default scaling indicator for this
10895 escape is @samp{v}.  Beware, however, that @code{gtroff} continues text
10896 processing at the point where the motion ends, so you should always
10897 balance motions to avoid interference with text processing.
10899 @code{\v} doesn't trigger a trap.  This can be quite useful; for example,
10900 consider a page bottom trap macro which prints a marker in the margin to
10901 indicate continuation of a footnote or something similar.
10902 @endDefesc
10904 There are some special-case escapes for vertical motion.
10906 @Defesc {\\r, , , }
10907 Move upwards@tie{}1@dmn{v}.
10908 @endDefesc
10910 @Defesc {\\u, , , }
10911 Move upwards@tie{}.5@dmn{v}.
10912 @endDefesc
10914 @Defesc {\\d, , , }
10915 Move down@tie{}.5@dmn{v}.
10916 @endDefesc
10918 @Defesc {\\h, ', e, '}
10919 @cindex inserting horizontal space (@code{\h})
10920 @cindex horizontal space (@code{\h})
10921 @cindex space, horizontal (@code{\h})
10922 @cindex horizontal motion (@code{\h})
10923 @cindex motion, horizontal (@code{\h})
10924 Move horizontally, usually from the current location (if no absolute
10925 position operator @samp{|} is used).  The expression@tie{}@var{e}
10926 indicates how far to move: positive is rightwards and negative
10927 leftwards.  The default scaling indicator for this escape is @samp{m}.
10929 This horizontal space is not discarded at the end of a line.  To insert
10930 discardable space of a certain length use the @code{ss} request.
10931 @endDefesc
10933 There are a number of special-case escapes for horizontal motion.
10935 @Defesc {\\@key{SP}, , , }
10936 @cindex space, unbreakable
10937 @cindex unbreakable space
10938 An unbreakable and unpaddable (i.e.@: not expanded during filling)
10939 space.  (Note: This is a backslash followed by a space.)
10940 @endDefesc
10942 @Defesc {\\~, , , }
10943 An unbreakable space that stretches like a normal inter-word space
10944 when a line is adjusted.
10945 @endDefesc
10947 @Defesc {\\|, , , }
10948 A 1/6@dmn{th} em space.  Ignored for TTY output devices (rounded to
10949 zero).
10950 @endDefesc
10952 @Defesc {\\^, , , }
10953 A 1/12@dmn{th} em space.  Ignored for TTY output devices (rounded to
10954 zero).
10955 @endDefesc
10957 @Defesc {\\0, , , }
10958 @cindex space, width of a digit (@code{\0})
10959 @cindex digit width space (@code{\0})
10960 A space the size of a digit.
10961 @endDefesc
10963 The following string sets the @TeX{} logo:
10965 @Example
10966 .ds TeX T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
10967 @endExample
10969 @DefescList {\\w, ', text, '}
10970 @DefregItem {st}
10971 @DefregItem {sb}
10972 @DefregItem {rst}
10973 @DefregItem {rsb}
10974 @DefregItem {ct}
10975 @DefregItem {ssc}
10976 @DefregListEnd {skw}
10977 @cindex width escape (@code{\w})
10978 Return the width of the specified @var{text} in basic units.
10979 This allows horizontal movement based on the width of some
10980 arbitrary text (e.g.@: given as an argument to a macro).
10982 @Example
10983 The length of the string `abc' is \w'abc'u.
10984     @result{} The length of the string `abc' is 72u.
10985 @endExample
10987 Font changes may occur in @var{text} which don't affect current
10988 settings.
10990 After use, @code{\w} sets several registers:
10992 @table @code
10993 @item st
10994 @itemx sb
10995 The highest and lowest point of the baseline, respectively, in @var{text}.
10997 @item rst
10998 @itemx rsb
10999 Like the @code{st} and @code{sb} registers, but takes account of the
11000 heights and depths of glyphs.  With other words, this gives the
11001 highest and lowest point of @var{text}.  Values below the baseline are
11002 negative.
11004 @item ct
11005 Defines the kinds of glyphs occurring in @var{text}:
11007 @table @asis
11008 @item 0
11009 only short glyphs, no descenders or tall glyphs.
11011 @item 1
11012 at least one descender.
11014 @item 2
11015 at least one tall glyph.
11017 @item 3
11018 at least one each of a descender and a tall glyph.
11019 @end table
11021 @item ssc
11022 The amount of horizontal space (possibly negative) that should be added
11023 to the last glyph before a subscript.
11025 @item skw
11026 How far to right of the center of the last glyph in the @code{\w}
11027 argument, the center of an accent from a roman font should be placed
11028 over that glyph.
11029 @end table
11030 @endDefesc
11032 @DefescList {\\k, , p, }
11033 @DefescItem {\\k, @lparen{}, ps, }
11034 @DefescListEnd {\\k, @lbrack{}, position, @rbrack}
11035 @cindex saving horizontal input line position (@code{\k})
11036 @cindex horizontal input line position, saving (@code{\k})
11037 @cindex input line position, horizontal, saving (@code{\k})
11038 @cindex position, horizontal input line, saving (@code{\k})
11039 @cindex line, input, horizontal position, saving (@code{\k})
11040 Store the current horizontal position in the @emph{input} line in
11041 number register with name @var{position} (one-character name@tie{}@var{p},
11042 two-character name @var{ps}).  Use this, for example, to return to the
11043 beginning of a string for highlighting or other decoration.
11044 @endDefesc
11046 @Defreg {hp}
11047 @cindex horizontal input line position register (@code{hp})
11048 @cindex input line, horizontal position, register (@code{hp})
11049 @cindex position, horizontal, in input line, register (@code{hp})
11050 @cindex line, input, horizontal position, register (@code{hp})
11051 The current horizontal position at the input line.
11052 @endDefreg
11054 @Defreg {.k}
11055 @cindex horizontal output line position register (@code{.k})
11056 @cindex output line, horizontal position, register (@code{.k})
11057 @cindex position, horizontal, in output line, register (@code{.k})
11058 @cindex line, output, horizontal position, register (@code{.k})
11059 A read-only number register containing the current horizontal output
11060 position (relative to the current indentation).
11061 @endDefreg
11063 @Defesc {\\o, ', abc, '}
11064 @cindex overstriking glyphs (@code{\o})
11065 @cindex glyphs, overstriking (@code{\o})
11066 Overstrike glyphs @var{a}, @var{b}, @var{c}, @dots{}; the glyphs
11067 are centered, and the resulting spacing is the largest width of the
11068 affected glyphs.
11069 @endDefesc
11071 @Defesc {\\z, , g, , }
11072 @cindex zero-width printing (@code{\z}, @code{\Z})
11073 @cindex printing, zero-width (@code{\z}, @code{\Z})
11074 Print glyph @var{g} with zero width, i.e., without spacing.  Use
11075 this to overstrike glyphs left-aligned.
11076 @endDefesc
11078 @Defesc {\\Z, ', anything, '}
11079 @cindex zero-width printing (@code{\z}, @code{\Z})
11080 @cindex printing, zero-width (@code{\z}, @code{\Z})
11081 Print @var{anything}, then restore the horizontal and vertical position.
11082 The argument may not contain tabs or leaders.
11084 The following is an example of a strike-through macro:
11086 @Example
11087 .de ST
11088 .nr ww \w'\\$1'
11089 \Z@@\v'-.25m'\l'\\n[ww]u'@@\\$1
11092 This is
11093 .ST "a test"
11094 an actual emergency!
11095 @endExample
11096 @endDefesc
11099 @c =====================================================================
11101 @node Drawing Requests, Traps, Page Motions, gtroff Reference
11102 @section Drawing Requests
11103 @cindex drawing requests
11104 @cindex requests for drawing
11106 @code{gtroff} provides a number of ways to draw lines and other figures
11107 on the page.  Used in combination with the page motion commands (see
11108 @ref{Page Motions}, for more info), a wide variety of figures can be
11109 drawn.  However, for complex drawings these operations can be quite
11110 cumbersome, and it may be wise to use graphic preprocessors like
11111 @code{gpic} or @code{ggrn}.  @xref{gpic}, and @ref{ggrn}, for more
11112 information.
11114 All drawing is done via escapes.
11116 @DefescList {\\l, ', l, '}
11117 @DefescListEnd {\\l, ', lg, '}
11118 @cindex drawing horizontal lines (@code{\l})
11119 @cindex horizontal line, drawing (@code{\l})
11120 @cindex line, horizontal, drawing (@code{\l})
11121 Draw a line horizontally.  @var{l} is the length of the line to be
11122 drawn.  If it is positive, start the line at the current location and
11123 draw to the right; its end point is the new current location.  Negative
11124 values are handled differently: The line starts at the current location
11125 and draws to the left, but the current location doesn't move.
11127 @var{l} can also be specified absolutely (i.e.@: with a leading
11128 @samp{|}) which draws back to the beginning of the input line.
11129 Default scaling indicator is @samp{m}.
11131 @cindex underscore glyph (@code{\[ru]})
11132 @cindex glyph, underscore (@code{\[ru]})
11133 @cindex line drawing glyph
11134 @cindex glyph, for line drawing
11135 The optional second parameter@tie{}@var{g} is a glyph to draw the line
11136 with.  If this second argument is not specified, @code{gtroff} uses
11137 the underscore glyph, @code{\[ru]}.
11139 @cindex zero width space character (@code{\&})
11140 @cindex character, zero width space (@code{\&})
11141 @cindex space character, zero width (@code{\&})
11142 To separate the two arguments (to prevent @code{gtroff} from
11143 interpreting a drawing glyph as a scaling indicator if the glyph is
11144 represented by a single character) use @code{\&}.
11146 Here a small useful example:
11148 @Example
11149 .de box
11150 \[br]\\$*\[br]\l'|0\[rn]'\l'|0\[ul]'
11152 @endExample
11154 @noindent
11155 Note that this works by outputting a box rule (a vertical line), then
11156 the text given as an argument and then another box rule.  Finally, the
11157 line drawing escapes both draw from the current location to the
11158 beginning of the @emph{input} line -- this works because the line
11159 length is negative, not moving the current point.
11160 @endDefesc
11162 @DefescList {\\L, ', l, '}
11163 @DefescListEnd {\\L, ', lg, '}
11164 @cindex drawing vertical lines (@code{\L})
11165 @cindex vertical line drawing (@code{\L})
11166 @cindex line, vertical, drawing (@code{\L})
11167 @cindex line drawing glyph
11168 @cindex glyph for line drawing
11169 @cindex box rule glyph (@code{\[br]})
11170 @cindex glyph, box rule (@code{\[br]})
11171 Draw vertical lines.  Its parameters are
11172 similar to the @code{\l} escape, except that the default scaling
11173 indicator is @samp{v}.  The movement is downwards for positive values,
11174 and upwards for negative values.  The default glyph is the box rule
11175 glyph, @code{\[br]}.  As with the vertical motion escapes, text
11176 processing blindly continues where the line ends.
11178 @Example
11179 This is a \L'3v'test.
11180 @endExample
11182 @noindent
11183 Here the result, produced with @code{grotty}.
11185 @Example
11186 This is a
11187           |
11188           |
11189           |test.
11190 @endExample
11191 @endDefesc
11193 @Defesc {\\D, ', command arg @dots{}, '}
11194 The @code{\D} escape provides a variety of drawing functions.
11195 Note that on character devices, only vertical and horizontal lines are
11196 supported within @code{grotty}; other devices may only support a subset
11197 of the available drawing functions.
11199 The default scaling indicator for all subcommands of @code{\D} is
11200 @samp{m} for horizontal distances and @samp{v} for vertical ones.
11201 Exceptions are @w{@code{\D'f @dots{}'}} and @w{@code{\D't @dots{}'}}
11202 which use @code{u} as the default, and @w{@code{\D'F@var{x} @dots{}'}}
11203 which arguments are treated similar to the @code{defcolor} request.
11205 @table @code
11206 @item \D'l @var{dx} @var{dy}'
11207 @cindex line, drawing (@w{@code{\D'l @dots{}'}})
11208 @cindex drawing a line (@w{@code{\D'l @dots{}'}})
11209 Draw a line from the current location to the relative point specified by
11210 (@var{dx},@var{dy}), where positive values mean down and right,
11211 respectively.  The end point of the line is the new current location.
11213 The following example is a macro for creating a box around a text string;
11214 for simplicity, the box margin is taken as a fixed value, 0.2@dmn{m}.
11216 @Example
11217 .de BOX
11218 .  nr @@wd \w'\\$1'
11219 \h'.2m'\
11220 \h'-.2m'\v'(.2m - \\n[rsb]u)'\
11221 \D'l 0 -(\\n[rst]u - \\n[rsb]u + .4m)'\
11222 \D'l (\\n[@@wd]u + .4m) 0'\
11223 \D'l 0 (\\n[rst]u - \\n[rsb]u + .4m)'\
11224 \D'l -(\\n[@@wd]u + .4m) 0'\
11225 \h'.2m'\v'-(.2m - \\n[rsb]u)'\
11226 \\$1\
11227 \h'.2m'
11229 @endExample
11231 @noindent
11232 First, the width of the string is stored in register @code{@@wd}.  Then,
11233 four lines are drawn to form a box, properly offset by the box margin.
11234 The registers @code{rst} and @code{rsb} are set by the @code{\w} escape,
11235 containing the largest height and depth of the whole string.
11237 @item \D'c @var{d}'
11238 @cindex circle, drawing (@w{@code{\D'c @dots{}'}})
11239 @cindex drawing a circle (@w{@code{\D'c @dots{}'}})
11240 Draw a circle with a diameter of@tie{}@var{d} with the leftmost point at the
11241 current position.  After drawing, the current location is positioned at the
11242 rightmost point of the circle.
11244 @item \D'C @var{d}'
11245 @cindex circle, solid, drawing (@w{@code{\D'C @dots{}'}})
11246 @cindex drawing a solid circle (@w{@code{\D'C @dots{}'}})
11247 @cindex solid circle, drawing (@w{@code{\D'C @dots{}'}})
11248 Draw a solid circle with the same parameters and behaviour as an outlined
11249 circle.  No outline is drawn.
11251 @item \D'e @var{x} @var{y}'
11252 @cindex drawing an ellipse (@w{@code{\D'e @dots{}'}})
11253 @cindex ellipse, drawing (@w{@code{\D'e @dots{}'}})
11254 Draw an ellipse with a horizontal diameter of @var{x} and a vertical
11255 diameter of @var{y} with the leftmost point at the current position.
11256 After drawing, the current location is positioned at the rightmost point of
11257 the ellipse.
11259 @item \D'E @var{x} @var{y}'
11260 @cindex ellipse, solid, drawing (@w{@code{\D'E @dots{}'}})
11261 @cindex drawing a solid ellipse (@w{@code{\D'E @dots{}'}})
11262 @cindex solid ellipse, drawing (@w{@code{\D'E @dots{}'}})
11263 Draw a solid ellipse with the same parameters and behaviour as an
11264 outlined ellipse.  No outline is drawn.
11266 @item \D'a @var{dx1} @var{dy1} @var{dx2} @var{dy2}'
11267 @cindex arc, drawing (@w{@code{\D'a @dots{}'}})
11268 @cindex drawing an arc (@w{@code{\D'a @dots{}'}})
11269 Draw an arc clockwise from the current location through the two
11270 specified relative locations (@var{dx1},@var{dy1}) and
11271 (@var{dx2},@var{dy2}).  The coordinates of the first point are relative
11272 to the current position, and the coordinates of the second point are
11273 relative to the first point.  After drawing, the current position is moved
11274 to the final point of the arc.
11276 @item \D'~ @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
11277 @cindex drawing a spline (@w{@code{\D'~ @dots{}'}})
11278 @cindex spline, drawing (@w{@code{\D'~ @dots{}'}})
11279 Draw a spline from the current location to the relative point
11280 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}), and so on.
11281 The current position is moved to the terminal point of the drawn curve.
11283 @item \D'f @var{n}'
11284 @cindex gray shading (@w{@code{\D'f @dots{}'}})
11285 @cindex shading filled objects (@w{@code{\D'f @dots{}'}})
11286 Set the shade of gray to be used for filling solid objects to@tie{}@var{n};
11287 @var{n}@tie{}must be an integer between 0 and@tie{}1000, where 0
11288 corresponds solid white and 1000 to solid black, and values in between
11289 correspond to intermediate shades of gray.  This applies only to solid
11290 circles, solid ellipses, and solid polygons.  By default, a level of
11291 1000 is used.
11293 Despite of being silly, the current point is moved horizontally to the
11294 right by@tie{}@var{n}.
11296 @cindex @w{@code{\D'f @dots{}'}} and horizontal resolution
11297 Don't use this command!  It has the serious drawback that it will be
11298 always rounded to the next integer multiple of the horizontal resolution
11299 (the value of the @code{hor} keyword in the @file{DESC} file).  Use
11300 @code{\M} (@pxref{Colors}) or @w{@code{\D'Fg @dots{}'}} instead.
11302 @item \D'p @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
11303 @cindex drawing a polygon (@w{@code{\D'p @dots{}'}})
11304 @cindex polygon, drawing (@w{@code{\D'p @dots{}'}})
11305 Draw a polygon from the current location to the relative position
11306 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}) and so on.
11307 When the specified data points are exhausted, a line is drawn back
11308 to the starting point.  The current position is changed by adding the
11309 sum of all arguments with odd index to the actual horizontal position and
11310 the even ones to the vertical position.
11312 @item \D'P @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
11313 @cindex polygon, solid, drawing (@w{@code{\D'P @dots{}'}})
11314 @cindex drawing a solid polygon (@w{@code{\D'P @dots{}'}})
11315 @cindex solid polygon, drawing (@w{@code{\D'P @dots{}'}})
11316 Draw a solid polygon with the same parameters and behaviour as an
11317 outlined polygon.  No outline is drawn.
11319 Here a better variant of the box macro to fill the box with some color.
11320 Note that the box must be drawn before the text since colors in
11321 @code{gtroff} are not transparent; the filled polygon would hide the
11322 text completely.
11324 @Example
11325 .de BOX
11326 .  nr @@wd \w'\\$1'
11327 \h'.2m'\
11328 \h'-.2m'\v'(.2m - \\n[rsb]u)'\
11329 \M[lightcyan]\
11330 \D'P 0 -(\\n[rst]u - \\n[rsb]u + .4m) \
11331      (\\n[@@wd]u + .4m) 0 \
11332      0 (\\n[rst]u - \\n[rsb]u + .4m) \
11333      -(\\n[@@wd]u + .4m) 0'\
11334 \h'.2m'\v'-(.2m - \\n[rsb]u)'\
11335 \M[]\
11336 \\$1\
11337 \h'.2m'
11339 @endExample
11341 @item \D't @var{n}'
11342 @cindex line thickness (@w{@code{\D't @dots{}'}})
11343 @cindex thickness of lines (@w{@code{\D't @dots{}'}})
11344 Set the current line thickness to @var{n}@tie{}machine units.  A value of
11345 zero selects the smallest available line thickness.  A negative value
11346 makes the line thickness proportional to the current point size (this is
11347 the default behaviour of @acronym{AT&T} @code{troff}).
11349 Despite of being silly, the current point is moved horizontally to the
11350 right by@tie{}@var{n}.
11352 @item \D'F@var{scheme} @var{color_components}'
11353 @cindex unnamed fill colors (@code{\D'F@dots{}'})
11354 @cindex fill colors, unnamed (@code{\D'F@dots{}'})
11355 @cindex colors, fill, unnamed (@code{\D'F@dots{}'})
11356 Change current fill color.  @var{scheme} is a single letter denoting the
11357 color scheme: @samp{r} (rgb), @samp{c} (cmy), @samp{k} (cmyk), @samp{g}
11358 (gray), or @samp{d} (default color).  The color components use exactly
11359 the same syntax as in the @code{defcolor} request (@pxref{Colors}); the
11360 command @code{\D'Fd'} doesn't take an argument.
11362 @emph{No} position changing!
11364 Examples:
11366 @Example
11367 @endExample
11368 \D'Fg .3'      \" same gray as \D'f 700'
11369 \D'Fr #0000ff' \" blue
11370 @end table
11371 @endDefesc
11373 @xref{Graphics Commands}.
11375 @Defesc {\\b, ', string, '}
11376 @cindex pile, glyph (@code{\b})
11377 @cindex glyph pile (@code{\b})
11378 @cindex stacking glyphs (@code{\b})
11379 @dfn{Pile} a sequence of glyphs vertically, and center it vertically
11380 on the current line.  Use it to build large brackets and braces.
11382 Here an example how to create a large opening brace:
11384 @Example
11385 \b'\[lt]\[bv]\[lk]\[bv]\[lb]'
11386 @endExample
11388 @cindex @code{\b}, limitations
11389 @cindex limitations of @code{\b} escape
11390 The first glyph is on the top, the last glyph in @var{string} is
11391 at the bottom.  Note that @code{gtroff} separates the glyphs
11392 vertically by 1@dmn{m}, and the whole object is centered 0.5@dmn{m}
11393 above the current baseline; the largest glyph width is used as the
11394 width for the whole object.  This rather unflexible positioning
11395 algorithm doesn't work with @option{-Tdvi} since the bracket pieces vary
11396 in height for this device.  Instead, use the @code{eqn} preprocessor.
11398 @xref{Manipulating Spacing}, how to adjust the vertical spacing with
11399 the @code{\x} escape.
11400 @endDefesc
11403 @c =====================================================================
11405 @node Traps, Diversions, Drawing Requests, gtroff Reference
11406 @section Traps
11407 @cindex traps
11409 @dfn{Traps} are locations, which, when reached, call a specified
11410 macro.  These traps can occur at a given location on the page, at a
11411 given location in the current diversion, at a blank line,
11412 after a certain number of input lines, or at the end of input.
11414 @cindex planting a trap
11415 @cindex trap, planting
11416 Setting a trap is also called @dfn{planting}.
11417 @cindex trap, springing
11418 @cindex springing a trap
11419 It is also said that a trap is @dfn{sprung} if the associated macro
11420 is executed.
11422 @menu
11423 * Page Location Traps::
11424 * Diversion Traps::
11425 * Input Line Traps::
11426 * Blank Line Traps::
11427 * End-of-input Traps::
11428 @end menu
11430 @c ---------------------------------------------------------------------
11432 @node Page Location Traps, Diversion Traps, Traps, Traps
11433 @subsection Page Location Traps
11434 @cindex page location traps
11435 @cindex traps, page location
11437 @dfn{Page location traps} perform an action when @code{gtroff}
11438 reaches or passes a certain vertical location on the page.  Page
11439 location traps have a variety of purposes, including:
11441 @itemize
11442 @item
11443 setting headers and footers
11445 @item
11446 setting body text in multiple columns
11448 @item
11449 setting footnotes
11450 @end itemize
11452 @DefreqList {vpt, flag}
11453 @DefregListEnd {.vpt}
11454 @cindex enabling vertical position traps (@code{vpt})
11455 @cindex vertical position traps, enabling (@code{vpt})
11456 @cindex vertical position trap enable register (@code{.vpt})
11457 Enable vertical position traps if @var{flag} is non-zero, or disables
11458 them otherwise.  Vertical position traps are traps set by the @code{wh}
11459 or @code{dt} requests.  Traps set by the @code{it} request are not
11460 vertical position traps.  The parameter that controls whether vertical
11461 position traps are enabled is global.  Initially vertical position traps
11462 are enabled.  The current setting of this is available in the
11463 @code{.vpt} read-only number register.
11465 Note that a page can't be ejected if @code{vpt} is set to zero.
11466 @endDefreq
11468 @Defreq {wh, dist [@Var{macro}]}
11469 Set a page location trap.  Non-negative values for @var{dist} set
11470 the trap relative to the top of the page; negative values set
11471 the trap relative to the bottom of the page.  Default scaling
11472 indicator is @samp{v}.
11474 @var{macro} is the name of the macro to execute when the
11475 trap is sprung.  If @var{macro} is missing, remove the first trap
11476 (if any) at @var{dist}.
11478 @cindex page headers
11479 @cindex page footers
11480 @cindex headers
11481 @cindex footers
11482 The following is a simple example of how many macro packages
11483 set headers and footers.
11485 @Example
11486 .de hd                \" Page header
11487 '  sp .5i
11488 .  tl 'Title''date'
11489 '  sp .3i
11492 .de fo                \" Page footer
11493 '  sp 1v
11494 .  tl ''%''
11495 '  bp
11498 .wh 0   hd            \" trap at top of the page
11499 .wh -1i fo            \" trap one inch from bottom
11500 @endExample
11502 A trap at or below the bottom of the page is ignored; it can be made
11503 active by either moving it up or increasing the page length so that the
11504 trap is on the page.
11506 It is possible to have more than one trap at the same location; to do so,
11507 the traps must be defined at different locations, then moved together with
11508 the @code{ch} request; otherwise the second trap would replace the first
11509 one.  Earlier defined traps hide later defined traps if moved to the same
11510 position (the many empty lines caused by the @code{bp} request are omitted
11511 in the following example):
11513 @Example
11514 .de a
11515 .  nop a
11517 .de b
11518 .  nop b
11520 .de c
11521 .  nop c
11524 .wh 1i a
11525 .wh 2i b
11526 .wh 3i c
11528     @result{} a b c
11529 @endExample
11530 @Example
11531 .ch b 1i
11532 .ch c 1i
11534     @result{} a
11535 @endExample
11536 @Example
11537 .ch a 0.5i
11539     @result{} a b
11540 @endExample
11541 @endDefreq
11543 @Defreg {.t}
11544 @cindex distance to next trap register (@code{.t})
11545 @cindex trap, distance, register (@code{.t})
11546 A read-only number register holding the distance to the next trap.
11548 If there are no traps between the current position and the bottom of the
11549 page, it contains the distance to the page bottom.  In a diversion, the
11550 distance to the page bottom is infinite (the returned value is the biggest
11551 integer which can be represented in @code{groff}) if there are no diversion
11552 traps.
11553 @endDefreg
11555 @Defreq {ch, macro [@Var{dist}]}
11556 @cindex changing trap location (@code{ch})
11557 @cindex trap, changing location (@code{ch})
11558 Change the location of a trap.
11559 The first argument is the name of the macro to be invoked at
11560 the trap, and the second argument is the new location for the trap
11561 (note that the parameters are specified in opposite order as in the
11562 @code{wh} request).  This is useful for building up footnotes in a
11563 diversion to allow more space at the bottom of the page for them.
11565 Default scaling indicator for @var{dist} is @samp{v}.  If @var{dist}
11566 is missing, the trap is removed.
11568 @c XXX
11570 @ignore
11571 @Example
11572 ... (simplified) footnote example ...
11573 @endExample
11574 @end ignore
11575 @endDefreq
11577 @Defreg {.ne}
11578 The read-only number register @code{.ne} contains the amount of space
11579 that was needed in the last @code{ne} request that caused a trap to be
11580 sprung.  Useful in conjunction with the @code{.trunc} register.
11581 @xref{Page Control}, for more information.
11583 Since the @code{.ne} register is only set by traps it doesn't make
11584 much sense to use it outside of trap macros.
11585 @endDefreg
11587 @Defreg {.trunc}
11588 @cindex @code{ne} request, and the @code{.trunc} register
11589 @cindex truncated vertical space register (@code{.trunc})
11590 A read-only register containing the amount of vertical space truncated
11591 by the most recently sprung vertical position trap, or, if the trap was
11592 sprung by an @code{ne} request, minus the amount of vertical motion
11593 produced by the @code{ne} request.  In other words, at the point a trap
11594 is sprung, it represents the difference of what the vertical position
11595 would have been but for the trap, and what the vertical position
11596 actually is.
11598 Since the @code{.trunc} register is only set by traps it doesn't make
11599 much sense to use it outside of trap macros.
11600 @endDefreg
11602 @Defreg {.pe}
11603 @cindex @code{bp} request, and traps (@code{.pe})
11604 @cindex traps, sprung by @code{bp} request (@code{.pe})
11605 @cindex page ejecting register (@code{.pe})
11606 A read-only register which is set to@tie{}1 while a page is ejected with
11607 the @code{bp} request (or by the end of input).
11609 Outside of traps this register is always zero.  In the following example,
11610 only the second call to@tie{}@code{x} is caused by @code{bp}.
11612 @Example
11613 .de x
11614 \&.pe=\\n[.pe]
11617 .wh 1v x
11618 .wh 4v x
11619 A line.
11621 Another line.
11623     @result{} A line.
11624        .pe=0
11625        Another line.
11627        .pe=1
11628 @endExample
11629 @endDefreg
11631 @cindex diversions, and traps
11632 @cindex traps, and diversions
11633 An important fact to consider while designing macros is that diversions and
11634 traps do not interact normally.  For example, if a trap invokes a header
11635 macro (while outputting a diversion) which tries to change the font on the
11636 current page, the effect will not be visible before the diversion has
11637 completely been printed (except for input protected with @code{\!} or
11638 @code{\?}) since the data in the diversion is already formatted.  In most
11639 cases, this is not the expected behaviour.
11641 @c ---------------------------------------------------------------------
11643 @node Diversion Traps, Input Line Traps, Page Location Traps, Traps
11644 @subsection Diversion Traps
11645 @cindex diversion traps
11646 @cindex traps, diversion
11648 @Defreq {dt, [@Var{dist} @Var{macro}]}
11649 @cindex @code{.t} register, and diversions
11650 @cindex setting diversion trap (@code{dt})
11651 @cindex diversion trap, setting (@code{dt})
11652 @cindex trap, diversion, setting (@code{dt})
11653 Set a trap @emph{within} a diversion.
11654 @var{dist} is the location of the trap
11655 (identical to the @code{wh} request; default scaling indicator is
11656 @samp{v}) and @var{macro} is the name of the macro to be invoked.
11657 If called without arguments, the diversion trap is removed.
11659 Note that there exists only a single diversion trap.
11661 The number register @code{.t} still works within diversions.
11662 @xref{Diversions}, for more information.
11663 @endDefreq
11665 @c ---------------------------------------------------------------------
11667 @node Input Line Traps, Blank Line Traps, Diversion Traps, Traps
11668 @subsection Input Line Traps
11669 @cindex input line traps
11670 @cindex traps, input line
11672 @DefreqList {it, n macro}
11673 @DefreqItem {itc, n macro}
11674 @cindex setting input line trap (@code{it})
11675 @cindex input line trap, setting (@code{it})
11676 @cindex trap, input line, setting (@code{it})
11677 Set an input line trap.
11678 @var{n}@tie{}is the number of lines of input which may be read before
11679 springing the trap, @var{macro} is the macro to be invoked.
11680 Request lines are not counted as input lines.
11682 For example, one possible use is to have a macro which prints the
11683 next @var{n}@tie{}lines in a bold font.
11685 @Example
11686 .de B
11687 .  it \\$1 B-end
11688 .  ft B
11691 .de B-end
11692 .  ft R
11694 @endExample
11696 @cindex input line traps and interrupted lines (@code{itc})
11697 @cindex interrupted lines and input line traps (@code{itc})
11698 @cindex traps, input line, and interrupted lines (@code{itc})
11699 @cindex lines, interrupted, and input line traps (@code{itc})
11700 The @code{itc} request is identical
11701 except that an interrupted text line (ending with @code{\c})
11702 is not counted as a separate line.
11704 Both requests are associated with the current environment
11705 (@pxref{Environments}); switching to another environment disables the
11706 current input trap, and going back reactivates it, restoring the number
11707 of already processed lines.
11708 @endDefreq
11710 @c ---------------------------------------------------------------------
11712 @node Blank Line Traps, End-of-input Traps, Input Line Traps, Traps
11713 @subsection Blank Line Traps
11714 @cindex blank line traps
11715 @cindex traps, blank line
11717 @Defreq {blm, macro}
11718 @cindex blank line macro (@code{blm})
11719 Set a blank line trap.
11720 @code{gtroff} executes @var{macro} when it encounters a blank line in
11721 the input file.
11722 @endDefreq
11724 @c ---------------------------------------------------------------------
11726 @node End-of-input Traps,  , Blank Line Traps, Traps
11727 @subsection End-of-input Traps
11728 @cindex end-of-input traps
11729 @cindex traps, end-of-input
11731 @Defreq {em, macro}
11732 @cindex setting end-of-input trap (@code{em})
11733 @cindex end-of-input trap, setting (@code{em})
11734 @cindex trap, end-of-input, setting (@code{em})
11735 @cindex end-of-input macro (@code{em})
11736 @cindex macro, end-of-input (@code{em})
11737 Set a trap at the end of input.  @var{macro} is executed after the
11738 last line of the input file has been processed.
11740 For example, if the document had to have a section at the bottom of the
11741 last page for someone to approve it, the @code{em} request could be
11742 used.
11744 @Example
11745 .de approval
11746 .  ne 5v
11747 .  sp |(\\n[.t] - 6v)
11748 .  in +4i
11749 .  lc _
11750 .  br
11751 Approved:\t\a
11752 .  sp
11753 Date:\t\t\a
11756 .em approval
11757 @endExample
11758 @endDefreq
11761 @c =====================================================================
11763 @node Diversions, Environments, Traps, gtroff Reference
11764 @section Diversions
11765 @cindex diversions
11767 In @code{gtroff} it is possible to @dfn{divert} text into a named
11768 storage area.  Due to the similarity to defining macros it is sometimes
11769 said to be stored in a macro.  This is used for saving text for output
11770 at a later time, which is useful for keeping blocks of text on the same
11771 page, footnotes, tables of contents, and indices.
11773 @cindex top-level diversion
11774 @cindex diversion, top-level
11775 For orthogonality it is said that @code{gtroff} is in the @dfn{top-level
11776 diversion} if no diversion is active (i.e., the data is diverted to the
11777 output device).
11779 @DefreqList {di, macro}
11780 @DefreqListEnd {da, macro}
11781 @cindex beginning diversion (@code{di})
11782 @cindex diversion, beginning (@code{di})
11783 @cindex ending diversion (@code{di})
11784 @cindex diversion, ending (@code{di})
11785 @cindex appending to a diversion (@code{da})
11786 @cindex diversion, appending (@code{da})
11787 Begin a diversion.  Like the @code{de}
11788 request, it takes an argument of a macro name to divert subsequent text
11789 into.  The @code{da} macro appends to an existing diversion.
11791 @code{di} or @code{da} without an argument ends the diversion.
11792 @endDefreq
11794 @DefreqList {box, macro}
11795 @DefreqListEnd {boxa, macro}
11796 Begin (or appends to) a diversion like the
11797 @code{di} and @code{da} requests.
11798 The difference is that @code{box} and @code{boxa}
11799 do not include a partially-filled line in the diversion.
11801 Compare this:
11803 @Example
11804 Before the box.
11805 .box xxx
11806 In the box.
11808 .box
11809 After the box.
11811     @result{} Before the box.  After the box.
11812 .xxx
11813     @result{} In the box.
11814 @endExample
11816 @noindent
11817 with this:
11819 @Example
11820 Before the diversion.
11821 .di yyy
11822 In the diversion.
11825 After the diversion.
11827     @result{} After the diversion.
11828 .yyy
11829     @result{} Before the diversion.  In the diversion.
11830 @endExample
11832 @code{box} or @code{boxa} without an argument ends the diversion.
11833 @endDefreq
11835 @DefregList {.z}
11836 @DefregListEnd {.d}
11837 @cindex @code{nl} register, and @code{.d}
11838 @cindex nested diversions
11839 @cindex diversion, nested
11840 @cindex diversion name register (@code{.z})
11841 @cindex vertical position in diversion register (@code{.d})
11842 @cindex position, vertical, in diversion, register (@code{.d})
11843 @cindex diversion, vertical position in, register (@code{.d})
11844 Diversions may be nested.  The read-only number register @code{.z}
11845 contains the name of the current diversion (this is a string-valued
11846 register).  The read-only number register @code{.d} contains the current
11847 vertical place in the diversion.  If not in a diversion it is the same
11848 as register @code{nl}.
11849 @endDefreg
11851 @Defreg {.h}
11852 @cindex high-water mark register (@code{.h})
11853 @cindex mark, high-water, register (@code{.h})
11854 @cindex position of lowest text line (@code{.h})
11855 @cindex text line, position of lowest (@code{.h})
11856 The @dfn{high-water mark} on the current page.  It corresponds to the
11857 text baseline of the lowest line on the page.  This is a read-only
11858 register.
11860 @Example
11861 .tm .h==\n[.h], nl==\n[nl]
11862     @result{} .h==0, nl==-1
11863 This is a test.
11865 .sp 2
11866 .tm .h==\n[.h], nl==\n[nl]
11867     @result{} .h==40, nl==120
11868 @endExample
11870 @cindex @code{.h} register, difference to @code{nl}
11871 @cindex @code{nl} register, difference to @code{.h}
11872 @noindent
11873 As can be seen in the previous example, empty lines are not considered
11874 in the return value of the @code{.h} register.
11875 @endDefreg
11877 @DefregList {dn}
11878 @DefregListEnd {dl}
11879 @cindex @code{dn} register, and @code{da} (@code{boxa})
11880 @cindex @code{dl} register, and @code{da} (@code{boxa})
11881 @cindex @code{da} request, and @code{dn} (@code{dl})
11882 @cindex @code{boxa} request, and @code{dn} (@code{dl})
11883 After completing a diversion, the read-write number registers @code{dn}
11884 and @code{dl} contain the vertical and horizontal size of the diversion.
11885 Note that only the just processed lines are counted: For the computation
11886 of @code{dn} and @code{dl}, the requests @code{da} and @code{boxa} are
11887 handled as if @code{di} and @code{box} had been used -- lines which have
11888 been already stored in a macro are not taken into account.
11890 @Example
11891 .\" Center text both horizontally & vertically
11893 .\" Enclose macro definitions in .eo and .ec
11894 .\" to avoid the doubling of the backslash
11896 .\" macro .(c starts centering mode
11897 .de (c
11898 .  br
11899 .  ev (c
11900 .  evc 0
11901 .  in 0
11902 .  nf
11903 .  di @@c
11905 @endExample
11906 @Example
11907 .\" macro .)c terminates centering mode
11908 .de )c
11909 .  br
11910 .  ev
11911 .  di
11912 .  nr @@s (((\n[.t]u - \n[dn]u) / 2u) - 1v)
11913 .  sp \n[@@s]u
11914 .  ce 1000
11915 .  @@c
11916 .  ce 0
11917 .  sp \n[@@s]u
11918 .  br
11919 .  fi
11920 .  rr @@s
11921 .  rm @@s
11922 .  rm @@c
11924 .\" End of macro definitions, restore escape mechanism
11926 @endExample
11927 @endDefreg
11929 @DefescList {\\!, , , }
11930 @DefescListEnd {\\?, , anything, \\?}
11931 @cindex transparent output (@code{\!}, @code{\?})
11932 @cindex output, transparent (@code{\!}, @code{\?})
11933 Prevent requests, macros, and escapes from being
11934 interpreted when read into a diversion.  Both escapes take the given text
11935 and @dfn{transparently} embed it into the diversion.  This is useful for
11936 macros which shouldn't be invoked until the diverted text is actually
11937 output.
11939 The @code{\!} escape transparently embeds text up to
11940 and including the end of the line.
11941 The @code{\?} escape transparently embeds text until the next
11942 occurrence of the @code{\?} escape.  Example:
11944 @Example
11945 \?@var{anything}\?
11946 @endExample
11948 @noindent
11949 @var{anything} may not contain newlines; use @code{\!}  to embed
11950 newlines in a diversion.  The escape sequence @code{\?} is also
11951 recognized in copy mode and turned into a single internal code; it is
11952 this code that terminates @var{anything}.  Thus the following example
11953 prints@tie{}4.
11955 @Example
11956 .nr x 1
11958 .di d
11959 \?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
11961 .nr x 2
11962 .di e
11965 .nr x 3
11966 .di f
11969 .nr x 4
11971 @endExample
11973 Both escapes read the data in copy mode.
11975 @cindex @code{\!}, in top-level diversion
11976 @cindex top-level diversion, and @code{\!}
11977 @cindex diversion, top-level, and @code{\!}
11978 If @code{\!} is used in the top-level diversion, its argument is
11979 directly embedded into the @code{gtroff} intermediate output.  This can
11980 be used for example to control a postprocessor which processes the data
11981 before it is sent to the device driver.
11983 @cindex @code{\?}, in top-level diversion
11984 @cindex top-level diversion, and @code{\?}
11985 @cindex diversion, top-level, and @code{\?}
11986 The @code{\?} escape used in the top-level diversion produces no output
11987 at all; its argument is simply ignored.
11988 @endDefesc
11990 @cindex @code{\!}, and @code{output}
11991 @cindex @code{output} request, and @code{\!}
11992 @Defreq {output, string}
11993 Emit @var{string} directly to the @code{gtroff} intermediate output
11994 (subject to copy-mode interpretation); this is similar to @code{\!} used
11995 at the top level.  An initial double quote in @var{string} is stripped off
11996 to allow initial blanks.
11998 This request can't be used before the first page has started -- if you get
11999 an error, simply insert @code{.br} before the @code{output} request.
12001 Without argument, @code{output} is ignored.
12003 Use with caution!  It is normally only needed for mark-up used by a
12004 postprocessor which does something with the output before sending it to
12005 the output device, filtering out @var{string} again.
12006 @endDefreq
12008 @Defreq {asciify, div}
12009 @cindex unformatting diversions (@code{asciify})
12010 @cindex diversion, unformatting (@code{asciify})
12011 @cindex @code{trin} request, and @code{asciify}
12012 @dfn{Unformat} the diversion specified by @var{div}
12013 in such a way that @acronym{ASCII} characters, characters translated with
12014 the @code{trin} request, space characters, and some escape sequences that
12015 were formatted and diverted are treated like ordinary input
12016 characters when the diversion is reread.  It can be also used for gross
12017 hacks; for example, the following sets register@tie{}@code{n} to@tie{}1.
12019 @Example
12020 .tr @@.
12021 .di x
12022 @@nr n 1
12025 .tr @@@@
12026 .asciify x
12028 @endExample
12030 @xref{Copy-in Mode}.
12031 @endDefreq
12033 @Defreq {unformat, div}
12034 Like @code{asciify}, unformat the specified diversion.
12035 However, @code{unformat} only unformats spaces and tabs
12036 between words.
12037 Unformatted tabs are treated as input tokens,
12038 and spaces are stretchable again.
12040 The vertical size of lines is not preserved; glyph information (font,
12041 font size, space width, etc.)@: is retained.
12042 @endDefreq
12045 @c =====================================================================
12047 @node Environments, Suppressing output, Diversions, gtroff Reference
12048 @section Environments
12049 @cindex environments
12051 It happens frequently that some text should be printed in a certain
12052 format regardless of what may be in effect at the time, for example, in
12053 a trap invoked macro to print headers and footers.  To solve this
12054 @code{gtroff} processes text in @dfn{environments}.  An
12055 environment contains most of the parameters that control text
12056 processing.  It is possible to switch amongst these environments; by
12057 default @code{gtroff} processes text in environment@tie{}0.  The
12058 following is the information kept in an environment.
12060 @itemize @bullet
12061 @item
12062 font parameters (size, family, style, glyph height and slant, space
12063 and sentence space size)
12065 @item
12066 page parameters (line length, title length, vertical spacing,
12067 line spacing, indentation, line numbering, centering, right-justifying,
12068 underlining, hyphenation data)
12070 @item
12071 fill and adjust mode
12073 @item
12074 tab stops, tab and leader characters, escape character,
12075 no-break and hyphen indicators, margin character data
12077 @item
12078 partially collected lines
12080 @item
12081 input traps
12083 @item
12084 drawing and fill colours
12085 @end itemize
12087 These environments may be given arbitrary names (see @ref{Identifiers},
12088 for more info).  Old versions of @code{troff} only had environments
12089 named @samp{0}, @samp{1}, and @samp{2}.
12091 @DefreqList {ev, [@Var{env}]}
12092 @DefregListEnd {.ev}
12093 @cindex switching environments (@code{ev})
12094 @cindex environment, switching (@code{ev})
12095 @cindex environment number/name register (@code{.ev})
12096 Switch to another environment.  The argument @var{env} is the name of
12097 the environment to switch to.  With no argument, @code{gtroff} switches
12098 back to the previous environment.  There is no limit on the number of
12099 named environments; they are created the first time that they are
12100 referenced.  The @code{.ev} read-only register contains the name or
12101 number of the current environment.  This is a string-valued register.
12103 Note that a call to @code{ev} (with argument) pushes the previously
12104 active environment onto a stack.  If, say, environments @samp{foo},
12105 @samp{bar}, and @samp{zap} are called (in that order), the first
12106 @code{ev} request without parameter switches back to environment
12107 @samp{bar} (which is popped off the stack), and a second call
12108 switches back to environment @samp{foo}.
12110 Here is an example:
12112 @Example
12113 .ev footnote-env
12114 .fam N
12115 .ps 6
12116 .vs 8
12117 .ll -.5i
12122 .ev footnote-env
12123 \(dg Note the large, friendly letters.
12125 @endExample
12126 @endDefreq
12128 @Defreq {evc, env}
12129 @cindex copying environment (@code{evc})
12130 @cindex environment, copying (@code{evc})
12131 Copy the environment @var{env} into the current environment.
12133 The following environment data is not copied:
12135 @itemize @bullet
12136 @item
12137 Partially filled lines.
12139 @item
12140 The status whether the previous line was interrupted.
12142 @item
12143 The number of lines still to center, or to right-justify, or to underline
12144 (with or without underlined spaces); they are set to zero.
12146 @item
12147 The status whether a temporary indent is active.
12149 @item
12150 Input traps and its associated data.
12152 @item
12153 Line numbering mode is disabled; it can be reactivated with
12154 @w{@samp{.nm +0}}.
12156 @item
12157 The number of consecutive hyphenated lines (set to zero).
12158 @end itemize
12159 @endDefreq
12161 @DefregList {.w}
12162 @DefregItem {.cht}
12163 @DefregItem {.cdp}
12164 @DefregListEnd {.csk}
12165 @cindex environment, dimensions of last glyph (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
12166 @cindex width, of last glyph (@code{.w})
12167 @cindex height, of last glyph (@code{.cht})
12168 @cindex depth, of last glyph (@code{.cdp})
12169 @cindex skew, of last glyph (@code{.csk})
12170 @cindex last glyph, dimensions (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
12171 @cindex glyph, last, dimensions (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
12172 The @code{\n[.w]} register contains the
12173 width of the last glyph added to the current environment.
12175 The @code{\n[.cht]} register contains the
12176 height of the last glyph added to the current environment.
12178 The @code{\n[.cdp]} register contains the
12179 depth of the last glyph added to the current environment.
12180 It is positive for glyphs extending below the baseline.
12182 The @code{\n[.csk]} register contains the
12183 @dfn{skew} (how far to the right of the glyph's center
12184 that @code{gtroff} should place an accent)
12185 of the last glyph added to the current environment.
12186 @endDefreg
12188 @Defreg {.n}
12189 @cindex environment, previous line length (@code{.n})
12190 @cindex line length, previous (@code{.n})
12191 @cindex length of previous line (@code{.n})
12192 @cindex previous line length (@code{.n})
12193 The @code{\n[.n]} register contains the
12194 length of the previous output line in the current environment.
12195 @endDefreg
12198 @c =====================================================================
12200 @node Suppressing output, Colors, Environments, gtroff Reference
12201 @section Suppressing output
12203 @Defesc {\\O, , num, }
12204 @cindex suppressing output (@code{\O})
12205 @cindex output, suppressing (@code{\O})
12206 Disable or enable output depending on the value of @var{num}:
12208 @table @samp
12209 @item \O0
12210 Disable any glyphs from being emitted to the device driver, provided that
12211 the escape occurs at the outer level (see @code{\O[3]} and @code{\O[4]}).
12212 Motion is not suppressed so effectively @code{\O[0]} means @emph{pen up}.
12214 @item \O1
12215 Enable output of glyphs, provided that the escape occurs at the outer
12216 level.
12217 @end table
12219 @vindex opminx
12220 @vindex opminy
12221 @vindex opmaxx
12222 @vindex opmaxy
12223 @code{\O0} and @code{\O1} also reset the four registers @samp{opminx},
12224 @samp{opminy}, @samp{opmaxx}, and @samp{opmaxy} to @minus{}1.
12225 @xref{Register Index}.  These four registers mark the top left and
12226 bottom right hand corners of a box which encompasses all written glyphs.
12228 For example the input text:
12230 @Example
12231 Hello \O[0]world \O[1]this is a test.
12232 @endExample
12234 @noindent
12235 produces the following output:
12237 @Example
12238 Hello       this is a test.
12239 @endExample
12241 @table @samp
12242 @item \O2
12243 Provided that the escape occurs at the outer level, enable output of
12244 glyphs and also write out to @code{stderr} the page number and four
12245 registers encompassing the glyphs previously written since the last call
12246 to @code{\O}.
12248 @item \O3
12249 Begin a nesting level.  At start-up, @code{gtroff} is at outer level.
12251 @item \O4
12252 End a nesting level.
12254 @item \O[5@var{P}@var{filename}]
12255 This escape is @code{grohtml} specific.  Provided that this escape
12256 occurs at the outer nesting level write the @code{filename} to
12257 @code{stderr}.  The position of the image, @var{P}, must be specified
12258 and must be one of @code{l}, @code{r}, @code{c}, or@tie{}@code{i} (left,
12259 right, centered, inline).  @var{filename} will be associated with the
12260 production of the next inline image.
12261 @end table
12262 @endDefesc
12264 @c =====================================================================
12266 @node Colors, I/O, Suppressing output, gtroff Reference
12267 @section Colors
12268 @cindex colors
12270 @DefreqList {color, [@Var{n}]}
12271 @DefregListEnd {.color}
12272 If @var{n} is missing or non-zero, activate colors (this is the default);
12273 otherwise, turn it off.
12275 The read-only number register @code{.color} is@tie{}1 if colors are active,
12276 0@tie{}otherwise.
12278 Internally, @code{color} sets a global flag; it does not produce a token.
12279 Similar to the @code{cp} request, you should use it at the beginning of
12280 your document to control color output.
12282 Colors can be also turned off with the @option{-c} command line option.
12283 @endDefreq
12285 @Defreq {defcolor, ident scheme color_components}
12286 Define color with name @var{ident}.  @var{scheme} can be one of  the
12287 following values: @code{rgb} (three components), @code{cmy} (three
12288 components), @code{cmyk} (four components), and @code{gray} or
12289 @code{grey} (one component).
12291 @cindex default color
12292 @cindex color, default
12293 Color components can be given either as a hexadecimal string or as
12294 positive decimal integers in the range 0--65535.  A hexadecimal string
12295 contains all color components concatenated.  It must start with either
12296 @code{#} or @code{##}; the former specifies hex values in the range
12297 0--255 (which are internally multiplied by@tie{}257), the latter in the
12298 range 0--65535.  Examples: @code{#FFC0CB} (pink), @code{##ffff0000ffff}
12299 (magenta).  The default color name @c{default} can't be redefined; its
12300 value is device-specific (usually black).  It is possible that the
12301 default color for @code{\m} and @code{\M} is not identical.
12303 @cindex @code{f} unit, and colors
12304 @cindex unit, @code{f}, and colors
12305 A new scaling indicator@tie{}@code{f} has been introduced which multiplies
12306 its value by 65536; this makes it convenient to specify color components
12307 as fractions in the range 0 to@tie{}1 (1f equals 65536u).  Example:
12309 @Example
12310 .defcolor darkgreen rgb 0.1f 0.5f 0.2f
12311 @endExample
12313 Note that @code{f} is the default scaling indicator for the
12314 @code{defcolor} request, thus the above statement is equivalent to
12316 @Example
12317 .defcolor darkgreen rgb 0.1 0.5 0.2
12318 @endExample
12319 @endDefreq
12321 @DefreqList {gcolor, [@Var{color}]}
12322 @DefescItem {\\m, , c, }
12323 @DefescItem {\\m, @lparen{}, co, }
12324 @DefescItem {\\m, @lbrack{}, color, @rbrack}
12325 @DefregListEnd {.m}
12326 Set (glyph) drawing color.  The following examples show how to turn the
12327 next four words red.
12329 @Example
12330 .gcolor red
12331 these are in red
12332 .gcolor
12333 and these words are in black.
12334 @endExample
12336 @Example
12337 \m[red]these are in red\m[] and these words are in black.
12338 @endExample
12340 The escape @code{\m[]} returns to the previous color, as does a call to
12341 @code{gcolor} without an argument.
12343 @cindex drawing color name register (@code{.m})
12344 @cindex name, drawing color, register (@code{.m})
12345 @cindex color name, drawing, register (@code{.m})
12346 The name of the current drawing color is available in the read-only,
12347 string-valued number register @samp{.m}.
12349 The drawing color is associated with the current environment
12350 (@pxref{Environments}).
12352 Note that @code{\m} doesn't produce an input token in @code{gtroff}.
12353 As a consequence, it can be used in requests like @code{mc} (which
12354 expects a single character as an argument) to change the color on
12355 the fly:
12357 @Example
12358 .mc \m[red]x\m[]
12359 @endExample
12360 @endDefesc
12362 @DefreqList {fcolor, [@Var{color}]}
12363 @DefescItem {\\M, , c, }
12364 @DefescItem {\\M, @lparen{}, co, }
12365 @DefescItem {\\M, @lbrack{}, color, @rbrack}
12366 @DefregListEnd {.M}
12367 Set fill (background) color for filled objects drawn with the
12368 @code{\D'@dots{}'} commands.
12370 A red ellipse can be created with the following code:
12372 @Example
12373 \M[red]\h'0.5i'\D'E 2i 1i'\M[]
12374 @endExample
12376 The escape @code{\M[]} returns to the previous fill color, as does a call to
12377 @code{fcolor} without an argument.
12379 @cindex background color name register (@code{.M})
12380 @cindex name, background color, register (@code{.M})
12381 @cindex color name, background, register (@code{.M})
12382 @cindex fill color name register (@code{.M})
12383 @cindex name, fill color, register (@code{.M})
12384 @cindex color name, fill, register (@code{.M})
12385 The name of the current fill (background) color is available in the
12386 read-only, string-valued number register @samp{.M}.
12388 The fill color is associated with the current environment
12389 (@pxref{Environments}).
12391 Note that @code{\M} doesn't produce an input token in @code{gtroff}.
12392 @endDefesc
12395 @c =====================================================================
12397 @node I/O, Postprocessor Access, Colors, gtroff Reference
12398 @section I/O
12399 @cindex i/o
12400 @cindex input and output requests
12401 @cindex requests for input and output
12402 @cindex output and input requests
12404 @code{gtroff} has several requests for including files:
12406 @Defreq {so, file}
12407 @cindex including a file (@code{so})
12408 @cindex file, inclusion (@code{so})
12409 Read in the specified @var{file} and
12410 includes it in place of the @code{so} request.  This is quite useful for
12411 large documents, e.g.@: keeping each chapter in a separate file.
12412 @xref{gsoelim}, for more information.
12414 Since @code{gtroff} replaces the @code{so} request with the contents
12415 of @code{file}, it makes a difference whether the data is terminated with
12416 a newline or not: Assuming that file @file{xxx} contains the word
12417 @samp{foo} without a final newline, this
12419 @Example
12420 This is
12421 .so xxx
12423 @endExample
12425 @noindent
12426 yields @samp{This is foobar}.
12428 The search path for @var{file} can be controlled with the @option{-I} command
12429 line option.
12430 @endDefreq
12432 @Defreq {pso, command}
12433 Read the standard output from the specified @var{command}
12434 and includes it in place of the @code{pso} request.
12436 @cindex safer mode
12437 @cindex mode, safer
12438 @cindex unsafe mode
12439 @cindex mode, unsafe
12440 This request causes an error if used in safer mode (which is the default).
12441 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
12442 mode.
12444 The comment regarding a final newline for the @code{so} request is valid
12445 for @code{pso} also.
12446 @endDefreq
12448 @Defreq {mso, file}
12449 Identical to the @code{so} request except that @code{gtroff} searches for
12450 the specified @var{file} in the same directories as macro files for the
12451 the @option{-m} command line option.  If the file name to be included
12452 has the form @file{@var{name}.tmac} and it isn't found, @code{mso} tries
12453 to include @file{tmac.@var{name}} and vice versa.
12454 @endDefreq
12456 @DefreqList {trf, file}
12457 @DefreqListEnd {cf, file}
12458 @cindex transparent output (@code{cf}, @code{trf})
12459 @cindex output, transparent (@code{cf}, @code{trf})
12460 Transparently output the contents of @var{file}.  Each line is output
12461 as if it were preceded by @code{\!}; however, the lines are not subject
12462 to copy mode interpretation.  If the file does not end with a newline,
12463 then a newline is added (@code{trf} only).  For example, to define a
12464 macro@tie{}@code{x} containing the contents of file@tie{}@file{f}, use
12466 @Example
12467 .di x
12468 .trf f
12470 @endExample
12472 Both @code{trf} and @code{cf}, when used in a diversion,
12473 embeds an object in the diversion which, when reread, causes the
12474 contents of @var{file} to be transparently copied through to the
12475 output.  In @acronym{UNIX} @code{troff}, the contents of @var{file}
12476 is immediately copied through to the output regardless of whether there
12477 is a current diversion; this behaviour is so anomalous that it must be
12478 considered a bug.
12480 @cindex @code{trf} request, and invalid characters
12481 @cindex characters, invalid for @code{trf} request
12482 @cindex invalid characters for @code{trf} request
12483 While @code{cf} copies the contents of @var{file} completely unprocessed,
12484 @code{trf} disallows characters such as NUL that are not valid
12485 @code{gtroff} input characters (@pxref{Identifiers}).
12487 Both requests cause a line break.
12488 @endDefreq
12490 @Defreq {nx, [@Var{file}]}
12491 @cindex processing next file (@code{nx})
12492 @cindex file, processing next (@code{nx})
12493 @cindex next file, processing (@code{nx})
12494 Force @code{gtroff} to continue processing of
12495 the file specified as an argument.  If no argument is given, immediately
12496 jump to the end of file.
12497 @endDefreq
12499 @Defreq {rd, [@Var{prompt} [@Var{arg1} @Var{arg2} @dots{}]]}
12500 @cindex reading from standard input (@code{rd})
12501 @cindex standard input, reading from (@code{rd})
12502 @cindex input, standard, reading from (@code{rd})
12503 Read from standard input, and include what is read as though it
12504 were part of the input file.  Text is read until a blank line
12505 is encountered.
12507 If standard input is a TTY input device (keyboard), write @var{prompt}
12508 to standard error, followed by a colon (or send BEL for a beep if no
12509 argument is given).
12511 Arguments after @var{prompt} are available for the input.  For example,
12512 the line
12514 @Example
12515 .rd data foo bar
12516 @endExample
12518 with the input @w{@samp{This is \$2.}} prints
12520 @Example
12521 This is bar.
12522 @endExample
12523 @endDefreq
12525 @cindex form letters
12526 @cindex letters, form
12527 Using the @code{nx} and @code{rd} requests,
12528 it is easy to set up form letters.  The form
12529 letter template is constructed like this, putting the following lines
12530 into a file called @file{repeat.let}:
12532 @Example
12534 \*(td
12535 .sp 2
12541 Body of letter.
12543 .nx repeat.let
12544 @endExample
12546 @cindex @code{ex} request, used with @code{nx} and @code{rd}
12547 @noindent
12548 When this is run, a file containing the following lines should be
12549 redirected in.  Note that requests included in this file are executed
12550 as though they were part of the form letter.  The last block of input
12551 is the @code{ex} request which tells @code{groff} to stop processing.  If
12552 this was not there, @code{groff} would not know when to stop.
12554 @Example
12555 Trent A. Fisher
12556 708 NW 19th Av., #202
12557 Portland, OR  97209
12559 Dear Trent,
12561 Len Adollar
12562 4315 Sierra Vista
12563 San Diego, CA  92103
12565 Dear Mr. Adollar,
12568 @endExample
12570 @Defreq {pi, pipe}
12571 Pipe the output of @code{gtroff} to the shell command(s)
12572 specified by @var{pipe}.  This request must occur before
12573 @code{gtroff} has a chance to print anything.
12575 @cindex safer mode
12576 @cindex mode, safer
12577 @cindex unsafe mode
12578 @cindex mode, unsafe
12579 @code{pi} causes an error if used in safer mode (which is the default).
12580 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
12581 mode.
12583 Multiple calls to @code{pi} are allowed, acting as a chain.  For example,
12585 @Example
12586 .pi foo
12587 .pi bar
12589 @endExample
12591 is the same as @w{@samp{.pi foo | bar}}.
12593 @cindex @code{groff}, and @code{pi} request
12594 @cindex @code{pi} request, and @code{groff}
12595 Note that the intermediate output format of @code{gtroff} is piped to
12596 the specified commands.  Consequently, calling @code{groff} without the
12597 @option{-Z} option normally causes a fatal error.
12598 @endDefreq
12600 @DefreqList {sy, cmds}
12601 @DefregListEnd {systat}
12602 Execute the shell command(s) specified by @var{cmds}.  The output is not
12603 saved anyplace, so it is up to the user to do so.
12605 @cindex safer mode
12606 @cindex mode, safer
12607 @cindex unsafe mode
12608 @cindex mode, unsafe
12609 This request causes an error if used in safer mode (which is the default).
12610 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
12611 mode.
12613 For example, the following code fragment introduces the current time into a
12614 document:
12616 @cindex time, current
12617 @cindex current time
12618 @pindex perl
12619 @Example
12620 .sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
12621              (localtime(time))[2,1,0]' > /tmp/x\n[$$]
12622 .so /tmp/x\n[$$]
12623 .sy rm /tmp/x\n[$$]
12624 \nH:\nM:\nS
12625 @endExample
12627 @noindent
12628 Note that this works by having the @code{perl} script (run by @code{sy})
12629 print out the @code{nr} requests which set the number registers
12630 @code{H}, @code{M}, and @code{S}, and then reads those commands in with
12631 the @code{so} request.
12633 For most practical purposes, the number registers @code{seconds},
12634 @code{minutes}, and @code{hours} which are initialized at start-up of
12635 @code{gtroff} should be sufficient.  Use the @code{af} request to get a
12636 formatted output:
12638 @Example
12639 .af hours 00
12640 .af minutes 00
12641 .af seconds 00
12642 \n[hours]:\n[minutes]:\n[seconds]
12643 @endExample
12645 @cindex @code{system()} return value register (@code{systat})
12646 The @code{systat} read-write number register contains the return value
12647 of the @code{system()} function executed by the last @code{sy} request.
12648 @endDefreq
12650 @DefreqList {open, stream file}
12651 @DefreqListEnd {opena, stream file}
12652 @cindex opening file (@code{open})
12653 @cindex file, opening (@code{open})
12654 @cindex appending to a file (@code{opena})
12655 @cindex file, appending to (@code{opena})
12656 Open the specified @var{file} for writing and
12657 associates the specified @var{stream} with it.
12659 The @code{opena} request is like @code{open}, but if the file exists,
12660 append to it instead of truncating it.
12662 @cindex safer mode
12663 @cindex mode, safer
12664 @cindex unsafe mode
12665 @cindex mode, unsafe
12666 Both @code{open} and @code{opena} cause an error if used in safer mode
12667 (which is the default).  Use @code{groff}'s or @code{troff}'s @option{-U}
12668 option to activate unsafe mode.
12669 @endDefreq
12671 @DefreqList {write, stream data}
12672 @DefreqListEnd {writec, stream data}
12673 @cindex copy-in mode, and @code{write} requests
12674 @cindex mode, copy-in, and @code{write} requests
12675 @cindex writing to file (@code{write})
12676 @cindex file, writing to (@code{write})
12677 Write to the file associated with the specified @var{stream}.
12678 The stream must previously have
12679 been the subject of an open request.  The remainder of the line is
12680 interpreted as the @code{ds} request reads its second argument: A
12681 leading @samp{"} is stripped, and it is read in copy-in mode.
12683 The @code{writec} request is like @code{write}, but only
12684 @code{write} appends a newline to the data.
12685 @endDefreq
12687 @Defreq {writem, stream xx}
12688 @cindex @code{asciify} request, and @code{writem}
12689 Write the contents of the macro or string @var{xx}
12690 to the file associated with the specified @var{stream}.
12692 @var{xx} is read in copy mode, i.e., already formatted elements are
12693 ignored.  Consequently, diversions must be unformatted with the
12694 @code{asciify} request before calling @code{writem}.  Usually, this
12695 means a loss of information.
12696 @endDefreq
12698 @Defreq {close, stream}
12699 @cindex closing file (@code{close})
12700 @cindex file, closing (@code{close})
12701 Close the specified @var{stream};
12702 the stream is no longer an acceptable argument to the
12703 @code{write} request.
12705 Here a simple macro to write an index entry.
12707 @Example
12708 .open idx test.idx
12710 .de IX
12711 .  write idx \\n[%] \\$*
12714 .IX test entry
12716 .close idx
12717 @endExample
12718 @endDefreq
12720 @DefescList {\\V, , e, }
12721 @DefescItem {\\V, @lparen{}, ev, }
12722 @DefescListEnd {\\V, @lbrack{}, env, @rbrack}
12723 Interpolate the contents of the specified environment variable
12724 @var{env} (one-character name@tie{}@var{e}, two-character name @var{ev})
12725 as returned by the function @code{getenv}.  @code{\V} is interpreted
12726 in copy-in mode.
12727 @endDefesc
12730 @c =====================================================================
12732 @node Postprocessor Access, Miscellaneous, I/O, gtroff Reference
12733 @section Postprocessor Access
12734 @cindex postprocessor access
12735 @cindex access of postprocessor
12737 There are two escapes which give information directly to the
12738 postprocessor.  This is particularly useful for embedding
12739 @sc{PostScript} into the final document.
12741 @Defesc {\\X, ', xxx, '}
12742 Embeds its argument into the @code{gtroff}
12743 output preceded with @w{@samp{x X}}.
12745 @cindex @code{\&}, in @code{\X}
12746 @cindex @code{\)}, in @code{\X}
12747 @cindex @code{\%}, in @code{\X}
12748 @ifnotinfo
12749 @cindex @code{\:}, in @code{\X}
12750 @end ifnotinfo
12751 @ifinfo
12752 @cindex @code{\@r{<colon>}}, in @code{\X}
12753 @end ifinfo
12754 The escapes @code{\&}, @code{\)}, @code{\%}, and @code{\:} are ignored
12755 within @code{\X}, @w{@samp{\ }} and @code{\~} are converted to single
12756 space characters.  All other escapes (except @code{\\} which produces a
12757 backslash) cause an error.
12759 @kindex use_charnames_in_special
12760 @pindex DESC@r{, and @code{use_charnames_in_special}}
12761 @cindex @code{\X}, and special characters
12762 If the @samp{use_charnames_in_special} keyword is set in the @file{DESC}
12763 file, special characters no longer cause an error; the name @var{xx} is
12764 represented as @samp{\(@var{xx})} in the @w{@samp{x X}} output command.
12765 Additionally, the backslash is represented as @code{\\}.
12767 @samp{use_charnames_in_special} is currently used by @code{grohtml} only.
12768 @endDefesc
12770 @DefescList {\\Y, , n, }
12771 @DefescItem {\\Y, @lparen{}, nm, }
12772 @DefescListEnd {\\Y, @lbrack{}, name, @rbrack}
12773 This is approximately equivalent to @samp{\X'\*[@var{name}]'}
12774 (one-character name@tie{}@var{n}, two-character name @var{nm}).
12775 However, the contents of the string or macro @var{name} are not
12776 interpreted; also it is permitted for @var{name} to have been defined
12777 as a macro and thus contain newlines (it is not permitted for the
12778 argument to @code{\X} to contain newlines).  The inclusion of
12779 newlines requires an extension to the @acronym{UNIX} @code{troff}
12780 output format, and confuses drivers that do not know about this
12781 extension (@pxref{Device Control Commands}).
12782 @endDefesc
12784 @xref{Output Devices}.
12787 @c =====================================================================
12789 @node Miscellaneous, Gtroff Internals, Postprocessor Access, gtroff Reference
12790 @section Miscellaneous
12792 This section documents parts of @code{gtroff} which cannot (yet) be
12793 categorized elsewhere in this manual.
12795 @Defreq {nm, [@Var{start} [@Var{inc} [@Var{space} [@Var{indent}]]]]}
12796 @cindex printing line numbers (@code{nm})
12797 @cindex line numbers, printing (@code{nm})
12798 @cindex numbers, line, printing (@code{nm})
12799 Print line numbers.
12800 @var{start} is the line number of the @emph{next}
12801 output line.  @var{inc} indicates which line numbers are printed.
12802 For example, the value@tie{}5 means to emit only line numbers which
12803 are multiples of@tie{}5; this defaults to@tie{}1.  @var{space} is the
12804 space to be left between the number and the text; this defaults to
12805 one digit space.  The fourth argument is the indentation of the line
12806 numbers, defaulting to zero.  Both @var{space} and @var{indent} are
12807 given as multiples of digit spaces; they can be negative also.
12808 Without any arguments, line numbers are turned off.
12810 @code{gtroff} reserves three digit spaces for the line number (which is
12811 printed right-justified) plus the amount given by @var{indent}; the
12812 output lines are concatenated to the line numbers, separated by
12813 @var{space}, and @emph{without} reducing the line length.  Depending
12814 on the value of the horizontal page offset (as set with the
12815 @code{po} request), line numbers which are longer than the reserved
12816 space stick out to the left, or the whole line is moved to the right.
12818 Parameters corresponding to missing arguments are not changed; any
12819 non-digit argument (to be more precise, any argument starting with a
12820 character valid as a delimiter for identifiers) is also treated as
12821 missing.
12823 If line numbering has been disabled with a call to @code{nm} without
12824 an argument, it can be reactivated with @samp{.nm +0}, using the
12825 previously active line numbering parameters.
12827 The parameters of @code{nm} are associated with the current environment
12828 (@pxref{Environments}).  The current output line number is available
12829 in the number register @code{ln}.
12831 @Example
12832 .po 1m
12833 .ll 2i
12834 This test shows how line numbering works with groff.
12835 .nm 999
12836 This test shows how line numbering works with groff.
12838 .nm xxx 3 2
12839 .ll -\w'0'u
12840 This test shows how line numbering works with groff.
12841 .nn 2
12842 This test shows how line numbering works with groff.
12843 @endExample
12845 @noindent
12846 And here the result:
12848 @Example
12849  This  test shows how
12850  line numbering works
12851  999 with   groff.   This
12852 1000 test shows how  line
12853 1001 numbering works with
12854 1002 groff.
12855       This test shows how
12856       line      numbering
12857  works  with  groff.
12858  This test shows how
12859 1005  line      numbering
12860       works with groff.
12861 @endExample
12862 @endDefreq
12864 @Defreq {nn, [@Var{skip}]}
12865 Temporarily turn off line numbering.  The argument is the number
12866 of lines not to be numbered; this defaults to@tie{}1.
12867 @endDefreq
12869 @Defreq {mc, glyph [@Var{dist}]}
12870 @cindex margin glyph (@code{mc})
12871 @cindex glyph, for margins (@code{mc})
12872 Print a @dfn{margin character} to the right of the
12873 text.@footnote{@dfn{Margin character} is a misnomer since it is an
12874 output glyph.}  The first argument is the glyph to be
12875 printed.  The second argument is the distance away from the right
12876 margin.  If missing, the previously set value is used; default is
12877 10@dmn{pt}).  For text lines that are too long (that is, longer than
12878 the text length plus @var{dist}), the margin character is directly
12879 appended to the lines.
12881 With no arguments the margin character is turned off.
12882 If this occurs before a break, no margin character is printed.
12884 For compatibility with @acronym{AT&T} @code{troff}, a call to @code{mc}
12885 to set the margin character can't be undone immediately; at least one
12886 line gets a margin character.  Thus
12888 @Example
12889 .ll 1i
12890 .mc \[br]
12895 @endExample
12897 @noindent
12898 produces
12900 @Example
12901 xxx        |
12903 @endExample
12905 @cindex @code{tl} request, and @code{mc}
12906 For empty lines and lines produced by the @code{tl} request no margin
12907 character is emitted.
12909 The margin character is associated with the current environment
12910 (@pxref{Environments}).
12912 @pindex nrchbar
12913 @pindex changebar
12914 This is quite useful for indicating text that has changed, and, in fact,
12915 there are programs available for doing this (they are called
12916 @code{nrchbar} and @code{changebar} and can be found in any
12917 @samp{comp.sources.unix} archive).
12919 @Example
12920 .ll 3i
12921 .mc |
12922 This paragraph is highlighted with a margin
12923 character.
12925 Note that vertical space isn't marked.
12929 But we can fake it with `\&'.
12930 @endExample
12932 Result:
12934 @Example
12935 This  paragraph is highlighted |
12936 with a margin character.       |
12938 Note that vertical space isn't |
12939 marked.                        |
12940                                |
12941 But we can fake it with `\&'.  |
12942 @endExample
12943 @endDefreq
12945 @DefreqList {psbb, filename}
12946 @DefregItem {llx}
12947 @DefregItem {lly}
12948 @DefregItem {urx}
12949 @DefregListEnd {ury}
12950 @cindex PostScript, bounding box
12951 @cindex bounding box
12952 Retrieve the bounding box of the PostScript image
12953 found in @var{filename}.
12954 The file must conform to
12955 Adobe's @dfn{Document Structuring Conventions} (DSC);
12956 the command searches for a @code{%%BoundingBox} comment
12957 and extracts the bounding box values into the number registers
12958 @code{llx}, @code{lly}, @code{urx}, and @code{ury}.
12959 If an error occurs (for example, @code{psbb} cannot find
12960 the @code{%%BoundingBox} comment),
12961 it sets the four number registers to zero.
12963 The search path for @var{filename} can be controlled with the @option{-I}
12964 command line option.
12965 @endDefreq
12968 @c =====================================================================
12970 @node Gtroff Internals, Debugging, Miscellaneous, gtroff Reference
12971 @section @code{gtroff} Internals
12973 @cindex input token
12974 @cindex token, input
12975 @cindex output node
12976 @cindex node, output
12977 @code{gtroff} processes input in three steps.  One or more input
12978 characters are converted to an @dfn{input token}.@footnote{Except the
12979 escapes @code{\f}, @code{\F}, @code{\H}, @code{\m}, @code{\M}, @code{\R},
12980 @code{\s}, and @code{\S} which are processed immediately if not in
12981 copy-in mode.}  Then, one or more input tokens are converted to an
12982 @dfn{output node}.  Finally, output nodes are converted to the
12983 intermediate output language understood by all output devices.
12985 Actually, before step one happens, @code{gtroff} converts certain
12986 escape sequences into reserved input characters (not accessible by
12987 the user); such reserved characters are used for other internal
12988 processing also -- this is the very reason why not all characters
12989 are valid input.  @xref{Identifiers}, for more on this topic.
12991 For example, the input string @samp{fi\[:u]} is converted into a
12992 character token @samp{f}, a character token @samp{i}, and a special
12993 token @samp{:u} (representing u@tie{}umlaut).  Later on, the character
12994 tokens @samp{f} and @samp{i} are merged to a single output node
12995 representing the ligature glyph @samp{fi} (provided the current font
12996 has a glyph for this ligature); the same happens with @samp{:u}.  All
12997 output glyph nodes are `processed' which means that they are invariably
12998 associated with a given font, font size, advance width, etc.  During
12999 the formatting process, @code{gtroff} itself adds various nodes to
13000 control the data flow.
13002 Macros, diversions, and strings collect elements in two chained lists:
13003 a list of input tokens which have been passed unprocessed, and a list
13004 of output nodes.  Consider the following the diversion.
13006 @Example
13007 .di xxx
13013 @endExample
13015 @noindent
13016 It contains these elements.
13018 @multitable {@i{vertical size node}} {token list} {element number}
13019 @item node list               @tab token list @tab element number
13021 @item @i{line start node}     @tab ---        @tab 1
13022 @item @i{glyph node @code{a}} @tab ---        @tab 2
13023 @item @i{word space node}     @tab ---        @tab 3
13024 @item ---                     @tab @code{b}   @tab 4
13025 @item ---                     @tab @code{\n}  @tab 5
13026 @item @i{glyph node @code{c}} @tab ---        @tab 6
13027 @item @i{vertical size node}  @tab ---        @tab 7
13028 @item @i{vertical size node}  @tab ---        @tab 8
13029 @item ---                     @tab @code{\n}  @tab 9
13030 @end multitable
13032 @cindex @code{\v}, internal representation
13033 @noindent
13034 Elements 1, 7, and@tie{}8 are inserted by @code{gtroff}; the latter two
13035 (which are always present) specify the vertical extent of the last
13036 line, possibly modified by @code{\x}.  The @code{br} request finishes
13037 the current partial line, inserting a newline input token which is
13038 subsequently converted to a space when the diversion is reread.  Note
13039 that the word space node has a fixed width which isn't stretchable
13040 anymore.  To convert horizontal space nodes back to input tokens, use
13041 the @code{unformat} request.
13043 Macros only contain elements in the token list (and the node list is
13044 empty); diversions and strings can contain elements in both lists.
13046 Note that the @code{chop} request simply reduces the number of elements in a
13047 macro, string, or diversion by one.  Exceptions are @dfn{compatibility save}
13048 and @dfn{compatibility ignore} input tokens which are ignored.  The
13049 @code{substring} request also ignores those input tokens.
13051 Some requests like @code{tr} or @code{cflags} work on glyph
13052 identifiers only; this means that the associated glyph can be changed
13053 without destroying this association.  This can be very helpful for
13054 substituting glyphs.  In the following example, we assume that
13055 glyph @samp{foo} isn't available by default, so we provide a
13056 substitution using the @code{fchar} request and map it to input
13057 character @samp{x}.
13059 @Example
13060 .fchar \[foo] foo
13061 .tr x \[foo]
13062 @endExample
13064 @noindent
13065 Now let us assume that we install an additional special font
13066 @samp{bar} which has glyph @samp{foo}.
13068 @Example
13069 .special bar
13070 .rchar \[foo]
13071 @endExample
13073 @noindent
13074 Since glyphs defined with @code{fchar} are searched before glyphs
13075 in special fonts, we must call @code{rchar} to remove the definition
13076 of the fallback glyph.  Anyway, the translation is still active;
13077 @samp{x} now maps to the real glyph @samp{foo}.
13079 @cindex compatibility mode, and parameters
13080 @cindex mode, compatibility, and parameters
13081 @cindex arguments, and compatibility mode
13082 @cindex parameters, and compatibility mode
13083 @cindex macro arguments, and compatibility mode
13084 @cindex request arguments, and compatibility mode
13085 Macro and request arguments preserve the compatibility mode:
13087 @Example
13088 .cp 1     \" switch to compatibility mode
13089 .de xx
13090 \\$1
13092 .cp 0     \" switch compatibility mode off
13093 .xx caf\['e]
13094     @result{} café
13095 @endExample
13097 @noindent
13098 Since compatibility mode is on while @code{de} is called, the macro
13099 @code{xx} activates compatibility mode while executing.  Argument
13100 @code{$1} can still be handled properly because it inherits the
13101 compatibility mode status which was active at the point where @code{xx}
13102 is called.
13104 After expansion of the parameters, the compatibility save and restore
13105 tokens are removed.
13108 @c =====================================================================
13110 @node Debugging, Implementation Differences, Gtroff Internals, gtroff Reference
13111 @section Debugging
13112 @cindex debugging
13114 @code{gtroff} is not easy to debug, but there are some useful features
13115 and strategies for debugging.
13117 @Defreq {lf, line [@Var{filename}]}
13118 @pindex soelim
13119 @cindex multi-file documents
13120 @cindex documents, multi-file
13121 @cindex setting input line number (@code{lf})
13122 @cindex input line number, setting (@code{lf})
13123 @cindex number, input line, setting (@code{lf})
13124 Change the line number and optionally the file name @code{gtroff} shall
13125 use for error and warning messages.  @var{line} is the input line number
13126 of the @emph{next} line.
13128 Without argument, the request is ignored.
13130 This is a debugging aid for documents which are split into many files,
13131 then put together with @code{soelim} and other preprocessors.  Usually,
13132 it isn't invoked manually.
13134 Note that other @code{troff} implementations (including the original
13135 @acronym{AT&T} version) handle @code{lf} differently.  For them,
13136 @var{line} changes the line number of the @emph{current} line.
13137 @endDefreq
13139 @DefreqList {tm, string}
13140 @DefreqItem {tm1, string}
13141 @DefreqListEnd {tmc, string}
13142 @cindex printing to stderr (@code{tm}, @code{tm1}, @code{tmc})
13143 @cindex stderr, printing to (@code{tm}, @code{tm1}, @code{tmc})
13144 Send @var{string} to the standard error output;
13145 this is very useful for printing debugging messages among other things.
13147 @var{string} is read in copy mode.
13149 The @code{tm} request ignores leading spaces of @var{string}; @code{tm1}
13150 handles its argument similar to the @code{ds} request: a leading double
13151 quote in @var{string} is stripped to allow initial blanks.
13153 The @code{tmc} request is similar to @code{tm1} but does
13154 not append a newline (as is done in @code{tm} and @code{tm1}).
13155 @endDefreq
13157 @Defreq {ab, [@Var{string}]}
13158 @cindex aborting (@code{ab})
13159 Similar to the @code{tm} request, except that
13160 it causes @code{gtroff} to stop processing.  With no argument it
13161 prints @samp{User Abort.} to standard error.
13162 @endDefreq
13164 @Defreq {ex, }
13165 @cindex @code{ex} request, use in debugging
13166 @cindex exiting (@code{ex})
13167 The @code{ex} request also causes @code{gtroff} to stop processing;
13168 see also @ref{I/O}.
13169 @endDefreq
13171 When doing something involved it is useful to leave the debugging
13172 statements in the code and have them turned on by a command line flag.
13174 @Example
13175 .if \n(DB .tm debugging output
13176 @endExample
13178 @noindent
13179 To activate these statements say
13181 @Example
13182 groff -rDB=1 file
13183 @endExample
13185 If it is known in advance that there will be many errors and no useful
13186 output, @code{gtroff} can be forced to suppress formatted output with
13187 the @option{-z} flag.
13189 @Defreq {pm, }
13190 @cindex dumping symbol table (@code{pm})
13191 @cindex symbol table, dumping (@code{pm})
13192 Print the entire symbol table on @code{stderr}.  Names of all defined
13193 macros, strings, and diversions are print together with their size in
13194 bytes.  Since @code{gtroff} sometimes adds nodes by itself, the
13195 returned size can be larger than expected.
13197 This request differs from @acronym{UNIX} @code{troff}: @code{gtroff}
13198 reports the sizes of diversions, ignores an additional argument to
13199 print only the total of the sizes, and the size isn't returned in
13200 blocks of 128 characters.
13201 @endDefreq
13203 @Defreq {pnr, }
13204 @cindex dumping number registers (@code{pnr})
13205 @cindex number registers, dumping (@code{pnr})
13206 Print the names and contents of all
13207 currently defined number registers on @code{stderr}.
13208 @endDefreq
13210 @Defreq {ptr, }
13211 @cindex dumping traps (@code{ptr})
13212 @cindex traps, dumping (@code{ptr})
13213 Print the names and positions of all traps
13214 (not including input line traps and diversion traps) on @code{stderr}.
13215 Empty slots in the page trap list are printed as well, because they can
13216 affect the priority of subsequently planted traps.
13217 @endDefreq
13219 @Defreq {fl, }
13220 @cindex flush output (@code{fl})
13221 @cindex output, flush (@code{fl})
13222 @cindex interactive use of @code{gtroff}
13223 @cindex @code{gtroff}, interactive use
13224 Instruct @code{gtroff} to flush its output immediately.  The intent
13225 is for interactive use, but this behaviour is currently not
13226 implemented in @code{gtroff}.  Contrary to @acronym{UNIX} @code{troff},
13227 TTY output is sent to a device driver also (@code{grotty}), making it
13228 non-trivial to communicate interactively.
13230 This request causes a line break.
13231 @endDefreq
13233 @Defreq {backtrace, }
13234 @cindex backtrace of input stack (@code{backtrace})
13235 @cindex input stack, backtrace (@code{backtrace})
13236 Print a backtrace of the input stack to the standard error stream.
13238 Consider the following in file @file{test}:
13240 @Example
13241 .de xxx
13242 .  backtrace
13244 .de yyy
13245 .  xxx
13248 .yyy
13249 @endExample
13251 @noindent
13252 On execution, @code{gtroff} prints the following:
13254 @Example
13255 test:2: backtrace: macro `xxx'
13256 test:5: backtrace: macro `yyy'
13257 test:8: backtrace: file `test'
13258 @endExample
13260 The option @option{-b} of @code{gtroff} internally calls a variant of
13261 this request on each error and warning.
13262 @endDefreq
13264 @Defreg {slimit}
13265 @cindex input stack, setting limit
13266 Use the @code{slimit} number register
13267 to set the maximum number of objects on the input stack.
13268 If @code{slimit} is less than or equal to@tie{}0,
13269 there is no limit set.
13270 With no limit, a buggy recursive macro can exhaust virtual memory.
13272 The default value is 1000; this is a compile-time constant.
13273 @endDefreg
13275 @Defreq {warnscale, si}
13276 Set the scaling indicator used in warnings to @var{si}.  Valid values for
13277 @var{si} are @samp{u}, @samp{i}, @samp{c}, @samp{p}, and @samp{P}.  At
13278 startup, it is set to @samp{i}.
13279 @endDefreq
13281 @Defreq {spreadwarn, [@Var{limit}]}
13282 Make @code{gtroff} emit a warning if the additional space inserted for
13283 each space between words in an output line is larger or equal to
13284 @var{limit}.  A negative value is changed to zero; no argument toggles the
13285 warning on and off without changing @var{limit}.  The default scaling
13286 indicator is @samp{m}.  At startup, @code{spreadwarn} is deactivated, and
13287 @var{limit} is set to 3@dmn{m}.
13289 For example,
13291 @Example
13292 .spreadwarn 0.2m
13293 @endExample
13295 @noindent
13296 will cause a warning if @code{gtroff} must add 0.2@dmn{m} or more for each
13297 interword space in a line.
13299 This request is active only if text is justified to both margins (using
13300 @w{@samp{.ad b}}).
13301 @endDefreq
13303 @cindex warnings
13304 @code{gtroff} has command line options for printing out more warnings
13305 (@option{-w}) and for printing backtraces (@option{-b}) when a warning
13306 or an error occurs.  The most verbose level of warnings is @option{-ww}.
13308 @DefreqList {warn, [@Var{flags}]}
13309 @DefregListEnd {.warn}
13310 @cindex level of warnings (@code{warn})
13311 @cindex warnings, level (@code{warn})
13312 Control the level of warnings checked for.  The @var{flags} are the sum
13313 of the numbers associated with each warning that is to be enabled; all
13314 other warnings are disabled.  The number associated with each warning is
13315 listed below.  For example, @w{@code{.warn 0}} disables all warnings,
13316 and @w{@code{.warn 1}} disables all warnings except that about missing
13317 glyphs.  If no argument is given, all warnings are enabled.
13319 The read-only number register @code{.warn} contains the current warning
13320 level.
13321 @endDefreq
13323 @menu
13324 * Warnings::
13325 @end menu
13327 @c ---------------------------------------------------------------------
13329 @node Warnings,  , Debugging, Debugging
13330 @subsection Warnings
13331 @cindex warnings
13333 The warnings that can be given to @code{gtroff} are divided into the
13334 following categories.  The name associated with each warning is used by
13335 the @option{-w} and @option{-W} options; the number is used by the
13336 @code{warn} request and by the @code{.warn} register.
13338 @table @samp
13339 @item char
13340 @itemx 1
13341 Non-existent glyphs.@footnote{@code{char} is a misnomer since it reports
13342 missing glyphs -- there aren't missing input characters, only invalid
13343 ones.}  This is enabled by default.
13345 @item number
13346 @itemx 2
13347 Invalid numeric expressions.  This is enabled by default.
13348 @xref{Expressions}.
13350 @item break
13351 @itemx 4
13352 @cindex fill mode
13353 @cindex mode, fill
13354 In fill mode, lines which could not be broken so that their length was
13355 less than the line length.  This is enabled by default.
13357 @item delim
13358 @itemx 8
13359 Missing or mismatched closing delimiters.
13361 @item el
13362 @itemx 16
13363 @cindex @code{ie} request, and warnings
13364 @cindex @code{el} request, and warnings
13365 Use of the @code{el} request with no matching @code{ie} request.
13366 @xref{if-else}.
13368 @item scale
13369 @itemx 32
13370 Meaningless scaling indicators.
13372 @item range
13373 @itemx 64
13374 Out of range arguments.
13376 @item syntax
13377 @itemx 128
13378 Dubious syntax in numeric expressions.
13380 @item di
13381 @itemx 256
13382 @cindex @code{di} request, and warnings
13383 @cindex @code{da} request, and warnings
13384 Use of @code{di} or @code{da} without an argument when there is no
13385 current diversion.
13387 @item mac
13388 @itemx 512
13389 @cindex @code{de}, @code{de1}, @code{dei} requests, and warnings
13390 @cindex @code{am}, @code{am1}, @code{ami} requests, and warnings
13391 @cindex @code{ds}, @code{ds1} requests, and warnings
13392 @cindex @code{as}, @code{as1} requests, and warnings
13393 @cindex @code{di} request, and warnings
13394 @cindex @code{da} request, and warnings
13395 @cindex @code{box}, @code{boxa} requests, and warnings
13396 @cindex @code{\*}, and warnings
13397 Use of undefined strings, macros and diversions.  When an undefined
13398 string, macro, or diversion is used, that string is automatically
13399 defined as empty.  So, in most cases, at most one warning is given
13400 for each name.
13402 @item reg
13403 @itemx 1024
13404 @cindex @code{nr} request, and warnings
13405 @cindex @code{\R}, and warnings
13406 @cindex @code{\n}, and warnings
13407 Use of undefined number registers.  When an undefined number register is
13408 used, that register is automatically defined to have a value of@tie{}0.
13409 So, in most cases, at most one warning is given for use of a particular
13410 name.
13412 @item tab
13413 @itemx 2048
13414 @cindex @code{\t}, and warnings
13415 Use of a tab character where a number was expected.
13417 @item right-brace
13418 @itemx 4096
13419 @cindex @code{\@}}, and warnings
13420 Use of @code{\@}} where a number was expected.
13422 @item missing
13423 @itemx 8192
13424 Requests that are missing non-optional arguments.
13426 @item input
13427 @itemx 16384
13428 Invalid input characters.
13430 @item escape
13431 @itemx 32768
13432 Unrecognized escape sequences.  When an unrecognized escape sequence
13433 @code{\@var{X}} is encountered, the escape character is ignored, and
13434 @var{X} is printed.
13436 @item space
13437 @itemx 65536
13438 @cindex compatibility mode
13439 Missing space between a request or macro and its argument.  This warning
13440 is given when an undefined name longer than two characters is
13441 encountered, and the first two characters of the name make a defined
13442 name.  The request or macro is not invoked.  When this warning is
13443 given, no macro is automatically defined.  This is enabled by default.
13444 This warning never occurs in compatibility mode.
13446 @item font
13447 @itemx 131072
13448 Non-existent fonts.  This is enabled by default.
13450 @item ig
13451 @itemx 262144
13452 Invalid escapes in text ignored with the @code{ig} request.  These are
13453 conditions that are errors when they do not occur in ignored text.
13455 @item color
13456 @itemx 524288
13457 Color related warnings.
13459 @item all
13460 All warnings except @samp{di}, @samp{mac} and @samp{reg}.  It is
13461 intended that this covers all warnings that are useful with traditional
13462 macro packages.
13464 @item w
13465 All warnings.
13466 @end table
13469 @c =====================================================================
13471 @node Implementation Differences,  , Debugging, gtroff Reference
13472 @section Implementation Differences
13473 @cindex implementation differences
13474 @cindex differences in implementation
13475 @cindex incompatibilities with @acronym{AT&T} @code{troff}
13476 @cindex compatibility mode
13477 @cindex mode, compatibility
13479 GNU @code{troff} has a number of features which cause incompatibilities
13480 with documents written with old versions of @code{troff}.
13482 @cindex long names
13483 @cindex names, long
13484 Long names cause some incompatibilities.  @acronym{UNIX} @code{troff}
13485 interprets
13487 @Example
13488 .dsabcd
13489 @endExample
13491 @cindex @code{\*}, incompatibilities with @acronym{AT&T} @code{troff}
13492 @cindex @code{\n}, incompatibilities with @acronym{AT&T} @code{troff}
13493 @noindent
13494 as defining a string @samp{ab} with contents @samp{cd}.  Normally, GNU
13495 @code{troff} interprets this as a call of a macro named
13496 @code{dsabcd}.  Also @acronym{UNIX} @code{troff} interprets
13497 @code{\*[} or @code{\n[} as references to a string or number register
13498 called @samp{[}.  In GNU @code{troff}, however, this is normally
13499 interpreted as the start of a long name.  In compatibility mode GNU
13500 @code{troff} interprets long names in the traditional way
13501 (which means that they are not recognized as names).
13503 @DefreqList {cp, [@Var{n}]}
13504 @DefreqItem {do, cmd}
13505 @DefregListEnd {.C}
13506 If @var{n} is missing or non-zero, turn on compatibility mode;
13507 otherwise, turn it off.
13509 The read-only number register @code{.C} is@tie{}1 if compatibility mode is
13510 on, 0@tie{}otherwise.
13512 Compatibility mode can be also turned on with the @option{-C} command line
13513 option.
13515 The @code{do} request turns off compatibility mode
13516 while executing its arguments as a @code{gtroff} command.
13518 @Example
13519 .do fam T
13520 @endExample
13522 @noindent
13523 executes the @code{fam} request when compatibility mode
13524 is enabled.
13526 @code{gtroff} restores the previous compatibility setting
13527 before interpreting any files sourced by the @var{cmd}.
13528 @endDefreq
13530 @cindex input level in delimited arguments
13531 @cindex delimited arguments, incompatibilities with @acronym{AT&T} @code{troff}
13532 Two other features are controlled by @option{-C}.  If not in
13533 compatibility mode, GNU @code{troff} preserves the input level in
13534 delimited arguments:
13536 @Example
13537 .ds xx '
13538 \w'abc\*(xxdef'
13539 @endExample
13541 @noindent
13542 In compatibility mode, the string @samp{72def'} is returned; without
13543 @option{-C} the resulting string is @samp{168} (assuming a TTY output
13544 device).
13546 @cindex @code{\f}, incompatibilities with @acronym{AT&T} @code{troff}
13547 @cindex @code{\H}, incompatibilities with @acronym{AT&T} @code{troff}
13548 @cindex @code{\s}, incompatibilities with @acronym{AT&T} @code{troff}
13549 @cindex @code{\S}, incompatibilities with @acronym{AT&T} @code{troff}
13550 Finally, the escapes @code{\f}, @code{\H}, @code{\m}, @code{\M},
13551 @code{\R}, @code{\s}, and @code{\S} are transparent for recognizing the
13552 beginning of a line only in compatibility mode (this is a rather obscure
13553 feature).  For example, the code
13555 @Example
13556 .de xx
13557 Hallo!
13559 \fB.xx\fP
13560 @endExample
13562 @noindent
13563 prints @samp{Hallo!} in bold face if in compatibility mode, and
13564 @samp{.xx} in bold face otherwise.
13566 @cindex @code{\A}, incompatibilities with @acronym{AT&T} @code{troff}
13567 @cindex @code{\|}, incompatibilities with @acronym{AT&T} @code{troff}
13568 @cindex @code{\^}, incompatibilities with @acronym{AT&T} @code{troff}
13569 @cindex @code{\&}, incompatibilities with @acronym{AT&T} @code{troff}
13570 @cindex @code{\@{}, incompatibilities with @acronym{AT&T} @code{troff}
13571 @cindex @code{\@}}, incompatibilities with @acronym{AT&T} @code{troff}
13572 @cindex @code{\@key{SP}}, incompatibilities with @acronym{AT&T} @code{troff}
13573 @cindex @code{\'}, incompatibilities with @acronym{AT&T} @code{troff}
13574 @cindex @code{\`}, incompatibilities with @acronym{AT&T} @code{troff}
13575 @cindex @code{\-}, incompatibilities with @acronym{AT&T} @code{troff}
13576 @cindex @code{\_}, incompatibilities with @acronym{AT&T} @code{troff}
13577 @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
13578 @cindex @code{\%}, incompatibilities with @acronym{AT&T} @code{troff}
13579 @cindex @code{\c}, incompatibilities with @acronym{AT&T} @code{troff}
13580 GNU @code{troff} does not allow the use of the escape sequences
13581 @code{\|}, @code{\^}, @code{\&}, @code{\@{}, @code{\@}},
13582 @code{\@key{SP}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
13583 @code{\%}, and @code{\c} in names of strings, macros, diversions, number
13584 registers, fonts or environments; @acronym{UNIX} @code{troff} does.  The
13585 @code{\A} escape sequence (@pxref{Identifiers}) may be helpful in
13586 avoiding use of these escape sequences in names.
13588 @cindex fractional point sizes
13589 @cindex fractional type sizes
13590 @cindex point sizes, fractional
13591 @cindex type sizes, fractional
13592 @cindex sizes, fractional
13593 @cindex @code{ps} request, incompatibilities with @acronym{AT&T} @code{troff}
13594 Fractional point sizes cause one noteworthy incompatibility.  In
13595 @acronym{UNIX} @code{troff} the @code{ps} request ignores scale
13596 indicators and thus
13598 @Example
13599 .ps 10u
13600 @endExample
13602 @noindent
13603 sets the point size to 10@tie{}points, whereas in GNU @code{troff} it
13604 sets the point size to 10@tie{}scaled points.  @xref{Fractional Type
13605 Sizes}, for more information.
13607 @cindex @code{bd} request, incompatibilities with @acronym{AT&T} @code{troff}
13608 @cindex @code{cs} request, incompatibilities with @acronym{AT&T} @code{troff}
13609 @cindex @code{tr} request, incompatibilities with @acronym{AT&T} @code{troff}
13610 @cindex @code{fp} request, incompatibilities with @acronym{AT&T} @code{troff}
13611 @cindex input characters and output glyphs, compatibility with @acronym{AT&T} @code{troff}
13612 @cindex output glyphs, and input characters,compatibility with @acronym{AT&T} @code{troff}
13613 @cindex characters, input, and output glyphs, compatibility with @acronym{AT&T} @code{troff}
13614 @cindex glyphs, output, and input characters, compatibility with @acronym{AT&T} @code{troff}
13615 In GNU @code{troff} there is a fundamental difference between
13616 (unformatted) input characters and (formatted) output glyphs.
13617 Everything that affects how a glyph is output is stored
13618 with the glyph node; once a glyph node has been constructed it is
13619 unaffected by any subsequent requests that are executed, including
13620 @code{bd}, @code{cs}, @code{tkf}, @code{tr}, or @code{fp} requests.
13621 Normally glyphs are constructed from input characters at the
13622 moment immediately before the glyph is added to the current output
13623 line.  Macros, diversions and strings are all, in fact, the same type of
13624 object; they contain lists of input characters and glyph nodes in
13625 any combination.  A glyph node does not behave like an input
13626 character for the purposes of macro processing; it does not inherit any
13627 of the special properties that the input character from which it was
13628 constructed might have had.  For example,
13630 @Example
13631 .di x
13632 \\\\
13636 @endExample
13638 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
13639 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
13640 @cindex @code{\e}, incompatibilities with @acronym{AT&T} @code{troff}
13641 @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
13642 @cindex @code{\?}, incompatibilities with @acronym{AT&T} @code{troff}
13643 @cindex transparent output, incompatibilities with @acronym{AT&T} @code{troff}
13644 @cindex output, transparent, incompatibilities with @acronym{AT&T} @code{troff}
13645 @noindent
13646 prints @samp{\\} in GNU @code{troff}; each pair of input backslashes
13647 is turned into one output backslash and the resulting output backslashes
13648 are not interpreted as escape characters when they are reread.
13649 @acronym{UNIX} @code{troff} would interpret them as escape characters
13650 when they were reread and would end up printing one @samp{\}.  The
13651 correct way to obtain a printable backslash is to use the @code{\e}
13652 escape sequence: This always prints a single instance of the current
13653 escape character, regardless of whether or not it is used in a
13654 diversion; it also works in both GNU @code{troff} and @acronym{UNIX}
13655 @code{troff}.@footnote{To be completely independent of the current
13656 escape character, use @code{\(rs} which represents a reverse solidus
13657 (backslash) glyph.}  To store, for some reason, an escape sequence in a
13658 diversion that will be interpreted when the diversion is reread, either
13659 use the traditional @code{\!} transparent output facility, or, if this
13660 is unsuitable, the new @code{\?} escape sequence.
13662 @xref{Diversions}, and @ref{Gtroff Internals}, for more information.
13666 @c =====================================================================
13667 @c =====================================================================
13669 @node Preprocessors, Output Devices, gtroff Reference, Top
13670 @chapter Preprocessors
13671 @cindex preprocessors
13673 This chapter describes all preprocessors that come with @code{groff} or
13674 which are freely available.
13676 @menu
13677 * geqn::
13678 * gtbl::
13679 * gpic::
13680 * ggrn::
13681 * grap::
13682 * grefer::
13683 * gsoelim::
13684 @end menu
13687 @c =====================================================================
13689 @node geqn, gtbl, Preprocessors, Preprocessors
13690 @section @code{geqn}
13691 @cindex @code{eqn}, the program
13692 @cindex @code{geqn}, the program
13694 @c XXX
13696 @menu
13697 * Invoking geqn::
13698 @end menu
13700 @c ---------------------------------------------------------------------
13702 @node Invoking geqn,  , geqn, geqn
13703 @subsection Invoking @code{geqn}
13704 @cindex invoking @code{geqn}
13705 @cindex @code{geqn}, invoking
13707 @c XXX
13710 @c =====================================================================
13712 @node gtbl, gpic, geqn, Preprocessors
13713 @section @code{gtbl}
13714 @cindex @code{tbl}, the program
13715 @cindex @code{gtbl}, the program
13717 @c XXX
13719 @menu
13720 * Invoking gtbl::
13721 @end menu
13723 @c ---------------------------------------------------------------------
13725 @node Invoking gtbl,  , gtbl, gtbl
13726 @subsection Invoking @code{gtbl}
13727 @cindex invoking @code{gtbl}
13728 @cindex @code{gtbl}, invoking
13730 @c XXX
13733 @c =====================================================================
13735 @node gpic, ggrn, gtbl, Preprocessors
13736 @section @code{gpic}
13737 @cindex @code{pic}, the program
13738 @cindex @code{gpic}, the program
13740 @c XXX
13742 @menu
13743 * Invoking gpic::
13744 @end menu
13746 @c ---------------------------------------------------------------------
13748 @node Invoking gpic,  , gpic, gpic
13749 @subsection Invoking @code{gpic}
13750 @cindex invoking @code{gpic}
13751 @cindex @code{gpic}, invoking
13753 @c XXX
13756 @c =====================================================================
13758 @node ggrn, grap, gpic, Preprocessors
13759 @section @code{ggrn}
13760 @cindex @code{grn}, the program
13761 @cindex @code{ggrn}, the program
13763 @c XXX
13765 @menu
13766 * Invoking ggrn::
13767 @end menu
13769 @c ---------------------------------------------------------------------
13771 @node Invoking ggrn,  , ggrn, ggrn
13772 @subsection Invoking @code{ggrn}
13773 @cindex invoking @code{ggrn}
13774 @cindex @code{ggrn}, invoking
13776 @c XXX
13779 @c =====================================================================
13781 @node grap, grefer, ggrn, Preprocessors
13782 @section @code{grap}
13783 @cindex @code{grap}, the program
13785 A free implementation of @code{grap}, written by Ted Faber,
13786 is available as an extra package from the following address:
13788 @display
13789 @uref{http://www.lunabase.org/~faber/Vault/software/grap/}
13790 @end display
13793 @c =====================================================================
13795 @node grefer, gsoelim, grap, Preprocessors
13796 @section @code{grefer}
13797 @cindex @code{refer}, the program
13798 @cindex @code{grefer}, the program
13800 @c XXX
13802 @menu
13803 * Invoking grefer::
13804 @end menu
13806 @c ---------------------------------------------------------------------
13808 @node Invoking grefer,  , grefer, grefer
13809 @subsection Invoking @code{grefer}
13810 @cindex invoking @code{grefer}
13811 @cindex @code{grefer}, invoking
13813 @c XXX
13816 @c =====================================================================
13818 @node gsoelim,  , grefer, Preprocessors
13819 @section @code{gsoelim}
13820 @cindex @code{soelim}, the program
13821 @cindex @code{gsoelim}, the program
13823 @c XXX
13825 @menu
13826 * Invoking gsoelim::
13827 @end menu
13829 @c ---------------------------------------------------------------------
13831 @node Invoking gsoelim,  , gsoelim, gsoelim
13832 @subsection Invoking @code{gsoelim}
13833 @cindex invoking @code{gsoelim}
13834 @cindex @code{gsoelim}, invoking
13836 @c XXX
13840 @c =====================================================================
13841 @c =====================================================================
13843 @node Output Devices, File formats, Preprocessors, Top
13844 @chapter Output Devices
13845 @cindex output devices
13846 @cindex devices for output
13848 @c XXX
13850 @menu
13851 * Special Characters::
13852 * grotty::
13853 * grops::
13854 * grodvi::
13855 * grolj4::
13856 * grolbp::
13857 * grohtml::
13858 * gxditview::
13859 @end menu
13862 @c =====================================================================
13864 @node Special Characters, grotty, Output Devices, Output Devices
13865 @section Special Characters
13866 @cindex special characters
13867 @cindex characters, special
13869 @c XXX
13871 @xref{Font Files}.
13874 @c =====================================================================
13876 @node grotty, grops, Special Characters, Output Devices
13877 @section @code{grotty}
13878 @cindex @code{grotty}, the program
13880 @c XXX
13882 @menu
13883 * Invoking grotty::
13884 @end menu
13886 @c ---------------------------------------------------------------------
13888 @node Invoking grotty,  , grotty, grotty
13889 @subsection Invoking @code{grotty}
13890 @cindex invoking @code{grotty}
13891 @cindex @code{grotty}, invoking
13893 @c XXX
13895 @c The following is no longer true; fix and extend it.
13897 @c @pindex less
13898 @c @cindex Teletype
13899 @c @cindex ISO 6249 SGR
13900 @c @cindex terminal control sequences
13901 @c @cindex control sequences, for terminals
13902 @c For TTY output devices, underlining is done by emitting sequences of
13903 @c @samp{_} and @samp{\b} (the backspace character) before the actual
13904 @c character.  Literally, this is printing an underline character, then
13905 @c moving back one character position, and printing the actual character
13906 @c at the same position as the underline character (similar to a
13907 @c typewriter).  Usually, a modern terminal can't interpret this (and the
13908 @c original Teletype machines for which this sequence was appropriate are
13909 @c no longer in use).  You need a pager program like @code{less} which
13910 @c translates this into ISO 6429 SGR sequences to control terminals.
13913 @c =====================================================================
13915 @node grops, grodvi, grotty, Output Devices
13916 @section @code{grops}
13917 @cindex @code{grops}, the program
13919 @c XXX
13921 @menu
13922 * Invoking grops::
13923 * Embedding PostScript::
13924 @end menu
13926 @c ---------------------------------------------------------------------
13928 @node Invoking grops, Embedding PostScript, grops, grops
13929 @subsection Invoking @code{grops}
13930 @cindex invoking @code{grops}
13931 @cindex @code{grops}, invoking
13933 @c XXX
13935 @c ---------------------------------------------------------------------
13937 @node Embedding PostScript,  , Invoking grops, grops
13938 @subsection Embedding @sc{PostScript}
13939 @cindex embedding PostScript
13940 @cindex PostScript, embedding
13942 @c XXX
13945 @c =====================================================================
13947 @node grodvi, grolj4, grops, Output Devices
13948 @section @code{grodvi}
13949 @cindex @code{grodvi}, the program
13951 @c XXX
13953 @menu
13954 * Invoking grodvi::
13955 @end menu
13957 @c ---------------------------------------------------------------------
13959 @node Invoking grodvi,  , grodvi, grodvi
13960 @subsection Invoking @code{grodvi}
13961 @cindex invoking @code{grodvi}
13962 @cindex @code{grodvi}, invoking
13964 @c XXX
13967 @c =====================================================================
13969 @node grolj4, grolbp, grodvi, Output Devices
13970 @section @code{grolj4}
13971 @cindex @code{grolj4}, the program
13973 @c XXX
13975 @menu
13976 * Invoking grolj4::
13977 @end menu
13979 @c ---------------------------------------------------------------------
13981 @node Invoking grolj4,  , grolj4, grolj4
13982 @subsection Invoking @code{grolj4}
13983 @cindex invoking @code{grolj4}
13984 @cindex @code{grolj4}, invoking
13986 @c XXX
13989 @c =====================================================================
13991 @node grolbp, grohtml, grolj4, Output Devices
13992 @section @code{grolbp}
13993 @cindex @code{grolbp}, the program
13995 @c XXX
13997 @menu
13998 * Invoking grolbp::
13999 @end menu
14001 @c ---------------------------------------------------------------------
14003 @node Invoking grolbp,  , grolbp, grolbp
14004 @subsection Invoking @code{grolbp}
14005 @cindex invoking @code{grolbp}
14006 @cindex @code{grolbp}, invoking
14008 @c XXX
14011 @c =====================================================================
14013 @node grohtml, gxditview, grolbp, Output Devices
14014 @section @code{grohtml}
14015 @cindex @code{grohtml}, the program
14017 @c XXX
14019 @menu
14020 * Invoking grohtml::
14021 * grohtml specific registers and strings::
14022 @end menu
14024 @c ---------------------------------------------------------------------
14026 @node Invoking grohtml, grohtml specific registers and strings, grohtml, grohtml
14027 @subsection Invoking @code{grohtml}
14028 @cindex invoking @code{grohtml}
14029 @cindex @code{grohtml}, invoking
14031 @c XXX
14033 @c ---------------------------------------------------------------------
14035 @node grohtml specific registers and strings,  , Invoking grohtml, grohtml
14036 @subsection @code{grohtml} specific registers and strings
14037 @cindex registers specific to @code{grohtml}
14038 @cindex strings specific to @code{grohtml}
14039 @cindex @code{grohtml}, registers and strings
14041 @DefmpregList {ps4html, grohtml}
14042 @DefstrListEnd {www-image-template, grohtml}
14043 The registers @code{ps4html} and @code{www-image-template} are defined
14044 by the @code{pre-grohtml} preprocessor.  @code{pre-grohtml} reads in
14045 the @code{troff} input, marks up the inline equations and passes the
14046 result firstly to
14048 @Example
14049 troff -Tps -rps4html=1 -dwww-image-template=@var{template}
14050 @endExample
14052 @noindent
14053 and secondly to
14055 @Example
14056 troff -Thtml
14057 @endExample
14059 The PostScript device is used to create all the image files, and the
14060 register @code{ps4html} enables the macro sets to ignore floating
14061 keeps, footers, and headings.
14063 The register @code{www-image-template} is set to the user specified
14064 template name or the default name.
14065 @endDefmpreg
14068 @c =====================================================================
14070 @node gxditview,  , grohtml, Output Devices
14071 @section @code{gxditview}
14072 @cindex @code{gxditview}, the program
14074 @c XXX
14076 @menu
14077 * Invoking gxditview::
14078 @end menu
14080 @c ---------------------------------------------------------------------
14082 @node Invoking gxditview,  , gxditview, gxditview
14083 @subsection Invoking @code{gxditview}
14084 @cindex invoking @code{gxditview}
14085 @cindex @code{gxditview}, invoking
14087 @c XXX
14088 @c X11's xditview
14092 @c =====================================================================
14093 @c =====================================================================
14095 @node File formats, Installation, Output Devices, Top
14096 @chapter File formats
14097 @cindex file formats
14098 @cindex formats, file
14100 All files read and written by @code{gtroff} are text files.  The
14101 following two sections describe their format.
14103 @menu
14104 * gtroff Output::
14105 * Font Files::
14106 @end menu
14109 @c =====================================================================
14111 @node gtroff Output, Font Files, File formats, File formats
14112 @section @code{gtroff} Output
14113 @cindex @code{gtroff}, output
14114 @cindex output, @code{gtroff}
14116 This section describes the intermediate output format of GNU
14117 @code{troff}.  This output is produced by a run of @code{gtroff}
14118 before it is fed into a device postprocessor program.
14120 As @code{groff} is a wrapper program around @code{gtroff} that
14121 automatically calls a postprocessor, this output does not show up
14122 normally.  This is why it is called @dfn{intermediate}.
14123 @code{groff} provides the option @option{-Z} to inhibit postprocessing,
14124 such that the produced intermediate output is sent to standard output
14125 just like calling @code{gtroff} manually.
14127 @cindex troff output
14128 @cindex output, troff
14129 @cindex intermediate output
14130 @cindex output, intermediate
14131 Here, the term @dfn{troff output} describes what is output by
14132 @code{gtroff}, while @dfn{intermediate output} refers to the language
14133 that is accepted by the parser that prepares this output for the
14134 postprocessors.  This parser is smarter on whitespace and implements
14135 obsolete elements for compatibility, otherwise both formats are the
14136 same.@footnote{The parser and postprocessor for intermediate output
14137 can be found in the file@*
14138 @file{@var{groff-source-dir}/src/libs/libdriver/input.cpp}.}
14140 The main purpose of the intermediate output concept is to facilitate
14141 the development of postprocessors by providing a common programming
14142 interface for all devices.  It has a language of its own that is
14143 completely different from the @code{gtroff} language.  While the
14144 @code{gtroff} language is a high-level programming language for text
14145 processing, the intermediate output language is a kind of low-level
14146 assembler language by specifying all positions on the page for writing
14147 and drawing.
14149 The intermediate output produced by @code{gtroff} is fairly readable,
14150 while output from @acronym{AT&T} @code{troff} is rather hard to
14151 understand because of strange habits that are still supported, but not
14152 used any longer by @code{gtroff}.
14154 @menu
14155 * Language Concepts::
14156 * Command Reference::
14157 * Intermediate Output Examples::
14158 * Output Language Compatibility::
14159 @end menu
14161 @c ---------------------------------------------------------------------
14163 @node Language Concepts, Command Reference, gtroff Output, gtroff Output
14164 @subsection Language Concepts
14166 During the run of @code{gtroff}, the input data is cracked down to the
14167 information on what has to be printed at what position on the intended
14168 device.  So the language of the intermediate output format can be quite
14169 small.  Its only elements are commands with and without arguments.
14170 In this section, the term @dfn{command} always refers to the intermediate
14171 output language, and never to the @code{gtroff} language used for document
14172 formatting.  There are commands for positioning and text writing, for drawing, and
14173 for device controlling.
14175 @menu
14176 * Separation::
14177 * Argument Units::
14178 * Document Parts::
14179 @end menu
14181 @node Separation, Argument Units, Language Concepts, Language Concepts
14182 @subsubsection Separation
14184 @acronym{AT&T} @code{troff} output has strange requirements on whitespace.
14185 The @code{gtroff} output parser, however, is smart about whitespace by
14186 making it maximally optional.  The whitespace characters, i.e., the
14187 tab, space, and newline characters, always have a syntactical meaning.
14188 They are never printable because spacing within the output is always
14189 done by positioning commands.
14191 Any sequence of space or tab characters is treated as a single
14192 @dfn{syntactical space}.  It separates commands and arguments, but is
14193 only required when there would occur a clashing between the command code
14194 and the arguments without the space.  Most often, this happens when
14195 variable-length command names, arguments, argument lists, or command
14196 clusters meet.  Commands and arguments with a known, fixed length need
14197 not be separated by syntactical space.
14199 A line break is a syntactical element, too.  Every command argument can be
14200 followed by whitespace, a comment, or a newline character.  Thus a
14201 @dfn{syntactical line break} is defined to consist of optional
14202 syntactical space that is optionally followed by a comment, and a
14203 newline character.
14205 The normal commands, those for positioning and text, consist of a
14206 single letter taking a fixed number of arguments.  For historical reasons,
14207 the parser allows to stack such commands on the same line, but
14208 fortunately, in @code{gtroff}'s intermediate output, every command with
14209 at least one argument is followed by a line break, thus providing
14210 excellent readability.
14212 The other commands -- those for drawing and device controlling --
14213 have a more complicated structure; some recognize long command names,
14214 and some take a variable number of arguments.  So all @samp{D} and
14215 @samp{x} commands were designed to request a syntactical line break
14216 after their last argument.  Only one command, @w{@samp{x X}},
14217 has an argument that can stretch over several lines; all other
14218 commands must have all of their arguments on the same line as the
14219 command, i.e., the arguments may not be splitted by a line break.
14221 Empty lines (these are lines containing only space and/or a comment), can
14222 occur everywhere.  They are just ignored.
14224 @node Argument Units, Document Parts, Separation, Language Concepts
14225 @subsubsection Argument Units
14227 Some commands take integer arguments that are assumed to represent
14228 values in a measurement unit, but the letter for the corresponding
14229 scale indicator is not written with the output command arguments.
14230 Most commands assume the scale indicator @samp{u}, the basic unit of
14231 the device, some use @samp{z}, the scaled point unit of the device,
14232 while others, such as the color commands, expect plain integers.
14234 Note that single characters can have the eighth bit set, as can the
14235 names of fonts and special characters.  The names of characters and
14236 fonts can be of arbitrary length.  A character that is to be printed
14237 will always be in the current font.
14239 A string argument is always terminated by the next whitespace
14240 character (space, tab, or newline); an embedded @samp{#} character is
14241 regarded as part of the argument, not as the beginning of a comment
14242 command.  An integer argument is already terminated by the next
14243 non-digit character, which then is regarded as the first character of
14244 the next argument or command.
14246 @node Document Parts,  , Argument Units, Language Concepts
14247 @subsubsection Document Parts
14249 A correct intermediate output document consists of two parts, the
14250 @dfn{prologue} and the @dfn{body}.
14252 The task of the prologue is to set the general device parameters
14253 using three exactly specified commands.  @code{gtroff}'s prologue
14254 is guaranteed to consist of the following three lines (in that order):
14256 @Example
14257 x T @var{device}
14258 x res @var{n} @var{h} @var{v}
14259 x init
14260 @endExample
14262 @noindent
14263 with the arguments set as outlined in @ref{Device Control Commands}.
14264 Note that the parser for the intermediate output format is able to
14265 swallow additional whitespace and comments as well even in the
14266 prologue.
14268 The body is the main section for processing the document data.
14269 Syntactically, it is a sequence of any commands different from the
14270 ones used in the prologue.  Processing is terminated as soon as the
14271 first @w{@samp{x stop}} command is encountered; the last line of any
14272 @code{gtroff} intermediate output always contains such a command.
14274 Semantically, the body is page oriented.  A new page is started by a
14275 @samp{p} command.  Positioning, writing, and drawing commands are
14276 always done within the current page, so they cannot occur before the
14277 first @samp{p} command.  Absolute positioning (by the @samp{H} and
14278 @samp{V} commands) is done relative to the current page; all other
14279 positioning is done relative to the current location within this page.
14281 @c ---------------------------------------------------------------------
14283 @node Command Reference, Intermediate Output Examples, Language Concepts, gtroff Output
14284 @subsection Command Reference
14286 This section describes all intermediate output commands, both from
14287 @acronym{AT&T} @code{troff} as well as the @code{gtroff} extensions.
14289 @menu
14290 * Comment Command::
14291 * Simple Commands::
14292 * Graphics Commands::
14293 * Device Control Commands::
14294 * Obsolete Command::
14295 @end menu
14297 @node Comment Command, Simple Commands, Command Reference, Command Reference
14298 @subsubsection Comment Command
14300 @table @code
14301 @item #@var{anything}@angles{end of line}
14302 A comment.  Ignore any characters from the @samp{#} character up to
14303 the next newline character.
14305 This command is the only possibility for commenting in the intermediate
14306 output.  Each comment can be preceded by arbitrary syntactical space;
14307 every command can be terminated by a comment.
14308 @end table
14310 @node Simple Commands, Graphics Commands, Comment Command, Command Reference
14311 @subsubsection Simple Commands
14313 The commands in this subsection have a command code consisting of a
14314 single character, taking a fixed number of arguments.  Most of them
14315 are commands for positioning and text writing.  These commands are
14316 smart about whitespace.  Optionally, syntactical space can be inserted
14317 before, after, and between the command letter and its arguments.
14318 All of these commands are stackable, i.e., they can be preceded by
14319 other simple commands or followed by arbitrary other commands on the
14320 same line.  A separating syntactical space is only necessary when two
14321 integer arguments would clash or if the preceding argument ends with a
14322 string argument.
14324 @table @code
14325 @ignore
14326 .if (\n[@USE_ENV_STACK] == 1) \{\
14327 .command {
14328 Open a new environment by copying the actual device configuration data
14329 to the environment stack.
14331 The current environment is setup by the device specification and
14332 manipulated by the setting commands.
14335 .command }
14336 Close the actual environment (opened by a preceding
14337 .BR { \~command)
14338 and restore the previous environment from the environment
14339 stack as the actual device configuration data.
14341 \}              \" endif @USE_ENV_STACK
14342 @end ignore
14344 @item C @var{xxx}@angles{whitespace}
14345 Print a special character named @var{xxx}.  The trailing
14346 syntactical space or line break is necessary to allow glyph names
14347 of arbitrary length.  The glyph is printed at the current print
14348 position; the glyph's size is read from the font file.  The print
14349 position is not changed.
14351 @item c @var{g}
14352 Print glyph@tie{}@var{g} at the current print position;@footnote{@samp{c}
14353 is actually a misnomer since it outputs a glyph.} the glyph's size is
14354 read from the font file.  The print position is not changed.
14356 @item f @var{n}
14357 Set font to font number@tie{}@var{n} (a non-negative integer).
14359 @item H @var{n}
14360 Move right to the absolute vertical position@tie{}@var{n} (a
14361 non-negative integer in basic units @samp{u} relative to left edge
14362 of current page.
14364 @item h @var{n}
14365 Move @var{n} (a non-negative integer) basic units @samp{u} horizontally
14366 to the right.  The original @acronym{UNIX} troff manual allows negative
14367 values for @var{n} also, but @code{gtroff} doesn't use this.
14369 @item m @var{color-scheme} @r{[}@var{component} @dots{}@r{]}
14370 Set the color for text (glyphs), line drawing, and the outline of
14371 graphic objects using different color schemes; the analoguous command
14372 for the filling color of graphic objects is @samp{DF}.  The color
14373 components are specified as integer arguments between 0 and 65536.
14374 The number of color components and their meaning vary for the
14375 different color schemes.  These commands are generated by
14376 @code{gtroff}'s escape sequence @code{\m}.  No position changing.
14377 These commands are a @code{gtroff} extension.
14379 @table @code
14380 @item mc @var{cyan} @var{magenta} @var{yellow}
14381 Set color using the CMY color scheme, having the 3@tie{}color components
14382 @var{cyan}, @var{magenta}, and @var{yellow}.
14384 @item md
14385 Set color to the default color value (black in most cases).
14386 No component arguments.
14388 @item mg @var{gray}
14389 Set color to the shade of gray given by the argument, an integer
14390 between 0 (black) and 65536 (white).
14392 @item mk @var{cyan} @var{magenta} @var{yellow} @var{black}
14393 Set color using the CMYK color scheme, having the 4@tie{}color components
14394 @var{cyan}, @var{magenta}, @var{yellow}, and @var{black}.
14396 @item mr @var{red} @var{green} @var{blue}
14397 Set color using the RGB color scheme, having the 3@tie{}color components
14398 @var{red}, @var{green}, and @var{blue}.
14399 @end table
14401 @item N @var{n}
14402 Print glyph with index@tie{}@var{n} (a non-negative integer) of the
14403 current font.  This command is a @code{gtroff} extension.
14405 @item n @var{b} @var{a}
14406 Inform the device about a line break, but no positioning is done by
14407 this command.  In @acronym{AT&T} @code{troff}, the integer arguments
14408 @var{b} and@tie{}@var{a} informed about the space before and after the
14409 current line to make the intermediate output more human readable
14410 without performing any action.  In @code{groff}, they are just ignored, but
14411 they must be provided for compatibility reasons.
14413 @item p @var{n}
14414 Begin a new page in the outprint.  The page number is set
14415 to@tie{}@var{n}.  This page is completely independent of pages formerly
14416 processed even if those have the same page number.  The vertical
14417 position on the outprint is automatically set to@tie{}0.  All
14418 positioning, writing, and drawing is always done relative to a page,
14419 so a @samp{p} command must be issued before any of these commands.
14421 @item s @var{n}
14422 Set point size to @var{n}@tie{}scaled points (this is unit @samp{z}).
14423 @acronym{AT&T} @code{troff} used the unit points (@samp{p}) instead.
14424 @xref{Output Language Compatibility}.
14426 @item t @var{xxx}@angles{whitespace}
14427 @itemx t @var{xxx} @var{dummy-arg}@angles{whitespace}
14428 Print a word, i.e., a sequence of characters @var{xxx} representing
14429 output glyphs which names are single characters, terminated by
14430 a space character or a line break; an optional second integer argument
14431 is ignored (this allows the formatter to generate an even number of
14432 arguments).  The first glyph should be printed at the current
14433 position, the current horizontal position should then be increased by
14434 the width of the first glyph, and so on for each glyph.
14435 The widths of the glyphs are read from the font file, scaled for the
14436 current point size, and rounded to a multiple of the horizontal
14437 resolution.  Special characters cannot be printed using this command
14438 (use the @samp{C} command for special characters).  This command is a
14439 @code{gtroff} extension; it is only used for devices whose @file{DESC}
14440 file contains the @code{tcommand} keyword (@pxref{DESC File Format}).
14442 @item u @var{n} @var{xxx}@angles{whitespace}
14443 Print word with track kerning.  This is the same as the @samp{t}
14444 command except that after printing each glyph, the current
14445 horizontal position is increased by the sum of the width of that
14446 glyph and@tie{}@var{n} (an integer in basic units @samp{u}).
14447 This command is a @code{gtroff} extension; it is only used for devices
14448 whose @file{DESC} file contains the @code{tcommand} keyword
14449 (@pxref{DESC File Format}).
14451 @item V @var{n}
14452 Move down to the absolute vertical position@tie{}@var{n} (a
14453 non-negative integer in basic units @samp{u}) relative to upper edge
14454 of current page.
14456 @item v @var{n}
14457 Move @var{n}@tie{}basic units @samp{u} down (@var{n} is a non-negative
14458 integer).  The original @acronym{UNIX} troff manual allows negative
14459 values for @var{n} also, but @code{gtroff} doesn't use this.
14461 @item w
14462 Informs about a paddable white space to increase readability.
14463 The spacing itself must be performed explicitly by a move command.
14464 @end table
14466 @node Graphics Commands, Device Control Commands, Simple Commands, Command Reference
14467 @subsubsection Graphics Commands
14469 Each graphics or drawing command in the intermediate output starts
14470 with the letter @samp{D}, followed by one or two characters that
14471 specify a subcommand; this is followed by a fixed or variable number
14472 of integer arguments that are separated by a single space character.
14473 A @samp{D} command may not be followed by another command on the same line
14474 (apart from a comment), so each @samp{D} command is terminated by a
14475 syntactical line break.
14477 @code{gtroff} output follows the classical spacing rules (no space
14478 between command and subcommand, all arguments are preceded by a
14479 single space character), but the parser allows optional space between
14480 the command letters and makes the space before the first argument
14481 optional.  As usual, each space can be any sequence of tab and space
14482 characters.
14484 Some graphics commands can take a variable number of arguments.
14485 In this case, they are integers representing a size measured in basic
14486 units @samp{u}.  The arguments called @var{h1}, @var{h2}, @dots{},
14487 @var{hn} stand for horizontal distances where positive means right,
14488 negative left.  The arguments called @var{v1}, @var{v2}, @dots{},
14489 @var{vn} stand for vertical distances where positive means down,
14490 negative up.  All these distances are offsets relative to the current
14491 location.
14493 Each graphics command directly corresponds to a similar @code{gtroff}
14494 @code{\D} escape sequence.  @xref{Drawing Requests}.
14496 Unknown @samp{D} commands are assumed to be device-specific.
14497 Its arguments are parsed as strings; the whole information is then
14498 sent to the postprocessor.
14500 In the following command reference, the syntax element
14501 @angles{line break} means a syntactical line break as defined above.
14503 @table @code
14504 @item D~ @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
14505 Draw B-spline from current position to offset (@var{h1},@var{v1}),
14506 then to offset (@var{h2},@var{v2}), if given, etc.@: up to
14507 (@var{hn},@var{vn}).  This command takes a variable number of argument
14508 pairs; the current position is moved to the terminal point of the drawn
14509 curve.
14511 @item Da @var{h1} @var{v1} @var{h2} @var{v2}@angles{line break}
14512 Draw arc from current position to
14513 (@var{h1},@var{v1})@math{+}(@var{h2},@var{v2}) with center at
14514 (@var{h1},@var{v1}); then move the current position to the final point
14515 of the arc.
14517 @item DC @var{d}@angles{line break}
14518 @itemx DC @var{d} @var{dummy-arg}@angles{line break}
14519 Draw a solid circle using the current fill color with
14520 diameter@tie{}@var{d} (integer in basic units @samp{u}) with leftmost
14521 point at the current position; then move the current position to the
14522 rightmost point of the circle.  An optional second integer argument is
14523 ignored (this allows the formatter to generate an even number of
14524 arguments).  This command is a @code{gtroff} extension.
14526 @item Dc @var{d}@angles{line break}
14527 Draw circle line with diameter@tie{}@var{d} (integer in basic units
14528 @samp{u}) with leftmost point at the current position; then move the
14529 current position to the rightmost point of the circle.
14531 @item DE @var{h} @var{v}@angles{line break}
14532 Draw a solid ellipse in the current fill color with a horizontal
14533 diameter of@tie{}@var{h} and a vertical diameter of@tie{}@var{v} (both
14534 integers in basic units @samp{u}) with the leftmost point at the
14535 current position; then move to the rightmost point of the ellipse.
14536 This command is a @code{gtroff} extension.
14538 @item De @var{h} @var{v}@angles{line break}
14539 Draw an outlined ellipse with a horizontal diameter of@tie{}@var{h}
14540 and a vertical diameter of@tie{}@var{v} (both integers in basic units
14541 @samp{u}) with the leftmost point at current position; then move to
14542 the rightmost point of the ellipse.
14544 @item DF @var{color-scheme} @r{[}@var{component} @dots{}@r{]}@angles{line break}
14545 Set fill color for solid drawing objects using different color
14546 schemes; the analoguous command for setting the color of text, line
14547 graphics, and the outline of graphic objects is @samp{m}.
14548 The color components are specified as integer arguments between 0 and
14549 65536.  The number of color components and their meaning vary for the
14550 different color schemes.  These commands are generated by @code{gtroff}'s
14551 escape sequences @w{@code{\D'F @dots{}'}} and @code{\M} (with no other
14552 corresponding graphics commands).  No position changing.  This command
14553 is a @code{gtroff} extension.
14555 @table @code
14556 @item DFc @var{cyan} @var{magenta} @var{yellow}@angles{line break}
14557 Set fill color for solid drawing objects using the CMY color scheme,
14558 having the 3@tie{}color components @var{cyan}, @var{magenta}, and
14559 @var{yellow}.
14561 @item DFd@angles{line break}
14562 Set fill color for solid drawing objects to the default fill color value
14563 (black in most cases).  No component arguments.
14565 @item DFg @var{gray}@angles{line break}
14566 Set fill color for solid drawing objects to the shade of gray given by
14567 the argument, an integer between 0 (black) and 65536 (white).
14569 @item DFk @var{cyan} @var{magenta} @var{yellow} @var{black}@angles{line break}
14570 Set fill color for solid drawing objects using the CMYK color scheme,
14571 having the 4@tie{}color components @var{cyan}, @var{magenta}, @var{yellow},
14572 and @var{black}.
14574 @item DFr @var{red} @var{green} @var{blue}@angles{line break}
14575 Set fill color for solid drawing objects using the RGB color scheme,
14576 having the 3@tie{}color components @var{red}, @var{green}, and @var{blue}.
14577 @end table
14579 @item Df @var{n}@angles{line break}
14580 The argument@tie{}@var{n} must be an integer in the range @math{-32767}
14581 to 32767.
14583 @table @asis
14584 @item @math{0 @LE @var{n} @LE 1000}
14585 Set the color for filling solid drawing objects to a shade of gray,
14586 where 0 corresponds to solid white, 1000 (the default) to solid black,
14587 and values in between to intermediate shades of gray; this is
14588 obsoleted by command @samp{DFg}.
14590 @item @math{@var{n} < 0} or @math{@var{n} > 1000}
14591 Set the filling color to the color that is currently being used for
14592 the text and the outline, see command @samp{m}.  For example, the
14593 command sequence
14595 @Example
14596 mg 0 0 65536
14597 Df -1
14598 @endExample
14600 @noindent
14601 sets all colors to blue.
14602 @end table
14604 @noindent
14605 No position changing.  This command is a @code{gtroff} extension.
14607 @item Dl @var{h} @var{v}@angles{line break}
14608 Draw line from current position to offset (@var{h},@var{v}) (integers
14609 in basic units @samp{u}); then set current position to the end of the
14610 drawn line.
14612 @item Dp @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
14613 Draw a polygon line from current position to offset (@var{h1},@var{v1}),
14614 from there to offset (@var{h2},@var{v2}), etc.@: up to offset
14615 (@var{hn},@var{vn}), and from there back to the starting position.
14616 For historical reasons, the position is changed by adding the sum of
14617 all arguments with odd index to the actual horizontal position and the
14618 even ones to the vertical position.  Although this doesn't make sense
14619 it is kept for compatibility.
14620 @ignore
14621 As the polygon is closed, the end of drawing is the starting point, so
14622 the position doesn't change.
14623 @end ignore
14624 This command is a @code{gtroff} extension.
14626 @item Dp @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
14627 Draw a solid polygon in the current fill color rather than an outlined
14628 polygon, using the same arguments and positioning as the corresponding
14629 @samp{Dp} command.
14630 @ignore
14631 No position changing.
14632 @end ignore
14633 This command is a @code{gtroff} extension.
14635 @item Dt @var{n}@angles{line break}
14636 Set the current line thickness to@tie{}@var{n} (an integer in basic
14637 units @samp{u}) if @math{@var{n}>0}; if @math{@var{n}=0} select the
14638 smallest available line thickness; if @math{@var{n}<0} set the line
14639 thickness proportional to the point size (this is the default before
14640 the first @samp{Dt} command was specified).  For historical reasons,
14641 the horizontal position is changed by adding the argument to the actual
14642 horizontal position, while the vertical position is not changed.
14643 Although this doesn't make sense it is kept for compatibility.
14644 @ignore
14645 No position changing.
14646 @end ignore
14647 This command is a @code{gtroff} extension.
14648 @end table
14650 @node Device Control Commands, Obsolete Command, Graphics Commands, Command Reference
14651 @subsubsection Device Control Commands
14653 Each device control command starts with the letter @samp{x},
14654 followed by a space character (optional or arbitrary space or tab in
14655 @code{gtroff}) and a subcommand letter or word; each argument (if any)
14656 must be preceded by a syntactical space.  All @samp{x} commands are
14657 terminated by a syntactical line break; no device control command can
14658 be followed by another command on the same line (except a comment).
14660 The subcommand is basically a single letter, but to increase
14661 readability, it can be written as a word, i.e., an arbitrary sequence
14662 of characters terminated by the next tab, space, or newline character.
14663 All characters of the subcommand word but the first are simply ignored.
14664 For example, @code{gtroff} outputs the initialization command
14665 @w{@samp{x i}} as @w{@samp{x init}} and the resolution command
14666 @w{@samp{x r}} as @w{@samp{x res}}.
14668 In the following, the syntax element @angles{line break} means a
14669 syntactical line break (@pxref{Separation}).
14671 @table @code
14672 @item xF @var{name}@angles{line break}
14673 The @samp{F} stands for @var{Filename}.
14675 Use @var{name} as the intended name for the current file in error
14676 reports.  This is useful for remembering the original file name when
14677 @code{gtroff} uses an internal piping mechanism.  The input file is
14678 not changed by this command.  This command is a @code{gtroff} extension.
14680 @item xf @var{n} @var{s}@angles{line break}
14681 The @samp{f} stands for @var{font}.
14683 Mount font position@tie{}@var{n} (a non-negative integer) with font
14684 named@tie{}@var{s} (a text word).  @xref{Font Positions}.
14686 @item xH @var{n}@angles{line break}
14687 The @samp{H} stands for @var{Height}.
14689 Set glyph height to@tie{}@var{n} (a positive integer in scaled
14690 points @samp{z}).  @acronym{AT&T} @code{troff} uses the unit points
14691 (@samp{p}) instead.  @xref{Output Language Compatibility}.
14693 @item xi@angles{line break}
14694 The @samp{i} stands for @var{init}.
14696 Initialize device.  This is the third command of the prologue.
14698 @item xp@angles{line break}
14699 The @samp{p} stands for @var{pause}.
14701 Parsed but ignored.  The original @acronym{UNIX} troff manual writes
14703 @display
14704 pause device, can be restarted
14705 @end display
14707 @item xr @var{n} @var{h} @var{v}@angles{line break}
14708 The @samp{r} stands for @var{resolution}.
14710 Resolution is@tie{}@var{n}, while @var{h} is the minimal horizontal
14711 motion, and @var{v} the minimal vertical motion possible with this
14712 device; all arguments are positive integers in basic units @samp{u}
14713 per inch.  This is the second command of the prologue.
14715 @item xS @var{n}@angles{line break}
14716 The @samp{S} stands for @var{Slant}.
14718 Set slant to@tie{}@var{n} (an integer in basic units @samp{u}).
14720 @item xs@angles{line break}
14721 The @samp{s} stands for @var{stop}.
14723 Terminates the processing of the current file; issued as the last
14724 command of any intermediate troff output.
14726 @item xt@angles{line break}
14727 The @samp{t} stands for @var{trailer}.
14729 Generate trailer information, if any.  In @var{gtroff}, this is
14730 actually just ignored.
14732 @item xT @var{xxx}@angles{line break}
14733 The @samp{T} stands for @var{Typesetter}.
14735 Set name of device to word @var{xxx}, a sequence of characters ended
14736 by the next white space character.  The possible device names coincide
14737 with those from the @code{groff} @option{-T} option.  This is the first
14738 command of the prologue.
14740 @item xu @var{n}@angles{line break}
14741 The @samp{u} stands for @var{underline}.
14743 Configure underlining of spaces.  If @var{n} is@tie{}1, start
14744 underlining of spaces; if @var{n} is@tie{}0, stop underlining of spaces.
14745 This is needed for the @code{cu} request in nroff mode and is ignored
14746 otherwise.  This command is a @code{gtroff} extension.
14748 @item xX @var{anything}@angles{line break}
14749 The @samp{x} stands for @var{X-escape}.
14751 Send string @var{anything} uninterpreted to the device.  If the line
14752 following this command starts with a @samp{+} character this line is
14753 interpreted as a continuation line in the following sense.  The
14754 @samp{+} is ignored, but a newline character is sent instead to the
14755 device, the rest of the line is sent uninterpreted.  The same applies
14756 to all following lines until the first character of a line is not a
14757 @samp{+} character.  This command is generated by the @code{gtroff}
14758 escape sequence @code{\X}.  The line-continuing feature is a
14759 @code{gtroff} extension.
14760 @end table
14762 @node Obsolete Command,  , Device Control Commands, Command Reference
14763 @subsubsection Obsolete Command
14764 In @acronym{AT&T} @code{troff} output, the writing of a single
14765 glyph is mostly done by a very strange command that combines a
14766 horizontal move and a single character giving the glyph name.  It
14767 doesn't have a command code, but is represented by a 3-character
14768 argument consisting of exactly 2@tie{}digits and a character.
14770 @table @asis
14771 @item @var{dd}@var{g}
14772 Move right @var{dd} (exactly two decimal digits) basic units @samp{u},
14773 then print glyph@tie{}@var{g} (represented as a single character).
14775 In @code{gtroff}, arbitrary syntactical space around and within this
14776 command is allowed to be added.  Only when a preceding command on the
14777 same line ends with an argument of variable length a separating space
14778 is obligatory.  In @acronym{AT&T} @code{troff}, large clusters of these
14779 and other commands are used, mostly without spaces; this made such output
14780 almost unreadable.
14781 @end table
14783 For modern high-resolution devices, this command does not make sense
14784 because the width of the glyphs can become much larger than two
14785 decimal digits.  In @code{gtroff}, this is only used for the devices
14786 @code{X75}, @code{X75-12}, @code{X100}, and @code{X100-12}.  For other
14787 devices, the commands @samp{t} and @samp{u} provide a better
14788 functionality.
14790 @c ---------------------------------------------------------------------
14792 @node Intermediate Output Examples, Output Language Compatibility, Command Reference, gtroff Output
14793 @subsection Intermediate Output Examples
14795 This section presents the intermediate output generated from the same
14796 input for three different devices.  The input is the sentence
14797 @samp{hell world} fed into @code{gtroff} on the command line.
14799 @table @asis
14800 @item High-resolution device @code{ps}
14802 This is the standard output of @code{gtroff} if no @option{-T} option
14803 is given.
14805 @example
14806 @group
14807 shell> echo "hell world" | groff -Z -T ps
14809 x T ps
14810 x res 72000 1 1
14811 x init
14812 @end group
14814 x font 5 TR
14816 s10000
14817 V12000
14818 H72000
14819 thell
14820 wh2500
14822 H96620
14823 torld
14824 n12000 0
14825 @group
14826 x trailer
14827 V792000
14828 x stop
14829 @end group
14830 @end example
14832 @noindent
14833 This output can be fed into @code{grops} to get its representation as
14834 a PostScript file.
14836 @item Low-resolution device @code{latin1}
14838 This is similar to the high-resolution device except that the
14839 positioning is done at a minor scale.  Some comments (lines starting
14840 with @samp{#}) were added for clarification; they were not generated
14841 by the formatter.
14843 @example
14844 @group
14845 shell> echo "hell world" | groff -Z -T latin1
14847 # prologue
14848 x T latin1
14849 x res 240 24 40
14850 x init
14851 @end group
14852 # begin a new page
14854 # font setup
14855 x font 1 R
14858 # initial positioning on the page
14861 # write text `hell'
14862 thell
14863 # inform about space, and issue a horizontal jump
14864 wh24
14865 # write text `world'
14866 tworld
14867 # announce line break, but do nothing because ...
14868 n40 0
14869 @group
14870 # ... the end of the document has been reached
14871 x trailer
14872 V2640
14873 x stop
14874 @end group
14875 @end example
14877 @noindent
14878 This output can be fed into @code{grotty} to get a formatted text
14879 document.
14881 @item @acronym{AT&T} @code{troff} output
14882 Since a computer monitor has a very low resolution compared to modern
14883 printers the intermediate output for the X@tie{}Window devices can use
14884 the jump-and-write command with its 2-digit displacements.
14886 @example
14887 @group
14888 shell> echo "hell world" | groff -Z -T X100
14890 x T X100
14891 x res 100 1 1
14892 x init
14893 @end group
14895 x font 5 TR
14899 H100
14900 # write text with jump-and-write commands
14901 ch07e07l03lw06w11o07r05l03dh7
14902 n16 0
14903 @group
14904 x trailer
14905 V1100
14906 x stop
14907 @end group
14908 @end example
14910 @noindent
14911 This output can be fed into @code{xditview} or @code{gxditview}
14912 for displaying in@tie{}X.
14914 Due to the obsolete jump-and-write command, the text clusters in the
14915 @acronym{AT&T} @code{troff} output are almost unreadable.
14916 @end table
14918 @c ---------------------------------------------------------------------
14920 @node Output Language Compatibility,  , Intermediate Output Examples, gtroff Output
14921 @subsection Output Language Compatibility
14923 The intermediate output language of @acronym{AT&T} @code{troff}
14924 was first documented in the @acronym{UNIX} troff manual, with later
14925 additions documented in @cite{A Typesetter-indenpendent TROFF},
14926 written by Brian Kernighan.
14928 The @code{gtroff} intermediate output format is compatible with this
14929 specification except for the following features.
14931 @itemize @bullet
14932 @item
14933 The classical quasi device independence is not yet implemented.
14935 @item
14936 The old hardware was very different from what we use today.  So the
14937 @code{groff} devices are also fundamentally different from the ones in
14938 @acronym{AT&T} @code{troff}.  For example, the @acronym{AT&T}
14939 PostScript device is called @code{post} and has a resolution of only
14940 720 units per inch, suitable for printers 20 years ago, while
14941 @code{groff}'s @code{ps} device has a resolution of
14942 72000 units per inch.  Maybe, by implementing some rescaling
14943 mechanism similar to the classical quasi device independence,
14944 @code{groff} could emulate @acronym{AT&T}'s @code{post} device.
14946 @item
14947 The B-spline command @samp{D~} is correctly handled by the
14948 intermediate output parser, but the drawing routines aren't
14949 implemented in some of the postprocessor programs.
14951 @item
14952 The argument of the commands @samp{s} and @w{@samp{x H}} has the
14953 implicit unit scaled point @samp{z} in @code{gtroff}, while
14954 @acronym{AT&T} @code{troff} has point (@samp{p}).  This isn't an
14955 incompatibility but a compatible extension, for both units coincide
14956 for all devices without a @code{sizescale} parameter in the @file{DESC}
14957 file, including all postprocessors from @acronym{AT&T} and
14958 @code{groff}'s text devices.  The few @code{groff} devices with
14959 a @code{sizescale} parameter either do not exist for @acronym{AT&T}
14960 @code{troff}, have a different name, or seem to have a different
14961 resolution.  So conflicts are very unlikely.
14963 @item
14964 The position changing after the commands @samp{Dp}, @samp{DP}, and
14965 @samp{Dt} is illogical, but as old versions of @code{gtroff} used this
14966 feature it is kept for compatibility reasons.
14968 @ignore
14969 Temporarily, there existed some confusion on the positioning after the
14970 @samp{D} commands that are groff extensions.  This has been clarified
14971 by establishing the classical rule for all @code{groff} drawing commands:
14973 @itemize
14974 @item
14975 The position after a graphic object has been drawn is at its end;
14976 for circles and ellipses, the `end' is at the right side.
14978 @item
14979 From this, the positionings specified for the drawing commands above
14980 follow quite naturally.
14981 @end itemize
14982 @end ignore
14984 @end itemize
14987 @c =====================================================================
14989 @node Font Files,  , gtroff Output, File formats
14990 @section Font Files
14991 @cindex font files
14992 @cindex files, font
14994 The @code{gtroff} font format is roughly a superset of the
14995 @code{ditroff} font format (as used in later versions of @acronym{AT&T}
14996 @code{troff} and its descendants).  Unlike the @code{ditroff} font
14997 format, there is no associated binary format; all files are text
14998 files.@footnote{Plan@tie{}9 @code{troff} has also abandoned the binary
14999 format.}  The font files for device @var{name} are stored in a directory
15000 @file{dev@var{name}}.  There are two types of file: a device description
15001 file called @file{DESC} and for each font@tie{}@var{f} a font file
15002 called@tie{}@file{@var{f}}.
15004 @menu
15005 * DESC File Format::
15006 * Font File Format::
15007 @end menu
15009 @c ---------------------------------------------------------------------
15011 @node DESC File Format, Font File Format, Font Files, Font Files
15012 @subsection @file{DESC} File Format
15013 @cindex @file{DESC} file, format
15014 @cindex font description file, format
15015 @cindex format of font description file
15016 @pindex DESC@r{ file format}
15018 The @file{DESC} file can contain the following types of line.  Except
15019 for the @code{charset} keyword which must comes last (if at all), the
15020 order of the lines is not important.
15022 @table @code
15023 @item res @var{n}
15024 @kindex res
15025 @cindex device resolution
15026 @cindex resolution, device
15027 There are @var{n}@tie{}machine units per inch.
15029 @item hor @var{n}
15030 @kindex hor
15031 @cindex horizontal resolution
15032 @cindex resolution, horizontal
15033 The horizontal resolution is @var{n}@tie{}machine units.  All horizontal
15034 quantities are rounded to be multiples of this value.
15036 @item vert @var{n}
15037 @kindex vert
15038 @cindex vertical resolution
15039 @cindex resolution, vertical
15040 The vertical resolution is @var{n}@tie{}machine units.  All vertical
15041 quantities are rounded to be multiples of this value.
15043 @item sizescale @var{n}
15044 @kindex sizescale
15045 The scale factor for point sizes.  By default this has a value of@tie{}1.
15046 One scaled point is equal to one point/@var{n}.  The arguments to the
15047 @code{unitwidth} and @code{sizes} commands are given in scaled points.
15048 @xref{Fractional Type Sizes}, for more information.
15050 @item unitwidth @var{n}
15051 @kindex unitwidth
15052 Quantities in the font files are given in machine units for fonts whose
15053 point size is @var{n}@tie{}scaled points.
15055 @item prepro @var{program}
15056 @kindex prepro
15057 Call @var{program} as a preprocessor.  Currently, this keyword is used
15058 by @code{groff} with option @option{-Thtml} only.
15060 @item postpro @var{program}
15061 @kindex postpro
15062 Call @var{program} as a postprocessor.  For example, the line
15064 @Example
15065 postpro grodvi
15066 @endExample
15068 @noindent
15069 in the file @file{devdvi/DESC} makes @code{groff} call @code{grodvi}
15070 if option @option{-Tdvi} is given (and @option{-Z} isn't used).
15072 @item tcommand
15073 @kindex tcommand
15074 This means that the postprocessor can handle the @samp{t} and @samp{u}
15075 intermediate output commands.
15077 @item sizes @var{s1} @var{s2} @dots{} @var{sn} 0
15078 @kindex sizes
15079 This means that the device has fonts at @var{s1}, @var{s2}, @dots{}
15080 @var{sn} scaled points.  The list of sizes must be terminated by@tie{}0
15081 (this is digit zero).  Each @var{si} can also be a range of sizes
15082 @var{m}-@var{n}.  The list can extend over more than one line.
15084 @item styles @var{S1} @var{S2} @dots{} @var{Sm}
15085 @kindex styles
15086 The first @var{m}@tie{}font positions are associated with styles
15087 @var{S1} @dots{} @var{Sm}.
15089 @item fonts @var{n} @var{F1} @var{F2} @var{F3} @dots{} @var{Fn}
15090 @kindex fonts
15091 Fonts @var{F1} @dots{} @var{Fn} are mounted in the font positions
15092 @var{m}+1, @dots{}, @var{m}+@var{n} where @var{m} is the number of
15093 styles.  This command may extend over more than one line.  A font name
15094 of@tie{}0 means no font is mounted on the corresponding font position.
15096 @item family @var{fam}
15097 @kindex family
15098 The default font family is @var{fam}.
15100 @item use_charnames_in_special
15101 @kindex use_charnames_in_special
15102 This command indicates that @code{gtroff} should encode special
15103 characters inside special commands.  Currently, this is only used
15104 by the @acronym{HTML} output device.  @xref{Postprocessor Access}.
15106 @item papersize @var{string} @dots{}
15107 @kindex papersize
15108 Select a paper size.  Valid values for @var{string} are the ISO paper
15109 types @code{A0}-@code{A7}, @code{B0}-@code{B7}, @code{C0}-@code{C7},
15110 @code{D0}-@code{D7}, @code{DL}, and the US paper types @code{letter},
15111 @code{legal}, @code{tabloid}, @code{ledger}, @code{statement},
15112 @code{executive}, @code{com10}, and @code{monarch}.  Case is not significant
15113 for @var{string} if it holds predefined paper types.  Alternatively,
15114 @var{string} can be a file name (e.g.@: @file{/etc/papersize}); if the file
15115 can be opened, @code{groff} reads the first line and tests for the above
15116 paper sizes.  Finally, @var{string} can be a custom paper size in the format
15117 @code{@var{length},@var{width}} (no spaces before and after the comma).
15118 Both @var{length} and @var{width} must have a unit appended; valid values
15119 are @samp{i} for inches, @samp{C} for centimeters, @samp{p} for points, and
15120 @samp{P} for picas.  Example: @code{12c,235p}.  An argument which starts
15121 with a digit is always treated as a custom paper format.  @code{papersize}
15122 sets both the vertical and horizontal dimension of the output medium.
15124 More than one argument can be specified; @code{groff} scans from left to
15125 right and uses the first valid paper specification.
15127 @item pass_filenames
15128 @kindex pass_filenames
15129 Tell @code{gtroff} to emit the name of the source file currently
15130 being processed.  This is achieved by the intermediate output command
15131 @samp{F}.  Currently, this is only used by the @acronym{HTML} output
15132 device.
15134 @item print @var{program}
15135 @kindex print
15136 Use @var{program} as a spooler program for printing.  If omitted,
15137 the @option{-l} and @option{-L} options of @code{groff} are ignored.
15139 @item charset
15140 @kindex charset
15141 This line and everything following in the file are ignored.  It is
15142 allowed for the sake of backwards compatibility.
15143 @end table
15145 The @code{res}, @code{unitwidth}, @code{fonts}, and @code{sizes} lines
15146 are mandatory.  Other commands are ignored by @code{gtroff} but may be
15147 used by postprocessors to store arbitrary information about the device
15148 in the @file{DESC} file.
15150 @kindex spare1
15151 @kindex spare2
15152 @kindex biggestfont
15153 Here a list of obsolete keywords which are recognized by @code{groff}
15154 but completely ignored: @code{spare1}, @code{spare2},
15155 @code{biggestfont}.
15157 @c ---------------------------------------------------------------------
15159 @node Font File Format,  , DESC File Format, Font Files
15160 @subsection Font File Format
15161 @cindex font file, format
15162 @cindex font description file, format
15163 @cindex format of font files
15164 @cindex format of font description files
15166 A @dfn{font file}, also (and probably better) called a @dfn{font
15167 description file}, has two sections.  The first section is a sequence
15168 of lines each containing a sequence of blank delimited words; the first
15169 word in the line is a key, and subsequent words give a value for that
15170 key.
15172 @table @code
15173 @item name @var{f}
15174 @kindex name
15175 The name of the font is@tie{}@var{f}.
15177 @item spacewidth @var{n}
15178 @kindex spacewidth
15179 The normal width of a space is@tie{}@var{n}.
15181 @item slant @var{n}
15182 @kindex slant
15183 The glyphs of the font have a slant of @var{n}@tie{}degrees.
15184 (Positive means forward.)
15186 @item ligatures @var{lig1} @var{lig2} @dots{} @var{lign} [0]
15187 @kindex ligatures
15188 Glyphs @var{lig1}, @var{lig2}, @dots{}, @var{lign} are ligatures;
15189 possible ligatures are @samp{ff}, @samp{fi}, @samp{fl}, @samp{ffi} and
15190 @samp{ffl}.  For backwards compatibility, the list of ligatures may be
15191 terminated with a@tie{}0.  The list of ligatures may not extend over more
15192 than one line.
15194 @item special
15195 @cindex special fonts
15196 @kindex special
15197 The font is @dfn{special}; this means that when a glyph is requested
15198 that is not present in the current font, it is searched for in any
15199 special fonts that are mounted.
15200 @end table
15202 Other commands are ignored by @code{gtroff} but may be used by
15203 postprocessors to store arbitrary information about the font in the font
15204 file.
15206 @cindex comments in font files
15207 @cindex font files, comments
15208 @kindex #
15209 The first section can contain comments which start with the @samp{#}
15210 character and extend to the end of a line.
15212 The second section contains one or two subsections.  It must contain a
15213 @code{charset} subsection and it may also contain a @code{kernpairs}
15214 subsection.  These subsections can appear in any order.  Each
15215 subsection starts with a word on a line by itself.
15217 @kindex charset
15218 The word @code{charset} starts the character set
15219 subsection.@footnote{This keyword is misnamed since it starts a list
15220 of ordered glyphs, not characters.}  The @code{charset} line is
15221 followed by a sequence of lines.  Each line gives information for one
15222 glyph.  A line comprises a number of fields separated by blanks or
15223 tabs.  The format is
15225 @quotation
15226 @var{name} @var{metrics} @var{type} @var{code}
15227 [@var{entity-name}] [@code{--} @var{comment}]
15228 @end quotation
15230 @cindex 8-bit input
15231 @cindex input, 8-bit
15232 @cindex accessing unnamed glyphs with @code{\N}
15233 @cindex unnamed glyphs, accessing with @code{\N}
15234 @cindex characters, unnamed, accessing with @code{\N}
15235 @cindex glyphs, unnamed, accessing with @code{\N}
15236 @kindex ---
15237 @noindent
15238 @var{name} identifies the glyph name@footnote{The distinction between
15239 input, characters, and output, glyphs, is not clearly separated in the
15240 terminology of @code{groff}; for example, the @code{char} request
15241 should be called @code{glyph} since it defines an output entity.}:
15242 If @var{name} is a single character@tie{}@var{c} then it corresponds
15243 to the @code{gtroff} input character@tie{}@var{c}; if it is of the form
15244 @samp{\@var{c}} where @var{c} is a single character, then it
15245 corresponds to the special character @code{\[@var{c}]}; otherwise it
15246 corresponds to the special character @samp{\[@var{name}]}.  If it
15247 is exactly two characters @var{xx} it can be entered as
15248 @samp{\(@var{xx}}.  Note that single-letter special characters can't
15249 be accessed as @samp{\@var{c}}; the only exception is @samp{\-} which
15250 is identical to @code{\[-]}.
15252 @code{gtroff} supports 8-bit input characters; however some utilities
15253 have difficulties with eight-bit characters.  For this reason, there is
15254 a convention that the entity name @samp{char@var{n}} is equivalent to
15255 the single input character whose code is@tie{}@var{n}.  For example,
15256 @samp{char163} would be equivalent to the character with code@tie{}163
15257 which is the pounds sterling sign in the ISO@tie{}@w{Latin-1} character set.
15258 You shouldn't use @samp{char@var{n}} entities in font description files
15259 since they are related to input, not output.  Otherwise, you get
15260 hard-coded connections between input and output encoding which
15261 prevents use of different (input) character sets.
15263 The name @samp{---} is special and indicates that the glyph is
15264 unnamed; such glyphs can only be used by means of the @code{\N}
15265 escape sequence in @code{gtroff}.
15267 The @var{type} field gives the glyph type:
15269 @table @code
15270 @item 1
15271 the glyph has a descender, for example, @samp{p};
15273 @item 2
15274 the glyph has an ascender, for example, @samp{b};
15276 @item 3
15277 the glyph has both an ascender and a descender, for example, @samp{(}.
15278 @end table
15280 The @var{code} field gives the code which the postprocessor uses to
15281 print the glyph.  The glyph can also be input to @code{gtroff}
15282 using this code by means of the @code{\N} escape sequence.  @var{code}
15283 can be any integer.  If it starts with @samp{0} it is interpreted as
15284 octal; if it starts with @samp{0x} or @samp{0X} it is interpreted as
15285 hexadecimal.  Note, however, that the @code{\N} escape sequence only
15286 accepts a decimal integer.
15288 The @var{entity-name} field gives an @acronym{ASCII} string
15289 identifying the glyph which the postprocessor uses to print the
15290 @code{gtroff} glyph @var{name}.  This field is optional and has been
15291 introduced so that the @acronym{HTML} device driver can encode its
15292 character set.  For example, the glyph @samp{\[Po]} is
15293 represented as @samp{&pound;} in @acronym{HTML} 4.0.
15295 Anything on the line after the @var{entity-name} field resp.@: after
15296 @samp{--} will be ignored.
15298 The @var{metrics} field has the form:
15300 @display
15301 @group
15302 @var{width}[@code{,}@var{height}[@code{,}@var{depth}[@code{,}@var{italic-correction}
15303   [@code{,}@var{left-italic-correction}[@code{,}@var{subscript-correction}]]]]]
15304 @end group
15305 @end display
15307 @noindent
15308 There must not be any spaces between these subfields (it has been split
15309 here into two lines for better legibility only).  Missing subfields are
15310 assumed to be@tie{}0.  The subfields are all decimal integers.  Since
15311 there is no associated binary format, these values are not required to
15312 fit into a variable of type @samp{char} as they are in @code{ditroff}.
15313 The @var{width} subfield gives the width of the glyph.  The @var{height}
15314 subfield gives the height of the glyph (upwards is positive); if a
15315 glyph does not extend above the baseline, it should be given a zero
15316 height, rather than a negative height.  The @var{depth} subfield gives
15317 the depth of the glyph, that is, the distance from the baseline to the
15318 lowest point below the baseline to which the glyph extends (downwards is
15319 positive); if a glyph does not extend below the baseline, it should be
15320 given a zero depth, rather than a negative depth.  The
15321 @var{italic-correction} subfield gives the amount of space that should
15322 be added after the glyph when it is immediately to be followed by a
15323 glyph from a roman font.  The @var{left-italic-correction} subfield
15324 gives the amount of space that should be added before the glyph when it
15325 is immediately to be preceded by a glyph from a roman font.  The
15326 @var{subscript-correction} gives the amount of space that should be
15327 added after a glyph before adding a subscript.  This should be less
15328 than the italic correction.
15330 A line in the @code{charset} section can also have the format
15332 @Example
15333 @var{name} "
15334 @endExample
15336 @noindent
15337 This indicates that @var{name} is just another name for the glyph
15338 mentioned in the preceding line.
15340 @kindex kernpairs
15341 The word @code{kernpairs} starts the kernpairs section.  This contains a
15342 sequence of lines of the form:
15344 @Example
15345 @var{c1} @var{c2} @var{n}
15346 @endExample
15348 @noindent
15349 This means that when glyph @var{c1} appears next to glyph @var{c2}
15350 the space between them should be increased by@tie{}@var{n}.  Most
15351 entries in the kernpairs section have a negative value for@tie{}@var{n}.
15355 @c =====================================================================
15356 @c =====================================================================
15358 @node Installation, Copying This Manual, File formats, Top
15359 @chapter Installation
15360 @cindex installation
15362 @c XXX
15366 @c =====================================================================
15367 @c =====================================================================
15369 @node Copying This Manual, Request Index, Installation, Top
15370 @appendix Copying This Manual
15372 @menu
15373 * GNU Free Documentation License::  License for copying this manual.
15374 @end menu
15376 @include fdl.texi
15380 @c =====================================================================
15381 @c =====================================================================
15383 @node Request Index, Escape Index, Copying This Manual, Top
15384 @appendix Request Index
15386 Requests appear without the leading control character (normally either
15387 @samp{.} or @samp{'}).
15389 @printindex rq
15393 @c =====================================================================
15394 @c =====================================================================
15396 @node Escape Index, Operator Index, Request Index, Top
15397 @appendix Escape Index
15399 Any escape sequence @code{\@var{X}} with @var{X} not in the list below
15400 emits a warning, printing glyph @var{X}.
15402 @printindex es
15406 @c =====================================================================
15407 @c =====================================================================
15409 @node Operator Index, Register Index, Escape Index, Top
15410 @appendix Operator Index
15412 @printindex op
15416 @c =====================================================================
15417 @c =====================================================================
15419 @node Register Index, Macro Index, Operator Index, Top
15420 @appendix Register Index
15422 The macro package or program a specific register belongs to is appended in
15423 brackets.
15425 A register name@tie{}@code{x} consisting of exactly one character can be
15426 accessed as @samp{\nx}.  A register name @code{xx} consisting of exactly
15427 two characters can be accessed as @samp{\n(xx}.  Register names @code{xxx}
15428 of any length can be accessed as @samp{\n[xxx]}.
15430 @printindex vr
15434 @c =====================================================================
15435 @c =====================================================================
15437 @node Macro Index, String Index, Register Index, Top
15438 @appendix Macro Index
15440 The macro package a specific macro belongs to is appended in brackets.
15441 They appear without the leading control character (normally @samp{.}).
15443 @printindex ma
15447 @c =====================================================================
15448 @c =====================================================================
15450 @node String Index, Glyph Name Index, Macro Index, Top
15451 @appendix String Index
15453 The macro package or program a specific string belongs to is appended in
15454 brackets.
15456 A string name@tie{}@code{x} consisting of exactly one character can be
15457 accessed as @samp{\*x}.  A string name @code{xx} consisting of exactly
15458 two characters can be accessed as @samp{\*(xx}.  String names @code{xxx}
15459 of any length can be accessed as @samp{\*[xxx]}.
15462 @printindex st
15466 @c =====================================================================
15467 @c =====================================================================
15469 @node Glyph Name Index, Font File Keyword Index, String Index, Top
15470 @appendix Glyph Name Index
15472 A glyph name @code{xx} consisting of exactly two characters can be
15473 accessed as @samp{\(xx}.  Glyph names @code{xxx} of any length can be
15474 accessed as @samp{\[xxx]}.
15476 @c XXX
15480 @c =====================================================================
15481 @c =====================================================================
15483 @node Font File Keyword Index, Program and File Index, Glyph Name Index, Top
15484 @appendix Font File Keyword Index
15486 @printindex ky
15490 @c =====================================================================
15491 @c =====================================================================
15493 @node Program and File Index, Concept Index, Font File Keyword Index, Top
15494 @appendix Program and File Index
15496 @printindex pg
15500 @c =====================================================================
15501 @c =====================================================================
15503 @node Concept Index,  , Program and File Index, Top
15504 @appendix Concept Index
15506 @printindex cp
15509 @bye