* doc/groff.texinfo: Improve documentation of `ad'.
[s-roff.git] / doc / groff.texinfo
blobdbd4a7923279fd7d9239784c51835ad7bd87e07c
1 \input texinfo   @c -*-texinfo-*-
3 @c
4 @c Please convert this manual with `texi2dvi -e groff.texinfo' due to a bug
5 @c in texinfo regarding expansion of user-defined macros.
6 @c
7 @c You need texinfo 4.3 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.)
18 @smallbook
20 @finalout
23 @copying
24 This manual documents GNU @code{troff} version 1.18.
26 Copyright @copyright{} 1994-2000, 2001, 2002, 2003
27 Free Software Foundation, Inc.
29 @quotation
30 Permission is granted to copy, distribute and/or modify this document
31 under the terms of the GNU Free Documentation License, Version 1.1 or
32 any later version published by the Free Software Foundation; with no
33 Invariant Sections, with the Front-Cover texts being `A GNU Manual,''
34 and with the Back-Cover Texts as in (a) below.  A copy of the
35 license is included in the section entitled `GNU Free Documentation
36 License.''
38 (a) The FSF's Back-Cover Text is: `You have freedom to copy and modify
39 this GNU Manual, like GNU software.  Copies published by the Free
40 Software Foundation raise funds for GNU development.''
41 @end quotation
42 @end copying
45 @c We use the following indices:
47 @c   cindex: concepts
48 @c   rqindex: requests
49 @c   esindex: escapes
50 @c   vindex: registers
51 @c   kindex: commands in font files
52 @c   pindex: programs and files
53 @c   tindex: environment variables
54 @c   maindex: macros
55 @c   stindex: strings
56 @c   opindex: operators
58 @c tindex and cindex are merged.
60 @defcodeindex rq
61 @defcodeindex es
62 @defcodeindex ma
63 @defcodeindex st
64 @defcodeindex op
65 @syncodeindex tp cp
68 @c to avoid uppercasing in @deffn while converting to info, we define
69 @c our special @Var{}
71 @c due to a (not officially documented) `feature' in makeinfo 4.0,
72 @c macros are not expanded in @deffn (but the macro definition is
73 @c properly removed), so we have to define @Var{} directly in TeX also
75 @macro Var{arg}
76 \arg\
77 @end macro
78 @tex
79 \gdef\Var#1{\var{#1}}
80 @end tex
83 @c To assure correct HTML translation, some ugly hacks are necessary.
84 @c While processing a @def... request, the HTML translator looks at the
85 @c next line to decide whether it should start indentation or not.  If
86 @c it is something starting with @def... (e.g. @deffnx), it doesn't.
87 @c So we must assure during macro expansion that a @def... is seen.
89 @c The following macros have to be used:
91 @c One item:
93 @c   @Def...
95 @c Two items:
97 @c   @Def...List
98 @c   @Def...ListEnd
100 @c More than two:
102 @c   @Def...List
103 @c   @Def...Item
104 @c   @Def...Item
105 @c   ...
106 @c   @Def...ListEnd
108 @c The definition block must end with
110 @c   @endDef...
112 @c The above is valid for texinfo 4.0f.
115 @c a dummy macro to assure the `@def...'
117 @macro defdummy
118 @end macro
121 @c definition of requests
123 @macro Defreq{name, arg}
124 @deffn Request @t{.\name\} \arg\
125 @rqindex \name\
126 @end macro
128 @macro DefreqList{name, arg}
129 @deffn Request @t{.\name\} \arg\
130 @defdummy
131 @rqindex \name\
132 @end macro
134 @macro DefreqItem{name, arg}
135 @deffnx Request @t{.\name\} \arg\
136 @defdummy
137 @rqindex \name\
138 @end macro
140 @macro DefreqListEnd{name, arg}
141 @deffnx Request @t{.\name\} \arg\
142 @rqindex \name\
143 @end macro
145 @macro endDefreq
146 @end deffn
147 @end macro
150 @c definition of escapes
152 @macro Defesc{name, delimI, arg, delimII}
153 @deffn Escape @t{\name\\delimI\}@var{\arg\}@t{\delimII\}
154 @esindex \name\
155 @end macro
157 @macro DefescList{name, delimI, arg, delimII}
158 @deffn Escape @t{\name\\delimI\}@var{\arg\}@t{\delimII\}
159 @defdummy
160 @esindex \name\
161 @end macro
163 @macro DefescItem{name, delimI, arg, delimII}
164 @deffnx Escape @t{\name\\delimI\}@var{\arg\}@t{\delimII\}
165 @defdummy
166 @esindex \name\
167 @end macro
169 @macro DefescListEnd{name, delimI, arg, delimII}
170 @deffnx Escape @t{\name\\delimI\}@var{\arg\}@t{\delimII\}
171 @esindex \name\
172 @end macro
174 @macro endDefesc
175 @end deffn
176 @end macro
179 @c definition of registers
181 @macro Defreg{name}
182 @deffn Register @t{\\n[\name\]}
183 @vindex \name\
184 @end macro
186 @macro DefregList{name}
187 @deffn Register @t{\\n[\name\]}
188 @defdummy
189 @vindex \name\
190 @end macro
192 @macro DefregItem{name}
193 @deffnx Register @t{\\n[\name\]}
194 @defdummy
195 @vindex \name\
196 @end macro
198 @macro DefregListEnd{name}
199 @deffnx Register @t{\\n[\name\]}
200 @vindex \name\
201 @end macro
203 @macro endDefreg
204 @end deffn
205 @end macro
208 @c definition of registers specific to macro packages, preprocessors, etc.
210 @macro Defmpreg{name, package}
211 @deffn Register @t{\\n[\name\]}
212 @vindex \name\ @r{[}\package\@r{]}
213 @end macro
215 @macro DefmpregList{name, package}
216 @deffn Register @t{\\n[\name\]}
217 @defdummy
218 @vindex \name\ @r{[}\package\@r{]}
219 @end macro
221 @macro DefmpregItem{name, package}
222 @deffnx Register @t{\\n[\name\]}
223 @defdummy
224 @vindex \name\ @r{[}\package\@r{]}
225 @end macro
227 @macro DefmpregListEnd{name, package}
228 @deffnx Register @t{\\n[\name\]}
229 @vindex \name\ @r{[}\package\@r{]}
230 @end macro
232 @macro endDefmpreg
233 @end deffn
234 @end macro
237 @c definition of macros
239 @macro Defmac{name, arg, package}
240 @defmac @t{.\name\} \arg\
241 @maindex \name\ @r{[}\package\@r{]}
242 @end macro
244 @macro DefmacList{name, arg, package}
245 @defmac @t{.\name\} \arg\
246 @defdummy
247 @maindex \name\ @r{[}\package\@r{]}
248 @end macro
250 @macro DefmacItem{name, arg, package}
251 @defmacx @t{.\name\} \arg\
252 @defdummy
253 @maindex \name\ @r{[}\package\@r{]}
254 @end macro
256 @macro DefmacListEnd{name, arg, package}
257 @defmacx @t{.\name\} \arg\
258 @maindex \name\ @r{[}\package\@r{]}
259 @end macro
261 @macro endDefmac
262 @end defmac
263 @end macro
266 @c definition of strings
268 @macro Defstr{name, package}
269 @deffn String @t{\\*[\name\]}
270 @stindex \name\ @r{[}\package\@r{]}
271 @end macro
273 @macro DefstrList{name, package}
274 @deffn String @t{\\*[\name\]}
275 @defdummy
276 @stindex \name\ @r{[}\package\@r{]}
277 @end macro
279 @macro DefstrItem{name, package}
280 @deffnx String @t{\\*[\name\]}
281 @defdummy
282 @stindex \name\ @r{[}\package\@r{]}
283 @end macro
285 @macro DefstrListEnd{name, package}
286 @deffnx String @t{\\*[\name\]}
287 @stindex \name\ @r{[}\package\@r{]}
288 @end macro
290 @macro endDefstr
291 @end deffn
292 @end macro
295 @c our example macro
297 @macro Example
298 @example
299 @group
300 @end macro
302 @macro endExample
303 @end group
304 @end example
305 @end macro
308 @c <text>
310 @tex
311 \gdef\angles#1{\angleleft{}\r{#1}\angleright{}}
312 @end tex
314 @macro angles{text}
315 <\text\>
316 @end macro
319 @c a <= sign
321 @tex
322 \gdef\LE{\le}
323 @end tex
325 @macro LE
327 @end macro
330 @c We need special parentheses and brackets:
332 @c . Real parentheses in @deffn produce an error while compiling with
333 @c   TeX
334 @c . Real brackets use the wrong font in @deffn, overriding @t{}.
336 @c Since macros aren't expanded in @deffn during -E, the following
337 @c definitions are for non-TeX only.
339 @c This is true for texinfo 4.0.
341 @macro lparen
343 @end macro
344 @macro rparen
346 @end macro
347 @macro lbrack
349 @end macro
350 @macro rbrack
352 @end macro
355 @tex
356 \gdef\gobblefirst#1#2{#2}
357 \gdef\putwordAppendix{\gobblefirst}
358 @end tex
361 @c Note: We say `Roman numerals' but `roman font'.
364 @dircategory Miscellaneous
365 @direntry
366 * Groff: (groff).               The GNU troff document formatting system.
367 @end direntry
370 @titlepage
371 @title groff
372 @subtitle The GNU implementation of @code{troff}
373 @subtitle Edition 1.18.2
374 @subtitle Spring 2003
375 @author by Trent A.@tie{}Fisher
376 @author and Werner Lemberg (@email{bug-groff@@gnu.org})
378 @page
379 @vskip 0pt plus 1filll
380 @insertcopying
381 @end titlepage
384 @contents
386 @ifinfo
387 @node Top, Introduction, (dir), (dir)
388 @top GNU troff
390 @insertcopying
391 @end ifinfo
393 @ifhtml
394 @node Top, Introduction, (dir), (dir)
395 @top GNU troff
397 @insertcopying
398 @end ifhtml
400 @menu
401 * Introduction::
402 * Invoking groff::
403 * Tutorial for Macro Users::
404 * Macro Packages::
405 * gtroff Reference::
406 * Preprocessors::
407 * Output Devices::
408 * File formats::
409 * Installation::
410 * Copying This Manual::
411 * Request Index::
412 * Escape Index::
413 * Operator Index::
414 * Register Index::
415 * Macro Index::
416 * String Index::
417 * Glyph Name Index::
418 * Font File Keyword Index::
419 * Program and File Index::
420 * Concept Index::
421 @end menu
425 @c =====================================================================
426 @c =====================================================================
428 @node Introduction, Invoking groff, Top, Top
429 @chapter Introduction
430 @cindex introduction
432 GNU @code{troff} (or @code{groff}) is a system for typesetting
433 documents.  @code{troff} is very flexible and has been in existence (and
434 use) for about 3@tie{}decades.  It is quite widespread and firmly
435 entrenched in the @acronym{UNIX} community.
437 @menu
438 * What Is groff?::
439 * History::
440 * groff Capabilities::
441 * Macro Package Intro::
442 * Preprocessor Intro::
443 * Output device intro::
444 * Credits::
445 @end menu
448 @c =====================================================================
450 @node What Is groff?, History, Introduction, Introduction
451 @section What Is @code{groff}?
452 @cindex what is @code{groff}?
453 @cindex @code{groff} -- what is it?
455 @code{groff} belongs to an older generation of document preparation
456 systems, which operate more like compilers than the more recent
457 interactive @acronym{WYSIWYG}@footnote{What You See Is What You Get}
458 systems.  @code{groff} and its contemporary counterpart, @TeX{}, both
459 work using a @dfn{batch} paradigm: The input (or @dfn{source}) files are
460 normal text files with embedded formatting commands.  These files can
461 then be processed by @code{groff} to produce a typeset document on a
462 variety of devices.
464 Likewise, @code{groff} should not be confused with a @dfn{word
465 processor}, since that term connotes an integrated system that includes
466 an editor and a text formatter.  Also, many word processors follow the
467 @acronym{WYSIWYG} paradigm discussed earlier.
469 Although @acronym{WYSIWYG} systems may be easier to use, they have a
470 number of disadvantages compared to @code{troff}:
472 @itemize @bullet
473 @item
474 They must be used on a graphics display to work on a document.
476 @item
477 Most of the @acronym{WYSIWYG} systems are either non-free or are not
478 very portable.
480 @item
481 @code{troff} is firmly entrenched in all @acronym{UNIX} systems.
483 @item
484 It is difficult to have a wide range of capabilities available within
485 the confines of a GUI/window system.
487 @item
488 It is more difficult to make global changes to a document.
489 @end itemize
491 @quotation
492 ``GUIs normally make it simple to accomplish simple actions and
493 impossible to accomplish complex actions.''  --Doug Gwyn (22/Jun/91 in
494 @code{comp.unix.wizards})
495 @end quotation
498 @c =====================================================================
500 @node History, groff Capabilities, What Is groff?, Introduction
501 @section History
502 @cindex history
504 @cindex @code{runoff}, the program
505 @cindex @code{rf}, the program
506 @code{troff} can trace its origins back to a formatting program called
507 @code{runoff}, written by J.@tie{}E.@tie{}Saltzer, which ran on MIT's CTSS
508 operating system in the mid-sixties.  This name came from the common
509 phrase of the time ``I'll run off a document.''  Bob Morris ported it to
510 the 635 architecture and called the program @code{roff} (an abbreviation
511 of @code{runoff}).  It was rewritten as @code{rf} for the @w{PDP-7}
512 (before having @acronym{UNIX}), and at the same time (1969), Doug
513 McIllroy rewrote an extended and simplified version of @code{roff} in
514 the @acronym{BCPL} programming language.
516 @cindex @code{roff}, the program
517 The first version of @acronym{UNIX} was developed on a @w{PDP-7} which
518 was sitting around Bell Labs.  In 1971 the developers wanted to get a
519 @w{PDP-11} for further work on the operating system.  In order to
520 justify the cost for this system, they proposed that they would
521 implement a document formatting system for the @acronym{AT&T} patents
522 division.  This first formatting program was a reimplementation of
523 McIllroy's @code{roff}, written by J.@tie{}F.@tie{}Ossanna.
525 @cindex @code{nroff}, the program
526 When they needed a more flexible language, a new version of @code{roff}
527 called @code{nroff} (``Newer @code{roff}'') was written.  It had a much
528 more complicated syntax, but provided the basis for all future versions.
529 When they got a Graphic Systems CAT Phototypesetter, Ossanna wrote a
530 version of @code{nroff} that would drive it.  It was dubbed
531 @code{troff}, for ``typesetter @code{roff}'', although many people have
532 speculated that it actually means ``Times @code{roff}'' because of the
533 use of the Times font family in @code{troff} by default.  As such, the
534 name @code{troff} is pronounced `@w{t-roff}' rather than `trough'.
536 With @code{troff} came @code{nroff} (they were actually the same program
537 except for some @samp{#ifdef}s), which was for producing output for line
538 printers and character terminals.  It understood everything @code{troff}
539 did, and ignored the commands which were not applicable (e.g.@: font
540 changes).
542 Since there are several things which cannot be done easily in
543 @code{troff}, work on several preprocessors began.  These programs would
544 transform certain parts of a document into @code{troff}, which made a
545 very natural use of pipes in @acronym{UNIX}.
547 The @code{eqn} preprocessor allowed mathematical formul@ae{} to be
548 specified in a much simpler and more intuitive manner.  @code{tbl} is a
549 preprocessor for formatting tables.  The @code{refer} preprocessor (and
550 the similar program, @code{bib}) processes citations in a document
551 according to a bibliographic database.
553 Unfortunately, Ossanna's @code{troff} was written in @w{PDP-11} assembly
554 language and produced output specifically for the CAT phototypesetter.
555 He rewrote it in C, although it was now 7000@tie{}lines of uncommented
556 code and still dependent on the CAT.  As the CAT became less common, and
557 was no longer supported by the manufacturer, the need to make it support
558 other devices became a priority.  However, before this could be done,
559 Ossanna was killed in a car accident.
561 @pindex ditroff
562 @cindex @code{ditroff}, the program
563 So, Brian Kernighan took on the task of rewriting @code{troff}.  The
564 newly rewritten version produced device independent code which was
565 very easy for postprocessors to read and translate to the appropriate
566 printer codes.  Also, this new version of @code{troff} (called
567 @code{ditroff} for ``device independent @code{troff}'') had several
568 extensions, which included drawing functions.
570 Due to the additional abilities of the new version of @code{troff},
571 several new preprocessors appeared.  The @code{pic} preprocessor
572 provides a wide range of drawing functions.  Likewise the @code{ideal}
573 preprocessor did the same, although via a much different paradigm.  The
574 @code{grap} preprocessor took specifications for graphs, but, unlike
575 other preprocessors, produced @code{pic} code.
577 James Clark began work on a GNU implementation of @code{ditroff} in
578 early@tie{}1989.  The first version, @code{groff}@tie{}0.3.1, was released
579 June@tie{}1990.  @code{groff} included:
581 @itemize @bullet
582 @item
583 A replacement for @code{ditroff} with many extensions.
585 @item
586 The @code{soelim}, @code{pic}, @code{tbl}, and @code{eqn} preprocessors.
588 @item
589 Postprocessors for character devices, @sc{PostScript}, @TeX{} DVI, and
590 X@tie{}Windows.  GNU @code{troff} also eliminated the need for a
591 separate @code{nroff} program with a postprocessor which would produce
592 @acronym{ASCII} output.
594 @item
595 A version of the @file{me} macros and an implementation of the
596 @file{man} macros.
597 @end itemize
599 Also, a front-end was included which could construct the, sometimes
600 painfully long, pipelines required for all the post- and preprocessors.
602 Development of GNU @code{troff} progressed rapidly, and saw the
603 additions of a replacement for @code{refer}, an implementation of the
604 @file{ms} and @file{mm} macros, and a program to deduce how to format a
605 document (@code{grog}).
607 It was declared a stable (i.e.@: non-beta) package with the release of
608 version@tie{}1.04 around November@tie{}1991.
610 Beginning in@tie{}1999, @code{groff} has new maintainers (the package was
611 an orphan for a few years).  As a result, new features and programs like
612 @code{grn}, a preprocessor for gremlin images, and an output device to
613 produce @acronym{HTML} output have been added.
616 @c =====================================================================
618 @node groff Capabilities, Macro Package Intro, History, Introduction
619 @section @code{groff} Capabilities
620 @cindex @code{groff} capabilities
621 @cindex capabilities of @code{groff}
623 So what exactly is @code{groff} capable of doing?  @code{groff} provides
624 a wide range of low-level text formatting operations.  Using these, it
625 is possible to perform a wide range of formatting tasks, such as
626 footnotes, table of contents, multiple columns, etc.  Here's a list of
627 the most important operations supported by @code{groff}:
629 @itemize @bullet
630 @item
631 text filling, adjusting, and centering
633 @item
634 hyphenation
636 @item
637 page control
639 @item
640 font and glyph size control
642 @item
643 vertical spacing (e.g.@: double-spacing)
645 @item
646 line length and indenting
648 @item
649 macros, strings, diversions, and traps
651 @item
652 number registers
654 @item
655 tabs, leaders, and fields
657 @item
658 input and output conventions and character translation
660 @item
661 overstrike, bracket, line drawing, and zero-width functions
663 @item
664 local horizontal and vertical motions and the width function
666 @item
667 three-part titles
669 @item
670 output line numbering
672 @item
673 conditional acceptance of input
675 @item
676 environment switching
678 @item
679 insertions from the standard input
681 @item
682 input/output file switching
684 @item
685 output and error messages
686 @end itemize
689 @c =====================================================================
691 @node Macro Package Intro, Preprocessor Intro, groff Capabilities, Introduction
692 @section Macro Packages
693 @cindex macro packages
695 Since @code{groff} provides such low-level facilities, it can be quite
696 difficult to use by itself.  However, @code{groff} provides a
697 @dfn{macro} facility to specify how certain routine operations
698 (e.g.@tie{}starting paragraphs, printing headers and footers, etc.)@:
699 should be done.  These macros can be collected together into a @dfn{macro
700 package}.  There are a number of macro packages available; the most
701 common (and the ones described in this manual) are @file{man},
702 @file{mdoc}, @file{me}, @file{ms}, and @file{mm}.
705 @c =====================================================================
707 @node Preprocessor Intro, Output device intro, Macro Package Intro, Introduction
708 @section Preprocessors
709 @cindex preprocessors
711 Although @code{groff} provides most functions needed to format a
712 document, some operations would be unwieldy (e.g.@: to draw pictures).
713 Therefore, programs called @dfn{preprocessors} were written which
714 understand their own language and produce the necessary @code{groff}
715 operations.  These preprocessors are able to differentiate their own
716 input from the rest of the document via markers.
718 To use a preprocessor, @acronym{UNIX} pipes are used to feed the output
719 from the preprocessor into @code{groff}.  Any number of preprocessors
720 may be used on a given document; in this case, the preprocessors are
721 linked together into one pipeline.  However, with @code{groff}, the user
722 does not need to construct the pipe, but only tell @code{groff} what
723 preprocessors to use.
725 @code{groff} currently has preprocessors for producing tables
726 (@code{tbl}), typesetting equations (@code{eqn}), drawing pictures
727 (@code{pic} and @code{grn}), and for processing bibliographies
728 (@code{refer}).  An associated program which is useful when dealing with
729 preprocessors is @code{soelim}.
731 A free implementation of @code{grap}, a preprocessor for drawing graphs,
732 can be obtained as an extra package; @code{groff} can use @code{grap}
733 also.
735 There are other preprocessors in existence, but, unfortunately, no free
736 implementations are available.  Among them are preprocessors for drawing
737 mathematical pictures (@code{ideal}) and chemical structures
738 (@code{chem}).
741 @c =====================================================================
743 @node Output device intro, Credits, Preprocessor Intro, Introduction
744 @section Output Devices
745 @cindex postprocessors
746 @cindex output devices
747 @cindex devices for output
749 @code{groff} actually produces device independent code which may be
750 fed into a postprocessor to produce output for a particular device.
751 Currently, @code{groff} has postprocessors for @sc{PostScript}
752 devices, character terminals, X@tie{}Windows (for previewing), @TeX{}
753 DVI format, HP LaserJet@tie{}4 and Canon LBP printers (which use
754 @acronym{CAPSL}), and @acronym{HTML}.
757 @c =====================================================================
759 @node Credits,  , Output device intro, Introduction
760 @section Credits
761 @cindex credits
763 Large portions of this manual were taken from existing documents, most
764 notably, the manual pages for the @code{groff} package by James Clark,
765 and Eric Allman's papers on the @file{me} macro package.
767 The section on the @file{man} macro package is partly based on
768 Susan@tie{}G.@: Kleinmann's @file{groff_man} manual page written for the
769 Debian GNU/Linux system.
771 Larry Kollar contributed the section in the @file{ms} macro package.
775 @c =====================================================================
776 @c =====================================================================
778 @node Invoking groff, Tutorial for Macro Users, Introduction, Top
779 @chapter Invoking @code{groff}
780 @cindex invoking @code{groff}
781 @cindex @code{groff} invocation
783 This section focuses on how to invoke the @code{groff} front end.  This
784 front end takes care of the details of constructing the pipeline among
785 the preprocessors, @code{gtroff} and the postprocessor.
787 It has become a tradition that GNU programs get the prefix @samp{g} to
788 distinguish it from its original counterparts provided by the host (see
789 @ref{Environment}, for more details).  Thus, for example, @code{geqn} is
790 GNU @code{eqn}.  On operating systems like GNU/Linux or the Hurd, which
791 don't contain proprietary versions of @code{troff}, and on
792 MS-DOS/MS-Windows, where @code{troff} and associated programs are not
793 available at all, this prefix is omitted since GNU @code{troff} is the
794 only used incarnation of @code{troff}.  Exception: @samp{groff} is never
795 replaced by @samp{roff}.
797 In this document, we consequently say @samp{gtroff} when talking about
798 the GNU @code{troff} program.  All other implementations of @code{troff}
799 are called @acronym{AT&T} @code{troff} which is the common origin of
800 all @code{troff} derivates (with more or less compatible changes).
801 Similarly, we say @samp{gpic}, @samp{geqn}, etc.
803 @menu
804 * Groff Options::
805 * Environment::
806 * Macro Directories::
807 * Font Directories::
808 * Invocation Examples::
809 @end menu
812 @c =====================================================================
814 @node Groff Options, Environment, Invoking groff, Invoking groff
815 @section Options
816 @cindex options
818 @pindex groff
819 @pindex gtroff
820 @pindex gpic
821 @pindex geqn
822 @pindex ggrn
823 @pindex grap
824 @pindex gtbl
825 @pindex grefer
826 @pindex gsoelim
827 @code{groff} normally runs the @code{gtroff} program and a postprocessor
828 appropriate for the selected device.  The default device is @samp{ps}
829 (but it can be changed when @code{groff} is configured and built).  It
830 can optionally preprocess with any of @code{gpic}, @code{geqn},
831 @code{gtbl}, @code{ggrn}, @code{grap}, @code{grefer}, or @code{gsoelim}.
833 This section only documents options to the @code{groff} front end.  Many
834 of the arguments to @code{groff} are passed on to @code{gtroff},
835 therefore those are also included.  Arguments to pre- or postprocessors
836 can be found in @ref{Invoking gpic}, @ref{Invoking geqn}, @ref{Invoking
837 gtbl}, @ref{Invoking ggrn}, @ref{Invoking grefer}, @ref{Invoking
838 gsoelim}, @ref{Invoking grotty}, @ref{Invoking grops}, @ref{Invoking
839 grohtml}, @ref{Invoking grodvi}, @ref{Invoking grolj4}, @ref{Invoking
840 grolbp}, and @ref{Invoking gxditview}.
842 The command line format for @code{groff} is:
844 @Example
845 groff [ -abceghilpstvzCEGNRSUVXZ ] [ -F@var{dir} ] [ -m@var{name} ]
846       [ -T@var{def} ] [ -f@var{fam} ] [ -w@var{name} ] [ -W@var{name} ]
847       [ -M@var{dir} ] [ -d@var{cs} ] [ -r@var{cn} ] [ -n@var{num} ]
848       [ -o@var{list} ] [ -P@var{arg} ] [ -L@var{arg} ] [ -I@var{dir} ]
849       [ @var{files}@dots{} ]
850 @endExample
852 The command line format for @code{gtroff} is as follows.
854 @Example
855 gtroff [ -abcivzCERU ] [ -w@var{name} ] [ -W@var{name} ] [ -d@var{cs} ]
856        [ -f@var{fam} ] [ -m@var{name} ] [ -n@var{num} ]
857        [ -o@var{list} ] [ -r@var{cn} ] [ -T@var{name} ]
858        [ -F@var{dir} ] [ -M@var{dir} ] [ @var{files}@dots{} ]
859 @endExample
861 @noindent
862 Obviously, many of the options to @code{groff} are actually passed on to
863 @code{gtroff}.
865 Options without an argument can be grouped behind a single@tie{}@option{-}.
866 A filename of@tie{}@file{-} denotes the standard input.  It is possible to
867 have whitespace between an option and its parameter.
869 The @code{grog} command can be used to guess the correct @code{groff}
870 command to format a file.
872 Here's the description of the command-line options:
874 @cindex command-line options
875 @table @samp
876 @item -h
877 Print a help message.
879 @item -e
880 Preprocess with @code{geqn}.
882 @item -t
883 Preprocess with @code{gtbl}.
885 @item -g
886 Preprocess with @code{ggrn}.
888 @item -G
889 Preprocess with @code{grap}.
891 @item -p
892 Preprocess with @code{gpic}.
894 @item -s
895 Preprocess with @code{gsoelim}.
897 @item -c
898 Suppress color output.
900 @item -R
901 Preprocess with @code{grefer}.  No mechanism is provided for passing
902 arguments to @code{grefer} because most @code{grefer} options have
903 equivalent commands which can be included in the file.  @xref{grefer},
904 for more details.
906 @pindex troffrc
907 @pindex troffrc-end
908 Note that @code{gtroff} also accepts a @option{-R} option, which is not
909 accessible via @code{groff}.  This option prevents the loading of the
910 @file{troffrc} and @file{troffrc-end} files.
912 @item -v
913 Make programs run by @code{groff} print out their version number.
915 @item -V
916 Print the pipeline on @code{stdout} instead of executing it.
918 @item -z
919 Suppress output from @code{gtroff}.  Only error messages are printed.
921 @item -Z
922 Do not postprocess the output of @code{gtroff}.  Normally @code{groff}
923 automatically runs the appropriate postprocessor.
925 @item -P@var{arg}
926 Pass @var{arg} to the postprocessor.  Each argument should be passed
927 with a separate @option{-P} option.  Note that @code{groff} does not
928 prepend @samp{-} to @var{arg} before passing it to the postprocessor.
930 @item -l
931 Send the output to a spooler for printing.  The command used for this is
932 specified by the @code{print} command in the device description file
933 (see @ref{Font Files}, for more info).  If not present, @option{-l} is
934 ignored.
936 @item -L@var{arg}
937 Pass @var{arg} to the spooler.  Each argument should be passed with a
938 separate @option{-L} option.  Note that @code{groff} does not prepend
939 a @samp{-} to @var{arg} before passing it to the postprocessor.
940 If the @code{print} keyword in the device description file is missing,
941 @option{-L} is ignored.
943 @item -T@var{dev}
944 Prepare output for device @var{dev}.  The default device is @samp{ps},
945 unless changed when @code{groff} was configured and built.  The
946 following are the output devices currently available:
948 @table @code
949 @item ps
950 For @sc{PostScript} printers and previewers.
952 @item dvi
953 For @TeX{} DVI format.
955 @item X75
956 For a 75@dmn{dpi} X11 previewer.
958 @item X75-12
959 For a 75@dmn{dpi} X11 previewer with a 12@dmn{pt} base font in the
960 document.
962 @item X100
963 For a 100@dmn{dpi} X11 previewer.
965 @item X100-12
966 For a 100@dmn{dpi} X11 previewer with a 12@dmn{pt} base font in the
967 document.
969 @item ascii
970 @cindex encoding, @acronym{ASCII}
971 @cindex @acronym{ASCII}, encoding
972 For typewriter-like devices using the (7-bit) @acronym{ASCII}
973 character set.
975 @item latin1
976 @cindex encoding, latin-1
977 @cindex latin-1, encoding
978 For typewriter-like devices that support the @w{Latin-1}
979 (ISO@tie{}@w{8859-1}) character set.
981 @item utf8
982 @cindex encoding, utf-8
983 @cindex utf-8, encoding
984 For typewriter-like devices which use the Unicode (ISO@tie{}10646)
985 character set with @w{UTF-8} encoding.
987 @item cp1047
988 @cindex @acronym{EBCDIC} encoding
989 @cindex encoding, @acronym{EBCDIC}
990 @cindex encoding, cp1047
991 @cindex cp1047
992 @cindex IBM cp1047
993 For typewriter-like devices which use the @acronym{EBCDIC} encoding IBM
994 cp1047.
996 @item lj4
997 For HP LaserJet4-compatible (or other PCL5-compatible) printers.
999 @item lbp
1000 For Canon @acronym{CAPSL} printers (@w{LBP-4} and @w{LBP-8} series laser
1001 printers).
1003 @pindex pre-grohtml
1004 @pindex post-grohtml
1005 @cindex @code{grohtml}, the program
1006 @item html
1007 To produce @acronym{HTML} output.  Note that the @acronym{HTML} driver
1008 consists of two parts, a preprocessor (@code{pre-grohtml}) and a
1009 postprocessor (@code{post-grohtml}).
1010 @end table
1012 @cindex output device name string register (@code{.T})
1013 @cindex output device usage number register (@code{.T})
1014 The predefined @code{gtroff} string register @code{.T} contains the
1015 current output device; the read-only number register @code{.T} is set
1016 to@tie{}1 if this option is used (which is always true if @code{groff} is
1017 used to call @code{gtroff}).  @xref{Built-in Registers}.
1019 The postprocessor to be used for a device is specified by the
1020 @code{postpro} command in the device description file.  (@xref{Font
1021 Files}, for more info.)  This can be overridden with the @option{-X}
1022 option.
1024 @item -X
1025 Preview with @code{gxditview} instead of using the usual postprocessor.
1026 This is unlikely to produce good results except with @option{-Tps}.
1028 Note that this is not the same as using @option{-TX75} or
1029 @option{-TX100} to view a document with @code{gxditview}: The former
1030 uses the metrics of the specified device, whereas the latter uses
1031 X-specific fonts and metrics.
1033 @item -N
1034 Don't allow newlines with @code{eqn} delimiters.  This is the same as
1035 the @option{-N} option in @code{geqn}.
1037 @item -S
1038 @cindex @code{open} request, and safer mode
1039 @cindex @code{opena} request, and safer mode
1040 @cindex @code{pso} request, and safer mode
1041 @cindex @code{sy} request, and safer mode
1042 @cindex @code{pi} request, and safer mode
1043 @cindex safer mode
1044 @cindex mode, safer
1045 Safer mode.  Pass the @option{-S} option to @code{gpic} and disable the
1046 @code{open}, @code{opena}, @code{pso}, @code{sy}, and @code{pi}
1047 requests.  For security reasons, this is enabled by default.
1049 @item -U
1050 @cindex mode, unsafe
1051 @cindex unsafe mode
1052 Unsafe mode.  This enables the @code{open}, @code{opena}, @code{pso},
1053 @code{sy}, and @code{pi} requests.
1055 @item -a
1056 @cindex @acronym{ASCII} approximation output register (@code{.A})
1057 Generate an @acronym{ASCII} approximation of the typeset output.  The
1058 read-only register @code{.A} is then set to@tie{}1.  @xref{Built-in
1059 Registers}.  A typical example is
1061 @Example
1062 groff -a -man -Tdvi troff.man | less
1063 @endExample
1065 @noindent
1066 which shows how lines are broken for the DVI device.  Note that this
1067 option is rather useless today since graphic output devices are
1068 available virtually everywhere.
1070 @item -b
1071 Print a backtrace with each warning or error message.  This backtrace
1072 should help track down the cause of the error.  The line numbers given
1073 in the backtrace may not always be correct: @code{gtroff} can get
1074 confused by @code{as} or @code{am} requests while counting line numbers.
1076 @item -i
1077 Read the standard input after all the named input files have been
1078 processed.
1080 @item -w@var{name}
1081 Enable warning @var{name}.  Available warnings are described in
1082 @ref{Debugging}.  Multiple @option{-w} options are allowed.
1084 @item -W@var{name}
1085 Inhibit warning @var{name}.  Multiple @option{-W} options are allowed.
1087 @item -E
1088 Inhibit all error messages.
1090 @item -C
1091 Enable compatibility mode.  @xref{Implementation Differences}, for the
1092 list of incompatibilities between @code{groff} and @acronym{AT&T}
1093 @code{troff}.
1095 @item -d@var{c}@var{s}
1096 @itemx -d@var{name}=@var{s}
1097 Define @var{c} or @var{name} to be a string@tie{}@var{s}.  @var{c}@tie{}must
1098 be a one-letter name; @var{name} can be of arbitrary length.  All string
1099 assignments happen before loading any macro file (including the start-up
1100 file).
1102 @item -f@var{fam}
1103 Use @var{fam} as the default font family.  @xref{Font Families}.
1105 @item -m@var{name}
1106 Read in the file @file{@var{name}.tmac}.  Normally @code{groff} searches
1107 for this in its macro directories.  If it isn't found, it tries
1108 @file{tmac.@var{name}} (searching in the same directories).
1110 @item -n@var{num}
1111 Number the first page @var{num}.
1113 @item -o@var{list}
1114 @cindex print current page register (@code{.P})
1115 Output only pages in @var{list}, which is a comma-separated list of page
1116 ranges; @samp{@var{n}} means print page@tie{}@var{n}, @samp{@var{m}-@var{n}}
1117 means print every page between @var{m} and@tie{}@var{n}, @samp{-@var{n}}
1118 means print every page up to@tie{}@var{n}, @samp{@var{n}-} means print every
1119 page beginning with@tie{}@var{n}.  @code{gtroff} exits after printing the
1120 last page in the list.  All the ranges are inclusive on both ends.
1122 Within @code{gtroff}, this information can be extracted with the
1123 @samp{.P} register.  @xref{Built-in Registers}.
1125 If your document restarts page numbering at the beginning of each
1126 chapter, then @code{gtroff} prints the specified page range for each
1127 chapter.
1129 @item -r@var{c}@var{n}
1130 @itemx -r@var{name}=@var{n}
1131 Set number register@tie{}@var{c} or @var{name} to the value@tie{}@var{n}.
1132 @var{c}@tie{}must be a one-letter name; @var{name} can be of arbitrary
1133 length.  @var{n}@tie{}can be any @code{gtroff} numeric expression.  All
1134 register  assignments happen before loading any macro file (including
1135 the start-up file).
1137 @item -F@var{dir}
1138 Search @file{@var{dir}} for subdirectories @file{dev@var{name}}
1139 (@var{name} is the name of the device), for the @file{DESC} file, and
1140 for font files before looking in the standard directories (@pxref{Font
1141 Directories}).  This option is passed to all pre- and postprocessors
1142 using the @env{GROFF_FONT_PATH} environment variable.
1144 @item -M@var{dir}
1145 Search directory @file{@var{dir}} for macro files before the standard
1146 directories (@pxref{Macro Directories}).
1148 @item -I@var{dir}
1149 This option is as described in @ref{gsoelim}.  It implies the
1150 @option{-s} option.
1151 @end table
1154 @c =====================================================================
1156 @node Environment, Macro Directories, Groff Options, Invoking groff
1157 @section Environment
1158 @cindex environment variables
1159 @cindex variables in environment
1161 There are also several environment variables (of the operating system,
1162 not within @code{gtroff}) which can modify the behavior of @code{groff}.
1164 @table @code
1165 @item GROFF_COMMAND_PREFIX
1166 @tindex GROFF_COMMAND_PREFIX@r{, environment variable}
1167 @cindex command prefix
1168 @cindex prefix, for commands
1169 If this is set to@tie{}@var{X}, then @code{groff} runs @code{@var{X}troff}
1170 instead of @code{gtroff}.  This also applies to @code{tbl}, @code{pic},
1171 @code{eqn}, @code{grn}, @code{refer}, and @code{soelim}.  It does not
1172 apply to @code{grops}, @code{grodvi}, @code{grotty}, @code{pre-grohtml},
1173 @code{post-grohtml}, @code{grolj4}, and @code{gxditview}.
1175 The default command prefix is determined during the installation process.
1176 If a non-GNU troff system is found, prefix @samp{g} is used, none
1177 otherwise.
1179 @item GROFF_TMAC_PATH
1180 @tindex GROFF_TMAC_PATH@r{, environment variable}
1181 A colon-separated list of directories in which to search for macro files
1182 (before the default directories are tried).  @xref{Macro Directories}.
1184 @item GROFF_TYPESETTER
1185 @tindex GROFF_TYPESETTER@r{, environment variable}
1186 The default output device.
1188 @item GROFF_FONT_PATH
1189 @tindex GROFF_FONT_PATH@r{, environment variable}
1190 A colon-separated list of directories in which to search for the
1191 @code{dev}@var{name} directory (before the default directories are
1192 tried).  @xref{Font Directories}.
1194 @item GROFF_BIN_PATH
1195 @tindex GROFF_BIN_PATH@r{, environment variable}
1196 This search path, followed by @code{PATH}, is used for commands executed
1197 by @code{groff}.
1199 @item GROFF_TMPDIR
1200 @tindex GROFF_TMPDIR@r{, environment variable}
1201 @tindex TMPDIR@r{, environment variable}
1202 The directory in which @code{groff} creates temporary files.  If this is
1203 not set and @env{TMPDIR} is set, temporary files are created in that
1204 directory.  Otherwise temporary files are created in a system-dependent
1205 default directory (on Unix and GNU/Linux systems, this is usually
1206 @file{/tmp}).  @code{grops}, @code{grefer}, @code{pre-grohtml}, and
1207 @code{post-grohtml} can create temporary files in this directory.
1208 @end table
1210 Note that MS-DOS and MS-Windows ports of @code{groff} use semi-colons,
1211 rather than colons, to separate the directories in the lists described
1212 above.
1215 @c =====================================================================
1217 @node Macro Directories, Font Directories, Environment, Invoking groff
1218 @section Macro Directories
1219 @cindex macro directories
1220 @cindex directories for macros
1221 @cindex searching macros
1222 @cindex macros, searching
1224 All macro file names must be named @code{@var{name}.tmac} or
1225 @code{tmac.@var{name}} to make the @option{-m@var{name}} command line
1226 option work.  The @code{mso} request doesn't have this restriction; any
1227 file name can be used, and @code{gtroff} won't try to append or prepend
1228 the @samp{tmac} string.
1230 @cindex tmac, directory
1231 @cindex directory, for tmac files
1232 @cindex tmac, path
1233 @cindex path, for tmac files
1234 @cindex searching macro files
1235 @cindex macro files, searching
1236 @cindex files, macro, searching
1237 Macro files are kept in the @dfn{tmac directories}, all of which
1238 constitute the @dfn{tmac path}.  The elements of the search path for
1239 macro files are (in that order):
1241 @itemize @bullet
1242 @item
1243 The directories specified with @code{gtroff}'s or @code{groff}'s
1244 @option{-M} command line option.
1246 @item
1247 @tindex GROFF_TMAC_PATH@r{, environment variable}
1248 The directories given in the @env{GROFF_TMAC_PATH} environment
1249 variable.
1251 @item
1252 @cindex safer mode
1253 @cindex mode, safer
1254 @cindex unsafe mode
1255 @cindex mode, unsafe
1256 @cindex current directory
1257 @cindex directory, current
1258 The current directory (only if in unsafe mode using the @option{-U}
1259 command line switch).
1261 @item
1262 @cindex home directory
1263 @cindex directory, home
1264 The home directory.
1266 @item
1267 @cindex site-specific directory
1268 @cindex directory, site-specific
1269 @cindex platform-specific directory
1270 @cindex directory, platform-specific
1271 A platform-dependent directory, a site-specific (platform-independent)
1272 directory, and the main tmac directory; the default locations are
1274 @Example
1275 /usr/local/lib/groff/site-tmac
1276 /usr/local/share/groff/site-tmac
1277 /usr/local/share/groff/1.18/tmac
1278 @endExample
1280 @noindent
1281 assuming that the version of @code{groff} is 1.18, and the installation
1282 prefix was @file{/usr/local}.  It is possible to fine-tune those
1283 directories during the installation process.
1284 @end itemize
1287 @c =====================================================================
1289 @node Font Directories, Invocation Examples, Macro Directories, Invoking groff
1290 @section Font Directories
1291 @cindex font directories
1292 @cindex directories for fonts
1293 @cindex searching fonts
1294 @cindex fonts, searching
1296 Basically, there is no restriction how font files for @code{groff} are
1297 named and how long font names are; however, to make the font family
1298 mechanism work (@pxref{Font Families}), fonts within a family should
1299 start with the family name, followed by the shape.  For example, the
1300 Times family uses @samp{T} for the family name and @samp{R}, @samp{B},
1301 @samp{I}, and @samp{BI} to indicate the shapes `roman', `bold',
1302 `italic', and `bold italic', respectively.  Thus the final font names
1303 are @samp{TR}, @samp{TB}, @samp{TI}, and @samp{TBI}.
1305 @cindex font path
1306 @cindex path, for font files
1307 All font files are kept in the @dfn{font directories} which constitute
1308 the @dfn{font path}.  The file search functions will always append the
1309 directory @code{dev}@var{name}, where @var{name} is the name of the
1310 output device.  Assuming, say, DVI output, and @file{/foo/bar} as a
1311 font directory, the font files for @code{grodvi} must be in
1312 @file{/foo/bar/devdvi}.
1314 The elements of the search path for font files are (in that order):
1316 @itemize @bullet
1317 @item
1318 The directories specified with @code{gtroff}'s or @code{groff}'s
1319 @option{-F} command line option.  All device drivers and some
1320 preprocessors also have this option.
1322 @item
1323 @tindex GROFF_FONT_PATH@r{, environment variable}
1324 The directories given in the @env{GROFF_FONT_PATH} environment
1325 variable.
1327 @item
1328 @cindex site-specific directory
1329 @cindex directory, site-specific
1330 A site-specific directory and the main font directory; the default
1331 locations are
1333 @Example
1334 /usr/local/share/groff/site-font
1335 /usr/local/share/groff/1.18/font
1336 @endExample
1338 @noindent
1339 assuming that the version of @code{groff} is 1.18, and the installation
1340 prefix was @file{/usr/local}.  It is possible to fine-tune those
1341 directories during the installation process.
1342 @end itemize
1345 @c =====================================================================
1347 @node Invocation Examples,  , Font Directories, Invoking groff
1348 @section Invocation Examples
1349 @cindex invocation examples
1350 @cindex examples of invocation
1352 This section lists several common uses of @code{groff} and the
1353 corresponding command lines.
1355 @Example
1356 groff file
1357 @endExample
1359 @noindent
1360 This command processes @file{file} without a macro package or a
1361 preprocessor.  The output device is the default, @samp{ps}, and the
1362 output is sent to @code{stdout}.
1364 @Example
1365 groff -t -mandoc -Tascii file | less
1366 @endExample
1368 @noindent
1369 This is basically what a call to the @code{man} program does.
1370 @code{gtroff} processes the manual page @file{file} with the
1371 @file{mandoc} macro file (which in turn either calls the @file{man} or
1372 the @file{mdoc} macro package), using the @code{tbl} preprocessor and
1373 the @acronym{ASCII} output device.  Finally, the @code{less} pager
1374 displays the result.
1376 @Example
1377 groff -X -m me file
1378 @endExample
1380 @noindent
1381 Preview @file{file} with @code{gxditview}, using the @file{me} macro
1382 package.  Since no @option{-T} option is specified, use the default
1383 device (@samp{ps}).  Note that you can either say @w{@samp{-m me}} or
1384 @w{@samp{-me}}; the latter is an anachronism from the early days of
1385 @acronym{UNIX}.@footnote{The same is true for the other main macro
1386 packages that come with @code{groff}: @file{man}, @file{mdoc},
1387 @file{ms}, @file{mm}, and @file{mandoc}.  This won't work in general;
1388 for example, to load @file{trace.tmac}, either @samp{-mtrace} or
1389 @w{@samp{-m trace}} must be used.}
1391 @Example
1392 groff -man -rD1 -z file
1393 @endExample
1395 @noindent
1396 Check @file{file} with the @file{man} macro package, forcing
1397 double-sided printing -- don't produce any output.
1399 @menu
1400 * grog::
1401 @end menu
1403 @c ---------------------------------------------------------------------
1405 @node grog,  , Invocation Examples, Invocation Examples
1406 @subsection @code{grog}
1408 @pindex grog
1409 @code{grog} reads files, guesses which of the @code{groff} preprocessors
1410 and/or macro packages are required for formatting them, and prints the
1411 @code{groff} command including those options on the standard output.  It
1412 generates one or more of the options @option{-e}, @option{-man},
1413 @option{-me}, @option{-mm}, @option{-mom}, @option{-ms}, @option{-mdoc},
1414 @option{-mdoc-old}, @option{-p}, @option{-R}, @option{-g}, @option{-G},
1415 @option{-s}, and @option{-t}.
1417 A special file name@tie{}@file{-} refers to the standard input.  Specifying
1418 no files also means to read the standard input.  Any specified options
1419 are included in the printed command.  No space is allowed between
1420 options and their arguments.  The only options recognized are
1421 @option{-C} (which is also passed on) to enable compatibility mode, and
1422 @option{-v} to print the version number and exit.
1424 For example,
1426 @Example
1427 grog -Tdvi paper.ms
1428 @endExample
1430 @noindent
1431 guesses the appropriate command to print @file{paper.ms} and then prints
1432 it to the command line after adding the @option{-Tdvi} option.  For
1433 direct execution, enclose the call to @code{grog} in backquotes at the
1434 @acronym{UNIX} shell prompt:
1436 @Example
1437 `grog -Tdvi paper.ms` > paper.dvi
1438 @endExample
1440 @noindent
1441 As seen in the example, it is still necessary to redirect the output to
1442 something meaningful (i.e.@: either a file or a pager program like
1443 @code{less}).
1447 @c =====================================================================
1448 @c =====================================================================
1450 @node Tutorial for Macro Users, Macro Packages, Invoking groff, Top
1451 @chapter Tutorial for Macro Users
1452 @cindex tutorial for macro users
1453 @cindex macros, tutorial for users
1454 @cindex user's tutorial for macros
1455 @cindex user's macro tutorial
1457 Most users tend to use a macro package to format their papers.  This
1458 means that the whole breadth of @code{groff} is not necessary for most
1459 people.  This chapter covers the material needed to efficiently use a
1460 macro package.
1462 @menu
1463 * Basics::
1464 * Common Features::
1465 @end menu
1468 @c =====================================================================
1470 @node Basics, Common Features, Tutorial for Macro Users, Tutorial for Macro Users
1471 @section Basics
1472 @cindex basics of macros
1473 @cindex macro basics
1475 This section covers some of the basic concepts necessary to understand
1476 how to use a macro package.@footnote{This section is derived from
1477 @cite{Writing Papers with nroff using -me} by Eric P.@tie{}Allman.}
1478 References are made throughout to more detailed information, if desired.
1480 @code{gtroff} reads an input file prepared by the user and outputs a
1481 formatted document suitable for publication or framing.  The input
1482 consists of text, or words to be printed, and embedded commands
1483 (@dfn{requests} and @dfn{escapes}), which tell @code{gtroff} how to
1484 format the output.  For more detail on this, see @ref{Embedded
1485 Commands}.
1487 The word @dfn{argument} is used in this chapter to mean a word or number
1488 which appears on the same line as a request, and which modifies the
1489 meaning of that request.  For example, the request
1491 @Example
1493 @endExample
1495 @noindent
1496 spaces one line, but
1498 @Example
1499 .sp 4
1500 @endExample
1502 @noindent
1503 spaces four lines.  The number@tie{}4 is an argument to the @code{sp}
1504 request which says to space four lines instead of one.  Arguments are
1505 separated from the request and from each other by spaces (@emph{no}
1506 tabs).  More details on this can be found in @ref{Request Arguments}.
1508 The primary function of @code{gtroff} is to collect words from input
1509 lines, fill output lines with those words, justify the right-hand margin
1510 by inserting extra spaces in the line, and output the result.  For
1511 example, the input:
1513 @Example
1514 Now is the time
1515 for all good men
1516 to come to the aid
1517 of their party.
1518 Four score and seven
1519 years ago, etc.
1520 @endExample
1522 @noindent
1523 is read, packed onto output lines, and justified to produce:
1525 @quotation
1526 Now is the time for all good men to come to the aid of their party.
1527 Four score and seven years ago, etc.
1528 @end quotation
1530 @cindex break
1531 @cindex line break
1532 Sometimes a new output line should be started even though the current
1533 line is not yet full; for example, at the end of a paragraph.  To do
1534 this it is possible to cause a @dfn{break}, which starts a new output
1535 line.  Some requests cause a break automatically, as normally do blank
1536 input lines and input lines beginning with a space.
1538 Not all input lines are text to be formatted.  Some input lines are
1539 requests which describe how to format the text.  Requests always have a
1540 period (@samp{.}) or an apostrophe (@samp{'}) as the first character of
1541 the input line.
1543 The text formatter also does more complex things, such as automatically
1544 numbering pages, skipping over page boundaries, putting footnotes in the
1545 correct place, and so forth.
1547 Here are a few hints for preparing text for input to @code{gtroff}.
1549 @itemize @bullet
1550 @item
1551 First, keep the input lines short.  Short input lines are easier to
1552 edit, and @code{gtroff} packs words onto longer lines anyhow.
1554 @item
1555 In keeping with this, it is helpful to begin a new line after every
1556 comma or phrase, since common corrections are to add or delete sentences
1557 or phrases.
1559 @item
1560 End each sentence with two spaces -- or better, start each sentence on a
1561 new line.  @code{gtroff} recognizes characters that usually end a
1562 sentence, and inserts sentence space accordingly.
1564 @item
1565 Do not hyphenate words at the end of lines -- @code{gtroff} is smart
1566 enough to hyphenate words as needed, but is not smart enough to take
1567 hyphens out and join a word back together.  Also, words such as
1568 ``mother-in-law'' should not be broken over a line, since then a space
1569 can occur where not wanted, such as ``@w{mother- in}-law''.
1570 @end itemize
1572 @cindex double-spacing (@code{ls})
1573 @cindex spacing
1574 @code{gtroff} double-spaces output text automatically if you use the
1575 request @w{@samp{.ls 2}}.  Reactivate single-spaced mode by typing
1576 @w{@samp{.ls 1}}.@footnote{If you need finer granularity of the
1577 vertical space, use the @code{pvs} request (@pxref{Changing Type
1578 Sizes}).}
1580 A number of requests allow to change the way the output looks,
1581 sometimes called the @dfn{layout} of the output page.  Most of these
1582 requests adjust the placing of @dfn{whitespace} (blank lines or
1583 spaces).
1585 @cindex new page (@code{bp})
1586 The @code{bp} request starts a new page, causing a line break.
1588 @cindex blank line (@code{sp})
1589 @cindex empty line (@code{sp})
1590 @cindex line, empty (@code{sp})
1591 The request @w{@samp{.sp @var{N}}} leaves @var{N}@tie{}lines of blank
1592 space.  @var{N}@tie{}can be omitted (meaning skip a single line) or can
1593 be of the form @var{N}i (for @var{N}@tie{}inches) or @var{N}c (for
1594 @var{N}@tie{}centimeters).  For example, the input:
1596 @Example
1597 .sp 1.5i
1598 My thoughts on the subject
1600 @endExample
1602 @noindent
1603 leaves one and a half inches of space, followed by the line ``My
1604 thoughts on the subject'', followed by a single blank line (more
1605 measurement units are available, see @ref{Measurements}).
1607 @cindex centering lines (@code{ce})
1608 @cindex lines, centering (@code{ce})
1609 Text lines can be centered by using the @code{ce} request.  The line
1610 after @code{ce} is centered (horizontally) on the page.  To center more
1611 than one line, use @w{@samp{.ce @var{N}}} (where @var{N} is the number
1612 of lines to center), followed by the @var{N}@tie{}lines.  To center many
1613 lines without counting them, type:
1615 @Example
1616 .ce 1000
1617 lines to center
1618 .ce 0
1619 @endExample
1621 @noindent
1622 The @w{@samp{.ce 0}} request tells @code{groff} to center zero more
1623 lines, in other words, stop centering.
1625 @cindex line break (@code{br})
1626 @cindex break (@code{br})
1627 All of these requests cause a break; that is, they always start a new
1628 line.  To start a new line without performing any other action, use
1629 @code{br}.
1632 @c =====================================================================
1634 @node Common Features,  , Basics, Tutorial for Macro Users
1635 @section Common Features
1636 @cindex common features
1637 @cindex features, common
1639 @code{gtroff} provides very low-level operations for formatting a
1640 document.  There are many common routine operations which are done in
1641 all documents.  These common operations are written into @dfn{macros}
1642 and collected into a @dfn{macro package}.
1644 All macro packages provide certain common capabilities which fall into
1645 the following categories.
1647 @menu
1648 * Paragraphs::
1649 * Sections and Chapters::
1650 * Headers and Footers::
1651 * Page Layout Adjustment::
1652 * Displays::
1653 * Footnotes and Annotations::
1654 * Table of Contents::
1655 * Indices::
1656 * Paper Formats::
1657 * Multiple Columns::
1658 * Font and Size Changes::
1659 * Predefined Strings::
1660 * Preprocessor Support::
1661 * Configuration and Customization::
1662 @end menu
1664 @c ---------------------------------------------------------------------
1666 @node Paragraphs, Sections and Chapters, Common Features, Common Features
1667 @subsection Paragraphs
1668 @cindex paragraphs
1670 One of the most common and most used capability is starting a
1671 paragraph.  There are a number of different types of paragraphs, any
1672 of which can be initiated with macros supplied by the macro package.
1673 Normally, paragraphs start with a blank line and the first line
1674 indented, like the text in this manual.  There are also block style
1675 paragraphs, which omit the indentation:
1677 @Example
1678 Some   men  look   at  constitutions   with  sanctimonious
1679 reverence, and deem them like the ark of the covenant, too
1680 sacred to be touched.
1681 @endExample
1683 @noindent
1684 And there are also indented paragraphs which begin with a tag or label
1685 at the margin and the remaining text indented.
1687 @Example
1688 one   This is  the first paragraph.  Notice  how the first
1689       line of  the resulting  paragraph lines up  with the
1690       other lines in the paragraph.
1691 @endExample
1692 @Example
1693 longlabel
1694       This  paragraph   had  a  long   label.   The  first
1695       character of text on the first line does not line up
1696       with  the  text  on  second  and  subsequent  lines,
1697       although they line up with each other.
1698 @endExample
1700 A variation of this is a bulleted list.
1702 @Example
1703 .     Bulleted lists start with a bullet.   It is possible
1704       to use other glyphs instead of the bullet.  In nroff
1705       mode using the ASCII character set for output, a dot
1706       is used instead of a real bullet.
1707 @endExample
1710 @c ---------------------------------------------------------------------
1712 @node Sections and Chapters, Headers and Footers, Paragraphs, Common Features
1713 @subsection Sections and Chapters
1715 Most macro packages supply some form of section headers.  The simplest
1716 kind is simply the heading on a line by itself in bold type.  Others
1717 supply automatically numbered section heading or different heading
1718 styles at different levels.  Some, more sophisticated, macro packages
1719 supply macros for starting chapters and appendices.
1721 @c ---------------------------------------------------------------------
1723 @node Headers and Footers, Page Layout Adjustment, Sections and Chapters, Common Features
1724 @subsection Headers and Footers
1726 Every macro package gives some way to manipulate the @dfn{headers} and
1727 @dfn{footers} (also called @dfn{titles}) on each page.  This is text
1728 put at the top and bottom of each page, respectively, which contain
1729 data like the current page number, the current chapter title, and so
1730 on.  Its appearance is not affected by the running text.  Some packages
1731 allow for different ones on the even and odd pages (for material printed
1732 in a book form).
1734 The titles are called @dfn{three-part titles}, that is, there is a
1735 left-justified part, a centered part, and a right-justified part.  An
1736 automatically generated page number may be put in any of these fields
1737 with the @samp{%} character (see @ref{Page Layout}, for more details).
1739 @c ---------------------------------------------------------------------
1741 @node Page Layout Adjustment, Displays, Headers and Footers, Common Features
1742 @subsection Page Layout
1744 Most macro packages let the user specify top and bottom margins and
1745 other details about the appearance of the printed pages.
1747 @c ---------------------------------------------------------------------
1749 @node Displays, Footnotes and Annotations, Page Layout Adjustment, Common Features
1750 @subsection Displays
1751 @cindex displays
1753 @dfn{Displays} are sections of text to be set off from the body of
1754 the paper.  Major quotes, tables, and figures are types of displays, as
1755 are all the examples used in this document.
1757 @cindex quotes, major
1758 @cindex major quotes
1759 @dfn{Major quotes} are quotes which are several lines long, and hence
1760 are set in from the rest of the text without quote marks around them.
1762 @cindex list
1763 A @dfn{list} is an indented, single-spaced, unfilled display.  Lists
1764 should be used when the material to be printed should not be filled and
1765 justified like normal text, such as columns of figures or the examples
1766 used in this paper.
1768 @cindex keep
1769 A @dfn{keep} is a display of lines which are kept on a single page if
1770 possible.  An example for a keep might be a diagram.  Keeps differ from
1771 lists in that lists may be broken over a page boundary whereas keeps are
1772 not.
1774 @cindex keep, floating
1775 @cindex floating keep
1776 @dfn{Floating keeps} move relative to the text.  Hence, they are good for
1777 things which are referred to by name, such as ``See figure@tie{}3''.  A
1778 floating keep appears at the bottom of the current page if it fits;
1779 otherwise, it appears at the top of the next page.  Meanwhile, the
1780 surrounding text `flows' around the keep, thus leaving no blank areas.
1782 @c ---------------------------------------------------------------------
1784 @node Footnotes and Annotations, Table of Contents, Displays, Common Features
1785 @subsection Footnotes and Annotations
1786 @cindex footnotes
1787 @cindex annotations
1789 There are a number of requests to save text for later printing.
1791 @dfn{Footnotes} are printed at the bottom of the current page.
1793 @cindex delayed text
1794 @dfn{Delayed text} is very similar to a footnote except that it is
1795 printed when called for explicitly.  This allows a list of references to
1796 appear (for example) at the end of each chapter, as is the convention in
1797 some disciplines.
1799 Most macro packages which supply this functionality also supply a means
1800 of automatically numbering either type of annotation.
1802 @c ---------------------------------------------------------------------
1804 @node Table of Contents, Indices, Footnotes and Annotations, Common Features
1805 @subsection Table of Contents
1806 @cindex table of contents
1807 @cindex contents, table of
1809 @dfn{Tables of contents} are a type of delayed text having a tag
1810 (usually the page number) attached to each entry after a row of dots.
1811 The table accumulates throughout the paper until printed, usually after
1812 the paper has ended.  Many macro packages provide the ability to have
1813 several tables of contents (e.g.@: a standard table of contents, a list
1814 of tables, etc).
1816 @c ---------------------------------------------------------------------
1818 @node Indices, Paper Formats, Table of Contents, Common Features
1819 @subsection Indices
1820 @cindex index, in macro package
1822 While some macro packages use the term @dfn{index}, none actually
1823 provide that functionality.  The facilities they call indices are
1824 actually more appropriate for tables of contents.
1826 @pindex makeindex
1827 To produce a real index in a document, external tools like the
1828 @code{makeindex} program are necessary.
1830 @c ---------------------------------------------------------------------
1832 @node Paper Formats, Multiple Columns, Indices, Common Features
1833 @subsection Paper Formats
1834 @cindex paper formats
1836 Some macro packages provide stock formats for various kinds of
1837 documents.  Many of them provide a common format for the title and
1838 opening pages of a technical paper.  The @file{mm} macros in particular
1839 provide formats for letters and memoranda.
1841 @c ---------------------------------------------------------------------
1843 @node Multiple Columns, Font and Size Changes, Paper Formats, Common Features
1844 @subsection Multiple Columns
1846 Some macro packages (but not @file{man}) provide the ability to have two
1847 or more columns on a page.
1849 @c ---------------------------------------------------------------------
1851 @node Font and Size Changes, Predefined Strings, Multiple Columns, Common Features
1852 @subsection Font and Size Changes
1854 The built-in font and size functions are not always intuitive, so all
1855 macro packages provide macros to make these operations simpler.
1857 @c ---------------------------------------------------------------------
1859 @node Predefined Strings, Preprocessor Support, Font and Size Changes, Common Features
1860 @subsection Predefined Strings
1862 Most macro packages provide various predefined strings for a variety of
1863 uses; examples are sub- and superscripts, printable dates, quotes and
1864 various special characters.
1866 @c ---------------------------------------------------------------------
1868 @node Preprocessor Support, Configuration and Customization, Predefined Strings, Common Features
1869 @subsection Preprocessor Support
1871 All macro packages provide support for various preprocessors and may
1872 extend their functionality.
1874 For example, all macro packages mark tables (which are processed with
1875 @code{gtbl}) by placing them between @code{TS} and @code{TE} macros.
1876 The @file{ms} macro package has an option, @samp{.TS@tie{}H}, that prints
1877 a caption at the top of a new page (when the table is too long to fit on
1878 a single page).
1880 @c ---------------------------------------------------------------------
1882 @node Configuration and Customization,  , Preprocessor Support, Common Features
1883 @subsection Configuration and Customization
1885 Some macro packages provide means of customizing many of the details of
1886 how the package behaves.  This ranges from setting the default type size
1887 to changing the appearance of section headers.
1891 @c =====================================================================
1892 @c =====================================================================
1894 @node Macro Packages, gtroff Reference, Tutorial for Macro Users, Top
1895 @chapter Macro Packages
1896 @cindex macro packages
1897 @cindex packages, macros
1899 This chapter documents the main macro packages that come with
1900 @code{groff}.
1902 Different main macro packages can't be used at the same time; for example
1904 @Example
1905 groff -m man foo.man -m ms bar.doc
1906 @endExample
1908 @noindent
1909 doesn't work.  Note that option arguments are processed before non-option
1910 arguments; the above (failing) sample is thus reordered to
1912 @Example
1913 groff -m man -m ms foo.man bar.doc
1914 @endExample
1916 @menu
1917 * man::
1918 * mdoc::
1919 * ms::
1920 * me::
1921 * mm::
1922 @end menu
1925 @c =====================================================================
1927 @node man, mdoc, Macro Packages, Macro Packages
1928 @section @file{man}
1929 @cindex manual pages
1930 @cindex man pages
1931 @pindex an.tmac
1932 @pindex man.tmac
1933 @pindex man-old.tmac
1935 This is the most popular and probably the most important macro package
1936 of @code{groff}.  It is easy to use, and a vast majority of manual pages
1937 are based on it.
1939 @menu
1940 * Man options::
1941 * Man usage::
1942 * Man font macros::
1943 * Miscellaneous man macros::
1944 * Predefined man strings::
1945 * Preprocessors in man pages::
1946 @end menu
1948 @c ---------------------------------------------------------------------
1950 @node Man options, Man usage, man, man
1951 @subsection Options
1953 The command line format for using the @file{man} macros with
1954 @code{groff} is:
1956 @Example
1957 groff -m man [ -rLL=@var{length} ] [ -rLT=@var{length} ]
1958       [ -rcR=1 ] [ -rC1 ] [ -rD1 ] [ -rP@var{nnn} ]
1959       [ -rS@var{xx} ] [ -rX@var{nnn} ] [ @var{files}@dots{} ]
1960 @endExample
1962 @noindent
1963 It is possible to use @samp{-man} instead of @w{@samp{-m man}}.
1965 @table @code
1966 @item -rLL=@var{length}
1967 Set line length to @var{length}.  If not specified, the line length
1968 defaults to 78@tie{}en in nroff mode (this is 78@tie{}characters per
1969 line) and 6.5@tie{}inch otherwise.
1971 @item -rLT=@var{length}
1972 Set title length to @var{length}.  If not specified, the title length
1973 defaults to 78@tie{}en in nroff mode (this is 78@tie{}characters per
1974 line) and 6.5@tie{}inch otherwise.
1976 @item -rcR=1
1977 This option (the default if a TTY output device is used) creates a
1978 single, very long page instead of multiple pages.  Use @code{-rcR=0}
1979 to disable it.
1981 @item -rC1
1982 If more than one manual page is given on the command line, number the
1983 pages continuously, rather than starting each at@tie{}1.
1985 @item -rD1
1986 Double-sided printing.  Footers for even and odd pages are formatted
1987 differently.
1989 @item -rP@var{nnn}
1990 Page numbering starts with @var{nnn} rather than with@tie{}1.
1992 @item -rS@var{xx}
1993 Use @var{xx} (which can be 10, 11, or@tie{}12@dmn{pt}) as the base
1994 document font size instead of the default value of@tie{}10@dmn{pt}.
1996 @item -rX@var{nnn}
1997 After page @var{nnn}, number pages as @var{nnn}a, @var{nnn}b,
1998 @var{nnn}c, etc.  For example, the option @option{-rX2} produces the
1999 following page numbers: 1, 2, 2a, 2b, 2c, etc.
2000 @end table
2002 @c ---------------------------------------------------------------------
2004 @node Man usage, Man font macros, Man options, man
2005 @subsection Usage
2006 @cindex @code{man} macros
2007 @cindex macros for manual pages [@code{man}]
2009 @pindex man.local
2010 This section describes the available macros for manual pages.  For
2011 further customization, put additional macros and requests into the file
2012 @file{man.local} which is loaded immediately after the @file{man}
2013 package.
2015 @Defmac {TH, title section [@Var{extra1} [@Var{extra2} [@Var{extra3}]]], man}
2016 Set the title of the man page to @var{title} and the section to
2017 @var{section}, which must have a value between 1 and@tie{}8.  The value
2018 of @var{section} may also have a string appended, e.g.@: @samp{.pm},
2019 to indicate a specific subsection of the man pages.
2021 Both @var{title} and @var{section} are positioned at the left and right
2022 in the header line (with @var{section} in parentheses immediately
2023 appended to @var{title}.  @var{extra1} is positioned in the middle of
2024 the footer line.  @var{extra2} is positioned at the left in the footer
2025 line (or at the left on even pages and at the right on odd pages if
2026 double-sided printing is active).  @var{extra3} is centered in the
2027 header line.
2029 For @acronym{HTML} output, headers and footers are completely suppressed.
2031 Additionally, this macro starts a new page; the new line number is@tie{}1
2032 again (except if the @option{-rC1} option is given on the command line)
2033 -- this feature is intended only for formatting multiple man pages; a
2034 single man page should contain exactly one @code{TH} macro at the
2035 beginning of the file.
2036 @endDefmac
2038 @Defmac {SH, [@Var{heading}], man}
2039 Set up an unnumbered section heading sticking out to the left.  Prints
2040 out all the text following @code{SH} up to the end of the line (or the
2041 text in the next line if there is no argument to @code{SH}) in bold
2042 face, one size larger than the base document size.  Additionally, the
2043 left margin for the following text is reset to its default value.
2044 @endDefmac
2046 @Defmac {SS, [@Var{heading}], man}
2047 Set up an unnumbered (sub)section heading.  Prints out all the text
2048 following @code{SS} up to the end of the line (or the text in the next
2049 line if there is no argument to @code{SS}) in bold face, at the same
2050 size as the base document size.  Additionally, the left margin for the
2051 following text is reset to its default value.
2052 @endDefmac
2054 @Defmac {TP, [@Var{nnn}], man}
2055 Set up an indented paragraph with label.  The indentation is set to
2056 @var{nnn} if that argument is supplied (the default unit is @samp{n}
2057 if omitted), otherwise it is set to the default indentation value.
2059 The first line of text following this macro is interpreted as a string
2060 to be printed flush-left, as it is appropriate for a label.  It is not
2061 interpreted as part of a paragraph, so there is no attempt to fill the
2062 first line with text from the following input lines.  Nevertheless, if
2063 the label is not as wide as the indentation, then the paragraph starts
2064 at the same line (but indented), continuing on the following lines.
2065 If the label is wider than the indentation, then the descriptive part
2066 of the paragraph begins on the line following the label, entirely
2067 indented.  Note that neither font shape nor font size of the label is
2068 set to a default value; on the other hand, the rest of the text has
2069 default font settings.
2070 @endDefmac
2072 @DefmacList {LP, , man}
2073 @DefmacItem {PP, , man}
2074 @DefmacListEnd {P, , man}
2075 These macros are mutual aliases.  Any of them causes a line break at
2076 the current position, followed by a vertical space downwards by the
2077 amount specified by the @code{PD} macro.  The font size and shape are
2078 reset to the default value (10@dmn{pt} roman if no @option{-rS} option
2079 is given on the command line).  Finally, the current left margin is
2080 restored.
2081 @endDefmac
2083 @Defmac {IP, [@Var{designator} [@Var{nnn}]], man}
2084 Set up an indented paragraph, using @var{designator} as a tag to mark
2085 its beginning.  The indentation is set to @var{nnn} if that argument
2086 is supplied (default unit is @samp{n}), otherwise the default
2087 indentation value is used.  Font size and face of the paragraph (but
2088 not the designator) are reset to their default values.  To start an
2089 indented paragraph with a particular indentation but without a
2090 designator, use @samp{""} (two double quotes) as the first argument of
2091 @code{IP}.
2093 For example, to start a paragraph with bullets as the designator and
2094 4@tie{}en indentation, write
2096 @Example
2097 .IP \(bu 4
2098 @endExample
2099 @endDefmac
2101 @Defmac {HP, [@Var{nnn}], man}
2102 @cindex hanging indentation [@code{man}]
2103 @cindex @code{man} macros, hanging indentation
2104 Set up a paragraph with hanging left indentation.  The indentation is
2105 set to @var{nnn} if that argument is supplied (default unit is
2106 @samp{n}), otherwise the default indentation value is used.  Font size
2107 and face are reset to their default values.
2108 @endDefmac
2110 @Defmac {RS, [@Var{nnn}], man}
2111 @cindex left margin, how to move [@code{man}]
2112 @cindex @code{man} macros, moving left margin
2113 Move the left margin to the right by the value @var{nnn} if specified
2114 (default unit is @samp{n}); otherwise the default indentation value
2115 is used.  Calls to the @code{RS} macro can be nested.
2116 @endDefmac
2118 @Defmac {RE, [@Var{nnn}], man}
2119 Move the left margin back to level @var{nnn}; if no argument is given,
2120 it moves one level back.  The first level (i.e., no call to @code{RS}
2121 yet) has number@tie{}1, and each call to @code{RS} increases the level
2122 by@tie{}1.
2123 @endDefmac
2125 @cindex line breaks, with vertical space [@code{man}]
2126 @cindex @code{man} macros, line breaks with vertical space
2127 To summarize, the following macros cause a line break with the insertion
2128 of vertical space (which amount can be changed with the @code{PD}
2129 macro): @code{SH}, @code{SS}, @code{TP}, @code{LP} (@code{PP},
2130 @code{P}), @code{IP}, and @code{HP}.
2132 @cindex line breaks, without vertical space [@code{man}]
2133 @cindex @code{man} macros, line breaks without vertical space
2134 The macros @code{RS} and @code{RE} also cause a break but do not insert
2135 vertical space.
2137 @cindex default indentation, resetting [@code{man}]
2138 @cindex indentaion, resetting to default [@code{man}]
2139 @cindex @code{man} macros, resetting default indentation
2140 Finally, the macros @code{SH}, @code{SS}, @code{LP} (@code{PP}, @code{P}),
2141 and @code{RS} reset the indentation to its default value.
2143 @c ---------------------------------------------------------------------
2145 @node Man font macros, Miscellaneous man macros, Man usage, man
2146 @subsection Macros to set fonts
2147 @cindex font selection [@code{man}]
2148 @cindex @code{man} macros, how to set fonts
2150 The standard font is roman; the default text size is 10@tie{}point.
2151 If command line option @option{-rS=@var{n}} is given, use
2152 @var{n}@dmn{pt} as the default text size.
2154 @Defmac {SM, [@Var{text}], man}
2155 Set the text on the same line or the text on the next line in a font
2156 that is one point size smaller than the default font.
2157 @endDefmac
2159 @Defmac {SB, [@Var{text}], man}
2160 @cindex bold face [@code{man}]
2161 @cindex @code{man} macros, bold face
2162 Set the text on the same line or the text on the next line in bold face
2163 font, one point size smaller than the default font.
2164 @endDefmac
2166 @Defmac {BI, text, man}
2167 Set its arguments alternately in bold face and italic.  Thus,
2169 @Example
2170 .BI this "word and" that
2171 @endExample
2173 @noindent
2174 would set ``this'' and ``that'' in bold face, and ``word and'' in
2175 italics.
2176 @endDefmac
2178 @Defmac {IB, text, man}
2179 Set its arguments alternately in italic and bold face.
2180 @endDefmac
2182 @Defmac {RI, text, man}
2183 Set its arguments alternately in roman and italic.
2184 @endDefmac
2186 @Defmac {IR, text, man}
2187 Set its arguments alternately in italic and roman.
2188 @endDefmac
2190 @Defmac {BR, text, man}
2191 Set its arguments alternately in bold face and roman.
2192 @endDefmac
2194 @Defmac {RB, text, man}
2195 Set its arguments alternately in roman and bold face.
2196 @endDefmac
2198 @Defmac {B, [@Var{text}], man}
2199 Set @var{text} in bold face.  If no text is present on the line where
2200 the macro is called, then the text of the next line appears in bold
2201 face.
2202 @endDefmac
2204 @Defmac {I, [@Var{text}], man}
2205 @cindex italic fonts [@code{man}]
2206 @cindex @code{man} macros, italic fonts
2207 Set @var{text} in italic.  If no text is present on the line where the
2208 macro is called, then the text of the next line appears in italic.
2209 @endDefmac
2211 @c ---------------------------------------------------------------------
2213 @node Miscellaneous man macros, Predefined man strings, Man font macros, man
2214 @subsection Miscellaneous macros
2216 @pindex grohtml
2217 @cindex @code{man} macros, default indentation
2218 @cindex default indentation [@code{man}]
2219 The default indentation is 7.2@tie{}en for all output devices except for
2220 @code{grohtml} which ignores indentation.
2222 @Defmac {DT, , man}
2223 @cindex tab stops [@code{man}]
2224 @cindex @code{man} macros, tab stops
2225 Set tabs every 0.5@tie{}inches.  Since this macro is always executed
2226 during a call to the @code{TH} macro, it makes sense to call it only if
2227 the tab positions have been changed.
2228 @endDefmac
2230 @Defmac {PD, [@Var{nnn}], man}
2231 @cindex empty space before a paragraph [@code{man}]
2232 @cindex @code{man} macros, empty space before a paragraph
2233 Adjust the empty space before a new paragraph (or section).  The
2234 optional argument gives the amount of space (default unit is
2235 @samp{v}); without parameter, the value is reset to its default value
2236 (1@tie{}line for TTY devices, 0.4@dmn{v}@tie{}otherwise).
2237 @endDefmac
2239 This affects the macros @code{SH}, @code{SS}, @code{TP}, @code{LP} (as
2240 well as @code{PP} and @code{P}), @code{IP}, and @code{HP}.
2242 @c ---------------------------------------------------------------------
2244 @node Predefined man strings, Preprocessors in man pages, Miscellaneous man macros, man
2245 @subsection Predefined strings
2247 The following strings are defined:
2249 @Defstr {S, man}
2250 Switch back to the default font size.
2251 @endDefstr
2253 @Defstr {R, man}
2254 The `registered' sign.
2255 @endDefstr
2257 @Defstr {Tm, man}
2258 The `trademark' sign.
2259 @endDefstr
2261 @DefstrList {lq, man}
2262 @DefstrListEnd {rq, man}
2263 @cindex @code{lq} glyph, and @code{lq} string [@code{man}]
2264 @cindex @code{rq} glyph, and @code{rq} string [@code{man}]
2265 Left and right quote.  This is equal to @code{\(lq} and @code{\(rq},
2266 respectively.
2267 @endDefstr
2269 @c ---------------------------------------------------------------------
2271 @node Preprocessors in man pages,  , Predefined man strings, man
2272 @subsection Preprocessors in @file{man} pages
2274 @cindex preprocessor, calling convention
2275 @cindex calling convention of preprocessors
2276 If a preprocessor like @code{gtbl} or @code{geqn} is needed, it has
2277 become common usage to make the first line of the man page look like
2278 this:
2280 @Example
2281 '\" @var{word}
2282 @endExample
2284 @pindex geqn@r{, invocation in manual pages}
2285 @pindex grefer@r{, invocation in manual pages}
2286 @pindex gtbl@r{, invocation in manual pages}
2287 @pindex man@r{, invocation of preprocessors}
2288 @noindent
2289 Note the single space character after the double quote.  @var{word}
2290 consists of letters for the needed preprocessors: @samp{e} for
2291 @code{geqn}, @samp{r} for @code{grefer}, @samp{t} for @code{gtbl}.
2292 Modern implementations of the @code{man} program read this first line
2293 and automatically call the right preprocessor(s).
2296 @c =====================================================================
2298 @node mdoc, ms, man, Macro Packages
2299 @section @file{mdoc}
2300 @cindex @code{mdoc} macros
2302 @c XXX documentation
2303 @c XXX this is a placeholder until we get stuff knocked into shape
2304 See the @cite{groff_mdoc(7)} man page (type @command{man groff_mdoc}
2305 at the command line).
2308 @c =====================================================================
2310 @node ms, me, mdoc, Macro Packages
2311 @section @file{ms}
2312 @cindex @code{ms} macros
2314 The @file{-ms}
2315 macros are suitable for reports, letters, books,
2316 user manuals, and so forth.
2317 The package provides macros for cover pages, section headings,
2318 paragraphs, lists, footnotes, pagination,
2319 and a table of contents.
2321 @menu
2322 * ms Intro::
2323 * General ms Structure::
2324 * ms Document Control Registers::
2325 * ms Cover Page Macros::
2326 * ms Body Text::
2327 * ms Page Layout::
2328 * Differences from AT&T ms::
2329 @end menu
2331 @c ---------------------------------------------------------------------
2333 @node ms Intro, General ms Structure, ms, ms
2334 @subsection Introduction to @file{ms}
2336 The original @file{-ms} macros were included with
2337 @acronym{AT&T} @code{troff} as well as the
2338 @file{man} macros.
2339 While the @file{man} package is intended for brief documents
2340 that can be read on-line as well as printed, the @file{ms}
2341 macros are suitable for longer documents that are meant to be
2342 printed rather than read on-line.
2344 The @file{ms} macro package included with @code{groff}
2345 is a complete, bottom-up re-implementation.
2346 Several macros (specific to @acronym{AT&T}
2347 or Berkeley) are not included, while several new commands are.
2348 @xref{Differences from AT&T ms}, for more information.
2350 @c ---------------------------------------------------------------------
2352 @node General ms Structure, ms Document Control Registers, ms Intro, ms
2353 @subsection General structure of an @file{ms} document
2354 @cindex @code{ms} macros, general structure
2356 The @file{ms} macro package expects a certain amount of structure,
2357 but not as much as packages such as @file{man} or @file{mdoc}.
2359 The simplest documents can begin with a paragraph macro
2360 (such as @code{LP} or @code{PP}),
2361 and consist of text separated by paragraph macros
2362 or even blank lines.
2363 Longer documents have a structure as follows:
2365 @table @strong
2366 @item Document type
2367 If you invoke the @code{RP}
2368 (report) macro on the first line of the document,
2369 @code{groff} prints the cover page information on its own page;
2370 otherwise it prints the information on the
2371 first page with your document text immediately following.
2372 Other document formats found in @acronym{AT&T} @code{troff}
2373 are specific to @acronym{AT&T} or Berkeley, and are not supported in
2374 @code{groff}.
2376 @item Format and layout
2377 By setting number registers,
2378 you can change your document's type (font and size),
2379 margins, spacing, headers and footers, and footnotes.
2380 @xref{ms Document Control Registers}, for more details.
2382 @item Cover page
2383 A cover page consists of a title, the author's name and institution,
2384 an abstract, and the date.
2385 @footnote{Actually, only the title is required.}
2386 @xref{ms Cover Page Macros}, for more details.
2388 @item Body
2389 Following the cover page is your document.
2390 You can use the @file{ms}
2391 macros to write reports, letters, books, and so forth.
2392 The package is designed for structured documents,
2393 consisting of paragraphs interspersed with headings
2394 and augmented by lists, footnotes, tables, and other
2395 common constructs.
2396 @xref{ms Body Text}, for more details.
2398 @item Table of contents
2399 Longer documents usually include a table of contents,
2400 which you can invoke by placing the
2401 @code{TC}
2402 macro at the end of your document.
2403 The @file{ms}
2404 macros have minimal indexing facilities, consisting of the
2405 @code{IX} macro, which prints an entry on standard error.
2406 Printing the table of contents at the end is necessary since
2407 @code{groff} is a single-pass text formatter,
2408 thus it cannot determine the page number of each section
2409 until that section has actually been set and printed.
2410 Since @file{ms} output is intended for hardcopy,
2411 you can manually relocate the pages containing
2412 the table of contents between the cover page and the
2413 body text after printing.
2414 @end table
2416 @c ---------------------------------------------------------------------
2418 @node ms Document Control Registers, ms Cover Page Macros, General ms Structure, ms
2419 @subsection Document control registers
2420 @cindex @code{ms} macros, document control registers
2422 The following is a list of document control number registers.
2423 For the sake of consistency,
2424 set registers related to margins at the beginning of your document,
2425 or just after the @code{RP} macro.
2426 You can set other registers later in your document,
2427 but you should keep them together at the beginning
2428 to make them easy to find and edit as necessary.
2430 @unnumberedsubsubsec Margin Settings
2432 @Defmpreg {PO, ms}
2433 Defines the page offset (i.e.@: the left margin).
2434 There is no explicit right margin setting; the combination of
2435 the @code{PO} and @code{LL} registers implicitly define the
2436 right margin width.
2438 Effective: next page.
2440 Default value: 1@dmn{i}.
2441 @endDefmpreg
2443 @Defmpreg {LL, ms}
2444 Defines the line length (i.e.@: the width of the body text).
2446 Effective: next paragraph.
2448 Default: 6@dmn{i}.
2449 @endDefmpreg
2451 @Defmpreg {LT, ms}
2452 Defines the title length (i.e.@: the header and footer width).
2453 This is usually the same as @code{LL}, but not necessarily.
2455 Effective: next paragraph.
2457 Default: 6@dmn{i}.
2458 @endDefmpreg
2460 @Defmpreg {HM, ms}
2461 Defines the header margin height at the top of the page.
2463 Effective: next page.
2465 Default: 1@dmn{i}.
2466 @endDefmpreg
2468 @Defmpreg {FM, ms}
2469 Defines the footer margin height at the bottom of the page.
2471 Effective: next page.
2473 Default: 1@dmn{i}.
2474 @endDefmpreg
2476 @unnumberedsubsubsec Text Settings
2478 @Defmpreg {PS, ms}
2479 Defines the point size of the body text.
2481 Effective: next paragraph.
2483 Default: 10@dmn{p}.
2484 @endDefmpreg
2486 @Defmpreg {VS, ms}
2487 Defines the space between lines (line height plus leading).
2489 Effective: next paragraph.
2491 Default: 12@dmn{p}.
2492 @endDefmpreg
2494 @unnumberedsubsubsec Paragraph Settings
2496 @Defmpreg {PI, ms}
2497 Defines the initial indent of a @code{.PP} paragraph.
2499 Effective: next paragraph.
2501 Default: 5@dmn{n}.
2502 @endDefmpreg
2504 @Defmpreg {PD, ms}
2505 Defines the space between paragraphs.
2507 Effective: next paragraph.
2509 Default: 0.3@dmn{v}.
2510 @endDefmpreg
2512 @Defmpreg {QI, ms}
2513 Defines the indent on both sides of a quoted (@code{.QP}) paragraph.
2515 Effective: next paragraph.
2517 Default: 5@dmn{n}.
2518 @endDefmpreg
2520 @unnumberedsubsubsec Footnote Settings
2522 @Defmpreg {FL, ms}
2523 Defines the length of a footnote.
2525 Effective: next footnote.
2527 Default: @math{@code{@\n[LL]} * 5 / 6}.
2528 @endDefmpreg
2530 @Defmpreg {FI, ms}
2531 Defines the footnote indent.
2533 Effective: next footnote.
2535 Default: 2@dmn{n}.
2536 @endDefmpreg
2538 @Defmpreg {FF, ms}
2539 The footnote format:
2540 @table @code
2541 @item 0
2542 Prints the footnote number as a superscript; indents the footnote (default).
2544 @item 1
2545 Prints the number followed by a period (like 1.)
2546 and indents the footnote.
2548 @item 2
2549 Like 1, without an indent.
2551 @item 3
2552 Like 1, but prints the footnote number as a hanging paragraph.
2553 @end table
2555 Effective: next footnote.
2557 Default: 0.
2558 @endDefmpreg
2560 @unnumberedsubsubsec Miscellaneous Number Registers
2562 @Defmpreg {MINGW, ms}
2563 Defines the minimum width between columns in a multi-column document.
2565 Effective: next page.
2567 Default: 2@dmn{n}.
2568 @endDefmpreg
2570 @c ---------------------------------------------------------------------
2572 @node ms Cover Page Macros, ms Body Text, ms Document Control Registers, ms
2573 @subsection Cover page macros
2574 @cindex @code{ms} macros, cover page
2575 @cindex cover page macros, [@code{ms}]
2577 Use the following macros to create a cover page for your document
2578 in the order shown.
2580 @Defmac {RP, [@code{no}], ms}
2581 Specifies the report format for your document.
2582 The report format creates a separate cover page.
2583 The default action (no @code{.RP}
2584 macro) is to print a subset of the
2585 cover page on page 1 of your document.
2587 If you use the word @code{no} as an optional argument,
2588 @code{groff} prints a title page but
2589 does not repeat any of the title page information
2590 (title, author, abstract, etc.)
2591 on page 1 of the document.
2592 @endDefmac
2594 @Defmac {DA, [@dots{}], ms}
2595 (optional) Print the current date, or the arguments to the macro if any,
2596 on the title page (if specified) and in the footers.
2597 This is the default for @code{nroff}.
2598 @endDefmac
2600 @Defmac {ND, [@dots{}], ms}
2601 (optional) Print the current date, or the arguments to the macro if any,
2602 on the title page (if specified) but not in the footers.
2603 This is the default for @code{troff}.
2604 @endDefmac
2606 @Defmac {TL, , ms}
2607 Specifies the document title.
2608 @code{groff} collects text following the @code{.TL}
2609 macro into the title, until reaching the author name or abstract.
2610 @endDefmac
2612 @Defmac {AU, , ms}
2613 Specifies the author's name, which appears on the
2614 line (or lines) immediately following.
2615 You can specify multiple authors as follows:
2617 @Example
2619 John Doe
2621 University of West Bumblefuzz
2623 Martha Buck
2625 Monolithic Corporation
2628 @endExample
2629 @endDefmac
2631 @Defmac {AI, , ms}
2632 Specifies the author's institution.
2633 You can specify multiple institutions in the same way
2634 that you specify multiple authors.
2635 @endDefmac
2637 @Defmac {AB, [@code{no}], ms}
2638 Begins the abstract.
2639 The default is to print the word @acronym{ABSTRACT},
2640 centered and in italics, above the text of the abstract.
2641 The word @code{no} as an optional argument suppresses this heading.
2642 @endDefmac
2644 @Defmac {AE, , ms}
2645 End the abstract.
2646 @endDefmac
2648 The following is example mark-up for a title page.
2649 @cindex title page, example markup
2650 @cindex example markup, title page
2652 @Example
2653 @cartouche
2656 The Inevitability of Code Bloat
2657 in Commercial and Free Software
2659 J. Random Luser
2661 University of West Bumblefuzz
2663 This report examines the long-term growth
2664 of the code bases in two large, popular software
2665 packages; the free Emacs and the commercial
2666 Microsoft Word.
2667 While differences appear in the type or order
2668 of features added, due to the different
2669 methodologies used, the results are the same
2670 in the end.
2672 The free software approach is shown to be
2673 superior in that while free software can
2674 become as bloated as commercial offerings,
2675 free software tends to have fewer serious
2676 bugs and the added features are in line with
2677 user demand.
2680 ... the rest of the paper follows ...
2681 @end cartouche
2682 @endExample
2684 @c ---------------------------------------------------------------------
2686 @node ms Body Text, ms Page Layout, ms Cover Page Macros, ms
2687 @subsection Body text
2688 @cindex @code{ms} macros, body text
2690 This section describes macros used to mark up the body of your document.
2691 Examples include paragraphs, sections, and other groups.
2693 @menu
2694 * Paragraphs in ms::
2695 * Headings in ms::
2696 * Highlighting in ms::
2697 * Lists in ms::
2698 * Indents in ms::
2699 * Tabstops in ms::
2700 * ms Displays and Keeps::
2701 * ms Insertions::
2702 * Example multi-page table::
2703 * ms Footnotes::
2704 @end menu
2706 @c ---------------------------------------------------------------------
2708 @node Paragraphs in ms, Headings in ms, ms Body Text, ms Body Text
2709 @subsubsection Paragraphs
2710 @cindex @code{ms} macros, paragraph handling
2712 The following paragraph types are available.
2714 @Defmac {PP, , ms}
2715 Sets a paragraph with an initial indent.
2716 @endDefmac
2718 @Defmac {LP, , ms}
2719 Sets a paragraph with no initial indent.
2720 @endDefmac
2722 @Defmac {QP, , ms}
2723 Sets a paragraph that is indented at both left and right margins.
2724 The effect is identical to the @acronym{HTML} @code{<BLOCKQUOTE>} element.
2725 The next paragraph or heading returns margins to normal.
2726 @endDefmac
2728 @Defmac {XP, , ms}
2729 Sets a paragraph whose lines are indented,
2730 except for the first line.
2731 This is a Berkeley extension.
2732 @endDefmac
2734 The following markup uses all four paragraph macros.
2736 @Example
2737 @cartouche
2738 .NH 2
2739 Cases used in the study
2741 The following software and versions were
2742 considered for this report.
2744 For commercial software, we chose
2745 .B "Microsoft Word for Windows" ,
2746 starting with version 1.0 through the
2747 current version (Word 2000).
2749 For free software, we chose
2750 .B Emacs ,
2751 from its first appearance as a standalone
2752 editor through the current version (v20).
2753 See [Bloggs 2002] for details.
2755 Franklin's Law applied to software:
2756 software expands to outgrow both
2757 RAM and disk space over time.
2759 Bibliography:
2761 Bloggs, Joseph R.,
2762 .I "Everyone's a Critic" ,
2763 Underground Press, March 2002.
2764 A definitive work that answers all questions
2765 and criticisms about the quality and usability of
2766 free software.
2768 @end cartouche
2769 @endExample
2771 @c ---------------------------------------------------------------------
2773 @node Headings in ms, Highlighting in ms, Paragraphs in ms, ms Body Text
2774 @subsubsection Headings
2775 @cindex @code{ms} macros, headings
2777 Use headings to create a hierarchical structure for your document.
2778 The @file{ms} macros print headings in @strong{bold},
2779 using the same font family and point size as the body text.
2781 The following describes the heading macros:
2783 @DefmacList {NH, @Var{curr-level}, ms}
2784 @DefmacListEnd {NH, @t{S} @Var{level0} @dots{}, ms}
2785 Numbered heading.
2786 The argument is either a numeric argument to indicate the
2787 level of the heading, or the letter@tie{}@code{S} followed by numeric
2788 arguments to set the heading level explicitly.
2790 If you specify heading levels out of sequence, such as invoking
2791 @samp{.NH 3} after @samp{.NH 1}, @code{groff}
2792 prints a warning on standard error.
2793 @endDefmac
2795 @Defmac {SH, , ms}
2796 Unnumbered subheading.
2797 @endDefmac
2799 @c ---------------------------------------------------------------------
2801 @node Highlighting in ms, Lists in ms, Headings in ms, ms Body Text
2802 @subsubsection Highlighting
2803 @cindex @code{ms} macros, highlighting
2805 The @file{ms} macros provide a variety of methods to highlight
2806 or emphasize text:
2808 @Defmac {B, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
2809 Sets its first argument in @strong{bold type}.
2810 If you specify a second argument, @code{groff} prints it in the
2811 previous font after the bold text, with no intervening space
2812 (this allows you to set punctuation after the highlighted text
2813 without highlighting the punctuation).
2814 Similarly, it prints the third argument (if any) in the previous
2815 font @strong{before} the first argument.
2816 For example,
2818 @Example
2819 .B foo ) (
2820 @endExample
2822 prints (@strong{foo}).
2824 If you give this macro no arguments, @code{groff}
2825 prints all text following in bold until
2826 the next highlighting, paragraph, or heading macro.
2827 @endDefmac
2829 @Defmac {R, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
2830 Sets its first argument in roman (or regular) type.
2831 It operates similarly to the @code{B}@tie{}macro otherwise.
2832 @endDefmac
2834 @Defmac {I, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
2835 Sets its first argument in @emph{italic type}.
2836 It operates similarly to the @code{B}@tie{}macro otherwise.
2837 @endDefmac
2839 @Defmac {CW, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
2840 Sets its first argument in a @code{constant width face}.
2841 It operates similarly to the @code{B}@tie{}macro otherwise.
2842 @endDefmac
2844 @Defmac {BI, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
2845 Sets its first argument in bold italic type.
2846 It operates similarly to the @code{B}@tie{}macro otherwise.
2847 @endDefmac
2849 @Defmac {BX, [@Var{txt}], ms}
2850 Prints its argument and draws a box around it.
2851 If you want to box a string that contains spaces,
2852 use a digit-width space (@code{\0}).
2853 @endDefmac
2855 @Defmac {UL, [@Var{txt} [@Var{post}]], ms}
2856 Prints its first argument with an underline.
2857 If you specify a second argument, @code{groff}
2858 prints it in the previous font after
2859 the underlined text, with no intervening space.
2860 @endDefmac
2862 @Defmac {LG, , ms}
2863 Prints all text following in larger type
2864 (two points larger than the current point size) until
2865 the next font size, highlighting, paragraph, or heading macro.
2866 You can specify this macro multiple times
2867 to enlarge the point size as needed.
2868 @endDefmac
2870 @Defmac {SM, , ms}
2871 Prints all text following in smaller type
2872 (two points smaller than the current point size) until
2873 the next type size, highlighting, paragraph, or heading macro.
2874 You can specify this macro multiple times
2875 to reduce the point size as needed.
2876 @endDefmac
2878 @Defmac {NL, , ms}
2879 Prints all text following in the normal point size
2880 (that is, the value of the @code{PS} register).
2881 @endDefmac
2883 @c ---------------------------------------------------------------------
2885 @node Lists in ms, Indents in ms, Highlighting in ms, ms Body Text
2886 @subsubsection Lists
2887 @cindex @code{ms} macros, lists
2889 The @code{.IP} macro handles duties for all lists.
2891 @Defmac {IP, [@Var{marker} [@Var{width}]], ms}
2892 The @var{marker} is usually a bullet glyph (@code{\[bu]})
2893 for unordered lists, a number (or auto-incrementing number
2894 register) for numbered lists, or a word or phrase for indented
2895 (glossary-style) lists.
2897 The @var{width} specifies the indent for the body of each list item;
2898 its default unit is @samp{n}.
2899 Once specified, the indent remains the same for all
2900 list items in the document until specified again.
2901 @endDefmac
2903 The following is an example of a bulleted list.
2904 @cindex example markup, bulleted list [@code{ms}]
2905 @cindex bulleted list, example markup [@code{ms}]
2907 @Example
2908 A bulleted list:
2909 .IP \[bu] 2
2910 lawyers
2911 .IP \[bu]
2912 guns
2913 .IP \[bu]
2914 money
2915 @endExample
2917 Produces:
2919 @Example
2920 A bulleted list:
2922 o lawyers
2924 o guns
2926 o money
2927 @endExample
2929 @sp 1
2931 The following is an example of a numbered list.
2932 @cindex example markup, numbered list [@code{ms}]
2933 @cindex numbered list, example markup [@code{ms}]
2935 @Example
2936 .nr step 1 1
2937 A numbered list:
2938 .IP \n[step] 3
2939 lawyers
2940 .IP \n+[step]
2941 guns
2942 .IP \n+[step]
2943 money
2944 @endExample
2946 Produces:
2948 @Example
2949 A numbered list:
2951 1. lawyers
2953 2. guns
2955 3. money
2956 @endExample
2958 Note the use of the auto-incrementing number
2959 register in this example.
2961 @sp 1
2962 The following is an example of a glossary-style list.
2963 @cindex example markup, glossary-style list [@code{ms}]
2964 @cindex glossary-style list, example markup [@code{ms}]
2966 @Example
2967 A glossary-style list:
2968 .IP lawyers 0.4i
2969 Two or more attorneys.
2970 .IP guns
2971 Firearms, preferably
2972 large-caliber.
2973 .IP money
2974 Gotta pay for those
2975 lawyers and guns!
2976 @endExample
2978 Produces:
2980 @Example
2981 A glossary-style list:
2983 lawyers
2984       Two or more attorneys.
2986 guns  Firearms, preferably large-caliber.
2988 money
2989       Gotta pay for those lawyers and guns!
2990 @endExample
2992 In the last example, the @code{IP} macro places the definition
2993 on the same line as the term if it has enough space; otherwise,
2994 it breaks to the next line and starts the definition below the
2995 term.
2996 This may or may not be the effect you want, especially if some
2997 of the definitions break and some do not.
2998 The following examples show two possible ways to force a break.
3000 The first workaround uses the @code{br}
3001 request to force a break after printing the term or label.
3003 @Example
3004 @cartouche
3005 A glossary-style list:
3006 .IP lawyers 0.4i
3007 Two or more attorneys.
3008 .IP guns
3010 Firearms, preferably large-caliber.
3011 .IP money
3012 Gotta pay for those lawyers and guns!
3013 @end cartouche
3014 @endExample
3016 @sp 1
3017 The second workaround uses the @code{\p} escape to force the break.
3018 Note the space following the escape; this is important.
3019 If you omit the space, @code{groff} prints the first word on
3020 the same line as the term or label (if it fits) @strong{then}
3021 breaks the line.
3023 @Example
3024 @cartouche
3025 A glossary-style list:
3026 .IP lawyers 0.4i
3027 Two or more attorneys.
3028 .IP guns
3029 \p Firearms, preferably large-caliber.
3030 .IP money
3031 Gotta pay for those lawyers and guns!
3032 @end cartouche
3033 @endExample
3035 @sp 1
3036 To set nested lists, use the @code{RS} and @code{RE} macros.
3037 @xref{Indents in ms}, for more information.
3038 @cindex @code{ms} macros, nested lists
3039 @cindex nested lists [@code{ms}]
3041 For example:
3043 @Example
3044 @cartouche
3045 .IP \[bu] 2
3046 Lawyers:
3048 .IP \[bu]
3049 Dewey,
3050 .IP \[bu]
3051 Cheatham,
3052 .IP \[bu]
3053 and Howe.
3055 .IP \[bu]
3056 Guns
3057 @end cartouche
3058 @endExample
3060 Produces:
3062 @Example
3063 o Lawyers:
3065   o  Dewey,
3067   o  Cheatham,
3069   o  and Howe.
3071 o Guns
3072 @endExample
3074 @c ---------------------------------------------------------------------
3076 @node Indents in ms, Tabstops in ms, Lists in ms, ms Body Text
3077 @subsubsection Indents
3079 In many situations,
3080 you may need to indent a section of text
3081 while still wrapping and filling.
3082 @xref{Lists in ms},
3083 for an example of nested lists.
3085 @DefmacList {RS, , ms}
3086 @DefmacListEnd {RE, , ms}
3087 These macros begin and end an indented section.
3088 The @code{PI} register controls the amount of indent,
3089 allowing the indented text to line up under hanging
3090 and indented paragraphs.
3091 @endDefmac
3093 @xref{ms Displays and Keeps},
3094 for macros to indent and turn off filling.
3096 @c ---------------------------------------------------------------------
3098 @node Tabstops in ms, ms Displays and Keeps, Indents in ms, ms Body Text
3099 @subsubsection Tab Stops
3101 Use the @code{ta} request to define tab stops as needed.
3102 @xref{Tabs and Fields}.
3104 @Defmac{TA, , ms}
3105 Use this macro to reset the tab stops to the default for @file{ms}
3106 (every 5n).
3107 You can redefine the @code{TA} macro to create a different set
3108 of default tab stops.
3109 @endDefmac
3111 @c ---------------------------------------------------------------------
3113 @node ms Displays and Keeps, ms Insertions, Tabstops in ms, ms Body Text
3114 @subsubsection Displays and keeps
3115 @cindex @code{ms} macros, displays
3116 @cindex @code{ms} macros, keeps
3117 @cindex keeps [@code{ms}]
3118 @cindex displays [@code{ms}]
3120 Use displays to show text-based examples or figures
3121 (such as code listings).
3123 Displays turn off filling, so lines of code are displayed
3124 as-is without inserting @code{br} requests in between each line.
3125 Displays can be @dfn{kept} on a single page, or allowed
3126 to break across pages.
3128 @DefmacList {DS, @t{L}, ms}
3129 @DefmacItem {LD, , ms}
3130 @DefmacListEnd {DE, , ms}
3131 Left-justified display.
3132 The @samp{.DS L} call generates a page break, if necessary,
3133 to keep the entire display on one page.
3134 The @code{LD} macro allows the display to break across pages.
3135 The @code{DE} macro ends the display.
3136 @endDefmac
3138 @DefmacList {DS, @t{I}, ms}
3139 @DefmacItem {ID, , ms}
3140 @DefmacListEnd {DE, , ms}
3141 Indents the display as defined by the @code{DI} register.
3142 The @samp{.DS I} call generates a page break, if necessary,
3143 to keep the entire display on one page.
3144 The @code{ID} macro allows the display to break across pages.
3145 The @code{DE} macro ends the display.
3146 @endDefmac
3148 @DefmacList {DS, @t{B}, ms}
3149 @DefmacItem {BD, , ms}
3150 @DefmacListEnd {DE, , ms}
3151 Sets a block-centered display: the entire display is left-justified,
3152 but indented so that the longest line in the display is centered
3153 on the page.
3154 The @samp{.DS B} call generates a page break, if necessary,
3155 to keep the entire display on one page.
3156 The @code{BD} macro allows the display to break across pages.
3157 The @code{DE} macro ends the display.
3158 @endDefmac
3160 @DefmacList {DS, @t{C}, ms}
3161 @DefmacItem {CD, , ms}
3162 @DefmacListEnd {DE, , ms}
3163 Sets a centered display: each line in the display is centered.
3164 The @samp{.DS C} call generates a page break, if necessary,
3165 to keep the entire display on one page.
3166 The @code{CD} macro allows the display to break across pages.
3167 The @code{DE} macro ends the display.
3168 @endDefmac
3170 @DefmacList {DS, @t{R}, ms}
3171 @DefmacItem {RD, , ms}
3172 @DefmacListEnd {DE, , ms}
3173 Right-justifies each line in the display.
3174 The @samp{.DS R} call generates a page break, if necessary,
3175 to keep the entire display on one page.
3176 The @code{RD} macro allows the display to break across pages.
3177 The @code{DE} macro ends the display.
3178 @endDefmac
3180 @sp 1
3181 On occasion, you may want to @dfn{keep} other text together on a page.
3182 For example, you may want to keep two paragraphs together, or
3183 a paragraph that refers to a table (or list, or other item)
3184 immediately following.
3185 The @file{ms} macros provide the @code{KS} and @code{KE}
3186 macros for this purpose.
3188 @DefmacList {KS, , ms}
3189 @DefmacListEnd {KE, , ms}
3190 The @code{KS} macro begins a block of text to be kept on a
3191 single page, and the @code{KE} macro ends the block.
3192 @endDefmac
3194 @DefmacList {KF, , ms}
3195 @DefmacListEnd {KE, , ms}
3196 Specifies a @dfn{floating keep};
3197 if the keep cannot fit on the current page, @code{groff}
3198 holds the contents of the keep and allows text following
3199 the keep (in the source file) to fill in the remainder of
3200 the current page.
3201 When the page breaks, whether by an explicit @code{bp}
3202 request or by reaching the end of the page, @code{groff}
3203 prints the floating keep at the top of the new page.
3204 This is useful for printing large graphics or tables
3205 that do not need to appear exactly where specified.
3206 @endDefmac
3208 You can also use the @code{ne} request to force a page break if
3209 there is not enough vertical space remaining on the page.
3211 @sp 1
3212 Use the following macros to draw a box around a section of
3213 text (such as a display).
3215 @DefmacList {B1, , ms}
3216 @DefmacListEnd {B2, , ms}
3217 Marks the beginning and ending of text that is to have a
3218 box drawn around it.
3219 The @code{B1} macro begins the box; the @code{B2} macro ends it.
3220 Text in the box is automatically placed in a diversion (keep).
3221 @endDefmac
3223 @c ---------------------------------------------------------------------
3225 @node ms Insertions, Example multi-page table, ms Displays and Keeps, ms Body Text
3226 @subsubsection Tables, figures, equations, and references
3227 @cindex @code{ms} macros, tables
3228 @cindex @code{ms} macros, figures
3229 @cindex @code{ms} macros, equations
3230 @cindex @code{ms} macros, references
3231 @cindex tables [@code{ms}]
3232 @cindex figures [@code{ms}]
3233 @cindex equations [@code{ms}]
3234 @cindex references [@code{ms}]
3236 The @file{ms} macros support the standard
3237 @code{groff} preprocessors:
3238 @code{tbl}, @code{pic}, @code{eqn}, and @code{refer}.
3239 @pindex tbl
3240 @pindex pic
3241 @pindex eqn
3242 @pindex refer
3243 You mark text meant for preprocessors by enclosing it
3244 in pairs of tags as follows.
3246 @DefmacList {TS, [@code{H}], ms}
3247 @DefmacListEnd {TE, , ms}
3248 Denotes a table, to be processed by the @code{tbl} preprocessor.
3249 The optional argument@tie{}@code{H} to @code{TS} instructs @code{groff}
3250 to create a running header with the information
3251 up to the @code{TH} macro.
3252 @code{groff} prints the header at the beginning of the
3253 table; if the table runs onto another page, @code{groff}
3254 prints the header on the next page as well.
3255 @endDefmac
3257 @DefmacList {PS, , ms}
3258 @DefmacListEnd {PE, , ms}
3259 Denotes a graphic, to be processed by the @code{pic} preprocessor.
3260 You can create a @code{pic} file by hand, using the @acronym{AT&T}
3261 @code{pic} manual available on the Web as a reference, or by using
3262 a graphics program such as @code{xfig}.
3263 @endDefmac
3265 @DefmacList {EQ, [@Var{align}], ms}
3266 @DefmacListEnd {EN, , ms}
3267 Denotes an equation, to be processed by the @code{eqn} preprocessor.
3268 The optional @var{align} argument can be @code{C}, @code{L},
3269 or@tie{}@code{I} to center (the default), left-justify, or indent the
3270 equation.
3271 @endDefmac
3273 @DefmacList {[, , ms}
3274 @DefmacListEnd {], , ms}
3275 Denotes a reference, to be processed by the @code{refer} preprocessor.
3276 The @acronym{GNU} @cite{refer(1)} man page provides a comprehensive
3277 reference to the preprocessor and the format of the bibliographic
3278 database.
3279 @endDefmac
3281 @menu
3282 * Example multi-page table::
3283 @end menu
3285 @c ---------------------------------------------------------------------
3287 @node Example multi-page table, ms Footnotes, ms Insertions, ms Body Text
3288 @subsubsection An example multi-page table
3289 @cindex example markup, multi-page table [@code{ms}]
3290 @cindex multi-page table, example markup [@code{ms}]
3292 The following is an example of how to set up a
3293 table that may print across two or more pages.
3295 @Example
3296 @cartouche
3297 .TS H
3298 allbox expand;
3299 cb | cb .
3300 Text      ...of heading...
3304 l | l .
3305 ... the rest of the table follows...
3308 @end cartouche
3309 @endExample
3311 @c ---------------------------------------------------------------------
3313 @node ms Footnotes,  , Example multi-page table, ms Body Text
3314 @subsubsection Footnotes
3315 @cindex @code{ms} macros, footnotes
3316 @cindex footnotes [@code{ms}]
3318 The @file{ms} macro package has a flexible footnote system.
3319 You can specify either numbered footnotes or symbolic footnotes
3320 (that is, using a marker such as a dagger symbol).
3322 @Defstr {*, ms}
3323 Specifies the location of a numbered footnote marker in the text.
3324 @endDefesc
3326 @DefmacList {FS, , ms}
3327 @DefmacListEnd {FE, , ms}
3328 Specifies the text of the footnote.
3329 The default action is to create a numbered footnote;
3330 you can create a symbolic footnote by specifying
3331 a @dfn{mark} glyph
3332 (such as @code{\[dg]} for the dagger glyph)
3333 in the body text and as an argument to the @code{FS} macro,
3334 followed by the text of the footnote
3335 and the @code{FE} macro.
3336 @endDefmac
3338 You can control how @code{groff}
3339 prints footnote numbers by changing the value of the
3340 @code{FF} register.  @xref{ms Document Control Registers}.
3342 @c ---------------------------------------------------------------------
3344 @node ms Page Layout, Differences from AT&T ms, ms Body Text, ms
3345 @subsection Page layout
3346 @cindex @code{ms} macros, page layout
3347 @cindex page layout [@code{ms}]
3349 The default output from the @file{ms}
3350 macros provides a minimalist page layout:
3351 it prints a single column, with the page number centered at the top
3352 of each page.
3353 It prints no footers.
3355 You can change the layout by setting
3356 the proper number registers and strings.
3358 @menu
3359 * ms Headers and Footers::
3360 * ms Margins::
3361 * ms Multiple Columns::
3362 * ms TOC::
3363 * ms Strings and Special Characters::
3364 @end menu
3366 @c ---------------------------------------------------------------------
3368 @node ms Headers and Footers, ms Margins, ms Page Layout, ms Page Layout
3369 @subsubsection Headers and footers
3370 @cindex @code{ms} macros, headers
3371 @cindex @code{ms} macros, footers
3372 @cindex headers [@code{ms}]
3373 @cindex footers [@code{ms}]
3375 For documents that do not distinguish between odd and even pages,
3376 set the following strings:
3378 @DefstrList {LH, ms}
3379 @DefstrItem {CH, ms}
3380 @DefstrListEnd {RH, ms}
3381 Sets the left, center, and right headers.
3382 @endDefstr
3384 @DefstrList {LF, ms}
3385 @DefstrItem {CF, ms}
3386 @DefstrListEnd {RF, ms}
3387 Sets the left, center, and right footers.
3388 @endDefstr
3390 @sp 1
3391 For documents that need different information printed in the
3392 even and odd pages, use the following macros:
3394 @DefmacList {OH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3395 @DefmacItem {EH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3396 @DefmacItem {OF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3397 @DefmacListEnd {EF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3398 The @code{OH} and @code{EH} macros define headers for the odd and even pages;
3399 the @code{OF} and @code{EF} macros define footers for the odd and even pages.
3400 This is more flexible than defining the individual strings.
3402 You can replace the quote (@code{'}) marks with any character not
3403 appearing in the header or footer text.
3404 @endDefmac
3406 @c ---------------------------------------------------------------------
3408 @node ms Margins, ms Multiple Columns, ms Headers and Footers, ms Page Layout
3409 @subsubsection Margins
3410 @cindex @code{ms} macros, margins
3412 You control margins using a set of number registers.
3413 @xref{ms Document Control Registers}, for details.
3415 @c ---------------------------------------------------------------------
3417 @node ms Multiple Columns, ms TOC, ms Margins, ms Page Layout
3418 @subsubsection Multiple columns
3419 @cindex @code{ms} macros, multiple columns
3420 @cindex multiple columns [@code{ms}]
3422 The @file{ms} macros can set text in as many columns as will
3423 reasonably fit on the page.
3424 The following macros are available;
3425 all of them force a page break if a multi-column mode is already set.
3426 However, if the current mode is single-column, starting a multi-column
3427 mode does @strong{not} force a page break.
3429 @Defmac {1C, , ms}
3430 Single-column mode.
3431 @endDefmac
3433 @Defmac {2C, , ms}
3434 Two-column mode.
3435 @endDefmac
3437 @Defmac {MC, [@Var{width} [@Var{gutter}]], ms}
3438 Multi-column mode.
3439 If you specify no arguments, it is equivalent to the
3440 @code{2C} macro.
3441 Otherwise, @var{width} is the width of each column and
3442 @var{gutter} is the space between columns.
3443 The @code{MINGW} number register controls the default gutter width.
3444 @endDefmac
3446 @c ---------------------------------------------------------------------
3448 @node ms TOC, ms Strings and Special Characters, ms Multiple Columns, ms Page Layout
3449 @subsubsection Creating a table of contents
3450 @cindex @code{ms} macros, creating table of contents
3451 @cindex table of contents, creating [@code{ms}]
3453 The facilities in the @file{ms} macro package for creating
3454 a table of contents are semi-automated at best.
3455 Assuming that you want the table of contents to consist of
3456 the document's headings, you need to repeat those headings
3457 wrapped in @code{XS} and @code{XE} macros.
3459 @DefmacList {XS, [@Var{page}], ms}
3460 @DefmacItem {XA, [@Var{page}], ms}
3461 @DefmacListEnd {XE, , ms}
3462 These macros define a table of contents
3463 or an individual entry in the table of contents,
3464 depending on their use.
3465 The macros are very simple; they cannot indent a heading based on its level.
3466 The easiest way to work around this is to add tabs
3467 to the table of contents string.
3468 The following is an example:
3470 @Example
3471 @cartouche
3472 .NH 1
3473 Introduction
3475 Introduction
3480 .NH 2
3481 Methodology
3483 Methodology
3487 @end cartouche
3488 @endExample
3490 You can manually create a table of contents
3491 by beginning with the @code{XS} macro for the first entry,
3492 specifying the page number for that entry as the argument to @code{XS}.
3493 Add subsequent entries using the @code{XA} macro,
3494 specifying the page number for that entry as the argument to @code{XA}.
3495 The following is an example:
3497 @Example
3498 @cartouche
3499 .XS 1
3500 Introduction
3501 .XA 2
3502 A Brief History of the Universe
3503 .XA 729
3504 Details of Galactic Formation
3507 @end cartouche
3508 @endExample
3509 @endDefmac
3511 @Defmac {TC, [@code{no}], ms}
3512 Prints the table of contents on a new page,
3513 setting the page number to@tie{}@strong{i} (Roman numeral one).
3514 You should usually place this macro at the end of the
3515 file, since @code{groff} is a single-pass formatter and
3516 can only print what has been collected up to the point
3517 that the @code{TC} macro appears.
3519 The optional argument @code{no} suppresses printing
3520 the title specified by the string register @code{TOC}.
3521 @endDefmac
3523 @Defmac{PX, [@code{no}], ms}
3524 Prints the table of contents on a new page,
3525 using the current page numbering sequence.
3526 Use this macro to print a manually-generated table of contents
3527 at the beginning of your document.
3529 The optional argument @code{no} suppresses printing
3530 the title specified by the string register @code{TOC}.
3531 @endDefmac
3533 The @cite{Groff and Friends HOWTO}
3534 includes a @code{sed} script that automatically inserts
3535 @code{XS} and @code{XE} macro entries after each heading in a document.
3537 Altering the @code{NH} macro to automatically build the table
3538 of contents is perhaps initially more difficult, but would save
3539 a great deal of time in the long run if you use @file{ms} regularly.
3541 @c ---------------------------------------------------------------------
3543 @node ms Strings and Special Characters,  , ms TOC, ms Page Layout
3544 @subsubsection Strings and Special Characters
3545 @cindex @code{ms} macros, strings
3546 @cindex @code{ms} macros, special characters
3547 @cindex @code{ms} macros, accent marks
3548 @cindex accent marks [@code{ms}]
3549 @cindex special characters [@code{ms}]
3550 @cindex strings [@code{ms}]
3552 The @file{ms} macros provide the following predefined strings.
3553 You can change the string definitions to help in creating
3554 documents in languages other than English.
3556 @Defstr {REFERENCES, ms}
3557 Contains the string printed at the beginning of the
3558 references (bibliography) page.
3559 The default is @samp{References}.
3560 @endDefstr
3562 @Defstr {ABSTRACT, ms}
3563 Contains the string printed at the beginning of the abstract.
3564 The default is @samp{ABSTRACT}.
3565 @endDefstr
3567 @Defstr {TOC, ms}
3568 Contains the string printed at the beginning of the table of contents.
3569 @endDefstr
3571 @DefstrList {MONTH1, ms}
3572 @DefstrItem {MONTH2, ms}
3573 @DefstrItem {MONTH3, ms}
3574 @DefstrItem {MONTH4, ms}
3575 @DefstrItem {MONTH5, ms}
3576 @DefstrItem {MONTH6, ms}
3577 @DefstrItem {MONTH7, ms}
3578 @DefstrItem {MONTH8, ms}
3579 @DefstrItem {MONTH9, ms}
3580 @DefstrItem {MONTH10, ms}
3581 @DefstrItem {MONTH11, ms}
3582 @DefstrListEnd {MONTH12, ms}
3583 Prints the full name of the month in dates.
3584 The default is @samp{January}, @samp{February}, etc.
3585 @endDefstr
3587 The following special characters are available@footnote{For an
3588 explanation what special characters are see @ref{Special Characters}.}:
3590 @Defstr {-, ms}
3591 Prints an em dash.
3592 @endDefstr
3594 @DefstrList {*Q, ms}
3595 @DefstrListEnd {*U, ms}
3596 Prints typographer's quotes in troff,
3597 plain quotes in nroff.
3598 @code{*Q} is the left quote and @code{*U} is the right quote.
3599 @endDefstr
3601 Improved accent marks are available in the @file{ms} macros.
3603 @Defmac {AM, , ms}
3604 Specify this macro at the beginning of your document
3605 to enable extended accent marks and special characters.
3606 This is a Berkeley extension.
3608 To use the accent marks, place them @strong{after}
3609 the character being accented.
3610 @endDefmac
3612 The following accent marks are available
3613 after invoking the @code{AM} macro:
3615 @Defstr {\', ms}
3616 Acute accent.
3617 @endDefstr
3619 @Defstr {\`, ms}
3620 Grave accent.
3621 @endDefstr
3623 @Defstr {^, ms}
3624 Circumflex.
3625 @endDefstr
3627 @Defstr {\,, ms}
3628 Cedilla.
3629 @endDefstr
3631 @Defstr {~, ms}
3632 Tilde.
3633 @endDefstr
3635 @deffn String @t{\*[:]}
3636 @ifnotinfo
3637 @stindex : @r{[}ms@r{]}
3638 @end ifnotinfo
3639 @ifinfo
3640 @stindex \*[@r{<colon>}] @r{[}ms@r{]}
3641 @end ifinfo
3642 Umlaut.
3643 @end deffn
3645 @Defstr {v, ms}
3646 Hacek.
3647 @endDefstr
3649 @Defstr {_, ms}
3650 Macron (overbar).
3651 @endDefstr
3653 @Defstr {., ms}
3654 Underdot.
3655 @endDefstr
3657 @Defstr {o, ms}
3658 Ring above.
3659 @endDefstr
3661 The following are standalone characters
3662 available after invoking the @code{AM} macro:
3664 @Defstr {?, ms}
3665 Upside-down question mark.
3666 @endDefstr
3668 @Defstr {!, ms}
3669 Upside-down exclamation point.
3670 @endDefstr
3672 @Defstr {8, ms}
3673 German @ss{} ligature.
3674 @endDefstr
3676 @Defstr {3, ms}
3677 Yogh.
3678 @endDefstr
3680 @Defstr {Th, ms}
3681 Uppercase thorn.
3682 @endDefstr
3684 @Defstr {th, ms}
3685 Lowercase thorn.
3686 @endDefstr
3688 @Defstr {D-, ms}
3689 Uppercase eth.
3690 @endDefstr
3692 @Defstr {d-, ms}
3693 Lowercase eth.
3694 @endDefstr
3696 @Defstr {q, ms}
3697 Hooked o.
3698 @endDefstr
3700 @Defstr {ae, ms}
3701 Lowercase @ae{} ligature.
3702 @endDefstr
3704 @Defstr {Ae, ms}
3705 Uppercase @AE{} ligature.
3706 @endDefstr
3708 @c ---------------------------------------------------------------------
3710 @node Differences from AT&T ms,  , ms Page Layout, ms
3711 @subsection Differences from @acronym{AT&T} @file{ms}
3712 @cindex @code{ms} macros, differences from @acronym{AT&T}
3713 @cindex @acronym{AT&T} @code{troff}, @code{ms} macro package differences
3715 This section lists the (minor) differences between the
3716 @code{groff -ms} macros and @acronym{AT&T}
3717 @code{troff -ms} macros.
3719 @menu
3720 * Missing ms Macros::
3721 * Additional ms Macros::
3722 @end menu
3724 @c ---------------------------------------------------------------------
3726 @node Missing ms Macros, Additional ms Macros, Differences from AT&T ms, Differences from AT&T ms
3727 @subsubsection @code{troff} macros not appearing in @code{groff}
3729 Macros missing from @code{groff -ms}
3730 are cover page macros specific to Bell Labs.
3731 The macros known to be missing are:
3733 @table @code
3734 @item .TM
3735 Technical memorandum; a cover sheet style
3737 @item .IM
3738 Internal memorandum; a cover sheet style
3740 @item .MR
3741 Memo for record; a cover sheet style
3743 @item .MF
3744 Memo for file; a cover sheet style
3746 @item .EG
3747 Engineer's notes; a cover sheet style
3749 @item .TR
3750 Computing Science Tech Report; a cover sheet style
3752 @item .OK
3753 Other keywords
3755 @item .CS
3756 Cover sheet information
3758 @item .MH
3759 A cover sheet macro
3760 @end table
3762 @c ---------------------------------------------------------------------
3764 @node Additional ms Macros,  , Missing ms Macros, Differences from AT&T ms
3765 @subsubsection @code{groff} macros not appearing in @acronym{AT&T} @code{troff}
3767 The @code{groff -ms} macros have a few minor extensions
3768 compared to the @acronym{AT&T} @code{troff -ms} macros.
3770 @Defmac {AM, , ms}
3771 Improved accent marks.
3772 @xref{ms Strings and Special Characters}, for details.
3773 @endDefmac
3775 @Defmac {DS, @t{I}, ms}
3776 Indented display.
3777 The default behavior of @acronym{AT&T} @code{troff -ms}
3778 was to indent; the @code{groff} default prints displays
3779 flush left with the body text.
3780 @endDefmac
3782 @Defmac {CW, , ms}
3783 Print text in @code{constant width} (Courier) font.
3784 @endDefmac
3786 @Defmac {IX, , ms}
3787 Indexing term (printed on standard error).
3788 You can write a script to capture and process an index
3789 generated in this manner.
3790 @endDefmac
3792 @sp 1
3793 The following additional number registers
3794 appear in @code{groff -ms}:
3796 @Defmpreg {MINGW, ms}
3797 Specifies a minimum space
3798 between columns (for multi-column output); this takes the
3799 place of the @code{GW} register that was documented but apparently
3800 not implemented in @acronym{AT&T} @code{troff}.
3801 @endDefmpreg
3803 @sp 1
3804 Several new string registers are available as well.
3805 You can change these to handle (for example) the local language.
3806 @xref{ms Strings and Special Characters}, for details.
3809 @c =====================================================================
3811 @node me, mm, ms, Macro Packages
3812 @section @file{me}
3813 @cindex @code{me} macro package
3815 @c XXX documentation
3816 @c XXX this is a placeholder until we get stuff knocked into shape
3817 See the @file{meintro.me} and @file{meref.me} documents in
3818 groff's @file{doc} directory.
3821 @c =====================================================================
3823 @node mm,  , me, Macro Packages
3824 @section @file{mm}
3825 @cindex @code{mm} macro package
3827 @c XXX documentation
3828 @c XXX this is a placeholder until we get stuff knocked into shape
3829 See the @cite{groff_mm(7)} man page (type @command{man groff_mm} at
3830 the command line).
3833 @c =====================================================================
3834 @c =====================================================================
3836 @node gtroff Reference, Preprocessors, Macro Packages, Top
3837 @chapter @code{gtroff} Reference
3838 @cindex reference, @code{gtroff}
3839 @cindex @code{gtroff}, reference
3841 This chapter covers @strong{all} of the facilities of @code{gtroff}.
3842 Users of macro packages may skip it if not interested in details.
3845 @menu
3846 * Text::
3847 * Input Conventions::
3848 * Measurements::
3849 * Expressions::
3850 * Identifiers::
3851 * Embedded Commands::
3852 * Registers::
3853 * Manipulating Filling and Adjusting::
3854 * Manipulating Hyphenation::
3855 * Manipulating Spacing::
3856 * Tabs and Fields::
3857 * Character Translations::
3858 * Troff and Nroff Mode::
3859 * Line Layout::
3860 * Line Control::
3861 * Page Layout::
3862 * Page Control::
3863 * Fonts::
3864 * Sizes::
3865 * Strings::
3866 * Conditionals and Loops::
3867 * Writing Macros::
3868 * Page Motions::
3869 * Drawing Requests::
3870 * Traps::
3871 * Diversions::
3872 * Environments::
3873 * Suppressing output::
3874 * Colors::
3875 * I/O::
3876 * Postprocessor Access::
3877 * Miscellaneous::
3878 * Gtroff Internals::
3879 * Debugging::
3880 * Implementation Differences::
3881 @end menu
3884 @c =====================================================================
3886 @node Text, Input Conventions, gtroff Reference, gtroff Reference
3887 @section Text
3888 @cindex text, @code{gtroff} processing
3890 @code{gtroff} input files contain text with control commands
3891 interspersed throughout.  But, even without control codes, @code{gtroff}
3892 still does several things with the input text:
3894 @itemize @bullet
3895 @item
3896 filling and adjusting
3898 @item
3899 adding additional space after sentences
3901 @item
3902 hyphenating
3904 @item
3905 inserting implicit line breaks
3906 @end itemize
3908 @menu
3909 * Filling and Adjusting::
3910 * Hyphenation::
3911 * Sentences::
3912 * Tab Stops::
3913 * Implicit Line Breaks::
3914 @end menu
3916 @c ---------------------------------------------------------------------
3918 @node Filling and Adjusting, Hyphenation, Text, Text
3919 @subsection Filling and Adjusting
3920 @cindex filling
3921 @cindex adjusting
3923 When @code{gtroff} reads text, it collects words from the input and fits
3924 as many of them together on one output line as it can.  This is known as
3925 @dfn{filling}.
3927 @cindex leading spaces
3928 @cindex spaces, leading and trailing
3929 @cindex extra spaces
3930 @cindex trailing spaces
3931 Once @code{gtroff} has a @dfn{filled} line, it tries to @dfn{adjust}
3932 it.  This means it widens the spacing between words until the text
3933 reaches the right margin (in the default adjustment mode).  Extra spaces
3934 between words are preserved, but spaces at the end of lines are ignored.
3935 Spaces at the front of a line cause a @dfn{break} (breaks are
3936 explained in @ref{Implicit Line Breaks}).
3938 @xref{Manipulating Filling and Adjusting}.
3940 @c ---------------------------------------------------------------------
3942 @node Hyphenation, Sentences, Filling and Adjusting, Text
3943 @subsection Hyphenation
3944 @cindex hyphenation
3946 Since the odds are not great for finding a set of words, for every
3947 output line, which fit nicely on a line without inserting excessive
3948 amounts of space between words, @code{gtroff} hyphenates words so
3949 that it can justify lines without inserting too much space between
3950 words.  It uses an internal hyphenation algorithm (a simplified version
3951 of the algorithm used within @TeX{}) to indicate which words can be
3952 hyphenated and how to do so.  When a word is hyphenated, the first part
3953 of the word is added to the current filled line being output (with
3954 an attached hyphen), and the other portion is added to the next
3955 line to be filled.
3957 @xref{Manipulating Hyphenation}.
3959 @c ---------------------------------------------------------------------
3961 @node Sentences, Tab Stops, Hyphenation, Text
3962 @subsection Sentences
3963 @cindex sentences
3965 Although it is often debated, some typesetting rules say there should be
3966 different amounts of space after various punctuation marks.  For
3967 example, the @cite{Chicago typsetting manual} says that a period at the
3968 end of a sentence should have twice as much space following it as would
3969 a comma or a period as part of an abbreviation.
3971 @c XXX exact citation of Chicago manual
3973 @cindex sentence space
3974 @cindex space between sentences
3975 @cindex french-spacing
3976 @code{gtroff} does this by flagging certain characters (normally
3977 @samp{!}, @samp{?}, and @samp{.}) as @dfn{end-of-sentence} characters.
3978 When @code{gtroff} encounters one of these characters at the end of a
3979 line, it appends a normal space followed by a @dfn{sentence space} in
3980 the formatted output.  (This justifies one of the conventions mentioned
3981 in @ref{Input Conventions}.)
3983 @cindex transparent characters
3984 @cindex character, transparent
3985 @cindex @code{dg} glyph, at end of sentence
3986 @cindex @code{rq} glyph, at end of sentence
3987 @cindex @code{"}, at end of sentence
3988 @cindex @code{'}, at end of sentence
3989 @cindex @code{)}, at end of sentence
3990 @cindex @code{]}, at end of sentence
3991 @cindex @code{*}, at end of sentence
3992 In addition, the following characters and symbols are treated
3993 transparently while handling end-of-sentence characters: @samp{"},
3994 @samp{'}, @samp{)}, @samp{]}, @samp{*}, @code{\[dg]}, and @code{\[rq]}.
3996 See the @code{cflags} request in @ref{Using Symbols}, for more details.
3998 @cindex @code{\&}, at end of sentence
3999 To prevent the insertion of extra space after an end-of-sentence
4000 character (at the end of a line), append @code{\&}.
4002 @c ---------------------------------------------------------------------
4004 @node Tab Stops, Implicit Line Breaks, Sentences, Text
4005 @subsection Tab Stops
4006 @cindex tab stops
4007 @cindex stops, tabulator
4008 @cindex tab character
4009 @cindex character, tabulator
4011 @cindex @acronym{EBCDIC} encoding
4012 @cindex encoding, @acronym{EBCDIC}
4013 @code{gtroff} translates @dfn{tabulator characters}, also called
4014 @dfn{tabs} (normally code point @acronym{ASCII} @code{0x09} or
4015 @acronym{EBCDIC} @code{0x05}), in the input into movements to the next
4016 tabulator stop.  These tab stops are initially located every half inch
4017 across the page.  Using this, simple tables can be made easily.
4018 However, it can often be deceptive as the appearance (and width) of the
4019 text on a terminal and the results from @code{gtroff} can vary greatly.
4021 Also, a possible sticking point is that lines beginning with tab
4022 characters are still filled, again producing unexpected results.
4023 For example, the following input
4025 @multitable {12345678} {12345678} {12345678} {12345678}
4026 @item
4027 @tab 1 @tab 2 @tab 3
4028 @item
4029 @tab   @tab 4 @tab 5
4030 @end multitable
4032 @noindent
4033 produces
4035 @multitable {12345678} {12345678} {12345678} {12345678} {12345678} {12345678} {12345678}
4036 @item
4037 @tab 1 @tab 2 @tab 3 @tab   @tab 4 @tab 5
4038 @end multitable
4040 @xref{Tabs and Fields}.
4042 @c ---------------------------------------------------------------------
4044 @node Implicit Line Breaks,  , Tab Stops, Text
4045 @subsection Implicit Line Breaks
4046 @cindex implicit line breaks
4047 @cindex implicit breaks of lines
4048 @cindex line, implicit breaks
4049 @cindex break, implicit
4050 @cindex line break
4052 An important concept in @code{gtroff} is the @dfn{break}.  When a break
4053 occurs, @code{gtroff} outputs the partially filled line
4054 (unjustified), and resumes collecting and filling text on the next output
4055 line.
4057 @cindex blank line
4058 @cindex empty line
4059 @cindex line, blank
4060 @cindex blank line macro (@code{blm})
4061 There are several ways to cause a break in @code{gtroff}.  A blank
4062 line not only causes a break, but it also outputs a one-line vertical
4063 space (effectively a blank line).  Note that this behaviour can be
4064 modified with the blank line macro request @code{blm}.
4065 @xref{Blank Line Traps}.
4067 @cindex fill mode
4068 @cindex mode, fill
4069 A line that begins with a space causes a break and the space is
4070 output at the beginning of the next line.  Note that this space isn't
4071 adjusted, even in fill mode.
4073 The end of file also causes a break -- otherwise the last line of
4074 the document may vanish!
4076 Certain requests also cause breaks, implicitly or explicitly.  This is
4077 discussed in @ref{Manipulating Filling and Adjusting}.
4080 @c =====================================================================
4082 @node Input Conventions, Measurements, Text, gtroff Reference
4083 @section Input Conventions
4084 @cindex input conventions
4085 @cindex conventions for input
4087 Since @code{gtroff} does filling automatically, it is traditional in
4088 @code{groff} not to try and type things in as nicely formatted
4089 paragraphs.  These are some conventions commonly used when typing
4090 @code{gtroff} text:
4092 @itemize @bullet
4093 @item
4094 Break lines after punctuation, particularly at the end of a sentence
4095 and in other logical places.  Keep separate phrases on lines by
4096 themselves, as entire phrases are often added or deleted when editing.
4098 @item
4099 Try to keep lines less than 40-60@tie{}characters, to allow space for
4100 inserting more text.
4102 @item
4103 Do not try to do any formatting in a @acronym{WYSIWYG} manner (i.e.,
4104 don't try using spaces to get proper indentation).
4105 @end itemize
4108 @c =====================================================================
4110 @node Measurements, Expressions, Input Conventions, gtroff Reference
4111 @section Measurements
4112 @cindex measurements
4114 @cindex units of measurement
4115 @cindex basic unit (@code{u})
4116 @cindex machine unit (@code{u})
4117 @cindex measurement unit
4118 @cindex @code{u} unit
4119 @cindex unit, @code{u}
4120 @code{gtroff} (like many other programs) requires numeric parameters to
4121 specify various measurements.  Most numeric parameters@footnote{those
4122 that specify vertical or horizontal motion or a type size} may have a
4123 @dfn{measurement unit} attached.  These units are specified as a single
4124 character which immediately follows the number or expression.  Each of
4125 these units are understood, by @code{gtroff}, to be a multiple of its
4126 @dfn{basic unit}.  So, whenever a different measurement unit is
4127 specified @code{gtroff} converts this into its @dfn{basic units}.  This
4128 basic unit, represented by a @samp{u}, is a device dependent measurement
4129 which is quite small, ranging from 1/75@dmn{th} to 1/72000@dmn{th} of an
4130 inch.  The values may be given as fractional numbers; however,
4131 fractional basic units are always rounded to integers.
4133 Some of the measurement units are completely independent of any of the
4134 current settings (e.g.@: type size) of @code{gtroff}.
4136 @table @code
4137 @item i
4138 @cindex inch unit (@code{i})
4139 @cindex @code{i} unit
4140 @cindex unit, @code{i}
4141 Inches.  An antiquated measurement unit still in use in certain
4142 backwards countries with incredibly low-cost computer equipment.  One
4143 inch is equal to@tie{}2.54@dmn{cm}.
4145 @item c
4146 @cindex centimeter unit (@code{c})
4147 @cindex @code{c} unit
4148 @cindex unit, @code{c}
4149 Centimeters.  One centimeter is equal to@tie{}0.3937@dmn{in}.
4151 @item p
4152 @cindex point unit (@code{p})
4153 @cindex @code{p} unit
4154 @cindex unit, @code{p}
4155 Points.  This is a typesetter's measurement used for measure type size.
4156 It is 72@tie{}points to an inch.
4158 @item P
4159 @cindex pica unit (@code{P})
4160 @cindex @code{P} unit
4161 @cindex unit, @code{P}
4162 Pica.  Another typesetting measurement.  6@tie{}Picas to an inch (and
4163 12@tie{}points to a pica).
4165 @item s
4166 @itemx z
4167 @cindex @code{s} unit
4168 @cindex unit, @code{s}
4169 @cindex @code{z} unit
4170 @cindex unit, @code{z}
4171 @xref{Fractional Type Sizes}, for a discussion of these units.
4173 @item f
4174 @cindex @code{f} unit
4175 @cindex unit, @code{f}
4176 Fractions. Value is 65536.
4177 @xref{Colors}, for usage.
4178 @end table
4180 The other measurements understood by @code{gtroff} depend on
4181 settings currently in effect in @code{gtroff}.  These are very useful
4182 for specifying measurements which should look proper with any size of
4183 text.
4185 @table @code
4186 @item m
4187 @cindex em unit (@code{m})
4188 @cindex @code{m} unit
4189 @cindex unit, @code{m}
4190 Ems.  This unit is equal to the current font size in points.  So called
4191 because it is @emph{approximately} the width of the letter@tie{}@samp{m}
4192 in the current font.
4194 @item n
4195 @cindex en unit (@code{n})
4196 @cindex @code{n} unit
4197 @cindex unit, @code{n}
4198 Ens.  In @code{groff}, this is half of an em.
4200 @item v
4201 @cindex vertical space unit (@code{v})
4202 @cindex space, vertical, unit (@code{v})
4203 @cindex @code{v} unit
4204 @cindex unit, @code{v}
4205 Vertical space.  This is equivalent to the current line spacing.
4206 @xref{Sizes}, for more information about this.
4208 @item M
4209 @cindex @code{M} unit
4210 @cindex unit, @code{M}
4211 100ths of an em.
4212 @end table
4214 @menu
4215 * Default Units::
4216 @end menu
4218 @c ---------------------------------------------------------------------
4220 @node Default Units,  , Measurements, Measurements
4221 @subsection Default Units
4222 @cindex default units
4223 @cindex units, default
4225 Many requests take a default unit.  While this can be helpful at times,
4226 it can cause strange errors in some expressions.  For example, the line
4227 length request expects em units.  Here are several attempts to get a
4228 line length of 3.5@tie{}inches and their results:
4230 @Example
4231 3.5i      @result{}   3.5i
4232 7/2       @result{}   0i
4233 7/2i      @result{}   0i
4234 (7 / 2)u  @result{}   0i
4235 7i/2      @result{}   0.1i
4236 7i/2u     @result{}   3.5i
4237 @endExample
4239 @noindent
4240 Everything is converted to basic units first.  In the above example it
4241 is assumed that 1@dmn{i} equals@tie{}240@dmn{u}, and 1@dmn{m}
4242 equals@tie{}10@dmn{p} (thus 1@dmn{m} equals@tie{}33@dmn{u}).  The value
4243 7@dmn{i}/2 is first handled as 7@dmn{i}/2@dmn{m}, then converted to
4244 1680@dmn{u}/66@dmn{u} which is 25@dmn{u}, and this is approximately
4245 0.1@dmn{i}.  As can be seen, a scaling indicator after a closing
4246 parenthesis is simply ignored.
4248 @cindex measurements, specifying safely
4249 Thus, the safest way to specify measurements is to always
4250 attach a scaling indicator.  If you want to multiply or divide by a
4251 certain scalar value, use @samp{u} as the unit for that value.
4254 @c =====================================================================
4256 @node Expressions, Identifiers, Measurements, gtroff Reference
4257 @section Expressions
4258 @cindex expressions
4260 @code{gtroff} has most arithmetic operators common to other languages:
4262 @itemize @bullet
4263 @item
4264 @cindex arithmetic operators
4265 @cindex operators, arithmetic
4266 @opindex +
4267 @opindex -
4268 @opindex /
4269 @opindex *
4270 @opindex %
4271 Arithmetic: @samp{+} (addition), @samp{-} (subtraction), @samp{/}
4272 (division), @samp{*} (multiplication), @samp{%} (modulo).
4274 @code{gtroff} only provides integer arithmetic.  The internal type used
4275 for computing results is @samp{int}, which is usually a 32@dmn{bit}
4276 signed integer.
4278 @item
4279 @cindex comparison operators
4280 @cindex operators, comparison
4281 @opindex <
4282 @opindex >
4283 @opindex >=
4284 @opindex <=
4285 @opindex =
4286 @opindex ==
4287 Comparison: @samp{<} (less than), @samp{>} (greater than), @samp{<=}
4288 (less than or equal), @samp{>=} (greater than or equal), @samp{=}
4289 (equal), @samp{==} (the same as @samp{=}).
4291 @item
4292 @cindex logical operators
4293 @cindex operators, logical
4294 @opindex &
4295 @ifnotinfo
4296 @opindex :
4297 @end ifnotinfo
4298 @ifinfo
4299 @opindex @r{<colon>}
4300 @end ifinfo
4301 Logical: @samp{&} (logical and), @samp{:} (logical or).
4303 @item
4304 @cindex unary operators
4305 @cindex operators, unary
4306 @opindex -
4307 @opindex +
4308 @opindex !
4309 @cindex @code{if} request, and the @samp{!} operator
4310 @cindex @code{while} request, and the @samp{!} operator
4311 Unary operators: @samp{-} (negating, i.e.@: changing the sign), @samp{+}
4312 (just for completeness; does nothing in expressions), @samp{!} (logical
4313 not; this works only within @code{if} and @code{while} requests).  See
4314 below for the use of unary operators in motion requests.
4316 @item
4317 @cindex extremum operators (@code{>?}, @code{<?})
4318 @cindex operators, extremum (@code{>?}, @code{<?})
4319 @opindex >?
4320 @opindex <?
4321 Extrema: @samp{>?} (maximum), @samp{<?} (minimum).
4323 Example:
4325 @Example
4326 .nr x 5
4327 .nr y 3
4328 .nr z (\n[x] >? \n[y])
4329 @endExample
4331 @noindent
4332 The register@tie{}@code{z} now contains@tie{}5.
4334 @item
4335 @cindex scaling operator
4336 @cindex operator, scaling
4337 Scaling: @code{(@var{c};@var{e})}.  Evaluate@tie{}@var{e} using@tie{}@var{c}
4338 as the default scaling indicator.  If @var{c} is missing, ignore scaling
4339 indicators in the evaluation of@tie{}@var{e}.
4340 @end itemize
4342 @cindex parentheses
4343 @cindex order of evaluation in expressions
4344 @cindex expression, order of evaluation
4345 @opindex (
4346 @opindex )
4347 Parentheses may be used as in any other language.  However, in
4348 @code{gtroff} they are necessary to ensure order of evaluation.
4349 @code{gtroff} has no operator precedence; expressions are evaluated left
4350 to right.  This means that @code{gtroff} evaluates @samp{3+5*4} as if it were
4351 parenthesized like @samp{(3+5)*4}, not as @samp{3+(5*4)}, as might be
4352 expected.
4354 @cindex @code{+}, and page motion
4355 @cindex @code{-}, and page motion
4356 @cindex motion operators
4357 @cindex operators, motion
4358 For many requests which cause a motion on the page, the unary operators
4359 @samp{+} and @samp{-} work differently if leading an expression.  They
4360 then indicate a motion relative to the current position (down or up,
4361 respectively).
4363 @cindex @code{|}, and page motion
4364 @cindex absolute position operator (@code{|})
4365 @cindex position, absolute, operator (@code{|})
4366 Similarly, a leading @samp{|} operator indicates an absolute position.
4367 For vertical movements, it specifies the distance from the top of the
4368 page; for horizontal movements, it gives the distance from the beginning
4369 of the @emph{input} line.
4371 @cindex @code{bp} request, using @code{+} and@tie{}@code{-}
4372 @cindex @code{in} request, using @code{+} and@tie{}@code{-}
4373 @cindex @code{ll} request, using @code{+} and@tie{}@code{-}
4374 @cindex @code{lt} request, using @code{+} and@tie{}@code{-}
4375 @cindex @code{nm} request, using @code{+} and@tie{}@code{-}
4376 @cindex @code{nr} request, using @code{+} and@tie{}@code{-}
4377 @cindex @code{pl} request, using @code{+} and@tie{}@code{-}
4378 @cindex @code{pn} request, using @code{+} and@tie{}@code{-}
4379 @cindex @code{po} request, using @code{+} and@tie{}@code{-}
4380 @cindex @code{ps} request, using @code{+} and@tie{}@code{-}
4381 @cindex @code{pvs} request, using @code{+} and@tie{}@code{-}
4382 @cindex @code{rt} request, using @code{+} and@tie{}@code{-}
4383 @cindex @code{ti} request, using @code{+} and@tie{}@code{-}
4384 @cindex @code{\H}, using @code{+} and@tie{}@code{-}
4385 @cindex @code{\R}, using @code{+} and@tie{}@code{-}
4386 @cindex @code{\s}, using @code{+} and@tie{}@code{-}
4387 @samp{+} and @samp{-} are also treated differently by the following
4388 requests and escapes: @code{bp}, @code{in}, @code{ll}, @code{lt},
4389 @code{nm}, @code{nr}, @code{pl}, @code{pn}, @code{po}, @code{ps},
4390 @code{pvs}, @code{rt}, @code{ti}, @code{\H}, @code{\R}, and @code{\s}.
4391 Here, leading plus and minus signs indicate increments and decrements.
4393 @xref{Setting Registers}, for some examples.
4395 @Defesc {\\B, ', anything, '}
4396 @cindex numeric expression, valid
4397 @cindex valid numeric expression
4398 Return@tie{}1 if @var{anything} is a valid numeric expression;
4399 or@tie{}0 if @var{anything} is empty or not a valid numeric expression.
4400 @endDefesc
4402 @cindex space characters, in expressions
4403 @cindex expressions, and space characters
4404 Due to the way arguments are parsed, spaces are not allowed in
4405 expressions, unless the entire expression is surrounded by parentheses.
4407 @xref{Request Arguments}, and @ref{Conditionals and Loops}.
4410 @c =====================================================================
4412 @node Identifiers, Embedded Commands, Expressions, gtroff Reference
4413 @section Identifiers
4414 @cindex identifiers
4416 Like any other language, @code{gtroff} has rules for properly formed
4417 @dfn{identifiers}.  In @code{gtroff}, an identifier can be made up of
4418 almost any printable character, with the exception of the following
4419 characters:
4421 @itemize @bullet
4422 @item
4423 @cindex whitespace characters
4424 @cindex newline character
4425 @cindex character, whitespace
4426 Whitespace characters (spaces, tabs, and newlines).
4428 @item
4429 @cindex character, backspace
4430 @cindex backspace character
4431 @cindex @acronym{EBCDIC} encoding of backspace
4432 Backspace (@acronym{ASCII}@tie{}@code{0x08} or
4433 @acronym{EBCDIC}@tie{}@code{0x16}) and character code @code{0x01}.
4435 @item
4436 @cindex invalid input characters
4437 @cindex input characters, invalid
4438 @cindex characters, invalid input
4439 @cindex Unicode
4440 The following input characters are invalid and are ignored if
4441 @code{groff} runs on a machine based on @acronym{ASCII}, causing a
4442 warning message of type @samp{input} (see @ref{Debugging}, for more
4443 details): @code{0x00}, @code{0x0B}, @code{0x0D}-@code{0x1F},
4444 @code{0x80}-@code{0x9F}.
4446 And here are the invalid input characters if @code{groff} runs on an
4447 @acronym{EBCDIC} host: @code{0x00}, @code{0x08}, @code{0x09},
4448 @code{0x0B}, @code{0x0D}-@code{0x14}, @code{0x17}-@code{0x1F},
4449 @code{0x30}-@code{0x3F}.
4451 Currently, some of these reserved codepoints are used internally, thus
4452 making it non-trivial to extend @code{gtroff} to cover Unicode or other
4453 character sets and encodings which use characters of these ranges.
4455 Note that invalid characters are removed before parsing; an
4456 identifier @code{foo}, followed by an invalid character, followed by
4457 @code{bar} is treated as @code{foobar}.
4458 @end itemize
4460 For example, any of the following is valid.
4462 @Example
4466 end-list
4468 @endExample
4470 @cindex @code{]}, as part of an identifier
4471 @noindent
4472 Note that identifiers longer than two characters with a closing bracket
4473 (@samp{]}) in its name can't be accessed with escape sequences which
4474 expect an identifier as a parameter.  For example, @samp{\[foo]]}
4475 accesses the glyph @samp{foo}, followed by @samp{]}, whereas
4476 @samp{\C'foo]'} really asks for glyph @samp{foo]}.
4478 @cindex @code{refer}, and macro names starting with @code{[} or @code{]}
4479 @cindex @code{[}, macro names starting with, and @code{refer}
4480 @cindex @code{]}, macro names starting with, and @code{refer}
4481 @cindex macro names, starting with @code{[} or @code{]}, and @code{refer}
4482 To avoid problems with the @code{refer} preprocessor, macro names
4483 should not start with @samp{[} or @samp{]}.  Due to backwards
4484 compatibility, everything after @samp{.[} and @samp{.]} is handled as
4485 a special argument to @code{refer}.  For example, @samp{.[foo} makes
4486 @code{refer} to start a reference, using @samp{foo} as a parameter.
4488 @Defesc {\\A, ', ident, '}
4489 Test whether an identifier @var{ident} is valid in @code{gtroff}.  It
4490 expands to the character@tie{}1 or@tie{}0 according to whether its
4491 argument (usually delimited by quotes) is or is not acceptable as the
4492 name of a string, macro, diversion, number register, environment, or
4493 font.  It returns@tie{}0 if no argument is given.  This is useful for
4494 looking up user input in some sort of associative table.
4496 @Example
4497 \A'end-list'
4498     @result{} 1
4499 @endExample
4500 @endDefesc
4502 @xref{Escapes}, for details on parameter delimiting characters.
4504 Identifiers in @code{gtroff} can be any length, but, in some contexts,
4505 @code{gtroff} needs to be told where identifiers end and text begins
4506 (and in different ways depending on their length):
4508 @itemize @bullet
4509 @item
4510 Single character.
4512 @cindex @code{(}, starting a two-character identifier
4513 @item
4514 Two characters.  Must be prefixed with @samp{(} in some situations.
4516 @cindex @code{[}, starting an identifier
4517 @cindex @code{]}, ending an identifier
4518 @item
4519 Arbitrary length (@code{gtroff} only).  Must be bracketed with @samp{[}
4520 and@tie{}@samp{]} in some situations.  Any length identifier can be put
4521 in brackets.
4522 @end itemize
4524 @cindex undefined identifiers
4525 @cindex identifiers, undefined
4526 Unlike many other programming languages, undefined identifiers are
4527 silently ignored or expanded to nothing.
4528 When @code{gtroff} finds an undefined identifier, it emits a
4529 warning, doing the following:
4531 @itemize @bullet
4532 @item
4533 If the identifier is a string, macro, or diversion,
4534 @code{gtroff} defines it as empty.
4536 @item
4537 If the identifier is a number register, @code{gtroff}
4538 defines it with a value of@tie{}0.
4539 @end itemize
4541 @xref{Warnings}., @ref{Interpolating Registers}, and @ref{Strings}.
4543 Note that macros, strings, and diversions share the same name space.
4545 @Example
4546 .de xxx
4547 .  nop foo
4550 .di xxx
4555 .xxx
4556     @result{} bar
4557 @endExample
4559 @noindent
4560 As can be seen in the previous example, @code{gtroff} reuses the
4561 identifier @samp{xxx}, changing it from a macro to a diversion.
4562 No warning is emitted!  The contents of the first macro definition is
4563 lost.
4565 @xref{Interpolating Registers}, and @ref{Strings}.
4568 @c =====================================================================
4570 @node Embedded Commands, Registers, Identifiers, gtroff Reference
4571 @section Embedded Commands
4572 @cindex embedded commands
4573 @cindex commands, embedded
4575 Most documents need more functionality beyond filling, adjusting and
4576 implicit line breaking.  In order to gain further functionality,
4577 @code{gtroff} allows commands to be embedded into the text, in two ways.
4579 The first is a @dfn{request} which takes up an entire line, and does
4580 some large-scale operation (e.g.@: break lines, start new pages).
4582 The other is an @dfn{escape} which can be usually embedded anywhere
4583 in the text; most requests can accept it even as an argument.
4584 Escapes generally do more minor operations like sub- and superscripts,
4585 print a symbol, etc.
4587 @menu
4588 * Requests::
4589 * Macros::
4590 * Escapes::
4591 @end menu
4593 @c ---------------------------------------------------------------------
4595 @node Requests, Macros, Embedded Commands, Embedded Commands
4596 @subsection Requests
4597 @cindex requests
4599 @cindex control character (@code{.})
4600 @cindex character, control (@code{.})
4601 @cindex no-break control character (@code{'})
4602 @cindex character, no-break control (@code{'})
4603 @cindex control character, no-break (@code{'})
4604 A request line begins with a control character, which is either a single
4605 quote (@samp{'}, the @dfn{no-break control character}) or a period
4606 (@samp{.}, the normal @dfn{control character}).  These can be changed;
4607 see @ref{Character Translations}, for details.  After this there may be
4608 optional tabs or spaces followed by an identifier which is the name of
4609 the request.  This may be followed by any number of space-separated
4610 arguments (@emph{no} tabs here).
4612 @cindex structuring source code of documents or macro packages
4613 @cindex documents, structuring the source code
4614 @cindex macro packages, structuring the source code
4615 Since a control character followed by whitespace only is ignored, it
4616 is common practice to use this feature for structuring the source code
4617 of documents or macro packages.
4619 @Example
4620 .de foo
4621 .  tm This is foo.
4625 .de bar
4626 .  tm This is bar.
4628 @endExample
4630 @cindex blank line
4631 @cindex blank line macro (@code{blm})
4632 Another possibility is to use the blank line macro request @code{blm}
4633 by assigning an empty macro to it.
4635 @Example
4636 .de do-nothing
4638 .blm do-nothing  \" activate blank line macro
4640 .de foo
4641 .  tm This is foo.
4645 .de bar
4646 .  tm This is bar.
4649 .blm             \" deactivate blank line macro
4650 @endExample
4652 @xref{Blank Line Traps}.
4654 @cindex zero width space character (@code{\&})
4655 @cindex character, zero width space (@code{\&})
4656 @cindex space character, zero width (@code{\&})
4657 @cindex @code{\&}, escaping control characters
4658 To begin a line with a control character without it being interpreted,
4659 precede it with @code{\&}.  This represents a zero width space, which
4660 means it does not affect the output.
4662 In most cases the period is used as a control character.  Several
4663 requests cause a break implicitly; using the single quote control
4664 character prevents this.
4666 @menu
4667 * Request Arguments::
4668 @end menu
4670 @node Request Arguments,  , Requests, Requests
4671 @subsubsection Request Arguments
4672 @cindex request arguments
4673 @cindex arguments to requests
4675 Arguments to requests (and macros) are processed much like the shell:
4676 The line is split into arguments according to
4677 spaces.@footnote{Plan@tie{}9's @code{troff} implementation also allows
4678 tabs for argument separation -- @code{gtroff} intentionally doesn't
4679 support this.}  An argument which is intended to contain spaces can
4680 either be enclosed in double quotes, or have the spaces @dfn{escaped}
4681 with backslashes.
4683 Here are a few examples:
4685 @Example
4686 .uh The Mouse Problem
4687 .uh "The Mouse Problem"
4688 .uh The\ Mouse\ Problem
4689 @endExample
4691 @cindex @code{\~}, difference to @code{\@key{SP}}
4692 @cindex @code{\@key{SP}}, difference to @code{\~}
4693 @noindent
4694 The first line is the @code{uh} macro being called with 3 arguments,
4695 @samp{The}, @samp{Mouse}, and @samp{Problem}.  The latter two have the
4696 same effect of calling the @code{uh} macro with one argument, @samp{The
4697 Mouse Problem}.@footnote{The last solution, i.e., using escaped spaces,
4698 is ``classical'' in the sense that it can be found in most @code{troff}
4699 documents.  Nevertheless, it is not optimal in all situations, since
4700 @w{@samp{\ }} inserts a fixed-width, non-breaking space character which
4701 can't stretch.  @code{gtroff} provides a different command @code{\~} to
4702 insert a stretchable, non-breaking space.}
4704 @cindex @code{"}, in a macro argument
4705 @cindex double quote, in a macro argument
4706 A double quote which isn't preceded by a space doesn't start a macro
4707 argument.  If not closing a string, it is printed literally.
4709 For example,
4711 @Example
4712 .xxx a" "b c" "de"fg"
4713 @endExample
4715 @noindent
4716 has the arguments @samp{a"}, @w{@samp{b c}}, @samp{de}, and @samp{fg"}.
4717 Don't rely on this obscure behaviour!
4719 There are two possibilities to get a double quote reliably.
4721 @itemize @bullet
4722 @item
4723 Enclose the whole argument with double quotes and use two consecutive double
4724 quotes to represent a single one.  This traditional solution has the
4725 disadvantage that double quotes don't survive argument expansion again if
4726 called in compatibility mode (using the @option{-C} option of @code{groff}):
4728 @Example
4729 .de xx
4730 .  tm xx: `\\$1' `\\$2' `\\$3'
4732 .  yy "\\$1" "\\$2" "\\$3"
4734 .de yy
4735 .  tm yy: `\\$1' `\\$2' `\\$3'
4737 .xx A "test with ""quotes""" .
4738     @result{} xx: `A' `test with "quotes"' `.'
4739     @result{} yy: `A' `test with ' `quotes""'
4740 @endExample
4742 @noindent
4743 If not in compatibility mode, you get the expected result
4745 @Example
4746 xx: `A' `test with "quotes"' `.'
4747 yy: `A' `test with "quotes"' `.'
4748 @endExample
4750 @noindent
4751 since @code{gtroff} preserves the input level.
4753 @item
4754 Use the double quote glyph @code{\(dq}.  This works with and without
4755 compatibility mode enabled since @code{gtroff} doesn't convert @code{\(dq}
4756 back to a double quote input character.
4758 Not that this method won't work with @acronym{UNIX} @code{troff} in general
4759 since the glyph `dq' isn't defined normally.
4760 @end itemize
4762 @cindex @code{ds} request, and double quotes
4763 Double quotes in the @code{ds} request are handled differently.
4764 @xref{Strings}, for more details.
4766 @c ---------------------------------------------------------------------
4768 @node Macros, Escapes, Requests, Embedded Commands
4769 @subsection Macros
4770 @cindex macros
4772 @code{gtroff} has a @dfn{macro} facility for defining a series of lines
4773 which can be invoked by name.  They are called in the same manner as
4774 requests -- arguments also may be passed in the same manner.
4776 @xref{Writing Macros}, and @ref{Request Arguments}.
4778 @c ---------------------------------------------------------------------
4780 @node Escapes,  , Macros, Embedded Commands
4781 @subsection Escapes
4782 @cindex escapes
4784 Escapes may occur anywhere in the input to @code{gtroff}.  They usually
4785 begin with a backslash and are followed by a single character which
4786 indicates the function to be performed.  The escape character can be
4787 changed; see @ref{Character Translations}.
4789 Escape sequences which require an identifier as a parameter accept three
4790 possible syntax forms.
4792 @itemize @bullet
4793 @item
4794 The next single character is the identifier.
4796 @cindex @code{(}, starting a two-character identifier
4797 @item
4798 If this single character is an opening parenthesis, take the following
4799 two characters as the identifier.  Note that there is no closing
4800 parenthesis after the identifier.
4802 @cindex @code{[}, starting an identifier
4803 @cindex @code{]}, ending an identifier
4804 @item
4805 If this single character is an opening bracket, take all characters
4806 until a closing bracket as the identifier.
4807 @end itemize
4809 @noindent
4810 Examples:
4812 @Example
4814 \n(XX
4815 \*[TeX]
4816 @endExample
4818 @cindex @code{'}, delimiting arguments
4819 @cindex argument delimiting characters
4820 @cindex characters, argument delimiting
4821 @cindex delimiting characters for arguments
4822 Other escapes may require several arguments and/or some special format.
4823 In such cases the argument is traditionally enclosed in single quotes
4824 (and quotes are always used in this manual for the definitions of escape
4825 sequences).  The enclosed text is then processed according to what that
4826 escape expects.  Example:
4828 @Example
4829 \l'1.5i\(bu'
4830 @endExample
4832 @cindex @code{\o}, possible quote characters
4833 @cindex @code{\b}, possible quote characters
4834 @cindex @code{\X}, possible quote characters
4835 Note that the quote character can be replaced with any other character
4836 which does not occur in the argument (even a newline or a space
4837 character) in the following escapes: @code{\o}, @code{\b}, and
4838 @code{\X}.  This makes e.g.
4840 @Example
4841 A caf
4846 in Paris
4847   @result{} A caf@'e in Paris
4848 @endExample
4850 @noindent
4851 possible, but it is better not to use this feature to avoid confusion.
4853 @cindex @code{\%}, used as delimiter
4854 @cindex @code{\@key{SP}}, used as delimiter
4855 @cindex @code{\|}, used as delimiter
4856 @cindex @code{\^}, used as delimiter
4857 @cindex @code{\@{}, used as delimiter
4858 @cindex @code{\@}}, used as delimiter
4859 @cindex @code{\'}, used as delimiter
4860 @cindex @code{\`}, used as delimiter
4861 @cindex @code{\-}, used as delimiter
4862 @cindex @code{\_}, used as delimiter
4863 @cindex @code{\!}, used as delimiter
4864 @cindex @code{\?}, used as delimiter
4865 @cindex @code{\@@}, used as delimiter
4866 @cindex @code{\)}, used as delimiter
4867 @cindex @code{\/}, used as delimiter
4868 @cindex @code{\,}, used as delimiter
4869 @cindex @code{\&}, used as delimiter
4870 @ifnotinfo
4871 @cindex @code{\:}, used as delimiter
4872 @end ifnotinfo
4873 @ifinfo
4874 @cindex @code{\@r{<colon>}}, used as delimiter
4875 @end ifinfo
4876 @cindex @code{\~}, used as delimiter
4877 @cindex @code{\0}, used as delimiter
4878 @cindex @code{\a}, used as delimiter
4879 @cindex @code{\c}, used as delimiter
4880 @cindex @code{\d}, used as delimiter
4881 @cindex @code{\e}, used as delimiter
4882 @cindex @code{\E}, used as delimiter
4883 @cindex @code{\p}, used as delimiter
4884 @cindex @code{\r}, used as delimiter
4885 @cindex @code{\t}, used as delimiter
4886 @cindex @code{\u}, used as delimiter
4887 The following escapes sequences (which are handled similarly to
4888 characters since they don't take a parameter) are also allowed as
4889 delimiters: @code{\%}, @w{@samp{\ }}, @code{\|}, @code{\^}, @code{\@{},
4890 @code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
4891 @code{\?}, @code{\@@}, @code{\)}, @code{\/}, @code{\,}, @code{\&},
4892 @code{\:}, @code{\~}, @code{\0}, @code{\a}, @code{\c}, @code{\d},
4893 @code{\e}, @code{\E}, @code{\p}, @code{\r}, @code{\t}, and @code{\u}.
4894 Again, don't use these if possible.
4896 @cindex @code{\A}, allowed delimiters
4897 @cindex @code{\B}, allowed delimiters
4898 @cindex @code{\Z}, allowed delimiters
4899 @cindex @code{\C}, allowed delimiters
4900 @cindex @code{\w}, allowed delimiters
4901 No newline characters as delimiters are allowed in the following
4902 escapes: @code{\A}, @code{\B}, @code{\Z}, @code{\C}, and @code{\w}.
4904 @cindex @code{\D}, allowed delimiters
4905 @cindex @code{\h}, allowed delimiters
4906 @cindex @code{\H}, allowed delimiters
4907 @cindex @code{\l}, allowed delimiters
4908 @cindex @code{\L}, allowed delimiters
4909 @cindex @code{\N}, allowed delimiters
4910 @cindex @code{\R}, allowed delimiters
4911 @cindex @code{\s}, allowed delimiters
4912 @cindex @code{\S}, allowed delimiters
4913 @cindex @code{\v}, allowed delimiters
4914 @cindex @code{\x}, allowed delimiters
4915 Finally, the escapes @code{\D}, @code{\h}, @code{\H}, @code{\l},
4916 @code{\L}, @code{\N}, @code{\R}, @code{\s}, @code{\S}, @code{\v},
4917 and @code{\x} can't use the following characters as delimiters:
4919 @itemize @bullet
4920 @item
4921 @cindex numbers, and delimiters
4922 @cindex digits, and delimiters
4923 The digits @code{0}-@code{9}.
4925 @item
4926 @cindex operators, as delimiters
4927 @cindex @code{+}, as delimiter
4928 @cindex @code{-}, as delimiter
4929 @cindex @code{/}, as delimiter
4930 @cindex @code{*}, as delimiter
4931 @cindex @code{%}, as delimiter
4932 @cindex @code{<}, as delimiter
4933 @cindex @code{>}, as delimiter
4934 @cindex @code{=}, as delimiter
4935 @cindex @code{&}, as delimiter
4936 @ifnotinfo
4937 @cindex @code{:}, as delimiter
4938 @end ifnotinfo
4939 @ifinfo
4940 @cindex <colon>, as delimiter
4941 @end ifinfo
4942 @cindex @code{(}, as delimiter
4943 @cindex @code{)}, as delimiter
4944 @cindex @code{.}, as delimiter
4945 The (single-character) operators @samp{+-/*%<>=&:().}.
4947 @item
4948 @cindex space character
4949 @cindex character, space
4950 @cindex tab character
4951 @cindex character, tab
4952 @cindex newline character
4953 @cindex character, newline
4954 The space, tab, and newline characters.
4956 @item
4957 @cindex @code{\%}, used as delimiter
4958 @ifnotinfo
4959 @cindex @code{\:}, used as delimiter
4960 @end ifnotinfo
4961 @ifinfo
4962 @cindex @code{\@r{<colon>}}, used as delimiter
4963 @end ifinfo
4964 @cindex @code{\@{}, used as delimiter
4965 @cindex @code{\@}}, used as delimiter
4966 @cindex @code{\'}, used as delimiter
4967 @cindex @code{\`}, used as delimiter
4968 @cindex @code{\-}, used as delimiter
4969 @cindex @code{\_}, used as delimiter
4970 @cindex @code{\!}, used as delimiter
4971 @cindex @code{\@@}, used as delimiter
4972 @cindex @code{\/}, used as delimiter
4973 @cindex @code{\c}, used as delimiter
4974 @cindex @code{\e}, used as delimiter
4975 @cindex @code{\p}, used as delimiter
4976 All escape sequences except @code{\%}, @code{\:}, @code{\@{}, @code{\@}},
4977 @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!}, @code{\@@},
4978 @code{\/}, @code{\c}, @code{\e}, and @code{\p}.
4979 @end itemize
4981 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
4982 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
4983 To have a backslash (actually, the current escape character) appear in the
4984 output several escapes are defined: @code{\\}, @code{\e} or @code{\E}.
4985 These are very similar, and only differ with respect to being used in
4986 macros or diversions.  @xref{Character Translations}, for an exact
4987 description of those escapes.
4989 @xref{Implementation Differences}, @ref{Copy-in Mode}, and @ref{Diversions},
4990 @ref{Identifiers}, for more information.
4992 @menu
4993 * Comments::
4994 @end menu
4996 @node Comments,  , Escapes, Escapes
4997 @subsubsection Comments
4998 @cindex comments
5000 Probably one of the most@footnote{Unfortunately, this is a lie.  But
5001 hopefully future @code{gtroff} hackers will believe it @code{:-)}}
5002 common forms of escapes is the comment.
5004 @Defesc {\\", , , }
5005 Start a comment.  Everything to the end of the input line is ignored.
5007 This may sound simple, but it can be tricky to keep the comments from
5008 interfering with the appearance of the final output.
5010 @cindex @code{ds}, @code{ds1} requests, and comments
5011 @cindex @code{as}, @code{as1} requests, and comments
5012 If the escape is to the right of some text or a request, that portion
5013 of the line is ignored, but the space leading up to it is noticed by
5014 @code{gtroff}.  This only affects the @code{ds} and @code{as}
5015 request and its variants.
5017 @cindex tabs, before comments
5018 @cindex comments, lining up with tabs
5019 One possibly irritating idiosyncracy is that tabs must not be used to
5020 line up comments.  Tabs are not treated as whitespace between the
5021 request and macro arguments.
5023 @cindex undefined request
5024 @cindex request, undefined
5025 A comment on a line by itself is treated as a blank line, because
5026 after eliminating the comment, that is all that remains:
5028 @Example
5029 Test
5030 \" comment
5031 Test
5032 @endExample
5034 @noindent
5035 produces
5037 @Example
5038 Test
5040 Test
5041 @endExample
5043 To avoid this, it is common to start the line with @code{.\"} which
5044 causes the line to be treated as an undefined request and thus ignored
5045 completely.
5047 @cindex @code{'}, as a comment
5048 Another commenting scheme seen sometimes is three consecutive single
5049 quotes (@code{'''}) at the beginning of a line.  This works, but
5050 @code{gtroff} gives a warning about an undefined macro (namely
5051 @code{''}), which is harmless, but irritating.
5052 @endDefesc
5054 @Defesc {\\#, , , }
5055 To avoid all this, @code{gtroff} has a new comment mechanism using the
5056 @code{\#} escape.  This escape works the same as @code{\"} except that
5057 the newline is also ignored:
5059 @Example
5060 Test
5061 \# comment
5062 Test
5063 @endExample
5065 @noindent
5066 produces
5068 @Example
5069 Test Test
5070 @endExample
5072 @noindent
5073 as expected.
5074 @endDefesc
5076 @Defreq {ig, [@Var{end}]}
5077 Ignore all input until @code{gtroff} encounters the macro named
5078 @code{.}@var{end} on a line by itself (or @code{..} if @var{end} is not
5079 specified).  This is useful for commenting out large blocks of text:
5081 @Example
5082 text text text...
5084 This is part of a large block
5085 of text that has been
5086 temporarily(?) commented out.
5088 We can restore it simply by removing
5089 the .ig request and the ".." at the
5090 end of the block.
5092 More text text text...
5093 @endExample
5095 @noindent
5096 produces
5098 @Example
5099 text text text@dots{}  More text text text@dots{}
5100 @endExample
5102 @noindent
5103 Note that the commented-out block of text does not
5104 cause a break.
5106 The input is read in copy-mode; auto-incremented registers @emph{are}
5107 affected (@pxref{Auto-increment}).
5108 @endDefreq
5111 @c =====================================================================
5113 @node Registers, Manipulating Filling and Adjusting, Embedded Commands, gtroff Reference
5114 @section Registers
5115 @cindex registers
5117 Numeric variables in @code{gtroff} are called @dfn{registers}.  There
5118 are a number of built-in registers, supplying anything from the date to
5119 details of formatting parameters.
5121 @xref{Identifiers}, for details on register identifiers.
5123 @menu
5124 * Setting Registers::
5125 * Interpolating Registers::
5126 * Auto-increment::
5127 * Assigning Formats::
5128 * Built-in Registers::
5129 @end menu
5131 @c ---------------------------------------------------------------------
5133 @node Setting Registers, Interpolating Registers, Registers, Registers
5134 @subsection Setting Registers
5135 @cindex setting registers (@code{nr}, @code{\R})
5136 @cindex registers, setting (@code{nr}, @code{\R})
5138 Define or set registers using the @code{nr} request or the
5139 @code{\R} escape.
5141 @DefreqList {nr, ident value}
5142 @DefescListEnd {\\R, ', ident value, '}
5143 Set number register @var{ident} to @var{value}.  If @var{ident}
5144 doesn't exist, @code{gtroff} creates it.
5146 The argument to @code{\R} usually has to be enclosed in quotes.
5147 @xref{Escapes}, for details on parameter delimiting characters.
5149 The @code{\R} escape doesn't produce an input token in @code{gtroff};
5150 with other words, it vanishes completely after @code{gtroff} has
5151 processed it.
5152 @endDefreq
5154 For example, the following two lines are equivalent:
5156 @Example
5157 .nr a (((17 + (3 * 4))) % 4)
5158 \R'a (((17 + (3 * 4))) % 4)'
5159     @result{} 1
5160 @endExample
5162 Both @code{nr} and @code{\R} have two additional special forms to
5163 increment or decrement a register.
5165 @DefreqList {nr, ident @t{+}@Var{value}}
5166 @DefreqItem {nr, ident @t{-}@Var{value}}
5167 @DefescItem {\\R, ', ident @t{+}@Var{value}, '}
5168 @DefescListEnd {\\R, ', ident @t{-}@Var{value}, '}
5169 Increment (decrement) register @var{ident} by @var{value}.
5171 @Example
5172 .nr a 1
5173 .nr a +1
5175     @result{} 2
5176 @endExample
5178 @cindex negating register values
5179 To assign the negated value of a register to another register, some care
5180 must be taken to get the desired result:
5182 @Example
5183 .nr a 7
5184 .nr b 3
5185 .nr a -\nb
5187     @result{} 4
5188 .nr a (-\nb)
5190     @result{} -3
5191 @endExample
5193 @noindent
5194 The surrounding parentheses prevent the interpretation of the minus sign
5195 as a decrementing operator.  An alternative is to start the assignment
5196 with a @samp{0}:
5198 @Example
5199 .nr a 7
5200 .nr b -3
5201 .nr a \nb
5203     @result{} 4
5204 .nr a 0\nb
5206     @result{} -3
5207 @endExample
5208 @endDefreq
5210 @Defreq {rr, ident}
5211 @cindex removing number register (@code{rr})
5212 @cindex number register, removing (@code{rr})
5213 @cindex register, removing (@code{rr})
5214 Remove number register @var{ident}.  If @var{ident} doesn't exist, the
5215 request is ignored.
5216 @endDefreq
5218 @Defreq {rnn, ident1 ident2}
5219 @cindex renaming number register (@code{rnn})
5220 @cindex number register, renaming (@code{rnn})
5221 @cindex register, renaming (@code{rnn})
5222 Rename number register @var{ident1} to @var{ident2}.  If either
5223 @var{ident1} or @var{ident2} doesn't exist, the request is ignored.
5224 @endDefreq
5226 @Defreq {aln, ident1 ident2}
5227 @cindex alias, number register, creating (@code{aln})
5228 @cindex creating alias, for number register (@code{aln})
5229 @cindex number register, creating alias (@code{aln})
5230 @cindex register, creating alias (@code{aln})
5231 Create an alias @var{ident1} for a number register @var{ident2}.  The
5232 new name and the old name are exactly equivalent.  If @var{ident1} is
5233 undefined, a warning of type @samp{reg} is generated, and the request
5234 is ignored.  @xref{Debugging}, for information about warnings.
5235 @endDefreq
5237 @c ---------------------------------------------------------------------
5239 @node Interpolating Registers, Auto-increment, Setting Registers, Registers
5240 @subsection Interpolating Registers
5241 @cindex interpolating registers (@code{\n})
5242 @cindex registers, interpolating (@code{\n})
5244 Numeric registers can be accessed via the @code{\n} escape.
5246 @DefescList {\\n, , i, }
5247 @DefescItem {\\n, @lparen{}, id, }
5248 @DefescListEnd {\\n, @lbrack{}, ident, @rbrack}
5249 @cindex nested assignments
5250 @cindex assignments, nested
5251 @cindex indirect assignments
5252 @cindex assignments, indirect
5253 Interpolate number register with name @var{ident} (one-character
5254 name@tie{}@var{i}, two-character name @var{id}).  This means that the value
5255 of the register is expanded in-place while @code{gtroff} is parsing the
5256 input line.  Nested assignments (also called indirect assignments) are
5257 possible.
5259 @Example
5260 .nr a 5
5261 .nr as \na+\na
5262 \n(as
5263     @result{} 10
5264 @endExample
5266 @Example
5267 .nr a1 5
5268 .nr ab 6
5269 .ds str b
5270 .ds num 1
5271 \n[a\n[num]]
5272     @result{} 5
5273 \n[a\*[str]]
5274     @result{} 6
5275 @endExample
5276 @endDefesc
5278 @c ---------------------------------------------------------------------
5280 @node Auto-increment, Assigning Formats, Interpolating Registers, Registers
5281 @subsection Auto-increment
5282 @cindex auto-increment
5283 @cindex increment, automatic
5285 Number registers can also be auto-incremented and auto-decremented.
5286 The increment or decrement value can be specified with a third
5287 argument to the @code{nr} request or @code{\R} escape.
5289 @Defreq {nr, ident value incr}
5290 @cindex @code{\R}, difference to @code{nr}
5291 Set number register @var{ident} to @var{value}; the increment for
5292 auto-incrementing is set to @var{incr}.  Note that the @code{\R}
5293 escape doesn't support this notation.
5294 @endDefreq
5296 To activate auto-incrementing, the escape @code{\n} has a special
5297 syntax form.
5299 @DefescList {\\n, +, i, }
5300 @DefescItem {\\n, -, i, }
5301 @DefescItem {\\n, @lparen{}+, id, }
5302 @DefescItem {\\n, @lparen{}-, id, }
5303 @DefescItem {\\n, +@lparen{}, id, }
5304 @DefescItem {\\n, -@lparen{}, id, }
5305 @DefescItem {\\n, @lbrack{}+, ident, @rbrack{}}
5306 @DefescItem {\\n, @lbrack{}-, ident, @rbrack{}}
5307 @DefescItem {\\n, +@lbrack{}, ident, @rbrack{}}
5308 @DefescListEnd {\\n, -@lbrack{}, ident, @rbrack{}}
5309 Before interpolating, increment or decrement @var{ident}
5310 (one-character name@tie{}@var{i}, two-character name @var{id}) by the
5311 auto-increment value as specified with the @code{nr} request (or the
5312 @code{\R} escape).  If no auto-increment value has been specified,
5313 these syntax forms are identical to @code{\n}.
5314 @endDefesc
5316 For example,
5318 @Example
5319 .nr a 0 1
5320 .nr xx 0 5
5321 .nr foo 0 -2
5322 \n+a, \n+a, \n+a, \n+a, \n+a
5324 \n-(xx, \n-(xx, \n-(xx, \n-(xx, \n-(xx
5326 \n+[foo], \n+[foo], \n+[foo], \n+[foo], \n+[foo]
5327 @endExample
5329 @noindent
5330 produces
5332 @Example
5333 1, 2, 3, 4, 5
5334 -5, -10, -15, -20, -25
5335 -2, -4, -6, -8, -10
5336 @endExample
5338 @cindex increment value without changing the register
5339 @cindex value, incrementing without changing the register
5340 To change the increment value without changing the value of a register
5341 (@var{a} in the example), the following can be used:
5343 @Example
5344 .nr a \na 10
5345 @endExample
5347 @c ---------------------------------------------------------------------
5349 @node Assigning Formats, Built-in Registers, Auto-increment, Registers
5350 @subsection Assigning Formats
5351 @cindex assigning formats (@code{af})
5352 @cindex formats, assigning (@code{af})
5354 When a register is used in the text of an input file (as opposed to
5355 part of an expression), it is textually replaced (or interpolated)
5356 with a representation of that number.  This output format can be
5357 changed to a variety of formats (numbers, Roman numerals, etc.).  This
5358 is done using the @code{af} request.
5360 @Defreq {af, ident format}
5361 Change the output format of a number register.  The first argument
5362 @var{ident} is the name of the number register to be changed, and the
5363 second argument @var{format} is the output format.  The following
5364 output formats are available:
5366 @table @code
5367 @item 1
5368 Decimal arabic numbers.  This is the default format: 0, 1, 2,
5369 3,@tie{}@enddots{}
5371 @item 0@dots{}0
5372 Decimal numbers with as many digits as specified.  So, @samp{00} would
5373 result in printing numbers as 01, 02, 03,@tie{}@enddots{}
5375 In fact, any digit instead of zero will do; @code{gtroff} only counts
5376 how many digits are specified.  As a consequence, @code{af}'s default
5377 format @samp{1} could be specified as @samp{0} also (and exactly this is
5378 returned by the @code{\g} escape, see below).
5380 @item I
5381 @cindex Roman numerals
5382 @cindex numerals, Roman
5383 Upper-case Roman numerals: 0, I, II, III, IV,@tie{}@enddots{}
5385 @item i
5386 Lower-case Roman numerals: 0, i, ii, iii, iv,@tie{}@enddots{}
5388 @item A
5389 Upper-case letters: 0, A, B, C, @dots{},@tie{}Z, AA, AB,@tie{}@enddots{}
5391 @item a
5392 Lower-case letters: 0, a, b, c, @dots{},@tie{}z, aa, ab,@tie{}@enddots{}
5393 @end table
5395 Omitting the number register format causes a warning of type
5396 @samp{missing}.  @xref{Debugging}, for more details.  Specifying a
5397 nonexistent format causes an error.
5399 The following example produces @samp{10, X, j, 010}:
5401 @Example
5402 .nr a 10
5403 .af a 1           \" the default format
5404 \na,
5405 .af a I
5406 \na,
5407 .af a a
5408 \na,
5409 .af a 001
5411 @endExample
5413 @cindex Roman numerals, maximum and minimum
5414 @cindex maximum values of Roman numerals
5415 @cindex minimum values of Roman numerals
5416 The largest number representable for the @samp{i} and @samp{I} formats
5417 is 39999 (or @minus{}39999); @acronym{UNIX} @code{troff} uses @samp{z}
5418 and @samp{w} to represent 10000 and 5000 in Roman numerals, and so does
5419 @code{gtroff}.  Currently, the correct glyphs of Roman numeral five
5420 thousand and Roman numeral ten thousand (Unicode code points
5421 @code{U+2182} and @code{U+2181}, respectively) are not available.
5423 If @var{ident} doesn't exist, it is created.
5425 @cindex read-only register, changing format
5426 @cindex changing format, and read-only registers
5427 Changing the output format of a read-only register causes an error.  It
5428 is necessary to first copy the register's value to a writeable register,
5429 then apply the @code{af} request to this other register.
5430 @endDefreq
5432 @DefescList {\\g, , i, }
5433 @DefescItem {\\g, @lparen{}, id, }
5434 @DefescListEnd {\\g, @lbrack{}, ident, @rbrack{}}
5435 @cindex format of register (@code{\g})
5436 @cindex register, format (@code{\g})
5437 Return the current format of the specified register @var{ident}
5438 (one-character name@tie{}@var{i}, two-character name @var{id}).  For
5439 example, @samp{\ga} after the previous example would produce the
5440 string @samp{000}.  If the register hasn't been defined yet, nothing
5441 is returned.
5442 @endDefesc
5444 @c ---------------------------------------------------------------------
5446 @node Built-in Registers,  , Assigning Formats, Registers
5447 @subsection Built-in Registers
5448 @cindex built-in registers
5449 @cindex registers, built-in
5451 The following lists some built-in registers which are not described
5452 elsewhere in this manual.  Any register which begins with a @samp{.} is
5453 read-only.  A complete listing of all built-in registers can be found in
5454 appendix@tie{}@ref{Register Index}.
5456 @table @code
5457 @item .F
5458 @cindex current input file name register (@code{.F})
5459 @cindex input file name, current, register (@code{.F})
5460 @vindex .F
5461 This string-valued register returns the current input file name.
5463 @item .H
5464 @cindex horizontal resolution register (@code{.H})
5465 @cindex resolution, horizontal, register (@code{.H})
5466 @vindex .H
5467 Horizontal resolution in basic units.
5469 @item .V
5470 @cindex vertical resolution register (@code{.V})
5471 @cindex resolution, vertical, register (@code{.V})
5472 @vindex .V
5473 Vertical resolution in basic units.
5475 @item seconds
5476 @cindex seconds, current time (@code{seconds})
5477 @cindex time, current, seconds (@code{seconds})
5478 @cindex current time, seconds (@code{seconds})
5479 @vindex seconds
5480 The number of seconds after the minute, normally in the range@tie{}0
5481 to@tie{}59, but can be up to@tie{}61 to allow for leap seconds.  Initialized
5482 at start-up of @code{gtroff}.
5484 @item minutes
5485 @cindex minutes, current time (@code{minutes})
5486 @cindex time, current, minutes (@code{minutes})
5487 @cindex current time, minutes (@code{minutes})
5488 @vindex minutes
5489 The number of minutes after the hour, in the range@tie{}0 to@tie{}59.
5490 Initialized at start-up of @code{gtroff}.
5492 @item hours
5493 @cindex hours, current time (@code{hours})
5494 @cindex time, current, hours (@code{hours})
5495 @cindex current time, hours (@code{hours})
5496 @vindex hours
5497 The number of hours past midnight, in the range@tie{}0 to@tie{}23.
5498 Initialized at start-up of @code{gtroff}.
5500 @item dw
5501 @cindex day of the week register (@code{dw})
5502 @cindex date, day of the week register (@code{dw})
5503 @vindex dw
5504 Day of the week (1-7).
5506 @item dy
5507 @cindex day of the month register (@code{dy})
5508 @cindex date, day of the month register (@code{dy})
5509 @vindex dy
5510 Day of the month (1-31).
5512 @item mo
5513 @cindex month of the year register (@code{mo})
5514 @cindex date, month of the year register (@code{mo})
5515 @vindex mo
5516 Current month (1-12).
5518 @item year
5519 @cindex date, year register (@code{year}, @code{yr})
5520 @cindex year, current, register (@code{year}, @code{yr})
5521 @vindex year
5522 The current year.
5524 @item yr
5525 @vindex yr
5526 The current year minus@tie{}1900.  Unfortunately, the documentation of
5527 @acronym{UNIX} Version@tie{}7's @code{troff} had a year@tie{}2000 bug: It
5528 incorrectly claimed that @code{yr} contains the last two digits of the
5529 year.  That claim has never been true of either @acronym{AT&T}
5530 @code{troff} or GNU @code{troff}.  Old @code{troff} input that looks
5531 like this:
5533 @Example
5534 '\" The following line stopped working after 1999
5535 This document was formatted in 19\n(yr.
5536 @endExample
5538 @noindent
5539 can be corrected as follows:
5541 @Example
5542 This document was formatted in \n[year].
5543 @endExample
5545 @noindent
5546 or, to be portable to older @code{troff} versions, as follows:
5548 @Example
5549 .nr y4 1900+\n(yr
5550 This document was formatted in \n(y4.
5551 @endExample
5553 @item .c
5554 @vindex .c
5555 @itemx c.
5556 @vindex c.
5557 @cindex input line number register (@code{.c}, @code{c.})
5558 @cindex line number, input, register (@code{.c}, @code{c.})
5559 The current @emph{input} line number.  Register @samp{.c} is read-only,
5560 whereas @samp{c.} (a @code{gtroff} extension) is writable also,
5561 affecting both @samp{.c} and @samp{c.}.
5563 @item ln
5564 @vindex ln
5565 @cindex output line number register (@code{ln})
5566 @cindex line number, output, register (@code{ln})
5567 The current @emph{output} line number after a call to the @code{nm}
5568 request to activate line numbering.
5570 @xref{Miscellaneous}, for more information about line numbering.
5572 @item .x
5573 @vindex .x
5574 @cindex major version number register (@code{.x})
5575 @cindex version number, major, register (@code{.x})
5576 The major version number.  For example, if the version number
5577 is 1.03 then @code{.x} contains@tie{}@samp{1}.
5579 @item .y
5580 @vindex .y
5581 @cindex minor version number register (@code{.y})
5582 @cindex version number, minor, register (@code{.y})
5583 The minor version number.  For example, if the version number
5584 is 1.03 then @code{.y} contains@tie{}@samp{03}.
5586 @item .Y
5587 @vindex .Y
5588 @cindex revision number register (@code{.Y})
5589 The revision number of @code{groff}.
5591 @item $$
5592 @vindex $$
5593 @cindex process ID of @code{gtroff} register (@code{$$})
5594 @cindex @code{gtroff}, process ID register (@code{$$})
5595 The process ID of @code{gtroff}.
5597 @item .g
5598 @vindex .g
5599 @cindex @code{gtroff}, identification register (@code{.g})
5600 @cindex GNU-specific register (@code{.g})
5601 Always@tie{}1.  Macros should use this to determine whether they are
5602 running under GNU @code{troff}.
5604 @item .A
5605 @vindex .A
5606 @cindex @acronym{ASCII} approximation output register (@code{.A})
5607 If the command line option @option{-a} is used to produce an
5608 @acronym{ASCII} approximation of the output, this is set to@tie{}1, zero
5609 otherwise.  @xref{Groff Options}.
5611 @item .P
5612 @vindex .P
5613 This register is set to@tie{}1 (and to@tie{}0 otherwise) if the current
5614 page is actually being printed, i.e., if the @option{-o} option is being
5615 used to only print selected pages.  @xref{Groff Options}, for more
5616 information.
5618 @item .T
5619 @vindex .T
5620 If @code{gtroff} is called with the @option{-T} command line option, the
5621 number register @code{.T} is set to@tie{}1, and zero otherwise.
5622 @xref{Groff Options}.
5624 @stindex .T
5625 @cindex output device name string register (@code{.T})
5626 Additionally, @code{gtroff} predefines a single read-write string
5627 register @code{.T} which contains the current output device (for
5628 example, @samp{latin1} or @samp{ps}).
5629 @end table
5632 @c =====================================================================
5634 @node Manipulating Filling and Adjusting, Manipulating Hyphenation, Registers, gtroff Reference
5635 @section Manipulating Filling and Adjusting
5636 @cindex manipulating filling and adjusting
5637 @cindex filling and adjusting, manipulating
5638 @cindex adjusting and filling, manipulating
5639 @cindex justifying text
5640 @cindex text, justifying
5642 @cindex break
5643 @cindex line break
5644 @cindex @code{bp} request, causing implicit linebreak
5645 @cindex @code{ce} request, causing implicit linebreak
5646 @cindex @code{cf} request, causing implicit linebreak
5647 @cindex @code{fi} request, causing implicit linebreak
5648 @cindex @code{fl} request, causing implicit linebreak
5649 @cindex @code{in} request, causing implicit linebreak
5650 @cindex @code{nf} request, causing implicit linebreak
5651 @cindex @code{rj} request, causing implicit linebreak
5652 @cindex @code{sp} request, causing implicit linebreak
5653 @cindex @code{ti} request, causing implicit linebreak
5654 @cindex @code{trf} request, causing implicit linebreak
5655 Various ways of causing @dfn{breaks} were given in @ref{Implicit Line
5656 Breaks}.  The @code{br} request likewise causes a break.  Several
5657 other requests also cause breaks, but implicitly.  These are
5658 @code{bp}, @code{ce}, @code{cf}, @code{fi}, @code{fl}, @code{in},
5659 @code{nf}, @code{rj}, @code{sp}, @code{ti}, and @code{trf}.
5661 @Defreq {br, }
5662 Break the current line, i.e., the input collected so far is emitted
5663 without adjustment.
5665 If the no-break control character is used, @code{gtroff} suppresses
5666 the break:
5668 @Example
5672     @result{} a b
5673 @endExample
5674 @endDefreq
5676 Initially, @code{gtroff} fills and adjusts text to both margins.
5677 Filling can be disabled via the @code{nf} request and re-enabled with
5678 the @code{fi} request.
5680 @DefreqList {fi, }
5681 @DefregListEnd {.u}
5682 @cindex fill mode (@code{fi})
5683 @cindex mode, fill (@code{fi})
5684 Activate fill mode (which is the default).  This request implicitly
5685 enables adjusting; it also inserts a break in the text currently being
5686 filled.  The read-only number register @code{.u} is set to@tie{}1.
5688 The fill mode status is associated with the current environment
5689 (@pxref{Environments}).
5691 See @ref{Line Control}, for interaction with the @code{\c} escape.
5692 @endDefreq
5694 @Defreq {nf, }
5695 @cindex no-fill mode (@code{nf})
5696 @cindex mode, no-fill (@code{nf})
5697 Activate no-fill mode.  Input lines are output as-is, retaining line
5698 breaks and ignoring the current line length.  This command implicitly
5699 disables adjusting; it also causes a break.  The number register
5700 @code{.u} is set to@tie{}0.
5702 The fill mode status is associated with the current environment
5703 (@pxref{Environments}).
5705 See @ref{Line Control}, for interaction with the @code{\c} escape.
5706 @endDefreq
5708 @DefreqList {ad, [@Var{mode}]}
5709 @DefregListEnd {.j}
5710 Set adjusting mode.
5712 Activation and deactivation of adjusting is done implicitly with
5713 calls to the @code{fi} or @code{nf} requests.
5715 @var{mode} can have one of the following values:
5717 @table @code
5718 @item l
5719 @cindex ragged-right
5720 Adjust text to the left margin.  This produces what is traditionally
5721 called ragged-right text.
5723 @item r
5724 @cindex ragged-left
5725 Adjust text to the right margin, producing ragged-left text.
5727 @item c
5728 @cindex centered text
5729 @cindex @code{ce} request, difference to @samp{.ad@tie{}c}
5730 Center filled text.  This is different to the @code{ce} request which
5731 only centers text without filling.
5733 @item b
5734 @itemx n
5735 Justify to both margins.  This is the default used by @code{gtroff}.
5736 @end table
5738 Finally, @var{mode} can be the numeric argument returned by the @code{.j}
5739 register.
5741 With no argument, @code{gtroff} adjusts lines in the same way it did
5742 before adjusting was deactivated (with a call to @code{na}, for
5743 example).
5745 @Example
5746 text
5747 .ad r
5748 .nr ad \n[.j]
5749 text
5750 .ad c
5751 text
5753 text
5754 .ad         \" back to centering
5755 text
5756 .ad \n[ad]  \" back to right justifying
5757 @endExample
5759 @cindex adjustment mode register (@code{.j})
5760 The current adjustment mode is available in the read-only number
5761 register @code{.j}; it can be stored and subsequently used to set
5762 adjustment.
5764 The adjustment mode status is associated with the current environment
5765 (@pxref{Environments}).
5766 @endDefreq
5768 @Defreq {na, }
5769 Disable adjusting.  This request won't change the current adjustment
5770 mode: A subsequent call to @code{ad} uses the previous adjustment
5771 setting.
5773 The adjustment mode status is associated with the current environment
5774 (@pxref{Environments}).
5775 @endDefreq
5777 @DefreqList {brp, }
5778 @DefescListEnd {\\p, , , }
5779 Adjust the current line and cause a break.
5781 In most cases this produces very ugly results since @code{gtroff}
5782 doesn't have a sophisticated paragraph building algorithm (as @TeX{}
5783 have, for example); instead, @code{gtroff} fills and adjusts a paragraph
5784 line by line:
5786 @Example
5787   This is an uninteresting sentence.
5788   This is an uninteresting sentence.\p
5789   This is an uninteresting sentence.
5790 @endExample
5792 @noindent
5793 is formatted as
5795 @Example
5796   This is  an uninteresting  sentence.   This  is an
5797   uninteresting                            sentence.
5798   This is an uninteresting sentence.
5799 @endExample
5800 @endDefreq
5802 @DefreqList {ss, word_space_size [@Var{sentence_space_size}]}
5803 @DefregItem {.ss}
5804 @DefregListEnd {.sss}
5805 @cindex word space size register (@code{.ss})
5806 @cindex size of word space register (@code{.ss})
5807 @cindex space between words register (@code{.ss})
5808 @cindex sentence space size register (@code{.sss})
5809 @cindex size of sentence space register (@code{.sss})
5810 @cindex space between sentences register (@code{.sss})
5811 Change the minimum size of a space between filled words.  It takes its
5812 units as one twelfth of the space width parameter for the current
5813 font.  Initially both the @var{word_space_size} and
5814 @var{sentence_space_size} are@tie{}12.
5816 @cindex fill mode
5817 @cindex mode, fill
5818 If two arguments are given to the @code{ss} request, the second
5819 argument sets the sentence space size.  If the second argument is not
5820 given, sentence space size is set to @var{word_space_size}.  The
5821 sentence space size is used in two circumstances: If the end of a
5822 sentence occurs at the end of a line in fill mode, then both an
5823 inter-word space and a sentence space are added; if two spaces follow
5824 the end of a sentence in the middle of a line, then the second space
5825 is a sentence space.  If a second argument is never given to the
5826 @code{ss} request, the behaviour of @acronym{UNIX} @code{troff} is the
5827 same as that exhibited by GNU @code{troff}.  In GNU @code{troff}, as
5828 in @acronym{UNIX} @code{troff}, a sentence should always be followed
5829 by either a newline or two spaces.
5831 The read-only number registers @code{.ss} and @code{.sss} hold the
5832 values of the parameters set by the first and second arguments of the
5833 @code{ss} request.
5835 The word space and sentence space values are associated with the current
5836 environment (@pxref{Environments}).
5838 Contrary to @acronym{AT&T} @code{troff}, this request is @emph{not}
5839 ignored if a TTY output device is used; the given values are then
5840 rounded down to a multiple of@tie{}12 (@pxref{Implementation Differences}).
5842 The request is ignored if there is no parameter.
5843 @endDefreq
5845 @DefreqList {ce, [@Var{nnn}]}
5846 @DefregListEnd {.ce}
5847 @cindex centering lines (@code{ce})
5848 @cindex lines, centering (@code{ce})
5849 Center text.  While the @w{@samp{.ad c}} request also centers text,
5850 it fills the text as well.  @code{ce} does not fill the
5851 text it affects.  This request causes a break.  The number of lines
5852 still to be centered is associated with the current environment
5853 (@pxref{Environments}).
5855 The following example demonstrates the differences.
5856 Here the input:
5858 @Example
5859 .ll 4i
5860 .ce 1000
5861 This is a small text fragment which shows the differences
5862 between the `.ce' and the `.ad c' request.
5863 .ce 0
5865 .ad c
5866 This is a small text fragment which shows the differences
5867 between the `.ce' and the `.ad c' request.
5868 @endExample
5870 @noindent
5871 And here the result:
5873 @Example
5874   This is a small text fragment which
5875          shows the differences
5876 between the `.ce' and the `.ad c' request.
5878   This is a small text fragment which
5879 shows the differences between the `.ce'
5880         and the `.ad c' request.
5881 @endExample
5883 With no arguments, @code{ce} centers the next line of text.  @var{nnn}
5884 specifies the number of lines to be centered.  If the argument is zero
5885 or negative, centering is disabled.
5887 The basic length for centering text is the line length (as set with the
5888 @code{ll} request) minus the indentation (as set with the @code{in}
5889 request).  Temporary indentation is ignored.
5891 As can be seen in the previous example, it is a common idiom to turn
5892 on centering for a large number of lines, and to turn off centering
5893 after text to be centered.  This is useful for any request which takes
5894 a number of lines as an argument.
5896 The @code{.ce} read-only number register contains the number of lines
5897 remaining to be centered, as set by the @code{ce} request.
5898 @endDefreq
5900 @DefreqList {rj, [@Var{nnn}]}
5901 @DefregListEnd {.rj}
5902 @cindex justifying text (@code{rj})
5903 @cindex text, justifying (@code{rj})
5904 @cindex right-justifying (@code{rj})
5905 Justify unfilled text to the right margin.  Arguments are identical to
5906 the @code{ce} request.  The @code{.rj} read-only number register is
5907 the number of lines to be right-justified as set by the @code{rj}
5908 request.  This request causes a break.  The number of lines still to be
5909 right-justified is associated with the current environment
5910 (@pxref{Environments}).
5911 @endDefreq
5914 @c =====================================================================
5916 @node Manipulating Hyphenation, Manipulating Spacing, Manipulating Filling and Adjusting, gtroff Reference
5917 @section Manipulating Hyphenation
5918 @cindex manipulating hyphenation
5919 @cindex hyphenation, manipulating
5921 As discussed in @ref{Hyphenation}, @code{gtroff} hyphenates words.
5922 There are a number of ways to influence hyphenation.
5924 @DefreqList {hy, [@Var{mode}]}
5925 @DefregListEnd {.hy}
5926 Enable hyphenation.  The request has an optional numeric argument,
5927 @var{mode}, to restrict hyphenation if necessary:
5929 @table @code
5930 @item 1
5931 The default argument if @var{mode} is omitted.  Hyphenate without
5932 restrictions.  This is also the start-up value of @code{gtroff}.
5934 @item 2
5935 Do not hyphenate the last word on a page or column.
5937 @item 4
5938 Do not hyphenate the last two characters of a word.
5940 @item 8
5941 Do not hyphenate the first two characters of a word.
5942 @end table
5944 Values in the previous table are additive.  For example, the
5945 value@tie{}12 causes @code{gtroff} to neither hyphenate the last
5946 two nor the first two characters of a word.
5948 @cindex hyphenation restrictions register (@code{.hy})
5949 The current hyphenation restrictions can be found in the read-only
5950 number register @samp{.hy}.
5952 The hyphenation mode is associated with the current environment
5953 (@pxref{Environments}).
5954 @endDefreq
5956 @Defreq {nh, }
5957 Disable hyphenation (i.e., set the hyphenation mode to zero).  Note
5958 that the hyphenation mode of the last call to @code{hy} is not
5959 remembered.
5961 The hyphenation mode is associated with the current environment
5962 (@pxref{Environments}).
5963 @endDefreq
5965 @DefreqList {hlm, [@Var{nnn}]}
5966 @DefregItem {.hlm}
5967 @DefregListEnd {.hlc}
5968 @cindex explicit hyphen (@code{\%})
5969 @cindex hyphen, explicit (@code{\%})
5970 @cindex consecutive hyphenated lines (@code{hlm})
5971 @cindex lines, consecutive hyphenated (@code{hlm})
5972 @cindex hyphenated lines, consecutive (@code{hlm})
5973 Set the maximum number of consecutive hyphenated lines to @var{nnn}.
5974 If this number is negative, there is no maximum.  The default value
5975 is@tie{}@minus{}1 if @var{nnn} is omitted.  This value is associated
5976 with the current environment (@pxref{Environments}).  Only lines
5977 output from a given environment count towards the maximum associated
5978 with that environment.  Hyphens resulting from @code{\%} are counted;
5979 explicit hyphens are not.
5981 The current setting of @code{hlm} is available in the @code{.hlm}
5982 read-only number register.  Also the number of immediately preceding
5983 consecutive hyphenated lines are available in the read-only number
5984 register @samp{.hlc}.
5985 @endDefreq
5987 @Defreq {hw, word1 word2 @dots{}}
5988 Define how @var{word1}, @var{word2}, etc.@: are to be hyphenated.  The
5989 words must be given with hyphens at the hyphenation points.  For
5990 example:
5992 @Example
5993 .hw in-sa-lub-rious
5994 @endExample
5996 @noindent
5997 Besides the space character, any character whose hyphenation code value
5998 is zero can be used to separate the arguments of @code{hw} (see the
5999 documentation for the @code{hcode} request below for more information).
6000 In addition, this request can be used more than once.
6002 Hyphenation exceptions specified with the @code{hw} request are
6003 associated with the current hyphenation language; it causes an error
6004 if there is no current hyphenation language.
6006 This request is ignored if there is no parameter.
6008 In old versions of @code{troff} there was a limited amount of space to
6009 store such information; fortunately, with @code{gtroff}, this is no
6010 longer a restriction.
6011 @endDefreq
6013 @DefescList {\\%, , , }
6014 @deffnx Escape @t{\:}
6015 @ifnotinfo
6016 @esindex \:
6017 @end ifnotinfo
6018 @ifinfo
6019 @esindex \@r{<colon>}
6020 @end ifinfo
6021 @cindex hyphenation character (@code{\%})
6022 @cindex character, hyphenation (@code{\%})
6023 @cindex disabling hyphenation (@code{\%})
6024 @cindex hyphenation, disabling (@code{\%})
6025 To tell @code{gtroff} how to hyphenate words on the fly, use the
6026 @code{\%} escape, also known as the @dfn{hyphenation character}.
6027 Preceding a word with this character prevents it from being
6028 hyphenated; putting it inside a word indicates to @code{gtroff} that
6029 the word may be hyphenated at that point.  Note that this mechanism
6030 only affects that one occurrence of the word; to change the
6031 hyphenation of a word for the entire document, use the @code{hw}
6032 request.
6034 The @code{\:} escape inserts a zero-width break point
6035 (that is, the word breaks but without adding a hyphen).
6037 @Example
6038 ... check the /var/log/\:httpd/\:access_log file ...
6039 @endExample
6041 @cindex @code{\X}, followed by @code{\%}
6042 @cindex @code{\Y}, followed by @code{\%}
6043 @cindex @code{\%}, following @code{\X} or @code{\Y}
6044 Note that @code{\X} and @code{\Y} start a word, that is, the @code{\%}
6045 escape in (say) @w{@samp{\X'...'\%foobar}} and
6046 @w{@samp{\Y'...'\%foobar}} no longer prevents hyphenation but inserts
6047 a hyphenation point at the beginning of @samp{foobar}; most likely
6048 this isn't what you want to do.
6049 @endDefesc
6051 @Defreq {hc, [@Var{char}]}
6052 Change the hyphenation character to @var{char}.  This character then
6053 works the same as the @code{\%} escape, and thus, no longer appears in
6054 the output.  Without an argument, @code{hc} resets the hyphenation
6055 character to be @code{\%} (the default) only.
6057 The hyphenation character is associated with the current environment
6058 (@pxref{Environments}).
6059 @endDefreq
6061 @DefreqList {hpf, pattern_file}
6062 @DefreqItem {hpfa, pattern_file}
6063 @DefreqListEnd {hpfcode, a b [c d @dots{}]}
6064 @cindex hyphenation patterns (@code{hpf})
6065 @cindex patterns for hyphenation (@code{hpf})
6066 Read in a file of hyphenation patterns.  This file is searched for in
6067 the same way as @file{@var{name}.tmac} (or @file{tmac.@var{name}}) is
6068 searched for if the @option{-m@var{name}} option is specified.
6070 It should have the same format as (simple) @TeX{} patterns files.
6071 More specifically, the following scanning rules are implemented.
6073 @itemize @bullet
6074 @item
6075 A percent sign starts a comment (up to the end of the line)
6076 even if preceded by a backslash.
6078 @item
6079 No support for `digraphs' like @code{\$}.
6081 @item
6082 @code{^^@var{xx}} (@var{x} is 0-9 or a-f) and @code{^^@var{x}} (character
6083 code of @var{x} in the range 0-127) are recognized; other use of @code{^}
6084 causes an error.
6086 @item
6087 No macro expansion.
6089 @item
6090 @code{hpf} checks for the expression @code{\patterns@{@dots{}@}}
6091 (possibly with whitespace before and after the braces).
6092 Everything between the braces is taken as hyphenation patterns.
6093 Consequently, @code{@{} and @code{@}} are not allowed in patterns.
6095 @item
6096 Similarly, @code{\hyphenation@{@dots{}@}} gives a list of hyphenation
6097 exceptions.
6099 @item
6100 @code{\endinput} is recognized also.
6102 @item
6103 For backwards compatibility, if @code{\patterns} is missing,
6104 the whole file is treated as a list of hyphenation patterns
6105 (only recognizing the @code{%} character as the start of a comment).
6106 @end itemize
6108 If no @code{hpf} request is specified (either in the document or in a
6109 macro package), @code{gtroff} won't hyphenate at all.
6111 The @code{hpfa} request appends a file of patterns to the current list.
6113 The @code{hpfcode} request defines mapping values for character codes in
6114 hyphenation patterns.  @code{hpf} or @code{hpfa} then apply the mapping
6115 (after reading the patterns) before replacing or appending them to
6116 the current list of patterns.  Its arguments are pairs of character codes
6117 -- integers from 0 to@tie{}255.  The request maps character code@tie{}@var{a}
6118 to code@tie{}@var{b}, code@tie{}@var{c} to code@tie{}@var{d}, and so on.  You
6119 can use character codes which would be invalid otherwise.
6121 @pindex troffrc
6122 @pindex troffrc-end
6123 @pindex hyphen.us
6124 @pindex hyphenex.us
6125 The set of hyphenation patterns is associated with the current language
6126 set by the @code{hla} request.  The @code{hpf} request is usually
6127 invoked by the @file{troffrc} or @file{troffrc-end} file; by default,
6128 @file{troffrc} loads hyphenation patterns and exceptions for American
6129 English (in files @file{hyphen.us} and @file{hyphenex.us}).
6131 A second call to @code{hpf} (for the same language) will replace the
6132 hyphenation patterns with the new ones.
6134 Invoking @code{hpf} causes an error if there is no current hyphenation
6135 language.
6136 @endDefreq
6138 @Defreq {hcode, c1 code1 c2 code2 @dots{}}
6139 @cindex hyphenation code (@code{hcode})
6140 @cindex code, hyphenation (@code{hcode})
6141 Set the hyphenation code of character @var{c1} to @var{code1}, that of
6142 @var{c2} to @var{code2}, etc.  A hyphenation code must be a single
6143 input character (not a special character) other than a digit or a
6144 space.  Initially each lower-case letter (@samp{a}-@samp{z}) has its
6145 hyphenation code set to itself, and each upper-case letter
6146 (@samp{A}-@samp{Z}) has a hyphenation code which is the lower-case
6147 version of itself.
6149 This request is ignored if it has no parameter.
6150 @endDefreq
6152 @DefreqList {hym, [@Var{length}]}
6153 @DefregListEnd {.hym}
6154 @cindex hyphenation margin (@code{hym})
6155 @cindex margin for hyphenation (@code{hym})
6156 @cindex @code{ad} request, and hyphenation margin
6157 Set the (right) hyphenation margin to @var{length}.  If the current
6158 adjustment mode is not @samp{b} or @samp{n}, the line is not
6159 hyphenated if it is shorter than @var{length}.  Without an argument,
6160 the hyphenation margin is reset to its default value, which is@tie{}0.
6161 The default scaling indicator for this request is @samp{m}.  The
6162 hyphenation margin is associated with the current environment
6163 (@pxref{Environments}).
6165 A negative argument resets the hyphenation margin to zero, emitting
6166 a warning of type @samp{range}.
6168 @cindex hyphenation margin register (@code{.hym})
6169 The current hyphenation margin is available in the @code{.hym} read-only
6170 number register.
6171 @endDefreq
6173 @DefreqList {hys, [@Var{hyphenation_space}]}
6174 @DefregListEnd {.hys}
6175 @cindex hyphenation space (@code{hys})
6176 @cindex @code{ad} request, and hyphenation space
6177 Set the hyphenation space to @var{hyphenation_space}.  If the current
6178 adjustment mode is @samp{b} or @samp{n}, don't hyphenate the line
6179 if it can be justified by adding no more than @var{hyphenation_space}
6180 extra space to each word space.  Without argument, the hyphenation
6181 space is set to its default value, which is@tie{}0.  The default
6182 scaling indicator for this request is @samp{m}.  The hyphenation
6183 space is associated with the current environment
6184 (@pxref{Environments}).
6186 A negative argument resets the hyphenation space to zero, emitting a
6187 warning of type @samp{range}.
6189 @cindex hyphenation space register (@code{.hys})
6190 The current hyphenation space is available in the @code{.hys} read-only
6191 number register.
6192 @endDefreq
6194 @Defreq {shc, [@Var{glyph}]}
6195 @cindex soft hyphen character, setting (@code{shc})
6196 @cindex character, soft hyphen, setting (@code{shc})
6197 @cindex glyph, soft hyphen (@code{hy})
6198 @cindex soft hyphen glyph (@code{hy})
6199 @cindex @code{char} request, and soft hyphen character
6200 @cindex @code{tr} request, and soft hyphen character
6201 Set the @dfn{soft hyphen character} to @var{glyph}.@footnote{@dfn{Soft
6202 hyphen character} is a misnomer since it is an output glyph.}  If the
6203 argument is omitted, the soft hyphen character is set to the default
6204 glyph @code{\(hy} (this is the start-up value of @code{gtroff} also).
6205 The soft hyphen character is the glyph that is inserted when a word is
6206 hyphenated at a line break.  If the soft hyphen character does not
6207 exist in the font of the character immediately preceding a potential
6208 break point, then the line is not broken at that point.  Neither
6209 definitions (specified with the @code{char} request) nor translations
6210 (specified with the @code{tr} request) are considered when finding the
6211 soft hyphen character.
6212 @endDefreq
6214 @DefreqList {hla, language}
6215 @DefregListEnd {.hla}
6216 @cindex @code{hpf} request, and hyphenation language
6217 @cindex @code{hw} request, and hyphenation language
6218 @pindex troffrc
6219 @pindex troffrc-end
6220 Set the current hyphenation language to the string @var{language}.
6221 Hyphenation exceptions specified with the @code{hw} request and
6222 hyphenation patterns specified with the @code{hpf} and @code{hpfa}
6223 requests are both associated with the current hyphenation language.
6224 The @code{hla} request is usually invoked by the @file{troffrc} or the
6225 @file{troffrc-end} files; @file{troffrc} sets the default language to
6226 @samp{us}.
6228 @cindex hyphenation language register (@code{.hla})
6229 The current hyphenation language is available as a string in the
6230 read-only number register @samp{.hla}.
6232 @Example
6233 .ds curr_language \n[.hla]
6234 \*[curr_language]
6235     @result{} us
6236 @endExample
6237 @endDefreq
6240 @c =====================================================================
6242 @node Manipulating Spacing, Tabs and Fields, Manipulating Hyphenation, gtroff Reference
6243 @section Manipulating Spacing
6244 @cindex manipulating spacing
6245 @cindex spacing, manipulating
6247 @Defreq {sp, [@Var{distance}]}
6248 Space downwards @var{distance}.  With no argument it advances
6249 1@tie{}line.  A negative argument causes @code{gtroff} to move up the page
6250 the specified distance.  If the argument is preceded by a @samp{|}
6251 then @code{gtroff} moves that distance from the top of the page.  This
6252 request causes a line break.  The default scaling indicator is @samp{v}.
6254 If a vertical trap is sprung during execution of @code{sp}, the amount of
6255 vertical space after the trap is discarded.  For example, this
6257 @Example
6258 .de xxx
6261 .wh 0 xxx
6263 .pl 5v
6265 .sp 2
6267 .sp 50
6269 @endExample
6271 @noindent
6272 results in
6274 @Example
6281 @endExample
6283 @cindex @code{sp} request, and traps
6284 @cindex discarded space in traps
6285 @cindex space, discarded, in traps
6286 @cindex traps, and discarded space
6287 The amount of discarded space is available in the number register
6288 @code{.trunc}.
6290 To protect @code{sp} against vertical traps, use the @code{vpt} request:
6292 @Example
6293 .vpt 0
6294 .sp -3
6295 .vpt 1
6296 @endExample
6297 @endDefreq
6299 @DefreqList {ls, [@Var{nnn}]}
6300 @DefregListEnd {.L}
6301 @cindex double-spacing (@code{ls})
6302 Output @w{@var{nnn}@minus{}1} blank lines after each line of text.
6303 With no argument, @code{gtroff} uses the previous value before the
6304 last @code{ls} call.
6306 @Example
6307 .ls 2    \" This causes double-spaced output
6308 .ls 3    \" This causes triple-spaced output
6309 .ls      \" Again double-spaced
6310 @endExample
6312 The line spacing is associated with the current environment
6313 (@pxref{Environments}).
6315 @cindex line spacing register (@code{.L})
6316 The read-only number register @code{.L} contains the current line
6317 spacing setting.
6318 @endDefreq
6320 @xref{Changing Type Sizes}, for the requests @code{vs} and @code{pvs}
6321 as alternatives to @code{ls}.
6323 @DefescList {\\x, ', spacing, '}
6324 @DefregListEnd {.a}
6325 Sometimes, extra vertical spacing is only needed occasionally, e.g.@:
6326 to allow space for a tall construct (like an equation).  The @code{\x}
6327 escape does this.  The escape is given a numerical argument, usually
6328 enclosed in quotes (like @samp{\x'3p'}); the default scaling indicator
6329 is @samp{v}.  If this number is positive extra vertical space is
6330 inserted below the current line.  A negative number adds space above.
6331 If this escape is used multiple times on the same line, the maximum of
6332 the values is used.
6334 @xref{Escapes}, for details on parameter delimiting characters.
6336 @cindex extra post-vertical line space register (@code{.a})
6337 The @code{.a} read-only number register contains the most recent
6338 (nonnegative) extra vertical line space.
6340 Using @code{\x} can be necessary in combination with the @code{\b}
6341 escape, as the following example shows.
6343 @Example
6344 This is a test with the \[rs]b escape.
6346 This is a test with the \[rs]b escape.
6348 This is a test with \b'xyz'\x'-1m'\x'1m'.
6350 This is a test with the \[rs]b escape.
6352 This is a test with the \[rs]b escape.
6353 @endExample
6355 @noindent
6356 produces
6358 @Example
6359 This is a test with the \b escape.
6360 This is a test with the \b escape.
6361                     x
6362 This is a test with y.
6363                     z
6364 This is a test with the \b escape.
6365 This is a test with the \b escape.
6366 @endExample
6367 @endDefesc
6369 @DefreqList {ns, }
6370 @DefreqItem {rs, }
6371 @DefregListEnd {.ns}
6372 @cindex @code{sp} request, and no-space mode
6373 @cindex no-space mode (@code{ns})
6374 @cindex mode, no-space (@code{ns})
6375 @cindex blank lines, disabling
6376 @cindex lines, blank, disabling
6377 Enable @dfn{no-space mode}.  In this mode, spacing (either via
6378 @code{sp} or via blank lines) is disabled.  The @code{bp} request to
6379 advance to the next page is also disabled, except if it is accompanied
6380 by a page number (see @ref{Page Control}, for more information).  This
6381 mode ends when actual text is output or the @code{rs} request is
6382 encountered which ends no-space mode.  The read-only number register
6383 @code{.ns} is set to@tie{}1 as long as no-space mode is active.
6385 This request is useful for macros that conditionally
6386 insert vertical space before the text starts
6387 (for example, a paragraph macro could insert some space
6388 except when it is the first paragraph after a section header).
6389 @endDefreq
6392 @c =====================================================================
6394 @node Tabs and Fields, Character Translations, Manipulating Spacing, gtroff Reference
6395 @section Tabs and Fields
6396 @cindex tabs, and fields
6397 @cindex fields, and tabs
6399 @cindex @acronym{EBCDIC} encoding of a tab
6400 A tab character (@acronym{ASCII} char@tie{}9, @acronym{EBCDIC}
6401 char@tie{}5) causes a horizontal movement to the next tab stop (much
6402 like it did on a typewriter).
6404 @Defesc {\\t, , , }
6405 @cindex tab character, non-interpreted (@code{\t})
6406 @cindex character, tab, non-interpreted (@code{\t})
6407 This escape is a non-interpreted tab character.  In copy mode
6408 (@pxref{Copy-in Mode}), @code{\t} is the same as a real tab character.
6409 @endDefesc
6411 @DefreqList {ta, [@Var{n1} @Var{n2} @dots{} @Var{nn} @t{T} @Var{r1} @Var{r2} @dots{} @Var{rn}]}
6412 @DefregListEnd {.tabs}
6413 Change tab stop positions.  This request takes a series of tab
6414 specifiers as arguments (optionally divided into two groups with the
6415 letter @samp{T}) which indicate where each tab stop is to be
6416 (overriding any previous settings).
6418 Tab stops can be specified absolutely, i.e., as the distance from the
6419 left margin.  For example, the following sets 6@tie{}tab stops every
6420 one inch.
6422 @Example
6423 .ta 1i 2i 3i 4i 5i 6i
6424 @endExample
6426 Tab stops can also be specified using a leading @samp{+}
6427 which means that the specified tab stop is set relative to
6428 the previous tab stop.  For example, the following is equivalent to the
6429 previous example.
6431 @Example
6432 .ta 1i +1i +1i +1i +1i +1i
6433 @endExample
6435 @code{gtroff} supports an extended syntax to specify repeat values after
6436 the @samp{T} mark (these values are always taken as relative) -- this is
6437 the usual way to specify tabs set at equal intervals.  The following is,
6438 yet again, the same as the previous examples.  It does even more since
6439 it defines an infinite number of tab stops separated by one inch.
6441 @Example
6442 .ta T 1i
6443 @endExample
6445 Now we are ready to interpret the full syntax given at the beginning:
6446 Set tabs at positions @var{n1}, @var{n2}, @dots{}, @var{nn} and then set
6447 tabs at @var{nn}+@var{r1}, @var{nn}+@var{r2}, @dots{}, @var{nn}+@var{rn}
6448 and then at @var{nn}+@var{rn}+@var{r1}, @var{nn}+@var{rn}+@var{r2},
6449 @dots{}, @var{nn}+@var{rn}+@var{rn}, and so on.
6451 Example: @samp{4c +6c T 3c 5c 2c} is equivalent to @samp{4c 10c 13c 18c
6452 20c 23c 28c 30c @dots{}}.
6454 The material in each tab column (i.e., the column between two tab stops)
6455 may be justified to the right or left or centered in the column.  This
6456 is specified by appending @samp{R}, @samp{L}, or @samp{C} to the tab
6457 specifier.  The default justification is @samp{L}.  Example:
6459 @Example
6460 .ta 1i 2iC 3iR
6461 @endExample
6463 Some notes:
6465 @itemize @bullet
6466 @item
6467 The default unit of the @code{ta} request is @samp{m}.
6469 @item
6470 A tab stop is converted into a non-breakable horizontal movement which
6471 can be neither stretched nor squeezed.  For example,
6473 @Example
6474 .ds foo a\tb\tc
6475 .ta T 5i
6476 \*[foo]
6477 @endExample
6479 @noindent
6480 creates a single line which is a bit longer than 10@tie{}inches (a string
6481 is used to show exactly where the tab characters are).  Now consider the
6482 following:
6484 @Example
6485 .ds bar a\tb b\tc
6486 .ta T 5i
6487 \*[bar]
6488 @endExample
6490 @noindent
6491 @code{gtroff} first converts the tab stops of the line into unbreakable
6492 horizontal movements, then splits the line after the second @samp{b}
6493 (assuming a sufficiently short line length).  Usually, this isn't what
6494 the user wants.
6496 @item
6497 Superfluous tabs (i.e., tab characters which do not correspond to a tab
6498 stop) are ignored except the first one which delimits the characters
6499 belonging to the last tab stop for right-justifying or centering.
6500 Consider the following example
6502 @Example
6503 .ds Z   foo\tbar\tfoo
6504 .ds ZZ  foo\tbar\tfoobar
6505 .ds ZZZ foo\tbar\tfoo\tbar
6506 .ta 2i 4iR
6507 \*[Z]
6509 \*[ZZ]
6511 \*[ZZZ]
6513 @endExample
6515 @noindent
6516 which produces the following output:
6518 @Example
6519 foo                 bar              foo
6520 foo                 bar           foobar
6521 foo                 bar              foobar
6522 @endExample
6524 @noindent
6525 The first line right-justifies the second `foo' relative to the tab
6526 stop.  The second line right-justifies `foobar'.  The third line finally
6527 right-justifies only `foo' because of the additional tab character which
6528 marks the end of the string belonging to the last defined tab stop.
6530 @item
6531 Tab stops are associated with the current environment
6532 (@pxref{Environments}).
6534 @item
6535 Calling @code{ta} without an argument removes all tab stops.
6537 @item
6538 @cindex tab stops, for TTY output devices
6539 The start-up value of @code{gtroff} is @w{@samp{T 0.8i}}.
6540 @end itemize
6542 @cindex tab settings register (@code{.tabs})
6543 The read-only number register @code{.tabs} contains a string
6544 representation of the current tab settings suitable for use as an
6545 argument to the @code{ta} request.
6547 @Example
6548 .ds tab-string \n[.tabs]
6549 \*[tab-string]
6550     @result{} T120u
6551 @endExample
6553 @cindex @code{.S} register, Plan@tie{}9 alias for @code{.tabs}
6554 @cindex @code{.tabs} register, Plan@tie{}9 alias (@code{.S})
6555 The @code{troff} version of the Plan@tie{}9 operating system uses
6556 register @code{.S} for the same purpose.
6557 @endDefreq
6559 @Defreq {tc, [@Var{fill-glyph}]}
6560 @cindex tab repetition character (@code{tc})
6561 @cindex character, tab repetition (@code{tc})
6562 @cindex glyph, tab repetition (@code{tc})
6563 Normally @code{gtroff} fills the space to the next tab stop with
6564 whitespace.  This can be changed with the @code{tc} request.  With no
6565 argument @code{gtroff} reverts to using whitespace, which is the
6566 default.  The value of this @dfn{tab repetition character} is
6567 associated with the current environment
6568 (@pxref{Environments}).@footnote{@dfn{Tab repetition character} is a
6569 misnomer since it is an output glyph.}
6570 @endDefreq
6572 @DefreqList {linetabs, n}
6573 @DefregListEnd {.linetabs}
6574 @cindex tab, line-tabs mode
6575 @cindex line-tabs mode
6576 @cindex mode, line-tabs
6577 If @var{n} is missing or not zero, enable @dfn{line-tabs} mode,
6578 or disable it otherwise (the default).
6579 In line-tabs mode, @code{gtroff} computes tab distances
6580 relative to the (current) output line instead of the input line.
6582 For example, the following code:
6584 @Example
6585 .ds x a\t\c
6586 .ds y b\t\c
6587 .ds z c
6588 .ta 1i 3i
6592 @endExample
6594 @noindent
6595 in normal mode, results in the output
6597 @Example
6598 a         b         c
6599 @endExample
6601 @noindent
6602 in line-tabs mode, the same code outputs
6604 @Example
6605 a         b                   c
6606 @endExample
6608 Line-tabs mode is associated with the current environment.
6609 The read-only register @code{.linetabs} is set to@tie{}1 if in line-tabs
6610 mode, and 0 in normal mode.
6611 @endDefreq
6613 @menu
6614 * Leaders::
6615 * Fields::
6616 @end menu
6618 @c ---------------------------------------------------------------------
6620 @node Leaders, Fields, Tabs and Fields, Tabs and Fields
6621 @subsection Leaders
6622 @cindex leaders
6624 Sometimes it may may be desirable to use the @code{tc} request to fill a
6625 particular tab stop with a given glyph (for example dots in a table
6626 of contents), but also normal tab stops on the rest of the line.  For
6627 this @code{gtroff} provides an alternate tab mechanism, called
6628 @dfn{leaders} which does just that.
6630 @cindex leader character
6631 A leader character (character code@tie{}1) behaves similarly to a tab
6632 character: It moves to the next tab stop.  The only difference is that
6633 for this movement, the fill glyph defaults to a period character and
6634 not to space.
6636 @Defesc {\\a, , , }
6637 @cindex leader character, non-interpreted (@code{\a})
6638 @cindex character, leader, non-interpreted (@code{\a})
6639 This escape is a non-interpreted leader character.  In copy mode
6640 (@pxref{Copy-in Mode}), @code{\a} is the same as a real leader
6641 character.
6642 @endDefesc
6644 @Defreq {lc, [@Var{fill-glyph}]}
6645 @cindex leader repetition character (@code{lc})
6646 @cindex character, leader repetition (@code{lc})
6647 @cindex glyph, leader repetition (@code{lc})
6648 Declare the @dfn{leader repetition character}.@footnote{@dfn{Leader
6649 repetition character} is a misnomer since it is an output glyph.}
6650 Without an argument, leaders act the same as tabs (i.e., using
6651 whitespace for filling).  @code{gtroff}'s start-up value is a dot
6652 (@samp{.}).  The value of the leader repetition character is
6653 associated with the current environment (@pxref{Environments}).
6654 @endDefreq
6656 @cindex table of contents
6657 @cindex contents, table of
6658 For a table of contents, to name an example, tab stops may be defined so
6659 that the section number is one tab stop, the title is the second with
6660 the remaining space being filled with a line of dots, and then the page
6661 number slightly separated from the dots.
6663 @Example
6664 .ds entry 1.1\tFoo\a\t12
6665 .lc .
6666 .ta 1i 5i +.25i
6667 \*[entry]
6668 @endExample
6670 @noindent
6671 This produces
6673 @Example
6674 1.1  Foo..........................................  12
6675 @endExample
6677 @c ---------------------------------------------------------------------
6679 @node Fields,  , Leaders, Tabs and Fields
6680 @subsection Fields
6681 @cindex fields
6683 @cindex field delimiting character (@code{fc})
6684 @cindex delimiting character, for fields (@code{fc})
6685 @cindex character, field delimiting (@code{fc})
6686 @cindex field padding character (@code{fc})
6687 @cindex padding character, for fields (@code{fc})
6688 @cindex character, field padding (@code{fc})
6689 @dfn{Fields} are a more general way of laying out tabular data.  A field
6690 is defined as the data between a pair of @dfn{delimiting characters}.
6691 It contains substrings which are separated by @dfn{padding characters}.
6692 The width of a field is the distance on the @emph{input} line from the
6693 position where the field starts to the next tab stop.  A padding
6694 character inserts stretchable space similar to @TeX{}'s @code{\hss}
6695 command (thus it can even be negative) to make the sum of all substring
6696 lengths plus the stretchable space equal to the field width.  If more
6697 than one padding character is inserted, the available space is evenly
6698 distributed among them.
6700 @Defreq {fc, [@Var{delim-char} [@Var{padding-char}]]}
6701 Define a delimiting and a padding character for fields.  If the latter
6702 is missing, the padding character defaults to a space character.  If
6703 there is no argument at all, the field mechanism is disabled (which is
6704 the default).  Note that contrary to e.g.@: the tab repetition
6705 character, delimiting and padding characters are @emph{not} associated
6706 to the current environment (@pxref{Environments}).
6708 Example:
6710 @Example
6711 .fc # ^
6712 .ta T 3i
6713 #foo^bar^smurf#
6715 #foo^^bar^smurf#
6716 @endExample
6718 @noindent
6719 and here the result:
6721 @Example
6722 foo         bar          smurf
6723 foo            bar       smurf
6724 @endExample
6725 @endDefreq
6728 @c =====================================================================
6730 @node Character Translations, Troff and Nroff Mode, Tabs and Fields, gtroff Reference
6731 @section Character Translations
6732 @cindex character translations
6733 @cindex translations of characters
6735 @cindex control character, changing (@code{cc})
6736 @cindex character, control, changing (@code{cc})
6737 @cindex no-break control character, changing (@code{c2})
6738 @cindex character, no-break control, changing (@code{c2})
6739 @cindex control character, no-break, changing (@code{c2})
6740 The control character (@samp{.}) and the no-break control character
6741 (@samp{'}) can be changed with the @code{cc} and @code{c2} requests,
6742 respectively.
6744 @Defreq {cc, [@Var{c}]}
6745 Set the control character to@tie{}@var{c}.  With no argument the default
6746 control character @samp{.} is restored.  The value of the control
6747 character is associated with the current environment
6748 (@pxref{Environments}).
6749 @endDefreq
6751 @Defreq {c2, [@Var{c}]}
6752 Set the no-break control character to@tie{}@var{c}.  With no argument the
6753 default control character @samp{'} is restored.  The value of the
6754 no-break control character is associated with the current environment
6755 (@pxref{Environments}).
6756 @endDefreq
6758 @Defreq {eo, }
6759 @cindex disabling @code{\} (@code{eo})
6760 @cindex @code{\}, disabling (@code{eo})
6761 Disable the escape mechanism completely.  After executing this
6762 request, the backslash character @samp{\} no longer starts an escape
6763 sequence.
6765 This request can be very helpful in writing macros since it is not
6766 necessary then to double the escape character.  Here an example:
6768 @Example
6769 .\" This is a simplified version of the
6770 .\" .BR request from the man macro package
6772 .de BR
6773 .  ds result \&
6774 .  while (\n[.$] >= 2) \@{\
6775 .    as result \fB\$1\fR\$2
6776 .    shift 2
6777 .  \@}
6778 .  if \n[.$] .as result \fB\$1
6779 \*[result]
6780 .  ft R
6783 @endExample
6784 @endDefreq
6786 @Defreq {ec, [@Var{c}]}
6787 @cindex escape character, changing (@code{ec})
6788 @cindex character, escape, changing (@code{ec})
6789 Set the escape character to@tie{}@var{c}.  With no argument the default
6790 escape character @samp{\} is restored.  It can be also used to
6791 re-enable the escape mechanism after an @code{eo} request.
6793 Note that changing the escape character globally will likely break
6794 macro packages since @code{gtroff} has no mechanism to `intern' macros,
6795 i.e., to convert a macro definition into an internal form which is
6796 independent of its representation (@TeX{} has this mechanism).
6797 If a macro is called, it is executed literally.
6798 @endDefreq
6800 @DefreqList {ecs, }
6801 @DefreqListEnd {ecr, }
6802 The @code{ecs} request saves the current escape character
6803 in an internal register.
6804 Use this request in combination with the @code{ec} request to
6805 temporarily change the escape character.
6807 The @code{ecr} request restores the escape character
6808 saved with @code{ecs}.
6809 Without a previous call to @code{ecs}, this request
6810 sets the escape character to @code{\}.
6811 @endDefreq
6813 @DefescList {\\\\, , , }
6814 @DefescItem {\\e, , , }
6815 @DefescListEnd {\\E, , , }
6816 Print the current escape character (which is the backslash character
6817 @samp{\} by default).
6819 @code{\\} is a `delayed' backslash; more precisely, it is the default
6820 escape character followed by a backslash, which no longer has special
6821 meaning due to the leading escape character.  It is @emph{not} an escape
6822 sequence in the usual sense!  In any unknown escape sequence
6823 @code{\@var{X}} the escape character is ignored and @var{X} is printed.
6824 But if @var{X} is equal to the current escape character, no warning is
6825 emitted.
6827 As a consequence, only at top-level or in a diversion a backslash glyph is
6828 printed; in copy-in mode, it expands to a single backslash which then
6829 combines with the following character to an escape sequence.
6831 The @code{\E} escape differs from @code{\e} by printing an escape
6832 character that is not interpreted in copy mode.
6833 Use this to define strings with escapes that work
6834 when used in copy mode (for example, as a macro argument).
6835 The following example defines strings to begin and end
6836 a superscript:
6838 @Example
6839 .ds @{ \v'-.3m'\s'\En[.s]*60/100'
6840 .ds @} \s0\v'.3m'
6841 @endExample
6843 Another example to demonstrate the differences between the various escape
6844 sequences, using a strange escape character, @samp{-}.
6846 @Example
6847 .ec -
6848 .de xxx
6849 --A'123'
6851 .xxx
6852     @result{} -A'foo'
6853 @endExample
6855 @noindent
6856 The result is surprising for most users, expecting @samp{1} since
6857 @samp{foo} is a valid identifier.  What has happened?  As mentioned
6858 above, the leading escape character makes the following character
6859 ordinary.  Written with the default escape character the sequence
6860 @samp{--} becomes @samp{\-} -- this is the minus sign.
6862 If the escape character followed by itself is a valid escape sequence,
6863 only @code{\E} yields the expected result:
6865 @Example
6866 .ec -
6867 .de xxx
6868 -EA'123'
6870 .xxx
6871     @result{} 1
6872 @endExample
6873 @endDefesc
6875 @Defesc {\\., , , }
6876 Similar to @code{\\}, the sequence @code{\.} isn't a real escape sequence.
6877 As before, a warning message is suppressed if the escape character is
6878 followed by a dot, and the dot itself is printed.
6880 @Example
6881 .de foo
6882 .  nop foo
6884 .  de bar
6885 .    nop bar
6886 \\..
6889 .foo
6890 .bar
6891     @result{} foo bar
6892 @endExample
6894 @noindent
6895 The first backslash is consumed while the macro is read, and the second
6896 is swallowed while exexuting macro @code{foo}.
6897 @endDefesc
6899 A @dfn{translation} is a mapping of an input character to an output
6900 glyph.  The mapping occurs at output time, i.e., the input character
6901 gets assigned the metric information of the mapped output character
6902 right before input tokens are converted to nodes (@pxref{Gtroff
6903 Internals}, for more on this process).
6905 @DefreqList {tr, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
6906 @DefreqListEnd {trin, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
6907 Translate character @var{a} to glyph@tie{}@var{b}, character @var{c} to
6908 glyph@tie{}@var{d}, etc.  If there is an odd number of arguments, the
6909 last one is translated to an unstretchable space (@w{@samp{\ }}).
6911 The @code{trin} request is identical to @code{tr},
6912 but when you unformat a diversion with @code{asciify}
6913 it ignores the translation.
6914 @xref{Diversions}, for details about the @code{asciify} request.
6916 Some notes:
6918 @itemize @bullet
6919 @item
6920 @cindex @code{\(}, and translations
6921 @cindex @code{\[}, and translations
6922 @cindex @code{\'}, and translations
6923 @cindex @code{\`}, and translations
6924 @cindex @code{\-}, and translations
6925 @cindex @code{\_}, and translations
6926 @cindex @code{\C}, and translations
6927 @cindex @code{\N}, and translations
6928 @cindex @code{char} request, and translations
6929 @cindex special characters
6930 @cindex character, special
6931 @cindex numbered glyph (@code{\N})
6932 @cindex glyph, numbered (@code{\N})
6933 Special characters (@code{\(@var{xx}}, @code{\[@var{xxx}]},
6934 @code{\C'@var{xxx}'}, @code{\'}, @code{\`}, @code{\-}, @code{\_}),
6935 glyphs defined with the @code{char} request, and numbered glyphs
6936 (@code{\N'@var{xxx}'}) can be translated also.
6938 @item
6939 @cindex @code{\e}, and translations
6940 The @code{\e} escape can be translated also.
6942 @item
6943 @cindex @code{\%}, and translations
6944 @cindex @code{\~}, and translations
6945 Characters can be mapped onto the @code{\%} and @code{\~} escapes (but
6946 @code{\%} and @code{\~} can't be mapped onto another glyph).
6948 @item
6949 @cindex backspace character, and translations
6950 @cindex character, backspace, and translations
6951 @cindex leader character, and translations
6952 @cindex character, leader, and translations
6953 @cindex newline character, and translations
6954 @cindex character, newline, and translations
6955 @cindex tab character, and translations
6956 @cindex character, tab, and translations
6957 @cindex @code{\a}, and translations
6958 @cindex @code{\t}, and translations
6959 The following characters can't be translated: space (with one exception,
6960 see below), backspace, newline, leader (and @code{\a}), tab (and
6961 @code{\t}).
6963 @item
6964 @cindex @code{shc} request, and translations
6965 Translations are not considered for finding the soft hyphen character
6966 set with the @code{shc} request.
6968 @item
6969 @cindex @code{\&}, and translations
6970 The pair @samp{@var{c}\&} (this is an arbitrary character@tie{}@var{c}
6971 followed by the zero width space character) maps this character to nothing.
6973 @Example
6974 .tr a\&
6975 foo bar
6976     @result{} foo br
6977 @endExample
6979 @noindent
6980 It is even possible to map the space character to nothing:
6982 @Example
6983 .tr aa \&
6984 foo bar
6985     @result{} foobar
6986 @endExample
6988 @noindent
6989 As shown in the example, the space character can't be the first
6990 character/glyph pair as an argument of @code{tr}.  Additionally, it is
6991 not possible to map the space character to any other glyph; requests
6992 like @w{@samp{.tr aa x}} undo @w{@samp{.tr aa \&}} instead.
6994 If justification is active, lines are justified in spite of the
6995 `empty' space character (but there is no minimal distance, i.e.@: the
6996 space character, between words).
6998 @item
6999 After an output glyph has been constructed (this happens at the
7000 moment immediately before the glyph is appended to an output
7001 glyph list, either by direct output, in a macro, diversion, or
7002 string), it is no longer affected by @code{tr}.
7004 @item
7005 Translating character to glyphs where one of them or both are
7006 undefined is possible also; @code{tr} does not check whether the
7007 entities in its argument do exist.
7009 @xref{Gtroff Internals}.
7011 @item
7012 @code{troff} no longer has a hard-coded dependency on @w{Latin-1};
7013 all @code{char@var{XXX}} entities have been removed from the font
7014 description files.  This has a notable consequence which shows up in
7015 warnings like @code{can't find character with input code @var{XXX}}
7016 if the @code{tr} request isn't handled properly.
7018 Consider the following translation:
7020 @Example
7021 .tr @'e@'E
7022 @endExample
7024 @noindent
7025 This maps input character @code{@'e} onto glyph @code{@'E}, which is
7026 identical to glyph @code{char201}.  But this glyph intentionally
7027 doesn't exist!  Instead, @code{\[char201]} is treated as an input
7028 character entity and is by default mapped onto @code{\['E]}, and
7029 @code{gtroff} doesn't handle translations of translations.
7031 The right way to write the above translation is
7033 @Example
7034 .tr @'e\['E]
7035 @endExample
7037 @noindent
7038 With other words, the first argument of @code{tr} should be an input
7039 character or entity, and the second one a glyph entity.
7041 @item
7042 Without an argument, the @code{tr} request is ignored.
7043 @end itemize
7044 @endDefreq
7046 @Defreq {trnt, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
7047 @cindex @code{\!}, and @code{trnt}
7048 @code{trnt} is the same as the @code{tr} request except that the
7049 translations do not apply to text that is transparently throughput
7050 into a diversion with @code{\!}.  @xref{Diversions}, for more
7051 information.
7053 For example,
7055 @Example
7056 .tr ab
7057 .di x
7058 \!.tm a
7061 @endExample
7063 @noindent
7064 prints @samp{b} to the standard error stream; if @code{trnt} is used
7065 instead of @code{tr} it prints @samp{a}.
7066 @endDefreq
7069 @c =====================================================================
7071 @node Troff and Nroff Mode, Line Layout, Character Translations, gtroff Reference
7072 @section Troff and Nroff Mode
7073 @cindex troff mode
7074 @cindex mode, troff
7075 @cindex nroff mode
7076 @cindex mode, nroff
7078 Originally, @code{nroff} and @code{troff} were two separate programs,
7079 the former for TTY output, the latter for everything else.  With GNU
7080 @code{troff}, both programs are merged into one executable, sending
7081 its output to a device driver (@code{grotty} for TTY devices,
7082 @code{grops} for @sc{PostScript}, etc.) which interprets the
7083 intermediate output of @code{gtroff}.  For @acronym{UNIX} @code{troff}
7084 it makes sense to talk about @dfn{Nroff mode} and @dfn{Troff mode}
7085 since the differences are hardcoded.  For GNU @code{troff}, this
7086 distinction is not appropriate because @code{gtroff} simply takes the
7087 information given in the font files for a particular device without
7088 handling requests specially if a TTY output device is used.
7090 Usually, a macro package can be used with all output devices.
7091 Nevertheless, it is sometimes necessary to make a distinction between
7092 TTY and non-TTY devices: @code{gtroff} provides two built-in
7093 conditions @samp{n} and @samp{t} for the @code{if}, @code{ie}, and
7094 @code{while} requests to decide whether @code{gtroff} shall behave
7095 like @code{nroff} or like @code{troff}.
7097 @Defreq {troff, }
7098 @pindex troffrc
7099 @pindex troffrc-end
7100 Make the @samp{t} built-in condition true (and the @samp{n} built-in
7101 condition false) for @code{if}, @code{ie}, and @code{while}
7102 conditional requests.  This is the default if @code{gtroff}
7103 (@emph{not} @code{groff}) is started with the @option{-R} switch to
7104 avoid loading of the start-up files @file{troffrc} and
7105 @file{troffrc-end}.  Without @option{-R}, @code{gtroff} stays in troff
7106 mode if the output device is not a TTY (e.g.@: `ps').
7107 @endDefreq
7109 @Defreq {nroff, }
7110 @pindex tty.tmac
7111 Make the @samp{n} built-in condition true (and the @samp{t} built-in
7112 condition false) for @code{if}, @code{ie}, and @code{while}
7113 conditional requests.  This is the default if @code{gtroff} uses a TTY
7114 output device; the code for switching to nroff mode is in the file
7115 @file{tty.tmac} which is loaded by the start-up file @code{troffrc}.
7116 @endDefreq
7118 @xref{Conditionals and Loops}, for more details on built-in
7119 conditions.
7122 @c =====================================================================
7124 @node Line Layout, Line Control, Troff and Nroff Mode, gtroff Reference
7125 @section Line Layout
7126 @cindex line layout
7127 @cindex layout, line
7129 @cindex dimensions, line
7130 @cindex line dimensions
7131 The following drawing shows the dimensions which @code{gtroff} uses for
7132 placing a line of output onto the page.  They are labeled with the
7133 request which manipulates each dimension.
7135 @Example
7136                 -->| in |<--
7137                    |<-----------ll------------>|
7138               +----+----+----------------------+----+
7139               |    :    :                      :    |
7140               +----+----+----------------------+----+
7141            -->| po |<--
7142               |<--------paper width---------------->|
7143 @endExample
7145 @noindent
7146 These dimensions are:
7148 @ftable @code
7149 @item po
7150 @cindex left margin (@code{po})
7151 @cindex margin, left (@code{po})
7152 @cindex page offset (@code{po})
7153 @cindex offset, page (@code{po})
7154 @dfn{Page offset} -- this is the leftmost position of text on the final
7155 output, defining the @dfn{left margin}.
7157 @item in
7158 @cindex indentation (@code{in})
7159 @cindex line indentation (@code{in})
7160 @dfn{Indentation} -- this is the distance from the left margin where
7161 text is printed.
7163 @item ll
7164 @cindex line length (@code{ll})
7165 @cindex length of line (@code{ll})
7166 @dfn{Line length} -- this is the distance from the left margin to right
7167 margin.
7168 @end ftable
7170 A simple demonstration:
7172 @Example
7173 .ll 3i
7174 This is text without indentation.
7175 The line length has been set to 3\~inch.
7176 .in +.5i
7177 .ll -.5i
7178 Now the left and right margins are both increased.
7181 Calling .in and .ll without parameters restore
7182 the previous values.
7183 @endExample
7185 Result:
7187 @Example
7188 This  is text without indenta-
7189 tion.   The  line  length  has
7190 been set to 3 inch.
7191      Now   the  left  and
7192      right  margins   are
7193      both increased.
7194 Calling  .in  and  .ll without
7195 parameters restore the  previ-
7196 ous values.
7197 @endExample
7199 @DefreqList {po, [@Var{offset}]}
7200 @DefreqItem {po, @t{+}@Var{offset}}
7201 @DefreqItem {po, @t{-}@Var{offset}}
7202 @DefregListEnd {.o}
7203 @pindex troffrc
7204 Set horizontal page offset to @var{offset} (or increment or decrement
7205 the current value by @var{offset}).  Note that this request does not
7206 cause a break, so changing the page offset in the middle of text being
7207 filled may not yield the expected result.  The initial value is
7208 1@dmn{i}.  For TTY output devices, it is set to 0 in the startup file
7209 @file{troffrc}; the default scaling indicator is @samp{m} (and
7210 not @samp{v} as incorrectly documented in the original
7211 @acronym{UNIX} troff manual).
7213 The current page offset can be found in the read-only number register
7214 @samp{.o}.
7216 If @code{po} is called without an argument, the page offset is reset to
7217 the previous value before the last call to @code{po}.
7219 @Example
7220 .po 3i
7221 \n[.o]
7222     @result{} 720
7223 .po -1i
7224 \n[.o]
7225     @result{} 480
7227 \n[.o]
7228     @result{} 720
7229 @endExample
7230 @endDefreq
7232 @DefreqList {in, [@Var{indent}]}
7233 @DefreqItem {in, @t{+}@Var{indent}}
7234 @DefreqItem {in, @t{-}@Var{indent}}
7235 @DefregListEnd {.i}
7236 Set indentation to @var{indent} (or increment or decrement the
7237 current value by @var{indent}).  This request causes a break.
7238 Initially, there is no indentation.
7240 If @code{in} is called without an argument, the indentation is reset to
7241 the previous value before the last call to @code{in}.  The default
7242 scaling indicator is @samp{m}.
7244 The indentation is associated with the current environment
7245 (@pxref{Environments}).
7247 If a negative indentation value is specified (which is not allowed),
7248 @code{gtroff} emits a warning of type @samp{range} and sets the
7249 indentation to zero.
7251 The effect of @code{in} is delayed until a partially collected line (if
7252 it exists) is output.  A temporary indent value is reset to zero also.
7254 The current indentation (as set by @code{in}) can be found in the
7255 read-only number register @samp{.i}.
7256 @endDefreq
7258 @DefreqList {ti, offset}
7259 @DefreqItem {ti, @t{+}@Var{offset}}
7260 @DefreqItem {ti, @t{-}@Var{offset}}
7261 @DefregListEnd {.in}
7262 Temporarily indent the next output line by @var{offset}.  If an
7263 increment or decrement value is specified, adjust the temporary
7264 indentation relative to the value set by the @code{in} request.
7266 This request causes a break; its value is associated with the current
7267 environment (@pxref{Environments}).  The default scaling indicator
7268 is @samp{m}.  A call of @code{ti} without an argument is ignored.
7270 If the total indentation value is negative (which is not allowed),
7271 @code{gtroff} emits a warning of type @samp{range} and sets the
7272 temporary indentation to zero.  `Total indentation' is either
7273 @var{offset} if specified as an absolute value, or the temporary plus
7274 normal indentation, if @var{offset} is given as a relative value.
7276 The effect of @code{ti} is delayed until a partially collected line (if
7277 it exists) is output.
7279 The read-only number register @code{.in} is the indentation that applies
7280 to the current output line.
7282 The difference between @code{.i} and @code{.in} is that the latter takes
7283 into account whether a partially collected line still uses the old
7284 indentation value or a temporary indentation value is active.
7285 @endDefreq
7287 @DefreqList {ll, [@Var{length}]}
7288 @DefreqItem {ll, @t{+}@Var{length}}
7289 @DefreqItem {ll, @t{-}@Var{length}}
7290 @DefregItem {.l}
7291 @DefregListEnd {.ll}
7292 Set the line length to @var{length} (or increment or decrement the
7293 current value by @var{length}).  Initially, the line length is set to
7294 6.5@dmn{i}.  The effect of @code{ll} is delayed until a partially
7295 collected line (if it exists) is output.  The default scaling
7296 indicator is @samp{m}.
7298 If @code{ll} is called without an argument, the line length is reset to
7299 the previous value before the last call to @code{ll}.  If a negative
7300 line length is specified (which is not allowed), @code{gtroff} emits a
7301 warning of type @samp{range} and sets the line length to zero.
7303 The line length is associated with the current environment
7304 (@pxref{Environments}).
7306 @cindex line length register (@code{.l})
7307 The current line length (as set by @code{ll}) can be found in the
7308 read-only number register @samp{.l}.  The read-only number register
7309 @code{.ll} is the line length that applies to the current output line.
7311 Similar to @code{.i} and @code{.in}, the difference between @code{.l}
7312 and @code{.ll} is that the latter takes into account whether a partially
7313 collected line still uses the old line length value.
7314 @endDefreq
7317 @c =====================================================================
7319 @node Line Control, Page Layout, Line Layout, gtroff Reference
7320 @section Line Control
7321 @cindex line control
7322 @cindex control, line
7324 It is important to understand how @code{gtroff} handles input and output
7325 lines.
7327 Many escapes use positioning relative to the input line.  For example,
7328 this
7330 @Example
7331 This is a \h'|1.2i'test.
7333 This is a
7334 \h'|1.2i'test.
7335 @endExample
7337 @noindent
7338 produces
7340 @Example
7341 This is a   test.
7343 This is a             test.
7344 @endExample
7346 The main usage of this feature is to define macros which act exactly
7347 at the place where called.
7349 @Example
7350 .\" A simple macro to underline a word
7351 .de underline
7352 .  nop \\$1\l'|0\[ul]'
7354 @endExample
7356 @noindent
7357 In the above example, @samp{|0} specifies a negative distance from the
7358 current position (at the end of the just emitted argument @code{\$1}) back
7359 to the beginning of the input line.  Thus, the @samp{\l} escape draws a
7360 line from right to left.
7362 @cindex input line continuation (@code{\})
7363 @cindex line, input, continuation (@code{\})
7364 @cindex continuation, input line (@code{\})
7365 @cindex output line, continuation (@code{\c})
7366 @cindex line, output, continuation (@code{\c})
7367 @cindex continuation, output line (@code{\c})
7368 @cindex interrupted line
7369 @cindex line, interrupted
7370 @code{gtroff} makes a difference between input and output line
7371 continuation; the latter is also called @dfn{interrupting} a line.
7373 @DefescList {\\@key{RET}, , ,}
7374 @DefescItem {\\c, , ,}
7375 @DefregListEnd{.int}
7376 Continue a line.  @code{\@key{RET}} (this is a backslash at the end
7377 of a line immediately followed by a newline) works on the input level,
7378 suppressing the effects of the following newline in the input.
7380 @Example
7381 This is a \
7382 .test
7383     @result{} This is a .test
7384 @endExample
7386 The @samp{|} operator is also affected.
7388 @cindex @code{\R}, after @code{\c}
7389 @code{\c} works on the output level.  Anything after this escape on the
7390 same line is ignored, except @code{\R} which works as usual.  Anything
7391 before @code{\c} on the same line will be appended to the current partial
7392 output line.  The next non-command line after an interrupted line counts
7393 as a new input line.
7395 The visual results depend on whether no-fill mode is active.
7397 @itemize @bullet
7398 @item
7399 @cindex @code{\c}, and no-fill mode
7400 @cindex no-fill mode, and @code{\c}
7401 @cindex mode, no-fill, and @code{\c}
7402 If no-fill mode is active (using the @code{nf} request), the next input
7403 text line after @code{\c} will be handled as a continuation of the same
7404 input text line.
7406 @Example
7408 This is a \c
7409 test.
7410     @result{} This is a test.
7411 @endExample
7413 @item
7414 @cindex @code{\c}, and fill mode
7415 @cindex fill mode, and @code{\c}
7416 @cindex mode, fill, and @code{\c}
7417 If fill mode is active (using the @code{fi} request), a word interrupted
7418 with @code{\c} will be continued with the text on the next input text line,
7419 without an intervening space.
7421 @Example
7422 This is a te\c
7424     @result{} This is a test.
7425 @endExample
7426 @end itemize
7428 Note that an intervening control line which causes a break is stronger
7429 than @code{\c}, flushing out the current partial line in the usual way.
7431 @cindex interrupted line register (@code{.int})
7432 The @code{.int} register contains a positive value
7433 if the last output line was interrupted with @code{\c}; this is
7434 associated with the current environment (@pxref{Environments}).
7436 @endDefesc
7438 @c =====================================================================
7440 @node Page Layout, Page Control, Line Control, gtroff Reference
7441 @section Page Layout
7442 @cindex page layout
7443 @cindex layout, page
7445 @code{gtroff} provides some very primitive operations for controlling
7446 page layout.
7448 @DefreqList {pl, [@Var{length}]}
7449 @DefreqItem {pl, @t{+}@Var{length}}
7450 @DefreqItem {pl, @t{-}@Var{length}}
7451 @DefregListEnd {.p}
7452 @cindex page length (@code{pl})
7453 @cindex length of page (@code{pl})
7454 Set the @dfn{page length} to @var{length} (or increment or decrement
7455 the current value by @var{length}).  This is the length of the
7456 physical output page.  The default scaling indicator is @samp{v}.
7458 @cindex page length register (@code{.p})
7459 The current setting can be found in the read-only number register
7460 @samp{.p}.
7462 @cindex top margin
7463 @cindex margin, top
7464 @cindex bottom margin
7465 @cindex margin, bottom
7466 Note that this only specifies the size of the page, not the top and
7467 bottom margins.  Those are not set by @code{gtroff} directly.
7468 @xref{Traps}, for further information on how to do this.
7470 Negative @code{pl} values are possible also, but not very useful: No
7471 trap is sprung, and each line is output on a single page (thus
7472 suppressing all vertical spacing).
7474 If no argument or an invalid argument is given, @code{pl} sets the page
7475 length to 11@dmn{i}.
7476 @endDefreq
7478 @cindex headers
7479 @cindex footers
7480 @cindex titles
7481 @code{gtroff} provides several operations which help in setting up top
7482 and bottom titles (or headers and footers).
7484 @Defreq {tl, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}}
7485 @cindex title line (@code{tl})
7486 @cindex three-part title (@code{tl})
7487 @cindex page number character (@code{%})
7488 Print a @dfn{title line}.  It consists of three parts: a left
7489 justified portion, a centered portion, and a right justified portion.
7490 The argument separator @samp{'} can be replaced with any character not
7491 occurring in the title line.  The @samp{%} character is replaced with
7492 the current page number.  This character can be changed with the
7493 @code{pc} request (see below).
7495 Without argument, @code{tl} is ignored.
7497 Some notes:
7499 @itemize @bullet
7500 @item
7501 A title line is not restricted to the top or bottom of a page.
7503 @item
7504 @code{tl} prints the title line immediately, ignoring a partially filled
7505 line (which stays untouched).
7507 @item
7508 It is not an error to omit closing delimiters.  For example,
7509 @w{@samp{.tl /foo}} is equivalent to @w{@samp{.tl /foo///}}: It prints a
7510 title line with the left justified word @samp{foo}; the centered and
7511 right justfied parts are empty.
7513 @item
7514 @code{tl} accepts the same parameter delimiting characters as the
7515 @code{\A} escape; see @ref{Escapes}.
7516 @end itemize
7517 @endDefreq
7519 @DefreqList {lt, [@Var{length}]}
7520 @DefreqItem {lt, @t{+}@Var{length}}
7521 @DefreqItem {lt, @t{-}@Var{length}}
7522 @DefregListEnd {.lt}
7523 @cindex length of title line (@code{lt})
7524 @cindex title line, length (@code{lt})
7525 @cindex title line length register (@code{.lt})
7526 The title line is printed using its own line length, which is
7527 specified (or incremented or decremented) with the @code{lt} request.
7528 Initially, the title line length is set to 6.5@dmn{i}.  If a negative
7529 line length is specified (which is not allowed), @code{gtroff} emits a
7530 warning of type @samp{range} and sets the title line length to zero.
7531 The default scaling indicator is @samp{m}.  If @code{lt} is called
7532 without an argument, the title length is reset to the previous value
7533 before the last call to @code{lt}.
7535 The current setting of this is available in the @code{.lt} read-only
7536 number register; it is associated with the current environment
7537 (@pxref{Environments}).
7539 @endDefreq
7541 @DefreqList {pn, page}
7542 @DefreqItem {pn, @t{+}@Var{page}}
7543 @DefreqItem {pn, @t{-}@Var{page}}
7544 @DefregListEnd {.pn}
7545 @cindex page number (@code{pn})
7546 @cindex number, page (@code{pn})
7547 Change (increase or decrease) the page number of the @emph{next} page.
7548 The only argument is the page number; the request is ignored without a
7549 parameter.
7551 The read-only number register @code{.pn} contains the number of the next
7552 page: either the value set by a @code{pn} request, or the number of the
7553 current page plus@tie{}1.
7554 @endDefreq
7556 @Defreg {%}
7557 @cindex page number register (@code{%})
7558 A read-write register holding the current page number.
7559 @endDefreg
7561 @Defreq {pc, [@Var{char}]}
7562 @cindex changing the page number character (@code{pc})
7563 @cindex page number character, changing (@code{pc})
7564 @vindex %
7565 Change the page number character (used by the @code{tl} request) to a
7566 different character.  With no argument, this mechanism is disabled.
7567 Note that this doesn't affect the number register@tie{}@code{%}.
7568 @endDefreq
7570 @xref{Traps}.
7573 @c =====================================================================
7575 @node Page Control, Fonts, Page Layout, gtroff Reference
7576 @section Page Control
7577 @cindex page control
7578 @cindex control, page
7580 @DefreqList {bp, [@Var{page}]}
7581 @DefreqItem {bp, @t{+}@Var{page}}
7582 @DefreqListEnd {bp, @t{-}@Var{page}}
7583 @cindex new page (@code{bp})
7584 @cindex page, new (@code{bp})
7585 Stop processing the current page and move to the next page.  This
7586 request causes a break.  It can also take an argument to set
7587 (increase, decrease) the page number of the next page.  The only
7588 difference between @code{bp} and @code{pn} is that @code{pn} does not
7589 cause a break or actually eject a page.
7591 @Example
7592 .de newpage                         \" define macro
7593 'bp                                 \" begin page
7594 'sp .5i                             \" vertical space
7595 .tl 'left top'center top'right top' \" title
7596 'sp .3i                             \" vertical space
7597 ..                                  \" end macro
7598 @endExample
7600 @cindex @code{bp} request, and top-level diversion
7601 @cindex top-level diversion, and @code{bp}
7602 @cindex diversion, top-level, and @code{bp}
7603 @code{bp} has no effect if not called within the top-level diversion
7604 (@pxref{Diversions}).
7606 The number register @code{.pe} is set to@tie{}1 while @code{bp} is
7607 active.  @xref{Page Location Traps}.
7608 @endDefreq
7610 @Defreq {ne, [@Var{space}]}
7611 @cindex orphan lines, preventing with @code{ne}
7612 @cindex conditional page break (@code{ne})
7613 @cindex page break, conditional (@code{ne})
7614 It is often necessary to force a certain amount of space before a new
7615 page occurs.  This is most useful to make sure that there is not a
7616 single @dfn{orphan} line left at the bottom of a page.  The @code{ne}
7617 request ensures that there is a certain distance, specified by the
7618 first argument, before the next page is triggered (see @ref{Traps},
7619 for further information).  The default scaling indicator for @code{ne}
7620 is @samp{v}; the default value of @var{space} is@tie{}1@dmn{v} if no
7621 argument is given.
7623 For example, to make sure that no fewer than 2@tie{}lines get orphaned,
7624 do the following before each paragraph:
7626 @Example
7627 .ne 2
7628 text text text
7629 @endExample
7631 @code{ne} will then automatically cause a page break if there is space
7632 for one line only.
7633 @endDefreq
7635 @DefreqList {sv, [@Var{space}]}
7636 @DefreqListEnd {os, }
7637 @cindex @code{ne} request, comparison with @code{sv}
7638 @code{sv} is similar to the @code{ne} request; it reserves the
7639 specified amount of vertical space.  If the desired amount of space
7640 exists before the next trap (or the bottom page boundary if no trap is
7641 set), the space is output immediately (ignoring a partially filled line
7642 which stays untouched).  If there is not enough space, it is stored for
7643 later output via the @code{os} request.  The default value is@tie{}1@dmn{v}
7644 if no argument is given; the default scaling indicator is @samp{v}.
7646 @cindex @code{sv} request, and no-space mode
7647 @cindex @code{os} request, and no-space mode
7648 Both @code{sv} and @code{os} ignore no-space mode.  While the @code{sv}
7649 request allows negative values for @var{space}, @code{os} will ignore
7650 them.
7651 @endDefreq
7653 @Defreg {nl}
7654 This register contains the current vertical position.  If the vertical
7655 position is zero and the top of page transition hasn't happened yet,
7656 @code{nl} is set to negative value.  @code{gtroff} itself does this at
7657 the very beginning of a document before anything has been printed, but
7658 the main usage is to plant a header trap on a page if this page has
7659 already started.
7661 Consider the following:
7663 @Example
7664 .de xxx
7665 .  sp
7666 .  tl ''Header''
7667 .  sp
7670 First page.
7672 .wh 0 xxx
7673 .nr nl (-1)
7674 Second page.
7675 @endExample
7677 @noindent
7678 Result:
7680 @Example
7681 First page.
7685                              Header
7687 Second page.
7690 @endExample
7692 @noindent
7693 Without resetting @code{nl} to a negative value, the just planted trap
7694 would be active beginning with the @emph{next} page, not the current
7695 one.
7697 @xref{Diversions}, for a comparison with the @code{.h} and @code{.d}
7698 registers.
7699 @endDefreg
7701 @c =====================================================================
7703 @node Fonts, Sizes, Page Control, gtroff Reference
7704 @section Fonts
7705 @cindex fonts
7707 @code{gtroff} can switch fonts at any point in the text.
7709 The basic set of fonts is @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
7710 These are Times Roman, Italic, Bold, and Bold Italic.  For non-TTY
7711 devices, there is also at least one symbol font which contains various
7712 special symbols (Greek, mathematics).
7714 @menu
7715 * Changing Fonts::
7716 * Font Families::
7717 * Font Positions::
7718 * Using Symbols::
7719 * Special Fonts::
7720 * Artificial Fonts::
7721 * Ligatures and Kerning::
7722 @end menu
7724 @c ---------------------------------------------------------------------
7726 @node Changing Fonts, Font Families, Fonts, Fonts
7727 @subsection Changing Fonts
7728 @cindex fonts
7730 @DefreqList {ft, [@Var{font}]}
7731 @DefescItem {\\f, , f, }
7732 @DefescItem {\\f, @lparen{}, fn, }
7733 @DefescListEnd {\\f, @lbrack{}, font, @rbrack}
7734 @cindex changing fonts (@code{ft}, @code{\f})
7735 @cindex fonts, changing (@code{ft}, @code{\f})
7736 @cindex @code{sty} request, and changing fonts
7737 @cindex @code{fam} request, and changing fonts
7738 @cindex @code{\F}, and changing fonts
7739 @kindex styles
7740 @kindex family
7741 @pindex DESC
7742 The @code{ft} request and the @code{\f} escape change the current font
7743 to @var{font} (one-character name@tie{}@var{f}, two-character name
7744 @var{fn}).
7746 If @var{font} is a style name (as set with the @code{sty} request or
7747 with the @code{styles} command in the @file{DESC} file), use it within
7748 the current font family (as set with the @code{fam} request, @code{\F}
7749 escape, or with the @code{family} command in the @file{DESC} file).
7751 @cindex previous font (@code{ft}, @code{\f[]}, @code{\fP})
7752 @cindex font, previous (@code{ft}, @code{\f[]}, @code{\fP})
7753 With no argument or using @samp{P} as an argument, @code{.ft} switches
7754 to the previous font.  Use @code{\f[]} to do this with the escape.  The
7755 old syntax forms @code{\fP} or @code{\f[P]} are also supported.
7757 Fonts are generally specified as upper-case strings, which are usually
7758 1@tie{}to 4 characters representing an abbreviation or acronym of the
7759 font name.  This is no limitation, just a convention.
7761 The example below produces two identical lines.
7763 @Example
7764 eggs, bacon,
7765 .ft B
7766 spam
7768 and sausage.
7770 eggs, bacon, \fBspam\fP and sausage.
7771 @endExample
7773 Note that @code{\f} doesn't produce an input token in @code{gtroff}.
7774 As a consequence, it can be used in requests like @code{mc} (which
7775 expects a single character as an argument) to change the font on
7776 the fly:
7778 @Example
7779 .mc \f[I]x\f[]
7780 @endExample
7782 @xref{Font Positions}, for an alternative syntax.
7783 @endDefreq
7785 @Defreq {ftr, f [@Var{g}]}
7786 @cindex @code{ft} request, and font translations
7787 @cindex @code{ul} request, and font translations
7788 @cindex @code{bd} request, and font translations
7789 @cindex @code{\f}, and font translations
7790 @cindex @code{cs} request, and font translations
7791 @cindex @code{tkf} request, and font translations
7792 @cindex @code{special} request, and font translations
7793 @cindex @code{fspecial} request, and font translations
7794 @cindex @code{fp} request, and font translations
7795 @cindex @code{sty} request, and font translations
7796 Translate font@tie{}@var{f} to font@tie{}@var{g}.  Whenever a font
7797 named@tie{}@var{f} is referred to in a @code{\f} escape sequence, or in the
7798 @code{ft}, @code{ul}, @code{bd}, @code{cs}, @code{tkf},
7799 @code{special}, @code{fspecial}, @code{fp}, or @code{sty} requests,
7800 font@tie{}@var{g} is used.  If @var{g} is missing or equal to@tie{}@var{f}
7801 the translation is undone.
7802 @endDefreq
7804 @c ---------------------------------------------------------------------
7806 @node Font Families, Font Positions, Changing Fonts, Fonts
7807 @subsection Font Families
7808 @cindex font families
7809 @cindex families, font
7810 @cindex font styles
7811 @cindex styles, font
7813 Due to the variety of fonts available, @code{gtroff} has added the
7814 concept of @dfn{font families} and @dfn{font styles}.  The fonts are
7815 specified as the concatenation of the font family and style.  Specifying
7816 a font without the family part causes @code{gtroff} to use that style of
7817 the current family.
7819 @cindex PostScript fonts
7820 @cindex fonts, PostScript
7821 Currently, fonts for the devices @option{-Tps}, @option{-Tdvi}, and
7822 @option{-Tlbp} are set up to this mechanism.
7823 By default, @code{gtroff} uses the Times family with the four styles
7824 @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
7826 This way, it is possible to use the basic four fonts and to select a
7827 different font family on the command line (@pxref{Groff Options}).
7829 @DefreqList {fam, [@Var{family}]}
7830 @DefregItem {.fam}
7831 @DefescItem {\\F, , f, }
7832 @DefescItem {\\F, @lparen{}, fm, }
7833 @DefescItem {\\F, @lbrack{}, family, @rbrack}
7834 @DefregListEnd {.fn}
7835 @cindex changing font family (@code{fam}, @code{\F})
7836 @cindex font family, changing (@code{fam}, @code{\F})
7837 Switch font family to @var{family} (one-character name@tie{}@var{f},
7838 two-character name @var{fm}).  If no argument is given, switch
7839 back to the previous font family.  Use @code{\F[]} to do this with the
7840 escape.  Note that @code{\FP} doesn't work; it selects font family
7841 @samp{P} instead.
7843 The value at start-up is @samp{T}.
7844 The current font family is available in the read-only number register
7845 @samp{.fam} (this is a string-valued register); it is associated with
7846 the current environment.
7848 @Example
7849 spam,
7850 .fam H    \" helvetica family
7851 spam,     \" used font is family H + style R = HR
7852 .ft B     \" family H + style B = font HB
7853 spam,
7854 .fam T    \" times family
7855 spam,     \" used font is family T + style B = TB
7856 .ft AR    \" font AR (not a style)
7857 baked beans,
7858 .ft R     \" family T + style R = font TR
7859 and spam.
7860 @endExample
7862 Note that @code{\F} doesn't produce an input token in @code{gtroff}.
7863 As a consequence, it can be used in requests like @code{mc} (which
7864 expects a single character as an argument) to change the font family on
7865 the fly:
7867 @Example
7868 .mc \F[P]x\F[]
7869 @endExample
7871 The @samp{.fn} register contains the current @dfn{real font name}
7872 of the current font.
7873 This is a string-valued register.
7874 If the current font is a style, the value of @code{\n[.fn]}
7875 is the proper concatenation of family and style name.
7876 @endDefreq
7878 @Defreq {sty, n style}
7879 @cindex changing font style (@code{sty})
7880 @cindex font style, changing (@code{sty})
7881 @cindex @code{cs} request, and font styles
7882 @cindex @code{bd} request, and font styles
7883 @cindex @code{tkf} request, and font styles
7884 @cindex @code{uf} request, and font styles
7885 @cindex @code{fspecial} request, and font styles
7886 Associate @var{style} with font position@tie{}@var{n}.  A font position
7887 can be associated either with a font or with a style.  The current
7888 font is the index of a font position and so is also either a font or a
7889 style.  If it is a style, the font that is actually used is the font
7890 which name is the concatenation of the name of the current
7891 family and the name of the current style.  For example, if the current
7892 font is@tie{}1 and font position@tie{}1 is associated with style
7893 @samp{R} and the current font family is @samp{T}, then font
7894 @samp{TR} will be used.  If the current font is not a style, then the
7895 current family is ignored.  If the requests @code{cs}, @code{bd},
7896 @code{tkf}, @code{uf}, or @code{fspecial} are applied to a style,
7897 they will instead be applied to the member of the current family
7898 corresponding to that style.
7900 @var{n}@tie{}must be a non-negative integer value.
7902 @pindex DESC
7903 @kindex styles
7904 The default family can be set with the @option{-f} option
7905 (@pxref{Groff Options}).  The @code{styles} command in the @file{DESC}
7906 file controls which font positions (if any) are initially associated
7907 with styles rather than fonts.  For example, the default setting for
7908 @sc{PostScript} fonts
7910 @Example
7911 styles R I B BI
7912 @endExample
7914 @noindent
7915 is equivalent to
7917 @Example
7918 .sty 1 R
7919 .sty 2 I
7920 .sty 3 B
7921 .sty 4 BI
7922 @endExample
7924 @code{fam} and @code{\F} always check whether the current font position
7925 is valid; this can give surprising results if the current font position is
7926 associated with a style.
7928 In the following example, we want to access the @sc{PostScript} font
7929 @code{FooBar} from the font family @code{Foo}:
7931 @Example
7932 .sty \n[.fp] Bar
7933 .fam Foo
7934     @result{} warning: can't find font `FooR'
7935 @endExample
7937 @noindent
7938 The default font position at start-up is@tie{}1; for the
7939 @sc{PostScript} device, this is associated with style @samp{R}, so
7940 @code{gtroff} tries to open @code{FooR}.
7942 A solution to this problem is to use a dummy font like the following:
7944 @Example
7945 .fp 0 dummy TR    \" set up dummy font at position 0
7946 .sty \n[.fp] Bar  \" register style `Bar'
7947 .ft 0             \" switch to font at position 0
7948 .fam Foo          \" activate family `Foo'
7949 .ft Bar           \" switch to font `FooBar'
7950 @endExample
7952 @xref{Font Positions}.
7953 @endDefreq
7955 @c ---------------------------------------------------------------------
7957 @node Font Positions, Using Symbols, Font Families, Fonts
7958 @subsection Font Positions
7959 @cindex font positions
7960 @cindex positions, font
7962 For the sake of old phototypesetters and compatibility with old versions
7963 of @code{troff}, @code{gtroff} has the concept of font @dfn{positions},
7964 on which various fonts are mounted.
7966 @DefreqList {fp, pos font [@Var{external-name}]}
7967 @DefregItem {.f}
7968 @DefregListEnd {.fp}
7969 @cindex mounting font (@code{fp})
7970 @cindex font, mounting (@code{fp})
7971 Mount font @var{font} at position @var{pos} (which must be a
7972 non-negative integer).  This numeric position can then be referred to
7973 with font changing commands.  When @code{gtroff} starts it is using
7974 font position@tie{}1 (which must exist; position@tie{}0 is unused
7975 usually at start-up).
7977 @cindex font position register (@code{.f})
7978 The current font in use, as a font position, is available in the
7979 read-only number register @samp{.f}.  This can be useful to remember the
7980 current font for later recall.  It is associated with the current
7981 environment (@pxref{Environments}).
7983 @Example
7984 .nr save-font \n[.f]
7985 .ft B
7986 ... text text text ...
7987 .ft \n[save-font]
7988 @endExample
7990 @cindex next free font position register (@code{.fp})
7991 The number of the next free font position is available in the read-only
7992 number register @samp{.fp}.  This is useful when mounting a new font,
7993 like so:
7995 @Example
7996 .fp \n[.fp] NEATOFONT
7997 @endExample
7999 @pindex DESC@r{, and font mounting}
8000 Fonts not listed in the @file{DESC} file are automatically mounted on
8001 the next available font position when they are referenced.  If a font
8002 is to be mounted explicitly with the @code{fp} request on an unused
8003 font position, it should be mounted on the first unused font position,
8004 which can be found in the @code{.fp} register.  Although @code{gtroff}
8005 does not enforce this strictly, it is not allowed to mount a font at a
8006 position whose number is much greater (approx.@: 1000 positions) than
8007 that of any currently used position.
8009 The @code{fp} request has an optional third argument.  This argument
8010 gives the external name of the font, which is used for finding the font
8011 description file.  The second argument gives the internal name of the
8012 font which is used to refer to the font in @code{gtroff} after it has
8013 been mounted.  If there is no third argument then the internal name is
8014 used as the external name.  This feature makes it possible to use
8015 fonts with long names in compatibility mode.
8016 @endDefreq
8018 Both the @code{ft} request and the @code{\f} escape have alternative
8019 syntax forms to access font positions.
8021 @DefreqList {ft, nnn}
8022 @DefescItem {\\f, , n, }
8023 @DefescItem {\\f, @lparen{}, nn, }
8024 @DefescListEnd {\\f, @lbrack{}, nnn, @rbrack}
8025 @cindex changing font position (@code{\f})
8026 @cindex font position, changing (@code{\f})
8027 @cindex @code{sty} request, and font positions
8028 @cindex @code{fam} request, and font positions
8029 @cindex @code{\F}, and font positions
8030 @kindex styles
8031 @kindex family
8032 @pindex DESC
8033 Change the current font position to @var{nnn} (one-digit
8034 position@tie{}@var{n}, two-digit position @var{nn}), which must be a
8035 non-negative integer.
8037 If @var{nnn} is associated with a style (as set with the @code{sty}
8038 request or with the @code{styles} command in the @file{DESC} file), use
8039 it within the current font family (as set with the @code{fam} request,
8040 the @code{\F} escape, or with the @code{family} command in the @file{DESC}
8041 file).
8043 @Example
8044 this is font 1
8045 .ft 2
8046 this is font 2
8047 .ft                   \" switch back to font 1
8048 .ft 3
8049 this is font 3
8051 this is font 1 again
8052 @endExample
8054 @xref{Changing Fonts}, for the standard syntax form.
8055 @endDefreq
8057 @c ---------------------------------------------------------------------
8059 @node Using Symbols, Special Fonts, Font Positions, Fonts
8060 @subsection Using Symbols
8061 @cindex using symbols
8062 @cindex symbols, using
8064 @cindex glyph
8065 @cindex character
8066 @cindex ligature
8067 A @dfn{glyph} is a graphical representation of a @dfn{character}.
8068 While a character is an abstract entity containing semantic
8069 information, a glyph is something which can be actually seen on screen
8070 or paper.  It is possible that a character has multiple glyph
8071 representation forms (for example, the character `A' can be either
8072 written in a roman or an italic font, yielding two different glyphs);
8073 sometimes more than one character maps to a single glyph (this is a
8074 @dfn{ligature} -- the most common is `fi').
8076 @cindex symbol
8077 @cindex special fonts
8078 @kindex fonts
8079 @pindex DESC
8080 @cindex @code{special} request, and glyph search order
8081 @cindex @code{fspecial} request, and glyph search order
8082 A @dfn{symbol} is simply a named glyph.  Within @code{gtroff}, all
8083 glyph names of a particular font are defined in its font file.  If the
8084 user requests a glyph not available in this font, @code{gtroff} looks
8085 up an ordered list of @dfn{special fonts}.  By default, the
8086 @sc{PostScript} output device supports the two special fonts @samp{SS}
8087 (slanted symbols) and @samp{S} (symbols) (the former is looked up
8088 before the latter).  Other output devices use different names for
8089 special fonts.  Fonts mounted with the @code{fonts} keyword in the
8090 @file{DESC} file are globally available.  To install additional
8091 special fonts locally (i.e.@: for a particular font), use the
8092 @code{fspecial} request.
8094 Here the exact rules how @code{gtroff} searches a given symbol:
8096 @itemize @bullet
8097 @item
8098 If the symbol has been defined with the @code{char} request, use it.
8099 This hides a symbol with the same name in the current font.
8101 @item
8102 Check the current font.
8104 @item
8105 If the symbol has been defined with the @code{fchar} request, use it.
8107 @item
8108 Check whether the current font has a font-specific list of special fonts;
8109 test all fonts in the order of appearance in the last @code{fspecial}
8110 call if appropriate.
8112 @item
8113 If the symbol has been defined with the @code{fschar} request for the
8114 current font, use it.
8116 @item
8117 Check all fonts in the order of appearance in the last @code{special}
8118 call.
8120 @item
8121 If the symbol has been defined with the @code{schar} request, use it.
8123 @item
8124 As a last resort, consult all fonts loaded up to now for special fonts
8125 and check them, starting with the lowest font number.  Note that this can
8126 sometimes lead to surprising results since the @code{fonts} line in the
8127 @file{DESC} file often contains empty positions which are filled later
8128 on.  For example, consider the following:
8130 @Example
8131 fonts 3 0 0 FOO
8132 @endExample
8134 @noindent
8135 This mounts font @code{foo} at font position@tie{}3.  We assume that
8136 @code{FOO} is a special font, containing glyph @code{foo},
8137 and that no font has been loaded yet.  The line
8139 @Example
8140 .fspecial BAR BAZ
8141 @endExample
8143 @noindent
8144 makes font @code{BAZ} special only if font @code{BAR} is active.  We
8145 further assume that @code{BAZ} is really a special font, i.e., the font
8146 description file contains the @code{special} keyword, and that it
8147 also contains glyph @code{foo} with a special shape fitting to font
8148 @code{BAR}.  After executing @code{fspecial}, font @code{BAR} is loaded at
8149 font position@tie{}1, and @code{BAZ} at position@tie{}2.
8151 We now switch to a new font @code{XXX}, trying to access glyph @code{foo}
8152 which is assumed to be missing.  There are neither font-specific special
8153 fonts for @code{XXX} nor any other fonts made special with the
8154 @code{special} request, so @code{gtroff} starts the search for special
8155 fonts in the list of already mounted fonts, with increasing font
8156 positions.  Consequently, it finds @code{BAZ} before @code{FOO} even for
8157 @code{XXX} which is not the intended behaviour.
8158 @end itemize
8160 @xref{Font Files}, and @ref{Special Fonts}, for more details.
8162 @DefescList {\\, @lparen{}, nm, }
8163 @DefescListEnd {\\, @lbrack{}, name, @rbrack}
8164 Insert a symbol @var{name} (two-character name @var{nm}).  There is no
8165 special syntax for one-character names -- the natural form
8166 @samp{\@var{n}} would collide with escapes.@footnote{Note that a
8167 one-character symbol is not the same as an input character, i.e., the
8168 character @code{a} is not the same as @code{\[a]}.  By default,
8169 @code{groff} defines only a single one-character symbol, @code{\[-]};
8170 it is usually accessed as @code{\-}.  On the other hand, @code{gtroff}
8171 has the special feature that @code{\[char@var{XXX}]} is the same as the
8172 input character with character code @var{XXX}.  For example,
8173 @code{\[char97]} is identical to the letter @code{a} if @acronym{ASCII}
8174 encoding is active.}
8176 If @var{name} is undefined, a warning of type @samp{char} is generated,
8177 and the escape is ignored.  @xref{Debugging}, for information about
8178 warnings.
8180 @cindex list of available glyphs (@cite{groff_char(7)} man page)
8181 @cindex available glyphs, list (@cite{groff_char(7)} man page)
8182 @cindex glyphs, available, list (@cite{groff_char(7)} man page)
8183 The list of available symbols is device dependent; see the
8184 @cite{groff_char(7)} man page for a complete list for the given output
8185 device.  For example, say
8187 @Example
8188 man -Tdvi groff_char > groff_char.dvi
8189 @endExample
8191 @noindent
8192 for a list using the default DVI fonts (not all versions of the
8193 @code{man} program support the @option{-T} option).  If you want to
8194 use an additional macro package to change the used fonts, @code{groff}
8195 must be called directly:
8197 @Example
8198 groff -Tdvi -mec -man groff_char.7 > groff_char.dvi
8199 @endExample
8201 @c XXX list of common symbols
8202 @endDefesc
8204 @Defesc {\\C, ', xxx, '}
8205 @cindex named character (@code{\C})
8206 @cindex character, named (@code{\C})
8207 Typeset the glyph named @var{xxx}.@footnote{@code{\C} is actually a
8208 misnomer since it accesses an output glyph.}  Normally it is more
8209 convenient to use @code{\[@var{xxx}]}, but @code{\C} has the advantage
8210 that it is compatible with newer versions of @acronym{AT&T}
8211 @code{troff} and is available in compatibility mode.
8212 @endDefesc
8214 @Defesc {\\N, ', n, '}
8215 @cindex numbered glyph (@code{\N})
8216 @cindex glyph, numbered (@code{\N})
8217 @cindex @code{char} request, used with @code{\N}
8218 @cindex Unicode
8219 Typeset the glyph with code@tie{}@var{n} in the current font
8220 (@code{n}@tie{}is @strong{not} the input character code).  The
8221 number @var{n}@tie{}can be any non-negative decimal integer.  Most devices
8222 only have glyphs with codes between 0 and@tie{}255; the Unicode
8223 output device uses codes in the range 0--65535.  If the current
8224 font does not contain a glyph with that code, special fonts are
8225 @emph{not} searched.  The @code{\N} escape sequence can be
8226 conveniently used in conjunction with the @code{char} request:
8228 @Example
8229 .char \[phone] \f[ZD]\N'37'
8230 @endExample
8232 @noindent
8233 @pindex DESC
8234 @cindex unnamed glyphs
8235 @cindex glyphs, unnamed
8236 The code of each glyph is given in the fourth column in the font
8237 description file after the @code{charset} command.  It is possible to
8238 include unnamed glyphs in the font description file by using a
8239 name of @samp{---}; the @code{\N} escape sequence is the only way to
8240 use these.
8242 No kerning is applied to glyphs accessed with @code{\N}.
8243 @endDefesc
8245 Some escape sequences directly map onto special glyphs.
8247 @Defesc {\\', , , }
8248 This is a backslash followed by the apostrophe character, @acronym{ASCII}
8249 character @code{0x27} (@acronym{EBCDIC} character @code{0x7D}).  The same
8250 as @code{\[aa]}, the acute accent.
8251 @endDefesc
8253 @Defesc {\\`, , , }
8254 This is a backslash followed by @acronym{ASCII} character @code{0x60}
8255 (@acronym{EBCDIC} character @code{0x79} usually).  The same as
8256 @code{\[ga]}, the grave accent.
8257 @endDefesc
8259 @Defesc {\\-, , , }
8260 This is the same as @code{\[-]}, the minus sign in the current font.
8261 @endDefesc
8263 @Defreq {cflags, n c1 c2 @dots{}}
8264 @cindex glyph properties (@code{cflags})
8265 @cindex character properties (@code{cflags})
8266 @cindex properties of glyphs (@code{cflags})
8267 @cindex properties of characters (@code{cflags})
8268 Input characters and symbols have certain properties associated
8269 with it.@footnote{Note that the output glyphs themselves don't have
8270 such properties.  For @code{gtroff}, a glyph is a numbered box with
8271 a given width, depth, and height, nothing else.  All manipulations
8272 with the @code{cflags} request work on the input level.}  These
8273 properties can be modified with the @code{cflags} request.  The
8274 first argument is the sum of the desired flags and the remaining
8275 arguments are the characters or symbols to have those properties.
8276 It is possible to omit the spaces between the characters or symbols.
8278 @table @code
8279 @item 1
8280 @cindex end-of-sentence characters
8281 @cindex characters, end-of-sentence
8282 The character ends sentences (initially characters @samp{.?!} have this
8283 property).
8285 @item 2
8286 @cindex hyphenating characters
8287 @cindex characters, hyphenation
8288 Lines can be broken before the character (initially no characters have
8289 this property).
8291 @item 4
8292 @cindex @code{hy} glyph, and @code{cflags}
8293 @cindex @code{em} glyph, and @code{cflags}
8294 Lines can be broken after the character (initially the character
8295 @samp{-} and the symbols @samp{\[hy]} and @samp{\[em]} have this property).
8297 @item 8
8298 @cindex overlapping characters
8299 @cindex characters, overlapping
8300 @cindex @code{ul} glyph, and @code{cflags}
8301 @cindex @code{rn} glyph, and @code{cflags}
8302 @cindex @code{ru} glyph, and @code{cflags}
8303 @cindex @code{radicalex} glyph, and @code{cflags}
8304 @cindex @code{sqrtex} glyph, and @code{cflags}
8305 The character overlaps horizontally (initially the symbols
8306 @samp{\[ul]}, @samp{\[rn]}, @samp{\[ru]}, @samp{\[radicalex}, and
8307 @samp{\[sqrtex]} have this property).
8309 @item 16
8310 @cindex @code{br} glyph, and @code{cflags}
8311 The character overlaps vertically (initially symbol @samp{\[br]} has
8312 this property).
8314 @item 32
8315 @cindex transparent characters
8316 @cindex character, transparent
8317 @cindex @code{"}, at end of sentence
8318 @cindex @code{'}, at end of sentence
8319 @cindex @code{)}, at end of sentence
8320 @cindex @code{]}, at end of sentence
8321 @cindex @code{*}, at end of sentence
8322 @cindex @code{dg} glyph, at end of sentence
8323 @cindex @code{rq} glyph, at end of sentence
8324 An end-of-sentence character followed by any number of characters with
8325 this property is treated as the end of a sentence if followed by a
8326 newline or two spaces; in other words the character is
8327 @dfn{transparent} for the purposes of end-of-sentence recognition --
8328 this is the same as having a zero space factor in @TeX{} (initially
8329 characters @samp{"')]*} and the symbols @samp{\[dg]} and @samp{\[rq]} have
8330 this property).
8331 @end table
8332 @endDefreq
8334 @DefreqList {char, g [@Var{string}]}
8335 @DefreqItem {fchar, g [@Var{string}]}
8336 @DefreqItem {fschar, f g [@Var{string}]}
8337 @DefreqListEnd {schar, g [@Var{string}]}
8338 @cindex defining character (@code{char})
8339 @cindex defining fallback character (@code{fchar}, @code{fschar}, @code{schar})
8340 @cindex character, defining (@code{char})
8341 @cindex character, defining fallback (@code{fchar}, @code{fschar}, @code{schar})
8342 @cindex fallback character, defining (@code{fchar}, @code{fschar}, @code{schar})
8343 @cindex creating new characters (@code{char})
8344 @cindex defining symbol (@code{char})
8345 @cindex symbol, defining (@code{char})
8346 @cindex defining glyph (@code{char})
8347 @cindex glyph, defining (@code{char})
8348 @cindex escape character, while defining glyph
8349 @cindex character, escape, while defining glyph
8350 @cindex @code{tr} request, and glyph definitions
8351 @cindex @code{cp} request, and glyph definitions
8352 @cindex @code{rc} request, and glyph definitions
8353 @cindex @code{lc} request, and glyph definitions
8354 @cindex @code{\l}, and glyph definitions
8355 @cindex @code{\L}, and glyph definitions
8356 @cindex @code{\&}, and glyph definitions
8357 @cindex @code{\e}, and glyph definitions
8358 @cindex @code{hcode} request, and glyph definitions
8359 Define a new glyph@tie{}@var{g} to be @var{string} (which can be
8360 empty).@footnote{@code{char} is a misnomer since an output glyph is
8361 defined.}  Every time glyph@tie{}@var{g} needs to be printed,
8362 @var{string} is processed in a temporary environment and the result is
8363 wrapped up into a single object.  Compatibility mode is turned off and
8364 the escape character is set to @samp{\} while @var{string} is being
8365 processed.  Any emboldening, constant spacing or track kerning is
8366 applied to this object rather than to individual characters in
8367 @var{string}.
8369 A glyph defined by these requests can be used just
8370 like a normal glyph provided by the output device.  In particular,
8371 other characters can be translated to it with the @code{tr} or
8372 @code{trin} requests; it can be made the leader character by the
8373 @code{lc} request; repeated patterns can be drawn with the glyph
8374 using the @code{\l} and @code{\L} escape sequences; words containing
8375 the glyph can be hyphenated correctly if the @code{hcode} request
8376 is used to give the glyph's symbol a hyphenation code.
8378 There is a special anti-recursion feature: Use of @code{g} within
8379 the glyph's definition is handled like normal characters and symbols
8380 not defined with @code{char}.
8382 Note that the @code{tr} and @code{trin} requests take precedence if
8383 @code{char} accesses the same symbol.
8385 @Example
8386 .tr XY
8388     @result{} Y
8389 .char X Z
8391     @result{} Y
8392 .tr XX
8394     @result{} Z
8395 @endExample
8397 The @code{fchar} request defines a fallback glyph:
8398 @code{gtroff} only checks for glyphs defined with @code{fchar}
8399 if it cannot find the glyph in the current font.
8400 @code{gtroff} carries out this test before checking special fonts.
8402 @code{fschar} defines a fallback glyph for font@tie{}@var{f}: @code{gtroff}
8403 checks for glyphs defined with @code{fschar} after the list of fonts
8404 declared as font-specific special fonts with the @code{fspecial} request,
8405 but before the list of fonts declared as global special fonts with the
8406 @code{special} request.
8408 Finally, the @code{schar} request defines a global fallback glyph:
8409 @code{gtroff} checks for glyphs defined with @code{schar} after the list
8410 of fonts declared as global special fonts with the @code{special} request,
8411 but before the already mounted special fonts.
8413 @xref{Using Symbols}, for a detailed description of the glyph
8414 searching mechanism in @code{gtroff}.
8415 @endDefreq
8417 @DefreqList {rchar, c1 c2 @dots{}}
8418 @DefreqListEnd {rfschar, f c1 c2 @dots{}}
8419 @cindex removing glyph definition (@code{rchar}, @code{rfschar})
8420 @cindex glyph, removing definition (@code{rchar}, @code{rfschar})
8421 @cindex fallback glyph, removing definition (@code{rchar}, @code{rfschar})
8422 Remove the definitions of glyphs @var{c1}, @var{c2},@tie{}@enddots{}
8423 This undoes the effect of a @code{char}, @code{fchar}, or
8424 @code{schar} request.
8426 It is possible to omit the whitespace between arguments.
8428 The request @code{rfschar} removes glyph definitions defined with
8429 @code{fschar} for glyph@tie{}f.
8430 @endDefreq
8432 @xref{Special Characters}.
8434 @c ---------------------------------------------------------------------
8436 @node Special Fonts, Artificial Fonts, Using Symbols, Fonts
8437 @subsection Special Fonts
8438 @cindex special fonts
8439 @cindex fonts, special
8441 Special fonts are those that @code{gtroff} searches
8442 when it cannot find the requested glyph in the current font.
8443 The Symbol font is usually a special font.
8445 @code{gtroff} provides the following two requests to add more special
8446 fonts.  @xref{Using Symbols}, for a detailed description of the glyph
8447 searching mechanism in @code{gtroff}.
8449 Usually, only non-TTY devices have special fonts.
8451 @DefreqList {special, [@Var{s1} @Var{s2} @dots{}]}
8452 @DefreqListEnd {fspecial, f [@Var{s1} @Var{s2} @dots{}]}
8453 @kindex fonts
8454 @pindex DESC
8455 Use the @code{special} request to define special fonts.  Initially, this
8456 list is empty.
8458 Use the @code{fspecial} request to designate special fonts only when
8459 font@tie{}@var{f} is active.  Initially, this list is empty.
8461 Previous calls to @code{special} or @code{fspecial} are overwritten;
8462 without arguments, the particular list of special fonts is set to empty.
8463 Special fonts are searched in the order they appear as arguments.
8465 All fonts which appear in a call to @code{special} or @code{fspecial} are
8466 loaded.
8468 @xref{Using Symbols}, for the exact search order of glyphs.
8469 @endDefreq
8471 @c ---------------------------------------------------------------------
8473 @node Artificial Fonts, Ligatures and Kerning, Special Fonts, Fonts
8474 @subsection Artificial Fonts
8475 @cindex artificial fonts
8476 @cindex fonts, artificial
8478 There are a number of requests and escapes for artificially creating
8479 fonts.  These are largely vestiges of the days when output devices
8480 did not have a wide variety of fonts, and when @code{nroff} and
8481 @code{troff} were separate programs.  Most of them are no longer
8482 necessary in GNU @code{troff}.  Nevertheless, they are supported.
8484 @DefescList {\\H, ', height, '}
8485 @DefescItem {\\H, ', @t{+}@Var{height}, '}
8486 @DefescListEnd {\\H, ', @t{-}@Var{height}, '}
8487 @cindex changing the font height (@code{\H})
8488 @cindex font height, changing (@code{\H})
8489 @cindex height, font, changing (@code{\H})
8490 Change (increment, decrement) the height of the current font, but not
8491 the width.  If @var{height} is zero, restore the original height.
8492 Default scaling indicator is @samp{z}.
8494 Currently, only the @option{-Tps} device supports this feature.
8496 Note that @code{\H} doesn't produce an input token in @code{gtroff}.
8497 As a consequence, it can be used in requests like @code{mc} (which
8498 expects a single character as an argument) to change the font on
8499 the fly:
8501 @Example
8502 .mc \H'+5z'x\H'0'
8503 @endExample
8505 In compatibility mode, @code{gtroff} behaves differently:  If an
8506 increment or decrement is used, it is always taken relative to the
8507 current point size and not relative to the previously selected font
8508 height.  Thus,
8510 @Example
8511 .cp 1
8512 \H'+5'test \H'+5'test
8513 @endExample
8515 @noindent
8516 prints the word @samp{test} twice with the same font height (five
8517 points larger than the current font size).
8518 @endDefesc
8520 @DefescList {\\S, ', slant, '}
8521 @cindex changing the font slant (@code{\S})
8522 @cindex font slant, changing (@code{\S})
8523 @cindex slant, font, changing (@code{\S})
8524 Slant the current font by @var{slant} degrees.  Positive values slant
8525 to the right.
8527 Currently, only the @option{-Tps} device supports this feature.
8529 Note that @code{\S} doesn't produce an input token in @code{gtroff}.
8530 As a consequence, it can be used in requests like @code{mc} (which
8531 expects a single character as an argument) to change the font on
8532 the fly:
8534 @Example
8535 .mc \S'20'x\S'0'
8536 @endExample
8538 This request is incorrectly documented in the original @acronym{UNIX}
8539 troff manual; the slant is always set to an absolute value.
8540 @endDefesc
8542 @Defreq {ul, [@Var{lines}]}
8543 @cindex underlining (@code{ul})
8544 The @code{ul} request normally underlines subsequent lines if a TTY
8545 output device is used.  Otherwise, the lines are printed in italics
8546 (only the term `underlined' is used in the following).  The single
8547 argument is the number of input lines to be underlined; with no
8548 argument, the next line is underlined.  If @var{lines} is zero or
8549 negative, stop the effects of @code{ul} (if it was active).  Requests
8550 and empty lines do not count for computing the number of underlined
8551 input lines, even if they produce some output like @code{tl}.  Lines
8552 inserted by macros (e.g.@: invoked by a trap) do count.
8554 At the beginning of @code{ul}, the current font is stored and the
8555 underline font is activated.  Within the span of a @code{ul} request,
8556 it is possible to change fonts, but after the last line affected by
8557 @code{ul} the saved font is restored.
8559 This number of lines still to be underlined is associated with the
8560 current environment (@pxref{Environments}).  The underline font can be
8561 changed with the @code{uf} request.
8563 @c XXX @xref should be changed to grotty
8565 @c @xref{Troff and Nroff Mode}, for a discussion how underlining is
8566 @c implemented in for TTY output devices, and which problems can arise.
8568 The @code{ul} request does not underline spaces.
8569 @endDefreq
8571 @Defreq {cu, [@Var{lines}]}
8572 @cindex continuous underlining (@code{cu})
8573 @cindex underlining, continuous (@code{cu})
8574 The @code{cu} request is similar to @code{ul} but underlines spaces as
8575 well (if a TTY output device is used).
8576 @endDefreq
8578 @Defreq {uf, font}
8579 @cindex underline font (@code{uf})
8580 @cindex font for underlining (@code{uf})
8581 Set the underline font (globally) used by @code{ul} and @code{cu}.  By
8582 default, this is the font at position@tie{}2.  @var{font} can be either
8583 a non-negative font position or the name of a font.
8584 @endDefreq
8586 @DefreqList {bd, font [@Var{offset}]}
8587 @DefreqItem {bd, font1 font2 [@Var{offset}]}
8588 @DefregListEnd {.b}
8589 @cindex imitating bold face (@code{bd})
8590 @cindex bold face, imitating (@code{bd})
8591 Artificially create a bold font by printing each glyph twice,
8592 slightly offset.
8594 Two syntax forms are available.
8596 @itemize @bullet
8597 @item
8598 Imitate a bold font unconditionally.  The first argument specifies the
8599 font to embolden, and the second is the number of basic units, minus
8600 one, by which the two glyphs are offset.  If the second argument is
8601 missing, emboldening is turned off.
8603 @var{font} can be either a non-negative font position or the name of a
8604 font.
8606 @var{offset} is available in the @code{.b} read-only register if a
8607 special font is active; in the @code{bd} request, its default unit is
8608 @samp{u}.
8610 @cindex @code{fspecial} request, and imitating bold
8611 @kindex special
8612 @cindex embolding of special fonts
8613 @cindex special fonts, emboldening
8614 @item
8615 Imitate a bold form conditionally.  Embolden @var{font1} by
8616 @var{offset} only if font @var{font2} is the current font.  This
8617 command can be issued repeatedly to set up different emboldening
8618 values for different current fonts.  If the second argument is
8619 missing, emboldening is turned off for this particular current font.
8621 This affects special fonts only (either set up with the @code{special}
8622 command in font files or with the @code{fspecial} request).
8623 @end itemize
8624 @endDefreq
8626 @Defreq {cs, font [@Var{width} [@Var{em-size}]]}
8627 @cindex constant glyph space mode (@code{cs})
8628 @cindex mode for constant glyph space (@code{cs})
8629 @cindex glyph, constant space
8630 @cindex @code{ps} request, and constant glyph space mode
8631 Switch to and from @dfn{constant glyph space mode}.  If activated, the
8632 width of every glyph is @math{@var{width}/36} ems.  The em size is
8633 given absolutely by @var{em-size}; if this argument is missing, the em
8634 value is taken from the current font size (as set with the @code{ps}
8635 request) when the font is effectively in use.  Without second and
8636 third argument, constant glyph space mode is deactivated.
8638 Default scaling indicator for @var{em-size} is @samp{z}; @var{width} is
8639 an integer.
8640 @endDefreq
8642 @c ---------------------------------------------------------------------
8644 @node Ligatures and Kerning,  , Artificial Fonts, Fonts
8645 @subsection Ligatures and Kerning
8646 @cindex ligatures and kerning
8647 @cindex kerning and ligatures
8649 Ligatures are groups of characters that are run together, i.e, producing
8650 a single glyph.  For example, the letters `f' and `i' can form a
8651 ligature `fi' as in the word `file'.  This produces a cleaner look
8652 (albeit subtle) to the printed output.  Usually, ligatures are not
8653 available in fonts for TTY output devices.
8655 Most @sc{PostScript} fonts support the fi and fl ligatures.  The C/A/T
8656 typesetter that was the target of @acronym{AT&T} @code{troff} also
8657 supported `ff', `ffi', and `ffl' ligatures.  Advanced typesetters or
8658 `expert' fonts may include ligatures for `ft' and `ct', although GNU
8659 @code{troff} does not support these (yet).
8661 Only the current font is checked for ligatures and kerns; neither special
8662 fonts nor entities defined with the @code{char} request (and its siblings)
8663 are taken into account.
8665 @DefreqList {lg, [@Var{flag}]}
8666 @DefregListEnd {.lg}
8667 @cindex activating ligatures (@code{lg})
8668 @cindex ligatures, activating (@code{lg})
8669 @cindex ligatures enabled register (@code{.lg})
8670 Switch the ligature mechanism on or off; if the parameter is non-zero
8671 or missing, ligatures are enabled, otherwise disabled.  Default is on.
8672 The current ligature mode can be found in the read-only number register
8673 @code{.lg} (set to 1 or@tie{}2 if ligatures are enabled, 0@tie{}otherwise).
8675 Setting the ligature mode to@tie{}2 enables the two-character ligatures
8676 (fi, fl, and ff) and disables the three-character ligatures (ffi and
8677 ffl).
8678 @endDefreq
8680 @dfn{Pairwise kerning} is another subtle typesetting mechanism that
8681 modifies the distance between a glyph pair to improve readability.
8682 In most cases (but not always) the distance is decreased.
8683 @ifnotinfo
8684 For example, compare the combination of the letters `V' and `A'.  With
8685 kerning, `VA' is printed.  Without kerning it appears as `V@w{}A'.
8686 @end ifnotinfo
8687 Typewriter-like fonts and fonts for terminals where all glyphs
8688 have the same width don't use kerning.
8690 @DefreqList {kern, [@Var{flag}]}
8691 @DefregListEnd {.kern}
8692 @cindex activating kerning (@code{kern})
8693 @cindex kerning, activating (@code{kern})
8694 @cindex kerning enabled register (@code{.kern})
8695 Switch kerning on or off.  If the parameter is non-zero or missing,
8696 enable pairwise kerning, otherwise disable it.  The read-only number
8697 register @code{.kern} is set to@tie{}1 if pairwise kerning is enabled,
8698 0@tie{}otherwise.
8700 @cindex zero width space character (@code{\&})
8701 @cindex character, zero width space (@code{\&})
8702 @cindex space character, zero width (@code{\&})
8703 If the font description file contains pairwise kerning information,
8704 glyphs from that font are kerned.  Kerning between two glyphs
8705 can be inhibited by placing @code{\&} between them: @samp{V\&A}.
8707 @xref{Font File Format}.
8708 @endDefreq
8710 @cindex track kerning
8711 @cindex kerning, track
8712 @dfn{Track kerning} expands or reduces the space between glyphs.
8713 This can be handy, for example, if you need to squeeze a long word
8714 onto a single line or spread some text to fill a narrow column.  It
8715 must be used with great care since it is usually considered bad
8716 typography if the reader notices the effect.
8718 @Defreq {tkf, f s1 n1 s2 n2}
8719 @cindex activating track kerning (@code{tkf})
8720 @cindex track kerning, activating (@code{tkf})
8721 Enable track kerning for font@tie{}@var{f}.  If the current font
8722 is@tie{}@var{f} the width of every glyph is increased by an amount
8723 between @var{n1} and @var{n2} (@var{n1}, @var{n2} can be negative); if
8724 the current point size is less than or equal to @var{s1} the width is
8725 increased by @var{n1}; if it is greater than or equal to @var{s2} the
8726 width is increased by @var{n2}; if the point size is greater than or
8727 equal to @var{s1} and less than or equal to @var{s2} the increase in
8728 width is a linear function of the point size.
8730 The default scaling indicator is @samp{z} for @var{s1} and @var{s2},
8731 @samp{p} for @var{n1} and @var{n2}.
8733 Note that the track kerning amount is added even to the rightmost glyph
8734 in a line; for large values it is thus recommended to increase the line
8735 length by the same amount to compensate it.
8736 @endDefreq
8738 Sometimes, when typesetting letters of different fonts, more or less
8739 space at such boundaries are needed.  There are two escapes to help
8740 with this.
8742 @Defesc {\\/, , , }
8743 @cindex italic correction (@code{\/})
8744 @cindex correction, italic (@code{\/})
8745 @cindex correction between italic and roman glyph (@code{\/}, @code{\,})
8746 @cindex roman glyph, correction after italic glyph (@code{\/})
8747 @cindex italic glyph, correction before roman glyph (@code{\/})
8748 @cindex glyph, italic correction (@code{\/})
8749 Increase the width of the preceding glyph so that the spacing
8750 between that glyph and the following glyph is correct if the
8751 following glyph is a roman glyph.  For example, if an
8752 italic@tie{}@code{f} is immediately followed by a roman right
8753 parenthesis, then in many fonts the top right portion of the@tie{}@code{f}
8754 overlaps the top left of the right parenthesis.  Use this escape
8755 sequence whenever an italic glyph is immediately followed by a
8756 roman glyph without any intervening space.  This small amount of
8757 space is also called @dfn{italic correction}.
8759 @iftex
8760 @example
8761 @group
8762 \f[I]f\f[R])
8763     @result{} {@it f}@r{)}
8764 \f[I]f\/\f[R])
8765     @result{} @i{f}@r{)}
8766 @end group
8767 @end example
8768 @end iftex
8769 @endDefesc
8771 @Defesc {\\\,, , , }
8772 @cindex left italic correction (@code{\,})
8773 @cindex correction, left italic (@code{\,})
8774 @cindex glyph, left italic correction (@code{\,})
8775 @cindex roman glyph, correction before italic glyph (@code{\,})
8776 @cindex italic glyph, correction after roman glyph (@code{\,})
8777 Modify the spacing of the following glyph so that the spacing
8778 between that glyph and the preceding glyph is correct if the
8779 preceding glyph is a roman glyph.  Use this escape sequence
8780 whenever a roman glyph is immediately followed by an italic
8781 glyph without any intervening space.  In analogy to above, this
8782 space could be called @dfn{left italic correction}, but this term
8783 isn't used widely.
8785 @iftex
8786 @example
8787 @group
8788 q\f[I]f
8789     @result{} @r{q}@i{f}
8790 q\,\f[I]f
8791     @result{} @r{q}@math{@ptexcomma}@i{f}
8792 @end group
8793 @end example
8794 @end iftex
8795 @endDefesc
8797 @Defesc {\\&, , , }
8798 Insert a zero-width character, which is invisible.  Its intended use
8799 is to stop interaction of a character with its surrounding.
8801 @itemize @bullet
8802 @item
8803 It prevents the insertion of extra space after an end-of-sentence
8804 character.
8806 @Example
8807 Test.
8808 Test.
8809     @result{} Test.  Test.
8810 Test.\&
8811 Test.
8812     @result{} Test. Test.
8813 @endExample
8815 @item
8816 It prevents interpretation of a control character at the beginning of
8817 an input line.
8819 @Example
8820 .Test
8821     @result{} warning: `Test' not defined
8822 \&.Test
8823     @result{} .Test
8824 @endExample
8826 @item
8827 It prevents kerning between two glyphs.
8829 @ifnotinfo
8830 @example
8831 @group
8833     @result{} @r{VA}
8834 V\&A
8835     @result{} @r{V@w{}A}
8836 @end group
8837 @end example
8838 @end ifnotinfo
8840 @item
8841 It is needed to map an arbitrary character to nothing in the @code{tr}
8842 request (@pxref{Character Translations}).
8843 @end itemize
8844 @endDefesc
8846 @Defesc {\\), , , }
8847 This escape is similar to @code{\&} except that it behaves like a
8848 character declared with the @code{cflags} request to be transparent
8849 for the purposes of an end-of-sentence character.
8851 Its main usage is in macro definitions to protect against arguments
8852 starting with a control character.
8854 @Example
8855 .de xxx
8856 \)\\$1
8858 .de yyy
8859 \&\\$1
8861 This is a test.\c
8862 .xxx '
8863 This is a test.
8864     @result{}This is a test.'  This is a test.
8865 This is a test.\c
8866 .yyy '
8867 This is a test.
8868     @result{}This is a test.' This is a test.
8869 @endExample
8870 @endDefesc
8873 @c =====================================================================
8875 @node Sizes, Strings, Fonts, gtroff Reference
8876 @section Sizes
8877 @cindex sizes
8879 @cindex baseline
8880 @cindex type size
8881 @cindex size of type
8882 @cindex vertical spacing
8883 @cindex spacing, vertical
8884 @code{gtroff} uses two dimensions with each line of text, type size
8885 and vertical spacing.  The @dfn{type size} is approximately the height
8886 of the tallest glyph.@footnote{This is usually the parenthesis.
8887 Note that in most cases the real dimensions of the glyphs in a font
8888 are @emph{not} related to its type size!  For example, the standard
8889 @sc{PostScript} font families `Times Roman', `Helvetica', and
8890 `Courier' can't be used together at 10@dmn{pt}; to get acceptable
8891 output, the size of `Helvetica' has to be reduced by one point, and
8892 the size of `Courier' must be increased by one point.}  @dfn{Vertical
8893 spacing} is the amount of space @code{gtroff} allows for a line of
8894 text; normally, this is about 20%@tie{}larger than the current type
8895 size.  Ratios smaller than this can result in hard-to-read text;
8896 larger than this, it spreads the text out more vertically (useful for
8897 term papers).  By default, @code{gtroff} uses 10@tie{}point type on
8898 12@tie{}point spacing.
8900 @cindex leading
8901 The difference between type size and vertical spacing is known, by
8902 typesetters, as @dfn{leading} (this is pronounced `ledding').
8904 @menu
8905 * Changing Type Sizes::
8906 * Fractional Type Sizes::
8907 @end menu
8909 @c ---------------------------------------------------------------------
8911 @node Changing Type Sizes, Fractional Type Sizes, Sizes, Sizes
8912 @subsection Changing Type Sizes
8914 @DefreqList {ps, [@Var{size}]}
8915 @DefreqItem {ps, @t{+}@Var{size}}
8916 @DefreqItem {ps, @t{-}@Var{size}}
8917 @DefescItem {\\s, , size, }
8918 @DefregListEnd {.s}
8919 @cindex changing type sizes (@code{ps}, @code{\s})
8920 @cindex type sizes, changing (@code{ps}, @code{\s})
8921 @cindex point sizes, changing (@code{ps}, @code{\s})
8922 Use the @code{ps} request or the @code{\s} escape to change (increase,
8923 decrease) the type size (in points).  Specify @var{size} as either an
8924 absolute point size, or as a relative change from the current size.
8925 The size@tie{}0, or no argument, goes back to the previous size.
8927 Default scaling indicator of @code{size} is @samp{z}.  If @code{size}
8928 is zero or negative, it is set to 1@dmn{u}.
8930 @cindex type size registers (@code{.s}, @code{.ps})
8931 @cindex point size registers (@code{.s}, @code{.ps})
8932 The read-only number register @code{.s} returns the point size in
8933 points as a decimal fraction.  This is a string.  To get the point
8934 size in scaled points, use the @code{.ps} register instead.
8936 @code{.s} is associated with the current environment
8937 (@pxref{Environments}).
8939 @Example
8940 snap, snap,
8941 .ps +2
8942 grin, grin,
8943 .ps +2
8944 wink, wink, \s+2nudge, nudge,\s+8 say no more!
8945 .ps 10
8946 @endExample
8948 The @code{\s} escape may be called in a variety of ways.  Much like
8949 other escapes there must be a way to determine where the argument ends
8950 and the text begins.  Any of the following forms are valid:
8952 @table @code
8953 @item \s@var{n}
8954 Set the point size to @var{n}@tie{}points.  @var{n}@tie{}must be either
8955 0 or in the range 4 to@tie{}39.
8957 @item \s+@var{n}
8958 @itemx \s-@var{n}
8959 Increase or decrease the point size by @var{n}@tie{}points.
8960 @var{n}@tie{}must be exactly one digit.
8962 @item \s(@var{nn}
8963 Set the point size to @var{nn}@tie{}points.  @var{nn} must be exactly
8964 two digits.
8966 @item \s+(@var{nn}
8967 @itemx \s-(@var{nn}
8968 @itemx \s(+@var{nn}
8969 @itemx \s(-@var{nn}
8970 Increase or decrease the point size by @var{nn}@tie{}points.  @var{nn}
8971 must be exactly two digits.
8972 @end table
8974 Note that @code{\s} doesn't produce an input token in @code{gtroff}.
8975 As a consequence, it can be used in requests like @code{mc} (which
8976 expects a single character as an argument) to change the font on
8977 the fly:
8979 @Example
8980 .mc \s[20]x\s[0]
8981 @endExample
8983 @xref{Fractional Type Sizes}, for yet another syntactical form of
8984 using the @code{\s} escape.
8985 @endDefreq
8987 @Defreq {sizes, s1 s2 @dots{} sn [0]}
8988 Some devices may only have certain permissible sizes, in which case
8989 @code{gtroff} rounds to the nearest permissible size.
8990 The @file{DESC} file specifies which sizes are permissible for the device.
8992 Use the @code{sizes} request to change the permissible sizes
8993 for the current output device.
8994 Arguments are in scaled points;
8995 the @code{sizescale} line in the
8996 @file{DESC} file for the output device
8997 provides the scaling factor.
8998 For example, if the scaling factor is 1000,
8999 then the value 12000 is 12@tie{}points.
9001 Each argument can be a single point size (such as @samp{12000}),
9002 or a range of sizes (such as @samp{4000-72000}).
9003 You can optionally end the list with a zero.
9004 @endDefreq
9006 @DefreqList {vs, [@Var{space}]}
9007 @DefreqItem {vs, @t{+}@Var{space}}
9008 @DefreqItem {vs, @t{-}@Var{space}}
9009 @DefregListEnd {.v}
9010 @cindex changing vertical line spacing (@code{vs})
9011 @cindex vertical line spacing, changing (@code{vs})
9012 @cindex vertical line spacing register (@code{.v})
9013 Change (increase, decrease) the vertical spacing by @var{space}.  The
9014 default scaling indicator is @samp{p}.
9016 If @code{vs} is called without an argument, the vertical spacing is
9017 reset to the previous value before the last call to @code{vs}.
9019 @cindex @code{.V} register, and @code{vs}
9020 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
9021 zero or negative; the vertical spacing is then set to the vertical
9022 resolution (as given in the @code{.V} register).
9024 The read-only number register @code{.v} contains the current vertical
9025 spacing; it is associated with the current environment
9026 (@pxref{Environments}).
9027 @endDefreq
9029 @cindex vertical line spacing, effective value
9030 The effective vertical line spacing consists of four components.
9032 @itemize @bullet
9033 @item
9034 The vertical line spacing as set with the @code{vs} request.
9036 @cindex post-vertical line spacing
9037 @cindex line spacing, post-vertical (@code{pvs})
9038 @item
9039 The @dfn{post-vertical line spacing} as set with the @code{pvs} request.
9040 This is vertical space which will be added after a line has been
9041 output.
9043 @cindex extra pre-vertical line space (@code{\x})
9044 @cindex line space, extra pre-vertical (@code{\x})
9045 @item
9046 The @dfn{extra pre-vertical line space} as set with the @code{\x} request,
9047 using a negative value.  This is vertical space which will be added once
9048 before the current line has been output.
9050 @cindex extra post-vertical line space (@code{\x})
9051 @cindex line space, extra post-vertical (@code{\x})
9052 @item
9053 The @dfn{extra post-vertical line space} as set with the @code{\x} request,
9054 using a positive value.  This is vertical space which will be added once
9055 after the current line has been output.
9056 @end itemize
9058 @cindex double-spacing (@code{vs}, @code{pvs})
9059 It is usually better to use @code{vs} or @code{pvs} instead of @code{ls}
9060 to produce double-spaced documents: @code{vs} and @code{pvs} have a finer
9061 granularity for the inserted vertical space compared to @code{ls};
9062 furthermore, certain preprocessors assume single-spacing.
9064 @xref{Manipulating Spacing}, for more details on the @code{\x} escape
9065 and the @code{ls} request.
9067 @DefreqList {pvs, [@Var{space}]}
9068 @DefreqItem {pvs, @t{+}@Var{space}}
9069 @DefreqItem {pvs, @t{-}@Var{space}}
9070 @DefregListEnd {.pvs}
9071 @cindex @code{ls} request, alternative to (@code{pvs})
9072 @cindex post-vertical line spacing, changing (@code{pvs})
9073 @cindex post-vertical line spacing register (@code{.pvs})
9074 Change (increase, decrease) the post-vertical spacing by
9075 @var{space}.  The default scaling indicator is @samp{p}.
9077 If @code{pvs} is called without an argument, the post-vertical spacing is
9078 reset to the previous value before the last call to @code{pvs}.
9080 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
9081 zero or negative; the vertical spacing is then set to zero.
9083 The read-only number register @code{.pvs} contains the current
9084 post-vertical spacing; it is associated with the current environment
9085 (@pxref{Environments}).
9086 @endDefreq
9089 @c ---------------------------------------------------------------------
9091 @node Fractional Type Sizes,  , Changing Type Sizes, Sizes
9092 @subsection Fractional Type Sizes
9093 @cindex fractional type sizes
9094 @cindex fractional point sizes
9095 @cindex type sizes, fractional
9096 @cindex point sizes, fractional
9097 @cindex sizes, fractional
9099 @cindex @code{s} unit
9100 @cindex unit, @code{s}
9101 @cindex @code{z} unit
9102 @cindex unit, @code{z}
9103 @cindex @code{ps} request, with fractional type sizes
9104 @cindex @code{cs} request, with fractional type sizes
9105 @cindex @code{tkf} request, with fractional type sizes
9106 @cindex @code{\H}, with fractional type sizes
9107 @cindex @code{\s}, with fractional type sizes
9108 A @dfn{scaled point} is equal to @math{1/@var{sizescale}} points,
9109 where @var{sizescale} is specified in the @file{DESC} file (1@tie{}by
9110 default).  There is a new scale indicator @samp{z} which has the
9111 effect of multiplying by @var{sizescale}.  Requests and escape
9112 sequences in @code{gtroff} interpret arguments that represent a point
9113 size as being in units of scaled points, but they evaluate each such
9114 argument using a default scale indicator of @samp{z}.  Arguments
9115 treated in this way are the argument to the @code{ps} request, the
9116 third argument to the @code{cs} request, the second and fourth
9117 arguments to the @code{tkf} request, the argument to the @code{\H}
9118 escape sequence, and those variants of the @code{\s} escape sequence
9119 that take a numeric expression as their argument (see below).
9121 For example, suppose @var{sizescale} is@tie{}1000; then a scaled point
9122 is equivalent to a millipoint; the request @w{@samp{.ps 10.25}} is
9123 equivalent to @w{@samp{.ps 10.25z}} and thus sets the point size to
9124 10250@tie{}scaled points, which is equal to 10.25@tie{}points.
9126 @code{gtroff} disallows the use of the @samp{z} scale indicator in
9127 instances where it would make no sense, such as a numeric
9128 expression whose default scale indicator was neither @samp{u} nor
9129 @samp{z}.  Similarly it would make
9130 no sense to use a scaling indicator other than @samp{z} or @samp{u} in a
9131 numeric expression whose default scale indicator was @samp{z}, and so
9132 @code{gtroff} disallows this as well.
9134 There is also new scale indicator @samp{s} which multiplies by the
9135 number of units in a scaled point.  So, for example, @samp{\n[.ps]s} is
9136 equal to @samp{1m}.  Be sure not to confuse the @samp{s} and @samp{z}
9137 scale indicators.
9139 @Defreg {.ps}
9140 A read-only number register returning the point size in scaled points.
9142 @code{.ps} is associated with the current environment
9143 (@pxref{Environments}).
9144 @endDefreg
9146 @DefregList {.psr}
9147 @DefregListEnd {.sr}
9148 @cindex last-requested point size registers (@code{.psr}, @code{.sr})
9149 @cindex point size registers, last-requested (@code{.psr}, @code{.sr})
9150 @cindex @code{.ps} register, in comparison with @code{.psr}
9151 @cindex @code{.s} register, in comparison with @code{.sr}
9152 The last-requested point size in scaled points is contained in the
9153 @code{.psr} read-only number register.  The last requested point size
9154 in points as a decimal fraction can be found in @code{.sr}.  This is a
9155 string-valued read-only number register.
9157 Note that the requested point sizes are device-independent, whereas
9158 the values returned by the @code{.ps} and @code{.s} registers are not.
9159 For example, if a point size of 11@dmn{pt} is requested, and a
9160 @code{sizes} request (or a @code{sizescale} line in a @file{DESC} file)
9161 specifies 10.95@dmn{pt} instead, this value is actually used.
9163 Both registers are associated with the current environment
9164 (@pxref{Environments}).
9165 @endDefreg
9167 The @code{\s} escape has the following syntax for working with
9168 fractional type sizes:
9170 @table @code
9171 @item \s[@var{n}]
9172 @itemx \s'@var{n}'
9173 Set the point size to @var{n}@tie{}scaled points; @var{n}@tie{}is a numeric
9174 expression with a default scale indicator of @samp{z}.
9176 @item \s[+@var{n}]
9177 @itemx \s[-@var{n}]
9178 @itemx \s+[@var{n}]
9179 @itemx \s-[@var{n}]
9180 @itemx \s'+@var{n}'
9181 @itemx \s'-@var{n}'
9182 @itemx \s+'@var{n}'
9183 @itemx \s-'@var{n}'
9184 Increase or or decrease the point size by @var{n}@tie{}scaled points;
9185 @var{n}@tie{}is a numeric expression with a default scale indicator of
9186 @samp{z}.
9187 @end table
9189 @xref{Font Files}.
9192 @c =====================================================================
9194 @node Strings, Conditionals and Loops, Sizes, gtroff Reference
9195 @section Strings
9196 @cindex strings
9198 @code{gtroff} has string variables, which are entirely for user
9199 convenience (i.e.@: there are no built-in strings exept @code{.T}, but
9200 even this is a read-write string variable).
9202 @DefreqList {ds, name [@Var{string}]}
9203 @DefreqItem {ds1, name [@Var{string}]}
9204 @DefescItem {\\*, , n, }
9205 @DefescItem {\\*, @lparen{}, nm, }
9206 @DefescListEnd {\\*, @lbrack{}, name arg1 arg2 @dots{}, @rbrack{}}
9207 @cindex string interpolation (@code{\*})
9208 @cindex string expansion (@code{\*})
9209 @cindex interpolation of strings (@code{\*})
9210 @cindex expansion of strings (@code{\*})
9211 @cindex string arguments
9212 @cindex arguments, of strings
9213 Define and access a string variable @var{name} (one-character
9214 name@tie{}@var{n}, two-character name @var{nm}).  If @var{name} already
9215 exists, @code{ds} overwrites the previous definition.  Only the syntax form
9216 using brackets can take arguments which are handled identically to
9217 macro arguments; the single exception is that a closing bracket as an
9218 argument must be enclosed in double quotes.  @xref{Request Arguments},
9219 and @ref{Parameters}.
9221 Example:
9223 @Example
9224 .ds foo a \\$1 test
9226 This is \*[foo nice].
9227     @result{} This is a nice test.
9228 @endExample
9230 The @code{\*} escape @dfn{interpolates} (expands in-place) a
9231 previously-defined string variable.  To be more precise, the stored
9232 string is pushed onto the input stack which is then parsed by
9233 @code{gtroff}.  Similar to number registers, it is possible to nest
9234 strings, i.e. string variables can be called within string variables.
9236 If the string named by the @code{\*} escape does not exist, it is
9237 defined as empty, and a warning of type @samp{mac} is emitted (see
9238 @ref{Debugging}, for more details).
9240 @cindex comments, with @code{ds}
9241 @cindex @code{ds} request, and comments
9242 @strong{Caution:} Unlike other requests, the second argument to the
9243 @code{ds} request takes up the entire line including trailing spaces.
9244 This means that comments on a line with such a request can introduce
9245 unwanted space into a string.
9247 @Example
9248 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d \" UNIX trademark
9249 @endExample
9251 @noindent
9252 Instead the comment should be put on another line or have the comment
9253 escape adjacent with the end of the string.
9255 @Example
9256 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d\"  UNIX trademark
9257 @endExample
9259 @cindex trailing quotes
9260 @cindex quotes, trailing
9261 @cindex leading spaces with @code{ds}
9262 @cindex spaces with @code{ds}
9263 @cindex @code{ds} request, and leading spaces
9264 To produce leading space the string can be started with a double
9265 quote.  No trailing quote is needed; in fact, any trailing quote is
9266 included in your string.
9268 @Example
9269 .ds sign "           Yours in a white wine sauce,
9270 @endExample
9272 @cindex multi-line strings
9273 @cindex strings, multi-line
9274 @cindex newline character, in strings, escaping
9275 @cindex escaping newline characters, in strings
9276 Strings are not limited to a single line of text.  A string can span
9277 several lines by escaping the newlines with a backslash.  The
9278 resulting string is stored @emph{without} the newlines.
9280 @Example
9281 .ds foo lots and lots \
9282 of text are on these \
9283 next several lines
9284 @endExample
9286 It is not possible to have real newlines in a string.  To put a single
9287 double quote character into a string, use two consecutive double quote
9288 characters.
9290 The @code{ds1} request turns off compatibility mode
9291 while interpreting a string.  To be more precise, a @dfn{compatibility
9292 save} input token is inserted at the beginning of  the string, and a
9293 @dfn{compatibility restore} input token at the end.
9295 @Example
9296 .nr xxx 12345
9297 .ds aa The value of xxx is \\n[xxx].
9298 .ds1 bb The value of xxx ix \\n[xxx].
9300 .cp 1
9302 \*(aa
9303     @result{} warning: number register `[' not defined
9304     @result{} The value of xxx is 0xxx].
9305 \*(bb
9306     @result{} The value of xxx ix 12345.
9307 @endExample
9309 @cindex name space, common, of macros, diversions, and strings
9310 @cindex common name space of macros, diversions, and strings
9311 @cindex macros, shared name space with strings and diversions
9312 @cindex strings, shared name space with macros and diversions
9313 @cindex diversions, shared name space with macros and strings
9314 Strings, macros, and diversions (and boxes) share the same name space.
9315 Internally, even the same mechanism is used to store them.  This has
9316 some interesting consequences.  For example, it is possible to call a
9317 macro with string syntax and vice versa.
9319 @Example
9320 .de xxx
9321 a funny test.
9323 This is \*[xxx]
9324     @result{} This is a funny test.
9326 .ds yyy a funny test
9327 This is
9328 .yyy
9329     @result{} This is a funny test.
9330 @endExample
9332 Diversions and boxes can be also called with string syntax.
9334 Another consequence is that you can copy one-line diversions or boxes
9335 to a string.
9337 @Example
9338 .di xxx
9339 a \fItest\fR
9342 .ds yyy This is \*[xxx]\c
9343 \*[yyy].
9344     @result{} @r{This is a }@i{test}.
9345 @endExample
9347 @noindent
9348 As the previous example shows, it is possible to store formatted
9349 output in strings.  The @code{\c} escape prevents the insertion of an
9350 additional blank line in the output.
9352 Copying diversions longer than a single output line produces
9353 unexpected results.
9355 @Example
9356 .di xxx
9357 a funny
9359 test
9362 .ds yyy This is \*[xxx]\c
9363 \*[yyy].
9364     @result{} test This is a funny.
9365 @endExample
9367 Usually, it is not predictable whether a diversion contains one or
9368 more output lines, so this mechanism should be avoided.  With
9369 @acronym{UNIX} @code{troff}, this was the only solution to strip off a
9370 final newline from a diversion.  Another disadvantage is that the
9371 spaces in the copied string are already formatted, making them
9372 unstretchable.  This can cause ugly results.
9374 @cindex stripping final newline in diversions
9375 @cindex diversion, stripping final newline
9376 @cindex final newline, stripping in diversions
9377 @cindex newline, final, stripping in diversions
9378 @cindex horizontal space, unformatting
9379 @cindex space, horizontal, unformatting
9380 @cindex unformatting horizontal space
9381 A clean solution to this problem is available in GNU @code{troff},
9382 using the requests @code{chop} to remove the final newline of a
9383 diversion, and @code{unformat} to make the horizontal spaces
9384 stretchable again.
9386 @Example
9387 .box xxx
9388 a funny
9390 test
9392 .box
9393 .chop xxx
9394 .unformat xxx
9395 This is \*[xxx].
9396     @result{} This is a funny test.
9397 @endExample
9399 @xref{Gtroff Internals}, for more information.
9400 @endDefreq
9402 @DefreqList {as, name [@Var{string}]}
9403 @DefreqListEnd {as1, name [@Var{string}]}
9404 @cindex appending to a string (@code{as})
9405 @cindex string, appending (@code{as})
9406 The @code{as} request is similar to @code{ds} but appends @var{string}
9407 to the string stored as @var{name} instead of redefining it.  If
9408 @var{name} doesn't exist yet, it is created.
9410 @Example
9411 .as sign " with shallots, onions and garlic,
9412 @endExample
9414 The @code{as1} request is similar to @code{as}, but compatibility mode
9415 is switched off while the appended string is interpreted.  To be more
9416 precise, a @dfn{compatibility save} input token is inserted at the
9417 beginning of the appended string, and a @dfn{compatibility restore}
9418 input token at the end.
9419 @endDefreq
9421 Rudimentary string manipulation routines are given with the next two
9422 requests.
9424 @Defreq {substring, str n1 [@Var{n2}]}
9425 @cindex substring (@code{substring})
9426 Replace the string named @var{str} with the substring
9427 defined by the indices @var{n1} and@tie{}@var{n2}.  The first character
9428 in the string has index@tie{}0.  If @var{n2} is omitted, it is taken to
9429 be equal to the string's length.  If the index value @var{n1} or
9430 @var{n2} is negative, it is counted from the end of the
9431 string, going backwards: The last character has index@tie{}@minus{}1, the
9432 character before the last character has index@tie{}@minus{}2, etc.
9434 @Example
9435 .ds xxx abcdefgh
9436 .substring xxx 1 -4
9437 \*[xxx]
9438     @result{} bcde
9439 @endExample
9440 @endDefreq
9442 @Defreq {length, reg str}
9443 @cindex length of a string (@code{length})
9444 @cindex string, length of (@code{length})
9445 Compute the number of characters of @var{str} and return it in the
9446 number register @var{reg}.  If @var{reg} doesn't exist, it is created.
9447 @code{str} is read in copy mode.
9449 @Example
9450 .ds xxx abcd\h'3i'efgh
9451 .length yyy \n[xxx]
9452 \n[yyy]
9453     @result{} 14
9454 @endExample
9455 @endDefreq
9457 @Defreq {rn, xx yy}
9458 @cindex renaming request (@code{rn})
9459 @cindex request, renaming (@code{rn})
9460 @cindex renaming macro (@code{rn})
9461 @cindex macro, renaming (@code{rn})
9462 @cindex renaming string (@code{rn})
9463 @cindex string, renaming (@code{rn})
9464 @cindex renaming diversion (@code{rn})
9465 @cindex diversion, renaming (@code{rn})
9466 Rename the request, macro, diversion, or string @var{xx} to @var{yy}.
9467 @endDefreq
9469 @Defreq {rm, xx}
9470 @cindex removing request (@code{rm})
9471 @cindex request, removing (@code{rm})
9472 @cindex removing macro (@code{rm})
9473 @cindex macro, removing (@code{rm})
9474 @cindex removing string (@code{rm})
9475 @cindex string, removing (@code{rm})
9476 @cindex removing diversion (@code{rm})
9477 @cindex diversion, removing (@code{rm})
9478 Remove the request, macro, diversion, or string @var{xx}.  @code{gtroff}
9479 treats subsequent invocations as if the object had never been defined.
9480 @endDefreq
9482 @Defreq {als, new old}
9483 @cindex alias, string, creating (@code{als})
9484 @cindex alias, macro, creating (@code{als})
9485 @cindex alias, diversion, creating (@code{als})
9486 @cindex creating alias, for string (@code{als})
9487 @cindex creating alias, for macro (@code{als})
9488 @cindex creating alias, for diversion (@code{als})
9489 @cindex string, creating alias (@code{als})
9490 @cindex macro, creating alias (@code{als})
9491 @cindex diversion, creating alias (@code{als})
9492 Create an alias named @var{new} for the request, string, macro, or
9493 diversion object named @var{old}.  The new name and the old name are
9494 exactly equivalent (it is similar to a hard rather than a soft
9495 link). If @var{old} is undefined, @code{gtroff} generates a warning of
9496 type @samp{mac} and ignores the request.
9497 @endDefreq
9499 @Defreq {chop, xx}
9500 Remove (chop) the last character from the macro, string, or diversion
9501 named @var{xx}.  This is useful for removing the newline from the end
9502 of diversions that are to be interpolated as strings.  This command
9503 can be used repeatedly; see @ref{Gtroff Internals}, for details on
9504 nodes inserted additionally by @code{gtroff}.
9505 @endDefreq
9507 @xref{Identifiers}, and @ref{Comments}.
9510 @c =====================================================================
9512 @node Conditionals and Loops, Writing Macros, Strings, gtroff Reference
9513 @section Conditionals and Loops
9514 @cindex conditionals and loops
9515 @cindex loops and conditionals
9517 @menu
9518 * Operators in Conditionals::
9519 * if-else::
9520 * while::
9521 @end menu
9523 @c ---------------------------------------------------------------------
9525 @node Operators in Conditionals, if-else, Conditionals and Loops, Conditionals and Loops
9526 @subsection Operators in Conditionals
9528 @cindex @code{if} request, operators to use with
9529 @cindex @code{while} request, operators to use with
9530 In @code{if} and @code{while} requests, there are several more
9531 operators available:
9533 @table @code
9534 @item e
9535 @itemx o
9536 True if the current page is even or odd numbered (respectively).
9538 @item n
9539 True if the document is being processed in nroff mode (i.e., the
9540 @code{.nroff} command has been issued).
9542 @item t
9543 True if the document is being processed in troff mode (i.e., the
9544 @code{.troff} command has been issued).
9546 @item v
9547 Always false.  This condition is for compatibility with other
9548 @code{troff} versions only.
9550 @item '@var{xxx}'@var{yyy}'
9551 True if the string @var{xxx} is equal to the string @var{yyy}.  Other
9552 characters can be used in place of the single quotes; the same set of
9553 delimiters as for the @code{\D} escape is used (@pxref{Escapes}).
9554 @code{gtroff} formats the strings before being compared:
9556 @Example
9557 .ie "|"\fR|\fP" \
9558 true
9559 .el \
9560 false
9561     @result{} true
9562 @endExample
9564 @noindent
9565 The resulting motions, glyph sizes, and fonts have to
9566 match,@footnote{The created output nodes must be identical.
9567 @xref{Gtroff Internals}.} and not the individual motion, size, and
9568 font requests.  In the previous example, @samp{|} and @samp{\fR|\fP}
9569 both result in a roman @samp{|} glyph with the same point size and
9570 at the same location on the page, so the strings are equal.  If
9571 @samp{.ft@tie{}I} had been added before the @samp{.ie}, the result
9572 would be ``false'' because (the first) @samp{|} produces an italic
9573 @samp{|} rather than a roman one.
9575 @item r @var{xxx}
9576 True if there is a number register named @var{xxx}.
9578 @item d @var{xxx}
9579 True if there is a string, macro, diversion, or request named @var{xxx}.
9581 @item m @var{xxx}
9582 True if there is a color named @var{xxx}.
9584 @item c @var{g}
9585 True if there is a glyph @var{g} available@footnote{The name of this
9586 conditional operator is a misnomer since it tests names of output
9587 glyphs.}; @var{g} is either an @acronym{ASCII} character or a special
9588 character (@code{\(@var{gg}} or @code{\[@var{ggg}]}); the condition
9589 is also true if @var{g} has been defined by the @code{char} request.
9590 @end table
9592 Note that these operators can't be combined with other operators like
9593 @samp{:} or @samp{&}; only a leading @samp{!} (without whitespace
9594 between the exclamation mark and the operator) can be used to negate
9595 the result.
9597 @Example
9598 .nr xxx 1
9599 .ie !r xxx \
9600 true
9601 .el \
9602 false
9603     @result{} false
9604 @endExample
9606 A whitespace after @samp{!} always evaluates to zero (this bizarre
9607 behaviour is due to compatibility with @acronym{UNIX} @code{troff}).
9609 @Example
9610 .nr xxx 1
9611 .ie ! r xxx \
9612 true
9613 .el \
9614 false
9615     @result{} r xxx true
9616 @endExample
9618 It is possible to omit the whitespace before the argument to the
9619 @samp{r}, @samp{d}, and @samp{c} operators.
9621 @xref{Expressions}.
9623 @c ---------------------------------------------------------------------
9625 @node if-else, while, Operators in Conditionals, Conditionals and Loops
9626 @subsection if-else
9627 @cindex if-else
9629 @code{gtroff} has if-then-else constructs like other languages, although
9630 the formatting can be painful.
9632 @Defreq {if, expr anything}
9633 Evaluate the expression @var{expr}, and executes @var{anything} (the
9634 remainder of the line) if @var{expr} evaluates to non-zero (true).
9635 @var{anything} is interpreted as though it was on a line by itself
9636 (except that leading spaces are swallowed).  @xref{Expressions}, for
9637 more info.
9639 @Example
9640 .nr xxx 1
9641 .nr yyy 2
9642 .if ((\n[xxx] == 1) & (\n[yyy] == 2)) true
9643     @result{} true
9644 @endExample
9645 @endDefreq
9647 @Defreq{nop, anything}
9648 Executes @var{anything}.
9649 This is similar to @code{.if@tie{}1}.
9650 @endDefreq
9652 @DefreqList {ie, expr anything}
9653 @DefreqListEnd {el, anything}
9654 Use the @code{ie} and @code{el} requests to write an if-then-else.
9655 The first request is the `if' part and the latter is the `else' part.
9657 @Example
9658 .ie n .ls 2 \" double-spacing in nroff
9659 .el   .ls 1 \" single-spacing in troff
9660 @endExample
9661 @endDefreq
9663 @c there is a bug in makeinfo <= 4.1a: you can't have `@{' as an argument
9664 @c to @deffn
9666 @c and in 4.2 you still can't use @{ in macros.
9668 @c @DefescList {\@{, , , }
9669 @c @DefescListEnd {\@}, , , }
9670 @deffn Escape @t{\@{}
9671 @deffnx Escape @t{\@}}
9672 @esindex \@{
9673 @esindex \@}
9674 @cindex begin of conditional block (@code{\@{})
9675 @cindex end of conditional block (@code{\@}})
9676 @cindex conditional block, begin (@code{\@{})
9677 @cindex conditional block, end (@code{\@}})
9678 @cindex block, conditional, begin (@code{\@{})
9679 @cindex block, condititional, end (@code{\@}})
9680 In many cases, an if (or if-else) construct needs to execute more than
9681 one request.  This can be done using the @code{\@{} and @code{\@}}
9682 escapes.  The following example shows the possible ways to use these
9683 escapes (note the position of the opening and closing braces).
9685 @Example
9686 .ie t \@{\
9687 .    ds lq ``
9688 .    ds rq ''
9689 .\@}
9690 .el \
9691 .\@{\
9692 .    ds lq "
9693 .    ds rq "\@}
9694 @endExample
9695 @c @endDefesc
9696 @end deffn
9698 @xref{Expressions}.
9700 @c ---------------------------------------------------------------------
9702 @node while,  , if-else, Conditionals and Loops
9703 @subsection while
9704 @cindex while
9706 @code{gtroff} provides a looping construct using the @code{while}
9707 request, which is used much like the @code{if} (and related) requests.
9709 @Defreq {while, expr anything}
9710 Evaluate the expression @var{expr}, and repeatedly execute
9711 @var{anything} (the remainder of the line) until @var{expr} evaluates
9712 to@tie{}0.
9714 @Example
9715 .nr a 0 1
9716 .while (\na < 9) \@{\
9717 \n+a,
9718 .\@}
9719 \n+a
9720     @result{} 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
9721 @endExample
9723 Some remarks.
9725 @cindex @code{de} request, and @code{while}
9726 @itemize @bullet
9727 @item
9728 The body of a @code{while} request is treated like the body of a
9729 @code{de} request: @code{gtroff} temporarily stores it in a macro
9730 which is deleted after the loop has been exited.  It can considerably
9731 slow down a macro if the body of the @code{while} request (within the
9732 macro) is large.  Each time the macro is executed, the @code{while}
9733 body is parsed and stored again as a temporary macro.
9735 @Example
9736 .de xxx
9737 .  nr num 10
9738 .  while (\\n[num] > 0) \@{\
9739 .    \" many lines of code
9740 .    nr num -1
9741 .  \@}
9743 @endExample
9745 @cindex recursive macros
9746 @cindex macros, recursive
9747 @noindent
9748 The traditional and ofter better solution (@acronym{UNIX} @code{troff}
9749 doesn't have the @code{while} request) is to use a recursive macro
9750 instead which is parsed only once during its definition.
9752 @Example
9753 .de yyy
9754 .  if (\\n[num] > 0) \@{\
9755 .    \" many lines of code
9756 .    nr num -1
9757 .    yyy
9758 .  \@}
9761 .de xxx
9762 .  nr num 10
9763 .  yyy
9765 @endExample
9767 @noindent
9768 Note that the number of available recursion levels is set to@tie{}1000
9769 (this is a compile-time constant value of @code{gtroff}).
9771 @item
9772 The closing brace of a @code{while} body must end a line.
9774 @Example
9775 .if 1 \@{\
9776 .  nr a 0 1
9777 .  while (\n[a] < 10) \@{\
9778 .    nop \n+[a]
9779 .\@}\@}
9780     @result{} unbalanced \@{ \@}
9781 @endExample
9782 @end itemize
9783 @endDefreq
9785 @Defreq {break, }
9786 @cindex @code{while} request, confusing with @code{br}
9787 @cindex @code{break} request, in a @code{while} loop
9788 @cindex @code{continue} request, in a @code{while} loop
9789 Break out of a @code{while} loop.  Be sure not to confuse this with
9790 the @code{br} request (causing a line break).
9791 @endDefreq
9793 @Defreq {continue, }
9794 Finish the current iteration of a @code{while} loop, immediately
9795 restarting the next iteration.
9796 @endDefreq
9798 @xref{Expressions}.
9801 @c =====================================================================
9803 @node Writing Macros, Page Motions, Conditionals and Loops, gtroff Reference
9804 @section Writing Macros
9805 @cindex writing macros
9806 @cindex macros, writing
9808 A @dfn{macro} is a collection of text and embedded commands which can
9809 be invoked multiple times.  Use macros to define common operations.
9811 @DefreqList {de, name [@Var{end}]}
9812 @DefreqItem {de1, name [@Var{end}]}
9813 @DefreqListEnd {dei, name [@Var{end}]}
9814 Define a new macro named @var{name}.  @code{gtroff} copies subsequent
9815 lines (starting with the next one) into an internal buffer until it
9816 encounters the line @samp{..} (two dots).  The optional second
9817 argument to @code{de} changes this to a macro to @samp{.@var{end}}.
9819 There can be whitespace after the first dot in the line containing the
9820 ending token (either @samp{.} or macro @samp{@var{end}}).
9822 Here a small example macro called @samp{P} which causes a break and
9823 inserts some vertical space.  It could be used to separate paragraphs.
9825 @Example
9826 .de P
9827 .  br
9828 .  sp .8v
9830 @endExample
9832 The following example defines a macro within another.  Remember that
9833 expansion must be protected twice; once for reading the macro and
9834 once for executing.
9836 @Example
9837 \# a dummy macro to avoid a warning
9838 .de end
9841 .de foo
9842 .  de bar end
9843 .    nop \f[B]Hallo \\\\$1!\f[]
9844 .  end
9847 .foo
9848 .bar Joe
9849     @result{} @b{Hallo Joe!}
9850 @endExample
9852 @noindent
9853 Since @code{\f} has no expansion, it isn't necessary to protect its
9854 backslash.  Had we defined another macro within @code{bar} which takes
9855 a parameter, eight backslashes would be necessary before @samp{$1}.
9857 The @code{de1} request turns off compatibility mode
9858 while executing the macro.  On entry, the current compatibility mode
9859 is saved and restored at exit.
9861 @Example
9862 .nr xxx 12345
9864 .de aa
9865 The value of xxx is \\n[xxx].
9867 .de1 bb
9868 The value of xxx ix \\n[xxx].
9871 .cp 1
9874     @result{} warning: number register \e' not defined
9875     @result{} The value of xxx is 0xxx].
9877     @result{} The value of xxx ix 12345.
9878 @endExample
9880 The @code{dei} request defines a macro indirectly.
9881 That is, it expands strings whose names
9882 are @var{name} or @var{end} before performing the append.
9884 This:
9886 @Example
9887 .ds xx aa
9888 .ds yy bb
9889 .dei xx yy
9890 @endExample
9892 @noindent
9893 is equivalent to:
9895 @Example
9896 .de aa bb
9897 @endExample
9899 @pindex trace.tmac
9900 Using @file{trace.tmac}, you can trace calls to @code{de} and @code{de1}.
9902 Note that macro identifiers are shared with identifiers for strings and
9903 diversions.
9904 @endDefreq
9906 @DefreqList {am, name [@Var{end}]}
9907 @DefreqItem {am1, name [@Var{end}]}
9908 @DefreqListEnd {ami, name [@Var{end}]}
9909 @cindex appending to a macro (@code{am})
9910 @cindex macro, appending (@code{am})
9911 Works similarly to @code{de} except it appends onto the macro named
9912 @var{name}.  So, to make the previously defined @samp{P} macro actually
9913 do indented instead of block paragraphs, add the necessary code to the
9914 existing macro like this:
9916 @Example
9917 .am P
9918 .ti +5n
9920 @endExample
9922 The @code{am1} request turns off compatibility mode
9923 while executing the appended macro piece.  To be more precise, a
9924 @dfn{compatibility save} input token is inserted at the beginning of
9925 the appended code, and a @dfn{compatibility restore} input token at
9926 the end.
9928 The @code{ami} request appends indirectly,
9929 meaning that @code{gtroff} expands strings whose names
9930 are @var{name} or @var{end} before performing the append.
9932 @pindex trace.tmac
9933 Using @file{trace.tmac}, you can trace calls to @code{am} and @code{am1}.
9934 @endDefreq
9936 @xref{Strings}, for the @code{als} request to rename a macro.
9938 The @code{de}, @code{am}, @code{di}, @code{da}, @code{ds}, and
9939 @code{as} requests (together with its variants) only create a new object
9940 if the name of the macro, diversion or string diversion is currently
9941 undefined or if it is defined to be a request; normally they modify the
9942 value of an existing object.
9944 @Defreq {return, }
9945 Exit a macro, immediately returning to the caller.
9946 @endDefreq
9948 @menu
9949 * Copy-in Mode::
9950 * Parameters::
9951 @end menu
9953 @c ---------------------------------------------------------------------
9955 @node Copy-in Mode, Parameters, Writing Macros, Writing Macros
9956 @subsection Copy-in Mode
9957 @cindex copy-in mode
9958 @cindex mode, copy-in
9960 @cindex @code{\n}, when reading text for a macro
9961 @cindex @code{\$}, when reading text for a macro
9962 @cindex @code{\*}, when reading text for a macro
9963 @cindex @code{\\}, when reading text for a macro
9964 @cindex \@key{RET}, when reading text for a macro
9965 When @code{gtroff} reads in the text for a macro, string, or diversion,
9966 it copies the text (including request lines, but excluding escapes) into
9967 an internal buffer.  Escapes are converted into an internal form,
9968 except for @code{\n}, @code{\$}, @code{\*}, @code{\\} and
9969 @code{\@key{RET}} which are evaluated and inserted into the text where
9970 the escape was located.  This is known as @dfn{copy-in} mode or
9971 @dfn{copy} mode.
9973 What this means is that you can specify when these escapes are to be
9974 evaluated (either at copy-in time or at the time of use) by insulating
9975 the escapes with an extra backslash.  Compare this to the @code{\def}
9976 and @code{\edef} commands in @TeX{}.
9978 The following example prints the numbers 20 and@tie{}10:
9980 @Example
9981 .nr x 20
9982 .de y
9983 .nr x 10
9984 \&\nx
9985 \&\\nx
9988 @endExample
9990 @c ---------------------------------------------------------------------
9992 @node Parameters,  , Copy-in Mode, Writing Macros
9993 @subsection Parameters
9994 @cindex parameters
9996 The arguments to a macro or string can be examined using a variety of
9997 escapes.
9999 @Defreg {.$}
10000 @cindex number of arguments register (@code{.$})
10001 The number of arguments passed to a macro or string.  This is a read-only
10002 number register.
10003 @endDefreg
10005 Any individual argument can be retrieved with one of the following
10006 escapes:
10008 @DefescList {\\$, , n, }
10009 @DefescItem {\\$, @lparen{}, nn, }
10010 @DefescListEnd {\\$, @lbrack{}, nnn, @rbrack{}}
10011 @cindex copy-in mode, and macro arguments
10012 @cindex macro, arguments (@code{\$})
10013 @cindex arguments, macro (@code{\$})
10014 Retrieve the @var{n}@dmn{th}, @var{nn}@dmn{th} or @var{nnn}@dmn{th}
10015 argument.  As usual, the first form only accepts a single number
10016 (larger than zero), the second a two-digit number (larger or equal
10017 to@tie{}10), and the third any positive integer value (larger
10018 than zero).  Macros and strings can have an unlimited number of arguments.
10019 Note that due to copy-in mode, use two backslashes on these in actual use
10020 to prevent interpolation until the macro is actually invoked.
10021 @endDefesc
10023 @Defreq {shift, [@Var{n}]}
10024 Shift the arguments 1@tie{}position, or as
10025 many positions as specified by its argument.  After executing this
10026 request, argument@tie{}@var{i} becomes argument @math{@var{i}-@var{n}};
10027 arguments 1 to@tie{}@var{n} are no longer available.  Shifting by
10028 negative amounts is currently undefined.
10029 @endDefreq
10031 @DefescList {\\$*, , , }
10032 @DefescListEnd {\\$@@, , , }
10033 In some cases it is convenient to use all of the arguments at once (for
10034 example, to pass the arguments along to another macro).  The @code{\$*}
10035 escape concatenates all the arguments separated by spaces.  A
10036 similar escape is @code{\$@@}, which concatenates all the
10037 arguments with each surrounded by double quotes, and separated by
10038 spaces.  If not in compatibility mode, the input level of double quotes
10039 is preserved (see @ref{Request Arguments}).
10040 @endDefesc
10042 @Defesc {\\$0, , , }
10043 @cindex macro name register (@code{\$0})
10044 @cindex @code{als} request, and @code{\$0}
10045 The name used to invoke the current macro.
10046 The @code{als} request can make a macro have more than one name.
10048 @Example
10049 .de generic-macro
10050 .  ...
10051 .  if \\n[error] \@{\
10052 .    tm \\$0: Houston, we have a problem.
10053 .    return
10054 .  \@}
10057 .als foo generic-macro
10058 .als bar generic-macro
10059 @endExample
10060 @endDefesc
10062 @xref{Request Arguments}.
10065 @c =====================================================================
10067 @node Page Motions, Drawing Requests, Writing Macros, gtroff Reference
10068 @section Page Motions
10069 @cindex page motions
10070 @cindex motions, page
10072 @xref{Manipulating Spacing}, for a discussion of the main request for
10073 vertical motion, @code{sp}.
10075 @DefreqList {mk, [@Var{reg}]}
10076 @DefreqListEnd {rt, [@Var{dist}]}
10077 @cindex marking vertical page location (@code{mk})
10078 @cindex page location, vertical, marking (@code{mk})
10079 @cindex location, vertical, page, marking (@code{mk})
10080 @cindex vertical page location, marking (@code{mk})
10081 @cindex returning to marked vertical page location (@code{rt})
10082 @cindex page location, vertical, returning to marked (@code{rt})
10083 @cindex location, vertical, page, returning to marked (@code{rt})
10084 @cindex vertical page location, returning to marked (@code{rt})
10085 The request @code{mk} can be used to mark a location on a page, for
10086 movement to later.  This request takes a register name as an argument
10087 in which to store the current page location.  With no argument it
10088 stores the location in an internal register.  The results of this can
10089 be used later by the @code{rt} or the @code{sp} request (or the
10090 @code{\v} escape).
10092 The @code{rt} request returns @emph{upwards} to the location marked
10093 with the last @code{mk} request.  If used with an argument, return to
10094 a position which distance from the top of the page is @var{dist} (no
10095 previous call to @code{mk} is necessary in this case).  Default scaling
10096 indicator is @samp{v}.
10098 Here a primitive solution for a two-column macro.
10100 @Example
10101 .nr column-length 1.5i
10102 .nr column-gap 4m
10103 .nr bottom-margin 1m
10105 @endExample
10106 @Example
10107 .de 2c
10108 .  br
10109 .  mk
10110 .  ll \\n[column-length]u
10111 .  wh -\\n[bottom-margin]u 2c-trap
10112 .  nr right-side 0
10115 @endExample
10116 @Example
10117 .de 2c-trap
10118 .  ie \\n[right-side] \@{\
10119 .    nr right-side 0
10120 .    po -(\\n[column-length]u + \\n[column-gap]u)
10121 .    \" remove trap
10122 .    wh -\\n[bottom-margin]u
10123 .  \@}
10124 .  el \@{\
10125 .    \" switch to right side
10126 .    nr right-side 1
10127 .    po +(\\n[column-length]u + \\n[column-gap]u)
10128 .    rt
10129 .  \@}
10132 @endExample
10133 @Example
10134 .pl 1.5i
10135 .ll 4i
10136 This is a small test which shows how the
10137 rt request works in combination with mk.
10140 Starting here, text is typeset in two columns.
10141 Note that this implementation isn't robust
10142 and thus not suited for a real two-column
10143 macro.
10144 @endExample
10146 Result:
10148 @Example
10149 This is a small test which shows how the
10150 rt request works in combination with mk.
10152 Starting  here,    isn't    robust
10153 text is typeset    and   thus  not
10154 in two columns.    suited  for   a
10155 Note that  this    real two-column
10156 implementation     macro.
10157 @endExample
10158 @endDefreq
10160 The following escapes give fine control of movements about the page.
10162 @Defesc {\\v, ', e, '}
10163 @cindex vertical motion (@code{\v})
10164 @cindex motion, vertical (@code{\v})
10165 Move vertically, usually from the current location on the page (if no
10166 absolute position operator @samp{|} is used).  The
10167 argument@tie{}@var{e} specifies the distance to move; positive is
10168 downwards and negative upwards.  The default scaling indicator for this
10169 escape is @samp{v}.  Beware, however, that @code{gtroff} continues text
10170 processing at the point where the motion ends, so you should always
10171 balance motions to avoid interference with text processing.
10173 @code{\v} doesn't trigger a trap.  This can be quite useful; for example,
10174 consider a page bottom trap macro which prints a marker in the margin to
10175 indicate continuation of a footnote or something similar.
10176 @endDefesc
10178 There are some special-case escapes for vertical motion.
10180 @Defesc {\\r, , , }
10181 Move upwards@tie{}1@dmn{v}.
10182 @endDefesc
10184 @Defesc {\\u, , , }
10185 Move upwards@tie{}.5@dmn{v}.
10186 @endDefesc
10188 @Defesc {\\d, , , }
10189 Move down@tie{}.5@dmn{v}.
10190 @endDefesc
10192 @Defesc {\\h, ', e, '}
10193 @cindex inserting horizontal space (@code{\h})
10194 @cindex horizontal space (@code{\h})
10195 @cindex space, horizontal (@code{\h})
10196 @cindex horizontal motion (@code{\h})
10197 @cindex motion, horizontal (@code{\h})
10198 Move horizontally, usually from the current location (if no absolute
10199 position operator @samp{|} is used).  The expression@tie{}@var{e}
10200 indicates how far to move: positive is rightwards and negative
10201 leftwards.  The default scaling indicator for this escape is @samp{m}.
10202 @endDefesc
10204 There are a number of special-case escapes for horizontal motion.
10206 @Defesc {\\@key{SP}, , , }
10207 @cindex space, unbreakable
10208 @cindex unbreakable space
10209 An unbreakable and unpaddable (i.e.@: not expanded during filling)
10210 space.  (Note: This is a backslash followed by a space.)
10211 @endDefesc
10213 @Defesc {\\~, , , }
10214 An unbreakable space that stretches like a normal inter-word space
10215 when a line is adjusted.
10216 @endDefesc
10218 @Defesc {\\|, , , }
10219 A 1/6@dmn{th} em space.  Ignored for TTY output devices (rounded to
10220 zero).
10221 @endDefesc
10223 @Defesc {\\^, , , }
10224 A 1/12@dmn{th} em space.  Ignored for TTY output devices (rounded to
10225 zero).
10226 @endDefesc
10228 @Defesc {\\0, , , }
10229 @cindex space, width of a digit (@code{\0})
10230 @cindex digit width space (@code{\0})
10231 A space the size of a digit.
10232 @endDefesc
10234 The following string sets the @TeX{} logo:
10236 @Example
10237 .ds TeX T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
10238 @endExample
10240 @DefescList {\\w, ', text, '}
10241 @DefregItem {st}
10242 @DefregItem {sb}
10243 @DefregItem {rst}
10244 @DefregItem {rsb}
10245 @DefregItem {ct}
10246 @DefregItem {ssc}
10247 @DefregListEnd {skw}
10248 @cindex width escape (@code{\w})
10249 Return the width of the specified @var{text} in basic units.
10250 This allows horizontal movement based on the width of some
10251 arbitrary text (e.g.@: given as an argument to a macro).
10253 @Example
10254 The length of the string `abc' is \w'abc'u.
10255     @result{} The length of the string `abc' is 72u.
10256 @endExample
10258 Font changes may occur in @var{text} which don't affect current
10259 settings.
10261 After use, @code{\w} sets several registers:
10263 @table @code
10264 @item st
10265 @itemx sb
10266 The highest and lowest point of the baseline, respectively, in @var{text}.
10268 @item rst
10269 @itemx rsb
10270 Like the @code{st} and @code{sb} registers, but takes account of the
10271 heights and depths of glyphs.  With other words, this gives the
10272 highest and lowest point of @var{text}.  Values below the baseline are
10273 negative.
10275 @item ct
10276 Defines the kinds of glyphs occurring in @var{text}:
10278 @table @asis
10279 @item 0
10280 only short glyphs, no descenders or tall glyphs.
10282 @item 1
10283 at least one descender.
10285 @item 2
10286 at least one tall glyph.
10288 @item 3
10289 at least one each of a descender and a tall glyph.
10290 @end table
10292 @item ssc
10293 The amount of horizontal space (possibly negative) that should be added
10294 to the last glyph before a subscript.
10296 @item skw
10297 How far to right of the center of the last glyph in the @code{\w}
10298 argument, the center of an accent from a roman font should be placed
10299 over that glyph.
10300 @end table
10301 @endDefesc
10303 @DefescList {\\k, , p, }
10304 @DefescItem {\\k, @lparen{}, ps, }
10305 @DefescListEnd {\\k, @lbrack{}, position, @rbrack}
10306 @cindex saving horizontal input line position (@code{\k})
10307 @cindex horizontal input line position, saving (@code{\k})
10308 @cindex input line position, horizontal, saving (@code{\k})
10309 @cindex position, horizontal input line, saving (@code{\k})
10310 @cindex line, input, horizontal position, saving (@code{\k})
10311 Store the current horizontal position in the @emph{input} line in
10312 number register with name @var{position} (one-character name@tie{}@var{p},
10313 two-character name @var{ps}).  Use this, for example, to return to the
10314 beginning of a string for highlighting or other decoration.
10315 @endDefesc
10317 @Defreg {hp}
10318 @cindex horizontal input line position register (@code{hp})
10319 @cindex input line, horizontal position, register (@code{hp})
10320 @cindex position, horizontal, in input line, register (@code{hp})
10321 @cindex line, input, horizontal position, register (@code{hp})
10322 The current horizontal position at the input line.
10323 @endDefreg
10325 @Defreg {.k}
10326 @cindex horizontal output line position register (@code{.k})
10327 @cindex output line, horizontal position, register (@code{.k})
10328 @cindex position, horizontal, in output line, register (@code{.k})
10329 @cindex line, output, horizontal position, register (@code{.k})
10330 A read-only number register containing the current horizontal output
10331 position.
10332 @endDefreg
10334 @Defesc {\\o, ', @Var{a}@Var{b}@Var{c}, '}
10335 @cindex overstriking glyphs (@code{\o})
10336 @cindex glyphs, overstriking (@code{\o})
10337 Overstrike glyphs @var{a}, @var{b}, @var{c}, @dots{}; the glyphs
10338 are centered, and the resulting spacing is the largest width of the
10339 affected glyphs.
10340 @endDefesc
10342 @Defesc {\\z, , g, , }
10343 @cindex zero-width printing (@code{\z}, @code{\Z})
10344 @cindex printing, zero-width (@code{\z}, @code{\Z})
10345 Print glyph @var{g} with zero width, i.e., without spacing.  Use
10346 this to overstrike glyphs left-aligned.
10347 @endDefesc
10349 @Defesc {\\Z, ', anything, '}
10350 @cindex zero-width printing (@code{\z}, @code{\Z})
10351 @cindex printing, zero-width (@code{\z}, @code{\Z})
10352 Print @var{anything}, then restore the horizontal and vertical position.
10353 The argument may not contain tabs or leaders.
10355 The following is an example of a strike-through macro:
10357 @Example
10358 .de ST
10359 .nr ww \w'\\$1'
10360 \Z@@\v'-.25m'\l'\\n[ww]u'@@\\$1
10363 This is
10364 .ST "a test"
10365 an actual emergency!
10366 @endExample
10367 @endDefesc
10370 @c =====================================================================
10372 @node Drawing Requests, Traps, Page Motions, gtroff Reference
10373 @section Drawing Requests
10374 @cindex drawing requests
10375 @cindex requests for drawing
10377 @code{gtroff} provides a number of ways to draw lines and other figures
10378 on the page.  Used in combination with the page motion commands (see
10379 @ref{Page Motions}, for more info), a wide variety of figures can be
10380 drawn.  However, for complex drawings these operations can be quite
10381 cumbersome, and it may be wise to use graphic preprocessors like
10382 @code{gpic} or @code{ggrn}.  @xref{gpic}, and @ref{ggrn}, for more
10383 information.
10385 All drawing is done via escapes.
10387 @DefescList {\\l, ', @Var{l}, '}
10388 @DefescListEnd {\\l, ', @Var{l}@Var{g}, '}
10389 @cindex drawing horizontal lines (@code{\l})
10390 @cindex horizontal line, drawing (@code{\l})
10391 @cindex line, horizontal, drawing (@code{\l})
10392 Draw a line horizontally.  @var{l} is the length of the line to be
10393 drawn.  If it is positive, start the line at the current location and
10394 draw to the right; its end point is the new current location.  Negative
10395 values are handled differently: The line starts at the current location
10396 and draws to the left, but the current location doesn't move.
10398 @var{l} can also be specified absolutely (i.e.@: with a leading
10399 @samp{|}) which draws back to the beginning of the input line.
10400 Default scaling indicator is @samp{m}.
10402 @cindex underscore glyph (@code{\[ru]})
10403 @cindex glyph, underscore (@code{\[ru]})
10404 @cindex line drawing glyph
10405 @cindex glyph, for line drawing
10406 The optional second parameter@tie{}@var{g} is a glyph to draw the line
10407 with.  If this second argument is not specified, @code{gtroff} uses
10408 the underscore glyph, @code{\[ru]}.
10410 @cindex zero width space character (@code{\&})
10411 @cindex character, zero width space (@code{\&})
10412 @cindex space character, zero width (@code{\&})
10413 To separate the two arguments (to prevent @code{gtroff} from
10414 interpreting a drawing glyph as a scaling indicator if the glyph is
10415 represented by a single character) use @code{\&}.
10417 Here a small useful example:
10419 @Example
10420 .de box
10421 \[br]\\$*\[br]\l'|0\[rn]'\l'|0\[ul]'
10423 @endExample
10425 @noindent
10426 Note that this works by outputting a box rule (a vertical line), then
10427 the text given as an argument and then another box rule.  Finally, the
10428 line drawing escapes both draw from the current location to the
10429 beginning of the @emph{input} line -- this works because the line
10430 length is negative, not moving the current point.
10431 @endDefesc
10433 @DefescList {\\L, ', @Var{l}, '}
10434 @DefescListEnd {\\L, ', @Var{l}@Var{g}, '}
10435 @cindex drawing vertical lines (@code{\L})
10436 @cindex vertical line drawing (@code{\L})
10437 @cindex line, vertical, drawing (@code{\L})
10438 @cindex line drawing glyph
10439 @cindex glyph for line drawing
10440 @cindex box rule glyph (@code{\[br]})
10441 @cindex glyph, box rule (@code{\[br]})
10442 Draw vertical lines.  Its parameters are
10443 similar to the @code{\l} escape, except that the default scaling
10444 indicator is @samp{v}.  The movement is downwards for positive values,
10445 and upwards for negative values.  The default glyph is the box rule
10446 glyph, @code{\[br]}.  As with the vertical motion escapes, text
10447 processing blindly continues where the line ends.
10449 @Example
10450 This is a \L'3v'test.
10451 @endExample
10453 @noindent
10454 Here the result, produced with @code{grotty}.
10456 @Example
10457 This is a
10458           |
10459           |
10460           |test.
10461 @endExample
10462 @endDefesc
10464 @Defesc {\\D, ', command arg @dots{}, '}
10465 The @code{\D} escape provides a variety of drawing functions.
10466 Note that on character devices, only vertical and horizontal lines are
10467 supported within @code{grotty}; other devices may only support a subset
10468 of the available drawing functions.
10470 The default scaling indicator for all subcommands of @code{\D} is
10471 @samp{m} for horizontal distances and @samp{v} for vertical ones.
10472 Exceptions are @w{@code{\D'f @dots{}'}} and @w{@code{\D't @dots{}'}}
10473 which use @code{u} as the default.
10475 @table @code
10476 @item \D'l @var{dx} @var{dy}'
10477 @cindex line, drawing (@w{@code{\D'l @dots{}'}})
10478 @cindex drawing a line (@w{@code{\D'l @dots{}'}})
10479 Draw a line from the current location to the relative point specified by
10480 (@var{dx},@var{dy}).
10482 The following example is a macro for creating a box around a text string;
10483 for simplicity, the box margin is taken as a fixed value, 0.2@dmn{m}.
10485 @Example
10486 .de BOX
10487 .  nr @@wd \w'\\$1'
10488 \h'.2m'\
10489 \h'-.2m'\v'(.2m - \\n[rsb]u)'\
10490 \D'l 0 -(\\n[rst]u - \\n[rsb]u + .4m)'\
10491 \D'l (\\n[@@wd]u + .4m) 0'\
10492 \D'l 0 (\\n[rst]u - \\n[rsb]u + .4m)'\
10493 \D'l -(\\n[@@wd]u + .4m) 0'\
10494 \h'.2m'\v'-(.2m - \\n[rsb]u)'\
10495 \\$1\
10496 \h'.2m'
10498 @endExample
10500 @noindent
10501 First, the width of the string is stored in register @code{@@wd}.  Then,
10502 four lines are drawn to form a box, properly offset by the box margin.
10503 The registers @code{rst} and @code{rsb} are set by the @code{\w} escape,
10504 containing the largest height and depth of the whole string.
10506 @item \D'c @var{d}'
10507 @cindex circle, drawing (@w{@code{\D'c @dots{}'}})
10508 @cindex drawing a circle (@w{@code{\D'c @dots{}'}})
10509 Draw a circle with a diameter of@tie{}@var{d} with the leftmost point at the
10510 current position.
10512 @item \D'C @var{d}'
10513 @cindex circle, solid, drawing (@w{@code{\D'C @dots{}'}})
10514 @cindex drawing a solid circle (@w{@code{\D'C @dots{}'}})
10515 @cindex solid circle, drawing (@w{@code{\D'C @dots{}'}})
10516 Draw a solid circle with the same parameters as an outlined circle.  No
10517 outline is drawn.
10519 @item \D'e @var{x} @var{y}'
10520 @cindex drawing an ellipse (@w{@code{\D'e @dots{}'}})
10521 @cindex ellipse, drawing (@w{@code{\D'e @dots{}'}})
10522 Draw an ellipse with a horizontal diameter of @var{x} and a vertical
10523 diameter of @var{y} with the leftmost point at the current position.
10525 @item \D'E @var{x} @var{y}'
10526 @cindex ellipse, solid, drawing (@w{@code{\D'E @dots{}'}})
10527 @cindex drawing a solid ellipse (@w{@code{\D'E @dots{}'}})
10528 @cindex solid ellipse, drawing (@w{@code{\D'E @dots{}'}})
10529 Draw a solid ellipse with the same parameters as an outlined ellipse.
10530 No outline is drawn.
10532 @item \D'a @var{dx1} @var{dy1} @var{dx2} @var{dy2}'
10533 @cindex arc, drawing (@w{@code{\D'a @dots{}'}})
10534 @cindex drawing an arc (@w{@code{\D'a @dots{}'}})
10535 Draw an arc clockwise from the current location through the two
10536 specified relative locations (@var{dx1},@var{dy1}) and
10537 (@var{dx2},@var{dy2}).  The coordinates of the first point are relative
10538 to the current position, and the coordinates of the second point are
10539 relative to the first point.
10541 @item \D'~ @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
10542 @cindex drawing a spline (@w{@code{\D'~ @dots{}'}})
10543 @cindex spline, drawing (@w{@code{\D'~ @dots{}'}})
10544 Draw a spline from the current location to the relative point
10545 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}), and so on.
10547 @item \D'f @var{n}'
10548 @cindex gray shading (@w{@code{\D'f @dots{}'}})
10549 @cindex shading filled objects (@w{@code{\D'f @dots{}'}})
10550 Set the shade of gray to be used for filling solid objects to@tie{}@var{n};
10551 @var{n}@tie{}must be an integer between 0 and@tie{}1000, where 0
10552 corresponds solid white and 1000 to solid black, and values in between
10553 correspond to intermediate shades of gray.  This applies only to solid
10554 circles, solid ellipses, and solid polygons.  By default, a level of
10555 1000 is used.
10557 @cindex @w{@code{\D'f @dots{}'}} and horizontal resolution
10558 Don't use this command!  It has the serious drawback that it will be
10559 always rounded to the next integer multiple of the horizontal resolution
10560 (the value of the @code{hor} keyword in the @file{DESC} file).  Use
10561 @code{\M} with a gray value instead (@pxref{Colors}).
10563 @item \D'p @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
10564 @cindex drawing a polygon (@w{@code{\D'p @dots{}'}})
10565 @cindex polygon, drawing (@w{@code{\D'p @dots{}'}})
10566 Draw a polygon from the current location to the relative position
10567 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}) and so on.
10568 When the specified data points are exhausted, a line is drawn back
10569 to the starting point.
10571 @item \D'P @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
10572 @cindex polygon, solid, drawing (@w{@code{\D'P @dots{}'}})
10573 @cindex drawing a solid polygon (@w{@code{\D'P @dots{}'}})
10574 @cindex solid polygon, drawing (@w{@code{\D'P @dots{}'}})
10575 Draw a solid polygon with the same parameters as an outlined polygon.
10576 No outline is drawn.
10578 Here a better variant of the box macro to fill the box with some color.
10579 Note that the box must be drawn before the text since colors in
10580 @code{gtroff} are not transparent; the filled polygon would hide the
10581 text completely.
10583 @Example
10584 .de BOX
10585 .  nr @@wd \w'\\$1'
10586 \h'.2m'\
10587 \h'-.2m'\v'(.2m - \\n[rsb]u)'\
10588 \M[lightcyan]\
10589 \D'P 0 -(\\n[rst]u - \\n[rsb]u + .4m) \
10590      (\\n[@@wd]u + .4m) 0 \
10591      0 (\\n[rst]u - \\n[rsb]u + .4m) \
10592      -(\\n[@@wd]u + .4m) 0'\
10593 \h'.2m'\v'-(.2m - \\n[rsb]u)'\
10594 \M[]\
10595 \\$1\
10596 \h'.2m'
10598 @endExample
10600 @item \D't @var{n}'
10601 @cindex line thickness (@w{@code{\D't @dots{}'}})
10602 @cindex thickness of lines (@w{@code{\D't @dots{}'}})
10603 Set the current line thickness to @var{n}@tie{}machine units.  A value of
10604 zero selects the smallest available line thickness.  A negative value
10605 makes the line thickness proportional to the current point size (this is
10606 the default behaviour of @acronym{AT&T} @code{troff}).
10607 @end table
10608 @endDefesc
10610 @xref{Graphics Commands}.
10612 @Defesc {\\b, ', string, '}
10613 @cindex pile, glyph (@code{\b})
10614 @cindex glyph pile (@code{\b})
10615 @cindex stacking glyphs (@code{\b})
10616 @dfn{Pile} a sequence of glyphs vertically, and center it vertically
10617 on the current line.  Use it to build large brackets and braces.
10619 Here an example how to create a large opening brace:
10621 @Example
10622 \b'\[lt]\[bv]\[lk]\[bv]\[lb]'
10623 @endExample
10625 @cindex @code{\b}, limitations
10626 @cindex limitations of @code{\b} escape
10627 The first glyph is on the top, the last glyph in @var{string} is
10628 at the bottom.  Note that @code{gtroff} separates the glyphs
10629 vertically by 1@dmn{m}, and the whole object is centered 0.5@dmn{m}
10630 above the current baseline; the largest glyph width is used as the
10631 width for the whole object.  This rather unflexible positioning
10632 algorithm doesn't work with @option{-Tdvi} since the bracket pieces vary
10633 in height for this device.  Instead, use the @code{eqn} preprocessor.
10635 @xref{Manipulating Spacing}, how to adjust the vertical spacing with
10636 the @code{\x} escape.
10637 @endDefesc
10640 @c =====================================================================
10642 @node Traps, Diversions, Drawing Requests, gtroff Reference
10643 @section Traps
10644 @cindex traps
10646 @dfn{Traps} are locations, which, when reached, call a specified
10647 macro.  These traps can occur at a given location on the page, at a
10648 given location in the current diversion, at a blank line,
10649 after a certain number of input lines, or at the end of input.
10651 @cindex planting a trap
10652 @cindex trap, planting
10653 Setting a trap is also called @dfn{planting}.
10654 @cindex trap, springing
10655 @cindex springing a trap
10656 It is also said that a trap is @dfn{sprung} if the associated macro
10657 is executed.
10659 @menu
10660 * Page Location Traps::
10661 * Diversion Traps::
10662 * Input Line Traps::
10663 * Blank Line Traps::
10664 * End-of-input Traps::
10665 @end menu
10667 @c ---------------------------------------------------------------------
10669 @node Page Location Traps, Diversion Traps, Traps, Traps
10670 @subsection Page Location Traps
10671 @cindex page location traps
10672 @cindex traps, page location
10674 @dfn{Page location traps} perform an action when @code{gtroff}
10675 reaches or passes a certain vertical location on the page.  Page
10676 location traps have a variety of purposes, including:
10678 @itemize
10679 @item
10680 setting headers and footers
10682 @item
10683 setting body text in multiple columns
10685 @item
10686 setting footnotes
10687 @end itemize
10689 @DefreqList {vpt, flag}
10690 @DefregListEnd {.vpt}
10691 @cindex enabling vertical position traps (@code{vpt})
10692 @cindex vertical position traps, enabling (@code{vpt})
10693 @cindex vertical position trap enable register (@code{.vpt})
10694 Enable vertical position traps if @var{flag} is non-zero, or disables
10695 them otherwise.  Vertical position traps are traps set by the @code{wh}
10696 or @code{dt} requests.  Traps set by the @code{it} request are not
10697 vertical position traps.  The parameter that controls whether vertical
10698 position traps are enabled is global.  Initially vertical position traps
10699 are enabled.  The current setting of this is available in the
10700 @code{.vpt} read-only number register.
10702 Note that a page can't be ejected if @code{vpt} is set to zero.
10703 @endDefreq
10705 @Defreq {wh, dist [@Var{macro}]}
10706 Set a page location trap.  Non-negative values for @var{dist} set
10707 the trap relative to the top of the page; negative values set
10708 the trap relative to the bottom of the page.  Default scaling
10709 indicator is @samp{v}.
10711 @var{macro} is the name of the macro to execute when the
10712 trap is sprung.  If @var{macro} is missing, remove the first trap
10713 (if any) at @var{dist}.
10715 @cindex page headers
10716 @cindex page footers
10717 @cindex headers
10718 @cindex footers
10719 The following is a simple example of how many macro packages
10720 set headers and footers.
10722 @Example
10723 .de hd                \" Page header
10724 '  sp .5i
10725 .  tl 'Title''date'
10726 '  sp .3i
10729 .de fo                \" Page footer
10730 '  sp 1v
10731 .  tl ''%''
10732 '  bp
10735 .wh 0   hd            \" trap at top of the page
10736 .wh -1i fo            \" trap one inch from bottom
10737 @endExample
10739 A trap at or below the bottom of the page is ignored; it can be made
10740 active by either moving it up or increasing the page length so that the
10741 trap is on the page.
10743 It is possible to have more than one trap at the same location; to do so,
10744 the traps must be defined at different locations, then moved together with
10745 the @code{ch} request; otherwise the second trap would replace the first
10746 one.  Earlier defined traps hide later defined traps if moved to the same
10747 position (the many empty lines caused by the @code{bp} request are omitted
10748 in the following example):
10750 @Example
10751 .de a
10752 .  nop a
10754 .de b
10755 .  nop b
10757 .de c
10758 .  nop c
10761 .wh 1i a
10762 .wh 2i b
10763 .wh 3i c
10765     @result{} a b c
10766 @endExample
10767 @Example
10768 .ch b 1i
10769 .ch c 1i
10771     @result{} a
10772 @endExample
10773 @Example
10774 .ch a 0.5i
10776     @result{} a b
10777 @endExample
10778 @endDefreq
10780 @Defreg {.t}
10781 @cindex distance to next trap register (@code{.t})
10782 @cindex trap, distance, register (@code{.t})
10783 A read-only number register holding the distance to the next trap.
10785 If there are no traps between the current position and the bottom of the
10786 page, it contains the distance to the page bottom.  In a diversion, the
10787 distance to the page bottom is infinite (the returned value is the biggest
10788 integer which can be represented in @code{groff}) if there are no diversion
10789 traps.
10790 @endDefreg
10792 @Defreq {ch, macro [@Var{dist}]}
10793 @cindex changing trap location (@code{ch})
10794 @cindex trap, changing location (@code{ch})
10795 Change the location of a trap.
10796 The first argument is the name of the macro to be invoked at
10797 the trap, and the second argument is the new location for the trap
10798 (note that the parameters are specified in opposite order as in the
10799 @code{wh} request).  This is useful for building up footnotes in a
10800 diversion to allow more space at the bottom of the page for them.
10802 Default scaling indicator for @var{dist} is @samp{v}.  If @var{dist}
10803 is missing, the trap is removed.
10805 @c XXX
10807 @ignore
10808 @Example
10809 ... (simplified) footnote example ...
10810 @endExample
10811 @end ignore
10812 @endDefreq
10814 @Defreg {.ne}
10815 The read-only number register @code{.ne} contains the amount of space
10816 that was needed in the last @code{ne} request that caused a trap to be
10817 sprung.  Useful in conjunction with the @code{.trunc} register.
10818 @xref{Page Control}, for more information.
10820 Since the @code{.ne} register is only set by traps it doesn't make
10821 much sense to use it outside of trap macros.
10822 @endDefreg
10824 @Defreg {.trunc}
10825 @cindex @code{ne} request, and the @code{.trunc} register
10826 @cindex truncated vertical space register (@code{.trunc})
10827 A read-only register containing the amount of vertical space truncated
10828 by the most recently sprung vertical position trap, or, if the trap was
10829 sprung by an @code{ne} request, minus the amount of vertical motion
10830 produced by the @code{ne} request.  In other words, at the point a trap
10831 is sprung, it represents the difference of what the vertical position
10832 would have been but for the trap, and what the vertical position
10833 actually is.
10835 Since the @code{.trunc} register is only set by traps and it doesn't make
10836 much sense to use it outside of trap macros.
10837 @endDefreg
10839 @Defreg {.pe}
10840 @cindex @code{bp} request, and traps (@code{.pe})
10841 @cindex traps, sprung by @code{bp} request (@code{.pe})
10842 @cindex page ejecting register (@code{.pe})
10843 A read-only register which is set to@tie{}1 while a page is ejected with
10844 the @code{bp} request (or by the end of input).
10846 Outside of traps this register is always zero.  In the following example,
10847 only the second call to@tie{}@code{x} is caused by @code{bp}.
10849 @Example
10850 .de x
10851 \&.pe=\\n[.pe]       
10854 .wh 1v x
10855 .wh 4v x
10856 A line.
10858 Another line.
10860     @result{} A line.
10861               .pe=0
10862               Another line.
10864               .pe=1
10865 @endExample
10866 @endDefreg
10868 @cindex diversions, and traps
10869 @cindex traps, and diversions
10870 An important fact to consider while designing macros is that diversions and
10871 traps do not interact normally.  For example, if a trap invokes a header
10872 macro (while outputting a diversion) which tries to change the font on the
10873 current page, the effect will not be visible before the diversion has
10874 completely been printed (except for input protected with @code{\!} or
10875 @code{\?}) since the data in the diversion is already formatted.  In most
10876 cases, this is not the expected behaviour.
10878 @c ---------------------------------------------------------------------
10880 @node Diversion Traps, Input Line Traps, Page Location Traps, Traps
10881 @subsection Diversion Traps
10882 @cindex diversion traps
10883 @cindex traps, diversion
10885 @Defreq {dt, dist macro}
10886 @cindex @code{.t} register, and diversions
10887 @cindex setting diversion trap (@code{dt})
10888 @cindex diversion trap, setting (@code{dt})
10889 @cindex trap, diversion, setting (@code{dt})
10890 Set a trap @emph{within} a diversion.
10891 @var{dist} is the location of the trap
10892 (identical to the @code{wh} request; default scaling indicator is
10893 @samp{v}) and @var{macro} is the name of the macro to be invoked.  The
10894 number register @code{.t} still works within diversions.
10895 @xref{Diversions}, for more information.
10896 @endDefreq
10898 @c ---------------------------------------------------------------------
10900 @node Input Line Traps, Blank Line Traps, Diversion Traps, Traps
10901 @subsection Input Line Traps
10902 @cindex input line traps
10903 @cindex traps, input line
10905 @DefreqList {it, n macro}
10906 @DefreqItem {itc, n macro}
10907 @cindex setting input line trap (@code{it})
10908 @cindex input line trap, setting (@code{it})
10909 @cindex trap, input line, setting (@code{it})
10910 Set an input line trap.
10911 @var{n}@tie{}is the number of lines of input which may be read before
10912 springing the trap, @var{macro} is the macro to be invoked.
10913 Request lines are not counted as input lines.
10915 For example, one possible use is to have a macro which prints the
10916 next @var{n}@tie{}lines in a bold font.
10918 @Example
10919 .de B
10920 .  it \\$1 B-end
10921 .  ft B
10924 .de B-end
10925 .  ft R
10927 @endExample
10929 @cindex input line traps and interrupted lines (@code{itc})
10930 @cindex interrupted lines and input line traps (@code{itc})
10931 @cindex traps, input line, and interrupted lines (@code{itc})
10932 @cindex lines, interrupted, and input line traps (@code{itc})
10933 The @code{itc} request is identical
10934 except that an interrupted text line (ending with @code{\c})
10935 is not counted as a separate line.
10937 Both requests are associated with the current environment
10938 (@pxref{Environments}); switching to another environment disables the
10939 current input trap, and going back reactivates it, restoring the number
10940 of already processed lines.
10941 @endDefreq
10943 @c ---------------------------------------------------------------------
10945 @node Blank Line Traps, End-of-input Traps, Input Line Traps, Traps
10946 @subsection Blank Line Traps
10947 @cindex blank line traps
10948 @cindex traps, blank line
10950 @Defreq {blm, macro}
10951 @cindex blank line macro (@code{blm})
10952 Set a blank line trap.
10953 @code{gtroff} executes @var{macro} when it encounters a blank line in
10954 the input file.
10955 @endDefreq
10957 @c ---------------------------------------------------------------------
10959 @node End-of-input Traps,  , Blank Line Traps, Traps
10960 @subsection End-of-input Traps
10961 @cindex end-of-input traps
10962 @cindex traps, end-of-input
10964 @Defreq {em, macro}
10965 @cindex setting end-of-input trap (@code{em})
10966 @cindex end-of-input trap, setting (@code{em})
10967 @cindex trap, end-of-input, setting (@code{em})
10968 @cindex end-of-input macro (@code{em})
10969 @cindex macro, end-of-input (@code{em})
10970 Set a trap at the end of input.  @var{macro} is executed after the
10971 last line of the input file has been processed.
10973 For example, if the document had to have a section at the bottom of the
10974 last page for someone to approve it, the @code{em} request could be
10975 used.
10977 @Example
10978 .de approval
10979 .  ne 5v
10980 .  sp |(\\n[.t] - 6v)
10981 .  in +4i
10982 .  lc _
10983 .  br
10984 Approved:\t\a
10985 .  sp
10986 Date:\t\t\a
10989 .em approval
10990 @endExample
10991 @endDefreq
10994 @c =====================================================================
10996 @node Diversions, Environments, Traps, gtroff Reference
10997 @section Diversions
10998 @cindex diversions
11000 In @code{gtroff} it is possible to @dfn{divert} text into a named
11001 storage area.  Due to the similarity to defining macros it is sometimes
11002 said to be stored in a macro.  This is used for saving text for output
11003 at a later time, which is useful for keeping blocks of text on the same
11004 page, footnotes, tables of contents, and indices.
11006 @cindex top-level diversion
11007 @cindex diversion, top-level
11008 For orthogonality it is said that @code{gtroff} is in the @dfn{top-level
11009 diversion} if no diversion is active (i.e., the data is diverted to the
11010 output device).
11012 @DefreqList {di, macro}
11013 @DefreqListEnd {da, macro}
11014 @cindex beginning diversion (@code{di})
11015 @cindex diversion, beginning (@code{di})
11016 @cindex ending diversion (@code{di})
11017 @cindex diversion, ending (@code{di})
11018 @cindex appending to a diversion (@code{da})
11019 @cindex diversion, appending (@code{da})
11020 Begin a diversion.  Like the @code{de}
11021 request, it takes an argument of a macro name to divert subsequent text
11022 into.  The @code{da} macro appends to an existing diversion.
11024 @code{di} or @code{da} without an argument ends the diversion.
11025 @endDefreq
11027 @DefreqList {box, macro}
11028 @DefreqListEnd {boxa, macro}
11029 Begin (or appends to) a diversion like the
11030 @code{di} and @code{da} requests.
11031 The difference is that @code{box} and @code{boxa}
11032 do not include a partially-filled line in the diversion.
11034 Compare this:
11036 @Example
11037 Before the box.
11038 .box xxx
11039 In the box.
11041 .box
11042 After the box.
11044     @result{} Before the box.  After the box.
11045 .xxx
11046     @result{} In the box.
11047 @endExample
11049 @noindent
11050 with this:
11052 @Example
11053 Before the diversion.
11054 .di yyy
11055 In the diversion.
11058 After the diversion.
11060     @result{} After the diversion.
11061 .yyy
11062     @result{} Before the diversion.  In the diversion.
11063 @endExample
11065 @code{box} or @code{boxa} without an argument ends the diversion.
11066 @endDefreq
11068 @DefregList {.z}
11069 @DefregListEnd {.d}
11070 @cindex @code{nl} register, and @code{.d}
11071 @cindex nested diversions
11072 @cindex diversion, nested
11073 @cindex diversion name register (@code{.z})
11074 @cindex vertical position in diversion register (@code{.d})
11075 @cindex position, vertical, in diversion, register (@code{.d})
11076 @cindex diversion, vertical position in, register (@code{.d})
11077 Diversions may be nested.  The read-only number register @code{.z}
11078 contains the name of the current diversion (this is a string-valued
11079 register).  The read-only number register @code{.d} contains the current
11080 vertical place in the diversion.  If not in a diversion it is the same
11081 as register @code{nl}.
11082 @endDefreg
11084 @Defreg {.h}
11085 @cindex high-water mark register (@code{.h})
11086 @cindex mark, high-water, register (@code{.h})
11087 @cindex position of lowest text line (@code{.h})
11088 @cindex text line, position of lowest (@code{.h})
11089 The @dfn{high-water mark} on the current page.  It corresponds to the
11090 text baseline of the lowest line on the page.  This is a read-only
11091 register.
11093 @Example
11094 .tm .h==\n[.h], nl==\n[nl]
11095     @result{} .h==0, nl==-1
11096 This is a test.
11098 .sp 2
11099 .tm .h==\n[.h], nl==\n[nl]
11100     @result{} .h==40, nl==120
11101 @endExample
11103 @cindex @code{.h} register, difference to @code{nl}
11104 @cindex @code{nl} register, difference to @code{.h}
11105 @noindent
11106 As can be seen in the previous example, empty lines are not considered
11107 in the return value of the @code{.h} register.
11108 @endDefreg
11110 @DefregList {dn}
11111 @DefregListEnd {dl}
11112 After completing a diversion, the read-write number registers @code{dn}
11113 and @code{dl} contain the vertical and horizontal size of the diversion.
11115 @Example
11116 .\" Center text both horizontally & vertically
11118 .\" Enclose macro definitions in .eo and .ec
11119 .\" to avoid the doubling of the backslash
11121 .\" macro .(c starts centering mode
11122 .de (c
11123 .  br
11124 .  ev (c
11125 .  evc 0
11126 .  in 0
11127 .  nf
11128 .  di @@c
11130 @endExample
11131 @Example
11132 .\" macro .)c terminates centering mode
11133 .de )c
11134 .  br
11135 .  ev
11136 .  di
11137 .  nr @@s (((\n[.t]u - \n[dn]u) / 2u) - 1v)
11138 .  sp \n[@@s]u
11139 .  ce 1000
11140 .  @@c
11141 .  ce 0
11142 .  sp \n[@@s]u
11143 .  br
11144 .  fi
11145 .  rr @@s
11146 .  rm @@s
11147 .  rm @@c
11149 .\" End of macro definitions, restore escape mechanism
11151 @endExample
11152 @endDefreg
11154 @DefescList {\\!, , , }
11155 @DefescListEnd {\\?, , @Var{anything}, \\?}
11156 @cindex transparent output (@code{\!}, @code{\?})
11157 @cindex output, transparent (@code{\!}, @code{\?})
11158 Prevent requests, macros, and escapes from being
11159 interpreted when read into a diversion.  Both escapes take the given text
11160 and @dfn{transparently} embed it into the diversion.  This is useful for
11161 macros which shouldn't be invoked until the diverted text is actually
11162 output.
11164 The @code{\!} escape transparently embeds text up to
11165 and including the end of the line.
11166 The @code{\?} escape transparently embeds text until the next
11167 occurrence of the @code{\?} escape.  Example:
11169 @Example
11170 \?@var{anything}\?
11171 @endExample
11173 @noindent
11174 @var{anything} may not contain newlines; use @code{\!}  to embed
11175 newlines in a diversion.  The escape sequence @code{\?} is also
11176 recognized in copy mode and turned into a single internal code; it is
11177 this code that terminates @var{anything}.  Thus the following example
11178 prints@tie{}4.
11180 @Example
11181 .nr x 1
11183 .di d
11184 \?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
11186 .nr x 2
11187 .di e
11190 .nr x 3
11191 .di f
11194 .nr x 4
11196 @endExample
11198 Both escapes read the data in copy mode.
11200 @cindex @code{\!}, in top-level diversion
11201 @cindex top-level diversion, and @code{\!}
11202 @cindex diversion, top-level, and @code{\!}
11203 If @code{\!} is used in the top-level diversion, its argument is
11204 directly embedded into the @code{gtroff} intermediate output.  This can
11205 be used for example to control a postprocessor which processes the data
11206 before it is sent to the device driver.
11208 @cindex @code{\?}, in top-level diversion
11209 @cindex top-level diversion, and @code{\?}
11210 @cindex diversion, top-level, and @code{\?}
11211 The @code{\?} escape used in the top-level diversion produces no output
11212 at all; its argument is simply ignored.
11213 @endDefesc
11215 @cindex @code{\!}, and @code{output}
11216 @cindex @code{output} request, and @code{\!}
11217 @Defreq {output, string}
11218 Emit @var{string} directly to the @code{gtroff} intermediate output
11219 (subject to copy-mode interpretation); this is similar to @code{\!} used
11220 at the top level.  An initial double quote in @var{string} is stripped off
11221 to allow initial blanks.
11223 This request can't be used before the first page has started -- if you get
11224 an error, simply insert @code{.br} before the @code{output} request.
11226 Without argument, @code{output} is ignored.
11228 Use with caution!  It is normally only needed for mark-up used by a
11229 postprocessor which does something with the output before sending it to
11230 the output device, filtering out @var{string} again.
11231 @endDefreq
11233 @Defreq {asciify, div}
11234 @cindex unformatting diversions (@code{asciify})
11235 @cindex diversion, unformatting (@code{asciify})
11236 @cindex @code{trin} request, and @code{asciify}
11237 @dfn{Unformat} the diversion specified by @var{div}
11238 in such a way that @acronym{ASCII} characters, characters translated with
11239 the @code{trin} request, space characters, and some escape sequences that
11240 were formatted and diverted are treated like ordinary input
11241 characters when the diversion is reread.  It can be also used for gross
11242 hacks; for example, the following sets register@tie{}@code{n} to@tie{}1.
11244 @Example
11245 .tr @@.
11246 .di x
11247 @@nr n 1
11250 .tr @@@@
11251 .asciify x
11253 @endExample
11255 @xref{Copy-in Mode}.
11256 @endDefreq
11258 @Defreq {unformat, div}
11259 Like @code{asciify}, unformat the specified diversion.
11260 However, @code{unformat} only unformats spaces and tabs
11261 between words.
11262 Unformatted tabs are treated as input tokens,
11263 and spaces are stretchable again.
11265 The vertical size of lines is not preserved; glyph information (font,
11266 font size, space width, etc.)@: is retained.
11267 @endDefreq
11270 @c =====================================================================
11272 @node Environments, Suppressing output, Diversions, gtroff Reference
11273 @section Environments
11274 @cindex environments
11276 It happens frequently that some text should be printed in a certain
11277 format regardless of what may be in effect at the time, for example, in
11278 a trap invoked macro to print headers and footers.  To solve this
11279 @code{gtroff} processes text in @dfn{environments}.  An
11280 environment contains most of the parameters that control text
11281 processing.  It is possible to switch amongst these environments; by
11282 default @code{gtroff} processes text in environment@tie{}0.  The
11283 following is the information kept in an environment.
11285 @itemize @bullet
11286 @item
11287 font parameters (size, family, style, glyph height and slant, space
11288 and sentence space size)
11290 @item
11291 page parameters (line length, title length, vertical spacing,
11292 line spacing, indentation, line numbering, centering, right-justifying,
11293 underlining, hyphenation data)
11295 @item
11296 fill and adjust mode
11298 @item
11299 tab stops, tab and leader characters, escape character,
11300 no-break and hyphen indicators, margin character data
11302 @item
11303 partially collected lines
11305 @item
11306 input traps
11308 @item
11309 drawing and fill colours
11310 @end itemize
11312 These environments may be given arbitrary names (see @ref{Identifiers},
11313 for more info).  Old versions of @code{troff} only had environments
11314 named @samp{0}, @samp{1}, and @samp{2}.
11316 @DefreqList {ev, [@Var{env}]}
11317 @DefregListEnd {.ev}
11318 @cindex switching environments (@code{ev})
11319 @cindex environment, switching (@code{ev})
11320 @cindex environment number/name register (@code{.ev})
11321 Switch to another environment.  The argument @var{env} is the name of
11322 the environment to switch to.  With no argument, @code{gtroff} switches
11323 back to the previous environment.  There is no limit on the number of
11324 named environments; they are created the first time that they are
11325 referenced.  The @code{.ev} read-only register contains the name or
11326 number of the current environment.  This is a string-valued register.
11328 Note that a call to @code{ev} (with argument) pushes the previously
11329 active environment onto a stack.  If, say, environments @samp{foo},
11330 @samp{bar}, and @samp{zap} are called (in that order), the first
11331 @code{ev} request without parameter switches back to environment
11332 @samp{bar} (which is popped off the stack), and a second call
11333 switches back to environment @samp{foo}.
11335 Here is an example:
11337 @Example
11338 .ev footnote-env
11339 .fam N
11340 .ps 6
11341 .vs 8
11342 .ll -.5i
11347 .ev footnote-env
11348 \(dg Note the large, friendly letters.
11350 @endExample
11351 @endDefreq
11353 @Defreq {evc, env}
11354 @cindex copying environment (@code{evc})
11355 @cindex environment, copying (@code{evc})
11356 Copy the environment @var{env} into the current environment.
11358 The following environment data is not copied:
11360 @itemize @bullet
11361 @item
11362 Partially filled lines.
11364 @item
11365 The status whether the previous line was interrupted.
11367 @item
11368 The number of lines still to center, or to right-justify, or to underline
11369 (with or without underlined spaces); they are set to zero.
11371 @item
11372 The status whether a temporary indent is active.
11374 @item
11375 Input traps and its associated data.
11377 @item
11378 Line numbering mode is disabled; it can be reactivated with
11379 @w{@samp{.nm +0}}.
11381 @item
11382 The number of consecutive hyphenated lines (set to zero).
11383 @end itemize
11384 @endDefreq
11386 @DefregList {.w}
11387 @DefregItem {.cht}
11388 @DefregItem {.cdp}
11389 @DefregListEnd {.csk}
11390 @cindex environment, dimensions of last glyph (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
11391 @cindex width, of last glyph (@code{.w})
11392 @cindex height, of last glyph (@code{.cht})
11393 @cindex depth, of last glyph (@code{.cdp})
11394 @cindex skew, of last glyph (@code{.csk})
11395 @cindex last glyph, dimensions (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
11396 @cindex glyph, last, dimensions (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
11397 The @code{\n[.w]} register contains the
11398 width of the last glyph added to the current environment.
11400 The @code{\n[.cht]} register contains the
11401 height of the last glyph added to the current environment.
11403 The @code{\n[.cdp]} register contains the
11404 depth of the last glyph added to the current environment.
11405 It is positive for glyphs extending below the baseline.
11407 The @code{\n[.csk]} register contains the
11408 @dfn{skew} (how far to the right of the glyph's center
11409 that @code{gtroff} should place an accent)
11410 of the last glyph added to the current environment.
11411 @endDefreg
11413 @Defreg {.n}
11414 @cindex environment, previous line length (@code{.n})
11415 @cindex line length, previous (@code{.n})
11416 @cindex length of previous line (@code{.n})
11417 @cindex previous line length (@code{.n})
11418 The @code{\n[.n]} register contains the
11419 length of the previous output line in the current environment.
11420 @endDefreg
11423 @c =====================================================================
11425 @node Suppressing output, Colors, Environments, gtroff Reference
11426 @section Suppressing output
11428 @Defesc {\\O, , num, }
11429 @cindex suppressing output (@code{\O})
11430 @cindex output, suppressing (@code{\O})
11431 Disable or enable output depending on the value of @var{num}:
11433 @table @samp
11434 @item \O0
11435 Disable any glyphs from being emitted to the device driver, provided that
11436 the escape occurs at the outer level (see @code{\O[3]} and @code{\O[4]}).
11437 Motion is not suppressed so effectively @code{\O[0]} means @emph{pen up}.
11439 @item \O1
11440 Enable output of glyphs, provided that the escape occurs at the outer
11441 level.
11442 @end table
11444 @vindex opminx
11445 @vindex opminy
11446 @vindex opmaxx
11447 @vindex opmaxy
11448 @code{\O0} and @code{\O1} also reset the four registers @samp{opminx},
11449 @samp{opminy}, @samp{opmaxx}, and @samp{opmaxy} to @minus{}1.
11450 @xref{Register Index}.  These four registers mark the top left and
11451 bottom right hand corners of a box which encompasses all written glyphs.
11453 For example the input text:
11455 @Example
11456 Hello \O[0]world \O[1]this is a test.
11457 @endExample
11459 @noindent
11460 produces the following output:
11462 @Example
11463 Hello       this is a test.
11464 @endExample
11466 @table @samp
11467 @item \O2
11468 Provided that the escape occurs at the outer level, enable output of
11469 glyphs and also write out to @code{stderr} the page number and four
11470 registers encompassing the glyphs previously written since the last call
11471 to @code{\O}.
11473 @item \O3
11474 Begin a nesting level.  At start-up, @code{gtroff} is at outer level.
11476 @item \O4
11477 End a nesting level.
11479 @item \O[5@var{P}@var{filename}]
11480 This escape is @code{grohtml} specific.  Provided that this escape
11481 occurs at the outer nesting level write the @code{filename} to
11482 @code{stderr}.  The position of the image, @var{P}, must be specified
11483 and must be one of @code{l}, @code{r}, @code{c}, or@tie{}@code{i} (left,
11484 right, centered, inline).  @var{filename} will be associated with the
11485 production of the next inline image.
11486 @end table
11487 @endDefesc
11489 @c =====================================================================
11491 @node Colors, I/O, Suppressing output, gtroff Reference
11492 @section Colors
11493 @cindex colors
11495 @DefreqList {color, [@Var{n}]}
11496 @DefregListEnd {.color}
11497 If @var{n} is missing or non-zero, activate colors (this is the default);
11498 otherwise, turn it off.
11500 The read-only number register @code{.color} is@tie{}1 if colors are active,
11501 0@tie{}otherwise.
11503 Internally, @code{color} sets a global flag; it does not produce a token.
11504 Similar to the @code{cp} request, you should use it at the beginning of
11505 your document to control color output.
11507 Colors can be also turned off with the @option{-c} command line option.
11508 @endDefreq
11510 @Defreq {defcolor, ident scheme color_components}
11511 Define color with name @var{ident}.  @var{scheme} can be one of  the
11512 following values: @code{rgb} (three components), @code{cym} (three
11513 components), @code{cmyk} (four components), and @code{gray} or
11514 @code{grey} (one component).
11516 @cindex default color
11517 @cindex color, default
11518 Color components can be given either as a hexadecimal string or as
11519 positive decimal integers in the range 0--65535.  A hexadecimal string
11520 contains all color components concatenated.  It must start with either
11521 @code{#} or @code{##}; the former specifies hex values in the range
11522 0--255 (which are internally multiplied by@tie{}257), the latter in the
11523 range 0--65535.  Examples: @code{#FFC0CB} (pink), @code{##ffff0000ffff}
11524 (magenta).  The default color name @c{default} can't be redefined; its
11525 value is device-specific (usually black).  It is possible that the
11526 default color for @code{\m} and @code{\M} is not identical.
11528 @cindex @code{f} unit, and colors
11529 @cindex unit, @code{f}, and colors
11530 A new scaling indicator@tie{}@code{f} has been introduced which multiplies
11531 its value by 65536; this makes it convenient to specify color components
11532 as fractions in the range 0 to@tie{}1 (1f equals 65536u).  Example:
11534 @Example
11535 .defcolor darkgreen rgb 0.1f 0.5f 0.2f
11536 @endExample
11538 Note that @code{f} is the default scaling indicator for the
11539 @code{defcolor} request, thus the above statement is equivalent to
11541 @Example
11542 .defcolor darkgreen rgb 0.1 0.5 0.2
11543 @endExample
11544 @endDefreq
11546 @DefescList {\\m, , c, }
11547 @DefescItem {\\m, @lparen{}, co, }
11548 @DefescListEnd {\\m, @lbrack{}, color, @rbrack}
11549 Set drawing color.  The following example shows how to turn the next four
11550 words red.
11552 @Example
11553 \m[red]these are in red\m[] and these words are in black.
11554 @endExample
11556 The escape @code{\m[]} returns to the previous color.
11558 The drawing color is associated with the current environment
11559 (@pxref{Environments}).
11561 Note that @code{\m} doesn't produce an input token in @code{gtroff}.
11562 As a consequence, it can be used in requests like @code{mc} (which
11563 expects a single character as an argument) to change the color on
11564 the fly:
11566 @Example
11567 .mc \m[red]x\m[]
11568 @endExample
11569 @endDefesc
11571 @DefescList {\\M, , c, }
11572 @DefescItem {\\M, @lparen{}, co, }
11573 @DefescListEnd {\\M, @lbrack{}, color, @rbrack}
11574 Set background color for filled objects drawn with the
11575 @code{\D'@dots{}'} commands.
11577 A red ellipse can be created with the following code:
11579 @Example
11580 \M[red]\h'0.5i'\D'E 2i 1i'\M[]
11581 @endExample
11583 The escape @code{\M[]} returns to the previous fill color.
11585 The fill color is associated with the current environment
11586 (@pxref{Environments}).
11588 Note that @code{\M} doesn't produce an input token in @code{gtroff}.
11589 @endDefesc
11592 @c =====================================================================
11594 @node I/O, Postprocessor Access, Colors, gtroff Reference
11595 @section I/O
11596 @cindex i/o
11597 @cindex input and output requests
11598 @cindex requests for input and output
11599 @cindex output and input requests
11601 @code{gtroff} has several requests for including files:
11603 @Defreq {so, file}
11604 @cindex including a file (@code{so})
11605 @cindex file, inclusion (@code{so})
11606 Read in the specified @var{file} and
11607 includes it in place of the @code{so} request.  This is quite useful for
11608 large documents, e.g.@: keeping each chapter in a separate file.
11609 @xref{gsoelim}, for more information.
11611 Since @code{gtroff} replaces the @code{so} request with the contents
11612 of @code{file}, it makes a difference whether the data is terminated with
11613 a newline or not: Assuming that file @file{xxx} contains the word
11614 @samp{foo} without a final newline, this
11616 @Example
11617 This is
11618 .so xxx
11620 @endExample
11622 @noindent
11623 yields @samp{This is foobar}.
11624 @endDefreq
11626 @Defreq {pso, command}
11627 Read the standard output from the specified @var{command}
11628 and includes it in place of the @code{pso} request.
11630 @cindex safer mode
11631 @cindex mode, safer
11632 @cindex unsafe mode
11633 @cindex mode, unsafe
11634 This request causes an error if used in safer mode (which is the default).
11635 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
11636 mode.
11638 The comment regarding a final newline for the @code{so} request is valid
11639 for @code{pso} also.
11640 @endDefreq
11642 @Defreq {mso, file}
11643 Identical to the @code{so} request except that @code{gtroff} searches for
11644 the specified @var{file} in the same directories as macro files for the
11645 the @option{-m} command line option.  If the file name to be included
11646 has the form @file{@var{name}.tmac} and it isn't found, @code{mso} tries
11647 to include @file{tmac.@var{name}} and vice versa.
11648 @endDefreq
11650 @DefreqList {trf, file}
11651 @DefreqListEnd {cf, file}
11652 @cindex transparent output (@code{cf}, @code{trf})
11653 @cindex output, transparent (@code{cf}, @code{trf})
11654 Transparently output the contents of @var{file}.  Each line is output
11655 as if it were preceded by @code{\!}; however, the lines are not subject
11656 to copy mode interpretation.  If the file does not end with a newline,
11657 then a newline is added (@code{trf} only).  For example, to define a
11658 macro@tie{}@code{x} containing the contents of file@tie{}@file{f}, use
11660 @Example
11661 .di x
11662 .trf f
11664 @endExample
11666 Both @code{trf} and @code{cf}, when used in a diversion,
11667 embeds an object in the diversion which, when reread, causes the
11668 contents of @var{file} to be transparently copied through to the
11669 output.  In @acronym{UNIX} @code{troff}, the contents of @var{file}
11670 is immediately copied through to the output regardless of whether there
11671 is a current diversion; this behaviour is so anomalous that it must be
11672 considered a bug.
11674 @cindex @code{trf} request, and invalid characters
11675 @cindex characters, invalid for @code{trf} request
11676 @cindex invalid characters for @code{trf} request
11677 While @code{cf} copies the contents of @var{file} completely unprocessed,
11678 @code{trf} disallows characters such as NUL that are not valid
11679 @code{gtroff} input characters (@pxref{Identifiers}).
11681 Both requests cause a line break.
11682 @endDefreq
11684 @Defreq {nx, [@Var{file}]}
11685 @cindex processing next file (@code{nx})
11686 @cindex file, processing next (@code{nx})
11687 @cindex next file, processing (@code{nx})
11688 Force @code{gtroff} to continue processing of
11689 the file specified as an argument.  If no argument is given, immediately
11690 jump to the end of file.
11691 @endDefreq
11693 @Defreq {rd, [@Var{prompt} [@Var{arg1} @Var{arg2} @dots{}]]}
11694 @cindex reading from standard input (@code{rd})
11695 @cindex standard input, reading from (@code{rd})
11696 @cindex input, standard, reading from (@code{rd})
11697 Read from standard input, and include what is read as though it
11698 were part of the input file.  Text is read until a blank line
11699 is encountered.
11701 If standard input is a TTY input device (keyboard), write @var{prompt}
11702 to standard error, followed by a colon (or send BEL for a beep if no
11703 argument is given).
11705 Arguments after @var{prompt} are available for the input.  For example,
11706 the line
11708 @Example
11709 .rd data foo bar
11710 @endExample
11712 with the input @w{@samp{This is \$2.}} prints
11714 @Example
11715 This is bar.
11716 @endExample
11717 @endDefreq
11719 @cindex form letters
11720 @cindex letters, form
11721 Using the @code{nx} and @code{rd} requests,
11722 it is easy to set up form letters.  The form
11723 letter template is constructed like this, putting the following lines
11724 into a file called @file{repeat.let}:
11726 @Example
11728 \*(td
11729 .sp 2
11735 Body of letter.
11737 .nx repeat.let
11738 @endExample
11740 @cindex @code{ex} request, used with @code{nx} and @code{rd}
11741 @noindent
11742 When this is run, a file containing the following lines should be
11743 redirected in.  Note that requests included in this file are executed
11744 as though they were part of the form letter.  The last block of input
11745 is the @code{ex} request which tells @code{groff} to stop processing.  If
11746 this was not there, @code{groff} would not know when to stop.
11748 @Example
11749 Trent A. Fisher
11750 708 NW 19th Av., #202
11751 Portland, OR  97209
11753 Dear Trent,
11755 Len Adollar
11756 4315 Sierra Vista
11757 San Diego, CA  92103
11759 Dear Mr. Adollar,
11762 @endExample
11764 @Defreq {pi, pipe}
11765 Pipe the output of @code{gtroff} to the shell command(s)
11766 specified by @var{pipe}.  This request must occur before
11767 @code{gtroff} has a chance to print anything.
11769 @cindex safer mode
11770 @cindex mode, safer
11771 @cindex unsafe mode
11772 @cindex mode, unsafe
11773 @code{pi} causes an error if used in safer mode (which is the default).
11774 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
11775 mode.
11777 Multiple calls to @code{pi} are allowed, acting as a chain.  For example,
11779 @Example
11780 .pi foo
11781 .pi bar
11783 @endExample
11785 is the same as @w{@samp{.pi foo | bar}}.
11787 @cindex @code{groff}, and @code{pi} request
11788 @cindex @code{pi} request, and @code{groff}
11789 Note that the intermediate output format of @code{gtroff} is piped to
11790 the specified commands.  Consequently, calling @code{groff} without the
11791 @option{-Z} option normally causes a fatal error.
11792 @endDefreq
11794 @DefreqList {sy, cmds}
11795 @DefregListEnd {systat}
11796 Execute the shell command(s) specified by @var{cmds}.  The output is not
11797 saved anyplace, so it is up to the user to do so.
11799 @cindex safer mode
11800 @cindex mode, safer
11801 @cindex unsafe mode
11802 @cindex mode, unsafe
11803 This request causes an error if used in safer mode (which is the default).
11804 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
11805 mode.
11807 For example, the following code fragment introduces the current time into a
11808 document:
11810 @cindex time, current
11811 @cindex current time
11812 @pindex perl
11813 @Example
11814 .sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
11815              (localtime(time))[2,1,0]' > /tmp/x\n[$$]
11816 .so /tmp/x\n[$$]
11817 .sy rm /tmp/x\n[$$]
11818 \nH:\nM:\nS
11819 @endExample
11821 @noindent
11822 Note that this works by having the @code{perl} script (run by @code{sy})
11823 print out the @code{nr} requests which set the number registers
11824 @code{H}, @code{M}, and @code{S}, and then reads those commands in with
11825 the @code{so} request.
11827 For most practical purposes, the number registers @code{seconds},
11828 @code{minutes}, and @code{hours} which are initialized at start-up of
11829 @code{gtroff} should be sufficient.  Use the @code{af} request to get a
11830 formatted output:
11832 @Example
11833 .af hours 00
11834 .af minutes 00
11835 .af seconds 00
11836 \n[hours]:\n[minutes]:\n[seconds]
11837 @endExample
11839 @cindex @code{system()} return value register (@code{systat})
11840 The @code{systat} read-write number register contains the return value
11841 of the @code{system()} function executed by the last @code{sy} request.
11842 @endDefreq
11844 @DefreqList {open, stream file}
11845 @DefreqListEnd {opena, stream file}
11846 @cindex opening file (@code{open})
11847 @cindex file, opening (@code{open})
11848 @cindex appending to a file (@code{opena})
11849 @cindex file, appending to (@code{opena})
11850 Open the specified @var{file} for writing and
11851 associates the specified @var{stream} with it.
11853 The @code{opena} request is like @code{open}, but if the file exists,
11854 append to it instead of truncating it.
11856 @cindex safer mode
11857 @cindex mode, safer
11858 @cindex unsafe mode
11859 @cindex mode, unsafe
11860 Both @code{open} and @code{opena} cause an error if used in safer mode
11861 (which is the default).  Use @code{groff}'s or @code{troff}'s @option{-U}
11862 option to activate unsafe mode.
11863 @endDefreq
11865 @DefreqList {write, stream data}
11866 @DefreqListEnd {writec, stream data}
11867 @cindex copy-in mode, and @code{write} requests
11868 @cindex mode, copy-in, and @code{write} requests
11869 @cindex writing to file (@code{write})
11870 @cindex file, writing to (@code{write})
11871 Write to the file associated with the specified @var{stream}.
11872 The stream must previously have
11873 been the subject of an open request.  The remainder of the line is
11874 interpreted as the @code{ds} request reads its second argument: A
11875 leading @samp{"} is stripped, and it is read in copy-in mode.
11877 The @code{writec} request is like @code{write}, but only
11878 @code{write} appends a newline to the data.
11879 @endDefreq
11881 @Defreq {writem, stream xx}
11882 @cindex @code{asciify} request, and @code{writem}
11883 Write the contents of the macro or string @var{xx}
11884 to the file associated with the specified @var{stream}.
11886 @var{xx} is read in copy mode, i.e., already formatted elements are
11887 ignored.  Consequently, diversions must be unformatted with the
11888 @code{asciify} request before calling @code{writem}.  Usually, this
11889 means a loss of information.
11890 @endDefreq
11892 @Defreq {close, stream}
11893 @cindex closing file (@code{close})
11894 @cindex file, closing (@code{close})
11895 Close the specified @var{stream};
11896 the stream is no longer an acceptable argument to the
11897 @code{write} request.
11899 Here a simple macro to write an index entry.
11901 @Example
11902 .open idx test.idx
11904 .de IX
11905 .  write idx \\n[%] \\$*
11908 .IX test entry
11910 .close idx
11911 @endExample
11912 @endDefreq
11914 @DefescList {\\V, , e, }
11915 @DefescItem {\\V, @lparen{}, ev, }
11916 @DefescListEnd {\\V, @lbrack{}, env, @rbrack}
11917 Interpolate the contents of the specified environment variable
11918 @var{env} (one-character name@tie{}@var{e}, two-character name @var{ev})
11919 as returned by the function @code{getenv}.  @code{\V} is interpreted
11920 in copy-in mode.
11921 @endDefesc
11924 @c =====================================================================
11926 @node Postprocessor Access, Miscellaneous, I/O, gtroff Reference
11927 @section Postprocessor Access
11928 @cindex postprocessor access
11929 @cindex access of postprocessor
11931 There are two escapes which give information directly to the
11932 postprocessor.  This is particularly useful for embedding
11933 @sc{PostScript} into the final document.
11935 @Defesc {\\X, ', xxx, '}
11936 Embeds its argument into the @code{gtroff}
11937 output preceded with @w{@samp{x X}}.
11939 @cindex @code{\&}, in @code{\X}
11940 @cindex @code{\)}, in @code{\X}
11941 @cindex @code{\%}, in @code{\X}
11942 @ifnotinfo
11943 @cindex @code{\:}, in @code{\X}
11944 @end ifnotinfo
11945 @ifinfo
11946 @cindex @code{\@r{<colon>}}, in @code{\X}
11947 @end ifinfo
11948 The escapes @code{\&}, @code{\)}, @code{\%}, and @code{\:} are ignored
11949 within @code{\X}, @w{@samp{\ }} and @code{\~} are converted to single
11950 space characters.  All other escapes (except @code{\\} which produces a
11951 backslash) cause an error.
11953 @kindex use_charnames_in_special
11954 @pindex DESC@r{, and @code{use_charnames_in_special}}
11955 @cindex @code{\X}, and special characters
11956 If the @samp{use_charnames_in_special} keyword is set in the @file{DESC}
11957 file, special characters no longer cause an error; the name @var{xx} is
11958 represented as @samp{\(@var{xx})} in the @w{@samp{x X}} output command.
11959 Additionally, the backslash is represented as @code{\\}.
11961 @samp{use_charnames_in_special} is currently used by @code{grohtml} only.
11962 @endDefesc
11964 @DefescList {\\Y, , n, }
11965 @DefescItem {\\Y, @lparen{}, nm, }
11966 @DefescListEnd {\\Y, @lbrack{}, name, @rbrack}
11967 This is approximately equivalent to @samp{\X'\*[@var{name}]'}
11968 (one-character name@tie{}@var{n}, two-character name @var{nm}).
11969 However, the contents of the string or macro @var{name} are not
11970 interpreted; also it is permitted for @var{name} to have been defined
11971 as a macro and thus contain newlines (it is not permitted for the
11972 argument to @code{\X} to contain newlines).  The inclusion of
11973 newlines requires an extension to the @acronym{UNIX} @code{troff}
11974 output format, and confuses drivers that do not know about this
11975 extension (@pxref{Device Control Commands}).
11976 @endDefesc
11978 @xref{Output Devices}.
11981 @c =====================================================================
11983 @node Miscellaneous, Gtroff Internals, Postprocessor Access, gtroff Reference
11984 @section Miscellaneous
11986 This section documents parts of @code{gtroff} which cannot (yet) be
11987 categorized elsewhere in this manual.
11989 @Defreq {nm, [@Var{start} [@Var{inc} [@Var{space} [@Var{indent}]]]]}
11990 @cindex printing line numbers (@code{nm})
11991 @cindex line numbers, printing (@code{nm})
11992 @cindex numbers, line, printing (@code{nm})
11993 Print line numbers.
11994 @var{start} is the line number of the @emph{next}
11995 output line.  @var{inc} indicates which line numbers are printed.
11996 For example, the value@tie{}5 means to emit only line numbers which
11997 are multiples of@tie{}5; this defaults to@tie{}1.  @var{space} is the
11998 space to be left between the number and the text; this defaults to
11999 one digit space.  The fourth argument is the indentation of the line
12000 numbers, defaulting to zero.  Both @var{space} and @var{indent} are
12001 given as multiples of digit spaces; they can be negative also.
12002 Without any arguments, line numbers are turned off.
12004 @code{gtroff} reserves three digit spaces for the line number (which is
12005 printed right-justified) plus the amount given by @var{indent}; the
12006 output lines are concatenated to the line numbers, separated by
12007 @var{space}, and @emph{without} reducing the line length.  Depending
12008 on the value of the horizontal page offset (as set with the
12009 @code{po} request), line numbers which are longer than the reserved
12010 space stick out to the left, or the whole line is moved to the right.
12012 Parameters corresponding to missing arguments are not changed; any
12013 non-digit argument (to be more precise, any argument starting with a
12014 character valid as a delimiter for identifiers) is also treated as
12015 missing.
12017 If line numbering has been disabled with a call to @code{nm} without
12018 an argument, it can be reactivated with @samp{.nm +0}, using the
12019 previously active line numbering parameters.
12021 The parameters of @code{nm} are associated with the current environment
12022 (@pxref{Environments}).  The current output line number is available
12023 in the number register @code{ln}.
12025 @Example
12026 .po 1m
12027 .ll 2i
12028 This test shows how line numbering works with groff.
12029 .nm 999
12030 This test shows how line numbering works with groff.
12032 .nm xxx 3 2
12033 .ll -\w'0'u
12034 This test shows how line numbering works with groff.
12035 .nn 2
12036 This test shows how line numbering works with groff.
12037 @endExample
12039 @noindent
12040 And here the result:
12042 @Example
12043  This  test shows how
12044  line numbering works
12045  999 with   groff.   This
12046 1000 test shows how  line
12047 1001 numbering works with
12048 1002 groff.
12049       This test shows how
12050       line      numbering
12051  works  with  groff.
12052  This test shows how
12053 1005  line      numbering
12054       works with groff.
12055 @endExample
12056 @endDefreq
12058 @Defreq {nn, [@Var{skip}]}
12059 Temporarily turn off line numbering.  The argument is the number
12060 of lines not to be numbered; this defaults to@tie{}1.
12061 @endDefreq
12063 @Defreq {mc, glyph [@Var{dist}]}
12064 @cindex margin glyph (@code{mc})
12065 @cindex glyph, for margins (@code{mc})
12066 Print a @dfn{margin character} to the right of the
12067 text.@footnote{@dfn{Margin character} is a misnomer since it is an
12068 output glyph.}  The first argument is the glyph to be
12069 printed.  The second argument is the distance away from the right
12070 margin.  If missing, the previously set value is used; default is
12071 10@dmn{pt}).  For text lines that are too long (that is, longer than
12072 the text length plus @var{dist}), the margin character is directly
12073 appended to the lines.
12075 With no arguments the margin character is turned off.
12076 If this occurs before a break, no margin character is printed.
12078 @cindex @code{tl} request, and @code{mc}
12079 For empty lines and lines produced by the @code{tl} request no margin
12080 character is emitted.
12082 The margin character is associated with the current environment
12083 (@pxref{Environments}).
12085 @pindex nrchbar
12086 @pindex changebar
12087 This is quite useful for indicating text that has changed, and, in fact,
12088 there are programs available for doing this (they are called
12089 @code{nrchbar} and @code{changebar} and can be found in any
12090 @samp{comp.sources.unix} archive.
12092 @Example
12093 .ll 3i
12094 .mc |
12095 This paragraph is highlighted with a margin
12096 character.
12098 Note that vertical space isn't marked.
12102 But we can fake it with `\&'.
12103 @endExample
12105 Result:
12107 @Example
12108 This  paragraph is highlighted |
12109 with a margin character.       |
12111 Note that vertical space isn't |
12112 marked.                        |
12113                                |
12114 But we can fake it with `\&'.  |
12115 @endExample
12116 @endDefreq
12118 @DefreqList {psbb, filename}
12119 @DefregItem {llx}
12120 @DefregItem {lly}
12121 @DefregItem {urx}
12122 @DefregListEnd {ury}
12123 @cindex PostScript, bounding box
12124 @cindex bounding box
12125 Retrieve the bounding box of the PostScript image
12126 found in @var{filename}.
12127 The file must conform to
12128 Adobe's @dfn{Document Structuring Conventions} (DSC);
12129 the command searches for a @code{%%BoundingBox} comment
12130 and extracts the bounding box values into the number registers
12131 @code{llx}, @code{lly}, @code{urx}, and @code{ury}.
12132 If an error occurs (for example, @code{psbb} cannot find
12133 the @code{%%BoundingBox} comment),
12134 it sets the four number registers to zero.
12135 @endDefreq
12138 @c =====================================================================
12140 @node Gtroff Internals, Debugging, Miscellaneous, gtroff Reference
12141 @section @code{gtroff} Internals
12143 @cindex input token
12144 @cindex token, input
12145 @cindex output node
12146 @cindex node, output
12147 @code{gtroff} processes input in three steps.  One or more input
12148 characters are converted to an @dfn{input token}.@footnote{Except the
12149 escapes @code{\f}, @code{\F}, @code{\H}, @code{\m}, @code{\M}, @code{\R},
12150 @code{\s}, and @code{\S} which are processed immediately if not in
12151 copy-in mode.}  Then, one or more input tokens are converted to an
12152 @dfn{output node}.  Finally, output nodes are converted to the
12153 intermediate output language understood by all output devices.
12155 Actually, before step one happens, @code{gtroff} converts certain
12156 escape sequences into reserved input characters (not accessible by
12157 the user); such reserved characters are used for other internal
12158 processing also -- this is the very reason why not all characters
12159 are valid input.  @xref{Identifiers}, for more on this topic.
12161 For example, the input string @samp{fi\[:u]} is converted into a
12162 character token @samp{f}, a character token @samp{i}, and a special
12163 token @samp{:u} (representing u@tie{}umlaut).  Later on, the character
12164 tokens @samp{f} and @samp{i} are merged to a single output node
12165 representing the ligature glyph @samp{fi} (provided the current font
12166 has a glyph for this ligature); the same happens with @samp{:u}.  All
12167 output glyph nodes are `processed' which means that they are invariably
12168 associated with a given font, font size, advance width, etc.  During
12169 the formatting process, @code{gtroff} itself adds various nodes to
12170 control the data flow.
12172 Macros, diversions, and strings collect elements in two chained lists:
12173 a list of input tokens which have been passed unprocessed, and a list
12174 of output nodes.  Consider the following the diversion.
12176 @Example
12177 .di xxx
12183 @endExample
12185 @noindent
12186 It contains these elements.
12188 @multitable {@i{vertical size node}} {token list} {element number}
12189 @item node list               @tab token list @tab element number
12191 @item @i{line start node}     @tab ---        @tab 1
12192 @item @i{glyph node @code{a}} @tab ---        @tab 2
12193 @item @i{word space node}     @tab ---        @tab 3
12194 @item ---                     @tab @code{b}   @tab 4
12195 @item ---                     @tab @code{\n}  @tab 5
12196 @item @i{glyph node @code{c}} @tab ---        @tab 6
12197 @item @i{vertical size node}  @tab ---        @tab 7
12198 @item @i{vertical size node}  @tab ---        @tab 8
12199 @item ---                     @tab @code{\n}  @tab 9
12200 @end multitable
12202 @cindex @code{\v}, internal representation
12203 @noindent
12204 Elements 1, 7, and@tie{}8 are inserted by @code{gtroff}; the latter two
12205 (which are always present) specify the vertical extent of the last
12206 line, possibly modified by @code{\x}.  The @code{br} request finishes
12207 the current partial line, inserting a newline input token which is
12208 subsequently converted to a space when the diversion is reread.  Note
12209 that the word space node has a fixed width which isn't stretchable
12210 anymore.  To convert horizontal space nodes back to input tokens, use
12211 the @code{unformat} request.
12213 Macros only contain elements in the token list (and the node list is
12214 empty); diversions and strings can contain elements in both lists.
12216 Note that the @code{chop} request simply reduces the number of elements in a
12217 macro, string, or diversion by one.  Exceptions are @dfn{compatibility save}
12218 and @dfn{compatibility ignore} input tokens which are ignored.  The
12219 @code{substring} request also ignores those input tokens.
12221 Some requests like @code{tr} or @code{cflags} work on glyph
12222 identifiers only; this means that the associated glyph can be changed
12223 without destroying this association.  This can be very helpful for
12224 substituting glyphs.  In the following example, we assume that
12225 glyph @samp{foo} isn't available by default, so we provide a
12226 substitution using the @code{fchar} request and map it to input
12227 character @samp{x}.
12229 @Example
12230 .fchar \[foo] foo
12231 .tr x \[foo]
12232 @endExample
12234 @noindent
12235 Now let us assume that we install an additional special font
12236 @samp{bar} which has glyph @samp{foo}.
12238 @Example
12239 .special bar
12240 .rchar \[foo]
12241 @endExample
12243 @noindent
12244 Since glyphs defined with @code{fchar} are searched before glyphs
12245 in special fonts, we must call @code{rchar} to remove the definition
12246 of the fallback glyph.  Anyway, the translation is still active;
12247 @samp{x} now maps to the real glyph @samp{foo}.
12250 @c =====================================================================
12252 @node Debugging, Implementation Differences, Gtroff Internals, gtroff Reference
12253 @section Debugging
12254 @cindex debugging
12256 @code{gtroff} is not easy to debug, but there are some useful features
12257 and strategies for debugging.
12259 @Defreq {lf, line filename}
12260 @pindex soelim
12261 @cindex multi-file documents
12262 @cindex documents, multi-file
12263 @cindex setting input line number (@code{lf})
12264 @cindex input line number, setting (@code{lf})
12265 @cindex number, input line, setting (@code{lf})
12266 Change the line number and the file name @code{gtroff} shall use for
12267 error and warning messages.  @var{line} is the input line number of the
12268 @emph{next} line.
12270 Without argument, the request is ignored.
12272 This is a debugging aid for documents which are split into many files,
12273 then put together with @code{soelim} and other preprocessors.  Usually,
12274 it isn't invoked manually.
12275 @endDefreq
12277 @DefreqList {tm, string}
12278 @DefreqItem {tm1, string}
12279 @DefreqListEnd {tmc, string}
12280 @cindex printing to stderr (@code{tm}, @code{tm1}, @code{tmc})
12281 @cindex stderr, printing to (@code{tm}, @code{tm1}, @code{tmc})
12282 Send @var{string} to the standard error output;
12283 this is very useful for printing debugging messages among other things.
12285 @var{string} is read in copy mode.
12287 The @code{tm} request ignores leading spaces of @var{string}; @code{tm1}
12288 handles its argument similar to the @code{ds} request: a leading double
12289 quote in @var{string} is stripped to allow initial blanks.
12291 The @code{tmc} request is similar to @code{tm1} but does
12292 not append a newline (as is done in @code{tm} and @code{tm1}).
12293 @endDefreq
12295 @Defreq {ab, [@Var{string}]}
12296 @cindex aborting (@code{ab})
12297 Similar to the @code{tm} request, except that
12298 it causes @code{gtroff} to stop processing.  With no argument it
12299 prints @samp{User Abort.} to standard error.
12300 @endDefreq
12302 @Defreq {ex, }
12303 @cindex @code{ex} request, use in debugging
12304 @cindex exiting (@code{ex})
12305 The @code{ex} request also causes @code{gtroff} to stop processing;
12306 see also @ref{I/O}.
12307 @endDefreq
12309 When doing something involved it is useful to leave the debugging
12310 statements in the code and have them turned on by a command line flag.
12312 @Example
12313 .if \n(DB .tm debugging output
12314 @endExample
12316 @noindent
12317 To activate these statements say
12319 @Example
12320 groff -rDB=1 file
12321 @endExample
12323 If it is known in advance that there will be many errors and no useful
12324 output, @code{gtroff} can be forced to suppress formatted output with
12325 the @option{-z} flag.
12327 @Defreq {pm, }
12328 @cindex dumping symbol table (@code{pm})
12329 @cindex symbol table, dumping (@code{pm})
12330 Print the entire symbol table on @code{stderr}.  Names of all defined
12331 macros, strings, and diversions are print together with their size in
12332 bytes.  Since @code{gtroff} sometimes adds nodes by itself, the
12333 returned size can be larger than expected.
12335 This request differs from @acronym{UNIX} @code{troff}: @code{gtroff}
12336 reports the sizes of diversions, ignores an additional argument to
12337 print only the total of the sizes, and the size isn't returned in
12338 blocks of 128 characters.
12339 @endDefreq
12341 @Defreq {pnr, }
12342 @cindex dumping number registers (@code{pnr})
12343 @cindex number registers, dumping (@code{pnr})
12344 Print the names and contents of all
12345 currently defined number registers on @code{stderr}.
12346 @endDefreq
12348 @Defreq {ptr, }
12349 @cindex dumping traps (@code{ptr})
12350 @cindex traps, dumping (@code{ptr})
12351 Print the names and positions of all traps
12352 (not including input line traps and diversion traps) on @code{stderr}.
12353 Empty slots in the page trap list are printed as well, because they can
12354 affect the priority of subsequently planted traps.
12355 @endDefreq
12357 @Defreq {fl, }
12358 @cindex flush output (@code{fl})
12359 @cindex output, flush (@code{fl})
12360 @cindex interactive use of @code{gtroff}
12361 @cindex @code{gtroff}, interactive use
12362 Instruct @code{gtroff} to flush its output immediately.  The intent
12363 is for interactive use, but this behaviour is currently not
12364 implemented in @code{gtroff}.  Contrary to @acronym{UNIX} @code{troff},
12365 TTY output is sent to a device driver also (@code{grotty}), making it
12366 non-trivial to communicate interactively.
12368 This request causes a line break.
12369 @endDefreq
12371 @Defreq {backtrace, }
12372 @cindex backtrace of input stack (@code{backtrace})
12373 @cindex input stack, backtrace (@code{backtrace})
12374 Print a backtrace of the input stack to the standard error stream.
12376 Consider the following in file @file{test}:
12378 @Example
12379 .de xxx
12380 .  backtrace
12382 .de yyy
12383 .  xxx
12386 .yyy
12387 @endExample
12389 @noindent
12390 On execution, @code{gtroff} prints the following:
12392 @Example
12393 test:2: backtrace: macro `xxx'
12394 test:5: backtrace: macro `yyy'
12395 test:8: backtrace: file `test'
12396 @endExample
12398 The option @option{-b} of @code{gtroff} internally calls a variant of
12399 this request on each error and warning.
12400 @endDefreq
12402 @Defreg {slimit}
12403 @cindex input stack, setting limit
12404 Use the @code{slimit} number register
12405 to set the maximum number of objects on the input stack.
12406 If @code{slimit} is less than or equal to@tie{}0,
12407 there is no limit set.
12408 With no limit, a buggy recursive macro can exhaust virtual memory.
12410 The default value is 1000; this is a compile-time constant.
12411 @endDefreg
12413 @Defreq {warnscale, si}
12414 Set the scaling indicator used in warnings to @var{si}.  Valid values for
12415 @var{si} are @samp{u}, @samp{i}, @samp{c}, @samp{p}, and @samp{P}.  At
12416 startup, it is set to @samp{i}.
12417 @endDefreq
12419 @Defreq {spreadwarn, [@Var{limit}]}
12420 Make @code{gtroff} emit a warning if the additional space inserted for
12421 each space between words in an output line is larger or equal to
12422 @var{limit}.  A negative value is changed to zero; no argument toggles the
12423 warning on and off without changing @var{limit}.  The default scaling
12424 indicator is @samp{m}.  At startup, @code{spreadwarn} is deactivated, and
12425 @var{limit} is set to 3@dmn{m}.
12427 For example,
12429 @Example
12430 .spreadwarn 0.2m
12431 @endExample
12433 @noindent
12434 will cause a warning if @code{gtroff} must add 0.2@dmn{m} or more for each
12435 interword space in a line.
12437 This request is active only if text is justified to both margins (using
12438 @w{@samp{.ad b}}).
12439 @endDefreq
12441 @cindex warnings
12442 @code{gtroff} has command line options for printing out more warnings
12443 (@option{-w}) and for printing backtraces (@option{-b}) when a warning
12444 or an error occurs.  The most verbose level of warnings is @option{-ww}.
12446 @DefreqList {warn, [@Var{flags}]}
12447 @DefregListEnd {.warn}
12448 @cindex level of warnings (@code{warn})
12449 @cindex warnings, level (@code{warn})
12450 Control the level of warnings checked for.  The @var{flags} are the sum
12451 of the numbers associated with each warning that is to be enabled; all
12452 other warnings are disabled.  The number associated with each warning is
12453 listed below.  For example, @w{@code{.warn 0}} disables all warnings,
12454 and @w{@code{.warn 1}} disables all warnings except that about missing
12455 glyphs.  If no argument is given, all warnings are enabled.
12457 The read-only number register @code{.warn} contains the current warning
12458 level.
12459 @endDefreq
12461 @menu
12462 * Warnings::
12463 @end menu
12465 @c ---------------------------------------------------------------------
12467 @node Warnings,  , Debugging, Debugging
12468 @subsection Warnings
12469 @cindex warnings
12471 The warnings that can be given to @code{gtroff} are divided into the
12472 following categories.  The name associated with each warning is used by
12473 the @option{-w} and @option{-W} options; the number is used by the
12474 @code{warn} request and by the @code{.warn} register.
12476 @table @samp
12477 @item char
12478 @itemx 1
12479 Non-existent glyphs.@footnote{@code{char} is a misnomer since it reports
12480 missing glyphs -- there aren't missing input characters, only invalid
12481 ones.}  This is enabled by default.
12483 @item number
12484 @itemx 2
12485 Invalid numeric expressions.  This is enabled by default.
12486 @xref{Expressions}.
12488 @item break
12489 @itemx 4
12490 @cindex fill mode
12491 @cindex mode, fill
12492 In fill mode, lines which could not be broken so that their length was
12493 less than the line length.  This is enabled by default.
12495 @item delim
12496 @itemx 8
12497 Missing or mismatched closing delimiters.
12499 @item el
12500 @itemx 16
12501 @cindex @code{ie} request, and warnings
12502 @cindex @code{el} request, and warnings
12503 Use of the @code{el} request with no matching @code{ie} request.
12504 @xref{if-else}.
12506 @item scale
12507 @itemx 32
12508 Meaningless scaling indicators.
12510 @item range
12511 @itemx 64
12512 Out of range arguments.
12514 @item syntax
12515 @itemx 128
12516 Dubious syntax in numeric expressions.
12518 @item di
12519 @itemx 256
12520 @cindex @code{di} request, and warnings
12521 @cindex @code{da} request, and warnings
12522 Use of @code{di} or @code{da} without an argument when there is no
12523 current diversion.
12525 @item mac
12526 @itemx 512
12527 @cindex @code{de}, @code{de1}, @code{dei} requests, and warnings
12528 @cindex @code{am}, @code{am1}, @code{ami} requests, and warnings
12529 @cindex @code{ds}, @code{ds1} requests, and warnings
12530 @cindex @code{as}, @code{as1} requests, and warnings
12531 @cindex @code{di} request, and warnings
12532 @cindex @code{da} request, and warnings
12533 @cindex @code{box}, @code{boxa} requests, and warnings
12534 @cindex @code{\*}, and warnings
12535 Use of undefined strings, macros and diversions.  When an undefined
12536 string, macro, or diversion is used, that string is automatically
12537 defined as empty.  So, in most cases, at most one warning is given
12538 for each name.
12540 @item reg
12541 @itemx 1024
12542 @cindex @code{nr} request, and warnings
12543 @cindex @code{\R}, and warnings
12544 @cindex @code{\n}, and warnings
12545 Use of undefined number registers.  When an undefined number register is
12546 used, that register is automatically defined to have a value of@tie{}0.
12547 So, in most cases, at most one warning is given for use of a particular
12548 name.
12550 @item tab
12551 @itemx 2048
12552 @cindex @code{\t}, and warnings
12553 Use of a tab character where a number was expected.
12555 @item right-brace
12556 @itemx 4096
12557 @cindex @code{\@}}, and warnings
12558 Use of @code{\@}} where a number was expected.
12560 @item missing
12561 @itemx 8192
12562 Requests that are missing non-optional arguments.
12564 @item input
12565 @itemx 16384
12566 Invalid input characters.
12568 @item escape
12569 @itemx 32768
12570 Unrecognized escape sequences.  When an unrecognized escape sequence
12571 @code{\@var{X}} is encountered, the escape character is ignored, and
12572 @var{X} is printed.
12574 @item space
12575 @itemx 65536
12576 @cindex compatibility mode
12577 Missing space between a request or macro and its argument.  This warning
12578 is given when an undefined name longer than two characters is
12579 encountered, and the first two characters of the name make a defined
12580 name.  The request or macro is not invoked.  When this warning is
12581 given, no macro is automatically defined.  This is enabled by default.
12582 This warning never occurs in compatibility mode.
12584 @item font
12585 @itemx 131072
12586 Non-existent fonts.  This is enabled by default.
12588 @item ig
12589 @itemx 262144
12590 Invalid escapes in text ignored with the @code{ig} request.  These are
12591 conditions that are errors when they do not occur in ignored text.
12593 @item color
12594 @itemx 524288
12595 Color related warnings.
12597 @item all
12598 All warnings except @samp{di}, @samp{mac} and @samp{reg}.  It is
12599 intended that this covers all warnings that are useful with traditional
12600 macro packages.
12602 @item w
12603 All warnings.
12604 @end table
12607 @c =====================================================================
12609 @node Implementation Differences,  , Debugging, gtroff Reference
12610 @section Implementation Differences
12611 @cindex implementation differences
12612 @cindex differences in implementation
12613 @cindex incompatibilities with @acronym{AT&T} @code{troff}
12614 @cindex compatibility mode
12615 @cindex mode, compatibility
12617 GNU @code{troff} has a number of features which cause incompatibilities
12618 with documents written with old versions of @code{troff}.
12620 @cindex long names
12621 @cindex names, long
12622 Long names cause some incompatibilities.  @acronym{UNIX} @code{troff}
12623 interprets
12625 @Example
12626 .dsabcd
12627 @endExample
12629 @cindex @code{\*}, incompatibilities with @acronym{AT&T} @code{troff}
12630 @cindex @code{\n}, incompatibilities with @acronym{AT&T} @code{troff}
12631 @noindent
12632 as defining a string @samp{ab} with contents @samp{cd}.  Normally, GNU
12633 @code{troff} interprets this as a call of a macro named
12634 @code{dsabcd}.  Also @acronym{UNIX} @code{troff} interprets
12635 @code{\*[} or @code{\n[} as references to a string or number register
12636 called @samp{[}.  In GNU @code{troff}, however, this is normally
12637 interpreted as the start of a long name.  In compatibility mode GNU
12638 @code{troff} interprets long names in the traditional way
12639 (which means that they are not recognized as names).
12641 @DefreqList {cp, [@Var{n}]}
12642 @DefreqItem {do, cmd}
12643 @DefregListEnd {.C}
12644 If @var{n} is missing or non-zero, turn on compatibility mode;
12645 otherwise, turn it off.
12647 The read-only number register @code{.C} is@tie{}1 if compatibility mode is
12648 on, 0@tie{}otherwise.
12650 Compatibility mode can be also turned on with the @option{-C} command line
12651 option.
12653 The @code{do} request turns off compatibility mode
12654 while executing its arguments as a @code{gtroff} command.
12656 @Example
12657 .do fam T
12658 @endExample
12660 @noindent
12661 executes the @code{fam} request when compatibility mode
12662 is enabled.
12664 @code{gtroff} restores the previous compatibility setting
12665 before interpreting any files sourced by the @var{cmd}.
12666 @endDefreq
12668 @cindex input level in delimited arguments
12669 @cindex delimited arguments, incompatibilities with @acronym{AT&T} @code{troff}
12670 Two other features are controlled by @option{-C}.  If not in
12671 compatibility mode, GNU @code{troff} preserves the input level in
12672 delimited arguments:
12674 @Example
12675 .ds xx '
12676 \w'abc\*(xxdef'
12677 @endExample
12679 @noindent
12680 In compatibility mode, the string @samp{72def'} is returned; without
12681 @option{-C} the resulting string is @samp{168} (assuming a TTY output
12682 device).
12684 @cindex @code{\f}, incompatibilities with @acronym{AT&T} @code{troff}
12685 @cindex @code{\H}, incompatibilities with @acronym{AT&T} @code{troff}
12686 @cindex @code{\s}, incompatibilities with @acronym{AT&T} @code{troff}
12687 @cindex @code{\S}, incompatibilities with @acronym{AT&T} @code{troff}
12688 Finally, the escapes @code{\f}, @code{\H}, @code{\m}, @code{\M},
12689 @code{\R}, @code{\s}, and @code{\S} are transparent for recognizing the
12690 beginning of a line only in compatibility mode (this is a rather obscure
12691 feature).  For example, the code
12693 @Example
12694 .de xx
12695 Hallo!
12697 \fB.xx\fP
12698 @endExample
12700 prints @samp{Hallo!} in bold face if in compatibility mode, and
12701 @samp{.xx} in bold face otherwise.
12703 @cindex @code{\A}, incompatibilities with @acronym{AT&T} @code{troff}
12704 @cindex @code{\|}, incompatibilities with @acronym{AT&T} @code{troff}
12705 @cindex @code{\^}, incompatibilities with @acronym{AT&T} @code{troff}
12706 @cindex @code{\&}, incompatibilities with @acronym{AT&T} @code{troff}
12707 @cindex @code{\@{}, incompatibilities with @acronym{AT&T} @code{troff}
12708 @cindex @code{\@}}, incompatibilities with @acronym{AT&T} @code{troff}
12709 @cindex @code{\@key{SP}}, incompatibilities with @acronym{AT&T} @code{troff}
12710 @cindex @code{\'}, incompatibilities with @acronym{AT&T} @code{troff}
12711 @cindex @code{\`}, incompatibilities with @acronym{AT&T} @code{troff}
12712 @cindex @code{\-}, incompatibilities with @acronym{AT&T} @code{troff}
12713 @cindex @code{\_}, incompatibilities with @acronym{AT&T} @code{troff}
12714 @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
12715 @cindex @code{\%}, incompatibilities with @acronym{AT&T} @code{troff}
12716 @cindex @code{\c}, incompatibilities with @acronym{AT&T} @code{troff}
12717 GNU @code{troff} does not allow the use of the escape sequences
12718 @code{\|}, @code{\^}, @code{\&}, @code{\@{}, @code{\@}},
12719 @code{\@key{SP}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
12720 @code{\%}, and @code{\c} in names of strings, macros, diversions, number
12721 registers, fonts or environments; @acronym{UNIX} @code{troff} does.  The
12722 @code{\A} escape sequence (@pxref{Identifiers}) may be helpful in
12723 avoiding use of these escape sequences in names.
12725 @cindex fractional point sizes
12726 @cindex fractional type sizes
12727 @cindex point sizes, fractional
12728 @cindex type sizes, fractional
12729 @cindex sizes, fractional
12730 @cindex @code{ps} request, incompatibilities with @acronym{AT&T} @code{troff}
12731 Fractional point sizes cause one noteworthy incompatibility.  In
12732 @acronym{UNIX} @code{troff} the @code{ps} request ignores scale
12733 indicators and thus
12735 @Example
12736 .ps 10u
12737 @endExample
12739 @noindent
12740 sets the point size to 10@tie{}points, whereas in GNU @code{troff} it
12741 sets the point size to 10@tie{}scaled points.  @xref{Fractional Type
12742 Sizes}, for more information.
12744 @cindex @code{bd} request, incompatibilities with @acronym{AT&T} @code{troff}
12745 @cindex @code{cs} request, incompatibilities with @acronym{AT&T} @code{troff}
12746 @cindex @code{tr} request, incompatibilities with @acronym{AT&T} @code{troff}
12747 @cindex @code{fp} request, incompatibilities with @acronym{AT&T} @code{troff}
12748 @cindex input characters and output glyphs, compatibility with @acronym{AT&T} @code{troff}
12749 @cindex output glyphs, and input characters,compatibility with @acronym{AT&T} @code{troff}
12750 @cindex characters, input, and output glyphs, compatibility with @acronym{AT&T} @code{troff}
12751 @cindex glyphs, output, and input characters, compatibility with @acronym{AT&T} @code{troff}
12752 In GNU @code{troff} there is a fundamental difference between
12753 (unformatted) input characters and (formatted) output glyphs.
12754 Everything that affects how a glyph is output is stored
12755 with the glyph node; once a glyph node has been constructed it is
12756 unaffected by any subsequent requests that are executed, including
12757 @code{bd}, @code{cs}, @code{tkf}, @code{tr}, or @code{fp} requests.
12758 Normally glyphs are constructed from input characters at the
12759 moment immediately before the glyph is added to the current output
12760 line.  Macros, diversions and strings are all, in fact, the same type of
12761 object; they contain lists of input characters and glyph nodes in
12762 any combination.  A glyph node does not behave like an input
12763 character for the purposes of macro processing; it does not inherit any
12764 of the special properties that the input character from which it was
12765 constructed might have had.  For example,
12767 @Example
12768 .di x
12769 \\\\
12773 @endExample
12775 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
12776 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
12777 @cindex @code{\e}, incompatibilities with @acronym{AT&T} @code{troff}
12778 @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
12779 @cindex @code{\?}, incompatibilities with @acronym{AT&T} @code{troff}
12780 @cindex transparent output, incompatibilities with @acronym{AT&T} @code{troff}
12781 @cindex output, transparent, incompatibilities with @acronym{AT&T} @code{troff}
12782 @noindent
12783 prints @samp{\\} in GNU @code{troff}; each pair of input backslashes
12784 is turned into one output backslash and the resulting output backslashes
12785 are not interpreted as escape characters when they are reread.
12786 @acronym{UNIX} @code{troff} would interpret them as escape characters
12787 when they were reread and would end up printing one @samp{\}.  The
12788 correct way to obtain a printable backslash is to use the @code{\e}
12789 escape sequence: This always prints a single instance of the current
12790 escape character, regardless of whether or not it is used in a
12791 diversion; it also works in both GNU @code{troff} and @acronym{UNIX}
12792 @code{troff}.@footnote{To be completely independent of the current
12793 escape character, use @code{\(rs} which represents a reverse solidus
12794 (backslash) glyph.}  To store, for some reason, an escape sequence in a
12795 diversion that will be interpreted when the diversion is reread, either
12796 use the traditional @code{\!} transparent output facility, or, if this
12797 is unsuitable, the new @code{\?} escape sequence.
12799 @xref{Diversions}, and @ref{Gtroff Internals}, for more information.
12803 @c =====================================================================
12804 @c =====================================================================
12806 @node Preprocessors, Output Devices, gtroff Reference, Top
12807 @chapter Preprocessors
12808 @cindex preprocessors
12810 This chapter describes all preprocessors that come with @code{groff} or
12811 which are freely available.
12813 @menu
12814 * geqn::
12815 * gtbl::
12816 * gpic::
12817 * ggrn::
12818 * grap::
12819 * grefer::
12820 * gsoelim::
12821 @end menu
12824 @c =====================================================================
12826 @node geqn, gtbl, Preprocessors, Preprocessors
12827 @section @code{geqn}
12828 @cindex @code{eqn}, the program
12829 @cindex @code{geqn}, the program
12831 @c XXX
12833 @menu
12834 * Invoking geqn::
12835 @end menu
12837 @c ---------------------------------------------------------------------
12839 @node Invoking geqn,  , geqn, geqn
12840 @subsection Invoking @code{geqn}
12841 @cindex invoking @code{geqn}
12842 @cindex @code{geqn}, invoking
12844 @c XXX
12847 @c =====================================================================
12849 @node gtbl, gpic, geqn, Preprocessors
12850 @section @code{gtbl}
12851 @cindex @code{tbl}, the program
12852 @cindex @code{gtbl}, the program
12854 @c XXX
12856 @menu
12857 * Invoking gtbl::
12858 @end menu
12860 @c ---------------------------------------------------------------------
12862 @node Invoking gtbl,  , gtbl, gtbl
12863 @subsection Invoking @code{gtbl}
12864 @cindex invoking @code{gtbl}
12865 @cindex @code{gtbl}, invoking
12867 @c XXX
12870 @c =====================================================================
12872 @node gpic, ggrn, gtbl, Preprocessors
12873 @section @code{gpic}
12874 @cindex @code{pic}, the program
12875 @cindex @code{gpic}, the program
12877 @c XXX
12879 @menu
12880 * Invoking gpic::
12881 @end menu
12883 @c ---------------------------------------------------------------------
12885 @node Invoking gpic,  , gpic, gpic
12886 @subsection Invoking @code{gpic}
12887 @cindex invoking @code{gpic}
12888 @cindex @code{gpic}, invoking
12890 @c XXX
12893 @c =====================================================================
12895 @node ggrn, grap, gpic, Preprocessors
12896 @section @code{ggrn}
12897 @cindex @code{grn}, the program
12898 @cindex @code{ggrn}, the program
12900 @c XXX
12902 @menu
12903 * Invoking ggrn::
12904 @end menu
12906 @c ---------------------------------------------------------------------
12908 @node Invoking ggrn,  , ggrn, ggrn
12909 @subsection Invoking @code{ggrn}
12910 @cindex invoking @code{ggrn}
12911 @cindex @code{ggrn}, invoking
12913 @c XXX
12916 @c =====================================================================
12918 @node grap, grefer, ggrn, Preprocessors
12919 @section @code{grap}
12920 @cindex @code{grap}, the program
12922 A free implementation of @code{grap}, written by Ted Faber,
12923 is available as an extra package from the following address:
12925 @display
12926 @url{http://www.lunabase.org/~faber/Vault/software/grap/}
12927 @end display
12930 @c =====================================================================
12932 @node grefer, gsoelim, grap, Preprocessors
12933 @section @code{grefer}
12934 @cindex @code{refer}, the program
12935 @cindex @code{grefer}, the program
12937 @c XXX
12939 @menu
12940 * Invoking grefer::
12941 @end menu
12943 @c ---------------------------------------------------------------------
12945 @node Invoking grefer,  , grefer, grefer
12946 @subsection Invoking @code{grefer}
12947 @cindex invoking @code{grefer}
12948 @cindex @code{grefer}, invoking
12950 @c XXX
12953 @c =====================================================================
12955 @node gsoelim,  , grefer, Preprocessors
12956 @section @code{gsoelim}
12957 @cindex @code{soelim}, the program
12958 @cindex @code{gsoelim}, the program
12960 @c XXX
12962 @menu
12963 * Invoking gsoelim::
12964 @end menu
12966 @c ---------------------------------------------------------------------
12968 @node Invoking gsoelim,  , gsoelim, gsoelim
12969 @subsection Invoking @code{gsoelim}
12970 @cindex invoking @code{gsoelim}
12971 @cindex @code{gsoelim}, invoking
12973 @c XXX
12977 @c =====================================================================
12978 @c =====================================================================
12980 @node Output Devices, File formats, Preprocessors, Top
12981 @chapter Output Devices
12982 @cindex output devices
12983 @cindex devices for output
12985 @c XXX
12987 @menu
12988 * Special Characters::
12989 * grotty::
12990 * grops::
12991 * grodvi::
12992 * grolj4::
12993 * grolbp::
12994 * grohtml::
12995 * gxditview::
12996 @end menu
12999 @c =====================================================================
13001 @node Special Characters, grotty, Output Devices, Output Devices
13002 @section Special Characters
13003 @cindex special characters
13004 @cindex characters, special
13006 @c XXX
13008 @xref{Font Files}.
13011 @c =====================================================================
13013 @node grotty, grops, Special Characters, Output Devices
13014 @section @code{grotty}
13015 @cindex @code{grotty}, the program
13017 @c XXX
13019 @menu
13020 * Invoking grotty::
13021 @end menu
13023 @c ---------------------------------------------------------------------
13025 @node Invoking grotty,  , grotty, grotty
13026 @subsection Invoking @code{grotty}
13027 @cindex invoking @code{grotty}
13028 @cindex @code{grotty}, invoking
13030 @c XXX
13032 @c The following is no longer true; fix and extend it.
13034 @c @pindex less
13035 @c @cindex Teletype
13036 @c @cindex ISO 6249 SGR
13037 @c @cindex terminal control sequences
13038 @c @cindex control sequences, for terminals
13039 @c For TTY output devices, underlining is done by emitting sequences of
13040 @c @samp{_} and @samp{\b} (the backspace character) before the actual
13041 @c character.  Literally, this is printing an underline character, then
13042 @c moving back one character position, and printing the actual character
13043 @c at the same position as the underline character (similar to a
13044 @c typewriter).  Usually, a modern terminal can't interpret this (and the
13045 @c original Teletype machines for which this sequence was appropriate are
13046 @c no longer in use).  You need a pager program like @code{less} which
13047 @c translates this into ISO 6429 SGR sequences to control terminals.
13050 @c =====================================================================
13052 @node grops, grodvi, grotty, Output Devices
13053 @section @code{grops}
13054 @cindex @code{grops}, the program
13056 @c XXX
13058 @menu
13059 * Invoking grops::
13060 * Embedding PostScript::
13061 @end menu
13063 @c ---------------------------------------------------------------------
13065 @node Invoking grops, Embedding PostScript, grops, grops
13066 @subsection Invoking @code{grops}
13067 @cindex invoking @code{grops}
13068 @cindex @code{grops}, invoking
13070 @c XXX
13072 @c ---------------------------------------------------------------------
13074 @node Embedding PostScript,  , Invoking grops, grops
13075 @subsection Embedding @sc{PostScript}
13076 @cindex embedding PostScript
13077 @cindex PostScript, embedding
13079 @c XXX
13082 @c =====================================================================
13084 @node grodvi, grolj4, grops, Output Devices
13085 @section @code{grodvi}
13086 @cindex @code{grodvi}, the program
13088 @c XXX
13090 @menu
13091 * Invoking grodvi::
13092 @end menu
13094 @c ---------------------------------------------------------------------
13096 @node Invoking grodvi,  , grodvi, grodvi
13097 @subsection Invoking @code{grodvi}
13098 @cindex invoking @code{grodvi}
13099 @cindex @code{grodvi}, invoking
13101 @c XXX
13104 @c =====================================================================
13106 @node grolj4, grolbp, grodvi, Output Devices
13107 @section @code{grolj4}
13108 @cindex @code{grolj4}, the program
13110 @c XXX
13112 @menu
13113 * Invoking grolj4::
13114 @end menu
13116 @c ---------------------------------------------------------------------
13118 @node Invoking grolj4,  , grolj4, grolj4
13119 @subsection Invoking @code{grolj4}
13120 @cindex invoking @code{grolj4}
13121 @cindex @code{grolj4}, invoking
13123 @c XXX
13126 @c =====================================================================
13128 @node grolbp, grohtml, grolj4, Output Devices
13129 @section @code{grolbp}
13130 @cindex @code{grolbp}, the program
13132 @c XXX
13134 @menu
13135 * Invoking grolbp::
13136 @end menu
13138 @c ---------------------------------------------------------------------
13140 @node Invoking grolbp,  , grolbp, grolbp
13141 @subsection Invoking @code{grolbp}
13142 @cindex invoking @code{grolbp}
13143 @cindex @code{grolbp}, invoking
13145 @c XXX
13148 @c =====================================================================
13150 @node grohtml, gxditview, grolbp, Output Devices
13151 @section @code{grohtml}
13152 @cindex @code{grohtml}, the program
13154 @c XXX
13156 @menu
13157 * Invoking grohtml::
13158 * grohtml specific registers and strings::
13159 @end menu
13161 @c ---------------------------------------------------------------------
13163 @node Invoking grohtml, grohtml specific registers and strings, grohtml, grohtml
13164 @subsection Invoking @code{grohtml}
13165 @cindex invoking @code{grohtml}
13166 @cindex @code{grohtml}, invoking
13168 @c XXX
13170 @c ---------------------------------------------------------------------
13172 @node grohtml specific registers and strings,  , Invoking grohtml, grohtml
13173 @subsection @code{grohtml} specific registers and strings
13174 @cindex registers specific to @code{grohtml}
13175 @cindex strings specific to @code{grohtml}
13176 @cindex @code{grohtml}, registers and strings
13178 @DefmpregList {ps4html, grohtml}
13179 @DefstrListEnd {www-image-template, grohtml}
13180 The registers @code{ps4html} and @code{www-image-template} are defined
13181 by the @code{pre-grohtml} preprocessor.  @code{pre-grohtml} reads in
13182 the @code{troff} input, marks up the inline equations and passes the
13183 result firstly to
13185 @Example
13186 troff -Tps -rps4html=1 -dwww-image-template=@var{template}
13187 @endExample
13189 @noindent
13190 and secondly to
13192 @Example
13193 troff -Thtml
13194 @endExample
13196 The PostScript device is used to create all the image files, and the
13197 register @code{ps4html} enables the macro sets to ignore floating
13198 keeps, footers, and headings.
13200 The register @code{www-image-template} is set to the user specified
13201 template name or the default name.
13202 @endDefmpreg
13205 @c =====================================================================
13207 @node gxditview,  , grohtml, Output Devices
13208 @section @code{gxditview}
13209 @cindex @code{gxditview}, the program
13211 @c XXX
13213 @menu
13214 * Invoking gxditview::
13215 @end menu
13217 @c ---------------------------------------------------------------------
13219 @node Invoking gxditview,  , gxditview, gxditview
13220 @subsection Invoking @code{gxditview}
13221 @cindex invoking @code{gxditview}
13222 @cindex @code{gxditview}, invoking
13224 @c XXX
13225 @c X11's xditview
13229 @c =====================================================================
13230 @c =====================================================================
13232 @node File formats, Installation, Output Devices, Top
13233 @chapter File formats
13234 @cindex file formats
13235 @cindex formats, file
13237 All files read and written by @code{gtroff} are text files.  The
13238 following two sections describe their format.
13240 @menu
13241 * gtroff Output::
13242 * Font Files::
13243 @end menu
13246 @c =====================================================================
13248 @node gtroff Output, Font Files, File formats, File formats
13249 @section @code{gtroff} Output
13250 @cindex @code{gtroff}, output
13251 @cindex output, @code{gtroff}
13253 This section describes the intermediate output format of GNU
13254 @code{troff}.  This output is produced by a run of @code{gtroff}
13255 before it is fed into a device postprocessor program.
13257 As @code{groff} is a wrapper program around @code{gtroff} that
13258 automatically calls a postprocessor, this output does not show up
13259 normally.  This is why it is called @dfn{intermediate}.
13260 @code{groff} provides the option @option{-Z} to inhibit postprocessing,
13261 such that the produced intermediate output is sent to standard output
13262 just like calling @code{gtroff} manually.
13264 @cindex troff output
13265 @cindex output, troff
13266 @cindex intermediate output
13267 @cindex output, intermediate
13268 Here, the term @dfn{troff output} describes what is output by
13269 @code{gtroff}, while @dfn{intermediate output} refers to the language
13270 that is accepted by the parser that prepares this output for the
13271 postprocessors.  This parser is smarter on whitespace and implements
13272 obsolete elements for compatibility, otherwise both formats are the
13273 same.@footnote{The parser and postprocessor for intermediate output
13274 can be found in the file@*
13275 @file{@var{groff-source-dir}/src/libs/libdriver/input.cc}.}
13277 The main purpose of the intermediate output concept is to facilitate
13278 the development of postprocessors by providing a common programming
13279 interface for all devices.  It has a language of its own that is
13280 completely different from the @code{gtroff} language.  While the
13281 @code{gtroff} language is a high-level programming language for text
13282 processing, the intermediate output language is a kind of low-level
13283 assembler language by specifying all positions on the page for writing
13284 and drawing.
13286 The intermediate output produced by @code{gtroff} is fairly readable,
13287 while output from @acronym{AT&T} @code{troff} is rather hard to
13288 understand because of strange habits that are still supported, but not
13289 used any longer by @code{gtroff}.
13291 @menu
13292 * Language Concepts::
13293 * Command Reference::
13294 * Intermediate Output Examples::
13295 * Output Language Compatibility::
13296 @end menu
13298 @c ---------------------------------------------------------------------
13300 @node Language Concepts, Command Reference, gtroff Output, gtroff Output
13301 @subsection Language Concepts
13303 During the run of @code{gtroff}, the input data is cracked down to the
13304 information on what has to be printed at what position on the intended
13305 device.  So the language of the intermediate output format can be quite
13306 small.  Its only elements are commands with and without arguments.
13307 In this section, the term @dfn{command} always refers to the intermediate
13308 output language, and never to the @code{gtroff} language used for document
13309 formatting.  There are commands for positioning and text writing, for drawing, and
13310 for device controlling.
13312 @menu
13313 * Separation::
13314 * Argument Units::
13315 * Document Parts::
13316 @end menu
13318 @node Separation, Argument Units, Language Concepts, Language Concepts
13319 @subsubsection Separation
13321 @acronym{AT&T} @code{troff} output has strange requirements on whitespace.
13322 The @code{gtroff} output parser, however, is smart about whitespace by
13323 making it maximally optional.  The whitespace characters, i.e., the
13324 tab, space, and newline characters, always have a syntactical meaning.
13325 They are never printable because spacing within the output is always
13326 done by positioning commands.
13328 Any sequence of space or tab characters is treated as a single
13329 @dfn{syntactical space}.  It separates commands and arguments, but is
13330 only required when there would occur a clashing between the command code
13331 and the arguments without the space.  Most often, this happens when
13332 variable-length command names, arguments, argument lists, or command
13333 clusters meet.  Commands and arguments with a known, fixed length need
13334 not be separated by syntactical space.
13336 A line break is a syntactical element, too.  Every command argument can be
13337 followed by whitespace, a comment, or a newline character.  Thus a
13338 @dfn{syntactical line break} is defined to consist of optional
13339 syntactical space that is optionally followed by a comment, and a
13340 newline character.
13342 The normal commands, those for positioning and text, consist of a
13343 single letter taking a fixed number of arguments.  For historical reasons,
13344 the parser allows to stack such commands on the same line, but
13345 fortunately, in @code{gtroff}'s intermediate output, every command with
13346 at least one argument is followed by a line break, thus providing
13347 excellent readability.
13349 The other commands -- those for drawing and device controlling --
13350 have a more complicated structure; some recognize long command names,
13351 and some take a variable number of arguments.  So all @samp{D} and
13352 @samp{x} commands were designed to request a syntactical line break
13353 after their last argument.  Only one command, @w{@samp{x X}},
13354 has an argument that can stretch over several lines; all other
13355 commands must have all of their arguments on the same line as the
13356 command, i.e., the arguments may not be splitted by a line break.
13358 Empty lines (these are lines containing only space and/or a comment), can
13359 occur everywhere.  They are just ignored.
13361 @node Argument Units, Document Parts, Separation, Language Concepts
13362 @subsubsection Argument Units
13364 Some commands take integer arguments that are assumed to represent
13365 values in a measurement unit, but the letter for the corresponding
13366 scale indicator is not written with the output command arguments.
13367 Most commands assume the scale indicator @samp{u}, the basic unit of
13368 the device, some use @samp{z}, the scaled point unit of the device,
13369 while others, such as the color commands, expect plain integers.
13371 Note that single characters can have the eighth bit set, as can the
13372 names of fonts and special characters.  The names of characters and
13373 fonts can be of arbitrary length.  A character that is to be printed
13374 will always be in the current font.
13376 A string argument is always terminated by the next whitespace
13377 character (space, tab, or newline); an embedded @samp{#} character is
13378 regarded as part of the argument, not as the beginning of a comment
13379 command.  An integer argument is already terminated by the next
13380 non-digit character, which then is regarded as the first character of
13381 the next argument or command.
13383 @node Document Parts,  , Argument Units, Language Concepts
13384 @subsubsection Document Parts
13386 A correct intermediate output document consists of two parts, the
13387 @dfn{prologue} and the @dfn{body}.
13389 The task of the prologue is to set the general device parameters
13390 using three exactly specified commands.  @code{gtroff}'s prologue
13391 is guaranteed to consist of the following three lines (in that order):
13393 @Example
13394 x T @var{device}
13395 x res @var{n} @var{h} @var{v}
13396 x init
13397 @endExample
13399 @noindent
13400 with the arguments set as outlined in @ref{Device Control Commands}.
13401 Note that the parser for the intermediate output format is able to
13402 swallow additional whitespace and comments as well even in the
13403 prologue.
13405 The body is the main section for processing the document data.
13406 Syntactically, it is a sequence of any commands different from the
13407 ones used in the prologue.  Processing is terminated as soon as the
13408 first @w{@samp{x stop}} command is encountered; the last line of any
13409 @code{gtroff} intermediate output always contains such a command.
13411 Semantically, the body is page oriented.  A new page is started by a
13412 @samp{p} command.  Positioning, writing, and drawing commands are
13413 always done within the current page, so they cannot occur before the
13414 first @samp{p} command.  Absolute positioning (by the @samp{H} and
13415 @samp{V} commands) is done relative to the current page; all other
13416 positioning is done relative to the current location within this page.
13418 @c ---------------------------------------------------------------------
13420 @node Command Reference, Intermediate Output Examples, Language Concepts, gtroff Output
13421 @subsection Command Reference
13423 This section describes all intermediate output commands, both from
13424 @acronym{AT&T} @code{troff} as well as the @code{gtroff} extensions.
13426 @menu
13427 * Comment Command::
13428 * Simple Commands::
13429 * Graphics Commands::
13430 * Device Control Commands::
13431 * Obsolete Command::
13432 @end menu
13434 @node Comment Command, Simple Commands, Command Reference, Command Reference
13435 @subsubsection Comment Command
13437 @table @code
13438 @item #@var{anything}@angles{end of line}
13439 A comment.  Ignore any characters from the @samp{#} character up to
13440 the next newline character.
13442 This command is the only possibility for commenting in the intermediate
13443 output.  Each comment can be preceded by arbitrary syntactical space;
13444 every command can be terminated by a comment.
13445 @end table
13447 @node Simple Commands, Graphics Commands, Comment Command, Command Reference
13448 @subsubsection Simple Commands
13450 The commands in this subsection have a command code consisting of a
13451 single character, taking a fixed number of arguments.  Most of them
13452 are commands for positioning and text writing.  These commands are
13453 smart about whitespace.  Optionally, syntactical space can be inserted
13454 before, after, and between the command letter and its arguments.
13455 All of these commands are stackable, i.e., they can be preceded by
13456 other simple commands or followed by arbitrary other commands on the
13457 same line.  A separating syntactical space is only necessary when two
13458 integer arguments would clash or if the preceding argument ends with a
13459 string argument.
13461 @table @code
13462 @ignore
13463 .if (\n[@USE_ENV_STACK] == 1) \{\
13464 .command {
13465 Open a new environment by copying the actual device configuration data
13466 to the environment stack.
13468 The current environment is setup by the device specification and
13469 manipulated by the setting commands.
13472 .command }
13473 Close the actual environment (opened by a preceding
13474 .BR { \~command)
13475 and restore the previous environment from the environment
13476 stack as the actual device configuration data.
13478 \}              \" endif @USE_ENV_STACK
13479 @end ignore
13481 @item C @var{xxx}@angles{whitespace}
13482 Print a special character named @var{xxx}.  The trailing
13483 syntactical space or line break is necessary to allow glyph names
13484 of arbitrary length.  The glyph is printed at the current print
13485 position; the glyph's size is read from the font file.  The print
13486 position is not changed.
13488 @item c @var{g}
13489 Print glyph@tie{}@var{g} at the current print position;@footnote{@samp{c}
13490 is actually a misnomer since it outputs a glyph.} the glyph's size is
13491 read from the font file.  The print position is not changed.
13493 @item f @var{n}
13494 Set font to font number@tie{}@var{n} (a non-negative integer).
13496 @item H @var{n}
13497 Move right to the absolute vertical position@tie{}@var{n} (a
13498 non-negative integer in basic units @samp{u} relative to left edge
13499 of current page.
13501 @item h @var{n}
13502 Move @var{n} (a non-negative integer) basic units @samp{u} horizontally
13503 to the right.  The original @acronym{UNIX} troff manual allows negative
13504 values for @var{n} also, but @code{gtroff} doesn't use this.
13506 @item m @var{color-scheme} @r{[}@var{component} @dots{}@r{]}
13507 Set the color for text (glyphs), line drawing, and the outline of
13508 graphic objects using different color schemes; the analoguous command
13509 for the filling color of graphic objects is @samp{DF}.  The color
13510 components are specified as integer arguments between 0 and 65536.
13511 The number of color components and their meaning vary for the
13512 different color schemes.  These commands are generated by
13513 @code{gtroff}'s escape sequence @code{\m}.  No position changing.
13514 These commands are a @code{gtroff} extension.
13516 @table @code
13517 @item mc @var{cyan} @var{magenta} @var{yellow}
13518 Set color using the CMY color scheme, having the 3@tie{}color components
13519 @var{cyan}, @var{magenta}, and @var{yellow}.
13521 @item md
13522 Set color to the default color value (black in most cases).
13523 No component arguments.
13525 @item mg @var{gray}
13526 Set color to the shade of gray given by the argument, an integer
13527 between 0 (black) and 65536 (white).
13529 @item mk @var{cyan} @var{magenta} @var{yellow} @var{black}
13530 Set color using the CMYK color scheme, having the 4@tie{}color components
13531 @var{cyan}, @var{magenta}, @var{yellow}, and @var{black}.
13533 @item mr @var{red} @var{green} @var{blue}
13534 Set color using the RGB color scheme, having the 3@tie{}color components
13535 @var{red}, @var{green}, and @var{blue}.
13537 @end table
13539 @item N @var{n}
13540 Print glyph with index@tie{}@var{n} (a non-negative integer) of the
13541 current font.  This command is a @code{gtroff} extension.
13543 @item n @var{b} @var{a}
13544 Inform the device about a line break, but no positioning is done by
13545 this command.  In @acronym{AT&T} @code{troff}, the integer arguments
13546 @var{b} and@tie{}@var{a} informed about the space before and after the
13547 current line to make the intermediate output more human readable
13548 without performing any action.  In @code{groff}, they are just ignored, but
13549 they must be provided for compatibility reasons.
13551 @item p @var{n}
13552 Begin a new page in the outprint.  The page number is set
13553 to@tie{}@var{n}.  This page is completely independent of pages formerly
13554 processed even if those have the same page number.  The vertical
13555 position on the outprint is automatically set to@tie{}0.  All
13556 positioning, writing, and drawing is always done relative to a page,
13557 so a @samp{p} command must be issued before any of these commands.
13559 @item s @var{n}
13560 Set point size to @var{n}@tie{}scaled points (this is unit @samp{z}).
13561 @acronym{AT&T} @code{troff} used the unit points (@samp{p}) instead.
13562 @xref{Output Language Compatibility}.
13564 @item t @var{xxx}@angles{whitespace}
13565 @itemx t @var{xxx} @var{dummy-arg}@angles{whitespace}
13566 Print a word, i.e., a sequence of characters @var{xxx} representing
13567 output glyphs which names are single characters, terminated by
13568 a space character or a line break; an optional second integer argument
13569 is ignored (this allows the formatter to generate an even number of
13570 arguments).  The first glyph should be printed at the current
13571 position, the current horizontal position should then be increased by
13572 the width of the first glyph, and so on for each glyph.
13573 The widths of the glyphs are read from the font file, scaled for the
13574 current point size, and rounded to a multiple of the horizontal
13575 resolution.  Special characters cannot be printed using this command
13576 (use the @samp{C} command for special characters).  This command is a
13577 @code{gtroff} extension; it is only used for devices whose @file{DESC}
13578 file contains the @code{tcommand} keyword (@pxref{DESC File Format}).
13580 @item u @var{n} @var{xxx}@angles{whitespace}
13581 Print word with track kerning.  This is the same as the @samp{t}
13582 command except that after printing each glyph, the current
13583 horizontal position is increased by the sum of the width of that
13584 glyph and@tie{}@var{n} (an integer in basic units @samp{u}).
13585 This command is a @code{gtroff} extension; it is only used for devices
13586 whose @file{DESC} file contains the @code{tcommand} keyword
13587 (@pxref{DESC File Format}).
13589 @item V @var{n}
13590 Move down to the absolute vertical position@tie{}@var{n} (a
13591 non-negative integer in basic units @samp{u}) relative to upper edge
13592 of current page.
13594 @item v @var{n}
13595 Move @var{n}@tie{}basic units @samp{u} down (@var{n} is a non-negative
13596 integer).  The original @acronym{UNIX} troff manual allows negative
13597 values for @var{n} also, but @code{gtroff} doesn't use this.
13599 @item w
13600 Informs about a paddable white space to increase readability.
13601 The spacing itself must be performed explicitly by a move command.
13603 @end table
13605 @node Graphics Commands, Device Control Commands, Simple Commands, Command Reference
13606 @subsubsection Graphics Commands
13608 Each graphics or drawing command in the intermediate output starts
13609 with the letter @samp{D}, followed by one or two characters that
13610 specify a subcommand; this is followed by a fixed or variable number
13611 of integer arguments that are separated by a single space character.
13612 A @samp{D} command may not be followed by another command on the same line
13613 (apart from a comment), so each @samp{D} command is terminated by a
13614 syntactical line break.
13616 @code{gtroff} output follows the classical spacing rules (no space
13617 between command and subcommand, all arguments are preceded by a
13618 single space character), but the parser allows optional space between
13619 the command letters and makes the space before the first argument
13620 optional.  As usual, each space can be any sequence of tab and space
13621 characters.
13623 Some graphics commands can take a variable number of arguments.
13624 In this case, they are integers representing a size measured in basic
13625 units @samp{u}.  The arguments called @var{h1}, @var{h2}, @dots{},
13626 @var{hn} stand for horizontal distances where positive means right,
13627 negative left.  The arguments called @var{v1}, @var{v2}, @dots{},
13628 @var{vn} stand for vertical distances where positive means down,
13629 negative up.  All these distances are offsets relative to the current
13630 location.
13632 Unless indicated otherwise, each graphics command directly corresponds
13633 to a similar @code{gtroff} @code{\D} escape sequence.  @xref{Drawing
13634 Requests}.
13636 Unknown @samp{D} commands are assumed to be device-specific.
13637 Its arguments are parsed as strings; the whole information is then
13638 sent to the postprocessor.
13640 In the following command reference, the syntax element
13641 @angles{line break} means a syntactical line break as defined above.
13643 @table @code
13644 @item D~ @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
13645 Draw B-spline from current position to offset (@var{h1},@var{v1}),
13646 then to offset (@var{h2},@var{v2}), if given, etc.@: up to
13647 (@var{hn},@var{vn}).  This command takes a variable number of argument
13648 pairs; the current position is moved to the terminal point of the drawn
13649 curve.
13651 @item Da @var{h1} @var{v1} @var{h2} @var{v2}@angles{line break}
13652 Draw arc from current position to
13653 (@var{h1},@var{v1})@math{+}(@var{h2},@var{v2}) with center at
13654 (@var{h1},@var{v1}); then move the current position to the final point
13655 of the arc.
13657 @item DC @var{d}@angles{line break}
13658 @itemx DC @var{d} @var{dummy-arg}@angles{line break}
13659 Draw a solid circle using the current fill color with
13660 diameter@tie{}@var{d} (integer in basic units @samp{u}) with leftmost
13661 point at the current position; then move the current position to the
13662 rightmost point of the circle.  An optional second integer argument is
13663 ignored (this allows the formatter to generate an even number of
13664 arguments).  This command is a @code{gtroff} extension.
13666 @item Dc @var{d}@angles{line break}
13667 Draw circle line with diameter@tie{}@var{d} (integer in basic units
13668 @samp{u}) with leftmost point at the current position; then move the
13669 current position to the rightmost point of the circle.
13671 @item DE @var{h} @var{v}@angles{line break}
13672 Draw a solid ellipse in the current fill color with a horizontal
13673 diameter of@tie{}@var{h} and a vertical diameter of@tie{}@var{v} (both
13674 integers in basic units @samp{u}) with the leftmost point at the
13675 current position; then move to the rightmost point of the ellipse.
13676 This command is a @code{gtroff} extension.
13678 @item De @var{h} @var{v}@angles{line break}
13679 Draw an outlined ellipse with a horizontal diameter of@tie{}@var{h}
13680 and a vertical diameter of@tie{}@var{v} (both integers in basic units
13681 @samp{u}) with the leftmost point at current position; then move to
13682 the rightmost point of the ellipse.
13684 @item DF @var{color-scheme} @r{[}@var{component} @dots{}@r{]}@angles{line break}
13685 Set fill color for solid drawing objects using different color
13686 schemes; the analoguous command for setting the color of text, line
13687 graphics, and the outline of graphic objects is @samp{m}.
13688 The color components are specified as integer arguments between 0 and
13689 65536.  The number of color components and their meaning vary for the
13690 different color schemes.  These commands are generated by @code{gtroff}'s
13691 escape sequences @w{@code{\D'F @dots{}'}} and @code{\M} (with no other
13692 corresponding graphics commands).  No position changing.  This command
13693 is a @code{gtroff} extension.
13695 @table @code
13696 @item DFc @var{cyan} @var{magenta} @var{yellow}@angles{line break}
13697 Set fill color for solid drawing objects using the CMY color scheme,
13698 having the 3@tie{}color components @var{cyan}, @var{magenta}, and
13699 @var{yellow}.
13701 @item DFd@angles{line break}
13702 Set fill color for solid drawing objects to the default fill color value
13703 (black in most cases).  No component arguments.
13705 @item DFg @var{gray}@angles{line break}
13706 Set fill color for solid drawing objects to the shade of gray given by
13707 the argument, an integer between 0 (black) and 65536 (white).
13709 @item DFk @var{cyan} @var{magenta} @var{yellow} @var{black}@angles{line break}
13710 Set fill color for solid drawing objects using the CMYK color scheme,
13711 having the 4@tie{}color components @var{cyan}, @var{magenta}, @var{yellow},
13712 and @var{black}.
13714 @item DFr @var{red} @var{green} @var{blue}@angles{line break}
13715 Set fill color for solid drawing objects using the RGB color scheme,
13716 having the 3@tie{}color components @var{red}, @var{green}, and @var{blue}.
13718 @end table
13720 @item Df @var{n}@angles{line break}
13721 The argument@tie{}@var{n} must be an integer in the range @math{-32767}
13722 to 32767.
13724 @table @asis
13725 @item @math{0 @LE @var{n} @LE 1000}
13726 Set the color for filling solid drawing objects to a shade of gray,
13727 where 0 corresponds to solid white, 1000 (the default) to solid black,
13728 and values in between to intermediate shades of gray; this is
13729 obsoleted by command @samp{DFg}.
13731 @item @math{@var{n} < 0} or @math{@var{n} > 1000}
13732 Set the filling color to the color that is currently being used for
13733 the text and the outline, see command @samp{m}.  For example, the
13734 command sequence
13736 @Example
13737 mg 0 0 65536
13738 Df -1
13739 @endExample
13741 @noindent
13742 sets all colors to blue.
13744 @end table
13746 @noindent
13747 No position changing.  This command is a @code{gtroff} extension.
13749 @item Dl @var{h} @var{v}@angles{line break}
13750 Draw line from current position to offset (@var{h},@var{v}) (integers
13751 in basic units @samp{u}); then set current position to the end of the
13752 drawn line.
13754 @item Dp @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
13755 Draw a polygon line from current position to offset (@var{h1},@var{v1}),
13756 from there to offset (@var{h2},@var{v2}), etc.@: up to offset
13757 (@var{hn},@var{vn}), and from there back to the starting position.
13758 For historical reasons, the position is changed by adding the sum of
13759 all arguments with odd index to the actual horizontal position and the
13760 even ones to the vertical position.  Although this doesn't make sense
13761 it is kept for compatibility.
13762 @ignore
13763 As the polygon is closed, the end of drawing is the starting point, so
13764 the position doesn't change.
13765 @end ignore
13766 This command is a @code{gtroff} extension.
13768 @item Dp @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
13769 Draw a solid polygon in the current fill color rather than an outlined
13770 polygon, using the same arguments and positioning as the corresponding
13771 @samp{Dp} command.
13772 @ignore
13773 No position changing.
13774 @end ignore
13775 This command is a @code{gtroff} extension.
13777 @item Dt @var{n}@angles{line break}
13778 Set the current line thickness to@tie{}@var{n} (an integer in basic
13779 units @samp{u}) if @math{@var{n}>0}; if @math{@var{n}=0} select the
13780 smallest available line thickness; if @math{@var{n}<0} set the line
13781 thickness proportional to the point size (this is the default before
13782 the first @samp{Dt} command was specified).  For historical reasons,
13783 the horizontal position is changed by adding the argument to the actual
13784 horizontal position, while the vertical position is not changed.
13785 Although this doesn't make sense it is kept for compatibility.
13786 @ignore
13787 No position changing.
13788 @end ignore
13789 This command is a @code{gtroff} extension.
13791 @end table
13793 @node Device Control Commands, Obsolete Command, Graphics Commands, Command Reference
13794 @subsubsection Device Control Commands
13796 Each device control command starts with the letter @samp{x},
13797 followed by a space character (optional or arbitrary space or tab in
13798 @code{gtroff}) and a subcommand letter or word; each argument (if any)
13799 must be preceded by a syntactical space.  All @samp{x} commands are
13800 terminated by a syntactical line break; no device control command can
13801 be followed by another command on the same line (except a comment).
13803 The subcommand is basically a single letter, but to increase
13804 readability, it can be written as a word, i.e., an arbitrary sequence
13805 of characters terminated by the next tab, space, or newline character.
13806 All characters of the subcommand word but the first are simply ignored.
13807 For example, @code{gtroff} outputs the initialization command
13808 @w{@samp{x i}} as @w{@samp{x init}} and the resolution command
13809 @w{@samp{x r}} as @w{@samp{x res}}.
13811 In the following, the syntax element @angles{line break} means a
13812 syntactical line break (@pxref{Separation}).
13814 @table @code
13815 @item xF @var{name}@angles{line break}
13816 The @samp{F} stands for @var{Filename}.
13818 Use @var{name} as the intended name for the current file in error
13819 reports.  This is useful for remembering the original file name when
13820 @code{gtroff} uses an internal piping mechanism.  The input file is
13821 not changed by this command.  This command is a @code{gtroff} extension.
13823 @item xf @var{n} @var{s}@angles{line break}
13824 The @samp{f} stands for @var{font}.
13826 Mount font position@tie{}@var{n} (a non-negative integer) with font
13827 named@tie{}@var{s} (a text word).  @xref{Font Positions}.
13829 @item xH @var{n}@angles{line break}
13830 The @samp{H} stands for @var{Height}.
13832 Set glyph height to@tie{}@var{n} (a positive integer in scaled
13833 points @samp{z}).  @acronym{AT&T} @code{troff} uses the unit points
13834 (@samp{p}) instead.  @xref{Output Language Compatibility}.
13836 @item xi@angles{line break}
13837 The @samp{i} stands for @var{init}.
13839 Initialize device.  This is the third command of the prologue.
13841 @item xp@angles{line break}
13842 The @samp{p} stands for @var{pause}.
13844 Parsed but ignored.  The original @acronym{UNIX} troff manual writes
13846 @display
13847 pause device, can be restarted
13848 @end display
13850 @item xr @var{n} @var{h} @var{v}@angles{line break}
13851 The @samp{r} stands for @var{resolution}.
13853 Resolution is@tie{}@var{n}, while @var{h} is the minimal horizontal
13854 motion, and @var{v} the minimal vertical motion possible with this
13855 device; all arguments are positive integers in basic units @samp{u}
13856 per inch.  This is the second command of the prologue.
13858 @item xS @var{n}@angles{line break}
13859 The @samp{S} stands for @var{Slant}.
13861 Set slant to@tie{}@var{n} (an integer in basic units @samp{u}).
13863 @item xs@angles{line break}
13864 The @samp{s} stands for @var{stop}.
13866 Terminates the processing of the current file; issued as the last
13867 command of any intermediate troff output.
13869 @item xt@angles{line break}
13870 The @samp{t} stands for @var{trailer}.
13872 Generate trailer information, if any.  In @var{gtroff}, this is
13873 actually just ignored.
13875 @item xT @var{xxx}@angles{line break}
13876 The @samp{T} stands for @var{Typesetter}.
13878 Set name of device to word @var{xxx}, a sequence of characters ended
13879 by the next white space character.  The possible device names coincide
13880 with those from the @code{groff} @option{-T} option.  This is the first
13881 command of the prologue.
13883 @item xu @var{n}@angles{line break}
13884 The @samp{u} stands for @var{underline}.
13886 Configure underlining of spaces.  If @var{n} is@tie{}1, start
13887 underlining of spaces; if @var{n} is@tie{}0, stop underlining of spaces.
13888 This is needed for the @code{cu} request in nroff mode and is ignored
13889 otherwise.  This command is a @code{gtroff} extension.
13891 @item xX @var{anything}@angles{line break}
13892 The @samp{x} stands for @var{X-escape}.
13894 Send string @var{anything} uninterpreted to the device.  If the line
13895 following this command starts with a @samp{+} character this line is
13896 interpreted as a continuation line in the following sense.  The
13897 @samp{+} is ignored, but a newline character is sent instead to the
13898 device, the rest of the line is sent uninterpreted.  The same applies
13899 to all following lines until the first character of a line is not a
13900 @samp{+} character.  This command is generated by the @code{gtroff}
13901 escape sequence @code{\X}.  The line-continuing feature is a
13902 @code{gtroff} extension.
13904 @end table
13906 @node Obsolete Command,  , Device Control Commands, Command Reference
13907 @subsubsection Obsolete Command
13908 In @acronym{AT&T} @code{troff} output, the writing of a single
13909 glyph is mostly done by a very strange command that combines a
13910 horizontal move and a single character giving the glyph name.  It
13911 doesn't have a command code, but is represented by a 3-character
13912 argument consisting of exactly 2@tie{}digits and a character.
13914 @table @asis
13915 @item @var{dd}@var{g}
13916 Move right @var{dd} (exactly two decimal digits) basic units @samp{u},
13917 then print glyph@tie{}@var{g} (represented as a single character).
13919 In @code{gtroff}, arbitrary syntactical space around and within this
13920 command is allowed to be added.  Only when a preceding command on the
13921 same line ends with an argument of variable length a separating space
13922 is obligatory.  In @acronym{AT&T} @code{troff}, large clusters of these
13923 and other commands are used, mostly without spaces; this made such output
13924 almost unreadable.
13926 @end table
13928 For modern high-resolution devices, this command does not make sense
13929 because the width of the glyphs can become much larger than two
13930 decimal digits.  In @code{gtroff}, this is only used for the devices
13931 @code{X75}, @code{X75-12}, @code{X100}, and @code{X100-12}.  For other
13932 devices, the commands @samp{t} and @samp{u} provide a better
13933 functionality.
13935 @c ---------------------------------------------------------------------
13937 @node Intermediate Output Examples, Output Language Compatibility, Command Reference, gtroff Output
13938 @subsection Intermediate Output Examples
13940 This section presents the intermediate output generated from the same
13941 input for three different devices.  The input is the sentence
13942 @samp{hell world} fed into @code{gtroff} on the command line.
13944 @table @asis
13945 @item High-resolution device @code{ps}
13947 This is the standard output of @code{gtroff} if no @option{-T} option
13948 is given.
13950 @example
13951 @group
13952 shell> echo "hell world" | groff -Z -T ps
13954 x T ps
13955 x res 72000 1 1
13956 x init
13957 @end group
13959 x font 5 TR
13961 s10000
13962 V12000
13963 H72000
13964 thell
13965 wh2500
13967 H96620
13968 torld
13969 n12000 0
13970 @group
13971 x trailer
13972 V792000
13973 x stop
13974 @end group
13975 @end example
13977 @noindent
13978 This output can be fed into @code{grops} to get its representation as
13979 a PostScript file.
13981 @item Low-resolution device @code{latin1}
13983 This is similar to the high-resolution device except that the
13984 positioning is done at a minor scale.  Some comments (lines starting
13985 with @samp{#}) were added for clarification; they were not generated
13986 by the formatter.
13988 @example
13989 @group
13990 shell> echo "hell world" | groff -Z -T latin1
13992 # prologue
13993 x T latin1
13994 x res 240 24 40
13995 x init
13996 @end group
13997 # begin a new page
13999 # font setup
14000 x font 1 R
14003 # initial positioning on the page
14006 # write text `hell'
14007 thell
14008 # inform about space, and issue a horizontal jump
14009 wh24
14010 # write text `world'
14011 tworld
14012 # announce line break, but do nothing because ...
14013 n40 0
14014 @group
14015 # ... the end of the document has been reached
14016 x trailer
14017 V2640
14018 x stop
14019 @end group
14020 @end example
14022 @noindent
14023 This output can be fed into @code{grotty} to get a formatted text
14024 document.
14026 @item @acronym{AT&T} @code{troff} output
14027 Since a computer monitor has a very low resolution compared to modern
14028 printers the intermediate output for the X@tie{}Window devices can use
14029 the jump-and-write command with its 2-digit displacements.
14031 @example
14032 @group
14033 shell> echo "hell world" | groff -Z -T X100
14035 x T X100
14036 x res 100 1 1
14037 x init
14038 @end group
14040 x font 5 TR
14044 H100
14045 # write text with jump-and-write commands
14046 ch07e07l03lw06w11o07r05l03dh7
14047 n16 0
14048 @group
14049 x trailer
14050 V1100
14051 x stop
14052 @end group
14053 @end example
14055 @noindent
14056 This output can be fed into @code{xditview} or @code{gxditview}
14057 for displaying in@tie{}X.
14059 Due to the obsolete jump-and-write command, the text clusters in the
14060 @acronym{AT&T} @code{troff} output are almost unreadable.
14062 @end table
14064 @c ---------------------------------------------------------------------
14066 @node Output Language Compatibility,  , Intermediate Output Examples, gtroff Output
14067 @subsection Output Language Compatibility
14069 The intermediate output language of @acronym{AT&T} @code{troff}
14070 was first documented in the @acronym{UNIX} troff manual, with later
14071 additions documented in @cite{A Typesetter-indenpendent TROFF},
14072 written by Brian Kernighan.
14074 The @code{gtroff} intermediate output format is compatible with this
14075 specification except for the following features.
14077 @itemize @bullet
14078 @item
14079 The classical quasi device independence is not yet implemented.
14081 @item
14082 The old hardware was very different from what we use today.  So the
14083 @code{groff} devices are also fundamentally different from the ones in
14084 @acronym{AT&T} @code{troff}.  For example, the @acronym{AT&T}
14085 PostScript device is called @code{post} and has a resolution of only
14086 720 units per inch, suitable for printers 20 years ago, while
14087 @code{groff}'s @code{ps} device has a resolution of
14088 72000 units per inch.  Maybe, by implementing some rescaling
14089 mechanism similar to the classical quasi device independence,
14090 @code{groff} could emulate @acronym{AT&T}'s @code{post} device.
14092 @item
14093 The B-spline command @samp{D~} is correctly handled by the
14094 intermediate output parser, but the drawing routines aren't
14095 implemented in some of the postprocessor programs.
14097 @item
14098 The argument of the commands @samp{s} and @w{@samp{x H}} has the
14099 implicit unit scaled point @samp{z} in @code{gtroff}, while
14100 @acronym{AT&T} @code{troff} has point (@samp{p}).  This isn't an
14101 incompatibility but a compatible extension, for both units coincide
14102 for all devices without a @code{sizescale} parameter in the @file{DESC}
14103 file, including all postprocessors from @acronym{AT&T} and
14104 @code{groff}'s text devices.  The few @code{groff} devices with
14105 a @code{sizescale} parameter either do not exist for @acronym{AT&T}
14106 @code{troff}, have a different name, or seem to have a different
14107 resolution.  So conflicts are very unlikely.
14109 @item
14110 The position changing after the commands @samp{Dp}, @samp{DP}, and
14111 @samp{Dt} is illogical, but as old versions of @code{gtroff} used this
14112 feature it is kept for compatibility reasons.
14114 @ignore
14115 Temporarily, there existed some confusion on the positioning after the
14116 @samp{D} commands that are groff extensions.  This has been clarified
14117 by establishing the classical rule for all @code{groff} drawing commands:
14119 @itemize
14120 @item
14121 The position after a graphic object has been drawn is at its end;
14122 for circles and ellipses, the `end' is at the right side.
14124 @item
14125 From this, the positionings specified for the drawing commands above
14126 follow quite naturally.
14127 @end itemize
14128 @end ignore
14130 @end itemize
14133 @c =====================================================================
14135 @node Font Files,  , gtroff Output, File formats
14136 @section Font Files
14137 @cindex font files
14138 @cindex files, font
14140 The @code{gtroff} font format is roughly a superset of the
14141 @code{ditroff} font format (as used in later versions of @acronym{AT&T}
14142 @code{troff} and its descendants).  Unlike the @code{ditroff} font
14143 format, there is no associated binary format; all files are text
14144 files.@footnote{Plan@tie{}9 @code{troff} has also abandoned the binary
14145 format.}  The font files for device @var{name} are stored in a directory
14146 @file{dev@var{name}}.  There are two types of file: a device description
14147 file called @file{DESC} and for each font@tie{}@var{f} a font file
14148 called@tie{}@file{@var{f}}.
14150 @menu
14151 * DESC File Format::
14152 * Font File Format::
14153 @end menu
14155 @c ---------------------------------------------------------------------
14157 @node DESC File Format, Font File Format, Font Files, Font Files
14158 @subsection @file{DESC} File Format
14159 @cindex @file{DESC} file, format
14160 @cindex font description file, format
14161 @cindex format of font description file
14162 @pindex DESC@r{ file format}
14164 The @file{DESC} file can contain the following types of line.  Except
14165 for the @code{charset} keyword which must comes last (if at all), the
14166 order of the lines is not important.
14168 @table @code
14169 @item res @var{n}
14170 @kindex res
14171 @cindex device resolution
14172 @cindex resolution, device
14173 There are @var{n}@tie{}machine units per inch.
14175 @item hor @var{n}
14176 @kindex hor
14177 @cindex horizontal resolution
14178 @cindex resolution, horizontal
14179 The horizontal resolution is @var{n}@tie{}machine units.  All horizontal
14180 quantities are rounded to be multiples of this value.
14182 @item vert @var{n}
14183 @kindex vert
14184 @cindex vertical resolution
14185 @cindex resolution, vertical
14186 The vertical resolution is @var{n}@tie{}machine units.  All vertical
14187 quantities are rounded to be multiples of this value.
14189 @item sizescale @var{n}
14190 @kindex sizescale
14191 The scale factor for point sizes.  By default this has a value of@tie{}1.
14192 One scaled point is equal to one point/@var{n}.  The arguments to the
14193 @code{unitwidth} and @code{sizes} commands are given in scaled points.
14194 @xref{Fractional Type Sizes}, for more information.
14196 @item unitwidth @var{n}
14197 @kindex unitwidth
14198 Quantities in the font files are given in machine units for fonts whose
14199 point size is @var{n}@tie{}scaled points.
14201 @item prepro @var{program}
14202 @kindex prepro
14203 Call @var{program} as a preprocessor.  Currently, this keyword is used
14204 by @code{groff} with option @option{-Thtml} only.
14206 @item postpro @var{program}
14207 @kindex postpro
14208 Call @var{program} as a postprocessor.  For example, the line
14210 @Example
14211 postpro grodvi
14212 @endExample
14214 @noindent
14215 in the file @file{devdvi/DESC} makes @code{groff} call @code{grodvi}
14216 if option @option{-Tdvi} is given (and @option{-Z} isn't used).
14218 @item tcommand
14219 @kindex tcommand
14220 This means that the postprocessor can handle the @samp{t} and @samp{u}
14221 intermediate output commands.
14223 @item sizes @var{s1} @var{s2} @dots{} @var{sn} 0
14224 @kindex sizes
14225 This means that the device has fonts at @var{s1}, @var{s2}, @dots{}
14226 @var{sn} scaled points.  The list of sizes must be terminated by@tie{}0
14227 (this is digit zero).  Each @var{si} can also be a range of sizes
14228 @var{m}-@var{n}.  The list can extend over more than one line.
14230 @item styles @var{S1} @var{S2} @dots{} @var{Sm}
14231 @kindex styles
14232 The first @var{m}@tie{}font positions are associated with styles
14233 @var{S1} @dots{} @var{Sm}.
14235 @item fonts @var{n} @var{F1} @var{F2} @var{F3} @dots{} @var{Fn}
14236 @kindex fonts
14237 Fonts @var{F1} @dots{} @var{Fn} are mounted in the font positions
14238 @var{m}+1, @dots{}, @var{m}+@var{n} where @var{m} is the number of
14239 styles.  This command may extend over more than one line.  A font name
14240 of@tie{}0 means no font is mounted on the corresponding font position.
14242 @item family @var{fam}
14243 @kindex family
14244 The default font family is @var{fam}.
14246 @item use_charnames_in_special
14247 @kindex use_charnames_in_special
14248 This command indicates that @code{gtroff} should encode special
14249 characters inside special commands.  Currently, this is only used
14250 by the @acronym{HTML} output device.  @xref{Postprocessor Access}.
14252 @item papersize @var{string} @dots{}
14253 @kindex papersize
14254 Select a paper size.  Valid values for @var{string} are the ISO paper
14255 types @code{A0}-@code{A7}, @code{B0}-@code{B7}, @code{C0}-@code{C7},
14256 @code{D0}-@code{D7}, @code{DL}, and the US paper types @code{letter},
14257 @code{legal}, @code{tabloid}, @code{ledger}, @code{statement},
14258 @code{executive}, @code{com10}, and @code{monarch}.  Case is not significant
14259 for @var{string} if it holds predefined paper types.  Alternatively,
14260 @var{string} can be a file name (e.g.@: @file{/etc/papersize}); if the file
14261 can be opened, @code{groff} reads the first line and tests for the above
14262 paper sizes.  Finally, @var{string} can be a custom paper size in the format
14263 @code{@var{length},@var{width}} (no spaces before and after the comma).
14264 Both @var{length} and @var{width} must have a unit appended; valid values
14265 are @samp{i} for inches, @samp{C} for centimeters, @samp{p} for points, and
14266 @samp{P} for picas.  Example: @code{12c,235p}.  An argument which starts
14267 with a digit is always treated as a custom paper format.  @code{papersize}
14268 sets both the vertical and horizontal dimension of the output medium.
14270 More than one argument can be specified; @code{groff} scans from left to
14271 right and uses the first valid paper specification.
14273 @item pass_filenames
14274 @kindex pass_filenames
14275 Tell @code{gtroff} to emit the name of the source file currently
14276 being processed.  This is achieved by the intermediate output command
14277 @samp{F}.  Currently, this is only used by the @acronym{HTML} output
14278 device.
14280 @item print @var{program}
14281 @kindex print
14282 Use @var{program} as a spooler program for printing.  If omitted,
14283 the @option{-l} and @option{-L} options of @code{groff} are ignored.
14285 @item charset
14286 @kindex charset
14287 This line and everything following in the file are ignored.  It is
14288 allowed for the sake of backwards compatibility.
14289 @end table
14291 The @code{res}, @code{unitwidth}, @code{fonts}, and @code{sizes} lines
14292 are mandatory.  Other commands are ignored by @code{gtroff} but may be
14293 used by postprocessors to store arbitrary information about the device
14294 in the @file{DESC} file.
14296 @kindex spare1
14297 @kindex spare2
14298 @kindex biggestfont
14299 Here a list of obsolete keywords which are recognized by @code{groff}
14300 but completely ignored: @code{spare1}, @code{spare2},
14301 @code{biggestfont}.
14304 @c ---------------------------------------------------------------------
14306 @node Font File Format,  , DESC File Format, Font Files
14307 @subsection Font File Format
14308 @cindex font file, format
14309 @cindex font description file, format
14310 @cindex format of font files
14311 @cindex format of font description files
14313 A @dfn{font file}, also (and probably better) called a @dfn{font
14314 description file}, has two sections.  The first section is a sequence
14315 of lines each containing a sequence of blank delimited words; the first
14316 word in the line is a key, and subsequent words give a value for that
14317 key.
14319 @table @code
14320 @item name @var{f}
14321 @kindex name
14322 The name of the font is@tie{}@var{f}.
14324 @item spacewidth @var{n}
14325 @kindex spacewidth
14326 The normal width of a space is@tie{}@var{n}.
14328 @item slant @var{n}
14329 @kindex slant
14330 The glyphs of the font have a slant of @var{n}@tie{}degrees.
14331 (Positive means forward.)
14333 @item ligatures @var{lig1} @var{lig2} @dots{} @var{lign} [0]
14334 @kindex ligatures
14335 Glyphs @var{lig1}, @var{lig2}, @dots{}, @var{lign} are ligatures;
14336 possible ligatures are @samp{ff}, @samp{fi}, @samp{fl}, @samp{ffi} and
14337 @samp{ffl}.  For backwards compatibility, the list of ligatures may be
14338 terminated with a@tie{}0.  The list of ligatures may not extend over more
14339 than one line.
14341 @item special
14342 @cindex special fonts
14343 @kindex special
14344 The font is @dfn{special}; this means that when a glyph is requested
14345 that is not present in the current font, it is searched for in any
14346 special fonts that are mounted.
14347 @end table
14349 Other commands are ignored by @code{gtroff} but may be used by
14350 postprocessors to store arbitrary information about the font in the font
14351 file.
14353 @cindex comments in font files
14354 @cindex font files, comments
14355 @kindex #
14356 The first section can contain comments which start with the @samp{#}
14357 character and extend to the end of a line.
14359 The second section contains one or two subsections.  It must contain a
14360 @code{charset} subsection and it may also contain a @code{kernpairs}
14361 subsection.  These subsections can appear in any order.  Each
14362 subsection starts with a word on a line by itself.
14364 @kindex charset
14365 The word @code{charset} starts the character set
14366 subsection.@footnote{This keyword is misnamed since it starts a list
14367 of ordered glyphs, not characters.}  The @code{charset} line is
14368 followed by a sequence of lines.  Each line gives information for one
14369 glyph.  A line comprises a number of fields separated by blanks or
14370 tabs.  The format is
14372 @quotation
14373 @var{name} @var{metrics} @var{type} @var{code}
14374 [@var{entity-name}] [@code{--} @var{comment}]
14375 @end quotation
14377 @cindex 8-bit input
14378 @cindex input, 8-bit
14379 @cindex accessing unnamed glyphs with @code{\N}
14380 @cindex unnamed glyphs, accessing with @code{\N}
14381 @cindex characters, unnamed, accessing with @code{\N}
14382 @cindex glyphs, unnamed, accessing with @code{\N}
14383 @kindex ---
14384 @noindent
14385 @var{name} identifies the glyph name@footnote{The distinction between
14386 input, characters, and output, glyphs, is not clearly separated in the
14387 terminology of @code{groff}; for example, the @code{char} request
14388 should be called @code{glyph} since it defines an output entity.}:
14389 If @var{name} is a single character@tie{}@var{c} then it corresponds
14390 to the @code{gtroff} input character@tie{}@var{c}; if it is of the form
14391 @samp{\@var{c}} where @var{c} is a single character, then it
14392 corresponds to the special character @code{\[@var{c}]}; otherwise it
14393 corresponds to the special character @samp{\[@var{name}]}.  If it
14394 is exactly two characters @var{xx} it can be entered as
14395 @samp{\(@var{xx}}.  Note that single-letter special characters can't
14396 be accessed as @samp{\@var{c}}; the only exception is @samp{\-} which
14397 is identical to @code{\[-]}.
14399 @code{gtroff} supports 8-bit input characters; however some utilities
14400 have difficulties with eight-bit characters.  For this reason, there is
14401 a convention that the entity name @samp{char@var{n}} is equivalent to
14402 the single input character whose code is@tie{}@var{n}.  For example,
14403 @samp{char163} would be equivalent to the character with code@tie{}163
14404 which is the pounds sterling sign in the ISO@tie{}@w{Latin-1} character set.
14405 You shouldn't use @samp{char@var{n}} entities in font description files
14406 since they are related to input, not output.  Otherwise, you get
14407 hard-coded connections between input and output encoding which
14408 prevents use of different (input) character sets.
14410 The name @samp{---} is special and indicates that the glyph is
14411 unnamed; such glyphs can only be used by means of the @code{\N}
14412 escape sequence in @code{gtroff}.
14414 The @var{type} field gives the glyph type:
14416 @table @code
14417 @item 1
14418 the glyph has a descender, for example, @samp{p};
14420 @item 2
14421 the glyph has an ascender, for example, @samp{b};
14423 @item 3
14424 the glyph has both an ascender and a descender, for example, @samp{(}.
14425 @end table
14427 The @var{code} field gives the code which the postprocessor uses to
14428 print the glyph.  The glyph can also be input to @code{gtroff}
14429 using this code by means of the @code{\N} escape sequence.  @var{code}
14430 can be any integer.  If it starts with @samp{0} it is interpreted as
14431 octal; if it starts with @samp{0x} or @samp{0X} it is interpreted as
14432 hexadecimal.  Note, however, that the @code{\N} escape sequence only
14433 accepts a decimal integer.
14435 The @var{entity-name} field gives an @acronym{ASCII} string
14436 identifying the glyph which the postprocessor uses to print the
14437 @code{gtroff} glyph @var{name}.  This field is optional and has been
14438 introduced so that the @acronym{HTML} device driver can encode its
14439 character set.  For example, the glyph @samp{\[Po]} is
14440 represented as @samp{&pound;} in @acronym{HTML} 4.0.
14442 Anything on the line after the @var{entity-name} field resp.@: after
14443 @samp{--} will be ignored.
14445 The @var{metrics} field has the form:
14447 @display
14448 @group
14449 @var{width}[@code{,}@var{height}[@code{,}@var{depth}[@code{,}@var{italic-correction}
14450   [@code{,}@var{left-italic-correction}[@code{,}@var{subscript-correction}]]]]]
14451 @end group
14452 @end display
14454 @noindent
14455 There must not be any spaces between these subfields (it has been split
14456 here into two lines for better legibility only).  Missing subfields are
14457 assumed to be@tie{}0.  The subfields are all decimal integers.  Since
14458 there is no associated binary format, these values are not required to
14459 fit into a variable of type @samp{char} as they are in @code{ditroff}.
14460 The @var{width} subfield gives the width of the glyph.  The @var{height}
14461 subfield gives the height of the glyph (upwards is positive); if a
14462 glyph does not extend above the baseline, it should be given a zero
14463 height, rather than a negative height.  The @var{depth} subfield gives
14464 the depth of the glyph, that is, the distance from the baseline to the
14465 lowest point below the baseline to which the glyph extends (downwards is
14466 positive); if a glyph does not extend below the baseline, it should be
14467 given a zero depth, rather than a negative depth.  The
14468 @var{italic-correction} subfield gives the amount of space that should
14469 be added after the glyph when it is immediately to be followed by a
14470 glyph from a roman font.  The @var{left-italic-correction} subfield
14471 gives the amount of space that should be added before the glyph when it
14472 is immediately to be preceded by a glyph from a roman font.  The
14473 @var{subscript-correction} gives the amount of space that should be
14474 added after a glyph before adding a subscript.  This should be less
14475 than the italic correction.
14477 A line in the @code{charset} section can also have the format
14479 @Example
14480 @var{name} "
14481 @endExample
14483 @noindent
14484 This indicates that @var{name} is just another name for the glyph
14485 mentioned in the preceding line.
14487 @kindex kernpairs
14488 The word @code{kernpairs} starts the kernpairs section.  This contains a
14489 sequence of lines of the form:
14491 @Example
14492 @var{c1} @var{c2} @var{n}
14493 @endExample
14495 @noindent
14496 This means that when glyph @var{c1} appears next to glyph @var{c2}
14497 the space between them should be increased by@tie{}@var{n}.  Most
14498 entries in the kernpairs section have a negative value for@tie{}@var{n}.
14502 @c =====================================================================
14503 @c =====================================================================
14505 @node Installation, Copying This Manual, File formats, Top
14506 @chapter Installation
14507 @cindex installation
14509 @c XXX
14513 @c =====================================================================
14514 @c =====================================================================
14516 @node Copying This Manual, Request Index, Installation, Top
14517 @appendix Copying This Manual
14519 @menu
14520 * GNU Free Documentation License::  License for copying this manual.
14521 @end menu
14523 @include fdl.texi
14527 @c =====================================================================
14528 @c =====================================================================
14530 @node Request Index, Escape Index, Copying This Manual, Top
14531 @appendix Request Index
14533 Requests appear without the leading control character (normally either
14534 @samp{.} or @samp{'}).
14536 @printindex rq
14540 @c =====================================================================
14541 @c =====================================================================
14543 @node Escape Index, Operator Index, Request Index, Top
14544 @appendix Escape Index
14546 Any escape sequence @code{\@var{X}} with @var{X} not in the list below
14547 emits a warning, printing glyph @var{X}.
14549 @printindex es
14553 @c =====================================================================
14554 @c =====================================================================
14556 @node Operator Index, Register Index, Escape Index, Top
14557 @appendix Operator Index
14559 @printindex op
14563 @c =====================================================================
14564 @c =====================================================================
14566 @node Register Index, Macro Index, Operator Index, Top
14567 @appendix Register Index
14569 The macro package or program a specific register belongs to is appended in
14570 brackets.
14572 A register name@tie{}@code{x} consisting of exactly one character can be
14573 accessed as @samp{\nx}.  A register name @code{xx} consisting of exactly
14574 two characters can be accessed as @samp{\n(xx}.  Register names @code{xxx}
14575 of any length can be accessed as @samp{\n[xxx]}.
14577 @printindex vr
14581 @c =====================================================================
14582 @c =====================================================================
14584 @node Macro Index, String Index, Register Index, Top
14585 @appendix Macro Index
14587 The macro package a specific macro belongs to is appended in brackets.
14588 They appear without the leading control character (normally @samp{.}).
14590 @printindex ma
14594 @c =====================================================================
14595 @c =====================================================================
14597 @node String Index, Glyph Name Index, Macro Index, Top
14598 @appendix String Index
14600 The macro package or program a specific string belongs to is appended in
14601 brackets.
14603 A string name@tie{}@code{x} consisting of exactly one character can be
14604 accessed as @samp{\*x}.  A string name @code{xx} consisting of exactly
14605 two characters can be accessed as @samp{\*(xx}.  String names @code{xxx}
14606 of any length can be accessed as @samp{\*[xxx]}.
14609 @printindex st
14613 @c =====================================================================
14614 @c =====================================================================
14616 @node Glyph Name Index, Font File Keyword Index, String Index, Top
14617 @appendix Glyph Name Index
14619 A glyph name @code{xx} consisting of exactly two characters can be
14620 accessed as @samp{\(xx}.  Glyph names @code{xxx} of any length can be
14621 accessed as @samp{\[xxx]}.
14623 @c XXX
14627 @c =====================================================================
14628 @c =====================================================================
14630 @node Font File Keyword Index, Program and File Index, Glyph Name Index, Top
14631 @appendix Font File Keyword Index
14633 @printindex ky
14637 @c =====================================================================
14638 @c =====================================================================
14640 @node Program and File Index, Concept Index, Font File Keyword Index, Top
14641 @appendix Program and File Index
14643 @printindex pg
14647 @c =====================================================================
14648 @c =====================================================================
14650 @node Concept Index,  , Program and File Index, Top
14651 @appendix Concept Index
14653 @printindex cp
14656 @bye