Minor fixes from Bernd.
[s-roff.git] / doc / groff.texinfo
blob099b7c86f9c7d7325f51b50e9dfe83d5740480c8
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 seconds
5395 @cindex seconds, current time (@code{seconds})
5396 @cindex time, current, seconds (@code{seconds})
5397 @cindex current time, seconds (@code{seconds})
5398 @vindex seconds
5399 The number of seconds after the minute, normally in the range@w{ }0
5400 to@w{ }59, but can be up to@w{ }61 to allow for leap seconds.  Initialized
5401 at start-up of @code{gtroff}.
5403 @item minutes
5404 @cindex minutes, current time (@code{minutes})
5405 @cindex time, current, minutes (@code{minutes})
5406 @cindex current time, minutes (@code{minutes})
5407 @vindex minutes
5408 The number of minutes after the hour, in the range@w{ }0 to@w{ }59.
5409 Initialized at start-up of @code{gtroff}.
5411 @item hours
5412 @cindex hours, current time (@code{hours})
5413 @cindex time, current, hours (@code{hours})
5414 @cindex current time, hours (@code{hours})
5415 @vindex hours
5416 The number of hours past midnight, in the range@w{ }0 to@w{ }23.
5417 Initialized at start-up of @code{gtroff}.
5419 @item dw
5420 @cindex day of the week register (@code{dw})
5421 @cindex date, day of the week register (@code{dw})
5422 @vindex dw
5423 Day of the week (1-7).
5425 @item dy
5426 @cindex day of the month register (@code{dy})
5427 @cindex date, day of the month register (@code{dy})
5428 @vindex dy
5429 Day of the month (1-31).
5431 @item mo
5432 @cindex month of the year register (@code{mo})
5433 @cindex date, month of the year register (@code{mo})
5434 @vindex mo
5435 Current month (1-12).
5437 @item year
5438 @cindex date, year register (@code{year}, @code{yr})
5439 @cindex year, current, register (@code{year}, @code{yr})
5440 @vindex year
5441 The current year.
5443 @item yr
5444 @vindex yr
5445 The current year minus@w{ }1900.  Unfortunately, the documentation of
5446 @acronym{UNIX} Version@w{ }7's @code{troff} had a year@w{ }2000 bug: It
5447 incorrectly claimed that @code{yr} contains the last two digits of the
5448 year.  That claim has never been true of either @acronym{AT&T}
5449 @code{troff} or GNU @code{troff}.  Old @code{troff} input that looks
5450 like this:
5452 @Example
5453 '\" The following line stopped working after 1999
5454 This document was formatted in 19\n(yr.
5455 @endExample
5457 @noindent
5458 can be corrected as follows:
5460 @Example
5461 This document was formatted in \n[year].
5462 @endExample
5464 @noindent
5465 or, to be portable to older @code{troff} versions, as follows:
5467 @Example
5468 .nr y4 1900+\n(yr
5469 This document was formatted in \n(y4.
5470 @endExample
5472 @item .c
5473 @vindex .c
5474 @itemx c.
5475 @vindex c.
5476 @cindex input line number register (@code{.c}, @code{c.})
5477 @cindex line number, input, register (@code{.c}, @code{c.})
5478 The current @emph{input} line number.  Register @samp{.c} is read-only,
5479 whereas @samp{c.} (a @code{gtroff} extension) is writable also,
5480 affecting both @samp{.c} and @samp{c.}.
5482 @item ln
5483 @vindex ln
5484 @cindex output line number register (@code{ln})
5485 @cindex line number, output, register (@code{ln})
5486 The current @emph{output} line number after a call to the @code{nm}
5487 request to activate line numbering.
5489 @xref{Miscellaneous}, for more information about line numbering.
5491 @item .x
5492 @vindex .x
5493 @cindex major version number register (@code{.x})
5494 @cindex version number, major, register (@code{.x})
5495 The major version number.  For example, if the version number is@w{
5496 }1.03 then @code{.x} contains@w{ }@samp{1}.
5498 @item .y
5499 @vindex .y
5500 @cindex minor version number register (@code{.y})
5501 @cindex version number, minor, register (@code{.y})
5502 The minor version number.  For example, if the version number is@w{
5503 }1.03 then @code{.y} contains@w{ }@samp{03}.
5505 @item .Y
5506 @vindex .Y
5507 @cindex revision number register (@code{.Y})
5508 The revision number of @code{groff}.
5510 @item $$
5511 @vindex $$
5512 @cindex process ID of @code{gtroff} register (@code{$$})
5513 @cindex @code{gtroff}, process ID register (@code{$$})
5514 The process ID of @code{gtroff}.
5516 @item .g
5517 @vindex .g
5518 @cindex @code{gtroff}, identification register (@code{.g})
5519 @cindex GNU-specific register (@code{.g})
5520 Always@w{ }1.  Macros should use this to determine whether they are
5521 running under GNU @code{troff}.
5523 @item .A
5524 @vindex .A
5525 @cindex @acronym{ASCII} approximation output register (@code{.A})
5526 If the command line option @option{-a} is used to produce an
5527 @acronym{ASCII} approximation of the output, this is set to@w{ }1, zero
5528 otherwise.  @xref{Groff Options}.
5530 @item .P
5531 @vindex .P
5532 This register is set to@w{ }1 (and to@w{ }0 otherwise) if the current
5533 page is actually being printed, i.e., if the @option{-o} option is being
5534 used to only print selected pages.  @xref{Groff Options}, for more
5535 information.
5537 @item .T
5538 @vindex .T
5539 If @code{gtroff} is called with the @option{-T} command line option, the
5540 number register @code{.T} is set to@w{ }1, and zero otherwise.
5541 @xref{Groff Options}.
5543 @stindex .T
5544 @cindex output device name string register (@code{.T})
5545 Additionally, @code{gtroff} predefines a single read-write string
5546 register @code{.T} which contains the current output device (for
5547 example, @samp{latin1} or @samp{ps}).
5548 @end table
5551 @c =====================================================================
5553 @node Manipulating Filling and Adjusting, Manipulating Hyphenation, Registers, gtroff Reference
5554 @section Manipulating Filling and Adjusting
5555 @cindex manipulating filling and adjusting
5556 @cindex filling and adjusting, manipulating
5557 @cindex adjusting and filling, manipulating
5558 @cindex justifying text
5559 @cindex text, justifying
5561 @cindex break
5562 @cindex line break
5563 @cindex @code{bp} request, causing implicit linebreak
5564 @cindex @code{ce} request, causing implicit linebreak
5565 @cindex @code{cf} request, causing implicit linebreak
5566 @cindex @code{fi} request, causing implicit linebreak
5567 @cindex @code{fl} request, causing implicit linebreak
5568 @cindex @code{in} request, causing implicit linebreak
5569 @cindex @code{nf} request, causing implicit linebreak
5570 @cindex @code{rj} request, causing implicit linebreak
5571 @cindex @code{sp} request, causing implicit linebreak
5572 @cindex @code{ti} request, causing implicit linebreak
5573 @cindex @code{trf} request, causing implicit linebreak
5574 Various ways of causing @dfn{breaks} were given in @ref{Implicit Line
5575 Breaks}.  The @code{br} request likewise causes a break.  Several
5576 other requests also cause breaks, but implicitly.  These are
5577 @code{bp}, @code{ce}, @code{cf}, @code{fi}, @code{fl}, @code{in},
5578 @code{nf}, @code{rj}, @code{sp}, @code{ti}, and @code{trf}.
5580 @Defreq {br, }
5581 Break the current line, i.e., the input collected so far is emitted
5582 without adjustment.
5584 If the no-break control character is used, @code{gtroff} suppresses
5585 the break:
5587 @Example
5591     @result{} a b
5592 @endExample
5593 @endDefreq
5595 Initially, @code{gtroff} fills and adjusts text to both margins.
5596 Filling can be disabled via the @code{nf} request and re-enabled with
5597 the @code{fi} request.
5599 @DefreqList {fi, }
5600 @DefregListEnd {.u}
5601 @cindex fill mode (@code{fi})
5602 @cindex mode, fill (@code{fi})
5603 Activate fill mode (which is the default).  This request implicitly
5604 enables adjusting; it also inserts a break in the text currently being
5605 filled.  The read-only number register @code{.u} is set to@w{ }1.
5607 The fill mode status is associated with the current environment
5608 (@pxref{Environments}).
5610 See @ref{Line Control}, for interaction with the @code{\c} escape.
5611 @endDefreq
5613 @Defreq {nf, }
5614 @cindex no-fill mode (@code{nf})
5615 @cindex mode, no-fill (@code{nf})
5616 Activate no-fill mode.  Input lines are output as-is, retaining line
5617 breaks and ignoring the current line length.  This command implicitly
5618 disables adjusting; it also causes a break.  The number register
5619 @code{.u} is set to@w{ }0.
5621 The fill mode status is associated with the current environment
5622 (@pxref{Environments}).
5624 See @ref{Line Control}, for interaction with the @code{\c} escape.
5625 @endDefreq
5627 @DefreqList {ad, [@Var{mode}]}
5628 @DefregListEnd {.j}
5629 Set adjusting mode.
5631 Activation and deactivation of adjusting is done implicitly with
5632 calls to the @code{fi} or @code{nf} requests.
5634 @var{mode} can have one of the following values:
5636 @table @code
5637 @item l
5638 @cindex ragged-right
5639 Adjust text to the left margin.  This produces what is traditionally
5640 called ragged-right text.
5642 @item r
5643 @cindex ragged-left
5644 Adjust text to the right margin, producing ragged-left text.
5646 @item c
5647 @cindex centered text
5648 @cindex @code{ce} request, difference to @samp{.ad@w{ }c}
5649 Center filled text.  This is different to the @code{ce} request which
5650 only centers text without filling.
5652 @item b
5653 @itemx n
5654 Justify to both margins.  This is the default used by @code{gtroff}.
5655 @end table
5657 With no argument, @code{gtroff} adjusts lines in the same way it did
5658 before adjusting was deactivated (with a call to @code{na}, for
5659 example).
5661 @Example
5662 text
5663 .ad r
5664 text
5665 .ad c
5666 text
5668 text
5669 .ad  \" back to centering
5670 text
5671 @endExample
5673 @cindex adjustment mode register (@code{.j})
5674 The current adjustment mode is available in the read-only number
5675 register @code{.j}; it can be stored and subsequently used to set
5676 adjustment.
5678 The adjustment mode status is associated with the current environment
5679 (@pxref{Environments}).
5680 @endDefreq
5682 @Defreq {na, }
5683 Disable adjusting.  This request won't change the current adjustment
5684 mode: A subsequent call to @code{ad} uses the previous adjustment
5685 setting.
5687 The adjustment mode status is associated with the current environment
5688 (@pxref{Environments}).
5689 @endDefreq
5691 @DefreqList {brp, }
5692 @DefescListEnd {\\p, , , }
5693 Adjust the current line and cause a break.
5695 In most cases this produces very ugly results since @code{gtroff}
5696 doesn't have a sophisticated paragraph building algorithm (as @TeX{}
5697 have, for example); instead, @code{gtroff} fills and adjusts a paragraph
5698 line by line:
5700 @Example
5701   This is an uninteresting sentence.
5702   This is an uninteresting sentence.\p
5703   This is an uninteresting sentence.
5704 @endExample
5706 @noindent
5707 is formatted as
5709 @Example
5710   This is  an uninteresting  sentence.   This  is an
5711   uninteresting                            sentence.
5712   This is an uninteresting sentence.
5713 @endExample
5714 @endDefreq
5716 @DefreqList {ss, word_space_size [@Var{sentence_space_size}]}
5717 @DefregItem {.ss}
5718 @DefregListEnd {.sss}
5719 @cindex word space size register (@code{.ss})
5720 @cindex size of word space register (@code{.ss})
5721 @cindex space between words register (@code{.ss})
5722 @cindex sentence space size register (@code{.sss})
5723 @cindex size of sentence space register (@code{.sss})
5724 @cindex space between sentences register (@code{.sss})
5725 Change the minimum size of a space between filled words.  It takes its
5726 units as one twelfth of the space width parameter for the current
5727 font.  Initially both the @var{word_space_size} and
5728 @var{sentence_space_size} are@w{ }12.
5730 @cindex fill mode
5731 @cindex mode, fill
5732 If two arguments are given to the @code{ss} request, the second
5733 argument sets the sentence space size.  If the second argument is not
5734 given, sentence space size is set to @var{word_space_size}.  The
5735 sentence space size is used in two circumstances: If the end of a
5736 sentence occurs at the end of a line in fill mode, then both an
5737 inter-word space and a sentence space are added; if two spaces follow
5738 the end of a sentence in the middle of a line, then the second space
5739 is a sentence space.  If a second argument is never given to the
5740 @code{ss} request, the behaviour of @acronym{UNIX} @code{troff} is the
5741 same as that exhibited by GNU @code{troff}.  In GNU @code{troff}, as
5742 in @acronym{UNIX} @code{troff}, a sentence should always be followed
5743 by either a newline or two spaces.
5745 The read-only number registers @code{.ss} and @code{.sss} hold the
5746 values of the parameters set by the first and second arguments of the
5747 @code{ss} request.
5749 The word space and sentence space values are associated with the current
5750 environment (@pxref{Environments}).
5752 Contrary to @acronym{AT&T} @code{troff}, this request is @emph{not}
5753 ignored if a TTY output device is used; the given values are then
5754 rounded down to a multiple of@w{ }12 (@pxref{Implementation Differences}).
5756 The request is ignored if there is no parameter.
5757 @endDefreq
5759 @DefreqList {ce, [@Var{nnn}]}
5760 @DefregListEnd {.ce}
5761 @cindex centering lines (@code{ce})
5762 @cindex lines, centering (@code{ce})
5763 Center text.  While the @w{@samp{.ad c}} request also centers text,
5764 it fills the text as well.  @code{ce} does not fill the
5765 text it affects.  This request causes a break.  The number of lines
5766 still to be centered is associated with the current environment
5767 (@pxref{Environments}).
5769 The following example demonstrates the differences.
5770 Here the input:
5772 @Example
5773 .ll 4i
5774 .ce 1000
5775 This is a small text fragment which shows the differences
5776 between the `.ce' and the `.ad c' request.
5777 .ce 0
5779 .ad c
5780 This is a small text fragment which shows the differences
5781 between the `.ce' and the `.ad c' request.
5782 @endExample
5784 @noindent
5785 And here the result:
5787 @Example
5788   This is a small text fragment which
5789          shows the differences
5790 between the `.ce' and the `.ad c' request.
5792   This is a small text fragment which
5793 shows the differences between the `.ce'
5794         and the `.ad c' request.
5795 @endExample
5797 With no arguments, @code{ce} centers the next line of text.  @var{nnn}
5798 specifies the number of lines to be centered.  If the argument is zero
5799 or negative, centering is disabled.
5801 The basic length for centering text is the line length (as set with the
5802 @code{ll} request) minus the indentation (as set with the @code{in}
5803 request).  Temporary indentation is ignored.
5805 As can be seen in the previous example, it is a common idiom to turn
5806 on centering for a large number of lines, and to turn off centering
5807 after text to be centered.  This is useful for any request which takes
5808 a number of lines as an argument.
5810 The @code{.ce} read-only number register contains the number of lines
5811 remaining to be centered, as set by the @code{ce} request.
5812 @endDefreq
5814 @DefreqList {rj, [@Var{nnn}]}
5815 @DefregListEnd {.rj}
5816 @cindex justifying text (@code{rj})
5817 @cindex text, justifying (@code{rj})
5818 @cindex right-justifying (@code{rj})
5819 Justify unfilled text to the right margin.  Arguments are identical to
5820 the @code{ce} request.  The @code{.rj} read-only number register is
5821 the number of lines to be right-justified as set by the @code{rj}
5822 request.  This request causes a break.  The number of lines still to be
5823 right-justified is associated with the current environment
5824 (@pxref{Environments}).
5825 @endDefreq
5828 @c =====================================================================
5830 @node Manipulating Hyphenation, Manipulating Spacing, Manipulating Filling and Adjusting, gtroff Reference
5831 @section Manipulating Hyphenation
5832 @cindex manipulating hyphenation
5833 @cindex hyphenation, manipulating
5835 As discussed in @ref{Hyphenation}, @code{gtroff} hyphenates words.
5836 There are a number of ways to influence hyphenation.
5838 @DefreqList {hy, [@Var{mode}]}
5839 @DefregListEnd {.hy}
5840 Enable hyphenation.  The request has an optional numeric argument,
5841 @var{mode}, to restrict hyphenation if necessary:
5843 @table @code
5844 @item 1
5845 The default argument if @var{mode} is omitted.  Hyphenate without
5846 restrictions.  This is also the start-up value of @code{gtroff}.
5848 @item 2
5849 Do not hyphenate the last word on a page or column.
5851 @item 4
5852 Do not hyphenate the last two characters of a word.
5854 @item 8
5855 Do not hyphenate the first two characters of a word.
5856 @end table
5858 Values in the previous table are additive.  For example, the value@w{
5859 }12 causes @code{gtroff} to neither hyphenate the last two nor the first
5860 two characters of a word.
5862 @cindex hyphenation restrictions register (@code{.hy})
5863 The current hyphenation restrictions can be found in the read-only
5864 number register @samp{.hy}.
5866 The hyphenation mode is associated with the current environment
5867 (@pxref{Environments}).
5868 @endDefreq
5870 @Defreq {nh, }
5871 Disable hyphenation (i.e., set the hyphenation mode to zero).  Note
5872 that the hyphenation mode of the last call to @code{hy} is not
5873 remembered.
5875 The hyphenation mode is associated with the current environment
5876 (@pxref{Environments}).
5877 @endDefreq
5879 @DefreqList {hlm, [@Var{nnn}]}
5880 @DefregItem {.hlm}
5881 @DefregListEnd {.hlc}
5882 @cindex explicit hyphen (@code{\%})
5883 @cindex hyphen, explicit (@code{\%})
5884 @cindex consecutive hyphenated lines (@code{hlm})
5885 @cindex lines, consecutive hyphenated (@code{hlm})
5886 @cindex hyphenated lines, consecutive (@code{hlm})
5887 Set the maximum number of consecutive hyphenated lines to @var{nnn}.
5888 If this number is negative, there is no maximum.  The default value
5889 is@w{ }@minus{}1 if @var{nnn} is omitted.  This value is associated
5890 with the current environment (@pxref{Environments}).  Only lines
5891 output from a given environment count towards the maximum associated
5892 with that environment.  Hyphens resulting from @code{\%} are counted;
5893 explicit hyphens are not.
5895 The current setting of @code{hlm} is available in the @code{.hlm}
5896 read-only number register.  Also the number of immediately preceding
5897 consecutive hyphenated lines are available in the read-only number
5898 register @samp{.hlc}.
5899 @endDefreq
5901 @Defreq {hw, word1 word2 @dots{}}
5902 Define how @var{word1}, @var{word2}, etc.@: are to be hyphenated.  The
5903 words must be given with hyphens at the hyphenation points.  For
5904 example:
5906 @Example
5907 .hw in-sa-lub-rious
5908 @endExample
5910 @noindent
5911 Besides the space character, any character whose hyphenation code value
5912 is zero can be used to separate the arguments of @code{hw} (see the
5913 documentation for the @code{hcode} request below for more information).
5914 In addition, this request can be used more than once.
5916 Hyphenation exceptions specified with the @code{hw} request are
5917 associated with the current hyphenation language; it causes an error
5918 if there is no current hyphenation language.
5920 This request is ignored if there is no parameter.
5922 In old versions of @code{troff} there was a limited amount of space to
5923 store such information; fortunately, with @code{gtroff}, this is no
5924 longer a restriction.
5925 @endDefreq
5927 @DefescList {\\%, , , }
5928 @deffnx Escape @t{\:}
5929 @ifnotinfo
5930 @esindex \:
5931 @end ifnotinfo
5932 @ifinfo
5933 @esindex @r{<colon>}
5934 @end ifinfo
5935 @cindex hyphenation character (@code{\%})
5936 @cindex character, hyphenation (@code{\%})
5937 @cindex disabling hyphenation (@code{\%})
5938 @cindex hyphenation, disabling (@code{\%})
5939 To tell @code{gtroff} how to hyphenate words on the fly, use the
5940 @code{\%} escape, also known as the @dfn{hyphenation character}.
5941 Preceding a word with this character prevents it from being
5942 hyphenated; putting it inside a word indicates to @code{gtroff} that
5943 the word may be hyphenated at that point.  Note that this mechanism
5944 only affects that one occurrence of the word; to change the
5945 hyphenation of a word for the entire document, use the @code{hw}
5946 request.
5948 The @code{\:} escape inserts a zero-width break point
5949 (that is, the word breaks but without adding a hyphen).
5951 @Example
5952 ... check the /var/log/\:httpd/\:access_log file ...
5953 @endExample
5955 @cindex @code{\X}, followed by @code{\%}
5956 @cindex @code{\Y}, followed by @code{\%}
5957 @cindex @code{\%}, following @code{\X} or @code{\Y}
5958 Note that @code{\X} and @code{\Y} start a word, that is, the @code{\%}
5959 escape in (say) @w{@samp{ \X'...'\%foobar}} and
5960 @w{@samp{ \Y'...'\%foobar}} no longer prevents hyphenation but inserts
5961 a hyphenation point at the beginning of @samp{foobar}; most likely
5962 this isn't what you want to do.
5963 @endDefesc
5965 @Defreq {hc, [@Var{char}]}
5966 Change the hyphenation character to @var{char}.  This character then
5967 works the same as the @code{\%} escape, and thus, no longer appears in
5968 the output.  Without an argument, @code{hc} resets the hyphenation
5969 character to be @code{\%} (the default) only.
5971 The hyphenation character is associated with the current environment
5972 (@pxref{Environments}).
5973 @endDefreq
5975 @DefreqList {hpf, pattern_file}
5976 @DefreqItem {hpfa, pattern_file}
5977 @DefreqListEnd {hpfcode, a b [c d @dots{}]}
5978 @cindex hyphenation patterns (@code{hpf})
5979 @cindex patterns for hyphenation (@code{hpf})
5980 Read in a file of hyphenation patterns.  This file is searched for in
5981 the same way as @file{@var{name}.tmac} (or @file{tmac.@var{name}}) is
5982 searched for if the @option{-m@var{name}} option is specified.
5984 It should have the same format as (simple) @TeX{} patterns files.
5985 More specifically, the following scanning rules are implemented.
5987 @itemize @bullet
5988 @item
5989 A percent sign starts a comment (up to the end of the line)
5990 even if preceded by a backslash.
5992 @item
5993 No support for `digraphs' like @code{\$}.
5995 @item
5996 @code{^^@var{xx}} (@var{x} is 0-9 or a-f) and @code{^^@var{x}} (character
5997 code of @var{x} in the range 0-127) are recognized; other use of @code{^}
5998 causes an error.
6000 @item
6001 No macro expansion.
6003 @item
6004 @code{hpf} checks for the expression @code{\patterns@{@dots{}@}}
6005 (possibly with whitespace before and after the braces).
6006 Everything between the braces is taken as hyphenation patterns.
6007 Consequently, @code{@{} and @code{@}} are not allowed in patterns.
6009 @item
6010 Similarly, @code{\hyphenation@{@dots{}@}} gives a list of hyphenation
6011 exceptions.
6013 @item
6014 @code{\endinput} is recognized also.
6016 @item
6017 For backwards compatibility, if @code{\patterns} is missing,
6018 the whole file is treated as a list of hyphenation patterns
6019 (only recognizing the @code{%} character as the start of a comment).
6020 @end itemize
6022 If no @code{hpf} request is specified (either in the document or in a
6023 macro package), @code{gtroff} won't hyphenate at all.
6025 The @code{hpfa} request appends a file of patterns to the current list.
6027 The @code{hpfcode} request defines mapping values for character codes in
6028 hyphenation patterns.  @code{hpf} or @code{hpfa} then apply the mapping
6029 (after reading the patterns) before replacing or appending them to
6030 the current list of patterns.  Its arguments are pairs of character codes
6031 -- integers from 0 to@w{ }255.  The request maps character code@w{ }@var{a}
6032 to code@w{ }@var{b}, code@w{ }@var{c} to code@w{ }@var{d}, and so on.  You
6033 can use character codes which would be invalid otherwise.
6035 @pindex troffrc
6036 @pindex troffrc-end
6037 @pindex hyphen.us
6038 The set of hyphenation patterns is associated with the current language
6039 set by the @code{hla} request.  The @code{hpf} request is usually
6040 invoked by the @file{troffrc} or @file{troffrc-end} file; by default,
6041 @file{troffrc} loads hyphenation patterns for American English (in file
6042 @file{hyphen.us}).
6044 A second call to @code{hpf} (for the same language) will replace the
6045 hyphenation patterns with the new ones.
6047 Invoking @code{hpf} causes an error if there is no current hyphenation
6048 language.
6049 @endDefreq
6051 @Defreq {hcode, c1 code1 c2 code2 @dots{}}
6052 @cindex hyphenation code (@code{hcode})
6053 @cindex code, hyphenation (@code{hcode})
6054 Set the hyphenation code of character @var{c1} to @var{code1}, that of
6055 @var{c2} to @var{code2}, etc.  A hyphenation code must be a single
6056 input character (not a special character) other than a digit or a
6057 space.  Initially each lower-case letter (@samp{a}-@samp{z}) has its
6058 hyphenation code set to itself, and each upper-case letter
6059 (@samp{A}-@samp{Z}) has a hyphenation code which is the lower-case
6060 version of itself.
6062 This request is ignored if it has no parameter.
6063 @endDefreq
6065 @DefreqList {hym, [@Var{length}]}
6066 @DefregListEnd {.hym}
6067 @cindex hyphenation margin (@code{hym})
6068 @cindex margin for hyphenation (@code{hym})
6069 @cindex @code{ad} request, and hyphenation margin
6070 Set the (right) hyphenation margin to @var{length}.  If the current
6071 adjustment mode is not @samp{b} or @samp{n}, the line is not
6072 hyphenated if it is shorter than @var{length}.  Without an argument,
6073 the hyphenation margin is reset to its default value, which is@w{ }0.
6074 The default scaling indicator for this request is @samp{m}.  The
6075 hyphenation margin is associated with the current environment
6076 (@pxref{Environments}).
6078 A negative argument resets the hyphenation margin to zero, emitting
6079 a warning of type @samp{range}.
6081 @cindex hyphenation margin register (@code{.hym})
6082 The current hyphenation margin is available in the @code{.hym} read-only
6083 number register.
6084 @endDefreq
6086 @DefreqList {hys, [@Var{hyphenation_space}]}
6087 @DefregListEnd {.hys}
6088 @cindex hyphenation space (@code{hys})
6089 @cindex @code{ad} request, and hyphenation space
6090 Set the hyphenation space to @var{hyphenation_space}.  If the current
6091 adjustment mode is @samp{b} or @samp{n}, don't hyphenate the line
6092 if it can be justified by adding no more than @var{hyphenation_space}
6093 extra space to each word space.  Without argument, the hyphenation
6094 space is set to its default value, which is@w{ }0.  The default
6095 scaling indicator for this request is @samp{m}.  The hyphenation
6096 space is associated with the current environment
6097 (@pxref{Environments}).
6099 A negative argument resets the hyphenation space to zero, emitting a
6100 warning of type @samp{range}.
6102 @cindex hyphenation space register (@code{.hys})
6103 The current hyphenation space is available in the @code{.hys} read-only
6104 number register.
6105 @endDefreq
6107 @Defreq {shc, [@Var{glyph}]}
6108 @cindex soft hyphen character, setting (@code{shc})
6109 @cindex character, soft hyphen, setting (@code{shc})
6110 @cindex glyph, soft hyphen (@code{hy})
6111 @cindex soft hyphen glyph (@code{hy})
6112 @cindex @code{char} request, and soft hyphen character
6113 @cindex @code{tr} request, and soft hyphen character
6114 Set the @dfn{soft hyphen character} to @var{glyph}.@footnote{@dfn{Soft
6115 hyphen character} is a misnomer since it is an output glyph.}  If the
6116 argument is omitted, the soft hyphen character is set to the default
6117 glyph @code{\(hy} (this is the start-up value of @code{gtroff} also).
6118 The soft hyphen character is the glyph that is inserted when a word is
6119 hyphenated at a line break.  If the soft hyphen character does not
6120 exist in the font of the character immediately preceding a potential
6121 break point, then the line is not broken at that point.  Neither
6122 definitions (specified with the @code{char} request) nor translations
6123 (specified with the @code{tr} request) are considered when finding the
6124 soft hyphen character.
6125 @endDefreq
6127 @DefreqList {hla, language}
6128 @DefregListEnd {.hla}
6129 @cindex @code{hpf} request, and hyphenation language
6130 @cindex @code{hw} request, and hyphenation language
6131 @pindex troffrc
6132 @pindex troffrc-end
6133 Set the current hyphenation language to the string @var{language}.
6134 Hyphenation exceptions specified with the @code{hw} request and
6135 hyphenation patterns specified with the @code{hpf} and @code{hpfa}
6136 requests are both associated with the current hyphenation language.
6137 The @code{hla} request is usually invoked by the @file{troffrc} or the
6138 @file{troffrc-end} files; @file{troffrc} sets the default language to
6139 @samp{us}.
6141 @cindex hyphenation language register (@code{.hla})
6142 The current hyphenation language is available as a string in the
6143 read-only number register @samp{.hla}.
6145 @Example
6146 .ds curr_language \n[.hla]
6147 \*[curr_language]
6148     @result{} us
6149 @endExample
6150 @endDefreq
6153 @c =====================================================================
6155 @node Manipulating Spacing, Tabs and Fields, Manipulating Hyphenation, gtroff Reference
6156 @section Manipulating Spacing
6157 @cindex manipulating spacing
6158 @cindex spacing, manipulating
6160 @Defreq {sp, [@Var{distance}]}
6161 Space downwards @var{distance}.  With no argument it advances 1@w{
6162 }line.  A negative argument causes @code{gtroff} to move up the page
6163 the specified distance.  If the argument is preceded by a @samp{|}
6164 then @code{gtroff} moves that distance from the top of the page.  This
6165 request causes a line break.  The default scaling indicator is @samp{v}.
6166 @endDefreq
6168 @DefreqList {ls, [@Var{nnn}]}
6169 @DefregListEnd {.L}
6170 @cindex double-spacing (@code{ls})
6171 Output @w{@var{nnn}@minus{}1} blank lines after each line of text.
6172 With no argument, @code{gtroff} uses the previous value before the
6173 last @code{ls} call.
6175 @Example
6176 .ls 2    \" This causes double-spaced output
6177 .ls 3    \" This causes triple-spaced output
6178 .ls      \" Again double-spaced
6179 @endExample
6181 The line spacing is associated with the current environment
6182 (@pxref{Environments}).
6184 @cindex line spacing register (@code{.L})
6185 The read-only number register @code{.L} contains the current line
6186 spacing setting.
6187 @endDefreq
6189 @xref{Changing Type Sizes}, for the requests @code{vs} and @code{pvs}
6190 as alternatives to @code{ls}.
6192 @DefescList {\\x, ', spacing, '}
6193 @DefregListEnd {.a}
6194 Sometimes, extra vertical spacing is only needed occasionally, e.g.@:
6195 to allow space for a tall construct (like an equation).  The @code{\x}
6196 escape does this.  The escape is given a numerical argument, usually
6197 enclosed in quotes (like @samp{\x'3p'}); the default scaling indicator
6198 is @samp{v}.  If this number is positive extra vertical space is
6199 inserted below the current line.  A negative number adds space above.
6200 If this escape is used multiple times on the same line, the maximum of
6201 the values is used.
6203 @xref{Escapes}, for details on parameter delimiting characters.
6205 @cindex extra post-vertical line space register (@code{.a})
6206 The @code{.a} read-only number register contains the most recent
6207 (nonnegative) extra vertical line space.
6209 Using @code{\x} can be necessary in combination with the @code{\b}
6210 escape, as the following example shows.
6212 @Example
6213 This is a test with the \[rs]b escape.
6215 This is a test with the \[rs]b escape.
6217 This is a test with \b'xyz'\x'-1m'\x'1m'.
6219 This is a test with the \[rs]b escape.
6221 This is a test with the \[rs]b escape.
6222 @endExample
6224 @noindent
6225 produces
6227 @Example
6228 This is a test with the \b escape.
6229 This is a test with the \b escape.
6230                     x
6231 This is a test with y.
6232                     z
6233 This is a test with the \b escape.
6234 This is a test with the \b escape.
6235 @endExample
6236 @endDefesc
6238 @DefreqList {ns, }
6239 @DefreqItem {rs, }
6240 @DefregListEnd {.ns}
6241 @cindex @code{sp} request, and no-space mode
6242 @cindex no-space mode (@code{ns})
6243 @cindex mode, no-space (@code{ns})
6244 @cindex blank lines, disabling
6245 @cindex lines, blank, disabling
6246 Enable @dfn{no-space mode}.  In this mode, spacing (either via
6247 @code{sp} or via blank lines) is disabled.  The @code{bp} request to
6248 advance to the next page is also disabled, except if it is accompanied
6249 by a page number (see @ref{Page Control}, for more information).  This
6250 mode ends when actual text is output or the @code{rs} request is
6251 encountered which ends no-space mode.  The read-only number register
6252 @code{.ns} is set to@w{ }1 as long as no-space mode is active.
6254 This request is useful for macros that conditionally
6255 insert vertical space before the text starts
6256 (for example, a paragraph macro could insert some space
6257 except when it is the first paragraph after a section header).
6258 @endDefreq
6261 @c =====================================================================
6263 @node Tabs and Fields, Character Translations, Manipulating Spacing, gtroff Reference
6264 @section Tabs and Fields
6265 @cindex tabs, and fields
6266 @cindex fields, and tabs
6268 @cindex @acronym{EBCDIC} encoding of a tab
6269 A tab character (@acronym{ASCII} char@w{ }9, @acronym{EBCDIC} char@w{
6270 }5) causes a horizontal movement to the next tab stop (much
6271 like it did on a typewriter).
6273 @Defesc {\\t, , , }
6274 @cindex tab character, non-interpreted (@code{\t})
6275 @cindex character, tab, non-interpreted (@code{\t})
6276 This escape is a non-interpreted tab character.  In copy mode
6277 (@pxref{Copy-in Mode}), @code{\t} is the same as a real tab character.
6278 @endDefesc
6280 @DefreqList {ta, [@Var{n1} @Var{n2} @dots{} @Var{nn} @t{T} @Var{r1} @Var{r2} @dots{} @Var{rn}]}
6281 @DefregListEnd {.tabs}
6282 Change tab stop positions.  This request takes a series of tab
6283 specifiers as arguments (optionally divided into two groups with the
6284 letter @samp{T}) which indicate where each tab stop is to be
6285 (overriding any previous settings).
6287 Tab stops can be specified absolutely, i.e., as the distance from the
6288 left margin.  For example, the following sets 6@w{ }tab stops every
6289 one inch.
6291 @Example
6292 .ta 1i 2i 3i 4i 5i 6i
6293 @endExample
6295 Tab stops can also be specified using a leading @samp{+}
6296 which means that the specified tab stop is set relative to
6297 the previous tab stop.  For example, the following is equivalent to the
6298 previous example.
6300 @Example
6301 .ta 1i +1i +1i +1i +1i +1i
6302 @endExample
6304 @code{gtroff} supports an extended syntax to specify repeat values after
6305 the @samp{T} mark (these values are always taken as relative) -- this is
6306 the usual way to specify tabs set at equal intervals.  The following is,
6307 yet again, the same as the previous examples.  It does even more since
6308 it defines an infinite number of tab stops separated by one inch.
6310 @Example
6311 .ta T 1i
6312 @endExample
6314 Now we are ready to interpret the full syntax given at the beginning:
6315 Set tabs at positions @var{n1}, @var{n2}, @dots{}, @var{nn} and then set
6316 tabs at @var{nn}+@var{r1}, @var{nn}+@var{r2}, @dots{}, @var{nn}+@var{rn}
6317 and then at @var{nn}+@var{rn}+@var{r1}, @var{nn}+@var{rn}+@var{r2},
6318 @dots{}, @var{nn}+@var{rn}+@var{rn}, and so on.
6320 Example: @samp{4c +6c T 3c 5c 2c} is equivalent to @samp{4c 10c 13c 18c
6321 20c 23c 28c 30c @dots{}}.
6323 The material in each tab column (i.e., the column between two tab stops)
6324 may be justified to the right or left or centered in the column.  This
6325 is specified by appending @samp{R}, @samp{L}, or @samp{C} to the tab
6326 specifier.  The default justification is @samp{L}.  Example:
6328 @Example
6329 .ta 1i 2iC 3iR
6330 @endExample
6332 Some notes:
6334 @itemize @bullet
6335 @item
6336 The default unit of the @code{ta} request is @samp{m}.
6338 @item
6339 A tab stop is converted into a non-breakable horizontal movement which
6340 can be neither stretched nor squeezed.  For example,
6342 @Example
6343 .ds foo a\tb\tc
6344 .ta T 5i
6345 \*[foo]
6346 @endExample
6348 @noindent
6349 creates a single line which is a bit longer than 10@w{ }inches (a string
6350 is used to show exactly where the tab characters are).  Now consider the
6351 following:
6353 @Example
6354 .ds bar a\tb b\tc
6355 .ta T 5i
6356 \*[bar]
6357 @endExample
6359 @noindent
6360 @code{gtroff} first converts the tab stops of the line into unbreakable
6361 horizontal movements, then splits the line after the second @samp{b}
6362 (assuming a sufficiently short line length).  Usually, this isn't what
6363 the user wants.
6365 @item
6366 Superfluous tabs (i.e., tab characters which do not correspond to a tab
6367 stop) are ignored except the first one which delimits the characters
6368 belonging to the last tab stop for right-justifying or centering.
6369 Consider the following example
6371 @Example
6372 .ds Z   foo\tbar\tfoo
6373 .ds ZZ  foo\tbar\tfoobar
6374 .ds ZZZ foo\tbar\tfoo\tbar
6375 .ta 2i 4iR
6376 \*[Z]
6378 \*[ZZ]
6380 \*[ZZZ]
6382 @endExample
6384 @noindent
6385 which produces the following output:
6387 @Example
6388 foo                 bar              foo
6389 foo                 bar           foobar
6390 foo                 bar              foobar
6391 @endExample
6393 @noindent
6394 The first line right-justifies the second `foo' relative to the tab
6395 stop.  The second line right-justifies `foobar'.  The third line finally
6396 right-justifies only `foo' because of the additional tab character which
6397 marks the end of the string belonging to the last defined tab stop.
6399 @item
6400 Tab stops are associated with the current environment
6401 (@pxref{Environments}).
6403 @item
6404 Calling @code{ta} without an argument removes all tab stops.
6406 @item
6407 @cindex tab stops, for TTY output devices
6408 The start-up value of @code{gtroff} is @w{@samp{T 0.5i}} in troff mode
6409 and @w{@samp{T 0.8i}} in nroff mode (the latter is done with an
6410 explicit call to the @code{ta} request in the file @file{tty.tmac}.
6411 @end itemize
6413 @cindex tab settings register (@code{.tabs})
6414 The read-only number register @code{.tabs} contains a string
6415 representation of the current tab settings suitable for use as an
6416 argument to the @code{ta} request.
6418 @Example
6419 .ds tab-string \n[.tabs]
6420 \*[tab-string]
6421     @result{} T120u
6422 @endExample
6424 @cindex @code{.S} register, Plan@w{ }9 alias for @code{.tabs}
6425 @cindex @code{.tabs} register, Plan@w{ }9 alias (@code{.S})
6426 The @code{troff} version of the Plan@w{ }9 operating system uses
6427 register @code{.S} for the same purpose.
6428 @endDefreq
6430 @Defreq {tc, [@Var{fill-glyph}]}
6431 @cindex tab repetition character (@code{tc})
6432 @cindex character, tab repetition (@code{tc})
6433 @cindex glyph, tab repetition (@code{tc})
6434 Normally @code{gtroff} fills the space to the next tab stop with
6435 whitespace.  This can be changed with the @code{tc} request.  With no
6436 argument @code{gtroff} reverts to using whitespace, which is the
6437 default.  The value of this @dfn{tab repetition character} is
6438 associated with the current environment
6439 (@pxref{Environments}).@footnote{@dfn{Tab repetition character} is a
6440 misnomer since it is an output glyph.}
6441 @endDefreq
6443 @DefreqList {linetabs, n}
6444 @DefregListEnd {.linetabs}
6445 @cindex tab, line-tabs mode
6446 @cindex line-tabs mode
6447 @cindex mode, line-tabs
6448 If @var{n} is missing or not zero, enable @dfn{line-tabs} mode,
6449 or disable it otherwise (the default).
6450 In line-tabs mode, @code{gtroff} computes tab distances
6451 relative to the (current) output line instead of the input line.
6453 For example, the following code:
6455 @Example
6456 .ds x a\t\c
6457 .ds y b\t\c
6458 .ds z c
6459 .ta 1i 3i
6463 @endExample
6465 @noindent
6466 in normal mode, results in the output
6468 @Example
6469 a         b         c
6470 @endExample
6472 @noindent
6473 in line-tabs mode, the same code outputs
6475 @Example
6476 a         b                   c
6477 @endExample
6479 Line-tabs mode is associated with the current environment.
6480 The read-only register @code{.linetabs} is set to@w{ }1 if in line-tabs
6481 mode, and 0 in normal mode.
6482 @endDefreq
6484 @menu
6485 * Leaders::
6486 * Fields::
6487 @end menu
6489 @c ---------------------------------------------------------------------
6491 @node Leaders, Fields, Tabs and Fields, Tabs and Fields
6492 @subsection Leaders
6493 @cindex leaders
6495 Sometimes it may may be desirable to use the @code{tc} request to fill a
6496 particular tab stop with a given glyph (for example dots in a table
6497 of contents), but also normal tab stops on the rest of the line.  For
6498 this @code{gtroff} provides an alternate tab mechanism, called
6499 @dfn{leaders} which does just that.
6501 @cindex leader character
6502 A leader character (character code@w{ }1) behaves similarly to a tab
6503 character: It moves to the next tab stop.  The only difference is that
6504 for this movement, the fill glyph defaults to a period character and
6505 not to space.
6507 @Defesc {\\a, , , }
6508 @cindex leader character, non-interpreted (@code{\a})
6509 @cindex character, leader, non-interpreted (@code{\a})
6510 This escape is a non-interpreted leader character.  In copy mode
6511 (@pxref{Copy-in Mode}), @code{\a} is the same as a real leader
6512 character.
6513 @endDefesc
6515 @Defreq {lc, [@Var{fill-glyph}]}
6516 @cindex leader repetition character (@code{lc})
6517 @cindex character, leader repetition (@code{lc})
6518 @cindex glyph, leader repetition (@code{lc})
6519 Declare the @dfn{leader repetition character}.@footnote{@dfn{Leader
6520 repetition character} is a misnomer since it is an output glyph.}
6521 Without an argument, leaders act the same as tabs (i.e., using
6522 whitespace for filling).  @code{gtroff}'s start-up value is a dot
6523 (@samp{.}).  The value of the leader repetition character is
6524 associated with the current environment (@pxref{Environments}).
6525 @endDefreq
6527 @cindex table of contents
6528 @cindex contents, table of
6529 For a table of contents, to name an example, tab stops may be defined so
6530 that the section number is one tab stop, the title is the second with
6531 the remaining space being filled with a line of dots, and then the page
6532 number slightly separated from the dots.
6534 @Example
6535 .ds entry 1.1\tFoo\a\t12
6536 .lc .
6537 .ta 1i 5i +.25i
6538 \*[entry]
6539 @endExample
6541 @noindent
6542 This produces
6544 @Example
6545 1.1  Foo..........................................  12
6546 @endExample
6548 @c ---------------------------------------------------------------------
6550 @node Fields,  , Leaders, Tabs and Fields
6551 @subsection Fields
6552 @cindex fields
6554 @cindex field delimiting character (@code{fc})
6555 @cindex delimiting character, for fields (@code{fc})
6556 @cindex character, field delimiting (@code{fc})
6557 @cindex field padding character (@code{fc})
6558 @cindex padding character, for fields (@code{fc})
6559 @cindex character, field padding (@code{fc})
6560 @dfn{Fields} are a more general way of laying out tabular data.  A field
6561 is defined as the data between a pair of @dfn{delimiting characters}.
6562 It contains substrings which are separated by @dfn{padding characters}.
6563 The width of a field is the distance on the @emph{input} line from the
6564 position where the field starts to the next tab stop.  A padding
6565 character inserts stretchable space similar to @TeX{}'s @code{\hss}
6566 command (thus it can even be negative) to make the sum of all substring
6567 lengths plus the stretchable space equal to the field width.  If more
6568 than one padding character is inserted, the available space is evenly
6569 distributed among them.
6571 @Defreq {fc, [@Var{delim-char} [@Var{padding-char}]]}
6572 Define a delimiting and a padding character for fields.  If the latter
6573 is missing, the padding character defaults to a space character.  If
6574 there is no argument at all, the field mechanism is disabled (which is
6575 the default).  Note that contrary to e.g.@: the tab repetition
6576 character, delimiting and padding characters are @emph{not} associated
6577 to the current environment (@pxref{Environments}).
6579 Example:
6581 @Example
6582 .fc # ^
6583 .ta T 3i
6584 #foo^bar^smurf#
6586 #foo^^bar^smurf#
6587 @endExample
6589 @noindent
6590 and here the result:
6592 @Example
6593 foo         bar          smurf
6594 foo            bar       smurf
6595 @endExample
6596 @endDefreq
6599 @c =====================================================================
6601 @node Character Translations, Troff and Nroff Mode, Tabs and Fields, gtroff Reference
6602 @section Character Translations
6603 @cindex character translations
6604 @cindex translations of characters
6606 @cindex control character, changing (@code{cc})
6607 @cindex character, control, changing (@code{cc})
6608 @cindex no-break control character, changing (@code{c2})
6609 @cindex character, no-break control, changing (@code{c2})
6610 @cindex control character, no-break, changing (@code{c2})
6611 The control character (@samp{.}) and the no-break control character
6612 (@samp{'}) can be changed with the @code{cc} and @code{c2} requests,
6613 respectively.
6615 @Defreq {cc, [@Var{c}]}
6616 Set the control character to@w{ }@var{c}.  With no argument the default
6617 control character @samp{.} is restored.  The value of the control
6618 character is associated with the current environment
6619 (@pxref{Environments}).
6620 @endDefreq
6622 @Defreq {c2, [@Var{c}]}
6623 Set the no-break control character to@w{ }@var{c}.  With no argument the
6624 default control character @samp{'} is restored.  The value of the
6625 no-break control character is associated with the current environment
6626 (@pxref{Environments}).
6627 @endDefreq
6629 @Defreq {eo, }
6630 @cindex disabling @code{\} (@code{eo})
6631 @cindex @code{\}, disabling (@code{eo})
6632 Disable the escape mechanism completely.  After executing this
6633 request, the backslash character @samp{\} no longer starts an escape
6634 sequence.
6636 This request can be very helpful in writing macros since it is not
6637 necessary then to double the escape character.  Here an example:
6639 @Example
6640 .\" This is a simplified version of the
6641 .\" .BR request from the man macro package
6643 .de BR
6644 .  ds result \&
6645 .  while (\n[.$] >= 2) \@{\
6646 .    as result \fB\$1\fR\$2
6647 .    shift 2
6648 .  \@}
6649 .  if \n[.$] .as result \fB\$1
6650 \*[result]
6651 .  ft R
6654 @endExample
6655 @endDefreq
6657 @Defreq {ec, [@Var{c}]}
6658 @cindex escape character, changing (@code{ec})
6659 @cindex character, escape, changing (@code{ec})
6660 Set the escape character to@w{ }@var{c}.  With no argument the default
6661 escape character @samp{\} is restored.  It can be also used to
6662 re-enable the escape mechanism after an @code{eo} request.
6664 Note that changing the escape character globally will likely break
6665 macro packages since @code{gtroff} has no mechanism to `intern' macros,
6666 i.e., to convert a macro definition into an internal form which is
6667 independent of its representation (@TeX{} has this mechanism).
6668 If a macro is called, it is executed literally.
6669 @endDefreq
6671 @DefreqList {ecs, }
6672 @DefreqListEnd {ecr, }
6673 The @code{ecs} request saves the current escape character
6674 in an internal register.
6675 Use this request in combination with the @code{ec} request to
6676 temporarily change the escape character.
6678 The @code{ecr} request restores the escape character
6679 saved with @code{ecs}.
6680 Without a previous call to @code{ecs}, this request
6681 sets the escape character to @code{\}.
6682 @endDefreq
6684 @DefescList {\\\\, , , }
6685 @DefescItem {\\e, , , }
6686 @DefescListEnd {\\E, , , }
6687 Print the current escape character (which is the backslash character
6688 @samp{\} by default).
6690 @code{\\} is a `delayed' backslash; more precisely, it is the default
6691 escape character followed by a backslash, which no longer has special
6692 meaning due to the leading escape character.  It is @emph{not} an escape
6693 sequence in the usual sense!  In any unknown escape sequence
6694 @code{\@var{X}} the escape character is ignored and @var{X} is printed.
6695 But if @var{X} is equal to the current escape character, no warning is
6696 emitted.
6698 As a consequence, only at top-level or in a diversion a backslash glyph is
6699 printed; in copy-in mode, it expands to a single backslash which then
6700 combines with the following character to an escape sequence.
6702 The @code{\E} escape differs from @code{\e} by printing an escape
6703 character that is not interpreted in copy mode.
6704 Use this to define strings with escapes that work
6705 when used in copy mode (for example, as a macro argument).
6706 The following example defines strings to begin and end
6707 a superscript:
6709 @Example
6710 .ds @{ \v'-.3m'\s'\Es[.s]*60/100'
6711 .ds @} \s0\v'.3m'
6712 @endExample
6714 Another example to demonstrate the differences between the various escape
6715 sequences, using a strange escape character, @samp{-}.
6717 @Example
6718 .ec -
6719 .de xxx
6720 --A'123'
6722 .xxx
6723     @result{} -A'foo'
6724 @endExample
6726 @noindent
6727 The result is surprising for most users, expecting @samp{1} since
6728 @samp{foo} is a valid identifier.  What has happened?  As mentioned
6729 above, the leading escape character makes the following character
6730 ordinary.  Written with the default escape character the sequence
6731 @samp{--} becomes @samp{\-} -- this is the minus sign.
6733 If the escape character followed by itself is a valid escape sequence,
6734 only @code{\E} yields the expected result:
6736 @Example
6737 .ec -
6738 .de xxx
6739 -EA'123'
6741 .xxx
6742     @result{} 1
6743 @endExample
6744 @endDefesc
6746 @Defesc {\\., , , }
6747 Similar to @code{\\}, the sequence @code{\.} isn't a real escape sequence.
6748 As before, a warning message is suppressed if the escape character is
6749 followed by a dot, and the dot itself is printed.
6751 @Example
6752 .de foo
6753 .  nop foo
6755 .  de bar
6756 .    nop bar
6757 \\..
6760 .foo
6761 .bar
6762     @result{} foo bar
6763 @endExample
6765 @noindent
6766 The first backslash is consumed while the macro is read, and the second
6767 is swallowed while exexuting macro @code{foo}.
6768 @endDefesc
6770 A @dfn{translation} is a mapping of an input character to an output
6771 glyph.  The mapping occurs at output time, i.e., the input character
6772 gets assigned the metric information of the mapped output character
6773 right before input tokens are converted to nodes (@pxref{Gtroff
6774 Internals}, for more on this process).
6776 @DefreqList {tr, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
6777 @DefreqListEnd {trin, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
6778 Translate character @var{a} to glyph@w{ }@var{b}, character @var{c} to
6779 glyph@w{ }@var{d}, etc.  If there is an odd number of arguments, the
6780 last one is translated to an unstretchable space (@w{@samp{\ }}).
6782 The @code{trin} request is identical to @code{tr},
6783 but when you unformat a diversion with @code{asciify}
6784 it ignores the translation.
6785 @xref{Diversions}, for details about the @code{asciify} request.
6787 Some notes:
6789 @itemize @bullet
6790 @item
6791 @cindex @code{\(}, and translations
6792 @cindex @code{\[}, and translations
6793 @cindex @code{\'}, and translations
6794 @cindex @code{\`}, and translations
6795 @cindex @code{\-}, and translations
6796 @cindex @code{\_}, and translations
6797 @cindex @code{\C}, and translations
6798 @cindex @code{\N}, and translations
6799 @cindex @code{char} request, and translations
6800 @cindex special characters
6801 @cindex character, special
6802 @cindex numbered glyph (@code{\N})
6803 @cindex glyph, numbered (@code{\N})
6804 Special characters (@code{\(@var{xx}}, @code{\[@var{xxx}]},
6805 @code{\C'@var{xxx}'}, @code{\'}, @code{\`}, @code{\-}, @code{\_}),
6806 glyphs defined with the @code{char} request, and numbered glyphs
6807 (@code{\N'@var{xxx}'}) can be translated also.
6809 @item
6810 @cindex @code{\e}, and translations
6811 The @code{\e} escape can be translated also.
6813 @item
6814 @cindex @code{\%}, and translations
6815 @cindex @code{\~}, and translations
6816 Characters can be mapped onto the @code{\%} and @code{\~} escapes (but
6817 @code{\%} and @code{\~} can't be mapped onto another glyph).
6819 @item
6820 @cindex backspace character, and translations
6821 @cindex character, backspace, and translations
6822 @cindex leader character, and translations
6823 @cindex character, leader, and translations
6824 @cindex newline character, and translations
6825 @cindex character, newline, and translations
6826 @cindex tab character, and translations
6827 @cindex character, tab, and translations
6828 @cindex @code{\a}, and translations
6829 @cindex @code{\t}, and translations
6830 The following characters can't be translated: space (with one exception,
6831 see below), backspace, newline, leader (and @code{\a}), tab (and
6832 @code{\t}).
6834 @item
6835 @cindex @code{shc} request, and translations
6836 Translations are not considered for finding the soft hyphen character
6837 set with the @code{shc} request.
6839 @item
6840 @cindex @code{\&}, and translations
6841 The pair @samp{@var{c}\&} (this is an arbitrary character@w{
6842 }@var{c} followed by the zero width space character) maps this
6843 character to nothing.
6845 @Example
6846 .tr a\&
6847 foo bar
6848     @result{} foo br
6849 @endExample
6851 @noindent
6852 It is even possible to map the space character to nothing:
6854 @Example
6855 .tr aa \&
6856 foo bar
6857     @result{} foobar
6858 @endExample
6860 @noindent
6861 As shown in the example, the space character can't be the first
6862 character/glyph pair as an argument of @code{tr}.  Additionally, it is
6863 not possible to map the space character to any other glyph; requests
6864 like @w{@samp{.tr aa x}} undo @w{@samp{.tr aa \&}} instead.
6866 If justification is active, lines are justified in spite of the
6867 `empty' space character (but there is no minimal distance, i.e.@: the
6868 space character, between words).
6870 @item
6871 After an output glyph has been constructed (this happens at the
6872 moment immediately before the glyph is appended to an output
6873 glyph list, either by direct output, in a macro, diversion, or
6874 string), it is no longer affected by @code{tr}.
6876 @item
6877 Translating character to glyphs where one of them or both are
6878 undefined is possible also; @code{tr} does not check whether the
6879 entities in its argument do exist.
6881 @xref{Gtroff Internals}.
6883 @item
6884 @code{troff} no longer has a hard-coded dependency on @w{Latin-1};
6885 all @code{char@var{XXX}} entities have been removed from the font
6886 description files.  This has a notable consequence which shows up in
6887 warnings like @code{can't find character with input code @var{XXX}}
6888 if the @code{tr} request isn't handled properly.
6890 Consider the following translation:
6892 @Example
6893 .tr @'e@'E
6894 @endExample
6896 @noindent
6897 This maps input character @code{@'e} onto glyph @code{@'E}, which is
6898 identical to glyph @code{char201}.  But this glyph intentionally
6899 doesn't exist!  Instead, @code{\[char201]} is treated as an input
6900 character entity and is by default mapped onto @code{\['E]}, and
6901 @code{gtroff} doesn't handle translations of translations.
6903 The right way to write the above translation is
6905 @Example
6906 .tr @'e\['E]
6907 @endExample
6909 @noindent
6910 With other words, the first argument of @code{tr} should be an input
6911 character or entity, and the second one a glyph entity.
6913 @item
6914 Without an argument, the @code{tr} request is ignored.
6915 @end itemize
6916 @endDefreq
6918 @Defreq {trnt, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
6919 @cindex @code{\!}, and @code{trnt}
6920 @code{trnt} is the same as the @code{tr} request except that the
6921 translations do not apply to text that is transparently throughput
6922 into a diversion with @code{\!}.  @xref{Diversions}, for more
6923 information.
6925 For example,
6927 @Example
6928 .tr ab
6929 .di x
6930 \!.tm a
6933 @endExample
6935 @noindent
6936 prints @samp{b} to the standard error stream; if @code{trnt} is used
6937 instead of @code{tr} it prints @samp{a}.
6938 @endDefreq
6941 @c =====================================================================
6943 @node Troff and Nroff Mode, Line Layout, Character Translations, gtroff Reference
6944 @section Troff and Nroff Mode
6945 @cindex troff mode
6946 @cindex mode, troff
6947 @cindex nroff mode
6948 @cindex mode, nroff
6950 Originally, @code{nroff} and @code{troff} were two separate programs,
6951 the former for TTY output, the latter for everything else.  With GNU
6952 @code{troff}, both programs are merged into one executable, sending
6953 its output to a device driver (@code{grotty} for TTY devices,
6954 @code{grops} for @sc{PostScript}, etc.) which interprets the
6955 intermediate output of @code{gtroff}.  For @acronym{UNIX} @code{troff}
6956 it makes sense to talk about @dfn{Nroff mode} and @dfn{Troff mode}
6957 since the differences are hardcoded.  For GNU @code{troff}, this
6958 distinction is not appropriate because @code{gtroff} simply takes the
6959 information given in the font files for a particular device without
6960 handling requests specially if a TTY output device is used.
6962 Usually, a macro package can be used with all output devices.
6963 Nevertheless, it is sometimes necessary to make a distinction between
6964 TTY and non-TTY devices: @code{gtroff} provides two built-in
6965 conditions @samp{n} and @samp{t} for the @code{if}, @code{ie}, and
6966 @code{while} requests to decide whether @code{gtroff} shall behave
6967 like @code{nroff} or like @code{troff}.
6969 @Defreq {troff, }
6970 @pindex troffrc
6971 @pindex troffrc-end
6972 Make the @samp{t} built-in condition true (and the @samp{n} built-in
6973 condition false) for @code{if}, @code{ie}, and @code{while}
6974 conditional requests.  This is the default if @code{gtroff}
6975 (@emph{not} @code{groff}) is started with the @option{-R} switch to
6976 avoid loading of the start-up files @file{troffrc} and
6977 @file{troffrc-end}.  Without @option{-R}, @code{gtroff} stays in troff
6978 mode if the output device is not a TTY (e.g.@: `ps').
6979 @endDefreq
6981 @Defreq {nroff, }
6982 @pindex tty.tmac
6983 Make the @samp{n} built-in condition true (and the @samp{t} built-in
6984 condition false) for @code{if}, @code{ie}, and @code{while}
6985 conditional requests.  This is the default if @code{gtroff} uses a TTY
6986 output device; the code for switching to nroff mode is in the file
6987 @file{tty.tmac} which is loaded by the start-up file @code{troffrc}.
6988 @endDefreq
6990 @xref{Conditionals and Loops}, for more details on built-in
6991 conditions.
6994 @c =====================================================================
6996 @node Line Layout, Line Control, Troff and Nroff Mode, gtroff Reference
6997 @section Line Layout
6998 @cindex line layout
6999 @cindex layout, line
7001 @cindex dimensions, line
7002 @cindex line dimensions
7003 The following drawing shows the dimensions which @code{gtroff} uses for
7004 placing a line of output onto the page.  They are labeled with the
7005 request which manipulates each dimension.
7007 @Example
7008                 -->| in |<--
7009                    |<-----------ll------------>|
7010               +----+----+----------------------+----+
7011               |    :    :                      :    |
7012               +----+----+----------------------+----+
7013            -->| po |<--
7014               |<--------paper width---------------->|
7015 @endExample
7017 @noindent
7018 These dimensions are:
7020 @ftable @code
7021 @item po
7022 @cindex left margin (@code{po})
7023 @cindex margin, left (@code{po})
7024 @cindex page offset (@code{po})
7025 @cindex offset, page (@code{po})
7026 @dfn{Page offset} -- this is the leftmost position of text on the final
7027 output, defining the @dfn{left margin}.
7029 @item in
7030 @cindex indentation (@code{in})
7031 @cindex line indentation (@code{in})
7032 @dfn{Indentation} -- this is the distance from the left margin where
7033 text is printed.
7035 @item ll
7036 @cindex line length (@code{ll})
7037 @cindex length of line (@code{ll})
7038 @dfn{Line length} -- this is the distance from the left margin to right
7039 margin.
7040 @end ftable
7042 A simple demonstration:
7044 @Example
7045 .ll 3i
7046 This is text without indentation.
7047 The line length has been set to 3\~inch.
7048 .in +.5i
7049 .ll -.5i
7050 Now the left and right margins are both increased.
7053 Calling .in and .ll without parameters restore
7054 the previous values.
7055 @endExample
7057 Result:
7059 @Example
7060 This  is text without indenta-
7061 tion.   The  line  length  has
7062 been set to 3 inch.
7063      Now   the  left  and
7064      right  margins   are
7065      both increased.
7066 Calling  .in  and  .ll without
7067 parameters restore the  previ-
7068 ous values.
7069 @endExample
7071 @DefreqList {po, [@Var{offset}]}
7072 @DefreqItem {po, @t{+}@Var{offset}}
7073 @DefreqItem {po, @t{-}@Var{offset}}
7074 @DefregListEnd {.o}
7075 @pindex troffrc
7076 Set horizontal page offset to @var{offset} (or increment or decrement
7077 the current value by @var{offset}).  Note that this request does not
7078 cause a break, so changing the page offset in the middle of text being
7079 filled may not yield the expected result.  The initial value is
7080 1@dmn{i}.  For TTY output devices, it is set to 0 in the startup file
7081 @file{troffrc}; the default scaling indicator is @samp{m} (and
7082 not @samp{v} as incorrectly documented in the original
7083 @acronym{UNIX} troff manual).
7085 The current page offset can be found in the read-only number register
7086 @samp{.o}.
7088 If @code{po} is called without an argument, the page offset is reset to
7089 the previous value before the last call to @code{po}.
7091 @Example
7092 .po 3i
7093 \n[.o]
7094     @result{} 720
7095 .po -1i
7096 \n[.o]
7097     @result{} 480
7099 \n[.o]
7100     @result{} 720
7101 @endExample
7102 @endDefreq
7104 @DefreqList {in, [@Var{indent}]}
7105 @DefreqItem {in, @t{+}@Var{indent}}
7106 @DefreqItem {in, @t{-}@Var{indent}}
7107 @DefregListEnd {.i}
7108 Set indentation to @var{indent} (or increment or decrement the
7109 current value by @var{indent}).  This request causes a break.
7110 Initially, there is no indentation.
7112 If @code{in} is called without an argument, the indentation is reset to
7113 the previous value before the last call to @code{in}.  The default
7114 scaling indicator is @samp{m}.
7116 The indentation is associated with the current environment
7117 (@pxref{Environments}).
7119 If a negative indentation value is specified (which is not allowed),
7120 @code{gtroff} emits a warning of type @samp{range} and sets the
7121 indentation to zero.
7123 The effect of @code{in} is delayed until a partially collected line (if
7124 it exists) is output.  A temporary indent value is reset to zero also.
7126 The current indentation (as set by @code{in}) can be found in the
7127 read-only number register @samp{.i}.
7128 @endDefreq
7130 @DefreqList {ti, offset}
7131 @DefreqItem {ti, @t{+}@Var{offset}}
7132 @DefreqItem {ti, @t{-}@Var{offset}}
7133 @DefregListEnd {.in}
7134 Temporarily indent the next output line by @var{offset}.  If an
7135 increment or decrement value is specified, adjust the temporary
7136 indentation relative to the value set by the @code{in} request.
7138 This request causes a break; its value is associated with the current
7139 environment (@pxref{Environments}).  The default scaling indicator
7140 is @samp{m}.  A call of @code{ti} without an argument is ignored.
7142 If the total indentation value is negative (which is not allowed),
7143 @code{gtroff} emits a warning of type @samp{range} and sets the
7144 temporary indentation to zero.  `Total indentation' is either
7145 @var{offset} if specified as an absolute value, or the temporary plus
7146 normal indentation, if @var{offset} is given as a relative value.
7148 The effect of @code{ti} is delayed until a partially collected line (if
7149 it exists) is output.
7151 The read-only number register @code{.in} is the indentation that applies
7152 to the current output line.
7154 The difference between @code{.i} and @code{.in} is that the latter takes
7155 into account whether a partially collected line still uses the old
7156 indentation value or a temporary indentation value is active.
7157 @endDefreq
7159 @DefreqList {ll, [@Var{length}]}
7160 @DefreqItem {ll, @t{+}@Var{length}}
7161 @DefreqItem {ll, @t{-}@Var{length}}
7162 @DefregItem {.l}
7163 @DefregListEnd {.ll}
7164 Set the line length to @var{length} (or increment or decrement the
7165 current value by @var{length}).  Initially, the line length is set to
7166 6.5@dmn{i}.  The effect of @code{ll} is delayed until a partially
7167 collected line (if it exists) is output.  The default scaling
7168 indicator is @samp{m}.
7170 If @code{ll} is called without an argument, the line length is reset to
7171 the previous value before the last call to @code{ll}.  If a negative
7172 line length is specified (which is not allowed), @code{gtroff} emits a
7173 warning of type @samp{range} and sets the line length to zero.
7175 The line length is associated with the current environment
7176 (@pxref{Environments}).
7178 @cindex line length register (@code{.l})
7179 The current line length (as set by @code{ll}) can be found in the
7180 read-only number register @samp{.l}.  The read-only number register
7181 @code{.ll} is the line length that applies to the current output line.
7183 Similar to @code{.i} and @code{.in}, the difference between @code{.l}
7184 and @code{.ll} is that the latter takes into account whether a partially
7185 collected line still uses the old line length value.
7186 @endDefreq
7189 @c =====================================================================
7191 @node Line Control, Page Layout, Line Layout, gtroff Reference
7192 @section Line Control
7193 @cindex line control
7194 @cindex control, line
7196 It is important to understand how @code{gtroff} handles input and output
7197 lines.
7199 Many escapes use positioning relative to the input line.  For example,
7200 this
7202 @Example
7203 This is a \h'|1.2i'test.
7205 This is a
7206 \h'|1.2i'test.
7207 @endExample
7209 @noindent
7210 produces
7212 @Example
7213 This is a   test.
7215 This is a             test.
7216 @endExample
7218 The main usage of this feature is to define macros which act exactly
7219 at the place where called.
7221 @Example
7222 .\" A simple macro to underline a word
7223 .de underline
7224 .  nop \\$1\l'|0\[ul]'
7226 @endExample
7228 @noindent
7229 In the above example, @samp{|0} specifies a negative distance from the
7230 current position (at the end of the just emitted argument @code{\$1}) back
7231 to the beginning of the input line.  Thus, the @samp{\l} escape draws a
7232 line from right to left.
7234 @cindex input line continuation (@code{\})
7235 @cindex line, input, continuation (@code{\})
7236 @cindex continuation, input line (@code{\})
7237 @cindex output line, continuation (@code{\c})
7238 @cindex line, output, continuation (@code{\c})
7239 @cindex continuation, output line (@code{\c})
7240 @cindex interrupted line
7241 @cindex line, interrupted
7242 @code{gtroff} makes a difference between input and output line
7243 continuation; the latter is also called @dfn{interrupting} a line.
7245 @DefescList {\\@key{RET}, , ,}
7246 @DefescItem {\\c, , ,}
7247 @DefregListEnd{.int}
7248 Continue a line.  @code{\@key{RET}} (this is a backslash at the end
7249 of a line immediately followed by a newline) works on the input level,
7250 suppressing the effects of the following newline in the input.
7252 @Example
7253 This is a \
7254 .test
7255     @result{} This is a .test
7256 @endExample
7258 The @samp{|} operator is also affected.
7260 @cindex @code{\R}, after @code{\c}
7261 @code{\c} works on the output level.  Anything after this escape on the
7262 same line is ignored, except @code{\R} which works as usual.  Anything
7263 before @code{\c} on the same line will be appended to the current partial
7264 output line.  The next non-command line after an interrupted line counts
7265 as a new input line.
7267 The visual results depend on whether no-fill mode is active.
7269 @itemize @bullet
7270 @item
7271 @cindex @code{\c}, and no-fill mode
7272 @cindex no-fill mode, and @code{\c}
7273 @cindex mode, no-fill, and @code{\c}
7274 If no-fill mode is active (using the @code{nf} request), the next input
7275 text line after @code{\c} will be handled as a continuation of the same
7276 input text line.
7278 @Example
7280 This is a \c
7281 test.
7282     @result{} This is a test.
7283 @endExample
7285 @item
7286 @cindex @code{\c}, and fill mode
7287 @cindex fill mode, and @code{\c}
7288 @cindex mode, fill, and @code{\c}
7289 If fill mode is active (using the @code{fi} request), a word interrupted
7290 with @code{\c} will be continued with the text on the next input text line,
7291 without an intervening space.
7293 @Example
7294 This is a te\c
7296     @result{} This is a test.
7297 @endExample
7298 @end itemize
7300 Note that an intervening control line which causes a break is stronger
7301 than @code{\c}, flushing out the current partial line in the usual way.
7303 @cindex interrupted line register (@code{.int})
7304 The @code{.int} register contains a positive value
7305 if the last output line was interrupted with @code{\c}; this is
7306 associated with the current environment (@pxref{Environments}).
7308 @endDefesc
7310 @c =====================================================================
7312 @node Page Layout, Page Control, Line Control, gtroff Reference
7313 @section Page Layout
7314 @cindex page layout
7315 @cindex layout, page
7317 @code{gtroff} provides some very primitive operations for controlling
7318 page layout.
7320 @DefreqList {pl, [@Var{length}]}
7321 @DefreqItem {pl, @t{+}@Var{length}}
7322 @DefreqItem {pl, @t{-}@Var{length}}
7323 @DefregListEnd {.p}
7324 @cindex page length (@code{pl})
7325 @cindex length of page (@code{pl})
7326 Set the @dfn{page length} to @var{length} (or increment or decrement
7327 the current value by @var{length}).  This is the length of the
7328 physical output page.  The default scaling indicator is @samp{v}.
7330 @cindex page length register (@code{.p})
7331 The current setting can be found in the read-only number register
7332 @samp{.p}.
7334 @cindex top margin
7335 @cindex margin, top
7336 @cindex bottom margin
7337 @cindex margin, bottom
7338 Note that this only specifies the size of the page, not the top and
7339 bottom margins.  Those are not set by @code{gtroff} directly.
7340 @xref{Traps}, for further information on how to do this.
7342 Negative @code{pl} values are possible also, but not very useful: No
7343 trap is sprung, and each line is output on a single page (thus
7344 suppressing all vertical spacing).
7346 If no argument or an invalid argument is given, @code{pl} sets the page
7347 length to 11@dmn{i}.
7348 @endDefreq
7350 @cindex headers
7351 @cindex footers
7352 @cindex titles
7353 @code{gtroff} provides several operations which help in setting up top
7354 and bottom titles (or headers and footers).
7356 @Defreq {tl, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}}
7357 @cindex title line (@code{tl})
7358 @cindex three-part title (@code{tl})
7359 @cindex page number character (@code{%})
7360 Print a @dfn{title line}.  It consists of three parts: a left
7361 justified portion, a centered portion, and a right justified portion.
7362 The argument separator @samp{'} can be replaced with any character not
7363 occurring in the title line.  The @samp{%} character is replaced with
7364 the current page number.  This character can be changed with the
7365 @code{pc} request (see below).
7367 Without argument, @code{tl} is ignored.
7369 Some notes:
7371 @itemize @bullet
7372 @item
7373 A title line is not restricted to the top or bottom of a page.
7375 @item
7376 @code{tl} prints the title line immediately, ignoring a partially filled
7377 line (which stays untouched).
7379 @item
7380 It is not an error to omit closing delimiters.  For example,
7381 @w{@samp{.tl /foo}} is equivalent to @w{@samp{.tl /foo///}}: It prints a
7382 title line with the left justified word @samp{foo}; the centered and
7383 right justfied parts are empty.
7385 @item
7386 Any modifications to the current environment within @code{tl} (e.g.@:
7387 changing the font or font size) are undone after processing @code{tl}.
7389 @item
7390 @code{tl} accepts the same parameter delimiting characters as the
7391 @code{\A} escape; see @ref{Escapes}.
7392 @end itemize
7393 @endDefreq
7395 @DefreqList {lt, [@Var{length}]}
7396 @DefreqItem {lt, @t{+}@Var{length}}
7397 @DefreqItem {lt, @t{-}@Var{length}}
7398 @DefregListEnd {.lt}
7399 @cindex length of title line (@code{lt})
7400 @cindex title line, length (@code{lt})
7401 @cindex title line length register (@code{.lt})
7402 The title line is printed using its own line length, which is
7403 specified (or incremented or decremented) with the @code{lt} request.
7404 Initially, the title line length is set to 6.5@dmn{i}.  If a negative
7405 line length is specified (which is not allowed), @code{gtroff} emits a
7406 warning of type @samp{range} and sets the title line length to zero.
7407 The default scaling indicator is @samp{m}.  If @code{lt} is called
7408 without an argument, the title length is reset to the previous value
7409 before the last call to @code{lt}.
7411 The current setting of this is available in the @code{.lt} read-only
7412 number register; it is associated with the current environment
7413 (@pxref{Environments}).
7415 @endDefreq
7417 @DefreqList {pn, page}
7418 @DefreqItem {pn, @t{+}@Var{page}}
7419 @DefreqItem {pn, @t{-}@Var{page}}
7420 @DefregListEnd {.pn}
7421 @cindex page number (@code{pn})
7422 @cindex number, page (@code{pn})
7423 Change (increase or decrease) the page number of the @emph{next} page.
7424 The only argument is the page number; the request is ignored without a
7425 parameter.
7427 The read-only number register @code{.pn} contains the number of the next
7428 page: either the value set by a @code{pn} request, or the number of the
7429 current page plus@w{ }1.
7430 @endDefreq
7432 @Defreg {%}
7433 @cindex page number register (@code{%})
7434 A read-write register holding the current page number.
7435 @endDefreg
7437 @Defreq {pc, [@Var{char}]}
7438 @cindex changing the page number character (@code{pc})
7439 @cindex page number character, changing (@code{pc})
7440 @vindex %
7441 Change the page number character (used by the @code{tl} request) to a
7442 different character.  With no argument, this mechanism is disabled.
7443 Note that this doesn't affect the number register@w{ }@code{%}.
7444 @endDefreq
7446 @xref{Traps}.
7449 @c =====================================================================
7451 @node Page Control, Fonts, Page Layout, gtroff Reference
7452 @section Page Control
7453 @cindex page control
7454 @cindex control, page
7456 @DefreqList {bp, [@Var{page}]}
7457 @DefreqItem {bp, @t{+}@Var{page}}
7458 @DefreqListEnd {bp, @t{-}@Var{page}}
7459 @cindex new page (@code{bp})
7460 @cindex page, new (@code{bp})
7461 Stop processing the current page and move to the next page.  This
7462 request causes a break.  It can also take an argument to set
7463 (increase, decrease) the page number of the next page.  The only
7464 difference between @code{bp} and @code{pn} is that @code{pn} does not
7465 cause a break or actually eject a page.
7467 @Example
7468 .de newpage                         \" define macro
7469 'bp                                 \" begin page
7470 'sp .5i                             \" vertical space
7471 .tl 'left top'center top'right top' \" title
7472 'sp .3i                             \" vertical space
7473 ..                                  \" end macro
7474 @endExample
7476 @cindex @code{bp} request, and top-level diversion
7477 @cindex top-level diversion, and @code{bp}
7478 @cindex diversion, top-level, and @code{bp}
7479 @code{bp} has no effect if not called within the top-level diversion
7480 (@pxref{Diversions}).
7481 @endDefreq
7483 @Defreq {ne, [@Var{space}]}
7484 @cindex orphan lines, preventing with @code{ne}
7485 @cindex conditional page break (@code{ne})
7486 @cindex page break, conditional (@code{ne})
7487 It is often necessary to force a certain amount of space before a new
7488 page occurs.  This is most useful to make sure that there is not a
7489 single @dfn{orphan} line left at the bottom of a page.  The @code{ne}
7490 request ensures that there is a certain distance, specified by the
7491 first argument, before the next page is triggered (see @ref{Traps},
7492 for further information).  The default scaling indicator for @code{ne}
7493 is @samp{v}; the default value of @var{space} is@w{ }1@dmn{v} if no
7494 argument is given.
7496 For example, to make sure that no fewer than 2@w{ }lines get orphaned,
7497 do the following before each paragraph:
7499 @Example
7500 .ne 2
7501 text text text
7502 @endExample
7504 @code{ne} will then automatically cause a page break if there is space
7505 for one line only.
7506 @endDefreq
7508 @DefreqList {sv, [@Var{space}]}
7509 @DefreqListEnd {os, }
7510 @cindex @code{ne} request, comparison with @code{sv}
7511 @code{sv} is similar to the @code{ne} request; it reserves the
7512 specified amount of vertical space.  If the desired amount of space
7513 exists before the next trap (or the bottom page boundary if no trap is
7514 set), the space is output immediately (ignoring a partially filled line
7515 which stays untouched).  If there is not enough space, it is stored for
7516 later output via the @code{os} request.  The default value is@w{ }1@dmn{v}
7517 if no argument is given; the default scaling indicator is @samp{v}.
7519 @cindex @code{sv} request, and no-space mode
7520 @cindex @code{os} request, and no-space mode
7521 Both @code{sv} and @code{os} ignore no-space mode.  While the @code{sv}
7522 request allows negative values for @var{space}, @code{os} will ignore
7523 them.
7524 @endDefreq
7526 @Defreg {nl}
7527 This register contains the current vertical position.  If the vertical
7528 position is zero and the top of page transition hasn't happened yet,
7529 @code{nl} is set to negative value.  @code{gtroff} itself does this at
7530 the very beginning of a document before anything has been printed, but
7531 the main usage is to plant a header trap on a page if this page has
7532 already started.
7534 Consider the following:
7536 @Example
7537 .de xxx
7538 .  sp
7539 .  tl ''Header''
7540 .  sp
7543 First page.
7545 .wh 0 xxx
7546 .nr nl (-1)
7547 Second page.
7548 @endExample
7550 @noindent
7551 Result:
7553 @Example
7554 First page.
7558                              Header
7560 Second page.
7563 @endExample
7565 @noindent
7566 Without resetting @code{nl} to a negative value, the just planted trap
7567 would be active beginning with the @emph{next} page, not the current
7568 one.
7570 @xref{Diversions}, for a comparison with the @code{.h} and @code{.d}
7571 registers.
7572 @endDefreg
7574 @c =====================================================================
7576 @node Fonts, Sizes, Page Control, gtroff Reference
7577 @section Fonts
7578 @cindex fonts
7580 @code{gtroff} can switch fonts at any point in the text.
7582 The basic set of fonts is @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
7583 These are Times Roman, Italic, Bold, and Bold Italic.  For non-TTY
7584 devices, there is also at least one symbol font which contains various
7585 special symbols (Greek, mathematics).
7587 @menu
7588 * Changing Fonts::
7589 * Font Families::
7590 * Font Positions::
7591 * Using Symbols::
7592 * Special Fonts::
7593 * Artificial Fonts::
7594 * Ligatures and Kerning::
7595 @end menu
7597 @c ---------------------------------------------------------------------
7599 @node Changing Fonts, Font Families, Fonts, Fonts
7600 @subsection Changing Fonts
7601 @cindex fonts
7603 @DefreqList {ft, [@Var{font}]}
7604 @DefescItem {\\f, , f, }
7605 @DefescItem {\\f, @lparen{}, fn, }
7606 @DefescListEnd {\\f, @lbrack{}, font, @rbrack}
7607 @cindex changing fonts (@code{ft}, @code{\f})
7608 @cindex fonts, changing (@code{ft}, @code{\f})
7609 @cindex @code{sty} request, and changing fonts
7610 @cindex @code{fam} request, and changing fonts
7611 @cindex @code{\F}, and changing fonts
7612 @kindex styles
7613 @kindex family
7614 @pindex DESC
7615 The @code{ft} request and the @code{\f} escape change the current font
7616 to @var{font} (one-character name@w{ }@var{f}, two-character name
7617 @var{fn}).
7619 If @var{font} is a style name (as set with the @code{sty} request or
7620 with the @code{styles} command in the @file{DESC} file), use it within
7621 the current font family (as set with the @code{fam} request, @code{\F}
7622 escape, or with the @code{family} command in the @file{DESC} file).
7624 @cindex previous font (@code{ft}, @code{\f[]}, @code{\fP})
7625 @cindex font, previous (@code{ft}, @code{\f[]}, @code{\fP})
7626 With no argument or using @samp{P} as an argument, @code{.ft} switches
7627 to the previous font.  Use @code{\f[]} to do this with the escape.  The
7628 old syntax forms @code{\fP} or @code{\f[P]} are also supported.
7630 Fonts are generally specified as upper-case strings, which are usually
7631 1@w{ }to 4 characters representing an abbreviation or acronym of the
7632 font name.  This is no limitation, just a convention.
7634 The example below produces two identical lines.
7636 @Example
7637 eggs, bacon,
7638 .ft B
7639 spam
7641 and sausage.
7643 eggs, bacon, \fBspam\fP and sausage.
7644 @endExample
7646 Note that @code{\f} doesn't produce an input token in @code{gtroff}.
7647 As a consequence, it can be used in requests like @code{mc} (which
7648 expects a single character as an argument) to change the font on
7649 the fly:
7651 @Example
7652 .mc \f[I]x\f[]
7653 @endExample
7655 @xref{Font Positions}, for an alternative syntax.
7656 @endDefreq
7658 @Defreq {ftr, f [@Var{g}]}
7659 @cindex @code{ft} request, and font translations
7660 @cindex @code{ul} request, and font translations
7661 @cindex @code{bd} request, and font translations
7662 @cindex @code{\f}, and font translations
7663 @cindex @code{cs} request, and font translations
7664 @cindex @code{tkf} request, and font translations
7665 @cindex @code{special} request, and font translations
7666 @cindex @code{fspecial} request, and font translations
7667 @cindex @code{fp} request, and font translations
7668 @cindex @code{sty} request, and font translations
7669 Translate font@w{ }@var{f} to font@w{ }@var{g}.  Whenever a font named@w{
7670 }@var{f} is referred to in a @code{\f} escape sequence, or in the
7671 @code{ft}, @code{ul}, @code{bd}, @code{cs}, @code{tkf},
7672 @code{special}, @code{fspecial}, @code{fp}, or @code{sty} requests,
7673 font@w{ }@var{g} is used.  If @var{g} is missing or equal to@w{ }@var{f}
7674 the translation is undone.
7675 @endDefreq
7677 @c ---------------------------------------------------------------------
7679 @node Font Families, Font Positions, Changing Fonts, Fonts
7680 @subsection Font Families
7681 @cindex font families
7682 @cindex families, font
7683 @cindex font styles
7684 @cindex styles, font
7686 Due to the variety of fonts available, @code{gtroff} has added the
7687 concept of @dfn{font families} and @dfn{font styles}.  The fonts are
7688 specified as the concatenation of the font family and style.  Specifying
7689 a font without the family part causes @code{gtroff} to use that style of
7690 the current family.
7692 @cindex PostScript fonts
7693 @cindex fonts, PostScript
7694 Currently, fonts for the devices @option{-Tps}, @option{-Tdvi}, and
7695 @option{-Tlbp} are set up to this mechanism.
7696 By default, @code{gtroff} uses the Times family with the four styles
7697 @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
7699 This way, it is possible to use the basic four fonts and to select a
7700 different font family on the command line (@pxref{Groff Options}).
7702 @DefreqList {fam, [@Var{family}]}
7703 @DefregItem {.fam}
7704 @DefescItem {\\F, , f, }
7705 @DefescItem {\\F, @lparen{}, fm, }
7706 @DefescItem {\\F, @lbrack{}, family, @rbrack}
7707 @DefregListEnd {.fn}
7708 @cindex changing font family (@code{fam}, @code{\F})
7709 @cindex font family, changing (@code{fam}, @code{\F})
7710 Switch font family to @var{family} (one-character name@w{ }@var{f},
7711 two-character name @var{fm}).  If no argument is given, switch
7712 back to the previous font family.  Use @code{\F[]} to do this with the
7713 escape.  Note that @code{\FP} doesn't work; it selects font family
7714 @samp{P} instead.
7716 The value at start-up is @samp{T}.
7717 The current font family is available in the read-only number register
7718 @samp{.fam} (this is a string-valued register); it is associated with
7719 the current environment.
7721 @Example
7722 spam,
7723 .fam H    \" helvetica family
7724 spam,     \" used font is family H + style R = HR
7725 .ft B     \" family H + style B = font HB
7726 spam,
7727 .fam T    \" times family
7728 spam,     \" used font is family T + style B = TB
7729 .ft AR    \" font AR (not a style)
7730 baked beans,
7731 .ft R     \" family T + style R = font TR
7732 and spam.
7733 @endExample
7735 Note that @code{\F} doesn't produce an input token in @code{gtroff}.
7736 As a consequence, it can be used in requests like @code{mc} (which
7737 expects a single character as an argument) to change the font family on
7738 the fly:
7740 @Example
7741 .mc \F[P]x\F[]
7742 @endExample
7744 The @samp{.fn} register contains the current @dfn{real font name}
7745 of the current font.
7746 This is a string-valued register.
7747 If the current font is a style, the value of @code{\n[.fn]}
7748 is the proper concatenation of family and style name.
7749 @endDefreq
7751 @Defreq {sty, n style}
7752 @cindex changing font style (@code{sty})
7753 @cindex font style, changing (@code{sty})
7754 @cindex @code{cs} request, and font styles
7755 @cindex @code{bd} request, and font styles
7756 @cindex @code{tkf} request, and font styles
7757 @cindex @code{uf} request, and font styles
7758 @cindex @code{fspecial} request, and font styles
7759 Associate @var{style} with font position@w{ }@var{n}.  A font position
7760 can be associated either with a font or with a style.  The current
7761 font is the index of a font position and so is also either a font or a
7762 style.  If it is a style, the font that is actually used is the font
7763 which name is the concatenation of the name of the current
7764 family and the name of the current style.  For example, if the current
7765 font is@w{ }1 and font position@w{ }1 is associated with style
7766 @samp{R} and the current font family is @samp{T}, then font
7767 @samp{TR} will be used.  If the current font is not a style, then the
7768 current family is ignored.  If the requests @code{cs}, @code{bd},
7769 @code{tkf}, @code{uf}, or @code{fspecial} are applied to a style,
7770 they will instead be applied to the member of the current family
7771 corresponding to that style.
7773 @var{n}@w{ }must be a non-negative integer value.
7775 @pindex DESC
7776 @kindex styles
7777 The default family can be set with the @option{-f} option
7778 (@pxref{Groff Options}).  The @code{styles} command in the @file{DESC}
7779 file controls which font positions (if any) are initially associated
7780 with styles rather than fonts.  For example, the default setting for
7781 @sc{PostScript} fonts
7783 @Example
7784 styles R I B BI
7785 @endExample
7787 @noindent
7788 is equivalent to
7790 @Example
7791 .sty 1 R
7792 .sty 2 I
7793 .sty 3 B
7794 .sty 4 BI
7795 @endExample
7797 @code{fam} and @code{\F} always check whether the current font position
7798 is valid; this can give surprising results if the current font position is
7799 associated with a style.
7801 In the following example, we want to access the @sc{PostScript} font
7802 @code{FooBar} from the font family @code{Foo}:
7804 @Example
7805 .sty \n[.fp] Bar
7806 .fam Foo
7807     @result{} warning: can't find font `FooR'
7808 @endExample
7810 @noindent
7811 The default font position at start-up is@w{ }1; for the
7812 @sc{PostScript} device, this is associated with style @samp{R}, so
7813 @code{gtroff} tries to open @code{FooR}.
7815 A solution to this problem is to use a dummy font like the following:
7817 @Example
7818 .fp 0 dummy TR    \" set up dummy font at position 0
7819 .sty \n[.fp] Bar  \" register style `Bar'
7820 .ft 0             \" switch to font at position 0
7821 .fam Foo          \" activate family `Foo'
7822 .ft Bar           \" switch to font `FooBar'
7823 @endExample
7825 @xref{Font Positions}.
7826 @endDefreq
7828 @c ---------------------------------------------------------------------
7830 @node Font Positions, Using Symbols, Font Families, Fonts
7831 @subsection Font Positions
7832 @cindex font positions
7833 @cindex positions, font
7835 For the sake of old phototypesetters and compatibility with old versions
7836 of @code{troff}, @code{gtroff} has the concept of font @dfn{positions},
7837 on which various fonts are mounted.
7839 @DefreqList {fp, pos font [@Var{external-name}]}
7840 @DefregItem {.f}
7841 @DefregListEnd {.fp}
7842 @cindex mounting font (@code{fp})
7843 @cindex font, mounting (@code{fp})
7844 Mount font @var{font} at position @var{pos} (which must be a
7845 non-negative integer).  This numeric position can then be referred to
7846 with font changing commands.  When @code{gtroff} starts it is using
7847 font position@w{ }1 (which must exist; position@w{ }0 is unused
7848 usually at start-up).
7850 @cindex font position register (@code{.f})
7851 The current font in use, as a font position, is available in the
7852 read-only number register @samp{.f}.  This can be useful to remember the
7853 current font for later recall.  It is associated with the current
7854 environment (@pxref{Environments}).
7856 @Example
7857 .nr save-font \n[.f]
7858 .ft B
7859 ... text text text ...
7860 .ft \n[save-font]
7861 @endExample
7863 @cindex next free font position register (@code{.fp})
7864 The number of the next free font position is available in the read-only
7865 number register @samp{.fp}.  This is useful when mounting a new font,
7866 like so:
7868 @Example
7869 .fp \n[.fp] NEATOFONT
7870 @endExample
7872 @pindex DESC@r{, and font mounting}
7873 Fonts not listed in the @file{DESC} file are automatically mounted on
7874 the next available font position when they are referenced.  If a font
7875 is to be mounted explicitly with the @code{fp} request on an unused
7876 font position, it should be mounted on the first unused font position,
7877 which can be found in the @code{.fp} register.  Although @code{gtroff}
7878 does not enforce this strictly, it is not allowed to mount a font at a
7879 position whose number is much greater (approx.@: 1000 positions) than
7880 that of any currently used position.
7882 The @code{fp} request has an optional third argument.  This argument
7883 gives the external name of the font, which is used for finding the font
7884 description file.  The second argument gives the internal name of the
7885 font which is used to refer to the font in @code{gtroff} after it has
7886 been mounted.  If there is no third argument then the internal name is
7887 used as the external name.  This feature makes it possible to use
7888 fonts with long names in compatibility mode.
7889 @endDefreq
7891 Both the @code{ft} request and the @code{\f} escape have alternative
7892 syntax forms to access font positions.
7894 @DefreqList {ft, nnn}
7895 @DefescItem {\\f, , n, }
7896 @DefescItem {\\f, @lparen{}, nn, }
7897 @DefescListEnd {\\f, @lbrack{}, nnn, @rbrack}
7898 @cindex changing font position (@code{\f})
7899 @cindex font position, changing (@code{\f})
7900 @cindex @code{sty} request, and font positions
7901 @cindex @code{fam} request, and font positions
7902 @cindex @code{\F}, and font positions
7903 @kindex styles
7904 @kindex family
7905 @pindex DESC
7906 Change the current font position to @var{nnn} (one-digit position@w{
7907 }@var{n}, two-digit position @var{nn}), which must be a non-negative
7908 integer.
7910 If @var{nnn} is associated with a style (as set with the @code{sty}
7911 request or with the @code{styles} command in the @file{DESC} file), use
7912 it within the current font family (as set with the @code{fam} request,
7913 the @code{\F} escape, or with the @code{family} command in the @file{DESC}
7914 file).
7916 @Example
7917 this is font 1
7918 .ft 2
7919 this is font 2
7920 .ft                   \" switch back to font 1
7921 .ft 3
7922 this is font 3
7924 this is font 1 again
7925 @endExample
7927 @xref{Changing Fonts}, for the standard syntax form.
7928 @endDefreq
7930 @c ---------------------------------------------------------------------
7932 @node Using Symbols, Special Fonts, Font Positions, Fonts
7933 @subsection Using Symbols
7934 @cindex using symbols
7935 @cindex symbols, using
7937 @cindex glyph
7938 @cindex character
7939 @cindex ligature
7940 A @dfn{glyph} is a graphical representation of a @dfn{character}.
7941 While a character is an abstract entity containing semantic
7942 information, a glyph is something which can be actually seen on screen
7943 or paper.  It is possible that a character has multiple glyph
7944 representation forms (for example, the character `A' can be either
7945 written in a roman or an italic font, yielding two different glyphs);
7946 sometimes more than one character maps to a single glyph (this is a
7947 @dfn{ligature} -- the most common is `fi').
7949 @cindex symbol
7950 @cindex special fonts
7951 @kindex fonts
7952 @pindex DESC
7953 A @dfn{symbol} is simply a named glyph.  Within @code{gtroff}, all
7954 glyph names of a particular font are defined in its font file.  If the
7955 user requests a glyph not available in this font, @code{gtroff} looks
7956 up an ordered list of @dfn{special fonts}.  By default, the
7957 @sc{PostScript} output device supports the two special fonts @samp{SS}
7958 (slanted symbols) and @samp{S} (symbols) (the former is looked up
7959 before the latter).  Other output devices use different names for
7960 special fonts.  Fonts mounted with the @code{fonts} keyword in the
7961 @file{DESC} file are globally available.  To install additional
7962 special fonts locally (i.e.@: for a particular font), use the
7963 @code{fspecial} request.
7965 In summary, @code{gtroff} tries the following to find a given symbol:
7967 @itemize @bullet
7968 @item
7969 If the symbol has been defined with the @code{char} request, use it.
7970 This hides a symbol with the same name in the current font.
7972 @item
7973 Check the current font.
7975 @item
7976 If the symbol has been defined with the @code{fchar} request, use it.
7978 @item
7979 Check all fonts given with the @code{fspecial} request, in the order
7980 of appearance in @code{fspecial} calls.
7982 @item
7983 Check all fonts given with the @code{special} request, in the order
7984 of appearance in @code{special} calls (inclusively the special fonts
7985 defined in the @file{DESC} file, which come first).
7987 @item
7988 As a last resort, consult all fonts loaded up to now (in the order they
7989 have been called the first time) for special fonts and check them.
7990 @end itemize
7992 @xref{Font Files}, and @ref{Special Fonts}, for more details.
7994 @DefescList {\\, @lparen{}, nm, }
7995 @DefescListEnd {\\, @lbrack{}, name, @rbrack}
7996 Insert a symbol @var{name} (two-character name @var{nm}).  There is no
7997 special syntax for one-character names -- the natural form
7998 @samp{\@var{n}} would collide with escapes.@footnote{Note that a
7999 one-character symbol is not the same as an input character, i.e., the
8000 character @code{a} is not the same as @code{\[a]}.  By default,
8001 @code{groff} defines only a single one-character symbol, @code{\[-]};
8002 it is usually accessed as @code{\-}.  On the other hand, @code{gtroff}
8003 has the special feature that @code{\[char@var{XXX}]} is the same as the
8004 input character with character code @var{XXX}.  For example,
8005 @code{\[char97]} is identical to the letter @code{a} if @acronym{ASCII}
8006 encoding is active.}
8008 If @var{name} is undefined, a warning of type @samp{char} is generated,
8009 and the escape is ignored.  @xref{Debugging}, for information about
8010 warnings.
8012 @cindex list of available glyphs (@cite{groff_char(7)} man page)
8013 @cindex available glyphs, list (@cite{groff_char(7)} man page)
8014 @cindex glyphs, available, list (@cite{groff_char(7)} man page)
8015 The list of available symbols is device dependent; see the
8016 @cite{groff_char(7)} man page for a complete list for the given output
8017 device.  For example, say
8019 @Example
8020 man -Tdvi groff_char > groff_char.dvi
8021 @endExample
8023 @noindent
8024 for a list using the default DVI fonts (not all versions of the
8025 @code{man} program support the @option{-T} option).  If you want to
8026 use an additional macro package to change the used fonts, @code{groff}
8027 must be called directly:
8029 @Example
8030 groff -Tdvi -mec -man groff_char.7 > groff_char.dvi
8031 @endExample
8033 @c XXX list of common symbols
8034 @endDefesc
8036 @Defesc {\\C, ', xxx, '}
8037 @cindex named character (@code{\C})
8038 @cindex character, named (@code{\C})
8039 Typeset the glyph named @var{xxx}.@footnote{@code{\C} is actually a
8040 misnomer since it accesses an output glyph.}  Normally it is more
8041 convenient to use @code{\[@var{xxx}]}, but @code{\C} has the advantage
8042 that it is compatible with newer versions of @acronym{AT&T}
8043 @code{troff} and is available in compatibility mode.
8044 @endDefesc
8046 @Defesc {\\N, ', n, '}
8047 @cindex numbered glyph (@code{\N})
8048 @cindex glyph, numbered (@code{\N})
8049 @cindex @code{char} request, used with @code{\N}
8050 @cindex Unicode
8051 Typeset the glyph with code@w{ }@var{n} in the current font
8052 (@code{n}@w{ }is @strong{not} the input character code).  The
8053 number @var{n}@w{ }can be any non-negative integer.  Most devices
8054 only have glyphs with codes between 0 and@w{ }255; the Unicode
8055 output device uses codes in the range 0--65535.  If the current
8056 font does not contain a glyph with that code, special fonts are
8057 @emph{not} searched.  The @code{\N} escape sequence can be
8058 conveniently used in conjunction with the @code{char} request:
8060 @Example
8061 .char \[phone] \f[ZD]\N'37'
8062 @endExample
8064 @noindent
8065 @pindex DESC
8066 @cindex unnamed glyphs
8067 @cindex glyphs, unnamed
8068 The code of each glyph is given in the fourth column in the font
8069 description file after the @code{charset} command.  It is possible to
8070 include unnamed glyphs in the font description file by using a
8071 name of @samp{---}; the @code{\N} escape sequence is the only way to
8072 use these.
8073 @endDefesc
8075 Some escape sequences directly map onto special glyphs.
8077 @Defesc {\\', , , }
8078 This is a backslash followed by the apostrophe character, @acronym{ASCII}
8079 character @code{0x27} (@acronym{EBCDIC} character @code{0x7D}).  The same
8080 as @code{\[aa]}, the acute accent.
8081 @endDefesc
8083 @Defesc {\\`, , , }
8084 This is a backslash followed by @acronym{ASCII} character @code{0x60}
8085 (@acronym{EBCDIC} character @code{0x79} usually).  The same as
8086 @code{\[ga]}, the grave accent.
8087 @endDefesc
8089 @Defesc {\\-, , , }
8090 This is the same as @code{\[-]}, the minus sign in the current font.
8091 @endDefesc
8093 @Defreq {cflags, n c1 c2 @dots{}}
8094 @cindex glyph properties (@code{cflags})
8095 @cindex character properties (@code{cflags})
8096 @cindex properties of glyphs (@code{cflags})
8097 @cindex properties of characters (@code{cflags})
8098 Input characters and symbols have certain properties associated
8099 with it.@footnote{Note that the output glyphs themselves don't have
8100 such properties.  For @code{gtroff}, a glyph is a numbered box with
8101 a given width, depth, and height, nothing else.  All manipulations
8102 with the @code{cflags} request work on the input level.}  These
8103 properties can be modified with the @code{cflags} request.  The
8104 first argument is the sum of the desired flags and the remaining
8105 arguments are the characters or symbols to have those properties.
8106 It is possible to omit the spaces between the characters or symbols.
8108 @table @code
8109 @item 1
8110 @cindex end-of-sentence characters
8111 @cindex characters, end-of-sentence
8112 The character ends sentences (initially characters @samp{.?!} have this
8113 property).
8115 @item 2
8116 @cindex hyphenating characters
8117 @cindex characters, hyphenation
8118 Lines can be broken before the character (initially no characters have
8119 this property).
8121 @item 4
8122 @cindex @code{hy} glyph, and @code{cflags}
8123 @cindex @code{em} glyph, and @code{cflags}
8124 Lines can be broken after the character (initially the character
8125 @samp{-} and the symbols @samp{\(hy} and @samp{\(em} have this property).
8127 @item 8
8128 @cindex overlapping characters
8129 @cindex characters, overlapping
8130 @cindex @code{ul} glyph, and @code{cflags}
8131 @cindex @code{rn} glyph, and @code{cflags}
8132 @cindex @code{ru} glyph, and @code{cflags}
8133 The character overlaps horizontally (initially the symbols
8134 @samp{\(ul\(rn\(ru} have this property).
8136 @item 16
8137 @cindex @code{br} glyph, and @code{cflags}
8138 The character overlaps vertically (initially symbol @samp{\(br} has
8139 this property).
8141 @item 32
8142 @cindex transparent characters
8143 @cindex character, transparent
8144 @cindex @code{"}, at end of sentence
8145 @cindex @code{'}, at end of sentence
8146 @cindex @code{)}, at end of sentence
8147 @cindex @code{]}, at end of sentence
8148 @cindex @code{*}, at end of sentence
8149 @cindex @code{dg} glyph, at end of sentence
8150 @cindex @code{rq} glyph, at end of sentence
8151 An end-of-sentence character followed by any number of characters with
8152 this property is treated as the end of a sentence if followed by a
8153 newline or two spaces; in other words the character is
8154 @dfn{transparent} for the purposes of end-of-sentence recognition --
8155 this is the same as having a zero space factor in @TeX{} (initially
8156 characters @samp{"')]*} and the symbols @samp{\(dg\(rq} have this
8157 property).
8158 @end table
8159 @endDefreq
8161 @DefreqList {char, g [@Var{string}]}
8162 @DefreqListEnd {fchar, g [@Var{string}]}
8163 @cindex defining character (@code{char})
8164 @cindex character, defining (@code{char})
8165 @cindex creating new characters (@code{char})
8166 @cindex defining symbol (@code{char})
8167 @cindex symbol, defining (@code{char})
8168 @cindex defining glyph (@code{char})
8169 @cindex glyph, defining (@code{char})
8170 @cindex escape character, while defining glyph
8171 @cindex character, escape, while defining glyph
8172 @cindex @code{tr} request, and glyph definitions
8173 @cindex @code{cp} request, and glyph definitions
8174 @cindex @code{rc} request, and glyph definitions
8175 @cindex @code{lc} request, and glyph definitions
8176 @cindex @code{\l}, and glyph definitions
8177 @cindex @code{\L}, and glyph definitions
8178 @cindex @code{\&}, and glyph definitions
8179 @cindex @code{\e}, and glyph definitions
8180 @cindex @code{hcode} request, and glyph definitions
8181 Define a new glyph@w{ }@var{g} to be @var{string} (which can be
8182 empty).@footnote{@code{char} is a misnomer since an output glyph is
8183 defined.}  Every time glyph@w{ }@var{g} needs to be printed,
8184 @var{string} is processed in a temporary environment and the result is
8185 wrapped up into a single object.  Compatibility mode is turned off and
8186 the escape character is set to @samp{\} while @var{string} is being
8187 processed.  Any emboldening, constant spacing or track kerning is
8188 applied to this object rather than to individual characters in
8189 @var{string}.
8191 A glyph defined by this request can be used just
8192 like a normal glyph provided by the output device.  In particular,
8193 other characters can be translated to it with the @code{tr} or
8194 @code{trin} requests; it can be made the leader character by the
8195 @code{lc} request; repeated patterns can be drawn with the glyph
8196 using the @code{\l} and @code{\L} escape sequences; words containing
8197 the glyph can be hyphenated correctly if the @code{hcode} request
8198 is used to give the glyph's symbol a hyphenation code.
8200 There is a special anti-recursion feature: Use of @code{g} within
8201 the glyph's definition is handled like normal characters and symbols
8202 not defined with @code{char}.
8204 Note that the @code{tr} and @code{trin} requests take precedence if
8205 @code{char} accesses the same symbol.
8207 @Example
8208 .tr XY
8210     @result{} Y
8211 .char X Z
8213     @result{} Y
8214 .tr XX
8216     @result{} Z
8217 @endExample
8219 The @code{fchar} request defines a fallback glyph:
8220 @code{gtroff} only checks for glyphs defined with @code{fchar}
8221 if it cannot find the glyph in the current font.
8222 @code{gtroff} carries out this test before checking special fonts.
8223 @endDefreq
8225 @Defreq {rchar, c1 c2 @dots{}}
8226 @cindex removing glyph definition (@code{rchar})
8227 @cindex glyph, removing definition (@code{rchar})
8228 Remove the definitions of glyphs @var{c1}, @var{c2},@w{
8229 }@enddots{} This undoes the effect of a @code{char} or @code{fchar}
8230 request.
8232 It is possible to omit the whitespace between arguments.
8233 @endDefreq
8235 @xref{Special Characters}.
8237 @c ---------------------------------------------------------------------
8239 @node Special Fonts, Artificial Fonts, Using Symbols, Fonts
8240 @subsection Special Fonts
8241 @cindex special fonts
8242 @cindex fonts, special
8244 Special fonts are those that @code{gtroff} searches
8245 when it cannot find the requested glyph in the current font.
8246 The Symbol font is usually a special font.
8248 @code{gtroff} provides the following two requests to add more special
8249 fonts.  @xref{Using Symbols}, for a detailed description of the glyph
8250 searching mechanism in @code{gtroff}.
8252 Usually, only non-TTY devices have special fonts.
8254 @DefreqList {special, s1 s2 @dots{}}
8255 @DefreqListEnd {fspecial, f s1 s2 @dots{}}
8256 @kindex fonts
8257 @pindex DESC
8258 Use the @code{special} request to define special fonts.  They are
8259 appended to the list of global special fonts in the given order.
8260 The first entries in this list are the fonts defined with the
8261 @code{fonts} command in the @file{DESC} file which are marked as
8262 special in the corresponding font description files.
8264 Use the @code{fspecial} request to designate special fonts
8265 only when font@w{ }@var{f} font is active.  They are appended to the
8266 list of special fonts for @var{f} in the given order.  Initially, this
8267 list is empty.
8268 @endDefreq
8270 @c ---------------------------------------------------------------------
8272 @node Artificial Fonts, Ligatures and Kerning, Special Fonts, Fonts
8273 @subsection Artificial Fonts
8274 @cindex artificial fonts
8275 @cindex fonts, artificial
8277 There are a number of requests and escapes for artificially creating
8278 fonts.  These are largely vestiges of the days when output devices
8279 did not have a wide variety of fonts, and when @code{nroff} and
8280 @code{troff} were separate programs.  Most of them are no longer
8281 necessary in GNU @code{troff}.  Nevertheless, they are supported.
8283 @DefescList {\\H, ', height, '}
8284 @DefescItem {\\H, ', @t{+}@Var{height}, '}
8285 @DefescListEnd {\\H, ', @t{-}@Var{height}, '}
8286 @cindex changing the font height (@code{\H})
8287 @cindex font height, changing (@code{\H})
8288 @cindex height, font, changing (@code{\H})
8289 Change (increment, decrement) the height of the current font, but not
8290 the width.  If @var{height} is zero, restore the original height.
8291 Default scaling indicator is @samp{z}.
8293 Currently, only the @option{-Tps} device supports this feature.
8295 Note that @code{\H} doesn't produce an input token in @code{gtroff}.
8296 As a consequence, it can be used in requests like @code{mc} (which
8297 expects a single character as an argument) to change the font on
8298 the fly:
8300 @Example
8301 .mc \H'+5z'x\H'0'
8302 @endExample
8304 In compatibility mode, @code{gtroff} behaves differently:  If an
8305 increment or decrement is used, it is always taken relative to the
8306 current point size and not relative to the previously selected font
8307 height.  Thus,
8309 @Example
8310 .cp 1
8311 \H'+5'test \H'+5'test
8312 @endExample
8314 @noindent
8315 prints the word @samp{test} twice with the same font height (five
8316 points larger than the current font size).
8317 @endDefesc
8319 @DefescList {\\S, ', slant, '}
8320 @cindex changing the font slant (@code{\S})
8321 @cindex font slant, changing (@code{\S})
8322 @cindex slant, font, changing (@code{\S})
8323 Slant the current font by @var{slant} degrees.  Positive values slant
8324 to the right.
8326 Currently, only the @option{-Tps} device supports this feature.
8328 Note that @code{\S} doesn't produce an input token in @code{gtroff}.
8329 As a consequence, it can be used in requests like @code{mc} (which
8330 expects a single character as an argument) to change the font on
8331 the fly:
8333 @Example
8334 .mc \S'20'x\S'0'
8335 @endExample
8337 This request is incorrectly documented in the original @acronym{UNIX}
8338 troff manual; the slant is always set to an absolute value.
8339 @endDefesc
8341 @Defreq {ul, [@Var{lines}]}
8342 @cindex underlining (@code{ul})
8343 The @code{ul} request normally underlines subsequent lines if a TTY
8344 output device is used.  Otherwise, the lines are printed in italics
8345 (only the term `underlined' is used in the following).  The single
8346 argument is the number of input lines to be underlined; with no
8347 argument, the next line is underlined.  If @var{lines} is zero or
8348 negative, stop the effects of @code{ul} (if it was active).  Requests
8349 and empty lines do not count for computing the number of underlined
8350 input lines, even if they produce some output like @code{tl}.  Lines
8351 inserted by macros (e.g.@: invoked by a trap) do count.
8353 At the beginning of @code{ul}, the current font is stored and the
8354 underline font is activated.  Within the span of a @code{ul} request,
8355 it is possible to change fonts, but after the last line affected by
8356 @code{ul} the saved font is restored.
8358 This number of lines still to be underlined is associated with the
8359 current environment (@pxref{Environments}).  The underline font can be
8360 changed with the @code{uf} request.
8362 @c XXX @xref should be changed to grotty
8364 @c @xref{Troff and Nroff Mode}, for a discussion how underlining is
8365 @c implemented in for TTY output devices, and which problems can arise.
8367 The @code{ul} request does not underline spaces.
8368 @endDefreq
8370 @Defreq {cu, [@Var{lines}]}
8371 @cindex continuous underlining (@code{cu})
8372 @cindex underlining, continuous (@code{cu})
8373 The @code{cu} request is similar to @code{ul} but underlines spaces as
8374 well (if a TTY output device is used).
8375 @endDefreq
8377 @Defreq {uf, font}
8378 @cindex underline font (@code{uf})
8379 @cindex font for underlining (@code{uf})
8380 Set the underline font (globally) used by @code{ul} and @code{cu}.  By
8381 default, this is the font at position@w{ }2.  @var{font} can be either
8382 a non-negative font position or the name of a font.
8383 @endDefreq
8385 @DefreqList {bd, font [@Var{offset}]}
8386 @DefreqItem {bd, font1 font2 [@Var{offset}]}
8387 @DefregListEnd {.b}
8388 @cindex imitating bold face (@code{bd})
8389 @cindex bold face, imitating (@code{bd})
8390 Artificially create a bold font by printing each glyph twice,
8391 slightly offset.
8393 Two syntax forms are available.
8395 @itemize @bullet
8396 @item
8397 Imitate a bold font unconditionally.  The first argument specifies the
8398 font to embolden, and the second is the number of basic units, minus
8399 one, by which the two glyphs are offset.  If the second argument is
8400 missing, emboldening is turned off.
8402 @var{font} can be either a non-negative font position or the name of a
8403 font.
8405 @var{offset} is available in the @code{.b} read-only register if a
8406 special font is active; in the @code{bd} request, its default unit is
8407 @samp{u}.
8409 @cindex @code{fspecial} request, and imitating bold
8410 @kindex special
8411 @cindex embolding of special fonts
8412 @cindex special fonts, emboldening
8413 @item
8414 Imitate a bold form conditionally.  Embolden @var{font1} by
8415 @var{offset} only if font @var{font2} is the current font.  This
8416 command can be issued repeatedly to set up different emboldening
8417 values for different current fonts.  If the second argument is
8418 missing, emboldening is turned off for this particular current font.
8420 This affects special fonts only (either set up with the @code{special}
8421 command in font files or with the @code{fspecial} request).
8422 @end itemize
8423 @endDefreq
8425 @Defreq {cs, font [@Var{width} [@Var{em-size}]]}
8426 @cindex constant glyph space mode (@code{cs})
8427 @cindex mode for constant glyph space (@code{cs})
8428 @cindex glyph, constant space
8429 @cindex @code{ps} request, and constant glyph space mode
8430 Switch to and from @dfn{constant glyph space mode}.  If activated, the
8431 width of every glyph is @math{@var{width}/36} ems.  The em size is
8432 given absolutely by @var{em-size}; if this argument is missing, the em
8433 value is taken from the current font size (as set with the @code{ps}
8434 request) when the font is effectively in use.  Without second and
8435 third argument, constant glyph space mode is deactivated.
8437 Default scaling indicator for @var{em-size} is @samp{z}; @var{width} is
8438 an integer.
8439 @endDefreq
8441 @c ---------------------------------------------------------------------
8443 @node Ligatures and Kerning,  , Artificial Fonts, Fonts
8444 @subsection Ligatures and Kerning
8445 @cindex ligatures and kerning
8446 @cindex kerning and ligatures
8448 Ligatures are groups of characters that are run together, i.e, producing
8449 a single glyph.  For example, the letters `f' and `i' can form a
8450 ligature `fi' as in the word `file'.  This produces a cleaner look
8451 (albeit subtle) to the printed output.  Usually, ligatures are not
8452 available in fonts for TTY output devices.
8454 Most @sc{PostScript} fonts support the fi and fl ligatures.  The C/A/T
8455 typesetter that was the target of @acronym{AT&T} @code{troff} also
8456 supported `ff', `ffi', and `ffl' ligatures.  Advanced typesetters or
8457 `expert' fonts may include ligatures for `ft' and `ct', although GNU
8458 @code{troff} does not support these (yet).
8460 @DefreqList {lg, [@Var{flag}]}
8461 @DefregListEnd {.lg}
8462 @cindex activating ligatures (@code{lg})
8463 @cindex ligatures, activating (@code{lg})
8464 @cindex ligatures enabled register (@code{.lg})
8465 Switch the ligature mechanism on or off; if the parameter is non-zero
8466 or missing, ligatures are enabled, otherwise disabled.  Default is on.
8467 The current ligature mode can be found in the read-only number register
8468 @code{.lg} (set to 1 or@w{ }2 if ligatures are enabled, 0@w{ }otherwise).
8470 Setting the ligature mode to@w{ }2 enables the two-character ligatures
8471 (fi, fl, and ff) and disables the three-character ligatures (ffi and
8472 ffl).
8473 @endDefreq
8475 @dfn{Pairwise kerning} is another subtle typesetting mechanism that
8476 modifies the distance between a glyph pair to improve readability.
8477 In most cases (but not always) the distance is decreased.
8478 @ifnotinfo
8479 For example, compare the combination of the letters `V' and `A'.  With
8480 kerning, `VA' is printed.  Without kerning it appears as `V@w{}A'.
8481 @end ifnotinfo
8482 Typewriter-like fonts and fonts for terminals where all glyphs
8483 have the same width don't use kerning.
8485 @DefreqList {kern, [@Var{flag}]}
8486 @DefregListEnd {.kern}
8487 @cindex activating kerning (@code{kern})
8488 @cindex kerning, activating (@code{kern})
8489 @cindex kerning enabled register (@code{.kern})
8490 Switch kerning on or off.  If the parameter is non-zero or missing,
8491 enable pairwise kerning, otherwise disable it.  The read-only number
8492 register @code{.kern} is set to@w{ }1 if pairwise kerning is enabled,
8493 0@w{ }otherwise.
8495 @cindex zero width space character (@code{\&})
8496 @cindex character, zero width space (@code{\&})
8497 @cindex space character, zero width (@code{\&})
8498 If the font description file contains pairwise kerning information,
8499 glyphs from that font are kerned.  Kerning between two glyphs
8500 can be inhibited by placing @code{\&} between them: @samp{V\&A}.
8502 @xref{Font File Format}.
8503 @endDefreq
8505 @cindex track kerning
8506 @cindex kerning, track
8507 @dfn{Track kerning} expands or reduces the space between glyphs.
8508 This can be handy, for example, if you need to squeeze a long word
8509 onto a single line or spread some text to fill a narrow column.  It
8510 must be used with great care since it is usually considered bad
8511 typography if the reader notices the effect.
8513 @Defreq {tkf, f s1 n1 s2 n2}
8514 @cindex activating track kerning (@code{tkf})
8515 @cindex track kerning, activating (@code{tkf})
8516 Enable track kerning for font@w{ }@var{f}.  If the current font is@w{
8517 }@var{f} the width of every glyph is increased by an amount
8518 between @var{n1} and @var{n2} (@var{n1}, @var{n2} can be negative); if
8519 the current point size is less than or equal to @var{s1} the width is
8520 increased by @var{n1}; if it is greater than or equal to @var{s2} the
8521 width is increased by @var{n2}; if the point size is greater than or
8522 equal to @var{s1} and less than or equal to @var{s2} the increase in
8523 width is a linear function of the point size.
8525 The default scaling indicator is @samp{z} for @var{s1} and @var{s2},
8526 @samp{p} for @var{n1} and @var{n2}.
8528 Note that the track kerning amount is added even to the rightmost glyph
8529 in a line; for large values it is thus recommended to increase the line
8530 length by the same amount to compensate it.
8531 @endDefreq
8533 Sometimes, when typesetting letters of different fonts, more or less
8534 space at such boundaries are needed.  There are two escapes to help
8535 with this.
8537 @Defesc {\\/, , , }
8538 @cindex italic correction (@code{\/})
8539 @cindex correction, italic (@code{\/})
8540 @cindex correction between italic and roman glyph (@code{\/}, @code{\,})
8541 @cindex roman glyph, correction after italic glyph (@code{\/})
8542 @cindex italic glyph, correction before roman glyph (@code{\/})
8543 @cindex glyph, italic correction (@code{\/})
8544 Increase the width of the preceding glyph so that the spacing
8545 between that glyph and the following glyph is correct if the
8546 following glyph is a roman glyph.  For example, if an
8547 italic@w{ }@code{f} is immediately followed by a roman right
8548 parenthesis, then in many fonts the top right portion of the@w{ }@code{f}
8549 overlaps the top left of the right parenthesis.  Use this escape
8550 sequence whenever an italic glyph is immediately followed by a
8551 roman glyph without any intervening space.  This small amount of
8552 space is also called @dfn{italic correction}.
8554 @iftex
8555 @example
8556 @group
8557 \f[I]f\f[R])
8558     @result{} {@it f}@r{)}
8559 \f[I]f\/\f[R])
8560     @result{} @i{f}@r{)}
8561 @end group
8562 @end example
8563 @end iftex
8564 @endDefesc
8566 @Defesc {\\\,, , , }
8567 @cindex left italic correction (@code{\,})
8568 @cindex correction, left italic (@code{\,})
8569 @cindex glyph, left italic correction (@code{\,})
8570 @cindex roman glyph, correction before italic glyph (@code{\,})
8571 @cindex italic glyph, correction after roman glyph (@code{\,})
8572 Modify the spacing of the following glyph so that the spacing
8573 between that glyph and the preceding glyph is correct if the
8574 preceding glyph is a roman glyph.  Use this escape sequence
8575 whenever a roman glyph is immediately followed by an italic
8576 glyph without any intervening space.  In analogy to above, this
8577 space could be called @dfn{left italic correction}, but this term
8578 isn't used widely.
8580 @iftex
8581 @example
8582 @group
8583 q\f[I]f
8584     @result{} @r{q}@i{f}
8585 q\,\f[I]f
8586     @result{} @r{q}@math{@ptexcomma}@i{f}
8587 @end group
8588 @end example
8589 @end iftex
8590 @endDefesc
8592 @Defesc {\\&, , , }
8593 Insert a zero-width character, which is invisible.  Its intended use
8594 is to stop interaction of a character with its surrounding.
8596 @itemize @bullet
8597 @item
8598 It prevents the insertion of extra space after an end-of-sentence
8599 character.
8601 @Example
8602 Test.
8603 Test.
8604     @result{} Test.  Test.
8605 Test.\&
8606 Test.
8607     @result{} Test. Test.
8608 @endExample
8610 @item
8611 It prevents interpretation of a control character at the beginning of
8612 an input line.
8614 @Example
8615 .Test
8616     @result{} warning: `Test' not defined
8617 \&.Test
8618     @result{} .Test
8619 @endExample
8621 @item
8622 It prevents kerning between two glyphs.
8624 @ifnotinfo
8625 @example
8626 @group
8628     @result{} @r{VA}
8629 V\&A
8630     @result{} @r{V@w{}A}
8631 @end group
8632 @end example
8633 @end ifnotinfo
8635 @item
8636 It is needed to map an arbitrary character to nothing in the @code{tr}
8637 request (@pxref{Character Translations}).
8638 @end itemize
8639 @endDefesc
8641 @Defesc {\\), , , }
8642 This escape is similar to @code{\&} except that it behaves like a
8643 character declared with the @code{cflags} request to be transparent
8644 for the purposes of an end-of-sentence character.
8646 Its main usage is in macro definitions to protect against arguments
8647 starting with a control character.
8649 @Example
8650 .de xxx
8651 \)\\$1
8653 .de yyy
8654 \&\\$1
8656 This is a test.\c
8657 .xxx '
8658 This is a test.
8659     @result{}This is a test.'  This is a test.
8660 This is a test.\c
8661 .yyy '
8662 This is a test.
8663     @result{}This is a test.' This is a test.
8664 @endExample
8665 @endDefesc
8668 @c =====================================================================
8670 @node Sizes, Strings, Fonts, gtroff Reference
8671 @section Sizes
8672 @cindex sizes
8674 @cindex baseline
8675 @cindex type size
8676 @cindex size of type
8677 @cindex vertical spacing
8678 @cindex spacing, vertical
8679 @code{gtroff} uses two dimensions with each line of text, type size
8680 and vertical spacing.  The @dfn{type size} is approximately the height
8681 of the tallest glyph.@footnote{This is usually the parenthesis.
8682 Note that in most cases the real dimensions of the glyphs in a font
8683 are @emph{not} related to its type size!  For example, the standard
8684 @sc{PostScript} font families `Times Roman', `Helvetica', and
8685 `Courier' can't be used together at 10@dmn{pt}; to get acceptable
8686 output, the size of `Helvetica' has to be reduced by one point, and
8687 the size of `Courier' must be increased by one point.}  @dfn{Vertical
8688 spacing} is the amount of space @code{gtroff} allows for a line of
8689 text; normally, this is about 20%@w{ }larger than the current type
8690 size.  Ratios smaller than this can result in hard-to-read text;
8691 larger than this, it spreads the text out more vertically (useful for
8692 term papers).  By default, @code{gtroff} uses 10@w{ }point type on
8693 12@w{ }point spacing.
8695 @cindex leading
8696 The difference between type size and vertical spacing is known, by
8697 typesetters, as @dfn{leading} (this is pronounced `ledding').
8699 @menu
8700 * Changing Type Sizes::
8701 * Fractional Type Sizes::
8702 @end menu
8704 @c ---------------------------------------------------------------------
8706 @node Changing Type Sizes, Fractional Type Sizes, Sizes, Sizes
8707 @subsection Changing Type Sizes
8709 @DefreqList {ps, [@Var{size}]}
8710 @DefreqItem {ps, @t{+}@Var{size}}
8711 @DefreqItem {ps, @t{-}@Var{size}}
8712 @DefescItem {\\s, , size, }
8713 @DefregListEnd {.s}
8714 @cindex changing type sizes (@code{ps}, @code{\s})
8715 @cindex type sizes, changing (@code{ps}, @code{\s})
8716 @cindex point sizes, changing (@code{ps}, @code{\s})
8717 Use the @code{ps} request or the @code{\s} escape to change (increase,
8718 decrease) the type size (in points).  Specify @var{size} as either an
8719 absolute point size, or as a relative change from the current size.
8720 The size@w{ }0, or no argument, goes back to the previous size.
8722 Default scaling indicator of @code{size} is @samp{z}.  If @code{size}
8723 is zero or negative, it is set to 1@dmn{u}.
8725 @cindex type size registers (@code{.s}, @code{.ps})
8726 @cindex point size registers (@code{.s}, @code{.ps})
8727 The read-only number register @code{.s} returns the point size in
8728 points as a decimal fraction.  This is a string.  To get the point
8729 size in scaled points, use the @code{.ps} register instead.
8731 @code{.s} is associated with the current environment
8732 (@pxref{Environments}).
8734 @Example
8735 snap, snap,
8736 .ps +2
8737 grin, grin,
8738 .ps +2
8739 wink, wink, \s+2nudge, nudge,\s+8 say no more!
8740 .ps 10
8741 @endExample
8743 The @code{\s} escape may be called in a variety of ways.  Much like
8744 other escapes there must be a way to determine where the argument ends
8745 and the text begins.  Any of the following forms are valid:
8747 @table @code
8748 @item \s@var{n}
8749 Set the point size to @var{n}@w{ }points.  @var{n}@w{ }must be either
8750 0 or in the range 4 to@w{ }39.
8752 @item \s+@var{n}
8753 @itemx \s-@var{n}
8754 Increase or decrease the point size by @var{n}@w{ }points.  @var{n}@w{
8755 }must be exactly one digit.
8757 @item \s(@var{nn}
8758 Set the point size to @var{nn}@w{ }points.  @var{nn} must be exactly
8759 two digits.
8761 @item \s+(@var{nn}
8762 @itemx \s-(@var{nn}
8763 @itemx \s(+@var{nn}
8764 @itemx \s(-@var{nn}
8765 Increase or decrease the point size by @var{nn}@w{ }points.  @var{nn}
8766 must be exactly two digits.
8767 @end table
8769 Note that @code{\s} doesn't produce an input token in @code{gtroff}.
8770 As a consequence, it can be used in requests like @code{mc} (which
8771 expects a single character as an argument) to change the font on
8772 the fly:
8774 @Example
8775 .mc \s[20]x\s[0]
8776 @endExample
8778 @xref{Fractional Type Sizes}, for yet another syntactical form of
8779 using the @code{\s} escape.
8780 @endDefreq
8782 @Defreq {sizes, s1 s2 @dots{} sn [0]}
8783 Some devices may only have certain permissible sizes, in which case
8784 @code{gtroff} rounds to the nearest permissible size.
8785 The @file{DESC} file specifies which sizes are permissible for the device.
8787 Use the @code{sizes} request to change the permissible sizes
8788 for the current output device.
8789 Arguments are in scaled points;
8790 the @code{sizescale} line in the
8791 @file{DESC} file for the output device
8792 provides the scaling factor.
8793 For example, if the scaling factor is 1000,
8794 then the value 12000 is 12@w{ }points.
8796 Each argument can be a single point size (such as @samp{12000}),
8797 or a range of sizes (such as @samp{4000-72000}).
8798 You can optionally end the list with a zero.
8799 @endDefreq
8801 @DefreqList {vs, [@Var{space}]}
8802 @DefreqItem {vs, @t{+}@Var{space}}
8803 @DefreqItem {vs, @t{-}@Var{space}}
8804 @DefregListEnd {.v}
8805 @cindex changing vertical line spacing (@code{vs})
8806 @cindex vertical line spacing, changing (@code{vs})
8807 @cindex vertical line spacing register (@code{.v})
8808 Change (increase, decrease) the vertical spacing by @var{space}.  The
8809 default scaling indicator is @samp{p}.
8811 If @code{vs} is called without an argument, the vertical spacing is
8812 reset to the previous value before the last call to @code{vs}.
8814 @cindex @code{.V} register, and @code{vs}
8815 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
8816 zero or negative; the vertical spacing is then set to the vertical
8817 resolution (as given in the @code{.V} register).
8819 The read-only number register @code{.v} contains the current vertical
8820 spacing; it is associated with the current environment
8821 (@pxref{Environments}).
8822 @endDefreq
8824 @cindex vertical line spacing, effective value
8825 The effective vertical line spacing consists of four components.
8827 @itemize @bullet
8828 @item
8829 The vertical line spacing as set with the @code{vs} request.
8831 @cindex post-vertical line spacing
8832 @cindex line spacing, post-vertical (@code{pvs})
8833 @item
8834 The @dfn{post-vertical line spacing} as set with the @code{pvs} request.
8835 This is vertical space which will be added after a line has been
8836 output.
8838 @cindex extra pre-vertical line space (@code{\x})
8839 @cindex line space, extra pre-vertical (@code{\x})
8840 @item
8841 The @dfn{extra pre-vertical line space} as set with the @code{\x} request,
8842 using a negative value.  This is vertical space which will be added once
8843 before the current line has been output.
8845 @cindex extra post-vertical line space (@code{\x})
8846 @cindex line space, extra post-vertical (@code{\x})
8847 @item
8848 The @dfn{extra post-vertical line space} as set with the @code{\x} request,
8849 using a positive value.  This is vertical space which will be added once
8850 after the current line has been output.
8851 @end itemize
8853 @cindex double-spacing (@code{vs}, @code{pvs})
8854 It is usually better to use @code{vs} or @code{pvs} instead of @code{ls}
8855 to produce double-spaced documents: @code{vs} and @code{pvs} have a finer
8856 granularity for the inserted vertical space compared to @code{ls};
8857 furthermore, certain preprocessors assume single-spacing.
8859 @xref{Manipulating Spacing}, for more details on the @code{\x} escape
8860 and the @code{ls} request.
8862 @DefreqList {pvs, [@Var{space}]}
8863 @DefreqItem {pvs, @t{+}@Var{space}}
8864 @DefreqItem {pvs, @t{-}@Var{space}}
8865 @DefregListEnd {.pvs}
8866 @cindex @code{ls} request, alternative to (@code{pvs})
8867 @cindex post-vertical line spacing, changing (@code{pvs})
8868 @cindex post-vertical line spacing register (@code{.pvs})
8869 Change (increase, decrease) the post-vertical spacing by
8870 @var{space}.  The default scaling indicator is @samp{p}.
8872 If @code{pvs} is called without an argument, the post-vertical spacing is
8873 reset to the previous value before the last call to @code{pvs}.
8875 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
8876 zero or negative; the vertical spacing is then set to zero.
8878 The read-only number register @code{.pvs} contains the current
8879 post-vertical spacing; it is associated with the current environment
8880 (@pxref{Environments}).
8881 @endDefreq
8884 @c ---------------------------------------------------------------------
8886 @node Fractional Type Sizes,  , Changing Type Sizes, Sizes
8887 @subsection Fractional Type Sizes
8888 @cindex fractional type sizes
8889 @cindex fractional point sizes
8890 @cindex type sizes, fractional
8891 @cindex point sizes, fractional
8892 @cindex sizes, fractional
8894 @cindex @code{s} unit
8895 @cindex unit, @code{s}
8896 @cindex @code{z} unit
8897 @cindex unit, @code{z}
8898 @cindex @code{ps} request, with fractional type sizes
8899 @cindex @code{cs} request, with fractional type sizes
8900 @cindex @code{tkf} request, with fractional type sizes
8901 @cindex @code{\H}, with fractional type sizes
8902 @cindex @code{\s}, with fractional type sizes
8903 A @dfn{scaled point} is equal to @math{1/@var{sizescale}} points,
8904 where @var{sizescale} is specified in the @file{DESC} file (1@w{ }by
8905 default).  There is a new scale indicator @samp{z} which has the
8906 effect of multiplying by @var{sizescale}.  Requests and escape
8907 sequences in @code{gtroff} interpret arguments that represent a point
8908 size as being in units of scaled points, but they evaluate each such
8909 argument using a default scale indicator of @samp{z}.  Arguments
8910 treated in this way are the argument to the @code{ps} request, the
8911 third argument to the @code{cs} request, the second and fourth
8912 arguments to the @code{tkf} request, the argument to the @code{\H}
8913 escape sequence, and those variants of the @code{\s} escape sequence
8914 that take a numeric expression as their argument (see below).
8916 For example, suppose @var{sizescale} is@w{ }1000; then a scaled point
8917 is equivalent to a millipoint; the request @w{@samp{.ps 10.25}} is
8918 equivalent to @w{@samp{.ps 10.25z}} and thus sets the point size to
8919 10250@w{ }scaled points, which is equal to 10.25@w{ }points.
8921 @code{gtroff} disallows the use of the @samp{z} scale indicator in
8922 instances where it would make no sense, such as a numeric
8923 expression whose default scale indicator was neither @samp{u} nor
8924 @samp{z}.  Similarly it would make
8925 no sense to use a scaling indicator other than @samp{z} or @samp{u} in a
8926 numeric expression whose default scale indicator was @samp{z}, and so
8927 @code{gtroff} disallows this as well.
8929 There is also new scale indicator @samp{s} which multiplies by the
8930 number of units in a scaled point.  So, for example, @samp{\n[.ps]s} is
8931 equal to @samp{1m}.  Be sure not to confuse the @samp{s} and @samp{z}
8932 scale indicators.
8934 @Defreg {.ps}
8935 A read-only number register returning the point size in scaled points.
8937 @code{.ps} is associated with the current environment
8938 (@pxref{Environments}).
8939 @endDefreg
8941 @DefregList {.psr}
8942 @DefregListEnd {.sr}
8943 @cindex last-requested point size registers (@code{.psr}, @code{.sr})
8944 @cindex point size registers, last-requested (@code{.psr}, @code{.sr})
8945 @cindex @code{.ps} register, in comparison with @code{.psr}
8946 @cindex @code{.s} register, in comparison with @code{.sr}
8947 The last-requested point size in scaled points is contained in the
8948 @code{.psr} read-only number register.  The last requested point size
8949 in points as a decimal fraction can be found in @code{.sr}.  This is a
8950 string-valued read-only number register.
8952 Note that the requested point sizes are device-independent, whereas
8953 the values returned by the @code{.ps} and @code{.s} registers are not.
8954 For example, if a point size of 11@dmn{pt} is requested, and a
8955 @code{sizes} request (or a @code{sizescale} line in a @file{DESC} file)
8956 specifies 10.95@dmn{pt} instead, this value is actually used.
8958 Both registers are associated with the current environment
8959 (@pxref{Environments}).
8960 @endDefreg
8962 The @code{\s} escape has the following syntax for working with
8963 fractional type sizes:
8965 @table @code
8966 @item \s[@var{n}]
8967 @itemx \s'@var{n}'
8968 Set the point size to @var{n}@w{ }scaled points; @var{n}@w{ }is a numeric
8969 expression with a default scale indicator of @samp{z}.
8971 @item \s[+@var{n}]
8972 @itemx \s[-@var{n}]
8973 @itemx \s+[@var{n}]
8974 @itemx \s-[@var{n}]
8975 @itemx \s'+@var{n}'
8976 @itemx \s'-@var{n}'
8977 @itemx \s+'@var{n}'
8978 @itemx \s-'@var{n}'
8979 Increase or or decrease the point size by @var{n}@w{ }scaled points;
8980 @var{n}@w{ }is a numeric expression with a default scale indicator of
8981 @samp{z}.
8982 @end table
8984 @xref{Font Files}.
8987 @c =====================================================================
8989 @node Strings, Conditionals and Loops, Sizes, gtroff Reference
8990 @section Strings
8991 @cindex strings
8993 @code{gtroff} has string variables, which are entirely for user
8994 convenience (i.e.@: there are no built-in strings exept @code{.T}, but
8995 even this is a read-write string variable).
8997 @DefreqList {ds, name [@Var{string}]}
8998 @DefreqItem {ds1, name [@Var{string}]}
8999 @DefescItem {\\*, , n, }
9000 @DefescItem {\\*, @lparen{}, nm, }
9001 @DefescListEnd {\\*, @lbrack{}, name, @rbrack{}}
9002 @cindex string interpolation (@code{\*})
9003 @cindex string expansion (@code{\*})
9004 @cindex interpolation of strings (@code{\*})
9005 @cindex expansion of strings (@code{\*})
9006 Define and access a string variable @var{name} (one-character name@w{
9007 }@var{n}, two-character name @var{nm}).  If @var{name} already exists,
9008 @code{ds} overwrites the previous definition.
9010 Example:
9012 @Example
9013 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d
9015 The \*(UX Operating System
9016 @endExample
9018 The @code{\*} escape @dfn{interpolates} (expands in-place) a
9019 previously-defined string variable.  To be more precise, the stored
9020 string is pushed onto the input stack which is then parsed by
9021 @code{gtroff}.  Similar to number registers, it is possible to nest
9022 strings, i.e. string variables can be called within string variables.
9024 If the string named by the @code{\*} escape does not exist, it is
9025 defined as empty, and a warning of type @samp{mac} is emitted (see
9026 @ref{Debugging}, for more details).
9028 @cindex comments, with @code{ds}
9029 @cindex @code{ds} request, and comments
9030 @strong{Caution:} Unlike other requests, the second argument to the
9031 @code{ds} request takes up the entire line including trailing spaces.
9032 This means that comments on a line with such a request can introduce
9033 unwanted space into a string.
9035 @Example
9036 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d \" UNIX trademark
9037 @endExample
9039 @noindent
9040 Instead the comment should be put on another line or have the comment
9041 escape adjacent with the end of the string.
9043 @Example
9044 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d\"  UNIX trademark
9045 @endExample
9047 @cindex trailing quotes
9048 @cindex quotes, trailing
9049 @cindex leading spaces with @code{ds}
9050 @cindex spaces with @code{ds}
9051 @cindex @code{ds} request, and leading spaces
9052 To produce leading space the string can be started with a double
9053 quote.  No trailing quote is needed; in fact, any trailing quote is
9054 included in your string.
9056 @Example
9057 .ds sign "           Yours in a white wine sauce,
9058 @endExample
9060 @cindex multi-line strings
9061 @cindex strings, multi-line
9062 @cindex newline character, in strings, escaping
9063 @cindex escaping newline characters, in strings
9064 Strings are not limited to a single line of text.  A string can span
9065 several lines by escaping the newlines with a backslash.  The
9066 resulting string is stored @emph{without} the newlines.
9068 @Example
9069 .ds foo lots and lots \
9070 of text are on these \
9071 next several lines
9072 @endExample
9074 It is not possible to have real newlines in a string.  To put a single
9075 double quote character into a string, use two consecutive double quote
9076 characters.
9078 The @code{ds1} request turns off compatibility mode
9079 while interpreting a string.  To be more precise, a @dfn{compatibility
9080 save} input token is inserted at the beginning of  the string, and a
9081 @dfn{compatibility restore} input token at the end.
9083 @Example
9084 .nr xxx 12345
9085 .ds aa The value of xxx is \\n[xxx].
9086 .ds1 bb The value of xxx ix \\n[xxx].
9088 .cp 1
9090 \*(aa
9091     @result{} warning: number register `[' not defined
9092     @result{} The value of xxx is 0xxx].
9093 \*(bb
9094     @result{} The value of xxx ix 12345.
9095 @endExample
9097 @cindex name space, common, of macros, diversions, and strings
9098 @cindex common name space of macros, diversions, and strings
9099 @cindex macros, shared name space with strings and diversions
9100 @cindex strings, shared name space with macros and diversions
9101 @cindex diversions, shared name space with macros and strings
9102 Strings, macros, and diversions (and boxes) share the same name space.
9103 Internally, even the same mechanism is used to store them.  This has
9104 some interesting consequences.  For example, it is possible to call a
9105 macro with string syntax and vice versa.
9107 @Example
9108 .de xxx
9109 a funny test.
9111 This is \*[xxx]
9112     @result{} This is a funny test.
9114 .ds yyy a funny test
9115 This is
9116 .yyy
9117     @result{} This is a funny test.
9118 @endExample
9120 Diversions and boxes can be also called with string syntax.  It is not
9121 possible to pass arguments to a macro if called with @code{\*}.
9123 Another consequence is that you can copy one-line diversions or boxes
9124 to a string.
9126 @Example
9127 .di xxx
9128 a \fItest\fR
9131 .ds yyy This is \*[xxx]\c
9132 \*[yyy].
9133     @result{} @r{This is a }@i{test}.
9134 @endExample
9136 @noindent
9137 As the previous example shows, it is possible to store formatted
9138 output in strings.  The @code{\c} escape prevents the insertion of an
9139 additional blank line in the output.
9141 Copying diversions longer than a single output line produces
9142 unexpected results.
9144 @Example
9145 .di xxx
9146 a funny
9148 test
9151 .ds yyy This is \*[xxx]\c
9152 \*[yyy].
9153     @result{} test This is a funny.
9154 @endExample
9156 Usually, it is not predictable whether a diversion contains one or
9157 more output lines, so this mechanism should be avoided.  With
9158 @acronym{UNIX} @code{troff}, this was the only solution to strip off a
9159 final newline from a diversion.  Another disadvantage is that the
9160 spaces in the copied string are already formatted, making them
9161 unstretchable.  This can cause ugly results.
9163 @cindex stripping final newline in diversions
9164 @cindex diversion, stripping final newline
9165 @cindex final newline, stripping in diversions
9166 @cindex newline, final, stripping in diversions
9167 @cindex horizontal space, unformatting
9168 @cindex space, horizontal, unformatting
9169 @cindex unformatting horizontal space
9170 A clean solution to this problem is available in GNU @code{troff},
9171 using the requests @code{chop} to remove the final newline of a
9172 diversion, and @code{unformat} to make the horizontal spaces
9173 stretchable again.
9175 @Example
9176 .box xxx
9177 a funny
9179 test
9181 .box
9182 .chop xxx
9183 .unformat xxx
9184 This is \*[xxx].
9185     @result{} This is a funny test.
9186 @endExample
9188 @xref{Gtroff Internals}, for more information.
9189 @endDefreq
9191 @DefreqList {as, name [@Var{string}]}
9192 @DefreqListEnd {as1, name [@Var{string}]}
9193 @cindex appending to a string (@code{as})
9194 @cindex string, appending (@code{as})
9195 The @code{as} request is similar to @code{ds} but appends @var{string}
9196 to the string stored as @var{name} instead of redefining it.  If
9197 @var{name} doesn't exist yet, it is created.
9199 @Example
9200 .as sign " with shallots, onions and garlic,
9201 @endExample
9203 The @code{as1} request is similar to @code{as}, but compatibility mode
9204 is switched off while the appended string is interpreted.  To be more
9205 precise, a @dfn{compatibility save} input token is inserted at the
9206 beginning of the appended string, and a @dfn{compatibility restore}
9207 input token at the end.
9208 @endDefreq
9210 Rudimentary string manipulation routines are given with the next two
9211 requests.
9213 @Defreq {substring, str n1 [@Var{n2}]}
9214 @cindex substring (@code{substring})
9215 Replace the string named @var{str} with the substring
9216 defined by the indices @var{n1} and@w{ }@var{n2}.  The first character
9217 in the string has index one.  If @var{n2} is omitted, it is taken to
9218 be equal to the string's length.  If the index value @var{n1} or
9219 @var{n2} is negative or zero, it is counted from the end of the
9220 string, going backwards: The last character has index@w{ }0, the
9221 character before the last character has index@w{ }@minus{}1, etc.
9223 @Example
9224 .ds xxx abcdefgh
9225 .substring xxx 2 -3
9226 \*[xxx]
9227     @result{} bcde
9228 @endExample
9229 @endDefreq
9231 @Defreq {length, reg str}
9232 @cindex length of a string (@code{length})
9233 @cindex string, length of (@code{length})
9234 Compute the number of characters of @var{str} and return it in the
9235 number register @var{reg}.  If @var{reg} doesn't exist, it is created.
9236 @code{str} is read in copy mode.
9238 @Example
9239 .ds xxx abcd\h'3i'efgh
9240 .length yyy \n[xxx]
9241 \n[yyy]
9242     @result{} 14
9243 @endExample
9244 @endDefreq
9246 @Defreq {rn, xx yy}
9247 @cindex renaming request (@code{rn})
9248 @cindex request, renaming (@code{rn})
9249 @cindex renaming macro (@code{rn})
9250 @cindex macro, renaming (@code{rn})
9251 @cindex renaming string (@code{rn})
9252 @cindex string, renaming (@code{rn})
9253 @cindex renaming diversion (@code{rn})
9254 @cindex diversion, renaming (@code{rn})
9255 Rename the request, macro, diversion, or string @var{xx} to @var{yy}.
9256 @endDefreq
9258 @Defreq {rm, xx}
9259 @cindex removing request (@code{rm})
9260 @cindex request, removing (@code{rm})
9261 @cindex removing macro (@code{rm})
9262 @cindex macro, removing (@code{rm})
9263 @cindex removing string (@code{rm})
9264 @cindex string, removing (@code{rm})
9265 @cindex removing diversion (@code{rm})
9266 @cindex diversion, removing (@code{rm})
9267 Remove the request, macro, diversion, or string @var{xx}.  @code{gtroff}
9268 treats subsequent invocations as if the object had never been defined.
9269 @endDefreq
9271 @Defreq {als, new old}
9272 @cindex alias, string, creating (@code{als})
9273 @cindex alias, macro, creating (@code{als})
9274 @cindex alias, diversion, creating (@code{als})
9275 @cindex creating alias, for string (@code{als})
9276 @cindex creating alias, for macro (@code{als})
9277 @cindex creating alias, for diversion (@code{als})
9278 @cindex string, creating alias (@code{als})
9279 @cindex macro, creating alias (@code{als})
9280 @cindex diversion, creating alias (@code{als})
9281 Create an alias named @var{new} for the request, string, macro, or
9282 diversion object named @var{old}.  The new name and the old name are
9283 exactly equivalent (it is similar to a hard rather than a soft
9284 link). If @var{old} is undefined, @code{gtroff} generates a warning of
9285 type @samp{mac} and ignores the request.
9286 @endDefreq
9288 @Defreq {chop, xx}
9289 Remove (chop) the last character from the macro, string, or diversion
9290 named @var{xx}. This is useful for removing the newline from the end
9291 of diversions that are to be interpolated as strings.  This command
9292 can be used repeatedly; see @ref{Gtroff Internals}, for details on
9293 nodes inserted additionally by @code{gtroff}.
9294 @endDefreq
9296 @xref{Identifiers}, and @ref{Comments}.
9299 @c =====================================================================
9301 @node Conditionals and Loops, Writing Macros, Strings, gtroff Reference
9302 @section Conditionals and Loops
9303 @cindex conditionals and loops
9304 @cindex loops and conditionals
9306 @menu
9307 * Operators in Conditionals::
9308 * if-else::
9309 * while::
9310 @end menu
9312 @c ---------------------------------------------------------------------
9314 @node Operators in Conditionals, if-else, Conditionals and Loops, Conditionals and Loops
9315 @subsection Operators in Conditionals
9317 @cindex @code{if} request, operators to use with
9318 @cindex @code{while} request, operators to use with
9319 In @code{if} and @code{while} requests, there are several more
9320 operators available:
9322 @table @code
9323 @item e
9324 @itemx o
9325 True if the current page is even or odd numbered (respectively).
9327 @item n
9328 True if the document is being processed in nroff mode (i.e., the
9329 @code{.nroff} command has been issued).
9331 @item t
9332 True if the document is being processed in troff mode (i.e., the
9333 @code{.troff} command has been issued).
9335 @item v
9336 Always false.  This condition is for compatibility with other
9337 @code{troff} versions only.
9339 @item '@var{xxx}'@var{yyy}'
9340 True if the string @var{xxx} is equal to the string @var{yyy}.  Other
9341 characters can be used in place of the single quotes; the same set of
9342 delimiters as for the @code{\D} escape is used (@pxref{Escapes}).
9343 @code{gtroff} formats the strings before being compared:
9345 @Example
9346 .ie "|"\fR|\fP" \
9347 true
9348 .el \
9349 false
9350     @result{} true
9351 @endExample
9353 @noindent
9354 The resulting motions, glyph sizes, and fonts have to
9355 match,@footnote{The created output nodes must be identical.
9356 @xref{Gtroff Internals}.} and not the individual motion, size, and
9357 font requests.  In the previous example, @samp{|} and @samp{\fR|\fP}
9358 both result in a roman @samp{|} glyph with the same point size and
9359 at the same location on the page, so the strings are equal.  If
9360 @samp{.ft@w{ }I} had been added before the @samp{.ie}, the result
9361 would be ``false'' because (the first) @samp{|} produces an italic
9362 @samp{|} rather than a roman one.
9364 @item r @var{xxx}
9365 True if there is a number register named @var{xxx}.
9367 @item d @var{xxx}
9368 True if there is a string, macro, diversion, or request named @var{xxx}.
9370 @item m @var{xxx}
9371 True if there is a color named @var{xxx}.
9373 @item c @var{g}
9374 True if there is a glyph @var{g} available@footnote{The name of this
9375 conditional operator is a misnomer since it tests names of output
9376 glyphs.}; @var{g} is either an @acronym{ASCII} character or a special
9377 character (@code{\(@var{gg}} or @code{\[@var{ggg}]}); the condition
9378 is also true if @var{g} has been defined by the @code{char} request.
9379 @end table
9381 Note that these operators can't be combined with other operators like
9382 @samp{:} or @samp{&}; only a leading @samp{!} (without whitespace
9383 between the exclamation mark and the operator) can be used to negate
9384 the result.
9386 @Example
9387 .nr xxx 1
9388 .ie !r xxx \
9389 true
9390 .el \
9391 false
9392     @result{} false
9393 @endExample
9395 A whitespace after @samp{!} always evaluates to zero (this bizarre
9396 behaviour is due to compatibility with @acronym{UNIX} @code{troff}).
9398 @Example
9399 .nr xxx 1
9400 .ie ! r xxx \
9401 true
9402 .el \
9403 false
9404     @result{} r xxx true
9405 @endExample
9407 It is possible to omit the whitespace before the argument to the
9408 @samp{r}, @samp{d}, and @samp{c} operators.
9410 @xref{Expressions}.
9412 @c ---------------------------------------------------------------------
9414 @node if-else, while, Operators in Conditionals, Conditionals and Loops
9415 @subsection if-else
9416 @cindex if-else
9418 @code{gtroff} has if-then-else constructs like other languages, although
9419 the formatting can be painful.
9421 @Defreq {if, expr anything}
9422 Evaluate the expression @var{expr}, and executes @var{anything} (the
9423 remainder of the line) if @var{expr} evaluates to non-zero (true).
9424 @var{anything} is interpreted as though it was on a line by itself
9425 (except that leading spaces are swallowed).  @xref{Expressions}, for
9426 more info.
9428 @Example
9429 .nr xxx 1
9430 .nr yyy 2
9431 .if ((\n[xxx] == 1) & (\n[yyy] == 2)) true
9432     @result{} true
9433 @endExample
9434 @endDefreq
9436 @Defreq{nop, anything}
9437 Executes @var{anything}.
9438 This is similar to @code{.if@w{ }1}.
9439 @endDefreq
9441 @DefreqList {ie, expr anything}
9442 @DefreqListEnd {el, anything}
9443 Use the @code{ie} and @code{el} requests to write an if-then-else.
9444 The first request is the `if' part and the latter is the `else' part.
9446 @Example
9447 .ie n .ls 2 \" double-spacing in nroff
9448 .el   .ls 1 \" single-spacing in troff
9449 @endExample
9450 @endDefreq
9452 @c there is a bug in makeinfo <= 4.1a: you can't have `@{' as an argument
9453 @c to @deffn
9455 @c and in 4.2 you still can't use @{ in macros.
9457 @c @DefescList {\@{, , , }
9458 @c @DefescListEnd {\@}, , , }
9459 @deffn Escape @t{\@{}
9460 @deffnx Escape @t{\@}}
9461 @esindex \@{
9462 @esindex \@}
9463 @cindex begin of conditional block (@code{\@{})
9464 @cindex end of conditional block (@code{\@}})
9465 @cindex conditional block, begin (@code{\@{})
9466 @cindex conditional block, end (@code{\@}})
9467 @cindex block, conditional, begin (@code{\@{})
9468 @cindex block, condititional, end (@code{\@}})
9469 In many cases, an if (or if-else) construct needs to execute more than
9470 one request.  This can be done using the @code{\@{} and @code{\@}}
9471 escapes.  The following example shows the possible ways to use these
9472 escapes (note the position of the opening and closing braces).
9474 @Example
9475 .ie t \@{\
9476 .    ds lq ``
9477 .    ds rq ''
9478 .\@}
9479 .el \
9480 .\@{\
9481 .    ds lq "
9482 .    ds rq "\@}
9483 @endExample
9484 @c @endDefesc
9485 @end deffn
9487 @xref{Expressions}.
9489 @c ---------------------------------------------------------------------
9491 @node while,  , if-else, Conditionals and Loops
9492 @subsection while
9493 @cindex while
9495 @code{gtroff} provides a looping construct using the @code{while}
9496 request, which is used much like the @code{if} (and related) requests.
9498 @Defreq {while, expr anything}
9499 Evaluate the expression @var{expr}, and repeatedly execute
9500 @var{anything} (the remainder of the line) until @var{expr} evaluates
9501 to@w{ }0.
9503 @Example
9504 .nr a 0 1
9505 .while (\na < 9) \@{\
9506 \n+a,
9507 .\@}
9508 \n+a
9509     @result{} 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
9510 @endExample
9512 Some remarks.
9514 @cindex @code{de} request, and @code{while}
9515 @itemize @bullet
9516 @item
9517 The body of a @code{while} request is treated like the body of a
9518 @code{de} request: @code{gtroff} temporarily stores it in a macro
9519 which is deleted after the loop has been exited.  It can considerably
9520 slow down a macro if the body of the @code{while} request (within the
9521 macro) is large.  Each time the macro is executed, the @code{while}
9522 body is parsed and stored again as a temporary macro.
9524 @Example
9525 .de xxx
9526 .  nr num 10
9527 .  while (\\n[num] > 0) \@{\
9528 .    \" many lines of code
9529 .    nr num -1
9530 .  \@}
9532 @endExample
9534 @cindex recursive macros
9535 @cindex macros, recursive
9536 @noindent
9537 The traditional and ofter better solution (@acronym{UNIX} @code{troff}
9538 doesn't have the @code{while} request) is to use a recursive macro
9539 instead which is parsed only once during its definition.
9541 @Example
9542 .de yyy
9543 .  if (\\n[num] > 0) \@{\
9544 .    \" many lines of code
9545 .    nr num -1
9546 .    yyy
9547 .  \@}
9550 .de xxx
9551 .  nr num 10
9552 .  yyy
9554 @endExample
9556 @noindent
9557 Note that the number of available recursion levels is set to@w{ }1000
9558 (this is a compile-time constant value of @code{gtroff}).
9560 @item
9561 The closing brace of a @code{while} body must end a line.
9563 @Example
9564 .if 1 \@{\
9565 .  nr a 0 1
9566 .  while (\n[a] < 10) \@{\
9567 .    nop \n+[a]
9568 .\@}\@}
9569     @result{} unbalanced \@{ \@}
9570 @endExample
9571 @end itemize
9572 @endDefreq
9574 @Defreq {break, }
9575 @cindex @code{while} request, confusing with @code{br}
9576 @cindex @code{break} request, in a @code{while} loop
9577 @cindex @code{continue} request, in a @code{while} loop
9578 Break out of a @code{while} loop.  Be sure not to confuse this with
9579 the @code{br} request (causing a line break).
9580 @endDefreq
9582 @Defreq {continue, }
9583 Finish the current iteration of a @code{while} loop, immediately
9584 restarting the next iteration.
9585 @endDefreq
9587 @xref{Expressions}.
9590 @c =====================================================================
9592 @node Writing Macros, Page Motions, Conditionals and Loops, gtroff Reference
9593 @section Writing Macros
9594 @cindex writing macros
9595 @cindex macros, writing
9597 A @dfn{macro} is a collection of text and embedded commands which can
9598 be invoked multiple times.  Use macros to define common operations.
9600 @DefreqList {de, name [@Var{end}]}
9601 @DefreqItem {de1, name [@Var{end}]}
9602 @DefreqListEnd {dei, name [@Var{end}]}
9603 Define a new macro named @var{name}.  @code{gtroff} copies subsequent
9604 lines (starting with the next one) into an internal buffer until it
9605 encounters the line @samp{..} (two dots).  The optional second
9606 argument to @code{de} changes this to a macro to @samp{.@var{end}}.
9608 There can be whitespace after the first dot in the line containing the
9609 ending token (either @samp{.} or macro @samp{@var{end}}).
9611 Here a small example macro called @samp{P} which causes a break and
9612 inserts some vertical space.  It could be used to separate paragraphs.
9614 @Example
9615 .de P
9616 .  br
9617 .  sp .8v
9619 @endExample
9621 The following example defines a macro within another.  Remember that
9622 expansion must be protected twice; once for reading the macro and
9623 once for executing.
9625 @Example
9626 \# a dummy macro to avoid a warning
9627 .de end
9630 .de foo
9631 .  de bar end
9632 .    nop \f[B]Hallo \\\\$1!\f[]
9633 .  end
9636 .foo
9637 .bar Joe
9638     @result{} @b{Hallo Joe!}
9639 @endExample
9641 @noindent
9642 Since @code{\f} has no expansion, it isn't necessary to protect its
9643 backslash.  Had we defined another macro within @code{bar} which takes
9644 a parameter, eight backslashes would be necessary before @samp{$1}.
9646 The @code{de1} request turns off compatibility mode
9647 while executing the macro.  On entry, the current compatibility mode
9648 is saved and restored at exit.
9650 @Example
9651 .nr xxx 12345
9653 .de aa
9654 The value of xxx is \\n[xxx].
9656 .de1 bb
9657 The value of xxx ix \\n[xxx].
9660 .cp 1
9663     @result{} warning: number register \e' not defined
9664     @result{} The value of xxx is 0xxx].
9666     @result{} The value of xxx ix 12345.
9667 @endExample
9669 The @code{dei} request defines a macro indirectly.
9670 That is, it expands strings whose names
9671 are @var{name} or @var{end} before performing the append.
9673 This:
9675 @Example
9676 .ds xx aa
9677 .ds yy bb
9678 .dei xx yy
9679 @endExample
9681 @noindent
9682 is equivalent to:
9684 @Example
9685 .de aa bb
9686 @endExample
9688 @pindex trace.tmac
9689 Using @file{trace.tmac}, you can trace calls to @code{de} and @code{de1}.
9691 Note that macro identifiers are shared with identifiers for strings and
9692 diversions.
9693 @endDefreq
9695 @DefreqList {am, xx}
9696 @DefreqItem {am1, xx}
9697 @DefreqListEnd {ami, xx yy}
9698 @cindex appending to a macro (@code{am})
9699 @cindex macro, appending (@code{am})
9700 Works similarly to @code{de} except it appends onto the macro named
9701 @var{xx}.  So, to make the previously defined @samp{P} macro actually
9702 do indented instead of block paragraphs, add the necessary code to the
9703 existing macro like this:
9705 @Example
9706 .am P
9707 .ti +5n
9709 @endExample
9711 The @code{am1} request turns off compatibility mode
9712 while executing the appended macro piece.  To be more precise, a
9713 @dfn{compatibility save} input token is inserted at the beginning of
9714 the appended code, and a @dfn{compatibility restore} input token at
9715 the end.
9717 The @code{ami} request appends indirectly,
9718 meaning that @code{gtroff} expands strings whose names
9719 are @var{xx} or @var{yy} before performing the append.
9721 @pindex trace.tmac
9722 Using @file{trace.tmac}, you can trace calls to @code{am} and @code{am1}.
9723 @endDefreq
9725 @xref{Strings}, for the @code{als} request to rename a macro.
9727 The @code{de}, @code{am}, @code{di}, @code{da}, @code{ds}, and
9728 @code{as} requests (together with its variants) only create a new object
9729 if the name of the macro, diversion or string diversion is currently
9730 undefined or if it is defined to be a request; normally they modify the
9731 value of an existing object.
9733 @Defreq {return, }
9734 Exit a macro, immediately returning to the caller.
9735 @endDefreq
9737 @menu
9738 * Copy-in Mode::
9739 * Parameters::
9740 @end menu
9742 @c ---------------------------------------------------------------------
9744 @node Copy-in Mode, Parameters, Writing Macros, Writing Macros
9745 @subsection Copy-in Mode
9746 @cindex copy-in mode
9747 @cindex mode, copy-in
9749 @cindex @code{\n}, when reading text for a macro
9750 @cindex @code{\$}, when reading text for a macro
9751 @cindex @code{\*}, when reading text for a macro
9752 @cindex @code{\\}, when reading text for a macro
9753 @cindex \@key{RET}, when reading text for a macro
9754 When @code{gtroff} reads in the text for a macro or diversion, it copies
9755 the text (including request lines, but excluding escapes) into an
9756 internal buffer.  Escapes are converted into an internal form,
9757 except for @code{\n}, @code{\$}, @code{\*}, @code{\\} and
9758 @code{\@key{RET}} which are evaluated and inserted into the text where
9759 the escape was located.  This is known as @dfn{copy-in} mode or
9760 @dfn{copy} mode.
9762 What this means is that you can specify when these escapes are to be
9763 evaluated (either at copy-in time or at the time of use) by insulating
9764 the escapes with an extra backslash.  Compare this to the @code{\def}
9765 and @code{\edef} commands in @TeX{}.
9767 The following example prints the numbers 20 and@w{ }10:
9769 @Example
9770 .nr x 20
9771 .de y
9772 .nr x 10
9773 \&\nx
9774 \&\\nx
9777 @endExample
9779 @c ---------------------------------------------------------------------
9781 @node Parameters,  , Copy-in Mode, Writing Macros
9782 @subsection Parameters
9783 @cindex parameters
9785 The arguments to a macro can be examined using a variety of escapes.
9787 @Defreg {.$}
9788 @cindex number of arguments register (@code{.$})
9789 The number of arguments in a macro.  This is a read-only number register.
9790 @endDefreg
9792 Any individual argument can be retrieved with one of the following
9793 escapes:
9795 @DefescList {\\$, , n, }
9796 @DefescItem {\\$, @lparen{}, nn, }
9797 @DefescListEnd {\\$, @lbrack{}, nnn, @rbrack{}}
9798 @cindex copy-in mode, and macro arguments
9799 @cindex macro, arguments (@code{\$})
9800 @cindex arguments, macro (@code{\$})
9801 Retrieve the @var{n}@dmn{th}, @var{nn}@dmn{th} or @var{nnn}@dmn{th}
9802 argument.  As usual, the first form only accepts a single number
9803 (larger than zero), the second a two-digit number (larger or equal
9804 to@w{ }10), and the third any positive integer value (larger
9805 than zero).  Macros can have an unlimited number of arguments.  Note
9806 that due to copy-in mode, use two backslashes on these in actual use to
9807 prevent interpolation until the macro is actually invoked.
9808 @endDefesc
9810 @Defreq {shift, [@Var{n}]}
9811 Shift the arguments 1@w{ }position, or as
9812 many positions as specified by its argument.  After executing this
9813 request, argument@w{ }@var{i} becomes argument @math{@var{i}-@var{n}};
9814 arguments 1 to@w{ }@var{n} are no longer available.  Shifting by
9815 negative amounts is currently undefined.
9816 @endDefreq
9818 @DefescList {\\$*, , , }
9819 @DefescListEnd {\\$@@, , , }
9820 In some cases it is convenient to use all of the arguments at once (for
9821 example, to pass the arguments along to another macro).  The @code{\$*}
9822 escape concatenates all the arguments separated by spaces.  A
9823 similar escape is @code{\$@@}, which concatenates all the
9824 arguments with each surrounded by double quotes, and separated by
9825 spaces.  If not in compatibility mode, the input level of double quotes
9826 is preserved (see @ref{Request Arguments}).
9827 @endDefesc
9829 @Defesc {\\$0, , , }
9830 @cindex macro name register (@code{\$0})
9831 @cindex @code{als} request, and @code{\$0}
9832 The name used to invoke the current macro.
9833 The @code{als} request can make a macro have more than one name.
9835 @Example
9836 .de generic-macro
9837 .  ...
9838 .  if \\n[error] \@{\
9839 .    tm \\$0: Houston, we have a problem.
9840 .    return
9841 .  \@}
9844 .als foo generic-macro
9845 .als bar generic-macro
9846 @endExample
9847 @endDefesc
9849 @xref{Request Arguments}.
9852 @c =====================================================================
9854 @node Page Motions, Drawing Requests, Writing Macros, gtroff Reference
9855 @section Page Motions
9856 @cindex page motions
9857 @cindex motions, page
9859 @xref{Manipulating Spacing}, for a discussion of the main request for
9860 vertical motion, @code{sp}.
9862 @DefreqList {mk, [@Var{reg}]}
9863 @DefreqListEnd {rt, [@Var{dist}]}
9864 @cindex marking vertical page location (@code{mk})
9865 @cindex page location, vertical, marking (@code{mk})
9866 @cindex location, vertical, page, marking (@code{mk})
9867 @cindex vertical page location, marking (@code{mk})
9868 @cindex returning to marked vertical page location (@code{rt})
9869 @cindex page location, vertical, returning to marked (@code{rt})
9870 @cindex location, vertical, page, returning to marked (@code{rt})
9871 @cindex vertical page location, returning to marked (@code{rt})
9872 The request @code{mk} can be used to mark a location on a page, for
9873 movement to later.  This request takes a register name as an argument
9874 in which to store the current page location.  With no argument it
9875 stores the location in an internal register.  The results of this can
9876 be used later by the @code{rt} or the @code{sp} request (or the
9877 @code{\v} escape).
9879 The @code{rt} request returns @emph{upwards} to the location marked
9880 with the last @code{mk} request.  If used with an argument, return to
9881 a position which distance from the top of the page is @var{dist} (no
9882 previous call to @code{mk} is necessary in this case).  Default scaling
9883 indicator is @samp{v}.
9885 Here a primitive solution for a two-column macro.
9887 @Example
9888 .nr column-length 1.5i
9889 .nr column-gap 4m
9890 .nr bottom-margin 1m
9892 @endExample
9893 @Example
9894 .de 2c
9895 .  br
9896 .  mk
9897 .  ll \\n[column-length]u
9898 .  wh -\\n[bottom-margin]u 2c-trap
9899 .  nr right-side 0
9902 @endExample
9903 @Example
9904 .de 2c-trap
9905 .  ie \\n[right-side] \@{\.    nr right-side 0
9906 .    po -(\\n[column-length]u + \\n[column-gap]u)
9907 .    \" remove trap
9908 .    wh -\\n[bottom-margin]u
9909 .  \@}
9910 .  el \@{\
9911 .    \" switch to right side
9912 .    nr right-side 1
9913 .    po +(\\n[column-length]u + \\n[column-gap]u)
9914 .    rt
9915 .  \@}
9918 @endExample
9919 @Example
9920 .pl 1.5i
9921 .ll 4i
9922 This is a small test which shows how the
9923 rt request works in combination with mk.
9926 Starting here, text is typeset in two columns.
9927 Note that this implementation isn't robust
9928 and thus not suited for a real two-column
9929 macro.
9930 @endExample
9932 Result:
9934 @Example
9935 This is a small test which shows how the
9936 rt request works in combination with mk.
9938 Starting  here,    isn't    robust
9939 text is typeset    and   thus  not
9940 in two columns.    suited  for   a
9941 Note that  this    real two-column
9942 implementation     macro.
9943 @endExample
9944 @endDefreq
9946 The following escapes give fine control of movements about the page.
9948 @Defesc {\\v, ', e, '}
9949 @cindex vertical motion (@code{\v})
9950 @cindex motion, vertical (@code{\v})
9951 Move vertically, usually from the current location on the page (if no
9952 absolute position operator @samp{|} is used).  The
9953 argument@w{ }@var{e} specifies the distance to move; positive is
9954 downwards and negative upwards.  The default scaling indicator for this
9955 escape is @samp{v}.  Beware, however, that @code{gtroff} continues text
9956 processing at the point where the motion ends, so you should always
9957 balance motions to avoid interference with text processing.
9959 @code{\v} doesn't trigger a trap.  This can be quite useful; for example,
9960 consider a page bottom trap macro which prints a marker in the margin to
9961 indicate continuation of a footnote or something similar.
9962 @endDefesc
9964 There are some special-case escapes for vertical motion.
9966 @Defesc {\\r, , , }
9967 Move upwards@w{ }1@dmn{v}.
9968 @endDefesc
9970 @Defesc {\\u, , , }
9971 Move upwards@w{ }.5@dmn{v}.
9972 @endDefesc
9974 @Defesc {\\d, , , }
9975 Move down@w{ }.5@dmn{v}.
9976 @endDefesc
9978 @Defesc {\\h, ', e, '}
9979 @cindex inserting horizontal space (@code{\h})
9980 @cindex horizontal space (@code{\h})
9981 @cindex space, horizontal (@code{\h})
9982 @cindex horizontal motion (@code{\h})
9983 @cindex motion, horizontal (@code{\h})
9984 Move horizontally, usually from the current location (if no absolute
9985 position operator @samp{|} is used).  The expression@w{ }@var{e}
9986 indicates how far to move: positive is rightwards and negative
9987 leftwards.  The default scaling indicator for this escape is @samp{m}.
9988 @endDefesc
9990 There are a number of special-case escapes for horizontal motion.
9992 @Defesc {\\@key{SP}, , , }
9993 @cindex space, unbreakable
9994 @cindex unbreakable space
9995 An unbreakable and unpaddable (i.e.@: not expanded during filling)
9996 space.  (Note: This is a backslash followed by a space.)
9997 @endDefesc
9999 @Defesc {\\~, , , }
10000 An unbreakable space that stretches like a normal inter-word space
10001 when a line is adjusted.
10002 @endDefesc
10004 @Defesc {\\|, , , }
10005 A 1/6@dmn{th} em space.  Ignored for TTY output devices (rounded to
10006 zero).
10007 @endDefesc
10009 @Defesc {\\^, , , }
10010 A 1/12@dmn{th} em space.  Ignored for TTY output devices (rounded to
10011 zero).
10012 @endDefesc
10014 @Defesc {\\0, , , }
10015 @cindex space, width of a digit (@code{\0})
10016 @cindex digit width space (@code{\0})
10017 A space the size of a digit.
10018 @endDefesc
10020 The following string sets the @TeX{} logo:
10022 @Example
10023 .ds TeX T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
10024 @endExample
10026 @DefescList {\\w, ', text, '}
10027 @DefregItem {st}
10028 @DefregItem {sb}
10029 @DefregItem {rst}
10030 @DefregItem {rsb}
10031 @DefregItem {ct}
10032 @DefregItem {ssc}
10033 @DefregListEnd {skw}
10034 @cindex width escape (@code{\w})
10035 Return the width of the specified @var{text} in basic units.
10036 This allows horizontal movement based on the width of some
10037 arbitrary text (e.g.@: given as an argument to a macro).
10039 @Example
10040 The length of the string `abc' is \w'abc'u.
10041     @result{} The length of the string `abc' is 72u.
10042 @endExample
10044 Font changes may occur in @var{text} which don't affect current
10045 settings.
10047 After use, @code{\w} sets several registers:
10049 @table @code
10050 @item st
10051 @itemx sb
10052 The highest and lowest point of the baseline, respectively, in @var{text}.
10054 @item rst
10055 @itemx rsb
10056 Like the @code{st} and @code{sb} registers, but takes account of the
10057 heights and depths of glyphs.  With other words, this gives the
10058 highest and lowest point of @var{text}.
10060 @item ct
10061 Defines the kinds of glyphs occurring in @var{text}:
10063 @table @asis
10064 @item 0
10065 only short glyphs, no descenders or tall glyphs.
10067 @item 1
10068 at least one descender.
10070 @item 2
10071 at least one tall glyph.
10073 @item 3
10074 at least one each of a descender and a tall glyph.
10075 @end table
10077 @item ssc
10078 The amount of horizontal space (possibly negative) that should be added
10079 to the last glyph before a subscript.
10081 @item skw
10082 How far to right of the center of the last glyph in the @code{\w}
10083 argument, the center of an accent from a roman font should be placed
10084 over that glyph.
10085 @end table
10086 @endDefesc
10088 @DefescList {\\k, , p, }
10089 @DefescItem {\\k, @lparen{}, ps, }
10090 @DefescListEnd {\\k, @lbrack{}, position, @rbrack}
10091 @cindex saving horizontal input line position (@code{\k})
10092 @cindex horizontal input line position, saving (@code{\k})
10093 @cindex input line position, horizontal, saving (@code{\k})
10094 @cindex position, horizontal input line, saving (@code{\k})
10095 @cindex line, input, horizontal position, saving (@code{\k})
10096 Store the current horizontal position in the @emph{input} line in
10097 number register with name @var{position} (one-character name@w{ }@var{p},
10098 two-character name @var{ps}).  Use this, for example, to return to the
10099 beginning of a string for highlighting or other decoration.
10100 @endDefesc
10102 @Defreg {hp}
10103 @cindex horizontal input line position register (@code{hp})
10104 @cindex input line, horizontal position, register (@code{hp})
10105 @cindex position, horizontal, in input line, register (@code{hp})
10106 @cindex line, input, horizontal position, register (@code{hp})
10107 The current horizontal position at the input line.
10108 @endDefreg
10110 @Defreg {.k}
10111 @cindex horizontal output line position register (@code{.k})
10112 @cindex output line, horizontal position, register (@code{.k})
10113 @cindex position, horizontal, in output line, register (@code{.k})
10114 @cindex line, output, horizontal position, register (@code{.k})
10115 A read-only number register containing the current horizontal output
10116 position.
10117 @endDefreg
10119 @Defesc {\\o, ', @Var{a}@Var{b}@Var{c}, '}
10120 @cindex overstriking glyphs (@code{\o})
10121 @cindex glyphs, overstriking (@code{\o})
10122 Overstrike glyphs @var{a}, @var{b}, @var{c}, @dots{}; the glyphs
10123 are centered, and the resulting spacing is the largest width of the
10124 affected glyphs.
10125 @endDefesc
10127 @Defesc {\\z, , g, , }
10128 @cindex zero-width printing (@code{\z}, @code{\Z})
10129 @cindex printing, zero-width (@code{\z}, @code{\Z})
10130 Print glyph @var{g} with zero width, i.e., without spacing.  Use
10131 this to overstrike glyphs left-aligned.
10132 @endDefesc
10134 @Defesc {\\Z, ', anything, '}
10135 @cindex zero-width printing (@code{\z}, @code{\Z})
10136 @cindex printing, zero-width (@code{\z}, @code{\Z})
10137 Print @var{anything}, then restore the horizontal and vertical position.
10138 The argument may not contain tabs or leaders.
10140 The following is an example of a strike-through macro:
10142 @Example
10143 .de ST
10144 .nr ww \w'\\$1'
10145 \Z@@\v'-.25m'\l'\\n[ww]u'@@\\$1
10148 This is
10149 .ST "a test"
10150 an actual emergency!
10151 @endExample
10152 @endDefesc
10155 @c =====================================================================
10157 @node Drawing Requests, Traps, Page Motions, gtroff Reference
10158 @section Drawing Requests
10159 @cindex drawing requests
10160 @cindex requests for drawing
10162 @code{gtroff} provides a number of ways to draw lines and other figures
10163 on the page.  Used in combination with the page motion commands (see
10164 @ref{Page Motions}, for more info), a wide variety of figures can be
10165 drawn.  However, for complex drawings these operations can be quite
10166 cumbersome, and it may be wise to use graphic preprocessors like
10167 @code{gpic} or @code{ggrn}.  @xref{gpic}, and @ref{ggrn}, for more
10168 information.
10170 All drawing is done via escapes.
10172 @DefescList {\\l, ', @Var{l}, '}
10173 @DefescListEnd {\\l, ', @Var{l}@Var{g}, '}
10174 @cindex drawing horizontal lines (@code{\l})
10175 @cindex horizontal line, drawing (@code{\l})
10176 @cindex line, horizontal, drawing (@code{\l})
10177 Draw a line horizontally.  @var{l} is the length of the line to be
10178 drawn.  If it is positive, start the line at the current location and
10179 draw to the right; its end point is the new current location.  Negative
10180 values are handled differently: The line starts at the current location
10181 and draws to the left, but the current location doesn't move.
10183 @var{l} can also be specified absolutely (i.e.@: with a leading
10184 @samp{|}) which draws back to the beginning of the input line.
10185 Default scaling indicator is @samp{m}.
10187 @cindex underscore glyph (@code{\[ru]})
10188 @cindex glyph, underscore (@code{\[ru]})
10189 @cindex line drawing glyph
10190 @cindex glyph, for line drawing
10191 The optional second parameter@w{ }@var{g} is a glyph to draw the line
10192 with.  If this second argument is not specified, @code{gtroff} uses
10193 the underscore glyph, @code{\[ru]}.
10195 @cindex zero width space character (@code{\&})
10196 @cindex character, zero width space (@code{\&})
10197 @cindex space character, zero width (@code{\&})
10198 To separate the two arguments (to prevent @code{gtroff} from
10199 interpreting a drawing glyph as a scaling indicator if the glyph is
10200 represented by a single character) use @code{\&}.
10202 Here a small useful example:
10204 @Example
10205 .de box
10206 \[br]\\$*\[br]\l'|0\[rn]'\l'|0\[ul]'
10208 @endExample
10210 @noindent
10211 Note that this works by outputting a box rule (a vertical line), then
10212 the text given as an argument and then another box rule.  Finally, the
10213 line drawing escapes both draw from the current location to the
10214 beginning of the @emph{input} line -- this works because the line
10215 length is negative, not moving the current point.
10216 @endDefesc
10218 @DefescList {\\L, ', @Var{l}, '}
10219 @DefescListEnd {\\L, ', @Var{l}@Var{g}, '}
10220 @cindex drawing vertical lines (@code{\L})
10221 @cindex vertical line drawing (@code{\L})
10222 @cindex line, vertical, drawing (@code{\L})
10223 @cindex line drawing glyph
10224 @cindex glyph for line drawing
10225 @cindex box rule glyph (@code{\[br]})
10226 @cindex glyph, box rule (@code{\[br]})
10227 Draw vertical lines.  Its parameters are
10228 similar to the @code{\l} escape, except that the default scaling
10229 indicator is @samp{v}.  The movement is downwards for positive values,
10230 and upwards for negative values.  The default glyph is the box rule
10231 glyph, @code{\[br]}.  As with the vertical motion escapes, text
10232 processing blindly continues where the line ends.
10234 @Example
10235 This is a \L'3v'test.
10236 @endExample
10238 @noindent
10239 Here the result, produced with @code{grotty}.
10241 @Example
10242 This is a
10243           |
10244           |
10245           |test.
10246 @endExample
10247 @endDefesc
10249 @Defesc {\\D, ', command arg @dots{}, '}
10250 The @code{\D} escape provides a variety of drawing functions.
10251 Note that on character devices, only vertical and horizontal lines are
10252 supported within @code{grotty}; other devices may only support a subset
10253 of the available drawing functions.
10255 The default scaling indicator for all subcommands of @code{\D} is
10256 @samp{m} for horizontal distances and @samp{v} for vertical ones.
10257 Exceptions are @w{@code{\D'f @dots{}'}} and @w{@code{\D't @dots{}'}}
10258 which use @code{u} as the default.
10260 @table @code
10261 @item \D'l @var{dx} @var{dy}'
10262 @cindex line, drawing (@w{@code{\D'l @dots{}'}})
10263 @cindex drawing a line (@w{@code{\D'l @dots{}'}})
10264 Draw a line from the current location to the relative point specified by
10265 (@var{dx},@var{dy}).
10267 The following example is a macro for creating a box around a text string;
10268 for simplicity, the box margin is taken as a fixed value, 0.2@dmn{m}.
10270 @Example
10271 .de BOX
10272 .  nr @@wd \w'\\$1'
10273 \h'.2m'\
10274 \h'-.2m'\v'(.2m - \\n[rsb]u)'\
10275 \D'l 0 -(\\n[rst]u - \\n[rsb]u + .4m)'\
10276 \D'l (\\n[@@wd]u + .4m) 0'\
10277 \D'l 0 (\\n[rst]u - \\n[rsb]u + .4m)'\
10278 \D'l -(\\n[@@wd]u + .4m) 0'\
10279 \h'.2m'\v'-(.2m - \\n[rsb]u)'\
10280 \\$1\
10281 \h'.2m'
10283 @endExample
10285 @noindent
10286 First, the width of the string is stored in register @code{@@wd}.  Then,
10287 four lines are drawn to form a box, properly offset by the box margin.
10288 The registers @code{rst} and @code{rsb} are set by the @code{\w} escape,
10289 containing the largest height and depth of the whole string.
10291 @item \D'c @var{d}'
10292 @cindex circle, drawing (@w{@code{\D'c @dots{}'}})
10293 @cindex drawing a circle (@w{@code{\D'c @dots{}'}})
10294 Draw a circle with a diameter of@w{ }@var{d} with the leftmost point at the
10295 current position.
10297 @item \D'C @var{d}'
10298 @cindex circle, solid, drawing (@w{@code{\D'C @dots{}'}})
10299 @cindex drawing a solid circle (@w{@code{\D'C @dots{}'}})
10300 @cindex solid circle, drawing (@w{@code{\D'C @dots{}'}})
10301 Draw a solid circle with the same parameters as an outlined circle.  No
10302 outline is drawn.
10304 @item \D'e @var{x} @var{y}'
10305 @cindex drawing an ellipse (@w{@code{\D'e @dots{}'}})
10306 @cindex ellipse, drawing (@w{@code{\D'e @dots{}'}})
10307 Draw an ellipse with a horizontal diameter of @var{x} and a vertical
10308 diameter of @var{y} with the leftmost point at the current position.
10310 @item \D'E @var{x} @var{y}'
10311 @cindex ellipse, solid, drawing (@w{@code{\D'E @dots{}'}})
10312 @cindex drawing a solid ellipse (@w{@code{\D'E @dots{}'}})
10313 @cindex solid ellipse, drawing (@w{@code{\D'E @dots{}'}})
10314 Draw a solid ellipse with the same parameters as an outlined ellipse.
10315 No outline is drawn.
10317 @item \D'a @var{dx1} @var{dy1} @var{dx2} @var{dy2}'
10318 @cindex arc, drawing (@w{@code{\D'a @dots{}'}})
10319 @cindex drawing an arc (@w{@code{\D'a @dots{}'}})
10320 Draw an arc clockwise from the current location through the two
10321 specified relative locations (@var{dx1},@var{dy1}) and
10322 (@var{dx2},@var{dy2}).  The coordinates of the first point are relative
10323 to the current position, and the coordinates of the second point are
10324 relative to the first point.
10326 @item \D'~ @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
10327 @cindex drawing a spline (@w{@code{\D'~ @dots{}'}})
10328 @cindex spline, drawing (@w{@code{\D'~ @dots{}'}})
10329 Draw a spline from the current location to the relative point
10330 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}), and so on.
10332 @item \D'f @var{n}'
10333 @cindex gray shading (@w{@code{\D'f @dots{}'}})
10334 @cindex shading filled objects (@w{@code{\D'f @dots{}'}})
10335 Set the shade of gray to be used for filling solid objects to@w{
10336 }@var{n}; @var{n}@w{ }must be an integer between 0 and@w{ }1000, where 0
10337 corresponds solid white and 1000 to solid black, and values in between
10338 correspond to intermediate shades of gray.  This applies only to solid
10339 circles, solid ellipses, and solid polygons.  By default, a level of
10340 1000 is used.
10342 @item \D'p @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
10343 @cindex drawing a polygon (@w{@code{\D'p @dots{}'}})
10344 @cindex polygon, drawing (@w{@code{\D'p @dots{}'}})
10345 Draw a polygon from the current location to the relative position
10346 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}) and so on.
10347 When the specified data points are exhausted, a line is drawn back
10348 to the starting point.
10350 @item \D'P @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
10351 @cindex polygon, solid, drawing (@w{@code{\D'P @dots{}'}})
10352 @cindex drawing a solid polygon (@w{@code{\D'P @dots{}'}})
10353 @cindex solid polygon, drawing (@w{@code{\D'P @dots{}'}})
10354 Draw a solid polygon with the same parameters as an outlined polygon.
10355 No outline is drawn.
10357 Here a better variant of the box macro to fill the box with some color.
10358 Note that the box must be drawn before the text since colors in
10359 @code{gtroff} are not transparent; the filled polygon would hide the
10360 text completely.
10362 @Example
10363 .de BOX
10364 .  nr @@wd \w'\\$1'
10365 \h'.2m'\
10366 \h'-.2m'\v'(.2m - \\n[rsb]u)'\
10367 \M[lightcyan]\
10368 \D'P 0 -(\\n[rst]u - \\n[rsb]u + .4m) \
10369      (\\n[@@wd]u + .4m) 0 \
10370      0 (\\n[rst]u - \\n[rsb]u + .4m) \
10371      -(\\n[@@wd]u + .4m) 0'\
10372 \h'.2m'\v'-(.2m - \\n[rsb]u)'\
10373 \M[]\
10374 \\$1\
10375 \h'.2m'
10377 @endExample
10379 @item \D't @var{n}'
10380 @cindex line thickness (@w{@code{\D't @dots{}'}})
10381 @cindex thickness of lines (@w{@code{\D't @dots{}'}})
10382 Set the current line thickness to @var{n}@w{ }machine units.  A value of
10383 zero selects the smallest available line thickness.  A negative value
10384 makes the line thickness proportional to the current point size (this is
10385 the default behaviour of @acronym{AT&T} @code{troff}).
10386 @end table
10387 @endDefesc
10389 @xref{Graphics Commands}.
10391 @Defesc {\\b, ', string, '}
10392 @cindex pile, glyph (@code{\b})
10393 @cindex glyph pile (@code{\b})
10394 @cindex stacking glyphs (@code{\b})
10395 @dfn{Pile} a sequence of glyphs vertically, and center it vertically
10396 on the current line.  Use it to build large brackets and braces.
10398 Here an example how to create a large opening brace:
10400 @Example
10401 \b'\[lt]\[bv]\[lk]\[bv]\[lb]'
10402 @endExample
10404 @cindex @code{\b}, limitations
10405 @cindex limitations of @code{\b} escape
10406 The first glyph is on the top, the last glyph in @var{string} is
10407 at the bottom.  Note that @code{gtroff} separates the glyphs
10408 vertically by 1@dmn{m}, and the whole object is centered 0.5@dmn{m}
10409 above the current baseline; the largest glyph width is used as the
10410 width for the whole object.  This rather unflexible positioning
10411 algorithm doesn't work with @option{-Tdvi} since the bracket pieces vary
10412 in height for this device.  Instead, use the @code{eqn} preprocessor.
10414 @xref{Manipulating Spacing}, how to adjust the vertical spacing with
10415 the @code{\x} escape.
10416 @endDefesc
10419 @c =====================================================================
10421 @node Traps, Diversions, Drawing Requests, gtroff Reference
10422 @section Traps
10423 @cindex traps
10425 @dfn{Traps} are locations, which, when reached, call a specified
10426 macro.  These traps can occur at a given location on the page, at a
10427 given location in the current diversion, at a blank line,
10428 after a certain number of input lines, or at the end of input.
10430 @cindex planting a trap
10431 @cindex trap, planting
10432 Setting a trap is also called @dfn{planting}.
10433 @cindex trap, springing
10434 @cindex springing a trap
10435 It is also said that a trap is @dfn{sprung} if the associated macro
10436 is executed.
10438 @menu
10439 * Page Location Traps::
10440 * Diversion Traps::
10441 * Input Line Traps::
10442 * Blank Line Traps::
10443 * End-of-input Traps::
10444 @end menu
10446 @c ---------------------------------------------------------------------
10448 @node Page Location Traps, Diversion Traps, Traps, Traps
10449 @subsection Page Location Traps
10450 @cindex page location traps
10451 @cindex traps, page location
10453 @dfn{Page location traps} perform an action when @code{gtroff}
10454 reaches or passes a certain vertical location on the page.  Page
10455 location traps have a variety of purposes, including:
10457 @itemize
10458 @item
10459 setting headers and footers
10461 @item
10462 setting body text in multiple columns
10464 @item
10465 setting footnotes
10466 @end itemize
10468 @DefreqList {vpt, flag}
10469 @DefregListEnd {.vpt}
10470 @cindex enabling vertical position traps (@code{vpt})
10471 @cindex vertical position traps, enabling (@code{vpt})
10472 @cindex vertical position trap enable register (@code{.vpt})
10473 Enable vertical position traps if @var{flag} is non-zero, or disables
10474 them otherwise.  Vertical position traps are traps set by the @code{wh}
10475 or @code{dt} requests.  Traps set by the @code{it} request are not
10476 vertical position traps.  The parameter that controls whether vertical
10477 position traps are enabled is global.  Initially vertical position traps
10478 are enabled.  The current setting of this is available in the
10479 @code{.vpt} read-only number register.
10480 @endDefreq
10482 @Defreq {wh, dist [@Var{macro}]}
10483 Set a page location trap.  Positive values for @var{dist} set
10484 the trap relative to the top of the page; negative values set
10485 the trap relative to the bottom of the page.  Default scaling
10486 indicator is @samp{v}.
10488 @var{macro} is the name of the macro to execute when the
10489 trap is sprung.  If @var{macro} is missing, remove the first trap
10490 (if any) at @var{dist}.
10492 @cindex page headers
10493 @cindex page footers
10494 @cindex headers
10495 @cindex footers
10496 The following is a simple example of how many macro packages
10497 set headers and footers.
10499 @Example
10500 .de hd                \" Page header
10501 '  sp .5i
10502 .  tl 'Title''date'
10503 '  sp .3i
10506 .de fo                \" Page footer
10507 '  sp 1v
10508 .  tl ''%''
10509 '  bp
10512 .wh 0   hd            \" trap at top of the page
10513 .wh -1i fo            \" trap one inch from bottom
10514 @endExample
10516 A trap at or below the bottom of the page is ignored; it can be made
10517 active by either moving it up or increasing the page length so that the
10518 trap is on the page.
10520 It is possible to have more than one trap at the same location; to do so,
10521 the traps must be defined at different locations, then moved together with
10522 the @code{ch} request; otherwise the second trap would replace the first
10523 one.  Earlier defined traps hide later defined traps if moved to the same
10524 position (the many empty lines caused by the @code{bp} request are omitted):
10526 @Example
10527 .de a
10528 .  nop a
10530 .de b
10531 .  nop b
10533 .de c
10534 .  nop c
10537 .wh 1i a
10538 .wh 2i b
10539 .wh 3i c
10541     @result{} a b c
10542 @endExample
10543 @Example
10544 .ch b 1i
10545 .ch c 1i
10547     @result{} a
10548 @endExample
10549 @Example
10550 .ch a 0.5i
10552     @result{} a b
10553 @endExample
10554 @endDefreq
10556 @Defreg {.t}
10557 @cindex distance to next trap register (@code{.t})
10558 @cindex trap, distance, register (@code{.t})
10559 A read-only number register holding the distance to the next trap.
10561 If there are no traps between the current position and the bottom of the
10562 page, it contains the distance to the page bottom.  In a diversion, the
10563 distance to the page bottom is infinite (the returned value is the biggest
10564 integer which can be represented in @code{groff}) if there are no diversion
10565 traps.
10566 @endDefreg
10568 @Defreq {ch, macro dist}
10569 @cindex changing trap location (@code{ch})
10570 @cindex trap, changing location (@code{ch})
10571 Change the location of a trap.
10572 The first argument is the name of the macro to be invoked at
10573 the trap, and the second argument is the new location for the trap
10574 (note that the parameters are specified the opposite of the @code{wh}
10575 request).  This is useful for building up footnotes in a diversion to
10576 allow more space at the bottom of the page for them.
10578 Default scaling indicator for @var{dist} is @samp{v}.  If @var{dist}
10579 is missing, the trap is removed.
10581 @c XXX
10583 @ignore
10584 @Example
10585 ... (simplified) footnote example ...
10586 @endExample
10587 @end ignore
10588 @endDefreq
10590 @Defreg {.ne}
10591 The read-only number register @code{.ne} contains the amount of space
10592 that was needed in the last @code{ne} request that caused a trap to be
10593 sprung.  Useful in conjunction with the @code{.trunc} register.
10594 @xref{Page Control}, for more information.
10595 @endDefreg
10597 @Defreg {.trunc}
10598 @cindex @code{ne} request, and the @code{.trunc} register
10599 @cindex truncated vertical space register (@code{.trunc})
10600 A read-only register containing the amount of vertical space truncated
10601 by the most recently sprung vertical position trap, or, if the trap was
10602 sprung by an @code{ne} request, minus the amount of vertical motion
10603 produced by the @code{ne} request.  In other words, at the point a trap
10604 is sprung, it represents the difference of what the vertical position
10605 would have been but for the trap, and what the vertical position
10606 actually is.
10607 @endDefreg
10609 @c ---------------------------------------------------------------------
10611 @node Diversion Traps, Input Line Traps, Page Location Traps, Traps
10612 @subsection Diversion Traps
10613 @cindex diversion traps
10614 @cindex traps, diversion
10616 @Defreq {dt, dist macro}
10617 @cindex @code{.t} register, and diversions
10618 @cindex setting diversion trap (@code{dt})
10619 @cindex diversion trap, setting (@code{dt})
10620 @cindex trap, diversion, setting (@code{dt})
10621 Set a trap @emph{within} a diversion.
10622 @var{dist} is the location of the trap
10623 (identical to the @code{.wh} request; default scaling indicator is
10624 @samp{v}) and @var{macro} is the name of the macro to be invoked.  The
10625 number register @code{.t} still works within diversions.
10626 @xref{Diversions}, for more information.
10627 @endDefreq
10629 @c ---------------------------------------------------------------------
10631 @node Input Line Traps, Blank Line Traps, Diversion Traps, Traps
10632 @subsection Input Line Traps
10633 @cindex input line traps
10634 @cindex traps, input line
10636 @DefreqList {it, n macro}
10637 @DefreqItem {itc, n macro}
10638 @cindex setting input line trap (@code{it})
10639 @cindex input line trap, setting (@code{it})
10640 @cindex trap, input line, setting (@code{it})
10641 Set an input line trap.
10642 @var{n}@w{ }is the number of lines of input which may be read before
10643 springing the trap, @var{macro} is the macro to be invoked.
10644 Request lines are not counted as input lines.
10646 For example, one possible use is to have a macro which prints the
10647 next @var{n}@w{ }lines in a bold font.
10649 @Example
10650 .de B
10651 .  it \\$1 B-end
10652 .  ft B
10655 .de B-end
10656 .  ft R
10658 @endExample
10660 @cindex input line traps and interrupted lines (@code{itc})
10661 @cindex interrupted lines and input line traps (@code{itc})
10662 @cindex traps, input line, and interrupted lines (@code{itc})
10663 @cindex lines, interrupted, and input line traps (@code{itc})
10664 The @code{itc} request is identical,
10665 except that a line interrupted with @code{\c}
10666 counts as one input line.
10668 Both requests are associated with the current environment
10669 (@pxref{Environments}); switching to another environment disables the
10670 current input trap, and going back reactivates it, restoring the number
10671 of already processed lines.
10672 @endDefreq
10674 @c ---------------------------------------------------------------------
10676 @node Blank Line Traps, End-of-input Traps, Input Line Traps, Traps
10677 @subsection Blank Line Traps
10678 @cindex blank line traps
10679 @cindex traps, blank line
10681 @Defreq {blm, macro}
10682 @cindex blank line macro (@code{blm})
10683 Set a blank line trap.
10684 @code{gtroff} executes @var{macro} when it encounters a blank line in
10685 the input file.
10686 @endDefreq
10688 @c ---------------------------------------------------------------------
10690 @node End-of-input Traps,  , Blank Line Traps, Traps
10691 @subsection End-of-input Traps
10692 @cindex end-of-input traps
10693 @cindex traps, end-of-input
10695 @Defreq {em, macro}
10696 @cindex setting end-of-input trap (@code{em})
10697 @cindex end-of-input trap, setting (@code{em})
10698 @cindex trap, end-of-input, setting (@code{em})
10699 @cindex end-of-input macro (@code{em})
10700 @cindex macro, end-of-input (@code{em})
10701 Set a trap at the end of input.  @var{macro} is executed after the
10702 last line of the input file has been processed.
10704 For example, if the document had to have a section at the bottom of the
10705 last page for someone to approve it, the @code{em} request could be
10706 used.
10708 @Example
10709 .de approval
10710 .  ne 5v
10711 .  sp |(\\n[.t] - 6v)
10712 .  in +4i
10713 .  lc _
10714 .  br
10715 Approved:\t\a
10716 .  sp
10717 Date:\t\t\a
10720 .em approval
10721 @endExample
10722 @endDefreq
10725 @c =====================================================================
10727 @node Diversions, Environments, Traps, gtroff Reference
10728 @section Diversions
10729 @cindex diversions
10731 In @code{gtroff} it is possible to @dfn{divert} text into a named
10732 storage area.  Due to the similarity to defining macros it is sometimes
10733 said to be stored in a macro.  This is used for saving text for output
10734 at a later time, which is useful for keeping blocks of text on the same
10735 page, footnotes, tables of contents, and indices.
10737 @cindex top-level diversion
10738 @cindex diversion, top-level
10739 For orthogonality it is said that @code{gtroff} is in the @dfn{top-level
10740 diversion} if no diversion is active (i.e., the data is diverted to the
10741 output device).
10743 @DefreqList {di, macro}
10744 @DefreqListEnd {da, macro}
10745 @cindex beginning diversion (@code{di})
10746 @cindex diversion, beginning (@code{di})
10747 @cindex ending diversion (@code{di})
10748 @cindex diversion, ending (@code{di})
10749 @cindex appending to a diversion (@code{da})
10750 @cindex diversion, appending (@code{da})
10751 Begin a diversion.  Like the @code{de}
10752 request, it takes an argument of a macro name to divert subsequent text
10753 into.  The @code{da} macro appends to an existing diversion.
10755 @code{di} or @code{da} without an argument ends the diversion.
10756 @endDefreq
10758 @DefreqList {box, macro}
10759 @DefreqListEnd {boxa, macro}
10760 Begin (or appends to) a diversion like the
10761 @code{di} and @code{da} requests.
10762 The difference is that @code{box} and @code{boxa}
10763 do not include a partially-filled line in the diversion.
10765 Compare this:
10767 @Example
10768 Before the box.
10769 .box xxx
10770 In the box.
10772 .box
10773 After the box.
10775     @result{} Before the box.  After the box.
10776 .xxx
10777     @result{} In the box.
10778 @endExample
10780 @noindent
10781 with this:
10783 @Example
10784 Before the diversion.
10785 .di yyy
10786 In the diversion.
10789 After the diversion.
10791     @result{} After the diversion.
10792 .yyy
10793     @result{} Before the diversion.  In the diversion.
10794 @endExample
10796 @code{box} or @code{boxa} without an argument ends the diversion.
10797 @endDefreq
10799 @DefregList {.z}
10800 @DefregListEnd {.d}
10801 @cindex @code{nl} register, and @code{.d}
10802 @cindex nested diversions
10803 @cindex diversion, nested
10804 @cindex diversion name register (@code{.z})
10805 @cindex vertical position in diversion register (@code{.d})
10806 @cindex position, vertical, in diversion, register (@code{.d})
10807 @cindex diversion, vertical position in, register (@code{.d})
10808 Diversions may be nested.  The read-only number register @code{.z}
10809 contains the name of the current diversion (this is a string-valued
10810 register).  The read-only number register @code{.d} contains the current
10811 vertical place in the diversion.  If not in a diversion it is the same
10812 as the register @code{nl}.
10813 @endDefreg
10815 @Defreg {.h}
10816 @cindex high-water mark register (@code{.h})
10817 @cindex mark, high-water, register (@code{.h})
10818 @cindex position of lowest text line (@code{.h})
10819 @cindex text line, position of lowest (@code{.h})
10820 The @dfn{high-water mark} on the current page.  It corresponds to the
10821 text baseline of the lowest line on the page.  This is a read-only
10822 register.
10824 @Example
10825 .tm .h==\n[.h], nl==\n[nl]
10826     @result{} .h==0, nl==-1
10827 This is a test.
10829 .sp 2
10830 .tm .h==\n[.h], nl==\n[nl]
10831     @result{} .h==40, nl==120
10832 @endExample
10834 @cindex @code{.h} register, difference to @code{nl}
10835 @cindex @code{nl} register, difference to @code{.h}
10836 @noindent
10837 As can be seen in the previous example, empty lines are not considered
10838 in the return value of the @code{.h} register.
10839 @endDefreg
10841 @DefregList {dn}
10842 @DefregListEnd {dl}
10843 After completing a diversion, the read-write number registers @code{dn}
10844 and @code{dl} contain the vertical and horizontal size of the diversion.
10846 @Example
10847 .\" Center text both horizontally & vertically
10849 .\" Enclose macro definitions in .eo and .ec
10850 .\" to avoid the doubling of the backslash
10852 .\" macro .(c starts centering mode
10853 .de (c
10854 .  br
10855 .  ev (c
10856 .  evc 0
10857 .  in 0
10858 .  nf
10859 .  di @@c
10861 @endExample
10862 @Example
10863 .\" macro .)c terminates centering mode
10864 .de )c
10865 .  br
10866 .  ev
10867 .  di
10868 .  nr @@s (((\n[.t]u - \n[dn]u) / 2u) - 1v)
10869 .  sp \n[@@s]u
10870 .  ce 1000
10871 .  @@c
10872 .  ce 0
10873 .  sp \n[@@s]u
10874 .  br
10875 .  fi
10876 .  rr @@s
10877 .  rm @@s
10878 .  rm @@c
10880 .\" End of macro definitions, restore escape mechanism
10882 @endExample
10883 @endDefreg
10885 @DefescList {\\!, , , }
10886 @DefescListEnd {\\?, , @Var{anything}, \\?}
10887 @cindex transparent output (@code{\!}, @code{\?})
10888 @cindex output, transparent (@code{\!}, @code{\?})
10889 Prevent requests, macros, and escapes from being
10890 interpreted when read into a diversion.  This takes the given text
10891 and @dfn{transparently} embeds it into the diversion.  This is useful for
10892 macros which shouldn't be invoked until the diverted text is actually
10893 output.
10895 The @code{\!} escape transparently embeds text up to
10896 and including the end of the line.
10897 The @code{\?} escape transparently embeds text until the next
10898 occurrence of the @code{\?} escape.  For example:
10900 @Example
10901 \?@var{anything}\?
10902 @endExample
10904 @noindent
10905 @var{anything} may not contain newlines; use @code{\!}  to embed
10906 newlines in a diversion.  The escape sequence @code{\?} is also
10907 recognized in copy mode and turned into a single internal code; it is
10908 this code that terminates @var{anything}.  Thus the following example
10909 prints@w{ }4.
10911 @Example
10912 .nr x 1
10914 .di d
10915 \?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
10917 .nr x 2
10918 .di e
10921 .nr x 3
10922 .di f
10925 .nr x 4
10927 @endExample
10929 Both escapes read the data in copy mode.
10931 @cindex @code{\!}, in top-level diversion
10932 @cindex top-level diversion, and @code{\!}
10933 @cindex diversion, top-level, and @code{\!}
10934 If @code{\!} is used in the top-level diversion, its argument is
10935 directly embedded into the @code{gtroff} intermediate output.  This can
10936 be used for example to control a postprocessor which processes the data
10937 before it is sent to the device driver.
10939 @cindex @code{\?}, in top-level diversion
10940 @cindex top-level diversion, and @code{\?}
10941 @cindex diversion, top-level, and @code{\?}
10942 The @code{\?} escape used in the top-level diversion produces no output
10943 at all; its argument is simply ignored.
10944 @endDefesc
10946 @cindex @code{\!}, and @code{output}
10947 @cindex @code{output} request, and @code{\!}
10948 @Defreq {output, string}
10949 Emit @var{string} directly to the @code{gtroff} intermediate output
10950 (subject to copy-mode interpretation);  this is similar to @code{\!} used
10951 at the top level.  An initial double quote in @var{string} is stripped off
10952 to allow initial blanks.
10954 This request can't be used before the first page has started -- if you get
10955 an error, simply insert @code{.br} before the @code{output} request.
10957 Without argument, @code{output} is ignored.
10959 Use with caution!  It is normally only needed for mark-up used by a
10960 postprocessor which does something with the output before sending it to
10961 the output device, filtering out @code{string} again.
10962 @endDefreq
10964 @Defreq {asciify, div}
10965 @cindex unformatting diversions (@code{asciify})
10966 @cindex diversion, unformatting (@code{asciify})
10967 @cindex @code{trin} request, and @code{asciify}
10968 @dfn{Unformat} the diversion specified by @var{div}
10969 in such a way that @acronym{ASCII} characters, characters translated with
10970 the @code{trin} request, space characters, and some escape sequences that
10971 were formatted and diverted are treated like ordinary input
10972 characters when the diversion is reread.  It can be also used for gross
10973 hacks; for example, the following sets register@w{ }@code{n} to@w{ }1.
10975 @Example
10976 .tr @@.
10977 .di x
10978 @@nr n 1
10981 .tr @@@@
10982 .asciify x
10984 @endExample
10986 @xref{Copy-in Mode}.
10987 @endDefreq
10989 @Defreq {unformat, div}
10990 Like @code{asciify}, unformat the specified diversion.
10991 However, @code{unformat} only unformats spaces and tabs
10992 between words.
10993 Unformatted tabs are treated as input tokens,
10994 and spaces are stretchable again.
10996 The vertical size of lines is not preserved; glyph information (font,
10997 font size, space width, etc.)@: is retained.
10998 @endDefreq
11001 @c =====================================================================
11003 @node Environments, Suppressing output, Diversions, gtroff Reference
11004 @section Environments
11005 @cindex environments
11007 It happens frequently that some text should be printed in a certain
11008 format regardless of what may be in effect at the time, for example, in
11009 a trap invoked macro to print headers and footers.  To solve this
11010 @code{gtroff} processes text in @dfn{environments}.  An
11011 environment contains most of the parameters that control text
11012 processing.  It is possible to switch amongst these environments; by
11013 default @code{gtroff} processes text in environment@w{ }0.  The
11014 following is the information kept in an environment.
11016 @itemize @bullet
11017 @item
11018 font parameters (size, family, style, glyph height and slant, space
11019 and sentence space size)
11021 @item
11022 page parameters (line length, title length, vertical spacing,
11023 line spacing, indentation, line numbering, centering, right-justifying,
11024 underlining, hyphenation data)
11026 @item
11027 fill and adjust mode
11029 @item
11030 tab stops, tab and leader characters, escape character,
11031 no-break and hyphen indicators, margin character data
11033 @item
11034 partially collected lines
11036 @item
11037 input traps
11039 @item
11040 drawing and fill colours
11041 @end itemize
11043 These environments may be given arbitrary names (see @ref{Identifiers},
11044 for more info).  Old versions of @code{troff} only had environments
11045 named @samp{0}, @samp{1}, and @samp{2}.
11047 @DefreqList {ev, [@Var{env}]}
11048 @DefregListEnd {.ev}
11049 @cindex switching environments (@code{ev})
11050 @cindex environment, switching (@code{ev})
11051 @cindex environment number/name register (@code{.ev})
11052 Switch to another environment.  The argument @var{env} is the name of
11053 the environment to switch to.  With no argument, @code{gtroff} switches
11054 back to the previous environment.  There is no limit on the number of
11055 named environments; they are created the first time that they are
11056 referenced.  The @code{.ev} read-only register contains the name or
11057 number of the current environment.  This is a string-valued register.
11059 Note that a call to @code{ev} (with argument) pushes the previously
11060 active environment onto a stack.  If, say, environments @samp{foo},
11061 @samp{bar}, and @samp{zap} are called (in that order), the first
11062 @code{ev} request without parameter switches back to environment
11063 @samp{bar} (which is popped off the stack), and a second call
11064 switches back to environment @samp{foo}.
11066 Here is an example:
11068 @Example
11069 .ev footnote-env
11070 .fam N
11071 .ps 6
11072 .vs 8
11073 .ll -.5i
11078 .ev footnote-env
11079 \(dg Note the large, friendly letters.
11081 @endExample
11082 @endDefreq
11084 @Defreq {evc, env}
11085 @cindex copying environment (@code{evc})
11086 @cindex environment, copying (@code{evc})
11087 Copy the environment @var{env} into the current environment.
11089 The following environment data is not copied:
11091 @itemize @bullet
11092 @item
11093 Partially filled lines.
11095 @item
11096 The status whether the previous line was interrupted.
11098 @item
11099 The number of lines still to center, or to right-justify, or to underline
11100 (with or without underlined spaces); they are set to zero.
11102 @item
11103 The status whether a temporary indent is active.
11105 @item
11106 Input traps and its associated data.
11108 @item
11109 Line numbering mode is disabled; it can be reactivated with
11110 @w{@samp{.nm +0}}.
11112 @item
11113 The number of consecutive hyphenated lines (set to zero).
11114 @end itemize
11115 @endDefreq
11117 @DefregList {.cht}
11118 @DefregItem {.cdp}
11119 @DefregListEnd {.csk}
11120 @cindex environment, last glyph
11121 The @code{\n[.cht]} register contains the
11122 maximum extent (above the baseline)
11123 of the last glyph added to the current environment.
11125 The @code{\n[.cdp]} register contains the
11126 maximum extent (below the baseline)
11127 of the last glyph added to the current environment.
11129 The @code{\n[.csk]} register contains the
11130 @dfn{skew} (how far to the right of the glyph's center
11131 that @code{gtroff} shold place an accent)
11132 of the last glyph added to the current environment.
11133 @endDefreg
11136 @c =====================================================================
11138 @node Suppressing output, Colors, Environments, gtroff Reference
11139 @section Suppressing output
11141 @Defesc {\\O, , num, }
11142 @cindex suppressing output (@code{\O})
11143 @cindex output, suppressing (@code{\O})
11144 Disable or enable output depending on the value of @var{num}:
11146 @table @samp
11147 @item \O0
11148 Disable any glyphs from being emitted to the device driver, provided that
11149 the escape occurs at the outer level (see @code{\O[3]} and @code{\O[4]}).
11150 Motion is not suppressed so effectively @code{\O[0]} means @emph{pen up}.
11152 @item \O1
11153 Enable output of glyphs, provided that the escape occurs at the outer
11154 level.
11155 @end table
11157 @vindex opminx
11158 @vindex opminy
11159 @vindex opmaxx
11160 @vindex opmaxy
11161 @code{\O0} and @code{\O1} also reset the four registers @samp{opminx},
11162 @samp{opminy}, @samp{opmaxx}, and @samp{opmaxy} to @minus{}1.
11163 @xref{Register Index}.  These four registers mark the top left and
11164 bottom right hand corners of a box which encompasses all written glyphs.
11166 For example the input text:
11168 @Example
11169 Hello \O[0]world \O[1]this is a test.
11170 @endExample
11172 @noindent
11173 produces the following output:
11175 @Example
11176 Hello       this is a test.
11177 @endExample
11179 @table @samp
11180 @item \O2
11181 Provided that the escape occurs at the outer level, enable output of
11182 glyphs and also write out to @code{stderr} the page number and four
11183 registers encompassing the glyphs previously written since the last call
11184 to @code{\O}.
11186 @item \O3
11187 Begin a nesting level.  At start-up, @code{gtroff} is at outer level.
11189 @item \O4
11190 End a nesting level.
11192 @item \O[5@var{P}@var{filename}]
11193 This escape is @code{grohtml} specific.  Provided that this escape
11194 occurs at the outer nesting level write the @code{filename} to
11195 @code{stderr}.  The position of the image, @var{P}, must be specified
11196 and must be one of @code{l}, @code{r}, @code{c}, or@w{ }@code{i} (left,
11197 right, centered, inline).  @var{filename} will be associated with the
11198 production of the next inline image.
11199 @end table
11200 @endDefesc
11202 @c =====================================================================
11204 @node Colors, I/O, Suppressing output, gtroff Reference
11205 @section Colors
11206 @cindex colors
11208 @DefreqList {color, [@Var{n}]}
11209 @DefregListEnd {.color}
11210 If @var{n} is missing or non-zero, activate colors (this is the default);
11211 otherwise, turn it off.
11213 The read-only number register @code{.color} is@w{ }1 if colors are active,
11214 0@w{ }otherwise.
11216 Internally, @code{color} sets a global flag; it does not produce a token.
11217 Similar to the @code{cp} request, you should use it at the beginning of
11218 your document to control color output.
11220 Colors can be also turned off with the @option{-c} command line option.
11221 @endDefreq
11223 @Defreq {defcolor, ident scheme color_components}
11224 Define color with name @var{ident}.  @var{scheme} can be one of  the
11225 following values: @code{rgb} (three components), @code{cym} (three
11226 components), @code{cmyk} (four components), and @code{gray} or
11227 @code{grey} (one component).
11229 @cindex default color
11230 @cindex color, default
11231 Color components can be given either as a hexadecimal string or as
11232 positive decimal integers in the range 0--65535.  A hexadecimal string
11233 contains all color components concatenated.  It must start with either
11234 @code{#} or @code{##}; the former specifies hex values in the range
11235 0--255 (which are internally multiplied by@w{ }257), the latter in the
11236 range 0--65535.  Examples: @code{#FFC0CB} (pink), @code{##ffff0000ffff}
11237 (magenta).  The default color name @c{default} can't be redefined; its
11238 value is device-specific (usually black).  It is possible that the
11239 default color for @code{\m} and @code{\M} is not identical.
11241 @cindex @code{f} unit, and colors
11242 @cindex unit, @code{f}, and colors
11243 A new scaling indicator@w{ }@code{f} has been introduced which multiplies
11244 its value by 65536; this makes it convenient to specify color components
11245 as fractions in the range 0 to@w{ }1 (1f equals 65536u).  Example:
11247 @Example
11248 .defcolor darkgreen rgb 0.1f 0.5f 0.2f
11249 @endExample
11251 Note that @code{f} is the default scaling indicator for the
11252 @code{defcolor} request, thus the above statement is equivalent to
11254 @Example
11255 .defcolor darkgreen rgb 0.1 0.5 0.2
11256 @endExample
11257 @endDefreq
11259 @DefescList {\\m, , c, }
11260 @DefescItem {\\m, @lparen{}, co, }
11261 @DefescListEnd {\\m, @lbrack{}, color, @rbrack}
11262 Set drawing color.  The following example shows how to turn the next four
11263 words red.
11265 @Example
11266 \m[red]these are in red\m[] and these words are in black.
11267 @endExample
11269 The escape @code{\m[]} returns to the previous color.
11271 The drawing color is associated with the current environment
11272 (@pxref{Environments}).
11273 @endDefesc
11275 @DefescList {\\M, , c, }
11276 @DefescItem {\\M, @lparen{}, co, }
11277 @DefescListEnd {\\M, @lbrack{}, color, @rbrack}
11278 Set background color for filled objects drawn with the
11279 @code{\D'@dots{}'} commands.
11281 A red ellipse can be created with the following code:
11283 @Example
11284 \M[red]\h'0.5i'\D'E 2i 1i'\M[]
11285 @endExample
11287 The escape @code{\M[]} returns to the previous fill color.
11289 The fill color is associated with the current environment
11290 (@pxref{Environments}).
11291 @endDefesc
11294 @c =====================================================================
11296 @node I/O, Postprocessor Access, Colors, gtroff Reference
11297 @section I/O
11298 @cindex i/o
11299 @cindex input and output requests
11300 @cindex requests for input and output
11301 @cindex output and input requests
11303 @code{gtroff} has several requests for including files:
11305 @Defreq {so, file}
11306 @cindex including a file (@code{so})
11307 @cindex file, inclusion (@code{so})
11308 Read in the specified @var{file} and
11309 includes it in place of the @code{so} request.  This is quite useful for
11310 large documents, e.g.@: keeping each chapter in a separate file.
11311 @xref{gsoelim}, for more information.
11313 Since @code{gtroff} replaces the @code{so} request with the contents
11314 of @code{file}, it makes a difference whether the data is terminated with
11315 a newline or not: Assuming that file @file{xxx} contains the word
11316 @samp{foo} without a final newline, this
11318 @Example
11319 This is
11320 .so xxx
11322 @endExample
11324 @noindent
11325 yields @samp{This is foobar}.
11326 @endDefreq
11328 @Defreq {pso, command}
11329 Read the standard output from the specified @var{command}
11330 and includes it in place of the @code{pso} request.
11332 @cindex safer mode
11333 @cindex mode, safer
11334 @cindex unsafe mode
11335 @cindex mode, unsafe
11336 This request causes an error if used in safer mode (which is the default).
11337 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
11338 mode.
11340 The comment regarding a final newline for the @code{so} request is valid
11341 for @code{pso} also.
11342 @endDefreq
11344 @Defreq {mso, file}
11345 Identical to the @code{so} request except that @code{gtroff} searches for
11346 the specified @var{file} in the same directories as macro files for the
11347 the @option{-m} command line option.  If the file name to be included
11348 has the form @file{@var{name}.tmac} and it isn't found, @code{mso} tries
11349 to include @file{tmac.@var{name}} and vice versa.
11350 @endDefreq
11352 @DefreqList {trf, file}
11353 @DefreqListEnd {cf, file}
11354 @cindex transparent output (@code{cf}, @code{trf})
11355 @cindex output, transparent (@code{cf}, @code{trf})
11356 Transparently output the contents of @var{file}.  Each line is output
11357 as if it were preceded by @code{\!}; however, the lines are not subject
11358 to copy mode interpretation.  If the file does not end with a newline,
11359 then a newline is added (@code{trf} only).  For example, to define a
11360 macro@w{ }@code{x} containing the contents of file@w{ }@file{f}, use
11362 @Example
11363 .di x
11364 .trf f
11366 @endExample
11368 Both @code{trf} and @code{cf}, when used in a diversion,
11369 embeds an object in the diversion which, when reread, causes the
11370 contents of @var{file} to be transparently copied through to the
11371 output.  In @acronym{UNIX} @code{troff}, the contents of @var{file}
11372 is immediately copied through to the output regardless of whether there
11373 is a current diversion; this behaviour is so anomalous that it must be
11374 considered a bug.
11376 @cindex @code{trf} request, and invalid characters
11377 @cindex characters, invalid for @code{trf} request
11378 @cindex invalid characters for @code{trf} request
11379 While @code{cf} copies the contents of @var{file} completely unprocessed,
11380 @code{trf} disallows characters such as NUL that are not valid
11381 @code{gtroff} input characters (@pxref{Identifiers}).
11383 Both requests cause a line break.
11384 @endDefreq
11386 @Defreq {nx, [@Var{file}]}
11387 @cindex processing next file (@code{nx})
11388 @cindex file, processing next (@code{nx})
11389 @cindex next file, processing (@code{nx})
11390 Force @code{gtroff} to continue processing of
11391 the file specified as an argument.  If no argument is given, immediately
11392 jump to the end of file.
11393 @endDefreq
11395 @Defreq {rd, [@Var{prompt} [@Var{arg1} @Var{arg2} @dots{}]]}
11396 @cindex reading from standard input (@code{rd})
11397 @cindex standard input, reading from (@code{rd})
11398 @cindex input, standard, reading from (@code{rd})
11399 Read from standard input, and include what is read as though it
11400 were part of the input file.  Text is read until a blank line
11401 is encountered.
11403 If standard input is a TTY input device (keyboard), write @var{prompt}
11404 to standard error, followed by a colon (or send BEL for a beep if no
11405 argument is given).
11407 Arguments after @var{prompt} are available for the input.  For example,
11408 the line
11410 @Example
11411 .rd data foo bar
11412 @endExample
11414 with the input @w{@samp{This is \$2.}} prints
11416 @Example
11417 This is bar.
11418 @endExample
11419 @endDefreq
11421 @cindex form letters
11422 @cindex letters, form
11423 Using the @code{nx} and @code{rd} requests,
11424 it is easy to set up form letters.  The form
11425 letter template is constructed like this, putting the following lines
11426 into a file called @file{repeat.let}:
11428 @Example
11430 \*(td
11431 .sp 2
11437 Body of letter.
11439 .nx repeat.let
11440 @endExample
11442 @cindex @code{ex} request, used with @code{nx} and @code{rd}
11443 @noindent
11444 When this is run, a file containing the following lines should be
11445 redirected in.  Note that requests included in this file are executed
11446 as though they were part of the form letter.  The last block of input
11447 is the @code{ex} request which tells groff to stop processing.  If
11448 this was not there, groff would not know when to stop.
11450 @Example
11451 Trent A. Fisher
11452 708 NW 19th Av., #202
11453 Portland, OR  97209
11455 Dear Trent,
11457 Len Adollar
11458 4315 Sierra Vista
11459 San Diego, CA  92103
11461 Dear Mr. Adollar,
11464 @endExample
11466 @Defreq {pi, pipe}
11467 Pipe the output of @code{gtroff} to the shell command(s)
11468 specified by @var{pipe}.  This request must occur before
11469 @code{gtroff} has a chance to print anything.
11471 @cindex safer mode
11472 @cindex mode, safer
11473 @cindex unsafe mode
11474 @cindex mode, unsafe
11475 @code{pi} causes an error if used in safer mode (which is the default).
11476 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
11477 mode.
11479 Multiple calls to @code{pi} are allowed, acting as a chain.  For example,
11481 @Example
11482 .pi foo
11483 .pi bar
11485 @endExample
11487 is the same as @w{@samp{.pi foo | bar}}.
11489 @cindex @code{groff}, and @code{pi} request
11490 @cindex @code{pi} request, and @code{groff}
11491 Note that the intermediate output format of @code{gtroff} is piped to
11492 the specified commands.  Consequently, calling @code{groff} without the
11493 @option{-Z} option normally causes a fatal error.
11494 @endDefreq
11496 @DefreqList {sy, cmds}
11497 @DefregListEnd {systat}
11498 Execute the shell command(s) specified by @var{cmds}.  The output is not
11499 saved anyplace, so it is up to the user to do so.
11501 @cindex safer mode
11502 @cindex mode, safer
11503 @cindex unsafe mode
11504 @cindex mode, unsafe
11505 This request causes an error if used in safer mode (which is the default).
11506 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
11507 mode.
11509 For example, the following code fragment introduces the current time into a
11510 document:
11512 @cindex time, current
11513 @cindex current time
11514 @pindex perl
11515 @Example
11516 .sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
11517              (localtime(time))[2,1,0]' > /tmp/x\n[$$]
11518 .so /tmp/x\n[$$]
11519 .sy rm /tmp/x\n[$$]
11520 \nH:\nM:\nS
11521 @endExample
11523 @noindent
11524 Note that this works by having the @code{perl} script (run by @code{sy})
11525 print out the @code{nr} requests which set the number registers
11526 @code{H}, @code{M}, and @code{S}, and then reads those commands in with
11527 the @code{so} request.
11529 For most practical purposes, the number registers @code{seconds},
11530 @code{minutes}, and @code{hours} which are initialized at start-up of
11531 @code{gtroff} should be sufficient.  Use the @code{af} request to get a
11532 formatted output:
11534 @Example
11535 .af hours 00
11536 .af minutes 00
11537 .af seconds 00
11538 \n[hours]:\n[minutes]:\n[seconds]
11539 @endExample
11541 @cindex @code{system()} return value register (@code{systat})
11542 The @code{systat} read-write number register contains the return value
11543 of the @code{system()} function executed by the last @code{sy} request.
11544 @endDefreq
11546 @DefreqList {open, stream file}
11547 @DefreqListEnd {opena, stream file}
11548 @cindex opening file (@code{open})
11549 @cindex file, opening (@code{open})
11550 @cindex appending to a file (@code{opena})
11551 @cindex file, appending to (@code{opena})
11552 Open the specified @var{file} for writing and
11553 associates the specified @var{stream} with it.
11555 The @code{opena} request is like @code{open}, but if the file exists,
11556 append to it instead of truncating it.
11558 @cindex safer mode
11559 @cindex mode, safer
11560 @cindex unsafe mode
11561 @cindex mode, unsafe
11562 Both @code{open} and @code{opena} cause an error if used in safer mode
11563 (which is the default).  Use @code{groff}'s or @code{troff}'s @option{-U}
11564 option to activate unsafe mode.
11565 @endDefreq
11567 @DefreqList {write, stream data}
11568 @DefreqListEnd {writec, stream data}
11569 @cindex copy-in mode, and @code{write} requests
11570 @cindex mode, copy-in, and @code{write} requests
11571 @cindex writing to file (@code{write})
11572 @cindex file, writing to (@code{write})
11573 Write to the file associated with the specified @var{stream}.
11574 The stream must previously have
11575 been the subject of an open request.  The remainder of the line is
11576 interpreted as the @code{ds} request reads its second argument: A
11577 leading @samp{"} is stripped, and it is read in copy-in mode.
11579 The @code{writec} request is like @code{write}, but only
11580 @code{write} appends a newline to the data.
11581 @endDefreq
11583 @Defreq {writem, stream xx}
11584 @cindex @code{asciify} request, and @code{writem}
11585 Write the contents of the macro or string @var{xx}
11586 to the file associated with the specified @var{stream}.
11588 @var{xx} is read in copy mode, i.e., already formatted elements are
11589 ignored.  Consequently, diversions must be unformatted with the
11590 @code{asciify} request before calling @code{writem}.  Usually, this
11591 means a loss of information.
11592 @endDefreq
11594 @Defreq {close, stream}
11595 @cindex closing file (@code{close})
11596 @cindex file, closing (@code{close})
11597 Close the specified @var{stream};
11598 the stream is no longer an acceptable argument to the
11599 @code{write} request.
11601 Here a simple macro to write an index entry.
11603 @Example
11604 .open idx test.idx
11606 .de IX
11607 .  write idx \\n[%] \\$*
11610 .IX test entry
11612 .close idx
11613 @endExample
11614 @endDefreq
11616 @DefescList {\\V, , e, }
11617 @DefescItem {\\V, @lparen{}, ev, }
11618 @DefescListEnd {\\V, @lbrack{}, env, @rbrack}
11619 Interpolate the contents of the specified environment variable
11620 @var{env} (one-character name@w{ }@var{e}, two-character name @var{ev})
11621 as returned by the function @code{getenv}.  @code{\V} is interpreted
11622 in copy-in mode.
11623 @endDefesc
11626 @c =====================================================================
11628 @node Postprocessor Access, Miscellaneous, I/O, gtroff Reference
11629 @section Postprocessor Access
11630 @cindex postprocessor access
11631 @cindex access of postprocessor
11633 There are two escapes which give information directly to the
11634 postprocessor.  This is particularly useful for embedding
11635 @sc{PostScript} into the final document.
11637 @Defesc {\\X, ', xxx, '}
11638 Embeds its argument into the @code{gtroff}
11639 output preceded with @w{@samp{x X}}.
11641 @cindex @code{\&}, in @code{\X}
11642 @cindex @code{\)}, in @code{\X}
11643 @cindex @code{\%}, in @code{\X}
11644 @ifnotinfo
11645 @cindex @code{\:}, in @code{\X}
11646 @end ifnotinfo
11647 @ifinfo
11648 @cindex @code{\@r{<colon>}}, in @code{\X}
11649 @end ifinfo
11650 The escapes @code{\&}, @code{\)}, @code{\%}, and @code{\:} are ignored
11651 within @code{\X}, @w{@samp{\ }} and @code{\~} are converted to single
11652 space characters.  All other escapes (except @code{\\} which produces a
11653 backslash) cause an error.
11655 @kindex use_charnames_in_special
11656 @pindex DESC@r{, and @code{use_charnames_in_special}}
11657 @cindex @code{\X}, and special characters
11658 If the @samp{use_charnames_in_special} keyword is set in the @file{DESC}
11659 file, special characters no longer cause an error; the name @var{xx} is
11660 represented as @samp{\(@var{xx})} in the @w{@samp{x X}} output command.
11661 Additionally, the backslash is represented as @code{\\}.
11663 This mechanism is currently used by @code{grohtml} only.
11664 @endDefesc
11666 @DefescList {\\Y, , n, }
11667 @DefescItem {\\Y, @lparen{}, nm, }
11668 @DefescListEnd {\\Y, @lbrack{}, name, @rbrack}
11669 This is approximately equivalent to @samp{\X'\*[@var{name}]'}
11670 (one-character name@w{ }@var{n}, two-character name @var{nm}).
11671 However, the contents of the string or macro @var{name} are not
11672 interpreted; also it is permitted for @var{name} to have been defined
11673 as a macro and thus contain newlines (it is not permitted for the
11674 argument to @code{\X} to contain newlines).  The inclusion of
11675 newlines requires an extension to the @acronym{UNIX} @code{troff}
11676 output format, and confuses drivers that do not know about this
11677 extension (@pxref{Device Control Commands}).
11678 @endDefesc
11680 @xref{Output Devices}.
11683 @c =====================================================================
11685 @node Miscellaneous, Gtroff Internals, Postprocessor Access, gtroff Reference
11686 @section Miscellaneous
11688 This section documents parts of @code{gtroff} which cannot (yet) be
11689 categorized elsewhere in this manual.
11691 @Defreq {nm, [@Var{start} [@Var{inc} [@Var{space} [@Var{indent}]]]]}
11692 @cindex printing line numbers (@code{nm})
11693 @cindex line numbers, printing (@code{nm})
11694 @cindex numbers, line, printing (@code{nm})
11695 Print line numbers.
11696 @var{start} is the line number of the @emph{next}
11697 output line.  @var{inc} indicates which line numbers are printed.
11698 For example, the value@w{ }5 means to emit only line numbers which
11699 are multiples of@w{ }5; this defaults to@w{ }1.  @var{space} is the
11700 space to be left between the number and the text; this defaults to
11701 one digit space.  The fourth argument is the indentation of the line
11702 numbers, defaulting to zero.  Both @var{space} and @var{indent} are
11703 given as multiples of digit spaces; they can be negative also.
11704 Without any arguments, line numbers are turned off.
11706 @code{gtroff} reserves three digit spaces for the line number (which is
11707 printed right-justified) plus the amount given by @var{indent}; the
11708 output lines are concatenated to the line numbers, separated by
11709 @var{space}, and @emph{without} reducing the line length.  Depending
11710 on the value of the horizontal page offset (as set with the
11711 @code{po} request), line numbers which are longer than the reserved
11712 space stick out to the left, or the whole line is moved to the right.
11714 Parameters corresponding to missing arguments are not changed; any
11715 non-digit argument (to be more precise, any argument starting with a
11716 character valid as a delimiter for identifiers) is also treated as
11717 missing.
11719 If line numbering has been disabled with a call to @code{nm} without
11720 an argument, it can be reactivated with @samp{.nm +0}, using the
11721 previously active line numbering parameters.
11723 The parameters of @code{nm} are associated with the current environment
11724 (@pxref{Environments}).  The current output line number is available
11725 in the number register @code{ln}.
11727 @Example
11728 .po 1m
11729 .ll 2i
11730 This test shows how line numbering works with groff.
11731 .nm 999
11732 This test shows how line numbering works with groff.
11734 .nm xxx 3 2
11735 .ll -\w'0'u
11736 This test shows how line numbering works with groff.
11737 .nn 2
11738 This test shows how line numbering works with groff.
11739 @endExample
11741 @noindent
11742 And here the result:
11744 @Example
11745  This  test shows how
11746  line numbering works
11747  999 with   groff.   This
11748 1000 test shows how  line
11749 1001 numbering works with
11750 1002 groff.
11751       This test shows how
11752       line      numbering
11753  works  with  groff.
11754  This test shows how
11755 1005  line      numbering
11756       works with groff.
11757 @endExample
11758 @endDefreq
11760 @Defreq {nn, [@Var{skip}]}
11761 Temporarily turn off line numbering.  The argument is the number
11762 of lines not to be numbered; this defaults to@w{ }1.
11763 @endDefreq
11765 @Defreq {mc, glyph [@Var{dist}]}
11766 @cindex margin glyph (@code{mc})
11767 @cindex glyph, for margins (@code{mc})
11768 Print a @dfn{margin character} to the right of the
11769 text.@footnote{@dfn{Margin character} is a misnomer since it is an
11770 output glyph.}  The first argument is the glyph to be
11771 printed.  The second argument is the distance away from the right
11772 margin.  If missing, the previously set value is used; default is
11773 10@dmn{pt}).  For text lines that are too long (that is, longer than
11774 the text length plus @var{dist}), the margin character is directly
11775 appended to the lines.
11777 With no arguments the margin character is turned off.
11778 If this occurs before a break, no margin character is printed.
11780 @cindex @code{tl} request, and @code{mc}
11781 For empty lines and lines produced by the @code{tl} request no margin
11782 character is emitted.
11784 The margin character is associated with the current environment
11785 (@pxref{Environments}).
11787 @pindex nrchbar
11788 @pindex changebar
11789 This is quite useful for indicating text that has changed, and, in fact,
11790 there are programs available for doing this (they are called
11791 @code{nrchbar} and @code{changebar} and can be found in any
11792 @samp{comp.sources.unix} archive.
11794 @Example
11795 .ll 3i
11796 .mc |
11797 This paragraph is highlighted with a margin
11798 character.
11800 Note that vertical space isn't marked.
11804 But we can fake it with `\&'.
11805 @endExample
11807 Result:
11809 @Example
11810 This  paragraph is highlighted |
11811 with a margin character.       |
11813 Note that vertical space isn't |
11814 marked.                        |
11815                                |
11816 But we can fake it with `\&'.  |
11817 @endExample
11818 @endDefreq
11820 @DefreqList {psbb, filename}
11821 @DefregItem {llx}
11822 @DefregItem {lly}
11823 @DefregItem {urx}
11824 @DefregListEnd {ury}
11825 @cindex PostScript, bounding box
11826 @cindex bounding box
11827 Retrieve the bounding box of the PostScript image
11828 found in @var{filename}.
11829 The file must conform to
11830 Adobe's @dfn{Document Structuring Conventions} (DSC);
11831 the command searches for a @code{%%BoundingBox} comment
11832 and extracts the bounding box values into the number registers
11833 @code{llx}, @code{lly}, @code{urx}, and @code{ury}.
11834 If an error occurs (for example, @code{psbb} cannot find
11835 the @code{%%BoundingBox} comment),
11836 it sets the four number registers to zero.
11837 @endDefreq
11840 @c =====================================================================
11842 @node Gtroff Internals, Debugging, Miscellaneous, gtroff Reference
11843 @section @code{gtroff} Internals
11845 @cindex input token
11846 @cindex token, input
11847 @cindex output node
11848 @cindex node, output
11849 @code{gtroff} processes input in three steps.  One or more input
11850 characters are converted to an @dfn{input token}.@footnote{Except the
11851 escapes @code{\f}, @code{\F}, @code{\H}, @code{\R}, @code{\s}, and
11852 @code{\S} which are processed immediately if not in copy-in mode.}
11853 Then, one or more input tokens are converted to an @dfn{output node}.
11854 Finally, output nodes are converted to the intermediate output language
11855 understood by all output devices.
11857 Actually, before step one happens, @code{gtroff} converts certain
11858 escape sequences into reserved input characters (not accessible by
11859 the user); such reserved characters are used for other internal
11860 processing also -- this is the very reason why not all characters
11861 are valid input.  @xref{Identifiers}, for more on this topic.
11863 For example, the input string @samp{fi\[:u]} is converted into a
11864 character token @samp{f}, a character token @samp{i}, and a special
11865 token @samp{:u} (representing u@w{ }umlaut).  Later on, the character
11866 tokens @samp{f} and @samp{i} are merged to a single output node
11867 representing the ligature glyph @samp{fi} (provided the current font
11868 has a glyph for this ligature); the same happens with @samp{:u}.  All
11869 output glyph nodes are `processed' which means that they are invariably
11870 associated with a given font, font size, advance width, etc.  During
11871 the formatting process, @code{gtroff} itself adds various nodes to
11872 control the data flow.
11874 Macros, diversions, and strings collect elements in two chained lists:
11875 a list of input tokens which have been passed unprocessed, and a list
11876 of output nodes.  Consider the following the diversion.
11878 @Example
11879 .di xxx
11885 @endExample
11887 @noindent
11888 It contains these elements.
11890 @multitable {@i{vertical size node}} {token list} {element number}
11891 @item node list               @tab token list @tab element number
11893 @item @i{line start node}     @tab ---        @tab 1
11894 @item @i{glyph node @code{a}} @tab ---        @tab 2
11895 @item @i{word space node}     @tab ---        @tab 3
11896 @item ---                     @tab @code{b}   @tab 4
11897 @item ---                     @tab @code{\n}  @tab 5
11898 @item @i{glyph node @code{c}} @tab ---        @tab 6
11899 @item @i{vertical size node}  @tab ---        @tab 7
11900 @item @i{vertical size node}  @tab ---        @tab 8
11901 @item ---                     @tab @code{\n}  @tab 9
11902 @end multitable
11904 @cindex @code{\v}, internal representation
11905 @noindent
11906 Elements 1, 7, and@w{ }8 are inserted by @code{gtroff}; the latter two
11907 (which are always present) specify the vertical extent of the last
11908 line, possibly modified by @code{\x}.  The @code{br} request finishes
11909 the current partial line, inserting a newline input token which is
11910 subsequently converted to a space when the diversion is reread.  Note
11911 that the word space node has a fixed width which isn't stretchable
11912 anymore.  To convert horizontal space nodes back to input tokens, use
11913 the @code{unformat} request.
11915 Macros only contain elements in the token list (and the node list is
11916 empty); diversions and strings can contain elements in both lists.
11918 Some requests like @code{tr} or @code{cflags} work on glyph
11919 identifiers only; this means that the associated glyph can be changed
11920 without destroying this association.  This can be very helpful for
11921 substituting glyphs.  In the following example, we assume that
11922 glyph @samp{foo} isn't available by default, so we provide a
11923 substitution using the @code{fchar} request and map it to input
11924 character @samp{x}.
11926 @Example
11927 .fchar \[foo] foo
11928 .tr x \[foo]
11929 @endExample
11931 @noindent
11932 Now let us assume that we install an additional special font
11933 @samp{bar} which has glyph @samp{foo}.
11935 @Example
11936 .special bar
11937 .rchar \[foo]
11938 @endExample
11940 @noindent
11941 Since glyphs defined with @code{fchar} are searched before glyphs
11942 in special fonts, we must call @code{rchar} to remove the definition
11943 of the fallback glyph.  Anyway, the translation is still active;
11944 @samp{x} now maps to the real glyph @samp{foo}.
11947 @c =====================================================================
11949 @node Debugging, Implementation Differences, Gtroff Internals, gtroff Reference
11950 @section Debugging
11951 @cindex debugging
11953 @code{gtroff} is not easy to debug, but there are some useful features
11954 and strategies for debugging.
11956 @Defreq {lf, line filename}
11957 @pindex soelim
11958 @cindex multi-file documents
11959 @cindex documents, multi-file
11960 @cindex setting input line number (@code{lf})
11961 @cindex input line number, setting (@code{lf})
11962 @cindex number, input line, setting (@code{lf})
11963 Change the line number and the file name @code{gtroff} shall use for
11964 error and warning messages.  @var{line} is the input line number of the
11965 @emph{next} line.
11967 Without argument, the request is ignored.
11969 This is a debugging aid for documents which are split into many files,
11970 then put together with @code{soelim} and other preprocessors.  Usually,
11971 it isn't invoked manually.
11972 @endDefreq
11974 @DefreqList {tm, string}
11975 @DefreqItem {tm1, string}
11976 @DefreqListEnd {tmc, string}
11977 @cindex printing to stderr (@code{tm}, @code{tm1}, @code{tmc})
11978 @cindex stderr, printing to (@code{tm}, @code{tm1}, @code{tmc})
11979 Send @var{string} to the standard error output;
11980 this is very useful for printing debugging messages among other things.
11982 @var{string} is read in copy mode.
11984 The @code{tm} request ignores leading spaces of @var{string}; @code{tm1}
11985 handles its argument similar to the @code{ds} request: a leading double
11986 quote in @var{string} is stripped to allow initial blanks.
11988 The @code{tmc} request is similar to @code{tm1} but does
11989 not append a newline (as is done in @code{tm} and @code{tm1}).
11990 @endDefreq
11992 @Defreq {ab, [@Var{string}]}
11993 @cindex aborting (@code{ab})
11994 Similar to the @code{tm} request, except that
11995 it causes @code{gtroff} to stop processing.  With no argument it
11996 prints @samp{User Abort.} to standard error.
11997 @endDefreq
11999 @Defreq {ex, }
12000 @cindex @code{ex} request, use in debugging
12001 @cindex exiting (@code{ex})
12002 The @code{ex} request also causes @code{gtroff} to stop processing;
12003 see also @ref{I/O}.
12004 @endDefreq
12006 When doing something involved it is useful to leave the debugging
12007 statements in the code and have them turned on by a command line flag.
12009 @Example
12010 .if \n(DB .tm debugging output
12011 @endExample
12013 @noindent
12014 To activate these statements say
12016 @Example
12017 groff -rDB=1 file
12018 @endExample
12020 If it is known in advance that there will be many errors and no useful
12021 output, @code{gtroff} can be forced to suppress formatted output with
12022 the @option{-z} flag.
12024 @Defreq {pm, }
12025 @cindex dumping symbol table (@code{pm})
12026 @cindex symbol table, dumping (@code{pm})
12027 Print the entire symbol table on @code{stderr}.  Names of all defined
12028 macros, strings, and diversions are print together with their size in
12029 bytes.  Since @code{gtroff} sometimes adds nodes by itself, the
12030 returned size can be larger than expected.
12032 This request differs from @acronym{UNIX} @code{troff}: @code{gtroff}
12033 reports the sizes of diversions, ignores an additional argument to
12034 print only the total of the sizes, and the size isn't returned in
12035 blocks of 128 characters.
12036 @endDefreq
12038 @Defreq {pnr, }
12039 @cindex dumping number registers (@code{pnr})
12040 @cindex number registers, dumping (@code{pnr})
12041 Print the names and contents of all
12042 currently defined number registers on @code{stderr}.
12043 @endDefreq
12045 @Defreq {ptr, }
12046 @cindex dumping traps (@code{ptr})
12047 @cindex traps, dumping (@code{ptr})
12048 Print the names and positions of all traps
12049 (not including input line traps and diversion traps) on @code{stderr}.
12050 Empty slots in the page trap list are printed as well, because they can
12051 affect the priority of subsequently planted traps.
12052 @endDefreq
12054 @Defreq {fl, }
12055 @cindex flush output (@code{fl})
12056 @cindex output, flush (@code{fl})
12057 @cindex interactive use of @code{gtroff}
12058 @cindex @code{gtroff}, interactive use
12059 Instruct @code{gtroff} to flush its output immediately.  The intent
12060 is for interactive use, but this behaviour is currently not
12061 implemented in @code{gtroff}.  Contrary to @acronym{UNIX} @code{troff},
12062 TTY output is sent to a device driver also (@code{grotty}), making it
12063 non-trivial to communicate interactively.
12065 This request causes a line break.
12066 @endDefreq
12068 @Defreq {backtrace, }
12069 @cindex backtrace of input stack (@code{backtrace})
12070 @cindex input stack, backtrace (@code{backtrace})
12071 Print a backtrace of the input stack to the standard error stream.
12073 Consider the following in file @file{test}:
12075 @Example
12076 .de xxx
12077 .  backtrace
12079 .de yyy
12080 .  xxx
12083 .yyy
12084 @endExample
12086 @noindent
12087 On execution, @code{gtroff} prints the following:
12089 @Example
12090 test:2: backtrace: macro `xxx'
12091 test:5: backtrace: macro `yyy'
12092 test:8: backtrace: file `test'
12093 @endExample
12095 The option @option{-b} of @code{gtroff} internally calls a variant of
12096 this request on each error and warning.
12097 @endDefreq
12099 @Defreg {slimit}
12100 @cindex input stack, setting limit
12101 Use the @code{slimit} number register
12102 to set the maximum number of objects on the input stack.
12103 If @code{slimit} is less than or equal to@w{ }0,
12104 there is no limit set.
12105 With no limit, a buggy recursive macro can exhaust virtual memory.
12107 The default value is 1000; this is a compile-time constant.
12108 @endDefreg
12110 @Defreq {warnscale, si}
12111 Set the scaling indicator used in warnings to @var{si}.  Valid values for
12112 @var{si} are @samp{u}, @samp{i}, @samp{c}, @samp{p}, and @samp{P}.  At
12113 startup, it is set to @samp{i}.
12114 @endDefreq
12116 @Defreq {spreadwarn, [@Var{limit}]}
12117 Make @code{gtroff} emit a warning if the additional space inserted for
12118 each space between words in an output line is larger or equal to
12119 @var{limit}.  A negative value is changed to zero; no argument toggles the
12120 warning on and off without changing @var{limit}.  The default scaling
12121 indicator is @samp{m}.  At startup, @code{spreadwarn} is deactivated, and
12122 @var{limit} is set to 3@dmn{m}.
12124 For example,
12126 @Example
12127 .spreadwarn 0.2m
12128 @endExample
12130 @noindent
12131 will cause a warning if @code{gtroff} must add 0.2@dmn{m} or more for each
12132 interword space in a line.
12134 This request is active only if text is justified to both margins (using
12135 @w{@samp{.ad b}}).
12136 @endDefreq
12138 @cindex warnings
12139 @code{gtroff} has command line options for printing out more warnings
12140 (@option{-w}) and for printing backtraces (@option{-b}) when a warning
12141 or an error occurs.  The most verbose level of warnings is @option{-ww}.
12143 @DefreqList {warn, [@Var{flags}]}
12144 @DefregListEnd {.warn}
12145 @cindex level of warnings (@code{warn})
12146 @cindex warnings, level (@code{warn})
12147 Control the level of warnings checked for.  The @var{flags} are the sum
12148 of the numbers associated with each warning that is to be enabled; all
12149 other warnings are disabled.  The number associated with each warning is
12150 listed below.  For example, @w{@code{.warn 0}} disables all warnings,
12151 and @w{@code{.warn 1}} disables all warnings except that about missing
12152 glyphs.  If no argument is given, all warnings are enabled.
12154 The read-only number register @code{.warn} contains the current warning
12155 level.
12156 @endDefreq
12158 @menu
12159 * Warnings::
12160 @end menu
12162 @c ---------------------------------------------------------------------
12164 @node Warnings,  , Debugging, Debugging
12165 @subsection Warnings
12166 @cindex warnings
12168 The warnings that can be given to @code{gtroff} are divided into the
12169 following categories.  The name associated with each warning is used by
12170 the @option{-w} and @option{-W} options; the number is used by the
12171 @code{warn} request and by the @code{.warn} register.
12173 @table @samp
12174 @item char
12175 @itemx 1
12176 Non-existent glyphs.@footnote{@code{char} is a misnomer since it reports
12177 missing glyphs -- there aren't missing input characters, only invalid
12178 ones.}  This is enabled by default.
12180 @item number
12181 @itemx 2
12182 Invalid numeric expressions.  This is enabled by default.
12183 @xref{Expressions}.
12185 @item break
12186 @itemx 4
12187 @cindex fill mode
12188 @cindex mode, fill
12189 In fill mode, lines which could not be broken so that their length was
12190 less than the line length.  This is enabled by default.
12192 @item delim
12193 @itemx 8
12194 Missing or mismatched closing delimiters.
12196 @item el
12197 @itemx 16
12198 @cindex @code{ie} request, and warnings
12199 @cindex @code{el} request, and warnings
12200 Use of the @code{el} request with no matching @code{ie} request.
12201 @xref{if-else}.
12203 @item scale
12204 @itemx 32
12205 Meaningless scaling indicators.
12207 @item range
12208 @itemx 64
12209 Out of range arguments.
12211 @item syntax
12212 @itemx 128
12213 Dubious syntax in numeric expressions.
12215 @item di
12216 @itemx 256
12217 @cindex @code{di} request, and warnings
12218 @cindex @code{da} request, and warnings
12219 Use of @code{di} or @code{da} without an argument when there is no
12220 current diversion.
12222 @item mac
12223 @itemx 512
12224 @cindex @code{de}, @code{de1}, @code{dei} requests, and warnings
12225 @cindex @code{am}, @code{am1}, @code{ami} requests, and warnings
12226 @cindex @code{ds}, @code{ds1} requests, and warnings
12227 @cindex @code{as}, @code{as1} requests, and warnings
12228 @cindex @code{di} request, and warnings
12229 @cindex @code{da} request, and warnings
12230 @cindex @code{box}, @code{boxa} requests, and warnings
12231 @cindex @code{\*}, and warnings
12232 Use of undefined strings, macros and diversions.  When an undefined
12233 string, macro, or diversion is used, that string is automatically
12234 defined as empty.  So, in most cases, at most one warning is given
12235 for each name.
12237 @item reg
12238 @itemx 1024
12239 @cindex @code{nr} request, and warnings
12240 @cindex @code{\R}, and warnings
12241 @cindex @code{\n}, and warnings
12242 Use of undefined number registers.  When an undefined number register is
12243 used, that register is automatically defined to have a value of@w{ }0.
12244 So, in most cases, at most one warning is given for use of a particular
12245 name.
12247 @item tab
12248 @itemx 2048
12249 @cindex @code{\t}, and warnings
12250 Use of a tab character where a number was expected.
12252 @item right-brace
12253 @itemx 4096
12254 @cindex @code{\@}}, and warnings
12255 Use of @code{\@}} where a number was expected.
12257 @item missing
12258 @itemx 8192
12259 Requests that are missing non-optional arguments.
12261 @item input
12262 @itemx 16384
12263 Invalid input characters.
12265 @item escape
12266 @itemx 32768
12267 Unrecognized escape sequences.  When an unrecognized escape sequence
12268 @code{\@var{X}} is encountered, the escape character is ignored, and
12269 @var{X} is printed.
12271 @item space
12272 @itemx 65536
12273 @cindex compatibility mode
12274 Missing space between a request or macro and its argument.  This warning
12275 is given when an undefined name longer than two characters is
12276 encountered, and the first two characters of the name make a defined
12277 name.  The request or macro is not invoked.  When this warning is
12278 given, no macro is automatically defined.  This is enabled by default.
12279 This warning never occurs in compatibility mode.
12281 @item font
12282 @itemx 131072
12283 Non-existent fonts.  This is enabled by default.
12285 @item ig
12286 @itemx 262144
12287 Invalid escapes in text ignored with the @code{ig} request.  These are
12288 conditions that are errors when they do not occur in ignored text.
12290 @item color
12291 @itemx 524288
12292 Color related warnings.
12294 @item all
12295 All warnings except @samp{di}, @samp{mac} and @samp{reg}.  It is
12296 intended that this covers all warnings that are useful with traditional
12297 macro packages.
12299 @item w
12300 All warnings.
12301 @end table
12304 @c =====================================================================
12306 @node Implementation Differences,  , Debugging, gtroff Reference
12307 @section Implementation Differences
12308 @cindex implementation differences
12309 @cindex differences in implementation
12310 @cindex incompatibilities with @acronym{AT&T} @code{troff}
12311 @cindex compatibility mode
12312 @cindex mode, compatibility
12314 GNU @code{troff} has a number of features which cause incompatibilities
12315 with documents written with old versions of @code{troff}.
12317 @cindex long names
12318 @cindex names, long
12319 Long names cause some incompatibilities.  @acronym{UNIX} @code{troff}
12320 interprets
12322 @Example
12323 .dsabcd
12324 @endExample
12326 @cindex @code{\*}, incompatibilities with @acronym{AT&T} @code{troff}
12327 @cindex @code{\n}, incompatibilities with @acronym{AT&T} @code{troff}
12328 @noindent
12329 as defining a string @samp{ab} with contents @samp{cd}.  Normally, GNU
12330 @code{troff} interprets this as a call of a macro named
12331 @code{dsabcd}.  Also @acronym{UNIX} @code{troff} interprets
12332 @code{\*[} or @code{\n[} as references to a string or number register
12333 called @samp{[}.  In GNU @code{troff}, however, this is normally
12334 interpreted as the start of a long name.  In compatibility mode GNU
12335 @code{troff} interprets long names in the traditional way
12336 (which means that they are not recognized as names).
12338 @DefreqList {cp, [@Var{n}]}
12339 @DefreqItem {do, cmd}
12340 @DefregListEnd {.C}
12341 If @var{n} is missing or non-zero, turn on compatibility mode;
12342 otherwise, turn it off.
12344 The read-only number register @code{.C} is@w{ }1 if compatibility mode is
12345 on, 0@w{ }otherwise.
12347 Compatibility mode can be also turned on with the @option{-C} command line
12348 option.
12350 The @code{do} request turns off compatibility mode
12351 while executing its arguments as a @code{gtroff} command.
12353 @Example
12354 .do fam T
12355 @endExample
12357 @noindent
12358 executes the @code{fam} request when compatibility mode
12359 is enabled.
12361 @code{gtroff} restores the previous compatibility setting
12362 before interpreting any files sourced by the @var{cmd}.
12363 @endDefreq
12365 @cindex input level in delimited arguments
12366 @cindex delimited arguments, incompatibilities with @acronym{AT&T} @code{troff}
12367 Two other features are controlled by @option{-C}.  If not in
12368 compatibility mode, GNU @code{troff} preserves the input level in
12369 delimited arguments:
12371 @Example
12372 .ds xx '
12373 \w'abc\*(xxdef'
12374 @endExample
12376 @noindent
12377 In compatibility mode, the string @samp{72def'} is returned; without
12378 @option{-C} the resulting string is @samp{168} (assuming a TTY output
12379 device).
12381 @cindex @code{\f}, incompatibilities with @acronym{AT&T} @code{troff}
12382 @cindex @code{\H}, incompatibilities with @acronym{AT&T} @code{troff}
12383 @cindex @code{\R}, incompatibilities with @acronym{AT&T} @code{troff}
12384 @cindex @code{\s}, incompatibilities with @acronym{AT&T} @code{troff}
12385 @cindex @code{\S}, incompatibilities with @acronym{AT&T} @code{troff}
12386 Finally, the escapes @code{\f}, @code{\H}, @code{\R}, @code{\s}, and
12387 @code{\S} are transparent for recognizing the beginning of a line only
12388 in compatibility mode (this is a rather obscure feature).  For example,
12389 the code
12391 @Example
12392 .de xx
12393 Hallo!
12395 \fB.xx\fP
12396 @endExample
12398 prints @samp{Hallo!} in bold face if in compatibility mode, and
12399 @samp{.xx} in bold face otherwise.
12401 @cindex @code{\A}, incompatibilities with @acronym{AT&T} @code{troff}
12402 @cindex @code{\|}, incompatibilities with @acronym{AT&T} @code{troff}
12403 @cindex @code{\^}, incompatibilities with @acronym{AT&T} @code{troff}
12404 @cindex @code{\&}, incompatibilities with @acronym{AT&T} @code{troff}
12405 @cindex @code{\@{}, incompatibilities with @acronym{AT&T} @code{troff}
12406 @cindex @code{\@}}, incompatibilities with @acronym{AT&T} @code{troff}
12407 @cindex @code{\@key{SP}}, incompatibilities with @acronym{AT&T} @code{troff}
12408 @cindex @code{\'}, incompatibilities with @acronym{AT&T} @code{troff}
12409 @cindex @code{\`}, incompatibilities with @acronym{AT&T} @code{troff}
12410 @cindex @code{\-}, incompatibilities with @acronym{AT&T} @code{troff}
12411 @cindex @code{\_}, incompatibilities with @acronym{AT&T} @code{troff}
12412 @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
12413 @cindex @code{\%}, incompatibilities with @acronym{AT&T} @code{troff}
12414 @cindex @code{\c}, incompatibilities with @acronym{AT&T} @code{troff}
12415 GNU @code{troff} does not allow the use of the escape sequences
12416 @code{\|}, @code{\^}, @code{\&}, @code{\@{}, @code{\@}},
12417 @code{\@key{SP}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
12418 @code{\%}, and @code{\c} in names of strings, macros, diversions, number
12419 registers, fonts or environments; @acronym{UNIX} @code{troff} does.  The
12420 @code{\A} escape sequence (@pxref{Identifiers}) may be helpful in
12421 avoiding use of these escape sequences in names.
12423 @cindex fractional point sizes
12424 @cindex fractional type sizes
12425 @cindex point sizes, fractional
12426 @cindex type sizes, fractional
12427 @cindex sizes, fractional
12428 @cindex @code{ps} request, incompatibilities with @acronym{AT&T} @code{troff}
12429 Fractional point sizes cause one noteworthy incompatibility.  In
12430 @acronym{UNIX} @code{troff} the @code{ps} request ignores scale
12431 indicators and thus
12433 @Example
12434 .ps 10u
12435 @endExample
12437 @noindent
12438 sets the point size to 10@w{ }points, whereas in GNU @code{troff} it
12439 sets the point size to 10@w{ }scaled points.  @xref{Fractional Type
12440 Sizes}, for more information.
12442 @cindex @code{bd} request, incompatibilities with @acronym{AT&T} @code{troff}
12443 @cindex @code{cs} request, incompatibilities with @acronym{AT&T} @code{troff}
12444 @cindex @code{tr} request, incompatibilities with @acronym{AT&T} @code{troff}
12445 @cindex @code{fp} request, incompatibilities with @acronym{AT&T} @code{troff}
12446 @cindex input characters and output glyphs, compatibility with @acronym{AT&T} @code{troff}
12447 @cindex output glyphs, and input characters,compatibility with @acronym{AT&T} @code{troff}
12448 @cindex characters, input, and output glyphs, compatibility with @acronym{AT&T} @code{troff}
12449 @cindex glyphs, output, and input characters, compatibility with @acronym{AT&T} @code{troff}
12450 In GNU @code{troff} there is a fundamental difference between
12451 (unformatted) input characters and (formatted) output glyphs.
12452 Everything that affects how a glyph is output is stored
12453 with the glyph node; once a glyph node has been constructed it is
12454 unaffected by any subsequent requests that are executed, including
12455 @code{bd}, @code{cs}, @code{tkf}, @code{tr}, or @code{fp} requests.
12456 Normally glyphs are constructed from input characters at the
12457 moment immediately before the glyph is added to the current output
12458 line.  Macros, diversions and strings are all, in fact, the same type of
12459 object; they contain lists of input characters and glyph nodes in
12460 any combination.  A glyph node does not behave like an input
12461 character for the purposes of macro processing; it does not inherit any
12462 of the special properties that the input character from which it was
12463 constructed might have had.  For example,
12465 @Example
12466 .di x
12467 \\\\
12471 @endExample
12473 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
12474 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
12475 @cindex @code{\e}, incompatibilities with @acronym{AT&T} @code{troff}
12476 @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
12477 @cindex @code{\?}, incompatibilities with @acronym{AT&T} @code{troff}
12478 @cindex transparent output, incompatibilities with @acronym{AT&T} @code{troff}
12479 @cindex output, transparent, incompatibilities with @acronym{AT&T} @code{troff}
12480 @noindent
12481 prints @samp{\\} in GNU @code{troff}; each pair of input backslashes
12482 is turned into one output backslash and the resulting output backslashes
12483 are not interpreted as escape characters when they are reread.
12484 @acronym{UNIX} @code{troff} would interpret them as escape characters
12485 when they were reread and would end up printing one @samp{\}.  The
12486 correct way to obtain a printable backslash is to use the @code{\e}
12487 escape sequence: This always prints a single instance of the current
12488 escape character, regardless of whether or not it is used in a
12489 diversion; it also works in both GNU @code{troff} and @acronym{UNIX}
12490 @code{troff}.@footnote{To be completely independent of the current
12491 escape character, use @code{\(rs} which represents a reverse solidus
12492 (backslash) glyph.}  To store, for some reason, an escape sequence in a
12493 diversion that will be interpreted when the diversion is reread, either
12494 use the traditional @code{\!} transparent output facility, or, if this
12495 is unsuitable, the new @code{\?} escape sequence.
12497 @xref{Diversions}, and @ref{Gtroff Internals}, for more information.
12501 @c =====================================================================
12502 @c =====================================================================
12504 @node Preprocessors, Output Devices, gtroff Reference, Top
12505 @chapter Preprocessors
12506 @cindex preprocessors
12508 This chapter describes all preprocessors that come with @code{groff} or
12509 which are freely available.
12511 @menu
12512 * geqn::
12513 * gtbl::
12514 * gpic::
12515 * ggrn::
12516 * grap::
12517 * grefer::
12518 * gsoelim::
12519 @end menu
12522 @c =====================================================================
12524 @node geqn, gtbl, Preprocessors, Preprocessors
12525 @section @code{geqn}
12526 @cindex @code{eqn}, the program
12527 @cindex @code{geqn}, the program
12529 @c XXX
12531 @menu
12532 * Invoking geqn::
12533 @end menu
12535 @c ---------------------------------------------------------------------
12537 @node Invoking geqn,  , geqn, geqn
12538 @subsection Invoking @code{geqn}
12539 @cindex invoking @code{geqn}
12540 @cindex @code{geqn}, invoking
12542 @c XXX
12545 @c =====================================================================
12547 @node gtbl, gpic, geqn, Preprocessors
12548 @section @code{gtbl}
12549 @cindex @code{tbl}, the program
12550 @cindex @code{gtbl}, the program
12552 @c XXX
12554 @menu
12555 * Invoking gtbl::
12556 @end menu
12558 @c ---------------------------------------------------------------------
12560 @node Invoking gtbl,  , gtbl, gtbl
12561 @subsection Invoking @code{gtbl}
12562 @cindex invoking @code{gtbl}
12563 @cindex @code{gtbl}, invoking
12565 @c XXX
12568 @c =====================================================================
12570 @node gpic, ggrn, gtbl, Preprocessors
12571 @section @code{gpic}
12572 @cindex @code{pic}, the program
12573 @cindex @code{gpic}, the program
12575 @c XXX
12577 @menu
12578 * Invoking gpic::
12579 @end menu
12581 @c ---------------------------------------------------------------------
12583 @node Invoking gpic,  , gpic, gpic
12584 @subsection Invoking @code{gpic}
12585 @cindex invoking @code{gpic}
12586 @cindex @code{gpic}, invoking
12588 @c XXX
12591 @c =====================================================================
12593 @node ggrn, grap, gpic, Preprocessors
12594 @section @code{ggrn}
12595 @cindex @code{grn}, the program
12596 @cindex @code{ggrn}, the program
12598 @c XXX
12600 @menu
12601 * Invoking ggrn::
12602 @end menu
12604 @c ---------------------------------------------------------------------
12606 @node Invoking ggrn,  , ggrn, ggrn
12607 @subsection Invoking @code{ggrn}
12608 @cindex invoking @code{ggrn}
12609 @cindex @code{ggrn}, invoking
12611 @c XXX
12614 @c =====================================================================
12616 @node grap, grefer, ggrn, Preprocessors
12617 @section @code{grap}
12618 @cindex @code{grap}, the program
12620 A free implementation of @code{grap}, written by Ted Faber,
12621 is available as an extra package from the following address:
12623 @display
12624 @url{http://www.lunabase.org/~faber/Vault/software/grap/}
12625 @end display
12628 @c =====================================================================
12630 @node grefer, gsoelim, grap, Preprocessors
12631 @section @code{grefer}
12632 @cindex @code{refer}, the program
12633 @cindex @code{grefer}, the program
12635 @c XXX
12637 @menu
12638 * Invoking grefer::
12639 @end menu
12641 @c ---------------------------------------------------------------------
12643 @node Invoking grefer,  , grefer, grefer
12644 @subsection Invoking @code{grefer}
12645 @cindex invoking @code{grefer}
12646 @cindex @code{grefer}, invoking
12648 @c XXX
12651 @c =====================================================================
12653 @node gsoelim,  , grefer, Preprocessors
12654 @section @code{gsoelim}
12655 @cindex @code{soelim}, the program
12656 @cindex @code{gsoelim}, the program
12658 @c XXX
12660 @menu
12661 * Invoking gsoelim::
12662 @end menu
12664 @c ---------------------------------------------------------------------
12666 @node Invoking gsoelim,  , gsoelim, gsoelim
12667 @subsection Invoking @code{gsoelim}
12668 @cindex invoking @code{gsoelim}
12669 @cindex @code{gsoelim}, invoking
12671 @c XXX
12675 @c =====================================================================
12676 @c =====================================================================
12678 @node Output Devices, File formats, Preprocessors, Top
12679 @chapter Output Devices
12680 @cindex output devices
12681 @cindex devices for output
12683 @c XXX
12685 @menu
12686 * Special Characters::
12687 * grotty::
12688 * grops::
12689 * grodvi::
12690 * grolj4::
12691 * grolbp::
12692 * grohtml::
12693 * gxditview::
12694 @end menu
12697 @c =====================================================================
12699 @node Special Characters, grotty, Output Devices, Output Devices
12700 @section Special Characters
12701 @cindex special characters
12702 @cindex characters, special
12704 @c XXX
12706 @xref{Font Files}.
12709 @c =====================================================================
12711 @node grotty, grops, Special Characters, Output Devices
12712 @section @code{grotty}
12713 @cindex @code{grotty}, the program
12715 @c XXX
12717 @menu
12718 * Invoking grotty::
12719 @end menu
12721 @c ---------------------------------------------------------------------
12723 @node Invoking grotty,  , grotty, grotty
12724 @subsection Invoking @code{grotty}
12725 @cindex invoking @code{grotty}
12726 @cindex @code{grotty}, invoking
12728 @c XXX
12730 @c The following is no longer true; fix and extend it.
12732 @c @pindex less
12733 @c @cindex Teletype
12734 @c @cindex ISO 6249 SGR
12735 @c @cindex terminal control sequences
12736 @c @cindex control sequences, for terminals
12737 @c For TTY output devices, underlining is done by emitting sequences of
12738 @c @samp{_} and @samp{\b} (the backspace character) before the actual
12739 @c character.  Literally, this is printing an underline character, then
12740 @c moving back one character position, and printing the actual character
12741 @c at the same position as the underline character (similar to a
12742 @c typewriter).  Usually, a modern terminal can't interpret this (and the
12743 @c original Teletype machines for which this sequence was appropriate are
12744 @c no longer in use).  You need a pager program like @code{less} which
12745 @c translates this into ISO 6429 SGR sequences to control terminals.
12748 @c =====================================================================
12750 @node grops, grodvi, grotty, Output Devices
12751 @section @code{grops}
12752 @cindex @code{grops}, the program
12754 @c XXX
12756 @menu
12757 * Invoking grops::
12758 * Embedding PostScript::
12759 @end menu
12761 @c ---------------------------------------------------------------------
12763 @node Invoking grops, Embedding PostScript, grops, grops
12764 @subsection Invoking @code{grops}
12765 @cindex invoking @code{grops}
12766 @cindex @code{grops}, invoking
12768 @c XXX
12770 @c ---------------------------------------------------------------------
12772 @node Embedding PostScript,  , Invoking grops, grops
12773 @subsection Embedding @sc{PostScript}
12774 @cindex embedding PostScript
12775 @cindex PostScript, embedding
12777 @c XXX
12780 @c =====================================================================
12782 @node grodvi, grolj4, grops, Output Devices
12783 @section @code{grodvi}
12784 @cindex @code{grodvi}, the program
12786 @c XXX
12788 @menu
12789 * Invoking grodvi::
12790 @end menu
12792 @c ---------------------------------------------------------------------
12794 @node Invoking grodvi,  , grodvi, grodvi
12795 @subsection Invoking @code{grodvi}
12796 @cindex invoking @code{grodvi}
12797 @cindex @code{grodvi}, invoking
12799 @c XXX
12802 @c =====================================================================
12804 @node grolj4, grolbp, grodvi, Output Devices
12805 @section @code{grolj4}
12806 @cindex @code{grolj4}, the program
12808 @c XXX
12810 @menu
12811 * Invoking grolj4::
12812 @end menu
12814 @c ---------------------------------------------------------------------
12816 @node Invoking grolj4,  , grolj4, grolj4
12817 @subsection Invoking @code{grolj4}
12818 @cindex invoking @code{grolj4}
12819 @cindex @code{grolj4}, invoking
12821 @c XXX
12824 @c =====================================================================
12826 @node grolbp, grohtml, grolj4, Output Devices
12827 @section @code{grolbp}
12828 @cindex @code{grolbp}, the program
12830 @c XXX
12832 @menu
12833 * Invoking grolbp::
12834 @end menu
12836 @c ---------------------------------------------------------------------
12838 @node Invoking grolbp,  , grolbp, grolbp
12839 @subsection Invoking @code{grolbp}
12840 @cindex invoking @code{grolbp}
12841 @cindex @code{grolbp}, invoking
12843 @c XXX
12846 @c =====================================================================
12848 @node grohtml, gxditview, grolbp, Output Devices
12849 @section @code{grohtml}
12850 @cindex @code{grohtml}, the program
12852 @c XXX
12854 @menu
12855 * Invoking grohtml::
12856 * grohtml specific registers and strings::
12857 @end menu
12859 @c ---------------------------------------------------------------------
12861 @node Invoking grohtml, grohtml specific registers and strings, grohtml, grohtml
12862 @subsection Invoking @code{grohtml}
12863 @cindex invoking @code{grohtml}
12864 @cindex @code{grohtml}, invoking
12866 @c XXX
12868 @c ---------------------------------------------------------------------
12870 @node grohtml specific registers and strings,  , Invoking grohtml, grohtml
12871 @subsection @code{grohtml} specific registers and strings
12872 @cindex registers specific to @code{grohtml}
12873 @cindex strings specific to @code{grohtml}
12874 @cindex @code{grohtml}, registers and strings
12876 @DefmpregList {ps4html, grohtml}
12877 @DefstrListEnd {www-image-template, grohtml}
12878 The registers @code{ps4html} and @code{www-image-template} are defined
12879 by the @code{pre-grohtml} preprocessor.  @code{pre-grohtml} reads in
12880 the @code{troff} input, marks up the inline equations and passes the
12881 result firstly to
12883 @Example
12884 troff -Tps -rps4html=1 -dwww-image-template=@var{template}
12885 @endExample
12887 @noindent
12888 and secondly to
12890 @Example
12891 troff -Thtml
12892 @endExample
12894 The PostScript device is used to create all the image files, and the
12895 register @code{ps4html} enables the macro sets to ignore floating
12896 keeps, footers, and headings.
12898 The register @code{www-image-template} is set to the user specified
12899 template name or the default name.
12900 @endDefmpreg
12903 @c =====================================================================
12905 @node gxditview,  , grohtml, Output Devices
12906 @section @code{gxditview}
12907 @cindex @code{gxditview}, the program
12909 @c XXX
12911 @menu
12912 * Invoking gxditview::
12913 @end menu
12915 @c ---------------------------------------------------------------------
12917 @node Invoking gxditview,  , gxditview, gxditview
12918 @subsection Invoking @code{gxditview}
12919 @cindex invoking @code{gxditview}
12920 @cindex @code{gxditview}, invoking
12922 @c XXX
12923 @c X11's xditview
12927 @c =====================================================================
12928 @c =====================================================================
12930 @node File formats, Installation, Output Devices, Top
12931 @chapter File formats
12932 @cindex file formats
12933 @cindex formats, file
12935 All files read and written by @code{gtroff} are text files.  The
12936 following two sections describe their format.
12938 @menu
12939 * gtroff Output::
12940 * Font Files::
12941 @end menu
12944 @c =====================================================================
12946 @node gtroff Output, Font Files, File formats, File formats
12947 @section @code{gtroff} Output
12948 @cindex @code{gtroff}, output
12949 @cindex output, @code{gtroff}
12951 This section describes the intermediate output format of GNU
12952 @code{troff}.  This output is produced by a run of @code{gtroff}
12953 before it is fed into a device postprocessor program.
12955 As @code{groff} is a wrapper program around @code{gtroff} that
12956 automatically calls a postprocessor, this output does not show up
12957 normally.  This is why it is called @dfn{intermediate}.
12958 @code{groff} provides the option @option{-Z} to inhibit postprocessing,
12959 such that the produced intermediate output is sent to standard output
12960 just like calling @code{gtroff} manually.
12962 @cindex troff output
12963 @cindex output, troff
12964 @cindex intermediate output
12965 @cindex output, intermediate
12966 Here, the term @dfn{troff output} describes what is output by
12967 @code{gtroff}, while @dfn{intermediate output} refers to the language
12968 that is accepted by the parser that prepares this output for the
12969 postprocessors.  This parser is smarter on whitespace and implements
12970 obsolete elements for compatibility, otherwise both formats are the
12971 same.@footnote{The parser and postprocessor for intermediate output
12972 can be found in the file@*
12973 @file{@var{groff-source-dir}/src/libs/libdriver/input.cc}.}
12975 The main purpose of the intermediate output concept is to facilitate
12976 the development of postprocessors by providing a common programming
12977 interface for all devices.  It has a language of its own that is
12978 completely different from the @code{gtroff} language.  While the
12979 @code{gtroff} language is a high-level programming language for text
12980 processing, the intermediate output language is a kind of low-level
12981 assembler language by specifying all positions on the page for writing
12982 and drawing.
12984 The intermediate output produced by @code{gtroff} is fairly readable,
12985 while output from @acronym{AT&T} @code{troff} is rather hard to
12986 understand because of strange habits that are still supported, but not
12987 used any longer by @code{gtroff}.
12989 @menu
12990 * Language Concepts::
12991 * Command Reference::
12992 * Intermediate Output Examples::
12993 * Output Language Compatibility::
12994 @end menu
12996 @c ---------------------------------------------------------------------
12998 @node Language Concepts, Command Reference, gtroff Output, gtroff Output
12999 @subsection Language Concepts
13001 During the run of @code{gtroff}, the input data is cracked down to the
13002 information on what has to be printed at what position on the intended
13003 device.  So the language of the intermediate output format can be quite
13004 small.  Its only elements are commands with and without arguments.
13005 In this section, the term @dfn{command} always refers to the intermediate
13006 output language, and never to the @code{gtroff} language used for document
13007 formatting.  There are commands for positioning and text writing, for drawing, and
13008 for device controlling.
13010 @menu
13011 * Separation::
13012 * Argument Units::
13013 * Document Parts::
13014 @end menu
13016 @node Separation, Argument Units, Language Concepts, Language Concepts
13017 @subsubsection Separation
13019 @acronym{AT&T} @code{troff} output has strange requirements on whitespace.
13020 The @code{gtroff} output parser, however, is smart about whitespace by
13021 making it maximally optional.  The whitespace characters, i.e., the
13022 tab, space, and newline characters, always have a syntactical meaning.
13023 They are never printable because spacing within the output is always
13024 done by positioning commands.
13026 Any sequence of space or tab characters is treated as a single
13027 @dfn{syntactical space}.  It separates commands and arguments, but is
13028 only required when there would occur a clashing between the command code
13029 and the arguments without the space.  Most often, this happens when
13030 variable-length command names, arguments, argument lists, or command
13031 clusters meet.  Commands and arguments with a known, fixed length need
13032 not be separated by syntactical space.
13034 A line break is a syntactical element, too.  Every command argument can be
13035 followed by whitespace, a comment, or a newline character.  Thus a
13036 @dfn{syntactical line break} is defined to consist of optional
13037 syntactical space that is optionally followed by a comment, and a
13038 newline character.
13040 The normal commands, those for positioning and text, consist of a
13041 single letter taking a fixed number of arguments.  For historical reasons,
13042 the parser allows to stack such commands on the same line, but
13043 fortunately, in @code{gtroff}'s intermediate output, every command with
13044 at least one argument is followed by a line break, thus providing
13045 excellent readability.
13047 The other commands -- those for drawing and device controlling --
13048 have a more complicated structure; some recognize long command names,
13049 and some take a variable number of arguments.  So all @samp{D} and
13050 @samp{x} commands were designed to request a syntactical line break
13051 after their last argument.  Only one command, @w{@samp{x X}},
13052 has an argument that can stretch over several lines; all other
13053 commands must have all of their arguments on the same line as the
13054 command, i.e., the arguments may not be splitted by a line break.
13056 Empty lines (these are lines containing only space and/or a comment), can
13057 occur everywhere.  They are just ignored.
13059 @node Argument Units, Document Parts, Separation, Language Concepts
13060 @subsubsection Argument Units
13062 Some commands take integer arguments that are assumed to represent
13063 values in a measurement unit, but the letter for the corresponding
13064 scale indicator is not written with the output command arguments.
13065 Most commands assume the scale indicator @samp{u}, the basic unit of
13066 the device, some use @samp{z}, the scaled point unit of the device,
13067 while others, such as the color commands, expect plain integers.
13069 Note that single characters can have the eighth bit set, as can the
13070 names of fonts and special characters.  The names of characters and
13071 fonts can be of arbitrary length.  A character that is to be printed
13072 will always be in the current font.
13074 A string argument is always terminated by the next whitespace
13075 character (space, tab, or newline); an embedded @samp{#} character is
13076 regarded as part of the argument, not as the beginning of a comment
13077 command.  An integer argument is already terminated by the next
13078 non-digit character, which then is regarded as the first character of
13079 the next argument or command.
13081 @node Document Parts,  , Argument Units, Language Concepts
13082 @subsubsection Document Parts
13084 A correct intermediate output document consists of two parts, the
13085 @dfn{prologue} and the @dfn{body}.
13087 The task of the prologue is to set the general device parameters
13088 using three exactly specified commands.  @code{gtroff}'s prologue
13089 is guaranteed to consist of the following three lines (in that order):
13091 @Example
13092 x T @var{device}
13093 x res @var{n} @var{h} @var{v}
13094 x init
13095 @endExample
13097 @noindent
13098 with the arguments set as outlined in @ref{Device Control Commands}.
13099 Note that the parser for the intermediate output format is able to
13100 swallow additional whitespace and comments as well even in the
13101 prologue.
13103 The body is the main section for processing the document data.
13104 Syntactically, it is a sequence of any commands different from the
13105 ones used in the prologue.  Processing is terminated as soon as the
13106 first @w{@samp{x stop}} command is encountered; the last line of any
13107 @code{gtroff} intermediate output always contains such a command.
13109 Semantically, the body is page oriented.  A new page is started by a
13110 @samp{p} command.  Positioning, writing, and drawing commands are
13111 always done within the current page, so they cannot occur before the
13112 first @samp{p} command.  Absolute positioning (by the @samp{H} and
13113 @samp{V} commands) is done relative to the current page; all other
13114 positioning is done relative to the current location within this page.
13116 @c ---------------------------------------------------------------------
13118 @node Command Reference, Intermediate Output Examples, Language Concepts, gtroff Output
13119 @subsection Command Reference
13121 This section describes all intermediate output commands, both from
13122 @acronym{AT&T} @code{troff} as well as the @code{gtroff} extensions.
13124 @menu
13125 * Comment Command::
13126 * Simple Commands::
13127 * Graphics Commands::
13128 * Device Control Commands::
13129 * Obsolete Command::
13130 @end menu
13132 @node Comment Command, Simple Commands, Command Reference, Command Reference
13133 @subsubsection Comment Command
13135 @table @code
13136 @item #@var{anything}@angles{end of line}
13137 A comment.  Ignore any characters from the @samp{#} character up to
13138 the next newline character.
13140 This command is the only possibility for commenting in the intermediate
13141 output.  Each comment can be preceded by arbitrary syntactical space;
13142 every command can be terminated by a comment.
13143 @end table
13145 @node Simple Commands, Graphics Commands, Comment Command, Command Reference
13146 @subsubsection Simple Commands
13148 The commands in this subsection have a command code consisting of a
13149 single character, taking a fixed number of arguments.  Most of them
13150 are commands for positioning and text writing.  These commands are
13151 smart about whitespace.  Optionally, syntactical space can be inserted
13152 before, after, and between the command letter and its arguments.
13153 All of these commands are stackable, i.e., they can be preceded by
13154 other simple commands or followed by arbitrary other commands on the
13155 same line.  A separating syntactical space is only necessary when two
13156 integer arguments would clash or if the preceding argument ends with a
13157 string argument.
13159 @table @code
13160 @ignore
13161 .if (\n[@USE_ENV_STACK] == 1) \{\
13162 .command {
13163 Open a new environment by copying the actual device configuration data
13164 to the environment stack.
13166 The current environment is setup by the device specification and
13167 manipulated by the setting commands.
13170 .command }
13171 Close the actual environment (opened by a preceding
13172 .BR { \~command)
13173 and restore the previous environment from the environment
13174 stack as the actual device configuration data.
13176 \}              \" endif @USE_ENV_STACK
13177 @end ignore
13179 @item C @var{xxx}@angles{whitespace}
13180 Print a special character named @var{xxx}.  The trailing
13181 syntactical space or line break is necessary to allow glyph names
13182 of arbitrary length.  The glyph is printed at the current print
13183 position; the glyph's size is read from the font file.  The print
13184 position is not changed.
13186 @item c @var{g}
13187 Print glyph@w{ }@var{g} at the current print position;@footnote{@samp{c}
13188 is actually a misnomer since it outputs a glyph.} the glyph's size is
13189 read from the font file.  The print position is not changed.
13191 @item f @var{n}
13192 Set font to font number@w{ }@var{n} (a non-negative integer).
13194 @item H @var{n}
13195 Move right to the absolute vertical position@w{ }@var{n} (a
13196 non-negative integer in basic units @samp{u} relative to left edge
13197 of current page.
13199 @item h @var{n}
13200 Move @var{n} (a non-negative integer) basic units @samp{u} horizontally
13201 to the right.  The original @acronym{UNIX} troff manual allows negative
13202 values for @var{n} also, but @code{gtroff} doesn't use this.
13204 @item m @var{color-scheme} @r{[}@var{component} @dots{}@r{]}
13205 Set the color for text (glyphs), line drawing, and the outline of
13206 graphic objects using different color schemes; the analoguous command
13207 for the filling color of graphic objects is @samp{DF}.  The color
13208 components are specified as integer arguments between 0 and 65536.
13209 The number of color components and their meaning vary for the
13210 different color schemes.  These commands are generated by
13211 @code{gtroff}'s escape sequence @code{\m}.  No position changing.
13212 These commands are a @code{gtroff} extension.
13214 @table @code
13215 @item mc @var{cyan} @var{magenta} @var{yellow}
13216 Set color using the CMY color scheme, having the 3@w{ }color components
13217 @var{cyan}, @var{magenta}, and @var{yellow}.
13219 @item md
13220 Set color to the default color value (black in most cases).
13221 No component arguments.
13223 @item mg @var{gray}
13224 Set color to the shade of gray given by the argument, an integer
13225 between 0 (black) and 65536 (white).
13227 @item mk @var{cyan} @var{magenta} @var{yellow} @var{black}
13228 Set color using the CMYK color scheme, having the 4@w{ }color components
13229 @var{cyan}, @var{magenta}, @var{yellow}, and @var{black}.
13231 @item mr @var{red} @var{green} @var{blue}
13232 Set color using the RGB color scheme, having the 3@w{ }color components
13233 @var{red}, @var{green}, and @var{blue}.
13235 @end table
13237 @item N @var{n}
13238 Print glyph with index@w{ }@var{n} (a non-negative integer) of the
13239 current font.  This command is a @code{gtroff} extension.
13241 @item n @var{b} @var{a}
13242 Inform the device about a line break, but no positioning is done by
13243 this command.  In @acronym{AT&T} @code{troff}, the integer arguments
13244 @var{b} and@w{ }@var{a} informed about the space before and after the
13245 current line to make the intermediate output more human readable
13246 without performing any action.  In groff, they are just ignored, but
13247 they must be provided for compatibility reasons.
13249 @item p @var{n}
13250 Begin a new page in the outprint.  The page number is set
13251 to@w{ }@var{n}.  This page is completely independent of pages formerly
13252 processed even if those have the same page number.  The vertical
13253 position on the outprint is automatically set to@w{ }0.  All
13254 positioning, writing, and drawing is always done relative to a page,
13255 so a @samp{p} command must be issued before any of these commands.
13257 @item s @var{n}
13258 Set point size to @var{n}@w{ }scaled points (this is unit @samp{z}).
13259 @acronym{AT&T} @code{troff} used the unit points (@samp{p}) instead.
13260 @xref{Output Language Compatibility}.
13262 @item t @var{xxx}@angles{whitespace}
13263 @itemx t @var{xxx} @var{dummy-arg}@angles{whitespace}
13264 Print a word, i.e., a sequence of characters @var{xxx} representing
13265 output glyphs which names are single characters, terminated by
13266 a space character or a line break; an optional second integer argument
13267 is ignored (this allows the formatter to generate an even number of
13268 arguments).  The first glyph should be printed at the current
13269 position, the current horizontal position should then be increased by
13270 the width of the first glyph, and so on for each glyph.
13271 The widths of the glyphs are read from the font file, scaled for the
13272 current point size, and rounded to a multiple of the horizontal
13273 resolution.  Special characters cannot be printed using this command
13274 (use the @samp{C} command for special characters).  This command is a
13275 @code{gtroff} extension; it is only used for devices whose @file{DESC}
13276 file contains the @code{tcommand} keyword (@pxref{DESC File Format}).
13278 @item u @var{n} @var{xxx}@angles{whitespace}
13279 Print word with track kerning.  This is the same as the @samp{t}
13280 command except that after printing each glyph, the current
13281 horizontal position is increased by the sum of the width of that
13282 glyph and@w{ }@var{n} (an integer in basic units @samp{u}).
13283 This command is a @code{gtroff} extension; it is only used for devices
13284 whose @file{DESC} file contains the @code{tcommand} keyword
13285 (@pxref{DESC File Format}).
13287 @item V @var{n}
13288 Move down to the absolute vertical position@w{ }@var{n} (a
13289 non-negative integer in basic units @samp{u}) relative to upper edge
13290 of current page.
13292 @item v @var{n}
13293 Move @var{n}@w{ }basic units @samp{u} down (@var{n} is a non-negative
13294 integer).  The original @acronym{UNIX} troff manual allows negative
13295 values for @var{n} also, but @code{gtroff} doesn't use this.
13297 @item w
13298 Informs about a paddable white space to increase readability.
13299 The spacing itself must be performed explicitly by a move command.
13301 @end table
13303 @node Graphics Commands, Device Control Commands, Simple Commands, Command Reference
13304 @subsubsection Graphics Commands
13306 Each graphics or drawing command in the intermediate output starts
13307 with the letter @samp{D}, followed by one or two characters that
13308 specify a subcommand; this is followed by a fixed or variable number
13309 of integer arguments that are separated by a single space character.
13310 A @samp{D} command may not be followed by another command on the same line
13311 (apart from a comment), so each @samp{D} command is terminated by a
13312 syntactical line break.
13314 @code{gtroff} output follows the classical spacing rules (no space
13315 between command and subcommand, all arguments are preceded by a
13316 single space character), but the parser allows optional space between
13317 the command letters and makes the space before the first argument
13318 optional.  As usual, each space can be any sequence of tab and space
13319 characters.
13321 Some graphics commands can take a variable number of arguments.
13322 In this case, they are integers representing a size measured in basic
13323 units @samp{u}.  The arguments called @var{h1}, @var{h2}, @dots{},
13324 @var{hn} stand for horizontal distances where positive means right,
13325 negative left.  The arguments called @var{v1}, @var{v2}, @dots{},
13326 @var{vn} stand for vertical distances where positive means down,
13327 negative up.  All these distances are offsets relative to the current
13328 location.
13330 Unless indicated otherwise, each graphics command directly corresponds
13331 to a similar @code{gtroff} @code{\D} escape sequence.  @xref{Drawing
13332 Requests}.
13334 Unknown @samp{D} commands are assumed to be device-specific.
13335 Its arguments are parsed as strings; the whole information is then
13336 sent to the postprocessor.
13338 In the following command reference, the syntax element
13339 @angles{line break} means a syntactical line break as defined above.
13341 @table @code
13342 @item D~ @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
13343 Draw B-spline from current position to offset (@var{h1},@var{v1}),
13344 then to offset (@var{h2},@var{v2}), if given, etc.@: up to
13345 (@var{hn},@var{vn}).  This command takes a variable number of argument
13346 pairs; the current position is moved to the terminal point of the drawn
13347 curve.
13349 @item Da @var{h1} @var{v1} @var{h2} @var{v2}@angles{line break}
13350 Draw arc from current position to
13351 (@var{h1},@var{v1})@math{+}(@var{h2},@var{v2}) with center at
13352 (@var{h1},@var{v1}); then move the current position to the final point
13353 of the arc.
13355 @item DC @var{d}@angles{line break}
13356 @itemx DC @var{d} @var{dummy-arg}@angles{line break}
13357 Draw a solid circle using the current fill color with
13358 diameter@w{ }@var{d} (integer in basic units @samp{u}) with leftmost
13359 point at the current position; then move the current position to the
13360 rightmost point of the circle.  An optional second integer argument is
13361 ignored (this allows the formatter to generate an even number of
13362 arguments).  This command is a @code{gtroff} extension.
13364 @item Dc @var{d}@angles{line break}
13365 Draw circle line with diameter@w{ }@var{d} (integer in basic units
13366 @samp{u}) with leftmost point at the current position; then move the
13367 current position to the rightmost point of the circle.
13369 @item DE @var{h} @var{v}@angles{line break}
13370 Draw a solid ellipse in the current fill color with a horizontal
13371 diameter of@w{ }@var{h} and a vertical diameter of@w{ }@var{v} (both
13372 integers in basic units @samp{u}) with the leftmost point at the
13373 current position; then move to the rightmost point of the ellipse.
13374 This command is a @code{gtroff} extension.
13376 @item De @var{h} @var{v}@angles{line break}
13377 Draw an outlined ellipse with a horizontal diameter of@w{ }@var{h}
13378 and a vertical diameter of@w{ }@var{v} (both integers in basic units
13379 @samp{u}) with the leftmost point at current position; then move to
13380 the rightmost point of the ellipse.
13382 @item DF @var{color-scheme} @r{[}@var{component} @dots{}@r{]}@angles{line break}
13383 Set fill color for solid drawing objects using different color
13384 schemes; the analoguous command for setting the color of text, line
13385 graphics, and the outline of graphic objects is @samp{m}.
13386 The color components are specified as integer arguments between 0 and
13387 65536.  The number of color components and their meaning vary for the
13388 different color schemes.  These commands are generated by @code{gtroff}'s
13389 escape sequences @w{@code{\D'F @dots{}'}} and @code{\M} (with no other
13390 corresponding graphics commands).  No position changing.  This command
13391 is a @code{gtroff} extension.
13393 @table @code
13394 @item DFc @var{cyan} @var{magenta} @var{yellow}@angles{line break}
13395 Set fill color for solid drawing objects using the CMY color scheme,
13396 having the 3@w{ }color components @var{cyan}, @var{magenta}, and
13397 @var{yellow}.
13399 @item DFd@angles{line break}
13400 Set fill color for solid drawing objects to the default fill color value
13401 (black in most cases).  No component arguments.
13403 @item DFg @var{gray}@angles{line break}
13404 Set fill color for solid drawing objects to the shade of gray given by
13405 the argument, an integer between 0 (black) and 65536 (white).
13407 @item DFk @var{cyan} @var{magenta} @var{yellow} @var{black}@angles{line break}
13408 Set fill color for solid drawing objects using the CMYK color scheme,
13409 having the 4@w{ }color components @var{cyan}, @var{magenta}, @var{yellow},
13410 and @var{black}.
13412 @item DFr @var{red} @var{green} @var{blue}@angles{line break}
13413 Set fill color for solid drawing objects using the RGB color scheme,
13414 having the 3@w{ }color components @var{red}, @var{green}, and @var{blue}.
13416 @end table
13418 @item Df @var{n}@angles{line break}
13419 The argument@w{ }@var{n} must be an integer in the range @math{-32767}
13420 to 32767.
13422 @table @asis
13423 @item @math{0 @LE @var{n} @LE 1000}
13424 Set the color for filling solid drawing objects to a shade of gray,
13425 where 0 corresponds to solid white, 1000 (the default) to solid black,
13426 and values in between to intermediate shades of gray; this is
13427 obsoleted by command @samp{DFg}.
13429 @item @math{@var{n} @LT 0} or @math{@var{n} @LT 1000}
13430 Set the filling color to the color that is currently being used for
13431 the text and the outline, see command @samp{m}.  For example, the
13432 command sequence
13434 @Example
13435 mg 0 0 65536
13436 Df -1
13437 @endExample
13439 @noindent
13440 sets all colors to blue.
13442 @end table
13444 @noindent
13445 No position changing.  This command is a @code{gtroff} extension.
13447 @item Dl @var{h} @var{v}@angles{line break}
13448 Draw line from current position to offset (@var{h},@var{v}) (integers
13449 in basic units @samp{u}); then set current position to the end of the
13450 drawn line.
13452 @item Dp @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
13453 Draw a polygon line from current position to offset (@var{h1},@var{v1}),
13454 from there to offset (@var{h2},@var{v2}), etc.@: up to offset
13455 (@var{hn},@var{vn}), and from there back to the starting position.
13456 For historical reasons, the position is changed by adding the sum of
13457 all arguments with odd index to the actual horizontal position and the
13458 even ones to the vertical position.  Although this doesn't make sense
13459 it is kept for compatibility.
13460 @ignore
13461 As the polygon is closed, the end of drawing is the starting point, so
13462 the position doesn't change.
13463 @end ignore
13464 This command is a @code{gtroff} extension.
13466 @item Dp @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
13467 Draw a solid polygon in the current fill color rather than an outlined
13468 polygon, using the same arguments and positioning as the corresponding
13469 @samp{Dp} command.
13470 @ignore
13471 No position changing.
13472 @end ignore
13473 This command is a @code{gtroff} extension.
13475 @item Dt @var{n}@angles{line break}
13476 Set the current line thickness to@w{ }@var{n} (an integer in basic
13477 units @samp{u}) if @math{@var{n}>0}; if @math{@var{n}=0} select the
13478 smallest available line thickness; if @math{@var{n}<0} set the line
13479 thickness proportional to the point size (this is the default before
13480 the first @samp{Dt} command was specified).  For historical reasons,
13481 the horizontal position is changed by adding the argument to the actual
13482 horizontal position, while the vertical position is not changed.
13483 Although this doesn't make sense it is kept for compatibility.
13484 @ignore
13485 No position changing.
13486 @end ignore
13487 This command is a @code{gtroff} extension.
13489 @end table
13491 @node Device Control Commands, Obsolete Command, Graphics Commands, Command Reference
13492 @subsubsection Device Control Commands
13494 Each device control command starts with the letter @samp{x},
13495 followed by a space character (optional or arbitrary space or tab in
13496 @code{gtroff}) and a subcommand letter or word; each argument (if any)
13497 must be preceded by a syntactical space.  All @samp{x} commands are
13498 terminated by a syntactical line break; no device control command can
13499 be followed by another command on the same line (except a comment).
13501 The subcommand is basically a single letter, but to increase
13502 readability, it can be written as a word, i.e., an arbitrary sequence
13503 of characters terminated by the next tab, space, or newline character.
13504 All characters of the subcommand word but the first are simply ignored.
13505 For example, @code{gtroff} outputs the initialization command
13506 @w{@samp{x i}} as @w{@samp{x init}} and the resolution command
13507 @w{@samp{x r}} as @w{@samp{x res}}.
13509 In the following, the syntax element @angles{line break} means a
13510 syntactical line break (@pxref{Separation}).
13512 @table @code
13513 @item xF @var{name}@angles{line break}
13514 The @samp{F} stands for @var{Filename}.
13516 Use @var{name} as the intended name for the current file in error
13517 reports.  This is useful for remembering the original file name when
13518 @code{gtroff} uses an internal piping mechanism.  The input file is
13519 not changed by this command.  This command is a @code{gtroff} extension.
13521 @item xf @var{n} @var{s}@angles{line break}
13522 The @samp{f} stands for @var{font}.
13524 Mount font position@w{ }@var{n} (a non-negative integer) with font
13525 named@w{ }@var{s} (a text word).  @xref{Font Positions}.
13527 @item xH @var{n}@angles{line break}
13528 The @samp{H} stands for @var{Height}.
13530 Set glyph height to@w{ }@var{n} (a positive integer in scaled
13531 points @samp{z}).  @acronym{AT&T} @code{troff} uses the unit points
13532 (@samp{p}) instead.  @xref{Output Language Compatibility}.
13534 @item xi@angles{line break}
13535 The @samp{i} stands for @var{init}.
13537 Initialize device.  This is the third command of the prologue.
13539 @item xp@angles{line break}
13540 The @samp{p} stands for @var{pause}.
13542 Parsed but ignored.  The original @acronym{UNIX} troff manual writes
13544 @display
13545 pause device, can be restarted
13546 @end display
13548 @item xr @var{n} @var{h} @var{v}@angles{line break}
13549 The @samp{r} stands for @var{resolution}.
13551 Resolution is@w{ }@var{n}, while @var{h} is the minimal horizontal
13552 motion, and @var{v} the minimal vertical motion possible with this
13553 device; all arguments are positive integers in basic units @samp{u}
13554 per inch.  This is the second command of the prologue.
13556 @item xS @var{n}@angles{line break}
13557 The @samp{S} stands for @var{Slant}.
13559 Set slant to@w{ }@var{n} (an integer in basic units @samp{u}).
13561 @item xs@angles{line break}
13562 The @samp{s} stands for @var{stop}.
13564 Terminates the processing of the current file; issued as the last
13565 command of any intermediate troff output.
13567 @item xt@angles{line break}
13568 The @samp{t} stands for @var{trailer}.
13570 Generate trailer information, if any.  In @var{gtroff}, this is
13571 actually just ignored.
13573 @item xT @var{xxx}@angles{line break}
13574 The @samp{T} stands for @var{Typesetter}.
13576 Set name of device to word @var{xxx}, a sequence of characters ended
13577 by the next white space character.  The possible device names coincide
13578 with those from the groff @option{-T} option.  This is the first
13579 command of the prologue.
13581 @item xu @var{n}@angles{line break}
13582 The @samp{u} stands for @var{underline}.
13584 Configure underlining of spaces.  If @var{n} is@w{ }1, start
13585 underlining of spaces; if @var{n} is@w{ }0, stop underlining of spaces.
13586 This is needed for the @code{cu} request in nroff mode and is ignored
13587 otherwise.  This command is a @code{gtroff} extension.
13589 @item xX @var{anything}@angles{line break}
13590 The @samp{x} stands for @var{X-escape}.
13592 Send string @var{anything} uninterpreted to the device.  If the line
13593 following this command starts with a @samp{+} character this line is
13594 interpreted as a continuation line in the following sense.  The
13595 @samp{+} is ignored, but a newline character is sent instead to the
13596 device, the rest of the line is sent uninterpreted.  The same applies
13597 to all following lines until the first character of a line is not a
13598 @samp{+} character.  This command is generated by the @code{gtroff}
13599 escape sequence @code{\X}.  The line-continuing feature is a
13600 @code{gtroff} extension.
13602 @end table
13604 @node Obsolete Command,  , Device Control Commands, Command Reference
13605 @subsubsection Obsolete Command
13606 In @acronym{AT&T} @code{troff} output, the writing of a single
13607 glyph is mostly done by a very strange command that combines a
13608 horizontal move and a single character giving the glyph name.  It
13609 doesn't have a command code, but is represented by a 3-character
13610 argument consisting of exactly 2@w{ }digits and a character.
13612 @table @asis
13613 @item @var{dd}@var{g}
13614 Move right @var{dd} (exactly two decimal digits) basic units @samp{u},
13615 then print glyph@w{ }@var{g} (represented as a single character).
13617 In @code{gtroff}, arbitrary syntactical space around and within this
13618 command is allowed to be added.  Only when a preceding command on the
13619 same line ends with an argument of variable length a separating space
13620 is obligatory.  In @acronym{AT&T} @code{troff}, large clusters of these
13621 and other commands are used, mostly without spaces; this made such output
13622 almost unreadable.
13624 @end table
13626 For modern high-resolution devices, this command does not make sense
13627 because the width of the glyphs can become much larger than two
13628 decimal digits.  In @code{gtroff}, this is only used for the devices
13629 @code{X75}, @code{X75-12}, @code{X100}, and @code{X100-12}.  For other
13630 devices, the commands @samp{t} and @samp{u} provide a better
13631 functionality.
13633 @c ---------------------------------------------------------------------
13635 @node Intermediate Output Examples, Output Language Compatibility, Command Reference, gtroff Output
13636 @subsection Intermediate Output Examples
13638 This section presents the intermediate output generated from the same
13639 input for three different devices.  The input is the sentence
13640 @samp{hell world} fed into @code{gtroff} on the command line.
13642 @table @asis
13643 @item High-resolution device @code{ps}
13645 This is the standard output of @code{gtroff} if no @option{-T} option
13646 is given.
13648 @example
13649 @group
13650 shell> echo "hell world" | groff -Z -T ps
13652 x T ps
13653 x res 72000 1 1
13654 x init
13655 @end group
13657 x font 5 TR
13659 s10000
13660 V12000
13661 H72000
13662 thell
13663 wh2500
13665 H96620
13666 torld
13667 n12000 0
13668 @group
13669 x trailer
13670 V792000
13671 x stop
13672 @end group
13673 @end example
13675 @noindent
13676 This output can be fed into @code{grops} to get its representation as
13677 a PostScript file.
13679 @item Low-resolution device @code{latin1}
13681 This is similar to the high-resolution device except that the
13682 positioning is done at a minor scale.  Some comments (lines starting
13683 with @samp{#}) were added for clarification; they were not generated
13684 by the formatter.
13686 @example
13687 @group
13688 shell> echo "hell world" | groff -Z -T latin1
13690 # prologue
13691 x T latin1
13692 x res 240 24 40
13693 x init
13694 @end group
13695 # begin a new page
13697 # font setup
13698 x font 1 R
13701 # initial positioning on the page
13704 # write text `hell'
13705 thell
13706 # inform about space, and issue a horizontal jump
13707 wh24
13708 # write text `world'
13709 tworld
13710 # announce line break, but do nothing because ...
13711 n40 0
13712 @group
13713 # ... the end of the document has been reached
13714 x trailer
13715 V2640
13716 x stop
13717 @end group
13718 @end example
13720 @noindent
13721 This output can be fed into @code{grotty} to get a formatted text
13722 document.
13724 @item @acronym{AT&T} @code{troff} output
13725 Since a computer monitor has a very low resolution compared to modern
13726 printers the intermediate output for the X@w{ }Window devices can use
13727 the jump-and-write command with its 2-digit displacements.
13729 @example
13730 @group
13731 shell> echo "hell world" | groff -Z -T X100
13733 x T X100
13734 x res 100 1 1
13735 x init
13736 @end group
13738 x font 5 TR
13742 H100
13743 # write text with jump-and-write commands
13744 ch07e07l03lw06w11o07r05l03dh7
13745 n16 0
13746 @group
13747 x trailer
13748 V1100
13749 x stop
13750 @end group
13751 @end example
13753 @noindent
13754 This output can be fed into @code{xditview} or @code{gxditview}
13755 for displaying in@w{ }X.
13757 Due to the obsolete jump-and-write command, the text clusters in the
13758 @acronym{AT&T} @code{troff} output are almost unreadable.
13760 @end table
13762 @c ---------------------------------------------------------------------
13764 @node Output Language Compatibility,  , Intermediate Output Examples, gtroff Output
13765 @subsection Output Language Compatibility
13767 The intermediate output language of @acronym{AT&T} @code{troff}
13768 was first documented in the @acronym{UNIX} troff manual, with later
13769 additions documented in @cite{A Typesetter-indenpendent TROFF},
13770 written by Brian Kernighan.
13772 The @code{gtroff} intermediate output format is compatible with this
13773 specification except for the following features.
13775 @itemize @bullet
13776 @item
13777 The classical quasi device independence is not yet implemented.
13779 @item
13780 The old hardware was very different from what we use today.  So the
13781 @code{groff} devices are also fundamentally different from the ones in
13782 @acronym{AT&T} @code{troff}.  For example, the @acronym{AT&T}
13783 PostScript device is called @code{post} and has a resolution of only
13784 720 units per inch, suitable for printers 20 years ago, while
13785 @code{groff}'s @code{ps} device has a resolution of
13786 72000 units per inch.  Maybe, by implementing some rescaling
13787 mechanism similar to the classical quasi device independence,
13788 @code{groff} could emulate @acronym{AT&T}'s @code{post} device.
13790 @item
13791 The B-spline command @samp{D~} is correctly handled by the
13792 intermediate output parser, but the drawing routines aren't
13793 implemented in some of the postprocessor programs.
13795 @item
13796 The argument of the commands @samp{s} and @w{@samp{x H}} has the
13797 implicit unit scaled point @samp{z} in @code{gtroff}, while
13798 @acronym{AT&T} @code{troff} has point (@samp{p}).  This isn't an
13799 incompatibility but a compatible extension, for both units coincide
13800 for all devices without a @code{sizescale} parameter in the @file{DESC}
13801 file, including all postprocessors from @acronym{AT&T} and
13802 @code{groff}'s text devices.  The few @code{groff} devices with
13803 a @code{sizescale} parameter either do not exist for @acronym{AT&T}
13804 @code{troff}, have a different name, or seem to have a different
13805 resolution.  So conflicts are very unlikely.
13807 @item
13808 The position changing after the commands @samp{Dp}, @samp{DP}, and
13809 @samp{Dt} is illogical, but as old versions of @code{gtroff} used this
13810 feature it is kept for compatibility reasons.
13812 @ignore
13813 Temporarily, there existed some confusion on the positioning after the
13814 @samp{D} commands that are groff extensions.  This has been clarified
13815 by establishing the classical rule for all groff drawing commands:
13817 @itemize
13818 @item
13819 The position after a graphic object has been drawn is at its end;
13820 for circles and ellipses, the `end' is at the right side.
13822 @item
13823 From this, the positionings specified for the drawing commands above
13824 follow quite naturally.
13825 @end itemize
13826 @end ignore
13828 @end itemize
13831 @c =====================================================================
13833 @node Font Files,  , gtroff Output, File formats
13834 @section Font Files
13835 @cindex font files
13836 @cindex files, font
13838 The @code{gtroff} font format is roughly a superset of the
13839 @code{ditroff} font format (as used in later versions of @acronym{AT&T}
13840 @code{troff} and its descendants).  Unlike the @code{ditroff} font
13841 format, there is no associated binary format; all files are text
13842 files.@footnote{Plan@w{ }9 @code{troff} has also abandoned the binary
13843 format.}  The font files for device @var{name} are stored in a directory
13844 @file{dev@var{name}}.  There are two types of file: a device description
13845 file called @file{DESC} and for each font@w{ }@var{f} a font file
13846 called@w{ }@file{@var{f}}.
13848 @menu
13849 * DESC File Format::
13850 * Font File Format::
13851 @end menu
13853 @c ---------------------------------------------------------------------
13855 @node DESC File Format, Font File Format, Font Files, Font Files
13856 @subsection @file{DESC} File Format
13857 @cindex @file{DESC} file, format
13858 @cindex font description file, format
13859 @cindex format of font description file
13860 @pindex DESC@r{ file format}
13862 The @file{DESC} file can contain the following types of line.  Except
13863 for the @code{charset} keyword which must comes last (if at all), the
13864 order of the lines is not important.
13866 @table @code
13867 @item res @var{n}
13868 @kindex res
13869 There are @var{n}@w{ }machine units per inch.
13871 @item hor @var{n}
13872 @kindex hor
13873 The horizontal resolution is @var{n}@w{ }machine units.
13875 @item vert @var{n}
13876 @kindex vert
13877 The vertical resolution is @var{n}@w{ }machine units.
13879 @item sizescale @var{n}
13880 @kindex sizescale
13881 The scale factor for point sizes.  By default this has a value of@w{ }1.
13882 One scaled point is equal to one point/@var{n}.  The arguments to the
13883 @code{unitwidth} and @code{sizes} commands are given in scaled points.
13884 @xref{Fractional Type Sizes}, for more information.
13886 @item unitwidth @var{n}
13887 @kindex unitwidth
13888 Quantities in the font files are given in machine units for fonts whose
13889 point size is @var{n}@w{ }scaled points.
13891 @item prepro @var{program}
13892 @kindex prepro
13893 Call @var{program} as a preprocessor.  Currently, this keyword is used
13894 by @code{groff} with option @option{-Thtml} only.
13896 @item postpro @var{program}
13897 @kindex postpro
13898 Call @var{program} as a postprocessor.  For example, the line
13900 @Example
13901 postpro grodvi
13902 @endExample
13904 @noindent
13905 in the file @file{devdvi/DESC} makes @code{groff} call @code{grodvi}
13906 if option @option{-Tdvi} is given (and @option{-Z} isn't used).
13908 @item tcommand
13909 @kindex tcommand
13910 This means that the postprocessor can handle the @samp{t} and @samp{u}
13911 intermediate output commands.
13913 @item sizes @var{s1} @var{s2} @dots{} @var{sn} 0
13914 @kindex sizes
13915 This means that the device has fonts at @var{s1}, @var{s2}, @dots{}
13916 @var{sn} scaled points.  The list of sizes must be terminated by@w{ }0
13917 (this is digit zero).  Each @var{si} can also be a range of sizes
13918 @var{m}-@var{n}.  The list can extend over more than one line.
13920 @item styles @var{S1} @var{S2} @dots{} @var{Sm}
13921 @kindex styles
13922 The first @var{m}@w{ }font positions are associated with styles
13923 @var{S1} @dots{} @var{Sm}.
13925 @item fonts @var{n} @var{F1} @var{F2} @var{F3} @dots{} @var{Fn}
13926 @kindex fonts
13927 Fonts @var{F1} @dots{} @var{Fn} are mounted in the font positions
13928 @var{m}+1, @dots{}, @var{m}+@var{n} where @var{m} is the number of
13929 styles.  This command may extend over more than one line.  A font name
13930 of@w{ }0 means no font is mounted on the corresponding font position.
13932 @item family @var{fam}
13933 @kindex family
13934 The default font family is @var{fam}.
13936 @item use_charnames_in_special
13937 @kindex use_charnames_in_special
13938 This command indicates that @code{gtroff} should encode special
13939 characters inside special commands.  Currently, this is only used
13940 by the @acronym{HTML} output device.  @xref{Postprocessor Access}.
13942 @item pass_filenames
13943 @kindex pass_filenames
13944 Tell @code{gtroff} to emit the name of the source file currently
13945 being processed.  This is achieved by the intermediate output command
13946 @samp{F}.  Currently, this is only used by the @acronym{HTML} output
13947 device.
13949 @item print @var{program}
13950 @kindex print
13951 Use @var{program} as a spooler program for printing.  If omitted,
13952 the @option{-l} and @option{-L} options of @code{groff} are ignored.
13954 @item charset
13955 @kindex charset
13956 This line and everything following in the file are ignored.  It is
13957 allowed for the sake of backwards compatibility.
13958 @end table
13960 The @code{res}, @code{unitwidth}, @code{fonts}, and @code{sizes} lines
13961 are mandatory.  Other commands are ignored by @code{gtroff} but may be
13962 used by postprocessors to store arbitrary information about the device
13963 in the @file{DESC} file.
13965 @kindex spare1
13966 @kindex spare2
13967 @kindex biggestfont
13968 Here a list of obsolete keywords which are recognized by @code{groff}
13969 but completely ignored: @code{spare1}, @code{spare2},
13970 @code{biggestfont}.
13973 @c ---------------------------------------------------------------------
13975 @node Font File Format,  , DESC File Format, Font Files
13976 @subsection Font File Format
13977 @cindex font file, format
13978 @cindex font description file, format
13979 @cindex format of font files
13980 @cindex format of font description files
13982 A @dfn{font file}, also (and probably better) called a @dfn{font
13983 description file}, has two sections.  The first section is a sequence
13984 of lines each containing a sequence of blank delimited words; the first
13985 word in the line is a key, and subsequent words give a value for that
13986 key.
13988 @table @code
13989 @item name @var{f}
13990 @kindex name
13991 The name of the font is@w{ }@var{f}.
13993 @item spacewidth @var{n}
13994 @kindex spacewidth
13995 The normal width of a space is@w{ }@var{n}.
13997 @item slant @var{n}
13998 @kindex slant
13999 The glyphs of the font have a slant of @var{n}@w{ }degrees.
14000 (Positive means forward.)
14002 @item ligatures @var{lig1} @var{lig2} @dots{} @var{lign} [0]
14003 @kindex ligatures
14004 Glyphs @var{lig1}, @var{lig2}, @dots{}, @var{lign} are ligatures;
14005 possible ligatures are @samp{ff}, @samp{fi}, @samp{fl}, @samp{ffi} and
14006 @samp{ffl}.  For backwards compatibility, the list of ligatures may be
14007 terminated with a@w{ }0.  The list of ligatures may not extend over more
14008 than one line.
14010 @item special
14011 @cindex special fonts
14012 @kindex special
14013 The font is @dfn{special}; this means that when a glyph is requested
14014 that is not present in the current font, it is searched for in any
14015 special fonts that are mounted.
14016 @end table
14018 Other commands are ignored by @code{gtroff} but may be used by
14019 postprocessors to store arbitrary information about the font in the font
14020 file.
14022 @cindex comments in font files
14023 @cindex font files, comments
14024 @kindex #
14025 The first section can contain comments which start with the @samp{#}
14026 character and extend to the end of a line.
14028 The second section contains one or two subsections.  It must contain a
14029 @code{charset} subsection and it may also contain a @code{kernpairs}
14030 subsection.  These subsections can appear in any order.  Each
14031 subsection starts with a word on a line by itself.
14033 @kindex charset
14034 The word @code{charset} starts the character set
14035 subsection.@footnote{This keyword is misnamed since it starts a list
14036 of ordered glyphs, not characters.}  The @code{charset} line is
14037 followed by a sequence of lines.  Each line gives information for one
14038 glyph.  A line comprises a number of fields separated by blanks or
14039 tabs.  The format is
14041 @quotation
14042 @var{name} @var{metrics} @var{type} @var{code}
14043 [@var{entity-name}] [@code{--} @var{comment}]
14044 @end quotation
14046 @cindex 8-bit input
14047 @cindex input, 8-bit
14048 @cindex accessing unnamed glyphs with @code{\N}
14049 @cindex unnamed glyphs, accessing with @code{\N}
14050 @cindex characters, unnamed, accessing with @code{\N}
14051 @cindex glyphs, unnamed, accessing with @code{\N}
14052 @kindex ---
14053 @noindent
14054 @var{name} identifies the glyph name@footnote{The distinction between
14055 input, characters, and output, glyphs, is not clearly separated in the
14056 terminology of @code{groff}; for example, the @code{char} request
14057 should be called @code{glyph} since it defines an output entity.}:
14058 If @var{name} is a single character@w{ }@var{c} then it corresponds
14059 to the @code{gtroff} input character@w{ }@var{c}; if it is of the form
14060 @samp{\@var{c}} where @var{c} is a single character, then it
14061 corresponds to the special character @code{\[@var{c}]}; otherwise it
14062 corresponds to the special character @samp{\[@var{name}]}.  If it
14063 is exactly two characters @var{xx} it can be entered as
14064 @samp{\(@var{xx}}.  Note that single-letter special characters can't
14065 be accessed as @samp{\@var{c}}; the only exception is @samp{\-} which
14066 is identical to @code{\[-]}.
14068 @code{gtroff} supports 8-bit input characters; however some utilities
14069 have difficulties with eight-bit characters.  For this reason, there is
14070 a convention that the entity name @samp{char@var{n}} is equivalent to
14071 the single input character whose code is@w{ }@var{n}.  For example,
14072 @samp{char163} would be equivalent to the character with code@w{ }163
14073 which is the pounds sterling sign in the @w{ISO Latin-1} character set.
14074 You shouldn't use @samp{char@var{n}} entities in font description files
14075 since they are related to input, not output.  Otherwise, you get
14076 hard-coded connections between input and output encoding which
14077 prevents use of different (input) character sets.
14079 The name @samp{---} is special and indicates that the glyph is
14080 unnamed; such glyphs can only be used by means of the @code{\N}
14081 escape sequence in @code{gtroff}.
14083 The @var{type} field gives the glyph type:
14085 @table @code
14086 @item 1
14087 the glyph has a descender, for example, @samp{p};
14089 @item 2
14090 the glyph has an ascender, for example, @samp{b};
14092 @item 3
14093 the glyph has both an ascender and a descender, for example, @samp{(}.
14094 @end table
14096 The @var{code} field gives the code which the postprocessor uses to
14097 print the glyph.  The glyph can also be input to @code{gtroff}
14098 using this code by means of the @code{\N} escape sequence.  @var{code}
14099 can be any integer.  If it starts with @samp{0} it is interpreted as
14100 octal; if it starts with @samp{0x} or @samp{0X} it is interpreted as
14101 hexadecimal.
14103 The @var{entity-name} field gives an @acronym{ASCII} string
14104 identifying the glyph which the postprocessor uses to print the
14105 @code{gtroff} glyph @var{name}.  This field is optional and has been
14106 introduced so that the @acronym{HTML} device driver can encode its
14107 character set.  For example, the glyph @samp{\[Po]} is
14108 represented as @samp{&pound;} in @acronym{HTML} 4.0.
14110 Anything on the line after the @var{entity-name} field resp.@: after
14111 @samp{--} will be ignored.
14113 The @var{metrics} field has the form:
14115 @display
14116 @group
14117 @var{width}[@code{,}@var{height}[@code{,}@var{depth}[@code{,}@var{italic-correction}
14118   [@code{,}@var{left-italic-correction}[@code{,}@var{subscript-correction}]]]]]
14119 @end group
14120 @end display
14122 @noindent
14123 There must not be any spaces between these subfields (it has been split
14124 here into two lines for better legibility only).  Missing subfields are
14125 assumed to be@w{ }0.  The subfields are all decimal integers.  Since
14126 there is no associated binary format, these values are not required to
14127 fit into a variable of type @samp{char} as they are in @code{ditroff}.
14128 The @var{width} subfield gives the width of the glyph.  The @var{height}
14129 subfield gives the height of the glyph (upwards is positive); if a
14130 glyph does not extend above the baseline, it should be given a zero
14131 height, rather than a negative height.  The @var{depth} subfield gives
14132 the depth of the glyph, that is, the distance from the baseline to the
14133 lowest point below the baseline to which the glyph extends (downwards is
14134 positive); if a glyph does not extend below the baseline, it should be
14135 given a zero depth, rather than a negative depth.  The
14136 @var{italic-correction} subfield gives the amount of space that should
14137 be added after the glyph when it is immediately to be followed by a
14138 glyph from a roman font.  The @var{left-italic-correction} subfield
14139 gives the amount of space that should be added before the glyph when it
14140 is immediately to be preceded by a glyph from a roman font.  The
14141 @var{subscript-correction} gives the amount of space that should be
14142 added after a glyph before adding a subscript.  This should be less
14143 than the italic correction.
14145 A line in the @code{charset} section can also have the format
14147 @Example
14148 @var{name} "
14149 @endExample
14151 @noindent
14152 This indicates that @var{name} is just another name for the glyph
14153 mentioned in the preceding line.
14155 @kindex kernpairs
14156 The word @code{kernpairs} starts the kernpairs section.  This contains a
14157 sequence of lines of the form:
14159 @Example
14160 @var{c1} @var{c2} @var{n}
14161 @endExample
14163 @noindent
14164 This means that when glyph @var{c1} appears next to glyph @var{c2}
14165 the space between them should be increased by@w{ }@var{n}.  Most
14166 entries in the kernpairs section have a negative value for@w{ }@var{n}.
14170 @c =====================================================================
14171 @c =====================================================================
14173 @node Installation, Copying This Manual, File formats, Top
14174 @chapter Installation
14175 @cindex installation
14177 @c XXX
14181 @c =====================================================================
14182 @c =====================================================================
14184 @node Copying This Manual, Request Index, Installation, Top
14185 @appendix Copying This Manual
14187 @menu
14188 * GNU Free Documentation License::  License for copying this manual.
14189 @end menu
14191 @include fdl.texi
14195 @c =====================================================================
14196 @c =====================================================================
14198 @node Request Index, Escape Index, Copying This Manual, Top
14199 @appendix Request Index
14201 Requests appear without the leading control character (normally either
14202 @samp{.} or @samp{'}).
14204 @printindex rq
14208 @c =====================================================================
14209 @c =====================================================================
14211 @node Escape Index, Operator Index, Request Index, Top
14212 @appendix Escape Index
14214 Any escape sequence @code{\@var{X}} with @var{X} not in the list below
14215 emits a warning, printing glyph @var{X}.
14217 @printindex es
14221 @c =====================================================================
14222 @c =====================================================================
14224 @node Operator Index, Register Index, Escape Index, Top
14225 @appendix Operator Index
14227 @printindex op
14231 @c =====================================================================
14232 @c =====================================================================
14234 @node Register Index, Macro Index, Operator Index, Top
14235 @appendix Register Index
14237 The macro package or program a specific register belongs to is appended in
14238 brackets.
14240 A register name@w{ }@code{x} consisting of exactly one character can be
14241 accessed as @samp{\nx}.  A register name @code{xx} consisting of exactly
14242 two characters can be accessed as @samp{\n(xx}.  Register names @code{xxx}
14243 of any length can be accessed as @samp{\n[xxx]}.
14245 @printindex vr
14249 @c =====================================================================
14250 @c =====================================================================
14252 @node Macro Index, String Index, Register Index, Top
14253 @appendix Macro Index
14255 The macro package a specific macro belongs to is appended in brackets.
14256 They appear without the leading control character (normally @samp{.}).
14258 @printindex ma
14262 @c =====================================================================
14263 @c =====================================================================
14265 @node String Index, Glyph Name Index, Macro Index, Top
14266 @appendix String Index
14268 The macro package or program a specific string belongs to is appended in
14269 brackets.
14271 A string name@w{ }@code{x} consisting of exactly one character can be
14272 accessed as @samp{\*x}.  A string name @code{xx} consisting of exactly
14273 two characters can be accessed as @samp{\*(xx}.  String names @code{xxx}
14274 of any length can be accessed as @samp{\*[xxx]}.
14277 @printindex st
14281 @c =====================================================================
14282 @c =====================================================================
14284 @node Glyph Name Index, Font File Keyword Index, String Index, Top
14285 @appendix Glyph Name Index
14287 A glyph name @code{xx} consisting of exactly two characters can be
14288 accessed as @samp{\(xx}.  Glyph names @code{xxx} of any length can be
14289 accessed as @samp{\[xxx]}.
14291 @c XXX
14295 @c =====================================================================
14296 @c =====================================================================
14298 @node Font File Keyword Index, Program and File Index, Glyph Name Index, Top
14299 @appendix Font File Keyword Index
14301 @printindex ky
14305 @c =====================================================================
14306 @c =====================================================================
14308 @node Program and File Index, Concept Index, Font File Keyword Index, Top
14309 @appendix Program and File Index
14311 @printindex pg
14315 @c =====================================================================
14316 @c =====================================================================
14318 @node Concept Index,  , Program and File Index, Top
14319 @appendix Concept Index
14321 @printindex cp
14324 @bye