* tmac/groff_ms.man, doc/groff.texinfo: Document changes from
[s-roff.git] / doc / groff.texinfo
blob9f67e65017f2262650bc174490446bb72f54c61d
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 @Defmpreg {PSINCR, ms}
2864 Defines an increment in point size, which will be applied to section
2865 headings at nesting levels below the value specified in @code{GROWPS}.  The
2866 value of @code{PSINCR} should be specified in points, with the @dmn{p}
2867 scaling factor, and may include a fractional component; for example,
2868 @w{@samp{.nr PSINCR 1.5p}} sets a point size increment of 1.5@dmn{p}.
2870 Effective: next section heading.
2872 Default: 1@dmn{p}.
2873 @endDefmpreg
2875 @Defmpreg {GROWPS, ms}
2876 Defines the heading level below which the point size increment set by
2877 @code{PSINCR} becomes effective.  Section headings at and above the level
2878 specified by @code{GROWPS} will be printed at the point size set by @code{PS};
2879 for each level below the value of @code{GROWPS}, the point size will be
2880 increased in steps equal to the value of @code{PSINCR}.  Setting @code{GROWPS}
2881 to any value less than@tie{}2 disables the incremental heading size feature.
2883 Effective: next section heading.
2885 Default: 0.
2886 @endDefmpreg
2888 @unnumberedsubsubsec Paragraph Settings
2890 @Defmpreg {PI, ms}
2891 Defines the initial indent of a @code{.PP} paragraph.
2893 Effective: next paragraph.
2895 Default: 5@dmn{n}.
2896 @endDefmpreg
2898 @Defmpreg {PD, ms}
2899 Defines the space between paragraphs.
2901 Effective: next paragraph.
2903 Default: 0.3@dmn{v}.
2904 @endDefmpreg
2906 @Defmpreg {QI, ms}
2907 Defines the indent on both sides of a quoted (@code{.QP}) paragraph.
2909 Effective: next paragraph.
2911 Default: 5@dmn{n}.
2912 @endDefmpreg
2914 @Defmpreg {PORPHANS, ms}
2915 Defines the minimum number of initial lines of any paragraph which should
2916 be kept together, to avoid orphan lines at the bottom of a page.  If a new
2917 paragraph is started close to the bottom of a page, and there is insufficient
2918 space to accommodate @code{PORPHANS} lines before an automatic page break,
2919 then the page break will be forced, before the start of the paragraph.
2921 Effective: next paragraph.
2923 Default: 1.
2924 @endDefmpreg
2926 @Defmpreg {HORPHANS, ms}
2927 Defines the minimum number of lines of the following paragraph which should
2928 be kept together with any section heading introduced by the @code{NH} or
2929 @code{SH} macros.  If a section heading is placed close to the bottom of a
2930 page, and there is insufficient space to accommodate both the heading and
2931 at least @code{HORPHANS} lines of the following paragraph, before an
2932 automatic page break, then the page break will be forced before the heading.
2934 Effective: next paragraph.
2936 Default: 1.
2937 @endDefmpreg
2939 @unnumberedsubsubsec Footnote Settings
2941 @Defmpreg {FL, ms}
2942 Defines the length of a footnote.
2944 Effective: next footnote.
2946 Default: @math{@code{@\n[LL]} * 5 / 6}.
2947 @endDefmpreg
2949 @Defmpreg {FI, ms}
2950 Defines the footnote indent.
2952 Effective: next footnote.
2954 Default: 2@dmn{n}.
2955 @endDefmpreg
2957 @Defmpreg {FF, ms}
2958 The footnote format:
2959 @table @code
2960 @item 0
2961 Prints the footnote number as a superscript; indents the footnote (default).
2963 @item 1
2964 Prints the number followed by a period (like 1.)
2965 and indents the footnote.
2967 @item 2
2968 Like 1, without an indent.
2970 @item 3
2971 Like 1, but prints the footnote number as a hanging paragraph.
2972 @end table
2974 Effective: next footnote.
2976 Default: 0.
2977 @endDefmpreg
2979 @Defmpreg {FPS, ms}
2980 Defines the footnote point size.  If the value is larger than or equal to
2981 1000, divide it by 1000 to get a fractional point size.
2983 Effective: next footnote.
2985 Default: @math{@code{@\n[PS]} - 2}.
2986 @endDefmpreg
2988 @Defmpreg {FVS, ms}
2989 Defines the footnote vertical spacing.  If the value is larger than or equal
2990 to 1000, divide it by 1000 to get a fractional point size.
2992 Effective: next footnote.
2994 Default: @math{@code{@\n[FPS]} + 2}.
2995 @endDefmpreg
2997 @Defmpreg {FPD, ms}
2998 Defines the footnote paragraph spacing.
3000 Effective: next footnote.
3002 Default: @math{@code{@\n[PD]} / 2}.
3003 @endDefmpreg
3005 @unnumberedsubsubsec Miscellaneous Number Registers
3007 @Defmpreg {MINGW, ms}
3008 Defines the minimum width between columns in a multi-column document.
3010 Effective: next page.
3012 Default: 2@dmn{n}.
3013 @endDefmpreg
3015 @c ---------------------------------------------------------------------
3017 @node ms Cover Page Macros, ms Body Text, ms Document Control Registers, ms
3018 @subsection Cover page macros
3019 @cindex @code{ms} macros, cover page
3020 @cindex cover page macros, [@code{ms}]
3022 Use the following macros to create a cover page for your document
3023 in the order shown.
3025 @Defmac {RP, [@code{no}], ms}
3026 Specifies the report format for your document.
3027 The report format creates a separate cover page.
3028 The default action (no @code{.RP}
3029 macro) is to print a subset of the
3030 cover page on page 1 of your document.
3032 If you use the word @code{no} as an optional argument,
3033 @code{groff} prints a title page but
3034 does not repeat any of the title page information
3035 (title, author, abstract, etc.)
3036 on page 1 of the document.
3037 @endDefmac
3039 @Defmac {DA, [@dots{}], ms}
3040 (optional) Print the current date, or the arguments to the macro if any,
3041 on the title page (if specified) and in the footers.
3042 This is the default for @code{nroff}.
3043 @endDefmac
3045 @Defmac {ND, [@dots{}], ms}
3046 (optional) Print the current date, or the arguments to the macro if any,
3047 on the title page (if specified) but not in the footers.
3048 This is the default for @code{troff}.
3049 @endDefmac
3051 @Defmac {TL, , ms}
3052 Specifies the document title.
3053 @code{groff} collects text following the @code{.TL}
3054 macro into the title, until reaching the author name or abstract.
3055 @endDefmac
3057 @Defmac {AU, , ms}
3058 Specifies the author's name, which appears on the
3059 line (or lines) immediately following.
3060 You can specify multiple authors as follows:
3062 @Example
3064 John Doe
3066 University of West Bumblefuzz
3068 Martha Buck
3070 Monolithic Corporation
3073 @endExample
3074 @endDefmac
3076 @Defmac {AI, , ms}
3077 Specifies the author's institution.
3078 You can specify multiple institutions in the same way
3079 that you specify multiple authors.
3080 @endDefmac
3082 @Defmac {AB, [@code{no}], ms}
3083 Begins the abstract.
3084 The default is to print the word @acronym{ABSTRACT},
3085 centered and in italics, above the text of the abstract.
3086 The word @code{no} as an optional argument suppresses this heading.
3087 @endDefmac
3089 @Defmac {AE, , ms}
3090 End the abstract.
3091 @endDefmac
3093 The following is example mark-up for a title page.
3094 @cindex title page, example markup
3095 @cindex example markup, title page
3097 @Example
3098 @cartouche
3101 The Inevitability of Code Bloat
3102 in Commercial and Free Software
3104 J. Random Luser
3106 University of West Bumblefuzz
3108 This report examines the long-term growth
3109 of the code bases in two large, popular software
3110 packages; the free Emacs and the commercial
3111 Microsoft Word.
3112 While differences appear in the type or order
3113 of features added, due to the different
3114 methodologies used, the results are the same
3115 in the end.
3117 The free software approach is shown to be
3118 superior in that while free software can
3119 become as bloated as commercial offerings,
3120 free software tends to have fewer serious
3121 bugs and the added features are in line with
3122 user demand.
3125 ... the rest of the paper follows ...
3126 @end cartouche
3127 @endExample
3129 @c ---------------------------------------------------------------------
3131 @node ms Body Text, ms Page Layout, ms Cover Page Macros, ms
3132 @subsection Body text
3133 @cindex @code{ms} macros, body text
3135 This section describes macros used to mark up the body of your document.
3136 Examples include paragraphs, sections, and other groups.
3138 @menu
3139 * Paragraphs in ms::
3140 * Headings in ms::
3141 * Highlighting in ms::
3142 * Lists in ms::
3143 * Indents in ms::
3144 * Tabstops in ms::
3145 * ms Displays and Keeps::
3146 * ms Insertions::
3147 * Example multi-page table::
3148 * ms Footnotes::
3149 @end menu
3151 @c ---------------------------------------------------------------------
3153 @node Paragraphs in ms, Headings in ms, ms Body Text, ms Body Text
3154 @subsubsection Paragraphs
3155 @cindex @code{ms} macros, paragraph handling
3157 The following paragraph types are available.
3159 @Defmac {PP, , ms}
3160 Sets a paragraph with an initial indent.
3161 @endDefmac
3163 @Defmac {LP, , ms}
3164 Sets a paragraph with no initial indent.
3165 @endDefmac
3167 @Defmac {QP, , ms}
3168 Sets a paragraph that is indented at both left and right margins.
3169 The effect is identical to the @acronym{HTML} @code{<BLOCKQUOTE>} element.
3170 The next paragraph or heading returns margins to normal.
3171 @endDefmac
3173 @Defmac {XP, , ms}
3174 Sets a paragraph whose lines are indented,
3175 except for the first line.
3176 This is a Berkeley extension.
3177 @endDefmac
3179 The following markup uses all four paragraph macros.
3181 @Example
3182 @cartouche
3183 .NH 2
3184 Cases used in the study
3186 The following software and versions were
3187 considered for this report.
3189 For commercial software, we chose
3190 .B "Microsoft Word for Windows" ,
3191 starting with version 1.0 through the
3192 current version (Word 2000).
3194 For free software, we chose
3195 .B Emacs ,
3196 from its first appearance as a standalone
3197 editor through the current version (v20).
3198 See [Bloggs 2002] for details.
3200 Franklin's Law applied to software:
3201 software expands to outgrow both
3202 RAM and disk space over time.
3204 Bibliography:
3206 Bloggs, Joseph R.,
3207 .I "Everyone's a Critic" ,
3208 Underground Press, March 2002.
3209 A definitive work that answers all questions
3210 and criticisms about the quality and usability of
3211 free software.
3212 @end cartouche
3213 @endExample
3215 The @code{PORPHANS} register (@pxref{ms Document Control Registers})
3216 operates in conjunction with each of these macros, to inhibit the
3217 printing of orphan lines at the bottom of any page.
3219 @c ---------------------------------------------------------------------
3221 @node Headings in ms, Highlighting in ms, Paragraphs in ms, ms Body Text
3222 @subsubsection Headings
3223 @cindex @code{ms} macros, headings
3225 Use headings to create a hierarchical structure for your document.
3226 The @file{ms} macros print headings in @strong{bold},
3227 using the same font family and point size as the body text.
3229 The following describes the heading macros:
3231 @DefmacList {NH, @Var{curr-level}, ms}
3232 @DefmacListEnd {NH, @t{S} @Var{level0} @dots{}, ms}
3233 Numbered heading.
3234 The argument is either a numeric argument to indicate the
3235 level of the heading, or the letter@tie{}@code{S} followed by numeric
3236 arguments to set the heading level explicitly.
3238 If you specify heading levels out of sequence, such as invoking
3239 @samp{.NH 3} after @samp{.NH 1}, @code{groff}
3240 prints a warning on standard error.
3241 @endDefmac
3243 @DefstrList {SN, ms}
3244 @DefstrItem {SN-DOT, ms}
3245 @DefstrListEnd {SN-NO-DOT, ms}
3246 After invocation of @code{NH}, the assigned section number is made
3247 available in the strings @code{SN-DOT} (exactly as it appears in the
3248 printed section heading) and @code{SN-NO-DOT} (with the final period
3249 omitted).  The string @code{SN} is also defined, as an alias for
3250 @code{SN-DOT}; if preferred, you may redefine it as an alias for
3251 @code{SN-NO-DOT}, by including the initialization
3253 @Example
3254 .ds SN-NO-DOT
3255 .als SN SN-NO-DOT
3256 @endExample
3258 @noindent
3259 @strong{before} your first use of @code{NH}, or simply
3261 @Example
3262 .als SN SN-NO-DOT
3263 @endExample
3265 @noindent
3266 @strong{after} your first use of @code{NH}.
3267 @endDefstr
3269 @Defmac {SH, [@Var{match-level}], ms}
3270 Unnumbered subheading.
3272 The optional @code{match-level} argument is a GNU extension.  It is a
3273 number indicating the level of the heading, in a manner analogous to
3274 the @code{curr-level} argument to @code{.NH}.  Its purpose is to match
3275 the point size, at which the heading is printed, to the size of a
3276 numbered heading at the same level, when the @code{GROWPS}/@code{PSINCR}
3277 heading size adjustment mechanism is in effect.
3278 @xref{ms Document Control Registers}.
3279 @endDefmac
3281 The @code{HORPHANS} register (@pxref{ms Document Control Registers})
3282 operates in conjunction with the @code{NH} and @code{SH} macros, to
3283 inhibit the printing of orphaned section headings at the bottom of any
3284 page.
3286 @c ---------------------------------------------------------------------
3288 @node Highlighting in ms, Lists in ms, Headings in ms, ms Body Text
3289 @subsubsection Highlighting
3290 @cindex @code{ms} macros, highlighting
3292 The @file{ms} macros provide a variety of methods to highlight
3293 or emphasize text:
3295 @Defmac {B, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3296 Sets its first argument in @strong{bold type}.
3297 If you specify a second argument, @code{groff} prints it in the
3298 previous font after the bold text, with no intervening space
3299 (this allows you to set punctuation after the highlighted text
3300 without highlighting the punctuation).
3301 Similarly, it prints the third argument (if any) in the previous
3302 font @strong{before} the first argument.
3303 For example,
3305 @Example
3306 .B foo ) (
3307 @endExample
3309 prints (@strong{foo}).
3311 If you give this macro no arguments, @code{groff}
3312 prints all text following in bold until
3313 the next highlighting, paragraph, or heading macro.
3314 @endDefmac
3316 @Defmac {R, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3317 Sets its first argument in roman (or regular) type.
3318 It operates similarly to the @code{B}@tie{}macro otherwise.
3319 @endDefmac
3321 @Defmac {I, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3322 Sets its first argument in @emph{italic type}.
3323 It operates similarly to the @code{B}@tie{}macro otherwise.
3324 @endDefmac
3326 @Defmac {CW, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3327 Sets its first argument in a @code{constant width face}.
3328 It operates similarly to the @code{B}@tie{}macro otherwise.
3329 @endDefmac
3331 @Defmac {BI, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3332 Sets its first argument in bold italic type.
3333 It operates similarly to the @code{B}@tie{}macro otherwise.
3334 @endDefmac
3336 @Defmac {BX, [@Var{txt}], ms}
3337 Prints its argument and draws a box around it.
3338 If you want to box a string that contains spaces,
3339 use a digit-width space (@code{\0}).
3340 @endDefmac
3342 @Defmac {UL, [@Var{txt} [@Var{post}]], ms}
3343 Prints its first argument with an underline.
3344 If you specify a second argument, @code{groff}
3345 prints it in the previous font after
3346 the underlined text, with no intervening space.
3347 @endDefmac
3349 @Defmac {LG, , ms}
3350 Prints all text following in larger type
3351 (two points larger than the current point size) until
3352 the next font size, highlighting, paragraph, or heading macro.
3353 You can specify this macro multiple times
3354 to enlarge the point size as needed.
3355 @endDefmac
3357 @Defmac {SM, , ms}
3358 Prints all text following in smaller type
3359 (two points smaller than the current point size) until
3360 the next type size, highlighting, paragraph, or heading macro.
3361 You can specify this macro multiple times
3362 to reduce the point size as needed.
3363 @endDefmac
3365 @Defmac {NL, , ms}
3366 Prints all text following in the normal point size
3367 (that is, the value of the @code{PS} register).
3368 @endDefmac
3370 @c ---------------------------------------------------------------------
3372 @node Lists in ms, Indents in ms, Highlighting in ms, ms Body Text
3373 @subsubsection Lists
3374 @cindex @code{ms} macros, lists
3376 The @code{.IP} macro handles duties for all lists.
3378 @Defmac {IP, [@Var{marker} [@Var{width}]], ms}
3379 The @var{marker} is usually a bullet glyph (@code{\[bu]})
3380 for unordered lists, a number (or auto-incrementing number
3381 register) for numbered lists, or a word or phrase for indented
3382 (glossary-style) lists.
3384 The @var{width} specifies the indent for the body of each list item;
3385 its default unit is @samp{n}.
3386 Once specified, the indent remains the same for all
3387 list items in the document until specified again.
3389 The @code{PORPHANS} register (@pxref{ms Document Control Registers})
3390 operates in conjunction with the @code{IP} macro, to inhibit the
3391 printing of orphaned list markers at the bottom of any page.
3392 @endDefmac
3394 The following is an example of a bulleted list.
3395 @cindex example markup, bulleted list [@code{ms}]
3396 @cindex bulleted list, example markup [@code{ms}]
3398 @Example
3399 A bulleted list:
3400 .IP \[bu] 2
3401 lawyers
3402 .IP \[bu]
3403 guns
3404 .IP \[bu]
3405 money
3406 @endExample
3408 Produces:
3410 @Example
3411 A bulleted list:
3413 o lawyers
3415 o guns
3417 o money
3418 @endExample
3420 @sp 1
3422 The following is an example of a numbered list.
3423 @cindex example markup, numbered list [@code{ms}]
3424 @cindex numbered list, example markup [@code{ms}]
3426 @Example
3427 .nr step 1 1
3428 A numbered list:
3429 .IP \n[step] 3
3430 lawyers
3431 .IP \n+[step]
3432 guns
3433 .IP \n+[step]
3434 money
3435 @endExample
3437 Produces:
3439 @Example
3440 A numbered list:
3442 1. lawyers
3444 2. guns
3446 3. money
3447 @endExample
3449 Note the use of the auto-incrementing number
3450 register in this example.
3452 @sp 1
3453 The following is an example of a glossary-style list.
3454 @cindex example markup, glossary-style list [@code{ms}]
3455 @cindex glossary-style list, example markup [@code{ms}]
3457 @Example
3458 A glossary-style list:
3459 .IP lawyers 0.4i
3460 Two or more attorneys.
3461 .IP guns
3462 Firearms, preferably
3463 large-caliber.
3464 .IP money
3465 Gotta pay for those
3466 lawyers and guns!
3467 @endExample
3469 Produces:
3471 @Example
3472 A glossary-style list:
3474 lawyers
3475       Two or more attorneys.
3477 guns  Firearms, preferably large-caliber.
3479 money
3480       Gotta pay for those lawyers and guns!
3481 @endExample
3483 In the last example, the @code{IP} macro places the definition
3484 on the same line as the term if it has enough space; otherwise,
3485 it breaks to the next line and starts the definition below the
3486 term.
3487 This may or may not be the effect you want, especially if some
3488 of the definitions break and some do not.
3489 The following examples show two possible ways to force a break.
3491 The first workaround uses the @code{br}
3492 request to force a break after printing the term or label.
3494 @Example
3495 @cartouche
3496 A glossary-style list:
3497 .IP lawyers 0.4i
3498 Two or more attorneys.
3499 .IP guns
3501 Firearms, preferably large-caliber.
3502 .IP money
3503 Gotta pay for those lawyers and guns!
3504 @end cartouche
3505 @endExample
3507 @sp 1
3508 The second workaround uses the @code{\p} escape to force the break.
3509 Note the space following the escape; this is important.
3510 If you omit the space, @code{groff} prints the first word on
3511 the same line as the term or label (if it fits) @strong{then}
3512 breaks the line.
3514 @Example
3515 @cartouche
3516 A glossary-style list:
3517 .IP lawyers 0.4i
3518 Two or more attorneys.
3519 .IP guns
3520 \p Firearms, preferably large-caliber.
3521 .IP money
3522 Gotta pay for those lawyers and guns!
3523 @end cartouche
3524 @endExample
3526 @sp 1
3527 To set nested lists, use the @code{RS} and @code{RE} macros.
3528 @xref{Indents in ms}, for more information.
3529 @cindex @code{ms} macros, nested lists
3530 @cindex nested lists [@code{ms}]
3532 For example:
3534 @Example
3535 @cartouche
3536 .IP \[bu] 2
3537 Lawyers:
3539 .IP \[bu]
3540 Dewey,
3541 .IP \[bu]
3542 Cheatham,
3543 .IP \[bu]
3544 and Howe.
3546 .IP \[bu]
3547 Guns
3548 @end cartouche
3549 @endExample
3551 Produces:
3553 @Example
3554 o Lawyers:
3556   o  Dewey,
3558   o  Cheatham,
3560   o  and Howe.
3562 o Guns
3563 @endExample
3565 @c ---------------------------------------------------------------------
3567 @node Indents in ms, Tabstops in ms, Lists in ms, ms Body Text
3568 @subsubsection Indents
3570 In many situations,
3571 you may need to indent a section of text
3572 while still wrapping and filling.
3573 @xref{Lists in ms},
3574 for an example of nested lists.
3576 @DefmacList {RS, , ms}
3577 @DefmacListEnd {RE, , ms}
3578 These macros begin and end an indented section.
3579 The @code{PI} register controls the amount of indent,
3580 allowing the indented text to line up under hanging
3581 and indented paragraphs.
3582 @endDefmac
3584 @xref{ms Displays and Keeps},
3585 for macros to indent and turn off filling.
3587 @c ---------------------------------------------------------------------
3589 @node Tabstops in ms, ms Displays and Keeps, Indents in ms, ms Body Text
3590 @subsubsection Tab Stops
3592 Use the @code{ta} request to define tab stops as needed.
3593 @xref{Tabs and Fields}.
3595 @Defmac{TA, , ms}
3596 Use this macro to reset the tab stops to the default for @file{ms}
3597 (every 5n).
3598 You can redefine the @code{TA} macro to create a different set
3599 of default tab stops.
3600 @endDefmac
3602 @c ---------------------------------------------------------------------
3604 @node ms Displays and Keeps, ms Insertions, Tabstops in ms, ms Body Text
3605 @subsubsection Displays and keeps
3606 @cindex @code{ms} macros, displays
3607 @cindex @code{ms} macros, keeps
3608 @cindex keeps [@code{ms}]
3609 @cindex displays [@code{ms}]
3611 Use displays to show text-based examples or figures
3612 (such as code listings).
3614 Displays turn off filling, so lines of code are displayed
3615 as-is without inserting @code{br} requests in between each line.
3616 Displays can be @dfn{kept} on a single page, or allowed
3617 to break across pages.
3619 @DefmacList {DS, @t{L}, ms}
3620 @DefmacItem {LD, , ms}
3621 @DefmacListEnd {DE, , ms}
3622 Left-justified display.
3623 The @samp{.DS L} call generates a page break, if necessary,
3624 to keep the entire display on one page.
3625 The @code{LD} macro allows the display to break across pages.
3626 The @code{DE} macro ends the display.
3627 @endDefmac
3629 @DefmacList {DS, @t{I}, ms}
3630 @DefmacItem {ID, , ms}
3631 @DefmacListEnd {DE, , ms}
3632 Indents the display as defined by the @code{DI} register.
3633 The @samp{.DS I} call generates a page break, if necessary,
3634 to keep the entire display on one page.
3635 The @code{ID} macro allows the display to break across pages.
3636 The @code{DE} macro ends the display.
3637 @endDefmac
3639 @DefmacList {DS, @t{B}, ms}
3640 @DefmacItem {BD, , ms}
3641 @DefmacListEnd {DE, , ms}
3642 Sets a block-centered display: the entire display is left-justified,
3643 but indented so that the longest line in the display is centered
3644 on the page.
3645 The @samp{.DS B} call generates a page break, if necessary,
3646 to keep the entire display on one page.
3647 The @code{BD} macro allows the display to break across pages.
3648 The @code{DE} macro ends the display.
3649 @endDefmac
3651 @DefmacList {DS, @t{C}, ms}
3652 @DefmacItem {CD, , ms}
3653 @DefmacListEnd {DE, , ms}
3654 Sets a centered display: each line in the display is centered.
3655 The @samp{.DS C} call generates a page break, if necessary,
3656 to keep the entire display on one page.
3657 The @code{CD} macro allows the display to break across pages.
3658 The @code{DE} macro ends the display.
3659 @endDefmac
3661 @DefmacList {DS, @t{R}, ms}
3662 @DefmacItem {RD, , ms}
3663 @DefmacListEnd {DE, , ms}
3664 Right-justifies each line in the display.
3665 The @samp{.DS R} call generates a page break, if necessary,
3666 to keep the entire display on one page.
3667 The @code{RD} macro allows the display to break across pages.
3668 The @code{DE} macro ends the display.
3669 @endDefmac
3671 @DefmacList {Ds, , ms}
3672 @DefmacListEnd {De, , ms}
3673 These two macros were formerly provided as aliases for
3674 @code{DS} and @code{DE}, respectively.
3675 They have been removed, and should no longer be used.
3676 X11 documents which actually use @code{Ds} and @code{De} always load a
3677 specific macro file from the X11 distribution (@file{macros.t}) which
3678 provides proper definitions for the two macros.
3679 @endDefmac
3681 @sp 1
3682 On occasion, you may want to @dfn{keep} other text together on a page.
3683 For example, you may want to keep two paragraphs together, or
3684 a paragraph that refers to a table (or list, or other item)
3685 immediately following.
3686 The @file{ms} macros provide the @code{KS} and @code{KE}
3687 macros for this purpose.
3689 @DefmacList {KS, , ms}
3690 @DefmacListEnd {KE, , ms}
3691 The @code{KS} macro begins a block of text to be kept on a
3692 single page, and the @code{KE} macro ends the block.
3693 @endDefmac
3695 @DefmacList {KF, , ms}
3696 @DefmacListEnd {KE, , ms}
3697 Specifies a @dfn{floating keep};
3698 if the keep cannot fit on the current page, @code{groff}
3699 holds the contents of the keep and allows text following
3700 the keep (in the source file) to fill in the remainder of
3701 the current page.
3702 When the page breaks, whether by an explicit @code{bp}
3703 request or by reaching the end of the page, @code{groff}
3704 prints the floating keep at the top of the new page.
3705 This is useful for printing large graphics or tables
3706 that do not need to appear exactly where specified.
3707 @endDefmac
3709 You can also use the @code{ne} request to force a page break if
3710 there is not enough vertical space remaining on the page.
3712 @sp 1
3713 Use the following macros to draw a box around a section of
3714 text (such as a display).
3716 @DefmacList {B1, , ms}
3717 @DefmacListEnd {B2, , ms}
3718 Marks the beginning and ending of text that is to have a
3719 box drawn around it.
3720 The @code{B1} macro begins the box; the @code{B2} macro ends it.
3721 Text in the box is automatically placed in a diversion (keep).
3722 @endDefmac
3724 @c ---------------------------------------------------------------------
3726 @node ms Insertions, Example multi-page table, ms Displays and Keeps, ms Body Text
3727 @subsubsection Tables, figures, equations, and references
3728 @cindex @code{ms} macros, tables
3729 @cindex @code{ms} macros, figures
3730 @cindex @code{ms} macros, equations
3731 @cindex @code{ms} macros, references
3732 @cindex tables [@code{ms}]
3733 @cindex figures [@code{ms}]
3734 @cindex equations [@code{ms}]
3735 @cindex references [@code{ms}]
3737 The @file{ms} macros support the standard
3738 @code{groff} preprocessors:
3739 @code{tbl}, @code{pic}, @code{eqn}, and @code{refer}.
3740 @pindex tbl
3741 @pindex pic
3742 @pindex eqn
3743 @pindex refer
3744 You mark text meant for preprocessors by enclosing it
3745 in pairs of tags as follows.
3747 @DefmacList {TS, [@code{H}], ms}
3748 @DefmacListEnd {TE, , ms}
3749 Denotes a table, to be processed by the @code{tbl} preprocessor.
3750 The optional argument@tie{}@code{H} to @code{TS} instructs @code{groff}
3751 to create a running header with the information
3752 up to the @code{TH} macro.
3753 @code{groff} prints the header at the beginning of the
3754 table; if the table runs onto another page, @code{groff}
3755 prints the header on the next page as well.
3756 @endDefmac
3758 @DefmacList {PS, , ms}
3759 @DefmacListEnd {PE, , ms}
3760 Denotes a graphic, to be processed by the @code{pic} preprocessor.
3761 You can create a @code{pic} file by hand, using the @acronym{AT&T}
3762 @code{pic} manual available on the Web as a reference, or by using
3763 a graphics program such as @code{xfig}.
3764 @endDefmac
3766 @DefmacList {EQ, [@Var{align}], ms}
3767 @DefmacListEnd {EN, , ms}
3768 Denotes an equation, to be processed by the @code{eqn} preprocessor.
3769 The optional @var{align} argument can be @code{C}, @code{L},
3770 or@tie{}@code{I} to center (the default), left-justify, or indent the
3771 equation.
3772 @endDefmac
3774 @DefmacList {[, , ms}
3775 @DefmacListEnd {], , ms}
3776 Denotes a reference, to be processed by the @code{refer} preprocessor.
3777 The @acronym{GNU} @cite{refer(1)} man page provides a comprehensive
3778 reference to the preprocessor and the format of the bibliographic
3779 database.
3780 @endDefmac
3782 @menu
3783 * Example multi-page table::
3784 @end menu
3786 @c ---------------------------------------------------------------------
3788 @node Example multi-page table, ms Footnotes, ms Insertions, ms Body Text
3789 @subsubsection An example multi-page table
3790 @cindex example markup, multi-page table [@code{ms}]
3791 @cindex multi-page table, example markup [@code{ms}]
3793 The following is an example of how to set up a
3794 table that may print across two or more pages.
3796 @Example
3797 @cartouche
3798 .TS H
3799 allbox expand;
3800 cb | cb .
3801 Text      ...of heading...
3805 l | l .
3806 ... the rest of the table follows...
3809 @end cartouche
3810 @endExample
3812 @c ---------------------------------------------------------------------
3814 @node ms Footnotes,  , Example multi-page table, ms Body Text
3815 @subsubsection Footnotes
3816 @cindex @code{ms} macros, footnotes
3817 @cindex footnotes [@code{ms}]
3819 The @file{ms} macro package has a flexible footnote system.
3820 You can specify either numbered footnotes or symbolic footnotes
3821 (that is, using a marker such as a dagger symbol).
3823 @Defstr {*, ms}
3824 Specifies the location of a numbered footnote marker in the text.
3825 @endDefesc
3827 @DefmacList {FS, , ms}
3828 @DefmacListEnd {FE, , ms}
3829 Specifies the text of the footnote.
3830 The default action is to create a numbered footnote;
3831 you can create a symbolic footnote by specifying
3832 a @dfn{mark} glyph
3833 (such as @code{\[dg]} for the dagger glyph)
3834 in the body text and as an argument to the @code{FS} macro,
3835 followed by the text of the footnote
3836 and the @code{FE} macro.
3837 @endDefmac
3839 You can control how @code{groff}
3840 prints footnote numbers by changing the value of the
3841 @code{FF} register.  @xref{ms Document Control Registers}.
3843 @c ---------------------------------------------------------------------
3845 @node ms Page Layout, Differences from AT&T ms, ms Body Text, ms
3846 @subsection Page layout
3847 @cindex @code{ms} macros, page layout
3848 @cindex page layout [@code{ms}]
3850 The default output from the @file{ms}
3851 macros provides a minimalist page layout:
3852 it prints a single column, with the page number centered at the top
3853 of each page.
3854 It prints no footers.
3856 You can change the layout by setting
3857 the proper number registers and strings.
3859 @menu
3860 * ms Headers and Footers::
3861 * ms Margins::
3862 * ms Multiple Columns::
3863 * ms TOC::
3864 * ms Strings and Special Characters::
3865 @end menu
3867 @c ---------------------------------------------------------------------
3869 @node ms Headers and Footers, ms Margins, ms Page Layout, ms Page Layout
3870 @subsubsection Headers and footers
3871 @cindex @code{ms} macros, headers
3872 @cindex @code{ms} macros, footers
3873 @cindex headers [@code{ms}]
3874 @cindex footers [@code{ms}]
3876 For documents that do not distinguish between odd and even pages,
3877 set the following strings:
3879 @DefstrList {LH, ms}
3880 @DefstrItem {CH, ms}
3881 @DefstrListEnd {RH, ms}
3882 Sets the left, center, and right headers.
3883 @endDefstr
3885 @DefstrList {LF, ms}
3886 @DefstrItem {CF, ms}
3887 @DefstrListEnd {RF, ms}
3888 Sets the left, center, and right footers.
3889 @endDefstr
3891 @sp 1
3892 For documents that need different information printed in the
3893 even and odd pages, use the following macros:
3895 @DefmacList {OH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3896 @DefmacItem {EH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3897 @DefmacItem {OF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3898 @DefmacListEnd {EF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3899 The @code{OH} and @code{EH} macros define headers for the odd and even pages;
3900 the @code{OF} and @code{EF} macros define footers for the odd and even pages.
3901 This is more flexible than defining the individual strings.
3903 You can replace the quote (@code{'}) marks with any character not
3904 appearing in the header or footer text.
3905 @endDefmac
3907 @c ---------------------------------------------------------------------
3909 @node ms Margins, ms Multiple Columns, ms Headers and Footers, ms Page Layout
3910 @subsubsection Margins
3911 @cindex @code{ms} macros, margins
3913 You control margins using a set of number registers.
3914 @xref{ms Document Control Registers}, for details.
3916 @c ---------------------------------------------------------------------
3918 @node ms Multiple Columns, ms TOC, ms Margins, ms Page Layout
3919 @subsubsection Multiple columns
3920 @cindex @code{ms} macros, multiple columns
3921 @cindex multiple columns [@code{ms}]
3923 The @file{ms} macros can set text in as many columns as will
3924 reasonably fit on the page.
3925 The following macros are available;
3926 all of them force a page break if a multi-column mode is already set.
3927 However, if the current mode is single-column, starting a multi-column
3928 mode does @strong{not} force a page break.
3930 @Defmac {1C, , ms}
3931 Single-column mode.
3932 @endDefmac
3934 @Defmac {2C, , ms}
3935 Two-column mode.
3936 @endDefmac
3938 @Defmac {MC, [@Var{width} [@Var{gutter}]], ms}
3939 Multi-column mode.
3940 If you specify no arguments, it is equivalent to the
3941 @code{2C} macro.
3942 Otherwise, @var{width} is the width of each column and
3943 @var{gutter} is the space between columns.
3944 The @code{MINGW} number register controls the default gutter width.
3945 @endDefmac
3947 @c ---------------------------------------------------------------------
3949 @node ms TOC, ms Strings and Special Characters, ms Multiple Columns, ms Page Layout
3950 @subsubsection Creating a table of contents
3951 @cindex @code{ms} macros, creating table of contents
3952 @cindex table of contents, creating [@code{ms}]
3954 The facilities in the @file{ms} macro package for creating
3955 a table of contents are semi-automated at best.
3956 Assuming that you want the table of contents to consist of
3957 the document's headings, you need to repeat those headings
3958 wrapped in @code{XS} and @code{XE} macros.
3960 @DefmacList {XS, [@Var{page}], ms}
3961 @DefmacItem {XA, [@Var{page}], ms}
3962 @DefmacListEnd {XE, , ms}
3963 These macros define a table of contents
3964 or an individual entry in the table of contents,
3965 depending on their use.
3966 The macros are very simple; they cannot indent a heading based on its level.
3967 The easiest way to work around this is to add tabs
3968 to the table of contents string.
3969 The following is an example:
3971 @Example
3972 @cartouche
3973 .NH 1
3974 Introduction
3976 Introduction
3981 .NH 2
3982 Methodology
3984 Methodology
3988 @end cartouche
3989 @endExample
3991 You can manually create a table of contents
3992 by beginning with the @code{XS} macro for the first entry,
3993 specifying the page number for that entry as the argument to @code{XS}.
3994 Add subsequent entries using the @code{XA} macro,
3995 specifying the page number for that entry as the argument to @code{XA}.
3996 The following is an example:
3998 @Example
3999 @cartouche
4000 .XS 1
4001 Introduction
4002 .XA 2
4003 A Brief History of the Universe
4004 .XA 729
4005 Details of Galactic Formation
4008 @end cartouche
4009 @endExample
4010 @endDefmac
4012 @Defmac {TC, [@code{no}], ms}
4013 Prints the table of contents on a new page,
4014 setting the page number to@tie{}@strong{i} (Roman numeral one).
4015 You should usually place this macro at the end of the
4016 file, since @code{groff} is a single-pass formatter and
4017 can only print what has been collected up to the point
4018 that the @code{TC} macro appears.
4020 The optional argument @code{no} suppresses printing
4021 the title specified by the string register @code{TOC}.
4022 @endDefmac
4024 @Defmac{PX, [@code{no}], ms}
4025 Prints the table of contents on a new page,
4026 using the current page numbering sequence.
4027 Use this macro to print a manually-generated table of contents
4028 at the beginning of your document.
4030 The optional argument @code{no} suppresses printing
4031 the title specified by the string register @code{TOC}.
4032 @endDefmac
4034 The @cite{Groff and Friends HOWTO}
4035 includes a @code{sed} script that automatically inserts
4036 @code{XS} and @code{XE} macro entries after each heading in a document.
4038 Altering the @code{NH} macro to automatically build the table
4039 of contents is perhaps initially more difficult, but would save
4040 a great deal of time in the long run if you use @file{ms} regularly.
4042 @c ---------------------------------------------------------------------
4044 @node ms Strings and Special Characters,  , ms TOC, ms Page Layout
4045 @subsubsection Strings and Special Characters
4046 @cindex @code{ms} macros, strings
4047 @cindex @code{ms} macros, special characters
4048 @cindex @code{ms} macros, accent marks
4049 @cindex accent marks [@code{ms}]
4050 @cindex special characters [@code{ms}]
4051 @cindex strings [@code{ms}]
4053 The @file{ms} macros provide the following predefined strings.
4054 You can change the string definitions to help in creating
4055 documents in languages other than English.
4057 @Defstr {REFERENCES, ms}
4058 Contains the string printed at the beginning of the
4059 references (bibliography) page.
4060 The default is @samp{References}.
4061 @endDefstr
4063 @Defstr {ABSTRACT, ms}
4064 Contains the string printed at the beginning of the abstract.
4065 The default is @samp{ABSTRACT}.
4066 @endDefstr
4068 @Defstr {TOC, ms}
4069 Contains the string printed at the beginning of the table of contents.
4070 @endDefstr
4072 @DefstrList {MONTH1, ms}
4073 @DefstrItem {MONTH2, ms}
4074 @DefstrItem {MONTH3, ms}
4075 @DefstrItem {MONTH4, ms}
4076 @DefstrItem {MONTH5, ms}
4077 @DefstrItem {MONTH6, ms}
4078 @DefstrItem {MONTH7, ms}
4079 @DefstrItem {MONTH8, ms}
4080 @DefstrItem {MONTH9, ms}
4081 @DefstrItem {MONTH10, ms}
4082 @DefstrItem {MONTH11, ms}
4083 @DefstrListEnd {MONTH12, ms}
4084 Prints the full name of the month in dates.
4085 The default is @samp{January}, @samp{February}, etc.
4086 @endDefstr
4088 The following special characters are available@footnote{For an
4089 explanation what special characters are see @ref{Special Characters}.}:
4091 @Defstr {-, ms}
4092 Prints an em dash.
4093 @endDefstr
4095 @DefstrList {*Q, ms}
4096 @DefstrListEnd {*U, ms}
4097 Prints typographer's quotes in troff,
4098 plain quotes in nroff.
4099 @code{*Q} is the left quote and @code{*U} is the right quote.
4100 @endDefstr
4102 Improved accent marks are available in the @file{ms} macros.
4104 @Defmac {AM, , ms}
4105 Specify this macro at the beginning of your document
4106 to enable extended accent marks and special characters.
4107 This is a Berkeley extension.
4109 To use the accent marks, place them @strong{after}
4110 the character being accented.
4111 @endDefmac
4113 The following accent marks are available
4114 after invoking the @code{AM} macro:
4116 @Defstr {\', ms}
4117 Acute accent.
4118 @endDefstr
4120 @Defstr {\`, ms}
4121 Grave accent.
4122 @endDefstr
4124 @Defstr {^, ms}
4125 Circumflex.
4126 @endDefstr
4128 @Defstr {\,, ms}
4129 Cedilla.
4130 @endDefstr
4132 @Defstr {~, ms}
4133 Tilde.
4134 @endDefstr
4136 @deffn String @t{\*[:]}
4137 @ifnotinfo
4138 @stindex : @r{[}ms@r{]}
4139 @end ifnotinfo
4140 @ifinfo
4141 @stindex \*[@r{<colon>}] @r{[}ms@r{]}
4142 @end ifinfo
4143 Umlaut.
4144 @end deffn
4146 @Defstr {v, ms}
4147 Hacek.
4148 @endDefstr
4150 @Defstr {_, ms}
4151 Macron (overbar).
4152 @endDefstr
4154 @Defstr {., ms}
4155 Underdot.
4156 @endDefstr
4158 @Defstr {o, ms}
4159 Ring above.
4160 @endDefstr
4162 The following are standalone characters
4163 available after invoking the @code{AM} macro:
4165 @Defstr {?, ms}
4166 Upside-down question mark.
4167 @endDefstr
4169 @Defstr {!, ms}
4170 Upside-down exclamation point.
4171 @endDefstr
4173 @Defstr {8, ms}
4174 German ÃŸ ligature.
4175 @endDefstr
4177 @Defstr {3, ms}
4178 Yogh.
4179 @endDefstr
4181 @Defstr {Th, ms}
4182 Uppercase thorn.
4183 @endDefstr
4185 @Defstr {th, ms}
4186 Lowercase thorn.
4187 @endDefstr
4189 @Defstr {D-, ms}
4190 Uppercase eth.
4191 @endDefstr
4193 @Defstr {d-, ms}
4194 Lowercase eth.
4195 @endDefstr
4197 @Defstr {q, ms}
4198 Hooked o.
4199 @endDefstr
4201 @Defstr {ae, ms}
4202 Lowercase Ã¦ ligature.
4203 @endDefstr
4205 @Defstr {Ae, ms}
4206 Uppercase Ã† ligature.
4207 @endDefstr
4209 @c ---------------------------------------------------------------------
4211 @node Differences from AT&T ms,  , ms Page Layout, ms
4212 @subsection Differences from @acronym{AT&T} @file{ms}
4213 @cindex @code{ms} macros, differences from @acronym{AT&T}
4214 @cindex @acronym{AT&T} @code{troff}, @code{ms} macro package differences
4216 This section lists the (minor) differences between the
4217 @code{groff -ms} macros and @acronym{AT&T}
4218 @code{troff -ms} macros.
4220 @menu
4221 * Missing ms Macros::
4222 * Additional ms Macros::
4223 @end menu
4225 @c ---------------------------------------------------------------------
4227 @node Missing ms Macros, Additional ms Macros, Differences from AT&T ms, Differences from AT&T ms
4228 @subsubsection @code{troff} macros not appearing in @code{groff}
4230 Macros missing from @code{groff -ms}
4231 are cover page macros specific to Bell Labs.
4232 The macros known to be missing are:
4234 @table @code
4235 @item .TM
4236 Technical memorandum; a cover sheet style
4238 @item .IM
4239 Internal memorandum; a cover sheet style
4241 @item .MR
4242 Memo for record; a cover sheet style
4244 @item .MF
4245 Memo for file; a cover sheet style
4247 @item .EG
4248 Engineer's notes; a cover sheet style
4250 @item .TR
4251 Computing Science Tech Report; a cover sheet style
4253 @item .OK
4254 Other keywords
4256 @item .CS
4257 Cover sheet information
4259 @item .MH
4260 A cover sheet macro
4261 @end table
4263 @c ---------------------------------------------------------------------
4265 @node Additional ms Macros,  , Missing ms Macros, Differences from AT&T ms
4266 @subsubsection @code{groff} macros not appearing in @acronym{AT&T} @code{troff}
4268 The @code{groff -ms} macros have a few minor extensions
4269 compared to the @acronym{AT&T} @code{troff -ms} macros.
4271 @Defmac {AM, , ms}
4272 Improved accent marks.
4273 @xref{ms Strings and Special Characters}, for details.
4274 @endDefmac
4276 @Defmac {DS, @t{I}, ms}
4277 Indented display.
4278 The default behavior of @acronym{AT&T} @code{troff -ms}
4279 was to indent; the @code{groff} default prints displays
4280 flush left with the body text.
4281 @endDefmac
4283 @Defmac {CW, , ms}
4284 Print text in @code{constant width} (Courier) font.
4285 @endDefmac
4287 @Defmac {IX, , ms}
4288 Indexing term (printed on standard error).
4289 You can write a script to capture and process an index
4290 generated in this manner.
4291 @endDefmac
4293 @sp 1
4294 The following additional number registers
4295 appear in @code{groff -ms}:
4297 @Defmpreg {MINGW, ms}
4298 Specifies a minimum space
4299 between columns (for multi-column output); this takes the
4300 place of the @code{GW} register that was documented but apparently
4301 not implemented in @acronym{AT&T} @code{troff}.
4302 @endDefmpreg
4304 @sp 1
4305 Several new string registers are available as well.
4306 You can change these to handle (for example) the local language.
4307 @xref{ms Strings and Special Characters}, for details.
4310 @c =====================================================================
4312 @node me, mm, ms, Macro Packages
4313 @section @file{me}
4314 @cindex @code{me} macro package
4316 @c XXX documentation
4317 @c XXX this is a placeholder until we get stuff knocked into shape
4318 See the @file{meintro.me} and @file{meref.me} documents in
4319 groff's @file{doc} directory.
4322 @c =====================================================================
4324 @node mm,  , me, Macro Packages
4325 @section @file{mm}
4326 @cindex @code{mm} macro package
4328 @c XXX documentation
4329 @c XXX this is a placeholder until we get stuff knocked into shape
4330 See the @cite{groff_mm(7)} man page (type @command{man groff_mm} at
4331 the command line).
4334 @c =====================================================================
4335 @c =====================================================================
4337 @node gtroff Reference, Preprocessors, Macro Packages, Top
4338 @chapter @code{gtroff} Reference
4339 @cindex reference, @code{gtroff}
4340 @cindex @code{gtroff}, reference
4342 This chapter covers @strong{all} of the facilities of @code{gtroff}.
4343 Users of macro packages may skip it if not interested in details.
4346 @menu
4347 * Text::
4348 * Measurements::
4349 * Expressions::
4350 * Identifiers::
4351 * Embedded Commands::
4352 * Registers::
4353 * Manipulating Filling and Adjusting::
4354 * Manipulating Hyphenation::
4355 * Manipulating Spacing::
4356 * Tabs and Fields::
4357 * Character Translations::
4358 * Troff and Nroff Mode::
4359 * Line Layout::
4360 * Line Control::
4361 * Page Layout::
4362 * Page Control::
4363 * Fonts and Symbols::
4364 * Sizes::
4365 * Strings::
4366 * Conditionals and Loops::
4367 * Writing Macros::
4368 * Page Motions::
4369 * Drawing Requests::
4370 * Traps::
4371 * Diversions::
4372 * Environments::
4373 * Suppressing output::
4374 * Colors::
4375 * I/O::
4376 * Postprocessor Access::
4377 * Miscellaneous::
4378 * Gtroff Internals::
4379 * Debugging::
4380 * Implementation Differences::
4381 @end menu
4384 @c =====================================================================
4386 @node Text, Measurements, gtroff Reference, gtroff Reference
4387 @section Text
4388 @cindex text, @code{gtroff} processing
4390 @code{gtroff} input files contain text with control commands
4391 interspersed throughout.  But, even without control codes, @code{gtroff}
4392 still does several things with the input text:
4394 @itemize @bullet
4395 @item
4396 filling and adjusting
4398 @item
4399 adding additional space after sentences
4401 @item
4402 hyphenating
4404 @item
4405 inserting implicit line breaks
4406 @end itemize
4408 @menu
4409 * Filling and Adjusting::
4410 * Hyphenation::
4411 * Sentences::
4412 * Tab Stops::
4413 * Implicit Line Breaks::
4414 * Input Conventions::
4415 * Input Encodings::
4416 @end menu
4418 @c ---------------------------------------------------------------------
4420 @node Filling and Adjusting, Hyphenation, Text, Text
4421 @subsection Filling and Adjusting
4422 @cindex filling
4423 @cindex adjusting
4425 When @code{gtroff} reads text, it collects words from the input and fits
4426 as many of them together on one output line as it can.  This is known as
4427 @dfn{filling}.
4429 @cindex leading spaces
4430 @cindex spaces, leading and trailing
4431 @cindex extra spaces
4432 @cindex trailing spaces
4433 Once @code{gtroff} has a @dfn{filled} line, it tries to @dfn{adjust}
4434 it.  This means it widens the spacing between words until the text
4435 reaches the right margin (in the default adjustment mode).  Extra spaces
4436 between words are preserved, but spaces at the end of lines are ignored.
4437 Spaces at the front of a line cause a @dfn{break} (breaks are
4438 explained in @ref{Implicit Line Breaks}).
4440 @xref{Manipulating Filling and Adjusting}.
4442 @c ---------------------------------------------------------------------
4444 @node Hyphenation, Sentences, Filling and Adjusting, Text
4445 @subsection Hyphenation
4446 @cindex hyphenation
4448 Since the odds are not great for finding a set of words, for every
4449 output line, which fit nicely on a line without inserting excessive
4450 amounts of space between words, @code{gtroff} hyphenates words so
4451 that it can justify lines without inserting too much space between
4452 words.  It uses an internal hyphenation algorithm (a simplified version
4453 of the algorithm used within @TeX{}) to indicate which words can be
4454 hyphenated and how to do so.  When a word is hyphenated, the first part
4455 of the word is added to the current filled line being output (with
4456 an attached hyphen), and the other portion is added to the next
4457 line to be filled.
4459 @xref{Manipulating Hyphenation}.
4461 @c ---------------------------------------------------------------------
4463 @node Sentences, Tab Stops, Hyphenation, Text
4464 @subsection Sentences
4465 @cindex sentences
4467 Although it is often debated, some typesetting rules say there should be
4468 different amounts of space after various punctuation marks.  For
4469 example, the @cite{Chicago typsetting manual} says that a period at the
4470 end of a sentence should have twice as much space following it as would
4471 a comma or a period as part of an abbreviation.
4473 @c XXX exact citation of Chicago manual
4475 @cindex sentence space
4476 @cindex space between sentences
4477 @cindex french-spacing
4478 @code{gtroff} does this by flagging certain characters (normally
4479 @samp{!}, @samp{?}, and @samp{.}) as @dfn{end-of-sentence} characters.
4480 When @code{gtroff} encounters one of these characters at the end of a
4481 line, it appends a normal space followed by a @dfn{sentence space} in
4482 the formatted output.  (This justifies one of the conventions mentioned
4483 in @ref{Input Conventions}.)
4485 @cindex transparent characters
4486 @cindex character, transparent
4487 @cindex @code{dg} glyph, at end of sentence
4488 @cindex @code{rq} glyph, at end of sentence
4489 @cindex @code{"}, at end of sentence
4490 @cindex @code{'}, at end of sentence
4491 @cindex @code{)}, at end of sentence
4492 @cindex @code{]}, at end of sentence
4493 @cindex @code{*}, at end of sentence
4494 In addition, the following characters and symbols are treated
4495 transparently while handling end-of-sentence characters: @samp{"},
4496 @samp{'}, @samp{)}, @samp{]}, @samp{*}, @code{\[dg]}, and @code{\[rq]}.
4498 See the @code{cflags} request in @ref{Using Symbols}, for more details.
4500 @cindex @code{\&}, at end of sentence
4501 To prevent the insertion of extra space after an end-of-sentence
4502 character (at the end of a line), append @code{\&}.
4504 @c ---------------------------------------------------------------------
4506 @node Tab Stops, Implicit Line Breaks, Sentences, Text
4507 @subsection Tab Stops
4508 @cindex tab stops
4509 @cindex stops, tabulator
4510 @cindex tab character
4511 @cindex character, tabulator
4513 @cindex @acronym{EBCDIC} encoding
4514 @cindex encoding, @acronym{EBCDIC}
4515 @code{gtroff} translates @dfn{tabulator characters}, also called
4516 @dfn{tabs} (normally code point @acronym{ASCII} @code{0x09} or
4517 @acronym{EBCDIC} @code{0x05}), in the input into movements to the next
4518 tabulator stop.  These tab stops are initially located every half inch
4519 across the page.  Using this, simple tables can be made easily.
4520 However, it can often be deceptive as the appearance (and width) of the
4521 text on a terminal and the results from @code{gtroff} can vary greatly.
4523 Also, a possible sticking point is that lines beginning with tab
4524 characters are still filled, again producing unexpected results.
4525 For example, the following input
4527 @multitable {12345678} {12345678} {12345678} {12345678}
4528 @item
4529 @tab 1 @tab 2 @tab 3
4530 @item
4531 @tab   @tab 4 @tab 5
4532 @end multitable
4534 @noindent
4535 produces
4537 @multitable {12345678} {12345678} {12345678} {12345678} {12345678} {12345678} {12345678}
4538 @item
4539 @tab 1 @tab 2 @tab 3 @tab   @tab 4 @tab 5
4540 @end multitable
4542 @xref{Tabs and Fields}.
4544 @c ---------------------------------------------------------------------
4546 @node Implicit Line Breaks, Input Conventions, Tab Stops, Text
4547 @subsection Implicit Line Breaks
4548 @cindex implicit line breaks
4549 @cindex implicit breaks of lines
4550 @cindex line, implicit breaks
4551 @cindex break, implicit
4552 @cindex line break
4554 An important concept in @code{gtroff} is the @dfn{break}.  When a break
4555 occurs, @code{gtroff} outputs the partially filled line
4556 (unjustified), and resumes collecting and filling text on the next output
4557 line.
4559 @cindex blank line
4560 @cindex empty line
4561 @cindex line, blank
4562 @cindex blank line macro (@code{blm})
4563 There are several ways to cause a break in @code{gtroff}.  A blank
4564 line not only causes a break, but it also outputs a one-line vertical
4565 space (effectively a blank line).  Note that this behaviour can be
4566 modified with the blank line macro request @code{blm}.
4567 @xref{Blank Line Traps}.
4569 @cindex fill mode
4570 @cindex mode, fill
4571 A line that begins with a space causes a break and the space is
4572 output at the beginning of the next line.  Note that this space isn't
4573 adjusted, even in fill mode.
4575 The end of file also causes a break -- otherwise the last line of
4576 the document may vanish!
4578 Certain requests also cause breaks, implicitly or explicitly.  This is
4579 discussed in @ref{Manipulating Filling and Adjusting}.
4581 @c ---------------------------------------------------------------------
4583 @node Input Conventions, Input Encodings, Implicit Line Breaks, Text
4584 @subsection Input Conventions
4585 @cindex input conventions
4586 @cindex conventions for input
4588 Since @code{gtroff} does filling automatically, it is traditional in
4589 @code{groff} not to try and type things in as nicely formatted
4590 paragraphs.  These are some conventions commonly used when typing
4591 @code{gtroff} text:
4593 @itemize @bullet
4594 @item
4595 Break lines after punctuation, particularly at the end of a sentence
4596 and in other logical places.  Keep separate phrases on lines by
4597 themselves, as entire phrases are often added or deleted when editing.
4599 @item
4600 Try to keep lines less than 40-60@tie{}characters, to allow space for
4601 inserting more text.
4603 @item
4604 Do not try to do any formatting in a @acronym{WYSIWYG} manner (i.e.,
4605 don't try using spaces to get proper indentation).
4606 @end itemize
4608 @c ---------------------------------------------------------------------
4610 @node Input Encodings,  , Input Conventions, Text
4611 @subsection Input Encodings
4613 Currently, the following input encodings are available.
4615 @table @asis
4616 @item cp1047
4617 @cindex encoding, input, @acronym{EBCDIC}
4618 @cindex @acronym{EBCDIC}, input encoding
4619 @cindex input encoding, @acronym{EBCDIC}
4620 @cindex encoding, input, cp1047
4621 @cindex cp1047, input encoding
4622 @cindex input encoding, cp1047
4623 @cindex IBM cp1047 input encoding
4624 @pindex cp1047.tmac
4625 This input encoding works only on @acronym{EBCDIC} platforms (and vice
4626 versa, the other input encodings don't work with @acronym{EBCDIC}); the
4627 file @file{cp1047.tmac} is by default loaded at start-up.
4629 @item latin-1
4630 @cindex encoding, input, @w{latin-1} (ISO @w{8859-1})
4631 @cindex @w{latin-1} (ISO @w{8859-1}), input encoding
4632 @cindex ISO @w{8859-1} (@w{latin-1}), input encoding
4633 @cindex input encoding, @w{latin-1} (ISO @w{8859-1})
4634 @pindex latin1.tmac
4635 This is the default input encoding on non-@acronym{EBCDIC} platforms;
4636 the file @file{latin1.tmac} is loaded at start-up.
4638 @item latin-2
4639 @cindex encoding, input, @w{latin-2} (ISO @w{8859-2})
4640 @cindex @w{latin-2} (ISO @w{8859-2}), input encoding
4641 @cindex ISO @w{8859-2} (@w{latin-2}), input encoding
4642 @cindex input encoding, @w{latin-2} (ISO @w{8859-2})
4643 @pindex latin2.tmac
4644 To use this encoding, either say @w{@samp{.mso latin2.tmac}} at the very
4645 beginning of your document or use @samp{-mlatin2} as a command line
4646 argument for @code{groff}.
4648 @item latin-9 (latin-0)
4649 @cindex encoding, input, @w{latin-9} (@w{latin-0}, ISO @w{8859-15})
4650 @cindex @w{latin-9} (@w{latin-0}, ISO @w{8859-15}), input encoding
4651 @cindex ISO @w{8859-15} (@w{latin-9}, @w{latin-0}), input encoding
4652 @cindex input encoding, @w{latin-9} (@w{latin-9}, ISO @w{8859-15})
4653 @pindex latin9.tmac
4654 This encoding is intended (at least in Europe) to replace @w{latin-1}
4655 encoding.  The main difference to @w{latin-1} is that @w{latin-9}
4656 contains the Euro character.  To use this encoding, either say
4657 @w{@samp{.mso latin9.tmac}} at the very beginning of your document or
4658 use @samp{-mlatin9} as a command line argument for @code{groff}.
4659 @end table
4661 Note that it can happen that some input encoding characters are not
4662 available for a particular output device.  For example, saying
4664 @Example
4665 groff -Tlatin1 -mlatin9 ...
4666 @endExample
4668 @noindent
4669 will fail if you use the Euro character in the input.  Usually, this
4670 limitation is present only for devices which have a limited set of
4671 output glyphs (e.g.@: @option{-Tascii} and @option{-Tlatin1}); for other
4672 devices it is usually sufficient to install proper fonts which contain
4673 the necessary glyphs.
4675 @pindex freeeuro.pfa
4676 @pindex ec.tmac
4677 Due to the importance of the Euro glyph in Europe, the groff package now
4678 comes with a @sc{PostScript} font called @file{freeeuro.pfa} which
4679 provides various glyph shapes for the Euro.  With other words,
4680 @w{latin-9} encoding is supported for the @option{-Tps} device out of
4681 the box (@w{latin-2} isn't).
4683 By its very nature, @option{-Tutf8} supports all input encodings;
4684 @option{-Tdvi} has support for both @w{latin-2} and @w{latin-9} if the
4685 command line @option{-mec} is used also to load the file @file{ec.tmac}
4686 (which flips to the EC fonts).
4689 @c =====================================================================
4691 @node Measurements, Expressions, Text, gtroff Reference
4692 @section Measurements
4693 @cindex measurements
4695 @cindex units of measurement
4696 @cindex basic unit (@code{u})
4697 @cindex machine unit (@code{u})
4698 @cindex measurement unit
4699 @cindex @code{u} unit
4700 @cindex unit, @code{u}
4701 @code{gtroff} (like many other programs) requires numeric parameters to
4702 specify various measurements.  Most numeric parameters@footnote{those
4703 that specify vertical or horizontal motion or a type size} may have a
4704 @dfn{measurement unit} attached.  These units are specified as a single
4705 character which immediately follows the number or expression.  Each of
4706 these units are understood, by @code{gtroff}, to be a multiple of its
4707 @dfn{basic unit}.  So, whenever a different measurement unit is
4708 specified @code{gtroff} converts this into its @dfn{basic units}.  This
4709 basic unit, represented by a @samp{u}, is a device dependent measurement
4710 which is quite small, ranging from 1/75@dmn{th} to 1/72000@dmn{th} of an
4711 inch.  The values may be given as fractional numbers; however,
4712 fractional basic units are always rounded to integers.
4714 Some of the measurement units are completely independent of any of the
4715 current settings (e.g.@: type size) of @code{gtroff}.
4717 @table @code
4718 @item i
4719 @cindex inch unit (@code{i})
4720 @cindex @code{i} unit
4721 @cindex unit, @code{i}
4722 Inches.  An antiquated measurement unit still in use in certain
4723 backwards countries with incredibly low-cost computer equipment.  One
4724 inch is equal to@tie{}2.54@dmn{cm}.
4726 @item c
4727 @cindex centimeter unit (@code{c})
4728 @cindex @code{c} unit
4729 @cindex unit, @code{c}
4730 Centimeters.  One centimeter is equal to@tie{}0.3937@dmn{in}.
4732 @item p
4733 @cindex point unit (@code{p})
4734 @cindex @code{p} unit
4735 @cindex unit, @code{p}
4736 Points.  This is a typesetter's measurement used for measure type size.
4737 It is 72@tie{}points to an inch.
4739 @item P
4740 @cindex pica unit (@code{P})
4741 @cindex @code{P} unit
4742 @cindex unit, @code{P}
4743 Pica.  Another typesetting measurement.  6@tie{}Picas to an inch (and
4744 12@tie{}points to a pica).
4746 @item s
4747 @itemx z
4748 @cindex @code{s} unit
4749 @cindex unit, @code{s}
4750 @cindex @code{z} unit
4751 @cindex unit, @code{z}
4752 @xref{Fractional Type Sizes}, for a discussion of these units.
4754 @item f
4755 @cindex @code{f} unit
4756 @cindex unit, @code{f}
4757 Fractions. Value is 65536.
4758 @xref{Colors}, for usage.
4759 @end table
4761 The other measurements understood by @code{gtroff} depend on
4762 settings currently in effect in @code{gtroff}.  These are very useful
4763 for specifying measurements which should look proper with any size of
4764 text.
4766 @table @code
4767 @item m
4768 @cindex em unit (@code{m})
4769 @cindex @code{m} unit
4770 @cindex unit, @code{m}
4771 Ems.  This unit is equal to the current font size in points.  So called
4772 because it is @emph{approximately} the width of the letter@tie{}@samp{m}
4773 in the current font.
4775 @item n
4776 @cindex en unit (@code{n})
4777 @cindex @code{n} unit
4778 @cindex unit, @code{n}
4779 Ens.  In @code{groff}, this is half of an em.
4781 @item v
4782 @cindex vertical space unit (@code{v})
4783 @cindex space, vertical, unit (@code{v})
4784 @cindex @code{v} unit
4785 @cindex unit, @code{v}
4786 Vertical space.  This is equivalent to the current line spacing.
4787 @xref{Sizes}, for more information about this.
4789 @item M
4790 @cindex @code{M} unit
4791 @cindex unit, @code{M}
4792 100ths of an em.
4793 @end table
4795 @menu
4796 * Default Units::
4797 @end menu
4799 @c ---------------------------------------------------------------------
4801 @node Default Units,  , Measurements, Measurements
4802 @subsection Default Units
4803 @cindex default units
4804 @cindex units, default
4806 Many requests take a default unit.  While this can be helpful at times,
4807 it can cause strange errors in some expressions.  For example, the line
4808 length request expects em units.  Here are several attempts to get a
4809 line length of 3.5@tie{}inches and their results:
4811 @Example
4812 3.5i      @result{}   3.5i
4813 7/2       @result{}   0i
4814 7/2i      @result{}   0i
4815 (7 / 2)u  @result{}   0i
4816 7i/2      @result{}   0.1i
4817 7i/2u     @result{}   3.5i
4818 @endExample
4820 @noindent
4821 Everything is converted to basic units first.  In the above example it
4822 is assumed that 1@dmn{i} equals@tie{}240@dmn{u}, and 1@dmn{m}
4823 equals@tie{}10@dmn{p} (thus 1@dmn{m} equals@tie{}33@dmn{u}).  The value
4824 7@dmn{i}/2 is first handled as 7@dmn{i}/2@dmn{m}, then converted to
4825 1680@dmn{u}/66@dmn{u} which is 25@dmn{u}, and this is approximately
4826 0.1@dmn{i}.  As can be seen, a scaling indicator after a closing
4827 parenthesis is simply ignored.
4829 @cindex measurements, specifying safely
4830 Thus, the safest way to specify measurements is to always
4831 attach a scaling indicator.  If you want to multiply or divide by a
4832 certain scalar value, use @samp{u} as the unit for that value.
4835 @c =====================================================================
4837 @node Expressions, Identifiers, Measurements, gtroff Reference
4838 @section Expressions
4839 @cindex expressions
4841 @code{gtroff} has most arithmetic operators common to other languages:
4843 @itemize @bullet
4844 @item
4845 @cindex arithmetic operators
4846 @cindex operators, arithmetic
4847 @opindex +
4848 @opindex -
4849 @opindex /
4850 @opindex *
4851 @opindex %
4852 Arithmetic: @samp{+} (addition), @samp{-} (subtraction), @samp{/}
4853 (division), @samp{*} (multiplication), @samp{%} (modulo).
4855 @code{gtroff} only provides integer arithmetic.  The internal type used
4856 for computing results is @samp{int}, which is usually a 32@dmn{bit}
4857 signed integer.
4859 @item
4860 @cindex comparison operators
4861 @cindex operators, comparison
4862 @opindex <
4863 @opindex >
4864 @opindex >=
4865 @opindex <=
4866 @opindex =
4867 @opindex ==
4868 Comparison: @samp{<} (less than), @samp{>} (greater than), @samp{<=}
4869 (less than or equal), @samp{>=} (greater than or equal), @samp{=}
4870 (equal), @samp{==} (the same as @samp{=}).
4872 @item
4873 @cindex logical operators
4874 @cindex operators, logical
4875 @opindex &
4876 @ifnotinfo
4877 @opindex :
4878 @end ifnotinfo
4879 @ifinfo
4880 @opindex @r{<colon>}
4881 @end ifinfo
4882 Logical: @samp{&} (logical and), @samp{:} (logical or).
4884 @item
4885 @cindex unary operators
4886 @cindex operators, unary
4887 @opindex -
4888 @opindex +
4889 @opindex !
4890 @cindex @code{if} request, and the @samp{!} operator
4891 @cindex @code{while} request, and the @samp{!} operator
4892 Unary operators: @samp{-} (negating, i.e.@: changing the sign), @samp{+}
4893 (just for completeness; does nothing in expressions), @samp{!} (logical
4894 not; this works only within @code{if} and @code{while} requests).  See
4895 below for the use of unary operators in motion requests.
4897 @item
4898 @cindex extremum operators (@code{>?}, @code{<?})
4899 @cindex operators, extremum (@code{>?}, @code{<?})
4900 @opindex >?
4901 @opindex <?
4902 Extrema: @samp{>?} (maximum), @samp{<?} (minimum).
4904 Example:
4906 @Example
4907 .nr x 5
4908 .nr y 3
4909 .nr z (\n[x] >? \n[y])
4910 @endExample
4912 @noindent
4913 The register@tie{}@code{z} now contains@tie{}5.
4915 @item
4916 @cindex scaling operator
4917 @cindex operator, scaling
4918 Scaling: @code{(@var{c};@var{e})}.  Evaluate@tie{}@var{e} using@tie{}@var{c}
4919 as the default scaling indicator.  If @var{c} is missing, ignore scaling
4920 indicators in the evaluation of@tie{}@var{e}.
4921 @end itemize
4923 @cindex parentheses
4924 @cindex order of evaluation in expressions
4925 @cindex expression, order of evaluation
4926 @opindex (
4927 @opindex )
4928 Parentheses may be used as in any other language.  However, in
4929 @code{gtroff} they are necessary to ensure order of evaluation.
4930 @code{gtroff} has no operator precedence; expressions are evaluated left
4931 to right.  This means that @code{gtroff} evaluates @samp{3+5*4} as if it were
4932 parenthesized like @samp{(3+5)*4}, not as @samp{3+(5*4)}, as might be
4933 expected.
4935 @cindex @code{+}, and page motion
4936 @cindex @code{-}, and page motion
4937 @cindex motion operators
4938 @cindex operators, motion
4939 For many requests which cause a motion on the page, the unary operators
4940 @samp{+} and @samp{-} work differently if leading an expression.  They
4941 then indicate a motion relative to the current position (down or up,
4942 respectively).
4944 @cindex @code{|}, and page motion
4945 @cindex absolute position operator (@code{|})
4946 @cindex position, absolute, operator (@code{|})
4947 Similarly, a leading @samp{|} operator indicates an absolute position.
4948 For vertical movements, it specifies the distance from the top of the
4949 page; for horizontal movements, it gives the distance from the beginning
4950 of the @emph{input} line.
4952 @cindex @code{bp} request, using @code{+} and@tie{}@code{-}
4953 @cindex @code{in} request, using @code{+} and@tie{}@code{-}
4954 @cindex @code{ll} request, using @code{+} and@tie{}@code{-}
4955 @cindex @code{lt} request, using @code{+} and@tie{}@code{-}
4956 @cindex @code{nm} request, using @code{+} and@tie{}@code{-}
4957 @cindex @code{nr} request, using @code{+} and@tie{}@code{-}
4958 @cindex @code{pl} request, using @code{+} and@tie{}@code{-}
4959 @cindex @code{pn} request, using @code{+} and@tie{}@code{-}
4960 @cindex @code{po} request, using @code{+} and@tie{}@code{-}
4961 @cindex @code{ps} request, using @code{+} and@tie{}@code{-}
4962 @cindex @code{pvs} request, using @code{+} and@tie{}@code{-}
4963 @cindex @code{rt} request, using @code{+} and@tie{}@code{-}
4964 @cindex @code{ti} request, using @code{+} and@tie{}@code{-}
4965 @cindex @code{\H}, using @code{+} and@tie{}@code{-}
4966 @cindex @code{\R}, using @code{+} and@tie{}@code{-}
4967 @cindex @code{\s}, using @code{+} and@tie{}@code{-}
4968 @samp{+} and @samp{-} are also treated differently by the following
4969 requests and escapes: @code{bp}, @code{in}, @code{ll}, @code{lt},
4970 @code{nm}, @code{nr}, @code{pl}, @code{pn}, @code{po}, @code{ps},
4971 @code{pvs}, @code{rt}, @code{ti}, @code{\H}, @code{\R}, and @code{\s}.
4972 Here, leading plus and minus signs indicate increments and decrements.
4974 @xref{Setting Registers}, for some examples.
4976 @Defesc {\\B, ', anything, '}
4977 @cindex numeric expression, valid
4978 @cindex valid numeric expression
4979 Return@tie{}1 if @var{anything} is a valid numeric expression;
4980 or@tie{}0 if @var{anything} is empty or not a valid numeric expression.
4981 @endDefesc
4983 @cindex space characters, in expressions
4984 @cindex expressions, and space characters
4985 Due to the way arguments are parsed, spaces are not allowed in
4986 expressions, unless the entire expression is surrounded by parentheses.
4988 @xref{Request and Macro Arguments}, and @ref{Conditionals and Loops}.
4991 @c =====================================================================
4993 @node Identifiers, Embedded Commands, Expressions, gtroff Reference
4994 @section Identifiers
4995 @cindex identifiers
4997 Like any other language, @code{gtroff} has rules for properly formed
4998 @dfn{identifiers}.  In @code{gtroff}, an identifier can be made up of
4999 almost any printable character, with the exception of the following
5000 characters:
5002 @itemize @bullet
5003 @item
5004 @cindex whitespace characters
5005 @cindex newline character
5006 @cindex character, whitespace
5007 Whitespace characters (spaces, tabs, and newlines).
5009 @item
5010 @cindex character, backspace
5011 @cindex backspace character
5012 @cindex @acronym{EBCDIC} encoding of backspace
5013 Backspace (@acronym{ASCII}@tie{}@code{0x08} or
5014 @acronym{EBCDIC}@tie{}@code{0x16}) and character code @code{0x01}.
5016 @item
5017 @cindex invalid input characters
5018 @cindex input characters, invalid
5019 @cindex characters, invalid input
5020 @cindex Unicode
5021 The following input characters are invalid and are ignored if
5022 @code{groff} runs on a machine based on @acronym{ASCII}, causing a
5023 warning message of type @samp{input} (see @ref{Debugging}, for more
5024 details): @code{0x00}, @code{0x0B}, @code{0x0D}-@code{0x1F},
5025 @code{0x80}-@code{0x9F}.
5027 And here are the invalid input characters if @code{groff} runs on an
5028 @acronym{EBCDIC} host: @code{0x00}, @code{0x08}, @code{0x09},
5029 @code{0x0B}, @code{0x0D}-@code{0x14}, @code{0x17}-@code{0x1F},
5030 @code{0x30}-@code{0x3F}.
5032 Currently, some of these reserved codepoints are used internally, thus
5033 making it non-trivial to extend @code{gtroff} to cover Unicode or other
5034 character sets and encodings which use characters of these ranges.
5036 Note that invalid characters are removed before parsing; an
5037 identifier @code{foo}, followed by an invalid character, followed by
5038 @code{bar} is treated as @code{foobar}.
5039 @end itemize
5041 For example, any of the following is valid.
5043 @Example
5047 end-list
5049 @endExample
5051 @cindex @code{]}, as part of an identifier
5052 @noindent
5053 Note that identifiers longer than two characters with a closing bracket
5054 (@samp{]}) in its name can't be accessed with escape sequences which
5055 expect an identifier as a parameter.  For example, @samp{\[foo]]}
5056 accesses the glyph @samp{foo}, followed by @samp{]}, whereas
5057 @samp{\C'foo]'} really asks for glyph @samp{foo]}.
5059 @cindex @code{refer}, and macro names starting with @code{[} or @code{]}
5060 @cindex @code{[}, macro names starting with, and @code{refer}
5061 @cindex @code{]}, macro names starting with, and @code{refer}
5062 @cindex macro names, starting with @code{[} or @code{]}, and @code{refer}
5063 To avoid problems with the @code{refer} preprocessor, macro names
5064 should not start with @samp{[} or @samp{]}.  Due to backwards
5065 compatibility, everything after @samp{.[} and @samp{.]} is handled as
5066 a special argument to @code{refer}.  For example, @samp{.[foo} makes
5067 @code{refer} to start a reference, using @samp{foo} as a parameter.
5069 @Defesc {\\A, ', ident, '}
5070 Test whether an identifier @var{ident} is valid in @code{gtroff}.  It
5071 expands to the character@tie{}1 or@tie{}0 according to whether its
5072 argument (usually delimited by quotes) is or is not acceptable as the
5073 name of a string, macro, diversion, number register, environment, or
5074 font.  It returns@tie{}0 if no argument is given.  This is useful for
5075 looking up user input in some sort of associative table.
5077 @Example
5078 \A'end-list'
5079     @result{} 1
5080 @endExample
5081 @endDefesc
5083 @xref{Escapes}, for details on parameter delimiting characters.
5085 Identifiers in @code{gtroff} can be any length, but, in some contexts,
5086 @code{gtroff} needs to be told where identifiers end and text begins
5087 (and in different ways depending on their length):
5089 @itemize @bullet
5090 @item
5091 Single character.
5093 @cindex @code{(}, starting a two-character identifier
5094 @item
5095 Two characters.  Must be prefixed with @samp{(} in some situations.
5097 @cindex @code{[}, starting an identifier
5098 @cindex @code{]}, ending an identifier
5099 @item
5100 Arbitrary length (@code{gtroff} only).  Must be bracketed with @samp{[}
5101 and@tie{}@samp{]} in some situations.  Any length identifier can be put
5102 in brackets.
5103 @end itemize
5105 @cindex undefined identifiers
5106 @cindex identifiers, undefined
5107 Unlike many other programming languages, undefined identifiers are
5108 silently ignored or expanded to nothing.
5109 When @code{gtroff} finds an undefined identifier, it emits a
5110 warning, doing the following:
5112 @itemize @bullet
5113 @item
5114 If the identifier is a string, macro, or diversion,
5115 @code{gtroff} defines it as empty.
5117 @item
5118 If the identifier is a number register, @code{gtroff}
5119 defines it with a value of@tie{}0.
5120 @end itemize
5122 @xref{Warnings}., @ref{Interpolating Registers}, and @ref{Strings}.
5124 Note that macros, strings, and diversions share the same name space.
5126 @Example
5127 .de xxx
5128 .  nop foo
5131 .di xxx
5136 .xxx
5137     @result{} bar
5138 @endExample
5140 @noindent
5141 As can be seen in the previous example, @code{gtroff} reuses the
5142 identifier @samp{xxx}, changing it from a macro to a diversion.
5143 No warning is emitted!  The contents of the first macro definition is
5144 lost.
5146 @xref{Interpolating Registers}, and @ref{Strings}.
5149 @c =====================================================================
5151 @node Embedded Commands, Registers, Identifiers, gtroff Reference
5152 @section Embedded Commands
5153 @cindex embedded commands
5154 @cindex commands, embedded
5156 Most documents need more functionality beyond filling, adjusting and
5157 implicit line breaking.  In order to gain further functionality,
5158 @code{gtroff} allows commands to be embedded into the text, in two ways.
5160 The first is a @dfn{request} which takes up an entire line, and does
5161 some large-scale operation (e.g.@: break lines, start new pages).
5163 The other is an @dfn{escape} which can be usually embedded anywhere
5164 in the text; most requests can accept it even as an argument.
5165 Escapes generally do more minor operations like sub- and superscripts,
5166 print a symbol, etc.
5168 @menu
5169 * Requests::
5170 * Macros::
5171 * Escapes::
5172 @end menu
5174 @c ---------------------------------------------------------------------
5176 @node Requests, Macros, Embedded Commands, Embedded Commands
5177 @subsection Requests
5178 @cindex requests
5180 @cindex control character (@code{.})
5181 @cindex character, control (@code{.})
5182 @cindex no-break control character (@code{'})
5183 @cindex character, no-break control (@code{'})
5184 @cindex control character, no-break (@code{'})
5185 A request line begins with a control character, which is either a single
5186 quote (@samp{'}, the @dfn{no-break control character}) or a period
5187 (@samp{.}, the normal @dfn{control character}).  These can be changed;
5188 see @ref{Character Translations}, for details.  After this there may be
5189 optional tabs or spaces followed by an identifier which is the name of
5190 the request.  This may be followed by any number of space-separated
5191 arguments (@emph{no} tabs here).
5193 @cindex structuring source code of documents or macro packages
5194 @cindex documents, structuring the source code
5195 @cindex macro packages, structuring the source code
5196 Since a control character followed by whitespace only is ignored, it
5197 is common practice to use this feature for structuring the source code
5198 of documents or macro packages.
5200 @Example
5201 .de foo
5202 .  tm This is foo.
5206 .de bar
5207 .  tm This is bar.
5209 @endExample
5211 @cindex blank line
5212 @cindex blank line macro (@code{blm})
5213 Another possibility is to use the blank line macro request @code{blm}
5214 by assigning an empty macro to it.
5216 @Example
5217 .de do-nothing
5219 .blm do-nothing  \" activate blank line macro
5221 .de foo
5222 .  tm This is foo.
5226 .de bar
5227 .  tm This is bar.
5230 .blm             \" deactivate blank line macro
5231 @endExample
5233 @xref{Blank Line Traps}.
5235 @cindex zero width space character (@code{\&})
5236 @cindex character, zero width space (@code{\&})
5237 @cindex space character, zero width (@code{\&})
5238 @cindex @code{\&}, escaping control characters
5239 To begin a line with a control character without it being interpreted,
5240 precede it with @code{\&}.  This represents a zero width space, which
5241 means it does not affect the output.
5243 In most cases the period is used as a control character.  Several
5244 requests cause a break implicitly; using the single quote control
5245 character prevents this.
5247 @menu
5248 * Request and Macro Arguments::
5249 @end menu
5251 @node Request and Macro Arguments,  , Requests, Requests
5252 @subsubsection Request and Macro Arguments
5253 @cindex request arguments
5254 @cindex macro arguments
5255 @cindex arguments to requests and macros
5257 Arguments to requests and macros are processed much like the shell:
5258 The line is split into arguments according to
5259 spaces.@footnote{Plan@tie{}9's @code{troff} implementation also allows
5260 tabs for argument separation -- @code{gtroff} intentionally doesn't
5261 support this.}
5263 @cindex spaces, in a macro argument
5264 An argument to a macro which is intended to contain spaces can either be
5265 enclosed in double quotes, or have the spaces @dfn{escaped} with
5266 backslashes.  This is @emph{not} true for requests.
5268 Here are a few examples for a hypothetical macro @code{uh}:
5270 @Example
5271 .uh The Mouse Problem
5272 .uh "The Mouse Problem"
5273 .uh The\ Mouse\ Problem
5274 @endExample
5276 @cindex @code{\~}, difference to @code{\@key{SP}}
5277 @cindex @code{\@key{SP}}, difference to @code{\~}
5278 @noindent
5279 The first line is the @code{uh} macro being called with 3 arguments,
5280 @samp{The}, @samp{Mouse}, and @samp{Problem}.  The latter two have the
5281 same effect of calling the @code{uh} macro with one argument, @samp{The
5282 Mouse Problem}.@footnote{The last solution, i.e., using escaped spaces,
5283 is ``classical'' in the sense that it can be found in most @code{troff}
5284 documents.  Nevertheless, it is not optimal in all situations, since
5285 @w{@samp{\ }} inserts a fixed-width, non-breaking space character which
5286 can't stretch.  @code{gtroff} provides a different command @code{\~} to
5287 insert a stretchable, non-breaking space.}
5289 @cindex @code{"}, in a macro argument
5290 @cindex double quote, in a macro argument
5291 A double quote which isn't preceded by a space doesn't start a macro
5292 argument.  If not closing a string, it is printed literally.
5294 For example,
5296 @Example
5297 .xxx a" "b c" "de"fg"
5298 @endExample
5300 @noindent
5301 has the arguments @samp{a"}, @w{@samp{b c}}, @samp{de}, and @samp{fg"}.
5302 Don't rely on this obscure behaviour!
5304 There are two possibilities to get a double quote reliably.
5306 @itemize @bullet
5307 @item
5308 Enclose the whole argument with double quotes and use two consecutive double
5309 quotes to represent a single one.  This traditional solution has the
5310 disadvantage that double quotes don't survive argument expansion again if
5311 called in compatibility mode (using the @option{-C} option of @code{groff}):
5313 @Example
5314 .de xx
5315 .  tm xx: `\\$1' `\\$2' `\\$3'
5317 .  yy "\\$1" "\\$2" "\\$3"
5319 .de yy
5320 .  tm yy: `\\$1' `\\$2' `\\$3'
5322 .xx A "test with ""quotes""" .
5323     @result{} xx: `A' `test with "quotes"' `.'
5324     @result{} yy: `A' `test with ' `quotes""'
5325 @endExample
5327 @noindent
5328 If not in compatibility mode, you get the expected result
5330 @Example
5331 xx: `A' `test with "quotes"' `.'
5332 yy: `A' `test with "quotes"' `.'
5333 @endExample
5335 @noindent
5336 since @code{gtroff} preserves the input level.
5338 @item
5339 Use the double quote glyph @code{\(dq}.  This works with and without
5340 compatibility mode enabled since @code{gtroff} doesn't convert @code{\(dq}
5341 back to a double quote input character.
5343 Not that this method won't work with @acronym{UNIX} @code{troff} in general
5344 since the glyph `dq' isn't defined normally.
5345 @end itemize
5347 @cindex @code{ds} request, and double quotes
5348 Double quotes in the @code{ds} request are handled differently.
5349 @xref{Strings}, for more details.
5351 @c ---------------------------------------------------------------------
5353 @node Macros, Escapes, Requests, Embedded Commands
5354 @subsection Macros
5355 @cindex macros
5357 @code{gtroff} has a @dfn{macro} facility for defining a series of lines
5358 which can be invoked by name.  They are called in the same manner as
5359 requests -- arguments also may be passed basically in the same manner.
5361 @xref{Writing Macros}, and @ref{Request and Macro Arguments}.
5363 @c ---------------------------------------------------------------------
5365 @node Escapes,  , Macros, Embedded Commands
5366 @subsection Escapes
5367 @cindex escapes
5369 Escapes may occur anywhere in the input to @code{gtroff}.  They usually
5370 begin with a backslash and are followed by a single character which
5371 indicates the function to be performed.  The escape character can be
5372 changed; see @ref{Character Translations}.
5374 Escape sequences which require an identifier as a parameter accept three
5375 possible syntax forms.
5377 @itemize @bullet
5378 @item
5379 The next single character is the identifier.
5381 @cindex @code{(}, starting a two-character identifier
5382 @item
5383 If this single character is an opening parenthesis, take the following
5384 two characters as the identifier.  Note that there is no closing
5385 parenthesis after the identifier.
5387 @cindex @code{[}, starting an identifier
5388 @cindex @code{]}, ending an identifier
5389 @item
5390 If this single character is an opening bracket, take all characters
5391 until a closing bracket as the identifier.
5392 @end itemize
5394 @noindent
5395 Examples:
5397 @Example
5399 \n(XX
5400 \*[TeX]
5401 @endExample
5403 @cindex @code{'}, delimiting arguments
5404 @cindex argument delimiting characters
5405 @cindex characters, argument delimiting
5406 @cindex delimiting characters for arguments
5407 Other escapes may require several arguments and/or some special format.
5408 In such cases the argument is traditionally enclosed in single quotes
5409 (and quotes are always used in this manual for the definitions of escape
5410 sequences).  The enclosed text is then processed according to what that
5411 escape expects.  Example:
5413 @Example
5414 \l'1.5i\(bu'
5415 @endExample
5417 @cindex @code{\o}, possible quote characters
5418 @cindex @code{\b}, possible quote characters
5419 @cindex @code{\X}, possible quote characters
5420 Note that the quote character can be replaced with any other character
5421 which does not occur in the argument (even a newline or a space
5422 character) in the following escapes: @code{\o}, @code{\b}, and
5423 @code{\X}.  This makes e.g.
5425 @Example
5426 A caf
5431 in Paris
5432   @result{} A café in Paris
5433 @endExample
5435 @noindent
5436 possible, but it is better not to use this feature to avoid confusion.
5438 @cindex @code{\%}, used as delimiter
5439 @cindex @code{\@key{SP}}, used as delimiter
5440 @cindex @code{\|}, used as delimiter
5441 @cindex @code{\^}, used as delimiter
5442 @cindex @code{\@{}, used as delimiter
5443 @cindex @code{\@}}, used as delimiter
5444 @cindex @code{\'}, used as delimiter
5445 @cindex @code{\`}, used as delimiter
5446 @cindex @code{\-}, used as delimiter
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 @ifnotinfo
5456 @cindex @code{\:}, used as delimiter
5457 @end ifnotinfo
5458 @ifinfo
5459 @cindex @code{\@r{<colon>}}, used as delimiter
5460 @end ifinfo
5461 @cindex @code{\~}, used as delimiter
5462 @cindex @code{\0}, used as delimiter
5463 @cindex @code{\a}, used as delimiter
5464 @cindex @code{\c}, used as delimiter
5465 @cindex @code{\d}, used as delimiter
5466 @cindex @code{\e}, used as delimiter
5467 @cindex @code{\E}, used as delimiter
5468 @cindex @code{\p}, used as delimiter
5469 @cindex @code{\r}, used as delimiter
5470 @cindex @code{\t}, used as delimiter
5471 @cindex @code{\u}, used as delimiter
5472 The following escapes sequences (which are handled similarly to
5473 characters since they don't take a parameter) are also allowed as
5474 delimiters: @code{\%}, @w{@samp{\ }}, @code{\|}, @code{\^}, @code{\@{},
5475 @code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
5476 @code{\?}, @code{\@@}, @code{\)}, @code{\/}, @code{\,}, @code{\&},
5477 @code{\:}, @code{\~}, @code{\0}, @code{\a}, @code{\c}, @code{\d},
5478 @code{\e}, @code{\E}, @code{\p}, @code{\r}, @code{\t}, and @code{\u}.
5479 Again, don't use these if possible.
5481 @cindex @code{\A}, allowed delimiters
5482 @cindex @code{\B}, allowed delimiters
5483 @cindex @code{\Z}, allowed delimiters
5484 @cindex @code{\C}, allowed delimiters
5485 @cindex @code{\w}, allowed delimiters
5486 No newline characters as delimiters are allowed in the following
5487 escapes: @code{\A}, @code{\B}, @code{\Z}, @code{\C}, and @code{\w}.
5489 @cindex @code{\D}, allowed delimiters
5490 @cindex @code{\h}, allowed delimiters
5491 @cindex @code{\H}, allowed delimiters
5492 @cindex @code{\l}, allowed delimiters
5493 @cindex @code{\L}, allowed delimiters
5494 @cindex @code{\N}, allowed delimiters
5495 @cindex @code{\R}, allowed delimiters
5496 @cindex @code{\s}, allowed delimiters
5497 @cindex @code{\S}, allowed delimiters
5498 @cindex @code{\v}, allowed delimiters
5499 @cindex @code{\x}, allowed delimiters
5500 Finally, the escapes @code{\D}, @code{\h}, @code{\H}, @code{\l},
5501 @code{\L}, @code{\N}, @code{\R}, @code{\s}, @code{\S}, @code{\v},
5502 and @code{\x} can't use the following characters as delimiters:
5504 @itemize @bullet
5505 @item
5506 @cindex numbers, and delimiters
5507 @cindex digits, and delimiters
5508 The digits @code{0}-@code{9}.
5510 @item
5511 @cindex operators, as delimiters
5512 @cindex @code{+}, as delimiter
5513 @cindex @code{-}, as delimiter
5514 @cindex @code{/}, as delimiter
5515 @cindex @code{*}, as delimiter
5516 @cindex @code{%}, as delimiter
5517 @cindex @code{<}, as delimiter
5518 @cindex @code{>}, as delimiter
5519 @cindex @code{=}, as delimiter
5520 @cindex @code{&}, as delimiter
5521 @ifnotinfo
5522 @cindex @code{:}, as delimiter
5523 @end ifnotinfo
5524 @ifinfo
5525 @cindex <colon>, as delimiter
5526 @end ifinfo
5527 @cindex @code{(}, as delimiter
5528 @cindex @code{)}, as delimiter
5529 @cindex @code{.}, as delimiter
5530 The (single-character) operators @samp{+-/*%<>=&:().}.
5532 @item
5533 @cindex space character
5534 @cindex character, space
5535 @cindex tab character
5536 @cindex character, tab
5537 @cindex newline character
5538 @cindex character, newline
5539 The space, tab, and newline characters.
5541 @item
5542 @cindex @code{\%}, used as delimiter
5543 @ifnotinfo
5544 @cindex @code{\:}, used as delimiter
5545 @end ifnotinfo
5546 @ifinfo
5547 @cindex @code{\@r{<colon>}}, used as delimiter
5548 @end ifinfo
5549 @cindex @code{\@{}, used as delimiter
5550 @cindex @code{\@}}, used as delimiter
5551 @cindex @code{\'}, used as delimiter
5552 @cindex @code{\`}, used as delimiter
5553 @cindex @code{\-}, used as delimiter
5554 @cindex @code{\_}, used as delimiter
5555 @cindex @code{\!}, used as delimiter
5556 @cindex @code{\@@}, used as delimiter
5557 @cindex @code{\/}, used as delimiter
5558 @cindex @code{\c}, used as delimiter
5559 @cindex @code{\e}, used as delimiter
5560 @cindex @code{\p}, used as delimiter
5561 All escape sequences except @code{\%}, @code{\:}, @code{\@{}, @code{\@}},
5562 @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!}, @code{\@@},
5563 @code{\/}, @code{\c}, @code{\e}, and @code{\p}.
5564 @end itemize
5566 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
5567 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
5568 To have a backslash (actually, the current escape character) appear in the
5569 output several escapes are defined: @code{\\}, @code{\e} or @code{\E}.
5570 These are very similar, and only differ with respect to being used in
5571 macros or diversions.  @xref{Character Translations}, for an exact
5572 description of those escapes.
5574 @xref{Implementation Differences}, @ref{Copy-in Mode}, and @ref{Diversions},
5575 @ref{Identifiers}, for more information.
5577 @menu
5578 * Comments::
5579 @end menu
5581 @node Comments,  , Escapes, Escapes
5582 @subsubsection Comments
5583 @cindex comments
5585 Probably one of the most@footnote{Unfortunately, this is a lie.  But
5586 hopefully future @code{gtroff} hackers will believe it @code{:-)}}
5587 common forms of escapes is the comment.
5589 @Defesc {\\", , , }
5590 Start a comment.  Everything to the end of the input line is ignored.
5592 This may sound simple, but it can be tricky to keep the comments from
5593 interfering with the appearance of the final output.
5595 @cindex @code{ds}, @code{ds1} requests, and comments
5596 @cindex @code{as}, @code{as1} requests, and comments
5597 If the escape is to the right of some text or a request, that portion
5598 of the line is ignored, but the space leading up to it is noticed by
5599 @code{gtroff}.  This only affects the @code{ds} and @code{as}
5600 request and its variants.
5602 @cindex tabs, before comments
5603 @cindex comments, lining up with tabs
5604 One possibly irritating idiosyncracy is that tabs must not be used to
5605 line up comments.  Tabs are not treated as whitespace between the
5606 request and macro arguments.
5608 @cindex undefined request
5609 @cindex request, undefined
5610 A comment on a line by itself is treated as a blank line, because
5611 after eliminating the comment, that is all that remains:
5613 @Example
5614 Test
5615 \" comment
5616 Test
5617 @endExample
5619 @noindent
5620 produces
5622 @Example
5623 Test
5625 Test
5626 @endExample
5628 To avoid this, it is common to start the line with @code{.\"} which
5629 causes the line to be treated as an undefined request and thus ignored
5630 completely.
5632 @cindex @code{'}, as a comment
5633 Another commenting scheme seen sometimes is three consecutive single
5634 quotes (@code{'''}) at the beginning of a line.  This works, but
5635 @code{gtroff} gives a warning about an undefined macro (namely
5636 @code{''}), which is harmless, but irritating.
5637 @endDefesc
5639 @Defesc {\\#, , , }
5640 To avoid all this, @code{gtroff} has a new comment mechanism using the
5641 @code{\#} escape.  This escape works the same as @code{\"} except that
5642 the newline is also ignored:
5644 @Example
5645 Test
5646 \# comment
5647 Test
5648 @endExample
5650 @noindent
5651 produces
5653 @Example
5654 Test Test
5655 @endExample
5657 @noindent
5658 as expected.
5659 @endDefesc
5661 @Defreq {ig, [@Var{end}]}
5662 Ignore all input until @code{gtroff} encounters the macro named
5663 @code{.}@var{end} on a line by itself (or @code{..} if @var{end} is not
5664 specified).  This is useful for commenting out large blocks of text:
5666 @Example
5667 text text text...
5669 This is part of a large block
5670 of text that has been
5671 temporarily(?) commented out.
5673 We can restore it simply by removing
5674 the .ig request and the ".." at the
5675 end of the block.
5677 More text text text...
5678 @endExample
5680 @noindent
5681 produces
5683 @Example
5684 text text text@dots{}  More text text text@dots{}
5685 @endExample
5687 @noindent
5688 Note that the commented-out block of text does not
5689 cause a break.
5691 The input is read in copy-mode; auto-incremented registers @emph{are}
5692 affected (@pxref{Auto-increment}).
5693 @endDefreq
5696 @c =====================================================================
5698 @node Registers, Manipulating Filling and Adjusting, Embedded Commands, gtroff Reference
5699 @section Registers
5700 @cindex registers
5702 Numeric variables in @code{gtroff} are called @dfn{registers}.  There
5703 are a number of built-in registers, supplying anything from the date to
5704 details of formatting parameters.
5706 @xref{Identifiers}, for details on register identifiers.
5708 @menu
5709 * Setting Registers::
5710 * Interpolating Registers::
5711 * Auto-increment::
5712 * Assigning Formats::
5713 * Built-in Registers::
5714 @end menu
5716 @c ---------------------------------------------------------------------
5718 @node Setting Registers, Interpolating Registers, Registers, Registers
5719 @subsection Setting Registers
5720 @cindex setting registers (@code{nr}, @code{\R})
5721 @cindex registers, setting (@code{nr}, @code{\R})
5723 Define or set registers using the @code{nr} request or the
5724 @code{\R} escape.
5726 @DefreqList {nr, ident value}
5727 @DefescListEnd {\\R, ', ident value, '}
5728 Set number register @var{ident} to @var{value}.  If @var{ident}
5729 doesn't exist, @code{gtroff} creates it.
5731 The argument to @code{\R} usually has to be enclosed in quotes.
5732 @xref{Escapes}, for details on parameter delimiting characters.
5734 The @code{\R} escape doesn't produce an input token in @code{gtroff};
5735 with other words, it vanishes completely after @code{gtroff} has
5736 processed it.
5737 @endDefreq
5739 For example, the following two lines are equivalent:
5741 @Example
5742 .nr a (((17 + (3 * 4))) % 4)
5743 \R'a (((17 + (3 * 4))) % 4)'
5744     @result{} 1
5745 @endExample
5747 Both @code{nr} and @code{\R} have two additional special forms to
5748 increment or decrement a register.
5750 @DefreqList {nr, ident @t{+}@Var{value}}
5751 @DefreqItem {nr, ident @t{-}@Var{value}}
5752 @DefescItem {\\R, ', ident @t{+}value, '}
5753 @DefescListEnd {\\R, ', ident @t{-}value, '}
5754 Increment (decrement) register @var{ident} by @var{value}.
5756 @Example
5757 .nr a 1
5758 .nr a +1
5760     @result{} 2
5761 @endExample
5763 @cindex negating register values
5764 To assign the negated value of a register to another register, some care
5765 must be taken to get the desired result:
5767 @Example
5768 .nr a 7
5769 .nr b 3
5770 .nr a -\nb
5772     @result{} 4
5773 .nr a (-\nb)
5775     @result{} -3
5776 @endExample
5778 @noindent
5779 The surrounding parentheses prevent the interpretation of the minus sign
5780 as a decrementing operator.  An alternative is to start the assignment
5781 with a @samp{0}:
5783 @Example
5784 .nr a 7
5785 .nr b -3
5786 .nr a \nb
5788     @result{} 4
5789 .nr a 0\nb
5791     @result{} -3
5792 @endExample
5793 @endDefreq
5795 @Defreq {rr, ident}
5796 @cindex removing number register (@code{rr})
5797 @cindex number register, removing (@code{rr})
5798 @cindex register, removing (@code{rr})
5799 Remove number register @var{ident}.  If @var{ident} doesn't exist, the
5800 request is ignored.
5801 @endDefreq
5803 @Defreq {rnn, ident1 ident2}
5804 @cindex renaming number register (@code{rnn})
5805 @cindex number register, renaming (@code{rnn})
5806 @cindex register, renaming (@code{rnn})
5807 Rename number register @var{ident1} to @var{ident2}.  If either
5808 @var{ident1} or @var{ident2} doesn't exist, the request is ignored.
5809 @endDefreq
5811 @Defreq {aln, ident1 ident2}
5812 @cindex alias, number register, creating (@code{aln})
5813 @cindex creating alias, for number register (@code{aln})
5814 @cindex number register, creating alias (@code{aln})
5815 @cindex register, creating alias (@code{aln})
5816 Create an alias @var{ident1} for a number register @var{ident2}.  The
5817 new name and the old name are exactly equivalent.  If @var{ident1} is
5818 undefined, a warning of type @samp{reg} is generated, and the request
5819 is ignored.  @xref{Debugging}, for information about warnings.
5820 @endDefreq
5822 @c ---------------------------------------------------------------------
5824 @node Interpolating Registers, Auto-increment, Setting Registers, Registers
5825 @subsection Interpolating Registers
5826 @cindex interpolating registers (@code{\n})
5827 @cindex registers, interpolating (@code{\n})
5829 Numeric registers can be accessed via the @code{\n} escape.
5831 @DefescList {\\n, , i, }
5832 @DefescItem {\\n, @lparen{}, id, }
5833 @DefescListEnd {\\n, @lbrack{}, ident, @rbrack}
5834 @cindex nested assignments
5835 @cindex assignments, nested
5836 @cindex indirect assignments
5837 @cindex assignments, indirect
5838 Interpolate number register with name @var{ident} (one-character
5839 name@tie{}@var{i}, two-character name @var{id}).  This means that the value
5840 of the register is expanded in-place while @code{gtroff} is parsing the
5841 input line.  Nested assignments (also called indirect assignments) are
5842 possible.
5844 @Example
5845 .nr a 5
5846 .nr as \na+\na
5847 \n(as
5848     @result{} 10
5849 @endExample
5851 @Example
5852 .nr a1 5
5853 .nr ab 6
5854 .ds str b
5855 .ds num 1
5856 \n[a\n[num]]
5857     @result{} 5
5858 \n[a\*[str]]
5859     @result{} 6
5860 @endExample
5861 @endDefesc
5863 @c ---------------------------------------------------------------------
5865 @node Auto-increment, Assigning Formats, Interpolating Registers, Registers
5866 @subsection Auto-increment
5867 @cindex auto-increment
5868 @cindex increment, automatic
5870 Number registers can also be auto-incremented and auto-decremented.
5871 The increment or decrement value can be specified with a third
5872 argument to the @code{nr} request or @code{\R} escape.
5874 @Defreq {nr, ident value incr}
5875 @cindex @code{\R}, difference to @code{nr}
5876 Set number register @var{ident} to @var{value}; the increment for
5877 auto-incrementing is set to @var{incr}.  Note that the @code{\R}
5878 escape doesn't support this notation.
5879 @endDefreq
5881 To activate auto-incrementing, the escape @code{\n} has a special
5882 syntax form.
5884 @DefescList {\\n, +, i, }
5885 @DefescItem {\\n, -, i, }
5886 @DefescItem {\\n, @lparen{}+, id, }
5887 @DefescItem {\\n, @lparen{}-, id, }
5888 @DefescItem {\\n, +@lparen{}, id, }
5889 @DefescItem {\\n, -@lparen{}, id, }
5890 @DefescItem {\\n, @lbrack{}+, ident, @rbrack{}}
5891 @DefescItem {\\n, @lbrack{}-, ident, @rbrack{}}
5892 @DefescItem {\\n, +@lbrack{}, ident, @rbrack{}}
5893 @DefescListEnd {\\n, -@lbrack{}, ident, @rbrack{}}
5894 Before interpolating, increment or decrement @var{ident}
5895 (one-character name@tie{}@var{i}, two-character name @var{id}) by the
5896 auto-increment value as specified with the @code{nr} request (or the
5897 @code{\R} escape).  If no auto-increment value has been specified,
5898 these syntax forms are identical to @code{\n}.
5899 @endDefesc
5901 For example,
5903 @Example
5904 .nr a 0 1
5905 .nr xx 0 5
5906 .nr foo 0 -2
5907 \n+a, \n+a, \n+a, \n+a, \n+a
5909 \n-(xx, \n-(xx, \n-(xx, \n-(xx, \n-(xx
5911 \n+[foo], \n+[foo], \n+[foo], \n+[foo], \n+[foo]
5912 @endExample
5914 @noindent
5915 produces
5917 @Example
5918 1, 2, 3, 4, 5
5919 -5, -10, -15, -20, -25
5920 -2, -4, -6, -8, -10
5921 @endExample
5923 @cindex increment value without changing the register
5924 @cindex value, incrementing without changing the register
5925 To change the increment value without changing the value of a register
5926 (@var{a} in the example), the following can be used:
5928 @Example
5929 .nr a \na 10
5930 @endExample
5932 @c ---------------------------------------------------------------------
5934 @node Assigning Formats, Built-in Registers, Auto-increment, Registers
5935 @subsection Assigning Formats
5936 @cindex assigning formats (@code{af})
5937 @cindex formats, assigning (@code{af})
5939 When a register is used in the text of an input file (as opposed to
5940 part of an expression), it is textually replaced (or interpolated)
5941 with a representation of that number.  This output format can be
5942 changed to a variety of formats (numbers, Roman numerals, etc.).  This
5943 is done using the @code{af} request.
5945 @Defreq {af, ident format}
5946 Change the output format of a number register.  The first argument
5947 @var{ident} is the name of the number register to be changed, and the
5948 second argument @var{format} is the output format.  The following
5949 output formats are available:
5951 @table @code
5952 @item 1
5953 Decimal arabic numbers.  This is the default format: 0, 1, 2,
5954 3,@tie{}@enddots{}
5956 @item 0@dots{}0
5957 Decimal numbers with as many digits as specified.  So, @samp{00} would
5958 result in printing numbers as 01, 02, 03,@tie{}@enddots{}
5960 In fact, any digit instead of zero will do; @code{gtroff} only counts
5961 how many digits are specified.  As a consequence, @code{af}'s default
5962 format @samp{1} could be specified as @samp{0} also (and exactly this is
5963 returned by the @code{\g} escape, see below).
5965 @item I
5966 @cindex Roman numerals
5967 @cindex numerals, Roman
5968 Upper-case Roman numerals: 0, I, II, III, IV,@tie{}@enddots{}
5970 @item i
5971 Lower-case Roman numerals: 0, i, ii, iii, iv,@tie{}@enddots{}
5973 @item A
5974 Upper-case letters: 0, A, B, C, @dots{},@tie{}Z, AA, AB,@tie{}@enddots{}
5976 @item a
5977 Lower-case letters: 0, a, b, c, @dots{},@tie{}z, aa, ab,@tie{}@enddots{}
5978 @end table
5980 Omitting the number register format causes a warning of type
5981 @samp{missing}.  @xref{Debugging}, for more details.  Specifying a
5982 nonexistent format causes an error.
5984 The following example produces @samp{10, X, j, 010}:
5986 @Example
5987 .nr a 10
5988 .af a 1           \" the default format
5989 \na,
5990 .af a I
5991 \na,
5992 .af a a
5993 \na,
5994 .af a 001
5996 @endExample
5998 @cindex Roman numerals, maximum and minimum
5999 @cindex maximum values of Roman numerals
6000 @cindex minimum values of Roman numerals
6001 The largest number representable for the @samp{i} and @samp{I} formats
6002 is 39999 (or @minus{}39999); @acronym{UNIX} @code{troff} uses @samp{z}
6003 and @samp{w} to represent 10000 and 5000 in Roman numerals, and so does
6004 @code{gtroff}.  Currently, the correct glyphs of Roman numeral five
6005 thousand and Roman numeral ten thousand (Unicode code points
6006 @code{U+2182} and @code{U+2181}, respectively) are not available.
6008 If @var{ident} doesn't exist, it is created.
6010 @cindex read-only register, changing format
6011 @cindex changing format, and read-only registers
6012 Changing the output format of a read-only register causes an error.  It
6013 is necessary to first copy the register's value to a writeable register,
6014 then apply the @code{af} request to this other register.
6015 @endDefreq
6017 @DefescList {\\g, , i, }
6018 @DefescItem {\\g, @lparen{}, id, }
6019 @DefescListEnd {\\g, @lbrack{}, ident, @rbrack{}}
6020 @cindex format of register (@code{\g})
6021 @cindex register, format (@code{\g})
6022 Return the current format of the specified register @var{ident}
6023 (one-character name@tie{}@var{i}, two-character name @var{id}).  For
6024 example, @samp{\ga} after the previous example would produce the
6025 string @samp{000}.  If the register hasn't been defined yet, nothing
6026 is returned.
6027 @endDefesc
6029 @c ---------------------------------------------------------------------
6031 @node Built-in Registers,  , Assigning Formats, Registers
6032 @subsection Built-in Registers
6033 @cindex built-in registers
6034 @cindex registers, built-in
6036 The following lists some built-in registers which are not described
6037 elsewhere in this manual.  Any register which begins with a @samp{.} is
6038 read-only.  A complete listing of all built-in registers can be found in
6039 @ref{Register Index}.
6041 @table @code
6042 @item \n[.F]
6043 @cindex current input file name register (@code{.F})
6044 @cindex input file name, current, register (@code{.F})
6045 @vindex \n[.F]
6046 This string-valued register returns the current input file name.
6048 @item \n[.H]
6049 @cindex horizontal resolution register (@code{.H})
6050 @cindex resolution, horizontal, register (@code{.H})
6051 @vindex .H
6052 Horizontal resolution in basic units.
6054 @item \n[.U]
6055 @cindex safer mode
6056 @cindex mode, safer
6057 @cindex unsafe mode
6058 @cindex mode, unsafe
6059 If @code{gtroff} is called with the @option{-U} command line option, the
6060 number register @code{.U} is set to@tie{}1, and zero otherwise.
6061 @xref{Groff Options}.
6063 @item \n[.V]
6064 @cindex vertical resolution register (@code{.V})
6065 @cindex resolution, vertical, register (@code{.V})
6066 @vindex .V
6067 Vertical resolution in basic units.
6069 @item \n[seconds]
6070 @cindex seconds, current time (@code{seconds})
6071 @cindex time, current, seconds (@code{seconds})
6072 @cindex current time, seconds (@code{seconds})
6073 @vindex seconds
6074 The number of seconds after the minute, normally in the range@tie{}0
6075 to@tie{}59, but can be up to@tie{}61 to allow for leap seconds.  Initialized
6076 at start-up of @code{gtroff}.
6078 @item \n[minutes]
6079 @cindex minutes, current time (@code{minutes})
6080 @cindex time, current, minutes (@code{minutes})
6081 @cindex current time, minutes (@code{minutes})
6082 @vindex minutes
6083 The number of minutes after the hour, in the range@tie{}0 to@tie{}59.
6084 Initialized at start-up of @code{gtroff}.
6086 @item \n[hours]
6087 @cindex hours, current time (@code{hours})
6088 @cindex time, current, hours (@code{hours})
6089 @cindex current time, hours (@code{hours})
6090 @vindex hours
6091 The number of hours past midnight, in the range@tie{}0 to@tie{}23.
6092 Initialized at start-up of @code{gtroff}.
6094 @item \n[dw]
6095 @cindex day of the week register (@code{dw})
6096 @cindex date, day of the week register (@code{dw})
6097 @vindex dw
6098 Day of the week (1-7).
6100 @item \n[dy]
6101 @cindex day of the month register (@code{dy})
6102 @cindex date, day of the month register (@code{dy})
6103 @vindex dy
6104 Day of the month (1-31).
6106 @item \n[mo]
6107 @cindex month of the year register (@code{mo})
6108 @cindex date, month of the year register (@code{mo})
6109 @vindex mo
6110 Current month (1-12).
6112 @item \n[year]
6113 @cindex date, year register (@code{year}, @code{yr})
6114 @cindex year, current, register (@code{year}, @code{yr})
6115 @vindex year
6116 The current year.
6118 @item \n[yr]
6119 @vindex \n[yr]
6120 The current year minus@tie{}1900.  Unfortunately, the documentation of
6121 @acronym{UNIX} Version@tie{}7's @code{troff} had a year@tie{}2000 bug: It
6122 incorrectly claimed that @code{yr} contains the last two digits of the
6123 year.  That claim has never been true of either @acronym{AT&T}
6124 @code{troff} or GNU @code{troff}.  Old @code{troff} input that looks
6125 like this:
6127 @Example
6128 '\" The following line stopped working after 1999
6129 This document was formatted in 19\n(yr.
6130 @endExample
6132 @noindent
6133 can be corrected as follows:
6135 @Example
6136 This document was formatted in \n[year].
6137 @endExample
6139 @noindent
6140 or, to be portable to older @code{troff} versions, as follows:
6142 @Example
6143 .nr y4 1900+\n(yr
6144 This document was formatted in \n(y4.
6145 @endExample
6147 @item \n[.c]
6148 @vindex .c
6149 @itemx \n[c.]
6150 @vindex c.
6151 @cindex input line number register (@code{.c}, @code{c.})
6152 @cindex line number, input, register (@code{.c}, @code{c.})
6153 The current @emph{input} line number.  Register @samp{.c} is read-only,
6154 whereas @samp{c.} (a @code{gtroff} extension) is writable also,
6155 affecting both @samp{.c} and @samp{c.}.
6157 @item \n[ln]
6158 @vindex ln
6159 @cindex output line number register (@code{ln})
6160 @cindex line number, output, register (@code{ln})
6161 The current @emph{output} line number after a call to the @code{nm}
6162 request to activate line numbering.
6164 @xref{Miscellaneous}, for more information about line numbering.
6166 @item \n[.x]
6167 @vindex .x
6168 @cindex major version number register (@code{.x})
6169 @cindex version number, major, register (@code{.x})
6170 The major version number.  For example, if the version number
6171 is 1.03 then @code{.x} contains@tie{}@samp{1}.
6173 @item \n[.y]
6174 @vindex .y
6175 @cindex minor version number register (@code{.y})
6176 @cindex version number, minor, register (@code{.y})
6177 The minor version number.  For example, if the version number
6178 is 1.03 then @code{.y} contains@tie{}@samp{03}.
6180 @item \n[.Y]
6181 @vindex .Y
6182 @cindex revision number register (@code{.Y})
6183 The revision number of @code{groff}.
6185 @item \n[$$]
6186 @vindex $$
6187 @cindex process ID of @code{gtroff} register (@code{$$})
6188 @cindex @code{gtroff}, process ID register (@code{$$})
6189 The process ID of @code{gtroff}.
6191 @item \n[.g]
6192 @vindex .g
6193 @cindex @code{gtroff}, identification register (@code{.g})
6194 @cindex GNU-specific register (@code{.g})
6195 Always@tie{}1.  Macros should use this to determine whether they are
6196 running under GNU @code{troff}.
6198 @item \n[.A]
6199 @vindex .A
6200 @cindex @acronym{ASCII} approximation output register (@code{.A})
6201 If the command line option @option{-a} is used to produce an
6202 @acronym{ASCII} approximation of the output, this is set to@tie{}1, zero
6203 otherwise.  @xref{Groff Options}.
6205 @item \n[.P]
6206 @vindex .P
6207 This register is set to@tie{}1 (and to@tie{}0 otherwise) if the current
6208 page is actually being printed, i.e., if the @option{-o} option is being
6209 used to only print selected pages.  @xref{Groff Options}, for more
6210 information.
6212 @item \n[.T]
6213 @vindex .T
6214 If @code{gtroff} is called with the @option{-T} command line option, the
6215 number register @code{.T} is set to@tie{}1, and zero otherwise.
6216 @xref{Groff Options}.
6218 @item \*[.T]
6219 @stindex .T
6220 @cindex output device name string register (@code{.T})
6221 A single read-write string register which contains the current output
6222 device (for example, @samp{latin1} or @samp{ps}).  This is the only
6223 string register defined by @code{gtroff}.
6224 @end table
6227 @c =====================================================================
6229 @node Manipulating Filling and Adjusting, Manipulating Hyphenation, Registers, gtroff Reference
6230 @section Manipulating Filling and Adjusting
6231 @cindex manipulating filling and adjusting
6232 @cindex filling and adjusting, manipulating
6233 @cindex adjusting and filling, manipulating
6234 @cindex justifying text
6235 @cindex text, justifying
6237 @cindex break
6238 @cindex line break
6239 @cindex @code{bp} request, causing implicit linebreak
6240 @cindex @code{ce} request, causing implicit linebreak
6241 @cindex @code{cf} request, causing implicit linebreak
6242 @cindex @code{fi} request, causing implicit linebreak
6243 @cindex @code{fl} request, causing implicit linebreak
6244 @cindex @code{in} request, causing implicit linebreak
6245 @cindex @code{nf} request, causing implicit linebreak
6246 @cindex @code{rj} request, causing implicit linebreak
6247 @cindex @code{sp} request, causing implicit linebreak
6248 @cindex @code{ti} request, causing implicit linebreak
6249 @cindex @code{trf} request, causing implicit linebreak
6250 Various ways of causing @dfn{breaks} were given in @ref{Implicit Line
6251 Breaks}.  The @code{br} request likewise causes a break.  Several
6252 other requests also cause breaks, but implicitly.  These are
6253 @code{bp}, @code{ce}, @code{cf}, @code{fi}, @code{fl}, @code{in},
6254 @code{nf}, @code{rj}, @code{sp}, @code{ti}, and @code{trf}.
6256 @Defreq {br, }
6257 Break the current line, i.e., the input collected so far is emitted
6258 without adjustment.
6260 If the no-break control character is used, @code{gtroff} suppresses
6261 the break:
6263 @Example
6267     @result{} a b
6268 @endExample
6269 @endDefreq
6271 Initially, @code{gtroff} fills and adjusts text to both margins.
6272 Filling can be disabled via the @code{nf} request and re-enabled with
6273 the @code{fi} request.
6275 @DefreqList {fi, }
6276 @DefregListEnd {.u}
6277 @cindex fill mode (@code{fi})
6278 @cindex mode, fill (@code{fi})
6279 Activate fill mode (which is the default).  This request implicitly
6280 enables adjusting; it also inserts a break in the text currently being
6281 filled.  The read-only number register @code{.u} is set to@tie{}1.
6283 The fill mode status is associated with the current environment
6284 (@pxref{Environments}).
6286 See @ref{Line Control}, for interaction with the @code{\c} escape.
6287 @endDefreq
6289 @Defreq {nf, }
6290 @cindex no-fill mode (@code{nf})
6291 @cindex mode, no-fill (@code{nf})
6292 Activate no-fill mode.  Input lines are output as-is, retaining line
6293 breaks and ignoring the current line length.  This command implicitly
6294 disables adjusting; it also causes a break.  The number register
6295 @code{.u} is set to@tie{}0.
6297 The fill mode status is associated with the current environment
6298 (@pxref{Environments}).
6300 See @ref{Line Control}, for interaction with the @code{\c} escape.
6301 @endDefreq
6303 @DefreqList {ad, [@Var{mode}]}
6304 @DefregListEnd {.j}
6305 Set adjusting mode.
6307 Activation and deactivation of adjusting is done implicitly with
6308 calls to the @code{fi} or @code{nf} requests.
6310 @var{mode} can have one of the following values:
6312 @table @code
6313 @item l
6314 @cindex ragged-right
6315 Adjust text to the left margin.  This produces what is traditionally
6316 called ragged-right text.
6318 @item r
6319 @cindex ragged-left
6320 Adjust text to the right margin, producing ragged-left text.
6322 @item c
6323 @cindex centered text
6324 @cindex @code{ce} request, difference to @samp{.ad@tie{}c}
6325 Center filled text.  This is different to the @code{ce} request which
6326 only centers text without filling.
6328 @item b
6329 @itemx n
6330 Justify to both margins.  This is the default used by @code{gtroff}.
6331 @end table
6333 Finally, @var{mode} can be the numeric argument returned by the @code{.j}
6334 register.
6336 With no argument, @code{gtroff} adjusts lines in the same way it did
6337 before adjusting was deactivated (with a call to @code{na}, for
6338 example).
6340 @Example
6341 text
6342 .ad r
6343 .nr ad \n[.j]
6344 text
6345 .ad c
6346 text
6348 text
6349 .ad         \" back to centering
6350 text
6351 .ad \n[ad]  \" back to right justifying
6352 @endExample
6354 @cindex adjustment mode register (@code{.j})
6355 The current adjustment mode is available in the read-only number
6356 register @code{.j}; it can be stored and subsequently used to set
6357 adjustment.
6359 The adjustment mode status is associated with the current environment
6360 (@pxref{Environments}).
6361 @endDefreq
6363 @Defreq {na, }
6364 Disable adjusting.  This request won't change the current adjustment
6365 mode: A subsequent call to @code{ad} uses the previous adjustment
6366 setting.
6368 The adjustment mode status is associated with the current environment
6369 (@pxref{Environments}).
6370 @endDefreq
6372 @DefreqList {brp, }
6373 @DefescListEnd {\\p, , , }
6374 Adjust the current line and cause a break.
6376 In most cases this produces very ugly results since @code{gtroff}
6377 doesn't have a sophisticated paragraph building algorithm (as @TeX{}
6378 have, for example); instead, @code{gtroff} fills and adjusts a paragraph
6379 line by line:
6381 @Example
6382   This is an uninteresting sentence.
6383   This is an uninteresting sentence.\p
6384   This is an uninteresting sentence.
6385 @endExample
6387 @noindent
6388 is formatted as
6390 @Example
6391   This is  an uninteresting  sentence.   This  is an
6392   uninteresting                            sentence.
6393   This is an uninteresting sentence.
6394 @endExample
6395 @endDefreq
6397 @DefreqList {ss, word_space_size [@Var{sentence_space_size}]}
6398 @DefregItem {.ss}
6399 @DefregListEnd {.sss}
6400 @cindex word space size register (@code{.ss})
6401 @cindex size of word space register (@code{.ss})
6402 @cindex space between words register (@code{.ss})
6403 @cindex sentence space size register (@code{.sss})
6404 @cindex size of sentence space register (@code{.sss})
6405 @cindex space between sentences register (@code{.sss})
6406 Change the size of a space between words.  It takes its units as one
6407 twelfth of the space width parameter for the current font.
6408 Initially both the @var{word_space_size} and @var{sentence_space_size}
6409 are@tie{}12.  In fill mode, the values specify the minimum distance.
6411 @cindex fill mode
6412 @cindex mode, fill
6413 If two arguments are given to the @code{ss} request, the second
6414 argument sets the sentence space size.  If the second argument is not
6415 given, sentence space size is set to @var{word_space_size}.  The
6416 sentence space size is used in two circumstances: If the end of a
6417 sentence occurs at the end of a line in fill mode, then both an
6418 inter-word space and a sentence space are added; if two spaces follow
6419 the end of a sentence in the middle of a line, then the second space
6420 is a sentence space.  If a second argument is never given to the
6421 @code{ss} request, the behaviour of @acronym{UNIX} @code{troff} is the
6422 same as that exhibited by GNU @code{troff}.  In GNU @code{troff}, as
6423 in @acronym{UNIX} @code{troff}, a sentence should always be followed
6424 by either a newline or two spaces.
6426 The read-only number registers @code{.ss} and @code{.sss} hold the
6427 values of the parameters set by the first and second arguments of the
6428 @code{ss} request.
6430 The word space and sentence space values are associated with the current
6431 environment (@pxref{Environments}).
6433 Contrary to @acronym{AT&T} @code{troff}, this request is @emph{not}
6434 ignored if a TTY output device is used; the given values are then
6435 rounded down to a multiple of@tie{}12 (@pxref{Implementation Differences}).
6437 The request is ignored if there is no parameter.
6439 @cindex discardable horizontal space
6440 @cindex space, discardable, horizontal
6441 @cindex horizontal discardable space
6442 Another useful application of the @code{ss} request is to insert
6443 discardable horizontal space, i.e., space which is discarded at a line
6444 break.  For example, paragraph-style footnotes could be separated this
6445 way:
6447 @Example
6448 .ll 4.5i
6449 1.\ This is the first footnote.\c
6450 .ss 48
6451 .nop
6452 .ss 12
6453 2.\ This is the second footnote.
6454 @endExample
6456 @noindent
6457 The result:
6459 @Example
6460 1. This is the first footnote.        2. This
6461 is the second footnote.
6462 @endExample
6464 @noindent
6465 Note that the @code{\h} escape produces unbreakable space.
6466 @endDefreq
6468 @DefreqList {ce, [@Var{nnn}]}
6469 @DefregListEnd {.ce}
6470 @cindex centering lines (@code{ce})
6471 @cindex lines, centering (@code{ce})
6472 Center text.  While the @w{@samp{.ad c}} request also centers text,
6473 it fills the text as well.  @code{ce} does not fill the
6474 text it affects.  This request causes a break.  The number of lines
6475 still to be centered is associated with the current environment
6476 (@pxref{Environments}).
6478 The following example demonstrates the differences.
6479 Here the input:
6481 @Example
6482 .ll 4i
6483 .ce 1000
6484 This is a small text fragment which shows the differences
6485 between the `.ce' and the `.ad c' request.
6486 .ce 0
6488 .ad c
6489 This is a small text fragment which shows the differences
6490 between the `.ce' and the `.ad c' request.
6491 @endExample
6493 @noindent
6494 And here the result:
6496 @Example
6497   This is a small text fragment which
6498          shows the differences
6499 between the `.ce' and the `.ad c' request.
6501   This is a small text fragment which
6502 shows the differences between the `.ce'
6503         and the `.ad c' request.
6504 @endExample
6506 With no arguments, @code{ce} centers the next line of text.  @var{nnn}
6507 specifies the number of lines to be centered.  If the argument is zero
6508 or negative, centering is disabled.
6510 The basic length for centering text is the line length (as set with the
6511 @code{ll} request) minus the indentation (as set with the @code{in}
6512 request).  Temporary indentation is ignored.
6514 As can be seen in the previous example, it is a common idiom to turn
6515 on centering for a large number of lines, and to turn off centering
6516 after text to be centered.  This is useful for any request which takes
6517 a number of lines as an argument.
6519 The @code{.ce} read-only number register contains the number of lines
6520 remaining to be centered, as set by the @code{ce} request.
6521 @endDefreq
6523 @DefreqList {rj, [@Var{nnn}]}
6524 @DefregListEnd {.rj}
6525 @cindex justifying text (@code{rj})
6526 @cindex text, justifying (@code{rj})
6527 @cindex right-justifying (@code{rj})
6528 Justify unfilled text to the right margin.  Arguments are identical to
6529 the @code{ce} request.  The @code{.rj} read-only number register is
6530 the number of lines to be right-justified as set by the @code{rj}
6531 request.  This request causes a break.  The number of lines still to be
6532 right-justified is associated with the current environment
6533 (@pxref{Environments}).
6534 @endDefreq
6537 @c =====================================================================
6539 @node Manipulating Hyphenation, Manipulating Spacing, Manipulating Filling and Adjusting, gtroff Reference
6540 @section Manipulating Hyphenation
6541 @cindex manipulating hyphenation
6542 @cindex hyphenation, manipulating
6545 Here a description of requests which influence hyphenation.
6547 @DefreqList {hy, [@Var{mode}]}
6548 @DefregListEnd {.hy}
6549 Enable hyphenation.  The request has an optional numeric argument,
6550 @var{mode}, to restrict hyphenation if necessary:
6552 @table @code
6553 @item 1
6554 The default argument if @var{mode} is omitted.  Hyphenate without
6555 restrictions.  This is also the start-up value of @code{gtroff}.
6557 @item 2
6558 Do not hyphenate the last word on a page or column.
6560 @item 4
6561 Do not hyphenate the last two characters of a word.
6563 @item 8
6564 Do not hyphenate the first two characters of a word.
6565 @end table
6567 Values in the previous table are additive.  For example, the
6568 value@tie{}12 causes @code{gtroff} to neither hyphenate the last
6569 two nor the first two characters of a word.
6571 @cindex hyphenation restrictions register (@code{.hy})
6572 The current hyphenation restrictions can be found in the read-only
6573 number register @samp{.hy}.
6575 The hyphenation mode is associated with the current environment
6576 (@pxref{Environments}).
6577 @endDefreq
6579 @Defreq {nh, }
6580 Disable hyphenation (i.e., set the hyphenation mode to zero).  Note
6581 that the hyphenation mode of the last call to @code{hy} is not
6582 remembered.
6584 The hyphenation mode is associated with the current environment
6585 (@pxref{Environments}).
6586 @endDefreq
6588 @DefreqList {hlm, [@Var{nnn}]}
6589 @DefregItem {.hlm}
6590 @DefregListEnd {.hlc}
6591 @cindex explicit hyphen (@code{\%})
6592 @cindex hyphen, explicit (@code{\%})
6593 @cindex consecutive hyphenated lines (@code{hlm})
6594 @cindex lines, consecutive hyphenated (@code{hlm})
6595 @cindex hyphenated lines, consecutive (@code{hlm})
6596 Set the maximum number of consecutive hyphenated lines to @var{nnn}.
6597 If this number is negative, there is no maximum.  The default value
6598 is@tie{}@minus{}1 if @var{nnn} is omitted.  This value is associated
6599 with the current environment (@pxref{Environments}).  Only lines
6600 output from a given environment count towards the maximum associated
6601 with that environment.  Hyphens resulting from @code{\%} are counted;
6602 explicit hyphens are not.
6604 The current setting of @code{hlm} is available in the @code{.hlm}
6605 read-only number register.  Also the number of immediately preceding
6606 consecutive hyphenated lines are available in the read-only number
6607 register @samp{.hlc}.
6608 @endDefreq
6610 @Defreq {hw, word1 word2 @dots{}}
6611 Define how @var{word1}, @var{word2}, etc.@: are to be hyphenated.  The
6612 words must be given with hyphens at the hyphenation points.  For
6613 example:
6615 @Example
6616 .hw in-sa-lub-rious
6617 @endExample
6619 @noindent
6620 Besides the space character, any character whose hyphenation code value
6621 is zero can be used to separate the arguments of @code{hw} (see the
6622 documentation for the @code{hcode} request below for more information).
6623 In addition, this request can be used more than once.
6625 Hyphenation exceptions specified with the @code{hw} request are
6626 associated with the current hyphenation language; it causes an error
6627 if there is no current hyphenation language.
6629 This request is ignored if there is no parameter.
6631 In old versions of @code{troff} there was a limited amount of space to
6632 store such information; fortunately, with @code{gtroff}, this is no
6633 longer a restriction.
6634 @endDefreq
6636 @DefescList {\\%, , , }
6637 @deffnx Escape @t{\:}
6638 @ifnotinfo
6639 @esindex \:
6640 @end ifnotinfo
6641 @ifinfo
6642 @esindex \@r{<colon>}
6643 @end ifinfo
6644 @cindex hyphenation character (@code{\%})
6645 @cindex character, hyphenation (@code{\%})
6646 @cindex disabling hyphenation (@code{\%})
6647 @cindex hyphenation, disabling (@code{\%})
6648 To tell @code{gtroff} how to hyphenate words on the fly, use the
6649 @code{\%} escape, also known as the @dfn{hyphenation character}.
6650 Preceding a word with this character prevents it from being
6651 hyphenated; putting it inside a word indicates to @code{gtroff} that
6652 the word may be hyphenated at that point.  Note that this mechanism
6653 only affects that one occurrence of the word; to change the
6654 hyphenation of a word for the entire document, use the @code{hw}
6655 request.
6657 The @code{\:} escape inserts a zero-width break point
6658 (that is, the word breaks but without adding a hyphen).
6660 @Example
6661 ... check the /var/log/\:httpd/\:access_log file ...
6662 @endExample
6664 @cindex @code{\X}, followed by @code{\%}
6665 @cindex @code{\Y}, followed by @code{\%}
6666 @cindex @code{\%}, following @code{\X} or @code{\Y}
6667 Note that @code{\X} and @code{\Y} start a word, that is, the @code{\%}
6668 escape in (say) @w{@samp{\X'...'\%foobar}} and
6669 @w{@samp{\Y'...'\%foobar}} no longer prevents hyphenation but inserts
6670 a hyphenation point at the beginning of @samp{foobar}; most likely
6671 this isn't what you want to do.
6672 @endDefesc
6674 @Defreq {hc, [@Var{char}]}
6675 Change the hyphenation character to @var{char}.  This character then
6676 works the same as the @code{\%} escape, and thus, no longer appears in
6677 the output.  Without an argument, @code{hc} resets the hyphenation
6678 character to be @code{\%} (the default) only.
6680 The hyphenation character is associated with the current environment
6681 (@pxref{Environments}).
6682 @endDefreq
6684 @DefreqList {hpf, pattern_file}
6685 @DefreqItem {hpfa, pattern_file}
6686 @DefreqListEnd {hpfcode, a b [c d @dots{}]}
6687 @cindex hyphenation patterns (@code{hpf})
6688 @cindex patterns for hyphenation (@code{hpf})
6689 Read in a file of hyphenation patterns.  This file is searched for in
6690 the same way as @file{@var{name}.tmac} (or @file{tmac.@var{name}}) is
6691 searched for if the @option{-m@var{name}} option is specified.
6693 It should have the same format as (simple) @TeX{} patterns files.
6694 More specifically, the following scanning rules are implemented.
6696 @itemize @bullet
6697 @item
6698 A percent sign starts a comment (up to the end of the line)
6699 even if preceded by a backslash.
6701 @item
6702 No support for `digraphs' like @code{\$}.
6704 @item
6705 @code{^^@var{xx}} (@var{x} is 0-9 or a-f) and @code{^^@var{x}} (character
6706 code of @var{x} in the range 0-127) are recognized; other use of @code{^}
6707 causes an error.
6709 @item
6710 No macro expansion.
6712 @item
6713 @code{hpf} checks for the expression @code{\patterns@{@dots{}@}}
6714 (possibly with whitespace before and after the braces).
6715 Everything between the braces is taken as hyphenation patterns.
6716 Consequently, @code{@{} and @code{@}} are not allowed in patterns.
6718 @item
6719 Similarly, @code{\hyphenation@{@dots{}@}} gives a list of hyphenation
6720 exceptions.
6722 @item
6723 @code{\endinput} is recognized also.
6725 @item
6726 For backwards compatibility, if @code{\patterns} is missing,
6727 the whole file is treated as a list of hyphenation patterns
6728 (only recognizing the @code{%} character as the start of a comment).
6729 @end itemize
6731 If no @code{hpf} request is specified (either in the document or in a
6732 macro package), @code{gtroff} won't hyphenate at all.
6734 The @code{hpfa} request appends a file of patterns to the current list.
6736 The @code{hpfcode} request defines mapping values for character codes in
6737 hyphenation patterns.  @code{hpf} or @code{hpfa} then apply the mapping
6738 (after reading the patterns) before replacing or appending them to
6739 the current list of patterns.  Its arguments are pairs of character codes
6740 -- integers from 0 to@tie{}255.  The request maps character code@tie{}@var{a}
6741 to code@tie{}@var{b}, code@tie{}@var{c} to code@tie{}@var{d}, and so on.  You
6742 can use character codes which would be invalid otherwise.
6744 @pindex troffrc
6745 @pindex troffrc-end
6746 @pindex hyphen.us
6747 @pindex hyphenex.us
6748 The set of hyphenation patterns is associated with the current language
6749 set by the @code{hla} request.  The @code{hpf} request is usually
6750 invoked by the @file{troffrc} or @file{troffrc-end} file; by default,
6751 @file{troffrc} loads hyphenation patterns and exceptions for American
6752 English (in files @file{hyphen.us} and @file{hyphenex.us}).
6754 A second call to @code{hpf} (for the same language) will replace the
6755 hyphenation patterns with the new ones.
6757 Invoking @code{hpf} causes an error if there is no current hyphenation
6758 language.
6759 @endDefreq
6761 @Defreq {hcode, c1 code1 c2 code2 @dots{}}
6762 @cindex hyphenation code (@code{hcode})
6763 @cindex code, hyphenation (@code{hcode})
6764 Set the hyphenation code of character @var{c1} to @var{code1}, that of
6765 @var{c2} to @var{code2}, etc.  A hyphenation code must be a single
6766 input character (not a special character) other than a digit or a
6767 space.
6769 To make hyphenation work, hyphenation codes must be set up.  At
6770 start-up, groff only assigns hyphenation codes to the letters
6771 @samp{a}-@samp{z} (mapped to themselves) and to the letters
6772 @samp{A}-@samp{Z} (mapped to @samp{a}-@samp{z}); all other hyphenation
6773 codes are set to zero.  Normally, hyphenation patterns contain only
6774 lowercase letters which should be applied regardless of case.  With
6775 other words, the words `FOO' and `Foo' should be hyphenated exactly the
6776 same way as the word `foo' is hyphenated, and this is what @code{hcode}
6777 is good for.  Words which contain other letters won't be hyphenated
6778 properly if the corresponding hyphenation patterns actually do contain
6779 them.  For example, the following @code{hcode} requests are necessary to
6780 assign hyphenation codes to the letters @samp{ÄäÖöÜüß} (this is needed
6781 for German):
6783 @Example
6784 .hcode Ã¤ Ã¤  Ã„ Ã¤
6785 .hcode Ã¶ Ã¶  Ã– Ã¶
6786 .hcode Ã¼ Ã¼  Ãœ Ã¼
6787 .hcode ÃŸ ÃŸ
6788 @endExample
6790 Without those assignments, groff treats German words like
6791 @w{`Kindergärten'} (the plural form of `kindergarten') as two
6792 substrings @w{`kinderg'} and @w{`rten'} because the hyphenation code
6793 of the umlaut@tie{}a is zero by default.  There is a German
6794 hyphenation pattern which covers @w{`kinder'}, so groff finds the
6795 hyphenation `kin-der'.  The other two hyphenation points
6796 (`kin-der-gär-ten') are missed.
6798 This request is ignored if it has no parameter.
6799 @endDefreq
6801 @DefreqList {hym, [@Var{length}]}
6802 @DefregListEnd {.hym}
6803 @cindex hyphenation margin (@code{hym})
6804 @cindex margin for hyphenation (@code{hym})
6805 @cindex @code{ad} request, and hyphenation margin
6806 Set the (right) hyphenation margin to @var{length}.  If the current
6807 adjustment mode is not @samp{b} or @samp{n}, the line is not
6808 hyphenated if it is shorter than @var{length}.  Without an argument,
6809 the hyphenation margin is reset to its default value, which is@tie{}0.
6810 The default scaling indicator for this request is @samp{m}.  The
6811 hyphenation margin is associated with the current environment
6812 (@pxref{Environments}).
6814 A negative argument resets the hyphenation margin to zero, emitting
6815 a warning of type @samp{range}.
6817 @cindex hyphenation margin register (@code{.hym})
6818 The current hyphenation margin is available in the @code{.hym} read-only
6819 number register.
6820 @endDefreq
6822 @DefreqList {hys, [@Var{hyphenation_space}]}
6823 @DefregListEnd {.hys}
6824 @cindex hyphenation space (@code{hys})
6825 @cindex @code{ad} request, and hyphenation space
6826 Set the hyphenation space to @var{hyphenation_space}.  If the current
6827 adjustment mode is @samp{b} or @samp{n}, don't hyphenate the line
6828 if it can be justified by adding no more than @var{hyphenation_space}
6829 extra space to each word space.  Without argument, the hyphenation
6830 space is set to its default value, which is@tie{}0.  The default
6831 scaling indicator for this request is @samp{m}.  The hyphenation
6832 space is associated with the current environment
6833 (@pxref{Environments}).
6835 A negative argument resets the hyphenation space to zero, emitting a
6836 warning of type @samp{range}.
6838 @cindex hyphenation space register (@code{.hys})
6839 The current hyphenation space is available in the @code{.hys} read-only
6840 number register.
6841 @endDefreq
6843 @Defreq {shc, [@Var{glyph}]}
6844 @cindex soft hyphen character, setting (@code{shc})
6845 @cindex character, soft hyphen, setting (@code{shc})
6846 @cindex glyph, soft hyphen (@code{hy})
6847 @cindex soft hyphen glyph (@code{hy})
6848 @cindex @code{char} request, and soft hyphen character
6849 @cindex @code{tr} request, and soft hyphen character
6850 Set the @dfn{soft hyphen character} to @var{glyph}.@footnote{@dfn{Soft
6851 hyphen character} is a misnomer since it is an output glyph.}  If the
6852 argument is omitted, the soft hyphen character is set to the default
6853 glyph @code{\(hy} (this is the start-up value of @code{gtroff} also).
6854 The soft hyphen character is the glyph that is inserted when a word is
6855 hyphenated at a line break.  If the soft hyphen character does not
6856 exist in the font of the character immediately preceding a potential
6857 break point, then the line is not broken at that point.  Neither
6858 definitions (specified with the @code{char} request) nor translations
6859 (specified with the @code{tr} request) are considered when finding the
6860 soft hyphen character.
6861 @endDefreq
6863 @DefreqList {hla, language}
6864 @DefregListEnd {.hla}
6865 @cindex @code{hpf} request, and hyphenation language
6866 @cindex @code{hw} request, and hyphenation language
6867 @pindex troffrc
6868 @pindex troffrc-end
6869 Set the current hyphenation language to the string @var{language}.
6870 Hyphenation exceptions specified with the @code{hw} request and
6871 hyphenation patterns specified with the @code{hpf} and @code{hpfa}
6872 requests are both associated with the current hyphenation language.
6873 The @code{hla} request is usually invoked by the @file{troffrc} or the
6874 @file{troffrc-end} files; @file{troffrc} sets the default language to
6875 @samp{us}.
6877 @cindex hyphenation language register (@code{.hla})
6878 The current hyphenation language is available as a string in the
6879 read-only number register @samp{.hla}.
6881 @Example
6882 .ds curr_language \n[.hla]
6883 \*[curr_language]
6884     @result{} us
6885 @endExample
6886 @endDefreq
6889 @c =====================================================================
6891 @node Manipulating Spacing, Tabs and Fields, Manipulating Hyphenation, gtroff Reference
6892 @section Manipulating Spacing
6893 @cindex manipulating spacing
6894 @cindex spacing, manipulating
6896 @Defreq {sp, [@Var{distance}]}
6897 Space downwards @var{distance}.  With no argument it advances
6898 1@tie{}line.  A negative argument causes @code{gtroff} to move up the page
6899 the specified distance.  If the argument is preceded by a @samp{|}
6900 then @code{gtroff} moves that distance from the top of the page.  This
6901 request causes a line break.  The default scaling indicator is @samp{v}.
6903 If a vertical trap is sprung during execution of @code{sp}, the amount of
6904 vertical space after the trap is discarded.  For example, this
6906 @Example
6907 .de xxx
6910 .wh 0 xxx
6912 .pl 5v
6914 .sp 2
6916 .sp 50
6918 @endExample
6920 @noindent
6921 results in
6923 @Example
6930 @endExample
6932 @cindex @code{sp} request, and traps
6933 @cindex discarded space in traps
6934 @cindex space, discarded, in traps
6935 @cindex traps, and discarded space
6936 The amount of discarded space is available in the number register
6937 @code{.trunc}.
6939 To protect @code{sp} against vertical traps, use the @code{vpt} request:
6941 @Example
6942 .vpt 0
6943 .sp -3
6944 .vpt 1
6945 @endExample
6946 @endDefreq
6948 @DefreqList {ls, [@Var{nnn}]}
6949 @DefregListEnd {.L}
6950 @cindex double-spacing (@code{ls})
6951 Output @w{@var{nnn}@minus{}1} blank lines after each line of text.
6952 With no argument, @code{gtroff} uses the previous value before the
6953 last @code{ls} call.
6955 @Example
6956 .ls 2    \" This causes double-spaced output
6957 .ls 3    \" This causes triple-spaced output
6958 .ls      \" Again double-spaced
6959 @endExample
6961 The line spacing is associated with the current environment
6962 (@pxref{Environments}).
6964 @cindex line spacing register (@code{.L})
6965 The read-only number register @code{.L} contains the current line
6966 spacing setting.
6967 @endDefreq
6969 @xref{Changing Type Sizes}, for the requests @code{vs} and @code{pvs}
6970 as alternatives to @code{ls}.
6972 @DefescList {\\x, ', spacing, '}
6973 @DefregListEnd {.a}
6974 Sometimes, extra vertical spacing is only needed occasionally, e.g.@:
6975 to allow space for a tall construct (like an equation).  The @code{\x}
6976 escape does this.  The escape is given a numerical argument, usually
6977 enclosed in quotes (like @samp{\x'3p'}); the default scaling indicator
6978 is @samp{v}.  If this number is positive extra vertical space is
6979 inserted below the current line.  A negative number adds space above.
6980 If this escape is used multiple times on the same line, the maximum of
6981 the values is used.
6983 @xref{Escapes}, for details on parameter delimiting characters.
6985 @cindex extra post-vertical line space register (@code{.a})
6986 The @code{.a} read-only number register contains the most recent
6987 (nonnegative) extra vertical line space.
6989 Using @code{\x} can be necessary in combination with the @code{\b}
6990 escape, as the following example shows.
6992 @Example
6993 This is a test with the \[rs]b escape.
6995 This is a test with the \[rs]b escape.
6997 This is a test with \b'xyz'\x'-1m'\x'1m'.
6999 This is a test with the \[rs]b escape.
7001 This is a test with the \[rs]b escape.
7002 @endExample
7004 @noindent
7005 produces
7007 @Example
7008 This is a test with the \b escape.
7009 This is a test with the \b escape.
7010                     x
7011 This is a test with y.
7012                     z
7013 This is a test with the \b escape.
7014 This is a test with the \b escape.
7015 @endExample
7016 @endDefesc
7018 @DefreqList {ns, }
7019 @DefreqItem {rs, }
7020 @DefregListEnd {.ns}
7021 @cindex @code{sp} request, and no-space mode
7022 @cindex no-space mode (@code{ns})
7023 @cindex mode, no-space (@code{ns})
7024 @cindex blank lines, disabling
7025 @cindex lines, blank, disabling
7026 Enable @dfn{no-space mode}.  In this mode, spacing (either via
7027 @code{sp} or via blank lines) is disabled.  The @code{bp} request to
7028 advance to the next page is also disabled, except if it is accompanied
7029 by a page number (see @ref{Page Control}, for more information).  This
7030 mode ends when actual text is output or the @code{rs} request is
7031 encountered which ends no-space mode.  The read-only number register
7032 @code{.ns} is set to@tie{}1 as long as no-space mode is active.
7034 This request is useful for macros that conditionally
7035 insert vertical space before the text starts
7036 (for example, a paragraph macro could insert some space
7037 except when it is the first paragraph after a section header).
7038 @endDefreq
7041 @c =====================================================================
7043 @node Tabs and Fields, Character Translations, Manipulating Spacing, gtroff Reference
7044 @section Tabs and Fields
7045 @cindex tabs, and fields
7046 @cindex fields, and tabs
7048 @cindex @acronym{EBCDIC} encoding of a tab
7049 A tab character (@acronym{ASCII} char@tie{}9, @acronym{EBCDIC}
7050 char@tie{}5) causes a horizontal movement to the next tab stop (much
7051 like it did on a typewriter).
7053 @Defesc {\\t, , , }
7054 @cindex tab character, non-interpreted (@code{\t})
7055 @cindex character, tab, non-interpreted (@code{\t})
7056 This escape is a non-interpreted tab character.  In copy mode
7057 (@pxref{Copy-in Mode}), @code{\t} is the same as a real tab character.
7058 @endDefesc
7060 @DefreqList {ta, [@Var{n1} @Var{n2} @dots{} @Var{nn} @t{T} @Var{r1} @Var{r2} @dots{} @Var{rn}]}
7061 @DefregListEnd {.tabs}
7062 Change tab stop positions.  This request takes a series of tab
7063 specifiers as arguments (optionally divided into two groups with the
7064 letter @samp{T}) which indicate where each tab stop is to be
7065 (overriding any previous settings).
7067 Tab stops can be specified absolutely, i.e., as the distance from the
7068 left margin.  For example, the following sets 6@tie{}tab stops every
7069 one inch.
7071 @Example
7072 .ta 1i 2i 3i 4i 5i 6i
7073 @endExample
7075 Tab stops can also be specified using a leading @samp{+}
7076 which means that the specified tab stop is set relative to
7077 the previous tab stop.  For example, the following is equivalent to the
7078 previous example.
7080 @Example
7081 .ta 1i +1i +1i +1i +1i +1i
7082 @endExample
7084 @code{gtroff} supports an extended syntax to specify repeat values after
7085 the @samp{T} mark (these values are always taken as relative) -- this is
7086 the usual way to specify tabs set at equal intervals.  The following is,
7087 yet again, the same as the previous examples.  It does even more since
7088 it defines an infinite number of tab stops separated by one inch.
7090 @Example
7091 .ta T 1i
7092 @endExample
7094 Now we are ready to interpret the full syntax given at the beginning:
7095 Set tabs at positions @var{n1}, @var{n2}, @dots{}, @var{nn} and then set
7096 tabs at @var{nn}+@var{r1}, @var{nn}+@var{r2}, @dots{}, @var{nn}+@var{rn}
7097 and then at @var{nn}+@var{rn}+@var{r1}, @var{nn}+@var{rn}+@var{r2},
7098 @dots{}, @var{nn}+@var{rn}+@var{rn}, and so on.
7100 Example: @samp{4c +6c T 3c 5c 2c} is equivalent to @samp{4c 10c 13c 18c
7101 20c 23c 28c 30c @dots{}}.
7103 The material in each tab column (i.e., the column between two tab stops)
7104 may be justified to the right or left or centered in the column.  This
7105 is specified by appending @samp{R}, @samp{L}, or @samp{C} to the tab
7106 specifier.  The default justification is @samp{L}.  Example:
7108 @Example
7109 .ta 1i 2iC 3iR
7110 @endExample
7112 Some notes:
7114 @itemize @bullet
7115 @item
7116 The default unit of the @code{ta} request is @samp{m}.
7118 @item
7119 A tab stop is converted into a non-breakable horizontal movement which
7120 can be neither stretched nor squeezed.  For example,
7122 @Example
7123 .ds foo a\tb\tc
7124 .ta T 5i
7125 \*[foo]
7126 @endExample
7128 @noindent
7129 creates a single line which is a bit longer than 10@tie{}inches (a string
7130 is used to show exactly where the tab characters are).  Now consider the
7131 following:
7133 @Example
7134 .ds bar a\tb b\tc
7135 .ta T 5i
7136 \*[bar]
7137 @endExample
7139 @noindent
7140 @code{gtroff} first converts the tab stops of the line into unbreakable
7141 horizontal movements, then splits the line after the second @samp{b}
7142 (assuming a sufficiently short line length).  Usually, this isn't what
7143 the user wants.
7145 @item
7146 Superfluous tabs (i.e., tab characters which do not correspond to a tab
7147 stop) are ignored except the first one which delimits the characters
7148 belonging to the last tab stop for right-justifying or centering.
7149 Consider the following example
7151 @Example
7152 .ds Z   foo\tbar\tfoo
7153 .ds ZZ  foo\tbar\tfoobar
7154 .ds ZZZ foo\tbar\tfoo\tbar
7155 .ta 2i 4iR
7156 \*[Z]
7158 \*[ZZ]
7160 \*[ZZZ]
7162 @endExample
7164 @noindent
7165 which produces the following output:
7167 @Example
7168 foo                 bar              foo
7169 foo                 bar           foobar
7170 foo                 bar              foobar
7171 @endExample
7173 @noindent
7174 The first line right-justifies the second `foo' relative to the tab
7175 stop.  The second line right-justifies `foobar'.  The third line finally
7176 right-justifies only `foo' because of the additional tab character which
7177 marks the end of the string belonging to the last defined tab stop.
7179 @item
7180 Tab stops are associated with the current environment
7181 (@pxref{Environments}).
7183 @item
7184 Calling @code{ta} without an argument removes all tab stops.
7186 @item
7187 @cindex tab stops, for TTY output devices
7188 The start-up value of @code{gtroff} is @w{@samp{T 0.8i}}.
7189 @end itemize
7191 @cindex tab settings register (@code{.tabs})
7192 The read-only number register @code{.tabs} contains a string
7193 representation of the current tab settings suitable for use as an
7194 argument to the @code{ta} request.
7196 @Example
7197 .ds tab-string \n[.tabs]
7198 \*[tab-string]
7199     @result{} T120u
7200 @endExample
7202 @cindex @code{.S} register, Plan@tie{}9 alias for @code{.tabs}
7203 @cindex @code{.tabs} register, Plan@tie{}9 alias (@code{.S})
7204 The @code{troff} version of the Plan@tie{}9 operating system uses
7205 register @code{.S} for the same purpose.
7206 @endDefreq
7208 @Defreq {tc, [@Var{fill-glyph}]}
7209 @cindex tab repetition character (@code{tc})
7210 @cindex character, tab repetition (@code{tc})
7211 @cindex glyph, tab repetition (@code{tc})
7212 Normally @code{gtroff} fills the space to the next tab stop with
7213 whitespace.  This can be changed with the @code{tc} request.  With no
7214 argument @code{gtroff} reverts to using whitespace, which is the
7215 default.  The value of this @dfn{tab repetition character} is
7216 associated with the current environment
7217 (@pxref{Environments}).@footnote{@dfn{Tab repetition character} is a
7218 misnomer since it is an output glyph.}
7219 @endDefreq
7221 @DefreqList {linetabs, n}
7222 @DefregListEnd {.linetabs}
7223 @cindex tab, line-tabs mode
7224 @cindex line-tabs mode
7225 @cindex mode, line-tabs
7226 If @var{n} is missing or not zero, enable @dfn{line-tabs} mode,
7227 or disable it otherwise (the default).
7228 In line-tabs mode, @code{gtroff} computes tab distances
7229 relative to the (current) output line instead of the input line.
7231 For example, the following code:
7233 @Example
7234 .ds x a\t\c
7235 .ds y b\t\c
7236 .ds z c
7237 .ta 1i 3i
7241 @endExample
7243 @noindent
7244 in normal mode, results in the output
7246 @Example
7247 a         b         c
7248 @endExample
7250 @noindent
7251 in line-tabs mode, the same code outputs
7253 @Example
7254 a         b                   c
7255 @endExample
7257 Line-tabs mode is associated with the current environment.
7258 The read-only register @code{.linetabs} is set to@tie{}1 if in line-tabs
7259 mode, and 0 in normal mode.
7260 @endDefreq
7262 @menu
7263 * Leaders::
7264 * Fields::
7265 @end menu
7267 @c ---------------------------------------------------------------------
7269 @node Leaders, Fields, Tabs and Fields, Tabs and Fields
7270 @subsection Leaders
7271 @cindex leaders
7273 Sometimes it may may be desirable to use the @code{tc} request to fill a
7274 particular tab stop with a given glyph (for example dots in a table
7275 of contents), but also normal tab stops on the rest of the line.  For
7276 this @code{gtroff} provides an alternate tab mechanism, called
7277 @dfn{leaders} which does just that.
7279 @cindex leader character
7280 A leader character (character code@tie{}1) behaves similarly to a tab
7281 character: It moves to the next tab stop.  The only difference is that
7282 for this movement, the fill glyph defaults to a period character and
7283 not to space.
7285 @Defesc {\\a, , , }
7286 @cindex leader character, non-interpreted (@code{\a})
7287 @cindex character, leader, non-interpreted (@code{\a})
7288 This escape is a non-interpreted leader character.  In copy mode
7289 (@pxref{Copy-in Mode}), @code{\a} is the same as a real leader
7290 character.
7291 @endDefesc
7293 @Defreq {lc, [@Var{fill-glyph}]}
7294 @cindex leader repetition character (@code{lc})
7295 @cindex character, leader repetition (@code{lc})
7296 @cindex glyph, leader repetition (@code{lc})
7297 Declare the @dfn{leader repetition character}.@footnote{@dfn{Leader
7298 repetition character} is a misnomer since it is an output glyph.}
7299 Without an argument, leaders act the same as tabs (i.e., using
7300 whitespace for filling).  @code{gtroff}'s start-up value is a dot
7301 (@samp{.}).  The value of the leader repetition character is
7302 associated with the current environment (@pxref{Environments}).
7303 @endDefreq
7305 @cindex table of contents
7306 @cindex contents, table of
7307 For a table of contents, to name an example, tab stops may be defined so
7308 that the section number is one tab stop, the title is the second with
7309 the remaining space being filled with a line of dots, and then the page
7310 number slightly separated from the dots.
7312 @Example
7313 .ds entry 1.1\tFoo\a\t12
7314 .lc .
7315 .ta 1i 5i +.25i
7316 \*[entry]
7317 @endExample
7319 @noindent
7320 This produces
7322 @Example
7323 1.1  Foo..........................................  12
7324 @endExample
7326 @c ---------------------------------------------------------------------
7328 @node Fields,  , Leaders, Tabs and Fields
7329 @subsection Fields
7330 @cindex fields
7332 @cindex field delimiting character (@code{fc})
7333 @cindex delimiting character, for fields (@code{fc})
7334 @cindex character, field delimiting (@code{fc})
7335 @cindex field padding character (@code{fc})
7336 @cindex padding character, for fields (@code{fc})
7337 @cindex character, field padding (@code{fc})
7338 @dfn{Fields} are a more general way of laying out tabular data.  A field
7339 is defined as the data between a pair of @dfn{delimiting characters}.
7340 It contains substrings which are separated by @dfn{padding characters}.
7341 The width of a field is the distance on the @emph{input} line from the
7342 position where the field starts to the next tab stop.  A padding
7343 character inserts stretchable space similar to @TeX{}'s @code{\hss}
7344 command (thus it can even be negative) to make the sum of all substring
7345 lengths plus the stretchable space equal to the field width.  If more
7346 than one padding character is inserted, the available space is evenly
7347 distributed among them.
7349 @Defreq {fc, [@Var{delim-char} [@Var{padding-char}]]}
7350 Define a delimiting and a padding character for fields.  If the latter
7351 is missing, the padding character defaults to a space character.  If
7352 there is no argument at all, the field mechanism is disabled (which is
7353 the default).  Note that contrary to e.g.@: the tab repetition
7354 character, delimiting and padding characters are @emph{not} associated
7355 to the current environment (@pxref{Environments}).
7357 Example:
7359 @Example
7360 .fc # ^
7361 .ta T 3i
7362 #foo^bar^smurf#
7364 #foo^^bar^smurf#
7365 @endExample
7367 @noindent
7368 and here the result:
7370 @Example
7371 foo         bar          smurf
7372 foo            bar       smurf
7373 @endExample
7374 @endDefreq
7377 @c =====================================================================
7379 @node Character Translations, Troff and Nroff Mode, Tabs and Fields, gtroff Reference
7380 @section Character Translations
7381 @cindex character translations
7382 @cindex translations of characters
7384 @cindex control character, changing (@code{cc})
7385 @cindex character, control, changing (@code{cc})
7386 @cindex no-break control character, changing (@code{c2})
7387 @cindex character, no-break control, changing (@code{c2})
7388 @cindex control character, no-break, changing (@code{c2})
7389 The control character (@samp{.}) and the no-break control character
7390 (@samp{'}) can be changed with the @code{cc} and @code{c2} requests,
7391 respectively.
7393 @Defreq {cc, [@Var{c}]}
7394 Set the control character to@tie{}@var{c}.  With no argument the default
7395 control character @samp{.} is restored.  The value of the control
7396 character is associated with the current environment
7397 (@pxref{Environments}).
7398 @endDefreq
7400 @Defreq {c2, [@Var{c}]}
7401 Set the no-break control character to@tie{}@var{c}.  With no argument the
7402 default control character @samp{'} is restored.  The value of the
7403 no-break control character is associated with the current environment
7404 (@pxref{Environments}).
7405 @endDefreq
7407 @Defreq {eo, }
7408 @cindex disabling @code{\} (@code{eo})
7409 @cindex @code{\}, disabling (@code{eo})
7410 Disable the escape mechanism completely.  After executing this
7411 request, the backslash character @samp{\} no longer starts an escape
7412 sequence.
7414 This request can be very helpful in writing macros since it is not
7415 necessary then to double the escape character.  Here an example:
7417 @Example
7418 .\" This is a simplified version of the
7419 .\" .BR request from the man macro package
7421 .de BR
7422 .  ds result \&
7423 .  while (\n[.$] >= 2) \@{\
7424 .    as result \fB\$1\fR\$2
7425 .    shift 2
7426 .  \@}
7427 .  if \n[.$] .as result \fB\$1
7428 \*[result]
7429 .  ft R
7432 @endExample
7433 @endDefreq
7435 @Defreq {ec, [@Var{c}]}
7436 @cindex escape character, changing (@code{ec})
7437 @cindex character, escape, changing (@code{ec})
7438 Set the escape character to@tie{}@var{c}.  With no argument the default
7439 escape character @samp{\} is restored.  It can be also used to
7440 re-enable the escape mechanism after an @code{eo} request.
7442 Note that changing the escape character globally will likely break
7443 macro packages since @code{gtroff} has no mechanism to `intern' macros,
7444 i.e., to convert a macro definition into an internal form which is
7445 independent of its representation (@TeX{} has this mechanism).
7446 If a macro is called, it is executed literally.
7447 @endDefreq
7449 @DefreqList {ecs, }
7450 @DefreqListEnd {ecr, }
7451 The @code{ecs} request saves the current escape character
7452 in an internal register.
7453 Use this request in combination with the @code{ec} request to
7454 temporarily change the escape character.
7456 The @code{ecr} request restores the escape character
7457 saved with @code{ecs}.
7458 Without a previous call to @code{ecs}, this request
7459 sets the escape character to @code{\}.
7460 @endDefreq
7462 @DefescList {\\\\, , , }
7463 @DefescItem {\\e, , , }
7464 @DefescListEnd {\\E, , , }
7465 Print the current escape character (which is the backslash character
7466 @samp{\} by default).
7468 @code{\\} is a `delayed' backslash; more precisely, it is the default
7469 escape character followed by a backslash, which no longer has special
7470 meaning due to the leading escape character.  It is @emph{not} an escape
7471 sequence in the usual sense!  In any unknown escape sequence
7472 @code{\@var{X}} the escape character is ignored and @var{X} is printed.
7473 But if @var{X} is equal to the current escape character, no warning is
7474 emitted.
7476 As a consequence, only at top-level or in a diversion a backslash glyph is
7477 printed; in copy-in mode, it expands to a single backslash which then
7478 combines with the following character to an escape sequence.
7480 The @code{\E} escape differs from @code{\e} by printing an escape
7481 character that is not interpreted in copy mode.
7482 Use this to define strings with escapes that work
7483 when used in copy mode (for example, as a macro argument).
7484 The following example defines strings to begin and end
7485 a superscript:
7487 @Example
7488 .ds @{ \v'-.3m'\s'\En[.s]*60/100'
7489 .ds @} \s0\v'.3m'
7490 @endExample
7492 Another example to demonstrate the differences between the various escape
7493 sequences, using a strange escape character, @samp{-}.
7495 @Example
7496 .ec -
7497 .de xxx
7498 --A'123'
7500 .xxx
7501     @result{} -A'foo'
7502 @endExample
7504 @noindent
7505 The result is surprising for most users, expecting @samp{1} since
7506 @samp{foo} is a valid identifier.  What has happened?  As mentioned
7507 above, the leading escape character makes the following character
7508 ordinary.  Written with the default escape character the sequence
7509 @samp{--} becomes @samp{\-} -- this is the minus sign.
7511 If the escape character followed by itself is a valid escape sequence,
7512 only @code{\E} yields the expected result:
7514 @Example
7515 .ec -
7516 .de xxx
7517 -EA'123'
7519 .xxx
7520     @result{} 1
7521 @endExample
7522 @endDefesc
7524 @Defesc {\\., , , }
7525 Similar to @code{\\}, the sequence @code{\.} isn't a real escape sequence.
7526 As before, a warning message is suppressed if the escape character is
7527 followed by a dot, and the dot itself is printed.
7529 @Example
7530 .de foo
7531 .  nop foo
7533 .  de bar
7534 .    nop bar
7535 \\..
7538 .foo
7539 .bar
7540     @result{} foo bar
7541 @endExample
7543 @noindent
7544 The first backslash is consumed while the macro is read, and the second
7545 is swallowed while exexuting macro @code{foo}.
7546 @endDefesc
7548 A @dfn{translation} is a mapping of an input character to an output
7549 glyph.  The mapping occurs at output time, i.e., the input character
7550 gets assigned the metric information of the mapped output character
7551 right before input tokens are converted to nodes (@pxref{Gtroff
7552 Internals}, for more on this process).
7554 @DefreqList {tr, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
7555 @DefreqListEnd {trin, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
7556 Translate character @var{a} to glyph@tie{}@var{b}, character @var{c} to
7557 glyph@tie{}@var{d}, etc.  If there is an odd number of arguments, the
7558 last one is translated to an unstretchable space (@w{@samp{\ }}).
7560 The @code{trin} request is identical to @code{tr},
7561 but when you unformat a diversion with @code{asciify}
7562 it ignores the translation.
7563 @xref{Diversions}, for details about the @code{asciify} request.
7565 Some notes:
7567 @itemize @bullet
7568 @item
7569 @cindex @code{\(}, and translations
7570 @cindex @code{\[}, and translations
7571 @cindex @code{\'}, and translations
7572 @cindex @code{\`}, and translations
7573 @cindex @code{\-}, and translations
7574 @cindex @code{\_}, and translations
7575 @cindex @code{\C}, and translations
7576 @cindex @code{\N}, and translations
7577 @cindex @code{char} request, and translations
7578 @cindex special characters
7579 @cindex character, special
7580 @cindex numbered glyph (@code{\N})
7581 @cindex glyph, numbered (@code{\N})
7582 Special characters (@code{\(@var{xx}}, @code{\[@var{xxx}]},
7583 @code{\C'@var{xxx}'}, @code{\'}, @code{\`}, @code{\-}, @code{\_}),
7584 glyphs defined with the @code{char} request, and numbered glyphs
7585 (@code{\N'@var{xxx}'}) can be translated also.
7587 @item
7588 @cindex @code{\e}, and translations
7589 The @code{\e} escape can be translated also.
7591 @item
7592 @cindex @code{\%}, and translations
7593 @cindex @code{\~}, and translations
7594 Characters can be mapped onto the @code{\%} and @code{\~} escapes (but
7595 @code{\%} and @code{\~} can't be mapped onto another glyph).
7597 @item
7598 @cindex backspace character, and translations
7599 @cindex character, backspace, and translations
7600 @cindex leader character, and translations
7601 @cindex character, leader, and translations
7602 @cindex newline character, and translations
7603 @cindex character, newline, and translations
7604 @cindex tab character, and translations
7605 @cindex character, tab, and translations
7606 @cindex @code{\a}, and translations
7607 @cindex @code{\t}, and translations
7608 The following characters can't be translated: space (with one exception,
7609 see below), backspace, newline, leader (and @code{\a}), tab (and
7610 @code{\t}).
7612 @item
7613 @cindex @code{shc} request, and translations
7614 Translations are not considered for finding the soft hyphen character
7615 set with the @code{shc} request.
7617 @item
7618 @cindex @code{\&}, and translations
7619 The pair @samp{@var{c}\&} (this is an arbitrary character@tie{}@var{c}
7620 followed by the zero width space character) maps this character to nothing.
7622 @Example
7623 .tr a\&
7624 foo bar
7625     @result{} foo br
7626 @endExample
7628 @noindent
7629 It is even possible to map the space character to nothing:
7631 @Example
7632 .tr aa \&
7633 foo bar
7634     @result{} foobar
7635 @endExample
7637 @noindent
7638 As shown in the example, the space character can't be the first
7639 character/glyph pair as an argument of @code{tr}.  Additionally, it is
7640 not possible to map the space character to any other glyph; requests
7641 like @w{@samp{.tr aa x}} undo @w{@samp{.tr aa \&}} instead.
7643 If justification is active, lines are justified in spite of the
7644 `empty' space character (but there is no minimal distance, i.e.@: the
7645 space character, between words).
7647 @item
7648 After an output glyph has been constructed (this happens at the
7649 moment immediately before the glyph is appended to an output
7650 glyph list, either by direct output, in a macro, diversion, or
7651 string), it is no longer affected by @code{tr}.
7653 @item
7654 Translating character to glyphs where one of them or both are
7655 undefined is possible also; @code{tr} does not check whether the
7656 entities in its argument do exist.
7658 @xref{Gtroff Internals}.
7660 @item
7661 @code{troff} no longer has a hard-coded dependency on @w{Latin-1};
7662 all @code{char@var{XXX}} entities have been removed from the font
7663 description files.  This has a notable consequence which shows up in
7664 warnings like @code{can't find character with input code @var{XXX}}
7665 if the @code{tr} request isn't handled properly.
7667 Consider the following translation:
7669 @Example
7670 .tr Ã©Ã‰
7671 @endExample
7673 @noindent
7674 This maps input character @code{é} onto glyph @code{É}, which is
7675 identical to glyph @code{char201}.  But this glyph intentionally
7676 doesn't exist!  Instead, @code{\[char201]} is treated as an input
7677 character entity and is by default mapped onto @code{\['E]}, and
7678 @code{gtroff} doesn't handle translations of translations.
7680 The right way to write the above translation is
7682 @Example
7683 .tr Ã©\['E]
7684 @endExample
7686 @noindent
7687 With other words, the first argument of @code{tr} should be an input
7688 character or entity, and the second one a glyph entity.
7690 @item
7691 Without an argument, the @code{tr} request is ignored.
7692 @end itemize
7693 @endDefreq
7695 @Defreq {trnt, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
7696 @cindex @code{\!}, and @code{trnt}
7697 @code{trnt} is the same as the @code{tr} request except that the
7698 translations do not apply to text that is transparently throughput
7699 into a diversion with @code{\!}.  @xref{Diversions}, for more
7700 information.
7702 For example,
7704 @Example
7705 .tr ab
7706 .di x
7707 \!.tm a
7710 @endExample
7712 @noindent
7713 prints @samp{b} to the standard error stream; if @code{trnt} is used
7714 instead of @code{tr} it prints @samp{a}.
7715 @endDefreq
7718 @c =====================================================================
7720 @node Troff and Nroff Mode, Line Layout, Character Translations, gtroff Reference
7721 @section Troff and Nroff Mode
7722 @cindex troff mode
7723 @cindex mode, troff
7724 @cindex nroff mode
7725 @cindex mode, nroff
7727 Originally, @code{nroff} and @code{troff} were two separate programs,
7728 the former for TTY output, the latter for everything else.  With GNU
7729 @code{troff}, both programs are merged into one executable, sending
7730 its output to a device driver (@code{grotty} for TTY devices,
7731 @code{grops} for @sc{PostScript}, etc.) which interprets the
7732 intermediate output of @code{gtroff}.  For @acronym{UNIX} @code{troff}
7733 it makes sense to talk about @dfn{Nroff mode} and @dfn{Troff mode}
7734 since the differences are hardcoded.  For GNU @code{troff}, this
7735 distinction is not appropriate because @code{gtroff} simply takes the
7736 information given in the font files for a particular device without
7737 handling requests specially if a TTY output device is used.
7739 Usually, a macro package can be used with all output devices.
7740 Nevertheless, it is sometimes necessary to make a distinction between
7741 TTY and non-TTY devices: @code{gtroff} provides two built-in
7742 conditions @samp{n} and @samp{t} for the @code{if}, @code{ie}, and
7743 @code{while} requests to decide whether @code{gtroff} shall behave
7744 like @code{nroff} or like @code{troff}.
7746 @Defreq {troff, }
7747 @pindex troffrc
7748 @pindex troffrc-end
7749 Make the @samp{t} built-in condition true (and the @samp{n} built-in
7750 condition false) for @code{if}, @code{ie}, and @code{while}
7751 conditional requests.  This is the default if @code{gtroff}
7752 (@emph{not} @code{groff}) is started with the @option{-R} switch to
7753 avoid loading of the start-up files @file{troffrc} and
7754 @file{troffrc-end}.  Without @option{-R}, @code{gtroff} stays in troff
7755 mode if the output device is not a TTY (e.g.@: `ps').
7756 @endDefreq
7758 @Defreq {nroff, }
7759 @pindex tty.tmac
7760 Make the @samp{n} built-in condition true (and the @samp{t} built-in
7761 condition false) for @code{if}, @code{ie}, and @code{while}
7762 conditional requests.  This is the default if @code{gtroff} uses a TTY
7763 output device; the code for switching to nroff mode is in the file
7764 @file{tty.tmac} which is loaded by the start-up file @code{troffrc}.
7765 @endDefreq
7767 @xref{Conditionals and Loops}, for more details on built-in
7768 conditions.
7771 @c =====================================================================
7773 @node Line Layout, Line Control, Troff and Nroff Mode, gtroff Reference
7774 @section Line Layout
7775 @cindex line layout
7776 @cindex layout, line
7778 @cindex dimensions, line
7779 @cindex line dimensions
7780 The following drawing shows the dimensions which @code{gtroff} uses for
7781 placing a line of output onto the page.  They are labeled with the
7782 request which manipulates each dimension.
7784 @Example
7785                 -->| in |<--
7786                    |<-----------ll------------>|
7787               +----+----+----------------------+----+
7788               |    :    :                      :    |
7789               +----+----+----------------------+----+
7790            -->| po |<--
7791               |<--------paper width---------------->|
7792 @endExample
7794 @noindent
7795 These dimensions are:
7797 @ftable @code
7798 @item po
7799 @cindex left margin (@code{po})
7800 @cindex margin, left (@code{po})
7801 @cindex page offset (@code{po})
7802 @cindex offset, page (@code{po})
7803 @dfn{Page offset} -- this is the leftmost position of text on the final
7804 output, defining the @dfn{left margin}.
7806 @item in
7807 @cindex indentation (@code{in})
7808 @cindex line indentation (@code{in})
7809 @dfn{Indentation} -- this is the distance from the left margin where
7810 text is printed.
7812 @item ll
7813 @cindex line length (@code{ll})
7814 @cindex length of line (@code{ll})
7815 @dfn{Line length} -- this is the distance from the left margin to right
7816 margin.
7817 @end ftable
7819 A simple demonstration:
7821 @Example
7822 .ll 3i
7823 This is text without indentation.
7824 The line length has been set to 3\~inch.
7825 .in +.5i
7826 .ll -.5i
7827 Now the left and right margins are both increased.
7830 Calling .in and .ll without parameters restore
7831 the previous values.
7832 @endExample
7834 Result:
7836 @Example
7837 This  is text without indenta-
7838 tion.   The  line  length  has
7839 been set to 3 inch.
7840      Now   the  left  and
7841      right  margins   are
7842      both increased.
7843 Calling  .in  and  .ll without
7844 parameters restore the  previ-
7845 ous values.
7846 @endExample
7848 @DefreqList {po, [@Var{offset}]}
7849 @DefreqItem {po, @t{+}@Var{offset}}
7850 @DefreqItem {po, @t{-}@Var{offset}}
7851 @DefregListEnd {.o}
7852 @pindex troffrc
7853 Set horizontal page offset to @var{offset} (or increment or decrement
7854 the current value by @var{offset}).  Note that this request does not
7855 cause a break, so changing the page offset in the middle of text being
7856 filled may not yield the expected result.  The initial value is
7857 1@dmn{i}.  For TTY output devices, it is set to 0 in the startup file
7858 @file{troffrc}; the default scaling indicator is @samp{m} (and
7859 not @samp{v} as incorrectly documented in the original
7860 @acronym{UNIX} troff manual).
7862 The current page offset can be found in the read-only number register
7863 @samp{.o}.
7865 If @code{po} is called without an argument, the page offset is reset to
7866 the previous value before the last call to @code{po}.
7868 @Example
7869 .po 3i
7870 \n[.o]
7871     @result{} 720
7872 .po -1i
7873 \n[.o]
7874     @result{} 480
7876 \n[.o]
7877     @result{} 720
7878 @endExample
7879 @endDefreq
7881 @DefreqList {in, [@Var{indent}]}
7882 @DefreqItem {in, @t{+}@Var{indent}}
7883 @DefreqItem {in, @t{-}@Var{indent}}
7884 @DefregListEnd {.i}
7885 Set indentation to @var{indent} (or increment or decrement the
7886 current value by @var{indent}).  This request causes a break.
7887 Initially, there is no indentation.
7889 If @code{in} is called without an argument, the indentation is reset to
7890 the previous value before the last call to @code{in}.  The default
7891 scaling indicator is @samp{m}.
7893 The indentation is associated with the current environment
7894 (@pxref{Environments}).
7896 If a negative indentation value is specified (which is not allowed),
7897 @code{gtroff} emits a warning of type @samp{range} and sets the
7898 indentation to zero.
7900 The effect of @code{in} is delayed until a partially collected line (if
7901 it exists) is output.  A temporary indent value is reset to zero also.
7903 The current indentation (as set by @code{in}) can be found in the
7904 read-only number register @samp{.i}.
7905 @endDefreq
7907 @DefreqList {ti, offset}
7908 @DefreqItem {ti, @t{+}@Var{offset}}
7909 @DefreqItem {ti, @t{-}@Var{offset}}
7910 @DefregListEnd {.in}
7911 Temporarily indent the next output line by @var{offset}.  If an
7912 increment or decrement value is specified, adjust the temporary
7913 indentation relative to the value set by the @code{in} request.
7915 This request causes a break; its value is associated with the current
7916 environment (@pxref{Environments}).  The default scaling indicator
7917 is @samp{m}.  A call of @code{ti} without an argument is ignored.
7919 If the total indentation value is negative (which is not allowed),
7920 @code{gtroff} emits a warning of type @samp{range} and sets the
7921 temporary indentation to zero.  `Total indentation' is either
7922 @var{offset} if specified as an absolute value, or the temporary plus
7923 normal indentation, if @var{offset} is given as a relative value.
7925 The effect of @code{ti} is delayed until a partially collected line (if
7926 it exists) is output.
7928 The read-only number register @code{.in} is the indentation that applies
7929 to the current output line.
7931 The difference between @code{.i} and @code{.in} is that the latter takes
7932 into account whether a partially collected line still uses the old
7933 indentation value or a temporary indentation value is active.
7934 @endDefreq
7936 @DefreqList {ll, [@Var{length}]}
7937 @DefreqItem {ll, @t{+}@Var{length}}
7938 @DefreqItem {ll, @t{-}@Var{length}}
7939 @DefregItem {.l}
7940 @DefregListEnd {.ll}
7941 Set the line length to @var{length} (or increment or decrement the
7942 current value by @var{length}).  Initially, the line length is set to
7943 6.5@dmn{i}.  The effect of @code{ll} is delayed until a partially
7944 collected line (if it exists) is output.  The default scaling
7945 indicator is @samp{m}.
7947 If @code{ll} is called without an argument, the line length is reset to
7948 the previous value before the last call to @code{ll}.  If a negative
7949 line length is specified (which is not allowed), @code{gtroff} emits a
7950 warning of type @samp{range} and sets the line length to zero.
7952 The line length is associated with the current environment
7953 (@pxref{Environments}).
7955 @cindex line length register (@code{.l})
7956 The current line length (as set by @code{ll}) can be found in the
7957 read-only number register @samp{.l}.  The read-only number register
7958 @code{.ll} is the line length that applies to the current output line.
7960 Similar to @code{.i} and @code{.in}, the difference between @code{.l}
7961 and @code{.ll} is that the latter takes into account whether a partially
7962 collected line still uses the old line length value.
7963 @endDefreq
7966 @c =====================================================================
7968 @node Line Control, Page Layout, Line Layout, gtroff Reference
7969 @section Line Control
7970 @cindex line control
7971 @cindex control, line
7973 It is important to understand how @code{gtroff} handles input and output
7974 lines.
7976 Many escapes use positioning relative to the input line.  For example,
7977 this
7979 @Example
7980 This is a \h'|1.2i'test.
7982 This is a
7983 \h'|1.2i'test.
7984 @endExample
7986 @noindent
7987 produces
7989 @Example
7990 This is a   test.
7992 This is a             test.
7993 @endExample
7995 The main usage of this feature is to define macros which act exactly
7996 at the place where called.
7998 @Example
7999 .\" A simple macro to underline a word
8000 .de underline
8001 .  nop \\$1\l'|0\[ul]'
8003 @endExample
8005 @noindent
8006 In the above example, @samp{|0} specifies a negative distance from the
8007 current position (at the end of the just emitted argument @code{\$1}) back
8008 to the beginning of the input line.  Thus, the @samp{\l} escape draws a
8009 line from right to left.
8011 @cindex input line continuation (@code{\})
8012 @cindex line, input, continuation (@code{\})
8013 @cindex continuation, input line (@code{\})
8014 @cindex output line, continuation (@code{\c})
8015 @cindex line, output, continuation (@code{\c})
8016 @cindex continuation, output line (@code{\c})
8017 @cindex interrupted line
8018 @cindex line, interrupted
8019 @code{gtroff} makes a difference between input and output line
8020 continuation; the latter is also called @dfn{interrupting} a line.
8022 @DefescList {\\@key{RET}, , ,}
8023 @DefescItem {\\c, , ,}
8024 @DefregListEnd{.int}
8025 Continue a line.  @code{\@key{RET}} (this is a backslash at the end
8026 of a line immediately followed by a newline) works on the input level,
8027 suppressing the effects of the following newline in the input.
8029 @Example
8030 This is a \
8031 .test
8032     @result{} This is a .test
8033 @endExample
8035 The @samp{|} operator is also affected.
8037 @cindex @code{\R}, after @code{\c}
8038 @code{\c} works on the output level.  Anything after this escape on the
8039 same line is ignored, except @code{\R} which works as usual.  Anything
8040 before @code{\c} on the same line will be appended to the current partial
8041 output line.  The next non-command line after an interrupted line counts
8042 as a new input line.
8044 The visual results depend on whether no-fill mode is active.
8046 @itemize @bullet
8047 @item
8048 @cindex @code{\c}, and no-fill mode
8049 @cindex no-fill mode, and @code{\c}
8050 @cindex mode, no-fill, and @code{\c}
8051 If no-fill mode is active (using the @code{nf} request), the next input
8052 text line after @code{\c} will be handled as a continuation of the same
8053 input text line.
8055 @Example
8057 This is a \c
8058 test.
8059     @result{} This is a test.
8060 @endExample
8062 @item
8063 @cindex @code{\c}, and fill mode
8064 @cindex fill mode, and @code{\c}
8065 @cindex mode, fill, and @code{\c}
8066 If fill mode is active (using the @code{fi} request), a word interrupted
8067 with @code{\c} will be continued with the text on the next input text line,
8068 without an intervening space.
8070 @Example
8071 This is a te\c
8073     @result{} This is a test.
8074 @endExample
8075 @end itemize
8077 Note that an intervening control line which causes a break is stronger
8078 than @code{\c}, flushing out the current partial line in the usual way.
8080 @cindex interrupted line register (@code{.int})
8081 The @code{.int} register contains a positive value
8082 if the last output line was interrupted with @code{\c}; this is
8083 associated with the current environment (@pxref{Environments}).
8084 @endDefesc
8086 @c =====================================================================
8088 @node Page Layout, Page Control, Line Control, gtroff Reference
8089 @section Page Layout
8090 @cindex page layout
8091 @cindex layout, page
8093 @code{gtroff} provides some very primitive operations for controlling
8094 page layout.
8096 @DefreqList {pl, [@Var{length}]}
8097 @DefreqItem {pl, @t{+}@Var{length}}
8098 @DefreqItem {pl, @t{-}@Var{length}}
8099 @DefregListEnd {.p}
8100 @cindex page length (@code{pl})
8101 @cindex length of page (@code{pl})
8102 Set the @dfn{page length} to @var{length} (or increment or decrement
8103 the current value by @var{length}).  This is the length of the
8104 physical output page.  The default scaling indicator is @samp{v}.
8106 @cindex page length register (@code{.p})
8107 The current setting can be found in the read-only number register
8108 @samp{.p}.
8110 @cindex top margin
8111 @cindex margin, top
8112 @cindex bottom margin
8113 @cindex margin, bottom
8114 Note that this only specifies the size of the page, not the top and
8115 bottom margins.  Those are not set by @code{gtroff} directly.
8116 @xref{Traps}, for further information on how to do this.
8118 Negative @code{pl} values are possible also, but not very useful: No
8119 trap is sprung, and each line is output on a single page (thus
8120 suppressing all vertical spacing).
8122 If no argument or an invalid argument is given, @code{pl} sets the page
8123 length to 11@dmn{i}.
8124 @endDefreq
8126 @cindex headers
8127 @cindex footers
8128 @cindex titles
8129 @code{gtroff} provides several operations which help in setting up top
8130 and bottom titles (or headers and footers).
8132 @Defreq {tl, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}}
8133 @cindex title line (@code{tl})
8134 @cindex three-part title (@code{tl})
8135 @cindex page number character (@code{%})
8136 Print a @dfn{title line}.  It consists of three parts: a left
8137 justified portion, a centered portion, and a right justified portion.
8138 The argument separator @samp{'} can be replaced with any character not
8139 occurring in the title line.  The @samp{%} character is replaced with
8140 the current page number.  This character can be changed with the
8141 @code{pc} request (see below).
8143 Without argument, @code{tl} is ignored.
8145 Some notes:
8147 @itemize @bullet
8148 @item
8149 A title line is not restricted to the top or bottom of a page.
8151 @item
8152 @code{tl} prints the title line immediately, ignoring a partially filled
8153 line (which stays untouched).
8155 @item
8156 It is not an error to omit closing delimiters.  For example,
8157 @w{@samp{.tl /foo}} is equivalent to @w{@samp{.tl /foo///}}: It prints a
8158 title line with the left justified word @samp{foo}; the centered and
8159 right justfied parts are empty.
8161 @item
8162 @code{tl} accepts the same parameter delimiting characters as the
8163 @code{\A} escape; see @ref{Escapes}.
8164 @end itemize
8165 @endDefreq
8167 @DefreqList {lt, [@Var{length}]}
8168 @DefreqItem {lt, @t{+}@Var{length}}
8169 @DefreqItem {lt, @t{-}@Var{length}}
8170 @DefregListEnd {.lt}
8171 @cindex length of title line (@code{lt})
8172 @cindex title line, length (@code{lt})
8173 @cindex title line length register (@code{.lt})
8174 The title line is printed using its own line length, which is
8175 specified (or incremented or decremented) with the @code{lt} request.
8176 Initially, the title line length is set to 6.5@dmn{i}.  If a negative
8177 line length is specified (which is not allowed), @code{gtroff} emits a
8178 warning of type @samp{range} and sets the title line length to zero.
8179 The default scaling indicator is @samp{m}.  If @code{lt} is called
8180 without an argument, the title length is reset to the previous value
8181 before the last call to @code{lt}.
8183 The current setting of this is available in the @code{.lt} read-only
8184 number register; it is associated with the current environment
8185 (@pxref{Environments}).
8186 @endDefreq
8188 @DefreqList {pn, page}
8189 @DefreqItem {pn, @t{+}@Var{page}}
8190 @DefreqItem {pn, @t{-}@Var{page}}
8191 @DefregListEnd {.pn}
8192 @cindex page number (@code{pn})
8193 @cindex number, page (@code{pn})
8194 Change (increase or decrease) the page number of the @emph{next} page.
8195 The only argument is the page number; the request is ignored without a
8196 parameter.
8198 The read-only number register @code{.pn} contains the number of the next
8199 page: either the value set by a @code{pn} request, or the number of the
8200 current page plus@tie{}1.
8201 @endDefreq
8203 @Defreq {pc, [@Var{char}]}
8204 @cindex changing the page number character (@code{pc})
8205 @cindex page number character, changing (@code{pc})
8206 @vindex %
8207 Change the page number character (used by the @code{tl} request) to a
8208 different character.  With no argument, this mechanism is disabled.
8209 Note that this doesn't affect the number register@tie{}@code{%}.
8210 @endDefreq
8212 @xref{Traps}.
8215 @c =====================================================================
8217 @node Page Control, Fonts and Symbols, Page Layout, gtroff Reference
8218 @section Page Control
8219 @cindex page control
8220 @cindex control, page
8222 @DefreqList {bp, [@Var{page}]}
8223 @DefreqItem {bp, @t{+}@Var{page}}
8224 @DefreqItem {bp, @t{-}@Var{page}}
8225 @DefregListEnd {%}
8226 @cindex new page (@code{bp})
8227 @cindex page, new (@code{bp})
8228 Stop processing the current page and move to the next page.  This
8229 request causes a break.  It can also take an argument to set
8230 (increase, decrease) the page number of the next page (which actually
8231 becomes the current page after @code{bp} has finished).  The
8232 difference between @code{bp} and @code{pn} is that @code{pn} does not
8233 cause a break or actually eject a page.  @xref{Page Layout}.
8235 @Example
8236 .de newpage                         \" define macro
8237 'bp                                 \" begin page
8238 'sp .5i                             \" vertical space
8239 .tl 'left top'center top'right top' \" title
8240 'sp .3i                             \" vertical space
8241 ..                                  \" end macro
8242 @endExample
8244 @cindex @code{bp} request, and top-level diversion
8245 @cindex top-level diversion, and @code{bp}
8246 @cindex diversion, top-level, and @code{bp}
8247 @code{bp} has no effect if not called within the top-level diversion
8248 (@pxref{Diversions}).
8250 @cindex page number register (@code{%})
8251 @cindex current page number (@code{%})
8252 The read-write register@tie{}@code{%} holds the current page number.
8254 The number register @code{.pe} is set to@tie{}1 while @code{bp} is
8255 active.  @xref{Page Location Traps}.
8256 @endDefreq
8258 @Defreq {ne, [@Var{space}]}
8259 @cindex orphan lines, preventing with @code{ne}
8260 @cindex conditional page break (@code{ne})
8261 @cindex page break, conditional (@code{ne})
8262 It is often necessary to force a certain amount of space before a new
8263 page occurs.  This is most useful to make sure that there is not a
8264 single @dfn{orphan} line left at the bottom of a page.  The @code{ne}
8265 request ensures that there is a certain distance, specified by the
8266 first argument, before the next page is triggered (see @ref{Traps},
8267 for further information).  The default scaling indicator for @code{ne}
8268 is @samp{v}; the default value of @var{space} is@tie{}1@dmn{v} if no
8269 argument is given.
8271 For example, to make sure that no fewer than 2@tie{}lines get orphaned,
8272 do the following before each paragraph:
8274 @Example
8275 .ne 2
8276 text text text
8277 @endExample
8279 @code{ne} will then automatically cause a page break if there is space
8280 for one line only.
8281 @endDefreq
8283 @DefreqList {sv, [@Var{space}]}
8284 @DefreqListEnd {os, }
8285 @cindex @code{ne} request, comparison with @code{sv}
8286 @code{sv} is similar to the @code{ne} request; it reserves the
8287 specified amount of vertical space.  If the desired amount of space
8288 exists before the next trap (or the bottom page boundary if no trap is
8289 set), the space is output immediately (ignoring a partially filled line
8290 which stays untouched).  If there is not enough space, it is stored for
8291 later output via the @code{os} request.  The default value is@tie{}1@dmn{v}
8292 if no argument is given; the default scaling indicator is @samp{v}.
8294 @cindex @code{sv} request, and no-space mode
8295 @cindex @code{os} request, and no-space mode
8296 Both @code{sv} and @code{os} ignore no-space mode.  While the @code{sv}
8297 request allows negative values for @var{space}, @code{os} will ignore
8298 them.
8299 @endDefreq
8301 @Defreg {nl}
8302 @cindex current vertical position (@code{nl})
8303 @cindex vertical position, current (@code{nl})
8304 @cindex position, vertical, current (@code{nl})
8305 This register contains the current vertical position.  If the vertical
8306 position is zero and the top of page transition hasn't happened yet,
8307 @code{nl} is set to negative value.  @code{gtroff} itself does this at
8308 the very beginning of a document before anything has been printed, but
8309 the main usage is to plant a header trap on a page if this page has
8310 already started.
8312 Consider the following:
8314 @Example
8315 .de xxx
8316 .  sp
8317 .  tl ''Header''
8318 .  sp
8321 First page.
8323 .wh 0 xxx
8324 .nr nl (-1)
8325 Second page.
8326 @endExample
8328 @noindent
8329 Result:
8331 @Example
8332 First page.
8336                              Header
8338 Second page.
8341 @endExample
8343 @noindent
8344 Without resetting @code{nl} to a negative value, the just planted trap
8345 would be active beginning with the @emph{next} page, not the current
8346 one.
8348 @xref{Diversions}, for a comparison with the @code{.h} and @code{.d}
8349 registers.
8350 @endDefreg
8352 @c =====================================================================
8354 @node Fonts and Symbols, Sizes, Page Control, gtroff Reference
8355 @section Fonts and Symbols
8356 @cindex fonts
8358 @code{gtroff} can switch fonts at any point in the text.
8360 The basic set of fonts is @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
8361 These are Times Roman, Italic, Bold, and Bold Italic.  For non-TTY
8362 devices, there is also at least one symbol font which contains various
8363 special symbols (Greek, mathematics).
8365 @menu
8366 * Changing Fonts::
8367 * Font Families::
8368 * Font Positions::
8369 * Using Symbols::
8370 * Special Fonts::
8371 * Artificial Fonts::
8372 * Ligatures and Kerning::
8373 @end menu
8375 @c ---------------------------------------------------------------------
8377 @node Changing Fonts, Font Families, Fonts and Symbols, Fonts and Symbols
8378 @subsection Changing Fonts
8379 @cindex fonts
8381 @DefreqList {ft, [@Var{font}]}
8382 @DefescItem {\\f, , f, }
8383 @DefescItem {\\f, @lparen{}, fn, }
8384 @DefescItem {\\f, @lbrack{}, font, @rbrack}
8385 @DefregListEnd {.sty}
8386 @cindex changing fonts (@code{ft}, @code{\f})
8387 @cindex fonts, changing (@code{ft}, @code{\f})
8388 @cindex @code{sty} request, and changing fonts
8389 @cindex @code{fam} request, and changing fonts
8390 @cindex @code{\F}, and changing fonts
8391 @kindex styles
8392 @kindex family
8393 @pindex DESC
8394 The @code{ft} request and the @code{\f} escape change the current font
8395 to @var{font} (one-character name@tie{}@var{f}, two-character name
8396 @var{fn}).
8398 If @var{font} is a style name (as set with the @code{sty} request or
8399 with the @code{styles} command in the @file{DESC} file), use it within
8400 the current font family (as set with the @code{fam} request, @code{\F}
8401 escape, or with the @code{family} command in the @file{DESC} file).
8403 @cindex previous font (@code{ft}, @code{\f[]}, @code{\fP})
8404 @cindex font, previous (@code{ft}, @code{\f[]}, @code{\fP})
8405 With no argument or using @samp{P} as an argument, @code{.ft} switches
8406 to the previous font.  Use @code{\f[]} to do this with the escape.  The
8407 old syntax forms @code{\fP} or @code{\f[P]} are also supported.
8409 Fonts are generally specified as upper-case strings, which are usually
8410 1@tie{}to 4 characters representing an abbreviation or acronym of the
8411 font name.  This is no limitation, just a convention.
8413 The example below produces two identical lines.
8415 @Example
8416 eggs, bacon,
8417 .ft B
8418 spam
8420 and sausage.
8422 eggs, bacon, \fBspam\fP and sausage.
8423 @endExample
8425 Note that @code{\f} doesn't produce an input token in @code{gtroff}.
8426 As a consequence, it can be used in requests like @code{mc} (which
8427 expects a single character as an argument) to change the font on
8428 the fly:
8430 @Example
8431 .mc \f[I]x\f[]
8432 @endExample
8434 The current style name is available in the read-only number register
8435 @samp{.sty} (this is a string-valued register); if the current font
8436 isn't a style, the empty string is returned.  It is associated with
8437 the current environment.
8439 @xref{Font Positions}, for an alternative syntax.
8440 @endDefreq
8442 @Defreq {ftr, f [@Var{g}]}
8443 @cindex @code{ft} request, and font translations
8444 @cindex @code{ul} request, and font translations
8445 @cindex @code{bd} request, and font translations
8446 @cindex @code{\f}, and font translations
8447 @cindex @code{cs} request, and font translations
8448 @cindex @code{tkf} request, and font translations
8449 @cindex @code{special} request, and font translations
8450 @cindex @code{fspecial} request, and font translations
8451 @cindex @code{fp} request, and font translations
8452 @cindex @code{sty} request, and font translations
8453 @cindex @code{if} request, and font translations
8454 @cindex @code{ie} request, and font translations
8455 @cindex @code{while} request, and font translations
8456 Translate font@tie{}@var{f} to font@tie{}@var{g}.  Whenever a font
8457 named@tie{}@var{f} is referred to in a @code{\f} escape sequence,
8458 in the @code{F} and @code{S} conditional operators, or in the
8459 @code{ft}, @code{ul}, @code{bd}, @code{cs}, @code{tkf},
8460 @code{special}, @code{fspecial}, @code{fp}, or @code{sty} requests,
8461 font@tie{}@var{g} is used.  If @var{g} is missing or equal to@tie{}@var{f}
8462 the translation is undone.
8463 @endDefreq
8465 @c ---------------------------------------------------------------------
8467 @node Font Families, Font Positions, Changing Fonts, Fonts and Symbols
8468 @subsection Font Families
8469 @cindex font families
8470 @cindex families, font
8471 @cindex font styles
8472 @cindex styles, font
8474 Due to the variety of fonts available, @code{gtroff} has added the
8475 concept of @dfn{font families} and @dfn{font styles}.  The fonts are
8476 specified as the concatenation of the font family and style.  Specifying
8477 a font without the family part causes @code{gtroff} to use that style of
8478 the current family.
8480 @cindex PostScript fonts
8481 @cindex fonts, PostScript
8482 Currently, fonts for the devices @option{-Tps}, @option{-Tdvi},
8483 @option{-Tlj4}, @option{-Tlbp}, and the X11 fonts are set up to this
8484 mechanism.  By default, @code{gtroff} uses the Times family with the four
8485 styles @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
8487 This way, it is possible to use the basic four fonts and to select a
8488 different font family on the command line (@pxref{Groff Options}).
8490 @DefreqList {fam, [@Var{family}]}
8491 @DefregItem {.fam}
8492 @DefescItem {\\F, , f, }
8493 @DefescItem {\\F, @lparen{}, fm, }
8494 @DefescItem {\\F, @lbrack{}, family, @rbrack}
8495 @DefregListEnd {.fn}
8496 @cindex changing font family (@code{fam}, @code{\F})
8497 @cindex font family, changing (@code{fam}, @code{\F})
8498 Switch font family to @var{family} (one-character name@tie{}@var{f},
8499 two-character name @var{fm}).  If no argument is given, switch
8500 back to the previous font family.  Use @code{\F[]} to do this with the
8501 escape.  Note that @code{\FP} doesn't work; it selects font family
8502 @samp{P} instead.
8504 The value at start-up is @samp{T}.
8505 The current font family is available in the read-only number register
8506 @samp{.fam} (this is a string-valued register); it is associated with
8507 the current environment.
8509 @Example
8510 spam,
8511 .fam H    \" helvetica family
8512 spam,     \" used font is family H + style R = HR
8513 .ft B     \" family H + style B = font HB
8514 spam,
8515 .fam T    \" times family
8516 spam,     \" used font is family T + style B = TB
8517 .ft AR    \" font AR (not a style)
8518 baked beans,
8519 .ft R     \" family T + style R = font TR
8520 and spam.
8521 @endExample
8523 Note that @code{\F} doesn't produce an input token in @code{gtroff}.
8524 As a consequence, it can be used in requests like @code{mc} (which
8525 expects a single character as an argument) to change the font family on
8526 the fly:
8528 @Example
8529 .mc \F[P]x\F[]
8530 @endExample
8532 The @samp{.fn} register contains the current @dfn{real font name}
8533 of the current font.
8534 This is a string-valued register.
8535 If the current font is a style, the value of @code{\n[.fn]}
8536 is the proper concatenation of family and style name.
8537 @endDefreq
8539 @Defreq {sty, n style}
8540 @cindex changing font style (@code{sty})
8541 @cindex font style, changing (@code{sty})
8542 @cindex @code{cs} request, and font styles
8543 @cindex @code{bd} request, and font styles
8544 @cindex @code{tkf} request, and font styles
8545 @cindex @code{uf} request, and font styles
8546 @cindex @code{fspecial} request, and font styles
8547 Associate @var{style} with font position@tie{}@var{n}.  A font position
8548 can be associated either with a font or with a style.  The current
8549 font is the index of a font position and so is also either a font or a
8550 style.  If it is a style, the font that is actually used is the font
8551 which name is the concatenation of the name of the current
8552 family and the name of the current style.  For example, if the current
8553 font is@tie{}1 and font position@tie{}1 is associated with style
8554 @samp{R} and the current font family is @samp{T}, then font
8555 @samp{TR} will be used.  If the current font is not a style, then the
8556 current family is ignored.  If the requests @code{cs}, @code{bd},
8557 @code{tkf}, @code{uf}, or @code{fspecial} are applied to a style,
8558 they will instead be applied to the member of the current family
8559 corresponding to that style.
8561 @var{n}@tie{}must be a non-negative integer value.
8563 @pindex DESC
8564 @kindex styles
8565 The default family can be set with the @option{-f} option
8566 (@pxref{Groff Options}).  The @code{styles} command in the @file{DESC}
8567 file controls which font positions (if any) are initially associated
8568 with styles rather than fonts.  For example, the default setting for
8569 @sc{PostScript} fonts
8571 @Example
8572 styles R I B BI
8573 @endExample
8575 @noindent
8576 is equivalent to
8578 @Example
8579 .sty 1 R
8580 .sty 2 I
8581 .sty 3 B
8582 .sty 4 BI
8583 @endExample
8585 @code{fam} and @code{\F} always check whether the current font position
8586 is valid; this can give surprising results if the current font position is
8587 associated with a style.
8589 In the following example, we want to access the @sc{PostScript} font
8590 @code{FooBar} from the font family @code{Foo}:
8592 @Example
8593 .sty \n[.fp] Bar
8594 .fam Foo
8595     @result{} warning: can't find font `FooR'
8596 @endExample
8598 @noindent
8599 The default font position at start-up is@tie{}1; for the
8600 @sc{PostScript} device, this is associated with style @samp{R}, so
8601 @code{gtroff} tries to open @code{FooR}.
8603 A solution to this problem is to use a dummy font like the following:
8605 @Example
8606 .fp 0 dummy TR    \" set up dummy font at position 0
8607 .sty \n[.fp] Bar  \" register style `Bar'
8608 .ft 0             \" switch to font at position 0
8609 .fam Foo          \" activate family `Foo'
8610 .ft Bar           \" switch to font `FooBar'
8611 @endExample
8613 @xref{Font Positions}.
8614 @endDefreq
8616 @c ---------------------------------------------------------------------
8618 @node Font Positions, Using Symbols, Font Families, Fonts and Symbols
8619 @subsection Font Positions
8620 @cindex font positions
8621 @cindex positions, font
8623 For the sake of old phototypesetters and compatibility with old versions
8624 of @code{troff}, @code{gtroff} has the concept of font @dfn{positions},
8625 on which various fonts are mounted.
8627 @DefreqList {fp, pos font [@Var{external-name}]}
8628 @DefregItem {.f}
8629 @DefregListEnd {.fp}
8630 @cindex mounting font (@code{fp})
8631 @cindex font, mounting (@code{fp})
8632 Mount font @var{font} at position @var{pos} (which must be a
8633 non-negative integer).  This numeric position can then be referred to
8634 with font changing commands.  When @code{gtroff} starts it is using
8635 font position@tie{}1 (which must exist; position@tie{}0 is unused
8636 usually at start-up).
8638 @cindex font position register (@code{.f})
8639 The current font in use, as a font position, is available in the
8640 read-only number register @samp{.f}.  This can be useful to remember the
8641 current font for later recall.  It is associated with the current
8642 environment (@pxref{Environments}).
8644 @Example
8645 .nr save-font \n[.f]
8646 .ft B
8647 ... text text text ...
8648 .ft \n[save-font]
8649 @endExample
8651 @cindex next free font position register (@code{.fp})
8652 The number of the next free font position is available in the read-only
8653 number register @samp{.fp}.  This is useful when mounting a new font,
8654 like so:
8656 @Example
8657 .fp \n[.fp] NEATOFONT
8658 @endExample
8660 @pindex DESC@r{, and font mounting}
8661 Fonts not listed in the @file{DESC} file are automatically mounted on
8662 the next available font position when they are referenced.  If a font
8663 is to be mounted explicitly with the @code{fp} request on an unused
8664 font position, it should be mounted on the first unused font position,
8665 which can be found in the @code{.fp} register.  Although @code{gtroff}
8666 does not enforce this strictly, it is not allowed to mount a font at a
8667 position whose number is much greater (approx.@: 1000 positions) than
8668 that of any currently used position.
8670 The @code{fp} request has an optional third argument.  This argument
8671 gives the external name of the font, which is used for finding the font
8672 description file.  The second argument gives the internal name of the
8673 font which is used to refer to the font in @code{gtroff} after it has
8674 been mounted.  If there is no third argument then the internal name is
8675 used as the external name.  This feature makes it possible to use
8676 fonts with long names in compatibility mode.
8677 @endDefreq
8679 Both the @code{ft} request and the @code{\f} escape have alternative
8680 syntax forms to access font positions.
8682 @DefreqList {ft, nnn}
8683 @DefescItem {\\f, , n, }
8684 @DefescItem {\\f, @lparen{}, nn, }
8685 @DefescListEnd {\\f, @lbrack{}, nnn, @rbrack}
8686 @cindex changing font position (@code{\f})
8687 @cindex font position, changing (@code{\f})
8688 @cindex @code{sty} request, and font positions
8689 @cindex @code{fam} request, and font positions
8690 @cindex @code{\F}, and font positions
8691 @kindex styles
8692 @kindex family
8693 @pindex DESC
8694 Change the current font position to @var{nnn} (one-digit
8695 position@tie{}@var{n}, two-digit position @var{nn}), which must be a
8696 non-negative integer.
8698 If @var{nnn} is associated with a style (as set with the @code{sty}
8699 request or with the @code{styles} command in the @file{DESC} file), use
8700 it within the current font family (as set with the @code{fam} request,
8701 the @code{\F} escape, or with the @code{family} command in the @file{DESC}
8702 file).
8704 @Example
8705 this is font 1
8706 .ft 2
8707 this is font 2
8708 .ft                   \" switch back to font 1
8709 .ft 3
8710 this is font 3
8712 this is font 1 again
8713 @endExample
8715 @xref{Changing Fonts}, for the standard syntax form.
8716 @endDefreq
8718 @c ---------------------------------------------------------------------
8720 @node Using Symbols, Special Fonts, Font Positions, Fonts and Symbols
8721 @subsection Using Symbols
8722 @cindex using symbols
8723 @cindex symbols, using
8725 @cindex glyph
8726 @cindex character
8727 @cindex ligature
8728 A @dfn{glyph} is a graphical representation of a @dfn{character}.
8729 While a character is an abstract entity containing semantic
8730 information, a glyph is something which can be actually seen on screen
8731 or paper.  It is possible that a character has multiple glyph
8732 representation forms (for example, the character `A' can be either
8733 written in a roman or an italic font, yielding two different glyphs);
8734 sometimes more than one character maps to a single glyph (this is a
8735 @dfn{ligature} -- the most common is `fi').
8737 @cindex symbol
8738 @cindex special fonts
8739 @kindex fonts
8740 @pindex DESC
8741 @cindex @code{special} request, and glyph search order
8742 @cindex @code{fspecial} request, and glyph search order
8743 A @dfn{symbol} is simply a named glyph.  Within @code{gtroff}, all
8744 glyph names of a particular font are defined in its font file.  If the
8745 user requests a glyph not available in this font, @code{gtroff} looks
8746 up an ordered list of @dfn{special fonts}.  By default, the
8747 @sc{PostScript} output device supports the two special fonts @samp{SS}
8748 (slanted symbols) and @samp{S} (symbols) (the former is looked up
8749 before the latter).  Other output devices use different names for
8750 special fonts.  Fonts mounted with the @code{fonts} keyword in the
8751 @file{DESC} file are globally available.  To install additional
8752 special fonts locally (i.e.@: for a particular font), use the
8753 @code{fspecial} request.
8755 Here the exact rules how @code{gtroff} searches a given symbol:
8757 @itemize @bullet
8758 @item
8759 If the symbol has been defined with the @code{char} request, use it.
8760 This hides a symbol with the same name in the current font.
8762 @item
8763 Check the current font.
8765 @item
8766 If the symbol has been defined with the @code{fchar} request, use it.
8768 @item
8769 Check whether the current font has a font-specific list of special fonts;
8770 test all fonts in the order of appearance in the last @code{fspecial}
8771 call if appropriate.
8773 @item
8774 If the symbol has been defined with the @code{fschar} request for the
8775 current font, use it.
8777 @item
8778 Check all fonts in the order of appearance in the last @code{special}
8779 call.
8781 @item
8782 If the symbol has been defined with the @code{schar} request, use it.
8784 @item
8785 As a last resort, consult all fonts loaded up to now for special fonts
8786 and check them, starting with the lowest font number.  Note that this can
8787 sometimes lead to surprising results since the @code{fonts} line in the
8788 @file{DESC} file often contains empty positions which are filled later
8789 on.  For example, consider the following:
8791 @Example
8792 fonts 3 0 0 FOO
8793 @endExample
8795 @noindent
8796 This mounts font @code{foo} at font position@tie{}3.  We assume that
8797 @code{FOO} is a special font, containing glyph @code{foo},
8798 and that no font has been loaded yet.  The line
8800 @Example
8801 .fspecial BAR BAZ
8802 @endExample
8804 @noindent
8805 makes font @code{BAZ} special only if font @code{BAR} is active.  We
8806 further assume that @code{BAZ} is really a special font, i.e., the font
8807 description file contains the @code{special} keyword, and that it
8808 also contains glyph @code{foo} with a special shape fitting to font
8809 @code{BAR}.  After executing @code{fspecial}, font @code{BAR} is loaded at
8810 font position@tie{}1, and @code{BAZ} at position@tie{}2.
8812 We now switch to a new font @code{XXX}, trying to access glyph @code{foo}
8813 which is assumed to be missing.  There are neither font-specific special
8814 fonts for @code{XXX} nor any other fonts made special with the
8815 @code{special} request, so @code{gtroff} starts the search for special
8816 fonts in the list of already mounted fonts, with increasing font
8817 positions.  Consequently, it finds @code{BAZ} before @code{FOO} even for
8818 @code{XXX} which is not the intended behaviour.
8819 @end itemize
8821 @xref{Font Files}, and @ref{Special Fonts}, for more details.
8823 @cindex list of available glyphs (@cite{groff_char(7)} man page)
8824 @cindex available glyphs, list (@cite{groff_char(7)} man page)
8825 @cindex glyphs, available, list (@cite{groff_char(7)} man page)
8826 The list of available symbols is device dependent; see the
8827 @cite{groff_char(7)} man page for a complete list of all glyphs.  For
8828 example, say
8830 @Example
8831 man -Tdvi groff_char > groff_char.dvi
8832 @endExample
8834 @noindent
8835 for a list using the default DVI fonts (not all versions of the
8836 @code{man} program support the @option{-T} option).  If you want to
8837 use an additional macro package to change the used fonts, @code{groff}
8838 must be called directly:
8840 @Example
8841 groff -Tdvi -mec -man groff_char.7 > groff_char.dvi
8842 @endExample
8844 @cindex composite glyph names
8845 @cindex glyph names, composite
8846 @cindex groff glyph list (GGL)
8847 @cindex GGL (groff glyph list)
8848 @cindex adobe glyph list (AGL)
8849 @cindex AGL (adobe glyph list)
8850 Glyph names not listed in groff_char(7) are derived algorithmically,
8851 using a simplified version of the Adobe Glyph List (AGL) algorithm
8852 which is described in
8853 @uref{http://partners.adobe.com@//asn@//tech@//type@//unicodegn.jsp}.
8854 The (frozen) set of glyph names which can't be derived algorithmically
8855 is called @dfn{groff glyph list (GGL)}.
8857 @itemize @bullet
8858 @item
8859 A glyph for Unicode character U+@var{XXXX}[@var{X}[@var{X}]] which is
8860 not a composite character will be named
8861 @code{u@var{XXXX}@r{[}@var{X}@r{[}@var{X}@r{]]}}.  @var{X} must be an
8862 uppercase hexadecimal digit.  Examples: @code{u1234}, @code{u008E},
8863 @code{u12DB8}.  The largest Unicode value is 0x10FFFF.  There must be at
8864 least four @code{X} digits; if necessary, add leading zeroes (after the
8865 @samp{u}).  No zero padding is allowed for character codes greater than
8866 0xFFFF.  Surrogates (i.e., Unicode values greater than 0xFFFF
8867 represented with character codes from the surrogate area U+D800-U+DFFF)
8868 are not allowed too.
8870 @item
8871 A glyph representing more than a single input character will be named
8873 @display
8874 @samp{u} @var{component1} @samp{_} @var{component2} @samp{_} @var{component3} @dots{}
8875 @end display
8877 @noindent
8878 Example: @code{u0045_0302_0301}.
8880 For simplicity, all Unicode characters which are composites must be
8881 decomposed maximally (this is normalization form@tie{}D in the Unicode
8882 standard); for example, @code{u00CA_0301} is not a valid glyph name
8883 since U+00CA (@sc{latin capital letter e with circumflex}) can be
8884 further decomposed into U+0045 (@sc{latin capital letter e}) and U+0302
8885 (@sc{combining circumflex accent}).  @code{u0045_0302_0301} is thus the
8886 glyph name for U+1EBE, @sc{latin capital letter e with circumflex and
8887 acute}.
8889 @item
8890 groff maintains a table to decompose all algorithmically derived glyph
8891 names which are composites itself.  For example, @code{u0100} (@sc{latin
8892 letter a with macron}) will be automatically decomposed into
8893 @code{u0041_0304}.  Additionally, a glyph name of the GGL is preferred
8894 to an algorithmically derived glyph name; groff also automatically does
8895 the mapping.  Example: The glyph @code{u0045_0302} will be mapped to
8896 @code{^E}.
8898 @item
8899 glyph names of the GGL can't be used in composite glyph names; for
8900 example, @code{^E_u0301} is invalid.
8901 @end itemize
8903 @DefescList {\\, @lparen{}, nm, }
8904 @DefescItem {\\, @lbrack{}, name, @rbrack}
8905 @DefescListEnd {\\, @lbrack{}, component1 component2 @dots{}, @rbrack}
8906 Insert a symbol @var{name} (two-character name @var{nm}) or a composite
8907 glyph with component glyphs @var{component1}, @var{component2},
8908 @enddots{} There is no special syntax for one-character names -- the
8909 natural form @samp{\@var{n}} would collide with escapes.@footnote{Note
8910 that a one-character symbol is not the same as an input character, i.e.,
8911 the character @code{a} is not the same as @code{\[a]}.  By default,
8912 @code{groff} defines only a single one-character symbol, @code{\[-]}; it
8913 is usually accessed as @code{\-}.  On the other hand, @code{gtroff} has
8914 the special feature that @code{\[char@var{XXX}]} is the same as the
8915 input character with character code @var{XXX}.  For example,
8916 @code{\[char97]} is identical to the letter @code{a} if @acronym{ASCII}
8917 encoding is active.}
8919 If @var{name} is undefined, a warning of type @samp{char} is generated,
8920 and the escape is ignored.  @xref{Debugging}, for information about
8921 warnings.
8923 groff resolves @code{\[...]} with more than a single component as
8924 follows:
8926 @itemize @bullet
8927 @item
8928 Any component which is found in the GGL will be converted to the
8929 @code{u@var{XXXX}} form.
8931 @item
8932 Any component @code{u@var{XXXX}} which is found in the list of
8933 decomposable glyphs will be decomposed.
8935 @item
8936 The resulting elements are then concatenated with @samp{_} inbetween,
8937 dropping the leading @samp{u} in all elements but the first.
8938 @end itemize
8940 No check for the existence of any component (similar to @code{tr}
8941 request) will be done.
8943 Examples:
8945 @table @code
8946 @item \[A ho]
8947 @samp{A} maps to @code{u0041}, @samp{ho} maps to @code{u02DB}, thus the
8948 final glyph name would be @code{u0041_02DB}.  Note this is not the
8949 expected result: The ogonek glyph @samp{ho} is a spacing ogonek, but for
8950 a proper composite a non-spacing ogonek (U+0328) is necessary.  Looking
8951 into the file @file{composite.tmac} one can find @w{@samp{.composite ho
8952 u0328}} which changes the mapping of @samp{ho} while a composite glyph
8953 name is constructed, causing the final glyph name to be
8954 @code{u0041_0328}.
8956 @item \[^E u0301]
8957 @itemx \[^E aa]
8958 @itemx \[E a^ aa]
8959 @itemx \[E ^ ']
8960 @samp{^E} maps to @code{u0045_0302}, thus the final glyph name is
8961 @code{u0045_0302_0301} in all forms (assuming proper calls of the
8962 @code{composite} request).
8963 @end table
8965 It is not possible to define glyphs with names like @w{@samp{A ho}}
8966 within a groff font file.  This is not really a limitation; instead, you
8967 have to define @code{u0041_0328}.
8968 @endDefesc
8970 @Defesc {\\C, ', xxx, '}
8971 @cindex named character (@code{\C})
8972 @cindex character, named (@code{\C})
8973 Typeset the glyph named @var{xxx}.@footnote{@code{\C} is actually a
8974 misnomer since it accesses an output glyph.}  Normally it is more
8975 convenient to use @code{\[@var{xxx}]}, but @code{\C} has the advantage
8976 that it is compatible with newer versions of @acronym{AT&T}
8977 @code{troff} and is available in compatibility mode.
8978 @endDefesc
8980 @Defreq {composite, from to}
8981 @pindex composite.tmac
8982 Map glyph name @var{from} to glyph name @var{to} if it is used in
8983 @code{\[...]} with more than one component.  See above for examples.
8985 This mapping is based on glyph names only; no check for the existence of
8986 either glyph is done.
8988 A set of default mappings for many accents can be found in the file
8989 @file{composite.tmac} which is loaded at start-up.
8990 @endDefreq
8992 @Defesc {\\N, ', n, '}
8993 @cindex numbered glyph (@code{\N})
8994 @cindex glyph, numbered (@code{\N})
8995 @cindex @code{char} request, used with @code{\N}
8996 @cindex Unicode
8997 Typeset the glyph with code@tie{}@var{n} in the current font
8998 (@code{n}@tie{}is @strong{not} the input character code).  The
8999 number @var{n}@tie{}can be any non-negative decimal integer.  Most devices
9000 only have glyphs with codes between 0 and@tie{}255; the Unicode
9001 output device uses codes in the range 0--65535.  If the current
9002 font does not contain a glyph with that code, special fonts are
9003 @emph{not} searched.  The @code{\N} escape sequence can be
9004 conveniently used in conjunction with the @code{char} request:
9006 @Example
9007 .char \[phone] \f[ZD]\N'37'
9008 @endExample
9010 @noindent
9011 @pindex DESC
9012 @cindex unnamed glyphs
9013 @cindex glyphs, unnamed
9014 The code of each glyph is given in the fourth column in the font
9015 description file after the @code{charset} command.  It is possible to
9016 include unnamed glyphs in the font description file by using a
9017 name of @samp{---}; the @code{\N} escape sequence is the only way to
9018 use these.
9020 No kerning is applied to glyphs accessed with @code{\N}.
9021 @endDefesc
9023 Some escape sequences directly map onto special glyphs.
9025 @Defesc {\\', , , }
9026 This is a backslash followed by the apostrophe character, @acronym{ASCII}
9027 character @code{0x27} (@acronym{EBCDIC} character @code{0x7D}).  The same
9028 as @code{\[aa]}, the acute accent.
9029 @endDefesc
9031 @Defesc {\\`, , , }
9032 This is a backslash followed by @acronym{ASCII} character @code{0x60}
9033 (@acronym{EBCDIC} character @code{0x79} usually).  The same as
9034 @code{\[ga]}, the grave accent.
9035 @endDefesc
9037 @Defesc {\\-, , , }
9038 This is the same as @code{\[-]}, the minus sign in the current font.
9039 @endDefesc
9041 @Defreq {cflags, n c1 c2 @dots{}}
9042 @cindex glyph properties (@code{cflags})
9043 @cindex character properties (@code{cflags})
9044 @cindex properties of glyphs (@code{cflags})
9045 @cindex properties of characters (@code{cflags})
9046 Input characters and symbols have certain properties associated
9047 with it.@footnote{Note that the output glyphs themselves don't have
9048 such properties.  For @code{gtroff}, a glyph is a numbered box with
9049 a given width, depth, and height, nothing else.  All manipulations
9050 with the @code{cflags} request work on the input level.}  These
9051 properties can be modified with the @code{cflags} request.  The
9052 first argument is the sum of the desired flags and the remaining
9053 arguments are the characters or symbols to have those properties.
9054 It is possible to omit the spaces between the characters or symbols.
9056 @table @code
9057 @item 1
9058 @cindex end-of-sentence characters
9059 @cindex characters, end-of-sentence
9060 The character ends sentences (initially characters @samp{.?!} have this
9061 property).
9063 @item 2
9064 @cindex hyphenating characters
9065 @cindex characters, hyphenation
9066 Lines can be broken before the character (initially no characters have
9067 this property).
9069 @item 4
9070 @cindex @code{hy} glyph, and @code{cflags}
9071 @cindex @code{em} glyph, and @code{cflags}
9072 Lines can be broken after the character (initially the character
9073 @samp{-} and the symbols @samp{\[hy]} and @samp{\[em]} have this property).
9075 @item 8
9076 @cindex overlapping characters
9077 @cindex characters, overlapping
9078 @cindex @code{ul} glyph, and @code{cflags}
9079 @cindex @code{rn} glyph, and @code{cflags}
9080 @cindex @code{ru} glyph, and @code{cflags}
9081 @cindex @code{radicalex} glyph, and @code{cflags}
9082 @cindex @code{sqrtex} glyph, and @code{cflags}
9083 The character overlaps horizontally if used as a horizontal line building
9084 element.  Initially the symbols @samp{\[ul]}, @samp{\[rn]}, @samp{\[ru]},
9085 @samp{\[radicalex]}, and @samp{\[sqrtex]} have this property.
9087 @item 16
9088 @cindex @code{br} glyph, and @code{cflags}
9089 The character overlaps vertically if used as vertical line building element.
9090 Initially symbol @samp{\[br]} has this property.
9092 @item 32
9093 @cindex transparent characters
9094 @cindex character, transparent
9095 @cindex @code{"}, at end of sentence
9096 @cindex @code{'}, at end of sentence
9097 @cindex @code{)}, at end of sentence
9098 @cindex @code{]}, at end of sentence
9099 @cindex @code{*}, at end of sentence
9100 @cindex @code{dg} glyph, at end of sentence
9101 @cindex @code{rq} glyph, at end of sentence
9102 An end-of-sentence character followed by any number of characters with
9103 this property is treated as the end of a sentence if followed by a
9104 newline or two spaces; in other words the character is
9105 @dfn{transparent} for the purposes of end-of-sentence recognition --
9106 this is the same as having a zero space factor in @TeX{} (initially
9107 characters @samp{"')]*} and the symbols @samp{\[dg]} and @samp{\[rq]} have
9108 this property).
9109 @end table
9110 @endDefreq
9112 @DefreqList {char, g [@Var{string}]}
9113 @DefreqItem {fchar, g [@Var{string}]}
9114 @DefreqItem {fschar, f g [@Var{string}]}
9115 @DefreqListEnd {schar, g [@Var{string}]}
9116 @cindex defining character (@code{char})
9117 @cindex defining fallback character (@code{fchar}, @code{fschar}, @code{schar})
9118 @cindex character, defining (@code{char})
9119 @cindex character, defining fallback (@code{fchar}, @code{fschar}, @code{schar})
9120 @cindex fallback character, defining (@code{fchar}, @code{fschar}, @code{schar})
9121 @cindex creating new characters (@code{char})
9122 @cindex defining symbol (@code{char})
9123 @cindex symbol, defining (@code{char})
9124 @cindex defining glyph (@code{char})
9125 @cindex glyph, defining (@code{char})
9126 @cindex escape character, while defining glyph
9127 @cindex character, escape, while defining glyph
9128 @cindex @code{tr} request, and glyph definitions
9129 @cindex @code{cp} request, and glyph definitions
9130 @cindex @code{rc} request, and glyph definitions
9131 @cindex @code{lc} request, and glyph definitions
9132 @cindex @code{\l}, and glyph definitions
9133 @cindex @code{\L}, and glyph definitions
9134 @cindex @code{\&}, and glyph definitions
9135 @cindex @code{\e}, and glyph definitions
9136 @cindex @code{hcode} request, and glyph definitions
9137 Define a new glyph@tie{}@var{g} to be @var{string} (which can be
9138 empty).@footnote{@code{char} is a misnomer since an output glyph is
9139 defined.}  Every time glyph@tie{}@var{g} needs to be printed,
9140 @var{string} is processed in a temporary environment and the result is
9141 wrapped up into a single object.  Compatibility mode is turned off and
9142 the escape character is set to @samp{\} while @var{string} is being
9143 processed.  Any emboldening, constant spacing or track kerning is
9144 applied to this object rather than to individual characters in
9145 @var{string}.
9147 A glyph defined by these requests can be used just
9148 like a normal glyph provided by the output device.  In particular,
9149 other characters can be translated to it with the @code{tr} or
9150 @code{trin} requests; it can be made the leader character by the
9151 @code{lc} request; repeated patterns can be drawn with the glyph
9152 using the @code{\l} and @code{\L} escape sequences; words containing
9153 the glyph can be hyphenated correctly if the @code{hcode} request
9154 is used to give the glyph's symbol a hyphenation code.
9156 There is a special anti-recursion feature: Use of @code{g} within
9157 the glyph's definition is handled like normal characters and symbols
9158 not defined with @code{char}.
9160 Note that the @code{tr} and @code{trin} requests take precedence if
9161 @code{char} accesses the same symbol.
9163 @Example
9164 .tr XY
9166     @result{} Y
9167 .char X Z
9169     @result{} Y
9170 .tr XX
9172     @result{} Z
9173 @endExample
9175 The @code{fchar} request defines a fallback glyph:
9176 @code{gtroff} only checks for glyphs defined with @code{fchar}
9177 if it cannot find the glyph in the current font.
9178 @code{gtroff} carries out this test before checking special fonts.
9180 @code{fschar} defines a fallback glyph for font@tie{}@var{f}: @code{gtroff}
9181 checks for glyphs defined with @code{fschar} after the list of fonts
9182 declared as font-specific special fonts with the @code{fspecial} request,
9183 but before the list of fonts declared as global special fonts with the
9184 @code{special} request.
9186 Finally, the @code{schar} request defines a global fallback glyph:
9187 @code{gtroff} checks for glyphs defined with @code{schar} after the list
9188 of fonts declared as global special fonts with the @code{special} request,
9189 but before the already mounted special fonts.
9191 @xref{Using Symbols}, for a detailed description of the glyph
9192 searching mechanism in @code{gtroff}.
9193 @endDefreq
9195 @DefreqList {rchar, c1 c2 @dots{}}
9196 @DefreqListEnd {rfschar, f c1 c2 @dots{}}
9197 @cindex removing glyph definition (@code{rchar}, @code{rfschar})
9198 @cindex glyph, removing definition (@code{rchar}, @code{rfschar})
9199 @cindex fallback glyph, removing definition (@code{rchar}, @code{rfschar})
9200 Remove the definitions of glyphs @var{c1}, @var{c2},@tie{}@enddots{}
9201 This undoes the effect of a @code{char}, @code{fchar}, or
9202 @code{schar} request.
9204 It is possible to omit the whitespace between arguments.
9206 The request @code{rfschar} removes glyph definitions defined with
9207 @code{fschar} for glyph@tie{}f.
9208 @endDefreq
9210 @xref{Special Characters}.
9212 @c ---------------------------------------------------------------------
9214 @node Special Fonts, Artificial Fonts, Using Symbols, Fonts and Symbols
9215 @subsection Special Fonts
9216 @cindex special fonts
9217 @cindex fonts, special
9219 Special fonts are those that @code{gtroff} searches
9220 when it cannot find the requested glyph in the current font.
9221 The Symbol font is usually a special font.
9223 @code{gtroff} provides the following two requests to add more special
9224 fonts.  @xref{Using Symbols}, for a detailed description of the glyph
9225 searching mechanism in @code{gtroff}.
9227 Usually, only non-TTY devices have special fonts.
9229 @DefreqList {special, [@Var{s1} @Var{s2} @dots{}]}
9230 @DefreqListEnd {fspecial, f [@Var{s1} @Var{s2} @dots{}]}
9231 @kindex fonts
9232 @pindex DESC
9233 Use the @code{special} request to define special fonts.  Initially, this
9234 list is empty.
9236 Use the @code{fspecial} request to designate special fonts only when
9237 font@tie{}@var{f} is active.  Initially, this list is empty.
9239 Previous calls to @code{special} or @code{fspecial} are overwritten;
9240 without arguments, the particular list of special fonts is set to empty.
9241 Special fonts are searched in the order they appear as arguments.
9243 All fonts which appear in a call to @code{special} or @code{fspecial} are
9244 loaded.
9246 @xref{Using Symbols}, for the exact search order of glyphs.
9247 @endDefreq
9249 @c ---------------------------------------------------------------------
9251 @node Artificial Fonts, Ligatures and Kerning, Special Fonts, Fonts and Symbols
9252 @subsection Artificial Fonts
9253 @cindex artificial fonts
9254 @cindex fonts, artificial
9256 There are a number of requests and escapes for artificially creating
9257 fonts.  These are largely vestiges of the days when output devices
9258 did not have a wide variety of fonts, and when @code{nroff} and
9259 @code{troff} were separate programs.  Most of them are no longer
9260 necessary in GNU @code{troff}.  Nevertheless, they are supported.
9262 @DefescList {\\H, ', height, '}
9263 @DefescItem {\\H, ', @t{+}height, '}
9264 @DefescItem {\\H, ', @t{-}height, '}
9265 @DefregListEnd {.height}
9266 @cindex changing the font height (@code{\H})
9267 @cindex font height, changing (@code{\H})
9268 @cindex height, font, changing (@code{\H})
9269 Change (increment, decrement) the height of the current font, but not
9270 the width.  If @var{height} is zero, restore the original height.
9271 Default scaling indicator is @samp{z}.
9273 The read-only number register @code{.height} contains the font height as
9274 set by @code{\H}.
9276 Currently, only the @option{-Tps} device supports this feature.
9278 Note that @code{\H} doesn't produce an input token in @code{gtroff}.
9279 As a consequence, it can be used in requests like @code{mc} (which
9280 expects a single character as an argument) to change the font on
9281 the fly:
9283 @Example
9284 .mc \H'+5z'x\H'0'
9285 @endExample
9287 In compatibility mode, @code{gtroff} behaves differently:  If an
9288 increment or decrement is used, it is always taken relative to the
9289 current point size and not relative to the previously selected font
9290 height.  Thus,
9292 @Example
9293 .cp 1
9294 \H'+5'test \H'+5'test
9295 @endExample
9297 @noindent
9298 prints the word @samp{test} twice with the same font height (five
9299 points larger than the current font size).
9300 @endDefesc
9302 @DefescList {\\S, ', slant, '}
9303 @DefregListEnd {.slant}
9304 @cindex changing the font slant (@code{\S})
9305 @cindex font slant, changing (@code{\S})
9306 @cindex slant, font, changing (@code{\S})
9307 Slant the current font by @var{slant} degrees.  Positive values slant
9308 to the right.  Only integer values are possible.
9310 The read-only number register @code{.slant} contains the font slant as
9311 set by @code{\S}.
9313 Currently, only the @option{-Tps} device supports this feature.
9315 Note that @code{\S} doesn't produce an input token in @code{gtroff}.
9316 As a consequence, it can be used in requests like @code{mc} (which
9317 expects a single character as an argument) to change the font on
9318 the fly:
9320 @Example
9321 .mc \S'20'x\S'0'
9322 @endExample
9324 This request is incorrectly documented in the original @acronym{UNIX}
9325 troff manual; the slant is always set to an absolute value.
9326 @endDefesc
9328 @Defreq {ul, [@Var{lines}]}
9329 @cindex underlining (@code{ul})
9330 The @code{ul} request normally underlines subsequent lines if a TTY
9331 output device is used.  Otherwise, the lines are printed in italics
9332 (only the term `underlined' is used in the following).  The single
9333 argument is the number of input lines to be underlined; with no
9334 argument, the next line is underlined.  If @var{lines} is zero or
9335 negative, stop the effects of @code{ul} (if it was active).  Requests
9336 and empty lines do not count for computing the number of underlined
9337 input lines, even if they produce some output like @code{tl}.  Lines
9338 inserted by macros (e.g.@: invoked by a trap) do count.
9340 At the beginning of @code{ul}, the current font is stored and the
9341 underline font is activated.  Within the span of a @code{ul} request,
9342 it is possible to change fonts, but after the last line affected by
9343 @code{ul} the saved font is restored.
9345 This number of lines still to be underlined is associated with the
9346 current environment (@pxref{Environments}).  The underline font can be
9347 changed with the @code{uf} request.
9349 @c XXX @xref should be changed to grotty
9351 @c @xref{Troff and Nroff Mode}, for a discussion how underlining is
9352 @c implemented in for TTY output devices, and which problems can arise.
9354 The @code{ul} request does not underline spaces.
9355 @endDefreq
9357 @Defreq {cu, [@Var{lines}]}
9358 @cindex continuous underlining (@code{cu})
9359 @cindex underlining, continuous (@code{cu})
9360 The @code{cu} request is similar to @code{ul} but underlines spaces as
9361 well (if a TTY output device is used).
9362 @endDefreq
9364 @Defreq {uf, font}
9365 @cindex underline font (@code{uf})
9366 @cindex font for underlining (@code{uf})
9367 Set the underline font (globally) used by @code{ul} and @code{cu}.  By
9368 default, this is the font at position@tie{}2.  @var{font} can be either
9369 a non-negative font position or the name of a font.
9370 @endDefreq
9372 @DefreqList {bd, font [@Var{offset}]}
9373 @DefreqItem {bd, font1 font2 [@Var{offset}]}
9374 @DefregListEnd {.b}
9375 @cindex imitating bold face (@code{bd})
9376 @cindex bold face, imitating (@code{bd})
9377 Artificially create a bold font by printing each glyph twice,
9378 slightly offset.
9380 Two syntax forms are available.
9382 @itemize @bullet
9383 @item
9384 Imitate a bold font unconditionally.  The first argument specifies the
9385 font to embolden, and the second is the number of basic units, minus
9386 one, by which the two glyphs are offset.  If the second argument is
9387 missing, emboldening is turned off.
9389 @var{font} can be either a non-negative font position or the name of a
9390 font.
9392 @var{offset} is available in the @code{.b} read-only register if a
9393 special font is active; in the @code{bd} request, its default unit is
9394 @samp{u}.
9396 @cindex @code{fspecial} request, and imitating bold
9397 @kindex special
9398 @cindex embolding of special fonts
9399 @cindex special fonts, emboldening
9400 @item
9401 Imitate a bold form conditionally.  Embolden @var{font1} by
9402 @var{offset} only if font @var{font2} is the current font.  This
9403 command can be issued repeatedly to set up different emboldening
9404 values for different current fonts.  If the second argument is
9405 missing, emboldening is turned off for this particular current font.
9407 This affects special fonts only (either set up with the @code{special}
9408 command in font files or with the @code{fspecial} request).
9409 @end itemize
9410 @endDefreq
9412 @Defreq {cs, font [@Var{width} [@Var{em-size}]]}
9413 @cindex constant glyph space mode (@code{cs})
9414 @cindex mode for constant glyph space (@code{cs})
9415 @cindex glyph, constant space
9416 @cindex @code{ps} request, and constant glyph space mode
9417 Switch to and from @dfn{constant glyph space mode}.  If activated, the
9418 width of every glyph is @math{@var{width}/36} ems.  The em size is
9419 given absolutely by @var{em-size}; if this argument is missing, the em
9420 value is taken from the current font size (as set with the @code{ps}
9421 request) when the font is effectively in use.  Without second and
9422 third argument, constant glyph space mode is deactivated.
9424 Default scaling indicator for @var{em-size} is @samp{z}; @var{width} is
9425 an integer.
9426 @endDefreq
9428 @c ---------------------------------------------------------------------
9430 @node Ligatures and Kerning,  , Artificial Fonts, Fonts and Symbols
9431 @subsection Ligatures and Kerning
9432 @cindex ligatures and kerning
9433 @cindex kerning and ligatures
9435 Ligatures are groups of characters that are run together, i.e, producing
9436 a single glyph.  For example, the letters `f' and `i' can form a
9437 ligature `fi' as in the word `file'.  This produces a cleaner look
9438 (albeit subtle) to the printed output.  Usually, ligatures are not
9439 available in fonts for TTY output devices.
9441 Most @sc{PostScript} fonts support the fi and fl ligatures.  The C/A/T
9442 typesetter that was the target of @acronym{AT&T} @code{troff} also
9443 supported `ff', `ffi', and `ffl' ligatures.  Advanced typesetters or
9444 `expert' fonts may include ligatures for `ft' and `ct', although GNU
9445 @code{troff} does not support these (yet).
9447 Only the current font is checked for ligatures and kerns; neither special
9448 fonts nor entities defined with the @code{char} request (and its siblings)
9449 are taken into account.
9451 @DefreqList {lg, [@Var{flag}]}
9452 @DefregListEnd {.lg}
9453 @cindex activating ligatures (@code{lg})
9454 @cindex ligatures, activating (@code{lg})
9455 @cindex ligatures enabled register (@code{.lg})
9456 Switch the ligature mechanism on or off; if the parameter is non-zero
9457 or missing, ligatures are enabled, otherwise disabled.  Default is on.
9458 The current ligature mode can be found in the read-only number register
9459 @code{.lg} (set to 1 or@tie{}2 if ligatures are enabled, 0@tie{}otherwise).
9461 Setting the ligature mode to@tie{}2 enables the two-character ligatures
9462 (fi, fl, and ff) and disables the three-character ligatures (ffi and
9463 ffl).
9464 @endDefreq
9466 @dfn{Pairwise kerning} is another subtle typesetting mechanism that
9467 modifies the distance between a glyph pair to improve readability.
9468 In most cases (but not always) the distance is decreased.
9469 @ifnotinfo
9470 For example, compare the combination of the letters `V' and `A'.  With
9471 kerning, `VA' is printed.  Without kerning it appears as `V@w{}A'.
9472 @end ifnotinfo
9473 Typewriter-like fonts and fonts for terminals where all glyphs
9474 have the same width don't use kerning.
9476 @DefreqList {kern, [@Var{flag}]}
9477 @DefregListEnd {.kern}
9478 @cindex activating kerning (@code{kern})
9479 @cindex kerning, activating (@code{kern})
9480 @cindex kerning enabled register (@code{.kern})
9481 Switch kerning on or off.  If the parameter is non-zero or missing,
9482 enable pairwise kerning, otherwise disable it.  The read-only number
9483 register @code{.kern} is set to@tie{}1 if pairwise kerning is enabled,
9484 0@tie{}otherwise.
9486 @cindex zero width space character (@code{\&})
9487 @cindex character, zero width space (@code{\&})
9488 @cindex space character, zero width (@code{\&})
9489 If the font description file contains pairwise kerning information,
9490 glyphs from that font are kerned.  Kerning between two glyphs
9491 can be inhibited by placing @code{\&} between them: @samp{V\&A}.
9493 @xref{Font File Format}.
9494 @endDefreq
9496 @cindex track kerning
9497 @cindex kerning, track
9498 @dfn{Track kerning} expands or reduces the space between glyphs.
9499 This can be handy, for example, if you need to squeeze a long word
9500 onto a single line or spread some text to fill a narrow column.  It
9501 must be used with great care since it is usually considered bad
9502 typography if the reader notices the effect.
9504 @Defreq {tkf, f s1 n1 s2 n2}
9505 @cindex activating track kerning (@code{tkf})
9506 @cindex track kerning, activating (@code{tkf})
9507 Enable track kerning for font@tie{}@var{f}.  If the current font
9508 is@tie{}@var{f} the width of every glyph is increased by an amount
9509 between @var{n1} and @var{n2} (@var{n1}, @var{n2} can be negative); if
9510 the current point size is less than or equal to @var{s1} the width is
9511 increased by @var{n1}; if it is greater than or equal to @var{s2} the
9512 width is increased by @var{n2}; if the point size is greater than or
9513 equal to @var{s1} and less than or equal to @var{s2} the increase in
9514 width is a linear function of the point size.
9516 The default scaling indicator is @samp{z} for @var{s1} and @var{s2},
9517 @samp{p} for @var{n1} and @var{n2}.
9519 Note that the track kerning amount is added even to the rightmost glyph
9520 in a line; for large values it is thus recommended to increase the line
9521 length by the same amount to compensate it.
9522 @endDefreq
9524 Sometimes, when typesetting letters of different fonts, more or less
9525 space at such boundaries are needed.  There are two escapes to help
9526 with this.
9528 @Defesc {\\/, , , }
9529 @cindex italic correction (@code{\/})
9530 @cindex correction, italic (@code{\/})
9531 @cindex correction between italic and roman glyph (@code{\/}, @code{\,})
9532 @cindex roman glyph, correction after italic glyph (@code{\/})
9533 @cindex italic glyph, correction before roman glyph (@code{\/})
9534 @cindex glyph, italic correction (@code{\/})
9535 Increase the width of the preceding glyph so that the spacing
9536 between that glyph and the following glyph is correct if the
9537 following glyph is a roman glyph.  For example, if an
9538 italic@tie{}@code{f} is immediately followed by a roman right
9539 parenthesis, then in many fonts the top right portion of the@tie{}@code{f}
9540 overlaps the top left of the right parenthesis.  Use this escape
9541 sequence whenever an italic glyph is immediately followed by a
9542 roman glyph without any intervening space.  This small amount of
9543 space is also called @dfn{italic correction}.
9545 @iftex
9546 @c can't use @Example...@endExample here
9547 @example
9548 @group
9549 \f[I]f\f[R])
9550     @result{} {@it f}@r{)}
9551 \f[I]f\/\f[R])
9552     @result{} @i{f}@r{)}
9553 @end group
9554 @end example
9555 @end iftex
9556 @endDefesc
9558 @Defesc {\\\,, , , }
9559 @cindex left italic correction (@code{\,})
9560 @cindex correction, left italic (@code{\,})
9561 @cindex glyph, left italic correction (@code{\,})
9562 @cindex roman glyph, correction before italic glyph (@code{\,})
9563 @cindex italic glyph, correction after roman glyph (@code{\,})
9564 Modify the spacing of the following glyph so that the spacing
9565 between that glyph and the preceding glyph is correct if the
9566 preceding glyph is a roman glyph.  Use this escape sequence
9567 whenever a roman glyph is immediately followed by an italic
9568 glyph without any intervening space.  In analogy to above, this
9569 space could be called @dfn{left italic correction}, but this term
9570 isn't used widely.
9572 @iftex
9573 @c can't use @Example...@endExample here
9574 @example
9575 @group
9576 q\f[I]f
9577     @result{} @r{q}@i{f}
9578 q\,\f[I]f
9579     @result{} @r{q}@math{@ptexcomma}@i{f}
9580 @end group
9581 @end example
9582 @end iftex
9583 @endDefesc
9585 @Defesc {\\&, , , }
9586 Insert a zero-width character, which is invisible.  Its intended use
9587 is to stop interaction of a character with its surrounding.
9589 @itemize @bullet
9590 @item
9591 It prevents the insertion of extra space after an end-of-sentence
9592 character.
9594 @Example
9595 Test.
9596 Test.
9597     @result{} Test.  Test.
9598 Test.\&
9599 Test.
9600     @result{} Test. Test.
9601 @endExample
9603 @item
9604 It prevents interpretation of a control character at the beginning of
9605 an input line.
9607 @Example
9608 .Test
9609     @result{} warning: `Test' not defined
9610 \&.Test
9611     @result{} .Test
9612 @endExample
9614 @item
9615 It prevents kerning between two glyphs.
9617 @ifnotinfo
9618 @Example
9620     @result{} @r{VA}
9621 V\&A
9622     @result{} @r{V@w{}A}
9623 @endExample
9624 @end ifnotinfo
9626 @item
9627 It is needed to map an arbitrary character to nothing in the @code{tr}
9628 request (@pxref{Character Translations}).
9629 @end itemize
9630 @endDefesc
9632 @Defesc {\\), , , }
9633 This escape is similar to @code{\&} except that it behaves like a
9634 character declared with the @code{cflags} request to be transparent
9635 for the purposes of an end-of-sentence character.
9637 Its main usage is in macro definitions to protect against arguments
9638 starting with a control character.
9640 @Example
9641 .de xxx
9642 \)\\$1
9644 .de yyy
9645 \&\\$1
9647 This is a test.\c
9648 .xxx '
9649 This is a test.
9650     @result{}This is a test.'  This is a test.
9651 This is a test.\c
9652 .yyy '
9653 This is a test.
9654     @result{}This is a test.' This is a test.
9655 @endExample
9656 @endDefesc
9659 @c =====================================================================
9661 @node Sizes, Strings, Fonts and Symbols, gtroff Reference
9662 @section Sizes
9663 @cindex sizes
9665 @cindex baseline
9666 @cindex type size
9667 @cindex size of type
9668 @cindex vertical spacing
9669 @cindex spacing, vertical
9670 @code{gtroff} uses two dimensions with each line of text, type size
9671 and vertical spacing.  The @dfn{type size} is approximately the height
9672 of the tallest glyph.@footnote{This is usually the parenthesis.
9673 Note that in most cases the real dimensions of the glyphs in a font
9674 are @emph{not} related to its type size!  For example, the standard
9675 @sc{PostScript} font families `Times Roman', `Helvetica', and
9676 `Courier' can't be used together at 10@dmn{pt}; to get acceptable
9677 output, the size of `Helvetica' has to be reduced by one point, and
9678 the size of `Courier' must be increased by one point.}  @dfn{Vertical
9679 spacing} is the amount of space @code{gtroff} allows for a line of
9680 text; normally, this is about 20%@tie{}larger than the current type
9681 size.  Ratios smaller than this can result in hard-to-read text;
9682 larger than this, it spreads the text out more vertically (useful for
9683 term papers).  By default, @code{gtroff} uses 10@tie{}point type on
9684 12@tie{}point spacing.
9686 @cindex leading
9687 The difference between type size and vertical spacing is known, by
9688 typesetters, as @dfn{leading} (this is pronounced `ledding').
9690 @menu
9691 * Changing Type Sizes::
9692 * Fractional Type Sizes::
9693 @end menu
9695 @c ---------------------------------------------------------------------
9697 @node Changing Type Sizes, Fractional Type Sizes, Sizes, Sizes
9698 @subsection Changing Type Sizes
9700 @DefreqList {ps, [@Var{size}]}
9701 @DefreqItem {ps, @t{+}@Var{size}}
9702 @DefreqItem {ps, @t{-}@Var{size}}
9703 @DefescItem {\\s, , size, }
9704 @DefregListEnd {.s}
9705 @cindex changing type sizes (@code{ps}, @code{\s})
9706 @cindex type sizes, changing (@code{ps}, @code{\s})
9707 @cindex point sizes, changing (@code{ps}, @code{\s})
9708 Use the @code{ps} request or the @code{\s} escape to change (increase,
9709 decrease) the type size (in points).  Specify @var{size} as either an
9710 absolute point size, or as a relative change from the current size.
9711 The size@tie{}0, or no argument, goes back to the previous size.
9713 Default scaling indicator of @code{size} is @samp{z}.  If @code{size}
9714 is zero or negative, it is set to 1@dmn{u}.
9716 @cindex type size registers (@code{.s}, @code{.ps})
9717 @cindex point size registers (@code{.s}, @code{.ps})
9718 The read-only number register @code{.s} returns the point size in
9719 points as a decimal fraction.  This is a string.  To get the point
9720 size in scaled points, use the @code{.ps} register instead.
9722 @code{.s} is associated with the current environment
9723 (@pxref{Environments}).
9725 @Example
9726 snap, snap,
9727 .ps +2
9728 grin, grin,
9729 .ps +2
9730 wink, wink, \s+2nudge, nudge,\s+8 say no more!
9731 .ps 10
9732 @endExample
9734 The @code{\s} escape may be called in a variety of ways.  Much like
9735 other escapes there must be a way to determine where the argument ends
9736 and the text begins.  Any of the following forms are valid:
9738 @table @code
9739 @item \s@var{n}
9740 Set the point size to @var{n}@tie{}points.  @var{n}@tie{}must be either
9741 0 or in the range 4 to@tie{}39.
9743 @item \s+@var{n}
9744 @itemx \s-@var{n}
9745 Increase or decrease the point size by @var{n}@tie{}points.
9746 @var{n}@tie{}must be exactly one digit.
9748 @item \s(@var{nn}
9749 Set the point size to @var{nn}@tie{}points.  @var{nn} must be exactly
9750 two digits.
9752 @item \s+(@var{nn}
9753 @itemx \s-(@var{nn}
9754 @itemx \s(+@var{nn}
9755 @itemx \s(-@var{nn}
9756 Increase or decrease the point size by @var{nn}@tie{}points.  @var{nn}
9757 must be exactly two digits.
9758 @end table
9760 Note that @code{\s} doesn't produce an input token in @code{gtroff}.
9761 As a consequence, it can be used in requests like @code{mc} (which
9762 expects a single character as an argument) to change the font on
9763 the fly:
9765 @Example
9766 .mc \s[20]x\s[0]
9767 @endExample
9769 @xref{Fractional Type Sizes}, for yet another syntactical form of
9770 using the @code{\s} escape.
9771 @endDefreq
9773 @Defreq {sizes, s1 s2 @dots{} sn [0]}
9774 Some devices may only have certain permissible sizes, in which case
9775 @code{gtroff} rounds to the nearest permissible size.
9776 The @file{DESC} file specifies which sizes are permissible for the device.
9778 Use the @code{sizes} request to change the permissible sizes
9779 for the current output device.
9780 Arguments are in scaled points;
9781 the @code{sizescale} line in the
9782 @file{DESC} file for the output device
9783 provides the scaling factor.
9784 For example, if the scaling factor is 1000,
9785 then the value 12000 is 12@tie{}points.
9787 Each argument can be a single point size (such as @samp{12000}),
9788 or a range of sizes (such as @samp{4000-72000}).
9789 You can optionally end the list with a zero.
9790 @endDefreq
9792 @DefreqList {vs, [@Var{space}]}
9793 @DefreqItem {vs, @t{+}@Var{space}}
9794 @DefreqItem {vs, @t{-}@Var{space}}
9795 @DefregListEnd {.v}
9796 @cindex changing vertical line spacing (@code{vs})
9797 @cindex vertical line spacing, changing (@code{vs})
9798 @cindex vertical line spacing register (@code{.v})
9799 Change (increase, decrease) the vertical spacing by @var{space}.  The
9800 default scaling indicator is @samp{p}.
9802 If @code{vs} is called without an argument, the vertical spacing is
9803 reset to the previous value before the last call to @code{vs}.
9805 @cindex @code{.V} register, and @code{vs}
9806 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
9807 negative; the vertical spacing is then set to smallest positive value,
9808 the vertical resolution (as given in the @code{.V} register).
9810 Note that @w{@samp{.vs 0}} isn't saved in a diversion since it doesn't
9811 result in a vertical motion.  You explicitly have to repeat this command
9812 before inserting the diversion.
9814 The read-only number register @code{.v} contains the current vertical
9815 spacing; it is associated with the current environment
9816 (@pxref{Environments}).
9817 @endDefreq
9819 @cindex vertical line spacing, effective value
9820 The effective vertical line spacing consists of four components.  Breaking
9821 a line causes the following actions (in the given order).
9823 @itemize @bullet
9824 @item
9825 @cindex extra pre-vertical line space (@code{\x})
9826 @cindex line space, extra pre-vertical (@code{\x})
9827 Move the current point vertically by the @dfn{extra pre-vertical line
9828 space}.  This is the minimum value of all @code{\x} escapes with a
9829 negative argument in the current output line.
9831 @item
9832 Move the current point vertically by the vertical line spacing as set with
9833 the @code{vs} request.
9835 @item
9836 Output the current line.
9838 @item
9839 @cindex extra post-vertical line space (@code{\x})
9840 @cindex line space, extra post-vertical (@code{\x})
9841 Move the current point vertically by the @dfn{extra post-vertical line
9842 space}.  This is the maximum value of all @code{\x} escapes with a
9843 positive argument in the line which has just been output.
9845 @item
9846 @cindex post-vertical line spacing
9847 @cindex line spacing, post-vertical (@code{pvs})
9848 Move the current point vertically by the @dfn{post-vertical line spacing}
9849 as set with the @code{pvs} request.
9850 @end itemize
9852 @cindex double-spacing (@code{vs}, @code{pvs})
9853 It is usually better to use @code{vs} or @code{pvs} instead of @code{ls}
9854 to produce double-spaced documents: @code{vs} and @code{pvs} have a finer
9855 granularity for the inserted vertical space compared to @code{ls};
9856 furthermore, certain preprocessors assume single-spacing.
9858 @xref{Manipulating Spacing}, for more details on the @code{\x} escape
9859 and the @code{ls} request.
9861 @DefreqList {pvs, [@Var{space}]}
9862 @DefreqItem {pvs, @t{+}@Var{space}}
9863 @DefreqItem {pvs, @t{-}@Var{space}}
9864 @DefregListEnd {.pvs}
9865 @cindex @code{ls} request, alternative to (@code{pvs})
9866 @cindex post-vertical line spacing, changing (@code{pvs})
9867 @cindex post-vertical line spacing register (@code{.pvs})
9868 Change (increase, decrease) the post-vertical spacing by
9869 @var{space}.  The default scaling indicator is @samp{p}.
9871 If @code{pvs} is called without an argument, the post-vertical spacing is
9872 reset to the previous value before the last call to @code{pvs}.
9874 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
9875 zero or negative; the vertical spacing is then set to zero.
9877 The read-only number register @code{.pvs} contains the current
9878 post-vertical spacing; it is associated with the current environment
9879 (@pxref{Environments}).
9880 @endDefreq
9882 @c ---------------------------------------------------------------------
9884 @node Fractional Type Sizes,  , Changing Type Sizes, Sizes
9885 @subsection Fractional Type Sizes
9886 @cindex fractional type sizes
9887 @cindex fractional point sizes
9888 @cindex type sizes, fractional
9889 @cindex point sizes, fractional
9890 @cindex sizes, fractional
9892 @cindex @code{s} unit
9893 @cindex unit, @code{s}
9894 @cindex @code{z} unit
9895 @cindex unit, @code{z}
9896 @cindex @code{ps} request, with fractional type sizes
9897 @cindex @code{cs} request, with fractional type sizes
9898 @cindex @code{tkf} request, with fractional type sizes
9899 @cindex @code{\H}, with fractional type sizes
9900 @cindex @code{\s}, with fractional type sizes
9901 A @dfn{scaled point} is equal to @math{1/@var{sizescale}} points,
9902 where @var{sizescale} is specified in the @file{DESC} file (1@tie{}by
9903 default).  There is a new scale indicator @samp{z} which has the
9904 effect of multiplying by @var{sizescale}.  Requests and escape
9905 sequences in @code{gtroff} interpret arguments that represent a point
9906 size as being in units of scaled points, but they evaluate each such
9907 argument using a default scale indicator of @samp{z}.  Arguments
9908 treated in this way are the argument to the @code{ps} request, the
9909 third argument to the @code{cs} request, the second and fourth
9910 arguments to the @code{tkf} request, the argument to the @code{\H}
9911 escape sequence, and those variants of the @code{\s} escape sequence
9912 that take a numeric expression as their argument (see below).
9914 For example, suppose @var{sizescale} is@tie{}1000; then a scaled point
9915 is equivalent to a millipoint; the request @w{@samp{.ps 10.25}} is
9916 equivalent to @w{@samp{.ps 10.25z}} and thus sets the point size to
9917 10250@tie{}scaled points, which is equal to 10.25@tie{}points.
9919 @code{gtroff} disallows the use of the @samp{z} scale indicator in
9920 instances where it would make no sense, such as a numeric
9921 expression whose default scale indicator was neither @samp{u} nor
9922 @samp{z}.  Similarly it would make
9923 no sense to use a scaling indicator other than @samp{z} or @samp{u} in a
9924 numeric expression whose default scale indicator was @samp{z}, and so
9925 @code{gtroff} disallows this as well.
9927 There is also new scale indicator @samp{s} which multiplies by the
9928 number of units in a scaled point.  So, for example, @samp{\n[.ps]s} is
9929 equal to @samp{1m}.  Be sure not to confuse the @samp{s} and @samp{z}
9930 scale indicators.
9932 @Defreg {.ps}
9933 A read-only number register returning the point size in scaled points.
9935 @code{.ps} is associated with the current environment
9936 (@pxref{Environments}).
9937 @endDefreg
9939 @DefregList {.psr}
9940 @DefregListEnd {.sr}
9941 @cindex last-requested point size registers (@code{.psr}, @code{.sr})
9942 @cindex point size registers, last-requested (@code{.psr}, @code{.sr})
9943 @cindex @code{.ps} register, in comparison with @code{.psr}
9944 @cindex @code{.s} register, in comparison with @code{.sr}
9945 The last-requested point size in scaled points is contained in the
9946 @code{.psr} read-only number register.  The last requested point size
9947 in points as a decimal fraction can be found in @code{.sr}.  This is a
9948 string-valued read-only number register.
9950 Note that the requested point sizes are device-independent, whereas
9951 the values returned by the @code{.ps} and @code{.s} registers are not.
9952 For example, if a point size of 11@dmn{pt} is requested, and a
9953 @code{sizes} request (or a @code{sizescale} line in a @file{DESC} file)
9954 specifies 10.95@dmn{pt} instead, this value is actually used.
9956 Both registers are associated with the current environment
9957 (@pxref{Environments}).
9958 @endDefreg
9960 The @code{\s} escape has the following syntax for working with
9961 fractional type sizes:
9963 @table @code
9964 @item \s[@var{n}]
9965 @itemx \s'@var{n}'
9966 Set the point size to @var{n}@tie{}scaled points; @var{n}@tie{}is a numeric
9967 expression with a default scale indicator of @samp{z}.
9969 @item \s[+@var{n}]
9970 @itemx \s[-@var{n}]
9971 @itemx \s+[@var{n}]
9972 @itemx \s-[@var{n}]
9973 @itemx \s'+@var{n}'
9974 @itemx \s'-@var{n}'
9975 @itemx \s+'@var{n}'
9976 @itemx \s-'@var{n}'
9977 Increase or or decrease the point size by @var{n}@tie{}scaled points;
9978 @var{n}@tie{}is a numeric expression with a default scale indicator of
9979 @samp{z}.
9980 @end table
9982 @xref{Font Files}.
9985 @c =====================================================================
9987 @node Strings, Conditionals and Loops, Sizes, gtroff Reference
9988 @section Strings
9989 @cindex strings
9991 @code{gtroff} has string variables, which are entirely for user
9992 convenience (i.e.@: there are no built-in strings exept @code{.T}, but
9993 even this is a read-write string variable).
9995 @DefreqList {ds, name [@Var{string}]}
9996 @DefreqItem {ds1, name [@Var{string}]}
9997 @DefescItem {\\*, , n, }
9998 @DefescItem {\\*, @lparen{}, nm, }
9999 @DefescListEnd {\\*, @lbrack{}, name arg1 arg2 @dots{}, @rbrack{}}
10000 @cindex string interpolation (@code{\*})
10001 @cindex string expansion (@code{\*})
10002 @cindex interpolation of strings (@code{\*})
10003 @cindex expansion of strings (@code{\*})
10004 @cindex string arguments
10005 @cindex arguments, of strings
10006 Define and access a string variable @var{name} (one-character
10007 name@tie{}@var{n}, two-character name @var{nm}).  If @var{name} already
10008 exists, @code{ds} overwrites the previous definition.  Only the syntax form
10009 using brackets can take arguments which are handled identically to
10010 macro arguments; the single exception is that a closing bracket as an
10011 argument must be enclosed in double quotes.  @xref{Request and Macro
10012 Arguments}, and @ref{Parameters}.
10014 Example:
10016 @Example
10017 .ds foo a \\$1 test
10019 This is \*[foo nice].
10020     @result{} This is a nice test.
10021 @endExample
10023 The @code{\*} escape @dfn{interpolates} (expands in-place) a
10024 previously-defined string variable.  To be more precise, the stored
10025 string is pushed onto the input stack which is then parsed by
10026 @code{gtroff}.  Similar to number registers, it is possible to nest
10027 strings, i.e. string variables can be called within string variables.
10029 If the string named by the @code{\*} escape does not exist, it is
10030 defined as empty, and a warning of type @samp{mac} is emitted (see
10031 @ref{Debugging}, for more details).
10033 @cindex comments, with @code{ds}
10034 @cindex @code{ds} request, and comments
10035 @strong{Caution:} Unlike other requests, the second argument to the
10036 @code{ds} request takes up the entire line including trailing spaces.
10037 This means that comments on a line with such a request can introduce
10038 unwanted space into a string.
10040 @Example
10041 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d \" UNIX trademark
10042 @endExample
10044 @noindent
10045 Instead the comment should be put on another line or have the comment
10046 escape adjacent with the end of the string.
10048 @Example
10049 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d\"  UNIX trademark
10050 @endExample
10052 @cindex trailing quotes
10053 @cindex quotes, trailing
10054 @cindex leading spaces with @code{ds}
10055 @cindex spaces with @code{ds}
10056 @cindex @code{ds} request, and leading spaces
10057 To produce leading space the string can be started with a double
10058 quote.  No trailing quote is needed; in fact, any trailing quote is
10059 included in your string.
10061 @Example
10062 .ds sign "           Yours in a white wine sauce,
10063 @endExample
10065 @cindex multi-line strings
10066 @cindex strings, multi-line
10067 @cindex newline character, in strings, escaping
10068 @cindex escaping newline characters, in strings
10069 Strings are not limited to a single line of text.  A string can span
10070 several lines by escaping the newlines with a backslash.  The
10071 resulting string is stored @emph{without} the newlines.
10073 @Example
10074 .ds foo lots and lots \
10075 of text are on these \
10076 next several lines
10077 @endExample
10079 It is not possible to have real newlines in a string.  To put a single
10080 double quote character into a string, use two consecutive double quote
10081 characters.
10083 The @code{ds1} request turns off compatibility mode
10084 while interpreting a string.  To be more precise, a @dfn{compatibility
10085 save} input token is inserted at the beginning of  the string, and a
10086 @dfn{compatibility restore} input token at the end.
10088 @Example
10089 .nr xxx 12345
10090 .ds aa The value of xxx is \\n[xxx].
10091 .ds1 bb The value of xxx ix \\n[xxx].
10093 .cp 1
10095 \*(aa
10096     @result{} warning: number register `[' not defined
10097     @result{} The value of xxx is 0xxx].
10098 \*(bb
10099     @result{} The value of xxx ix 12345.
10100 @endExample
10102 @cindex name space, common, of macros, diversions, and strings
10103 @cindex common name space of macros, diversions, and strings
10104 @cindex macros, shared name space with strings and diversions
10105 @cindex strings, shared name space with macros and diversions
10106 @cindex diversions, shared name space with macros and strings
10107 Strings, macros, and diversions (and boxes) share the same name space.
10108 Internally, even the same mechanism is used to store them.  This has
10109 some interesting consequences.  For example, it is possible to call a
10110 macro with string syntax and vice versa.
10112 @Example
10113 .de xxx
10114 a funny test.
10116 This is \*[xxx]
10117     @result{} This is a funny test.
10119 .ds yyy a funny test
10120 This is
10121 .yyy
10122     @result{} This is a funny test.
10123 @endExample
10125 Diversions and boxes can be also called with string syntax.
10127 Another consequence is that you can copy one-line diversions or boxes
10128 to a string.
10130 @Example
10131 .di xxx
10132 a \fItest\fR
10135 .ds yyy This is \*[xxx]\c
10136 \*[yyy].
10137     @result{} @r{This is a }@i{test}.
10138 @endExample
10140 @noindent
10141 As the previous example shows, it is possible to store formatted
10142 output in strings.  The @code{\c} escape prevents the insertion of an
10143 additional blank line in the output.
10145 Copying diversions longer than a single output line produces
10146 unexpected results.
10148 @Example
10149 .di xxx
10150 a funny
10152 test
10155 .ds yyy This is \*[xxx]\c
10156 \*[yyy].
10157     @result{} test This is a funny.
10158 @endExample
10160 Usually, it is not predictable whether a diversion contains one or
10161 more output lines, so this mechanism should be avoided.  With
10162 @acronym{UNIX} @code{troff}, this was the only solution to strip off a
10163 final newline from a diversion.  Another disadvantage is that the
10164 spaces in the copied string are already formatted, making them
10165 unstretchable.  This can cause ugly results.
10167 @cindex stripping final newline in diversions
10168 @cindex diversion, stripping final newline
10169 @cindex final newline, stripping in diversions
10170 @cindex newline, final, stripping in diversions
10171 @cindex horizontal space, unformatting
10172 @cindex space, horizontal, unformatting
10173 @cindex unformatting horizontal space
10174 A clean solution to this problem is available in GNU @code{troff},
10175 using the requests @code{chop} to remove the final newline of a
10176 diversion, and @code{unformat} to make the horizontal spaces
10177 stretchable again.
10179 @Example
10180 .box xxx
10181 a funny
10183 test
10185 .box
10186 .chop xxx
10187 .unformat xxx
10188 This is \*[xxx].
10189     @result{} This is a funny test.
10190 @endExample
10192 @xref{Gtroff Internals}, for more information.
10193 @endDefreq
10195 @DefreqList {as, name [@Var{string}]}
10196 @DefreqListEnd {as1, name [@Var{string}]}
10197 @cindex appending to a string (@code{as})
10198 @cindex string, appending (@code{as})
10199 The @code{as} request is similar to @code{ds} but appends @var{string}
10200 to the string stored as @var{name} instead of redefining it.  If
10201 @var{name} doesn't exist yet, it is created.
10203 @Example
10204 .as sign " with shallots, onions and garlic,
10205 @endExample
10207 The @code{as1} request is similar to @code{as}, but compatibility mode
10208 is switched off while the appended string is interpreted.  To be more
10209 precise, a @dfn{compatibility save} input token is inserted at the
10210 beginning of the appended string, and a @dfn{compatibility restore}
10211 input token at the end.
10212 @endDefreq
10214 Rudimentary string manipulation routines are given with the next two
10215 requests.
10217 @Defreq {substring, str n1 [@Var{n2}]}
10218 @cindex substring (@code{substring})
10219 Replace the string named @var{str} with the substring
10220 defined by the indices @var{n1} and@tie{}@var{n2}.  The first character
10221 in the string has index@tie{}0.  If @var{n2} is omitted, it is taken to
10222 be equal to the string's length.  If the index value @var{n1} or
10223 @var{n2} is negative, it is counted from the end of the
10224 string, going backwards: The last character has index@tie{}@minus{}1, the
10225 character before the last character has index@tie{}@minus{}2, etc.
10227 @Example
10228 .ds xxx abcdefgh
10229 .substring xxx 1 -4
10230 \*[xxx]
10231     @result{} bcde
10232 @endExample
10233 @endDefreq
10235 @Defreq {length, reg str}
10236 @cindex length of a string (@code{length})
10237 @cindex string, length of (@code{length})
10238 Compute the number of characters of @var{str} and return it in the
10239 number register @var{reg}.  If @var{reg} doesn't exist, it is created.
10240 @code{str} is read in copy mode.
10242 @Example
10243 .ds xxx abcd\h'3i'efgh
10244 .length yyy \*[xxx]
10245 \n[yyy]
10246     @result{} 14
10247 @endExample
10248 @endDefreq
10250 @Defreq {rn, xx yy}
10251 @cindex renaming request (@code{rn})
10252 @cindex request, renaming (@code{rn})
10253 @cindex renaming macro (@code{rn})
10254 @cindex macro, renaming (@code{rn})
10255 @cindex renaming string (@code{rn})
10256 @cindex string, renaming (@code{rn})
10257 @cindex renaming diversion (@code{rn})
10258 @cindex diversion, renaming (@code{rn})
10259 Rename the request, macro, diversion, or string @var{xx} to @var{yy}.
10260 @endDefreq
10262 @Defreq {rm, xx}
10263 @cindex removing request (@code{rm})
10264 @cindex request, removing (@code{rm})
10265 @cindex removing macro (@code{rm})
10266 @cindex macro, removing (@code{rm})
10267 @cindex removing string (@code{rm})
10268 @cindex string, removing (@code{rm})
10269 @cindex removing diversion (@code{rm})
10270 @cindex diversion, removing (@code{rm})
10271 Remove the request, macro, diversion, or string @var{xx}.  @code{gtroff}
10272 treats subsequent invocations as if the object had never been defined.
10273 @endDefreq
10275 @Defreq {als, new old}
10276 @cindex alias, string, creating (@code{als})
10277 @cindex alias, macro, creating (@code{als})
10278 @cindex alias, diversion, creating (@code{als})
10279 @cindex creating alias, for string (@code{als})
10280 @cindex creating alias, for macro (@code{als})
10281 @cindex creating alias, for diversion (@code{als})
10282 @cindex string, creating alias (@code{als})
10283 @cindex macro, creating alias (@code{als})
10284 @cindex diversion, creating alias (@code{als})
10285 Create an alias named @var{new} for the request, string, macro, or
10286 diversion object named @var{old}.  The new name and the old name are
10287 exactly equivalent (it is similar to a hard rather than a soft
10288 link). If @var{old} is undefined, @code{gtroff} generates a warning of
10289 type @samp{mac} and ignores the request.
10290 @endDefreq
10292 @Defreq {chop, xx}
10293 Remove (chop) the last character from the macro, string, or diversion
10294 named @var{xx}.  This is useful for removing the newline from the end
10295 of diversions that are to be interpolated as strings.  This command
10296 can be used repeatedly; see @ref{Gtroff Internals}, for details on
10297 nodes inserted additionally by @code{gtroff}.
10298 @endDefreq
10300 @xref{Identifiers}, and @ref{Comments}.
10303 @c =====================================================================
10305 @node Conditionals and Loops, Writing Macros, Strings, gtroff Reference
10306 @section Conditionals and Loops
10307 @cindex conditionals and loops
10308 @cindex loops and conditionals
10310 @menu
10311 * Operators in Conditionals::
10312 * if-else::
10313 * while::
10314 @end menu
10316 @c ---------------------------------------------------------------------
10318 @node Operators in Conditionals, if-else, Conditionals and Loops, Conditionals and Loops
10319 @subsection Operators in Conditionals
10321 @cindex @code{if} request, operators to use with
10322 @cindex @code{while} request, operators to use with
10323 In @code{if} and @code{while} requests, there are several more
10324 operators available:
10326 @table @code
10327 @item e
10328 @itemx o
10329 True if the current page is even or odd numbered (respectively).
10331 @item n
10332 True if the document is being processed in nroff mode (i.e., the
10333 @code{.nroff} command has been issued).
10335 @item t
10336 True if the document is being processed in troff mode (i.e., the
10337 @code{.troff} command has been issued).
10339 @item v
10340 Always false.  This condition is for compatibility with other
10341 @code{troff} versions only (identifying a @code{-Tversatec} device).
10343 @item '@var{xxx}'@var{yyy}'
10344 True if the string @var{xxx} is equal to the string @var{yyy}.  Other
10345 characters can be used in place of the single quotes; the same set of
10346 delimiters as for the @code{\D} escape is used (@pxref{Escapes}).
10347 @code{gtroff} formats the strings before being compared:
10349 @Example
10350 .ie "|"\fR|\fP" \
10351 true
10352 .el \
10353 false
10354     @result{} true
10355 @endExample
10357 @noindent
10358 The resulting motions, glyph sizes, and fonts have to
10359 match,@footnote{The created output nodes must be identical.
10360 @xref{Gtroff Internals}.} and not the individual motion, size, and
10361 font requests.  In the previous example, @samp{|} and @samp{\fR|\fP}
10362 both result in a roman @samp{|} glyph with the same point size and
10363 at the same location on the page, so the strings are equal.  If
10364 @samp{.ft@tie{}I} had been added before the @samp{.ie}, the result
10365 would be ``false'' because (the first) @samp{|} produces an italic
10366 @samp{|} rather than a roman one.
10368 @item r @var{xxx}
10369 True if there is a number register named @var{xxx}.
10371 @item d @var{xxx}
10372 True if there is a string, macro, diversion, or request named @var{xxx}.
10374 @item m @var{xxx}
10375 True if there is a color named @var{xxx}.
10377 @item c @var{g}
10378 True if there is a glyph @var{g} available@footnote{The name of this
10379 conditional operator is a misnomer since it tests names of output
10380 glyphs.}; @var{g} is either an @acronym{ASCII} character or a special
10381 character (@code{\(@var{gg}} or @code{\[@var{ggg}]}); the condition
10382 is also true if @var{g} has been defined by the @code{char} request.
10384 @item F @var{font}
10385 True if a font named @var{font} exists.  @var{font} is handled as if it was
10386 opened with the @code{ft} request (this is, font translation and styles are
10387 applied), without actually mounting it.
10389 This test doesn't load the complete font but only its header to verify
10390 its validity.
10392 @item S @var{style}
10393 True if style @var{style} has been registered.  Font translation is applied.
10394 @end table
10396 Note that these operators can't be combined with other operators like
10397 @samp{:} or @samp{&}; only a leading @samp{!} (without whitespace
10398 between the exclamation mark and the operator) can be used to negate
10399 the result.
10401 @Example
10402 .nr xxx 1
10403 .ie !r xxx \
10404 true
10405 .el \
10406 false
10407     @result{} false
10408 @endExample
10410 A whitespace after @samp{!} always evaluates to zero (this bizarre
10411 behaviour is due to compatibility with @acronym{UNIX} @code{troff}).
10413 @Example
10414 .nr xxx 1
10415 .ie ! r xxx \
10416 true
10417 .el \
10418 false
10419     @result{} r xxx true
10420 @endExample
10422 It is possible to omit the whitespace before the argument to the
10423 @samp{r}, @samp{d}, and @samp{c} operators.
10425 @xref{Expressions}.
10427 @c ---------------------------------------------------------------------
10429 @node if-else, while, Operators in Conditionals, Conditionals and Loops
10430 @subsection if-else
10431 @cindex if-else
10433 @code{gtroff} has if-then-else constructs like other languages, although
10434 the formatting can be painful.
10436 @Defreq {if, expr anything}
10438 Evaluate the expression @var{expr}, and executes @var{anything} (the
10439 remainder of the line) if @var{expr} evaluates to a value greater than
10440 zero (true).  @var{anything} is interpreted as though it was on a line
10441 by itself (except that leading spaces are swallowed).
10442 @xref{Expressions}, for more info.
10444 @Example
10445 .nr xxx 1
10446 .nr yyy 2
10447 .if ((\n[xxx] == 1) & (\n[yyy] == 2)) true
10448     @result{} true
10449 @endExample
10450 @endDefreq
10452 @Defreq{nop, anything}
10453 Executes @var{anything}.
10454 This is similar to @code{.if@tie{}1}.
10455 @endDefreq
10457 @DefreqList {ie, expr anything}
10458 @DefreqListEnd {el, anything}
10459 Use the @code{ie} and @code{el} requests to write an if-then-else.
10460 The first request is the `if' part and the latter is the `else' part.
10462 @Example
10463 .ie n .ls 2 \" double-spacing in nroff
10464 .el   .ls 1 \" single-spacing in troff
10465 @endExample
10466 @endDefreq
10468 @c there is a bug in makeinfo <= 4.1a: you can't have `@{' as an argument
10469 @c to @deffn
10471 @c and in 4.2 you still can't use @{ in macros.
10473 @c @DefescList {\@{, , , }
10474 @c @DefescListEnd {\@}, , , }
10475 @deffn Escape @t{\@{}
10476 @deffnx Escape @t{\@}}
10477 @esindex \@{
10478 @esindex \@}
10479 @cindex begin of conditional block (@code{\@{})
10480 @cindex end of conditional block (@code{\@}})
10481 @cindex conditional block, begin (@code{\@{})
10482 @cindex conditional block, end (@code{\@}})
10483 @cindex block, conditional, begin (@code{\@{})
10484 @cindex block, condititional, end (@code{\@}})
10485 In many cases, an if (or if-else) construct needs to execute more than
10486 one request.  This can be done using the @code{\@{} and @code{\@}}
10487 escapes.  The following example shows the possible ways to use these
10488 escapes (note the position of the opening and closing braces).
10490 @Example
10491 .ie t \@{\
10492 .    ds lq ``
10493 .    ds rq ''
10494 .\@}
10495 .el \
10496 .\@{\
10497 .    ds lq "
10498 .    ds rq "\@}
10499 @endExample
10500 @c @endDefesc
10501 @end deffn
10503 @xref{Expressions}.
10505 @c ---------------------------------------------------------------------
10507 @node while,  , if-else, Conditionals and Loops
10508 @subsection while
10509 @cindex while
10511 @code{gtroff} provides a looping construct using the @code{while}
10512 request, which is used much like the @code{if} (and related) requests.
10514 @Defreq {while, expr anything}
10515 Evaluate the expression @var{expr}, and repeatedly execute
10516 @var{anything} (the remainder of the line) until @var{expr} evaluates
10517 to@tie{}0.
10519 @Example
10520 .nr a 0 1
10521 .while (\na < 9) \@{\
10522 \n+a,
10523 .\@}
10524 \n+a
10525     @result{} 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
10526 @endExample
10528 Some remarks.
10530 @cindex @code{de} request, and @code{while}
10531 @itemize @bullet
10532 @item
10533 The body of a @code{while} request is treated like the body of a
10534 @code{de} request: @code{gtroff} temporarily stores it in a macro
10535 which is deleted after the loop has been exited.  It can considerably
10536 slow down a macro if the body of the @code{while} request (within the
10537 macro) is large.  Each time the macro is executed, the @code{while}
10538 body is parsed and stored again as a temporary macro.
10540 @Example
10541 .de xxx
10542 .  nr num 10
10543 .  while (\\n[num] > 0) \@{\
10544 .    \" many lines of code
10545 .    nr num -1
10546 .  \@}
10548 @endExample
10550 @cindex recursive macros
10551 @cindex macros, recursive
10552 @noindent
10553 The traditional and ofter better solution (@acronym{UNIX} @code{troff}
10554 doesn't have the @code{while} request) is to use a recursive macro
10555 instead which is parsed only once during its definition.
10557 @Example
10558 .de yyy
10559 .  if (\\n[num] > 0) \@{\
10560 .    \" many lines of code
10561 .    nr num -1
10562 .    yyy
10563 .  \@}
10566 .de xxx
10567 .  nr num 10
10568 .  yyy
10570 @endExample
10572 @noindent
10573 Note that the number of available recursion levels is set to@tie{}1000
10574 (this is a compile-time constant value of @code{gtroff}).
10576 @item
10577 The closing brace of a @code{while} body must end a line.
10579 @Example
10580 .if 1 \@{\
10581 .  nr a 0 1
10582 .  while (\n[a] < 10) \@{\
10583 .    nop \n+[a]
10584 .\@}\@}
10585     @result{} unbalanced \@{ \@}
10586 @endExample
10587 @end itemize
10588 @endDefreq
10590 @Defreq {break, }
10591 @cindex @code{while} request, confusing with @code{br}
10592 @cindex @code{break} request, in a @code{while} loop
10593 @cindex @code{continue} request, in a @code{while} loop
10594 Break out of a @code{while} loop.  Be sure not to confuse this with
10595 the @code{br} request (causing a line break).
10596 @endDefreq
10598 @Defreq {continue, }
10599 Finish the current iteration of a @code{while} loop, immediately
10600 restarting the next iteration.
10601 @endDefreq
10603 @xref{Expressions}.
10606 @c =====================================================================
10608 @node Writing Macros, Page Motions, Conditionals and Loops, gtroff Reference
10609 @section Writing Macros
10610 @cindex writing macros
10611 @cindex macros, writing
10613 A @dfn{macro} is a collection of text and embedded commands which can
10614 be invoked multiple times.  Use macros to define common operations.
10616 @DefreqList {de, name [@Var{end}]}
10617 @DefreqItem {de1, name [@Var{end}]}
10618 @DefreqItem {dei, name [@Var{end}]}
10619 @DefreqListEnd {dei1, name [@Var{end}]}
10620 Define a new macro named @var{name}.  @code{gtroff} copies subsequent
10621 lines (starting with the next one) into an internal buffer until it
10622 encounters the line @samp{..} (two dots).  The optional second
10623 argument to @code{de} changes this to a macro to @samp{.@var{end}}.
10625 There can be whitespace after the first dot in the line containing the
10626 ending token (either @samp{.} or macro @samp{@var{end}}).
10628 Here a small example macro called @samp{P} which causes a break and
10629 inserts some vertical space.  It could be used to separate paragraphs.
10631 @Example
10632 .de P
10633 .  br
10634 .  sp .8v
10636 @endExample
10638 The following example defines a macro within another.  Remember that
10639 expansion must be protected twice; once for reading the macro and
10640 once for executing.
10642 @Example
10643 \# a dummy macro to avoid a warning
10644 .de end
10647 .de foo
10648 .  de bar end
10649 .    nop \f[B]Hallo \\\\$1!\f[]
10650 .  end
10653 .foo
10654 .bar Joe
10655     @result{} @b{Hallo Joe!}
10656 @endExample
10658 @noindent
10659 Since @code{\f} has no expansion, it isn't necessary to protect its
10660 backslash.  Had we defined another macro within @code{bar} which takes
10661 a parameter, eight backslashes would be necessary before @samp{$1}.
10663 The @code{de1} request turns off compatibility mode
10664 while executing the macro.  On entry, the current compatibility mode
10665 is saved and restored at exit.
10667 @Example
10668 .nr xxx 12345
10670 .de aa
10671 The value of xxx is \\n[xxx].
10673 .de1 bb
10674 The value of xxx ix \\n[xxx].
10677 .cp 1
10680     @result{} warning: number register `[' not defined
10681     @result{} The value of xxx is 0xxx].
10683     @result{} The value of xxx ix 12345.
10684 @endExample
10686 The @code{dei} request defines a macro indirectly.
10687 That is, it expands strings whose names
10688 are @var{name} or @var{end} before performing the append.
10690 This:
10692 @Example
10693 .ds xx aa
10694 .ds yy bb
10695 .dei xx yy
10696 @endExample
10698 @noindent
10699 is equivalent to:
10701 @Example
10702 .de aa bb
10703 @endExample
10705 The @code{dei1} request is similar to @code{dei} but with compatibility
10706 mode switched off during execution of the defined macro.
10708 If compatibility mode is on, @code{de} (and @code{dei}) behave similar to
10709 @code{de1} (and @code{dei1}): A `compatibility save' token is inserted at
10710 the beginning, and a `compatibility restore' token at the end, with
10711 compatibility mode switched on during execution.  @xref{Gtroff Internals},
10712 for more information on switching compatibility mode on and off in a
10713 single document.
10715 @pindex trace.tmac
10716 Using @file{trace.tmac}, you can trace calls to @code{de} and @code{de1}.
10718 Note that macro identifiers are shared with identifiers for strings and
10719 diversions.
10720 @endDefreq
10722 @DefreqList {am, name [@Var{end}]}
10723 @DefreqItem {am1, name [@Var{end}]}
10724 @DefreqItem {ami, name [@Var{end}]}
10725 @DefreqListEnd {ami1, name [@Var{end}]}
10726 @cindex appending to a macro (@code{am})
10727 @cindex macro, appending (@code{am})
10728 Works similarly to @code{de} except it appends onto the macro named
10729 @var{name}.  So, to make the previously defined @samp{P} macro actually
10730 do indented instead of block paragraphs, add the necessary code to the
10731 existing macro like this:
10733 @Example
10734 .am P
10735 .ti +5n
10737 @endExample
10739 The @code{am1} request turns off compatibility mode
10740 while executing the appended macro piece.  To be more precise, a
10741 @dfn{compatibility save} input token is inserted at the beginning of
10742 the appended code, and a @dfn{compatibility restore} input token at
10743 the end.
10745 The @code{ami} request appends indirectly,
10746 meaning that @code{gtroff} expands strings whose names
10747 are @var{name} or @var{end} before performing the append.
10749 The @code{ami1} request is similar to @code{ami} but compatibility mode
10750 is switched off during execution of the defined macro.
10752 @pindex trace.tmac
10753 Using @file{trace.tmac}, you can trace calls to @code{am} and @code{am1}.
10754 @endDefreq
10756 @xref{Strings}, for the @code{als} request to rename a macro.
10758 The @code{de}, @code{am}, @code{di}, @code{da}, @code{ds}, and
10759 @code{as} requests (together with its variants) only create a new object
10760 if the name of the macro, diversion or string diversion is currently
10761 undefined or if it is defined to be a request; normally they modify the
10762 value of an existing object.
10764 @Defreq {return, [@Var{anything}]}
10765 Exit a macro, immediately returning to the caller.
10767 If called with an argument, exit twice, namely the current macro and the
10768 macro one level higher.  This is used to define a wrapper macro for
10769 @code{return} in @file{trace.tmac}.
10770 @endDefreq
10772 @menu
10773 * Copy-in Mode::
10774 * Parameters::
10775 @end menu
10777 @c ---------------------------------------------------------------------
10779 @node Copy-in Mode, Parameters, Writing Macros, Writing Macros
10780 @subsection Copy-in Mode
10781 @cindex copy-in mode
10782 @cindex mode, copy-in
10784 @cindex @code{\n}, when reading text for a macro
10785 @cindex @code{\$}, when reading text for a macro
10786 @cindex @code{\*}, when reading text for a macro
10787 @cindex @code{\\}, when reading text for a macro
10788 @cindex \@key{RET}, when reading text for a macro
10789 When @code{gtroff} reads in the text for a macro, string, or diversion,
10790 it copies the text (including request lines, but excluding escapes) into
10791 an internal buffer.  Escapes are converted into an internal form,
10792 except for @code{\n}, @code{\$}, @code{\*}, @code{\\} and
10793 @code{\@key{RET}} which are evaluated and inserted into the text where
10794 the escape was located.  This is known as @dfn{copy-in} mode or
10795 @dfn{copy} mode.
10797 What this means is that you can specify when these escapes are to be
10798 evaluated (either at copy-in time or at the time of use) by insulating
10799 the escapes with an extra backslash.  Compare this to the @code{\def}
10800 and @code{\edef} commands in @TeX{}.
10802 The following example prints the numbers 20 and@tie{}10:
10804 @Example
10805 .nr x 20
10806 .de y
10807 .nr x 10
10808 \&\nx
10809 \&\\nx
10812 @endExample
10814 @c ---------------------------------------------------------------------
10816 @node Parameters,  , Copy-in Mode, Writing Macros
10817 @subsection Parameters
10818 @cindex parameters
10820 The arguments to a macro or string can be examined using a variety of
10821 escapes.
10823 @Defreg {.$}
10824 @cindex number of arguments register (@code{.$})
10825 The number of arguments passed to a macro or string.  This is a read-only
10826 number register.
10828 Note that the @code{shift} request can change its value.
10829 @endDefreg
10831 Any individual argument can be retrieved with one of the following
10832 escapes:
10834 @DefescList {\\$, , n, }
10835 @DefescItem {\\$, @lparen{}, nn, }
10836 @DefescListEnd {\\$, @lbrack{}, nnn, @rbrack{}}
10837 @cindex copy-in mode, and macro arguments
10838 @cindex macro, arguments (@code{\$})
10839 @cindex arguments, macro (@code{\$})
10840 Retrieve the @var{n}@dmn{th}, @var{nn}@dmn{th} or @var{nnn}@dmn{th}
10841 argument.  As usual, the first form only accepts a single number
10842 (larger than zero), the second a two-digit number (larger or equal
10843 to@tie{}10), and the third any positive integer value (larger
10844 than zero).  Macros and strings can have an unlimited number of arguments.
10845 Note that due to copy-in mode, use two backslashes on these in actual use
10846 to prevent interpolation until the macro is actually invoked.
10847 @endDefesc
10849 @Defreq {shift, [@Var{n}]}
10850 Shift the arguments 1@tie{}position, or as
10851 many positions as specified by its argument.  After executing this
10852 request, argument@tie{}@var{i} becomes argument @math{@var{i}-@var{n}};
10853 arguments 1 to@tie{}@var{n} are no longer available.  Shifting by
10854 negative amounts is currently undefined.
10856 The register @code{.$} is adjusted accordingly.
10857 @endDefreq
10859 @DefescList {\\$*, , , }
10860 @DefescListEnd {\\$@@, , , }
10861 In some cases it is convenient to use all of the arguments at once (for
10862 example, to pass the arguments along to another macro).  The @code{\$*}
10863 escape concatenates all the arguments separated by spaces.  A
10864 similar escape is @code{\$@@}, which concatenates all the
10865 arguments with each surrounded by double quotes, and separated by
10866 spaces.  If not in compatibility mode, the input level of double quotes
10867 is preserved (see @ref{Request and Macro Arguments}).
10868 @endDefesc
10870 @Defesc {\\$0, , , }
10871 @cindex macro name register (@code{\$0})
10872 @cindex @code{als} request, and @code{\$0}
10873 The name used to invoke the current macro.
10874 The @code{als} request can make a macro have more than one name.
10876 @Example
10877 .de generic-macro
10878 .  ...
10879 .  if \\n[error] \@{\
10880 .    tm \\$0: Houston, we have a problem.
10881 .    return
10882 .  \@}
10885 .als foo generic-macro
10886 .als bar generic-macro
10887 @endExample
10888 @endDefesc
10890 @xref{Request and Macro Arguments}.
10893 @c =====================================================================
10895 @node Page Motions, Drawing Requests, Writing Macros, gtroff Reference
10896 @section Page Motions
10897 @cindex page motions
10898 @cindex motions, page
10900 @xref{Manipulating Spacing}, for a discussion of the main request for
10901 vertical motion, @code{sp}.
10903 @DefreqList {mk, [@Var{reg}]}
10904 @DefreqListEnd {rt, [@Var{dist}]}
10905 @cindex marking vertical page location (@code{mk})
10906 @cindex page location, vertical, marking (@code{mk})
10907 @cindex location, vertical, page, marking (@code{mk})
10908 @cindex vertical page location, marking (@code{mk})
10909 @cindex returning to marked vertical page location (@code{rt})
10910 @cindex page location, vertical, returning to marked (@code{rt})
10911 @cindex location, vertical, page, returning to marked (@code{rt})
10912 @cindex vertical page location, returning to marked (@code{rt})
10913 The request @code{mk} can be used to mark a location on a page, for
10914 movement to later.  This request takes a register name as an argument
10915 in which to store the current page location.  With no argument it
10916 stores the location in an internal register.  The results of this can
10917 be used later by the @code{rt} or the @code{sp} request (or the
10918 @code{\v} escape).
10920 The @code{rt} request returns @emph{upwards} to the location marked
10921 with the last @code{mk} request.  If used with an argument, return to
10922 a position which distance from the top of the page is @var{dist} (no
10923 previous call to @code{mk} is necessary in this case).  Default scaling
10924 indicator is @samp{v}.
10926 Here a primitive solution for a two-column macro.
10928 @Example
10929 .nr column-length 1.5i
10930 .nr column-gap 4m
10931 .nr bottom-margin 1m
10933 @endExample
10934 @Example
10935 .de 2c
10936 .  br
10937 .  mk
10938 .  ll \\n[column-length]u
10939 .  wh -\\n[bottom-margin]u 2c-trap
10940 .  nr right-side 0
10943 @endExample
10944 @Example
10945 .de 2c-trap
10946 .  ie \\n[right-side] \@{\
10947 .    nr right-side 0
10948 .    po -(\\n[column-length]u + \\n[column-gap]u)
10949 .    \" remove trap
10950 .    wh -\\n[bottom-margin]u
10951 .  \@}
10952 .  el \@{\
10953 .    \" switch to right side
10954 .    nr right-side 1
10955 .    po +(\\n[column-length]u + \\n[column-gap]u)
10956 .    rt
10957 .  \@}
10960 @endExample
10961 @Example
10962 .pl 1.5i
10963 .ll 4i
10964 This is a small test which shows how the
10965 rt request works in combination with mk.
10968 Starting here, text is typeset in two columns.
10969 Note that this implementation isn't robust
10970 and thus not suited for a real two-column
10971 macro.
10972 @endExample
10974 Result:
10976 @Example
10977 This is a small test which shows how the
10978 rt request works in combination with mk.
10980 Starting  here,    isn't    robust
10981 text is typeset    and   thus  not
10982 in two columns.    suited  for   a
10983 Note that  this    real two-column
10984 implementation     macro.
10985 @endExample
10986 @endDefreq
10988 The following escapes give fine control of movements about the page.
10990 @Defesc {\\v, ', e, '}
10991 @cindex vertical motion (@code{\v})
10992 @cindex motion, vertical (@code{\v})
10993 Move vertically, usually from the current location on the page (if no
10994 absolute position operator @samp{|} is used).  The
10995 argument@tie{}@var{e} specifies the distance to move; positive is
10996 downwards and negative upwards.  The default scaling indicator for this
10997 escape is @samp{v}.  Beware, however, that @code{gtroff} continues text
10998 processing at the point where the motion ends, so you should always
10999 balance motions to avoid interference with text processing.
11001 @code{\v} doesn't trigger a trap.  This can be quite useful; for example,
11002 consider a page bottom trap macro which prints a marker in the margin to
11003 indicate continuation of a footnote or something similar.
11004 @endDefesc
11006 There are some special-case escapes for vertical motion.
11008 @Defesc {\\r, , , }
11009 Move upwards@tie{}1@dmn{v}.
11010 @endDefesc
11012 @Defesc {\\u, , , }
11013 Move upwards@tie{}.5@dmn{v}.
11014 @endDefesc
11016 @Defesc {\\d, , , }
11017 Move down@tie{}.5@dmn{v}.
11018 @endDefesc
11020 @Defesc {\\h, ', e, '}
11021 @cindex inserting horizontal space (@code{\h})
11022 @cindex horizontal space (@code{\h})
11023 @cindex space, horizontal (@code{\h})
11024 @cindex horizontal motion (@code{\h})
11025 @cindex motion, horizontal (@code{\h})
11026 Move horizontally, usually from the current location (if no absolute
11027 position operator @samp{|} is used).  The expression@tie{}@var{e}
11028 indicates how far to move: positive is rightwards and negative
11029 leftwards.  The default scaling indicator for this escape is @samp{m}.
11031 This horizontal space is not discarded at the end of a line.  To insert
11032 discardable space of a certain length use the @code{ss} request.
11033 @endDefesc
11035 There are a number of special-case escapes for horizontal motion.
11037 @Defesc {\\@key{SP}, , , }
11038 @cindex space, unbreakable
11039 @cindex unbreakable space
11040 An unbreakable and unpaddable (i.e.@: not expanded during filling)
11041 space.  (Note: This is a backslash followed by a space.)
11042 @endDefesc
11044 @Defesc {\\~, , , }
11045 An unbreakable space that stretches like a normal inter-word space
11046 when a line is adjusted.
11047 @endDefesc
11049 @Defesc {\\|, , , }
11050 A 1/6@dmn{th} em space.  Ignored for TTY output devices (rounded to
11051 zero).
11052 @endDefesc
11054 @Defesc {\\^, , , }
11055 A 1/12@dmn{th} em space.  Ignored for TTY output devices (rounded to
11056 zero).
11057 @endDefesc
11059 @Defesc {\\0, , , }
11060 @cindex space, width of a digit (@code{\0})
11061 @cindex digit width space (@code{\0})
11062 A space the size of a digit.
11063 @endDefesc
11065 The following string sets the @TeX{} logo:
11067 @Example
11068 .ds TeX T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
11069 @endExample
11071 @DefescList {\\w, ', text, '}
11072 @DefregItem {st}
11073 @DefregItem {sb}
11074 @DefregItem {rst}
11075 @DefregItem {rsb}
11076 @DefregItem {ct}
11077 @DefregItem {ssc}
11078 @DefregListEnd {skw}
11079 @cindex width escape (@code{\w})
11080 Return the width of the specified @var{text} in basic units.
11081 This allows horizontal movement based on the width of some
11082 arbitrary text (e.g.@: given as an argument to a macro).
11084 @Example
11085 The length of the string `abc' is \w'abc'u.
11086     @result{} The length of the string `abc' is 72u.
11087 @endExample
11089 Font changes may occur in @var{text} which don't affect current
11090 settings.
11092 After use, @code{\w} sets several registers:
11094 @table @code
11095 @item st
11096 @itemx sb
11097 The highest and lowest point of the baseline, respectively, in @var{text}.
11099 @item rst
11100 @itemx rsb
11101 Like the @code{st} and @code{sb} registers, but takes account of the
11102 heights and depths of glyphs.  With other words, this gives the
11103 highest and lowest point of @var{text}.  Values below the baseline are
11104 negative.
11106 @item ct
11107 Defines the kinds of glyphs occurring in @var{text}:
11109 @table @asis
11110 @item 0
11111 only short glyphs, no descenders or tall glyphs.
11113 @item 1
11114 at least one descender.
11116 @item 2
11117 at least one tall glyph.
11119 @item 3
11120 at least one each of a descender and a tall glyph.
11121 @end table
11123 @item ssc
11124 The amount of horizontal space (possibly negative) that should be added
11125 to the last glyph before a subscript.
11127 @item skw
11128 How far to right of the center of the last glyph in the @code{\w}
11129 argument, the center of an accent from a roman font should be placed
11130 over that glyph.
11131 @end table
11132 @endDefesc
11134 @DefescList {\\k, , p, }
11135 @DefescItem {\\k, @lparen{}, ps, }
11136 @DefescListEnd {\\k, @lbrack{}, position, @rbrack}
11137 @cindex saving horizontal input line position (@code{\k})
11138 @cindex horizontal input line position, saving (@code{\k})
11139 @cindex input line position, horizontal, saving (@code{\k})
11140 @cindex position, horizontal input line, saving (@code{\k})
11141 @cindex line, input, horizontal position, saving (@code{\k})
11142 Store the current horizontal position in the @emph{input} line in
11143 number register with name @var{position} (one-character name@tie{}@var{p},
11144 two-character name @var{ps}).  Use this, for example, to return to the
11145 beginning of a string for highlighting or other decoration.
11146 @endDefesc
11148 @Defreg {hp}
11149 @cindex horizontal input line position register (@code{hp})
11150 @cindex input line, horizontal position, register (@code{hp})
11151 @cindex position, horizontal, in input line, register (@code{hp})
11152 @cindex line, input, horizontal position, register (@code{hp})
11153 The current horizontal position at the input line.
11154 @endDefreg
11156 @Defreg {.k}
11157 @cindex horizontal output line position register (@code{.k})
11158 @cindex output line, horizontal position, register (@code{.k})
11159 @cindex position, horizontal, in output line, register (@code{.k})
11160 @cindex line, output, horizontal position, register (@code{.k})
11161 A read-only number register containing the current horizontal output
11162 position (relative to the current indentation).
11163 @endDefreg
11165 @Defesc {\\o, ', abc, '}
11166 @cindex overstriking glyphs (@code{\o})
11167 @cindex glyphs, overstriking (@code{\o})
11168 Overstrike glyphs @var{a}, @var{b}, @var{c}, @dots{}; the glyphs
11169 are centered, and the resulting spacing is the largest width of the
11170 affected glyphs.
11171 @endDefesc
11173 @Defesc {\\z, , g, , }
11174 @cindex zero-width printing (@code{\z}, @code{\Z})
11175 @cindex printing, zero-width (@code{\z}, @code{\Z})
11176 Print glyph @var{g} with zero width, i.e., without spacing.  Use
11177 this to overstrike glyphs left-aligned.
11178 @endDefesc
11180 @Defesc {\\Z, ', anything, '}
11181 @cindex zero-width printing (@code{\z}, @code{\Z})
11182 @cindex printing, zero-width (@code{\z}, @code{\Z})
11183 Print @var{anything}, then restore the horizontal and vertical position.
11184 The argument may not contain tabs or leaders.
11186 The following is an example of a strike-through macro:
11188 @Example
11189 .de ST
11190 .nr ww \w'\\$1'
11191 \Z@@\v'-.25m'\l'\\n[ww]u'@@\\$1
11194 This is
11195 .ST "a test"
11196 an actual emergency!
11197 @endExample
11198 @endDefesc
11201 @c =====================================================================
11203 @node Drawing Requests, Traps, Page Motions, gtroff Reference
11204 @section Drawing Requests
11205 @cindex drawing requests
11206 @cindex requests for drawing
11208 @code{gtroff} provides a number of ways to draw lines and other figures
11209 on the page.  Used in combination with the page motion commands (see
11210 @ref{Page Motions}, for more info), a wide variety of figures can be
11211 drawn.  However, for complex drawings these operations can be quite
11212 cumbersome, and it may be wise to use graphic preprocessors like
11213 @code{gpic} or @code{ggrn}.  @xref{gpic}, and @ref{ggrn}, for more
11214 information.
11216 All drawing is done via escapes.
11218 @DefescList {\\l, ', l, '}
11219 @DefescListEnd {\\l, ', lg, '}
11220 @cindex drawing horizontal lines (@code{\l})
11221 @cindex horizontal line, drawing (@code{\l})
11222 @cindex line, horizontal, drawing (@code{\l})
11223 Draw a line horizontally.  @var{l} is the length of the line to be
11224 drawn.  If it is positive, start the line at the current location and
11225 draw to the right; its end point is the new current location.  Negative
11226 values are handled differently: The line starts at the current location
11227 and draws to the left, but the current location doesn't move.
11229 @var{l} can also be specified absolutely (i.e.@: with a leading
11230 @samp{|}) which draws back to the beginning of the input line.
11231 Default scaling indicator is @samp{m}.
11233 @cindex underscore glyph (@code{\[ru]})
11234 @cindex glyph, underscore (@code{\[ru]})
11235 @cindex line drawing glyph
11236 @cindex glyph, for line drawing
11237 The optional second parameter@tie{}@var{g} is a glyph to draw the line
11238 with.  If this second argument is not specified, @code{gtroff} uses
11239 the underscore glyph, @code{\[ru]}.
11241 @cindex zero width space character (@code{\&})
11242 @cindex character, zero width space (@code{\&})
11243 @cindex space character, zero width (@code{\&})
11244 To separate the two arguments (to prevent @code{gtroff} from
11245 interpreting a drawing glyph as a scaling indicator if the glyph is
11246 represented by a single character) use @code{\&}.
11248 Here a small useful example:
11250 @Example
11251 .de box
11252 \[br]\\$*\[br]\l'|0\[rn]'\l'|0\[ul]'
11254 @endExample
11256 @noindent
11257 Note that this works by outputting a box rule (a vertical line), then
11258 the text given as an argument and then another box rule.  Finally, the
11259 line drawing escapes both draw from the current location to the
11260 beginning of the @emph{input} line -- this works because the line
11261 length is negative, not moving the current point.
11262 @endDefesc
11264 @DefescList {\\L, ', l, '}
11265 @DefescListEnd {\\L, ', lg, '}
11266 @cindex drawing vertical lines (@code{\L})
11267 @cindex vertical line drawing (@code{\L})
11268 @cindex line, vertical, drawing (@code{\L})
11269 @cindex line drawing glyph
11270 @cindex glyph for line drawing
11271 @cindex box rule glyph (@code{\[br]})
11272 @cindex glyph, box rule (@code{\[br]})
11273 Draw vertical lines.  Its parameters are
11274 similar to the @code{\l} escape, except that the default scaling
11275 indicator is @samp{v}.  The movement is downwards for positive values,
11276 and upwards for negative values.  The default glyph is the box rule
11277 glyph, @code{\[br]}.  As with the vertical motion escapes, text
11278 processing blindly continues where the line ends.
11280 @Example
11281 This is a \L'3v'test.
11282 @endExample
11284 @noindent
11285 Here the result, produced with @code{grotty}.
11287 @Example
11288 This is a
11289           |
11290           |
11291           |test.
11292 @endExample
11293 @endDefesc
11295 @Defesc {\\D, ', command arg @dots{}, '}
11296 The @code{\D} escape provides a variety of drawing functions.
11297 Note that on character devices, only vertical and horizontal lines are
11298 supported within @code{grotty}; other devices may only support a subset
11299 of the available drawing functions.
11301 The default scaling indicator for all subcommands of @code{\D} is
11302 @samp{m} for horizontal distances and @samp{v} for vertical ones.
11303 Exceptions are @w{@code{\D'f @dots{}'}} and @w{@code{\D't @dots{}'}}
11304 which use @code{u} as the default, and @w{@code{\D'F@var{x} @dots{}'}}
11305 which arguments are treated similar to the @code{defcolor} request.
11307 @table @code
11308 @item \D'l @var{dx} @var{dy}'
11309 @cindex line, drawing (@w{@code{\D'l @dots{}'}})
11310 @cindex drawing a line (@w{@code{\D'l @dots{}'}})
11311 Draw a line from the current location to the relative point specified by
11312 (@var{dx},@var{dy}), where positive values mean down and right,
11313 respectively.  The end point of the line is the new current location.
11315 The following example is a macro for creating a box around a text string;
11316 for simplicity, the box margin is taken as a fixed value, 0.2@dmn{m}.
11318 @Example
11319 .de BOX
11320 .  nr @@wd \w'\\$1'
11321 \h'.2m'\
11322 \h'-.2m'\v'(.2m - \\n[rsb]u)'\
11323 \D'l 0 -(\\n[rst]u - \\n[rsb]u + .4m)'\
11324 \D'l (\\n[@@wd]u + .4m) 0'\
11325 \D'l 0 (\\n[rst]u - \\n[rsb]u + .4m)'\
11326 \D'l -(\\n[@@wd]u + .4m) 0'\
11327 \h'.2m'\v'-(.2m - \\n[rsb]u)'\
11328 \\$1\
11329 \h'.2m'
11331 @endExample
11333 @noindent
11334 First, the width of the string is stored in register @code{@@wd}.  Then,
11335 four lines are drawn to form a box, properly offset by the box margin.
11336 The registers @code{rst} and @code{rsb} are set by the @code{\w} escape,
11337 containing the largest height and depth of the whole string.
11339 @item \D'c @var{d}'
11340 @cindex circle, drawing (@w{@code{\D'c @dots{}'}})
11341 @cindex drawing a circle (@w{@code{\D'c @dots{}'}})
11342 Draw a circle with a diameter of@tie{}@var{d} with the leftmost point at the
11343 current position.  After drawing, the current location is positioned at the
11344 rightmost point of the circle.
11346 @item \D'C @var{d}'
11347 @cindex circle, solid, drawing (@w{@code{\D'C @dots{}'}})
11348 @cindex drawing a solid circle (@w{@code{\D'C @dots{}'}})
11349 @cindex solid circle, drawing (@w{@code{\D'C @dots{}'}})
11350 Draw a solid circle with the same parameters and behaviour as an outlined
11351 circle.  No outline is drawn.
11353 @item \D'e @var{x} @var{y}'
11354 @cindex drawing an ellipse (@w{@code{\D'e @dots{}'}})
11355 @cindex ellipse, drawing (@w{@code{\D'e @dots{}'}})
11356 Draw an ellipse with a horizontal diameter of @var{x} and a vertical
11357 diameter of @var{y} with the leftmost point at the current position.
11358 After drawing, the current location is positioned at the rightmost point of
11359 the ellipse.
11361 @item \D'E @var{x} @var{y}'
11362 @cindex ellipse, solid, drawing (@w{@code{\D'E @dots{}'}})
11363 @cindex drawing a solid ellipse (@w{@code{\D'E @dots{}'}})
11364 @cindex solid ellipse, drawing (@w{@code{\D'E @dots{}'}})
11365 Draw a solid ellipse with the same parameters and behaviour as an
11366 outlined ellipse.  No outline is drawn.
11368 @item \D'a @var{dx1} @var{dy1} @var{dx2} @var{dy2}'
11369 @cindex arc, drawing (@w{@code{\D'a @dots{}'}})
11370 @cindex drawing an arc (@w{@code{\D'a @dots{}'}})
11371 Draw an arc clockwise from the current location through the two
11372 specified relative locations (@var{dx1},@var{dy1}) and
11373 (@var{dx2},@var{dy2}).  The coordinates of the first point are relative
11374 to the current position, and the coordinates of the second point are
11375 relative to the first point.  After drawing, the current position is moved
11376 to the final point of the arc.
11378 @item \D'~ @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
11379 @cindex drawing a spline (@w{@code{\D'~ @dots{}'}})
11380 @cindex spline, drawing (@w{@code{\D'~ @dots{}'}})
11381 Draw a spline from the current location to the relative point
11382 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}), and so on.
11383 The current position is moved to the terminal point of the drawn curve.
11385 @item \D'f @var{n}'
11386 @cindex gray shading (@w{@code{\D'f @dots{}'}})
11387 @cindex shading filled objects (@w{@code{\D'f @dots{}'}})
11388 Set the shade of gray to be used for filling solid objects to@tie{}@var{n};
11389 @var{n}@tie{}must be an integer between 0 and@tie{}1000, where 0
11390 corresponds solid white and 1000 to solid black, and values in between
11391 correspond to intermediate shades of gray.  This applies only to solid
11392 circles, solid ellipses, and solid polygons.  By default, a level of
11393 1000 is used.
11395 Despite of being silly, the current point is moved horizontally to the
11396 right by@tie{}@var{n}.
11398 @cindex @w{@code{\D'f @dots{}'}} and horizontal resolution
11399 Don't use this command!  It has the serious drawback that it will be
11400 always rounded to the next integer multiple of the horizontal resolution
11401 (the value of the @code{hor} keyword in the @file{DESC} file).  Use
11402 @code{\M} (@pxref{Colors}) or @w{@code{\D'Fg @dots{}'}} instead.
11404 @item \D'p @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
11405 @cindex drawing a polygon (@w{@code{\D'p @dots{}'}})
11406 @cindex polygon, drawing (@w{@code{\D'p @dots{}'}})
11407 Draw a polygon from the current location to the relative position
11408 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}) and so on.
11409 When the specified data points are exhausted, a line is drawn back
11410 to the starting point.  The current position is changed by adding the
11411 sum of all arguments with odd index to the actual horizontal position and
11412 the even ones to the vertical position.
11414 @item \D'P @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
11415 @cindex polygon, solid, drawing (@w{@code{\D'P @dots{}'}})
11416 @cindex drawing a solid polygon (@w{@code{\D'P @dots{}'}})
11417 @cindex solid polygon, drawing (@w{@code{\D'P @dots{}'}})
11418 Draw a solid polygon with the same parameters and behaviour as an
11419 outlined polygon.  No outline is drawn.
11421 Here a better variant of the box macro to fill the box with some color.
11422 Note that the box must be drawn before the text since colors in
11423 @code{gtroff} are not transparent; the filled polygon would hide the
11424 text completely.
11426 @Example
11427 .de BOX
11428 .  nr @@wd \w'\\$1'
11429 \h'.2m'\
11430 \h'-.2m'\v'(.2m - \\n[rsb]u)'\
11431 \M[lightcyan]\
11432 \D'P 0 -(\\n[rst]u - \\n[rsb]u + .4m) \
11433      (\\n[@@wd]u + .4m) 0 \
11434      0 (\\n[rst]u - \\n[rsb]u + .4m) \
11435      -(\\n[@@wd]u + .4m) 0'\
11436 \h'.2m'\v'-(.2m - \\n[rsb]u)'\
11437 \M[]\
11438 \\$1\
11439 \h'.2m'
11441 @endExample
11443 @item \D't @var{n}'
11444 @cindex line thickness (@w{@code{\D't @dots{}'}})
11445 @cindex thickness of lines (@w{@code{\D't @dots{}'}})
11446 Set the current line thickness to @var{n}@tie{}machine units.  A value of
11447 zero selects the smallest available line thickness.  A negative value
11448 makes the line thickness proportional to the current point size (this is
11449 the default behaviour of @acronym{AT&T} @code{troff}).
11451 Despite of being silly, the current point is moved horizontally to the
11452 right by@tie{}@var{n}.
11454 @item \D'F@var{scheme} @var{color_components}'
11455 @cindex unnamed fill colors (@code{\D'F@dots{}'})
11456 @cindex fill colors, unnamed (@code{\D'F@dots{}'})
11457 @cindex colors, fill, unnamed (@code{\D'F@dots{}'})
11458 Change current fill color.  @var{scheme} is a single letter denoting the
11459 color scheme: @samp{r} (rgb), @samp{c} (cmy), @samp{k} (cmyk), @samp{g}
11460 (gray), or @samp{d} (default color).  The color components use exactly
11461 the same syntax as in the @code{defcolor} request (@pxref{Colors}); the
11462 command @code{\D'Fd'} doesn't take an argument.
11464 @emph{No} position changing!
11466 Examples:
11468 @Example
11469 @endExample
11470 \D'Fg .3'      \" same gray as \D'f 700'
11471 \D'Fr #0000ff' \" blue
11472 @end table
11473 @endDefesc
11475 @xref{Graphics Commands}.
11477 @Defesc {\\b, ', string, '}
11478 @cindex pile, glyph (@code{\b})
11479 @cindex glyph pile (@code{\b})
11480 @cindex stacking glyphs (@code{\b})
11481 @dfn{Pile} a sequence of glyphs vertically, and center it vertically
11482 on the current line.  Use it to build large brackets and braces.
11484 Here an example how to create a large opening brace:
11486 @Example
11487 \b'\[lt]\[bv]\[lk]\[bv]\[lb]'
11488 @endExample
11490 @cindex @code{\b}, limitations
11491 @cindex limitations of @code{\b} escape
11492 The first glyph is on the top, the last glyph in @var{string} is
11493 at the bottom.  Note that @code{gtroff} separates the glyphs
11494 vertically by 1@dmn{m}, and the whole object is centered 0.5@dmn{m}
11495 above the current baseline; the largest glyph width is used as the
11496 width for the whole object.  This rather unflexible positioning
11497 algorithm doesn't work with @option{-Tdvi} since the bracket pieces vary
11498 in height for this device.  Instead, use the @code{eqn} preprocessor.
11500 @xref{Manipulating Spacing}, how to adjust the vertical spacing with
11501 the @code{\x} escape.
11502 @endDefesc
11505 @c =====================================================================
11507 @node Traps, Diversions, Drawing Requests, gtroff Reference
11508 @section Traps
11509 @cindex traps
11511 @dfn{Traps} are locations, which, when reached, call a specified
11512 macro.  These traps can occur at a given location on the page, at a
11513 given location in the current diversion, at a blank line,
11514 after a certain number of input lines, or at the end of input.
11516 @cindex planting a trap
11517 @cindex trap, planting
11518 Setting a trap is also called @dfn{planting}.
11519 @cindex trap, springing
11520 @cindex springing a trap
11521 It is also said that a trap is @dfn{sprung} if the associated macro
11522 is executed.
11524 @menu
11525 * Page Location Traps::
11526 * Diversion Traps::
11527 * Input Line Traps::
11528 * Blank Line Traps::
11529 * End-of-input Traps::
11530 @end menu
11532 @c ---------------------------------------------------------------------
11534 @node Page Location Traps, Diversion Traps, Traps, Traps
11535 @subsection Page Location Traps
11536 @cindex page location traps
11537 @cindex traps, page location
11539 @dfn{Page location traps} perform an action when @code{gtroff}
11540 reaches or passes a certain vertical location on the page.  Page
11541 location traps have a variety of purposes, including:
11543 @itemize
11544 @item
11545 setting headers and footers
11547 @item
11548 setting body text in multiple columns
11550 @item
11551 setting footnotes
11552 @end itemize
11554 @DefreqList {vpt, flag}
11555 @DefregListEnd {.vpt}
11556 @cindex enabling vertical position traps (@code{vpt})
11557 @cindex vertical position traps, enabling (@code{vpt})
11558 @cindex vertical position trap enable register (@code{.vpt})
11559 Enable vertical position traps if @var{flag} is non-zero, or disables
11560 them otherwise.  Vertical position traps are traps set by the @code{wh}
11561 or @code{dt} requests.  Traps set by the @code{it} request are not
11562 vertical position traps.  The parameter that controls whether vertical
11563 position traps are enabled is global.  Initially vertical position traps
11564 are enabled.  The current setting of this is available in the
11565 @code{.vpt} read-only number register.
11567 Note that a page can't be ejected if @code{vpt} is set to zero.
11568 @endDefreq
11570 @Defreq {wh, dist [@Var{macro}]}
11571 Set a page location trap.  Non-negative values for @var{dist} set
11572 the trap relative to the top of the page; negative values set
11573 the trap relative to the bottom of the page.  Default scaling
11574 indicator is @samp{v}.
11576 @var{macro} is the name of the macro to execute when the
11577 trap is sprung.  If @var{macro} is missing, remove the first trap
11578 (if any) at @var{dist}.
11580 @cindex page headers
11581 @cindex page footers
11582 @cindex headers
11583 @cindex footers
11584 The following is a simple example of how many macro packages
11585 set headers and footers.
11587 @Example
11588 .de hd                \" Page header
11589 '  sp .5i
11590 .  tl 'Title''date'
11591 '  sp .3i
11594 .de fo                \" Page footer
11595 '  sp 1v
11596 .  tl ''%''
11597 '  bp
11600 .wh 0   hd            \" trap at top of the page
11601 .wh -1i fo            \" trap one inch from bottom
11602 @endExample
11604 A trap at or below the bottom of the page is ignored; it can be made
11605 active by either moving it up or increasing the page length so that the
11606 trap is on the page.
11608 It is possible to have more than one trap at the same location; to do so,
11609 the traps must be defined at different locations, then moved together with
11610 the @code{ch} request; otherwise the second trap would replace the first
11611 one.  Earlier defined traps hide later defined traps if moved to the same
11612 position (the many empty lines caused by the @code{bp} request are omitted
11613 in the following example):
11615 @Example
11616 .de a
11617 .  nop a
11619 .de b
11620 .  nop b
11622 .de c
11623 .  nop c
11626 .wh 1i a
11627 .wh 2i b
11628 .wh 3i c
11630     @result{} a b c
11631 @endExample
11632 @Example
11633 .ch b 1i
11634 .ch c 1i
11636     @result{} a
11637 @endExample
11638 @Example
11639 .ch a 0.5i
11641     @result{} a b
11642 @endExample
11643 @endDefreq
11645 @Defreg {.t}
11646 @cindex distance to next trap register (@code{.t})
11647 @cindex trap, distance, register (@code{.t})
11648 A read-only number register holding the distance to the next trap.
11650 If there are no traps between the current position and the bottom of the
11651 page, it contains the distance to the page bottom.  In a diversion, the
11652 distance to the page bottom is infinite (the returned value is the biggest
11653 integer which can be represented in @code{groff}) if there are no diversion
11654 traps.
11655 @endDefreg
11657 @Defreq {ch, macro [@Var{dist}]}
11658 @cindex changing trap location (@code{ch})
11659 @cindex trap, changing location (@code{ch})
11660 Change the location of a trap.
11661 The first argument is the name of the macro to be invoked at
11662 the trap, and the second argument is the new location for the trap
11663 (note that the parameters are specified in opposite order as in the
11664 @code{wh} request).  This is useful for building up footnotes in a
11665 diversion to allow more space at the bottom of the page for them.
11667 Default scaling indicator for @var{dist} is @samp{v}.  If @var{dist}
11668 is missing, the trap is removed.
11670 @c XXX
11672 @ignore
11673 @Example
11674 ... (simplified) footnote example ...
11675 @endExample
11676 @end ignore
11677 @endDefreq
11679 @Defreg {.ne}
11680 The read-only number register @code{.ne} contains the amount of space
11681 that was needed in the last @code{ne} request that caused a trap to be
11682 sprung.  Useful in conjunction with the @code{.trunc} register.
11683 @xref{Page Control}, for more information.
11685 Since the @code{.ne} register is only set by traps it doesn't make
11686 much sense to use it outside of trap macros.
11687 @endDefreg
11689 @Defreg {.trunc}
11690 @cindex @code{ne} request, and the @code{.trunc} register
11691 @cindex truncated vertical space register (@code{.trunc})
11692 A read-only register containing the amount of vertical space truncated
11693 by the most recently sprung vertical position trap, or, if the trap was
11694 sprung by an @code{ne} request, minus the amount of vertical motion
11695 produced by the @code{ne} request.  In other words, at the point a trap
11696 is sprung, it represents the difference of what the vertical position
11697 would have been but for the trap, and what the vertical position
11698 actually is.
11700 Since the @code{.trunc} register is only set by traps it doesn't make
11701 much sense to use it outside of trap macros.
11702 @endDefreg
11704 @Defreg {.pe}
11705 @cindex @code{bp} request, and traps (@code{.pe})
11706 @cindex traps, sprung by @code{bp} request (@code{.pe})
11707 @cindex page ejecting register (@code{.pe})
11708 A read-only register which is set to@tie{}1 while a page is ejected with
11709 the @code{bp} request (or by the end of input).
11711 Outside of traps this register is always zero.  In the following example,
11712 only the second call to@tie{}@code{x} is caused by @code{bp}.
11714 @Example
11715 .de x
11716 \&.pe=\\n[.pe]
11719 .wh 1v x
11720 .wh 4v x
11721 A line.
11723 Another line.
11725     @result{} A line.
11726        .pe=0
11727        Another line.
11729        .pe=1
11730 @endExample
11731 @endDefreg
11733 @cindex diversions, and traps
11734 @cindex traps, and diversions
11735 An important fact to consider while designing macros is that diversions and
11736 traps do not interact normally.  For example, if a trap invokes a header
11737 macro (while outputting a diversion) which tries to change the font on the
11738 current page, the effect will not be visible before the diversion has
11739 completely been printed (except for input protected with @code{\!} or
11740 @code{\?}) since the data in the diversion is already formatted.  In most
11741 cases, this is not the expected behaviour.
11743 @c ---------------------------------------------------------------------
11745 @node Diversion Traps, Input Line Traps, Page Location Traps, Traps
11746 @subsection Diversion Traps
11747 @cindex diversion traps
11748 @cindex traps, diversion
11750 @Defreq {dt, [@Var{dist} @Var{macro}]}
11751 @cindex @code{.t} register, and diversions
11752 @cindex setting diversion trap (@code{dt})
11753 @cindex diversion trap, setting (@code{dt})
11754 @cindex trap, diversion, setting (@code{dt})
11755 Set a trap @emph{within} a diversion.
11756 @var{dist} is the location of the trap
11757 (identical to the @code{wh} request; default scaling indicator is
11758 @samp{v}) and @var{macro} is the name of the macro to be invoked.
11759 If called without arguments, the diversion trap is removed.
11761 Note that there exists only a single diversion trap.
11763 The number register @code{.t} still works within diversions.
11764 @xref{Diversions}, for more information.
11765 @endDefreq
11767 @c ---------------------------------------------------------------------
11769 @node Input Line Traps, Blank Line Traps, Diversion Traps, Traps
11770 @subsection Input Line Traps
11771 @cindex input line traps
11772 @cindex traps, input line
11774 @DefreqList {it, n macro}
11775 @DefreqItem {itc, n macro}
11776 @cindex setting input line trap (@code{it})
11777 @cindex input line trap, setting (@code{it})
11778 @cindex trap, input line, setting (@code{it})
11779 Set an input line trap.
11780 @var{n}@tie{}is the number of lines of input which may be read before
11781 springing the trap, @var{macro} is the macro to be invoked.
11782 Request lines are not counted as input lines.
11784 For example, one possible use is to have a macro which prints the
11785 next @var{n}@tie{}lines in a bold font.
11787 @Example
11788 .de B
11789 .  it \\$1 B-end
11790 .  ft B
11793 .de B-end
11794 .  ft R
11796 @endExample
11798 @cindex input line traps and interrupted lines (@code{itc})
11799 @cindex interrupted lines and input line traps (@code{itc})
11800 @cindex traps, input line, and interrupted lines (@code{itc})
11801 @cindex lines, interrupted, and input line traps (@code{itc})
11802 The @code{itc} request is identical
11803 except that an interrupted text line (ending with @code{\c})
11804 is not counted as a separate line.
11806 Both requests are associated with the current environment
11807 (@pxref{Environments}); switching to another environment disables the
11808 current input trap, and going back reactivates it, restoring the number
11809 of already processed lines.
11810 @endDefreq
11812 @c ---------------------------------------------------------------------
11814 @node Blank Line Traps, End-of-input Traps, Input Line Traps, Traps
11815 @subsection Blank Line Traps
11816 @cindex blank line traps
11817 @cindex traps, blank line
11819 @Defreq {blm, macro}
11820 @cindex blank line macro (@code{blm})
11821 Set a blank line trap.
11822 @code{gtroff} executes @var{macro} when it encounters a blank line in
11823 the input file.
11824 @endDefreq
11826 @c ---------------------------------------------------------------------
11828 @node End-of-input Traps,  , Blank Line Traps, Traps
11829 @subsection End-of-input Traps
11830 @cindex end-of-input traps
11831 @cindex traps, end-of-input
11833 @Defreq {em, macro}
11834 @cindex setting end-of-input trap (@code{em})
11835 @cindex end-of-input trap, setting (@code{em})
11836 @cindex trap, end-of-input, setting (@code{em})
11837 @cindex end-of-input macro (@code{em})
11838 @cindex macro, end-of-input (@code{em})
11839 Set a trap at the end of input.  @var{macro} is executed after the
11840 last line of the input file has been processed.
11842 For example, if the document had to have a section at the bottom of the
11843 last page for someone to approve it, the @code{em} request could be
11844 used.
11846 @Example
11847 .de approval
11848 .  ne 5v
11849 .  sp |(\\n[.t] - 6v)
11850 .  in +4i
11851 .  lc _
11852 .  br
11853 Approved:\t\a
11854 .  sp
11855 Date:\t\t\a
11858 .em approval
11859 @endExample
11860 @endDefreq
11863 @c =====================================================================
11865 @node Diversions, Environments, Traps, gtroff Reference
11866 @section Diversions
11867 @cindex diversions
11869 In @code{gtroff} it is possible to @dfn{divert} text into a named
11870 storage area.  Due to the similarity to defining macros it is sometimes
11871 said to be stored in a macro.  This is used for saving text for output
11872 at a later time, which is useful for keeping blocks of text on the same
11873 page, footnotes, tables of contents, and indices.
11875 @cindex top-level diversion
11876 @cindex diversion, top-level
11877 For orthogonality it is said that @code{gtroff} is in the @dfn{top-level
11878 diversion} if no diversion is active (i.e., the data is diverted to the
11879 output device).
11881 @DefreqList {di, macro}
11882 @DefreqListEnd {da, macro}
11883 @cindex beginning diversion (@code{di})
11884 @cindex diversion, beginning (@code{di})
11885 @cindex ending diversion (@code{di})
11886 @cindex diversion, ending (@code{di})
11887 @cindex appending to a diversion (@code{da})
11888 @cindex diversion, appending (@code{da})
11889 Begin a diversion.  Like the @code{de}
11890 request, it takes an argument of a macro name to divert subsequent text
11891 into.  The @code{da} macro appends to an existing diversion.
11893 @code{di} or @code{da} without an argument ends the diversion.
11894 @endDefreq
11896 @DefreqList {box, macro}
11897 @DefreqListEnd {boxa, macro}
11898 Begin (or appends to) a diversion like the
11899 @code{di} and @code{da} requests.
11900 The difference is that @code{box} and @code{boxa}
11901 do not include a partially-filled line in the diversion.
11903 Compare this:
11905 @Example
11906 Before the box.
11907 .box xxx
11908 In the box.
11910 .box
11911 After the box.
11913     @result{} Before the box.  After the box.
11914 .xxx
11915     @result{} In the box.
11916 @endExample
11918 @noindent
11919 with this:
11921 @Example
11922 Before the diversion.
11923 .di yyy
11924 In the diversion.
11927 After the diversion.
11929     @result{} After the diversion.
11930 .yyy
11931     @result{} Before the diversion.  In the diversion.
11932 @endExample
11934 @code{box} or @code{boxa} without an argument ends the diversion.
11935 @endDefreq
11937 @DefregList {.z}
11938 @DefregListEnd {.d}
11939 @cindex @code{nl} register, and @code{.d}
11940 @cindex nested diversions
11941 @cindex diversion, nested
11942 @cindex diversion name register (@code{.z})
11943 @cindex vertical position in diversion register (@code{.d})
11944 @cindex position, vertical, in diversion, register (@code{.d})
11945 @cindex diversion, vertical position in, register (@code{.d})
11946 Diversions may be nested.  The read-only number register @code{.z}
11947 contains the name of the current diversion (this is a string-valued
11948 register).  The read-only number register @code{.d} contains the current
11949 vertical place in the diversion.  If not in a diversion it is the same
11950 as register @code{nl}.
11951 @endDefreg
11953 @Defreg {.h}
11954 @cindex high-water mark register (@code{.h})
11955 @cindex mark, high-water, register (@code{.h})
11956 @cindex position of lowest text line (@code{.h})
11957 @cindex text line, position of lowest (@code{.h})
11958 The @dfn{high-water mark} on the current page.  It corresponds to the
11959 text baseline of the lowest line on the page.  This is a read-only
11960 register.
11962 @Example
11963 .tm .h==\n[.h], nl==\n[nl]
11964     @result{} .h==0, nl==-1
11965 This is a test.
11967 .sp 2
11968 .tm .h==\n[.h], nl==\n[nl]
11969     @result{} .h==40, nl==120
11970 @endExample
11972 @cindex @code{.h} register, difference to @code{nl}
11973 @cindex @code{nl} register, difference to @code{.h}
11974 @noindent
11975 As can be seen in the previous example, empty lines are not considered
11976 in the return value of the @code{.h} register.
11977 @endDefreg
11979 @DefregList {dn}
11980 @DefregListEnd {dl}
11981 @cindex @code{dn} register, and @code{da} (@code{boxa})
11982 @cindex @code{dl} register, and @code{da} (@code{boxa})
11983 @cindex @code{da} request, and @code{dn} (@code{dl})
11984 @cindex @code{boxa} request, and @code{dn} (@code{dl})
11985 After completing a diversion, the read-write number registers @code{dn}
11986 and @code{dl} contain the vertical and horizontal size of the diversion.
11987 Note that only the just processed lines are counted: For the computation
11988 of @code{dn} and @code{dl}, the requests @code{da} and @code{boxa} are
11989 handled as if @code{di} and @code{box} had been used -- lines which have
11990 been already stored in a macro are not taken into account.
11992 @Example
11993 .\" Center text both horizontally & vertically
11995 .\" Enclose macro definitions in .eo and .ec
11996 .\" to avoid the doubling of the backslash
11998 .\" macro .(c starts centering mode
11999 .de (c
12000 .  br
12001 .  ev (c
12002 .  evc 0
12003 .  in 0
12004 .  nf
12005 .  di @@c
12007 @endExample
12008 @Example
12009 .\" macro .)c terminates centering mode
12010 .de )c
12011 .  br
12012 .  ev
12013 .  di
12014 .  nr @@s (((\n[.t]u - \n[dn]u) / 2u) - 1v)
12015 .  sp \n[@@s]u
12016 .  ce 1000
12017 .  @@c
12018 .  ce 0
12019 .  sp \n[@@s]u
12020 .  br
12021 .  fi
12022 .  rr @@s
12023 .  rm @@s
12024 .  rm @@c
12026 .\" End of macro definitions, restore escape mechanism
12028 @endExample
12029 @endDefreg
12031 @DefescList {\\!, , , }
12032 @DefescListEnd {\\?, , anything, \\?}
12033 @cindex transparent output (@code{\!}, @code{\?})
12034 @cindex output, transparent (@code{\!}, @code{\?})
12035 Prevent requests, macros, and escapes from being
12036 interpreted when read into a diversion.  Both escapes take the given text
12037 and @dfn{transparently} embed it into the diversion.  This is useful for
12038 macros which shouldn't be invoked until the diverted text is actually
12039 output.
12041 The @code{\!} escape transparently embeds text up to
12042 and including the end of the line.
12043 The @code{\?} escape transparently embeds text until the next
12044 occurrence of the @code{\?} escape.  Example:
12046 @Example
12047 \?@var{anything}\?
12048 @endExample
12050 @noindent
12051 @var{anything} may not contain newlines; use @code{\!}  to embed
12052 newlines in a diversion.  The escape sequence @code{\?} is also
12053 recognized in copy mode and turned into a single internal code; it is
12054 this code that terminates @var{anything}.  Thus the following example
12055 prints@tie{}4.
12057 @Example
12058 .nr x 1
12060 .di d
12061 \?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
12063 .nr x 2
12064 .di e
12067 .nr x 3
12068 .di f
12071 .nr x 4
12073 @endExample
12075 Both escapes read the data in copy mode.
12077 @cindex @code{\!}, in top-level diversion
12078 @cindex top-level diversion, and @code{\!}
12079 @cindex diversion, top-level, and @code{\!}
12080 If @code{\!} is used in the top-level diversion, its argument is
12081 directly embedded into the @code{gtroff} intermediate output.  This can
12082 be used for example to control a postprocessor which processes the data
12083 before it is sent to the device driver.
12085 @cindex @code{\?}, in top-level diversion
12086 @cindex top-level diversion, and @code{\?}
12087 @cindex diversion, top-level, and @code{\?}
12088 The @code{\?} escape used in the top-level diversion produces no output
12089 at all; its argument is simply ignored.
12090 @endDefesc
12092 @cindex @code{\!}, and @code{output}
12093 @cindex @code{output} request, and @code{\!}
12094 @Defreq {output, string}
12095 Emit @var{string} directly to the @code{gtroff} intermediate output
12096 (subject to copy-mode interpretation); this is similar to @code{\!} used
12097 at the top level.  An initial double quote in @var{string} is stripped off
12098 to allow initial blanks.
12100 This request can't be used before the first page has started -- if you get
12101 an error, simply insert @code{.br} before the @code{output} request.
12103 Without argument, @code{output} is ignored.
12105 Use with caution!  It is normally only needed for mark-up used by a
12106 postprocessor which does something with the output before sending it to
12107 the output device, filtering out @var{string} again.
12108 @endDefreq
12110 @Defreq {asciify, div}
12111 @cindex unformatting diversions (@code{asciify})
12112 @cindex diversion, unformatting (@code{asciify})
12113 @cindex @code{trin} request, and @code{asciify}
12114 @dfn{Unformat} the diversion specified by @var{div}
12115 in such a way that @acronym{ASCII} characters, characters translated with
12116 the @code{trin} request, space characters, and some escape sequences that
12117 were formatted and diverted are treated like ordinary input
12118 characters when the diversion is reread.  It can be also used for gross
12119 hacks; for example, the following sets register@tie{}@code{n} to@tie{}1.
12121 @Example
12122 .tr @@.
12123 .di x
12124 @@nr n 1
12127 .tr @@@@
12128 .asciify x
12130 @endExample
12132 @xref{Copy-in Mode}.
12133 @endDefreq
12135 @Defreq {unformat, div}
12136 Like @code{asciify}, unformat the specified diversion.
12137 However, @code{unformat} only unformats spaces and tabs
12138 between words.
12139 Unformatted tabs are treated as input tokens,
12140 and spaces are stretchable again.
12142 The vertical size of lines is not preserved; glyph information (font,
12143 font size, space width, etc.)@: is retained.
12144 @endDefreq
12147 @c =====================================================================
12149 @node Environments, Suppressing output, Diversions, gtroff Reference
12150 @section Environments
12151 @cindex environments
12153 It happens frequently that some text should be printed in a certain
12154 format regardless of what may be in effect at the time, for example, in
12155 a trap invoked macro to print headers and footers.  To solve this
12156 @code{gtroff} processes text in @dfn{environments}.  An
12157 environment contains most of the parameters that control text
12158 processing.  It is possible to switch amongst these environments; by
12159 default @code{gtroff} processes text in environment@tie{}0.  The
12160 following is the information kept in an environment.
12162 @itemize @bullet
12163 @item
12164 font parameters (size, family, style, glyph height and slant, space
12165 and sentence space size)
12167 @item
12168 page parameters (line length, title length, vertical spacing,
12169 line spacing, indentation, line numbering, centering, right-justifying,
12170 underlining, hyphenation data)
12172 @item
12173 fill and adjust mode
12175 @item
12176 tab stops, tab and leader characters, escape character,
12177 no-break and hyphen indicators, margin character data
12179 @item
12180 partially collected lines
12182 @item
12183 input traps
12185 @item
12186 drawing and fill colours
12187 @end itemize
12189 These environments may be given arbitrary names (see @ref{Identifiers},
12190 for more info).  Old versions of @code{troff} only had environments
12191 named @samp{0}, @samp{1}, and @samp{2}.
12193 @DefreqList {ev, [@Var{env}]}
12194 @DefregListEnd {.ev}
12195 @cindex switching environments (@code{ev})
12196 @cindex environment, switching (@code{ev})
12197 @cindex environment number/name register (@code{.ev})
12198 Switch to another environment.  The argument @var{env} is the name of
12199 the environment to switch to.  With no argument, @code{gtroff} switches
12200 back to the previous environment.  There is no limit on the number of
12201 named environments; they are created the first time that they are
12202 referenced.  The @code{.ev} read-only register contains the name or
12203 number of the current environment.  This is a string-valued register.
12205 Note that a call to @code{ev} (with argument) pushes the previously
12206 active environment onto a stack.  If, say, environments @samp{foo},
12207 @samp{bar}, and @samp{zap} are called (in that order), the first
12208 @code{ev} request without parameter switches back to environment
12209 @samp{bar} (which is popped off the stack), and a second call
12210 switches back to environment @samp{foo}.
12212 Here is an example:
12214 @Example
12215 .ev footnote-env
12216 .fam N
12217 .ps 6
12218 .vs 8
12219 .ll -.5i
12224 .ev footnote-env
12225 \(dg Note the large, friendly letters.
12227 @endExample
12228 @endDefreq
12230 @Defreq {evc, env}
12231 @cindex copying environment (@code{evc})
12232 @cindex environment, copying (@code{evc})
12233 Copy the environment @var{env} into the current environment.
12235 The following environment data is not copied:
12237 @itemize @bullet
12238 @item
12239 Partially filled lines.
12241 @item
12242 The status whether the previous line was interrupted.
12244 @item
12245 The number of lines still to center, or to right-justify, or to underline
12246 (with or without underlined spaces); they are set to zero.
12248 @item
12249 The status whether a temporary indent is active.
12251 @item
12252 Input traps and its associated data.
12254 @item
12255 Line numbering mode is disabled; it can be reactivated with
12256 @w{@samp{.nm +0}}.
12258 @item
12259 The number of consecutive hyphenated lines (set to zero).
12260 @end itemize
12261 @endDefreq
12263 @DefregList {.w}
12264 @DefregItem {.cht}
12265 @DefregItem {.cdp}
12266 @DefregListEnd {.csk}
12267 @cindex environment, dimensions of last glyph (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
12268 @cindex width, of last glyph (@code{.w})
12269 @cindex height, of last glyph (@code{.cht})
12270 @cindex depth, of last glyph (@code{.cdp})
12271 @cindex skew, of last glyph (@code{.csk})
12272 @cindex last glyph, dimensions (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
12273 @cindex glyph, last, dimensions (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
12274 The @code{\n[.w]} register contains the
12275 width of the last glyph added to the current environment.
12277 The @code{\n[.cht]} register contains the
12278 height of the last glyph added to the current environment.
12280 The @code{\n[.cdp]} register contains the
12281 depth of the last glyph added to the current environment.
12282 It is positive for glyphs extending below the baseline.
12284 The @code{\n[.csk]} register contains the
12285 @dfn{skew} (how far to the right of the glyph's center
12286 that @code{gtroff} should place an accent)
12287 of the last glyph added to the current environment.
12288 @endDefreg
12290 @Defreg {.n}
12291 @cindex environment, previous line length (@code{.n})
12292 @cindex line length, previous (@code{.n})
12293 @cindex length of previous line (@code{.n})
12294 @cindex previous line length (@code{.n})
12295 The @code{\n[.n]} register contains the
12296 length of the previous output line in the current environment.
12297 @endDefreg
12300 @c =====================================================================
12302 @node Suppressing output, Colors, Environments, gtroff Reference
12303 @section Suppressing output
12305 @Defesc {\\O, , num, }
12306 @cindex suppressing output (@code{\O})
12307 @cindex output, suppressing (@code{\O})
12308 Disable or enable output depending on the value of @var{num}:
12310 @table @samp
12311 @item \O0
12312 Disable any glyphs from being emitted to the device driver, provided that
12313 the escape occurs at the outer level (see @code{\O[3]} and @code{\O[4]}).
12314 Motion is not suppressed so effectively @code{\O[0]} means @emph{pen up}.
12316 @item \O1
12317 Enable output of glyphs, provided that the escape occurs at the outer
12318 level.
12319 @end table
12321 @vindex opminx
12322 @vindex opminy
12323 @vindex opmaxx
12324 @vindex opmaxy
12325 @code{\O0} and @code{\O1} also reset the four registers @samp{opminx},
12326 @samp{opminy}, @samp{opmaxx}, and @samp{opmaxy} to @minus{}1.
12327 @xref{Register Index}.  These four registers mark the top left and
12328 bottom right hand corners of a box which encompasses all written glyphs.
12330 For example the input text:
12332 @Example
12333 Hello \O[0]world \O[1]this is a test.
12334 @endExample
12336 @noindent
12337 produces the following output:
12339 @Example
12340 Hello       this is a test.
12341 @endExample
12343 @table @samp
12344 @item \O2
12345 Provided that the escape occurs at the outer level, enable output of
12346 glyphs and also write out to @code{stderr} the page number and four
12347 registers encompassing the glyphs previously written since the last call
12348 to @code{\O}.
12350 @item \O3
12351 Begin a nesting level.  At start-up, @code{gtroff} is at outer level.
12353 @item \O4
12354 End a nesting level.
12356 @item \O[5@var{P}@var{filename}]
12357 This escape is @code{grohtml} specific.  Provided that this escape
12358 occurs at the outer nesting level write the @code{filename} to
12359 @code{stderr}.  The position of the image, @var{P}, must be specified
12360 and must be one of @code{l}, @code{r}, @code{c}, or@tie{}@code{i} (left,
12361 right, centered, inline).  @var{filename} will be associated with the
12362 production of the next inline image.
12363 @end table
12364 @endDefesc
12366 @c =====================================================================
12368 @node Colors, I/O, Suppressing output, gtroff Reference
12369 @section Colors
12370 @cindex colors
12372 @DefreqList {color, [@Var{n}]}
12373 @DefregListEnd {.color}
12374 If @var{n} is missing or non-zero, activate colors (this is the default);
12375 otherwise, turn it off.
12377 The read-only number register @code{.color} is@tie{}1 if colors are active,
12378 0@tie{}otherwise.
12380 Internally, @code{color} sets a global flag; it does not produce a token.
12381 Similar to the @code{cp} request, you should use it at the beginning of
12382 your document to control color output.
12384 Colors can be also turned off with the @option{-c} command line option.
12385 @endDefreq
12387 @Defreq {defcolor, ident scheme color_components}
12388 Define color with name @var{ident}.  @var{scheme} can be one of  the
12389 following values: @code{rgb} (three components), @code{cmy} (three
12390 components), @code{cmyk} (four components), and @code{gray} or
12391 @code{grey} (one component).
12393 @cindex default color
12394 @cindex color, default
12395 Color components can be given either as a hexadecimal string or as
12396 positive decimal integers in the range 0--65535.  A hexadecimal string
12397 contains all color components concatenated.  It must start with either
12398 @code{#} or @code{##}; the former specifies hex values in the range
12399 0--255 (which are internally multiplied by@tie{}257), the latter in the
12400 range 0--65535.  Examples: @code{#FFC0CB} (pink), @code{##ffff0000ffff}
12401 (magenta).  The default color name @c{default} can't be redefined; its
12402 value is device-specific (usually black).  It is possible that the
12403 default color for @code{\m} and @code{\M} is not identical.
12405 @cindex @code{f} unit, and colors
12406 @cindex unit, @code{f}, and colors
12407 A new scaling indicator@tie{}@code{f} has been introduced which multiplies
12408 its value by 65536; this makes it convenient to specify color components
12409 as fractions in the range 0 to@tie{}1 (1f equals 65536u).  Example:
12411 @Example
12412 .defcolor darkgreen rgb 0.1f 0.5f 0.2f
12413 @endExample
12415 Note that @code{f} is the default scaling indicator for the
12416 @code{defcolor} request, thus the above statement is equivalent to
12418 @Example
12419 .defcolor darkgreen rgb 0.1 0.5 0.2
12420 @endExample
12421 @endDefreq
12423 @DefreqList {gcolor, [@Var{color}]}
12424 @DefescItem {\\m, , c, }
12425 @DefescItem {\\m, @lparen{}, co, }
12426 @DefescItem {\\m, @lbrack{}, color, @rbrack}
12427 @DefregListEnd {.m}
12428 Set (glyph) drawing color.  The following examples show how to turn the
12429 next four words red.
12431 @Example
12432 .gcolor red
12433 these are in red
12434 .gcolor
12435 and these words are in black.
12436 @endExample
12438 @Example
12439 \m[red]these are in red\m[] and these words are in black.
12440 @endExample
12442 The escape @code{\m[]} returns to the previous color, as does a call to
12443 @code{gcolor} without an argument.
12445 @cindex drawing color name register (@code{.m})
12446 @cindex name, drawing color, register (@code{.m})
12447 @cindex color name, drawing, register (@code{.m})
12448 The name of the current drawing color is available in the read-only,
12449 string-valued number register @samp{.m}.
12451 The drawing color is associated with the current environment
12452 (@pxref{Environments}).
12454 Note that @code{\m} doesn't produce an input token in @code{gtroff}.
12455 As a consequence, it can be used in requests like @code{mc} (which
12456 expects a single character as an argument) to change the color on
12457 the fly:
12459 @Example
12460 .mc \m[red]x\m[]
12461 @endExample
12462 @endDefesc
12464 @DefreqList {fcolor, [@Var{color}]}
12465 @DefescItem {\\M, , c, }
12466 @DefescItem {\\M, @lparen{}, co, }
12467 @DefescItem {\\M, @lbrack{}, color, @rbrack}
12468 @DefregListEnd {.M}
12469 Set fill (background) color for filled objects drawn with the
12470 @code{\D'@dots{}'} commands.
12472 A red ellipse can be created with the following code:
12474 @Example
12475 \M[red]\h'0.5i'\D'E 2i 1i'\M[]
12476 @endExample
12478 The escape @code{\M[]} returns to the previous fill color, as does a call to
12479 @code{fcolor} without an argument.
12481 @cindex background color name register (@code{.M})
12482 @cindex name, background color, register (@code{.M})
12483 @cindex color name, background, register (@code{.M})
12484 @cindex fill color name register (@code{.M})
12485 @cindex name, fill color, register (@code{.M})
12486 @cindex color name, fill, register (@code{.M})
12487 The name of the current fill (background) color is available in the
12488 read-only, string-valued number register @samp{.M}.
12490 The fill color is associated with the current environment
12491 (@pxref{Environments}).
12493 Note that @code{\M} doesn't produce an input token in @code{gtroff}.
12494 @endDefesc
12497 @c =====================================================================
12499 @node I/O, Postprocessor Access, Colors, gtroff Reference
12500 @section I/O
12501 @cindex i/o
12502 @cindex input and output requests
12503 @cindex requests for input and output
12504 @cindex output and input requests
12506 @code{gtroff} has several requests for including files:
12508 @Defreq {so, file}
12509 @cindex including a file (@code{so})
12510 @cindex file, inclusion (@code{so})
12511 Read in the specified @var{file} and
12512 includes it in place of the @code{so} request.  This is quite useful for
12513 large documents, e.g.@: keeping each chapter in a separate file.
12514 @xref{gsoelim}, for more information.
12516 Since @code{gtroff} replaces the @code{so} request with the contents
12517 of @code{file}, it makes a difference whether the data is terminated with
12518 a newline or not: Assuming that file @file{xxx} contains the word
12519 @samp{foo} without a final newline, this
12521 @Example
12522 This is
12523 .so xxx
12525 @endExample
12527 @noindent
12528 yields @samp{This is foobar}.
12530 The search path for @var{file} can be controlled with the @option{-I} command
12531 line option.
12532 @endDefreq
12534 @Defreq {pso, command}
12535 Read the standard output from the specified @var{command}
12536 and includes it in place of the @code{pso} request.
12538 @cindex safer mode
12539 @cindex mode, safer
12540 @cindex unsafe mode
12541 @cindex mode, unsafe
12542 This request causes an error if used in safer mode (which is the default).
12543 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
12544 mode.
12546 The comment regarding a final newline for the @code{so} request is valid
12547 for @code{pso} also.
12548 @endDefreq
12550 @Defreq {mso, file}
12551 Identical to the @code{so} request except that @code{gtroff} searches for
12552 the specified @var{file} in the same directories as macro files for the
12553 the @option{-m} command line option.  If the file name to be included
12554 has the form @file{@var{name}.tmac} and it isn't found, @code{mso} tries
12555 to include @file{tmac.@var{name}} and vice versa.
12556 @endDefreq
12558 @DefreqList {trf, file}
12559 @DefreqListEnd {cf, file}
12560 @cindex transparent output (@code{cf}, @code{trf})
12561 @cindex output, transparent (@code{cf}, @code{trf})
12562 Transparently output the contents of @var{file}.  Each line is output
12563 as if it were preceded by @code{\!}; however, the lines are not subject
12564 to copy mode interpretation.  If the file does not end with a newline,
12565 then a newline is added (@code{trf} only).  For example, to define a
12566 macro@tie{}@code{x} containing the contents of file@tie{}@file{f}, use
12568 @Example
12569 .di x
12570 .trf f
12572 @endExample
12574 Both @code{trf} and @code{cf}, when used in a diversion,
12575 embeds an object in the diversion which, when reread, causes the
12576 contents of @var{file} to be transparently copied through to the
12577 output.  In @acronym{UNIX} @code{troff}, the contents of @var{file}
12578 is immediately copied through to the output regardless of whether there
12579 is a current diversion; this behaviour is so anomalous that it must be
12580 considered a bug.
12582 @cindex @code{trf} request, and invalid characters
12583 @cindex characters, invalid for @code{trf} request
12584 @cindex invalid characters for @code{trf} request
12585 While @code{cf} copies the contents of @var{file} completely unprocessed,
12586 @code{trf} disallows characters such as NUL that are not valid
12587 @code{gtroff} input characters (@pxref{Identifiers}).
12589 Both requests cause a line break.
12590 @endDefreq
12592 @Defreq {nx, [@Var{file}]}
12593 @cindex processing next file (@code{nx})
12594 @cindex file, processing next (@code{nx})
12595 @cindex next file, processing (@code{nx})
12596 Force @code{gtroff} to continue processing of
12597 the file specified as an argument.  If no argument is given, immediately
12598 jump to the end of file.
12599 @endDefreq
12601 @Defreq {rd, [@Var{prompt} [@Var{arg1} @Var{arg2} @dots{}]]}
12602 @cindex reading from standard input (@code{rd})
12603 @cindex standard input, reading from (@code{rd})
12604 @cindex input, standard, reading from (@code{rd})
12605 Read from standard input, and include what is read as though it
12606 were part of the input file.  Text is read until a blank line
12607 is encountered.
12609 If standard input is a TTY input device (keyboard), write @var{prompt}
12610 to standard error, followed by a colon (or send BEL for a beep if no
12611 argument is given).
12613 Arguments after @var{prompt} are available for the input.  For example,
12614 the line
12616 @Example
12617 .rd data foo bar
12618 @endExample
12620 with the input @w{@samp{This is \$2.}} prints
12622 @Example
12623 This is bar.
12624 @endExample
12625 @endDefreq
12627 @cindex form letters
12628 @cindex letters, form
12629 Using the @code{nx} and @code{rd} requests,
12630 it is easy to set up form letters.  The form
12631 letter template is constructed like this, putting the following lines
12632 into a file called @file{repeat.let}:
12634 @Example
12636 \*(td
12637 .sp 2
12643 Body of letter.
12645 .nx repeat.let
12646 @endExample
12648 @cindex @code{ex} request, used with @code{nx} and @code{rd}
12649 @noindent
12650 When this is run, a file containing the following lines should be
12651 redirected in.  Note that requests included in this file are executed
12652 as though they were part of the form letter.  The last block of input
12653 is the @code{ex} request which tells @code{groff} to stop processing.  If
12654 this was not there, @code{groff} would not know when to stop.
12656 @Example
12657 Trent A. Fisher
12658 708 NW 19th Av., #202
12659 Portland, OR  97209
12661 Dear Trent,
12663 Len Adollar
12664 4315 Sierra Vista
12665 San Diego, CA  92103
12667 Dear Mr. Adollar,
12670 @endExample
12672 @Defreq {pi, pipe}
12673 Pipe the output of @code{gtroff} to the shell command(s)
12674 specified by @var{pipe}.  This request must occur before
12675 @code{gtroff} has a chance to print anything.
12677 @cindex safer mode
12678 @cindex mode, safer
12679 @cindex unsafe mode
12680 @cindex mode, unsafe
12681 @code{pi} causes an error if used in safer mode (which is the default).
12682 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
12683 mode.
12685 Multiple calls to @code{pi} are allowed, acting as a chain.  For example,
12687 @Example
12688 .pi foo
12689 .pi bar
12691 @endExample
12693 is the same as @w{@samp{.pi foo | bar}}.
12695 @cindex @code{groff}, and @code{pi} request
12696 @cindex @code{pi} request, and @code{groff}
12697 Note that the intermediate output format of @code{gtroff} is piped to
12698 the specified commands.  Consequently, calling @code{groff} without the
12699 @option{-Z} option normally causes a fatal error.
12700 @endDefreq
12702 @DefreqList {sy, cmds}
12703 @DefregListEnd {systat}
12704 Execute the shell command(s) specified by @var{cmds}.  The output is not
12705 saved anyplace, so it is up to the user to do so.
12707 @cindex safer mode
12708 @cindex mode, safer
12709 @cindex unsafe mode
12710 @cindex mode, unsafe
12711 This request causes an error if used in safer mode (which is the default).
12712 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
12713 mode.
12715 For example, the following code fragment introduces the current time into a
12716 document:
12718 @cindex time, current
12719 @cindex current time
12720 @pindex perl
12721 @Example
12722 .sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
12723              (localtime(time))[2,1,0]' > /tmp/x\n[$$]
12724 .so /tmp/x\n[$$]
12725 .sy rm /tmp/x\n[$$]
12726 \nH:\nM:\nS
12727 @endExample
12729 @noindent
12730 Note that this works by having the @code{perl} script (run by @code{sy})
12731 print out the @code{nr} requests which set the number registers
12732 @code{H}, @code{M}, and @code{S}, and then reads those commands in with
12733 the @code{so} request.
12735 For most practical purposes, the number registers @code{seconds},
12736 @code{minutes}, and @code{hours} which are initialized at start-up of
12737 @code{gtroff} should be sufficient.  Use the @code{af} request to get a
12738 formatted output:
12740 @Example
12741 .af hours 00
12742 .af minutes 00
12743 .af seconds 00
12744 \n[hours]:\n[minutes]:\n[seconds]
12745 @endExample
12747 @cindex @code{system()} return value register (@code{systat})
12748 The @code{systat} read-write number register contains the return value
12749 of the @code{system()} function executed by the last @code{sy} request.
12750 @endDefreq
12752 @DefreqList {open, stream file}
12753 @DefreqListEnd {opena, stream file}
12754 @cindex opening file (@code{open})
12755 @cindex file, opening (@code{open})
12756 @cindex appending to a file (@code{opena})
12757 @cindex file, appending to (@code{opena})
12758 Open the specified @var{file} for writing and
12759 associates the specified @var{stream} with it.
12761 The @code{opena} request is like @code{open}, but if the file exists,
12762 append to it instead of truncating it.
12764 @cindex safer mode
12765 @cindex mode, safer
12766 @cindex unsafe mode
12767 @cindex mode, unsafe
12768 Both @code{open} and @code{opena} cause an error if used in safer mode
12769 (which is the default).  Use @code{groff}'s or @code{troff}'s @option{-U}
12770 option to activate unsafe mode.
12771 @endDefreq
12773 @DefreqList {write, stream data}
12774 @DefreqListEnd {writec, stream data}
12775 @cindex copy-in mode, and @code{write} requests
12776 @cindex mode, copy-in, and @code{write} requests
12777 @cindex writing to file (@code{write})
12778 @cindex file, writing to (@code{write})
12779 Write to the file associated with the specified @var{stream}.
12780 The stream must previously have
12781 been the subject of an open request.  The remainder of the line is
12782 interpreted as the @code{ds} request reads its second argument: A
12783 leading @samp{"} is stripped, and it is read in copy-in mode.
12785 The @code{writec} request is like @code{write}, but only
12786 @code{write} appends a newline to the data.
12787 @endDefreq
12789 @Defreq {writem, stream xx}
12790 @cindex @code{asciify} request, and @code{writem}
12791 Write the contents of the macro or string @var{xx}
12792 to the file associated with the specified @var{stream}.
12794 @var{xx} is read in copy mode, i.e., already formatted elements are
12795 ignored.  Consequently, diversions must be unformatted with the
12796 @code{asciify} request before calling @code{writem}.  Usually, this
12797 means a loss of information.
12798 @endDefreq
12800 @Defreq {close, stream}
12801 @cindex closing file (@code{close})
12802 @cindex file, closing (@code{close})
12803 Close the specified @var{stream};
12804 the stream is no longer an acceptable argument to the
12805 @code{write} request.
12807 Here a simple macro to write an index entry.
12809 @Example
12810 .open idx test.idx
12812 .de IX
12813 .  write idx \\n[%] \\$*
12816 .IX test entry
12818 .close idx
12819 @endExample
12820 @endDefreq
12822 @DefescList {\\V, , e, }
12823 @DefescItem {\\V, @lparen{}, ev, }
12824 @DefescListEnd {\\V, @lbrack{}, env, @rbrack}
12825 Interpolate the contents of the specified environment variable
12826 @var{env} (one-character name@tie{}@var{e}, two-character name @var{ev})
12827 as returned by the function @code{getenv}.  @code{\V} is interpreted
12828 in copy-in mode.
12829 @endDefesc
12832 @c =====================================================================
12834 @node Postprocessor Access, Miscellaneous, I/O, gtroff Reference
12835 @section Postprocessor Access
12836 @cindex postprocessor access
12837 @cindex access of postprocessor
12839 There are two escapes which give information directly to the
12840 postprocessor.  This is particularly useful for embedding
12841 @sc{PostScript} into the final document.
12843 @Defesc {\\X, ', xxx, '}
12844 Embeds its argument into the @code{gtroff}
12845 output preceded with @w{@samp{x X}}.
12847 @cindex @code{\&}, in @code{\X}
12848 @cindex @code{\)}, in @code{\X}
12849 @cindex @code{\%}, in @code{\X}
12850 @ifnotinfo
12851 @cindex @code{\:}, in @code{\X}
12852 @end ifnotinfo
12853 @ifinfo
12854 @cindex @code{\@r{<colon>}}, in @code{\X}
12855 @end ifinfo
12856 The escapes @code{\&}, @code{\)}, @code{\%}, and @code{\:} are ignored
12857 within @code{\X}, @w{@samp{\ }} and @code{\~} are converted to single
12858 space characters.  All other escapes (except @code{\\} which produces a
12859 backslash) cause an error.
12861 @kindex use_charnames_in_special
12862 @pindex DESC@r{, and @code{use_charnames_in_special}}
12863 @cindex @code{\X}, and special characters
12864 If the @samp{use_charnames_in_special} keyword is set in the @file{DESC}
12865 file, special characters no longer cause an error; the name @var{xx} is
12866 represented as @samp{\(@var{xx})} in the @w{@samp{x X}} output command.
12867 Additionally, the backslash is represented as @code{\\}.
12869 @samp{use_charnames_in_special} is currently used by @code{grohtml} only.
12870 @endDefesc
12872 @DefescList {\\Y, , n, }
12873 @DefescItem {\\Y, @lparen{}, nm, }
12874 @DefescListEnd {\\Y, @lbrack{}, name, @rbrack}
12875 This is approximately equivalent to @samp{\X'\*[@var{name}]'}
12876 (one-character name@tie{}@var{n}, two-character name @var{nm}).
12877 However, the contents of the string or macro @var{name} are not
12878 interpreted; also it is permitted for @var{name} to have been defined
12879 as a macro and thus contain newlines (it is not permitted for the
12880 argument to @code{\X} to contain newlines).  The inclusion of
12881 newlines requires an extension to the @acronym{UNIX} @code{troff}
12882 output format, and confuses drivers that do not know about this
12883 extension (@pxref{Device Control Commands}).
12884 @endDefesc
12886 @xref{Output Devices}.
12889 @c =====================================================================
12891 @node Miscellaneous, Gtroff Internals, Postprocessor Access, gtroff Reference
12892 @section Miscellaneous
12894 This section documents parts of @code{gtroff} which cannot (yet) be
12895 categorized elsewhere in this manual.
12897 @Defreq {nm, [@Var{start} [@Var{inc} [@Var{space} [@Var{indent}]]]]}
12898 @cindex printing line numbers (@code{nm})
12899 @cindex line numbers, printing (@code{nm})
12900 @cindex numbers, line, printing (@code{nm})
12901 Print line numbers.
12902 @var{start} is the line number of the @emph{next}
12903 output line.  @var{inc} indicates which line numbers are printed.
12904 For example, the value@tie{}5 means to emit only line numbers which
12905 are multiples of@tie{}5; this defaults to@tie{}1.  @var{space} is the
12906 space to be left between the number and the text; this defaults to
12907 one digit space.  The fourth argument is the indentation of the line
12908 numbers, defaulting to zero.  Both @var{space} and @var{indent} are
12909 given as multiples of digit spaces; they can be negative also.
12910 Without any arguments, line numbers are turned off.
12912 @code{gtroff} reserves three digit spaces for the line number (which is
12913 printed right-justified) plus the amount given by @var{indent}; the
12914 output lines are concatenated to the line numbers, separated by
12915 @var{space}, and @emph{without} reducing the line length.  Depending
12916 on the value of the horizontal page offset (as set with the
12917 @code{po} request), line numbers which are longer than the reserved
12918 space stick out to the left, or the whole line is moved to the right.
12920 Parameters corresponding to missing arguments are not changed; any
12921 non-digit argument (to be more precise, any argument starting with a
12922 character valid as a delimiter for identifiers) is also treated as
12923 missing.
12925 If line numbering has been disabled with a call to @code{nm} without
12926 an argument, it can be reactivated with @samp{.nm +0}, using the
12927 previously active line numbering parameters.
12929 The parameters of @code{nm} are associated with the current environment
12930 (@pxref{Environments}).  The current output line number is available
12931 in the number register @code{ln}.
12933 @Example
12934 .po 1m
12935 .ll 2i
12936 This test shows how line numbering works with groff.
12937 .nm 999
12938 This test shows how line numbering works with groff.
12940 .nm xxx 3 2
12941 .ll -\w'0'u
12942 This test shows how line numbering works with groff.
12943 .nn 2
12944 This test shows how line numbering works with groff.
12945 @endExample
12947 @noindent
12948 And here the result:
12950 @Example
12951  This  test shows how
12952  line numbering works
12953  999 with   groff.   This
12954 1000 test shows how  line
12955 1001 numbering works with
12956 1002 groff.
12957       This test shows how
12958       line      numbering
12959  works  with  groff.
12960  This test shows how
12961 1005  line      numbering
12962       works with groff.
12963 @endExample
12964 @endDefreq
12966 @Defreq {nn, [@Var{skip}]}
12967 Temporarily turn off line numbering.  The argument is the number
12968 of lines not to be numbered; this defaults to@tie{}1.
12969 @endDefreq
12971 @Defreq {mc, glyph [@Var{dist}]}
12972 @cindex margin glyph (@code{mc})
12973 @cindex glyph, for margins (@code{mc})
12974 Print a @dfn{margin character} to the right of the
12975 text.@footnote{@dfn{Margin character} is a misnomer since it is an
12976 output glyph.}  The first argument is the glyph to be
12977 printed.  The second argument is the distance away from the right
12978 margin.  If missing, the previously set value is used; default is
12979 10@dmn{pt}).  For text lines that are too long (that is, longer than
12980 the text length plus @var{dist}), the margin character is directly
12981 appended to the lines.
12983 With no arguments the margin character is turned off.
12984 If this occurs before a break, no margin character is printed.
12986 For compatibility with @acronym{AT&T} @code{troff}, a call to @code{mc}
12987 to set the margin character can't be undone immediately; at least one
12988 line gets a margin character.  Thus
12990 @Example
12991 .ll 1i
12992 .mc \[br]
12997 @endExample
12999 @noindent
13000 produces
13002 @Example
13003 xxx        |
13005 @endExample
13007 @cindex @code{tl} request, and @code{mc}
13008 For empty lines and lines produced by the @code{tl} request no margin
13009 character is emitted.
13011 The margin character is associated with the current environment
13012 (@pxref{Environments}).
13014 @pindex nrchbar
13015 @pindex changebar
13016 This is quite useful for indicating text that has changed, and, in fact,
13017 there are programs available for doing this (they are called
13018 @code{nrchbar} and @code{changebar} and can be found in any
13019 @samp{comp.sources.unix} archive).
13021 @Example
13022 .ll 3i
13023 .mc |
13024 This paragraph is highlighted with a margin
13025 character.
13027 Note that vertical space isn't marked.
13031 But we can fake it with `\&'.
13032 @endExample
13034 Result:
13036 @Example
13037 This  paragraph is highlighted |
13038 with a margin character.       |
13040 Note that vertical space isn't |
13041 marked.                        |
13042                                |
13043 But we can fake it with `\&'.  |
13044 @endExample
13045 @endDefreq
13047 @DefreqList {psbb, filename}
13048 @DefregItem {llx}
13049 @DefregItem {lly}
13050 @DefregItem {urx}
13051 @DefregListEnd {ury}
13052 @cindex PostScript, bounding box
13053 @cindex bounding box
13054 Retrieve the bounding box of the PostScript image
13055 found in @var{filename}.
13056 The file must conform to
13057 Adobe's @dfn{Document Structuring Conventions} (DSC);
13058 the command searches for a @code{%%BoundingBox} comment
13059 and extracts the bounding box values into the number registers
13060 @code{llx}, @code{lly}, @code{urx}, and @code{ury}.
13061 If an error occurs (for example, @code{psbb} cannot find
13062 the @code{%%BoundingBox} comment),
13063 it sets the four number registers to zero.
13065 The search path for @var{filename} can be controlled with the @option{-I}
13066 command line option.
13067 @endDefreq
13070 @c =====================================================================
13072 @node Gtroff Internals, Debugging, Miscellaneous, gtroff Reference
13073 @section @code{gtroff} Internals
13075 @cindex input token
13076 @cindex token, input
13077 @cindex output node
13078 @cindex node, output
13079 @code{gtroff} processes input in three steps.  One or more input
13080 characters are converted to an @dfn{input token}.@footnote{Except the
13081 escapes @code{\f}, @code{\F}, @code{\H}, @code{\m}, @code{\M}, @code{\R},
13082 @code{\s}, and @code{\S} which are processed immediately if not in
13083 copy-in mode.}  Then, one or more input tokens are converted to an
13084 @dfn{output node}.  Finally, output nodes are converted to the
13085 intermediate output language understood by all output devices.
13087 Actually, before step one happens, @code{gtroff} converts certain
13088 escape sequences into reserved input characters (not accessible by
13089 the user); such reserved characters are used for other internal
13090 processing also -- this is the very reason why not all characters
13091 are valid input.  @xref{Identifiers}, for more on this topic.
13093 For example, the input string @samp{fi\[:u]} is converted into a
13094 character token @samp{f}, a character token @samp{i}, and a special
13095 token @samp{:u} (representing u@tie{}umlaut).  Later on, the character
13096 tokens @samp{f} and @samp{i} are merged to a single output node
13097 representing the ligature glyph @samp{fi} (provided the current font
13098 has a glyph for this ligature); the same happens with @samp{:u}.  All
13099 output glyph nodes are `processed' which means that they are invariably
13100 associated with a given font, font size, advance width, etc.  During
13101 the formatting process, @code{gtroff} itself adds various nodes to
13102 control the data flow.
13104 Macros, diversions, and strings collect elements in two chained lists:
13105 a list of input tokens which have been passed unprocessed, and a list
13106 of output nodes.  Consider the following the diversion.
13108 @Example
13109 .di xxx
13115 @endExample
13117 @noindent
13118 It contains these elements.
13120 @multitable {@i{vertical size node}} {token list} {element number}
13121 @item node list               @tab token list @tab element number
13123 @item @i{line start node}     @tab ---        @tab 1
13124 @item @i{glyph node @code{a}} @tab ---        @tab 2
13125 @item @i{word space node}     @tab ---        @tab 3
13126 @item ---                     @tab @code{b}   @tab 4
13127 @item ---                     @tab @code{\n}  @tab 5
13128 @item @i{glyph node @code{c}} @tab ---        @tab 6
13129 @item @i{vertical size node}  @tab ---        @tab 7
13130 @item @i{vertical size node}  @tab ---        @tab 8
13131 @item ---                     @tab @code{\n}  @tab 9
13132 @end multitable
13134 @cindex @code{\v}, internal representation
13135 @noindent
13136 Elements 1, 7, and@tie{}8 are inserted by @code{gtroff}; the latter two
13137 (which are always present) specify the vertical extent of the last
13138 line, possibly modified by @code{\x}.  The @code{br} request finishes
13139 the current partial line, inserting a newline input token which is
13140 subsequently converted to a space when the diversion is reread.  Note
13141 that the word space node has a fixed width which isn't stretchable
13142 anymore.  To convert horizontal space nodes back to input tokens, use
13143 the @code{unformat} request.
13145 Macros only contain elements in the token list (and the node list is
13146 empty); diversions and strings can contain elements in both lists.
13148 Note that the @code{chop} request simply reduces the number of elements in a
13149 macro, string, or diversion by one.  Exceptions are @dfn{compatibility save}
13150 and @dfn{compatibility ignore} input tokens which are ignored.  The
13151 @code{substring} request also ignores those input tokens.
13153 Some requests like @code{tr} or @code{cflags} work on glyph
13154 identifiers only; this means that the associated glyph can be changed
13155 without destroying this association.  This can be very helpful for
13156 substituting glyphs.  In the following example, we assume that
13157 glyph @samp{foo} isn't available by default, so we provide a
13158 substitution using the @code{fchar} request and map it to input
13159 character @samp{x}.
13161 @Example
13162 .fchar \[foo] foo
13163 .tr x \[foo]
13164 @endExample
13166 @noindent
13167 Now let us assume that we install an additional special font
13168 @samp{bar} which has glyph @samp{foo}.
13170 @Example
13171 .special bar
13172 .rchar \[foo]
13173 @endExample
13175 @noindent
13176 Since glyphs defined with @code{fchar} are searched before glyphs
13177 in special fonts, we must call @code{rchar} to remove the definition
13178 of the fallback glyph.  Anyway, the translation is still active;
13179 @samp{x} now maps to the real glyph @samp{foo}.
13181 @cindex compatibility mode, and parameters
13182 @cindex mode, compatibility, and parameters
13183 @cindex arguments, and compatibility mode
13184 @cindex parameters, and compatibility mode
13185 @cindex macro arguments, and compatibility mode
13186 @cindex request arguments, and compatibility mode
13187 Macro and request arguments preserve the compatibility mode:
13189 @Example
13190 .cp 1     \" switch to compatibility mode
13191 .de xx
13192 \\$1
13194 .cp 0     \" switch compatibility mode off
13195 .xx caf\['e]
13196     @result{} café
13197 @endExample
13199 @noindent
13200 Since compatibility mode is on while @code{de} is called, the macro
13201 @code{xx} activates compatibility mode while executing.  Argument
13202 @code{$1} can still be handled properly because it inherits the
13203 compatibility mode status which was active at the point where @code{xx}
13204 is called.
13206 After expansion of the parameters, the compatibility save and restore
13207 tokens are removed.
13210 @c =====================================================================
13212 @node Debugging, Implementation Differences, Gtroff Internals, gtroff Reference
13213 @section Debugging
13214 @cindex debugging
13216 @code{gtroff} is not easy to debug, but there are some useful features
13217 and strategies for debugging.
13219 @Defreq {lf, line [@Var{filename}]}
13220 @pindex soelim
13221 @cindex multi-file documents
13222 @cindex documents, multi-file
13223 @cindex setting input line number (@code{lf})
13224 @cindex input line number, setting (@code{lf})
13225 @cindex number, input line, setting (@code{lf})
13226 Change the line number and optionally the file name @code{gtroff} shall
13227 use for error and warning messages.  @var{line} is the input line number
13228 of the @emph{next} line.
13230 Without argument, the request is ignored.
13232 This is a debugging aid for documents which are split into many files,
13233 then put together with @code{soelim} and other preprocessors.  Usually,
13234 it isn't invoked manually.
13236 Note that other @code{troff} implementations (including the original
13237 @acronym{AT&T} version) handle @code{lf} differently.  For them,
13238 @var{line} changes the line number of the @emph{current} line.
13239 @endDefreq
13241 @DefreqList {tm, string}
13242 @DefreqItem {tm1, string}
13243 @DefreqListEnd {tmc, string}
13244 @cindex printing to stderr (@code{tm}, @code{tm1}, @code{tmc})
13245 @cindex stderr, printing to (@code{tm}, @code{tm1}, @code{tmc})
13246 Send @var{string} to the standard error output;
13247 this is very useful for printing debugging messages among other things.
13249 @var{string} is read in copy mode.
13251 The @code{tm} request ignores leading spaces of @var{string}; @code{tm1}
13252 handles its argument similar to the @code{ds} request: a leading double
13253 quote in @var{string} is stripped to allow initial blanks.
13255 The @code{tmc} request is similar to @code{tm1} but does
13256 not append a newline (as is done in @code{tm} and @code{tm1}).
13257 @endDefreq
13259 @Defreq {ab, [@Var{string}]}
13260 @cindex aborting (@code{ab})
13261 Similar to the @code{tm} request, except that
13262 it causes @code{gtroff} to stop processing.  With no argument it
13263 prints @samp{User Abort.} to standard error.
13264 @endDefreq
13266 @Defreq {ex, }
13267 @cindex @code{ex} request, use in debugging
13268 @cindex exiting (@code{ex})
13269 The @code{ex} request also causes @code{gtroff} to stop processing;
13270 see also @ref{I/O}.
13271 @endDefreq
13273 When doing something involved it is useful to leave the debugging
13274 statements in the code and have them turned on by a command line flag.
13276 @Example
13277 .if \n(DB .tm debugging output
13278 @endExample
13280 @noindent
13281 To activate these statements say
13283 @Example
13284 groff -rDB=1 file
13285 @endExample
13287 If it is known in advance that there will be many errors and no useful
13288 output, @code{gtroff} can be forced to suppress formatted output with
13289 the @option{-z} flag.
13291 @Defreq {pm, }
13292 @cindex dumping symbol table (@code{pm})
13293 @cindex symbol table, dumping (@code{pm})
13294 Print the entire symbol table on @code{stderr}.  Names of all defined
13295 macros, strings, and diversions are print together with their size in
13296 bytes.  Since @code{gtroff} sometimes adds nodes by itself, the
13297 returned size can be larger than expected.
13299 This request differs from @acronym{UNIX} @code{troff}: @code{gtroff}
13300 reports the sizes of diversions, ignores an additional argument to
13301 print only the total of the sizes, and the size isn't returned in
13302 blocks of 128 characters.
13303 @endDefreq
13305 @Defreq {pnr, }
13306 @cindex dumping number registers (@code{pnr})
13307 @cindex number registers, dumping (@code{pnr})
13308 Print the names and contents of all
13309 currently defined number registers on @code{stderr}.
13310 @endDefreq
13312 @Defreq {ptr, }
13313 @cindex dumping traps (@code{ptr})
13314 @cindex traps, dumping (@code{ptr})
13315 Print the names and positions of all traps
13316 (not including input line traps and diversion traps) on @code{stderr}.
13317 Empty slots in the page trap list are printed as well, because they can
13318 affect the priority of subsequently planted traps.
13319 @endDefreq
13321 @Defreq {fl, }
13322 @cindex flush output (@code{fl})
13323 @cindex output, flush (@code{fl})
13324 @cindex interactive use of @code{gtroff}
13325 @cindex @code{gtroff}, interactive use
13326 Instruct @code{gtroff} to flush its output immediately.  The intent
13327 is for interactive use, but this behaviour is currently not
13328 implemented in @code{gtroff}.  Contrary to @acronym{UNIX} @code{troff},
13329 TTY output is sent to a device driver also (@code{grotty}), making it
13330 non-trivial to communicate interactively.
13332 This request causes a line break.
13333 @endDefreq
13335 @Defreq {backtrace, }
13336 @cindex backtrace of input stack (@code{backtrace})
13337 @cindex input stack, backtrace (@code{backtrace})
13338 Print a backtrace of the input stack to the standard error stream.
13340 Consider the following in file @file{test}:
13342 @Example
13343 .de xxx
13344 .  backtrace
13346 .de yyy
13347 .  xxx
13350 .yyy
13351 @endExample
13353 @noindent
13354 On execution, @code{gtroff} prints the following:
13356 @Example
13357 test:2: backtrace: macro `xxx'
13358 test:5: backtrace: macro `yyy'
13359 test:8: backtrace: file `test'
13360 @endExample
13362 The option @option{-b} of @code{gtroff} internally calls a variant of
13363 this request on each error and warning.
13364 @endDefreq
13366 @Defreg {slimit}
13367 @cindex input stack, setting limit
13368 Use the @code{slimit} number register
13369 to set the maximum number of objects on the input stack.
13370 If @code{slimit} is less than or equal to@tie{}0,
13371 there is no limit set.
13372 With no limit, a buggy recursive macro can exhaust virtual memory.
13374 The default value is 1000; this is a compile-time constant.
13375 @endDefreg
13377 @Defreq {warnscale, si}
13378 Set the scaling indicator used in warnings to @var{si}.  Valid values for
13379 @var{si} are @samp{u}, @samp{i}, @samp{c}, @samp{p}, and @samp{P}.  At
13380 startup, it is set to @samp{i}.
13381 @endDefreq
13383 @Defreq {spreadwarn, [@Var{limit}]}
13384 Make @code{gtroff} emit a warning if the additional space inserted for
13385 each space between words in an output line is larger or equal to
13386 @var{limit}.  A negative value is changed to zero; no argument toggles the
13387 warning on and off without changing @var{limit}.  The default scaling
13388 indicator is @samp{m}.  At startup, @code{spreadwarn} is deactivated, and
13389 @var{limit} is set to 3@dmn{m}.
13391 For example,
13393 @Example
13394 .spreadwarn 0.2m
13395 @endExample
13397 @noindent
13398 will cause a warning if @code{gtroff} must add 0.2@dmn{m} or more for each
13399 interword space in a line.
13401 This request is active only if text is justified to both margins (using
13402 @w{@samp{.ad b}}).
13403 @endDefreq
13405 @cindex warnings
13406 @code{gtroff} has command line options for printing out more warnings
13407 (@option{-w}) and for printing backtraces (@option{-b}) when a warning
13408 or an error occurs.  The most verbose level of warnings is @option{-ww}.
13410 @DefreqList {warn, [@Var{flags}]}
13411 @DefregListEnd {.warn}
13412 @cindex level of warnings (@code{warn})
13413 @cindex warnings, level (@code{warn})
13414 Control the level of warnings checked for.  The @var{flags} are the sum
13415 of the numbers associated with each warning that is to be enabled; all
13416 other warnings are disabled.  The number associated with each warning is
13417 listed below.  For example, @w{@code{.warn 0}} disables all warnings,
13418 and @w{@code{.warn 1}} disables all warnings except that about missing
13419 glyphs.  If no argument is given, all warnings are enabled.
13421 The read-only number register @code{.warn} contains the current warning
13422 level.
13423 @endDefreq
13425 @menu
13426 * Warnings::
13427 @end menu
13429 @c ---------------------------------------------------------------------
13431 @node Warnings,  , Debugging, Debugging
13432 @subsection Warnings
13433 @cindex warnings
13435 The warnings that can be given to @code{gtroff} are divided into the
13436 following categories.  The name associated with each warning is used by
13437 the @option{-w} and @option{-W} options; the number is used by the
13438 @code{warn} request and by the @code{.warn} register.
13440 @table @samp
13441 @item char
13442 @itemx 1
13443 Non-existent glyphs.@footnote{@code{char} is a misnomer since it reports
13444 missing glyphs -- there aren't missing input characters, only invalid
13445 ones.}  This is enabled by default.
13447 @item number
13448 @itemx 2
13449 Invalid numeric expressions.  This is enabled by default.
13450 @xref{Expressions}.
13452 @item break
13453 @itemx 4
13454 @cindex fill mode
13455 @cindex mode, fill
13456 In fill mode, lines which could not be broken so that their length was
13457 less than the line length.  This is enabled by default.
13459 @item delim
13460 @itemx 8
13461 Missing or mismatched closing delimiters.
13463 @item el
13464 @itemx 16
13465 @cindex @code{ie} request, and warnings
13466 @cindex @code{el} request, and warnings
13467 Use of the @code{el} request with no matching @code{ie} request.
13468 @xref{if-else}.
13470 @item scale
13471 @itemx 32
13472 Meaningless scaling indicators.
13474 @item range
13475 @itemx 64
13476 Out of range arguments.
13478 @item syntax
13479 @itemx 128
13480 Dubious syntax in numeric expressions.
13482 @item di
13483 @itemx 256
13484 @cindex @code{di} request, and warnings
13485 @cindex @code{da} request, and warnings
13486 Use of @code{di} or @code{da} without an argument when there is no
13487 current diversion.
13489 @item mac
13490 @itemx 512
13491 @cindex @code{de}, @code{de1}, @code{dei} requests, and warnings
13492 @cindex @code{am}, @code{am1}, @code{ami} requests, and warnings
13493 @cindex @code{ds}, @code{ds1} requests, and warnings
13494 @cindex @code{as}, @code{as1} requests, and warnings
13495 @cindex @code{di} request, and warnings
13496 @cindex @code{da} request, and warnings
13497 @cindex @code{box}, @code{boxa} requests, and warnings
13498 @cindex @code{\*}, and warnings
13499 Use of undefined strings, macros and diversions.  When an undefined
13500 string, macro, or diversion is used, that string is automatically
13501 defined as empty.  So, in most cases, at most one warning is given
13502 for each name.
13504 @item reg
13505 @itemx 1024
13506 @cindex @code{nr} request, and warnings
13507 @cindex @code{\R}, and warnings
13508 @cindex @code{\n}, and warnings
13509 Use of undefined number registers.  When an undefined number register is
13510 used, that register is automatically defined to have a value of@tie{}0.
13511 So, in most cases, at most one warning is given for use of a particular
13512 name.
13514 @item tab
13515 @itemx 2048
13516 @cindex @code{\t}, and warnings
13517 Use of a tab character where a number was expected.
13519 @item right-brace
13520 @itemx 4096
13521 @cindex @code{\@}}, and warnings
13522 Use of @code{\@}} where a number was expected.
13524 @item missing
13525 @itemx 8192
13526 Requests that are missing non-optional arguments.
13528 @item input
13529 @itemx 16384
13530 Invalid input characters.
13532 @item escape
13533 @itemx 32768
13534 Unrecognized escape sequences.  When an unrecognized escape sequence
13535 @code{\@var{X}} is encountered, the escape character is ignored, and
13536 @var{X} is printed.
13538 @item space
13539 @itemx 65536
13540 @cindex compatibility mode
13541 Missing space between a request or macro and its argument.  This warning
13542 is given when an undefined name longer than two characters is
13543 encountered, and the first two characters of the name make a defined
13544 name.  The request or macro is not invoked.  When this warning is
13545 given, no macro is automatically defined.  This is enabled by default.
13546 This warning never occurs in compatibility mode.
13548 @item font
13549 @itemx 131072
13550 Non-existent fonts.  This is enabled by default.
13552 @item ig
13553 @itemx 262144
13554 Invalid escapes in text ignored with the @code{ig} request.  These are
13555 conditions that are errors when they do not occur in ignored text.
13557 @item color
13558 @itemx 524288
13559 Color related warnings.
13561 @item all
13562 All warnings except @samp{di}, @samp{mac} and @samp{reg}.  It is
13563 intended that this covers all warnings that are useful with traditional
13564 macro packages.
13566 @item w
13567 All warnings.
13568 @end table
13571 @c =====================================================================
13573 @node Implementation Differences,  , Debugging, gtroff Reference
13574 @section Implementation Differences
13575 @cindex implementation differences
13576 @cindex differences in implementation
13577 @cindex incompatibilities with @acronym{AT&T} @code{troff}
13578 @cindex compatibility mode
13579 @cindex mode, compatibility
13581 GNU @code{troff} has a number of features which cause incompatibilities
13582 with documents written with old versions of @code{troff}.
13584 @cindex long names
13585 @cindex names, long
13586 Long names cause some incompatibilities.  @acronym{UNIX} @code{troff}
13587 interprets
13589 @Example
13590 .dsabcd
13591 @endExample
13593 @cindex @code{\*}, incompatibilities with @acronym{AT&T} @code{troff}
13594 @cindex @code{\n}, incompatibilities with @acronym{AT&T} @code{troff}
13595 @noindent
13596 as defining a string @samp{ab} with contents @samp{cd}.  Normally, GNU
13597 @code{troff} interprets this as a call of a macro named
13598 @code{dsabcd}.  Also @acronym{UNIX} @code{troff} interprets
13599 @code{\*[} or @code{\n[} as references to a string or number register
13600 called @samp{[}.  In GNU @code{troff}, however, this is normally
13601 interpreted as the start of a long name.  In compatibility mode GNU
13602 @code{troff} interprets long names in the traditional way
13603 (which means that they are not recognized as names).
13605 @DefreqList {cp, [@Var{n}]}
13606 @DefreqItem {do, cmd}
13607 @DefregListEnd {.C}
13608 If @var{n} is missing or non-zero, turn on compatibility mode;
13609 otherwise, turn it off.
13611 The read-only number register @code{.C} is@tie{}1 if compatibility mode is
13612 on, 0@tie{}otherwise.
13614 Compatibility mode can be also turned on with the @option{-C} command line
13615 option.
13617 The @code{do} request turns off compatibility mode
13618 while executing its arguments as a @code{gtroff} command.
13620 @Example
13621 .do fam T
13622 @endExample
13624 @noindent
13625 executes the @code{fam} request when compatibility mode
13626 is enabled.
13628 @code{gtroff} restores the previous compatibility setting
13629 before interpreting any files sourced by the @var{cmd}.
13630 @endDefreq
13632 @cindex input level in delimited arguments
13633 @cindex delimited arguments, incompatibilities with @acronym{AT&T} @code{troff}
13634 Two other features are controlled by @option{-C}.  If not in
13635 compatibility mode, GNU @code{troff} preserves the input level in
13636 delimited arguments:
13638 @Example
13639 .ds xx '
13640 \w'abc\*(xxdef'
13641 @endExample
13643 @noindent
13644 In compatibility mode, the string @samp{72def'} is returned; without
13645 @option{-C} the resulting string is @samp{168} (assuming a TTY output
13646 device).
13648 @cindex @code{\f}, incompatibilities with @acronym{AT&T} @code{troff}
13649 @cindex @code{\H}, incompatibilities with @acronym{AT&T} @code{troff}
13650 @cindex @code{\s}, incompatibilities with @acronym{AT&T} @code{troff}
13651 @cindex @code{\S}, incompatibilities with @acronym{AT&T} @code{troff}
13652 Finally, the escapes @code{\f}, @code{\H}, @code{\m}, @code{\M},
13653 @code{\R}, @code{\s}, and @code{\S} are transparent for recognizing the
13654 beginning of a line only in compatibility mode (this is a rather obscure
13655 feature).  For example, the code
13657 @Example
13658 .de xx
13659 Hallo!
13661 \fB.xx\fP
13662 @endExample
13664 @noindent
13665 prints @samp{Hallo!} in bold face if in compatibility mode, and
13666 @samp{.xx} in bold face otherwise.
13668 @cindex @code{\A}, incompatibilities with @acronym{AT&T} @code{troff}
13669 @cindex @code{\|}, incompatibilities with @acronym{AT&T} @code{troff}
13670 @cindex @code{\^}, incompatibilities with @acronym{AT&T} @code{troff}
13671 @cindex @code{\&}, incompatibilities with @acronym{AT&T} @code{troff}
13672 @cindex @code{\@{}, incompatibilities with @acronym{AT&T} @code{troff}
13673 @cindex @code{\@}}, incompatibilities with @acronym{AT&T} @code{troff}
13674 @cindex @code{\@key{SP}}, incompatibilities with @acronym{AT&T} @code{troff}
13675 @cindex @code{\'}, incompatibilities with @acronym{AT&T} @code{troff}
13676 @cindex @code{\`}, incompatibilities with @acronym{AT&T} @code{troff}
13677 @cindex @code{\-}, incompatibilities with @acronym{AT&T} @code{troff}
13678 @cindex @code{\_}, incompatibilities with @acronym{AT&T} @code{troff}
13679 @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
13680 @cindex @code{\%}, incompatibilities with @acronym{AT&T} @code{troff}
13681 @cindex @code{\c}, incompatibilities with @acronym{AT&T} @code{troff}
13682 GNU @code{troff} does not allow the use of the escape sequences
13683 @code{\|}, @code{\^}, @code{\&}, @code{\@{}, @code{\@}},
13684 @code{\@key{SP}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
13685 @code{\%}, and @code{\c} in names of strings, macros, diversions, number
13686 registers, fonts or environments; @acronym{UNIX} @code{troff} does.  The
13687 @code{\A} escape sequence (@pxref{Identifiers}) may be helpful in
13688 avoiding use of these escape sequences in names.
13690 @cindex fractional point sizes
13691 @cindex fractional type sizes
13692 @cindex point sizes, fractional
13693 @cindex type sizes, fractional
13694 @cindex sizes, fractional
13695 @cindex @code{ps} request, incompatibilities with @acronym{AT&T} @code{troff}
13696 Fractional point sizes cause one noteworthy incompatibility.  In
13697 @acronym{UNIX} @code{troff} the @code{ps} request ignores scale
13698 indicators and thus
13700 @Example
13701 .ps 10u
13702 @endExample
13704 @noindent
13705 sets the point size to 10@tie{}points, whereas in GNU @code{troff} it
13706 sets the point size to 10@tie{}scaled points.  @xref{Fractional Type
13707 Sizes}, for more information.
13709 @cindex @code{bd} request, incompatibilities with @acronym{AT&T} @code{troff}
13710 @cindex @code{cs} request, incompatibilities with @acronym{AT&T} @code{troff}
13711 @cindex @code{tr} request, incompatibilities with @acronym{AT&T} @code{troff}
13712 @cindex @code{fp} request, incompatibilities with @acronym{AT&T} @code{troff}
13713 @cindex input characters and output glyphs, compatibility with @acronym{AT&T} @code{troff}
13714 @cindex output glyphs, and input characters,compatibility with @acronym{AT&T} @code{troff}
13715 @cindex characters, input, and output glyphs, compatibility with @acronym{AT&T} @code{troff}
13716 @cindex glyphs, output, and input characters, compatibility with @acronym{AT&T} @code{troff}
13717 In GNU @code{troff} there is a fundamental difference between
13718 (unformatted) input characters and (formatted) output glyphs.
13719 Everything that affects how a glyph is output is stored
13720 with the glyph node; once a glyph node has been constructed it is
13721 unaffected by any subsequent requests that are executed, including
13722 @code{bd}, @code{cs}, @code{tkf}, @code{tr}, or @code{fp} requests.
13723 Normally glyphs are constructed from input characters at the
13724 moment immediately before the glyph is added to the current output
13725 line.  Macros, diversions and strings are all, in fact, the same type of
13726 object; they contain lists of input characters and glyph nodes in
13727 any combination.  A glyph node does not behave like an input
13728 character for the purposes of macro processing; it does not inherit any
13729 of the special properties that the input character from which it was
13730 constructed might have had.  For example,
13732 @Example
13733 .di x
13734 \\\\
13738 @endExample
13740 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
13741 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
13742 @cindex @code{\e}, incompatibilities with @acronym{AT&T} @code{troff}
13743 @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
13744 @cindex @code{\?}, incompatibilities with @acronym{AT&T} @code{troff}
13745 @cindex transparent output, incompatibilities with @acronym{AT&T} @code{troff}
13746 @cindex output, transparent, incompatibilities with @acronym{AT&T} @code{troff}
13747 @noindent
13748 prints @samp{\\} in GNU @code{troff}; each pair of input backslashes
13749 is turned into one output backslash and the resulting output backslashes
13750 are not interpreted as escape characters when they are reread.
13751 @acronym{UNIX} @code{troff} would interpret them as escape characters
13752 when they were reread and would end up printing one @samp{\}.  The
13753 correct way to obtain a printable backslash is to use the @code{\e}
13754 escape sequence: This always prints a single instance of the current
13755 escape character, regardless of whether or not it is used in a
13756 diversion; it also works in both GNU @code{troff} and @acronym{UNIX}
13757 @code{troff}.@footnote{To be completely independent of the current
13758 escape character, use @code{\(rs} which represents a reverse solidus
13759 (backslash) glyph.}  To store, for some reason, an escape sequence in a
13760 diversion that will be interpreted when the diversion is reread, either
13761 use the traditional @code{\!} transparent output facility, or, if this
13762 is unsuitable, the new @code{\?} escape sequence.
13764 @xref{Diversions}, and @ref{Gtroff Internals}, for more information.
13768 @c =====================================================================
13769 @c =====================================================================
13771 @node Preprocessors, Output Devices, gtroff Reference, Top
13772 @chapter Preprocessors
13773 @cindex preprocessors
13775 This chapter describes all preprocessors that come with @code{groff} or
13776 which are freely available.
13778 @menu
13779 * geqn::
13780 * gtbl::
13781 * gpic::
13782 * ggrn::
13783 * grap::
13784 * grefer::
13785 * gsoelim::
13786 @end menu
13789 @c =====================================================================
13791 @node geqn, gtbl, Preprocessors, Preprocessors
13792 @section @code{geqn}
13793 @cindex @code{eqn}, the program
13794 @cindex @code{geqn}, the program
13796 @c XXX
13798 @menu
13799 * Invoking geqn::
13800 @end menu
13802 @c ---------------------------------------------------------------------
13804 @node Invoking geqn,  , geqn, geqn
13805 @subsection Invoking @code{geqn}
13806 @cindex invoking @code{geqn}
13807 @cindex @code{geqn}, invoking
13809 @c XXX
13812 @c =====================================================================
13814 @node gtbl, gpic, geqn, Preprocessors
13815 @section @code{gtbl}
13816 @cindex @code{tbl}, the program
13817 @cindex @code{gtbl}, the program
13819 @c XXX
13821 @menu
13822 * Invoking gtbl::
13823 @end menu
13825 @c ---------------------------------------------------------------------
13827 @node Invoking gtbl,  , gtbl, gtbl
13828 @subsection Invoking @code{gtbl}
13829 @cindex invoking @code{gtbl}
13830 @cindex @code{gtbl}, invoking
13832 @c XXX
13835 @c =====================================================================
13837 @node gpic, ggrn, gtbl, Preprocessors
13838 @section @code{gpic}
13839 @cindex @code{pic}, the program
13840 @cindex @code{gpic}, the program
13842 @c XXX
13844 @menu
13845 * Invoking gpic::
13846 @end menu
13848 @c ---------------------------------------------------------------------
13850 @node Invoking gpic,  , gpic, gpic
13851 @subsection Invoking @code{gpic}
13852 @cindex invoking @code{gpic}
13853 @cindex @code{gpic}, invoking
13855 @c XXX
13858 @c =====================================================================
13860 @node ggrn, grap, gpic, Preprocessors
13861 @section @code{ggrn}
13862 @cindex @code{grn}, the program
13863 @cindex @code{ggrn}, the program
13865 @c XXX
13867 @menu
13868 * Invoking ggrn::
13869 @end menu
13871 @c ---------------------------------------------------------------------
13873 @node Invoking ggrn,  , ggrn, ggrn
13874 @subsection Invoking @code{ggrn}
13875 @cindex invoking @code{ggrn}
13876 @cindex @code{ggrn}, invoking
13878 @c XXX
13881 @c =====================================================================
13883 @node grap, grefer, ggrn, Preprocessors
13884 @section @code{grap}
13885 @cindex @code{grap}, the program
13887 A free implementation of @code{grap}, written by Ted Faber,
13888 is available as an extra package from the following address:
13890 @display
13891 @uref{http://www.lunabase.org/~faber/Vault/software/grap/}
13892 @end display
13895 @c =====================================================================
13897 @node grefer, gsoelim, grap, Preprocessors
13898 @section @code{grefer}
13899 @cindex @code{refer}, the program
13900 @cindex @code{grefer}, the program
13902 @c XXX
13904 @menu
13905 * Invoking grefer::
13906 @end menu
13908 @c ---------------------------------------------------------------------
13910 @node Invoking grefer,  , grefer, grefer
13911 @subsection Invoking @code{grefer}
13912 @cindex invoking @code{grefer}
13913 @cindex @code{grefer}, invoking
13915 @c XXX
13918 @c =====================================================================
13920 @node gsoelim,  , grefer, Preprocessors
13921 @section @code{gsoelim}
13922 @cindex @code{soelim}, the program
13923 @cindex @code{gsoelim}, the program
13925 @c XXX
13927 @menu
13928 * Invoking gsoelim::
13929 @end menu
13931 @c ---------------------------------------------------------------------
13933 @node Invoking gsoelim,  , gsoelim, gsoelim
13934 @subsection Invoking @code{gsoelim}
13935 @cindex invoking @code{gsoelim}
13936 @cindex @code{gsoelim}, invoking
13938 @c XXX
13942 @c =====================================================================
13943 @c =====================================================================
13945 @node Output Devices, File formats, Preprocessors, Top
13946 @chapter Output Devices
13947 @cindex output devices
13948 @cindex devices for output
13950 @c XXX
13952 @menu
13953 * Special Characters::
13954 * grotty::
13955 * grops::
13956 * grodvi::
13957 * grolj4::
13958 * grolbp::
13959 * grohtml::
13960 * gxditview::
13961 @end menu
13964 @c =====================================================================
13966 @node Special Characters, grotty, Output Devices, Output Devices
13967 @section Special Characters
13968 @cindex special characters
13969 @cindex characters, special
13971 @c XXX
13973 @xref{Font Files}.
13976 @c =====================================================================
13978 @node grotty, grops, Special Characters, Output Devices
13979 @section @code{grotty}
13980 @cindex @code{grotty}, the program
13982 @c XXX
13984 @menu
13985 * Invoking grotty::
13986 @end menu
13988 @c ---------------------------------------------------------------------
13990 @node Invoking grotty,  , grotty, grotty
13991 @subsection Invoking @code{grotty}
13992 @cindex invoking @code{grotty}
13993 @cindex @code{grotty}, invoking
13995 @c XXX
13997 @c The following is no longer true; fix and extend it.
13999 @c @pindex less
14000 @c @cindex Teletype
14001 @c @cindex ISO 6249 SGR
14002 @c @cindex terminal control sequences
14003 @c @cindex control sequences, for terminals
14004 @c For TTY output devices, underlining is done by emitting sequences of
14005 @c @samp{_} and @samp{\b} (the backspace character) before the actual
14006 @c character.  Literally, this is printing an underline character, then
14007 @c moving back one character position, and printing the actual character
14008 @c at the same position as the underline character (similar to a
14009 @c typewriter).  Usually, a modern terminal can't interpret this (and the
14010 @c original Teletype machines for which this sequence was appropriate are
14011 @c no longer in use).  You need a pager program like @code{less} which
14012 @c translates this into ISO 6429 SGR sequences to control terminals.
14015 @c =====================================================================
14017 @node grops, grodvi, grotty, Output Devices
14018 @section @code{grops}
14019 @cindex @code{grops}, the program
14021 @c XXX
14023 @menu
14024 * Invoking grops::
14025 * Embedding PostScript::
14026 @end menu
14028 @c ---------------------------------------------------------------------
14030 @node Invoking grops, Embedding PostScript, grops, grops
14031 @subsection Invoking @code{grops}
14032 @cindex invoking @code{grops}
14033 @cindex @code{grops}, invoking
14035 @c XXX
14037 @c ---------------------------------------------------------------------
14039 @node Embedding PostScript,  , Invoking grops, grops
14040 @subsection Embedding @sc{PostScript}
14041 @cindex embedding PostScript
14042 @cindex PostScript, embedding
14044 @c XXX
14047 @c =====================================================================
14049 @node grodvi, grolj4, grops, Output Devices
14050 @section @code{grodvi}
14051 @cindex @code{grodvi}, the program
14053 @c XXX
14055 @menu
14056 * Invoking grodvi::
14057 @end menu
14059 @c ---------------------------------------------------------------------
14061 @node Invoking grodvi,  , grodvi, grodvi
14062 @subsection Invoking @code{grodvi}
14063 @cindex invoking @code{grodvi}
14064 @cindex @code{grodvi}, invoking
14066 @c XXX
14069 @c =====================================================================
14071 @node grolj4, grolbp, grodvi, Output Devices
14072 @section @code{grolj4}
14073 @cindex @code{grolj4}, the program
14075 @c XXX
14077 @menu
14078 * Invoking grolj4::
14079 @end menu
14081 @c ---------------------------------------------------------------------
14083 @node Invoking grolj4,  , grolj4, grolj4
14084 @subsection Invoking @code{grolj4}
14085 @cindex invoking @code{grolj4}
14086 @cindex @code{grolj4}, invoking
14088 @c XXX
14091 @c =====================================================================
14093 @node grolbp, grohtml, grolj4, Output Devices
14094 @section @code{grolbp}
14095 @cindex @code{grolbp}, the program
14097 @c XXX
14099 @menu
14100 * Invoking grolbp::
14101 @end menu
14103 @c ---------------------------------------------------------------------
14105 @node Invoking grolbp,  , grolbp, grolbp
14106 @subsection Invoking @code{grolbp}
14107 @cindex invoking @code{grolbp}
14108 @cindex @code{grolbp}, invoking
14110 @c XXX
14113 @c =====================================================================
14115 @node grohtml, gxditview, grolbp, Output Devices
14116 @section @code{grohtml}
14117 @cindex @code{grohtml}, the program
14119 @c XXX
14121 @menu
14122 * Invoking grohtml::
14123 * grohtml specific registers and strings::
14124 @end menu
14126 @c ---------------------------------------------------------------------
14128 @node Invoking grohtml, grohtml specific registers and strings, grohtml, grohtml
14129 @subsection Invoking @code{grohtml}
14130 @cindex invoking @code{grohtml}
14131 @cindex @code{grohtml}, invoking
14133 @c XXX
14135 @c ---------------------------------------------------------------------
14137 @node grohtml specific registers and strings,  , Invoking grohtml, grohtml
14138 @subsection @code{grohtml} specific registers and strings
14139 @cindex registers specific to @code{grohtml}
14140 @cindex strings specific to @code{grohtml}
14141 @cindex @code{grohtml}, registers and strings
14143 @DefmpregList {ps4html, grohtml}
14144 @DefstrListEnd {www-image-template, grohtml}
14145 The registers @code{ps4html} and @code{www-image-template} are defined
14146 by the @code{pre-grohtml} preprocessor.  @code{pre-grohtml} reads in
14147 the @code{troff} input, marks up the inline equations and passes the
14148 result firstly to
14150 @Example
14151 troff -Tps -rps4html=1 -dwww-image-template=@var{template}
14152 @endExample
14154 @noindent
14155 and secondly to
14157 @Example
14158 troff -Thtml
14159 @endExample
14161 The PostScript device is used to create all the image files, and the
14162 register @code{ps4html} enables the macro sets to ignore floating
14163 keeps, footers, and headings.
14165 The register @code{www-image-template} is set to the user specified
14166 template name or the default name.
14167 @endDefmpreg
14170 @c =====================================================================
14172 @node gxditview,  , grohtml, Output Devices
14173 @section @code{gxditview}
14174 @cindex @code{gxditview}, the program
14176 @c XXX
14178 @menu
14179 * Invoking gxditview::
14180 @end menu
14182 @c ---------------------------------------------------------------------
14184 @node Invoking gxditview,  , gxditview, gxditview
14185 @subsection Invoking @code{gxditview}
14186 @cindex invoking @code{gxditview}
14187 @cindex @code{gxditview}, invoking
14189 @c XXX
14190 @c X11's xditview
14194 @c =====================================================================
14195 @c =====================================================================
14197 @node File formats, Installation, Output Devices, Top
14198 @chapter File formats
14199 @cindex file formats
14200 @cindex formats, file
14202 All files read and written by @code{gtroff} are text files.  The
14203 following two sections describe their format.
14205 @menu
14206 * gtroff Output::
14207 * Font Files::
14208 @end menu
14211 @c =====================================================================
14213 @node gtroff Output, Font Files, File formats, File formats
14214 @section @code{gtroff} Output
14215 @cindex @code{gtroff}, output
14216 @cindex output, @code{gtroff}
14218 This section describes the intermediate output format of GNU
14219 @code{troff}.  This output is produced by a run of @code{gtroff}
14220 before it is fed into a device postprocessor program.
14222 As @code{groff} is a wrapper program around @code{gtroff} that
14223 automatically calls a postprocessor, this output does not show up
14224 normally.  This is why it is called @dfn{intermediate}.
14225 @code{groff} provides the option @option{-Z} to inhibit postprocessing,
14226 such that the produced intermediate output is sent to standard output
14227 just like calling @code{gtroff} manually.
14229 @cindex troff output
14230 @cindex output, troff
14231 @cindex intermediate output
14232 @cindex output, intermediate
14233 Here, the term @dfn{troff output} describes what is output by
14234 @code{gtroff}, while @dfn{intermediate output} refers to the language
14235 that is accepted by the parser that prepares this output for the
14236 postprocessors.  This parser is smarter on whitespace and implements
14237 obsolete elements for compatibility, otherwise both formats are the
14238 same.@footnote{The parser and postprocessor for intermediate output
14239 can be found in the file@*
14240 @file{@var{groff-source-dir}/src/libs/libdriver/input.cpp}.}
14242 The main purpose of the intermediate output concept is to facilitate
14243 the development of postprocessors by providing a common programming
14244 interface for all devices.  It has a language of its own that is
14245 completely different from the @code{gtroff} language.  While the
14246 @code{gtroff} language is a high-level programming language for text
14247 processing, the intermediate output language is a kind of low-level
14248 assembler language by specifying all positions on the page for writing
14249 and drawing.
14251 The intermediate output produced by @code{gtroff} is fairly readable,
14252 while output from @acronym{AT&T} @code{troff} is rather hard to
14253 understand because of strange habits that are still supported, but not
14254 used any longer by @code{gtroff}.
14256 @menu
14257 * Language Concepts::
14258 * Command Reference::
14259 * Intermediate Output Examples::
14260 * Output Language Compatibility::
14261 @end menu
14263 @c ---------------------------------------------------------------------
14265 @node Language Concepts, Command Reference, gtroff Output, gtroff Output
14266 @subsection Language Concepts
14268 During the run of @code{gtroff}, the input data is cracked down to the
14269 information on what has to be printed at what position on the intended
14270 device.  So the language of the intermediate output format can be quite
14271 small.  Its only elements are commands with and without arguments.
14272 In this section, the term @dfn{command} always refers to the intermediate
14273 output language, and never to the @code{gtroff} language used for document
14274 formatting.  There are commands for positioning and text writing, for drawing, and
14275 for device controlling.
14277 @menu
14278 * Separation::
14279 * Argument Units::
14280 * Document Parts::
14281 @end menu
14283 @node Separation, Argument Units, Language Concepts, Language Concepts
14284 @subsubsection Separation
14286 @acronym{AT&T} @code{troff} output has strange requirements on whitespace.
14287 The @code{gtroff} output parser, however, is smart about whitespace by
14288 making it maximally optional.  The whitespace characters, i.e., the
14289 tab, space, and newline characters, always have a syntactical meaning.
14290 They are never printable because spacing within the output is always
14291 done by positioning commands.
14293 Any sequence of space or tab characters is treated as a single
14294 @dfn{syntactical space}.  It separates commands and arguments, but is
14295 only required when there would occur a clashing between the command code
14296 and the arguments without the space.  Most often, this happens when
14297 variable-length command names, arguments, argument lists, or command
14298 clusters meet.  Commands and arguments with a known, fixed length need
14299 not be separated by syntactical space.
14301 A line break is a syntactical element, too.  Every command argument can be
14302 followed by whitespace, a comment, or a newline character.  Thus a
14303 @dfn{syntactical line break} is defined to consist of optional
14304 syntactical space that is optionally followed by a comment, and a
14305 newline character.
14307 The normal commands, those for positioning and text, consist of a
14308 single letter taking a fixed number of arguments.  For historical reasons,
14309 the parser allows to stack such commands on the same line, but
14310 fortunately, in @code{gtroff}'s intermediate output, every command with
14311 at least one argument is followed by a line break, thus providing
14312 excellent readability.
14314 The other commands -- those for drawing and device controlling --
14315 have a more complicated structure; some recognize long command names,
14316 and some take a variable number of arguments.  So all @samp{D} and
14317 @samp{x} commands were designed to request a syntactical line break
14318 after their last argument.  Only one command, @w{@samp{x X}},
14319 has an argument that can stretch over several lines; all other
14320 commands must have all of their arguments on the same line as the
14321 command, i.e., the arguments may not be splitted by a line break.
14323 Empty lines (these are lines containing only space and/or a comment), can
14324 occur everywhere.  They are just ignored.
14326 @node Argument Units, Document Parts, Separation, Language Concepts
14327 @subsubsection Argument Units
14329 Some commands take integer arguments that are assumed to represent
14330 values in a measurement unit, but the letter for the corresponding
14331 scale indicator is not written with the output command arguments.
14332 Most commands assume the scale indicator @samp{u}, the basic unit of
14333 the device, some use @samp{z}, the scaled point unit of the device,
14334 while others, such as the color commands, expect plain integers.
14336 Note that single characters can have the eighth bit set, as can the
14337 names of fonts and special characters.  The names of characters and
14338 fonts can be of arbitrary length.  A character that is to be printed
14339 will always be in the current font.
14341 A string argument is always terminated by the next whitespace
14342 character (space, tab, or newline); an embedded @samp{#} character is
14343 regarded as part of the argument, not as the beginning of a comment
14344 command.  An integer argument is already terminated by the next
14345 non-digit character, which then is regarded as the first character of
14346 the next argument or command.
14348 @node Document Parts,  , Argument Units, Language Concepts
14349 @subsubsection Document Parts
14351 A correct intermediate output document consists of two parts, the
14352 @dfn{prologue} and the @dfn{body}.
14354 The task of the prologue is to set the general device parameters
14355 using three exactly specified commands.  @code{gtroff}'s prologue
14356 is guaranteed to consist of the following three lines (in that order):
14358 @Example
14359 x T @var{device}
14360 x res @var{n} @var{h} @var{v}
14361 x init
14362 @endExample
14364 @noindent
14365 with the arguments set as outlined in @ref{Device Control Commands}.
14366 Note that the parser for the intermediate output format is able to
14367 swallow additional whitespace and comments as well even in the
14368 prologue.
14370 The body is the main section for processing the document data.
14371 Syntactically, it is a sequence of any commands different from the
14372 ones used in the prologue.  Processing is terminated as soon as the
14373 first @w{@samp{x stop}} command is encountered; the last line of any
14374 @code{gtroff} intermediate output always contains such a command.
14376 Semantically, the body is page oriented.  A new page is started by a
14377 @samp{p} command.  Positioning, writing, and drawing commands are
14378 always done within the current page, so they cannot occur before the
14379 first @samp{p} command.  Absolute positioning (by the @samp{H} and
14380 @samp{V} commands) is done relative to the current page; all other
14381 positioning is done relative to the current location within this page.
14383 @c ---------------------------------------------------------------------
14385 @node Command Reference, Intermediate Output Examples, Language Concepts, gtroff Output
14386 @subsection Command Reference
14388 This section describes all intermediate output commands, both from
14389 @acronym{AT&T} @code{troff} as well as the @code{gtroff} extensions.
14391 @menu
14392 * Comment Command::
14393 * Simple Commands::
14394 * Graphics Commands::
14395 * Device Control Commands::
14396 * Obsolete Command::
14397 @end menu
14399 @node Comment Command, Simple Commands, Command Reference, Command Reference
14400 @subsubsection Comment Command
14402 @table @code
14403 @item #@var{anything}@angles{end of line}
14404 A comment.  Ignore any characters from the @samp{#} character up to
14405 the next newline character.
14407 This command is the only possibility for commenting in the intermediate
14408 output.  Each comment can be preceded by arbitrary syntactical space;
14409 every command can be terminated by a comment.
14410 @end table
14412 @node Simple Commands, Graphics Commands, Comment Command, Command Reference
14413 @subsubsection Simple Commands
14415 The commands in this subsection have a command code consisting of a
14416 single character, taking a fixed number of arguments.  Most of them
14417 are commands for positioning and text writing.  These commands are
14418 smart about whitespace.  Optionally, syntactical space can be inserted
14419 before, after, and between the command letter and its arguments.
14420 All of these commands are stackable, i.e., they can be preceded by
14421 other simple commands or followed by arbitrary other commands on the
14422 same line.  A separating syntactical space is only necessary when two
14423 integer arguments would clash or if the preceding argument ends with a
14424 string argument.
14426 @table @code
14427 @ignore
14428 .if (\n[@USE_ENV_STACK] == 1) \{\
14429 .command {
14430 Open a new environment by copying the actual device configuration data
14431 to the environment stack.
14433 The current environment is setup by the device specification and
14434 manipulated by the setting commands.
14437 .command }
14438 Close the actual environment (opened by a preceding
14439 .BR { \~command)
14440 and restore the previous environment from the environment
14441 stack as the actual device configuration data.
14443 \}              \" endif @USE_ENV_STACK
14444 @end ignore
14446 @item C @var{xxx}@angles{whitespace}
14447 Print a special character named @var{xxx}.  The trailing
14448 syntactical space or line break is necessary to allow glyph names
14449 of arbitrary length.  The glyph is printed at the current print
14450 position; the glyph's size is read from the font file.  The print
14451 position is not changed.
14453 @item c @var{g}
14454 Print glyph@tie{}@var{g} at the current print position;@footnote{@samp{c}
14455 is actually a misnomer since it outputs a glyph.} the glyph's size is
14456 read from the font file.  The print position is not changed.
14458 @item f @var{n}
14459 Set font to font number@tie{}@var{n} (a non-negative integer).
14461 @item H @var{n}
14462 Move right to the absolute vertical position@tie{}@var{n} (a
14463 non-negative integer in basic units @samp{u} relative to left edge
14464 of current page.
14466 @item h @var{n}
14467 Move @var{n} (a non-negative integer) basic units @samp{u} horizontally
14468 to the right.  The original @acronym{UNIX} troff manual allows negative
14469 values for @var{n} also, but @code{gtroff} doesn't use this.
14471 @item m @var{color-scheme} @r{[}@var{component} @dots{}@r{]}
14472 Set the color for text (glyphs), line drawing, and the outline of
14473 graphic objects using different color schemes; the analoguous command
14474 for the filling color of graphic objects is @samp{DF}.  The color
14475 components are specified as integer arguments between 0 and 65536.
14476 The number of color components and their meaning vary for the
14477 different color schemes.  These commands are generated by
14478 @code{gtroff}'s escape sequence @code{\m}.  No position changing.
14479 These commands are a @code{gtroff} extension.
14481 @table @code
14482 @item mc @var{cyan} @var{magenta} @var{yellow}
14483 Set color using the CMY color scheme, having the 3@tie{}color components
14484 @var{cyan}, @var{magenta}, and @var{yellow}.
14486 @item md
14487 Set color to the default color value (black in most cases).
14488 No component arguments.
14490 @item mg @var{gray}
14491 Set color to the shade of gray given by the argument, an integer
14492 between 0 (black) and 65536 (white).
14494 @item mk @var{cyan} @var{magenta} @var{yellow} @var{black}
14495 Set color using the CMYK color scheme, having the 4@tie{}color components
14496 @var{cyan}, @var{magenta}, @var{yellow}, and @var{black}.
14498 @item mr @var{red} @var{green} @var{blue}
14499 Set color using the RGB color scheme, having the 3@tie{}color components
14500 @var{red}, @var{green}, and @var{blue}.
14501 @end table
14503 @item N @var{n}
14504 Print glyph with index@tie{}@var{n} (a non-negative integer) of the
14505 current font.  This command is a @code{gtroff} extension.
14507 @item n @var{b} @var{a}
14508 Inform the device about a line break, but no positioning is done by
14509 this command.  In @acronym{AT&T} @code{troff}, the integer arguments
14510 @var{b} and@tie{}@var{a} informed about the space before and after the
14511 current line to make the intermediate output more human readable
14512 without performing any action.  In @code{groff}, they are just ignored, but
14513 they must be provided for compatibility reasons.
14515 @item p @var{n}
14516 Begin a new page in the outprint.  The page number is set
14517 to@tie{}@var{n}.  This page is completely independent of pages formerly
14518 processed even if those have the same page number.  The vertical
14519 position on the outprint is automatically set to@tie{}0.  All
14520 positioning, writing, and drawing is always done relative to a page,
14521 so a @samp{p} command must be issued before any of these commands.
14523 @item s @var{n}
14524 Set point size to @var{n}@tie{}scaled points (this is unit @samp{z}).
14525 @acronym{AT&T} @code{troff} used the unit points (@samp{p}) instead.
14526 @xref{Output Language Compatibility}.
14528 @item t @var{xxx}@angles{whitespace}
14529 @itemx t @var{xxx} @var{dummy-arg}@angles{whitespace}
14530 Print a word, i.e., a sequence of characters @var{xxx} representing
14531 output glyphs which names are single characters, terminated by
14532 a space character or a line break; an optional second integer argument
14533 is ignored (this allows the formatter to generate an even number of
14534 arguments).  The first glyph should be printed at the current
14535 position, the current horizontal position should then be increased by
14536 the width of the first glyph, and so on for each glyph.
14537 The widths of the glyphs are read from the font file, scaled for the
14538 current point size, and rounded to a multiple of the horizontal
14539 resolution.  Special characters cannot be printed using this command
14540 (use the @samp{C} command for special characters).  This command is a
14541 @code{gtroff} extension; it is only used for devices whose @file{DESC}
14542 file contains the @code{tcommand} keyword (@pxref{DESC File Format}).
14544 @item u @var{n} @var{xxx}@angles{whitespace}
14545 Print word with track kerning.  This is the same as the @samp{t}
14546 command except that after printing each glyph, the current
14547 horizontal position is increased by the sum of the width of that
14548 glyph and@tie{}@var{n} (an integer in basic units @samp{u}).
14549 This command is a @code{gtroff} extension; it is only used for devices
14550 whose @file{DESC} file contains the @code{tcommand} keyword
14551 (@pxref{DESC File Format}).
14553 @item V @var{n}
14554 Move down to the absolute vertical position@tie{}@var{n} (a
14555 non-negative integer in basic units @samp{u}) relative to upper edge
14556 of current page.
14558 @item v @var{n}
14559 Move @var{n}@tie{}basic units @samp{u} down (@var{n} is a non-negative
14560 integer).  The original @acronym{UNIX} troff manual allows negative
14561 values for @var{n} also, but @code{gtroff} doesn't use this.
14563 @item w
14564 Informs about a paddable white space to increase readability.
14565 The spacing itself must be performed explicitly by a move command.
14566 @end table
14568 @node Graphics Commands, Device Control Commands, Simple Commands, Command Reference
14569 @subsubsection Graphics Commands
14571 Each graphics or drawing command in the intermediate output starts
14572 with the letter @samp{D}, followed by one or two characters that
14573 specify a subcommand; this is followed by a fixed or variable number
14574 of integer arguments that are separated by a single space character.
14575 A @samp{D} command may not be followed by another command on the same line
14576 (apart from a comment), so each @samp{D} command is terminated by a
14577 syntactical line break.
14579 @code{gtroff} output follows the classical spacing rules (no space
14580 between command and subcommand, all arguments are preceded by a
14581 single space character), but the parser allows optional space between
14582 the command letters and makes the space before the first argument
14583 optional.  As usual, each space can be any sequence of tab and space
14584 characters.
14586 Some graphics commands can take a variable number of arguments.
14587 In this case, they are integers representing a size measured in basic
14588 units @samp{u}.  The arguments called @var{h1}, @var{h2}, @dots{},
14589 @var{hn} stand for horizontal distances where positive means right,
14590 negative left.  The arguments called @var{v1}, @var{v2}, @dots{},
14591 @var{vn} stand for vertical distances where positive means down,
14592 negative up.  All these distances are offsets relative to the current
14593 location.
14595 Each graphics command directly corresponds to a similar @code{gtroff}
14596 @code{\D} escape sequence.  @xref{Drawing Requests}.
14598 Unknown @samp{D} commands are assumed to be device-specific.
14599 Its arguments are parsed as strings; the whole information is then
14600 sent to the postprocessor.
14602 In the following command reference, the syntax element
14603 @angles{line break} means a syntactical line break as defined above.
14605 @table @code
14606 @item D~ @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
14607 Draw B-spline from current position to offset (@var{h1},@var{v1}),
14608 then to offset (@var{h2},@var{v2}), if given, etc.@: up to
14609 (@var{hn},@var{vn}).  This command takes a variable number of argument
14610 pairs; the current position is moved to the terminal point of the drawn
14611 curve.
14613 @item Da @var{h1} @var{v1} @var{h2} @var{v2}@angles{line break}
14614 Draw arc from current position to
14615 (@var{h1},@var{v1})@math{+}(@var{h2},@var{v2}) with center at
14616 (@var{h1},@var{v1}); then move the current position to the final point
14617 of the arc.
14619 @item DC @var{d}@angles{line break}
14620 @itemx DC @var{d} @var{dummy-arg}@angles{line break}
14621 Draw a solid circle using the current fill color with
14622 diameter@tie{}@var{d} (integer in basic units @samp{u}) with leftmost
14623 point at the current position; then move the current position to the
14624 rightmost point of the circle.  An optional second integer argument is
14625 ignored (this allows the formatter to generate an even number of
14626 arguments).  This command is a @code{gtroff} extension.
14628 @item Dc @var{d}@angles{line break}
14629 Draw circle line with diameter@tie{}@var{d} (integer in basic units
14630 @samp{u}) with leftmost point at the current position; then move the
14631 current position to the rightmost point of the circle.
14633 @item DE @var{h} @var{v}@angles{line break}
14634 Draw a solid ellipse in the current fill color with a horizontal
14635 diameter of@tie{}@var{h} and a vertical diameter of@tie{}@var{v} (both
14636 integers in basic units @samp{u}) with the leftmost point at the
14637 current position; then move to the rightmost point of the ellipse.
14638 This command is a @code{gtroff} extension.
14640 @item De @var{h} @var{v}@angles{line break}
14641 Draw an outlined ellipse with a horizontal diameter of@tie{}@var{h}
14642 and a vertical diameter of@tie{}@var{v} (both integers in basic units
14643 @samp{u}) with the leftmost point at current position; then move to
14644 the rightmost point of the ellipse.
14646 @item DF @var{color-scheme} @r{[}@var{component} @dots{}@r{]}@angles{line break}
14647 Set fill color for solid drawing objects using different color
14648 schemes; the analoguous command for setting the color of text, line
14649 graphics, and the outline of graphic objects is @samp{m}.
14650 The color components are specified as integer arguments between 0 and
14651 65536.  The number of color components and their meaning vary for the
14652 different color schemes.  These commands are generated by @code{gtroff}'s
14653 escape sequences @w{@code{\D'F @dots{}'}} and @code{\M} (with no other
14654 corresponding graphics commands).  No position changing.  This command
14655 is a @code{gtroff} extension.
14657 @table @code
14658 @item DFc @var{cyan} @var{magenta} @var{yellow}@angles{line break}
14659 Set fill color for solid drawing objects using the CMY color scheme,
14660 having the 3@tie{}color components @var{cyan}, @var{magenta}, and
14661 @var{yellow}.
14663 @item DFd@angles{line break}
14664 Set fill color for solid drawing objects to the default fill color value
14665 (black in most cases).  No component arguments.
14667 @item DFg @var{gray}@angles{line break}
14668 Set fill color for solid drawing objects to the shade of gray given by
14669 the argument, an integer between 0 (black) and 65536 (white).
14671 @item DFk @var{cyan} @var{magenta} @var{yellow} @var{black}@angles{line break}
14672 Set fill color for solid drawing objects using the CMYK color scheme,
14673 having the 4@tie{}color components @var{cyan}, @var{magenta}, @var{yellow},
14674 and @var{black}.
14676 @item DFr @var{red} @var{green} @var{blue}@angles{line break}
14677 Set fill color for solid drawing objects using the RGB color scheme,
14678 having the 3@tie{}color components @var{red}, @var{green}, and @var{blue}.
14679 @end table
14681 @item Df @var{n}@angles{line break}
14682 The argument@tie{}@var{n} must be an integer in the range @math{-32767}
14683 to 32767.
14685 @table @asis
14686 @item @math{0 @LE @var{n} @LE 1000}
14687 Set the color for filling solid drawing objects to a shade of gray,
14688 where 0 corresponds to solid white, 1000 (the default) to solid black,
14689 and values in between to intermediate shades of gray; this is
14690 obsoleted by command @samp{DFg}.
14692 @item @math{@var{n} < 0} or @math{@var{n} > 1000}
14693 Set the filling color to the color that is currently being used for
14694 the text and the outline, see command @samp{m}.  For example, the
14695 command sequence
14697 @Example
14698 mg 0 0 65536
14699 Df -1
14700 @endExample
14702 @noindent
14703 sets all colors to blue.
14704 @end table
14706 @noindent
14707 No position changing.  This command is a @code{gtroff} extension.
14709 @item Dl @var{h} @var{v}@angles{line break}
14710 Draw line from current position to offset (@var{h},@var{v}) (integers
14711 in basic units @samp{u}); then set current position to the end of the
14712 drawn line.
14714 @item Dp @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
14715 Draw a polygon line from current position to offset (@var{h1},@var{v1}),
14716 from there to offset (@var{h2},@var{v2}), etc.@: up to offset
14717 (@var{hn},@var{vn}), and from there back to the starting position.
14718 For historical reasons, the position is changed by adding the sum of
14719 all arguments with odd index to the actual horizontal position and the
14720 even ones to the vertical position.  Although this doesn't make sense
14721 it is kept for compatibility.
14722 @ignore
14723 As the polygon is closed, the end of drawing is the starting point, so
14724 the position doesn't change.
14725 @end ignore
14726 This command is a @code{gtroff} extension.
14728 @item Dp @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
14729 Draw a solid polygon in the current fill color rather than an outlined
14730 polygon, using the same arguments and positioning as the corresponding
14731 @samp{Dp} command.
14732 @ignore
14733 No position changing.
14734 @end ignore
14735 This command is a @code{gtroff} extension.
14737 @item Dt @var{n}@angles{line break}
14738 Set the current line thickness to@tie{}@var{n} (an integer in basic
14739 units @samp{u}) if @math{@var{n}>0}; if @math{@var{n}=0} select the
14740 smallest available line thickness; if @math{@var{n}<0} set the line
14741 thickness proportional to the point size (this is the default before
14742 the first @samp{Dt} command was specified).  For historical reasons,
14743 the horizontal position is changed by adding the argument to the actual
14744 horizontal position, while the vertical position is not changed.
14745 Although this doesn't make sense it is kept for compatibility.
14746 @ignore
14747 No position changing.
14748 @end ignore
14749 This command is a @code{gtroff} extension.
14750 @end table
14752 @node Device Control Commands, Obsolete Command, Graphics Commands, Command Reference
14753 @subsubsection Device Control Commands
14755 Each device control command starts with the letter @samp{x},
14756 followed by a space character (optional or arbitrary space or tab in
14757 @code{gtroff}) and a subcommand letter or word; each argument (if any)
14758 must be preceded by a syntactical space.  All @samp{x} commands are
14759 terminated by a syntactical line break; no device control command can
14760 be followed by another command on the same line (except a comment).
14762 The subcommand is basically a single letter, but to increase
14763 readability, it can be written as a word, i.e., an arbitrary sequence
14764 of characters terminated by the next tab, space, or newline character.
14765 All characters of the subcommand word but the first are simply ignored.
14766 For example, @code{gtroff} outputs the initialization command
14767 @w{@samp{x i}} as @w{@samp{x init}} and the resolution command
14768 @w{@samp{x r}} as @w{@samp{x res}}.
14770 In the following, the syntax element @angles{line break} means a
14771 syntactical line break (@pxref{Separation}).
14773 @table @code
14774 @item xF @var{name}@angles{line break}
14775 The @samp{F} stands for @var{Filename}.
14777 Use @var{name} as the intended name for the current file in error
14778 reports.  This is useful for remembering the original file name when
14779 @code{gtroff} uses an internal piping mechanism.  The input file is
14780 not changed by this command.  This command is a @code{gtroff} extension.
14782 @item xf @var{n} @var{s}@angles{line break}
14783 The @samp{f} stands for @var{font}.
14785 Mount font position@tie{}@var{n} (a non-negative integer) with font
14786 named@tie{}@var{s} (a text word).  @xref{Font Positions}.
14788 @item xH @var{n}@angles{line break}
14789 The @samp{H} stands for @var{Height}.
14791 Set glyph height to@tie{}@var{n} (a positive integer in scaled
14792 points @samp{z}).  @acronym{AT&T} @code{troff} uses the unit points
14793 (@samp{p}) instead.  @xref{Output Language Compatibility}.
14795 @item xi@angles{line break}
14796 The @samp{i} stands for @var{init}.
14798 Initialize device.  This is the third command of the prologue.
14800 @item xp@angles{line break}
14801 The @samp{p} stands for @var{pause}.
14803 Parsed but ignored.  The original @acronym{UNIX} troff manual writes
14805 @display
14806 pause device, can be restarted
14807 @end display
14809 @item xr @var{n} @var{h} @var{v}@angles{line break}
14810 The @samp{r} stands for @var{resolution}.
14812 Resolution is@tie{}@var{n}, while @var{h} is the minimal horizontal
14813 motion, and @var{v} the minimal vertical motion possible with this
14814 device; all arguments are positive integers in basic units @samp{u}
14815 per inch.  This is the second command of the prologue.
14817 @item xS @var{n}@angles{line break}
14818 The @samp{S} stands for @var{Slant}.
14820 Set slant to@tie{}@var{n} (an integer in basic units @samp{u}).
14822 @item xs@angles{line break}
14823 The @samp{s} stands for @var{stop}.
14825 Terminates the processing of the current file; issued as the last
14826 command of any intermediate troff output.
14828 @item xt@angles{line break}
14829 The @samp{t} stands for @var{trailer}.
14831 Generate trailer information, if any.  In @var{gtroff}, this is
14832 actually just ignored.
14834 @item xT @var{xxx}@angles{line break}
14835 The @samp{T} stands for @var{Typesetter}.
14837 Set name of device to word @var{xxx}, a sequence of characters ended
14838 by the next white space character.  The possible device names coincide
14839 with those from the @code{groff} @option{-T} option.  This is the first
14840 command of the prologue.
14842 @item xu @var{n}@angles{line break}
14843 The @samp{u} stands for @var{underline}.
14845 Configure underlining of spaces.  If @var{n} is@tie{}1, start
14846 underlining of spaces; if @var{n} is@tie{}0, stop underlining of spaces.
14847 This is needed for the @code{cu} request in nroff mode and is ignored
14848 otherwise.  This command is a @code{gtroff} extension.
14850 @item xX @var{anything}@angles{line break}
14851 The @samp{x} stands for @var{X-escape}.
14853 Send string @var{anything} uninterpreted to the device.  If the line
14854 following this command starts with a @samp{+} character this line is
14855 interpreted as a continuation line in the following sense.  The
14856 @samp{+} is ignored, but a newline character is sent instead to the
14857 device, the rest of the line is sent uninterpreted.  The same applies
14858 to all following lines until the first character of a line is not a
14859 @samp{+} character.  This command is generated by the @code{gtroff}
14860 escape sequence @code{\X}.  The line-continuing feature is a
14861 @code{gtroff} extension.
14862 @end table
14864 @node Obsolete Command,  , Device Control Commands, Command Reference
14865 @subsubsection Obsolete Command
14866 In @acronym{AT&T} @code{troff} output, the writing of a single
14867 glyph is mostly done by a very strange command that combines a
14868 horizontal move and a single character giving the glyph name.  It
14869 doesn't have a command code, but is represented by a 3-character
14870 argument consisting of exactly 2@tie{}digits and a character.
14872 @table @asis
14873 @item @var{dd}@var{g}
14874 Move right @var{dd} (exactly two decimal digits) basic units @samp{u},
14875 then print glyph@tie{}@var{g} (represented as a single character).
14877 In @code{gtroff}, arbitrary syntactical space around and within this
14878 command is allowed to be added.  Only when a preceding command on the
14879 same line ends with an argument of variable length a separating space
14880 is obligatory.  In @acronym{AT&T} @code{troff}, large clusters of these
14881 and other commands are used, mostly without spaces; this made such output
14882 almost unreadable.
14883 @end table
14885 For modern high-resolution devices, this command does not make sense
14886 because the width of the glyphs can become much larger than two
14887 decimal digits.  In @code{gtroff}, this is only used for the devices
14888 @code{X75}, @code{X75-12}, @code{X100}, and @code{X100-12}.  For other
14889 devices, the commands @samp{t} and @samp{u} provide a better
14890 functionality.
14892 @c ---------------------------------------------------------------------
14894 @node Intermediate Output Examples, Output Language Compatibility, Command Reference, gtroff Output
14895 @subsection Intermediate Output Examples
14897 This section presents the intermediate output generated from the same
14898 input for three different devices.  The input is the sentence
14899 @samp{hell world} fed into @code{gtroff} on the command line.
14901 @table @asis
14902 @item High-resolution device @code{ps}
14904 This is the standard output of @code{gtroff} if no @option{-T} option
14905 is given.
14907 @example
14908 @group
14909 shell> echo "hell world" | groff -Z -T ps
14911 x T ps
14912 x res 72000 1 1
14913 x init
14914 @end group
14916 x font 5 TR
14918 s10000
14919 V12000
14920 H72000
14921 thell
14922 wh2500
14924 H96620
14925 torld
14926 n12000 0
14927 @group
14928 x trailer
14929 V792000
14930 x stop
14931 @end group
14932 @end example
14934 @noindent
14935 This output can be fed into @code{grops} to get its representation as
14936 a PostScript file.
14938 @item Low-resolution device @code{latin1}
14940 This is similar to the high-resolution device except that the
14941 positioning is done at a minor scale.  Some comments (lines starting
14942 with @samp{#}) were added for clarification; they were not generated
14943 by the formatter.
14945 @example
14946 @group
14947 shell> echo "hell world" | groff -Z -T latin1
14949 # prologue
14950 x T latin1
14951 x res 240 24 40
14952 x init
14953 @end group
14954 # begin a new page
14956 # font setup
14957 x font 1 R
14960 # initial positioning on the page
14963 # write text `hell'
14964 thell
14965 # inform about space, and issue a horizontal jump
14966 wh24
14967 # write text `world'
14968 tworld
14969 # announce line break, but do nothing because ...
14970 n40 0
14971 @group
14972 # ... the end of the document has been reached
14973 x trailer
14974 V2640
14975 x stop
14976 @end group
14977 @end example
14979 @noindent
14980 This output can be fed into @code{grotty} to get a formatted text
14981 document.
14983 @item @acronym{AT&T} @code{troff} output
14984 Since a computer monitor has a very low resolution compared to modern
14985 printers the intermediate output for the X@tie{}Window devices can use
14986 the jump-and-write command with its 2-digit displacements.
14988 @example
14989 @group
14990 shell> echo "hell world" | groff -Z -T X100
14992 x T X100
14993 x res 100 1 1
14994 x init
14995 @end group
14997 x font 5 TR
15001 H100
15002 # write text with jump-and-write commands
15003 ch07e07l03lw06w11o07r05l03dh7
15004 n16 0
15005 @group
15006 x trailer
15007 V1100
15008 x stop
15009 @end group
15010 @end example
15012 @noindent
15013 This output can be fed into @code{xditview} or @code{gxditview}
15014 for displaying in@tie{}X.
15016 Due to the obsolete jump-and-write command, the text clusters in the
15017 @acronym{AT&T} @code{troff} output are almost unreadable.
15018 @end table
15020 @c ---------------------------------------------------------------------
15022 @node Output Language Compatibility,  , Intermediate Output Examples, gtroff Output
15023 @subsection Output Language Compatibility
15025 The intermediate output language of @acronym{AT&T} @code{troff}
15026 was first documented in the @acronym{UNIX} troff manual, with later
15027 additions documented in @cite{A Typesetter-indenpendent TROFF},
15028 written by Brian Kernighan.
15030 The @code{gtroff} intermediate output format is compatible with this
15031 specification except for the following features.
15033 @itemize @bullet
15034 @item
15035 The classical quasi device independence is not yet implemented.
15037 @item
15038 The old hardware was very different from what we use today.  So the
15039 @code{groff} devices are also fundamentally different from the ones in
15040 @acronym{AT&T} @code{troff}.  For example, the @acronym{AT&T}
15041 PostScript device is called @code{post} and has a resolution of only
15042 720 units per inch, suitable for printers 20 years ago, while
15043 @code{groff}'s @code{ps} device has a resolution of
15044 72000 units per inch.  Maybe, by implementing some rescaling
15045 mechanism similar to the classical quasi device independence,
15046 @code{groff} could emulate @acronym{AT&T}'s @code{post} device.
15048 @item
15049 The B-spline command @samp{D~} is correctly handled by the
15050 intermediate output parser, but the drawing routines aren't
15051 implemented in some of the postprocessor programs.
15053 @item
15054 The argument of the commands @samp{s} and @w{@samp{x H}} has the
15055 implicit unit scaled point @samp{z} in @code{gtroff}, while
15056 @acronym{AT&T} @code{troff} has point (@samp{p}).  This isn't an
15057 incompatibility but a compatible extension, for both units coincide
15058 for all devices without a @code{sizescale} parameter in the @file{DESC}
15059 file, including all postprocessors from @acronym{AT&T} and
15060 @code{groff}'s text devices.  The few @code{groff} devices with
15061 a @code{sizescale} parameter either do not exist for @acronym{AT&T}
15062 @code{troff}, have a different name, or seem to have a different
15063 resolution.  So conflicts are very unlikely.
15065 @item
15066 The position changing after the commands @samp{Dp}, @samp{DP}, and
15067 @samp{Dt} is illogical, but as old versions of @code{gtroff} used this
15068 feature it is kept for compatibility reasons.
15070 @ignore
15071 Temporarily, there existed some confusion on the positioning after the
15072 @samp{D} commands that are groff extensions.  This has been clarified
15073 by establishing the classical rule for all @code{groff} drawing commands:
15075 @itemize
15076 @item
15077 The position after a graphic object has been drawn is at its end;
15078 for circles and ellipses, the `end' is at the right side.
15080 @item
15081 From this, the positionings specified for the drawing commands above
15082 follow quite naturally.
15083 @end itemize
15084 @end ignore
15086 @end itemize
15089 @c =====================================================================
15091 @node Font Files,  , gtroff Output, File formats
15092 @section Font Files
15093 @cindex font files
15094 @cindex files, font
15096 The @code{gtroff} font format is roughly a superset of the
15097 @code{ditroff} font format (as used in later versions of @acronym{AT&T}
15098 @code{troff} and its descendants).  Unlike the @code{ditroff} font
15099 format, there is no associated binary format; all files are text
15100 files.@footnote{Plan@tie{}9 @code{troff} has also abandoned the binary
15101 format.}  The font files for device @var{name} are stored in a directory
15102 @file{dev@var{name}}.  There are two types of file: a device description
15103 file called @file{DESC} and for each font@tie{}@var{f} a font file
15104 called@tie{}@file{@var{f}}.
15106 @menu
15107 * DESC File Format::
15108 * Font File Format::
15109 @end menu
15111 @c ---------------------------------------------------------------------
15113 @node DESC File Format, Font File Format, Font Files, Font Files
15114 @subsection @file{DESC} File Format
15115 @cindex @file{DESC} file, format
15116 @cindex font description file, format
15117 @cindex format of font description file
15118 @pindex DESC@r{ file format}
15120 The @file{DESC} file can contain the following types of line.  Except
15121 for the @code{charset} keyword which must comes last (if at all), the
15122 order of the lines is not important.
15124 @table @code
15125 @item res @var{n}
15126 @kindex res
15127 @cindex device resolution
15128 @cindex resolution, device
15129 There are @var{n}@tie{}machine units per inch.
15131 @item hor @var{n}
15132 @kindex hor
15133 @cindex horizontal resolution
15134 @cindex resolution, horizontal
15135 The horizontal resolution is @var{n}@tie{}machine units.  All horizontal
15136 quantities are rounded to be multiples of this value.
15138 @item vert @var{n}
15139 @kindex vert
15140 @cindex vertical resolution
15141 @cindex resolution, vertical
15142 The vertical resolution is @var{n}@tie{}machine units.  All vertical
15143 quantities are rounded to be multiples of this value.
15145 @item sizescale @var{n}
15146 @kindex sizescale
15147 The scale factor for point sizes.  By default this has a value of@tie{}1.
15148 One scaled point is equal to one point/@var{n}.  The arguments to the
15149 @code{unitwidth} and @code{sizes} commands are given in scaled points.
15150 @xref{Fractional Type Sizes}, for more information.
15152 @item unitwidth @var{n}
15153 @kindex unitwidth
15154 Quantities in the font files are given in machine units for fonts whose
15155 point size is @var{n}@tie{}scaled points.
15157 @item prepro @var{program}
15158 @kindex prepro
15159 Call @var{program} as a preprocessor.  Currently, this keyword is used
15160 by @code{groff} with option @option{-Thtml} only.
15162 @item postpro @var{program}
15163 @kindex postpro
15164 Call @var{program} as a postprocessor.  For example, the line
15166 @Example
15167 postpro grodvi
15168 @endExample
15170 @noindent
15171 in the file @file{devdvi/DESC} makes @code{groff} call @code{grodvi}
15172 if option @option{-Tdvi} is given (and @option{-Z} isn't used).
15174 @item tcommand
15175 @kindex tcommand
15176 This means that the postprocessor can handle the @samp{t} and @samp{u}
15177 intermediate output commands.
15179 @item sizes @var{s1} @var{s2} @dots{} @var{sn} 0
15180 @kindex sizes
15181 This means that the device has fonts at @var{s1}, @var{s2}, @dots{}
15182 @var{sn} scaled points.  The list of sizes must be terminated by@tie{}0
15183 (this is digit zero).  Each @var{si} can also be a range of sizes
15184 @var{m}-@var{n}.  The list can extend over more than one line.
15186 @item styles @var{S1} @var{S2} @dots{} @var{Sm}
15187 @kindex styles
15188 The first @var{m}@tie{}font positions are associated with styles
15189 @var{S1} @dots{} @var{Sm}.
15191 @item fonts @var{n} @var{F1} @var{F2} @var{F3} @dots{} @var{Fn}
15192 @kindex fonts
15193 Fonts @var{F1} @dots{} @var{Fn} are mounted in the font positions
15194 @var{m}+1, @dots{}, @var{m}+@var{n} where @var{m} is the number of
15195 styles.  This command may extend over more than one line.  A font name
15196 of@tie{}0 means no font is mounted on the corresponding font position.
15198 @item family @var{fam}
15199 @kindex family
15200 The default font family is @var{fam}.
15202 @item use_charnames_in_special
15203 @kindex use_charnames_in_special
15204 This command indicates that @code{gtroff} should encode special
15205 characters inside special commands.  Currently, this is only used
15206 by the @acronym{HTML} output device.  @xref{Postprocessor Access}.
15208 @item papersize @var{string} @dots{}
15209 @kindex papersize
15210 Select a paper size.  Valid values for @var{string} are the ISO paper
15211 types @code{A0}-@code{A7}, @code{B0}-@code{B7}, @code{C0}-@code{C7},
15212 @code{D0}-@code{D7}, @code{DL}, and the US paper types @code{letter},
15213 @code{legal}, @code{tabloid}, @code{ledger}, @code{statement},
15214 @code{executive}, @code{com10}, and @code{monarch}.  Case is not significant
15215 for @var{string} if it holds predefined paper types.  Alternatively,
15216 @var{string} can be a file name (e.g.@: @file{/etc/papersize}); if the file
15217 can be opened, @code{groff} reads the first line and tests for the above
15218 paper sizes.  Finally, @var{string} can be a custom paper size in the format
15219 @code{@var{length},@var{width}} (no spaces before and after the comma).
15220 Both @var{length} and @var{width} must have a unit appended; valid values
15221 are @samp{i} for inches, @samp{C} for centimeters, @samp{p} for points, and
15222 @samp{P} for picas.  Example: @code{12c,235p}.  An argument which starts
15223 with a digit is always treated as a custom paper format.  @code{papersize}
15224 sets both the vertical and horizontal dimension of the output medium.
15226 More than one argument can be specified; @code{groff} scans from left to
15227 right and uses the first valid paper specification.
15229 @item pass_filenames
15230 @kindex pass_filenames
15231 Tell @code{gtroff} to emit the name of the source file currently
15232 being processed.  This is achieved by the intermediate output command
15233 @samp{F}.  Currently, this is only used by the @acronym{HTML} output
15234 device.
15236 @item print @var{program}
15237 @kindex print
15238 Use @var{program} as a spooler program for printing.  If omitted,
15239 the @option{-l} and @option{-L} options of @code{groff} are ignored.
15241 @item charset
15242 @kindex charset
15243 This line and everything following in the file are ignored.  It is
15244 allowed for the sake of backwards compatibility.
15245 @end table
15247 The @code{res}, @code{unitwidth}, @code{fonts}, and @code{sizes} lines
15248 are mandatory.  Other commands are ignored by @code{gtroff} but may be
15249 used by postprocessors to store arbitrary information about the device
15250 in the @file{DESC} file.
15252 @kindex spare1
15253 @kindex spare2
15254 @kindex biggestfont
15255 Here a list of obsolete keywords which are recognized by @code{groff}
15256 but completely ignored: @code{spare1}, @code{spare2},
15257 @code{biggestfont}.
15259 @c ---------------------------------------------------------------------
15261 @node Font File Format,  , DESC File Format, Font Files
15262 @subsection Font File Format
15263 @cindex font file, format
15264 @cindex font description file, format
15265 @cindex format of font files
15266 @cindex format of font description files
15268 A @dfn{font file}, also (and probably better) called a @dfn{font
15269 description file}, has two sections.  The first section is a sequence
15270 of lines each containing a sequence of blank delimited words; the first
15271 word in the line is a key, and subsequent words give a value for that
15272 key.
15274 @table @code
15275 @item name @var{f}
15276 @kindex name
15277 The name of the font is@tie{}@var{f}.
15279 @item spacewidth @var{n}
15280 @kindex spacewidth
15281 The normal width of a space is@tie{}@var{n}.
15283 @item slant @var{n}
15284 @kindex slant
15285 The glyphs of the font have a slant of @var{n}@tie{}degrees.
15286 (Positive means forward.)
15288 @item ligatures @var{lig1} @var{lig2} @dots{} @var{lign} [0]
15289 @kindex ligatures
15290 Glyphs @var{lig1}, @var{lig2}, @dots{}, @var{lign} are ligatures;
15291 possible ligatures are @samp{ff}, @samp{fi}, @samp{fl}, @samp{ffi} and
15292 @samp{ffl}.  For backwards compatibility, the list of ligatures may be
15293 terminated with a@tie{}0.  The list of ligatures may not extend over more
15294 than one line.
15296 @item special
15297 @cindex special fonts
15298 @kindex special
15299 The font is @dfn{special}; this means that when a glyph is requested
15300 that is not present in the current font, it is searched for in any
15301 special fonts that are mounted.
15302 @end table
15304 Other commands are ignored by @code{gtroff} but may be used by
15305 postprocessors to store arbitrary information about the font in the font
15306 file.
15308 @cindex comments in font files
15309 @cindex font files, comments
15310 @kindex #
15311 The first section can contain comments which start with the @samp{#}
15312 character and extend to the end of a line.
15314 The second section contains one or two subsections.  It must contain a
15315 @code{charset} subsection and it may also contain a @code{kernpairs}
15316 subsection.  These subsections can appear in any order.  Each
15317 subsection starts with a word on a line by itself.
15319 @kindex charset
15320 The word @code{charset} starts the character set
15321 subsection.@footnote{This keyword is misnamed since it starts a list
15322 of ordered glyphs, not characters.}  The @code{charset} line is
15323 followed by a sequence of lines.  Each line gives information for one
15324 glyph.  A line comprises a number of fields separated by blanks or
15325 tabs.  The format is
15327 @quotation
15328 @var{name} @var{metrics} @var{type} @var{code}
15329 [@var{entity-name}] [@code{--} @var{comment}]
15330 @end quotation
15332 @cindex 8-bit input
15333 @cindex input, 8-bit
15334 @cindex accessing unnamed glyphs with @code{\N}
15335 @cindex unnamed glyphs, accessing with @code{\N}
15336 @cindex characters, unnamed, accessing with @code{\N}
15337 @cindex glyphs, unnamed, accessing with @code{\N}
15338 @kindex ---
15339 @noindent
15340 @var{name} identifies the glyph name@footnote{The distinction between
15341 input, characters, and output, glyphs, is not clearly separated in the
15342 terminology of @code{groff}; for example, the @code{char} request
15343 should be called @code{glyph} since it defines an output entity.}:
15344 If @var{name} is a single character@tie{}@var{c} then it corresponds
15345 to the @code{gtroff} input character@tie{}@var{c}; if it is of the form
15346 @samp{\@var{c}} where @var{c} is a single character, then it
15347 corresponds to the special character @code{\[@var{c}]}; otherwise it
15348 corresponds to the special character @samp{\[@var{name}]}.  If it
15349 is exactly two characters @var{xx} it can be entered as
15350 @samp{\(@var{xx}}.  Note that single-letter special characters can't
15351 be accessed as @samp{\@var{c}}; the only exception is @samp{\-} which
15352 is identical to @code{\[-]}.
15354 @code{gtroff} supports 8-bit input characters; however some utilities
15355 have difficulties with eight-bit characters.  For this reason, there is
15356 a convention that the entity name @samp{char@var{n}} is equivalent to
15357 the single input character whose code is@tie{}@var{n}.  For example,
15358 @samp{char163} would be equivalent to the character with code@tie{}163
15359 which is the pounds sterling sign in the ISO@tie{}@w{Latin-1} character set.
15360 You shouldn't use @samp{char@var{n}} entities in font description files
15361 since they are related to input, not output.  Otherwise, you get
15362 hard-coded connections between input and output encoding which
15363 prevents use of different (input) character sets.
15365 The name @samp{---} is special and indicates that the glyph is
15366 unnamed; such glyphs can only be used by means of the @code{\N}
15367 escape sequence in @code{gtroff}.
15369 The @var{type} field gives the glyph type:
15371 @table @code
15372 @item 1
15373 the glyph has a descender, for example, @samp{p};
15375 @item 2
15376 the glyph has an ascender, for example, @samp{b};
15378 @item 3
15379 the glyph has both an ascender and a descender, for example, @samp{(}.
15380 @end table
15382 The @var{code} field gives the code which the postprocessor uses to
15383 print the glyph.  The glyph can also be input to @code{gtroff}
15384 using this code by means of the @code{\N} escape sequence.  @var{code}
15385 can be any integer.  If it starts with @samp{0} it is interpreted as
15386 octal; if it starts with @samp{0x} or @samp{0X} it is interpreted as
15387 hexadecimal.  Note, however, that the @code{\N} escape sequence only
15388 accepts a decimal integer.
15390 The @var{entity-name} field gives an @acronym{ASCII} string
15391 identifying the glyph which the postprocessor uses to print the
15392 @code{gtroff} glyph @var{name}.  This field is optional and has been
15393 introduced so that the @acronym{HTML} device driver can encode its
15394 character set.  For example, the glyph @samp{\[Po]} is
15395 represented as @samp{&pound;} in @acronym{HTML} 4.0.
15397 Anything on the line after the @var{entity-name} field resp.@: after
15398 @samp{--} will be ignored.
15400 The @var{metrics} field has the form:
15402 @display
15403 @group
15404 @var{width}[@code{,}@var{height}[@code{,}@var{depth}[@code{,}@var{italic-correction}
15405   [@code{,}@var{left-italic-correction}[@code{,}@var{subscript-correction}]]]]]
15406 @end group
15407 @end display
15409 @noindent
15410 There must not be any spaces between these subfields (it has been split
15411 here into two lines for better legibility only).  Missing subfields are
15412 assumed to be@tie{}0.  The subfields are all decimal integers.  Since
15413 there is no associated binary format, these values are not required to
15414 fit into a variable of type @samp{char} as they are in @code{ditroff}.
15415 The @var{width} subfield gives the width of the glyph.  The @var{height}
15416 subfield gives the height of the glyph (upwards is positive); if a
15417 glyph does not extend above the baseline, it should be given a zero
15418 height, rather than a negative height.  The @var{depth} subfield gives
15419 the depth of the glyph, that is, the distance from the baseline to the
15420 lowest point below the baseline to which the glyph extends (downwards is
15421 positive); if a glyph does not extend below the baseline, it should be
15422 given a zero depth, rather than a negative depth.  The
15423 @var{italic-correction} subfield gives the amount of space that should
15424 be added after the glyph when it is immediately to be followed by a
15425 glyph from a roman font.  The @var{left-italic-correction} subfield
15426 gives the amount of space that should be added before the glyph when it
15427 is immediately to be preceded by a glyph from a roman font.  The
15428 @var{subscript-correction} gives the amount of space that should be
15429 added after a glyph before adding a subscript.  This should be less
15430 than the italic correction.
15432 A line in the @code{charset} section can also have the format
15434 @Example
15435 @var{name} "
15436 @endExample
15438 @noindent
15439 This indicates that @var{name} is just another name for the glyph
15440 mentioned in the preceding line.
15442 @kindex kernpairs
15443 The word @code{kernpairs} starts the kernpairs section.  This contains a
15444 sequence of lines of the form:
15446 @Example
15447 @var{c1} @var{c2} @var{n}
15448 @endExample
15450 @noindent
15451 This means that when glyph @var{c1} appears next to glyph @var{c2}
15452 the space between them should be increased by@tie{}@var{n}.  Most
15453 entries in the kernpairs section have a negative value for@tie{}@var{n}.
15457 @c =====================================================================
15458 @c =====================================================================
15460 @node Installation, Copying This Manual, File formats, Top
15461 @chapter Installation
15462 @cindex installation
15464 @c XXX
15468 @c =====================================================================
15469 @c =====================================================================
15471 @node Copying This Manual, Request Index, Installation, Top
15472 @appendix Copying This Manual
15474 @menu
15475 * GNU Free Documentation License::  License for copying this manual.
15476 @end menu
15478 @include fdl.texi
15482 @c =====================================================================
15483 @c =====================================================================
15485 @node Request Index, Escape Index, Copying This Manual, Top
15486 @appendix Request Index
15488 Requests appear without the leading control character (normally either
15489 @samp{.} or @samp{'}).
15491 @printindex rq
15495 @c =====================================================================
15496 @c =====================================================================
15498 @node Escape Index, Operator Index, Request Index, Top
15499 @appendix Escape Index
15501 Any escape sequence @code{\@var{X}} with @var{X} not in the list below
15502 emits a warning, printing glyph @var{X}.
15504 @printindex es
15508 @c =====================================================================
15509 @c =====================================================================
15511 @node Operator Index, Register Index, Escape Index, Top
15512 @appendix Operator Index
15514 @printindex op
15518 @c =====================================================================
15519 @c =====================================================================
15521 @node Register Index, Macro Index, Operator Index, Top
15522 @appendix Register Index
15524 The macro package or program a specific register belongs to is appended in
15525 brackets.
15527 A register name@tie{}@code{x} consisting of exactly one character can be
15528 accessed as @samp{\nx}.  A register name @code{xx} consisting of exactly
15529 two characters can be accessed as @samp{\n(xx}.  Register names @code{xxx}
15530 of any length can be accessed as @samp{\n[xxx]}.
15532 @printindex vr
15536 @c =====================================================================
15537 @c =====================================================================
15539 @node Macro Index, String Index, Register Index, Top
15540 @appendix Macro Index
15542 The macro package a specific macro belongs to is appended in brackets.
15543 They appear without the leading control character (normally @samp{.}).
15545 @printindex ma
15549 @c =====================================================================
15550 @c =====================================================================
15552 @node String Index, Glyph Name Index, Macro Index, Top
15553 @appendix String Index
15555 The macro package or program a specific string belongs to is appended in
15556 brackets.
15558 A string name@tie{}@code{x} consisting of exactly one character can be
15559 accessed as @samp{\*x}.  A string name @code{xx} consisting of exactly
15560 two characters can be accessed as @samp{\*(xx}.  String names @code{xxx}
15561 of any length can be accessed as @samp{\*[xxx]}.
15564 @printindex st
15568 @c =====================================================================
15569 @c =====================================================================
15571 @node Glyph Name Index, Font File Keyword Index, String Index, Top
15572 @appendix Glyph Name Index
15574 A glyph name @code{xx} consisting of exactly two characters can be
15575 accessed as @samp{\(xx}.  Glyph names @code{xxx} of any length can be
15576 accessed as @samp{\[xxx]}.
15578 @c XXX
15582 @c =====================================================================
15583 @c =====================================================================
15585 @node Font File Keyword Index, Program and File Index, Glyph Name Index, Top
15586 @appendix Font File Keyword Index
15588 @printindex ky
15592 @c =====================================================================
15593 @c =====================================================================
15595 @node Program and File Index, Concept Index, Font File Keyword Index, Top
15596 @appendix Program and File Index
15598 @printindex pg
15602 @c =====================================================================
15603 @c =====================================================================
15605 @node Concept Index,  , Program and File Index, Top
15606 @appendix Concept Index
15608 @printindex cp
15611 @bye