doc/pic.ms: typos (Zinn5jm)..
[s-roff.git] / doc / groff.texinfo
blobe7793df13e5c1378151ed581517bbd3b8e04f5e5
1 \input texinfo   @c -*-texinfo-*-
3 @c
4 @c Please convert this manual with `texi2dvi -e groff.texinfo' due to
5 @c problems in texinfo regarding expansion of user-defined macros.
6 @c
7 @c You need texinfo 4.8 or newer to format this document!
8 @c
10 @c %**start of header (This is for running Texinfo on a region.)
11 @setfilename groff.info
12 @settitle The GNU Troff Manual
13 @setchapternewpage odd
14 @footnotestyle separate
15 @c %**end of header (This is for running Texinfo on a region.)
17 @documentlanguage en
18 @documentencoding ISO-8859-1
21 @smallbook
23 @finalout
26 @copying
27 This manual documents GNU @code{troff} version 1.20.
29 Copyright @copyright{} 1994-2000, 2001, 2002, 2003, 2004, 2005, 2006,
30 2007, 2008, 2009
31 Free Software Foundation, Inc.
33 @quotation
34 Permission is granted to copy, distribute and/or modify this document
35 under the terms of the GNU Free Documentation License, Version 1.1 or
36 any later version published by the Free Software Foundation; with no
37 Invariant Sections, with the Front-Cover texts being `A GNU Manual,''
38 and with the Back-Cover Texts as in (a) below.  A copy of the license is
39 included in the section entitled `GNU Free Documentation License.''
41 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
42 modify this GNU manual.  Buying copies from the FSF supports it in
43 developing GNU and promoting software freedom.''
44 @end quotation
45 @end copying
48 @c We use the following indices:
50 @c   cindex: concepts
51 @c   rqindex: requests
52 @c   esindex: escapes
53 @c   vindex: registers
54 @c   kindex: commands in font files
55 @c   pindex: programs and files
56 @c   tindex: environment variables
57 @c   maindex: macros
58 @c   stindex: strings
59 @c   opindex: operators
61 @c tindex and cindex are merged.
63 @defcodeindex rq
64 @defcodeindex es
65 @defcodeindex ma
66 @defcodeindex st
67 @defcodeindex op
68 @syncodeindex tp cp
71 @c To avoid uppercasing in @deffn while converting to info, we define
72 @c our special @Var{}.
74 @macro Var{arg}
75 @r{@slanted{\arg\}}
76 @end macro
79 @c To assure correct HTML translation, some ugly hacks are necessary.
80 @c While processing a @def... request, the HTML translator looks at the
81 @c next line to decide whether to start indentation, and if the line
82 @c starts with @def... (e.g. @deffnx), indentation is started.  We must
83 @c therefore ensure that a @def... is seen, during macro expansion.
85 @c The following macros have to be used:
87 @c One item:
89 @c   @Def...
91 @c Two items:
93 @c   @Def...List
94 @c   @Def...ListEnd
96 @c More than two:
98 @c   @Def...List
99 @c   @Def...Item
100 @c   @Def...Item
101 @c   ...
102 @c   @Def...ListEnd
104 @c The definition block must end with
106 @c   @endDef...
108 @c The above is valid for texinfo 4.0f and above.
111 @c a dummy macro to assure the `@def...'
113 @macro defdummy
115 @end macro
118 @c definition of requests
120 @macro Defreq{name, arg}
121 @deffn Request @t{.\name\} \arg\
122 @rqindex \name\
124 @end macro
126 @macro DefreqList{name, arg}
127 @deffn Request @t{.\name\} \arg\
128 @defdummy
129 @rqindex \name\
131 @end macro
133 @macro DefreqItem{name, arg}
134 @deffnx Request @t{.\name\} \arg\
135 @defdummy
136 @rqindex \name\
138 @end macro
140 @macro DefreqListEnd{name, arg}
141 @deffnx Request @t{.\name\} \arg\
142 @rqindex \name\
144 @end macro
146 @macro endDefreq
147 @end deffn
148 @end macro
151 @c definition of escapes
153 @macro Defesc{name, delimI, arg, delimII}
154 @deffn Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
155 @esindex \name\
157 @end macro
159 @macro DefescList{name, delimI, arg, delimII}
160 @deffn Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
161 @defdummy
162 @esindex \name\
164 @end macro
166 @macro DefescItem{name, delimI, arg, delimII}
167 @deffnx Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
168 @defdummy
169 @esindex \name\
171 @end macro
173 @macro DefescListEnd{name, delimI, arg, delimII}
174 @deffnx Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
175 @esindex \name\
177 @end macro
179 @macro endDefesc
180 @end deffn
181 @end macro
184 @c definition of registers
186 @macro Defreg{name}
187 @deffn Register @t{\\n[\name\]}
188 @vindex \name\
190 @end macro
192 @macro DefregList{name}
193 @deffn Register @t{\\n[\name\]}
194 @defdummy
195 @vindex \name\
197 @end macro
199 @macro DefregItem{name}
200 @deffnx Register @t{\\n[\name\]}
201 @defdummy
202 @vindex \name\
204 @end macro
206 @macro DefregListEnd{name}
207 @deffnx Register @t{\\n[\name\]}
208 @vindex \name\
210 @end macro
212 @macro endDefreg
213 @end deffn
214 @end macro
217 @c definition of registers specific to macro packages, preprocessors, etc.
219 @macro Defmpreg{name, package}
220 @deffn Register @t{\\n[\name\]}
221 @vindex \name\ @r{[}\package\@r{]}
223 @end macro
225 @macro DefmpregList{name, package}
226 @deffn Register @t{\\n[\name\]}
227 @defdummy
228 @vindex \name\ @r{[}\package\@r{]}
230 @end macro
232 @macro DefmpregItem{name, package}
233 @deffnx Register @t{\\n[\name\]}
234 @defdummy
235 @vindex \name\ @r{[}\package\@r{]}
237 @end macro
239 @macro DefmpregListEnd{name, package}
240 @deffnx Register @t{\\n[\name\]}
241 @vindex \name\ @r{[}\package\@r{]}
243 @end macro
245 @macro endDefmpreg
246 @end deffn
247 @end macro
250 @c definition of macros
252 @macro Defmac{name, arg, package}
253 @defmac @t{.\name\} \arg\
254 @maindex \name\ @r{[}\package\@r{]}
256 @end macro
258 @macro DefmacList{name, arg, package}
259 @defmac @t{.\name\} \arg\
260 @defdummy
261 @maindex \name\ @r{[}\package\@r{]}
263 @end macro
265 @macro DefmacItem{name, arg, package}
266 @defmacx @t{.\name\} \arg\
267 @defdummy
268 @maindex \name\ @r{[}\package\@r{]}
270 @end macro
272 @macro DefmacListEnd{name, arg, package}
273 @defmacx @t{.\name\} \arg\
274 @maindex \name\ @r{[}\package\@r{]}
276 @end macro
278 @macro endDefmac
279 @end defmac
280 @end macro
283 @c definition of strings
285 @macro Defstr{name, package}
286 @deffn String @t{\\*[\name\]}
287 @stindex \name\ @r{[}\package\@r{]}
289 @end macro
291 @macro DefstrList{name, package}
292 @deffn String @t{\\*[\name\]}
293 @defdummy
294 @stindex \name\ @r{[}\package\@r{]}
296 @end macro
298 @macro DefstrItem{name, package}
299 @deffnx String @t{\\*[\name\]}
300 @defdummy
301 @stindex \name\ @r{[}\package\@r{]}
303 @end macro
305 @macro DefstrListEnd{name, package}
306 @deffnx String @t{\\*[\name\]}
307 @stindex \name\ @r{[}\package\@r{]}
309 @end macro
311 @macro endDefstr
312 @end deffn
313 @end macro
316 @c our example macro
318 @macro Example
319 @example
320 @group
321 @end macro
323 @macro endExample
324 @end group
325 @end example
326 @end macro
329 @c <text>
331 @tex
332 \gdef\Langlemacro{\angleleft}
333 \gdef\Ranglemacro{\angleright}
334 @end tex
336 @iftex
337 @set Langlemacro @Langlemacro
338 @set Ranglemacro @Ranglemacro
339 @end iftex
341 @ifnottex
342 @set Langlemacro <
343 @set Ranglemacro >
344 @end ifnottex
346 @macro angles{text}
347 @value{Langlemacro}@r{\text\}@value{Ranglemacro}
348 @end macro
351 @c a <= sign
353 @c A value defined with @set is embedded into three group levels if
354 @c called with @value, so we need seven \aftergroup to put \le outside
355 @c of the groups -- this is necessary to get proper mathematical
356 @c spacing.
358 @tex
359 \gdef\LEmacro{\aftergroup\aftergroup\aftergroup\aftergroup
360               \aftergroup\aftergroup\aftergroup\le}
361 @end tex
363 @iftex
364 @set LEmacro @LEmacro
365 @end iftex
367 @ifnottex
368 @set LEmacro <=
369 @end ifnottex
371 @macro LE
372 @value{LEmacro}
373 @end macro
376 @c Special care is required with parentheses, brackets, and braces:
378 @c . Real parentheses in @deffn produce an error while compiling with
379 @c   TeX.
380 @c . Real brackets use the wrong font in @deffn, overriding @t{}.
382 @c . @{ and @} fail with info if used in a macro.
384 @c Since macros aren't expanded in @deffn during -E, the following
385 @c definitions are for non-TeX only.
387 @c This is true for texinfo 4.0 and above.
389 @iftex
390 @set Lparenmacro @lparen
391 @set Rparenmacro @rparen
392 @set Lbrackmacro @lbrack
393 @set Rbrackmacro @rbrack
394 @set Lbracemacro @{
395 @set Rbracemacro @}
396 @end iftex
398 @ifnottex
399 @set Lparenmacro (
400 @set Rparenmacro )
401 @set Lbrackmacro [
402 @set Rbrackmacro ]
403 @set Lbracemacro @{
404 @set Rbracemacro @}
405 @end ifnottex
407 @macro Lparen{}
408 @value{Lparenmacro}
409 @end macro
410 @macro Rparen{}
411 @value{Rparenmacro}
412 @end macro
413 @macro Lbrack{}
414 @value{Lbrackmacro}
415 @end macro
416 @macro Rbrack{}
417 @value{Rbrackmacro}
418 @end macro
419 @macro Lbrace{}
420 @value{Lbracemacro}
421 @end macro
422 @macro Rbrace{}
423 @value{Rbracemacro}
424 @end macro
427 @c This suppresses the word `Appendix' in the appendix headers.
429 @tex
430 \gdef\gobblefirst#1#2{#2}
431 \gdef\putwordAppendix{\gobblefirst}
432 @end tex
435 @c We map some latin-1 characters to corresponding texinfo macros.
436 @c Newer versions of texinfo.tex have similar code included already.
438 @tex
439 \global\catcode`^^e4\active % Ã¤
440 \gdef^^e4{\"a}
441 \global\catcode`^^c4\active % Ã„
442 \gdef^^c4{\"A}
443 \global\catcode`^^e9\active % Ã©
444 \gdef^^e9{\'e}
445 \global\catcode`^^c9\active % Ã‰
446 \gdef^^c9{\'E}
447 \global\catcode`^^f6\active % Ã¶
448 \gdef^^f6{\"o}
449 \global\catcode`^^d6\active % Ã–
450 \gdef^^d6{\"O}
451 \global\catcode`^^fc\active % Ã¼
452 \gdef^^fc{\"u}
453 \global\catcode`^^dc\active % Ãœ
454 \gdef^^dc{\"U}
455 \global\catcode`^^e6\active % Ã¦
456 \gdef^^e6{\ae}
457 \global\catcode`^^c6\active % Ã†
458 \gdef^^c6{\AE}
459 \global\catcode`^^df\active % ÃŸ
460 \gdef^^df{\ss}
461 @end tex
464 @c Note: We say `Roman numerals' but `roman font'.
467 @dircategory Typesetting
468 @direntry
469 * Groff: (groff).               The GNU troff document formatting system.
470 @end direntry
473 @titlepage
474 @title groff
475 @subtitle The GNU implementation of @code{troff}
476 @subtitle Edition 1.20
477 @subtitle Spring 2009
478 @author by Trent A.@tie{}Fisher
479 @author and Werner Lemberg (@email{bug-groff@@gnu.org})
481 @page
482 @vskip 0pt plus 1filll
483 @insertcopying
484 @end titlepage
486 @contents
488 @ifnottex
489 @node Top, Introduction, (dir), (dir)
490 @top GNU troff
491 @end ifnottex
493 @menu
494 * Introduction::
495 * Invoking groff::
496 * Tutorial for Macro Users::
497 * Macro Packages::
498 * gtroff Reference::
499 * Preprocessors::
500 * Output Devices::
501 * File formats::
502 * Installation::
503 * Copying This Manual::
504 * Request Index::
505 * Escape Index::
506 * Operator Index::
507 * Register Index::
508 * Macro Index::
509 * String Index::
510 * Glyph Name Index::
511 * Font File Keyword Index::
512 * Program and File Index::
513 * Concept Index::
514 @end menu
516 @ifnottex
517 @insertcopying
518 @end ifnottex
522 @c =====================================================================
523 @c =====================================================================
525 @node Introduction, Invoking groff, Top, Top
526 @chapter Introduction
527 @cindex introduction
529 GNU @code{troff} (or @code{groff}) is a system for typesetting
530 documents.  @code{troff} is very flexible and has been used extensively
531 for some thirty years.  It is well entrenched in the @acronym{UNIX}
532 community.
534 @menu
535 * What Is groff?::
536 * History::
537 * groff Capabilities::
538 * Macro Package Intro::
539 * Preprocessor Intro::
540 * Output device intro::
541 * Credits::
542 @end menu
545 @c =====================================================================
547 @node What Is groff?, History, Introduction, Introduction
548 @section What Is @code{groff}?
549 @cindex what is @code{groff}?
550 @cindex @code{groff} -- what is it?
552 @code{groff} belongs to an older generation of document preparation
553 systems, which operate more like compilers than the more recent
554 interactive @acronym{WYSIWYG}@footnote{What You See Is What You Get}
555 systems.  @code{groff} and its contemporary counterpart, @TeX{}, both
556 work using a @dfn{batch} paradigm: The input (or @dfn{source}) files are
557 normal text files with embedded formatting commands.  These files can
558 then be processed by @code{groff} to produce a typeset document on a
559 variety of devices.
561 @code{groff} should not be confused with a @dfn{word processor}, an
562 integrated system of editor and text formatter.  Also, many word
563 processors follow the @acronym{WYSIWYG} paradigm discussed earlier.
565 Although @acronym{WYSIWYG} systems may be easier to use, they have a
566 number of disadvantages compared to @code{troff}:
568 @itemize @bullet
569 @item
570 They must be used on a graphics display to work on a document.
572 @item
573 Most of the @acronym{WYSIWYG} systems are either non-free or are not
574 very portable.
576 @item
577 @code{troff} is firmly entrenched in all @acronym{UNIX} systems.
579 @item
580 It is difficult to have a wide range of capabilities within the confines
581 of a GUI/window system.
583 @item
584 It is more difficult to make global changes to a document.
585 @end itemize
587 @quotation
588 ``GUIs normally make it simple to accomplish simple actions and
589 impossible to accomplish complex actions.''  --Doug Gwyn (22/Jun/91 in
590 @code{comp.unix.wizards})
591 @end quotation
594 @c =====================================================================
596 @node History, groff Capabilities, What Is groff?, Introduction
597 @section History
598 @cindex history
600 @cindex @code{RUNOFF}, the program
601 @cindex @code{rf}, the program
602 @code{troff} can trace its origins back to a formatting program called
603 @code{RUNOFF}, written by Jerry Saltzer, which ran on the @acronym{CTSS}
604 (@emph{Compatible Time Sharing System}, a project of MIT, the
605 Massachusetts Institute of Technology) in the
606 mid-sixties.@footnote{Jerome H.@: Saltzer, a grad student then, later a
607 Professor of Electrical Engineering, now retired.  Saltzer's PhD thesis
608 was the first application for @code{RUNOFF} and is available from the
609 MIT Libraries.}  The name came from the use of the phrase ``run off a
610 document'', meaning to print it out.
612 @c Tom Van Vleck <thvv@multicians.org> writes about the following:
614 @c I am not sure about this.. I think the BCPL runoff was the port to
615 @c the 635 architecture, and that the order of events is
616 @c 1. CTSS runoff
617 @c 2. BCPL runoff on Multics
618 @c 3. BCPL runoff on 635
619 @c 4. rf on PDP-7
621 Bob Morris ported it to the 635 architecture and called the program
622 @code{roff} (an abbreviation of @code{runoff}).  It was rewritten as
623 @code{rf} for the @w{PDP-7} (before having @acronym{UNIX}), and at the
624 same time (1969), Doug McIllroy rewrote an extended and simplified
625 version of @code{roff} in the @acronym{BCPL} programming language.
627 @cindex @code{roff}, the program
628 In 1971, the UNIX developers wanted to get a @w{PDP-11}, and to justify
629 the cost, proposed the development of a document formatting system for
630 the @acronym{AT&T} patents division.  This first formatting program was
631 a reimplementation of McIllroy's @code{roff}, written by J.@tie{}F.@:
632 Ossanna.
634 @cindex @code{nroff}, the program
635 When they needed a more flexible language, a new version of @code{roff}
636 called @code{nroff} (``Newer @code{roff}'') was written.  It had a much
637 more complicated syntax, but provided the basis for all future versions.
638 When they got a Graphic Systems CAT Phototypesetter, Ossanna wrote a
639 version of @code{nroff} that would drive it.  It was dubbed
640 @code{troff}, for ``typesetter @code{roff}'', although many people have
641 speculated that it actually means ``Times @code{roff}'' because of the
642 use of the Times font family in @code{troff} by default.  As such, the
643 name @code{troff} is pronounced `@w{t-roff}' rather than `trough'.
645 With @code{troff} came @code{nroff} (they were actually the same program
646 except for some @samp{#ifdef}s), which was for producing output for line
647 printers and character terminals.  It understood everything @code{troff}
648 did, and ignored the commands which were not applicable (e.g.@: font
649 changes).
651 Since there are several things which cannot be done easily in
652 @code{troff}, work on several preprocessors began.  These programs would
653 transform certain parts of a document into @code{troff}, which made a
654 very natural use of pipes in @acronym{UNIX}.
656 The @code{eqn} preprocessor allowed mathematical formulæ to be specified
657 in a much simpler and more intuitive manner.  @code{tbl} is a
658 preprocessor for formatting tables.  The @code{refer} preprocessor (and
659 the similar program, @code{bib}) processes citations in a document
660 according to a bibliographic database.
662 Unfortunately, Ossanna's @code{troff} was written in @w{PDP-11} assembly
663 language and produced output specifically for the CAT phototypesetter.
664 He rewrote it in C, although it was now 7000@tie{}lines of uncommented
665 code and still dependent on the CAT.  As the CAT became less common, and
666 was no longer supported by the manufacturer, the need to make it support
667 other devices became a priority.  However, before this could be done,
668 Ossanna died by a severe heart attack in a hospital while recovering
669 from a previous one.
671 @pindex ditroff
672 @cindex @code{ditroff}, the program
673 So, Brian Kernighan took on the task of rewriting @code{troff}.  The
674 newly rewritten version produced device independent code which was very
675 easy for postprocessors to read and translate to the appropriate printer
676 codes.  Also, this new version of @code{troff} (called @code{ditroff}
677 for ``device independent @code{troff}'') had several extensions, which
678 included drawing functions.
680 Due to the additional abilities of the new version of @code{troff},
681 several new preprocessors appeared.  The @code{pic} preprocessor
682 provides a wide range of drawing functions.  Likewise the @code{ideal}
683 preprocessor did the same, although via a much different paradigm.  The
684 @code{grap} preprocessor took specifications for graphs, but, unlike
685 other preprocessors, produced @code{pic} code.
687 James Clark began work on a GNU implementation of @code{ditroff} in
688 early@tie{}1989.  The first version, @code{groff}@tie{}0.3.1, was
689 released June@tie{}1990.  @code{groff} included:
691 @itemize @bullet
692 @item
693 A replacement for @code{ditroff} with many extensions.
695 @item
696 The @code{soelim}, @code{pic}, @code{tbl}, and @code{eqn} preprocessors.
698 @item
699 Postprocessors for character devices, @sc{PostScript}, @TeX{} DVI, and
700 X@tie{}Windows.  GNU @code{troff} also eliminated the need for a
701 separate @code{nroff} program with a postprocessor which would produce
702 @acronym{ASCII} output.
704 @item
705 A version of the @file{me} macros and an implementation of the
706 @file{man} macros.
707 @end itemize
709 Also, a front-end was included which could construct the, sometimes
710 painfully long, pipelines required for all the post- and preprocessors.
712 Development of GNU @code{troff} progressed rapidly, and saw the
713 additions of a replacement for @code{refer}, an implementation of the
714 @file{ms} and @file{mm} macros, and a program to deduce how to format a
715 document (@code{grog}).
717 It was declared a stable (i.e.@: non-beta) package with the release of
718 version@tie{}1.04 around November@tie{}1991.
720 Beginning in@tie{}1999, @code{groff} has new maintainers (the package
721 was an orphan for a few years).  As a result, new features and programs
722 like @code{grn}, a preprocessor for gremlin images, and an output device
723 to produce @acronym{HTML} and @acronym{XHTML} have been added.
726 @c =====================================================================
728 @node groff Capabilities, Macro Package Intro, History, Introduction
729 @section @code{groff} Capabilities
730 @cindex @code{groff} capabilities
731 @cindex capabilities of @code{groff}
733 So what exactly is @code{groff} capable of doing?  @code{groff} provides
734 a wide range of low-level text formatting operations.  Using these, it
735 is possible to perform a wide range of formatting tasks, such as
736 footnotes, table of contents, multiple columns, etc.  Here's a list of
737 the most important operations supported by @code{groff}:
739 @itemize @bullet
740 @item
741 text filling, adjusting, and centering
743 @item
744 hyphenation
746 @item
747 page control
749 @item
750 font and glyph size control
752 @item
753 vertical spacing (e.g.@: double-spacing)
755 @item
756 line length and indenting
758 @item
759 macros, strings, diversions, and traps
761 @item
762 number registers
764 @item
765 tabs, leaders, and fields
767 @item
768 input and output conventions and character translation
770 @item
771 overstrike, bracket, line drawing, and zero-width functions
773 @item
774 local horizontal and vertical motions and the width function
776 @item
777 three-part titles
779 @item
780 output line numbering
782 @item
783 conditional acceptance of input
785 @item
786 environment switching
788 @item
789 insertions from the standard input
791 @item
792 input/output file switching
794 @item
795 output and error messages
796 @end itemize
799 @c =====================================================================
801 @node Macro Package Intro, Preprocessor Intro, groff Capabilities, Introduction
802 @section Macro Packages
803 @cindex macro packages
805 Since @code{groff} provides such low-level facilities, it can be quite
806 difficult to use by itself.  However, @code{groff} provides a
807 @dfn{macro} facility to specify how certain routine operations
808 (e.g.@tie{}starting paragraphs, printing headers and footers, etc.)@:
809 should be done.  These macros can be collected together into a
810 @dfn{macro package}.  There are a number of macro packages available;
811 the most common (and the ones described in this manual) are @file{man},
812 @file{mdoc}, @file{me}, @file{ms}, and @file{mm}.
815 @c =====================================================================
817 @node Preprocessor Intro, Output device intro, Macro Package Intro, Introduction
818 @section Preprocessors
819 @cindex preprocessors
821 Although @code{groff} provides most functions needed to format a
822 document, some operations would be unwieldy (e.g.@: to draw pictures).
823 Therefore, programs called @dfn{preprocessors} were written which
824 understand their own language and produce the necessary @code{groff}
825 operations.  These preprocessors are able to differentiate their own
826 input from the rest of the document via markers.
828 To use a preprocessor, @acronym{UNIX} pipes are used to feed the output
829 from the preprocessor into @code{groff}.  Any number of preprocessors
830 may be used on a given document; in this case, the preprocessors are
831 linked together into one pipeline.  However, with @code{groff}, the user
832 does not need to construct the pipe, but only tell @code{groff} what
833 preprocessors to use.
835 @code{groff} currently has preprocessors for producing tables
836 (@code{tbl}), typesetting equations (@code{eqn}), drawing pictures
837 (@code{pic} and @code{grn}), and for processing bibliographies
838 (@code{refer}).  An associated program which is useful when dealing with
839 preprocessors is @code{soelim}.
841 A free implementation of @code{grap}, a preprocessor for drawing graphs,
842 can be obtained as an extra package; @code{groff} can use @code{grap}
843 also.
845 There are other preprocessors in existence, but, unfortunately, no free
846 implementations are available.  Among them are preprocessors for drawing
847 mathematical pictures (@code{ideal}) and chemical structures
848 (@code{chem}).
851 @c =====================================================================
853 @node Output device intro, Credits, Preprocessor Intro, Introduction
854 @section Output Devices
855 @cindex postprocessors
856 @cindex output devices
857 @cindex devices for output
859 @code{groff} actually produces device independent code which may be fed
860 into a postprocessor to produce output for a particular device.
861 Currently, @code{groff} has postprocessors for @sc{PostScript} devices,
862 character terminals, X@tie{}Windows (for previewing), @TeX{} DVI format,
863 HP LaserJet@tie{}4 and Canon LBP printers (which use @acronym{CAPSL}),
864 @acronym{HTML}, and @acronym{XHTML}.
867 @c =====================================================================
869 @node Credits,  , Output device intro, Introduction
870 @section Credits
871 @cindex credits
873 Large portions of this manual were taken from existing documents, most
874 notably, the manual pages for the @code{groff} package by James Clark,
875 and Eric Allman's papers on the @file{me} macro package.
877 The section on the @file{man} macro package is partly based on
878 Susan@tie{}G.@: Kleinmann's @file{groff_man} manual page written for the
879 Debian GNU/Linux system.
881 Larry Kollar contributed the section in the @file{ms} macro package.
885 @c =====================================================================
886 @c =====================================================================
888 @node Invoking groff, Tutorial for Macro Users, Introduction, Top
889 @chapter Invoking @code{groff}
890 @cindex invoking @code{groff}
891 @cindex @code{groff} invocation
893 This section focuses on how to invoke the @code{groff} front end.  This
894 front end takes care of the details of constructing the pipeline among
895 the preprocessors, @code{gtroff} and the postprocessor.
897 It has become a tradition that GNU programs get the prefix @samp{g} to
898 distinguish it from its original counterparts provided by the host (see
899 @ref{Environment}, for more details).  Thus, for example, @code{geqn} is
900 GNU @code{eqn}.  On operating systems like GNU/Linux or the Hurd, which
901 don't contain proprietary versions of @code{troff}, and on
902 MS-DOS/MS-Windows, where @code{troff} and associated programs are not
903 available at all, this prefix is omitted since GNU @code{troff} is the
904 only used incarnation of @code{troff}.  Exception: @samp{groff} is never
905 replaced by @samp{roff}.
907 In this document, we consequently say @samp{gtroff} when talking about
908 the GNU @code{troff} program.  All other implementations of @code{troff}
909 are called @acronym{AT&T} @code{troff} which is the common origin of all
910 @code{troff} derivates (with more or less compatible changes).
911 Similarly, we say @samp{gpic}, @samp{geqn}, etc.
913 @menu
914 * Groff Options::
915 * Environment::
916 * Macro Directories::
917 * Font Directories::
918 * Paper Size::
919 * Invocation Examples::
920 @end menu
923 @c =====================================================================
925 @node Groff Options, Environment, Invoking groff, Invoking groff
926 @section Options
927 @cindex options
929 @pindex groff
930 @pindex gtroff
931 @pindex gpic
932 @pindex geqn
933 @pindex ggrn
934 @pindex grap
935 @pindex gtbl
936 @pindex grefer
937 @pindex gsoelim
938 @code{groff} normally runs the @code{gtroff} program and a postprocessor
939 appropriate for the selected device.  The default device is @samp{ps}
940 (but it can be changed when @code{groff} is configured and built).  It
941 can optionally preprocess with any of @code{gpic}, @code{geqn},
942 @code{gtbl}, @code{ggrn}, @code{grap}, @code{grefer}, or @code{gsoelim}.
944 This section only documents options to the @code{groff} front end.  Many
945 of the arguments to @code{groff} are passed on to @code{gtroff},
946 therefore those are also included.  Arguments to pre- or postprocessors
947 can be found in @ref{Invoking gpic}, @ref{Invoking geqn}, @ref{Invoking
948 gtbl}, @ref{Invoking ggrn}, @ref{Invoking grefer}, @ref{Invoking
949 gsoelim}, @ref{Invoking grotty}, @ref{Invoking grops}, @ref{Invoking
950 grohtml}, @ref{Invoking grodvi}, @ref{Invoking grolj4}, @ref{Invoking
951 grolbp}, and @ref{Invoking gxditview}.
953 The command line format for @code{groff} is:
955 @Example
956 groff [ -abceghilpstvzCEGNRSUVXZ ] [ -F@var{dir} ] [ -m@var{name} ]
957       [ -T@var{def} ] [ -f@var{fam} ] [ -w@var{name} ] [ -W@var{name} ]
958       [ -M@var{dir} ] [ -d@var{cs} ] [ -r@var{cn} ] [ -n@var{num} ]
959       [ -o@var{list} ] [ -P@var{arg} ] [ -L@var{arg} ] [ -I@var{dir} ]
960       [ @var{files}@dots{} ]
961 @endExample
963 The command line format for @code{gtroff} is as follows.
965 @Example
966 gtroff [ -abcivzCERU ] [ -w@var{name} ] [ -W@var{name} ] [ -d@var{cs} ]
967        [ -f@var{fam} ] [ -m@var{name} ] [ -n@var{num} ]
968        [ -o@var{list} ] [ -r@var{cn} ] [ -T@var{name} ]
969        [ -F@var{dir} ] [ -M@var{dir} ] [ @var{files}@dots{} ]
970 @endExample
972 @noindent
973 Obviously, many of the options to @code{groff} are actually passed on to
974 @code{gtroff}.
976 Options without an argument can be grouped behind a
977 single@tie{}@option{-}.  A filename of@tie{}@file{-} denotes the
978 standard input.  It is possible to have whitespace between an option and
979 its parameter.
981 The @code{grog} command can be used to guess the correct @code{groff}
982 command to format a file.
984 Here's the description of the command-line options:
986 @cindex command-line options
987 @table @samp
988 @item -h
989 Print a help message.
991 @item -e
992 Preprocess with @code{geqn}.
994 @item -t
995 Preprocess with @code{gtbl}.
997 @item -g
998 Preprocess with @code{ggrn}.
1000 @item -G
1001 Preprocess with @code{grap}.
1003 @item -p
1004 Preprocess with @code{gpic}.
1006 @item -s
1007 Preprocess with @code{gsoelim}.
1009 @item -c
1010 Suppress color output.
1012 @item -R
1013 Preprocess with @code{grefer}.  No mechanism is provided for passing
1014 arguments to @code{grefer} because most @code{grefer} options have
1015 equivalent commands which can be included in the file.  @xref{grefer},
1016 for more details.
1018 @pindex troffrc
1019 @pindex troffrc-end
1020 Note that @code{gtroff} also accepts a @option{-R} option, which is not
1021 accessible via @code{groff}.  This option prevents the loading of the
1022 @file{troffrc} and @file{troffrc-end} files.
1024 @item -v
1025 Make programs run by @code{groff} print out their version number.
1027 @item -V
1028 Print the pipeline on @code{stdout} instead of executing it.  If
1029 specified more than once, print the pipeline on @code{stderr} and
1030 execute it.
1032 @item -z
1033 Suppress output from @code{gtroff}.  Only error messages are printed.
1035 @item -Z
1036 Do not postprocess the output of @code{gtroff}.  Normally @code{groff}
1037 automatically runs the appropriate postprocessor.
1039 @item -P@var{arg}
1040 Pass @var{arg} to the postprocessor.  Each argument should be passed
1041 with a separate @option{-P} option.  Note that @code{groff} does not
1042 prepend @samp{-} to @var{arg} before passing it to the postprocessor.
1044 @item -l
1045 Send the output to a spooler for printing.  The command used for this is
1046 specified by the @code{print} command in the device description file
1047 (see @ref{Font Files}, for more info).  If not present, @option{-l} is
1048 ignored.
1050 @item -L@var{arg}
1051 Pass @var{arg} to the spooler.  Each argument should be passed with a
1052 separate @option{-L} option.  Note that @code{groff} does not prepend a
1053 @samp{-} to @var{arg} before passing it to the postprocessor.  If the
1054 @code{print} keyword in the device description file is missing,
1055 @option{-L} is ignored.
1057 @item -T@var{dev}
1058 Prepare output for device @var{dev}.  The default device is @samp{ps},
1059 unless changed when @code{groff} was configured and built.  The
1060 following are the output devices currently available:
1062 @table @code
1063 @item ps
1064 For @sc{PostScript} printers and previewers.
1066 @item dvi
1067 For @TeX{} DVI format.
1069 @item X75
1070 For a 75@dmn{dpi} X11 previewer.
1072 @item X75-12
1073 For a 75@dmn{dpi} X11 previewer with a 12@dmn{pt} base font in the
1074 document.
1076 @item X100
1077 For a 100@dmn{dpi} X11 previewer.
1079 @item X100-12
1080 For a 100@dmn{dpi} X11 previewer with a 12@dmn{pt} base font in the
1081 document.
1083 @item ascii
1084 @cindex encoding, output, @acronym{ASCII}
1085 @cindex @acronym{ASCII}, output encoding
1086 @cindex output encoding, @acronym{ASCII}
1087 For typewriter-like devices using the (7-bit) @acronym{ASCII}
1088 character set.
1090 @item latin1
1091 @cindex encoding, output, @w{latin-1} (ISO @w{8859-1})
1092 @cindex @w{latin-1} (ISO @w{8859-1}), output encoding
1093 @cindex ISO @w{8859-1} (@w{latin-1}), output encoding
1094 @cindex output encoding, @w{latin-1} (ISO @w{8859-1})
1095 For typewriter-like devices that support the @w{Latin-1}
1096 (ISO@tie{}@w{8859-1}) character set.
1098 @item utf8
1099 @cindex encoding, output, @w{utf-8}
1100 @cindex @w{utf-8}, output encoding
1101 @cindex output encoding, @w{utf-8}
1102 For typewriter-like devices which use the Unicode (ISO@tie{}10646)
1103 character set with @w{UTF-8} encoding.
1105 @item cp1047
1106 @cindex encoding, output, @acronym{EBCDIC}
1107 @cindex @acronym{EBCDIC}, output encoding
1108 @cindex output encoding, @acronym{EBCDIC}
1109 @cindex encoding, output, cp1047
1110 @cindex cp1047, output encoding
1111 @cindex output encoding, cp1047
1112 @cindex IBM cp1047 output encoding
1113 For typewriter-like devices which use the @acronym{EBCDIC} encoding IBM
1114 cp1047.
1116 @item lj4
1117 For HP LaserJet4-compatible (or other PCL5-compatible) printers.
1119 @item lbp
1120 For Canon @acronym{CAPSL} printers (@w{LBP-4} and @w{LBP-8} series laser
1121 printers).
1123 @pindex pre-grohtml
1124 @pindex post-grohtml
1125 @cindex @code{grohtml}, the program
1126 @item html
1127 @itemx xhtml
1128 To produce @acronym{HTML} and @acronym{XHTML} output, respectively.
1129 Note that this driver consists of two parts, a preprocessor
1130 (@code{pre-grohtml}) and a postprocessor (@code{post-grohtml}).
1131 @end table
1133 @cindex output device name string register (@code{.T})
1134 @cindex output device usage number register (@code{.T})
1135 The predefined @code{gtroff} string register @code{.T} contains the
1136 current output device; the read-only number register @code{.T} is set
1137 to@tie{}1 if this option is used (which is always true if @code{groff}
1138 is used to call @code{gtroff}).  @xref{Built-in Registers}.
1140 The postprocessor to be used for a device is specified by the
1141 @code{postpro} command in the device description file.  (@xref{Font
1142 Files}, for more info.)  This can be overridden with the @option{-X}
1143 option.
1145 @item -X
1146 Preview with @code{gxditview} instead of using the usual postprocessor.
1147 This is unlikely to produce good results except with @option{-Tps}.
1149 Note that this is not the same as using @option{-TX75} or
1150 @option{-TX100} to view a document with @code{gxditview}: The former
1151 uses the metrics of the specified device, whereas the latter uses
1152 X-specific fonts and metrics.
1154 @item -N
1155 Don't allow newlines with @code{eqn} delimiters.  This is the same as
1156 the @option{-N} option in @code{geqn}.
1158 @item -S
1159 @cindex @code{open} request, and safer mode
1160 @cindex @code{opena} request, and safer mode
1161 @cindex @code{pso} request, and safer mode
1162 @cindex @code{sy} request, and safer mode
1163 @cindex @code{pi} request, and safer mode
1164 @cindex safer mode
1165 @cindex mode, safer
1166 Safer mode.  Pass the @option{-S} option to @code{gpic} and disable the
1167 @code{open}, @code{opena}, @code{pso}, @code{sy}, and @code{pi}
1168 requests.  For security reasons, this is enabled by default.
1170 @item -U
1171 @cindex mode, unsafe
1172 @cindex unsafe mode
1173 Unsafe mode.  This enables the @code{open}, @code{opena}, @code{pso},
1174 @code{sy}, and @code{pi} requests.
1176 @item -a
1177 @cindex @acronym{ASCII} approximation output register (@code{.A})
1178 Generate an @acronym{ASCII} approximation of the typeset output.  The
1179 read-only register @code{.A} is then set to@tie{}1.  @xref{Built-in
1180 Registers}.  A typical example is
1182 @Example
1183 groff -a -man -Tdvi troff.man | less
1184 @endExample
1186 @noindent
1187 which shows how lines are broken for the DVI device.  Note that this
1188 option is rather useless today since graphic output devices are
1189 available virtually everywhere.
1191 @item -b
1192 Print a backtrace with each warning or error message.  This backtrace
1193 should help track down the cause of the error.  The line numbers given
1194 in the backtrace may not always be correct: @code{gtroff} can get
1195 confused by @code{as} or @code{am} requests while counting line numbers.
1197 @item -i
1198 Read the standard input after all the named input files have been
1199 processed.
1201 @item -w@var{name}
1202 Enable warning @var{name}.  Available warnings are described in
1203 @ref{Debugging}.  Multiple @option{-w} options are allowed.
1205 @item -W@var{name}
1206 Inhibit warning @var{name}.  Multiple @option{-W} options are allowed.
1208 @item -E
1209 Inhibit all error messages.
1211 @item -C
1212 Enable compatibility mode.  @xref{Implementation Differences}, for the
1213 list of incompatibilities between @code{groff} and @acronym{AT&T}
1214 @code{troff}.
1216 @item -d@var{c}@var{s}
1217 @itemx -d@var{name}=@var{s}
1218 Define @var{c} or @var{name} to be a string@tie{}@var{s}.
1219 @var{c}@tie{}must be a one-letter name; @var{name} can be of arbitrary
1220 length.  All string assignments happen before loading any macro file
1221 (including the start-up file).
1223 @item -f@var{fam}
1224 Use @var{fam} as the default font family.  @xref{Font Families}.
1226 @item -m@var{name}
1227 Read in the file @file{@var{name}.tmac}.  Normally @code{groff} searches
1228 for this in its macro directories.  If it isn't found, it tries
1229 @file{tmac.@var{name}} (searching in the same directories).
1231 @item -n@var{num}
1232 Number the first page @var{num}.
1234 @item -o@var{list}
1235 @cindex print current page register (@code{.P})
1236 Output only pages in @var{list}, which is a comma-separated list of page
1237 ranges; @samp{@var{n}} means print page@tie{}@var{n},
1238 @samp{@var{m}-@var{n}} means print every page between @var{m}
1239 and@tie{}@var{n}, @samp{-@var{n}} means print every page up
1240 to@tie{}@var{n}, @samp{@var{n}-} means print every page beginning
1241 with@tie{}@var{n}.  @code{gtroff} exits after printing the last page in
1242 the list.  All the ranges are inclusive on both ends.
1244 Within @code{gtroff}, this information can be extracted with the
1245 @samp{.P} register.  @xref{Built-in Registers}.
1247 If your document restarts page numbering at the beginning of each
1248 chapter, then @code{gtroff} prints the specified page range for each
1249 chapter.
1251 @item -r@var{c}@var{n}
1252 @itemx -r@var{name}=@var{n}
1253 Set number register@tie{}@var{c} or @var{name} to the
1254 value@tie{}@var{n}.  @var{c}@tie{}must be a one-letter name; @var{name}
1255 can be of arbitrary length.  @var{n}@tie{}can be any @code{gtroff}
1256 numeric expression.  All register assignments happen before loading any
1257 macro file (including the start-up file).
1259 @item -F@var{dir}
1260 Search @file{@var{dir}} for subdirectories @file{dev@var{name}}
1261 (@var{name} is the name of the device), for the @file{DESC} file, and
1262 for font files before looking in the standard directories (@pxref{Font
1263 Directories}).  This option is passed to all pre- and postprocessors
1264 using the @env{GROFF_FONT_PATH} environment variable.
1266 @item -M@var{dir}
1267 Search directory @file{@var{dir}} for macro files before the standard
1268 directories (@pxref{Macro Directories}).
1270 @item -I@var{dir}
1271 This option may be used to specify a directory to search for files.
1272 It is passed to the following programs:
1274 @itemize
1275 @item
1276 @code{gsoelim} (see @ref{gsoelim} for more details);
1277 it also implies @code{groff}'s @option{-s} option.
1279 @item
1280 @code{gtroff}; it is used to search files named in the @code{psbb} and
1281 @code{so} requests.
1283 @item
1284 @code{grops}; it is used to search files named in the
1285 @w{@code{\X'ps: import}} and @w{@code{\X'ps: file}} escapes.
1286 @end itemize
1288 The current directory is always searched first.  This option may be
1289 specified more than once; the directories are searched in the order
1290 specified.  No directory search is performed for files specified using
1291 an absolute path.
1292 @end table
1295 @c =====================================================================
1297 @node Environment, Macro Directories, Groff Options, Invoking groff
1298 @section Environment
1299 @cindex environment variables
1300 @cindex variables in environment
1302 There are also several environment variables (of the operating system,
1303 not within @code{gtroff}) which can modify the behavior of @code{groff}.
1305 @table @code
1306 @item GROFF_COMMAND_PREFIX
1307 @tindex GROFF_COMMAND_PREFIX@r{, environment variable}
1308 @cindex command prefix
1309 @cindex prefix, for commands
1310 If this is set to@tie{}@var{X}, then @code{groff} runs
1311 @code{@var{X}troff} instead of @code{gtroff}.  This also applies to
1312 @code{tbl}, @code{pic}, @code{eqn}, @code{grn}, @code{refer}, and
1313 @code{soelim}.  It does not apply to @code{grops}, @code{grodvi},
1314 @code{grotty}, @code{pre-grohtml}, @code{post-grohtml}, @code{grolj4},
1315 and @code{gxditview}.
1317 The default command prefix is determined during the installation
1318 process.  If a non-GNU troff system is found, prefix @samp{g} is used,
1319 none otherwise.
1321 @item GROFF_TMAC_PATH
1322 @tindex GROFF_TMAC_PATH@r{, environment variable}
1323 A colon-separated list of directories in which to search for macro files
1324 (before the default directories are tried).  @xref{Macro Directories}.
1326 @item GROFF_TYPESETTER
1327 @tindex GROFF_TYPESETTER@r{, environment variable}
1328 The default output device.
1330 @item GROFF_FONT_PATH
1331 @tindex GROFF_FONT_PATH@r{, environment variable}
1332 A colon-separated list of directories in which to search for the
1333 @code{dev}@var{name} directory (before the default directories are
1334 tried).  @xref{Font Directories}.
1336 @item GROFF_BIN_PATH
1337 @tindex GROFF_BIN_PATH@r{, environment variable}
1338 This search path, followed by @code{PATH}, is used for commands executed
1339 by @code{groff}.
1341 @item GROFF_TMPDIR
1342 @tindex GROFF_TMPDIR@r{, environment variable}
1343 @tindex TMPDIR@r{, environment variable}
1344 The directory in which @code{groff} creates temporary files.  If this is
1345 not set and @env{TMPDIR} is set, temporary files are created in that
1346 directory.  Otherwise temporary files are created in a system-dependent
1347 default directory (on Unix and GNU/Linux systems, this is usually
1348 @file{/tmp}).  @code{grops}, @code{grefer}, @code{pre-grohtml}, and
1349 @code{post-grohtml} can create temporary files in this directory.
1350 @end table
1352 Note that MS-DOS and MS-Windows ports of @code{groff} use semi-colons,
1353 rather than colons, to separate the directories in the lists described
1354 above.
1357 @c =====================================================================
1359 @node Macro Directories, Font Directories, Environment, Invoking groff
1360 @section Macro Directories
1361 @cindex macro directories
1362 @cindex directories for macros
1363 @cindex searching macros
1364 @cindex macros, searching
1366 All macro file names must be named @code{@var{name}.tmac} or
1367 @code{tmac.@var{name}} to make the @option{-m@var{name}} command line
1368 option work.  The @code{mso} request doesn't have this restriction; any
1369 file name can be used, and @code{gtroff} won't try to append or prepend
1370 the @samp{tmac} string.
1372 @cindex tmac, directory
1373 @cindex directory, for tmac files
1374 @cindex tmac, path
1375 @cindex path, for tmac files
1376 @cindex searching macro files
1377 @cindex macro files, searching
1378 @cindex files, macro, searching
1379 Macro files are kept in the @dfn{tmac directories}, all of which
1380 constitute the @dfn{tmac path}.  The elements of the search path for
1381 macro files are (in that order):
1383 @itemize @bullet
1384 @item
1385 The directories specified with @code{gtroff}'s or @code{groff}'s
1386 @option{-M} command line option.
1388 @item
1389 @tindex GROFF_TMAC_PATH@r{, environment variable}
1390 The directories given in the @env{GROFF_TMAC_PATH} environment variable.
1392 @item
1393 @cindex safer mode
1394 @cindex mode, safer
1395 @cindex unsafe mode
1396 @cindex mode, unsafe
1397 @cindex current directory
1398 @cindex directory, current
1399 The current directory (only if in unsafe mode using the @option{-U}
1400 command line switch).
1402 @item
1403 @cindex home directory
1404 @cindex directory, home
1405 The home directory.
1407 @item
1408 @cindex site-specific directory
1409 @cindex directory, site-specific
1410 @cindex platform-specific directory
1411 @cindex directory, platform-specific
1412 A platform-dependent directory, a site-specific (platform-independent)
1413 directory, and the main tmac directory; the default locations are
1415 @Example
1416 /usr/local/lib/groff/site-tmac
1417 /usr/local/share/groff/site-tmac
1418 /usr/local/share/groff/1.18.2/tmac
1419 @endExample
1421 @noindent
1422 assuming that the version of @code{groff} is 1.18.2, and the
1423 installation prefix was @file{/usr/local}.  It is possible to fine-tune
1424 those directories during the installation process.
1425 @end itemize
1428 @c =====================================================================
1430 @node Font Directories, Paper Size, Macro Directories, Invoking groff
1431 @section Font Directories
1432 @cindex font directories
1433 @cindex directories for fonts
1434 @cindex searching fonts
1435 @cindex fonts, searching
1437 Basically, there is no restriction how font files for @code{groff} are
1438 named and how long font names are; however, to make the font family
1439 mechanism work (@pxref{Font Families}), fonts within a family should
1440 start with the family name, followed by the shape.  For example, the
1441 Times family uses @samp{T} for the family name and @samp{R}, @samp{B},
1442 @samp{I}, and @samp{BI} to indicate the shapes `roman', `bold',
1443 `italic', and `bold italic', respectively.  Thus the final font names
1444 are @samp{TR}, @samp{TB}, @samp{TI}, and @samp{TBI}.
1446 @cindex font path
1447 @cindex path, for font files
1448 All font files are kept in the @dfn{font directories} which constitute
1449 the @dfn{font path}.  The file search functions always append the
1450 directory @code{dev}@var{name}, where @var{name} is the name of the
1451 output device.  Assuming, say, DVI output, and @file{/foo/bar} as a font
1452 directory, the font files for @code{grodvi} must be in
1453 @file{/foo/bar/devdvi}.
1455 The elements of the search path for font files are (in that order):
1457 @itemize @bullet
1458 @item
1459 The directories specified with @code{gtroff}'s or @code{groff}'s
1460 @option{-F} command line option.  All device drivers and some
1461 preprocessors also have this option.
1463 @item
1464 @tindex GROFF_FONT_PATH@r{, environment variable}
1465 The directories given in the @env{GROFF_FONT_PATH} environment variable.
1467 @item
1468 @cindex site-specific directory
1469 @cindex directory, site-specific
1470 A site-specific directory and the main font directory; the default
1471 locations are
1473 @Example
1474 /usr/local/share/groff/site-font
1475 /usr/local/share/groff/1.18.2/font
1476 @endExample
1478 @noindent
1479 assuming that the version of @code{groff} is 1.18.2, and the
1480 installation prefix was @file{/usr/local}.  It is possible to fine-tune
1481 those directories during the installation process.
1482 @end itemize
1485 @c =====================================================================
1487 @node Paper Size, Invocation Examples, Font Directories, Invoking groff
1488 @section Paper Size
1489 @cindex paper size
1490 @cindex size, paper
1491 @cindex landscape page orientation
1492 @cindex orientation, landscape
1493 @cindex page orientation, landscape
1495 In groff, the page size for @code{gtroff} and for output devices are
1496 handled separately.  @xref{Page Layout}, for vertical manipulation of
1497 the page size.  @xref{Line Layout}, for horizontal changes.
1499 A default paper size can be set in the device's @file{DESC} file.  Most
1500 output devices also have a command line option @option{-p} to override
1501 the default paper size and option @option{-l} to use landscape
1502 orientation.  @xref{DESC File Format}, for a description of the
1503 @code{papersize} keyword which takes the same argument as @option{-p}.
1505 @pindex papersize.tmac
1506 @pindex troffrc
1507 A convenient shorthand to set a particular paper size for @code{gtroff}
1508 is command line option @option{-dpaper=@var{size}}.  This defines string
1509 @code{paper} which is processed in file @file{papersize.tmac} (loaded in
1510 the start-up file @file{troffrc} by default).  Possible values for
1511 @var{size} are the same as the predefined values for the
1512 @code{papersize} keyword (but only in lowercase) except
1513 @code{a7}-@code{d7}.  An appended @samp{l} (ell) character denotes
1514 landscape orientation.
1516 For example, use the following for PS output on A4 paper in landscape
1517 orientation:
1519 @Example
1520 groff -Tps -dpaper=a4l -P-pa4 -P-l -ms foo.ms > foo.ps
1521 @endExample
1523 Note that it is up to the particular macro package to respect default
1524 page dimensions set in this way (most do).
1527 @c =====================================================================
1529 @node Invocation Examples,  , Paper Size, Invoking groff
1530 @section Invocation Examples
1531 @cindex invocation examples
1532 @cindex examples of invocation
1534 This section lists several common uses of @code{groff} and the
1535 corresponding command lines.
1537 @Example
1538 groff file
1539 @endExample
1541 @noindent
1542 This command processes @file{file} without a macro package or a
1543 preprocessor.  The output device is the default, @samp{ps}, and the
1544 output is sent to @code{stdout}.
1546 @Example
1547 groff -t -mandoc -Tascii file | less
1548 @endExample
1550 @noindent
1551 This is basically what a call to the @code{man} program does.
1552 @code{gtroff} processes the manual page @file{file} with the
1553 @file{mandoc} macro file (which in turn either calls the @file{man} or
1554 the @file{mdoc} macro package), using the @code{tbl} preprocessor and
1555 the @acronym{ASCII} output device.  Finally, the @code{less} pager
1556 displays the result.
1558 @Example
1559 groff -X -m me file
1560 @endExample
1562 @noindent
1563 Preview @file{file} with @code{gxditview}, using the @file{me} macro
1564 package.  Since no @option{-T} option is specified, use the default
1565 device (@samp{ps}).  Note that you can either say @w{@samp{-m me}} or
1566 @w{@samp{-me}}; the latter is an anachronism from the early days of
1567 @acronym{UNIX}.@footnote{The same is true for the other main macro
1568 packages that come with @code{groff}: @file{man}, @file{mdoc},
1569 @file{ms}, @file{mm}, and @file{mandoc}.  This won't work in general;
1570 for example, to load @file{trace.tmac}, either @samp{-mtrace} or
1571 @w{@samp{-m trace}} must be used.}
1573 @Example
1574 groff -man -rD1 -z file
1575 @endExample
1577 @noindent
1578 Check @file{file} with the @file{man} macro package, forcing
1579 double-sided printing -- don't produce any output.
1581 @menu
1582 * grog::
1583 @end menu
1585 @c ---------------------------------------------------------------------
1587 @node grog,  , Invocation Examples, Invocation Examples
1588 @subsection @code{grog}
1590 @pindex grog
1591 @code{grog} reads files, guesses which of the @code{groff} preprocessors
1592 and/or macro packages are required for formatting them, and prints the
1593 @code{groff} command including those options on the standard output.  It
1594 generates one or more of the options @option{-e}, @option{-man},
1595 @option{-me}, @option{-mm}, @option{-mom}, @option{-ms}, @option{-mdoc},
1596 @option{-mdoc-old}, @option{-p}, @option{-R}, @option{-g}, @option{-G},
1597 @option{-s}, and @option{-t}.
1599 A special file name@tie{}@file{-} refers to the standard input.
1600 Specifying no files also means to read the standard input.  Any
1601 specified options are included in the printed command.  No space is
1602 allowed between options and their arguments.  The only options
1603 recognized are @option{-C} (which is also passed on) to enable
1604 compatibility mode, and @option{-v} to print the version number and
1605 exit.
1607 For example,
1609 @Example
1610 grog -Tdvi paper.ms
1611 @endExample
1613 @noindent
1614 guesses the appropriate command to print @file{paper.ms} and then prints
1615 it to the command line after adding the @option{-Tdvi} option.  For
1616 direct execution, enclose the call to @code{grog} in backquotes at the
1617 @acronym{UNIX} shell prompt:
1619 @Example
1620 `grog -Tdvi paper.ms` > paper.dvi
1621 @endExample
1623 @noindent
1624 As seen in the example, it is still necessary to redirect the output to
1625 something meaningful (i.e.@: either a file or a pager program like
1626 @code{less}).
1630 @c =====================================================================
1631 @c =====================================================================
1633 @node Tutorial for Macro Users, Macro Packages, Invoking groff, Top
1634 @chapter Tutorial for Macro Users
1635 @cindex tutorial for macro users
1636 @cindex macros, tutorial for users
1637 @cindex user's tutorial for macros
1638 @cindex user's macro tutorial
1640 Most users tend to use a macro package to format their papers.  This
1641 means that the whole breadth of @code{groff} is not necessary for most
1642 people.  This chapter covers the material needed to efficiently use a
1643 macro package.
1645 @menu
1646 * Basics::
1647 * Common Features::
1648 @end menu
1651 @c =====================================================================
1653 @node Basics, Common Features, Tutorial for Macro Users, Tutorial for Macro Users
1654 @section Basics
1655 @cindex basics of macros
1656 @cindex macro basics
1658 This section covers some of the basic concepts necessary to understand
1659 how to use a macro package.@footnote{This section is derived from
1660 @cite{Writing Papers with nroff using -me} by Eric P.@tie{}Allman.}
1661 References are made throughout to more detailed information, if desired.
1663 @code{gtroff} reads an input file prepared by the user and outputs a
1664 formatted document suitable for publication or framing.  The input
1665 consists of text, or words to be printed, and embedded commands
1666 (@dfn{requests} and @dfn{escapes}), which tell @code{gtroff} how to
1667 format the output.  For more detail on this, see @ref{Embedded
1668 Commands}.
1670 The word @dfn{argument} is used in this chapter to mean a word or number
1671 which appears on the same line as a request, and which modifies the
1672 meaning of that request.  For example, the request
1674 @Example
1676 @endExample
1678 @noindent
1679 spaces one line, but
1681 @Example
1682 .sp 4
1683 @endExample
1685 @noindent
1686 spaces four lines.  The number@tie{}4 is an argument to the @code{sp}
1687 request which says to space four lines instead of one.  Arguments are
1688 separated from the request and from each other by spaces (@emph{no}
1689 tabs).  More details on this can be found in @ref{Request and Macro
1690 Arguments}.
1692 The primary function of @code{gtroff} is to collect words from input
1693 lines, fill output lines with those words, justify the right-hand margin
1694 by inserting extra spaces in the line, and output the result.  For
1695 example, the input:
1697 @Example
1698 Now is the time
1699 for all good men
1700 to come to the aid
1701 of their party.
1702 Four score and seven
1703 years ago, etc.
1704 @endExample
1706 @noindent
1707 is read, packed onto output lines, and justified to produce:
1709 @quotation
1710 Now is the time for all good men to come to the aid of their party.
1711 Four score and seven years ago, etc.
1712 @end quotation
1714 @cindex break
1715 @cindex line break
1716 Sometimes a new output line should be started even though the current
1717 line is not yet full; for example, at the end of a paragraph.  To do
1718 this it is possible to cause a @dfn{break}, which starts a new output
1719 line.  Some requests cause a break automatically, as normally do blank
1720 input lines and input lines beginning with a space.
1722 Not all input lines are text to be formatted.  Some input lines are
1723 requests which describe how to format the text.  Requests always have a
1724 period (@samp{.}) or an apostrophe (@samp{'}) as the first character of
1725 the input line.
1727 The text formatter also does more complex things, such as automatically
1728 numbering pages, skipping over page boundaries, putting footnotes in the
1729 correct place, and so forth.
1731 Here are a few hints for preparing text for input to @code{gtroff}.
1733 @itemize @bullet
1734 @item
1735 First, keep the input lines short.  Short input lines are easier to
1736 edit, and @code{gtroff} packs words onto longer lines anyhow.
1738 @item
1739 In keeping with this, it is helpful to begin a new line after every
1740 comma or phrase, since common corrections are to add or delete sentences
1741 or phrases.
1743 @item
1744 End each sentence with two spaces -- or better, start each sentence on a
1745 new line.  @code{gtroff} recognizes characters that usually end a
1746 sentence, and inserts sentence space accordingly.
1748 @item
1749 Do not hyphenate words at the end of lines -- @code{gtroff} is smart
1750 enough to hyphenate words as needed, but is not smart enough to take
1751 hyphens out and join a word back together.  Also, words such as
1752 ``mother-in-law'' should not be broken over a line, since then a space
1753 can occur where not wanted, such as ``@w{mother- in}-law''.
1754 @end itemize
1756 @cindex double-spacing (@code{ls})
1757 @cindex spacing
1758 @code{gtroff} double-spaces output text automatically if you use the
1759 request @w{@samp{.ls 2}}.  Reactivate single-spaced mode by typing
1760 @w{@samp{.ls 1}}.@footnote{If you need finer granularity of the vertical
1761 space, use the @code{pvs} request (@pxref{Changing Type Sizes}).}
1763 A number of requests allow to change the way the output looks, sometimes
1764 called the @dfn{layout} of the output page.  Most of these requests
1765 adjust the placing of @dfn{whitespace} (blank lines or spaces).
1767 @cindex new page (@code{bp})
1768 The @code{bp} request starts a new page, causing a line break.
1770 @cindex blank line (@code{sp})
1771 @cindex empty line (@code{sp})
1772 @cindex line, empty (@code{sp})
1773 The request @w{@samp{.sp @var{N}}} leaves @var{N}@tie{}lines of blank
1774 space.  @var{N}@tie{}can be omitted (meaning skip a single line) or can
1775 be of the form @var{N}i (for @var{N}@tie{}inches) or @var{N}c (for
1776 @var{N}@tie{}centimeters).  For example, the input:
1778 @Example
1779 .sp 1.5i
1780 My thoughts on the subject
1782 @endExample
1784 @noindent
1785 leaves one and a half inches of space, followed by the line ``My
1786 thoughts on the subject'', followed by a single blank line (more
1787 measurement units are available, see @ref{Measurements}).
1789 @cindex centering lines (@code{ce})
1790 @cindex lines, centering (@code{ce})
1791 Text lines can be centered by using the @code{ce} request.  The line
1792 after @code{ce} is centered (horizontally) on the page.  To center more
1793 than one line, use @w{@samp{.ce @var{N}}} (where @var{N} is the number
1794 of lines to center), followed by the @var{N}@tie{}lines.  To center many
1795 lines without counting them, type:
1797 @Example
1798 .ce 1000
1799 lines to center
1800 .ce 0
1801 @endExample
1803 @noindent
1804 The @w{@samp{.ce 0}} request tells @code{groff} to center zero more
1805 lines, in other words, stop centering.
1807 @cindex line break (@code{br})
1808 @cindex break (@code{br})
1809 All of these requests cause a break; that is, they always start a new
1810 line.  To start a new line without performing any other action, use
1811 @code{br}.
1814 @c =====================================================================
1816 @node Common Features,  , Basics, Tutorial for Macro Users
1817 @section Common Features
1818 @cindex common features
1819 @cindex features, common
1821 @code{gtroff} provides very low-level operations for formatting a
1822 document.  There are many common routine operations which are done in
1823 all documents.  These common operations are written into @dfn{macros}
1824 and collected into a @dfn{macro package}.
1826 All macro packages provide certain common capabilities which fall into
1827 the following categories.
1829 @menu
1830 * Paragraphs::
1831 * Sections and Chapters::
1832 * Headers and Footers::
1833 * Page Layout Adjustment::
1834 * Displays::
1835 * Footnotes and Annotations::
1836 * Table of Contents::
1837 * Indices::
1838 * Paper Formats::
1839 * Multiple Columns::
1840 * Font and Size Changes::
1841 * Predefined Strings::
1842 * Preprocessor Support::
1843 * Configuration and Customization::
1844 @end menu
1846 @c ---------------------------------------------------------------------
1848 @node Paragraphs, Sections and Chapters, Common Features, Common Features
1849 @subsection Paragraphs
1850 @cindex paragraphs
1852 One of the most common and most used capability is starting a paragraph.
1853 There are a number of different types of paragraphs, any of which can be
1854 initiated with macros supplied by the macro package.  Normally,
1855 paragraphs start with a blank line and the first line indented, like the
1856 text in this manual.  There are also block style paragraphs, which omit
1857 the indentation:
1859 @Example
1860 Some   men  look   at  constitutions   with  sanctimonious
1861 reverence, and deem them like the ark of the covenant, too
1862 sacred to be touched.
1863 @endExample
1865 @noindent
1866 And there are also indented paragraphs which begin with a tag or label
1867 at the margin and the remaining text indented.
1869 @Example
1870 one   This is  the first paragraph.  Notice  how the first
1871       line of  the resulting  paragraph lines up  with the
1872       other lines in the paragraph.
1873 @endExample
1874 @Example
1875 longlabel
1876       This  paragraph   had  a  long   label.   The  first
1877       character of text on the first line does not line up
1878       with  the  text  on  second  and  subsequent  lines,
1879       although they line up with each other.
1880 @endExample
1882 A variation of this is a bulleted list.
1884 @Example
1885 .     Bulleted lists start with a bullet.   It is possible
1886       to use other glyphs instead of the bullet.  In nroff
1887       mode using the ASCII character set for output, a dot
1888       is used instead of a real bullet.
1889 @endExample
1891 @c ---------------------------------------------------------------------
1893 @node Sections and Chapters, Headers and Footers, Paragraphs, Common Features
1894 @subsection Sections and Chapters
1896 Most macro packages supply some form of section headers.  The simplest
1897 kind is simply the heading on a line by itself in bold type.  Others
1898 supply automatically numbered section heading or different heading
1899 styles at different levels.  Some, more sophisticated, macro packages
1900 supply macros for starting chapters and appendices.
1902 @c ---------------------------------------------------------------------
1904 @node Headers and Footers, Page Layout Adjustment, Sections and Chapters, Common Features
1905 @subsection Headers and Footers
1907 Every macro package gives some way to manipulate the @dfn{headers} and
1908 @dfn{footers} (also called @dfn{titles}) on each page.  This is text put
1909 at the top and bottom of each page, respectively, which contain data
1910 like the current page number, the current chapter title, and so on.  Its
1911 appearance is not affected by the running text.  Some packages allow for
1912 different ones on the even and odd pages (for material printed in a book
1913 form).
1915 The titles are called @dfn{three-part titles}, that is, there is a
1916 left-justified part, a centered part, and a right-justified part.  An
1917 automatically generated page number may be put in any of these fields
1918 with the @samp{%} character (see @ref{Page Layout}, for more details).
1920 @c ---------------------------------------------------------------------
1922 @node Page Layout Adjustment, Displays, Headers and Footers, Common Features
1923 @subsection Page Layout
1925 Most macro packages let the user specify top and bottom margins and
1926 other details about the appearance of the printed pages.
1928 @c ---------------------------------------------------------------------
1930 @node Displays, Footnotes and Annotations, Page Layout Adjustment, Common Features
1931 @subsection Displays
1932 @cindex displays
1934 @dfn{Displays} are sections of text to be set off from the body of the
1935 paper.  Major quotes, tables, and figures are types of displays, as are
1936 all the examples used in this document.
1938 @cindex quotes, major
1939 @cindex major quotes
1940 @dfn{Major quotes} are quotes which are several lines long, and hence
1941 are set in from the rest of the text without quote marks around them.
1943 @cindex list
1944 A @dfn{list} is an indented, single-spaced, unfilled display.  Lists
1945 should be used when the material to be printed should not be filled and
1946 justified like normal text, such as columns of figures or the examples
1947 used in this paper.
1949 @cindex keep
1950 A @dfn{keep} is a display of lines which are kept on a single page if
1951 possible.  An example for a keep might be a diagram.  Keeps differ from
1952 lists in that lists may be broken over a page boundary whereas keeps are
1953 not.
1955 @cindex keep, floating
1956 @cindex floating keep
1957 @dfn{Floating keeps} move relative to the text.  Hence, they are good
1958 for things which are referred to by name, such as ``See figure@tie{}3''.
1959 A floating keep appears at the bottom of the current page if it fits;
1960 otherwise, it appears at the top of the next page.  Meanwhile, the
1961 surrounding text `flows' around the keep, thus leaving no blank areas.
1963 @c ---------------------------------------------------------------------
1965 @node Footnotes and Annotations, Table of Contents, Displays, Common Features
1966 @subsection Footnotes and Annotations
1967 @cindex footnotes
1968 @cindex annotations
1970 There are a number of requests to save text for later printing.
1972 @dfn{Footnotes} are printed at the bottom of the current page.
1974 @cindex delayed text
1975 @dfn{Delayed text} is very similar to a footnote except that it is
1976 printed when called for explicitly.  This allows a list of references to
1977 appear (for example) at the end of each chapter, as is the convention in
1978 some disciplines.
1980 Most macro packages which supply this functionality also supply a means
1981 of automatically numbering either type of annotation.
1983 @c ---------------------------------------------------------------------
1985 @node Table of Contents, Indices, Footnotes and Annotations, Common Features
1986 @subsection Table of Contents
1987 @cindex table of contents
1988 @cindex contents, table of
1990 @dfn{Tables of contents} are a type of delayed text having a tag
1991 (usually the page number) attached to each entry after a row of dots.
1992 The table accumulates throughout the paper until printed, usually after
1993 the paper has ended.  Many macro packages provide the ability to have
1994 several tables of contents (e.g.@: a standard table of contents, a list
1995 of tables, etc).
1997 @c ---------------------------------------------------------------------
1999 @node Indices, Paper Formats, Table of Contents, Common Features
2000 @subsection Indices
2001 @cindex index, in macro package
2003 While some macro packages use the term @dfn{index}, none actually
2004 provide that functionality.  The facilities they call indices are
2005 actually more appropriate for tables of contents.
2007 @pindex makeindex
2008 To produce a real index in a document, external tools like the
2009 @code{makeindex} program are necessary.
2011 @c ---------------------------------------------------------------------
2013 @node Paper Formats, Multiple Columns, Indices, Common Features
2014 @subsection Paper Formats
2015 @cindex paper formats
2017 Some macro packages provide stock formats for various kinds of
2018 documents.  Many of them provide a common format for the title and
2019 opening pages of a technical paper.  The @file{mm} macros in particular
2020 provide formats for letters and memoranda.
2022 @c ---------------------------------------------------------------------
2024 @node Multiple Columns, Font and Size Changes, Paper Formats, Common Features
2025 @subsection Multiple Columns
2027 Some macro packages (but not @file{man}) provide the ability to have two
2028 or more columns on a page.
2030 @c ---------------------------------------------------------------------
2032 @node Font and Size Changes, Predefined Strings, Multiple Columns, Common Features
2033 @subsection Font and Size Changes
2035 The built-in font and size functions are not always intuitive, so all
2036 macro packages provide macros to make these operations simpler.
2038 @c ---------------------------------------------------------------------
2040 @node Predefined Strings, Preprocessor Support, Font and Size Changes, Common Features
2041 @subsection Predefined Strings
2043 Most macro packages provide various predefined strings for a variety of
2044 uses; examples are sub- and superscripts, printable dates, quotes and
2045 various special characters.
2047 @c ---------------------------------------------------------------------
2049 @node Preprocessor Support, Configuration and Customization, Predefined Strings, Common Features
2050 @subsection Preprocessor Support
2052 All macro packages provide support for various preprocessors and may
2053 extend their functionality.
2055 For example, all macro packages mark tables (which are processed with
2056 @code{gtbl}) by placing them between @code{TS} and @code{TE} macros.
2057 The @file{ms} macro package has an option, @samp{.TS@tie{}H}, that
2058 prints a caption at the top of a new page (when the table is too long to
2059 fit on a single page).
2061 @c ---------------------------------------------------------------------
2063 @node Configuration and Customization,  , Preprocessor Support, Common Features
2064 @subsection Configuration and Customization
2066 Some macro packages provide means of customizing many of the details of
2067 how the package behaves.  This ranges from setting the default type size
2068 to changing the appearance of section headers.
2072 @c =====================================================================
2073 @c =====================================================================
2075 @node Macro Packages, gtroff Reference, Tutorial for Macro Users, Top
2076 @chapter Macro Packages
2077 @cindex macro packages
2078 @cindex packages, macros
2080 This chapter documents the main macro packages that come with
2081 @code{groff}.
2083 Different main macro packages can't be used at the same time; for
2084 example
2086 @Example
2087 groff -m man foo.man -m ms bar.doc
2088 @endExample
2090 @noindent
2091 doesn't work.  Note that option arguments are processed before
2092 non-option arguments; the above (failing) sample is thus reordered to
2094 @Example
2095 groff -m man -m ms foo.man bar.doc
2096 @endExample
2098 @menu
2099 * man::
2100 * mdoc::
2101 * ms::
2102 * me::
2103 * mm::
2104 @end menu
2107 @c =====================================================================
2109 @node man, mdoc, Macro Packages, Macro Packages
2110 @section @file{man}
2111 @cindex manual pages
2112 @cindex man pages
2113 @pindex an.tmac
2114 @pindex man.tmac
2115 @pindex man-old.tmac
2117 This is the most popular and probably the most important macro package
2118 of @code{groff}.  It is easy to use, and a vast majority of manual pages
2119 are based on it.
2121 @menu
2122 * Man options::
2123 * Man usage::
2124 * Man font macros::
2125 * Miscellaneous man macros::
2126 * Predefined man strings::
2127 * Preprocessors in man pages::
2128 * Optional man extensions::
2129 @end menu
2131 @c ---------------------------------------------------------------------
2133 @node Man options, Man usage, man, man
2134 @subsection Options
2136 The command line format for using the @file{man} macros with
2137 @code{groff} is:
2139 @Example
2140 groff -m man [ -rLL=@var{length} ] [ -rLT=@var{length} ] [ -rFT=@var{dist} ]
2141       [ -rcR=1 ] [ -rC1 ] [ -rD1 ] [-rHY=@var{flags} ]
2142       [ -rP@var{nnn} ] [ -rS@var{xx} ] [ -rX@var{nnn} ]
2143       [ -rIN=@var{length} ] [ -rSN=@var{length} ] [ @var{files}@dots{} ]
2144 @endExample
2146 @noindent
2147 It is possible to use @samp{-man} instead of @w{@samp{-m man}}.
2149 @table @code
2150 @item -rcR=1
2151 This option (the default if a TTY output device is used) creates a
2152 single, very long page instead of multiple pages.  Use @code{-rcR=0} to
2153 disable it.
2155 @item -rC1
2156 If more than one manual page is given on the command line, number the
2157 pages continuously, rather than starting each at@tie{}1.
2159 @item -rD1
2160 Double-sided printing.  Footers for even and odd pages are formatted
2161 differently.
2163 @item -rFT=@var{dist}
2164 Set the position of the footer text to @var{dist}.  If positive, the
2165 distance is measured relative to the top of the page, otherwise it is
2166 relative to the bottom.  The default is @minus{}0.5@dmn{i}.
2168 @item -rHY=@var{flags}
2169 Set hyphenation flags.  Possible values are 1@tie{}to hyphenate without
2170 restrictions, 2@tie{}to not hyphenate the last word on a page, 4@tie{}to
2171 not hyphenate the last two characters of a word, and 8@tie{}to not
2172 hyphenate the first two characters of a word.  These values are
2173 additive; the default is@tie{}14.
2175 @item -rIN=@var{length}
2176 Set the body text indentation to @var{length}.  If not specified, the
2177 indentation defaults to 7@dmn{n} (7@tie{}characters) in nroff mode and
2178 7.2@dmn{n} otherwise.  For nroff, this value should always be an integer
2179 multiple of unit @samp{n} to get consistent indentation.
2181 @item -rLL=@var{length}
2182 Set line length to @var{length}.  If not specified, the line length is
2183 set to respect any value set by a prior @samp{ll} request (which
2184 @emph{must} be in effect when the @samp{TH} macro is invoked), if this
2185 differs from the built-in default for the formatter; otherwise it
2186 defaults to 78@dmn{n} in nroff mode (this is 78 characters per line) and
2187 6.5@dmn{i} in troff mode.@footnote{Note that the use of a @samp{.ll
2188 @var{length}} request to initialize the line length, prior to use of the
2189 @samp{TH} macro, is supported for backward compatibility with some
2190 versions of the @code{man} program.  @emph{Always} use the
2191 @option{-rLL=@var{length}} option, or an equivalent @samp{.nr LL
2192 @var{length}} request, in preference to such a @samp{.ll @var{length}}
2193 request.  In particular, note that in nroff mode, the request @samp{.ll
2194 65n}, (with any @var{length} expression which evaluates equal to
2195 65@dmn{n}, i.e., the formatter's default line length in nroff mode),
2196 does @emph{not} set the line length to 65@dmn{n} (it is adjusted to the
2197 @code{man} macro package's default setting of 78@dmn{n}), whereas the
2198 use of the @option{-rLL=65n} option, or the @samp{.nr LL 65n} request
2199 @emph{does} establish a line length of 65@dmn{n}.}
2201 @item -rLT=@var{length}
2202 Set title length to @var{length}.  If not specified, the title length
2203 defaults to the line length.
2205 @item -rP@var{nnn}
2206 Page numbering starts with @var{nnn} rather than with@tie{}1.
2208 @item -rS@var{xx}
2209 Use @var{xx} (which can be 10, 11, or@tie{}12@dmn{pt}) as the base
2210 document font size instead of the default value of@tie{}10@dmn{pt}.
2212 @item -rSN=@var{length}
2213 Set the indentation for sub-subheadings to @var{length}.  If not
2214 specified, the indentation defaults to 3@dmn{n}.
2216 @item -rX@var{nnn}
2217 After page @var{nnn}, number pages as @var{nnn}a, @var{nnn}b,
2218 @var{nnn}c, etc.  For example, the option @option{-rX2} produces the
2219 following page numbers: 1, 2, 2a, 2b, 2c, etc.
2220 @end table
2222 @c ---------------------------------------------------------------------
2224 @node Man usage, Man font macros, Man options, man
2225 @subsection Usage
2226 @cindex @code{man} macros
2227 @cindex macros for manual pages [@code{man}]
2229 @pindex man.local
2230 This section describes the available macros for manual pages.  For
2231 further customization, put additional macros and requests into the file
2232 @file{man.local} which is loaded immediately after the @file{man}
2233 package.
2235 @Defmac {TH, title section [@Var{extra1} [@Var{extra2} [@Var{extra3}]]], man}
2236 Set the title of the man page to @var{title} and the section to
2237 @var{section}, which must have a value between 1 and@tie{}8.  The value
2238 of @var{section} may also have a string appended, e.g.@: @samp{.pm}, to
2239 indicate a specific subsection of the man pages.
2241 Both @var{title} and @var{section} are positioned at the left and right
2242 in the header line (with @var{section} in parentheses immediately
2243 appended to @var{title}.  @var{extra1} is positioned in the middle of
2244 the footer line.  @var{extra2} is positioned at the left in the footer
2245 line (or at the left on even pages and at the right on odd pages if
2246 double-sided printing is active).  @var{extra3} is centered in the
2247 header line.
2249 For @acronym{HTML} and @acronym{XHTML} output, headers and footers are
2250 completely suppressed.
2252 Additionally, this macro starts a new page; the new line number
2253 is@tie{}1 again (except if the @option{-rC1} option is given on the
2254 command line) -- this feature is intended only for formatting multiple
2255 man pages; a single man page should contain exactly one @code{TH} macro
2256 at the beginning of the file.
2257 @endDefmac
2259 @Defmac {SH, [@Var{heading}], man}
2260 Set up an unnumbered section heading sticking out to the left.  Prints
2261 out all the text following @code{SH} up to the end of the line (or the
2262 text in the next line if there is no argument to @code{SH}) in bold face
2263 (or the font specified by the string @code{HF}), one size larger than
2264 the base document size.  Additionally, the left margin and the
2265 indentation for the following text is reset to its default value.
2266 @endDefmac
2268 @Defmac {SS, [@Var{heading}], man}
2269 Set up an unnumbered (sub)section heading.  Prints out all the text
2270 following @code{SS} up to the end of the line (or the text in the next
2271 line if there is no argument to @code{SS}) in bold face (or the font
2272 specified by the string @code{HF}), at the same size as the base
2273 document size.  Additionally, the left margin and the indentation for
2274 the following text is reset to its default value.
2275 @endDefmac
2277 @Defmac {TP, [@Var{nnn}], man}
2278 Set up an indented paragraph with label.  The indentation is set to
2279 @var{nnn} if that argument is supplied (the default unit is @samp{n} if
2280 omitted), otherwise it is set to the previous indentation value
2281 specified with @code{TP}, @code{IP}, or @code{HP} (or to the default
2282 value if none of them have been used yet).
2284 The first line of text following this macro is interpreted as a string
2285 to be printed flush-left, as it is appropriate for a label.  It is not
2286 interpreted as part of a paragraph, so there is no attempt to fill the
2287 first line with text from the following input lines.  Nevertheless, if
2288 the label is not as wide as the indentation the paragraph starts at the
2289 same line (but indented), continuing on the following lines.  If the
2290 label is wider than the indentation the descriptive part of the
2291 paragraph begins on the line following the label, entirely indented.
2292 Note that neither font shape nor font size of the label is set to a
2293 default value; on the other hand, the rest of the text has default font
2294 settings.
2295 @endDefmac
2297 @DefmacList {LP, , man}
2298 @DefmacItem {PP, , man}
2299 @DefmacListEnd {P, , man}
2300 These macros are mutual aliases.  Any of them causes a line break at the
2301 current position, followed by a vertical space downwards by the amount
2302 specified by the @code{PD} macro.  The font size and shape are reset to
2303 the default value (10@dmn{pt} roman if no @option{-rS} option is given
2304 on the command line).  Finally, the current left margin and the
2305 indentation is restored.
2306 @endDefmac
2308 @Defmac {IP, [@Var{designator} [@Var{nnn}]], man}
2309 Set up an indented paragraph, using @var{designator} as a tag to mark
2310 its beginning.  The indentation is set to @var{nnn} if that argument is
2311 supplied (default unit is @samp{n}), otherwise it is set to the previous
2312 indentation value specified with @code{TP}, @code{IP}, or @code{HP} (or
2313 the default value if none of them have been used yet).  Font size and
2314 face of the paragraph (but not the designator) are reset to their
2315 default values.
2317 To start an indented paragraph with a particular indentation but without
2318 a designator, use @samp{""} (two double quotes) as the first argument of
2319 @code{IP}.
2321 For example, to start a paragraph with bullets as the designator and
2322 4@tie{}en indentation, write
2324 @Example
2325 .IP \(bu 4
2326 @endExample
2327 @endDefmac
2329 @Defmac {HP, [@Var{nnn}], man}
2330 @cindex hanging indentation [@code{man}]
2331 @cindex @code{man} macros, hanging indentation
2332 Set up a paragraph with hanging left indentation.  The indentation is
2333 set to @var{nnn} if that argument is supplied (default unit is
2334 @samp{n}), otherwise it is set to the previous indentation value
2335 specified with @code{TP}, @code{IP}, or @code{HP} (or the default value
2336 if non of them have been used yet).  Font size and face are reset to
2337 their default values.
2338 @endDefmac
2340 @Defmac {RS, [@Var{nnn}], man}
2341 @cindex left margin, how to move [@code{man}]
2342 @cindex @code{man} macros, moving left margin
2343 Move the left margin to the right by the value @var{nnn} if specified
2344 (default unit is @samp{n}); otherwise it is set to the previous
2345 indentation value specified with @code{TP}, @code{IP}, or @code{HP} (or
2346 to the default value if none of them have been used yet).  The
2347 indentation value is then set to the default.
2349 Calls to the @code{RS} macro can be nested.
2350 @endDefmac
2352 @Defmac {RE, [@Var{nnn}], man}
2353 Move the left margin back to level @var{nnn}, restoring the previous
2354 left margin.  If no argument is given, it moves one level back.  The
2355 first level (i.e., no call to @code{RS} yet) has number@tie{}1, and each
2356 call to @code{RS} increases the level by@tie{}1.
2357 @endDefmac
2359 @cindex line breaks, with vertical space [@code{man}]
2360 @cindex @code{man} macros, line breaks with vertical space
2361 To summarize, the following macros cause a line break with the insertion
2362 of vertical space (which amount can be changed with the @code{PD}
2363 macro): @code{SH}, @code{SS}, @code{TP}, @code{LP} (@code{PP},
2364 @code{P}), @code{IP}, and @code{HP}.
2366 @cindex line breaks, without vertical space [@code{man}]
2367 @cindex @code{man} macros, line breaks without vertical space
2368 The macros @code{RS} and @code{RE} also cause a break but do not insert
2369 vertical space.
2371 @cindex default indentation, resetting [@code{man}]
2372 @cindex indentaion, resetting to default [@code{man}]
2373 @cindex @code{man} macros, resetting default indentation
2374 Finally, the macros @code{SH}, @code{SS}, @code{LP} (@code{PP},
2375 @code{P}), and @code{RS} reset the indentation to its default value.
2377 @c ---------------------------------------------------------------------
2379 @node Man font macros, Miscellaneous man macros, Man usage, man
2380 @subsection Macros to set fonts
2381 @cindex font selection [@code{man}]
2382 @cindex @code{man} macros, how to set fonts
2384 The standard font is roman; the default text size is 10@tie{}point.  If
2385 command line option @option{-rS=@var{n}} is given, use @var{n}@dmn{pt}
2386 as the default text size.
2388 @Defmac {SM, [@Var{text}], man}
2389 Set the text on the same line or the text on the next line in a font
2390 that is one point size smaller than the default font.
2391 @endDefmac
2393 @Defmac {SB, [@Var{text}], man}
2394 @cindex bold face [@code{man}]
2395 @cindex @code{man} macros, bold face
2396 Set the text on the same line or the text on the next line in bold face
2397 font, one point size smaller than the default font.
2398 @endDefmac
2400 @Defmac {BI, text, man}
2401 Set its arguments alternately in bold face and italic, without a space
2402 between the arguments.  Thus,
2404 @Example
2405 .BI this "word and" that
2406 @endExample
2408 @noindent
2409 produces ``thisword andthat'' with ``this'' and ``that'' in bold face,
2410 and ``word and'' in italics.
2411 @endDefmac
2413 @Defmac {IB, text, man}
2414 Set its arguments alternately in italic and bold face, without a space
2415 between the arguments.
2416 @endDefmac
2418 @Defmac {RI, text, man}
2419 Set its arguments alternately in roman and italic, without a space
2420 between the arguments.
2421 @endDefmac
2423 @Defmac {IR, text, man}
2424 Set its arguments alternately in italic and roman, without a space
2425 between the arguments.
2426 @endDefmac
2428 @Defmac {BR, text, man}
2429 Set its arguments alternately in bold face and roman, without a space
2430 between the arguments.
2431 @endDefmac
2433 @Defmac {RB, text, man}
2434 Set its arguments alternately in roman and bold face, without a space
2435 between the arguments.
2436 @endDefmac
2438 @Defmac {B, [@Var{text}], man}
2439 Set @var{text} in bold face.  If no text is present on the line where
2440 the macro is called, then the text of the next line appears in bold
2441 face.
2442 @endDefmac
2444 @Defmac {I, [@Var{text}], man}
2445 @cindex italic fonts [@code{man}]
2446 @cindex @code{man} macros, italic fonts
2447 Set @var{text} in italic.  If no text is present on the line where the
2448 macro is called, then the text of the next line appears in italic.
2449 @endDefmac
2451 @c ---------------------------------------------------------------------
2453 @node Miscellaneous man macros, Predefined man strings, Man font macros, man
2454 @subsection Miscellaneous macros
2456 @pindex grohtml
2457 @cindex @code{man} macros, default indentation
2458 @cindex default indentation [@code{man}]
2459 The default indentation is 7.2@dmn{n} in troff mode and 7@dmn{n} in
2460 nroff mode except for @code{grohtml} which ignores indentation.
2462 @Defmac {DT, , man}
2463 @cindex tab stops [@code{man}]
2464 @cindex @code{man} macros, tab stops
2465 Set tabs every 0.5@tie{}inches.  Since this macro is always executed
2466 during a call to the @code{TH} macro, it makes sense to call it only if
2467 the tab positions have been changed.
2468 @endDefmac
2470 @Defmac {PD, [@Var{nnn}], man}
2471 @cindex empty space before a paragraph [@code{man}]
2472 @cindex @code{man} macros, empty space before a paragraph
2473 Adjust the empty space before a new paragraph (or section).  The
2474 optional argument gives the amount of space (default unit is @samp{v});
2475 without parameter, the value is reset to its default value (1@tie{}line
2476 in nroff mode, 0.4@dmn{v}@tie{}otherwise).
2478 This affects the macros @code{SH}, @code{SS}, @code{TP}, @code{LP} (as
2479 well as @code{PP} and @code{P}), @code{IP}, and @code{HP}.
2480 @endDefmac
2482 The following two macros are included for BSD compatibility.
2484 @Defmac {AT, [@Var{system} [@Var{release}]], man}
2485 @cindex @code{man}macros, BSD compatibility
2486 Alter the footer for use with @acronym{AT&T} manpages.  This command
2487 exists only for compatibility; don't use it.  The first argument
2488 @var{system} can be:
2490 @table @code
2491 @item 3
2492 7th Edition (the default)
2494 @item 4
2495 System III
2497 @item 5
2498 System V
2499 @end table
2501 An optional second argument @var{release} to @code{AT} specifies the
2502 release number (such as ``System V Release 3'').
2503 @endDefmac
2505 @Defmac {UC, [@Var{version}], man}
2506 @cindex @code{man}macros, BSD compatibility
2507 Alters the footer for use with @acronym{BSD} manpages.  This command
2508 exists only for compatibility; don't use it.  The argument can be:
2510 @table @code
2511 @item 3
2512 3rd Berkeley Distribution (the default)
2514 @item 4
2515 4th Berkeley Distribution
2517 @item 5
2518 4.2 Berkeley Distribution
2520 @item 6
2521 4.3 Berkeley Distribution
2523 @item 7
2524 4.4 Berkeley Distribution
2525 @end table
2526 @endDefmac
2528 @c ---------------------------------------------------------------------
2530 @node Predefined man strings, Preprocessors in man pages, Miscellaneous man macros, man
2531 @subsection Predefined strings
2533 The following strings are defined:
2535 @Defstr {S, man}
2536 Switch back to the default font size.
2537 @endDefstr
2539 @Defstr {HF, man}
2540 The typeface used for headings.
2541 The default is @samp{B}.
2542 @endDefstr
2544 @Defstr {R, man}
2545 The `registered' sign.
2546 @endDefstr
2548 @Defstr {Tm, man}
2549 The `trademark' sign.
2550 @endDefstr
2552 @DefstrList {lq, man}
2553 @DefstrListEnd {rq, man}
2554 @cindex @code{lq} glyph, and @code{lq} string [@code{man}]
2555 @cindex @code{rq} glyph, and @code{rq} string [@code{man}]
2556 Left and right quote.  This is equal to @code{\(lq} and @code{\(rq},
2557 respectively.
2558 @endDefstr
2560 @c ---------------------------------------------------------------------
2562 @node Preprocessors in man pages, Optional man extensions, Predefined man strings, man
2563 @subsection Preprocessors in @file{man} pages
2565 @cindex preprocessor, calling convention
2566 @cindex calling convention of preprocessors
2567 If a preprocessor like @code{gtbl} or @code{geqn} is needed, it has
2568 become common usage to make the first line of the man page look like
2569 this:
2571 @Example
2572 '\" @var{word}
2573 @endExample
2575 @pindex geqn@r{, invocation in manual pages}
2576 @pindex grefer@r{, invocation in manual pages}
2577 @pindex gtbl@r{, invocation in manual pages}
2578 @pindex man@r{, invocation of preprocessors}
2579 @noindent
2580 Note the single space character after the double quote.  @var{word}
2581 consists of letters for the needed preprocessors: @samp{e} for
2582 @code{geqn}, @samp{r} for @code{grefer}, @samp{t} for @code{gtbl}.
2583 Modern implementations of the @code{man} program read this first line
2584 and automatically call the right preprocessor(s).
2586 @c ---------------------------------------------------------------------
2588 @node Optional man extensions,  , Preprocessors in man pages, man
2589 @subsection Optional @file{man} extensions
2591 @pindex man.local
2592 Use the file @file{man.local} for local extensions to the @code{man}
2593 macros or for style changes.
2595 @unnumberedsubsubsec Custom headers and footers
2596 @cindex @code{man} macros, custom headers and footers
2598 In groff versions 1.18.2 and later, you can specify custom headers and
2599 footers by redefining the following macros in @file{man.local}.
2601 @Defmac {PT, , man}
2602 Control the content of the headers.  Normally, the header prints the
2603 command name and section number on either side, and the optional fifth
2604 argument to @code{TH} in the center.
2605 @endDefmac
2607 @Defmac {BT, , man}
2608 Control the content of the footers.  Normally, the footer prints the
2609 page number and the third and fourth arguments to @code{TH}.
2611 Use the @code{FT} number register to specify the footer position.  The
2612 default is @minus{}0.5@dmn{i}.
2613 @endDefmac
2615 @unnumberedsubsubsec Ultrix-specific man macros
2616 @cindex Ultrix-specific @code{man} macros
2617 @cindex @code{man} macros, Ultrix-specific
2619 @pindex man.ultrix
2620 The @code{groff} source distribution includes a file named
2621 @file{man.ultrix}, containing macros compatible with the Ultrix variant
2622 of @code{man}.  Copy this file into @file{man.local} (or use the
2623 @code{mso} request to load it) to enable the following macros.
2625 @Defmac {CT, @Var{key}, man}
2626 Print @samp{<CTRL/@var{key}>}.
2627 @endDefmac
2629 @Defmac {CW, , man}
2630 Print subsequent text using the constant width (Courier) typeface.
2631 @endDefmac
2633 @Defmac {Ds, , man}
2634 Begin a non-filled display.
2635 @endDefmac
2637 @Defmac {De, , man}
2638 End a non-filled display started with @code{Ds}.
2639 @endDefmac
2641 @Defmac {EX, [@Var{indent}], man}
2642 Begin a non-filled display using the constant width (Courier) typeface.
2643 Use the optional @var{indent} argument to indent the display.
2644 @endDefmac
2646 @Defmac {EE, , man}
2647 End a non-filled display started with @code{EX}.
2648 @endDefmac
2650 @Defmac {G, [@Var{text}], man}
2651 Set @var{text} in Helvetica.  If no text is present on the line where
2652 the macro is called, then the text of the next line appears in
2653 Helvetica.
2654 @endDefmac
2656 @Defmac {GL, [@Var{text}], man}
2657 Set @var{text} in Helvetica Oblique.  If no text is present on the line
2658 where the macro is called, then the text of the next line appears in
2659 Helvetica Oblique.
2660 @endDefmac
2662 @Defmac {HB, [@Var{text}], man}
2663 Set @var{text} in Helvetica Bold.  If no text is present on the line
2664 where the macro is called, then all text up to the next @code{HB}
2665 appears in Helvetica Bold.
2666 @endDefmac
2668 @Defmac {TB, [@Var{text}], man}
2669 Identical to @code{HB}.
2670 @endDefmac
2672 @Defmac {MS, @Var{title} @Var{sect} [@Var{punct}], man}
2673 Set a manpage reference in Ultrix format.  The @var{title} is in Courier
2674 instead of italic.  Optional punctuation follows the section number
2675 without an intervening space.
2676 @endDefmac
2678 @Defmac {NT, [@code{C}] [@Var{title}], man}
2679 Begin a note.  Print the optional @Var{title}, or the word ``Note'',
2680 centered on the page.  Text following the macro makes up the body of the
2681 note, and is indented on both sides.  If the first argument is @code{C},
2682 the body of the note is printed centered (the second argument replaces
2683 the word ``Note'' if specified).
2684 @endDefmac
2686 @Defmac {NE, , man}
2687 End a note begun with @code{NT}.
2688 @endDefmac
2690 @Defmac {PN, @Var{path} [@Var{punct}], man}
2691 Set the path name in constant width (Courier), followed by optional
2692 punctuation.
2693 @endDefmac
2695 @Defmac {Pn, [@Var{punct}] @Var{path} [@Var{punct}], man}
2696 If called with two arguments, identical to @code{PN}.  If called with
2697 three arguments, set the second argument in constant width (Courier),
2698 bracketed by the first and third arguments in the current font.
2699 @endDefmac
2701 @Defmac {R, , man}
2702 Switch to roman font and turn off any underlining in effect.
2703 @endDefmac
2705 @Defmac {RN, , man}
2706 Print the string @samp{<RETURN>}.
2707 @endDefmac
2709 @Defmac {VS, [@code{4}], man}
2710 Start printing a change bar in the margin if the number@tie{}@code{4} is
2711 specified.  Otherwise, this macro does nothing.
2712 @endDefmac
2714 @Defmac {VE, , man}
2715 End printing the change bar begun by @code{VS}.
2716 @endDefmac
2718 @unnumberedsubsubsec Simple example
2720 The following example @file{man.local} file alters the @code{SH} macro
2721 to add some extra vertical space before printing the heading.  Headings
2722 are printed in Helvetica Bold.
2724 @Example
2725 .\" Make the heading fonts Helvetica
2726 .ds HF HB
2728 .\" Put more whitespace in front of headings.
2729 .rn SH SH-orig
2730 .de SH
2731 .  if t .sp (u;\\n[PD]*2)
2732 .  SH-orig \\$*
2734 @endExample
2737 @c =====================================================================
2739 @node mdoc, ms, man, Macro Packages
2740 @section @file{mdoc}
2741 @cindex @code{mdoc} macros
2743 @c XXX documentation
2744 @c XXX this is a placeholder until we get stuff knocked into shape
2745 See the @cite{groff_mdoc(7)} man page (type @command{man groff_mdoc}
2746 at the command line).
2749 @c =====================================================================
2751 @node ms, me, mdoc, Macro Packages
2752 @section @file{ms}
2753 @cindex @code{ms} macros
2755 The @file{-ms} macros are suitable for reports, letters, books, user
2756 manuals, and so forth.  The package provides macros for cover pages,
2757 section headings, paragraphs, lists, footnotes, pagination, and a table
2758 of contents.
2760 @menu
2761 * ms Intro::
2762 * General ms Structure::
2763 * ms Document Control Registers::
2764 * ms Cover Page Macros::
2765 * ms Body Text::
2766 * ms Page Layout::
2767 * Differences from AT&T ms::
2768 * Naming Conventions::
2769 @end menu
2771 @c ---------------------------------------------------------------------
2773 @node ms Intro, General ms Structure, ms, ms
2774 @subsection Introduction to @file{ms}
2776 The original @file{-ms} macros were included with @acronym{AT&T}
2777 @code{troff} as well as the @file{man} macros.  While the @file{man}
2778 package is intended for brief documents that can be read on-line as well
2779 as printed, the @file{ms} macros are suitable for longer documents that
2780 are meant to be printed rather than read on-line.
2782 The @file{ms} macro package included with @code{groff} is a complete,
2783 bottom-up re-implementation.  Several macros (specific to @acronym{AT&T}
2784 or Berkeley) are not included, while several new commands are.
2785 @xref{Differences from AT&T ms}, for more information.
2787 @c ---------------------------------------------------------------------
2789 @node General ms Structure, ms Document Control Registers, ms Intro, ms
2790 @subsection General structure of an @file{ms} document
2791 @cindex @code{ms} macros, general structure
2793 The @file{ms} macro package expects a certain amount of structure, but
2794 not as much as packages such as @file{man} or @file{mdoc}.
2796 The simplest documents can begin with a paragraph macro (such as
2797 @code{LP} or @code{PP}), and consist of text separated by paragraph
2798 macros or even blank lines.  Longer documents have a structure as
2799 follows:
2801 @table @strong
2802 @item Document type
2803 If you invoke the @code{RP} (report) macro on the first line of the
2804 document, @code{groff} prints the cover page information on its own
2805 page; otherwise it prints the information on the first page with your
2806 document text immediately following.  Other document formats found in
2807 @acronym{AT&T} @code{troff} are specific to @acronym{AT&T} or Berkeley,
2808 and are not supported in @code{groff}.
2810 @item Format and layout
2811 By setting number registers, you can change your document's type (font
2812 and size), margins, spacing, headers and footers, and footnotes.
2813 @xref{ms Document Control Registers}, for more details.
2815 @item Cover page
2816 A cover page consists of a title, the author's name and institution, an
2817 abstract, and the date.@footnote{Actually, only the title is required.}
2818 @xref{ms Cover Page Macros}, for more details.
2820 @item Body
2821 Following the cover page is your document.  You can use the @file{ms}
2822 macros to write reports, letters, books, and so forth.  The package is
2823 designed for structured documents, consisting of paragraphs interspersed
2824 with headings and augmented by lists, footnotes, tables, and other
2825 common constructs.  @xref{ms Body Text}, for more details.
2827 @item Table of contents
2828 Longer documents usually include a table of contents, which you can
2829 invoke by placing the @code{TC} macro at the end of your document.  The
2830 @file{ms} macros have minimal indexing facilities, consisting of the
2831 @code{IX} macro, which prints an entry on standard error.  Printing the
2832 table of contents at the end is necessary since @code{groff} is a
2833 single-pass text formatter, thus it cannot determine the page number of
2834 each section until that section has actually been set and printed.
2835 Since @file{ms} output is intended for hardcopy, you can manually
2836 relocate the pages containing the table of contents between the cover
2837 page and the body text after printing.
2838 @end table
2840 @c ---------------------------------------------------------------------
2842 @node ms Document Control Registers, ms Cover Page Macros, General ms Structure, ms
2843 @subsection Document control registers
2844 @cindex @code{ms} macros, document control registers
2846 The following is a list of document control number registers.  For the
2847 sake of consistency, set registers related to margins at the beginning
2848 of your document, or just after the @code{RP} macro.  You can set other
2849 registers later in your document, but you should keep them together at
2850 the beginning to make them easy to find and edit as necessary.
2852 @unnumberedsubsubsec Margin Settings
2854 @Defmpreg {PO, ms}
2855 Defines the page offset (i.e., the left margin).  There is no explicit
2856 right margin setting; the combination of the @code{PO} and @code{LL}
2857 registers implicitly define the right margin width.
2859 Effective: next page.
2861 Default value: 1@dmn{i}.
2862 @endDefmpreg
2864 @Defmpreg {LL, ms}
2865 Defines the line length (i.e., the width of the body text).
2867 Effective: next paragraph.
2869 Default: 6@dmn{i}.
2870 @endDefmpreg
2872 @Defmpreg {LT, ms}
2873 Defines the title length (i.e., the header and footer width).  This
2874 is usually the same as @code{LL}, but not necessarily.
2876 Effective: next paragraph.
2878 Default: 6@dmn{i}.
2879 @endDefmpreg
2881 @Defmpreg {HM, ms}
2882 Defines the header margin height at the top of the page.
2884 Effective: next page.
2886 Default: 1@dmn{i}.
2887 @endDefmpreg
2889 @Defmpreg {FM, ms}
2890 Defines the footer margin height at the bottom of the page.
2892 Effective: next page.
2894 Default: 1@dmn{i}.
2895 @endDefmpreg
2897 @unnumberedsubsubsec Text Settings
2899 @Defmpreg {PS, ms}
2900 Defines the point size of the body text.  If the value is larger than or
2901 equal to 1000, divide it by 1000 to get a fractional point size.  For
2902 example, @samp{.nr PS 10250} sets the document's point size to
2903 10.25@dmn{p}.
2905 Effective: next paragraph.
2907 Default: 10@dmn{p}.
2908 @endDefmpreg
2910 @Defmpreg {VS, ms}
2911 Defines the space between lines (line height plus leading).  If the
2912 value is larger than or equal to 1000, divide it by 1000 to get a
2913 fractional point size.  Due to backwards compatibility, @code{VS} must
2914 be smaller than 40000 (this is 40.0@dmn{p}).
2916 Effective: next paragraph.
2918 Default: 12@dmn{p}.
2919 @endDefmpreg
2921 @Defmpreg {PSINCR, ms}
2922 Defines an increment in point size, which is applied to section headings
2923 at nesting levels below the value specified in @code{GROWPS}.  The value
2924 of @code{PSINCR} should be specified in points, with the @dmn{p} scaling
2925 factor, and may include a fractional component; for example,
2926 @w{@samp{.nr PSINCR 1.5p}} sets a point size increment of 1.5@dmn{p}.
2928 Effective: next section heading.
2930 Default: 1@dmn{p}.
2931 @endDefmpreg
2933 @Defmpreg {GROWPS, ms}
2934 Defines the heading level below which the point size increment set by
2935 @code{PSINCR} becomes effective.  Section headings at and above the
2936 level specified by @code{GROWPS} are printed at the point size set by
2937 @code{PS}; for each level below the value of @code{GROWPS}, the point
2938 size is increased in steps equal to the value of @code{PSINCR}.  Setting
2939 @code{GROWPS} to any value less than@tie{}2 disables the incremental
2940 heading size feature.
2942 Effective: next section heading.
2944 Default: 0.
2945 @endDefmpreg
2947 @Defmpreg {HY, ms}
2948 Defines the hyphenation level.  @code{HY} sets safely the value of the
2949 low-level @code{hy} register.  Setting the value of @code{HY} to@tie{}0
2950 is equivalent to using the @code{nh} request.
2952 Effective: next paragraph.
2954 Default: 14.
2955 @endDefmpreg
2957 @Defmpreg {FAM, ms}
2958 Defines the font family used to typeset the document.
2960 Effective: next paragraph.
2962 Default: as defined in the output device.
2963 @endDefmpreg
2965 @unnumberedsubsubsec Paragraph Settings
2967 @Defmpreg {PI, ms}
2968 Defines the initial indentation of a (@code{PP} macro) paragraph.
2970 Effective: next paragraph.
2972 Default: 5@dmn{n}.
2973 @endDefmpreg
2975 @Defmpreg {PD, ms}
2976 Defines the space between paragraphs.
2978 Effective: next paragraph.
2980 Default: 0.3@dmn{v}.
2981 @endDefmpreg
2983 @Defmpreg {QI, ms}
2984 Defines the indentation on both sides of a quoted (@code{QP} macro)
2985 paragraph.
2987 Effective: next paragraph.
2989 Default: 5@dmn{n}.
2990 @endDefmpreg
2992 @Defmpreg {PORPHANS, ms}
2993 Defines the minimum number of initial lines of any paragraph which
2994 should be kept together, to avoid orphan lines at the bottom of a page.
2995 If a new paragraph is started close to the bottom of a page, and there
2996 is insufficient space to accommodate @code{PORPHANS} lines before an
2997 automatic page break, then the page break is forced, before the start of
2998 the paragraph.
3000 Effective: next paragraph.
3002 Default: 1.
3003 @endDefmpreg
3005 @Defmpreg {HORPHANS, ms}
3006 Defines the minimum number of lines of the following paragraph which
3007 should be kept together with any section heading introduced by the
3008 @code{NH} or @code{SH} macros.  If a section heading is placed close to
3009 the bottom of a page, and there is insufficient space to accommodate
3010 both the heading and at least @code{HORPHANS} lines of the following
3011 paragraph, before an automatic page break, then the page break is forced
3012 before the heading.
3014 Effective: next paragraph.
3016 Default: 1.
3017 @endDefmpreg
3019 @unnumberedsubsubsec Footnote Settings
3021 @Defmpreg {FL, ms}
3022 Defines the length of a footnote.
3024 Effective: next footnote.
3026 Default: @math{@code{@\n[LL]} * 5 / 6}.
3027 @endDefmpreg
3029 @Defmpreg {FI, ms}
3030 Defines the footnote indentation.
3032 Effective: next footnote.
3034 Default: 2@dmn{n}.
3035 @endDefmpreg
3037 @Defmpreg {FF, ms}
3038 The footnote format:
3039 @table @code
3040 @item 0
3041 Print the footnote number as a superscript; indent the footnote
3042 (default).
3044 @item 1
3045 Print the number followed by a period (like 1.@:) and indent the
3046 footnote.
3048 @item 2
3049 Like 1, without an indentation.
3051 @item 3
3052 Like 1, but print the footnote number as a hanging paragraph.
3053 @end table
3055 Effective: next footnote.
3057 Default: 0.
3058 @endDefmpreg
3060 @Defmpreg {FPS, ms}
3061 Defines the footnote point size.  If the value is larger than or equal
3062 to 1000, divide it by 1000 to get a fractional point size.
3064 Effective: next footnote.
3066 Default: @math{@code{@\n[PS]} - 2}.
3067 @endDefmpreg
3069 @Defmpreg {FVS, ms}
3070 Defines the footnote vertical spacing.  If the value is larger than or
3071 equal to 1000, divide it by 1000 to get a fractional point size.
3073 Effective: next footnote.
3075 Default: @math{@code{@\n[FPS]} + 2}.
3076 @endDefmpreg
3078 @Defmpreg {FPD, ms}
3079 Defines the footnote paragraph spacing.
3081 Effective: next footnote.
3083 Default: @math{@code{@\n[PD]} / 2}.
3084 @endDefmpreg
3086 @unnumberedsubsubsec Miscellaneous Number Registers
3088 @Defmpreg {MINGW, ms}
3089 Defines the minimum width between columns in a multi-column document.
3091 Effective: next page.
3093 Default: 2@dmn{n}.
3094 @endDefmpreg
3096 @c ---------------------------------------------------------------------
3098 @node ms Cover Page Macros, ms Body Text, ms Document Control Registers, ms
3099 @subsection Cover page macros
3100 @cindex @code{ms} macros, cover page
3101 @cindex cover page macros, [@code{ms}]
3103 Use the following macros to create a cover page for your document in the
3104 order shown.
3106 @Defmac {RP, [@code{no}], ms}
3107 Specifies the report format for your document.  The report format
3108 creates a separate cover page.  The default action (no @code{RP} macro)
3109 is to print a subset of the cover page on page@tie{}1 of your document.
3111 If you use the word @code{no} as an optional argument, @code{groff}
3112 prints a title page but does not repeat any of the title page
3113 information (title, author, abstract, etc.@:) on page@tie{}1 of the
3114 document.
3115 @endDefmac
3117 @Defmac {P1, , ms}
3118 (P-one) Prints the header on page@tie{}1.  The default is to suppress
3119 the header.
3120 @endDefmac
3122 @Defmac {DA, [@dots{}], ms}
3123 (optional) Prints the current date, or the arguments to the macro if
3124 any, on the title page (if specified) and in the footers.  This is the
3125 default for @code{nroff}.
3126 @endDefmac
3128 @Defmac {ND, [@dots{}], ms}
3129 (optional) Prints the current date, or the arguments to the macro if
3130 any, on the title page (if specified) but not in the footers.  This is
3131 the default for @code{troff}.
3132 @endDefmac
3134 @Defmac {TL, , ms}
3135 Specifies the document title.  @code{groff} collects text following the
3136 @code{TL} macro into the title, until reaching the author name or
3137 abstract.
3138 @endDefmac
3140 @Defmac {AU, , ms}
3141 Specifies the author's name, which appears on the line (or lines)
3142 immediately following.  You can specify multiple authors as follows:
3144 @Example
3146 John Doe
3148 University of West Bumblefuzz
3150 Martha Buck
3152 Monolithic Corporation
3155 @endExample
3156 @endDefmac
3158 @Defmac {AI, , ms}
3159 Specifies the author's institution.  You can specify multiple
3160 institutions in the same way that you specify multiple authors.
3161 @endDefmac
3163 @Defmac {AB, [@code{no}], ms}
3164 Begins the abstract.  The default is to print the word
3165 @acronym{ABSTRACT}, centered and in italics, above the text of the
3166 abstract.  The word @code{no} as an optional argument suppresses this
3167 heading.
3168 @endDefmac
3170 @Defmac {AE, , ms}
3171 Ends the abstract.
3172 @endDefmac
3174 The following is example mark-up for a title page.
3175 @cindex title page, example markup
3176 @cindex example markup, title page
3178 @Example
3179 @cartouche
3182 The Inevitability of Code Bloat
3183 in Commercial and Free Software
3185 J. Random Luser
3187 University of West Bumblefuzz
3189 This report examines the long-term growth
3190 of the code bases in two large, popular software
3191 packages; the free Emacs and the commercial
3192 Microsoft Word.
3193 While differences appear in the type or order
3194 of features added, due to the different
3195 methodologies used, the results are the same
3196 in the end.
3198 The free software approach is shown to be
3199 superior in that while free software can
3200 become as bloated as commercial offerings,
3201 free software tends to have fewer serious
3202 bugs and the added features are in line with
3203 user demand.
3206 ... the rest of the paper follows ...
3207 @end cartouche
3208 @endExample
3210 @c ---------------------------------------------------------------------
3212 @node ms Body Text, ms Page Layout, ms Cover Page Macros, ms
3213 @subsection Body text
3214 @cindex @code{ms} macros, body text
3216 This section describes macros used to mark up the body of your document.
3217 Examples include paragraphs, sections, and other groups.
3219 @menu
3220 * Paragraphs in ms::
3221 * Headings in ms::
3222 * Highlighting in ms::
3223 * Lists in ms::
3224 * Indentation values in ms::
3225 * Tabstops in ms::
3226 * ms Displays and Keeps::
3227 * ms Insertions::
3228 * Example multi-page table::
3229 * ms Footnotes::
3230 @end menu
3232 @c ---------------------------------------------------------------------
3234 @node Paragraphs in ms, Headings in ms, ms Body Text, ms Body Text
3235 @subsubsection Paragraphs
3236 @cindex @code{ms} macros, paragraph handling
3238 The following paragraph types are available.
3240 @DefmacList {PP, , ms}
3241 @DefmacListEnd {LP, , ms}
3242 Sets a paragraph with an initial indentation.
3243 @endDefmac
3245 @Defmac {QP, , ms}
3246 Sets a paragraph that is indented at both left and right margins.  The
3247 effect is identical to the @acronym{HTML} @code{<BLOCKQUOTE>} element.
3248 The next paragraph or heading returns margins to normal.
3249 @endDefmac
3251 @Defmac {XP, , ms}
3252 Sets a paragraph whose lines are indented, except for the first line.
3253 This is a Berkeley extension.
3254 @endDefmac
3256 The following markup uses all four paragraph macros.
3258 @Example
3259 @cartouche
3260 .NH 2
3261 Cases used in the study
3263 The following software and versions were
3264 considered for this report.
3266 For commercial software, we chose
3267 .B "Microsoft Word for Windows" ,
3268 starting with version 1.0 through the
3269 current version (Word 2000).
3271 For free software, we chose
3272 .B Emacs ,
3273 from its first appearance as a standalone
3274 editor through the current version (v20).
3275 See [Bloggs 2002] for details.
3277 Franklin's Law applied to software:
3278 software expands to outgrow both
3279 RAM and disk space over time.
3281 Bibliography:
3283 Bloggs, Joseph R.,
3284 .I "Everyone's a Critic" ,
3285 Underground Press, March 2002.
3286 A definitive work that answers all questions
3287 and criticisms about the quality and usability of
3288 free software.
3289 @end cartouche
3290 @endExample
3292 The @code{PORPHANS} register (@pxref{ms Document Control Registers})
3293 operates in conjunction with each of these macros, to inhibit the
3294 printing of orphan lines at the bottom of any page.
3296 @c ---------------------------------------------------------------------
3298 @node Headings in ms, Highlighting in ms, Paragraphs in ms, ms Body Text
3299 @subsubsection Headings
3300 @cindex @code{ms} macros, headings
3302 Use headings to create a hierarchical structure for your document.  The
3303 @file{ms} macros print headings in @strong{bold}, using the same font
3304 family and point size as the body text.
3306 The following describes the heading macros:
3308 @DefmacList {NH, @Var{curr-level}, ms}
3309 @DefmacListEnd {NH, @t{S} @Var{level0} @dots{}, ms}
3310 Numbered heading.  The argument is either a numeric argument to indicate
3311 the level of the heading, or the letter@tie{}@code{S} followed by
3312 numeric arguments to set the heading level explicitly.
3314 If you specify heading levels out of sequence, such as invoking
3315 @samp{.NH 3} after @samp{.NH 1}, @code{groff} prints a warning on
3316 standard error.
3317 @endDefmac
3319 @DefstrList {SN, ms}
3320 @DefstrItem {SN-DOT, ms}
3321 @DefstrListEnd {SN-NO-DOT, ms}
3322 After invocation of @code{NH}, the assigned section number is made
3323 available in the strings @code{SN-DOT} (as it appears in a printed
3324 section heading with default formatting, followed by a terminating
3325 period), and @code{SN-NO-DOT} (with the terminating period omitted).
3326 The string @code{SN} is also defined, as an alias for @code{SN-DOT}; if
3327 preferred, you may redefine it as an alias for @code{SN-NO-DOT}, by
3328 including the initialization
3329 @Example
3330 .als SN SN-NO-DOT
3331 @endExample
3333 @noindent
3334 at any time @strong{before} you would like the change to take effect.
3335 @endDefstr
3337 @Defstr {SN-STYLE, ms}
3338 You may control the style used to print section numbers, within numbered
3339 section headings, by defining an appropriate alias for the string
3340 @code{SN-STYLE}.  The default style, in which the printed section number
3341 is followed by a terminating period, is obtained by defining the alias
3342 @Example
3343 .als SN-STYLE SN-DOT
3344 @endExample
3346 @noindent
3347 If you prefer to omit the terminating period, from section numbers
3348 appearing in numbered section headings, you may define the alias
3349 @Example
3350 .als SN-STYLE SN-NO-DOT
3351 @endExample
3353 @noindent
3354 Any such change in section numbering style becomes effective from the
3355 next use of @code{.NH}, following redefinition of the alias for
3356 @code{SN-STYLE}.
3357 @endDefstr
3359 @Defmac {SH, [@Var{match-level}], ms}
3360 Unnumbered subheading.
3362 The optional @var{match-level} argument is a GNU extension.  It is a
3363 number indicating the level of the heading, in a manner analogous to the
3364 @var{curr-level} argument to @code{.NH}.  Its purpose is to match the
3365 point size, at which the heading is printed, to the size of a numbered
3366 heading at the same level, when the @code{GROWPS} and @code{PSINCR}
3367 heading size adjustment mechanism is in effect.  @xref{ms Document
3368 Control Registers}.
3369 @endDefmac
3371 The @code{HORPHANS} register (@pxref{ms Document Control Registers})
3372 operates in conjunction with the @code{NH} and @code{SH} macros, to
3373 inhibit the printing of orphaned section headings at the bottom of any
3374 page.
3376 @c ---------------------------------------------------------------------
3378 @node Highlighting in ms, Lists in ms, Headings in ms, ms Body Text
3379 @subsubsection Highlighting
3380 @cindex @code{ms} macros, highlighting
3382 The @file{ms} macros provide a variety of methods to highlight or
3383 emphasize text:
3385 @Defmac {B, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3386 Sets its first argument in @strong{bold type}.  If you specify a second
3387 argument, @code{groff} prints it in the previous font after the bold
3388 text, with no intervening space (this allows you to set punctuation
3389 after the highlighted text without highlighting the punctuation).
3390 Similarly, it prints the third argument (if any) in the previous font
3391 @strong{before} the first argument.  For example,
3393 @Example
3394 .B foo ) (
3395 @endExample
3397 prints (@strong{foo}).
3399 If you give this macro no arguments, @code{groff} prints all text
3400 following in bold until the next highlighting, paragraph, or heading
3401 macro.
3402 @endDefmac
3404 @Defmac {R, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3405 Sets its first argument in roman (or regular) type.  It operates
3406 similarly to the @code{B}@tie{}macro otherwise.
3407 @endDefmac
3409 @Defmac {I, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3410 Sets its first argument in @emph{italic type}.  It operates similarly
3411 to the @code{B}@tie{}macro otherwise.
3412 @endDefmac
3414 @Defmac {CW, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3415 Sets its first argument in a @code{constant width face}.  It operates
3416 similarly to the @code{B}@tie{}macro otherwise.
3417 @endDefmac
3419 @Defmac {BI, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3420 Sets its first argument in bold italic type.  It operates similarly to
3421 the @code{B}@tie{}macro otherwise.
3422 @endDefmac
3424 @Defmac {BX, [@Var{txt}], ms}
3425 Prints its argument and draws a box around it.  If you want to box a
3426 string that contains spaces, use a digit-width space (@code{\0}).
3427 @endDefmac
3429 @Defmac {UL, [@Var{txt} [@Var{post}]], ms}
3430 Prints its first argument with an underline.  If you specify a second
3431 argument, @code{groff} prints it in the previous font after the
3432 underlined text, with no intervening space.
3433 @endDefmac
3435 @Defmac {LG, , ms}
3436 Prints all text following in larger type (two points larger than the
3437 current point size) until the next font size, highlighting, paragraph,
3438 or heading macro.  You can specify this macro multiple times to
3439 enlarge the point size as needed.
3440 @endDefmac
3442 @Defmac {SM, , ms}
3443 Prints all text following in smaller type (two points smaller than the
3444 current point size) until the next type size, highlighting, paragraph,
3445 or heading macro.  You can specify this macro multiple times to reduce
3446 the point size as needed.
3447 @endDefmac
3449 @Defmac {NL, , ms}
3450 Prints all text following in the normal point size (that is, the value
3451 of the @code{PS} register).
3452 @endDefmac
3454 @DefstrList {@Lbrace{}, ms}
3455 @DefstrListEnd {@Rbrace{}, ms}
3456 Text enclosed with @code{\*@{} and @code{\*@}} is printed as a
3457 superscript.
3458 @endDefstr
3460 @c ---------------------------------------------------------------------
3462 @node Lists in ms, Indentation values in ms, Highlighting in ms, ms Body Text
3463 @subsubsection Lists
3464 @cindex @code{ms} macros, lists
3466 The @code{IP} macro handles duties for all lists.
3468 @Defmac {IP, [@Var{marker} [@Var{width}]], ms}
3469 The @var{marker} is usually a bullet glyph (@code{\[bu]}) for unordered
3470 lists, a number (or auto-incrementing number register) for numbered
3471 lists, or a word or phrase for indented (glossary-style) lists.
3473 The @var{width} specifies the indentation for the body of each list
3474 item; its default unit is @samp{n}.  Once specified, the indentation
3475 remains the same for all list items in the document until specified
3476 again.
3478 The @code{PORPHANS} register (@pxref{ms Document Control Registers})
3479 operates in conjunction with the @code{IP} macro, to inhibit the
3480 printing of orphaned list markers at the bottom of any page.
3481 @endDefmac
3483 The following is an example of a bulleted list.
3484 @cindex example markup, bulleted list [@code{ms}]
3485 @cindex bulleted list, example markup [@code{ms}]
3487 @Example
3488 A bulleted list:
3489 .IP \[bu] 2
3490 lawyers
3491 .IP \[bu]
3492 guns
3493 .IP \[bu]
3494 money
3495 @endExample
3497 Produces:
3499 @Example
3500 A bulleted list:
3502 o lawyers
3504 o guns
3506 o money
3507 @endExample
3509 The following is an example of a numbered list.
3510 @cindex example markup, numbered list [@code{ms}]
3511 @cindex numbered list, example markup [@code{ms}]
3513 @Example
3514 .nr step 1 1
3515 A numbered list:
3516 .IP \n[step] 3
3517 lawyers
3518 .IP \n+[step]
3519 guns
3520 .IP \n+[step]
3521 money
3522 @endExample
3524 Produces:
3526 @Example
3527 A numbered list:
3529 1. lawyers
3531 2. guns
3533 3. money
3534 @endExample
3536 Note the use of the auto-incrementing number register in this example.
3538 The following is an example of a glossary-style list.
3539 @cindex example markup, glossary-style list [@code{ms}]
3540 @cindex glossary-style list, example markup [@code{ms}]
3542 @Example
3543 A glossary-style list:
3544 .IP lawyers 0.4i
3545 Two or more attorneys.
3546 .IP guns
3547 Firearms, preferably
3548 large-caliber.
3549 .IP money
3550 Gotta pay for those
3551 lawyers and guns!
3552 @endExample
3554 Produces:
3556 @Example
3557 A glossary-style list:
3559 lawyers
3560       Two or more attorneys.
3562 guns  Firearms, preferably large-caliber.
3564 money
3565       Gotta pay for those lawyers and guns!
3566 @endExample
3568 In the last example, the @code{IP} macro places the definition on the
3569 same line as the term if it has enough space; otherwise, it breaks to
3570 the next line and starts the definition below the term.  This may or may
3571 not be the effect you want, especially if some of the definitions break
3572 and some do not.  The following examples show two possible ways to force
3573 a break.
3575 The first workaround uses the @code{br} request to force a break after
3576 printing the term or label.
3578 @Example
3579 @cartouche
3580 A glossary-style list:
3581 .IP lawyers 0.4i
3582 Two or more attorneys.
3583 .IP guns
3585 Firearms, preferably large-caliber.
3586 .IP money
3587 Gotta pay for those lawyers and guns!
3588 @end cartouche
3589 @endExample
3591 The second workaround uses the @code{\p} escape to force the break.
3592 Note the space following the escape; this is important.  If you omit the
3593 space, @code{groff} prints the first word on the same line as the term
3594 or label (if it fits) @strong{then} breaks the line.
3596 @Example
3597 @cartouche
3598 A glossary-style list:
3599 .IP lawyers 0.4i
3600 Two or more attorneys.
3601 .IP guns
3602 \p Firearms, preferably large-caliber.
3603 .IP money
3604 Gotta pay for those lawyers and guns!
3605 @end cartouche
3606 @endExample
3608 To set nested lists, use the @code{RS} and @code{RE} macros.
3609 @xref{Indentation values in ms}, for more information.
3610 @cindex @code{ms} macros, nested lists
3611 @cindex nested lists [@code{ms}]
3613 For example:
3615 @Example
3616 @cartouche
3617 .IP \[bu] 2
3618 Lawyers:
3620 .IP \[bu]
3621 Dewey,
3622 .IP \[bu]
3623 Cheatham,
3624 .IP \[bu]
3625 and Howe.
3627 .IP \[bu]
3628 Guns
3629 @end cartouche
3630 @endExample
3632 Produces:
3634 @Example
3635 o Lawyers:
3637   o  Dewey,
3639   o  Cheatham,
3641   o  and Howe.
3643 o Guns
3644 @endExample
3646 @c ---------------------------------------------------------------------
3648 @node Indentation values in ms, Tabstops in ms, Lists in ms, ms Body Text
3649 @subsubsection Indentation values
3651 In many situations, you may need to indentation a section of text while
3652 still wrapping and filling.  @xref{Lists in ms}, for an example of
3653 nested lists.
3655 @DefmacList {RS, , ms}
3656 @DefmacListEnd {RE, , ms}
3657 These macros begin and end an indented section.  The @code{PI} register
3658 controls the amount of indentation, allowing the indented text to line
3659 up under hanging and indented paragraphs.
3660 @endDefmac
3662 @xref{ms Displays and Keeps}, for macros to indentation and turn off
3663 filling.
3665 @c ---------------------------------------------------------------------
3667 @node Tabstops in ms, ms Displays and Keeps, Indentation values in ms, ms Body Text
3668 @subsubsection Tab Stops
3670 Use the @code{ta} request to define tab stops as needed.  @xref{Tabs and
3671 Fields}.
3673 @Defmac {TA, , ms}
3674 Use this macro to reset the tab stops to the default for @file{ms}
3675 (every 5n).  You can redefine the @code{TA} macro to create a different
3676 set of default tab stops.
3677 @endDefmac
3679 @c ---------------------------------------------------------------------
3681 @node ms Displays and Keeps, ms Insertions, Tabstops in ms, ms Body Text
3682 @subsubsection Displays and keeps
3683 @cindex @code{ms} macros, displays
3684 @cindex @code{ms} macros, keeps
3685 @cindex keeps [@code{ms}]
3686 @cindex displays [@code{ms}]
3688 Use displays to show text-based examples or figures (such as code
3689 listings).
3691 Displays turn off filling, so lines of code are displayed as-is without
3692 inserting @code{br} requests in between each line.  Displays can be
3693 @dfn{kept} on a single page, or allowed to break across pages.
3695 @DefmacList {DS, @t{L}, ms}
3696 @DefmacItem {LD, , ms}
3697 @DefmacListEnd {DE, , ms}
3698 Left-justified display.  The @samp{.DS L} call generates a page break,
3699 if necessary, to keep the entire display on one page.  The @code{LD}
3700 macro allows the display to break across pages.  The @code{DE} macro
3701 ends the display.
3702 @endDefmac
3704 @DefmacList {DS, @t{I}, ms}
3705 @DefmacItem {ID, , ms}
3706 @DefmacListEnd {DE, , ms}
3707 Indents the display as defined by the @code{DI} register.  The @samp{.DS
3708 I} call generates a page break, if necessary, to keep the entire display
3709 on one page.  The @code{ID} macro allows the display to break across
3710 pages.  The @code{DE} macro ends the display.
3711 @endDefmac
3713 @DefmacList {DS, @t{B}, ms}
3714 @DefmacItem {BD, , ms}
3715 @DefmacListEnd {DE, , ms}
3716 Sets a block-centered display: the entire display is left-justified, but
3717 indented so that the longest line in the display is centered on the
3718 page.  The @samp{.DS B} call generates a page break, if necessary, to
3719 keep the entire display on one page.  The @code{BD} macro allows the
3720 display to break across pages.  The @code{DE} macro ends the display.
3721 @endDefmac
3723 @DefmacList {DS, @t{C}, ms}
3724 @DefmacItem {CD, , ms}
3725 @DefmacListEnd {DE, , ms}
3726 Sets a centered display: each line in the display is centered.  The
3727 @samp{.DS C} call generates a page break, if necessary, to keep the
3728 entire display on one page.  The @code{CD} macro allows the display to
3729 break across pages.  The @code{DE} macro ends the display.
3730 @endDefmac
3732 @DefmacList {DS, @t{R}, ms}
3733 @DefmacItem {RD, , ms}
3734 @DefmacListEnd {DE, , ms}
3735 Right-justifies each line in the display.  The @samp{.DS R} call
3736 generates a page break, if necessary, to keep the entire display on one
3737 page.  The @code{RD} macro allows the display to break across pages.
3738 The @code{DE} macro ends the display.
3739 @endDefmac
3741 @DefmacList {Ds, , ms}
3742 @DefmacListEnd {De, , ms}
3743 These two macros were formerly provided as aliases for @code{DS} and
3744 @code{DE}, respectively.  They have been removed, and should no longer
3745 be used.  The original implementations of @code{DS} and @code{DE} are
3746 retained, and should be used instead.  X11 documents which actually use
3747 @code{Ds} and @code{De} always load a specific macro file from the X11
3748 distribution (@file{macros.t}) which provides proper definitions for the
3749 two macros.
3750 @endDefmac
3752 On occasion, you may want to @dfn{keep} other text together on a page.
3753 For example, you may want to keep two paragraphs together, or a
3754 paragraph that refers to a table (or list, or other item) immediately
3755 following.  The @file{ms} macros provide the @code{KS} and @code{KE}
3756 macros for this purpose.
3758 @DefmacList {KS, , ms}
3759 @DefmacListEnd {KE, , ms}
3760 The @code{KS} macro begins a block of text to be kept on a single page,
3761 and the @code{KE} macro ends the block.
3762 @endDefmac
3764 @DefmacList {KF, , ms}
3765 @DefmacListEnd {KE, , ms}
3766 Specifies a @dfn{floating keep}; if the keep cannot fit on the current
3767 page, @code{groff} holds the contents of the keep and allows text
3768 following the keep (in the source file) to fill in the remainder of the
3769 current page.  When the page breaks, whether by an explicit @code{bp}
3770 request or by reaching the end of the page, @code{groff} prints the
3771 floating keep at the top of the new page.  This is useful for printing
3772 large graphics or tables that do not need to appear exactly where
3773 specified.
3774 @endDefmac
3776 You can also use the @code{ne} request to force a page break if there is
3777 not enough vertical space remaining on the page.
3779 Use the following macros to draw a box around a section of text (such as
3780 a display).
3782 @DefmacList {B1, , ms}
3783 @DefmacListEnd {B2, , ms}
3784 Marks the beginning and ending of text that is to have a box drawn
3785 around it.  The @code{B1} macro begins the box; the @code{B2} macro ends
3786 it.  Text in the box is automatically placed in a diversion (keep).
3787 @endDefmac
3789 @c ---------------------------------------------------------------------
3791 @node ms Insertions, Example multi-page table, ms Displays and Keeps, ms Body Text
3792 @subsubsection Tables, figures, equations, and references
3793 @cindex @code{ms} macros, tables
3794 @cindex @code{ms} macros, figures
3795 @cindex @code{ms} macros, equations
3796 @cindex @code{ms} macros, references
3797 @cindex tables [@code{ms}]
3798 @cindex figures [@code{ms}]
3799 @cindex equations [@code{ms}]
3800 @cindex references [@code{ms}]
3802 The @file{ms} macros support the standard @code{groff} preprocessors:
3803 @code{tbl}, @code{pic}, @code{eqn}, and @code{refer}.
3804 @pindex tbl
3805 @pindex pic
3806 @pindex eqn
3807 @pindex refer
3808 You mark text meant for preprocessors by enclosing it in pairs of tags
3809 as follows.
3811 @DefmacList {TS, [@code{H}], ms}
3812 @DefmacListEnd {TE, , ms}
3813 Denotes a table, to be processed by the @code{tbl} preprocessor.  The
3814 optional argument@tie{}@code{H} to @code{TS} instructs @code{groff} to
3815 create a running header with the information up to the @code{TH} macro.
3816 @code{groff} prints the header at the beginning of the table; if the
3817 table runs onto another page, @code{groff} prints the header on the next
3818 page as well.
3819 @endDefmac
3821 @DefmacList {PS, , ms}
3822 @DefmacListEnd {PE, , ms}
3823 Denotes a graphic, to be processed by the @code{pic} preprocessor.  You
3824 can create a @code{pic} file by hand, using the @acronym{AT&T}
3825 @code{pic} manual available on the Web as a reference, or by using a
3826 graphics program such as @code{xfig}.
3827 @endDefmac
3829 @DefmacList {EQ, [@Var{align}], ms}
3830 @DefmacListEnd {EN, , ms}
3831 Denotes an equation, to be processed by the @code{eqn} preprocessor.
3832 The optional @var{align} argument can be @code{C}, @code{L},
3833 or@tie{}@code{I} to center (the default), left-justify, or indent the
3834 equation.
3835 @endDefmac
3837 @DefmacList {[, , ms}
3838 @DefmacListEnd {], , ms}
3839 Denotes a reference, to be processed by the @code{refer} preprocessor.
3840 The @acronym{GNU} @cite{refer(1)} man page provides a comprehensive
3841 reference to the preprocessor and the format of the bibliographic
3842 database.
3843 @endDefmac
3845 @menu
3846 * Example multi-page table::
3847 @end menu
3849 @c ---------------------------------------------------------------------
3851 @node Example multi-page table, ms Footnotes, ms Insertions, ms Body Text
3852 @subsubsection An example multi-page table
3853 @cindex example markup, multi-page table [@code{ms}]
3854 @cindex multi-page table, example markup [@code{ms}]
3856 The following is an example of how to set up a table that may print
3857 across two or more pages.
3859 @Example
3860 @cartouche
3861 .TS H
3862 allbox expand;
3863 cb | cb .
3864 Text      ...of heading...
3868 l | l .
3869 ... the rest of the table follows...
3872 @end cartouche
3873 @endExample
3875 @c ---------------------------------------------------------------------
3877 @node ms Footnotes,  , Example multi-page table, ms Body Text
3878 @subsubsection Footnotes
3879 @cindex @code{ms} macros, footnotes
3880 @cindex footnotes [@code{ms}]
3882 The @file{ms} macro package has a flexible footnote system.  You can
3883 specify either numbered footnotes or symbolic footnotes (that is, using
3884 a marker such as a dagger symbol).
3886 @Defstr {*, ms}
3887 Specifies the location of a numbered footnote marker in the text.
3888 @endDefesc
3890 @DefmacList {FS, , ms}
3891 @DefmacListEnd {FE, , ms}
3892 Specifies the text of the footnote.  The default action is to create a
3893 numbered footnote; you can create a symbolic footnote by specifying a
3894 @dfn{mark} glyph (such as @code{\[dg]} for the dagger glyph) in the body
3895 text and as an argument to the @code{FS} macro, followed by the text of
3896 the footnote and the @code{FE} macro.
3897 @endDefmac
3899 You can control how @code{groff} prints footnote numbers by changing the
3900 value of the @code{FF} register.  @xref{ms Document Control Registers}.
3902 @cindex footnotes, and keeps [@code{ms}]
3903 @cindex keeps, and footnotes [@code{ms}]
3904 @cindex footnotes, and displays [@code{ms}]
3905 @cindex displays, and footnotes [@code{ms}]
3906 Footnotes can be safely used within keeps and displays, but you should
3907 avoid using numbered footnotes within floating keeps.  You can set a
3908 second @code{\**} marker between a @code{\**} and its corresponding
3909 @code{.FS} entry; as long as each @code{FS} macro occurs @emph{after}
3910 the corresponding @code{\**} and the occurrences of @code{.FS} are in
3911 the same order as the corresponding occurrences of @code{\**}.
3913 @c ---------------------------------------------------------------------
3915 @node ms Page Layout, Differences from AT&T ms, ms Body Text, ms
3916 @subsection Page layout
3917 @cindex @code{ms} macros, page layout
3918 @cindex page layout [@code{ms}]
3920 The default output from the @file{ms} macros provides a minimalist page
3921 layout: it prints a single column, with the page number centered at the
3922 top of each page.  It prints no footers.
3924 You can change the layout by setting the proper number registers and
3925 strings.
3927 @menu
3928 * ms Headers and Footers::
3929 * ms Margins::
3930 * ms Multiple Columns::
3931 * ms TOC::
3932 * ms Strings and Special Characters::
3933 @end menu
3935 @c ---------------------------------------------------------------------
3937 @node ms Headers and Footers, ms Margins, ms Page Layout, ms Page Layout
3938 @subsubsection Headers and footers
3939 @cindex @code{ms} macros, headers
3940 @cindex @code{ms} macros, footers
3941 @cindex headers [@code{ms}]
3942 @cindex footers [@code{ms}]
3944 For documents that do not distinguish between odd and even pages, set
3945 the following strings:
3947 @DefstrList {LH, ms}
3948 @DefstrItem {CH, ms}
3949 @DefstrListEnd {RH, ms}
3950 Sets the left, center, and right headers.
3951 @endDefstr
3953 @DefstrList {LF, ms}
3954 @DefstrItem {CF, ms}
3955 @DefstrListEnd {RF, ms}
3956 Sets the left, center, and right footers.
3957 @endDefstr
3959 For documents that need different information printed in the even and
3960 odd pages, use the following macros:
3962 @DefmacList {OH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3963 @DefmacItem {EH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3964 @DefmacItem {OF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3965 @DefmacListEnd {EF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3966 The @code{OH} and @code{EH} macros define headers for the odd and even
3967 pages; the @code{OF} and @code{EF} macros define footers for the odd and
3968 even pages.  This is more flexible than defining the individual strings.
3970 You can replace the quote (@code{'}) marks with any character not
3971 appearing in the header or footer text.
3972 @endDefmac
3974 To specify custom header and footer processing, redefine the following
3975 macros:
3977 @DefmacList {PT,, ms}
3978 @DefmacItem {HD,, ms}
3979 @DefmacListEnd {BT,, ms}
3980 The @code{PT} macro defines a custom header; the @code{BT} macro defines
3981 a custom footer.  These macros must handle odd/even/first page
3982 differences if necessary.
3984 The @code{HD} macro defines additional header processing to take place
3985 after executing the @code{PT} macro.
3986 @endDefmac
3988 @c ---------------------------------------------------------------------
3990 @node ms Margins, ms Multiple Columns, ms Headers and Footers, ms Page Layout
3991 @subsubsection Margins
3992 @cindex @code{ms} macros, margins
3994 You control margins using a set of number registers.  @xref{ms Document
3995 Control Registers}, for details.
3997 @c ---------------------------------------------------------------------
3999 @node ms Multiple Columns, ms TOC, ms Margins, ms Page Layout
4000 @subsubsection Multiple columns
4001 @cindex @code{ms} macros, multiple columns
4002 @cindex multiple columns [@code{ms}]
4004 The @file{ms} macros can set text in as many columns as do reasonably
4005 fit on the page.  The following macros are available; all of them force
4006 a page break if a multi-column mode is already set.  However, if the
4007 current mode is single-column, starting a multi-column mode does
4008 @emph{not} force a page break.
4010 @Defmac {1C, , ms}
4011 Single-column mode.
4012 @endDefmac
4014 @Defmac {2C, , ms}
4015 Two-column mode.
4016 @endDefmac
4018 @Defmac {MC, [@Var{width} [@Var{gutter}]], ms}
4019 Multi-column mode.  If you specify no arguments, it is equivalent to the
4020 @code{2C} macro.  Otherwise, @var{width} is the width of each column and
4021 @var{gutter} is the space between columns.  The @code{MINGW} number
4022 register controls the default gutter width.
4023 @endDefmac
4025 @c ---------------------------------------------------------------------
4027 @node ms TOC, ms Strings and Special Characters, ms Multiple Columns, ms Page Layout
4028 @subsubsection Creating a table of contents
4029 @cindex @code{ms} macros, creating table of contents
4030 @cindex table of contents, creating [@code{ms}]
4032 The facilities in the @file{ms} macro package for creating a table of
4033 contents are semi-automated at best.  Assuming that you want the table
4034 of contents to consist of the document's headings, you need to repeat
4035 those headings wrapped in @code{XS} and @code{XE} macros.
4037 @DefmacList {XS, [@Var{page}], ms}
4038 @DefmacItem {XA, [@Var{page}], ms}
4039 @DefmacListEnd {XE, , ms}
4040 These macros define a table of contents or an individual entry in the
4041 table of contents, depending on their use.  The macros are very simple;
4042 they cannot indent a heading based on its level.  The easiest way to
4043 work around this is to add tabs to the table of contents string.  The
4044 following is an example:
4046 @Example
4047 @cartouche
4048 .NH 1
4049 Introduction
4051 Introduction
4056 .NH 2
4057 Methodology
4059 Methodology
4063 @end cartouche
4064 @endExample
4066 You can manually create a table of contents by beginning with the
4067 @code{XS} macro for the first entry, specifying the page number for that
4068 entry as the argument to @code{XS}.  Add subsequent entries using the
4069 @code{XA} macro, specifying the page number for that entry as the
4070 argument to @code{XA}.  The following is an example:
4072 @Example
4073 @cartouche
4074 .XS 1
4075 Introduction
4076 .XA 2
4077 A Brief History of the Universe
4078 .XA 729
4079 Details of Galactic Formation
4082 @end cartouche
4083 @endExample
4084 @endDefmac
4086 @Defmac {TC, [@code{no}], ms}
4087 Prints the table of contents on a new page, setting the page number
4088 to@tie{}@strong{i} (Roman lowercase numeral one).  You should usually
4089 place this macro at the end of the file, since @code{groff} is a
4090 single-pass formatter and can only print what has been collected up to
4091 the point that the @code{TC} macro appears.
4093 The optional argument @code{no} suppresses printing the title specified
4094 by the string register @code{TOC}.
4095 @endDefmac
4097 @Defmac {PX, [@code{no}], ms}
4098 Prints the table of contents on a new page, using the current page
4099 numbering sequence.  Use this macro to print a manually-generated table
4100 of contents at the beginning of your document.
4102 The optional argument @code{no} suppresses printing the title specified
4103 by the string register @code{TOC}.
4104 @endDefmac
4106 The @cite{Groff and Friends HOWTO} includes a @code{sed} script that
4107 automatically inserts @code{XS} and @code{XE} macro entries after each
4108 heading in a document.
4110 Altering the @code{NH} macro to automatically build the table of
4111 contents is perhaps initially more difficult, but would save a great
4112 deal of time in the long run if you use @file{ms} regularly.
4114 @c ---------------------------------------------------------------------
4116 @node ms Strings and Special Characters,  , ms TOC, ms Page Layout
4117 @subsubsection Strings and Special Characters
4118 @cindex @code{ms} macros, strings
4119 @cindex @code{ms} macros, special characters
4120 @cindex @code{ms} macros, accent marks
4121 @cindex accent marks [@code{ms}]
4122 @cindex special characters [@code{ms}]
4123 @cindex strings [@code{ms}]
4125 The @file{ms} macros provide the following predefined strings.  You can
4126 change the string definitions to help in creating documents in languages
4127 other than English.
4129 @Defstr {REFERENCES, ms}
4130 Contains the string printed at the beginning of the references
4131 (bibliography) page.  The default is @samp{References}.
4132 @endDefstr
4134 @Defstr {ABSTRACT, ms}
4135 Contains the string printed at the beginning of the abstract.  The
4136 default is @samp{ABSTRACT}.
4137 @endDefstr
4139 @Defstr {TOC, ms}
4140 Contains the string printed at the beginning of the table of contents.
4141 @endDefstr
4143 @DefstrList {MONTH1, ms}
4144 @DefstrItem {MONTH2, ms}
4145 @DefstrItem {MONTH3, ms}
4146 @DefstrItem {MONTH4, ms}
4147 @DefstrItem {MONTH5, ms}
4148 @DefstrItem {MONTH6, ms}
4149 @DefstrItem {MONTH7, ms}
4150 @DefstrItem {MONTH8, ms}
4151 @DefstrItem {MONTH9, ms}
4152 @DefstrItem {MONTH10, ms}
4153 @DefstrItem {MONTH11, ms}
4154 @DefstrListEnd {MONTH12, ms}
4155 Prints the full name of the month in dates.  The default is
4156 @samp{January}, @samp{February}, etc.
4157 @endDefstr
4159 The following special characters are available@footnote{For an
4160 explanation what special characters are see @ref{Special Characters}.}:
4162 @Defstr {-, ms}
4163 Prints an em dash.
4164 @endDefstr
4166 @DefstrList {Q, ms}
4167 @DefstrListEnd {U, ms}
4168 Prints typographer's quotes in troff, and plain quotes in nroff.
4169 @code{\*Q} is the left quote and @code{\*U} is the right quote.
4170 @endDefstr
4172 Improved accent marks are available in the @file{ms} macros.
4174 @Defmac {AM, , ms}
4175 Specify this macro at the beginning of your document to enable extended
4176 accent marks and special characters.  This is a Berkeley extension.
4178 To use the accent marks, place them @strong{after} the character being
4179 accented.
4181 Note that groff's native support for accents is superior to the
4182 following definitions.
4183 @endDefmac
4185 The following accent marks are available after invoking the @code{AM}
4186 macro:
4188 @Defstr {\', ms}
4189 Acute accent.
4190 @endDefstr
4192 @Defstr {\`, ms}
4193 Grave accent.
4194 @endDefstr
4196 @Defstr {^, ms}
4197 Circumflex.
4198 @endDefstr
4200 @Defstr {\,, ms}
4201 Cedilla.
4202 @endDefstr
4204 @Defstr {~, ms}
4205 Tilde.
4206 @endDefstr
4208 @deffn String @t{\*[:]}
4209 @ifnotinfo
4210 @stindex : @r{[}ms@r{]}
4211 @end ifnotinfo
4212 @ifinfo
4213 @stindex \*[@r{<colon>}] @r{[}ms@r{]}
4214 @end ifinfo
4215 Umlaut.
4216 @end deffn
4218 @Defstr {v, ms}
4219 Hacek.
4220 @endDefstr
4222 @Defstr {_, ms}
4223 Macron (overbar).
4224 @endDefstr
4226 @Defstr {., ms}
4227 Underdot.
4228 @endDefstr
4230 @Defstr {o, ms}
4231 Ring above.
4232 @endDefstr
4234 The following are standalone characters available after invoking the
4235 @code{AM} macro:
4237 @Defstr {?, ms}
4238 Upside-down question mark.
4239 @endDefstr
4241 @Defstr {!, ms}
4242 Upside-down exclamation point.
4243 @endDefstr
4245 @Defstr {8, ms}
4246 German ÃŸ ligature.
4247 @endDefstr
4249 @Defstr {3, ms}
4250 Yogh.
4251 @endDefstr
4253 @Defstr {Th, ms}
4254 Uppercase thorn.
4255 @endDefstr
4257 @Defstr {th, ms}
4258 Lowercase thorn.
4259 @endDefstr
4261 @Defstr {D-, ms}
4262 Uppercase eth.
4263 @endDefstr
4265 @Defstr {d-, ms}
4266 Lowercase eth.
4267 @endDefstr
4269 @Defstr {q, ms}
4270 Hooked o.
4271 @endDefstr
4273 @Defstr {ae, ms}
4274 Lowercase Ã¦ ligature.
4275 @endDefstr
4277 @Defstr {Ae, ms}
4278 Uppercase Ã† ligature.
4279 @endDefstr
4281 @c ---------------------------------------------------------------------
4283 @node Differences from AT&T ms, Naming Conventions, ms Page Layout, ms
4284 @subsection Differences from @acronym{AT&T} @file{ms}
4285 @cindex @code{ms} macros, differences from @acronym{AT&T}
4286 @cindex @acronym{AT&T} @code{troff}, @code{ms} macro package differences
4288 This section lists the (minor) differences between the @code{groff -ms}
4289 macros and @acronym{AT&T} @code{troff -ms} macros.
4291 @itemize @bullet
4292 @item
4293 The internals of @code{groff -ms} differ from the internals of
4294 @acronym{AT&T} @code{troff -ms}.  Documents that depend upon
4295 implementation details of @acronym{AT&T} @code{troff -ms} may not format
4296 properly with @code{groff -ms}.
4298 @item
4299 The general error-handling policy of @code{groff -ms} is to detect and
4300 report errors, rather than silently to ignore them.
4302 @item
4303 @code{groff -ms} does not work in compatibility mode (this is, with the
4304 @option{-C} option).
4306 @item
4307 There is no special support for typewriter-like devices.
4309 @item
4310 @code{groff -ms} does not provide cut marks.
4312 @item
4313 Multiple line spacing is not supported.  Use a larger vertical spacing
4314 instead.
4316 @item
4317 Some @acronym{UNIX} @code{ms} documentation says that the @code{CW} and
4318 @code{GW} number registers can be used to control the column width and
4319 gutter width, respectively.  These number registers are not used in
4320 @code{groff -ms}.
4322 @item
4323 Macros that cause a reset (paragraphs, headings, etc.@:) may change the
4324 indentation.  Macros that change the indentation do not increment or
4325 decrement the indentation, but rather set it absolutely.  This can cause
4326 problems for documents that define additional macros of their own.  The
4327 solution is to use not the @code{in} request but instead the @code{RS}
4328 and @code{RE} macros.
4330 @item
4331 To make @code{groff -ms} use the default page offset (which also
4332 specifies the left margin), the @code{PO} register must stay undefined
4333 until the first @file{-ms} macro is evaluated.  This implies that
4334 @code{PO} should not be used early in the document, unless it is changed
4335 also: Remember that accessing an undefined register automatically
4336 defines it.
4337 @end itemize
4339 @Defmpreg {GS, ms}
4340 This number register is set to@tie{}1 by the @code{groff -ms} macros,
4341 but it is not used by the @code{AT&T} @code{troff -ms} macros.
4342 Documents that need to determine whether they are being formatted with
4343 @code{AT&T} @code{troff -ms} or @code{groff -ms} should use this number
4344 register.
4345 @endDefmpreg
4347 Emulations of a few ancient Bell Labs macros can be re-enabled by
4348 calling the otherwise undocumented @code{SC} section-header macro.
4349 Calling @code{SC} enables @code{UC} for marking up a product or
4350 application name, and the pair @code{P1}/@code{P2} for surrounding code
4351 example displays.
4353 These are not enabled by default because (a)@tie{}they were not
4354 documented, in the original @code{ms} manual, and (b)@tie{}the @code{P1}
4355 and @code{UC} macros collide with different macros with the same names
4356 in the Berkeley version of @code{ms}.
4358 These @code{groff} emulations are sufficient to give back the 1976
4359 Kernighan@tie{}& Cherry paper @cite{Typsetting Mathematics -- User's
4360 Guide} its section headings, and restore some text that had gone missing
4361 as arguments of undefined macros.  No warranty express or implied is
4362 given as to how well the typographic details these produce match the
4363 original Bell Labs macros.
4365 @menu
4366 * Missing ms Macros::
4367 * Additional ms Macros::
4368 @end menu
4370 @c ---------------------------------------------------------------------
4372 @node Missing ms Macros, Additional ms Macros, Differences from AT&T ms, Differences from AT&T ms
4373 @subsubsection @code{troff} macros not appearing in @code{groff}
4375 Macros missing from @code{groff -ms} are cover page macros specific to
4376 Bell Labs and Berkeley.  The macros known to be missing are:
4378 @table @code
4379 @item .TM
4380 Technical memorandum; a cover sheet style
4382 @item .IM
4383 Internal memorandum; a cover sheet style
4385 @item .MR
4386 Memo for record; a cover sheet style
4388 @item .MF
4389 Memo for file; a cover sheet style
4391 @item .EG
4392 Engineer's notes; a cover sheet style
4394 @item .TR
4395 Computing Science Tech Report; a cover sheet style
4397 @item .OK
4398 Other keywords
4400 @item .CS
4401 Cover sheet information
4403 @item .MH
4404 A cover sheet macro
4405 @end table
4407 @c ---------------------------------------------------------------------
4409 @node Additional ms Macros,  , Missing ms Macros, Differences from AT&T ms
4410 @subsubsection @code{groff} macros not appearing in @acronym{AT&T} @code{troff}
4412 The @code{groff -ms} macros have a few minor extensions compared to the
4413 @acronym{AT&T} @code{troff -ms} macros.
4415 @Defmac {AM, , ms}
4416 Improved accent marks.  @xref{ms Strings and Special Characters}, for
4417 details.
4418 @endDefmac
4420 @Defmac {DS, @t{I}, ms}
4421 Indented display.  The default behavior of @acronym{AT&T} @code{troff
4422 -ms} was to indent; the @code{groff} default prints displays flush left
4423 with the body text.
4424 @endDefmac
4426 @Defmac {CW, , ms}
4427 Print text in @code{constant width} (Courier) font.
4428 @endDefmac
4430 @Defmac {IX, , ms}
4431 Indexing term (printed on standard error).  You can write a script to
4432 capture and process an index generated in this manner.
4433 @endDefmac
4435 The following additional number registers
4436 appear in @code{groff -ms}:
4438 @Defmpreg {MINGW, ms}
4439 Specifies a minimum space between columns (for multi-column output);
4440 this takes the place of the @code{GW} register that was documented but
4441 apparently not implemented in @acronym{AT&T} @code{troff}.
4442 @endDefmpreg
4444 Several new string registers are available as well.  You can change
4445 these to handle (for example) the local language.  @xref{ms Strings and
4446 Special Characters}, for details.
4448 @c ---------------------------------------------------------------------
4450 @node Naming Conventions,  , Differences from AT&T ms, ms
4451 @subsection Naming Conventions
4452 @cindex @code{ms} macros, naming conventions
4453 @cindex naming conventions, @code{ms} macros
4455 The following conventions are used for names of macros, strings and
4456 number registers.  External names available to documents that use the
4457 @code{groff -ms} macros contain only uppercase letters and digits.
4459 Internally the macros are divided into modules; naming conventions are
4460 as follows:
4462 @itemize @bullet
4463 @item
4464 Names used only within one module are of the form
4465 @var{module}@code{*}@var{name}.
4467 @item
4468 Names used outside the module in which they are defined are of the form
4469 @var{module}@code{@@}@var{name}.
4471 @item
4472 Names associated with a particular environment are of the form
4473 @var{environment}@code{:}@var{name}; these are used only within the
4474 @code{par} module.
4476 @item
4477 @var{name} does not have a module prefix.
4479 @item
4480 Constructed names used to implement arrays are of the form
4481 @var{array}@code{!}@var{index}.
4482 @end itemize
4484 Thus the groff ms macros reserve the following names:
4486 @itemize @bullet
4487 @item
4488 Names containing the characters @code{*}, @code{@@}, and@tie{}@code{:}.
4490 @item
4491 Names containing only uppercase letters and digits.
4492 @end itemize
4495 @c =====================================================================
4497 @node me, mm, ms, Macro Packages
4498 @section @file{me}
4499 @cindex @code{me} macro package
4501 @c XXX documentation
4502 @c XXX this is a placeholder until we get stuff knocked into shape
4503 See the @file{meintro.me} and @file{meref.me} documents in groff's
4504 @file{doc} directory.
4507 @c =====================================================================
4509 @node mm,  , me, Macro Packages
4510 @section @file{mm}
4511 @cindex @code{mm} macro package
4513 @c XXX documentation
4514 @c XXX this is a placeholder until we get stuff knocked into shape
4515 See the @cite{groff_mm(7)} man page (type @command{man groff_mm} at the
4516 command line).
4520 @c =====================================================================
4521 @c =====================================================================
4523 @node gtroff Reference, Preprocessors, Macro Packages, Top
4524 @chapter @code{gtroff} Reference
4525 @cindex reference, @code{gtroff}
4526 @cindex @code{gtroff}, reference
4528 This chapter covers @strong{all} of the facilities of @code{gtroff}.
4529 Users of macro packages may skip it if not interested in details.
4532 @menu
4533 * Text::
4534 * Measurements::
4535 * Expressions::
4536 * Identifiers::
4537 * Embedded Commands::
4538 * Registers::
4539 * Manipulating Filling and Adjusting::
4540 * Manipulating Hyphenation::
4541 * Manipulating Spacing::
4542 * Tabs and Fields::
4543 * Character Translations::
4544 * Troff and Nroff Mode::
4545 * Line Layout::
4546 * Line Control::
4547 * Page Layout::
4548 * Page Control::
4549 * Fonts and Symbols::
4550 * Sizes::
4551 * Strings::
4552 * Conditionals and Loops::
4553 * Writing Macros::
4554 * Page Motions::
4555 * Drawing Requests::
4556 * Traps::
4557 * Diversions::
4558 * Environments::
4559 * Suppressing output::
4560 * Colors::
4561 * I/O::
4562 * Postprocessor Access::
4563 * Miscellaneous::
4564 * Gtroff Internals::
4565 * Debugging::
4566 * Implementation Differences::
4567 @end menu
4570 @c =====================================================================
4572 @node Text, Measurements, gtroff Reference, gtroff Reference
4573 @section Text
4574 @cindex text, @code{gtroff} processing
4576 @code{gtroff} input files contain text with control commands
4577 interspersed throughout.  But, even without control codes, @code{gtroff}
4578 still does several things with the input text:
4580 @itemize @bullet
4581 @item
4582 filling and adjusting
4584 @item
4585 adding additional space after sentences
4587 @item
4588 hyphenating
4590 @item
4591 inserting implicit line breaks
4592 @end itemize
4594 @menu
4595 * Filling and Adjusting::
4596 * Hyphenation::
4597 * Sentences::
4598 * Tab Stops::
4599 * Implicit Line Breaks::
4600 * Input Conventions::
4601 * Input Encodings::
4602 @end menu
4604 @c ---------------------------------------------------------------------
4606 @node Filling and Adjusting, Hyphenation, Text, Text
4607 @subsection Filling and Adjusting
4608 @cindex filling
4609 @cindex adjusting
4611 When @code{gtroff} reads text, it collects words from the input and fits
4612 as many of them together on one output line as it can.  This is known as
4613 @dfn{filling}.
4615 @cindex leading spaces
4616 @cindex spaces, leading and trailing
4617 @cindex extra spaces
4618 @cindex trailing spaces
4619 Once @code{gtroff} has a @dfn{filled} line, it tries to @dfn{adjust} it.
4620 This means it widens the spacing between words until the text reaches
4621 the right margin (in the default adjustment mode).  Extra spaces between
4622 words are preserved, but spaces at the end of lines are ignored.  Spaces
4623 at the front of a line cause a @dfn{break} (breaks are explained in
4624 @ref{Implicit Line Breaks}).
4626 @xref{Manipulating Filling and Adjusting}.
4628 @c ---------------------------------------------------------------------
4630 @node Hyphenation, Sentences, Filling and Adjusting, Text
4631 @subsection Hyphenation
4632 @cindex hyphenation
4634 Since the odds are not great for finding a set of words, for every
4635 output line, which fit nicely on a line without inserting excessive
4636 amounts of space between words, @code{gtroff} hyphenates words so that
4637 it can justify lines without inserting too much space between words.  It
4638 uses an internal hyphenation algorithm (a simplified version of the
4639 algorithm used within @TeX{}) to indicate which words can be hyphenated
4640 and how to do so.  When a word is hyphenated, the first part of the word
4641 is added to the current filled line being output (with an attached
4642 hyphen), and the other portion is added to the next line to be filled.
4644 @xref{Manipulating Hyphenation}.
4646 @c ---------------------------------------------------------------------
4648 @node Sentences, Tab Stops, Hyphenation, Text
4649 @subsection Sentences
4650 @cindex sentences
4652 Although it is often debated, some typesetting rules say there should be
4653 different amounts of space after various punctuation marks.  For
4654 example, the @cite{Chicago typsetting manual} says that a period at the
4655 end of a sentence should have twice as much space following it as would
4656 a comma or a period as part of an abbreviation.
4658 @c XXX exact citation of Chicago manual
4660 @cindex sentence space
4661 @cindex space between sentences
4662 @cindex french-spacing
4663 @code{gtroff} does this by flagging certain characters (normally
4664 @samp{!}, @samp{?}, and @samp{.}) as @dfn{end-of-sentence} characters.
4665 When @code{gtroff} encounters one of these characters at the end of a
4666 line, it appends a normal space followed by a @dfn{sentence space} in
4667 the formatted output.  (This justifies one of the conventions mentioned
4668 in @ref{Input Conventions}.)
4670 @cindex transparent characters
4671 @cindex character, transparent
4672 @cindex @code{dg} glyph, at end of sentence
4673 @cindex @code{rq} glyph, at end of sentence
4674 @cindex @code{"}, at end of sentence
4675 @cindex @code{'}, at end of sentence
4676 @cindex @code{)}, at end of sentence
4677 @cindex @code{]}, at end of sentence
4678 @cindex @code{*}, at end of sentence
4679 In addition, the following characters and symbols are treated
4680 transparently while handling end-of-sentence characters: @samp{"},
4681 @samp{'}, @samp{)}, @samp{]}, @samp{*}, @code{\[dg]}, and @code{\[rq]}.
4683 See the @code{cflags} request in @ref{Using Symbols}, for more details.
4685 @cindex @code{\&}, at end of sentence
4686 To prevent the insertion of extra space after an end-of-sentence
4687 character (at the end of a line), append @code{\&}.
4689 @c ---------------------------------------------------------------------
4691 @node Tab Stops, Implicit Line Breaks, Sentences, Text
4692 @subsection Tab Stops
4693 @cindex tab stops
4694 @cindex stops, tabulator
4695 @cindex tab character
4696 @cindex character, tabulator
4698 @cindex @acronym{EBCDIC} encoding
4699 @cindex encoding, @acronym{EBCDIC}
4700 @code{gtroff} translates @dfn{tabulator characters}, also called
4701 @dfn{tabs} (normally code point @acronym{ASCII} @code{0x09} or
4702 @acronym{EBCDIC} @code{0x05}), in the input into movements to the next
4703 tabulator stop.  These tab stops are initially located every half inch
4704 across the page.  Using this, simple tables can be made easily.
4705 However, it can often be deceptive as the appearance (and width) of the
4706 text on a terminal and the results from @code{gtroff} can vary greatly.
4708 Also, a possible sticking point is that lines beginning with tab
4709 characters are still filled, again producing unexpected results.  For
4710 example, the following input
4712 @multitable {12345678} {12345678} {12345678} {12345678}
4713 @item
4714 @tab 1 @tab 2 @tab 3
4715 @item
4716 @tab   @tab 4 @tab 5
4717 @end multitable
4719 @noindent
4720 produces
4722 @multitable {12345678} {12345678} {12345678} {12345678} {12345678} {12345678} {12345678}
4723 @item
4724 @tab 1 @tab 2 @tab 3 @tab   @tab 4 @tab 5
4725 @end multitable
4727 @xref{Tabs and Fields}.
4729 @c ---------------------------------------------------------------------
4731 @node Implicit Line Breaks, Input Conventions, Tab Stops, Text
4732 @subsection Implicit Line Breaks
4733 @cindex implicit line breaks
4734 @cindex implicit breaks of lines
4735 @cindex line, implicit breaks
4736 @cindex break, implicit
4737 @cindex line break
4739 An important concept in @code{gtroff} is the @dfn{break}.  When a break
4740 occurs, @code{gtroff} outputs the partially filled line (unjustified),
4741 and resumes collecting and filling text on the next output line.
4743 @cindex blank line
4744 @cindex empty line
4745 @cindex line, blank
4746 @cindex blank line macro (@code{blm})
4747 There are several ways to cause a break in @code{gtroff}.  A blank line
4748 not only causes a break, but it also outputs a one-line vertical space
4749 (effectively a blank line).  Note that this behaviour can be modified
4750 with the blank line macro request @code{blm}.  @xref{Blank Line Traps}.
4752 @cindex fill mode
4753 @cindex mode, fill
4754 A line that begins with a space causes a break and the space is output
4755 at the beginning of the next line.  Note that this space isn't adjusted,
4756 even in fill mode.
4758 The end of file also causes a break -- otherwise the last line of the
4759 document may vanish!
4761 Certain requests also cause breaks, implicitly or explicitly.  This is
4762 discussed in @ref{Manipulating Filling and Adjusting}.
4764 @c ---------------------------------------------------------------------
4766 @node Input Conventions, Input Encodings, Implicit Line Breaks, Text
4767 @subsection Input Conventions
4768 @cindex input conventions
4769 @cindex conventions for input
4771 Since @code{gtroff} does filling automatically, it is traditional in
4772 @code{groff} not to try and type things in as nicely formatted
4773 paragraphs.  These are some conventions commonly used when typing
4774 @code{gtroff} text:
4776 @itemize @bullet
4777 @item
4778 Break lines after punctuation, particularly at the end of a sentence and
4779 in other logical places.  Keep separate phrases on lines by themselves,
4780 as entire phrases are often added or deleted when editing.
4782 @item
4783 Try to keep lines less than 40-60@tie{}characters, to allow space for
4784 inserting more text.
4786 @item
4787 Do not try to do any formatting in a @acronym{WYSIWYG} manner (i.e.,
4788 don't try using spaces to get proper indentation).
4789 @end itemize
4791 @c ---------------------------------------------------------------------
4793 @node Input Encodings,  , Input Conventions, Text
4794 @subsection Input Encodings
4796 Currently, the following input encodings are available.
4798 @table @asis
4799 @item cp1047
4800 @cindex encoding, input, @acronym{EBCDIC}
4801 @cindex @acronym{EBCDIC}, input encoding
4802 @cindex input encoding, @acronym{EBCDIC}
4803 @cindex encoding, input, cp1047
4804 @cindex cp1047, input encoding
4805 @cindex input encoding, cp1047
4806 @cindex IBM cp1047 input encoding
4807 @pindex cp1047.tmac
4808 This input encoding works only on @acronym{EBCDIC} platforms (and vice
4809 versa, the other input encodings don't work with @acronym{EBCDIC}); the
4810 file @file{cp1047.tmac} is by default loaded at start-up.
4812 @item latin-1
4813 @cindex encoding, input, @w{latin-1} (ISO @w{8859-1})
4814 @cindex @w{latin-1} (ISO @w{8859-1}), input encoding
4815 @cindex ISO @w{8859-1} (@w{latin-1}), input encoding
4816 @cindex input encoding, @w{latin-1} (ISO @w{8859-1})
4817 @pindex latin1.tmac
4818 This is the default input encoding on non-@acronym{EBCDIC} platforms;
4819 the file @file{latin1.tmac} is loaded at start-up.
4821 @item latin-2
4822 @cindex encoding, input, @w{latin-2} (ISO @w{8859-2})
4823 @cindex @w{latin-2} (ISO @w{8859-2}), input encoding
4824 @cindex ISO @w{8859-2} (@w{latin-2}), input encoding
4825 @cindex input encoding, @w{latin-2} (ISO @w{8859-2})
4826 @pindex latin2.tmac
4827 To use this encoding, either say @w{@samp{.mso latin2.tmac}} at the very
4828 beginning of your document or use @samp{-mlatin2} as a command line
4829 argument for @code{groff}.
4831 @item latin-5
4832 @cindex encoding, input, @w{latin-5} (ISO @w{8859-9})
4833 @cindex @w{latin-2} (ISO @w{8859-9}), input encoding
4834 @cindex ISO @w{8859-9} (@w{latin-2}), input encoding
4835 @cindex input encoding, @w{latin-2} (ISO @w{8859-9})
4836 @pindex latin2.tmac
4837 For Turkish.  Either say @w{@samp{.mso latin9.tmac}} at the very
4838 beginning of your document or use @samp{-mlatin9} as a command line
4839 argument for @code{groff}.
4841 @item latin-9 (latin-0)
4842 @cindex encoding, input, @w{latin-9} (@w{latin-0}, ISO @w{8859-15})
4843 @cindex @w{latin-9} (@w{latin-0}, ISO @w{8859-15}), input encoding
4844 @cindex ISO @w{8859-15} (@w{latin-9}, @w{latin-0}), input encoding
4845 @cindex input encoding, @w{latin-9} (@w{latin-9}, ISO @w{8859-15})
4846 @pindex latin9.tmac
4847 This encoding is intended (at least in Europe) to replace @w{latin-1}
4848 encoding.  The main difference to @w{latin-1} is that @w{latin-9}
4849 contains the Euro character.  To use this encoding, either say
4850 @w{@samp{.mso latin9.tmac}} at the very beginning of your document or
4851 use @samp{-mlatin9} as a command line argument for @code{groff}.
4852 @end table
4854 Note that it can happen that some input encoding characters are not
4855 available for a particular output device.  For example, saying
4857 @Example
4858 groff -Tlatin1 -mlatin9 ...
4859 @endExample
4861 @noindent
4862 fails if you use the Euro character in the input.  Usually, this
4863 limitation is present only for devices which have a limited set of
4864 output glyphs (e.g.@: @option{-Tascii} and @option{-Tlatin1}); for other
4865 devices it is usually sufficient to install proper fonts which contain
4866 the necessary glyphs.
4868 @pindex freeeuro.pfa
4869 @pindex ec.tmac
4870 Due to the importance of the Euro glyph in Europe, the groff package now
4871 comes with a @sc{PostScript} font called @file{freeeuro.pfa} which
4872 provides various glyph shapes for the Euro.  In other words,
4873 @w{latin-9} encoding is supported for the @option{-Tps} device out of
4874 the box (@w{latin-2} isn't).
4876 By its very nature, @option{-Tutf8} supports all input encodings;
4877 @option{-Tdvi} has support for both @w{latin-2} and @w{latin-9} if the
4878 command line @option{-mec} is used also to load the file @file{ec.tmac}
4879 (which flips to the EC fonts).
4882 @c =====================================================================
4884 @node Measurements, Expressions, Text, gtroff Reference
4885 @section Measurements
4886 @cindex measurements
4887 @cindex scaling indicator
4888 @cindex indicator, scaling
4890 @cindex units of measurement
4891 @cindex basic unit (@code{u})
4892 @cindex machine unit (@code{u})
4893 @cindex measurement unit
4894 @cindex @code{u} unit
4895 @cindex unit, @code{u}
4896 @code{gtroff} (like many other programs) requires numeric parameters to
4897 specify various measurements.  Most numeric parameters@footnote{those
4898 that specify vertical or horizontal motion or a type size} may have a
4899 @dfn{measurement unit} attached.  These units are specified as a single
4900 character which immediately follows the number or expression.  Each of
4901 these units are understood, by @code{gtroff}, to be a multiple of its
4902 @dfn{basic unit}.  So, whenever a different measurement unit is
4903 specified @code{gtroff} converts this into its @dfn{basic units}.  This
4904 basic unit, represented by a @samp{u}, is a device dependent measurement
4905 which is quite small, ranging from 1/75@dmn{th} to 1/72000@dmn{th} of an
4906 inch.  The values may be given as fractional numbers; however,
4907 fractional basic units are always rounded to integers.
4909 Some of the measurement units are completely independent of any of the
4910 current settings (e.g.@: type size) of @code{gtroff}.
4912 @table @code
4913 @item i
4914 @cindex inch unit (@code{i})
4915 @cindex @code{i} unit
4916 @cindex unit, @code{i}
4917 Inches.  An antiquated measurement unit still in use in certain
4918 backwards countries with incredibly low-cost computer equipment.  One
4919 inch is equal to@tie{}2.54@dmn{cm}.
4921 @item c
4922 @cindex centimeter unit (@code{c})
4923 @cindex @code{c} unit
4924 @cindex unit, @code{c}
4925 Centimeters.  One centimeter is equal to@tie{}0.3937@dmn{in}.
4927 @item p
4928 @cindex point unit (@code{p})
4929 @cindex @code{p} unit
4930 @cindex unit, @code{p}
4931 Points.  This is a typesetter's measurement used for measure type size.
4932 It is 72@tie{}points to an inch.
4934 @item P
4935 @cindex pica unit (@code{P})
4936 @cindex @code{P} unit
4937 @cindex unit, @code{P}
4938 Pica.  Another typesetting measurement.  6@tie{}Picas to an inch (and
4939 12@tie{}points to a pica).
4941 @item s
4942 @itemx z
4943 @cindex @code{s} unit
4944 @cindex unit, @code{s}
4945 @cindex @code{z} unit
4946 @cindex unit, @code{z}
4947 @xref{Fractional Type Sizes}, for a discussion of these units.
4949 @item f
4950 @cindex @code{f} unit
4951 @cindex unit, @code{f}
4952 Fractions.  Value is 65536.
4953 @xref{Colors}, for usage.
4954 @end table
4956 The other measurements understood by @code{gtroff} depend on settings
4957 currently in effect in @code{gtroff}.  These are very useful for
4958 specifying measurements which should look proper with any size of text.
4960 @table @code
4961 @item m
4962 @cindex em unit (@code{m})
4963 @cindex @code{m} unit
4964 @cindex unit, @code{m}
4965 Ems.  This unit is equal to the current font size in points.  So called
4966 because it is @emph{approximately} the width of the letter@tie{}@samp{m}
4967 in the current font.
4969 @item n
4970 @cindex en unit (@code{n})
4971 @cindex @code{n} unit
4972 @cindex unit, @code{n}
4973 Ens.  In @code{groff}, this is half of an em.
4975 @item v
4976 @cindex vertical space unit (@code{v})
4977 @cindex space, vertical, unit (@code{v})
4978 @cindex @code{v} unit
4979 @cindex unit, @code{v}
4980 Vertical space.  This is equivalent to the current line spacing.
4981 @xref{Sizes}, for more information about this.
4983 @item M
4984 @cindex @code{M} unit
4985 @cindex unit, @code{M}
4986 100ths of an em.
4987 @end table
4989 @menu
4990 * Default Units::
4991 @end menu
4993 @c ---------------------------------------------------------------------
4995 @node Default Units,  , Measurements, Measurements
4996 @subsection Default Units
4997 @cindex default units
4998 @cindex units, default
5000 Many requests take a default unit.  While this can be helpful at times,
5001 it can cause strange errors in some expressions.  For example, the line
5002 length request expects em units.  Here are several attempts to get a
5003 line length of 3.5@tie{}inches and their results:
5005 @Example
5006 3.5i      @result{}   3.5i
5007 7/2       @result{}   0i
5008 7/2i      @result{}   0i
5009 (7 / 2)u  @result{}   0i
5010 7i/2      @result{}   0.1i
5011 7i/2u     @result{}   3.5i
5012 @endExample
5014 @noindent
5015 Everything is converted to basic units first.  In the above example it
5016 is assumed that 1@dmn{i} equals@tie{}240@dmn{u}, and 1@dmn{m}
5017 equals@tie{}10@dmn{p} (thus 1@dmn{m} equals@tie{}33@dmn{u}).  The value
5018 7@dmn{i}/2 is first handled as 7@dmn{i}/2@dmn{m}, then converted to
5019 1680@dmn{u}/66@dmn{u} which is 25@dmn{u}, and this is approximately
5020 0.1@dmn{i}.  As can be seen, a scaling indicator after a closing
5021 parenthesis is simply ignored.
5023 @cindex measurements, specifying safely
5024 Thus, the safest way to specify measurements is to always attach a
5025 scaling indicator.  If you want to multiply or divide by a certain
5026 scalar value, use @samp{u} as the unit for that value.
5029 @c =====================================================================
5031 @node Expressions, Identifiers, Measurements, gtroff Reference
5032 @section Expressions
5033 @cindex expressions
5035 @code{gtroff} has most arithmetic operators common to other languages:
5037 @itemize @bullet
5038 @item
5039 @cindex arithmetic operators
5040 @cindex operators, arithmetic
5041 @opindex +
5042 @opindex -
5043 @opindex /
5044 @opindex *
5045 @opindex %
5046 Arithmetic: @samp{+} (addition), @samp{-} (subtraction), @samp{/}
5047 (division), @samp{*} (multiplication), @samp{%} (modulo).
5049 @code{gtroff} only provides integer arithmetic.  The internal type used
5050 for computing results is @samp{int}, which is usually a 32@dmn{bit}
5051 signed integer.
5053 @item
5054 @cindex comparison operators
5055 @cindex operators, comparison
5056 @opindex <
5057 @opindex >
5058 @opindex >=
5059 @opindex <=
5060 @opindex =
5061 @opindex ==
5062 Comparison: @samp{<} (less than), @samp{>} (greater than), @samp{<=}
5063 (less than or equal), @samp{>=} (greater than or equal), @samp{=}
5064 (equal), @samp{==} (the same as @samp{=}).
5066 @item
5067 @cindex logical operators
5068 @cindex operators, logical
5069 @opindex &
5070 @ifnotinfo
5071 @opindex :
5072 @end ifnotinfo
5073 @ifinfo
5074 @opindex @r{<colon>}
5075 @end ifinfo
5076 Logical: @samp{&} (logical and), @samp{:} (logical or).
5078 @item
5079 @cindex unary operators
5080 @cindex operators, unary
5081 @opindex -
5082 @opindex +
5083 @opindex !
5084 @cindex @code{if} request, and the @samp{!} operator
5085 @cindex @code{while} request, and the @samp{!} operator
5086 Unary operators: @samp{-} (negating, i.e.@: changing the sign), @samp{+}
5087 (just for completeness; does nothing in expressions), @samp{!} (logical
5088 not; this works only within @code{if} and @code{while}
5089 requests).@footnote{Note that, for example, @samp{!(-1)} evaluates to
5090 `true' because @code{gtroff} treats both negative numbers and zero as
5091 `false'.}  See below for the use of unary operators in motion requests.
5093 @item
5094 @cindex extremum operators (@code{>?}, @code{<?})
5095 @cindex operators, extremum (@code{>?}, @code{<?})
5096 @opindex >?
5097 @opindex <?
5098 Extrema: @samp{>?} (maximum), @samp{<?} (minimum).
5100 Example:
5102 @Example
5103 .nr x 5
5104 .nr y 3
5105 .nr z (\n[x] >? \n[y])
5106 @endExample
5108 @noindent
5109 The register@tie{}@code{z} now contains@tie{}5.
5111 @item
5112 @cindex scaling operator
5113 @cindex operator, scaling
5114 Scaling: @code{(@var{c};@var{e})}.  Evaluate@tie{}@var{e}
5115 using@tie{}@var{c} as the default scaling indicator.  If @var{c} is
5116 missing, ignore scaling indicators in the evaluation of@tie{}@var{e}.
5117 @end itemize
5119 @cindex parentheses
5120 @cindex order of evaluation in expressions
5121 @cindex expression, order of evaluation
5122 @opindex (
5123 @opindex )
5124 Parentheses may be used as in any other language.  However, in
5125 @code{gtroff} they are necessary to ensure order of evaluation.
5126 @code{gtroff} has no operator precedence; expressions are evaluated left
5127 to right.  This means that @code{gtroff} evaluates @samp{3+5*4} as if it
5128 were parenthesized like @samp{(3+5)*4}, not as @samp{3+(5*4)}, as might
5129 be expected.
5131 @cindex @code{+}, and page motion
5132 @cindex @code{-}, and page motion
5133 @cindex motion operators
5134 @cindex operators, motion
5135 For many requests which cause a motion on the page, the unary operators
5136 @samp{+} and @samp{-} work differently if leading an expression.  They
5137 then indicate a motion relative to the current position (down or up,
5138 respectively).
5140 @cindex @code{|}, and page motion
5141 @cindex absolute position operator (@code{|})
5142 @cindex position, absolute, operator (@code{|})
5143 Similarly, a leading @samp{|} operator indicates an absolute position.
5144 For vertical movements, it specifies the distance from the top of the
5145 page; for horizontal movements, it gives the distance from the beginning
5146 of the @emph{input} line.
5148 @cindex @code{bp} request, using @code{+} and@tie{}@code{-}
5149 @cindex @code{in} request, using @code{+} and@tie{}@code{-}
5150 @cindex @code{ll} request, using @code{+} and@tie{}@code{-}
5151 @cindex @code{lt} request, using @code{+} and@tie{}@code{-}
5152 @cindex @code{nm} request, using @code{+} and@tie{}@code{-}
5153 @cindex @code{nr} request, using @code{+} and@tie{}@code{-}
5154 @cindex @code{pl} request, using @code{+} and@tie{}@code{-}
5155 @cindex @code{pn} request, using @code{+} and@tie{}@code{-}
5156 @cindex @code{po} request, using @code{+} and@tie{}@code{-}
5157 @cindex @code{ps} request, using @code{+} and@tie{}@code{-}
5158 @cindex @code{pvs} request, using @code{+} and@tie{}@code{-}
5159 @cindex @code{rt} request, using @code{+} and@tie{}@code{-}
5160 @cindex @code{ti} request, using @code{+} and@tie{}@code{-}
5161 @cindex @code{\H}, using @code{+} and@tie{}@code{-}
5162 @cindex @code{\R}, using @code{+} and@tie{}@code{-}
5163 @cindex @code{\s}, using @code{+} and@tie{}@code{-}
5164 @samp{+} and @samp{-} are also treated differently by the following
5165 requests and escapes: @code{bp}, @code{in}, @code{ll}, @code{lt},
5166 @code{nm}, @code{nr}, @code{pl}, @code{pn}, @code{po}, @code{ps},
5167 @code{pvs}, @code{rt}, @code{ti}, @code{\H}, @code{\R}, and @code{\s}.
5168 Here, leading plus and minus signs indicate increments and decrements.
5170 @xref{Setting Registers}, for some examples.
5172 @Defesc {\\B, ', anything, '}
5173 @cindex numeric expression, valid
5174 @cindex valid numeric expression
5175 Return@tie{}1 if @var{anything} is a valid numeric expression; or@tie{}0
5176 if @var{anything} is empty or not a valid numeric expression.
5177 @endDefesc
5179 @cindex space characters, in expressions
5180 @cindex expressions, and space characters
5181 Due to the way arguments are parsed, spaces are not allowed in
5182 expressions, unless the entire expression is surrounded by parentheses.
5184 @xref{Request and Macro Arguments}, and @ref{Conditionals and Loops}.
5187 @c =====================================================================
5189 @node Identifiers, Embedded Commands, Expressions, gtroff Reference
5190 @section Identifiers
5191 @cindex identifiers
5193 Like any other language, @code{gtroff} has rules for properly formed
5194 @dfn{identifiers}.  In @code{gtroff}, an identifier can be made up of
5195 almost any printable character, with the exception of the following
5196 characters:
5198 @itemize @bullet
5199 @item
5200 @cindex whitespace characters
5201 @cindex newline character
5202 @cindex character, whitespace
5203 Whitespace characters (spaces, tabs, and newlines).
5205 @item
5206 @cindex character, backspace
5207 @cindex backspace character
5208 @cindex @acronym{EBCDIC} encoding of backspace
5209 Backspace (@acronym{ASCII}@tie{}@code{0x08} or
5210 @acronym{EBCDIC}@tie{}@code{0x16}) and character code @code{0x01}.
5212 @item
5213 @cindex invalid input characters
5214 @cindex input characters, invalid
5215 @cindex characters, invalid input
5216 @cindex Unicode
5217 The following input characters are invalid and are ignored if
5218 @code{groff} runs on a machine based on @acronym{ASCII}, causing a
5219 warning message of type @samp{input} (see @ref{Debugging}, for more
5220 details): @code{0x00}, @code{0x0B}, @code{0x0D}-@code{0x1F},
5221 @code{0x80}-@code{0x9F}.
5223 And here are the invalid input characters if @code{groff} runs on an
5224 @acronym{EBCDIC} host: @code{0x00}, @code{0x08}, @code{0x09},
5225 @code{0x0B}, @code{0x0D}-@code{0x14}, @code{0x17}-@code{0x1F},
5226 @code{0x30}-@code{0x3F}.
5228 Currently, some of these reserved codepoints are used internally, thus
5229 making it non-trivial to extend @code{gtroff} to cover Unicode or other
5230 character sets and encodings which use characters of these ranges.
5232 Note that invalid characters are removed before parsing; an identifier
5233 @code{foo}, followed by an invalid character, followed by @code{bar} is
5234 treated as @code{foobar}.
5235 @end itemize
5237 For example, any of the following is valid.
5239 @Example
5243 end-list
5245 @endExample
5247 @cindex @code{]}, as part of an identifier
5248 @noindent
5249 Note that identifiers longer than two characters with a closing bracket
5250 (@samp{]}) in its name can't be accessed with escape sequences which
5251 expect an identifier as a parameter.  For example, @samp{\[foo]]}
5252 accesses the glyph @samp{foo}, followed by @samp{]}, whereas
5253 @samp{\C'foo]'} really asks for glyph @samp{foo]}.
5255 @cindex @code{refer}, and macro names starting with @code{[} or @code{]}
5256 @cindex @code{[}, macro names starting with, and @code{refer}
5257 @cindex @code{]}, macro names starting with, and @code{refer}
5258 @cindex macro names, starting with @code{[} or @code{]}, and @code{refer}
5259 To avoid problems with the @code{refer} preprocessor, macro names should
5260 not start with @samp{[} or @samp{]}.  Due to backwards compatibility,
5261 everything after @samp{.[} and @samp{.]} is handled as a special
5262 argument to @code{refer}.  For example, @samp{.[foo} makes @code{refer}
5263 to start a reference, using @samp{foo} as a parameter.
5265 @Defesc {\\A, ', ident, '}
5266 Test whether an identifier @var{ident} is valid in @code{gtroff}.  It
5267 expands to the character@tie{}1 or@tie{}0 according to whether its
5268 argument (usually delimited by quotes) is or is not acceptable as the
5269 name of a string, macro, diversion, number register, environment, or
5270 font.  It returns@tie{}0 if no argument is given.  This is useful for
5271 looking up user input in some sort of associative table.
5273 @Example
5274 \A'end-list'
5275     @result{} 1
5276 @endExample
5277 @endDefesc
5279 @xref{Escapes}, for details on parameter delimiting characters.
5281 Identifiers in @code{gtroff} can be any length, but, in some contexts,
5282 @code{gtroff} needs to be told where identifiers end and text begins
5283 (and in different ways depending on their length):
5285 @itemize @bullet
5286 @item
5287 Single character.
5289 @cindex @code{(}, starting a two-character identifier
5290 @item
5291 Two characters.  Must be prefixed with @samp{(} in some situations.
5293 @cindex @code{[}, starting an identifier
5294 @cindex @code{]}, ending an identifier
5295 @item
5296 Arbitrary length (@code{gtroff} only).  Must be bracketed with @samp{[}
5297 and@tie{}@samp{]} in some situations.  Any length identifier can be put
5298 in brackets.
5299 @end itemize
5301 @cindex undefined identifiers
5302 @cindex identifiers, undefined
5303 Unlike many other programming languages, undefined identifiers are
5304 silently ignored or expanded to nothing.  When @code{gtroff} finds an
5305 undefined identifier, it emits a warning, doing the following:
5307 @itemize @bullet
5308 @item
5309 If the identifier is a string, macro, or diversion, @code{gtroff}
5310 defines it as empty.
5312 @item
5313 If the identifier is a number register, @code{gtroff} defines it with a
5314 value of@tie{}0.
5315 @end itemize
5317 @xref{Warnings}., @ref{Interpolating Registers}, and @ref{Strings}.
5319 Note that macros, strings, and diversions share the same name space.
5321 @Example
5322 .de xxx
5323 .  nop foo
5326 .di xxx
5331 .xxx
5332     @result{} bar
5333 @endExample
5335 @noindent
5336 As can be seen in the previous example, @code{gtroff} reuses the
5337 identifier @samp{xxx}, changing it from a macro to a diversion.  No
5338 warning is emitted!  The contents of the first macro definition is lost.
5340 @xref{Interpolating Registers}, and @ref{Strings}.
5343 @c =====================================================================
5345 @node Embedded Commands, Registers, Identifiers, gtroff Reference
5346 @section Embedded Commands
5347 @cindex embedded commands
5348 @cindex commands, embedded
5350 Most documents need more functionality beyond filling, adjusting and
5351 implicit line breaking.  In order to gain further functionality,
5352 @code{gtroff} allows commands to be embedded into the text, in two ways.
5354 The first is a @dfn{request} which takes up an entire line, and does
5355 some large-scale operation (e.g.@: break lines, start new pages).
5357 The other is an @dfn{escape} which can be usually embedded anywhere in
5358 the text; most requests can accept it even as an argument.  Escapes
5359 generally do more minor operations like sub- and superscripts, print a
5360 symbol, etc.
5362 @menu
5363 * Requests::
5364 * Macros::
5365 * Escapes::
5366 @end menu
5368 @c ---------------------------------------------------------------------
5370 @node Requests, Macros, Embedded Commands, Embedded Commands
5371 @subsection Requests
5372 @cindex requests
5374 @cindex control character (@code{.})
5375 @cindex character, control (@code{.})
5376 @cindex no-break control character (@code{'})
5377 @cindex character, no-break control (@code{'})
5378 @cindex control character, no-break (@code{'})
5379 A request line begins with a control character, which is either a single
5380 quote (@samp{'}, the @dfn{no-break control character}) or a period
5381 (@samp{.}, the normal @dfn{control character}).  These can be changed;
5382 see @ref{Character Translations}, for details.  After this there may be
5383 optional tabs or spaces followed by an identifier which is the name of
5384 the request.  This may be followed by any number of space-separated
5385 arguments (@emph{no} tabs here).
5387 @cindex structuring source code of documents or macro packages
5388 @cindex documents, structuring the source code
5389 @cindex macro packages, structuring the source code
5390 Since a control character followed by whitespace only is ignored, it is
5391 common practice to use this feature for structuring the source code of
5392 documents or macro packages.
5394 @Example
5395 .de foo
5396 .  tm This is foo.
5400 .de bar
5401 .  tm This is bar.
5403 @endExample
5405 @cindex blank line
5406 @cindex blank line macro (@code{blm})
5407 Another possibility is to use the blank line macro request @code{blm} by
5408 assigning an empty macro to it.
5410 @Example
5411 .de do-nothing
5413 .blm do-nothing  \" activate blank line macro
5415 .de foo
5416 .  tm This is foo.
5420 .de bar
5421 .  tm This is bar.
5424 .blm             \" deactivate blank line macro
5425 @endExample
5427 @xref{Blank Line Traps}.
5429 @cindex zero width space character (@code{\&})
5430 @cindex character, zero width space (@code{\&})
5431 @cindex space character, zero width (@code{\&})
5432 @cindex @code{\&}, escaping control characters
5433 To begin a line with a control character without it being interpreted,
5434 precede it with @code{\&}.  This represents a zero width space, which
5435 means it does not affect the output.
5437 In most cases the period is used as a control character.  Several
5438 requests cause a break implicitly; using the single quote control
5439 character prevents this.
5441 @Defreg {.br}
5442 A read-only number register which is set to@tie{}1 if a macro is called
5443 with the normal control character (as defined with the @code{cc}
5444 request), and set to@tie{}0 otherwise.
5446 @cindex modifying requests
5447 @cindex requests, modifying
5448 This allows to reliably modify requests.
5450 @Example
5451 .als bp*orig bp
5452 .de bp
5453 .  tm before bp
5454 .  ie \\n[.br] .bp*orig
5455 .  el 'bp*orig
5456 .  tm after bp
5458 @endExample
5460 Using this register outside of a macro makes no sense (it always returns
5461 zero in such cases).
5463 If a macro is called as a string (this is, using @code{\*}), the value
5464 of the @code{.br} register is inherited from the calling macro.
5465 @endDefreg
5467 @menu
5468 * Request and Macro Arguments::
5469 @end menu
5471 @node Request and Macro Arguments,  , Requests, Requests
5472 @subsubsection Request and Macro Arguments
5473 @cindex request arguments
5474 @cindex macro arguments
5475 @cindex arguments to requests and macros
5477 @cindex tabs, and macro arguments
5478 @cindex macro arguments, and tabs
5479 @cindex arguments to macros, and tabs
5480 Arguments to requests and macros are processed much like the shell:
5481 The line is split into arguments according to
5482 spaces.@footnote{Plan@tie{}9's @code{troff} implementation also allows
5483 tabs for argument separation -- @code{gtroff} intentionally doesn't
5484 support this.}
5486 @cindex spaces, in a macro argument
5487 An argument to a macro which is intended to contain spaces can either be
5488 enclosed in double quotes, or have the spaces @dfn{escaped} with
5489 backslashes.  This is @emph{not} true for requests.
5491 Here are a few examples for a hypothetical macro @code{uh}:
5493 @Example
5494 .uh The Mouse Problem
5495 .uh "The Mouse Problem"
5496 .uh The\ Mouse\ Problem
5497 @endExample
5499 @cindex @code{\~}, difference to @code{\@key{SP}}
5500 @cindex @code{\@key{SP}}, difference to @code{\~}
5501 @noindent
5502 The first line is the @code{uh} macro being called with 3 arguments,
5503 @samp{The}, @samp{Mouse}, and @samp{Problem}.  The latter two have the
5504 same effect of calling the @code{uh} macro with one argument, @samp{The
5505 Mouse Problem}.@footnote{The last solution, i.e., using escaped spaces,
5506 is ``classical'' in the sense that it can be found in most @code{troff}
5507 documents.  Nevertheless, it is not optimal in all situations, since
5508 @w{@samp{\ }} inserts a fixed-width, non-breaking space character which
5509 can't stretch.  @code{gtroff} provides a different command @code{\~} to
5510 insert a stretchable, non-breaking space.}
5512 @cindex @code{"}, in a macro argument
5513 @cindex double quote, in a macro argument
5514 A double quote which isn't preceded by a space doesn't start a macro
5515 argument.  If not closing a string, it is printed literally.
5517 For example,
5519 @Example
5520 .xxx a" "b c" "de"fg"
5521 @endExample
5523 @noindent
5524 has the arguments @samp{a"}, @w{@samp{b c}}, @samp{de}, and @samp{fg"}.
5525 Don't rely on this obscure behaviour!
5527 There are two possibilities to get a double quote reliably.
5529 @itemize @bullet
5530 @item
5531 Enclose the whole argument with double quotes and use two consecutive
5532 double quotes to represent a single one.  This traditional solution has
5533 the disadvantage that double quotes don't survive argument expansion
5534 again if called in compatibility mode (using the @option{-C} option of
5535 @code{groff}):
5537 @Example
5538 .de xx
5539 .  tm xx: `\\$1' `\\$2' `\\$3'
5541 .  yy "\\$1" "\\$2" "\\$3"
5543 .de yy
5544 .  tm yy: `\\$1' `\\$2' `\\$3'
5546 .xx A "test with ""quotes""" .
5547     @result{} xx: `A' `test with "quotes"' `.'
5548     @result{} yy: `A' `test with ' `quotes""'
5549 @endExample
5551 @noindent
5552 If not in compatibility mode, you get the expected result
5554 @Example
5555 xx: `A' `test with "quotes"' `.'
5556 yy: `A' `test with "quotes"' `.'
5557 @endExample
5559 @noindent
5560 since @code{gtroff} preserves the input level.
5562 @item
5563 Use the double quote glyph @code{\(dq}.  This works with and without
5564 compatibility mode enabled since @code{gtroff} doesn't convert
5565 @code{\(dq} back to a double quote input character.
5567 Note that this method won't work with @acronym{UNIX} @code{troff} in
5568 general since the glyph `dq' isn't defined normally.
5569 @end itemize
5571 @cindex @code{ds} request, and double quotes
5572 Double quotes in the @code{ds} request are handled differently.
5573 @xref{Strings}, for more details.
5575 @c ---------------------------------------------------------------------
5577 @node Macros, Escapes, Requests, Embedded Commands
5578 @subsection Macros
5579 @cindex macros
5581 @code{gtroff} has a @dfn{macro} facility for defining a series of lines
5582 which can be invoked by name.  They are called in the same manner as
5583 requests -- arguments also may be passed basically in the same manner.
5585 @xref{Writing Macros}, and @ref{Request and Macro Arguments}.
5587 @c ---------------------------------------------------------------------
5589 @node Escapes,  , Macros, Embedded Commands
5590 @subsection Escapes
5591 @cindex escapes
5593 Escapes may occur anywhere in the input to @code{gtroff}.  They usually
5594 begin with a backslash and are followed by a single character which
5595 indicates the function to be performed.  The escape character can be
5596 changed; see @ref{Character Translations}.
5598 Escape sequences which require an identifier as a parameter accept three
5599 possible syntax forms.
5601 @itemize @bullet
5602 @item
5603 The next single character is the identifier.
5605 @cindex @code{(}, starting a two-character identifier
5606 @item
5607 If this single character is an opening parenthesis, take the following
5608 two characters as the identifier.  Note that there is no closing
5609 parenthesis after the identifier.
5611 @cindex @code{[}, starting an identifier
5612 @cindex @code{]}, ending an identifier
5613 @item
5614 If this single character is an opening bracket, take all characters
5615 until a closing bracket as the identifier.
5616 @end itemize
5618 @noindent
5619 Examples:
5621 @Example
5623 \n(XX
5624 \*[TeX]
5625 @endExample
5627 @cindex @code{'}, delimiting arguments
5628 @cindex argument delimiting characters
5629 @cindex characters, argument delimiting
5630 @cindex delimiting characters for arguments
5631 Other escapes may require several arguments and/or some special format.
5632 In such cases the argument is traditionally enclosed in single quotes
5633 (and quotes are always used in this manual for the definitions of escape
5634 sequences).  The enclosed text is then processed according to what that
5635 escape expects.  Example:
5637 @Example
5638 \l'1.5i\(bu'
5639 @endExample
5641 @cindex @code{\o}, possible quote characters
5642 @cindex @code{\b}, possible quote characters
5643 @cindex @code{\X}, possible quote characters
5644 Note that the quote character can be replaced with any other character
5645 which does not occur in the argument (even a newline or a space
5646 character) in the following escapes: @code{\o}, @code{\b}, and
5647 @code{\X}.  This makes e.g.
5649 @Example
5650 A caf
5655 in Paris
5656   @result{} A café in Paris
5657 @endExample
5659 @noindent
5660 possible, but it is better not to use this feature to avoid confusion.
5662 @cindex @code{\%}, used as delimiter
5663 @cindex @code{\@key{SP}}, used as delimiter
5664 @cindex @code{\|}, used as delimiter
5665 @cindex @code{\^}, used as delimiter
5666 @cindex @code{\@{}, used as delimiter
5667 @cindex @code{\@}}, used as delimiter
5668 @cindex @code{\'}, used as delimiter
5669 @cindex @code{\`}, used as delimiter
5670 @cindex @code{\-}, used as delimiter
5671 @cindex @code{\_}, used as delimiter
5672 @cindex @code{\!}, used as delimiter
5673 @cindex @code{\?}, used as delimiter
5674 @cindex @code{\)}, used as delimiter
5675 @cindex @code{\/}, used as delimiter
5676 @cindex @code{\,}, used as delimiter
5677 @cindex @code{\&}, used as delimiter
5678 @ifnotinfo
5679 @cindex @code{\:}, used as delimiter
5680 @end ifnotinfo
5681 @ifinfo
5682 @cindex @code{\@r{<colon>}}, used as delimiter
5683 @end ifinfo
5684 @cindex @code{\~}, used as delimiter
5685 @cindex @code{\0}, used as delimiter
5686 @cindex @code{\a}, used as delimiter
5687 @cindex @code{\c}, used as delimiter
5688 @cindex @code{\d}, used as delimiter
5689 @cindex @code{\e}, used as delimiter
5690 @cindex @code{\E}, used as delimiter
5691 @cindex @code{\p}, used as delimiter
5692 @cindex @code{\r}, used as delimiter
5693 @cindex @code{\t}, used as delimiter
5694 @cindex @code{\u}, used as delimiter
5695 The following escapes sequences (which are handled similarly to
5696 characters since they don't take a parameter) are also allowed as
5697 delimiters: @code{\%}, @w{@samp{\ }}, @code{\|}, @code{\^}, @code{\@{},
5698 @code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
5699 @code{\?}, @code{\)}, @code{\/}, @code{\,}, @code{\&}, @code{\:},
5700 @code{\~}, @code{\0}, @code{\a}, @code{\c}, @code{\d}, @code{\e},
5701 @code{\E}, @code{\p}, @code{\r}, @code{\t}, and @code{\u}.  Again, don't
5702 use these if possible.
5704 @cindex @code{\A}, allowed delimiters
5705 @cindex @code{\B}, allowed delimiters
5706 @cindex @code{\Z}, allowed delimiters
5707 @cindex @code{\C}, allowed delimiters
5708 @cindex @code{\w}, allowed delimiters
5709 No newline characters as delimiters are allowed in the following
5710 escapes: @code{\A}, @code{\B}, @code{\Z}, @code{\C}, and @code{\w}.
5712 @cindex @code{\D}, allowed delimiters
5713 @cindex @code{\h}, allowed delimiters
5714 @cindex @code{\H}, allowed delimiters
5715 @cindex @code{\l}, allowed delimiters
5716 @cindex @code{\L}, allowed delimiters
5717 @cindex @code{\N}, allowed delimiters
5718 @cindex @code{\R}, allowed delimiters
5719 @cindex @code{\s}, allowed delimiters
5720 @cindex @code{\S}, allowed delimiters
5721 @cindex @code{\v}, allowed delimiters
5722 @cindex @code{\x}, allowed delimiters
5723 Finally, the escapes @code{\D}, @code{\h}, @code{\H}, @code{\l},
5724 @code{\L}, @code{\N}, @code{\R}, @code{\s}, @code{\S}, @code{\v}, and
5725 @code{\x} can't use the following characters as delimiters:
5727 @itemize @bullet
5728 @item
5729 @cindex numbers, and delimiters
5730 @cindex digits, and delimiters
5731 The digits @code{0}-@code{9}.
5733 @item
5734 @cindex operators, as delimiters
5735 @cindex @code{+}, as delimiter
5736 @cindex @code{-}, as delimiter
5737 @cindex @code{/}, as delimiter
5738 @cindex @code{*}, as delimiter
5739 @cindex @code{%}, as delimiter
5740 @cindex @code{<}, as delimiter
5741 @cindex @code{>}, as delimiter
5742 @cindex @code{=}, as delimiter
5743 @cindex @code{&}, as delimiter
5744 @ifnotinfo
5745 @cindex @code{:}, as delimiter
5746 @end ifnotinfo
5747 @ifinfo
5748 @cindex <colon>, as delimiter
5749 @end ifinfo
5750 @cindex @code{(}, as delimiter
5751 @cindex @code{)}, as delimiter
5752 @cindex @code{.}, as delimiter
5753 The (single-character) operators @samp{+-/*%<>=&:().}.
5755 @item
5756 @cindex space character
5757 @cindex character, space
5758 @cindex tab character
5759 @cindex character, tab
5760 @cindex newline character
5761 @cindex character, newline
5762 The space, tab, and newline characters.
5764 @item
5765 @cindex @code{\%}, used as delimiter
5766 @ifnotinfo
5767 @cindex @code{\:}, used as delimiter
5768 @end ifnotinfo
5769 @ifinfo
5770 @cindex @code{\@r{<colon>}}, used as delimiter
5771 @end ifinfo
5772 @cindex @code{\@{}, used as delimiter
5773 @cindex @code{\@}}, used as delimiter
5774 @cindex @code{\'}, used as delimiter
5775 @cindex @code{\`}, used as delimiter
5776 @cindex @code{\-}, used as delimiter
5777 @cindex @code{\_}, used as delimiter
5778 @cindex @code{\!}, used as delimiter
5779 @cindex @code{\/}, used as delimiter
5780 @cindex @code{\c}, used as delimiter
5781 @cindex @code{\e}, used as delimiter
5782 @cindex @code{\p}, used as delimiter
5783 All escape sequences except @code{\%}, @code{\:}, @code{\@{},
5784 @code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
5785 @code{\/}, @code{\c}, @code{\e}, and @code{\p}.
5786 @end itemize
5788 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
5789 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
5790 To have a backslash (actually, the current escape character) appear in
5791 the output several escapes are defined: @code{\\}, @code{\e} or
5792 @code{\E}.  These are very similar, and only differ with respect to
5793 being used in macros or diversions.  @xref{Character Translations}, for
5794 an exact description of those escapes.
5796 @xref{Implementation Differences}, @ref{Copy-in Mode}, and
5797 @ref{Diversions}, @ref{Identifiers}, for more information.
5799 @menu
5800 * Comments::
5801 @end menu
5803 @node Comments,  , Escapes, Escapes
5804 @subsubsection Comments
5805 @cindex comments
5807 Probably one of the most@footnote{Unfortunately, this is a lie.  But
5808 hopefully future @code{gtroff} hackers will believe it @code{:-)}}
5809 common forms of escapes is the comment.
5811 @Defesc {\\", , , }
5812 Start a comment.  Everything to the end of the input line is ignored.
5814 This may sound simple, but it can be tricky to keep the comments from
5815 interfering with the appearance of the final output.
5817 @cindex @code{ds}, @code{ds1} requests, and comments
5818 @cindex @code{as}, @code{as1} requests, and comments
5819 If the escape is to the right of some text or a request, that portion of
5820 the line is ignored, but the space leading up to it is noticed by
5821 @code{gtroff}.  This only affects the @code{ds} and @code{as} request
5822 and its variants.
5824 @cindex tabs, before comments
5825 @cindex comments, lining up with tabs
5826 One possibly irritating idiosyncracy is that tabs must not be used to
5827 line up comments.  Tabs are not treated as whitespace between the
5828 request and macro arguments.
5830 @cindex undefined request
5831 @cindex request, undefined
5832 A comment on a line by itself is treated as a blank line, because after
5833 eliminating the comment, that is all that remains:
5835 @Example
5836 Test
5837 \" comment
5838 Test
5839 @endExample
5841 @noindent
5842 produces
5844 @Example
5845 Test
5847 Test
5848 @endExample
5850 To avoid this, it is common to start the line with @code{.\"} which
5851 causes the line to be treated as an undefined request and thus ignored
5852 completely.
5854 @cindex @code{'}, as a comment
5855 Another commenting scheme seen sometimes is three consecutive single
5856 quotes (@code{'''}) at the beginning of a line.  This works, but
5857 @code{gtroff} gives a warning about an undefined macro (namely
5858 @code{''}), which is harmless, but irritating.
5859 @endDefesc
5861 @Defesc {\\#, , , }
5862 To avoid all this, @code{gtroff} has a new comment mechanism using the
5863 @code{\#} escape.  This escape works the same as @code{\"} except that
5864 the newline is also ignored:
5866 @Example
5867 Test
5868 \# comment
5869 Test
5870 @endExample
5872 @noindent
5873 produces
5875 @Example
5876 Test Test
5877 @endExample
5879 @noindent
5880 as expected.
5881 @endDefesc
5883 @Defreq {ig, [@Var{end}]}
5884 Ignore all input until @code{gtroff} encounters the macro named
5885 @code{.}@var{end} on a line by itself (or @code{..} if @var{end} is not
5886 specified).  This is useful for commenting out large blocks of text:
5888 @Example
5889 text text text...
5891 This is part of a large block
5892 of text that has been
5893 temporarily(?) commented out.
5895 We can restore it simply by removing
5896 the .ig request and the ".." at the
5897 end of the block.
5899 More text text text...
5900 @endExample
5902 @noindent
5903 produces
5905 @Example
5906 text text text@dots{}  More text text text@dots{}
5907 @endExample
5909 @noindent
5910 Note that the commented-out block of text does not cause a break.
5912 @cindex @code{ig} request, and copy-in mode
5913 @cindex copy-in mode, and @code{ig} request
5914 @cindex mode, copy-in, and @code{ig} request
5915 @cindex @code{ig} request, and auto-increment
5916 @cindex auto-increment, and @code{ig} request
5917 The input is read in copy-mode; auto-incremented registers @emph{are}
5918 affected (@pxref{Auto-increment}).
5919 @endDefreq
5922 @c =====================================================================
5924 @node Registers, Manipulating Filling and Adjusting, Embedded Commands, gtroff Reference
5925 @section Registers
5926 @cindex registers
5928 Numeric variables in @code{gtroff} are called @dfn{registers}.  There
5929 are a number of built-in registers, supplying anything from the date to
5930 details of formatting parameters.
5932 @xref{Identifiers}, for details on register identifiers.
5934 @menu
5935 * Setting Registers::
5936 * Interpolating Registers::
5937 * Auto-increment::
5938 * Assigning Formats::
5939 * Built-in Registers::
5940 @end menu
5942 @c ---------------------------------------------------------------------
5944 @node Setting Registers, Interpolating Registers, Registers, Registers
5945 @subsection Setting Registers
5946 @cindex setting registers (@code{nr}, @code{\R})
5947 @cindex registers, setting (@code{nr}, @code{\R})
5949 Define or set registers using the @code{nr} request or the @code{\R}
5950 escape.
5952 @DefreqList {nr, ident value}
5953 @DefescListEnd {\\R, ', ident value, '}
5954 Set number register @var{ident} to @var{value}.  If @var{ident} doesn't
5955 exist, @code{gtroff} creates it.
5957 The argument to @code{\R} usually has to be enclosed in quotes.
5958 @xref{Escapes}, for details on parameter delimiting characters.
5960 The @code{\R} escape doesn't produce an input token in @code{gtroff};
5961 in other words, it vanishes completely after @code{gtroff} has
5962 processed it.
5963 @endDefreq
5965 For example, the following two lines are equivalent:
5967 @Example
5968 .nr a (((17 + (3 * 4))) % 4)
5969 \R'a (((17 + (3 * 4))) % 4)'
5970     @result{} 1
5971 @endExample
5973 Both @code{nr} and @code{\R} have two additional special forms to
5974 increment or decrement a register.
5976 @DefreqList {nr, ident @t{+}@Var{value}}
5977 @DefreqItem {nr, ident @t{-}@Var{value}}
5978 @DefescItem {\\R, ', ident @t{+}value, '}
5979 @DefescListEnd {\\R, ', ident @t{-}value, '}
5980 Increment (decrement) register @var{ident} by @var{value}.
5982 @Example
5983 .nr a 1
5984 .nr a +1
5986     @result{} 2
5987 @endExample
5989 @cindex negating register values
5990 To assign the negated value of a register to another register, some care
5991 must be taken to get the desired result:
5993 @Example
5994 .nr a 7
5995 .nr b 3
5996 .nr a -\nb
5998     @result{} 4
5999 .nr a (-\nb)
6001     @result{} -3
6002 @endExample
6004 @noindent
6005 The surrounding parentheses prevent the interpretation of the minus sign
6006 as a decrementing operator.  An alternative is to start the assignment
6007 with a @samp{0}:
6009 @Example
6010 .nr a 7
6011 .nr b -3
6012 .nr a \nb
6014     @result{} 4
6015 .nr a 0\nb
6017     @result{} -3
6018 @endExample
6019 @endDefreq
6021 @Defreq {rr, ident}
6022 @cindex removing number register (@code{rr})
6023 @cindex number register, removing (@code{rr})
6024 @cindex register, removing (@code{rr})
6025 Remove number register @var{ident}.  If @var{ident} doesn't exist, the
6026 request is ignored.
6027 @endDefreq
6029 @Defreq {rnn, ident1 ident2}
6030 @cindex renaming number register (@code{rnn})
6031 @cindex number register, renaming (@code{rnn})
6032 @cindex register, renaming (@code{rnn})
6033 Rename number register @var{ident1} to @var{ident2}.  If either
6034 @var{ident1} or @var{ident2} doesn't exist, the request is ignored.
6035 @endDefreq
6037 @Defreq {aln, ident1 ident2}
6038 @cindex alias, number register, creating (@code{aln})
6039 @cindex creating alias, for number register (@code{aln})
6040 @cindex number register, creating alias (@code{aln})
6041 @cindex register, creating alias (@code{aln})
6042 Create an alias @var{ident1} for a number register @var{ident2}.  The
6043 new name and the old name are exactly equivalent.  If @var{ident1} is
6044 undefined, a warning of type @samp{reg} is generated, and the request is
6045 ignored.  @xref{Debugging}, for information about warnings.
6046 @endDefreq
6048 @c ---------------------------------------------------------------------
6050 @node Interpolating Registers, Auto-increment, Setting Registers, Registers
6051 @subsection Interpolating Registers
6052 @cindex interpolating registers (@code{\n})
6053 @cindex registers, interpolating (@code{\n})
6055 Numeric registers can be accessed via the @code{\n} escape.
6057 @DefescList {\\n, , i, }
6058 @DefescItem {\\n, @Lparen{}, id, }
6059 @DefescListEnd {\\n, @Lbrack{}, ident, @Rbrack{}}
6060 @cindex nested assignments
6061 @cindex assignments, nested
6062 @cindex indirect assignments
6063 @cindex assignments, indirect
6064 Interpolate number register with name @var{ident} (one-character
6065 name@tie{}@var{i}, two-character name @var{id}).  This means that the
6066 value of the register is expanded in-place while @code{gtroff} is
6067 parsing the input line.  Nested assignments (also called indirect
6068 assignments) are possible.
6070 @Example
6071 .nr a 5
6072 .nr as \na+\na
6073 \n(as
6074     @result{} 10
6075 @endExample
6077 @Example
6078 .nr a1 5
6079 .nr ab 6
6080 .ds str b
6081 .ds num 1
6082 \n[a\n[num]]
6083     @result{} 5
6084 \n[a\*[str]]
6085     @result{} 6
6086 @endExample
6087 @endDefesc
6089 @c ---------------------------------------------------------------------
6091 @node Auto-increment, Assigning Formats, Interpolating Registers, Registers
6092 @subsection Auto-increment
6093 @cindex auto-increment
6094 @cindex increment, automatic
6096 Number registers can also be auto-incremented and auto-decremented.  The
6097 increment or decrement value can be specified with a third argument to
6098 the @code{nr} request or @code{\R} escape.
6100 @Defreq {nr, ident value incr}
6101 @cindex @code{\R}, difference to @code{nr}
6102 Set number register @var{ident} to @var{value}; the increment for
6103 auto-incrementing is set to @var{incr}.  Note that the @code{\R} escape
6104 doesn't support this notation.
6105 @endDefreq
6107 To activate auto-incrementing, the escape @code{\n} has a special syntax
6108 form.
6110 @DefescList {\\n, +, i, }
6111 @DefescItem {\\n, -, i, }
6112 @DefescItem {\\n, @Lparen{}+, id, }
6113 @DefescItem {\\n, @Lparen{}-, id, }
6114 @DefescItem {\\n, +@Lparen{}, id, }
6115 @DefescItem {\\n, -@Lparen{}, id, }
6116 @DefescItem {\\n, @Lbrack{}+, ident, @Rbrack{}}
6117 @DefescItem {\\n, @Lbrack{}-, ident, @Rbrack{}}
6118 @DefescItem {\\n, +@Lbrack{}, ident, @Rbrack{}}
6119 @DefescListEnd {\\n, -@Lbrack{}, ident, @Rbrack{}}
6120 Before interpolating, increment or decrement @var{ident} (one-character
6121 name@tie{}@var{i}, two-character name @var{id}) by the auto-increment
6122 value as specified with the @code{nr} request (or the @code{\R} escape).
6123 If no auto-increment value has been specified, these syntax forms are
6124 identical to @code{\n}.
6125 @endDefesc
6127 For example,
6129 @Example
6130 .nr a 0 1
6131 .nr xx 0 5
6132 .nr foo 0 -2
6133 \n+a, \n+a, \n+a, \n+a, \n+a
6135 \n-(xx, \n-(xx, \n-(xx, \n-(xx, \n-(xx
6137 \n+[foo], \n+[foo], \n+[foo], \n+[foo], \n+[foo]
6138 @endExample
6140 @noindent
6141 produces
6143 @Example
6144 1, 2, 3, 4, 5
6145 -5, -10, -15, -20, -25
6146 -2, -4, -6, -8, -10
6147 @endExample
6149 @cindex increment value without changing the register
6150 @cindex value, incrementing without changing the register
6151 To change the increment value without changing the value of a register
6152 (@var{a} in the example), the following can be used:
6154 @Example
6155 .nr a \na 10
6156 @endExample
6158 @c ---------------------------------------------------------------------
6160 @node Assigning Formats, Built-in Registers, Auto-increment, Registers
6161 @subsection Assigning Formats
6162 @cindex assigning formats (@code{af})
6163 @cindex formats, assigning (@code{af})
6165 When a register is used, it is always textually replaced (or
6166 interpolated) with a representation of that number.  This output format
6167 can be changed to a variety of formats (numbers, Roman numerals, etc.).
6168 This is done using the @code{af} request.
6170 @Defreq {af, ident format}
6171 Change the output format of a number register.  The first argument
6172 @var{ident} is the name of the number register to be changed, and the
6173 second argument @var{format} is the output format.  The following output
6174 formats are available:
6176 @table @code
6177 @item 1
6178 Decimal arabic numbers.  This is the default format: 0, 1, 2,
6179 3,@tie{}@enddots{}
6181 @item 0@dots{}0
6182 Decimal numbers with as many digits as specified.  So, @samp{00} would
6183 result in printing numbers as 01, 02, 03,@tie{}@enddots{}
6185 In fact, any digit instead of zero does work; @code{gtroff} only counts
6186 how many digits are specified.  As a consequence, @code{af}'s default
6187 format @samp{1} could be specified as @samp{0} also (and exactly this is
6188 returned by the @code{\g} escape, see below).
6190 @item I
6191 @cindex Roman numerals
6192 @cindex numerals, Roman
6193 Upper-case Roman numerals: 0, I, II, III, IV,@tie{}@enddots{}
6195 @item i
6196 Lower-case Roman numerals: 0, i, ii, iii, iv,@tie{}@enddots{}
6198 @item A
6199 Upper-case letters: 0, A, B, C, @dots{},@tie{}Z, AA, AB,@tie{}@enddots{}
6201 @item a
6202 Lower-case letters: 0, a, b, c, @dots{},@tie{}z, aa, ab,@tie{}@enddots{}
6203 @end table
6205 Omitting the number register format causes a warning of type
6206 @samp{missing}.  @xref{Debugging}, for more details.  Specifying a
6207 nonexistent format causes an error.
6209 The following example produces @samp{10, X, j, 010}:
6211 @Example
6212 .nr a 10
6213 .af a 1           \" the default format
6214 \na,
6215 .af a I
6216 \na,
6217 .af a a
6218 \na,
6219 .af a 001
6221 @endExample
6223 @cindex Roman numerals, maximum and minimum
6224 @cindex maximum values of Roman numerals
6225 @cindex minimum values of Roman numerals
6226 The largest number representable for the @samp{i} and @samp{I} formats
6227 is 39999 (or @minus{}39999); @acronym{UNIX} @code{troff} uses @samp{z}
6228 and @samp{w} to represent 10000 and 5000 in Roman numerals, and so does
6229 @code{gtroff}.  Currently, the correct glyphs of Roman numeral five
6230 thousand and Roman numeral ten thousand (Unicode code points
6231 @code{U+2182} and @code{U+2181}, respectively) are not available.
6233 If @var{ident} doesn't exist, it is created.
6235 @cindex read-only register, changing format
6236 @cindex changing format, and read-only registers
6237 Changing the output format of a read-only register causes an error.  It
6238 is necessary to first copy the register's value to a writeable register,
6239 then apply the @code{af} request to this other register.
6240 @endDefreq
6242 @DefescList {\\g, , i, }
6243 @DefescItem {\\g, @Lparen{}, id, }
6244 @DefescListEnd {\\g, @Lbrack{}, ident, @Rbrack{}}
6245 @cindex format of register (@code{\g})
6246 @cindex register, format (@code{\g})
6247 Return the current format of the specified register @var{ident}
6248 (one-character name@tie{}@var{i}, two-character name @var{id}).  For
6249 example, @samp{\ga} after the previous example would produce the string
6250 @samp{000}.  If the register hasn't been defined yet, nothing is
6251 returned.
6252 @endDefesc
6254 @c ---------------------------------------------------------------------
6256 @node Built-in Registers,  , Assigning Formats, Registers
6257 @subsection Built-in Registers
6258 @cindex built-in registers
6259 @cindex registers, built-in
6261 The following lists some built-in registers which are not described
6262 elsewhere in this manual.  Any register which begins with a @samp{.} is
6263 read-only.  A complete listing of all built-in registers can be found in
6264 @ref{Register Index}.
6266 @table @code
6267 @item \n[.F]
6268 @cindex current input file name register (@code{.F})
6269 @cindex input file name, current, register (@code{.F})
6270 @vindex .F
6271 This string-valued register returns the current input file name.
6273 @item \n[.H]
6274 @cindex horizontal resolution register (@code{.H})
6275 @cindex resolution, horizontal, register (@code{.H})
6276 @vindex .H
6277 Horizontal resolution in basic units.
6279 @item \n[.U]
6280 @cindex safer mode
6281 @cindex mode, safer
6282 @cindex unsafe mode
6283 @cindex mode, unsafe
6284 If @code{gtroff} is called with the @option{-U} command line option to
6285 activate unsafe mode, the number register @code{.U} is set to@tie{}1,
6286 and to zero otherwise.  @xref{Groff Options}.
6288 @item \n[.V]
6289 @cindex vertical resolution register (@code{.V})
6290 @cindex resolution, vertical, register (@code{.V})
6291 @vindex .V
6292 Vertical resolution in basic units.
6294 @item \n[seconds]
6295 @cindex seconds, current time (@code{seconds})
6296 @cindex time, current, seconds (@code{seconds})
6297 @cindex current time, seconds (@code{seconds})
6298 @vindex seconds
6299 The number of seconds after the minute, normally in the range@tie{}0
6300 to@tie{}59, but can be up to@tie{}61 to allow for leap seconds.
6301 Initialized at start-up of @code{gtroff}.
6303 @item \n[minutes]
6304 @cindex minutes, current time (@code{minutes})
6305 @cindex time, current, minutes (@code{minutes})
6306 @cindex current time, minutes (@code{minutes})
6307 @vindex minutes
6308 The number of minutes after the hour, in the range@tie{}0 to@tie{}59.
6309 Initialized at start-up of @code{gtroff}.
6311 @item \n[hours]
6312 @cindex hours, current time (@code{hours})
6313 @cindex time, current, hours (@code{hours})
6314 @cindex current time, hours (@code{hours})
6315 @vindex hours
6316 The number of hours past midnight, in the range@tie{}0 to@tie{}23.
6317 Initialized at start-up of @code{gtroff}.
6319 @item \n[dw]
6320 @cindex day of the week register (@code{dw})
6321 @cindex date, day of the week register (@code{dw})
6322 @vindex dw
6323 Day of the week (1-7).
6325 @item \n[dy]
6326 @cindex day of the month register (@code{dy})
6327 @cindex date, day of the month register (@code{dy})
6328 @vindex dy
6329 Day of the month (1-31).
6331 @item \n[mo]
6332 @cindex month of the year register (@code{mo})
6333 @cindex date, month of the year register (@code{mo})
6334 @vindex mo
6335 Current month (1-12).
6337 @item \n[year]
6338 @cindex date, year register (@code{year}, @code{yr})
6339 @cindex year, current, register (@code{year}, @code{yr})
6340 @vindex year
6341 The current year.
6343 @item \n[yr]
6344 @vindex yr
6345 The current year minus@tie{}1900.  Unfortunately, the documentation of
6346 @acronym{UNIX} Version@tie{}7's @code{troff} had a year@tie{}2000 bug:
6347 It incorrectly claimed that @code{yr} contains the last two digits of
6348 the year.  That claim has never been true of either @acronym{AT&T}
6349 @code{troff} or GNU @code{troff}.  Old @code{troff} input that looks
6350 like this:
6352 @Example
6353 '\" The following line stopped working after 1999
6354 This document was formatted in 19\n(yr.
6355 @endExample
6357 @noindent
6358 can be corrected as follows:
6360 @Example
6361 This document was formatted in \n[year].
6362 @endExample
6364 @noindent
6365 or, to be portable to older @code{troff} versions, as follows:
6367 @Example
6368 .nr y4 1900+\n(yr
6369 This document was formatted in \n(y4.
6370 @endExample
6372 @item \n[.c]
6373 @vindex .c
6374 @itemx \n[c.]
6375 @vindex c.
6376 @cindex input line number register (@code{.c}, @code{c.})
6377 @cindex line number, input, register (@code{.c}, @code{c.})
6378 The current @emph{input} line number.  Register @samp{.c} is read-only,
6379 whereas @samp{c.} (a @code{gtroff} extension) is writable also,
6380 affecting both @samp{.c} and @samp{c.}.
6382 @item \n[ln]
6383 @vindex ln
6384 @cindex output line number register (@code{ln})
6385 @cindex line number, output, register (@code{ln})
6386 The current @emph{output} line number after a call to the @code{nm}
6387 request to activate line numbering.
6389 @xref{Miscellaneous}, for more information about line numbering.
6391 @item \n[.x]
6392 @vindex .x
6393 @cindex major version number register (@code{.x})
6394 @cindex version number, major, register (@code{.x})
6395 The major version number.  For example, if the version number is 1.03
6396 then @code{.x} contains@tie{}@samp{1}.
6398 @item \n[.y]
6399 @vindex .y
6400 @cindex minor version number register (@code{.y})
6401 @cindex version number, minor, register (@code{.y})
6402 The minor version number.  For example, if the version number is 1.03
6403 then @code{.y} contains@tie{}@samp{03}.
6405 @item \n[.Y]
6406 @vindex .Y
6407 @cindex revision number register (@code{.Y})
6408 The revision number of @code{groff}.
6410 @item \n[$$]
6411 @vindex $$
6412 @cindex process ID of @code{gtroff} register (@code{$$})
6413 @cindex @code{gtroff}, process ID register (@code{$$})
6414 The process ID of @code{gtroff}.
6416 @item \n[.g]
6417 @vindex .g
6418 @cindex @code{gtroff}, identification register (@code{.g})
6419 @cindex GNU-specific register (@code{.g})
6420 Always@tie{}1.  Macros should use this to determine whether they are
6421 running under GNU @code{troff}.
6423 @item \n[.A]
6424 @vindex .A
6425 @cindex @acronym{ASCII} approximation output register (@code{.A})
6426 If the command line option @option{-a} is used to produce an
6427 @acronym{ASCII} approximation of the output, this is set to@tie{}1, zero
6428 otherwise.  @xref{Groff Options}.
6430 @item \n[.O]
6431 @vindex .O
6432 This read-only register is set to the suppression nesting level (see
6433 escapes @code{\O}).  @xref{Suppressing output}.
6435 @item \n[.P]
6436 @vindex .P
6437 This register is set to@tie{}1 (and to@tie{}0 otherwise) if the current
6438 page is actually being printed, i.e., if the @option{-o} option is being
6439 used to only print selected pages.  @xref{Groff Options}, for more
6440 information.
6442 @item \n[.T]
6443 @vindex .T
6444 If @code{gtroff} is called with the @option{-T} command line option, the
6445 number register @code{.T} is set to@tie{}1, and zero otherwise.
6446 @xref{Groff Options}.
6448 @item \*[.T]
6449 @stindex .T
6450 @cindex output device name string register (@code{.T})
6451 A single read-write string register which contains the current output
6452 device (for example, @samp{latin1} or @samp{ps}).  This is the only
6453 string register defined by @code{gtroff}.
6454 @end table
6457 @c =====================================================================
6459 @node Manipulating Filling and Adjusting, Manipulating Hyphenation, Registers, gtroff Reference
6460 @section Manipulating Filling and Adjusting
6461 @cindex manipulating filling and adjusting
6462 @cindex filling and adjusting, manipulating
6463 @cindex adjusting and filling, manipulating
6464 @cindex justifying text
6465 @cindex text, justifying
6467 @cindex break
6468 @cindex line break
6469 @cindex @code{bp} request, causing implicit linebreak
6470 @cindex @code{ce} request, causing implicit linebreak
6471 @cindex @code{cf} request, causing implicit linebreak
6472 @cindex @code{fi} request, causing implicit linebreak
6473 @cindex @code{fl} request, causing implicit linebreak
6474 @cindex @code{in} request, causing implicit linebreak
6475 @cindex @code{nf} request, causing implicit linebreak
6476 @cindex @code{rj} request, causing implicit linebreak
6477 @cindex @code{sp} request, causing implicit linebreak
6478 @cindex @code{ti} request, causing implicit linebreak
6479 @cindex @code{trf} request, causing implicit linebreak
6480 Various ways of causing @dfn{breaks} were given in @ref{Implicit Line
6481 Breaks}.  The @code{br} request likewise causes a break.  Several other
6482 requests also cause breaks, but implicitly.  These are @code{bp},
6483 @code{ce}, @code{cf}, @code{fi}, @code{fl}, @code{in}, @code{nf},
6484 @code{rj}, @code{sp}, @code{ti}, and @code{trf}.
6486 @Defreq {br, }
6487 Break the current line, i.e., the input collected so far is emitted
6488 without adjustment.
6490 If the no-break control character is used, @code{gtroff} suppresses the
6491 break:
6493 @Example
6497     @result{} a b
6498 @endExample
6499 @endDefreq
6501 Initially, @code{gtroff} fills and adjusts text to both margins.
6502 Filling can be disabled via the @code{nf} request and re-enabled with
6503 the @code{fi} request.
6505 @DefreqList {fi, }
6506 @DefregListEnd {.u}
6507 @cindex fill mode (@code{fi})
6508 @cindex mode, fill (@code{fi})
6509 Activate fill mode (which is the default).  This request implicitly
6510 enables adjusting; it also inserts a break in the text currently being
6511 filled.  The read-only number register @code{.u} is set to@tie{}1.
6513 The fill mode status is associated with the current environment
6514 (@pxref{Environments}).
6516 See @ref{Line Control}, for interaction with the @code{\c} escape.
6517 @endDefreq
6519 @Defreq {nf, }
6520 @cindex no-fill mode (@code{nf})
6521 @cindex mode, no-fill (@code{nf})
6522 Activate no-fill mode.  Input lines are output as-is, retaining line
6523 breaks and ignoring the current line length.  This command implicitly
6524 disables adjusting; it also causes a break.  The number register
6525 @code{.u} is set to@tie{}0.
6527 The fill mode status is associated with the current environment
6528 (@pxref{Environments}).
6530 See @ref{Line Control}, for interaction with the @code{\c} escape.
6531 @endDefreq
6533 @DefreqList {ad, [@Var{mode}]}
6534 @DefregListEnd {.j}
6535 Set adjusting mode.
6537 Activation and deactivation of adjusting is done implicitly with calls
6538 to the @code{fi} or @code{nf} requests.
6540 @var{mode} can have one of the following values:
6542 @table @code
6543 @item l
6544 @cindex ragged-right
6545 Adjust text to the left margin.  This produces what is traditionally
6546 called ragged-right text.
6548 @item r
6549 @cindex ragged-left
6550 Adjust text to the right margin, producing ragged-left text.
6552 @item c
6553 @cindex centered text
6554 @cindex @code{ce} request, difference to @samp{.ad@tie{}c}
6555 Center filled text.  This is different to the @code{ce} request which
6556 only centers text without filling.
6558 @item b
6559 @itemx n
6560 Justify to both margins.  This is the default used by @code{gtroff}.
6561 @end table
6563 Finally, @var{mode} can be the numeric argument returned by the
6564 @code{.j} register.
6566 With no argument, @code{gtroff} adjusts lines in the same way it did
6567 before adjusting was deactivated (with a call to @code{na}, for
6568 example).
6570 @Example
6571 text
6572 .ad r
6573 .nr ad \n[.j]
6574 text
6575 .ad c
6576 text
6578 text
6579 .ad         \" back to centering
6580 text
6581 .ad \n[ad]  \" back to right justifying
6582 @endExample
6584 @cindex adjustment mode register (@code{.j})
6585 The current adjustment mode is available in the read-only number
6586 register @code{.j}; it can be stored and subsequently used to set
6587 adjustment.
6589 The adjustment mode status is associated with the current environment
6590 (@pxref{Environments}).
6591 @endDefreq
6593 @Defreq {na, }
6594 Disable adjusting.  This request won't change the current adjustment
6595 mode: A subsequent call to @code{ad} uses the previous adjustment
6596 setting.
6598 The adjustment mode status is associated with the current environment
6599 (@pxref{Environments}).
6600 @endDefreq
6602 @DefreqList {brp, }
6603 @DefescListEnd {\\p, , , }
6604 Adjust the current line and cause a break.
6606 In most cases this produces very ugly results since @code{gtroff}
6607 doesn't have a sophisticated paragraph building algorithm (as @TeX{}
6608 have, for example); instead, @code{gtroff} fills and adjusts a paragraph
6609 line by line:
6611 @Example
6612 This is an uninteresting sentence.
6613 This is an uninteresting sentence.\p
6614 This is an uninteresting sentence.
6615 @endExample
6617 @noindent
6618 is formatted as
6620 @Example
6621 This is  an uninteresting  sentence.   This  is an
6622 uninteresting                            sentence.
6623 This is an uninteresting sentence.
6624 @endExample
6625 @endDefreq
6627 @DefreqList {ss, word_space_size [@Var{sentence_space_size}]}
6628 @DefregItem {.ss}
6629 @DefregListEnd {.sss}
6630 @cindex word space size register (@code{.ss})
6631 @cindex size of word space register (@code{.ss})
6632 @cindex space between words register (@code{.ss})
6633 @cindex sentence space size register (@code{.sss})
6634 @cindex size of sentence space register (@code{.sss})
6635 @cindex space between sentences register (@code{.sss})
6636 Change the size of a space between words.  It takes its units as one
6637 twelfth of the space width parameter for the current font.  Initially
6638 both the @var{word_space_size} and @var{sentence_space_size}
6639 are@tie{}12.  In fill mode, the values specify the minimum distance.
6641 @cindex fill mode
6642 @cindex mode, fill
6643 If two arguments are given to the @code{ss} request, the second argument
6644 sets the sentence space size.  If the second argument is not given,
6645 sentence space size is set to @var{word_space_size}.  The sentence space
6646 size is used in two circumstances: If the end of a sentence occurs at
6647 the end of a line in fill mode, then both an inter-word space and a
6648 sentence space are added; if two spaces follow the end of a sentence in
6649 the middle of a line, then the second space is a sentence space.  If a
6650 second argument is never given to the @code{ss} request, the behaviour
6651 of @acronym{UNIX} @code{troff} is the same as that exhibited by GNU
6652 @code{troff}.  In GNU @code{troff}, as in @acronym{UNIX} @code{troff}, a
6653 sentence should always be followed by either a newline or two spaces.
6655 The read-only number registers @code{.ss} and @code{.sss} hold the
6656 values of the parameters set by the first and second arguments of the
6657 @code{ss} request.
6659 The word space and sentence space values are associated with the current
6660 environment (@pxref{Environments}).
6662 Contrary to @acronym{AT&T} @code{troff}, this request is @emph{not}
6663 ignored if a TTY output device is used; the given values are then
6664 rounded down to a multiple of@tie{}12 (@pxref{Implementation
6665 Differences}).
6667 The request is ignored if there is no parameter.
6669 @cindex discardable horizontal space
6670 @cindex space, discardable, horizontal
6671 @cindex horizontal discardable space
6672 Another useful application of the @code{ss} request is to insert
6673 discardable horizontal space, i.e., space which is discarded at a line
6674 break.  For example, paragraph-style footnotes could be separated this
6675 way:
6677 @Example
6678 .ll 4.5i
6679 1.\ This is the first footnote.\c
6680 .ss 48
6681 .nop
6682 .ss 12
6683 2.\ This is the second footnote.
6684 @endExample
6686 @noindent
6687 The result:
6689 @Example
6690 1. This is the first footnote.        2. This
6691 is the second footnote.
6692 @endExample
6694 @noindent
6695 Note that the @code{\h} escape produces unbreakable space.
6696 @endDefreq
6698 @DefreqList {ce, [@Var{nnn}]}
6699 @DefregListEnd {.ce}
6700 @cindex centering lines (@code{ce})
6701 @cindex lines, centering (@code{ce})
6702 Center text.  While the @w{@samp{.ad c}} request also centers text, it
6703 fills the text as well.  @code{ce} does not fill the text it affects.
6704 This request causes a break.  The number of lines still to be centered
6705 is associated with the current environment (@pxref{Environments}).
6707 The following example demonstrates the differences.  Here the input:
6709 @Example
6710 .ll 4i
6711 .ce 1000
6712 This is a small text fragment which shows the differences
6713 between the `.ce' and the `.ad c' request.
6714 .ce 0
6716 .ad c
6717 This is a small text fragment which shows the differences
6718 between the `.ce' and the `.ad c' request.
6719 @endExample
6721 @noindent
6722 And here the result:
6724 @Example
6725   This is a small text fragment which
6726          shows the differences
6727 between the `.ce' and the `.ad c' request.
6729   This is a small text fragment which
6730 shows the differences between the `.ce'
6731         and the `.ad c' request.
6732 @endExample
6734 With no arguments, @code{ce} centers the next line of text.  @var{nnn}
6735 specifies the number of lines to be centered.  If the argument is zero
6736 or negative, centering is disabled.
6738 The basic length for centering text is the line length (as set with the
6739 @code{ll} request) minus the indentation (as set with the @code{in}
6740 request).  Temporary indentation is ignored.
6742 As can be seen in the previous example, it is a common idiom to turn on
6743 centering for a large number of lines, and to turn off centering after
6744 text to be centered.  This is useful for any request which takes a
6745 number of lines as an argument.
6747 The @code{.ce} read-only number register contains the number of lines
6748 remaining to be centered, as set by the @code{ce} request.
6749 @endDefreq
6751 @DefreqList {rj, [@Var{nnn}]}
6752 @DefregListEnd {.rj}
6753 @cindex justifying text (@code{rj})
6754 @cindex text, justifying (@code{rj})
6755 @cindex right-justifying (@code{rj})
6756 Justify unfilled text to the right margin.  Arguments are identical to
6757 the @code{ce} request.  The @code{.rj} read-only number register is the
6758 number of lines to be right-justified as set by the @code{rj} request.
6759 This request causes a break.  The number of lines still to be
6760 right-justified is associated with the current environment
6761 (@pxref{Environments}).
6762 @endDefreq
6765 @c =====================================================================
6767 @node Manipulating Hyphenation, Manipulating Spacing, Manipulating Filling and Adjusting, gtroff Reference
6768 @section Manipulating Hyphenation
6769 @cindex manipulating hyphenation
6770 @cindex hyphenation, manipulating
6772 Here a description of requests which influence hyphenation.
6774 @DefreqList {hy, [@Var{mode}]}
6775 @DefregListEnd {.hy}
6776 Enable hyphenation.  The request has an optional numeric argument,
6777 @var{mode}, to restrict hyphenation if necessary:
6779 @table @code
6780 @item 1
6781 The default argument if @var{mode} is omitted.  Hyphenate without
6782 restrictions.  This is also the start-up value of @code{gtroff}.
6784 @item 2
6785 Do not hyphenate the last word on a page or column.
6787 @item 4
6788 Do not hyphenate the last two characters of a word.
6790 @item 8
6791 Do not hyphenate the first two characters of a word.
6792 @end table
6794 Values in the previous table are additive.  For example, the
6795 value@tie{}12 causes @code{gtroff} to neither hyphenate the last two nor
6796 the first two characters of a word.
6798 @cindex hyphenation restrictions register (@code{.hy})
6799 The current hyphenation restrictions can be found in the read-only
6800 number register @samp{.hy}.
6802 The hyphenation mode is associated with the current environment
6803 (@pxref{Environments}).
6804 @endDefreq
6806 @Defreq {nh, }
6807 Disable hyphenation (i.e., set the hyphenation mode to zero).  Note that
6808 the hyphenation mode of the last call to @code{hy} is not remembered.
6810 The hyphenation mode is associated with the current environment
6811 (@pxref{Environments}).
6812 @endDefreq
6814 @DefreqList {hlm, [@Var{nnn}]}
6815 @DefregItem {.hlm}
6816 @DefregListEnd {.hlc}
6817 @cindex explicit hyphen (@code{\%})
6818 @cindex hyphen, explicit (@code{\%})
6819 @cindex consecutive hyphenated lines (@code{hlm})
6820 @cindex lines, consecutive hyphenated (@code{hlm})
6821 @cindex hyphenated lines, consecutive (@code{hlm})
6822 Set the maximum number of consecutive hyphenated lines to @var{nnn}.  If
6823 this number is negative, there is no maximum.  The default value
6824 is@tie{}@minus{}1 if @var{nnn} is omitted.  This value is associated
6825 with the current environment (@pxref{Environments}).  Only lines output
6826 from a given environment count towards the maximum associated with that
6827 environment.  Hyphens resulting from @code{\%} are counted; explicit
6828 hyphens are not.
6830 The current setting of @code{hlm} is available in the @code{.hlm}
6831 read-only number register.  Also the number of immediately preceding
6832 consecutive hyphenated lines are available in the read-only number
6833 register @samp{.hlc}.
6834 @endDefreq
6836 @Defreq {hw, word1 word2 @dots{}}
6837 Define how @var{word1}, @var{word2}, etc.@: are to be hyphenated.  The
6838 words must be given with hyphens at the hyphenation points.  For
6839 example:
6841 @Example
6842 .hw in-sa-lub-rious
6843 @endExample
6845 @noindent
6846 Besides the space character, any character whose hyphenation code value
6847 is zero can be used to separate the arguments of @code{hw} (see the
6848 documentation for the @code{hcode} request below for more information).
6849 In addition, this request can be used more than once.
6851 Hyphenation exceptions specified with the @code{hw} request are
6852 associated with the current hyphenation language; it causes an error if
6853 there is no current hyphenation language.
6855 This request is ignored if there is no parameter.
6857 In old versions of @code{troff} there was a limited amount of space to
6858 store such information; fortunately, with @code{gtroff}, this is no
6859 longer a restriction.
6860 @endDefreq
6862 @DefescList {\\%, , , }
6863 @deffnx Escape @t{\:}
6864 @ifnotinfo
6865 @esindex \:
6866 @end ifnotinfo
6867 @ifinfo
6868 @esindex \@r{<colon>}
6869 @end ifinfo
6870 @cindex hyphenation character (@code{\%})
6871 @cindex character, hyphenation (@code{\%})
6872 @cindex disabling hyphenation (@code{\%})
6873 @cindex hyphenation, disabling (@code{\%})
6874 To tell @code{gtroff} how to hyphenate words on the fly, use the
6875 @code{\%} escape, also known as the @dfn{hyphenation character}.
6876 Preceding a word with this character prevents it from being
6877 hyphenated; putting it inside a word indicates to @code{gtroff} that
6878 the word may be hyphenated at that point.  Note that this mechanism
6879 only affects that one occurrence of the word; to change the
6880 hyphenation of a word for the entire document, use the @code{hw}
6881 request.
6883 The @code{\:} escape inserts a zero-width break point (that is, the word
6884 breaks but without adding a hyphen).
6886 @Example
6887 ... check the /var/log/\:httpd/\:access_log file ...
6888 @endExample
6890 @cindex @code{\X}, followed by @code{\%}
6891 @cindex @code{\Y}, followed by @code{\%}
6892 @cindex @code{\%}, following @code{\X} or @code{\Y}
6893 Note that @code{\X} and @code{\Y} start a word, that is, the @code{\%}
6894 escape in (say) @w{@samp{\X'...'\%foobar}} and
6895 @w{@samp{\Y'...'\%foobar}} no longer prevents hyphenation but inserts a
6896 hyphenation point at the beginning of @samp{foobar}; most likely this
6897 isn't what you want to do.
6898 @endDefesc
6900 @Defreq {hc, [@Var{char}]}
6901 Change the hyphenation character to @var{char}.  This character then
6902 works the same as the @code{\%} escape, and thus, no longer appears in
6903 the output.  Without an argument, @code{hc} resets the hyphenation
6904 character to be @code{\%} (the default) only.
6906 The hyphenation character is associated with the current environment
6907 (@pxref{Environments}).
6908 @endDefreq
6910 @DefreqList {hpf, pattern_file}
6911 @DefreqItem {hpfa, pattern_file}
6912 @DefreqListEnd {hpfcode, a b [c d @dots{}]}
6913 @cindex hyphenation patterns (@code{hpf})
6914 @cindex patterns for hyphenation (@code{hpf})
6915 Read in a file of hyphenation patterns.  This file is searched for in
6916 the same way as @file{@var{name}.tmac} (or @file{tmac.@var{name}}) is
6917 searched for if the @option{-m@var{name}} option is specified.
6919 It should have the same format as (simple) @TeX{} patterns files.  More
6920 specifically, the following scanning rules are implemented.
6922 @itemize @bullet
6923 @item
6924 A percent sign starts a comment (up to the end of the line) even if
6925 preceded by a backslash.
6927 @item
6928 No support for `digraphs' like @code{\$}.
6930 @item
6931 @code{^^@var{xx}} (@var{x} is 0-9 or a-f) and @code{^^@var{x}}
6932 (character code of @var{x} in the range 0-127) are recognized; other use
6933 of @code{^} causes an error.
6935 @item
6936 No macro expansion.
6938 @item
6939 @code{hpf} checks for the expression @code{\patterns@{@dots{}@}}
6940 (possibly with whitespace before and after the braces).  Everything
6941 between the braces is taken as hyphenation patterns.  Consequently,
6942 @code{@{} and @code{@}} are not allowed in patterns.
6944 @item
6945 Similarly, @code{\hyphenation@{@dots{}@}} gives a list of hyphenation
6946 exceptions.
6948 @item
6949 @code{\endinput} is recognized also.
6951 @item
6952 For backwards compatibility, if @code{\patterns} is missing, the whole
6953 file is treated as a list of hyphenation patterns (only recognizing the
6954 @code{%} character as the start of a comment).
6955 @end itemize
6957 If no @code{hpf} request is specified (either in the document or in a
6958 macro package), @code{gtroff} won't hyphenate at all.
6960 The @code{hpfa} request appends a file of patterns to the current list.
6962 The @code{hpfcode} request defines mapping values for character codes in
6963 hyphenation patterns.  @code{hpf} or @code{hpfa} then apply the mapping
6964 (after reading the patterns) before replacing or appending them to the
6965 current list of patterns.  Its arguments are pairs of character codes --
6966 integers from 0 to@tie{}255.  The request maps character
6967 code@tie{}@var{a} to code@tie{}@var{b}, code@tie{}@var{c} to
6968 code@tie{}@var{d}, and so on.  You can use character codes which would
6969 be invalid otherwise.
6971 @pindex troffrc
6972 @pindex troffrc-end
6973 @pindex hyphen.us
6974 @pindex hyphenex.us
6975 The set of hyphenation patterns is associated with the current language
6976 set by the @code{hla} request.  The @code{hpf} request is usually
6977 invoked by the @file{troffrc} or @file{troffrc-end} file; by default,
6978 @file{troffrc} loads hyphenation patterns and exceptions for American
6979 English (in files @file{hyphen.us} and @file{hyphenex.us}).
6981 A second call to @code{hpf} (for the same language) replaces the
6982 hyphenation patterns with the new ones.
6984 Invoking @code{hpf} causes an error if there is no current hyphenation
6985 language.
6986 @endDefreq
6988 @Defreq {hcode, c1 code1 [c2 code2 @dots{}]}
6989 @cindex hyphenation code (@code{hcode})
6990 @cindex code, hyphenation (@code{hcode})
6991 Set the hyphenation code of character @var{c1} to @var{code1}, that of
6992 @var{c2} to @var{code2}, etc.  A hyphenation code must be a single input
6993 character (not a special character) other than a digit or a space.
6995 To make hyphenation work, hyphenation codes must be set up.  At
6996 start-up, groff only assigns hyphenation codes to the letters
6997 @samp{a}-@samp{z} (mapped to themselves) and to the letters
6998 @samp{A}-@samp{Z} (mapped to @samp{a}-@samp{z}); all other hyphenation
6999 codes are set to zero.  Normally, hyphenation patterns contain only
7000 lowercase letters which should be applied regardless of case.  In
7001 other words, the words `FOO' and `Foo' should be hyphenated exactly the
7002 same way as the word `foo' is hyphenated, and this is what @code{hcode}
7003 is good for.  Words which contain other letters won't be hyphenated
7004 properly if the corresponding hyphenation patterns actually do contain
7005 them.  For example, the following @code{hcode} requests are necessary to
7006 assign hyphenation codes to the letters @samp{ÄäÖöÜüß} (this is needed
7007 for German):
7009 @Example
7010 .hcode Ã¤ Ã¤  Ã„ Ã¤
7011 .hcode Ã¶ Ã¶  Ã– Ã¶
7012 .hcode Ã¼ Ã¼  Ãœ Ã¼
7013 .hcode ÃŸ ÃŸ
7014 @endExample
7016 Without those assignments, groff treats German words like
7017 @w{`Kindergärten'} (the plural form of `kindergarten') as two substrings
7018 @w{`kinderg'} and @w{`rten'} because the hyphenation code of the
7019 umlaut@tie{}a is zero by default.  There is a German hyphenation pattern
7020 which covers @w{`kinder'}, so groff finds the hyphenation `kin-der'.
7021 The other two hyphenation points (`kin-der-gär-ten') are missed.
7023 This request is ignored if it has no parameter.
7024 @endDefreq
7026 @DefreqList {hym, [@Var{length}]}
7027 @DefregListEnd {.hym}
7028 @cindex hyphenation margin (@code{hym})
7029 @cindex margin for hyphenation (@code{hym})
7030 @cindex @code{ad} request, and hyphenation margin
7031 Set the (right) hyphenation margin to @var{length}.  If the current
7032 adjustment mode is not @samp{b} or @samp{n}, the line is not hyphenated
7033 if it is shorter than @var{length}.  Without an argument, the
7034 hyphenation margin is reset to its default value, which is@tie{}0.  The
7035 default scaling indicator for this request is @samp{m}.  The hyphenation
7036 margin is associated with the current environment
7037 (@pxref{Environments}).
7039 A negative argument resets the hyphenation margin to zero, emitting a
7040 warning of type @samp{range}.
7042 @cindex hyphenation margin register (@code{.hym})
7043 The current hyphenation margin is available in the @code{.hym} read-only
7044 number register.
7045 @endDefreq
7047 @DefreqList {hys, [@Var{hyphenation_space}]}
7048 @DefregListEnd {.hys}
7049 @cindex hyphenation space (@code{hys})
7050 @cindex @code{ad} request, and hyphenation space
7051 Set the hyphenation space to @var{hyphenation_space}.  If the current
7052 adjustment mode is @samp{b} or @samp{n}, don't hyphenate the line if it
7053 can be justified by adding no more than @var{hyphenation_space} extra
7054 space to each word space.  Without argument, the hyphenation space is
7055 set to its default value, which is@tie{}0.  The default scaling
7056 indicator for this request is @samp{m}.  The hyphenation space is
7057 associated with the current environment (@pxref{Environments}).
7059 A negative argument resets the hyphenation space to zero, emitting a
7060 warning of type @samp{range}.
7062 @cindex hyphenation space register (@code{.hys})
7063 The current hyphenation space is available in the @code{.hys} read-only
7064 number register.
7065 @endDefreq
7067 @Defreq {shc, [@Var{glyph}]}
7068 @cindex soft hyphen character, setting (@code{shc})
7069 @cindex character, soft hyphen, setting (@code{shc})
7070 @cindex glyph, soft hyphen (@code{hy})
7071 @cindex soft hyphen glyph (@code{hy})
7072 @cindex @code{char} request, and soft hyphen character
7073 @cindex @code{tr} request, and soft hyphen character
7074 Set the @dfn{soft hyphen character} to @var{glyph}.@footnote{@dfn{Soft
7075 hyphen character} is a misnomer since it is an output glyph.}  If the
7076 argument is omitted, the soft hyphen character is set to the default
7077 glyph @code{\(hy} (this is the start-up value of @code{gtroff} also).
7078 The soft hyphen character is the glyph that is inserted when a word is
7079 hyphenated at a line break.  If the soft hyphen character does not exist
7080 in the font of the character immediately preceding a potential break
7081 point, then the line is not broken at that point.  Neither definitions
7082 (specified with the @code{char} request) nor translations (specified
7083 with the @code{tr} request) are considered when finding the soft hyphen
7084 character.
7085 @endDefreq
7087 @DefreqList {hla, language}
7088 @DefregListEnd {.hla}
7089 @cindex @code{hpf} request, and hyphenation language
7090 @cindex @code{hw} request, and hyphenation language
7091 @pindex troffrc
7092 @pindex troffrc-end
7093 Set the current hyphenation language to the string @var{language}.
7094 Hyphenation exceptions specified with the @code{hw} request and
7095 hyphenation patterns specified with the @code{hpf} and @code{hpfa}
7096 requests are both associated with the current hyphenation language.  The
7097 @code{hla} request is usually invoked by the @file{troffrc} or the
7098 @file{troffrc-end} files; @file{troffrc} sets the default language to
7099 @samp{us}.
7101 @cindex hyphenation language register (@code{.hla})
7102 The current hyphenation language is available as a string in the
7103 read-only number register @samp{.hla}.
7105 @Example
7106 .ds curr_language \n[.hla]
7107 \*[curr_language]
7108     @result{} us
7109 @endExample
7110 @endDefreq
7113 @c =====================================================================
7115 @node Manipulating Spacing, Tabs and Fields, Manipulating Hyphenation, gtroff Reference
7116 @section Manipulating Spacing
7117 @cindex manipulating spacing
7118 @cindex spacing, manipulating
7120 @Defreq {sp, [@Var{distance}]}
7121 Space downwards @var{distance}.  With no argument it advances
7122 1@tie{}line.  A negative argument causes @code{gtroff} to move up the
7123 page the specified distance.  If the argument is preceded by a @samp{|}
7124 then @code{gtroff} moves that distance from the top of the page.  This
7125 request causes a line break, and that adds the current line spacing to
7126 the space you have just specified.  The default scaling indicator is
7127 @samp{v}.
7129 For convenience you may wish to use the following macros to set the
7130 height of the next line at a given distance from the top or the bottom
7131 of the page:
7133 @Example
7134 .de y-from-top-down
7135 .  sp |\\$1-\\n[.v]u
7138 .de y-from-bot-up
7139 .  sp |\\n[.p]u-\\$1-\\n[.v]u
7141 @endExample
7143 @noindent
7144 A call to @samp{.y-from-bot-up 10c} means that the bottom of the next
7145 line will be at 10@dmn{cm} from the paper edge at the bottom.
7147 If a vertical trap is sprung during execution of @code{sp}, the amount
7148 of vertical space after the trap is discarded.  For example, this
7150 @Example
7151 .de xxx
7154 .wh 0 xxx
7156 .pl 5v
7158 .sp 2
7160 .sp 50
7162 @endExample
7164 @noindent
7165 results in
7167 @Example
7174 @endExample
7176 @cindex @code{sp} request, and traps
7177 @cindex discarded space in traps
7178 @cindex space, discarded, in traps
7179 @cindex traps, and discarded space
7180 The amount of discarded space is available in the number register
7181 @code{.trunc}.
7183 To protect @code{sp} against vertical traps, use the @code{vpt} request:
7185 @Example
7186 .vpt 0
7187 .sp -3
7188 .vpt 1
7189 @endExample
7190 @endDefreq
7192 @DefreqList {ls, [@Var{nnn}]}
7193 @DefregListEnd {.L}
7194 @cindex double-spacing (@code{ls})
7195 Output @w{@var{nnn}@minus{}1} blank lines after each line of text.  With
7196 no argument, @code{gtroff} uses the previous value before the last
7197 @code{ls} call.
7199 @Example
7200 .ls 2    \" This causes double-spaced output
7201 .ls 3    \" This causes triple-spaced output
7202 .ls      \" Again double-spaced
7203 @endExample
7205 The line spacing is associated with the current environment
7206 (@pxref{Environments}).
7208 @cindex line spacing register (@code{.L})
7209 The read-only number register @code{.L} contains the current line
7210 spacing setting.
7211 @endDefreq
7213 @xref{Changing Type Sizes}, for the requests @code{vs} and @code{pvs} as
7214 alternatives to @code{ls}.
7216 @DefescList {\\x, ', spacing, '}
7217 @DefregListEnd {.a}
7218 Sometimes, extra vertical spacing is only needed occasionally, e.g.@: to
7219 allow space for a tall construct (like an equation).  The @code{\x}
7220 escape does this.  The escape is given a numerical argument, usually
7221 enclosed in quotes (like @samp{\x'3p'}); the default scaling indicator
7222 is @samp{v}.  If this number is positive extra vertical space is
7223 inserted below the current line.  A negative number adds space above.
7224 If this escape is used multiple times on the same line, the maximum of
7225 the values is used.
7227 @xref{Escapes}, for details on parameter delimiting characters.
7229 @cindex extra post-vertical line space register (@code{.a})
7230 The @code{.a} read-only number register contains the most recent
7231 (nonnegative) extra vertical line space.
7233 Using @code{\x} can be necessary in combination with the @code{\b}
7234 escape, as the following example shows.
7236 @Example
7237 This is a test with the \[rs]b escape.
7239 This is a test with the \[rs]b escape.
7241 This is a test with \b'xyz'\x'-1m'\x'1m'.
7243 This is a test with the \[rs]b escape.
7245 This is a test with the \[rs]b escape.
7246 @endExample
7248 @noindent
7249 produces
7251 @Example
7252 This is a test with the \b escape.
7253 This is a test with the \b escape.
7254                     x
7255 This is a test with y.
7256                     z
7257 This is a test with the \b escape.
7258 This is a test with the \b escape.
7259 @endExample
7260 @endDefesc
7262 @DefreqList {ns, }
7263 @DefreqItem {rs, }
7264 @DefregListEnd {.ns}
7265 @cindex @code{sp} request, and no-space mode
7266 @cindex no-space mode (@code{ns})
7267 @cindex mode, no-space (@code{ns})
7268 @cindex blank lines, disabling
7269 @cindex lines, blank, disabling
7270 Enable @dfn{no-space mode}.  In this mode, spacing (either via @code{sp}
7271 or via blank lines) is disabled.  The @code{bp} request to advance to
7272 the next page is also disabled, except if it is accompanied by a page
7273 number (see @ref{Page Control}, for more information).  This mode ends
7274 when actual text is output or the @code{rs} request is encountered which
7275 ends no-space mode.  The read-only number register @code{.ns} is set
7276 to@tie{}1 as long as no-space mode is active.
7278 This request is useful for macros that conditionally insert vertical
7279 space before the text starts (for example, a paragraph macro could
7280 insert some space except when it is the first paragraph after a section
7281 header).
7282 @endDefreq
7285 @c =====================================================================
7287 @node Tabs and Fields, Character Translations, Manipulating Spacing, gtroff Reference
7288 @section Tabs and Fields
7289 @cindex tabs, and fields
7290 @cindex fields, and tabs
7292 @cindex @acronym{EBCDIC} encoding of a tab
7293 A tab character (@acronym{ASCII} char@tie{}9, @acronym{EBCDIC}
7294 char@tie{}5) causes a horizontal movement to the next tab stop (much
7295 like it did on a typewriter).
7297 @Defesc {\\t, , , }
7298 @cindex tab character, non-interpreted (@code{\t})
7299 @cindex character, tab, non-interpreted (@code{\t})
7300 @cindex @code{\t}, and copy-in mode
7301 @cindex copy-in mode, and @code{\t}
7302 @cindex mode, copy-in, and @code{\t}
7303 This escape is a non-interpreted tab character.  In copy mode
7304 (@pxref{Copy-in Mode}), @code{\t} is the same as a real tab character.
7305 @endDefesc
7307 @DefreqList {ta, [@Var{n1} @Var{n2} @dots{} @Var{nn} @t{T} @Var{r1} @Var{r2} @dots{} @Var{rn}]}
7308 @DefregListEnd {.tabs}
7309 Change tab stop positions.  This request takes a series of tab
7310 specifiers as arguments (optionally divided into two groups with the
7311 letter @samp{T}) which indicate where each tab stop is to be (overriding
7312 any previous settings).
7314 Tab stops can be specified absolutely, i.e., as the distance from the
7315 left margin.  For example, the following sets 6@tie{}tab stops every one
7316 inch.
7318 @Example
7319 .ta 1i 2i 3i 4i 5i 6i
7320 @endExample
7322 Tab stops can also be specified using a leading @samp{+} which means
7323 that the specified tab stop is set relative to the previous tab stop.
7324 For example, the following is equivalent to the previous example.
7326 @Example
7327 .ta 1i +1i +1i +1i +1i +1i
7328 @endExample
7330 @code{gtroff} supports an extended syntax to specify repeat values after
7331 the @samp{T} mark (these values are always taken as relative) -- this is
7332 the usual way to specify tabs set at equal intervals.  The following is,
7333 yet again, the same as the previous examples.  It does even more since
7334 it defines an infinite number of tab stops separated by one inch.
7336 @Example
7337 .ta T 1i
7338 @endExample
7340 Now we are ready to interpret the full syntax given at the beginning:
7341 Set tabs at positions @var{n1}, @var{n2}, @dots{}, @var{nn} and then set
7342 tabs at @var{nn}+@var{r1}, @var{nn}+@var{r2}, @dots{}, @var{nn}+@var{rn}
7343 and then at @var{nn}+@var{rn}+@var{r1}, @var{nn}+@var{rn}+@var{r2},
7344 @dots{}, @var{nn}+@var{rn}+@var{rn}, and so on.
7346 Example: @samp{4c +6c T 3c 5c 2c} is equivalent to @samp{4c 10c 13c 18c
7347 20c 23c 28c 30c @dots{}}.
7349 The material in each tab column (i.e., the column between two tab stops)
7350 may be justified to the right or left or centered in the column.  This
7351 is specified by appending @samp{R}, @samp{L}, or @samp{C} to the tab
7352 specifier.  The default justification is @samp{L}.  Example:
7354 @Example
7355 .ta 1i 2iC 3iR
7356 @endExample
7358 Some notes:
7360 @itemize @bullet
7361 @item
7362 The default unit of the @code{ta} request is @samp{m}.
7364 @item
7365 A tab stop is converted into a non-breakable horizontal movement which
7366 can be neither stretched nor squeezed.  For example,
7368 @Example
7369 .ds foo a\tb\tc
7370 .ta T 5i
7371 \*[foo]
7372 @endExample
7374 @noindent
7375 creates a single line which is a bit longer than 10@tie{}inches (a
7376 string is used to show exactly where the tab characters are).  Now
7377 consider the following:
7379 @Example
7380 .ds bar a\tb b\tc
7381 .ta T 5i
7382 \*[bar]
7383 @endExample
7385 @noindent
7386 @code{gtroff} first converts the tab stops of the line into unbreakable
7387 horizontal movements, then splits the line after the second @samp{b}
7388 (assuming a sufficiently short line length).  Usually, this isn't what
7389 the user wants.
7391 @item
7392 Superfluous tabs (i.e., tab characters which do not correspond to a tab
7393 stop) are ignored except the first one which delimits the characters
7394 belonging to the last tab stop for right-justifying or centering.
7395 Consider the following example
7397 @Example
7398 .ds Z   foo\tbar\tfoo
7399 .ds ZZ  foo\tbar\tfoobar
7400 .ds ZZZ foo\tbar\tfoo\tbar
7401 .ta 2i 4iR
7402 \*[Z]
7404 \*[ZZ]
7406 \*[ZZZ]
7408 @endExample
7410 @noindent
7411 which produces the following output:
7413 @Example
7414 foo                 bar              foo
7415 foo                 bar           foobar
7416 foo                 bar              foobar
7417 @endExample
7419 @noindent
7420 The first line right-justifies the second `foo' relative to the tab
7421 stop.  The second line right-justifies `foobar'.  The third line finally
7422 right-justifies only `foo' because of the additional tab character which
7423 marks the end of the string belonging to the last defined tab stop.
7425 @item
7426 Tab stops are associated with the current environment
7427 (@pxref{Environments}).
7429 @item
7430 Calling @code{ta} without an argument removes all tab stops.
7432 @item
7433 @cindex tab stops, for TTY output devices
7434 The start-up value of @code{gtroff} is @w{@samp{T 0.8i}}.
7435 @end itemize
7437 @cindex tab settings register (@code{.tabs})
7438 The read-only number register @code{.tabs} contains a string
7439 representation of the current tab settings suitable for use as an
7440 argument to the @code{ta} request.
7442 @Example
7443 .ds tab-string \n[.tabs]
7444 \*[tab-string]
7445     @result{} T120u
7446 @endExample
7448 @cindex @code{.S} register, Plan@tie{}9 alias for @code{.tabs}
7449 @cindex @code{.tabs} register, Plan@tie{}9 alias (@code{.S})
7450 The @code{troff} version of the Plan@tie{}9 operating system uses
7451 register @code{.S} for the same purpose.
7452 @endDefreq
7454 @Defreq {tc, [@Var{fill-glyph}]}
7455 @cindex tab repetition character (@code{tc})
7456 @cindex character, tab repetition (@code{tc})
7457 @cindex glyph, tab repetition (@code{tc})
7458 Normally @code{gtroff} fills the space to the next tab stop with
7459 whitespace.  This can be changed with the @code{tc} request.  With no
7460 argument @code{gtroff} reverts to using whitespace, which is the
7461 default.  The value of this @dfn{tab repetition character} is associated
7462 with the current environment (@pxref{Environments}).@footnote{@dfn{Tab
7463 repetition character} is a misnomer since it is an output glyph.}
7464 @endDefreq
7466 @DefreqList {linetabs, n}
7467 @DefregListEnd {.linetabs}
7468 @cindex tab, line-tabs mode
7469 @cindex line-tabs mode
7470 @cindex mode, line-tabs
7471 If @var{n} is missing or not zero, enable @dfn{line-tabs} mode, or
7472 disable it otherwise (the default).  In line-tabs mode, @code{gtroff}
7473 computes tab distances relative to the (current) output line instead of
7474 the input line.
7476 For example, the following code:
7478 @Example
7479 .ds x a\t\c
7480 .ds y b\t\c
7481 .ds z c
7482 .ta 1i 3i
7486 @endExample
7488 @noindent
7489 in normal mode, results in the output
7491 @Example
7492 a         b         c
7493 @endExample
7495 @noindent
7496 in line-tabs mode, the same code outputs
7498 @Example
7499 a         b                   c
7500 @endExample
7502 Line-tabs mode is associated with the current environment.  The
7503 read-only register @code{.linetabs} is set to@tie{}1 if in line-tabs
7504 mode, and 0 in normal mode.
7505 @endDefreq
7507 @menu
7508 * Leaders::
7509 * Fields::
7510 @end menu
7512 @c ---------------------------------------------------------------------
7514 @node Leaders, Fields, Tabs and Fields, Tabs and Fields
7515 @subsection Leaders
7516 @cindex leaders
7518 Sometimes it may may be desirable to use the @code{tc} request to fill a
7519 particular tab stop with a given glyph (for example dots in a table of
7520 contents), but also normal tab stops on the rest of the line.  For this
7521 @code{gtroff} provides an alternate tab mechanism, called @dfn{leaders}
7522 which does just that.
7524 @cindex leader character
7525 A leader character (character code@tie{}1) behaves similarly to a tab
7526 character: It moves to the next tab stop.  The only difference is that
7527 for this movement, the fill glyph defaults to a period character and not
7528 to space.
7530 @Defesc {\\a, , , }
7531 @cindex leader character, non-interpreted (@code{\a})
7532 @cindex character, leader, non-interpreted (@code{\a})
7533 @cindex @code{\a}, and copy-in mode
7534 @cindex copy-in mode, and @code{\a}
7535 @cindex mode, copy-in, and @code{\a}
7536 This escape is a non-interpreted leader character.  In copy mode
7537 (@pxref{Copy-in Mode}), @code{\a} is the same as a real leader
7538 character.
7539 @endDefesc
7541 @Defreq {lc, [@Var{fill-glyph}]}
7542 @cindex leader repetition character (@code{lc})
7543 @cindex character, leader repetition (@code{lc})
7544 @cindex glyph, leader repetition (@code{lc})
7545 Declare the @dfn{leader repetition character}.@footnote{@dfn{Leader
7546 repetition character} is a misnomer since it is an output glyph.}
7547 Without an argument, leaders act the same as tabs (i.e., using
7548 whitespace for filling).  @code{gtroff}'s start-up value is a dot
7549 (@samp{.}).  The value of the leader repetition character is associated
7550 with the current environment (@pxref{Environments}).
7551 @endDefreq
7553 @cindex table of contents
7554 @cindex contents, table of
7555 For a table of contents, to name an example, tab stops may be defined so
7556 that the section number is one tab stop, the title is the second with
7557 the remaining space being filled with a line of dots, and then the page
7558 number slightly separated from the dots.
7560 @Example
7561 .ds entry 1.1\tFoo\a\t12
7562 .lc .
7563 .ta 1i 5i +.25i
7564 \*[entry]
7565 @endExample
7567 @noindent
7568 This produces
7570 @Example
7571 1.1  Foo..........................................  12
7572 @endExample
7574 @c ---------------------------------------------------------------------
7576 @node Fields,  , Leaders, Tabs and Fields
7577 @subsection Fields
7578 @cindex fields
7580 @cindex field delimiting character (@code{fc})
7581 @cindex delimiting character, for fields (@code{fc})
7582 @cindex character, field delimiting (@code{fc})
7583 @cindex field padding character (@code{fc})
7584 @cindex padding character, for fields (@code{fc})
7585 @cindex character, field padding (@code{fc})
7586 @dfn{Fields} are a more general way of laying out tabular data.  A field
7587 is defined as the data between a pair of @dfn{delimiting characters}.
7588 It contains substrings which are separated by @dfn{padding characters}.
7589 The width of a field is the distance on the @emph{input} line from the
7590 position where the field starts to the next tab stop.  A padding
7591 character inserts stretchable space similar to @TeX{}'s @code{\hss}
7592 command (thus it can even be negative) to make the sum of all substring
7593 lengths plus the stretchable space equal to the field width.  If more
7594 than one padding character is inserted, the available space is evenly
7595 distributed among them.
7597 @Defreq {fc, [@Var{delim-char} [@Var{padding-char}]]}
7598 Define a delimiting and a padding character for fields.  If the latter
7599 is missing, the padding character defaults to a space character.  If
7600 there is no argument at all, the field mechanism is disabled (which is
7601 the default).  Note that contrary to e.g.@: the tab repetition
7602 character, delimiting and padding characters are @emph{not} associated
7603 to the current environment (@pxref{Environments}).
7605 Example:
7607 @Example
7608 .fc # ^
7609 .ta T 3i
7610 #foo^bar^smurf#
7612 #foo^^bar^smurf#
7613 @endExample
7615 @noindent
7616 and here the result:
7618 @Example
7619 foo         bar          smurf
7620 foo            bar       smurf
7621 @endExample
7622 @endDefreq
7625 @c =====================================================================
7627 @node Character Translations, Troff and Nroff Mode, Tabs and Fields, gtroff Reference
7628 @section Character Translations
7629 @cindex character translations
7630 @cindex translations of characters
7632 @cindex control character, changing (@code{cc})
7633 @cindex character, control, changing (@code{cc})
7634 @cindex no-break control character, changing (@code{c2})
7635 @cindex character, no-break control, changing (@code{c2})
7636 @cindex control character, no-break, changing (@code{c2})
7637 The control character (@samp{.}) and the no-break control character
7638 (@samp{'}) can be changed with the @code{cc} and @code{c2} requests,
7639 respectively.
7641 @Defreq {cc, [@Var{c}]}
7642 Set the control character to@tie{}@var{c}.  With no argument the default
7643 control character @samp{.} is restored.  The value of the control
7644 character is associated with the current environment
7645 (@pxref{Environments}).
7646 @endDefreq
7648 @Defreq {c2, [@Var{c}]}
7649 Set the no-break control character to@tie{}@var{c}.  With no argument
7650 the default control character @samp{'} is restored.  The value of the
7651 no-break control character is associated with the current environment
7652 (@pxref{Environments}).
7653 @endDefreq
7655 @xref{Requests}.
7657 @Defreq {eo, }
7658 @cindex disabling @code{\} (@code{eo})
7659 @cindex @code{\}, disabling (@code{eo})
7660 Disable the escape mechanism completely.  After executing this request,
7661 the backslash character @samp{\} no longer starts an escape sequence.
7663 This request can be very helpful in writing macros since it is not
7664 necessary then to double the escape character.  Here an example:
7666 @Example
7667 .\" This is a simplified version of the
7668 .\" .BR request from the man macro package
7670 .de BR
7671 .  ds result \&
7672 .  while (\n[.$] >= 2) \@{\
7673 .    as result \fB\$1\fR\$2
7674 .    shift 2
7675 .  \@}
7676 .  if \n[.$] .as result \fB\$1
7677 \*[result]
7678 .  ft R
7681 @endExample
7682 @endDefreq
7684 @Defreq {ec, [@Var{c}]}
7685 @cindex escape character, changing (@code{ec})
7686 @cindex character, escape, changing (@code{ec})
7687 Set the escape character to@tie{}@var{c}.  With no argument the default
7688 escape character @samp{\} is restored.  It can be also used to re-enable
7689 the escape mechanism after an @code{eo} request.
7691 Note that changing the escape character globally likely breaks macro
7692 packages since @code{gtroff} has no mechanism to `intern' macros, i.e.,
7693 to convert a macro definition into an internal form which is independent
7694 of its representation (@TeX{} has this mechanism).  If a macro is
7695 called, it is executed literally.
7696 @endDefreq
7698 @DefreqList {ecs, }
7699 @DefreqListEnd {ecr, }
7700 The @code{ecs} request saves the current escape character in an internal
7701 register.  Use this request in combination with the @code{ec} request to
7702 temporarily change the escape character.
7704 The @code{ecr} request restores the escape character saved with
7705 @code{ecs}.  Without a previous call to @code{ecs}, this request sets
7706 the escape character to @code{\}.
7707 @endDefreq
7709 @DefescList {\\\\, , , }
7710 @DefescItem {\\e, , , }
7711 @DefescListEnd {\\E, , , }
7712 Print the current escape character (which is the backslash character
7713 @samp{\} by default).
7715 @code{\\} is a `delayed' backslash; more precisely, it is the default
7716 escape character followed by a backslash, which no longer has special
7717 meaning due to the leading escape character.  It is @emph{not} an escape
7718 sequence in the usual sense!  In any unknown escape sequence
7719 @code{\@var{X}} the escape character is ignored and @var{X} is printed.
7720 But if @var{X} is equal to the current escape character, no warning is
7721 emitted.
7723 @cindex @code{\E}, and copy-in mode
7724 @cindex copy-in mode, and @code{\E}
7725 @cindex mode, copy-in, and @code{\E}
7726 As a consequence, only at top-level or in a diversion a backslash glyph
7727 is printed; in copy-in mode, it expands to a single backslash which then
7728 combines with the following character to an escape sequence.
7730 The @code{\E} escape differs from @code{\e} by printing an escape
7731 character that is not interpreted in copy mode.  Use this to define
7732 strings with escapes that work when used in copy mode (for example, as a
7733 macro argument).  The following example defines strings to begin and end
7734 a superscript:
7736 @Example
7737 .ds @{ \v'-.3m'\s'\En[.s]*60/100'
7738 .ds @} \s0\v'.3m'
7739 @endExample
7741 Another example to demonstrate the differences between the various
7742 escape sequences, using a strange escape character, @samp{-}.
7744 @Example
7745 .ec -
7746 .de xxx
7747 --A'123'
7749 .xxx
7750     @result{} -A'foo'
7751 @endExample
7753 @noindent
7754 The result is surprising for most users, expecting @samp{1} since
7755 @samp{foo} is a valid identifier.  What has happened?  As mentioned
7756 above, the leading escape character makes the following character
7757 ordinary.  Written with the default escape character the sequence
7758 @samp{--} becomes @samp{\-} -- this is the minus sign.
7760 If the escape character followed by itself is a valid escape sequence,
7761 only @code{\E} yields the expected result:
7763 @Example
7764 .ec -
7765 .de xxx
7766 -EA'123'
7768 .xxx
7769     @result{} 1
7770 @endExample
7771 @endDefesc
7773 @Defesc {\\., , , }
7774 Similar to @code{\\}, the sequence @code{\.} isn't a real escape
7775 sequence.  As before, a warning message is suppressed if the escape
7776 character is followed by a dot, and the dot itself is printed.
7778 @Example
7779 .de foo
7780 .  nop foo
7782 .  de bar
7783 .    nop bar
7784 \\..
7787 .foo
7788 .bar
7789     @result{} foo bar
7790 @endExample
7792 @noindent
7793 The first backslash is consumed while the macro is read, and the second
7794 is swallowed while exexuting macro @code{foo}.
7795 @endDefesc
7797 A @dfn{translation} is a mapping of an input character to an output
7798 glyph.  The mapping occurs at output time, i.e., the input character
7799 gets assigned the metric information of the mapped output character
7800 right before input tokens are converted to nodes (@pxref{Gtroff
7801 Internals}, for more on this process).
7803 @DefreqList {tr, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
7804 @DefreqListEnd {trin, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
7805 Translate character @var{a} to glyph@tie{}@var{b}, character @var{c} to
7806 glyph@tie{}@var{d}, etc.  If there is an odd number of arguments, the
7807 last one is translated to an unstretchable space (@w{@samp{\ }}).
7809 The @code{trin} request is identical to @code{tr}, but when you unformat
7810 a diversion with @code{asciify} it ignores the translation.
7811 @xref{Diversions}, for details about the @code{asciify} request.
7813 Some notes:
7815 @itemize @bullet
7816 @item
7817 @cindex @code{\(}, and translations
7818 @cindex @code{\[}, and translations
7819 @cindex @code{\'}, and translations
7820 @cindex @code{\`}, and translations
7821 @cindex @code{\-}, and translations
7822 @cindex @code{\_}, and translations
7823 @cindex @code{\C}, and translations
7824 @cindex @code{\N}, and translations
7825 @cindex @code{char} request, and translations
7826 @cindex special characters
7827 @cindex character, special
7828 @cindex numbered glyph (@code{\N})
7829 @cindex glyph, numbered (@code{\N})
7830 Special characters (@code{\(@var{xx}}, @code{\[@var{xxx}]},
7831 @code{\C'@var{xxx}'}, @code{\'}, @code{\`}, @code{\-}, @code{\_}),
7832 glyphs defined with the @code{char} request, and numbered glyphs
7833 (@code{\N'@var{xxx}'}) can be translated also.
7835 @item
7836 @cindex @code{\e}, and translations
7837 The @code{\e} escape can be translated also.
7839 @item
7840 @cindex @code{\%}, and translations
7841 @cindex @code{\~}, and translations
7842 Characters can be mapped onto the @code{\%} and @code{\~} escapes (but
7843 @code{\%} and @code{\~} can't be mapped onto another glyph).
7845 @item
7846 @cindex backspace character, and translations
7847 @cindex character, backspace, and translations
7848 @cindex leader character, and translations
7849 @cindex character, leader, and translations
7850 @cindex newline character, and translations
7851 @cindex character, newline, and translations
7852 @cindex tab character, and translations
7853 @cindex character, tab, and translations
7854 @cindex @code{\a}, and translations
7855 @cindex @code{\t}, and translations
7856 The following characters can't be translated: space (with one exception,
7857 see below), backspace, newline, leader (and @code{\a}), tab (and
7858 @code{\t}).
7860 @item
7861 @cindex @code{shc} request, and translations
7862 Translations are not considered for finding the soft hyphen character
7863 set with the @code{shc} request.
7865 @item
7866 @cindex @code{\&}, and translations
7867 The pair @samp{@var{c}\&} (this is an arbitrary character@tie{}@var{c}
7868 followed by the zero width space character) maps this character to
7869 nothing.
7871 @Example
7872 .tr a\&
7873 foo bar
7874     @result{} foo br
7875 @endExample
7877 @noindent
7878 It is even possible to map the space character to nothing:
7880 @Example
7881 .tr aa \&
7882 foo bar
7883     @result{} foobar
7884 @endExample
7886 @noindent
7887 As shown in the example, the space character can't be the first
7888 character/glyph pair as an argument of @code{tr}.  Additionally, it is
7889 not possible to map the space character to any other glyph; requests
7890 like @w{@samp{.tr aa x}} undo @w{@samp{.tr aa \&}} instead.
7892 If justification is active, lines are justified in spite of the `empty'
7893 space character (but there is no minimal distance, i.e.@: the space
7894 character, between words).
7896 @item
7897 After an output glyph has been constructed (this happens at the moment
7898 immediately before the glyph is appended to an output glyph list, either
7899 by direct output, in a macro, diversion, or string), it is no longer
7900 affected by @code{tr}.
7902 @item
7903 Translating character to glyphs where one of them or both are undefined
7904 is possible also; @code{tr} does not check whether the entities in its
7905 argument do exist.
7907 @xref{Gtroff Internals}.
7909 @item
7910 @code{troff} no longer has a hard-coded dependency on @w{Latin-1}; all
7911 @code{char@var{XXX}} entities have been removed from the font
7912 description files.  This has a notable consequence which shows up in
7913 warnings like @code{can't find character with input code @var{XXX}} if
7914 the @code{tr} request isn't handled properly.
7916 Consider the following translation:
7918 @Example
7919 .tr Ã©Ã‰
7920 @endExample
7922 @noindent
7923 This maps input character @code{é} onto glyph @code{É}, which is
7924 identical to glyph @code{char201}.  But this glyph intentionally doesn't
7925 exist!  Instead, @code{\[char201]} is treated as an input character
7926 entity and is by default mapped onto @code{\['E]}, and @code{gtroff}
7927 doesn't handle translations of translations.
7929 The right way to write the above translation is
7931 @Example
7932 .tr Ã©\['E]
7933 @endExample
7935 @noindent
7936 In other words, the first argument of @code{tr} should be an input
7937 character or entity, and the second one a glyph entity.
7939 @item
7940 Without an argument, the @code{tr} request is ignored.
7941 @end itemize
7942 @endDefreq
7944 @Defreq {trnt, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
7945 @cindex @code{\!}, and @code{trnt}
7946 @code{trnt} is the same as the @code{tr} request except that the
7947 translations do not apply to text that is transparently throughput into
7948 a diversion with @code{\!}.  @xref{Diversions}, for more information.
7950 For example,
7952 @Example
7953 .tr ab
7954 .di x
7955 \!.tm a
7958 @endExample
7960 @noindent
7961 prints @samp{b} to the standard error stream; if @code{trnt} is used
7962 instead of @code{tr} it prints @samp{a}.
7963 @endDefreq
7966 @c =====================================================================
7968 @node Troff and Nroff Mode, Line Layout, Character Translations, gtroff Reference
7969 @section Troff and Nroff Mode
7970 @cindex troff mode
7971 @cindex mode, troff
7972 @cindex nroff mode
7973 @cindex mode, nroff
7975 Originally, @code{nroff} and @code{troff} were two separate programs,
7976 the former for TTY output, the latter for everything else.  With GNU
7977 @code{troff}, both programs are merged into one executable, sending its
7978 output to a device driver (@code{grotty} for TTY devices, @code{grops}
7979 for @sc{PostScript}, etc.)@: which interprets the intermediate output of
7980 @code{gtroff}.  For @acronym{UNIX} @code{troff} it makes sense to talk
7981 about @dfn{Nroff mode} and @dfn{Troff mode} since the differences are
7982 hardcoded.  For GNU @code{troff}, this distinction is not appropriate
7983 because @code{gtroff} simply takes the information given in the font
7984 files for a particular device without handling requests specially if a
7985 TTY output device is used.
7987 Usually, a macro package can be used with all output devices.
7988 Nevertheless, it is sometimes necessary to make a distinction between
7989 TTY and non-TTY devices: @code{gtroff} provides two built-in conditions
7990 @samp{n} and @samp{t} for the @code{if}, @code{ie}, and @code{while}
7991 requests to decide whether @code{gtroff} shall behave like @code{nroff}
7992 or like @code{troff}.
7994 @Defreq {troff, }
7995 @pindex troffrc
7996 @pindex troffrc-end
7997 Make the @samp{t} built-in condition true (and the @samp{n} built-in
7998 condition false) for @code{if}, @code{ie}, and @code{while} conditional
7999 requests.  This is the default if @code{gtroff} (@emph{not}
8000 @code{groff}) is started with the @option{-R} switch to avoid loading of
8001 the start-up files @file{troffrc} and @file{troffrc-end}.  Without
8002 @option{-R}, @code{gtroff} stays in troff mode if the output device is
8003 not a TTY (e.g.@: `ps').
8004 @endDefreq
8006 @Defreq {nroff, }
8007 @pindex tty.tmac
8008 Make the @samp{n} built-in condition true (and the @samp{t} built-in
8009 condition false) for @code{if}, @code{ie}, and @code{while} conditional
8010 requests.  This is the default if @code{gtroff} uses a TTY output
8011 device; the code for switching to nroff mode is in the file
8012 @file{tty.tmac} which is loaded by the start-up file @code{troffrc}.
8013 @endDefreq
8015 @xref{Conditionals and Loops}, for more details on built-in conditions.
8018 @c =====================================================================
8020 @node Line Layout, Line Control, Troff and Nroff Mode, gtroff Reference
8021 @section Line Layout
8022 @cindex line layout
8023 @cindex layout, line
8025 @cindex dimensions, line
8026 @cindex line dimensions
8027 The following drawing shows the dimensions which @code{gtroff} uses for
8028 placing a line of output onto the page.  They are labeled with the
8029 request which manipulates each dimension.
8031 @Example
8032      -->| in |<--
8033         |<-----------ll------------>|
8034    +----+----+----------------------+----+
8035    |    :    :                      :    |
8036    +----+----+----------------------+----+
8037 -->| po |<--
8038    |<--------paper width---------------->|
8039 @endExample
8041 @noindent
8042 These dimensions are:
8044 @ftable @code
8045 @item po
8046 @cindex left margin (@code{po})
8047 @cindex margin, left (@code{po})
8048 @cindex page offset (@code{po})
8049 @cindex offset, page (@code{po})
8050 @dfn{Page offset} -- this is the leftmost position of text on the final
8051 output, defining the @dfn{left margin}.
8053 @item in
8054 @cindex indentation (@code{in})
8055 @cindex line indentation (@code{in})
8056 @dfn{Indentation} -- this is the distance from the left margin where
8057 text is printed.
8059 @item ll
8060 @cindex line length (@code{ll})
8061 @cindex length of line (@code{ll})
8062 @dfn{Line length} -- this is the distance from the left margin to right
8063 margin.
8064 @end ftable
8066 A simple demonstration:
8068 @Example
8069 .ll 3i
8070 This is text without indentation.
8071 The line length has been set to 3\~inch.
8072 .in +.5i
8073 .ll -.5i
8074 Now the left and right margins are both increased.
8077 Calling .in and .ll without parameters restore
8078 the previous values.
8079 @endExample
8081 Result:
8083 @Example
8084 This  is text without indenta-
8085 tion.   The  line  length  has
8086 been set to 3 inch.
8087      Now   the  left  and
8088      right  margins   are
8089      both increased.
8090 Calling  .in  and  .ll without
8091 parameters restore the  previ-
8092 ous values.
8093 @endExample
8095 @DefreqList {po, [@Var{offset}]}
8096 @DefreqItem {po, @t{+}@Var{offset}}
8097 @DefreqItem {po, @t{-}@Var{offset}}
8098 @DefregListEnd {.o}
8099 @pindex troffrc
8100 Set horizontal page offset to @var{offset} (or increment or decrement
8101 the current value by @var{offset}).  Note that this request does not
8102 cause a break, so changing the page offset in the middle of text being
8103 filled may not yield the expected result.  The initial value is
8104 1@dmn{i}.  For TTY output devices, it is set to 0 in the startup file
8105 @file{troffrc}; the default scaling indicator is @samp{m} (and not
8106 @samp{v} as incorrectly documented in the original @acronym{UNIX} troff
8107 manual).
8109 The current page offset can be found in the read-only number register
8110 @samp{.o}.
8112 If @code{po} is called without an argument, the page offset is reset to
8113 the previous value before the last call to @code{po}.
8115 @Example
8116 .po 3i
8117 \n[.o]
8118     @result{} 720
8119 .po -1i
8120 \n[.o]
8121     @result{} 480
8123 \n[.o]
8124     @result{} 720
8125 @endExample
8126 @endDefreq
8128 @DefreqList {in, [@Var{indent}]}
8129 @DefreqItem {in, @t{+}@Var{indent}}
8130 @DefreqItem {in, @t{-}@Var{indent}}
8131 @DefregListEnd {.i}
8132 Set indentation to @var{indent} (or increment or decrement the current
8133 value by @var{indent}).  This request causes a break.  Initially, there
8134 is no indentation.
8136 If @code{in} is called without an argument, the indentation is reset to
8137 the previous value before the last call to @code{in}.  The default
8138 scaling indicator is @samp{m}.
8140 The indentation is associated with the current environment
8141 (@pxref{Environments}).
8143 If a negative indentation value is specified (which is not allowed),
8144 @code{gtroff} emits a warning of type @samp{range} and sets the
8145 indentation to zero.
8147 The effect of @code{in} is delayed until a partially collected line (if
8148 it exists) is output.  A temporary indentation value is reset to zero
8149 also.
8151 The current indentation (as set by @code{in}) can be found in the
8152 read-only number register @samp{.i}.
8153 @endDefreq
8155 @DefreqList {ti, offset}
8156 @DefreqItem {ti, @t{+}@Var{offset}}
8157 @DefreqItem {ti, @t{-}@Var{offset}}
8158 @DefregListEnd {.in}
8159 Temporarily indent the next output line by @var{offset}.  If an
8160 increment or decrement value is specified, adjust the temporary
8161 indentation relative to the value set by the @code{in} request.
8163 This request causes a break; its value is associated with the current
8164 environment (@pxref{Environments}).  The default scaling indicator is
8165 @samp{m}.  A call of @code{ti} without an argument is ignored.
8167 If the total indentation value is negative (which is not allowed),
8168 @code{gtroff} emits a warning of type @samp{range} and sets the
8169 temporary indentation to zero.  `Total indentation' is either
8170 @var{offset} if specified as an absolute value, or the temporary plus
8171 normal indentation, if @var{offset} is given as a relative value.
8173 The effect of @code{ti} is delayed until a partially collected line (if
8174 it exists) is output.
8176 The read-only number register @code{.in} is the indentation that applies
8177 to the current output line.
8179 The difference between @code{.i} and @code{.in} is that the latter takes
8180 into account whether a partially collected line still uses the old
8181 indentation value or a temporary indentation value is active.
8182 @endDefreq
8184 @DefreqList {ll, [@Var{length}]}
8185 @DefreqItem {ll, @t{+}@Var{length}}
8186 @DefreqItem {ll, @t{-}@Var{length}}
8187 @DefregItem {.l}
8188 @DefregListEnd {.ll}
8189 Set the line length to @var{length} (or increment or decrement the
8190 current value by @var{length}).  Initially, the line length is set to
8191 6.5@dmn{i}.  The effect of @code{ll} is delayed until a partially
8192 collected line (if it exists) is output.  The default scaling indicator
8193 is @samp{m}.
8195 If @code{ll} is called without an argument, the line length is reset to
8196 the previous value before the last call to @code{ll}.  If a negative
8197 line length is specified (which is not allowed), @code{gtroff} emits a
8198 warning of type @samp{range} and sets the line length to zero.
8200 The line length is associated with the current environment
8201 (@pxref{Environments}).
8203 @cindex line length register (@code{.l})
8204 The current line length (as set by @code{ll}) can be found in the
8205 read-only number register @samp{.l}.  The read-only number register
8206 @code{.ll} is the line length that applies to the current output line.
8208 Similar to @code{.i} and @code{.in}, the difference between @code{.l}
8209 and @code{.ll} is that the latter takes into account whether a partially
8210 collected line still uses the old line length value.
8211 @endDefreq
8214 @c =====================================================================
8216 @node Line Control, Page Layout, Line Layout, gtroff Reference
8217 @section Line Control
8218 @cindex line control
8219 @cindex control, line
8221 It is important to understand how @code{gtroff} handles input and output
8222 lines.
8224 Many escapes use positioning relative to the input line.  For example,
8225 this
8227 @Example
8228 This is a \h'|1.2i'test.
8230 This is a
8231 \h'|1.2i'test.
8232 @endExample
8234 @noindent
8235 produces
8237 @Example
8238 This is a   test.
8240 This is a             test.
8241 @endExample
8243 The main usage of this feature is to define macros which act exactly at
8244 the place where called.
8246 @Example
8247 .\" A simple macro to underline a word
8248 .de underline
8249 .  nop \\$1\l'|0\[ul]'
8251 @endExample
8253 @noindent
8254 In the above example, @samp{|0} specifies a negative distance from the
8255 current position (at the end of the just emitted argument @code{\$1})
8256 back to the beginning of the input line.  Thus, the @samp{\l} escape
8257 draws a line from right to left.
8259 @cindex input line continuation (@code{\})
8260 @cindex line, input, continuation (@code{\})
8261 @cindex continuation, input line (@code{\})
8262 @cindex output line, continuation (@code{\c})
8263 @cindex line, output, continuation (@code{\c})
8264 @cindex continuation, output line (@code{\c})
8265 @cindex interrupted line
8266 @cindex line, interrupted
8267 @code{gtroff} makes a difference between input and output line
8268 continuation; the latter is also called @dfn{interrupting} a line.
8270 @DefescList {\\@key{RET}, , ,}
8271 @DefescItem {\\c, , ,}
8272 @DefregListEnd {.int}
8273 Continue a line.  @code{\@key{RET}} (this is a backslash at the end of a
8274 line immediately followed by a newline) works on the input level,
8275 suppressing the effects of the following newline in the input.
8277 @Example
8278 This is a \
8279 .test
8280     @result{} This is a .test
8281 @endExample
8283 The @samp{|} operator is also affected.
8285 @cindex @code{\R}, after @code{\c}
8286 @code{\c} works on the output level.  Anything after this escape on the
8287 same line is ignored, except @code{\R} which works as usual.  Anything
8288 before @code{\c} on the same line is appended to the current partial
8289 output line.  The next non-command line after an interrupted line counts
8290 as a new input line.
8292 The visual results depend on whether no-fill mode is active.
8294 @itemize @bullet
8295 @item
8296 @cindex @code{\c}, and no-fill mode
8297 @cindex no-fill mode, and @code{\c}
8298 @cindex mode, no-fill, and @code{\c}
8299 If no-fill mode is active (using the @code{nf} request), the next input
8300 text line after @code{\c} is handled as a continuation of the same input
8301 text line.
8303 @Example
8305 This is a \c
8306 test.
8307     @result{} This is a test.
8308 @endExample
8310 @item
8311 @cindex @code{\c}, and fill mode
8312 @cindex fill mode, and @code{\c}
8313 @cindex mode, fill, and @code{\c}
8314 If fill mode is active (using the @code{fi} request), a word interrupted
8315 with @code{\c} is continued with the text on the next input text line,
8316 without an intervening space.
8318 @Example
8319 This is a te\c
8321     @result{} This is a test.
8322 @endExample
8323 @end itemize
8325 Note that an intervening control line which causes a break is stronger
8326 than @code{\c}, flushing out the current partial line in the usual way.
8328 @cindex interrupted line register (@code{.int})
8329 The @code{.int} register contains a positive value if the last output
8330 line was interrupted with @code{\c}; this is associated with the current
8331 environment (@pxref{Environments}).
8332 @endDefesc
8335 @c =====================================================================
8337 @node Page Layout, Page Control, Line Control, gtroff Reference
8338 @section Page Layout
8339 @cindex page layout
8340 @cindex layout, page
8342 @code{gtroff} provides some very primitive operations for controlling
8343 page layout.
8345 @DefreqList {pl, [@Var{length}]}
8346 @DefreqItem {pl, @t{+}@Var{length}}
8347 @DefreqItem {pl, @t{-}@Var{length}}
8348 @DefregListEnd {.p}
8349 @cindex page length (@code{pl})
8350 @cindex length of page (@code{pl})
8351 Set the @dfn{page length} to @var{length} (or increment or decrement the
8352 current value by @var{length}).  This is the length of the physical
8353 output page.  The default scaling indicator is @samp{v}.
8355 @cindex page length register (@code{.p})
8356 The current setting can be found in the read-only number register
8357 @samp{.p}.
8359 @cindex top margin
8360 @cindex margin, top
8361 @cindex bottom margin
8362 @cindex margin, bottom
8363 Note that this only specifies the size of the page, not the top and
8364 bottom margins.  Those are not set by @code{gtroff} directly.
8365 @xref{Traps}, for further information on how to do this.
8367 Negative @code{pl} values are possible also, but not very useful: No
8368 trap is sprung, and each line is output on a single page (thus
8369 suppressing all vertical spacing).
8371 If no argument or an invalid argument is given, @code{pl} sets the page
8372 length to 11@dmn{i}.
8373 @endDefreq
8375 @cindex headers
8376 @cindex footers
8377 @cindex titles
8378 @code{gtroff} provides several operations which help in setting up top
8379 and bottom titles (or headers and footers).
8381 @Defreq {tl, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}}
8382 @cindex title line (@code{tl})
8383 @cindex three-part title (@code{tl})
8384 @cindex page number character (@code{%})
8385 Print a @dfn{title line}.  It consists of three parts: a left justified
8386 portion, a centered portion, and a right justified portion.  The
8387 argument separator @samp{'} can be replaced with any character not
8388 occurring in the title line.  The @samp{%} character is replaced with
8389 the current page number.  This character can be changed with the
8390 @code{pc} request (see below).
8392 Without argument, @code{tl} is ignored.
8394 Some notes:
8396 @itemize @bullet
8397 @item
8398 A title line is not restricted to the top or bottom of a page.
8400 @item
8401 @code{tl} prints the title line immediately, ignoring a partially filled
8402 line (which stays untouched).
8404 @item
8405 It is not an error to omit closing delimiters.  For example,
8406 @w{@samp{.tl /foo}} is equivalent to @w{@samp{.tl /foo///}}: It prints a
8407 title line with the left justified word @samp{foo}; the centered and
8408 right justfied parts are empty.
8410 @item
8411 @code{tl} accepts the same parameter delimiting characters as the
8412 @code{\A} escape; see @ref{Escapes}.
8413 @end itemize
8414 @endDefreq
8416 @DefreqList {lt, [@Var{length}]}
8417 @DefreqItem {lt, @t{+}@Var{length}}
8418 @DefreqItem {lt, @t{-}@Var{length}}
8419 @DefregListEnd {.lt}
8420 @cindex length of title line (@code{lt})
8421 @cindex title line, length (@code{lt})
8422 @cindex title line length register (@code{.lt})
8423 The title line is printed using its own line length, which is specified
8424 (or incremented or decremented) with the @code{lt} request.  Initially,
8425 the title line length is set to 6.5@dmn{i}.  If a negative line length
8426 is specified (which is not allowed), @code{gtroff} emits a warning of
8427 type @samp{range} and sets the title line length to zero.  The default
8428 scaling indicator is @samp{m}.  If @code{lt} is called without an
8429 argument, the title length is reset to the previous value before the
8430 last call to @code{lt}.
8432 The current setting of this is available in the @code{.lt} read-only
8433 number register; it is associated with the current environment
8434 (@pxref{Environments}).
8435 @endDefreq
8437 @DefreqList {pn, page}
8438 @DefreqItem {pn, @t{+}@Var{page}}
8439 @DefreqItem {pn, @t{-}@Var{page}}
8440 @DefregListEnd {.pn}
8441 @cindex page number (@code{pn})
8442 @cindex number, page (@code{pn})
8443 Change (increase or decrease) the page number of the @emph{next} page.
8444 The only argument is the page number; the request is ignored without a
8445 parameter.
8447 The read-only number register @code{.pn} contains the number of the next
8448 page: either the value set by a @code{pn} request, or the number of the
8449 current page plus@tie{}1.
8450 @endDefreq
8452 @Defreq {pc, [@Var{char}]}
8453 @cindex changing the page number character (@code{pc})
8454 @cindex page number character, changing (@code{pc})
8455 @vindex %
8456 Change the page number character (used by the @code{tl} request) to a
8457 different character.  With no argument, this mechanism is disabled.
8458 Note that this doesn't affect the number register@tie{}@code{%}.
8459 @endDefreq
8461 @xref{Traps}.
8464 @c =====================================================================
8466 @node Page Control, Fonts and Symbols, Page Layout, gtroff Reference
8467 @section Page Control
8468 @cindex page control
8469 @cindex control, page
8471 @DefreqList {bp, [@Var{page}]}
8472 @DefreqItem {bp, @t{+}@Var{page}}
8473 @DefreqItem {bp, @t{-}@Var{page}}
8474 @DefregListEnd {%}
8475 @cindex new page (@code{bp})
8476 @cindex page, new (@code{bp})
8477 Stop processing the current page and move to the next page.  This
8478 request causes a break.  It can also take an argument to set (increase,
8479 decrease) the page number of the next page (which actually becomes the
8480 current page after @code{bp} has finished).  The difference between
8481 @code{bp} and @code{pn} is that @code{pn} does not cause a break or
8482 actually eject a page.  @xref{Page Layout}.
8484 @Example
8485 .de newpage                         \" define macro
8486 'bp                                 \" begin page
8487 'sp .5i                             \" vertical space
8488 .tl 'left top'center top'right top' \" title
8489 'sp .3i                             \" vertical space
8490 ..                                  \" end macro
8491 @endExample
8493 @cindex @code{bp} request, and top-level diversion
8494 @cindex top-level diversion, and @code{bp}
8495 @cindex diversion, top-level, and @code{bp}
8496 @code{bp} has no effect if not called within the top-level diversion
8497 (@pxref{Diversions}).
8499 @cindex page number register (@code{%})
8500 @cindex current page number (@code{%})
8501 The read-write register@tie{}@code{%} holds the current page number.
8503 The number register @code{.pe} is set to@tie{}1 while @code{bp} is
8504 active.  @xref{Page Location Traps}.
8505 @endDefreq
8507 @Defreq {ne, [@Var{space}]}
8508 @cindex orphan lines, preventing with @code{ne}
8509 @cindex conditional page break (@code{ne})
8510 @cindex page break, conditional (@code{ne})
8511 It is often necessary to force a certain amount of space before a new
8512 page occurs.  This is most useful to make sure that there is not a
8513 single @dfn{orphan} line left at the bottom of a page.  The @code{ne}
8514 request ensures that there is a certain distance, specified by the first
8515 argument, before the next page is triggered (see @ref{Traps}, for
8516 further information).  The default scaling indicator for @code{ne} is
8517 @samp{v}; the default value of @var{space} is@tie{}1@dmn{v} if no
8518 argument is given.
8520 For example, to make sure that no fewer than 2@tie{}lines get orphaned,
8521 do the following before each paragraph:
8523 @Example
8524 .ne 2
8525 text text text
8526 @endExample
8528 @code{ne} then automatically causes a page break if there is space for
8529 one line only.
8530 @endDefreq
8532 @DefreqList {sv, [@Var{space}]}
8533 @DefreqListEnd {os, }
8534 @cindex @code{ne} request, comparison with @code{sv}
8535 @code{sv} is similar to the @code{ne} request; it reserves the specified
8536 amount of vertical space.  If the desired amount of space exists before
8537 the next trap (or the bottom page boundary if no trap is set), the space
8538 is output immediately (ignoring a partially filled line which stays
8539 untouched).  If there is not enough space, it is stored for later output
8540 via the @code{os} request.  The default value is@tie{}1@dmn{v} if no
8541 argument is given; the default scaling indicator is @samp{v}.
8543 @cindex @code{sv} request, and no-space mode
8544 @cindex @code{os} request, and no-space mode
8545 Both @code{sv} and @code{os} ignore no-space mode.  While the @code{sv}
8546 request allows negative values for @var{space}, @code{os} ignores them.
8547 @endDefreq
8549 @Defreg {nl}
8550 @cindex current vertical position (@code{nl})
8551 @cindex vertical position, current (@code{nl})
8552 @cindex position, vertical, current (@code{nl})
8553 This register contains the current vertical position.  If the vertical
8554 position is zero and the top of page transition hasn't happened yet,
8555 @code{nl} is set to negative value.  @code{gtroff} itself does this at
8556 the very beginning of a document before anything has been printed, but
8557 the main usage is to plant a header trap on a page if this page has
8558 already started.
8560 Consider the following:
8562 @Example
8563 .de xxx
8564 .  sp
8565 .  tl ''Header''
8566 .  sp
8569 First page.
8571 .wh 0 xxx
8572 .nr nl (-1)
8573 Second page.
8574 @endExample
8576 @noindent
8577 Result:
8579 @Example
8580 First page.
8584                              Header
8586 Second page.
8589 @endExample
8591 @noindent
8592 Without resetting @code{nl} to a negative value, the just planted trap
8593 would be active beginning with the @emph{next} page, not the current
8594 one.
8596 @xref{Diversions}, for a comparison with the @code{.h} and @code{.d}
8597 registers.
8598 @endDefreg
8601 @c =====================================================================
8603 @node Fonts and Symbols, Sizes, Page Control, gtroff Reference
8604 @section Fonts and Symbols
8605 @cindex fonts
8607 @code{gtroff} can switch fonts at any point in the text.
8609 The basic set of fonts is @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
8610 These are Times Roman, Italic, Bold, and Bold Italic.  For non-TTY
8611 devices, there is also at least one symbol font which contains various
8612 special symbols (Greek, mathematics).
8614 @menu
8615 * Changing Fonts::
8616 * Font Families::
8617 * Font Positions::
8618 * Using Symbols::
8619 * Special Fonts::
8620 * Artificial Fonts::
8621 * Ligatures and Kerning::
8622 @end menu
8624 @c ---------------------------------------------------------------------
8626 @node Changing Fonts, Font Families, Fonts and Symbols, Fonts and Symbols
8627 @subsection Changing Fonts
8628 @cindex fonts
8630 @DefreqList {ft, [@Var{font}]}
8631 @DefescItem {\\f, , f, }
8632 @DefescItem {\\f, @Lparen{}, fn, }
8633 @DefescItem {\\f, @Lbrack{}, font, @Rbrack{}}
8634 @DefregListEnd {.sty}
8635 @cindex changing fonts (@code{ft}, @code{\f})
8636 @cindex fonts, changing (@code{ft}, @code{\f})
8637 @cindex @code{sty} request, and changing fonts
8638 @cindex @code{fam} request, and changing fonts
8639 @cindex @code{\F}, and changing fonts
8640 @kindex styles
8641 @kindex family
8642 @pindex DESC
8643 The @code{ft} request and the @code{\f} escape change the current font
8644 to @var{font} (one-character name@tie{}@var{f}, two-character name
8645 @var{fn}).
8647 If @var{font} is a style name (as set with the @code{sty} request or
8648 with the @code{styles} command in the @file{DESC} file), use it within
8649 the current font family (as set with the @code{fam} request, @code{\F}
8650 escape, or with the @code{family} command in the @file{DESC} file).
8652 It is not possible to switch to a font with the name @samp{DESC}
8653 (whereas this name could be used as a style name; however, this is not
8654 recommended).
8656 @cindex previous font (@code{ft}, @code{\f[]}, @code{\fP})
8657 @cindex font, previous (@code{ft}, @code{\f[]}, @code{\fP})
8658 With no argument or using @samp{P} as an argument, @code{.ft} switches
8659 to the previous font.  Use @code{\f[]} to do this with the escape.  The
8660 old syntax forms @code{\fP} or @code{\f[P]} are also supported.
8662 Fonts are generally specified as upper-case strings, which are usually
8663 1@tie{}to 4 characters representing an abbreviation or acronym of the
8664 font name.  This is no limitation, just a convention.
8666 The example below produces two identical lines.
8668 @Example
8669 eggs, bacon,
8670 .ft B
8671 spam
8673 and sausage.
8675 eggs, bacon, \fBspam\fP and sausage.
8676 @endExample
8678 Note that @code{\f} doesn't produce an input token in @code{gtroff}.  As
8679 a consequence, it can be used in requests like @code{mc} (which expects
8680 a single character as an argument) to change the font on the fly:
8682 @Example
8683 .mc \f[I]x\f[]
8684 @endExample
8686 The current style name is available in the read-only number register
8687 @samp{.sty} (this is a string-valued register); if the current font
8688 isn't a style, the empty string is returned.  It is associated with the
8689 current environment.
8691 @xref{Font Positions}, for an alternative syntax.
8692 @endDefreq
8694 @Defreq {ftr, f [@Var{g}]}
8695 @cindex font translation (@code{ftr})
8696 @cindex @code{ft} request, and font translations
8697 @cindex @code{ul} request, and font translations
8698 @cindex @code{bd} request, and font translations
8699 @cindex @code{\f}, and font translations
8700 @cindex @code{cs} request, and font translations
8701 @cindex @code{tkf} request, and font translations
8702 @cindex @code{special} request, and font translations
8703 @cindex @code{fspecial} request, and font translations
8704 @cindex @code{fp} request, and font translations
8705 @cindex @code{sty} request, and font translations
8706 @cindex @code{if} request, and font translations
8707 @cindex @code{ie} request, and font translations
8708 @cindex @code{while} request, and font translations
8709 Translate font@tie{}@var{f} to font@tie{}@var{g}.  Whenever a font
8710 named@tie{}@var{f} is referred to in a @code{\f} escape sequence, in the
8711 @code{F} and @code{S} conditional operators, or in the @code{ft},
8712 @code{ul}, @code{bd}, @code{cs}, @code{tkf}, @code{special},
8713 @code{fspecial}, @code{fp}, or @code{sty} requests, font@tie{}@var{g} is
8714 used.  If @var{g} is missing or equal to@tie{}@var{f} the translation is
8715 undone.
8717 Note that it is not possible to chain font translations.  Example:
8719 @Example
8720 .ftr XXX TR
8721 .ftr XXX YYY
8722 .ft XXX
8723     @result{} warning: can't find font `XXX'
8724 @endExample
8725 @endDefreq
8727 @DefreqList {fzoom, f [@Var{zoom}]}
8728 @DefregListEnd {.zoom}
8729 @cindex magnification of a font (@code{fzoom})
8730 @cindex font, magnification (@code{fzoom})
8731 @cindex zoom factor of a font (@code{fzoom})
8732 @cindex factor, zoom, of a font (@code{fzoom})
8733 @cindex font, zoom factor (@code{fzoom})
8734 @cindex optical size of a font
8735 @cindex font, optical size
8736 @cindex size, optical, of a font
8737 Set magnification of font@tie{}@var{f} to factor @var{zoom}, which must
8738 be a non-negative integer multiple of 1/1000th.  This request is useful
8739 to adjust the optical size of a font in relation to the others.  In the
8740 example below, font @code{CR} is magnified by 10% (the zoom factor is
8741 thus 1.1).
8743 @Example
8744 .fam P
8745 .fzoom CR 1100
8746 .ps 12
8747 Palatino and \f[CR]Courier\f[]
8748 @endExample
8750 A missing or zero value of @var{zoom} is the same as a value of 1000,
8751 which means no magnification.  @var{f}@tie{}must be a real font name,
8752 not a style.
8754 Note that the magnification of a font is completely transparent to
8755 troff; a change of the zoom factor doesn't cause any effect except that
8756 the dimensions of glyphs, (word) spaces, kerns, etc., of the affected
8757 font are adjusted accordingly.
8759 The zoom factor of the current font is available in the read-only number
8760 register @samp{.zoom}, in multiples of 1/1000th.  It returns zero if
8761 there is no magnification.
8762 @endDefreq
8764 @c ---------------------------------------------------------------------
8766 @node Font Families, Font Positions, Changing Fonts, Fonts and Symbols
8767 @subsection Font Families
8768 @cindex font families
8769 @cindex families, font
8770 @cindex font styles
8771 @cindex styles, font
8773 Due to the variety of fonts available, @code{gtroff} has added the
8774 concept of @dfn{font families} and @dfn{font styles}.  The fonts are
8775 specified as the concatenation of the font family and style.  Specifying
8776 a font without the family part causes @code{gtroff} to use that style of
8777 the current family.
8779 @cindex PostScript fonts
8780 @cindex fonts, PostScript
8781 Currently, fonts for the devices @option{-Tps}, @option{-Tdvi},
8782 @option{-Tlj4}, @option{-Tlbp}, and the X11 fonts are set up to this
8783 mechanism.  By default, @code{gtroff} uses the Times family with the
8784 four styles @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
8786 This way, it is possible to use the basic four fonts and to select a
8787 different font family on the command line (@pxref{Groff Options}).
8789 @DefreqList {fam, [@Var{family}]}
8790 @DefregItem {.fam}
8791 @DefescItem {\\F, , f, }
8792 @DefescItem {\\F, @Lparen{}, fm, }
8793 @DefescItem {\\F, @Lbrack{}, family, @Rbrack{}}
8794 @DefregListEnd {.fn}
8795 @cindex changing font family (@code{fam}, @code{\F})
8796 @cindex font family, changing (@code{fam}, @code{\F})
8797 Switch font family to @var{family} (one-character name@tie{}@var{f},
8798 two-character name @var{fm}).  If no argument is given, switch back to
8799 the previous font family.  Use @code{\F[]} to do this with the escape.
8800 Note that @code{\FP} doesn't work; it selects font family @samp{P}
8801 instead.
8803 The value at start-up is @samp{T}.  The current font family is available
8804 in the read-only number register @samp{.fam} (this is a string-valued
8805 register); it is associated with the current environment.
8807 @Example
8808 spam,
8809 .fam H    \" helvetica family
8810 spam,     \" used font is family H + style R = HR
8811 .ft B     \" family H + style B = font HB
8812 spam,
8813 .fam T    \" times family
8814 spam,     \" used font is family T + style B = TB
8815 .ft AR    \" font AR (not a style)
8816 baked beans,
8817 .ft R     \" family T + style R = font TR
8818 and spam.
8819 @endExample
8821 Note that @code{\F} doesn't produce an input token in @code{gtroff}.  As
8822 a consequence, it can be used in requests like @code{mc} (which expects
8823 a single character as an argument) to change the font family on the fly:
8825 @Example
8826 .mc \F[P]x\F[]
8827 @endExample
8829 The @samp{.fn} register contains the current @dfn{real font name} of the
8830 current font.  This is a string-valued register.  If the current font is
8831 a style, the value of @code{\n[.fn]} is the proper concatenation of
8832 family and style name.
8833 @endDefreq
8835 @Defreq {sty, n style}
8836 @cindex changing font style (@code{sty})
8837 @cindex font style, changing (@code{sty})
8838 @cindex @code{cs} request, and font styles
8839 @cindex @code{bd} request, and font styles
8840 @cindex @code{tkf} request, and font styles
8841 @cindex @code{uf} request, and font styles
8842 @cindex @code{fspecial} request, and font styles
8843 Associate @var{style} with font position@tie{}@var{n}.  A font position
8844 can be associated either with a font or with a style.  The current font
8845 is the index of a font position and so is also either a font or a style.
8846 If it is a style, the font that is actually used is the font which name
8847 is the concatenation of the name of the current family and the name of
8848 the current style.  For example, if the current font is@tie{}1 and font
8849 position@tie{}1 is associated with style @samp{R} and the current font
8850 family is @samp{T}, then font @samp{TR} is used.  If the current font is
8851 not a style, then the current family is ignored.  If the requests
8852 @code{cs}, @code{bd}, @code{tkf}, @code{uf}, or @code{fspecial} are
8853 applied to a style, they are instead applied to the member of the
8854 current family corresponding to that style.
8856 @var{n}@tie{}must be a non-negative integer value.
8858 @pindex DESC
8859 @kindex styles
8860 The default family can be set with the @option{-f} option (@pxref{Groff
8861 Options}).  The @code{styles} command in the @file{DESC} file controls
8862 which font positions (if any) are initially associated with styles
8863 rather than fonts.  For example, the default setting for @sc{PostScript}
8864 fonts
8866 @Example
8867 styles R I B BI
8868 @endExample
8870 @noindent
8871 is equivalent to
8873 @Example
8874 .sty 1 R
8875 .sty 2 I
8876 .sty 3 B
8877 .sty 4 BI
8878 @endExample
8880 @code{fam} and @code{\F} always check whether the current font position
8881 is valid; this can give surprising results if the current font position
8882 is associated with a style.
8884 In the following example, we want to access the @sc{PostScript} font
8885 @code{FooBar} from the font family @code{Foo}:
8887 @Example
8888 .sty \n[.fp] Bar
8889 .fam Foo
8890     @result{} warning: can't find font `FooR'
8891 @endExample
8893 @noindent
8894 The default font position at start-up is@tie{}1; for the @sc{PostScript}
8895 device, this is associated with style @samp{R}, so @code{gtroff} tries
8896 to open @code{FooR}.
8898 A solution to this problem is to use a dummy font like the following:
8900 @Example
8901 .fp 0 dummy TR    \" set up dummy font at position 0
8902 .sty \n[.fp] Bar  \" register style `Bar'
8903 .ft 0             \" switch to font at position 0
8904 .fam Foo          \" activate family `Foo'
8905 .ft Bar           \" switch to font `FooBar'
8906 @endExample
8908 @xref{Font Positions}.
8909 @endDefreq
8911 @c ---------------------------------------------------------------------
8913 @node Font Positions, Using Symbols, Font Families, Fonts and Symbols
8914 @subsection Font Positions
8915 @cindex font positions
8916 @cindex positions, font
8918 For the sake of old phototypesetters and compatibility with old versions
8919 of @code{troff}, @code{gtroff} has the concept of font @dfn{positions},
8920 on which various fonts are mounted.
8922 @DefreqList {fp, pos font [@Var{external-name}]}
8923 @DefregItem {.f}
8924 @DefregListEnd {.fp}
8925 @cindex mounting font (@code{fp})
8926 @cindex font, mounting (@code{fp})
8927 Mount font @var{font} at position @var{pos} (which must be a
8928 non-negative integer).  This numeric position can then be referred to
8929 with font changing commands.  When @code{gtroff} starts it is using font
8930 position@tie{}1 (which must exist; position@tie{}0 is unused usually at
8931 start-up).
8933 @cindex font position register (@code{.f})
8934 The current font in use, as a font position, is available in the
8935 read-only number register @samp{.f}.  This can be useful to remember the
8936 current font for later recall.  It is associated with the current
8937 environment (@pxref{Environments}).
8939 @Example
8940 .nr save-font \n[.f]
8941 .ft B
8942 ... text text text ...
8943 .ft \n[save-font]
8944 @endExample
8946 @cindex next free font position register (@code{.fp})
8947 The number of the next free font position is available in the read-only
8948 number register @samp{.fp}.  This is useful when mounting a new font,
8949 like so:
8951 @Example
8952 .fp \n[.fp] NEATOFONT
8953 @endExample
8955 @pindex DESC@r{, and font mounting}
8956 Fonts not listed in the @file{DESC} file are automatically mounted on
8957 the next available font position when they are referenced.  If a font is
8958 to be mounted explicitly with the @code{fp} request on an unused font
8959 position, it should be mounted on the first unused font position, which
8960 can be found in the @code{.fp} register.  Although @code{gtroff} does
8961 not enforce this strictly, it is not allowed to mount a font at a
8962 position whose number is much greater (approx.@: 1000 positions) than
8963 that of any currently used position.
8965 The @code{fp} request has an optional third argument.  This argument
8966 gives the external name of the font, which is used for finding the font
8967 description file.  The second argument gives the internal name of the
8968 font which is used to refer to the font in @code{gtroff} after it has
8969 been mounted.  If there is no third argument then the internal name is
8970 used as the external name.  This feature makes it possible to use fonts
8971 with long names in compatibility mode.
8972 @endDefreq
8974 Both the @code{ft} request and the @code{\f} escape have alternative
8975 syntax forms to access font positions.
8977 @DefreqList {ft, nnn}
8978 @DefescItem {\\f, , n, }
8979 @DefescItem {\\f, @Lparen{}, nn, }
8980 @DefescListEnd {\\f, @Lbrack{}, nnn, @Rbrack{}}
8981 @cindex changing font position (@code{\f})
8982 @cindex font position, changing (@code{\f})
8983 @cindex @code{sty} request, and font positions
8984 @cindex @code{fam} request, and font positions
8985 @cindex @code{\F}, and font positions
8986 @kindex styles
8987 @kindex family
8988 @pindex DESC
8989 Change the current font position to @var{nnn} (one-digit
8990 position@tie{}@var{n}, two-digit position @var{nn}), which must be a
8991 non-negative integer.
8993 If @var{nnn} is associated with a style (as set with the @code{sty}
8994 request or with the @code{styles} command in the @file{DESC} file), use
8995 it within the current font family (as set with the @code{fam} request,
8996 the @code{\F} escape, or with the @code{family} command in the
8997 @file{DESC} file).
8999 @Example
9000 this is font 1
9001 .ft 2
9002 this is font 2
9003 .ft                   \" switch back to font 1
9004 .ft 3
9005 this is font 3
9007 this is font 1 again
9008 @endExample
9010 @xref{Changing Fonts}, for the standard syntax form.
9011 @endDefreq
9013 @c ---------------------------------------------------------------------
9015 @node Using Symbols, Special Fonts, Font Positions, Fonts and Symbols
9016 @subsection Using Symbols
9017 @cindex using symbols
9018 @cindex symbols, using
9020 @cindex glyph
9021 @cindex character
9022 @cindex ligature
9023 A @dfn{glyph} is a graphical representation of a @dfn{character}.  While
9024 a character is an abstract entity containing semantic information, a
9025 glyph is something which can be actually seen on screen or paper.  It is
9026 possible that a character has multiple glyph representation forms (for
9027 example, the character `A' can be either written in a roman or an italic
9028 font, yielding two different glyphs); sometimes more than one character
9029 maps to a single glyph (this is a @dfn{ligature} -- the most common is
9030 `fi').
9032 @cindex symbol
9033 @cindex special fonts
9034 @kindex fonts
9035 @pindex DESC
9036 @cindex @code{special} request, and glyph search order
9037 @cindex @code{fspecial} request, and glyph search order
9038 A @dfn{symbol} is simply a named glyph.  Within @code{gtroff}, all glyph
9039 names of a particular font are defined in its font file.  If the user
9040 requests a glyph not available in this font, @code{gtroff} looks up an
9041 ordered list of @dfn{special fonts}.  By default, the @sc{PostScript}
9042 output device supports the two special fonts @samp{SS} (slanted symbols)
9043 and @samp{S} (symbols) (the former is looked up before the latter).
9044 Other output devices use different names for special fonts.  Fonts
9045 mounted with the @code{fonts} keyword in the @file{DESC} file are
9046 globally available.  To install additional special fonts locally (i.e.@:
9047 for a particular font), use the @code{fspecial} request.
9049 Here the exact rules how @code{gtroff} searches a given symbol:
9051 @itemize @bullet
9052 @item
9053 If the symbol has been defined with the @code{char} request, use it.
9054 This hides a symbol with the same name in the current font.
9056 @item
9057 Check the current font.
9059 @item
9060 If the symbol has been defined with the @code{fchar} request, use it.
9062 @item
9063 Check whether the current font has a font-specific list of special
9064 fonts; test all fonts in the order of appearance in the last
9065 @code{fspecial} call if appropriate.
9067 @item
9068 If the symbol has been defined with the @code{fschar} request for the
9069 current font, use it.
9071 @item
9072 Check all fonts in the order of appearance in the last @code{special}
9073 call.
9075 @item
9076 If the symbol has been defined with the @code{schar} request, use it.
9078 @item
9079 As a last resort, consult all fonts loaded up to now for special fonts
9080 and check them, starting with the lowest font number.  Note that this
9081 can sometimes lead to surprising results since the @code{fonts} line in
9082 the @file{DESC} file often contains empty positions which are filled
9083 later on.  For example, consider the following:
9085 @Example
9086 fonts 3 0 0 FOO
9087 @endExample
9089 @noindent
9090 This mounts font @code{foo} at font position@tie{}3.  We assume that
9091 @code{FOO} is a special font, containing glyph @code{foo}, and that no
9092 font has been loaded yet.  The line
9094 @Example
9095 .fspecial BAR BAZ
9096 @endExample
9098 @noindent
9099 makes font @code{BAZ} special only if font @code{BAR} is active.  We
9100 further assume that @code{BAZ} is really a special font, i.e., the font
9101 description file contains the @code{special} keyword, and that it also
9102 contains glyph @code{foo} with a special shape fitting to font
9103 @code{BAR}.  After executing @code{fspecial}, font @code{BAR} is loaded
9104 at font position@tie{}1, and @code{BAZ} at position@tie{}2.
9106 We now switch to a new font @code{XXX}, trying to access glyph
9107 @code{foo} which is assumed to be missing.  There are neither
9108 font-specific special fonts for @code{XXX} nor any other fonts made
9109 special with the @code{special} request, so @code{gtroff} starts the
9110 search for special fonts in the list of already mounted fonts, with
9111 increasing font positions.  Consequently, it finds @code{BAZ} before
9112 @code{FOO} even for @code{XXX} which is not the intended behaviour.
9113 @end itemize
9115 @xref{Font Files}, and @ref{Special Fonts}, for more details.
9117 @cindex list of available glyphs (@cite{groff_char(7)} man page)
9118 @cindex available glyphs, list (@cite{groff_char(7)} man page)
9119 @cindex glyphs, available, list (@cite{groff_char(7)} man page)
9120 The list of available symbols is device dependent; see the
9121 @cite{groff_char(7)} man page for a complete list of all glyphs.  For
9122 example, say
9124 @Example
9125 man -Tdvi groff_char > groff_char.dvi
9126 @endExample
9128 @noindent
9129 for a list using the default DVI fonts (not all versions of the
9130 @code{man} program support the @option{-T} option).  If you want to use
9131 an additional macro package to change the used fonts, @code{groff} must
9132 be called directly:
9134 @Example
9135 groff -Tdvi -mec -man groff_char.7 > groff_char.dvi
9136 @endExample
9138 @cindex composite glyph names
9139 @cindex glyph names, composite
9140 @cindex groff glyph list (GGL)
9141 @cindex GGL (groff glyph list)
9142 @cindex adobe glyph list (AGL)
9143 @cindex AGL (adobe glyph list)
9144 Glyph names not listed in groff_char(7) are derived algorithmically,
9145 using a simplified version of the Adobe Glyph List (AGL) algorithm which
9146 is described in
9147 @uref{http://partners.adobe.com@//public@//developer@//opentype@//index_glyph.html}.
9148 The (frozen) set of glyph names which can't be derived algorithmically
9149 is called @dfn{groff glyph list (GGL)}.
9151 @itemize @bullet
9152 @item
9153 A glyph for Unicode character U+@var{XXXX}[@var{X}[@var{X}]] which is
9154 not a composite character is named
9155 @code{u@var{XXXX}@r{[}@var{X}@r{[}@var{X}@r{]]}}.  @var{X} must be an
9156 uppercase hexadecimal digit.  Examples: @code{u1234}, @code{u008E},
9157 @code{u12DB8}.  The largest Unicode value is 0x10FFFF.  There must be at
9158 least four @code{X} digits; if necessary, add leading zeroes (after the
9159 @samp{u}).  No zero padding is allowed for character codes greater than
9160 0xFFFF.  Surrogates (i.e., Unicode values greater than 0xFFFF
9161 represented with character codes from the surrogate area U+D800-U+DFFF)
9162 are not allowed too.
9164 @item
9165 A glyph representing more than a single input character is named
9167 @display
9168 @samp{u} @var{component1} @samp{_} @var{component2} @samp{_} @var{component3} @dots{}
9169 @end display
9171 @noindent
9172 Example: @code{u0045_0302_0301}.
9174 For simplicity, all Unicode characters which are composites must be
9175 decomposed maximally (this is normalization form@tie{}D in the Unicode
9176 standard); for example, @code{u00CA_0301} is not a valid glyph name
9177 since U+00CA (@sc{latin capital letter e with circumflex}) can be
9178 further decomposed into U+0045 (@sc{latin capital letter e}) and U+0302
9179 (@sc{combining circumflex accent}).  @code{u0045_0302_0301} is thus the
9180 glyph name for U+1EBE, @sc{latin capital letter e with circumflex and
9181 acute}.
9183 @item
9184 groff maintains a table to decompose all algorithmically derived glyph
9185 names which are composites itself.  For example, @code{u0100} (@sc{latin
9186 letter a with macron}) is automatically decomposed into
9187 @code{u0041_0304}.  Additionally, a glyph name of the GGL is preferred
9188 to an algorithmically derived glyph name; groff also automatically does
9189 the mapping.  Example: The glyph @code{u0045_0302} is mapped to
9190 @code{^E}.
9192 @item
9193 glyph names of the GGL can't be used in composite glyph names; for
9194 example, @code{^E_u0301} is invalid.
9195 @end itemize
9197 @DefescList {\\, @Lparen{}, nm, }
9198 @DefescItem {\\, @Lbrack{}, name, @Rbrack{}}
9199 @DefescListEnd {\\, @Lbrack{}, component1 component2 @dots{}, @Rbrack{}}
9200 Insert a symbol @var{name} (two-character name @var{nm}) or a composite
9201 glyph with component glyphs @var{component1}, @var{component2},
9202 @enddots{} There is no special syntax for one-character names -- the
9203 natural form @samp{\@var{n}} would collide with escapes.@footnote{Note
9204 that a one-character symbol is not the same as an input character, i.e.,
9205 the character @code{a} is not the same as @code{\[a]}.  By default,
9206 @code{groff} defines only a single one-character symbol, @code{\[-]}; it
9207 is usually accessed as @code{\-}.  On the other hand, @code{gtroff} has
9208 the special feature that @code{\[char@var{XXX}]} is the same as the
9209 input character with character code @var{XXX}.  For example,
9210 @code{\[char97]} is identical to the letter @code{a} if @acronym{ASCII}
9211 encoding is active.}
9213 If @var{name} is undefined, a warning of type @samp{char} is generated,
9214 and the escape is ignored.  @xref{Debugging}, for information about
9215 warnings.
9217 groff resolves @code{\[...]} with more than a single component as
9218 follows:
9220 @itemize @bullet
9221 @item
9222 Any component which is found in the GGL is converted to the
9223 @code{u@var{XXXX}} form.
9225 @item
9226 Any component @code{u@var{XXXX}} which is found in the list of
9227 decomposable glyphs is decomposed.
9229 @item
9230 The resulting elements are then concatenated with @samp{_} inbetween,
9231 dropping the leading @samp{u} in all elements but the first.
9232 @end itemize
9234 No check for the existence of any component (similar to @code{tr}
9235 request) is done.
9237 Examples:
9239 @table @code
9240 @item \[A ho]
9241 @samp{A} maps to @code{u0041}, @samp{ho} maps to @code{u02DB}, thus the
9242 final glyph name would be @code{u0041_02DB}.  Note this is not the
9243 expected result: The ogonek glyph @samp{ho} is a spacing ogonek, but for
9244 a proper composite a non-spacing ogonek (U+0328) is necessary.  Looking
9245 into the file @file{composite.tmac} one can find @w{@samp{.composite ho
9246 u0328}} which changes the mapping of @samp{ho} while a composite glyph
9247 name is constructed, causing the final glyph name to be
9248 @code{u0041_0328}.
9250 @item \[^E u0301]
9251 @itemx \[^E aa]
9252 @itemx \[E a^ aa]
9253 @itemx \[E ^ ']
9254 @samp{^E} maps to @code{u0045_0302}, thus the final glyph name is
9255 @code{u0045_0302_0301} in all forms (assuming proper calls of the
9256 @code{composite} request).
9257 @end table
9259 It is not possible to define glyphs with names like @w{@samp{A ho}}
9260 within a groff font file.  This is not really a limitation; instead, you
9261 have to define @code{u0041_0328}.
9262 @endDefesc
9264 @Defesc {\\C, ', xxx, '}
9265 @cindex named character (@code{\C})
9266 @cindex character, named (@code{\C})
9267 Typeset the glyph named @var{xxx}.@footnote{@code{\C} is actually a
9268 misnomer since it accesses an output glyph.}  Normally it is more
9269 convenient to use @code{\[@var{xxx}]}, but @code{\C} has the advantage
9270 that it is compatible with newer versions of @acronym{AT&T} @code{troff}
9271 and is available in compatibility mode.
9272 @endDefesc
9274 @Defreq {composite, from to}
9275 @pindex composite.tmac
9276 Map glyph name @var{from} to glyph name @var{to} if it is used in
9277 @code{\[...]} with more than one component.  See above for examples.
9279 This mapping is based on glyph names only; no check for the existence of
9280 either glyph is done.
9282 A set of default mappings for many accents can be found in the file
9283 @file{composite.tmac} which is loaded at start-up.
9284 @endDefreq
9286 @Defesc {\\N, ', n, '}
9287 @cindex numbered glyph (@code{\N})
9288 @cindex glyph, numbered (@code{\N})
9289 @cindex @code{char} request, used with @code{\N}
9290 @cindex Unicode
9291 Typeset the glyph with code@tie{}@var{n} in the current font
9292 (@code{n}@tie{}is @strong{not} the input character code).  The number
9293 @var{n}@tie{}can be any non-negative decimal integer.  Most devices only
9294 have glyphs with codes between 0 and@tie{}255; the Unicode output device
9295 uses codes in the range 0--65535.  If the current font does not contain
9296 a glyph with that code, special fonts are @emph{not} searched.  The
9297 @code{\N} escape sequence can be conveniently used in conjunction with
9298 the @code{char} request:
9300 @Example
9301 .char \[phone] \f[ZD]\N'37'
9302 @endExample
9304 @noindent
9305 @pindex DESC
9306 @cindex unnamed glyphs
9307 @cindex glyphs, unnamed
9308 The code of each glyph is given in the fourth column in the font
9309 description file after the @code{charset} command.  It is possible to
9310 include unnamed glyphs in the font description file by using a name of
9311 @samp{---}; the @code{\N} escape sequence is the only way to use these.
9313 No kerning is applied to glyphs accessed with @code{\N}.
9314 @endDefesc
9316 Some escape sequences directly map onto special glyphs.
9318 @Defesc {\\', , , }
9319 This is a backslash followed by the apostrophe character,
9320 @acronym{ASCII} character @code{0x27} (@acronym{EBCDIC} character
9321 @code{0x7D}).  The same as @code{\[aa]}, the acute accent.
9322 @endDefesc
9324 @Defesc {\\`, , , }
9325 This is a backslash followed by @acronym{ASCII} character @code{0x60}
9326 (@acronym{EBCDIC} character @code{0x79} usually).  The same as
9327 @code{\[ga]}, the grave accent.
9328 @endDefesc
9330 @Defesc {\\-, , , }
9331 This is the same as @code{\[-]}, the minus sign in the current font.
9332 @endDefesc
9334 @Defesc {\\_, , , }
9335 This is the same as @code{\[ul]}, the underline character.
9336 @endDefesc
9338 @Defreq {cflags, n c1 c2 @dots{}}
9339 @cindex glyph properties (@code{cflags})
9340 @cindex character properties (@code{cflags})
9341 @cindex properties of glyphs (@code{cflags})
9342 @cindex properties of characters (@code{cflags})
9343 Input characters and symbols have certain properties associated with
9344 it.@footnote{Note that the output glyphs themselves don't have such
9345 properties.  For @code{gtroff}, a glyph is a numbered box with a given
9346 width, depth, and height, nothing else.  All manipulations with the
9347 @code{cflags} request work on the input level.}  These properties can be
9348 modified with the @code{cflags} request.  The first argument is the sum
9349 of the desired flags and the remaining arguments are the characters or
9350 symbols to have those properties.  It is possible to omit the spaces
9351 between the characters or symbols.
9353 @table @code
9354 @item 1
9355 @cindex end-of-sentence characters
9356 @cindex characters, end-of-sentence
9357 The character ends sentences (initially characters @samp{.?!} have this
9358 property).
9360 @item 2
9361 @cindex hyphenating characters
9362 @cindex characters, hyphenation
9363 Lines can be broken before the character (initially no characters have
9364 this property).  This only works if both the characters before and after
9365 have non-zero hyphenation codes (as set with the @code{hcode} request).
9366 Use value@tie{}64 to override this behaviour.
9368 @item 4
9369 @cindex @code{hy} glyph, and @code{cflags}
9370 @cindex @code{em} glyph, and @code{cflags}
9371 Lines can be broken after the character (initially the character
9372 @samp{-} and the symbols @samp{\[hy]} and @samp{\[em]} have this
9373 property).  This only works if both the characters before and after have
9374 non-zero hyphenation codes (as set with the @code{hcode} request).  Use
9375 value@tie{}64 to override this behaviour.
9377 @item 8
9378 @cindex overlapping characters
9379 @cindex characters, overlapping
9380 @cindex @code{ul} glyph, and @code{cflags}
9381 @cindex @code{rn} glyph, and @code{cflags}
9382 @cindex @code{ru} glyph, and @code{cflags}
9383 @cindex @code{radicalex} glyph, and @code{cflags}
9384 @cindex @code{sqrtex} glyph, and @code{cflags}
9385 The character overlaps horizontally if used as a horizontal line
9386 building element.  Initially the symbols @samp{\[ul]}, @samp{\[rn]},
9387 @samp{\[ru]}, @samp{\[radicalex]}, and @samp{\[sqrtex]} have this
9388 property.
9390 @item 16
9391 @cindex @code{br} glyph, and @code{cflags}
9392 The character overlaps vertically if used as vertical line building
9393 element.  Initially symbol @samp{\[br]} has this property.
9395 @item 32
9396 @cindex transparent characters
9397 @cindex character, transparent
9398 @cindex @code{"}, at end of sentence
9399 @cindex @code{'}, at end of sentence
9400 @cindex @code{)}, at end of sentence
9401 @cindex @code{]}, at end of sentence
9402 @cindex @code{*}, at end of sentence
9403 @cindex @code{dg} glyph, at end of sentence
9404 @cindex @code{rq} glyph, at end of sentence
9405 An end-of-sentence character followed by any number of characters with
9406 this property is treated as the end of a sentence if followed by a
9407 newline or two spaces; in other words the character is @dfn{transparent}
9408 for the purposes of end-of-sentence recognition -- this is the same as
9409 having a zero space factor in @TeX{} (initially characters @samp{"')]*}
9410 and the symbols @samp{\[dg]} and @samp{\[rq]} have this property).
9412 @item 64
9413 Ignore hyphenation code values of the surrounding characters.  Use this
9414 in combination with values 2 and@tie{}4 (initially no characters have
9415 this property).  For example, if you need an automatic break point after
9416 the hyphen in number ranges like `3000-5000', insert
9418 @Example
9419 .cflags 68 -
9420 @endExample
9422 @noindent
9423 into your document.  Note, however, that this can lead to bad layout if
9424 done without thinking; in most situations, a better solution instead of
9425 changing the @code{cflags} value is to insert @code{\:} right after the
9426 hyphen at the places which really need a break point.
9427 @end table
9428 @endDefreq
9430 @DefreqList {char, g [@Var{string}]}
9431 @DefreqItem {fchar, g [@Var{string}]}
9432 @DefreqItem {fschar, f g [@Var{string}]}
9433 @DefreqListEnd {schar, g [@Var{string}]}
9434 @cindex defining character (@code{char})
9435 @cindex defining fallback character (@code{fchar}, @code{fschar}, @code{schar})
9436 @cindex character, defining (@code{char})
9437 @cindex character, defining fallback (@code{fchar}, @code{fschar}, @code{schar})
9438 @cindex fallback character, defining (@code{fchar}, @code{fschar}, @code{schar})
9439 @cindex creating new characters (@code{char})
9440 @cindex defining symbol (@code{char})
9441 @cindex symbol, defining (@code{char})
9442 @cindex defining glyph (@code{char})
9443 @cindex glyph, defining (@code{char})
9444 @cindex escape character, while defining glyph
9445 @cindex character, escape, while defining glyph
9446 @cindex @code{tr} request, and glyph definitions
9447 @cindex @code{cp} request, and glyph definitions
9448 @cindex @code{rc} request, and glyph definitions
9449 @cindex @code{lc} request, and glyph definitions
9450 @cindex @code{\l}, and glyph definitions
9451 @cindex @code{\L}, and glyph definitions
9452 @cindex @code{\&}, and glyph definitions
9453 @cindex @code{\e}, and glyph definitions
9454 @cindex @code{hcode} request, and glyph definitions
9455 Define a new glyph@tie{}@var{g} to be @var{string} (which can be
9456 empty).@footnote{@code{char} is a misnomer since an output glyph is
9457 defined.}  Every time glyph@tie{}@var{g} needs to be printed,
9458 @var{string} is processed in a temporary environment and the result is
9459 wrapped up into a single object.  Compatibility mode is turned off and
9460 the escape character is set to @samp{\} while @var{string} is being
9461 processed.  Any emboldening, constant spacing or track kerning is
9462 applied to this object rather than to individual characters in
9463 @var{string}.
9465 A glyph defined by these requests can be used just like a normal glyph
9466 provided by the output device.  In particular, other characters can be
9467 translated to it with the @code{tr} or @code{trin} requests; it can be
9468 made the leader character by the @code{lc} request; repeated patterns
9469 can be drawn with the glyph using the @code{\l} and @code{\L} escape
9470 sequences; words containing the glyph can be hyphenated correctly if the
9471 @code{hcode} request is used to give the glyph's symbol a hyphenation
9472 code.
9474 There is a special anti-recursion feature: Use of @code{g} within the
9475 glyph's definition is handled like normal characters and symbols not
9476 defined with @code{char}.
9478 Note that the @code{tr} and @code{trin} requests take precedence if
9479 @code{char} accesses the same symbol.
9481 @Example
9482 .tr XY
9484     @result{} Y
9485 .char X Z
9487     @result{} Y
9488 .tr XX
9490     @result{} Z
9491 @endExample
9493 The @code{fchar} request defines a fallback glyph: @code{gtroff} only
9494 checks for glyphs defined with @code{fchar} if it cannot find the glyph
9495 in the current font.  @code{gtroff} carries out this test before
9496 checking special fonts.
9498 @code{fschar} defines a fallback glyph for font@tie{}@var{f}:
9499 @code{gtroff} checks for glyphs defined with @code{fschar} after the
9500 list of fonts declared as font-specific special fonts with the
9501 @code{fspecial} request, but before the list of fonts declared as global
9502 special fonts with the @code{special} request.
9504 Finally, the @code{schar} request defines a global fallback glyph:
9505 @code{gtroff} checks for glyphs defined with @code{schar} after the list
9506 of fonts declared as global special fonts with the @code{special}
9507 request, but before the already mounted special fonts.
9509 @xref{Using Symbols}, for a detailed description of the glyph searching
9510 mechanism in @code{gtroff}.
9511 @endDefreq
9513 @DefreqList {rchar, c1 c2 @dots{}}
9514 @DefreqListEnd {rfschar, f c1 c2 @dots{}}
9515 @cindex removing glyph definition (@code{rchar}, @code{rfschar})
9516 @cindex glyph, removing definition (@code{rchar}, @code{rfschar})
9517 @cindex fallback glyph, removing definition (@code{rchar}, @code{rfschar})
9518 Remove the definitions of glyphs @var{c1}, @var{c2},@tie{}@enddots{}
9519 This undoes the effect of a @code{char}, @code{fchar}, or @code{schar}
9520 request.
9522 It is possible to omit the whitespace between arguments.
9524 The request @code{rfschar} removes glyph definitions defined with
9525 @code{fschar} for glyph@tie{}f.
9526 @endDefreq
9528 @xref{Special Characters}.
9530 @c ---------------------------------------------------------------------
9532 @node Special Fonts, Artificial Fonts, Using Symbols, Fonts and Symbols
9533 @subsection Special Fonts
9534 @cindex special fonts
9535 @cindex fonts, special
9537 Special fonts are those that @code{gtroff} searches when it cannot find
9538 the requested glyph in the current font.  The Symbol font is usually a
9539 special font.
9541 @code{gtroff} provides the following two requests to add more special
9542 fonts.  @xref{Using Symbols}, for a detailed description of the glyph
9543 searching mechanism in @code{gtroff}.
9545 Usually, only non-TTY devices have special fonts.
9547 @DefreqList {special, [@Var{s1} @Var{s2} @dots{}]}
9548 @DefreqListEnd {fspecial, f [@Var{s1} @Var{s2} @dots{}]}
9549 @kindex fonts
9550 @pindex DESC
9551 Use the @code{special} request to define special fonts.  Initially, this
9552 list is empty.
9554 Use the @code{fspecial} request to designate special fonts only when
9555 font@tie{}@var{f} is active.  Initially, this list is empty.
9557 Previous calls to @code{special} or @code{fspecial} are overwritten;
9558 without arguments, the particular list of special fonts is set to empty.
9559 Special fonts are searched in the order they appear as arguments.
9561 All fonts which appear in a call to @code{special} or @code{fspecial}
9562 are loaded.
9564 @xref{Using Symbols}, for the exact search order of glyphs.
9565 @endDefreq
9567 @c ---------------------------------------------------------------------
9569 @node Artificial Fonts, Ligatures and Kerning, Special Fonts, Fonts and Symbols
9570 @subsection Artificial Fonts
9571 @cindex artificial fonts
9572 @cindex fonts, artificial
9574 There are a number of requests and escapes for artificially creating
9575 fonts.  These are largely vestiges of the days when output devices did
9576 not have a wide variety of fonts, and when @code{nroff} and @code{troff}
9577 were separate programs.  Most of them are no longer necessary in GNU
9578 @code{troff}.  Nevertheless, they are supported.
9580 @DefescList {\\H, ', height, '}
9581 @DefescItem {\\H, ', @t{+}height, '}
9582 @DefescItem {\\H, ', @t{-}height, '}
9583 @DefregListEnd {.height}
9584 @cindex changing the font height (@code{\H})
9585 @cindex font height, changing (@code{\H})
9586 @cindex height, font, changing (@code{\H})
9587 Change (increment, decrement) the height of the current font, but not
9588 the width.  If @var{height} is zero, restore the original height.
9589 Default scaling indicator is @samp{z}.
9591 The read-only number register @code{.height} contains the font height as
9592 set by @code{\H}.
9594 Currently, only the @option{-Tps} device supports this feature.
9596 Note that @code{\H} doesn't produce an input token in @code{gtroff}.  As
9597 a consequence, it can be used in requests like @code{mc} (which expects
9598 a single character as an argument) to change the font on the fly:
9600 @Example
9601 .mc \H'+5z'x\H'0'
9602 @endExample
9604 In compatibility mode, @code{gtroff} behaves differently: If an
9605 increment or decrement is used, it is always taken relative to the
9606 current point size and not relative to the previously selected font
9607 height.  Thus,
9609 @Example
9610 .cp 1
9611 \H'+5'test \H'+5'test
9612 @endExample
9614 @noindent
9615 prints the word @samp{test} twice with the same font height (five points
9616 larger than the current font size).
9617 @endDefesc
9619 @DefescList {\\S, ', slant, '}
9620 @DefregListEnd {.slant}
9621 @cindex changing the font slant (@code{\S})
9622 @cindex font slant, changing (@code{\S})
9623 @cindex slant, font, changing (@code{\S})
9624 Slant the current font by @var{slant} degrees.  Positive values slant to
9625 the right.  Only integer values are possible.
9627 The read-only number register @code{.slant} contains the font slant as
9628 set by @code{\S}.
9630 Currently, only the @option{-Tps} device supports this feature.
9632 Note that @code{\S} doesn't produce an input token in @code{gtroff}.  As
9633 a consequence, it can be used in requests like @code{mc} (which expects
9634 a single character as an argument) to change the font on the fly:
9636 @Example
9637 .mc \S'20'x\S'0'
9638 @endExample
9640 This request is incorrectly documented in the original @acronym{UNIX}
9641 troff manual; the slant is always set to an absolute value.
9642 @endDefesc
9644 @Defreq {ul, [@Var{lines}]}
9645 @cindex underlining (@code{ul})
9646 The @code{ul} request normally underlines subsequent lines if a TTY
9647 output device is used.  Otherwise, the lines are printed in italics
9648 (only the term `underlined' is used in the following).  The single
9649 argument is the number of input lines to be underlined; with no
9650 argument, the next line is underlined.  If @var{lines} is zero or
9651 negative, stop the effects of @code{ul} (if it was active).  Requests
9652 and empty lines do not count for computing the number of underlined
9653 input lines, even if they produce some output like @code{tl}.  Lines
9654 inserted by macros (e.g.@: invoked by a trap) do count.
9656 At the beginning of @code{ul}, the current font is stored and the
9657 underline font is activated.  Within the span of a @code{ul} request, it
9658 is possible to change fonts, but after the last line affected by
9659 @code{ul} the saved font is restored.
9661 This number of lines still to be underlined is associated with the
9662 current environment (@pxref{Environments}).  The underline font can be
9663 changed with the @code{uf} request.
9665 @c XXX @xref should be changed to grotty
9667 @c @xref{Troff and Nroff Mode}, for a discussion how underlining is
9668 @c implemented in for TTY output devices, and which problems can arise.
9670 The @code{ul} request does not underline spaces.
9671 @endDefreq
9673 @Defreq {cu, [@Var{lines}]}
9674 @cindex continuous underlining (@code{cu})
9675 @cindex underlining, continuous (@code{cu})
9676 The @code{cu} request is similar to @code{ul} but underlines spaces as
9677 well (if a TTY output device is used).
9678 @endDefreq
9680 @Defreq {uf, font}
9681 @cindex underline font (@code{uf})
9682 @cindex font for underlining (@code{uf})
9683 Set the underline font (globally) used by @code{ul} and @code{cu}.  By
9684 default, this is the font at position@tie{}2.  @var{font} can be either
9685 a non-negative font position or the name of a font.
9686 @endDefreq
9688 @DefreqList {bd, font [@Var{offset}]}
9689 @DefreqItem {bd, font1 font2 [@Var{offset}]}
9690 @DefregListEnd {.b}
9691 @cindex imitating bold face (@code{bd})
9692 @cindex bold face, imitating (@code{bd})
9693 Artificially create a bold font by printing each glyph twice, slightly
9694 offset.
9696 Two syntax forms are available.
9698 @itemize @bullet
9699 @item
9700 Imitate a bold font unconditionally.  The first argument specifies the
9701 font to embolden, and the second is the number of basic units, minus
9702 one, by which the two glyphs are offset.  If the second argument is
9703 missing, emboldening is turned off.
9705 @var{font} can be either a non-negative font position or the name of a
9706 font.
9708 @var{offset} is available in the @code{.b} read-only register if a
9709 special font is active; in the @code{bd} request, its default unit is
9710 @samp{u}.
9712 @cindex @code{fspecial} request, and imitating bold
9713 @kindex special
9714 @cindex embolding of special fonts
9715 @cindex special fonts, emboldening
9716 @item
9717 Imitate a bold form conditionally.  Embolden @var{font1} by @var{offset}
9718 only if font @var{font2} is the current font.  This command can be
9719 issued repeatedly to set up different emboldening values for different
9720 current fonts.  If the second argument is missing, emboldening is turned
9721 off for this particular current font.
9723 This affects special fonts only (either set up with the @code{special}
9724 command in font files or with the @code{fspecial} request).
9725 @end itemize
9726 @endDefreq
9728 @Defreq {cs, font [@Var{width} [@Var{em-size}]]}
9729 @cindex constant glyph space mode (@code{cs})
9730 @cindex mode for constant glyph space (@code{cs})
9731 @cindex glyph, constant space
9732 @cindex @code{ps} request, and constant glyph space mode
9733 Switch to and from @dfn{constant glyph space mode}.  If activated, the
9734 width of every glyph is @math{@var{width}/36} ems.  The em size is given
9735 absolutely by @var{em-size}; if this argument is missing, the em value
9736 is taken from the current font size (as set with the @code{ps} request)
9737 when the font is effectively in use.  Without second and third argument,
9738 constant glyph space mode is deactivated.
9740 Default scaling indicator for @var{em-size} is @samp{z}; @var{width} is
9741 an integer.
9742 @endDefreq
9744 @c ---------------------------------------------------------------------
9746 @node Ligatures and Kerning,  , Artificial Fonts, Fonts and Symbols
9747 @subsection Ligatures and Kerning
9748 @cindex ligatures and kerning
9749 @cindex kerning and ligatures
9751 Ligatures are groups of characters that are run together, i.e, producing
9752 a single glyph.  For example, the letters `f' and `i' can form a
9753 ligature `fi' as in the word `file'.  This produces a cleaner look
9754 (albeit subtle) to the printed output.  Usually, ligatures are not
9755 available in fonts for TTY output devices.
9757 Most @sc{PostScript} fonts support the fi and fl ligatures.  The C/A/T
9758 typesetter that was the target of @acronym{AT&T} @code{troff} also
9759 supported `ff', `ffi', and `ffl' ligatures.  Advanced typesetters or
9760 `expert' fonts may include ligatures for `ft' and `ct', although GNU
9761 @code{troff} does not support these (yet).
9763 Only the current font is checked for ligatures and kerns; neither
9764 special fonts nor entities defined with the @code{char} request (and its
9765 siblings) are taken into account.
9767 @DefreqList {lg, [@Var{flag}]}
9768 @DefregListEnd {.lg}
9769 @cindex activating ligatures (@code{lg})
9770 @cindex ligatures, activating (@code{lg})
9771 @cindex ligatures enabled register (@code{.lg})
9772 Switch the ligature mechanism on or off; if the parameter is non-zero or
9773 missing, ligatures are enabled, otherwise disabled.  Default is on.  The
9774 current ligature mode can be found in the read-only number register
9775 @code{.lg} (set to 1 or@tie{}2 if ligatures are enabled,
9776 0@tie{}otherwise).
9778 Setting the ligature mode to@tie{}2 enables the two-character ligatures
9779 (fi, fl, and ff) and disables the three-character ligatures (ffi and
9780 ffl).
9781 @endDefreq
9783 @dfn{Pairwise kerning} is another subtle typesetting mechanism that
9784 modifies the distance between a glyph pair to improve readability.  In
9785 most cases (but not always) the distance is decreased.
9786 @iftex
9787 For example, compare the combination of the letters `V' and `A'.  With
9788 kerning, `VA' is printed.  Without kerning it appears as `V@w{}A'.
9789 @end iftex
9790 Typewriter-like fonts and fonts for terminals where all glyphs have the
9791 same width don't use kerning.
9793 @DefreqList {kern, [@Var{flag}]}
9794 @DefregListEnd {.kern}
9795 @cindex activating kerning (@code{kern})
9796 @cindex kerning, activating (@code{kern})
9797 @cindex kerning enabled register (@code{.kern})
9798 Switch kerning on or off.  If the parameter is non-zero or missing,
9799 enable pairwise kerning, otherwise disable it.  The read-only number
9800 register @code{.kern} is set to@tie{}1 if pairwise kerning is enabled,
9801 0@tie{}otherwise.
9803 @cindex zero width space character (@code{\&})
9804 @cindex character, zero width space (@code{\&})
9805 @cindex space character, zero width (@code{\&})
9806 If the font description file contains pairwise kerning information,
9807 glyphs from that font are kerned.  Kerning between two glyphs can be
9808 inhibited by placing @code{\&} between them: @samp{V\&A}.
9810 @xref{Font File Format}.
9811 @endDefreq
9813 @cindex track kerning
9814 @cindex kerning, track
9815 @dfn{Track kerning} expands or reduces the space between glyphs.  This
9816 can be handy, for example, if you need to squeeze a long word onto a
9817 single line or spread some text to fill a narrow column.  It must be
9818 used with great care since it is usually considered bad typography if
9819 the reader notices the effect.
9821 @Defreq {tkf, f s1 n1 s2 n2}
9822 @cindex activating track kerning (@code{tkf})
9823 @cindex track kerning, activating (@code{tkf})
9824 Enable track kerning for font@tie{}@var{f}.  If the current font
9825 is@tie{}@var{f} the width of every glyph is increased by an amount
9826 between @var{n1} and @var{n2} (@var{n1}, @var{n2} can be negative); if
9827 the current point size is less than or equal to @var{s1} the width is
9828 increased by @var{n1}; if it is greater than or equal to @var{s2} the
9829 width is increased by @var{n2}; if the point size is greater than or
9830 equal to @var{s1} and less than or equal to @var{s2} the increase in
9831 width is a linear function of the point size.
9833 The default scaling indicator is @samp{z} for @var{s1} and @var{s2},
9834 @samp{p} for @var{n1} and @var{n2}.
9836 Note that the track kerning amount is added even to the rightmost glyph
9837 in a line; for large values it is thus recommended to increase the line
9838 length by the same amount to compensate it.
9839 @endDefreq
9841 Sometimes, when typesetting letters of different fonts, more or less
9842 space at such boundaries are needed.  There are two escapes to help with
9843 this.
9845 @Defesc {\\/, , , }
9846 @cindex italic correction (@code{\/})
9847 @cindex correction, italic (@code{\/})
9848 @cindex correction between italic and roman glyph (@code{\/}, @code{\,})
9849 @cindex roman glyph, correction after italic glyph (@code{\/})
9850 @cindex italic glyph, correction before roman glyph (@code{\/})
9851 @cindex glyph, italic correction (@code{\/})
9852 Increase the width of the preceding glyph so that the spacing between
9853 that glyph and the following glyph is correct if the following glyph is
9854 a roman glyph.  For example, if an italic@tie{}@code{f} is immediately
9855 followed by a roman right parenthesis, then in many fonts the top right
9856 portion of the@tie{}@code{f} overlaps the top left of the right
9857 parenthesis.  Use this escape sequence whenever an italic glyph is
9858 immediately followed by a roman glyph without any intervening space.
9859 This small amount of space is also called @dfn{italic correction}.
9861 @iftex
9862 @c can't use @Example...@endExample here
9863 @example
9864 @group
9865 \f[I]f\f[R])
9866     @result{} {@it f}@r{)}
9867 \f[I]f\/\f[R])
9868     @result{} @i{f}@r{)}
9869 @end group
9870 @end example
9871 @end iftex
9872 @endDefesc
9874 @Defesc {\\\,, , , }
9875 @cindex left italic correction (@code{\,})
9876 @cindex correction, left italic (@code{\,})
9877 @cindex glyph, left italic correction (@code{\,})
9878 @cindex roman glyph, correction before italic glyph (@code{\,})
9879 @cindex italic glyph, correction after roman glyph (@code{\,})
9880 Modify the spacing of the following glyph so that the spacing between
9881 that glyph and the preceding glyph is correct if the preceding glyph is
9882 a roman glyph.  Use this escape sequence whenever a roman glyph is
9883 immediately followed by an italic glyph without any intervening space.
9884 In analogy to above, this space could be called @dfn{left italic
9885 correction}, but this term isn't used widely.
9887 @iftex
9888 @c can't use @Example...@endExample here
9889 @example
9890 @group
9891 q\f[I]f
9892     @result{} @r{q}@i{f}
9893 q\,\f[I]f
9894     @result{} @r{q}@math{@ptexcomma}@i{f}
9895 @end group
9896 @end example
9897 @end iftex
9898 @endDefesc
9900 @Defesc {\\&, , , }
9901 Insert a zero-width character, which is invisible.  Its intended use is
9902 to stop interaction of a character with its surrounding.
9904 @itemize @bullet
9905 @item
9906 It prevents the insertion of extra space after an end-of-sentence
9907 character.
9909 @Example
9910 Test.
9911 Test.
9912     @result{} Test.  Test.
9913 Test.\&
9914 Test.
9915     @result{} Test. Test.
9916 @endExample
9918 @item
9919 It prevents interpretation of a control character at the beginning of an
9920 input line.
9922 @Example
9923 .Test
9924     @result{} warning: `Test' not defined
9925 \&.Test
9926     @result{} .Test
9927 @endExample
9929 @item
9930 It prevents kerning between two glyphs.
9932 @iftex
9933 @c can't use @Example...@endExample here
9934 @example
9935 @group
9937     @result{} @r{VA}
9938 V\&A
9939     @result{} @r{V@w{}A}
9940 @end group
9941 @end example
9942 @end iftex
9944 @item
9945 It is needed to map an arbitrary character to nothing in the @code{tr}
9946 request (@pxref{Character Translations}).
9947 @end itemize
9948 @endDefesc
9950 @Defesc {\\), , , }
9951 This escape is similar to @code{\&} except that it behaves like a
9952 character declared with the @code{cflags} request to be transparent for
9953 the purposes of an end-of-sentence character.
9955 Its main usage is in macro definitions to protect against arguments
9956 starting with a control character.
9958 @Example
9959 .de xxx
9960 \)\\$1
9962 .de yyy
9963 \&\\$1
9965 This is a test.\c
9966 .xxx '
9967 This is a test.
9968     @result{}This is a test.'  This is a test.
9969 This is a test.\c
9970 .yyy '
9971 This is a test.
9972     @result{}This is a test.' This is a test.
9973 @endExample
9974 @endDefesc
9977 @c =====================================================================
9979 @node Sizes, Strings, Fonts and Symbols, gtroff Reference
9980 @section Sizes
9981 @cindex sizes
9983 @cindex baseline
9984 @cindex type size
9985 @cindex size of type
9986 @cindex vertical spacing
9987 @cindex spacing, vertical
9988 @code{gtroff} uses two dimensions with each line of text, type size and
9989 vertical spacing.  The @dfn{type size} is approximately the height of
9990 the tallest glyph.@footnote{This is usually the parenthesis.  Note that
9991 in most cases the real dimensions of the glyphs in a font are @emph{not}
9992 related to its type size!  For example, the standard @sc{PostScript}
9993 font families `Times Roman', `Helvetica', and `Courier' can't be used
9994 together at 10@dmn{pt}; to get acceptable output, the size of
9995 `Helvetica' has to be reduced by one point, and the size of `Courier'
9996 must be increased by one point.}  @dfn{Vertical spacing} is the amount
9997 of space @code{gtroff} allows for a line of text; normally, this is
9998 about 20%@tie{}larger than the current type size.  Ratios smaller than
9999 this can result in hard-to-read text; larger than this, it spreads the
10000 text out more vertically (useful for term papers).  By default,
10001 @code{gtroff} uses 10@tie{}point type on 12@tie{}point spacing.
10003 @cindex leading
10004 The difference between type size and vertical spacing is known, by
10005 typesetters, as @dfn{leading} (this is pronounced `ledding').
10007 @menu
10008 * Changing Type Sizes::
10009 * Fractional Type Sizes::
10010 @end menu
10012 @c ---------------------------------------------------------------------
10014 @node Changing Type Sizes, Fractional Type Sizes, Sizes, Sizes
10015 @subsection Changing Type Sizes
10017 @DefreqList {ps, [@Var{size}]}
10018 @DefreqItem {ps, @t{+}@Var{size}}
10019 @DefreqItem {ps, @t{-}@Var{size}}
10020 @DefescItem {\\s, , size, }
10021 @DefregListEnd {.s}
10022 @cindex changing type sizes (@code{ps}, @code{\s})
10023 @cindex type sizes, changing (@code{ps}, @code{\s})
10024 @cindex point sizes, changing (@code{ps}, @code{\s})
10025 Use the @code{ps} request or the @code{\s} escape to change (increase,
10026 decrease) the type size (in points).  Specify @var{size} as either an
10027 absolute point size, or as a relative change from the current size.  The
10028 size@tie{}0, or no argument, goes back to the previous size.
10030 Default scaling indicator of @code{size} is @samp{z}.  If @code{size} is
10031 zero or negative, it is set to 1@dmn{u}.
10033 @cindex type size registers (@code{.s}, @code{.ps})
10034 @cindex point size registers (@code{.s}, @code{.ps})
10035 The read-only number register @code{.s} returns the point size in points
10036 as a decimal fraction.  This is a string.  To get the point size in
10037 scaled points, use the @code{.ps} register instead.
10039 @code{.s} is associated with the current environment
10040 (@pxref{Environments}).
10042 @Example
10043 snap, snap,
10044 .ps +2
10045 grin, grin,
10046 .ps +2
10047 wink, wink, \s+2nudge, nudge,\s+8 say no more!
10048 .ps 10
10049 @endExample
10051 The @code{\s} escape may be called in a variety of ways.  Much like
10052 other escapes there must be a way to determine where the argument ends
10053 and the text begins.  Any of the following forms are valid:
10055 @table @code
10056 @item \s@var{n}
10057 Set the point size to @var{n}@tie{}points.  @var{n}@tie{}must be either
10058 0 or in the range 4 to@tie{}39.
10060 @item \s+@var{n}
10061 @itemx \s-@var{n}
10062 Increase or decrease the point size by @var{n}@tie{}points.
10063 @var{n}@tie{}must be exactly one digit.
10065 @item \s(@var{nn}
10066 Set the point size to @var{nn}@tie{}points.  @var{nn} must be exactly
10067 two digits.
10069 @item \s+(@var{nn}
10070 @itemx \s-(@var{nn}
10071 @itemx \s(+@var{nn}
10072 @itemx \s(-@var{nn}
10073 Increase or decrease the point size by @var{nn}@tie{}points.  @var{nn}
10074 must be exactly two digits.
10075 @end table
10077 Note that @code{\s} doesn't produce an input token in @code{gtroff}.  As
10078 a consequence, it can be used in requests like @code{mc} (which expects
10079 a single character as an argument) to change the font on the fly:
10081 @Example
10082 .mc \s[20]x\s[0]
10083 @endExample
10085 @xref{Fractional Type Sizes}, for yet another syntactical form of using
10086 the @code{\s} escape.
10087 @endDefreq
10089 @Defreq {sizes, s1 s2 @dots{} sn [0]}
10090 Some devices may only have certain permissible sizes, in which case
10091 @code{gtroff} rounds to the nearest permissible size.  The @file{DESC}
10092 file specifies which sizes are permissible for the device.
10094 Use the @code{sizes} request to change the permissible sizes for the
10095 current output device.  Arguments are in scaled points; the
10096 @code{sizescale} line in the @file{DESC} file for the output device
10097 provides the scaling factor.  For example, if the scaling factor is
10098 1000, then the value 12000 is 12@tie{}points.
10100 Each argument can be a single point size (such as @samp{12000}), or a
10101 range of sizes (such as @samp{4000-72000}).  You can optionally end the
10102 list with a zero.
10103 @endDefreq
10105 @DefreqList {vs, [@Var{space}]}
10106 @DefreqItem {vs, @t{+}@Var{space}}
10107 @DefreqItem {vs, @t{-}@Var{space}}
10108 @DefregListEnd {.v}
10109 @cindex changing vertical line spacing (@code{vs})
10110 @cindex vertical line spacing, changing (@code{vs})
10111 @cindex vertical line spacing register (@code{.v})
10112 Change (increase, decrease) the vertical spacing by @var{space}.  The
10113 default scaling indicator is @samp{p}.
10115 If @code{vs} is called without an argument, the vertical spacing is
10116 reset to the previous value before the last call to @code{vs}.
10118 @cindex @code{.V} register, and @code{vs}
10119 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
10120 negative; the vertical spacing is then set to smallest positive value,
10121 the vertical resolution (as given in the @code{.V} register).
10123 Note that @w{@samp{.vs 0}} isn't saved in a diversion since it doesn't
10124 result in a vertical motion.  You explicitly have to repeat this command
10125 before inserting the diversion.
10127 The read-only number register @code{.v} contains the current vertical
10128 spacing; it is associated with the current environment
10129 (@pxref{Environments}).
10130 @endDefreq
10132 @cindex vertical line spacing, effective value
10133 The effective vertical line spacing consists of four components.
10134 Breaking a line causes the following actions (in the given order).
10136 @itemize @bullet
10137 @item
10138 @cindex extra pre-vertical line space (@code{\x})
10139 @cindex line space, extra pre-vertical (@code{\x})
10140 Move the current point vertically by the @dfn{extra pre-vertical line
10141 space}.  This is the minimum value of all @code{\x} escapes with a
10142 negative argument in the current output line.
10144 @item
10145 Move the current point vertically by the vertical line spacing as set
10146 with the @code{vs} request.
10148 @item
10149 Output the current line.
10151 @item
10152 @cindex extra post-vertical line space (@code{\x})
10153 @cindex line space, extra post-vertical (@code{\x})
10154 Move the current point vertically by the @dfn{extra post-vertical line
10155 space}.  This is the maximum value of all @code{\x} escapes with a
10156 positive argument in the line which has just been output.
10158 @item
10159 @cindex post-vertical line spacing
10160 @cindex line spacing, post-vertical (@code{pvs})
10161 Move the current point vertically by the @dfn{post-vertical line
10162 spacing} as set with the @code{pvs} request.
10163 @end itemize
10165 @cindex double-spacing (@code{vs}, @code{pvs})
10166 It is usually better to use @code{vs} or @code{pvs} instead of @code{ls}
10167 to produce double-spaced documents: @code{vs} and @code{pvs} have a
10168 finer granularity for the inserted vertical space compared to @code{ls};
10169 furthermore, certain preprocessors assume single-spacing.
10171 @xref{Manipulating Spacing}, for more details on the @code{\x} escape
10172 and the @code{ls} request.
10174 @DefreqList {pvs, [@Var{space}]}
10175 @DefreqItem {pvs, @t{+}@Var{space}}
10176 @DefreqItem {pvs, @t{-}@Var{space}}
10177 @DefregListEnd {.pvs}
10178 @cindex @code{ls} request, alternative to (@code{pvs})
10179 @cindex post-vertical line spacing, changing (@code{pvs})
10180 @cindex post-vertical line spacing register (@code{.pvs})
10181 Change (increase, decrease) the post-vertical spacing by @var{space}.
10182 The default scaling indicator is @samp{p}.
10184 If @code{pvs} is called without an argument, the post-vertical spacing
10185 is reset to the previous value before the last call to @code{pvs}.
10187 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
10188 zero or negative; the vertical spacing is then set to zero.
10190 The read-only number register @code{.pvs} contains the current
10191 post-vertical spacing; it is associated with the current environment
10192 (@pxref{Environments}).
10193 @endDefreq
10195 @c ---------------------------------------------------------------------
10197 @node Fractional Type Sizes,  , Changing Type Sizes, Sizes
10198 @subsection Fractional Type Sizes
10199 @cindex fractional type sizes
10200 @cindex fractional point sizes
10201 @cindex type sizes, fractional
10202 @cindex point sizes, fractional
10203 @cindex sizes, fractional
10205 @cindex @code{s} unit
10206 @cindex unit, @code{s}
10207 @cindex @code{z} unit
10208 @cindex unit, @code{z}
10209 @cindex @code{ps} request, with fractional type sizes
10210 @cindex @code{cs} request, with fractional type sizes
10211 @cindex @code{tkf} request, with fractional type sizes
10212 @cindex @code{\H}, with fractional type sizes
10213 @cindex @code{\s}, with fractional type sizes
10214 A @dfn{scaled point} is equal to @math{1/@var{sizescale}} points, where
10215 @var{sizescale} is specified in the @file{DESC} file (1@tie{}by
10216 default).  There is a new scale indicator @samp{z} which has the effect
10217 of multiplying by @var{sizescale}.  Requests and escape sequences in
10218 @code{gtroff} interpret arguments that represent a point size as being
10219 in units of scaled points, but they evaluate each such argument using a
10220 default scale indicator of @samp{z}.  Arguments treated in this way are
10221 the argument to the @code{ps} request, the third argument to the
10222 @code{cs} request, the second and fourth arguments to the @code{tkf}
10223 request, the argument to the @code{\H} escape sequence, and those
10224 variants of the @code{\s} escape sequence that take a numeric expression
10225 as their argument (see below).
10227 For example, suppose @var{sizescale} is@tie{}1000; then a scaled point
10228 is equivalent to a millipoint; the request @w{@samp{.ps 10.25}} is
10229 equivalent to @w{@samp{.ps 10.25z}} and thus sets the point size to
10230 10250@tie{}scaled points, which is equal to 10.25@tie{}points.
10232 @code{gtroff} disallows the use of the @samp{z} scale indicator in
10233 instances where it would make no sense, such as a numeric expression
10234 whose default scale indicator was neither @samp{u} nor @samp{z}.
10235 Similarly it would make no sense to use a scaling indicator other than
10236 @samp{z} or @samp{u} in a numeric expression whose default scale
10237 indicator was @samp{z}, and so @code{gtroff} disallows this as well.
10239 There is also new scale indicator @samp{s} which multiplies by the
10240 number of units in a scaled point.  So, for example, @samp{\n[.ps]s} is
10241 equal to @samp{1m}.  Be sure not to confuse the @samp{s} and @samp{z}
10242 scale indicators.
10244 @Defreg {.ps}
10245 A read-only number register returning the point size in scaled points.
10247 @code{.ps} is associated with the current environment
10248 (@pxref{Environments}).
10249 @endDefreg
10251 @DefregList {.psr}
10252 @DefregListEnd {.sr}
10253 @cindex last-requested point size registers (@code{.psr}, @code{.sr})
10254 @cindex point size registers, last-requested (@code{.psr}, @code{.sr})
10255 @cindex @code{.ps} register, in comparison with @code{.psr}
10256 @cindex @code{.s} register, in comparison with @code{.sr}
10257 The last-requested point size in scaled points is contained in the
10258 @code{.psr} read-only number register.  The last requested point size in
10259 points as a decimal fraction can be found in @code{.sr}.  This is a
10260 string-valued read-only number register.
10262 Note that the requested point sizes are device-independent, whereas the
10263 values returned by the @code{.ps} and @code{.s} registers are not.  For
10264 example, if a point size of 11@dmn{pt} is requested, and a @code{sizes}
10265 request (or a @code{sizescale} line in a @file{DESC} file) specifies
10266 10.95@dmn{pt} instead, this value is actually used.
10268 Both registers are associated with the current environment
10269 (@pxref{Environments}).
10270 @endDefreg
10272 The @code{\s} escape has the following syntax for working with
10273 fractional type sizes:
10275 @table @code
10276 @item \s[@var{n}]
10277 @itemx \s'@var{n}'
10278 Set the point size to @var{n}@tie{}scaled points; @var{n}@tie{}is a
10279 numeric expression with a default scale indicator of @samp{z}.
10281 @item \s[+@var{n}]
10282 @itemx \s[-@var{n}]
10283 @itemx \s+[@var{n}]
10284 @itemx \s-[@var{n}]
10285 @itemx \s'+@var{n}'
10286 @itemx \s'-@var{n}'
10287 @itemx \s+'@var{n}'
10288 @itemx \s-'@var{n}'
10289 Increase or or decrease the point size by @var{n}@tie{}scaled points;
10290 @var{n}@tie{}is a numeric expression (which may start with a minus sign)
10291 with a default scale indicator of @samp{z}.
10292 @end table
10294 @xref{Font Files}.
10297 @c =====================================================================
10299 @node Strings, Conditionals and Loops, Sizes, gtroff Reference
10300 @section Strings
10301 @cindex strings
10303 @code{gtroff} has string variables, which are entirely for user
10304 convenience (i.e.@: there are no built-in strings exept @code{.T}, but
10305 even this is a read-write string variable).
10307 @DefreqList {ds, name [@Var{string}]}
10308 @DefreqItem {ds1, name [@Var{string}]}
10309 @DefescItem {\\*, , n, }
10310 @DefescItem {\\*, @Lparen{}, nm, }
10311 @DefescListEnd {\\*, @Lbrack{}, name arg1 arg2 @dots{}, @Rbrack{}}
10312 @cindex string interpolation (@code{\*})
10313 @cindex string expansion (@code{\*})
10314 @cindex interpolation of strings (@code{\*})
10315 @cindex expansion of strings (@code{\*})
10316 @cindex string arguments
10317 @cindex arguments, of strings
10318 Define and access a string variable @var{name} (one-character
10319 name@tie{}@var{n}, two-character name @var{nm}).  If @var{name} already
10320 exists, @code{ds} overwrites the previous definition.  Only the syntax
10321 form using brackets can take arguments which are handled identically to
10322 macro arguments; the single exception is that a closing bracket as an
10323 argument must be enclosed in double quotes.  @xref{Request and Macro
10324 Arguments}, and @ref{Parameters}.
10326 Example:
10328 @Example
10329 .ds foo a \\$1 test
10331 This is \*[foo nice].
10332     @result{} This is a nice test.
10333 @endExample
10335 The @code{\*} escape @dfn{interpolates} (expands in-place) a
10336 previously-defined string variable.  To be more precise, the stored
10337 string is pushed onto the input stack which is then parsed by
10338 @code{gtroff}.  Similar to number registers, it is possible to nest
10339 strings, i.e., string variables can be called within string variables.
10341 If the string named by the @code{\*} escape does not exist, it is
10342 defined as empty, and a warning of type @samp{mac} is emitted (see
10343 @ref{Debugging}, for more details).
10345 @cindex comments, with @code{ds}
10346 @cindex @code{ds} request, and comments
10347 @strong{Caution:} Unlike other requests, the second argument to the
10348 @code{ds} request takes up the entire line including trailing spaces.
10349 This means that comments on a line with such a request can introduce
10350 unwanted space into a string.
10352 @Example
10353 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d \" UNIX trademark
10354 @endExample
10356 @noindent
10357 Instead the comment should be put on another line or have the comment
10358 escape adjacent with the end of the string.
10360 @Example
10361 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d\"  UNIX trademark
10362 @endExample
10364 @cindex trailing quotes
10365 @cindex quotes, trailing
10366 @cindex leading spaces with @code{ds}
10367 @cindex spaces with @code{ds}
10368 @cindex @code{ds} request, and leading spaces
10369 To produce leading space the string can be started with a double quote.
10370 No trailing quote is needed; in fact, any trailing quote is included in
10371 your string.
10373 @Example
10374 .ds sign "           Yours in a white wine sauce,
10375 @endExample
10377 @cindex multi-line strings
10378 @cindex strings, multi-line
10379 @cindex newline character, in strings, escaping
10380 @cindex escaping newline characters, in strings
10381 Strings are not limited to a single line of text.  A string can span
10382 several lines by escaping the newlines with a backslash.  The resulting
10383 string is stored @emph{without} the newlines.
10385 @Example
10386 .ds foo lots and lots \
10387 of text are on these \
10388 next several lines
10389 @endExample
10391 It is not possible to have real newlines in a string.  To put a single
10392 double quote character into a string, use two consecutive double quote
10393 characters.
10395 The @code{ds1} request turns off compatibility mode while interpreting a
10396 string.  To be more precise, a @dfn{compatibility save} input token is
10397 inserted at the beginning of the string, and a @dfn{compatibility
10398 restore} input token at the end.
10400 @Example
10401 .nr xxx 12345
10402 .ds aa The value of xxx is \\n[xxx].
10403 .ds1 bb The value of xxx ix \\n[xxx].
10405 .cp 1
10407 \*(aa
10408     @result{} warning: number register `[' not defined
10409     @result{} The value of xxx is 0xxx].
10410 \*(bb
10411     @result{} The value of xxx ix 12345.
10412 @endExample
10414 @cindex name space, common, of macros, diversions, and strings
10415 @cindex common name space of macros, diversions, and strings
10416 @cindex macros, shared name space with strings and diversions
10417 @cindex strings, shared name space with macros and diversions
10418 @cindex diversions, shared name space with macros and strings
10419 Strings, macros, and diversions (and boxes) share the same name space.
10420 Internally, even the same mechanism is used to store them.  This has
10421 some interesting consequences.  For example, it is possible to call a
10422 macro with string syntax and vice versa.
10424 @Example
10425 .de xxx
10426 a funny test.
10428 This is \*[xxx]
10429     @result{} This is a funny test.
10431 .ds yyy a funny test
10432 This is
10433 .yyy
10434     @result{} This is a funny test.
10435 @endExample
10437 In particular, interpolating a string does not hide existing macro
10438 arguments.  Thus in a macro, a more efficient way of doing
10440 @Example
10441 .xx \\$@@
10442 @endExample
10444 @noindent
10447 @Example
10448 \\*[xx]\\
10449 @endExample
10451 @noindent
10452 Note that the latter calling syntax doesn't change the value of
10453 @code{\$0}, which is then inherited from the calling macro.
10455 Diversions and boxes can be also called with string syntax.
10457 Another consequence is that you can copy one-line diversions or boxes to
10458 a string.
10460 @Example
10461 .di xxx
10462 a \fItest\fR
10465 .ds yyy This is \*[xxx]\c
10466 \*[yyy].
10467     @result{} @r{This is a }@i{test}.
10468 @endExample
10470 @noindent
10471 As the previous example shows, it is possible to store formatted output
10472 in strings.  The @code{\c} escape prevents the insertion of an
10473 additional blank line in the output.
10475 Copying diversions longer than a single output line produces unexpected
10476 results.
10478 @Example
10479 .di xxx
10480 a funny
10482 test
10485 .ds yyy This is \*[xxx]\c
10486 \*[yyy].
10487     @result{} test This is a funny.
10488 @endExample
10490 Usually, it is not predictable whether a diversion contains one or more
10491 output lines, so this mechanism should be avoided.  With @acronym{UNIX}
10492 @code{troff}, this was the only solution to strip off a final newline
10493 from a diversion.  Another disadvantage is that the spaces in the copied
10494 string are already formatted, making them unstretchable.  This can cause
10495 ugly results.
10497 @cindex stripping final newline in diversions
10498 @cindex diversion, stripping final newline
10499 @cindex final newline, stripping in diversions
10500 @cindex newline, final, stripping in diversions
10501 @cindex horizontal space, unformatting
10502 @cindex space, horizontal, unformatting
10503 @cindex unformatting horizontal space
10504 A clean solution to this problem is available in GNU @code{troff}, using
10505 the requests @code{chop} to remove the final newline of a diversion, and
10506 @code{unformat} to make the horizontal spaces stretchable again.
10508 @Example
10509 .box xxx
10510 a funny
10512 test
10514 .box
10515 .chop xxx
10516 .unformat xxx
10517 This is \*[xxx].
10518     @result{} This is a funny test.
10519 @endExample
10521 @xref{Gtroff Internals}, for more information.
10522 @endDefreq
10524 @DefreqList {as, name [@Var{string}]}
10525 @DefreqListEnd {as1, name [@Var{string}]}
10526 @cindex appending to a string (@code{as})
10527 @cindex string, appending (@code{as})
10528 The @code{as} request is similar to @code{ds} but appends @var{string}
10529 to the string stored as @var{name} instead of redefining it.  If
10530 @var{name} doesn't exist yet, it is created.
10532 @Example
10533 .as sign " with shallots, onions and garlic,
10534 @endExample
10536 The @code{as1} request is similar to @code{as}, but compatibility mode
10537 is switched off while the appended string is interpreted.  To be more
10538 precise, a @dfn{compatibility save} input token is inserted at the
10539 beginning of the appended string, and a @dfn{compatibility restore}
10540 input token at the end.
10541 @endDefreq
10543 Rudimentary string manipulation routines are given with the next two
10544 requests.
10546 @Defreq {substring, str n1 [@Var{n2}]}
10547 @cindex substring (@code{substring})
10548 Replace the string named @var{str} with the substring defined by the
10549 indices @var{n1} and@tie{}@var{n2}.  The first character in the string
10550 has index@tie{}0.  If @var{n2} is omitted, it is taken to be equal to
10551 the string's length.  If the index value @var{n1} or @var{n2} is
10552 negative, it is counted from the end of the string, going backwards: The
10553 last character has index@tie{}@minus{}1, the character before the last
10554 character has index@tie{}@minus{}2, etc.
10556 @Example
10557 .ds xxx abcdefgh
10558 .substring xxx 1 -4
10559 \*[xxx]
10560     @result{} bcde
10561 @endExample
10562 @endDefreq
10564 @Defreq {length, reg str}
10565 @cindex length of a string (@code{length})
10566 @cindex string, length of (@code{length})
10567 @cindex @code{length} request, and copy-in mode
10568 @cindex copy-in mode, and @code{length} request
10569 @cindex mode, copy-in, and @code{length} request
10570 Compute the number of characters of @var{str} and return it in the
10571 number register @var{reg}.  If @var{reg} doesn't exist, it is created.
10572 @code{str} is read in copy mode.
10574 @Example
10575 .ds xxx abcd\h'3i'efgh
10576 .length yyy \*[xxx]
10577 \n[yyy]
10578     @result{} 14
10579 @endExample
10580 @endDefreq
10582 @Defreq {rn, xx yy}
10583 @cindex renaming request (@code{rn})
10584 @cindex request, renaming (@code{rn})
10585 @cindex renaming macro (@code{rn})
10586 @cindex macro, renaming (@code{rn})
10587 @cindex renaming string (@code{rn})
10588 @cindex string, renaming (@code{rn})
10589 @cindex renaming diversion (@code{rn})
10590 @cindex diversion, renaming (@code{rn})
10591 Rename the request, macro, diversion, or string @var{xx} to @var{yy}.
10592 @endDefreq
10594 @Defreq {rm, xx}
10595 @cindex removing request (@code{rm})
10596 @cindex request, removing (@code{rm})
10597 @cindex removing macro (@code{rm})
10598 @cindex macro, removing (@code{rm})
10599 @cindex removing string (@code{rm})
10600 @cindex string, removing (@code{rm})
10601 @cindex removing diversion (@code{rm})
10602 @cindex diversion, removing (@code{rm})
10603 Remove the request, macro, diversion, or string @var{xx}.  @code{gtroff}
10604 treats subsequent invocations as if the object had never been defined.
10605 @endDefreq
10607 @anchor{als}
10608 @Defreq {als, new old}
10609 @cindex alias, string, creating (@code{als})
10610 @cindex alias, macro, creating (@code{als})
10611 @cindex alias, diversion, creating (@code{als})
10612 @cindex creating alias, for string (@code{als})
10613 @cindex creating alias, for macro (@code{als})
10614 @cindex creating alias, for diversion (@code{als})
10615 @cindex string, creating alias (@code{als})
10616 @cindex macro, creating alias (@code{als})
10617 @cindex diversion, creating alias (@code{als})
10618 Create an alias named @var{new} for the request, string, macro, or
10619 diversion object named @var{old}.  The new name and the old name are
10620 exactly equivalent (it is similar to a hard rather than a soft link).  If
10621 @var{old} is undefined, @code{gtroff} generates a warning of type
10622 @samp{mac} and ignores the request.
10624 To understand how the @code{als} request works it is probably best to
10625 think of two different pools: one pool for objects (macros, strings,
10626 etc.), and another one for names.  As soon as an object is defined,
10627 @code{gtroff} adds it to the object pool, adds its name to the name
10628 pool, and creates a link between them.  When @code{als} creates an
10629 alias, it adds a new name to the name pool which gets linked to the same
10630 object as the old name.
10632 Now consider this example.
10634 @Example
10635 .de foo
10638 .als bar foo
10640 .de bar
10641 .  foo
10644 .bar
10645     @result{} input stack limit exceeded
10646 @endExample
10648 @noindent
10649 The definition of macro @code{bar} replaces the old object this name is
10650 linked to.  However, the alias to @code{foo} is still active!  In
10651 other words, @code{foo} is still linked to the same object as
10652 @code{bar}, and the result of calling @code{bar} is an infinite,
10653 recursive loop which finally leads to an error.
10655 @cindex alias, string, removing (@code{rm})
10656 @cindex alias, macro, removing (@code{rm})
10657 @cindex alias, diversion, removing (@code{rm})
10658 @cindex removing alias, for string (@code{rm})
10659 @cindex removing alias, for macro (@code{rm})
10660 @cindex removing alias, for diversion (@code{rm})
10661 @cindex string, removing alias (@code{rm})
10662 @cindex macro, removing alias (@code{rm})
10663 @cindex diversion, removing alias (@code{rm})
10664 To undo an alias, simply call @code{rm} on the aliased name.  The object
10665 itself is not destroyed until there are no more aliases.
10666 @endDefreq
10668 @Defreq {chop, xx}
10669 Remove (chop) the last character from the macro, string, or diversion
10670 named @var{xx}.  This is useful for removing the newline from the end of
10671 diversions that are to be interpolated as strings.  This command can be
10672 used repeatedly; see @ref{Gtroff Internals}, for details on nodes
10673 inserted additionally by @code{gtroff}.
10674 @endDefreq
10676 @xref{Identifiers}, and @ref{Comments}.
10679 @c =====================================================================
10681 @node Conditionals and Loops, Writing Macros, Strings, gtroff Reference
10682 @section Conditionals and Loops
10683 @cindex conditionals and loops
10684 @cindex loops and conditionals
10686 @menu
10687 * Operators in Conditionals::
10688 * if-else::
10689 * while::
10690 @end menu
10692 @c ---------------------------------------------------------------------
10694 @node Operators in Conditionals, if-else, Conditionals and Loops, Conditionals and Loops
10695 @subsection Operators in Conditionals
10697 @cindex @code{if} request, operators to use with
10698 @cindex @code{ie} request, operators to use with
10699 @cindex @code{while} request, operators to use with
10700 In @code{if}, @code{ie}, and @code{while} requests, there are several
10701 more operators available:
10703 @table @code
10704 @item e
10705 @itemx o
10706 True if the current page is even or odd numbered (respectively).
10708 @item n
10709 @cindex conditional output for terminal (TTY)
10710 @cindex TTY, conditional output for
10711 @cindex terminal, conditional output for
10712 True if the document is being processed in nroff mode (i.e., the
10713 @code{.nroff} command has been issued).  @xref{Troff and Nroff Mode}.
10715 @item t
10716 True if the document is being processed in troff mode (i.e., the
10717 @code{.troff} command has been issued).  @xref{Troff and Nroff Mode}.
10719 @item v
10720 Always false.  This condition is for compatibility with other
10721 @code{troff} versions only (identifying a @code{-Tversatec} device).
10723 @item '@var{xxx}'@var{yyy}'
10724 True if the output produced by @var{xxx} is equal to the output produced
10725 by @var{yyy}.  Other characters can be used in place of the single
10726 quotes; the same set of delimiters as for the @code{\D} escape is used
10727 (@pxref{Escapes}).  @code{gtroff} formats @var{xxx} and @var{yyy} in
10728 separate environments; after the comparison the resulting data is
10729 discarded.
10731 @Example
10732 .ie "|"\fR|\fP" \
10733 true
10734 .el \
10735 false
10736     @result{} true
10737 @endExample
10739 @noindent
10740 The resulting motions, glyph sizes, and fonts have to
10741 match,@footnote{The created output nodes must be identical.
10742 @xref{Gtroff Internals}.} and not the individual motion, size, and font
10743 requests.  In the previous example, @samp{|} and @samp{\fR|\fP} both
10744 result in a roman @samp{|} glyph with the same point size and at the
10745 same location on the page, so the strings are equal.  If
10746 @samp{.ft@tie{}I} had been added before the @samp{.ie}, the result would
10747 be ``false'' because (the first) @samp{|} produces an italic @samp{|}
10748 rather than a roman one.
10750 @cindex string comparison
10751 @cindex comparison of strings
10752 To compare strings without processing, surround the data with @code{\?}.
10754 @Example
10755 .ie "\?|\?"\?\fR|\fP\?" \
10756 true
10757 .el \
10758 false
10759     @result{} false
10760 @endExample
10762 @cindex @code{\?}, and copy-in mode
10763 @cindex copy-in mode, and @code{\?}
10764 @cindex mode, copy-in, and @code{\?}
10765 @noindent
10766 Since data protected with @code{\?} is read in copy-in mode it is even
10767 possible to use incomplete input without causing an error.
10769 @Example
10770 .ds a \[
10771 .ds b \[
10772 .ie '\?\*a\?'\?\*b\?' \
10773 true
10774 .el \
10775 false
10776     @result{} true
10777 @endExample
10779 @item r @var{xxx}
10780 True if there is a number register named @var{xxx}.
10782 @item d @var{xxx}
10783 True if there is a string, macro, diversion, or request named @var{xxx}.
10785 @item m @var{xxx}
10786 True if there is a color named @var{xxx}.
10788 @item c @var{g}
10789 True if there is a glyph @var{g} available@footnote{The name of this
10790 conditional operator is a misnomer since it tests names of output
10791 glyphs.}; @var{g} is either an @acronym{ASCII} character or a special
10792 character (@code{\N'@var{xxx}'}, @code{\(@var{gg}} or
10793 @code{\[@var{ggg}]}); the condition is also true if @var{g} has been
10794 defined by the @code{char} request.
10796 @item F @var{font}
10797 True if a font named @var{font} exists.  @var{font} is handled as if it
10798 was opened with the @code{ft} request (this is, font translation and
10799 styles are applied), without actually mounting it.
10801 This test doesn't load the complete font but only its header to verify
10802 its validity.
10804 @item S @var{style}
10805 True if style @var{style} has been registered.  Font translation is
10806 applied.
10807 @end table
10809 Note that these operators can't be combined with other operators like
10810 @samp{:} or @samp{&}; only a leading @samp{!} (without whitespace
10811 between the exclamation mark and the operator) can be used to negate the
10812 result.
10814 @Example
10815 .nr xxx 1
10816 .ie !r xxx \
10817 true
10818 .el \
10819 false
10820     @result{} false
10821 @endExample
10823 A whitespace after @samp{!} always evaluates to zero (this bizarre
10824 behaviour is due to compatibility with @acronym{UNIX} @code{troff}).
10826 @Example
10827 .nr xxx 1
10828 .ie ! r xxx \
10829 true
10830 .el \
10831 false
10832     @result{} r xxx true
10833 @endExample
10835 It is possible to omit the whitespace before the argument to the
10836 @samp{r}, @samp{d}, and @samp{c} operators.
10838 @xref{Expressions}.
10840 @c ---------------------------------------------------------------------
10842 @node if-else, while, Operators in Conditionals, Conditionals and Loops
10843 @subsection if-else
10844 @cindex if-else
10846 @code{gtroff} has if-then-else constructs like other languages, although
10847 the formatting can be painful.
10849 @Defreq {if, expr anything}
10851 Evaluate the expression @var{expr}, and executes @var{anything} (the
10852 remainder of the line) if @var{expr} evaluates to a value greater than
10853 zero (true).  @var{anything} is interpreted as though it was on a line
10854 by itself (except that leading spaces are swallowed).
10855 @xref{Expressions}, for more info.
10857 @Example
10858 .nr xxx 1
10859 .nr yyy 2
10860 .if ((\n[xxx] == 1) & (\n[yyy] == 2)) true
10861     @result{} true
10862 @endExample
10863 @endDefreq
10865 @Defreq {nop, anything}
10866 Executes @var{anything}.  This is similar to @code{.if@tie{}1}.
10867 @endDefreq
10869 @DefreqList {ie, expr anything}
10870 @DefreqListEnd {el, anything}
10871 Use the @code{ie} and @code{el} requests to write an if-then-else.  The
10872 first request is the `if' part and the latter is the `else' part.
10874 @Example
10875 .ie n .ls 2 \" double-spacing in nroff
10876 .el   .ls 1 \" single-spacing in troff
10877 @endExample
10878 @endDefreq
10880 @c there is a bug in makeinfo <= 4.1a: you can't have `@{' as an argument
10881 @c to @deffn
10883 @c and in 4.2 you still can't use @{ in macros.
10885 @c @DefescList {\@{, , , }
10886 @c @DefescListEnd {\@}, , , }
10887 @deffn Escape @t{\@{}
10888 @deffnx Escape @t{\@}}
10889 @esindex \@{
10890 @esindex \@}
10891 @cindex begin of conditional block (@code{\@{})
10892 @cindex end of conditional block (@code{\@}})
10893 @cindex conditional block, begin (@code{\@{})
10894 @cindex conditional block, end (@code{\@}})
10895 @cindex block, conditional, begin (@code{\@{})
10896 @cindex block, condititional, end (@code{\@}})
10897 In many cases, an if (or if-else) construct needs to execute more than
10898 one request.  This can be done using the @code{\@{} and @code{\@}}
10899 escapes.  The following example shows the possible ways to use these
10900 escapes (note the position of the opening and closing braces).
10902 @Example
10903 .ie t \@{\
10904 .    ds lq ``
10905 .    ds rq ''
10906 .\@}
10907 .el \
10908 .\@{\
10909 .    ds lq "
10910 .    ds rq "\@}
10911 @endExample
10912 @c @endDefesc
10913 @end deffn
10915 @xref{Expressions}.
10917 @c ---------------------------------------------------------------------
10919 @node while,  , if-else, Conditionals and Loops
10920 @subsection while
10921 @cindex while
10923 @code{gtroff} provides a looping construct using the @code{while}
10924 request, which is used much like the @code{if} (and related) requests.
10926 @Defreq {while, expr anything}
10927 Evaluate the expression @var{expr}, and repeatedly execute
10928 @var{anything} (the remainder of the line) until @var{expr} evaluates
10929 to@tie{}0.
10931 @Example
10932 .nr a 0 1
10933 .while (\na < 9) \@{\
10934 \n+a,
10935 .\@}
10936 \n+a
10937     @result{} 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
10938 @endExample
10940 Some remarks.
10942 @cindex @code{de} request, and @code{while}
10943 @itemize @bullet
10944 @item
10945 The body of a @code{while} request is treated like the body of a
10946 @code{de} request: @code{gtroff} temporarily stores it in a macro which
10947 is deleted after the loop has been exited.  It can considerably slow
10948 down a macro if the body of the @code{while} request (within the macro)
10949 is large.  Each time the macro is executed, the @code{while} body is
10950 parsed and stored again as a temporary macro.
10952 @Example
10953 .de xxx
10954 .  nr num 10
10955 .  while (\\n[num] > 0) \@{\
10956 .    \" many lines of code
10957 .    nr num -1
10958 .  \@}
10960 @endExample
10962 @cindex recursive macros
10963 @cindex macros, recursive
10964 @noindent
10965 The traditional and ofter better solution (@acronym{UNIX} @code{troff}
10966 doesn't have the @code{while} request) is to use a recursive macro
10967 instead which is parsed only once during its definition.
10969 @Example
10970 .de yyy
10971 .  if (\\n[num] > 0) \@{\
10972 .    \" many lines of code
10973 .    nr num -1
10974 .    yyy
10975 .  \@}
10978 .de xxx
10979 .  nr num 10
10980 .  yyy
10982 @endExample
10984 @noindent
10985 Note that the number of available recursion levels is set to@tie{}1000
10986 (this is a compile-time constant value of @code{gtroff}).
10988 @item
10989 The closing brace of a @code{while} body must end a line.
10991 @Example
10992 .if 1 \@{\
10993 .  nr a 0 1
10994 .  while (\n[a] < 10) \@{\
10995 .    nop \n+[a]
10996 .\@}\@}
10997     @result{} unbalanced \@{ \@}
10998 @endExample
10999 @end itemize
11000 @endDefreq
11002 @Defreq {break, }
11003 @cindex @code{while} request, confusing with @code{br}
11004 @cindex @code{break} request, in a @code{while} loop
11005 @cindex @code{continue} request, in a @code{while} loop
11006 Break out of a @code{while} loop.  Be sure not to confuse this with the
11007 @code{br} request (causing a line break).
11008 @endDefreq
11010 @Defreq {continue, }
11011 Finish the current iteration of a @code{while} loop, immediately
11012 restarting the next iteration.
11013 @endDefreq
11015 @xref{Expressions}.
11018 @c =====================================================================
11020 @node Writing Macros, Page Motions, Conditionals and Loops, gtroff Reference
11021 @section Writing Macros
11022 @cindex writing macros
11023 @cindex macros, writing
11025 A @dfn{macro} is a collection of text and embedded commands which can be
11026 invoked multiple times.  Use macros to define common operations.
11027 @xref{Strings}, for a (limited) alternative syntax to call macros.
11029 @DefreqList {de, name [@Var{end}]}
11030 @DefreqItem {de1, name [@Var{end}]}
11031 @DefreqItem {dei, name [@Var{end}]}
11032 @DefreqListEnd {dei1, name [@Var{end}]}
11033 Define a new macro named @var{name}.  @code{gtroff} copies subsequent
11034 lines (starting with the next one) into an internal buffer until it
11035 encounters the line @samp{..} (two dots).  The optional second argument
11036 to @code{de} changes this to a macro to @samp{.@var{end}}.
11038 There can be whitespace after the first dot in the line containing the
11039 ending token (either @samp{.} or macro @samp{@var{end}}).  Don't insert
11040 a tab character immediately after the @samp{..}, otherwise it isn't
11041 recognized as the end-of-macro symbol.@footnote{While it is possible to
11042 define and call a macro @samp{.} with
11044 @Example
11045 .de .
11046 .  tm foo
11049 ..    \" This calls macro `.'!
11050 @endExample
11052 @noindent
11053 you can't use this as the end-of-macro macro: during a macro definition,
11054 @samp{..} is never handled as a call to @samp{.}, even if you say
11055 @samp{.de foo .} explicitly.}
11057 Here a small example macro called @samp{P} which causes a break and
11058 inserts some vertical space.  It could be used to separate paragraphs.
11060 @Example
11061 .de P
11062 .  br
11063 .  sp .8v
11065 @endExample
11067 The following example defines a macro within another.  Remember that
11068 expansion must be protected twice; once for reading the macro and once
11069 for executing.
11071 @Example
11072 \# a dummy macro to avoid a warning
11073 .de end
11076 .de foo
11077 .  de bar end
11078 .    nop \f[B]Hallo \\\\$1!\f[]
11079 .  end
11082 .foo
11083 .bar Joe
11084     @result{} @b{Hallo Joe!}
11085 @endExample
11087 @noindent
11088 Since @code{\f} has no expansion, it isn't necessary to protect its
11089 backslash.  Had we defined another macro within @code{bar} which takes a
11090 parameter, eight backslashes would be necessary before @samp{$1}.
11092 The @code{de1} request turns off compatibility mode while executing the
11093 macro.  On entry, the current compatibility mode is saved and restored
11094 at exit.
11096 @Example
11097 .nr xxx 12345
11099 .de aa
11100 The value of xxx is \\n[xxx].
11102 .de1 bb
11103 The value of xxx ix \\n[xxx].
11106 .cp 1
11109     @result{} warning: number register `[' not defined
11110     @result{} The value of xxx is 0xxx].
11112     @result{} The value of xxx ix 12345.
11113 @endExample
11115 The @code{dei} request defines a macro indirectly.  That is, it expands
11116 strings whose names are @var{name} or @var{end} before performing the
11117 append.
11119 This:
11121 @Example
11122 .ds xx aa
11123 .ds yy bb
11124 .dei xx yy
11125 @endExample
11127 @noindent
11128 is equivalent to:
11130 @Example
11131 .de aa bb
11132 @endExample
11134 The @code{dei1} request is similar to @code{dei} but with compatibility
11135 mode switched off during execution of the defined macro.
11137 If compatibility mode is on, @code{de} (and @code{dei}) behave similar
11138 to @code{de1} (and @code{dei1}): A `compatibility save' token is
11139 inserted at the beginning, and a `compatibility restore' token at the
11140 end, with compatibility mode switched on during execution.  @xref{Gtroff
11141 Internals}, for more information on switching compatibility mode on and
11142 off in a single document.
11144 @pindex trace.tmac
11145 Using @file{trace.tmac}, you can trace calls to @code{de} and
11146 @code{de1}.
11148 Note that macro identifiers are shared with identifiers for strings and
11149 diversions.
11151 @xref{als,,the description of the @code{als} request}, for possible
11152 pitfalls if redefining a macro which has been aliased.
11153 @endDefreq
11155 @DefreqList {am, name [@Var{end}]}
11156 @DefreqItem {am1, name [@Var{end}]}
11157 @DefreqItem {ami, name [@Var{end}]}
11158 @DefreqListEnd {ami1, name [@Var{end}]}
11159 @cindex appending to a macro (@code{am})
11160 @cindex macro, appending (@code{am})
11161 Works similarly to @code{de} except it appends onto the macro named
11162 @var{name}.  So, to make the previously defined @samp{P} macro actually
11163 do indented instead of block paragraphs, add the necessary code to the
11164 existing macro like this:
11166 @Example
11167 .am P
11168 .ti +5n
11170 @endExample
11172 The @code{am1} request turns off compatibility mode while executing the
11173 appended macro piece.  To be more precise, a @dfn{compatibility save}
11174 input token is inserted at the beginning of the appended code, and a
11175 @dfn{compatibility restore} input token at the end.
11177 The @code{ami} request appends indirectly, meaning that @code{gtroff}
11178 expands strings whose names are @var{name} or @var{end} before
11179 performing the append.
11181 The @code{ami1} request is similar to @code{ami} but compatibility mode
11182 is switched off during execution of the defined macro.
11184 @pindex trace.tmac
11185 Using @file{trace.tmac}, you can trace calls to @code{am} and
11186 @code{am1}.
11187 @endDefreq
11189 @xref{Strings}, for the @code{als} and @code{rn} request to create an
11190 alias and rename a macro, respectively.
11192 The @code{de}, @code{am}, @code{di}, @code{da}, @code{ds}, and @code{as}
11193 requests (together with its variants) only create a new object if the
11194 name of the macro, diversion or string diversion is currently undefined
11195 or if it is defined to be a request; normally they modify the value of
11196 an existing object.
11198 @Defreq {return, [@Var{anything}]}
11199 Exit a macro, immediately returning to the caller.
11201 If called with an argument, exit twice, namely the current macro and the
11202 macro one level higher.  This is used to define a wrapper macro for
11203 @code{return} in @file{trace.tmac}.
11204 @endDefreq
11206 @menu
11207 * Copy-in Mode::
11208 * Parameters::
11209 @end menu
11211 @c ---------------------------------------------------------------------
11213 @node Copy-in Mode, Parameters, Writing Macros, Writing Macros
11214 @subsection Copy-in Mode
11215 @cindex copy mode
11216 @cindex copy-in mode
11217 @cindex mode, copy
11218 @cindex mode, copy-in
11220 @cindex @code{\n}, when reading text for a macro
11221 @cindex @code{\$}, when reading text for a macro
11222 @cindex @code{\*}, when reading text for a macro
11223 @cindex @code{\\}, when reading text for a macro
11224 @cindex \@key{RET}, when reading text for a macro
11225 When @code{gtroff} reads in the text for a macro, string, or diversion,
11226 it copies the text (including request lines, but excluding escapes) into
11227 an internal buffer.  Escapes are converted into an internal form, except
11228 for @code{\n}, @code{\$}, @code{\*}, @code{\\} and @code{\@key{RET}}
11229 which are evaluated and inserted into the text where the escape was
11230 located.  This is known as @dfn{copy-in} mode or @dfn{copy} mode.
11232 What this means is that you can specify when these escapes are to be
11233 evaluated (either at copy-in time or at the time of use) by insulating
11234 the escapes with an extra backslash.  Compare this to the @code{\def}
11235 and @code{\edef} commands in @TeX{}.
11237 The following example prints the numbers 20 and@tie{}10:
11239 @Example
11240 .nr x 20
11241 .de y
11242 .nr x 10
11243 \&\nx
11244 \&\\nx
11247 @endExample
11249 @c ---------------------------------------------------------------------
11251 @node Parameters,  , Copy-in Mode, Writing Macros
11252 @subsection Parameters
11253 @cindex parameters
11255 The arguments to a macro or string can be examined using a variety of
11256 escapes.
11258 @Defreg {.$}
11259 @cindex number of arguments register (@code{.$})
11260 The number of arguments passed to a macro or string.  This is a
11261 read-only number register.
11263 Note that the @code{shift} request can change its value.
11264 @endDefreg
11266 Any individual argument can be retrieved with one of the following
11267 escapes:
11269 @DefescList {\\$, , n, }
11270 @DefescItem {\\$, @Lparen{}, nn, }
11271 @DefescListEnd {\\$, @Lbrack{}, nnn, @Rbrack{}}
11272 @cindex copy-in mode, and macro arguments
11273 @cindex mode, copy-in, and macro arguments
11274 @cindex macro, arguments (@code{\$})
11275 @cindex arguments, macro (@code{\$})
11276 Retrieve the @var{n}@dmn{th}, @var{nn}@dmn{th} or @var{nnn}@dmn{th}
11277 argument.  As usual, the first form only accepts a single number (larger
11278 than zero), the second a two-digit number (larger or equal to@tie{}10),
11279 and the third any positive integer value (larger than zero).  Macros and
11280 strings can have an unlimited number of arguments.  Note that due to
11281 copy-in mode, use two backslashes on these in actual use to prevent
11282 interpolation until the macro is actually invoked.
11283 @endDefesc
11285 @Defreq {shift, [@Var{n}]}
11286 Shift the arguments 1@tie{}position, or as many positions as specified
11287 by its argument.  After executing this request, argument@tie{}@var{i}
11288 becomes argument @math{@var{i}-@var{n}}; arguments 1 to@tie{}@var{n} are
11289 no longer available.  Shifting by negative amounts is currently
11290 undefined.
11292 The register @code{.$} is adjusted accordingly.
11293 @endDefreq
11295 @DefescList {\\$*, , , }
11296 @DefescListEnd {\\$@@, , , }
11297 In some cases it is convenient to use all of the arguments at once (for
11298 example, to pass the arguments along to another macro).  The @code{\$*}
11299 escape concatenates all the arguments separated by spaces.  A similar
11300 escape is @code{\$@@}, which concatenates all the arguments with each
11301 surrounded by double quotes, and separated by spaces.  If not in
11302 compatibility mode, the input level of double quotes is preserved (see
11303 @ref{Request and Macro Arguments}).
11304 @endDefesc
11306 @Defesc {\\$^, , , }
11307 Handle the parameters of a macro as if they were an argument to the
11308 @code{ds} or similar requests.
11310 @Example
11311 .de foo
11312 .  tm $1=`\\$1'
11313 .  tm $2=`\\$2'
11314 .  tm $*=`\\$*'
11315 .  tm $@@=`\\$@@'
11316 .  tm $^=`\\$^'
11318 .foo " This is a "test"
11319     @result{} $1=` This is a '
11320     @result{} $2=`test"'
11321     @result{} $*=` This is a  test"'
11322     @result{} $@@=`" This is a " "test""'
11323     @result{} $^=`" This is a "test"'
11324 @endExample
11326 This escape is useful mainly for macro packages like @file{trace.tmac}
11327 which redefines some requests and macros for debugging purposes.
11328 @endDefesc
11330 @Defesc {\\$0, , , }
11331 @cindex macro name register (@code{\$0})
11332 @cindex @code{als} request, and @code{\$0}
11333 The name used to invoke the current macro.  The @code{als} request can
11334 make a macro have more than one name.
11336 If a macro is called as a string (within another macro), the value of
11337 @code{\$0} isn't changed.
11339 @Example
11340 .de foo
11341 .  tm \\$0
11343 .als foo bar
11345 @endExample
11346 @Example
11347 .de aaa
11348 .  foo
11350 .de bbb
11351 .  bar
11353 .de ccc
11354 \\*[foo]\\
11356 .de ddd
11357 \\*[bar]\\
11360 @endExample
11361 @Example
11362 .aaa
11363     @result{} foo
11364 .bbb
11365     @result{} bar
11366 .ccc
11367     @result{} ccc
11368 .ddd
11369     @result{} ddd
11370 @endExample
11371 @endDefesc
11373 @xref{Request and Macro Arguments}.
11376 @c =====================================================================
11378 @node Page Motions, Drawing Requests, Writing Macros, gtroff Reference
11379 @section Page Motions
11380 @cindex page motions
11381 @cindex motions, page
11383 @xref{Manipulating Spacing}, for a discussion of the main request for
11384 vertical motion, @code{sp}.
11386 @DefreqList {mk, [@Var{reg}]}
11387 @DefreqListEnd {rt, [@Var{dist}]}
11388 @cindex marking vertical page location (@code{mk})
11389 @cindex page location, vertical, marking (@code{mk})
11390 @cindex location, vertical, page, marking (@code{mk})
11391 @cindex vertical page location, marking (@code{mk})
11392 @cindex returning to marked vertical page location (@code{rt})
11393 @cindex page location, vertical, returning to marked (@code{rt})
11394 @cindex location, vertical, page, returning to marked (@code{rt})
11395 @cindex vertical page location, returning to marked (@code{rt})
11396 The request @code{mk} can be used to mark a location on a page, for
11397 movement to later.  This request takes a register name as an argument in
11398 which to store the current page location.  With no argument it stores
11399 the location in an internal register.  The results of this can be used
11400 later by the @code{rt} or the @code{sp} request (or the @code{\v}
11401 escape).
11403 The @code{rt} request returns @emph{upwards} to the location marked with
11404 the last @code{mk} request.  If used with an argument, return to a
11405 position which distance from the top of the page is @var{dist} (no
11406 previous call to @code{mk} is necessary in this case).  Default scaling
11407 indicator is @samp{v}.
11409 Here a primitive solution for a two-column macro.
11411 @Example
11412 .nr column-length 1.5i
11413 .nr column-gap 4m
11414 .nr bottom-margin 1m
11416 @endExample
11417 @Example
11418 .de 2c
11419 .  br
11420 .  mk
11421 .  ll \\n[column-length]u
11422 .  wh -\\n[bottom-margin]u 2c-trap
11423 .  nr right-side 0
11426 @endExample
11427 @Example
11428 .de 2c-trap
11429 .  ie \\n[right-side] \@{\
11430 .    nr right-side 0
11431 .    po -(\\n[column-length]u + \\n[column-gap]u)
11432 .    \" remove trap
11433 .    wh -\\n[bottom-margin]u
11434 .  \@}
11435 .  el \@{\
11436 .    \" switch to right side
11437 .    nr right-side 1
11438 .    po +(\\n[column-length]u + \\n[column-gap]u)
11439 .    rt
11440 .  \@}
11443 @endExample
11444 @Example
11445 .pl 1.5i
11446 .ll 4i
11447 This is a small test which shows how the
11448 rt request works in combination with mk.
11451 Starting here, text is typeset in two columns.
11452 Note that this implementation isn't robust
11453 and thus not suited for a real two-column
11454 macro.
11455 @endExample
11457 Result:
11459 @Example
11460 This is a small test which shows how the
11461 rt request works in combination with mk.
11463 Starting  here,    isn't    robust
11464 text is typeset    and   thus  not
11465 in two columns.    suited  for   a
11466 Note that  this    real two-column
11467 implementation     macro.
11468 @endExample
11469 @endDefreq
11471 The following escapes give fine control of movements about the page.
11473 @Defesc {\\v, ', e, '}
11474 @cindex vertical motion (@code{\v})
11475 @cindex motion, vertical (@code{\v})
11476 Move vertically, usually from the current location on the page (if no
11477 absolute position operator @samp{|} is used).  The argument@tie{}@var{e}
11478 specifies the distance to move; positive is downwards and negative
11479 upwards.  The default scaling indicator for this escape is @samp{v}.
11480 Beware, however, that @code{gtroff} continues text processing at the
11481 point where the motion ends, so you should always balance motions to
11482 avoid interference with text processing.
11484 @code{\v} doesn't trigger a trap.  This can be quite useful; for
11485 example, consider a page bottom trap macro which prints a marker in the
11486 margin to indicate continuation of a footnote or something similar.
11487 @endDefesc
11489 There are some special-case escapes for vertical motion.
11491 @Defesc {\\r, , , }
11492 Move upwards@tie{}1@dmn{v}.
11493 @endDefesc
11495 @Defesc {\\u, , , }
11496 Move upwards@tie{}.5@dmn{v}.
11497 @endDefesc
11499 @Defesc {\\d, , , }
11500 Move down@tie{}.5@dmn{v}.
11501 @endDefesc
11503 @Defesc {\\h, ', e, '}
11504 @cindex inserting horizontal space (@code{\h})
11505 @cindex horizontal space (@code{\h})
11506 @cindex space, horizontal (@code{\h})
11507 @cindex horizontal motion (@code{\h})
11508 @cindex motion, horizontal (@code{\h})
11509 Move horizontally, usually from the current location (if no absolute
11510 position operator @samp{|} is used).  The expression@tie{}@var{e}
11511 indicates how far to move: positive is rightwards and negative
11512 leftwards.  The default scaling indicator for this escape is @samp{m}.
11514 This horizontal space is not discarded at the end of a line.  To insert
11515 discardable space of a certain length use the @code{ss} request.
11516 @endDefesc
11518 There are a number of special-case escapes for horizontal motion.
11520 @Defesc {\\@key{SP}, , , }
11521 @cindex space, unbreakable
11522 @cindex unbreakable space
11523 An unbreakable and unpaddable (i.e.@: not expanded during filling)
11524 space.  (Note: This is a backslash followed by a space.)
11525 @endDefesc
11527 @Defesc {\\~, , , }
11528 An unbreakable space that stretches like a normal inter-word space when
11529 a line is adjusted.
11530 @endDefesc
11532 @Defesc {\\|, , , }
11533 A 1/6@dmn{th} em space.  Ignored for TTY output devices (rounded to
11534 zero).
11536 However, if there is a glyph defined in the current font file with name
11537 @code{\|} (note the leading backslash), the width of this glyph is used
11538 instead (even for TTYs).
11539 @endDefesc
11541 @Defesc {\\^, , , }
11542 A 1/12@dmn{th} em space.  Ignored for TTY output devices (rounded to
11543 zero).
11545 However, if there is a glyph defined in the current font file with name
11546 @code{\^} (note the leading backslash), the width of this glyph is used
11547 instead (even for TTYs).
11548 @endDefesc
11550 @Defesc {\\0, , , }
11551 @cindex space, width of a digit (@code{\0})
11552 @cindex digit width space (@code{\0})
11553 A space the size of a digit.
11554 @endDefesc
11556 The following string sets the @TeX{} logo:
11558 @Example
11559 .ds TeX T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
11560 @endExample
11562 @DefescList {\\w, ', text, '}
11563 @DefregItem {st}
11564 @DefregItem {sb}
11565 @DefregItem {rst}
11566 @DefregItem {rsb}
11567 @DefregItem {ct}
11568 @DefregItem {ssc}
11569 @DefregListEnd {skw}
11570 @cindex width escape (@code{\w})
11571 Return the width of the specified @var{text} in basic units.  This
11572 allows horizontal movement based on the width of some arbitrary text
11573 (e.g.@: given as an argument to a macro).
11575 @Example
11576 The length of the string `abc' is \w'abc'u.
11577     @result{} The length of the string `abc' is 72u.
11578 @endExample
11580 Font changes may occur in @var{text} which don't affect current
11581 settings.
11583 After use, @code{\w} sets several registers:
11585 @table @code
11586 @item st
11587 @itemx sb
11588 The highest and lowest point of the baseline, respectively, in
11589 @var{text}.
11591 @item rst
11592 @itemx rsb
11593 Like the @code{st} and @code{sb} registers, but takes account of the
11594 heights and depths of glyphs.  In other words, this gives the highest
11595 and lowest point of @var{text}.  Values below the baseline are negative.
11597 @item ct
11598 Defines the kinds of glyphs occurring in @var{text}:
11600 @table @asis
11601 @item 0
11602 only short glyphs, no descenders or tall glyphs.
11604 @item 1
11605 at least one descender.
11607 @item 2
11608 at least one tall glyph.
11610 @item 3
11611 at least one each of a descender and a tall glyph.
11612 @end table
11614 @item ssc
11615 The amount of horizontal space (possibly negative) that should be added
11616 to the last glyph before a subscript.
11618 @item skw
11619 How far to right of the center of the last glyph in the @code{\w}
11620 argument, the center of an accent from a roman font should be placed
11621 over that glyph.
11622 @end table
11623 @endDefesc
11625 @DefescList {\\k, , p, }
11626 @DefescItem {\\k, @Lparen{}, ps, }
11627 @DefescListEnd {\\k, @Lbrack{}, position, @Rbrack{}}
11628 @cindex saving horizontal input line position (@code{\k})
11629 @cindex horizontal input line position, saving (@code{\k})
11630 @cindex input line position, horizontal, saving (@code{\k})
11631 @cindex position, horizontal input line, saving (@code{\k})
11632 @cindex line, input, horizontal position, saving (@code{\k})
11633 Store the current horizontal position in the @emph{input} line in number
11634 register with name @var{position} (one-character name@tie{}@var{p},
11635 two-character name @var{ps}).  Use this, for example, to return to the
11636 beginning of a string for highlighting or other decoration.
11637 @endDefesc
11639 @Defreg {hp}
11640 @cindex horizontal input line position register (@code{hp})
11641 @cindex input line, horizontal position, register (@code{hp})
11642 @cindex position, horizontal, in input line, register (@code{hp})
11643 @cindex line, input, horizontal position, register (@code{hp})
11644 The current horizontal position at the input line.
11645 @endDefreg
11647 @Defreg {.k}
11648 @cindex horizontal output line position register (@code{.k})
11649 @cindex output line, horizontal position, register (@code{.k})
11650 @cindex position, horizontal, in output line, register (@code{.k})
11651 @cindex line, output, horizontal position, register (@code{.k})
11652 A read-only number register containing the current horizontal output
11653 position (relative to the current indentation).
11654 @endDefreg
11656 @Defesc {\\o, ', abc, '}
11657 @cindex overstriking glyphs (@code{\o})
11658 @cindex glyphs, overstriking (@code{\o})
11659 Overstrike glyphs @var{a}, @var{b}, @var{c}, @dots{}; the glyphs are
11660 centered, and the resulting spacing is the largest width of the affected
11661 glyphs.
11662 @endDefesc
11664 @Defesc {\\z, , g, , }
11665 @cindex zero-width printing (@code{\z}, @code{\Z})
11666 @cindex printing, zero-width (@code{\z}, @code{\Z})
11667 Print glyph @var{g} with zero width, i.e., without spacing.  Use this to
11668 overstrike glyphs left-aligned.
11669 @endDefesc
11671 @Defesc {\\Z, ', anything, '}
11672 @cindex zero-width printing (@code{\z}, @code{\Z})
11673 @cindex printing, zero-width (@code{\z}, @code{\Z})
11674 Print @var{anything}, then restore the horizontal and vertical position.
11675 The argument may not contain tabs or leaders.
11677 The following is an example of a strike-through macro:
11679 @Example
11680 .de ST
11681 .nr ww \w'\\$1'
11682 \Z@@\v'-.25m'\l'\\n[ww]u'@@\\$1
11685 This is
11686 .ST "a test"
11687 an actual emergency!
11688 @endExample
11689 @endDefesc
11692 @c =====================================================================
11694 @node Drawing Requests, Traps, Page Motions, gtroff Reference
11695 @section Drawing Requests
11696 @cindex drawing requests
11697 @cindex requests for drawing
11699 @code{gtroff} provides a number of ways to draw lines and other figures
11700 on the page.  Used in combination with the page motion commands (see
11701 @ref{Page Motions}, for more info), a wide variety of figures can be
11702 drawn.  However, for complex drawings these operations can be quite
11703 cumbersome, and it may be wise to use graphic preprocessors like
11704 @code{gpic} or @code{ggrn}.  @xref{gpic}, and @ref{ggrn}, for more
11705 information.
11707 All drawing is done via escapes.
11709 @DefescList {\\l, ', l, '}
11710 @DefescListEnd {\\l, ', lg, '}
11711 @cindex drawing horizontal lines (@code{\l})
11712 @cindex horizontal line, drawing (@code{\l})
11713 @cindex line, horizontal, drawing (@code{\l})
11714 Draw a line horizontally.  @var{l} is the length of the line to be
11715 drawn.  If it is positive, start the line at the current location and
11716 draw to the right; its end point is the new current location.  Negative
11717 values are handled differently: The line starts at the current location
11718 and draws to the left, but the current location doesn't move.
11720 @var{l} can also be specified absolutely (i.e.@: with a leading
11721 @samp{|}) which draws back to the beginning of the input line.  Default
11722 scaling indicator is @samp{m}.
11724 @cindex underscore glyph (@code{\[ru]})
11725 @cindex glyph, underscore (@code{\[ru]})
11726 @cindex line drawing glyph
11727 @cindex glyph, for line drawing
11728 The optional second parameter@tie{}@var{g} is a glyph to draw the line
11729 with.  If this second argument is not specified, @code{gtroff} uses the
11730 underscore glyph, @code{\[ru]}.
11732 @cindex zero width space character (@code{\&})
11733 @cindex character, zero width space (@code{\&})
11734 @cindex space character, zero width (@code{\&})
11735 To separate the two arguments (to prevent @code{gtroff} from
11736 interpreting a drawing glyph as a scaling indicator if the glyph is
11737 represented by a single character) use @code{\&}.
11739 Here a small useful example:
11741 @Example
11742 .de box
11743 \[br]\\$*\[br]\l'|0\[rn]'\l'|0\[ul]'
11745 @endExample
11747 @noindent
11748 Note that this works by outputting a box rule (a vertical line), then
11749 the text given as an argument and then another box rule.  Finally, the
11750 line drawing escapes both draw from the current location to the
11751 beginning of the @emph{input} line -- this works because the line length
11752 is negative, not moving the current point.
11753 @endDefesc
11755 @DefescList {\\L, ', l, '}
11756 @DefescListEnd {\\L, ', lg, '}
11757 @cindex drawing vertical lines (@code{\L})
11758 @cindex vertical line drawing (@code{\L})
11759 @cindex line, vertical, drawing (@code{\L})
11760 @cindex line drawing glyph
11761 @cindex glyph for line drawing
11762 @cindex box rule glyph (@code{\[br]})
11763 @cindex glyph, box rule (@code{\[br]})
11764 Draw vertical lines.  Its parameters are similar to the @code{\l}
11765 escape, except that the default scaling indicator is @samp{v}.  The
11766 movement is downwards for positive values, and upwards for negative
11767 values.  The default glyph is the box rule glyph, @code{\[br]}.  As with
11768 the vertical motion escapes, text processing blindly continues where the
11769 line ends.
11771 @Example
11772 This is a \L'3v'test.
11773 @endExample
11775 @noindent
11776 Here the result, produced with @code{grotty}.
11778 @Example
11779 This is a
11780           |
11781           |
11782           |test.
11783 @endExample
11784 @endDefesc
11786 @Defesc {\\D, ', command arg @dots{}, '}
11787 The @code{\D} escape provides a variety of drawing functions.  Note that
11788 on character devices, only vertical and horizontal lines are supported
11789 within @code{grotty}; other devices may only support a subset of the
11790 available drawing functions.
11792 The default scaling indicator for all subcommands of @code{\D} is
11793 @samp{m} for horizontal distances and @samp{v} for vertical ones.
11794 Exceptions are @w{@code{\D'f @dots{}'}} and @w{@code{\D't @dots{}'}}
11795 which use @code{u} as the default, and @w{@code{\D'F@var{x} @dots{}'}}
11796 which arguments are treated similar to the @code{defcolor} request.
11798 @table @code
11799 @item \D'l @var{dx} @var{dy}'
11800 @cindex line, drawing (@w{@code{\D'l @dots{}'}})
11801 @cindex drawing a line (@w{@code{\D'l @dots{}'}})
11802 Draw a line from the current location to the relative point specified by
11803 (@var{dx},@var{dy}), where positive values mean down and right,
11804 respectively.  The end point of the line is the new current location.
11806 The following example is a macro for creating a box around a text
11807 string; for simplicity, the box margin is taken as a fixed value,
11808 0.2@dmn{m}.
11810 @Example
11811 .de BOX
11812 .  nr @@wd \w'\\$1'
11813 \h'.2m'\
11814 \h'-.2m'\v'(.2m - \\n[rsb]u)'\
11815 \D'l 0 -(\\n[rst]u - \\n[rsb]u + .4m)'\
11816 \D'l (\\n[@@wd]u + .4m) 0'\
11817 \D'l 0 (\\n[rst]u - \\n[rsb]u + .4m)'\
11818 \D'l -(\\n[@@wd]u + .4m) 0'\
11819 \h'.2m'\v'-(.2m - \\n[rsb]u)'\
11820 \\$1\
11821 \h'.2m'
11823 @endExample
11825 @noindent
11826 First, the width of the string is stored in register @code{@@wd}.  Then,
11827 four lines are drawn to form a box, properly offset by the box margin.
11828 The registers @code{rst} and @code{rsb} are set by the @code{\w} escape,
11829 containing the largest height and depth of the whole string.
11831 @item \D'c @var{d}'
11832 @cindex circle, drawing (@w{@code{\D'c @dots{}'}})
11833 @cindex drawing a circle (@w{@code{\D'c @dots{}'}})
11834 Draw a circle with a diameter of@tie{}@var{d} with the leftmost point at
11835 the current position.  After drawing, the current location is positioned
11836 at the rightmost point of the circle.
11838 @item \D'C @var{d}'
11839 @cindex circle, solid, drawing (@w{@code{\D'C @dots{}'}})
11840 @cindex drawing a solid circle (@w{@code{\D'C @dots{}'}})
11841 @cindex solid circle, drawing (@w{@code{\D'C @dots{}'}})
11842 Draw a solid circle with the same parameters and behaviour as an
11843 outlined circle.  No outline is drawn.
11845 @item \D'e @var{x} @var{y}'
11846 @cindex drawing an ellipse (@w{@code{\D'e @dots{}'}})
11847 @cindex ellipse, drawing (@w{@code{\D'e @dots{}'}})
11848 Draw an ellipse with a horizontal diameter of @var{x} and a vertical
11849 diameter of @var{y} with the leftmost point at the current position.
11850 After drawing, the current location is positioned at the rightmost point
11851 of the ellipse.
11853 @item \D'E @var{x} @var{y}'
11854 @cindex ellipse, solid, drawing (@w{@code{\D'E @dots{}'}})
11855 @cindex drawing a solid ellipse (@w{@code{\D'E @dots{}'}})
11856 @cindex solid ellipse, drawing (@w{@code{\D'E @dots{}'}})
11857 Draw a solid ellipse with the same parameters and behaviour as an
11858 outlined ellipse.  No outline is drawn.
11860 @item \D'a @var{dx1} @var{dy1} @var{dx2} @var{dy2}'
11861 @cindex arc, drawing (@w{@code{\D'a @dots{}'}})
11862 @cindex drawing an arc (@w{@code{\D'a @dots{}'}})
11863 Draw an arc clockwise from the current location through the two
11864 specified relative locations (@var{dx1},@var{dy1}) and
11865 (@var{dx2},@var{dy2}).  The coordinates of the first point are relative
11866 to the current position, and the coordinates of the second point are
11867 relative to the first point.  After drawing, the current position is
11868 moved to the final point of the arc.
11870 @item \D'~ @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
11871 @cindex drawing a spline (@w{@code{\D'~ @dots{}'}})
11872 @cindex spline, drawing (@w{@code{\D'~ @dots{}'}})
11873 Draw a spline from the current location to the relative point
11874 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}), and so on.  The
11875 current position is moved to the terminal point of the drawn curve.
11877 @item \D'f @var{n}'
11878 @cindex gray shading (@w{@code{\D'f @dots{}'}})
11879 @cindex shading filled objects (@w{@code{\D'f @dots{}'}})
11880 Set the shade of gray to be used for filling solid objects
11881 to@tie{}@var{n}; @var{n}@tie{}must be an integer between 0
11882 and@tie{}1000, where 0 corresponds solid white and 1000 to solid black,
11883 and values in between correspond to intermediate shades of gray.  This
11884 applies only to solid circles, solid ellipses, and solid polygons.  By
11885 default, a level of 1000 is used.
11887 Despite of being silly, the current point is moved horizontally to the
11888 right by@tie{}@var{n}.
11890 @cindex @w{@code{\D'f @dots{}'}} and horizontal resolution
11891 Don't use this command!  It has the serious drawback that it is always
11892 rounded to the next integer multiple of the horizontal resolution (the
11893 value of the @code{hor} keyword in the @file{DESC} file).  Use @code{\M}
11894 (@pxref{Colors}) or @w{@code{\D'Fg @dots{}'}} instead.
11896 @item \D'p @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
11897 @cindex drawing a polygon (@w{@code{\D'p @dots{}'}})
11898 @cindex polygon, drawing (@w{@code{\D'p @dots{}'}})
11899 Draw a polygon from the current location to the relative position
11900 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}) and so on.  When
11901 the specified data points are exhausted, a line is drawn back to the
11902 starting point.  The current position is changed by adding the sum of
11903 all arguments with odd index to the actual horizontal position and the
11904 even ones to the vertical position.
11906 @item \D'P @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
11907 @cindex polygon, solid, drawing (@w{@code{\D'P @dots{}'}})
11908 @cindex drawing a solid polygon (@w{@code{\D'P @dots{}'}})
11909 @cindex solid polygon, drawing (@w{@code{\D'P @dots{}'}})
11910 Draw a solid polygon with the same parameters and behaviour as an
11911 outlined polygon.  No outline is drawn.
11913 Here a better variant of the box macro to fill the box with some color.
11914 Note that the box must be drawn before the text since colors in
11915 @code{gtroff} are not transparent; the filled polygon would hide the
11916 text completely.
11918 @Example
11919 .de BOX
11920 .  nr @@wd \w'\\$1'
11921 \h'.2m'\
11922 \h'-.2m'\v'(.2m - \\n[rsb]u)'\
11923 \M[lightcyan]\
11924 \D'P 0 -(\\n[rst]u - \\n[rsb]u + .4m) \
11925      (\\n[@@wd]u + .4m) 0 \
11926      0 (\\n[rst]u - \\n[rsb]u + .4m) \
11927      -(\\n[@@wd]u + .4m) 0'\
11928 \h'.2m'\v'-(.2m - \\n[rsb]u)'\
11929 \M[]\
11930 \\$1\
11931 \h'.2m'
11933 @endExample
11935 If you want a filled polygon which has exactly the same size as an
11936 unfilled one, you must draw both an unfilled and a filled polygon.  A
11937 filled polygon is always smaller than an unfilled one because the latter
11938 uses straight lines with a given line thickness to connect the polygon's
11939 corners, while the former simply fills the area defined by the
11940 coordinates.
11942 @Example
11943 \h'1i'\v'1i'\
11944 \# increase line thickness
11945 \Z'\D't 5p''\
11946 \# draw unfilled polygon
11947 \Z'\D'p 3 3 -6 0''\
11948 \# draw filled polygon
11949 \Z'\D'P 3 3 -6 0''
11950 @endExample
11952 @item \D't @var{n}'
11953 @cindex line thickness (@w{@code{\D't @dots{}'}})
11954 @cindex thickness of lines (@w{@code{\D't @dots{}'}})
11955 Set the current line thickness to @var{n}@tie{}machine units.  A value
11956 of zero selects the smallest available line thickness.  A negative value
11957 makes the line thickness proportional to the current point size (this is
11958 the default behaviour of @acronym{AT&T} @code{troff}).
11960 Despite of being silly, the current point is moved horizontally to the
11961 right by@tie{}@var{n}.
11963 @item \D'F@var{scheme} @var{color_components}'
11964 @cindex unnamed fill colors (@code{\D'F@dots{}'})
11965 @cindex fill colors, unnamed (@code{\D'F@dots{}'})
11966 @cindex colors, fill, unnamed (@code{\D'F@dots{}'})
11967 Change current fill color.  @var{scheme} is a single letter denoting the
11968 color scheme: @samp{r} (rgb), @samp{c} (cmy), @samp{k} (cmyk), @samp{g}
11969 (gray), or @samp{d} (default color).  The color components use exactly
11970 the same syntax as in the @code{defcolor} request (@pxref{Colors}); the
11971 command @code{\D'Fd'} doesn't take an argument.
11973 @emph{No} position changing!
11975 Examples:
11977 @Example
11978 @endExample
11979 \D'Fg .3'      \" same gray as \D'f 700'
11980 \D'Fr #0000ff' \" blue
11981 @end table
11982 @endDefesc
11984 @xref{Graphics Commands}.
11986 @Defesc {\\b, ', string, '}
11987 @cindex pile, glyph (@code{\b})
11988 @cindex glyph pile (@code{\b})
11989 @cindex stacking glyphs (@code{\b})
11990 @dfn{Pile} a sequence of glyphs vertically, and center it vertically on
11991 the current line.  Use it to build large brackets and braces.
11993 Here an example how to create a large opening brace:
11995 @Example
11996 \b'\[lt]\[bv]\[lk]\[bv]\[lb]'
11997 @endExample
11999 @cindex @code{\b}, limitations
12000 @cindex limitations of @code{\b} escape
12001 The first glyph is on the top, the last glyph in @var{string} is at the
12002 bottom.  Note that @code{gtroff} separates the glyphs vertically by
12003 1@dmn{m}, and the whole object is centered 0.5@dmn{m} above the current
12004 baseline; the largest glyph width is used as the width for the whole
12005 object.  This rather unflexible positioning algorithm doesn't work with
12006 @option{-Tdvi} since the bracket pieces vary in height for this device.
12007 Instead, use the @code{eqn} preprocessor.
12009 @xref{Manipulating Spacing}, how to adjust the vertical spacing with the
12010 @code{\x} escape.
12011 @endDefesc
12014 @c =====================================================================
12016 @node Traps, Diversions, Drawing Requests, gtroff Reference
12017 @section Traps
12018 @cindex traps
12020 @dfn{Traps} are locations, which, when reached, call a specified macro.
12021 These traps can occur at a given location on the page, at a given
12022 location in the current diversion, at a blank line, after a certain
12023 number of input lines, or at the end of input.
12025 @cindex planting a trap
12026 @cindex trap, planting
12027 Setting a trap is also called @dfn{planting}.
12028 @cindex trap, springing
12029 @cindex springing a trap
12030 It is also said that a trap is @dfn{sprung} if the associated macro is
12031 executed.
12033 @menu
12034 * Page Location Traps::
12035 * Diversion Traps::
12036 * Input Line Traps::
12037 * Blank Line Traps::
12038 * End-of-input Traps::
12039 @end menu
12041 @c ---------------------------------------------------------------------
12043 @node Page Location Traps, Diversion Traps, Traps, Traps
12044 @subsection Page Location Traps
12045 @cindex page location traps
12046 @cindex traps, page location
12048 @dfn{Page location traps} perform an action when @code{gtroff} reaches
12049 or passes a certain vertical location on the page.  Page location traps
12050 have a variety of purposes, including:
12052 @itemize
12053 @item
12054 setting headers and footers
12056 @item
12057 setting body text in multiple columns
12059 @item
12060 setting footnotes
12061 @end itemize
12063 @DefreqList {vpt, flag}
12064 @DefregListEnd {.vpt}
12065 @cindex enabling vertical position traps (@code{vpt})
12066 @cindex vertical position traps, enabling (@code{vpt})
12067 @cindex vertical position trap enable register (@code{.vpt})
12068 Enable vertical position traps if @var{flag} is non-zero, or disables
12069 them otherwise.  Vertical position traps are traps set by the @code{wh}
12070 or @code{dt} requests.  Traps set by the @code{it} request are not
12071 vertical position traps.  The parameter that controls whether vertical
12072 position traps are enabled is global.  Initially vertical position traps
12073 are enabled.  The current setting of this is available in the
12074 @code{.vpt} read-only number register.
12076 Note that a page can't be ejected if @code{vpt} is set to zero.
12077 @endDefreq
12079 @Defreq {wh, dist [@Var{macro}]}
12080 Set a page location trap.  Non-negative values for @var{dist} set the
12081 trap relative to the top of the page; negative values set the trap
12082 relative to the bottom of the page.  Default scaling indicator is
12083 @samp{v}; values of @var{dist} are always rounded to be multiples of the
12084 vertical resolution (as given in register @code{.V}).
12086 @var{macro} is the name of the macro to execute when the trap is sprung.
12087 If @var{macro} is missing, remove the first trap (if any) at @var{dist}.
12089 @cindex page headers
12090 @cindex page footers
12091 @cindex headers
12092 @cindex footers
12093 The following is a simple example of how many macro packages set headers
12094 and footers.
12096 @Example
12097 .de hd                \" Page header
12098 '  sp .5i
12099 .  tl 'Title''date'
12100 '  sp .3i
12103 .de fo                \" Page footer
12104 '  sp 1v
12105 .  tl ''%''
12106 '  bp
12109 .wh 0   hd            \" trap at top of the page
12110 .wh -1i fo            \" trap one inch from bottom
12111 @endExample
12113 A trap at or below the bottom of the page is ignored; it can be made
12114 active by either moving it up or increasing the page length so that the
12115 trap is on the page.
12117 Negative trap values always use the @emph{current} page length; they are
12118 not converted to an absolute vertical position:
12120 @Example
12121 .pl 5i
12122 .wh -1i xx
12123 .ptr
12124     @result{} xx      -240
12125 .pl 100i
12126 .ptr
12127     @result{} xx      -240
12128 @endExample
12130 It is possible to have more than one trap at the same location; to do
12131 so, the traps must be defined at different locations, then moved
12132 together with the @code{ch} request; otherwise the second trap would
12133 replace the first one.  Earlier defined traps hide later defined traps
12134 if moved to the same position (the many empty lines caused by the
12135 @code{bp} request are omitted in the following example):
12137 @Example
12138 .de a
12139 .  nop a
12141 .de b
12142 .  nop b
12144 .de c
12145 .  nop c
12148 .wh 1i a
12149 .wh 2i b
12150 .wh 3i c
12152     @result{} a b c
12153 @endExample
12154 @Example
12155 .ch b 1i
12156 .ch c 1i
12158     @result{} a
12159 @endExample
12160 @Example
12161 .ch a 0.5i
12163     @result{} a b
12164 @endExample
12165 @endDefreq
12167 @Defreg {.t}
12168 @cindex distance to next trap register (@code{.t})
12169 @cindex trap, distance, register (@code{.t})
12170 A read-only number register holding the distance to the next trap.
12172 If there are no traps between the current position and the bottom of the
12173 page, it contains the distance to the page bottom.  In a diversion, the
12174 distance to the page bottom is infinite (the returned value is the
12175 biggest integer which can be represented in @code{groff}) if there are
12176 no diversion traps.
12177 @endDefreg
12179 @Defreq {ch, macro [@Var{dist}]}
12180 @cindex changing trap location (@code{ch})
12181 @cindex trap, changing location (@code{ch})
12182 Change the location of a trap.  The first argument is the name of the
12183 macro to be invoked at the trap, and the second argument is the new
12184 location for the trap (note that the parameters are specified in
12185 opposite order as in the @code{wh} request).  This is useful for
12186 building up footnotes in a diversion to allow more space at the bottom
12187 of the page for them.
12189 Default scaling indicator for @var{dist} is @samp{v}.  If @var{dist} is
12190 missing, the trap is removed.
12192 @c XXX
12194 @ignore
12195 @Example
12196 ... (simplified) footnote example ...
12197 @endExample
12198 @end ignore
12199 @endDefreq
12201 @Defreg {.ne}
12202 The read-only number register @code{.ne} contains the amount of space
12203 that was needed in the last @code{ne} request that caused a trap to be
12204 sprung.  Useful in conjunction with the @code{.trunc} register.
12205 @xref{Page Control}, for more information.
12207 Since the @code{.ne} register is only set by traps it doesn't make much
12208 sense to use it outside of trap macros.
12209 @endDefreg
12211 @Defreg {.trunc}
12212 @cindex @code{ne} request, and the @code{.trunc} register
12213 @cindex truncated vertical space register (@code{.trunc})
12214 A read-only register containing the amount of vertical space truncated
12215 by the most recently sprung vertical position trap, or, if the trap was
12216 sprung by an @code{ne} request, minus the amount of vertical motion
12217 produced by the @code{ne} request.  In other words, at the point a trap
12218 is sprung, it represents the difference of what the vertical position
12219 would have been but for the trap, and what the vertical position
12220 actually is.
12222 Since the @code{.trunc} register is only set by traps it doesn't make
12223 much sense to use it outside of trap macros.
12224 @endDefreg
12226 @Defreg {.pe}
12227 @cindex @code{bp} request, and traps (@code{.pe})
12228 @cindex traps, sprung by @code{bp} request (@code{.pe})
12229 @cindex page ejecting register (@code{.pe})
12230 A read-only register which is set to@tie{}1 while a page is ejected with
12231 the @code{bp} request (or by the end of input).
12233 Outside of traps this register is always zero.  In the following
12234 example, only the second call to@tie{}@code{x} is caused by @code{bp}.
12236 @Example
12237 .de x
12238 \&.pe=\\n[.pe]
12241 .wh 1v x
12242 .wh 4v x
12243 A line.
12245 Another line.
12247     @result{} A line.
12248        .pe=0
12249        Another line.
12251        .pe=1
12252 @endExample
12253 @endDefreg
12255 @cindex diversions, and traps
12256 @cindex traps, and diversions
12257 An important fact to consider while designing macros is that diversions
12258 and traps do not interact normally.  For example, if a trap invokes a
12259 header macro (while outputting a diversion) which tries to change the
12260 font on the current page, the effect is not visible before the diversion
12261 has completely been printed (except for input protected with @code{\!}
12262 or @code{\?}) since the data in the diversion is already formatted.  In
12263 most cases, this is not the expected behaviour.
12265 @c ---------------------------------------------------------------------
12267 @node Diversion Traps, Input Line Traps, Page Location Traps, Traps
12268 @subsection Diversion Traps
12269 @cindex diversion traps
12270 @cindex traps, diversion
12272 @Defreq {dt, [@Var{dist} @Var{macro}]}
12273 @cindex @code{.t} register, and diversions
12274 @cindex setting diversion trap (@code{dt})
12275 @cindex diversion trap, setting (@code{dt})
12276 @cindex trap, diversion, setting (@code{dt})
12277 Set a trap @emph{within} a diversion.  @var{dist} is the location of the
12278 trap (identical to the @code{wh} request; default scaling indicator is
12279 @samp{v}) and @var{macro} is the name of the macro to be invoked.  If
12280 called without arguments, the diversion trap is removed.
12282 Note that there exists only a single diversion trap.
12284 The number register @code{.t} still works within diversions.
12285 @xref{Diversions}, for more information.
12286 @endDefreq
12288 @c ---------------------------------------------------------------------
12290 @node Input Line Traps, Blank Line Traps, Diversion Traps, Traps
12291 @subsection Input Line Traps
12292 @cindex input line traps
12293 @cindex traps, input line
12295 @DefreqList {it, n macro}
12296 @DefreqItem {itc, n macro}
12297 @cindex setting input line trap (@code{it})
12298 @cindex input line trap, setting (@code{it})
12299 @cindex trap, input line, setting (@code{it})
12300 Set an input line trap.  @var{n}@tie{}is the number of lines of input
12301 which may be read before springing the trap, @var{macro} is the macro to
12302 be invoked.  Request lines are not counted as input lines.
12304 For example, one possible use is to have a macro which prints the next
12305 @var{n}@tie{}lines in a bold font.
12307 @Example
12308 .de B
12309 .  it \\$1 B-end
12310 .  ft B
12313 .de B-end
12314 .  ft R
12316 @endExample
12318 @cindex input line traps and interrupted lines (@code{itc})
12319 @cindex interrupted lines and input line traps (@code{itc})
12320 @cindex traps, input line, and interrupted lines (@code{itc})
12321 @cindex lines, interrupted, and input line traps (@code{itc})
12322 The @code{itc} request is identical except that an interrupted text line
12323 (ending with @code{\c}) is not counted as a separate line.
12325 Both requests are associated with the current environment
12326 (@pxref{Environments}); switching to another environment disables the
12327 current input trap, and going back reactivates it, restoring the number
12328 of already processed lines.
12329 @endDefreq
12331 @c ---------------------------------------------------------------------
12333 @node Blank Line Traps, End-of-input Traps, Input Line Traps, Traps
12334 @subsection Blank Line Traps
12335 @cindex blank line traps
12336 @cindex traps, blank line
12338 @Defreq {blm, macro}
12339 @cindex blank line macro (@code{blm})
12340 Set a blank line trap.  @code{gtroff} executes @var{macro} when it
12341 encounters a blank line in the input file.
12342 @endDefreq
12344 @c ---------------------------------------------------------------------
12346 @node End-of-input Traps,  , Blank Line Traps, Traps
12347 @subsection End-of-input Traps
12348 @cindex end-of-input traps
12349 @cindex traps, end-of-input
12351 @Defreq {em, macro}
12352 @cindex setting end-of-input trap (@code{em})
12353 @cindex end-of-input trap, setting (@code{em})
12354 @cindex trap, end-of-input, setting (@code{em})
12355 @cindex end-of-input macro (@code{em})
12356 @cindex macro, end-of-input (@code{em})
12357 Set a trap at the end of input.  @var{macro} is executed after the last
12358 line of the input file has been processed.
12360 For example, if the document had to have a section at the bottom of the
12361 last page for someone to approve it, the @code{em} request could be
12362 used.
12364 @Example
12365 .de approval
12366 .  ne 5v
12367 .  sp |(\\n[.t] - 6v)
12368 .  in +4i
12369 .  lc _
12370 .  br
12371 Approved:\t\a
12372 .  sp
12373 Date:\t\t\a
12376 .em approval
12377 @endExample
12378 @endDefreq
12381 @c =====================================================================
12383 @node Diversions, Environments, Traps, gtroff Reference
12384 @section Diversions
12385 @cindex diversions
12387 In @code{gtroff} it is possible to @dfn{divert} text into a named
12388 storage area.  Due to the similarity to defining macros it is sometimes
12389 said to be stored in a macro.  This is used for saving text for output
12390 at a later time, which is useful for keeping blocks of text on the same
12391 page, footnotes, tables of contents, and indices.
12393 @cindex top-level diversion
12394 @cindex diversion, top-level
12395 For orthogonality it is said that @code{gtroff} is in the @dfn{top-level
12396 diversion} if no diversion is active (i.e., the data is diverted to the
12397 output device).
12399 @DefreqList {di, macro}
12400 @DefreqListEnd {da, macro}
12401 @cindex beginning diversion (@code{di})
12402 @cindex diversion, beginning (@code{di})
12403 @cindex ending diversion (@code{di})
12404 @cindex diversion, ending (@code{di})
12405 @cindex appending to a diversion (@code{da})
12406 @cindex diversion, appending (@code{da})
12407 Begin a diversion.  Like the @code{de} request, it takes an argument of
12408 a macro name to divert subsequent text into.  The @code{da} macro
12409 appends to an existing diversion.
12411 @code{di} or @code{da} without an argument ends the diversion.
12413 The current partially-filled line is included into the diversion.  See
12414 the @code{box} request below for an example.  Note that switching to
12415 another (empty) environment (with the @code{ev} request) avoids the
12416 inclusion of the current partially-filled line.
12417 @endDefreq
12419 @DefreqList {box, macro}
12420 @DefreqListEnd {boxa, macro}
12421 Begin (or append to) a diversion like the @code{di} and @code{da}
12422 requests.  The difference is that @code{box} and @code{boxa} do not
12423 include a partially-filled line in the diversion.
12425 Compare this:
12427 @Example
12428 Before the box.
12429 .box xxx
12430 In the box.
12432 .box
12433 After the box.
12435     @result{} Before the box.  After the box.
12436 .xxx
12437     @result{} In the box.
12438 @endExample
12440 @noindent
12441 with this:
12443 @Example
12444 Before the diversion.
12445 .di yyy
12446 In the diversion.
12449 After the diversion.
12451     @result{} After the diversion.
12452 .yyy
12453     @result{} Before the diversion.  In the diversion.
12454 @endExample
12456 @code{box} or @code{boxa} without an argument ends the diversion.
12457 @endDefreq
12459 @DefregList {.z}
12460 @DefregListEnd {.d}
12461 @cindex @code{nl} register, and @code{.d}
12462 @cindex nested diversions
12463 @cindex diversion, nested
12464 @cindex diversion name register (@code{.z})
12465 @cindex vertical position in diversion register (@code{.d})
12466 @cindex position, vertical, in diversion, register (@code{.d})
12467 @cindex diversion, vertical position in, register (@code{.d})
12468 Diversions may be nested.  The read-only number register @code{.z}
12469 contains the name of the current diversion (this is a string-valued
12470 register).  The read-only number register @code{.d} contains the current
12471 vertical place in the diversion.  If not in a diversion it is the same
12472 as register @code{nl}.
12473 @endDefreg
12475 @Defreg {.h}
12476 @cindex high-water mark register (@code{.h})
12477 @cindex mark, high-water, register (@code{.h})
12478 @cindex position of lowest text line (@code{.h})
12479 @cindex text line, position of lowest (@code{.h})
12480 The @dfn{high-water mark} on the current page.  It corresponds to the
12481 text baseline of the lowest line on the page.  This is a read-only
12482 register.
12484 @Example
12485 .tm .h==\n[.h], nl==\n[nl]
12486     @result{} .h==0, nl==-1
12487 This is a test.
12489 .sp 2
12490 .tm .h==\n[.h], nl==\n[nl]
12491     @result{} .h==40, nl==120
12492 @endExample
12494 @cindex @code{.h} register, difference to @code{nl}
12495 @cindex @code{nl} register, difference to @code{.h}
12496 @noindent
12497 As can be seen in the previous example, empty lines are not considered
12498 in the return value of the @code{.h} register.
12499 @endDefreg
12501 @DefregList {dn}
12502 @DefregListEnd {dl}
12503 @cindex @code{dn} register, and @code{da} (@code{boxa})
12504 @cindex @code{dl} register, and @code{da} (@code{boxa})
12505 @cindex @code{da} request, and @code{dn} (@code{dl})
12506 @cindex @code{boxa} request, and @code{dn} (@code{dl})
12507 After completing a diversion, the read-write number registers @code{dn}
12508 and @code{dl} contain the vertical and horizontal size of the diversion.
12509 Note that only the just processed lines are counted: For the computation
12510 of @code{dn} and @code{dl}, the requests @code{da} and @code{boxa} are
12511 handled as if @code{di} and @code{box} had been used -- lines which have
12512 been already stored in a macro are not taken into account.
12514 @Example
12515 .\" Center text both horizontally & vertically
12517 .\" Enclose macro definitions in .eo and .ec
12518 .\" to avoid the doubling of the backslash
12520 .\" macro .(c starts centering mode
12521 .de (c
12522 .  br
12523 .  ev (c
12524 .  evc 0
12525 .  in 0
12526 .  nf
12527 .  di @@c
12529 @endExample
12530 @Example
12531 .\" macro .)c terminates centering mode
12532 .de )c
12533 .  br
12534 .  ev
12535 .  di
12536 .  nr @@s (((\n[.t]u - \n[dn]u) / 2u) - 1v)
12537 .  sp \n[@@s]u
12538 .  ce 1000
12539 .  @@c
12540 .  ce 0
12541 .  sp \n[@@s]u
12542 .  br
12543 .  fi
12544 .  rr @@s
12545 .  rm @@s
12546 .  rm @@c
12548 .\" End of macro definitions, restore escape mechanism
12550 @endExample
12551 @endDefreg
12553 @DefescList {\\!, , , }
12554 @DefescListEnd {\\?, , anything, \\?}
12555 @cindex transparent output (@code{\!}, @code{\?})
12556 @cindex output, transparent (@code{\!}, @code{\?})
12557 Prevent requests, macros, and escapes from being interpreted when read
12558 into a diversion.  Both escapes take the given text and
12559 @dfn{transparently} embed it into the diversion.  This is useful for
12560 macros which shouldn't be invoked until the diverted text is actually
12561 output.
12563 The @code{\!} escape transparently embeds text up to and including the
12564 end of the line.  The @code{\?} escape transparently embeds text until
12565 the next occurrence of the @code{\?} escape.  Example:
12567 @Example
12568 \?@var{anything}\?
12569 @endExample
12571 @cindex @code{\?}, and copy-in mode
12572 @cindex copy-in mode, and @code{\?}
12573 @cindex mode, copy-in, and @code{\?}
12574 @cindex @code{\!}, and copy-in mode
12575 @cindex copy-in mode, and @code{\!}
12576 @cindex mode, copy-in, and @code{\!}
12577 @noindent
12578 @var{anything} may not contain newlines; use @code{\!}  to embed
12579 newlines in a diversion.  The escape sequence @code{\?} is also
12580 recognized in copy mode and turned into a single internal code; it is
12581 this code that terminates @var{anything}.  Thus the following example
12582 prints@tie{}4.
12584 @Example
12585 .nr x 1
12587 .di d
12588 \?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
12590 .nr x 2
12591 .di e
12594 .nr x 3
12595 .di f
12598 .nr x 4
12600 @endExample
12602 Both escapes read the data in copy mode.
12604 @cindex @code{\!}, in top-level diversion
12605 @cindex top-level diversion, and @code{\!}
12606 @cindex diversion, top-level, and @code{\!}
12607 If @code{\!} is used in the top-level diversion, its argument is
12608 directly embedded into the @code{gtroff} intermediate output.  This can
12609 be used for example to control a postprocessor which processes the data
12610 before it is sent to the device driver.
12612 @cindex @code{\?}, in top-level diversion
12613 @cindex top-level diversion, and @code{\?}
12614 @cindex diversion, top-level, and @code{\?}
12615 The @code{\?} escape used in the top-level diversion produces no output
12616 at all; its argument is simply ignored.
12617 @endDefesc
12619 @cindex @code{\!}, and @code{output} request
12620 @cindex @code{output} request, and @code{\!}
12621 @cindex @code{output} request, and copy-in mode
12622 @cindex copy-in mode, and @code{output} request
12623 @cindex mode, copy-in, and @code{output} request
12624 @Defreq {output, string}
12625 Emit @var{string} directly to the @code{gtroff} intermediate output
12626 (subject to copy mode interpretation); this is similar to @code{\!} used
12627 at the top level.  An initial double quote in @var{string} is stripped
12628 off to allow initial blanks.
12630 This request can't be used before the first page has started -- if you
12631 get an error, simply insert @code{.br} before the @code{output} request.
12633 Without argument, @code{output} is ignored.
12635 Use with caution!  It is normally only needed for mark-up used by a
12636 postprocessor which does something with the output before sending it to
12637 the output device, filtering out @var{string} again.
12638 @endDefreq
12640 @Defreq {asciify, div}
12641 @cindex unformatting diversions (@code{asciify})
12642 @cindex diversion, unformatting (@code{asciify})
12643 @cindex @code{trin} request, and @code{asciify}
12644 @dfn{Unformat} the diversion specified by @var{div} in such a way that
12645 @acronym{ASCII} characters, characters translated with the @code{trin}
12646 request, space characters, and some escape sequences that were formatted
12647 and diverted are treated like ordinary input characters when the
12648 diversion is reread.  It can be also used for gross hacks; for example,
12649 the following sets register@tie{}@code{n} to@tie{}1.
12651 @Example
12652 .tr @@.
12653 .di x
12654 @@nr n 1
12657 .tr @@@@
12658 .asciify x
12660 @endExample
12662 @xref{Copy-in Mode}.
12663 @endDefreq
12665 @Defreq {unformat, div}
12666 Like @code{asciify}, unformat the specified diversion.  However,
12667 @code{unformat} only unformats spaces and tabs between words.
12668 Unformatted tabs are treated as input tokens, and spaces are stretchable
12669 again.
12671 The vertical size of lines is not preserved; glyph information (font,
12672 font size, space width, etc.)@: is retained.
12673 @endDefreq
12676 @c =====================================================================
12678 @node Environments, Suppressing output, Diversions, gtroff Reference
12679 @section Environments
12680 @cindex environments
12682 It happens frequently that some text should be printed in a certain
12683 format regardless of what may be in effect at the time, for example, in
12684 a trap invoked macro to print headers and footers.  To solve this
12685 @code{gtroff} processes text in @dfn{environments}.  An environment
12686 contains most of the parameters that control text processing.  It is
12687 possible to switch amongst these environments; by default @code{gtroff}
12688 processes text in environment@tie{}0.  The following is the information
12689 kept in an environment.
12691 @itemize @bullet
12692 @item
12693 font parameters (size, family, style, glyph height and slant, space and
12694 sentence space size)
12696 @item
12697 page parameters (line length, title length, vertical spacing, line
12698 spacing, indentation, line numbering, centering, right-justifying,
12699 underlining, hyphenation data)
12701 @item
12702 fill and adjust mode
12704 @item
12705 tab stops, tab and leader characters, escape character, no-break and
12706 hyphen indicators, margin character data
12708 @item
12709 partially collected lines
12711 @item
12712 input traps
12714 @item
12715 drawing and fill colours
12716 @end itemize
12718 These environments may be given arbitrary names (see @ref{Identifiers},
12719 for more info).  Old versions of @code{troff} only had environments
12720 named @samp{0}, @samp{1}, and @samp{2}.
12722 @DefreqList {ev, [@Var{env}]}
12723 @DefregListEnd {.ev}
12724 @cindex switching environments (@code{ev})
12725 @cindex environment, switching (@code{ev})
12726 @cindex environment number/name register (@code{.ev})
12727 Switch to another environment.  The argument @var{env} is the name of
12728 the environment to switch to.  With no argument, @code{gtroff} switches
12729 back to the previous environment.  There is no limit on the number of
12730 named environments; they are created the first time that they are
12731 referenced.  The @code{.ev} read-only register contains the name or
12732 number of the current environment.  This is a string-valued register.
12734 Note that a call to @code{ev} (with argument) pushes the previously
12735 active environment onto a stack.  If, say, environments @samp{foo},
12736 @samp{bar}, and @samp{zap} are called (in that order), the first
12737 @code{ev} request without parameter switches back to environment
12738 @samp{bar} (which is popped off the stack), and a second call switches
12739 back to environment @samp{foo}.
12741 Here is an example:
12743 @Example
12744 .ev footnote-env
12745 .fam N
12746 .ps 6
12747 .vs 8
12748 .ll -.5i
12753 .ev footnote-env
12754 \(dg Note the large, friendly letters.
12756 @endExample
12757 @endDefreq
12759 @Defreq {evc, env}
12760 @cindex copying environment (@code{evc})
12761 @cindex environment, copying (@code{evc})
12762 Copy the environment @var{env} into the current environment.
12764 The following environment data is not copied:
12766 @itemize @bullet
12767 @item
12768 Partially filled lines.
12770 @item
12771 The status whether the previous line was interrupted.
12773 @item
12774 The number of lines still to center, or to right-justify, or to
12775 underline (with or without underlined spaces); they are set to zero.
12777 @item
12778 The status whether a temporary indentation is active.
12780 @item
12781 Input traps and its associated data.
12783 @item
12784 Line numbering mode is disabled; it can be reactivated with @w{@samp{.nm
12785 +0}}.
12787 @item
12788 The number of consecutive hyphenated lines (set to zero).
12789 @end itemize
12790 @endDefreq
12792 @DefregList {.w}
12793 @DefregItem {.cht}
12794 @DefregItem {.cdp}
12795 @DefregListEnd {.csk}
12796 @cindex environment, dimensions of last glyph (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
12797 @cindex width, of last glyph (@code{.w})
12798 @cindex height, of last glyph (@code{.cht})
12799 @cindex depth, of last glyph (@code{.cdp})
12800 @cindex skew, of last glyph (@code{.csk})
12801 @cindex last glyph, dimensions (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
12802 @cindex glyph, last, dimensions (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
12803 The @code{\n[.w]} register contains the width of the last glyph added to
12804 the current environment.
12806 The @code{\n[.cht]} register contains the height of the last glyph added
12807 to the current environment.
12809 The @code{\n[.cdp]} register contains the depth of the last glyph added
12810 to the current environment.  It is positive for glyphs extending below
12811 the baseline.
12813 The @code{\n[.csk]} register contains the @dfn{skew} (how far to the
12814 right of the glyph's center that @code{gtroff} should place an accent)
12815 of the last glyph added to the current environment.
12816 @endDefreg
12818 @Defreg {.n}
12819 @cindex environment, previous line length (@code{.n})
12820 @cindex line length, previous (@code{.n})
12821 @cindex length of previous line (@code{.n})
12822 @cindex previous line length (@code{.n})
12823 The @code{\n[.n]} register contains the length of the previous output
12824 line in the current environment.
12825 @endDefreg
12828 @c =====================================================================
12830 @node Suppressing output, Colors, Environments, gtroff Reference
12831 @section Suppressing output
12833 @Defesc {\\O, , num, }
12834 @cindex suppressing output (@code{\O})
12835 @cindex output, suppressing (@code{\O})
12836 Disable or enable output depending on the value of @var{num}:
12838 @table @samp
12839 @item \O0
12840 Disable any glyphs from being emitted to the device driver, provided
12841 that the escape occurs at the outer level (see @code{\O[3]} and
12842 @code{\O[4]}).  Motion is not suppressed so effectively @code{\O[0]}
12843 means @emph{pen up}.
12845 @item \O1
12846 Enable output of glyphs, provided that the escape occurs at the outer
12847 level.
12848 @end table
12850 @vindex opminx
12851 @vindex opminy
12852 @vindex opmaxx
12853 @vindex opmaxy
12854 @code{\O0} and @code{\O1} also reset the four registers @samp{opminx},
12855 @samp{opminy}, @samp{opmaxx}, and @samp{opmaxy} to @minus{}1.
12856 @xref{Register Index}.  These four registers mark the top left and
12857 bottom right hand corners of a box which encompasses all written glyphs.
12859 For example the input text:
12861 @Example
12862 Hello \O[0]world \O[1]this is a test.
12863 @endExample
12865 @noindent
12866 produces the following output:
12868 @Example
12869 Hello       this is a test.
12870 @endExample
12872 @table @samp
12873 @item \O2
12874 Provided that the escape occurs at the outer level, enable output of
12875 glyphs and also write out to @code{stderr} the page number and four
12876 registers encompassing the glyphs previously written since the last call
12877 to @code{\O}.
12879 @item \O3
12880 Begin a nesting level.  At start-up, @code{gtroff} is at outer level.
12881 The current level is contained within the read-only register @code{.O}.
12882 @xref{Built-in Registers}.
12884 @item \O4
12885 End a nesting level.  The current level is contained within the
12886 read-only register @code{.O}.  @xref{Built-in Registers}.
12888 @item \O[5@var{P}@var{filename}]
12889 This escape is @code{grohtml} specific.  Provided that this escape
12890 occurs at the outer nesting level write the @code{filename} to
12891 @code{stderr}.  The position of the image, @var{P}, must be specified
12892 and must be one of @code{l}, @code{r}, @code{c}, or@tie{}@code{i} (left,
12893 right, centered, inline).  @var{filename} is associated with the
12894 production of the next inline image.
12895 @end table
12896 @endDefesc
12899 @c =====================================================================
12901 @node Colors, I/O, Suppressing output, gtroff Reference
12902 @section Colors
12903 @cindex colors
12905 @DefreqList {color, [@Var{n}]}
12906 @DefregListEnd {.color}
12907 If @var{n} is missing or non-zero, activate colors (this is the
12908 default); otherwise, turn it off.
12910 The read-only number register @code{.color} is@tie{}1 if colors are
12911 active, 0@tie{}otherwise.
12913 Internally, @code{color} sets a global flag; it does not produce a
12914 token.  Similar to the @code{cp} request, you should use it at the
12915 beginning of your document to control color output.
12917 Colors can be also turned off with the @option{-c} command line option.
12918 @endDefreq
12920 @Defreq {defcolor, ident scheme color_components}
12921 Define color with name @var{ident}.  @var{scheme} can be one of the
12922 following values: @code{rgb} (three components), @code{cmy} (three
12923 components), @code{cmyk} (four components), and @code{gray} or
12924 @code{grey} (one component).
12926 @cindex default color
12927 @cindex color, default
12928 Color components can be given either as a hexadecimal string or as
12929 positive decimal integers in the range 0--65535.  A hexadecimal string
12930 contains all color components concatenated.  It must start with either
12931 @code{#} or @code{##}; the former specifies hex values in the range
12932 0--255 (which are internally multiplied by@tie{}257), the latter in the
12933 range 0--65535.  Examples: @code{#FFC0CB} (pink), @code{##ffff0000ffff}
12934 (magenta).  The default color name @c{default} can't be redefined; its
12935 value is device-specific (usually black).  It is possible that the
12936 default color for @code{\m} and @code{\M} is not identical.
12938 @cindex @code{f} unit, and colors
12939 @cindex unit, @code{f}, and colors
12940 A new scaling indicator@tie{}@code{f} has been introduced which
12941 multiplies its value by 65536; this makes it convenient to specify color
12942 components as fractions in the range 0 to@tie{}1 (1f equals 65536u).
12943 Example:
12945 @Example
12946 .defcolor darkgreen rgb 0.1f 0.5f 0.2f
12947 @endExample
12949 Note that @code{f} is the default scaling indicator for the
12950 @code{defcolor} request, thus the above statement is equivalent to
12952 @Example
12953 .defcolor darkgreen rgb 0.1 0.5 0.2
12954 @endExample
12955 @endDefreq
12957 @DefreqList {gcolor, [@Var{color}]}
12958 @DefescItem {\\m, , c, }
12959 @DefescItem {\\m, @Lparen{}, co, }
12960 @DefescItem {\\m, @Lbrack{}, color, @Rbrack{}}
12961 @DefregListEnd {.m}
12962 Set (glyph) drawing color.  The following examples show how to turn the
12963 next four words red.
12965 @Example
12966 .gcolor red
12967 these are in red
12968 .gcolor
12969 and these words are in black.
12970 @endExample
12972 @Example
12973 \m[red]these are in red\m[] and these words are in black.
12974 @endExample
12976 The escape @code{\m[]} returns to the previous color, as does a call to
12977 @code{gcolor} without an argument.
12979 @cindex drawing color name register (@code{.m})
12980 @cindex name, drawing color, register (@code{.m})
12981 @cindex color name, drawing, register (@code{.m})
12982 The name of the current drawing color is available in the read-only,
12983 string-valued number register @samp{.m}.
12985 The drawing color is associated with the current environment
12986 (@pxref{Environments}).
12988 Note that @code{\m} doesn't produce an input token in @code{gtroff}.  As
12989 a consequence, it can be used in requests like @code{mc} (which expects
12990 a single character as an argument) to change the color on the fly:
12992 @Example
12993 .mc \m[red]x\m[]
12994 @endExample
12995 @endDefesc
12997 @DefreqList {fcolor, [@Var{color}]}
12998 @DefescItem {\\M, , c, }
12999 @DefescItem {\\M, @Lparen{}, co, }
13000 @DefescItem {\\M, @Lbrack{}, color, @Rbrack{}}
13001 @DefregListEnd {.M}
13002 Set fill (background) color for filled objects drawn with the
13003 @code{\D'@dots{}'} commands.
13005 A red ellipse can be created with the following code:
13007 @Example
13008 \M[red]\h'0.5i'\D'E 2i 1i'\M[]
13009 @endExample
13011 The escape @code{\M[]} returns to the previous fill color, as does a
13012 call to @code{fcolor} without an argument.
13014 @cindex background color name register (@code{.M})
13015 @cindex name, background color, register (@code{.M})
13016 @cindex color name, background, register (@code{.M})
13017 @cindex fill color name register (@code{.M})
13018 @cindex name, fill color, register (@code{.M})
13019 @cindex color name, fill, register (@code{.M})
13020 The name of the current fill (background) color is available in the
13021 read-only, string-valued number register @samp{.M}.
13023 The fill color is associated with the current environment
13024 (@pxref{Environments}).
13026 Note that @code{\M} doesn't produce an input token in @code{gtroff}.
13027 @endDefesc
13030 @c =====================================================================
13032 @node I/O, Postprocessor Access, Colors, gtroff Reference
13033 @section I/O
13034 @cindex i/o
13035 @cindex input and output requests
13036 @cindex requests for input and output
13037 @cindex output and input requests
13039 @code{gtroff} has several requests for including files:
13041 @Defreq {so, file}
13042 @cindex including a file (@code{so})
13043 @cindex file, inclusion (@code{so})
13044 Read in the specified @var{file} and includes it in place of the
13045 @code{so} request.  This is quite useful for large documents, e.g.@:
13046 keeping each chapter in a separate file.  @xref{gsoelim}, for more
13047 information.
13049 Since @code{gtroff} replaces the @code{so} request with the contents of
13050 @code{file}, it makes a difference whether the data is terminated with a
13051 newline or not: Assuming that file @file{xxx} contains the word
13052 @samp{foo} without a final newline, this
13054 @Example
13055 This is
13056 .so xxx
13058 @endExample
13060 @noindent
13061 yields @samp{This is foobar}.
13063 The search path for @var{file} can be controlled with the @option{-I}
13064 command line option.
13065 @endDefreq
13067 @Defreq {pso, command}
13068 Read the standard output from the specified @var{command} and includes
13069 it in place of the @code{pso} request.
13071 @cindex safer mode
13072 @cindex mode, safer
13073 @cindex unsafe mode
13074 @cindex mode, unsafe
13075 This request causes an error if used in safer mode (which is the
13076 default).  Use @code{groff}'s or @code{troff}'s @option{-U} option to
13077 activate unsafe mode.
13079 The comment regarding a final newline for the @code{so} request is valid
13080 for @code{pso} also.
13081 @endDefreq
13083 @Defreq {mso, file}
13084 Identical to the @code{so} request except that @code{gtroff} searches
13085 for the specified @var{file} in the same directories as macro files for
13086 the the @option{-m} command line option.  If the file name to be
13087 included has the form @file{@var{name}.tmac} and it isn't found,
13088 @code{mso} tries to include @file{tmac.@var{name}} and vice versa.
13089 @endDefreq
13091 @DefreqList {trf, file}
13092 @DefreqListEnd {cf, file}
13093 @cindex transparent output (@code{cf}, @code{trf})
13094 @cindex output, transparent (@code{cf}, @code{trf})
13095 @cindex @code{cf} request, and copy-in mode
13096 @cindex copy-in mode, and @code{cf} request
13097 @cindex mode, copy-in, and @code{cf} request
13098 @cindex @code{trf} request, and copy-in mode
13099 @cindex copy-in mode, and @code{trf} request
13100 @cindex mode, copy-in, and @code{trf} request
13101 Transparently output the contents of @var{file}.  Each line is output as
13102 if it were preceded by @code{\!}; however, the lines are @emph{not}
13103 subject to copy mode interpretation.  If the file does not end with a
13104 newline, then a newline is added (@code{trf} only).  For example, to
13105 define a macro@tie{}@code{x} containing the contents of
13106 file@tie{}@file{f}, use
13108 @Example
13109 .ev 1
13110 .di x
13111 .trf f
13114 @endExample
13116 @noindent
13117 The calls to @code{ev} prevent that the current partial input line
13118 becomes part of the diversion.
13120 Both @code{trf} and @code{cf}, when used in a diversion, embeds an
13121 object in the diversion which, when reread, causes the contents of
13122 @var{file} to be transparently copied through to the output.  In
13123 @acronym{UNIX} @code{troff}, the contents of @var{file} is immediately
13124 copied through to the output regardless of whether there is a current
13125 diversion; this behaviour is so anomalous that it must be considered a
13126 bug.
13128 @cindex @code{trf} request, and invalid characters
13129 @cindex characters, invalid for @code{trf} request
13130 @cindex invalid characters for @code{trf} request
13132 While @code{cf} copies the contents of @var{file} completely
13133 unprocessed, @code{trf} disallows characters such as NUL that are not
13134 valid @code{gtroff} input characters (@pxref{Identifiers}).
13136 For @code{cf}, within a diversion, `completely unprocessed' means that
13137 each line of a file to be inserted is handled as if it were preceded by
13138 @code{\!\\!}.
13140 Both requests cause a line break.
13141 @endDefreq
13143 @Defreq {nx, [@Var{file}]}
13144 @cindex processing next file (@code{nx})
13145 @cindex file, processing next (@code{nx})
13146 @cindex next file, processing (@code{nx})
13147 Force @code{gtroff} to continue processing of the file specified as an
13148 argument.  If no argument is given, immediately jump to the end of file.
13149 @endDefreq
13151 @Defreq {rd, [@Var{prompt} [@Var{arg1} @Var{arg2} @dots{}]]}
13152 @cindex reading from standard input (@code{rd})
13153 @cindex standard input, reading from (@code{rd})
13154 @cindex input, standard, reading from (@code{rd})
13155 Read from standard input, and include what is read as though it were
13156 part of the input file.  Text is read until a blank line is encountered.
13158 If standard input is a TTY input device (keyboard), write @var{prompt}
13159 to standard error, followed by a colon (or send BEL for a beep if no
13160 argument is given).
13162 Arguments after @var{prompt} are available for the input.  For example,
13163 the line
13165 @Example
13166 .rd data foo bar
13167 @endExample
13169 with the input @w{@samp{This is \$2.}} prints
13171 @Example
13172 This is bar.
13173 @endExample
13174 @endDefreq
13176 @cindex form letters
13177 @cindex letters, form
13178 Using the @code{nx} and @code{rd} requests, it is easy to set up form
13179 letters.  The form letter template is constructed like this, putting the
13180 following lines into a file called @file{repeat.let}:
13182 @Example
13184 \*(td
13185 .sp 2
13191 Body of letter.
13193 .nx repeat.let
13194 @endExample
13196 @cindex @code{ex} request, used with @code{nx} and @code{rd}
13197 @noindent
13198 When this is run, a file containing the following lines should be
13199 redirected in.  Note that requests included in this file are executed as
13200 though they were part of the form letter.  The last block of input is
13201 the @code{ex} request which tells @code{groff} to stop processing.  If
13202 this was not there, @code{groff} would not know when to stop.
13204 @Example
13205 Trent A. Fisher
13206 708 NW 19th Av., #202
13207 Portland, OR  97209
13209 Dear Trent,
13211 Len Adollar
13212 4315 Sierra Vista
13213 San Diego, CA  92103
13215 Dear Mr. Adollar,
13218 @endExample
13220 @Defreq {pi, pipe}
13221 Pipe the output of @code{gtroff} to the shell command(s) specified by
13222 @var{pipe}.  This request must occur before @code{gtroff} has a chance
13223 to print anything.
13225 @cindex safer mode
13226 @cindex mode, safer
13227 @cindex unsafe mode
13228 @cindex mode, unsafe
13229 @code{pi} causes an error if used in safer mode (which is the default).
13230 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate
13231 unsafe mode.
13233 Multiple calls to @code{pi} are allowed, acting as a chain.  For
13234 example,
13236 @Example
13237 .pi foo
13238 .pi bar
13240 @endExample
13242 is the same as @w{@samp{.pi foo | bar}}.
13244 @cindex @code{groff}, and @code{pi} request
13245 @cindex @code{pi} request, and @code{groff}
13246 Note that the intermediate output format of @code{gtroff} is piped to
13247 the specified commands.  Consequently, calling @code{groff} without the
13248 @option{-Z} option normally causes a fatal error.
13249 @endDefreq
13251 @DefreqList {sy, cmds}
13252 @DefregListEnd {systat}
13253 Execute the shell command(s) specified by @var{cmds}.  The output is not
13254 saved anyplace, so it is up to the user to do so.
13256 @cindex safer mode
13257 @cindex mode, safer
13258 @cindex unsafe mode
13259 @cindex mode, unsafe
13260 This request causes an error if used in safer mode (which is the
13261 default).  Use @code{groff}'s or @code{troff}'s @option{-U} option to
13262 activate unsafe mode.
13264 For example, the following code fragment introduces the current time
13265 into a document:
13267 @cindex time, current
13268 @cindex current time
13269 @pindex perl
13270 @Example
13271 .sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
13272              (localtime(time))[2,1,0]' > /tmp/x\n[$$]
13273 .so /tmp/x\n[$$]
13274 .sy rm /tmp/x\n[$$]
13275 \nH:\nM:\nS
13276 @endExample
13278 @noindent
13279 Note that this works by having the @code{perl} script (run by @code{sy})
13280 print out the @code{nr} requests which set the number registers
13281 @code{H}, @code{M}, and @code{S}, and then reads those commands in with
13282 the @code{so} request.
13284 For most practical purposes, the number registers @code{seconds},
13285 @code{minutes}, and @code{hours} which are initialized at start-up of
13286 @code{gtroff} should be sufficient.  Use the @code{af} request to get a
13287 formatted output:
13289 @Example
13290 .af hours 00
13291 .af minutes 00
13292 .af seconds 00
13293 \n[hours]:\n[minutes]:\n[seconds]
13294 @endExample
13296 @cindex @code{system()} return value register (@code{systat})
13297 The @code{systat} read-write number register contains the return value
13298 of the @code{system()} function executed by the last @code{sy} request.
13299 @endDefreq
13301 @DefreqList {open, stream file}
13302 @DefreqListEnd {opena, stream file}
13303 @cindex opening file (@code{open})
13304 @cindex file, opening (@code{open})
13305 @cindex appending to a file (@code{opena})
13306 @cindex file, appending to (@code{opena})
13307 Open the specified @var{file} for writing and associates the specified
13308 @var{stream} with it.
13310 The @code{opena} request is like @code{open}, but if the file exists,
13311 append to it instead of truncating it.
13313 @cindex safer mode
13314 @cindex mode, safer
13315 @cindex unsafe mode
13316 @cindex mode, unsafe
13317 Both @code{open} and @code{opena} cause an error if used in safer mode
13318 (which is the default).  Use @code{groff}'s or @code{troff}'s
13319 @option{-U} option to activate unsafe mode.
13320 @endDefreq
13322 @DefreqList {write, stream data}
13323 @DefreqListEnd {writec, stream data}
13324 @cindex copy-in mode, and @code{write} request
13325 @cindex @code{write} request, and copy-in mode
13326 @cindex mode, copy-in, and @code{write} request
13327 @cindex copy-in mode, and @code{writec} request
13328 @cindex @code{writec} request, and copy-in mode
13329 @cindex mode, copy-in, and @code{writec} request
13330 @cindex writing to file (@code{write}, @code{writec})
13331 @cindex file, writing to (@code{write}, @code{writec})
13332 Write to the file associated with the specified @var{stream}.  The
13333 stream must previously have been the subject of an open request.  The
13334 remainder of the line is interpreted as the @code{ds} request reads its
13335 second argument: A leading @samp{"} is stripped, and it is read in
13336 copy-in mode.
13338 The @code{writec} request is like @code{write}, but only @code{write}
13339 appends a newline to the data.
13340 @endDefreq
13342 @Defreq {writem, stream xx}
13343 @cindex @code{asciify} request, and @code{writem}
13344 Write the contents of the macro or string @var{xx} to the file
13345 associated with the specified @var{stream}.
13347 @cindex @code{writem} request, and copy-in mode
13348 @cindex copy-in mode, and @code{writem} request
13349 @cindex mode, copy-in, and @code{writem} request
13350 @var{xx} is read in copy mode, i.e., already formatted elements are
13351 ignored.  Consequently, diversions must be unformatted with the
13352 @code{asciify} request before calling @code{writem}.  Usually, this
13353 means a loss of information.
13354 @endDefreq
13356 @Defreq {close, stream}
13357 @cindex closing file (@code{close})
13358 @cindex file, closing (@code{close})
13359 Close the specified @var{stream}; the stream is no longer an acceptable
13360 argument to the @code{write} request.
13362 Here a simple macro to write an index entry.
13364 @Example
13365 .open idx test.idx
13367 .de IX
13368 .  write idx \\n[%] \\$*
13371 .IX test entry
13373 .close idx
13374 @endExample
13375 @endDefreq
13377 @DefescList {\\V, , e, }
13378 @DefescItem {\\V, @Lparen{}, ev, }
13379 @DefescListEnd {\\V, @Lbrack{}, env, @Rbrack{}}
13380 @cindex @code{\V}, and copy-in mode
13381 @cindex copy-in mode, and @code{\V}
13382 @cindex mode, copy-in, and @code{\V}
13383 Interpolate the contents of the specified environment variable @var{env}
13384 (one-character name@tie{}@var{e}, two-character name @var{ev}) as
13385 returned by the function @code{getenv}.  @code{\V} is interpreted in
13386 copy-in mode.
13387 @endDefesc
13390 @c =====================================================================
13392 @node Postprocessor Access, Miscellaneous, I/O, gtroff Reference
13393 @section Postprocessor Access
13394 @cindex postprocessor access
13395 @cindex access of postprocessor
13397 There are two escapes which give information directly to the
13398 postprocessor.  This is particularly useful for embedding
13399 @sc{PostScript} into the final document.
13401 @DefreqList {device, xxx}
13402 @DefescListEnd {\\X, ', xxx, '}
13403 Embeds its argument into the @code{gtroff} output preceded with
13404 @w{@samp{x X}}.
13406 @cindex @code{\&}, in @code{\X}
13407 @cindex @code{\)}, in @code{\X}
13408 @cindex @code{\%}, in @code{\X}
13409 @ifnotinfo
13410 @cindex @code{\:}, in @code{\X}
13411 @end ifnotinfo
13412 @ifinfo
13413 @cindex @code{\@r{<colon>}}, in @code{\X}
13414 @end ifinfo
13415 The escapes @code{\&}, @code{\)}, @code{\%}, and @code{\:} are ignored
13416 within @code{\X}, @w{@samp{\ }} and @code{\~} are converted to single
13417 space characters.  All other escapes (except @code{\\} which produces a
13418 backslash) cause an error.
13420 @cindex @code{device} request, and copy-in mode
13421 @cindex copy-in mode, and @code{device} request
13422 @cindex mode, copy-in, and @code{device} request
13423 Contrary to @code{\X}, the @code{device} request simply processes its
13424 argument in copy mode (@pxref{Copy-in Mode}).
13426 @kindex use_charnames_in_special
13427 @pindex DESC@r{, and @code{use_charnames_in_special}}
13428 @cindex @code{\X}, and special characters
13429 If the @samp{use_charnames_in_special} keyword is set in the @file{DESC}
13430 file, special characters no longer cause an error; they are simply
13431 output verbatim.  Additionally, the backslash is represented as
13432 @code{\\}.
13434 @samp{use_charnames_in_special} is currently used by @code{grohtml}
13435 only.
13436 @endDefesc
13438 @DefreqList {devicem, xx}
13439 @DefescItem {\\Y, , n, }
13440 @DefescItem {\\Y, @Lparen{}, nm, }
13441 @DefescListEnd {\\Y, @Lbrack{}, name, @Rbrack{}}
13442 This is approximately equivalent to @samp{\X'\*[@var{name}]'}
13443 (one-character name@tie{}@var{n}, two-character name @var{nm}).
13444 However, the contents of the string or macro @var{name} are not
13445 interpreted; also it is permitted for @var{name} to have been defined as
13446 a macro and thus contain newlines (it is not permitted for the argument
13447 to @code{\X} to contain newlines).  The inclusion of newlines requires
13448 an extension to the @acronym{UNIX} @code{troff} output format, and
13449 confuses drivers that do not know about this extension (@pxref{Device
13450 Control Commands}).
13451 @endDefesc
13453 @xref{Output Devices}.
13456 @c =====================================================================
13458 @node Miscellaneous, Gtroff Internals, Postprocessor Access, gtroff Reference
13459 @section Miscellaneous
13461 This section documents parts of @code{gtroff} which cannot (yet) be
13462 categorized elsewhere in this manual.
13464 @Defreq {nm, [@Var{start} [@Var{inc} [@Var{space} [@Var{indent}]]]]}
13465 @cindex printing line numbers (@code{nm})
13466 @cindex line numbers, printing (@code{nm})
13467 @cindex numbers, line, printing (@code{nm})
13468 Print line numbers.  @var{start} is the line number of the @emph{next}
13469 output line.  @var{inc} indicates which line numbers are printed.  For
13470 example, the value@tie{}5 means to emit only line numbers which are
13471 multiples of@tie{}5; this defaults to@tie{}1.  @var{space} is the space
13472 to be left between the number and the text; this defaults to one digit
13473 space.  The fourth argument is the indentation of the line numbers,
13474 defaulting to zero.  Both @var{space} and @var{indent} are given as
13475 multiples of digit spaces; they can be negative also.  Without any
13476 arguments, line numbers are turned off.
13478 @code{gtroff} reserves three digit spaces for the line number (which is
13479 printed right-justified) plus the amount given by @var{indent}; the
13480 output lines are concatenated to the line numbers, separated by
13481 @var{space}, and @emph{without} reducing the line length.  Depending on
13482 the value of the horizontal page offset (as set with the @code{po}
13483 request), line numbers which are longer than the reserved space stick
13484 out to the left, or the whole line is moved to the right.
13486 Parameters corresponding to missing arguments are not changed; any
13487 non-digit argument (to be more precise, any argument starting with a
13488 character valid as a delimiter for identifiers) is also treated as
13489 missing.
13491 If line numbering has been disabled with a call to @code{nm} without an
13492 argument, it can be reactivated with @samp{.nm +0}, using the previously
13493 active line numbering parameters.
13495 The parameters of @code{nm} are associated with the current environment
13496 (@pxref{Environments}).  The current output line number is available in
13497 the number register @code{ln}.
13499 @Example
13500 .po 1m
13501 .ll 2i
13502 This test shows how line numbering works with groff.
13503 .nm 999
13504 This test shows how line numbering works with groff.
13506 .nm xxx 3 2
13507 .ll -\w'0'u
13508 This test shows how line numbering works with groff.
13509 .nn 2
13510 This test shows how line numbering works with groff.
13511 @endExample
13513 @noindent
13514 And here the result:
13516 @Example
13517  This  test shows how
13518  line numbering works
13519  999 with   groff.   This
13520 1000 test shows how  line
13521 1001 numbering works with
13522 1002 groff.
13523       This test shows how
13524       line      numbering
13525  works  with  groff.
13526  This test shows how
13527 1005  line      numbering
13528       works with groff.
13529 @endExample
13530 @endDefreq
13532 @Defreq {nn, [@Var{skip}]}
13533 Temporarily turn off line numbering.  The argument is the number of
13534 lines not to be numbered; this defaults to@tie{}1.
13535 @endDefreq
13537 @Defreq {mc, glyph [@Var{dist}]}
13538 @cindex margin glyph (@code{mc})
13539 @cindex glyph, for margins (@code{mc})
13540 Print a @dfn{margin character} to the right of the
13541 text.@footnote{@dfn{Margin character} is a misnomer since it is an
13542 output glyph.}  The first argument is the glyph to be printed.  The
13543 second argument is the distance away from the right margin.  If missing,
13544 the previously set value is used; default is 10@dmn{pt}).  For text
13545 lines that are too long (that is, longer than the text length plus
13546 @var{dist}), the margin character is directly appended to the lines.
13548 With no arguments the margin character is turned off.  If this occurs
13549 before a break, no margin character is printed.
13551 For compatibility with @acronym{AT&T} @code{troff}, a call to @code{mc}
13552 to set the margin character can't be undone immediately; at least one
13553 line gets a margin character.  Thus
13555 @Example
13556 .ll 1i
13557 .mc \[br]
13562 @endExample
13564 @noindent
13565 produces
13567 @Example
13568 xxx        |
13570 @endExample
13572 @cindex @code{tl} request, and @code{mc}
13573 For empty lines and lines produced by the @code{tl} request no margin
13574 character is emitted.
13576 The margin character is associated with the current environment
13577 (@pxref{Environments}).
13579 @pindex nrchbar
13580 @pindex changebar
13581 This is quite useful for indicating text that has changed, and, in fact,
13582 there are programs available for doing this (they are called
13583 @code{nrchbar} and @code{changebar} and can be found in any
13584 @samp{comp.sources.unix} archive).
13586 @Example
13587 .ll 3i
13588 .mc |
13589 This paragraph is highlighted with a margin
13590 character.
13592 Note that vertical space isn't marked.
13596 But we can fake it with `\&'.
13597 @endExample
13599 Result:
13601 @Example
13602 This  paragraph is highlighted |
13603 with a margin character.       |
13605 Note that vertical space isn't |
13606 marked.                        |
13607                                |
13608 But we can fake it with `\&'.  |
13609 @endExample
13610 @endDefreq
13612 @DefreqList {psbb, filename}
13613 @DefregItem {llx}
13614 @DefregItem {lly}
13615 @DefregItem {urx}
13616 @DefregListEnd {ury}
13617 @cindex PostScript, bounding box
13618 @cindex bounding box
13619 Retrieve the bounding box of the PostScript image found in
13620 @var{filename}.  The file must conform to Adobe's @dfn{Document
13621 Structuring Conventions} (DSC); the command searches for a
13622 @code{%%BoundingBox} comment and extracts the bounding box values into
13623 the number registers @code{llx}, @code{lly}, @code{urx}, and @code{ury}.
13624 If an error occurs (for example, @code{psbb} cannot find the
13625 @code{%%BoundingBox} comment), it sets the four number registers to
13626 zero.
13628 The search path for @var{filename} can be controlled with the
13629 @option{-I} command line option.
13630 @endDefreq
13633 @c =====================================================================
13635 @node Gtroff Internals, Debugging, Miscellaneous, gtroff Reference
13636 @section @code{gtroff} Internals
13638 @cindex input token
13639 @cindex token, input
13640 @cindex output node
13641 @cindex node, output
13642 @code{gtroff} processes input in three steps.  One or more input
13643 characters are converted to an @dfn{input token}.@footnote{Except the
13644 escapes @code{\f}, @code{\F}, @code{\H}, @code{\m}, @code{\M},
13645 @code{\R}, @code{\s}, and @code{\S} which are processed immediately if
13646 not in copy-in mode.}  Then, one or more input tokens are converted to
13647 an @dfn{output node}.  Finally, output nodes are converted to the
13648 intermediate output language understood by all output devices.
13650 Actually, before step one happens, @code{gtroff} converts certain escape
13651 sequences into reserved input characters (not accessible by the user);
13652 such reserved characters are used for other internal processing also --
13653 this is the very reason why not all characters are valid input.
13654 @xref{Identifiers}, for more on this topic.
13656 For example, the input string @samp{fi\[:u]} is converted into a
13657 character token @samp{f}, a character token @samp{i}, and a special
13658 token @samp{:u} (representing u@tie{}umlaut).  Later on, the character
13659 tokens @samp{f} and @samp{i} are merged to a single output node
13660 representing the ligature glyph @samp{fi} (provided the current font has
13661 a glyph for this ligature); the same happens with @samp{:u}.  All output
13662 glyph nodes are `processed' which means that they are invariably
13663 associated with a given font, font size, advance width, etc.  During the
13664 formatting process, @code{gtroff} itself adds various nodes to control
13665 the data flow.
13667 Macros, diversions, and strings collect elements in two chained lists: a
13668 list of input tokens which have been passed unprocessed, and a list of
13669 output nodes.  Consider the following the diversion.
13671 @Example
13672 .di xxx
13678 @endExample
13680 @noindent
13681 It contains these elements.
13683 @multitable {@i{vertical size node}} {token list} {element number}
13684 @item node list               @tab token list @tab element number
13686 @item @i{line start node}     @tab ---        @tab 1
13687 @item @i{glyph node @code{a}} @tab ---        @tab 2
13688 @item @i{word space node}     @tab ---        @tab 3
13689 @item ---                     @tab @code{b}   @tab 4
13690 @item ---                     @tab @code{\n}  @tab 5
13691 @item @i{glyph node @code{c}} @tab ---        @tab 6
13692 @item @i{vertical size node}  @tab ---        @tab 7
13693 @item @i{vertical size node}  @tab ---        @tab 8
13694 @item ---                     @tab @code{\n}  @tab 9
13695 @end multitable
13697 @cindex @code{\v}, internal representation
13698 @noindent
13699 Elements 1, 7, and@tie{}8 are inserted by @code{gtroff}; the latter two
13700 (which are always present) specify the vertical extent of the last line,
13701 possibly modified by @code{\x}.  The @code{br} request finishes the
13702 current partial line, inserting a newline input token which is
13703 subsequently converted to a space when the diversion is reread.  Note
13704 that the word space node has a fixed width which isn't stretchable
13705 anymore.  To convert horizontal space nodes back to input tokens, use
13706 the @code{unformat} request.
13708 Macros only contain elements in the token list (and the node list is
13709 empty); diversions and strings can contain elements in both lists.
13711 Note that the @code{chop} request simply reduces the number of elements
13712 in a macro, string, or diversion by one.  Exceptions are
13713 @dfn{compatibility save} and @dfn{compatibility ignore} input tokens
13714 which are ignored.  The @code{substring} request also ignores those
13715 input tokens.
13717 Some requests like @code{tr} or @code{cflags} work on glyph identifiers
13718 only; this means that the associated glyph can be changed without
13719 destroying this association.  This can be very helpful for substituting
13720 glyphs.  In the following example, we assume that glyph @samp{foo} isn't
13721 available by default, so we provide a substitution using the
13722 @code{fchar} request and map it to input character @samp{x}.
13724 @Example
13725 .fchar \[foo] foo
13726 .tr x \[foo]
13727 @endExample
13729 @noindent
13730 Now let us assume that we install an additional special font @samp{bar}
13731 which has glyph @samp{foo}.
13733 @Example
13734 .special bar
13735 .rchar \[foo]
13736 @endExample
13738 @noindent
13739 Since glyphs defined with @code{fchar} are searched before glyphs in
13740 special fonts, we must call @code{rchar} to remove the definition of the
13741 fallback glyph.  Anyway, the translation is still active; @samp{x} now
13742 maps to the real glyph @samp{foo}.
13744 @cindex compatibility mode, and parameters
13745 @cindex mode, compatibility, and parameters
13746 @cindex arguments, and compatibility mode
13747 @cindex parameters, and compatibility mode
13748 @cindex macro arguments, and compatibility mode
13749 @cindex request arguments, and compatibility mode
13750 Macro and request arguments preserve the compatibility mode:
13752 @Example
13753 .cp 1     \" switch to compatibility mode
13754 .de xx
13755 \\$1
13757 .cp 0     \" switch compatibility mode off
13758 .xx caf\['e]
13759     @result{} café
13760 @endExample
13762 @noindent
13763 Since compatibility mode is on while @code{de} is called, the macro
13764 @code{xx} activates compatibility mode while executing.  Argument
13765 @code{$1} can still be handled properly because it inherits the
13766 compatibility mode status which was active at the point where @code{xx}
13767 is called.
13769 After expansion of the parameters, the compatibility save and restore
13770 tokens are removed.
13773 @c =====================================================================
13775 @node Debugging, Implementation Differences, Gtroff Internals, gtroff Reference
13776 @section Debugging
13777 @cindex debugging
13779 @code{gtroff} is not easy to debug, but there are some useful features
13780 and strategies for debugging.
13782 @Defreq {lf, line [@Var{filename}]}
13783 @pindex soelim
13784 @cindex multi-file documents
13785 @cindex documents, multi-file
13786 @cindex setting input line number (@code{lf})
13787 @cindex input line number, setting (@code{lf})
13788 @cindex number, input line, setting (@code{lf})
13789 Change the line number and optionally the file name @code{gtroff} shall
13790 use for error and warning messages.  @var{line} is the input line number
13791 of the @emph{next} line.
13793 Without argument, the request is ignored.
13795 This is a debugging aid for documents which are split into many files,
13796 then put together with @code{soelim} and other preprocessors.  Usually,
13797 it isn't invoked manually.
13799 Note that other @code{troff} implementations (including the original
13800 @acronym{AT&T} version) handle @code{lf} differently.  For them,
13801 @var{line} changes the line number of the @emph{current} line.
13802 @endDefreq
13804 @DefreqList {tm, string}
13805 @DefreqItem {tm1, string}
13806 @DefreqListEnd {tmc, string}
13807 @cindex printing to stderr (@code{tm}, @code{tm1}, @code{tmc})
13808 @cindex stderr, printing to (@code{tm}, @code{tm1}, @code{tmc})
13809 Send @var{string} to the standard error output; this is very useful for
13810 printing debugging messages among other things.
13812 @cindex @code{tm} request, and copy-in mode
13813 @cindex copy-in mode, and @code{tm} request
13814 @cindex mode, copy-in, and @code{tm} request
13815 @cindex @code{tm1} request, and copy-in mode
13816 @cindex copy-in mode, and @code{tm1} request
13817 @cindex mode, copy-in, and @code{tm1} request
13818 @cindex @code{tmc} request, and copy-in mode
13819 @cindex copy-in mode, and @code{tmc} request
13820 @cindex mode, copy-in, and @code{tmc} request
13821 @var{string} is read in copy mode.
13823 The @code{tm} request ignores leading spaces of @var{string}; @code{tm1}
13824 handles its argument similar to the @code{ds} request: a leading double
13825 quote in @var{string} is stripped to allow initial blanks.
13827 The @code{tmc} request is similar to @code{tm1} but does not append a
13828 newline (as is done in @code{tm} and @code{tm1}).
13829 @endDefreq
13831 @Defreq {ab, [@Var{string}]}
13832 @cindex aborting (@code{ab})
13833 Similar to the @code{tm} request, except that it causes @code{gtroff} to
13834 stop processing.  With no argument it prints @samp{User Abort.} to
13835 standard error.
13836 @endDefreq
13838 @Defreq {ex, }
13839 @cindex @code{ex} request, use in debugging
13840 @cindex exiting (@code{ex})
13841 The @code{ex} request also causes @code{gtroff} to stop processing; see
13842 also @ref{I/O}.
13843 @endDefreq
13845 When doing something involved it is useful to leave the debugging
13846 statements in the code and have them turned on by a command line flag.
13848 @Example
13849 .if \n(DB .tm debugging output
13850 @endExample
13852 @noindent
13853 To activate these statements say
13855 @Example
13856 groff -rDB=1 file
13857 @endExample
13859 If it is known in advance that there are many errors and no useful
13860 output, @code{gtroff} can be forced to suppress formatted output with
13861 the @option{-z} flag.
13863 @Defreq {pev, }
13864 @cindex dumping environments (@code{pev})
13865 @cindex environments, dumping (@code{pev})
13866 Print the contents of the current environment and all the currently
13867 defined environments (both named and numbered) on @code{stderr}.
13868 @endDefreq
13870 @Defreq {pm, }
13871 @cindex dumping symbol table (@code{pm})
13872 @cindex symbol table, dumping (@code{pm})
13873 Print the entire symbol table on @code{stderr}.  Names of all defined
13874 macros, strings, and diversions are print together with their size in
13875 bytes.  Since @code{gtroff} sometimes adds nodes by itself, the returned
13876 size can be larger than expected.
13878 This request differs from @acronym{UNIX} @code{troff}: @code{gtroff}
13879 reports the sizes of diversions, ignores an additional argument to print
13880 only the total of the sizes, and the size isn't returned in blocks of
13881 128 characters.
13882 @endDefreq
13884 @Defreq {pnr, }
13885 @cindex dumping number registers (@code{pnr})
13886 @cindex number registers, dumping (@code{pnr})
13887 Print the names and contents of all currently defined number registers
13888 on @code{stderr}.
13889 @endDefreq
13891 @Defreq {ptr, }
13892 @cindex dumping traps (@code{ptr})
13893 @cindex traps, dumping (@code{ptr})
13894 Print the names and positions of all traps (not including input line
13895 traps and diversion traps) on @code{stderr}.  Empty slots in the page
13896 trap list are printed as well, because they can affect the priority of
13897 subsequently planted traps.
13898 @endDefreq
13900 @Defreq {fl, }
13901 @cindex flush output (@code{fl})
13902 @cindex output, flush (@code{fl})
13903 @cindex interactive use of @code{gtroff}
13904 @cindex @code{gtroff}, interactive use
13905 Instruct @code{gtroff} to flush its output immediately.  The intent is
13906 for interactive use, but this behaviour is currently not implemented in
13907 @code{gtroff}.  Contrary to @acronym{UNIX} @code{troff}, TTY output is
13908 sent to a device driver also (@code{grotty}), making it non-trivial to
13909 communicate interactively.
13911 This request causes a line break.
13912 @endDefreq
13914 @Defreq {backtrace, }
13915 @cindex backtrace of input stack (@code{backtrace})
13916 @cindex input stack, backtrace (@code{backtrace})
13917 Print a backtrace of the input stack to the standard error stream.
13919 Consider the following in file @file{test}:
13921 @Example
13922 .de xxx
13923 .  backtrace
13925 .de yyy
13926 .  xxx
13929 .yyy
13930 @endExample
13932 @noindent
13933 On execution, @code{gtroff} prints the following:
13935 @Example
13936 test:2: backtrace: macro `xxx'
13937 test:5: backtrace: macro `yyy'
13938 test:8: backtrace: file `test'
13939 @endExample
13941 The option @option{-b} of @code{gtroff} internally calls a variant of
13942 this request on each error and warning.
13943 @endDefreq
13945 @Defreg {slimit}
13946 @cindex input stack, setting limit
13947 Use the @code{slimit} number register to set the maximum number of
13948 objects on the input stack.  If @code{slimit} is less than or equal
13949 to@tie{}0, there is no limit set.  With no limit, a buggy recursive
13950 macro can exhaust virtual memory.
13952 The default value is 1000; this is a compile-time constant.
13953 @endDefreg
13955 @Defreq {warnscale, si}
13956 Set the scaling indicator used in warnings to @var{si}.  Valid values
13957 for @var{si} are @samp{u}, @samp{i}, @samp{c}, @samp{p}, and @samp{P}.
13958 At startup, it is set to @samp{i}.
13959 @endDefreq
13961 @Defreq {spreadwarn, [@Var{limit}]}
13962 Make @code{gtroff} emit a warning if the additional space inserted for
13963 each space between words in an output line is larger or equal to
13964 @var{limit}.  A negative value is changed to zero; no argument toggles
13965 the warning on and off without changing @var{limit}.  The default
13966 scaling indicator is @samp{m}.  At startup, @code{spreadwarn} is
13967 deactivated, and @var{limit} is set to 3@dmn{m}.
13969 For example,
13971 @Example
13972 .spreadwarn 0.2m
13973 @endExample
13975 @noindent
13976 causes a warning if @code{gtroff} must add 0.2@dmn{m} or more for each
13977 interword space in a line.
13979 This request is active only if text is justified to both margins (using
13980 @w{@samp{.ad b}}).
13981 @endDefreq
13983 @cindex warnings
13984 @code{gtroff} has command line options for printing out more warnings
13985 (@option{-w}) and for printing backtraces (@option{-b}) when a warning
13986 or an error occurs.  The most verbose level of warnings is @option{-ww}.
13988 @DefreqList {warn, [@Var{flags}]}
13989 @DefregListEnd {.warn}
13990 @cindex level of warnings (@code{warn})
13991 @cindex warnings, level (@code{warn})
13992 Control the level of warnings checked for.  The @var{flags} are the sum
13993 of the numbers associated with each warning that is to be enabled; all
13994 other warnings are disabled.  The number associated with each warning is
13995 listed below.  For example, @w{@code{.warn 0}} disables all warnings,
13996 and @w{@code{.warn 1}} disables all warnings except that about missing
13997 glyphs.  If no argument is given, all warnings are enabled.
13999 The read-only number register @code{.warn} contains the current warning
14000 level.
14001 @endDefreq
14003 @menu
14004 * Warnings::
14005 @end menu
14007 @c ---------------------------------------------------------------------
14009 @node Warnings,  , Debugging, Debugging
14010 @subsection Warnings
14011 @cindex warnings
14013 The warnings that can be given to @code{gtroff} are divided into the
14014 following categories.  The name associated with each warning is used by
14015 the @option{-w} and @option{-W} options; the number is used by the
14016 @code{warn} request and by the @code{.warn} register.
14018 @table @samp
14019 @item char
14020 @itemx 1
14021 Non-existent glyphs.@footnote{@code{char} is a misnomer since it reports
14022 missing glyphs -- there aren't missing input characters, only invalid
14023 ones.}  This is enabled by default.
14025 @item number
14026 @itemx 2
14027 Invalid numeric expressions.  This is enabled by default.
14028 @xref{Expressions}.
14030 @item break
14031 @itemx 4
14032 @cindex fill mode
14033 @cindex mode, fill
14034 In fill mode, lines which could not be broken so that their length was
14035 less than the line length.  This is enabled by default.
14037 @item delim
14038 @itemx 8
14039 Missing or mismatched closing delimiters.
14041 @item el
14042 @itemx 16
14043 @cindex @code{ie} request, and warnings
14044 @cindex @code{el} request, and warnings
14045 Use of the @code{el} request with no matching @code{ie} request.
14046 @xref{if-else}.
14048 @item scale
14049 @itemx 32
14050 Meaningless scaling indicators.
14052 @item range
14053 @itemx 64
14054 Out of range arguments.
14056 @item syntax
14057 @itemx 128
14058 Dubious syntax in numeric expressions.
14060 @item di
14061 @itemx 256
14062 @cindex @code{di} request, and warnings
14063 @cindex @code{da} request, and warnings
14064 Use of @code{di} or @code{da} without an argument when there is no
14065 current diversion.
14067 @item mac
14068 @itemx 512
14069 @cindex @code{de}, @code{de1}, @code{dei} requests, and warnings
14070 @cindex @code{am}, @code{am1}, @code{ami} requests, and warnings
14071 @cindex @code{ds}, @code{ds1} requests, and warnings
14072 @cindex @code{as}, @code{as1} requests, and warnings
14073 @cindex @code{di} request, and warnings
14074 @cindex @code{da} request, and warnings
14075 @cindex @code{box}, @code{boxa} requests, and warnings
14076 @cindex @code{\*}, and warnings
14077 Use of undefined strings, macros and diversions.  When an undefined
14078 string, macro, or diversion is used, that string is automatically
14079 defined as empty.  So, in most cases, at most one warning is given for
14080 each name.
14082 @item reg
14083 @itemx 1024
14084 @cindex @code{nr} request, and warnings
14085 @cindex @code{\R}, and warnings
14086 @cindex @code{\n}, and warnings
14087 Use of undefined number registers.  When an undefined number register is
14088 used, that register is automatically defined to have a value of@tie{}0.
14089 So, in most cases, at most one warning is given for use of a particular
14090 name.
14092 @item tab
14093 @itemx 2048
14094 @cindex @code{\t}, and warnings
14095 Use of a tab character where a number was expected.
14097 @item right-brace
14098 @itemx 4096
14099 @cindex @code{\@}}, and warnings
14100 Use of @code{\@}} where a number was expected.
14102 @item missing
14103 @itemx 8192
14104 Requests that are missing non-optional arguments.
14106 @item input
14107 @itemx 16384
14108 Invalid input characters.
14110 @item escape
14111 @itemx 32768
14112 Unrecognized escape sequences.  When an unrecognized escape sequence
14113 @code{\@var{X}} is encountered, the escape character is ignored, and
14114 @var{X} is printed.
14116 @item space
14117 @itemx 65536
14118 @cindex compatibility mode
14119 Missing space between a request or macro and its argument.  This warning
14120 is given when an undefined name longer than two characters is
14121 encountered, and the first two characters of the name make a defined
14122 name.  The request or macro is not invoked.  When this warning is given,
14123 no macro is automatically defined.  This is enabled by default.  This
14124 warning never occurs in compatibility mode.
14126 @item font
14127 @itemx 131072
14128 Non-existent fonts.  This is enabled by default.
14130 @item ig
14131 @itemx 262144
14132 Invalid escapes in text ignored with the @code{ig} request.  These are
14133 conditions that are errors when they do not occur in ignored text.
14135 @item color
14136 @itemx 524288
14137 Color related warnings.
14139 @item all
14140 All warnings except @samp{di}, @samp{mac} and @samp{reg}.  It is
14141 intended that this covers all warnings that are useful with traditional
14142 macro packages.
14144 @item w
14145 All warnings.
14146 @end table
14149 @c =====================================================================
14151 @node Implementation Differences,  , Debugging, gtroff Reference
14152 @section Implementation Differences
14153 @cindex implementation differences
14154 @cindex differences in implementation
14155 @cindex incompatibilities with @acronym{AT&T} @code{troff}
14156 @cindex compatibility mode
14157 @cindex mode, compatibility
14159 GNU @code{troff} has a number of features which cause incompatibilities
14160 with documents written with old versions of @code{troff}.
14162 @cindex long names
14163 @cindex names, long
14164 Long names cause some incompatibilities.  @acronym{UNIX} @code{troff}
14165 interprets
14167 @Example
14168 .dsabcd
14169 @endExample
14171 @cindex @code{\*}, incompatibilities with @acronym{AT&T} @code{troff}
14172 @cindex @code{\n}, incompatibilities with @acronym{AT&T} @code{troff}
14173 @noindent
14174 as defining a string @samp{ab} with contents @samp{cd}.  Normally, GNU
14175 @code{troff} interprets this as a call of a macro named @code{dsabcd}.
14176 Also @acronym{UNIX} @code{troff} interprets @code{\*[} or @code{\n[} as
14177 references to a string or number register called @samp{[}.  In GNU
14178 @code{troff}, however, this is normally interpreted as the start of a
14179 long name.  In compatibility mode GNU @code{troff} interprets long names
14180 in the traditional way (which means that they are not recognized as
14181 names).
14183 @DefreqList {cp, [@Var{n}]}
14184 @DefreqItem {do, cmd}
14185 @DefregListEnd {.C}
14186 If @var{n} is missing or non-zero, turn on compatibility mode;
14187 otherwise, turn it off.
14189 The read-only number register @code{.C} is@tie{}1 if compatibility mode
14190 is on, 0@tie{}otherwise.
14192 Compatibility mode can be also turned on with the @option{-C} command
14193 line option.
14195 The @code{do} request turns off compatibility mode while executing its
14196 arguments as a @code{gtroff} command.  However, it does not turn off
14197 compatibility mode while processing the macro itself.  To do that, use
14198 the @code{de1} request (or manipulate the @code{.C} register manually).
14199 @xref{Writing Macros}.
14201 @Example
14202 .do fam T
14203 @endExample
14205 @noindent
14206 executes the @code{fam} request when compatibility mode is enabled.
14208 @code{gtroff} restores the previous compatibility setting before
14209 interpreting any files sourced by the @var{cmd}.
14210 @endDefreq
14212 @cindex input level in delimited arguments
14213 @cindex delimited arguments, incompatibilities with @acronym{AT&T} @code{troff}
14214 Two other features are controlled by @option{-C}.  If not in
14215 compatibility mode, GNU @code{troff} preserves the input level in
14216 delimited arguments:
14218 @Example
14219 .ds xx '
14220 \w'abc\*(xxdef'
14221 @endExample
14223 @noindent
14224 In compatibility mode, the string @samp{72def'} is returned; without
14225 @option{-C} the resulting string is @samp{168} (assuming a TTY output
14226 device).
14228 @cindex @code{\f}, incompatibilities with @acronym{AT&T} @code{troff}
14229 @cindex @code{\H}, incompatibilities with @acronym{AT&T} @code{troff}
14230 @cindex @code{\s}, incompatibilities with @acronym{AT&T} @code{troff}
14231 @cindex @code{\S}, incompatibilities with @acronym{AT&T} @code{troff}
14232 Finally, the escapes @code{\f}, @code{\H}, @code{\m}, @code{\M},
14233 @code{\R}, @code{\s}, and @code{\S} are transparent for recognizing the
14234 beginning of a line only in compatibility mode (this is a rather obscure
14235 feature).  For example, the code
14237 @Example
14238 .de xx
14239 Hallo!
14241 \fB.xx\fP
14242 @endExample
14244 @noindent
14245 prints @samp{Hallo!} in bold face if in compatibility mode, and
14246 @samp{.xx} in bold face otherwise.
14248 @cindex @code{\A}, incompatibilities with @acronym{AT&T} @code{troff}
14249 @cindex @code{\|}, incompatibilities with @acronym{AT&T} @code{troff}
14250 @cindex @code{\^}, incompatibilities with @acronym{AT&T} @code{troff}
14251 @cindex @code{\&}, incompatibilities with @acronym{AT&T} @code{troff}
14252 @cindex @code{\@{}, incompatibilities with @acronym{AT&T} @code{troff}
14253 @cindex @code{\@}}, incompatibilities with @acronym{AT&T} @code{troff}
14254 @cindex @code{\@key{SP}}, incompatibilities with @acronym{AT&T} @code{troff}
14255 @cindex @code{\'}, incompatibilities with @acronym{AT&T} @code{troff}
14256 @cindex @code{\`}, incompatibilities with @acronym{AT&T} @code{troff}
14257 @cindex @code{\-}, incompatibilities with @acronym{AT&T} @code{troff}
14258 @cindex @code{\_}, incompatibilities with @acronym{AT&T} @code{troff}
14259 @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
14260 @cindex @code{\%}, incompatibilities with @acronym{AT&T} @code{troff}
14261 @cindex @code{\c}, incompatibilities with @acronym{AT&T} @code{troff}
14262 GNU @code{troff} does not allow the use of the escape sequences
14263 @code{\|}, @code{\^}, @code{\&}, @code{\@{}, @code{\@}},
14264 @code{\@key{SP}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
14265 @code{\%}, and @code{\c} in names of strings, macros, diversions, number
14266 registers, fonts or environments; @acronym{UNIX} @code{troff} does.  The
14267 @code{\A} escape sequence (@pxref{Identifiers}) may be helpful in
14268 avoiding use of these escape sequences in names.
14270 @cindex fractional point sizes
14271 @cindex fractional type sizes
14272 @cindex point sizes, fractional
14273 @cindex type sizes, fractional
14274 @cindex sizes, fractional
14275 @cindex @code{ps} request, incompatibilities with @acronym{AT&T} @code{troff}
14276 Fractional point sizes cause one noteworthy incompatibility.  In
14277 @acronym{UNIX} @code{troff} the @code{ps} request ignores scale
14278 indicators and thus
14280 @Example
14281 .ps 10u
14282 @endExample
14284 @noindent
14285 sets the point size to 10@tie{}points, whereas in GNU @code{troff} it
14286 sets the point size to 10@tie{}scaled points.  @xref{Fractional Type
14287 Sizes}, for more information.
14289 @cindex @code{bd} request, incompatibilities with @acronym{AT&T} @code{troff}
14290 @cindex @code{cs} request, incompatibilities with @acronym{AT&T} @code{troff}
14291 @cindex @code{tr} request, incompatibilities with @acronym{AT&T} @code{troff}
14292 @cindex @code{fp} request, incompatibilities with @acronym{AT&T} @code{troff}
14293 @cindex input characters and output glyphs, compatibility with @acronym{AT&T} @code{troff}
14294 @cindex output glyphs, and input characters,compatibility with @acronym{AT&T} @code{troff}
14295 @cindex characters, input, and output glyphs, compatibility with @acronym{AT&T} @code{troff}
14296 @cindex glyphs, output, and input characters, compatibility with @acronym{AT&T} @code{troff}
14297 In GNU @code{troff} there is a fundamental difference between
14298 (unformatted) input characters and (formatted) output glyphs.
14299 Everything that affects how a glyph is output is stored with the glyph
14300 node; once a glyph node has been constructed it is unaffected by any
14301 subsequent requests that are executed, including @code{bd}, @code{cs},
14302 @code{tkf}, @code{tr}, or @code{fp} requests.  Normally glyphs are
14303 constructed from input characters at the moment immediately before the
14304 glyph is added to the current output line.  Macros, diversions and
14305 strings are all, in fact, the same type of object; they contain lists of
14306 input characters and glyph nodes in any combination.  A glyph node does
14307 not behave like an input character for the purposes of macro processing;
14308 it does not inherit any of the special properties that the input
14309 character from which it was constructed might have had.  For example,
14311 @Example
14312 .di x
14313 \\\\
14317 @endExample
14319 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
14320 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
14321 @cindex @code{\e}, incompatibilities with @acronym{AT&T} @code{troff}
14322 @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
14323 @cindex @code{\?}, incompatibilities with @acronym{AT&T} @code{troff}
14324 @cindex transparent output, incompatibilities with @acronym{AT&T} @code{troff}
14325 @cindex output, transparent, incompatibilities with @acronym{AT&T} @code{troff}
14326 @noindent
14327 prints @samp{\\} in GNU @code{troff}; each pair of input backslashes is
14328 turned into one output backslash and the resulting output backslashes
14329 are not interpreted as escape characters when they are reread.
14330 @acronym{UNIX} @code{troff} would interpret them as escape characters
14331 when they were reread and would end up printing one @samp{\}.  The
14332 correct way to obtain a printable backslash is to use the @code{\e}
14333 escape sequence: This always prints a single instance of the current
14334 escape character, regardless of whether or not it is used in a
14335 diversion; it also works in both GNU @code{troff} and @acronym{UNIX}
14336 @code{troff}.@footnote{To be completely independent of the current
14337 escape character, use @code{\(rs} which represents a reverse solidus
14338 (backslash) glyph.}  To store, for some reason, an escape sequence in a
14339 diversion that is interpreted when the diversion is reread, either use
14340 the traditional @code{\!} transparent output facility, or, if this is
14341 unsuitable, the new @code{\?} escape sequence.
14343 @xref{Diversions}, and @ref{Gtroff Internals}, for more information.
14347 @c =====================================================================
14348 @c =====================================================================
14350 @node Preprocessors, Output Devices, gtroff Reference, Top
14351 @chapter Preprocessors
14352 @cindex preprocessors
14354 This chapter describes all preprocessors that come with @code{groff} or
14355 which are freely available.
14357 @menu
14358 * geqn::
14359 * gtbl::
14360 * gpic::
14361 * ggrn::
14362 * grap::
14363 * grefer::
14364 * gsoelim::
14365 @end menu
14368 @c =====================================================================
14370 @node geqn, gtbl, Preprocessors, Preprocessors
14371 @section @code{geqn}
14372 @cindex @code{eqn}, the program
14373 @cindex @code{geqn}, the program
14375 @c XXX
14377 @menu
14378 * Invoking geqn::
14379 @end menu
14381 @c ---------------------------------------------------------------------
14383 @node Invoking geqn,  , geqn, geqn
14384 @subsection Invoking @code{geqn}
14385 @cindex invoking @code{geqn}
14386 @cindex @code{geqn}, invoking
14388 @c XXX
14391 @c =====================================================================
14393 @node gtbl, gpic, geqn, Preprocessors
14394 @section @code{gtbl}
14395 @cindex @code{tbl}, the program
14396 @cindex @code{gtbl}, the program
14398 @c XXX
14400 @menu
14401 * Invoking gtbl::
14402 @end menu
14404 @c ---------------------------------------------------------------------
14406 @node Invoking gtbl,  , gtbl, gtbl
14407 @subsection Invoking @code{gtbl}
14408 @cindex invoking @code{gtbl}
14409 @cindex @code{gtbl}, invoking
14411 @c XXX
14414 @c =====================================================================
14416 @node gpic, ggrn, gtbl, Preprocessors
14417 @section @code{gpic}
14418 @cindex @code{pic}, the program
14419 @cindex @code{gpic}, the program
14421 @c XXX
14423 @menu
14424 * Invoking gpic::
14425 @end menu
14427 @c ---------------------------------------------------------------------
14429 @node Invoking gpic,  , gpic, gpic
14430 @subsection Invoking @code{gpic}
14431 @cindex invoking @code{gpic}
14432 @cindex @code{gpic}, invoking
14434 @c XXX
14437 @c =====================================================================
14439 @node ggrn, grap, gpic, Preprocessors
14440 @section @code{ggrn}
14441 @cindex @code{grn}, the program
14442 @cindex @code{ggrn}, the program
14444 @c XXX
14446 @menu
14447 * Invoking ggrn::
14448 @end menu
14450 @c ---------------------------------------------------------------------
14452 @node Invoking ggrn,  , ggrn, ggrn
14453 @subsection Invoking @code{ggrn}
14454 @cindex invoking @code{ggrn}
14455 @cindex @code{ggrn}, invoking
14457 @c XXX
14460 @c =====================================================================
14462 @node grap, grefer, ggrn, Preprocessors
14463 @section @code{grap}
14464 @cindex @code{grap}, the program
14466 A free implementation of @code{grap}, written by Ted Faber,
14467 is available as an extra package from the following address:
14469 @display
14470 @uref{http://www.lunabase.org/~faber/Vault/software/grap/}
14471 @end display
14474 @c =====================================================================
14476 @node grefer, gsoelim, grap, Preprocessors
14477 @section @code{grefer}
14478 @cindex @code{refer}, the program
14479 @cindex @code{grefer}, the program
14481 @c XXX
14483 @menu
14484 * Invoking grefer::
14485 @end menu
14487 @c ---------------------------------------------------------------------
14489 @node Invoking grefer,  , grefer, grefer
14490 @subsection Invoking @code{grefer}
14491 @cindex invoking @code{grefer}
14492 @cindex @code{grefer}, invoking
14494 @c XXX
14497 @c =====================================================================
14499 @node gsoelim,  , grefer, Preprocessors
14500 @section @code{gsoelim}
14501 @cindex @code{soelim}, the program
14502 @cindex @code{gsoelim}, the program
14504 @c XXX
14506 @menu
14507 * Invoking gsoelim::
14508 @end menu
14510 @c ---------------------------------------------------------------------
14512 @node Invoking gsoelim,  , gsoelim, gsoelim
14513 @subsection Invoking @code{gsoelim}
14514 @cindex invoking @code{gsoelim}
14515 @cindex @code{gsoelim}, invoking
14517 @c XXX
14521 @c =====================================================================
14522 @c =====================================================================
14524 @node Output Devices, File formats, Preprocessors, Top
14525 @chapter Output Devices
14526 @cindex output devices
14527 @cindex devices for output
14529 @c XXX
14531 @menu
14532 * Special Characters::
14533 * grotty::
14534 * grops::
14535 * grodvi::
14536 * grolj4::
14537 * grolbp::
14538 * grohtml::
14539 * gxditview::
14540 @end menu
14543 @c =====================================================================
14545 @node Special Characters, grotty, Output Devices, Output Devices
14546 @section Special Characters
14547 @cindex special characters
14548 @cindex characters, special
14550 @c XXX
14552 @xref{Font Files}.
14555 @c =====================================================================
14557 @node grotty, grops, Special Characters, Output Devices
14558 @section @code{grotty}
14559 @cindex @code{grotty}, the program
14561 @c XXX
14563 @menu
14564 * Invoking grotty::
14565 @end menu
14567 @c ---------------------------------------------------------------------
14569 @node Invoking grotty,  , grotty, grotty
14570 @subsection Invoking @code{grotty}
14571 @cindex invoking @code{grotty}
14572 @cindex @code{grotty}, invoking
14574 @c XXX
14576 @c The following is no longer true; fix and extend it.
14578 @c @pindex less
14579 @c @cindex Teletype
14580 @c @cindex ISO 6249 SGR
14581 @c @cindex terminal control sequences
14582 @c @cindex control sequences, for terminals
14583 @c For TTY output devices, underlining is done by emitting sequences of
14584 @c @samp{_} and @samp{\b} (the backspace character) before the actual
14585 @c character.  Literally, this is printing an underline character, then
14586 @c moving back one character position, and printing the actual character
14587 @c at the same position as the underline character (similar to a
14588 @c typewriter).  Usually, a modern terminal can't interpret this (and
14589 @c the original Teletype machines for which this sequence was
14590 @c appropriate are no longer in use).  You need a pager program like
14591 @c @code{less} which translates this into ISO 6429 SGR sequences to
14592 @c control terminals.
14595 @c =====================================================================
14597 @node grops, grodvi, grotty, Output Devices
14598 @section @code{grops}
14599 @cindex @code{grops}, the program
14601 @c XXX
14603 @menu
14604 * Invoking grops::
14605 * Embedding PostScript::
14606 @end menu
14608 @c ---------------------------------------------------------------------
14610 @node Invoking grops, Embedding PostScript, grops, grops
14611 @subsection Invoking @code{grops}
14612 @cindex invoking @code{grops}
14613 @cindex @code{grops}, invoking
14615 @c XXX
14617 @c ---------------------------------------------------------------------
14619 @node Embedding PostScript,  , Invoking grops, grops
14620 @subsection Embedding @sc{PostScript}
14621 @cindex embedding PostScript
14622 @cindex PostScript, embedding
14624 @c XXX
14627 @c =====================================================================
14629 @node grodvi, grolj4, grops, Output Devices
14630 @section @code{grodvi}
14631 @cindex @code{grodvi}, the program
14633 @c XXX
14635 @menu
14636 * Invoking grodvi::
14637 @end menu
14639 @c ---------------------------------------------------------------------
14641 @node Invoking grodvi,  , grodvi, grodvi
14642 @subsection Invoking @code{grodvi}
14643 @cindex invoking @code{grodvi}
14644 @cindex @code{grodvi}, invoking
14646 @c XXX
14649 @c =====================================================================
14651 @node grolj4, grolbp, grodvi, Output Devices
14652 @section @code{grolj4}
14653 @cindex @code{grolj4}, the program
14655 @c XXX
14657 @menu
14658 * Invoking grolj4::
14659 @end menu
14661 @c ---------------------------------------------------------------------
14663 @node Invoking grolj4,  , grolj4, grolj4
14664 @subsection Invoking @code{grolj4}
14665 @cindex invoking @code{grolj4}
14666 @cindex @code{grolj4}, invoking
14668 @c XXX
14671 @c =====================================================================
14673 @node grolbp, grohtml, grolj4, Output Devices
14674 @section @code{grolbp}
14675 @cindex @code{grolbp}, the program
14677 @c XXX
14679 @menu
14680 * Invoking grolbp::
14681 @end menu
14683 @c ---------------------------------------------------------------------
14685 @node Invoking grolbp,  , grolbp, grolbp
14686 @subsection Invoking @code{grolbp}
14687 @cindex invoking @code{grolbp}
14688 @cindex @code{grolbp}, invoking
14690 @c XXX
14693 @c =====================================================================
14695 @node grohtml, gxditview, grolbp, Output Devices
14696 @section @code{grohtml}
14697 @cindex @code{grohtml}, the program
14699 @c XXX
14701 @menu
14702 * Invoking grohtml::
14703 * grohtml specific registers and strings::
14704 @end menu
14706 @c ---------------------------------------------------------------------
14708 @node Invoking grohtml, grohtml specific registers and strings, grohtml, grohtml
14709 @subsection Invoking @code{grohtml}
14710 @cindex invoking @code{grohtml}
14711 @cindex @code{grohtml}, invoking
14713 @c XXX
14715 @c ---------------------------------------------------------------------
14717 @node grohtml specific registers and strings,  , Invoking grohtml, grohtml
14718 @subsection @code{grohtml} specific registers and strings
14719 @cindex registers specific to @code{grohtml}
14720 @cindex strings specific to @code{grohtml}
14721 @cindex @code{grohtml}, registers and strings
14723 @DefmpregList {ps4html, grohtml}
14724 @DefstrListEnd {www-image-template, grohtml}
14725 The registers @code{ps4html} and @code{www-image-template} are defined
14726 by the @code{pre-grohtml} preprocessor.  @code{pre-grohtml} reads in the
14727 @code{troff} input, marks up the inline equations and passes the result
14728 firstly to
14730 @Example
14731 troff -Tps -rps4html=1 -dwww-image-template=@var{template}
14732 @endExample
14734 @noindent
14735 and secondly to
14737 @Example
14738 troff -Thtml
14739 @endExample
14741 @noindent
14744 @Example
14745 troff -Txhtml
14746 @endExample
14748 @cindex MathML
14749 The PostScript device is used to create all the image files (for
14750 @option{-Thtml}; if @option{-Txhtml} is used, all equations are passed
14751 to @code{geqn} to produce @acronym{MathML}, and the register
14752 @code{ps4html} enables the macro sets to ignore floating keeps, footers,
14753 and headings.
14755 The register @code{www-image-template} is set to the user specified
14756 template name or the default name.
14757 @endDefmpreg
14760 @c =====================================================================
14762 @node gxditview,  , grohtml, Output Devices
14763 @section @code{gxditview}
14764 @cindex @code{gxditview}, the program
14766 @c XXX
14768 @menu
14769 * Invoking gxditview::
14770 @end menu
14772 @c ---------------------------------------------------------------------
14774 @node Invoking gxditview,  , gxditview, gxditview
14775 @subsection Invoking @code{gxditview}
14776 @cindex invoking @code{gxditview}
14777 @cindex @code{gxditview}, invoking
14779 @c XXX
14780 @c X11's xditview
14784 @c =====================================================================
14785 @c =====================================================================
14787 @node File formats, Installation, Output Devices, Top
14788 @chapter File formats
14789 @cindex file formats
14790 @cindex formats, file
14792 All files read and written by @code{gtroff} are text files.  The
14793 following two sections describe their format.
14795 @menu
14796 * gtroff Output::
14797 * Font Files::
14798 @end menu
14801 @c =====================================================================
14803 @node gtroff Output, Font Files, File formats, File formats
14804 @section @code{gtroff} Output
14805 @cindex @code{gtroff}, output
14806 @cindex output, @code{gtroff}
14808 This section describes the intermediate output format of GNU
14809 @code{troff}.  This output is produced by a run of @code{gtroff} before
14810 it is fed into a device postprocessor program.
14812 As @code{groff} is a wrapper program around @code{gtroff} that
14813 automatically calls a postprocessor, this output does not show up
14814 normally.  This is why it is called @dfn{intermediate}.  @code{groff}
14815 provides the option @option{-Z} to inhibit postprocessing, such that the
14816 produced intermediate output is sent to standard output just like
14817 calling @code{gtroff} manually.
14819 @cindex troff output
14820 @cindex output, troff
14821 @cindex intermediate output
14822 @cindex output, intermediate
14823 Here, the term @dfn{troff output} describes what is output by
14824 @code{gtroff}, while @dfn{intermediate output} refers to the language
14825 that is accepted by the parser that prepares this output for the
14826 postprocessors.  This parser is smarter on whitespace and implements
14827 obsolete elements for compatibility, otherwise both formats are the
14828 same.@footnote{The parser and postprocessor for intermediate output can
14829 be found in the file@*
14830 @file{@var{groff-source-dir}/src/libs/libdriver/input.cpp}.}
14832 The main purpose of the intermediate output concept is to facilitate the
14833 development of postprocessors by providing a common programming
14834 interface for all devices.  It has a language of its own that is
14835 completely different from the @code{gtroff} language.  While the
14836 @code{gtroff} language is a high-level programming language for text
14837 processing, the intermediate output language is a kind of low-level
14838 assembler language by specifying all positions on the page for writing
14839 and drawing.
14841 The intermediate output produced by @code{gtroff} is fairly readable,
14842 while output from @acronym{AT&T} @code{troff} is rather hard to
14843 understand because of strange habits that are still supported, but not
14844 used any longer by @code{gtroff}.
14846 @menu
14847 * Language Concepts::
14848 * Command Reference::
14849 * Intermediate Output Examples::
14850 * Output Language Compatibility::
14851 @end menu
14853 @c ---------------------------------------------------------------------
14855 @node Language Concepts, Command Reference, gtroff Output, gtroff Output
14856 @subsection Language Concepts
14858 During the run of @code{gtroff}, the input data is cracked down to the
14859 information on what has to be printed at what position on the intended
14860 device.  So the language of the intermediate output format can be quite
14861 small.  Its only elements are commands with and without arguments.  In
14862 this section, the term @dfn{command} always refers to the intermediate
14863 output language, and never to the @code{gtroff} language used for
14864 document formatting.  There are commands for positioning and text
14865 writing, for drawing, and for device controlling.
14867 @menu
14868 * Separation::
14869 * Argument Units::
14870 * Document Parts::
14871 @end menu
14873 @node Separation, Argument Units, Language Concepts, Language Concepts
14874 @subsubsection Separation
14876 @acronym{AT&T} @code{troff} output has strange requirements on
14877 whitespace.  The @code{gtroff} output parser, however, is smart about
14878 whitespace by making it maximally optional.  The whitespace characters,
14879 i.e., the tab, space, and newline characters, always have a syntactical
14880 meaning.  They are never printable because spacing within the output is
14881 always done by positioning commands.
14883 Any sequence of space or tab characters is treated as a single
14884 @dfn{syntactical space}.  It separates commands and arguments, but is
14885 only required when there would occur a clashing between the command code
14886 and the arguments without the space.  Most often, this happens when
14887 variable-length command names, arguments, argument lists, or command
14888 clusters meet.  Commands and arguments with a known, fixed length need
14889 not be separated by syntactical space.
14891 A line break is a syntactical element, too.  Every command argument can
14892 be followed by whitespace, a comment, or a newline character.  Thus a
14893 @dfn{syntactical line break} is defined to consist of optional
14894 syntactical space that is optionally followed by a comment, and a
14895 newline character.
14897 The normal commands, those for positioning and text, consist of a single
14898 letter taking a fixed number of arguments.  For historical reasons, the
14899 parser allows to stack such commands on the same line, but fortunately,
14900 in @code{gtroff}'s intermediate output, every command with at least one
14901 argument is followed by a line break, thus providing excellent
14902 readability.
14904 The other commands -- those for drawing and device controlling -- have a
14905 more complicated structure; some recognize long command names, and some
14906 take a variable number of arguments.  So all @samp{D} and @samp{x}
14907 commands were designed to request a syntactical line break after their
14908 last argument.  Only one command, @w{@samp{x X}}, has an argument that
14909 can stretch over several lines; all other commands must have all of
14910 their arguments on the same line as the command, i.e., the arguments may
14911 not be split by a line break.
14913 Empty lines (these are lines containing only space and/or a comment),
14914 can occur everywhere.  They are just ignored.
14916 @node Argument Units, Document Parts, Separation, Language Concepts
14917 @subsubsection Argument Units
14919 Some commands take integer arguments that are assumed to represent
14920 values in a measurement unit, but the letter for the corresponding scale
14921 indicator is not written with the output command arguments.  Most
14922 commands assume the scale indicator @samp{u}, the basic unit of the
14923 device, some use @samp{z}, the scaled point unit of the device, while
14924 others, such as the color commands, expect plain integers.
14926 Note that single characters can have the eighth bit set, as can the
14927 names of fonts and special characters.  The names of characters and
14928 fonts can be of arbitrary length.  A character that is to be printed is
14929 always in the current font.
14931 A string argument is always terminated by the next whitespace character
14932 (space, tab, or newline); an embedded @samp{#} character is regarded as
14933 part of the argument, not as the beginning of a comment command.  An
14934 integer argument is already terminated by the next non-digit character,
14935 which then is regarded as the first character of the next argument or
14936 command.
14938 @node Document Parts,  , Argument Units, Language Concepts
14939 @subsubsection Document Parts
14941 A correct intermediate output document consists of two parts, the
14942 @dfn{prologue} and the @dfn{body}.
14944 The task of the prologue is to set the general device parameters using
14945 three exactly specified commands.  @code{gtroff}'s prologue is
14946 guaranteed to consist of the following three lines (in that order):
14948 @Example
14949 x T @var{device}
14950 x res @var{n} @var{h} @var{v}
14951 x init
14952 @endExample
14954 @noindent
14955 with the arguments set as outlined in @ref{Device Control Commands}.
14956 Note that the parser for the intermediate output format is able to
14957 swallow additional whitespace and comments as well even in the prologue.
14959 The body is the main section for processing the document data.
14960 Syntactically, it is a sequence of any commands different from the ones
14961 used in the prologue.  Processing is terminated as soon as the first
14962 @w{@samp{x stop}} command is encountered; the last line of any
14963 @code{gtroff} intermediate output always contains such a command.
14965 Semantically, the body is page oriented.  A new page is started by a
14966 @samp{p} command.  Positioning, writing, and drawing commands are always
14967 done within the current page, so they cannot occur before the first
14968 @samp{p} command.  Absolute positioning (by the @samp{H} and @samp{V}
14969 commands) is done relative to the current page; all other positioning is
14970 done relative to the current location within this page.
14972 @c ---------------------------------------------------------------------
14974 @node Command Reference, Intermediate Output Examples, Language Concepts, gtroff Output
14975 @subsection Command Reference
14977 This section describes all intermediate output commands, both from
14978 @acronym{AT&T} @code{troff} as well as the @code{gtroff} extensions.
14980 @menu
14981 * Comment Command::
14982 * Simple Commands::
14983 * Graphics Commands::
14984 * Device Control Commands::
14985 * Obsolete Command::
14986 @end menu
14988 @node Comment Command, Simple Commands, Command Reference, Command Reference
14989 @subsubsection Comment Command
14991 @table @code
14992 @item #@var{anything}@angles{end of line}
14993 A comment.  Ignore any characters from the @samp{#} character up to the
14994 next newline character.
14996 This command is the only possibility for commenting in the intermediate
14997 output.  Each comment can be preceded by arbitrary syntactical space;
14998 every command can be terminated by a comment.
14999 @end table
15001 @node Simple Commands, Graphics Commands, Comment Command, Command Reference
15002 @subsubsection Simple Commands
15004 The commands in this subsection have a command code consisting of a
15005 single character, taking a fixed number of arguments.  Most of them are
15006 commands for positioning and text writing.  These commands are smart
15007 about whitespace.  Optionally, syntactical space can be inserted before,
15008 after, and between the command letter and its arguments.  All of these
15009 commands are stackable, i.e., they can be preceded by other simple
15010 commands or followed by arbitrary other commands on the same line.  A
15011 separating syntactical space is only necessary when two integer
15012 arguments would clash or if the preceding argument ends with a string
15013 argument.
15015 @table @code
15016 @ignore
15017 .if (\n[@USE_ENV_STACK] == 1) \{\
15018 .command {
15019 Open a new environment by copying the actual device configuration data
15020 to the environment stack.
15022 The current environment is setup by the device specification and
15023 manipulated by the setting commands.
15026 .command }
15027 Close the actual environment (opened by a preceding
15028 .BR { \~command)
15029 and restore the previous environment from the environment
15030 stack as the actual device configuration data.
15032 \}              \" endif @USE_ENV_STACK
15033 @end ignore
15035 @item C @var{xxx}@angles{whitespace}
15036 Print a special character named @var{xxx}.  The trailing syntactical
15037 space or line break is necessary to allow glyph names of arbitrary
15038 length.  The glyph is printed at the current print position; the glyph's
15039 size is read from the font file.  The print position is not changed.
15041 @item c @var{g}
15042 Print glyph@tie{}@var{g} at the current print
15043 position;@footnote{@samp{c} is actually a misnomer since it outputs a
15044 glyph.} the glyph's size is read from the font file.  The print position
15045 is not changed.
15047 @item f @var{n}
15048 Set font to font number@tie{}@var{n} (a non-negative integer).
15050 @item H @var{n}
15051 Move right to the absolute vertical position@tie{}@var{n} (a
15052 non-negative integer in basic units @samp{u} relative to left edge of
15053 current page.
15055 @item h @var{n}
15056 Move @var{n} (a non-negative integer) basic units @samp{u} horizontally
15057 to the right.  The original @acronym{UNIX} troff manual allows negative
15058 values for @var{n} also, but @code{gtroff} doesn't use this.
15060 @item m @var{color-scheme} @r{[}@var{component} @dots{}@r{]}
15061 Set the color for text (glyphs), line drawing, and the outline of
15062 graphic objects using different color schemes; the analoguous command
15063 for the filling color of graphic objects is @samp{DF}.  The color
15064 components are specified as integer arguments between 0 and 65536.  The
15065 number of color components and their meaning vary for the different
15066 color schemes.  These commands are generated by @code{gtroff}'s escape
15067 sequence @code{\m}.  No position changing.  These commands are a
15068 @code{gtroff} extension.
15070 @table @code
15071 @item mc @var{cyan} @var{magenta} @var{yellow}
15072 Set color using the CMY color scheme, having the 3@tie{}color components
15073 @var{cyan}, @var{magenta}, and @var{yellow}.
15075 @item md
15076 Set color to the default color value (black in most cases).  No
15077 component arguments.
15079 @item mg @var{gray}
15080 Set color to the shade of gray given by the argument, an integer between
15081 0 (black) and 65536 (white).
15083 @item mk @var{cyan} @var{magenta} @var{yellow} @var{black}
15084 Set color using the CMYK color scheme, having the 4@tie{}color
15085 components @var{cyan}, @var{magenta}, @var{yellow}, and @var{black}.
15087 @item mr @var{red} @var{green} @var{blue}
15088 Set color using the RGB color scheme, having the 3@tie{}color components
15089 @var{red}, @var{green}, and @var{blue}.
15090 @end table
15092 @item N @var{n}
15093 Print glyph with index@tie{}@var{n} (a non-negative integer) of the
15094 current font.  This command is a @code{gtroff} extension.
15096 @item n @var{b} @var{a}
15097 Inform the device about a line break, but no positioning is done by this
15098 command.  In @acronym{AT&T} @code{troff}, the integer arguments @var{b}
15099 and@tie{}@var{a} informed about the space before and after the current
15100 line to make the intermediate output more human readable without
15101 performing any action.  In @code{groff}, they are just ignored, but they
15102 must be provided for compatibility reasons.
15104 @item p @var{n}
15105 Begin a new page in the outprint.  The page number is set
15106 to@tie{}@var{n}.  This page is completely independent of pages formerly
15107 processed even if those have the same page number.  The vertical
15108 position on the outprint is automatically set to@tie{}0.  All
15109 positioning, writing, and drawing is always done relative to a page, so
15110 a @samp{p} command must be issued before any of these commands.
15112 @item s @var{n}
15113 Set point size to @var{n}@tie{}scaled points (this is unit @samp{z}).
15114 @acronym{AT&T} @code{troff} used the unit points (@samp{p}) instead.
15115 @xref{Output Language Compatibility}.
15117 @item t @var{xxx}@angles{whitespace}
15118 @itemx t @var{xxx} @var{dummy-arg}@angles{whitespace}
15119 Print a word, i.e., a sequence of characters @var{xxx} representing
15120 output glyphs which names are single characters, terminated by a space
15121 character or a line break; an optional second integer argument is
15122 ignored (this allows the formatter to generate an even number of
15123 arguments).  The first glyph should be printed at the current position,
15124 the current horizontal position should then be increased by the width of
15125 the first glyph, and so on for each glyph.  The widths of the glyphs are
15126 read from the font file, scaled for the current point size, and rounded
15127 to a multiple of the horizontal resolution.  Special characters cannot
15128 be printed using this command (use the @samp{C} command for special
15129 characters).  This command is a @code{gtroff} extension; it is only used
15130 for devices whose @file{DESC} file contains the @code{tcommand} keyword
15131 (@pxref{DESC File Format}).
15133 @item u @var{n} @var{xxx}@angles{whitespace}
15134 Print word with track kerning.  This is the same as the @samp{t} command
15135 except that after printing each glyph, the current horizontal position
15136 is increased by the sum of the width of that glyph and@tie{}@var{n} (an
15137 integer in basic units @samp{u}).  This command is a @code{gtroff}
15138 extension; it is only used for devices whose @file{DESC} file contains
15139 the @code{tcommand} keyword (@pxref{DESC File Format}).
15141 @item V @var{n}
15142 Move down to the absolute vertical position@tie{}@var{n} (a non-negative
15143 integer in basic units @samp{u}) relative to upper edge of current page.
15145 @item v @var{n}
15146 Move @var{n}@tie{}basic units @samp{u} down (@var{n} is a non-negative
15147 integer).  The original @acronym{UNIX} troff manual allows negative
15148 values for @var{n} also, but @code{gtroff} doesn't use this.
15150 @item w
15151 Informs about a paddable white space to increase readability.  The
15152 spacing itself must be performed explicitly by a move command.
15153 @end table
15155 @node Graphics Commands, Device Control Commands, Simple Commands, Command Reference
15156 @subsubsection Graphics Commands
15158 Each graphics or drawing command in the intermediate output starts with
15159 the letter @samp{D}, followed by one or two characters that specify a
15160 subcommand; this is followed by a fixed or variable number of integer
15161 arguments that are separated by a single space character.  A @samp{D}
15162 command may not be followed by another command on the same line (apart
15163 from a comment), so each @samp{D} command is terminated by a syntactical
15164 line break.
15166 @code{gtroff} output follows the classical spacing rules (no space
15167 between command and subcommand, all arguments are preceded by a single
15168 space character), but the parser allows optional space between the
15169 command letters and makes the space before the first argument optional.
15170 As usual, each space can be any sequence of tab and space characters.
15172 Some graphics commands can take a variable number of arguments.  In this
15173 case, they are integers representing a size measured in basic units
15174 @samp{u}.  The arguments called @var{h1}, @var{h2}, @dots{}, @var{hn}
15175 stand for horizontal distances where positive means right, negative
15176 left.  The arguments called @var{v1}, @var{v2}, @dots{}, @var{vn} stand
15177 for vertical distances where positive means down, negative up.  All
15178 these distances are offsets relative to the current location.
15180 Each graphics command directly corresponds to a similar @code{gtroff}
15181 @code{\D} escape sequence.  @xref{Drawing Requests}.
15183 Unknown @samp{D} commands are assumed to be device-specific.  Its
15184 arguments are parsed as strings; the whole information is then sent to
15185 the postprocessor.
15187 In the following command reference, the syntax element @angles{line
15188 break} means a syntactical line break as defined above.
15190 @table @code
15191 @item D~ @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
15192 Draw B-spline from current position to offset (@var{h1},@var{v1}), then
15193 to offset (@var{h2},@var{v2}), if given, etc.@: up to
15194 (@var{hn},@var{vn}).  This command takes a variable number of argument
15195 pairs; the current position is moved to the terminal point of the drawn
15196 curve.
15198 @item Da @var{h1} @var{v1} @var{h2} @var{v2}@angles{line break}
15199 Draw arc from current position to
15200 (@var{h1},@var{v1})@math{+}(@var{h2},@var{v2}) with center at
15201 (@var{h1},@var{v1}); then move the current position to the final point
15202 of the arc.
15204 @item DC @var{d}@angles{line break}
15205 @itemx DC @var{d} @var{dummy-arg}@angles{line break}
15206 Draw a solid circle using the current fill color with
15207 diameter@tie{}@var{d} (integer in basic units @samp{u}) with leftmost
15208 point at the current position; then move the current position to the
15209 rightmost point of the circle.  An optional second integer argument is
15210 ignored (this allows the formatter to generate an even number of
15211 arguments).  This command is a @code{gtroff} extension.
15213 @item Dc @var{d}@angles{line break}
15214 Draw circle line with diameter@tie{}@var{d} (integer in basic units
15215 @samp{u}) with leftmost point at the current position; then move the
15216 current position to the rightmost point of the circle.
15218 @item DE @var{h} @var{v}@angles{line break}
15219 Draw a solid ellipse in the current fill color with a horizontal
15220 diameter of@tie{}@var{h} and a vertical diameter of@tie{}@var{v} (both
15221 integers in basic units @samp{u}) with the leftmost point at the current
15222 position; then move to the rightmost point of the ellipse.  This command
15223 is a @code{gtroff} extension.
15225 @item De @var{h} @var{v}@angles{line break}
15226 Draw an outlined ellipse with a horizontal diameter of@tie{}@var{h} and
15227 a vertical diameter of@tie{}@var{v} (both integers in basic units
15228 @samp{u}) with the leftmost point at current position; then move to the
15229 rightmost point of the ellipse.
15231 @item DF @var{color-scheme} @r{[}@var{component} @dots{}@r{]}@angles{line break}
15232 Set fill color for solid drawing objects using different color schemes;
15233 the analoguous command for setting the color of text, line graphics, and
15234 the outline of graphic objects is @samp{m}.  The color components are
15235 specified as integer arguments between 0 and 65536.  The number of color
15236 components and their meaning vary for the different color schemes.
15237 These commands are generated by @code{gtroff}'s escape sequences
15238 @w{@code{\D'F @dots{}'}} and @code{\M} (with no other corresponding
15239 graphics commands).  No position changing.  This command is a
15240 @code{gtroff} extension.
15242 @table @code
15243 @item DFc @var{cyan} @var{magenta} @var{yellow}@angles{line break}
15244 Set fill color for solid drawing objects using the CMY color scheme,
15245 having the 3@tie{}color components @var{cyan}, @var{magenta}, and
15246 @var{yellow}.
15248 @item DFd@angles{line break}
15249 Set fill color for solid drawing objects to the default fill color value
15250 (black in most cases).  No component arguments.
15252 @item DFg @var{gray}@angles{line break}
15253 Set fill color for solid drawing objects to the shade of gray given by
15254 the argument, an integer between 0 (black) and 65536 (white).
15256 @item DFk @var{cyan} @var{magenta} @var{yellow} @var{black}@angles{line break}
15257 Set fill color for solid drawing objects using the CMYK color scheme,
15258 having the 4@tie{}color components @var{cyan}, @var{magenta},
15259 @var{yellow}, and @var{black}.
15261 @item DFr @var{red} @var{green} @var{blue}@angles{line break}
15262 Set fill color for solid drawing objects using the RGB color scheme,
15263 having the 3@tie{}color components @var{red}, @var{green}, and
15264 @var{blue}.
15265 @end table
15267 @item Df @var{n}@angles{line break}
15268 The argument@tie{}@var{n} must be an integer in the range @math{-32767}
15269 to 32767.
15271 @table @asis
15272 @item @math{0 @LE{} @var{n} @LE{} 1000}
15273 Set the color for filling solid drawing objects to a shade of gray,
15274 where 0 corresponds to solid white, 1000 (the default) to solid black,
15275 and values in between to intermediate shades of gray; this is obsoleted
15276 by command @samp{DFg}.
15278 @item @math{@var{n} < 0} or @math{@var{n} > 1000}
15279 Set the filling color to the color that is currently being used for the
15280 text and the outline, see command @samp{m}.  For example, the command
15281 sequence
15283 @Example
15284 mg 0 0 65536
15285 Df -1
15286 @endExample
15288 @noindent
15289 sets all colors to blue.
15290 @end table
15292 @noindent
15293 No position changing.  This command is a @code{gtroff} extension.
15295 @item Dl @var{h} @var{v}@angles{line break}
15296 Draw line from current position to offset (@var{h},@var{v}) (integers in
15297 basic units @samp{u}); then set current position to the end of the drawn
15298 line.
15300 @item Dp @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
15301 Draw a polygon line from current position to offset (@var{h1},@var{v1}),
15302 from there to offset (@var{h2},@var{v2}), etc.@: up to offset
15303 (@var{hn},@var{vn}), and from there back to the starting position.  For
15304 historical reasons, the position is changed by adding the sum of all
15305 arguments with odd index to the actual horizontal position and the even
15306 ones to the vertical position.  Although this doesn't make sense it is
15307 kept for compatibility.
15308 @ignore
15309 As the polygon is closed, the end of drawing is the starting point, so
15310 the position doesn't change.
15311 @end ignore
15312 This command is a @code{gtroff} extension.
15314 @item Dp @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
15315 Draw a solid polygon in the current fill color rather than an outlined
15316 polygon, using the same arguments and positioning as the corresponding
15317 @samp{Dp} command.
15318 @ignore
15319 No position changing.
15320 @end ignore
15321 This command is a @code{gtroff} extension.
15323 @item Dt @var{n}@angles{line break}
15324 Set the current line thickness to@tie{}@var{n} (an integer in basic
15325 units @samp{u}) if @math{@var{n}>0}; if @math{@var{n}=0} select the
15326 smallest available line thickness; if @math{@var{n}<0} set the line
15327 thickness proportional to the point size (this is the default before the
15328 first @samp{Dt} command was specified).  For historical reasons, the
15329 horizontal position is changed by adding the argument to the actual
15330 horizontal position, while the vertical position is not changed.
15331 Although this doesn't make sense it is kept for compatibility.
15332 @ignore
15333 No position changing.
15334 @end ignore
15335 This command is a @code{gtroff} extension.
15336 @end table
15338 @node Device Control Commands, Obsolete Command, Graphics Commands, Command Reference
15339 @subsubsection Device Control Commands
15341 Each device control command starts with the letter @samp{x}, followed by
15342 a space character (optional or arbitrary space or tab in @code{gtroff})
15343 and a subcommand letter or word; each argument (if any) must be preceded
15344 by a syntactical space.  All @samp{x} commands are terminated by a
15345 syntactical line break; no device control command can be followed by
15346 another command on the same line (except a comment).
15348 The subcommand is basically a single letter, but to increase
15349 readability, it can be written as a word, i.e., an arbitrary sequence of
15350 characters terminated by the next tab, space, or newline character.  All
15351 characters of the subcommand word but the first are simply ignored.  For
15352 example, @code{gtroff} outputs the initialization command @w{@samp{x i}}
15353 as @w{@samp{x init}} and the resolution command @w{@samp{x r}} as
15354 @w{@samp{x res}}.
15356 In the following, the syntax element @angles{line break} means a
15357 syntactical line break (@pxref{Separation}).
15359 @table @code
15360 @item xF @var{name}@angles{line break}
15361 The @samp{F} stands for @var{Filename}.
15363 Use @var{name} as the intended name for the current file in error
15364 reports.  This is useful for remembering the original file name when
15365 @code{gtroff} uses an internal piping mechanism.  The input file is not
15366 changed by this command.  This command is a @code{gtroff} extension.
15368 @item xf @var{n} @var{s}@angles{line break}
15369 The @samp{f} stands for @var{font}.
15371 Mount font position@tie{}@var{n} (a non-negative integer) with font
15372 named@tie{}@var{s} (a text word).  @xref{Font Positions}.
15374 @item xH @var{n}@angles{line break}
15375 The @samp{H} stands for @var{Height}.
15377 Set glyph height to@tie{}@var{n} (a positive integer in scaled points
15378 @samp{z}).  @acronym{AT&T} @code{troff} uses the unit points (@samp{p})
15379 instead.  @xref{Output Language Compatibility}.
15381 @item xi@angles{line break}
15382 The @samp{i} stands for @var{init}.
15384 Initialize device.  This is the third command of the prologue.
15386 @item xp@angles{line break}
15387 The @samp{p} stands for @var{pause}.
15389 Parsed but ignored.  The original @acronym{UNIX} troff manual writes
15391 @display
15392 pause device, can be restarted
15393 @end display
15395 @item xr @var{n} @var{h} @var{v}@angles{line break}
15396 The @samp{r} stands for @var{resolution}.
15398 Resolution is@tie{}@var{n}, while @var{h} is the minimal horizontal
15399 motion, and @var{v} the minimal vertical motion possible with this
15400 device; all arguments are positive integers in basic units @samp{u} per
15401 inch.  This is the second command of the prologue.
15403 @item xS @var{n}@angles{line break}
15404 The @samp{S} stands for @var{Slant}.
15406 Set slant to@tie{}@var{n} (an integer in basic units @samp{u}).
15408 @item xs@angles{line break}
15409 The @samp{s} stands for @var{stop}.
15411 Terminates the processing of the current file; issued as the last
15412 command of any intermediate troff output.
15414 @item xt@angles{line break}
15415 The @samp{t} stands for @var{trailer}.
15417 Generate trailer information, if any.  In @var{gtroff}, this is actually
15418 just ignored.
15420 @item xT @var{xxx}@angles{line break}
15421 The @samp{T} stands for @var{Typesetter}.
15423 Set name of device to word @var{xxx}, a sequence of characters ended by
15424 the next white space character.  The possible device names coincide with
15425 those from the @code{groff} @option{-T} option.  This is the first
15426 command of the prologue.
15428 @item xu @var{n}@angles{line break}
15429 The @samp{u} stands for @var{underline}.
15431 Configure underlining of spaces.  If @var{n} is@tie{}1, start
15432 underlining of spaces; if @var{n} is@tie{}0, stop underlining of spaces.
15433 This is needed for the @code{cu} request in nroff mode and is ignored
15434 otherwise.  This command is a @code{gtroff} extension.
15436 @item xX @var{anything}@angles{line break}
15437 The @samp{x} stands for @var{X-escape}.
15439 Send string @var{anything} uninterpreted to the device.  If the line
15440 following this command starts with a @samp{+} character this line is
15441 interpreted as a continuation line in the following sense.  The @samp{+}
15442 is ignored, but a newline character is sent instead to the device, the
15443 rest of the line is sent uninterpreted.  The same applies to all
15444 following lines until the first character of a line is not a @samp{+}
15445 character.  This command is generated by the @code{gtroff} escape
15446 sequence @code{\X}.  The line-continuing feature is a @code{gtroff}
15447 extension.
15448 @end table
15450 @node Obsolete Command,  , Device Control Commands, Command Reference
15451 @subsubsection Obsolete Command
15452 In @acronym{AT&T} @code{troff} output, the writing of a single glyph is
15453 mostly done by a very strange command that combines a horizontal move
15454 and a single character giving the glyph name.  It doesn't have a command
15455 code, but is represented by a 3-character argument consisting of exactly
15456 2@tie{}digits and a character.
15458 @table @asis
15459 @item @var{dd}@var{g}
15460 Move right @var{dd} (exactly two decimal digits) basic units @samp{u},
15461 then print glyph@tie{}@var{g} (represented as a single character).
15463 In @code{gtroff}, arbitrary syntactical space around and within this
15464 command is allowed to be added.  Only when a preceding command on the
15465 same line ends with an argument of variable length a separating space is
15466 obligatory.  In @acronym{AT&T} @code{troff}, large clusters of these and
15467 other commands are used, mostly without spaces; this made such output
15468 almost unreadable.
15469 @end table
15471 For modern high-resolution devices, this command does not make sense
15472 because the width of the glyphs can become much larger than two decimal
15473 digits.  In @code{gtroff}, this is only used for the devices @code{X75},
15474 @code{X75-12}, @code{X100}, and @code{X100-12}.  For other devices, the
15475 commands @samp{t} and @samp{u} provide a better functionality.
15477 @c ---------------------------------------------------------------------
15479 @node Intermediate Output Examples, Output Language Compatibility, Command Reference, gtroff Output
15480 @subsection Intermediate Output Examples
15482 This section presents the intermediate output generated from the same
15483 input for three different devices.  The input is the sentence @samp{hell
15484 world} fed into @code{gtroff} on the command line.
15486 @table @asis
15487 @item High-resolution device @code{ps}
15489 This is the standard output of @code{gtroff} if no @option{-T} option is
15490 given.
15492 @example
15493 @group
15494 shell> echo "hell world" | groff -Z -T ps
15496 x T ps
15497 x res 72000 1 1
15498 x init
15499 @end group
15501 x font 5 TR
15503 s10000
15504 V12000
15505 H72000
15506 thell
15507 wh2500
15509 H96620
15510 torld
15511 n12000 0
15512 @group
15513 x trailer
15514 V792000
15515 x stop
15516 @end group
15517 @end example
15519 @noindent
15520 This output can be fed into @code{grops} to get its representation as a
15521 PostScript file.
15523 @item Low-resolution device @code{latin1}
15525 This is similar to the high-resolution device except that the
15526 positioning is done at a minor scale.  Some comments (lines starting
15527 with @samp{#}) were added for clarification; they were not generated by
15528 the formatter.
15530 @example
15531 @group
15532 shell> echo "hell world" | groff -Z -T latin1
15534 # prologue
15535 x T latin1
15536 x res 240 24 40
15537 x init
15538 @end group
15539 # begin a new page
15541 # font setup
15542 x font 1 R
15545 # initial positioning on the page
15548 # write text `hell'
15549 thell
15550 # inform about space, and issue a horizontal jump
15551 wh24
15552 # write text `world'
15553 tworld
15554 # announce line break, but do nothing because ...
15555 n40 0
15556 @group
15557 # ... the end of the document has been reached
15558 x trailer
15559 V2640
15560 x stop
15561 @end group
15562 @end example
15564 @noindent
15565 This output can be fed into @code{grotty} to get a formatted text
15566 document.
15568 @item @acronym{AT&T} @code{troff} output
15569 Since a computer monitor has a very low resolution compared to modern
15570 printers the intermediate output for the X@tie{}Window devices can use
15571 the jump-and-write command with its 2-digit displacements.
15573 @example
15574 @group
15575 shell> echo "hell world" | groff -Z -T X100
15577 x T X100
15578 x res 100 1 1
15579 x init
15580 @end group
15582 x font 5 TR
15586 H100
15587 # write text with jump-and-write commands
15588 ch07e07l03lw06w11o07r05l03dh7
15589 n16 0
15590 @group
15591 x trailer
15592 V1100
15593 x stop
15594 @end group
15595 @end example
15597 @noindent
15598 This output can be fed into @code{xditview} or @code{gxditview} for
15599 displaying in@tie{}X.
15601 Due to the obsolete jump-and-write command, the text clusters in the
15602 @acronym{AT&T} @code{troff} output are almost unreadable.
15603 @end table
15605 @c ---------------------------------------------------------------------
15607 @node Output Language Compatibility,  , Intermediate Output Examples, gtroff Output
15608 @subsection Output Language Compatibility
15610 The intermediate output language of @acronym{AT&T} @code{troff} was
15611 first documented in the @acronym{UNIX} troff manual, with later
15612 additions documented in @cite{A Typesetter-indenpendent TROFF}, written
15613 by Brian Kernighan.
15615 The @code{gtroff} intermediate output format is compatible with this
15616 specification except for the following features.
15618 @itemize @bullet
15619 @item
15620 The classical quasi device independence is not yet implemented.
15622 @item
15623 The old hardware was very different from what we use today.  So the
15624 @code{groff} devices are also fundamentally different from the ones in
15625 @acronym{AT&T} @code{troff}.  For example, the @acronym{AT&T} PostScript
15626 device is called @code{post} and has a resolution of only 720 units per
15627 inch, suitable for printers 20 years ago, while @code{groff}'s @code{ps}
15628 device has a resolution of 72000 units per inch.  Maybe, by implementing
15629 some rescaling mechanism similar to the classical quasi device
15630 independence, @code{groff} could emulate @acronym{AT&T}'s @code{post}
15631 device.
15633 @item
15634 The B-spline command @samp{D~} is correctly handled by the intermediate
15635 output parser, but the drawing routines aren't implemented in some of
15636 the postprocessor programs.
15638 @item
15639 The argument of the commands @samp{s} and @w{@samp{x H}} has the
15640 implicit unit scaled point @samp{z} in @code{gtroff}, while
15641 @acronym{AT&T} @code{troff} has point (@samp{p}).  This isn't an
15642 incompatibility but a compatible extension, for both units coincide for
15643 all devices without a @code{sizescale} parameter in the @file{DESC}
15644 file, including all postprocessors from @acronym{AT&T} and
15645 @code{groff}'s text devices.  The few @code{groff} devices with a
15646 @code{sizescale} parameter either do not exist for @acronym{AT&T}
15647 @code{troff}, have a different name, or seem to have a different
15648 resolution.  So conflicts are very unlikely.
15650 @item
15651 The position changing after the commands @samp{Dp}, @samp{DP}, and
15652 @samp{Dt} is illogical, but as old versions of @code{gtroff} used this
15653 feature it is kept for compatibility reasons.
15655 @ignore
15656 Temporarily, there existed some confusion on the positioning after the
15657 @samp{D} commands that are groff extensions.  This has been clarified by
15658 establishing the classical rule for all @code{groff} drawing commands:
15660 @itemize
15661 @item
15662 The position after a graphic object has been drawn is at its end; for
15663 circles and ellipses, the `end' is at the right side.
15665 @item
15666 From this, the positionings specified for the drawing commands above
15667 follow quite naturally.
15668 @end itemize
15669 @end ignore
15671 @end itemize
15674 @c =====================================================================
15676 @node Font Files,  , gtroff Output, File formats
15677 @section Font Files
15678 @cindex font files
15679 @cindex files, font
15681 The @code{gtroff} font format is roughly a superset of the
15682 @code{ditroff} font format (as used in later versions of @acronym{AT&T}
15683 @code{troff} and its descendants).  Unlike the @code{ditroff} font
15684 format, there is no associated binary format; all files are text
15685 files.@footnote{Plan@tie{}9 @code{troff} has also abandoned the binary
15686 format.}  The font files for device @var{name} are stored in a directory
15687 @file{dev@var{name}}.  There are two types of file: a device description
15688 file called @file{DESC} and for each font@tie{}@var{f} a font file
15689 called@tie{}@file{@var{f}}.
15691 @menu
15692 * DESC File Format::
15693 * Font File Format::
15694 @end menu
15696 @c ---------------------------------------------------------------------
15698 @node DESC File Format, Font File Format, Font Files, Font Files
15699 @subsection @file{DESC} File Format
15700 @cindex @file{DESC} file, format
15701 @cindex font description file, format
15702 @cindex format of font description file
15703 @pindex DESC@r{ file format}
15705 The @file{DESC} file can contain the following types of line.  Except
15706 for the @code{charset} keyword which must comes last (if at all), the
15707 order of the lines is not important.  Later entries in the file,
15708 however, override previous values.
15710 @table @code
15711 @item charset
15712 @kindex charset
15713 This line and everything following in the file are ignored.  It is
15714 allowed for the sake of backwards compatibility.
15716 @item family @var{fam}
15717 @kindex family
15718 The default font family is @var{fam}.
15720 @item fonts @var{n} @var{F1} @var{F2} @var{F3} @dots{} @var{Fn}
15721 @kindex fonts
15722 Fonts @var{F1} @dots{} @var{Fn} are mounted in the font positions
15723 @var{m}+1, @dots{}, @var{m}+@var{n} where @var{m} is the number of
15724 styles.  This command may extend over more than one line.  A font name
15725 of@tie{}0 means no font is mounted on the corresponding font position.
15727 @item hor @var{n}
15728 @kindex hor
15729 @cindex horizontal resolution
15730 @cindex resolution, horizontal
15731 The horizontal resolution is @var{n}@tie{}machine units.  All horizontal
15732 quantities are rounded to be multiples of this value.
15734 @item image_generator @var{string}
15735 @kindex image_generator
15736 @cindex PostScript, PNG image generation
15737 @cindex PNG image generation from PostScript
15738 Needed for @code{grohtml} only.  It specifies the program to generate
15739 PNG images from PostScript input.  Under GNU/Linux this is usually
15740 @code{gs} but under other systems (notably cygwin) it might be set to
15741 another name.
15743 @item paperlength @var{n}
15744 @kindex paperlength
15745 The physical vertical dimension of the output medium in machine units.
15746 This isn't used by @code{troff} itself but by output devices.
15747 Deprecated.  Use @code{papersize} instead.
15749 @item papersize @var{string} @dots{}
15750 @kindex papersize
15751 Select a paper size.  Valid values for @var{string} are the ISO paper
15752 types @code{A0}-@code{A7}, @code{B0}-@code{B7}, @code{C0}-@code{C7},
15753 @code{D0}-@code{D7}, @code{DL}, and the US paper types @code{letter},
15754 @code{legal}, @code{tabloid}, @code{ledger}, @code{statement},
15755 @code{executive}, @code{com10}, and @code{monarch}.  Case is not
15756 significant for @var{string} if it holds predefined paper types.
15757 Alternatively, @var{string} can be a file name (e.g.@:
15758 @file{/etc/papersize}); if the file can be opened, @code{groff} reads
15759 the first line and tests for the above paper sizes.  Finally,
15760 @var{string} can be a custom paper size in the format
15761 @code{@var{length},@var{width}} (no spaces before and after the comma).
15762 Both @var{length} and @var{width} must have a unit appended; valid
15763 values are @samp{i} for inches, @samp{C} for centimeters, @samp{p} for
15764 points, and @samp{P} for picas.  Example: @code{12c,235p}.  An argument
15765 which starts with a digit is always treated as a custom paper format.
15766 @code{papersize} sets both the vertical and horizontal dimension of the
15767 output medium.
15769 More than one argument can be specified; @code{groff} scans from left to
15770 right and uses the first valid paper specification.
15772 @item paperwidth @var{n}
15773 @kindex paperwidth
15774 The physical horizontal dimension of the output medium in machine units.
15775 This isn't used by @code{troff} itself but by output devices.
15776 Deprecated.  Use @code{papersize} instead.
15778 @item pass_filenames
15779 @kindex pass_filenames
15780 Tell @code{gtroff} to emit the name of the source file currently being
15781 processed.  This is achieved by the intermediate output command
15782 @samp{F}.  Currently, this is only used by the @code{grohtml} output
15783 device.
15785 @item postpro @var{program}
15786 @kindex postpro
15787 Call @var{program} as a postprocessor.  For example, the line
15789 @Example
15790 postpro grodvi
15791 @endExample
15793 @noindent
15794 in the file @file{devdvi/DESC} makes @code{groff} call @code{grodvi} if
15795 option @option{-Tdvi} is given (and @option{-Z} isn't used).
15797 @item prepro @var{program}
15798 @kindex prepro
15799 Call @var{program} as a preprocessor.  Currently, this keyword is used
15800 by @code{groff} with option @option{-Thtml} or @option{-Txhtml} only.
15802 @item print @var{program}
15803 @kindex print
15804 Use @var{program} as a spooler program for printing.  If omitted, the
15805 @option{-l} and @option{-L} options of @code{groff} are ignored.
15807 @item res @var{n}
15808 @kindex res
15809 @cindex device resolution
15810 @cindex resolution, device
15811 There are @var{n}@tie{}machine units per inch.
15813 @item sizes @var{s1} @var{s2} @dots{} @var{sn} 0
15814 @kindex sizes
15815 This means that the device has fonts at @var{s1}, @var{s2}, @dots{}
15816 @var{sn} scaled points.  The list of sizes must be terminated by@tie{}0
15817 (this is digit zero).  Each @var{si} can also be a range of sizes
15818 @var{m}-@var{n}.  The list can extend over more than one line.
15820 @item sizescale @var{n}
15821 @kindex sizescale
15822 The scale factor for point sizes.  By default this has a value
15823 of@tie{}1.  One scaled point is equal to one point/@var{n}.  The
15824 arguments to the @code{unitwidth} and @code{sizes} commands are given in
15825 scaled points.  @xref{Fractional Type Sizes}, for more information.
15827 @item styles @var{S1} @var{S2} @dots{} @var{Sm}
15828 @kindex styles
15829 The first @var{m}@tie{}font positions are associated with styles
15830 @var{S1} @dots{} @var{Sm}.
15832 @item tcommand
15833 @kindex tcommand
15834 This means that the postprocessor can handle the @samp{t} and @samp{u}
15835 intermediate output commands.
15837 @item unicode
15838 @kindex unicode
15839 Indicate that the output device supports the complete Unicode
15840 repertoire.  Useful only for devices which produce @emph{character
15841 entities} instead of glyphs.
15843 If @code{unicode} is present, no @code{charset} section is required in
15844 the font description files since the Unicode handling built into
15845 @code{groff} is used.  However, if there are entries in a @code{charset}
15846 section, they either override the default mappings for those particular
15847 characters or add new mappings (normally for composite characters).
15849 This is used for @option{-Tutf8}, @option{-Thtml}, and @option{-Txhtml}.
15851 @item unitwidth @var{n}
15852 @kindex unitwidth
15853 Quantities in the font files are given in machine units for fonts whose
15854 point size is @var{n}@tie{}scaled points.
15856 @item unscaled_charwidths
15857 @kindex unscaled_charwidths
15858 Make the font handling module always return unscaled character widths.
15859 Needed for the @code{grohtml} device.
15860 @item use_charnames_in_special
15861 @kindex use_charnames_in_special
15862 This command indicates that @code{gtroff} should encode special
15863 characters inside special commands.  Currently, this is only used by the
15864 @code{grohtml} output device.  @xref{Postprocessor Access}.
15866 @item vert @var{n}
15867 @kindex vert
15868 @cindex vertical resolution
15869 @cindex resolution, vertical
15870 The vertical resolution is @var{n}@tie{}machine units.  All vertical
15871 quantities are rounded to be multiples of this value.
15872 @end table
15874 The @code{res}, @code{unitwidth}, @code{fonts}, and @code{sizes} lines
15875 are mandatory.  Other commands are ignored by @code{gtroff} but may be
15876 used by postprocessors to store arbitrary information about the device
15877 in the @file{DESC} file.
15879 @kindex spare1
15880 @kindex spare2
15881 @kindex biggestfont
15882 Here a list of obsolete keywords which are recognized by @code{groff}
15883 but completely ignored: @code{spare1}, @code{spare2},
15884 @code{biggestfont}.
15886 @c ---------------------------------------------------------------------
15888 @node Font File Format,  , DESC File Format, Font Files
15889 @subsection Font File Format
15890 @cindex font file, format
15891 @cindex font description file, format
15892 @cindex format of font files
15893 @cindex format of font description files
15895 A @dfn{font file}, also (and probably better) called a @dfn{font
15896 description file}, has two sections.  The first section is a sequence of
15897 lines each containing a sequence of blank delimited words; the first
15898 word in the line is a key, and subsequent words give a value for that
15899 key.
15901 @table @code
15902 @item name @var{f}
15903 @kindex name
15904 The name of the font is@tie{}@var{f}.
15906 @item spacewidth @var{n}
15907 @kindex spacewidth
15908 The normal width of a space is@tie{}@var{n}.
15910 @item slant @var{n}
15911 @kindex slant
15912 The glyphs of the font have a slant of @var{n}@tie{}degrees.  (Positive
15913 means forward.)
15915 @item ligatures @var{lig1} @var{lig2} @dots{} @var{lign} [0]
15916 @kindex ligatures
15917 Glyphs @var{lig1}, @var{lig2}, @dots{}, @var{lign} are ligatures;
15918 possible ligatures are @samp{ff}, @samp{fi}, @samp{fl}, @samp{ffi} and
15919 @samp{ffl}.  For backwards compatibility, the list of ligatures may be
15920 terminated with a@tie{}0.  The list of ligatures may not extend over
15921 more than one line.
15923 @item special
15924 @cindex special fonts
15925 @kindex special
15926 The font is @dfn{special}; this means that when a glyph is requested
15927 that is not present in the current font, it is searched for in any
15928 special fonts that are mounted.
15929 @end table
15931 Other commands are ignored by @code{gtroff} but may be used by
15932 postprocessors to store arbitrary information about the font in the font
15933 file.
15935 @cindex comments in font files
15936 @cindex font files, comments
15937 @kindex #
15938 The first section can contain comments which start with the @samp{#}
15939 character and extend to the end of a line.
15941 The second section contains one or two subsections.  It must contain a
15942 @code{charset} subsection and it may also contain a @code{kernpairs}
15943 subsection.  These subsections can appear in any order.  Each subsection
15944 starts with a word on a line by itself.
15946 @kindex charset
15947 The word @code{charset} starts the character set
15948 subsection.@footnote{This keyword is misnamed since it starts a list of
15949 ordered glyphs, not characters.}  The @code{charset} line is followed by
15950 a sequence of lines.  Each line gives information for one glyph.  A line
15951 comprises a number of fields separated by blanks or tabs.  The format is
15953 @quotation
15954 @var{name} @var{metrics} @var{type} @var{code} [@var{entity-name}]
15955 [@code{--} @var{comment}]
15956 @end quotation
15958 @cindex 8-bit input
15959 @cindex input, 8-bit
15960 @cindex accessing unnamed glyphs with @code{\N}
15961 @cindex unnamed glyphs, accessing with @code{\N}
15962 @cindex characters, unnamed, accessing with @code{\N}
15963 @cindex glyphs, unnamed, accessing with @code{\N}
15964 @kindex ---
15965 @noindent
15966 @var{name} identifies the glyph name@footnote{The distinction between
15967 input, characters, and output, glyphs, is not clearly separated in the
15968 terminology of @code{groff}; for example, the @code{char} request should
15969 be called @code{glyph} since it defines an output entity.}: If
15970 @var{name} is a single character@tie{}@var{c} then it corresponds to the
15971 @code{gtroff} input character@tie{}@var{c}; if it is of the form
15972 @samp{\@var{c}} where @var{c} is a single character, then it corresponds
15973 to the special character @code{\[@var{c}]}; otherwise it corresponds to
15974 the special character @samp{\[@var{name}]}.  If it is exactly two
15975 characters @var{xx} it can be entered as @samp{\(@var{xx}}.  Note that
15976 single-letter special characters can't be accessed as @samp{\@var{c}};
15977 the only exception is @samp{\-} which is identical to @code{\[-]}.
15979 @code{gtroff} supports 8-bit input characters; however some utilities
15980 have difficulties with eight-bit characters.  For this reason, there is
15981 a convention that the entity name @samp{char@var{n}} is equivalent to
15982 the single input character whose code is@tie{}@var{n}.  For example,
15983 @samp{char163} would be equivalent to the character with code@tie{}163
15984 which is the pounds sterling sign in the ISO@tie{}@w{Latin-1} character
15985 set.  You shouldn't use @samp{char@var{n}} entities in font description
15986 files since they are related to input, not output.  Otherwise, you get
15987 hard-coded connections between input and output encoding which prevents
15988 use of different (input) character sets.
15990 The name @samp{---} is special and indicates that the glyph is unnamed;
15991 such glyphs can only be used by means of the @code{\N} escape sequence
15992 in @code{gtroff}.
15994 The @var{type} field gives the glyph type:
15996 @table @code
15997 @item 1
15998 the glyph has a descender, for example, @samp{p};
16000 @item 2
16001 the glyph has an ascender, for example, @samp{b};
16003 @item 3
16004 the glyph has both an ascender and a descender, for example, @samp{(}.
16005 @end table
16007 The @var{code} field gives the code which the postprocessor uses to
16008 print the glyph.  The glyph can also be input to @code{gtroff} using
16009 this code by means of the @code{\N} escape sequence.  @var{code} can be
16010 any integer.  If it starts with @samp{0} it is interpreted as octal; if
16011 it starts with @samp{0x} or @samp{0X} it is interpreted as hexadecimal.
16012 Note, however, that the @code{\N} escape sequence only accepts a decimal
16013 integer.
16015 The @var{entity-name} field gives an @acronym{ASCII} string identifying
16016 the glyph which the postprocessor uses to print the @code{gtroff} glyph
16017 @var{name}.  This field is optional and has been introduced so that the
16018 @code{grohtml} device driver can encode its character set.  For example,
16019 the glyph @samp{\[Po]} is represented as @samp{&pound;} in
16020 @acronym{HTML} 4.0.
16022 Anything on the line after the @var{entity-name} field resp.@: after
16023 @samp{--} is ignored.
16025 The @var{metrics} field has the form:
16027 @display
16028 @group
16029 @var{width}[@code{,}@var{height}[@code{,}@var{depth}[@code{,}@var{italic-correction}
16030   [@code{,}@var{left-italic-correction}[@code{,}@var{subscript-correction}]]]]]
16031 @end group
16032 @end display
16034 @noindent
16035 There must not be any spaces between these subfields (it has been split
16036 here into two lines for better legibility only).  Missing subfields are
16037 assumed to be@tie{}0.  The subfields are all decimal integers.  Since
16038 there is no associated binary format, these values are not required to
16039 fit into a variable of type @samp{char} as they are in @code{ditroff}.
16040 The @var{width} subfield gives the width of the glyph.  The @var{height}
16041 subfield gives the height of the glyph (upwards is positive); if a glyph
16042 does not extend above the baseline, it should be given a zero height,
16043 rather than a negative height.  The @var{depth} subfield gives the depth
16044 of the glyph, that is, the distance from the baseline to the lowest
16045 point below the baseline to which the glyph extends (downwards is
16046 positive); if a glyph does not extend below the baseline, it should be
16047 given a zero depth, rather than a negative depth.  The
16048 @var{italic-correction} subfield gives the amount of space that should
16049 be added after the glyph when it is immediately to be followed by a
16050 glyph from a roman font.  The @var{left-italic-correction} subfield
16051 gives the amount of space that should be added before the glyph when it
16052 is immediately to be preceded by a glyph from a roman font.  The
16053 @var{subscript-correction} gives the amount of space that should be
16054 added after a glyph before adding a subscript.  This should be less than
16055 the italic correction.
16057 A line in the @code{charset} section can also have the format
16059 @Example
16060 @var{name} "
16061 @endExample
16063 @noindent
16064 This indicates that @var{name} is just another name for the glyph
16065 mentioned in the preceding line.
16067 @kindex kernpairs
16068 The word @code{kernpairs} starts the kernpairs section.  This contains a
16069 sequence of lines of the form:
16071 @Example
16072 @var{c1} @var{c2} @var{n}
16073 @endExample
16075 @noindent
16076 This means that when glyph @var{c1} appears next to glyph @var{c2} the
16077 space between them should be increased by@tie{}@var{n}.  Most entries in
16078 the kernpairs section have a negative value for@tie{}@var{n}.
16082 @c =====================================================================
16083 @c =====================================================================
16085 @node Installation, Copying This Manual, File formats, Top
16086 @chapter Installation
16087 @cindex installation
16089 @c XXX
16093 @c =====================================================================
16094 @c =====================================================================
16096 @node Copying This Manual, Request Index, Installation, Top
16097 @appendix Copying This Manual
16099 @menu
16100 * GNU Free Documentation License::  License for copying this manual.
16101 @end menu
16103 @include fdl.texi
16107 @c =====================================================================
16108 @c =====================================================================
16110 @node Request Index, Escape Index, Copying This Manual, Top
16111 @appendix Request Index
16113 Requests appear without the leading control character (normally either
16114 @samp{.} or @samp{'}).
16116 @printindex rq
16120 @c =====================================================================
16121 @c =====================================================================
16123 @node Escape Index, Operator Index, Request Index, Top
16124 @appendix Escape Index
16126 Any escape sequence @code{\@var{X}} with @var{X} not in the list below
16127 emits a warning, printing glyph @var{X}.
16129 @printindex es
16133 @c =====================================================================
16134 @c =====================================================================
16136 @node Operator Index, Register Index, Escape Index, Top
16137 @appendix Operator Index
16139 @printindex op
16143 @c =====================================================================
16144 @c =====================================================================
16146 @node Register Index, Macro Index, Operator Index, Top
16147 @appendix Register Index
16149 The macro package or program a specific register belongs to is appended in
16150 brackets.
16152 A register name@tie{}@code{x} consisting of exactly one character can be
16153 accessed as @samp{\nx}.  A register name @code{xx} consisting of exactly
16154 two characters can be accessed as @samp{\n(xx}.  Register names
16155 @code{xxx} of any length can be accessed as @samp{\n[xxx]}.
16157 @printindex vr
16161 @c =====================================================================
16162 @c =====================================================================
16164 @node Macro Index, String Index, Register Index, Top
16165 @appendix Macro Index
16167 The macro package a specific macro belongs to is appended in brackets.
16168 They appear without the leading control character (normally @samp{.}).
16170 @printindex ma
16174 @c =====================================================================
16175 @c =====================================================================
16177 @node String Index, Glyph Name Index, Macro Index, Top
16178 @appendix String Index
16180 The macro package or program a specific string belongs to is appended in
16181 brackets.
16183 A string name@tie{}@code{x} consisting of exactly one character can be
16184 accessed as @samp{\*x}.  A string name @code{xx} consisting of exactly
16185 two characters can be accessed as @samp{\*(xx}.  String names @code{xxx}
16186 of any length can be accessed as @samp{\*[xxx]}.
16189 @printindex st
16193 @c =====================================================================
16194 @c =====================================================================
16196 @node Glyph Name Index, Font File Keyword Index, String Index, Top
16197 @appendix Glyph Name Index
16199 A glyph name @code{xx} consisting of exactly two characters can be
16200 accessed as @samp{\(xx}.  Glyph names @code{xxx} of any length can be
16201 accessed as @samp{\[xxx]}.
16203 @c XXX
16207 @c =====================================================================
16208 @c =====================================================================
16210 @node Font File Keyword Index, Program and File Index, Glyph Name Index, Top
16211 @appendix Font File Keyword Index
16213 @printindex ky
16217 @c =====================================================================
16218 @c =====================================================================
16220 @node Program and File Index, Concept Index, Font File Keyword Index, Top
16221 @appendix Program and File Index
16223 @printindex pg
16227 @c =====================================================================
16228 @c =====================================================================
16230 @node Concept Index,  , Program and File Index, Top
16231 @appendix Concept Index
16233 @printindex cp
16236 @bye