Don't produce HTML files if utility programs are missing.
[s-roff.git] / doc / groff.texinfo
blob1ecf7e11c677294dcd76d84a96ecbbf08490cf9f
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.2 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 Free Software Foundation, Inc.
28 @quotation
29 Permission is granted to copy, distribute and/or modify this document
30 under the terms of the GNU Free Documentation License, Version 1.1 or
31 any later version published by the Free Software Foundation; with no
32 Invariant Sections, with the Front-Cover texts being `A GNU Manual,''
33 and with the Back-Cover Texts as in (a) below.  A copy of the
34 license is included in the section entitled `GNU Free Documentation
35 License.''
37 (a) The FSF's Back-Cover Text is: `You have freedom to copy and modify
38 this GNU Manual, like GNU software.  Copies published by the Free
39 Software Foundation raise funds for GNU development.''
40 @end quotation
41 @end copying
44 @c We use the following indices:
46 @c   cindex: concepts
47 @c   rqindex: requests
48 @c   esindex: escapes
49 @c   vindex: registers
50 @c   kindex: commands in font files
51 @c   pindex: programs and files
52 @c   tindex: environment variables
53 @c   maindex: macros
54 @c   stindex: strings
55 @c   opindex: operators
57 @c tindex and cindex are merged.
59 @defcodeindex rq
60 @defcodeindex es
61 @defcodeindex ma
62 @defcodeindex st
63 @defcodeindex op
64 @syncodeindex tp cp
67 @c to avoid uppercasing in @deffn while converting to info, we define
68 @c our special @Var{}
70 @c due to a (not officially documented) `feature' in makeinfo 4.0,
71 @c macros are not expanded in @deffn (but the macro definition is
72 @c properly removed), so we have to define @Var{} directly in TeX also
74 @macro Var{arg}
75 \arg\
76 @end macro
77 @tex
78 \gdef\Var#1{\var{#1}}
79 @end tex
82 @c To assure correct HTML translation, some ugly hacks are necessary.
83 @c While processing a @def... request, the HTML translator looks at the
84 @c next line to decide whether it should start indentation or not.  If
85 @c it is something starting with @def... (e.g. @deffnx), it doesn't.
86 @c So we must assure during macro expansion that a @def... is seen.
88 @c The following macros have to be used:
90 @c One item:
92 @c   @Def...
94 @c Two items:
96 @c   @Def...List
97 @c   @Def...ListEnd
99 @c More than two:
101 @c   @Def...List
102 @c   @Def...Item
103 @c   @Def...Item
104 @c   ...
105 @c   @Def...ListEnd
107 @c The definition block must end with
109 @c   @endDef...
111 @c The above is valid for texinfo 4.0f.
114 @c a dummy macro to assure the `@def...'
116 @macro defdummy
117 @end macro
120 @c definition of requests
122 @macro Defreq{name, arg}
123 @deffn Request @t{.\name\} \arg\
124 @rqindex \name\
125 @end macro
127 @macro DefreqList{name, arg}
128 @deffn Request @t{.\name\} \arg\
129 @defdummy
130 @rqindex \name\
131 @end macro
133 @macro DefreqItem{name, arg}
134 @deffnx Request @t{.\name\} \arg\
135 @defdummy
136 @rqindex \name\
137 @end macro
139 @macro DefreqListEnd{name, arg}
140 @deffnx Request @t{.\name\} \arg\
141 @rqindex \name\
142 @end macro
144 @macro endDefreq
145 @end deffn
146 @end macro
149 @c definition of escapes
151 @macro Defesc{name, delimI, arg, delimII}
152 @deffn Escape @t{\name\\delimI\}@var{\arg\}@t{\delimII\}
153 @esindex \name\
154 @end macro
156 @macro DefescList{name, delimI, arg, delimII}
157 @deffn Escape @t{\name\\delimI\}@var{\arg\}@t{\delimII\}
158 @defdummy
159 @esindex \name\
160 @end macro
162 @macro DefescItem{name, delimI, arg, delimII}
163 @deffnx Escape @t{\name\\delimI\}@var{\arg\}@t{\delimII\}
164 @defdummy
165 @esindex \name\
166 @end macro
168 @macro DefescListEnd{name, delimI, arg, delimII}
169 @deffnx Escape @t{\name\\delimI\}@var{\arg\}@t{\delimII\}
170 @esindex \name\
171 @end macro
173 @macro endDefesc
174 @end deffn
175 @end macro
178 @c definition of registers
180 @macro Defreg{name}
181 @deffn Register @t{\\n[\name\]}
182 @vindex \name\
183 @end macro
185 @macro DefregList{name}
186 @deffn Register @t{\\n[\name\]}
187 @defdummy
188 @vindex \name\
189 @end macro
191 @macro DefregItem{name}
192 @deffnx Register @t{\\n[\name\]}
193 @defdummy
194 @vindex \name\
195 @end macro
197 @macro DefregListEnd{name}
198 @deffnx Register @t{\\n[\name\]}
199 @vindex \name\
200 @end macro
202 @macro endDefreg
203 @end deffn
204 @end macro
207 @c definition of registers specific to macro packages, preprocessors, etc.
209 @macro Defmpreg{name, package}
210 @deffn Register @t{\\n[\name\]}
211 @vindex \name\ @r{[}\package\@r{]}
212 @end macro
214 @macro DefmpregList{name, package}
215 @deffn Register @t{\\n[\name\]}
216 @defdummy
217 @vindex \name\ @r{[}\package\@r{]}
218 @end macro
220 @macro DefmpregItem{name, package}
221 @deffnx Register @t{\\n[\name\]}
222 @defdummy
223 @vindex \name\ @r{[}\package\@r{]}
224 @end macro
226 @macro DefmpregListEnd{name, package}
227 @deffnx Register @t{\\n[\name\]}
228 @vindex \name\ @r{[}\package\@r{]}
229 @end macro
231 @macro endDefmpreg
232 @end deffn
233 @end macro
236 @c definition of macros
238 @macro Defmac{name, arg, package}
239 @defmac @t{.\name\} \arg\
240 @maindex \name\ @r{[}\package\@r{]}
241 @end macro
243 @macro DefmacList{name, arg, package}
244 @defmac @t{.\name\} \arg\
245 @defdummy
246 @maindex \name\ @r{[}\package\@r{]}
247 @end macro
249 @macro DefmacItem{name, arg, package}
250 @defmacx @t{.\name\} \arg\
251 @defdummy
252 @maindex \name\ @r{[}\package\@r{]}
253 @end macro
255 @macro DefmacListEnd{name, arg, package}
256 @defmacx @t{.\name\} \arg\
257 @maindex \name\ @r{[}\package\@r{]}
258 @end macro
260 @macro endDefmac
261 @end defmac
262 @end macro
265 @c definition of strings
267 @macro Defstr{name, package}
268 @deffn String @t{\\*[\name\]}
269 @stindex \name\ @r{[}\package\@r{]}
270 @end macro
272 @macro DefstrList{name, package}
273 @deffn String @t{\\*[\name\]}
274 @defdummy
275 @stindex \name\ @r{[}\package\@r{]}
276 @end macro
278 @macro DefstrItem{name, package}
279 @deffnx String @t{\\*[\name\]}
280 @defdummy
281 @stindex \name\ @r{[}\package\@r{]}
282 @end macro
284 @macro DefstrListEnd{name, package}
285 @deffnx String @t{\\*[\name\]}
286 @stindex \name\ @r{[}\package\@r{]}
287 @end macro
289 @macro endDefstr
290 @end deffn
291 @end macro
294 @c our example macro
296 @macro Example
297 @example
298 @group
299 @end macro
301 @macro endExample
302 @end group
303 @end example
304 @end macro
307 @c <text>
309 @tex
310 \gdef\angles#1{\angleleft{}\r{#1}\angleright{}}
311 @end tex
313 @macro angles{text}
314 <\text\>
315 @end macro
318 @c a <= sign
320 @tex
321 \gdef\LE{\le}
322 @end tex
324 @macro LE
326 @end macro
329 @c due to a bug in texinfo 4.2, the spacing of `<' is bad in @item
331 @tex
332 \gdef\LT{\string<}
333 @end tex
335 @macro LT
337 @end macro
340 @c We need special parentheses and brackets:
342 @c . Real parentheses in @deffn produce an error while compiling with
343 @c   TeX
344 @c . Real brackets use the wrong font in @deffn, overriding @t{}.
346 @c Since macros aren't expanded in @deffn during -E, the following
347 @c definitions are for non-TeX only.
349 @c This is true for texinfo 4.0.
351 @macro lparen
353 @end macro
354 @macro rparen
356 @end macro
357 @macro lbrack
359 @end macro
360 @macro rbrack
362 @end macro
365 @tex
366 \gdef\gobblefirst#1#2{#2}
367 \gdef\putwordAppendix{\gobblefirst}
368 @end tex
371 @c Note: We say `Roman numerals' but `roman font'.
374 @dircategory Miscellaneous
375 @direntry
376 * Groff: (groff).               The GNU troff document formatting system.
377 @end direntry
380 @titlepage
381 @title groff
382 @subtitle The GNU implementation of @code{troff}
383 @subtitle Edition 1.18
384 @subtitle Spring 2002
385 @author by Trent A.@w{ }Fisher
386 @author and Werner Lemberg (@email{bug-groff@@gnu.org})
388 @page
389 @vskip 0pt plus 1filll
390 @insertcopying
391 @end titlepage
394 @contents
397 @ifinfo
398 @node Top, Introduction, (dir), (dir)
399 @top GNU troff
401 @insertcopying
402 @end ifinfo
404 @menu
405 * Introduction::
406 * Invoking groff::
407 * Tutorial for Macro Users::
408 * Macro Packages::
409 * gtroff Reference::
410 * Preprocessors::
411 * Output Devices::
412 * File formats::
413 * Installation::
414 * Copying This Manual::
415 * Request Index::
416 * Escape Index::
417 * Operator Index::
418 * Register Index::
419 * Macro Index::
420 * String Index::
421 * Glyph Name Index::
422 * Font File Keyword Index::
423 * Program and File Index::
424 * Concept Index::
425 @end menu
429 @c =====================================================================
430 @c =====================================================================
432 @node Introduction, Invoking groff, Top, Top
433 @chapter Introduction
434 @cindex introduction
436 GNU @code{troff} (or @code{groff}) is a system for typesetting
437 documents.  @code{troff} is very flexible and has been in existence (and
438 use) for about 3@w{ }decades.  It is quite widespread and firmly
439 entrenched in the @acronym{UNIX} community.
441 @menu
442 * What Is groff?::
443 * History::
444 * groff Capabilities::
445 * Macro Package Intro::
446 * Preprocessor Intro::
447 * Output device intro::
448 * Credits::
449 @end menu
452 @c =====================================================================
454 @node What Is groff?, History, Introduction, Introduction
455 @section What Is @code{groff}?
456 @cindex what is @code{groff}?
457 @cindex @code{groff} -- what is it?
459 @code{groff} belongs to an older generation of document preparation
460 systems, which operate more like compilers than the more recent
461 interactive @acronym{WYSIWYG}@footnote{What You See Is What You Get}
462 systems.  @code{groff} and its contemporary counterpart, @TeX{}, both
463 work using a @dfn{batch} paradigm: The input (or @dfn{source}) files are
464 normal text files with embedded formatting commands.  These files can
465 then be processed by @code{groff} to produce a typeset document on a
466 variety of devices.
468 Likewise, @code{groff} should not be confused with a @dfn{word
469 processor}, since that term connotes an integrated system that includes
470 an editor and a text formatter.  Also, many word processors follow the
471 @acronym{WYSIWYG} paradigm discussed earlier.
473 Although @acronym{WYSIWYG} systems may be easier to use, they have a
474 number of disadvantages compared to @code{troff}:
476 @itemize @bullet
477 @item
478 They must be used on a graphics display to work on a document.
480 @item
481 Most of the @acronym{WYSIWYG} systems are either non-free or are not
482 very portable.
484 @item
485 @code{troff} is firmly entrenched in all @acronym{UNIX} systems.
487 @item
488 It is difficult to have a wide range of capabilities available within
489 the confines of a GUI/window system.
491 @item
492 It is more difficult to make global changes to a document.
493 @end itemize
495 @quotation
496 ``GUIs normally make it simple to accomplish simple actions and
497 impossible to accomplish complex actions.''  --Doug Gwyn (22/Jun/91 in
498 @code{comp.unix.wizards})
499 @end quotation
502 @c =====================================================================
504 @node History, groff Capabilities, What Is groff?, Introduction
505 @section History
506 @cindex history
508 @cindex @code{runoff}, the program
509 @cindex @code{rf}, the program
510 @code{troff} can trace its origins back to a formatting program called
511 @code{runoff}, written by J.@w{ }E.@w{ }Saltzer, which ran on MIT's CTSS
512 operating system in the mid-sixties.  This name came from the common
513 phrase of the time ``I'll run off a document.''  Bob Morris ported it to
514 the 635 architecture and called the program @code{roff} (an abbreviation
515 of @code{runoff}).  It was rewritten as @code{rf} for the @w{PDP-7}
516 (before having @acronym{UNIX}), and at the same time (1969), Doug
517 McIllroy rewrote an extended and simplified version of @code{roff} in
518 the @acronym{BCPL} programming language.
520 @cindex @code{roff}, the program
521 The first version of @acronym{UNIX} was developed on a @w{PDP-7} which
522 was sitting around Bell Labs.  In 1971 the developers wanted to get a
523 @w{PDP-11} for further work on the operating system.  In order to
524 justify the cost for this system, they proposed that they would
525 implement a document formatting system for the @acronym{AT&T} patents
526 division.  This first formatting program was a reimplementation of
527 McIllroy's @code{roff}, written by J.@w{ }F.@w{ }Ossanna.
529 @cindex @code{nroff}, the program
530 When they needed a more flexible language, a new version of @code{roff}
531 called @code{nroff} (``Newer @code{roff}'') was written.  It had a much
532 more complicated syntax, but provided the basis for all future versions.
533 When they got a Graphic Systems CAT Phototypesetter, Ossanna wrote a
534 version of @code{nroff} that would drive it.  It was dubbed
535 @code{troff}, for ``typesetter @code{roff}'', although many people have
536 speculated that it actually means ``Times @code{roff}'' because of the
537 use of the Times font family in @code{troff} by default.  As such, the
538 name @code{troff} is pronounced `@w{t-roff}' rather than `trough'.
540 With @code{troff} came @code{nroff} (they were actually the same program
541 except for some @samp{#ifdef}s), which was for producing output for line
542 printers and character terminals.  It understood everything @code{troff}
543 did, and ignored the commands which were not applicable (e.g.@: font
544 changes).
546 Since there are several things which cannot be done easily in
547 @code{troff}, work on several preprocessors began.  These programs would
548 transform certain parts of a document into @code{troff}, which made a
549 very natural use of pipes in @acronym{UNIX}.
551 The @code{eqn} preprocessor allowed mathematical formul@ae{} to be
552 specified in a much simpler and more intuitive manner.  @code{tbl} is a
553 preprocessor for formatting tables.  The @code{refer} preprocessor (and
554 the similar program, @code{bib}) processes citations in a document
555 according to a bibliographic database.
557 Unfortunately, Ossanna's @code{troff} was written in @w{PDP-11} assembly
558 language and produced output specifically for the CAT phototypesetter.
559 He rewrote it in C, although it was now 7000@w{ }lines of uncommented
560 code and still dependent on the CAT.  As the CAT became less common, and
561 was no longer supported by the manufacturer, the need to make it support
562 other devices became a priority.  However, before this could be done,
563 Ossanna was killed in a car accident.
565 @pindex ditroff
566 @cindex @code{ditroff}, the program
567 So, Brian Kernighan took on the task of rewriting @code{troff}.  The
568 newly rewritten version produced device independent code which was
569 very easy for postprocessors to read and translate to the appropriate
570 printer codes.  Also, this new version of @code{troff} (called
571 @code{ditroff} for ``device independent @code{troff}'') had several
572 extensions, which included drawing functions.
574 Due to the additional abilities of the new version of @code{troff},
575 several new preprocessors appeared.  The @code{pic} preprocessor
576 provides a wide range of drawing functions.  Likewise the @code{ideal}
577 preprocessor did the same, although via a much different paradigm.  The
578 @code{grap} preprocessor took specifications for graphs, but, unlike
579 other preprocessors, produced @code{pic} code.
581 James Clark began work on a GNU implementation of @code{ditroff} in
582 early@w{ }1989.  The first version, @code{groff}@w{ }0.3.1, was released
583 June@w{ }1990.  @code{groff} included:
585 @itemize @bullet
586 @item
587 A replacement for @code{ditroff} with many extensions.
589 @item
590 The @code{soelim}, @code{pic}, @code{tbl}, and @code{eqn} preprocessors.
592 @item
593 Postprocessors for character devices, @sc{PostScript}, @TeX{} DVI, and
594 X@w{ }Windows.  GNU @code{troff} also eliminated the need for a
595 separate @code{nroff} program with a postprocessor which would produce
596 @acronym{ASCII} output.
598 @item
599 A version of the @file{me} macros and an implementation of the
600 @file{man} macros.
601 @end itemize
603 Also, a front-end was included which could construct the, sometimes
604 painfully long, pipelines required for all the post- and preprocessors.
606 Development of GNU @code{troff} progressed rapidly, and saw the
607 additions of a replacement for @code{refer}, an implementation of the
608 @file{ms} and @file{mm} macros, and a program to deduce how to format a
609 document (@code{grog}).
611 It was declared a stable (i.e.@: non-beta) package with the release of
612 version@w{ }1.04 around November@w{ }1991.
614 Beginning in@w{ }1999, @code{groff} has new maintainers (the package was
615 an orphan for a few years).  As a result, new features and programs like
616 @code{grn}, a preprocessor for gremlin images, and an output device to
617 produce @acronym{HTML} output have been added.
620 @c =====================================================================
622 @node groff Capabilities, Macro Package Intro, History, Introduction
623 @section @code{groff} Capabilities
624 @cindex @code{groff} capabilities
625 @cindex capabilities of @code{groff}
627 So what exactly is @code{groff} capable of doing?  @code{groff} provides
628 a wide range of low-level text formatting operations.  Using these, it
629 is possible to perform a wide range of formatting tasks, such as
630 footnotes, table of contents, multiple columns, etc.  Here's a list of
631 the most important operations supported by @code{groff}:
633 @itemize @bullet
634 @item
635 text filling, adjusting, and centering
637 @item
638 hyphenation
640 @item
641 page control
643 @item
644 font and glyph size control
646 @item
647 vertical spacing (i.e.@: double-spacing)
649 @item
650 line length and indenting
652 @item
653 macros, strings, diversions, and traps
655 @item
656 number registers
658 @item
659 tabs, leaders, and fields
661 @item
662 input and output conventions and character translation
664 @item
665 overstrike, bracket, line drawing, and zero-width functions
667 @item
668 local horizontal and vertical motions and the width function
670 @item
671 three-part titles
673 @item
674 output line numbering
676 @item
677 conditional acceptance of input
679 @item
680 environment switching
682 @item
683 insertions from the standard input
685 @item
686 input/output file switching
688 @item
689 output and error messages
690 @end itemize
693 @c =====================================================================
695 @node Macro Package Intro, Preprocessor Intro, groff Capabilities, Introduction
696 @section Macro Packages
697 @cindex macro packages
699 Since @code{groff} provides such low-level facilities, it can be quite
700 difficult to use by itself.  However, @code{groff} provides a
701 @dfn{macro} facility to specify how certain routine operations (e.g.@w{
702 }starting paragraphs, printing headers and footers, etc.)@: should be
703 done.  These macros can be collected together into a @dfn{macro
704 package}.  There are a number of macro packages available; the most
705 common (and the ones described in this manual) are @file{man},
706 @file{mdoc}, @file{me}, @file{ms}, and @file{mm}.
709 @c =====================================================================
711 @node Preprocessor Intro, Output device intro, Macro Package Intro, Introduction
712 @section Preprocessors
713 @cindex preprocessors
715 Although @code{groff} provides most functions needed to format a
716 document, some operations would be unwieldy (e.g.@: to draw pictures).
717 Therefore, programs called @dfn{preprocessors} were written which
718 understand their own language and produce the necessary @code{groff}
719 operations.  These preprocessors are able to differentiate their own
720 input from the rest of the document via markers.
722 To use a preprocessor, @acronym{UNIX} pipes are used to feed the output
723 from the preprocessor into @code{groff}.  Any number of preprocessors
724 may be used on a given document; in this case, the preprocessors are
725 linked together into one pipeline.  However, in @code{groff}, the user
726 does not need to construct the pipe, but only tell @code{groff} what
727 preprocessors to use.
729 @code{groff} currently has preprocessors for producing tables
730 (@code{tbl}), typesetting equations (@code{eqn}), drawing pictures
731 (@code{pic} and @code{grn}), and for processing bibliographies
732 (@code{refer}).  An associated program which is useful when dealing with
733 preprocessors is @code{soelim}.
735 A free implementation of @code{grap}, a preprocessor for drawing graphs,
736 can be obtained as an extra package; @code{groff} can use @code{grap}
737 also.
739 There are other preprocessors in existence, but, unfortunately, no free
740 implementations are available.  Among them are preprocessors for drawing
741 mathematical pictures (@code{ideal}) and chemical structures
742 (@code{chem}).
745 @c =====================================================================
747 @node Output device intro, Credits, Preprocessor Intro, Introduction
748 @section Output Devices
749 @cindex postprocessors
750 @cindex output devices
751 @cindex devices for output
753 @code{groff} actually produces device independent code which may be
754 fed into a postprocessor to produce output for a particular device.
755 Currently, @code{groff} has postprocessors for @sc{PostScript}
756 devices, character terminals, X@w{ }Windows (for previewing), @TeX{}
757 DVI format, HP LaserJet@w{ }4 and Canon LBP printers (which use
758 @acronym{CAPSL}), and @acronym{HTML}.
761 @c =====================================================================
763 @node Credits,  , Output device intro, Introduction
764 @section Credits
765 @cindex credits
767 Large portions of this manual were taken from existing documents, most
768 notably, the manual pages for the @code{groff} package by James Clark,
769 and Eric Allman's papers on the @file{me} macro package.
771 The section on the @file{man} macro package is partly based on Susan@w{
772 }G.@: Kleinmann's @file{groff_man} manual page written for the Debian
773 GNU/Linux system.
777 @c =====================================================================
778 @c =====================================================================
780 @node Invoking groff, Tutorial for Macro Users, Introduction, Top
781 @chapter Invoking @code{groff}
782 @cindex invoking @code{groff}
783 @cindex @code{groff} invocation
785 This section focuses on how to invoke the @code{groff} front end.  This
786 front end takes care of the details of constructing the pipeline among
787 the preprocessors, @code{gtroff} and the postprocessor.
789 It has become a tradition that GNU programs get the prefix @samp{g} to
790 distinguish it from its original counterparts provided by the host (see
791 @ref{Environment}, for more details).  Thus, for example, @code{geqn} is
792 GNU @code{eqn}.  On operating systems like GNU/Linux or the Hurd, which
793 don't contain proprietary versions of @code{troff}, and on
794 MS-DOS/MS-Windows, where @code{troff} and associated programs are not
795 available at all, this prefix is omitted since GNU @code{troff} is the
796 only used incarnation of @code{troff}.  Exception: @samp{groff} is never
797 replaced by @samp{roff}.
799 In this document, we consequently say @samp{gtroff} when talking about
800 the GNU @code{troff} program.  All other implementations of @code{troff}
801 are called @acronym{AT&T} @code{troff} which is the common origin of
802 all @code{troff} derivates (with more or less compatible changes).
803 Similarly, we say @samp{gpic}, @samp{geqn}, etc.
805 @menu
806 * Groff Options::
807 * Environment::
808 * Macro Directories::
809 * Invocation Examples::
810 @end menu
813 @c =====================================================================
815 @node Groff Options, Environment, Invoking groff, Invoking groff
816 @section Options
817 @cindex options
819 @pindex groff
820 @pindex gtroff
821 @pindex gpic
822 @pindex geqn
823 @pindex ggrn
824 @pindex grap
825 @pindex gtbl
826 @pindex grefer
827 @pindex gsoelim
828 @code{groff} normally runs the @code{gtroff} program and a postprocessor
829 appropriate for the selected device.  The default device is @samp{ps}
830 (but it can be changed when @code{groff} is configured and built).  It
831 can optionally preprocess with any of @code{gpic}, @code{geqn},
832 @code{gtbl}, @code{ggrn}, @code{grap}, @code{grefer}, or @code{gsoelim}.
834 This section only documents options to the @code{groff} front end.  Many
835 of the arguments to @code{groff} are passed on to @code{gtroff},
836 therefore those are also included.  Arguments to pre- or postprocessors
837 can be found in @ref{Invoking gpic}, @ref{Invoking geqn}, @ref{Invoking
838 gtbl}, @ref{Invoking ggrn}, @ref{Invoking grefer}, @ref{Invoking
839 gsoelim}, @ref{Invoking grotty}, @ref{Invoking grops}, @ref{Invoking
840 grohtml}, @ref{Invoking grodvi}, @ref{Invoking grolj4}, @ref{Invoking
841 grolbp}, and @ref{Invoking gxditview}.
843 The command line format for @code{groff} is:
845 @Example
846 groff [ -abceghilpstvzCEGNRSUVXZ ] [ -F@var{dir} ] [ -m@var{name} ]
847       [ -T@var{def} ] [ -f@var{fam} ] [ -w@var{name} ] [ -W@var{name} ]
848       [ -M@var{dir} ] [ -d@var{cs} ] [ -r@var{cn} ] [ -n@var{num} ]
849       [ -o@var{list} ] [ -P@var{arg} ] [ -L@var{arg} ] [ -I@var{dir} ]
850       [ @var{files}@dots{} ]
851 @endExample
853 The command line format for @code{gtroff} is as follows.
855 @Example
856 gtroff [ -abcivzCERU ] [ -w@var{name} ] [ -W@var{name} ] [ -d@var{cs} ]
857        [ -f@var{fam} ] [ -m@var{name} ] [ -n@var{num} ]
858        [ -o@var{list} ] [ -r@var{cn} ] [ -T@var{name} ]
859        [ -F@var{dir} ] [ -M@var{dir} ] [ @var{files}@dots{} ]
860 @endExample
862 @noindent
863 Obviously, many of the options to @code{groff} are actually passed on to
864 @code{gtroff}.
866 Options without an argument can be grouped behind a single@w{ }@option{-}.
867 A filename of@w{ }@file{-} denotes the standard input.  It is possible to
868 have whitespace between an option and its parameter.
870 The @code{grog} command can be used to guess the correct @code{groff}
871 command to format a file.
873 Here's the description of the command-line options:
875 @cindex command-line options
876 @table @samp
877 @item -h
878 Print a help message.
880 @item -e
881 Preprocess with @code{geqn}.
883 @item -t
884 Preprocess with @code{gtbl}.
886 @item -g
887 Preprocess with @code{ggrn}.
889 @item -G
890 Preprocess with @code{grap}.
892 @item -p
893 Preprocess with @code{gpic}.
895 @item -s
896 Preprocess with @code{gsoelim}.
898 @item -c
899 Suppress color output.
901 @item -R
902 Preprocess with @code{grefer}.  No mechanism is provided for passing
903 arguments to @code{grefer} because most @code{grefer} options have
904 equivalent commands which can be included in the file.  @xref{grefer},
905 for more details.
907 @pindex troffrc
908 @pindex troffrc-end
909 Note that @code{gtroff} also accepts a @option{-R} option, which is not
910 accessible via @code{groff}.  This option prevents the loading of the
911 @file{troffrc} and @file{troffrc-end} files.
913 @item -v
914 Make programs run by @code{groff} print out their version number.
916 @item -V
917 Print the pipeline on @code{stdout} instead of executing it.
919 @item -z
920 Suppress output from @code{gtroff}.  Only error messages are printed.
922 @item -Z
923 Do not postprocess the output of @code{gtroff}.  Normally @code{groff}
924 automatically runs the appropriate postprocessor.
926 @item -P@var{arg}
927 Pass @var{arg} to the postprocessor.  Each argument should be passed
928 with a separate @option{-P} option.  Note that @code{groff} does not
929 prepend @samp{-} to @var{arg} before passing it to the postprocessor.
931 @item -l
932 Send the output to a spooler for printing.  The command used for this is
933 specified by the @code{print} command in the device description file
934 (see @ref{Font Files}, for more info).  If not present, @option{-l} is
935 ignored.
937 @item -L@var{arg}
938 Pass @var{arg} to the spooler.  Each argument should be passed with a
939 separate @option{-L} option.  Note that @code{groff} does not prepend
940 a @samp{-} to @var{arg} before passing it to the postprocessor.
941 If the @code{print} keyword in the device description file is missing,
942 @option{-L} is ignored.
944 @item -T@var{dev}
945 Prepare output for device @var{dev}.  The default device is @samp{ps},
946 unless changed when @code{groff} was configured and built.  The
947 following are the output devices currently available:
949 @table @code
950 @item ps
951 For @sc{PostScript} printers and previewers.
953 @item dvi
954 For @TeX{} DVI format.
956 @item X75
957 For a 75@dmn{dpi} X11 previewer.
959 @item X75-12
960 For a 75@dmn{dpi} X11 previewer with a 12@dmn{pt} base font in the
961 document.
963 @item X100
964 For a 100@dmn{dpi} X11 previewer.
966 @item X100-12
967 For a 100@dmn{dpi} X11 previewer with a 12@dmn{pt} base font in the
968 document.
970 @item ascii
971 @cindex encoding, @acronym{ASCII}
972 @cindex @acronym{ASCII}, encoding
973 For typewriter-like devices using the (7-bit) @acronym{ASCII}
974 character set.
976 @item latin1
977 @cindex encoding, latin-1
978 @cindex latin-1, encoding
979 For typewriter-like devices that support the @w{Latin-1} (@w{ISO
980 8859-1}) character set.
982 @item utf8
983 @cindex encoding, utf-8
984 @cindex utf-8, encoding
985 For typewriter-like devices which use the Unicode (@w{ISO 10646})
986 character set with @w{UTF-8} encoding.
988 @item cp1047
989 @cindex @acronym{EBCDIC} encoding
990 @cindex encoding, @acronym{EBCDIC}
991 @cindex encoding, cp1047
992 @cindex cp1047
993 @cindex IBM cp1047
994 For typewriter-like devices which use the @acronym{EBCDIC} encoding IBM
995 cp1047.
997 @item lj4
998 For HP LaserJet4-compatible (or other PCL5-compatible) printers.
1000 @item lbp
1001 For Canon @acronym{CAPSL} printers (@w{LBP-4} and @w{LBP-8} series laser
1002 printers).
1004 @pindex pre-grohtml
1005 @pindex post-grohtml
1006 @cindex @code{grohtml}, the program
1007 @item html
1008 To produce @acronym{HTML} output.  Note that the @acronym{HTML} driver
1009 consists of two parts, a preprocessor (@code{pre-grohtml}) and a
1010 postprocessor (@code{post-grohtml}).
1011 @end table
1013 @cindex output device name string register (@code{.T})
1014 @cindex output device usage number register (@code{.T})
1015 The predefined @code{gtroff} string register @code{.T} contains the
1016 current output device; the read-only number register @code{.T} is set
1017 to@w{ }1 if this option is used (which is always true if @code{groff} is
1018 used to call @code{gtroff}).  @xref{Built-in Registers}.
1020 The postprocessor to be used for a device is specified by the
1021 @code{postpro} command in the device description file.  (@xref{Font
1022 Files}, for more info.)  This can be overridden with the @option{-X}
1023 option.
1025 @item -X
1026 Preview with @code{gxditview} instead of using the usual postprocessor.
1027 This is unlikely to produce good results except with @option{-Tps}.
1029 Note that this is not the same as using @option{-TX75} or
1030 @option{-TX100} to view a document with @code{gxditview}: The former
1031 uses the metrics of the specified device, whereas the latter uses
1032 X-specific fonts and metrics.
1034 @item -N
1035 Don't allow newlines with @code{eqn} delimiters.  This is the same as
1036 the @option{-N} option in @code{geqn}.
1038 @item -S
1039 @cindex @code{open} request, and safer mode
1040 @cindex @code{opena} request, and safer mode
1041 @cindex @code{pso} request, and safer mode
1042 @cindex @code{sy} request, and safer mode
1043 @cindex @code{pi} request, and safer mode
1044 @cindex safer mode
1045 @cindex mode, safer
1046 Safer mode.  Pass the @option{-S} option to @code{gpic} and disable the
1047 @code{open}, @code{opena}, @code{pso}, @code{sy}, and @code{pi}
1048 requests.  For security reasons, this is enabled by default.
1050 @item -U
1051 @cindex mode, unsafe
1052 @cindex unsafe mode
1053 Unsafe mode.  This enables the @code{open}, @code{opena}, @code{pso},
1054 @code{sy}, and @code{pi} requests.
1056 @item -a
1057 @cindex @acronym{ASCII} approximation output register (@code{.A})
1058 Generate an @acronym{ASCII} approximation of the typeset output.  The
1059 read-only register @code{.A} is then set to@w{ }1.  @xref{Built-in
1060 Registers}.  A typical example is
1062 @Example
1063 groff -a -man -Tdvi troff.man | less
1064 @endExample
1066 @noindent
1067 which shows how lines are broken for the DVI device.  Note that this
1068 option is rather useless today since graphic output devices are
1069 available virtually everywhere.
1071 @item -b
1072 Print a backtrace with each warning or error message.  This backtrace
1073 should help track down the cause of the error.  The line numbers given
1074 in the backtrace may not always be correct: @code{gtroff} can get
1075 confused by @code{as} or @code{am} requests while counting line numbers.
1077 @item -i
1078 Read the standard input after all the named input files have been
1079 processed.
1081 @item -w@var{name}
1082 Enable warning @var{name}.  Available warnings are described in
1083 @ref{Debugging}.  Multiple @option{-w} options are allowed.
1085 @item -W@var{name}
1086 Inhibit warning @var{name}.  Multiple @option{-W} options are allowed.
1088 @item -E
1089 Inhibit all error messages.
1091 @item -C
1092 Enable compatibility mode.  @xref{Implementation Differences}, for the
1093 list of incompatibilities between @code{groff} and @acronym{AT&T}
1094 @code{troff}.
1096 @item -d@var{c}@var{s}
1097 @itemx -d@var{name}=@var{s}
1098 Define @var{c} or @var{name} to be a string@w{ }@var{s}.  @var{c}@w{ }must
1099 be a one-letter name; @var{name} can be of arbitrary length.  All string
1100 assignments happen before loading any macro file (including the start-up
1101 file).
1103 @item -f@var{fam}
1104 Use @var{fam} as the default font family.  @xref{Font Families}.
1106 @item -m@var{name}
1107 Read in the file @file{@var{name}.tmac}.  Normally @code{groff} searches
1108 for this in its macro directories.  If it isn't found, it tries
1109 @file{tmac.@var{name}} (searching in the same directories).
1111 @item -n@var{num}
1112 Number the first page @var{num}.
1114 @item -o@var{list}
1115 @cindex print current page register (@code{.P})
1116 Output only pages in @var{list}, which is a comma-separated list of page
1117 ranges; @samp{@var{n}} means print page@w{ }@var{n}, @samp{@var{m}-@var{n}}
1118 means print every page between @var{m} and@w{ }@var{n}, @samp{-@var{n}}
1119 means print every page up to@w{ }@var{n}, @samp{@var{n}-} means print every
1120 page beginning with@w{ }@var{n}.  @code{gtroff} exits after printing the
1121 last page in the list.  All the ranges are inclusive on both ends.
1123 Within @code{gtroff}, this information can be extracted with the
1124 @samp{.P} register.  @xref{Built-in Registers}.
1126 If your document restarts page numbering at the beginning of each
1127 chapter, then @code{gtroff} prints the specified page range for each
1128 chapter.
1130 @item -r@var{c}@var{n}
1131 @itemx -r@var{name}=@var{n}
1132 Set number register@w{ }@var{c} or @var{name} to the value@w{ }@var{n}.
1133 @var{c}@w{ }must be a one-letter name; @var{name} can be of arbitrary
1134 length.  @var{n}@w{ }can be any @code{gtroff} numeric expression.  All
1135 register  assignments happen before loading any macro file (including
1136 the start-up file).
1138 @item -F@var{dir}
1139 Search @file{@var{dir}} for subdirectories @file{dev@var{name}}
1140 (@var{name} is the name of the device), for the @file{DESC} file, and
1141 for font files before looking in the standard directories.
1143 @item -M@var{dir}
1144 Search directory @file{@var{dir}} for macro files before the standard
1145 directories (@pxref{Macro Directories}).
1147 @item -I@var{dir}
1148 This option is as described in @ref{gsoelim}.  It implies the
1149 @option{-s} option.
1150 @end table
1153 @c =====================================================================
1155 @node Environment, Macro Directories, Groff Options, Invoking groff
1156 @section Environment
1157 @cindex environment variables
1158 @cindex variables in environment
1160 There are also several environment variables (of the operating system,
1161 not within @code{gtroff}) which can modify the behavior of @code{groff}.
1163 @table @code
1164 @item GROFF_COMMAND_PREFIX
1165 @tindex GROFF_COMMAND_PREFIX@r{, environment variable}
1166 @cindex command prefix
1167 @cindex prefix, for commands
1168 If this is set to@w{ }@var{X}, then @code{groff} runs @code{@var{X}troff}
1169 instead of @code{gtroff}.  This also applies to @code{tbl}, @code{pic},
1170 @code{eqn}, @code{grn}, @code{refer}, and @code{soelim}.  It does not
1171 apply to @code{grops}, @code{grodvi}, @code{grotty}, @code{pre-grohtml},
1172 @code{post-grohtml}, @code{grolj4}, and @code{gxditview}.
1174 The default command prefix is determined during the installation process.
1175 If a non-GNU troff system is found, prefix @samp{g} is used, none
1176 otherwise.
1178 @item GROFF_TMAC_PATH
1179 @tindex GROFF_TMAC_PATH@r{, environment variable}
1180 A colon-separated list of directories in which to search for macro files
1181 (before the default directories are tried).  @xref{Macro Directories}.
1183 @item GROFF_TYPESETTER
1184 @tindex GROFF_TYPESETTER@r{, environment variable}
1185 The default output device.
1187 @item GROFF_FONT_PATH
1188 @tindex GROFF_FONT_PATH@r{, environment variable}
1189 A colon-separated list of directories in which to search for the
1190 @code{dev}@var{name} directory (before the default directories are
1191 tried).
1193 @item GROFF_BIN_PATH
1194 @tindex GROFF_BIN_PATH@r{, environment variable}
1195 This search path, followed by @code{PATH}, is used for commands executed
1196 by @code{groff}.
1198 @item GROFF_TMPDIR
1199 @tindex GROFF_TMPDIR@r{, environment variable}
1200 @tindex TMPDIR@r{, environment variable}
1201 The directory in which @code{groff} creates temporary files.  If this is
1202 not set and @env{TMPDIR} is set, temporary files are created in that
1203 directory.  Otherwise temporary files are created in a system-dependent
1204 default directory (on Unix and GNU/Linux systems, this is usually
1205 @file{/tmp}).  @code{grops}, @code{grefer}, @code{pre-grohtml}, and
1206 @code{post-grohtml} can create temporary files in this directory.
1207 @end table
1209 Note that MS-DOS and MS-Windows ports of @code{groff} use semi-colons,
1210 rather than colons, to separate the directories in the lists described
1211 above.
1214 @c =====================================================================
1216 @node Macro Directories, Invocation Examples, Environment, Invoking groff
1217 @section Macro Directories
1218 @cindex macro directories
1219 @cindex directories for macros
1220 @cindex searching macros
1221 @cindex macros, searching
1223 All macro file names must be named @code{@var{name}.tmac} or
1224 @code{tmac.@var{name}} to make the @option{-m@var{name}} command line
1225 option work.  The @code{mso} request doesn't have this restriction; any
1226 file name can be used, and @code{gtroff} won't try to append or prepend
1227 the @samp{tmac} string.
1229 @cindex tmac, directory
1230 @cindex directory, for tmac files
1231 @cindex tmac, path
1232 @cindex path, for tmac files
1233 @cindex searching macro files
1234 @cindex macro files, searching
1235 @cindex files, macro, searching
1236 Macro files are kept in the @dfn{tmac directories}, all of which
1237 constitute the @dfn{tmac path}.  The elements of the search path for
1238 macro files are (in that order):
1240 @itemize @bullet
1241 @item
1242 The directories specified with @code{gtroff}'s or @code{groff}'s
1243 @option{-M} command line option.
1245 @item
1246 @tindex GROFF_TMAC_PATH@r{, environment variable}
1247 The directories given in the @env{GROFF_TMAC_PATH} environment
1248 variable.
1250 @item
1251 @cindex safer mode
1252 @cindex mode, safer
1253 @cindex unsafe mode
1254 @cindex mode, unsafe
1255 @cindex current directory
1256 @cindex directory, current
1257 The current directory (only if in unsafe mode using the @option{-U}
1258 command line switch).
1260 @item
1261 @cindex home directory
1262 @cindex directory, home
1263 The home directory.
1265 @item
1266 @cindex site-specific directory
1267 @cindex directory, site-specific
1268 @cindex platform-specific directory
1269 @cindex directory, platform-specific
1270 A platform-dependent directory, a site-specific (platform-independent)
1271 directory, and the main tmac directory; the default locations are
1273 @Example
1274 /usr/local/lib/groff/site-tmac
1275 /usr/local/share/groff/site-tmac
1276 /usr/local/share/groff/1.18/tmac
1277 @endExample
1279 @noindent
1280 assuming that the version of @code{groff} is 1.18, and the installation
1281 prefix was @file{/usr/local}.  It is possible to fine-tune those
1282 directories during the installation process.
1283 @end itemize
1286 @c =====================================================================
1288 @node Invocation Examples,  , Macro Directories, Invoking groff
1289 @section Invocation Examples
1290 @cindex invocation examples
1291 @cindex examples of invocation
1293 This section lists several common uses of @code{groff} and the
1294 corresponding command lines.
1296 @Example
1297 groff file
1298 @endExample
1300 @noindent
1301 This command processes @file{file} without a macro package or a
1302 preprocessor.  The output device is the default, @samp{ps}, and the
1303 output is sent to @code{stdout}.
1305 @Example
1306 groff -t -mandoc -Tascii file | less
1307 @endExample
1309 @noindent
1310 This is basically what a call to the @code{man} program does.
1311 @code{gtroff} processes the manual page @file{file} with the
1312 @file{mandoc} macro file (which in turn either calls the @file{man} or
1313 the @file{mdoc} macro package), using the @code{tbl} preprocessor and
1314 the @acronym{ASCII} output device.  Finally, the @code{less} pager
1315 displays the result.
1317 @Example
1318 groff -X -m me file
1319 @endExample
1321 @noindent
1322 Preview @file{file} with @code{gxditview}, using the @file{me} macro
1323 package.  Since no @option{-T} option is specified, use the default
1324 device (@samp{ps}).  Note that you can either say @w{@samp{-m me}} or
1325 @w{@samp{-me}}; the latter is an anachronism from the early days of
1326 @acronym{UNIX}.@footnote{The same is true for the other main macro
1327 packages that come with @code{groff}: @file{man}, @file{mdoc},
1328 @file{ms}, @file{mm}, and @file{mandoc}.  This won't work in general;
1329 for example, to load @file{trace.tmac}, either @samp{-mtrace} or
1330 @w{@samp{-m trace}} must be used.}
1332 @Example
1333 groff -man -rD1 -z file
1334 @endExample
1336 @noindent
1337 Check @file{file} with the @file{man} macro package, forcing
1338 double-sided printing -- don't produce any output.
1340 @menu
1341 * grog::
1342 @end menu
1344 @c ---------------------------------------------------------------------
1346 @node grog,  , Invocation Examples, Invocation Examples
1347 @subsection @code{grog}
1349 @pindex grog
1350 @code{grog} reads files, guesses which of the @code{groff} preprocessors
1351 and/or macro packages are required for formatting them, and prints the
1352 @code{groff} command including those options on the standard output.  It
1353 generates one or more of the options @option{-e}, @option{-man},
1354 @option{-me}, @option{-mm}, @option{-mom}, @option{-ms}, @option{-mdoc},
1355 @option{-mdoc-old}, @option{-p}, @option{-R}, @option{-g}, @option{-G},
1356 @option{-s}, and @option{-t}.
1358 A special file name@w{ }@file{-} refers to the standard input.  Specifying
1359 no files also means to read the standard input.  Any specified options
1360 are included in the printed command.  No space is allowed between
1361 options and their arguments.  The only options recognized are
1362 @option{-C} (which is also passed on) to enable compatibility mode, and
1363 @option{-v} (if it is the only parameter) to print the version number.
1365 For example,
1367 @Example
1368 grog -Tdvi paper.ms
1369 @endExample
1371 @noindent
1372 guesses the appropriate command to print @file{paper.ms} and then prints
1373 it to the command line after adding the @option{-Tdvi} option.  For
1374 direct execution, enclose the call to @code{grog} in backquotes at the
1375 @acronym{UNIX} shell prompt:
1377 @Example
1378 `grog -Tdvi paper.ms` > paper.dvi
1379 @endExample
1381 @noindent
1382 As seen in the example, it is still necessary to redirect the output to
1383 something meaningful (i.e.@: either a file or a pager program like
1384 @code{less}).
1388 @c =====================================================================
1389 @c =====================================================================
1391 @node Tutorial for Macro Users, Macro Packages, Invoking groff, Top
1392 @chapter Tutorial for Macro Users
1393 @cindex tutorial for macro users
1394 @cindex macros, tutorial for users
1395 @cindex user's tutorial for macros
1396 @cindex user's macro tutorial
1398 Most users tend to use a macro package to format their papers.  This
1399 means that the whole breadth of @code{groff} is not necessary for most
1400 people.  This chapter covers the material needed to efficiently use a
1401 macro package.
1403 @menu
1404 * Basics::
1405 * Common Features::
1406 @end menu
1409 @c =====================================================================
1411 @node Basics, Common Features, Tutorial for Macro Users, Tutorial for Macro Users
1412 @section Basics
1413 @cindex basics of macros
1414 @cindex macro basics
1416 This section covers some of the basic concepts necessary to understand
1417 how to use a macro package.@footnote{This section is derived from
1418 @cite{Writing Papers with nroff using -me} by Eric P.@w{ }Allman.}
1419 References are made throughout to more detailed information, if desired.
1421 @code{gtroff} reads an input file prepared by the user and outputs a
1422 formatted document suitable for publication or framing.  The input
1423 consists of text, or words to be printed, and embedded commands
1424 (@dfn{requests} and @dfn{escapes}), which tell @code{gtroff} how to
1425 format the output.  For more detail on this, see @ref{Embedded
1426 Commands}.
1428 The word @dfn{argument} is used in this chapter to mean a word or number
1429 which appears on the same line as a request, and which modifies the
1430 meaning of that request.  For example, the request
1432 @Example
1434 @endExample
1436 @noindent
1437 spaces one line, but
1439 @Example
1440 .sp 4
1441 @endExample
1443 @noindent
1444 spaces four lines.  The number@w{ }4 is an argument to the @code{sp}
1445 request which says to space four lines instead of one.  Arguments are
1446 separated from the request and from each other by spaces (@emph{no}
1447 tabs).  More details on this can be found in @ref{Request Arguments}.
1449 The primary function of @code{gtroff} is to collect words from input
1450 lines, fill output lines with those words, justify the right-hand margin
1451 by inserting extra spaces in the line, and output the result.  For
1452 example, the input:
1454 @Example
1455 Now is the time
1456 for all good men
1457 to come to the aid
1458 of their party.
1459 Four score and seven
1460 years ago,...
1461 @endExample
1463 @noindent
1464 is read, packed onto output lines, and justified to produce:
1466 @quotation
1467 Now is the time for all good men to come to the aid of their party.
1468 Four score and seven years ago,@dots{}
1469 @end quotation
1471 @cindex break
1472 @cindex line break
1473 Sometimes a new output line should be started even though the current
1474 line is not yet full; for example, at the end of a paragraph.  To do
1475 this it is possible to cause a @dfn{break}, which starts a new output
1476 line.  Some requests cause a break automatically, as normally do blank
1477 input lines and input lines beginning with a space.
1479 Not all input lines are text to be formatted.  Some input lines are
1480 requests which describe how to format the text.  Requests always have a
1481 period (@samp{.}) or an apostrophe (@samp{'}) as the first character of
1482 the input line.
1484 The text formatter also does more complex things, such as automatically
1485 numbering pages, skipping over page boundaries, putting footnotes in the
1486 correct place, and so forth.
1488 Here are a few hints for preparing text for input to @code{gtroff}.
1490 @itemize @bullet
1491 @item
1492 First, keep the input lines short.  Short input lines are easier to
1493 edit, and @code{gtroff} packs words onto longer lines anyhow.
1495 @item
1496 In keeping with this, it is helpful to begin a new line after every
1497 comma or phrase, since common corrections are to add or delete sentences
1498 or phrases.
1500 @item
1501 End each sentence with two spaces -- or better, start each sentence on a
1502 new line.  @code{gtroff} recognizes characters that usually end a
1503 sentence, and inserts sentence space accordingly.
1505 @item
1506 Do not hyphenate words at the end of lines -- @code{gtroff} is smart
1507 enough to hyphenate words as needed, but is not smart enough to take
1508 hyphens out and join a word back together.  Also, words such as
1509 ``mother-in-law'' should not be broken over a line, since then a space
1510 can occur where not wanted, such as ``@w{mother- in}-law''.
1511 @end itemize
1513 @cindex double-spacing (@code{ls})
1514 @cindex spacing
1515 @code{gtroff} double-spaces output text automatically if you use the
1516 request @w{@samp{.ls 2}}.  Reactivate single-spaced mode by typing
1517 @w{@samp{.ls 1}}.@footnote{If you need finer granularity of the
1518 vertical space, use the @code{pvs} request (@pxref{Changing Type
1519 Sizes}).}
1521 A number of requests allow to change the way the output looks,
1522 sometimes called the @dfn{layout} of the output page.  Most of these
1523 requests adjust the placing of @dfn{whitespace} (blank lines or
1524 spaces).
1526 @cindex new page (@code{bp})
1527 The @code{bp} request starts a new page, causing a line break.
1529 @cindex blank line (@code{sp})
1530 @cindex empty line (@code{sp})
1531 @cindex line, empty (@code{sp})
1532 The request @w{@samp{.sp @var{N}}} leaves @var{N}@w{ }lines of blank
1533 space.  @var{N}@w{ }can be omitted (meaning skip a single line) or can
1534 be of the form @var{N}i (for @var{N}@w{ }inches) or @var{N}c (for
1535 @var{N}@w{ }centimeters).  For example, the input:
1537 @Example
1538 .sp 1.5i
1539 My thoughts on the subject
1541 @endExample
1543 @noindent
1544 leaves one and a half inches of space, followed by the line ``My
1545 thoughts on the subject'', followed by a single blank line (more
1546 measurement units are available, see @ref{Measurements}).
1548 @cindex centering lines (@code{ce})
1549 @cindex lines, centering (@code{ce})
1550 Text lines can be centered by using the @code{ce} request.  The line
1551 after @code{ce} is centered (horizontally) on the page.  To center more
1552 than one line, use @w{@samp{.ce @var{N}}} (where @var{N} is the number
1553 of lines to center), followed by the @var{N}@w{ }lines.  To center many
1554 lines without counting them, type:
1556 @Example
1557 .ce 1000
1558 lines to center
1559 .ce 0
1560 @endExample
1562 @noindent
1563 The @w{@samp{.ce 0}} request tells @code{groff} to center zero more
1564 lines, in other words, stop centering.
1566 @cindex line break (@code{br})
1567 @cindex break (@code{br})
1568 All of these requests cause a break; that is, they always start a new
1569 line.  To start a new line without performing any other action, use
1570 @code{br}.
1573 @c =====================================================================
1575 @node Common Features,  , Basics, Tutorial for Macro Users
1576 @section Common Features
1577 @cindex common features
1578 @cindex features, common
1580 @code{gtroff} provides very low-level operations for formatting a
1581 document.  There are many common routine operations which are done in
1582 all documents.  These common operations are written into @dfn{macros}
1583 and collected into a @dfn{macro package}.
1585 All macro packages provide certain common capabilities which fall into
1586 the following categories.
1588 @menu
1589 * Paragraphs::
1590 * Sections and Chapters::
1591 * Headers and Footers::
1592 * Page Layout Adjustment::
1593 * Displays::
1594 * Footnotes and Annotations::
1595 * Table of Contents::
1596 * Indices::
1597 * Paper Formats::
1598 * Multiple Columns::
1599 * Font and Size Changes::
1600 * Predefined Strings::
1601 * Preprocessor Support::
1602 * Configuration and Customization::
1603 @end menu
1605 @c ---------------------------------------------------------------------
1607 @node Paragraphs, Sections and Chapters, Common Features, Common Features
1608 @subsection Paragraphs
1609 @cindex paragraphs
1611 One of the most common and most used capability is starting a
1612 paragraph.  There are a number of different types of paragraphs, any
1613 of which can be initiated with macros supplied by the macro package.
1614 Normally, paragraphs start with a blank line and the first line
1615 indented, like the text in this manual.  There are also block style
1616 paragraphs, which omit the indentation:
1618 @Example
1619 Some   men  look   at  constitutions   with  sanctimonious
1620 reverence, and deem them like the ark of the covenant, too
1621 sacred to be touched.
1622 @endExample
1624 @noindent
1625 And there are also indented paragraphs which begin with a tag or label
1626 at the margin and the remaining text indented.
1628 @Example
1629 one   This is  the first paragraph.  Notice  how the first
1630       line of  the resulting  paragraph lines up  with the
1631       other lines in the paragraph.
1632 @endExample
1633 @Example
1634 longlabel
1635       This  paragraph   had  a  long   label.   The  first
1636       character of text on the first line does not line up
1637       with  the  text  on  second  and  subsequent  lines,
1638       although they line up with each other.
1639 @endExample
1641 A variation of this is a bulleted list.
1643 @Example
1644 .     Bulleted lists start with a bullet.   It is possible
1645       to use other glyphs instead of the bullet.  In nroff
1646       mode using the ASCII character set for output, a dot
1647       is used instead of a real bullet.
1648 @endExample
1651 @c ---------------------------------------------------------------------
1653 @node Sections and Chapters, Headers and Footers, Paragraphs, Common Features
1654 @subsection Sections and Chapters
1656 Most macro packages supply some form of section headers.  The simplest
1657 kind is simply the heading on a line by itself in bold type.  Others
1658 supply automatically numbered section heading or different heading
1659 styles at different levels.  Some, more sophisticated, macro packages
1660 supply macros for starting chapters and appendices.
1662 @c ---------------------------------------------------------------------
1664 @node Headers and Footers, Page Layout Adjustment, Sections and Chapters, Common Features
1665 @subsection Headers and Footers
1667 Every macro package gives some way to manipulate the @dfn{headers} and
1668 @dfn{footers} (also called @dfn{titles}) on each page.  This is text
1669 put at the top and bottom of each page, respectively, which contain
1670 data like the current page number, the current chapter title, and so
1671 on.  Its appearance is not affected by the running text.  Some packages
1672 allow for different ones on the even and odd pages (for material printed
1673 in a book form).
1675 The titles are called @dfn{three-part titles}, that is, there is a
1676 left-justified part, a centered part, and a right-justified part.  An
1677 automatically generated page number may be put in any of these fields
1678 with the @samp{%} character (see @ref{Page Layout}, for more details).
1680 @c ---------------------------------------------------------------------
1682 @node Page Layout Adjustment, Displays, Headers and Footers, Common Features
1683 @subsection Page Layout
1685 Most macro packages let the user specify top and bottom margins and
1686 other details about the appearance of the printed pages.
1688 @c ---------------------------------------------------------------------
1690 @node Displays, Footnotes and Annotations, Page Layout Adjustment, Common Features
1691 @subsection Displays
1692 @cindex displays
1694 @dfn{Displays} are sections of text to be set off from the body of
1695 the paper.  Major quotes, tables, and figures are types of displays, as
1696 are all the examples used in this document.
1698 @cindex quotes, major
1699 @cindex major quotes
1700 @dfn{Major quotes} are quotes which are several lines long, and hence
1701 are set in from the rest of the text without quote marks around them.
1703 @cindex list
1704 A @dfn{list} is an indented, single-spaced, unfilled display.  Lists
1705 should be used when the material to be printed should not be filled and
1706 justified like normal text, such as columns of figures or the examples
1707 used in this paper.
1709 @cindex keep
1710 A @dfn{keep} is a display of lines which are kept on a single page if
1711 possible.  An example for a keep might be a diagram.  Keeps differ from
1712 lists in that lists may be broken over a page boundary whereas keeps are
1713 not.
1715 @cindex keep, floating
1716 @cindex floating keep
1717 @dfn{Floating keeps} move relative to the text.  Hence, they are good for
1718 things which are referred to by name, such as ``See figure@w{ }3''.  A
1719 floating keep appears at the bottom of the current page if it fits;
1720 otherwise, it appears at the top of the next page.  Meanwhile, the
1721 surrounding text `flows' around the keep, thus leaving no blank areas.
1723 @c ---------------------------------------------------------------------
1725 @node Footnotes and Annotations, Table of Contents, Displays, Common Features
1726 @subsection Footnotes and Annotations
1727 @cindex footnotes
1728 @cindex annotations
1730 There are a number of requests to save text for later printing.
1732 @dfn{Footnotes} are printed at the bottom of the current page.
1734 @cindex delayed text
1735 @dfn{Delayed text} is very similar to a footnote except that it is
1736 printed when called for explicitly.  This allows a list of references to
1737 appear (for example) at the end of each chapter, as is the convention in
1738 some disciplines.
1740 Most macro packages which supply this functionality also supply a means
1741 of automatically numbering either type of annotation.
1743 @c ---------------------------------------------------------------------
1745 @node Table of Contents, Indices, Footnotes and Annotations, Common Features
1746 @subsection Table of Contents
1747 @cindex table of contents
1748 @cindex contents, table of
1750 @dfn{Tables of contents} are a type of delayed text having a tag
1751 (usually the page number) attached to each entry after a row of dots.
1752 The table accumulates throughout the paper until printed, usually after
1753 the paper has ended.  Many macro packages provide the ability to have
1754 several tables of contents (e.g.@: a standard table of contents, a list
1755 of tables, etc).
1757 @c ---------------------------------------------------------------------
1759 @node Indices, Paper Formats, Table of Contents, Common Features
1760 @subsection Indices
1761 @cindex index, in macro package
1763 While some macro packages use the term @dfn{index}, none actually
1764 provide that functionality.  The facilities they call indices are
1765 actually more appropriate for tables of contents.
1767 @pindex makeindex
1768 To produce a real index in a document, external tools like the
1769 @code{makeindex} program are necessary.
1771 @c ---------------------------------------------------------------------
1773 @node Paper Formats, Multiple Columns, Indices, Common Features
1774 @subsection Paper Formats
1775 @cindex paper formats
1777 Some macro packages provide stock formats for various kinds of
1778 documents.  Many of them provide a common format for the title and
1779 opening pages of a technical paper.  The @file{mm} macros in particular
1780 provide formats for letters and memoranda.
1782 @c ---------------------------------------------------------------------
1784 @node Multiple Columns, Font and Size Changes, Paper Formats, Common Features
1785 @subsection Multiple Columns
1787 Some macro packages (but not @file{man}) provide the ability to have two
1788 or more columns on a page.
1790 @c ---------------------------------------------------------------------
1792 @node Font and Size Changes, Predefined Strings, Multiple Columns, Common Features
1793 @subsection Font and Size Changes
1795 The built-in font and size functions are not always intuitive, so all
1796 macro packages provide macros to make these operations simpler.
1798 @c ---------------------------------------------------------------------
1800 @node Predefined Strings, Preprocessor Support, Font and Size Changes, Common Features
1801 @subsection Predefined Strings
1803 Most macro packages provide various predefined strings for a variety of
1804 uses; examples are sub- and superscripts, printable dates, quotes and
1805 various special characters.
1807 @c ---------------------------------------------------------------------
1809 @node Preprocessor Support, Configuration and Customization, Predefined Strings, Common Features
1810 @subsection Preprocessor Support
1812 All macro packages provide support for various preprocessors and may
1813 extend their functionality.
1815 For example, all macro packages mark tables (which are processed with
1816 @code{gtbl}) by placing them between @code{TS} and @code{TE} macros.
1817 The @file{ms} macro package has an option, @samp{.TS@w{ }H}, that prints
1818 a caption at the top of a new page (when the table is too long to fit on
1819 a single page).
1821 @c ---------------------------------------------------------------------
1823 @node Configuration and Customization,  , Preprocessor Support, Common Features
1824 @subsection Configuration and Customization
1826 Some macro packages provide means of customizing many of the details of
1827 how the package behaves.  This ranges from setting the default type size
1828 to changing the appearance of section headers.
1832 @c =====================================================================
1833 @c =====================================================================
1835 @node Macro Packages, gtroff Reference, Tutorial for Macro Users, Top
1836 @chapter Macro Packages
1837 @cindex macro packages
1838 @cindex packages, macros
1840 This chapter documents the main macro packages that come with
1841 @code{groff}.
1843 @menu
1844 * man::
1845 * mdoc::
1846 * ms::
1847 * me::
1848 * mm::
1849 @end menu
1852 @c =====================================================================
1854 @node man, mdoc, Macro Packages, Macro Packages
1855 @section @file{man}
1856 @cindex manual pages
1857 @cindex man pages
1858 @pindex an.tmac
1859 @pindex man.tmac
1860 @pindex man-old.tmac
1862 This is the most popular and probably the most important macro package
1863 of @code{groff}.  It is easy to use, and a vast majority of manual pages
1864 are based on it.
1866 @menu
1867 * Man options::
1868 * Man usage::
1869 * Man font macros::
1870 * Miscellaneous man macros::
1871 * Predefined man strings::
1872 * Preprocessors in man pages::
1873 @end menu
1875 @c ---------------------------------------------------------------------
1877 @node Man options, Man usage, man, man
1878 @subsection Options
1880 The command line format for using the @file{man} macros with
1881 @code{groff} is:
1883 @Example
1884 groff -m man [ -rLL=@var{length} ] [ -rLT=@var{length} ]
1885       [ -rcR=1 ] [ -rC1 ] [ -rD1 ] [ -rP@var{nnn} ]
1886       [ -rS@var{xx} ] [ -rX@var{nnn} ] [ @var{files}@dots{} ]
1887 @endExample
1889 @noindent
1890 It is possible to use @samp{-man} instead of @w{@samp{-m man}}.
1892 @table @code
1893 @item -rLL=@var{length}
1894 Set line length to @var{length}.  If not specified, the line length
1895 defaults to 78@w{ }en in nroff mode (this is 78@w{ }characters per
1896 line) and 6.5@w{ }inch otherwise.
1898 @item -rLT=@var{length}
1899 Set title length to @var{length}.  If not specified, the title length
1900 defaults to 78@w{ }en in nroff mode (this is 78@w{ }characters per
1901 line) and 6.5@w{ }inch otherwise.
1903 @item -rcR=1
1904 This option (the default if a TTY output device is used) creates a
1905 single, very long page instead of multiple pages.  Use @code{-rcR=0}
1906 to disable it.
1908 @item -rC1
1909 If more than one manual page is given on the command line, number the
1910 pages continuously, rather than starting each at@w{ }1.
1912 @item -rD1
1913 Double-sided printing.  Footers for even and odd pages are formatted
1914 differently.
1916 @item -rP@var{nnn}
1917 Page numbering starts with @var{nnn} rather than with@w{ }1.
1919 @item -rS@var{xx}
1920 Use @var{xx} (which can be 10, 11, or@w{ }12@dmn{pt}) as the base
1921 document font size instead of the default value of@w{ }10@dmn{pt}.
1923 @item -rX@var{nnn}
1924 After page @var{nnn}, number pages as @var{nnn}a, @var{nnn}b,
1925 @var{nnn}c, etc.  For example, the option @option{-rX2} produces the
1926 following page numbers: 1, 2, 2a, 2b, 2c, etc.
1927 @end table
1929 @c ---------------------------------------------------------------------
1931 @node Man usage, Man font macros, Man options, man
1932 @subsection Usage
1933 @cindex @code{man} macros
1934 @cindex macros for manual pages [@code{man}]
1936 @pindex man.local
1937 This section describes the available macros for manual pages.  For
1938 further customization, put additional macros and requests into the file
1939 @file{man.local} which is loaded immediately after the @file{man}
1940 package.
1942 @Defmac {TH, title section [@Var{extra1} [@Var{extra2} [@Var{extra3}]]], man}
1943 Set the title of the man page to @var{title} and the section to
1944 @var{section}, which must have a value between 1 and@w{ }8.  The value
1945 of @var{section} may also have a string appended, e.g.@: @samp{.pm},
1946 to indicate a specific subsection of the man pages.
1948 Both @var{title} and @var{section} are positioned at the left and right
1949 in the header line (with @var{section} in parentheses immediately
1950 appended to @var{title}.  @var{extra1} is positioned in the middle of
1951 the footer line.  @var{extra2} is positioned at the left in the footer
1952 line (or at the left on even pages and at the right on odd pages if
1953 double-sided printing is active).  @var{extra3} is centered in the
1954 header line.
1956 For @acronym{HTML} output, headers and footers are completely suppressed.
1958 Additionally, this macro starts a new page; the new line number is@w{ }1
1959 again (except if the @option{-rC1} option is given on the command line)
1960 -- this feature is intended only for formatting multiple man pages; a
1961 single man page should contain exactly one @code{TH} macro at the
1962 beginning of the file.
1963 @endDefmac
1965 @Defmac {SH, [@Var{heading}], man}
1966 Set up an unnumbered section heading sticking out to the left.  Prints
1967 out all the text following @code{SH} up to the end of the line (or the
1968 text in the next line if there is no argument to @code{SH}) in bold
1969 face, one size larger than the base document size.  Additionally, the
1970 left margin for the following text is reset to its default value.
1971 @endDefmac
1973 @Defmac {SS, [@Var{heading}], man}
1974 Set up an unnumbered (sub)section heading.  Prints out all the text
1975 following @code{SS} up to the end of the line (or the text in the next
1976 line if there is no argument to @code{SS}) in bold face, at the same
1977 size as the base document size.  Additionally, the left margin for the
1978 following text is reset to its default value.
1979 @endDefmac
1981 @Defmac {TP, [@Var{nnn}], man}
1982 Set up an indented paragraph with label.  The indentation is set to
1983 @var{nnn} if that argument is supplied (the default unit is @samp{n}
1984 if omitted), otherwise it is set to the default indentation value.
1986 The first line of text following this macro is interpreted as a string
1987 to be printed flush-left, as it is appropriate for a label.  It is not
1988 interpreted as part of a paragraph, so there is no attempt to fill the
1989 first line with text from the following input lines.  Nevertheless, if
1990 the label is not as wide as the indentation, then the paragraph starts
1991 at the same line (but indented), continuing on the following lines.
1992 If the label is wider than the indentation, then the descriptive part
1993 of the paragraph begins on the line following the label, entirely
1994 indented.  Note that neither font shape nor font size of the label is
1995 set to a default value; on the other hand, the rest of the text has
1996 default font settings.
1997 @endDefmac
1999 @DefmacList {LP, , man}
2000 @DefmacItem {PP, , man}
2001 @DefmacListEnd {P, , man}
2002 These macros are mutual aliases.  Any of them causes a line break at
2003 the current position, followed by a vertical space downwards by the
2004 amount specified by the @code{PD} macro.  The font size and shape are
2005 reset to the default value (10@dmn{pt} roman if no @option{-rS} option
2006 is given on the command line).  Finally, the current left margin is
2007 restored.
2008 @endDefmac
2010 @Defmac {IP, [@Var{designator} [@Var{nnn}]], man}
2011 Set up an indented paragraph, using @var{designator} as a tag to mark
2012 its beginning.  The indentation is set to @var{nnn} if that argument
2013 is supplied (default unit is @samp{n}), otherwise the default
2014 indentation value is used.  Font size and face of the paragraph (but
2015 not the designator) are reset to their default values.  To start an
2016 indented paragraph with a particular indentation but without a
2017 designator, use @samp{""} (two double quotes) as the first argument of
2018 @code{IP}.
2020 For example, to start a paragraph with bullets as the designator and
2021 4@w{ }en indentation, write
2023 @Example
2024 .IP \(bu 4
2025 @endExample
2026 @endDefmac
2028 @Defmac {HP, [@Var{nnn}], man}
2029 @cindex hanging indentation [@code{man}]
2030 @cindex @code{man} macros, hanging indentation
2031 Set up a paragraph with hanging left indentation.  The indentation is
2032 set to @var{nnn} if that argument is supplied (default unit is
2033 @samp{n}), otherwise the default indentation value is used.  Font size
2034 and face are reset to their default values.
2035 @endDefmac
2037 @Defmac {RS, [@Var{nnn}], man}
2038 @cindex left margin, how to move [@code{man}]
2039 @cindex @code{man} macros, moving left margin
2040 Move the left margin to the right by the value @var{nnn} if specified
2041 (default unit is @samp{n}); otherwise the default indentation value
2042 is used.  Calls to the @code{RS} macro can be nested.
2043 @endDefmac
2045 @Defmac {RE, [@Var{nnn}], man}
2046 Move the left margin back to level @var{nnn}; if no argument is given,
2047 it moves one level back.  The first level (i.e., no call to @code{RS}
2048 yet) has number@w{ }1, and each call to @code{RS} increases the level
2049 by@w{ }1.
2050 @endDefmac
2052 @cindex line breaks, with vertical space [@code{man}]
2053 @cindex @code{man} macros, line breaks with vertical space
2054 To summarize, the following macros cause a line break with the insertion
2055 of vertical space (which amount can be changed with the @code{PD}
2056 macro): @code{SH}, @code{SS}, @code{TP}, @code{LP} (@code{PP},
2057 @code{P}), @code{IP}, and @code{HP}.
2059 @cindex line breaks, without vertical space [@code{man}]
2060 @cindex @code{man} macros, line breaks without vertical space
2061 The macros @code{RS} and @code{RE} also cause a break but do not insert
2062 vertical space.
2064 @c ---------------------------------------------------------------------
2066 @node Man font macros, Miscellaneous man macros, Man usage, man
2067 @subsection Macros to set fonts
2068 @cindex font selection [@code{man}]
2069 @cindex @code{man} macros, how to set fonts
2071 The standard font is roman; the default text size is 10@w{ }point.
2072 If command line option @option{-rS=@var{n}} is given, use
2073 @var{n}@dmn{pt} as the default text size.
2075 @Defmac {SM, [@Var{text}], man}
2076 Set the text on the same line or the text on the next line in a font
2077 that is one point size smaller than the default font.
2078 @endDefmac
2080 @Defmac {SB, [@Var{text}], man}
2081 @cindex bold face [@code{man}]
2082 @cindex @code{man} macros, bold face
2083 Set the text on the same line or the text on the next line in bold face
2084 font, one point size smaller than the default font.
2085 @endDefmac
2087 @Defmac {BI, text, man}
2088 Set its arguments alternately in bold face and italic.  Thus,
2090 @Example
2091 .BI this "word and" that
2092 @endExample
2094 @noindent
2095 would set ``this'' and ``that'' in bold face, and ``word and'' in
2096 italics.
2097 @endDefmac
2099 @Defmac {IB, text, man}
2100 Set its arguments alternately in italic and bold face.
2101 @endDefmac
2103 @Defmac {RI, text, man}
2104 Set its arguments alternately in roman and italic.
2105 @endDefmac
2107 @Defmac {IR, text, man}
2108 Set its arguments alternately in italic and roman.
2109 @endDefmac
2111 @Defmac {BR, text, man}
2112 Set its arguments alternately in bold face and roman.
2113 @endDefmac
2115 @Defmac {RB, text, man}
2116 Set its arguments alternately in roman and bold face.
2117 @endDefmac
2119 @Defmac {B, [@Var{text}], man}
2120 Set @var{text} in bold face.  If no text is present on the line where
2121 the macro is called, then the text of the next line appears in bold
2122 face.
2123 @endDefmac
2125 @Defmac {I, [@Var{text}], man}
2126 @cindex italic fonts [@code{man}]
2127 @cindex @code{man} macros, italic fonts
2128 Set @var{text} in italic.  If no text is present on the line where the
2129 macro is called, then the text of the next line appears in italic.
2130 @endDefmac
2132 @c ---------------------------------------------------------------------
2134 @node Miscellaneous man macros, Predefined man strings, Man font macros, man
2135 @subsection Miscellaneous macros
2137 @pindex grohtml
2138 @cindex @code{man} macros, default indentation
2139 @cindex default indentation [@code{man}]
2140 The default indentation is 7.2@w{ }en for all output devices except for
2141 @code{grohtml} which ignores indentation.
2143 @Defmac {DT, , man}
2144 @cindex tab stops [@code{man}]
2145 @cindex @code{man} macros, tab stops
2146 Set tabs every 0.5@w{ }inches.  Since this macro is always executed
2147 during a call to the @code{TH} macro, it makes sense to call it only if
2148 the tab positions have been changed.
2149 @endDefmac
2151 @Defmac {PD, [@Var{nnn}], man}
2152 @cindex empty space before a paragraph [@code{man}]
2153 @cindex @code{man} macros, empty space before a paragraph
2154 Adjust the empty space before a new paragraph (or section).  The
2155 optional argument gives the amount of space (default unit is
2156 @samp{v}); without parameter, the value is reset to its default value
2157 (1@w{ }line for TTY devices, 0.4@dmn{v}@w{ }otherwise).
2158 @endDefmac
2160 This affects the macros @code{SH}, @code{SS}, @code{TP}, @code{LP} (as
2161 well as @code{PP} and @code{P}), @code{IP}, and @code{HP}.
2163 @c ---------------------------------------------------------------------
2165 @node Predefined man strings, Preprocessors in man pages, Miscellaneous man macros, man
2166 @subsection Predefined strings
2168 The following strings are defined:
2170 @Defstr {S, man}
2171 Switch back to the default font size.
2172 @endDefstr
2174 @Defstr {R, man}
2175 The `registered' sign.
2176 @endDefstr
2178 @Defstr {Tm, man}
2179 The `trademark' sign.
2180 @endDefstr
2182 @DefstrList {lq, man}
2183 @DefstrListEnd {rq, man}
2184 @cindex @code{lq} glyph, and @code{lq} string [@code{man}]
2185 @cindex @code{rq} glyph, and @code{rq} string [@code{man}]
2186 Left and right quote.  This is equal to @code{\(lq} and @code{\(rq},
2187 respectively.
2188 @endDefstr
2190 @c ---------------------------------------------------------------------
2192 @node Preprocessors in man pages,  , Predefined man strings, man
2193 @subsection Preprocessors in @file{man} pages
2195 @cindex preprocessor, calling convention
2196 @cindex calling convention of preprocessors
2197 If a preprocessor like @code{gtbl} or @code{geqn} is needed, it has
2198 become common usage to make the first line of the man page look like
2199 this:
2201 @Example
2202 '\" @var{word}
2203 @endExample
2205 @pindex geqn@r{, invocation in manual pages}
2206 @pindex grefer@r{, invocation in manual pages}
2207 @pindex gtbl@r{, invocation in manual pages}
2208 @pindex man@r{, invocation of preprocessors}
2209 @noindent
2210 Note the single space character after the double quote.  @var{word}
2211 consists of letters for the needed preprocessors: @samp{e} for
2212 @code{geqn}, @samp{r} for @code{grefer}, @samp{t} for @code{gtbl}.
2213 Modern implementations of the @code{man} program read this first line
2214 and automatically call the right preprocessor(s).
2217 @c =====================================================================
2219 @node mdoc, ms, man, Macro Packages
2220 @section @file{mdoc}
2221 @cindex @code{mdoc} macros
2223 @c XXX documentation
2224 @c XXX this is a placeholder until we get stuff knocked into shape
2225 See the @cite{groff_mdoc(7)} man page (type @command{man groff_mdoc}
2226 at the command line).
2229 @c =====================================================================
2231 @node ms, me, mdoc, Macro Packages
2232 @section @file{ms}
2233 @cindex @code{ms} macros
2235 The @file{-ms}
2236 macros are suitable for reports, letters, books,
2237 user manuals, and so forth.
2238 The package provides macros for cover pages, section headings,
2239 paragraphs, lists, footnotes, pagination,
2240 and a table of contents.
2242 @menu
2243 * ms Intro::
2244 * General ms Structure::
2245 * ms Document Control Registers::
2246 * ms Cover Page Macros::
2247 * ms Body Text::
2248 * ms Page Layout::
2249 * Differences from AT&T ms::
2250 @end menu
2252 @c ---------------------------------------------------------------------
2254 @node ms Intro, General ms Structure, ms, ms
2255 @subsection Introduction to @file{ms}
2257 The original @file{-ms} macros were included with
2258 @acronym{AT&T} @code{troff} as well as the
2259 @file{man} macros.
2260 While the @file{man} package is intended for brief documents
2261 that can be read on-line as well as printed, the @file{ms}
2262 macros are suitable for longer documents that are meant to be
2263 printed rather than read on-line.
2265 The @file{ms} macro package included with @code{groff}
2266 is a complete, bottom-up re-implementation.
2267 Several macros (specific to @acronym{AT&T}
2268 or Berkeley) are not included, while several new commands are.
2269 @xref{Differences from AT&T ms}, for more information.
2271 @c ---------------------------------------------------------------------
2273 @node General ms Structure, ms Document Control Registers, ms Intro, ms
2274 @subsection General structure of an @file{ms} document
2275 @cindex @code{ms} macros, general structure
2277 The @file{ms} macro package expects a certain amount of structure,
2278 but not as much as packages such as @file{man} or @file{mdoc}.
2280 The simplest documents can begin with a paragraph macro
2281 (such as @code{LP} or @code{PP}),
2282 and consist of text separated by paragraph macros
2283 or even blank lines.
2284 Longer documents have a structure as follows:
2286 @table @strong
2287 @item Document type
2288 If you invoke the @code{RP}
2289 (report) macro on the first line of the document,
2290 @code{groff} prints the cover page information on its own page;
2291 otherwise it prints the information on the
2292 first page with your document text immediately following.
2293 Other document formats found in @acronym{AT&T} @code{troff}
2294 are specific to @acronym{AT&T} or Berkeley, and are not supported in
2295 @code{groff}.
2297 @item Format and layout
2298 By setting number registers,
2299 you can change your document's type (font and size),
2300 margins, spacing, headers and footers, and footnotes.
2301 @xref{ms Document Control Registers}, for more details.
2303 @item Cover page
2304 A cover page consists of a title, the author's name and institution,
2305 an abstract, and the date.
2306 @footnote{Actually, only the title is required.}
2307 @xref{ms Cover Page Macros}, for more details.
2309 @item Body
2310 Following the cover page is your document.
2311 You can use the @file{ms}
2312 macros to write reports, letters, books, and so forth.
2313 The package is designed for structured documents,
2314 consisting of paragraphs interspersed with headings
2315 and augmented by lists, footnotes, tables, and other
2316 common constructs.
2317 @xref{ms Body Text}, for more details.
2319 @item Table of contents
2320 Longer documents usually include a table of contents,
2321 which you can invoke by placing the
2322 @code{TC}
2323 macro at the end of your document.
2324 The @file{ms}
2325 macros have minimal indexing facilities, consisting of the
2326 @code{IX} macro, which prints an entry on standard error.
2327 Printing the table of contents at the end is necessary since
2328 @code{groff} is a single-pass text formatter,
2329 thus it cannot determine the page number of each section
2330 until that section has actually been set and printed.
2331 Since @file{ms} output is intended for hardcopy,
2332 you can manually relocate the pages containing
2333 the table of contents between the cover page and the
2334 body text after printing.
2335 @end table
2337 @c ---------------------------------------------------------------------
2339 @node ms Document Control Registers, ms Cover Page Macros, General ms Structure, ms
2340 @subsection Document control registers
2341 @cindex @code{ms} macros, document control registers
2343 The following is a list of document control number registers.
2344 For the sake of consistency,
2345 set registers related to margins at the beginning of your document,
2346 or just after the @code{RP} macro.
2347 You can set other registers later in your document,
2348 but you should keep them together at the beginning
2349 to make them easy to find and edit as necessary.
2351 @unnumberedsubsubsec Margin Settings
2353 @Defmpreg {PO, ms}
2354 Defines the page offset (i.e.@: the left margin).
2355 There is no explicit right margin setting; the combination of
2356 the @code{PO} and @code{LL} registers implicitly define the
2357 right margin width.
2359 Effective: next page.
2361 Default value: 1@dmn{i}.
2362 @endDefmpreg
2364 @Defmpreg {LL, ms}
2365 Defines the line length (i.e.@: the width of the body text).
2367 Effective: next paragraph.
2369 Default: 6@dmn{i}.
2370 @endDefmpreg
2372 @Defmpreg {LT, ms}
2373 Defines the title length (i.e.@: the header and footer width).
2374 This is usually the same as @code{LL}, but not necessarily.
2376 Effective: next paragraph.
2378 Default: 6@dmn{i}.
2379 @endDefmpreg
2381 @Defmpreg {HM, ms}
2382 Defines the header margin height at the top of the page.
2384 Effective: next page.
2386 Default: 1@dmn{i}.
2387 @endDefmpreg
2389 @Defmpreg {FM, ms}
2390 Defines the footer margin height at the bottom of the page.
2392 Effective: next page.
2394 Default: 1@dmn{i}.
2395 @endDefmpreg
2397 @unnumberedsubsubsec Text Settings
2399 @Defmpreg {PS, ms}
2400 Defines the point size of the body text.
2402 Effective: next paragraph.
2404 Default: 10@dmn{p}.
2405 @endDefmpreg
2407 @Defmpreg {VS, ms}
2408 Defines the space between lines (line height plus leading).
2410 Effective: next paragraph.
2412 Default: 12@dmn{p}.
2413 @endDefmpreg
2415 @unnumberedsubsubsec Paragraph Settings
2417 @Defmpreg {PI, ms}
2418 Defines the initial indent of a @code{.PP} paragraph.
2420 Effective: next paragraph.
2422 Default: 5@dmn{n}.
2423 @endDefmpreg
2425 @Defmpreg {PD, ms}
2426 Defines the space between paragraphs.
2428 Effective: next paragraph.
2430 Default: 0.3@dmn{v}.
2431 @endDefmpreg
2433 @Defmpreg {QI, ms}
2434 Defines the indent on both sides of a quoted (@code{.QP}) paragraph.
2436 Effective: next paragraph.
2438 Default: 5@dmn{n}.
2439 @endDefmpreg
2441 @unnumberedsubsubsec Footnote Settings
2443 @Defmpreg {FL, ms}
2444 Defines the length of a footnote.
2446 Effective: next footnote.
2448 Default: @math{@code{@\n[LL]} * 5 / 6}.
2449 @endDefmpreg
2451 @Defmpreg {FI, ms}
2452 Defines the footnote indent.
2454 Effective: next footnote.
2456 Default: 2@dmn{n}.
2457 @endDefmpreg
2459 @Defmpreg {FF, ms}
2460 The footnote format:
2461 @table @code
2462 @item 0
2463 Prints the footnote number as a superscript; indents the footnote (default).
2465 @item 1
2466 Prints the number followed by a period (like 1.)
2467 and indents the footnote.
2469 @item 2
2470 Like 1, without an indent.
2472 @item 3
2473 Like 1, but prints the footnote number as a hanging paragraph.
2474 @end table
2476 Effective: next footnote.
2478 Default: 0.
2479 @endDefmpreg
2481 @unnumberedsubsubsec Miscellaneous Number Registers
2483 @Defmpreg {MINGW, ms}
2484 Defines the minimum width between columns in a multi-column document.
2486 Effective: next page.
2488 Default: 2@dmn{n}.
2489 @endDefmpreg
2491 @c ---------------------------------------------------------------------
2493 @node ms Cover Page Macros, ms Body Text, ms Document Control Registers, ms
2494 @subsection Cover page macros
2495 @cindex @code{ms} macros, cover page
2496 @cindex cover page macros, [@code{ms}]
2498 Use the following macros to create a cover page for your document
2499 in the order shown.
2501 @Defmac {RP, [@code{no}], ms}
2502 Specifies the report format for your document.
2503 The report format creates a separate cover page.
2504 The default action (no @code{.RP}
2505 macro) is to print a subset of the
2506 cover page on page 1 of your document.
2508 If you use the word @code{no} as an optional argument,
2509 @code{groff} prints a title page but
2510 does not repeat any of the title page information
2511 (title, author, abstract, etc.)
2512 on page 1 of the document.
2513 @endDefmac
2515 @Defmac {DA, [@dots{}], ms}
2516 (optional) Print the current date, or the arguments to the macro if any,
2517 on the title page (if specified) and in the footers.
2518 This is the default for @code{nroff}.
2519 @endDefmac
2521 @Defmac {ND, [@dots{}], ms}
2522 (optional) Print the current date, or the arguments to the macro if any,
2523 on the title page (if specified) but not in the footers.
2524 This is the default for @code{troff}.
2525 @endDefmac
2527 @Defmac {TL, , ms}
2528 Specifies the document title.
2529 @code{groff} collects text following the @code{.TL}
2530 macro into the title, until reaching the author name or abstract.
2531 @endDefmac
2533 @Defmac {AU, , ms}
2534 Specifies the author's name, which appears on the
2535 line (or lines) immediately following.
2536 You can specify multiple authors as follows:
2538 @Example
2540 John Doe
2542 University of West Bumblefuzz
2544 Martha Buck
2546 Monolithic Corporation
2549 @endExample
2550 @endDefmac
2552 @Defmac {AI, , ms}
2553 Specifies the author's institution.
2554 You can specify multiple institutions in the same way
2555 that you specify multiple authors.
2556 @endDefmac
2558 @Defmac {AB, [@code{no}], ms}
2559 Begins the abstract.
2560 The default is to print the word @acronym{ABSTRACT},
2561 centered and in italics, above the text of the abstract.
2562 The word @code{no} as an optional argument suppresses this heading.
2563 @endDefmac
2565 @Defmac {AE, , ms}
2566 End the abstract.
2567 @endDefmac
2569 The following is example mark-up for a title page.
2570 @cindex title page, example markup
2571 @cindex example markup, title page
2573 @Example
2574 @cartouche
2577 The Inevitability of Code Bloat
2578 in Commercial and Free Software
2580 J. Random Luser
2582 University of West Bumblefuzz
2584 This report examines the long-term growth
2585 of the code bases in two large, popular software
2586 packages; the free Emacs and the commercial
2587 Microsoft Word.
2588 While differences appear in the type or order
2589 of features added, due to the different
2590 methodologies used, the results are the same
2591 in the end.
2593 The free software approach is shown to be
2594 superior in that while free software can
2595 become as bloated as commercial offerings,
2596 free software tends to have fewer serious
2597 bugs and the added features are in line with
2598 user demand.
2601 ... the rest of the paper follows ...
2602 @end cartouche
2603 @endExample
2605 @c ---------------------------------------------------------------------
2607 @node ms Body Text, ms Page Layout, ms Cover Page Macros, ms
2608 @subsection Body text
2609 @cindex @code{ms} macros, body text
2611 This section describes macros used to mark up the body of your document.
2612 Examples include paragraphs, sections, and other groups.
2614 @menu
2615 * Paragraphs in ms::
2616 * Headings in ms::
2617 * Highlighting in ms::
2618 * Lists in ms::
2619 * Indents in ms::
2620 * Tabstops in ms::
2621 * ms Displays and Keeps::
2622 * ms Insertions::
2623 * Example multi-page table::
2624 * ms Footnotes::
2625 @end menu
2627 @c ---------------------------------------------------------------------
2629 @node Paragraphs in ms, Headings in ms, ms Body Text, ms Body Text
2630 @subsubsection Paragraphs
2631 @cindex @code{ms} macros, paragraph handling
2633 The following paragraph types are available.
2635 @Defmac {PP, , ms}
2636 Sets a paragraph with an initial indent.
2637 @endDefmac
2639 @Defmac {LP, , ms}
2640 Sets a paragraph with no initial indent.
2641 @endDefmac
2643 @Defmac {QP, , ms}
2644 Sets a paragraph that is indented at both left and right margins.
2645 The effect is identical to the @acronym{HTML} @code{<BLOCKQUOTE>} element.
2646 The next paragraph or heading returns margins to normal.
2647 @endDefmac
2649 @Defmac {XP, , ms}
2650 Sets a paragraph whose lines are indented,
2651 except for the first line.
2652 This is a Berkeley extension.
2653 @endDefmac
2655 The following markup uses all four paragraph macros.
2657 @Example
2658 @cartouche
2659 .NH 2
2660 Cases used in the study
2662 The following software and versions were
2663 considered for this report.
2665 For commercial software, we chose
2666 .B "Microsoft Word for Windows" ,
2667 starting with version 1.0 through the
2668 current version (Word 2000).
2670 For free software, we chose
2671 .B Emacs ,
2672 from its first appearance as a standalone
2673 editor through the current version (v20).
2674 See [Bloggs 2002] for details.
2676 Franklin's Law applied to software:
2677 software expands to outgrow both
2678 RAM and disk space over time.
2680 Bibliography:
2682 Bloggs, Joseph R.,
2683 .I "Everyone's a Critic" ,
2684 Underground Press, March 2002.
2685 A definitive work that answers all questions
2686 and criticisms about the quality and usability of
2687 free software.
2689 @end cartouche
2690 @endExample
2692 @c ---------------------------------------------------------------------
2694 @node Headings in ms, Highlighting in ms, Paragraphs in ms, ms Body Text
2695 @subsubsection Headings
2696 @cindex @code{ms} macros, headings
2698 Use headings to create a hierarchical structure for your document.
2699 The @file{ms} macros print headings in @strong{bold},
2700 using the same font family and point size as the body text.
2702 The following describes the heading macros:
2704 @DefmacList {NH, @Var{curr-level}, ms}
2705 @DefmacListEnd {NH, @t{S} @Var{level0} @dots{}, ms}
2706 Numbered heading.
2707 The argument is either a numeric argument to indicate the
2708 level of the heading, or the letter@w{ }@code{S} followed by numeric
2709 arguments to set the heading level explicitly.
2711 If you specify heading levels out of sequence, such as invoking
2712 @samp{.NH 3} after @samp{.NH 1}, @code{groff}
2713 prints a warning on standard error.
2714 @endDefmac
2716 @Defmac {SH, , ms}
2717 Unnumbered subheading.
2718 @endDefmac
2720 @c ---------------------------------------------------------------------
2722 @node Highlighting in ms, Lists in ms, Headings in ms, ms Body Text
2723 @subsubsection Highlighting
2724 @cindex @code{ms} macros, highlighting
2726 The @file{ms} macros provide a variety of methods to highlight
2727 or emphasize text:
2729 @Defmac {B, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
2730 Sets its first argument in @strong{bold type}.
2731 If you specify a second argument, @code{groff} prints it in the
2732 previous font after the bold text, with no intervening space
2733 (this allows you to set punctuation after the highlighted text
2734 without highlighting the punctuation).
2735 Similarly, it prints the third argument (if any) in the previous
2736 font @strong{before} the first argument.
2737 For example,
2739 @Example
2740 .B foo ) (
2741 @endExample
2743 prints (@strong{foo}).
2745 If you give this macro no arguments, @code{groff}
2746 prints all text following in bold until
2747 the next highlighting, paragraph, or heading macro.
2748 @endDefmac
2750 @Defmac {R, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
2751 Sets its first argument in roman (or regular) type.
2752 It operates similarly to the @code{B}@w{ }macro otherwise.
2753 @endDefmac
2755 @Defmac {I, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
2756 Sets its first argument in @emph{italic type}.
2757 It operates similarly to the @code{B}@w{ }macro otherwise.
2758 @endDefmac
2760 @Defmac {CW, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
2761 Sets its first argument in a @code{constant width face}.
2762 It operates similarly to the @code{B}@w{ }macro otherwise.
2763 @endDefmac
2765 @Defmac {BI, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
2766 Sets its first argument in bold italic type.
2767 It operates similarly to the @code{B}@w{ }macro otherwise.
2768 @endDefmac
2770 @Defmac {BX, [@Var{txt}], ms}
2771 Prints its argument and draws a box around it.
2772 If you want to box a string that contains spaces,
2773 use a digit-width space (@code{\0}).
2774 @endDefmac
2776 @Defmac {UL, [@Var{txt} [@Var{post}]], ms}
2777 Prints its first argument with an underline.
2778 If you specify a second argument, @code{groff}
2779 prints it in the previous font after
2780 the underlined text, with no intervening space.
2781 @endDefmac
2783 @Defmac {LG, , ms}
2784 Prints all text following in larger type
2785 (two points larger than the current point size) until
2786 the next font size, highlighting, paragraph, or heading macro.
2787 You can specify this macro multiple times
2788 to enlarge the point size as needed.
2789 @endDefmac
2791 @Defmac {SM, , ms}
2792 Prints all text following in smaller type
2793 (two points smaller than the current point size) until
2794 the next type size, highlighting, paragraph, or heading macro.
2795 You can specify this macro multiple times
2796 to reduce the point size as needed.
2797 @endDefmac
2799 @Defmac {NL, , ms}
2800 Prints all text following in the normal point size
2801 (that is, the value of the @code{PS} register).
2802 @endDefmac
2804 @c ---------------------------------------------------------------------
2806 @node Lists in ms, Indents in ms, Highlighting in ms, ms Body Text
2807 @subsubsection Lists
2808 @cindex @code{ms} macros, lists
2810 The @code{.IP} macro handles duties for all lists.
2812 @Defmac {IP, [@Var{marker} [@Var{width}]], ms}
2813 The @var{marker} is usually a bullet glyph (@code{\[bu]})
2814 for unordered lists, a number (or auto-incrementing number
2815 register) for numbered lists, or a word or phrase for indented
2816 (glossary-style) lists.
2818 The @var{width} specifies the indent for the body of each list item;
2819 its default unit is @samp{n}.
2820 Once specified, the indent remains the same for all
2821 list items in the document until specified again.
2822 @endDefmac
2824 The following is an example of a bulleted list.
2825 @cindex example markup, bulleted list [@code{ms}]
2826 @cindex bulleted list, example markup [@code{ms}]
2828 @Example
2829 A bulleted list:
2830 .IP \[bu] 2
2831 lawyers
2832 .IP \[bu]
2833 guns
2834 .IP \[bu]
2835 money
2836 @endExample
2838 Produces:
2840 @Example
2841 A bulleted list:
2843 o lawyers
2845 o guns
2847 o money
2848 @endExample
2850 @sp 1
2852 The following is an example of a numbered list.
2853 @cindex example markup, numbered list [@code{ms}]
2854 @cindex numbered list, example markup [@code{ms}]
2856 @Example
2857 .nr step 1 1
2858 A numbered list:
2859 .IP \n[step] 3
2860 lawyers
2861 .IP \n+[step]
2862 guns
2863 .IP \n+[step]
2864 money
2865 @endExample
2867 Produces:
2869 @Example
2870 A numbered list:
2872 1. lawyers
2874 2. guns
2876 3. money
2877 @endExample
2879 Note the use of the auto-incrementing number
2880 register in this example.
2882 @sp 1
2883 The following is an example of a glossary-style list.
2884 @cindex example markup, glossary-style list [@code{ms}]
2885 @cindex glossary-style list, example markup [@code{ms}]
2887 @Example
2888 A glossary-style list:
2889 .IP lawyers 0.4i
2890 Two or more attorneys.
2891 .IP guns
2892 Firearms, preferably
2893 large-caliber.
2894 .IP money
2895 Gotta pay for those
2896 lawyers and guns!
2897 @endExample
2899 Produces:
2901 @Example
2902 A glossary-style list:
2904 lawyers
2905       Two or more attorneys.
2907 guns  Firearms, preferably large-caliber.
2909 money
2910       Gotta pay for those lawyers and guns!
2911 @endExample
2913 In the last example, the @code{IP} macro places the definition
2914 on the same line as the term if it has enough space; otherwise,
2915 it breaks to the next line and starts the definition below the
2916 term.
2917 This may or may not be the effect you want, especially if some
2918 of the definitions break and some do not.
2919 The following examples show two possible ways to force a break.
2921 The first workaround uses the @code{br}
2922 request to force a break after printing the term or label.
2924 @Example
2925 @cartouche
2926 A glossary-style list:
2927 .IP lawyers 0.4i
2928 Two or more attorneys.
2929 .IP guns
2931 Firearms, preferably large-caliber.
2932 .IP money
2933 Gotta pay for those lawyers and guns!
2934 @end cartouche
2935 @endExample
2937 @sp 1
2938 The second workaround uses the @code{\p} escape to force the break.
2939 Note the space following the escape; this is important.
2940 If you omit the space, @code{groff} prints the first word on
2941 the same line as the term or label (if it fits) @strong{then}
2942 breaks the line.
2944 @Example
2945 @cartouche
2946 A glossary-style list:
2947 .IP lawyers 0.4i
2948 Two or more attorneys.
2949 .IP guns
2950 \p Firearms, preferably large-caliber.
2951 .IP money
2952 Gotta pay for those lawyers and guns!
2953 @end cartouche
2954 @endExample
2956 @sp 1
2957 To set nested lists, use the @code{RS} and @code{RE} macros.
2958 @xref{Indents in ms}, for more information.
2959 @cindex @code{ms} macros, nested lists
2960 @cindex nested lists [@code{ms}]
2962 For example:
2964 @Example
2965 @cartouche
2966 .IP \[bu] 2
2967 Lawyers:
2969 .IP \[bu]
2970 Dewey,
2971 .IP \[bu]
2972 Cheatham,
2973 .IP \[bu]
2974 and Howe.
2976 .IP \[bu]
2977 Guns
2978 @end cartouche
2979 @endExample
2981 Produces:
2983 @Example
2984 o Lawyers:
2986   o  Dewey,
2988   o  Cheatham,
2990   o  and Howe.
2992 o Guns
2993 @endExample
2995 @c ---------------------------------------------------------------------
2997 @node Indents in ms, Tabstops in ms, Lists in ms, ms Body Text
2998 @subsubsection Indents
3000 In many situations,
3001 you may need to indent a section of text
3002 while still wrapping and filling.
3003 @xref{Lists in ms},
3004 for an example of nested lists.
3006 @DefmacList {RS, , ms}
3007 @DefmacListEnd {RE, , ms}
3008 These macros begin and end an indented section.
3009 The @code{PI} register controls the amount of indent,
3010 allowing the indented text to line up under hanging
3011 and indented paragraphs.
3012 @endDefmac
3014 @xref{ms Displays and Keeps},
3015 for macros to indent and turn off filling.
3017 @c ---------------------------------------------------------------------
3019 @node Tabstops in ms, ms Displays and Keeps, Indents in ms, ms Body Text
3020 @subsubsection Tab Stops
3022 Use the @code{ta} request to define tab stops as needed.
3023 @xref{Tabs and Fields}.
3025 @Defmac{TA, , ms}
3026 Use this macro to reset the tab stops to the default for @file{ms}
3027 (every 5n).
3028 You can redefine the @code{TA} macro to create a different set
3029 of default tab stops.
3030 @endDefmac
3032 @c ---------------------------------------------------------------------
3034 @node ms Displays and Keeps, ms Insertions, Tabstops in ms, ms Body Text
3035 @subsubsection Displays and keeps
3036 @cindex @code{ms} macros, displays
3037 @cindex @code{ms} macros, keeps
3038 @cindex keeps [@code{ms}]
3039 @cindex displays [@code{ms}]
3041 Use displays to show text-based examples or figures
3042 (such as code listings).
3044 Displays turn off filling, so lines of code are displayed
3045 as-is without inserting @code{br} requests in between each line.
3046 Displays can be @dfn{kept} on a single page, or allowed
3047 to break across pages.
3049 @DefmacList {DS, @t{L}, ms}
3050 @DefmacItem {LD, , ms}
3051 @DefmacListEnd {DE, , ms}
3052 Left-justified display.
3053 The @samp{.DS L} call generates a page break, if necessary,
3054 to keep the entire display on one page.
3055 The @code{LD} macro allows the display to break across pages.
3056 The @code{DE} macro ends the display.
3057 @endDefmac
3059 @DefmacList {DS, @t{I}, ms}
3060 @DefmacItem {ID, , ms}
3061 @DefmacListEnd {DE, , ms}
3062 Indents the display as defined by the @code{DI} register.
3063 The @samp{.DS I} call generates a page break, if necessary,
3064 to keep the entire display on one page.
3065 The @code{ID} macro allows the display to break across pages.
3066 The @code{DE} macro ends the display.
3067 @endDefmac
3069 @DefmacList {DS, @t{B}, ms}
3070 @DefmacItem {BD, , ms}
3071 @DefmacListEnd {DE, , ms}
3072 Sets a block-centered display: the entire display is left-justified,
3073 but indented so that the longest line in the display is centered
3074 on the page.
3075 The @samp{.DS B} call generates a page break, if necessary,
3076 to keep the entire display on one page.
3077 The @code{BD} macro allows the display to break across pages.
3078 The @code{DE} macro ends the display.
3079 @endDefmac
3081 @DefmacList {DS, @t{C}, ms}
3082 @DefmacItem {CD, , ms}
3083 @DefmacListEnd {DE, , ms}
3084 Sets a centered display: each line in the display is centered.
3085 The @samp{.DS C} call generates a page break, if necessary,
3086 to keep the entire display on one page.
3087 The @code{CD} macro allows the display to break across pages.
3088 The @code{DE} macro ends the display.
3089 @endDefmac
3091 @DefmacList {DS, @t{R}, ms}
3092 @DefmacItem {RD, , ms}
3093 @DefmacListEnd {DE, , ms}
3094 Right-justifies each line in the display.
3095 The @samp{.DS R} call generates a page break, if necessary,
3096 to keep the entire display on one page.
3097 The @code{RD} macro allows the display to break across pages.
3098 The @code{DE} macro ends the display.
3099 @endDefmac
3101 @sp 1
3102 On occasion, you may want to @dfn{keep} other text together on a page.
3103 For example, you may want to keep two paragraphs together, or
3104 a paragraph that refers to a table (or list, or other item)
3105 immediately following.
3106 The @file{ms} macros provide the @code{KS} and @code{KE}
3107 macros for this purpose.
3109 @DefmacList {KS, , ms}
3110 @DefmacListEnd {KE, , ms}
3111 The @code{KS} macro begins a block of text to be kept on a
3112 single page, and the @code{KE} macro ends the block.
3113 @endDefmac
3115 @DefmacList {KF, , ms}
3116 @DefmacListEnd {KE, , ms}
3117 Specifies a @dfn{floating keep};
3118 if the keep cannot fit on the current page, @code{groff}
3119 holds the contents of the keep and allows text following
3120 the keep (in the source file) to fill in the remainder of
3121 the current page.
3122 When the page breaks, whether by an explicit @code{bp}
3123 request or by reaching the end of the page, @code{groff}
3124 prints the floating keep at the top of the new page.
3125 This is useful for printing large graphics or tables
3126 that do not need to appear exactly where specified.
3127 @endDefmac
3129 You can also use the @code{ne} request to force a page break if
3130 there is not enough vertical space remaining on the page.
3132 @sp 1
3133 Use the following macros to draw a box around a section of
3134 text (such as a display).
3136 @DefmacList {B1, , ms}
3137 @DefmacListEnd {B2, , ms}
3138 Marks the beginning and ending of text that is to have a
3139 box drawn around it.
3140 The @code{B1} macro begins the box; the @code{B2} macro ends it.
3141 Text in the box is automatically placed in a diversion (keep).
3142 @endDefmac
3144 @c ---------------------------------------------------------------------
3146 @node ms Insertions, Example multi-page table, ms Displays and Keeps, ms Body Text
3147 @subsubsection Tables, figures, equations, and references
3148 @cindex @code{ms} macros, tables
3149 @cindex @code{ms} macros, figures
3150 @cindex @code{ms} macros, equations
3151 @cindex @code{ms} macros, references
3152 @cindex tables [@code{ms}]
3153 @cindex figures [@code{ms}]
3154 @cindex equations [@code{ms}]
3155 @cindex references [@code{ms}]
3157 The @file{ms} macros support the standard
3158 @code{groff} preprocessors:
3159 @code{tbl}, @code{pic}, @code{eqn}, and @code{refer}.
3160 @pindex tbl
3161 @pindex pic
3162 @pindex eqn
3163 @pindex refer
3164 You mark text meant for preprocessors by enclosing it
3165 in pairs of tags as follows.
3167 @DefmacList {TS, [@code{H}], ms}
3168 @DefmacListEnd {TE, , ms}
3169 Denotes a table, to be processed by the @code{tbl} preprocessor.
3170 The optional argument@w{ }@code{H} to @code{TS} instructs @code{groff}
3171 to create a running header with the information
3172 up to the @code{TH} macro.
3173 @code{groff} prints the header at the beginning of the
3174 table; if the table runs onto another page, @code{groff}
3175 prints the header on the next page as well.
3176 @endDefmac
3178 @DefmacList {PS, , ms}
3179 @DefmacListEnd {PE, , ms}
3180 Denotes a graphic, to be processed by the @code{pic} preprocessor.
3181 You can create a @code{pic} file by hand, using the @acronym{AT&T}
3182 @code{pic} manual available on the Web as a reference, or by using
3183 a graphics program such as @code{xfig}.
3184 @endDefmac
3186 @DefmacList {EQ, [@Var{align}], ms}
3187 @DefmacListEnd {EN, , ms}
3188 Denotes an equation, to be processed by the @code{eqn} preprocessor.
3189 The optional @var{align} argument can be @code{C}, @code{L}, or@w{
3190 }@code{I} to center (the default), left-justify, or indent the equation.
3191 @endDefmac
3193 @DefmacList {[, , ms}
3194 @DefmacListEnd {], , ms}
3195 Denotes a reference, to be processed by the @code{refer} preprocessor.
3196 The @acronym{GNU} @cite{refer(1)} man page provides a comprehensive
3197 reference to the preprocessor and the format of the bibliographic
3198 database.
3199 @endDefmac
3201 @menu
3202 * Example multi-page table::
3203 @end menu
3205 @c ---------------------------------------------------------------------
3207 @node Example multi-page table, ms Footnotes, ms Insertions, ms Body Text
3208 @subsubsection An example multi-page table
3209 @cindex example markup, multi-page table [@code{ms}]
3210 @cindex multi-page table, example markup [@code{ms}]
3212 The following is an example of how to set up a
3213 table that may print across two or more pages.
3215 @Example
3216 @cartouche
3217 .TS H
3218 allbox expand;
3219 cb | cb .
3220 Text      ...of heading...
3224 l | l .
3225 ... the rest of the table follows...
3228 @end cartouche
3229 @endExample
3231 @c ---------------------------------------------------------------------
3233 @node ms Footnotes,  , Example multi-page table, ms Body Text
3234 @subsubsection Footnotes
3235 @cindex @code{ms} macros, footnotes
3236 @cindex footnotes [@code{ms}]
3238 The @file{ms} macro package has a flexible footnote system.
3239 You can specify either numbered footnotes or symbolic footnotes
3240 (that is, using a marker such as a dagger symbol).
3242 @Defstr {*, ms}
3243 Specifies the location of a numbered footnote marker in the text.
3244 @endDefesc
3246 @DefmacList {FS, , ms}
3247 @DefmacListEnd {FE, , ms}
3248 Specifies the text of the footnote.
3249 The default action is to create a numbered footnote;
3250 you can create a symbolic footnote by specifying
3251 a @dfn{mark} glyph
3252 (such as @code{\[dg]} for the dagger glyph)
3253 in the body text and as an argument to the @code{FS} macro,
3254 followed by the text of the footnote
3255 and the @code{FE} macro.
3256 @endDefmac
3258 You can control how @code{groff}
3259 prints footnote numbers by changing the value of the
3260 @code{FF} register.  @xref{ms Document Control Registers}.
3262 @c ---------------------------------------------------------------------
3264 @node ms Page Layout, Differences from AT&T ms, ms Body Text, ms
3265 @subsection Page layout
3266 @cindex @code{ms} macros, page layout
3267 @cindex page layout [@code{ms}]
3269 The default output from the @file{ms}
3270 macros provides a minimalist page layout:
3271 it prints a single column, with the page number centered at the top
3272 of each page.
3273 It prints no footers.
3275 You can change the layout by setting
3276 the proper number registers and strings.
3278 @menu
3279 * ms Headers and Footers::
3280 * ms Margins::
3281 * ms Multiple Columns::
3282 * ms TOC::
3283 * ms Strings and Special Characters::
3284 @end menu
3286 @c ---------------------------------------------------------------------
3288 @node ms Headers and Footers, ms Margins, ms Page Layout, ms Page Layout
3289 @subsubsection Headers and footers
3290 @cindex @code{ms} macros, headers
3291 @cindex @code{ms} macros, footers
3292 @cindex headers [@code{ms}]
3293 @cindex footers [@code{ms}]
3295 For documents that do not distinguish between odd and even pages,
3296 set the following strings:
3298 @DefstrList {LH, ms}
3299 @DefstrItem {CH, ms}
3300 @DefstrListEnd {RH, ms}
3301 Sets the left, center, and right headers.
3302 @endDefstr
3304 @DefstrList {LF, ms}
3305 @DefstrItem {CF, ms}
3306 @DefstrListEnd {RF, ms}
3307 Sets the left, center, and right footers.
3308 @endDefstr
3310 @sp 1
3311 For documents that need different information printed in the
3312 even and odd pages, use the following macros:
3314 @DefmacList {OH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3315 @DefmacItem {EH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3316 @DefmacItem {OF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3317 @DefmacListEnd {EF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3318 The @code{OH} and @code{EH} macros define headers for the odd and even pages;
3319 the @code{OF} and @code{EF} macros define footers for the odd and even pages.
3320 This is more flexible than defining the individual strings.
3322 You can replace the quote (@code{'}) marks with any character not
3323 appearing in the header or footer text.
3324 @endDefmac
3326 @c ---------------------------------------------------------------------
3328 @node ms Margins, ms Multiple Columns, ms Headers and Footers, ms Page Layout
3329 @subsubsection Margins
3330 @cindex @code{ms} macros, margins
3332 You control margins using a set of number registers.
3333 @xref{ms Document Control Registers}, for details.
3335 @c ---------------------------------------------------------------------
3337 @node ms Multiple Columns, ms TOC, ms Margins, ms Page Layout
3338 @subsubsection Multiple columns
3339 @cindex @code{ms} macros, multiple columns
3340 @cindex multiple columns [@code{ms}]
3342 The @file{ms} macros can set text in as many columns as will
3343 reasonably fit on the page.
3344 The following macros are available;
3345 all of them force a page break if a multi-column mode is already set.
3346 However, if the current mode is single-column, starting a multi-column
3347 mode does @strong{not} force a page break.
3349 @Defmac {1C, , ms}
3350 Single-column mode.
3351 @endDefmac
3353 @Defmac {2C, , ms}
3354 Two-column mode.
3355 @endDefmac
3357 @Defmac {MC, [@Var{width} [@Var{gutter}]], ms}
3358 Multi-column mode.
3359 If you specify no arguments, it is equivalent to the
3360 @code{2C} macro.
3361 Otherwise, @var{width} is the width of each column and
3362 @var{gutter} is the space between columns.
3363 The @code{MINGW} number register controls the default gutter width.
3364 @endDefmac
3366 @c ---------------------------------------------------------------------
3368 @node ms TOC, ms Strings and Special Characters, ms Multiple Columns, ms Page Layout
3369 @subsubsection Creating a table of contents
3370 @cindex @code{ms} macros, creating table of contents
3371 @cindex table of contents, creating [@code{ms}]
3373 The facilities in the @file{ms} macro package for creating
3374 a table of contents are semi-automated at best.
3375 Assuming that you want the table of contents to consist of
3376 the document's headings, you need to repeat those headings
3377 wrapped in @code{XS} and @code{XE} macros.
3379 @DefmacList {XS, [@Var{page}], ms}
3380 @DefmacItem {XA, [@Var{page}], ms}
3381 @DefmacListEnd {XE, , ms}
3382 These macros define a table of contents
3383 or an individual entry in the table of contents,
3384 depending on their use.
3385 The macros are very simple; they cannot indent a heading based on its level.
3386 The easiest way to work around this is to add tabs
3387 to the table of contents string.
3388 The following is an example:
3390 @Example
3391 @cartouche
3392 .NH 1
3393 Introduction
3395 Introduction
3400 .NH 2
3401 Methodology
3403         Methodology
3407 @end cartouche
3408 @endExample
3410 You can manually create a table of contents
3411 by beginning with the @code{XS} macro for the first entry,
3412 specifying the page number for that entry as the argument to @code{XS}.
3413 Add subsequent entries using the @code{XA} macro,
3414 specifying the page number for that entry as the argument to @code{XA}.
3415 The following is an example:
3417 @Example
3418 @cartouche
3419 .XS 1
3420 Introduction
3421 .XA 2
3422 A Brief History of the Universe
3423 .XA 729
3424 Details of Galactic Formation
3427 @end cartouche
3428 @endExample
3429 @endDefmac
3431 @Defmac {TC, [@code{no}], ms}
3432 Prints the table of contents on a new page,
3433 setting the page number to@w{ }@strong{i} (Roman numeral one).
3434 You should usually place this macro at the end of the
3435 file, since @code{groff} is a single-pass formatter and
3436 can only print what has been collected up to the point
3437 that the @code{TC} macro appears.
3439 The optional argument @code{no} suppresses printing
3440 the title specified by the string register @code{TOC}.
3441 @endDefmac
3443 @Defmac{PX, [@code{no}], ms}
3444 Prints the table of contents on a new page,
3445 using the current page numbering sequence.
3446 Use this macro to print a manually-generated table of contents
3447 at the beginning of your document.
3449 The optional argument @code{no} suppresses printing
3450 the title specified by the string register @code{TOC}.
3451 @endDefmac
3453 The @cite{Groff and Friends HOWTO}
3454 includes a @code{sed} script that automatically inserts
3455 @code{XS} and @code{XE} macro entries after each heading in a document.
3457 Altering the @code{NH} macro to automatically build the table
3458 of contents is perhaps initially more difficult, but would save
3459 a great deal of time in the long run if you use @file{ms} regularly.
3461 @c ---------------------------------------------------------------------
3463 @node ms Strings and Special Characters,  , ms TOC, ms Page Layout
3464 @subsubsection Strings and Special Characters
3465 @cindex @code{ms} macros, strings
3466 @cindex @code{ms} macros, special characters
3467 @cindex @code{ms} macros, accent marks
3468 @cindex accent marks [@code{ms}]
3469 @cindex special characters [@code{ms}]
3470 @cindex strings [@code{ms}]
3472 The @file{ms} macros provide the following predefined strings.
3473 You can change the string definitions to help in creating
3474 documents in languages other than English.
3476 @Defstr {REFERENCES, ms}
3477 Contains the string printed at the beginning of the
3478 references (bibliography) page.
3479 The default is @samp{References}.
3480 @endDefstr
3482 @Defstr {ABSTRACT, ms}
3483 Contains the string printed at the beginning of the abstract.
3484 The default is @samp{ABSTRACT}.
3485 @endDefstr
3487 @Defstr {TOC, ms}
3488 Contains the string printed at the beginning of the table of contents.
3489 @endDefstr
3491 @DefstrList {MONTH1, ms}
3492 @DefstrItem {MONTH2, ms}
3493 @DefstrItem {MONTH3, ms}
3494 @DefstrItem {MONTH4, ms}
3495 @DefstrItem {MONTH5, ms}
3496 @DefstrItem {MONTH6, ms}
3497 @DefstrItem {MONTH7, ms}
3498 @DefstrItem {MONTH8, ms}
3499 @DefstrItem {MONTH9, ms}
3500 @DefstrItem {MONTH10, ms}
3501 @DefstrItem {MONTH11, ms}
3502 @DefstrListEnd {MONTH12, ms}
3503 Prints the full name of the month in dates.
3504 The default is @samp{January}, @samp{February}, etc.
3505 @endDefstr
3507 The following special characters are available@footnote{For an
3508 explanation what special characters are see @ref{Special Characters}.}:
3510 @Defstr {-, ms}
3511 Prints an em dash.
3512 @endDefstr
3514 @DefstrList {*Q, ms}
3515 @DefstrListEnd {*U, ms}
3516 Prints typographer's quotes in troff,
3517 plain quotes in nroff.
3518 @code{*Q} is the left quote and @code{*U} is the right quote.
3519 @endDefstr
3521 Improved accent marks are available in the @file{ms} macros.
3523 @Defmac {AM, , ms}
3524 Specify this macro at the beginning of your document
3525 to enable extended accent marks and special characters.
3526 This is a Berkeley extension.
3528 To use the accent marks, place them @strong{after}
3529 the character being accented.
3530 @endDefmac
3532 The following accent marks are available
3533 after invoking the @code{AM} macro:
3535 @Defstr {\', ms}
3536 Acute accent.
3537 @endDefstr
3539 @Defstr {\`, ms}
3540 Grave accent.
3541 @endDefstr
3543 @Defstr {^, ms}
3544 Circumflex.
3545 @endDefstr
3547 @Defstr {\,, ms}
3548 Cedilla.
3549 @endDefstr
3551 @Defstr {~, ms}
3552 Tilde.
3553 @endDefstr
3555 @deffn String @t{\*[:]}
3556 @ifnotinfo
3557 @stindex : @r{[}ms@r{]}
3558 @end ifnotinfo
3559 @ifinfo
3560 @stindex @r{<colon>} @r{[}ms@r{]}
3561 @end ifinfo
3562 Umlaut.
3563 @end deffn
3565 @Defstr {v, ms}
3566 Hacek.
3567 @endDefstr
3569 @Defstr {_, ms}
3570 Macron (overbar).
3571 @endDefstr
3573 @Defstr {., ms}
3574 Underdot.
3575 @endDefstr
3577 @Defstr {o, ms}
3578 Ring above.
3579 @endDefstr
3581 The following are standalone characters
3582 available after invoking the @code{AM} macro:
3584 @Defstr {?, ms}
3585 Upside-down question mark.
3586 @endDefstr
3588 @Defstr {!, ms}
3589 Upside-down exclamation point.
3590 @endDefstr
3592 @Defstr {8, ms}
3593 German @ss{} ligature.
3594 @endDefstr
3596 @Defstr {3, ms}
3597 Yogh.
3598 @endDefstr
3600 @Defstr {Th, ms}
3601 Uppercase thorn.
3602 @endDefstr
3604 @Defstr {th, ms}
3605 Lowercase thorn.
3606 @endDefstr
3608 @Defstr {D-, ms}
3609 Uppercase eth.
3610 @endDefstr
3612 @Defstr {d-, ms}
3613 Lowercase eth.
3614 @endDefstr
3616 @Defstr {q, ms}
3617 Hooked o.
3618 @endDefstr
3620 @Defstr {ae, ms}
3621 Lowercase @ae{} ligature.
3622 @endDefstr
3624 @Defstr {Ae, ms}
3625 Uppercase @AE{} ligature.
3626 @endDefstr
3628 @c ---------------------------------------------------------------------
3630 @node Differences from AT&T ms,  , ms Page Layout, ms
3631 @subsection Differences from @acronym{AT&T} @file{ms}
3632 @cindex @code{ms} macros, differences from @acronym{AT&T}
3633 @cindex @acronym{AT&T} @code{troff}, @code{ms} macro package differences
3635 This section lists the (minor) differences between the
3636 @code{groff -ms} macros and @acronym{AT&T}
3637 @code{troff -ms} macros.
3639 @menu
3640 * Missing ms Macros::
3641 * Additional ms Macros::
3642 @end menu
3644 @c ---------------------------------------------------------------------
3646 @node Missing ms Macros, Additional ms Macros, Differences from AT&T ms, Differences from AT&T ms
3647 @subsubsection @code{troff} macros not appearing in @code{groff}
3649 Macros missing from @code{groff -ms}
3650 are cover page macros specific to Bell Labs.
3651 The macros known to be missing are:
3653 @table @code
3654 @item .TM
3655 Technical memorandum; a cover sheet style
3657 @item .IM
3658 Internal memorandum; a cover sheet style
3660 @item .MR
3661 Memo for record; a cover sheet style
3663 @item .MF
3664 Memo for file; a cover sheet style
3666 @item .EG
3667 Engineer's notes; a cover sheet style
3669 @item .TR
3670 Computing Science Tech Report; a cover sheet style
3672 @item .OK
3673 Other keywords
3675 @item .CS
3676 Cover sheet information
3678 @item .MH
3679 A cover sheet macro
3680 @end table
3682 @c ---------------------------------------------------------------------
3684 @node Additional ms Macros,  , Missing ms Macros, Differences from AT&T ms
3685 @subsubsection @code{groff} macros not appearing in @acronym{AT&T} @code{troff}
3687 The @code{groff -ms} macros have a few minor extensions
3688 compared to the @acronym{AT&T} @code{troff -ms} macros.
3690 @Defmac {AM, , ms}
3691 Improved accent marks.
3692 @xref{ms Strings and Special Characters}, for details.
3693 @endDefmac
3695 @Defmac {DS, @t{I}, ms}
3696 Indented display.
3697 The default behavior of @acronym{AT&T} @code{troff -ms}
3698 was to indent; the @code{groff} default prints displays
3699 flush left with the body text.
3700 @endDefmac
3702 @Defmac {CW, , ms}
3703 Print text in @code{constant width} (Courier) font.
3704 @endDefmac
3706 @Defmac {IX, , ms}
3707 Indexing term (printed on standard error).
3708 You can write a script to capture and process an index
3709 generated in this manner.
3710 @endDefmac
3712 @sp 1
3713 The following additional number registers
3714 appear in @code{groff -ms}:
3716 @Defmpreg {MINGW, ms}
3717 Specifies a minimum space
3718 between columns (for multi-column output); this takes the
3719 place of the @code{GW} register that was documented but apparently
3720 not implemented in @acronym{AT&T} @code{troff}.
3721 @endDefmpreg
3723 @sp 1
3724 Several new string registers are available as well.
3725 You can change these to handle (for example) the local language.
3726 @xref{ms Strings and Special Characters}, for details.
3729 @c =====================================================================
3731 @node me, mm, ms, Macro Packages
3732 @section @file{me}
3733 @cindex @code{me} macro package
3735 @c XXX documentation
3736 @c XXX this is a placeholder until we get stuff knocked into shape
3737 See the @file{meintro.me} and @file{meref.me} documents in
3738 groff's @file{doc} directory.
3741 @c =====================================================================
3743 @node mm,  , me, Macro Packages
3744 @section @file{mm}
3745 @cindex @code{mm} macro package
3747 @c XXX documentation
3748 @c XXX this is a placeholder until we get stuff knocked into shape
3749 See the @cite{groff_mm(7)} man page (type @command{man groff_mm} at
3750 the command line).
3753 @c =====================================================================
3754 @c =====================================================================
3756 @node gtroff Reference, Preprocessors, Macro Packages, Top
3757 @chapter @code{gtroff} Reference
3758 @cindex reference, @code{gtroff}
3759 @cindex @code{gtroff}, reference
3761 This chapter covers @strong{all} of the facilities of @code{gtroff}.
3762 Users of macro packages may skip it if not interested in details.
3765 @menu
3766 * Text::
3767 * Input Conventions::
3768 * Measurements::
3769 * Expressions::
3770 * Identifiers::
3771 * Embedded Commands::
3772 * Registers::
3773 * Manipulating Filling and Adjusting::
3774 * Manipulating Hyphenation::
3775 * Manipulating Spacing::
3776 * Tabs and Fields::
3777 * Character Translations::
3778 * Troff and Nroff Mode::
3779 * Line Layout::
3780 * Line Control::
3781 * Page Layout::
3782 * Page Control::
3783 * Fonts::
3784 * Sizes::
3785 * Strings::
3786 * Conditionals and Loops::
3787 * Writing Macros::
3788 * Page Motions::
3789 * Drawing Requests::
3790 * Traps::
3791 * Diversions::
3792 * Environments::
3793 * Suppressing output::
3794 * Colors::
3795 * I/O::
3796 * Postprocessor Access::
3797 * Miscellaneous::
3798 * Gtroff Internals::
3799 * Debugging::
3800 * Implementation Differences::
3801 @end menu
3804 @c =====================================================================
3806 @node Text, Input Conventions, gtroff Reference, gtroff Reference
3807 @section Text
3808 @cindex text, @code{gtroff} processing
3810 @code{gtroff} input files contain text with control commands
3811 interspersed throughout.  But, even without control codes, @code{gtroff}
3812 still does several things with the input text:
3814 @itemize @bullet
3815 @item
3816 filling and adjusting
3818 @item
3819 adding additional space after sentences
3821 @item
3822 hyphenating
3824 @item
3825 inserting implicit line breaks
3826 @end itemize
3828 @menu
3829 * Filling and Adjusting::
3830 * Hyphenation::
3831 * Sentences::
3832 * Tab Stops::
3833 * Implicit Line Breaks::
3834 @end menu
3836 @c ---------------------------------------------------------------------
3838 @node Filling and Adjusting, Hyphenation, Text, Text
3839 @subsection Filling and Adjusting
3840 @cindex filling
3841 @cindex adjusting
3843 When @code{gtroff} reads text, it collects words from the input and fits
3844 as many of them together on one output line as it can.  This is known as
3845 @dfn{filling}.
3847 @cindex leading spaces
3848 @cindex spaces, leading and trailing
3849 @cindex extra spaces
3850 @cindex trailing spaces
3851 Once @code{gtroff} has a @dfn{filled} line, it tries to @dfn{adjust}
3852 it.  This means it widens the spacing between words until the text
3853 reaches the right margin (in the default adjustment mode).  Extra spaces
3854 between words are preserved, but spaces at the end of lines are ignored.
3855 Spaces at the front of a line cause a @dfn{break} (breaks are
3856 explained in @ref{Implicit Line Breaks}).
3858 @xref{Manipulating Filling and Adjusting}.
3860 @c ---------------------------------------------------------------------
3862 @node Hyphenation, Sentences, Filling and Adjusting, Text
3863 @subsection Hyphenation
3864 @cindex hyphenation
3866 Since the odds are not great for finding a set of words, for every
3867 output line, which fit nicely on a line without inserting excessive
3868 amounts of space between words, @code{gtroff} hyphenates words so
3869 that it can justify lines without inserting too much space between
3870 words.  It uses an internal hyphenation algorithm (a simplified version
3871 of the algorithm used within @TeX{}) to indicate which words can be
3872 hyphenated and how to do so.  When a word is hyphenated, the first part
3873 of the word is added to the current filled line being output (with
3874 an attached hyphen), and the other portion is added to the next
3875 line to be filled.
3877 @xref{Manipulating Hyphenation}.
3879 @c ---------------------------------------------------------------------
3881 @node Sentences, Tab Stops, Hyphenation, Text
3882 @subsection Sentences
3883 @cindex sentences
3885 Although it is often debated, some typesetting rules say there should be
3886 different amounts of space after various punctuation marks.  For
3887 example, the @cite{Chicago typsetting manual} says that a period at the
3888 end of a sentence should have twice as much space following it as would
3889 a comma or a period as part of an abbreviation.
3891 @c XXX exact citation of Chicago manual
3893 @cindex sentence space
3894 @cindex space between sentences
3895 @cindex french-spacing
3896 @code{gtroff} does this by flagging certain characters (normally
3897 @samp{!}, @samp{?}, and @samp{.}) as @dfn{end-of-sentence} characters.
3898 When @code{gtroff} encounters one of these characters at the end of a
3899 line, it appends a normal space followed by a @dfn{sentence space} in
3900 the formatted output.  (This justifies one of the conventions mentioned
3901 in @ref{Input Conventions}.)
3903 @cindex transparent characters
3904 @cindex character, transparent
3905 @cindex @code{dg} glyph, at end of sentence
3906 @cindex @code{rq} glyph, at end of sentence
3907 @cindex @code{"}, at end of sentence
3908 @cindex @code{'}, at end of sentence
3909 @cindex @code{)}, at end of sentence
3910 @cindex @code{]}, at end of sentence
3911 @cindex @code{*}, at end of sentence
3912 In addition, the following characters and symbols are treated
3913 transparently while handling end-of-sentence characters: @samp{"},
3914 @samp{'}, @samp{)}, @samp{]}, @samp{*}, @code{\[dg]}, and @code{\[rq]}.
3916 See the @code{cflags} request in @ref{Using Symbols}, for more details.
3918 @cindex @code{\&}, at end of sentence
3919 To prevent the insertion of extra space after an end-of-sentence
3920 character (at the end of a line), append @code{\&}.
3922 @c ---------------------------------------------------------------------
3924 @node Tab Stops, Implicit Line Breaks, Sentences, Text
3925 @subsection Tab Stops
3926 @cindex tab stops
3927 @cindex stops, tabulator
3928 @cindex tab character
3929 @cindex character, tabulator
3931 @cindex @acronym{EBCDIC} encoding
3932 @cindex encoding, @acronym{EBCDIC}
3933 @code{gtroff} translates @dfn{tabulator characters}, also called
3934 @dfn{tabs} (normally code point @acronym{ASCII} @code{0x09} or
3935 @acronym{EBCDIC} @code{0x05}), in the input into movements to the next
3936 tabulator stop.  These tab stops are initially located every half inch
3937 across the page.  Using this, simple tables can be made easily.
3938 However, it can often be deceptive as the appearance (and width) of the
3939 text on a terminal and the results from @code{gtroff} can vary greatly.
3941 Also, a possible sticking point is that lines beginning with tab
3942 characters are still filled, again producing unexpected results.
3943 For example, the following input
3945 @multitable {12345678} {12345678} {12345678} {12345678}
3946 @item
3947 @tab 1 @tab 2 @tab 3
3948 @item
3949 @tab   @tab 4 @tab 5
3950 @end multitable
3952 @noindent
3953 produces
3955 @multitable {12345678} {12345678} {12345678} {12345678} {12345678} {12345678} {12345678}
3956 @item
3957 @tab 1 @tab 2 @tab 3 @tab   @tab 4 @tab 5
3958 @end multitable
3960 @xref{Tabs and Fields}.
3962 @c ---------------------------------------------------------------------
3964 @node Implicit Line Breaks,  , Tab Stops, Text
3965 @subsection Implicit Line Breaks
3966 @cindex implicit line breaks
3967 @cindex implicit breaks of lines
3968 @cindex line, implicit breaks
3969 @cindex break, implicit
3970 @cindex line break
3972 An important concept in @code{gtroff} is the @dfn{break}.  When a break
3973 occurs, @code{gtroff} outputs the partially filled line
3974 (unjustified), and resumes collecting and filling text on the next output
3975 line.
3977 @cindex blank line
3978 @cindex empty line
3979 @cindex line, blank
3980 @cindex blank line macro (@code{blm})
3981 There are several ways to cause a break in @code{gtroff}.  A blank
3982 line not only causes a break, but it also outputs a one-line vertical
3983 space (effectively a blank line).  Note that this behaviour can be
3984 modified with the blank line macro request @code{blm}.
3985 @xref{Blank Line Traps}.
3987 @cindex fill mode
3988 @cindex mode, fill
3989 A line that begins with a space causes a break and the space is
3990 output at the beginning of the next line.  Note that this space isn't
3991 adjusted, even in fill mode.
3993 The end of file also causes a break -- otherwise the last line of
3994 the document may vanish!
3996 Certain requests also cause breaks, implicitly or explicitly.  This is
3997 discussed in @ref{Manipulating Filling and Adjusting}.
4000 @c =====================================================================
4002 @node Input Conventions, Measurements, Text, gtroff Reference
4003 @section Input Conventions
4004 @cindex input conventions
4005 @cindex conventions for input
4007 Since @code{gtroff} does filling automatically, it is traditional in
4008 @code{groff} not to try and type things in as nicely formatted
4009 paragraphs.  These are some conventions commonly used when typing
4010 @code{gtroff} text:
4012 @itemize @bullet
4013 @item
4014 Break lines after punctuation, particularly at the end of a sentence
4015 and in other logical places.  Keep separate phrases on lines by
4016 themselves, as entire phrases are often added or deleted when editing.
4018 @item
4019 Try to keep lines less than 40-60@w{ }characters, to allow space for
4020 inserting more text.
4022 @item
4023 Do not try to do any formatting in a @acronym{WYSIWYG} manner (i.e.,
4024 don't try using spaces to get proper indentation).
4025 @end itemize
4028 @c =====================================================================
4030 @node Measurements, Expressions, Input Conventions, gtroff Reference
4031 @section Measurements
4032 @cindex measurements
4034 @cindex units of measurement
4035 @cindex basic unit (@code{u})
4036 @cindex machine unit (@code{u})
4037 @cindex measurement unit
4038 @cindex @code{u} unit
4039 @cindex unit, @code{u}
4040 @code{gtroff} (like many other programs) requires numeric parameters to
4041 specify various measurements.  Most numeric parameters@footnote{those
4042 that specify vertical or horizontal motion or a type size} may have a
4043 @dfn{measurement unit} attached.  These units are specified as a single
4044 character which immediately follows the number or expression.  Each of
4045 these units are understood, by @code{gtroff}, to be a multiple of its
4046 @dfn{basic unit}.  So, whenever a different measurement unit is
4047 specified @code{gtroff} converts this into its @dfn{basic units}.  This
4048 basic unit, represented by a @samp{u}, is a device dependent measurement
4049 which is quite small, ranging from 1/75@dmn{th} to 1/72000@dmn{th} of an
4050 inch.  The values may be given as fractional numbers; however,
4051 fractional basic units are always rounded to integers.
4053 Some of the measurement units are completely independent of any of the
4054 current settings (e.g.@: type size) of @code{gtroff}.
4056 @table @code
4057 @item i
4058 @cindex inch unit (@code{i})
4059 @cindex @code{i} unit
4060 @cindex unit, @code{i}
4061 Inches.  An antiquated measurement unit still in use in certain
4062 backwards countries with incredibly low-cost computer equipment.  One
4063 inch is equal to@w{ }2.54@dmn{cm}.
4065 @item c
4066 @cindex centimeter unit (@code{c})
4067 @cindex @code{c} unit
4068 @cindex unit, @code{c}
4069 Centimeters.  One centimeter is equal to@w{ }0.3937@dmn{in}.
4071 @item p
4072 @cindex point unit (@code{p})
4073 @cindex @code{p} unit
4074 @cindex unit, @code{p}
4075 Points.  This is a typesetter's measurement used for measure type size.
4076 It is 72@w{ }points to an inch.
4078 @item P
4079 @cindex pica unit (@code{P})
4080 @cindex @code{P} unit
4081 @cindex unit, @code{P}
4082 Pica.  Another typesetting measurement.  6@w{ }Picas to an inch (and
4083 12@w{ }points to a pica).
4085 @item s
4086 @itemx z
4087 @cindex @code{s} unit
4088 @cindex unit, @code{s}
4089 @cindex @code{z} unit
4090 @cindex unit, @code{z}
4091 @xref{Fractional Type Sizes}, for a discussion of these units.
4093 @item f
4094 @cindex @code{f} unit
4095 @cindex unit, @code{f}
4096 Fractions. Value is 65536.
4097 @xref{Colors}, for usage.
4098 @end table
4100 The other measurements understood by @code{gtroff} depend on
4101 settings currently in effect in @code{gtroff}.  These are very useful
4102 for specifying measurements which should look proper with any size of
4103 text.
4105 @table @code
4106 @item m
4107 @cindex em unit (@code{m})
4108 @cindex @code{m} unit
4109 @cindex unit, @code{m}
4110 Ems.  This unit is equal to the current font size in points.  So called
4111 because it is @emph{approximately} the width of the letter@w{ }@samp{m}
4112 in the current font.
4114 @item n
4115 @cindex en unit (@code{n})
4116 @cindex @code{n} unit
4117 @cindex unit, @code{n}
4118 Ens.  In @code{groff}, this is half of an em.
4120 @item v
4121 @cindex vertical space unit (@code{v})
4122 @cindex space, vertical, unit (@code{v})
4123 @cindex @code{v} unit
4124 @cindex unit, @code{v}
4125 Vertical space.  This is equivalent to the current line spacing.
4126 @xref{Sizes}, for more information about this.
4128 @item M
4129 @cindex @code{M} unit
4130 @cindex unit, @code{M}
4131 100ths of an em.
4132 @end table
4134 @menu
4135 * Default Units::
4136 @end menu
4138 @c ---------------------------------------------------------------------
4140 @node Default Units,  , Measurements, Measurements
4141 @subsection Default Units
4142 @cindex default units
4143 @cindex units, default
4145 Many requests take a default unit.  While this can be helpful at times,
4146 it can cause strange errors in some expressions.  For example, the line
4147 length request expects em units.  Here are several attempts to get a
4148 line length of 3.5@w{ }inches and their results:
4150 @Example
4151 3.5i      @result{}   3.5i
4152 7/2       @result{}   0i
4153 7/2i      @result{}   0i
4154 (7 / 2)u  @result{}   0i
4155 7i/2      @result{}   0.1i
4156 7i/2u     @result{}   3.5i
4157 @endExample
4159 @noindent
4160 Everything is converted to basic units first.  In the above example it
4161 is assumed that 1@dmn{i} equals@w{ }240@dmn{u}, and 1@dmn{m} equals@w{
4162 }10@dmn{p} (thus 1@dmn{m} equals@w{ }33@dmn{u}).  The value 7@dmn{i}/2
4163 is first handled as 7@dmn{i}/2@dmn{m}, then converted to
4164 1680@dmn{u}/66@dmn{u} which is 25@dmn{u}, and this is approximately
4165 0.1@dmn{i}.  As can be seen, a scaling indicator after a closing
4166 parenthesis is simply ignored.
4168 @cindex measurements, specifying safely
4169 Thus, the safest way to specify measurements is to always
4170 attach a scaling indicator.  If you want to multiply or divide by a
4171 certain scalar value, use @samp{u} as the unit for that value.
4174 @c =====================================================================
4176 @node Expressions, Identifiers, Measurements, gtroff Reference
4177 @section Expressions
4178 @cindex expressions
4180 @code{gtroff} has most arithmetic operators common to other languages:
4182 @itemize @bullet
4183 @item
4184 @cindex arithmetic operators
4185 @cindex operators, arithmetic
4186 @opindex +
4187 @opindex -
4188 @opindex /
4189 @opindex *
4190 @opindex %
4191 Arithmetic: @samp{+} (addition), @samp{-} (subtraction), @samp{/}
4192 (division), @samp{*} (multiplication), @samp{%} (modulo).
4194 @code{gtroff} only provides integer arithmetic.  The internal type used
4195 for computing results is @samp{int}, which is usually a 32@dmn{bit}
4196 signed integer.
4198 @item
4199 @cindex comparison operators
4200 @cindex operators, comparison
4201 @opindex <
4202 @opindex >
4203 @opindex >=
4204 @opindex <=
4205 @opindex =
4206 @opindex ==
4207 Comparison: @samp{<} (less than), @samp{>} (greater than), @samp{<=}
4208 (less than or equal), @samp{>=} (greater than or equal), @samp{=}
4209 (equal), @samp{==} (the same as @samp{=}).
4211 @item
4212 @cindex logical operators
4213 @cindex operators, logical
4214 @opindex &
4215 @ifnotinfo
4216 @opindex :
4217 @end ifnotinfo
4218 @ifinfo
4219 @opindex @r{<colon>}
4220 @end ifinfo
4221 Logical: @samp{&} (logical and), @samp{:} (logical or).
4223 @item
4224 @cindex unary operators
4225 @cindex operators, unary
4226 @opindex -
4227 @opindex +
4228 @opindex !
4229 @cindex @code{if} request, and the @samp{!} operator
4230 @cindex @code{while} request, and the @samp{!} operator
4231 Unary operators: @samp{-} (negating, i.e.@: changing the sign), @samp{+}
4232 (just for completeness; does nothing in expressions), @samp{!} (logical
4233 not; this works only within @code{if} and @code{while} requests).  See
4234 below for the use of unary operators in motion requests.
4236 @item
4237 @cindex extremum operators (@code{>?}, @code{<?})
4238 @cindex operators, extremum (@code{>?}, @code{<?})
4239 @opindex >?
4240 @opindex <?
4241 Extrema: @samp{>?} (maximum), @samp{<?} (minimum).
4243 Example:
4245 @Example
4246 .nr x 5
4247 .nr y 3
4248 .nr z (\n[x] >? \n[y])
4249 @endExample
4251 @noindent
4252 The register@w{ }@code{z} now contains@w{ }5.
4254 @item
4255 @cindex scaling operator
4256 @cindex operator, scaling
4257 Scaling: @code{(@var{c};@var{e})}.  Evaluate@w{ }@var{e} using@w{ }@var{c}
4258 as the default scaling indicator.  If @var{c} is missing, ignore scaling
4259 indicators in the evaluation of@w{ }@var{e}.
4260 @end itemize
4262 @cindex parentheses
4263 @cindex order of evaluation in expressions
4264 @cindex expression, order of evaluation
4265 @opindex (
4266 @opindex )
4267 Parentheses may be used as in any other language.  However, in
4268 @code{gtroff} they are necessary to ensure order of evaluation.
4269 @code{gtroff} has no operator precedence; expressions are evaluated left
4270 to right.  This means that @code{gtroff} evaluates @samp{3+5*4} as if it were
4271 parenthesized like @samp{(3+5)*4}, not as @samp{3+(5*4)}, as might be
4272 expected.
4274 @cindex @code{+}, and page motion
4275 @cindex @code{-}, and page motion
4276 @cindex motion operators
4277 @cindex operators, motion
4278 For many requests which cause a motion on the page, the unary operators
4279 @samp{+} and @samp{-} work differently if leading an expression.  They
4280 then indicate a motion relative to the current position (down or up,
4281 respectively).
4283 @cindex @code{|}, and page motion
4284 @cindex absolute position operator (@code{|})
4285 @cindex position, absolute, operator (@code{|})
4286 Similarly, a leading @samp{|} operator indicates an absolute position.
4287 For vertical movements, it specifies the distance from the top of the
4288 page; for horizontal movements, it gives the distance from the beginning
4289 of the @emph{input} line.
4291 @cindex @code{bp} request, using @code{+} and@w{ }@code{-}
4292 @cindex @code{in} request, using @code{+} and@w{ }@code{-}
4293 @cindex @code{ll} request, using @code{+} and@w{ }@code{-}
4294 @cindex @code{lt} request, using @code{+} and@w{ }@code{-}
4295 @cindex @code{nm} request, using @code{+} and@w{ }@code{-}
4296 @cindex @code{nr} request, using @code{+} and@w{ }@code{-}
4297 @cindex @code{pl} request, using @code{+} and@w{ }@code{-}
4298 @cindex @code{pn} request, using @code{+} and@w{ }@code{-}
4299 @cindex @code{po} request, using @code{+} and@w{ }@code{-}
4300 @cindex @code{ps} request, using @code{+} and@w{ }@code{-}
4301 @cindex @code{pvs} request, using @code{+} and@w{ }@code{-}
4302 @cindex @code{rt} request, using @code{+} and@w{ }@code{-}
4303 @cindex @code{ti} request, using @code{+} and@w{ }@code{-}
4304 @cindex @code{\H}, using @code{+} and@w{ }@code{-}
4305 @cindex @code{\R}, using @code{+} and@w{ }@code{-}
4306 @cindex @code{\s}, using @code{+} and@w{ }@code{-}
4307 @samp{+} and @samp{-} are also treated differently by the following
4308 requests and escapes: @code{bp}, @code{in}, @code{ll}, @code{lt},
4309 @code{nm}, @code{nr}, @code{pl}, @code{pn}, @code{po}, @code{ps},
4310 @code{pvs}, @code{rt}, @code{ti}, @code{\H}, @code{\R}, and @code{\s}.
4311 Here, leading plus and minus signs indicate increments and decrements.
4313 @xref{Setting Registers}, for some examples.
4315 @Defesc {\\B, ', anything, '}
4316 @cindex numeric expression, valid
4317 @cindex valid numeric expression
4318 Return@w{ }1 if @var{anything} is a valid numeric expression;
4319 or@w{ }0 if @var{anything} is empty or not a valid numeric expression.
4320 @endDefesc
4322 @cindex space characters, in expressions
4323 @cindex expressions, and space characters
4324 Due to the way arguments are parsed, spaces are not allowed in
4325 expressions, unless the entire expression is surrounded by parentheses.
4327 @xref{Request Arguments}, and @ref{Conditionals and Loops}.
4330 @c =====================================================================
4332 @node Identifiers, Embedded Commands, Expressions, gtroff Reference
4333 @section Identifiers
4334 @cindex identifiers
4336 Like any other language, @code{gtroff} has rules for properly formed
4337 @dfn{identifiers}.  In @code{gtroff}, an identifier can be made up of
4338 almost any printable character, with the exception of the following
4339 characters:
4341 @itemize @bullet
4342 @item
4343 @cindex whitespace characters
4344 @cindex newline character
4345 @cindex character, whitespace
4346 Whitespace characters (spaces, tabs, and newlines).
4348 @item
4349 @cindex character, backspace
4350 @cindex backspace character
4351 @cindex @acronym{EBCDIC} encoding of backspace
4352 Backspace (@acronym{ASCII}@w{ }@code{0x08} or @acronym{EBCDIC}@w{
4353 }@code{0x16}) and character code @code{0x01}.
4355 @item
4356 @cindex invalid input characters
4357 @cindex input characters, invalid
4358 @cindex characters, invalid input
4359 @cindex Unicode
4360 The following input characters are invalid and are ignored if
4361 @code{groff} runs on a machine based on @acronym{ASCII}, causing a
4362 warning message of type @samp{input} (see @ref{Debugging}, for more
4363 details): @code{0x00}, @code{0x0B}, @code{0x0D}-@code{0x1F},
4364 @code{0x80}-@code{0x9F}.
4366 And here are the invalid input characters if @code{groff} runs on an
4367 @acronym{EBCDIC} host: @code{0x00}, @code{0x08}, @code{0x09},
4368 @code{0x0B}, @code{0x0D}-@code{0x14}, @code{0x17}-@code{0x1F},
4369 @code{0x30}-@code{0x3F}.
4371 Currently, some of these reserved codepoints are used internally, thus
4372 making it non-trivial to extend @code{gtroff} to cover Unicode or other
4373 character sets and encodings which use characters of these ranges.
4375 Note that invalid characters are removed before parsing; an
4376 identifier @code{foo}, followed by an invalid character, followed by
4377 @code{bar} is treated as @code{foobar}.
4378 @end itemize
4380 For example, any of the following is valid.
4382 @Example
4386 end-list
4388 @endExample
4390 @cindex @code{]}, as part of an identifier
4391 @noindent
4392 Note that identifiers longer than two characters with a closing bracket
4393 (@samp{]}) in its name can't be accessed with escape sequences which
4394 expect an identifier as a parameter.  For example, @samp{\[foo]]}
4395 accesses the glyph @samp{foo}, followed by @samp{]}, whereas
4396 @samp{\C'foo]'} really asks for glyph @samp{foo]}.
4398 @cindex @code{refer}, and macro names starting with @code{[} or @code{]}
4399 @cindex @code{[}, macro names starting with, and @code{refer}
4400 @cindex @code{]}, macro names starting with, and @code{refer}
4401 @cindex macro names, starting with @code{[} or @code{]}, and @code{refer}
4402 To avoid problems with the @code{refer} preprocessor, macro names
4403 should not start with @samp{[} or @samp{]}.  Due to backwards
4404 compatibility, everything after @samp{.[} and @samp{.]} is handled as
4405 a special argument to @code{refer}.  For example, @samp{.[foo} makes
4406 @code{refer} to start a reference, using @samp{foo} as a parameter.
4408 @Defesc {\\A, ', ident, '}
4409 Test whether an identifier @var{ident} is valid in @code{gtroff}.  It
4410 expands to the character@w{ }1 or@w{ }0 according to whether its
4411 argument (usually delimited by quotes) is or is not acceptable as the
4412 name of a string, macro, diversion, number register, environment, or
4413 font.  It returns@w{ }0 if no argument is given.  This is useful for
4414 looking up user input in some sort of associative table.
4416 @Example
4417 \A'end-list'
4418     @result{} 1
4419 @endExample
4420 @endDefesc
4422 @xref{Escapes}, for details on parameter delimiting characters.
4424 Identifiers in @code{gtroff} can be any length, but, in some contexts,
4425 @code{gtroff} needs to be told where identifiers end and text begins
4426 (and in different ways depending on their length):
4428 @itemize @bullet
4429 @item
4430 Single character.
4432 @cindex @code{(}, starting a two-character identifier
4433 @item
4434 Two characters.  Must be prefixed with @samp{(} in some situations.
4436 @cindex @code{[}, starting an identifier
4437 @cindex @code{]}, ending an identifier
4438 @item
4439 Arbitrary length (@code{gtroff} only).  Must be bracketed with @samp{[}
4440 and@w{ }@samp{]} in some situations.  Any length identifier can be put
4441 in brackets.
4442 @end itemize
4444 @cindex undefined identifiers
4445 @cindex identifiers, undefined
4446 Unlike many other programming languages, undefined identifiers are
4447 silently ignored or expanded to nothing.
4448 When @code{gtroff} finds an undefined identifier, it emits a
4449 warning, doing the following:
4451 @itemize @bullet
4452 @item
4453 If the identifier is a string, macro, or diversion,
4454 @code{gtroff} defines it as empty.
4456 @item
4457 If the identifier is a number register, @code{gtroff}
4458 defines it with a value of@w{ }0.
4459 @end itemize
4461 @xref{Warnings}., @ref{Interpolating Registers}, and @ref{Strings}.
4463 Note that macros, strings, and diversions share the same name space.
4465 @Example
4466 .de xxx
4467 .  nop foo
4470 .di xxx
4475 .xxx
4476     @result{} bar
4477 @endExample
4479 @noindent
4480 As can be seen in the previous example, @code{gtroff} reuses the
4481 identifier @samp{xxx}, changing it from a macro to a diversion.
4482 No warning is emitted!  The contents of the first macro definition is
4483 lost.
4485 @xref{Interpolating Registers}, and @ref{Strings}.
4488 @c =====================================================================
4490 @node Embedded Commands, Registers, Identifiers, gtroff Reference
4491 @section Embedded Commands
4492 @cindex embedded commands
4493 @cindex commands, embedded
4495 Most documents need more functionality beyond filling, adjusting and
4496 implicit line breaking.  In order to gain further functionality,
4497 @code{gtroff} allows commands to be embedded into the text, in two ways.
4499 The first is a @dfn{request} which takes up an entire line, and does
4500 some large-scale operation (e.g.@: break lines, start new pages).
4502 The other is an @dfn{escape} which can be usually embedded anywhere
4503 in the text; most requests can accept it even as an argument.
4504 Escapes generally do more minor operations like sub- and superscripts,
4505 print a symbol, etc.
4507 @menu
4508 * Requests::
4509 * Macros::
4510 * Escapes::
4511 @end menu
4513 @c ---------------------------------------------------------------------
4515 @node Requests, Macros, Embedded Commands, Embedded Commands
4516 @subsection Requests
4517 @cindex requests
4519 @cindex control character (@code{.})
4520 @cindex character, control (@code{.})
4521 @cindex no-break control character (@code{'})
4522 @cindex character, no-break control (@code{'})
4523 @cindex control character, no-break (@code{'})
4524 A request line begins with a control character, which is either a single
4525 quote (@samp{'}, the @dfn{no-break control character}) or a period
4526 (@samp{.}, the normal @dfn{control character}).  These can be changed;
4527 see @ref{Character Translations}, for details.  After this there may be
4528 optional tabs or spaces followed by an identifier which is the name of
4529 the request.  This may be followed by any number of space-separated
4530 arguments (@emph{no} tabs here).
4532 @cindex structuring source code of documents or macro packages
4533 @cindex documents, structuring the source code
4534 @cindex macro packages, structuring the source code
4535 Since a control character followed by whitespace only is ignored, it
4536 is common practice to use this feature for structuring the source code
4537 of documents or macro packages.
4539 @Example
4540 .de foo
4541 .  tm This is foo.
4545 .de bar
4546 .  tm This is bar.
4548 @endExample
4550 @cindex blank line
4551 @cindex blank line macro (@code{blm})
4552 Another possibility is to use the blank line macro request @code{blm}
4553 by assigning an empty macro to it.
4555 @Example
4556 .de do-nothing
4558 .blm do-nothing  \" activate blank line macro
4560 .de foo
4561 .  tm This is foo.
4565 .de bar
4566 .  tm This is bar.
4569 .blm             \" deactivate blank line macro
4570 @endExample
4572 @xref{Blank Line Traps}.
4574 @cindex zero width space character (@code{\&})
4575 @cindex character, zero width space (@code{\&})
4576 @cindex space character, zero width (@code{\&})
4577 @cindex @code{\&}, escaping control characters
4578 To begin a line with a control character without it being interpreted,
4579 precede it with @code{\&}.  This represents a zero width space, which
4580 means it does not affect the output.
4582 In most cases the period is used as a control character.  Several
4583 requests cause a break implicitly; using the single quote control
4584 character prevents this.
4586 @menu
4587 * Request Arguments::
4588 @end menu
4590 @node Request Arguments,  , Requests, Requests
4591 @subsubsection Request Arguments
4592 @cindex request arguments
4593 @cindex arguments to requests
4595 Arguments to requests (and macros) are processed much like the shell:
4596 The line is split into arguments according to
4597 spaces.@footnote{Plan@w{ }9's @code{troff} implementation also allows
4598 tabs for argument separation -- @code{gtroff} intentionally doesn't
4599 support this.}  An argument which is intended to contain spaces can
4600 either be enclosed in double quotes, or have the spaces @dfn{escaped}
4601 with backslashes.
4603 Here are a few examples:
4605 @Example
4606 .uh The Mouse Problem
4607 .uh "The Mouse Problem"
4608 .uh The\ Mouse\ Problem
4609 @endExample
4611 @cindex @code{\~}, difference to @code{\@key{SP}}
4612 @cindex @code{\@key{SP}}, difference to @code{\~}
4613 @noindent
4614 The first line is the @code{uh} macro being called with 3 arguments,
4615 @samp{The}, @samp{Mouse}, and @samp{Problem}.  The latter two have the
4616 same effect of calling the @code{uh} macro with one argument, @samp{The
4617 Mouse Problem}.@footnote{The last solution, i.e., using escaped spaces,
4618 is ``classical'' in the sense that it can be found in most @code{troff}
4619 documents.  Nevertheless, it is not optimal in all situations, since
4620 @w{@samp{\ }} inserts a fixed-width, non-breaking space character which
4621 can't stretch.  @code{gtroff} provides a different command @code{\~} to
4622 insert a stretchable, non-breaking space.}
4624 @cindex @code{"}, in a macro argument
4625 @cindex double quote, in a macro argument
4626 A double quote which isn't preceded by a space doesn't start a macro
4627 argument.  If not closing a string, it is printed literally.
4629 For example,
4631 @Example
4632 .xxx a" "b c" "de"fg"
4633 @endExample
4635 @noindent
4636 has the arguments @samp{a"}, @w{@samp{b c}}, @samp{de}, and @samp{fg"}.
4637 Don't rely on this obscure behaviour!
4639 There are two possibilities to get a double quote reliably.
4641 @itemize @bullet
4642 @item
4643 Enclose the whole argument with double quotes and use two consecutive double
4644 quotes to represent a single one.  This traditional solution has the
4645 disadvantage that double quotes don't survive argument expansion again if
4646 called in compatibility mode (using the @option{-C} option of @code{groff}):
4648 @Example
4649 .de xx
4650 .  tm xx: `\\$1' `\\$2' `\\$3'
4652 .  yy "\\$1" "\\$2" "\\$3"
4654 .de yy
4655 .  tm yy: `\\$1' `\\$2' `\\$3'
4657 .xx A "test with ""quotes""" .
4658     @result{} xx: `A' `test with "quotes"' `.'
4659     @result{} yy: `A' `test with ' `quotes""'
4660 @endExample
4662 @noindent
4663 If not in compatibility mode, you get the expected result
4665 @Example
4666 xx: `A' `test with "quotes"' `.'
4667 yy: `A' `test with "quotes"' `.'
4668 @endExample
4670 @noindent
4671 since @code{gtroff} preserves the input level.
4673 @item
4674 Use the double quote glyph @code{\(dq}.  This works with and without
4675 compatibility mode enabled since @code{gtroff} doesn't convert @code{\(dq}
4676 back to a double quote input character.
4678 Not that this method won't work with @acronym{UNIX} @code{troff} in general
4679 since the glyph `dq' isn't defined normally.
4680 @end itemize
4682 @cindex @code{ds} request, and double quotes
4683 Double quotes in the @code{ds} request are handled differently.
4684 @xref{Strings}, for more details.
4686 @c ---------------------------------------------------------------------
4688 @node Macros, Escapes, Requests, Embedded Commands
4689 @subsection Macros
4690 @cindex macros
4692 @code{gtroff} has a @dfn{macro} facility for defining a series of lines
4693 which can be invoked by name.  They are called in the same manner as
4694 requests -- arguments also may be passed in the same manner.
4696 @xref{Writing Macros}, and @ref{Request Arguments}.
4698 @c ---------------------------------------------------------------------
4700 @node Escapes,  , Macros, Embedded Commands
4701 @subsection Escapes
4702 @cindex escapes
4704 Escapes may occur anywhere in the input to @code{gtroff}.  They usually
4705 begin with a backslash and are followed by a single character which
4706 indicates the function to be performed.  The escape character can be
4707 changed; see @ref{Character Translations}.
4709 Escape sequences which require an identifier as a parameter accept three
4710 possible syntax forms.
4712 @itemize @bullet
4713 @item
4714 The next single character is the identifier.
4716 @cindex @code{(}, starting a two-character identifier
4717 @item
4718 If this single character is an opening parenthesis, take the following
4719 two characters as the identifier.  Note that there is no closing
4720 parenthesis after the identifier.
4722 @cindex @code{[}, starting an identifier
4723 @cindex @code{]}, ending an identifier
4724 @item
4725 If this single character is an opening bracket, take all characters
4726 until a closing bracket as the identifier.
4727 @end itemize
4729 @noindent
4730 Examples:
4732 @Example
4734 \n(XX
4735 \*[TeX]
4736 @endExample
4738 @cindex @code{'}, delimiting arguments
4739 @cindex argument delimiting characters
4740 @cindex characters, argument delimiting
4741 @cindex delimiting characters for arguments
4742 Other escapes may require several arguments and/or some special format.
4743 In such cases the argument is traditionally enclosed in single quotes
4744 (and quotes are always used in this manual for the definitions of escape
4745 sequences).  The enclosed text is then processed according to what that
4746 escape expects.  Example:
4748 @Example
4749 \l'1.5i\(bu'
4750 @endExample
4752 @cindex @code{\o}, possible quote characters
4753 @cindex @code{\b}, possible quote characters
4754 @cindex @code{\X}, possible quote characters
4755 Note that the quote character can be replaced with any other character
4756 which does not occur in the argument (even a newline or a space
4757 character) in the following escapes: @code{\o}, @code{\b}, and
4758 @code{\X}.  This makes e.g.
4760 @Example
4761 A caf
4766 in Paris
4767   @result{} A caf@'e in Paris
4768 @endExample
4770 @noindent
4771 possible, but it is better not to use this feature to avoid confusion.
4773 @cindex @code{\%}, used as delimiter
4774 @cindex @code{\@key{SP}}, used as delimiter
4775 @cindex @code{\|}, used as delimiter
4776 @cindex @code{\^}, used as delimiter
4777 @cindex @code{\@{}, used as delimiter
4778 @cindex @code{\@}}, used as delimiter
4779 @cindex @code{\'}, used as delimiter
4780 @cindex @code{\`}, used as delimiter
4781 @cindex @code{\-}, used as delimiter
4782 @cindex @code{\_}, used as delimiter
4783 @cindex @code{\!}, used as delimiter
4784 @cindex @code{\?}, used as delimiter
4785 @cindex @code{\@@}, used as delimiter
4786 @cindex @code{\)}, used as delimiter
4787 @cindex @code{\/}, used as delimiter
4788 @cindex @code{\,}, used as delimiter
4789 @cindex @code{\&}, used as delimiter
4790 @ifnotinfo
4791 @cindex @code{\:}, used as delimiter
4792 @end ifnotinfo
4793 @ifinfo
4794 @cindex @code{\@r{<colon>}}, used as delimiter
4795 @end ifinfo
4796 @cindex @code{\~}, used as delimiter
4797 @cindex @code{\0}, used as delimiter
4798 @cindex @code{\a}, used as delimiter
4799 @cindex @code{\c}, used as delimiter
4800 @cindex @code{\d}, used as delimiter
4801 @cindex @code{\e}, used as delimiter
4802 @cindex @code{\E}, used as delimiter
4803 @cindex @code{\p}, used as delimiter
4804 @cindex @code{\r}, used as delimiter
4805 @cindex @code{\t}, used as delimiter
4806 @cindex @code{\u}, used as delimiter
4807 The following escapes sequences (which are handled similarly to
4808 characters since they don't take a parameter) are also allowed as
4809 delimiters: @code{\%}, @w{@samp{\ }}, @code{\|}, @code{\^}, @code{\@{},
4810 @code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
4811 @code{\?}, @code{\@@}, @code{\)}, @code{\/}, @code{\,}, @code{\&},
4812 @code{\:}, @code{\~}, @code{\0}, @code{\a}, @code{\c}, @code{\d},
4813 @code{\e}, @code{\E}, @code{\p}, @code{\r}, @code{\t}, and @code{\u}.
4814 Again, don't use these if possible.
4816 @cindex @code{\A}, allowed delimiters
4817 @cindex @code{\B}, allowed delimiters
4818 @cindex @code{\Z}, allowed delimiters
4819 @cindex @code{\C}, allowed delimiters
4820 @cindex @code{\w}, allowed delimiters
4821 No newline characters as delimiters are allowed in the following
4822 escapes: @code{\A}, @code{\B}, @code{\Z}, @code{\C}, and @code{\w}.
4824 @cindex @code{\D}, allowed delimiters
4825 @cindex @code{\h}, allowed delimiters
4826 @cindex @code{\H}, allowed delimiters
4827 @cindex @code{\l}, allowed delimiters
4828 @cindex @code{\L}, allowed delimiters
4829 @cindex @code{\N}, allowed delimiters
4830 @cindex @code{\R}, allowed delimiters
4831 @cindex @code{\s}, allowed delimiters
4832 @cindex @code{\S}, allowed delimiters
4833 @cindex @code{\v}, allowed delimiters
4834 @cindex @code{\x}, allowed delimiters
4835 Finally, the escapes @code{\D}, @code{\h}, @code{\H}, @code{\l},
4836 @code{\L}, @code{\N}, @code{\R}, @code{\s}, @code{\S}, @code{\v},
4837 and @code{\x} can't use the following characters as delimiters:
4839 @itemize @bullet
4840 @item
4841 @cindex numbers, and delimiters
4842 @cindex digits, and delimiters
4843 The digits @code{0}-@code{9}.
4845 @item
4846 @cindex operators, as delimiters
4847 @cindex @code{+}, as delimiter
4848 @cindex @code{-}, as delimiter
4849 @cindex @code{/}, as delimiter
4850 @cindex @code{*}, as delimiter
4851 @cindex @code{%}, as delimiter
4852 @cindex @code{<}, as delimiter
4853 @cindex @code{>}, as delimiter
4854 @cindex @code{=}, as delimiter
4855 @cindex @code{&}, as delimiter
4856 @ifnotinfo
4857 @cindex @code{:}, as delimiter
4858 @end ifnotinfo
4859 @ifinfo
4860 @cindex <colon>, as delimiter
4861 @end ifinfo
4862 @cindex @code{(}, as delimiter
4863 @cindex @code{)}, as delimiter
4864 @cindex @code{.}, as delimiter
4865 The (single-character) operators @samp{+-/*%<>=&:().}.
4867 @item
4868 @cindex space character
4869 @cindex character, space
4870 @cindex tab character
4871 @cindex character, tab
4872 @cindex newline character
4873 @cindex character, newline
4874 The space, tab, and newline characters.
4876 @item
4877 @cindex @code{\%}, used as delimiter
4878 @ifnotinfo
4879 @cindex @code{\:}, used as delimiter
4880 @end ifnotinfo
4881 @ifinfo
4882 @cindex @code{\@r{<colon>}}, used as delimiter
4883 @end ifinfo
4884 @cindex @code{\@{}, used as delimiter
4885 @cindex @code{\@}}, used as delimiter
4886 @cindex @code{\'}, used as delimiter
4887 @cindex @code{\`}, used as delimiter
4888 @cindex @code{\-}, used as delimiter
4889 @cindex @code{\_}, used as delimiter
4890 @cindex @code{\!}, used as delimiter
4891 @cindex @code{\@@}, used as delimiter
4892 @cindex @code{\/}, used as delimiter
4893 @cindex @code{\c}, used as delimiter
4894 @cindex @code{\e}, used as delimiter
4895 @cindex @code{\p}, used as delimiter
4896 All escape sequences except @code{\%}, @code{\:}, @code{\@{}, @code{\@}},
4897 @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!}, @code{\@@},
4898 @code{\/}, @code{\c}, @code{\e}, and @code{\p}.
4899 @end itemize
4901 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
4902 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
4903 To have a backslash (actually, the current escape character) appear in the
4904 output several escapes are defined: @code{\\}, @code{\e} or @code{\E}.
4905 These are very similar, and only differ with respect to being used in
4906 macros or diversions.  @xref{Character Translations}, for an exact
4907 description of those escapes.
4909 @xref{Implementation Differences}, @ref{Copy-in Mode}, and @ref{Diversions},
4910 @ref{Identifiers}, for more information.
4912 @menu
4913 * Comments::
4914 @end menu
4916 @node Comments,  , Escapes, Escapes
4917 @subsubsection Comments
4918 @cindex comments
4920 Probably one of the most@footnote{Unfortunately, this is a lie.  But
4921 hopefully future @code{gtroff} hackers will believe it @code{:-)}}
4922 common forms of escapes is the comment.
4924 @Defesc {\\", , , }
4925 Start a comment.  Everything to the end of the input line is ignored.
4927 This may sound simple, but it can be tricky to keep the comments from
4928 interfering with the appearance of the final output.
4930 @cindex @code{ds}, @code{ds1} requests, and comments
4931 @cindex @code{as}, @code{as1} requests, and comments
4932 If the escape is to the right of some text or a request, that portion
4933 of the line is ignored, but the space leading up to it is noticed by
4934 @code{gtroff}.  This only affects the @code{ds} and @code{as}
4935 request and its variants.
4937 @cindex tabs, before comments
4938 @cindex comments, lining up with tabs
4939 One possibly irritating idiosyncracy is that tabs must not be used to
4940 line up comments.  Tabs are not treated as whitespace between the
4941 request and macro arguments.
4943 @cindex undefined request
4944 @cindex request, undefined
4945 A comment on a line by itself is treated as a blank line, because
4946 after eliminating the comment, that is all that remains:
4948 @Example
4949 Test
4950 \" comment
4951 Test
4952 @endExample
4954 @noindent
4955 produces
4957 @Example
4958 Test
4960 Test
4961 @endExample
4963 To avoid this, it is common to start the line with @code{.\"} which
4964 causes the line to be treated as an undefined request and thus ignored
4965 completely.
4967 @cindex @code{'}, as a comment
4968 Another commenting scheme seen sometimes is three consecutive single
4969 quotes (@code{'''}) at the beginning of a line.  This works, but
4970 @code{gtroff} gives a warning about an undefined macro (namely
4971 @code{''}), which is harmless, but irritating.
4972 @endDefesc
4974 @Defesc {\\#, , , }
4975 To avoid all this, @code{gtroff} has a new comment mechanism using the
4976 @code{\#} escape.  This escape works the same as @code{\"} except that
4977 the newline is also ignored:
4979 @Example
4980 Test
4981 \# comment
4982 Test
4983 @endExample
4985 @noindent
4986 produces
4988 @Example
4989 Test Test
4990 @endExample
4992 @noindent
4993 as expected.
4994 @endDefesc
4996 @Defreq {ig, yy}
4997 Ignore all input until @code{gtroff} encounters the macro named
4998 @code{.}@var{yy} on a line by itself (or @code{..} if @var{yy} is not
4999 specified).  This is useful for commenting out large blocks of text:
5001 @Example
5002 text text text...
5004 This is part of a large block
5005 of text that has been
5006 temporarily(?) commented out.
5008 We can restore it simply by removing
5009 the .ig request and the ".." at the
5010 end of the block.
5012 More text text text...
5013 @endExample
5015 @noindent
5016 produces
5018 @Example
5019 text text text@dots{}  More text text text@dots{}
5020 @endExample
5022 @noindent
5023 Note that the commented-out block of text does not
5024 cause a break.
5026 The input is read in copy-mode; auto-incremented registers @emph{are}
5027 affected (@pxref{Auto-increment}).
5028 @endDefreq
5031 @c =====================================================================
5033 @node Registers, Manipulating Filling and Adjusting, Embedded Commands, gtroff Reference
5034 @section Registers
5035 @cindex registers
5037 Numeric variables in @code{gtroff} are called @dfn{registers}.  There
5038 are a number of built-in registers, supplying anything from the date to
5039 details of formatting parameters.
5041 @xref{Identifiers}, for details on register identifiers.
5043 @menu
5044 * Setting Registers::
5045 * Interpolating Registers::
5046 * Auto-increment::
5047 * Assigning Formats::
5048 * Built-in Registers::
5049 @end menu
5051 @c ---------------------------------------------------------------------
5053 @node Setting Registers, Interpolating Registers, Registers, Registers
5054 @subsection Setting Registers
5055 @cindex setting registers (@code{nr}, @code{\R})
5056 @cindex registers, setting (@code{nr}, @code{\R})
5058 Define or set registers using the @code{nr} request or the
5059 @code{\R} escape.
5061 @DefreqList {nr, ident value}
5062 @DefescListEnd {\\R, ', ident value, '}
5063 Set number register @var{ident} to @var{value}.  If @var{ident}
5064 doesn't exist, @code{gtroff} creates it.
5066 The argument to @code{\R} usually has to be enclosed in quotes.
5067 @xref{Escapes}, for details on parameter delimiting characters.
5069 The @code{\R} escape doesn't produce an input token in @code{gtroff};
5070 with other words, it vanishes completely after @code{gtroff} has
5071 processed it.
5072 @endDefreq
5074 For example, the following two lines are equivalent:
5076 @Example
5077 .nr a (((17 + (3 * 4))) % 4)
5078 \R'a (((17 + (3 * 4))) % 4)'
5079     @result{} 1
5080 @endExample
5082 Both @code{nr} and @code{\R} have two additional special forms to
5083 increment or decrement a register.
5085 @DefreqList {nr, ident @t{+}@Var{value}}
5086 @DefreqItem {nr, ident @t{-}@Var{value}}
5087 @DefescItem {\\R, ', ident @t{+}@Var{value}, '}
5088 @DefescListEnd {\\R, ', ident @t{-}@Var{value}, '}
5089 Increment (decrement) register @var{ident} by @var{value}.
5091 @Example
5092 .nr a 1
5093 .nr a +1
5095     @result{} 2
5096 @endExample
5098 @cindex negating register values
5099 To assign the negated value of a register to another register, some care
5100 must be taken to get the desired result:
5102 @Example
5103 .nr a 7
5104 .nr b 3
5105 .nr a -\nb
5107     @result{} 4
5108 .nr a (-\nb)
5110     @result{} -3
5111 @endExample
5113 @noindent
5114 The surrounding parentheses prevent the interpretation of the minus sign
5115 as a decrementing operator.  An alternative is to start the assignment
5116 with a @samp{0}:
5118 @Example
5119 .nr a 7
5120 .nr b -3
5121 .nr a \nb
5123     @result{} 4
5124 .nr a 0\nb
5126     @result{} -3
5127 @endExample
5128 @endDefreq
5130 @Defreq {rr, ident}
5131 @cindex removing number register (@code{rr})
5132 @cindex number register, removing (@code{rr})
5133 @cindex register, removing (@code{rr})
5134 Remove number register @var{ident}.  If @var{ident} doesn't exist, the
5135 request is ignored.
5136 @endDefreq
5138 @Defreq {rnn, ident1 ident2}
5139 @cindex renaming number register (@code{rnn})
5140 @cindex number register, renaming (@code{rnn})
5141 @cindex register, renaming (@code{rnn})
5142 Rename number register @var{ident1} to @var{ident2}.  If either
5143 @var{ident1} or @var{ident2} doesn't exist, the request is ignored.
5144 @endDefreq
5146 @Defreq {aln, ident1 ident2}
5147 @cindex alias, number register, creating (@code{aln})
5148 @cindex creating alias, for number register (@code{aln})
5149 @cindex number register, creating alias (@code{aln})
5150 @cindex register, creating alias (@code{aln})
5151 Create an alias @var{ident1} for a number register @var{ident2}.  The
5152 new name and the old name are exactly equivalent.  If @var{ident1} is
5153 undefined, a warning of type @samp{reg} is generated, and the request
5154 is ignored.  @xref{Debugging}, for information about warnings.
5155 @endDefreq
5157 @c ---------------------------------------------------------------------
5159 @node Interpolating Registers, Auto-increment, Setting Registers, Registers
5160 @subsection Interpolating Registers
5161 @cindex interpolating registers (@code{\n})
5162 @cindex registers, interpolating (@code{\n})
5164 Numeric registers can be accessed via the @code{\n} escape.
5166 @DefescList {\\n, , i, }
5167 @DefescItem {\\n, @lparen{}, id, }
5168 @DefescListEnd {\\n, @lbrack{}, ident, @rbrack}
5169 @cindex nested assignments
5170 @cindex assignments, nested
5171 @cindex indirect assignments
5172 @cindex assignments, indirect
5173 Interpolate number register with name @var{ident} (one-character name@w{
5174 }@var{i}, two-character name @var{id}). This means that the value of the
5175 register is expanded in-place while @code{gtroff} is parsing the input line.
5176 Nested assignments (also called indirect assignments) are possible.
5178 @Example
5179 .nr a 5
5180 .nr as \na+\na
5181 \n(as
5182     @result{} 10
5183 @endExample
5185 @Example
5186 .nr a1 5
5187 .nr ab 6
5188 .ds str b
5189 .ds num 1
5190 \n[a\n[num]]
5191     @result{} 5
5192 \n[a\*[str]]
5193     @result{} 6
5194 @endExample
5195 @endDefesc
5197 @c ---------------------------------------------------------------------
5199 @node Auto-increment, Assigning Formats, Interpolating Registers, Registers
5200 @subsection Auto-increment
5201 @cindex auto-increment
5202 @cindex increment, automatic
5204 Number registers can also be auto-incremented and auto-decremented.
5205 The increment or decrement value can be specified with a third
5206 argument to the @code{nr} request or @code{\R} escape.
5208 @Defreq {nr, ident value incr}
5209 @cindex @code{\R}, difference to @code{nr}
5210 Set number register @var{ident} to @var{value}; the increment for
5211 auto-incrementing is set to @var{incr}.  Note that the @code{\R}
5212 escape doesn't support this notation.
5213 @endDefreq
5215 To activate auto-incrementing, the escape @code{\n} has a special
5216 syntax form.
5218 @DefescList {\\n, +, i, }
5219 @DefescItem {\\n, -, i, }
5220 @DefescItem {\\n, @lparen{}+, id, }
5221 @DefescItem {\\n, @lparen{}-, id, }
5222 @DefescItem {\\n, +@lparen{}, id, }
5223 @DefescItem {\\n, -@lparen{}, id, }
5224 @DefescItem {\\n, @lbrack{}+, ident, @rbrack{}}
5225 @DefescItem {\\n, @lbrack{}-, ident, @rbrack{}}
5226 @DefescItem {\\n, +@lbrack{}, ident, @rbrack{}}
5227 @DefescListEnd {\\n, -@lbrack{}, ident, @rbrack{}}
5228 Before interpolating, increment or decrement @var{ident}
5229 (one-character name@w{ }@var{i}, two-character name @var{id}) by the
5230 auto-increment value as specified with the @code{nr} request (or the
5231 @code{\R} escape).  If no auto-increment value has been specified,
5232 these syntax forms are identical to @code{\n}.
5233 @endDefesc
5235 For example,
5237 @Example
5238 .nr a 0 1
5239 .nr xx 0 5
5240 .nr foo 0 -2
5241 \n+a, \n+a, \n+a, \n+a, \n+a
5243 \n-(xx, \n-(xx, \n-(xx, \n-(xx, \n-(xx
5245 \n+[foo], \n+[foo], \n+[foo], \n+[foo], \n+[foo]
5246 @endExample
5248 @noindent
5249 produces
5251 @Example
5252 1, 2, 3, 4, 5
5253 -5, -10, -15, -20, -25
5254 -2, -4, -6, -8, -10
5255 @endExample
5257 @cindex increment value without changing the register
5258 @cindex value, incrementing without changing the register
5259 To change the increment value without changing the value of a register
5260 (@var{a} in the example), the following can be used:
5262 @Example
5263 .nr a \na 10
5264 @endExample
5266 @c ---------------------------------------------------------------------
5268 @node Assigning Formats, Built-in Registers, Auto-increment, Registers
5269 @subsection Assigning Formats
5270 @cindex assigning formats (@code{af})
5271 @cindex formats, assigning (@code{af})
5273 When a register is used in the text of an input file (as opposed to
5274 part of an expression), it is textually replaced (or interpolated)
5275 with a representation of that number.  This output format can be
5276 changed to a variety of formats (numbers, Roman numerals, etc.).  This
5277 is done using the @code{af} request.
5279 @Defreq {af, ident format}
5280 Change the output format of a number register.  The first argument
5281 @var{ident} is the name of the number register to be changed, and the
5282 second argument @var{format} is the output format.  The following
5283 output formats are available:
5285 @table @code
5286 @item 1
5287 Decimal arabic numbers.  This is the default format: 0, 1, 2, 3,@w{
5288 }@enddots{}
5290 @item 0@dots{}0
5291 Decimal numbers with as many digits as specified.  So, @samp{00} would
5292 result in printing numbers as 01, 02, 03,@w{ }@enddots{}
5294 In fact, any digit instead of zero will do; @code{gtroff} only counts
5295 how many digits are specified.  As a consequence, @code{af}'s default
5296 format @samp{1} could be specified as @samp{0} also (and exactly this is
5297 returned by the @code{\g} escape, see below).
5299 @item I
5300 @cindex Roman numerals
5301 @cindex numerals, Roman
5302 Upper-case Roman numerals: 0, I, II, III, IV,@w{ }@enddots{}
5304 @item i
5305 Lower-case Roman numerals: 0, i, ii, iii, iv,@w{ }@enddots{}
5307 @item A
5308 Upper-case letters: 0, A, B, C, @dots{},@w{ }Z, AA, AB,@w{ }@enddots{}
5310 @item a
5311 Lower-case letters: 0, a, b, c, @dots{},@w{ }z, aa, ab,@w{ }@enddots{}
5312 @end table
5314 Omitting the number register format causes a warning of type
5315 @samp{missing}.  @xref{Debugging}, for more details.  Specifying a
5316 nonexistent format causes an error.
5318 The following example produces @samp{10, X, j, 010}:
5320 @Example
5321 .nr a 10
5322 .af a 1           \" the default format
5323 \na,
5324 .af a I
5325 \na,
5326 .af a a
5327 \na,
5328 .af a 001
5330 @endExample
5332 @cindex Roman numerals, maximum and minimum
5333 @cindex maximum values of Roman numerals
5334 @cindex minimum values of Roman numerals
5335 The largest number representable for the @samp{i} and @samp{I} formats
5336 is 39999 (or @minus{}39999); @acronym{UNIX} @code{troff} uses @samp{z}
5337 and @samp{w} to represent 10000 and 5000 in Roman numerals, and so does
5338 @code{gtroff}.  Currently, the correct glyphs of Roman numeral five
5339 thousand and Roman numeral ten thousand (Unicode code points
5340 @code{U+2182} and @code{U+2181}, respectively) are not available.
5342 If @var{ident} doesn't exist, it is created.
5344 @cindex read-only register, changing format
5345 @cindex changing format, and read-only registers
5346 Changing the output format of a read-only register causes an error.  It
5347 is necessary to first copy the register's value to a writeable register,
5348 then apply the @code{af} request to this other register.
5349 @endDefreq
5351 @DefescList {\\g, , i, }
5352 @DefescItem {\\g, @lparen{}, id, }
5353 @DefescListEnd {\\g, @lbrack{}, ident, @rbrack{}}
5354 @cindex format of register (@code{\g})
5355 @cindex register, format (@code{\g})
5356 Return the current format of the specified register @var{ident}
5357 (one-character name@w{ }@var{i}, two-character name @var{id}).  For
5358 example, @samp{\ga} after the previous example would produce the
5359 string @samp{000}.  If the register hasn't been defined yet, nothing
5360 is returned.
5361 @endDefesc
5363 @c ---------------------------------------------------------------------
5365 @node Built-in Registers,  , Assigning Formats, Registers
5366 @subsection Built-in Registers
5367 @cindex built-in registers
5368 @cindex registers, built-in
5370 The following lists some built-in registers which are not described
5371 elsewhere in this manual.  Any register which begins with a @samp{.} is
5372 read-only.  A complete listing of all built-in registers can be found in
5373 @ref{Register Index}.
5375 @table @code
5376 @item .F
5377 @cindex current input file name register (@code{.F})
5378 @cindex input file name, current, register (@code{.F})
5379 @vindex .F
5380 This string-valued register returns the current input file name.
5382 @item .H
5383 @cindex horizontal resolution register (@code{.H})
5384 @cindex resolution, horizontal, register (@code{.H})
5385 @vindex .H
5386 Horizontal resolution in basic units.
5388 @item .V
5389 @cindex vertical resolution register (@code{.V})
5390 @cindex resolution, vertical, register (@code{.V})
5391 @vindex .V
5392 Vertical resolution in basic units.
5394 @item dw
5395 @cindex day of the week register (@code{dw})
5396 @cindex date, day of the week register (@code{dw})
5397 @vindex dw
5398 Day of the week (1-7).
5400 @item dy
5401 @cindex day of the month register (@code{dy})
5402 @cindex date, day of the month register (@code{dy})
5403 @vindex dy
5404 Day of the month (1-31).
5406 @item mo
5407 @cindex month of the year register (@code{mo})
5408 @cindex date, month of the year register (@code{mo})
5409 @vindex mo
5410 Current month (1-12).
5412 @item year
5413 @cindex date, year register (@code{year}, @code{yr})
5414 @cindex year, current, register (@code{year}, @code{yr})
5415 @vindex year
5416 The current year.
5418 @item yr
5419 @vindex yr
5420 The current year minus@w{ }1900.  Unfortunately, the documentation of
5421 @acronym{UNIX} Version@w{ }7's @code{troff} had a year@w{ }2000 bug: It
5422 incorrectly claimed that @code{yr} contains the last two digits of the
5423 year.  That claim has never been true of either @acronym{AT&T}
5424 @code{troff} or GNU @code{troff}.  Old @code{troff} input that looks
5425 like this:
5427 @Example
5428 '\" The following line stopped working after 1999
5429 This document was formatted in 19\n(yr.
5430 @endExample
5432 @noindent
5433 can be corrected as follows:
5435 @Example
5436 This document was formatted in \n[year].
5437 @endExample
5439 @noindent
5440 or, to be portable to older @code{troff} versions, as follows:
5442 @Example
5443 .nr y4 1900+\n(yr
5444 This document was formatted in \n(y4.
5445 @endExample
5447 @item .c
5448 @vindex .c
5449 @itemx c.
5450 @vindex c.
5451 @cindex input line number register (@code{.c}, @code{c.})
5452 @cindex line number, input, register (@code{.c}, @code{c.})
5453 The current @emph{input} line number.  Register @samp{.c} is read-only,
5454 whereas @samp{c.} (a @code{gtroff} extension) is writable also,
5455 affecting both @samp{.c} and @samp{c.}.
5457 @item ln
5458 @vindex ln
5459 @cindex output line number register (@code{ln})
5460 @cindex line number, output, register (@code{ln})
5461 The current @emph{output} line number after a call to the @code{nm}
5462 request to activate line numbering.
5464 @xref{Miscellaneous}, for more information about line numbering.
5466 @item .x
5467 @vindex .x
5468 @cindex major version number register (@code{.x})
5469 @cindex version number, major, register (@code{.x})
5470 The major version number.  For example, if the version number is@w{
5471 }1.03 then @code{.x} contains@w{ }@samp{1}.
5473 @item .y
5474 @vindex .y
5475 @cindex minor version number register (@code{.y})
5476 @cindex version number, minor, register (@code{.y})
5477 The minor version number.  For example, if the version number is@w{
5478 }1.03 then @code{.y} contains@w{ }@samp{03}.
5480 @item .Y
5481 @vindex .Y
5482 @cindex revision number register (@code{.Y})
5483 The revision number of @code{groff}.
5485 @item $$
5486 @vindex $$
5487 @cindex process ID of @code{gtroff} register (@code{$$})
5488 @cindex @code{gtroff}, process ID register (@code{$$})
5489 The process ID of @code{gtroff}.
5491 @item .g
5492 @vindex .g
5493 @cindex @code{gtroff}, identification register (@code{.g})
5494 @cindex GNU-specific register (@code{.g})
5495 Always@w{ }1.  Macros should use this to determine whether they are
5496 running under GNU @code{troff}.
5498 @item .A
5499 @vindex .A
5500 @cindex @acronym{ASCII} approximation output register (@code{.A})
5501 If the command line option @option{-a} is used to produce an
5502 @acronym{ASCII} approximation of the output, this is set to@w{ }1, zero
5503 otherwise.  @xref{Groff Options}.
5505 @item .P
5506 @vindex .P
5507 This register is set to@w{ }1 (and to@w{ }0 otherwise) if the current
5508 page is actually being printed, i.e., if the @option{-o} option is being
5509 used to only print selected pages.  @xref{Groff Options}, for more
5510 information.
5512 @item .T
5513 @vindex .T
5514 If @code{gtroff} is called with the @option{-T} command line option, the
5515 number register @code{.T} is set to@w{ }1, and zero otherwise.
5516 @xref{Groff Options}.
5518 @stindex .T
5519 @cindex output device name string register (@code{.T})
5520 Additionally, @code{gtroff} predefines a single read-write string
5521 register @code{.T} which contains the current output device (for
5522 example, @samp{latin1} or @samp{ps}).
5523 @end table
5526 @c =====================================================================
5528 @node Manipulating Filling and Adjusting, Manipulating Hyphenation, Registers, gtroff Reference
5529 @section Manipulating Filling and Adjusting
5530 @cindex manipulating filling and adjusting
5531 @cindex filling and adjusting, manipulating
5532 @cindex adjusting and filling, manipulating
5533 @cindex justifying text
5534 @cindex text, justifying
5536 @cindex break
5537 @cindex line break
5538 @cindex @code{bp} request, causing implicit linebreak
5539 @cindex @code{ce} request, causing implicit linebreak
5540 @cindex @code{cf} request, causing implicit linebreak
5541 @cindex @code{fi} request, causing implicit linebreak
5542 @cindex @code{fl} request, causing implicit linebreak
5543 @cindex @code{in} request, causing implicit linebreak
5544 @cindex @code{nf} request, causing implicit linebreak
5545 @cindex @code{rj} request, causing implicit linebreak
5546 @cindex @code{sp} request, causing implicit linebreak
5547 @cindex @code{ti} request, causing implicit linebreak
5548 @cindex @code{trf} request, causing implicit linebreak
5549 Various ways of causing @dfn{breaks} were given in @ref{Implicit Line
5550 Breaks}.  The @code{br} request likewise causes a break.  Several
5551 other requests also cause breaks, but implicitly.  These are
5552 @code{bp}, @code{ce}, @code{cf}, @code{fi}, @code{fl}, @code{in},
5553 @code{nf}, @code{rj}, @code{sp}, @code{ti}, and @code{trf}.
5555 @Defreq {br, }
5556 Break the current line, i.e., the input collected so far is emitted
5557 without adjustment.
5559 If the no-break control character is used, @code{gtroff} suppresses
5560 the break:
5562 @Example
5566     @result{} a b
5567 @endExample
5568 @endDefreq
5570 Initially, @code{gtroff} fills and adjusts text to both margins.
5571 Filling can be disabled via the @code{nf} request and re-enabled with
5572 the @code{fi} request.
5574 @DefreqList {fi, }
5575 @DefregListEnd {.u}
5576 @cindex fill mode (@code{fi})
5577 @cindex mode, fill (@code{fi})
5578 Activate fill mode (which is the default).  This request implicitly
5579 enables adjusting; it also inserts a break in the text currently being
5580 filled.  The read-only number register @code{.u} is set to@w{ }1.
5582 The fill mode status is associated with the current environment
5583 (@pxref{Environments}).
5585 See @ref{Line Control}, for interaction with the @code{\c} escape.
5586 @endDefreq
5588 @Defreq {nf, }
5589 @cindex no-fill mode (@code{nf})
5590 @cindex mode, no-fill (@code{nf})
5591 Activate no-fill mode.  Input lines are output as-is, retaining line
5592 breaks and ignoring the current line length.  This command implicitly
5593 disables adjusting; it also causes a break.  The number register
5594 @code{.u} is set to@w{ }0.
5596 The fill mode status is associated with the current environment
5597 (@pxref{Environments}).
5599 See @ref{Line Control}, for interaction with the @code{\c} escape.
5600 @endDefreq
5602 @DefreqList {ad, [@Var{mode}]}
5603 @DefregListEnd {.j}
5604 Set adjusting mode.
5606 Activation and deactivation of adjusting is done implicitly with
5607 calls to the @code{fi} or @code{nf} requests.
5609 @var{mode} can have one of the following values:
5611 @table @code
5612 @item l
5613 @cindex ragged-right
5614 Adjust text to the left margin.  This produces what is traditionally
5615 called ragged-right text.
5617 @item r
5618 @cindex ragged-left
5619 Adjust text to the right margin, producing ragged-left text.
5621 @item c
5622 @cindex centered text
5623 @cindex @code{ce} request, difference to @samp{.ad@w{ }c}
5624 Center filled text.  This is different to the @code{ce} request which
5625 only centers text without filling.
5627 @item b
5628 @itemx n
5629 Justify to both margins.  This is the default used by @code{gtroff}.
5630 @end table
5632 With no argument, @code{gtroff} adjusts lines in the same way it did
5633 before adjusting was deactivated (with a call to @code{na}, for
5634 example).
5636 @Example
5637 text
5638 .ad r
5639 text
5640 .ad c
5641 text
5643 text
5644 .ad  \" back to centering
5645 text
5646 @endExample
5648 @cindex adjustment mode register (@code{.j})
5649 The current adjustment mode is available in the read-only number
5650 register @code{.j}; it can be stored and subsequently used to set
5651 adjustment.
5653 The adjustment mode status is associated with the current environment
5654 (@pxref{Environments}).
5655 @endDefreq
5657 @Defreq {na, }
5658 Disable adjusting.  This request won't change the current adjustment
5659 mode: A subsequent call to @code{ad} uses the previous adjustment
5660 setting.
5662 The adjustment mode status is associated with the current environment
5663 (@pxref{Environments}).
5664 @endDefreq
5666 @DefreqList {brp, }
5667 @DefescListEnd {\\p, , , }
5668 Adjust the current line and cause a break.
5670 In most cases this produces very ugly results since @code{gtroff}
5671 doesn't have a sophisticated paragraph building algorithm (as @TeX{}
5672 have, for example); instead, @code{gtroff} fills and adjusts a paragraph
5673 line by line:
5675 @Example
5676   This is an uninteresting sentence.
5677   This is an uninteresting sentence.\p
5678   This is an uninteresting sentence.
5679 @endExample
5681 @noindent
5682 is formatted as
5684 @Example
5685   This is  an uninteresting  sentence.   This  is an
5686   uninteresting                            sentence.
5687   This is an uninteresting sentence.
5688 @endExample
5689 @endDefreq
5691 @DefreqList {ss, word_space_size [@Var{sentence_space_size}]}
5692 @DefregItem {.ss}
5693 @DefregListEnd {.sss}
5694 @cindex word space size register (@code{.ss})
5695 @cindex size of word space register (@code{.ss})
5696 @cindex space between words register (@code{.ss})
5697 @cindex sentence space size register (@code{.sss})
5698 @cindex size of sentence space register (@code{.sss})
5699 @cindex space between sentences register (@code{.sss})
5700 Change the minimum size of a space between filled words.  It takes its
5701 units as one twelfth of the space width parameter for the current
5702 font.  Initially both the @var{word_space_size} and
5703 @var{sentence_space_size} are@w{ }12.
5705 @cindex fill mode
5706 @cindex mode, fill
5707 If two arguments are given to the @code{ss} request, the second
5708 argument sets the sentence space size.  If the second argument is not
5709 given, sentence space size is set to @var{word_space_size}.  The
5710 sentence space size is used in two circumstances: If the end of a
5711 sentence occurs at the end of a line in fill mode, then both an
5712 inter-word space and a sentence space are added; if two spaces follow
5713 the end of a sentence in the middle of a line, then the second space
5714 is a sentence space.  If a second argument is never given to the
5715 @code{ss} request, the behaviour of @acronym{UNIX} @code{troff} is the
5716 same as that exhibited by GNU @code{troff}.  In GNU @code{troff}, as
5717 in @acronym{UNIX} @code{troff}, a sentence should always be followed
5718 by either a newline or two spaces.
5720 The read-only number registers @code{.ss} and @code{.sss} hold the
5721 values of the parameters set by the first and second arguments of the
5722 @code{ss} request.
5724 The word space and sentence space values are associated with the current
5725 environment (@pxref{Environments}).
5727 Contrary to @acronym{AT&T} @code{troff}, this request is @emph{not}
5728 ignored if a TTY output device is used; the given values are then
5729 rounded down to a multiple of@w{ }12 (@pxref{Implementation Differences}).
5731 The request is ignored if there is no parameter.
5732 @endDefreq
5734 @DefreqList {ce, [@Var{nnn}]}
5735 @DefregListEnd {.ce}
5736 @cindex centering lines (@code{ce})
5737 @cindex lines, centering (@code{ce})
5738 Center text.  While the @w{@samp{.ad c}} request also centers text,
5739 it fills the text as well.  @code{ce} does not fill the
5740 text it affects.  This request causes a break.  The number of lines
5741 still to be centered is associated with the current environment
5742 (@pxref{Environments}).
5744 The following example demonstrates the differences.
5745 Here the input:
5747 @Example
5748 .ll 4i
5749 .ce 1000
5750 This is a small text fragment which shows the differences
5751 between the `.ce' and the `.ad c' request.
5752 .ce 0
5754 .ad c
5755 This is a small text fragment which shows the differences
5756 between the `.ce' and the `.ad c' request.
5757 @endExample
5759 @noindent
5760 And here the result:
5762 @Example
5763   This is a small text fragment which
5764          shows the differences
5765 between the `.ce' and the `.ad c' request.
5767   This is a small text fragment which
5768 shows the differences between the `.ce'
5769         and the `.ad c' request.
5770 @endExample
5772 With no arguments, @code{ce} centers the next line of text.  @var{nnn}
5773 specifies the number of lines to be centered.  If the argument is zero
5774 or negative, centering is disabled.
5776 The basic length for centering text is the line length (as set with the
5777 @code{ll} request) minus the indentation (as set with the @code{in}
5778 request).  Temporary indentation is ignored.
5780 As can be seen in the previous example, it is a common idiom to turn
5781 on centering for a large number of lines, and to turn off centering
5782 after text to be centered.  This is useful for any request which takes
5783 a number of lines as an argument.
5785 The @code{.ce} read-only number register contains the number of lines
5786 remaining to be centered, as set by the @code{ce} request.
5787 @endDefreq
5789 @DefreqList {rj, [@Var{nnn}]}
5790 @DefregListEnd {.rj}
5791 @cindex justifying text (@code{rj})
5792 @cindex text, justifying (@code{rj})
5793 @cindex right-justifying (@code{rj})
5794 Justify unfilled text to the right margin.  Arguments are identical to
5795 the @code{ce} request.  The @code{.rj} read-only number register is
5796 the number of lines to be right-justified as set by the @code{rj}
5797 request.  This request causes a break.  The number of lines still to be
5798 right-justified is associated with the current environment
5799 (@pxref{Environments}).
5800 @endDefreq
5803 @c =====================================================================
5805 @node Manipulating Hyphenation, Manipulating Spacing, Manipulating Filling and Adjusting, gtroff Reference
5806 @section Manipulating Hyphenation
5807 @cindex manipulating hyphenation
5808 @cindex hyphenation, manipulating
5810 As discussed in @ref{Hyphenation}, @code{gtroff} hyphenates words.
5811 There are a number of ways to influence hyphenation.
5813 @DefreqList {hy, [@Var{mode}]}
5814 @DefregListEnd {.hy}
5815 Enable hyphenation.  The request has an optional numeric argument,
5816 @var{mode}, to restrict hyphenation if necessary:
5818 @table @code
5819 @item 1
5820 The default argument if @var{mode} is omitted.  Hyphenate without
5821 restrictions.  This is also the start-up value of @code{gtroff}.
5823 @item 2
5824 Do not hyphenate the last word on a page or column.
5826 @item 4
5827 Do not hyphenate the last two characters of a word.
5829 @item 8
5830 Do not hyphenate the first two characters of a word.
5831 @end table
5833 Values in the previous table are additive.  For example, the value@w{
5834 }12 causes @code{gtroff} to neither hyphenate the last two nor the first
5835 two characters of a word.
5837 @cindex hyphenation restrictions register (@code{.hy})
5838 The current hyphenation restrictions can be found in the read-only
5839 number register @samp{.hy}.
5841 The hyphenation mode is associated with the current environment
5842 (@pxref{Environments}).
5843 @endDefreq
5845 @Defreq {nh, }
5846 Disable hyphenation (i.e., set the hyphenation mode to zero).  Note
5847 that the hyphenation mode of the last call to @code{hy} is not
5848 remembered.
5850 The hyphenation mode is associated with the current environment
5851 (@pxref{Environments}).
5852 @endDefreq
5854 @DefreqList {hlm, [@Var{nnn}]}
5855 @DefregItem {.hlm}
5856 @DefregListEnd {.hlc}
5857 @cindex explicit hyphen (@code{\%})
5858 @cindex hyphen, explicit (@code{\%})
5859 @cindex consecutive hyphenated lines (@code{hlm})
5860 @cindex lines, consecutive hyphenated (@code{hlm})
5861 @cindex hyphenated lines, consecutive (@code{hlm})
5862 Set the maximum number of consecutive hyphenated lines to @var{nnn}.
5863 If this number is negative, there is no maximum.  The default value
5864 is@w{ }@minus{}1 if @var{nnn} is omitted.  This value is associated
5865 with the current environment (@pxref{Environments}).  Only lines
5866 output from a given environment count towards the maximum associated
5867 with that environment.  Hyphens resulting from @code{\%} are counted;
5868 explicit hyphens are not.
5870 The current setting of @code{hlm} is available in the @code{.hlm}
5871 read-only number register.  Also the number of immediately preceding
5872 consecutive hyphenated lines are available in the read-only number
5873 register @samp{.hlc}.
5874 @endDefreq
5876 @Defreq {hw, word1 word2 @dots{}}
5877 Define how @var{word1}, @var{word2}, etc.@: are to be hyphenated.  The
5878 words must be given with hyphens at the hyphenation points.  For
5879 example:
5881 @Example
5882 .hw in-sa-lub-rious
5883 @endExample
5885 @noindent
5886 Besides the space character, any character whose hyphenation code value
5887 is zero can be used to separate the arguments of @code{hw} (see the
5888 documentation for the @code{hcode} request below for more information).
5889 In addition, this request can be used more than once.
5891 Hyphenation exceptions specified with the @code{hw} request are
5892 associated with the current hyphenation language; it causes an error
5893 if there is no current hyphenation language.
5895 This request is ignored if there is no parameter.
5897 In old versions of @code{troff} there was a limited amount of space to
5898 store such information; fortunately, with @code{gtroff}, this is no
5899 longer a restriction.
5900 @endDefreq
5902 @DefescList {\\%, , , }
5903 @deffnx Escape @t{\:}
5904 @ifnotinfo
5905 @esindex \:
5906 @end ifnotinfo
5907 @ifinfo
5908 @esindex @r{<colon>}
5909 @end ifinfo
5910 @cindex hyphenation character (@code{\%})
5911 @cindex character, hyphenation (@code{\%})
5912 @cindex disabling hyphenation (@code{\%})
5913 @cindex hyphenation, disabling (@code{\%})
5914 To tell @code{gtroff} how to hyphenate words on the fly, use the
5915 @code{\%} escape, also known as the @dfn{hyphenation character}.
5916 Preceding a word with this character prevents it from being
5917 hyphenated; putting it inside a word indicates to @code{gtroff} that
5918 the word may be hyphenated at that point.  Note that this mechanism
5919 only affects that one occurrence of the word; to change the
5920 hyphenation of a word for the entire document, use the @code{hw}
5921 request.
5923 The @code{\:} escape inserts a zero-width break point
5924 (that is, the word breaks but without adding a hyphen).
5926 @Example
5927 ... check the /var/log/\:httpd/\:access_log file ...
5928 @endExample
5930 @cindex @code{\X}, followed by @code{\%}
5931 @cindex @code{\Y}, followed by @code{\%}
5932 @cindex @code{\%}, following @code{\X} or @code{\Y}
5933 Note that @code{\X} and @code{\Y} start a word, that is, the @code{\%}
5934 escape in (say) @w{@samp{ \X'...'\%foobar}} and
5935 @w{@samp{ \Y'...'\%foobar}} no longer prevents hyphenation but inserts
5936 a hyphenation point at the beginning of @samp{foobar}; most likely
5937 this isn't what you want to do.
5938 @endDefesc
5940 @Defreq {hc, [@Var{char}]}
5941 Change the hyphenation character to @var{char}.  This character then
5942 works the same as the @code{\%} escape, and thus, no longer appears in
5943 the output.  Without an argument, @code{hc} resets the hyphenation
5944 character to be @code{\%} (the default) only.
5946 The hyphenation character is associated with the current environment
5947 (@pxref{Environments}).
5948 @endDefreq
5950 @DefreqList {hpf, pattern_file}
5951 @DefreqItem {hpfa, pattern_file}
5952 @DefreqListEnd {hpfcode, a b [c d @dots{}]}
5953 @cindex hyphenation patterns (@code{hpf})
5954 @cindex patterns for hyphenation (@code{hpf})
5955 Read in a file of hyphenation patterns.  This file is searched for in
5956 the same way as @file{@var{name}.tmac} (or @file{tmac.@var{name}}) is
5957 searched for if the @option{-m@var{name}} option is specified.
5959 It should have the same format as (simple) @TeX{} patterns files.
5960 More specifically, the following scanning rules are implemented.
5962 @itemize @bullet
5963 @item
5964 A percent sign starts a comment (up to the end of the line)
5965 even if preceded by a backslash.
5967 @item
5968 No support for `digraphs' like @code{\$}.
5970 @item
5971 @code{^^@var{xx}} (@var{x} is 0-9 or a-f) and @code{^^@var{x}} (character
5972 code of @var{x} in the range 0-127) are recognized; other use of @code{^}
5973 causes an error.
5975 @item
5976 No macro expansion.
5978 @item
5979 @code{hpf} checks for the expression @code{\patterns@{@dots{}@}}
5980 (possibly with whitespace before and after the braces).
5981 Everything between the braces is taken as hyphenation patterns.
5982 Consequently, @code{@{} and @code{@}} are not allowed in patterns.
5984 @item
5985 Similarly, @code{\hyphenation@{@dots{}@}} gives a list of hyphenation
5986 exceptions.
5988 @item
5989 @code{\endinput} is recognized also.
5991 @item
5992 For backwards compatibility, if @code{\patterns} is missing,
5993 the whole file is treated as a list of hyphenation patterns
5994 (only recognizing the @code{%} character as the start of a comment).
5995 @end itemize
5997 If no @code{hpf} request is specified (either in the document or in a
5998 macro package), @code{gtroff} won't hyphenate at all.
6000 The @code{hpfa} request appends a file of patterns to the current list.
6002 The @code{hpfcode} request defines mapping values for character codes in
6003 hyphenation patterns.  @code{hpf} or @code{hpfa} then apply the mapping
6004 (after reading the patterns) before replacing or appending them to
6005 the current list of patterns.  Its arguments are pairs of character codes
6006 -- integers from 0 to@w{ }255.  The request maps character code@w{ }@var{a}
6007 to code@w{ }@var{b}, code@w{ }@var{c} to code@w{ }@var{d}, and so on.  You
6008 can use character codes which would be invalid otherwise.
6010 @pindex troffrc
6011 @pindex troffrc-end
6012 @pindex hyphen.us
6013 The set of hyphenation patterns is associated with the current language
6014 set by the @code{hla} request.  The @code{hpf} request is usually
6015 invoked by the @file{troffrc} or @file{troffrc-end} file; by default,
6016 @file{troffrc} loads hyphenation patterns for American English (in file
6017 @file{hyphen.us}).
6019 A second call to @code{hpf} (for the same language) will replace the
6020 hyphenation patterns with the new ones.
6022 Invoking @code{hpf} causes an error if there is no current hyphenation
6023 language.
6024 @endDefreq
6026 @Defreq {hcode, c1 code1 c2 code2 @dots{}}
6027 @cindex hyphenation code (@code{hcode})
6028 @cindex code, hyphenation (@code{hcode})
6029 Set the hyphenation code of character @var{c1} to @var{code1}, that of
6030 @var{c2} to @var{code2}, etc.  A hyphenation code must be a single
6031 input character (not a special character) other than a digit or a
6032 space.  Initially each lower-case letter (@samp{a}-@samp{z}) has its
6033 hyphenation code set to itself, and each upper-case letter
6034 (@samp{A}-@samp{Z}) has a hyphenation code which is the lower-case
6035 version of itself.
6037 This request is ignored if it has no parameter.
6038 @endDefreq
6040 @DefreqList {hym, [@Var{length}]}
6041 @DefregListEnd {.hym}
6042 @cindex hyphenation margin (@code{hym})
6043 @cindex margin for hyphenation (@code{hym})
6044 @cindex @code{ad} request, and hyphenation margin
6045 Set the (right) hyphenation margin to @var{length}.  If the current
6046 adjustment mode is not @samp{b} or @samp{n}, the line is not
6047 hyphenated if it is shorter than @var{length}.  Without an argument,
6048 the hyphenation margin is reset to its default value, which is@w{ }0.
6049 The default scaling indicator for this request is @samp{m}.  The
6050 hyphenation margin is associated with the current environment
6051 (@pxref{Environments}).
6053 A negative argument resets the hyphenation margin to zero, emitting
6054 a warning of type @samp{range}.
6056 @cindex hyphenation margin register (@code{.hym})
6057 The current hyphenation margin is available in the @code{.hym} read-only
6058 number register.
6059 @endDefreq
6061 @DefreqList {hys, [@Var{hyphenation_space}]}
6062 @DefregListEnd {.hys}
6063 @cindex hyphenation space (@code{hys})
6064 @cindex @code{ad} request, and hyphenation space
6065 Set the hyphenation space to @var{hyphenation_space}.  If the current
6066 adjustment mode is @samp{b} or @samp{n}, don't hyphenate the line
6067 if it can be justified by adding no more than @var{hyphenation_space}
6068 extra space to each word space.  Without argument, the hyphenation
6069 space is set to its default value, which is@w{ }0.  The default
6070 scaling indicator for this request is @samp{m}.  The hyphenation
6071 space is associated with the current environment
6072 (@pxref{Environments}).
6074 A negative argument resets the hyphenation space to zero, emitting a
6075 warning of type @samp{range}.
6077 @cindex hyphenation space register (@code{.hys})
6078 The current hyphenation space is available in the @code{.hys} read-only
6079 number register.
6080 @endDefreq
6082 @Defreq {shc, [@Var{glyph}]}
6083 @cindex soft hyphen character, setting (@code{shc})
6084 @cindex character, soft hyphen, setting (@code{shc})
6085 @cindex glyph, soft hyphen (@code{hy})
6086 @cindex soft hyphen glyph (@code{hy})
6087 @cindex @code{char} request, and soft hyphen character
6088 @cindex @code{tr} request, and soft hyphen character
6089 Set the @dfn{soft hyphen character} to @var{glyph}.@footnote{@dfn{Soft
6090 hyphen character} is a misnomer since it is an output glyph.}  If the
6091 argument is omitted, the soft hyphen character is set to the default
6092 glyph @code{\(hy} (this is the start-up value of @code{gtroff} also).
6093 The soft hyphen character is the glyph that is inserted when a word is
6094 hyphenated at a line break.  If the soft hyphen character does not
6095 exist in the font of the character immediately preceding a potential
6096 break point, then the line is not broken at that point.  Neither
6097 definitions (specified with the @code{char} request) nor translations
6098 (specified with the @code{tr} request) are considered when finding the
6099 soft hyphen character.
6100 @endDefreq
6102 @DefreqList {hla, language}
6103 @DefregListEnd {.hla}
6104 @cindex @code{hpf} request, and hyphenation language
6105 @cindex @code{hw} request, and hyphenation language
6106 @pindex troffrc
6107 @pindex troffrc-end
6108 Set the current hyphenation language to the string @var{language}.
6109 Hyphenation exceptions specified with the @code{hw} request and
6110 hyphenation patterns specified with the @code{hpf} and @code{hpfa}
6111 requests are both associated with the current hyphenation language.
6112 The @code{hla} request is usually invoked by the @file{troffrc} or the
6113 @file{troffrc-end} files; @file{troffrc} sets the default language to
6114 @samp{us}.
6116 @cindex hyphenation language register (@code{.hla})
6117 The current hyphenation language is available as a string in the
6118 read-only number register @samp{.hla}.
6120 @Example
6121 .ds curr_language \n[.hla]
6122 \*[curr_language]
6123     @result{} us
6124 @endExample
6125 @endDefreq
6128 @c =====================================================================
6130 @node Manipulating Spacing, Tabs and Fields, Manipulating Hyphenation, gtroff Reference
6131 @section Manipulating Spacing
6132 @cindex manipulating spacing
6133 @cindex spacing, manipulating
6135 @Defreq {sp, [@Var{distance}]}
6136 Space downwards @var{distance}.  With no argument it advances 1@w{
6137 }line.  A negative argument causes @code{gtroff} to move up the page
6138 the specified distance.  If the argument is preceded by a @samp{|}
6139 then @code{gtroff} moves that distance from the top of the page.  This
6140 request causes a line break.  The default scaling indicator is @samp{v}.
6141 @endDefreq
6143 @DefreqList {ls, [@Var{nnn}]}
6144 @DefregListEnd {.L}
6145 @cindex double-spacing (@code{ls})
6146 Output @w{@var{nnn}@minus{}1} blank lines after each line of text.
6147 With no argument, @code{gtroff} uses the previous value before the
6148 last @code{ls} call.
6150 @Example
6151 .ls 2    \" This causes double-spaced output
6152 .ls 3    \" This causes triple-spaced output
6153 .ls      \" Again double-spaced
6154 @endExample
6156 The line spacing is associated with the current environment
6157 (@pxref{Environments}).
6159 @cindex line spacing register (@code{.L})
6160 The read-only number register @code{.L} contains the current line
6161 spacing setting.
6162 @endDefreq
6164 @xref{Changing Type Sizes}, for the requests @code{vs} and @code{pvs}
6165 as alternatives to @code{ls}.
6167 @DefescList {\\x, ', spacing, '}
6168 @DefregListEnd {.a}
6169 Sometimes, extra vertical spacing is only needed occasionally, e.g.@:
6170 to allow space for a tall construct (like an equation).  The @code{\x}
6171 escape does this.  The escape is given a numerical argument, usually
6172 enclosed in quotes (like @samp{\x'3p'}); the default scaling indicator
6173 is @samp{v}.  If this number is positive extra vertical space is
6174 inserted below the current line.  A negative number adds space above.
6175 If this escape is used multiple times on the same line, the maximum of
6176 the values is used.
6178 @xref{Escapes}, for details on parameter delimiting characters.
6180 @cindex extra post-vertical line space register (@code{.a})
6181 The @code{.a} read-only number register contains the most recent
6182 (nonnegative) extra vertical line space.
6184 Using @code{\x} can be necessary in combination with the @code{\b}
6185 escape, as the following example shows.
6187 @Example
6188 This is a test with the \[rs]b escape.
6190 This is a test with the \[rs]b escape.
6192 This is a test with \b'xyz'\x'-1m'\x'1m'.
6194 This is a test with the \[rs]b escape.
6196 This is a test with the \[rs]b escape.
6197 @endExample
6199 @noindent
6200 produces
6202 @Example
6203 This is a test with the \b escape.
6204 This is a test with the \b escape.
6205                     x
6206 This is a test with y.
6207                     z
6208 This is a test with the \b escape.
6209 This is a test with the \b escape.
6210 @endExample
6211 @endDefesc
6213 @DefreqList {ns, }
6214 @DefreqItem {rs, }
6215 @DefregListEnd {.ns}
6216 @cindex @code{sp} request, and no-space mode
6217 @cindex no-space mode (@code{ns})
6218 @cindex mode, no-space (@code{ns})
6219 @cindex blank lines, disabling
6220 @cindex lines, blank, disabling
6221 Enable @dfn{no-space mode}.  In this mode, spacing (either via
6222 @code{sp} or via blank lines) is disabled.  The @code{bp} request to
6223 advance to the next page is also disabled, except if it is accompanied
6224 by a page number (see @ref{Page Control}, for more information).  This
6225 mode ends when actual text is output or the @code{rs} request is
6226 encountered which ends no-space mode.  The read-only number register
6227 @code{.ns} is set to@w{ }1 as long as no-space mode is active.
6229 This request is useful for macros that conditionally
6230 insert vertical space before the text starts
6231 (for example, a paragraph macro could insert some space
6232 except when it is the first paragraph after a section header).
6233 @endDefreq
6236 @c =====================================================================
6238 @node Tabs and Fields, Character Translations, Manipulating Spacing, gtroff Reference
6239 @section Tabs and Fields
6240 @cindex tabs, and fields
6241 @cindex fields, and tabs
6243 @cindex @acronym{EBCDIC} encoding of a tab
6244 A tab character (@acronym{ASCII} char@w{ }9, @acronym{EBCDIC} char@w{
6245 }5) causes a horizontal movement to the next tab stop (much
6246 like it did on a typewriter).
6248 @Defesc {\\t, , , }
6249 @cindex tab character, non-interpreted (@code{\t})
6250 @cindex character, tab, non-interpreted (@code{\t})
6251 This escape is a non-interpreted tab character.  In copy mode
6252 (@pxref{Copy-in Mode}), @code{\t} is the same as a real tab character.
6253 @endDefesc
6255 @DefreqList {ta, [@Var{n1} @Var{n2} @dots{} @Var{nn} @t{T} @Var{r1} @Var{r2} @dots{} @Var{rn}]}
6256 @DefregListEnd {.tabs}
6257 Change tab stop positions.  This request takes a series of tab
6258 specifiers as arguments (optionally divided into two groups with the
6259 letter @samp{T}) which indicate where each tab stop is to be
6260 (overriding any previous settings).
6262 Tab stops can be specified absolutely, i.e., as the distance from the
6263 left margin.  For example, the following sets 6@w{ }tab stops every
6264 one inch.
6266 @Example
6267 .ta 1i 2i 3i 4i 5i 6i
6268 @endExample
6270 Tab stops can also be specified using a leading @samp{+}
6271 which means that the specified tab stop is set relative to
6272 the previous tab stop.  For example, the following is equivalent to the
6273 previous example.
6275 @Example
6276 .ta 1i +1i +1i +1i +1i +1i
6277 @endExample
6279 @code{gtroff} supports an extended syntax to specify repeat values after
6280 the @samp{T} mark (these values are always taken as relative) -- this is
6281 the usual way to specify tabs set at equal intervals.  The following is,
6282 yet again, the same as the previous examples.  It does even more since
6283 it defines an infinite number of tab stops separated by one inch.
6285 @Example
6286 .ta T 1i
6287 @endExample
6289 Now we are ready to interpret the full syntax given at the beginning:
6290 Set tabs at positions @var{n1}, @var{n2}, @dots{}, @var{nn} and then set
6291 tabs at @var{nn}+@var{r1}, @var{nn}+@var{r2}, @dots{}, @var{nn}+@var{rn}
6292 and then at @var{nn}+@var{rn}+@var{r1}, @var{nn}+@var{rn}+@var{r2},
6293 @dots{}, @var{nn}+@var{rn}+@var{rn}, and so on.
6295 Example: @samp{4c +6c T 3c 5c 2c} is equivalent to @samp{4c 10c 13c 18c
6296 20c 23c 28c 30c @dots{}}.
6298 The material in each tab column (i.e., the column between two tab stops)
6299 may be justified to the right or left or centered in the column.  This
6300 is specified by appending @samp{R}, @samp{L}, or @samp{C} to the tab
6301 specifier.  The default justification is @samp{L}.  Example:
6303 @Example
6304 .ta 1i 2iC 3iR
6305 @endExample
6307 Some notes:
6309 @itemize @bullet
6310 @item
6311 The default unit of the @code{ta} request is @samp{m}.
6313 @item
6314 A tab stop is converted into a non-breakable horizontal movement which
6315 can be neither stretched nor squeezed.  For example,
6317 @Example
6318 .ds foo a\tb\tc
6319 .ta T 5i
6320 \*[foo]
6321 @endExample
6323 @noindent
6324 creates a single line which is a bit longer than 10@w{ }inches (a string
6325 is used to show exactly where the tab characters are).  Now consider the
6326 following:
6328 @Example
6329 .ds bar a\tb b\tc
6330 .ta T 5i
6331 \*[bar]
6332 @endExample
6334 @noindent
6335 @code{gtroff} first converts the tab stops of the line into unbreakable
6336 horizontal movements, then splits the line after the second @samp{b}
6337 (assuming a sufficiently short line length).  Usually, this isn't what
6338 the user wants.
6340 @item
6341 Superfluous tabs (i.e., tab characters which do not correspond to a tab
6342 stop) are ignored except the first one which delimits the characters
6343 belonging to the last tab stop for right-justifying or centering.
6344 Consider the following example
6346 @Example
6347 .ds Z   foo\tbar\tfoo
6348 .ds ZZ  foo\tbar\tfoobar
6349 .ds ZZZ foo\tbar\tfoo\tbar
6350 .ta 2i 4iR
6351 \*[Z]
6353 \*[ZZ]
6355 \*[ZZZ]
6357 @endExample
6359 @noindent
6360 which produces the following output:
6362 @Example
6363 foo                 bar              foo
6364 foo                 bar           foobar
6365 foo                 bar              foobar
6366 @endExample
6368 @noindent
6369 The first line right-justifies the second `foo' relative to the tab
6370 stop.  The second line right-justifies `foobar'.  The third line finally
6371 right-justifies only `foo' because of the additional tab character which
6372 marks the end of the string belonging to the last defined tab stop.
6374 @item
6375 Tab stops are associated with the current environment
6376 (@pxref{Environments}).
6378 @item
6379 Calling @code{ta} without an argument removes all tab stops.
6381 @item
6382 @cindex tab stops, for TTY output devices
6383 The start-up value of @code{gtroff} is @w{@samp{T 0.5i}} in troff mode
6384 and @w{@samp{T 0.8i}} in nroff mode (the latter is done with an
6385 explicit call to the @code{ta} request in the file @file{tty.tmac}.
6386 @end itemize
6388 @cindex tab settings register (@code{.tabs})
6389 The read-only number register @code{.tabs} contains a string
6390 representation of the current tab settings suitable for use as an
6391 argument to the @code{ta} request.
6393 @Example
6394 .ds tab-string \n[.tabs]
6395 \*[tab-string]
6396     @result{} T120u
6397 @endExample
6399 @cindex @code{.S} register, Plan@w{ }9 alias for @code{.tabs}
6400 @cindex @code{.tabs} register, Plan@w{ }9 alias (@code{.S})
6401 The @code{troff} version of the Plan@w{ }9 operating system uses
6402 register @code{.S} for the same purpose.
6403 @endDefreq
6405 @Defreq {tc, [@Var{fill-glyph}]}
6406 @cindex tab repetition character (@code{tc})
6407 @cindex character, tab repetition (@code{tc})
6408 @cindex glyph, tab repetition (@code{tc})
6409 Normally @code{gtroff} fills the space to the next tab stop with
6410 whitespace.  This can be changed with the @code{tc} request.  With no
6411 argument @code{gtroff} reverts to using whitespace, which is the
6412 default.  The value of this @dfn{tab repetition character} is
6413 associated with the current environment
6414 (@pxref{Environments}).@footnote{@dfn{Tab repetition character} is a
6415 misnomer since it is an output glyph.}
6416 @endDefreq
6418 @DefreqList {linetabs, n}
6419 @DefregListEnd {.linetabs}
6420 @cindex tab, line-tabs mode
6421 @cindex line-tabs mode
6422 @cindex mode, line-tabs
6423 If @var{n} is missing or not zero, enable @dfn{line-tabs} mode,
6424 or disable it otherwise (the default).
6425 In line-tabs mode, @code{gtroff} computes tab distances
6426 relative to the (current) output line instead of the input line.
6428 For example, the following code:
6430 @Example
6431 .ds x a\t\c
6432 .ds y b\t\c
6433 .ds z c
6434 .ta 1i 3i
6438 @endExample
6440 @noindent
6441 in normal mode, results in the output
6443 @Example
6444 a         b         c
6445 @endExample
6447 @noindent
6448 in line-tabs mode, the same code outputs
6450 @Example
6451 a         b                   c
6452 @endExample
6454 Line-tabs mode is associated with the current environment.
6455 The read-only register @code{.linetabs} is set to@w{ }1 if in line-tabs
6456 mode, and 0 in normal mode.
6457 @endDefreq
6459 @menu
6460 * Leaders::
6461 * Fields::
6462 @end menu
6464 @c ---------------------------------------------------------------------
6466 @node Leaders, Fields, Tabs and Fields, Tabs and Fields
6467 @subsection Leaders
6468 @cindex leaders
6470 Sometimes it may may be desirable to use the @code{tc} request to fill a
6471 particular tab stop with a given glyph (for example dots in a table
6472 of contents), but also normal tab stops on the rest of the line.  For
6473 this @code{gtroff} provides an alternate tab mechanism, called
6474 @dfn{leaders} which does just that.
6476 @cindex leader character
6477 A leader character (character code@w{ }1) behaves similarly to a tab
6478 character: It moves to the next tab stop.  The only difference is that
6479 for this movement, the fill glyph defaults to a period character and
6480 not to space.
6482 @Defesc {\\a, , , }
6483 @cindex leader character, non-interpreted (@code{\a})
6484 @cindex character, leader, non-interpreted (@code{\a})
6485 This escape is a non-interpreted leader character.  In copy mode
6486 (@pxref{Copy-in Mode}), @code{\a} is the same as a real leader
6487 character.
6488 @endDefesc
6490 @Defreq {lc, [@Var{fill-glyph}]}
6491 @cindex leader repetition character (@code{lc})
6492 @cindex character, leader repetition (@code{lc})
6493 @cindex glyph, leader repetition (@code{lc})
6494 Declare the @dfn{leader repetition character}.@footnote{@dfn{Leader
6495 repetition character} is a misnomer since it is an output glyph.}
6496 Without an argument, leaders act the same as tabs (i.e., using
6497 whitespace for filling).  @code{gtroff}'s start-up value is a dot
6498 (@samp{.}).  The value of the leader repetition character is
6499 associated with the current environment (@pxref{Environments}).
6500 @endDefreq
6502 @cindex table of contents
6503 @cindex contents, table of
6504 For a table of contents, to name an example, tab stops may be defined so
6505 that the section number is one tab stop, the title is the second with
6506 the remaining space being filled with a line of dots, and then the page
6507 number slightly separated from the dots.
6509 @Example
6510 .ds entry 1.1\tFoo\a\t12
6511 .lc .
6512 .ta 1i 5i +.25i
6513 \*[entry]
6514 @endExample
6516 @noindent
6517 This produces
6519 @Example
6520 1.1  Foo..........................................  12
6521 @endExample
6523 @c ---------------------------------------------------------------------
6525 @node Fields,  , Leaders, Tabs and Fields
6526 @subsection Fields
6527 @cindex fields
6529 @cindex field delimiting character (@code{fc})
6530 @cindex delimiting character, for fields (@code{fc})
6531 @cindex character, field delimiting (@code{fc})
6532 @cindex field padding character (@code{fc})
6533 @cindex padding character, for fields (@code{fc})
6534 @cindex character, field padding (@code{fc})
6535 @dfn{Fields} are a more general way of laying out tabular data.  A field
6536 is defined as the data between a pair of @dfn{delimiting characters}.
6537 It contains substrings which are separated by @dfn{padding characters}.
6538 The width of a field is the distance on the @emph{input} line from the
6539 position where the field starts to the next tab stop.  A padding
6540 character inserts stretchable space similar to @TeX{}'s @code{\hss}
6541 command (thus it can even be negative) to make the sum of all substring
6542 lengths plus the stretchable space equal to the field width.  If more
6543 than one padding character is inserted, the available space is evenly
6544 distributed among them.
6546 @Defreq {fc, [@Var{delim-char} [@Var{padding-char}]]}
6547 Define a delimiting and a padding character for fields.  If the latter
6548 is missing, the padding character defaults to a space character.  If
6549 there is no argument at all, the field mechanism is disabled (which is
6550 the default).  Note that contrary to e.g.@: the tab repetition
6551 character, delimiting and padding characters are @emph{not} associated
6552 to the current environment (@pxref{Environments}).
6554 Example:
6556 @Example
6557 .fc # ^
6558 .ta T 3i
6559 #foo^bar^smurf#
6561 #foo^^bar^smurf#
6562 @endExample
6564 @noindent
6565 and here the result:
6567 @Example
6568 foo         bar          smurf
6569 foo            bar       smurf
6570 @endExample
6571 @endDefreq
6574 @c =====================================================================
6576 @node Character Translations, Troff and Nroff Mode, Tabs and Fields, gtroff Reference
6577 @section Character Translations
6578 @cindex character translations
6579 @cindex translations of characters
6581 @cindex control character, changing (@code{cc})
6582 @cindex character, control, changing (@code{cc})
6583 @cindex no-break control character, changing (@code{c2})
6584 @cindex character, no-break control, changing (@code{c2})
6585 @cindex control character, no-break, changing (@code{c2})
6586 The control character (@samp{.}) and the no-break control character
6587 (@samp{'}) can be changed with the @code{cc} and @code{c2} requests,
6588 respectively.
6590 @Defreq {cc, [@Var{c}]}
6591 Set the control character to@w{ }@var{c}.  With no argument the default
6592 control character @samp{.} is restored.  The value of the control
6593 character is associated with the current environment
6594 (@pxref{Environments}).
6595 @endDefreq
6597 @Defreq {c2, [@Var{c}]}
6598 Set the no-break control character to@w{ }@var{c}.  With no argument the
6599 default control character @samp{'} is restored.  The value of the
6600 no-break control character is associated with the current environment
6601 (@pxref{Environments}).
6602 @endDefreq
6604 @Defreq {eo, }
6605 @cindex disabling @code{\} (@code{eo})
6606 @cindex @code{\}, disabling (@code{eo})
6607 Disable the escape mechanism completely.  After executing this
6608 request, the backslash character @samp{\} no longer starts an escape
6609 sequence.
6611 This request can be very helpful in writing macros since it is not
6612 necessary then to double the escape character.  Here an example:
6614 @Example
6615 .\" This is a simplified version of the
6616 .\" .BR request from the man macro package
6618 .de BR
6619 .  ds result \&
6620 .  while (\n[.$] >= 2) \@{\
6621 .    as result \fB\$1\fR\$2
6622 .    shift 2
6623 .  \@}
6624 .  if \n[.$] .as result \fB\$1
6625 \*[result]
6626 .  ft R
6629 @endExample
6630 @endDefreq
6632 @Defreq {ec, [@Var{c}]}
6633 @cindex escape character, changing (@code{ec})
6634 @cindex character, escape, changing (@code{ec})
6635 Set the escape character to@w{ }@var{c}.  With no argument the default
6636 escape character @samp{\} is restored.  It can be also used to
6637 re-enable the escape mechanism after an @code{eo} request.
6639 Note that changing the escape character globally will likely break
6640 macro packages since @code{gtroff} has no mechanism to `intern' macros,
6641 i.e., to convert a macro definition into an internal form which is
6642 independent of its representation (@TeX{} has this mechanism).
6643 If a macro is called, it is executed literally.
6644 @endDefreq
6646 @DefreqList {ecs, }
6647 @DefreqListEnd {ecr, }
6648 The @code{ecs} request saves the current escape character
6649 in an internal register.
6650 Use this request in combination with the @code{ec} request to
6651 temporarily change the escape character.
6653 The @code{ecr} request restores the escape character
6654 saved with @code{ecs}.
6655 Without a previous call to @code{ecs}, this request
6656 sets the escape character to @code{\}.
6657 @endDefreq
6659 @DefescList {\\\\, , , }
6660 @DefescItem {\\e, , , }
6661 @DefescListEnd {\\E, , , }
6662 Print the current escape character (which is the backslash character
6663 @samp{\} by default).
6665 @code{\\} is a `delayed' backslash; more precisely, it is the default
6666 escape character followed by a backslash, which no longer has special
6667 meaning due to the leading escape character.  It is @emph{not} an escape
6668 sequence in the usual sense!  In any unknown escape sequence
6669 @code{\@var{X}} the escape character is ignored and @var{X} is printed.
6670 But if @var{X} is equal to the current escape character, no warning is
6671 emitted.
6673 As a consequence, only at top-level or in a diversion a backslash glyph is
6674 printed; in copy-in mode, it expands to a single backslash which then
6675 combines with the following character to an escape sequence.
6677 The @code{\E} escape differs from @code{\e} by printing an escape
6678 character that is not interpreted in copy mode.
6679 Use this to define strings with escapes that work
6680 when used in copy mode (for example, as a macro argument).
6681 The following example defines strings to begin and end
6682 a superscript:
6684 @Example
6685 .ds @{ \v'-.3m'\s'\Es[.s]*60/100'
6686 .ds @} \s0\v'.3m'
6687 @endExample
6689 Another example to demonstrate the differences between the various escape
6690 sequences, using a strange escape character, @samp{-}.
6692 @Example
6693 .ec -
6694 .de xxx
6695 --A'123'
6697 .xxx
6698     @result{} -A'foo'
6699 @endExample
6701 @noindent
6702 The result is surprising for most users, expecting @samp{1} since
6703 @samp{foo} is a valid identifier.  What has happened?  As mentioned
6704 above, the leading escape character makes the following character
6705 ordinary.  Written with the default escape character the sequence
6706 @samp{--} becomes @samp{\-} -- this is the minus sign.
6708 If the escape character followed by itself is a valid escape sequence,
6709 only @code{\E} yields the expected result:
6711 @Example
6712 .ec -
6713 .de xxx
6714 -EA'123'
6716 .xxx
6717     @result{} 1
6718 @endExample
6719 @endDefesc
6721 @Defesc {\\., , , }
6722 Similar to @code{\\}, the sequence @code{\.} isn't a real escape sequence.
6723 As before, a warning message is suppressed if the escape character is
6724 followed by a dot, and the dot itself is printed.
6726 @Example
6727 .de foo
6728 .  nop foo
6730 .  de bar
6731 .    nop bar
6732 \\..
6735 .foo
6736 .bar
6737     @result{} foo bar
6738 @endExample
6740 @noindent
6741 The first backslash is consumed while the macro is read, and the second
6742 is swallowed while exexuting macro @code{foo}.
6743 @endDefesc
6745 A @dfn{translation} is a mapping of an input character to an output
6746 glyph.  The mapping occurs at output time, i.e., the input character
6747 gets assigned the metric information of the mapped output character
6748 right before input tokens are converted to nodes (@pxref{Gtroff
6749 Internals}, for more on this process).
6751 @DefreqList {tr, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
6752 @DefreqListEnd {trin, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
6753 Translate character @var{a} to glyph@w{ }@var{b}, character @var{c} to
6754 glyph@w{ }@var{d}, etc.  If there is an odd number of arguments, the
6755 last one is translated to an unstretchable space (@samp{\ }).
6757 The @code{trin} request is identical to @code{tr},
6758 but when you unformat a diversion with @code{asciify}
6759 it ignores the translation.
6760 @xref{Diversions}, for details about the @code{asciify} request.
6762 Some notes:
6764 @itemize @bullet
6765 @item
6766 @cindex @code{\(}, and translations
6767 @cindex @code{\[}, and translations
6768 @cindex @code{\'}, and translations
6769 @cindex @code{\`}, and translations
6770 @cindex @code{\-}, and translations
6771 @cindex @code{\_}, and translations
6772 @cindex @code{\C}, and translations
6773 @cindex @code{\N}, and translations
6774 @cindex @code{char} request, and translations
6775 @cindex special characters
6776 @cindex character, special
6777 @cindex numbered glyph (@code{\N})
6778 @cindex glyph, numbered (@code{\N})
6779 Special characters (@code{\(@var{xx}}, @code{\[@var{xxx}]},
6780 @code{\C'@var{xxx}'}, @code{\'}, @code{\`}, @code{\-}, @code{\_}),
6781 glyphs defined with the @code{char} request, and numbered glyphs
6782 (@code{\N'@var{xxx}'}) can be translated also.
6784 @item
6785 @cindex @code{\e}, and translations
6786 The @code{\e} escape can be translated also.
6788 @item
6789 @cindex @code{\%}, and translations
6790 @cindex @code{\~}, and translations
6791 Characters can be mapped onto the @code{\%} and @code{\~} escapes (but
6792 @code{\%} and @code{\~} can't be mapped onto another glyph).
6794 @item
6795 @cindex backspace character, and translations
6796 @cindex character, backspace, and translations
6797 @cindex leader character, and translations
6798 @cindex character, leader, and translations
6799 @cindex newline character, and translations
6800 @cindex character, newline, and translations
6801 @cindex tab character, and translations
6802 @cindex character, tab, and translations
6803 @cindex @code{\a}, and translations
6804 @cindex @code{\t}, and translations
6805 The following characters can't be translated: space (with one exception,
6806 see below), backspace, newline, leader (and @code{\a}), tab (and
6807 @code{\t}).
6809 @item
6810 @cindex @code{shc} request, and translations
6811 Translations are not considered for finding the soft hyphen character
6812 set with the @code{shc} request.
6814 @item
6815 @cindex @code{\&}, and translations
6816 The pair @samp{@var{c}\&} (this is an arbitrary character@w{
6817 }@var{c} followed by the zero width space character) maps this
6818 character to nothing.
6820 @Example
6821 .tr a\&
6822 foo bar
6823     @result{} foo br
6824 @endExample
6826 @noindent
6827 It is even possible to map the space character to nothing:
6829 @Example
6830 .tr aa \&
6831 foo bar
6832     @result{} foobar
6833 @endExample
6835 @noindent
6836 As shown in the example, the space character can't be the first
6837 character/glyph pair as an argument of @code{tr}.  Additionally, it is
6838 not possible to map the space character to any other glyph; requests
6839 like @w{@samp{.tr aa x}} undo @w{@samp{.tr aa \&}} instead.
6841 If justification is active, lines are justified in spite of the
6842 `empty' space character (but there is no minimal distance, i.e.@: the
6843 space character, between words).
6845 @item
6846 After an output glyph has been constructed (this happens at the
6847 moment immediately before the glyph is appended to an output
6848 glyph list, either by direct output, in a macro, diversion, or
6849 string), it is no longer affected by @code{tr}.
6851 @item
6852 Translating character to glyphs where one of them or both are
6853 undefined is possible also; @code{tr} does not check whether the
6854 entities in its argument do exist.
6856 @xref{Gtroff Internals}.
6858 @item
6859 @code{troff} no longer has a hard-coded dependency on @w{Latin-1};
6860 all @code{char@var{XXX}} entities have been removed from the font
6861 description files.  This has a notable consequence which shows up in
6862 warnings like @code{can't find character with input code @var{XXX}}
6863 if the @code{tr} request isn't handled properly.
6865 Consider the following translation:
6867 @Example
6868 .tr @'e@'E
6869 @endExample
6871 @noindent
6872 This maps input character @code{@'e} onto glyph @code{@'E}, which is
6873 identical to glyph @code{char201}.  But this glyph intentionally
6874 doesn't exist!  Instead, @code{\[char201]} is treated as an input
6875 character entity and is by default mapped onto @code{\['E]}, and
6876 @code{gtroff} doesn't handle translations of translations.
6878 The right way to write the above translation is
6880 @Example
6881 .tr @'e\['E]
6882 @endExample
6884 @noindent
6885 With other words, the first argument of @code{tr} should be an input
6886 character or entity, and the second one a glyph entity.
6888 @item
6889 Without an argument, the @code{tr} request is ignored.
6890 @end itemize
6891 @endDefreq
6893 @Defreq {trnt, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
6894 @cindex @code{\!}, and @code{trnt}
6895 @code{trnt} is the same as the @code{tr} request except that the
6896 translations do not apply to text that is transparently throughput
6897 into a diversion with @code{\!}.  @xref{Diversions}, for more
6898 information.
6900 For example,
6902 @Example
6903 .tr ab
6904 .di x
6905 \!.tm a
6908 @endExample
6910 @noindent
6911 prints @samp{b} to the standard error stream; if @code{trnt} is used
6912 instead of @code{tr} it prints @samp{a}.
6913 @endDefreq
6916 @c =====================================================================
6918 @node Troff and Nroff Mode, Line Layout, Character Translations, gtroff Reference
6919 @section Troff and Nroff Mode
6920 @cindex troff mode
6921 @cindex mode, troff
6922 @cindex nroff mode
6923 @cindex mode, nroff
6925 Originally, @code{nroff} and @code{troff} were two separate programs,
6926 the former for TTY output, the latter for everything else.  With GNU
6927 @code{troff}, both programs are merged into one executable, sending
6928 its output to a device driver (@code{grotty} for TTY devices,
6929 @code{grops} for @sc{PostScript}, etc.) which interprets the
6930 intermediate output of @code{gtroff}.  For @acronym{UNIX} @code{troff}
6931 it makes sense to talk about @dfn{Nroff mode} and @dfn{Troff mode}
6932 since the differences are hardcoded.  For GNU @code{troff}, this
6933 distinction is not appropriate because @code{gtroff} simply takes the
6934 information given in the font files for a particular device without
6935 handling requests specially if a TTY output device is used.
6937 Usually, a macro package can be used with all output devices.
6938 Nevertheless, it is sometimes necessary to make a distinction between
6939 TTY and non-TTY devices: @code{gtroff} provides two built-in
6940 conditions @samp{n} and @samp{t} for the @code{if}, @code{ie}, and
6941 @code{while} requests to decide whether @code{gtroff} shall behave
6942 like @code{nroff} or like @code{troff}.
6944 @Defreq {troff, }
6945 @pindex troffrc
6946 @pindex troffrc-end
6947 Make the @samp{t} built-in condition true (and the @samp{n} built-in
6948 condition false) for @code{if}, @code{ie}, and @code{while}
6949 conditional requests.  This is the default if @code{gtroff}
6950 (@emph{not} @code{groff}) is started with the @option{-R} switch to
6951 avoid loading of the start-up files @file{troffrc} and
6952 @file{troffrc-end}.  Without @option{-R}, @code{gtroff} stays in troff
6953 mode if the output device is not a TTY (e.g.@: `ps').
6954 @endDefreq
6956 @Defreq {nroff, }
6957 @pindex tty.tmac
6958 Make the @samp{n} built-in condition true (and the @samp{t} built-in
6959 condition false) for @code{if}, @code{ie}, and @code{while}
6960 conditional requests.  This is the default if @code{gtroff} uses a TTY
6961 output device; the code for switching to nroff mode is in the file
6962 @file{tty.tmac} which is loaded by the start-up file @code{troffrc}.
6963 @endDefreq
6965 @xref{Conditionals and Loops}, for more details on built-in
6966 conditions.
6969 @c =====================================================================
6971 @node Line Layout, Line Control, Troff and Nroff Mode, gtroff Reference
6972 @section Line Layout
6973 @cindex line layout
6974 @cindex layout, line
6976 @cindex dimensions, line
6977 @cindex line dimensions
6978 The following drawing shows the dimensions which @code{gtroff} uses for
6979 placing a line of output onto the page.  They are labeled with the
6980 request which manipulates each dimension.
6982 @Example
6983                 -->| in |<--
6984                    |<-----------ll------------>|
6985               +----+----+----------------------+----+
6986               |    :    :                      :    |
6987               +----+----+----------------------+----+
6988            -->| po |<--
6989               |<--------paper width---------------->|
6990 @endExample
6992 @noindent
6993 These dimensions are:
6995 @ftable @code
6996 @item po
6997 @cindex left margin (@code{po})
6998 @cindex margin, left (@code{po})
6999 @cindex page offset (@code{po})
7000 @cindex offset, page (@code{po})
7001 @dfn{Page offset} -- this is the leftmost position of text on the final
7002 output, defining the @dfn{left margin}.
7004 @item in
7005 @cindex indentation (@code{in})
7006 @cindex line indentation (@code{in})
7007 @dfn{Indentation} -- this is the distance from the left margin where
7008 text is printed.
7010 @item ll
7011 @cindex line length (@code{ll})
7012 @cindex length of line (@code{ll})
7013 @dfn{Line length} -- this is the distance from the left margin to right
7014 margin.
7015 @end ftable
7017 A simple demonstration:
7019 @Example
7020 .ll 3i
7021 This is text without indentation.
7022 The line length has been set to 3\~inch.
7023 .in +.5i
7024 .ll -.5i
7025 Now the left and right margins are both increased.
7028 Calling .in and .ll without parameters restore
7029 the previous values.
7030 @endExample
7032 Result:
7034 @Example
7035 This  is text without indenta-
7036 tion.   The  line  length  has
7037 been set to 3 inch.
7038      Now   the  left  and
7039      right  margins   are
7040      both increased.
7041 Calling  .in  and  .ll without
7042 parameters restore the  previ-
7043 ous values.
7044 @endExample
7046 @DefreqList {po, [@Var{offset}]}
7047 @DefreqItem {po, @t{+}@Var{offset}}
7048 @DefreqItem {po, @t{-}@Var{offset}}
7049 @DefregListEnd {.o}
7050 @pindex troffrc
7051 Set horizontal page offset to @var{offset} (or increment or decrement
7052 the current value by @var{offset}).  Note that this request does not
7053 cause a break, so changing the page offset in the middle of text being
7054 filled may not yield the expected result.  The initial value is
7055 1@dmn{i}.  For TTY output devices, it is set to 0 in the startup file
7056 @file{troffrc}; the default scaling indicator is @samp{m} (and
7057 not @samp{v} as incorrectly documented in the original
7058 @acronym{UNIX} troff manual).
7060 The current page offset can be found in the read-only number register
7061 @samp{.o}.
7063 If @code{po} is called without an argument, the page offset is reset to
7064 the previous value before the last call to @code{po}.
7066 @Example
7067 .po 3i
7068 \n[.o]
7069     @result{} 720
7070 .po -1i
7071 \n[.o]
7072     @result{} 480
7074 \n[.o]
7075     @result{} 720
7076 @endExample
7077 @endDefreq
7079 @DefreqList {in, [@Var{indent}]}
7080 @DefreqItem {in, @t{+}@Var{indent}}
7081 @DefreqItem {in, @t{-}@Var{indent}}
7082 @DefregListEnd {.i}
7083 Set indentation to @var{indent} (or increment or decrement the
7084 current value by @var{indent}).  This request causes a break.
7085 Initially, there is no indentation.
7087 If @code{in} is called without an argument, the indentation is reset to
7088 the previous value before the last call to @code{in}.  The default
7089 scaling indicator is @samp{m}.
7091 The indentation is associated with the current environment
7092 (@pxref{Environments}).
7094 If a negative indentation value is specified (which is not allowed),
7095 @code{gtroff} emits a warning of type @samp{range} and sets the
7096 indentation to zero.
7098 The effect of @code{in} is delayed until a partially collected line (if
7099 it exists) is output.  A temporary indent value is reset to zero also.
7101 The current indentation (as set by @code{in}) can be found in the
7102 read-only number register @samp{.i}.
7103 @endDefreq
7105 @DefreqList {ti, offset}
7106 @DefreqItem {ti, @t{+}@Var{offset}}
7107 @DefreqItem {ti, @t{-}@Var{offset}}
7108 @DefregListEnd {.in}
7109 Temporarily indent the next output line by @var{offset}.  If an
7110 increment or decrement value is specified, adjust the temporary
7111 indentation relative to the value set by the @code{in} request.
7113 This request causes a break; its value is associated with the current
7114 environment (@pxref{Environments}).  The default scaling indicator
7115 is @samp{m}.  A call of @code{ti} without an argument is ignored.
7117 If the total indentation value is negative (which is not allowed),
7118 @code{gtroff} emits a warning of type @samp{range} and sets the
7119 temporary indentation to zero.  `Total indentation' is either
7120 @var{offset} if specified as an absolute value, or the temporary plus
7121 normal indentation, if @var{offset} is given as a relative value.
7123 The effect of @code{ti} is delayed until a partially collected line (if
7124 it exists) is output.
7126 The read-only number register @code{.in} is the indentation that applies
7127 to the current output line.
7129 The difference between @code{.i} and @code{.in} is that the latter takes
7130 into account whether a partially collected line still uses the old
7131 indentation value or a temporary indentation value is active.
7132 @endDefreq
7134 @DefreqList {ll, [@Var{length}]}
7135 @DefreqItem {ll, @t{+}@Var{length}}
7136 @DefreqItem {ll, @t{-}@Var{length}}
7137 @DefregItem {.l}
7138 @DefregListEnd {.ll}
7139 Set the line length to @var{length} (or increment or decrement the
7140 current value by @var{length}).  Initially, the line length is set to
7141 6.5@dmn{i}.  The effect of @code{ll} is delayed until a partially
7142 collected line (if it exists) is output.  The default scaling
7143 indicator is @samp{m}.
7145 If @code{ll} is called without an argument, the line length is reset to
7146 the previous value before the last call to @code{ll}.  If a negative
7147 line length is specified (which is not allowed), @code{gtroff} emits a
7148 warning of type @samp{range} and sets the line length to zero.
7150 The line length is associated with the current environment
7151 (@pxref{Environments}).
7153 @cindex line length register (@code{.l})
7154 The current line length (as set by @code{ll}) can be found in the
7155 read-only number register @samp{.l}.  The read-only number register
7156 @code{.ll} is the line length that applies to the current output line.
7158 Similar to @code{.i} and @code{.in}, the difference between @code{.l}
7159 and @code{.ll} is that the latter takes into account whether a partially
7160 collected line still uses the old line length value.
7161 @endDefreq
7164 @c =====================================================================
7166 @node Line Control, Page Layout, Line Layout, gtroff Reference
7167 @section Line Control
7168 @cindex line control
7169 @cindex control, line
7171 It is important to understand how @code{gtroff} handles input and output
7172 lines.
7174 Many escapes use positioning relative to the input line.  For example,
7175 this
7177 @Example
7178 This is a \h'|1.2i'test.
7180 This is a
7181 \h'|1.2i'test.
7182 @endExample
7184 @noindent
7185 produces
7187 @Example
7188 This is a   test.
7190 This is a             test.
7191 @endExample
7193 The main usage of this feature is to define macros which act exactly
7194 at the place where called.
7196 @Example
7197 .\" A simple macro to underline a word
7198 .de underline
7199 .  nop \\$1\l'|0\[ul]'
7201 @endExample
7203 @noindent
7204 In the above example, @samp{|0} specifies a negative distance from the
7205 current position (at the end of the just emitted argument @code{\$1}) back
7206 to the beginning of the input line.  Thus, the @samp{\l} escape draws a
7207 line from right to left.
7209 @cindex input line continuation (@code{\})
7210 @cindex line, input, continuation (@code{\})
7211 @cindex continuation, input line (@code{\})
7212 @cindex output line, continuation (@code{\c})
7213 @cindex line, output, continuation (@code{\c})
7214 @cindex continuation, output line (@code{\c})
7215 @cindex interrupted line
7216 @cindex line, interrupted
7217 @code{gtroff} makes a difference between input and output line
7218 continuation; the latter is also called @dfn{interrupting} a line.
7220 @DefescList {\\@key{RET}, , ,}
7221 @DefescItem {\\c, , ,}
7222 @DefregListEnd{.int}
7223 Continue a line.  @code{\@key{RET}} (this is a backslash at the end
7224 of a line immediately followed by a newline) works on the input level,
7225 suppressing the effects of the following newline in the input.
7227 @Example
7228 This is a \
7229 .test
7230     @result{} This is a .test
7231 @endExample
7233 The @samp{|} operator is also affected.
7235 @cindex @code{\R}, after @code{\c}
7236 @code{\c} works on the output level.  Anything after this escape on the
7237 same line is ignored, except @code{\R} which works as usual.  Anything
7238 before @code{\c} on the same line will be appended to the current partial
7239 output line.  The next non-command line after an interrupted line counts
7240 as a new input line.
7242 The visual results depend on whether no-fill mode is active.
7244 @itemize @bullet
7245 @item
7246 @cindex @code{\c}, and no-fill mode
7247 @cindex no-fill mode, and @code{\c}
7248 @cindex mode, no-fill, and @code{\c}
7249 If no-fill mode is active (using the @code{nf} request), the next input
7250 text line after @code{\c} will be handled as a continuation of the same
7251 input text line.
7253 @Example
7255 This is a \c
7256 test.
7257     @result{} This is a test.
7258 @endExample
7260 @item
7261 @cindex @code{\c}, and fill mode
7262 @cindex fill mode, and @code{\c}
7263 @cindex mode, fill, and @code{\c}
7264 If fill mode is active (using the @code{fi} request), a word interrupted
7265 with @code{\c} will be continued with the text on the next input text line,
7266 without an intervening space.
7268 @Example
7269 This is a te\c
7271     @result{} This is a test.
7272 @endExample
7273 @end itemize
7275 Note that an intervening control line which causes a break is stronger
7276 than @code{\c}, flushing out the current partial line in the usual way.
7278 @cindex interrupted line register (@code{.int})
7279 The @code{.int} register contains a positive value
7280 if the last output line was interrupted with @code{\c}; this is
7281 associated with the current environment (@pxref{Environments}).
7283 @endDefesc
7285 @c =====================================================================
7287 @node Page Layout, Page Control, Line Control, gtroff Reference
7288 @section Page Layout
7289 @cindex page layout
7290 @cindex layout, page
7292 @code{gtroff} provides some very primitive operations for controlling
7293 page layout.
7295 @DefreqList {pl, [@Var{length}]}
7296 @DefreqItem {pl, @t{+}@Var{length}}
7297 @DefreqItem {pl, @t{-}@Var{length}}
7298 @DefregListEnd {.p}
7299 @cindex page length (@code{pl})
7300 @cindex length of page (@code{pl})
7301 Set the @dfn{page length} to @var{length} (or increment or decrement
7302 the current value by @var{length}).  This is the length of the
7303 physical output page.  The default scaling indicator is @samp{v}.
7305 @cindex page length register (@code{.p})
7306 The current setting can be found in the read-only number register
7307 @samp{.p}.
7309 @cindex top margin
7310 @cindex margin, top
7311 @cindex bottom margin
7312 @cindex margin, bottom
7313 Note that this only specifies the size of the page, not the top and
7314 bottom margins.  Those are not set by @code{gtroff} directly.
7315 @xref{Traps}, for further information on how to do this.
7317 Negative @code{pl} values are possible also, but not very useful: No
7318 trap is sprung, and each line is output on a single page (thus
7319 suppressing all vertical spacing).
7321 If no argument or an invalid argument is given, @code{pl} sets the page
7322 length to 11@dmn{i}.
7323 @endDefreq
7325 @cindex headers
7326 @cindex footers
7327 @cindex titles
7328 @code{gtroff} provides several operations which help in setting up top
7329 and bottom titles (or headers and footers).
7331 @Defreq {tl, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}}
7332 @cindex title line (@code{tl})
7333 @cindex three-part title (@code{tl})
7334 @cindex page number character (@code{%})
7335 Print a @dfn{title line}.  It consists of three parts: a left
7336 justified portion, a centered portion, and a right justified portion.
7337 The argument separator @samp{'} can be replaced with any character not
7338 occurring in the title line.  The @samp{%} character is replaced with
7339 the current page number.  This character can be changed with the
7340 @code{pc} request (see below).
7342 Without argument, @code{tl} is ignored.
7344 Some notes:
7346 @itemize @bullet
7347 @item
7348 A title line is not restricted to the top or bottom of a page.
7350 @item
7351 @code{tl} prints the title line immediately, ignoring a partially filled
7352 line (which stays untouched).
7354 @item
7355 It is not an error to omit closing delimiters.  For example,
7356 @w{@samp{.tl /foo}} is equivalent to @w{@samp{.tl /foo///}}: It prints a
7357 title line with the left justified word @samp{foo}; the centered and
7358 right justfied parts are empty.
7360 @item
7361 Any modifications to the current environment within @code{tl} (e.g.@:
7362 changing the font or font size) are undone after processing @code{tl}.
7364 @item
7365 @code{tl} accepts the same parameter delimiting characters as the
7366 @code{\A} escape; see @ref{Escapes}.
7367 @end itemize
7368 @endDefreq
7370 @DefreqList {lt, [@Var{length}]}
7371 @DefreqItem {lt, @t{+}@Var{length}}
7372 @DefreqItem {lt, @t{-}@Var{length}}
7373 @DefregListEnd {.lt}
7374 @cindex length of title line (@code{lt})
7375 @cindex title line, length (@code{lt})
7376 @cindex title line length register (@code{.lt})
7377 The title line is printed using its own line length, which is
7378 specified (or incremented or decremented) with the @code{lt} request.
7379 Initially, the title line length is set to 6.5@dmn{i}.  If a negative
7380 line length is specified (which is not allowed), @code{gtroff} emits a
7381 warning of type @samp{range} and sets the title line length to zero.
7382 The default scaling indicator is @samp{m}.  If @code{lt} is called
7383 without an argument, the title length is reset to the previous value
7384 before the last call to @code{lt}.
7386 The current setting of this is available in the @code{.lt} read-only
7387 number register; it is associated with the current environment
7388 (@pxref{Environments}).
7390 @endDefreq
7392 @DefreqList {pn, page}
7393 @DefreqItem {pn, @t{+}@Var{page}}
7394 @DefreqItem {pn, @t{-}@Var{page}}
7395 @DefregListEnd {.pn}
7396 @cindex page number (@code{pn})
7397 @cindex number, page (@code{pn})
7398 Change (increase or decrease) the page number of the @emph{next} page.
7399 The only argument is the page number; the request is ignored without a
7400 parameter.
7402 The read-only number register @code{.pn} contains the number of the next
7403 page: either the value set by a @code{pn} request, or the number of the
7404 current page plus@w{ }1.
7405 @endDefreq
7407 @Defreg {%}
7408 @cindex page number register (@code{%})
7409 A read-write register holding the current page number.
7410 @endDefreg
7412 @Defreq {pc, [@Var{char}]}
7413 @cindex changing the page number character (@code{pc})
7414 @cindex page number character, changing (@code{pc})
7415 @vindex %
7416 Change the page number character (used by the @code{tl} request) to a
7417 different character.  With no argument, this mechanism is disabled.
7418 Note that this doesn't affect the number register@w{ }@code{%}.
7419 @endDefreq
7421 @xref{Traps}.
7424 @c =====================================================================
7426 @node Page Control, Fonts, Page Layout, gtroff Reference
7427 @section Page Control
7428 @cindex page control
7429 @cindex control, page
7431 @DefreqList {bp, [@Var{page}]}
7432 @DefreqItem {bp, @t{+}@Var{page}}
7433 @DefreqListEnd {bp, @t{-}@Var{page}}
7434 @cindex new page (@code{bp})
7435 @cindex page, new (@code{bp})
7436 Stop processing the current page and move to the next page.  This
7437 request causes a break.  It can also take an argument to set
7438 (increase, decrease) the page number of the next page.  The only
7439 difference between @code{bp} and @code{pn} is that @code{pn} does not
7440 cause a break or actually eject a page.
7442 @Example
7443 .de newpage                         \" define macro
7444 'bp                                 \" begin page
7445 'sp .5i                             \" vertical space
7446 .tl 'left top'center top'right top' \" title
7447 'sp .3i                             \" vertical space
7448 ..                                  \" end macro
7449 @endExample
7451 @cindex @code{bp} request, and top-level diversion
7452 @cindex top-level diversion, and @code{bp}
7453 @cindex diversion, top-level, and @code{bp}
7454 @code{bp} has no effect if not called within the top-level diversion
7455 (@pxref{Diversions}).
7456 @endDefreq
7458 @Defreq {ne, [@Var{space}]}
7459 @cindex orphan lines, preventing with @code{ne}
7460 @cindex conditional page break (@code{ne})
7461 @cindex page break, conditional (@code{ne})
7462 It is often necessary to force a certain amount of space before a new
7463 page occurs.  This is most useful to make sure that there is not a
7464 single @dfn{orphan} line left at the bottom of a page.  The @code{ne}
7465 request ensures that there is a certain distance, specified by the
7466 first argument, before the next page is triggered (see @ref{Traps},
7467 for further information).  The default scaling indicator for @code{ne}
7468 is @samp{v}; the default value of @var{space} is@w{ }1@dmn{v} if no
7469 argument is given.
7471 For example, to make sure that no fewer than 2@w{ }lines get orphaned,
7472 do the following before each paragraph:
7474 @Example
7475 .ne 2
7476 text text text
7477 @endExample
7479 @code{ne} will then automatically cause a page break if there is space
7480 for one line only.
7481 @endDefreq
7483 @DefreqList {sv, [@Var{space}]}
7484 @DefreqListEnd {os, }
7485 @cindex @code{ne} request, comparison with @code{sv}
7486 @code{sv} is similar to the @code{ne} request; it reserves the
7487 specified amount of vertical space.  If the desired amount of space
7488 exists before the next trap (or the bottom page boundary if no trap is
7489 set), the space is output immediately (ignoring a partially filled line
7490 which stays untouched).  If there is not enough space, it is stored for
7491 later output via the @code{os} request.  The default value is@w{ }1@dmn{v}
7492 if no argument is given; the default scaling indicator is @samp{v}.
7494 @cindex @code{sv} request, and no-space mode
7495 @cindex @code{os} request, and no-space mode
7496 Both @code{sv} and @code{os} ignore no-space mode.  While the @code{sv}
7497 request allows negative values for @var{space}, @code{os} will ignore
7498 them.
7499 @endDefreq
7501 @Defreg {nl}
7502 This register contains the current vertical position.  If the vertical
7503 position is zero and the top of page transition hasn't happened yet,
7504 @code{nl} is set to negative value.  @code{gtroff} itself does this at
7505 the very beginning of a document before anything has been printed, but
7506 the main usage is to plant a header trap on a page if this page has
7507 already started.
7509 Consider the following:
7511 @Example
7512 .de xxx
7513 .  sp
7514 .  tl ''Header''
7515 .  sp
7518 First page.
7520 .wh 0 xxx
7521 .nr nl (-1)
7522 Second page.
7523 @endExample
7525 @noindent
7526 Result:
7528 @Example
7529 First page.
7533                              Header
7535 Second page.
7538 @endExample
7540 @noindent
7541 Without resetting @code{nl} to a negative value, the just planted trap
7542 would be active beginning with the @emph{next} page, not the current
7543 one.
7545 @xref{Diversions}, for a comparison with the @code{.h} and @code{.d}
7546 registers.
7547 @endDefreg
7549 @c =====================================================================
7551 @node Fonts, Sizes, Page Control, gtroff Reference
7552 @section Fonts
7553 @cindex fonts
7555 @code{gtroff} can switch fonts at any point in the text.
7557 The basic set of fonts is @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
7558 These are Times Roman, Italic, Bold, and Bold Italic.  For non-TTY
7559 devices, there is also at least one symbol font which contains various
7560 special symbols (Greek, mathematics).
7562 @menu
7563 * Changing Fonts::
7564 * Font Families::
7565 * Font Positions::
7566 * Using Symbols::
7567 * Special Fonts::
7568 * Artificial Fonts::
7569 * Ligatures and Kerning::
7570 @end menu
7572 @c ---------------------------------------------------------------------
7574 @node Changing Fonts, Font Families, Fonts, Fonts
7575 @subsection Changing Fonts
7576 @cindex fonts
7578 @DefreqList {ft, [@Var{font}]}
7579 @DefescItem {\\f, , f, }
7580 @DefescItem {\\f, @lparen{}, fn, }
7581 @DefescListEnd {\\f, @lbrack{}, font, @rbrack}
7582 @cindex changing fonts (@code{ft}, @code{\f})
7583 @cindex fonts, changing (@code{ft}, @code{\f})
7584 @cindex @code{sty} request, and changing fonts
7585 @cindex @code{fam} request, and changing fonts
7586 @cindex @code{\F}, and changing fonts
7587 @kindex styles
7588 @kindex family
7589 @pindex DESC
7590 The @code{ft} request and the @code{\f} escape change the current font
7591 to @var{font} (one-character name@w{ }@var{f}, two-character name
7592 @var{fn}).
7594 If @var{font} is a style name (as set with the @code{sty} request or
7595 with the @code{styles} command in the @file{DESC} file), use it within
7596 the current font family (as set with the @code{fam} request, @code{\F}
7597 escape, or with the @code{family} command in the @file{DESC} file).
7599 @cindex previous font (@code{ft}, @code{\f[]}, @code{\fP})
7600 @cindex font, previous (@code{ft}, @code{\f[]}, @code{\fP})
7601 With no argument or using @samp{P} as an argument, @code{.ft} switches
7602 to the previous font.  Use @code{\f[]} to do this with the escape.  The
7603 old syntax forms @code{\fP} or @code{\f[P]} are also supported.
7605 Fonts are generally specified as upper-case strings, which are usually
7606 1@w{ }to 4 characters representing an abbreviation or acronym of the
7607 font name.  This is no limitation, just a convention.
7609 The example below produces two identical lines.
7611 @Example
7612 eggs, bacon,
7613 .ft B
7614 spam
7616 and sausage.
7618 eggs, bacon, \fBspam\fP and sausage.
7619 @endExample
7621 Note that @code{\f} doesn't produce an input token in @code{gtroff}.
7622 As a consequence, it can be used in requests like @code{mc} (which
7623 expects a single character as an argument) to change the font on
7624 the fly:
7626 @Example
7627 .mc \f[I]x\f[]
7628 @endExample
7630 @xref{Font Positions}, for an alternative syntax.
7631 @endDefreq
7633 @Defreq {ftr, f [@Var{g}]}
7634 @cindex @code{ft} request, and font translations
7635 @cindex @code{ul} request, and font translations
7636 @cindex @code{bd} request, and font translations
7637 @cindex @code{\f}, and font translations
7638 @cindex @code{cs} request, and font translations
7639 @cindex @code{tkf} request, and font translations
7640 @cindex @code{special} request, and font translations
7641 @cindex @code{fspecial} request, and font translations
7642 @cindex @code{fp} request, and font translations
7643 @cindex @code{sty} request, and font translations
7644 Translate font@w{ }@var{f} to font@w{ }@var{g}.  Whenever a font named@w{
7645 }@var{f} is referred to in a @code{\f} escape sequence, or in the
7646 @code{ft}, @code{ul}, @code{bd}, @code{cs}, @code{tkf},
7647 @code{special}, @code{fspecial}, @code{fp}, or @code{sty} requests,
7648 font@w{ }@var{g} is used.  If @var{g} is missing or equal to@w{ }@var{f}
7649 the translation is undone.
7650 @endDefreq
7652 @c ---------------------------------------------------------------------
7654 @node Font Families, Font Positions, Changing Fonts, Fonts
7655 @subsection Font Families
7656 @cindex font families
7657 @cindex families, font
7658 @cindex font styles
7659 @cindex styles, font
7661 Due to the variety of fonts available, @code{gtroff} has added the
7662 concept of @dfn{font families} and @dfn{font styles}.  The fonts are
7663 specified as the concatenation of the font family and style.  Specifying
7664 a font without the family part causes @code{gtroff} to use that style of
7665 the current family.
7667 @cindex PostScript fonts
7668 @cindex fonts, PostScript
7669 Currently, fonts for the devices @option{-Tps}, @option{-Tdvi}, and
7670 @option{-Tlbp} are set up to this mechanism.
7671 By default, @code{gtroff} uses the Times family with the four styles
7672 @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
7674 This way, it is possible to use the basic four fonts and to select a
7675 different font family on the command line (@pxref{Groff Options}).
7677 @DefreqList {fam, [@Var{family}]}
7678 @DefregItem {.fam}
7679 @DefescItem {\\F, , f, }
7680 @DefescItem {\\F, @lparen{}, fm, }
7681 @DefescItem {\\F, @lbrack{}, family, @rbrack}
7682 @DefregListEnd {.fn}
7683 @cindex changing font family (@code{fam}, @code{\F})
7684 @cindex font family, changing (@code{fam}, @code{\F})
7685 Switch font family to @var{family} (one-character name@w{ }@var{f},
7686 two-character name @var{fm}).  If no argument is given, switch
7687 back to the previous font family.  Use @code{\F[]} to do this with the
7688 escape.  Note that @code{\FP} doesn't work; it selects font family
7689 @samp{P} instead.
7691 The value at start-up is @samp{T}.
7692 The current font family is available in the read-only number register
7693 @samp{.fam} (this is a string-valued register); it is associated with
7694 the current environment.
7696 @Example
7697 spam,
7698 .fam H    \" helvetica family
7699 spam,     \" used font is family H + style R = HR
7700 .ft B     \" family H + style B = font HB
7701 spam,
7702 .fam T    \" times family
7703 spam,     \" used font is family T + style B = TB
7704 .ft AR    \" font AR (not a style)
7705 baked beans,
7706 .ft R     \" family T + style R = font TR
7707 and spam.
7708 @endExample
7710 Note that @code{\F} doesn't produce an input token in @code{gtroff}.
7711 As a consequence, it can be used in requests like @code{mc} (which
7712 expects a single character as an argument) to change the font family on
7713 the fly:
7715 @Example
7716 .mc \F[P]x\F[]
7717 @endExample
7719 The @samp{.fn} register contains the current @dfn{real font name}
7720 of the current font.
7721 This is a string-valued register.
7722 If the current font is a style, the value of @code{\n[.fn]}
7723 is the proper concatenation of family and style name.
7724 @endDefreq
7726 @Defreq {sty, n style}
7727 @cindex changing font style (@code{sty})
7728 @cindex font style, changing (@code{sty})
7729 @cindex @code{cs} request, and font styles
7730 @cindex @code{bd} request, and font styles
7731 @cindex @code{tkf} request, and font styles
7732 @cindex @code{uf} request, and font styles
7733 @cindex @code{fspecial} request, and font styles
7734 Associate @var{style} with font position@w{ }@var{n}.  A font position
7735 can be associated either with a font or with a style.  The current
7736 font is the index of a font position and so is also either a font or a
7737 style.  If it is a style, the font that is actually used is the font
7738 which name is the concatenation of the name of the current
7739 family and the name of the current style.  For example, if the current
7740 font is@w{ }1 and font position@w{ }1 is associated with style
7741 @samp{R} and the current font family is @samp{T}, then font
7742 @samp{TR} will be used.  If the current font is not a style, then the
7743 current family is ignored.  If the requests @code{cs}, @code{bd},
7744 @code{tkf}, @code{uf}, or @code{fspecial} are applied to a style,
7745 they will instead be applied to the member of the current family
7746 corresponding to that style.
7748 @var{n}@w{ }must be a non-negative integer value.
7750 @pindex DESC
7751 @kindex styles
7752 The default family can be set with the @option{-f} option
7753 (@pxref{Groff Options}).  The @code{styles} command in the @file{DESC}
7754 file controls which font positions (if any) are initially associated
7755 with styles rather than fonts.  For example, the default setting for
7756 @sc{PostScript} fonts
7758 @Example
7759 styles R I B BI
7760 @endExample
7762 @noindent
7763 is equivalent to
7765 @Example
7766 .sty 1 R
7767 .sty 2 I
7768 .sty 3 B
7769 .sty 4 BI
7770 @endExample
7772 @code{fam} and @code{\F} always check whether the current font position
7773 is valid; this can give surprising results if the current font position is
7774 associated with a style.
7776 In the following example, we want to access the @sc{PostScript} font
7777 @code{FooBar} from the font family @code{Foo}:
7779 @Example
7780 .sty \n[.fp] Bar
7781 .fam Foo
7782     @result{} warning: can't find font `FooR'
7783 @endExample
7785 @noindent
7786 The default font position at start-up is@w{ }1; for the
7787 @sc{PostScript} device, this is associated with style @samp{R}, so
7788 @code{gtroff} tries to open @code{FooR}.
7790 A solution to this problem is to use a dummy font like the following:
7792 @Example
7793 .fp 0 dummy TR    \" set up dummy font at position 0
7794 .sty \n[.fp] Bar  \" register style `Bar'
7795 .ft 0             \" switch to font at position 0
7796 .fam Foo          \" activate family `Foo'
7797 .ft Bar           \" switch to font `FooBar'
7798 @endExample
7800 @xref{Font Positions}.
7801 @endDefreq
7803 @c ---------------------------------------------------------------------
7805 @node Font Positions, Using Symbols, Font Families, Fonts
7806 @subsection Font Positions
7807 @cindex font positions
7808 @cindex positions, font
7810 For the sake of old phototypesetters and compatibility with old versions
7811 of @code{troff}, @code{gtroff} has the concept of font @dfn{positions},
7812 on which various fonts are mounted.
7814 @DefreqList {fp, pos font [@Var{external-name}]}
7815 @DefregItem {.f}
7816 @DefregListEnd {.fp}
7817 @cindex mounting font (@code{fp})
7818 @cindex font, mounting (@code{fp})
7819 Mount font @var{font} at position @var{pos} (which must be a
7820 non-negative integer).  This numeric position can then be referred to
7821 with font changing commands.  When @code{gtroff} starts it is using
7822 font position@w{ }1 (which must exist; position@w{ }0 is unused
7823 usually at start-up).
7825 @cindex font position register (@code{.f})
7826 The current font in use, as a font position, is available in the
7827 read-only number register @samp{.f}.  This can be useful to remember the
7828 current font for later recall.  It is associated with the current
7829 environment (@pxref{Environments}).
7831 @Example
7832 .nr save-font \n[.f]
7833 .ft B
7834 ... text text text ...
7835 .ft \n[save-font]
7836 @endExample
7838 @cindex next free font position register (@code{.fp})
7839 The number of the next free font position is available in the read-only
7840 number register @samp{.fp}.  This is useful when mounting a new font,
7841 like so:
7843 @Example
7844 .fp \n[.fp] NEATOFONT
7845 @endExample
7847 @pindex DESC@r{, and font mounting}
7848 Fonts not listed in the @file{DESC} file are automatically mounted on
7849 the next available font position when they are referenced.  If a font
7850 is to be mounted explicitly with the @code{fp} request on an unused
7851 font position, it should be mounted on the first unused font position,
7852 which can be found in the @code{.fp} register.  Although @code{gtroff}
7853 does not enforce this strictly, it is not allowed to mount a font at a
7854 position whose number is much greater (approx.@: 1000 positions) than
7855 that of any currently used position.
7857 The @code{fp} request has an optional third argument.  This argument
7858 gives the external name of the font, which is used for finding the font
7859 description file.  The second argument gives the internal name of the
7860 font which is used to refer to the font in @code{gtroff} after it has
7861 been mounted.  If there is no third argument then the internal name is
7862 used as the external name.  This feature makes it possible to use
7863 fonts with long names in compatibility mode.
7864 @endDefreq
7866 Both the @code{ft} request and the @code{\f} escape have alternative
7867 syntax forms to access font positions.
7869 @DefreqList {ft, nnn}
7870 @DefescItem {\\f, , n, }
7871 @DefescItem {\\f, @lparen{}, nn, }
7872 @DefescListEnd {\\f, @lbrack{}, nnn, @rbrack}
7873 @cindex changing font position (@code{\f})
7874 @cindex font position, changing (@code{\f})
7875 @cindex @code{sty} request, and font positions
7876 @cindex @code{fam} request, and font positions
7877 @cindex @code{\F}, and font positions
7878 @kindex styles
7879 @kindex family
7880 @pindex DESC
7881 Change the current font position to @var{nnn} (one-digit position@w{
7882 }@var{n}, two-digit position @var{nn}), which must be a non-negative
7883 integer.
7885 If @var{nnn} is associated with a style (as set with the @code{sty}
7886 request or with the @code{styles} command in the @file{DESC} file), use
7887 it within the current font family (as set with the @code{fam} request,
7888 the @code{\F} escape, or with the @code{family} command in the @file{DESC}
7889 file).
7891 @Example
7892 this is font 1
7893 .ft 2
7894 this is font 2
7895 .ft                   \" switch back to font 1
7896 .ft 3
7897 this is font 3
7899 this is font 1 again
7900 @endExample
7902 @xref{Changing Fonts}, for the standard syntax form.
7903 @endDefreq
7905 @c ---------------------------------------------------------------------
7907 @node Using Symbols, Special Fonts, Font Positions, Fonts
7908 @subsection Using Symbols
7909 @cindex using symbols
7910 @cindex symbols, using
7912 @cindex glyph
7913 @cindex character
7914 @cindex ligature
7915 A @dfn{glyph} is a graphical representation of a @dfn{character}.
7916 While a character is an abstract entity containing semantic
7917 information, a glyph is something which can be actually seen on screen
7918 or paper.  It is possible that a character has multiple glyph
7919 representation forms (for example, the character `A' can be either
7920 written in a roman or an italic font, yielding two different glyphs);
7921 sometimes more than one character maps to a single glyph (this is a
7922 @dfn{ligature} -- the most common is `fi').
7924 @cindex symbol
7925 @cindex special fonts
7926 @kindex fonts
7927 @pindex DESC
7928 A @dfn{symbol} is simply a named glyph.  Within @code{gtroff}, all
7929 glyph names of a particular font are defined in its font file.  If the
7930 user requests a glyph not available in this font, @code{gtroff} looks
7931 up an ordered list of @dfn{special fonts}.  By default, the
7932 @sc{PostScript} output device supports the two special fonts @samp{SS}
7933 (slanted symbols) and @samp{S} (symbols) (the former is looked up
7934 before the latter).  Other output devices use different names for
7935 special fonts.  Fonts mounted with the @code{fonts} keyword in the
7936 @file{DESC} file are globally available.  To install additional
7937 special fonts locally (i.e.@: for a particular font), use the
7938 @code{fspecial} request.
7940 In summary, @code{gtroff} tries the following to find a given symbol:
7942 @itemize @bullet
7943 @item
7944 If the symbol has been defined with the @code{char} request, use it.
7945 This hides a symbol with the same name in the current font.
7947 @item
7948 Check the current font.
7950 @item
7951 If the symbol has been defined with the @code{fchar} request, use it.
7953 @item
7954 Check all fonts given with the @code{fspecial} request, in the order
7955 of appearance in @code{fspecial} calls.
7957 @item
7958 Check all fonts given with the @code{special} request, in the order
7959 of appearance in @code{special} calls (inclusively the special fonts
7960 defined in the @file{DESC} file, which come first).
7962 @item
7963 As a last resort, consult all fonts loaded up to now (in the order they
7964 have been called the first time) for special fonts and check them.
7965 @end itemize
7967 @xref{Font Files}, and @ref{Special Fonts}, for more details.
7969 @DefescList {\\, @lparen{}, nm, }
7970 @DefescListEnd {\\, @lbrack{}, name, @rbrack}
7971 Insert a symbol @var{name} (two-character name @var{nm}).  There is no
7972 special syntax for one-character names -- the natural form
7973 @samp{\@var{n}} would collide with escapes.@footnote{Note that a
7974 one-character symbol is not the same as an input character, i.e., the
7975 character @code{a} is not the same as @code{\[a]}.  By default,
7976 @code{groff} defines only a single one-character symbol, @code{\[-]};
7977 it is usually accessed as @code{\-}.  On the other hand, @code{gtroff}
7978 has the special feature that @code{\[char@var{XXX}]} is the same as the
7979 input character with character code @var{XXX}.  For example,
7980 @code{\[char97]} is identical to the letter @code{a} if @acronym{ASCII}
7981 encoding is active.}
7983 If @var{name} is undefined, a warning of type @samp{char} is generated,
7984 and the escape is ignored.  @xref{Debugging}, for information about
7985 warnings.
7987 @cindex list of available glyphs (@cite{groff_char(7)} man page)
7988 @cindex available glyphs, list (@cite{groff_char(7)} man page)
7989 @cindex glyphs, available, list (@cite{groff_char(7)} man page)
7990 The list of available symbols is device dependent; see the
7991 @cite{groff_char(7)} man page for a complete list for the given output
7992 device.  For example, say
7994 @Example
7995 man -Tdvi groff_char > groff_char.dvi
7996 @endExample
7998 @noindent
7999 for a list using the default DVI fonts (not all versions of the
8000 @code{man} program support the @option{-T} option).  If you want to
8001 use an additional macro package to change the used fonts, @code{groff}
8002 must be called directly:
8004 @Example
8005 groff -Tdvi -mec -man groff_char.7 > groff_char.dvi
8006 @endExample
8008 @c XXX list of common symbols
8009 @endDefesc
8011 @Defesc {\\C, ', xxx, '}
8012 @cindex named character (@code{\C})
8013 @cindex character, named (@code{\C})
8014 Typeset the glyph named @var{xxx}.@footnote{@code{\C} is actually a
8015 misnomer since it accesses an output glyph.}  Normally it is more
8016 convenient to use @code{\[@var{xxx}]}, but @code{\C} has the advantage
8017 that it is compatible with newer versions of @acronym{AT&T}
8018 @code{troff} and is available in compatibility mode.
8019 @endDefesc
8021 @Defesc {\\N, ', n, '}
8022 @cindex numbered glyph (@code{\N})
8023 @cindex glyph, numbered (@code{\N})
8024 @cindex @code{char} request, used with @code{\N}
8025 @cindex Unicode
8026 Typeset the glyph with code@w{ }@var{n} in the current font
8027 (@code{n}@w{ }is @strong{not} the input character code).  The
8028 number @var{n}@w{ }can be any non-negative integer.  Most devices
8029 only have glyphs with codes between 0 and@w{ }255; the Unicode
8030 output device uses codes in the range 0--65535.  If the current
8031 font does not contain a glyph with that code, special fonts are
8032 @emph{not} searched.  The @code{\N} escape sequence can be
8033 conveniently used in conjunction with the @code{char} request:
8035 @Example
8036 .char \[phone] \f[ZD]\N'37'
8037 @endExample
8039 @noindent
8040 @pindex DESC
8041 @cindex unnamed glyphs
8042 @cindex glyphs, unnamed
8043 The code of each glyph is given in the fourth column in the font
8044 description file after the @code{charset} command.  It is possible to
8045 include unnamed glyphs in the font description file by using a
8046 name of @samp{---}; the @code{\N} escape sequence is the only way to
8047 use these.
8048 @endDefesc
8050 Some escape sequences directly map onto special glyphs.
8052 @Defesc {\\', , , }
8053 This is a backslash followed by the apostrophe character, @acronym{ASCII}
8054 character @code{0x27} (@acronym{EBCDIC} character @code{0x7D}).  The same
8055 as @code{\[aa]}, the acute accent.
8056 @endDefesc
8058 @Defesc {\\`, , , }
8059 This is a backslash followed by @acronym{ASCII} character @code{0x60}
8060 (@acronym{EBCDIC} character @code{0x79} usually).  The same as
8061 @code{\[ga]}, the grave accent.
8062 @endDefesc
8064 @Defesc {\\-, , , }
8065 This is the same as @code{\[-]}, the minus sign in the current font.
8066 @endDefesc
8068 @Defreq {cflags, n c1 c2 @dots{}}
8069 @cindex glyph properties (@code{cflags})
8070 @cindex character properties (@code{cflags})
8071 @cindex properties of glyphs (@code{cflags})
8072 @cindex properties of characters (@code{cflags})
8073 Input characters and symbols have certain properties associated
8074 with it.@footnote{Note that the output glyphs themselves don't have
8075 such properties.  For @code{gtroff}, a glyph is a numbered box with
8076 a given width, depth, and height, nothing else.  All manipulations
8077 with the @code{cflags} request work on the input level.}  These
8078 properties can be modified with the @code{cflags} request.  The
8079 first argument is the sum of the desired flags and the remaining
8080 arguments are the characters or symbols to have those properties.
8081 It is possible to omit the spaces between the characters or symbols.
8083 @table @code
8084 @item 1
8085 @cindex end-of-sentence characters
8086 @cindex characters, end-of-sentence
8087 The character ends sentences (initially characters @samp{.?!} have this
8088 property).
8090 @item 2
8091 @cindex hyphenating characters
8092 @cindex characters, hyphenation
8093 Lines can be broken before the character (initially no characters have
8094 this property).
8096 @item 4
8097 @cindex @code{hy} glyph, and @code{cflags}
8098 @cindex @code{em} glyph, and @code{cflags}
8099 Lines can be broken after the character (initially the character
8100 @samp{-} and the symbols @samp{\(hy} and @samp{\(em} have this property).
8102 @item 8
8103 @cindex overlapping characters
8104 @cindex characters, overlapping
8105 @cindex @code{ul} glyph, and @code{cflags}
8106 @cindex @code{rn} glyph, and @code{cflags}
8107 @cindex @code{ru} glyph, and @code{cflags}
8108 The character overlaps horizontally (initially the symbols
8109 @samp{\(ul\(rn\(ru} have this property).
8111 @item 16
8112 @cindex @code{br} glyph, and @code{cflags}
8113 The character overlaps vertically (initially symbol @samp{\(br} has
8114 this property).
8116 @item 32
8117 @cindex transparent characters
8118 @cindex character, transparent
8119 @cindex @code{"}, at end of sentence
8120 @cindex @code{'}, at end of sentence
8121 @cindex @code{)}, at end of sentence
8122 @cindex @code{]}, at end of sentence
8123 @cindex @code{*}, at end of sentence
8124 @cindex @code{dg} glyph, at end of sentence
8125 @cindex @code{rq} glyph, at end of sentence
8126 An end-of-sentence character followed by any number of characters with
8127 this property is treated as the end of a sentence if followed by a
8128 newline or two spaces; in other words the character is
8129 @dfn{transparent} for the purposes of end-of-sentence recognition --
8130 this is the same as having a zero space factor in @TeX{} (initially
8131 characters @samp{"')]*} and the symbols @samp{\(dg\(rq} have this
8132 property).
8133 @end table
8134 @endDefreq
8136 @DefreqList {char, g [@Var{string}]}
8137 @DefreqListEnd {fchar, g [@Var{string}]}
8138 @cindex defining character (@code{char})
8139 @cindex character, defining (@code{char})
8140 @cindex creating new characters (@code{char})
8141 @cindex defining symbol (@code{char})
8142 @cindex symbol, defining (@code{char})
8143 @cindex defining glyph (@code{char})
8144 @cindex glyph, defining (@code{char})
8145 @cindex escape character, while defining glyph
8146 @cindex character, escape, while defining glyph
8147 @cindex @code{tr} request, and glyph definitions
8148 @cindex @code{cp} request, and glyph definitions
8149 @cindex @code{rc} request, and glyph definitions
8150 @cindex @code{lc} request, and glyph definitions
8151 @cindex @code{\l}, and glyph definitions
8152 @cindex @code{\L}, and glyph definitions
8153 @cindex @code{\&}, and glyph definitions
8154 @cindex @code{\e}, and glyph definitions
8155 @cindex @code{hcode} request, and glyph definitions
8156 Define a new glyph@w{ }@var{g} to be @var{string} (which can be
8157 empty).@footnote{@code{char} is a misnomer since an output glyph is
8158 defined.}  Every time glyph@w{ }@var{g} needs to be printed,
8159 @var{string} is processed in a temporary environment and the result is
8160 wrapped up into a single object.  Compatibility mode is turned off and
8161 the escape character is set to @samp{\} while @var{string} is being
8162 processed.  Any emboldening, constant spacing or track kerning is
8163 applied to this object rather than to individual characters in
8164 @var{string}.
8166 A glyph defined by this request can be used just
8167 like a normal glyph provided by the output device.  In particular,
8168 other characters can be translated to it with the @code{tr} or
8169 @code{trin} requests; it can be made the leader character by the
8170 @code{lc} request; repeated patterns can be drawn with the glyph
8171 using the @code{\l} and @code{\L} escape sequences; words containing
8172 the glyph can be hyphenated correctly if the @code{hcode} request
8173 is used to give the glyph's symbol a hyphenation code.
8175 There is a special anti-recursion feature: Use of @code{g} within
8176 the glyph's definition is handled like normal characters and symbols
8177 not defined with @code{char}.
8179 Note that the @code{tr} and @code{trin} requests take precedence if
8180 @code{char} accesses the same symbol.
8182 @Example
8183 .tr XY
8185     @result{} Y
8186 .char X Z
8188     @result{} Y
8189 .tr XX
8191     @result{} Z
8192 @endExample
8194 The @code{fchar} request defines a fallback glyph:
8195 @code{gtroff} only checks for glyphs defined with @code{fchar}
8196 if it cannot find the glyph in the current font.
8197 @code{gtroff} carries out this test before checking special fonts.
8198 @endDefreq
8200 @Defreq {rchar, c1 c2 @dots{}}
8201 @cindex removing glyph definition (@code{rchar})
8202 @cindex glyph, removing definition (@code{rchar})
8203 Remove the definitions of glyphs @var{c1}, @var{c2},@w{
8204 }@enddots{} This undoes the effect of a @code{char} or @code{fchar}
8205 request.
8207 It is possible to omit the whitespace between arguments.
8208 @endDefreq
8210 @xref{Special Characters}.
8212 @c ---------------------------------------------------------------------
8214 @node Special Fonts, Artificial Fonts, Using Symbols, Fonts
8215 @subsection Special Fonts
8216 @cindex special fonts
8217 @cindex fonts, special
8219 Special fonts are those that @code{gtroff} searches
8220 when it cannot find the requested glyph in the current font.
8221 The Symbol font is usually a special font.
8223 @code{gtroff} provides the following two requests to add more special
8224 fonts.  @xref{Using Symbols}, for a detailed description of the glyph
8225 searching mechanism in @code{gtroff}.
8227 Usually, only non-TTY devices have special fonts.
8229 @DefreqList {special, s1 s2 @dots{}}
8230 @DefreqListEnd {fspecial, f s1 s2 @dots{}}
8231 @kindex fonts
8232 @pindex DESC
8233 Use the @code{special} request to define special fonts.  They are
8234 appended to the list of global special fonts in the given order.
8235 The first entries in this list are the fonts defined with the
8236 @code{fonts} command in the @file{DESC} file which are marked as
8237 special in the corresponding font description files.
8239 Use the @code{fspecial} request to designate special fonts
8240 only when font@w{ }@var{f} font is active.  They are appended to the
8241 list of special fonts for @var{f} in the given order.  Initially, this
8242 list is empty.
8243 @endDefreq
8245 @c ---------------------------------------------------------------------
8247 @node Artificial Fonts, Ligatures and Kerning, Special Fonts, Fonts
8248 @subsection Artificial Fonts
8249 @cindex artificial fonts
8250 @cindex fonts, artificial
8252 There are a number of requests and escapes for artificially creating
8253 fonts.  These are largely vestiges of the days when output devices
8254 did not have a wide variety of fonts, and when @code{nroff} and
8255 @code{troff} were separate programs.  Most of them are no longer
8256 necessary in GNU @code{troff}.  Nevertheless, they are supported.
8258 @DefescList {\\H, ', height, '}
8259 @DefescItem {\\H, ', @t{+}@Var{height}, '}
8260 @DefescListEnd {\\H, ', @t{-}@Var{height}, '}
8261 @cindex changing the font height (@code{\H})
8262 @cindex font height, changing (@code{\H})
8263 @cindex height, font, changing (@code{\H})
8264 Change (increment, decrement) the height of the current font, but not
8265 the width.  If @var{height} is zero, restore the original height.
8266 Default scaling indicator is @samp{z}.
8268 Currently, only the @option{-Tps} device supports this feature.
8270 Note that @code{\H} doesn't produce an input token in @code{gtroff}.
8271 As a consequence, it can be used in requests like @code{mc} (which
8272 expects a single character as an argument) to change the font on
8273 the fly:
8275 @Example
8276 .mc \H'+5z'x\H'0'
8277 @endExample
8279 In compatibility mode, @code{gtroff} behaves differently:  If an
8280 increment or decrement is used, it is always taken relative to the
8281 current point size and not relative to the previously selected font
8282 height.  Thus,
8284 @Example
8285 .cp 1
8286 \H'+5'test \H'+5'test
8287 @endExample
8289 @noindent
8290 prints the word @samp{test} twice with the same font height (five
8291 points larger than the current font size).
8292 @endDefesc
8294 @DefescList {\\S, ', slant, '}
8295 @cindex changing the font slant (@code{\S})
8296 @cindex font slant, changing (@code{\S})
8297 @cindex slant, font, changing (@code{\S})
8298 Slant the current font by @var{slant} degrees.  Positive values slant
8299 to the right.
8301 Currently, only the @option{-Tps} device supports this feature.
8303 Note that @code{\S} doesn't produce an input token in @code{gtroff}.
8304 As a consequence, it can be used in requests like @code{mc} (which
8305 expects a single character as an argument) to change the font on
8306 the fly:
8308 @Example
8309 .mc \S'20'x\S'0'
8310 @endExample
8312 This request is incorrectly documented in the original @acronym{UNIX}
8313 troff manual; the slant is always set to an absolute value.
8314 @endDefesc
8316 @Defreq {ul, [@Var{lines}]}
8317 @cindex underlining (@code{ul})
8318 The @code{ul} request normally underlines subsequent lines if a TTY
8319 output device is used.  Otherwise, the lines are printed in italics
8320 (only the term `underlined' is used in the following).  The single
8321 argument is the number of input lines to be underlined; with no
8322 argument, the next line is underlined.  If @var{lines} is zero or
8323 negative, stop the effects of @code{ul} (if it was active).  Requests
8324 and empty lines do not count for computing the number of underlined
8325 input lines, even if they produce some output like @code{tl}.  Lines
8326 inserted by macros (e.g.@: invoked by a trap) do count.
8328 At the beginning of @code{ul}, the current font is stored and the
8329 underline font is activated.  Within the span of a @code{ul} request,
8330 it is possible to change fonts, but after the last line affected by
8331 @code{ul} the saved font is restored.
8333 This number of lines still to be underlined is associated with the
8334 current environment (@pxref{Environments}).  The underline font can be
8335 changed with the @code{uf} request.
8337 @c XXX @xref should be changed to grotty
8339 @c @xref{Troff and Nroff Mode}, for a discussion how underlining is
8340 @c implemented in for TTY output devices, and which problems can arise.
8342 The @code{ul} request does not underline spaces.
8343 @endDefreq
8345 @Defreq {cu, [@Var{lines}]}
8346 @cindex continuous underlining (@code{cu})
8347 @cindex underlining, continuous (@code{cu})
8348 The @code{cu} request is similar to @code{ul} but underlines spaces as
8349 well (if a TTY output device is used).
8350 @endDefreq
8352 @Defreq {uf, font}
8353 @cindex underline font (@code{uf})
8354 @cindex font for underlining (@code{uf})
8355 Set the underline font (globally) used by @code{ul} and @code{cu}.  By
8356 default, this is the font at position@w{ }2.  @var{font} can be either
8357 a non-negative font position or the name of a font.
8358 @endDefreq
8360 @DefreqList {bd, font [@Var{offset}]}
8361 @DefreqItem {bd, font1 font2 [@Var{offset}]}
8362 @DefregListEnd {.b}
8363 @cindex imitating bold face (@code{bd})
8364 @cindex bold face, imitating (@code{bd})
8365 Artificially create a bold font by printing each glyph twice,
8366 slightly offset.
8368 Two syntax forms are available.
8370 @itemize @bullet
8371 @item
8372 Imitate a bold font unconditionally.  The first argument specifies the
8373 font to embolden, and the second is the number of basic units, minus
8374 one, by which the two glyphs are offset.  If the second argument is
8375 missing, emboldening is turned off.
8377 @var{font} can be either a non-negative font position or the name of a
8378 font.
8380 @var{offset} is available in the @code{.b} read-only register if a
8381 special font is active; in the @code{bd} request, its default unit is
8382 @samp{u}.
8384 @cindex @code{fspecial} request, and imitating bold
8385 @kindex special
8386 @cindex embolding of special fonts
8387 @cindex special fonts, emboldening
8388 @item
8389 Imitate a bold form conditionally.  Embolden @var{font1} by
8390 @var{offset} only if font @var{font2} is the current font.  This
8391 command can be issued repeatedly to set up different emboldening
8392 values for different current fonts.  If the second argument is
8393 missing, emboldening is turned off for this particular current font.
8395 This affects special fonts only (either set up with the @code{special}
8396 command in font files or with the @code{fspecial} request).
8397 @end itemize
8398 @endDefreq
8400 @Defreq {cs, font [@Var{width} [@Var{em-size}]]}
8401 @cindex constant glyph space mode (@code{cs})
8402 @cindex mode for constant glyph space (@code{cs})
8403 @cindex glyph, constant space
8404 @cindex @code{ps} request, and constant glyph space mode
8405 Switch to and from @dfn{constant glyph space mode}.  If activated, the
8406 width of every glyph is @math{@var{width}/36} ems.  The em size is
8407 given absolutely by @var{em-size}; if this argument is missing, the em
8408 value is taken from the current font size (as set with the @code{ps}
8409 request) when the font is effectively in use.  Without second and
8410 third argument, constant glyph space mode is deactivated.
8412 Default scaling indicator for @var{em-size} is @samp{z}; @var{width} is
8413 an integer.
8414 @endDefreq
8416 @c ---------------------------------------------------------------------
8418 @node Ligatures and Kerning,  , Artificial Fonts, Fonts
8419 @subsection Ligatures and Kerning
8420 @cindex ligatures and kerning
8421 @cindex kerning and ligatures
8423 Ligatures are groups of characters that are run together, i.e, producing
8424 a single glyph.  For example, the letters `f' and `i' can form a
8425 ligature `fi' as in the word `file'.  This produces a cleaner look
8426 (albeit subtle) to the printed output.  Usually, ligatures are not
8427 available in fonts for TTY output devices.
8429 Most @sc{PostScript} fonts support the fi and fl ligatures.  The C/A/T
8430 typesetter that was the target of @acronym{AT&T} @code{troff} also
8431 supported `ff', `ffi', and `ffl' ligatures.  Advanced typesetters or
8432 `expert' fonts may include ligatures for `ft' and `ct', although GNU
8433 @code{troff} does not support these (yet).
8435 @DefreqList {lg, [@Var{flag}]}
8436 @DefregListEnd {.lg}
8437 @cindex activating ligatures (@code{lg})
8438 @cindex ligatures, activating (@code{lg})
8439 @cindex ligatures enabled register (@code{.lg})
8440 Switch the ligature mechanism on or off; if the parameter is non-zero
8441 or missing, ligatures are enabled, otherwise disabled.  Default is on.
8442 The current ligature mode can be found in the read-only number register
8443 @code{.lg} (set to 1 or@w{ }2 if ligatures are enabled, 0@w{ }otherwise).
8445 Setting the ligature mode to@w{ }2 enables the two-character ligatures
8446 (fi, fl, and ff) and disables the three-character ligatures (ffi and
8447 ffl).
8448 @endDefreq
8450 @dfn{Pairwise kerning} is another subtle typesetting mechanism that
8451 modifies the distance between a glyph pair to improve readability.
8452 In most cases (but not always) the distance is decreased.
8453 @ifnotinfo
8454 For example, compare the combination of the letters `V' and `A'.  With
8455 kerning, `VA' is printed.  Without kerning it appears as `V@w{}A'.
8456 @end ifnotinfo
8457 Typewriter-like fonts and fonts for terminals where all glyphs
8458 have the same width don't use kerning.
8460 @DefreqList {kern, [@Var{flag}]}
8461 @DefregListEnd {.kern}
8462 @cindex activating kerning (@code{kern})
8463 @cindex kerning, activating (@code{kern})
8464 @cindex kerning enabled register (@code{.kern})
8465 Switch kerning on or off.  If the parameter is non-zero or missing,
8466 enable pairwise kerning, otherwise disable it.  The read-only number
8467 register @code{.kern} is set to@w{ }1 if pairwise kerning is enabled,
8468 0@w{ }otherwise.
8470 @cindex zero width space character (@code{\&})
8471 @cindex character, zero width space (@code{\&})
8472 @cindex space character, zero width (@code{\&})
8473 If the font description file contains pairwise kerning information,
8474 glyphs from that font are kerned.  Kerning between two glyphs
8475 can be inhibited by placing @code{\&} between them: @samp{V\&A}.
8477 @xref{Font File Format}.
8478 @endDefreq
8480 @cindex track kerning
8481 @cindex kerning, track
8482 @dfn{Track kerning} expands or reduces the space between glyphs.
8483 This can be handy, for example, if you need to squeeze a long word
8484 onto a single line or spread some text to fill a narrow column.  It
8485 must be used with great care since it is usually considered bad
8486 typography if the reader notices the effect.
8488 @Defreq {tkf, f s1 n1 s2 n2}
8489 @cindex activating track kerning (@code{tkf})
8490 @cindex track kerning, activating (@code{tkf})
8491 Enable track kerning for font@w{ }@var{f}.  If the current font is@w{
8492 }@var{f} the width of every glyph is increased by an amount
8493 between @var{n1} and @var{n2} (@var{n1}, @var{n2} can be negative); if
8494 the current point size is less than or equal to @var{s1} the width is
8495 increased by @var{n1}; if it is greater than or equal to @var{s2} the
8496 width is increased by @var{n2}; if the point size is greater than or
8497 equal to @var{s1} and less than or equal to @var{s2} the increase in
8498 width is a linear function of the point size.
8500 The default scaling indicator is @samp{z} for @var{s1} and @var{s2},
8501 @samp{p} for @var{n1} and @var{n2}.
8503 Note that the track kerning amount is added even to the rightmost glyph
8504 in a line; for large values it is thus recommended to increase the line
8505 length by the same amount to compensate it.
8506 @endDefreq
8508 Sometimes, when typesetting letters of different fonts, more or less
8509 space at such boundaries are needed.  There are two escapes to help
8510 with this.
8512 @Defesc {\\/, , , }
8513 @cindex italic correction (@code{\/})
8514 @cindex correction, italic (@code{\/})
8515 @cindex correction between italic and roman glyph (@code{\/}, @code{\,})
8516 @cindex roman glyph, correction after italic glyph (@code{\/})
8517 @cindex italic glyph, correction before roman glyph (@code{\/})
8518 @cindex glyph, italic correction (@code{\/})
8519 Increase the width of the preceding glyph so that the spacing
8520 between that glyph and the following glyph is correct if the
8521 following glyph is a roman glyph.  For example, if an
8522 italic@w{ }@code{f} is immediately followed by a roman right
8523 parenthesis, then in many fonts the top right portion of the@w{ }@code{f}
8524 overlaps the top left of the right parenthesis.  Use this escape
8525 sequence whenever an italic glyph is immediately followed by a
8526 roman glyph without any intervening space.  This small amount of
8527 space is also called @dfn{italic correction}.
8529 @iftex
8530 @example
8531 @group
8532 \f[I]f\f[R])
8533     @result{} {@it f}@r{)}
8534 \f[I]f\/\f[R])
8535     @result{} @i{f}@r{)}
8536 @end group
8537 @end example
8538 @end iftex
8539 @endDefesc
8541 @Defesc {\\\,, , , }
8542 @cindex left italic correction (@code{\,})
8543 @cindex correction, left italic (@code{\,})
8544 @cindex glyph, left italic correction (@code{\,})
8545 @cindex roman glyph, correction before italic glyph (@code{\,})
8546 @cindex italic glyph, correction after roman glyph (@code{\,})
8547 Modify the spacing of the following glyph so that the spacing
8548 between that glyph and the preceding glyph is correct if the
8549 preceding glyph is a roman glyph.  Use this escape sequence
8550 whenever a roman glyph is immediately followed by an italic
8551 glyph without any intervening space.  In analogy to above, this
8552 space could be called @dfn{left italic correction}, but this term
8553 isn't used widely.
8555 @iftex
8556 @example
8557 @group
8558 q\f[I]f
8559     @result{} @r{q}@i{f}
8560 q\,\f[I]f
8561     @result{} @r{q}@math{@ptexcomma}@i{f}
8562 @end group
8563 @end example
8564 @end iftex
8565 @endDefesc
8567 @Defesc {\\&, , , }
8568 Insert a zero-width character, which is invisible.  Its intended use
8569 is to stop interaction of a character with its surrounding.
8571 @itemize @bullet
8572 @item
8573 It prevents the insertion of extra space after an end-of-sentence
8574 character.
8576 @Example
8577 Test.
8578 Test.
8579     @result{} Test.  Test.
8580 Test.\&
8581 Test.
8582     @result{} Test. Test.
8583 @endExample
8585 @item
8586 It prevents interpretation of a control character at the beginning of
8587 an input line.
8589 @Example
8590 .Test
8591     @result{} warning: `Test' not defined
8592 \&.Test
8593     @result{} .Test
8594 @endExample
8596 @item
8597 It prevents kerning between two glyphs.
8599 @ifnotinfo
8600 @example
8601 @group
8603     @result{} @r{VA}
8604 V\&A
8605     @result{} @r{V@w{}A}
8606 @end group
8607 @end example
8608 @end ifnotinfo
8610 @item
8611 It is needed to map an arbitrary character to nothing in the @code{tr}
8612 request (@pxref{Character Translations}).
8613 @end itemize
8614 @endDefesc
8616 @Defesc {\\), , , }
8617 This escape is similar to @code{\&} except that it behaves like a
8618 character declared with the @code{cflags} request to be transparent
8619 for the purposes of an end-of-sentence character.
8621 Its main usage is in macro definitions to protect against arguments
8622 starting with a control character.
8624 @Example
8625 .de xxx
8626 \)\\$1
8628 .de yyy
8629 \&\\$1
8631 This is a test.\c
8632 .xxx '
8633 This is a test.
8634     @result{}This is a test.'  This is a test.
8635 This is a test.\c
8636 .yyy '
8637 This is a test.
8638     @result{}This is a test.' This is a test.
8639 @endExample
8640 @endDefesc
8643 @c =====================================================================
8645 @node Sizes, Strings, Fonts, gtroff Reference
8646 @section Sizes
8647 @cindex sizes
8649 @cindex baseline
8650 @cindex type size
8651 @cindex size of type
8652 @cindex vertical spacing
8653 @cindex spacing, vertical
8654 @code{gtroff} uses two dimensions with each line of text, type size
8655 and vertical spacing.  The @dfn{type size} is approximately the height
8656 of the tallest glyph.@footnote{This is usually the parenthesis.
8657 Note that in most cases the real dimensions of the glyphs in a font
8658 are @emph{not} related to its type size!  For example, the standard
8659 @sc{PostScript} font families `Times Roman', `Helvetica', and
8660 `Courier' can't be used together at 10@dmn{pt}; to get acceptable
8661 output, the size of `Helvetica' has to be reduced by one point, and
8662 the size of `Courier' must be increased by one point.}  @dfn{Vertical
8663 spacing} is the amount of space @code{gtroff} allows for a line of
8664 text; normally, this is about 20%@w{ }larger than the current type
8665 size.  Ratios smaller than this can result in hard-to-read text;
8666 larger than this, it spreads the text out more vertically (useful for
8667 term papers).  By default, @code{gtroff} uses 10@w{ }point type on
8668 12@w{ }point spacing.
8670 @cindex leading
8671 The difference between type size and vertical spacing is known, by
8672 typesetters, as @dfn{leading} (this is pronounced `ledding').
8674 @menu
8675 * Changing Type Sizes::
8676 * Fractional Type Sizes::
8677 @end menu
8679 @c ---------------------------------------------------------------------
8681 @node Changing Type Sizes, Fractional Type Sizes, Sizes, Sizes
8682 @subsection Changing Type Sizes
8684 @DefreqList {ps, [@Var{size}]}
8685 @DefreqItem {ps, @t{+}@Var{size}}
8686 @DefreqItem {ps, @t{-}@Var{size}}
8687 @DefescItem {\\s, , size, }
8688 @DefregListEnd {.s}
8689 @cindex changing type sizes (@code{ps}, @code{\s})
8690 @cindex type sizes, changing (@code{ps}, @code{\s})
8691 @cindex point sizes, changing (@code{ps}, @code{\s})
8692 Use the @code{ps} request or the @code{\s} escape to change (increase,
8693 decrease) the type size (in points).  Specify @var{size} as either an
8694 absolute point size, or as a relative change from the current size.
8695 The size@w{ }0, or no argument, goes back to the previous size.
8697 Default scaling indicator of @code{size} is @samp{z}.  If @code{size}
8698 is zero or negative, it is set to 1@dmn{u}.
8700 @cindex type size registers (@code{.s}, @code{.ps})
8701 @cindex point size registers (@code{.s}, @code{.ps})
8702 The read-only number register @code{.s} returns the point size in
8703 points as a decimal fraction.  This is a string.  To get the point
8704 size in scaled points, use the @code{.ps} register instead.
8706 @code{.s} is associated with the current environment
8707 (@pxref{Environments}).
8709 @Example
8710 snap, snap,
8711 .ps +2
8712 grin, grin,
8713 .ps +2
8714 wink, wink, \s+2nudge, nudge,\s+8 say no more!
8715 .ps 10
8716 @endExample
8718 The @code{\s} escape may be called in a variety of ways.  Much like
8719 other escapes there must be a way to determine where the argument ends
8720 and the text begins.  Any of the following forms are valid:
8722 @table @code
8723 @item \s@var{n}
8724 Set the point size to @var{n}@w{ }points.  @var{n}@w{ }must be either
8725 0 or in the range 4 to@w{ }39.
8727 @item \s+@var{n}
8728 @itemx \s-@var{n}
8729 Increase or decrease the point size by @var{n}@w{ }points.  @var{n}@w{
8730 }must be exactly one digit.
8732 @item \s(@var{nn}
8733 Set the point size to @var{nn}@w{ }points.  @var{nn} must be exactly
8734 two digits.
8736 @item \s+(@var{nn}
8737 @itemx \s-(@var{nn}
8738 @itemx \s(+@var{nn}
8739 @itemx \s(-@var{nn}
8740 Increase or decrease the point size by @var{nn}@w{ }points.  @var{nn}
8741 must be exactly two digits.
8742 @end table
8744 Note that @code{\s} doesn't produce an input token in @code{gtroff}.
8745 As a consequence, it can be used in requests like @code{mc} (which
8746 expects a single character as an argument) to change the font on
8747 the fly:
8749 @Example
8750 .mc \s[20]x\s[0]
8751 @endExample
8753 @xref{Fractional Type Sizes}, for yet another syntactical form of
8754 using the @code{\s} escape.
8755 @endDefreq
8757 @Defreq {sizes, s1 s2 @dots{} sn [0]}
8758 Some devices may only have certain permissible sizes, in which case
8759 @code{gtroff} rounds to the nearest permissible size.
8760 The @file{DESC} file specifies which sizes are permissible for the device.
8762 Use the @code{sizes} request to change the permissible sizes
8763 for the current output device.
8764 Arguments are in scaled points;
8765 the @code{sizescale} line in the
8766 @file{DESC} file for the output device
8767 provides the scaling factor.
8768 For example, if the scaling factor is 1000,
8769 then the value 12000 is 12@w{ }points.
8771 Each argument can be a single point size (such as @samp{12000}),
8772 or a range of sizes (such as @samp{4000-72000}).
8773 You can optionally end the list with a zero.
8774 @endDefreq
8776 @DefreqList {vs, [@Var{space}]}
8777 @DefreqItem {vs, @t{+}@Var{space}}
8778 @DefreqItem {vs, @t{-}@Var{space}}
8779 @DefregListEnd {.v}
8780 @cindex changing vertical line spacing (@code{vs})
8781 @cindex vertical line spacing, changing (@code{vs})
8782 @cindex vertical line spacing register (@code{.v})
8783 Change (increase, decrease) the vertical spacing by @var{space}.  The
8784 default scaling indicator is @samp{p}.
8786 If @code{vs} is called without an argument, the vertical spacing is
8787 reset to the previous value before the last call to @code{vs}.
8789 @cindex @code{.V} register, and @code{vs}
8790 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
8791 zero or negative; the vertical spacing is then set to the vertical
8792 resolution (as given in the @code{.V} register).
8794 The read-only number register @code{.v} contains the current vertical
8795 spacing; it is associated with the current environment
8796 (@pxref{Environments}).
8797 @endDefreq
8799 @cindex vertical line spacing, effective value
8800 The effective vertical line spacing consists of four components.
8802 @itemize @bullet
8803 @item
8804 The vertical line spacing as set with the @code{vs} request.
8806 @cindex post-vertical line spacing
8807 @cindex line spacing, post-vertical (@code{pvs})
8808 @item
8809 The @dfn{post-vertical line spacing} as set with the @code{pvs} request.
8810 This is vertical space which will be added after a line has been
8811 output.
8813 @cindex extra pre-vertical line space (@code{\x})
8814 @cindex line space, extra pre-vertical (@code{\x})
8815 @item
8816 The @dfn{extra pre-vertical line space} as set with the @code{\x} request,
8817 using a negative value.  This is vertical space which will be added once
8818 before the current line has been output.
8820 @cindex extra post-vertical line space (@code{\x})
8821 @cindex line space, extra post-vertical (@code{\x})
8822 @item
8823 The @dfn{extra post-vertical line space} as set with the @code{\x} request,
8824 using a positive value.  This is vertical space which will be added once
8825 after the current line has been output.
8826 @end itemize
8828 @cindex double-spacing (@code{vs}, @code{pvs})
8829 It is usually better to use @code{vs} or @code{pvs} instead of @code{ls}
8830 to produce double-spaced documents: @code{vs} and @code{pvs} have a finer
8831 granularity for the inserted vertical space compared to @code{ls};
8832 furthermore, certain preprocessors assume single-spacing.
8834 @xref{Manipulating Spacing}, for more details on the @code{\x} escape
8835 and the @code{ls} request.
8837 @DefreqList {pvs, [@Var{space}]}
8838 @DefreqItem {pvs, @t{+}@Var{space}}
8839 @DefreqItem {pvs, @t{-}@Var{space}}
8840 @DefregListEnd {.pvs}
8841 @cindex @code{ls} request, alternative to (@code{pvs})
8842 @cindex post-vertical line spacing, changing (@code{pvs})
8843 @cindex post-vertical line spacing register (@code{.pvs})
8844 Change (increase, decrease) the post-vertical spacing by
8845 @var{space}.  The default scaling indicator is @samp{p}.
8847 If @code{pvs} is called without an argument, the post-vertical spacing is
8848 reset to the previous value before the last call to @code{pvs}.
8850 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
8851 zero or negative; the vertical spacing is then set to zero.
8853 The read-only number register @code{.pvs} contains the current
8854 post-vertical spacing; it is associated with the current environment
8855 (@pxref{Environments}).
8856 @endDefreq
8859 @c ---------------------------------------------------------------------
8861 @node Fractional Type Sizes,  , Changing Type Sizes, Sizes
8862 @subsection Fractional Type Sizes
8863 @cindex fractional type sizes
8864 @cindex fractional point sizes
8865 @cindex type sizes, fractional
8866 @cindex point sizes, fractional
8867 @cindex sizes, fractional
8869 @cindex @code{s} unit
8870 @cindex unit, @code{s}
8871 @cindex @code{z} unit
8872 @cindex unit, @code{z}
8873 @cindex @code{ps} request, with fractional type sizes
8874 @cindex @code{cs} request, with fractional type sizes
8875 @cindex @code{tkf} request, with fractional type sizes
8876 @cindex @code{\H}, with fractional type sizes
8877 @cindex @code{\s}, with fractional type sizes
8878 A @dfn{scaled point} is equal to @math{1/@var{sizescale}} points,
8879 where @var{sizescale} is specified in the @file{DESC} file (1@w{ }by
8880 default).  There is a new scale indicator @samp{z} which has the
8881 effect of multiplying by @var{sizescale}.  Requests and escape
8882 sequences in @code{gtroff} interpret arguments that represent a point
8883 size as being in units of scaled points, but they evaluate each such
8884 argument using a default scale indicator of @samp{z}.  Arguments
8885 treated in this way are the argument to the @code{ps} request, the
8886 third argument to the @code{cs} request, the second and fourth
8887 arguments to the @code{tkf} request, the argument to the @code{\H}
8888 escape sequence, and those variants of the @code{\s} escape sequence
8889 that take a numeric expression as their argument (see below).
8891 For example, suppose @var{sizescale} is@w{ }1000; then a scaled point
8892 is equivalent to a millipoint; the request @w{@samp{.ps 10.25}} is
8893 equivalent to @w{@samp{.ps 10.25z}} and thus sets the point size to
8894 10250@w{ }scaled points, which is equal to 10.25@w{ }points.
8896 @code{gtroff} disallows the use of the @samp{z} scale indicator in
8897 instances where it would make no sense, such as a numeric
8898 expression whose default scale indicator was neither @samp{u} nor
8899 @samp{z}.  Similarly it would make
8900 no sense to use a scaling indicator other than @samp{z} or @samp{u} in a
8901 numeric expression whose default scale indicator was @samp{z}, and so
8902 @code{gtroff} disallows this as well.
8904 There is also new scale indicator @samp{s} which multiplies by the
8905 number of units in a scaled point.  So, for example, @samp{\n[.ps]s} is
8906 equal to @samp{1m}.  Be sure not to confuse the @samp{s} and @samp{z}
8907 scale indicators.
8909 @Defreg {.ps}
8910 A read-only number register returning the point size in scaled points.
8912 @code{.ps} is associated with the current environment
8913 (@pxref{Environments}).
8914 @endDefreg
8916 @DefregList {.psr}
8917 @DefregListEnd {.sr}
8918 @cindex last-requested point size registers (@code{.psr}, @code{.sr})
8919 @cindex point size registers, last-requested (@code{.psr}, @code{.sr})
8920 @cindex @code{.ps} register, in comparison with @code{.psr}
8921 @cindex @code{.s} register, in comparison with @code{.sr}
8922 The last-requested point size in scaled points is contained in the
8923 @code{.psr} read-only number register.  The last requested point size
8924 in points as a decimal fraction can be found in @code{.sr}.  This is a
8925 string-valued read-only number register.
8927 Note that the requested point sizes are device-independent, whereas
8928 the values returned by the @code{.ps} and @code{.s} registers are not.
8929 For example, if a point size of 11@dmn{pt} is requested, and a
8930 @code{sizes} request (or a @code{sizescale} line in a @file{DESC} file)
8931 specifies 10.95@dmn{pt} instead, this value is actually used.
8933 Both registers are associated with the current environment
8934 (@pxref{Environments}).
8935 @endDefreg
8937 The @code{\s} escape has the following syntax for working with
8938 fractional type sizes:
8940 @table @code
8941 @item \s[@var{n}]
8942 @itemx \s'@var{n}'
8943 Set the point size to @var{n}@w{ }scaled points; @var{n}@w{ }is a numeric
8944 expression with a default scale indicator of @samp{z}.
8946 @item \s[+@var{n}]
8947 @itemx \s[-@var{n}]
8948 @itemx \s+[@var{n}]
8949 @itemx \s-[@var{n}]
8950 @itemx \s'+@var{n}'
8951 @itemx \s'-@var{n}'
8952 @itemx \s+'@var{n}'
8953 @itemx \s-'@var{n}'
8954 Increase or or decrease the point size by @var{n}@w{ }scaled points;
8955 @var{n}@w{ }is a numeric expression with a default scale indicator of
8956 @samp{z}.
8957 @end table
8959 @xref{Font Files}.
8962 @c =====================================================================
8964 @node Strings, Conditionals and Loops, Sizes, gtroff Reference
8965 @section Strings
8966 @cindex strings
8968 @code{gtroff} has string variables, which are entirely for user
8969 convenience (i.e.@: there are no built-in strings exept @code{.T}, but
8970 even this is a read-write string variable).
8972 @DefreqList {ds, name [@Var{string}]}
8973 @DefreqItem {ds1, name [@Var{string}]}
8974 @DefescItem {\\*, , n, }
8975 @DefescItem {\\*, @lparen{}, nm, }
8976 @DefescListEnd {\\*, @lbrack{}, name, @rbrack{}}
8977 @cindex string interpolation (@code{\*})
8978 @cindex string expansion (@code{\*})
8979 @cindex interpolation of strings (@code{\*})
8980 @cindex expansion of strings (@code{\*})
8981 Define and access a string variable @var{name} (one-character name@w{
8982 }@var{n}, two-character name @var{nm}).  If @var{name} already exists,
8983 @code{ds} overwrites the previous definition.
8985 Example:
8987 @Example
8988 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d
8990 The \*(UX Operating System
8991 @endExample
8993 The @code{\*} escape @dfn{interpolates} (expands in-place) a
8994 previously-defined string variable.  To be more precise, the stored
8995 string is pushed onto the input stack which is then parsed by
8996 @code{gtroff}.  Similar to number registers, it is possible to nest
8997 strings, i.e. string variables can be called within string variables.
8999 If the string named by the @code{\*} escape does not exist, it is
9000 defined as empty, and a warning of type @samp{mac} is emitted (see
9001 @ref{Debugging}, for more details).
9003 @cindex comments, with @code{ds}
9004 @cindex @code{ds} request, and comments
9005 @strong{Caution:} Unlike other requests, the second argument to the
9006 @code{ds} request takes up the entire line including trailing spaces.
9007 This means that comments on a line with such a request can introduce
9008 unwanted space into a string.
9010 @Example
9011 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d \" UNIX trademark
9012 @endExample
9014 @noindent
9015 Instead the comment should be put on another line or have the comment
9016 escape adjacent with the end of the string.
9018 @Example
9019 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d\"  UNIX trademark
9020 @endExample
9022 @cindex trailing quotes
9023 @cindex quotes, trailing
9024 @cindex leading spaces with @code{ds}
9025 @cindex spaces with @code{ds}
9026 @cindex @code{ds} request, and leading spaces
9027 To produce leading space the string can be started with a double
9028 quote.  No trailing quote is needed; in fact, any trailing quote is
9029 included in your string.
9031 @Example
9032 .ds sign "           Yours in a white wine sauce,
9033 @endExample
9035 @cindex multi-line strings
9036 @cindex strings, multi-line
9037 @cindex newline character, in strings, escaping
9038 @cindex escaping newline characters, in strings
9039 Strings are not limited to a single line of text.  A string can span
9040 several lines by escaping the newlines with a backslash.  The
9041 resulting string is stored @emph{without} the newlines.
9043 @Example
9044 .ds foo lots and lots \
9045 of text are on these \
9046 next several lines
9047 @endExample
9049 It is not possible to have real newlines in a string.  To put a single
9050 double quote character into a string, use two consecutive double quote
9051 characters.
9053 The @code{ds1} request turns off compatibility mode
9054 while interpreting a string.  To be more precise, a @dfn{compatibility
9055 save} input token is inserted at the beginning of  the string, and a
9056 @dfn{compatibility restore} input token at the end.
9058 @Example
9059 .nr xxx 12345
9060 .ds aa The value of xxx is \\n[xxx].
9061 .ds1 bb The value of xxx ix \\n[xxx].
9063 .cp 1
9065 \*(aa
9066     @result{} warning: number register `[' not defined
9067     @result{} The value of xxx is 0xxx].
9068 \*(bb
9069     @result{} The value of xxx ix 12345.
9070 @endExample
9072 @cindex name space, common, of macros, diversions, and strings
9073 @cindex common name space of macros, diversions, and strings
9074 @cindex macros, shared name space with strings and diversions
9075 @cindex strings, shared name space with macros and diversions
9076 @cindex diversions, shared name space with macros and strings
9077 Strings, macros, and diversions (and boxes) share the same name space.
9078 Internally, even the same mechanism is used to store them.  This has
9079 some interesting consequences.  For example, it is possible to call a
9080 macro with string syntax and vice versa.
9082 @Example
9083 .de xxx
9084 a funny test.
9086 This is \*[xxx]
9087     @result{} This is a funny test.
9089 .ds yyy a funny test
9090 This is
9091 .yyy
9092     @result{} This is a funny test.
9093 @endExample
9095 Diversions and boxes can be also called with string syntax.  It is not
9096 possible to pass arguments to a macro if called with @code{\*}.
9098 Another consequence is that you can copy one-line diversions or boxes
9099 to a string.
9101 @Example
9102 .di xxx
9103 a \fItest\fR
9106 .ds yyy This is \*[xxx]\c
9107 \*[yyy].
9108     @result{} @r{This is a }@i{test}.
9109 @endExample
9111 @noindent
9112 As the previous example shows, it is possible to store formatted
9113 output in strings.  The @code{\c} escape prevents the insertion of an
9114 additional blank line in the output.
9116 Copying diversions longer than a single output line produces
9117 unexpected results.
9119 @Example
9120 .di xxx
9121 a funny
9123 test
9126 .ds yyy This is \*[xxx]\c
9127 \*[yyy].
9128     @result{} test This is a funny.
9129 @endExample
9131 Usually, it is not predictable whether a diversion contains one or
9132 more output lines, so this mechanism should be avoided.  With
9133 @acronym{UNIX} @code{troff}, this was the only solution to strip off a
9134 final newline from a diversion.  Another disadvantage is that the
9135 spaces in the copied string are already formatted, making them
9136 unstretchable.  This can cause ugly results.
9138 @cindex stripping final newline in diversions
9139 @cindex diversion, stripping final newline
9140 @cindex final newline, stripping in diversions
9141 @cindex newline, final, stripping in diversions
9142 @cindex horizontal space, unformatting
9143 @cindex space, horizontal, unformatting
9144 @cindex unformatting horizontal space
9145 A clean solution to this problem is available in GNU @code{troff},
9146 using the requests @code{chop} to remove the final newline of a
9147 diversion, and @code{unformat} to make the horizontal spaces
9148 stretchable again.
9150 @Example
9151 .box xxx
9152 a funny
9154 test
9156 .box
9157 .chop xxx
9158 .unformat xxx
9159 This is \*[xxx].
9160     @result{} This is a funny test.
9161 @endExample
9163 @xref{Gtroff Internals}, for more information.
9164 @endDefreq
9166 @DefreqList {as, name [@Var{string}]}
9167 @DefreqListEnd {as1, name [@Var{string}]}
9168 @cindex appending to a string (@code{as})
9169 @cindex string, appending (@code{as})
9170 The @code{as} request is similar to @code{ds} but appends @var{string}
9171 to the string stored as @var{name} instead of redefining it.  If
9172 @var{name} doesn't exist yet, it is created.
9174 @Example
9175 .as sign " with shallots, onions and garlic,
9176 @endExample
9178 The @code{as1} request is similar to @code{as}, but compatibility mode
9179 is switched off while the appended string is interpreted.  To be more
9180 precise, a @dfn{compatibility save} input token is inserted at the
9181 beginning of the appended string, and a @dfn{compatibility restore}
9182 input token at the end.
9183 @endDefreq
9185 Rudimentary string manipulation routines are given with the next two
9186 requests.
9188 @Defreq {substring, str n1 [@Var{n2}]}
9189 @cindex substring (@code{substring})
9190 Replace the string in register@w{ }@var{str} with the substring
9191 defined by the indices @var{n1} and@w{ }@var{n2}.  The first character
9192 in the string has index one.  If @var{n2} is omitted, it is taken to
9193 be equal to the string's length.  If the index value @var{n1} or
9194 @var{n2} is negative or zero, it is counted from the end of the
9195 string, going backwards: The last character has index@w{ }0, the
9196 character before the last character has index@w{ }@minus{}1, etc.
9198 @Example
9199 .ds xxx abcdefgh
9200 .substring xxx 2 -3
9201 \*[xxx]
9202     @result{} bcde
9203 @endExample
9204 @endDefreq
9206 @Defreq {length, reg str}
9207 @cindex length of a string (@code{length})
9208 @cindex string, length of (@code{length})
9209 Compute the number of characters of @var{str} and return it in the
9210 number register @var{reg}.  If @var{reg} doesn't exist, it is created.
9211 @code{str} is read in copy mode.
9213 @Example
9214 .ds xxx abcd\h'3i'efgh
9215 .length yyy \n[xxx]
9216 \n[yyy]
9217     @result{} 14
9218 @endExample
9219 @endDefreq
9221 @Defreq {rn, xx yy}
9222 @cindex renaming request (@code{rn})
9223 @cindex request, renaming (@code{rn})
9224 @cindex renaming macro (@code{rn})
9225 @cindex macro, renaming (@code{rn})
9226 @cindex renaming string (@code{rn})
9227 @cindex string, renaming (@code{rn})
9228 @cindex renaming diversion (@code{rn})
9229 @cindex diversion, renaming (@code{rn})
9230 Rename the request, macro, diversion, or string @var{xx} to @var{yy}.
9231 @endDefreq
9233 @Defreq {rm, xx}
9234 @cindex removing request (@code{rm})
9235 @cindex request, removing (@code{rm})
9236 @cindex removing macro (@code{rm})
9237 @cindex macro, removing (@code{rm})
9238 @cindex removing string (@code{rm})
9239 @cindex string, removing (@code{rm})
9240 @cindex removing diversion (@code{rm})
9241 @cindex diversion, removing (@code{rm})
9242 Remove the request, macro, diversion, or string @var{xx}.  @code{gtroff}
9243 treats subsequent invocations as if the object had never been defined.
9244 @endDefreq
9246 @Defreq {als, new old}
9247 @cindex alias, string, creating (@code{als})
9248 @cindex alias, macro, creating (@code{als})
9249 @cindex alias, diversion, creating (@code{als})
9250 @cindex creating alias, for string (@code{als})
9251 @cindex creating alias, for macro (@code{als})
9252 @cindex creating alias, for diversion (@code{als})
9253 @cindex string, creating alias (@code{als})
9254 @cindex macro, creating alias (@code{als})
9255 @cindex diversion, creating alias (@code{als})
9256 Create an alias named @var{new} for the request, string, macro, or
9257 diversion object named @var{old}.  The new name and the old name are
9258 exactly equivalent (it is similar to a hard rather than a soft
9259 link). If @var{old} is undefined, @code{gtroff} generates a warning of
9260 type @samp{mac} and ignores the request.
9261 @endDefreq
9263 @Defreq {chop, xx}
9264 Remove (chop) the last character from the macro, string, or diversion
9265 named @var{xx}. This is useful for removing the newline from the end
9266 of diversions that are to be interpolated as strings.  This command
9267 can be used repeatedly; see @ref{Gtroff Internals}, for details on
9268 nodes inserted additionally by @code{gtroff}.
9269 @endDefreq
9271 @xref{Identifiers}, and @ref{Comments}.
9274 @c =====================================================================
9276 @node Conditionals and Loops, Writing Macros, Strings, gtroff Reference
9277 @section Conditionals and Loops
9278 @cindex conditionals and loops
9279 @cindex loops and conditionals
9281 @menu
9282 * Operators in Conditionals::
9283 * if-else::
9284 * while::
9285 @end menu
9287 @c ---------------------------------------------------------------------
9289 @node Operators in Conditionals, if-else, Conditionals and Loops, Conditionals and Loops
9290 @subsection Operators in Conditionals
9292 @cindex @code{if} request, operators to use with
9293 @cindex @code{while} request, operators to use with
9294 In @code{if} and @code{while} requests, there are several more
9295 operators available:
9297 @table @code
9298 @item e
9299 @itemx o
9300 True if the current page is even or odd numbered (respectively).
9302 @item n
9303 True if the document is being processed in nroff mode (i.e., the
9304 @code{.nroff} command has been issued).
9306 @item t
9307 True if the document is being processed in troff mode (i.e., the
9308 @code{.troff} command has been issued).
9310 @item v
9311 Always false.  This condition is for compatibility with other
9312 @code{troff} versions only.
9314 @item '@var{xxx}'@var{yyy}'
9315 True if the string @var{xxx} is equal to the string @var{yyy}.  Other
9316 characters can be used in place of the single quotes; the same set of
9317 delimiters as for the @code{\D} escape is used (@pxref{Escapes}).
9318 @code{gtroff} formats the strings before being compared:
9320 @Example
9321 .ie "|"\fR|\fP" \
9322 true
9323 .el \
9324 false
9325     @result{} true
9326 @endExample
9328 @noindent
9329 The resulting motions, glyph sizes, and fonts have to
9330 match,@footnote{The created output nodes must be identical.
9331 @xref{Gtroff Internals}.} and not the individual motion, size, and
9332 font requests.  In the previous example, @samp{|} and @samp{\fR|\fP}
9333 both result in a roman @samp{|} glyph with the same point size and
9334 at the same location on the page, so the strings are equal.  If
9335 @samp{.ft@w{ }I} had been added before the @samp{.ie}, the result
9336 would be ``false'' because (the first) @samp{|} produces an italic
9337 @samp{|} rather than a roman one.
9339 @item r @var{xxx}
9340 True if there is a number register named @var{xxx}.
9342 @item d @var{xxx}
9343 True if there is a string, macro, diversion, or request named @var{xxx}.
9345 @item m @var{xxx}
9346 True if there is a color named @var{xxx}.
9348 @item c @var{g}
9349 True if there is a glyph @var{g} available@footnote{The name of this
9350 conditional operator is a misnomer since it tests names of output
9351 glyphs.}; @var{g} is either an @acronym{ASCII} character or a special
9352 character (@code{\(@var{gg}} or @code{\[@var{ggg}]}); the condition
9353 is also true if @var{g} has been defined by the @code{char} request.
9354 @end table
9356 Note that these operators can't be combined with other operators like
9357 @samp{:} or @samp{&}; only a leading @samp{!} (without whitespace
9358 between the exclamation mark and the operator) can be used to negate
9359 the result.
9361 @Example
9362 .nr xxx 1
9363 .ie !r xxx \
9364 true
9365 .el \
9366 false
9367     @result{} false
9368 @endExample
9370 A whitespace after @samp{!} always evaluates to zero (this bizarre
9371 behaviour is due to compatibility with @acronym{UNIX} @code{troff}).
9373 @Example
9374 .nr xxx 1
9375 .ie ! r xxx \
9376 true
9377 .el \
9378 false
9379     @result{} r xxx true
9380 @endExample
9382 It is possible to omit the whitespace before the argument to the
9383 @samp{r}, @samp{d}, and @samp{c} operators.
9385 @xref{Expressions}.
9387 @c ---------------------------------------------------------------------
9389 @node if-else, while, Operators in Conditionals, Conditionals and Loops
9390 @subsection if-else
9391 @cindex if-else
9393 @code{gtroff} has if-then-else constructs like other languages, although
9394 the formatting can be painful.
9396 @Defreq {if, expr anything}
9397 Evaluate the expression @var{expr}, and executes @var{anything} (the
9398 remainder of the line) if @var{expr} evaluates to non-zero (true).
9399 @var{anything} is interpreted as though it was on a line by itself
9400 (except that leading spaces are swallowed).  @xref{Expressions}, for
9401 more info.
9403 @Example
9404 .nr xxx 1
9405 .nr yyy 2
9406 .if ((\n[xxx] == 1) & (\n[yyy] == 2)) true
9407     @result{} true
9408 @endExample
9409 @endDefreq
9411 @Defreq{nop, anything}
9412 Executes @var{anything}.
9413 This is similar to @code{.if@w{ }1}.
9414 @endDefreq
9416 @DefreqList {ie, expr anything}
9417 @DefreqListEnd {el, anything}
9418 Use the @code{ie} and @code{el} requests to write an if-then-else.
9419 The first request is the `if' part and the latter is the `else' part.
9421 @Example
9422 .ie n .ls 2 \" double-spacing in nroff
9423 .el   .ls 1 \" single-spacing in troff
9424 @endExample
9425 @endDefreq
9427 @c there is a bug in makeinfo <= 4.1a: you can't have `@{' as an argument
9428 @c to @deffn
9430 @c and in 4.2 you still can't use @{ in macros.
9432 @c @DefescList {\@{, , , }
9433 @c @DefescListEnd {\@}, , , }
9434 @deffn Escape @t{\@{}
9435 @deffnx Escape @t{\@}}
9436 @esindex \@{
9437 @esindex \@}
9438 @cindex begin of conditional block (@code{\@{})
9439 @cindex end of conditional block (@code{\@}})
9440 @cindex conditional block, begin (@code{\@{})
9441 @cindex conditional block, end (@code{\@}})
9442 @cindex block, conditional, begin (@code{\@{})
9443 @cindex block, condititional, end (@code{\@}})
9444 In many cases, an if (or if-else) construct needs to execute more than
9445 one request.  This can be done using the @code{\@{} and @code{\@}}
9446 escapes.  The following example shows the possible ways to use these
9447 escapes (note the position of the opening and closing braces).
9449 @Example
9450 .ie t \@{\
9451 .    ds lq ``
9452 .    ds rq ''
9453 .\@}
9454 .el \
9455 .\@{\
9456 .    ds lq "
9457 .    ds rq "\@}
9458 @endExample
9459 @c @endDefesc
9460 @end deffn
9462 @xref{Expressions}.
9464 @c ---------------------------------------------------------------------
9466 @node while,  , if-else, Conditionals and Loops
9467 @subsection while
9468 @cindex while
9470 @code{gtroff} provides a looping construct using the @code{while}
9471 request, which is used much like the @code{if} (and related) requests.
9473 @Defreq {while, expr anything}
9474 Evaluate the expression @var{expr}, and repeatedly execute
9475 @var{anything} (the remainder of the line) until @var{expr} evaluates
9476 to@w{ }0.
9478 @Example
9479 .nr a 0 1
9480 .while (\na < 9) \@{\
9481 \n+a,
9482 .\@}
9483 \n+a
9484     @result{} 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
9485 @endExample
9487 Some remarks.
9489 @cindex @code{de} request, and @code{while}
9490 @itemize @bullet
9491 @item
9492 The body of a @code{while} request is treated like the body of a
9493 @code{de} request: @code{gtroff} temporarily stores it in a macro
9494 which is deleted after the loop has been exited.  It can considerably
9495 slow down a macro if the body of the @code{while} request (within the
9496 macro) is large.  Each time the macro is executed, the @code{while}
9497 body is parsed and stored again as a temporary macro.
9499 @Example
9500 .de xxx
9501 .  nr num 10
9502 .  while (\\n[num] > 0) \@{\
9503 .    \" many lines of code
9504 .    nr num -1
9505 .  \@}
9507 @endExample
9509 @cindex recursive macros
9510 @cindex macros, recursive
9511 @noindent
9512 The traditional and ofter better solution (@acronym{UNIX} @code{troff}
9513 doesn't have the @code{while} request) is to use a recursive macro
9514 instead which is parsed only once during its definition.
9516 @Example
9517 .de yyy
9518 .  if (\\n[num] > 0) \@{\
9519 .    \" many lines of code
9520 .    nr num -1
9521 .    yyy
9522 .  \@}
9525 .de xxx
9526 .  nr num 10
9527 .  yyy
9529 @endExample
9531 @noindent
9532 Note that the number of available recursion levels is set to@w{ }1000
9533 (this is a compile-time constant value of @code{gtroff}).
9535 @item
9536 The closing brace of a @code{while} body must end a line.
9538 @Example
9539 .if 1 \@{\
9540 .  nr a 0 1
9541 .  while (\n[a] < 10) \@{\
9542 .    nop \n+[a]
9543 .\@}\@}
9544     @result{} unbalanced \@{ \@}
9545 @endExample
9546 @end itemize
9547 @endDefreq
9549 @Defreq {break, }
9550 @cindex @code{while} request, confusing with @code{br}
9551 @cindex @code{break} request, in a @code{while} loop
9552 @cindex @code{continue} request, in a @code{while} loop
9553 Break out of a @code{while} loop.  Be sure not to confuse this with
9554 the @code{br} request (causing a line break).
9555 @endDefreq
9557 @Defreq {continue, }
9558 Finish the current iteration of a @code{while} loop, immediately
9559 restarting the next iteration.
9560 @endDefreq
9562 @xref{Expressions}.
9565 @c =====================================================================
9567 @node Writing Macros, Page Motions, Conditionals and Loops, gtroff Reference
9568 @section Writing Macros
9569 @cindex writing macros
9570 @cindex macros, writing
9572 A @dfn{macro} is a collection of text and embedded commands which can
9573 be invoked multiple times.  Use macros to define common operations.
9575 @DefreqList {de, name [@Var{end}]}
9576 @DefreqItem {de1, name [@Var{end}]}
9577 @DefreqListEnd {dei, name [@Var{end}]}
9578 Define a new macro named @var{name}.  @code{gtroff} copies subsequent
9579 lines (starting with the next one) into an internal buffer until it
9580 encounters the line @samp{..} (two dots).  The optional second
9581 argument to @code{de} changes this to a macro to @samp{.@var{end}}.
9583 There can be whitespace after the first dot in the line containing the
9584 ending token (either @samp{.} or macro @samp{@var{end}}).
9586 Here a small example macro called @samp{P} which causes a break and
9587 inserts some vertical space.  It could be used to separate paragraphs.
9589 @Example
9590 .de P
9591 .  br
9592 .  sp .8v
9594 @endExample
9596 The following example defines a macro within another.  Remember that
9597 expansion must be protected twice; once for reading the macro and
9598 once for executing.
9600 @Example
9601 \# a dummy macro to avoid a warning
9602 .de end
9605 .de foo
9606 .  de bar end
9607 .    nop \f[B]Hallo \\\\$1!\f[]
9608 .  end
9611 .foo
9612 .bar Joe
9613     @result{} @b{Hallo Joe!}
9614 @endExample
9616 @noindent
9617 Since @code{\f} has no expansion, it isn't necessary to protect its
9618 backslash.  Had we defined another macro within @code{bar} which takes
9619 a parameter, eight backslashes would be necessary before @samp{$1}.
9621 The @code{de1} request turns off compatibility mode
9622 while executing the macro.  On entry, the current compatibility mode
9623 is saved and restored at exit.
9625 @Example
9626 .nr xxx 12345
9628 .de aa
9629 The value of xxx is \\n[xxx].
9631 .de1 bb
9632 The value of xxx ix \\n[xxx].
9635 .cp 1
9638     @result{} warning: number register \e' not defined
9639     @result{} The value of xxx is 0xxx].
9641     @result{} The value of xxx ix 12345.
9642 @endExample
9644 The @code{dei} request defines a macro indirectly.
9645 That is, it expands strings whose names
9646 are @var{name} or @var{end} before performing the append.
9648 This:
9650 @Example
9651 .ds xx aa
9652 .ds yy bb
9653 .dei xx yy
9654 @endExample
9656 @noindent
9657 is equivalent to:
9659 @Example
9660 .de aa bb
9661 @endExample
9663 @pindex trace.tmac
9664 Using @file{trace.tmac}, you can trace calls to @code{de} and @code{de1}.
9666 Note that macro identifiers are shared with identifiers for strings and
9667 diversions.
9668 @endDefreq
9670 @DefreqList {am, xx}
9671 @DefreqItem {am1, xx}
9672 @DefreqListEnd {ami, xx yy}
9673 @cindex appending to a macro (@code{am})
9674 @cindex macro, appending (@code{am})
9675 Works similarly to @code{de} except it appends onto the macro named
9676 @var{xx}.  So, to make the previously defined @samp{P} macro actually
9677 do indented instead of block paragraphs, add the necessary code to the
9678 existing macro like this:
9680 @Example
9681 .am P
9682 .ti +5n
9684 @endExample
9686 The @code{am1} request turns off compatibility mode
9687 while executing the appended macro piece.  To be more precise, a
9688 @dfn{compatibility save} input token is inserted at the beginning of
9689 the appended code, and a @dfn{compatibility restore} input token at
9690 the end.
9692 The @code{ami} request appends indirectly,
9693 meaning that @code{gtroff} expands strings whose names
9694 are @var{xx} or @var{yy} before performing the append.
9696 @pindex trace.tmac
9697 Using @file{trace.tmac}, you can trace calls to @code{am} and @code{am1}.
9698 @endDefreq
9700 @xref{Strings}, for the @code{als} request to rename a macro.
9702 The @code{de}, @code{am}, @code{di}, @code{da}, @code{ds}, and
9703 @code{as} requests (together with its variants) only create a new object
9704 if the name of the macro, diversion or string diversion is currently
9705 undefined or if it is defined to be a request; normally they modify the
9706 value of an existing object.
9708 @Defreq {return, }
9709 Exit a macro, immediately returning to the caller.
9710 @endDefreq
9712 @menu
9713 * Copy-in Mode::
9714 * Parameters::
9715 @end menu
9717 @c ---------------------------------------------------------------------
9719 @node Copy-in Mode, Parameters, Writing Macros, Writing Macros
9720 @subsection Copy-in Mode
9721 @cindex copy-in mode
9722 @cindex mode, copy-in
9724 @cindex @code{\n}, when reading text for a macro
9725 @cindex @code{\$}, when reading text for a macro
9726 @cindex @code{\*}, when reading text for a macro
9727 @cindex @code{\\}, when reading text for a macro
9728 @cindex \@key{RET}, when reading text for a macro
9729 When @code{gtroff} reads in the text for a macro or diversion, it copies
9730 the text (including request lines, but excluding escapes) into an
9731 internal buffer.  Escapes are converted into an internal form,
9732 except for @code{\n}, @code{\$}, @code{\*}, @code{\\} and
9733 @code{\@key{RET}} which are evaluated and inserted into the text where
9734 the escape was located.  This is known as @dfn{copy-in} mode or
9735 @dfn{copy} mode.
9737 What this means is that you can specify when these escapes are to be
9738 evaluated (either at copy-in time or at the time of use) by insulating
9739 the escapes with an extra backslash.  Compare this to the @code{\def}
9740 and @code{\edef} commands in @TeX{}.
9742 The following example prints the numbers 20 and@w{ }10:
9744 @Example
9745 .nr x 20
9746 .de y
9747 .nr x 10
9748 \&\nx
9749 \&\\nx
9752 @endExample
9754 @c ---------------------------------------------------------------------
9756 @node Parameters,  , Copy-in Mode, Writing Macros
9757 @subsection Parameters
9758 @cindex parameters
9760 The arguments to a macro can be examined using a variety of escapes.
9762 @Defreg {.$}
9763 @cindex number of arguments register (@code{.$})
9764 The number of arguments in a macro.  This is a read-only number register.
9765 @endDefreg
9767 Any individual argument can be retrieved with one of the following
9768 escapes:
9770 @DefescList {\\$, , n, }
9771 @DefescItem {\\$, @lparen{}, nn, }
9772 @DefescListEnd {\\$, @lbrack{}, nnn, @rbrack{}}
9773 @cindex copy-in mode, and macro arguments
9774 @cindex macro, arguments (@code{\$})
9775 @cindex arguments, macro (@code{\$})
9776 Retrieve the @var{n}@dmn{th}, @var{nn}@dmn{th} or @var{nnn}@dmn{th}
9777 argument.  As usual, the first form only accepts a single number
9778 (larger than zero), the second a two-digit number (larger or equal
9779 to@w{ }10), and the third any positive integer value (larger
9780 than zero).  Macros can have an unlimited number of arguments.  Note
9781 that due to copy-in mode, use two backslashes on these in actual use to
9782 prevent interpolation until the macro is actually invoked.
9783 @endDefesc
9785 @Defreq {shift, [@Var{n}]}
9786 Shift the arguments 1@w{ }position, or as
9787 many positions as specified by its argument.  After executing this
9788 request, argument@w{ }@var{i} becomes argument @math{@var{i}-@var{n}};
9789 arguments 1 to@w{ }@var{n} are no longer available.  Shifting by
9790 negative amounts is currently undefined.
9791 @endDefreq
9793 @DefescList {\\$*, , , }
9794 @DefescListEnd {\\$@@, , , }
9795 In some cases it is convenient to use all of the arguments at once (for
9796 example, to pass the arguments along to another macro).  The @code{\$*}
9797 escape concatenates all the arguments separated by spaces.  A
9798 similar escape is @code{\$@@}, which concatenates all the
9799 arguments with each surrounded by double quotes, and separated by
9800 spaces.  If not in compatibility mode, the input level of double quotes
9801 is preserved (see @ref{Request Arguments}).
9802 @endDefesc
9804 @Defesc {\\$0, , , }
9805 @cindex macro name register (@code{\$0})
9806 @cindex @code{als} request, and @code{\$0}
9807 The name used to invoke the current macro.
9808 The @code{als} request can make a macro have more than one name.
9810 @Example
9811 .de generic-macro
9812 .  ...
9813 .  if \\n[error] \@{\
9814 .    tm \\$0: Houston, we have a problem.
9815 .    return
9816 .  \@}
9819 .als foo generic-macro
9820 .als bar generic-macro
9821 @endExample
9822 @endDefesc
9824 @xref{Request Arguments}.
9827 @c =====================================================================
9829 @node Page Motions, Drawing Requests, Writing Macros, gtroff Reference
9830 @section Page Motions
9831 @cindex page motions
9832 @cindex motions, page
9834 @xref{Manipulating Spacing}, for a discussion of the main request for
9835 vertical motion, @code{sp}.
9837 @DefreqList {mk, [@Var{reg}]}
9838 @DefreqListEnd {rt, [@Var{dist}]}
9839 @cindex marking vertical page location (@code{mk})
9840 @cindex page location, vertical, marking (@code{mk})
9841 @cindex location, vertical, page, marking (@code{mk})
9842 @cindex vertical page location, marking (@code{mk})
9843 @cindex returning to marked vertical page location (@code{rt})
9844 @cindex page location, vertical, returning to marked (@code{rt})
9845 @cindex location, vertical, page, returning to marked (@code{rt})
9846 @cindex vertical page location, returning to marked (@code{rt})
9847 The request @code{mk} can be used to mark a location on a page, for
9848 movement to later.  This request takes a register name as an argument
9849 in which to store the current page location.  With no argument it
9850 stores the location in an internal register.  The results of this can
9851 be used later by the @code{rt} or the @code{sp} request (or the
9852 @code{\v} escape).
9854 The @code{rt} request returns @emph{upwards} to the location marked
9855 with the last @code{mk} request.  If used with an argument, return to
9856 a position which distance from the top of the page is @var{dist} (no
9857 previous call to @code{mk} is necessary in this case).  Default scaling
9858 indicator is @samp{v}.
9860 Here a primitive solution for a two-column macro.
9862 @Example
9863 .nr column-length 1.5i
9864 .nr column-gap 4m
9865 .nr bottom-margin 1m
9867 @endExample
9868 @Example
9869 .de 2c
9870 .  br
9871 .  mk
9872 .  ll \\n[column-length]u
9873 .  wh -\\n[bottom-margin]u 2c-trap
9874 .  nr right-side 0
9877 @endExample
9878 @Example
9879 .de 2c-trap
9880 .  ie \\n[right-side] \@{\.    nr right-side 0
9881 .    po -(\\n[column-length]u + \\n[column-gap]u)
9882 .    \" remove trap
9883 .    wh -\\n[bottom-margin]u
9884 .  \@}
9885 .  el \@{\
9886 .    \" switch to right side
9887 .    nr right-side 1
9888 .    po +(\\n[column-length]u + \\n[column-gap]u)
9889 .    rt
9890 .  \@}
9893 @endExample
9894 @Example
9895 .pl 1.5i
9896 .ll 4i
9897 This is a small test which shows how the
9898 rt request works in combination with mk.
9901 Starting here, text is typeset in two columns.
9902 Note that this implementation isn't robust
9903 and thus not suited for a real two-column
9904 macro.
9905 @endExample
9907 Result:
9909 @Example
9910 This is a small test which shows how the
9911 rt request works in combination with mk.
9913 Starting  here,    isn't    robust
9914 text is typeset    and   thus  not
9915 in two columns.    suited  for   a
9916 Note that  this    real two-column
9917 implementation     macro.
9918 @endExample
9919 @endDefreq
9921 The following escapes give fine control of movements about the page.
9923 @Defesc {\\v, ', e, '}
9924 @cindex vertical motion (@code{\v})
9925 @cindex motion, vertical (@code{\v})
9926 Move vertically, usually from the current location on the page (if no
9927 absolute position operator @samp{|} is used).  The
9928 argument@w{ }@var{e} specifies the distance to move; positive is
9929 downwards and negative upwards.  The default scaling indicator for this
9930 escape is @samp{v}.  Beware, however, that @code{gtroff} continues text
9931 processing at the point where the motion ends, so you should always
9932 balance motions to avoid interference with text processing.
9934 @code{\v} doesn't trigger a trap.  This can be quite useful; for example,
9935 consider a page bottom trap macro which prints a marker in the margin to
9936 indicate continuation of a footnote or something similar.
9937 @endDefesc
9939 There are some special-case escapes for vertical motion.
9941 @Defesc {\\r, , , }
9942 Move upwards@w{ }1@dmn{v}.
9943 @endDefesc
9945 @Defesc {\\u, , , }
9946 Move upwards@w{ }.5@dmn{v}.
9947 @endDefesc
9949 @Defesc {\\d, , , }
9950 Move down@w{ }.5@dmn{v}.
9951 @endDefesc
9953 @Defesc {\\h, ', e, '}
9954 @cindex inserting horizontal space (@code{\h})
9955 @cindex horizontal space (@code{\h})
9956 @cindex space, horizontal (@code{\h})
9957 @cindex horizontal motion (@code{\h})
9958 @cindex motion, horizontal (@code{\h})
9959 Move horizontally, usually from the current location (if no absolute
9960 position operator @samp{|} is used).  The expression@w{ }@var{e}
9961 indicates how far to move: positive is rightwards and negative
9962 leftwards.  The default scaling indicator for this escape is @samp{m}.
9963 @endDefesc
9965 There are a number of special-case escapes for horizontal motion.
9967 @Defesc {\\@key{SP}, , , }
9968 @cindex space, unbreakable
9969 @cindex unbreakable space
9970 An unbreakable and unpaddable (i.e.@: not expanded during filling)
9971 space.  (Note: This is a backslash followed by a space.)
9972 @endDefesc
9974 @Defesc {\\~, , , }
9975 An unbreakable space that stretches like a normal inter-word space
9976 when a line is adjusted.
9977 @endDefesc
9979 @Defesc {\\|, , , }
9980 A 1/6@dmn{th} em space.  Ignored for TTY output devices (rounded to
9981 zero).
9982 @endDefesc
9984 @Defesc {\\^, , , }
9985 A 1/12@dmn{th} em space.  Ignored for TTY output devices (rounded to
9986 zero).
9987 @endDefesc
9989 @Defesc {\\0, , , }
9990 @cindex space, width of a digit (@code{\0})
9991 @cindex digit width space (@code{\0})
9992 A space the size of a digit.
9993 @endDefesc
9995 The following string sets the @TeX{} logo:
9997 @Example
9998 .ds TeX T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
9999 @endExample
10001 @DefescList {\\w, ', text, '}
10002 @DefregItem {st}
10003 @DefregItem {sb}
10004 @DefregItem {rst}
10005 @DefregItem {rsb}
10006 @DefregItem {ct}
10007 @DefregItem {ssc}
10008 @DefregListEnd {skw}
10009 @cindex width escape (@code{\w})
10010 Return the width of the specified @var{text} in basic units.
10011 This allows horizontal movement based on the width of some
10012 arbitrary text (e.g.@: given as an argument to a macro).
10014 @Example
10015 The length of the string `abc' is \w'abc'u.
10016     @result{} The length of the string `abc' is 72u.
10017 @endExample
10019 Font changes may occur in @var{text} which don't affect current
10020 settings.
10022 After use, @code{\w} sets several registers:
10024 @table @code
10025 @item st
10026 @itemx sb
10027 The highest and lowest point of the baseline, respectively, in @var{text}.
10029 @item rst
10030 @itemx rsb
10031 Like the @code{st} and @code{sb} registers, but takes account of the
10032 heights and depths of glyphs.  With other words, this gives the
10033 highest and lowest point of @var{text}.
10035 @item ct
10036 Defines the kinds of glyphs occurring in @var{text}:
10038 @table @asis
10039 @item 0
10040 only short glyphs, no descenders or tall glyphs.
10042 @item 1
10043 at least one descender.
10045 @item 2
10046 at least one tall glyph.
10048 @item 3
10049 at least one each of a descender and a tall glyph.
10050 @end table
10052 @item ssc
10053 The amount of horizontal space (possibly negative) that should be added
10054 to the last glyph before a subscript.
10056 @item skw
10057 How far to right of the center of the last glyph in the @code{\w}
10058 argument, the center of an accent from a roman font should be placed
10059 over that glyph.
10060 @end table
10061 @endDefesc
10063 @DefescList {\\k, , p, }
10064 @DefescItem {\\k, @lparen{}, ps, }
10065 @DefescListEnd {\\k, @lbrack{}, position, @rbrack}
10066 @cindex saving horizontal input line position (@code{\k})
10067 @cindex horizontal input line position, saving (@code{\k})
10068 @cindex input line position, horizontal, saving (@code{\k})
10069 @cindex position, horizontal input line, saving (@code{\k})
10070 @cindex line, input, horizontal position, saving (@code{\k})
10071 Store the current horizontal position in the @emph{input} line in
10072 number register with name @var{position} (one-character name@w{ }@var{p},
10073 two-character name @var{ps}).  Use this, for example, to return to the
10074 beginning of a string for highlighting or other decoration.
10075 @endDefesc
10077 @Defreg {hp}
10078 @cindex horizontal input line position register (@code{hp})
10079 @cindex input line, horizontal position, register (@code{hp})
10080 @cindex position, horizontal, in input line, register (@code{hp})
10081 @cindex line, input, horizontal position, register (@code{hp})
10082 The current horizontal position at the input line.
10083 @endDefreg
10085 @Defreg {.k}
10086 @cindex horizontal output line position register (@code{.k})
10087 @cindex output line, horizontal position, register (@code{.k})
10088 @cindex position, horizontal, in output line, register (@code{.k})
10089 @cindex line, output, horizontal position, register (@code{.k})
10090 A read-only number register containing the current horizontal output
10091 position.
10092 @endDefreg
10094 @Defesc {\\o, ', @Var{a}@Var{b}@Var{c}, '}
10095 @cindex overstriking glyphs (@code{\o})
10096 @cindex glyphs, overstriking (@code{\o})
10097 Overstrike glyphs @var{a}, @var{b}, @var{c}, @dots{}; the glyphs
10098 are centered, and the resulting spacing is the largest width of the
10099 affected glyphs.
10100 @endDefesc
10102 @Defesc {\\z, , g, , }
10103 @cindex zero-width printing (@code{\z}, @code{\Z})
10104 @cindex printing, zero-width (@code{\z}, @code{\Z})
10105 Print glyph @var{g} with zero width, i.e., without spacing.  Use
10106 this to overstrike glyphs left-aligned.
10107 @endDefesc
10109 @Defesc {\\Z, ', anything, '}
10110 @cindex zero-width printing (@code{\z}, @code{\Z})
10111 @cindex printing, zero-width (@code{\z}, @code{\Z})
10112 Print @var{anything}, then restore the horizontal and vertical position.
10113 The argument may not contain tabs or leaders.
10115 The following is an example of a strike-through macro:
10117 @Example
10118 .de ST
10119 .nr ww \w'\\$1'
10120 \Z@@\v'-.25m'\l'\\n[ww]u'@@\\$1
10123 This is
10124 .ST "a test"
10125 an actual emergency!
10126 @endExample
10127 @endDefesc
10130 @c =====================================================================
10132 @node Drawing Requests, Traps, Page Motions, gtroff Reference
10133 @section Drawing Requests
10134 @cindex drawing requests
10135 @cindex requests for drawing
10137 @code{gtroff} provides a number of ways to draw lines and other figures
10138 on the page.  Used in combination with the page motion commands (see
10139 @ref{Page Motions}, for more info), a wide variety of figures can be
10140 drawn.  However, for complex drawings these operations can be quite
10141 cumbersome, and it may be wise to use graphic preprocessors like
10142 @code{gpic} or @code{ggrn}.  @xref{gpic}, and @ref{ggrn}, for more
10143 information.
10145 All drawing is done via escapes.
10147 @DefescList {\\l, ', @Var{l}, '}
10148 @DefescListEnd {\\l, ', @Var{l}@Var{g}, '}
10149 @cindex drawing horizontal lines (@code{\l})
10150 @cindex horizontal line, drawing (@code{\l})
10151 @cindex line, horizontal, drawing (@code{\l})
10152 Draw a line horizontally.  @var{l} is the length of the line to be
10153 drawn.  If it is positive, start the line at the current location and
10154 draw to the right; its end point is the new current location.  Negative
10155 values are handled differently: The line starts at the current location
10156 and draws to the left, but the current location doesn't move.
10158 @var{l} can also be specified absolutely (i.e.@: with a leading
10159 @samp{|}) which draws back to the beginning of the input line.
10160 Default scaling indicator is @samp{m}.
10162 @cindex underscore glyph (@code{\[ru]})
10163 @cindex glyph, underscore (@code{\[ru]})
10164 @cindex line drawing glyph
10165 @cindex glyph, for line drawing
10166 The optional second parameter@w{ }@var{g} is a glyph to draw the line
10167 with.  If this second argument is not specified, @code{gtroff} uses
10168 the underscore glyph, @code{\[ru]}.
10170 @cindex zero width space character (@code{\&})
10171 @cindex character, zero width space (@code{\&})
10172 @cindex space character, zero width (@code{\&})
10173 To separate the two arguments (to prevent @code{gtroff} from
10174 interpreting a drawing glyph as a scaling indicator if the glyph is
10175 represented by a single character) use @code{\&}.
10177 Here a small useful example:
10179 @Example
10180 .de box
10181 \[br]\\$*\[br]\l'|0\[rn]'\l'|0\[ul]'
10183 @endExample
10185 @noindent
10186 Note that this works by outputting a box rule (a vertical line), then
10187 the text given as an argument and then another box rule.  Finally, the
10188 line drawing escapes both draw from the current location to the
10189 beginning of the @emph{input} line -- this works because the line
10190 length is negative, not moving the current point.
10191 @endDefesc
10193 @DefescList {\\L, ', @Var{l}, '}
10194 @DefescListEnd {\\L, ', @Var{l}@Var{g}, '}
10195 @cindex drawing vertical lines (@code{\L})
10196 @cindex vertical line drawing (@code{\L})
10197 @cindex line, vertical, drawing (@code{\L})
10198 @cindex line drawing glyph
10199 @cindex glyph for line drawing
10200 @cindex box rule glyph (@code{\[br]})
10201 @cindex glyph, box rule (@code{\[br]})
10202 Draw vertical lines.  Its parameters are
10203 similar to the @code{\l} escape, except that the default scaling
10204 indicator is @samp{v}.  The movement is downwards for positive values,
10205 and upwards for negative values.  The default glyph is the box rule
10206 glyph, @code{\[br]}.  As with the vertical motion escapes, text
10207 processing blindly continues where the line ends.
10209 @Example
10210 This is a \L'3v'test.
10211 @endExample
10213 @noindent
10214 Here the result, produced with @code{grotty}.
10216 @Example
10217 This is a
10218           |
10219           |
10220           |test.
10221 @endExample
10222 @endDefesc
10224 @Defesc {\\D, ', command arg @dots{}, '}
10225 The @code{\D} escape provides a variety of drawing functions.
10226 Note that on character devices, only vertical and horizontal lines are
10227 supported within @code{grotty}; other devices may only support a subset
10228 of the available drawing functions.
10230 The default scaling indicator for all subcommands of @code{\D} is
10231 @samp{m} for horizontal distances and @samp{v} for vertical ones.
10232 Exceptions are @w{@code{\D'f @dots{}'}} and @w{@code{\D't @dots{}'}}
10233 which use @code{u} as the default.
10235 @table @code
10236 @item \D'l @var{dx} @var{dy}'
10237 @cindex line, drawing (@w{@code{\D'l @dots{}'}})
10238 @cindex drawing a line (@w{@code{\D'l @dots{}'}})
10239 Draw a line from the current location to the relative point specified by
10240 (@var{dx},@var{dy}).
10242 The following example is a macro for creating a box around a text string;
10243 for simplicity, the box margin is taken as a fixed value, 0.2@dmn{m}.
10245 @Example
10246 .de BOX
10247 .  nr @@wd \w'\\$1'
10248 \h'.2m'\
10249 \h'-.2m'\v'(.2m - \\n[rsb]u)'\
10250 \D'l 0 -(\\n[rst]u - \\n[rsb]u + .4m)'\
10251 \D'l (\\n[@@wd]u + .4m) 0'\
10252 \D'l 0 (\\n[rst]u - \\n[rsb]u + .4m)'\
10253 \D'l -(\\n[@@wd]u + .4m) 0'\
10254 \h'.2m'\v'-(.2m - \\n[rsb]u)'\
10255 \\$1\
10256 \h'.2m'
10258 @endExample
10260 @noindent
10261 First, the width of the string is stored in register @code{@@wd}.  Then,
10262 four lines are drawn to form a box, properly offset by the box margin.
10263 The registers @code{rst} and @code{rsb} are set by the @code{\w} escape,
10264 containing the largest height and depth of the whole string.
10266 @item \D'c @var{d}'
10267 @cindex circle, drawing (@w{@code{\D'c @dots{}'}})
10268 @cindex drawing a circle (@w{@code{\D'c @dots{}'}})
10269 Draw a circle with a diameter of@w{ }@var{d} with the leftmost point at the
10270 current position.
10272 @item \D'C @var{d}'
10273 @cindex circle, solid, drawing (@w{@code{\D'C @dots{}'}})
10274 @cindex drawing a solid circle (@w{@code{\D'C @dots{}'}})
10275 @cindex solid circle, drawing (@w{@code{\D'C @dots{}'}})
10276 Draw a solid circle with the same parameters as an outlined circle.  No
10277 outline is drawn.
10279 @item \D'e @var{x} @var{y}'
10280 @cindex drawing an ellipse (@w{@code{\D'e @dots{}'}})
10281 @cindex ellipse, drawing (@w{@code{\D'e @dots{}'}})
10282 Draw an ellipse with a horizontal diameter of @var{x} and a vertical
10283 diameter of @var{y} with the leftmost point at the current position.
10285 @item \D'E @var{x} @var{y}'
10286 @cindex ellipse, solid, drawing (@w{@code{\D'E @dots{}'}})
10287 @cindex drawing a solid ellipse (@w{@code{\D'E @dots{}'}})
10288 @cindex solid ellipse, drawing (@w{@code{\D'E @dots{}'}})
10289 Draw a solid ellipse with the same parameters as an outlined ellipse.
10290 No outline is drawn.
10292 @item \D'a @var{dx1} @var{dy1} @var{dx2} @var{dy2}'
10293 @cindex arc, drawing (@w{@code{\D'a @dots{}'}})
10294 @cindex drawing an arc (@w{@code{\D'a @dots{}'}})
10295 Draw an arc clockwise from the current location through the two
10296 specified relative locations (@var{dx1},@var{dy1}) and
10297 (@var{dx2},@var{dy2}).  The coordinates of the first point are relative
10298 to the current position, and the coordinates of the second point are
10299 relative to the first point.
10301 @item \D'~ @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
10302 @cindex drawing a spline (@w{@code{\D'~ @dots{}'}})
10303 @cindex spline, drawing (@w{@code{\D'~ @dots{}'}})
10304 Draw a spline from the current location to the relative point
10305 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}), and so on.
10307 @item \D'f @var{n}'
10308 @cindex gray shading (@w{@code{\D'f @dots{}'}})
10309 @cindex shading filled objects (@w{@code{\D'f @dots{}'}})
10310 Set the shade of gray to be used for filling solid objects to@w{
10311 }@var{n}; @var{n}@w{ }must be an integer between 0 and@w{ }1000, where 0
10312 corresponds solid white and 1000 to solid black, and values in between
10313 correspond to intermediate shades of gray.  This applies only to solid
10314 circles, solid ellipses, and solid polygons.  By default, a level of
10315 1000 is used.
10317 @item \D'p @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
10318 @cindex drawing a polygon (@w{@code{\D'p @dots{}'}})
10319 @cindex polygon, drawing (@w{@code{\D'p @dots{}'}})
10320 Draw a polygon from the current location to the relative position
10321 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}) and so on.
10322 When the specified data points are exhausted, a line is drawn back
10323 to the starting point.
10325 @item \D'P @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
10326 @cindex polygon, solid, drawing (@w{@code{\D'P @dots{}'}})
10327 @cindex drawing a solid polygon (@w{@code{\D'P @dots{}'}})
10328 @cindex solid polygon, drawing (@w{@code{\D'P @dots{}'}})
10329 Draw a solid polygon with the same parameters as an outlined polygon.
10330 No outline is drawn.
10332 Here a better variant of the box macro to fill the box with some color.
10333 Note that the box must be drawn before the text since colors in
10334 @code{gtroff} are not transparent; the filled polygon would hide the
10335 text completely.
10337 @Example
10338 .de BOX
10339 .  nr @@wd \w'\\$1'
10340 \h'.2m'\
10341 \h'-.2m'\v'(.2m - \\n[rsb]u)'\
10342 \M[lightcyan]\
10343 \D'P 0 -(\\n[rst]u - \\n[rsb]u + .4m) \
10344      (\\n[@@wd]u + .4m) 0 \
10345      0 (\\n[rst]u - \\n[rsb]u + .4m) \
10346      -(\\n[@@wd]u + .4m) 0'\
10347 \h'.2m'\v'-(.2m - \\n[rsb]u)'\
10348 \M[]\
10349 \\$1\
10350 \h'.2m'
10352 @endExample
10354 @item \D't @var{n}'
10355 @cindex line thickness (@w{@code{\D't @dots{}'}})
10356 @cindex thickness of lines (@w{@code{\D't @dots{}'}})
10357 Set the current line thickness to @var{n}@w{ }machine units.  A value of
10358 zero selects the smallest available line thickness.  A negative value
10359 makes the line thickness proportional to the current point size (this is
10360 the default behaviour of @acronym{AT&T} @code{troff}).
10361 @end table
10362 @endDefesc
10364 @xref{Graphics Commands}.
10366 @Defesc {\\b, ', string, '}
10367 @cindex pile, glyph (@code{\b})
10368 @cindex glyph pile (@code{\b})
10369 @cindex stacking glyphs (@code{\b})
10370 @dfn{Pile} a sequence of glyphs vertically, and center it vertically
10371 on the current line.  Use it to build large brackets and braces.
10373 Here an example how to create a large opening brace:
10375 @Example
10376 \b'\[lt]\[bv]\[lk]\[bv]\[lb]'
10377 @endExample
10379 @cindex @code{\b}, limitations
10380 @cindex limitations of @code{\b} escape
10381 The first glyph is on the top, the last glyph in @var{string} is
10382 at the bottom.  Note that @code{gtroff} separates the glyphs
10383 vertically by 1@dmn{m}, and the whole object is centered 0.5@dmn{m}
10384 above the current baseline; the largest glyph width is used as the
10385 width for the whole object.  This rather unflexible positioning
10386 algorithm doesn't work with @option{-Tdvi} since the bracket pieces vary
10387 in height for this device.  Instead, use the @code{eqn} preprocessor.
10389 @xref{Manipulating Spacing}, how to adjust the vertical spacing with
10390 the @code{\x} escape.
10391 @endDefesc
10394 @c =====================================================================
10396 @node Traps, Diversions, Drawing Requests, gtroff Reference
10397 @section Traps
10398 @cindex traps
10400 @dfn{Traps} are locations, which, when reached, call a specified
10401 macro.  These traps can occur at a given location on the page, at a
10402 given location in the current diversion, at a blank line,
10403 after a certain number of input lines, or at the end of input.
10405 @cindex planting a trap
10406 @cindex trap, planting
10407 Setting a trap is also called @dfn{planting}.
10408 @cindex trap, springing
10409 @cindex springing a trap
10410 It is also said that a trap is @dfn{sprung} if the associated macro
10411 is executed.
10413 @menu
10414 * Page Location Traps::
10415 * Diversion Traps::
10416 * Input Line Traps::
10417 * Blank Line Traps::
10418 * End-of-input Traps::
10419 @end menu
10421 @c ---------------------------------------------------------------------
10423 @node Page Location Traps, Diversion Traps, Traps, Traps
10424 @subsection Page Location Traps
10425 @cindex page location traps
10426 @cindex traps, page location
10428 @dfn{Page location traps} perform an action when @code{gtroff}
10429 reaches or passes a certain vertical location on the page.  Page
10430 location traps have a variety of purposes, including:
10432 @itemize
10433 @item
10434 setting headers and footers
10436 @item
10437 setting body text in multiple columns
10439 @item
10440 setting footnotes
10441 @end itemize
10443 @DefreqList {vpt, flag}
10444 @DefregListEnd {.vpt}
10445 @cindex enabling vertical position traps (@code{vpt})
10446 @cindex vertical position traps, enabling (@code{vpt})
10447 @cindex vertical position trap enable register (@code{.vpt})
10448 Enable vertical position traps if @var{flag} is non-zero, or disables
10449 them otherwise.  Vertical position traps are traps set by the @code{wh}
10450 or @code{dt} requests.  Traps set by the @code{it} request are not
10451 vertical position traps.  The parameter that controls whether vertical
10452 position traps are enabled is global.  Initially vertical position traps
10453 are enabled.  The current setting of this is available in the
10454 @code{.vpt} read-only number register.
10455 @endDefreq
10457 @Defreq {wh, dist [@Var{macro}]}
10458 Set a page location trap.  Positive values for @var{dist} set
10459 the trap relative to the top of the page; negative values set
10460 the trap relative to the bottom of the page.  Default scaling
10461 indicator is @samp{v}.
10463 @var{macro} is the name of the macro to execute when the
10464 trap is sprung.  If @var{macro} is missing, remove the first trap
10465 (if any) at @var{dist}.
10467 @cindex page headers
10468 @cindex page footers
10469 @cindex headers
10470 @cindex footers
10471 The following is a simple example of how many macro packages
10472 set headers and footers.
10474 @Example
10475 .de hd                \" Page header
10476 '  sp .5i
10477 .  tl 'Title''date'
10478 '  sp .3i
10481 .de fo                \" Page footer
10482 '  sp 1v
10483 .  tl ''%''
10484 '  bp
10487 .wh 0   hd            \" trap at top of the page
10488 .wh -1i fo            \" trap one inch from bottom
10489 @endExample
10491 A trap at or below the bottom of the page is ignored; it can be made
10492 active by either moving it up or increasing the page length so that the
10493 trap is on the page.
10495 It is possible to have more than one trap at the same location; to do so,
10496 the traps must be defined at different locations, then moved together with
10497 the @code{ch} request; otherwise the second trap would replace the first
10498 one.  Earlier defined traps hide later defined traps if moved to the same
10499 position (the many empty lines caused by the @code{bp} request are omitted):
10501 @Example
10502 .de a
10503 .  nop a
10505 .de b
10506 .  nop b
10508 .de c
10509 .  nop c
10512 .wh 1i a
10513 .wh 2i b
10514 .wh 3i c
10516     @result{} a b c
10517 @endExample
10518 @Example
10519 .ch b 1i
10520 .ch c 1i
10522     @result{} a
10523 @endExample
10524 @Example
10525 .ch a 0.5i
10527     @result{} a b
10528 @endExample
10529 @endDefreq
10531 @Defreg {.t}
10532 @cindex distance to next trap register (@code{.t})
10533 @cindex trap, distance, register (@code{.t})
10534 A read-only number register holding the distance to the next trap.
10536 If there are no traps between the current position and the bottom of the
10537 page, it contains the distance to the page bottom.  In a diversion, the
10538 distance to the page bottom is infinite (the returned value is the biggest
10539 integer which can be represented in @code{groff}) if there are no diversion
10540 traps.
10541 @endDefreg
10543 @Defreq {ch, macro dist}
10544 @cindex changing trap location (@code{ch})
10545 @cindex trap, changing location (@code{ch})
10546 Change the location of a trap.
10547 The first argument is the name of the macro to be invoked at
10548 the trap, and the second argument is the new location for the trap
10549 (note that the parameters are specified the opposite of the @code{wh}
10550 request).  This is useful for building up footnotes in a diversion to
10551 allow more space at the bottom of the page for them.
10553 Default scaling indicator for @var{dist} is @samp{v}.  If @var{dist}
10554 is missing, the trap is removed.
10556 @c XXX
10558 @ignore
10559 @Example
10560 ... (simplified) footnote example ...
10561 @endExample
10562 @end ignore
10563 @endDefreq
10565 @Defreg {.ne}
10566 The read-only number register @code{.ne} contains the amount of space
10567 that was needed in the last @code{ne} request that caused a trap to be
10568 sprung.  Useful in conjunction with the @code{.trunc} register.
10569 @xref{Page Control}, for more information.
10570 @endDefreg
10572 @Defreg {.trunc}
10573 @cindex @code{ne} request, and the @code{.trunc} register
10574 @cindex truncated vertical space register (@code{.trunc})
10575 A read-only register containing the amount of vertical space truncated
10576 by the most recently sprung vertical position trap, or, if the trap was
10577 sprung by an @code{ne} request, minus the amount of vertical motion
10578 produced by the @code{ne} request.  In other words, at the point a trap
10579 is sprung, it represents the difference of what the vertical position
10580 would have been but for the trap, and what the vertical position
10581 actually is.
10582 @endDefreg
10584 @c ---------------------------------------------------------------------
10586 @node Diversion Traps, Input Line Traps, Page Location Traps, Traps
10587 @subsection Diversion Traps
10588 @cindex diversion traps
10589 @cindex traps, diversion
10591 @Defreq {dt, dist macro}
10592 @cindex @code{.t} register, and diversions
10593 @cindex setting diversion trap (@code{dt})
10594 @cindex diversion trap, setting (@code{dt})
10595 @cindex trap, diversion, setting (@code{dt})
10596 Set a trap @emph{within} a diversion.
10597 @var{dist} is the location of the trap
10598 (identical to the @code{.wh} request; default scaling indicator is
10599 @samp{v}) and @var{macro} is the name of the macro to be invoked.  The
10600 number register @code{.t} still works within diversions.
10601 @xref{Diversions}, for more information.
10602 @endDefreq
10604 @c ---------------------------------------------------------------------
10606 @node Input Line Traps, Blank Line Traps, Diversion Traps, Traps
10607 @subsection Input Line Traps
10608 @cindex input line traps
10609 @cindex traps, input line
10611 @DefreqList {it, n macro}
10612 @DefreqItem {itc, n macro}
10613 @cindex setting input line trap (@code{it})
10614 @cindex input line trap, setting (@code{it})
10615 @cindex trap, input line, setting (@code{it})
10616 Set an input line trap.
10617 @var{n}@w{ }is the number of lines of input which may be read before
10618 springing the trap, @var{macro} is the macro to be invoked.
10619 Request lines are not counted as input lines.
10621 For example, one possible use is to have a macro which prints the
10622 next @var{n}@w{ }lines in a bold font.
10624 @Example
10625 .de B
10626 .  it \\$1 B-end
10627 .  ft B
10630 .de B-end
10631 .  ft R
10633 @endExample
10635 @cindex input line traps and interrupted lines (@code{itc})
10636 @cindex interrupted lines and input line traps (@code{itc})
10637 @cindex traps, input line, and interrupted lines (@code{itc})
10638 @cindex lines, interrupted, and input line traps (@code{itc})
10639 The @code{itc} request is identical,
10640 except that a line interrupted with @code{\c}
10641 counts as one input line.
10643 Both requests are associated with the current environment
10644 (@pxref{Environments}); switching to another environment disables the
10645 current input trap, and going back reactivates it, restoring the number
10646 of already processed lines.
10647 @endDefreq
10649 @c ---------------------------------------------------------------------
10651 @node Blank Line Traps, End-of-input Traps, Input Line Traps, Traps
10652 @subsection Blank Line Traps
10653 @cindex blank line traps
10654 @cindex traps, blank line
10656 @Defreq {blm, macro}
10657 @cindex blank line macro (@code{blm})
10658 Set a blank line trap.
10659 @code{gtroff} executes @var{macro} when it encounters a blank line in
10660 the input file.
10661 @endDefreq
10663 @c ---------------------------------------------------------------------
10665 @node End-of-input Traps,  , Blank Line Traps, Traps
10666 @subsection End-of-input Traps
10667 @cindex end-of-input traps
10668 @cindex traps, end-of-input
10670 @Defreq {em, macro}
10671 @cindex setting end-of-input trap (@code{em})
10672 @cindex end-of-input trap, setting (@code{em})
10673 @cindex trap, end-of-input, setting (@code{em})
10674 @cindex end-of-input macro (@code{em})
10675 @cindex macro, end-of-input (@code{em})
10676 Set a trap at the end of input.  @var{macro} is executed after the
10677 last line of the input file has been processed.
10679 For example, if the document had to have a section at the bottom of the
10680 last page for someone to approve it, the @code{em} request could be
10681 used.
10683 @Example
10684 .de approval
10685 .  ne 5v
10686 .  sp |(\\n[.t] - 6v)
10687 .  in +4i
10688 .  lc _
10689 .  br
10690 Approved:\t\a
10691 .  sp
10692 Date:\t\t\a
10695 .em approval
10696 @endExample
10697 @endDefreq
10700 @c =====================================================================
10702 @node Diversions, Environments, Traps, gtroff Reference
10703 @section Diversions
10704 @cindex diversions
10706 In @code{gtroff} it is possible to @dfn{divert} text into a named
10707 storage area.  Due to the similarity to defining macros it is sometimes
10708 said to be stored in a macro.  This is used for saving text for output
10709 at a later time, which is useful for keeping blocks of text on the same
10710 page, footnotes, tables of contents, and indices.
10712 @cindex top-level diversion
10713 @cindex diversion, top-level
10714 For orthogonality it is said that @code{gtroff} is in the @dfn{top-level
10715 diversion} if no diversion is active (i.e., the data is diverted to the
10716 output device).
10718 @DefreqList {di, macro}
10719 @DefreqListEnd {da, macro}
10720 @cindex beginning diversion (@code{di})
10721 @cindex diversion, beginning (@code{di})
10722 @cindex ending diversion (@code{di})
10723 @cindex diversion, ending (@code{di})
10724 @cindex appending to a diversion (@code{da})
10725 @cindex diversion, appending (@code{da})
10726 Begin a diversion.  Like the @code{de}
10727 request, it takes an argument of a macro name to divert subsequent text
10728 into.  The @code{da} macro appends to an existing diversion.
10730 @code{di} or @code{da} without an argument ends the diversion.
10731 @endDefreq
10733 @DefreqList {box, macro}
10734 @DefreqListEnd {boxa, macro}
10735 Begin (or appends to) a diversion like the
10736 @code{di} and @code{da} requests.
10737 The difference is that @code{box} and @code{boxa}
10738 do not include a partially-filled line in the diversion.
10740 Compare this:
10742 @Example
10743 Before the box.
10744 .box xxx
10745 In the box.
10747 .box
10748 After the box.
10750     @result{} Before the box.  After the box.
10751 .xxx
10752     @result{} In the box.
10753 @endExample
10755 @noindent
10756 with this:
10758 @Example
10759 Before the diversion.
10760 .di yyy
10761 In the diversion.
10764 After the diversion.
10766     @result{} After the diversion.
10767 .yyy
10768     @result{} Before the diversion.  In the diversion.
10769 @endExample
10771 @code{box} or @code{boxa} without an argument ends the diversion.
10772 @endDefreq
10774 @DefregList {.z}
10775 @DefregListEnd {.d}
10776 @cindex @code{nl} register, and @code{.d}
10777 @cindex nested diversions
10778 @cindex diversion, nested
10779 @cindex diversion name register (@code{.z})
10780 @cindex vertical position in diversion register (@code{.d})
10781 @cindex position, vertical, in diversion, register (@code{.d})
10782 @cindex diversion, vertical position in, register (@code{.d})
10783 Diversions may be nested.  The read-only number register @code{.z}
10784 contains the name of the current diversion (this is a string-valued
10785 register).  The read-only number register @code{.d} contains the current
10786 vertical place in the diversion.  If not in a diversion it is the same
10787 as the register @code{nl}.
10788 @endDefreg
10790 @Defreg {.h}
10791 @cindex high-water mark register (@code{.h})
10792 @cindex mark, high-water, register (@code{.h})
10793 @cindex position of lowest text line (@code{.h})
10794 @cindex text line, position of lowest (@code{.h})
10795 The @dfn{high-water mark} on the current page.  It corresponds to the
10796 text baseline of the lowest line on the page.  This is a read-only
10797 register.
10799 @Example
10800 .tm .h==\n[.h], nl==\n[nl]
10801     @result{} .h==0, nl==-1
10802 This is a test.
10804 .sp 2
10805 .tm .h==\n[.h], nl==\n[nl]
10806     @result{} .h==40, nl==120
10807 @endExample
10809 @cindex @code{.h} register, difference to @code{nl}
10810 @cindex @code{nl} register, difference to @code{.h}
10811 @noindent
10812 As can be seen in the previous example, empty lines are not considered
10813 in the return value of the @code{.h} register.
10814 @endDefreg
10816 @DefregList {dn}
10817 @DefregListEnd {dl}
10818 After completing a diversion, the read-write number registers @code{dn}
10819 and @code{dl} contain the vertical and horizontal size of the diversion.
10821 @Example
10822 .\" Center text both horizontally & vertically
10824 .\" Enclose macro definitions in .eo and .ec
10825 .\" to avoid the doubling of the backslash
10827 .\" macro .(c starts centering mode
10828 .de (c
10829 .  br
10830 .  ev (c
10831 .  evc 0
10832 .  in 0
10833 .  nf
10834 .  di @@c
10836 @endExample
10837 @Example
10838 .\" macro .)c terminates centering mode
10839 .de )c
10840 .  br
10841 .  ev
10842 .  di
10843 .  nr @@s (((\n[.t]u - \n[dn]u) / 2u) - 1v)
10844 .  sp \n[@@s]u
10845 .  ce 1000
10846 .  @@c
10847 .  ce 0
10848 .  sp \n[@@s]u
10849 .  br
10850 .  fi
10851 .  rr @@s
10852 .  rm @@s
10853 .  rm @@c
10855 .\" End of macro definitions, restore escape mechanism
10857 @endExample
10858 @endDefreg
10860 @DefescList {\\!, , , }
10861 @DefescListEnd {\\?, , @Var{anything}, \\?}
10862 @cindex transparent output (@code{\!}, @code{\?})
10863 @cindex output, transparent (@code{\!}, @code{\?})
10864 Prevent requests, macros, and escapes from being
10865 interpreted when read into a diversion.  This takes the given text
10866 and @dfn{transparently} embeds it into the diversion.  This is useful for
10867 macros which shouldn't be invoked until the diverted text is actually
10868 output.
10870 The @code{\!} escape transparently embeds text up to
10871 and including the end of the line.
10872 The @code{\?} escape transparently embeds text until the next
10873 occurrence of the @code{\?} escape.  For example:
10875 @Example
10876 \?@var{anything}\?
10877 @endExample
10879 @noindent
10880 @var{anything} may not contain newlines; use @code{\!}  to embed
10881 newlines in a diversion.  The escape sequence @code{\?} is also
10882 recognized in copy mode and turned into a single internal code; it is
10883 this code that terminates @var{anything}.  Thus the following example
10884 prints@w{ }4.
10886 @Example
10887 .nr x 1
10889 .di d
10890 \?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
10892 .nr x 2
10893 .di e
10896 .nr x 3
10897 .di f
10900 .nr x 4
10902 @endExample
10904 Both escapes read the data in copy mode.
10906 @cindex @code{\!}, in top-level diversion
10907 @cindex top-level diversion, and @code{\!}
10908 @cindex diversion, top-level, and @code{\!}
10909 If @code{\!} is used in the top-level diversion, its argument is
10910 directly embedded into the @code{gtroff} intermediate output.  This can
10911 be used for example to control a postprocessor which processes the data
10912 before it is sent to the device driver.
10914 @cindex @code{\?}, in top-level diversion
10915 @cindex top-level diversion, and @code{\?}
10916 @cindex diversion, top-level, and @code{\?}
10917 The @code{\?} escape used in the top-level diversion produces no output
10918 at all; its argument is simply ignored.
10919 @endDefesc
10921 @cindex @code{\!}, and @code{output}
10922 @cindex @code{output} request, and @code{\!}
10923 @Defreq {output, string}
10924 Emit @var{string} directly to the @code{gtroff} intermediate output
10925 (subject to copy-mode interpretation);  this is similar to @code{\!} used
10926 at the top level.  An initial double quote in @var{string} is stripped off
10927 to allow initial blanks.
10929 This request can't be used before the first page has started -- if you get
10930 an error, simply insert @code{.br} before the @code{output} request.
10932 Without argument, @code{output} is ignored.
10934 Use with caution!  It is normally only needed for mark-up used by a
10935 postprocessor which does something with the output before sending it to
10936 the output device, filtering out @code{string} again.
10937 @endDefreq
10939 @Defreq {asciify, div}
10940 @cindex unformatting diversions (@code{asciify})
10941 @cindex diversion, unformatting (@code{asciify})
10942 @cindex @code{trin} request, and @code{asciify}
10943 @dfn{Unformat} the diversion specified by @var{div}
10944 in such a way that @acronym{ASCII} characters, characters translated with
10945 the @code{trin} request, space characters, and some escape sequences that
10946 were formatted and diverted are treated like ordinary input
10947 characters when the diversion is reread.  It can be also used for gross
10948 hacks; for example, the following sets register@w{ }@code{n} to@w{ }1.
10950 @Example
10951 .tr @@.
10952 .di x
10953 @@nr n 1
10956 .tr @@@@
10957 .asciify x
10959 @endExample
10961 @xref{Copy-in Mode}.
10962 @endDefreq
10964 @Defreq {unformat, div}
10965 Like @code{asciify}, unformat the specified diversion.
10966 However, @code{unformat} only unformats spaces and tabs
10967 between words.
10968 Unformatted tabs are treated as input tokens,
10969 and spaces are stretchable again.
10971 The vertical size of lines is not preserved; glyph information (font,
10972 font size, space width, etc.)@: is retained.
10973 @endDefreq
10976 @c =====================================================================
10978 @node Environments, Suppressing output, Diversions, gtroff Reference
10979 @section Environments
10980 @cindex environments
10982 It happens frequently that some text should be printed in a certain
10983 format regardless of what may be in effect at the time, for example, in
10984 a trap invoked macro to print headers and footers.  To solve this
10985 @code{gtroff} processes text in @dfn{environments}.  An
10986 environment contains most of the parameters that control text
10987 processing.  It is possible to switch amongst these environments; by
10988 default @code{gtroff} processes text in environment@w{ }0.  The
10989 following is the information kept in an environment.
10991 @itemize @bullet
10992 @item
10993 font parameters (size, family, style, glyph height and slant, space
10994 and sentence space size)
10996 @item
10997 page parameters (line length, title length, vertical spacing,
10998 line spacing, indentation, line numbering, centering, right-justifying,
10999 underlining, hyphenation data)
11001 @item
11002 fill and adjust mode
11004 @item
11005 tab stops, tab and leader characters, escape character,
11006 no-break and hyphen indicators, margin character data
11008 @item
11009 partially collected lines
11011 @item
11012 input traps
11014 @item
11015 drawing and fill colours
11016 @end itemize
11018 These environments may be given arbitrary names (see @ref{Identifiers},
11019 for more info).  Old versions of @code{troff} only had environments
11020 named @samp{0}, @samp{1}, and @samp{2}.
11022 @DefreqList {ev, [@Var{env}]}
11023 @DefregListEnd {.ev}
11024 @cindex switching environments (@code{ev})
11025 @cindex environment, switching (@code{ev})
11026 @cindex environment number/name register (@code{.ev})
11027 Switch to another environment.  The argument @var{env} is the name of
11028 the environment to switch to.  With no argument, @code{gtroff} switches
11029 back to the previous environment.  There is no limit on the number of
11030 named environments; they are created the first time that they are
11031 referenced.  The @code{.ev} read-only register contains the name or
11032 number of the current environment.  This is a string-valued register.
11034 Note that a call to @code{ev} (with argument) pushes the previously
11035 active environment onto a stack.  If, say, environments @samp{foo},
11036 @samp{bar}, and @samp{zap} are called (in that order), the first
11037 @code{ev} request without parameter switches back to environment
11038 @samp{bar} (which is popped off the stack), and a second call
11039 switches back to environment @samp{foo}.
11041 Here is an example:
11043 @Example
11044 .ev footnote-env
11045 .fam N
11046 .ps 6
11047 .vs 8
11048 .ll -.5i
11053 .ev footnote-env
11054 \(dg Note the large, friendly letters.
11056 @endExample
11057 @endDefreq
11059 @Defreq {evc, env}
11060 @cindex copying environment (@code{evc})
11061 @cindex environment, copying (@code{evc})
11062 Copy the environment @var{env} into the current environment.
11064 The following environment data is not copied:
11066 @itemize @bullet
11067 @item
11068 Partially filled lines.
11070 @item
11071 The status whether the previous line was interrupted.
11073 @item
11074 The number of lines still to center, or to right-justify, or to underline
11075 (with or without underlined spaces); they are set to zero.
11077 @item
11078 The status whether a temporary indent is active.
11080 @item
11081 Input traps and its associated data.
11083 @item
11084 Line numbering mode is disabled; it can be reactivated with
11085 @w{@samp{.nm +0}}.
11087 @item
11088 The number of consecutive hyphenated lines (set to zero).
11089 @end itemize
11090 @endDefreq
11092 @DefregList {.cht}
11093 @DefregItem {.cdp}
11094 @DefregListEnd {.csk}
11095 @cindex environment, last glyph
11096 The @code{\n[.cht]} register contains the
11097 maximum extent (above the baseline)
11098 of the last glyph added to the current environment.
11100 The @code{\n[.cdp]} register contains the
11101 maximum extent (below the baseline)
11102 of the last glyph added to the current environment.
11104 The @code{\n[.csk]} register contains the
11105 @dfn{skew} (how far to the right of the glyph's center
11106 that @code{gtroff} shold place an accent)
11107 of the last glyph added to the current environment.
11108 @endDefreg
11111 @c =====================================================================
11113 @node Suppressing output, Colors, Environments, gtroff Reference
11114 @section Suppressing output
11116 @Defesc {\\O, , num, }
11117 @cindex suppressing output (@code{\O})
11118 @cindex output, suppressing (@code{\O})
11119 Disable or enable output depending on the value of @var{num}:
11121 @table @samp
11122 @item \O0
11123 Disable any glyphs from being emitted to the device driver, provided that
11124 the escape occurs at the outer level (see @code{\O[3]} and @code{\O[4]}).
11125 Motion is not suppressed so effectively @code{\O[0]} means @emph{pen up}.
11127 @item \O1
11128 Enable output of glyphs, provided that the escape occurs at the outer
11129 level.
11130 @end table
11132 @vindex opminx
11133 @vindex opminy
11134 @vindex opmaxx
11135 @vindex opmaxy
11136 @code{\O0} and @code{\O1} also reset the four registers @samp{opminx},
11137 @samp{opminy}, @samp{opmaxx}, and @samp{opmaxy} to @minus{}1.
11138 @xref{Register Index}.  These four registers mark the top left and
11139 bottom right hand corners of a box which encompasses all written glyphs.
11141 For example the input text:
11143 @Example
11144 Hello \O[0]world \O[1]this is a test.
11145 @endExample
11147 @noindent
11148 produces the following output:
11150 @Example
11151 Hello       this is a test.
11152 @endExample
11154 @table @samp
11155 @item \O2
11156 Provided that the escape occurs at the outer level, enable output of
11157 glyphs and also write out to @code{stderr} the page number and four
11158 registers encompassing the glyphs previously written since the last call
11159 to @code{\O}.
11161 @item \O3
11162 Begin a nesting level.  At start-up, @code{gtroff} is at outer level.
11164 @item \O4
11165 End a nesting level.
11167 @item \O[5@var{P}@var{filename}]
11168 This escape is @code{grohtml} specific.  Provided that this escape
11169 occurs at the outer nesting level write the @code{filename} to
11170 @code{stderr}.  The position of the image, @var{P}, must be specified
11171 and must be one of @code{l}, @code{r}, @code{c}, or@w{ }@code{i} (left,
11172 right, centered, inline).  @var{filename} will be associated with the
11173 production of the next inline image.
11174 @end table
11175 @endDefesc
11177 @c =====================================================================
11179 @node Colors, I/O, Suppressing output, gtroff Reference
11180 @section Colors
11181 @cindex colors
11183 @Defreq {defcolor, ident scheme color_components}
11184 Define color with name @var{ident}.  @var{scheme} can be one of  the
11185 following values: @code{rgb} (three components), @code{cym} (three
11186 components), @code{cmyk} (four components), and @code{gray} or
11187 @code{grey} (one component).
11189 @cindex default color
11190 @cindex color, default
11191 Color components can be given either as a hexadecimal string or as
11192 positive decimal integers in the range 0--65535.  A hexadecimal string
11193 contains all color components concatenated.  It must start with either
11194 @code{#} or @code{##}; the former specifies hex values in the range
11195 0--255 (which are internally multiplied by@w{ }257), the latter in the
11196 range 0--65535.  Examples: @code{#FFC0CB} (pink), @code{##ffff0000ffff}
11197 (magenta).  The default color name @c{default} can't be redefined; its
11198 value is device-specific (usually black).  It is possible that the
11199 default color for @code{\m} and @code{\M} is not identical.
11201 @cindex @code{f} unit, and colors
11202 @cindex unit, @code{f}, and colors
11203 A new scaling indicator@w{ }@code{f} has been introduced which multiplies
11204 its value by 65536; this makes it convenient to specify color components
11205 as fractions in the range 0 to@w{ }1 (1f equals 65536u).  Example:
11207 @Example
11208 .defcolor darkgreen rgb 0.1f 0.5f 0.2f
11209 @endExample
11211 Note that @code{f} is the default scaling indicator for the
11212 @code{defcolor} request, thus the above statement is equivalent to
11214 @Example
11215 .defcolor darkgreen rgb 0.1 0.5 0.2
11216 @endExample
11217 @endDefreq
11219 @DefescList {\\m, , c, }
11220 @DefescItem {\\m, @lparen{}, co, }
11221 @DefescListEnd {\\m, @lbrack{}, color, @rbrack}
11222 Set drawing color.  The following example shows how to turn the next four
11223 words red.
11225 @Example
11226 \m[red]these are in red\m[] and these words are in black.
11227 @endExample
11229 The escape @code{\m[]} returns to the previous color.
11231 The drawing color is associated with the current environment
11232 (@pxref{Environments}).
11233 @endDefesc
11235 @DefescList {\\M, , c, }
11236 @DefescItem {\\M, @lparen{}, co, }
11237 @DefescListEnd {\\M, @lbrack{}, color, @rbrack}
11238 Set background color for filled objects drawn with the
11239 @code{\D'@dots{}'} commands.
11241 A red ellipse can be created with the following code:
11243 @Example
11244 \M[red]\h'0.5i'\D'E 2i 1i'\M[]
11245 @endExample
11247 The escape @code{\M[]} returns to the previous fill color.
11249 The fill color is associated with the current environment
11250 (@pxref{Environments}).
11251 @endDefesc
11254 @c =====================================================================
11256 @node I/O, Postprocessor Access, Colors, gtroff Reference
11257 @section I/O
11258 @cindex i/o
11259 @cindex input and output requests
11260 @cindex requests for input and output
11261 @cindex output and input requests
11263 @code{gtroff} has several requests for including files:
11265 @Defreq {so, file}
11266 @cindex including a file (@code{so})
11267 @cindex file, inclusion (@code{so})
11268 Read in the specified @var{file} and
11269 includes it in place of the @code{so} request.  This is quite useful for
11270 large documents, e.g.@: keeping each chapter in a separate file.
11271 @xref{gsoelim}, for more information.
11273 Since @code{gtroff} replaces the @code{so} request with the contents
11274 of @code{file}, it makes a difference whether the data is terminated with
11275 a newline or not: Assuming that file @file{xxx} contains the word
11276 @samp{foo} without a final newline, this
11278 @Example
11279 This is
11280 .so xxx
11282 @endExample
11284 @noindent
11285 yields @samp{This is foobar}.
11286 @endDefreq
11288 @Defreq {pso, command}
11289 Read the standard output from the specified @var{command}
11290 and includes it in place of the @code{pso} request.
11292 @cindex safer mode
11293 @cindex mode, safer
11294 @cindex unsafe mode
11295 @cindex mode, unsafe
11296 This request causes an error if used in safer mode (which is the default).
11297 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
11298 mode.
11300 The comment regarding a final newline for the @code{so} request is valid
11301 for @code{pso} also.
11302 @endDefreq
11304 @Defreq {mso, file}
11305 Identical to the @code{so} request except that @code{gtroff} searches for
11306 the specified @var{file} in the same directories as macro files for the
11307 the @option{-m} command line option.  If the file name to be included
11308 has the form @file{@var{name}.tmac} and it isn't found, @code{mso} tries
11309 to include @file{tmac.@var{name}} and vice versa.
11310 @endDefreq
11312 @DefreqList {trf, file}
11313 @DefreqListEnd {cf, file}
11314 @cindex transparent output (@code{cf}, @code{trf})
11315 @cindex output, transparent (@code{cf}, @code{trf})
11316 Transparently output the contents of @var{file}.  Each line is output
11317 as if it were preceded by @code{\!}; however, the lines are not subject
11318 to copy mode interpretation.  If the file does not end with a newline,
11319 then a newline is added (@code{trf} only).  For example, to define a
11320 macro@w{ }@code{x} containing the contents of file@w{ }@file{f}, use
11322 @Example
11323 .di x
11324 .trf f
11326 @endExample
11328 Both @code{trf} and @code{cf}, when used in a diversion,
11329 embeds an object in the diversion which, when reread, causes the
11330 contents of @var{file} to be transparently copied through to the
11331 output.  In @acronym{UNIX} @code{troff}, the contents of @var{file}
11332 is immediately copied through to the output regardless of whether there
11333 is a current diversion; this behaviour is so anomalous that it must be
11334 considered a bug.
11336 @cindex @code{trf} request, and invalid characters
11337 @cindex characters, invalid for @code{trf} request
11338 @cindex invalid characters for @code{trf} request
11339 While @code{cf} copies the contents of @var{file} completely unprocessed,
11340 @code{trf} disallows characters such as NUL that are not valid
11341 @code{gtroff} input characters (@pxref{Identifiers}).
11343 Both requests cause a line break.
11344 @endDefreq
11346 @Defreq {nx, [@Var{file}]}
11347 @cindex processing next file (@code{nx})
11348 @cindex file, processing next (@code{nx})
11349 @cindex next file, processing (@code{nx})
11350 Force @code{gtroff} to continue processing of
11351 the file specified as an argument.  If no argument is given, immediately
11352 jump to the end of file.
11353 @endDefreq
11355 @Defreq {rd, [@Var{prompt} [@Var{arg1} @Var{arg2} @dots{}]]}
11356 @cindex reading from standard input (@code{rd})
11357 @cindex standard input, reading from (@code{rd})
11358 @cindex input, standard, reading from (@code{rd})
11359 Read from standard input, and include what is read as though it
11360 were part of the input file.  Text is read until a blank line
11361 is encountered.
11363 If standard input is a TTY input device (keyboard), write @var{prompt}
11364 to standard error, followed by a colon (or send BEL for a beep if no
11365 argument is given).
11367 Arguments after @var{prompt} are available for the input.  For example,
11368 the line
11370 @Example
11371 .rd data foo bar
11372 @endExample
11374 with the input @w{@samp{This is \$2.}} prints
11376 @Example
11377 This is bar.
11378 @endExample
11379 @endDefreq
11381 @cindex form letters
11382 @cindex letters, form
11383 Using the @code{nx} and @code{rd} requests,
11384 it is easy to set up form letters.  The form
11385 letter template is constructed like this, putting the following lines
11386 into a file called @file{repeat.let}:
11388 @Example
11390 \*(td
11391 .sp 2
11397 Body of letter.
11399 .nx repeat.let
11400 @endExample
11402 @cindex @code{ex} request, used with @code{nx} and @code{rd}
11403 @noindent
11404 When this is run, a file containing the following lines should be
11405 redirected in.  Note that requests included in this file are executed
11406 as though they were part of the form letter.  The last block of input
11407 is the @code{ex} request which tells groff to stop processing.  If
11408 this was not there, groff would not know when to stop.
11410 @Example
11411 Trent A. Fisher
11412 708 NW 19th Av., #202
11413 Portland, OR  97209
11415 Dear Trent,
11417 Len Adollar
11418 4315 Sierra Vista
11419 San Diego, CA  92103
11421 Dear Mr. Adollar,
11424 @endExample
11426 @Defreq {pi, pipe}
11427 Pipe the output of @code{gtroff} to the shell command(s)
11428 specified by @var{pipe}.  This request must occur before
11429 @code{gtroff} has a chance to print anything.
11431 @cindex safer mode
11432 @cindex mode, safer
11433 @cindex unsafe mode
11434 @cindex mode, unsafe
11435 @code{pi} causes an error if used in safer mode (which is the default).
11436 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
11437 mode.
11439 Multiple calls to @code{pi} are allowed, acting as a chain.  For example,
11441 @Example
11442 .pi foo
11443 .pi bar
11445 @endExample
11447 is the same as @w{@samp{.pi foo | bar}}.
11449 @cindex @code{groff}, and @code{pi} request
11450 @cindex @code{pi} request, and @code{groff}
11451 Note that the intermediate output format of @code{gtroff} is piped to
11452 the specified commands.  Consequently, calling @code{groff} without the
11453 @option{-Z} option normally causes a fatal error.
11454 @endDefreq
11456 @DefreqList {sy, cmds}
11457 @DefregListEnd {systat}
11458 Execute the shell command(s) specified by @var{cmds}.  The output is not
11459 saved anyplace, so it is up to the user to do so.
11461 @cindex safer mode
11462 @cindex mode, safer
11463 @cindex unsafe mode
11464 @cindex mode, unsafe
11465 This request causes an error if used in safer mode (which is the default).
11466 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
11467 mode.
11469 For example, the following example introduces the current time
11470 into a document:
11472 @cindex time, current
11473 @cindex current time
11474 @pindex perl
11475 @Example
11476 .sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
11477              (localtime(time))[2,1,0]' > /tmp/x\n[$$]
11478 .so /tmp/x\n[$$]
11479 .sy rm /tmp/x\n[$$]
11480 \nH:\nM:\nS
11481 @endExample
11483 @noindent
11484 Note that this works by having the @code{perl} script (run by @code{sy})
11485 print out the @code{nr} requests which set the number registers
11486 @samp{H}, @samp{M} and @samp{S}, and then reads those commands in with
11487 the @code{so} request.
11489 @cindex @code{system()} return value register (@code{systat})
11490 The @code{systat} read-write number register contains the return value
11491 of the @code{system()} function executed by the last @code{sy} request.
11492 @endDefreq
11494 @DefreqList {open, stream file}
11495 @DefreqListEnd {opena, stream file}
11496 @cindex opening file (@code{open})
11497 @cindex file, opening (@code{open})
11498 @cindex appending to a file (@code{opena})
11499 @cindex file, appending to (@code{opena})
11500 Open the specified @var{file} for writing and
11501 associates the specified @var{stream} with it.
11503 The @code{opena} request is like @code{open}, but if the file exists,
11504 append to it instead of truncating it.
11506 @cindex safer mode
11507 @cindex mode, safer
11508 @cindex unsafe mode
11509 @cindex mode, unsafe
11510 Both @code{open} and @code{opena} cause an error if used in safer mode
11511 (which is the default).  Use @code{groff}'s or @code{troff}'s @option{-U}
11512 option to activate unsafe mode.
11513 @endDefreq
11515 @DefreqList {write, stream data}
11516 @DefreqListEnd {writec, stream data}
11517 @cindex copy-in mode, and @code{write} requests
11518 @cindex mode, copy-in, and @code{write} requests
11519 @cindex writing to file (@code{write})
11520 @cindex file, writing to (@code{write})
11521 Write to the file associated with the specified @var{stream}.
11522 The stream must previously have
11523 been the subject of an open request.  The remainder of the line is
11524 interpreted as the @code{ds} request reads its second argument: A
11525 leading @samp{"} is stripped, and it is read in copy-in mode.
11527 The @code{writec} request is like @code{write}, but only
11528 @code{write} appends a newline to the data.
11529 @endDefreq
11531 @Defreq {writem, stream xx}
11532 @cindex @code{asciify} request, and @code{writem}
11533 Write the contents of the macro or string @var{xx}
11534 to the file associated with the specified @var{stream}.
11536 @var{xx} is read in copy mode, i.e., already formatted elements are
11537 ignored.  Consequently, diversions must be unformatted with the
11538 @code{asciify} request before calling @code{writem}.  Usually, this
11539 means a loss of information.
11540 @endDefreq
11542 @Defreq {close, stream}
11543 @cindex closing file (@code{close})
11544 @cindex file, closing (@code{close})
11545 Close the specified @var{stream};
11546 the stream is no longer an acceptable argument to the
11547 @code{write} request.
11549 Here a simple macro to write an index entry.
11551 @Example
11552 .open idx test.idx
11554 .de IX
11555 .  write idx \\n[%] \\$*
11558 .IX test entry
11560 .close idx
11561 @endExample
11562 @endDefreq
11564 @DefescList {\\V, , e, }
11565 @DefescItem {\\V, @lparen{}, ev, }
11566 @DefescListEnd {\\V, @lbrack{}, env, @rbrack}
11567 Interpolate the contents of the specified environment variable
11568 @var{env} (one-character name@w{ }@var{e}, two-character name @var{ev})
11569 as returned by the function @code{getenv}.  @code{\V} is interpreted
11570 in copy-in mode.
11571 @endDefesc
11574 @c =====================================================================
11576 @node Postprocessor Access, Miscellaneous, I/O, gtroff Reference
11577 @section Postprocessor Access
11578 @cindex postprocessor access
11579 @cindex access of postprocessor
11581 There are two escapes which give information directly to the
11582 postprocessor.  This is particularly useful for embedding
11583 @sc{PostScript} into the final document.
11585 @Defesc {\\X, ', xxx, '}
11586 Embeds its argument into the @code{gtroff}
11587 output preceded with @w{@samp{x X}}.
11589 @cindex @code{\&}, in @code{\X}
11590 @cindex @code{\)}, in @code{\X}
11591 @cindex @code{\%}, in @code{\X}
11592 @ifnotinfo
11593 @cindex @code{\:}, in @code{\X}
11594 @end ifnotinfo
11595 @ifinfo
11596 @cindex @code{\@r{<colon>}}, in @code{\X}
11597 @end ifinfo
11598 The escapes @code{\&}, @code{\)}, @code{\%}, and @code{\:} are ignored
11599 within @code{\X}; all other escapes (except @code{\\} which produces a
11600 backslash) cause an error.
11602 @kindex use_charnames_in_special
11603 @pindex DESC@r{, and @code{use_charnames_in_special}}
11604 @cindex @code{\X}, and special characters
11605 If the @samp{use_charnames_in_special} keyword is set in the @file{DESC}
11606 file, special characters no longer cause an error; the name @var{xx} is
11607 represented as @samp{\(@var{xx})} in the @w{@samp{x X}} output command.
11608 Additionally, the backslash is represented as @code{\\}.
11610 This mechanism is currently used by @code{grohtml} only.
11611 @endDefesc
11613 @DefescList {\\Y, , n, }
11614 @DefescItem {\\Y, @lparen{}, nm, }
11615 @DefescListEnd {\\Y, @lbrack{}, name, @rbrack}
11616 This is approximately equivalent to @samp{\X'\*[@var{name}]'}
11617 (one-character name@w{ }@var{n}, two-character name @var{nm}).
11618 However, the contents of the string or macro @var{name} are not
11619 interpreted; also it is permitted for @var{name} to have been defined
11620 as a macro and thus contain newlines (it is not permitted for the
11621 argument to @code{\X} to contain newlines).  The inclusion of
11622 newlines requires an extension to the @acronym{UNIX} @code{troff}
11623 output format, and confuses drivers that do not know about this
11624 extension (@pxref{Device Control Commands}).
11625 @endDefesc
11627 @xref{Output Devices}.
11630 @c =====================================================================
11632 @node Miscellaneous, Gtroff Internals, Postprocessor Access, gtroff Reference
11633 @section Miscellaneous
11635 This section documents parts of @code{gtroff} which cannot (yet) be
11636 categorized elsewhere in this manual.
11638 @Defreq {nm, [@Var{start} [@Var{inc} [@Var{space} [@Var{indent}]]]]}
11639 @cindex printing line numbers (@code{nm})
11640 @cindex line numbers, printing (@code{nm})
11641 @cindex numbers, line, printing (@code{nm})
11642 Print line numbers.
11643 @var{start} is the line number of the @emph{next}
11644 output line.  @var{inc} indicates which line numbers are printed.
11645 For example, the value@w{ }5 means to emit only line numbers which
11646 are multiples of@w{ }5; this defaults to@w{ }1.  @var{space} is the
11647 space to be left between the number and the text; this defaults to
11648 one digit space.  The fourth argument is the indentation of the line
11649 numbers, defaulting to zero.  Both @var{space} and @var{indent} are
11650 given as multiples of digit spaces; they can be negative also.
11651 Without any arguments, line numbers are turned off.
11653 @code{gtroff} reserves three digit spaces for the line number (which is
11654 printed right-justified) plus the amount given by @var{indent}; the
11655 output lines are concatenated to the line numbers, separated by
11656 @var{space}, and @emph{without} reducing the line length.  Depending
11657 on the value of the horizontal page offset (as set with the
11658 @code{po} request), line numbers which are longer than the reserved
11659 space stick out to the left, or the whole line is moved to the right.
11661 Parameters corresponding to missing arguments are not changed; any
11662 non-digit argument (to be more precise, any argument starting with a
11663 character valid as a delimiter for identifiers) is also treated as
11664 missing.
11666 If line numbering has been disabled with a call to @code{nm} without
11667 an argument, it can be reactivated with @samp{.nm +0}, using the
11668 previously active line numbering parameters.
11670 The parameters of @code{nm} are associated with the current environment
11671 (@pxref{Environments}).  The current output line number is available
11672 in the number register @code{ln}.
11674 @Example
11675 .po 1m
11676 .ll 2i
11677 This test shows how line numbering works with groff.
11678 .nm 999
11679 This test shows how line numbering works with groff.
11681 .nm xxx 3 2
11682 .ll -\w'0'u
11683 This test shows how line numbering works with groff.
11684 .nn 2
11685 This test shows how line numbering works with groff.
11686 @endExample
11688 @noindent
11689 And here the result:
11691 @Example
11692  This  test shows how
11693  line numbering works
11694  999 with   groff.   This
11695 1000 test shows how  line
11696 1001 numbering works with
11697 1002 groff.
11698       This test shows how
11699       line      numbering
11700  works  with  groff.
11701  This test shows how
11702 1005  line      numbering
11703       works with groff.
11704 @endExample
11705 @endDefreq
11707 @Defreq {nn, [@Var{skip}]}
11708 Temporarily turn off line numbering.  The argument is the number
11709 of lines not to be numbered; this defaults to@w{ }1.
11710 @endDefreq
11712 @Defreq {mc, glyph [@Var{dist}]}
11713 @cindex margin glyph (@code{mc})
11714 @cindex glyph, for margins (@code{mc})
11715 Print a @dfn{margin character} to the right of the
11716 text.@footnote{@dfn{Margin character} is a misnomer since it is an
11717 output glyph.}  The first argument is the glyph to be
11718 printed.  The second argument is the distance away from the right
11719 margin.  If missing, the previously set value is used; default is
11720 10@dmn{pt}).  For text lines that are too long (that is, longer than
11721 the text length plus @var{dist}), the margin character is directly
11722 appended to the lines.
11724 With no arguments the margin character is turned off.
11725 If this occurs before a break, no margin character is printed.
11727 @cindex @code{tl} request, and @code{mc}
11728 For empty lines and lines produced by the @code{tl} request no margin
11729 character is emitted.
11731 The margin character is associated with the current environment
11732 (@pxref{Environments}).
11734 @pindex nrchbar
11735 @pindex changebar
11736 This is quite useful for indicating text that has changed, and, in fact,
11737 there are programs available for doing this (they are called
11738 @code{nrchbar} and @code{changebar} and can be found in any
11739 @samp{comp.sources.unix} archive.
11741 @Example
11742 .ll 3i
11743 .mc |
11744 This paragraph is highlighted with a margin
11745 character.
11747 Note that vertical space isn't marked.
11751 But we can fake it with `\&'.
11752 @endExample
11754 Result:
11756 @Example
11757 This  paragraph is highlighted |
11758 with a margin character.       |
11760 Note that vertical space isn't |
11761 marked.                        |
11762                                |
11763 But we can fake it with `\&'.  |
11764 @endExample
11765 @endDefreq
11767 @DefreqList {psbb, filename}
11768 @DefregItem {llx}
11769 @DefregItem {lly}
11770 @DefregItem {urx}
11771 @DefregListEnd {ury}
11772 @cindex PostScript, bounding box
11773 @cindex bounding box
11774 Retrieve the bounding box of the PostScript image
11775 found in @var{filename}.
11776 The file must conform to
11777 Adobe's @dfn{Document Structuring Conventions} (DSC);
11778 the command searches for a @code{%%BoundingBox} comment
11779 and extracts the bounding box values into the number registers
11780 @code{llx}, @code{lly}, @code{urx}, and @code{ury}.
11781 If an error occurs (for example, @code{psbb} cannot find
11782 the @code{%%BoundingBox} comment),
11783 it sets the four number registers to zero.
11784 @endDefreq
11787 @c =====================================================================
11789 @node Gtroff Internals, Debugging, Miscellaneous, gtroff Reference
11790 @section @code{gtroff} Internals
11792 @cindex input token
11793 @cindex token, input
11794 @cindex output node
11795 @cindex node, output
11796 @code{gtroff} processes input in three steps.  One or more input
11797 characters are converted to an @dfn{input token}.@footnote{Except the
11798 escapes @code{\f}, @code{\F}, @code{\H}, @code{\R}, @code{\s}, and
11799 @code{\S} which are processed immediately if not in copy-in mode.}
11800 Then, one or more input tokens are converted to an @dfn{output node}.
11801 Finally, output nodes are converted to the intermediate output language
11802 understood by all output devices.
11804 Actually, before step one happens, @code{gtroff} converts certain
11805 escape sequences into reserved input characters (not accessible by
11806 the user); such reserved characters are used for other internal
11807 processing also -- this is the very reason why not all characters
11808 are valid input.  @xref{Identifiers}, for more on this topic.
11810 For example, the input string @samp{fi\[:u]} is converted into a
11811 character token @samp{f}, a character token @samp{i}, and a special
11812 token @samp{:u} (representing u@w{ }umlaut).  Later on, the character
11813 tokens @samp{f} and @samp{i} are merged to a single output node
11814 representing the ligature glyph @samp{fi} (provided the current font
11815 has a glyph for this ligature); the same happens with @samp{:u}.  All
11816 output glyph nodes are `processed' which means that they are invariably
11817 associated with a given font, font size, advance width, etc.  During
11818 the formatting process, @code{gtroff} itself adds various nodes to
11819 control the data flow.
11821 Macros, diversions, and strings collect elements in two chained lists:
11822 a list of input tokens which have been passed unprocessed, and a list
11823 of output nodes.  Consider the following the diversion.
11825 @Example
11826 .di xxx
11832 @endExample
11834 @noindent
11835 It contains these elements.
11837 @multitable {@i{vertical size node}} {token list} {element number}
11838 @item node list               @tab token list @tab element number
11840 @item @i{line start node}     @tab ---        @tab 1
11841 @item @i{glyph node @code{a}} @tab ---        @tab 2
11842 @item @i{word space node}     @tab ---        @tab 3
11843 @item ---                     @tab @code{b}   @tab 4
11844 @item ---                     @tab @code{\n}  @tab 5
11845 @item @i{glyph node @code{c}} @tab ---        @tab 6
11846 @item @i{vertical size node}  @tab ---        @tab 7
11847 @item @i{vertical size node}  @tab ---        @tab 8
11848 @item ---                     @tab @code{\n}  @tab 9
11849 @end multitable
11851 @cindex @code{\v}, internal representation
11852 @noindent
11853 Elements 1, 7, and@w{ }8 are inserted by @code{gtroff}; the latter two
11854 (which are always present) specify the vertical extent of the last
11855 line, possibly modified by @code{\x}.  The @code{br} request finishes
11856 the current partial line, inserting a newline input token which is
11857 subsequently converted to a space when the diversion is reread.  Note
11858 that the word space node has a fixed width which isn't stretchable
11859 anymore.  To convert horizontal space nodes back to input tokens, use
11860 the @code{unformat} request.
11862 Macros only contain elements in the token list (and the node list is
11863 empty); diversions and strings can contain elements in both lists.
11865 Some requests like @code{tr} or @code{cflags} work on glyph
11866 identifiers only; this means that the associated glyph can be changed
11867 without destroying this association.  This can be very helpful for
11868 substituting glyphs.  In the following example, we assume that
11869 glyph @samp{foo} isn't available by default, so we provide a
11870 substitution using the @code{fchar} request and map it to input
11871 character @samp{x}.
11873 @Example
11874 .fchar \[foo] foo
11875 .tr x \[foo]
11876 @endExample
11878 @noindent
11879 Now let us assume that we install an additional special font
11880 @samp{bar} which has glyph @samp{foo}.
11882 @Example
11883 .special bar
11884 .rchar \[foo]
11885 @endExample
11887 @noindent
11888 Since glyphs defined with @code{fchar} are searched before glyphs
11889 in special fonts, we must call @code{rchar} to remove the definition
11890 of the fallback glyph.  Anyway, the translation is still active;
11891 @samp{x} now maps to the real glyph @samp{foo}.
11894 @c =====================================================================
11896 @node Debugging, Implementation Differences, Gtroff Internals, gtroff Reference
11897 @section Debugging
11898 @cindex debugging
11900 @code{gtroff} is not easy to debug, but there are some useful features
11901 and strategies for debugging.
11903 @Defreq {lf, line filename}
11904 @pindex soelim
11905 @cindex multi-file documents
11906 @cindex documents, multi-file
11907 @cindex setting input line number (@code{lf})
11908 @cindex input line number, setting (@code{lf})
11909 @cindex number, input line, setting (@code{lf})
11910 Change the line number and the file name @code{gtroff} shall use for
11911 error and warning messages.  @var{line} is the input line number of the
11912 @emph{next} line.
11914 Without argument, the request is ignored.
11916 This is a debugging aid for documents which are split into many files,
11917 then put together with @code{soelim} and other preprocessors.  Usually,
11918 it isn't invoked manually.
11919 @endDefreq
11921 @DefreqList {tm, string}
11922 @DefreqItem {tm1, string}
11923 @DefreqListEnd {tmc, string}
11924 @cindex printing to stderr (@code{tm}, @code{tm1}, @code{tmc})
11925 @cindex stderr, printing to (@code{tm}, @code{tm1}, @code{tmc})
11926 Send @var{string} to the standard error output;
11927 this is very useful for printing debugging messages among other things.
11929 @var{string} is read in copy mode.
11931 The @code{tm} request ignores leading spaces of @var{string}; @code{tm1}
11932 handles its argument similar to the @code{ds} request: a leading double
11933 quote in @var{string} is stripped to allow initial blanks.
11935 The @code{tmc} request is similar to @code{tm1} but does
11936 not append a newline (as is done in @code{tm} and @code{tm1}).
11937 @endDefreq
11939 @Defreq {ab, [@Var{string}]}
11940 @cindex aborting (@code{ab})
11941 Similar to the @code{tm} request, except that
11942 it causes @code{gtroff} to stop processing.  With no argument it
11943 prints @samp{User Abort.} to standard error.
11944 @endDefreq
11946 @Defreq {ex, }
11947 @cindex @code{ex} request, use in debugging
11948 @cindex exiting (@code{ex})
11949 The @code{ex} request also causes @code{gtroff} to stop processing;
11950 see also @ref{I/O}.
11951 @endDefreq
11953 When doing something involved it is useful to leave the debugging
11954 statements in the code and have them turned on by a command line flag.
11956 @Example
11957 .if \n(DB .tm debugging output
11958 @endExample
11960 @noindent
11961 To activate these statements say
11963 @Example
11964 groff -rDB=1 file
11965 @endExample
11967 If it is known in advance that there will be many errors and no useful
11968 output, @code{gtroff} can be forced to suppress formatted output with
11969 the @option{-z} flag.
11971 @Defreq {pm, }
11972 @cindex dumping symbol table (@code{pm})
11973 @cindex symbol table, dumping (@code{pm})
11974 Print the entire symbol table on @code{stderr}.  Names of all defined
11975 macros, strings, and diversions are print together with their size in
11976 bytes.  Since @code{gtroff} sometimes adds nodes by itself, the
11977 returned size can be larger than expected.
11979 This request differs from @acronym{UNIX} @code{troff}: @code{gtroff}
11980 reports the sizes of diversions, ignores an additional argument to
11981 print only the total of the sizes, and the size isn't returned in
11982 blocks of 128 characters.
11983 @endDefreq
11985 @Defreq {pnr, }
11986 @cindex dumping number registers (@code{pnr})
11987 @cindex number registers, dumping (@code{pnr})
11988 Print the names and contents of all
11989 currently defined number registers on @code{stderr}.
11990 @endDefreq
11992 @Defreq {ptr, }
11993 @cindex dumping traps (@code{ptr})
11994 @cindex traps, dumping (@code{ptr})
11995 Print the names and positions of all traps
11996 (not including input line traps and diversion traps) on @code{stderr}.
11997 Empty slots in the page trap list are printed as well, because they can
11998 affect the priority of subsequently planted traps.
11999 @endDefreq
12001 @Defreq {fl, }
12002 @cindex flush output (@code{fl})
12003 @cindex output, flush (@code{fl})
12004 @cindex interactive use of @code{gtroff}
12005 @cindex @code{gtroff}, interactive use
12006 Instruct @code{gtroff} to flush its output immediately.  The intent
12007 is for interactive use, but this behaviour is currently not
12008 implemented in @code{gtroff}.  Contrary to @acronym{UNIX} @code{troff},
12009 TTY output is sent to a device driver also (@code{grotty}), making it
12010 non-trivial to communicate interactively.
12012 This request causes a line break.
12013 @endDefreq
12015 @Defreq {backtrace, }
12016 @cindex backtrace of input stack (@code{backtrace})
12017 @cindex input stack, backtrace (@code{backtrace})
12018 Print a backtrace of the input stack to the standard error stream.
12020 Consider the following in file @file{test}:
12022 @Example
12023 .de xxx
12024 .  backtrace
12026 .de yyy
12027 .  xxx
12030 .yyy
12031 @endExample
12033 @noindent
12034 On execution, @code{gtroff} prints the following:
12036 @Example
12037 test:2: backtrace: macro `xxx'
12038 test:5: backtrace: macro `yyy'
12039 test:8: backtrace: file `test'
12040 @endExample
12042 The option @option{-b} of @code{gtroff} internally calls a variant of
12043 this request on each error and warning.
12044 @endDefreq
12046 @Defreg {slimit}
12047 @cindex input stack, setting limit
12048 Use the @code{slimit} number register
12049 to set the maximum number of objects on the input stack.
12050 If @code{slimit} is less than or equal to@w{ }0,
12051 there is no limit set.
12052 With no limit, a buggy recursive macro can exhaust virtual memory.
12054 The default value is 1000; this is a compile-time constant.
12055 @endDefreg
12057 @Defreq {warnscale, si}
12058 Set the scaling indicator used in warnings to @var{si}.  Valid values for
12059 @var{si} are @samp{u}, @samp{i}, @samp{c}, @samp{p}, and @samp{P}.  At
12060 startup, it is set to @samp{i}.
12061 @endDefreq
12063 @Defreq {spreadwarn, [@Var{limit}]}
12064 Make @code{gtroff} emit a warning if the additional space inserted for
12065 each space between words in an output line is larger or equal to
12066 @var{limit}.  A negative value is changed to zero; no argument toggles the
12067 warning on and off without changing @var{limit}.  The default scaling
12068 indicator is @samp{m}.  At startup, @code{spreadwarn} is deactivated, and
12069 @var{limit} is set to 3@dmn{m}.
12071 For example,
12073 @Example
12074 .spreadwarn 0.2m
12075 @endExample
12077 @noindent
12078 will cause a warning if @code{gtroff} must add 0.2@dmn{m} or more for each
12079 interword space in a line.
12081 This request is active only if text is justified to both margins (using
12082 @w{@samp{.ad b}}).
12083 @endDefreq
12085 @cindex warnings
12086 @code{gtroff} has command line options for printing out more warnings
12087 (@option{-w}) and for printing backtraces (@option{-b}) when a warning
12088 or an error occurs.  The most verbose level of warnings is @option{-ww}.
12090 @DefreqList {warn, [@Var{flags}]}
12091 @DefregListEnd {.warn}
12092 @cindex level of warnings (@code{warn})
12093 @cindex warnings, level (@code{warn})
12094 Control the level of warnings checked for.  The @var{flags} are the sum
12095 of the numbers associated with each warning that is to be enabled; all
12096 other warnings are disabled.  The number associated with each warning is
12097 listed below.  For example, @w{@code{.warn 0}} disables all warnings,
12098 and @w{@code{.warn 1}} disables all warnings except that about missing
12099 glyphs.  If no argument is given, all warnings are enabled.
12101 The read-only number register @code{.warn} contains the current warning
12102 level.
12103 @endDefreq
12105 @menu
12106 * Warnings::
12107 @end menu
12109 @c ---------------------------------------------------------------------
12111 @node Warnings,  , Debugging, Debugging
12112 @subsection Warnings
12113 @cindex warnings
12115 The warnings that can be given to @code{gtroff} are divided into the
12116 following categories.  The name associated with each warning is used by
12117 the @option{-w} and @option{-W} options; the number is used by the
12118 @code{warn} request and by the @code{.warn} register.
12120 @table @samp
12121 @item char
12122 @itemx 1
12123 Non-existent glyphs.@footnote{@code{char} is a misnomer since it reports
12124 missing glyphs -- there aren't missing input characters, only invalid
12125 ones.}  This is enabled by default.
12127 @item number
12128 @itemx 2
12129 Invalid numeric expressions.  This is enabled by default.
12130 @xref{Expressions}.
12132 @item break
12133 @itemx 4
12134 @cindex fill mode
12135 @cindex mode, fill
12136 In fill mode, lines which could not be broken so that their length was
12137 less than the line length.  This is enabled by default.
12139 @item delim
12140 @itemx 8
12141 Missing or mismatched closing delimiters.
12143 @item el
12144 @itemx 16
12145 @cindex @code{ie} request, and warnings
12146 @cindex @code{el} request, and warnings
12147 Use of the @code{el} request with no matching @code{ie} request.
12148 @xref{if-else}.
12150 @item scale
12151 @itemx 32
12152 Meaningless scaling indicators.
12154 @item range
12155 @itemx 64
12156 Out of range arguments.
12158 @item syntax
12159 @itemx 128
12160 Dubious syntax in numeric expressions.
12162 @item di
12163 @itemx 256
12164 @cindex @code{di} request, and warnings
12165 @cindex @code{da} request, and warnings
12166 Use of @code{di} or @code{da} without an argument when there is no
12167 current diversion.
12169 @item mac
12170 @itemx 512
12171 @cindex @code{de}, @code{de1}, @code{dei} requests, and warnings
12172 @cindex @code{am}, @code{am1}, @code{ami} requests, and warnings
12173 @cindex @code{ds}, @code{ds1} requests, and warnings
12174 @cindex @code{as}, @code{as1} requests, and warnings
12175 @cindex @code{di} request, and warnings
12176 @cindex @code{da} request, and warnings
12177 @cindex @code{box}, @code{boxa} requests, and warnings
12178 @cindex @code{\*}, and warnings
12179 Use of undefined strings, macros and diversions.  When an undefined
12180 string, macro, or diversion is used, that string is automatically
12181 defined as empty.  So, in most cases, at most one warning is given
12182 for each name.
12184 @item reg
12185 @itemx 1024
12186 @cindex @code{nr} request, and warnings
12187 @cindex @code{\R}, and warnings
12188 @cindex @code{\n}, and warnings
12189 Use of undefined number registers.  When an undefined number register is
12190 used, that register is automatically defined to have a value of@w{ }0.
12191 So, in most cases, at most one warning is given for use of a particular
12192 name.
12194 @item tab
12195 @itemx 2048
12196 @cindex @code{\t}, and warnings
12197 Use of a tab character where a number was expected.
12199 @item right-brace
12200 @itemx 4096
12201 @cindex @code{\@}}, and warnings
12202 Use of @code{\@}} where a number was expected.
12204 @item missing
12205 @itemx 8192
12206 Requests that are missing non-optional arguments.
12208 @item input
12209 @itemx 16384
12210 Invalid input characters.
12212 @item escape
12213 @itemx 32768
12214 Unrecognized escape sequences.  When an unrecognized escape sequence
12215 @code{\@var{X}} is encountered, the escape character is ignored, and
12216 @var{X} is printed.
12218 @item space
12219 @itemx 65536
12220 @cindex compatibility mode
12221 Missing space between a request or macro and its argument.  This warning
12222 is given when an undefined name longer than two characters is
12223 encountered, and the first two characters of the name make a defined
12224 name.  The request or macro is not invoked.  When this warning is
12225 given, no macro is automatically defined.  This is enabled by default.
12226 This warning never occurs in compatibility mode.
12228 @item font
12229 @itemx 131072
12230 Non-existent fonts.  This is enabled by default.
12232 @item ig
12233 @itemx 262144
12234 Invalid escapes in text ignored with the @code{ig} request.  These are
12235 conditions that are errors when they do not occur in ignored text.
12237 @item color
12238 @itemx 524288
12239 Color related warnings.
12241 @item all
12242 All warnings except @samp{di}, @samp{mac} and @samp{reg}.  It is
12243 intended that this covers all warnings that are useful with traditional
12244 macro packages.
12246 @item w
12247 All warnings.
12248 @end table
12251 @c =====================================================================
12253 @node Implementation Differences,  , Debugging, gtroff Reference
12254 @section Implementation Differences
12255 @cindex implementation differences
12256 @cindex differences in implementation
12257 @cindex incompatibilities with @acronym{AT&T} @code{troff}
12258 @cindex compatibility mode
12259 @cindex mode, compatibility
12261 GNU @code{troff} has a number of features which cause incompatibilities
12262 with documents written with old versions of @code{troff}.
12264 @cindex long names
12265 @cindex names, long
12266 Long names cause some incompatibilities.  @acronym{UNIX} @code{troff}
12267 interprets
12269 @Example
12270 .dsabcd
12271 @endExample
12273 @cindex @code{\*}, incompatibilities with @acronym{AT&T} @code{troff}
12274 @cindex @code{\n}, incompatibilities with @acronym{AT&T} @code{troff}
12275 @noindent
12276 as defining a string @samp{ab} with contents @samp{cd}.  Normally, GNU
12277 @code{troff} interprets this as a call of a macro named
12278 @code{dsabcd}.  Also @acronym{UNIX} @code{troff} interprets
12279 @code{\*[} or @code{\n[} as references to a string or number register
12280 called @samp{[}.  In GNU @code{troff}, however, this is normally
12281 interpreted as the start of a long name.  In compatibility mode GNU
12282 @code{troff} interprets long names in the traditional way
12283 (which means that they are not recognized as names).
12285 @DefreqList {cp, [@Var{n}]}
12286 @DefreqItem {do, cmd}
12287 @DefregListEnd {.C}
12288 If @var{n} is missing or non-zero, turn on compatibility mode;
12289 otherwise, turn it off.
12291 The number
12292 register @code{.C} is@w{ }1 if compatibility mode is on, 0@w{
12293 }otherwise.
12295 Compatibility mode can be turned on with the
12296 @option{-C} command line option.
12298 The @code{do} request turns off compatibility mode
12299 while executing its arguments as a @code{gtroff} command.
12301 @Example
12302 .do fam T
12303 @endExample
12305 @noindent
12306 executes the @code{fam} request when compatibility mode
12307 is enabled.
12309 @code{gtroff} restores the previous compatibility setting
12310 before interpreting any files sourced by the @var{cmd}.
12311 @endDefreq
12313 @cindex input level in delimited arguments
12314 @cindex delimited arguments, incompatibilities with @acronym{AT&T} @code{troff}
12315 Two other features are controlled by @option{-C}.  If not in
12316 compatibility mode, GNU @code{troff} preserves the input level in
12317 delimited arguments:
12319 @Example
12320 .ds xx '
12321 \w'abc\*(xxdef'
12322 @endExample
12324 @noindent
12325 In compatibility mode, the string @samp{72def'} is returned; without
12326 @option{-C} the resulting string is @samp{168} (assuming a TTY output
12327 device).
12329 @cindex @code{\f}, incompatibilities with @acronym{AT&T} @code{troff}
12330 @cindex @code{\H}, incompatibilities with @acronym{AT&T} @code{troff}
12331 @cindex @code{\R}, incompatibilities with @acronym{AT&T} @code{troff}
12332 @cindex @code{\s}, incompatibilities with @acronym{AT&T} @code{troff}
12333 @cindex @code{\S}, incompatibilities with @acronym{AT&T} @code{troff}
12334 Finally, the escapes @code{\f}, @code{\H}, @code{\R}, @code{\s}, and
12335 @code{\S} are transparent for recognizing the beginning of a line only
12336 in compatibility mode (this is a rather obscure feature).  For example,
12337 the code
12339 @Example
12340 .de xx
12341 Hallo!
12343 \fB.xx\fP
12344 @endExample
12346 prints @samp{Hallo!} in bold face if in compatibility mode, and
12347 @samp{.xx} in bold face otherwise.
12349 @cindex @code{\A}, incompatibilities with @acronym{AT&T} @code{troff}
12350 @cindex @code{\|}, incompatibilities with @acronym{AT&T} @code{troff}
12351 @cindex @code{\^}, incompatibilities with @acronym{AT&T} @code{troff}
12352 @cindex @code{\&}, incompatibilities with @acronym{AT&T} @code{troff}
12353 @cindex @code{\@{}, incompatibilities with @acronym{AT&T} @code{troff}
12354 @cindex @code{\@}}, incompatibilities with @acronym{AT&T} @code{troff}
12355 @cindex @code{\@key{SP}}, incompatibilities with @acronym{AT&T} @code{troff}
12356 @cindex @code{\'}, incompatibilities with @acronym{AT&T} @code{troff}
12357 @cindex @code{\`}, incompatibilities with @acronym{AT&T} @code{troff}
12358 @cindex @code{\-}, incompatibilities with @acronym{AT&T} @code{troff}
12359 @cindex @code{\_}, incompatibilities with @acronym{AT&T} @code{troff}
12360 @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
12361 @cindex @code{\%}, incompatibilities with @acronym{AT&T} @code{troff}
12362 @cindex @code{\c}, incompatibilities with @acronym{AT&T} @code{troff}
12363 GNU @code{troff} does not allow the use of the escape sequences
12364 @code{\|}, @code{\^}, @code{\&}, @code{\@{}, @code{\@}},
12365 @code{\@key{SP}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
12366 @code{\%}, and @code{\c} in names of strings, macros, diversions, number
12367 registers, fonts or environments; @acronym{UNIX} @code{troff} does.  The
12368 @code{\A} escape sequence (@pxref{Identifiers}) may be helpful in
12369 avoiding use of these escape sequences in names.
12371 @cindex fractional point sizes
12372 @cindex fractional type sizes
12373 @cindex point sizes, fractional
12374 @cindex type sizes, fractional
12375 @cindex sizes, fractional
12376 @cindex @code{ps} request, incompatibilities with @acronym{AT&T} @code{troff}
12377 Fractional point sizes cause one noteworthy incompatibility.  In
12378 @acronym{UNIX} @code{troff} the @code{ps} request ignores scale
12379 indicators and thus
12381 @Example
12382 .ps 10u
12383 @endExample
12385 @noindent
12386 sets the point size to 10@w{ }points, whereas in GNU @code{troff} it
12387 sets the point size to 10@w{ }scaled points.  @xref{Fractional Type
12388 Sizes}, for more information.
12390 @cindex @code{bd} request, incompatibilities with @acronym{AT&T} @code{troff}
12391 @cindex @code{cs} request, incompatibilities with @acronym{AT&T} @code{troff}
12392 @cindex @code{tr} request, incompatibilities with @acronym{AT&T} @code{troff}
12393 @cindex @code{fp} request, incompatibilities with @acronym{AT&T} @code{troff}
12394 @cindex input characters and output glyphs, compatibility with @acronym{AT&T} @code{troff}
12395 @cindex output glyphs, and input characters,compatibility with @acronym{AT&T} @code{troff}
12396 @cindex characters, input, and output glyphs, compatibility with @acronym{AT&T} @code{troff}
12397 @cindex glyphs, output, and input characters, compatibility with @acronym{AT&T} @code{troff}
12398 In GNU @code{troff} there is a fundamental difference between
12399 (unformatted) input characters and (formatted) output glyphs.
12400 Everything that affects how a glyph is output is stored
12401 with the glyph node; once a glyph node has been constructed it is
12402 unaffected by any subsequent requests that are executed, including
12403 @code{bd}, @code{cs}, @code{tkf}, @code{tr}, or @code{fp} requests.
12404 Normally glyphs are constructed from input characters at the
12405 moment immediately before the glyph is added to the current output
12406 line.  Macros, diversions and strings are all, in fact, the same type of
12407 object; they contain lists of input characters and glyph nodes in
12408 any combination.  A glyph node does not behave like an input
12409 character for the purposes of macro processing; it does not inherit any
12410 of the special properties that the input character from which it was
12411 constructed might have had.  For example,
12413 @Example
12414 .di x
12415 \\\\
12419 @endExample
12421 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
12422 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
12423 @cindex @code{\e}, incompatibilities with @acronym{AT&T} @code{troff}
12424 @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
12425 @cindex @code{\?}, incompatibilities with @acronym{AT&T} @code{troff}
12426 @cindex transparent output, incompatibilities with @acronym{AT&T} @code{troff}
12427 @cindex output, transparent, incompatibilities with @acronym{AT&T} @code{troff}
12428 @noindent
12429 prints @samp{\\} in GNU @code{troff}; each pair of input backslashes
12430 is turned into one output backslash and the resulting output backslashes
12431 are not interpreted as escape characters when they are reread.
12432 @acronym{UNIX} @code{troff} would interpret them as escape characters
12433 when they were reread and would end up printing one @samp{\}.  The
12434 correct way to obtain a printable backslash is to use the @code{\e}
12435 escape sequence: This always prints a single instance of the current
12436 escape character, regardless of whether or not it is used in a
12437 diversion; it also works in both GNU @code{troff} and @acronym{UNIX}
12438 @code{troff}.@footnote{To be completely independent of the current
12439 escape character, use @code{\(rs} which represents a reverse solidus
12440 (backslash) glyph.}  To store, for some reason, an escape sequence in a
12441 diversion that will be interpreted when the diversion is reread, either
12442 use the traditional @code{\!} transparent output facility, or, if this
12443 is unsuitable, the new @code{\?} escape sequence.
12445 @xref{Diversions}, and @ref{Gtroff Internals}, for more information.
12449 @c =====================================================================
12450 @c =====================================================================
12452 @node Preprocessors, Output Devices, gtroff Reference, Top
12453 @chapter Preprocessors
12454 @cindex preprocessors
12456 This chapter describes all preprocessors that come with @code{groff} or
12457 which are freely available.
12459 @menu
12460 * geqn::
12461 * gtbl::
12462 * gpic::
12463 * ggrn::
12464 * grap::
12465 * grefer::
12466 * gsoelim::
12467 @end menu
12470 @c =====================================================================
12472 @node geqn, gtbl, Preprocessors, Preprocessors
12473 @section @code{geqn}
12474 @cindex @code{eqn}, the program
12475 @cindex @code{geqn}, the program
12477 @c XXX
12479 @menu
12480 * Invoking geqn::
12481 @end menu
12483 @c ---------------------------------------------------------------------
12485 @node Invoking geqn,  , geqn, geqn
12486 @subsection Invoking @code{geqn}
12487 @cindex invoking @code{geqn}
12488 @cindex @code{geqn}, invoking
12490 @c XXX
12493 @c =====================================================================
12495 @node gtbl, gpic, geqn, Preprocessors
12496 @section @code{gtbl}
12497 @cindex @code{tbl}, the program
12498 @cindex @code{gtbl}, the program
12500 @c XXX
12502 @menu
12503 * Invoking gtbl::
12504 @end menu
12506 @c ---------------------------------------------------------------------
12508 @node Invoking gtbl,  , gtbl, gtbl
12509 @subsection Invoking @code{gtbl}
12510 @cindex invoking @code{gtbl}
12511 @cindex @code{gtbl}, invoking
12513 @c XXX
12516 @c =====================================================================
12518 @node gpic, ggrn, gtbl, Preprocessors
12519 @section @code{gpic}
12520 @cindex @code{pic}, the program
12521 @cindex @code{gpic}, the program
12523 @c XXX
12525 @menu
12526 * Invoking gpic::
12527 @end menu
12529 @c ---------------------------------------------------------------------
12531 @node Invoking gpic,  , gpic, gpic
12532 @subsection Invoking @code{gpic}
12533 @cindex invoking @code{gpic}
12534 @cindex @code{gpic}, invoking
12536 @c XXX
12539 @c =====================================================================
12541 @node ggrn, grap, gpic, Preprocessors
12542 @section @code{ggrn}
12543 @cindex @code{grn}, the program
12544 @cindex @code{ggrn}, the program
12546 @c XXX
12548 @menu
12549 * Invoking ggrn::
12550 @end menu
12552 @c ---------------------------------------------------------------------
12554 @node Invoking ggrn,  , ggrn, ggrn
12555 @subsection Invoking @code{ggrn}
12556 @cindex invoking @code{ggrn}
12557 @cindex @code{ggrn}, invoking
12559 @c XXX
12562 @c =====================================================================
12564 @node grap, grefer, ggrn, Preprocessors
12565 @section @code{grap}
12566 @cindex @code{grap}, the program
12568 A free implementation of @code{grap}, written by Ted Faber,
12569 is available as an extra package from the following address:
12571 @display
12572 @url{http://www.lunabase.org/~faber/Vault/software/grap/}
12573 @end display
12576 @c =====================================================================
12578 @node grefer, gsoelim, grap, Preprocessors
12579 @section @code{grefer}
12580 @cindex @code{refer}, the program
12581 @cindex @code{grefer}, the program
12583 @c XXX
12585 @menu
12586 * Invoking grefer::
12587 @end menu
12589 @c ---------------------------------------------------------------------
12591 @node Invoking grefer,  , grefer, grefer
12592 @subsection Invoking @code{grefer}
12593 @cindex invoking @code{grefer}
12594 @cindex @code{grefer}, invoking
12596 @c XXX
12599 @c =====================================================================
12601 @node gsoelim,  , grefer, Preprocessors
12602 @section @code{gsoelim}
12603 @cindex @code{soelim}, the program
12604 @cindex @code{gsoelim}, the program
12606 @c XXX
12608 @menu
12609 * Invoking gsoelim::
12610 @end menu
12612 @c ---------------------------------------------------------------------
12614 @node Invoking gsoelim,  , gsoelim, gsoelim
12615 @subsection Invoking @code{gsoelim}
12616 @cindex invoking @code{gsoelim}
12617 @cindex @code{gsoelim}, invoking
12619 @c XXX
12623 @c =====================================================================
12624 @c =====================================================================
12626 @node Output Devices, File formats, Preprocessors, Top
12627 @chapter Output Devices
12628 @cindex output devices
12629 @cindex devices for output
12631 @c XXX
12633 @menu
12634 * Special Characters::
12635 * grotty::
12636 * grops::
12637 * grodvi::
12638 * grolj4::
12639 * grolbp::
12640 * grohtml::
12641 * gxditview::
12642 @end menu
12645 @c =====================================================================
12647 @node Special Characters, grotty, Output Devices, Output Devices
12648 @section Special Characters
12649 @cindex special characters
12650 @cindex characters, special
12652 @c XXX
12654 @xref{Font Files}.
12657 @c =====================================================================
12659 @node grotty, grops, Special Characters, Output Devices
12660 @section @code{grotty}
12661 @cindex @code{grotty}, the program
12663 @c XXX
12665 @menu
12666 * Invoking grotty::
12667 @end menu
12669 @c ---------------------------------------------------------------------
12671 @node Invoking grotty,  , grotty, grotty
12672 @subsection Invoking @code{grotty}
12673 @cindex invoking @code{grotty}
12674 @cindex @code{grotty}, invoking
12676 @c XXX
12678 @c The following is no longer true; fix and extend it.
12680 @c @pindex less
12681 @c @cindex Teletype
12682 @c @cindex ISO 6249 SGR
12683 @c @cindex terminal control sequences
12684 @c @cindex control sequences, for terminals
12685 @c For TTY output devices, underlining is done by emitting sequences of
12686 @c @samp{_} and @samp{\b} (the backspace character) before the actual
12687 @c character.  Literally, this is printing an underline character, then
12688 @c moving back one character position, and printing the actual character
12689 @c at the same position as the underline character (similar to a
12690 @c typewriter).  Usually, a modern terminal can't interpret this (and the
12691 @c original Teletype machines for which this sequence was appropriate are
12692 @c no longer in use).  You need a pager program like @code{less} which
12693 @c translates this into ISO 6429 SGR sequences to control terminals.
12696 @c =====================================================================
12698 @node grops, grodvi, grotty, Output Devices
12699 @section @code{grops}
12700 @cindex @code{grops}, the program
12702 @c XXX
12704 @menu
12705 * Invoking grops::
12706 * Embedding PostScript::
12707 @end menu
12709 @c ---------------------------------------------------------------------
12711 @node Invoking grops, Embedding PostScript, grops, grops
12712 @subsection Invoking @code{grops}
12713 @cindex invoking @code{grops}
12714 @cindex @code{grops}, invoking
12716 @c XXX
12718 @c ---------------------------------------------------------------------
12720 @node Embedding PostScript,  , Invoking grops, grops
12721 @subsection Embedding @sc{PostScript}
12722 @cindex embedding PostScript
12723 @cindex PostScript, embedding
12725 @c XXX
12728 @c =====================================================================
12730 @node grodvi, grolj4, grops, Output Devices
12731 @section @code{grodvi}
12732 @cindex @code{grodvi}, the program
12734 @c XXX
12736 @menu
12737 * Invoking grodvi::
12738 @end menu
12740 @c ---------------------------------------------------------------------
12742 @node Invoking grodvi,  , grodvi, grodvi
12743 @subsection Invoking @code{grodvi}
12744 @cindex invoking @code{grodvi}
12745 @cindex @code{grodvi}, invoking
12747 @c XXX
12750 @c =====================================================================
12752 @node grolj4, grolbp, grodvi, Output Devices
12753 @section @code{grolj4}
12754 @cindex @code{grolj4}, the program
12756 @c XXX
12758 @menu
12759 * Invoking grolj4::
12760 @end menu
12762 @c ---------------------------------------------------------------------
12764 @node Invoking grolj4,  , grolj4, grolj4
12765 @subsection Invoking @code{grolj4}
12766 @cindex invoking @code{grolj4}
12767 @cindex @code{grolj4}, invoking
12769 @c XXX
12772 @c =====================================================================
12774 @node grolbp, grohtml, grolj4, Output Devices
12775 @section @code{grolbp}
12776 @cindex @code{grolbp}, the program
12778 @c XXX
12780 @menu
12781 * Invoking grolbp::
12782 @end menu
12784 @c ---------------------------------------------------------------------
12786 @node Invoking grolbp,  , grolbp, grolbp
12787 @subsection Invoking @code{grolbp}
12788 @cindex invoking @code{grolbp}
12789 @cindex @code{grolbp}, invoking
12791 @c XXX
12794 @c =====================================================================
12796 @node grohtml, gxditview, grolbp, Output Devices
12797 @section @code{grohtml}
12798 @cindex @code{grohtml}, the program
12800 @c XXX
12802 @menu
12803 * Invoking grohtml::
12804 * grohtml specific registers and strings::
12805 @end menu
12807 @c ---------------------------------------------------------------------
12809 @node Invoking grohtml, grohtml specific registers and strings, grohtml, grohtml
12810 @subsection Invoking @code{grohtml}
12811 @cindex invoking @code{grohtml}
12812 @cindex @code{grohtml}, invoking
12814 @c XXX
12816 @c ---------------------------------------------------------------------
12818 @node grohtml specific registers and strings,  , Invoking grohtml, grohtml
12819 @subsection @code{grohtml} specific registers and strings
12820 @cindex registers specific to @code{grohtml}
12821 @cindex strings specific to @code{grohtml}
12822 @cindex @code{grohtml}, registers and strings
12824 @DefmpregList {ps4html, grohtml}
12825 @DefstrListEnd {www-image-template, grohtml}
12826 The registers @code{ps4html} and @code{www-image-template} are defined
12827 by the @code{pre-grohtml} preprocessor.  @code{pre-grohtml} reads in
12828 the @code{troff} input, marks up the inline equations and passes the
12829 result firstly to
12831 @Example
12832 troff -Tps -rps4html=1 -dwww-image-template=@var{template}
12833 @endExample
12835 @noindent
12836 and secondly to
12838 @Example
12839 troff -Thtml
12840 @endExample
12842 The PostScript device is used to create all the image files, and the
12843 register @code{ps4html} enables the macro sets to ignore floating
12844 keeps, footers, and headings.
12846 The register @code{www-image-template} is set to the user specified
12847 template name or the default name.
12848 @endDefmpreg
12851 @c =====================================================================
12853 @node gxditview,  , grohtml, Output Devices
12854 @section @code{gxditview}
12855 @cindex @code{gxditview}, the program
12857 @c XXX
12859 @menu
12860 * Invoking gxditview::
12861 @end menu
12863 @c ---------------------------------------------------------------------
12865 @node Invoking gxditview,  , gxditview, gxditview
12866 @subsection Invoking @code{gxditview}
12867 @cindex invoking @code{gxditview}
12868 @cindex @code{gxditview}, invoking
12870 @c XXX
12871 @c X11's xditview
12875 @c =====================================================================
12876 @c =====================================================================
12878 @node File formats, Installation, Output Devices, Top
12879 @chapter File formats
12880 @cindex file formats
12881 @cindex formats, file
12883 All files read and written by @code{gtroff} are text files.  The
12884 following two sections describe their format.
12886 @menu
12887 * gtroff Output::
12888 * Font Files::
12889 @end menu
12892 @c =====================================================================
12894 @node gtroff Output, Font Files, File formats, File formats
12895 @section @code{gtroff} Output
12896 @cindex @code{gtroff}, output
12897 @cindex output, @code{gtroff}
12899 This section describes the intermediate output format of GNU
12900 @code{troff}.  This output is produced by a run of @code{gtroff}
12901 before it is fed into a device postprocessor program.
12903 As @code{groff} is a wrapper program around @code{gtroff} that
12904 automatically calls a postprocessor, this output does not show up
12905 normally.  This is why it is called @dfn{intermediate}.
12906 @code{groff} provides the option @option{-Z} to inhibit postprocessing,
12907 such that the produced intermediate output is sent to standard output
12908 just like calling @code{gtroff} manually.
12910 @cindex troff output
12911 @cindex output, troff
12912 @cindex intermediate output
12913 @cindex output, intermediate
12914 Here, the term @dfn{troff output} describes what is output by
12915 @code{gtroff}, while @dfn{intermediate output} refers to the language
12916 that is accepted by the parser that prepares this output for the
12917 postprocessors.  This parser is smarter on whitespace and implements
12918 obsolete elements for compatibility, otherwise both formats are the
12919 same.@footnote{The parser and postprocessor for intermediate output
12920 can be found in the file@*
12921 @file{@var{groff-source-dir}/src/libs/libdriver/input.cc}.}
12923 The main purpose of the intermediate output concept is to facilitate
12924 the development of postprocessors by providing a common programming
12925 interface for all devices.  It has a language of its own that is
12926 completely different from the @code{gtroff} language.  While the
12927 @code{gtroff} language is a high-level programming language for text
12928 processing, the intermediate output language is a kind of low-level
12929 assembler language by specifying all positions on the page for writing
12930 and drawing.
12932 The intermediate output produced by @code{gtroff} is fairly readable,
12933 while output from @acronym{AT&T} @code{troff} is rather hard to
12934 understand because of strange habits that are still supported, but not
12935 used any longer by @code{gtroff}.
12937 @menu
12938 * Language Concepts::
12939 * Command Reference::
12940 * Intermediate Output Examples::
12941 * Output Language Compatibility::
12942 @end menu
12944 @c ---------------------------------------------------------------------
12946 @node Language Concepts, Command Reference, gtroff Output, gtroff Output
12947 @subsection Language Concepts
12949 During the run of @code{gtroff}, the input data is cracked down to the
12950 information on what has to be printed at what position on the intended
12951 device.  So the language of the intermediate output format can be quite
12952 small.  Its only elements are commands with and without arguments.
12953 In this section, the term @dfn{command} always refers to the intermediate
12954 output language, and never to the @code{gtroff} language used for document
12955 formatting.  There are commands for positioning and text writing, for drawing, and
12956 for device controlling.
12958 @menu
12959 * Separation::
12960 * Argument Units::
12961 * Document Parts::
12962 @end menu
12964 @node Separation, Argument Units, Language Concepts, Language Concepts
12965 @subsubsection Separation
12967 @acronym{AT&T} @code{troff} output has strange requirements on whitespace.
12968 The @code{gtroff} output parser, however, is smart about whitespace by
12969 making it maximally optional.  The whitespace characters, i.e., the
12970 tab, space, and newline characters, always have a syntactical meaning.
12971 They are never printable because spacing within the output is always
12972 done by positioning commands.
12974 Any sequence of space or tab characters is treated as a single
12975 @dfn{syntactical space}.  It separates commands and arguments, but is
12976 only required when there would occur a clashing between the command code
12977 and the arguments without the space.  Most often, this happens when
12978 variable-length command names, arguments, argument lists, or command
12979 clusters meet.  Commands and arguments with a known, fixed length need
12980 not be separated by syntactical space.
12982 A line break is a syntactical element, too.  Every command argument can be
12983 followed by whitespace, a comment, or a newline character.  Thus a
12984 @dfn{syntactical line break} is defined to consist of optional
12985 syntactical space that is optionally followed by a comment, and a
12986 newline character.
12988 The normal commands, those for positioning and text, consist of a
12989 single letter taking a fixed number of arguments.  For historical reasons,
12990 the parser allows to stack such commands on the same line, but
12991 fortunately, in @code{gtroff}'s intermediate output, every command with
12992 at least one argument is followed by a line break, thus providing
12993 excellent readability.
12995 The other commands -- those for drawing and device controlling --
12996 have a more complicated structure; some recognize long command names,
12997 and some take a variable number of arguments.  So all @samp{D} and
12998 @samp{x} commands were designed to request a syntactical line break
12999 after their last argument.  Only one command, @w{@samp{x X}},
13000 has an argument that can stretch over several lines; all other
13001 commands must have all of their arguments on the same line as the
13002 command, i.e., the arguments may not be splitted by a line break.
13004 Empty lines (these are lines containing only space and/or a comment), can
13005 occur everywhere.  They are just ignored.
13007 @node Argument Units, Document Parts, Separation, Language Concepts
13008 @subsubsection Argument Units
13010 Some commands take integer arguments that are assumed to represent
13011 values in a measurement unit, but the letter for the corresponding
13012 scale indicator is not written with the output command arguments.
13013 Most commands assume the scale indicator @samp{u}, the basic unit of
13014 the device, some use @samp{z}, the scaled point unit of the device,
13015 while others, such as the color commands, expect plain integers.
13017 Note that single characters can have the eighth bit set, as can the
13018 names of fonts and special characters.  The names of characters and
13019 fonts can be of arbitrary length.  A character that is to be printed
13020 will always be in the current font.
13022 A string argument is always terminated by the next whitespace
13023 character (space, tab, or newline); an embedded @samp{#} character is
13024 regarded as part of the argument, not as the beginning of a comment
13025 command.  An integer argument is already terminated by the next
13026 non-digit character, which then is regarded as the first character of
13027 the next argument or command.
13029 @node Document Parts,  , Argument Units, Language Concepts
13030 @subsubsection Document Parts
13032 A correct intermediate output document consists of two parts, the
13033 @dfn{prologue} and the @dfn{body}.
13035 The task of the prologue is to set the general device parameters
13036 using three exactly specified commands.  @code{gtroff}'s prologue
13037 is guaranteed to consist of the following three lines (in that order):
13039 @Example
13040 x T @var{device}
13041 x res @var{n} @var{h} @var{v}
13042 x init
13043 @endExample
13045 @noindent
13046 with the arguments set as outlined in @ref{Device Control Commands}.
13047 Note that the parser for the intermediate output format is able to
13048 swallow additional whitespace and comments as well even in the
13049 prologue.
13051 The body is the main section for processing the document data.
13052 Syntactically, it is a sequence of any commands different from the
13053 ones used in the prologue.  Processing is terminated as soon as the
13054 first @w{@samp{x stop}} command is encountered; the last line of any
13055 @code{gtroff} intermediate output always contains such a command.
13057 Semantically, the body is page oriented.  A new page is started by a
13058 @samp{p} command.  Positioning, writing, and drawing commands are
13059 always done within the current page, so they cannot occur before the
13060 first @samp{p} command.  Absolute positioning (by the @samp{H} and
13061 @samp{V} commands) is done relative to the current page; all other
13062 positioning is done relative to the current location within this page.
13064 @c ---------------------------------------------------------------------
13066 @node Command Reference, Intermediate Output Examples, Language Concepts, gtroff Output
13067 @subsection Command Reference
13069 This section describes all intermediate output commands, both from
13070 @acronym{AT&T} @code{troff} as well as the @code{gtroff} extensions.
13072 @menu
13073 * Comment Command::
13074 * Simple Commands::
13075 * Graphics Commands::
13076 * Device Control Commands::
13077 * Obsolete Command::
13078 @end menu
13080 @node Comment Command, Simple Commands, Command Reference, Command Reference
13081 @subsubsection Comment Command
13083 @table @code
13084 @item #@var{anything}@angles{end of line}
13085 A comment.  Ignore any characters from the @samp{#} character up to
13086 the next newline character.
13088 This command is the only possibility for commenting in the intermediate
13089 output.  Each comment can be preceded by arbitrary syntactical space;
13090 every command can be terminated by a comment.
13091 @end table
13093 @node Simple Commands, Graphics Commands, Comment Command, Command Reference
13094 @subsubsection Simple Commands
13096 The commands in this subsection have a command code consisting of a
13097 single character, taking a fixed number of arguments.  Most of them
13098 are commands for positioning and text writing.  These commands are
13099 smart about whitespace.  Optionally, syntactical space can be inserted
13100 before, after, and between the command letter and its arguments.
13101 All of these commands are stackable, i.e., they can be preceded by
13102 other simple commands or followed by arbitrary other commands on the
13103 same line.  A separating syntactical space is only necessary when two
13104 integer arguments would clash or if the preceding argument ends with a
13105 string argument.
13107 @table @code
13108 @ignore
13109 .if (\n[@USE_ENV_STACK] == 1) \{\
13110 .command {
13111 Open a new environment by copying the actual device configuration data
13112 to the environment stack.
13114 The current environment is setup by the device specification and
13115 manipulated by the setting commands.
13118 .command }
13119 Close the actual environment (opened by a preceding
13120 .BR { \~command)
13121 and restore the previous environment from the environment
13122 stack as the actual device configuration data.
13124 \}              \" endif @USE_ENV_STACK
13125 @end ignore
13127 @item C @var{xxx}@angles{whitespace}
13128 Print a special character named @var{xxx}.  The trailing
13129 syntactical space or line break is necessary to allow glyph names
13130 of arbitrary length.  The glyph is printed at the current print
13131 position; the glyph's size is read from the font file.  The print
13132 position is not changed.
13134 @item c @var{g}
13135 Print glyph@w{ }@var{g} at the current print position;@footnote{@samp{c}
13136 is actually a misnomer since it outputs a glyph.} the glyph's size is
13137 read from the font file.  The print position is not changed.
13139 @item f @var{n}
13140 Set font to font number@w{ }@var{n} (a non-negative integer).
13142 @item H @var{n}
13143 Move right to the absolute vertical position@w{ }@var{n} (a
13144 non-negative integer in basic units @samp{u} relative to left edge
13145 of current page.
13147 @item h @var{n}
13148 Move @var{n} (a non-negative integer) basic units @samp{u} horizontally
13149 to the right.  The original @acronym{UNIX} troff manual allows negative
13150 values for @var{n} also, but @code{gtroff} doesn't use this.
13152 @item m @var{color-scheme} @r{[}@var{component} @dots{}@r{]}
13153 Set the color for text (glyphs), line drawing, and the outline of
13154 graphic objects using different color schemes; the analoguous command
13155 for the filling color of graphic objects is @samp{DF}.  The color
13156 components are specified as integer arguments between 0 and 65536.
13157 The number of color components and their meaning vary for the
13158 different color schemes.  These commands are generated by
13159 @code{gtroff}'s escape sequence @code{\m}.  No position changing.
13160 These commands are a @code{gtroff} extension.
13162 @table @code
13163 @item mc @var{cyan} @var{magenta} @var{yellow}
13164 Set color using the CMY color scheme, having the 3@w{ }color components
13165 @var{cyan}, @var{magenta}, and @var{yellow}.
13167 @item md
13168 Set color to the default color value (black in most cases).
13169 No component arguments.
13171 @item mg @var{gray}
13172 Set color to the shade of gray given by the argument, an integer
13173 between 0 (black) and 65536 (white).
13175 @item mk @var{cyan} @var{magenta} @var{yellow} @var{black}
13176 Set color using the CMYK color scheme, having the 4@w{ }color components
13177 @var{cyan}, @var{magenta}, @var{yellow}, and @var{black}.
13179 @item mr @var{red} @var{green} @var{blue}
13180 Set color using the RGB color scheme, having the 3@w{ }color components
13181 @var{red}, @var{green}, and @var{blue}.
13183 @end table
13185 @item N @var{n}
13186 Print glyph with index@w{ }@var{n} (a non-negative integer) of the
13187 current font.  This command is a @code{gtroff} extension.
13189 @item n @var{b} @var{a}
13190 Inform the device about a line break, but no positioning is done by
13191 this command.  In @acronym{AT&T} @code{troff}, the integer arguments
13192 @var{b} and@w{ }@var{a} informed about the space before and after the
13193 current line to make the intermediate output more human readable
13194 without performing any action.  In groff, they are just ignored, but
13195 they must be provided for compatibility reasons.
13197 @item p @var{n}
13198 Begin a new page in the outprint.  The page number is set
13199 to@w{ }@var{n}.  This page is completely independent of pages formerly
13200 processed even if those have the same page number.  The vertical
13201 position on the outprint is automatically set to@w{ }0.  All
13202 positioning, writing, and drawing is always done relative to a page,
13203 so a @samp{p} command must be issued before any of these commands.
13205 @item s @var{n}
13206 Set point size to @var{n}@w{ }scaled points (this is unit @samp{z}).
13207 @acronym{AT&T} @code{troff} used the unit points (@samp{p}) instead.
13208 @xref{Output Language Compatibility}.
13210 @item t @var{xxx}@angles{whitespace}
13211 @itemx t @var{xxx} @var{dummy-arg}@angles{whitespace}
13212 Print a word, i.e., a sequence of characters @var{xxx} representing
13213 output glyphs which names are single characters, terminated by
13214 a space character or a line break; an optional second integer argument
13215 is ignored (this allows the formatter to generate an even number of
13216 arguments).  The first glyph should be printed at the current
13217 position, the current horizontal position should then be increased by
13218 the width of the first glyph, and so on for each glyph.
13219 The widths of the glyphs are read from the font file, scaled for the
13220 current point size, and rounded to a multiple of the horizontal
13221 resolution.  Special characters cannot be printed using this command
13222 (use the @samp{C} command for special characters).  This command is a
13223 @code{gtroff} extension; it is only used for devices whose @file{DESC}
13224 file contains the @code{tcommand} keyword (@pxref{DESC File Format}).
13226 @item u @var{n} @var{xxx}@angles{whitespace}
13227 Print word with track kerning.  This is the same as the @samp{t}
13228 command except that after printing each glyph, the current
13229 horizontal position is increased by the sum of the width of that
13230 glyph and@w{ }@var{n} (an integer in basic units @samp{u}).
13231 This command is a @code{gtroff} extension; it is only used for devices
13232 whose @file{DESC} file contains the @code{tcommand} keyword
13233 (@pxref{DESC File Format}).
13235 @item V @var{n}
13236 Move down to the absolute vertical position@w{ }@var{n} (a
13237 non-negative integer in basic units @samp{u}) relative to upper edge
13238 of current page.
13240 @item v @var{n}
13241 Move @var{n}@w{ }basic units @samp{u} down (@var{n} is a non-negative
13242 integer).  The original @acronym{UNIX} troff manual allows negative
13243 values for @var{n} also, but @code{gtroff} doesn't use this.
13245 @item w
13246 Informs about a paddable white space to increase readability.
13247 The spacing itself must be performed explicitly by a move command.
13249 @end table
13251 @node Graphics Commands, Device Control Commands, Simple Commands, Command Reference
13252 @subsubsection Graphics Commands
13254 Each graphics or drawing command in the intermediate output starts
13255 with the letter @samp{D}, followed by one or two characters that
13256 specify a subcommand; this is followed by a fixed or variable number
13257 of integer arguments that are separated by a single space character.
13258 A @samp{D} command may not be followed by another command on the same line
13259 (apart from a comment), so each @samp{D} command is terminated by a
13260 syntactical line break.
13262 @code{gtroff} output follows the classical spacing rules (no space
13263 between command and subcommand, all arguments are preceded by a
13264 single space character), but the parser allows optional space between
13265 the command letters and makes the space before the first argument
13266 optional.  As usual, each space can be any sequence of tab and space
13267 characters.
13269 Some graphics commands can take a variable number of arguments.
13270 In this case, they are integers representing a size measured in basic
13271 units @samp{u}.  The arguments called @var{h1}, @var{h2}, @dots{},
13272 @var{hn} stand for horizontal distances where positive means right,
13273 negative left.  The arguments called @var{v1}, @var{v2}, @dots{},
13274 @var{vn} stand for vertical distances where positive means down,
13275 negative up.  All these distances are offsets relative to the current
13276 location.
13278 Unless indicated otherwise, each graphics command directly corresponds
13279 to a similar @code{gtroff} @code{\D} escape sequence.  @xref{Drawing
13280 Requests}.
13282 Unknown @samp{D} commands are assumed to be device-specific.
13283 Its arguments are parsed as strings; the whole information is then
13284 sent to the postprocessor.
13286 In the following command reference, the syntax element
13287 @angles{line break} means a syntactical line break as defined above.
13289 @table @code
13290 @item D~ @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
13291 Draw B-spline from current position to offset (@var{h1},@var{v1}),
13292 then to offset (@var{h2},@var{v2}), if given, etc.@: up to
13293 (@var{hn},@var{vn}).  This command takes a variable number of argument
13294 pairs; the current position is moved to the terminal point of the drawn
13295 curve.
13297 @item Da @var{h1} @var{v1} @var{h2} @var{v2}@angles{line break}
13298 Draw arc from current position to
13299 (@var{h1},@var{v1})@math{+}(@var{h2},@var{v2}) with center at
13300 (@var{h1},@var{v1}); then move the current position to the final point
13301 of the arc.
13303 @item DC @var{d}@angles{line break}
13304 @itemx DC @var{d} @var{dummy-arg}@angles{line break}
13305 Draw a solid circle using the current fill color with
13306 diameter@w{ }@var{d} (integer in basic units @samp{u}) with leftmost
13307 point at the current position; then move the current position to the
13308 rightmost point of the circle.  An optional second integer argument is
13309 ignored (this allows the formatter to generate an even number of
13310 arguments).  This command is a @code{gtroff} extension.
13312 @item Dc @var{d}@angles{line break}
13313 Draw circle line with diameter@w{ }@var{d} (integer in basic units
13314 @samp{u}) with leftmost point at the current position; then move the
13315 current position to the rightmost point of the circle.
13317 @item DE @var{h} @var{v}@angles{line break}
13318 Draw a solid ellipse in the current fill color with a horizontal
13319 diameter of@w{ }@var{h} and a vertical diameter of@w{ }@var{v} (both
13320 integers in basic units @samp{u}) with the leftmost point at the
13321 current position; then move to the rightmost point of the ellipse.
13322 This command is a @code{gtroff} extension.
13324 @item De @var{h} @var{v}@angles{line break}
13325 Draw an outlined ellipse with a horizontal diameter of@w{ }@var{h}
13326 and a vertical diameter of@w{ }@var{v} (both integers in basic units
13327 @samp{u}) with the leftmost point at current position; then move to
13328 the rightmost point of the ellipse.
13330 @item DF @var{color-scheme} @r{[}@var{component} @dots{}@r{]}@angles{line break}
13331 Set fill color for solid drawing objects using different color
13332 schemes; the analoguous command for setting the color of text, line
13333 graphics, and the outline of graphic objects is @samp{m}.
13334 The color components are specified as integer arguments between 0 and
13335 65536.  The number of color components and their meaning vary for the
13336 different color schemes.  These commands are generated by @code{gtroff}'s
13337 escape sequences @w{@code{\D'F @dots{}'}} and @code{\M} (with no other
13338 corresponding graphics commands).  No position changing.  This command
13339 is a @code{gtroff} extension.
13341 @table @code
13342 @item DFc @var{cyan} @var{magenta} @var{yellow}@angles{line break}
13343 Set fill color for solid drawing objects using the CMY color scheme,
13344 having the 3@w{ }color components @var{cyan}, @var{magenta}, and
13345 @var{yellow}.
13347 @item DFd@angles{line break}
13348 Set fill color for solid drawing objects to the default fill color value
13349 (black in most cases).  No component arguments.
13351 @item DFg @var{gray}@angles{line break}
13352 Set fill color for solid drawing objects to the shade of gray given by
13353 the argument, an integer between 0 (black) and 65536 (white).
13355 @item DFk @var{cyan} @var{magenta} @var{yellow} @var{black}@angles{line break}
13356 Set fill color for solid drawing objects using the CMYK color scheme,
13357 having the 4@w{ }color components @var{cyan}, @var{magenta}, @var{yellow},
13358 and @var{black}.
13360 @item DFr @var{red} @var{green} @var{blue}@angles{line break}
13361 Set fill color for solid drawing objects using the RGB color scheme,
13362 having the 3@w{ }color components @var{red}, @var{green}, and @var{blue}.
13364 @end table
13366 @item Df @var{n}@angles{line break}
13367 The argument@w{ }@var{n} must be an integer in the range @math{-32767}
13368 to 32767.
13370 @table @asis
13371 @item @math{0 @LE @var{n} @LE 1000}
13372 Set the color for filling solid drawing objects to a shade of gray,
13373 where 0 corresponds to solid white, 1000 (the default) to solid black,
13374 and values in between to intermediate shades of gray; this is
13375 obsoleted by command @samp{DFg}.
13377 @item @math{@var{n} @LT 0} or @math{@var{n} @LT 1000}
13378 Set the filling color to the color that is currently being used for
13379 the text and the outline, see command @samp{m}.  For example, the
13380 command sequence
13382 @Example
13383 mg 0 0 65536
13384 Df -1
13385 @endExample
13387 @noindent
13388 sets all colors to blue.
13390 @end table
13392 @noindent
13393 No position changing.  This command is a @code{gtroff} extension.
13395 @item Dl @var{h} @var{v}@angles{line break}
13396 Draw line from current position to offset (@var{h},@var{v}) (integers
13397 in basic units @samp{u}); then set current position to the end of the
13398 drawn line.
13400 @item Dp @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
13401 Draw a polygon line from current position to offset (@var{h1},@var{v1}),
13402 from there to offset (@var{h2},@var{v2}), etc.@: up to offset
13403 (@var{hn},@var{vn}), and from there back to the starting position.
13404 For historical reasons, the position is changed by adding the sum of
13405 all arguments with odd index to the actual horizontal position and the
13406 even ones to the vertical position.  Although this doesn't make sense
13407 it is kept for compatibility.
13408 @ignore
13409 As the polygon is closed, the end of drawing is the starting point, so
13410 the position doesn't change.
13411 @end ignore
13412 This command is a @code{gtroff} extension.
13414 @item Dp @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
13415 Draw a solid polygon in the current fill color rather than an outlined
13416 polygon, using the same arguments and positioning as the corresponding
13417 @samp{Dp} command.
13418 @ignore
13419 No position changing.
13420 @end ignore
13421 This command is a @code{gtroff} extension.
13423 @item Dt @var{n}@angles{line break}
13424 Set the current line thickness to@w{ }@var{n} (an integer in basic
13425 units @samp{u}) if @math{@var{n}>0}; if @math{@var{n}=0} select the
13426 smallest available line thickness; if @math{@var{n}<0} set the line
13427 thickness proportional to the point size (this is the default before
13428 the first @samp{Dt} command was specified).  For historical reasons,
13429 the horizontal position is changed by adding the argument to the actual
13430 horizontal position, while the vertical position is not changed.
13431 Although this doesn't make sense it is kept for compatibility.
13432 @ignore
13433 No position changing.
13434 @end ignore
13435 This command is a @code{gtroff} extension.
13437 @end table
13439 @node Device Control Commands, Obsolete Command, Graphics Commands, Command Reference
13440 @subsubsection Device Control Commands
13442 Each device control command starts with the letter @samp{x},
13443 followed by a space character (optional or arbitrary space or tab in
13444 @code{gtroff}) and a subcommand letter or word; each argument (if any)
13445 must be preceded by a syntactical space.  All @samp{x} commands are
13446 terminated by a syntactical line break; no device control command can
13447 be followed by another command on the same line (except a comment).
13449 The subcommand is basically a single letter, but to increase
13450 readability, it can be written as a word, i.e., an arbitrary sequence
13451 of characters terminated by the next tab, space, or newline character.
13452 All characters of the subcommand word but the first are simply ignored.
13453 For example, @code{gtroff} outputs the initialization command
13454 @w{@samp{x i}} as @w{@samp{x init}} and the resolution command
13455 @w{@samp{x r}} as @w{@samp{x res}}.
13457 In the following, the syntax element @angles{line break} means a
13458 syntactical line break (@pxref{Separation}).
13460 @table @code
13461 @item xF @var{name}@angles{line break}
13462 The @samp{F} stands for @var{Filename}.
13464 Use @var{name} as the intended name for the current file in error
13465 reports.  This is useful for remembering the original file name when
13466 @code{gtroff} uses an internal piping mechanism.  The input file is
13467 not changed by this command.  This command is a @code{gtroff} extension.
13469 @item xf @var{n} @var{s}@angles{line break}
13470 The @samp{f} stands for @var{font}.
13472 Mount font position@w{ }@var{n} (a non-negative integer) with font
13473 named@w{ }@var{s} (a text word).  @xref{Font Positions}.
13475 @item xH @var{n}@angles{line break}
13476 The @samp{H} stands for @var{Height}.
13478 Set glyph height to@w{ }@var{n} (a positive integer in scaled
13479 points @samp{z}).  @acronym{AT&T} @code{troff} uses the unit points
13480 (@samp{p}) instead.  @xref{Output Language Compatibility}.
13482 @item xi@angles{line break}
13483 The @samp{i} stands for @var{init}.
13485 Initialize device.  This is the third command of the prologue.
13487 @item xp@angles{line break}
13488 The @samp{p} stands for @var{pause}.
13490 Parsed but ignored.  The original @acronym{UNIX} troff manual writes
13492 @display
13493 pause device, can be restarted
13494 @end display
13496 @item xr @var{n} @var{h} @var{v}@angles{line break}
13497 The @samp{r} stands for @var{resolution}.
13499 Resolution is@w{ }@var{n}, while @var{h} is the minimal horizontal
13500 motion, and @var{v} the minimal vertical motion possible with this
13501 device; all arguments are positive integers in basic units @samp{u}
13502 per inch.  This is the second command of the prologue.
13504 @item xS @var{n}@angles{line break}
13505 The @samp{S} stands for @var{Slant}.
13507 Set slant to@w{ }@var{n} (an integer in basic units @samp{u}).
13509 @item xs@angles{line break}
13510 The @samp{s} stands for @var{stop}.
13512 Terminates the processing of the current file; issued as the last
13513 command of any intermediate troff output.
13515 @item xt@angles{line break}
13516 The @samp{t} stands for @var{trailer}.
13518 Generate trailer information, if any.  In @var{gtroff}, this is
13519 actually just ignored.
13521 @item xT @var{xxx}@angles{line break}
13522 The @samp{T} stands for @var{Typesetter}.
13524 Set name of device to word @var{xxx}, a sequence of characters ended
13525 by the next white space character.  The possible device names coincide
13526 with those from the groff @option{-T} option.  This is the first
13527 command of the prologue.
13529 @item xu @var{n}@angles{line break}
13530 The @samp{u} stands for @var{underline}.
13532 Configure underlining of spaces.  If @var{n} is@w{ }1, start
13533 underlining of spaces; if @var{n} is@w{ }0, stop underlining of spaces.
13534 This is needed for the @code{cu} request in nroff mode and is ignored
13535 otherwise.  This command is a @code{gtroff} extension.
13537 @item xX @var{anything}@angles{line break}
13538 The @samp{x} stands for @var{X-escape}.
13540 Send string @var{anything} uninterpreted to the device.  If the line
13541 following this command starts with a @samp{+} character this line is
13542 interpreted as a continuation line in the following sense.  The
13543 @samp{+} is ignored, but a newline character is sent instead to the
13544 device, the rest of the line is sent uninterpreted.  The same applies
13545 to all following lines until the first character of a line is not a
13546 @samp{+} character.  This command is generated by the @code{gtroff}
13547 escape sequence @code{\X}.  The line-continuing feature is a
13548 @code{gtroff} extension.
13550 @end table
13552 @node Obsolete Command,  , Device Control Commands, Command Reference
13553 @subsubsection Obsolete Command
13554 In @acronym{AT&T} @code{troff} output, the writing of a single
13555 glyph is mostly done by a very strange command that combines a
13556 horizontal move and a single character giving the glyph name.  It
13557 doesn't have a command code, but is represented by a 3-character
13558 argument consisting of exactly 2@w{ }digits and a character.
13560 @table @asis
13561 @item @var{dd}@var{g}
13562 Move right @var{dd} (exactly two decimal digits) basic units @samp{u},
13563 then print glyph@w{ }@var{g} (represented as a single character).
13565 In @code{gtroff}, arbitrary syntactical space around and within this
13566 command is allowed to be added.  Only when a preceding command on the
13567 same line ends with an argument of variable length a separating space
13568 is obligatory.  In @acronym{AT&T} @code{troff}, large clusters of these
13569 and other commands are used, mostly without spaces; this made such output
13570 almost unreadable.
13572 @end table
13574 For modern high-resolution devices, this command does not make sense
13575 because the width of the glyphs can become much larger than two
13576 decimal digits.  In @code{gtroff}, this is only used for the devices
13577 @code{X75}, @code{X75-12}, @code{X100}, and @code{X100-12}.  For other
13578 devices, the commands @samp{t} and @samp{u} provide a better
13579 functionality.
13581 @c ---------------------------------------------------------------------
13583 @node Intermediate Output Examples, Output Language Compatibility, Command Reference, gtroff Output
13584 @subsection Intermediate Output Examples
13586 This section presents the intermediate output generated from the same
13587 input for three different devices.  The input is the sentence
13588 @samp{hell world} fed into @code{gtroff} on the command line.
13590 @table @asis
13591 @item High-resolution device @code{ps}
13593 This is the standard output of @code{gtroff} if no @option{-T} option
13594 is given.
13596 @example
13597 @group
13598 shell> echo "hell world" | groff -Z -T ps
13600 x T ps
13601 x res 72000 1 1
13602 x init
13603 @end group
13605 x font 5 TR
13607 s10000
13608 V12000
13609 H72000
13610 thell
13611 wh2500
13613 H96620
13614 torld
13615 n12000 0
13616 @group
13617 x trailer
13618 V792000
13619 x stop
13620 @end group
13621 @end example
13623 @noindent
13624 This output can be fed into @code{grops} to get its representation as
13625 a PostScript file.
13627 @item Low-resolution device @code{latin1}
13629 This is similar to the high-resolution device except that the
13630 positioning is done at a minor scale.  Some comments (lines starting
13631 with @samp{#}) were added for clarification; they were not generated
13632 by the formatter.
13634 @example
13635 @group
13636 shell> echo "hell world" | groff -Z -T latin1
13638 # prologue
13639 x T latin1
13640 x res 240 24 40
13641 x init
13642 @end group
13643 # begin a new page
13645 # font setup
13646 x font 1 R
13649 # initial positioning on the page
13652 # write text `hell'
13653 thell
13654 # inform about space, and issue a horizontal jump
13655 wh24
13656 # write text `world'
13657 tworld
13658 # announce line break, but do nothing because ...
13659 n40 0
13660 @group
13661 # ... the end of the document has been reached
13662 x trailer
13663 V2640
13664 x stop
13665 @end group
13666 @end example
13668 @noindent
13669 This output can be fed into @code{grotty} to get a formatted text
13670 document.
13672 @item @acronym{AT&T} @code{troff} output
13673 Since a computer monitor has a very low resolution compared to modern
13674 printers the intermediate output for the X@w{ }Window devices can use
13675 the jump-and-write command with its 2-digit displacements.
13677 @example
13678 @group
13679 shell> echo "hell world" | groff -Z -T X100
13681 x T X100
13682 x res 100 1 1
13683 x init
13684 @end group
13686 x font 5 TR
13690 H100
13691 # write text with jump-and-write commands
13692 ch07e07l03lw06w11o07r05l03dh7
13693 n16 0
13694 @group
13695 x trailer
13696 V1100
13697 x stop
13698 @end group
13699 @end example
13701 @noindent
13702 This output can be fed into @code{xditview} or @code{gxditview}
13703 for displaying in@w{ }X.
13705 Due to the obsolete jump-and-write command, the text clusters in the
13706 @acronym{AT&T} @code{troff} output are almost unreadable.
13708 @end table
13710 @c ---------------------------------------------------------------------
13712 @node Output Language Compatibility,  , Intermediate Output Examples, gtroff Output
13713 @subsection Output Language Compatibility
13715 The intermediate output language of @acronym{AT&T} @code{troff}
13716 was first documented in the @acronym{UNIX} troff manual, with later
13717 additions documented in @cite{A Typesetter-indenpendent TROFF},
13718 written by Brian Kernighan.
13720 The @code{gtroff} intermediate output format is compatible with this
13721 specification except for the following features.
13723 @itemize @bullet
13724 @item
13725 The classical quasi device independence is not yet implemented.
13727 @item
13728 The old hardware was very different from what we use today.  So the
13729 @code{groff} devices are also fundamentally different from the ones in
13730 @acronym{AT&T} @code{troff}.  For example, the @acronym{AT&T}
13731 PostScript device is called @code{post} and has a resolution of only
13732 720 units per inch, suitable for printers 20 years ago, while
13733 @code{groff}'s @code{ps} device has a resolution of
13734 72000 units per inch.  Maybe, by implementing some rescaling
13735 mechanism similar to the classical quasi device independence,
13736 @code{groff} could emulate @acronym{AT&T}'s @code{post} device.
13738 @item
13739 The B-spline command @samp{D~} is correctly handled by the
13740 intermediate output parser, but the drawing routines aren't
13741 implemented in some of the postprocessor programs.
13743 @item
13744 The argument of the commands @samp{s} and @w{@samp{x H}} has the
13745 implicit unit scaled point @samp{z} in @code{gtroff}, while
13746 @acronym{AT&T} @code{troff} has point (@samp{p}).  This isn't an
13747 incompatibility but a compatible extension, for both units coincide
13748 for all devices without a @code{sizescale} parameter in the @file{DESC}
13749 file, including all postprocessors from @acronym{AT&T} and
13750 @code{groff}'s text devices.  The few @code{groff} devices with
13751 a @code{sizescale} parameter either do not exist for @acronym{AT&T}
13752 @code{troff}, have a different name, or seem to have a different
13753 resolution.  So conflicts are very unlikely.
13755 @item
13756 The position changing after the commands @samp{Dp}, @samp{DP}, and
13757 @samp{Dt} is illogical, but as old versions of @code{gtroff} used this
13758 feature it is kept for compatibility reasons.
13760 @ignore
13761 Temporarily, there existed some confusion on the positioning after the
13762 @samp{D} commands that are groff extensions.  This has been clarified
13763 by establishing the classical rule for all groff drawing commands:
13765 @itemize
13766 @item
13767 The position after a graphic object has been drawn is at its end;
13768 for circles and ellipses, the `end' is at the right side.
13770 @item
13771 From this, the positionings specified for the drawing commands above
13772 follow quite naturally.
13773 @end itemize
13774 @end ignore
13776 @end itemize
13779 @c =====================================================================
13781 @node Font Files,  , gtroff Output, File formats
13782 @section Font Files
13783 @cindex font files
13784 @cindex files, font
13786 The @code{gtroff} font format is roughly a superset of the
13787 @code{ditroff} font format (as used in later versions of @acronym{AT&T}
13788 @code{troff} and its descendants).  Unlike the @code{ditroff} font
13789 format, there is no associated binary format; all files are text
13790 files.@footnote{Plan@w{ }9 @code{troff} has also abandoned the binary
13791 format.}  The font files for device @var{name} are stored in a directory
13792 @file{dev@var{name}}.  There are two types of file: a device description
13793 file called @file{DESC} and for each font@w{ }@var{f} a font file
13794 called@w{ }@file{@var{f}}.
13796 @menu
13797 * DESC File Format::
13798 * Font File Format::
13799 @end menu
13801 @c ---------------------------------------------------------------------
13803 @node DESC File Format, Font File Format, Font Files, Font Files
13804 @subsection @file{DESC} File Format
13805 @cindex @file{DESC} file, format
13806 @cindex font description file, format
13807 @cindex format of font description file
13808 @pindex DESC@r{ file format}
13810 The @file{DESC} file can contain the following types of line.  Except
13811 for the @code{charset} keyword which must comes last (if at all), the
13812 order of the lines is not important.
13814 @table @code
13815 @item res @var{n}
13816 @kindex res
13817 There are @var{n}@w{ }machine units per inch.
13819 @item hor @var{n}
13820 @kindex hor
13821 The horizontal resolution is @var{n}@w{ }machine units.
13823 @item vert @var{n}
13824 @kindex vert
13825 The vertical resolution is @var{n}@w{ }machine units.
13827 @item sizescale @var{n}
13828 @kindex sizescale
13829 The scale factor for point sizes.  By default this has a value of@w{ }1.
13830 One scaled point is equal to one point/@var{n}.  The arguments to the
13831 @code{unitwidth} and @code{sizes} commands are given in scaled points.
13832 @xref{Fractional Type Sizes}, for more information.
13834 @item unitwidth @var{n}
13835 @kindex unitwidth
13836 Quantities in the font files are given in machine units for fonts whose
13837 point size is @var{n}@w{ }scaled points.
13839 @item prepro @var{program}
13840 @kindex prepro
13841 Call @var{program} as a preprocessor.  Currently, this keyword is used
13842 by @code{groff} with option @option{-Thtml} only.
13844 @item postpro @var{program}
13845 @kindex postpro
13846 Call @var{program} as a postprocessor.  For example, the line
13848 @Example
13849 postpro grodvi
13850 @endExample
13852 @noindent
13853 in the file @file{devdvi/DESC} makes @code{groff} call @code{grodvi}
13854 if option @option{-Tdvi} is given (and @option{-Z} isn't used).
13856 @item tcommand
13857 @kindex tcommand
13858 This means that the postprocessor can handle the @samp{t} and @samp{u}
13859 intermediate output commands.
13861 @item sizes @var{s1} @var{s2} @dots{} @var{sn} 0
13862 @kindex sizes
13863 This means that the device has fonts at @var{s1}, @var{s2}, @dots{}
13864 @var{sn} scaled points.  The list of sizes must be terminated by@w{ }0
13865 (this is digit zero).  Each @var{si} can also be a range of sizes
13866 @var{m}-@var{n}.  The list can extend over more than one line.
13868 @item styles @var{S1} @var{S2} @dots{} @var{Sm}
13869 @kindex styles
13870 The first @var{m}@w{ }font positions are associated with styles
13871 @var{S1} @dots{} @var{Sm}.
13873 @item fonts @var{n} @var{F1} @var{F2} @var{F3} @dots{} @var{Fn}
13874 @kindex fonts
13875 Fonts @var{F1} @dots{} @var{Fn} are mounted in the font positions
13876 @var{m}+1, @dots{}, @var{m}+@var{n} where @var{m} is the number of
13877 styles.  This command may extend over more than one line.  A font name
13878 of@w{ }0 means no font is mounted on the corresponding font position.
13880 @item family @var{fam}
13881 @kindex family
13882 The default font family is @var{fam}.
13884 @item use_charnames_in_special
13885 @kindex use_charnames_in_special
13886 This command indicates that @code{gtroff} should encode special
13887 characters inside special commands.  Currently, this is only used
13888 by the @acronym{HTML} output device.  @xref{Postprocessor Access}.
13890 @item pass_filenames
13891 @kindex pass_filenames
13892 Tell @code{gtroff} to emit the name of the source file currently
13893 being processed.  This is achieved by the intermediate output command
13894 @samp{F}.  Currently, this is only used by the @acronym{HTML} output
13895 device.
13897 @item print @var{program}
13898 @kindex print
13899 Use @var{program} as a spooler program for printing.  If omitted,
13900 the @option{-l} and @option{-L} options of @code{groff} are ignored.
13902 @item charset
13903 @kindex charset
13904 This line and everything following in the file are ignored.  It is
13905 allowed for the sake of backwards compatibility.
13906 @end table
13908 The @code{res}, @code{unitwidth}, @code{fonts}, and @code{sizes} lines
13909 are mandatory.  Other commands are ignored by @code{gtroff} but may be
13910 used by postprocessors to store arbitrary information about the device
13911 in the @file{DESC} file.
13913 @kindex spare1
13914 @kindex spare2
13915 @kindex biggestfont
13916 Here a list of obsolete keywords which are recognized by @code{groff}
13917 but completely ignored: @code{spare1}, @code{spare2},
13918 @code{biggestfont}.
13921 @c ---------------------------------------------------------------------
13923 @node Font File Format,  , DESC File Format, Font Files
13924 @subsection Font File Format
13925 @cindex font file, format
13926 @cindex font description file, format
13927 @cindex format of font files
13928 @cindex format of font description files
13930 A @dfn{font file}, also (and probably better) called a @dfn{font
13931 description file}, has two sections.  The first section is a sequence
13932 of lines each containing a sequence of blank delimited words; the first
13933 word in the line is a key, and subsequent words give a value for that
13934 key.
13936 @table @code
13937 @item name @var{f}
13938 @kindex name
13939 The name of the font is@w{ }@var{f}.
13941 @item spacewidth @var{n}
13942 @kindex spacewidth
13943 The normal width of a space is@w{ }@var{n}.
13945 @item slant @var{n}
13946 @kindex slant
13947 The glyphs of the font have a slant of @var{n}@w{ }degrees.
13948 (Positive means forward.)
13950 @item ligatures @var{lig1} @var{lig2} @dots{} @var{lign} [0]
13951 @kindex ligatures
13952 Glyphs @var{lig1}, @var{lig2}, @dots{}, @var{lign} are ligatures;
13953 possible ligatures are @samp{ff}, @samp{fi}, @samp{fl}, @samp{ffi} and
13954 @samp{ffl}.  For backwards compatibility, the list of ligatures may be
13955 terminated with a@w{ }0.  The list of ligatures may not extend over more
13956 than one line.
13958 @item special
13959 @cindex special fonts
13960 @kindex special
13961 The font is @dfn{special}; this means that when a glyph is requested
13962 that is not present in the current font, it is searched for in any
13963 special fonts that are mounted.
13964 @end table
13966 Other commands are ignored by @code{gtroff} but may be used by
13967 postprocessors to store arbitrary information about the font in the font
13968 file.
13970 @cindex comments in font files
13971 @cindex font files, comments
13972 @kindex #
13973 The first section can contain comments which start with the @samp{#}
13974 character and extend to the end of a line.
13976 The second section contains one or two subsections.  It must contain a
13977 @code{charset} subsection and it may also contain a @code{kernpairs}
13978 subsection.  These subsections can appear in any order.  Each
13979 subsection starts with a word on a line by itself.
13981 @kindex charset
13982 The word @code{charset} starts the character set
13983 subsection.@footnote{This keyword is misnamed since it starts a list
13984 of ordered glyphs, not characters.}  The @code{charset} line is
13985 followed by a sequence of lines.  Each line gives information for one
13986 glyph.  A line comprises a number of fields separated by blanks or
13987 tabs.  The format is
13989 @quotation
13990 @var{name} @var{metrics} @var{type} @var{code}
13991 [@var{entity-name}] [@code{--} @var{comment}]
13992 @end quotation
13994 @cindex 8-bit input
13995 @cindex input, 8-bit
13996 @cindex accessing unnamed glyphs with @code{\N}
13997 @cindex unnamed glyphs, accessing with @code{\N}
13998 @cindex characters, unnamed, accessing with @code{\N}
13999 @cindex glyphs, unnamed, accessing with @code{\N}
14000 @kindex ---
14001 @noindent
14002 @var{name} identifies the glyph name@footnote{The distinction between
14003 input, characters, and output, glyphs, is not clearly separated in the
14004 terminology of @code{groff}; for example, the @code{char} request
14005 should be called @code{glyph} since it defines an output entity.}:
14006 If @var{name} is a single character@w{ }@var{c} then it corresponds
14007 to the @code{gtroff} input character@w{ }@var{c}; if it is of the form
14008 @samp{\@var{c}} where @var{c} is a single character, then it
14009 corresponds to the special character @code{\[@var{c}]}; otherwise it
14010 corresponds to the special character @samp{\[@var{name}]}.  If it
14011 is exactly two characters @var{xx} it can be entered as
14012 @samp{\(@var{xx}}.  Note that single-letter special characters can't
14013 be accessed as @samp{\@var{c}}; the only exception is @samp{\-} which
14014 is identical to @code{\[-]}.
14016 @code{gtroff} supports 8-bit input characters; however some utilities
14017 have difficulties with eight-bit characters.  For this reason, there is
14018 a convention that the entity name @samp{char@var{n}} is equivalent to
14019 the single input character whose code is@w{ }@var{n}.  For example,
14020 @samp{char163} would be equivalent to the character with code@w{ }163
14021 which is the pounds sterling sign in the @w{ISO Latin-1} character set.
14022 You shouldn't use @samp{char@var{n}} entities in font description files
14023 since they are related to input, not output.  Otherwise, you get
14024 hard-coded connections between input and output encoding which
14025 prevents use of different (input) character sets.
14027 The name @samp{---} is special and indicates that the glyph is
14028 unnamed; such glyphs can only be used by means of the @code{\N}
14029 escape sequence in @code{gtroff}.
14031 The @var{type} field gives the glyph type:
14033 @table @code
14034 @item 1
14035 the glyph has a descender, for example, @samp{p};
14037 @item 2
14038 the glyph has an ascender, for example, @samp{b};
14040 @item 3
14041 the glyph has both an ascender and a descender, for example, @samp{(}.
14042 @end table
14044 The @var{code} field gives the code which the postprocessor uses to
14045 print the glyph.  The glyph can also be input to @code{gtroff}
14046 using this code by means of the @code{\N} escape sequence.  @var{code}
14047 can be any integer.  If it starts with @samp{0} it is interpreted as
14048 octal; if it starts with @samp{0x} or @samp{0X} it is interpreted as
14049 hexadecimal.
14051 The @var{entity-name} field gives an @acronym{ASCII} string
14052 identifying the glyph which the postprocessor uses to print the
14053 @code{gtroff} glyph @var{name}.  This field is optional and has been
14054 introduced so that the @acronym{HTML} device driver can encode its
14055 character set.  For example, the glyph @samp{\[Po]} is
14056 represented as @samp{&pound;} in @acronym{HTML} 4.0.
14058 Anything on the line after the @var{entity-name} field resp.@: after
14059 @samp{--} will be ignored.
14061 The @var{metrics} field has the form:
14063 @display
14064 @group
14065 @var{width}[@code{,}@var{height}[@code{,}@var{depth}[@code{,}@var{italic-correction}
14066   [@code{,}@var{left-italic-correction}[@code{,}@var{subscript-correction}]]]]]
14067 @end group
14068 @end display
14070 @noindent
14071 There must not be any spaces between these subfields (it has been split
14072 here into two lines for better legibility only).  Missing subfields are
14073 assumed to be@w{ }0.  The subfields are all decimal integers.  Since
14074 there is no associated binary format, these values are not required to
14075 fit into a variable of type @samp{char} as they are in @code{ditroff}.
14076 The @var{width} subfield gives the width of the glyph.  The @var{height}
14077 subfield gives the height of the glyph (upwards is positive); if a
14078 glyph does not extend above the baseline, it should be given a zero
14079 height, rather than a negative height.  The @var{depth} subfield gives
14080 the depth of the glyph, that is, the distance from the baseline to the
14081 lowest point below the baseline to which the glyph extends (downwards is
14082 positive); if a glyph does not extend below the baseline, it should be
14083 given a zero depth, rather than a negative depth.  The
14084 @var{italic-correction} subfield gives the amount of space that should
14085 be added after the glyph when it is immediately to be followed by a
14086 glyph from a roman font.  The @var{left-italic-correction} subfield
14087 gives the amount of space that should be added before the glyph when it
14088 is immediately to be preceded by a glyph from a roman font.  The
14089 @var{subscript-correction} gives the amount of space that should be
14090 added after a glyph before adding a subscript.  This should be less
14091 than the italic correction.
14093 A line in the @code{charset} section can also have the format
14095 @Example
14096 @var{name} "
14097 @endExample
14099 @noindent
14100 This indicates that @var{name} is just another name for the glyph
14101 mentioned in the preceding line.
14103 @kindex kernpairs
14104 The word @code{kernpairs} starts the kernpairs section.  This contains a
14105 sequence of lines of the form:
14107 @Example
14108 @var{c1} @var{c2} @var{n}
14109 @endExample
14111 @noindent
14112 This means that when glyph @var{c1} appears next to glyph @var{c2}
14113 the space between them should be increased by@w{ }@var{n}.  Most
14114 entries in the kernpairs section have a negative value for@w{ }@var{n}.
14118 @c =====================================================================
14119 @c =====================================================================
14121 @node Installation, Copying This Manual, File formats, Top
14122 @chapter Installation
14123 @cindex installation
14125 @c XXX
14129 @c =====================================================================
14130 @c =====================================================================
14132 @node Copying This Manual, Request Index, Installation, Top
14133 @appendix Copying This Manual
14135 @menu
14136 * GNU Free Documentation License::  License for copying this manual.
14137 @end menu
14139 @include fdl.texi
14143 @c =====================================================================
14144 @c =====================================================================
14146 @node Request Index, Escape Index, Copying This Manual, Top
14147 @appendix Request Index
14149 Requests appear without the leading control character (normally either
14150 @samp{.} or @samp{'}).
14152 @printindex rq
14156 @c =====================================================================
14157 @c =====================================================================
14159 @node Escape Index, Operator Index, Request Index, Top
14160 @appendix Escape Index
14162 Any escape sequence @code{\@var{X}} with @var{X} not in the list below
14163 emits a warning, printing glyph @var{X}.
14165 @printindex es
14169 @c =====================================================================
14170 @c =====================================================================
14172 @node Operator Index, Register Index, Escape Index, Top
14173 @appendix Operator Index
14175 @printindex op
14179 @c =====================================================================
14180 @c =====================================================================
14182 @node Register Index, Macro Index, Operator Index, Top
14183 @appendix Register Index
14185 The macro package or program a specific register belongs to is appended in
14186 brackets.
14188 A register name@w{ }@code{x} consisting of exactly one character can be
14189 accessed as @samp{\nx}.  A register name @code{xx} consisting of exactly
14190 two characters can be accessed as @samp{\n(xx}.  Register names @code{xxx}
14191 of any length can be accessed as @samp{\n[xxx]}.
14193 @printindex vr
14197 @c =====================================================================
14198 @c =====================================================================
14200 @node Macro Index, String Index, Register Index, Top
14201 @appendix Macro Index
14203 The macro package a specific macro belongs to is appended in brackets.
14204 They appear without the leading control character (normally @samp{.}).
14206 @printindex ma
14210 @c =====================================================================
14211 @c =====================================================================
14213 @node String Index, Glyph Name Index, Macro Index, Top
14214 @appendix String Index
14216 The macro package or program a specific string belongs to is appended in
14217 brackets.
14219 A string name@w{ }@code{x} consisting of exactly one character can be
14220 accessed as @samp{\*x}.  A string name @code{xx} consisting of exactly
14221 two characters can be accessed as @samp{\*(xx}.  String names @code{xxx}
14222 of any length can be accessed as @samp{\*[xxx]}.
14225 @printindex st
14229 @c =====================================================================
14230 @c =====================================================================
14232 @node Glyph Name Index, Font File Keyword Index, String Index, Top
14233 @appendix Glyph Name Index
14235 A glyph name @code{xx} consisting of exactly two characters can be
14236 accessed as @samp{\(xx}.  Glyph names @code{xxx} of any length can be
14237 accessed as @samp{\[xxx]}.
14239 @c XXX
14243 @c =====================================================================
14244 @c =====================================================================
14246 @node Font File Keyword Index, Program and File Index, Glyph Name Index, Top
14247 @appendix Font File Keyword Index
14249 @printindex ky
14253 @c =====================================================================
14254 @c =====================================================================
14256 @node Program and File Index, Concept Index, Font File Keyword Index, Top
14257 @appendix Program and File Index
14259 @printindex pg
14263 @c =====================================================================
14264 @c =====================================================================
14266 @node Concept Index,  , Program and File Index, Top
14267 @appendix Concept Index
14269 @printindex cp
14272 @bye