* MORE.STUFF: Added gpresent.
[s-roff.git] / doc / groff.texinfo
blob6dffc6316ba54d82ed61ce12679ccbdd3e7f5130
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.
775 Larry Kollar contributed the section in the @file{ms} macro package.
779 @c =====================================================================
780 @c =====================================================================
782 @node Invoking groff, Tutorial for Macro Users, Introduction, Top
783 @chapter Invoking @code{groff}
784 @cindex invoking @code{groff}
785 @cindex @code{groff} invocation
787 This section focuses on how to invoke the @code{groff} front end.  This
788 front end takes care of the details of constructing the pipeline among
789 the preprocessors, @code{gtroff} and the postprocessor.
791 It has become a tradition that GNU programs get the prefix @samp{g} to
792 distinguish it from its original counterparts provided by the host (see
793 @ref{Environment}, for more details).  Thus, for example, @code{geqn} is
794 GNU @code{eqn}.  On operating systems like GNU/Linux or the Hurd, which
795 don't contain proprietary versions of @code{troff}, and on
796 MS-DOS/MS-Windows, where @code{troff} and associated programs are not
797 available at all, this prefix is omitted since GNU @code{troff} is the
798 only used incarnation of @code{troff}.  Exception: @samp{groff} is never
799 replaced by @samp{roff}.
801 In this document, we consequently say @samp{gtroff} when talking about
802 the GNU @code{troff} program.  All other implementations of @code{troff}
803 are called @acronym{AT&T} @code{troff} which is the common origin of
804 all @code{troff} derivates (with more or less compatible changes).
805 Similarly, we say @samp{gpic}, @samp{geqn}, etc.
807 @menu
808 * Groff Options::
809 * Environment::
810 * Macro Directories::
811 * Invocation Examples::
812 @end menu
815 @c =====================================================================
817 @node Groff Options, Environment, Invoking groff, Invoking groff
818 @section Options
819 @cindex options
821 @pindex groff
822 @pindex gtroff
823 @pindex gpic
824 @pindex geqn
825 @pindex ggrn
826 @pindex grap
827 @pindex gtbl
828 @pindex grefer
829 @pindex gsoelim
830 @code{groff} normally runs the @code{gtroff} program and a postprocessor
831 appropriate for the selected device.  The default device is @samp{ps}
832 (but it can be changed when @code{groff} is configured and built).  It
833 can optionally preprocess with any of @code{gpic}, @code{geqn},
834 @code{gtbl}, @code{ggrn}, @code{grap}, @code{grefer}, or @code{gsoelim}.
836 This section only documents options to the @code{groff} front end.  Many
837 of the arguments to @code{groff} are passed on to @code{gtroff},
838 therefore those are also included.  Arguments to pre- or postprocessors
839 can be found in @ref{Invoking gpic}, @ref{Invoking geqn}, @ref{Invoking
840 gtbl}, @ref{Invoking ggrn}, @ref{Invoking grefer}, @ref{Invoking
841 gsoelim}, @ref{Invoking grotty}, @ref{Invoking grops}, @ref{Invoking
842 grohtml}, @ref{Invoking grodvi}, @ref{Invoking grolj4}, @ref{Invoking
843 grolbp}, and @ref{Invoking gxditview}.
845 The command line format for @code{groff} is:
847 @Example
848 groff [ -abceghilpstvzCEGNRSUVXZ ] [ -F@var{dir} ] [ -m@var{name} ]
849       [ -T@var{def} ] [ -f@var{fam} ] [ -w@var{name} ] [ -W@var{name} ]
850       [ -M@var{dir} ] [ -d@var{cs} ] [ -r@var{cn} ] [ -n@var{num} ]
851       [ -o@var{list} ] [ -P@var{arg} ] [ -L@var{arg} ] [ -I@var{dir} ]
852       [ @var{files}@dots{} ]
853 @endExample
855 The command line format for @code{gtroff} is as follows.
857 @Example
858 gtroff [ -abcivzCERU ] [ -w@var{name} ] [ -W@var{name} ] [ -d@var{cs} ]
859        [ -f@var{fam} ] [ -m@var{name} ] [ -n@var{num} ]
860        [ -o@var{list} ] [ -r@var{cn} ] [ -T@var{name} ]
861        [ -F@var{dir} ] [ -M@var{dir} ] [ @var{files}@dots{} ]
862 @endExample
864 @noindent
865 Obviously, many of the options to @code{groff} are actually passed on to
866 @code{gtroff}.
868 Options without an argument can be grouped behind a single@w{ }@option{-}.
869 A filename of@w{ }@file{-} denotes the standard input.  It is possible to
870 have whitespace between an option and its parameter.
872 The @code{grog} command can be used to guess the correct @code{groff}
873 command to format a file.
875 Here's the description of the command-line options:
877 @cindex command-line options
878 @table @samp
879 @item -h
880 Print a help message.
882 @item -e
883 Preprocess with @code{geqn}.
885 @item -t
886 Preprocess with @code{gtbl}.
888 @item -g
889 Preprocess with @code{ggrn}.
891 @item -G
892 Preprocess with @code{grap}.
894 @item -p
895 Preprocess with @code{gpic}.
897 @item -s
898 Preprocess with @code{gsoelim}.
900 @item -c
901 Suppress color output.
903 @item -R
904 Preprocess with @code{grefer}.  No mechanism is provided for passing
905 arguments to @code{grefer} because most @code{grefer} options have
906 equivalent commands which can be included in the file.  @xref{grefer},
907 for more details.
909 @pindex troffrc
910 @pindex troffrc-end
911 Note that @code{gtroff} also accepts a @option{-R} option, which is not
912 accessible via @code{groff}.  This option prevents the loading of the
913 @file{troffrc} and @file{troffrc-end} files.
915 @item -v
916 Make programs run by @code{groff} print out their version number.
918 @item -V
919 Print the pipeline on @code{stdout} instead of executing it.
921 @item -z
922 Suppress output from @code{gtroff}.  Only error messages are printed.
924 @item -Z
925 Do not postprocess the output of @code{gtroff}.  Normally @code{groff}
926 automatically runs the appropriate postprocessor.
928 @item -P@var{arg}
929 Pass @var{arg} to the postprocessor.  Each argument should be passed
930 with a separate @option{-P} option.  Note that @code{groff} does not
931 prepend @samp{-} to @var{arg} before passing it to the postprocessor.
933 @item -l
934 Send the output to a spooler for printing.  The command used for this is
935 specified by the @code{print} command in the device description file
936 (see @ref{Font Files}, for more info).  If not present, @option{-l} is
937 ignored.
939 @item -L@var{arg}
940 Pass @var{arg} to the spooler.  Each argument should be passed with a
941 separate @option{-L} option.  Note that @code{groff} does not prepend
942 a @samp{-} to @var{arg} before passing it to the postprocessor.
943 If the @code{print} keyword in the device description file is missing,
944 @option{-L} is ignored.
946 @item -T@var{dev}
947 Prepare output for device @var{dev}.  The default device is @samp{ps},
948 unless changed when @code{groff} was configured and built.  The
949 following are the output devices currently available:
951 @table @code
952 @item ps
953 For @sc{PostScript} printers and previewers.
955 @item dvi
956 For @TeX{} DVI format.
958 @item X75
959 For a 75@dmn{dpi} X11 previewer.
961 @item X75-12
962 For a 75@dmn{dpi} X11 previewer with a 12@dmn{pt} base font in the
963 document.
965 @item X100
966 For a 100@dmn{dpi} X11 previewer.
968 @item X100-12
969 For a 100@dmn{dpi} X11 previewer with a 12@dmn{pt} base font in the
970 document.
972 @item ascii
973 @cindex encoding, @acronym{ASCII}
974 @cindex @acronym{ASCII}, encoding
975 For typewriter-like devices using the (7-bit) @acronym{ASCII}
976 character set.
978 @item latin1
979 @cindex encoding, latin-1
980 @cindex latin-1, encoding
981 For typewriter-like devices that support the @w{Latin-1} (@w{ISO
982 8859-1}) character set.
984 @item utf8
985 @cindex encoding, utf-8
986 @cindex utf-8, encoding
987 For typewriter-like devices which use the Unicode (@w{ISO 10646})
988 character set with @w{UTF-8} encoding.
990 @item cp1047
991 @cindex @acronym{EBCDIC} encoding
992 @cindex encoding, @acronym{EBCDIC}
993 @cindex encoding, cp1047
994 @cindex cp1047
995 @cindex IBM cp1047
996 For typewriter-like devices which use the @acronym{EBCDIC} encoding IBM
997 cp1047.
999 @item lj4
1000 For HP LaserJet4-compatible (or other PCL5-compatible) printers.
1002 @item lbp
1003 For Canon @acronym{CAPSL} printers (@w{LBP-4} and @w{LBP-8} series laser
1004 printers).
1006 @pindex pre-grohtml
1007 @pindex post-grohtml
1008 @cindex @code{grohtml}, the program
1009 @item html
1010 To produce @acronym{HTML} output.  Note that the @acronym{HTML} driver
1011 consists of two parts, a preprocessor (@code{pre-grohtml}) and a
1012 postprocessor (@code{post-grohtml}).
1013 @end table
1015 @cindex output device name string register (@code{.T})
1016 @cindex output device usage number register (@code{.T})
1017 The predefined @code{gtroff} string register @code{.T} contains the
1018 current output device; the read-only number register @code{.T} is set
1019 to@w{ }1 if this option is used (which is always true if @code{groff} is
1020 used to call @code{gtroff}).  @xref{Built-in Registers}.
1022 The postprocessor to be used for a device is specified by the
1023 @code{postpro} command in the device description file.  (@xref{Font
1024 Files}, for more info.)  This can be overridden with the @option{-X}
1025 option.
1027 @item -X
1028 Preview with @code{gxditview} instead of using the usual postprocessor.
1029 This is unlikely to produce good results except with @option{-Tps}.
1031 Note that this is not the same as using @option{-TX75} or
1032 @option{-TX100} to view a document with @code{gxditview}: The former
1033 uses the metrics of the specified device, whereas the latter uses
1034 X-specific fonts and metrics.
1036 @item -N
1037 Don't allow newlines with @code{eqn} delimiters.  This is the same as
1038 the @option{-N} option in @code{geqn}.
1040 @item -S
1041 @cindex @code{open} request, and safer mode
1042 @cindex @code{opena} request, and safer mode
1043 @cindex @code{pso} request, and safer mode
1044 @cindex @code{sy} request, and safer mode
1045 @cindex @code{pi} request, and safer mode
1046 @cindex safer mode
1047 @cindex mode, safer
1048 Safer mode.  Pass the @option{-S} option to @code{gpic} and disable the
1049 @code{open}, @code{opena}, @code{pso}, @code{sy}, and @code{pi}
1050 requests.  For security reasons, this is enabled by default.
1052 @item -U
1053 @cindex mode, unsafe
1054 @cindex unsafe mode
1055 Unsafe mode.  This enables the @code{open}, @code{opena}, @code{pso},
1056 @code{sy}, and @code{pi} requests.
1058 @item -a
1059 @cindex @acronym{ASCII} approximation output register (@code{.A})
1060 Generate an @acronym{ASCII} approximation of the typeset output.  The
1061 read-only register @code{.A} is then set to@w{ }1.  @xref{Built-in
1062 Registers}.  A typical example is
1064 @Example
1065 groff -a -man -Tdvi troff.man | less
1066 @endExample
1068 @noindent
1069 which shows how lines are broken for the DVI device.  Note that this
1070 option is rather useless today since graphic output devices are
1071 available virtually everywhere.
1073 @item -b
1074 Print a backtrace with each warning or error message.  This backtrace
1075 should help track down the cause of the error.  The line numbers given
1076 in the backtrace may not always be correct: @code{gtroff} can get
1077 confused by @code{as} or @code{am} requests while counting line numbers.
1079 @item -i
1080 Read the standard input after all the named input files have been
1081 processed.
1083 @item -w@var{name}
1084 Enable warning @var{name}.  Available warnings are described in
1085 @ref{Debugging}.  Multiple @option{-w} options are allowed.
1087 @item -W@var{name}
1088 Inhibit warning @var{name}.  Multiple @option{-W} options are allowed.
1090 @item -E
1091 Inhibit all error messages.
1093 @item -C
1094 Enable compatibility mode.  @xref{Implementation Differences}, for the
1095 list of incompatibilities between @code{groff} and @acronym{AT&T}
1096 @code{troff}.
1098 @item -d@var{c}@var{s}
1099 @itemx -d@var{name}=@var{s}
1100 Define @var{c} or @var{name} to be a string@w{ }@var{s}.  @var{c}@w{ }must
1101 be a one-letter name; @var{name} can be of arbitrary length.  All string
1102 assignments happen before loading any macro file (including the start-up
1103 file).
1105 @item -f@var{fam}
1106 Use @var{fam} as the default font family.  @xref{Font Families}.
1108 @item -m@var{name}
1109 Read in the file @file{@var{name}.tmac}.  Normally @code{groff} searches
1110 for this in its macro directories.  If it isn't found, it tries
1111 @file{tmac.@var{name}} (searching in the same directories).
1113 @item -n@var{num}
1114 Number the first page @var{num}.
1116 @item -o@var{list}
1117 @cindex print current page register (@code{.P})
1118 Output only pages in @var{list}, which is a comma-separated list of page
1119 ranges; @samp{@var{n}} means print page@w{ }@var{n}, @samp{@var{m}-@var{n}}
1120 means print every page between @var{m} and@w{ }@var{n}, @samp{-@var{n}}
1121 means print every page up to@w{ }@var{n}, @samp{@var{n}-} means print every
1122 page beginning with@w{ }@var{n}.  @code{gtroff} exits after printing the
1123 last page in the list.  All the ranges are inclusive on both ends.
1125 Within @code{gtroff}, this information can be extracted with the
1126 @samp{.P} register.  @xref{Built-in Registers}.
1128 If your document restarts page numbering at the beginning of each
1129 chapter, then @code{gtroff} prints the specified page range for each
1130 chapter.
1132 @item -r@var{c}@var{n}
1133 @itemx -r@var{name}=@var{n}
1134 Set number register@w{ }@var{c} or @var{name} to the value@w{ }@var{n}.
1135 @var{c}@w{ }must be a one-letter name; @var{name} can be of arbitrary
1136 length.  @var{n}@w{ }can be any @code{gtroff} numeric expression.  All
1137 register  assignments happen before loading any macro file (including
1138 the start-up file).
1140 @item -F@var{dir}
1141 Search @file{@var{dir}} for subdirectories @file{dev@var{name}}
1142 (@var{name} is the name of the device), for the @file{DESC} file, and
1143 for font files before looking in the standard directories.
1145 @item -M@var{dir}
1146 Search directory @file{@var{dir}} for macro files before the standard
1147 directories (@pxref{Macro Directories}).
1149 @item -I@var{dir}
1150 This option is as described in @ref{gsoelim}.  It implies the
1151 @option{-s} option.
1152 @end table
1155 @c =====================================================================
1157 @node Environment, Macro Directories, Groff Options, Invoking groff
1158 @section Environment
1159 @cindex environment variables
1160 @cindex variables in environment
1162 There are also several environment variables (of the operating system,
1163 not within @code{gtroff}) which can modify the behavior of @code{groff}.
1165 @table @code
1166 @item GROFF_COMMAND_PREFIX
1167 @tindex GROFF_COMMAND_PREFIX@r{, environment variable}
1168 @cindex command prefix
1169 @cindex prefix, for commands
1170 If this is set to@w{ }@var{X}, then @code{groff} runs @code{@var{X}troff}
1171 instead of @code{gtroff}.  This also applies to @code{tbl}, @code{pic},
1172 @code{eqn}, @code{grn}, @code{refer}, and @code{soelim}.  It does not
1173 apply to @code{grops}, @code{grodvi}, @code{grotty}, @code{pre-grohtml},
1174 @code{post-grohtml}, @code{grolj4}, and @code{gxditview}.
1176 The default command prefix is determined during the installation process.
1177 If a non-GNU troff system is found, prefix @samp{g} is used, none
1178 otherwise.
1180 @item GROFF_TMAC_PATH
1181 @tindex GROFF_TMAC_PATH@r{, environment variable}
1182 A colon-separated list of directories in which to search for macro files
1183 (before the default directories are tried).  @xref{Macro Directories}.
1185 @item GROFF_TYPESETTER
1186 @tindex GROFF_TYPESETTER@r{, environment variable}
1187 The default output device.
1189 @item GROFF_FONT_PATH
1190 @tindex GROFF_FONT_PATH@r{, environment variable}
1191 A colon-separated list of directories in which to search for the
1192 @code{dev}@var{name} directory (before the default directories are
1193 tried).
1195 @item GROFF_BIN_PATH
1196 @tindex GROFF_BIN_PATH@r{, environment variable}
1197 This search path, followed by @code{PATH}, is used for commands executed
1198 by @code{groff}.
1200 @item GROFF_TMPDIR
1201 @tindex GROFF_TMPDIR@r{, environment variable}
1202 @tindex TMPDIR@r{, environment variable}
1203 The directory in which @code{groff} creates temporary files.  If this is
1204 not set and @env{TMPDIR} is set, temporary files are created in that
1205 directory.  Otherwise temporary files are created in a system-dependent
1206 default directory (on Unix and GNU/Linux systems, this is usually
1207 @file{/tmp}).  @code{grops}, @code{grefer}, @code{pre-grohtml}, and
1208 @code{post-grohtml} can create temporary files in this directory.
1209 @end table
1211 Note that MS-DOS and MS-Windows ports of @code{groff} use semi-colons,
1212 rather than colons, to separate the directories in the lists described
1213 above.
1216 @c =====================================================================
1218 @node Macro Directories, Invocation Examples, Environment, Invoking groff
1219 @section Macro Directories
1220 @cindex macro directories
1221 @cindex directories for macros
1222 @cindex searching macros
1223 @cindex macros, searching
1225 All macro file names must be named @code{@var{name}.tmac} or
1226 @code{tmac.@var{name}} to make the @option{-m@var{name}} command line
1227 option work.  The @code{mso} request doesn't have this restriction; any
1228 file name can be used, and @code{gtroff} won't try to append or prepend
1229 the @samp{tmac} string.
1231 @cindex tmac, directory
1232 @cindex directory, for tmac files
1233 @cindex tmac, path
1234 @cindex path, for tmac files
1235 @cindex searching macro files
1236 @cindex macro files, searching
1237 @cindex files, macro, searching
1238 Macro files are kept in the @dfn{tmac directories}, all of which
1239 constitute the @dfn{tmac path}.  The elements of the search path for
1240 macro files are (in that order):
1242 @itemize @bullet
1243 @item
1244 The directories specified with @code{gtroff}'s or @code{groff}'s
1245 @option{-M} command line option.
1247 @item
1248 @tindex GROFF_TMAC_PATH@r{, environment variable}
1249 The directories given in the @env{GROFF_TMAC_PATH} environment
1250 variable.
1252 @item
1253 @cindex safer mode
1254 @cindex mode, safer
1255 @cindex unsafe mode
1256 @cindex mode, unsafe
1257 @cindex current directory
1258 @cindex directory, current
1259 The current directory (only if in unsafe mode using the @option{-U}
1260 command line switch).
1262 @item
1263 @cindex home directory
1264 @cindex directory, home
1265 The home directory.
1267 @item
1268 @cindex site-specific directory
1269 @cindex directory, site-specific
1270 @cindex platform-specific directory
1271 @cindex directory, platform-specific
1272 A platform-dependent directory, a site-specific (platform-independent)
1273 directory, and the main tmac directory; the default locations are
1275 @Example
1276 /usr/local/lib/groff/site-tmac
1277 /usr/local/share/groff/site-tmac
1278 /usr/local/share/groff/1.18/tmac
1279 @endExample
1281 @noindent
1282 assuming that the version of @code{groff} is 1.18, and the installation
1283 prefix was @file{/usr/local}.  It is possible to fine-tune those
1284 directories during the installation process.
1285 @end itemize
1288 @c =====================================================================
1290 @node Invocation Examples,  , Macro Directories, Invoking groff
1291 @section Invocation Examples
1292 @cindex invocation examples
1293 @cindex examples of invocation
1295 This section lists several common uses of @code{groff} and the
1296 corresponding command lines.
1298 @Example
1299 groff file
1300 @endExample
1302 @noindent
1303 This command processes @file{file} without a macro package or a
1304 preprocessor.  The output device is the default, @samp{ps}, and the
1305 output is sent to @code{stdout}.
1307 @Example
1308 groff -t -mandoc -Tascii file | less
1309 @endExample
1311 @noindent
1312 This is basically what a call to the @code{man} program does.
1313 @code{gtroff} processes the manual page @file{file} with the
1314 @file{mandoc} macro file (which in turn either calls the @file{man} or
1315 the @file{mdoc} macro package), using the @code{tbl} preprocessor and
1316 the @acronym{ASCII} output device.  Finally, the @code{less} pager
1317 displays the result.
1319 @Example
1320 groff -X -m me file
1321 @endExample
1323 @noindent
1324 Preview @file{file} with @code{gxditview}, using the @file{me} macro
1325 package.  Since no @option{-T} option is specified, use the default
1326 device (@samp{ps}).  Note that you can either say @w{@samp{-m me}} or
1327 @w{@samp{-me}}; the latter is an anachronism from the early days of
1328 @acronym{UNIX}.@footnote{The same is true for the other main macro
1329 packages that come with @code{groff}: @file{man}, @file{mdoc},
1330 @file{ms}, @file{mm}, and @file{mandoc}.  This won't work in general;
1331 for example, to load @file{trace.tmac}, either @samp{-mtrace} or
1332 @w{@samp{-m trace}} must be used.}
1334 @Example
1335 groff -man -rD1 -z file
1336 @endExample
1338 @noindent
1339 Check @file{file} with the @file{man} macro package, forcing
1340 double-sided printing -- don't produce any output.
1342 @menu
1343 * grog::
1344 @end menu
1346 @c ---------------------------------------------------------------------
1348 @node grog,  , Invocation Examples, Invocation Examples
1349 @subsection @code{grog}
1351 @pindex grog
1352 @code{grog} reads files, guesses which of the @code{groff} preprocessors
1353 and/or macro packages are required for formatting them, and prints the
1354 @code{groff} command including those options on the standard output.  It
1355 generates one or more of the options @option{-e}, @option{-man},
1356 @option{-me}, @option{-mm}, @option{-mom}, @option{-ms}, @option{-mdoc},
1357 @option{-mdoc-old}, @option{-p}, @option{-R}, @option{-g}, @option{-G},
1358 @option{-s}, and @option{-t}.
1360 A special file name@w{ }@file{-} refers to the standard input.  Specifying
1361 no files also means to read the standard input.  Any specified options
1362 are included in the printed command.  No space is allowed between
1363 options and their arguments.  The only options recognized are
1364 @option{-C} (which is also passed on) to enable compatibility mode, and
1365 @option{-v} (if it is the only parameter) to print the version number.
1367 For example,
1369 @Example
1370 grog -Tdvi paper.ms
1371 @endExample
1373 @noindent
1374 guesses the appropriate command to print @file{paper.ms} and then prints
1375 it to the command line after adding the @option{-Tdvi} option.  For
1376 direct execution, enclose the call to @code{grog} in backquotes at the
1377 @acronym{UNIX} shell prompt:
1379 @Example
1380 `grog -Tdvi paper.ms` > paper.dvi
1381 @endExample
1383 @noindent
1384 As seen in the example, it is still necessary to redirect the output to
1385 something meaningful (i.e.@: either a file or a pager program like
1386 @code{less}).
1390 @c =====================================================================
1391 @c =====================================================================
1393 @node Tutorial for Macro Users, Macro Packages, Invoking groff, Top
1394 @chapter Tutorial for Macro Users
1395 @cindex tutorial for macro users
1396 @cindex macros, tutorial for users
1397 @cindex user's tutorial for macros
1398 @cindex user's macro tutorial
1400 Most users tend to use a macro package to format their papers.  This
1401 means that the whole breadth of @code{groff} is not necessary for most
1402 people.  This chapter covers the material needed to efficiently use a
1403 macro package.
1405 @menu
1406 * Basics::
1407 * Common Features::
1408 @end menu
1411 @c =====================================================================
1413 @node Basics, Common Features, Tutorial for Macro Users, Tutorial for Macro Users
1414 @section Basics
1415 @cindex basics of macros
1416 @cindex macro basics
1418 This section covers some of the basic concepts necessary to understand
1419 how to use a macro package.@footnote{This section is derived from
1420 @cite{Writing Papers with nroff using -me} by Eric P.@w{ }Allman.}
1421 References are made throughout to more detailed information, if desired.
1423 @code{gtroff} reads an input file prepared by the user and outputs a
1424 formatted document suitable for publication or framing.  The input
1425 consists of text, or words to be printed, and embedded commands
1426 (@dfn{requests} and @dfn{escapes}), which tell @code{gtroff} how to
1427 format the output.  For more detail on this, see @ref{Embedded
1428 Commands}.
1430 The word @dfn{argument} is used in this chapter to mean a word or number
1431 which appears on the same line as a request, and which modifies the
1432 meaning of that request.  For example, the request
1434 @Example
1436 @endExample
1438 @noindent
1439 spaces one line, but
1441 @Example
1442 .sp 4
1443 @endExample
1445 @noindent
1446 spaces four lines.  The number@w{ }4 is an argument to the @code{sp}
1447 request which says to space four lines instead of one.  Arguments are
1448 separated from the request and from each other by spaces (@emph{no}
1449 tabs).  More details on this can be found in @ref{Request Arguments}.
1451 The primary function of @code{gtroff} is to collect words from input
1452 lines, fill output lines with those words, justify the right-hand margin
1453 by inserting extra spaces in the line, and output the result.  For
1454 example, the input:
1456 @Example
1457 Now is the time
1458 for all good men
1459 to come to the aid
1460 of their party.
1461 Four score and seven
1462 years ago,...
1463 @endExample
1465 @noindent
1466 is read, packed onto output lines, and justified to produce:
1468 @quotation
1469 Now is the time for all good men to come to the aid of their party.
1470 Four score and seven years ago,@dots{}
1471 @end quotation
1473 @cindex break
1474 @cindex line break
1475 Sometimes a new output line should be started even though the current
1476 line is not yet full; for example, at the end of a paragraph.  To do
1477 this it is possible to cause a @dfn{break}, which starts a new output
1478 line.  Some requests cause a break automatically, as normally do blank
1479 input lines and input lines beginning with a space.
1481 Not all input lines are text to be formatted.  Some input lines are
1482 requests which describe how to format the text.  Requests always have a
1483 period (@samp{.}) or an apostrophe (@samp{'}) as the first character of
1484 the input line.
1486 The text formatter also does more complex things, such as automatically
1487 numbering pages, skipping over page boundaries, putting footnotes in the
1488 correct place, and so forth.
1490 Here are a few hints for preparing text for input to @code{gtroff}.
1492 @itemize @bullet
1493 @item
1494 First, keep the input lines short.  Short input lines are easier to
1495 edit, and @code{gtroff} packs words onto longer lines anyhow.
1497 @item
1498 In keeping with this, it is helpful to begin a new line after every
1499 comma or phrase, since common corrections are to add or delete sentences
1500 or phrases.
1502 @item
1503 End each sentence with two spaces -- or better, start each sentence on a
1504 new line.  @code{gtroff} recognizes characters that usually end a
1505 sentence, and inserts sentence space accordingly.
1507 @item
1508 Do not hyphenate words at the end of lines -- @code{gtroff} is smart
1509 enough to hyphenate words as needed, but is not smart enough to take
1510 hyphens out and join a word back together.  Also, words such as
1511 ``mother-in-law'' should not be broken over a line, since then a space
1512 can occur where not wanted, such as ``@w{mother- in}-law''.
1513 @end itemize
1515 @cindex double-spacing (@code{ls})
1516 @cindex spacing
1517 @code{gtroff} double-spaces output text automatically if you use the
1518 request @w{@samp{.ls 2}}.  Reactivate single-spaced mode by typing
1519 @w{@samp{.ls 1}}.@footnote{If you need finer granularity of the
1520 vertical space, use the @code{pvs} request (@pxref{Changing Type
1521 Sizes}).}
1523 A number of requests allow to change the way the output looks,
1524 sometimes called the @dfn{layout} of the output page.  Most of these
1525 requests adjust the placing of @dfn{whitespace} (blank lines or
1526 spaces).
1528 @cindex new page (@code{bp})
1529 The @code{bp} request starts a new page, causing a line break.
1531 @cindex blank line (@code{sp})
1532 @cindex empty line (@code{sp})
1533 @cindex line, empty (@code{sp})
1534 The request @w{@samp{.sp @var{N}}} leaves @var{N}@w{ }lines of blank
1535 space.  @var{N}@w{ }can be omitted (meaning skip a single line) or can
1536 be of the form @var{N}i (for @var{N}@w{ }inches) or @var{N}c (for
1537 @var{N}@w{ }centimeters).  For example, the input:
1539 @Example
1540 .sp 1.5i
1541 My thoughts on the subject
1543 @endExample
1545 @noindent
1546 leaves one and a half inches of space, followed by the line ``My
1547 thoughts on the subject'', followed by a single blank line (more
1548 measurement units are available, see @ref{Measurements}).
1550 @cindex centering lines (@code{ce})
1551 @cindex lines, centering (@code{ce})
1552 Text lines can be centered by using the @code{ce} request.  The line
1553 after @code{ce} is centered (horizontally) on the page.  To center more
1554 than one line, use @w{@samp{.ce @var{N}}} (where @var{N} is the number
1555 of lines to center), followed by the @var{N}@w{ }lines.  To center many
1556 lines without counting them, type:
1558 @Example
1559 .ce 1000
1560 lines to center
1561 .ce 0
1562 @endExample
1564 @noindent
1565 The @w{@samp{.ce 0}} request tells @code{groff} to center zero more
1566 lines, in other words, stop centering.
1568 @cindex line break (@code{br})
1569 @cindex break (@code{br})
1570 All of these requests cause a break; that is, they always start a new
1571 line.  To start a new line without performing any other action, use
1572 @code{br}.
1575 @c =====================================================================
1577 @node Common Features,  , Basics, Tutorial for Macro Users
1578 @section Common Features
1579 @cindex common features
1580 @cindex features, common
1582 @code{gtroff} provides very low-level operations for formatting a
1583 document.  There are many common routine operations which are done in
1584 all documents.  These common operations are written into @dfn{macros}
1585 and collected into a @dfn{macro package}.
1587 All macro packages provide certain common capabilities which fall into
1588 the following categories.
1590 @menu
1591 * Paragraphs::
1592 * Sections and Chapters::
1593 * Headers and Footers::
1594 * Page Layout Adjustment::
1595 * Displays::
1596 * Footnotes and Annotations::
1597 * Table of Contents::
1598 * Indices::
1599 * Paper Formats::
1600 * Multiple Columns::
1601 * Font and Size Changes::
1602 * Predefined Strings::
1603 * Preprocessor Support::
1604 * Configuration and Customization::
1605 @end menu
1607 @c ---------------------------------------------------------------------
1609 @node Paragraphs, Sections and Chapters, Common Features, Common Features
1610 @subsection Paragraphs
1611 @cindex paragraphs
1613 One of the most common and most used capability is starting a
1614 paragraph.  There are a number of different types of paragraphs, any
1615 of which can be initiated with macros supplied by the macro package.
1616 Normally, paragraphs start with a blank line and the first line
1617 indented, like the text in this manual.  There are also block style
1618 paragraphs, which omit the indentation:
1620 @Example
1621 Some   men  look   at  constitutions   with  sanctimonious
1622 reverence, and deem them like the ark of the covenant, too
1623 sacred to be touched.
1624 @endExample
1626 @noindent
1627 And there are also indented paragraphs which begin with a tag or label
1628 at the margin and the remaining text indented.
1630 @Example
1631 one   This is  the first paragraph.  Notice  how the first
1632       line of  the resulting  paragraph lines up  with the
1633       other lines in the paragraph.
1634 @endExample
1635 @Example
1636 longlabel
1637       This  paragraph   had  a  long   label.   The  first
1638       character of text on the first line does not line up
1639       with  the  text  on  second  and  subsequent  lines,
1640       although they line up with each other.
1641 @endExample
1643 A variation of this is a bulleted list.
1645 @Example
1646 .     Bulleted lists start with a bullet.   It is possible
1647       to use other glyphs instead of the bullet.  In nroff
1648       mode using the ASCII character set for output, a dot
1649       is used instead of a real bullet.
1650 @endExample
1653 @c ---------------------------------------------------------------------
1655 @node Sections and Chapters, Headers and Footers, Paragraphs, Common Features
1656 @subsection Sections and Chapters
1658 Most macro packages supply some form of section headers.  The simplest
1659 kind is simply the heading on a line by itself in bold type.  Others
1660 supply automatically numbered section heading or different heading
1661 styles at different levels.  Some, more sophisticated, macro packages
1662 supply macros for starting chapters and appendices.
1664 @c ---------------------------------------------------------------------
1666 @node Headers and Footers, Page Layout Adjustment, Sections and Chapters, Common Features
1667 @subsection Headers and Footers
1669 Every macro package gives some way to manipulate the @dfn{headers} and
1670 @dfn{footers} (also called @dfn{titles}) on each page.  This is text
1671 put at the top and bottom of each page, respectively, which contain
1672 data like the current page number, the current chapter title, and so
1673 on.  Its appearance is not affected by the running text.  Some packages
1674 allow for different ones on the even and odd pages (for material printed
1675 in a book form).
1677 The titles are called @dfn{three-part titles}, that is, there is a
1678 left-justified part, a centered part, and a right-justified part.  An
1679 automatically generated page number may be put in any of these fields
1680 with the @samp{%} character (see @ref{Page Layout}, for more details).
1682 @c ---------------------------------------------------------------------
1684 @node Page Layout Adjustment, Displays, Headers and Footers, Common Features
1685 @subsection Page Layout
1687 Most macro packages let the user specify top and bottom margins and
1688 other details about the appearance of the printed pages.
1690 @c ---------------------------------------------------------------------
1692 @node Displays, Footnotes and Annotations, Page Layout Adjustment, Common Features
1693 @subsection Displays
1694 @cindex displays
1696 @dfn{Displays} are sections of text to be set off from the body of
1697 the paper.  Major quotes, tables, and figures are types of displays, as
1698 are all the examples used in this document.
1700 @cindex quotes, major
1701 @cindex major quotes
1702 @dfn{Major quotes} are quotes which are several lines long, and hence
1703 are set in from the rest of the text without quote marks around them.
1705 @cindex list
1706 A @dfn{list} is an indented, single-spaced, unfilled display.  Lists
1707 should be used when the material to be printed should not be filled and
1708 justified like normal text, such as columns of figures or the examples
1709 used in this paper.
1711 @cindex keep
1712 A @dfn{keep} is a display of lines which are kept on a single page if
1713 possible.  An example for a keep might be a diagram.  Keeps differ from
1714 lists in that lists may be broken over a page boundary whereas keeps are
1715 not.
1717 @cindex keep, floating
1718 @cindex floating keep
1719 @dfn{Floating keeps} move relative to the text.  Hence, they are good for
1720 things which are referred to by name, such as ``See figure@w{ }3''.  A
1721 floating keep appears at the bottom of the current page if it fits;
1722 otherwise, it appears at the top of the next page.  Meanwhile, the
1723 surrounding text `flows' around the keep, thus leaving no blank areas.
1725 @c ---------------------------------------------------------------------
1727 @node Footnotes and Annotations, Table of Contents, Displays, Common Features
1728 @subsection Footnotes and Annotations
1729 @cindex footnotes
1730 @cindex annotations
1732 There are a number of requests to save text for later printing.
1734 @dfn{Footnotes} are printed at the bottom of the current page.
1736 @cindex delayed text
1737 @dfn{Delayed text} is very similar to a footnote except that it is
1738 printed when called for explicitly.  This allows a list of references to
1739 appear (for example) at the end of each chapter, as is the convention in
1740 some disciplines.
1742 Most macro packages which supply this functionality also supply a means
1743 of automatically numbering either type of annotation.
1745 @c ---------------------------------------------------------------------
1747 @node Table of Contents, Indices, Footnotes and Annotations, Common Features
1748 @subsection Table of Contents
1749 @cindex table of contents
1750 @cindex contents, table of
1752 @dfn{Tables of contents} are a type of delayed text having a tag
1753 (usually the page number) attached to each entry after a row of dots.
1754 The table accumulates throughout the paper until printed, usually after
1755 the paper has ended.  Many macro packages provide the ability to have
1756 several tables of contents (e.g.@: a standard table of contents, a list
1757 of tables, etc).
1759 @c ---------------------------------------------------------------------
1761 @node Indices, Paper Formats, Table of Contents, Common Features
1762 @subsection Indices
1763 @cindex index, in macro package
1765 While some macro packages use the term @dfn{index}, none actually
1766 provide that functionality.  The facilities they call indices are
1767 actually more appropriate for tables of contents.
1769 @pindex makeindex
1770 To produce a real index in a document, external tools like the
1771 @code{makeindex} program are necessary.
1773 @c ---------------------------------------------------------------------
1775 @node Paper Formats, Multiple Columns, Indices, Common Features
1776 @subsection Paper Formats
1777 @cindex paper formats
1779 Some macro packages provide stock formats for various kinds of
1780 documents.  Many of them provide a common format for the title and
1781 opening pages of a technical paper.  The @file{mm} macros in particular
1782 provide formats for letters and memoranda.
1784 @c ---------------------------------------------------------------------
1786 @node Multiple Columns, Font and Size Changes, Paper Formats, Common Features
1787 @subsection Multiple Columns
1789 Some macro packages (but not @file{man}) provide the ability to have two
1790 or more columns on a page.
1792 @c ---------------------------------------------------------------------
1794 @node Font and Size Changes, Predefined Strings, Multiple Columns, Common Features
1795 @subsection Font and Size Changes
1797 The built-in font and size functions are not always intuitive, so all
1798 macro packages provide macros to make these operations simpler.
1800 @c ---------------------------------------------------------------------
1802 @node Predefined Strings, Preprocessor Support, Font and Size Changes, Common Features
1803 @subsection Predefined Strings
1805 Most macro packages provide various predefined strings for a variety of
1806 uses; examples are sub- and superscripts, printable dates, quotes and
1807 various special characters.
1809 @c ---------------------------------------------------------------------
1811 @node Preprocessor Support, Configuration and Customization, Predefined Strings, Common Features
1812 @subsection Preprocessor Support
1814 All macro packages provide support for various preprocessors and may
1815 extend their functionality.
1817 For example, all macro packages mark tables (which are processed with
1818 @code{gtbl}) by placing them between @code{TS} and @code{TE} macros.
1819 The @file{ms} macro package has an option, @samp{.TS@w{ }H}, that prints
1820 a caption at the top of a new page (when the table is too long to fit on
1821 a single page).
1823 @c ---------------------------------------------------------------------
1825 @node Configuration and Customization,  , Preprocessor Support, Common Features
1826 @subsection Configuration and Customization
1828 Some macro packages provide means of customizing many of the details of
1829 how the package behaves.  This ranges from setting the default type size
1830 to changing the appearance of section headers.
1834 @c =====================================================================
1835 @c =====================================================================
1837 @node Macro Packages, gtroff Reference, Tutorial for Macro Users, Top
1838 @chapter Macro Packages
1839 @cindex macro packages
1840 @cindex packages, macros
1842 This chapter documents the main macro packages that come with
1843 @code{groff}.
1845 @menu
1846 * man::
1847 * mdoc::
1848 * ms::
1849 * me::
1850 * mm::
1851 @end menu
1854 @c =====================================================================
1856 @node man, mdoc, Macro Packages, Macro Packages
1857 @section @file{man}
1858 @cindex manual pages
1859 @cindex man pages
1860 @pindex an.tmac
1861 @pindex man.tmac
1862 @pindex man-old.tmac
1864 This is the most popular and probably the most important macro package
1865 of @code{groff}.  It is easy to use, and a vast majority of manual pages
1866 are based on it.
1868 @menu
1869 * Man options::
1870 * Man usage::
1871 * Man font macros::
1872 * Miscellaneous man macros::
1873 * Predefined man strings::
1874 * Preprocessors in man pages::
1875 @end menu
1877 @c ---------------------------------------------------------------------
1879 @node Man options, Man usage, man, man
1880 @subsection Options
1882 The command line format for using the @file{man} macros with
1883 @code{groff} is:
1885 @Example
1886 groff -m man [ -rLL=@var{length} ] [ -rLT=@var{length} ]
1887       [ -rcR=1 ] [ -rC1 ] [ -rD1 ] [ -rP@var{nnn} ]
1888       [ -rS@var{xx} ] [ -rX@var{nnn} ] [ @var{files}@dots{} ]
1889 @endExample
1891 @noindent
1892 It is possible to use @samp{-man} instead of @w{@samp{-m man}}.
1894 @table @code
1895 @item -rLL=@var{length}
1896 Set line length to @var{length}.  If not specified, the line length
1897 defaults to 78@w{ }en in nroff mode (this is 78@w{ }characters per
1898 line) and 6.5@w{ }inch otherwise.
1900 @item -rLT=@var{length}
1901 Set title length to @var{length}.  If not specified, the title length
1902 defaults to 78@w{ }en in nroff mode (this is 78@w{ }characters per
1903 line) and 6.5@w{ }inch otherwise.
1905 @item -rcR=1
1906 This option (the default if a TTY output device is used) creates a
1907 single, very long page instead of multiple pages.  Use @code{-rcR=0}
1908 to disable it.
1910 @item -rC1
1911 If more than one manual page is given on the command line, number the
1912 pages continuously, rather than starting each at@w{ }1.
1914 @item -rD1
1915 Double-sided printing.  Footers for even and odd pages are formatted
1916 differently.
1918 @item -rP@var{nnn}
1919 Page numbering starts with @var{nnn} rather than with@w{ }1.
1921 @item -rS@var{xx}
1922 Use @var{xx} (which can be 10, 11, or@w{ }12@dmn{pt}) as the base
1923 document font size instead of the default value of@w{ }10@dmn{pt}.
1925 @item -rX@var{nnn}
1926 After page @var{nnn}, number pages as @var{nnn}a, @var{nnn}b,
1927 @var{nnn}c, etc.  For example, the option @option{-rX2} produces the
1928 following page numbers: 1, 2, 2a, 2b, 2c, etc.
1929 @end table
1931 @c ---------------------------------------------------------------------
1933 @node Man usage, Man font macros, Man options, man
1934 @subsection Usage
1935 @cindex @code{man} macros
1936 @cindex macros for manual pages [@code{man}]
1938 @pindex man.local
1939 This section describes the available macros for manual pages.  For
1940 further customization, put additional macros and requests into the file
1941 @file{man.local} which is loaded immediately after the @file{man}
1942 package.
1944 @Defmac {TH, title section [@Var{extra1} [@Var{extra2} [@Var{extra3}]]], man}
1945 Set the title of the man page to @var{title} and the section to
1946 @var{section}, which must have a value between 1 and@w{ }8.  The value
1947 of @var{section} may also have a string appended, e.g.@: @samp{.pm},
1948 to indicate a specific subsection of the man pages.
1950 Both @var{title} and @var{section} are positioned at the left and right
1951 in the header line (with @var{section} in parentheses immediately
1952 appended to @var{title}.  @var{extra1} is positioned in the middle of
1953 the footer line.  @var{extra2} is positioned at the left in the footer
1954 line (or at the left on even pages and at the right on odd pages if
1955 double-sided printing is active).  @var{extra3} is centered in the
1956 header line.
1958 For @acronym{HTML} output, headers and footers are completely suppressed.
1960 Additionally, this macro starts a new page; the new line number is@w{ }1
1961 again (except if the @option{-rC1} option is given on the command line)
1962 -- this feature is intended only for formatting multiple man pages; a
1963 single man page should contain exactly one @code{TH} macro at the
1964 beginning of the file.
1965 @endDefmac
1967 @Defmac {SH, [@Var{heading}], man}
1968 Set up an unnumbered section heading sticking out to the left.  Prints
1969 out all the text following @code{SH} up to the end of the line (or the
1970 text in the next line if there is no argument to @code{SH}) in bold
1971 face, one size larger than the base document size.  Additionally, the
1972 left margin for the following text is reset to its default value.
1973 @endDefmac
1975 @Defmac {SS, [@Var{heading}], man}
1976 Set up an unnumbered (sub)section heading.  Prints out all the text
1977 following @code{SS} up to the end of the line (or the text in the next
1978 line if there is no argument to @code{SS}) in bold face, at the same
1979 size as the base document size.  Additionally, the left margin for the
1980 following text is reset to its default value.
1981 @endDefmac
1983 @Defmac {TP, [@Var{nnn}], man}
1984 Set up an indented paragraph with label.  The indentation is set to
1985 @var{nnn} if that argument is supplied (the default unit is @samp{n}
1986 if omitted), otherwise it is set to the default indentation value.
1988 The first line of text following this macro is interpreted as a string
1989 to be printed flush-left, as it is appropriate for a label.  It is not
1990 interpreted as part of a paragraph, so there is no attempt to fill the
1991 first line with text from the following input lines.  Nevertheless, if
1992 the label is not as wide as the indentation, then the paragraph starts
1993 at the same line (but indented), continuing on the following lines.
1994 If the label is wider than the indentation, then the descriptive part
1995 of the paragraph begins on the line following the label, entirely
1996 indented.  Note that neither font shape nor font size of the label is
1997 set to a default value; on the other hand, the rest of the text has
1998 default font settings.
1999 @endDefmac
2001 @DefmacList {LP, , man}
2002 @DefmacItem {PP, , man}
2003 @DefmacListEnd {P, , man}
2004 These macros are mutual aliases.  Any of them causes a line break at
2005 the current position, followed by a vertical space downwards by the
2006 amount specified by the @code{PD} macro.  The font size and shape are
2007 reset to the default value (10@dmn{pt} roman if no @option{-rS} option
2008 is given on the command line).  Finally, the current left margin is
2009 restored.
2010 @endDefmac
2012 @Defmac {IP, [@Var{designator} [@Var{nnn}]], man}
2013 Set up an indented paragraph, using @var{designator} as a tag to mark
2014 its beginning.  The indentation is set to @var{nnn} if that argument
2015 is supplied (default unit is @samp{n}), otherwise the default
2016 indentation value is used.  Font size and face of the paragraph (but
2017 not the designator) are reset to their default values.  To start an
2018 indented paragraph with a particular indentation but without a
2019 designator, use @samp{""} (two double quotes) as the first argument of
2020 @code{IP}.
2022 For example, to start a paragraph with bullets as the designator and
2023 4@w{ }en indentation, write
2025 @Example
2026 .IP \(bu 4
2027 @endExample
2028 @endDefmac
2030 @Defmac {HP, [@Var{nnn}], man}
2031 @cindex hanging indentation [@code{man}]
2032 @cindex @code{man} macros, hanging indentation
2033 Set up a paragraph with hanging left indentation.  The indentation is
2034 set to @var{nnn} if that argument is supplied (default unit is
2035 @samp{n}), otherwise the default indentation value is used.  Font size
2036 and face are reset to their default values.
2037 @endDefmac
2039 @Defmac {RS, [@Var{nnn}], man}
2040 @cindex left margin, how to move [@code{man}]
2041 @cindex @code{man} macros, moving left margin
2042 Move the left margin to the right by the value @var{nnn} if specified
2043 (default unit is @samp{n}); otherwise the default indentation value
2044 is used.  Calls to the @code{RS} macro can be nested.
2045 @endDefmac
2047 @Defmac {RE, [@Var{nnn}], man}
2048 Move the left margin back to level @var{nnn}; if no argument is given,
2049 it moves one level back.  The first level (i.e., no call to @code{RS}
2050 yet) has number@w{ }1, and each call to @code{RS} increases the level
2051 by@w{ }1.
2052 @endDefmac
2054 @cindex line breaks, with vertical space [@code{man}]
2055 @cindex @code{man} macros, line breaks with vertical space
2056 To summarize, the following macros cause a line break with the insertion
2057 of vertical space (which amount can be changed with the @code{PD}
2058 macro): @code{SH}, @code{SS}, @code{TP}, @code{LP} (@code{PP},
2059 @code{P}), @code{IP}, and @code{HP}.
2061 @cindex line breaks, without vertical space [@code{man}]
2062 @cindex @code{man} macros, line breaks without vertical space
2063 The macros @code{RS} and @code{RE} also cause a break but do not insert
2064 vertical space.
2066 @c ---------------------------------------------------------------------
2068 @node Man font macros, Miscellaneous man macros, Man usage, man
2069 @subsection Macros to set fonts
2070 @cindex font selection [@code{man}]
2071 @cindex @code{man} macros, how to set fonts
2073 The standard font is roman; the default text size is 10@w{ }point.
2074 If command line option @option{-rS=@var{n}} is given, use
2075 @var{n}@dmn{pt} as the default text size.
2077 @Defmac {SM, [@Var{text}], man}
2078 Set the text on the same line or the text on the next line in a font
2079 that is one point size smaller than the default font.
2080 @endDefmac
2082 @Defmac {SB, [@Var{text}], man}
2083 @cindex bold face [@code{man}]
2084 @cindex @code{man} macros, bold face
2085 Set the text on the same line or the text on the next line in bold face
2086 font, one point size smaller than the default font.
2087 @endDefmac
2089 @Defmac {BI, text, man}
2090 Set its arguments alternately in bold face and italic.  Thus,
2092 @Example
2093 .BI this "word and" that
2094 @endExample
2096 @noindent
2097 would set ``this'' and ``that'' in bold face, and ``word and'' in
2098 italics.
2099 @endDefmac
2101 @Defmac {IB, text, man}
2102 Set its arguments alternately in italic and bold face.
2103 @endDefmac
2105 @Defmac {RI, text, man}
2106 Set its arguments alternately in roman and italic.
2107 @endDefmac
2109 @Defmac {IR, text, man}
2110 Set its arguments alternately in italic and roman.
2111 @endDefmac
2113 @Defmac {BR, text, man}
2114 Set its arguments alternately in bold face and roman.
2115 @endDefmac
2117 @Defmac {RB, text, man}
2118 Set its arguments alternately in roman and bold face.
2119 @endDefmac
2121 @Defmac {B, [@Var{text}], man}
2122 Set @var{text} in bold face.  If no text is present on the line where
2123 the macro is called, then the text of the next line appears in bold
2124 face.
2125 @endDefmac
2127 @Defmac {I, [@Var{text}], man}
2128 @cindex italic fonts [@code{man}]
2129 @cindex @code{man} macros, italic fonts
2130 Set @var{text} in italic.  If no text is present on the line where the
2131 macro is called, then the text of the next line appears in italic.
2132 @endDefmac
2134 @c ---------------------------------------------------------------------
2136 @node Miscellaneous man macros, Predefined man strings, Man font macros, man
2137 @subsection Miscellaneous macros
2139 @pindex grohtml
2140 @cindex @code{man} macros, default indentation
2141 @cindex default indentation [@code{man}]
2142 The default indentation is 7.2@w{ }en for all output devices except for
2143 @code{grohtml} which ignores indentation.
2145 @Defmac {DT, , man}
2146 @cindex tab stops [@code{man}]
2147 @cindex @code{man} macros, tab stops
2148 Set tabs every 0.5@w{ }inches.  Since this macro is always executed
2149 during a call to the @code{TH} macro, it makes sense to call it only if
2150 the tab positions have been changed.
2151 @endDefmac
2153 @Defmac {PD, [@Var{nnn}], man}
2154 @cindex empty space before a paragraph [@code{man}]
2155 @cindex @code{man} macros, empty space before a paragraph
2156 Adjust the empty space before a new paragraph (or section).  The
2157 optional argument gives the amount of space (default unit is
2158 @samp{v}); without parameter, the value is reset to its default value
2159 (1@w{ }line for TTY devices, 0.4@dmn{v}@w{ }otherwise).
2160 @endDefmac
2162 This affects the macros @code{SH}, @code{SS}, @code{TP}, @code{LP} (as
2163 well as @code{PP} and @code{P}), @code{IP}, and @code{HP}.
2165 @c ---------------------------------------------------------------------
2167 @node Predefined man strings, Preprocessors in man pages, Miscellaneous man macros, man
2168 @subsection Predefined strings
2170 The following strings are defined:
2172 @Defstr {S, man}
2173 Switch back to the default font size.
2174 @endDefstr
2176 @Defstr {R, man}
2177 The `registered' sign.
2178 @endDefstr
2180 @Defstr {Tm, man}
2181 The `trademark' sign.
2182 @endDefstr
2184 @DefstrList {lq, man}
2185 @DefstrListEnd {rq, man}
2186 @cindex @code{lq} glyph, and @code{lq} string [@code{man}]
2187 @cindex @code{rq} glyph, and @code{rq} string [@code{man}]
2188 Left and right quote.  This is equal to @code{\(lq} and @code{\(rq},
2189 respectively.
2190 @endDefstr
2192 @c ---------------------------------------------------------------------
2194 @node Preprocessors in man pages,  , Predefined man strings, man
2195 @subsection Preprocessors in @file{man} pages
2197 @cindex preprocessor, calling convention
2198 @cindex calling convention of preprocessors
2199 If a preprocessor like @code{gtbl} or @code{geqn} is needed, it has
2200 become common usage to make the first line of the man page look like
2201 this:
2203 @Example
2204 '\" @var{word}
2205 @endExample
2207 @pindex geqn@r{, invocation in manual pages}
2208 @pindex grefer@r{, invocation in manual pages}
2209 @pindex gtbl@r{, invocation in manual pages}
2210 @pindex man@r{, invocation of preprocessors}
2211 @noindent
2212 Note the single space character after the double quote.  @var{word}
2213 consists of letters for the needed preprocessors: @samp{e} for
2214 @code{geqn}, @samp{r} for @code{grefer}, @samp{t} for @code{gtbl}.
2215 Modern implementations of the @code{man} program read this first line
2216 and automatically call the right preprocessor(s).
2219 @c =====================================================================
2221 @node mdoc, ms, man, Macro Packages
2222 @section @file{mdoc}
2223 @cindex @code{mdoc} macros
2225 @c XXX documentation
2226 @c XXX this is a placeholder until we get stuff knocked into shape
2227 See the @cite{groff_mdoc(7)} man page (type @command{man groff_mdoc}
2228 at the command line).
2231 @c =====================================================================
2233 @node ms, me, mdoc, Macro Packages
2234 @section @file{ms}
2235 @cindex @code{ms} macros
2237 The @file{-ms}
2238 macros are suitable for reports, letters, books,
2239 user manuals, and so forth.
2240 The package provides macros for cover pages, section headings,
2241 paragraphs, lists, footnotes, pagination,
2242 and a table of contents.
2244 @menu
2245 * ms Intro::
2246 * General ms Structure::
2247 * ms Document Control Registers::
2248 * ms Cover Page Macros::
2249 * ms Body Text::
2250 * ms Page Layout::
2251 * Differences from AT&T ms::
2252 @end menu
2254 @c ---------------------------------------------------------------------
2256 @node ms Intro, General ms Structure, ms, ms
2257 @subsection Introduction to @file{ms}
2259 The original @file{-ms} macros were included with
2260 @acronym{AT&T} @code{troff} as well as the
2261 @file{man} macros.
2262 While the @file{man} package is intended for brief documents
2263 that can be read on-line as well as printed, the @file{ms}
2264 macros are suitable for longer documents that are meant to be
2265 printed rather than read on-line.
2267 The @file{ms} macro package included with @code{groff}
2268 is a complete, bottom-up re-implementation.
2269 Several macros (specific to @acronym{AT&T}
2270 or Berkeley) are not included, while several new commands are.
2271 @xref{Differences from AT&T ms}, for more information.
2273 @c ---------------------------------------------------------------------
2275 @node General ms Structure, ms Document Control Registers, ms Intro, ms
2276 @subsection General structure of an @file{ms} document
2277 @cindex @code{ms} macros, general structure
2279 The @file{ms} macro package expects a certain amount of structure,
2280 but not as much as packages such as @file{man} or @file{mdoc}.
2282 The simplest documents can begin with a paragraph macro
2283 (such as @code{LP} or @code{PP}),
2284 and consist of text separated by paragraph macros
2285 or even blank lines.
2286 Longer documents have a structure as follows:
2288 @table @strong
2289 @item Document type
2290 If you invoke the @code{RP}
2291 (report) macro on the first line of the document,
2292 @code{groff} prints the cover page information on its own page;
2293 otherwise it prints the information on the
2294 first page with your document text immediately following.
2295 Other document formats found in @acronym{AT&T} @code{troff}
2296 are specific to @acronym{AT&T} or Berkeley, and are not supported in
2297 @code{groff}.
2299 @item Format and layout
2300 By setting number registers,
2301 you can change your document's type (font and size),
2302 margins, spacing, headers and footers, and footnotes.
2303 @xref{ms Document Control Registers}, for more details.
2305 @item Cover page
2306 A cover page consists of a title, the author's name and institution,
2307 an abstract, and the date.
2308 @footnote{Actually, only the title is required.}
2309 @xref{ms Cover Page Macros}, for more details.
2311 @item Body
2312 Following the cover page is your document.
2313 You can use the @file{ms}
2314 macros to write reports, letters, books, and so forth.
2315 The package is designed for structured documents,
2316 consisting of paragraphs interspersed with headings
2317 and augmented by lists, footnotes, tables, and other
2318 common constructs.
2319 @xref{ms Body Text}, for more details.
2321 @item Table of contents
2322 Longer documents usually include a table of contents,
2323 which you can invoke by placing the
2324 @code{TC}
2325 macro at the end of your document.
2326 The @file{ms}
2327 macros have minimal indexing facilities, consisting of the
2328 @code{IX} macro, which prints an entry on standard error.
2329 Printing the table of contents at the end is necessary since
2330 @code{groff} is a single-pass text formatter,
2331 thus it cannot determine the page number of each section
2332 until that section has actually been set and printed.
2333 Since @file{ms} output is intended for hardcopy,
2334 you can manually relocate the pages containing
2335 the table of contents between the cover page and the
2336 body text after printing.
2337 @end table
2339 @c ---------------------------------------------------------------------
2341 @node ms Document Control Registers, ms Cover Page Macros, General ms Structure, ms
2342 @subsection Document control registers
2343 @cindex @code{ms} macros, document control registers
2345 The following is a list of document control number registers.
2346 For the sake of consistency,
2347 set registers related to margins at the beginning of your document,
2348 or just after the @code{RP} macro.
2349 You can set other registers later in your document,
2350 but you should keep them together at the beginning
2351 to make them easy to find and edit as necessary.
2353 @unnumberedsubsubsec Margin Settings
2355 @Defmpreg {PO, ms}
2356 Defines the page offset (i.e.@: the left margin).
2357 There is no explicit right margin setting; the combination of
2358 the @code{PO} and @code{LL} registers implicitly define the
2359 right margin width.
2361 Effective: next page.
2363 Default value: 1@dmn{i}.
2364 @endDefmpreg
2366 @Defmpreg {LL, ms}
2367 Defines the line length (i.e.@: the width of the body text).
2369 Effective: next paragraph.
2371 Default: 6@dmn{i}.
2372 @endDefmpreg
2374 @Defmpreg {LT, ms}
2375 Defines the title length (i.e.@: the header and footer width).
2376 This is usually the same as @code{LL}, but not necessarily.
2378 Effective: next paragraph.
2380 Default: 6@dmn{i}.
2381 @endDefmpreg
2383 @Defmpreg {HM, ms}
2384 Defines the header margin height at the top of the page.
2386 Effective: next page.
2388 Default: 1@dmn{i}.
2389 @endDefmpreg
2391 @Defmpreg {FM, ms}
2392 Defines the footer margin height at the bottom of the page.
2394 Effective: next page.
2396 Default: 1@dmn{i}.
2397 @endDefmpreg
2399 @unnumberedsubsubsec Text Settings
2401 @Defmpreg {PS, ms}
2402 Defines the point size of the body text.
2404 Effective: next paragraph.
2406 Default: 10@dmn{p}.
2407 @endDefmpreg
2409 @Defmpreg {VS, ms}
2410 Defines the space between lines (line height plus leading).
2412 Effective: next paragraph.
2414 Default: 12@dmn{p}.
2415 @endDefmpreg
2417 @unnumberedsubsubsec Paragraph Settings
2419 @Defmpreg {PI, ms}
2420 Defines the initial indent of a @code{.PP} paragraph.
2422 Effective: next paragraph.
2424 Default: 5@dmn{n}.
2425 @endDefmpreg
2427 @Defmpreg {PD, ms}
2428 Defines the space between paragraphs.
2430 Effective: next paragraph.
2432 Default: 0.3@dmn{v}.
2433 @endDefmpreg
2435 @Defmpreg {QI, ms}
2436 Defines the indent on both sides of a quoted (@code{.QP}) paragraph.
2438 Effective: next paragraph.
2440 Default: 5@dmn{n}.
2441 @endDefmpreg
2443 @unnumberedsubsubsec Footnote Settings
2445 @Defmpreg {FL, ms}
2446 Defines the length of a footnote.
2448 Effective: next footnote.
2450 Default: @math{@code{@\n[LL]} * 5 / 6}.
2451 @endDefmpreg
2453 @Defmpreg {FI, ms}
2454 Defines the footnote indent.
2456 Effective: next footnote.
2458 Default: 2@dmn{n}.
2459 @endDefmpreg
2461 @Defmpreg {FF, ms}
2462 The footnote format:
2463 @table @code
2464 @item 0
2465 Prints the footnote number as a superscript; indents the footnote (default).
2467 @item 1
2468 Prints the number followed by a period (like 1.)
2469 and indents the footnote.
2471 @item 2
2472 Like 1, without an indent.
2474 @item 3
2475 Like 1, but prints the footnote number as a hanging paragraph.
2476 @end table
2478 Effective: next footnote.
2480 Default: 0.
2481 @endDefmpreg
2483 @unnumberedsubsubsec Miscellaneous Number Registers
2485 @Defmpreg {MINGW, ms}
2486 Defines the minimum width between columns in a multi-column document.
2488 Effective: next page.
2490 Default: 2@dmn{n}.
2491 @endDefmpreg
2493 @c ---------------------------------------------------------------------
2495 @node ms Cover Page Macros, ms Body Text, ms Document Control Registers, ms
2496 @subsection Cover page macros
2497 @cindex @code{ms} macros, cover page
2498 @cindex cover page macros, [@code{ms}]
2500 Use the following macros to create a cover page for your document
2501 in the order shown.
2503 @Defmac {RP, [@code{no}], ms}
2504 Specifies the report format for your document.
2505 The report format creates a separate cover page.
2506 The default action (no @code{.RP}
2507 macro) is to print a subset of the
2508 cover page on page 1 of your document.
2510 If you use the word @code{no} as an optional argument,
2511 @code{groff} prints a title page but
2512 does not repeat any of the title page information
2513 (title, author, abstract, etc.)
2514 on page 1 of the document.
2515 @endDefmac
2517 @Defmac {DA, [@dots{}], ms}
2518 (optional) Print the current date, or the arguments to the macro if any,
2519 on the title page (if specified) and in the footers.
2520 This is the default for @code{nroff}.
2521 @endDefmac
2523 @Defmac {ND, [@dots{}], ms}
2524 (optional) Print the current date, or the arguments to the macro if any,
2525 on the title page (if specified) but not in the footers.
2526 This is the default for @code{troff}.
2527 @endDefmac
2529 @Defmac {TL, , ms}
2530 Specifies the document title.
2531 @code{groff} collects text following the @code{.TL}
2532 macro into the title, until reaching the author name or abstract.
2533 @endDefmac
2535 @Defmac {AU, , ms}
2536 Specifies the author's name, which appears on the
2537 line (or lines) immediately following.
2538 You can specify multiple authors as follows:
2540 @Example
2542 John Doe
2544 University of West Bumblefuzz
2546 Martha Buck
2548 Monolithic Corporation
2551 @endExample
2552 @endDefmac
2554 @Defmac {AI, , ms}
2555 Specifies the author's institution.
2556 You can specify multiple institutions in the same way
2557 that you specify multiple authors.
2558 @endDefmac
2560 @Defmac {AB, [@code{no}], ms}
2561 Begins the abstract.
2562 The default is to print the word @acronym{ABSTRACT},
2563 centered and in italics, above the text of the abstract.
2564 The word @code{no} as an optional argument suppresses this heading.
2565 @endDefmac
2567 @Defmac {AE, , ms}
2568 End the abstract.
2569 @endDefmac
2571 The following is example mark-up for a title page.
2572 @cindex title page, example markup
2573 @cindex example markup, title page
2575 @Example
2576 @cartouche
2579 The Inevitability of Code Bloat
2580 in Commercial and Free Software
2582 J. Random Luser
2584 University of West Bumblefuzz
2586 This report examines the long-term growth
2587 of the code bases in two large, popular software
2588 packages; the free Emacs and the commercial
2589 Microsoft Word.
2590 While differences appear in the type or order
2591 of features added, due to the different
2592 methodologies used, the results are the same
2593 in the end.
2595 The free software approach is shown to be
2596 superior in that while free software can
2597 become as bloated as commercial offerings,
2598 free software tends to have fewer serious
2599 bugs and the added features are in line with
2600 user demand.
2603 ... the rest of the paper follows ...
2604 @end cartouche
2605 @endExample
2607 @c ---------------------------------------------------------------------
2609 @node ms Body Text, ms Page Layout, ms Cover Page Macros, ms
2610 @subsection Body text
2611 @cindex @code{ms} macros, body text
2613 This section describes macros used to mark up the body of your document.
2614 Examples include paragraphs, sections, and other groups.
2616 @menu
2617 * Paragraphs in ms::
2618 * Headings in ms::
2619 * Highlighting in ms::
2620 * Lists in ms::
2621 * Indents in ms::
2622 * Tabstops in ms::
2623 * ms Displays and Keeps::
2624 * ms Insertions::
2625 * Example multi-page table::
2626 * ms Footnotes::
2627 @end menu
2629 @c ---------------------------------------------------------------------
2631 @node Paragraphs in ms, Headings in ms, ms Body Text, ms Body Text
2632 @subsubsection Paragraphs
2633 @cindex @code{ms} macros, paragraph handling
2635 The following paragraph types are available.
2637 @Defmac {PP, , ms}
2638 Sets a paragraph with an initial indent.
2639 @endDefmac
2641 @Defmac {LP, , ms}
2642 Sets a paragraph with no initial indent.
2643 @endDefmac
2645 @Defmac {QP, , ms}
2646 Sets a paragraph that is indented at both left and right margins.
2647 The effect is identical to the @acronym{HTML} @code{<BLOCKQUOTE>} element.
2648 The next paragraph or heading returns margins to normal.
2649 @endDefmac
2651 @Defmac {XP, , ms}
2652 Sets a paragraph whose lines are indented,
2653 except for the first line.
2654 This is a Berkeley extension.
2655 @endDefmac
2657 The following markup uses all four paragraph macros.
2659 @Example
2660 @cartouche
2661 .NH 2
2662 Cases used in the study
2664 The following software and versions were
2665 considered for this report.
2667 For commercial software, we chose
2668 .B "Microsoft Word for Windows" ,
2669 starting with version 1.0 through the
2670 current version (Word 2000).
2672 For free software, we chose
2673 .B Emacs ,
2674 from its first appearance as a standalone
2675 editor through the current version (v20).
2676 See [Bloggs 2002] for details.
2678 Franklin's Law applied to software:
2679 software expands to outgrow both
2680 RAM and disk space over time.
2682 Bibliography:
2684 Bloggs, Joseph R.,
2685 .I "Everyone's a Critic" ,
2686 Underground Press, March 2002.
2687 A definitive work that answers all questions
2688 and criticisms about the quality and usability of
2689 free software.
2691 @end cartouche
2692 @endExample
2694 @c ---------------------------------------------------------------------
2696 @node Headings in ms, Highlighting in ms, Paragraphs in ms, ms Body Text
2697 @subsubsection Headings
2698 @cindex @code{ms} macros, headings
2700 Use headings to create a hierarchical structure for your document.
2701 The @file{ms} macros print headings in @strong{bold},
2702 using the same font family and point size as the body text.
2704 The following describes the heading macros:
2706 @DefmacList {NH, @Var{curr-level}, ms}
2707 @DefmacListEnd {NH, @t{S} @Var{level0} @dots{}, ms}
2708 Numbered heading.
2709 The argument is either a numeric argument to indicate the
2710 level of the heading, or the letter@w{ }@code{S} followed by numeric
2711 arguments to set the heading level explicitly.
2713 If you specify heading levels out of sequence, such as invoking
2714 @samp{.NH 3} after @samp{.NH 1}, @code{groff}
2715 prints a warning on standard error.
2716 @endDefmac
2718 @Defmac {SH, , ms}
2719 Unnumbered subheading.
2720 @endDefmac
2722 @c ---------------------------------------------------------------------
2724 @node Highlighting in ms, Lists in ms, Headings in ms, ms Body Text
2725 @subsubsection Highlighting
2726 @cindex @code{ms} macros, highlighting
2728 The @file{ms} macros provide a variety of methods to highlight
2729 or emphasize text:
2731 @Defmac {B, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
2732 Sets its first argument in @strong{bold type}.
2733 If you specify a second argument, @code{groff} prints it in the
2734 previous font after the bold text, with no intervening space
2735 (this allows you to set punctuation after the highlighted text
2736 without highlighting the punctuation).
2737 Similarly, it prints the third argument (if any) in the previous
2738 font @strong{before} the first argument.
2739 For example,
2741 @Example
2742 .B foo ) (
2743 @endExample
2745 prints (@strong{foo}).
2747 If you give this macro no arguments, @code{groff}
2748 prints all text following in bold until
2749 the next highlighting, paragraph, or heading macro.
2750 @endDefmac
2752 @Defmac {R, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
2753 Sets its first argument in roman (or regular) type.
2754 It operates similarly to the @code{B}@w{ }macro otherwise.
2755 @endDefmac
2757 @Defmac {I, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
2758 Sets its first argument in @emph{italic type}.
2759 It operates similarly to the @code{B}@w{ }macro otherwise.
2760 @endDefmac
2762 @Defmac {CW, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
2763 Sets its first argument in a @code{constant width face}.
2764 It operates similarly to the @code{B}@w{ }macro otherwise.
2765 @endDefmac
2767 @Defmac {BI, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
2768 Sets its first argument in bold italic type.
2769 It operates similarly to the @code{B}@w{ }macro otherwise.
2770 @endDefmac
2772 @Defmac {BX, [@Var{txt}], ms}
2773 Prints its argument and draws a box around it.
2774 If you want to box a string that contains spaces,
2775 use a digit-width space (@code{\0}).
2776 @endDefmac
2778 @Defmac {UL, [@Var{txt} [@Var{post}]], ms}
2779 Prints its first argument with an underline.
2780 If you specify a second argument, @code{groff}
2781 prints it in the previous font after
2782 the underlined text, with no intervening space.
2783 @endDefmac
2785 @Defmac {LG, , ms}
2786 Prints all text following in larger type
2787 (two points larger than the current point size) until
2788 the next font size, highlighting, paragraph, or heading macro.
2789 You can specify this macro multiple times
2790 to enlarge the point size as needed.
2791 @endDefmac
2793 @Defmac {SM, , ms}
2794 Prints all text following in smaller type
2795 (two points smaller than the current point size) until
2796 the next type size, highlighting, paragraph, or heading macro.
2797 You can specify this macro multiple times
2798 to reduce the point size as needed.
2799 @endDefmac
2801 @Defmac {NL, , ms}
2802 Prints all text following in the normal point size
2803 (that is, the value of the @code{PS} register).
2804 @endDefmac
2806 @c ---------------------------------------------------------------------
2808 @node Lists in ms, Indents in ms, Highlighting in ms, ms Body Text
2809 @subsubsection Lists
2810 @cindex @code{ms} macros, lists
2812 The @code{.IP} macro handles duties for all lists.
2814 @Defmac {IP, [@Var{marker} [@Var{width}]], ms}
2815 The @var{marker} is usually a bullet glyph (@code{\[bu]})
2816 for unordered lists, a number (or auto-incrementing number
2817 register) for numbered lists, or a word or phrase for indented
2818 (glossary-style) lists.
2820 The @var{width} specifies the indent for the body of each list item;
2821 its default unit is @samp{n}.
2822 Once specified, the indent remains the same for all
2823 list items in the document until specified again.
2824 @endDefmac
2826 The following is an example of a bulleted list.
2827 @cindex example markup, bulleted list [@code{ms}]
2828 @cindex bulleted list, example markup [@code{ms}]
2830 @Example
2831 A bulleted list:
2832 .IP \[bu] 2
2833 lawyers
2834 .IP \[bu]
2835 guns
2836 .IP \[bu]
2837 money
2838 @endExample
2840 Produces:
2842 @Example
2843 A bulleted list:
2845 o lawyers
2847 o guns
2849 o money
2850 @endExample
2852 @sp 1
2854 The following is an example of a numbered list.
2855 @cindex example markup, numbered list [@code{ms}]
2856 @cindex numbered list, example markup [@code{ms}]
2858 @Example
2859 .nr step 1 1
2860 A numbered list:
2861 .IP \n[step] 3
2862 lawyers
2863 .IP \n+[step]
2864 guns
2865 .IP \n+[step]
2866 money
2867 @endExample
2869 Produces:
2871 @Example
2872 A numbered list:
2874 1. lawyers
2876 2. guns
2878 3. money
2879 @endExample
2881 Note the use of the auto-incrementing number
2882 register in this example.
2884 @sp 1
2885 The following is an example of a glossary-style list.
2886 @cindex example markup, glossary-style list [@code{ms}]
2887 @cindex glossary-style list, example markup [@code{ms}]
2889 @Example
2890 A glossary-style list:
2891 .IP lawyers 0.4i
2892 Two or more attorneys.
2893 .IP guns
2894 Firearms, preferably
2895 large-caliber.
2896 .IP money
2897 Gotta pay for those
2898 lawyers and guns!
2899 @endExample
2901 Produces:
2903 @Example
2904 A glossary-style list:
2906 lawyers
2907       Two or more attorneys.
2909 guns  Firearms, preferably large-caliber.
2911 money
2912       Gotta pay for those lawyers and guns!
2913 @endExample
2915 In the last example, the @code{IP} macro places the definition
2916 on the same line as the term if it has enough space; otherwise,
2917 it breaks to the next line and starts the definition below the
2918 term.
2919 This may or may not be the effect you want, especially if some
2920 of the definitions break and some do not.
2921 The following examples show two possible ways to force a break.
2923 The first workaround uses the @code{br}
2924 request to force a break after printing the term or label.
2926 @Example
2927 @cartouche
2928 A glossary-style list:
2929 .IP lawyers 0.4i
2930 Two or more attorneys.
2931 .IP guns
2933 Firearms, preferably large-caliber.
2934 .IP money
2935 Gotta pay for those lawyers and guns!
2936 @end cartouche
2937 @endExample
2939 @sp 1
2940 The second workaround uses the @code{\p} escape to force the break.
2941 Note the space following the escape; this is important.
2942 If you omit the space, @code{groff} prints the first word on
2943 the same line as the term or label (if it fits) @strong{then}
2944 breaks the line.
2946 @Example
2947 @cartouche
2948 A glossary-style list:
2949 .IP lawyers 0.4i
2950 Two or more attorneys.
2951 .IP guns
2952 \p Firearms, preferably large-caliber.
2953 .IP money
2954 Gotta pay for those lawyers and guns!
2955 @end cartouche
2956 @endExample
2958 @sp 1
2959 To set nested lists, use the @code{RS} and @code{RE} macros.
2960 @xref{Indents in ms}, for more information.
2961 @cindex @code{ms} macros, nested lists
2962 @cindex nested lists [@code{ms}]
2964 For example:
2966 @Example
2967 @cartouche
2968 .IP \[bu] 2
2969 Lawyers:
2971 .IP \[bu]
2972 Dewey,
2973 .IP \[bu]
2974 Cheatham,
2975 .IP \[bu]
2976 and Howe.
2978 .IP \[bu]
2979 Guns
2980 @end cartouche
2981 @endExample
2983 Produces:
2985 @Example
2986 o Lawyers:
2988   o  Dewey,
2990   o  Cheatham,
2992   o  and Howe.
2994 o Guns
2995 @endExample
2997 @c ---------------------------------------------------------------------
2999 @node Indents in ms, Tabstops in ms, Lists in ms, ms Body Text
3000 @subsubsection Indents
3002 In many situations,
3003 you may need to indent a section of text
3004 while still wrapping and filling.
3005 @xref{Lists in ms},
3006 for an example of nested lists.
3008 @DefmacList {RS, , ms}
3009 @DefmacListEnd {RE, , ms}
3010 These macros begin and end an indented section.
3011 The @code{PI} register controls the amount of indent,
3012 allowing the indented text to line up under hanging
3013 and indented paragraphs.
3014 @endDefmac
3016 @xref{ms Displays and Keeps},
3017 for macros to indent and turn off filling.
3019 @c ---------------------------------------------------------------------
3021 @node Tabstops in ms, ms Displays and Keeps, Indents in ms, ms Body Text
3022 @subsubsection Tab Stops
3024 Use the @code{ta} request to define tab stops as needed.
3025 @xref{Tabs and Fields}.
3027 @Defmac{TA, , ms}
3028 Use this macro to reset the tab stops to the default for @file{ms}
3029 (every 5n).
3030 You can redefine the @code{TA} macro to create a different set
3031 of default tab stops.
3032 @endDefmac
3034 @c ---------------------------------------------------------------------
3036 @node ms Displays and Keeps, ms Insertions, Tabstops in ms, ms Body Text
3037 @subsubsection Displays and keeps
3038 @cindex @code{ms} macros, displays
3039 @cindex @code{ms} macros, keeps
3040 @cindex keeps [@code{ms}]
3041 @cindex displays [@code{ms}]
3043 Use displays to show text-based examples or figures
3044 (such as code listings).
3046 Displays turn off filling, so lines of code are displayed
3047 as-is without inserting @code{br} requests in between each line.
3048 Displays can be @dfn{kept} on a single page, or allowed
3049 to break across pages.
3051 @DefmacList {DS, @t{L}, ms}
3052 @DefmacItem {LD, , ms}
3053 @DefmacListEnd {DE, , ms}
3054 Left-justified display.
3055 The @samp{.DS L} call generates a page break, if necessary,
3056 to keep the entire display on one page.
3057 The @code{LD} macro allows the display to break across pages.
3058 The @code{DE} macro ends the display.
3059 @endDefmac
3061 @DefmacList {DS, @t{I}, ms}
3062 @DefmacItem {ID, , ms}
3063 @DefmacListEnd {DE, , ms}
3064 Indents the display as defined by the @code{DI} register.
3065 The @samp{.DS I} call generates a page break, if necessary,
3066 to keep the entire display on one page.
3067 The @code{ID} macro allows the display to break across pages.
3068 The @code{DE} macro ends the display.
3069 @endDefmac
3071 @DefmacList {DS, @t{B}, ms}
3072 @DefmacItem {BD, , ms}
3073 @DefmacListEnd {DE, , ms}
3074 Sets a block-centered display: the entire display is left-justified,
3075 but indented so that the longest line in the display is centered
3076 on the page.
3077 The @samp{.DS B} call generates a page break, if necessary,
3078 to keep the entire display on one page.
3079 The @code{BD} macro allows the display to break across pages.
3080 The @code{DE} macro ends the display.
3081 @endDefmac
3083 @DefmacList {DS, @t{C}, ms}
3084 @DefmacItem {CD, , ms}
3085 @DefmacListEnd {DE, , ms}
3086 Sets a centered display: each line in the display is centered.
3087 The @samp{.DS C} call generates a page break, if necessary,
3088 to keep the entire display on one page.
3089 The @code{CD} macro allows the display to break across pages.
3090 The @code{DE} macro ends the display.
3091 @endDefmac
3093 @DefmacList {DS, @t{R}, ms}
3094 @DefmacItem {RD, , ms}
3095 @DefmacListEnd {DE, , ms}
3096 Right-justifies each line in the display.
3097 The @samp{.DS R} call generates a page break, if necessary,
3098 to keep the entire display on one page.
3099 The @code{RD} macro allows the display to break across pages.
3100 The @code{DE} macro ends the display.
3101 @endDefmac
3103 @sp 1
3104 On occasion, you may want to @dfn{keep} other text together on a page.
3105 For example, you may want to keep two paragraphs together, or
3106 a paragraph that refers to a table (or list, or other item)
3107 immediately following.
3108 The @file{ms} macros provide the @code{KS} and @code{KE}
3109 macros for this purpose.
3111 @DefmacList {KS, , ms}
3112 @DefmacListEnd {KE, , ms}
3113 The @code{KS} macro begins a block of text to be kept on a
3114 single page, and the @code{KE} macro ends the block.
3115 @endDefmac
3117 @DefmacList {KF, , ms}
3118 @DefmacListEnd {KE, , ms}
3119 Specifies a @dfn{floating keep};
3120 if the keep cannot fit on the current page, @code{groff}
3121 holds the contents of the keep and allows text following
3122 the keep (in the source file) to fill in the remainder of
3123 the current page.
3124 When the page breaks, whether by an explicit @code{bp}
3125 request or by reaching the end of the page, @code{groff}
3126 prints the floating keep at the top of the new page.
3127 This is useful for printing large graphics or tables
3128 that do not need to appear exactly where specified.
3129 @endDefmac
3131 You can also use the @code{ne} request to force a page break if
3132 there is not enough vertical space remaining on the page.
3134 @sp 1
3135 Use the following macros to draw a box around a section of
3136 text (such as a display).
3138 @DefmacList {B1, , ms}
3139 @DefmacListEnd {B2, , ms}
3140 Marks the beginning and ending of text that is to have a
3141 box drawn around it.
3142 The @code{B1} macro begins the box; the @code{B2} macro ends it.
3143 Text in the box is automatically placed in a diversion (keep).
3144 @endDefmac
3146 @c ---------------------------------------------------------------------
3148 @node ms Insertions, Example multi-page table, ms Displays and Keeps, ms Body Text
3149 @subsubsection Tables, figures, equations, and references
3150 @cindex @code{ms} macros, tables
3151 @cindex @code{ms} macros, figures
3152 @cindex @code{ms} macros, equations
3153 @cindex @code{ms} macros, references
3154 @cindex tables [@code{ms}]
3155 @cindex figures [@code{ms}]
3156 @cindex equations [@code{ms}]
3157 @cindex references [@code{ms}]
3159 The @file{ms} macros support the standard
3160 @code{groff} preprocessors:
3161 @code{tbl}, @code{pic}, @code{eqn}, and @code{refer}.
3162 @pindex tbl
3163 @pindex pic
3164 @pindex eqn
3165 @pindex refer
3166 You mark text meant for preprocessors by enclosing it
3167 in pairs of tags as follows.
3169 @DefmacList {TS, [@code{H}], ms}
3170 @DefmacListEnd {TE, , ms}
3171 Denotes a table, to be processed by the @code{tbl} preprocessor.
3172 The optional argument@w{ }@code{H} to @code{TS} instructs @code{groff}
3173 to create a running header with the information
3174 up to the @code{TH} macro.
3175 @code{groff} prints the header at the beginning of the
3176 table; if the table runs onto another page, @code{groff}
3177 prints the header on the next page as well.
3178 @endDefmac
3180 @DefmacList {PS, , ms}
3181 @DefmacListEnd {PE, , ms}
3182 Denotes a graphic, to be processed by the @code{pic} preprocessor.
3183 You can create a @code{pic} file by hand, using the @acronym{AT&T}
3184 @code{pic} manual available on the Web as a reference, or by using
3185 a graphics program such as @code{xfig}.
3186 @endDefmac
3188 @DefmacList {EQ, [@Var{align}], ms}
3189 @DefmacListEnd {EN, , ms}
3190 Denotes an equation, to be processed by the @code{eqn} preprocessor.
3191 The optional @var{align} argument can be @code{C}, @code{L}, or@w{
3192 }@code{I} to center (the default), left-justify, or indent the equation.
3193 @endDefmac
3195 @DefmacList {[, , ms}
3196 @DefmacListEnd {], , ms}
3197 Denotes a reference, to be processed by the @code{refer} preprocessor.
3198 The @acronym{GNU} @cite{refer(1)} man page provides a comprehensive
3199 reference to the preprocessor and the format of the bibliographic
3200 database.
3201 @endDefmac
3203 @menu
3204 * Example multi-page table::
3205 @end menu
3207 @c ---------------------------------------------------------------------
3209 @node Example multi-page table, ms Footnotes, ms Insertions, ms Body Text
3210 @subsubsection An example multi-page table
3211 @cindex example markup, multi-page table [@code{ms}]
3212 @cindex multi-page table, example markup [@code{ms}]
3214 The following is an example of how to set up a
3215 table that may print across two or more pages.
3217 @Example
3218 @cartouche
3219 .TS H
3220 allbox expand;
3221 cb | cb .
3222 Text      ...of heading...
3226 l | l .
3227 ... the rest of the table follows...
3230 @end cartouche
3231 @endExample
3233 @c ---------------------------------------------------------------------
3235 @node ms Footnotes,  , Example multi-page table, ms Body Text
3236 @subsubsection Footnotes
3237 @cindex @code{ms} macros, footnotes
3238 @cindex footnotes [@code{ms}]
3240 The @file{ms} macro package has a flexible footnote system.
3241 You can specify either numbered footnotes or symbolic footnotes
3242 (that is, using a marker such as a dagger symbol).
3244 @Defstr {*, ms}
3245 Specifies the location of a numbered footnote marker in the text.
3246 @endDefesc
3248 @DefmacList {FS, , ms}
3249 @DefmacListEnd {FE, , ms}
3250 Specifies the text of the footnote.
3251 The default action is to create a numbered footnote;
3252 you can create a symbolic footnote by specifying
3253 a @dfn{mark} glyph
3254 (such as @code{\[dg]} for the dagger glyph)
3255 in the body text and as an argument to the @code{FS} macro,
3256 followed by the text of the footnote
3257 and the @code{FE} macro.
3258 @endDefmac
3260 You can control how @code{groff}
3261 prints footnote numbers by changing the value of the
3262 @code{FF} register.  @xref{ms Document Control Registers}.
3264 @c ---------------------------------------------------------------------
3266 @node ms Page Layout, Differences from AT&T ms, ms Body Text, ms
3267 @subsection Page layout
3268 @cindex @code{ms} macros, page layout
3269 @cindex page layout [@code{ms}]
3271 The default output from the @file{ms}
3272 macros provides a minimalist page layout:
3273 it prints a single column, with the page number centered at the top
3274 of each page.
3275 It prints no footers.
3277 You can change the layout by setting
3278 the proper number registers and strings.
3280 @menu
3281 * ms Headers and Footers::
3282 * ms Margins::
3283 * ms Multiple Columns::
3284 * ms TOC::
3285 * ms Strings and Special Characters::
3286 @end menu
3288 @c ---------------------------------------------------------------------
3290 @node ms Headers and Footers, ms Margins, ms Page Layout, ms Page Layout
3291 @subsubsection Headers and footers
3292 @cindex @code{ms} macros, headers
3293 @cindex @code{ms} macros, footers
3294 @cindex headers [@code{ms}]
3295 @cindex footers [@code{ms}]
3297 For documents that do not distinguish between odd and even pages,
3298 set the following strings:
3300 @DefstrList {LH, ms}
3301 @DefstrItem {CH, ms}
3302 @DefstrListEnd {RH, ms}
3303 Sets the left, center, and right headers.
3304 @endDefstr
3306 @DefstrList {LF, ms}
3307 @DefstrItem {CF, ms}
3308 @DefstrListEnd {RF, ms}
3309 Sets the left, center, and right footers.
3310 @endDefstr
3312 @sp 1
3313 For documents that need different information printed in the
3314 even and odd pages, use the following macros:
3316 @DefmacList {OH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3317 @DefmacItem {EH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3318 @DefmacItem {OF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3319 @DefmacListEnd {EF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3320 The @code{OH} and @code{EH} macros define headers for the odd and even pages;
3321 the @code{OF} and @code{EF} macros define footers for the odd and even pages.
3322 This is more flexible than defining the individual strings.
3324 You can replace the quote (@code{'}) marks with any character not
3325 appearing in the header or footer text.
3326 @endDefmac
3328 @c ---------------------------------------------------------------------
3330 @node ms Margins, ms Multiple Columns, ms Headers and Footers, ms Page Layout
3331 @subsubsection Margins
3332 @cindex @code{ms} macros, margins
3334 You control margins using a set of number registers.
3335 @xref{ms Document Control Registers}, for details.
3337 @c ---------------------------------------------------------------------
3339 @node ms Multiple Columns, ms TOC, ms Margins, ms Page Layout
3340 @subsubsection Multiple columns
3341 @cindex @code{ms} macros, multiple columns
3342 @cindex multiple columns [@code{ms}]
3344 The @file{ms} macros can set text in as many columns as will
3345 reasonably fit on the page.
3346 The following macros are available;
3347 all of them force a page break if a multi-column mode is already set.
3348 However, if the current mode is single-column, starting a multi-column
3349 mode does @strong{not} force a page break.
3351 @Defmac {1C, , ms}
3352 Single-column mode.
3353 @endDefmac
3355 @Defmac {2C, , ms}
3356 Two-column mode.
3357 @endDefmac
3359 @Defmac {MC, [@Var{width} [@Var{gutter}]], ms}
3360 Multi-column mode.
3361 If you specify no arguments, it is equivalent to the
3362 @code{2C} macro.
3363 Otherwise, @var{width} is the width of each column and
3364 @var{gutter} is the space between columns.
3365 The @code{MINGW} number register controls the default gutter width.
3366 @endDefmac
3368 @c ---------------------------------------------------------------------
3370 @node ms TOC, ms Strings and Special Characters, ms Multiple Columns, ms Page Layout
3371 @subsubsection Creating a table of contents
3372 @cindex @code{ms} macros, creating table of contents
3373 @cindex table of contents, creating [@code{ms}]
3375 The facilities in the @file{ms} macro package for creating
3376 a table of contents are semi-automated at best.
3377 Assuming that you want the table of contents to consist of
3378 the document's headings, you need to repeat those headings
3379 wrapped in @code{XS} and @code{XE} macros.
3381 @DefmacList {XS, [@Var{page}], ms}
3382 @DefmacItem {XA, [@Var{page}], ms}
3383 @DefmacListEnd {XE, , ms}
3384 These macros define a table of contents
3385 or an individual entry in the table of contents,
3386 depending on their use.
3387 The macros are very simple; they cannot indent a heading based on its level.
3388 The easiest way to work around this is to add tabs
3389 to the table of contents string.
3390 The following is an example:
3392 @Example
3393 @cartouche
3394 .NH 1
3395 Introduction
3397 Introduction
3402 .NH 2
3403 Methodology
3405         Methodology
3409 @end cartouche
3410 @endExample
3412 You can manually create a table of contents
3413 by beginning with the @code{XS} macro for the first entry,
3414 specifying the page number for that entry as the argument to @code{XS}.
3415 Add subsequent entries using the @code{XA} macro,
3416 specifying the page number for that entry as the argument to @code{XA}.
3417 The following is an example:
3419 @Example
3420 @cartouche
3421 .XS 1
3422 Introduction
3423 .XA 2
3424 A Brief History of the Universe
3425 .XA 729
3426 Details of Galactic Formation
3429 @end cartouche
3430 @endExample
3431 @endDefmac
3433 @Defmac {TC, [@code{no}], ms}
3434 Prints the table of contents on a new page,
3435 setting the page number to@w{ }@strong{i} (Roman numeral one).
3436 You should usually place this macro at the end of the
3437 file, since @code{groff} is a single-pass formatter and
3438 can only print what has been collected up to the point
3439 that the @code{TC} macro appears.
3441 The optional argument @code{no} suppresses printing
3442 the title specified by the string register @code{TOC}.
3443 @endDefmac
3445 @Defmac{PX, [@code{no}], ms}
3446 Prints the table of contents on a new page,
3447 using the current page numbering sequence.
3448 Use this macro to print a manually-generated table of contents
3449 at the beginning of your document.
3451 The optional argument @code{no} suppresses printing
3452 the title specified by the string register @code{TOC}.
3453 @endDefmac
3455 The @cite{Groff and Friends HOWTO}
3456 includes a @code{sed} script that automatically inserts
3457 @code{XS} and @code{XE} macro entries after each heading in a document.
3459 Altering the @code{NH} macro to automatically build the table
3460 of contents is perhaps initially more difficult, but would save
3461 a great deal of time in the long run if you use @file{ms} regularly.
3463 @c ---------------------------------------------------------------------
3465 @node ms Strings and Special Characters,  , ms TOC, ms Page Layout
3466 @subsubsection Strings and Special Characters
3467 @cindex @code{ms} macros, strings
3468 @cindex @code{ms} macros, special characters
3469 @cindex @code{ms} macros, accent marks
3470 @cindex accent marks [@code{ms}]
3471 @cindex special characters [@code{ms}]
3472 @cindex strings [@code{ms}]
3474 The @file{ms} macros provide the following predefined strings.
3475 You can change the string definitions to help in creating
3476 documents in languages other than English.
3478 @Defstr {REFERENCES, ms}
3479 Contains the string printed at the beginning of the
3480 references (bibliography) page.
3481 The default is @samp{References}.
3482 @endDefstr
3484 @Defstr {ABSTRACT, ms}
3485 Contains the string printed at the beginning of the abstract.
3486 The default is @samp{ABSTRACT}.
3487 @endDefstr
3489 @Defstr {TOC, ms}
3490 Contains the string printed at the beginning of the table of contents.
3491 @endDefstr
3493 @DefstrList {MONTH1, ms}
3494 @DefstrItem {MONTH2, ms}
3495 @DefstrItem {MONTH3, ms}
3496 @DefstrItem {MONTH4, ms}
3497 @DefstrItem {MONTH5, ms}
3498 @DefstrItem {MONTH6, ms}
3499 @DefstrItem {MONTH7, ms}
3500 @DefstrItem {MONTH8, ms}
3501 @DefstrItem {MONTH9, ms}
3502 @DefstrItem {MONTH10, ms}
3503 @DefstrItem {MONTH11, ms}
3504 @DefstrListEnd {MONTH12, ms}
3505 Prints the full name of the month in dates.
3506 The default is @samp{January}, @samp{February}, etc.
3507 @endDefstr
3509 The following special characters are available@footnote{For an
3510 explanation what special characters are see @ref{Special Characters}.}:
3512 @Defstr {-, ms}
3513 Prints an em dash.
3514 @endDefstr
3516 @DefstrList {*Q, ms}
3517 @DefstrListEnd {*U, ms}
3518 Prints typographer's quotes in troff,
3519 plain quotes in nroff.
3520 @code{*Q} is the left quote and @code{*U} is the right quote.
3521 @endDefstr
3523 Improved accent marks are available in the @file{ms} macros.
3525 @Defmac {AM, , ms}
3526 Specify this macro at the beginning of your document
3527 to enable extended accent marks and special characters.
3528 This is a Berkeley extension.
3530 To use the accent marks, place them @strong{after}
3531 the character being accented.
3532 @endDefmac
3534 The following accent marks are available
3535 after invoking the @code{AM} macro:
3537 @Defstr {\', ms}
3538 Acute accent.
3539 @endDefstr
3541 @Defstr {\`, ms}
3542 Grave accent.
3543 @endDefstr
3545 @Defstr {^, ms}
3546 Circumflex.
3547 @endDefstr
3549 @Defstr {\,, ms}
3550 Cedilla.
3551 @endDefstr
3553 @Defstr {~, ms}
3554 Tilde.
3555 @endDefstr
3557 @deffn String @t{\*[:]}
3558 @ifnotinfo
3559 @stindex : @r{[}ms@r{]}
3560 @end ifnotinfo
3561 @ifinfo
3562 @stindex @r{<colon>} @r{[}ms@r{]}
3563 @end ifinfo
3564 Umlaut.
3565 @end deffn
3567 @Defstr {v, ms}
3568 Hacek.
3569 @endDefstr
3571 @Defstr {_, ms}
3572 Macron (overbar).
3573 @endDefstr
3575 @Defstr {., ms}
3576 Underdot.
3577 @endDefstr
3579 @Defstr {o, ms}
3580 Ring above.
3581 @endDefstr
3583 The following are standalone characters
3584 available after invoking the @code{AM} macro:
3586 @Defstr {?, ms}
3587 Upside-down question mark.
3588 @endDefstr
3590 @Defstr {!, ms}
3591 Upside-down exclamation point.
3592 @endDefstr
3594 @Defstr {8, ms}
3595 German @ss{} ligature.
3596 @endDefstr
3598 @Defstr {3, ms}
3599 Yogh.
3600 @endDefstr
3602 @Defstr {Th, ms}
3603 Uppercase thorn.
3604 @endDefstr
3606 @Defstr {th, ms}
3607 Lowercase thorn.
3608 @endDefstr
3610 @Defstr {D-, ms}
3611 Uppercase eth.
3612 @endDefstr
3614 @Defstr {d-, ms}
3615 Lowercase eth.
3616 @endDefstr
3618 @Defstr {q, ms}
3619 Hooked o.
3620 @endDefstr
3622 @Defstr {ae, ms}
3623 Lowercase @ae{} ligature.
3624 @endDefstr
3626 @Defstr {Ae, ms}
3627 Uppercase @AE{} ligature.
3628 @endDefstr
3630 @c ---------------------------------------------------------------------
3632 @node Differences from AT&T ms,  , ms Page Layout, ms
3633 @subsection Differences from @acronym{AT&T} @file{ms}
3634 @cindex @code{ms} macros, differences from @acronym{AT&T}
3635 @cindex @acronym{AT&T} @code{troff}, @code{ms} macro package differences
3637 This section lists the (minor) differences between the
3638 @code{groff -ms} macros and @acronym{AT&T}
3639 @code{troff -ms} macros.
3641 @menu
3642 * Missing ms Macros::
3643 * Additional ms Macros::
3644 @end menu
3646 @c ---------------------------------------------------------------------
3648 @node Missing ms Macros, Additional ms Macros, Differences from AT&T ms, Differences from AT&T ms
3649 @subsubsection @code{troff} macros not appearing in @code{groff}
3651 Macros missing from @code{groff -ms}
3652 are cover page macros specific to Bell Labs.
3653 The macros known to be missing are:
3655 @table @code
3656 @item .TM
3657 Technical memorandum; a cover sheet style
3659 @item .IM
3660 Internal memorandum; a cover sheet style
3662 @item .MR
3663 Memo for record; a cover sheet style
3665 @item .MF
3666 Memo for file; a cover sheet style
3668 @item .EG
3669 Engineer's notes; a cover sheet style
3671 @item .TR
3672 Computing Science Tech Report; a cover sheet style
3674 @item .OK
3675 Other keywords
3677 @item .CS
3678 Cover sheet information
3680 @item .MH
3681 A cover sheet macro
3682 @end table
3684 @c ---------------------------------------------------------------------
3686 @node Additional ms Macros,  , Missing ms Macros, Differences from AT&T ms
3687 @subsubsection @code{groff} macros not appearing in @acronym{AT&T} @code{troff}
3689 The @code{groff -ms} macros have a few minor extensions
3690 compared to the @acronym{AT&T} @code{troff -ms} macros.
3692 @Defmac {AM, , ms}
3693 Improved accent marks.
3694 @xref{ms Strings and Special Characters}, for details.
3695 @endDefmac
3697 @Defmac {DS, @t{I}, ms}
3698 Indented display.
3699 The default behavior of @acronym{AT&T} @code{troff -ms}
3700 was to indent; the @code{groff} default prints displays
3701 flush left with the body text.
3702 @endDefmac
3704 @Defmac {CW, , ms}
3705 Print text in @code{constant width} (Courier) font.
3706 @endDefmac
3708 @Defmac {IX, , ms}
3709 Indexing term (printed on standard error).
3710 You can write a script to capture and process an index
3711 generated in this manner.
3712 @endDefmac
3714 @sp 1
3715 The following additional number registers
3716 appear in @code{groff -ms}:
3718 @Defmpreg {MINGW, ms}
3719 Specifies a minimum space
3720 between columns (for multi-column output); this takes the
3721 place of the @code{GW} register that was documented but apparently
3722 not implemented in @acronym{AT&T} @code{troff}.
3723 @endDefmpreg
3725 @sp 1
3726 Several new string registers are available as well.
3727 You can change these to handle (for example) the local language.
3728 @xref{ms Strings and Special Characters}, for details.
3731 @c =====================================================================
3733 @node me, mm, ms, Macro Packages
3734 @section @file{me}
3735 @cindex @code{me} macro package
3737 @c XXX documentation
3738 @c XXX this is a placeholder until we get stuff knocked into shape
3739 See the @file{meintro.me} and @file{meref.me} documents in
3740 groff's @file{doc} directory.
3743 @c =====================================================================
3745 @node mm,  , me, Macro Packages
3746 @section @file{mm}
3747 @cindex @code{mm} macro package
3749 @c XXX documentation
3750 @c XXX this is a placeholder until we get stuff knocked into shape
3751 See the @cite{groff_mm(7)} man page (type @command{man groff_mm} at
3752 the command line).
3755 @c =====================================================================
3756 @c =====================================================================
3758 @node gtroff Reference, Preprocessors, Macro Packages, Top
3759 @chapter @code{gtroff} Reference
3760 @cindex reference, @code{gtroff}
3761 @cindex @code{gtroff}, reference
3763 This chapter covers @strong{all} of the facilities of @code{gtroff}.
3764 Users of macro packages may skip it if not interested in details.
3767 @menu
3768 * Text::
3769 * Input Conventions::
3770 * Measurements::
3771 * Expressions::
3772 * Identifiers::
3773 * Embedded Commands::
3774 * Registers::
3775 * Manipulating Filling and Adjusting::
3776 * Manipulating Hyphenation::
3777 * Manipulating Spacing::
3778 * Tabs and Fields::
3779 * Character Translations::
3780 * Troff and Nroff Mode::
3781 * Line Layout::
3782 * Line Control::
3783 * Page Layout::
3784 * Page Control::
3785 * Fonts::
3786 * Sizes::
3787 * Strings::
3788 * Conditionals and Loops::
3789 * Writing Macros::
3790 * Page Motions::
3791 * Drawing Requests::
3792 * Traps::
3793 * Diversions::
3794 * Environments::
3795 * Suppressing output::
3796 * Colors::
3797 * I/O::
3798 * Postprocessor Access::
3799 * Miscellaneous::
3800 * Gtroff Internals::
3801 * Debugging::
3802 * Implementation Differences::
3803 @end menu
3806 @c =====================================================================
3808 @node Text, Input Conventions, gtroff Reference, gtroff Reference
3809 @section Text
3810 @cindex text, @code{gtroff} processing
3812 @code{gtroff} input files contain text with control commands
3813 interspersed throughout.  But, even without control codes, @code{gtroff}
3814 still does several things with the input text:
3816 @itemize @bullet
3817 @item
3818 filling and adjusting
3820 @item
3821 adding additional space after sentences
3823 @item
3824 hyphenating
3826 @item
3827 inserting implicit line breaks
3828 @end itemize
3830 @menu
3831 * Filling and Adjusting::
3832 * Hyphenation::
3833 * Sentences::
3834 * Tab Stops::
3835 * Implicit Line Breaks::
3836 @end menu
3838 @c ---------------------------------------------------------------------
3840 @node Filling and Adjusting, Hyphenation, Text, Text
3841 @subsection Filling and Adjusting
3842 @cindex filling
3843 @cindex adjusting
3845 When @code{gtroff} reads text, it collects words from the input and fits
3846 as many of them together on one output line as it can.  This is known as
3847 @dfn{filling}.
3849 @cindex leading spaces
3850 @cindex spaces, leading and trailing
3851 @cindex extra spaces
3852 @cindex trailing spaces
3853 Once @code{gtroff} has a @dfn{filled} line, it tries to @dfn{adjust}
3854 it.  This means it widens the spacing between words until the text
3855 reaches the right margin (in the default adjustment mode).  Extra spaces
3856 between words are preserved, but spaces at the end of lines are ignored.
3857 Spaces at the front of a line cause a @dfn{break} (breaks are
3858 explained in @ref{Implicit Line Breaks}).
3860 @xref{Manipulating Filling and Adjusting}.
3862 @c ---------------------------------------------------------------------
3864 @node Hyphenation, Sentences, Filling and Adjusting, Text
3865 @subsection Hyphenation
3866 @cindex hyphenation
3868 Since the odds are not great for finding a set of words, for every
3869 output line, which fit nicely on a line without inserting excessive
3870 amounts of space between words, @code{gtroff} hyphenates words so
3871 that it can justify lines without inserting too much space between
3872 words.  It uses an internal hyphenation algorithm (a simplified version
3873 of the algorithm used within @TeX{}) to indicate which words can be
3874 hyphenated and how to do so.  When a word is hyphenated, the first part
3875 of the word is added to the current filled line being output (with
3876 an attached hyphen), and the other portion is added to the next
3877 line to be filled.
3879 @xref{Manipulating Hyphenation}.
3881 @c ---------------------------------------------------------------------
3883 @node Sentences, Tab Stops, Hyphenation, Text
3884 @subsection Sentences
3885 @cindex sentences
3887 Although it is often debated, some typesetting rules say there should be
3888 different amounts of space after various punctuation marks.  For
3889 example, the @cite{Chicago typsetting manual} says that a period at the
3890 end of a sentence should have twice as much space following it as would
3891 a comma or a period as part of an abbreviation.
3893 @c XXX exact citation of Chicago manual
3895 @cindex sentence space
3896 @cindex space between sentences
3897 @cindex french-spacing
3898 @code{gtroff} does this by flagging certain characters (normally
3899 @samp{!}, @samp{?}, and @samp{.}) as @dfn{end-of-sentence} characters.
3900 When @code{gtroff} encounters one of these characters at the end of a
3901 line, it appends a normal space followed by a @dfn{sentence space} in
3902 the formatted output.  (This justifies one of the conventions mentioned
3903 in @ref{Input Conventions}.)
3905 @cindex transparent characters
3906 @cindex character, transparent
3907 @cindex @code{dg} glyph, at end of sentence
3908 @cindex @code{rq} glyph, 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 @cindex @code{]}, at end of sentence
3913 @cindex @code{*}, at end of sentence
3914 In addition, the following characters and symbols are treated
3915 transparently while handling end-of-sentence characters: @samp{"},
3916 @samp{'}, @samp{)}, @samp{]}, @samp{*}, @code{\[dg]}, and @code{\[rq]}.
3918 See the @code{cflags} request in @ref{Using Symbols}, for more details.
3920 @cindex @code{\&}, at end of sentence
3921 To prevent the insertion of extra space after an end-of-sentence
3922 character (at the end of a line), append @code{\&}.
3924 @c ---------------------------------------------------------------------
3926 @node Tab Stops, Implicit Line Breaks, Sentences, Text
3927 @subsection Tab Stops
3928 @cindex tab stops
3929 @cindex stops, tabulator
3930 @cindex tab character
3931 @cindex character, tabulator
3933 @cindex @acronym{EBCDIC} encoding
3934 @cindex encoding, @acronym{EBCDIC}
3935 @code{gtroff} translates @dfn{tabulator characters}, also called
3936 @dfn{tabs} (normally code point @acronym{ASCII} @code{0x09} or
3937 @acronym{EBCDIC} @code{0x05}), in the input into movements to the next
3938 tabulator stop.  These tab stops are initially located every half inch
3939 across the page.  Using this, simple tables can be made easily.
3940 However, it can often be deceptive as the appearance (and width) of the
3941 text on a terminal and the results from @code{gtroff} can vary greatly.
3943 Also, a possible sticking point is that lines beginning with tab
3944 characters are still filled, again producing unexpected results.
3945 For example, the following input
3947 @multitable {12345678} {12345678} {12345678} {12345678}
3948 @item
3949 @tab 1 @tab 2 @tab 3
3950 @item
3951 @tab   @tab 4 @tab 5
3952 @end multitable
3954 @noindent
3955 produces
3957 @multitable {12345678} {12345678} {12345678} {12345678} {12345678} {12345678} {12345678}
3958 @item
3959 @tab 1 @tab 2 @tab 3 @tab   @tab 4 @tab 5
3960 @end multitable
3962 @xref{Tabs and Fields}.
3964 @c ---------------------------------------------------------------------
3966 @node Implicit Line Breaks,  , Tab Stops, Text
3967 @subsection Implicit Line Breaks
3968 @cindex implicit line breaks
3969 @cindex implicit breaks of lines
3970 @cindex line, implicit breaks
3971 @cindex break, implicit
3972 @cindex line break
3974 An important concept in @code{gtroff} is the @dfn{break}.  When a break
3975 occurs, @code{gtroff} outputs the partially filled line
3976 (unjustified), and resumes collecting and filling text on the next output
3977 line.
3979 @cindex blank line
3980 @cindex empty line
3981 @cindex line, blank
3982 @cindex blank line macro (@code{blm})
3983 There are several ways to cause a break in @code{gtroff}.  A blank
3984 line not only causes a break, but it also outputs a one-line vertical
3985 space (effectively a blank line).  Note that this behaviour can be
3986 modified with the blank line macro request @code{blm}.
3987 @xref{Blank Line Traps}.
3989 @cindex fill mode
3990 @cindex mode, fill
3991 A line that begins with a space causes a break and the space is
3992 output at the beginning of the next line.  Note that this space isn't
3993 adjusted, even in fill mode.
3995 The end of file also causes a break -- otherwise the last line of
3996 the document may vanish!
3998 Certain requests also cause breaks, implicitly or explicitly.  This is
3999 discussed in @ref{Manipulating Filling and Adjusting}.
4002 @c =====================================================================
4004 @node Input Conventions, Measurements, Text, gtroff Reference
4005 @section Input Conventions
4006 @cindex input conventions
4007 @cindex conventions for input
4009 Since @code{gtroff} does filling automatically, it is traditional in
4010 @code{groff} not to try and type things in as nicely formatted
4011 paragraphs.  These are some conventions commonly used when typing
4012 @code{gtroff} text:
4014 @itemize @bullet
4015 @item
4016 Break lines after punctuation, particularly at the end of a sentence
4017 and in other logical places.  Keep separate phrases on lines by
4018 themselves, as entire phrases are often added or deleted when editing.
4020 @item
4021 Try to keep lines less than 40-60@w{ }characters, to allow space for
4022 inserting more text.
4024 @item
4025 Do not try to do any formatting in a @acronym{WYSIWYG} manner (i.e.,
4026 don't try using spaces to get proper indentation).
4027 @end itemize
4030 @c =====================================================================
4032 @node Measurements, Expressions, Input Conventions, gtroff Reference
4033 @section Measurements
4034 @cindex measurements
4036 @cindex units of measurement
4037 @cindex basic unit (@code{u})
4038 @cindex machine unit (@code{u})
4039 @cindex measurement unit
4040 @cindex @code{u} unit
4041 @cindex unit, @code{u}
4042 @code{gtroff} (like many other programs) requires numeric parameters to
4043 specify various measurements.  Most numeric parameters@footnote{those
4044 that specify vertical or horizontal motion or a type size} may have a
4045 @dfn{measurement unit} attached.  These units are specified as a single
4046 character which immediately follows the number or expression.  Each of
4047 these units are understood, by @code{gtroff}, to be a multiple of its
4048 @dfn{basic unit}.  So, whenever a different measurement unit is
4049 specified @code{gtroff} converts this into its @dfn{basic units}.  This
4050 basic unit, represented by a @samp{u}, is a device dependent measurement
4051 which is quite small, ranging from 1/75@dmn{th} to 1/72000@dmn{th} of an
4052 inch.  The values may be given as fractional numbers; however,
4053 fractional basic units are always rounded to integers.
4055 Some of the measurement units are completely independent of any of the
4056 current settings (e.g.@: type size) of @code{gtroff}.
4058 @table @code
4059 @item i
4060 @cindex inch unit (@code{i})
4061 @cindex @code{i} unit
4062 @cindex unit, @code{i}
4063 Inches.  An antiquated measurement unit still in use in certain
4064 backwards countries with incredibly low-cost computer equipment.  One
4065 inch is equal to@w{ }2.54@dmn{cm}.
4067 @item c
4068 @cindex centimeter unit (@code{c})
4069 @cindex @code{c} unit
4070 @cindex unit, @code{c}
4071 Centimeters.  One centimeter is equal to@w{ }0.3937@dmn{in}.
4073 @item p
4074 @cindex point unit (@code{p})
4075 @cindex @code{p} unit
4076 @cindex unit, @code{p}
4077 Points.  This is a typesetter's measurement used for measure type size.
4078 It is 72@w{ }points to an inch.
4080 @item P
4081 @cindex pica unit (@code{P})
4082 @cindex @code{P} unit
4083 @cindex unit, @code{P}
4084 Pica.  Another typesetting measurement.  6@w{ }Picas to an inch (and
4085 12@w{ }points to a pica).
4087 @item s
4088 @itemx z
4089 @cindex @code{s} unit
4090 @cindex unit, @code{s}
4091 @cindex @code{z} unit
4092 @cindex unit, @code{z}
4093 @xref{Fractional Type Sizes}, for a discussion of these units.
4095 @item f
4096 @cindex @code{f} unit
4097 @cindex unit, @code{f}
4098 Fractions. Value is 65536.
4099 @xref{Colors}, for usage.
4100 @end table
4102 The other measurements understood by @code{gtroff} depend on
4103 settings currently in effect in @code{gtroff}.  These are very useful
4104 for specifying measurements which should look proper with any size of
4105 text.
4107 @table @code
4108 @item m
4109 @cindex em unit (@code{m})
4110 @cindex @code{m} unit
4111 @cindex unit, @code{m}
4112 Ems.  This unit is equal to the current font size in points.  So called
4113 because it is @emph{approximately} the width of the letter@w{ }@samp{m}
4114 in the current font.
4116 @item n
4117 @cindex en unit (@code{n})
4118 @cindex @code{n} unit
4119 @cindex unit, @code{n}
4120 Ens.  In @code{groff}, this is half of an em.
4122 @item v
4123 @cindex vertical space unit (@code{v})
4124 @cindex space, vertical, unit (@code{v})
4125 @cindex @code{v} unit
4126 @cindex unit, @code{v}
4127 Vertical space.  This is equivalent to the current line spacing.
4128 @xref{Sizes}, for more information about this.
4130 @item M
4131 @cindex @code{M} unit
4132 @cindex unit, @code{M}
4133 100ths of an em.
4134 @end table
4136 @menu
4137 * Default Units::
4138 @end menu
4140 @c ---------------------------------------------------------------------
4142 @node Default Units,  , Measurements, Measurements
4143 @subsection Default Units
4144 @cindex default units
4145 @cindex units, default
4147 Many requests take a default unit.  While this can be helpful at times,
4148 it can cause strange errors in some expressions.  For example, the line
4149 length request expects em units.  Here are several attempts to get a
4150 line length of 3.5@w{ }inches and their results:
4152 @Example
4153 3.5i      @result{}   3.5i
4154 7/2       @result{}   0i
4155 7/2i      @result{}   0i
4156 (7 / 2)u  @result{}   0i
4157 7i/2      @result{}   0.1i
4158 7i/2u     @result{}   3.5i
4159 @endExample
4161 @noindent
4162 Everything is converted to basic units first.  In the above example it
4163 is assumed that 1@dmn{i} equals@w{ }240@dmn{u}, and 1@dmn{m} equals@w{
4164 }10@dmn{p} (thus 1@dmn{m} equals@w{ }33@dmn{u}).  The value 7@dmn{i}/2
4165 is first handled as 7@dmn{i}/2@dmn{m}, then converted to
4166 1680@dmn{u}/66@dmn{u} which is 25@dmn{u}, and this is approximately
4167 0.1@dmn{i}.  As can be seen, a scaling indicator after a closing
4168 parenthesis is simply ignored.
4170 @cindex measurements, specifying safely
4171 Thus, the safest way to specify measurements is to always
4172 attach a scaling indicator.  If you want to multiply or divide by a
4173 certain scalar value, use @samp{u} as the unit for that value.
4176 @c =====================================================================
4178 @node Expressions, Identifiers, Measurements, gtroff Reference
4179 @section Expressions
4180 @cindex expressions
4182 @code{gtroff} has most arithmetic operators common to other languages:
4184 @itemize @bullet
4185 @item
4186 @cindex arithmetic operators
4187 @cindex operators, arithmetic
4188 @opindex +
4189 @opindex -
4190 @opindex /
4191 @opindex *
4192 @opindex %
4193 Arithmetic: @samp{+} (addition), @samp{-} (subtraction), @samp{/}
4194 (division), @samp{*} (multiplication), @samp{%} (modulo).
4196 @code{gtroff} only provides integer arithmetic.  The internal type used
4197 for computing results is @samp{int}, which is usually a 32@dmn{bit}
4198 signed integer.
4200 @item
4201 @cindex comparison operators
4202 @cindex operators, comparison
4203 @opindex <
4204 @opindex >
4205 @opindex >=
4206 @opindex <=
4207 @opindex =
4208 @opindex ==
4209 Comparison: @samp{<} (less than), @samp{>} (greater than), @samp{<=}
4210 (less than or equal), @samp{>=} (greater than or equal), @samp{=}
4211 (equal), @samp{==} (the same as @samp{=}).
4213 @item
4214 @cindex logical operators
4215 @cindex operators, logical
4216 @opindex &
4217 @ifnotinfo
4218 @opindex :
4219 @end ifnotinfo
4220 @ifinfo
4221 @opindex @r{<colon>}
4222 @end ifinfo
4223 Logical: @samp{&} (logical and), @samp{:} (logical or).
4225 @item
4226 @cindex unary operators
4227 @cindex operators, unary
4228 @opindex -
4229 @opindex +
4230 @opindex !
4231 @cindex @code{if} request, and the @samp{!} operator
4232 @cindex @code{while} request, and the @samp{!} operator
4233 Unary operators: @samp{-} (negating, i.e.@: changing the sign), @samp{+}
4234 (just for completeness; does nothing in expressions), @samp{!} (logical
4235 not; this works only within @code{if} and @code{while} requests).  See
4236 below for the use of unary operators in motion requests.
4238 @item
4239 @cindex extremum operators (@code{>?}, @code{<?})
4240 @cindex operators, extremum (@code{>?}, @code{<?})
4241 @opindex >?
4242 @opindex <?
4243 Extrema: @samp{>?} (maximum), @samp{<?} (minimum).
4245 Example:
4247 @Example
4248 .nr x 5
4249 .nr y 3
4250 .nr z (\n[x] >? \n[y])
4251 @endExample
4253 @noindent
4254 The register@w{ }@code{z} now contains@w{ }5.
4256 @item
4257 @cindex scaling operator
4258 @cindex operator, scaling
4259 Scaling: @code{(@var{c};@var{e})}.  Evaluate@w{ }@var{e} using@w{ }@var{c}
4260 as the default scaling indicator.  If @var{c} is missing, ignore scaling
4261 indicators in the evaluation of@w{ }@var{e}.
4262 @end itemize
4264 @cindex parentheses
4265 @cindex order of evaluation in expressions
4266 @cindex expression, order of evaluation
4267 @opindex (
4268 @opindex )
4269 Parentheses may be used as in any other language.  However, in
4270 @code{gtroff} they are necessary to ensure order of evaluation.
4271 @code{gtroff} has no operator precedence; expressions are evaluated left
4272 to right.  This means that @code{gtroff} evaluates @samp{3+5*4} as if it were
4273 parenthesized like @samp{(3+5)*4}, not as @samp{3+(5*4)}, as might be
4274 expected.
4276 @cindex @code{+}, and page motion
4277 @cindex @code{-}, and page motion
4278 @cindex motion operators
4279 @cindex operators, motion
4280 For many requests which cause a motion on the page, the unary operators
4281 @samp{+} and @samp{-} work differently if leading an expression.  They
4282 then indicate a motion relative to the current position (down or up,
4283 respectively).
4285 @cindex @code{|}, and page motion
4286 @cindex absolute position operator (@code{|})
4287 @cindex position, absolute, operator (@code{|})
4288 Similarly, a leading @samp{|} operator indicates an absolute position.
4289 For vertical movements, it specifies the distance from the top of the
4290 page; for horizontal movements, it gives the distance from the beginning
4291 of the @emph{input} line.
4293 @cindex @code{bp} request, using @code{+} and@w{ }@code{-}
4294 @cindex @code{in} request, using @code{+} and@w{ }@code{-}
4295 @cindex @code{ll} request, using @code{+} and@w{ }@code{-}
4296 @cindex @code{lt} request, using @code{+} and@w{ }@code{-}
4297 @cindex @code{nm} request, using @code{+} and@w{ }@code{-}
4298 @cindex @code{nr} request, using @code{+} and@w{ }@code{-}
4299 @cindex @code{pl} request, using @code{+} and@w{ }@code{-}
4300 @cindex @code{pn} request, using @code{+} and@w{ }@code{-}
4301 @cindex @code{po} request, using @code{+} and@w{ }@code{-}
4302 @cindex @code{ps} request, using @code{+} and@w{ }@code{-}
4303 @cindex @code{pvs} request, using @code{+} and@w{ }@code{-}
4304 @cindex @code{rt} request, using @code{+} and@w{ }@code{-}
4305 @cindex @code{ti} request, using @code{+} and@w{ }@code{-}
4306 @cindex @code{\H}, using @code{+} and@w{ }@code{-}
4307 @cindex @code{\R}, using @code{+} and@w{ }@code{-}
4308 @cindex @code{\s}, using @code{+} and@w{ }@code{-}
4309 @samp{+} and @samp{-} are also treated differently by the following
4310 requests and escapes: @code{bp}, @code{in}, @code{ll}, @code{lt},
4311 @code{nm}, @code{nr}, @code{pl}, @code{pn}, @code{po}, @code{ps},
4312 @code{pvs}, @code{rt}, @code{ti}, @code{\H}, @code{\R}, and @code{\s}.
4313 Here, leading plus and minus signs indicate increments and decrements.
4315 @xref{Setting Registers}, for some examples.
4317 @Defesc {\\B, ', anything, '}
4318 @cindex numeric expression, valid
4319 @cindex valid numeric expression
4320 Return@w{ }1 if @var{anything} is a valid numeric expression;
4321 or@w{ }0 if @var{anything} is empty or not a valid numeric expression.
4322 @endDefesc
4324 @cindex space characters, in expressions
4325 @cindex expressions, and space characters
4326 Due to the way arguments are parsed, spaces are not allowed in
4327 expressions, unless the entire expression is surrounded by parentheses.
4329 @xref{Request Arguments}, and @ref{Conditionals and Loops}.
4332 @c =====================================================================
4334 @node Identifiers, Embedded Commands, Expressions, gtroff Reference
4335 @section Identifiers
4336 @cindex identifiers
4338 Like any other language, @code{gtroff} has rules for properly formed
4339 @dfn{identifiers}.  In @code{gtroff}, an identifier can be made up of
4340 almost any printable character, with the exception of the following
4341 characters:
4343 @itemize @bullet
4344 @item
4345 @cindex whitespace characters
4346 @cindex newline character
4347 @cindex character, whitespace
4348 Whitespace characters (spaces, tabs, and newlines).
4350 @item
4351 @cindex character, backspace
4352 @cindex backspace character
4353 @cindex @acronym{EBCDIC} encoding of backspace
4354 Backspace (@acronym{ASCII}@w{ }@code{0x08} or @acronym{EBCDIC}@w{
4355 }@code{0x16}) and character code @code{0x01}.
4357 @item
4358 @cindex invalid input characters
4359 @cindex input characters, invalid
4360 @cindex characters, invalid input
4361 @cindex Unicode
4362 The following input characters are invalid and are ignored if
4363 @code{groff} runs on a machine based on @acronym{ASCII}, causing a
4364 warning message of type @samp{input} (see @ref{Debugging}, for more
4365 details): @code{0x00}, @code{0x0B}, @code{0x0D}-@code{0x1F},
4366 @code{0x80}-@code{0x9F}.
4368 And here are the invalid input characters if @code{groff} runs on an
4369 @acronym{EBCDIC} host: @code{0x00}, @code{0x08}, @code{0x09},
4370 @code{0x0B}, @code{0x0D}-@code{0x14}, @code{0x17}-@code{0x1F},
4371 @code{0x30}-@code{0x3F}.
4373 Currently, some of these reserved codepoints are used internally, thus
4374 making it non-trivial to extend @code{gtroff} to cover Unicode or other
4375 character sets and encodings which use characters of these ranges.
4377 Note that invalid characters are removed before parsing; an
4378 identifier @code{foo}, followed by an invalid character, followed by
4379 @code{bar} is treated as @code{foobar}.
4380 @end itemize
4382 For example, any of the following is valid.
4384 @Example
4388 end-list
4390 @endExample
4392 @cindex @code{]}, as part of an identifier
4393 @noindent
4394 Note that identifiers longer than two characters with a closing bracket
4395 (@samp{]}) in its name can't be accessed with escape sequences which
4396 expect an identifier as a parameter.  For example, @samp{\[foo]]}
4397 accesses the glyph @samp{foo}, followed by @samp{]}, whereas
4398 @samp{\C'foo]'} really asks for glyph @samp{foo]}.
4400 @cindex @code{refer}, and macro names starting with @code{[} or @code{]}
4401 @cindex @code{[}, macro names starting with, and @code{refer}
4402 @cindex @code{]}, macro names starting with, and @code{refer}
4403 @cindex macro names, starting with @code{[} or @code{]}, and @code{refer}
4404 To avoid problems with the @code{refer} preprocessor, macro names
4405 should not start with @samp{[} or @samp{]}.  Due to backwards
4406 compatibility, everything after @samp{.[} and @samp{.]} is handled as
4407 a special argument to @code{refer}.  For example, @samp{.[foo} makes
4408 @code{refer} to start a reference, using @samp{foo} as a parameter.
4410 @Defesc {\\A, ', ident, '}
4411 Test whether an identifier @var{ident} is valid in @code{gtroff}.  It
4412 expands to the character@w{ }1 or@w{ }0 according to whether its
4413 argument (usually delimited by quotes) is or is not acceptable as the
4414 name of a string, macro, diversion, number register, environment, or
4415 font.  It returns@w{ }0 if no argument is given.  This is useful for
4416 looking up user input in some sort of associative table.
4418 @Example
4419 \A'end-list'
4420     @result{} 1
4421 @endExample
4422 @endDefesc
4424 @xref{Escapes}, for details on parameter delimiting characters.
4426 Identifiers in @code{gtroff} can be any length, but, in some contexts,
4427 @code{gtroff} needs to be told where identifiers end and text begins
4428 (and in different ways depending on their length):
4430 @itemize @bullet
4431 @item
4432 Single character.
4434 @cindex @code{(}, starting a two-character identifier
4435 @item
4436 Two characters.  Must be prefixed with @samp{(} in some situations.
4438 @cindex @code{[}, starting an identifier
4439 @cindex @code{]}, ending an identifier
4440 @item
4441 Arbitrary length (@code{gtroff} only).  Must be bracketed with @samp{[}
4442 and@w{ }@samp{]} in some situations.  Any length identifier can be put
4443 in brackets.
4444 @end itemize
4446 @cindex undefined identifiers
4447 @cindex identifiers, undefined
4448 Unlike many other programming languages, undefined identifiers are
4449 silently ignored or expanded to nothing.
4450 When @code{gtroff} finds an undefined identifier, it emits a
4451 warning, doing the following:
4453 @itemize @bullet
4454 @item
4455 If the identifier is a string, macro, or diversion,
4456 @code{gtroff} defines it as empty.
4458 @item
4459 If the identifier is a number register, @code{gtroff}
4460 defines it with a value of@w{ }0.
4461 @end itemize
4463 @xref{Warnings}., @ref{Interpolating Registers}, and @ref{Strings}.
4465 Note that macros, strings, and diversions share the same name space.
4467 @Example
4468 .de xxx
4469 .  nop foo
4472 .di xxx
4477 .xxx
4478     @result{} bar
4479 @endExample
4481 @noindent
4482 As can be seen in the previous example, @code{gtroff} reuses the
4483 identifier @samp{xxx}, changing it from a macro to a diversion.
4484 No warning is emitted!  The contents of the first macro definition is
4485 lost.
4487 @xref{Interpolating Registers}, and @ref{Strings}.
4490 @c =====================================================================
4492 @node Embedded Commands, Registers, Identifiers, gtroff Reference
4493 @section Embedded Commands
4494 @cindex embedded commands
4495 @cindex commands, embedded
4497 Most documents need more functionality beyond filling, adjusting and
4498 implicit line breaking.  In order to gain further functionality,
4499 @code{gtroff} allows commands to be embedded into the text, in two ways.
4501 The first is a @dfn{request} which takes up an entire line, and does
4502 some large-scale operation (e.g.@: break lines, start new pages).
4504 The other is an @dfn{escape} which can be usually embedded anywhere
4505 in the text; most requests can accept it even as an argument.
4506 Escapes generally do more minor operations like sub- and superscripts,
4507 print a symbol, etc.
4509 @menu
4510 * Requests::
4511 * Macros::
4512 * Escapes::
4513 @end menu
4515 @c ---------------------------------------------------------------------
4517 @node Requests, Macros, Embedded Commands, Embedded Commands
4518 @subsection Requests
4519 @cindex requests
4521 @cindex control character (@code{.})
4522 @cindex character, control (@code{.})
4523 @cindex no-break control character (@code{'})
4524 @cindex character, no-break control (@code{'})
4525 @cindex control character, no-break (@code{'})
4526 A request line begins with a control character, which is either a single
4527 quote (@samp{'}, the @dfn{no-break control character}) or a period
4528 (@samp{.}, the normal @dfn{control character}).  These can be changed;
4529 see @ref{Character Translations}, for details.  After this there may be
4530 optional tabs or spaces followed by an identifier which is the name of
4531 the request.  This may be followed by any number of space-separated
4532 arguments (@emph{no} tabs here).
4534 @cindex structuring source code of documents or macro packages
4535 @cindex documents, structuring the source code
4536 @cindex macro packages, structuring the source code
4537 Since a control character followed by whitespace only is ignored, it
4538 is common practice to use this feature for structuring the source code
4539 of documents or macro packages.
4541 @Example
4542 .de foo
4543 .  tm This is foo.
4547 .de bar
4548 .  tm This is bar.
4550 @endExample
4552 @cindex blank line
4553 @cindex blank line macro (@code{blm})
4554 Another possibility is to use the blank line macro request @code{blm}
4555 by assigning an empty macro to it.
4557 @Example
4558 .de do-nothing
4560 .blm do-nothing  \" activate blank line macro
4562 .de foo
4563 .  tm This is foo.
4567 .de bar
4568 .  tm This is bar.
4571 .blm             \" deactivate blank line macro
4572 @endExample
4574 @xref{Blank Line Traps}.
4576 @cindex zero width space character (@code{\&})
4577 @cindex character, zero width space (@code{\&})
4578 @cindex space character, zero width (@code{\&})
4579 @cindex @code{\&}, escaping control characters
4580 To begin a line with a control character without it being interpreted,
4581 precede it with @code{\&}.  This represents a zero width space, which
4582 means it does not affect the output.
4584 In most cases the period is used as a control character.  Several
4585 requests cause a break implicitly; using the single quote control
4586 character prevents this.
4588 @menu
4589 * Request Arguments::
4590 @end menu
4592 @node Request Arguments,  , Requests, Requests
4593 @subsubsection Request Arguments
4594 @cindex request arguments
4595 @cindex arguments to requests
4597 Arguments to requests (and macros) are processed much like the shell:
4598 The line is split into arguments according to
4599 spaces.@footnote{Plan@w{ }9's @code{troff} implementation also allows
4600 tabs for argument separation -- @code{gtroff} intentionally doesn't
4601 support this.}  An argument which is intended to contain spaces can
4602 either be enclosed in double quotes, or have the spaces @dfn{escaped}
4603 with backslashes.
4605 Here are a few examples:
4607 @Example
4608 .uh The Mouse Problem
4609 .uh "The Mouse Problem"
4610 .uh The\ Mouse\ Problem
4611 @endExample
4613 @cindex @code{\~}, difference to @code{\@key{SP}}
4614 @cindex @code{\@key{SP}}, difference to @code{\~}
4615 @noindent
4616 The first line is the @code{uh} macro being called with 3 arguments,
4617 @samp{The}, @samp{Mouse}, and @samp{Problem}.  The latter two have the
4618 same effect of calling the @code{uh} macro with one argument, @samp{The
4619 Mouse Problem}.@footnote{The last solution, i.e., using escaped spaces,
4620 is ``classical'' in the sense that it can be found in most @code{troff}
4621 documents.  Nevertheless, it is not optimal in all situations, since
4622 @w{@samp{\ }} inserts a fixed-width, non-breaking space character which
4623 can't stretch.  @code{gtroff} provides a different command @code{\~} to
4624 insert a stretchable, non-breaking space.}
4626 @cindex @code{"}, in a macro argument
4627 @cindex double quote, in a macro argument
4628 A double quote which isn't preceded by a space doesn't start a macro
4629 argument.  If not closing a string, it is printed literally.
4631 For example,
4633 @Example
4634 .xxx a" "b c" "de"fg"
4635 @endExample
4637 @noindent
4638 has the arguments @samp{a"}, @w{@samp{b c}}, @samp{de}, and @samp{fg"}.
4639 Don't rely on this obscure behaviour!
4641 There are two possibilities to get a double quote reliably.
4643 @itemize @bullet
4644 @item
4645 Enclose the whole argument with double quotes and use two consecutive double
4646 quotes to represent a single one.  This traditional solution has the
4647 disadvantage that double quotes don't survive argument expansion again if
4648 called in compatibility mode (using the @option{-C} option of @code{groff}):
4650 @Example
4651 .de xx
4652 .  tm xx: `\\$1' `\\$2' `\\$3'
4654 .  yy "\\$1" "\\$2" "\\$3"
4656 .de yy
4657 .  tm yy: `\\$1' `\\$2' `\\$3'
4659 .xx A "test with ""quotes""" .
4660     @result{} xx: `A' `test with "quotes"' `.'
4661     @result{} yy: `A' `test with ' `quotes""'
4662 @endExample
4664 @noindent
4665 If not in compatibility mode, you get the expected result
4667 @Example
4668 xx: `A' `test with "quotes"' `.'
4669 yy: `A' `test with "quotes"' `.'
4670 @endExample
4672 @noindent
4673 since @code{gtroff} preserves the input level.
4675 @item
4676 Use the double quote glyph @code{\(dq}.  This works with and without
4677 compatibility mode enabled since @code{gtroff} doesn't convert @code{\(dq}
4678 back to a double quote input character.
4680 Not that this method won't work with @acronym{UNIX} @code{troff} in general
4681 since the glyph `dq' isn't defined normally.
4682 @end itemize
4684 @cindex @code{ds} request, and double quotes
4685 Double quotes in the @code{ds} request are handled differently.
4686 @xref{Strings}, for more details.
4688 @c ---------------------------------------------------------------------
4690 @node Macros, Escapes, Requests, Embedded Commands
4691 @subsection Macros
4692 @cindex macros
4694 @code{gtroff} has a @dfn{macro} facility for defining a series of lines
4695 which can be invoked by name.  They are called in the same manner as
4696 requests -- arguments also may be passed in the same manner.
4698 @xref{Writing Macros}, and @ref{Request Arguments}.
4700 @c ---------------------------------------------------------------------
4702 @node Escapes,  , Macros, Embedded Commands
4703 @subsection Escapes
4704 @cindex escapes
4706 Escapes may occur anywhere in the input to @code{gtroff}.  They usually
4707 begin with a backslash and are followed by a single character which
4708 indicates the function to be performed.  The escape character can be
4709 changed; see @ref{Character Translations}.
4711 Escape sequences which require an identifier as a parameter accept three
4712 possible syntax forms.
4714 @itemize @bullet
4715 @item
4716 The next single character is the identifier.
4718 @cindex @code{(}, starting a two-character identifier
4719 @item
4720 If this single character is an opening parenthesis, take the following
4721 two characters as the identifier.  Note that there is no closing
4722 parenthesis after the identifier.
4724 @cindex @code{[}, starting an identifier
4725 @cindex @code{]}, ending an identifier
4726 @item
4727 If this single character is an opening bracket, take all characters
4728 until a closing bracket as the identifier.
4729 @end itemize
4731 @noindent
4732 Examples:
4734 @Example
4736 \n(XX
4737 \*[TeX]
4738 @endExample
4740 @cindex @code{'}, delimiting arguments
4741 @cindex argument delimiting characters
4742 @cindex characters, argument delimiting
4743 @cindex delimiting characters for arguments
4744 Other escapes may require several arguments and/or some special format.
4745 In such cases the argument is traditionally enclosed in single quotes
4746 (and quotes are always used in this manual for the definitions of escape
4747 sequences).  The enclosed text is then processed according to what that
4748 escape expects.  Example:
4750 @Example
4751 \l'1.5i\(bu'
4752 @endExample
4754 @cindex @code{\o}, possible quote characters
4755 @cindex @code{\b}, possible quote characters
4756 @cindex @code{\X}, possible quote characters
4757 Note that the quote character can be replaced with any other character
4758 which does not occur in the argument (even a newline or a space
4759 character) in the following escapes: @code{\o}, @code{\b}, and
4760 @code{\X}.  This makes e.g.
4762 @Example
4763 A caf
4768 in Paris
4769   @result{} A caf@'e in Paris
4770 @endExample
4772 @noindent
4773 possible, but it is better not to use this feature to avoid confusion.
4775 @cindex @code{\%}, used as delimiter
4776 @cindex @code{\@key{SP}}, 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 @cindex @code{\,}, used as delimiter
4791 @cindex @code{\&}, used as delimiter
4792 @ifnotinfo
4793 @cindex @code{\:}, used as delimiter
4794 @end ifnotinfo
4795 @ifinfo
4796 @cindex @code{\@r{<colon>}}, used as delimiter
4797 @end ifinfo
4798 @cindex @code{\~}, used as delimiter
4799 @cindex @code{\0}, used as delimiter
4800 @cindex @code{\a}, used as delimiter
4801 @cindex @code{\c}, used as delimiter
4802 @cindex @code{\d}, used as delimiter
4803 @cindex @code{\e}, used as delimiter
4804 @cindex @code{\E}, used as delimiter
4805 @cindex @code{\p}, used as delimiter
4806 @cindex @code{\r}, used as delimiter
4807 @cindex @code{\t}, used as delimiter
4808 @cindex @code{\u}, used as delimiter
4809 The following escapes sequences (which are handled similarly to
4810 characters since they don't take a parameter) are also allowed as
4811 delimiters: @code{\%}, @w{@samp{\ }}, @code{\|}, @code{\^}, @code{\@{},
4812 @code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
4813 @code{\?}, @code{\@@}, @code{\)}, @code{\/}, @code{\,}, @code{\&},
4814 @code{\:}, @code{\~}, @code{\0}, @code{\a}, @code{\c}, @code{\d},
4815 @code{\e}, @code{\E}, @code{\p}, @code{\r}, @code{\t}, and @code{\u}.
4816 Again, don't use these if possible.
4818 @cindex @code{\A}, allowed delimiters
4819 @cindex @code{\B}, allowed delimiters
4820 @cindex @code{\Z}, allowed delimiters
4821 @cindex @code{\C}, allowed delimiters
4822 @cindex @code{\w}, allowed delimiters
4823 No newline characters as delimiters are allowed in the following
4824 escapes: @code{\A}, @code{\B}, @code{\Z}, @code{\C}, and @code{\w}.
4826 @cindex @code{\D}, allowed delimiters
4827 @cindex @code{\h}, allowed delimiters
4828 @cindex @code{\H}, allowed delimiters
4829 @cindex @code{\l}, allowed delimiters
4830 @cindex @code{\L}, allowed delimiters
4831 @cindex @code{\N}, allowed delimiters
4832 @cindex @code{\R}, allowed delimiters
4833 @cindex @code{\s}, allowed delimiters
4834 @cindex @code{\S}, allowed delimiters
4835 @cindex @code{\v}, allowed delimiters
4836 @cindex @code{\x}, allowed delimiters
4837 Finally, the escapes @code{\D}, @code{\h}, @code{\H}, @code{\l},
4838 @code{\L}, @code{\N}, @code{\R}, @code{\s}, @code{\S}, @code{\v},
4839 and @code{\x} can't use the following characters as delimiters:
4841 @itemize @bullet
4842 @item
4843 @cindex numbers, and delimiters
4844 @cindex digits, and delimiters
4845 The digits @code{0}-@code{9}.
4847 @item
4848 @cindex operators, as delimiters
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 @cindex @code{=}, as delimiter
4857 @cindex @code{&}, as delimiter
4858 @ifnotinfo
4859 @cindex @code{:}, as delimiter
4860 @end ifnotinfo
4861 @ifinfo
4862 @cindex <colon>, as delimiter
4863 @end ifinfo
4864 @cindex @code{(}, as delimiter
4865 @cindex @code{)}, as delimiter
4866 @cindex @code{.}, as delimiter
4867 The (single-character) operators @samp{+-/*%<>=&:().}.
4869 @item
4870 @cindex space character
4871 @cindex character, space
4872 @cindex tab character
4873 @cindex character, tab
4874 @cindex newline character
4875 @cindex character, newline
4876 The space, tab, and newline characters.
4878 @item
4879 @cindex @code{\%}, used as delimiter
4880 @ifnotinfo
4881 @cindex @code{\:}, used as delimiter
4882 @end ifnotinfo
4883 @ifinfo
4884 @cindex @code{\@r{<colon>}}, used as delimiter
4885 @end ifinfo
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{\@@}, used as delimiter
4894 @cindex @code{\/}, used as delimiter
4895 @cindex @code{\c}, used as delimiter
4896 @cindex @code{\e}, used as delimiter
4897 @cindex @code{\p}, used as delimiter
4898 All escape sequences except @code{\%}, @code{\:}, @code{\@{}, @code{\@}},
4899 @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!}, @code{\@@},
4900 @code{\/}, @code{\c}, @code{\e}, and @code{\p}.
4901 @end itemize
4903 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
4904 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
4905 To have a backslash (actually, the current escape character) appear in the
4906 output several escapes are defined: @code{\\}, @code{\e} or @code{\E}.
4907 These are very similar, and only differ with respect to being used in
4908 macros or diversions.  @xref{Character Translations}, for an exact
4909 description of those escapes.
4911 @xref{Implementation Differences}, @ref{Copy-in Mode}, and @ref{Diversions},
4912 @ref{Identifiers}, for more information.
4914 @menu
4915 * Comments::
4916 @end menu
4918 @node Comments,  , Escapes, Escapes
4919 @subsubsection Comments
4920 @cindex comments
4922 Probably one of the most@footnote{Unfortunately, this is a lie.  But
4923 hopefully future @code{gtroff} hackers will believe it @code{:-)}}
4924 common forms of escapes is the comment.
4926 @Defesc {\\", , , }
4927 Start a comment.  Everything to the end of the input line is ignored.
4929 This may sound simple, but it can be tricky to keep the comments from
4930 interfering with the appearance of the final output.
4932 @cindex @code{ds}, @code{ds1} requests, and comments
4933 @cindex @code{as}, @code{as1} requests, and comments
4934 If the escape is to the right of some text or a request, that portion
4935 of the line is ignored, but the space leading up to it is noticed by
4936 @code{gtroff}.  This only affects the @code{ds} and @code{as}
4937 request and its variants.
4939 @cindex tabs, before comments
4940 @cindex comments, lining up with tabs
4941 One possibly irritating idiosyncracy is that tabs must not be used to
4942 line up comments.  Tabs are not treated as whitespace between the
4943 request and macro arguments.
4945 @cindex undefined request
4946 @cindex request, undefined
4947 A comment on a line by itself is treated as a blank line, because
4948 after eliminating the comment, that is all that remains:
4950 @Example
4951 Test
4952 \" comment
4953 Test
4954 @endExample
4956 @noindent
4957 produces
4959 @Example
4960 Test
4962 Test
4963 @endExample
4965 To avoid this, it is common to start the line with @code{.\"} which
4966 causes the line to be treated as an undefined request and thus ignored
4967 completely.
4969 @cindex @code{'}, as a comment
4970 Another commenting scheme seen sometimes is three consecutive single
4971 quotes (@code{'''}) at the beginning of a line.  This works, but
4972 @code{gtroff} gives a warning about an undefined macro (namely
4973 @code{''}), which is harmless, but irritating.
4974 @endDefesc
4976 @Defesc {\\#, , , }
4977 To avoid all this, @code{gtroff} has a new comment mechanism using the
4978 @code{\#} escape.  This escape works the same as @code{\"} except that
4979 the newline is also ignored:
4981 @Example
4982 Test
4983 \# comment
4984 Test
4985 @endExample
4987 @noindent
4988 produces
4990 @Example
4991 Test Test
4992 @endExample
4994 @noindent
4995 as expected.
4996 @endDefesc
4998 @Defreq {ig, yy}
4999 Ignore all input until @code{gtroff} encounters the macro named
5000 @code{.}@var{yy} on a line by itself (or @code{..} if @var{yy} is not
5001 specified).  This is useful for commenting out large blocks of text:
5003 @Example
5004 text text text...
5006 This is part of a large block
5007 of text that has been
5008 temporarily(?) commented out.
5010 We can restore it simply by removing
5011 the .ig request and the ".." at the
5012 end of the block.
5014 More text text text...
5015 @endExample
5017 @noindent
5018 produces
5020 @Example
5021 text text text@dots{}  More text text text@dots{}
5022 @endExample
5024 @noindent
5025 Note that the commented-out block of text does not
5026 cause a break.
5028 The input is read in copy-mode; auto-incremented registers @emph{are}
5029 affected (@pxref{Auto-increment}).
5030 @endDefreq
5033 @c =====================================================================
5035 @node Registers, Manipulating Filling and Adjusting, Embedded Commands, gtroff Reference
5036 @section Registers
5037 @cindex registers
5039 Numeric variables in @code{gtroff} are called @dfn{registers}.  There
5040 are a number of built-in registers, supplying anything from the date to
5041 details of formatting parameters.
5043 @xref{Identifiers}, for details on register identifiers.
5045 @menu
5046 * Setting Registers::
5047 * Interpolating Registers::
5048 * Auto-increment::
5049 * Assigning Formats::
5050 * Built-in Registers::
5051 @end menu
5053 @c ---------------------------------------------------------------------
5055 @node Setting Registers, Interpolating Registers, Registers, Registers
5056 @subsection Setting Registers
5057 @cindex setting registers (@code{nr}, @code{\R})
5058 @cindex registers, setting (@code{nr}, @code{\R})
5060 Define or set registers using the @code{nr} request or the
5061 @code{\R} escape.
5063 @DefreqList {nr, ident value}
5064 @DefescListEnd {\\R, ', ident value, '}
5065 Set number register @var{ident} to @var{value}.  If @var{ident}
5066 doesn't exist, @code{gtroff} creates it.
5068 The argument to @code{\R} usually has to be enclosed in quotes.
5069 @xref{Escapes}, for details on parameter delimiting characters.
5071 The @code{\R} escape doesn't produce an input token in @code{gtroff};
5072 with other words, it vanishes completely after @code{gtroff} has
5073 processed it.
5074 @endDefreq
5076 For example, the following two lines are equivalent:
5078 @Example
5079 .nr a (((17 + (3 * 4))) % 4)
5080 \R'a (((17 + (3 * 4))) % 4)'
5081     @result{} 1
5082 @endExample
5084 Both @code{nr} and @code{\R} have two additional special forms to
5085 increment or decrement a register.
5087 @DefreqList {nr, ident @t{+}@Var{value}}
5088 @DefreqItem {nr, ident @t{-}@Var{value}}
5089 @DefescItem {\\R, ', ident @t{+}@Var{value}, '}
5090 @DefescListEnd {\\R, ', ident @t{-}@Var{value}, '}
5091 Increment (decrement) register @var{ident} by @var{value}.
5093 @Example
5094 .nr a 1
5095 .nr a +1
5097     @result{} 2
5098 @endExample
5100 @cindex negating register values
5101 To assign the negated value of a register to another register, some care
5102 must be taken to get the desired result:
5104 @Example
5105 .nr a 7
5106 .nr b 3
5107 .nr a -\nb
5109     @result{} 4
5110 .nr a (-\nb)
5112     @result{} -3
5113 @endExample
5115 @noindent
5116 The surrounding parentheses prevent the interpretation of the minus sign
5117 as a decrementing operator.  An alternative is to start the assignment
5118 with a @samp{0}:
5120 @Example
5121 .nr a 7
5122 .nr b -3
5123 .nr a \nb
5125     @result{} 4
5126 .nr a 0\nb
5128     @result{} -3
5129 @endExample
5130 @endDefreq
5132 @Defreq {rr, ident}
5133 @cindex removing number register (@code{rr})
5134 @cindex number register, removing (@code{rr})
5135 @cindex register, removing (@code{rr})
5136 Remove number register @var{ident}.  If @var{ident} doesn't exist, the
5137 request is ignored.
5138 @endDefreq
5140 @Defreq {rnn, ident1 ident2}
5141 @cindex renaming number register (@code{rnn})
5142 @cindex number register, renaming (@code{rnn})
5143 @cindex register, renaming (@code{rnn})
5144 Rename number register @var{ident1} to @var{ident2}.  If either
5145 @var{ident1} or @var{ident2} doesn't exist, the request is ignored.
5146 @endDefreq
5148 @Defreq {aln, ident1 ident2}
5149 @cindex alias, number register, creating (@code{aln})
5150 @cindex creating alias, for number register (@code{aln})
5151 @cindex number register, creating alias (@code{aln})
5152 @cindex register, creating alias (@code{aln})
5153 Create an alias @var{ident1} for a number register @var{ident2}.  The
5154 new name and the old name are exactly equivalent.  If @var{ident1} is
5155 undefined, a warning of type @samp{reg} is generated, and the request
5156 is ignored.  @xref{Debugging}, for information about warnings.
5157 @endDefreq
5159 @c ---------------------------------------------------------------------
5161 @node Interpolating Registers, Auto-increment, Setting Registers, Registers
5162 @subsection Interpolating Registers
5163 @cindex interpolating registers (@code{\n})
5164 @cindex registers, interpolating (@code{\n})
5166 Numeric registers can be accessed via the @code{\n} escape.
5168 @DefescList {\\n, , i, }
5169 @DefescItem {\\n, @lparen{}, id, }
5170 @DefescListEnd {\\n, @lbrack{}, ident, @rbrack}
5171 @cindex nested assignments
5172 @cindex assignments, nested
5173 @cindex indirect assignments
5174 @cindex assignments, indirect
5175 Interpolate number register with name @var{ident} (one-character name@w{
5176 }@var{i}, two-character name @var{id}). This means that the value of the
5177 register is expanded in-place while @code{gtroff} is parsing the input line.
5178 Nested assignments (also called indirect assignments) are possible.
5180 @Example
5181 .nr a 5
5182 .nr as \na+\na
5183 \n(as
5184     @result{} 10
5185 @endExample
5187 @Example
5188 .nr a1 5
5189 .nr ab 6
5190 .ds str b
5191 .ds num 1
5192 \n[a\n[num]]
5193     @result{} 5
5194 \n[a\*[str]]
5195     @result{} 6
5196 @endExample
5197 @endDefesc
5199 @c ---------------------------------------------------------------------
5201 @node Auto-increment, Assigning Formats, Interpolating Registers, Registers
5202 @subsection Auto-increment
5203 @cindex auto-increment
5204 @cindex increment, automatic
5206 Number registers can also be auto-incremented and auto-decremented.
5207 The increment or decrement value can be specified with a third
5208 argument to the @code{nr} request or @code{\R} escape.
5210 @Defreq {nr, ident value incr}
5211 @cindex @code{\R}, difference to @code{nr}
5212 Set number register @var{ident} to @var{value}; the increment for
5213 auto-incrementing is set to @var{incr}.  Note that the @code{\R}
5214 escape doesn't support this notation.
5215 @endDefreq
5217 To activate auto-incrementing, the escape @code{\n} has a special
5218 syntax form.
5220 @DefescList {\\n, +, i, }
5221 @DefescItem {\\n, -, i, }
5222 @DefescItem {\\n, @lparen{}+, id, }
5223 @DefescItem {\\n, @lparen{}-, id, }
5224 @DefescItem {\\n, +@lparen{}, id, }
5225 @DefescItem {\\n, -@lparen{}, id, }
5226 @DefescItem {\\n, @lbrack{}+, ident, @rbrack{}}
5227 @DefescItem {\\n, @lbrack{}-, ident, @rbrack{}}
5228 @DefescItem {\\n, +@lbrack{}, ident, @rbrack{}}
5229 @DefescListEnd {\\n, -@lbrack{}, ident, @rbrack{}}
5230 Before interpolating, increment or decrement @var{ident}
5231 (one-character name@w{ }@var{i}, two-character name @var{id}) by the
5232 auto-increment value as specified with the @code{nr} request (or the
5233 @code{\R} escape).  If no auto-increment value has been specified,
5234 these syntax forms are identical to @code{\n}.
5235 @endDefesc
5237 For example,
5239 @Example
5240 .nr a 0 1
5241 .nr xx 0 5
5242 .nr foo 0 -2
5243 \n+a, \n+a, \n+a, \n+a, \n+a
5245 \n-(xx, \n-(xx, \n-(xx, \n-(xx, \n-(xx
5247 \n+[foo], \n+[foo], \n+[foo], \n+[foo], \n+[foo]
5248 @endExample
5250 @noindent
5251 produces
5253 @Example
5254 1, 2, 3, 4, 5
5255 -5, -10, -15, -20, -25
5256 -2, -4, -6, -8, -10
5257 @endExample
5259 @cindex increment value without changing the register
5260 @cindex value, incrementing without changing the register
5261 To change the increment value without changing the value of a register
5262 (@var{a} in the example), the following can be used:
5264 @Example
5265 .nr a \na 10
5266 @endExample
5268 @c ---------------------------------------------------------------------
5270 @node Assigning Formats, Built-in Registers, Auto-increment, Registers
5271 @subsection Assigning Formats
5272 @cindex assigning formats (@code{af})
5273 @cindex formats, assigning (@code{af})
5275 When a register is used in the text of an input file (as opposed to
5276 part of an expression), it is textually replaced (or interpolated)
5277 with a representation of that number.  This output format can be
5278 changed to a variety of formats (numbers, Roman numerals, etc.).  This
5279 is done using the @code{af} request.
5281 @Defreq {af, ident format}
5282 Change the output format of a number register.  The first argument
5283 @var{ident} is the name of the number register to be changed, and the
5284 second argument @var{format} is the output format.  The following
5285 output formats are available:
5287 @table @code
5288 @item 1
5289 Decimal arabic numbers.  This is the default format: 0, 1, 2, 3,@w{
5290 }@enddots{}
5292 @item 0@dots{}0
5293 Decimal numbers with as many digits as specified.  So, @samp{00} would
5294 result in printing numbers as 01, 02, 03,@w{ }@enddots{}
5296 In fact, any digit instead of zero will do; @code{gtroff} only counts
5297 how many digits are specified.  As a consequence, @code{af}'s default
5298 format @samp{1} could be specified as @samp{0} also (and exactly this is
5299 returned by the @code{\g} escape, see below).
5301 @item I
5302 @cindex Roman numerals
5303 @cindex numerals, Roman
5304 Upper-case Roman numerals: 0, I, II, III, IV,@w{ }@enddots{}
5306 @item i
5307 Lower-case Roman numerals: 0, i, ii, iii, iv,@w{ }@enddots{}
5309 @item A
5310 Upper-case letters: 0, A, B, C, @dots{},@w{ }Z, AA, AB,@w{ }@enddots{}
5312 @item a
5313 Lower-case letters: 0, a, b, c, @dots{},@w{ }z, aa, ab,@w{ }@enddots{}
5314 @end table
5316 Omitting the number register format causes a warning of type
5317 @samp{missing}.  @xref{Debugging}, for more details.  Specifying a
5318 nonexistent format causes an error.
5320 The following example produces @samp{10, X, j, 010}:
5322 @Example
5323 .nr a 10
5324 .af a 1           \" the default format
5325 \na,
5326 .af a I
5327 \na,
5328 .af a a
5329 \na,
5330 .af a 001
5332 @endExample
5334 @cindex Roman numerals, maximum and minimum
5335 @cindex maximum values of Roman numerals
5336 @cindex minimum values of Roman numerals
5337 The largest number representable for the @samp{i} and @samp{I} formats
5338 is 39999 (or @minus{}39999); @acronym{UNIX} @code{troff} uses @samp{z}
5339 and @samp{w} to represent 10000 and 5000 in Roman numerals, and so does
5340 @code{gtroff}.  Currently, the correct glyphs of Roman numeral five
5341 thousand and Roman numeral ten thousand (Unicode code points
5342 @code{U+2182} and @code{U+2181}, respectively) are not available.
5344 If @var{ident} doesn't exist, it is created.
5346 @cindex read-only register, changing format
5347 @cindex changing format, and read-only registers
5348 Changing the output format of a read-only register causes an error.  It
5349 is necessary to first copy the register's value to a writeable register,
5350 then apply the @code{af} request to this other register.
5351 @endDefreq
5353 @DefescList {\\g, , i, }
5354 @DefescItem {\\g, @lparen{}, id, }
5355 @DefescListEnd {\\g, @lbrack{}, ident, @rbrack{}}
5356 @cindex format of register (@code{\g})
5357 @cindex register, format (@code{\g})
5358 Return the current format of the specified register @var{ident}
5359 (one-character name@w{ }@var{i}, two-character name @var{id}).  For
5360 example, @samp{\ga} after the previous example would produce the
5361 string @samp{000}.  If the register hasn't been defined yet, nothing
5362 is returned.
5363 @endDefesc
5365 @c ---------------------------------------------------------------------
5367 @node Built-in Registers,  , Assigning Formats, Registers
5368 @subsection Built-in Registers
5369 @cindex built-in registers
5370 @cindex registers, built-in
5372 The following lists some built-in registers which are not described
5373 elsewhere in this manual.  Any register which begins with a @samp{.} is
5374 read-only.  A complete listing of all built-in registers can be found in
5375 appendix@w{ }@ref{Register Index}.
5377 @table @code
5378 @item .F
5379 @cindex current input file name register (@code{.F})
5380 @cindex input file name, current, register (@code{.F})
5381 @vindex .F
5382 This string-valued register returns the current input file name.
5384 @item .H
5385 @cindex horizontal resolution register (@code{.H})
5386 @cindex resolution, horizontal, register (@code{.H})
5387 @vindex .H
5388 Horizontal resolution in basic units.
5390 @item .V
5391 @cindex vertical resolution register (@code{.V})
5392 @cindex resolution, vertical, register (@code{.V})
5393 @vindex .V
5394 Vertical resolution in basic units.
5396 @item seconds
5397 @cindex seconds, current time (@code{seconds})
5398 @cindex time, current, seconds (@code{seconds})
5399 @cindex current time, seconds (@code{seconds})
5400 @vindex seconds
5401 The number of seconds after the minute, normally in the range@w{ }0
5402 to@w{ }59, but can be up to@w{ }61 to allow for leap seconds.  Initialized
5403 at start-up of @code{gtroff}.
5405 @item minutes
5406 @cindex minutes, current time (@code{minutes})
5407 @cindex time, current, minutes (@code{minutes})
5408 @cindex current time, minutes (@code{minutes})
5409 @vindex minutes
5410 The number of minutes after the hour, in the range@w{ }0 to@w{ }59.
5411 Initialized at start-up of @code{gtroff}.
5413 @item hours
5414 @cindex hours, current time (@code{hours})
5415 @cindex time, current, hours (@code{hours})
5416 @cindex current time, hours (@code{hours})
5417 @vindex hours
5418 The number of hours past midnight, in the range@w{ }0 to@w{ }23.
5419 Initialized at start-up of @code{gtroff}.
5421 @item dw
5422 @cindex day of the week register (@code{dw})
5423 @cindex date, day of the week register (@code{dw})
5424 @vindex dw
5425 Day of the week (1-7).
5427 @item dy
5428 @cindex day of the month register (@code{dy})
5429 @cindex date, day of the month register (@code{dy})
5430 @vindex dy
5431 Day of the month (1-31).
5433 @item mo
5434 @cindex month of the year register (@code{mo})
5435 @cindex date, month of the year register (@code{mo})
5436 @vindex mo
5437 Current month (1-12).
5439 @item year
5440 @cindex date, year register (@code{year}, @code{yr})
5441 @cindex year, current, register (@code{year}, @code{yr})
5442 @vindex year
5443 The current year.
5445 @item yr
5446 @vindex yr
5447 The current year minus@w{ }1900.  Unfortunately, the documentation of
5448 @acronym{UNIX} Version@w{ }7's @code{troff} had a year@w{ }2000 bug: It
5449 incorrectly claimed that @code{yr} contains the last two digits of the
5450 year.  That claim has never been true of either @acronym{AT&T}
5451 @code{troff} or GNU @code{troff}.  Old @code{troff} input that looks
5452 like this:
5454 @Example
5455 '\" The following line stopped working after 1999
5456 This document was formatted in 19\n(yr.
5457 @endExample
5459 @noindent
5460 can be corrected as follows:
5462 @Example
5463 This document was formatted in \n[year].
5464 @endExample
5466 @noindent
5467 or, to be portable to older @code{troff} versions, as follows:
5469 @Example
5470 .nr y4 1900+\n(yr
5471 This document was formatted in \n(y4.
5472 @endExample
5474 @item .c
5475 @vindex .c
5476 @itemx c.
5477 @vindex c.
5478 @cindex input line number register (@code{.c}, @code{c.})
5479 @cindex line number, input, register (@code{.c}, @code{c.})
5480 The current @emph{input} line number.  Register @samp{.c} is read-only,
5481 whereas @samp{c.} (a @code{gtroff} extension) is writable also,
5482 affecting both @samp{.c} and @samp{c.}.
5484 @item ln
5485 @vindex ln
5486 @cindex output line number register (@code{ln})
5487 @cindex line number, output, register (@code{ln})
5488 The current @emph{output} line number after a call to the @code{nm}
5489 request to activate line numbering.
5491 @xref{Miscellaneous}, for more information about line numbering.
5493 @item .x
5494 @vindex .x
5495 @cindex major version number register (@code{.x})
5496 @cindex version number, major, register (@code{.x})
5497 The major version number.  For example, if the version number is@w{
5498 }1.03 then @code{.x} contains@w{ }@samp{1}.
5500 @item .y
5501 @vindex .y
5502 @cindex minor version number register (@code{.y})
5503 @cindex version number, minor, register (@code{.y})
5504 The minor version number.  For example, if the version number is@w{
5505 }1.03 then @code{.y} contains@w{ }@samp{03}.
5507 @item .Y
5508 @vindex .Y
5509 @cindex revision number register (@code{.Y})
5510 The revision number of @code{groff}.
5512 @item $$
5513 @vindex $$
5514 @cindex process ID of @code{gtroff} register (@code{$$})
5515 @cindex @code{gtroff}, process ID register (@code{$$})
5516 The process ID of @code{gtroff}.
5518 @item .g
5519 @vindex .g
5520 @cindex @code{gtroff}, identification register (@code{.g})
5521 @cindex GNU-specific register (@code{.g})
5522 Always@w{ }1.  Macros should use this to determine whether they are
5523 running under GNU @code{troff}.
5525 @item .A
5526 @vindex .A
5527 @cindex @acronym{ASCII} approximation output register (@code{.A})
5528 If the command line option @option{-a} is used to produce an
5529 @acronym{ASCII} approximation of the output, this is set to@w{ }1, zero
5530 otherwise.  @xref{Groff Options}.
5532 @item .P
5533 @vindex .P
5534 This register is set to@w{ }1 (and to@w{ }0 otherwise) if the current
5535 page is actually being printed, i.e., if the @option{-o} option is being
5536 used to only print selected pages.  @xref{Groff Options}, for more
5537 information.
5539 @item .T
5540 @vindex .T
5541 If @code{gtroff} is called with the @option{-T} command line option, the
5542 number register @code{.T} is set to@w{ }1, and zero otherwise.
5543 @xref{Groff Options}.
5545 @stindex .T
5546 @cindex output device name string register (@code{.T})
5547 Additionally, @code{gtroff} predefines a single read-write string
5548 register @code{.T} which contains the current output device (for
5549 example, @samp{latin1} or @samp{ps}).
5550 @end table
5553 @c =====================================================================
5555 @node Manipulating Filling and Adjusting, Manipulating Hyphenation, Registers, gtroff Reference
5556 @section Manipulating Filling and Adjusting
5557 @cindex manipulating filling and adjusting
5558 @cindex filling and adjusting, manipulating
5559 @cindex adjusting and filling, manipulating
5560 @cindex justifying text
5561 @cindex text, justifying
5563 @cindex break
5564 @cindex line break
5565 @cindex @code{bp} request, causing implicit linebreak
5566 @cindex @code{ce} request, causing implicit linebreak
5567 @cindex @code{cf} request, causing implicit linebreak
5568 @cindex @code{fi} request, causing implicit linebreak
5569 @cindex @code{fl} request, causing implicit linebreak
5570 @cindex @code{in} request, causing implicit linebreak
5571 @cindex @code{nf} request, causing implicit linebreak
5572 @cindex @code{rj} request, causing implicit linebreak
5573 @cindex @code{sp} request, causing implicit linebreak
5574 @cindex @code{ti} request, causing implicit linebreak
5575 @cindex @code{trf} request, causing implicit linebreak
5576 Various ways of causing @dfn{breaks} were given in @ref{Implicit Line
5577 Breaks}.  The @code{br} request likewise causes a break.  Several
5578 other requests also cause breaks, but implicitly.  These are
5579 @code{bp}, @code{ce}, @code{cf}, @code{fi}, @code{fl}, @code{in},
5580 @code{nf}, @code{rj}, @code{sp}, @code{ti}, and @code{trf}.
5582 @Defreq {br, }
5583 Break the current line, i.e., the input collected so far is emitted
5584 without adjustment.
5586 If the no-break control character is used, @code{gtroff} suppresses
5587 the break:
5589 @Example
5593     @result{} a b
5594 @endExample
5595 @endDefreq
5597 Initially, @code{gtroff} fills and adjusts text to both margins.
5598 Filling can be disabled via the @code{nf} request and re-enabled with
5599 the @code{fi} request.
5601 @DefreqList {fi, }
5602 @DefregListEnd {.u}
5603 @cindex fill mode (@code{fi})
5604 @cindex mode, fill (@code{fi})
5605 Activate fill mode (which is the default).  This request implicitly
5606 enables adjusting; it also inserts a break in the text currently being
5607 filled.  The read-only number register @code{.u} is set to@w{ }1.
5609 The fill mode status is associated with the current environment
5610 (@pxref{Environments}).
5612 See @ref{Line Control}, for interaction with the @code{\c} escape.
5613 @endDefreq
5615 @Defreq {nf, }
5616 @cindex no-fill mode (@code{nf})
5617 @cindex mode, no-fill (@code{nf})
5618 Activate no-fill mode.  Input lines are output as-is, retaining line
5619 breaks and ignoring the current line length.  This command implicitly
5620 disables adjusting; it also causes a break.  The number register
5621 @code{.u} is set to@w{ }0.
5623 The fill mode status is associated with the current environment
5624 (@pxref{Environments}).
5626 See @ref{Line Control}, for interaction with the @code{\c} escape.
5627 @endDefreq
5629 @DefreqList {ad, [@Var{mode}]}
5630 @DefregListEnd {.j}
5631 Set adjusting mode.
5633 Activation and deactivation of adjusting is done implicitly with
5634 calls to the @code{fi} or @code{nf} requests.
5636 @var{mode} can have one of the following values:
5638 @table @code
5639 @item l
5640 @cindex ragged-right
5641 Adjust text to the left margin.  This produces what is traditionally
5642 called ragged-right text.
5644 @item r
5645 @cindex ragged-left
5646 Adjust text to the right margin, producing ragged-left text.
5648 @item c
5649 @cindex centered text
5650 @cindex @code{ce} request, difference to @samp{.ad@w{ }c}
5651 Center filled text.  This is different to the @code{ce} request which
5652 only centers text without filling.
5654 @item b
5655 @itemx n
5656 Justify to both margins.  This is the default used by @code{gtroff}.
5657 @end table
5659 With no argument, @code{gtroff} adjusts lines in the same way it did
5660 before adjusting was deactivated (with a call to @code{na}, for
5661 example).
5663 @Example
5664 text
5665 .ad r
5666 text
5667 .ad c
5668 text
5670 text
5671 .ad  \" back to centering
5672 text
5673 @endExample
5675 @cindex adjustment mode register (@code{.j})
5676 The current adjustment mode is available in the read-only number
5677 register @code{.j}; it can be stored and subsequently used to set
5678 adjustment.
5680 The adjustment mode status is associated with the current environment
5681 (@pxref{Environments}).
5682 @endDefreq
5684 @Defreq {na, }
5685 Disable adjusting.  This request won't change the current adjustment
5686 mode: A subsequent call to @code{ad} uses the previous adjustment
5687 setting.
5689 The adjustment mode status is associated with the current environment
5690 (@pxref{Environments}).
5691 @endDefreq
5693 @DefreqList {brp, }
5694 @DefescListEnd {\\p, , , }
5695 Adjust the current line and cause a break.
5697 In most cases this produces very ugly results since @code{gtroff}
5698 doesn't have a sophisticated paragraph building algorithm (as @TeX{}
5699 have, for example); instead, @code{gtroff} fills and adjusts a paragraph
5700 line by line:
5702 @Example
5703   This is an uninteresting sentence.
5704   This is an uninteresting sentence.\p
5705   This is an uninteresting sentence.
5706 @endExample
5708 @noindent
5709 is formatted as
5711 @Example
5712   This is  an uninteresting  sentence.   This  is an
5713   uninteresting                            sentence.
5714   This is an uninteresting sentence.
5715 @endExample
5716 @endDefreq
5718 @DefreqList {ss, word_space_size [@Var{sentence_space_size}]}
5719 @DefregItem {.ss}
5720 @DefregListEnd {.sss}
5721 @cindex word space size register (@code{.ss})
5722 @cindex size of word space register (@code{.ss})
5723 @cindex space between words register (@code{.ss})
5724 @cindex sentence space size register (@code{.sss})
5725 @cindex size of sentence space register (@code{.sss})
5726 @cindex space between sentences register (@code{.sss})
5727 Change the minimum size of a space between filled words.  It takes its
5728 units as one twelfth of the space width parameter for the current
5729 font.  Initially both the @var{word_space_size} and
5730 @var{sentence_space_size} are@w{ }12.
5732 @cindex fill mode
5733 @cindex mode, fill
5734 If two arguments are given to the @code{ss} request, the second
5735 argument sets the sentence space size.  If the second argument is not
5736 given, sentence space size is set to @var{word_space_size}.  The
5737 sentence space size is used in two circumstances: If the end of a
5738 sentence occurs at the end of a line in fill mode, then both an
5739 inter-word space and a sentence space are added; if two spaces follow
5740 the end of a sentence in the middle of a line, then the second space
5741 is a sentence space.  If a second argument is never given to the
5742 @code{ss} request, the behaviour of @acronym{UNIX} @code{troff} is the
5743 same as that exhibited by GNU @code{troff}.  In GNU @code{troff}, as
5744 in @acronym{UNIX} @code{troff}, a sentence should always be followed
5745 by either a newline or two spaces.
5747 The read-only number registers @code{.ss} and @code{.sss} hold the
5748 values of the parameters set by the first and second arguments of the
5749 @code{ss} request.
5751 The word space and sentence space values are associated with the current
5752 environment (@pxref{Environments}).
5754 Contrary to @acronym{AT&T} @code{troff}, this request is @emph{not}
5755 ignored if a TTY output device is used; the given values are then
5756 rounded down to a multiple of@w{ }12 (@pxref{Implementation Differences}).
5758 The request is ignored if there is no parameter.
5759 @endDefreq
5761 @DefreqList {ce, [@Var{nnn}]}
5762 @DefregListEnd {.ce}
5763 @cindex centering lines (@code{ce})
5764 @cindex lines, centering (@code{ce})
5765 Center text.  While the @w{@samp{.ad c}} request also centers text,
5766 it fills the text as well.  @code{ce} does not fill the
5767 text it affects.  This request causes a break.  The number of lines
5768 still to be centered is associated with the current environment
5769 (@pxref{Environments}).
5771 The following example demonstrates the differences.
5772 Here the input:
5774 @Example
5775 .ll 4i
5776 .ce 1000
5777 This is a small text fragment which shows the differences
5778 between the `.ce' and the `.ad c' request.
5779 .ce 0
5781 .ad c
5782 This is a small text fragment which shows the differences
5783 between the `.ce' and the `.ad c' request.
5784 @endExample
5786 @noindent
5787 And here the result:
5789 @Example
5790   This is a small text fragment which
5791          shows the differences
5792 between the `.ce' and the `.ad c' request.
5794   This is a small text fragment which
5795 shows the differences between the `.ce'
5796         and the `.ad c' request.
5797 @endExample
5799 With no arguments, @code{ce} centers the next line of text.  @var{nnn}
5800 specifies the number of lines to be centered.  If the argument is zero
5801 or negative, centering is disabled.
5803 The basic length for centering text is the line length (as set with the
5804 @code{ll} request) minus the indentation (as set with the @code{in}
5805 request).  Temporary indentation is ignored.
5807 As can be seen in the previous example, it is a common idiom to turn
5808 on centering for a large number of lines, and to turn off centering
5809 after text to be centered.  This is useful for any request which takes
5810 a number of lines as an argument.
5812 The @code{.ce} read-only number register contains the number of lines
5813 remaining to be centered, as set by the @code{ce} request.
5814 @endDefreq
5816 @DefreqList {rj, [@Var{nnn}]}
5817 @DefregListEnd {.rj}
5818 @cindex justifying text (@code{rj})
5819 @cindex text, justifying (@code{rj})
5820 @cindex right-justifying (@code{rj})
5821 Justify unfilled text to the right margin.  Arguments are identical to
5822 the @code{ce} request.  The @code{.rj} read-only number register is
5823 the number of lines to be right-justified as set by the @code{rj}
5824 request.  This request causes a break.  The number of lines still to be
5825 right-justified is associated with the current environment
5826 (@pxref{Environments}).
5827 @endDefreq
5830 @c =====================================================================
5832 @node Manipulating Hyphenation, Manipulating Spacing, Manipulating Filling and Adjusting, gtroff Reference
5833 @section Manipulating Hyphenation
5834 @cindex manipulating hyphenation
5835 @cindex hyphenation, manipulating
5837 As discussed in @ref{Hyphenation}, @code{gtroff} hyphenates words.
5838 There are a number of ways to influence hyphenation.
5840 @DefreqList {hy, [@Var{mode}]}
5841 @DefregListEnd {.hy}
5842 Enable hyphenation.  The request has an optional numeric argument,
5843 @var{mode}, to restrict hyphenation if necessary:
5845 @table @code
5846 @item 1
5847 The default argument if @var{mode} is omitted.  Hyphenate without
5848 restrictions.  This is also the start-up value of @code{gtroff}.
5850 @item 2
5851 Do not hyphenate the last word on a page or column.
5853 @item 4
5854 Do not hyphenate the last two characters of a word.
5856 @item 8
5857 Do not hyphenate the first two characters of a word.
5858 @end table
5860 Values in the previous table are additive.  For example, the value@w{
5861 }12 causes @code{gtroff} to neither hyphenate the last two nor the first
5862 two characters of a word.
5864 @cindex hyphenation restrictions register (@code{.hy})
5865 The current hyphenation restrictions can be found in the read-only
5866 number register @samp{.hy}.
5868 The hyphenation mode is associated with the current environment
5869 (@pxref{Environments}).
5870 @endDefreq
5872 @Defreq {nh, }
5873 Disable hyphenation (i.e., set the hyphenation mode to zero).  Note
5874 that the hyphenation mode of the last call to @code{hy} is not
5875 remembered.
5877 The hyphenation mode is associated with the current environment
5878 (@pxref{Environments}).
5879 @endDefreq
5881 @DefreqList {hlm, [@Var{nnn}]}
5882 @DefregItem {.hlm}
5883 @DefregListEnd {.hlc}
5884 @cindex explicit hyphen (@code{\%})
5885 @cindex hyphen, explicit (@code{\%})
5886 @cindex consecutive hyphenated lines (@code{hlm})
5887 @cindex lines, consecutive hyphenated (@code{hlm})
5888 @cindex hyphenated lines, consecutive (@code{hlm})
5889 Set the maximum number of consecutive hyphenated lines to @var{nnn}.
5890 If this number is negative, there is no maximum.  The default value
5891 is@w{ }@minus{}1 if @var{nnn} is omitted.  This value is associated
5892 with the current environment (@pxref{Environments}).  Only lines
5893 output from a given environment count towards the maximum associated
5894 with that environment.  Hyphens resulting from @code{\%} are counted;
5895 explicit hyphens are not.
5897 The current setting of @code{hlm} is available in the @code{.hlm}
5898 read-only number register.  Also the number of immediately preceding
5899 consecutive hyphenated lines are available in the read-only number
5900 register @samp{.hlc}.
5901 @endDefreq
5903 @Defreq {hw, word1 word2 @dots{}}
5904 Define how @var{word1}, @var{word2}, etc.@: are to be hyphenated.  The
5905 words must be given with hyphens at the hyphenation points.  For
5906 example:
5908 @Example
5909 .hw in-sa-lub-rious
5910 @endExample
5912 @noindent
5913 Besides the space character, any character whose hyphenation code value
5914 is zero can be used to separate the arguments of @code{hw} (see the
5915 documentation for the @code{hcode} request below for more information).
5916 In addition, this request can be used more than once.
5918 Hyphenation exceptions specified with the @code{hw} request are
5919 associated with the current hyphenation language; it causes an error
5920 if there is no current hyphenation language.
5922 This request is ignored if there is no parameter.
5924 In old versions of @code{troff} there was a limited amount of space to
5925 store such information; fortunately, with @code{gtroff}, this is no
5926 longer a restriction.
5927 @endDefreq
5929 @DefescList {\\%, , , }
5930 @deffnx Escape @t{\:}
5931 @ifnotinfo
5932 @esindex \:
5933 @end ifnotinfo
5934 @ifinfo
5935 @esindex @r{<colon>}
5936 @end ifinfo
5937 @cindex hyphenation character (@code{\%})
5938 @cindex character, hyphenation (@code{\%})
5939 @cindex disabling hyphenation (@code{\%})
5940 @cindex hyphenation, disabling (@code{\%})
5941 To tell @code{gtroff} how to hyphenate words on the fly, use the
5942 @code{\%} escape, also known as the @dfn{hyphenation character}.
5943 Preceding a word with this character prevents it from being
5944 hyphenated; putting it inside a word indicates to @code{gtroff} that
5945 the word may be hyphenated at that point.  Note that this mechanism
5946 only affects that one occurrence of the word; to change the
5947 hyphenation of a word for the entire document, use the @code{hw}
5948 request.
5950 The @code{\:} escape inserts a zero-width break point
5951 (that is, the word breaks but without adding a hyphen).
5953 @Example
5954 ... check the /var/log/\:httpd/\:access_log file ...
5955 @endExample
5957 @cindex @code{\X}, followed by @code{\%}
5958 @cindex @code{\Y}, followed by @code{\%}
5959 @cindex @code{\%}, following @code{\X} or @code{\Y}
5960 Note that @code{\X} and @code{\Y} start a word, that is, the @code{\%}
5961 escape in (say) @w{@samp{ \X'...'\%foobar}} and
5962 @w{@samp{ \Y'...'\%foobar}} no longer prevents hyphenation but inserts
5963 a hyphenation point at the beginning of @samp{foobar}; most likely
5964 this isn't what you want to do.
5965 @endDefesc
5967 @Defreq {hc, [@Var{char}]}
5968 Change the hyphenation character to @var{char}.  This character then
5969 works the same as the @code{\%} escape, and thus, no longer appears in
5970 the output.  Without an argument, @code{hc} resets the hyphenation
5971 character to be @code{\%} (the default) only.
5973 The hyphenation character is associated with the current environment
5974 (@pxref{Environments}).
5975 @endDefreq
5977 @DefreqList {hpf, pattern_file}
5978 @DefreqItem {hpfa, pattern_file}
5979 @DefreqListEnd {hpfcode, a b [c d @dots{}]}
5980 @cindex hyphenation patterns (@code{hpf})
5981 @cindex patterns for hyphenation (@code{hpf})
5982 Read in a file of hyphenation patterns.  This file is searched for in
5983 the same way as @file{@var{name}.tmac} (or @file{tmac.@var{name}}) is
5984 searched for if the @option{-m@var{name}} option is specified.
5986 It should have the same format as (simple) @TeX{} patterns files.
5987 More specifically, the following scanning rules are implemented.
5989 @itemize @bullet
5990 @item
5991 A percent sign starts a comment (up to the end of the line)
5992 even if preceded by a backslash.
5994 @item
5995 No support for `digraphs' like @code{\$}.
5997 @item
5998 @code{^^@var{xx}} (@var{x} is 0-9 or a-f) and @code{^^@var{x}} (character
5999 code of @var{x} in the range 0-127) are recognized; other use of @code{^}
6000 causes an error.
6002 @item
6003 No macro expansion.
6005 @item
6006 @code{hpf} checks for the expression @code{\patterns@{@dots{}@}}
6007 (possibly with whitespace before and after the braces).
6008 Everything between the braces is taken as hyphenation patterns.
6009 Consequently, @code{@{} and @code{@}} are not allowed in patterns.
6011 @item
6012 Similarly, @code{\hyphenation@{@dots{}@}} gives a list of hyphenation
6013 exceptions.
6015 @item
6016 @code{\endinput} is recognized also.
6018 @item
6019 For backwards compatibility, if @code{\patterns} is missing,
6020 the whole file is treated as a list of hyphenation patterns
6021 (only recognizing the @code{%} character as the start of a comment).
6022 @end itemize
6024 If no @code{hpf} request is specified (either in the document or in a
6025 macro package), @code{gtroff} won't hyphenate at all.
6027 The @code{hpfa} request appends a file of patterns to the current list.
6029 The @code{hpfcode} request defines mapping values for character codes in
6030 hyphenation patterns.  @code{hpf} or @code{hpfa} then apply the mapping
6031 (after reading the patterns) before replacing or appending them to
6032 the current list of patterns.  Its arguments are pairs of character codes
6033 -- integers from 0 to@w{ }255.  The request maps character code@w{ }@var{a}
6034 to code@w{ }@var{b}, code@w{ }@var{c} to code@w{ }@var{d}, and so on.  You
6035 can use character codes which would be invalid otherwise.
6037 @pindex troffrc
6038 @pindex troffrc-end
6039 @pindex hyphen.us
6040 The set of hyphenation patterns is associated with the current language
6041 set by the @code{hla} request.  The @code{hpf} request is usually
6042 invoked by the @file{troffrc} or @file{troffrc-end} file; by default,
6043 @file{troffrc} loads hyphenation patterns for American English (in file
6044 @file{hyphen.us}).
6046 A second call to @code{hpf} (for the same language) will replace the
6047 hyphenation patterns with the new ones.
6049 Invoking @code{hpf} causes an error if there is no current hyphenation
6050 language.
6051 @endDefreq
6053 @Defreq {hcode, c1 code1 c2 code2 @dots{}}
6054 @cindex hyphenation code (@code{hcode})
6055 @cindex code, hyphenation (@code{hcode})
6056 Set the hyphenation code of character @var{c1} to @var{code1}, that of
6057 @var{c2} to @var{code2}, etc.  A hyphenation code must be a single
6058 input character (not a special character) other than a digit or a
6059 space.  Initially each lower-case letter (@samp{a}-@samp{z}) has its
6060 hyphenation code set to itself, and each upper-case letter
6061 (@samp{A}-@samp{Z}) has a hyphenation code which is the lower-case
6062 version of itself.
6064 This request is ignored if it has no parameter.
6065 @endDefreq
6067 @DefreqList {hym, [@Var{length}]}
6068 @DefregListEnd {.hym}
6069 @cindex hyphenation margin (@code{hym})
6070 @cindex margin for hyphenation (@code{hym})
6071 @cindex @code{ad} request, and hyphenation margin
6072 Set the (right) hyphenation margin to @var{length}.  If the current
6073 adjustment mode is not @samp{b} or @samp{n}, the line is not
6074 hyphenated if it is shorter than @var{length}.  Without an argument,
6075 the hyphenation margin is reset to its default value, which is@w{ }0.
6076 The default scaling indicator for this request is @samp{m}.  The
6077 hyphenation margin is associated with the current environment
6078 (@pxref{Environments}).
6080 A negative argument resets the hyphenation margin to zero, emitting
6081 a warning of type @samp{range}.
6083 @cindex hyphenation margin register (@code{.hym})
6084 The current hyphenation margin is available in the @code{.hym} read-only
6085 number register.
6086 @endDefreq
6088 @DefreqList {hys, [@Var{hyphenation_space}]}
6089 @DefregListEnd {.hys}
6090 @cindex hyphenation space (@code{hys})
6091 @cindex @code{ad} request, and hyphenation space
6092 Set the hyphenation space to @var{hyphenation_space}.  If the current
6093 adjustment mode is @samp{b} or @samp{n}, don't hyphenate the line
6094 if it can be justified by adding no more than @var{hyphenation_space}
6095 extra space to each word space.  Without argument, the hyphenation
6096 space is set to its default value, which is@w{ }0.  The default
6097 scaling indicator for this request is @samp{m}.  The hyphenation
6098 space is associated with the current environment
6099 (@pxref{Environments}).
6101 A negative argument resets the hyphenation space to zero, emitting a
6102 warning of type @samp{range}.
6104 @cindex hyphenation space register (@code{.hys})
6105 The current hyphenation space is available in the @code{.hys} read-only
6106 number register.
6107 @endDefreq
6109 @Defreq {shc, [@Var{glyph}]}
6110 @cindex soft hyphen character, setting (@code{shc})
6111 @cindex character, soft hyphen, setting (@code{shc})
6112 @cindex glyph, soft hyphen (@code{hy})
6113 @cindex soft hyphen glyph (@code{hy})
6114 @cindex @code{char} request, and soft hyphen character
6115 @cindex @code{tr} request, and soft hyphen character
6116 Set the @dfn{soft hyphen character} to @var{glyph}.@footnote{@dfn{Soft
6117 hyphen character} is a misnomer since it is an output glyph.}  If the
6118 argument is omitted, the soft hyphen character is set to the default
6119 glyph @code{\(hy} (this is the start-up value of @code{gtroff} also).
6120 The soft hyphen character is the glyph that is inserted when a word is
6121 hyphenated at a line break.  If the soft hyphen character does not
6122 exist in the font of the character immediately preceding a potential
6123 break point, then the line is not broken at that point.  Neither
6124 definitions (specified with the @code{char} request) nor translations
6125 (specified with the @code{tr} request) are considered when finding the
6126 soft hyphen character.
6127 @endDefreq
6129 @DefreqList {hla, language}
6130 @DefregListEnd {.hla}
6131 @cindex @code{hpf} request, and hyphenation language
6132 @cindex @code{hw} request, and hyphenation language
6133 @pindex troffrc
6134 @pindex troffrc-end
6135 Set the current hyphenation language to the string @var{language}.
6136 Hyphenation exceptions specified with the @code{hw} request and
6137 hyphenation patterns specified with the @code{hpf} and @code{hpfa}
6138 requests are both associated with the current hyphenation language.
6139 The @code{hla} request is usually invoked by the @file{troffrc} or the
6140 @file{troffrc-end} files; @file{troffrc} sets the default language to
6141 @samp{us}.
6143 @cindex hyphenation language register (@code{.hla})
6144 The current hyphenation language is available as a string in the
6145 read-only number register @samp{.hla}.
6147 @Example
6148 .ds curr_language \n[.hla]
6149 \*[curr_language]
6150     @result{} us
6151 @endExample
6152 @endDefreq
6155 @c =====================================================================
6157 @node Manipulating Spacing, Tabs and Fields, Manipulating Hyphenation, gtroff Reference
6158 @section Manipulating Spacing
6159 @cindex manipulating spacing
6160 @cindex spacing, manipulating
6162 @Defreq {sp, [@Var{distance}]}
6163 Space downwards @var{distance}.  With no argument it advances 1@w{
6164 }line.  A negative argument causes @code{gtroff} to move up the page
6165 the specified distance.  If the argument is preceded by a @samp{|}
6166 then @code{gtroff} moves that distance from the top of the page.  This
6167 request causes a line break.  The default scaling indicator is @samp{v}.
6168 @endDefreq
6170 @DefreqList {ls, [@Var{nnn}]}
6171 @DefregListEnd {.L}
6172 @cindex double-spacing (@code{ls})
6173 Output @w{@var{nnn}@minus{}1} blank lines after each line of text.
6174 With no argument, @code{gtroff} uses the previous value before the
6175 last @code{ls} call.
6177 @Example
6178 .ls 2    \" This causes double-spaced output
6179 .ls 3    \" This causes triple-spaced output
6180 .ls      \" Again double-spaced
6181 @endExample
6183 The line spacing is associated with the current environment
6184 (@pxref{Environments}).
6186 @cindex line spacing register (@code{.L})
6187 The read-only number register @code{.L} contains the current line
6188 spacing setting.
6189 @endDefreq
6191 @xref{Changing Type Sizes}, for the requests @code{vs} and @code{pvs}
6192 as alternatives to @code{ls}.
6194 @DefescList {\\x, ', spacing, '}
6195 @DefregListEnd {.a}
6196 Sometimes, extra vertical spacing is only needed occasionally, e.g.@:
6197 to allow space for a tall construct (like an equation).  The @code{\x}
6198 escape does this.  The escape is given a numerical argument, usually
6199 enclosed in quotes (like @samp{\x'3p'}); the default scaling indicator
6200 is @samp{v}.  If this number is positive extra vertical space is
6201 inserted below the current line.  A negative number adds space above.
6202 If this escape is used multiple times on the same line, the maximum of
6203 the values is used.
6205 @xref{Escapes}, for details on parameter delimiting characters.
6207 @cindex extra post-vertical line space register (@code{.a})
6208 The @code{.a} read-only number register contains the most recent
6209 (nonnegative) extra vertical line space.
6211 Using @code{\x} can be necessary in combination with the @code{\b}
6212 escape, as the following example shows.
6214 @Example
6215 This is a test with the \[rs]b escape.
6217 This is a test with the \[rs]b escape.
6219 This is a test with \b'xyz'\x'-1m'\x'1m'.
6221 This is a test with the \[rs]b escape.
6223 This is a test with the \[rs]b escape.
6224 @endExample
6226 @noindent
6227 produces
6229 @Example
6230 This is a test with the \b escape.
6231 This is a test with the \b escape.
6232                     x
6233 This is a test with y.
6234                     z
6235 This is a test with the \b escape.
6236 This is a test with the \b escape.
6237 @endExample
6238 @endDefesc
6240 @DefreqList {ns, }
6241 @DefreqItem {rs, }
6242 @DefregListEnd {.ns}
6243 @cindex @code{sp} request, and no-space mode
6244 @cindex no-space mode (@code{ns})
6245 @cindex mode, no-space (@code{ns})
6246 @cindex blank lines, disabling
6247 @cindex lines, blank, disabling
6248 Enable @dfn{no-space mode}.  In this mode, spacing (either via
6249 @code{sp} or via blank lines) is disabled.  The @code{bp} request to
6250 advance to the next page is also disabled, except if it is accompanied
6251 by a page number (see @ref{Page Control}, for more information).  This
6252 mode ends when actual text is output or the @code{rs} request is
6253 encountered which ends no-space mode.  The read-only number register
6254 @code{.ns} is set to@w{ }1 as long as no-space mode is active.
6256 This request is useful for macros that conditionally
6257 insert vertical space before the text starts
6258 (for example, a paragraph macro could insert some space
6259 except when it is the first paragraph after a section header).
6260 @endDefreq
6263 @c =====================================================================
6265 @node Tabs and Fields, Character Translations, Manipulating Spacing, gtroff Reference
6266 @section Tabs and Fields
6267 @cindex tabs, and fields
6268 @cindex fields, and tabs
6270 @cindex @acronym{EBCDIC} encoding of a tab
6271 A tab character (@acronym{ASCII} char@w{ }9, @acronym{EBCDIC} char@w{
6272 }5) causes a horizontal movement to the next tab stop (much
6273 like it did on a typewriter).
6275 @Defesc {\\t, , , }
6276 @cindex tab character, non-interpreted (@code{\t})
6277 @cindex character, tab, non-interpreted (@code{\t})
6278 This escape is a non-interpreted tab character.  In copy mode
6279 (@pxref{Copy-in Mode}), @code{\t} is the same as a real tab character.
6280 @endDefesc
6282 @DefreqList {ta, [@Var{n1} @Var{n2} @dots{} @Var{nn} @t{T} @Var{r1} @Var{r2} @dots{} @Var{rn}]}
6283 @DefregListEnd {.tabs}
6284 Change tab stop positions.  This request takes a series of tab
6285 specifiers as arguments (optionally divided into two groups with the
6286 letter @samp{T}) which indicate where each tab stop is to be
6287 (overriding any previous settings).
6289 Tab stops can be specified absolutely, i.e., as the distance from the
6290 left margin.  For example, the following sets 6@w{ }tab stops every
6291 one inch.
6293 @Example
6294 .ta 1i 2i 3i 4i 5i 6i
6295 @endExample
6297 Tab stops can also be specified using a leading @samp{+}
6298 which means that the specified tab stop is set relative to
6299 the previous tab stop.  For example, the following is equivalent to the
6300 previous example.
6302 @Example
6303 .ta 1i +1i +1i +1i +1i +1i
6304 @endExample
6306 @code{gtroff} supports an extended syntax to specify repeat values after
6307 the @samp{T} mark (these values are always taken as relative) -- this is
6308 the usual way to specify tabs set at equal intervals.  The following is,
6309 yet again, the same as the previous examples.  It does even more since
6310 it defines an infinite number of tab stops separated by one inch.
6312 @Example
6313 .ta T 1i
6314 @endExample
6316 Now we are ready to interpret the full syntax given at the beginning:
6317 Set tabs at positions @var{n1}, @var{n2}, @dots{}, @var{nn} and then set
6318 tabs at @var{nn}+@var{r1}, @var{nn}+@var{r2}, @dots{}, @var{nn}+@var{rn}
6319 and then at @var{nn}+@var{rn}+@var{r1}, @var{nn}+@var{rn}+@var{r2},
6320 @dots{}, @var{nn}+@var{rn}+@var{rn}, and so on.
6322 Example: @samp{4c +6c T 3c 5c 2c} is equivalent to @samp{4c 10c 13c 18c
6323 20c 23c 28c 30c @dots{}}.
6325 The material in each tab column (i.e., the column between two tab stops)
6326 may be justified to the right or left or centered in the column.  This
6327 is specified by appending @samp{R}, @samp{L}, or @samp{C} to the tab
6328 specifier.  The default justification is @samp{L}.  Example:
6330 @Example
6331 .ta 1i 2iC 3iR
6332 @endExample
6334 Some notes:
6336 @itemize @bullet
6337 @item
6338 The default unit of the @code{ta} request is @samp{m}.
6340 @item
6341 A tab stop is converted into a non-breakable horizontal movement which
6342 can be neither stretched nor squeezed.  For example,
6344 @Example
6345 .ds foo a\tb\tc
6346 .ta T 5i
6347 \*[foo]
6348 @endExample
6350 @noindent
6351 creates a single line which is a bit longer than 10@w{ }inches (a string
6352 is used to show exactly where the tab characters are).  Now consider the
6353 following:
6355 @Example
6356 .ds bar a\tb b\tc
6357 .ta T 5i
6358 \*[bar]
6359 @endExample
6361 @noindent
6362 @code{gtroff} first converts the tab stops of the line into unbreakable
6363 horizontal movements, then splits the line after the second @samp{b}
6364 (assuming a sufficiently short line length).  Usually, this isn't what
6365 the user wants.
6367 @item
6368 Superfluous tabs (i.e., tab characters which do not correspond to a tab
6369 stop) are ignored except the first one which delimits the characters
6370 belonging to the last tab stop for right-justifying or centering.
6371 Consider the following example
6373 @Example
6374 .ds Z   foo\tbar\tfoo
6375 .ds ZZ  foo\tbar\tfoobar
6376 .ds ZZZ foo\tbar\tfoo\tbar
6377 .ta 2i 4iR
6378 \*[Z]
6380 \*[ZZ]
6382 \*[ZZZ]
6384 @endExample
6386 @noindent
6387 which produces the following output:
6389 @Example
6390 foo                 bar              foo
6391 foo                 bar           foobar
6392 foo                 bar              foobar
6393 @endExample
6395 @noindent
6396 The first line right-justifies the second `foo' relative to the tab
6397 stop.  The second line right-justifies `foobar'.  The third line finally
6398 right-justifies only `foo' because of the additional tab character which
6399 marks the end of the string belonging to the last defined tab stop.
6401 @item
6402 Tab stops are associated with the current environment
6403 (@pxref{Environments}).
6405 @item
6406 Calling @code{ta} without an argument removes all tab stops.
6408 @item
6409 @cindex tab stops, for TTY output devices
6410 The start-up value of @code{gtroff} is @w{@samp{T 0.5i}} in troff mode
6411 and @w{@samp{T 0.8i}} in nroff mode (the latter is done with an
6412 explicit call to the @code{ta} request in the file @file{tty.tmac}.
6413 @end itemize
6415 @cindex tab settings register (@code{.tabs})
6416 The read-only number register @code{.tabs} contains a string
6417 representation of the current tab settings suitable for use as an
6418 argument to the @code{ta} request.
6420 @Example
6421 .ds tab-string \n[.tabs]
6422 \*[tab-string]
6423     @result{} T120u
6424 @endExample
6426 @cindex @code{.S} register, Plan@w{ }9 alias for @code{.tabs}
6427 @cindex @code{.tabs} register, Plan@w{ }9 alias (@code{.S})
6428 The @code{troff} version of the Plan@w{ }9 operating system uses
6429 register @code{.S} for the same purpose.
6430 @endDefreq
6432 @Defreq {tc, [@Var{fill-glyph}]}
6433 @cindex tab repetition character (@code{tc})
6434 @cindex character, tab repetition (@code{tc})
6435 @cindex glyph, tab repetition (@code{tc})
6436 Normally @code{gtroff} fills the space to the next tab stop with
6437 whitespace.  This can be changed with the @code{tc} request.  With no
6438 argument @code{gtroff} reverts to using whitespace, which is the
6439 default.  The value of this @dfn{tab repetition character} is
6440 associated with the current environment
6441 (@pxref{Environments}).@footnote{@dfn{Tab repetition character} is a
6442 misnomer since it is an output glyph.}
6443 @endDefreq
6445 @DefreqList {linetabs, n}
6446 @DefregListEnd {.linetabs}
6447 @cindex tab, line-tabs mode
6448 @cindex line-tabs mode
6449 @cindex mode, line-tabs
6450 If @var{n} is missing or not zero, enable @dfn{line-tabs} mode,
6451 or disable it otherwise (the default).
6452 In line-tabs mode, @code{gtroff} computes tab distances
6453 relative to the (current) output line instead of the input line.
6455 For example, the following code:
6457 @Example
6458 .ds x a\t\c
6459 .ds y b\t\c
6460 .ds z c
6461 .ta 1i 3i
6465 @endExample
6467 @noindent
6468 in normal mode, results in the output
6470 @Example
6471 a         b         c
6472 @endExample
6474 @noindent
6475 in line-tabs mode, the same code outputs
6477 @Example
6478 a         b                   c
6479 @endExample
6481 Line-tabs mode is associated with the current environment.
6482 The read-only register @code{.linetabs} is set to@w{ }1 if in line-tabs
6483 mode, and 0 in normal mode.
6484 @endDefreq
6486 @menu
6487 * Leaders::
6488 * Fields::
6489 @end menu
6491 @c ---------------------------------------------------------------------
6493 @node Leaders, Fields, Tabs and Fields, Tabs and Fields
6494 @subsection Leaders
6495 @cindex leaders
6497 Sometimes it may may be desirable to use the @code{tc} request to fill a
6498 particular tab stop with a given glyph (for example dots in a table
6499 of contents), but also normal tab stops on the rest of the line.  For
6500 this @code{gtroff} provides an alternate tab mechanism, called
6501 @dfn{leaders} which does just that.
6503 @cindex leader character
6504 A leader character (character code@w{ }1) behaves similarly to a tab
6505 character: It moves to the next tab stop.  The only difference is that
6506 for this movement, the fill glyph defaults to a period character and
6507 not to space.
6509 @Defesc {\\a, , , }
6510 @cindex leader character, non-interpreted (@code{\a})
6511 @cindex character, leader, non-interpreted (@code{\a})
6512 This escape is a non-interpreted leader character.  In copy mode
6513 (@pxref{Copy-in Mode}), @code{\a} is the same as a real leader
6514 character.
6515 @endDefesc
6517 @Defreq {lc, [@Var{fill-glyph}]}
6518 @cindex leader repetition character (@code{lc})
6519 @cindex character, leader repetition (@code{lc})
6520 @cindex glyph, leader repetition (@code{lc})
6521 Declare the @dfn{leader repetition character}.@footnote{@dfn{Leader
6522 repetition character} is a misnomer since it is an output glyph.}
6523 Without an argument, leaders act the same as tabs (i.e., using
6524 whitespace for filling).  @code{gtroff}'s start-up value is a dot
6525 (@samp{.}).  The value of the leader repetition character is
6526 associated with the current environment (@pxref{Environments}).
6527 @endDefreq
6529 @cindex table of contents
6530 @cindex contents, table of
6531 For a table of contents, to name an example, tab stops may be defined so
6532 that the section number is one tab stop, the title is the second with
6533 the remaining space being filled with a line of dots, and then the page
6534 number slightly separated from the dots.
6536 @Example
6537 .ds entry 1.1\tFoo\a\t12
6538 .lc .
6539 .ta 1i 5i +.25i
6540 \*[entry]
6541 @endExample
6543 @noindent
6544 This produces
6546 @Example
6547 1.1  Foo..........................................  12
6548 @endExample
6550 @c ---------------------------------------------------------------------
6552 @node Fields,  , Leaders, Tabs and Fields
6553 @subsection Fields
6554 @cindex fields
6556 @cindex field delimiting character (@code{fc})
6557 @cindex delimiting character, for fields (@code{fc})
6558 @cindex character, field delimiting (@code{fc})
6559 @cindex field padding character (@code{fc})
6560 @cindex padding character, for fields (@code{fc})
6561 @cindex character, field padding (@code{fc})
6562 @dfn{Fields} are a more general way of laying out tabular data.  A field
6563 is defined as the data between a pair of @dfn{delimiting characters}.
6564 It contains substrings which are separated by @dfn{padding characters}.
6565 The width of a field is the distance on the @emph{input} line from the
6566 position where the field starts to the next tab stop.  A padding
6567 character inserts stretchable space similar to @TeX{}'s @code{\hss}
6568 command (thus it can even be negative) to make the sum of all substring
6569 lengths plus the stretchable space equal to the field width.  If more
6570 than one padding character is inserted, the available space is evenly
6571 distributed among them.
6573 @Defreq {fc, [@Var{delim-char} [@Var{padding-char}]]}
6574 Define a delimiting and a padding character for fields.  If the latter
6575 is missing, the padding character defaults to a space character.  If
6576 there is no argument at all, the field mechanism is disabled (which is
6577 the default).  Note that contrary to e.g.@: the tab repetition
6578 character, delimiting and padding characters are @emph{not} associated
6579 to the current environment (@pxref{Environments}).
6581 Example:
6583 @Example
6584 .fc # ^
6585 .ta T 3i
6586 #foo^bar^smurf#
6588 #foo^^bar^smurf#
6589 @endExample
6591 @noindent
6592 and here the result:
6594 @Example
6595 foo         bar          smurf
6596 foo            bar       smurf
6597 @endExample
6598 @endDefreq
6601 @c =====================================================================
6603 @node Character Translations, Troff and Nroff Mode, Tabs and Fields, gtroff Reference
6604 @section Character Translations
6605 @cindex character translations
6606 @cindex translations of characters
6608 @cindex control character, changing (@code{cc})
6609 @cindex character, control, changing (@code{cc})
6610 @cindex no-break control character, changing (@code{c2})
6611 @cindex character, no-break control, changing (@code{c2})
6612 @cindex control character, no-break, changing (@code{c2})
6613 The control character (@samp{.}) and the no-break control character
6614 (@samp{'}) can be changed with the @code{cc} and @code{c2} requests,
6615 respectively.
6617 @Defreq {cc, [@Var{c}]}
6618 Set the control character to@w{ }@var{c}.  With no argument the default
6619 control character @samp{.} is restored.  The value of the control
6620 character is associated with the current environment
6621 (@pxref{Environments}).
6622 @endDefreq
6624 @Defreq {c2, [@Var{c}]}
6625 Set the no-break control character to@w{ }@var{c}.  With no argument the
6626 default control character @samp{'} is restored.  The value of the
6627 no-break control character is associated with the current environment
6628 (@pxref{Environments}).
6629 @endDefreq
6631 @Defreq {eo, }
6632 @cindex disabling @code{\} (@code{eo})
6633 @cindex @code{\}, disabling (@code{eo})
6634 Disable the escape mechanism completely.  After executing this
6635 request, the backslash character @samp{\} no longer starts an escape
6636 sequence.
6638 This request can be very helpful in writing macros since it is not
6639 necessary then to double the escape character.  Here an example:
6641 @Example
6642 .\" This is a simplified version of the
6643 .\" .BR request from the man macro package
6645 .de BR
6646 .  ds result \&
6647 .  while (\n[.$] >= 2) \@{\
6648 .    as result \fB\$1\fR\$2
6649 .    shift 2
6650 .  \@}
6651 .  if \n[.$] .as result \fB\$1
6652 \*[result]
6653 .  ft R
6656 @endExample
6657 @endDefreq
6659 @Defreq {ec, [@Var{c}]}
6660 @cindex escape character, changing (@code{ec})
6661 @cindex character, escape, changing (@code{ec})
6662 Set the escape character to@w{ }@var{c}.  With no argument the default
6663 escape character @samp{\} is restored.  It can be also used to
6664 re-enable the escape mechanism after an @code{eo} request.
6666 Note that changing the escape character globally will likely break
6667 macro packages since @code{gtroff} has no mechanism to `intern' macros,
6668 i.e., to convert a macro definition into an internal form which is
6669 independent of its representation (@TeX{} has this mechanism).
6670 If a macro is called, it is executed literally.
6671 @endDefreq
6673 @DefreqList {ecs, }
6674 @DefreqListEnd {ecr, }
6675 The @code{ecs} request saves the current escape character
6676 in an internal register.
6677 Use this request in combination with the @code{ec} request to
6678 temporarily change the escape character.
6680 The @code{ecr} request restores the escape character
6681 saved with @code{ecs}.
6682 Without a previous call to @code{ecs}, this request
6683 sets the escape character to @code{\}.
6684 @endDefreq
6686 @DefescList {\\\\, , , }
6687 @DefescItem {\\e, , , }
6688 @DefescListEnd {\\E, , , }
6689 Print the current escape character (which is the backslash character
6690 @samp{\} by default).
6692 @code{\\} is a `delayed' backslash; more precisely, it is the default
6693 escape character followed by a backslash, which no longer has special
6694 meaning due to the leading escape character.  It is @emph{not} an escape
6695 sequence in the usual sense!  In any unknown escape sequence
6696 @code{\@var{X}} the escape character is ignored and @var{X} is printed.
6697 But if @var{X} is equal to the current escape character, no warning is
6698 emitted.
6700 As a consequence, only at top-level or in a diversion a backslash glyph is
6701 printed; in copy-in mode, it expands to a single backslash which then
6702 combines with the following character to an escape sequence.
6704 The @code{\E} escape differs from @code{\e} by printing an escape
6705 character that is not interpreted in copy mode.
6706 Use this to define strings with escapes that work
6707 when used in copy mode (for example, as a macro argument).
6708 The following example defines strings to begin and end
6709 a superscript:
6711 @Example
6712 .ds @{ \v'-.3m'\s'\Es[.s]*60/100'
6713 .ds @} \s0\v'.3m'
6714 @endExample
6716 Another example to demonstrate the differences between the various escape
6717 sequences, using a strange escape character, @samp{-}.
6719 @Example
6720 .ec -
6721 .de xxx
6722 --A'123'
6724 .xxx
6725     @result{} -A'foo'
6726 @endExample
6728 @noindent
6729 The result is surprising for most users, expecting @samp{1} since
6730 @samp{foo} is a valid identifier.  What has happened?  As mentioned
6731 above, the leading escape character makes the following character
6732 ordinary.  Written with the default escape character the sequence
6733 @samp{--} becomes @samp{\-} -- this is the minus sign.
6735 If the escape character followed by itself is a valid escape sequence,
6736 only @code{\E} yields the expected result:
6738 @Example
6739 .ec -
6740 .de xxx
6741 -EA'123'
6743 .xxx
6744     @result{} 1
6745 @endExample
6746 @endDefesc
6748 @Defesc {\\., , , }
6749 Similar to @code{\\}, the sequence @code{\.} isn't a real escape sequence.
6750 As before, a warning message is suppressed if the escape character is
6751 followed by a dot, and the dot itself is printed.
6753 @Example
6754 .de foo
6755 .  nop foo
6757 .  de bar
6758 .    nop bar
6759 \\..
6762 .foo
6763 .bar
6764     @result{} foo bar
6765 @endExample
6767 @noindent
6768 The first backslash is consumed while the macro is read, and the second
6769 is swallowed while exexuting macro @code{foo}.
6770 @endDefesc
6772 A @dfn{translation} is a mapping of an input character to an output
6773 glyph.  The mapping occurs at output time, i.e., the input character
6774 gets assigned the metric information of the mapped output character
6775 right before input tokens are converted to nodes (@pxref{Gtroff
6776 Internals}, for more on this process).
6778 @DefreqList {tr, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
6779 @DefreqListEnd {trin, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
6780 Translate character @var{a} to glyph@w{ }@var{b}, character @var{c} to
6781 glyph@w{ }@var{d}, etc.  If there is an odd number of arguments, the
6782 last one is translated to an unstretchable space (@w{@samp{\ }}).
6784 The @code{trin} request is identical to @code{tr},
6785 but when you unformat a diversion with @code{asciify}
6786 it ignores the translation.
6787 @xref{Diversions}, for details about the @code{asciify} request.
6789 Some notes:
6791 @itemize @bullet
6792 @item
6793 @cindex @code{\(}, and translations
6794 @cindex @code{\[}, and translations
6795 @cindex @code{\'}, and translations
6796 @cindex @code{\`}, and translations
6797 @cindex @code{\-}, and translations
6798 @cindex @code{\_}, and translations
6799 @cindex @code{\C}, and translations
6800 @cindex @code{\N}, and translations
6801 @cindex @code{char} request, and translations
6802 @cindex special characters
6803 @cindex character, special
6804 @cindex numbered glyph (@code{\N})
6805 @cindex glyph, numbered (@code{\N})
6806 Special characters (@code{\(@var{xx}}, @code{\[@var{xxx}]},
6807 @code{\C'@var{xxx}'}, @code{\'}, @code{\`}, @code{\-}, @code{\_}),
6808 glyphs defined with the @code{char} request, and numbered glyphs
6809 (@code{\N'@var{xxx}'}) can be translated also.
6811 @item
6812 @cindex @code{\e}, and translations
6813 The @code{\e} escape can be translated also.
6815 @item
6816 @cindex @code{\%}, and translations
6817 @cindex @code{\~}, and translations
6818 Characters can be mapped onto the @code{\%} and @code{\~} escapes (but
6819 @code{\%} and @code{\~} can't be mapped onto another glyph).
6821 @item
6822 @cindex backspace character, and translations
6823 @cindex character, backspace, and translations
6824 @cindex leader character, and translations
6825 @cindex character, leader, and translations
6826 @cindex newline character, and translations
6827 @cindex character, newline, and translations
6828 @cindex tab character, and translations
6829 @cindex character, tab, and translations
6830 @cindex @code{\a}, and translations
6831 @cindex @code{\t}, and translations
6832 The following characters can't be translated: space (with one exception,
6833 see below), backspace, newline, leader (and @code{\a}), tab (and
6834 @code{\t}).
6836 @item
6837 @cindex @code{shc} request, and translations
6838 Translations are not considered for finding the soft hyphen character
6839 set with the @code{shc} request.
6841 @item
6842 @cindex @code{\&}, and translations
6843 The pair @samp{@var{c}\&} (this is an arbitrary character@w{
6844 }@var{c} followed by the zero width space character) maps this
6845 character to nothing.
6847 @Example
6848 .tr a\&
6849 foo bar
6850     @result{} foo br
6851 @endExample
6853 @noindent
6854 It is even possible to map the space character to nothing:
6856 @Example
6857 .tr aa \&
6858 foo bar
6859     @result{} foobar
6860 @endExample
6862 @noindent
6863 As shown in the example, the space character can't be the first
6864 character/glyph pair as an argument of @code{tr}.  Additionally, it is
6865 not possible to map the space character to any other glyph; requests
6866 like @w{@samp{.tr aa x}} undo @w{@samp{.tr aa \&}} instead.
6868 If justification is active, lines are justified in spite of the
6869 `empty' space character (but there is no minimal distance, i.e.@: the
6870 space character, between words).
6872 @item
6873 After an output glyph has been constructed (this happens at the
6874 moment immediately before the glyph is appended to an output
6875 glyph list, either by direct output, in a macro, diversion, or
6876 string), it is no longer affected by @code{tr}.
6878 @item
6879 Translating character to glyphs where one of them or both are
6880 undefined is possible also; @code{tr} does not check whether the
6881 entities in its argument do exist.
6883 @xref{Gtroff Internals}.
6885 @item
6886 @code{troff} no longer has a hard-coded dependency on @w{Latin-1};
6887 all @code{char@var{XXX}} entities have been removed from the font
6888 description files.  This has a notable consequence which shows up in
6889 warnings like @code{can't find character with input code @var{XXX}}
6890 if the @code{tr} request isn't handled properly.
6892 Consider the following translation:
6894 @Example
6895 .tr @'e@'E
6896 @endExample
6898 @noindent
6899 This maps input character @code{@'e} onto glyph @code{@'E}, which is
6900 identical to glyph @code{char201}.  But this glyph intentionally
6901 doesn't exist!  Instead, @code{\[char201]} is treated as an input
6902 character entity and is by default mapped onto @code{\['E]}, and
6903 @code{gtroff} doesn't handle translations of translations.
6905 The right way to write the above translation is
6907 @Example
6908 .tr @'e\['E]
6909 @endExample
6911 @noindent
6912 With other words, the first argument of @code{tr} should be an input
6913 character or entity, and the second one a glyph entity.
6915 @item
6916 Without an argument, the @code{tr} request is ignored.
6917 @end itemize
6918 @endDefreq
6920 @Defreq {trnt, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
6921 @cindex @code{\!}, and @code{trnt}
6922 @code{trnt} is the same as the @code{tr} request except that the
6923 translations do not apply to text that is transparently throughput
6924 into a diversion with @code{\!}.  @xref{Diversions}, for more
6925 information.
6927 For example,
6929 @Example
6930 .tr ab
6931 .di x
6932 \!.tm a
6935 @endExample
6937 @noindent
6938 prints @samp{b} to the standard error stream; if @code{trnt} is used
6939 instead of @code{tr} it prints @samp{a}.
6940 @endDefreq
6943 @c =====================================================================
6945 @node Troff and Nroff Mode, Line Layout, Character Translations, gtroff Reference
6946 @section Troff and Nroff Mode
6947 @cindex troff mode
6948 @cindex mode, troff
6949 @cindex nroff mode
6950 @cindex mode, nroff
6952 Originally, @code{nroff} and @code{troff} were two separate programs,
6953 the former for TTY output, the latter for everything else.  With GNU
6954 @code{troff}, both programs are merged into one executable, sending
6955 its output to a device driver (@code{grotty} for TTY devices,
6956 @code{grops} for @sc{PostScript}, etc.) which interprets the
6957 intermediate output of @code{gtroff}.  For @acronym{UNIX} @code{troff}
6958 it makes sense to talk about @dfn{Nroff mode} and @dfn{Troff mode}
6959 since the differences are hardcoded.  For GNU @code{troff}, this
6960 distinction is not appropriate because @code{gtroff} simply takes the
6961 information given in the font files for a particular device without
6962 handling requests specially if a TTY output device is used.
6964 Usually, a macro package can be used with all output devices.
6965 Nevertheless, it is sometimes necessary to make a distinction between
6966 TTY and non-TTY devices: @code{gtroff} provides two built-in
6967 conditions @samp{n} and @samp{t} for the @code{if}, @code{ie}, and
6968 @code{while} requests to decide whether @code{gtroff} shall behave
6969 like @code{nroff} or like @code{troff}.
6971 @Defreq {troff, }
6972 @pindex troffrc
6973 @pindex troffrc-end
6974 Make the @samp{t} built-in condition true (and the @samp{n} built-in
6975 condition false) for @code{if}, @code{ie}, and @code{while}
6976 conditional requests.  This is the default if @code{gtroff}
6977 (@emph{not} @code{groff}) is started with the @option{-R} switch to
6978 avoid loading of the start-up files @file{troffrc} and
6979 @file{troffrc-end}.  Without @option{-R}, @code{gtroff} stays in troff
6980 mode if the output device is not a TTY (e.g.@: `ps').
6981 @endDefreq
6983 @Defreq {nroff, }
6984 @pindex tty.tmac
6985 Make the @samp{n} built-in condition true (and the @samp{t} built-in
6986 condition false) for @code{if}, @code{ie}, and @code{while}
6987 conditional requests.  This is the default if @code{gtroff} uses a TTY
6988 output device; the code for switching to nroff mode is in the file
6989 @file{tty.tmac} which is loaded by the start-up file @code{troffrc}.
6990 @endDefreq
6992 @xref{Conditionals and Loops}, for more details on built-in
6993 conditions.
6996 @c =====================================================================
6998 @node Line Layout, Line Control, Troff and Nroff Mode, gtroff Reference
6999 @section Line Layout
7000 @cindex line layout
7001 @cindex layout, line
7003 @cindex dimensions, line
7004 @cindex line dimensions
7005 The following drawing shows the dimensions which @code{gtroff} uses for
7006 placing a line of output onto the page.  They are labeled with the
7007 request which manipulates each dimension.
7009 @Example
7010                 -->| in |<--
7011                    |<-----------ll------------>|
7012               +----+----+----------------------+----+
7013               |    :    :                      :    |
7014               +----+----+----------------------+----+
7015            -->| po |<--
7016               |<--------paper width---------------->|
7017 @endExample
7019 @noindent
7020 These dimensions are:
7022 @ftable @code
7023 @item po
7024 @cindex left margin (@code{po})
7025 @cindex margin, left (@code{po})
7026 @cindex page offset (@code{po})
7027 @cindex offset, page (@code{po})
7028 @dfn{Page offset} -- this is the leftmost position of text on the final
7029 output, defining the @dfn{left margin}.
7031 @item in
7032 @cindex indentation (@code{in})
7033 @cindex line indentation (@code{in})
7034 @dfn{Indentation} -- this is the distance from the left margin where
7035 text is printed.
7037 @item ll
7038 @cindex line length (@code{ll})
7039 @cindex length of line (@code{ll})
7040 @dfn{Line length} -- this is the distance from the left margin to right
7041 margin.
7042 @end ftable
7044 A simple demonstration:
7046 @Example
7047 .ll 3i
7048 This is text without indentation.
7049 The line length has been set to 3\~inch.
7050 .in +.5i
7051 .ll -.5i
7052 Now the left and right margins are both increased.
7055 Calling .in and .ll without parameters restore
7056 the previous values.
7057 @endExample
7059 Result:
7061 @Example
7062 This  is text without indenta-
7063 tion.   The  line  length  has
7064 been set to 3 inch.
7065      Now   the  left  and
7066      right  margins   are
7067      both increased.
7068 Calling  .in  and  .ll without
7069 parameters restore the  previ-
7070 ous values.
7071 @endExample
7073 @DefreqList {po, [@Var{offset}]}
7074 @DefreqItem {po, @t{+}@Var{offset}}
7075 @DefreqItem {po, @t{-}@Var{offset}}
7076 @DefregListEnd {.o}
7077 @pindex troffrc
7078 Set horizontal page offset to @var{offset} (or increment or decrement
7079 the current value by @var{offset}).  Note that this request does not
7080 cause a break, so changing the page offset in the middle of text being
7081 filled may not yield the expected result.  The initial value is
7082 1@dmn{i}.  For TTY output devices, it is set to 0 in the startup file
7083 @file{troffrc}; the default scaling indicator is @samp{m} (and
7084 not @samp{v} as incorrectly documented in the original
7085 @acronym{UNIX} troff manual).
7087 The current page offset can be found in the read-only number register
7088 @samp{.o}.
7090 If @code{po} is called without an argument, the page offset is reset to
7091 the previous value before the last call to @code{po}.
7093 @Example
7094 .po 3i
7095 \n[.o]
7096     @result{} 720
7097 .po -1i
7098 \n[.o]
7099     @result{} 480
7101 \n[.o]
7102     @result{} 720
7103 @endExample
7104 @endDefreq
7106 @DefreqList {in, [@Var{indent}]}
7107 @DefreqItem {in, @t{+}@Var{indent}}
7108 @DefreqItem {in, @t{-}@Var{indent}}
7109 @DefregListEnd {.i}
7110 Set indentation to @var{indent} (or increment or decrement the
7111 current value by @var{indent}).  This request causes a break.
7112 Initially, there is no indentation.
7114 If @code{in} is called without an argument, the indentation is reset to
7115 the previous value before the last call to @code{in}.  The default
7116 scaling indicator is @samp{m}.
7118 The indentation is associated with the current environment
7119 (@pxref{Environments}).
7121 If a negative indentation value is specified (which is not allowed),
7122 @code{gtroff} emits a warning of type @samp{range} and sets the
7123 indentation to zero.
7125 The effect of @code{in} is delayed until a partially collected line (if
7126 it exists) is output.  A temporary indent value is reset to zero also.
7128 The current indentation (as set by @code{in}) can be found in the
7129 read-only number register @samp{.i}.
7130 @endDefreq
7132 @DefreqList {ti, offset}
7133 @DefreqItem {ti, @t{+}@Var{offset}}
7134 @DefreqItem {ti, @t{-}@Var{offset}}
7135 @DefregListEnd {.in}
7136 Temporarily indent the next output line by @var{offset}.  If an
7137 increment or decrement value is specified, adjust the temporary
7138 indentation relative to the value set by the @code{in} request.
7140 This request causes a break; its value is associated with the current
7141 environment (@pxref{Environments}).  The default scaling indicator
7142 is @samp{m}.  A call of @code{ti} without an argument is ignored.
7144 If the total indentation value is negative (which is not allowed),
7145 @code{gtroff} emits a warning of type @samp{range} and sets the
7146 temporary indentation to zero.  `Total indentation' is either
7147 @var{offset} if specified as an absolute value, or the temporary plus
7148 normal indentation, if @var{offset} is given as a relative value.
7150 The effect of @code{ti} is delayed until a partially collected line (if
7151 it exists) is output.
7153 The read-only number register @code{.in} is the indentation that applies
7154 to the current output line.
7156 The difference between @code{.i} and @code{.in} is that the latter takes
7157 into account whether a partially collected line still uses the old
7158 indentation value or a temporary indentation value is active.
7159 @endDefreq
7161 @DefreqList {ll, [@Var{length}]}
7162 @DefreqItem {ll, @t{+}@Var{length}}
7163 @DefreqItem {ll, @t{-}@Var{length}}
7164 @DefregItem {.l}
7165 @DefregListEnd {.ll}
7166 Set the line length to @var{length} (or increment or decrement the
7167 current value by @var{length}).  Initially, the line length is set to
7168 6.5@dmn{i}.  The effect of @code{ll} is delayed until a partially
7169 collected line (if it exists) is output.  The default scaling
7170 indicator is @samp{m}.
7172 If @code{ll} is called without an argument, the line length is reset to
7173 the previous value before the last call to @code{ll}.  If a negative
7174 line length is specified (which is not allowed), @code{gtroff} emits a
7175 warning of type @samp{range} and sets the line length to zero.
7177 The line length is associated with the current environment
7178 (@pxref{Environments}).
7180 @cindex line length register (@code{.l})
7181 The current line length (as set by @code{ll}) can be found in the
7182 read-only number register @samp{.l}.  The read-only number register
7183 @code{.ll} is the line length that applies to the current output line.
7185 Similar to @code{.i} and @code{.in}, the difference between @code{.l}
7186 and @code{.ll} is that the latter takes into account whether a partially
7187 collected line still uses the old line length value.
7188 @endDefreq
7191 @c =====================================================================
7193 @node Line Control, Page Layout, Line Layout, gtroff Reference
7194 @section Line Control
7195 @cindex line control
7196 @cindex control, line
7198 It is important to understand how @code{gtroff} handles input and output
7199 lines.
7201 Many escapes use positioning relative to the input line.  For example,
7202 this
7204 @Example
7205 This is a \h'|1.2i'test.
7207 This is a
7208 \h'|1.2i'test.
7209 @endExample
7211 @noindent
7212 produces
7214 @Example
7215 This is a   test.
7217 This is a             test.
7218 @endExample
7220 The main usage of this feature is to define macros which act exactly
7221 at the place where called.
7223 @Example
7224 .\" A simple macro to underline a word
7225 .de underline
7226 .  nop \\$1\l'|0\[ul]'
7228 @endExample
7230 @noindent
7231 In the above example, @samp{|0} specifies a negative distance from the
7232 current position (at the end of the just emitted argument @code{\$1}) back
7233 to the beginning of the input line.  Thus, the @samp{\l} escape draws a
7234 line from right to left.
7236 @cindex input line continuation (@code{\})
7237 @cindex line, input, continuation (@code{\})
7238 @cindex continuation, input line (@code{\})
7239 @cindex output line, continuation (@code{\c})
7240 @cindex line, output, continuation (@code{\c})
7241 @cindex continuation, output line (@code{\c})
7242 @cindex interrupted line
7243 @cindex line, interrupted
7244 @code{gtroff} makes a difference between input and output line
7245 continuation; the latter is also called @dfn{interrupting} a line.
7247 @DefescList {\\@key{RET}, , ,}
7248 @DefescItem {\\c, , ,}
7249 @DefregListEnd{.int}
7250 Continue a line.  @code{\@key{RET}} (this is a backslash at the end
7251 of a line immediately followed by a newline) works on the input level,
7252 suppressing the effects of the following newline in the input.
7254 @Example
7255 This is a \
7256 .test
7257     @result{} This is a .test
7258 @endExample
7260 The @samp{|} operator is also affected.
7262 @cindex @code{\R}, after @code{\c}
7263 @code{\c} works on the output level.  Anything after this escape on the
7264 same line is ignored, except @code{\R} which works as usual.  Anything
7265 before @code{\c} on the same line will be appended to the current partial
7266 output line.  The next non-command line after an interrupted line counts
7267 as a new input line.
7269 The visual results depend on whether no-fill mode is active.
7271 @itemize @bullet
7272 @item
7273 @cindex @code{\c}, and no-fill mode
7274 @cindex no-fill mode, and @code{\c}
7275 @cindex mode, no-fill, and @code{\c}
7276 If no-fill mode is active (using the @code{nf} request), the next input
7277 text line after @code{\c} will be handled as a continuation of the same
7278 input text line.
7280 @Example
7282 This is a \c
7283 test.
7284     @result{} This is a test.
7285 @endExample
7287 @item
7288 @cindex @code{\c}, and fill mode
7289 @cindex fill mode, and @code{\c}
7290 @cindex mode, fill, and @code{\c}
7291 If fill mode is active (using the @code{fi} request), a word interrupted
7292 with @code{\c} will be continued with the text on the next input text line,
7293 without an intervening space.
7295 @Example
7296 This is a te\c
7298     @result{} This is a test.
7299 @endExample
7300 @end itemize
7302 Note that an intervening control line which causes a break is stronger
7303 than @code{\c}, flushing out the current partial line in the usual way.
7305 @cindex interrupted line register (@code{.int})
7306 The @code{.int} register contains a positive value
7307 if the last output line was interrupted with @code{\c}; this is
7308 associated with the current environment (@pxref{Environments}).
7310 @endDefesc
7312 @c =====================================================================
7314 @node Page Layout, Page Control, Line Control, gtroff Reference
7315 @section Page Layout
7316 @cindex page layout
7317 @cindex layout, page
7319 @code{gtroff} provides some very primitive operations for controlling
7320 page layout.
7322 @DefreqList {pl, [@Var{length}]}
7323 @DefreqItem {pl, @t{+}@Var{length}}
7324 @DefreqItem {pl, @t{-}@Var{length}}
7325 @DefregListEnd {.p}
7326 @cindex page length (@code{pl})
7327 @cindex length of page (@code{pl})
7328 Set the @dfn{page length} to @var{length} (or increment or decrement
7329 the current value by @var{length}).  This is the length of the
7330 physical output page.  The default scaling indicator is @samp{v}.
7332 @cindex page length register (@code{.p})
7333 The current setting can be found in the read-only number register
7334 @samp{.p}.
7336 @cindex top margin
7337 @cindex margin, top
7338 @cindex bottom margin
7339 @cindex margin, bottom
7340 Note that this only specifies the size of the page, not the top and
7341 bottom margins.  Those are not set by @code{gtroff} directly.
7342 @xref{Traps}, for further information on how to do this.
7344 Negative @code{pl} values are possible also, but not very useful: No
7345 trap is sprung, and each line is output on a single page (thus
7346 suppressing all vertical spacing).
7348 If no argument or an invalid argument is given, @code{pl} sets the page
7349 length to 11@dmn{i}.
7350 @endDefreq
7352 @cindex headers
7353 @cindex footers
7354 @cindex titles
7355 @code{gtroff} provides several operations which help in setting up top
7356 and bottom titles (or headers and footers).
7358 @Defreq {tl, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}}
7359 @cindex title line (@code{tl})
7360 @cindex three-part title (@code{tl})
7361 @cindex page number character (@code{%})
7362 Print a @dfn{title line}.  It consists of three parts: a left
7363 justified portion, a centered portion, and a right justified portion.
7364 The argument separator @samp{'} can be replaced with any character not
7365 occurring in the title line.  The @samp{%} character is replaced with
7366 the current page number.  This character can be changed with the
7367 @code{pc} request (see below).
7369 Without argument, @code{tl} is ignored.
7371 Some notes:
7373 @itemize @bullet
7374 @item
7375 A title line is not restricted to the top or bottom of a page.
7377 @item
7378 @code{tl} prints the title line immediately, ignoring a partially filled
7379 line (which stays untouched).
7381 @item
7382 It is not an error to omit closing delimiters.  For example,
7383 @w{@samp{.tl /foo}} is equivalent to @w{@samp{.tl /foo///}}: It prints a
7384 title line with the left justified word @samp{foo}; the centered and
7385 right justfied parts are empty.
7387 @item
7388 Any modifications to the current environment within @code{tl} (e.g.@:
7389 changing the font or font size) are undone after processing @code{tl}.
7391 @item
7392 @code{tl} accepts the same parameter delimiting characters as the
7393 @code{\A} escape; see @ref{Escapes}.
7394 @end itemize
7395 @endDefreq
7397 @DefreqList {lt, [@Var{length}]}
7398 @DefreqItem {lt, @t{+}@Var{length}}
7399 @DefreqItem {lt, @t{-}@Var{length}}
7400 @DefregListEnd {.lt}
7401 @cindex length of title line (@code{lt})
7402 @cindex title line, length (@code{lt})
7403 @cindex title line length register (@code{.lt})
7404 The title line is printed using its own line length, which is
7405 specified (or incremented or decremented) with the @code{lt} request.
7406 Initially, the title line length is set to 6.5@dmn{i}.  If a negative
7407 line length is specified (which is not allowed), @code{gtroff} emits a
7408 warning of type @samp{range} and sets the title line length to zero.
7409 The default scaling indicator is @samp{m}.  If @code{lt} is called
7410 without an argument, the title length is reset to the previous value
7411 before the last call to @code{lt}.
7413 The current setting of this is available in the @code{.lt} read-only
7414 number register; it is associated with the current environment
7415 (@pxref{Environments}).
7417 @endDefreq
7419 @DefreqList {pn, page}
7420 @DefreqItem {pn, @t{+}@Var{page}}
7421 @DefreqItem {pn, @t{-}@Var{page}}
7422 @DefregListEnd {.pn}
7423 @cindex page number (@code{pn})
7424 @cindex number, page (@code{pn})
7425 Change (increase or decrease) the page number of the @emph{next} page.
7426 The only argument is the page number; the request is ignored without a
7427 parameter.
7429 The read-only number register @code{.pn} contains the number of the next
7430 page: either the value set by a @code{pn} request, or the number of the
7431 current page plus@w{ }1.
7432 @endDefreq
7434 @Defreg {%}
7435 @cindex page number register (@code{%})
7436 A read-write register holding the current page number.
7437 @endDefreg
7439 @Defreq {pc, [@Var{char}]}
7440 @cindex changing the page number character (@code{pc})
7441 @cindex page number character, changing (@code{pc})
7442 @vindex %
7443 Change the page number character (used by the @code{tl} request) to a
7444 different character.  With no argument, this mechanism is disabled.
7445 Note that this doesn't affect the number register@w{ }@code{%}.
7446 @endDefreq
7448 @xref{Traps}.
7451 @c =====================================================================
7453 @node Page Control, Fonts, Page Layout, gtroff Reference
7454 @section Page Control
7455 @cindex page control
7456 @cindex control, page
7458 @DefreqList {bp, [@Var{page}]}
7459 @DefreqItem {bp, @t{+}@Var{page}}
7460 @DefreqListEnd {bp, @t{-}@Var{page}}
7461 @cindex new page (@code{bp})
7462 @cindex page, new (@code{bp})
7463 Stop processing the current page and move to the next page.  This
7464 request causes a break.  It can also take an argument to set
7465 (increase, decrease) the page number of the next page.  The only
7466 difference between @code{bp} and @code{pn} is that @code{pn} does not
7467 cause a break or actually eject a page.
7469 @Example
7470 .de newpage                         \" define macro
7471 'bp                                 \" begin page
7472 'sp .5i                             \" vertical space
7473 .tl 'left top'center top'right top' \" title
7474 'sp .3i                             \" vertical space
7475 ..                                  \" end macro
7476 @endExample
7478 @cindex @code{bp} request, and top-level diversion
7479 @cindex top-level diversion, and @code{bp}
7480 @cindex diversion, top-level, and @code{bp}
7481 @code{bp} has no effect if not called within the top-level diversion
7482 (@pxref{Diversions}).
7483 @endDefreq
7485 @Defreq {ne, [@Var{space}]}
7486 @cindex orphan lines, preventing with @code{ne}
7487 @cindex conditional page break (@code{ne})
7488 @cindex page break, conditional (@code{ne})
7489 It is often necessary to force a certain amount of space before a new
7490 page occurs.  This is most useful to make sure that there is not a
7491 single @dfn{orphan} line left at the bottom of a page.  The @code{ne}
7492 request ensures that there is a certain distance, specified by the
7493 first argument, before the next page is triggered (see @ref{Traps},
7494 for further information).  The default scaling indicator for @code{ne}
7495 is @samp{v}; the default value of @var{space} is@w{ }1@dmn{v} if no
7496 argument is given.
7498 For example, to make sure that no fewer than 2@w{ }lines get orphaned,
7499 do the following before each paragraph:
7501 @Example
7502 .ne 2
7503 text text text
7504 @endExample
7506 @code{ne} will then automatically cause a page break if there is space
7507 for one line only.
7508 @endDefreq
7510 @DefreqList {sv, [@Var{space}]}
7511 @DefreqListEnd {os, }
7512 @cindex @code{ne} request, comparison with @code{sv}
7513 @code{sv} is similar to the @code{ne} request; it reserves the
7514 specified amount of vertical space.  If the desired amount of space
7515 exists before the next trap (or the bottom page boundary if no trap is
7516 set), the space is output immediately (ignoring a partially filled line
7517 which stays untouched).  If there is not enough space, it is stored for
7518 later output via the @code{os} request.  The default value is@w{ }1@dmn{v}
7519 if no argument is given; the default scaling indicator is @samp{v}.
7521 @cindex @code{sv} request, and no-space mode
7522 @cindex @code{os} request, and no-space mode
7523 Both @code{sv} and @code{os} ignore no-space mode.  While the @code{sv}
7524 request allows negative values for @var{space}, @code{os} will ignore
7525 them.
7526 @endDefreq
7528 @Defreg {nl}
7529 This register contains the current vertical position.  If the vertical
7530 position is zero and the top of page transition hasn't happened yet,
7531 @code{nl} is set to negative value.  @code{gtroff} itself does this at
7532 the very beginning of a document before anything has been printed, but
7533 the main usage is to plant a header trap on a page if this page has
7534 already started.
7536 Consider the following:
7538 @Example
7539 .de xxx
7540 .  sp
7541 .  tl ''Header''
7542 .  sp
7545 First page.
7547 .wh 0 xxx
7548 .nr nl (-1)
7549 Second page.
7550 @endExample
7552 @noindent
7553 Result:
7555 @Example
7556 First page.
7560                              Header
7562 Second page.
7565 @endExample
7567 @noindent
7568 Without resetting @code{nl} to a negative value, the just planted trap
7569 would be active beginning with the @emph{next} page, not the current
7570 one.
7572 @xref{Diversions}, for a comparison with the @code{.h} and @code{.d}
7573 registers.
7574 @endDefreg
7576 @c =====================================================================
7578 @node Fonts, Sizes, Page Control, gtroff Reference
7579 @section Fonts
7580 @cindex fonts
7582 @code{gtroff} can switch fonts at any point in the text.
7584 The basic set of fonts is @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
7585 These are Times Roman, Italic, Bold, and Bold Italic.  For non-TTY
7586 devices, there is also at least one symbol font which contains various
7587 special symbols (Greek, mathematics).
7589 @menu
7590 * Changing Fonts::
7591 * Font Families::
7592 * Font Positions::
7593 * Using Symbols::
7594 * Special Fonts::
7595 * Artificial Fonts::
7596 * Ligatures and Kerning::
7597 @end menu
7599 @c ---------------------------------------------------------------------
7601 @node Changing Fonts, Font Families, Fonts, Fonts
7602 @subsection Changing Fonts
7603 @cindex fonts
7605 @DefreqList {ft, [@Var{font}]}
7606 @DefescItem {\\f, , f, }
7607 @DefescItem {\\f, @lparen{}, fn, }
7608 @DefescListEnd {\\f, @lbrack{}, font, @rbrack}
7609 @cindex changing fonts (@code{ft}, @code{\f})
7610 @cindex fonts, changing (@code{ft}, @code{\f})
7611 @cindex @code{sty} request, and changing fonts
7612 @cindex @code{fam} request, and changing fonts
7613 @cindex @code{\F}, and changing fonts
7614 @kindex styles
7615 @kindex family
7616 @pindex DESC
7617 The @code{ft} request and the @code{\f} escape change the current font
7618 to @var{font} (one-character name@w{ }@var{f}, two-character name
7619 @var{fn}).
7621 If @var{font} is a style name (as set with the @code{sty} request or
7622 with the @code{styles} command in the @file{DESC} file), use it within
7623 the current font family (as set with the @code{fam} request, @code{\F}
7624 escape, or with the @code{family} command in the @file{DESC} file).
7626 @cindex previous font (@code{ft}, @code{\f[]}, @code{\fP})
7627 @cindex font, previous (@code{ft}, @code{\f[]}, @code{\fP})
7628 With no argument or using @samp{P} as an argument, @code{.ft} switches
7629 to the previous font.  Use @code{\f[]} to do this with the escape.  The
7630 old syntax forms @code{\fP} or @code{\f[P]} are also supported.
7632 Fonts are generally specified as upper-case strings, which are usually
7633 1@w{ }to 4 characters representing an abbreviation or acronym of the
7634 font name.  This is no limitation, just a convention.
7636 The example below produces two identical lines.
7638 @Example
7639 eggs, bacon,
7640 .ft B
7641 spam
7643 and sausage.
7645 eggs, bacon, \fBspam\fP and sausage.
7646 @endExample
7648 Note that @code{\f} doesn't produce an input token in @code{gtroff}.
7649 As a consequence, it can be used in requests like @code{mc} (which
7650 expects a single character as an argument) to change the font on
7651 the fly:
7653 @Example
7654 .mc \f[I]x\f[]
7655 @endExample
7657 @xref{Font Positions}, for an alternative syntax.
7658 @endDefreq
7660 @Defreq {ftr, f [@Var{g}]}
7661 @cindex @code{ft} request, and font translations
7662 @cindex @code{ul} request, and font translations
7663 @cindex @code{bd} request, and font translations
7664 @cindex @code{\f}, and font translations
7665 @cindex @code{cs} request, and font translations
7666 @cindex @code{tkf} request, and font translations
7667 @cindex @code{special} request, and font translations
7668 @cindex @code{fspecial} request, and font translations
7669 @cindex @code{fp} request, and font translations
7670 @cindex @code{sty} request, and font translations
7671 Translate font@w{ }@var{f} to font@w{ }@var{g}.  Whenever a font named@w{
7672 }@var{f} is referred to in a @code{\f} escape sequence, or in the
7673 @code{ft}, @code{ul}, @code{bd}, @code{cs}, @code{tkf},
7674 @code{special}, @code{fspecial}, @code{fp}, or @code{sty} requests,
7675 font@w{ }@var{g} is used.  If @var{g} is missing or equal to@w{ }@var{f}
7676 the translation is undone.
7677 @endDefreq
7679 @c ---------------------------------------------------------------------
7681 @node Font Families, Font Positions, Changing Fonts, Fonts
7682 @subsection Font Families
7683 @cindex font families
7684 @cindex families, font
7685 @cindex font styles
7686 @cindex styles, font
7688 Due to the variety of fonts available, @code{gtroff} has added the
7689 concept of @dfn{font families} and @dfn{font styles}.  The fonts are
7690 specified as the concatenation of the font family and style.  Specifying
7691 a font without the family part causes @code{gtroff} to use that style of
7692 the current family.
7694 @cindex PostScript fonts
7695 @cindex fonts, PostScript
7696 Currently, fonts for the devices @option{-Tps}, @option{-Tdvi}, and
7697 @option{-Tlbp} are set up to this mechanism.
7698 By default, @code{gtroff} uses the Times family with the four styles
7699 @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
7701 This way, it is possible to use the basic four fonts and to select a
7702 different font family on the command line (@pxref{Groff Options}).
7704 @DefreqList {fam, [@Var{family}]}
7705 @DefregItem {.fam}
7706 @DefescItem {\\F, , f, }
7707 @DefescItem {\\F, @lparen{}, fm, }
7708 @DefescItem {\\F, @lbrack{}, family, @rbrack}
7709 @DefregListEnd {.fn}
7710 @cindex changing font family (@code{fam}, @code{\F})
7711 @cindex font family, changing (@code{fam}, @code{\F})
7712 Switch font family to @var{family} (one-character name@w{ }@var{f},
7713 two-character name @var{fm}).  If no argument is given, switch
7714 back to the previous font family.  Use @code{\F[]} to do this with the
7715 escape.  Note that @code{\FP} doesn't work; it selects font family
7716 @samp{P} instead.
7718 The value at start-up is @samp{T}.
7719 The current font family is available in the read-only number register
7720 @samp{.fam} (this is a string-valued register); it is associated with
7721 the current environment.
7723 @Example
7724 spam,
7725 .fam H    \" helvetica family
7726 spam,     \" used font is family H + style R = HR
7727 .ft B     \" family H + style B = font HB
7728 spam,
7729 .fam T    \" times family
7730 spam,     \" used font is family T + style B = TB
7731 .ft AR    \" font AR (not a style)
7732 baked beans,
7733 .ft R     \" family T + style R = font TR
7734 and spam.
7735 @endExample
7737 Note that @code{\F} doesn't produce an input token in @code{gtroff}.
7738 As a consequence, it can be used in requests like @code{mc} (which
7739 expects a single character as an argument) to change the font family on
7740 the fly:
7742 @Example
7743 .mc \F[P]x\F[]
7744 @endExample
7746 The @samp{.fn} register contains the current @dfn{real font name}
7747 of the current font.
7748 This is a string-valued register.
7749 If the current font is a style, the value of @code{\n[.fn]}
7750 is the proper concatenation of family and style name.
7751 @endDefreq
7753 @Defreq {sty, n style}
7754 @cindex changing font style (@code{sty})
7755 @cindex font style, changing (@code{sty})
7756 @cindex @code{cs} request, and font styles
7757 @cindex @code{bd} request, and font styles
7758 @cindex @code{tkf} request, and font styles
7759 @cindex @code{uf} request, and font styles
7760 @cindex @code{fspecial} request, and font styles
7761 Associate @var{style} with font position@w{ }@var{n}.  A font position
7762 can be associated either with a font or with a style.  The current
7763 font is the index of a font position and so is also either a font or a
7764 style.  If it is a style, the font that is actually used is the font
7765 which name is the concatenation of the name of the current
7766 family and the name of the current style.  For example, if the current
7767 font is@w{ }1 and font position@w{ }1 is associated with style
7768 @samp{R} and the current font family is @samp{T}, then font
7769 @samp{TR} will be used.  If the current font is not a style, then the
7770 current family is ignored.  If the requests @code{cs}, @code{bd},
7771 @code{tkf}, @code{uf}, or @code{fspecial} are applied to a style,
7772 they will instead be applied to the member of the current family
7773 corresponding to that style.
7775 @var{n}@w{ }must be a non-negative integer value.
7777 @pindex DESC
7778 @kindex styles
7779 The default family can be set with the @option{-f} option
7780 (@pxref{Groff Options}).  The @code{styles} command in the @file{DESC}
7781 file controls which font positions (if any) are initially associated
7782 with styles rather than fonts.  For example, the default setting for
7783 @sc{PostScript} fonts
7785 @Example
7786 styles R I B BI
7787 @endExample
7789 @noindent
7790 is equivalent to
7792 @Example
7793 .sty 1 R
7794 .sty 2 I
7795 .sty 3 B
7796 .sty 4 BI
7797 @endExample
7799 @code{fam} and @code{\F} always check whether the current font position
7800 is valid; this can give surprising results if the current font position is
7801 associated with a style.
7803 In the following example, we want to access the @sc{PostScript} font
7804 @code{FooBar} from the font family @code{Foo}:
7806 @Example
7807 .sty \n[.fp] Bar
7808 .fam Foo
7809     @result{} warning: can't find font `FooR'
7810 @endExample
7812 @noindent
7813 The default font position at start-up is@w{ }1; for the
7814 @sc{PostScript} device, this is associated with style @samp{R}, so
7815 @code{gtroff} tries to open @code{FooR}.
7817 A solution to this problem is to use a dummy font like the following:
7819 @Example
7820 .fp 0 dummy TR    \" set up dummy font at position 0
7821 .sty \n[.fp] Bar  \" register style `Bar'
7822 .ft 0             \" switch to font at position 0
7823 .fam Foo          \" activate family `Foo'
7824 .ft Bar           \" switch to font `FooBar'
7825 @endExample
7827 @xref{Font Positions}.
7828 @endDefreq
7830 @c ---------------------------------------------------------------------
7832 @node Font Positions, Using Symbols, Font Families, Fonts
7833 @subsection Font Positions
7834 @cindex font positions
7835 @cindex positions, font
7837 For the sake of old phototypesetters and compatibility with old versions
7838 of @code{troff}, @code{gtroff} has the concept of font @dfn{positions},
7839 on which various fonts are mounted.
7841 @DefreqList {fp, pos font [@Var{external-name}]}
7842 @DefregItem {.f}
7843 @DefregListEnd {.fp}
7844 @cindex mounting font (@code{fp})
7845 @cindex font, mounting (@code{fp})
7846 Mount font @var{font} at position @var{pos} (which must be a
7847 non-negative integer).  This numeric position can then be referred to
7848 with font changing commands.  When @code{gtroff} starts it is using
7849 font position@w{ }1 (which must exist; position@w{ }0 is unused
7850 usually at start-up).
7852 @cindex font position register (@code{.f})
7853 The current font in use, as a font position, is available in the
7854 read-only number register @samp{.f}.  This can be useful to remember the
7855 current font for later recall.  It is associated with the current
7856 environment (@pxref{Environments}).
7858 @Example
7859 .nr save-font \n[.f]
7860 .ft B
7861 ... text text text ...
7862 .ft \n[save-font]
7863 @endExample
7865 @cindex next free font position register (@code{.fp})
7866 The number of the next free font position is available in the read-only
7867 number register @samp{.fp}.  This is useful when mounting a new font,
7868 like so:
7870 @Example
7871 .fp \n[.fp] NEATOFONT
7872 @endExample
7874 @pindex DESC@r{, and font mounting}
7875 Fonts not listed in the @file{DESC} file are automatically mounted on
7876 the next available font position when they are referenced.  If a font
7877 is to be mounted explicitly with the @code{fp} request on an unused
7878 font position, it should be mounted on the first unused font position,
7879 which can be found in the @code{.fp} register.  Although @code{gtroff}
7880 does not enforce this strictly, it is not allowed to mount a font at a
7881 position whose number is much greater (approx.@: 1000 positions) than
7882 that of any currently used position.
7884 The @code{fp} request has an optional third argument.  This argument
7885 gives the external name of the font, which is used for finding the font
7886 description file.  The second argument gives the internal name of the
7887 font which is used to refer to the font in @code{gtroff} after it has
7888 been mounted.  If there is no third argument then the internal name is
7889 used as the external name.  This feature makes it possible to use
7890 fonts with long names in compatibility mode.
7891 @endDefreq
7893 Both the @code{ft} request and the @code{\f} escape have alternative
7894 syntax forms to access font positions.
7896 @DefreqList {ft, nnn}
7897 @DefescItem {\\f, , n, }
7898 @DefescItem {\\f, @lparen{}, nn, }
7899 @DefescListEnd {\\f, @lbrack{}, nnn, @rbrack}
7900 @cindex changing font position (@code{\f})
7901 @cindex font position, changing (@code{\f})
7902 @cindex @code{sty} request, and font positions
7903 @cindex @code{fam} request, and font positions
7904 @cindex @code{\F}, and font positions
7905 @kindex styles
7906 @kindex family
7907 @pindex DESC
7908 Change the current font position to @var{nnn} (one-digit position@w{
7909 }@var{n}, two-digit position @var{nn}), which must be a non-negative
7910 integer.
7912 If @var{nnn} is associated with a style (as set with the @code{sty}
7913 request or with the @code{styles} command in the @file{DESC} file), use
7914 it within the current font family (as set with the @code{fam} request,
7915 the @code{\F} escape, or with the @code{family} command in the @file{DESC}
7916 file).
7918 @Example
7919 this is font 1
7920 .ft 2
7921 this is font 2
7922 .ft                   \" switch back to font 1
7923 .ft 3
7924 this is font 3
7926 this is font 1 again
7927 @endExample
7929 @xref{Changing Fonts}, for the standard syntax form.
7930 @endDefreq
7932 @c ---------------------------------------------------------------------
7934 @node Using Symbols, Special Fonts, Font Positions, Fonts
7935 @subsection Using Symbols
7936 @cindex using symbols
7937 @cindex symbols, using
7939 @cindex glyph
7940 @cindex character
7941 @cindex ligature
7942 A @dfn{glyph} is a graphical representation of a @dfn{character}.
7943 While a character is an abstract entity containing semantic
7944 information, a glyph is something which can be actually seen on screen
7945 or paper.  It is possible that a character has multiple glyph
7946 representation forms (for example, the character `A' can be either
7947 written in a roman or an italic font, yielding two different glyphs);
7948 sometimes more than one character maps to a single glyph (this is a
7949 @dfn{ligature} -- the most common is `fi').
7951 @cindex symbol
7952 @cindex special fonts
7953 @kindex fonts
7954 @pindex DESC
7955 A @dfn{symbol} is simply a named glyph.  Within @code{gtroff}, all
7956 glyph names of a particular font are defined in its font file.  If the
7957 user requests a glyph not available in this font, @code{gtroff} looks
7958 up an ordered list of @dfn{special fonts}.  By default, the
7959 @sc{PostScript} output device supports the two special fonts @samp{SS}
7960 (slanted symbols) and @samp{S} (symbols) (the former is looked up
7961 before the latter).  Other output devices use different names for
7962 special fonts.  Fonts mounted with the @code{fonts} keyword in the
7963 @file{DESC} file are globally available.  To install additional
7964 special fonts locally (i.e.@: for a particular font), use the
7965 @code{fspecial} request.
7967 In summary, @code{gtroff} tries the following to find a given symbol:
7969 @itemize @bullet
7970 @item
7971 If the symbol has been defined with the @code{char} request, use it.
7972 This hides a symbol with the same name in the current font.
7974 @item
7975 Check the current font.
7977 @item
7978 If the symbol has been defined with the @code{fchar} request, use it.
7980 @item
7981 Check all fonts given with the @code{fspecial} request, in the order
7982 of appearance in @code{fspecial} calls.
7984 @item
7985 Check all fonts given with the @code{special} request, in the order
7986 of appearance in @code{special} calls (inclusively the special fonts
7987 defined in the @file{DESC} file, which come first).
7989 @item
7990 As a last resort, consult all fonts loaded up to now (in the order they
7991 have been called the first time) for special fonts and check them.
7992 @end itemize
7994 @xref{Font Files}, and @ref{Special Fonts}, for more details.
7996 @DefescList {\\, @lparen{}, nm, }
7997 @DefescListEnd {\\, @lbrack{}, name, @rbrack}
7998 Insert a symbol @var{name} (two-character name @var{nm}).  There is no
7999 special syntax for one-character names -- the natural form
8000 @samp{\@var{n}} would collide with escapes.@footnote{Note that a
8001 one-character symbol is not the same as an input character, i.e., the
8002 character @code{a} is not the same as @code{\[a]}.  By default,
8003 @code{groff} defines only a single one-character symbol, @code{\[-]};
8004 it is usually accessed as @code{\-}.  On the other hand, @code{gtroff}
8005 has the special feature that @code{\[char@var{XXX}]} is the same as the
8006 input character with character code @var{XXX}.  For example,
8007 @code{\[char97]} is identical to the letter @code{a} if @acronym{ASCII}
8008 encoding is active.}
8010 If @var{name} is undefined, a warning of type @samp{char} is generated,
8011 and the escape is ignored.  @xref{Debugging}, for information about
8012 warnings.
8014 @cindex list of available glyphs (@cite{groff_char(7)} man page)
8015 @cindex available glyphs, list (@cite{groff_char(7)} man page)
8016 @cindex glyphs, available, list (@cite{groff_char(7)} man page)
8017 The list of available symbols is device dependent; see the
8018 @cite{groff_char(7)} man page for a complete list for the given output
8019 device.  For example, say
8021 @Example
8022 man -Tdvi groff_char > groff_char.dvi
8023 @endExample
8025 @noindent
8026 for a list using the default DVI fonts (not all versions of the
8027 @code{man} program support the @option{-T} option).  If you want to
8028 use an additional macro package to change the used fonts, @code{groff}
8029 must be called directly:
8031 @Example
8032 groff -Tdvi -mec -man groff_char.7 > groff_char.dvi
8033 @endExample
8035 @c XXX list of common symbols
8036 @endDefesc
8038 @Defesc {\\C, ', xxx, '}
8039 @cindex named character (@code{\C})
8040 @cindex character, named (@code{\C})
8041 Typeset the glyph named @var{xxx}.@footnote{@code{\C} is actually a
8042 misnomer since it accesses an output glyph.}  Normally it is more
8043 convenient to use @code{\[@var{xxx}]}, but @code{\C} has the advantage
8044 that it is compatible with newer versions of @acronym{AT&T}
8045 @code{troff} and is available in compatibility mode.
8046 @endDefesc
8048 @Defesc {\\N, ', n, '}
8049 @cindex numbered glyph (@code{\N})
8050 @cindex glyph, numbered (@code{\N})
8051 @cindex @code{char} request, used with @code{\N}
8052 @cindex Unicode
8053 Typeset the glyph with code@w{ }@var{n} in the current font
8054 (@code{n}@w{ }is @strong{not} the input character code).  The
8055 number @var{n}@w{ }can be any non-negative integer.  Most devices
8056 only have glyphs with codes between 0 and@w{ }255; the Unicode
8057 output device uses codes in the range 0--65535.  If the current
8058 font does not contain a glyph with that code, special fonts are
8059 @emph{not} searched.  The @code{\N} escape sequence can be
8060 conveniently used in conjunction with the @code{char} request:
8062 @Example
8063 .char \[phone] \f[ZD]\N'37'
8064 @endExample
8066 @noindent
8067 @pindex DESC
8068 @cindex unnamed glyphs
8069 @cindex glyphs, unnamed
8070 The code of each glyph is given in the fourth column in the font
8071 description file after the @code{charset} command.  It is possible to
8072 include unnamed glyphs in the font description file by using a
8073 name of @samp{---}; the @code{\N} escape sequence is the only way to
8074 use these.
8075 @endDefesc
8077 Some escape sequences directly map onto special glyphs.
8079 @Defesc {\\', , , }
8080 This is a backslash followed by the apostrophe character, @acronym{ASCII}
8081 character @code{0x27} (@acronym{EBCDIC} character @code{0x7D}).  The same
8082 as @code{\[aa]}, the acute accent.
8083 @endDefesc
8085 @Defesc {\\`, , , }
8086 This is a backslash followed by @acronym{ASCII} character @code{0x60}
8087 (@acronym{EBCDIC} character @code{0x79} usually).  The same as
8088 @code{\[ga]}, the grave accent.
8089 @endDefesc
8091 @Defesc {\\-, , , }
8092 This is the same as @code{\[-]}, the minus sign in the current font.
8093 @endDefesc
8095 @Defreq {cflags, n c1 c2 @dots{}}
8096 @cindex glyph properties (@code{cflags})
8097 @cindex character properties (@code{cflags})
8098 @cindex properties of glyphs (@code{cflags})
8099 @cindex properties of characters (@code{cflags})
8100 Input characters and symbols have certain properties associated
8101 with it.@footnote{Note that the output glyphs themselves don't have
8102 such properties.  For @code{gtroff}, a glyph is a numbered box with
8103 a given width, depth, and height, nothing else.  All manipulations
8104 with the @code{cflags} request work on the input level.}  These
8105 properties can be modified with the @code{cflags} request.  The
8106 first argument is the sum of the desired flags and the remaining
8107 arguments are the characters or symbols to have those properties.
8108 It is possible to omit the spaces between the characters or symbols.
8110 @table @code
8111 @item 1
8112 @cindex end-of-sentence characters
8113 @cindex characters, end-of-sentence
8114 The character ends sentences (initially characters @samp{.?!} have this
8115 property).
8117 @item 2
8118 @cindex hyphenating characters
8119 @cindex characters, hyphenation
8120 Lines can be broken before the character (initially no characters have
8121 this property).
8123 @item 4
8124 @cindex @code{hy} glyph, and @code{cflags}
8125 @cindex @code{em} glyph, and @code{cflags}
8126 Lines can be broken after the character (initially the character
8127 @samp{-} and the symbols @samp{\(hy} and @samp{\(em} have this property).
8129 @item 8
8130 @cindex overlapping characters
8131 @cindex characters, overlapping
8132 @cindex @code{ul} glyph, and @code{cflags}
8133 @cindex @code{rn} glyph, and @code{cflags}
8134 @cindex @code{ru} glyph, and @code{cflags}
8135 The character overlaps horizontally (initially the symbols
8136 @samp{\(ul\(rn\(ru} have this property).
8138 @item 16
8139 @cindex @code{br} glyph, and @code{cflags}
8140 The character overlaps vertically (initially symbol @samp{\(br} has
8141 this property).
8143 @item 32
8144 @cindex transparent characters
8145 @cindex character, transparent
8146 @cindex @code{"}, at end of sentence
8147 @cindex @code{'}, at end of sentence
8148 @cindex @code{)}, at end of sentence
8149 @cindex @code{]}, at end of sentence
8150 @cindex @code{*}, at end of sentence
8151 @cindex @code{dg} glyph, at end of sentence
8152 @cindex @code{rq} glyph, at end of sentence
8153 An end-of-sentence character followed by any number of characters with
8154 this property is treated as the end of a sentence if followed by a
8155 newline or two spaces; in other words the character is
8156 @dfn{transparent} for the purposes of end-of-sentence recognition --
8157 this is the same as having a zero space factor in @TeX{} (initially
8158 characters @samp{"')]*} and the symbols @samp{\(dg\(rq} have this
8159 property).
8160 @end table
8161 @endDefreq
8163 @DefreqList {char, g [@Var{string}]}
8164 @DefreqListEnd {fchar, g [@Var{string}]}
8165 @cindex defining character (@code{char})
8166 @cindex character, defining (@code{char})
8167 @cindex creating new characters (@code{char})
8168 @cindex defining symbol (@code{char})
8169 @cindex symbol, defining (@code{char})
8170 @cindex defining glyph (@code{char})
8171 @cindex glyph, defining (@code{char})
8172 @cindex escape character, while defining glyph
8173 @cindex character, escape, while defining glyph
8174 @cindex @code{tr} request, and glyph definitions
8175 @cindex @code{cp} request, and glyph definitions
8176 @cindex @code{rc} request, and glyph definitions
8177 @cindex @code{lc} request, and glyph definitions
8178 @cindex @code{\l}, and glyph definitions
8179 @cindex @code{\L}, and glyph definitions
8180 @cindex @code{\&}, and glyph definitions
8181 @cindex @code{\e}, and glyph definitions
8182 @cindex @code{hcode} request, and glyph definitions
8183 Define a new glyph@w{ }@var{g} to be @var{string} (which can be
8184 empty).@footnote{@code{char} is a misnomer since an output glyph is
8185 defined.}  Every time glyph@w{ }@var{g} needs to be printed,
8186 @var{string} is processed in a temporary environment and the result is
8187 wrapped up into a single object.  Compatibility mode is turned off and
8188 the escape character is set to @samp{\} while @var{string} is being
8189 processed.  Any emboldening, constant spacing or track kerning is
8190 applied to this object rather than to individual characters in
8191 @var{string}.
8193 A glyph defined by this request can be used just
8194 like a normal glyph provided by the output device.  In particular,
8195 other characters can be translated to it with the @code{tr} or
8196 @code{trin} requests; it can be made the leader character by the
8197 @code{lc} request; repeated patterns can be drawn with the glyph
8198 using the @code{\l} and @code{\L} escape sequences; words containing
8199 the glyph can be hyphenated correctly if the @code{hcode} request
8200 is used to give the glyph's symbol a hyphenation code.
8202 There is a special anti-recursion feature: Use of @code{g} within
8203 the glyph's definition is handled like normal characters and symbols
8204 not defined with @code{char}.
8206 Note that the @code{tr} and @code{trin} requests take precedence if
8207 @code{char} accesses the same symbol.
8209 @Example
8210 .tr XY
8212     @result{} Y
8213 .char X Z
8215     @result{} Y
8216 .tr XX
8218     @result{} Z
8219 @endExample
8221 The @code{fchar} request defines a fallback glyph:
8222 @code{gtroff} only checks for glyphs defined with @code{fchar}
8223 if it cannot find the glyph in the current font.
8224 @code{gtroff} carries out this test before checking special fonts.
8225 @endDefreq
8227 @Defreq {rchar, c1 c2 @dots{}}
8228 @cindex removing glyph definition (@code{rchar})
8229 @cindex glyph, removing definition (@code{rchar})
8230 Remove the definitions of glyphs @var{c1}, @var{c2},@w{
8231 }@enddots{} This undoes the effect of a @code{char} or @code{fchar}
8232 request.
8234 It is possible to omit the whitespace between arguments.
8235 @endDefreq
8237 @xref{Special Characters}.
8239 @c ---------------------------------------------------------------------
8241 @node Special Fonts, Artificial Fonts, Using Symbols, Fonts
8242 @subsection Special Fonts
8243 @cindex special fonts
8244 @cindex fonts, special
8246 Special fonts are those that @code{gtroff} searches
8247 when it cannot find the requested glyph in the current font.
8248 The Symbol font is usually a special font.
8250 @code{gtroff} provides the following two requests to add more special
8251 fonts.  @xref{Using Symbols}, for a detailed description of the glyph
8252 searching mechanism in @code{gtroff}.
8254 Usually, only non-TTY devices have special fonts.
8256 @DefreqList {special, s1 s2 @dots{}}
8257 @DefreqListEnd {fspecial, f s1 s2 @dots{}}
8258 @kindex fonts
8259 @pindex DESC
8260 Use the @code{special} request to define special fonts.  They are
8261 appended to the list of global special fonts in the given order.
8262 The first entries in this list are the fonts defined with the
8263 @code{fonts} command in the @file{DESC} file which are marked as
8264 special in the corresponding font description files.
8266 Use the @code{fspecial} request to designate special fonts
8267 only when font@w{ }@var{f} font is active.  They are appended to the
8268 list of special fonts for @var{f} in the given order.  Initially, this
8269 list is empty.
8270 @endDefreq
8272 @c ---------------------------------------------------------------------
8274 @node Artificial Fonts, Ligatures and Kerning, Special Fonts, Fonts
8275 @subsection Artificial Fonts
8276 @cindex artificial fonts
8277 @cindex fonts, artificial
8279 There are a number of requests and escapes for artificially creating
8280 fonts.  These are largely vestiges of the days when output devices
8281 did not have a wide variety of fonts, and when @code{nroff} and
8282 @code{troff} were separate programs.  Most of them are no longer
8283 necessary in GNU @code{troff}.  Nevertheless, they are supported.
8285 @DefescList {\\H, ', height, '}
8286 @DefescItem {\\H, ', @t{+}@Var{height}, '}
8287 @DefescListEnd {\\H, ', @t{-}@Var{height}, '}
8288 @cindex changing the font height (@code{\H})
8289 @cindex font height, changing (@code{\H})
8290 @cindex height, font, changing (@code{\H})
8291 Change (increment, decrement) the height of the current font, but not
8292 the width.  If @var{height} is zero, restore the original height.
8293 Default scaling indicator is @samp{z}.
8295 Currently, only the @option{-Tps} device supports this feature.
8297 Note that @code{\H} doesn't produce an input token in @code{gtroff}.
8298 As a consequence, it can be used in requests like @code{mc} (which
8299 expects a single character as an argument) to change the font on
8300 the fly:
8302 @Example
8303 .mc \H'+5z'x\H'0'
8304 @endExample
8306 In compatibility mode, @code{gtroff} behaves differently:  If an
8307 increment or decrement is used, it is always taken relative to the
8308 current point size and not relative to the previously selected font
8309 height.  Thus,
8311 @Example
8312 .cp 1
8313 \H'+5'test \H'+5'test
8314 @endExample
8316 @noindent
8317 prints the word @samp{test} twice with the same font height (five
8318 points larger than the current font size).
8319 @endDefesc
8321 @DefescList {\\S, ', slant, '}
8322 @cindex changing the font slant (@code{\S})
8323 @cindex font slant, changing (@code{\S})
8324 @cindex slant, font, changing (@code{\S})
8325 Slant the current font by @var{slant} degrees.  Positive values slant
8326 to the right.
8328 Currently, only the @option{-Tps} device supports this feature.
8330 Note that @code{\S} doesn't produce an input token in @code{gtroff}.
8331 As a consequence, it can be used in requests like @code{mc} (which
8332 expects a single character as an argument) to change the font on
8333 the fly:
8335 @Example
8336 .mc \S'20'x\S'0'
8337 @endExample
8339 This request is incorrectly documented in the original @acronym{UNIX}
8340 troff manual; the slant is always set to an absolute value.
8341 @endDefesc
8343 @Defreq {ul, [@Var{lines}]}
8344 @cindex underlining (@code{ul})
8345 The @code{ul} request normally underlines subsequent lines if a TTY
8346 output device is used.  Otherwise, the lines are printed in italics
8347 (only the term `underlined' is used in the following).  The single
8348 argument is the number of input lines to be underlined; with no
8349 argument, the next line is underlined.  If @var{lines} is zero or
8350 negative, stop the effects of @code{ul} (if it was active).  Requests
8351 and empty lines do not count for computing the number of underlined
8352 input lines, even if they produce some output like @code{tl}.  Lines
8353 inserted by macros (e.g.@: invoked by a trap) do count.
8355 At the beginning of @code{ul}, the current font is stored and the
8356 underline font is activated.  Within the span of a @code{ul} request,
8357 it is possible to change fonts, but after the last line affected by
8358 @code{ul} the saved font is restored.
8360 This number of lines still to be underlined is associated with the
8361 current environment (@pxref{Environments}).  The underline font can be
8362 changed with the @code{uf} request.
8364 @c XXX @xref should be changed to grotty
8366 @c @xref{Troff and Nroff Mode}, for a discussion how underlining is
8367 @c implemented in for TTY output devices, and which problems can arise.
8369 The @code{ul} request does not underline spaces.
8370 @endDefreq
8372 @Defreq {cu, [@Var{lines}]}
8373 @cindex continuous underlining (@code{cu})
8374 @cindex underlining, continuous (@code{cu})
8375 The @code{cu} request is similar to @code{ul} but underlines spaces as
8376 well (if a TTY output device is used).
8377 @endDefreq
8379 @Defreq {uf, font}
8380 @cindex underline font (@code{uf})
8381 @cindex font for underlining (@code{uf})
8382 Set the underline font (globally) used by @code{ul} and @code{cu}.  By
8383 default, this is the font at position@w{ }2.  @var{font} can be either
8384 a non-negative font position or the name of a font.
8385 @endDefreq
8387 @DefreqList {bd, font [@Var{offset}]}
8388 @DefreqItem {bd, font1 font2 [@Var{offset}]}
8389 @DefregListEnd {.b}
8390 @cindex imitating bold face (@code{bd})
8391 @cindex bold face, imitating (@code{bd})
8392 Artificially create a bold font by printing each glyph twice,
8393 slightly offset.
8395 Two syntax forms are available.
8397 @itemize @bullet
8398 @item
8399 Imitate a bold font unconditionally.  The first argument specifies the
8400 font to embolden, and the second is the number of basic units, minus
8401 one, by which the two glyphs are offset.  If the second argument is
8402 missing, emboldening is turned off.
8404 @var{font} can be either a non-negative font position or the name of a
8405 font.
8407 @var{offset} is available in the @code{.b} read-only register if a
8408 special font is active; in the @code{bd} request, its default unit is
8409 @samp{u}.
8411 @cindex @code{fspecial} request, and imitating bold
8412 @kindex special
8413 @cindex embolding of special fonts
8414 @cindex special fonts, emboldening
8415 @item
8416 Imitate a bold form conditionally.  Embolden @var{font1} by
8417 @var{offset} only if font @var{font2} is the current font.  This
8418 command can be issued repeatedly to set up different emboldening
8419 values for different current fonts.  If the second argument is
8420 missing, emboldening is turned off for this particular current font.
8422 This affects special fonts only (either set up with the @code{special}
8423 command in font files or with the @code{fspecial} request).
8424 @end itemize
8425 @endDefreq
8427 @Defreq {cs, font [@Var{width} [@Var{em-size}]]}
8428 @cindex constant glyph space mode (@code{cs})
8429 @cindex mode for constant glyph space (@code{cs})
8430 @cindex glyph, constant space
8431 @cindex @code{ps} request, and constant glyph space mode
8432 Switch to and from @dfn{constant glyph space mode}.  If activated, the
8433 width of every glyph is @math{@var{width}/36} ems.  The em size is
8434 given absolutely by @var{em-size}; if this argument is missing, the em
8435 value is taken from the current font size (as set with the @code{ps}
8436 request) when the font is effectively in use.  Without second and
8437 third argument, constant glyph space mode is deactivated.
8439 Default scaling indicator for @var{em-size} is @samp{z}; @var{width} is
8440 an integer.
8441 @endDefreq
8443 @c ---------------------------------------------------------------------
8445 @node Ligatures and Kerning,  , Artificial Fonts, Fonts
8446 @subsection Ligatures and Kerning
8447 @cindex ligatures and kerning
8448 @cindex kerning and ligatures
8450 Ligatures are groups of characters that are run together, i.e, producing
8451 a single glyph.  For example, the letters `f' and `i' can form a
8452 ligature `fi' as in the word `file'.  This produces a cleaner look
8453 (albeit subtle) to the printed output.  Usually, ligatures are not
8454 available in fonts for TTY output devices.
8456 Most @sc{PostScript} fonts support the fi and fl ligatures.  The C/A/T
8457 typesetter that was the target of @acronym{AT&T} @code{troff} also
8458 supported `ff', `ffi', and `ffl' ligatures.  Advanced typesetters or
8459 `expert' fonts may include ligatures for `ft' and `ct', although GNU
8460 @code{troff} does not support these (yet).
8462 @DefreqList {lg, [@Var{flag}]}
8463 @DefregListEnd {.lg}
8464 @cindex activating ligatures (@code{lg})
8465 @cindex ligatures, activating (@code{lg})
8466 @cindex ligatures enabled register (@code{.lg})
8467 Switch the ligature mechanism on or off; if the parameter is non-zero
8468 or missing, ligatures are enabled, otherwise disabled.  Default is on.
8469 The current ligature mode can be found in the read-only number register
8470 @code{.lg} (set to 1 or@w{ }2 if ligatures are enabled, 0@w{ }otherwise).
8472 Setting the ligature mode to@w{ }2 enables the two-character ligatures
8473 (fi, fl, and ff) and disables the three-character ligatures (ffi and
8474 ffl).
8475 @endDefreq
8477 @dfn{Pairwise kerning} is another subtle typesetting mechanism that
8478 modifies the distance between a glyph pair to improve readability.
8479 In most cases (but not always) the distance is decreased.
8480 @ifnotinfo
8481 For example, compare the combination of the letters `V' and `A'.  With
8482 kerning, `VA' is printed.  Without kerning it appears as `V@w{}A'.
8483 @end ifnotinfo
8484 Typewriter-like fonts and fonts for terminals where all glyphs
8485 have the same width don't use kerning.
8487 @DefreqList {kern, [@Var{flag}]}
8488 @DefregListEnd {.kern}
8489 @cindex activating kerning (@code{kern})
8490 @cindex kerning, activating (@code{kern})
8491 @cindex kerning enabled register (@code{.kern})
8492 Switch kerning on or off.  If the parameter is non-zero or missing,
8493 enable pairwise kerning, otherwise disable it.  The read-only number
8494 register @code{.kern} is set to@w{ }1 if pairwise kerning is enabled,
8495 0@w{ }otherwise.
8497 @cindex zero width space character (@code{\&})
8498 @cindex character, zero width space (@code{\&})
8499 @cindex space character, zero width (@code{\&})
8500 If the font description file contains pairwise kerning information,
8501 glyphs from that font are kerned.  Kerning between two glyphs
8502 can be inhibited by placing @code{\&} between them: @samp{V\&A}.
8504 @xref{Font File Format}.
8505 @endDefreq
8507 @cindex track kerning
8508 @cindex kerning, track
8509 @dfn{Track kerning} expands or reduces the space between glyphs.
8510 This can be handy, for example, if you need to squeeze a long word
8511 onto a single line or spread some text to fill a narrow column.  It
8512 must be used with great care since it is usually considered bad
8513 typography if the reader notices the effect.
8515 @Defreq {tkf, f s1 n1 s2 n2}
8516 @cindex activating track kerning (@code{tkf})
8517 @cindex track kerning, activating (@code{tkf})
8518 Enable track kerning for font@w{ }@var{f}.  If the current font is@w{
8519 }@var{f} the width of every glyph is increased by an amount
8520 between @var{n1} and @var{n2} (@var{n1}, @var{n2} can be negative); if
8521 the current point size is less than or equal to @var{s1} the width is
8522 increased by @var{n1}; if it is greater than or equal to @var{s2} the
8523 width is increased by @var{n2}; if the point size is greater than or
8524 equal to @var{s1} and less than or equal to @var{s2} the increase in
8525 width is a linear function of the point size.
8527 The default scaling indicator is @samp{z} for @var{s1} and @var{s2},
8528 @samp{p} for @var{n1} and @var{n2}.
8530 Note that the track kerning amount is added even to the rightmost glyph
8531 in a line; for large values it is thus recommended to increase the line
8532 length by the same amount to compensate it.
8533 @endDefreq
8535 Sometimes, when typesetting letters of different fonts, more or less
8536 space at such boundaries are needed.  There are two escapes to help
8537 with this.
8539 @Defesc {\\/, , , }
8540 @cindex italic correction (@code{\/})
8541 @cindex correction, italic (@code{\/})
8542 @cindex correction between italic and roman glyph (@code{\/}, @code{\,})
8543 @cindex roman glyph, correction after italic glyph (@code{\/})
8544 @cindex italic glyph, correction before roman glyph (@code{\/})
8545 @cindex glyph, italic correction (@code{\/})
8546 Increase the width of the preceding glyph so that the spacing
8547 between that glyph and the following glyph is correct if the
8548 following glyph is a roman glyph.  For example, if an
8549 italic@w{ }@code{f} is immediately followed by a roman right
8550 parenthesis, then in many fonts the top right portion of the@w{ }@code{f}
8551 overlaps the top left of the right parenthesis.  Use this escape
8552 sequence whenever an italic glyph is immediately followed by a
8553 roman glyph without any intervening space.  This small amount of
8554 space is also called @dfn{italic correction}.
8556 @iftex
8557 @example
8558 @group
8559 \f[I]f\f[R])
8560     @result{} {@it f}@r{)}
8561 \f[I]f\/\f[R])
8562     @result{} @i{f}@r{)}
8563 @end group
8564 @end example
8565 @end iftex
8566 @endDefesc
8568 @Defesc {\\\,, , , }
8569 @cindex left italic correction (@code{\,})
8570 @cindex correction, left italic (@code{\,})
8571 @cindex glyph, left italic correction (@code{\,})
8572 @cindex roman glyph, correction before italic glyph (@code{\,})
8573 @cindex italic glyph, correction after roman glyph (@code{\,})
8574 Modify the spacing of the following glyph so that the spacing
8575 between that glyph and the preceding glyph is correct if the
8576 preceding glyph is a roman glyph.  Use this escape sequence
8577 whenever a roman glyph is immediately followed by an italic
8578 glyph without any intervening space.  In analogy to above, this
8579 space could be called @dfn{left italic correction}, but this term
8580 isn't used widely.
8582 @iftex
8583 @example
8584 @group
8585 q\f[I]f
8586     @result{} @r{q}@i{f}
8587 q\,\f[I]f
8588     @result{} @r{q}@math{@ptexcomma}@i{f}
8589 @end group
8590 @end example
8591 @end iftex
8592 @endDefesc
8594 @Defesc {\\&, , , }
8595 Insert a zero-width character, which is invisible.  Its intended use
8596 is to stop interaction of a character with its surrounding.
8598 @itemize @bullet
8599 @item
8600 It prevents the insertion of extra space after an end-of-sentence
8601 character.
8603 @Example
8604 Test.
8605 Test.
8606     @result{} Test.  Test.
8607 Test.\&
8608 Test.
8609     @result{} Test. Test.
8610 @endExample
8612 @item
8613 It prevents interpretation of a control character at the beginning of
8614 an input line.
8616 @Example
8617 .Test
8618     @result{} warning: `Test' not defined
8619 \&.Test
8620     @result{} .Test
8621 @endExample
8623 @item
8624 It prevents kerning between two glyphs.
8626 @ifnotinfo
8627 @example
8628 @group
8630     @result{} @r{VA}
8631 V\&A
8632     @result{} @r{V@w{}A}
8633 @end group
8634 @end example
8635 @end ifnotinfo
8637 @item
8638 It is needed to map an arbitrary character to nothing in the @code{tr}
8639 request (@pxref{Character Translations}).
8640 @end itemize
8641 @endDefesc
8643 @Defesc {\\), , , }
8644 This escape is similar to @code{\&} except that it behaves like a
8645 character declared with the @code{cflags} request to be transparent
8646 for the purposes of an end-of-sentence character.
8648 Its main usage is in macro definitions to protect against arguments
8649 starting with a control character.
8651 @Example
8652 .de xxx
8653 \)\\$1
8655 .de yyy
8656 \&\\$1
8658 This is a test.\c
8659 .xxx '
8660 This is a test.
8661     @result{}This is a test.'  This is a test.
8662 This is a test.\c
8663 .yyy '
8664 This is a test.
8665     @result{}This is a test.' This is a test.
8666 @endExample
8667 @endDefesc
8670 @c =====================================================================
8672 @node Sizes, Strings, Fonts, gtroff Reference
8673 @section Sizes
8674 @cindex sizes
8676 @cindex baseline
8677 @cindex type size
8678 @cindex size of type
8679 @cindex vertical spacing
8680 @cindex spacing, vertical
8681 @code{gtroff} uses two dimensions with each line of text, type size
8682 and vertical spacing.  The @dfn{type size} is approximately the height
8683 of the tallest glyph.@footnote{This is usually the parenthesis.
8684 Note that in most cases the real dimensions of the glyphs in a font
8685 are @emph{not} related to its type size!  For example, the standard
8686 @sc{PostScript} font families `Times Roman', `Helvetica', and
8687 `Courier' can't be used together at 10@dmn{pt}; to get acceptable
8688 output, the size of `Helvetica' has to be reduced by one point, and
8689 the size of `Courier' must be increased by one point.}  @dfn{Vertical
8690 spacing} is the amount of space @code{gtroff} allows for a line of
8691 text; normally, this is about 20%@w{ }larger than the current type
8692 size.  Ratios smaller than this can result in hard-to-read text;
8693 larger than this, it spreads the text out more vertically (useful for
8694 term papers).  By default, @code{gtroff} uses 10@w{ }point type on
8695 12@w{ }point spacing.
8697 @cindex leading
8698 The difference between type size and vertical spacing is known, by
8699 typesetters, as @dfn{leading} (this is pronounced `ledding').
8701 @menu
8702 * Changing Type Sizes::
8703 * Fractional Type Sizes::
8704 @end menu
8706 @c ---------------------------------------------------------------------
8708 @node Changing Type Sizes, Fractional Type Sizes, Sizes, Sizes
8709 @subsection Changing Type Sizes
8711 @DefreqList {ps, [@Var{size}]}
8712 @DefreqItem {ps, @t{+}@Var{size}}
8713 @DefreqItem {ps, @t{-}@Var{size}}
8714 @DefescItem {\\s, , size, }
8715 @DefregListEnd {.s}
8716 @cindex changing type sizes (@code{ps}, @code{\s})
8717 @cindex type sizes, changing (@code{ps}, @code{\s})
8718 @cindex point sizes, changing (@code{ps}, @code{\s})
8719 Use the @code{ps} request or the @code{\s} escape to change (increase,
8720 decrease) the type size (in points).  Specify @var{size} as either an
8721 absolute point size, or as a relative change from the current size.
8722 The size@w{ }0, or no argument, goes back to the previous size.
8724 Default scaling indicator of @code{size} is @samp{z}.  If @code{size}
8725 is zero or negative, it is set to 1@dmn{u}.
8727 @cindex type size registers (@code{.s}, @code{.ps})
8728 @cindex point size registers (@code{.s}, @code{.ps})
8729 The read-only number register @code{.s} returns the point size in
8730 points as a decimal fraction.  This is a string.  To get the point
8731 size in scaled points, use the @code{.ps} register instead.
8733 @code{.s} is associated with the current environment
8734 (@pxref{Environments}).
8736 @Example
8737 snap, snap,
8738 .ps +2
8739 grin, grin,
8740 .ps +2
8741 wink, wink, \s+2nudge, nudge,\s+8 say no more!
8742 .ps 10
8743 @endExample
8745 The @code{\s} escape may be called in a variety of ways.  Much like
8746 other escapes there must be a way to determine where the argument ends
8747 and the text begins.  Any of the following forms are valid:
8749 @table @code
8750 @item \s@var{n}
8751 Set the point size to @var{n}@w{ }points.  @var{n}@w{ }must be either
8752 0 or in the range 4 to@w{ }39.
8754 @item \s+@var{n}
8755 @itemx \s-@var{n}
8756 Increase or decrease the point size by @var{n}@w{ }points.  @var{n}@w{
8757 }must be exactly one digit.
8759 @item \s(@var{nn}
8760 Set the point size to @var{nn}@w{ }points.  @var{nn} must be exactly
8761 two digits.
8763 @item \s+(@var{nn}
8764 @itemx \s-(@var{nn}
8765 @itemx \s(+@var{nn}
8766 @itemx \s(-@var{nn}
8767 Increase or decrease the point size by @var{nn}@w{ }points.  @var{nn}
8768 must be exactly two digits.
8769 @end table
8771 Note that @code{\s} doesn't produce an input token in @code{gtroff}.
8772 As a consequence, it can be used in requests like @code{mc} (which
8773 expects a single character as an argument) to change the font on
8774 the fly:
8776 @Example
8777 .mc \s[20]x\s[0]
8778 @endExample
8780 @xref{Fractional Type Sizes}, for yet another syntactical form of
8781 using the @code{\s} escape.
8782 @endDefreq
8784 @Defreq {sizes, s1 s2 @dots{} sn [0]}
8785 Some devices may only have certain permissible sizes, in which case
8786 @code{gtroff} rounds to the nearest permissible size.
8787 The @file{DESC} file specifies which sizes are permissible for the device.
8789 Use the @code{sizes} request to change the permissible sizes
8790 for the current output device.
8791 Arguments are in scaled points;
8792 the @code{sizescale} line in the
8793 @file{DESC} file for the output device
8794 provides the scaling factor.
8795 For example, if the scaling factor is 1000,
8796 then the value 12000 is 12@w{ }points.
8798 Each argument can be a single point size (such as @samp{12000}),
8799 or a range of sizes (such as @samp{4000-72000}).
8800 You can optionally end the list with a zero.
8801 @endDefreq
8803 @DefreqList {vs, [@Var{space}]}
8804 @DefreqItem {vs, @t{+}@Var{space}}
8805 @DefreqItem {vs, @t{-}@Var{space}}
8806 @DefregListEnd {.v}
8807 @cindex changing vertical line spacing (@code{vs})
8808 @cindex vertical line spacing, changing (@code{vs})
8809 @cindex vertical line spacing register (@code{.v})
8810 Change (increase, decrease) the vertical spacing by @var{space}.  The
8811 default scaling indicator is @samp{p}.
8813 If @code{vs} is called without an argument, the vertical spacing is
8814 reset to the previous value before the last call to @code{vs}.
8816 @cindex @code{.V} register, and @code{vs}
8817 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
8818 zero or negative; the vertical spacing is then set to the vertical
8819 resolution (as given in the @code{.V} register).
8821 The read-only number register @code{.v} contains the current vertical
8822 spacing; it is associated with the current environment
8823 (@pxref{Environments}).
8824 @endDefreq
8826 @cindex vertical line spacing, effective value
8827 The effective vertical line spacing consists of four components.
8829 @itemize @bullet
8830 @item
8831 The vertical line spacing as set with the @code{vs} request.
8833 @cindex post-vertical line spacing
8834 @cindex line spacing, post-vertical (@code{pvs})
8835 @item
8836 The @dfn{post-vertical line spacing} as set with the @code{pvs} request.
8837 This is vertical space which will be added after a line has been
8838 output.
8840 @cindex extra pre-vertical line space (@code{\x})
8841 @cindex line space, extra pre-vertical (@code{\x})
8842 @item
8843 The @dfn{extra pre-vertical line space} as set with the @code{\x} request,
8844 using a negative value.  This is vertical space which will be added once
8845 before the current line has been output.
8847 @cindex extra post-vertical line space (@code{\x})
8848 @cindex line space, extra post-vertical (@code{\x})
8849 @item
8850 The @dfn{extra post-vertical line space} as set with the @code{\x} request,
8851 using a positive value.  This is vertical space which will be added once
8852 after the current line has been output.
8853 @end itemize
8855 @cindex double-spacing (@code{vs}, @code{pvs})
8856 It is usually better to use @code{vs} or @code{pvs} instead of @code{ls}
8857 to produce double-spaced documents: @code{vs} and @code{pvs} have a finer
8858 granularity for the inserted vertical space compared to @code{ls};
8859 furthermore, certain preprocessors assume single-spacing.
8861 @xref{Manipulating Spacing}, for more details on the @code{\x} escape
8862 and the @code{ls} request.
8864 @DefreqList {pvs, [@Var{space}]}
8865 @DefreqItem {pvs, @t{+}@Var{space}}
8866 @DefreqItem {pvs, @t{-}@Var{space}}
8867 @DefregListEnd {.pvs}
8868 @cindex @code{ls} request, alternative to (@code{pvs})
8869 @cindex post-vertical line spacing, changing (@code{pvs})
8870 @cindex post-vertical line spacing register (@code{.pvs})
8871 Change (increase, decrease) the post-vertical spacing by
8872 @var{space}.  The default scaling indicator is @samp{p}.
8874 If @code{pvs} is called without an argument, the post-vertical spacing is
8875 reset to the previous value before the last call to @code{pvs}.
8877 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
8878 zero or negative; the vertical spacing is then set to zero.
8880 The read-only number register @code{.pvs} contains the current
8881 post-vertical spacing; it is associated with the current environment
8882 (@pxref{Environments}).
8883 @endDefreq
8886 @c ---------------------------------------------------------------------
8888 @node Fractional Type Sizes,  , Changing Type Sizes, Sizes
8889 @subsection Fractional Type Sizes
8890 @cindex fractional type sizes
8891 @cindex fractional point sizes
8892 @cindex type sizes, fractional
8893 @cindex point sizes, fractional
8894 @cindex sizes, fractional
8896 @cindex @code{s} unit
8897 @cindex unit, @code{s}
8898 @cindex @code{z} unit
8899 @cindex unit, @code{z}
8900 @cindex @code{ps} request, with fractional type sizes
8901 @cindex @code{cs} request, with fractional type sizes
8902 @cindex @code{tkf} request, with fractional type sizes
8903 @cindex @code{\H}, with fractional type sizes
8904 @cindex @code{\s}, with fractional type sizes
8905 A @dfn{scaled point} is equal to @math{1/@var{sizescale}} points,
8906 where @var{sizescale} is specified in the @file{DESC} file (1@w{ }by
8907 default).  There is a new scale indicator @samp{z} which has the
8908 effect of multiplying by @var{sizescale}.  Requests and escape
8909 sequences in @code{gtroff} interpret arguments that represent a point
8910 size as being in units of scaled points, but they evaluate each such
8911 argument using a default scale indicator of @samp{z}.  Arguments
8912 treated in this way are the argument to the @code{ps} request, the
8913 third argument to the @code{cs} request, the second and fourth
8914 arguments to the @code{tkf} request, the argument to the @code{\H}
8915 escape sequence, and those variants of the @code{\s} escape sequence
8916 that take a numeric expression as their argument (see below).
8918 For example, suppose @var{sizescale} is@w{ }1000; then a scaled point
8919 is equivalent to a millipoint; the request @w{@samp{.ps 10.25}} is
8920 equivalent to @w{@samp{.ps 10.25z}} and thus sets the point size to
8921 10250@w{ }scaled points, which is equal to 10.25@w{ }points.
8923 @code{gtroff} disallows the use of the @samp{z} scale indicator in
8924 instances where it would make no sense, such as a numeric
8925 expression whose default scale indicator was neither @samp{u} nor
8926 @samp{z}.  Similarly it would make
8927 no sense to use a scaling indicator other than @samp{z} or @samp{u} in a
8928 numeric expression whose default scale indicator was @samp{z}, and so
8929 @code{gtroff} disallows this as well.
8931 There is also new scale indicator @samp{s} which multiplies by the
8932 number of units in a scaled point.  So, for example, @samp{\n[.ps]s} is
8933 equal to @samp{1m}.  Be sure not to confuse the @samp{s} and @samp{z}
8934 scale indicators.
8936 @Defreg {.ps}
8937 A read-only number register returning the point size in scaled points.
8939 @code{.ps} is associated with the current environment
8940 (@pxref{Environments}).
8941 @endDefreg
8943 @DefregList {.psr}
8944 @DefregListEnd {.sr}
8945 @cindex last-requested point size registers (@code{.psr}, @code{.sr})
8946 @cindex point size registers, last-requested (@code{.psr}, @code{.sr})
8947 @cindex @code{.ps} register, in comparison with @code{.psr}
8948 @cindex @code{.s} register, in comparison with @code{.sr}
8949 The last-requested point size in scaled points is contained in the
8950 @code{.psr} read-only number register.  The last requested point size
8951 in points as a decimal fraction can be found in @code{.sr}.  This is a
8952 string-valued read-only number register.
8954 Note that the requested point sizes are device-independent, whereas
8955 the values returned by the @code{.ps} and @code{.s} registers are not.
8956 For example, if a point size of 11@dmn{pt} is requested, and a
8957 @code{sizes} request (or a @code{sizescale} line in a @file{DESC} file)
8958 specifies 10.95@dmn{pt} instead, this value is actually used.
8960 Both registers are associated with the current environment
8961 (@pxref{Environments}).
8962 @endDefreg
8964 The @code{\s} escape has the following syntax for working with
8965 fractional type sizes:
8967 @table @code
8968 @item \s[@var{n}]
8969 @itemx \s'@var{n}'
8970 Set the point size to @var{n}@w{ }scaled points; @var{n}@w{ }is a numeric
8971 expression with a default scale indicator of @samp{z}.
8973 @item \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 @itemx \s+'@var{n}'
8980 @itemx \s-'@var{n}'
8981 Increase or or decrease the point size by @var{n}@w{ }scaled points;
8982 @var{n}@w{ }is a numeric expression with a default scale indicator of
8983 @samp{z}.
8984 @end table
8986 @xref{Font Files}.
8989 @c =====================================================================
8991 @node Strings, Conditionals and Loops, Sizes, gtroff Reference
8992 @section Strings
8993 @cindex strings
8995 @code{gtroff} has string variables, which are entirely for user
8996 convenience (i.e.@: there are no built-in strings exept @code{.T}, but
8997 even this is a read-write string variable).
8999 @DefreqList {ds, name [@Var{string}]}
9000 @DefreqItem {ds1, name [@Var{string}]}
9001 @DefescItem {\\*, , n, }
9002 @DefescItem {\\*, @lparen{}, nm, }
9003 @DefescListEnd {\\*, @lbrack{}, name arg1 arg2 @dots{}, @rbrack{}}
9004 @cindex string interpolation (@code{\*})
9005 @cindex string expansion (@code{\*})
9006 @cindex interpolation of strings (@code{\*})
9007 @cindex expansion of strings (@code{\*})
9008 @cindex string arguments
9009 @cindex arguments, of strings
9010 Define and access a string variable @var{name} (one-character name@w{
9011 }@var{n}, two-character name @var{nm}).  If @var{name} already exists,
9012 @code{ds} overwrites the previous definition.  Only the syntax form
9013 using brackets can take arguments which are handled identically to
9014 macro arguments; the single exception is that a closing bracket as an
9015 argument must be enclosed in double quotes.  @xref{Request Arguments},
9016 and @ref{Parameters}.
9018 Example:
9020 @Example
9021 .ds foo a \\$1 test
9023 This is \*[foo nice].
9024     @result{} This is a nice test.
9025 @endExample
9027 The @code{\*} escape @dfn{interpolates} (expands in-place) a
9028 previously-defined string variable.  To be more precise, the stored
9029 string is pushed onto the input stack which is then parsed by
9030 @code{gtroff}.  Similar to number registers, it is possible to nest
9031 strings, i.e. string variables can be called within string variables.
9033 If the string named by the @code{\*} escape does not exist, it is
9034 defined as empty, and a warning of type @samp{mac} is emitted (see
9035 @ref{Debugging}, for more details).
9037 @cindex comments, with @code{ds}
9038 @cindex @code{ds} request, and comments
9039 @strong{Caution:} Unlike other requests, the second argument to the
9040 @code{ds} request takes up the entire line including trailing spaces.
9041 This means that comments on a line with such a request can introduce
9042 unwanted space into a string.
9044 @Example
9045 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d \" UNIX trademark
9046 @endExample
9048 @noindent
9049 Instead the comment should be put on another line or have the comment
9050 escape adjacent with the end of the string.
9052 @Example
9053 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d\"  UNIX trademark
9054 @endExample
9056 @cindex trailing quotes
9057 @cindex quotes, trailing
9058 @cindex leading spaces with @code{ds}
9059 @cindex spaces with @code{ds}
9060 @cindex @code{ds} request, and leading spaces
9061 To produce leading space the string can be started with a double
9062 quote.  No trailing quote is needed; in fact, any trailing quote is
9063 included in your string.
9065 @Example
9066 .ds sign "           Yours in a white wine sauce,
9067 @endExample
9069 @cindex multi-line strings
9070 @cindex strings, multi-line
9071 @cindex newline character, in strings, escaping
9072 @cindex escaping newline characters, in strings
9073 Strings are not limited to a single line of text.  A string can span
9074 several lines by escaping the newlines with a backslash.  The
9075 resulting string is stored @emph{without} the newlines.
9077 @Example
9078 .ds foo lots and lots \
9079 of text are on these \
9080 next several lines
9081 @endExample
9083 It is not possible to have real newlines in a string.  To put a single
9084 double quote character into a string, use two consecutive double quote
9085 characters.
9087 The @code{ds1} request turns off compatibility mode
9088 while interpreting a string.  To be more precise, a @dfn{compatibility
9089 save} input token is inserted at the beginning of  the string, and a
9090 @dfn{compatibility restore} input token at the end.
9092 @Example
9093 .nr xxx 12345
9094 .ds aa The value of xxx is \\n[xxx].
9095 .ds1 bb The value of xxx ix \\n[xxx].
9097 .cp 1
9099 \*(aa
9100     @result{} warning: number register `[' not defined
9101     @result{} The value of xxx is 0xxx].
9102 \*(bb
9103     @result{} The value of xxx ix 12345.
9104 @endExample
9106 @cindex name space, common, of macros, diversions, and strings
9107 @cindex common name space of macros, diversions, and strings
9108 @cindex macros, shared name space with strings and diversions
9109 @cindex strings, shared name space with macros and diversions
9110 @cindex diversions, shared name space with macros and strings
9111 Strings, macros, and diversions (and boxes) share the same name space.
9112 Internally, even the same mechanism is used to store them.  This has
9113 some interesting consequences.  For example, it is possible to call a
9114 macro with string syntax and vice versa.
9116 @Example
9117 .de xxx
9118 a funny test.
9120 This is \*[xxx]
9121     @result{} This is a funny test.
9123 .ds yyy a funny test
9124 This is
9125 .yyy
9126     @result{} This is a funny test.
9127 @endExample
9129 Diversions and boxes can be also called with string syntax.
9131 Another consequence is that you can copy one-line diversions or boxes
9132 to a string.
9134 @Example
9135 .di xxx
9136 a \fItest\fR
9139 .ds yyy This is \*[xxx]\c
9140 \*[yyy].
9141     @result{} @r{This is a }@i{test}.
9142 @endExample
9144 @noindent
9145 As the previous example shows, it is possible to store formatted
9146 output in strings.  The @code{\c} escape prevents the insertion of an
9147 additional blank line in the output.
9149 Copying diversions longer than a single output line produces
9150 unexpected results.
9152 @Example
9153 .di xxx
9154 a funny
9156 test
9159 .ds yyy This is \*[xxx]\c
9160 \*[yyy].
9161     @result{} test This is a funny.
9162 @endExample
9164 Usually, it is not predictable whether a diversion contains one or
9165 more output lines, so this mechanism should be avoided.  With
9166 @acronym{UNIX} @code{troff}, this was the only solution to strip off a
9167 final newline from a diversion.  Another disadvantage is that the
9168 spaces in the copied string are already formatted, making them
9169 unstretchable.  This can cause ugly results.
9171 @cindex stripping final newline in diversions
9172 @cindex diversion, stripping final newline
9173 @cindex final newline, stripping in diversions
9174 @cindex newline, final, stripping in diversions
9175 @cindex horizontal space, unformatting
9176 @cindex space, horizontal, unformatting
9177 @cindex unformatting horizontal space
9178 A clean solution to this problem is available in GNU @code{troff},
9179 using the requests @code{chop} to remove the final newline of a
9180 diversion, and @code{unformat} to make the horizontal spaces
9181 stretchable again.
9183 @Example
9184 .box xxx
9185 a funny
9187 test
9189 .box
9190 .chop xxx
9191 .unformat xxx
9192 This is \*[xxx].
9193     @result{} This is a funny test.
9194 @endExample
9196 @xref{Gtroff Internals}, for more information.
9197 @endDefreq
9199 @DefreqList {as, name [@Var{string}]}
9200 @DefreqListEnd {as1, name [@Var{string}]}
9201 @cindex appending to a string (@code{as})
9202 @cindex string, appending (@code{as})
9203 The @code{as} request is similar to @code{ds} but appends @var{string}
9204 to the string stored as @var{name} instead of redefining it.  If
9205 @var{name} doesn't exist yet, it is created.
9207 @Example
9208 .as sign " with shallots, onions and garlic,
9209 @endExample
9211 The @code{as1} request is similar to @code{as}, but compatibility mode
9212 is switched off while the appended string is interpreted.  To be more
9213 precise, a @dfn{compatibility save} input token is inserted at the
9214 beginning of the appended string, and a @dfn{compatibility restore}
9215 input token at the end.
9216 @endDefreq
9218 Rudimentary string manipulation routines are given with the next two
9219 requests.
9221 @Defreq {substring, str n1 [@Var{n2}]}
9222 @cindex substring (@code{substring})
9223 Replace the string named @var{str} with the substring
9224 defined by the indices @var{n1} and@w{ }@var{n2}.  The first character
9225 in the string has index@w{ }0.  If @var{n2} is omitted, it is taken to
9226 be equal to the string's length.  If the index value @var{n1} or
9227 @var{n2} is negative, it is counted from the end of the
9228 string, going backwards: The last character has index@w{ }@minus{}1, the
9229 character before the last character has index@w{ }@minus{}2, etc.
9231 @Example
9232 .ds xxx abcdefgh
9233 .substring xxx 1 -4
9234 \*[xxx]
9235     @result{} bcde
9236 @endExample
9237 @endDefreq
9239 @Defreq {length, reg str}
9240 @cindex length of a string (@code{length})
9241 @cindex string, length of (@code{length})
9242 Compute the number of characters of @var{str} and return it in the
9243 number register @var{reg}.  If @var{reg} doesn't exist, it is created.
9244 @code{str} is read in copy mode.
9246 @Example
9247 .ds xxx abcd\h'3i'efgh
9248 .length yyy \n[xxx]
9249 \n[yyy]
9250     @result{} 14
9251 @endExample
9252 @endDefreq
9254 @Defreq {rn, xx yy}
9255 @cindex renaming request (@code{rn})
9256 @cindex request, renaming (@code{rn})
9257 @cindex renaming macro (@code{rn})
9258 @cindex macro, renaming (@code{rn})
9259 @cindex renaming string (@code{rn})
9260 @cindex string, renaming (@code{rn})
9261 @cindex renaming diversion (@code{rn})
9262 @cindex diversion, renaming (@code{rn})
9263 Rename the request, macro, diversion, or string @var{xx} to @var{yy}.
9264 @endDefreq
9266 @Defreq {rm, xx}
9267 @cindex removing request (@code{rm})
9268 @cindex request, removing (@code{rm})
9269 @cindex removing macro (@code{rm})
9270 @cindex macro, removing (@code{rm})
9271 @cindex removing string (@code{rm})
9272 @cindex string, removing (@code{rm})
9273 @cindex removing diversion (@code{rm})
9274 @cindex diversion, removing (@code{rm})
9275 Remove the request, macro, diversion, or string @var{xx}.  @code{gtroff}
9276 treats subsequent invocations as if the object had never been defined.
9277 @endDefreq
9279 @Defreq {als, new old}
9280 @cindex alias, string, creating (@code{als})
9281 @cindex alias, macro, creating (@code{als})
9282 @cindex alias, diversion, creating (@code{als})
9283 @cindex creating alias, for string (@code{als})
9284 @cindex creating alias, for macro (@code{als})
9285 @cindex creating alias, for diversion (@code{als})
9286 @cindex string, creating alias (@code{als})
9287 @cindex macro, creating alias (@code{als})
9288 @cindex diversion, creating alias (@code{als})
9289 Create an alias named @var{new} for the request, string, macro, or
9290 diversion object named @var{old}.  The new name and the old name are
9291 exactly equivalent (it is similar to a hard rather than a soft
9292 link). If @var{old} is undefined, @code{gtroff} generates a warning of
9293 type @samp{mac} and ignores the request.
9294 @endDefreq
9296 @Defreq {chop, xx}
9297 Remove (chop) the last character from the macro, string, or diversion
9298 named @var{xx}.  This is useful for removing the newline from the end
9299 of diversions that are to be interpolated as strings.  This command
9300 can be used repeatedly; see @ref{Gtroff Internals}, for details on
9301 nodes inserted additionally by @code{gtroff}.
9302 @endDefreq
9304 @xref{Identifiers}, and @ref{Comments}.
9307 @c =====================================================================
9309 @node Conditionals and Loops, Writing Macros, Strings, gtroff Reference
9310 @section Conditionals and Loops
9311 @cindex conditionals and loops
9312 @cindex loops and conditionals
9314 @menu
9315 * Operators in Conditionals::
9316 * if-else::
9317 * while::
9318 @end menu
9320 @c ---------------------------------------------------------------------
9322 @node Operators in Conditionals, if-else, Conditionals and Loops, Conditionals and Loops
9323 @subsection Operators in Conditionals
9325 @cindex @code{if} request, operators to use with
9326 @cindex @code{while} request, operators to use with
9327 In @code{if} and @code{while} requests, there are several more
9328 operators available:
9330 @table @code
9331 @item e
9332 @itemx o
9333 True if the current page is even or odd numbered (respectively).
9335 @item n
9336 True if the document is being processed in nroff mode (i.e., the
9337 @code{.nroff} command has been issued).
9339 @item t
9340 True if the document is being processed in troff mode (i.e., the
9341 @code{.troff} command has been issued).
9343 @item v
9344 Always false.  This condition is for compatibility with other
9345 @code{troff} versions only.
9347 @item '@var{xxx}'@var{yyy}'
9348 True if the string @var{xxx} is equal to the string @var{yyy}.  Other
9349 characters can be used in place of the single quotes; the same set of
9350 delimiters as for the @code{\D} escape is used (@pxref{Escapes}).
9351 @code{gtroff} formats the strings before being compared:
9353 @Example
9354 .ie "|"\fR|\fP" \
9355 true
9356 .el \
9357 false
9358     @result{} true
9359 @endExample
9361 @noindent
9362 The resulting motions, glyph sizes, and fonts have to
9363 match,@footnote{The created output nodes must be identical.
9364 @xref{Gtroff Internals}.} and not the individual motion, size, and
9365 font requests.  In the previous example, @samp{|} and @samp{\fR|\fP}
9366 both result in a roman @samp{|} glyph with the same point size and
9367 at the same location on the page, so the strings are equal.  If
9368 @samp{.ft@w{ }I} had been added before the @samp{.ie}, the result
9369 would be ``false'' because (the first) @samp{|} produces an italic
9370 @samp{|} rather than a roman one.
9372 @item r @var{xxx}
9373 True if there is a number register named @var{xxx}.
9375 @item d @var{xxx}
9376 True if there is a string, macro, diversion, or request named @var{xxx}.
9378 @item m @var{xxx}
9379 True if there is a color named @var{xxx}.
9381 @item c @var{g}
9382 True if there is a glyph @var{g} available@footnote{The name of this
9383 conditional operator is a misnomer since it tests names of output
9384 glyphs.}; @var{g} is either an @acronym{ASCII} character or a special
9385 character (@code{\(@var{gg}} or @code{\[@var{ggg}]}); the condition
9386 is also true if @var{g} has been defined by the @code{char} request.
9387 @end table
9389 Note that these operators can't be combined with other operators like
9390 @samp{:} or @samp{&}; only a leading @samp{!} (without whitespace
9391 between the exclamation mark and the operator) can be used to negate
9392 the result.
9394 @Example
9395 .nr xxx 1
9396 .ie !r xxx \
9397 true
9398 .el \
9399 false
9400     @result{} false
9401 @endExample
9403 A whitespace after @samp{!} always evaluates to zero (this bizarre
9404 behaviour is due to compatibility with @acronym{UNIX} @code{troff}).
9406 @Example
9407 .nr xxx 1
9408 .ie ! r xxx \
9409 true
9410 .el \
9411 false
9412     @result{} r xxx true
9413 @endExample
9415 It is possible to omit the whitespace before the argument to the
9416 @samp{r}, @samp{d}, and @samp{c} operators.
9418 @xref{Expressions}.
9420 @c ---------------------------------------------------------------------
9422 @node if-else, while, Operators in Conditionals, Conditionals and Loops
9423 @subsection if-else
9424 @cindex if-else
9426 @code{gtroff} has if-then-else constructs like other languages, although
9427 the formatting can be painful.
9429 @Defreq {if, expr anything}
9430 Evaluate the expression @var{expr}, and executes @var{anything} (the
9431 remainder of the line) if @var{expr} evaluates to non-zero (true).
9432 @var{anything} is interpreted as though it was on a line by itself
9433 (except that leading spaces are swallowed).  @xref{Expressions}, for
9434 more info.
9436 @Example
9437 .nr xxx 1
9438 .nr yyy 2
9439 .if ((\n[xxx] == 1) & (\n[yyy] == 2)) true
9440     @result{} true
9441 @endExample
9442 @endDefreq
9444 @Defreq{nop, anything}
9445 Executes @var{anything}.
9446 This is similar to @code{.if@w{ }1}.
9447 @endDefreq
9449 @DefreqList {ie, expr anything}
9450 @DefreqListEnd {el, anything}
9451 Use the @code{ie} and @code{el} requests to write an if-then-else.
9452 The first request is the `if' part and the latter is the `else' part.
9454 @Example
9455 .ie n .ls 2 \" double-spacing in nroff
9456 .el   .ls 1 \" single-spacing in troff
9457 @endExample
9458 @endDefreq
9460 @c there is a bug in makeinfo <= 4.1a: you can't have `@{' as an argument
9461 @c to @deffn
9463 @c and in 4.2 you still can't use @{ in macros.
9465 @c @DefescList {\@{, , , }
9466 @c @DefescListEnd {\@}, , , }
9467 @deffn Escape @t{\@{}
9468 @deffnx Escape @t{\@}}
9469 @esindex \@{
9470 @esindex \@}
9471 @cindex begin of conditional block (@code{\@{})
9472 @cindex end of conditional block (@code{\@}})
9473 @cindex conditional block, begin (@code{\@{})
9474 @cindex conditional block, end (@code{\@}})
9475 @cindex block, conditional, begin (@code{\@{})
9476 @cindex block, condititional, end (@code{\@}})
9477 In many cases, an if (or if-else) construct needs to execute more than
9478 one request.  This can be done using the @code{\@{} and @code{\@}}
9479 escapes.  The following example shows the possible ways to use these
9480 escapes (note the position of the opening and closing braces).
9482 @Example
9483 .ie t \@{\
9484 .    ds lq ``
9485 .    ds rq ''
9486 .\@}
9487 .el \
9488 .\@{\
9489 .    ds lq "
9490 .    ds rq "\@}
9491 @endExample
9492 @c @endDefesc
9493 @end deffn
9495 @xref{Expressions}.
9497 @c ---------------------------------------------------------------------
9499 @node while,  , if-else, Conditionals and Loops
9500 @subsection while
9501 @cindex while
9503 @code{gtroff} provides a looping construct using the @code{while}
9504 request, which is used much like the @code{if} (and related) requests.
9506 @Defreq {while, expr anything}
9507 Evaluate the expression @var{expr}, and repeatedly execute
9508 @var{anything} (the remainder of the line) until @var{expr} evaluates
9509 to@w{ }0.
9511 @Example
9512 .nr a 0 1
9513 .while (\na < 9) \@{\
9514 \n+a,
9515 .\@}
9516 \n+a
9517     @result{} 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
9518 @endExample
9520 Some remarks.
9522 @cindex @code{de} request, and @code{while}
9523 @itemize @bullet
9524 @item
9525 The body of a @code{while} request is treated like the body of a
9526 @code{de} request: @code{gtroff} temporarily stores it in a macro
9527 which is deleted after the loop has been exited.  It can considerably
9528 slow down a macro if the body of the @code{while} request (within the
9529 macro) is large.  Each time the macro is executed, the @code{while}
9530 body is parsed and stored again as a temporary macro.
9532 @Example
9533 .de xxx
9534 .  nr num 10
9535 .  while (\\n[num] > 0) \@{\
9536 .    \" many lines of code
9537 .    nr num -1
9538 .  \@}
9540 @endExample
9542 @cindex recursive macros
9543 @cindex macros, recursive
9544 @noindent
9545 The traditional and ofter better solution (@acronym{UNIX} @code{troff}
9546 doesn't have the @code{while} request) is to use a recursive macro
9547 instead which is parsed only once during its definition.
9549 @Example
9550 .de yyy
9551 .  if (\\n[num] > 0) \@{\
9552 .    \" many lines of code
9553 .    nr num -1
9554 .    yyy
9555 .  \@}
9558 .de xxx
9559 .  nr num 10
9560 .  yyy
9562 @endExample
9564 @noindent
9565 Note that the number of available recursion levels is set to@w{ }1000
9566 (this is a compile-time constant value of @code{gtroff}).
9568 @item
9569 The closing brace of a @code{while} body must end a line.
9571 @Example
9572 .if 1 \@{\
9573 .  nr a 0 1
9574 .  while (\n[a] < 10) \@{\
9575 .    nop \n+[a]
9576 .\@}\@}
9577     @result{} unbalanced \@{ \@}
9578 @endExample
9579 @end itemize
9580 @endDefreq
9582 @Defreq {break, }
9583 @cindex @code{while} request, confusing with @code{br}
9584 @cindex @code{break} request, in a @code{while} loop
9585 @cindex @code{continue} request, in a @code{while} loop
9586 Break out of a @code{while} loop.  Be sure not to confuse this with
9587 the @code{br} request (causing a line break).
9588 @endDefreq
9590 @Defreq {continue, }
9591 Finish the current iteration of a @code{while} loop, immediately
9592 restarting the next iteration.
9593 @endDefreq
9595 @xref{Expressions}.
9598 @c =====================================================================
9600 @node Writing Macros, Page Motions, Conditionals and Loops, gtroff Reference
9601 @section Writing Macros
9602 @cindex writing macros
9603 @cindex macros, writing
9605 A @dfn{macro} is a collection of text and embedded commands which can
9606 be invoked multiple times.  Use macros to define common operations.
9608 @DefreqList {de, name [@Var{end}]}
9609 @DefreqItem {de1, name [@Var{end}]}
9610 @DefreqListEnd {dei, name [@Var{end}]}
9611 Define a new macro named @var{name}.  @code{gtroff} copies subsequent
9612 lines (starting with the next one) into an internal buffer until it
9613 encounters the line @samp{..} (two dots).  The optional second
9614 argument to @code{de} changes this to a macro to @samp{.@var{end}}.
9616 There can be whitespace after the first dot in the line containing the
9617 ending token (either @samp{.} or macro @samp{@var{end}}).
9619 Here a small example macro called @samp{P} which causes a break and
9620 inserts some vertical space.  It could be used to separate paragraphs.
9622 @Example
9623 .de P
9624 .  br
9625 .  sp .8v
9627 @endExample
9629 The following example defines a macro within another.  Remember that
9630 expansion must be protected twice; once for reading the macro and
9631 once for executing.
9633 @Example
9634 \# a dummy macro to avoid a warning
9635 .de end
9638 .de foo
9639 .  de bar end
9640 .    nop \f[B]Hallo \\\\$1!\f[]
9641 .  end
9644 .foo
9645 .bar Joe
9646     @result{} @b{Hallo Joe!}
9647 @endExample
9649 @noindent
9650 Since @code{\f} has no expansion, it isn't necessary to protect its
9651 backslash.  Had we defined another macro within @code{bar} which takes
9652 a parameter, eight backslashes would be necessary before @samp{$1}.
9654 The @code{de1} request turns off compatibility mode
9655 while executing the macro.  On entry, the current compatibility mode
9656 is saved and restored at exit.
9658 @Example
9659 .nr xxx 12345
9661 .de aa
9662 The value of xxx is \\n[xxx].
9664 .de1 bb
9665 The value of xxx ix \\n[xxx].
9668 .cp 1
9671     @result{} warning: number register \e' not defined
9672     @result{} The value of xxx is 0xxx].
9674     @result{} The value of xxx ix 12345.
9675 @endExample
9677 The @code{dei} request defines a macro indirectly.
9678 That is, it expands strings whose names
9679 are @var{name} or @var{end} before performing the append.
9681 This:
9683 @Example
9684 .ds xx aa
9685 .ds yy bb
9686 .dei xx yy
9687 @endExample
9689 @noindent
9690 is equivalent to:
9692 @Example
9693 .de aa bb
9694 @endExample
9696 @pindex trace.tmac
9697 Using @file{trace.tmac}, you can trace calls to @code{de} and @code{de1}.
9699 Note that macro identifiers are shared with identifiers for strings and
9700 diversions.
9701 @endDefreq
9703 @DefreqList {am, xx}
9704 @DefreqItem {am1, xx}
9705 @DefreqListEnd {ami, xx yy}
9706 @cindex appending to a macro (@code{am})
9707 @cindex macro, appending (@code{am})
9708 Works similarly to @code{de} except it appends onto the macro named
9709 @var{xx}.  So, to make the previously defined @samp{P} macro actually
9710 do indented instead of block paragraphs, add the necessary code to the
9711 existing macro like this:
9713 @Example
9714 .am P
9715 .ti +5n
9717 @endExample
9719 The @code{am1} request turns off compatibility mode
9720 while executing the appended macro piece.  To be more precise, a
9721 @dfn{compatibility save} input token is inserted at the beginning of
9722 the appended code, and a @dfn{compatibility restore} input token at
9723 the end.
9725 The @code{ami} request appends indirectly,
9726 meaning that @code{gtroff} expands strings whose names
9727 are @var{xx} or @var{yy} before performing the append.
9729 @pindex trace.tmac
9730 Using @file{trace.tmac}, you can trace calls to @code{am} and @code{am1}.
9731 @endDefreq
9733 @xref{Strings}, for the @code{als} request to rename a macro.
9735 The @code{de}, @code{am}, @code{di}, @code{da}, @code{ds}, and
9736 @code{as} requests (together with its variants) only create a new object
9737 if the name of the macro, diversion or string diversion is currently
9738 undefined or if it is defined to be a request; normally they modify the
9739 value of an existing object.
9741 @Defreq {return, }
9742 Exit a macro, immediately returning to the caller.
9743 @endDefreq
9745 @menu
9746 * Copy-in Mode::
9747 * Parameters::
9748 @end menu
9750 @c ---------------------------------------------------------------------
9752 @node Copy-in Mode, Parameters, Writing Macros, Writing Macros
9753 @subsection Copy-in Mode
9754 @cindex copy-in mode
9755 @cindex mode, copy-in
9757 @cindex @code{\n}, when reading text for a macro
9758 @cindex @code{\$}, when reading text for a macro
9759 @cindex @code{\*}, when reading text for a macro
9760 @cindex @code{\\}, when reading text for a macro
9761 @cindex \@key{RET}, when reading text for a macro
9762 When @code{gtroff} reads in the text for a macro, string, or diversion,
9763 it copies the text (including request lines, but excluding escapes) into
9764 an internal buffer.  Escapes are converted into an internal form,
9765 except for @code{\n}, @code{\$}, @code{\*}, @code{\\} and
9766 @code{\@key{RET}} which are evaluated and inserted into the text where
9767 the escape was located.  This is known as @dfn{copy-in} mode or
9768 @dfn{copy} mode.
9770 What this means is that you can specify when these escapes are to be
9771 evaluated (either at copy-in time or at the time of use) by insulating
9772 the escapes with an extra backslash.  Compare this to the @code{\def}
9773 and @code{\edef} commands in @TeX{}.
9775 The following example prints the numbers 20 and@w{ }10:
9777 @Example
9778 .nr x 20
9779 .de y
9780 .nr x 10
9781 \&\nx
9782 \&\\nx
9785 @endExample
9787 @c ---------------------------------------------------------------------
9789 @node Parameters,  , Copy-in Mode, Writing Macros
9790 @subsection Parameters
9791 @cindex parameters
9793 The arguments to a macro or string can be examined using a variety of
9794 escapes.
9796 @Defreg {.$}
9797 @cindex number of arguments register (@code{.$})
9798 The number of arguments passed to a macro or string.  This is a read-only
9799 number register.
9800 @endDefreg
9802 Any individual argument can be retrieved with one of the following
9803 escapes:
9805 @DefescList {\\$, , n, }
9806 @DefescItem {\\$, @lparen{}, nn, }
9807 @DefescListEnd {\\$, @lbrack{}, nnn, @rbrack{}}
9808 @cindex copy-in mode, and macro arguments
9809 @cindex macro, arguments (@code{\$})
9810 @cindex arguments, macro (@code{\$})
9811 Retrieve the @var{n}@dmn{th}, @var{nn}@dmn{th} or @var{nnn}@dmn{th}
9812 argument.  As usual, the first form only accepts a single number
9813 (larger than zero), the second a two-digit number (larger or equal
9814 to@w{ }10), and the third any positive integer value (larger
9815 than zero).  Macros and strings can have an unlimited number of arguments.
9816 Note that due to copy-in mode, use two backslashes on these in actual use
9817 to prevent interpolation until the macro is actually invoked.
9818 @endDefesc
9820 @Defreq {shift, [@Var{n}]}
9821 Shift the arguments 1@w{ }position, or as
9822 many positions as specified by its argument.  After executing this
9823 request, argument@w{ }@var{i} becomes argument @math{@var{i}-@var{n}};
9824 arguments 1 to@w{ }@var{n} are no longer available.  Shifting by
9825 negative amounts is currently undefined.
9826 @endDefreq
9828 @DefescList {\\$*, , , }
9829 @DefescListEnd {\\$@@, , , }
9830 In some cases it is convenient to use all of the arguments at once (for
9831 example, to pass the arguments along to another macro).  The @code{\$*}
9832 escape concatenates all the arguments separated by spaces.  A
9833 similar escape is @code{\$@@}, which concatenates all the
9834 arguments with each surrounded by double quotes, and separated by
9835 spaces.  If not in compatibility mode, the input level of double quotes
9836 is preserved (see @ref{Request Arguments}).
9837 @endDefesc
9839 @Defesc {\\$0, , , }
9840 @cindex macro name register (@code{\$0})
9841 @cindex @code{als} request, and @code{\$0}
9842 The name used to invoke the current macro.
9843 The @code{als} request can make a macro have more than one name.
9845 @Example
9846 .de generic-macro
9847 .  ...
9848 .  if \\n[error] \@{\
9849 .    tm \\$0: Houston, we have a problem.
9850 .    return
9851 .  \@}
9854 .als foo generic-macro
9855 .als bar generic-macro
9856 @endExample
9857 @endDefesc
9859 @xref{Request Arguments}.
9862 @c =====================================================================
9864 @node Page Motions, Drawing Requests, Writing Macros, gtroff Reference
9865 @section Page Motions
9866 @cindex page motions
9867 @cindex motions, page
9869 @xref{Manipulating Spacing}, for a discussion of the main request for
9870 vertical motion, @code{sp}.
9872 @DefreqList {mk, [@Var{reg}]}
9873 @DefreqListEnd {rt, [@Var{dist}]}
9874 @cindex marking vertical page location (@code{mk})
9875 @cindex page location, vertical, marking (@code{mk})
9876 @cindex location, vertical, page, marking (@code{mk})
9877 @cindex vertical page location, marking (@code{mk})
9878 @cindex returning to marked vertical page location (@code{rt})
9879 @cindex page location, vertical, returning to marked (@code{rt})
9880 @cindex location, vertical, page, returning to marked (@code{rt})
9881 @cindex vertical page location, returning to marked (@code{rt})
9882 The request @code{mk} can be used to mark a location on a page, for
9883 movement to later.  This request takes a register name as an argument
9884 in which to store the current page location.  With no argument it
9885 stores the location in an internal register.  The results of this can
9886 be used later by the @code{rt} or the @code{sp} request (or the
9887 @code{\v} escape).
9889 The @code{rt} request returns @emph{upwards} to the location marked
9890 with the last @code{mk} request.  If used with an argument, return to
9891 a position which distance from the top of the page is @var{dist} (no
9892 previous call to @code{mk} is necessary in this case).  Default scaling
9893 indicator is @samp{v}.
9895 Here a primitive solution for a two-column macro.
9897 @Example
9898 .nr column-length 1.5i
9899 .nr column-gap 4m
9900 .nr bottom-margin 1m
9902 @endExample
9903 @Example
9904 .de 2c
9905 .  br
9906 .  mk
9907 .  ll \\n[column-length]u
9908 .  wh -\\n[bottom-margin]u 2c-trap
9909 .  nr right-side 0
9912 @endExample
9913 @Example
9914 .de 2c-trap
9915 .  ie \\n[right-side] \@{\
9916 .    nr right-side 0
9917 .    po -(\\n[column-length]u + \\n[column-gap]u)
9918 .    \" remove trap
9919 .    wh -\\n[bottom-margin]u
9920 .  \@}
9921 .  el \@{\
9922 .    \" switch to right side
9923 .    nr right-side 1
9924 .    po +(\\n[column-length]u + \\n[column-gap]u)
9925 .    rt
9926 .  \@}
9929 @endExample
9930 @Example
9931 .pl 1.5i
9932 .ll 4i
9933 This is a small test which shows how the
9934 rt request works in combination with mk.
9937 Starting here, text is typeset in two columns.
9938 Note that this implementation isn't robust
9939 and thus not suited for a real two-column
9940 macro.
9941 @endExample
9943 Result:
9945 @Example
9946 This is a small test which shows how the
9947 rt request works in combination with mk.
9949 Starting  here,    isn't    robust
9950 text is typeset    and   thus  not
9951 in two columns.    suited  for   a
9952 Note that  this    real two-column
9953 implementation     macro.
9954 @endExample
9955 @endDefreq
9957 The following escapes give fine control of movements about the page.
9959 @Defesc {\\v, ', e, '}
9960 @cindex vertical motion (@code{\v})
9961 @cindex motion, vertical (@code{\v})
9962 Move vertically, usually from the current location on the page (if no
9963 absolute position operator @samp{|} is used).  The
9964 argument@w{ }@var{e} specifies the distance to move; positive is
9965 downwards and negative upwards.  The default scaling indicator for this
9966 escape is @samp{v}.  Beware, however, that @code{gtroff} continues text
9967 processing at the point where the motion ends, so you should always
9968 balance motions to avoid interference with text processing.
9970 @code{\v} doesn't trigger a trap.  This can be quite useful; for example,
9971 consider a page bottom trap macro which prints a marker in the margin to
9972 indicate continuation of a footnote or something similar.
9973 @endDefesc
9975 There are some special-case escapes for vertical motion.
9977 @Defesc {\\r, , , }
9978 Move upwards@w{ }1@dmn{v}.
9979 @endDefesc
9981 @Defesc {\\u, , , }
9982 Move upwards@w{ }.5@dmn{v}.
9983 @endDefesc
9985 @Defesc {\\d, , , }
9986 Move down@w{ }.5@dmn{v}.
9987 @endDefesc
9989 @Defesc {\\h, ', e, '}
9990 @cindex inserting horizontal space (@code{\h})
9991 @cindex horizontal space (@code{\h})
9992 @cindex space, horizontal (@code{\h})
9993 @cindex horizontal motion (@code{\h})
9994 @cindex motion, horizontal (@code{\h})
9995 Move horizontally, usually from the current location (if no absolute
9996 position operator @samp{|} is used).  The expression@w{ }@var{e}
9997 indicates how far to move: positive is rightwards and negative
9998 leftwards.  The default scaling indicator for this escape is @samp{m}.
9999 @endDefesc
10001 There are a number of special-case escapes for horizontal motion.
10003 @Defesc {\\@key{SP}, , , }
10004 @cindex space, unbreakable
10005 @cindex unbreakable space
10006 An unbreakable and unpaddable (i.e.@: not expanded during filling)
10007 space.  (Note: This is a backslash followed by a space.)
10008 @endDefesc
10010 @Defesc {\\~, , , }
10011 An unbreakable space that stretches like a normal inter-word space
10012 when a line is adjusted.
10013 @endDefesc
10015 @Defesc {\\|, , , }
10016 A 1/6@dmn{th} em space.  Ignored for TTY output devices (rounded to
10017 zero).
10018 @endDefesc
10020 @Defesc {\\^, , , }
10021 A 1/12@dmn{th} em space.  Ignored for TTY output devices (rounded to
10022 zero).
10023 @endDefesc
10025 @Defesc {\\0, , , }
10026 @cindex space, width of a digit (@code{\0})
10027 @cindex digit width space (@code{\0})
10028 A space the size of a digit.
10029 @endDefesc
10031 The following string sets the @TeX{} logo:
10033 @Example
10034 .ds TeX T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
10035 @endExample
10037 @DefescList {\\w, ', text, '}
10038 @DefregItem {st}
10039 @DefregItem {sb}
10040 @DefregItem {rst}
10041 @DefregItem {rsb}
10042 @DefregItem {ct}
10043 @DefregItem {ssc}
10044 @DefregListEnd {skw}
10045 @cindex width escape (@code{\w})
10046 Return the width of the specified @var{text} in basic units.
10047 This allows horizontal movement based on the width of some
10048 arbitrary text (e.g.@: given as an argument to a macro).
10050 @Example
10051 The length of the string `abc' is \w'abc'u.
10052     @result{} The length of the string `abc' is 72u.
10053 @endExample
10055 Font changes may occur in @var{text} which don't affect current
10056 settings.
10058 After use, @code{\w} sets several registers:
10060 @table @code
10061 @item st
10062 @itemx sb
10063 The highest and lowest point of the baseline, respectively, in @var{text}.
10065 @item rst
10066 @itemx rsb
10067 Like the @code{st} and @code{sb} registers, but takes account of the
10068 heights and depths of glyphs.  With other words, this gives the
10069 highest and lowest point of @var{text}.
10071 @item ct
10072 Defines the kinds of glyphs occurring in @var{text}:
10074 @table @asis
10075 @item 0
10076 only short glyphs, no descenders or tall glyphs.
10078 @item 1
10079 at least one descender.
10081 @item 2
10082 at least one tall glyph.
10084 @item 3
10085 at least one each of a descender and a tall glyph.
10086 @end table
10088 @item ssc
10089 The amount of horizontal space (possibly negative) that should be added
10090 to the last glyph before a subscript.
10092 @item skw
10093 How far to right of the center of the last glyph in the @code{\w}
10094 argument, the center of an accent from a roman font should be placed
10095 over that glyph.
10096 @end table
10097 @endDefesc
10099 @DefescList {\\k, , p, }
10100 @DefescItem {\\k, @lparen{}, ps, }
10101 @DefescListEnd {\\k, @lbrack{}, position, @rbrack}
10102 @cindex saving horizontal input line position (@code{\k})
10103 @cindex horizontal input line position, saving (@code{\k})
10104 @cindex input line position, horizontal, saving (@code{\k})
10105 @cindex position, horizontal input line, saving (@code{\k})
10106 @cindex line, input, horizontal position, saving (@code{\k})
10107 Store the current horizontal position in the @emph{input} line in
10108 number register with name @var{position} (one-character name@w{ }@var{p},
10109 two-character name @var{ps}).  Use this, for example, to return to the
10110 beginning of a string for highlighting or other decoration.
10111 @endDefesc
10113 @Defreg {hp}
10114 @cindex horizontal input line position register (@code{hp})
10115 @cindex input line, horizontal position, register (@code{hp})
10116 @cindex position, horizontal, in input line, register (@code{hp})
10117 @cindex line, input, horizontal position, register (@code{hp})
10118 The current horizontal position at the input line.
10119 @endDefreg
10121 @Defreg {.k}
10122 @cindex horizontal output line position register (@code{.k})
10123 @cindex output line, horizontal position, register (@code{.k})
10124 @cindex position, horizontal, in output line, register (@code{.k})
10125 @cindex line, output, horizontal position, register (@code{.k})
10126 A read-only number register containing the current horizontal output
10127 position.
10128 @endDefreg
10130 @Defesc {\\o, ', @Var{a}@Var{b}@Var{c}, '}
10131 @cindex overstriking glyphs (@code{\o})
10132 @cindex glyphs, overstriking (@code{\o})
10133 Overstrike glyphs @var{a}, @var{b}, @var{c}, @dots{}; the glyphs
10134 are centered, and the resulting spacing is the largest width of the
10135 affected glyphs.
10136 @endDefesc
10138 @Defesc {\\z, , g, , }
10139 @cindex zero-width printing (@code{\z}, @code{\Z})
10140 @cindex printing, zero-width (@code{\z}, @code{\Z})
10141 Print glyph @var{g} with zero width, i.e., without spacing.  Use
10142 this to overstrike glyphs left-aligned.
10143 @endDefesc
10145 @Defesc {\\Z, ', anything, '}
10146 @cindex zero-width printing (@code{\z}, @code{\Z})
10147 @cindex printing, zero-width (@code{\z}, @code{\Z})
10148 Print @var{anything}, then restore the horizontal and vertical position.
10149 The argument may not contain tabs or leaders.
10151 The following is an example of a strike-through macro:
10153 @Example
10154 .de ST
10155 .nr ww \w'\\$1'
10156 \Z@@\v'-.25m'\l'\\n[ww]u'@@\\$1
10159 This is
10160 .ST "a test"
10161 an actual emergency!
10162 @endExample
10163 @endDefesc
10166 @c =====================================================================
10168 @node Drawing Requests, Traps, Page Motions, gtroff Reference
10169 @section Drawing Requests
10170 @cindex drawing requests
10171 @cindex requests for drawing
10173 @code{gtroff} provides a number of ways to draw lines and other figures
10174 on the page.  Used in combination with the page motion commands (see
10175 @ref{Page Motions}, for more info), a wide variety of figures can be
10176 drawn.  However, for complex drawings these operations can be quite
10177 cumbersome, and it may be wise to use graphic preprocessors like
10178 @code{gpic} or @code{ggrn}.  @xref{gpic}, and @ref{ggrn}, for more
10179 information.
10181 All drawing is done via escapes.
10183 @DefescList {\\l, ', @Var{l}, '}
10184 @DefescListEnd {\\l, ', @Var{l}@Var{g}, '}
10185 @cindex drawing horizontal lines (@code{\l})
10186 @cindex horizontal line, drawing (@code{\l})
10187 @cindex line, horizontal, drawing (@code{\l})
10188 Draw a line horizontally.  @var{l} is the length of the line to be
10189 drawn.  If it is positive, start the line at the current location and
10190 draw to the right; its end point is the new current location.  Negative
10191 values are handled differently: The line starts at the current location
10192 and draws to the left, but the current location doesn't move.
10194 @var{l} can also be specified absolutely (i.e.@: with a leading
10195 @samp{|}) which draws back to the beginning of the input line.
10196 Default scaling indicator is @samp{m}.
10198 @cindex underscore glyph (@code{\[ru]})
10199 @cindex glyph, underscore (@code{\[ru]})
10200 @cindex line drawing glyph
10201 @cindex glyph, for line drawing
10202 The optional second parameter@w{ }@var{g} is a glyph to draw the line
10203 with.  If this second argument is not specified, @code{gtroff} uses
10204 the underscore glyph, @code{\[ru]}.
10206 @cindex zero width space character (@code{\&})
10207 @cindex character, zero width space (@code{\&})
10208 @cindex space character, zero width (@code{\&})
10209 To separate the two arguments (to prevent @code{gtroff} from
10210 interpreting a drawing glyph as a scaling indicator if the glyph is
10211 represented by a single character) use @code{\&}.
10213 Here a small useful example:
10215 @Example
10216 .de box
10217 \[br]\\$*\[br]\l'|0\[rn]'\l'|0\[ul]'
10219 @endExample
10221 @noindent
10222 Note that this works by outputting a box rule (a vertical line), then
10223 the text given as an argument and then another box rule.  Finally, the
10224 line drawing escapes both draw from the current location to the
10225 beginning of the @emph{input} line -- this works because the line
10226 length is negative, not moving the current point.
10227 @endDefesc
10229 @DefescList {\\L, ', @Var{l}, '}
10230 @DefescListEnd {\\L, ', @Var{l}@Var{g}, '}
10231 @cindex drawing vertical lines (@code{\L})
10232 @cindex vertical line drawing (@code{\L})
10233 @cindex line, vertical, drawing (@code{\L})
10234 @cindex line drawing glyph
10235 @cindex glyph for line drawing
10236 @cindex box rule glyph (@code{\[br]})
10237 @cindex glyph, box rule (@code{\[br]})
10238 Draw vertical lines.  Its parameters are
10239 similar to the @code{\l} escape, except that the default scaling
10240 indicator is @samp{v}.  The movement is downwards for positive values,
10241 and upwards for negative values.  The default glyph is the box rule
10242 glyph, @code{\[br]}.  As with the vertical motion escapes, text
10243 processing blindly continues where the line ends.
10245 @Example
10246 This is a \L'3v'test.
10247 @endExample
10249 @noindent
10250 Here the result, produced with @code{grotty}.
10252 @Example
10253 This is a
10254           |
10255           |
10256           |test.
10257 @endExample
10258 @endDefesc
10260 @Defesc {\\D, ', command arg @dots{}, '}
10261 The @code{\D} escape provides a variety of drawing functions.
10262 Note that on character devices, only vertical and horizontal lines are
10263 supported within @code{grotty}; other devices may only support a subset
10264 of the available drawing functions.
10266 The default scaling indicator for all subcommands of @code{\D} is
10267 @samp{m} for horizontal distances and @samp{v} for vertical ones.
10268 Exceptions are @w{@code{\D'f @dots{}'}} and @w{@code{\D't @dots{}'}}
10269 which use @code{u} as the default.
10271 @table @code
10272 @item \D'l @var{dx} @var{dy}'
10273 @cindex line, drawing (@w{@code{\D'l @dots{}'}})
10274 @cindex drawing a line (@w{@code{\D'l @dots{}'}})
10275 Draw a line from the current location to the relative point specified by
10276 (@var{dx},@var{dy}).
10278 The following example is a macro for creating a box around a text string;
10279 for simplicity, the box margin is taken as a fixed value, 0.2@dmn{m}.
10281 @Example
10282 .de BOX
10283 .  nr @@wd \w'\\$1'
10284 \h'.2m'\
10285 \h'-.2m'\v'(.2m - \\n[rsb]u)'\
10286 \D'l 0 -(\\n[rst]u - \\n[rsb]u + .4m)'\
10287 \D'l (\\n[@@wd]u + .4m) 0'\
10288 \D'l 0 (\\n[rst]u - \\n[rsb]u + .4m)'\
10289 \D'l -(\\n[@@wd]u + .4m) 0'\
10290 \h'.2m'\v'-(.2m - \\n[rsb]u)'\
10291 \\$1\
10292 \h'.2m'
10294 @endExample
10296 @noindent
10297 First, the width of the string is stored in register @code{@@wd}.  Then,
10298 four lines are drawn to form a box, properly offset by the box margin.
10299 The registers @code{rst} and @code{rsb} are set by the @code{\w} escape,
10300 containing the largest height and depth of the whole string.
10302 @item \D'c @var{d}'
10303 @cindex circle, drawing (@w{@code{\D'c @dots{}'}})
10304 @cindex drawing a circle (@w{@code{\D'c @dots{}'}})
10305 Draw a circle with a diameter of@w{ }@var{d} with the leftmost point at the
10306 current position.
10308 @item \D'C @var{d}'
10309 @cindex circle, solid, drawing (@w{@code{\D'C @dots{}'}})
10310 @cindex drawing a solid circle (@w{@code{\D'C @dots{}'}})
10311 @cindex solid circle, drawing (@w{@code{\D'C @dots{}'}})
10312 Draw a solid circle with the same parameters as an outlined circle.  No
10313 outline is drawn.
10315 @item \D'e @var{x} @var{y}'
10316 @cindex drawing an ellipse (@w{@code{\D'e @dots{}'}})
10317 @cindex ellipse, drawing (@w{@code{\D'e @dots{}'}})
10318 Draw an ellipse with a horizontal diameter of @var{x} and a vertical
10319 diameter of @var{y} with the leftmost point at the current position.
10321 @item \D'E @var{x} @var{y}'
10322 @cindex ellipse, solid, drawing (@w{@code{\D'E @dots{}'}})
10323 @cindex drawing a solid ellipse (@w{@code{\D'E @dots{}'}})
10324 @cindex solid ellipse, drawing (@w{@code{\D'E @dots{}'}})
10325 Draw a solid ellipse with the same parameters as an outlined ellipse.
10326 No outline is drawn.
10328 @item \D'a @var{dx1} @var{dy1} @var{dx2} @var{dy2}'
10329 @cindex arc, drawing (@w{@code{\D'a @dots{}'}})
10330 @cindex drawing an arc (@w{@code{\D'a @dots{}'}})
10331 Draw an arc clockwise from the current location through the two
10332 specified relative locations (@var{dx1},@var{dy1}) and
10333 (@var{dx2},@var{dy2}).  The coordinates of the first point are relative
10334 to the current position, and the coordinates of the second point are
10335 relative to the first point.
10337 @item \D'~ @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
10338 @cindex drawing a spline (@w{@code{\D'~ @dots{}'}})
10339 @cindex spline, drawing (@w{@code{\D'~ @dots{}'}})
10340 Draw a spline from the current location to the relative point
10341 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}), and so on.
10343 @item \D'f @var{n}'
10344 @cindex gray shading (@w{@code{\D'f @dots{}'}})
10345 @cindex shading filled objects (@w{@code{\D'f @dots{}'}})
10346 Set the shade of gray to be used for filling solid objects to@w{
10347 }@var{n}; @var{n}@w{ }must be an integer between 0 and@w{ }1000, where 0
10348 corresponds solid white and 1000 to solid black, and values in between
10349 correspond to intermediate shades of gray.  This applies only to solid
10350 circles, solid ellipses, and solid polygons.  By default, a level of
10351 1000 is used.
10353 @item \D'p @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
10354 @cindex drawing a polygon (@w{@code{\D'p @dots{}'}})
10355 @cindex polygon, drawing (@w{@code{\D'p @dots{}'}})
10356 Draw a polygon from the current location to the relative position
10357 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}) and so on.
10358 When the specified data points are exhausted, a line is drawn back
10359 to the starting point.
10361 @item \D'P @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
10362 @cindex polygon, solid, drawing (@w{@code{\D'P @dots{}'}})
10363 @cindex drawing a solid polygon (@w{@code{\D'P @dots{}'}})
10364 @cindex solid polygon, drawing (@w{@code{\D'P @dots{}'}})
10365 Draw a solid polygon with the same parameters as an outlined polygon.
10366 No outline is drawn.
10368 Here a better variant of the box macro to fill the box with some color.
10369 Note that the box must be drawn before the text since colors in
10370 @code{gtroff} are not transparent; the filled polygon would hide the
10371 text completely.
10373 @Example
10374 .de BOX
10375 .  nr @@wd \w'\\$1'
10376 \h'.2m'\
10377 \h'-.2m'\v'(.2m - \\n[rsb]u)'\
10378 \M[lightcyan]\
10379 \D'P 0 -(\\n[rst]u - \\n[rsb]u + .4m) \
10380      (\\n[@@wd]u + .4m) 0 \
10381      0 (\\n[rst]u - \\n[rsb]u + .4m) \
10382      -(\\n[@@wd]u + .4m) 0'\
10383 \h'.2m'\v'-(.2m - \\n[rsb]u)'\
10384 \M[]\
10385 \\$1\
10386 \h'.2m'
10388 @endExample
10390 @item \D't @var{n}'
10391 @cindex line thickness (@w{@code{\D't @dots{}'}})
10392 @cindex thickness of lines (@w{@code{\D't @dots{}'}})
10393 Set the current line thickness to @var{n}@w{ }machine units.  A value of
10394 zero selects the smallest available line thickness.  A negative value
10395 makes the line thickness proportional to the current point size (this is
10396 the default behaviour of @acronym{AT&T} @code{troff}).
10397 @end table
10398 @endDefesc
10400 @xref{Graphics Commands}.
10402 @Defesc {\\b, ', string, '}
10403 @cindex pile, glyph (@code{\b})
10404 @cindex glyph pile (@code{\b})
10405 @cindex stacking glyphs (@code{\b})
10406 @dfn{Pile} a sequence of glyphs vertically, and center it vertically
10407 on the current line.  Use it to build large brackets and braces.
10409 Here an example how to create a large opening brace:
10411 @Example
10412 \b'\[lt]\[bv]\[lk]\[bv]\[lb]'
10413 @endExample
10415 @cindex @code{\b}, limitations
10416 @cindex limitations of @code{\b} escape
10417 The first glyph is on the top, the last glyph in @var{string} is
10418 at the bottom.  Note that @code{gtroff} separates the glyphs
10419 vertically by 1@dmn{m}, and the whole object is centered 0.5@dmn{m}
10420 above the current baseline; the largest glyph width is used as the
10421 width for the whole object.  This rather unflexible positioning
10422 algorithm doesn't work with @option{-Tdvi} since the bracket pieces vary
10423 in height for this device.  Instead, use the @code{eqn} preprocessor.
10425 @xref{Manipulating Spacing}, how to adjust the vertical spacing with
10426 the @code{\x} escape.
10427 @endDefesc
10430 @c =====================================================================
10432 @node Traps, Diversions, Drawing Requests, gtroff Reference
10433 @section Traps
10434 @cindex traps
10436 @dfn{Traps} are locations, which, when reached, call a specified
10437 macro.  These traps can occur at a given location on the page, at a
10438 given location in the current diversion, at a blank line,
10439 after a certain number of input lines, or at the end of input.
10441 @cindex planting a trap
10442 @cindex trap, planting
10443 Setting a trap is also called @dfn{planting}.
10444 @cindex trap, springing
10445 @cindex springing a trap
10446 It is also said that a trap is @dfn{sprung} if the associated macro
10447 is executed.
10449 @menu
10450 * Page Location Traps::
10451 * Diversion Traps::
10452 * Input Line Traps::
10453 * Blank Line Traps::
10454 * End-of-input Traps::
10455 @end menu
10457 @c ---------------------------------------------------------------------
10459 @node Page Location Traps, Diversion Traps, Traps, Traps
10460 @subsection Page Location Traps
10461 @cindex page location traps
10462 @cindex traps, page location
10464 @dfn{Page location traps} perform an action when @code{gtroff}
10465 reaches or passes a certain vertical location on the page.  Page
10466 location traps have a variety of purposes, including:
10468 @itemize
10469 @item
10470 setting headers and footers
10472 @item
10473 setting body text in multiple columns
10475 @item
10476 setting footnotes
10477 @end itemize
10479 @DefreqList {vpt, flag}
10480 @DefregListEnd {.vpt}
10481 @cindex enabling vertical position traps (@code{vpt})
10482 @cindex vertical position traps, enabling (@code{vpt})
10483 @cindex vertical position trap enable register (@code{.vpt})
10484 Enable vertical position traps if @var{flag} is non-zero, or disables
10485 them otherwise.  Vertical position traps are traps set by the @code{wh}
10486 or @code{dt} requests.  Traps set by the @code{it} request are not
10487 vertical position traps.  The parameter that controls whether vertical
10488 position traps are enabled is global.  Initially vertical position traps
10489 are enabled.  The current setting of this is available in the
10490 @code{.vpt} read-only number register.
10491 @endDefreq
10493 @Defreq {wh, dist [@Var{macro}]}
10494 Set a page location trap.  Positive values for @var{dist} set
10495 the trap relative to the top of the page; negative values set
10496 the trap relative to the bottom of the page.  Default scaling
10497 indicator is @samp{v}.
10499 @var{macro} is the name of the macro to execute when the
10500 trap is sprung.  If @var{macro} is missing, remove the first trap
10501 (if any) at @var{dist}.
10503 @cindex page headers
10504 @cindex page footers
10505 @cindex headers
10506 @cindex footers
10507 The following is a simple example of how many macro packages
10508 set headers and footers.
10510 @Example
10511 .de hd                \" Page header
10512 '  sp .5i
10513 .  tl 'Title''date'
10514 '  sp .3i
10517 .de fo                \" Page footer
10518 '  sp 1v
10519 .  tl ''%''
10520 '  bp
10523 .wh 0   hd            \" trap at top of the page
10524 .wh -1i fo            \" trap one inch from bottom
10525 @endExample
10527 A trap at or below the bottom of the page is ignored; it can be made
10528 active by either moving it up or increasing the page length so that the
10529 trap is on the page.
10531 It is possible to have more than one trap at the same location; to do so,
10532 the traps must be defined at different locations, then moved together with
10533 the @code{ch} request; otherwise the second trap would replace the first
10534 one.  Earlier defined traps hide later defined traps if moved to the same
10535 position (the many empty lines caused by the @code{bp} request are omitted):
10537 @Example
10538 .de a
10539 .  nop a
10541 .de b
10542 .  nop b
10544 .de c
10545 .  nop c
10548 .wh 1i a
10549 .wh 2i b
10550 .wh 3i c
10552     @result{} a b c
10553 @endExample
10554 @Example
10555 .ch b 1i
10556 .ch c 1i
10558     @result{} a
10559 @endExample
10560 @Example
10561 .ch a 0.5i
10563     @result{} a b
10564 @endExample
10565 @endDefreq
10567 @Defreg {.t}
10568 @cindex distance to next trap register (@code{.t})
10569 @cindex trap, distance, register (@code{.t})
10570 A read-only number register holding the distance to the next trap.
10572 If there are no traps between the current position and the bottom of the
10573 page, it contains the distance to the page bottom.  In a diversion, the
10574 distance to the page bottom is infinite (the returned value is the biggest
10575 integer which can be represented in @code{groff}) if there are no diversion
10576 traps.
10577 @endDefreg
10579 @Defreq {ch, macro dist}
10580 @cindex changing trap location (@code{ch})
10581 @cindex trap, changing location (@code{ch})
10582 Change the location of a trap.
10583 The first argument is the name of the macro to be invoked at
10584 the trap, and the second argument is the new location for the trap
10585 (note that the parameters are specified the opposite of the @code{wh}
10586 request).  This is useful for building up footnotes in a diversion to
10587 allow more space at the bottom of the page for them.
10589 Default scaling indicator for @var{dist} is @samp{v}.  If @var{dist}
10590 is missing, the trap is removed.
10592 @c XXX
10594 @ignore
10595 @Example
10596 ... (simplified) footnote example ...
10597 @endExample
10598 @end ignore
10599 @endDefreq
10601 @Defreg {.ne}
10602 The read-only number register @code{.ne} contains the amount of space
10603 that was needed in the last @code{ne} request that caused a trap to be
10604 sprung.  Useful in conjunction with the @code{.trunc} register.
10605 @xref{Page Control}, for more information.
10606 @endDefreg
10608 @Defreg {.trunc}
10609 @cindex @code{ne} request, and the @code{.trunc} register
10610 @cindex truncated vertical space register (@code{.trunc})
10611 A read-only register containing the amount of vertical space truncated
10612 by the most recently sprung vertical position trap, or, if the trap was
10613 sprung by an @code{ne} request, minus the amount of vertical motion
10614 produced by the @code{ne} request.  In other words, at the point a trap
10615 is sprung, it represents the difference of what the vertical position
10616 would have been but for the trap, and what the vertical position
10617 actually is.
10618 @endDefreg
10620 @c ---------------------------------------------------------------------
10622 @node Diversion Traps, Input Line Traps, Page Location Traps, Traps
10623 @subsection Diversion Traps
10624 @cindex diversion traps
10625 @cindex traps, diversion
10627 @Defreq {dt, dist macro}
10628 @cindex @code{.t} register, and diversions
10629 @cindex setting diversion trap (@code{dt})
10630 @cindex diversion trap, setting (@code{dt})
10631 @cindex trap, diversion, setting (@code{dt})
10632 Set a trap @emph{within} a diversion.
10633 @var{dist} is the location of the trap
10634 (identical to the @code{.wh} request; default scaling indicator is
10635 @samp{v}) and @var{macro} is the name of the macro to be invoked.  The
10636 number register @code{.t} still works within diversions.
10637 @xref{Diversions}, for more information.
10638 @endDefreq
10640 @c ---------------------------------------------------------------------
10642 @node Input Line Traps, Blank Line Traps, Diversion Traps, Traps
10643 @subsection Input Line Traps
10644 @cindex input line traps
10645 @cindex traps, input line
10647 @DefreqList {it, n macro}
10648 @DefreqItem {itc, n macro}
10649 @cindex setting input line trap (@code{it})
10650 @cindex input line trap, setting (@code{it})
10651 @cindex trap, input line, setting (@code{it})
10652 Set an input line trap.
10653 @var{n}@w{ }is the number of lines of input which may be read before
10654 springing the trap, @var{macro} is the macro to be invoked.
10655 Request lines are not counted as input lines.
10657 For example, one possible use is to have a macro which prints the
10658 next @var{n}@w{ }lines in a bold font.
10660 @Example
10661 .de B
10662 .  it \\$1 B-end
10663 .  ft B
10666 .de B-end
10667 .  ft R
10669 @endExample
10671 @cindex input line traps and interrupted lines (@code{itc})
10672 @cindex interrupted lines and input line traps (@code{itc})
10673 @cindex traps, input line, and interrupted lines (@code{itc})
10674 @cindex lines, interrupted, and input line traps (@code{itc})
10675 The @code{itc} request is identical,
10676 except that a line interrupted with @code{\c}
10677 counts as one input line.
10679 Both requests are associated with the current environment
10680 (@pxref{Environments}); switching to another environment disables the
10681 current input trap, and going back reactivates it, restoring the number
10682 of already processed lines.
10683 @endDefreq
10685 @c ---------------------------------------------------------------------
10687 @node Blank Line Traps, End-of-input Traps, Input Line Traps, Traps
10688 @subsection Blank Line Traps
10689 @cindex blank line traps
10690 @cindex traps, blank line
10692 @Defreq {blm, macro}
10693 @cindex blank line macro (@code{blm})
10694 Set a blank line trap.
10695 @code{gtroff} executes @var{macro} when it encounters a blank line in
10696 the input file.
10697 @endDefreq
10699 @c ---------------------------------------------------------------------
10701 @node End-of-input Traps,  , Blank Line Traps, Traps
10702 @subsection End-of-input Traps
10703 @cindex end-of-input traps
10704 @cindex traps, end-of-input
10706 @Defreq {em, macro}
10707 @cindex setting end-of-input trap (@code{em})
10708 @cindex end-of-input trap, setting (@code{em})
10709 @cindex trap, end-of-input, setting (@code{em})
10710 @cindex end-of-input macro (@code{em})
10711 @cindex macro, end-of-input (@code{em})
10712 Set a trap at the end of input.  @var{macro} is executed after the
10713 last line of the input file has been processed.
10715 For example, if the document had to have a section at the bottom of the
10716 last page for someone to approve it, the @code{em} request could be
10717 used.
10719 @Example
10720 .de approval
10721 .  ne 5v
10722 .  sp |(\\n[.t] - 6v)
10723 .  in +4i
10724 .  lc _
10725 .  br
10726 Approved:\t\a
10727 .  sp
10728 Date:\t\t\a
10731 .em approval
10732 @endExample
10733 @endDefreq
10736 @c =====================================================================
10738 @node Diversions, Environments, Traps, gtroff Reference
10739 @section Diversions
10740 @cindex diversions
10742 In @code{gtroff} it is possible to @dfn{divert} text into a named
10743 storage area.  Due to the similarity to defining macros it is sometimes
10744 said to be stored in a macro.  This is used for saving text for output
10745 at a later time, which is useful for keeping blocks of text on the same
10746 page, footnotes, tables of contents, and indices.
10748 @cindex top-level diversion
10749 @cindex diversion, top-level
10750 For orthogonality it is said that @code{gtroff} is in the @dfn{top-level
10751 diversion} if no diversion is active (i.e., the data is diverted to the
10752 output device).
10754 @DefreqList {di, macro}
10755 @DefreqListEnd {da, macro}
10756 @cindex beginning diversion (@code{di})
10757 @cindex diversion, beginning (@code{di})
10758 @cindex ending diversion (@code{di})
10759 @cindex diversion, ending (@code{di})
10760 @cindex appending to a diversion (@code{da})
10761 @cindex diversion, appending (@code{da})
10762 Begin a diversion.  Like the @code{de}
10763 request, it takes an argument of a macro name to divert subsequent text
10764 into.  The @code{da} macro appends to an existing diversion.
10766 @code{di} or @code{da} without an argument ends the diversion.
10767 @endDefreq
10769 @DefreqList {box, macro}
10770 @DefreqListEnd {boxa, macro}
10771 Begin (or appends to) a diversion like the
10772 @code{di} and @code{da} requests.
10773 The difference is that @code{box} and @code{boxa}
10774 do not include a partially-filled line in the diversion.
10776 Compare this:
10778 @Example
10779 Before the box.
10780 .box xxx
10781 In the box.
10783 .box
10784 After the box.
10786     @result{} Before the box.  After the box.
10787 .xxx
10788     @result{} In the box.
10789 @endExample
10791 @noindent
10792 with this:
10794 @Example
10795 Before the diversion.
10796 .di yyy
10797 In the diversion.
10800 After the diversion.
10802     @result{} After the diversion.
10803 .yyy
10804     @result{} Before the diversion.  In the diversion.
10805 @endExample
10807 @code{box} or @code{boxa} without an argument ends the diversion.
10808 @endDefreq
10810 @DefregList {.z}
10811 @DefregListEnd {.d}
10812 @cindex @code{nl} register, and @code{.d}
10813 @cindex nested diversions
10814 @cindex diversion, nested
10815 @cindex diversion name register (@code{.z})
10816 @cindex vertical position in diversion register (@code{.d})
10817 @cindex position, vertical, in diversion, register (@code{.d})
10818 @cindex diversion, vertical position in, register (@code{.d})
10819 Diversions may be nested.  The read-only number register @code{.z}
10820 contains the name of the current diversion (this is a string-valued
10821 register).  The read-only number register @code{.d} contains the current
10822 vertical place in the diversion.  If not in a diversion it is the same
10823 as the register @code{nl}.
10824 @endDefreg
10826 @Defreg {.h}
10827 @cindex high-water mark register (@code{.h})
10828 @cindex mark, high-water, register (@code{.h})
10829 @cindex position of lowest text line (@code{.h})
10830 @cindex text line, position of lowest (@code{.h})
10831 The @dfn{high-water mark} on the current page.  It corresponds to the
10832 text baseline of the lowest line on the page.  This is a read-only
10833 register.
10835 @Example
10836 .tm .h==\n[.h], nl==\n[nl]
10837     @result{} .h==0, nl==-1
10838 This is a test.
10840 .sp 2
10841 .tm .h==\n[.h], nl==\n[nl]
10842     @result{} .h==40, nl==120
10843 @endExample
10845 @cindex @code{.h} register, difference to @code{nl}
10846 @cindex @code{nl} register, difference to @code{.h}
10847 @noindent
10848 As can be seen in the previous example, empty lines are not considered
10849 in the return value of the @code{.h} register.
10850 @endDefreg
10852 @DefregList {dn}
10853 @DefregListEnd {dl}
10854 After completing a diversion, the read-write number registers @code{dn}
10855 and @code{dl} contain the vertical and horizontal size of the diversion.
10857 @Example
10858 .\" Center text both horizontally & vertically
10860 .\" Enclose macro definitions in .eo and .ec
10861 .\" to avoid the doubling of the backslash
10863 .\" macro .(c starts centering mode
10864 .de (c
10865 .  br
10866 .  ev (c
10867 .  evc 0
10868 .  in 0
10869 .  nf
10870 .  di @@c
10872 @endExample
10873 @Example
10874 .\" macro .)c terminates centering mode
10875 .de )c
10876 .  br
10877 .  ev
10878 .  di
10879 .  nr @@s (((\n[.t]u - \n[dn]u) / 2u) - 1v)
10880 .  sp \n[@@s]u
10881 .  ce 1000
10882 .  @@c
10883 .  ce 0
10884 .  sp \n[@@s]u
10885 .  br
10886 .  fi
10887 .  rr @@s
10888 .  rm @@s
10889 .  rm @@c
10891 .\" End of macro definitions, restore escape mechanism
10893 @endExample
10894 @endDefreg
10896 @DefescList {\\!, , , }
10897 @DefescListEnd {\\?, , @Var{anything}, \\?}
10898 @cindex transparent output (@code{\!}, @code{\?})
10899 @cindex output, transparent (@code{\!}, @code{\?})
10900 Prevent requests, macros, and escapes from being
10901 interpreted when read into a diversion.  This takes the given text
10902 and @dfn{transparently} embeds it into the diversion.  This is useful for
10903 macros which shouldn't be invoked until the diverted text is actually
10904 output.
10906 The @code{\!} escape transparently embeds text up to
10907 and including the end of the line.
10908 The @code{\?} escape transparently embeds text until the next
10909 occurrence of the @code{\?} escape.  For example:
10911 @Example
10912 \?@var{anything}\?
10913 @endExample
10915 @noindent
10916 @var{anything} may not contain newlines; use @code{\!}  to embed
10917 newlines in a diversion.  The escape sequence @code{\?} is also
10918 recognized in copy mode and turned into a single internal code; it is
10919 this code that terminates @var{anything}.  Thus the following example
10920 prints@w{ }4.
10922 @Example
10923 .nr x 1
10925 .di d
10926 \?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
10928 .nr x 2
10929 .di e
10932 .nr x 3
10933 .di f
10936 .nr x 4
10938 @endExample
10940 Both escapes read the data in copy mode.
10942 @cindex @code{\!}, in top-level diversion
10943 @cindex top-level diversion, and @code{\!}
10944 @cindex diversion, top-level, and @code{\!}
10945 If @code{\!} is used in the top-level diversion, its argument is
10946 directly embedded into the @code{gtroff} intermediate output.  This can
10947 be used for example to control a postprocessor which processes the data
10948 before it is sent to the device driver.
10950 @cindex @code{\?}, in top-level diversion
10951 @cindex top-level diversion, and @code{\?}
10952 @cindex diversion, top-level, and @code{\?}
10953 The @code{\?} escape used in the top-level diversion produces no output
10954 at all; its argument is simply ignored.
10955 @endDefesc
10957 @cindex @code{\!}, and @code{output}
10958 @cindex @code{output} request, and @code{\!}
10959 @Defreq {output, string}
10960 Emit @var{string} directly to the @code{gtroff} intermediate output
10961 (subject to copy-mode interpretation);  this is similar to @code{\!} used
10962 at the top level.  An initial double quote in @var{string} is stripped off
10963 to allow initial blanks.
10965 This request can't be used before the first page has started -- if you get
10966 an error, simply insert @code{.br} before the @code{output} request.
10968 Without argument, @code{output} is ignored.
10970 Use with caution!  It is normally only needed for mark-up used by a
10971 postprocessor which does something with the output before sending it to
10972 the output device, filtering out @code{string} again.
10973 @endDefreq
10975 @Defreq {asciify, div}
10976 @cindex unformatting diversions (@code{asciify})
10977 @cindex diversion, unformatting (@code{asciify})
10978 @cindex @code{trin} request, and @code{asciify}
10979 @dfn{Unformat} the diversion specified by @var{div}
10980 in such a way that @acronym{ASCII} characters, characters translated with
10981 the @code{trin} request, space characters, and some escape sequences that
10982 were formatted and diverted are treated like ordinary input
10983 characters when the diversion is reread.  It can be also used for gross
10984 hacks; for example, the following sets register@w{ }@code{n} to@w{ }1.
10986 @Example
10987 .tr @@.
10988 .di x
10989 @@nr n 1
10992 .tr @@@@
10993 .asciify x
10995 @endExample
10997 @xref{Copy-in Mode}.
10998 @endDefreq
11000 @Defreq {unformat, div}
11001 Like @code{asciify}, unformat the specified diversion.
11002 However, @code{unformat} only unformats spaces and tabs
11003 between words.
11004 Unformatted tabs are treated as input tokens,
11005 and spaces are stretchable again.
11007 The vertical size of lines is not preserved; glyph information (font,
11008 font size, space width, etc.)@: is retained.
11009 @endDefreq
11012 @c =====================================================================
11014 @node Environments, Suppressing output, Diversions, gtroff Reference
11015 @section Environments
11016 @cindex environments
11018 It happens frequently that some text should be printed in a certain
11019 format regardless of what may be in effect at the time, for example, in
11020 a trap invoked macro to print headers and footers.  To solve this
11021 @code{gtroff} processes text in @dfn{environments}.  An
11022 environment contains most of the parameters that control text
11023 processing.  It is possible to switch amongst these environments; by
11024 default @code{gtroff} processes text in environment@w{ }0.  The
11025 following is the information kept in an environment.
11027 @itemize @bullet
11028 @item
11029 font parameters (size, family, style, glyph height and slant, space
11030 and sentence space size)
11032 @item
11033 page parameters (line length, title length, vertical spacing,
11034 line spacing, indentation, line numbering, centering, right-justifying,
11035 underlining, hyphenation data)
11037 @item
11038 fill and adjust mode
11040 @item
11041 tab stops, tab and leader characters, escape character,
11042 no-break and hyphen indicators, margin character data
11044 @item
11045 partially collected lines
11047 @item
11048 input traps
11050 @item
11051 drawing and fill colours
11052 @end itemize
11054 These environments may be given arbitrary names (see @ref{Identifiers},
11055 for more info).  Old versions of @code{troff} only had environments
11056 named @samp{0}, @samp{1}, and @samp{2}.
11058 @DefreqList {ev, [@Var{env}]}
11059 @DefregListEnd {.ev}
11060 @cindex switching environments (@code{ev})
11061 @cindex environment, switching (@code{ev})
11062 @cindex environment number/name register (@code{.ev})
11063 Switch to another environment.  The argument @var{env} is the name of
11064 the environment to switch to.  With no argument, @code{gtroff} switches
11065 back to the previous environment.  There is no limit on the number of
11066 named environments; they are created the first time that they are
11067 referenced.  The @code{.ev} read-only register contains the name or
11068 number of the current environment.  This is a string-valued register.
11070 Note that a call to @code{ev} (with argument) pushes the previously
11071 active environment onto a stack.  If, say, environments @samp{foo},
11072 @samp{bar}, and @samp{zap} are called (in that order), the first
11073 @code{ev} request without parameter switches back to environment
11074 @samp{bar} (which is popped off the stack), and a second call
11075 switches back to environment @samp{foo}.
11077 Here is an example:
11079 @Example
11080 .ev footnote-env
11081 .fam N
11082 .ps 6
11083 .vs 8
11084 .ll -.5i
11089 .ev footnote-env
11090 \(dg Note the large, friendly letters.
11092 @endExample
11093 @endDefreq
11095 @Defreq {evc, env}
11096 @cindex copying environment (@code{evc})
11097 @cindex environment, copying (@code{evc})
11098 Copy the environment @var{env} into the current environment.
11100 The following environment data is not copied:
11102 @itemize @bullet
11103 @item
11104 Partially filled lines.
11106 @item
11107 The status whether the previous line was interrupted.
11109 @item
11110 The number of lines still to center, or to right-justify, or to underline
11111 (with or without underlined spaces); they are set to zero.
11113 @item
11114 The status whether a temporary indent is active.
11116 @item
11117 Input traps and its associated data.
11119 @item
11120 Line numbering mode is disabled; it can be reactivated with
11121 @w{@samp{.nm +0}}.
11123 @item
11124 The number of consecutive hyphenated lines (set to zero).
11125 @end itemize
11126 @endDefreq
11128 @DefregList {.cht}
11129 @DefregItem {.cdp}
11130 @DefregListEnd {.csk}
11131 @cindex environment, last glyph
11132 The @code{\n[.cht]} register contains the
11133 maximum extent (above the baseline)
11134 of the last glyph added to the current environment.
11136 The @code{\n[.cdp]} register contains the
11137 maximum extent (below the baseline)
11138 of the last glyph added to the current environment.
11140 The @code{\n[.csk]} register contains the
11141 @dfn{skew} (how far to the right of the glyph's center
11142 that @code{gtroff} shold place an accent)
11143 of the last glyph added to the current environment.
11144 @endDefreg
11147 @c =====================================================================
11149 @node Suppressing output, Colors, Environments, gtroff Reference
11150 @section Suppressing output
11152 @Defesc {\\O, , num, }
11153 @cindex suppressing output (@code{\O})
11154 @cindex output, suppressing (@code{\O})
11155 Disable or enable output depending on the value of @var{num}:
11157 @table @samp
11158 @item \O0
11159 Disable any glyphs from being emitted to the device driver, provided that
11160 the escape occurs at the outer level (see @code{\O[3]} and @code{\O[4]}).
11161 Motion is not suppressed so effectively @code{\O[0]} means @emph{pen up}.
11163 @item \O1
11164 Enable output of glyphs, provided that the escape occurs at the outer
11165 level.
11166 @end table
11168 @vindex opminx
11169 @vindex opminy
11170 @vindex opmaxx
11171 @vindex opmaxy
11172 @code{\O0} and @code{\O1} also reset the four registers @samp{opminx},
11173 @samp{opminy}, @samp{opmaxx}, and @samp{opmaxy} to @minus{}1.
11174 @xref{Register Index}.  These four registers mark the top left and
11175 bottom right hand corners of a box which encompasses all written glyphs.
11177 For example the input text:
11179 @Example
11180 Hello \O[0]world \O[1]this is a test.
11181 @endExample
11183 @noindent
11184 produces the following output:
11186 @Example
11187 Hello       this is a test.
11188 @endExample
11190 @table @samp
11191 @item \O2
11192 Provided that the escape occurs at the outer level, enable output of
11193 glyphs and also write out to @code{stderr} the page number and four
11194 registers encompassing the glyphs previously written since the last call
11195 to @code{\O}.
11197 @item \O3
11198 Begin a nesting level.  At start-up, @code{gtroff} is at outer level.
11200 @item \O4
11201 End a nesting level.
11203 @item \O[5@var{P}@var{filename}]
11204 This escape is @code{grohtml} specific.  Provided that this escape
11205 occurs at the outer nesting level write the @code{filename} to
11206 @code{stderr}.  The position of the image, @var{P}, must be specified
11207 and must be one of @code{l}, @code{r}, @code{c}, or@w{ }@code{i} (left,
11208 right, centered, inline).  @var{filename} will be associated with the
11209 production of the next inline image.
11210 @end table
11211 @endDefesc
11213 @c =====================================================================
11215 @node Colors, I/O, Suppressing output, gtroff Reference
11216 @section Colors
11217 @cindex colors
11219 @DefreqList {color, [@Var{n}]}
11220 @DefregListEnd {.color}
11221 If @var{n} is missing or non-zero, activate colors (this is the default);
11222 otherwise, turn it off.
11224 The read-only number register @code{.color} is@w{ }1 if colors are active,
11225 0@w{ }otherwise.
11227 Internally, @code{color} sets a global flag; it does not produce a token.
11228 Similar to the @code{cp} request, you should use it at the beginning of
11229 your document to control color output.
11231 Colors can be also turned off with the @option{-c} command line option.
11232 @endDefreq
11234 @Defreq {defcolor, ident scheme color_components}
11235 Define color with name @var{ident}.  @var{scheme} can be one of  the
11236 following values: @code{rgb} (three components), @code{cym} (three
11237 components), @code{cmyk} (four components), and @code{gray} or
11238 @code{grey} (one component).
11240 @cindex default color
11241 @cindex color, default
11242 Color components can be given either as a hexadecimal string or as
11243 positive decimal integers in the range 0--65535.  A hexadecimal string
11244 contains all color components concatenated.  It must start with either
11245 @code{#} or @code{##}; the former specifies hex values in the range
11246 0--255 (which are internally multiplied by@w{ }257), the latter in the
11247 range 0--65535.  Examples: @code{#FFC0CB} (pink), @code{##ffff0000ffff}
11248 (magenta).  The default color name @c{default} can't be redefined; its
11249 value is device-specific (usually black).  It is possible that the
11250 default color for @code{\m} and @code{\M} is not identical.
11252 @cindex @code{f} unit, and colors
11253 @cindex unit, @code{f}, and colors
11254 A new scaling indicator@w{ }@code{f} has been introduced which multiplies
11255 its value by 65536; this makes it convenient to specify color components
11256 as fractions in the range 0 to@w{ }1 (1f equals 65536u).  Example:
11258 @Example
11259 .defcolor darkgreen rgb 0.1f 0.5f 0.2f
11260 @endExample
11262 Note that @code{f} is the default scaling indicator for the
11263 @code{defcolor} request, thus the above statement is equivalent to
11265 @Example
11266 .defcolor darkgreen rgb 0.1 0.5 0.2
11267 @endExample
11268 @endDefreq
11270 @DefescList {\\m, , c, }
11271 @DefescItem {\\m, @lparen{}, co, }
11272 @DefescListEnd {\\m, @lbrack{}, color, @rbrack}
11273 Set drawing color.  The following example shows how to turn the next four
11274 words red.
11276 @Example
11277 \m[red]these are in red\m[] and these words are in black.
11278 @endExample
11280 The escape @code{\m[]} returns to the previous color.
11282 The drawing color is associated with the current environment
11283 (@pxref{Environments}).
11284 @endDefesc
11286 @DefescList {\\M, , c, }
11287 @DefescItem {\\M, @lparen{}, co, }
11288 @DefescListEnd {\\M, @lbrack{}, color, @rbrack}
11289 Set background color for filled objects drawn with the
11290 @code{\D'@dots{}'} commands.
11292 A red ellipse can be created with the following code:
11294 @Example
11295 \M[red]\h'0.5i'\D'E 2i 1i'\M[]
11296 @endExample
11298 The escape @code{\M[]} returns to the previous fill color.
11300 The fill color is associated with the current environment
11301 (@pxref{Environments}).
11302 @endDefesc
11305 @c =====================================================================
11307 @node I/O, Postprocessor Access, Colors, gtroff Reference
11308 @section I/O
11309 @cindex i/o
11310 @cindex input and output requests
11311 @cindex requests for input and output
11312 @cindex output and input requests
11314 @code{gtroff} has several requests for including files:
11316 @Defreq {so, file}
11317 @cindex including a file (@code{so})
11318 @cindex file, inclusion (@code{so})
11319 Read in the specified @var{file} and
11320 includes it in place of the @code{so} request.  This is quite useful for
11321 large documents, e.g.@: keeping each chapter in a separate file.
11322 @xref{gsoelim}, for more information.
11324 Since @code{gtroff} replaces the @code{so} request with the contents
11325 of @code{file}, it makes a difference whether the data is terminated with
11326 a newline or not: Assuming that file @file{xxx} contains the word
11327 @samp{foo} without a final newline, this
11329 @Example
11330 This is
11331 .so xxx
11333 @endExample
11335 @noindent
11336 yields @samp{This is foobar}.
11337 @endDefreq
11339 @Defreq {pso, command}
11340 Read the standard output from the specified @var{command}
11341 and includes it in place of the @code{pso} request.
11343 @cindex safer mode
11344 @cindex mode, safer
11345 @cindex unsafe mode
11346 @cindex mode, unsafe
11347 This request causes an error if used in safer mode (which is the default).
11348 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
11349 mode.
11351 The comment regarding a final newline for the @code{so} request is valid
11352 for @code{pso} also.
11353 @endDefreq
11355 @Defreq {mso, file}
11356 Identical to the @code{so} request except that @code{gtroff} searches for
11357 the specified @var{file} in the same directories as macro files for the
11358 the @option{-m} command line option.  If the file name to be included
11359 has the form @file{@var{name}.tmac} and it isn't found, @code{mso} tries
11360 to include @file{tmac.@var{name}} and vice versa.
11361 @endDefreq
11363 @DefreqList {trf, file}
11364 @DefreqListEnd {cf, file}
11365 @cindex transparent output (@code{cf}, @code{trf})
11366 @cindex output, transparent (@code{cf}, @code{trf})
11367 Transparently output the contents of @var{file}.  Each line is output
11368 as if it were preceded by @code{\!}; however, the lines are not subject
11369 to copy mode interpretation.  If the file does not end with a newline,
11370 then a newline is added (@code{trf} only).  For example, to define a
11371 macro@w{ }@code{x} containing the contents of file@w{ }@file{f}, use
11373 @Example
11374 .di x
11375 .trf f
11377 @endExample
11379 Both @code{trf} and @code{cf}, when used in a diversion,
11380 embeds an object in the diversion which, when reread, causes the
11381 contents of @var{file} to be transparently copied through to the
11382 output.  In @acronym{UNIX} @code{troff}, the contents of @var{file}
11383 is immediately copied through to the output regardless of whether there
11384 is a current diversion; this behaviour is so anomalous that it must be
11385 considered a bug.
11387 @cindex @code{trf} request, and invalid characters
11388 @cindex characters, invalid for @code{trf} request
11389 @cindex invalid characters for @code{trf} request
11390 While @code{cf} copies the contents of @var{file} completely unprocessed,
11391 @code{trf} disallows characters such as NUL that are not valid
11392 @code{gtroff} input characters (@pxref{Identifiers}).
11394 Both requests cause a line break.
11395 @endDefreq
11397 @Defreq {nx, [@Var{file}]}
11398 @cindex processing next file (@code{nx})
11399 @cindex file, processing next (@code{nx})
11400 @cindex next file, processing (@code{nx})
11401 Force @code{gtroff} to continue processing of
11402 the file specified as an argument.  If no argument is given, immediately
11403 jump to the end of file.
11404 @endDefreq
11406 @Defreq {rd, [@Var{prompt} [@Var{arg1} @Var{arg2} @dots{}]]}
11407 @cindex reading from standard input (@code{rd})
11408 @cindex standard input, reading from (@code{rd})
11409 @cindex input, standard, reading from (@code{rd})
11410 Read from standard input, and include what is read as though it
11411 were part of the input file.  Text is read until a blank line
11412 is encountered.
11414 If standard input is a TTY input device (keyboard), write @var{prompt}
11415 to standard error, followed by a colon (or send BEL for a beep if no
11416 argument is given).
11418 Arguments after @var{prompt} are available for the input.  For example,
11419 the line
11421 @Example
11422 .rd data foo bar
11423 @endExample
11425 with the input @w{@samp{This is \$2.}} prints
11427 @Example
11428 This is bar.
11429 @endExample
11430 @endDefreq
11432 @cindex form letters
11433 @cindex letters, form
11434 Using the @code{nx} and @code{rd} requests,
11435 it is easy to set up form letters.  The form
11436 letter template is constructed like this, putting the following lines
11437 into a file called @file{repeat.let}:
11439 @Example
11441 \*(td
11442 .sp 2
11448 Body of letter.
11450 .nx repeat.let
11451 @endExample
11453 @cindex @code{ex} request, used with @code{nx} and @code{rd}
11454 @noindent
11455 When this is run, a file containing the following lines should be
11456 redirected in.  Note that requests included in this file are executed
11457 as though they were part of the form letter.  The last block of input
11458 is the @code{ex} request which tells groff to stop processing.  If
11459 this was not there, groff would not know when to stop.
11461 @Example
11462 Trent A. Fisher
11463 708 NW 19th Av., #202
11464 Portland, OR  97209
11466 Dear Trent,
11468 Len Adollar
11469 4315 Sierra Vista
11470 San Diego, CA  92103
11472 Dear Mr. Adollar,
11475 @endExample
11477 @Defreq {pi, pipe}
11478 Pipe the output of @code{gtroff} to the shell command(s)
11479 specified by @var{pipe}.  This request must occur before
11480 @code{gtroff} has a chance to print anything.
11482 @cindex safer mode
11483 @cindex mode, safer
11484 @cindex unsafe mode
11485 @cindex mode, unsafe
11486 @code{pi} causes an error if used in safer mode (which is the default).
11487 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
11488 mode.
11490 Multiple calls to @code{pi} are allowed, acting as a chain.  For example,
11492 @Example
11493 .pi foo
11494 .pi bar
11496 @endExample
11498 is the same as @w{@samp{.pi foo | bar}}.
11500 @cindex @code{groff}, and @code{pi} request
11501 @cindex @code{pi} request, and @code{groff}
11502 Note that the intermediate output format of @code{gtroff} is piped to
11503 the specified commands.  Consequently, calling @code{groff} without the
11504 @option{-Z} option normally causes a fatal error.
11505 @endDefreq
11507 @DefreqList {sy, cmds}
11508 @DefregListEnd {systat}
11509 Execute the shell command(s) specified by @var{cmds}.  The output is not
11510 saved anyplace, so it is up to the user to do so.
11512 @cindex safer mode
11513 @cindex mode, safer
11514 @cindex unsafe mode
11515 @cindex mode, unsafe
11516 This request causes an error if used in safer mode (which is the default).
11517 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
11518 mode.
11520 For example, the following code fragment introduces the current time into a
11521 document:
11523 @cindex time, current
11524 @cindex current time
11525 @pindex perl
11526 @Example
11527 .sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
11528              (localtime(time))[2,1,0]' > /tmp/x\n[$$]
11529 .so /tmp/x\n[$$]
11530 .sy rm /tmp/x\n[$$]
11531 \nH:\nM:\nS
11532 @endExample
11534 @noindent
11535 Note that this works by having the @code{perl} script (run by @code{sy})
11536 print out the @code{nr} requests which set the number registers
11537 @code{H}, @code{M}, and @code{S}, and then reads those commands in with
11538 the @code{so} request.
11540 For most practical purposes, the number registers @code{seconds},
11541 @code{minutes}, and @code{hours} which are initialized at start-up of
11542 @code{gtroff} should be sufficient.  Use the @code{af} request to get a
11543 formatted output:
11545 @Example
11546 .af hours 00
11547 .af minutes 00
11548 .af seconds 00
11549 \n[hours]:\n[minutes]:\n[seconds]
11550 @endExample
11552 @cindex @code{system()} return value register (@code{systat})
11553 The @code{systat} read-write number register contains the return value
11554 of the @code{system()} function executed by the last @code{sy} request.
11555 @endDefreq
11557 @DefreqList {open, stream file}
11558 @DefreqListEnd {opena, stream file}
11559 @cindex opening file (@code{open})
11560 @cindex file, opening (@code{open})
11561 @cindex appending to a file (@code{opena})
11562 @cindex file, appending to (@code{opena})
11563 Open the specified @var{file} for writing and
11564 associates the specified @var{stream} with it.
11566 The @code{opena} request is like @code{open}, but if the file exists,
11567 append to it instead of truncating it.
11569 @cindex safer mode
11570 @cindex mode, safer
11571 @cindex unsafe mode
11572 @cindex mode, unsafe
11573 Both @code{open} and @code{opena} cause an error if used in safer mode
11574 (which is the default).  Use @code{groff}'s or @code{troff}'s @option{-U}
11575 option to activate unsafe mode.
11576 @endDefreq
11578 @DefreqList {write, stream data}
11579 @DefreqListEnd {writec, stream data}
11580 @cindex copy-in mode, and @code{write} requests
11581 @cindex mode, copy-in, and @code{write} requests
11582 @cindex writing to file (@code{write})
11583 @cindex file, writing to (@code{write})
11584 Write to the file associated with the specified @var{stream}.
11585 The stream must previously have
11586 been the subject of an open request.  The remainder of the line is
11587 interpreted as the @code{ds} request reads its second argument: A
11588 leading @samp{"} is stripped, and it is read in copy-in mode.
11590 The @code{writec} request is like @code{write}, but only
11591 @code{write} appends a newline to the data.
11592 @endDefreq
11594 @Defreq {writem, stream xx}
11595 @cindex @code{asciify} request, and @code{writem}
11596 Write the contents of the macro or string @var{xx}
11597 to the file associated with the specified @var{stream}.
11599 @var{xx} is read in copy mode, i.e., already formatted elements are
11600 ignored.  Consequently, diversions must be unformatted with the
11601 @code{asciify} request before calling @code{writem}.  Usually, this
11602 means a loss of information.
11603 @endDefreq
11605 @Defreq {close, stream}
11606 @cindex closing file (@code{close})
11607 @cindex file, closing (@code{close})
11608 Close the specified @var{stream};
11609 the stream is no longer an acceptable argument to the
11610 @code{write} request.
11612 Here a simple macro to write an index entry.
11614 @Example
11615 .open idx test.idx
11617 .de IX
11618 .  write idx \\n[%] \\$*
11621 .IX test entry
11623 .close idx
11624 @endExample
11625 @endDefreq
11627 @DefescList {\\V, , e, }
11628 @DefescItem {\\V, @lparen{}, ev, }
11629 @DefescListEnd {\\V, @lbrack{}, env, @rbrack}
11630 Interpolate the contents of the specified environment variable
11631 @var{env} (one-character name@w{ }@var{e}, two-character name @var{ev})
11632 as returned by the function @code{getenv}.  @code{\V} is interpreted
11633 in copy-in mode.
11634 @endDefesc
11637 @c =====================================================================
11639 @node Postprocessor Access, Miscellaneous, I/O, gtroff Reference
11640 @section Postprocessor Access
11641 @cindex postprocessor access
11642 @cindex access of postprocessor
11644 There are two escapes which give information directly to the
11645 postprocessor.  This is particularly useful for embedding
11646 @sc{PostScript} into the final document.
11648 @Defesc {\\X, ', xxx, '}
11649 Embeds its argument into the @code{gtroff}
11650 output preceded with @w{@samp{x X}}.
11652 @cindex @code{\&}, in @code{\X}
11653 @cindex @code{\)}, in @code{\X}
11654 @cindex @code{\%}, in @code{\X}
11655 @ifnotinfo
11656 @cindex @code{\:}, in @code{\X}
11657 @end ifnotinfo
11658 @ifinfo
11659 @cindex @code{\@r{<colon>}}, in @code{\X}
11660 @end ifinfo
11661 The escapes @code{\&}, @code{\)}, @code{\%}, and @code{\:} are ignored
11662 within @code{\X}, @w{@samp{\ }} and @code{\~} are converted to single
11663 space characters.  All other escapes (except @code{\\} which produces a
11664 backslash) cause an error.
11666 @kindex use_charnames_in_special
11667 @pindex DESC@r{, and @code{use_charnames_in_special}}
11668 @cindex @code{\X}, and special characters
11669 If the @samp{use_charnames_in_special} keyword is set in the @file{DESC}
11670 file, special characters no longer cause an error; the name @var{xx} is
11671 represented as @samp{\(@var{xx})} in the @w{@samp{x X}} output command.
11672 Additionally, the backslash is represented as @code{\\}.
11674 This mechanism is currently used by @code{grohtml} only.
11675 @endDefesc
11677 @DefescList {\\Y, , n, }
11678 @DefescItem {\\Y, @lparen{}, nm, }
11679 @DefescListEnd {\\Y, @lbrack{}, name, @rbrack}
11680 This is approximately equivalent to @samp{\X'\*[@var{name}]'}
11681 (one-character name@w{ }@var{n}, two-character name @var{nm}).
11682 However, the contents of the string or macro @var{name} are not
11683 interpreted; also it is permitted for @var{name} to have been defined
11684 as a macro and thus contain newlines (it is not permitted for the
11685 argument to @code{\X} to contain newlines).  The inclusion of
11686 newlines requires an extension to the @acronym{UNIX} @code{troff}
11687 output format, and confuses drivers that do not know about this
11688 extension (@pxref{Device Control Commands}).
11689 @endDefesc
11691 @xref{Output Devices}.
11694 @c =====================================================================
11696 @node Miscellaneous, Gtroff Internals, Postprocessor Access, gtroff Reference
11697 @section Miscellaneous
11699 This section documents parts of @code{gtroff} which cannot (yet) be
11700 categorized elsewhere in this manual.
11702 @Defreq {nm, [@Var{start} [@Var{inc} [@Var{space} [@Var{indent}]]]]}
11703 @cindex printing line numbers (@code{nm})
11704 @cindex line numbers, printing (@code{nm})
11705 @cindex numbers, line, printing (@code{nm})
11706 Print line numbers.
11707 @var{start} is the line number of the @emph{next}
11708 output line.  @var{inc} indicates which line numbers are printed.
11709 For example, the value@w{ }5 means to emit only line numbers which
11710 are multiples of@w{ }5; this defaults to@w{ }1.  @var{space} is the
11711 space to be left between the number and the text; this defaults to
11712 one digit space.  The fourth argument is the indentation of the line
11713 numbers, defaulting to zero.  Both @var{space} and @var{indent} are
11714 given as multiples of digit spaces; they can be negative also.
11715 Without any arguments, line numbers are turned off.
11717 @code{gtroff} reserves three digit spaces for the line number (which is
11718 printed right-justified) plus the amount given by @var{indent}; the
11719 output lines are concatenated to the line numbers, separated by
11720 @var{space}, and @emph{without} reducing the line length.  Depending
11721 on the value of the horizontal page offset (as set with the
11722 @code{po} request), line numbers which are longer than the reserved
11723 space stick out to the left, or the whole line is moved to the right.
11725 Parameters corresponding to missing arguments are not changed; any
11726 non-digit argument (to be more precise, any argument starting with a
11727 character valid as a delimiter for identifiers) is also treated as
11728 missing.
11730 If line numbering has been disabled with a call to @code{nm} without
11731 an argument, it can be reactivated with @samp{.nm +0}, using the
11732 previously active line numbering parameters.
11734 The parameters of @code{nm} are associated with the current environment
11735 (@pxref{Environments}).  The current output line number is available
11736 in the number register @code{ln}.
11738 @Example
11739 .po 1m
11740 .ll 2i
11741 This test shows how line numbering works with groff.
11742 .nm 999
11743 This test shows how line numbering works with groff.
11745 .nm xxx 3 2
11746 .ll -\w'0'u
11747 This test shows how line numbering works with groff.
11748 .nn 2
11749 This test shows how line numbering works with groff.
11750 @endExample
11752 @noindent
11753 And here the result:
11755 @Example
11756  This  test shows how
11757  line numbering works
11758  999 with   groff.   This
11759 1000 test shows how  line
11760 1001 numbering works with
11761 1002 groff.
11762       This test shows how
11763       line      numbering
11764  works  with  groff.
11765  This test shows how
11766 1005  line      numbering
11767       works with groff.
11768 @endExample
11769 @endDefreq
11771 @Defreq {nn, [@Var{skip}]}
11772 Temporarily turn off line numbering.  The argument is the number
11773 of lines not to be numbered; this defaults to@w{ }1.
11774 @endDefreq
11776 @Defreq {mc, glyph [@Var{dist}]}
11777 @cindex margin glyph (@code{mc})
11778 @cindex glyph, for margins (@code{mc})
11779 Print a @dfn{margin character} to the right of the
11780 text.@footnote{@dfn{Margin character} is a misnomer since it is an
11781 output glyph.}  The first argument is the glyph to be
11782 printed.  The second argument is the distance away from the right
11783 margin.  If missing, the previously set value is used; default is
11784 10@dmn{pt}).  For text lines that are too long (that is, longer than
11785 the text length plus @var{dist}), the margin character is directly
11786 appended to the lines.
11788 With no arguments the margin character is turned off.
11789 If this occurs before a break, no margin character is printed.
11791 @cindex @code{tl} request, and @code{mc}
11792 For empty lines and lines produced by the @code{tl} request no margin
11793 character is emitted.
11795 The margin character is associated with the current environment
11796 (@pxref{Environments}).
11798 @pindex nrchbar
11799 @pindex changebar
11800 This is quite useful for indicating text that has changed, and, in fact,
11801 there are programs available for doing this (they are called
11802 @code{nrchbar} and @code{changebar} and can be found in any
11803 @samp{comp.sources.unix} archive.
11805 @Example
11806 .ll 3i
11807 .mc |
11808 This paragraph is highlighted with a margin
11809 character.
11811 Note that vertical space isn't marked.
11815 But we can fake it with `\&'.
11816 @endExample
11818 Result:
11820 @Example
11821 This  paragraph is highlighted |
11822 with a margin character.       |
11824 Note that vertical space isn't |
11825 marked.                        |
11826                                |
11827 But we can fake it with `\&'.  |
11828 @endExample
11829 @endDefreq
11831 @DefreqList {psbb, filename}
11832 @DefregItem {llx}
11833 @DefregItem {lly}
11834 @DefregItem {urx}
11835 @DefregListEnd {ury}
11836 @cindex PostScript, bounding box
11837 @cindex bounding box
11838 Retrieve the bounding box of the PostScript image
11839 found in @var{filename}.
11840 The file must conform to
11841 Adobe's @dfn{Document Structuring Conventions} (DSC);
11842 the command searches for a @code{%%BoundingBox} comment
11843 and extracts the bounding box values into the number registers
11844 @code{llx}, @code{lly}, @code{urx}, and @code{ury}.
11845 If an error occurs (for example, @code{psbb} cannot find
11846 the @code{%%BoundingBox} comment),
11847 it sets the four number registers to zero.
11848 @endDefreq
11851 @c =====================================================================
11853 @node Gtroff Internals, Debugging, Miscellaneous, gtroff Reference
11854 @section @code{gtroff} Internals
11856 @cindex input token
11857 @cindex token, input
11858 @cindex output node
11859 @cindex node, output
11860 @code{gtroff} processes input in three steps.  One or more input
11861 characters are converted to an @dfn{input token}.@footnote{Except the
11862 escapes @code{\f}, @code{\F}, @code{\H}, @code{\R}, @code{\s}, and
11863 @code{\S} which are processed immediately if not in copy-in mode.}
11864 Then, one or more input tokens are converted to an @dfn{output node}.
11865 Finally, output nodes are converted to the intermediate output language
11866 understood by all output devices.
11868 Actually, before step one happens, @code{gtroff} converts certain
11869 escape sequences into reserved input characters (not accessible by
11870 the user); such reserved characters are used for other internal
11871 processing also -- this is the very reason why not all characters
11872 are valid input.  @xref{Identifiers}, for more on this topic.
11874 For example, the input string @samp{fi\[:u]} is converted into a
11875 character token @samp{f}, a character token @samp{i}, and a special
11876 token @samp{:u} (representing u@w{ }umlaut).  Later on, the character
11877 tokens @samp{f} and @samp{i} are merged to a single output node
11878 representing the ligature glyph @samp{fi} (provided the current font
11879 has a glyph for this ligature); the same happens with @samp{:u}.  All
11880 output glyph nodes are `processed' which means that they are invariably
11881 associated with a given font, font size, advance width, etc.  During
11882 the formatting process, @code{gtroff} itself adds various nodes to
11883 control the data flow.
11885 Macros, diversions, and strings collect elements in two chained lists:
11886 a list of input tokens which have been passed unprocessed, and a list
11887 of output nodes.  Consider the following the diversion.
11889 @Example
11890 .di xxx
11896 @endExample
11898 @noindent
11899 It contains these elements.
11901 @multitable {@i{vertical size node}} {token list} {element number}
11902 @item node list               @tab token list @tab element number
11904 @item @i{line start node}     @tab ---        @tab 1
11905 @item @i{glyph node @code{a}} @tab ---        @tab 2
11906 @item @i{word space node}     @tab ---        @tab 3
11907 @item ---                     @tab @code{b}   @tab 4
11908 @item ---                     @tab @code{\n}  @tab 5
11909 @item @i{glyph node @code{c}} @tab ---        @tab 6
11910 @item @i{vertical size node}  @tab ---        @tab 7
11911 @item @i{vertical size node}  @tab ---        @tab 8
11912 @item ---                     @tab @code{\n}  @tab 9
11913 @end multitable
11915 @cindex @code{\v}, internal representation
11916 @noindent
11917 Elements 1, 7, and@w{ }8 are inserted by @code{gtroff}; the latter two
11918 (which are always present) specify the vertical extent of the last
11919 line, possibly modified by @code{\x}.  The @code{br} request finishes
11920 the current partial line, inserting a newline input token which is
11921 subsequently converted to a space when the diversion is reread.  Note
11922 that the word space node has a fixed width which isn't stretchable
11923 anymore.  To convert horizontal space nodes back to input tokens, use
11924 the @code{unformat} request.
11926 Macros only contain elements in the token list (and the node list is
11927 empty); diversions and strings can contain elements in both lists.
11929 Note that the @code{chop} request simply reduces the number of elements in a
11930 macro, string, or diversion by one.  Exceptions are @dfn{compatibility save}
11931 and @dfn{compatibility ignore} input tokens which are ignored.  The
11932 @code{substring} request also ignores those input tokens.
11934 Some requests like @code{tr} or @code{cflags} work on glyph
11935 identifiers only; this means that the associated glyph can be changed
11936 without destroying this association.  This can be very helpful for
11937 substituting glyphs.  In the following example, we assume that
11938 glyph @samp{foo} isn't available by default, so we provide a
11939 substitution using the @code{fchar} request and map it to input
11940 character @samp{x}.
11942 @Example
11943 .fchar \[foo] foo
11944 .tr x \[foo]
11945 @endExample
11947 @noindent
11948 Now let us assume that we install an additional special font
11949 @samp{bar} which has glyph @samp{foo}.
11951 @Example
11952 .special bar
11953 .rchar \[foo]
11954 @endExample
11956 @noindent
11957 Since glyphs defined with @code{fchar} are searched before glyphs
11958 in special fonts, we must call @code{rchar} to remove the definition
11959 of the fallback glyph.  Anyway, the translation is still active;
11960 @samp{x} now maps to the real glyph @samp{foo}.
11963 @c =====================================================================
11965 @node Debugging, Implementation Differences, Gtroff Internals, gtroff Reference
11966 @section Debugging
11967 @cindex debugging
11969 @code{gtroff} is not easy to debug, but there are some useful features
11970 and strategies for debugging.
11972 @Defreq {lf, line filename}
11973 @pindex soelim
11974 @cindex multi-file documents
11975 @cindex documents, multi-file
11976 @cindex setting input line number (@code{lf})
11977 @cindex input line number, setting (@code{lf})
11978 @cindex number, input line, setting (@code{lf})
11979 Change the line number and the file name @code{gtroff} shall use for
11980 error and warning messages.  @var{line} is the input line number of the
11981 @emph{next} line.
11983 Without argument, the request is ignored.
11985 This is a debugging aid for documents which are split into many files,
11986 then put together with @code{soelim} and other preprocessors.  Usually,
11987 it isn't invoked manually.
11988 @endDefreq
11990 @DefreqList {tm, string}
11991 @DefreqItem {tm1, string}
11992 @DefreqListEnd {tmc, string}
11993 @cindex printing to stderr (@code{tm}, @code{tm1}, @code{tmc})
11994 @cindex stderr, printing to (@code{tm}, @code{tm1}, @code{tmc})
11995 Send @var{string} to the standard error output;
11996 this is very useful for printing debugging messages among other things.
11998 @var{string} is read in copy mode.
12000 The @code{tm} request ignores leading spaces of @var{string}; @code{tm1}
12001 handles its argument similar to the @code{ds} request: a leading double
12002 quote in @var{string} is stripped to allow initial blanks.
12004 The @code{tmc} request is similar to @code{tm1} but does
12005 not append a newline (as is done in @code{tm} and @code{tm1}).
12006 @endDefreq
12008 @Defreq {ab, [@Var{string}]}
12009 @cindex aborting (@code{ab})
12010 Similar to the @code{tm} request, except that
12011 it causes @code{gtroff} to stop processing.  With no argument it
12012 prints @samp{User Abort.} to standard error.
12013 @endDefreq
12015 @Defreq {ex, }
12016 @cindex @code{ex} request, use in debugging
12017 @cindex exiting (@code{ex})
12018 The @code{ex} request also causes @code{gtroff} to stop processing;
12019 see also @ref{I/O}.
12020 @endDefreq
12022 When doing something involved it is useful to leave the debugging
12023 statements in the code and have them turned on by a command line flag.
12025 @Example
12026 .if \n(DB .tm debugging output
12027 @endExample
12029 @noindent
12030 To activate these statements say
12032 @Example
12033 groff -rDB=1 file
12034 @endExample
12036 If it is known in advance that there will be many errors and no useful
12037 output, @code{gtroff} can be forced to suppress formatted output with
12038 the @option{-z} flag.
12040 @Defreq {pm, }
12041 @cindex dumping symbol table (@code{pm})
12042 @cindex symbol table, dumping (@code{pm})
12043 Print the entire symbol table on @code{stderr}.  Names of all defined
12044 macros, strings, and diversions are print together with their size in
12045 bytes.  Since @code{gtroff} sometimes adds nodes by itself, the
12046 returned size can be larger than expected.
12048 This request differs from @acronym{UNIX} @code{troff}: @code{gtroff}
12049 reports the sizes of diversions, ignores an additional argument to
12050 print only the total of the sizes, and the size isn't returned in
12051 blocks of 128 characters.
12052 @endDefreq
12054 @Defreq {pnr, }
12055 @cindex dumping number registers (@code{pnr})
12056 @cindex number registers, dumping (@code{pnr})
12057 Print the names and contents of all
12058 currently defined number registers on @code{stderr}.
12059 @endDefreq
12061 @Defreq {ptr, }
12062 @cindex dumping traps (@code{ptr})
12063 @cindex traps, dumping (@code{ptr})
12064 Print the names and positions of all traps
12065 (not including input line traps and diversion traps) on @code{stderr}.
12066 Empty slots in the page trap list are printed as well, because they can
12067 affect the priority of subsequently planted traps.
12068 @endDefreq
12070 @Defreq {fl, }
12071 @cindex flush output (@code{fl})
12072 @cindex output, flush (@code{fl})
12073 @cindex interactive use of @code{gtroff}
12074 @cindex @code{gtroff}, interactive use
12075 Instruct @code{gtroff} to flush its output immediately.  The intent
12076 is for interactive use, but this behaviour is currently not
12077 implemented in @code{gtroff}.  Contrary to @acronym{UNIX} @code{troff},
12078 TTY output is sent to a device driver also (@code{grotty}), making it
12079 non-trivial to communicate interactively.
12081 This request causes a line break.
12082 @endDefreq
12084 @Defreq {backtrace, }
12085 @cindex backtrace of input stack (@code{backtrace})
12086 @cindex input stack, backtrace (@code{backtrace})
12087 Print a backtrace of the input stack to the standard error stream.
12089 Consider the following in file @file{test}:
12091 @Example
12092 .de xxx
12093 .  backtrace
12095 .de yyy
12096 .  xxx
12099 .yyy
12100 @endExample
12102 @noindent
12103 On execution, @code{gtroff} prints the following:
12105 @Example
12106 test:2: backtrace: macro `xxx'
12107 test:5: backtrace: macro `yyy'
12108 test:8: backtrace: file `test'
12109 @endExample
12111 The option @option{-b} of @code{gtroff} internally calls a variant of
12112 this request on each error and warning.
12113 @endDefreq
12115 @Defreg {slimit}
12116 @cindex input stack, setting limit
12117 Use the @code{slimit} number register
12118 to set the maximum number of objects on the input stack.
12119 If @code{slimit} is less than or equal to@w{ }0,
12120 there is no limit set.
12121 With no limit, a buggy recursive macro can exhaust virtual memory.
12123 The default value is 1000; this is a compile-time constant.
12124 @endDefreg
12126 @Defreq {warnscale, si}
12127 Set the scaling indicator used in warnings to @var{si}.  Valid values for
12128 @var{si} are @samp{u}, @samp{i}, @samp{c}, @samp{p}, and @samp{P}.  At
12129 startup, it is set to @samp{i}.
12130 @endDefreq
12132 @Defreq {spreadwarn, [@Var{limit}]}
12133 Make @code{gtroff} emit a warning if the additional space inserted for
12134 each space between words in an output line is larger or equal to
12135 @var{limit}.  A negative value is changed to zero; no argument toggles the
12136 warning on and off without changing @var{limit}.  The default scaling
12137 indicator is @samp{m}.  At startup, @code{spreadwarn} is deactivated, and
12138 @var{limit} is set to 3@dmn{m}.
12140 For example,
12142 @Example
12143 .spreadwarn 0.2m
12144 @endExample
12146 @noindent
12147 will cause a warning if @code{gtroff} must add 0.2@dmn{m} or more for each
12148 interword space in a line.
12150 This request is active only if text is justified to both margins (using
12151 @w{@samp{.ad b}}).
12152 @endDefreq
12154 @cindex warnings
12155 @code{gtroff} has command line options for printing out more warnings
12156 (@option{-w}) and for printing backtraces (@option{-b}) when a warning
12157 or an error occurs.  The most verbose level of warnings is @option{-ww}.
12159 @DefreqList {warn, [@Var{flags}]}
12160 @DefregListEnd {.warn}
12161 @cindex level of warnings (@code{warn})
12162 @cindex warnings, level (@code{warn})
12163 Control the level of warnings checked for.  The @var{flags} are the sum
12164 of the numbers associated with each warning that is to be enabled; all
12165 other warnings are disabled.  The number associated with each warning is
12166 listed below.  For example, @w{@code{.warn 0}} disables all warnings,
12167 and @w{@code{.warn 1}} disables all warnings except that about missing
12168 glyphs.  If no argument is given, all warnings are enabled.
12170 The read-only number register @code{.warn} contains the current warning
12171 level.
12172 @endDefreq
12174 @menu
12175 * Warnings::
12176 @end menu
12178 @c ---------------------------------------------------------------------
12180 @node Warnings,  , Debugging, Debugging
12181 @subsection Warnings
12182 @cindex warnings
12184 The warnings that can be given to @code{gtroff} are divided into the
12185 following categories.  The name associated with each warning is used by
12186 the @option{-w} and @option{-W} options; the number is used by the
12187 @code{warn} request and by the @code{.warn} register.
12189 @table @samp
12190 @item char
12191 @itemx 1
12192 Non-existent glyphs.@footnote{@code{char} is a misnomer since it reports
12193 missing glyphs -- there aren't missing input characters, only invalid
12194 ones.}  This is enabled by default.
12196 @item number
12197 @itemx 2
12198 Invalid numeric expressions.  This is enabled by default.
12199 @xref{Expressions}.
12201 @item break
12202 @itemx 4
12203 @cindex fill mode
12204 @cindex mode, fill
12205 In fill mode, lines which could not be broken so that their length was
12206 less than the line length.  This is enabled by default.
12208 @item delim
12209 @itemx 8
12210 Missing or mismatched closing delimiters.
12212 @item el
12213 @itemx 16
12214 @cindex @code{ie} request, and warnings
12215 @cindex @code{el} request, and warnings
12216 Use of the @code{el} request with no matching @code{ie} request.
12217 @xref{if-else}.
12219 @item scale
12220 @itemx 32
12221 Meaningless scaling indicators.
12223 @item range
12224 @itemx 64
12225 Out of range arguments.
12227 @item syntax
12228 @itemx 128
12229 Dubious syntax in numeric expressions.
12231 @item di
12232 @itemx 256
12233 @cindex @code{di} request, and warnings
12234 @cindex @code{da} request, and warnings
12235 Use of @code{di} or @code{da} without an argument when there is no
12236 current diversion.
12238 @item mac
12239 @itemx 512
12240 @cindex @code{de}, @code{de1}, @code{dei} requests, and warnings
12241 @cindex @code{am}, @code{am1}, @code{ami} requests, and warnings
12242 @cindex @code{ds}, @code{ds1} requests, and warnings
12243 @cindex @code{as}, @code{as1} requests, and warnings
12244 @cindex @code{di} request, and warnings
12245 @cindex @code{da} request, and warnings
12246 @cindex @code{box}, @code{boxa} requests, and warnings
12247 @cindex @code{\*}, and warnings
12248 Use of undefined strings, macros and diversions.  When an undefined
12249 string, macro, or diversion is used, that string is automatically
12250 defined as empty.  So, in most cases, at most one warning is given
12251 for each name.
12253 @item reg
12254 @itemx 1024
12255 @cindex @code{nr} request, and warnings
12256 @cindex @code{\R}, and warnings
12257 @cindex @code{\n}, and warnings
12258 Use of undefined number registers.  When an undefined number register is
12259 used, that register is automatically defined to have a value of@w{ }0.
12260 So, in most cases, at most one warning is given for use of a particular
12261 name.
12263 @item tab
12264 @itemx 2048
12265 @cindex @code{\t}, and warnings
12266 Use of a tab character where a number was expected.
12268 @item right-brace
12269 @itemx 4096
12270 @cindex @code{\@}}, and warnings
12271 Use of @code{\@}} where a number was expected.
12273 @item missing
12274 @itemx 8192
12275 Requests that are missing non-optional arguments.
12277 @item input
12278 @itemx 16384
12279 Invalid input characters.
12281 @item escape
12282 @itemx 32768
12283 Unrecognized escape sequences.  When an unrecognized escape sequence
12284 @code{\@var{X}} is encountered, the escape character is ignored, and
12285 @var{X} is printed.
12287 @item space
12288 @itemx 65536
12289 @cindex compatibility mode
12290 Missing space between a request or macro and its argument.  This warning
12291 is given when an undefined name longer than two characters is
12292 encountered, and the first two characters of the name make a defined
12293 name.  The request or macro is not invoked.  When this warning is
12294 given, no macro is automatically defined.  This is enabled by default.
12295 This warning never occurs in compatibility mode.
12297 @item font
12298 @itemx 131072
12299 Non-existent fonts.  This is enabled by default.
12301 @item ig
12302 @itemx 262144
12303 Invalid escapes in text ignored with the @code{ig} request.  These are
12304 conditions that are errors when they do not occur in ignored text.
12306 @item color
12307 @itemx 524288
12308 Color related warnings.
12310 @item all
12311 All warnings except @samp{di}, @samp{mac} and @samp{reg}.  It is
12312 intended that this covers all warnings that are useful with traditional
12313 macro packages.
12315 @item w
12316 All warnings.
12317 @end table
12320 @c =====================================================================
12322 @node Implementation Differences,  , Debugging, gtroff Reference
12323 @section Implementation Differences
12324 @cindex implementation differences
12325 @cindex differences in implementation
12326 @cindex incompatibilities with @acronym{AT&T} @code{troff}
12327 @cindex compatibility mode
12328 @cindex mode, compatibility
12330 GNU @code{troff} has a number of features which cause incompatibilities
12331 with documents written with old versions of @code{troff}.
12333 @cindex long names
12334 @cindex names, long
12335 Long names cause some incompatibilities.  @acronym{UNIX} @code{troff}
12336 interprets
12338 @Example
12339 .dsabcd
12340 @endExample
12342 @cindex @code{\*}, incompatibilities with @acronym{AT&T} @code{troff}
12343 @cindex @code{\n}, incompatibilities with @acronym{AT&T} @code{troff}
12344 @noindent
12345 as defining a string @samp{ab} with contents @samp{cd}.  Normally, GNU
12346 @code{troff} interprets this as a call of a macro named
12347 @code{dsabcd}.  Also @acronym{UNIX} @code{troff} interprets
12348 @code{\*[} or @code{\n[} as references to a string or number register
12349 called @samp{[}.  In GNU @code{troff}, however, this is normally
12350 interpreted as the start of a long name.  In compatibility mode GNU
12351 @code{troff} interprets long names in the traditional way
12352 (which means that they are not recognized as names).
12354 @DefreqList {cp, [@Var{n}]}
12355 @DefreqItem {do, cmd}
12356 @DefregListEnd {.C}
12357 If @var{n} is missing or non-zero, turn on compatibility mode;
12358 otherwise, turn it off.
12360 The read-only number register @code{.C} is@w{ }1 if compatibility mode is
12361 on, 0@w{ }otherwise.
12363 Compatibility mode can be also turned on with the @option{-C} command line
12364 option.
12366 The @code{do} request turns off compatibility mode
12367 while executing its arguments as a @code{gtroff} command.
12369 @Example
12370 .do fam T
12371 @endExample
12373 @noindent
12374 executes the @code{fam} request when compatibility mode
12375 is enabled.
12377 @code{gtroff} restores the previous compatibility setting
12378 before interpreting any files sourced by the @var{cmd}.
12379 @endDefreq
12381 @cindex input level in delimited arguments
12382 @cindex delimited arguments, incompatibilities with @acronym{AT&T} @code{troff}
12383 Two other features are controlled by @option{-C}.  If not in
12384 compatibility mode, GNU @code{troff} preserves the input level in
12385 delimited arguments:
12387 @Example
12388 .ds xx '
12389 \w'abc\*(xxdef'
12390 @endExample
12392 @noindent
12393 In compatibility mode, the string @samp{72def'} is returned; without
12394 @option{-C} the resulting string is @samp{168} (assuming a TTY output
12395 device).
12397 @cindex @code{\f}, incompatibilities with @acronym{AT&T} @code{troff}
12398 @cindex @code{\H}, incompatibilities with @acronym{AT&T} @code{troff}
12399 @cindex @code{\R}, incompatibilities with @acronym{AT&T} @code{troff}
12400 @cindex @code{\s}, incompatibilities with @acronym{AT&T} @code{troff}
12401 @cindex @code{\S}, incompatibilities with @acronym{AT&T} @code{troff}
12402 Finally, the escapes @code{\f}, @code{\H}, @code{\R}, @code{\s}, and
12403 @code{\S} are transparent for recognizing the beginning of a line only
12404 in compatibility mode (this is a rather obscure feature).  For example,
12405 the code
12407 @Example
12408 .de xx
12409 Hallo!
12411 \fB.xx\fP
12412 @endExample
12414 prints @samp{Hallo!} in bold face if in compatibility mode, and
12415 @samp{.xx} in bold face otherwise.
12417 @cindex @code{\A}, incompatibilities with @acronym{AT&T} @code{troff}
12418 @cindex @code{\|}, incompatibilities with @acronym{AT&T} @code{troff}
12419 @cindex @code{\^}, incompatibilities with @acronym{AT&T} @code{troff}
12420 @cindex @code{\&}, incompatibilities with @acronym{AT&T} @code{troff}
12421 @cindex @code{\@{}, incompatibilities with @acronym{AT&T} @code{troff}
12422 @cindex @code{\@}}, incompatibilities with @acronym{AT&T} @code{troff}
12423 @cindex @code{\@key{SP}}, incompatibilities with @acronym{AT&T} @code{troff}
12424 @cindex @code{\'}, incompatibilities with @acronym{AT&T} @code{troff}
12425 @cindex @code{\`}, incompatibilities with @acronym{AT&T} @code{troff}
12426 @cindex @code{\-}, incompatibilities with @acronym{AT&T} @code{troff}
12427 @cindex @code{\_}, incompatibilities with @acronym{AT&T} @code{troff}
12428 @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
12429 @cindex @code{\%}, incompatibilities with @acronym{AT&T} @code{troff}
12430 @cindex @code{\c}, incompatibilities with @acronym{AT&T} @code{troff}
12431 GNU @code{troff} does not allow the use of the escape sequences
12432 @code{\|}, @code{\^}, @code{\&}, @code{\@{}, @code{\@}},
12433 @code{\@key{SP}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
12434 @code{\%}, and @code{\c} in names of strings, macros, diversions, number
12435 registers, fonts or environments; @acronym{UNIX} @code{troff} does.  The
12436 @code{\A} escape sequence (@pxref{Identifiers}) may be helpful in
12437 avoiding use of these escape sequences in names.
12439 @cindex fractional point sizes
12440 @cindex fractional type sizes
12441 @cindex point sizes, fractional
12442 @cindex type sizes, fractional
12443 @cindex sizes, fractional
12444 @cindex @code{ps} request, incompatibilities with @acronym{AT&T} @code{troff}
12445 Fractional point sizes cause one noteworthy incompatibility.  In
12446 @acronym{UNIX} @code{troff} the @code{ps} request ignores scale
12447 indicators and thus
12449 @Example
12450 .ps 10u
12451 @endExample
12453 @noindent
12454 sets the point size to 10@w{ }points, whereas in GNU @code{troff} it
12455 sets the point size to 10@w{ }scaled points.  @xref{Fractional Type
12456 Sizes}, for more information.
12458 @cindex @code{bd} request, incompatibilities with @acronym{AT&T} @code{troff}
12459 @cindex @code{cs} request, incompatibilities with @acronym{AT&T} @code{troff}
12460 @cindex @code{tr} request, incompatibilities with @acronym{AT&T} @code{troff}
12461 @cindex @code{fp} request, incompatibilities with @acronym{AT&T} @code{troff}
12462 @cindex input characters and output glyphs, compatibility with @acronym{AT&T} @code{troff}
12463 @cindex output glyphs, and input characters,compatibility with @acronym{AT&T} @code{troff}
12464 @cindex characters, input, and output glyphs, compatibility with @acronym{AT&T} @code{troff}
12465 @cindex glyphs, output, and input characters, compatibility with @acronym{AT&T} @code{troff}
12466 In GNU @code{troff} there is a fundamental difference between
12467 (unformatted) input characters and (formatted) output glyphs.
12468 Everything that affects how a glyph is output is stored
12469 with the glyph node; once a glyph node has been constructed it is
12470 unaffected by any subsequent requests that are executed, including
12471 @code{bd}, @code{cs}, @code{tkf}, @code{tr}, or @code{fp} requests.
12472 Normally glyphs are constructed from input characters at the
12473 moment immediately before the glyph is added to the current output
12474 line.  Macros, diversions and strings are all, in fact, the same type of
12475 object; they contain lists of input characters and glyph nodes in
12476 any combination.  A glyph node does not behave like an input
12477 character for the purposes of macro processing; it does not inherit any
12478 of the special properties that the input character from which it was
12479 constructed might have had.  For example,
12481 @Example
12482 .di x
12483 \\\\
12487 @endExample
12489 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
12490 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
12491 @cindex @code{\e}, incompatibilities with @acronym{AT&T} @code{troff}
12492 @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
12493 @cindex @code{\?}, incompatibilities with @acronym{AT&T} @code{troff}
12494 @cindex transparent output, incompatibilities with @acronym{AT&T} @code{troff}
12495 @cindex output, transparent, incompatibilities with @acronym{AT&T} @code{troff}
12496 @noindent
12497 prints @samp{\\} in GNU @code{troff}; each pair of input backslashes
12498 is turned into one output backslash and the resulting output backslashes
12499 are not interpreted as escape characters when they are reread.
12500 @acronym{UNIX} @code{troff} would interpret them as escape characters
12501 when they were reread and would end up printing one @samp{\}.  The
12502 correct way to obtain a printable backslash is to use the @code{\e}
12503 escape sequence: This always prints a single instance of the current
12504 escape character, regardless of whether or not it is used in a
12505 diversion; it also works in both GNU @code{troff} and @acronym{UNIX}
12506 @code{troff}.@footnote{To be completely independent of the current
12507 escape character, use @code{\(rs} which represents a reverse solidus
12508 (backslash) glyph.}  To store, for some reason, an escape sequence in a
12509 diversion that will be interpreted when the diversion is reread, either
12510 use the traditional @code{\!} transparent output facility, or, if this
12511 is unsuitable, the new @code{\?} escape sequence.
12513 @xref{Diversions}, and @ref{Gtroff Internals}, for more information.
12517 @c =====================================================================
12518 @c =====================================================================
12520 @node Preprocessors, Output Devices, gtroff Reference, Top
12521 @chapter Preprocessors
12522 @cindex preprocessors
12524 This chapter describes all preprocessors that come with @code{groff} or
12525 which are freely available.
12527 @menu
12528 * geqn::
12529 * gtbl::
12530 * gpic::
12531 * ggrn::
12532 * grap::
12533 * grefer::
12534 * gsoelim::
12535 @end menu
12538 @c =====================================================================
12540 @node geqn, gtbl, Preprocessors, Preprocessors
12541 @section @code{geqn}
12542 @cindex @code{eqn}, the program
12543 @cindex @code{geqn}, the program
12545 @c XXX
12547 @menu
12548 * Invoking geqn::
12549 @end menu
12551 @c ---------------------------------------------------------------------
12553 @node Invoking geqn,  , geqn, geqn
12554 @subsection Invoking @code{geqn}
12555 @cindex invoking @code{geqn}
12556 @cindex @code{geqn}, invoking
12558 @c XXX
12561 @c =====================================================================
12563 @node gtbl, gpic, geqn, Preprocessors
12564 @section @code{gtbl}
12565 @cindex @code{tbl}, the program
12566 @cindex @code{gtbl}, the program
12568 @c XXX
12570 @menu
12571 * Invoking gtbl::
12572 @end menu
12574 @c ---------------------------------------------------------------------
12576 @node Invoking gtbl,  , gtbl, gtbl
12577 @subsection Invoking @code{gtbl}
12578 @cindex invoking @code{gtbl}
12579 @cindex @code{gtbl}, invoking
12581 @c XXX
12584 @c =====================================================================
12586 @node gpic, ggrn, gtbl, Preprocessors
12587 @section @code{gpic}
12588 @cindex @code{pic}, the program
12589 @cindex @code{gpic}, the program
12591 @c XXX
12593 @menu
12594 * Invoking gpic::
12595 @end menu
12597 @c ---------------------------------------------------------------------
12599 @node Invoking gpic,  , gpic, gpic
12600 @subsection Invoking @code{gpic}
12601 @cindex invoking @code{gpic}
12602 @cindex @code{gpic}, invoking
12604 @c XXX
12607 @c =====================================================================
12609 @node ggrn, grap, gpic, Preprocessors
12610 @section @code{ggrn}
12611 @cindex @code{grn}, the program
12612 @cindex @code{ggrn}, the program
12614 @c XXX
12616 @menu
12617 * Invoking ggrn::
12618 @end menu
12620 @c ---------------------------------------------------------------------
12622 @node Invoking ggrn,  , ggrn, ggrn
12623 @subsection Invoking @code{ggrn}
12624 @cindex invoking @code{ggrn}
12625 @cindex @code{ggrn}, invoking
12627 @c XXX
12630 @c =====================================================================
12632 @node grap, grefer, ggrn, Preprocessors
12633 @section @code{grap}
12634 @cindex @code{grap}, the program
12636 A free implementation of @code{grap}, written by Ted Faber,
12637 is available as an extra package from the following address:
12639 @display
12640 @url{http://www.lunabase.org/~faber/Vault/software/grap/}
12641 @end display
12644 @c =====================================================================
12646 @node grefer, gsoelim, grap, Preprocessors
12647 @section @code{grefer}
12648 @cindex @code{refer}, the program
12649 @cindex @code{grefer}, the program
12651 @c XXX
12653 @menu
12654 * Invoking grefer::
12655 @end menu
12657 @c ---------------------------------------------------------------------
12659 @node Invoking grefer,  , grefer, grefer
12660 @subsection Invoking @code{grefer}
12661 @cindex invoking @code{grefer}
12662 @cindex @code{grefer}, invoking
12664 @c XXX
12667 @c =====================================================================
12669 @node gsoelim,  , grefer, Preprocessors
12670 @section @code{gsoelim}
12671 @cindex @code{soelim}, the program
12672 @cindex @code{gsoelim}, the program
12674 @c XXX
12676 @menu
12677 * Invoking gsoelim::
12678 @end menu
12680 @c ---------------------------------------------------------------------
12682 @node Invoking gsoelim,  , gsoelim, gsoelim
12683 @subsection Invoking @code{gsoelim}
12684 @cindex invoking @code{gsoelim}
12685 @cindex @code{gsoelim}, invoking
12687 @c XXX
12691 @c =====================================================================
12692 @c =====================================================================
12694 @node Output Devices, File formats, Preprocessors, Top
12695 @chapter Output Devices
12696 @cindex output devices
12697 @cindex devices for output
12699 @c XXX
12701 @menu
12702 * Special Characters::
12703 * grotty::
12704 * grops::
12705 * grodvi::
12706 * grolj4::
12707 * grolbp::
12708 * grohtml::
12709 * gxditview::
12710 @end menu
12713 @c =====================================================================
12715 @node Special Characters, grotty, Output Devices, Output Devices
12716 @section Special Characters
12717 @cindex special characters
12718 @cindex characters, special
12720 @c XXX
12722 @xref{Font Files}.
12725 @c =====================================================================
12727 @node grotty, grops, Special Characters, Output Devices
12728 @section @code{grotty}
12729 @cindex @code{grotty}, the program
12731 @c XXX
12733 @menu
12734 * Invoking grotty::
12735 @end menu
12737 @c ---------------------------------------------------------------------
12739 @node Invoking grotty,  , grotty, grotty
12740 @subsection Invoking @code{grotty}
12741 @cindex invoking @code{grotty}
12742 @cindex @code{grotty}, invoking
12744 @c XXX
12746 @c The following is no longer true; fix and extend it.
12748 @c @pindex less
12749 @c @cindex Teletype
12750 @c @cindex ISO 6249 SGR
12751 @c @cindex terminal control sequences
12752 @c @cindex control sequences, for terminals
12753 @c For TTY output devices, underlining is done by emitting sequences of
12754 @c @samp{_} and @samp{\b} (the backspace character) before the actual
12755 @c character.  Literally, this is printing an underline character, then
12756 @c moving back one character position, and printing the actual character
12757 @c at the same position as the underline character (similar to a
12758 @c typewriter).  Usually, a modern terminal can't interpret this (and the
12759 @c original Teletype machines for which this sequence was appropriate are
12760 @c no longer in use).  You need a pager program like @code{less} which
12761 @c translates this into ISO 6429 SGR sequences to control terminals.
12764 @c =====================================================================
12766 @node grops, grodvi, grotty, Output Devices
12767 @section @code{grops}
12768 @cindex @code{grops}, the program
12770 @c XXX
12772 @menu
12773 * Invoking grops::
12774 * Embedding PostScript::
12775 @end menu
12777 @c ---------------------------------------------------------------------
12779 @node Invoking grops, Embedding PostScript, grops, grops
12780 @subsection Invoking @code{grops}
12781 @cindex invoking @code{grops}
12782 @cindex @code{grops}, invoking
12784 @c XXX
12786 @c ---------------------------------------------------------------------
12788 @node Embedding PostScript,  , Invoking grops, grops
12789 @subsection Embedding @sc{PostScript}
12790 @cindex embedding PostScript
12791 @cindex PostScript, embedding
12793 @c XXX
12796 @c =====================================================================
12798 @node grodvi, grolj4, grops, Output Devices
12799 @section @code{grodvi}
12800 @cindex @code{grodvi}, the program
12802 @c XXX
12804 @menu
12805 * Invoking grodvi::
12806 @end menu
12808 @c ---------------------------------------------------------------------
12810 @node Invoking grodvi,  , grodvi, grodvi
12811 @subsection Invoking @code{grodvi}
12812 @cindex invoking @code{grodvi}
12813 @cindex @code{grodvi}, invoking
12815 @c XXX
12818 @c =====================================================================
12820 @node grolj4, grolbp, grodvi, Output Devices
12821 @section @code{grolj4}
12822 @cindex @code{grolj4}, the program
12824 @c XXX
12826 @menu
12827 * Invoking grolj4::
12828 @end menu
12830 @c ---------------------------------------------------------------------
12832 @node Invoking grolj4,  , grolj4, grolj4
12833 @subsection Invoking @code{grolj4}
12834 @cindex invoking @code{grolj4}
12835 @cindex @code{grolj4}, invoking
12837 @c XXX
12840 @c =====================================================================
12842 @node grolbp, grohtml, grolj4, Output Devices
12843 @section @code{grolbp}
12844 @cindex @code{grolbp}, the program
12846 @c XXX
12848 @menu
12849 * Invoking grolbp::
12850 @end menu
12852 @c ---------------------------------------------------------------------
12854 @node Invoking grolbp,  , grolbp, grolbp
12855 @subsection Invoking @code{grolbp}
12856 @cindex invoking @code{grolbp}
12857 @cindex @code{grolbp}, invoking
12859 @c XXX
12862 @c =====================================================================
12864 @node grohtml, gxditview, grolbp, Output Devices
12865 @section @code{grohtml}
12866 @cindex @code{grohtml}, the program
12868 @c XXX
12870 @menu
12871 * Invoking grohtml::
12872 * grohtml specific registers and strings::
12873 @end menu
12875 @c ---------------------------------------------------------------------
12877 @node Invoking grohtml, grohtml specific registers and strings, grohtml, grohtml
12878 @subsection Invoking @code{grohtml}
12879 @cindex invoking @code{grohtml}
12880 @cindex @code{grohtml}, invoking
12882 @c XXX
12884 @c ---------------------------------------------------------------------
12886 @node grohtml specific registers and strings,  , Invoking grohtml, grohtml
12887 @subsection @code{grohtml} specific registers and strings
12888 @cindex registers specific to @code{grohtml}
12889 @cindex strings specific to @code{grohtml}
12890 @cindex @code{grohtml}, registers and strings
12892 @DefmpregList {ps4html, grohtml}
12893 @DefstrListEnd {www-image-template, grohtml}
12894 The registers @code{ps4html} and @code{www-image-template} are defined
12895 by the @code{pre-grohtml} preprocessor.  @code{pre-grohtml} reads in
12896 the @code{troff} input, marks up the inline equations and passes the
12897 result firstly to
12899 @Example
12900 troff -Tps -rps4html=1 -dwww-image-template=@var{template}
12901 @endExample
12903 @noindent
12904 and secondly to
12906 @Example
12907 troff -Thtml
12908 @endExample
12910 The PostScript device is used to create all the image files, and the
12911 register @code{ps4html} enables the macro sets to ignore floating
12912 keeps, footers, and headings.
12914 The register @code{www-image-template} is set to the user specified
12915 template name or the default name.
12916 @endDefmpreg
12919 @c =====================================================================
12921 @node gxditview,  , grohtml, Output Devices
12922 @section @code{gxditview}
12923 @cindex @code{gxditview}, the program
12925 @c XXX
12927 @menu
12928 * Invoking gxditview::
12929 @end menu
12931 @c ---------------------------------------------------------------------
12933 @node Invoking gxditview,  , gxditview, gxditview
12934 @subsection Invoking @code{gxditview}
12935 @cindex invoking @code{gxditview}
12936 @cindex @code{gxditview}, invoking
12938 @c XXX
12939 @c X11's xditview
12943 @c =====================================================================
12944 @c =====================================================================
12946 @node File formats, Installation, Output Devices, Top
12947 @chapter File formats
12948 @cindex file formats
12949 @cindex formats, file
12951 All files read and written by @code{gtroff} are text files.  The
12952 following two sections describe their format.
12954 @menu
12955 * gtroff Output::
12956 * Font Files::
12957 @end menu
12960 @c =====================================================================
12962 @node gtroff Output, Font Files, File formats, File formats
12963 @section @code{gtroff} Output
12964 @cindex @code{gtroff}, output
12965 @cindex output, @code{gtroff}
12967 This section describes the intermediate output format of GNU
12968 @code{troff}.  This output is produced by a run of @code{gtroff}
12969 before it is fed into a device postprocessor program.
12971 As @code{groff} is a wrapper program around @code{gtroff} that
12972 automatically calls a postprocessor, this output does not show up
12973 normally.  This is why it is called @dfn{intermediate}.
12974 @code{groff} provides the option @option{-Z} to inhibit postprocessing,
12975 such that the produced intermediate output is sent to standard output
12976 just like calling @code{gtroff} manually.
12978 @cindex troff output
12979 @cindex output, troff
12980 @cindex intermediate output
12981 @cindex output, intermediate
12982 Here, the term @dfn{troff output} describes what is output by
12983 @code{gtroff}, while @dfn{intermediate output} refers to the language
12984 that is accepted by the parser that prepares this output for the
12985 postprocessors.  This parser is smarter on whitespace and implements
12986 obsolete elements for compatibility, otherwise both formats are the
12987 same.@footnote{The parser and postprocessor for intermediate output
12988 can be found in the file@*
12989 @file{@var{groff-source-dir}/src/libs/libdriver/input.cc}.}
12991 The main purpose of the intermediate output concept is to facilitate
12992 the development of postprocessors by providing a common programming
12993 interface for all devices.  It has a language of its own that is
12994 completely different from the @code{gtroff} language.  While the
12995 @code{gtroff} language is a high-level programming language for text
12996 processing, the intermediate output language is a kind of low-level
12997 assembler language by specifying all positions on the page for writing
12998 and drawing.
13000 The intermediate output produced by @code{gtroff} is fairly readable,
13001 while output from @acronym{AT&T} @code{troff} is rather hard to
13002 understand because of strange habits that are still supported, but not
13003 used any longer by @code{gtroff}.
13005 @menu
13006 * Language Concepts::
13007 * Command Reference::
13008 * Intermediate Output Examples::
13009 * Output Language Compatibility::
13010 @end menu
13012 @c ---------------------------------------------------------------------
13014 @node Language Concepts, Command Reference, gtroff Output, gtroff Output
13015 @subsection Language Concepts
13017 During the run of @code{gtroff}, the input data is cracked down to the
13018 information on what has to be printed at what position on the intended
13019 device.  So the language of the intermediate output format can be quite
13020 small.  Its only elements are commands with and without arguments.
13021 In this section, the term @dfn{command} always refers to the intermediate
13022 output language, and never to the @code{gtroff} language used for document
13023 formatting.  There are commands for positioning and text writing, for drawing, and
13024 for device controlling.
13026 @menu
13027 * Separation::
13028 * Argument Units::
13029 * Document Parts::
13030 @end menu
13032 @node Separation, Argument Units, Language Concepts, Language Concepts
13033 @subsubsection Separation
13035 @acronym{AT&T} @code{troff} output has strange requirements on whitespace.
13036 The @code{gtroff} output parser, however, is smart about whitespace by
13037 making it maximally optional.  The whitespace characters, i.e., the
13038 tab, space, and newline characters, always have a syntactical meaning.
13039 They are never printable because spacing within the output is always
13040 done by positioning commands.
13042 Any sequence of space or tab characters is treated as a single
13043 @dfn{syntactical space}.  It separates commands and arguments, but is
13044 only required when there would occur a clashing between the command code
13045 and the arguments without the space.  Most often, this happens when
13046 variable-length command names, arguments, argument lists, or command
13047 clusters meet.  Commands and arguments with a known, fixed length need
13048 not be separated by syntactical space.
13050 A line break is a syntactical element, too.  Every command argument can be
13051 followed by whitespace, a comment, or a newline character.  Thus a
13052 @dfn{syntactical line break} is defined to consist of optional
13053 syntactical space that is optionally followed by a comment, and a
13054 newline character.
13056 The normal commands, those for positioning and text, consist of a
13057 single letter taking a fixed number of arguments.  For historical reasons,
13058 the parser allows to stack such commands on the same line, but
13059 fortunately, in @code{gtroff}'s intermediate output, every command with
13060 at least one argument is followed by a line break, thus providing
13061 excellent readability.
13063 The other commands -- those for drawing and device controlling --
13064 have a more complicated structure; some recognize long command names,
13065 and some take a variable number of arguments.  So all @samp{D} and
13066 @samp{x} commands were designed to request a syntactical line break
13067 after their last argument.  Only one command, @w{@samp{x X}},
13068 has an argument that can stretch over several lines; all other
13069 commands must have all of their arguments on the same line as the
13070 command, i.e., the arguments may not be splitted by a line break.
13072 Empty lines (these are lines containing only space and/or a comment), can
13073 occur everywhere.  They are just ignored.
13075 @node Argument Units, Document Parts, Separation, Language Concepts
13076 @subsubsection Argument Units
13078 Some commands take integer arguments that are assumed to represent
13079 values in a measurement unit, but the letter for the corresponding
13080 scale indicator is not written with the output command arguments.
13081 Most commands assume the scale indicator @samp{u}, the basic unit of
13082 the device, some use @samp{z}, the scaled point unit of the device,
13083 while others, such as the color commands, expect plain integers.
13085 Note that single characters can have the eighth bit set, as can the
13086 names of fonts and special characters.  The names of characters and
13087 fonts can be of arbitrary length.  A character that is to be printed
13088 will always be in the current font.
13090 A string argument is always terminated by the next whitespace
13091 character (space, tab, or newline); an embedded @samp{#} character is
13092 regarded as part of the argument, not as the beginning of a comment
13093 command.  An integer argument is already terminated by the next
13094 non-digit character, which then is regarded as the first character of
13095 the next argument or command.
13097 @node Document Parts,  , Argument Units, Language Concepts
13098 @subsubsection Document Parts
13100 A correct intermediate output document consists of two parts, the
13101 @dfn{prologue} and the @dfn{body}.
13103 The task of the prologue is to set the general device parameters
13104 using three exactly specified commands.  @code{gtroff}'s prologue
13105 is guaranteed to consist of the following three lines (in that order):
13107 @Example
13108 x T @var{device}
13109 x res @var{n} @var{h} @var{v}
13110 x init
13111 @endExample
13113 @noindent
13114 with the arguments set as outlined in @ref{Device Control Commands}.
13115 Note that the parser for the intermediate output format is able to
13116 swallow additional whitespace and comments as well even in the
13117 prologue.
13119 The body is the main section for processing the document data.
13120 Syntactically, it is a sequence of any commands different from the
13121 ones used in the prologue.  Processing is terminated as soon as the
13122 first @w{@samp{x stop}} command is encountered; the last line of any
13123 @code{gtroff} intermediate output always contains such a command.
13125 Semantically, the body is page oriented.  A new page is started by a
13126 @samp{p} command.  Positioning, writing, and drawing commands are
13127 always done within the current page, so they cannot occur before the
13128 first @samp{p} command.  Absolute positioning (by the @samp{H} and
13129 @samp{V} commands) is done relative to the current page; all other
13130 positioning is done relative to the current location within this page.
13132 @c ---------------------------------------------------------------------
13134 @node Command Reference, Intermediate Output Examples, Language Concepts, gtroff Output
13135 @subsection Command Reference
13137 This section describes all intermediate output commands, both from
13138 @acronym{AT&T} @code{troff} as well as the @code{gtroff} extensions.
13140 @menu
13141 * Comment Command::
13142 * Simple Commands::
13143 * Graphics Commands::
13144 * Device Control Commands::
13145 * Obsolete Command::
13146 @end menu
13148 @node Comment Command, Simple Commands, Command Reference, Command Reference
13149 @subsubsection Comment Command
13151 @table @code
13152 @item #@var{anything}@angles{end of line}
13153 A comment.  Ignore any characters from the @samp{#} character up to
13154 the next newline character.
13156 This command is the only possibility for commenting in the intermediate
13157 output.  Each comment can be preceded by arbitrary syntactical space;
13158 every command can be terminated by a comment.
13159 @end table
13161 @node Simple Commands, Graphics Commands, Comment Command, Command Reference
13162 @subsubsection Simple Commands
13164 The commands in this subsection have a command code consisting of a
13165 single character, taking a fixed number of arguments.  Most of them
13166 are commands for positioning and text writing.  These commands are
13167 smart about whitespace.  Optionally, syntactical space can be inserted
13168 before, after, and between the command letter and its arguments.
13169 All of these commands are stackable, i.e., they can be preceded by
13170 other simple commands or followed by arbitrary other commands on the
13171 same line.  A separating syntactical space is only necessary when two
13172 integer arguments would clash or if the preceding argument ends with a
13173 string argument.
13175 @table @code
13176 @ignore
13177 .if (\n[@USE_ENV_STACK] == 1) \{\
13178 .command {
13179 Open a new environment by copying the actual device configuration data
13180 to the environment stack.
13182 The current environment is setup by the device specification and
13183 manipulated by the setting commands.
13186 .command }
13187 Close the actual environment (opened by a preceding
13188 .BR { \~command)
13189 and restore the previous environment from the environment
13190 stack as the actual device configuration data.
13192 \}              \" endif @USE_ENV_STACK
13193 @end ignore
13195 @item C @var{xxx}@angles{whitespace}
13196 Print a special character named @var{xxx}.  The trailing
13197 syntactical space or line break is necessary to allow glyph names
13198 of arbitrary length.  The glyph is printed at the current print
13199 position; the glyph's size is read from the font file.  The print
13200 position is not changed.
13202 @item c @var{g}
13203 Print glyph@w{ }@var{g} at the current print position;@footnote{@samp{c}
13204 is actually a misnomer since it outputs a glyph.} the glyph's size is
13205 read from the font file.  The print position is not changed.
13207 @item f @var{n}
13208 Set font to font number@w{ }@var{n} (a non-negative integer).
13210 @item H @var{n}
13211 Move right to the absolute vertical position@w{ }@var{n} (a
13212 non-negative integer in basic units @samp{u} relative to left edge
13213 of current page.
13215 @item h @var{n}
13216 Move @var{n} (a non-negative integer) basic units @samp{u} horizontally
13217 to the right.  The original @acronym{UNIX} troff manual allows negative
13218 values for @var{n} also, but @code{gtroff} doesn't use this.
13220 @item m @var{color-scheme} @r{[}@var{component} @dots{}@r{]}
13221 Set the color for text (glyphs), line drawing, and the outline of
13222 graphic objects using different color schemes; the analoguous command
13223 for the filling color of graphic objects is @samp{DF}.  The color
13224 components are specified as integer arguments between 0 and 65536.
13225 The number of color components and their meaning vary for the
13226 different color schemes.  These commands are generated by
13227 @code{gtroff}'s escape sequence @code{\m}.  No position changing.
13228 These commands are a @code{gtroff} extension.
13230 @table @code
13231 @item mc @var{cyan} @var{magenta} @var{yellow}
13232 Set color using the CMY color scheme, having the 3@w{ }color components
13233 @var{cyan}, @var{magenta}, and @var{yellow}.
13235 @item md
13236 Set color to the default color value (black in most cases).
13237 No component arguments.
13239 @item mg @var{gray}
13240 Set color to the shade of gray given by the argument, an integer
13241 between 0 (black) and 65536 (white).
13243 @item mk @var{cyan} @var{magenta} @var{yellow} @var{black}
13244 Set color using the CMYK color scheme, having the 4@w{ }color components
13245 @var{cyan}, @var{magenta}, @var{yellow}, and @var{black}.
13247 @item mr @var{red} @var{green} @var{blue}
13248 Set color using the RGB color scheme, having the 3@w{ }color components
13249 @var{red}, @var{green}, and @var{blue}.
13251 @end table
13253 @item N @var{n}
13254 Print glyph with index@w{ }@var{n} (a non-negative integer) of the
13255 current font.  This command is a @code{gtroff} extension.
13257 @item n @var{b} @var{a}
13258 Inform the device about a line break, but no positioning is done by
13259 this command.  In @acronym{AT&T} @code{troff}, the integer arguments
13260 @var{b} and@w{ }@var{a} informed about the space before and after the
13261 current line to make the intermediate output more human readable
13262 without performing any action.  In groff, they are just ignored, but
13263 they must be provided for compatibility reasons.
13265 @item p @var{n}
13266 Begin a new page in the outprint.  The page number is set
13267 to@w{ }@var{n}.  This page is completely independent of pages formerly
13268 processed even if those have the same page number.  The vertical
13269 position on the outprint is automatically set to@w{ }0.  All
13270 positioning, writing, and drawing is always done relative to a page,
13271 so a @samp{p} command must be issued before any of these commands.
13273 @item s @var{n}
13274 Set point size to @var{n}@w{ }scaled points (this is unit @samp{z}).
13275 @acronym{AT&T} @code{troff} used the unit points (@samp{p}) instead.
13276 @xref{Output Language Compatibility}.
13278 @item t @var{xxx}@angles{whitespace}
13279 @itemx t @var{xxx} @var{dummy-arg}@angles{whitespace}
13280 Print a word, i.e., a sequence of characters @var{xxx} representing
13281 output glyphs which names are single characters, terminated by
13282 a space character or a line break; an optional second integer argument
13283 is ignored (this allows the formatter to generate an even number of
13284 arguments).  The first glyph should be printed at the current
13285 position, the current horizontal position should then be increased by
13286 the width of the first glyph, and so on for each glyph.
13287 The widths of the glyphs are read from the font file, scaled for the
13288 current point size, and rounded to a multiple of the horizontal
13289 resolution.  Special characters cannot be printed using this command
13290 (use the @samp{C} command for special characters).  This command is a
13291 @code{gtroff} extension; it is only used for devices whose @file{DESC}
13292 file contains the @code{tcommand} keyword (@pxref{DESC File Format}).
13294 @item u @var{n} @var{xxx}@angles{whitespace}
13295 Print word with track kerning.  This is the same as the @samp{t}
13296 command except that after printing each glyph, the current
13297 horizontal position is increased by the sum of the width of that
13298 glyph and@w{ }@var{n} (an integer in basic units @samp{u}).
13299 This command is a @code{gtroff} extension; it is only used for devices
13300 whose @file{DESC} file contains the @code{tcommand} keyword
13301 (@pxref{DESC File Format}).
13303 @item V @var{n}
13304 Move down to the absolute vertical position@w{ }@var{n} (a
13305 non-negative integer in basic units @samp{u}) relative to upper edge
13306 of current page.
13308 @item v @var{n}
13309 Move @var{n}@w{ }basic units @samp{u} down (@var{n} is a non-negative
13310 integer).  The original @acronym{UNIX} troff manual allows negative
13311 values for @var{n} also, but @code{gtroff} doesn't use this.
13313 @item w
13314 Informs about a paddable white space to increase readability.
13315 The spacing itself must be performed explicitly by a move command.
13317 @end table
13319 @node Graphics Commands, Device Control Commands, Simple Commands, Command Reference
13320 @subsubsection Graphics Commands
13322 Each graphics or drawing command in the intermediate output starts
13323 with the letter @samp{D}, followed by one or two characters that
13324 specify a subcommand; this is followed by a fixed or variable number
13325 of integer arguments that are separated by a single space character.
13326 A @samp{D} command may not be followed by another command on the same line
13327 (apart from a comment), so each @samp{D} command is terminated by a
13328 syntactical line break.
13330 @code{gtroff} output follows the classical spacing rules (no space
13331 between command and subcommand, all arguments are preceded by a
13332 single space character), but the parser allows optional space between
13333 the command letters and makes the space before the first argument
13334 optional.  As usual, each space can be any sequence of tab and space
13335 characters.
13337 Some graphics commands can take a variable number of arguments.
13338 In this case, they are integers representing a size measured in basic
13339 units @samp{u}.  The arguments called @var{h1}, @var{h2}, @dots{},
13340 @var{hn} stand for horizontal distances where positive means right,
13341 negative left.  The arguments called @var{v1}, @var{v2}, @dots{},
13342 @var{vn} stand for vertical distances where positive means down,
13343 negative up.  All these distances are offsets relative to the current
13344 location.
13346 Unless indicated otherwise, each graphics command directly corresponds
13347 to a similar @code{gtroff} @code{\D} escape sequence.  @xref{Drawing
13348 Requests}.
13350 Unknown @samp{D} commands are assumed to be device-specific.
13351 Its arguments are parsed as strings; the whole information is then
13352 sent to the postprocessor.
13354 In the following command reference, the syntax element
13355 @angles{line break} means a syntactical line break as defined above.
13357 @table @code
13358 @item D~ @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
13359 Draw B-spline from current position to offset (@var{h1},@var{v1}),
13360 then to offset (@var{h2},@var{v2}), if given, etc.@: up to
13361 (@var{hn},@var{vn}).  This command takes a variable number of argument
13362 pairs; the current position is moved to the terminal point of the drawn
13363 curve.
13365 @item Da @var{h1} @var{v1} @var{h2} @var{v2}@angles{line break}
13366 Draw arc from current position to
13367 (@var{h1},@var{v1})@math{+}(@var{h2},@var{v2}) with center at
13368 (@var{h1},@var{v1}); then move the current position to the final point
13369 of the arc.
13371 @item DC @var{d}@angles{line break}
13372 @itemx DC @var{d} @var{dummy-arg}@angles{line break}
13373 Draw a solid circle using the current fill color with
13374 diameter@w{ }@var{d} (integer in basic units @samp{u}) with leftmost
13375 point at the current position; then move the current position to the
13376 rightmost point of the circle.  An optional second integer argument is
13377 ignored (this allows the formatter to generate an even number of
13378 arguments).  This command is a @code{gtroff} extension.
13380 @item Dc @var{d}@angles{line break}
13381 Draw circle line with diameter@w{ }@var{d} (integer in basic units
13382 @samp{u}) with leftmost point at the current position; then move the
13383 current position to the rightmost point of the circle.
13385 @item DE @var{h} @var{v}@angles{line break}
13386 Draw a solid ellipse in the current fill color with a horizontal
13387 diameter of@w{ }@var{h} and a vertical diameter of@w{ }@var{v} (both
13388 integers in basic units @samp{u}) with the leftmost point at the
13389 current position; then move to the rightmost point of the ellipse.
13390 This command is a @code{gtroff} extension.
13392 @item De @var{h} @var{v}@angles{line break}
13393 Draw an outlined ellipse with a horizontal diameter of@w{ }@var{h}
13394 and a vertical diameter of@w{ }@var{v} (both integers in basic units
13395 @samp{u}) with the leftmost point at current position; then move to
13396 the rightmost point of the ellipse.
13398 @item DF @var{color-scheme} @r{[}@var{component} @dots{}@r{]}@angles{line break}
13399 Set fill color for solid drawing objects using different color
13400 schemes; the analoguous command for setting the color of text, line
13401 graphics, and the outline of graphic objects is @samp{m}.
13402 The color components are specified as integer arguments between 0 and
13403 65536.  The number of color components and their meaning vary for the
13404 different color schemes.  These commands are generated by @code{gtroff}'s
13405 escape sequences @w{@code{\D'F @dots{}'}} and @code{\M} (with no other
13406 corresponding graphics commands).  No position changing.  This command
13407 is a @code{gtroff} extension.
13409 @table @code
13410 @item DFc @var{cyan} @var{magenta} @var{yellow}@angles{line break}
13411 Set fill color for solid drawing objects using the CMY color scheme,
13412 having the 3@w{ }color components @var{cyan}, @var{magenta}, and
13413 @var{yellow}.
13415 @item DFd@angles{line break}
13416 Set fill color for solid drawing objects to the default fill color value
13417 (black in most cases).  No component arguments.
13419 @item DFg @var{gray}@angles{line break}
13420 Set fill color for solid drawing objects to the shade of gray given by
13421 the argument, an integer between 0 (black) and 65536 (white).
13423 @item DFk @var{cyan} @var{magenta} @var{yellow} @var{black}@angles{line break}
13424 Set fill color for solid drawing objects using the CMYK color scheme,
13425 having the 4@w{ }color components @var{cyan}, @var{magenta}, @var{yellow},
13426 and @var{black}.
13428 @item DFr @var{red} @var{green} @var{blue}@angles{line break}
13429 Set fill color for solid drawing objects using the RGB color scheme,
13430 having the 3@w{ }color components @var{red}, @var{green}, and @var{blue}.
13432 @end table
13434 @item Df @var{n}@angles{line break}
13435 The argument@w{ }@var{n} must be an integer in the range @math{-32767}
13436 to 32767.
13438 @table @asis
13439 @item @math{0 @LE @var{n} @LE 1000}
13440 Set the color for filling solid drawing objects to a shade of gray,
13441 where 0 corresponds to solid white, 1000 (the default) to solid black,
13442 and values in between to intermediate shades of gray; this is
13443 obsoleted by command @samp{DFg}.
13445 @item @math{@var{n} @LT 0} or @math{@var{n} @LT 1000}
13446 Set the filling color to the color that is currently being used for
13447 the text and the outline, see command @samp{m}.  For example, the
13448 command sequence
13450 @Example
13451 mg 0 0 65536
13452 Df -1
13453 @endExample
13455 @noindent
13456 sets all colors to blue.
13458 @end table
13460 @noindent
13461 No position changing.  This command is a @code{gtroff} extension.
13463 @item Dl @var{h} @var{v}@angles{line break}
13464 Draw line from current position to offset (@var{h},@var{v}) (integers
13465 in basic units @samp{u}); then set current position to the end of the
13466 drawn line.
13468 @item Dp @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
13469 Draw a polygon line from current position to offset (@var{h1},@var{v1}),
13470 from there to offset (@var{h2},@var{v2}), etc.@: up to offset
13471 (@var{hn},@var{vn}), and from there back to the starting position.
13472 For historical reasons, the position is changed by adding the sum of
13473 all arguments with odd index to the actual horizontal position and the
13474 even ones to the vertical position.  Although this doesn't make sense
13475 it is kept for compatibility.
13476 @ignore
13477 As the polygon is closed, the end of drawing is the starting point, so
13478 the position doesn't change.
13479 @end ignore
13480 This command is a @code{gtroff} extension.
13482 @item Dp @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
13483 Draw a solid polygon in the current fill color rather than an outlined
13484 polygon, using the same arguments and positioning as the corresponding
13485 @samp{Dp} command.
13486 @ignore
13487 No position changing.
13488 @end ignore
13489 This command is a @code{gtroff} extension.
13491 @item Dt @var{n}@angles{line break}
13492 Set the current line thickness to@w{ }@var{n} (an integer in basic
13493 units @samp{u}) if @math{@var{n}>0}; if @math{@var{n}=0} select the
13494 smallest available line thickness; if @math{@var{n}<0} set the line
13495 thickness proportional to the point size (this is the default before
13496 the first @samp{Dt} command was specified).  For historical reasons,
13497 the horizontal position is changed by adding the argument to the actual
13498 horizontal position, while the vertical position is not changed.
13499 Although this doesn't make sense it is kept for compatibility.
13500 @ignore
13501 No position changing.
13502 @end ignore
13503 This command is a @code{gtroff} extension.
13505 @end table
13507 @node Device Control Commands, Obsolete Command, Graphics Commands, Command Reference
13508 @subsubsection Device Control Commands
13510 Each device control command starts with the letter @samp{x},
13511 followed by a space character (optional or arbitrary space or tab in
13512 @code{gtroff}) and a subcommand letter or word; each argument (if any)
13513 must be preceded by a syntactical space.  All @samp{x} commands are
13514 terminated by a syntactical line break; no device control command can
13515 be followed by another command on the same line (except a comment).
13517 The subcommand is basically a single letter, but to increase
13518 readability, it can be written as a word, i.e., an arbitrary sequence
13519 of characters terminated by the next tab, space, or newline character.
13520 All characters of the subcommand word but the first are simply ignored.
13521 For example, @code{gtroff} outputs the initialization command
13522 @w{@samp{x i}} as @w{@samp{x init}} and the resolution command
13523 @w{@samp{x r}} as @w{@samp{x res}}.
13525 In the following, the syntax element @angles{line break} means a
13526 syntactical line break (@pxref{Separation}).
13528 @table @code
13529 @item xF @var{name}@angles{line break}
13530 The @samp{F} stands for @var{Filename}.
13532 Use @var{name} as the intended name for the current file in error
13533 reports.  This is useful for remembering the original file name when
13534 @code{gtroff} uses an internal piping mechanism.  The input file is
13535 not changed by this command.  This command is a @code{gtroff} extension.
13537 @item xf @var{n} @var{s}@angles{line break}
13538 The @samp{f} stands for @var{font}.
13540 Mount font position@w{ }@var{n} (a non-negative integer) with font
13541 named@w{ }@var{s} (a text word).  @xref{Font Positions}.
13543 @item xH @var{n}@angles{line break}
13544 The @samp{H} stands for @var{Height}.
13546 Set glyph height to@w{ }@var{n} (a positive integer in scaled
13547 points @samp{z}).  @acronym{AT&T} @code{troff} uses the unit points
13548 (@samp{p}) instead.  @xref{Output Language Compatibility}.
13550 @item xi@angles{line break}
13551 The @samp{i} stands for @var{init}.
13553 Initialize device.  This is the third command of the prologue.
13555 @item xp@angles{line break}
13556 The @samp{p} stands for @var{pause}.
13558 Parsed but ignored.  The original @acronym{UNIX} troff manual writes
13560 @display
13561 pause device, can be restarted
13562 @end display
13564 @item xr @var{n} @var{h} @var{v}@angles{line break}
13565 The @samp{r} stands for @var{resolution}.
13567 Resolution is@w{ }@var{n}, while @var{h} is the minimal horizontal
13568 motion, and @var{v} the minimal vertical motion possible with this
13569 device; all arguments are positive integers in basic units @samp{u}
13570 per inch.  This is the second command of the prologue.
13572 @item xS @var{n}@angles{line break}
13573 The @samp{S} stands for @var{Slant}.
13575 Set slant to@w{ }@var{n} (an integer in basic units @samp{u}).
13577 @item xs@angles{line break}
13578 The @samp{s} stands for @var{stop}.
13580 Terminates the processing of the current file; issued as the last
13581 command of any intermediate troff output.
13583 @item xt@angles{line break}
13584 The @samp{t} stands for @var{trailer}.
13586 Generate trailer information, if any.  In @var{gtroff}, this is
13587 actually just ignored.
13589 @item xT @var{xxx}@angles{line break}
13590 The @samp{T} stands for @var{Typesetter}.
13592 Set name of device to word @var{xxx}, a sequence of characters ended
13593 by the next white space character.  The possible device names coincide
13594 with those from the groff @option{-T} option.  This is the first
13595 command of the prologue.
13597 @item xu @var{n}@angles{line break}
13598 The @samp{u} stands for @var{underline}.
13600 Configure underlining of spaces.  If @var{n} is@w{ }1, start
13601 underlining of spaces; if @var{n} is@w{ }0, stop underlining of spaces.
13602 This is needed for the @code{cu} request in nroff mode and is ignored
13603 otherwise.  This command is a @code{gtroff} extension.
13605 @item xX @var{anything}@angles{line break}
13606 The @samp{x} stands for @var{X-escape}.
13608 Send string @var{anything} uninterpreted to the device.  If the line
13609 following this command starts with a @samp{+} character this line is
13610 interpreted as a continuation line in the following sense.  The
13611 @samp{+} is ignored, but a newline character is sent instead to the
13612 device, the rest of the line is sent uninterpreted.  The same applies
13613 to all following lines until the first character of a line is not a
13614 @samp{+} character.  This command is generated by the @code{gtroff}
13615 escape sequence @code{\X}.  The line-continuing feature is a
13616 @code{gtroff} extension.
13618 @end table
13620 @node Obsolete Command,  , Device Control Commands, Command Reference
13621 @subsubsection Obsolete Command
13622 In @acronym{AT&T} @code{troff} output, the writing of a single
13623 glyph is mostly done by a very strange command that combines a
13624 horizontal move and a single character giving the glyph name.  It
13625 doesn't have a command code, but is represented by a 3-character
13626 argument consisting of exactly 2@w{ }digits and a character.
13628 @table @asis
13629 @item @var{dd}@var{g}
13630 Move right @var{dd} (exactly two decimal digits) basic units @samp{u},
13631 then print glyph@w{ }@var{g} (represented as a single character).
13633 In @code{gtroff}, arbitrary syntactical space around and within this
13634 command is allowed to be added.  Only when a preceding command on the
13635 same line ends with an argument of variable length a separating space
13636 is obligatory.  In @acronym{AT&T} @code{troff}, large clusters of these
13637 and other commands are used, mostly without spaces; this made such output
13638 almost unreadable.
13640 @end table
13642 For modern high-resolution devices, this command does not make sense
13643 because the width of the glyphs can become much larger than two
13644 decimal digits.  In @code{gtroff}, this is only used for the devices
13645 @code{X75}, @code{X75-12}, @code{X100}, and @code{X100-12}.  For other
13646 devices, the commands @samp{t} and @samp{u} provide a better
13647 functionality.
13649 @c ---------------------------------------------------------------------
13651 @node Intermediate Output Examples, Output Language Compatibility, Command Reference, gtroff Output
13652 @subsection Intermediate Output Examples
13654 This section presents the intermediate output generated from the same
13655 input for three different devices.  The input is the sentence
13656 @samp{hell world} fed into @code{gtroff} on the command line.
13658 @table @asis
13659 @item High-resolution device @code{ps}
13661 This is the standard output of @code{gtroff} if no @option{-T} option
13662 is given.
13664 @example
13665 @group
13666 shell> echo "hell world" | groff -Z -T ps
13668 x T ps
13669 x res 72000 1 1
13670 x init
13671 @end group
13673 x font 5 TR
13675 s10000
13676 V12000
13677 H72000
13678 thell
13679 wh2500
13681 H96620
13682 torld
13683 n12000 0
13684 @group
13685 x trailer
13686 V792000
13687 x stop
13688 @end group
13689 @end example
13691 @noindent
13692 This output can be fed into @code{grops} to get its representation as
13693 a PostScript file.
13695 @item Low-resolution device @code{latin1}
13697 This is similar to the high-resolution device except that the
13698 positioning is done at a minor scale.  Some comments (lines starting
13699 with @samp{#}) were added for clarification; they were not generated
13700 by the formatter.
13702 @example
13703 @group
13704 shell> echo "hell world" | groff -Z -T latin1
13706 # prologue
13707 x T latin1
13708 x res 240 24 40
13709 x init
13710 @end group
13711 # begin a new page
13713 # font setup
13714 x font 1 R
13717 # initial positioning on the page
13720 # write text `hell'
13721 thell
13722 # inform about space, and issue a horizontal jump
13723 wh24
13724 # write text `world'
13725 tworld
13726 # announce line break, but do nothing because ...
13727 n40 0
13728 @group
13729 # ... the end of the document has been reached
13730 x trailer
13731 V2640
13732 x stop
13733 @end group
13734 @end example
13736 @noindent
13737 This output can be fed into @code{grotty} to get a formatted text
13738 document.
13740 @item @acronym{AT&T} @code{troff} output
13741 Since a computer monitor has a very low resolution compared to modern
13742 printers the intermediate output for the X@w{ }Window devices can use
13743 the jump-and-write command with its 2-digit displacements.
13745 @example
13746 @group
13747 shell> echo "hell world" | groff -Z -T X100
13749 x T X100
13750 x res 100 1 1
13751 x init
13752 @end group
13754 x font 5 TR
13758 H100
13759 # write text with jump-and-write commands
13760 ch07e07l03lw06w11o07r05l03dh7
13761 n16 0
13762 @group
13763 x trailer
13764 V1100
13765 x stop
13766 @end group
13767 @end example
13769 @noindent
13770 This output can be fed into @code{xditview} or @code{gxditview}
13771 for displaying in@w{ }X.
13773 Due to the obsolete jump-and-write command, the text clusters in the
13774 @acronym{AT&T} @code{troff} output are almost unreadable.
13776 @end table
13778 @c ---------------------------------------------------------------------
13780 @node Output Language Compatibility,  , Intermediate Output Examples, gtroff Output
13781 @subsection Output Language Compatibility
13783 The intermediate output language of @acronym{AT&T} @code{troff}
13784 was first documented in the @acronym{UNIX} troff manual, with later
13785 additions documented in @cite{A Typesetter-indenpendent TROFF},
13786 written by Brian Kernighan.
13788 The @code{gtroff} intermediate output format is compatible with this
13789 specification except for the following features.
13791 @itemize @bullet
13792 @item
13793 The classical quasi device independence is not yet implemented.
13795 @item
13796 The old hardware was very different from what we use today.  So the
13797 @code{groff} devices are also fundamentally different from the ones in
13798 @acronym{AT&T} @code{troff}.  For example, the @acronym{AT&T}
13799 PostScript device is called @code{post} and has a resolution of only
13800 720 units per inch, suitable for printers 20 years ago, while
13801 @code{groff}'s @code{ps} device has a resolution of
13802 72000 units per inch.  Maybe, by implementing some rescaling
13803 mechanism similar to the classical quasi device independence,
13804 @code{groff} could emulate @acronym{AT&T}'s @code{post} device.
13806 @item
13807 The B-spline command @samp{D~} is correctly handled by the
13808 intermediate output parser, but the drawing routines aren't
13809 implemented in some of the postprocessor programs.
13811 @item
13812 The argument of the commands @samp{s} and @w{@samp{x H}} has the
13813 implicit unit scaled point @samp{z} in @code{gtroff}, while
13814 @acronym{AT&T} @code{troff} has point (@samp{p}).  This isn't an
13815 incompatibility but a compatible extension, for both units coincide
13816 for all devices without a @code{sizescale} parameter in the @file{DESC}
13817 file, including all postprocessors from @acronym{AT&T} and
13818 @code{groff}'s text devices.  The few @code{groff} devices with
13819 a @code{sizescale} parameter either do not exist for @acronym{AT&T}
13820 @code{troff}, have a different name, or seem to have a different
13821 resolution.  So conflicts are very unlikely.
13823 @item
13824 The position changing after the commands @samp{Dp}, @samp{DP}, and
13825 @samp{Dt} is illogical, but as old versions of @code{gtroff} used this
13826 feature it is kept for compatibility reasons.
13828 @ignore
13829 Temporarily, there existed some confusion on the positioning after the
13830 @samp{D} commands that are groff extensions.  This has been clarified
13831 by establishing the classical rule for all groff drawing commands:
13833 @itemize
13834 @item
13835 The position after a graphic object has been drawn is at its end;
13836 for circles and ellipses, the `end' is at the right side.
13838 @item
13839 From this, the positionings specified for the drawing commands above
13840 follow quite naturally.
13841 @end itemize
13842 @end ignore
13844 @end itemize
13847 @c =====================================================================
13849 @node Font Files,  , gtroff Output, File formats
13850 @section Font Files
13851 @cindex font files
13852 @cindex files, font
13854 The @code{gtroff} font format is roughly a superset of the
13855 @code{ditroff} font format (as used in later versions of @acronym{AT&T}
13856 @code{troff} and its descendants).  Unlike the @code{ditroff} font
13857 format, there is no associated binary format; all files are text
13858 files.@footnote{Plan@w{ }9 @code{troff} has also abandoned the binary
13859 format.}  The font files for device @var{name} are stored in a directory
13860 @file{dev@var{name}}.  There are two types of file: a device description
13861 file called @file{DESC} and for each font@w{ }@var{f} a font file
13862 called@w{ }@file{@var{f}}.
13864 @menu
13865 * DESC File Format::
13866 * Font File Format::
13867 @end menu
13869 @c ---------------------------------------------------------------------
13871 @node DESC File Format, Font File Format, Font Files, Font Files
13872 @subsection @file{DESC} File Format
13873 @cindex @file{DESC} file, format
13874 @cindex font description file, format
13875 @cindex format of font description file
13876 @pindex DESC@r{ file format}
13878 The @file{DESC} file can contain the following types of line.  Except
13879 for the @code{charset} keyword which must comes last (if at all), the
13880 order of the lines is not important.
13882 @table @code
13883 @item res @var{n}
13884 @kindex res
13885 There are @var{n}@w{ }machine units per inch.
13887 @item hor @var{n}
13888 @kindex hor
13889 The horizontal resolution is @var{n}@w{ }machine units.
13891 @item vert @var{n}
13892 @kindex vert
13893 The vertical resolution is @var{n}@w{ }machine units.
13895 @item sizescale @var{n}
13896 @kindex sizescale
13897 The scale factor for point sizes.  By default this has a value of@w{ }1.
13898 One scaled point is equal to one point/@var{n}.  The arguments to the
13899 @code{unitwidth} and @code{sizes} commands are given in scaled points.
13900 @xref{Fractional Type Sizes}, for more information.
13902 @item unitwidth @var{n}
13903 @kindex unitwidth
13904 Quantities in the font files are given in machine units for fonts whose
13905 point size is @var{n}@w{ }scaled points.
13907 @item prepro @var{program}
13908 @kindex prepro
13909 Call @var{program} as a preprocessor.  Currently, this keyword is used
13910 by @code{groff} with option @option{-Thtml} only.
13912 @item postpro @var{program}
13913 @kindex postpro
13914 Call @var{program} as a postprocessor.  For example, the line
13916 @Example
13917 postpro grodvi
13918 @endExample
13920 @noindent
13921 in the file @file{devdvi/DESC} makes @code{groff} call @code{grodvi}
13922 if option @option{-Tdvi} is given (and @option{-Z} isn't used).
13924 @item tcommand
13925 @kindex tcommand
13926 This means that the postprocessor can handle the @samp{t} and @samp{u}
13927 intermediate output commands.
13929 @item sizes @var{s1} @var{s2} @dots{} @var{sn} 0
13930 @kindex sizes
13931 This means that the device has fonts at @var{s1}, @var{s2}, @dots{}
13932 @var{sn} scaled points.  The list of sizes must be terminated by@w{ }0
13933 (this is digit zero).  Each @var{si} can also be a range of sizes
13934 @var{m}-@var{n}.  The list can extend over more than one line.
13936 @item styles @var{S1} @var{S2} @dots{} @var{Sm}
13937 @kindex styles
13938 The first @var{m}@w{ }font positions are associated with styles
13939 @var{S1} @dots{} @var{Sm}.
13941 @item fonts @var{n} @var{F1} @var{F2} @var{F3} @dots{} @var{Fn}
13942 @kindex fonts
13943 Fonts @var{F1} @dots{} @var{Fn} are mounted in the font positions
13944 @var{m}+1, @dots{}, @var{m}+@var{n} where @var{m} is the number of
13945 styles.  This command may extend over more than one line.  A font name
13946 of@w{ }0 means no font is mounted on the corresponding font position.
13948 @item family @var{fam}
13949 @kindex family
13950 The default font family is @var{fam}.
13952 @item use_charnames_in_special
13953 @kindex use_charnames_in_special
13954 This command indicates that @code{gtroff} should encode special
13955 characters inside special commands.  Currently, this is only used
13956 by the @acronym{HTML} output device.  @xref{Postprocessor Access}.
13958 @item papersize @var{string} @dots{}
13959 @kindex papersize
13960 Select a paper size.  Valid values for @var{string} are the ISO paper
13961 types @code{A0}-@code{A7}, @code{B0}-@code{B7}, @code{C0}-@code{C7},
13962 @code{D0}-@code{D7}, @code{DL}, and the US paper types @code{letter},
13963 @code{legal}, @code{tabloid}, @code{ledger}, @code{statement},
13964 @code{executive}, @code{com10}, and @code{monarch}.  Case is not significant
13965 for @var{string} if it holds predefined paper types.  Alternatively,
13966 @var{string} can be a file name (e.g.@: @file{/etc/papersize}); if the file
13967 can be opened, @code{groff} reads the first line and tests for the above
13968 paper sizes.  Finally, @var{string} can be a custom paper size in the format
13969 @code{@var{length},@var{width}} (no spaces before and after the comma).
13970 Both @var{length} and @var{width} must have a unit appended; valid values
13971 are @samp{i} for inches, @samp{C} for centimeters, @samp{p} for points, and
13972 @samp{P} for picas.  Example: @code{12c,235p}.  An argument which starts
13973 with a digit is always treated as a custom paper format.  @code{papersize}
13974 sets both the vertical and horizontal dimension of the output medium.
13976 More than one argument can be specified; @code{groff} scans from left to
13977 right and uses the first valid paper specification.
13979 @item pass_filenames
13980 @kindex pass_filenames
13981 Tell @code{gtroff} to emit the name of the source file currently
13982 being processed.  This is achieved by the intermediate output command
13983 @samp{F}.  Currently, this is only used by the @acronym{HTML} output
13984 device.
13986 @item print @var{program}
13987 @kindex print
13988 Use @var{program} as a spooler program for printing.  If omitted,
13989 the @option{-l} and @option{-L} options of @code{groff} are ignored.
13991 @item charset
13992 @kindex charset
13993 This line and everything following in the file are ignored.  It is
13994 allowed for the sake of backwards compatibility.
13995 @end table
13997 The @code{res}, @code{unitwidth}, @code{fonts}, and @code{sizes} lines
13998 are mandatory.  Other commands are ignored by @code{gtroff} but may be
13999 used by postprocessors to store arbitrary information about the device
14000 in the @file{DESC} file.
14002 @kindex spare1
14003 @kindex spare2
14004 @kindex biggestfont
14005 Here a list of obsolete keywords which are recognized by @code{groff}
14006 but completely ignored: @code{spare1}, @code{spare2},
14007 @code{biggestfont}.
14010 @c ---------------------------------------------------------------------
14012 @node Font File Format,  , DESC File Format, Font Files
14013 @subsection Font File Format
14014 @cindex font file, format
14015 @cindex font description file, format
14016 @cindex format of font files
14017 @cindex format of font description files
14019 A @dfn{font file}, also (and probably better) called a @dfn{font
14020 description file}, has two sections.  The first section is a sequence
14021 of lines each containing a sequence of blank delimited words; the first
14022 word in the line is a key, and subsequent words give a value for that
14023 key.
14025 @table @code
14026 @item name @var{f}
14027 @kindex name
14028 The name of the font is@w{ }@var{f}.
14030 @item spacewidth @var{n}
14031 @kindex spacewidth
14032 The normal width of a space is@w{ }@var{n}.
14034 @item slant @var{n}
14035 @kindex slant
14036 The glyphs of the font have a slant of @var{n}@w{ }degrees.
14037 (Positive means forward.)
14039 @item ligatures @var{lig1} @var{lig2} @dots{} @var{lign} [0]
14040 @kindex ligatures
14041 Glyphs @var{lig1}, @var{lig2}, @dots{}, @var{lign} are ligatures;
14042 possible ligatures are @samp{ff}, @samp{fi}, @samp{fl}, @samp{ffi} and
14043 @samp{ffl}.  For backwards compatibility, the list of ligatures may be
14044 terminated with a@w{ }0.  The list of ligatures may not extend over more
14045 than one line.
14047 @item special
14048 @cindex special fonts
14049 @kindex special
14050 The font is @dfn{special}; this means that when a glyph is requested
14051 that is not present in the current font, it is searched for in any
14052 special fonts that are mounted.
14053 @end table
14055 Other commands are ignored by @code{gtroff} but may be used by
14056 postprocessors to store arbitrary information about the font in the font
14057 file.
14059 @cindex comments in font files
14060 @cindex font files, comments
14061 @kindex #
14062 The first section can contain comments which start with the @samp{#}
14063 character and extend to the end of a line.
14065 The second section contains one or two subsections.  It must contain a
14066 @code{charset} subsection and it may also contain a @code{kernpairs}
14067 subsection.  These subsections can appear in any order.  Each
14068 subsection starts with a word on a line by itself.
14070 @kindex charset
14071 The word @code{charset} starts the character set
14072 subsection.@footnote{This keyword is misnamed since it starts a list
14073 of ordered glyphs, not characters.}  The @code{charset} line is
14074 followed by a sequence of lines.  Each line gives information for one
14075 glyph.  A line comprises a number of fields separated by blanks or
14076 tabs.  The format is
14078 @quotation
14079 @var{name} @var{metrics} @var{type} @var{code}
14080 [@var{entity-name}] [@code{--} @var{comment}]
14081 @end quotation
14083 @cindex 8-bit input
14084 @cindex input, 8-bit
14085 @cindex accessing unnamed glyphs with @code{\N}
14086 @cindex unnamed glyphs, accessing with @code{\N}
14087 @cindex characters, unnamed, accessing with @code{\N}
14088 @cindex glyphs, unnamed, accessing with @code{\N}
14089 @kindex ---
14090 @noindent
14091 @var{name} identifies the glyph name@footnote{The distinction between
14092 input, characters, and output, glyphs, is not clearly separated in the
14093 terminology of @code{groff}; for example, the @code{char} request
14094 should be called @code{glyph} since it defines an output entity.}:
14095 If @var{name} is a single character@w{ }@var{c} then it corresponds
14096 to the @code{gtroff} input character@w{ }@var{c}; if it is of the form
14097 @samp{\@var{c}} where @var{c} is a single character, then it
14098 corresponds to the special character @code{\[@var{c}]}; otherwise it
14099 corresponds to the special character @samp{\[@var{name}]}.  If it
14100 is exactly two characters @var{xx} it can be entered as
14101 @samp{\(@var{xx}}.  Note that single-letter special characters can't
14102 be accessed as @samp{\@var{c}}; the only exception is @samp{\-} which
14103 is identical to @code{\[-]}.
14105 @code{gtroff} supports 8-bit input characters; however some utilities
14106 have difficulties with eight-bit characters.  For this reason, there is
14107 a convention that the entity name @samp{char@var{n}} is equivalent to
14108 the single input character whose code is@w{ }@var{n}.  For example,
14109 @samp{char163} would be equivalent to the character with code@w{ }163
14110 which is the pounds sterling sign in the @w{ISO Latin-1} character set.
14111 You shouldn't use @samp{char@var{n}} entities in font description files
14112 since they are related to input, not output.  Otherwise, you get
14113 hard-coded connections between input and output encoding which
14114 prevents use of different (input) character sets.
14116 The name @samp{---} is special and indicates that the glyph is
14117 unnamed; such glyphs can only be used by means of the @code{\N}
14118 escape sequence in @code{gtroff}.
14120 The @var{type} field gives the glyph type:
14122 @table @code
14123 @item 1
14124 the glyph has a descender, for example, @samp{p};
14126 @item 2
14127 the glyph has an ascender, for example, @samp{b};
14129 @item 3
14130 the glyph has both an ascender and a descender, for example, @samp{(}.
14131 @end table
14133 The @var{code} field gives the code which the postprocessor uses to
14134 print the glyph.  The glyph can also be input to @code{gtroff}
14135 using this code by means of the @code{\N} escape sequence.  @var{code}
14136 can be any integer.  If it starts with @samp{0} it is interpreted as
14137 octal; if it starts with @samp{0x} or @samp{0X} it is interpreted as
14138 hexadecimal.
14140 The @var{entity-name} field gives an @acronym{ASCII} string
14141 identifying the glyph which the postprocessor uses to print the
14142 @code{gtroff} glyph @var{name}.  This field is optional and has been
14143 introduced so that the @acronym{HTML} device driver can encode its
14144 character set.  For example, the glyph @samp{\[Po]} is
14145 represented as @samp{&pound;} in @acronym{HTML} 4.0.
14147 Anything on the line after the @var{entity-name} field resp.@: after
14148 @samp{--} will be ignored.
14150 The @var{metrics} field has the form:
14152 @display
14153 @group
14154 @var{width}[@code{,}@var{height}[@code{,}@var{depth}[@code{,}@var{italic-correction}
14155   [@code{,}@var{left-italic-correction}[@code{,}@var{subscript-correction}]]]]]
14156 @end group
14157 @end display
14159 @noindent
14160 There must not be any spaces between these subfields (it has been split
14161 here into two lines for better legibility only).  Missing subfields are
14162 assumed to be@w{ }0.  The subfields are all decimal integers.  Since
14163 there is no associated binary format, these values are not required to
14164 fit into a variable of type @samp{char} as they are in @code{ditroff}.
14165 The @var{width} subfield gives the width of the glyph.  The @var{height}
14166 subfield gives the height of the glyph (upwards is positive); if a
14167 glyph does not extend above the baseline, it should be given a zero
14168 height, rather than a negative height.  The @var{depth} subfield gives
14169 the depth of the glyph, that is, the distance from the baseline to the
14170 lowest point below the baseline to which the glyph extends (downwards is
14171 positive); if a glyph does not extend below the baseline, it should be
14172 given a zero depth, rather than a negative depth.  The
14173 @var{italic-correction} subfield gives the amount of space that should
14174 be added after the glyph when it is immediately to be followed by a
14175 glyph from a roman font.  The @var{left-italic-correction} subfield
14176 gives the amount of space that should be added before the glyph when it
14177 is immediately to be preceded by a glyph from a roman font.  The
14178 @var{subscript-correction} gives the amount of space that should be
14179 added after a glyph before adding a subscript.  This should be less
14180 than the italic correction.
14182 A line in the @code{charset} section can also have the format
14184 @Example
14185 @var{name} "
14186 @endExample
14188 @noindent
14189 This indicates that @var{name} is just another name for the glyph
14190 mentioned in the preceding line.
14192 @kindex kernpairs
14193 The word @code{kernpairs} starts the kernpairs section.  This contains a
14194 sequence of lines of the form:
14196 @Example
14197 @var{c1} @var{c2} @var{n}
14198 @endExample
14200 @noindent
14201 This means that when glyph @var{c1} appears next to glyph @var{c2}
14202 the space between them should be increased by@w{ }@var{n}.  Most
14203 entries in the kernpairs section have a negative value for@w{ }@var{n}.
14207 @c =====================================================================
14208 @c =====================================================================
14210 @node Installation, Copying This Manual, File formats, Top
14211 @chapter Installation
14212 @cindex installation
14214 @c XXX
14218 @c =====================================================================
14219 @c =====================================================================
14221 @node Copying This Manual, Request Index, Installation, Top
14222 @appendix Copying This Manual
14224 @menu
14225 * GNU Free Documentation License::  License for copying this manual.
14226 @end menu
14228 @include fdl.texi
14232 @c =====================================================================
14233 @c =====================================================================
14235 @node Request Index, Escape Index, Copying This Manual, Top
14236 @appendix Request Index
14238 Requests appear without the leading control character (normally either
14239 @samp{.} or @samp{'}).
14241 @printindex rq
14245 @c =====================================================================
14246 @c =====================================================================
14248 @node Escape Index, Operator Index, Request Index, Top
14249 @appendix Escape Index
14251 Any escape sequence @code{\@var{X}} with @var{X} not in the list below
14252 emits a warning, printing glyph @var{X}.
14254 @printindex es
14258 @c =====================================================================
14259 @c =====================================================================
14261 @node Operator Index, Register Index, Escape Index, Top
14262 @appendix Operator Index
14264 @printindex op
14268 @c =====================================================================
14269 @c =====================================================================
14271 @node Register Index, Macro Index, Operator Index, Top
14272 @appendix Register Index
14274 The macro package or program a specific register belongs to is appended in
14275 brackets.
14277 A register name@w{ }@code{x} consisting of exactly one character can be
14278 accessed as @samp{\nx}.  A register name @code{xx} consisting of exactly
14279 two characters can be accessed as @samp{\n(xx}.  Register names @code{xxx}
14280 of any length can be accessed as @samp{\n[xxx]}.
14282 @printindex vr
14286 @c =====================================================================
14287 @c =====================================================================
14289 @node Macro Index, String Index, Register Index, Top
14290 @appendix Macro Index
14292 The macro package a specific macro belongs to is appended in brackets.
14293 They appear without the leading control character (normally @samp{.}).
14295 @printindex ma
14299 @c =====================================================================
14300 @c =====================================================================
14302 @node String Index, Glyph Name Index, Macro Index, Top
14303 @appendix String Index
14305 The macro package or program a specific string belongs to is appended in
14306 brackets.
14308 A string name@w{ }@code{x} consisting of exactly one character can be
14309 accessed as @samp{\*x}.  A string name @code{xx} consisting of exactly
14310 two characters can be accessed as @samp{\*(xx}.  String names @code{xxx}
14311 of any length can be accessed as @samp{\*[xxx]}.
14314 @printindex st
14318 @c =====================================================================
14319 @c =====================================================================
14321 @node Glyph Name Index, Font File Keyword Index, String Index, Top
14322 @appendix Glyph Name Index
14324 A glyph name @code{xx} consisting of exactly two characters can be
14325 accessed as @samp{\(xx}.  Glyph names @code{xxx} of any length can be
14326 accessed as @samp{\[xxx]}.
14328 @c XXX
14332 @c =====================================================================
14333 @c =====================================================================
14335 @node Font File Keyword Index, Program and File Index, Glyph Name Index, Top
14336 @appendix Font File Keyword Index
14338 @printindex ky
14342 @c =====================================================================
14343 @c =====================================================================
14345 @node Program and File Index, Concept Index, Font File Keyword Index, Top
14346 @appendix Program and File Index
14348 @printindex pg
14352 @c =====================================================================
14353 @c =====================================================================
14355 @node Concept Index,  , Program and File Index, Top
14356 @appendix Concept Index
14358 @printindex cp
14361 @bye