4 @c Please convert this manual with `texi2dvi -e groff.texi' due to
5 @c problems in texinfo regarding expansion of user-defined macros.
7 @c You need texinfo 4.8 or newer to format this document!
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.)
18 @documentencoding ISO-8859-1
27 This manual documents GNU @code{troff} version 1.22.4.
29 Copyright @copyright{} 1994--2018 Free Software Foundation, Inc.
32 Permission is granted to copy, distribute and/or modify this document
33 under the terms of the GNU Free Documentation License, Version 1.3 or
34 any later version published by the Free Software Foundation; with no
35 Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
36 and with the Back-Cover Texts as in (a) below. A copy of the license is
37 included in the section entitled ``GNU Free Documentation License.''
39 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
40 modify this GNU manual. Buying copies from the FSF supports it in
41 developing GNU and promoting software freedom.''
46 @c We use the following indices:
52 @c kindex: commands in font files
53 @c pindex: programs and files
54 @c tindex: environment variables
59 @c tindex and cindex are merged.
69 @c To avoid uppercasing in @deffn while converting to info, we define
70 @c our special @Var{}.
77 @c To assure correct HTML translation, some ugly hacks are necessary.
78 @c While processing a @def... request, the HTML translator looks at the
79 @c next line to decide whether to start indentation, and if the line
80 @c starts with @def... (e.g. @deffnx), indentation is started. We must
81 @c therefore ensure that a @def... is seen, during macro expansion.
83 @c The following macros have to be used:
102 @c The definition block must end with
106 @c The above is valid for texinfo 4.0f and above.
108 @c By default, only the first item generates an index entry. To
109 @c override this, use a variant with a trailing `x' (like
113 @c a dummy macro to assure the `@def...'
120 @c definition of requests
122 @macro Defreq{name, arg}
123 @deffn Request @t{.\name\} \arg\
128 @macro DefreqList{name, arg}
129 @deffn Request @t{.\name\} \arg\
135 @macro DefreqItem{name, arg}
136 @deffnx Request @t{.\name\} \arg\
141 @macro DefreqItemx{name, arg}
142 @deffnx Request @t{.\name\} \arg\
148 @macro DefreqListEnd{name, arg}
149 @deffnx Request @t{.\name\} \arg\
153 @macro DefreqListEndx{name, arg}
154 @deffnx Request @t{.\name\} \arg\
164 @c definition of escapes
166 @macro Defesc{name, delimI, arg, delimII}
167 @deffn Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
172 @macro DefescList{name, delimI, arg, delimII}
173 @deffn Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
179 @macro DefescItem{name, delimI, arg, delimII}
180 @deffnx Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
185 @macro DefescItemx{name, delimI, arg, delimII}
186 @deffnx Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
192 @macro DefescListEnd{name, delimI, arg, delimII}
193 @deffnx Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
197 @macro DefescListEndx{name, delimI, arg, delimII}
198 @deffnx Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
208 @c definition of registers
211 @deffn Register @t{\\n[\name\]}
216 @macro DefregList{name}
217 @deffn Register @t{\\n[\name\]}
223 @macro DefregItem{name}
224 @deffnx Register @t{\\n[\name\]}
229 @macro DefregItemx{name}
230 @deffnx Register @t{\\n[\name\]}
236 @macro DefregListEnd{name}
237 @deffnx Register @t{\\n[\name\]}
241 @macro DefregListEndx{name}
242 @deffnx Register @t{\\n[\name\]}
252 @c definition of registers specific to macro packages, preprocessors, etc.
254 @macro Defmpreg{name, package}
255 @deffn Register @t{\\n[\name\]}
256 @vindex \name\ @r{[}\package\@r{]}
260 @macro DefmpregList{name, package}
261 @deffn Register @t{\\n[\name\]}
263 @vindex \name\ @r{[}\package\@r{]}
267 @macro DefmpregItem{name, package}
268 @deffnx Register @t{\\n[\name\]}
273 @macro DefmpregItemx{name, package}
274 @deffnx Register @t{\\n[\name\]}
276 @vindex \name\ @r{[}\package\@r{]}
280 @macro DefmpregListEnd{name, package}
281 @deffnx Register @t{\\n[\name\]}
285 @macro DefmpregListEndx{name, package}
286 @deffnx Register @t{\\n[\name\]}
287 @vindex \name\ @r{[}\package\@r{]}
296 @c definition of macros
298 @macro Defmac{name, arg, package}
299 @defmac @t{.\name\} \arg\
300 @maindex \name\ @r{[}\package\@r{]}
304 @macro DefmacList{name, arg, package}
305 @defmac @t{.\name\} \arg\
307 @maindex \name\ @r{[}\package\@r{]}
311 @macro DefmacItem{name, arg, package}
312 @defmacx @t{.\name\} \arg\
317 @macro DefmacItemx{name, arg, package}
318 @defmacx @t{.\name\} \arg\
320 @maindex \name\ @r{[}\package\@r{]}
324 @macro DefmacListEnd{name, arg, package}
325 @defmacx @t{.\name\} \arg\
329 @macro DefmacListEndx{name, arg, package}
330 @defmacx @t{.\name\} \arg\
331 @maindex \name\ @r{[}\package\@r{]}
340 @c definition of strings
342 @macro Defstr{name, package}
343 @deffn String @t{\\*[\name\]}
344 @stindex \name\ @r{[}\package\@r{]}
348 @macro DefstrList{name, package}
349 @deffn String @t{\\*[\name\]}
351 @stindex \name\ @r{[}\package\@r{]}
355 @macro DefstrItem{name, package}
356 @deffnx String @t{\\*[\name\]}
361 @macro DefstrItemx{name, package}
362 @deffnx String @t{\\*[\name\]}
364 @stindex \name\ @r{[}\package\@r{]}
368 @macro DefstrListEnd{name, package}
369 @deffnx String @t{\\*[\name\]}
373 @macro DefstrListEndx{name, package}
374 @deffnx String @t{\\*[\name\]}
375 @stindex \name\ @r{[}\package\@r{]}
384 @c our example macros
396 @macro CartoucheExample
401 @macro endCartoucheExample
410 \gdef\Langlemacro{\angleleft}
411 \gdef\Ranglemacro{\angleright}
415 @set Langlemacro @Langlemacro
416 @set Ranglemacro @Ranglemacro
425 @value{Langlemacro}@r{\text\}@value{Ranglemacro}
431 @c Since expansion of macros has changed between texinfo 4.x and 5.x,
432 @c we can't define a macro but have to use @value directly.
447 @c Special care is required with parentheses, brackets, and braces:
449 @c . Real parentheses in @deffn produce an error while compiling with
451 @c . Real brackets use the wrong font in @deffn, overriding @t{}.
453 @c . @{ and @} fail with info if used in a macro.
455 @c Since macros aren't expanded in @deffn during -E, the following
456 @c definitions are for non-TeX only.
458 @c This is true for texinfo 4.0 and above.
461 @set Lparenmacro @lparen
462 @set Rparenmacro @rparen
463 @set Lbrackmacro @lbrack
464 @set Rbrackmacro @rbrack
498 @c This suppresses the word `Appendix' in the appendix headers.
501 \gdef\gobblefirst#1#2{#2}
502 \gdef\putwordAppendix{\gobblefirst}
506 @c We map some latin-1 characters to corresponding texinfo macros.
507 @c Newer versions of texinfo.tex have similar code included already.
510 \global\catcode`^^e4\active % ä
512 \global\catcode`^^c4\active % Ä
514 \global\catcode`^^e9\active % é
516 \global\catcode`^^c9\active % É
518 \global\catcode`^^f6\active % ö
520 \global\catcode`^^d6\active % Ö
522 \global\catcode`^^fc\active % ü
524 \global\catcode`^^dc\active % Ü
526 \global\catcode`^^e6\active % æ
528 \global\catcode`^^c6\active % Æ
530 \global\catcode`^^df\active % ß
535 @c Note: We say `Roman numerals' but `roman font'.
538 @dircategory Typesetting
540 * Groff: (groff). The GNU troff document formatting system.
546 @subtitle The GNU implementation of @code{troff}
547 @subtitle Edition 1.22.4
548 @subtitle Autumn 2018
549 @author by Trent A.@tie{}Fisher
550 @author and Werner Lemberg
553 @vskip 0pt plus 1filll
560 @node Top, Introduction, (dir), (dir)
567 * Tutorial for Macro Users::
574 * Copying This Manual::
582 * Font File Keyword Index::
583 * Program and File Index::
593 @c =====================================================================
594 @c =====================================================================
596 @node Introduction, Invoking groff, Top, Top
597 @chapter Introduction
600 GNU @code{troff} (or @code{groff}) is a system for typesetting
601 documents. @code{troff} is very flexible and has been used extensively
602 for some thirty years. It is well entrenched in the Unix community.
607 * groff Capabilities::
608 * Macro Package Intro::
609 * Preprocessor Intro::
610 * Output device intro::
615 @c =====================================================================
617 @node What Is groff?, History, Introduction, Introduction
618 @section What Is @code{groff}?
619 @cindex what is @code{groff}?
620 @cindex @code{groff} -- what is it?
622 @code{groff} belongs to an older generation of document preparation
623 systems, which operate more like compilers than the more recent
624 interactive @acronym{WYSIWYG}@footnote{What You See Is What You Get}
625 systems. @code{groff} and its contemporary counterpart, @TeX{}, both
626 work using a @dfn{batch} paradigm: The input (or @dfn{source}) files are
627 normal text files with embedded formatting commands. These files can
628 then be processed by @code{groff} to produce a typeset document on a
631 @code{groff} should not be confused with a @dfn{word processor}, an
632 integrated system of editor and text formatter. Also, many word
633 processors follow the @acronym{WYSIWYG} paradigm discussed earlier.
635 Although @acronym{WYSIWYG} systems may be easier to use, they have a
636 number of disadvantages compared to @code{troff}:
640 They must be used on a graphics display to work on a document.
643 Most of the @acronym{WYSIWYG} systems are either non-free or are not
647 @code{troff} is firmly entrenched in all Unix systems.
650 It is difficult to have a wide range of capabilities within the confines
651 of a GUI/window system.
654 It is more difficult to make global changes to a document.
658 ``GUIs normally make it simple to accomplish simple actions and
659 impossible to accomplish complex actions.'' --Doug Gwyn (22/Jun/91 in
660 @code{comp.unix.wizards})
664 @c =====================================================================
666 @node History, groff Capabilities, What Is groff?, Introduction
670 @cindex @code{RUNOFF}, the program
671 @cindex @code{rf}, the program
672 @code{troff} can trace its origins back to a formatting program called
673 @code{RUNOFF}, written by Jerry Saltzer, which ran on the @acronym{CTSS}
674 (@emph{Compatible Time Sharing System}, a project of MIT, the
675 Massachusetts Institute of Technology) in the
676 mid-sixties.@footnote{Jerome H.@: Saltzer, a grad student then, later a
677 Professor of Electrical Engineering, now retired. Saltzer's PhD thesis
678 was the first application for @code{RUNOFF} and is available from the
679 MIT Libraries.} The name came from the use of the phrase ``run off a
680 document'', meaning to print it out.
682 @c Tom Van Vleck <thvv@multicians.org> writes about the following:
684 @c I am not sure about this.. I think the BCPL runoff was the port to
685 @c the 635 architecture, and that the order of events is
687 @c 2. BCPL runoff on Multics
688 @c 3. BCPL runoff on 635
691 Bob Morris ported it to the 635 architecture and called the program
692 @code{roff} (an abbreviation of @code{runoff}). It was rewritten as
693 @code{rf} for the @w{PDP-7} (before having Unix), and at the
694 same time (1969), Doug McIlroy rewrote an extended and simplified
695 version of @code{roff} in the @acronym{BCPL} programming language.
697 @cindex @code{roff}, the program
698 In 1971, the Unix developers wanted to get a @w{PDP-11}, and to justify
699 the cost, proposed the development of a document formatting system for
700 the @acronym{AT&T} patents division. This first formatting program was
701 a reimplementation of McIlroy's @code{roff}, written by J.@tie{}F.@:
704 @cindex @code{nroff}, the program
705 When they needed a more flexible language, a new version of @code{roff}
706 called @code{nroff} (``Newer @code{roff}'') was written. It had a much
707 more complicated syntax, but provided the basis for all future versions.
708 When they got a Graphic Systems CAT Phototypesetter, Ossanna wrote a
709 version of @code{nroff} that would drive it. It was dubbed
710 @code{troff}, for ``typesetter @code{roff}'', although many people have
711 speculated that it actually means ``Times @code{roff}'' because of the
712 use of the Times font family in @code{troff} by default. As such, the
713 name @code{troff} is pronounced `@w{t-roff}' rather than `trough'.
715 With @code{troff} came @code{nroff} (they were actually the same program
716 except for some @samp{#ifdef}s), which was for producing output for line
717 printers and character terminals. It understood everything @code{troff}
718 did, and ignored the commands that were not applicable (e.g.@: font
721 Since there are several things that cannot be done easily in
722 @code{troff}, work on several preprocessors began. These programs would
723 transform certain parts of a document into @code{troff}, which made a
724 very natural use of pipes in Unix.
726 The @code{eqn} preprocessor allowed mathematical formulae to be specified
727 in a much simpler and more intuitive manner. @code{tbl} is a
728 preprocessor for formatting tables. The @code{refer} preprocessor (and
729 the similar program, @code{bib}) processes citations in a document
730 according to a bibliographic database.
732 Unfortunately, Ossanna's @code{troff} was written in @w{PDP-11} assembly
733 language and produced output specifically for the CAT phototypesetter.
734 He rewrote it in C, although it was now 7000@tie{}lines of uncommented
735 code and still dependent on the CAT@. As the CAT became less common, and
736 was no longer supported by the manufacturer, the need to make it support
737 other devices became a priority. However, before this could be done,
738 Ossanna died by a severe heart attack in a hospital while recovering
742 @cindex @code{ditroff}, the program
743 So, Brian Kernighan took on the task of rewriting @code{troff}. The
744 newly rewritten version produced device independent code that was very
745 easy for postprocessors to read and translate to the appropriate printer
746 codes. Also, this new version of @code{troff} (called @code{ditroff}
747 for ``device independent @code{troff}'') had several extensions, which
748 included drawing functions.
750 Due to the additional abilities of the new version of @code{troff},
751 several new preprocessors appeared. The @code{pic} preprocessor
752 provides a wide range of drawing functions. Likewise the @code{ideal}
753 preprocessor did the same, although via a much different paradigm. The
754 @code{grap} preprocessor took specifications for graphs, but, unlike
755 other preprocessors, produced @code{pic} code.
757 James Clark began work on a GNU implementation of @code{ditroff} in
758 early@tie{}1989. The first version, @code{groff}@tie{}0.3.1, was
759 released June@tie{}1990. @code{groff} included:
763 A replacement for @code{ditroff} with many extensions.
766 The @code{soelim}, @code{pic}, @code{tbl}, and @code{eqn} preprocessors.
769 Postprocessors for character devices, @sc{PostScript}, @TeX{} DVI, and
770 X@tie{}Windows. GNU @code{troff} also eliminated the need for a
771 separate @code{nroff} program with a postprocessor that would produce
772 @acronym{ASCII} output.
775 A version of the @file{me} macros and an implementation of the
779 Also, a front-end was included that could construct the, sometimes
780 painfully long, pipelines required for all the post- and preprocessors.
782 Development of GNU @code{troff} progressed rapidly, and saw the
783 additions of a replacement for @code{refer}, an implementation of the
784 @file{ms} and @file{mm} macros, and a program to deduce how to format a
785 document (@code{grog}).
787 It was declared a stable (i.e.@: non-beta) package with the release of
788 version@tie{}1.04 around November@tie{}1991.
790 Beginning in@tie{}1999, @code{groff} has new maintainers (the package
791 was an orphan for a few years). As a result, new features and programs
792 like @code{grn}, a preprocessor for gremlin images, and an output device
793 to produce @acronym{HTML} and @acronym{XHTML} have been added.
796 @c =====================================================================
798 @node groff Capabilities, Macro Package Intro, History, Introduction
799 @section @code{groff} Capabilities
800 @cindex @code{groff} capabilities
801 @cindex capabilities of @code{groff}
803 So what exactly is @code{groff} capable of doing? @code{groff} provides
804 a wide range of low-level text formatting operations. Using these, it
805 is possible to perform a wide range of formatting tasks, such as
806 footnotes, table of contents, multiple columns, etc. Here's a list of
807 the most important operations supported by @code{groff}:
811 text filling, adjusting, and centering
820 font and glyph size control
823 vertical spacing (e.g.@: double-spacing)
826 line length and indenting
829 macros, strings, diversions, and traps
835 tabs, leaders, and fields
838 input and output conventions and character translation
841 overstrike, bracket, line drawing, and zero-width functions
844 local horizontal and vertical motions and the width function
850 output line numbering
853 conditional acceptance of input
856 environment switching
859 insertions from the standard input
862 input/output file switching
865 output and error messages
869 @c =====================================================================
871 @node Macro Package Intro, Preprocessor Intro, groff Capabilities, Introduction
872 @section Macro Packages
873 @cindex macro packages
875 Since @code{groff} provides such low-level facilities, it can be quite
876 difficult to use by itself. However, @code{groff} provides a
877 @dfn{macro} facility to specify how certain routine operations
878 (e.g.@tie{}starting paragraphs, printing headers and footers, etc.)@:
879 should be done. These macros can be collected together into a
880 @dfn{macro package}. There are a number of macro packages available;
881 the most common (and the ones described in this manual) are @file{man},
882 @file{mdoc}, @file{me}, @file{ms}, and @file{mm}.
885 @c =====================================================================
887 @node Preprocessor Intro, Output device intro, Macro Package Intro, Introduction
888 @section Preprocessors
889 @cindex preprocessors
891 Although @code{groff} provides most functions needed to format a
892 document, some operations would be unwieldy (e.g.@: to draw pictures).
893 Therefore, programs called @dfn{preprocessors} were written that
894 understand their own language and produce the necessary @code{groff}
895 operations. These preprocessors are able to differentiate their own
896 input from the rest of the document via markers.
898 To use a preprocessor, Unix pipes are used to feed the output from the
899 preprocessor into @code{groff}. Any number of preprocessors may be used
900 on a given document; in this case, the preprocessors are linked together
901 into one pipeline. However, with @code{groff}, the user does not need
902 to construct the pipe, but only tell @code{groff} what preprocessors to
905 @code{groff} currently has preprocessors for producing tables
906 (@code{tbl}), typesetting equations (@code{eqn}), drawing pictures
907 (@code{pic} and @code{grn}), processing bibliographies
908 (@code{refer}), and drawing chemical structures (@code{chem}). An
909 associated program that is useful when dealing with preprocessors is
912 A free implementation of @code{grap}, a preprocessor for drawing graphs,
913 can be obtained as an extra package; @code{groff} can use @code{grap}
916 Unique to @code{groff} is the @code{preconv} preprocessor that enables
917 @code{groff} to handle documents in various input encodings.
919 There are other preprocessors in existence, but, unfortunately, no free
920 implementations are available. Among them is a preprocessor for drawing
921 mathematical pictures (@code{ideal}).
924 @c =====================================================================
926 @node Output device intro, Credits, Preprocessor Intro, Introduction
927 @section Output Devices
928 @cindex postprocessors
929 @cindex output devices
930 @cindex devices for output
932 @code{groff} actually produces device independent code that may be fed
933 into a postprocessor to produce output for a particular device.
934 Currently, @code{groff} has postprocessors for @sc{PostScript} devices,
935 character terminals, X@tie{}Windows (for previewing), @TeX{} DVI format,
936 HP LaserJet@tie{}4 and Canon LBP printers (which use @acronym{CAPSL}),
937 @acronym{HTML}, @acronym{XHTML}, and PDF.
940 @c =====================================================================
942 @node Credits, , Output device intro, Introduction
946 Large portions of this manual were taken from existing documents, most
947 notably, the manual pages for the @code{groff} package by James Clark,
948 and Eric Allman's papers on the @file{me} macro package.
950 The section on the @file{man} macro package is partly based on
951 Susan@tie{}G.@: Kleinmann's @file{groff_man} manual page written for the
952 Debian GNU/Linux system.
954 Larry Kollar contributed the section on the @file{ms} macro package.
958 @c =====================================================================
959 @c =====================================================================
961 @node Invoking groff, Tutorial for Macro Users, Introduction, Top
962 @chapter Invoking @code{groff}
963 @cindex invoking @code{groff}
964 @cindex @code{groff} invocation
966 This section focuses on how to invoke the @code{groff} front end. This
967 front end takes care of the details of constructing the pipeline among
968 the preprocessors, @code{gtroff} and the postprocessor.
970 It has become a tradition that GNU programs get the prefix @samp{g} to
971 distinguish it from its original counterparts provided by the host (see
972 @ref{Environment}, for more details). Thus, for example, @code{geqn} is
973 GNU @code{eqn}. On operating systems like GNU/Linux or the Hurd, which
974 don't contain proprietary versions of @code{troff}, and on
975 MS-DOS/MS-Windows, where @code{troff} and associated programs are not
976 available at all, this prefix is omitted since GNU @code{troff} is the
977 only used incarnation of @code{troff}. Exception: @samp{groff} is never
978 replaced by @samp{roff}.
980 In this document, we consequently say @samp{gtroff} when talking about
981 the GNU @code{troff} program. All other implementations of @code{troff}
982 are called @acronym{AT&T} @code{troff}, which is the common origin of all
983 @code{troff} derivates (with more or less compatible changes).
984 Similarly, we say @samp{gpic}, @samp{geqn}, etc.
989 * Macro Directories::
992 * Invocation Examples::
996 @c =====================================================================
998 @node Groff Options, Environment, Invoking groff, Invoking groff
1013 @code{groff} normally runs the @code{gtroff} program and a
1014 postprocessor appropriate for the selected device. The default device
1015 is @samp{ps} (but it can be changed when @code{groff} is configured and
1016 built). It can optionally preprocess with any of @code{gpic},
1017 @code{geqn}, @code{gtbl}, @code{ggrn}, @code{grap}, @code{gchem},
1018 @code{grefer}, @code{gsoelim}, or @code{preconv}.
1020 This section only documents options to the @code{groff} front end. Many
1021 of the arguments to @code{groff} are passed on to @code{gtroff},
1022 therefore those are also included. Arguments to pre- or postprocessors
1023 can be found in @ref{Invoking gpic}, @ref{Invoking geqn}, @ref{Invoking
1024 gtbl}, @ref{Invoking ggrn}, @ref{Invoking grefer}, @ref{Invoking gchem},
1025 @ref{Invoking gsoelim}, @ref{Invoking preconv}, @ref{Invoking grotty},
1026 @ref{Invoking grops}, @ref{Invoking gropdf}, @ref{Invoking grohtml},
1027 @ref{Invoking grodvi}, @ref{Invoking grolj4}, @ref{Invoking grolbp}, and
1028 @ref{Invoking gxditview}.
1030 The command-line format for @code{groff} is:
1033 groff [ -abceghijklpstvzCEGNRSUVXZ ] [ -d@var{cs} ] [ -D@var{arg} ]
1034 [ -f@var{fam} ] [ -F@var{dir} ] [ -I@var{dir} ] [ -K@var{arg} ]
1035 [ -L@var{arg} ] [ -m@var{name} ] [ -M@var{dir} ] [ -n@var{num} ]
1036 [ -o@var{list} ] [ -P@var{arg} ] [ -r@var{cn} ] [ -T@var{dev} ]
1037 [ -w@var{name} ] [ -W@var{name} ] [ @var{files}@dots{} ]
1040 The command-line format for @code{gtroff} is as follows.
1043 gtroff [ -abcivzCERU ] [ -d@var{cs} ] [ -f@var{fam} ] [ -F@var{dir} ]
1044 [ -m@var{name} ] [ -M@var{dir} ] [ -n@var{num} ] [ -o@var{list} ]
1045 [ -r@var{cn} ] [ -T@var{name} ] [ -w@var{name} ] [ -W@var{name} ]
1046 [ @var{files}@dots{} ]
1050 Obviously, many of the options to @code{groff} are actually passed on to
1053 Options without an argument can be grouped behind a
1054 single@tie{}@option{-}. A filename of@tie{}@file{-} denotes the
1055 standard input. It is possible to have whitespace between an option and
1058 The @code{grog} command can be used to guess the correct @code{groff}
1059 command to format a file.
1061 Here's the description of the command-line options:
1063 @cindex command-line options
1066 @cindex @acronym{ASCII} approximation output register (@code{.A})
1067 Generate an @acronym{ASCII} approximation of the typeset output. The
1068 read-only register @code{.A} is then set to@tie{}1. @xref{Built-in
1069 Registers}. A typical example is
1072 groff -a -man -Tdvi troff.man | less
1076 which shows how lines are broken for the DVI device. Note that this
1077 option is rather useless today since graphic output devices are
1078 available virtually everywhere.
1081 Print a backtrace with each warning or error message. This backtrace
1082 should help track down the cause of the error. The line numbers given
1083 in the backtrace may not always be correct: @code{gtroff} can get
1084 confused by @code{as} or @code{am} requests while counting line numbers.
1087 Suppress color output.
1090 Enable compatibility mode. @xref{Implementation Differences}, for the
1091 list of incompatibilities between @code{groff} and @acronym{AT&T}
1094 @item -d@var{c}@var{s}
1095 @itemx -d@var{name}=@var{s}
1096 Define @var{c} or @var{name} to be a string@tie{}@var{s}.
1097 @var{c}@tie{}must be a one-letter name; @var{name} can be of arbitrary
1098 length. All string assignments happen before loading any macro file
1099 (including the start-up file).
1102 Set default input encoding used by @code{preconv} to @var{arg}. Implies
1106 Preprocess with @code{geqn}.
1109 Inhibit all error messages.
1112 Use @var{fam} as the default font family. @xref{Font Families}.
1115 Search @file{@var{dir}} for subdirectories @file{dev@var{name}}
1116 (@var{name} is the name of the device), for the @file{DESC} file, and
1117 for font files before looking in the standard directories (@pxref{Font
1118 Directories}). This option is passed to all pre- and postprocessors
1119 using the @env{GROFF_FONT_PATH} environment variable.
1122 Preprocess with @code{ggrn}.
1125 Preprocess with @code{grap}. Implies @option{-p}.
1128 Print a help message.
1131 Read the standard input after all the named input files have been
1135 This option may be used to specify a directory to search for files.
1136 It is passed to the following programs:
1140 @code{gsoelim} (see @ref{gsoelim} for more details);
1141 it also implies @code{groff}'s @option{-s} option.
1144 @code{gtroff}; it is used to search files named in the @code{psbb} and
1148 @code{grops}; it is used to search files named in the
1149 @w{@code{\X'ps: import}} and @w{@code{\X'ps: file}} escapes.
1152 The current directory is always searched first. This option may be
1153 specified more than once; the directories are searched in the order
1154 specified. No directory search is performed for files specified using
1158 Preprocess with @code{gchem}. Implies @option{-p}.
1161 Preprocess with @code{preconv}. This is run before any other
1162 preprocessor. Please refer to @code{preconv}'s manual page for its
1163 behaviour if no @option{-K} (or @option{-D}) option is specified.
1166 Set input encoding used by preconv to @var{arg}. Implies @option{-k}.
1169 Send the output to a spooler for printing. The command used for this is
1170 specified by the @code{print} command in the device description file
1171 (see @ref{Font Files}, for more info). If not present, @option{-l} is
1175 Pass @var{arg} to the spooler. Each argument should be passed with a
1176 separate @option{-L} option. Note that @code{groff} does not prepend a
1177 @samp{-} to @var{arg} before passing it to the postprocessor. If the
1178 @code{print} keyword in the device description file is missing,
1179 @option{-L} is ignored.
1182 Read in the file @file{@var{name}.tmac}. Normally @code{groff} searches
1183 for this in its macro directories. If it isn't found, it tries
1184 @file{tmac.@var{name}} (searching in the same directories).
1187 Search directory @file{@var{dir}} for macro files before the standard
1188 directories (@pxref{Macro Directories}).
1191 Number the first page @var{num}.
1194 Don't allow newlines with @code{eqn} delimiters. This is the same as
1195 the @option{-N} option in @code{geqn}.
1198 @cindex print current page register (@code{.P})
1199 Output only pages in @var{list}, which is a comma-separated list of page
1200 ranges; @samp{@var{n}} means print page@tie{}@var{n},
1201 @samp{@var{m}-@var{n}} means print every page between @var{m}
1202 and@tie{}@var{n}, @samp{-@var{n}} means print every page up
1203 to@tie{}@var{n}, @samp{@var{n}-} means print every page beginning
1204 with@tie{}@var{n}. @code{gtroff} exits after printing the last page in
1205 the list. All the ranges are inclusive on both ends.
1207 Within @code{gtroff}, this information can be extracted with the
1208 @samp{.P} register. @xref{Built-in Registers}.
1210 If your document restarts page numbering at the beginning of each
1211 chapter, then @code{gtroff} prints the specified page range for each
1215 Preprocess with @code{gpic}.
1218 Pass @var{arg} to the postprocessor. Each argument should be passed
1219 with a separate @option{-P} option. Note that @code{groff} does not
1220 prepend @samp{-} to @var{arg} before passing it to the postprocessor.
1222 @item -r@var{c}@var{n}
1223 @itemx -r@var{name}=@var{n}
1224 Set number register@tie{}@var{c} or @var{name} to the
1225 value@tie{}@var{n}. @var{c}@tie{}must be a one-letter name; @var{name}
1226 can be of arbitrary length. @var{n}@tie{}can be any @code{gtroff}
1227 numeric expression. All register assignments happen before loading any
1228 macro file (including the start-up file).
1231 Preprocess with @code{grefer}. No mechanism is provided for passing
1232 arguments to @code{grefer} because most @code{grefer} options have
1233 equivalent commands that can be included in the file. @xref{grefer},
1238 Note that @code{gtroff} also accepts a @option{-R} option, which is not
1239 accessible via @code{groff}. This option prevents the loading of the
1240 @file{troffrc} and @file{troffrc-end} files.
1243 Preprocess with @code{gsoelim}.
1246 @cindex @code{open} request, and safer mode
1247 @cindex @code{opena} request, and safer mode
1248 @cindex @code{pso} request, and safer mode
1249 @cindex @code{sy} request, and safer mode
1250 @cindex @code{pi} request, and safer mode
1253 Safer mode. Pass the @option{-S} option to @code{gpic} and disable the
1254 @code{open}, @code{opena}, @code{pso}, @code{sy}, and @code{pi}
1255 requests. For security reasons, this is enabled by default.
1258 Preprocess with @code{gtbl}.
1261 Prepare output for device @var{dev}. The default device is @samp{ps},
1262 unless changed when @code{groff} was configured and built. The
1263 following are the output devices currently available:
1267 For @sc{PostScript} printers and previewers.
1270 For PDF viewers or printers.
1273 For @TeX{} DVI format.
1276 For a 75@dmn{dpi} X11 previewer.
1279 For a 75@dmn{dpi} X11 previewer with a 12@dmn{pt} base font in the
1283 For a 100@dmn{dpi} X11 previewer.
1286 For a 100@dmn{dpi} X11 previewer with a 12@dmn{pt} base font in the
1290 @cindex encoding, output, @acronym{ASCII}
1291 @cindex @acronym{ASCII}, output encoding
1292 @cindex output encoding, @acronym{ASCII}
1293 For typewriter-like devices using the (7-bit) @acronym{ASCII}
1297 @cindex encoding, output, @w{latin-1} (ISO @w{8859-1})
1298 @cindex @w{latin-1} (ISO @w{8859-1}), output encoding
1299 @cindex ISO @w{8859-1} (@w{latin-1}), output encoding
1300 @cindex output encoding, @w{latin-1} (ISO @w{8859-1})
1301 For typewriter-like devices that support the @w{Latin-1}
1302 (ISO@tie{}@w{8859-1}) character set.
1305 @cindex encoding, output, @w{utf-8}
1306 @cindex @w{utf-8}, output encoding
1307 @cindex output encoding, @w{utf-8}
1308 For typewriter-like devices that use the Unicode (ISO@tie{}10646)
1309 character set with @w{UTF-8} encoding.
1312 @cindex encoding, output, @acronym{EBCDIC}
1313 @cindex @acronym{EBCDIC}, output encoding
1314 @cindex output encoding, @acronym{EBCDIC}
1315 @cindex encoding, output, cp1047
1316 @cindex cp1047, output encoding
1317 @cindex output encoding, cp1047
1318 @cindex IBM cp1047 output encoding
1319 For typewriter-like devices that use the @acronym{EBCDIC} encoding IBM
1323 For HP LaserJet4-compatible (or other PCL5-compatible) printers.
1326 For Canon @acronym{CAPSL} printers (@w{LBP-4} and @w{LBP-8} series laser
1330 @pindex post-grohtml
1331 @cindex @code{grohtml}, the program
1334 To produce @acronym{HTML} and @acronym{XHTML} output, respectively.
1335 Note that this driver consists of two parts, a preprocessor
1336 (@code{pre-grohtml}) and a postprocessor (@code{post-grohtml}).
1339 @cindex output device name string register (@code{.T})
1340 @cindex output device usage number register (@code{.T})
1341 The predefined @code{gtroff} string register @code{.T} contains the
1342 current output device; the read-only number register @code{.T} is set
1343 to@tie{}1 if this option is used (which is always true if @code{groff}
1344 is used to call @code{gtroff}). @xref{Built-in Registers}.
1346 The postprocessor to be used for a device is specified by the
1347 @code{postpro} command in the device description file. (@xref{Font
1348 Files}, for more info.) This can be overridden with the @option{-X}
1352 @cindex mode, unsafe
1354 Unsafe mode. This enables the @code{open}, @code{opena}, @code{pso},
1355 @code{sy}, and @code{pi} requests.
1358 Enable warning @var{name}. Available warnings are described in
1359 @ref{Debugging}. Multiple @option{-w} options are allowed.
1362 Inhibit warning @var{name}. Multiple @option{-W} options are allowed.
1365 Make programs run by @code{groff} print out their version number.
1368 Print the pipeline on @code{stdout} instead of executing it. If
1369 specified more than once, print the pipeline on @code{stderr} and
1373 Preview with @code{gxditview} instead of using the usual postprocessor.
1374 This is unlikely to produce good results except with @option{-Tps}.
1376 Note that this is not the same as using @option{-TX75} or
1377 @option{-TX100} to view a document with @code{gxditview}: The former
1378 uses the metrics of the specified device, whereas the latter uses
1379 X-specific fonts and metrics.
1382 Suppress output from @code{gtroff}. Only error messages are printed.
1385 Do not postprocess the output of @code{gtroff}. Normally @code{groff}
1386 automatically runs the appropriate postprocessor.
1390 @c =====================================================================
1392 @node Environment, Macro Directories, Groff Options, Invoking groff
1393 @section Environment
1394 @cindex environment variables
1395 @cindex variables in environment
1397 There are also several environment variables (of the operating system,
1398 not within @code{gtroff}) that can modify the behavior of @code{groff}.
1401 @item GROFF_BIN_PATH
1402 @tindex GROFF_BIN_PATH@r{, environment variable}
1403 This search path, followed by @code{PATH}, is used for commands executed
1406 @item GROFF_COMMAND_PREFIX
1407 @tindex GROFF_COMMAND_PREFIX@r{, environment variable}
1408 @cindex command prefix
1409 @cindex prefix, for commands
1410 If this is set to@tie{}@var{X}, then @code{groff} runs
1411 @code{@var{X}troff} instead of @code{gtroff}. This also applies to
1412 @code{tbl}, @code{pic}, @code{eqn}, @code{grn}, @code{chem},
1413 @code{refer}, and @code{soelim}. It does not apply to @code{grops},
1414 @code{grodvi}, @code{grotty}, @code{pre-grohtml}, @code{post-grohtml},
1415 @code{preconv}, @code{grolj4}, @code{gropdf}, and @code{gxditview}.
1417 The default command prefix is determined during the installation
1418 process. If a non-GNU troff system is found, prefix @samp{g} is used,
1421 @item GROFF_ENCODING
1422 @tindex GROFF_ENCODING@r{, environment variable}
1423 The value of this environment value is passed to the @code{preconv}
1424 preprocessor to select the encoding of input files. Setting this option
1425 implies @code{groff}'s command-line option @option{-k} (that is,
1426 @code{groff} actually always calls @code{preconv}). If set without a
1427 value, @code{groff} calls @code{preconv} without arguments. An explicit
1428 @option{-K} command-line option overrides the value of
1429 @env{GROFF_ENCODING}. See the manual page of @code{preconv} for details.
1431 @item GROFF_FONT_PATH
1432 @tindex GROFF_FONT_PATH@r{, environment variable}
1433 A colon-separated list of directories in which to search for the
1434 @code{dev}@var{name} directory (before the default directories are
1435 tried). @xref{Font Directories}.
1437 @item GROFF_TMAC_PATH
1438 @tindex GROFF_TMAC_PATH@r{, environment variable}
1439 A colon-separated list of directories in which to search for macro files
1440 (before the default directories are tried). @xref{Macro Directories}.
1443 @tindex GROFF_TMPDIR@r{, environment variable}
1444 @tindex TMPDIR@r{, environment variable}
1445 The directory in which @code{groff} creates temporary files. If this is
1446 not set and @env{TMPDIR} is set, temporary files are created in that
1447 directory. Otherwise temporary files are created in a system-dependent
1448 default directory (on Unix and GNU/Linux systems, this is usually
1449 @file{/tmp}). @code{grops}, @code{grefer}, @code{pre-grohtml}, and
1450 @code{post-grohtml} can create temporary files in this directory.
1452 @item GROFF_TYPESETTER
1453 @tindex GROFF_TYPESETTER@r{, environment variable}
1454 The default output device.
1456 @item SOURCE_DATE_EPOCH
1457 @tindex SOURCE_DATE_EPOCH@r{, environment variable}
1458 A timestamp (expressed as seconds since the Unix epoch) to use in place of
1459 the current time when initializing time-based built-in registers such as
1463 Note that MS-DOS and MS-Windows ports of @code{groff} use semi-colons,
1464 rather than colons, to separate the directories in the lists described
1468 @c =====================================================================
1470 @node Macro Directories, Font Directories, Environment, Invoking groff
1471 @section Macro Directories
1472 @cindex macro directories
1473 @cindex directories for macros
1474 @cindex searching macros
1475 @cindex macros, searching
1477 All macro file names must be named @code{@var{name}.tmac} or
1478 @code{tmac.@var{name}} to make the @option{-m@var{name}} command-line
1479 option work. The @code{mso} request doesn't have this restriction; any
1480 file name can be used, and @code{gtroff} won't try to append or prepend
1481 the @samp{tmac} string.
1483 @cindex tmac, directory
1484 @cindex directory, for tmac files
1486 @cindex path, for tmac files
1487 @cindex searching macro files
1488 @cindex macro files, searching
1489 @cindex files, macro, searching
1490 Macro files are kept in the @dfn{tmac directories}, all of which
1491 constitute the @dfn{tmac path}. The elements of the search path for
1492 macro files are (in that order):
1496 The directories specified with @code{gtroff}'s or @code{groff}'s
1497 @option{-M} command-line option.
1500 @tindex GROFF_TMAC_PATH@r{, environment variable}
1501 The directories given in the @env{GROFF_TMAC_PATH} environment variable.
1507 @cindex mode, unsafe
1508 @cindex current directory
1509 @cindex directory, current
1510 The current directory (only if in unsafe mode using the @option{-U}
1511 command-line switch).
1514 @cindex home directory
1515 @cindex directory, home
1519 @cindex site-specific directory
1520 @cindex directory, site-specific
1521 @cindex platform-specific directory
1522 @cindex directory, platform-specific
1523 A platform-dependent directory, a site-specific (platform-independent)
1524 directory, and the main tmac directory; the default locations are
1527 /usr/local/lib/groff/site-tmac
1528 /usr/local/share/groff/site-tmac
1529 /usr/local/share/groff/1.22.3/tmac
1533 assuming that the version of @code{groff} is 1.22.3, and the
1534 installation prefix was @file{/usr/local}. It is possible to fine-tune
1535 those directories during the installation process.
1539 @c =====================================================================
1541 @node Font Directories, Paper Size, Macro Directories, Invoking groff
1542 @section Font Directories
1543 @cindex font directories
1544 @cindex directories for fonts
1545 @cindex searching fonts
1546 @cindex fonts, searching
1548 Basically, there is no restriction how font files for @code{groff} are
1549 named and how long font names are; however, to make the font family
1550 mechanism work (@pxref{Font Families}), fonts within a family should
1551 start with the family name, followed by the shape. For example, the
1552 Times family uses @samp{T} for the family name and @samp{R}, @samp{B},
1553 @samp{I}, and @samp{BI} to indicate the shapes `roman', `bold',
1554 `italic', and `bold italic', respectively. Thus the final font names
1555 are @samp{TR}, @samp{TB}, @samp{TI}, and @samp{TBI}.
1558 @cindex path, for font files
1559 All font files are kept in the @dfn{font directories}, which constitute
1560 the @dfn{font path}. The file search functions always append the
1561 directory @code{dev}@var{name}, where @var{name} is the name of the
1562 output device. Assuming, say, DVI output, and @file{/foo/bar} as a font
1563 directory, the font files for @code{grodvi} must be in
1564 @file{/foo/bar/devdvi}.
1566 The elements of the search path for font files are (in that order):
1570 The directories specified with @code{gtroff}'s or @code{groff}'s
1571 @option{-F} command-line option. All device drivers and some
1572 preprocessors also have this option.
1575 @tindex GROFF_FONT_PATH@r{, environment variable}
1576 The directories given in the @env{GROFF_FONT_PATH} environment variable.
1579 @cindex site-specific directory
1580 @cindex directory, site-specific
1581 A site-specific directory and the main font directory; the default
1585 /usr/local/share/groff/site-font
1586 /usr/local/share/groff/1.22.3/font
1590 assuming that the version of @code{groff} is 1.22.3, and the
1591 installation prefix was @file{/usr/local}. It is possible to fine-tune
1592 those directories during the installation process.
1596 @c =====================================================================
1598 @node Paper Size, Invocation Examples, Font Directories, Invoking groff
1602 @cindex landscape page orientation
1603 @cindex orientation, landscape
1604 @cindex page orientation, landscape
1606 In groff, the page size for @code{gtroff} and for output devices are
1607 handled separately. @xref{Page Layout}, for vertical manipulation of
1608 the page size. @xref{Line Layout}, for horizontal changes.
1610 A default paper size can be set in the device's @file{DESC} file. Most
1611 output devices also have a command-line option @option{-p} to override
1612 the default paper size and option @option{-l} to use landscape
1613 orientation. @xref{DESC File Format}, for a description of the
1614 @code{papersize} keyword, which takes the same argument as @option{-p}.
1616 @pindex papersize.tmac
1618 A convenient shorthand to set a particular paper size for @code{gtroff}
1619 is command-line option @option{-dpaper=@var{size}}. This defines string
1620 @code{paper}, which is processed in file @file{papersize.tmac} (loaded in
1621 the start-up file @file{troffrc} by default). Possible values for
1622 @var{size} are the same as the predefined values for the
1623 @code{papersize} keyword (but only in lowercase) except
1624 @code{a7}--@code{d7}. An appended @samp{l} (ell) character denotes
1625 landscape orientation.
1627 For example, use the following for PS output on A4 paper in landscape
1631 groff -Tps -dpaper=a4l -P-pa4 -P-l -ms foo.ms > foo.ps
1634 Note that it is up to the particular macro package to respect default
1635 page dimensions set in this way (most do).
1638 @c =====================================================================
1640 @node Invocation Examples, , Paper Size, Invoking groff
1641 @section Invocation Examples
1642 @cindex invocation examples
1643 @cindex examples of invocation
1645 This section lists several common uses of @code{groff} and the
1646 corresponding command lines.
1653 This command processes @file{file} without a macro package or a
1654 preprocessor. The output device is the default, @samp{ps}, and the
1655 output is sent to @code{stdout}.
1658 groff -t -mandoc -Tascii file | less
1662 This is basically what a call to the @code{man} program does.
1663 @code{gtroff} processes the manual page @file{file} with the
1664 @file{mandoc} macro file (which in turn either calls the @file{man} or
1665 the @file{mdoc} macro package), using the @code{tbl} preprocessor and
1666 the @acronym{ASCII} output device. Finally, the @code{less} pager
1667 displays the result.
1674 Preview @file{file} with @code{gxditview}, using the @file{me} macro
1675 package. Since no @option{-T} option is specified, use the default
1676 device (@samp{ps}). Note that you can either say @w{@samp{-m me}} or
1677 @w{@samp{-me}}; the latter is an anachronism from the early days of
1678 Unix.@footnote{The same is true for the other main macro packages that
1679 come with @code{groff}: @file{man}, @file{mdoc}, @file{ms}, @file{mm},
1680 and @file{mandoc}. This won't work in general; for example, to load
1681 @file{trace.tmac}, either @samp{-mtrace} or @w{@samp{-m trace}} must be
1685 groff -man -rD1 -z file
1689 Check @file{file} with the @file{man} macro package, forcing
1690 double-sided printing -- don't produce any output.
1696 @c ---------------------------------------------------------------------
1698 @node grog, , Invocation Examples, Invocation Examples
1699 @subsection @code{grog}
1702 @code{grog} reads files, guesses which of the @code{groff} preprocessors
1703 and/or macro packages are required for formatting them, and prints the
1704 @code{groff} command including those options on the standard output. It
1705 generates one or more of the options @option{-e}, @option{-man},
1706 @option{-me}, @option{-mm}, @option{-mom}, @option{-ms}, @option{-mdoc},
1707 @option{-mdoc-old}, @option{-p}, @option{-R}, @option{-g}, @option{-G},
1708 @option{-s}, and @option{-t}.
1710 A special file name@tie{}@file{-} refers to the standard input.
1711 Specifying no files also means to read the standard input. Any
1712 specified options are included in the printed command. No space is
1713 allowed between options and their arguments. The only options
1714 recognized are @option{-C} (which is also passed on) to enable
1715 compatibility mode, and @option{-v} to print the version number and
1725 guesses the appropriate command to print @file{paper.ms} and then prints
1726 it to the command line after adding the @option{-Tdvi} option. For
1727 direct execution, enclose the call to @code{grog} in backquotes at the
1731 `grog -Tdvi paper.ms` > paper.dvi
1735 As seen in the example, it is still necessary to redirect the output to
1736 something meaningful (i.e.@: either a file or a pager program like
1741 @c =====================================================================
1742 @c =====================================================================
1744 @node Tutorial for Macro Users, Macro Packages, Invoking groff, Top
1745 @chapter Tutorial for Macro Users
1746 @cindex tutorial for macro users
1747 @cindex macros, tutorial for users
1748 @cindex user's tutorial for macros
1749 @cindex user's macro tutorial
1751 Most users tend to use a macro package to format their papers. This
1752 means that the whole breadth of @code{groff} is not necessary for most
1753 people. This chapter covers the material needed to efficiently use a
1762 @c =====================================================================
1764 @node Basics, Common Features, Tutorial for Macro Users, Tutorial for Macro Users
1766 @cindex basics of macros
1767 @cindex macro basics
1769 This section covers some of the basic concepts necessary to understand
1770 how to use a macro package.@footnote{This section is derived from
1771 @cite{Writing Papers with nroff using -me} by Eric P.@tie{}Allman.}
1772 References are made throughout to more detailed information, if desired.
1774 @code{gtroff} reads an input file prepared by the user and outputs a
1775 formatted document suitable for publication or framing. The input
1776 consists of text, or words to be printed, and embedded commands
1777 (@dfn{requests} and @dfn{escapes}), which tell @code{gtroff} how to
1778 format the output. For more detail on this, see @ref{Embedded
1781 The word @dfn{argument} is used in this chapter to mean a word or number
1782 that appears on the same line as a request, and which modifies the
1783 meaning of that request. For example, the request
1790 spaces one line, but
1797 spaces four lines. The number@tie{}4 is an argument to the @code{sp}
1798 request, which says to space four lines instead of one. Arguments are
1799 separated from the request and from each other by spaces (@emph{no}
1800 tabs). More details on this can be found in @ref{Request and Macro
1803 The primary function of @code{gtroff} is to collect words from input
1804 lines, fill output lines with those words, justify the right-hand margin
1805 by inserting extra spaces in the line, and output the result. For
1813 Four score and seven
1818 is read, packed onto output lines, and justified to produce:
1821 Now is the time for all good men to come to the aid of their party.
1822 Four score and seven years ago, etc.
1827 Sometimes a new output line should be started even though the current
1828 line is not yet full; for example, at the end of a paragraph. To do
1829 this it is possible to cause a @dfn{break}, which starts a new output
1830 line. Some requests cause a break automatically, as normally do blank
1831 input lines and input lines beginning with a space.
1833 Not all input lines are text to be formatted. Some input lines are
1834 requests that describe how to format the text. Requests always have a
1835 period (@samp{.}) or an apostrophe (@samp{'}) as the first character of
1838 The text formatter also does more complex things, such as automatically
1839 numbering pages, skipping over page boundaries, putting footnotes in the
1840 correct place, and so forth.
1842 Here are a few hints for preparing text for input to @code{gtroff}.
1846 First, keep the input lines short. Short input lines are easier to
1847 edit, and @code{gtroff} packs words onto longer lines anyhow.
1850 In keeping with this, it is helpful to begin a new line after every
1851 comma or phrase, since common corrections are to add or delete sentences
1855 End each sentence with two spaces -- or better, start each sentence on a
1856 new line. @code{gtroff} recognizes characters that usually end a
1857 sentence, and inserts sentence space accordingly.
1860 Do not hyphenate words at the end of lines -- @code{gtroff} is smart
1861 enough to hyphenate words as needed, but is not smart enough to take
1862 hyphens out and join a word back together. Also, words such as
1863 ``mother-in-law'' should not be broken over a line, since then a space
1864 can occur where not wanted, such as ``@w{mother- in}-law''.
1867 @cindex double-spacing (@code{ls})
1869 @code{gtroff} double-spaces output text automatically if you use the
1870 request @w{@samp{.ls 2}}. Reactivate single-spaced mode by typing
1871 @w{@samp{.ls 1}}.@footnote{If you need finer granularity of the vertical
1872 space, use the @code{pvs} request (@pxref{Changing Type Sizes}).}
1874 A number of requests allow to change the way the output looks, sometimes
1875 called the @dfn{layout} of the output page. Most of these requests
1876 adjust the placing of @dfn{whitespace} (blank lines or spaces).
1878 @cindex new page (@code{bp})
1879 The @code{bp} request starts a new page, causing a line break.
1881 @cindex blank line (@code{sp})
1882 @cindex empty line (@code{sp})
1883 @cindex line, empty (@code{sp})
1884 The request @w{@samp{.sp @var{N}}} leaves @var{N}@tie{}lines of blank
1885 space. @var{N}@tie{}can be omitted (meaning skip a single line) or can
1886 be of the form @var{N}i (for @var{N}@tie{}inches) or @var{N}c (for
1887 @var{N}@tie{}centimeters). For example, the input:
1891 My thoughts on the subject
1896 leaves one and a half inches of space, followed by the line ``My
1897 thoughts on the subject'', followed by a single blank line (more
1898 measurement units are available, see @ref{Measurements}).
1900 @cindex centering lines (@code{ce})
1901 @cindex lines, centering (@code{ce})
1902 Text lines can be centered by using the @code{ce} request. The line
1903 after @code{ce} is centered (horizontally) on the page. To center more
1904 than one line, use @w{@samp{.ce @var{N}}} (where @var{N} is the number
1905 of lines to center), followed by the @var{N}@tie{}lines. To center many
1906 lines without counting them, type:
1915 The @w{@samp{.ce 0}} request tells @code{groff} to center zero more
1916 lines, in other words, stop centering.
1918 @cindex line break (@code{br})
1919 @cindex break (@code{br})
1920 All of these requests cause a break; that is, they always start a new
1921 line. To start a new line without performing any other action, use
1925 @c =====================================================================
1927 @node Common Features, , Basics, Tutorial for Macro Users
1928 @section Common Features
1929 @cindex common features
1930 @cindex features, common
1932 @code{gtroff} provides very low-level operations for formatting a
1933 document. There are many common routine operations that are done in
1934 all documents. These common operations are written into @dfn{macros}
1935 and collected into a @dfn{macro package}.
1937 All macro packages provide certain common capabilities that fall into
1938 the following categories.
1942 * Sections and Chapters::
1943 * Headers and Footers::
1944 * Page Layout Adjustment::
1946 * Footnotes and Annotations::
1947 * Table of Contents::
1950 * Multiple Columns::
1951 * Font and Size Changes::
1952 * Predefined Strings::
1953 * Preprocessor Support::
1954 * Configuration and Customization::
1957 @c ---------------------------------------------------------------------
1959 @node Paragraphs, Sections and Chapters, Common Features, Common Features
1960 @subsection Paragraphs
1963 One of the most common and most used capability is starting a paragraph.
1964 There are a number of different types of paragraphs, any of which can be
1965 initiated with macros supplied by the macro package. Normally,
1966 paragraphs start with a blank line and the first line indented, like the
1967 text in this manual. There are also block style paragraphs, which omit
1971 Some men look at constitutions with sanctimonious
1972 reverence, and deem them like the ark of the covenant, too
1973 sacred to be touched.
1977 And there are also indented paragraphs, which begin with a tag or label
1978 at the margin and the remaining text indented.
1981 one This is the first paragraph. Notice how the first
1982 line of the resulting paragraph lines up with the
1983 other lines in the paragraph.
1988 This paragraph had a long label. The first
1989 character of text on the first line does not line up
1990 with the text on second and subsequent lines,
1991 although they line up with each other.
1994 A variation of this is a bulleted list.
1997 . Bulleted lists start with a bullet. It is possible
1998 to use other glyphs instead of the bullet. In nroff
1999 mode using the ASCII character set for output, a dot
2000 is used instead of a real bullet.
2003 @c ---------------------------------------------------------------------
2005 @node Sections and Chapters, Headers and Footers, Paragraphs, Common Features
2006 @subsection Sections and Chapters
2008 Most macro packages supply some form of section headers. The simplest
2009 kind is simply the heading on a line by itself in bold type. Others
2010 supply automatically numbered section heading or different heading
2011 styles at different levels. Some, more sophisticated, macro packages
2012 supply macros for starting chapters and appendices.
2014 @c ---------------------------------------------------------------------
2016 @node Headers and Footers, Page Layout Adjustment, Sections and Chapters, Common Features
2017 @subsection Headers and Footers
2019 Every macro package gives some way to manipulate the @dfn{headers} and
2020 @dfn{footers} (also called @dfn{titles}) on each page. This is text put
2021 at the top and bottom of each page, respectively, which contain data
2022 like the current page number, the current chapter title, and so on. Its
2023 appearance is not affected by the running text. Some packages allow for
2024 different ones on the even and odd pages (for material printed in a book
2027 The titles are called @dfn{three-part titles}, that is, there is a
2028 left-justified part, a centered part, and a right-justified part. An
2029 automatically generated page number may be put in any of these fields
2030 with the @samp{%} character (see @ref{Page Layout}, for more details).
2032 @c ---------------------------------------------------------------------
2034 @node Page Layout Adjustment, Displays, Headers and Footers, Common Features
2035 @subsection Page Layout
2037 Most macro packages let the user specify top and bottom margins and
2038 other details about the appearance of the printed pages.
2040 @c ---------------------------------------------------------------------
2042 @node Displays, Footnotes and Annotations, Page Layout Adjustment, Common Features
2043 @subsection Displays
2046 @dfn{Displays} are sections of text to be set off from the body of the
2047 paper. Major quotes, tables, and figures are types of displays, as are
2048 all the examples used in this document.
2050 @cindex quotes, major
2051 @cindex major quotes
2052 @dfn{Major quotes} are quotes that are several lines long, and hence
2053 are set in from the rest of the text without quote marks around them.
2056 A @dfn{list} is an indented, single-spaced, unfilled display. Lists
2057 should be used when the material to be printed should not be filled and
2058 justified like normal text, such as columns of figures or the examples
2062 A @dfn{keep} is a display of lines that are kept on a single page if
2063 possible. An example for a keep might be a diagram. Keeps differ from
2064 lists in that lists may be broken over a page boundary whereas keeps are
2067 @cindex keep, floating
2068 @cindex floating keep
2069 @dfn{Floating keeps} move relative to the text. Hence, they are good
2070 for things that are referred to by name, such as ``See figure@tie{}3''.
2071 A floating keep appears at the bottom of the current page if it fits;
2072 otherwise, it appears at the top of the next page. Meanwhile, the
2073 surrounding text `flows' around the keep, thus leaving no blank areas.
2075 @c ---------------------------------------------------------------------
2077 @node Footnotes and Annotations, Table of Contents, Displays, Common Features
2078 @subsection Footnotes and Annotations
2082 There are a number of requests to save text for later printing.
2084 @dfn{Footnotes} are printed at the bottom of the current page.
2086 @cindex delayed text
2087 @dfn{Delayed text} is very similar to a footnote except that it is
2088 printed when called for explicitly. This allows a list of references to
2089 appear (for example) at the end of each chapter, as is the convention in
2092 Most macro packages that supply this functionality also supply a means
2093 of automatically numbering either type of annotation.
2095 @c ---------------------------------------------------------------------
2097 @node Table of Contents, Indices, Footnotes and Annotations, Common Features
2098 @subsection Table of Contents
2099 @cindex table of contents
2100 @cindex contents, table of
2102 @dfn{Tables of contents} are a type of delayed text having a tag
2103 (usually the page number) attached to each entry after a row of dots.
2104 The table accumulates throughout the paper until printed, usually after
2105 the paper has ended. Many macro packages provide the ability to have
2106 several tables of contents (e.g.@: a standard table of contents, a list
2109 @c ---------------------------------------------------------------------
2111 @node Indices, Paper Formats, Table of Contents, Common Features
2113 @cindex index, in macro package
2115 While some macro packages use the term @dfn{index}, none actually
2116 provide that functionality. The facilities they call indices are
2117 actually more appropriate for tables of contents.
2120 To produce a real index in a document, external tools like the
2121 @code{makeindex} program are necessary.
2123 @c ---------------------------------------------------------------------
2125 @node Paper Formats, Multiple Columns, Indices, Common Features
2126 @subsection Paper Formats
2127 @cindex paper formats
2129 Some macro packages provide stock formats for various kinds of
2130 documents. Many of them provide a common format for the title and
2131 opening pages of a technical paper. The @file{mm} macros in particular
2132 provide formats for letters and memoranda.
2134 @c ---------------------------------------------------------------------
2136 @node Multiple Columns, Font and Size Changes, Paper Formats, Common Features
2137 @subsection Multiple Columns
2139 Some macro packages (but not @file{man}) provide the ability to have two
2140 or more columns on a page.
2142 @c ---------------------------------------------------------------------
2144 @node Font and Size Changes, Predefined Strings, Multiple Columns, Common Features
2145 @subsection Font and Size Changes
2147 The built-in font and size functions are not always intuitive, so all
2148 macro packages provide macros to make these operations simpler.
2150 @c ---------------------------------------------------------------------
2152 @node Predefined Strings, Preprocessor Support, Font and Size Changes, Common Features
2153 @subsection Predefined Strings
2155 Most macro packages provide various predefined strings for a variety of
2156 uses; examples are sub- and superscripts, printable dates, quotes and
2157 various special characters.
2159 @c ---------------------------------------------------------------------
2161 @node Preprocessor Support, Configuration and Customization, Predefined Strings, Common Features
2162 @subsection Preprocessor Support
2164 All macro packages provide support for various preprocessors and may
2165 extend their functionality.
2167 For example, all macro packages mark tables (which are processed with
2168 @code{gtbl}) by placing them between @code{TS} and @code{TE} macros.
2169 The @file{ms} macro package has an option, @samp{.TS@tie{}H}, that
2170 prints a caption at the top of a new page (when the table is too long to
2171 fit on a single page).
2173 @c ---------------------------------------------------------------------
2175 @node Configuration and Customization, , Preprocessor Support, Common Features
2176 @subsection Configuration and Customization
2178 Some macro packages provide means of customizing many of the details of
2179 how the package behaves. This ranges from setting the default type size
2180 to changing the appearance of section headers.
2184 @c =====================================================================
2185 @c =====================================================================
2187 @node Macro Packages, gtroff Reference, Tutorial for Macro Users, Top
2188 @chapter Macro Packages
2189 @cindex macro packages
2190 @cindex packages, macros
2192 This chapter documents the main macro packages that come with
2195 Different main macro packages can't be used at the same time; for
2199 groff -m man foo.man -m ms bar.doc
2203 doesn't work. Note that option arguments are processed before
2204 non-option arguments; the above (failing) sample is thus reordered to
2207 groff -m man -m ms foo.man bar.doc
2220 @c =====================================================================
2222 @node man, mdoc, Macro Packages, Macro Packages
2224 @cindex manual pages
2228 @pindex man-old.tmac
2230 This is the most popular and probably the most important macro package
2231 of @code{groff}. It is easy to use, and a vast majority of manual pages
2238 * Miscellaneous man macros::
2239 * Predefined man strings::
2240 * Preprocessors in man pages::
2241 * Optional man extensions::
2244 @c ---------------------------------------------------------------------
2246 @node Man options, Man usage, man, man
2249 The command-line format for using the @file{man} macros with
2253 groff -m man [ -rLL=@var{length} ] [ -rLT=@var{length} ] [ -rFT=@var{dist} ]
2254 [ -rcR=1 ] [ -rC1 ] [ -rD1 ] [-rHY=@var{flags} ]
2255 [ -rP@var{nnn} ] [ -rS@var{xx} ] [ -rX@var{nnn} ]
2256 [ -rIN=@var{length} ] [ -rSN=@var{length} ] [ @var{files}@dots{} ]
2260 It is possible to use @samp{-man} instead of @w{@samp{-m man}}.
2264 This option (the default if a TTY output device is used) creates a
2265 single, very long page instead of multiple pages. Use @code{-rcR=0} to
2269 If more than one manual page is given on the command line, number the
2270 pages continuously, rather than starting each at@tie{}1.
2273 Double-sided printing. Footers for even and odd pages are formatted
2276 @item -rFT=@var{dist}
2277 Set the position of the footer text to @var{dist}. If positive, the
2278 distance is measured relative to the top of the page, otherwise it is
2279 relative to the bottom. The default is @minus{}0.5@dmn{i}.
2281 @item -rHY=@var{flags}
2282 Set hyphenation flags. Possible values are 1@tie{}to hyphenate without
2283 restrictions, 2@tie{}to not hyphenate the last word on a page, 4@tie{}to
2284 not hyphenate the last two characters of a word, and 8@tie{}to not
2285 hyphenate the first two characters of a word. These values are
2286 additive; the default is@tie{}8.
2288 @item -rIN=@var{length}
2289 Set the body text indentation to @var{length}. If not specified, the
2290 indentation defaults to 7@dmn{n} (7@tie{}characters) in nroff mode and
2291 7.2@dmn{n} otherwise. For nroff, this value should always be an integer
2292 multiple of unit @samp{n} to get consistent indentation.
2294 @item -rLL=@var{length}
2295 Set line length to @var{length}. If not specified, the line length is
2296 set to respect any value set by a prior @samp{ll} request (which
2297 @emph{must} be in effect when the @samp{TH} macro is invoked), if this
2298 differs from the built-in default for the formatter; otherwise it
2299 defaults to 78@dmn{n} in nroff mode (this is 78 characters per line) and
2300 6.5@dmn{i} in troff mode.@footnote{Note that the use of a @samp{.ll
2301 @var{length}} request to initialize the line length, prior to use of the
2302 @samp{TH} macro, is supported for backward compatibility with some
2303 versions of the @code{man} program. @emph{Always} use the
2304 @option{-rLL=@var{length}} option, or an equivalent @samp{.nr LL
2305 @var{length}} request, in preference to such a @samp{.ll @var{length}}
2306 request. In particular, note that in nroff mode, the request @samp{.ll
2307 65n}, (with any @var{length} expression that evaluates equal to
2308 65@dmn{n}, i.e., the formatter's default line length in nroff mode),
2309 does @emph{not} set the line length to 65@dmn{n} (it is adjusted to the
2310 @code{man} macro package's default setting of 78@dmn{n}), whereas the
2311 use of the @option{-rLL=65n} option, or the @samp{.nr LL 65n} request
2312 @emph{does} establish a line length of 65@dmn{n}.}
2314 @item -rLT=@var{length}
2315 Set title length to @var{length}. If not specified, the title length
2316 defaults to the line length.
2319 Page numbering starts with @var{nnn} rather than with@tie{}1.
2322 Use @var{xx} (which can be 10, 11, or@tie{}12@dmn{pt}) as the base
2323 document font size instead of the default value of@tie{}10@dmn{pt}.
2325 @item -rSN=@var{length}
2326 Set the indentation for sub-subheadings to @var{length}. If not
2327 specified, the indentation defaults to 3@dmn{n}.
2330 After page @var{nnn}, number pages as @var{nnn}a, @var{nnn}b,
2331 @var{nnn}c, etc. For example, the option @option{-rX2} produces the
2332 following page numbers: 1, 2, 2a, 2b, 2c, etc.
2335 @c ---------------------------------------------------------------------
2337 @node Man usage, Man font macros, Man options, man
2339 @cindex @code{man} macros
2340 @cindex macros for manual pages [@code{man}]
2343 This section describes the available macros for manual pages. For
2344 further customization, put additional macros and requests into the file
2345 @file{man.local}, which is loaded immediately after the @file{man}
2348 @Defmac {TH, title section [@Var{extra1} [@Var{extra2} [@Var{extra3}]]], man}
2349 Set the title of the man page to @var{title} and the section to
2350 @var{section}, which must have a value between 1 and@tie{}8. The value
2351 of @var{section} may also have a string appended, e.g.@: @samp{.pm}, to
2352 indicate a specific subsection of the man pages.
2354 Both @var{title} and @var{section} are positioned at the left and right
2355 in the header line (with @var{section} in parentheses immediately
2356 appended to @var{title}. @var{extra1} is positioned in the middle of
2357 the footer line. @var{extra2} is positioned at the left in the footer
2358 line (or at the left on even pages and at the right on odd pages if
2359 double-sided printing is active). @var{extra3} is centered in the
2362 For @acronym{HTML} and @acronym{XHTML} output, headers and footers are
2363 completely suppressed.
2365 Additionally, this macro starts a new page; the new line number
2366 is@tie{}1 again (except if the @option{-rC1} option is given on the
2367 command line) -- this feature is intended only for formatting multiple
2368 man pages; a single man page should contain exactly one @code{TH} macro
2369 at the beginning of the file.
2372 @Defmac {SH, [@Var{heading}], man}
2373 Set up an unnumbered section heading sticking out to the left. Prints
2374 out all the text following @code{SH} up to the end of the line (or the
2375 text in the next line if there is no argument to @code{SH}) in bold face
2376 (or the font specified by the string @code{HF}), one size larger than
2377 the base document size. Additionally, the left margin and the
2378 indentation for the following text is reset to its default value.
2381 @Defmac {SS, [@Var{heading}], man}
2382 Set up an unnumbered (sub)section heading. Prints out all the text
2383 following @code{SS} up to the end of the line (or the text in the next
2384 line if there is no argument to @code{SS}) in bold face (or the font
2385 specified by the string @code{HF}), at the same size as the base
2386 document size. Additionally, the left margin and the indentation for
2387 the following text is reset to its default value.
2390 @Defmac {TP, [@Var{nnn}], man}
2391 Set up an indented paragraph with label. The indentation is set to
2392 @var{nnn} if that argument is supplied (the default unit is @samp{n} if
2393 omitted), otherwise it is set to the previous indentation value
2394 specified with @code{TP}, @code{IP}, or @code{HP} (or to the default
2395 value if none of them have been used yet).
2397 The first line of text following this macro is interpreted as a string
2398 to be printed flush-left, as it is appropriate for a label. It is not
2399 interpreted as part of a paragraph, so there is no attempt to fill the
2400 first line with text from the following input lines. Nevertheless, if
2401 the label is not as wide as the indentation the paragraph starts at the
2402 same line (but indented), continuing on the following lines. If the
2403 label is wider than the indentation the descriptive part of the
2404 paragraph begins on the line following the label, entirely indented.
2405 Note that neither font shape nor font size of the label is set to a
2406 default value; on the other hand, the rest of the text has default font
2410 @DefmacList {LP, , man}
2411 @DefmacItemx {PP, , man}
2412 @DefmacListEndx {P, , man}
2413 These macros are mutual aliases. Any of them causes a line break at the
2414 current position, followed by a vertical space downwards by the amount
2415 specified by the @code{PD} macro. The font size and shape are reset to
2416 the default value (10@dmn{pt} roman if no @option{-rS} option is given
2417 on the command line). Finally, the current left margin and the
2418 indentation is restored.
2421 @Defmac {IP, [@Var{designator} [@Var{nnn}]], man}
2422 Set up an indented paragraph, using @var{designator} as a tag to mark
2423 its beginning. The indentation is set to @var{nnn} if that argument is
2424 supplied (default unit is @samp{n}), otherwise it is set to the previous
2425 indentation value specified with @code{TP}, @code{IP}, or @code{HP} (or
2426 the default value if none of them have been used yet). Font size and
2427 face of the paragraph (but not the designator) are reset to their
2430 To start an indented paragraph with a particular indentation but without
2431 a designator, use @samp{""} (two double quotes) as the first argument of
2434 For example, to start a paragraph with bullets as the designator and
2435 4@tie{}en indentation, write
2442 @Defmac {HP, [@Var{nnn}], man}
2443 @cindex hanging indentation [@code{man}]
2444 @cindex @code{man} macros, hanging indentation
2445 Set up a paragraph with hanging left indentation. The indentation is
2446 set to @var{nnn} if that argument is supplied (default unit is
2447 @samp{n}), otherwise it is set to the previous indentation value
2448 specified with @code{TP}, @code{IP}, or @code{HP} (or the default value
2449 if non of them have been used yet). Font size and face are reset to
2450 their default values.
2453 @Defmac {RS, [@Var{nnn}], man}
2454 @cindex left margin, how to move [@code{man}]
2455 @cindex @code{man} macros, moving left margin
2456 Move the left margin to the right by the value @var{nnn} if specified
2457 (default unit is @samp{n}); otherwise it is set to the previous
2458 indentation value specified with @code{TP}, @code{IP}, or @code{HP} (or
2459 to the default value if none of them have been used yet). The
2460 indentation value is then set to the default.
2462 Calls to the @code{RS} macro can be nested.
2465 @Defmac {RE, [@Var{nnn}], man}
2466 Move the left margin back to level @var{nnn}, restoring the previous
2467 left margin. If no argument is given, it moves one level back. The
2468 first level (i.e., no call to @code{RS} yet) has number@tie{}1, and each
2469 call to @code{RS} increases the level by@tie{}1.
2472 @cindex line breaks, with vertical space [@code{man}]
2473 @cindex @code{man} macros, line breaks with vertical space
2474 To summarize, the following macros cause a line break with the insertion
2475 of vertical space (which amount can be changed with the @code{PD}
2476 macro): @code{SH}, @code{SS}, @code{TP}, @code{LP} (@code{PP},
2477 @code{P}), @code{IP}, and @code{HP}.
2479 @cindex line breaks, without vertical space [@code{man}]
2480 @cindex @code{man} macros, line breaks without vertical space
2481 The macros @code{RS} and @code{RE} also cause a break but do not insert
2484 @cindex default indentation, resetting [@code{man}]
2485 @cindex indentation, resetting to default [@code{man}]
2486 @cindex @code{man} macros, resetting default indentation
2487 Finally, the macros @code{SH}, @code{SS}, @code{LP} (@code{PP},
2488 @code{P}), and @code{RS} reset the indentation to its default value.
2490 @c ---------------------------------------------------------------------
2492 @node Man font macros, Miscellaneous man macros, Man usage, man
2493 @subsection Macros to set fonts
2494 @cindex font selection [@code{man}]
2495 @cindex @code{man} macros, how to set fonts
2497 The standard font is roman; the default text size is 10@tie{}points. If
2498 command-line option @option{-rS=@var{n}} is given, use
2499 @var{n}@tie{}points as the default text size.
2501 @Defmac {SM, [@Var{text}], man}
2502 Set the text on the same line or the text on the next line in a font
2503 that is one point size smaller than the default font.
2506 @Defmac {SB, [@Var{text}], man}
2507 @cindex bold face [@code{man}]
2508 @cindex @code{man} macros, bold face
2509 Set the text on the same line or the text on the next line in bold face
2510 font, one point size smaller than the default font.
2513 @Defmac {BI, text, man}
2514 Set its arguments alternately in bold face and italic, without a space
2515 between the arguments. Thus,
2518 .BI this "word and" that
2522 produces ``thisword andthat'' with ``this'' and ``that'' in bold face,
2523 and ``word and'' in italics.
2526 @Defmac {IB, text, man}
2527 Set its arguments alternately in italic and bold face, without a space
2528 between the arguments.
2531 @Defmac {RI, text, man}
2532 Set its arguments alternately in roman and italic, without a space
2533 between the arguments.
2536 @Defmac {IR, text, man}
2537 Set its arguments alternately in italic and roman, without a space
2538 between the arguments.
2541 @Defmac {BR, text, man}
2542 Set its arguments alternately in bold face and roman, without a space
2543 between the arguments.
2546 @Defmac {RB, text, man}
2547 Set its arguments alternately in roman and bold face, without a space
2548 between the arguments.
2551 @Defmac {B, [@Var{text}], man}
2552 Set @var{text} in bold face. If no text is present on the line where
2553 the macro is called, then the text of the next line appears in bold
2557 @Defmac {I, [@Var{text}], man}
2558 @cindex italic fonts [@code{man}]
2559 @cindex @code{man} macros, italic fonts
2560 Set @var{text} in italic. If no text is present on the line where the
2561 macro is called, then the text of the next line appears in italic.
2564 @c ---------------------------------------------------------------------
2566 @node Miscellaneous man macros, Predefined man strings, Man font macros, man
2567 @subsection Miscellaneous macros
2570 @cindex @code{man} macros, default indentation
2571 @cindex default indentation [@code{man}]
2572 The default indentation is 7.2@dmn{n} in troff mode and 7@dmn{n} in
2573 nroff mode except for @code{grohtml}, which ignores indentation.
2576 @cindex tab stops [@code{man}]
2577 @cindex @code{man} macros, tab stops
2578 Set tabs every 0.5@tie{}inches. Since this macro is always executed
2579 during a call to the @code{TH} macro, it makes sense to call it only if
2580 the tab positions have been changed.
2583 @Defmac {PD, [@Var{nnn}], man}
2584 @cindex empty space before a paragraph [@code{man}]
2585 @cindex @code{man} macros, empty space before a paragraph
2586 Adjust the empty space before a new paragraph (or section). The
2587 optional argument gives the amount of space (default unit is @samp{v});
2588 without parameter, the value is reset to its default value (1@tie{}line
2589 in nroff mode, 0.4@dmn{v}@tie{}otherwise).
2591 This affects the macros @code{SH}, @code{SS}, @code{TP}, @code{LP} (as
2592 well as @code{PP} and @code{P}), @code{IP}, and @code{HP}.
2595 The following two macros are included for BSD compatibility.
2597 @Defmac {AT, [@Var{system} [@Var{release}]], man}
2598 @cindex @code{man}macros, BSD compatibility
2599 Alter the footer for use with @acronym{AT&T} manpages. This command
2600 exists only for compatibility; don't use it. The first argument
2601 @var{system} can be:
2605 7th Edition (the default)
2614 An optional second argument @var{release} to @code{AT} specifies the
2615 release number (such as ``System V Release 3'').
2618 @Defmac {UC, [@Var{version}], man}
2619 @cindex @code{man}macros, BSD compatibility
2620 Alters the footer for use with BSD manpages. This command exists only
2621 for compatibility; don't use it. The argument can be:
2625 3rd Berkeley Distribution (the default)
2628 4th Berkeley Distribution
2631 4.2 Berkeley Distribution
2634 4.3 Berkeley Distribution
2637 4.4 Berkeley Distribution
2641 @c ---------------------------------------------------------------------
2643 @node Predefined man strings, Preprocessors in man pages, Miscellaneous man macros, man
2644 @subsection Predefined strings
2646 The following strings are defined:
2649 Switch back to the default font size.
2653 The typeface used for headings.
2654 The default is @samp{B}.
2658 The `registered' sign.
2662 The `trademark' sign.
2665 @DefstrList {lq, man}
2666 @DefstrListEndx {rq, man}
2667 @cindex @code{lq} glyph, and @code{lq} string [@code{man}]
2668 @cindex @code{rq} glyph, and @code{rq} string [@code{man}]
2669 Left and right quote. This is equal to @code{\(lq} and @code{\(rq},
2673 @c ---------------------------------------------------------------------
2675 @node Preprocessors in man pages, Optional man extensions, Predefined man strings, man
2676 @subsection Preprocessors in @file{man} pages
2678 @cindex preprocessor, calling convention
2679 @cindex calling convention of preprocessors
2680 If a preprocessor like @code{gtbl} or @code{geqn} is needed, it has
2681 become common usage to make the first line of the man page look like
2688 @pindex geqn@r{, invocation in manual pages}
2689 @pindex grefer@r{, invocation in manual pages}
2690 @pindex gtbl@r{, invocation in manual pages}
2691 @pindex man@r{, invocation of preprocessors}
2693 Note the single space character after the double quote. @var{word}
2694 consists of letters for the needed preprocessors: @samp{e} for
2695 @code{geqn}, @samp{r} for @code{grefer}, @samp{t} for @code{gtbl}.
2696 Modern implementations of the @code{man} program read this first line
2697 and automatically call the right preprocessor(s).
2699 @c ---------------------------------------------------------------------
2701 @node Optional man extensions, , Preprocessors in man pages, man
2702 @subsection Optional @file{man} extensions
2705 Use the file @file{man.local} for local extensions to the @code{man}
2706 macros or for style changes.
2708 @unnumberedsubsubsec Custom headers and footers
2709 @cindex @code{man} macros, custom headers and footers
2711 In groff versions 1.18.2 and later, you can specify custom headers and
2712 footers by redefining the following macros in @file{man.local}.
2715 Control the content of the headers. Normally, the header prints the
2716 command name and section number on either side, and the optional fifth
2717 argument to @code{TH} in the center.
2721 Control the content of the footers. Normally, the footer prints the
2722 page number and the third and fourth arguments to @code{TH}.
2724 Use the @code{FT} number register to specify the footer position. The
2725 default is @minus{}0.5@dmn{i}.
2728 @unnumberedsubsubsec Ultrix-specific man macros
2729 @cindex Ultrix-specific @code{man} macros
2730 @cindex @code{man} macros, Ultrix-specific
2733 The @code{groff} source distribution includes a file named
2734 @file{man.ultrix}, containing macros compatible with the Ultrix variant
2735 of @code{man}. Copy this file into @file{man.local} (or use the
2736 @code{mso} request to load it) to enable the following macros.
2738 @Defmac {CT, @Var{key}, man}
2739 Print @samp{<CTRL/@var{key}>}.
2743 Print subsequent text using the constant width (Courier) typeface.
2747 Begin a non-filled display.
2751 End a non-filled display started with @code{Ds}.
2754 @Defmac {EX, [@Var{indent}], man}
2755 Begin a non-filled display using the constant width (Courier) typeface.
2756 Use the optional @var{indent} argument to indent the display.
2760 End a non-filled display started with @code{EX}.
2763 @Defmac {G, [@Var{text}], man}
2764 Set @var{text} in Helvetica. If no text is present on the line where
2765 the macro is called, then the text of the next line appears in
2769 @Defmac {GL, [@Var{text}], man}
2770 Set @var{text} in Helvetica Oblique. If no text is present on the line
2771 where the macro is called, then the text of the next line appears in
2775 @Defmac {HB, [@Var{text}], man}
2776 Set @var{text} in Helvetica Bold. If no text is present on the line
2777 where the macro is called, then all text up to the next @code{HB}
2778 appears in Helvetica Bold.
2781 @Defmac {TB, [@Var{text}], man}
2782 Identical to @code{HB}.
2785 @Defmac {MS, @Var{title} @Var{sect} [@Var{punct}], man}
2786 Set a manpage reference in Ultrix format. The @var{title} is in Courier
2787 instead of italic. Optional punctuation follows the section number
2788 without an intervening space.
2791 @Defmac {NT, [@code{C}] [@Var{title}], man}
2792 Begin a note. Print the optional @Var{title}, or the word ``Note'',
2793 centered on the page. Text following the macro makes up the body of the
2794 note, and is indented on both sides. If the first argument is @code{C},
2795 the body of the note is printed centered (the second argument replaces
2796 the word ``Note'' if specified).
2800 End a note begun with @code{NT}.
2803 @Defmac {PN, @Var{path} [@Var{punct}], man}
2804 Set the path name in constant width (Courier), followed by optional
2808 @Defmac {Pn, [@Var{punct}] @Var{path} [@Var{punct}], man}
2809 If called with two arguments, identical to @code{PN}. If called with
2810 three arguments, set the second argument in constant width (Courier),
2811 bracketed by the first and third arguments in the current font.
2815 Switch to roman font and turn off any underlining in effect.
2819 Print the string @samp{<RETURN>}.
2822 @Defmac {VS, [@code{4}], man}
2823 Start printing a change bar in the margin if the number@tie{}@code{4} is
2824 specified. Otherwise, this macro does nothing.
2828 End printing the change bar begun by @code{VS}.
2831 @unnumberedsubsubsec Simple example
2833 The following example @file{man.local} file alters the @code{SH} macro
2834 to add some extra vertical space before printing the heading. Headings
2835 are printed in Helvetica Bold.
2838 .\" Make the heading fonts Helvetica
2841 .\" Put more whitespace in front of headings.
2844 . if t .sp (u;\\n[PD]*2)
2850 @c =====================================================================
2852 @node mdoc, ms, man, Macro Packages
2853 @section @file{mdoc}
2854 @cindex @code{mdoc} macros
2856 @c XXX documentation
2857 @c XXX this is a placeholder until we get stuff knocked into shape
2858 See the @cite{groff_mdoc(7)} man page (type @command{man groff_mdoc}
2859 at the command line).
2862 @c =====================================================================
2864 @node ms, me, mdoc, Macro Packages
2866 @cindex @code{ms} macros
2868 The @file{-ms} macros are suitable for reports, letters, books, user
2869 manuals, and so forth. The package provides macros for cover pages,
2870 section headings, paragraphs, lists, footnotes, pagination, and a table
2875 * General ms Structure::
2876 * ms Document Control Registers::
2877 * ms Cover Page Macros::
2880 * Differences from AT&T ms::
2881 * Naming Conventions::
2884 @c ---------------------------------------------------------------------
2886 @node ms Intro, General ms Structure, ms, ms
2887 @subsection Introduction to @file{ms}
2889 The original @file{-ms} macros were included with @acronym{AT&T}
2890 @code{troff} as well as the @file{man} macros. While the @file{man}
2891 package is intended for brief documents that can be read on-line as well
2892 as printed, the @file{ms} macros are suitable for longer documents that
2893 are meant to be printed rather than read on-line.
2895 The @file{ms} macro package included with @code{groff} is a complete,
2896 bottom-up re-implementation. Several macros (specific to @acronym{AT&T}
2897 or Berkeley) are not included, while several new commands are.
2898 @xref{Differences from AT&T ms}, for more information.
2900 @c ---------------------------------------------------------------------
2902 @node General ms Structure, ms Document Control Registers, ms Intro, ms
2903 @subsection General structure of an @file{ms} document
2904 @cindex @code{ms} macros, general structure
2906 The @file{ms} macro package expects a certain amount of structure, but
2907 not as much as packages such as @file{man} or @file{mdoc}.
2909 The simplest documents can begin with a paragraph macro (such as
2910 @code{LP} or @code{PP}), and consist of text separated by paragraph
2911 macros or even blank lines. Longer documents have a structure as
2916 If you invoke the @code{RP} (report) macro on the first line of the
2917 document, @code{groff} prints the cover page information on its own
2918 page; otherwise it prints the information on the first page with your
2919 document text immediately following. Other document formats found in
2920 @acronym{AT&T} @code{troff} are specific to @acronym{AT&T} or Berkeley,
2921 and are not supported in @code{groff}.
2923 @item Format and layout
2924 By setting number registers, you can change your document's type (font
2925 and size), margins, spacing, headers and footers, and footnotes.
2926 @xref{ms Document Control Registers}, for more details.
2929 A cover page consists of a title, the author's name and institution, an
2930 abstract, and the date.@footnote{Actually, only the title is required.}
2931 @xref{ms Cover Page Macros}, for more details.
2934 Following the cover page is your document. You can use the @file{ms}
2935 macros to write reports, letters, books, and so forth. The package is
2936 designed for structured documents, consisting of paragraphs interspersed
2937 with headings and augmented by lists, footnotes, tables, and other
2938 common constructs. @xref{ms Body Text}, for more details.
2940 @item Table of contents
2941 Longer documents usually include a table of contents, which you can
2942 invoke by placing the @code{TC} macro at the end of your document. The
2943 @file{ms} macros have minimal indexing facilities, consisting of the
2944 @code{IX} macro, which prints an entry on standard error. Printing the
2945 table of contents at the end is necessary since @code{groff} is a
2946 single-pass text formatter, thus it cannot determine the page number of
2947 each section until that section has actually been set and printed.
2948 Since @file{ms} output is intended for hardcopy, you can manually
2949 relocate the pages containing the table of contents between the cover
2950 page and the body text after printing.
2953 @c ---------------------------------------------------------------------
2955 @node ms Document Control Registers, ms Cover Page Macros, General ms Structure, ms
2956 @subsection Document control registers
2957 @cindex @code{ms} macros, document control registers
2959 The following is a list of document control number registers. For the
2960 sake of consistency, set registers related to margins at the beginning
2961 of your document, or just after the @code{RP} macro. You can set other
2962 registers later in your document, but you should keep them together at
2963 the beginning to make them easy to find and edit as necessary.
2965 @unnumberedsubsubsec Margin Settings
2968 Defines the page offset (i.e., the left margin). There is no explicit
2969 right margin setting; the combination of the @code{PO} and @code{LL}
2970 registers implicitly define the right margin width.
2972 Effective: next page.
2974 Default value: 1@dmn{i}.
2978 Defines the line length (i.e., the width of the body text).
2980 Effective: next paragraph.
2986 Defines the title length (i.e., the header and footer width). This
2987 is usually the same as @code{LL}, but not necessarily.
2989 Effective: next paragraph.
2995 Defines the header margin height at the top of the page.
2997 Effective: next page.
3003 Defines the footer margin height at the bottom of the page.
3005 Effective: next page.
3010 @unnumberedsubsubsec Text Settings
3013 Defines the point size of the body text. If the value is larger than or
3014 equal to 1000, divide it by 1000 to get a fractional point size. For
3015 example, @samp{.nr PS 10250} sets the document's point size to
3018 Effective: next paragraph.
3024 Defines the space between lines (line height plus leading). If the
3025 value is larger than or equal to 1000, divide it by 1000 to get a
3026 fractional point size. Due to backwards compatibility, @code{VS} must
3027 be smaller than 40000 (this is 40.0@dmn{p}).
3029 Effective: next paragraph.
3034 @Defmpreg {PSINCR, ms}
3035 Defines an increment in point size, which is applied to section headings
3036 at nesting levels below the value specified in @code{GROWPS}. The value
3037 of @code{PSINCR} should be specified in points, with the @dmn{p} scaling
3038 factor, and may include a fractional component; for example,
3039 @w{@samp{.nr PSINCR 1.5p}} sets a point size increment of 1.5@dmn{p}.
3041 Effective: next section heading.
3046 @Defmpreg {GROWPS, ms}
3047 Defines the heading level below which the point size increment set by
3048 @code{PSINCR} becomes effective. Section headings at and above the
3049 level specified by @code{GROWPS} are printed at the point size set by
3050 @code{PS}; for each level below the value of @code{GROWPS}, the point
3051 size is increased in steps equal to the value of @code{PSINCR}. Setting
3052 @code{GROWPS} to any value less than@tie{}2 disables the incremental
3053 heading size feature.
3055 Effective: next section heading.
3061 Defines the hyphenation level. @code{HY} sets safely the value of the
3062 low-level @code{hy} register. Setting the value of @code{HY} to@tie{}0
3063 is equivalent to using the @code{nh} request.
3065 Effective: next paragraph.
3071 Defines the font family used to typeset the document.
3073 Effective: next paragraph.
3075 Default: as defined in the output device.
3078 @unnumberedsubsubsec Paragraph Settings
3081 Defines the initial indentation of a (@code{PP} macro) paragraph.
3083 Effective: next paragraph.
3089 Defines the space between paragraphs.
3091 Effective: next paragraph.
3093 Default: 0.3@dmn{v}.
3097 Defines the indentation on both sides of a quoted (@code{QP},
3098 @code{QS}, and @code{QE} macros)
3101 Effective: next paragraph.
3106 @Defmpreg {PORPHANS, ms}
3107 Defines the minimum number of initial lines of any paragraph that
3108 should be kept together, to avoid orphan lines at the bottom of a page.
3109 If a new paragraph is started close to the bottom of a page, and there
3110 is insufficient space to accommodate @code{PORPHANS} lines before an
3111 automatic page break, then the page break is forced, before the start of
3114 Effective: next paragraph.
3119 @Defmpreg {HORPHANS, ms}
3120 Defines the minimum number of lines of the following paragraph that
3121 should be kept together with any section heading introduced by the
3122 @code{NH} or @code{SH} macros. If a section heading is placed close to
3123 the bottom of a page, and there is insufficient space to accommodate
3124 both the heading and at least @code{HORPHANS} lines of the following
3125 paragraph, before an automatic page break, then the page break is forced
3128 Effective: next paragraph.
3133 @unnumberedsubsubsec Footnote Settings
3136 Defines the length of a footnote.
3138 Effective: next footnote.
3140 Default: @math{@code{@\n[LL]} * 5 / 6}.
3144 Defines the footnote indentation.
3146 Effective: next footnote.
3152 The footnote format:
3155 Print the footnote number as a superscript; indent the footnote
3159 Print the number followed by a period (like 1.@:) and indent the
3163 Like 1, without an indentation.
3166 Like 1, but print the footnote number as a hanging paragraph.
3169 Effective: next footnote.
3175 Defines the footnote point size. If the value is larger than or equal
3176 to 1000, divide it by 1000 to get a fractional point size.
3178 Effective: next footnote.
3180 Default: @math{@code{@\n[PS]} - 2}.
3184 Defines the footnote vertical spacing. If the value is larger than or
3185 equal to 1000, divide it by 1000 to get a fractional point size.
3187 Effective: next footnote.
3189 Default: @math{@code{@\n[FPS]} + 2}.
3193 Defines the footnote paragraph spacing.
3195 Effective: next footnote.
3197 Default: @math{@code{@\n[PD]} / 2}.
3200 @unnumberedsubsubsec Miscellaneous Number Registers
3202 @Defmpreg {MINGW, ms}
3203 Defines the minimum width between columns in a multi-column document.
3205 Effective: next page.
3211 Sets the vertical spacing before and after a display, a @code{tbl} table, an
3212 @code{eqn} equation, or a @code{pic} image.
3214 Effective: next paragraph.
3216 Default: 0.5@dmn{v}.
3219 @c ---------------------------------------------------------------------
3221 @node ms Cover Page Macros, ms Body Text, ms Document Control Registers, ms
3222 @subsection Cover page macros
3223 @cindex @code{ms} macros, cover page
3224 @cindex cover page macros, [@code{ms}]
3226 Use the following macros to create a cover page for your document in the
3229 @Defmac {RP, [@code{no}], ms}
3230 Specifies the report format for your document. The report format
3231 creates a separate cover page. The default action (no @code{RP} macro)
3232 is to print a subset of the cover page on page@tie{}1 of your document.
3234 If you use the word @code{no} as an optional argument, @code{groff}
3235 prints a title page but does not repeat any of the title page
3236 information (title, author, abstract, etc.@:) on page@tie{}1 of the
3241 (P-one) Prints the header on page@tie{}1. The default is to suppress
3245 @Defmac {DA, [@dots{}], ms}
3246 (optional) Prints the current date, or the arguments to the macro if
3247 any, on the title page (if specified) and in the footers. This is the
3248 default for @code{nroff}.
3251 @Defmac {ND, [@dots{}], ms}
3252 (optional) Prints the current date, or the arguments to the macro if
3253 any, on the title page (if specified) but not in the footers. This is
3254 the default for @code{troff}.
3258 Specifies the document title. @code{groff} collects text following the
3259 @code{TL} macro into the title, until reaching the author name or
3264 Specifies the author's name, which appears on the line (or lines)
3265 immediately following. You can specify multiple authors as follows:
3271 University of West Bumblefuzz
3275 Monolithic Corporation
3282 Specifies the author's institution. You can specify multiple
3283 institutions in the same way that you specify multiple authors.
3286 @Defmac {AB, [@code{no}], ms}
3287 Begins the abstract. The default is to print the word
3288 @acronym{ABSTRACT}, centered and in italics, above the text of the
3289 abstract. The word @code{no} as an optional argument suppresses this
3297 The following is example mark-up for a title page.
3298 @cindex title page, example markup
3299 @cindex example markup, title page
3304 The Inevitability of Code Bloat
3305 in Commercial and Free Software
3309 University of West Bumblefuzz
3311 This report examines the long-term growth
3312 of the code bases in two large, popular software
3313 packages; the free Emacs and the commercial
3315 While differences appear in the type or order
3316 of features added, due to the different
3317 methodologies used, the results are the same
3320 The free software approach is shown to be
3321 superior in that while free software can
3322 become as bloated as commercial offerings,
3323 free software tends to have fewer serious
3324 bugs and the added features are in line with
3328 ... the rest of the paper follows ...
3329 @endCartoucheExample
3331 @c ---------------------------------------------------------------------
3333 @node ms Body Text, ms Page Layout, ms Cover Page Macros, ms
3334 @subsection Body text
3335 @cindex @code{ms} macros, body text
3337 This section describes macros used to mark up the body of your document.
3338 Examples include paragraphs, sections, and other groups.
3341 * Paragraphs in ms::
3343 * Highlighting in ms::
3345 * Indentation values in ms::
3347 * ms Displays and Keeps::
3349 * Example multi-page table::
3353 @c ---------------------------------------------------------------------
3355 @node Paragraphs in ms, Headings in ms, ms Body Text, ms Body Text
3356 @subsubsection Paragraphs
3357 @cindex @code{ms} macros, paragraph handling
3359 The following paragraph types are available.
3362 Sets a paragraph with an initial indentation.
3366 Sets a paragraph without an initial indentation.
3370 Sets a paragraph that is indented at both left and right margins
3371 by the amount of the register @code{QI}.
3372 The effect is identical to the @acronym{HTML} @code{<BLOCKQUOTE>} element.
3373 The next paragraph or heading returns margins to normal.
3374 @code{QP} inserts vertical space of amount set by register @code{PD}
3375 before the paragraph.
3378 @DefmacList {QS, , ms}
3379 @DefmacListEndx {QE, , ms}
3380 These macros begin and end a quoted section.
3381 The @code{QI} register
3382 controls the amount of indentation.
3383 Both @code{QS} and @code{QE} insert inter-paragraph vertical space
3384 set by register @code{PD}.
3385 The text between @code{QS} and @code{QE} can be structured further
3386 by use of the macros @code{LP} or @code{PP}.
3390 Sets a paragraph whose lines are indented, except for the first line.
3391 This is a Berkeley extension.
3394 The following markup uses all four paragraph macros.
3398 Cases used in the study
3400 The following software and versions were
3401 considered for this report.
3403 For commercial software, we chose
3404 .B "Microsoft Word for Windows" ,
3405 starting with version 1.0 through the
3406 current version (Word 2000).
3408 For free software, we chose
3410 from its first appearance as a standalone
3411 editor through the current version (v20).
3412 See [Bloggs 2002] for details.
3414 Franklin's Law applied to software:
3415 software expands to outgrow both
3416 RAM and disk space over time.
3421 .I "Everyone's a Critic" ,
3422 Underground Press, March 2002.
3423 A definitive work that answers all questions
3424 and criticisms about the quality and usability of
3426 @endCartoucheExample
3428 The @code{PORPHANS} register (@pxref{ms Document Control Registers})
3429 operates in conjunction with each of these macros, to inhibit the
3430 printing of orphan lines at the bottom of any page.
3432 @c ---------------------------------------------------------------------
3434 @node Headings in ms, Highlighting in ms, Paragraphs in ms, ms Body Text
3435 @subsubsection Headings
3436 @cindex @code{ms} macros, headings
3438 Use headings to create a hierarchical structure for your document. The
3439 @file{ms} macros print headings in @strong{bold}, using the same font
3440 family and point size as the body text.
3442 The following describes the heading macros:
3444 @DefmacList {NH, @Var{curr-level}, ms}
3445 @DefmacListEnd {NH, @t{S} @Var{level0} @dots{}, ms}
3446 Numbered heading. The argument is either a numeric argument to indicate
3447 the level of the heading, or the letter@tie{}@code{S} followed by
3448 numeric arguments to set the heading level explicitly.
3450 If you specify heading levels out of sequence, such as invoking
3451 @samp{.NH 3} after @samp{.NH 1}, @code{groff} prints a warning on
3455 @DefstrList {SN, ms}
3456 @DefstrItemx {SN-DOT, ms}
3457 @DefstrListEndx {SN-NO-DOT, ms}
3458 After invocation of @code{NH}, the assigned section number is made
3459 available in the strings @code{SN-DOT} (as it appears in a printed
3460 section heading with default formatting, followed by a terminating
3461 period), and @code{SN-NO-DOT} (with the terminating period omitted).
3462 The string @code{SN} is also defined, as an alias for @code{SN-DOT}; if
3463 preferred, you may redefine it as an alias for @code{SN-NO-DOT}, by
3464 including the initialization
3470 at any time @strong{before} you would like the change to take effect.
3473 @Defstr {SN-STYLE, ms}
3474 You may control the style used to print section numbers, within numbered
3475 section headings, by defining an appropriate alias for the string
3476 @code{SN-STYLE}. The default style, in which the printed section number
3477 is followed by a terminating period, is obtained by defining the alias
3480 .als SN-STYLE SN-DOT
3484 If you prefer to omit the terminating period, from section numbers
3485 appearing in numbered section headings, you may define the alias
3488 .als SN-STYLE SN-NO-DOT
3492 Any such change in section numbering style becomes effective from the
3493 next use of @code{.NH}, following redefinition of the alias for
3497 @Defmac {SH, [@Var{match-level}], ms}
3498 Unnumbered subheading.
3500 The optional @var{match-level} argument is a GNU extension. It is a
3501 number indicating the level of the heading, in a manner analogous to the
3502 @var{curr-level} argument to @code{.NH}. Its purpose is to match the
3503 point size, at which the heading is printed, to the size of a numbered
3504 heading at the same level, when the @code{GROWPS} and @code{PSINCR}
3505 heading size adjustment mechanism is in effect. @xref{ms Document
3509 The @code{HORPHANS} register (@pxref{ms Document Control Registers})
3510 operates in conjunction with the @code{NH} and @code{SH} macros, to
3511 inhibit the printing of orphaned section headings at the bottom of any
3514 @c ---------------------------------------------------------------------
3516 @node Highlighting in ms, Lists in ms, Headings in ms, ms Body Text
3517 @subsubsection Highlighting
3518 @cindex @code{ms} macros, highlighting
3520 The @file{ms} macros provide a variety of methods to highlight or
3523 @Defmac {B, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3524 Sets its first argument in @strong{bold type}. If you specify a second
3525 argument, @code{groff} prints it in the previous font after the bold
3526 text, with no intervening space (this allows you to set punctuation
3527 after the highlighted text without highlighting the punctuation).
3528 Similarly, it prints the third argument (if any) in the previous font
3529 @strong{before} the first argument. For example,
3535 prints (@strong{foo}).
3537 If you give this macro no arguments, @code{groff} prints all text
3538 following in bold until the next highlighting, paragraph, or heading
3542 @Defmac {R, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3543 Sets its first argument in roman (or regular) type. It operates
3544 similarly to the @code{B}@tie{}macro otherwise.
3547 @Defmac {I, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3548 Sets its first argument in @emph{italic type}. It operates similarly
3549 to the @code{B}@tie{}macro otherwise.
3552 @Defmac {CW, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3553 Sets its first argument in a @code{constant width face}. It operates
3554 similarly to the @code{B}@tie{}macro otherwise.
3557 @Defmac {BI, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3558 Sets its first argument in bold italic type. It operates similarly to
3559 the @code{B}@tie{}macro otherwise.
3562 @Defmac {BX, [@Var{txt}], ms}
3563 Prints its argument and draws a box around it. If you want to box a
3564 string that contains spaces, use a digit-width space (@code{\0}).
3567 @Defmac {UL, [@Var{txt} [@Var{post}]], ms}
3568 Prints its first argument with an underline. If you specify a second
3569 argument, @code{groff} prints it in the previous font after the
3570 underlined text, with no intervening space.
3574 Prints all text following in larger type (two points larger than the
3575 current point size) until the next font size, highlighting, paragraph,
3576 or heading macro. You can specify this macro multiple times to
3577 enlarge the point size as needed.
3581 Prints all text following in smaller type (two points smaller than the
3582 current point size) until the next type size, highlighting, paragraph,
3583 or heading macro. You can specify this macro multiple times to reduce
3584 the point size as needed.
3588 Prints all text following in the normal point size (that is, the value
3589 of the @code{PS} register).
3592 @DefstrList {@Lbrace{}, ms}
3593 @DefstrListEndx {@Rbrace{}, ms}
3594 Text enclosed with @code{\*@{} and @code{\*@}} is printed as a
3598 @c ---------------------------------------------------------------------
3600 @node Lists in ms, Indentation values in ms, Highlighting in ms, ms Body Text
3601 @subsubsection Lists
3602 @cindex @code{ms} macros, lists
3604 The @code{IP} macro handles duties for all lists.
3606 @Defmac {IP, [@Var{marker} [@Var{width}]], ms}
3607 The @var{marker} is usually a bullet glyph (@code{\[bu]}) for unordered
3608 lists, a number (or auto-incrementing number register) for numbered
3609 lists, or a word or phrase for indented (glossary-style) lists.
3611 The @var{width} specifies the indentation for the body of each list
3612 item; its default unit is @samp{n}. Once specified, the indentation
3613 remains the same for all list items in the document until specified
3616 The @code{PORPHANS} register (@pxref{ms Document Control Registers})
3617 operates in conjunction with the @code{IP} macro, to inhibit the
3618 printing of orphaned list markers at the bottom of any page.
3621 The following is an example of a bulleted list.
3622 @cindex example markup, bulleted list [@code{ms}]
3623 @cindex bulleted list, example markup [@code{ms}]
3647 The following is an example of a numbered list.
3648 @cindex example markup, numbered list [@code{ms}]
3649 @cindex numbered list, example markup [@code{ms}]
3674 Note the use of the auto-incrementing number register in this example.
3676 The following is an example of a glossary-style list.
3677 @cindex example markup, glossary-style list [@code{ms}]
3678 @cindex glossary-style list, example markup [@code{ms}]
3681 A glossary-style list:
3683 Two or more attorneys.
3685 Firearms, preferably
3695 A glossary-style list:
3698 Two or more attorneys.
3700 guns Firearms, preferably large-caliber.
3703 Gotta pay for those lawyers and guns!
3706 In the last example, the @code{IP} macro places the definition on the
3707 same line as the term if it has enough space; otherwise, it breaks to
3708 the next line and starts the definition below the term. This may or may
3709 not be the effect you want, especially if some of the definitions break
3710 and some do not. The following examples show two possible ways to force
3713 The first workaround uses the @code{br} request to force a break after
3714 printing the term or label.
3717 A glossary-style list:
3719 Two or more attorneys.
3722 Firearms, preferably large-caliber.
3724 Gotta pay for those lawyers and guns!
3725 @endCartoucheExample
3727 The second workaround uses the @code{\p} escape to force the break.
3728 Note the space following the escape; this is important. If you omit the
3729 space, @code{groff} prints the first word on the same line as the term
3730 or label (if it fits) @strong{then} breaks the line.
3733 A glossary-style list:
3735 Two or more attorneys.
3737 \p Firearms, preferably large-caliber.
3739 Gotta pay for those lawyers and guns!
3740 @endCartoucheExample
3742 To set nested lists, use the @code{RS} and @code{RE} macros.
3743 @xref{Indentation values in ms}, for more information.
3744 @cindex @code{ms} macros, nested lists
3745 @cindex nested lists [@code{ms}]
3762 @endCartoucheExample
3778 @c ---------------------------------------------------------------------
3780 @node Indentation values in ms, Tabstops in ms, Lists in ms, ms Body Text
3781 @subsubsection Indentation values
3783 In many situations, you may need to indentation a section of text while
3784 still wrapping and filling. @xref{Lists in ms}, for an example of
3787 @DefmacList {RS, , ms}
3788 @DefmacListEndx {RE, , ms}
3789 These macros begin and end an indented section. The @code{PI} register
3790 controls the amount of indentation, allowing the indented text to line
3791 up under hanging and indented paragraphs.
3794 @xref{ms Displays and Keeps}, for macros to indentation and turn off
3797 @c ---------------------------------------------------------------------
3799 @node Tabstops in ms, ms Displays and Keeps, Indentation values in ms, ms Body Text
3800 @subsubsection Tab Stops
3802 Use the @code{ta} request to define tab stops as needed. @xref{Tabs and
3806 Use this macro to reset the tab stops to the default for @file{ms}
3807 (every 5n). You can redefine the @code{TA} macro to create a different
3808 set of default tab stops.
3811 @c ---------------------------------------------------------------------
3813 @node ms Displays and Keeps, ms Insertions, Tabstops in ms, ms Body Text
3814 @subsubsection Displays and keeps
3815 @cindex @code{ms} macros, displays
3816 @cindex @code{ms} macros, keeps
3817 @cindex keeps [@code{ms}]
3818 @cindex displays [@code{ms}]
3820 Use displays to show text-based examples or figures (such as code
3823 Displays turn off filling, so lines of code are displayed as-is without
3824 inserting @code{br} requests in between each line. Displays can be
3825 @dfn{kept} on a single page, or allowed to break across pages.
3827 @DefmacList {DS, @t{L}, ms}
3828 @DefmacItemx {LD, , ms}
3829 @DefmacListEndx {DE, , ms}
3830 Left-justified display. The @samp{.DS L} call generates a page break,
3831 if necessary, to keep the entire display on one page. The @code{LD}
3832 macro allows the display to break across pages. The @code{DE} macro
3836 @DefmacList {DS, @t{I}, ms}
3837 @DefmacItemx {ID, , ms}
3838 @DefmacListEndx {DE, , ms}
3839 Indents the display as defined by the @code{DI} register. The @samp{.DS
3840 I} call generates a page break, if necessary, to keep the entire display
3841 on one page. The @code{ID} macro allows the display to break across
3842 pages. The @code{DE} macro ends the display.
3845 @DefmacList {DS, @t{B}, ms}
3846 @DefmacItemx {BD, , ms}
3847 @DefmacListEndx {DE, , ms}
3848 Sets a block-centered display: the entire display is left-justified, but
3849 indented so that the longest line in the display is centered on the
3850 page. The @samp{.DS B} call generates a page break, if necessary, to
3851 keep the entire display on one page. The @code{BD} macro allows the
3852 display to break across pages. The @code{DE} macro ends the display.
3855 @DefmacList {DS, @t{C}, ms}
3856 @DefmacItemx {CD, , ms}
3857 @DefmacListEndx {DE, , ms}
3858 Sets a centered display: each line in the display is centered. The
3859 @samp{.DS C} call generates a page break, if necessary, to keep the
3860 entire display on one page. The @code{CD} macro allows the display to
3861 break across pages. The @code{DE} macro ends the display.
3864 @DefmacList {DS, @t{R}, ms}
3865 @DefmacItemx {RD, , ms}
3866 @DefmacListEndx {DE, , ms}
3867 Right-justifies each line in the display. The @samp{.DS R} call
3868 generates a page break, if necessary, to keep the entire display on one
3869 page. The @code{RD} macro allows the display to break across pages.
3870 The @code{DE} macro ends the display.
3873 @DefmacList {Ds, , ms}
3874 @DefmacListEndx {De, , ms}
3875 These two macros were formerly provided as aliases for @code{DS} and
3876 @code{DE}, respectively. They have been removed, and should no longer
3877 be used. The original implementations of @code{DS} and @code{DE} are
3878 retained, and should be used instead. X11 documents that actually use
3879 @code{Ds} and @code{De} always load a specific macro file from the X11
3880 distribution (@file{macros.t}) that provides proper definitions for the
3884 On occasion, you may want to @dfn{keep} other text together on a page.
3885 For example, you may want to keep two paragraphs together, or a
3886 paragraph that refers to a table (or list, or other item) immediately
3887 following. The @file{ms} macros provide the @code{KS} and @code{KE}
3888 macros for this purpose.
3890 @DefmacList {KS, , ms}
3891 @DefmacListEndx {KE, , ms}
3892 The @code{KS} macro begins a block of text to be kept on a single page,
3893 and the @code{KE} macro ends the block.
3896 @DefmacList {KF, , ms}
3897 @DefmacListEndx {KE, , ms}
3898 Specifies a @dfn{floating keep}; if the keep cannot fit on the current
3899 page, @code{groff} holds the contents of the keep and allows text
3900 following the keep (in the source file) to fill in the remainder of the
3901 current page. When the page breaks, whether by an explicit @code{bp}
3902 request or by reaching the end of the page, @code{groff} prints the
3903 floating keep at the top of the new page. This is useful for printing
3904 large graphics or tables that do not need to appear exactly where
3908 You can also use the @code{ne} request to force a page break if there is
3909 not enough vertical space remaining on the page.
3911 Use the following macros to draw a box around a section of text (such as
3914 @DefmacList {B1, , ms}
3915 @DefmacListEndx {B2, , ms}
3916 Marks the beginning and ending of text that is to have a box drawn
3917 around it. The @code{B1} macro begins the box; the @code{B2} macro ends
3918 it. Text in the box is automatically placed in a diversion (keep).
3921 @c ---------------------------------------------------------------------
3923 @node ms Insertions, Example multi-page table, ms Displays and Keeps, ms Body Text
3924 @subsubsection Tables, figures, equations, and references
3925 @cindex @code{ms} macros, tables
3926 @cindex @code{ms} macros, figures
3927 @cindex @code{ms} macros, equations
3928 @cindex @code{ms} macros, references
3929 @cindex tables [@code{ms}]
3930 @cindex figures [@code{ms}]
3931 @cindex equations [@code{ms}]
3932 @cindex references [@code{ms}]
3934 The @file{ms} macros support the standard @code{groff} preprocessors:
3935 @code{tbl}, @code{pic}, @code{eqn}, and @code{refer}.
3940 You mark text meant for preprocessors by enclosing it in pairs of tags
3943 @DefmacList {TS, [@code{H}], ms}
3944 @DefmacListEndx {TE, , ms}
3945 Denotes a table, to be processed by the @code{tbl} preprocessor. The
3946 optional argument@tie{}@code{H} to @code{TS} instructs @code{groff} to
3947 create a running header with the information up to the @code{TH} macro.
3948 @code{groff} prints the header at the beginning of the table; if the
3949 table runs onto another page, @code{groff} prints the header on the next
3953 @DefmacList {PS, , ms}
3954 @DefmacListEndx {PE, , ms}
3955 Denotes a graphic, to be processed by the @code{pic} preprocessor. You
3956 can create a @code{pic} file by hand, using the @acronym{AT&T}
3957 @code{pic} manual available on the Web as a reference, or by using a
3958 graphics program such as @code{xfig}.
3961 @DefmacList {EQ, [@Var{align}], ms}
3962 @DefmacListEndx {EN, , ms}
3963 Denotes an equation, to be processed by the @code{eqn} preprocessor.
3964 The optional @var{align} argument can be @code{C}, @code{L},
3965 or@tie{}@code{I} to center (the default), left-justify, or indent the
3969 @DefmacList {[, , ms}
3970 @DefmacListEndx {], , ms}
3971 Denotes a reference, to be processed by the @code{refer} preprocessor.
3972 The GNU @cite{refer(1)} man page provides a comprehensive reference to
3973 the preprocessor and the format of the bibliographic database.
3977 * Example multi-page table::
3980 @c ---------------------------------------------------------------------
3982 @node Example multi-page table, ms Footnotes, ms Insertions, ms Body Text
3983 @subsubsection An example multi-page table
3984 @cindex example markup, multi-page table [@code{ms}]
3985 @cindex multi-page table, example markup [@code{ms}]
3987 The following is an example of how to set up a table that may print
3988 across two or more pages.
3994 Text ...of heading...
3999 ... the rest of the table follows...
4002 @endCartoucheExample
4004 @c ---------------------------------------------------------------------
4006 @node ms Footnotes, , Example multi-page table, ms Body Text
4007 @subsubsection Footnotes
4008 @cindex @code{ms} macros, footnotes
4009 @cindex footnotes [@code{ms}]
4011 The @file{ms} macro package has a flexible footnote system. You can
4012 specify either numbered footnotes or symbolic footnotes (that is, using
4013 a marker such as a dagger symbol).
4016 Specifies the location of a numbered footnote marker in the text.
4019 @DefmacList {FS, , ms}
4020 @DefmacListEndx {FE, , ms}
4021 Specifies the text of the footnote. The default action is to create a
4022 numbered footnote; you can create a symbolic footnote by specifying a
4023 @dfn{mark} glyph (such as @code{\[dg]} for the dagger glyph) in the body
4024 text and as an argument to the @code{FS} macro, followed by the text of
4025 the footnote and the @code{FE} macro.
4028 You can control how @code{groff} prints footnote numbers by changing the
4029 value of the @code{FF} register. @xref{ms Document Control Registers}.
4031 @cindex footnotes, and keeps [@code{ms}]
4032 @cindex keeps, and footnotes [@code{ms}]
4033 @cindex footnotes, and displays [@code{ms}]
4034 @cindex displays, and footnotes [@code{ms}]
4035 Footnotes can be safely used within keeps and displays, but you should
4036 avoid using numbered footnotes within floating keeps. You can set a
4037 second @code{\**} marker between a @code{\**} and its corresponding
4038 @code{.FS} entry; as long as each @code{FS} macro occurs @emph{after}
4039 the corresponding @code{\**} and the occurrences of @code{.FS} are in
4040 the same order as the corresponding occurrences of @code{\**}.
4042 @c ---------------------------------------------------------------------
4044 @node ms Page Layout, Differences from AT&T ms, ms Body Text, ms
4045 @subsection Page layout
4046 @cindex @code{ms} macros, page layout
4047 @cindex page layout [@code{ms}]
4049 The default output from the @file{ms} macros provides a minimalist page
4050 layout: it prints a single column, with the page number centered at the
4051 top of each page. It prints no footers.
4053 You can change the layout by setting the proper number registers and
4057 * ms Headers and Footers::
4059 * ms Multiple Columns::
4061 * ms Strings and Special Characters::
4064 @c ---------------------------------------------------------------------
4066 @node ms Headers and Footers, ms Margins, ms Page Layout, ms Page Layout
4067 @subsubsection Headers and footers
4068 @cindex @code{ms} macros, headers
4069 @cindex @code{ms} macros, footers
4070 @cindex headers [@code{ms}]
4071 @cindex footers [@code{ms}]
4073 For documents that do not distinguish between odd and even pages, set
4074 the following strings:
4076 @DefstrList {LH, ms}
4077 @DefstrItemx {CH, ms}
4078 @DefstrListEndx {RH, ms}
4079 Sets the left, center, and right headers.
4082 @DefstrList {LF, ms}
4083 @DefstrItemx {CF, ms}
4084 @DefstrListEndx {RF, ms}
4085 Sets the left, center, and right footers.
4088 For documents that need different information printed in the even and
4089 odd pages, use the following macros:
4091 @DefmacList {OH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
4092 @DefmacItemx {EH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
4093 @DefmacItemx {OF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
4094 @DefmacListEndx {EF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
4095 The @code{OH} and @code{EH} macros define headers for the odd and even
4096 pages; the @code{OF} and @code{EF} macros define footers for the odd and
4097 even pages. This is more flexible than defining the individual strings.
4099 You can replace the quote (@code{'}) marks with any character not
4100 appearing in the header or footer text.
4103 To specify custom header and footer processing, redefine the following
4106 @DefmacList {PT,, ms}
4107 @DefmacItemx {HD,, ms}
4108 @DefmacListEndx {BT,, ms}
4109 The @code{PT} macro defines a custom header; the @code{BT} macro defines
4110 a custom footer. These macros must handle odd/even/first page
4111 differences if necessary.
4113 The @code{HD} macro defines additional header processing to take place
4114 after executing the @code{PT} macro.
4117 @c ---------------------------------------------------------------------
4119 @node ms Margins, ms Multiple Columns, ms Headers and Footers, ms Page Layout
4120 @subsubsection Margins
4121 @cindex @code{ms} macros, margins
4123 You control margins using a set of number registers. @xref{ms Document
4124 Control Registers}, for details.
4126 @c ---------------------------------------------------------------------
4128 @node ms Multiple Columns, ms TOC, ms Margins, ms Page Layout
4129 @subsubsection Multiple columns
4130 @cindex @code{ms} macros, multiple columns
4131 @cindex multiple columns [@code{ms}]
4133 The @file{ms} macros can set text in as many columns as do reasonably
4134 fit on the page. The following macros are available; all of them force
4135 a page break if a multi-column mode is already set. However, if the
4136 current mode is single-column, starting a multi-column mode does
4137 @emph{not} force a page break.
4147 @Defmac {MC, [@Var{width} [@Var{gutter}]], ms}
4148 Multi-column mode. If you specify no arguments, it is equivalent to the
4149 @code{2C} macro. Otherwise, @var{width} is the width of each column and
4150 @var{gutter} is the space between columns. The @code{MINGW} number
4151 register controls the default gutter width.
4154 @c ---------------------------------------------------------------------
4156 @node ms TOC, ms Strings and Special Characters, ms Multiple Columns, ms Page Layout
4157 @subsubsection Creating a table of contents
4158 @cindex @code{ms} macros, creating table of contents
4159 @cindex table of contents, creating [@code{ms}]
4161 The facilities in the @file{ms} macro package for creating a table of
4162 contents are semi-automated at best. Assuming that you want the table
4163 of contents to consist of the document's headings, you need to repeat
4164 those headings wrapped in @code{XS} and @code{XE} macros.
4166 @DefmacList {XS, [@Var{page}], ms}
4167 @DefmacItemx {XA, [@Var{page}], ms}
4168 @DefmacListEndx {XE, , ms}
4169 These macros define a table of contents or an individual entry in the
4170 table of contents, depending on their use. The macros are very simple;
4171 they cannot indent a heading based on its level. The easiest way to
4172 work around this is to add tabs to the table of contents string. The
4173 following is an example:
4191 @endCartoucheExample
4193 You can manually create a table of contents by beginning with the
4194 @code{XS} macro for the first entry, specifying the page number for that
4195 entry as the argument to @code{XS}. Add subsequent entries using the
4196 @code{XA} macro, specifying the page number for that entry as the
4197 argument to @code{XA}. The following is an example:
4203 A Brief History of the Universe
4205 Details of Galactic Formation
4208 @endCartoucheExample
4211 @Defmac {TC, [@code{no}], ms}
4212 Prints the table of contents on a new page, setting the page number
4213 to@tie{}@strong{i} (Roman lowercase numeral one). You should usually
4214 place this macro at the end of the file, since @code{groff} is a
4215 single-pass formatter and can only print what has been collected up to
4216 the point that the @code{TC} macro appears.
4218 The optional argument @code{no} suppresses printing the title specified
4219 by the string register @code{TOC}.
4222 @Defmac {PX, [@code{no}], ms}
4223 Prints the table of contents on a new page, using the current page
4224 numbering sequence. Use this macro to print a manually generated table
4225 of contents at the beginning of your document.
4227 The optional argument @code{no} suppresses printing the title specified
4228 by the string register @code{TOC}.
4231 The @cite{Groff and Friends HOWTO} includes a @code{sed} script that
4232 automatically inserts @code{XS} and @code{XE} macro entries after each
4233 heading in a document.
4235 Altering the @code{NH} macro to automatically build the table of
4236 contents is perhaps initially more difficult, but would save a great
4237 deal of time in the long run if you use @file{ms} regularly.
4239 @c ---------------------------------------------------------------------
4241 @node ms Strings and Special Characters, , ms TOC, ms Page Layout
4242 @subsubsection Strings and Special Characters
4243 @cindex @code{ms} macros, strings
4244 @cindex @code{ms} macros, special characters
4245 @cindex @code{ms} macros, accent marks
4246 @cindex accent marks [@code{ms}]
4247 @cindex special characters [@code{ms}]
4248 @cindex strings [@code{ms}]
4250 The @file{ms} macros provide the following predefined strings. You can
4251 change the string definitions to help in creating documents in languages
4254 @Defstr {REFERENCES, ms}
4255 Contains the string printed at the beginning of the references
4256 (bibliography) page. The default is @samp{References}.
4259 @Defstr {ABSTRACT, ms}
4260 Contains the string printed at the beginning of the abstract. The
4261 default is @samp{ABSTRACT}.
4265 Contains the string printed at the beginning of the table of contents.
4268 @DefstrList {MONTH1, ms}
4269 @DefstrItemx {MONTH2, ms}
4270 @DefstrItemx {MONTH3, ms}
4271 @DefstrItemx {MONTH4, ms}
4272 @DefstrItemx {MONTH5, ms}
4273 @DefstrItemx {MONTH6, ms}
4274 @DefstrItemx {MONTH7, ms}
4275 @DefstrItemx {MONTH8, ms}
4276 @DefstrItemx {MONTH9, ms}
4277 @DefstrItemx {MONTH10, ms}
4278 @DefstrItemx {MONTH11, ms}
4279 @DefstrListEndx {MONTH12, ms}
4280 Prints the full name of the month in dates. The default is
4281 @samp{January}, @samp{February}, etc.
4284 The following special characters are available@footnote{For an
4285 explanation what special characters are see @ref{Special Characters}.}:
4292 @DefstrListEndx {U, ms}
4293 Prints typographer's quotes in troff, and plain quotes in nroff.
4294 @code{\*Q} is the left quote and @code{\*U} is the right quote.
4297 Improved accent marks are available in the @file{ms} macros.
4300 Specify this macro at the beginning of your document to enable extended
4301 accent marks and special characters. This is a Berkeley extension.
4303 To use the accent marks, place them @strong{after} the character being
4306 Note that groff's native support for accents is superior to the
4307 following definitions.
4310 The following accent marks are available after invoking the @code{AM}
4333 @deffn String @t{\*[:]}
4335 @stindex : @r{[}ms@r{]}
4338 @stindex \*[@r{<colon>}] @r{[}ms@r{]}
4359 The following are standalone characters available after invoking the
4363 Upside-down question mark.
4367 Upside-down exclamation point.
4399 Lowercase æ ligature.
4403 Uppercase Æ ligature.
4406 @c ---------------------------------------------------------------------
4408 @node Differences from AT&T ms, Naming Conventions, ms Page Layout, ms
4409 @subsection Differences from @acronym{AT&T} @file{ms}
4410 @cindex @code{ms} macros, differences from @acronym{AT&T}
4411 @cindex @acronym{AT&T} @code{troff}, @code{ms} macro package differences
4413 This section lists the (minor) differences between the @code{groff -ms}
4414 macros and @acronym{AT&T} @code{troff -ms} macros.
4418 The internals of @code{groff -ms} differ from the internals of
4419 @acronym{AT&T} @code{troff -ms}. Documents that depend upon
4420 implementation details of @acronym{AT&T} @code{troff -ms} may not format
4421 properly with @code{groff -ms}.
4424 The general error-handling policy of @code{groff -ms} is to detect and
4425 report errors, rather than silently to ignore them.
4428 @code{groff -ms} does not work in compatibility mode (that is, with the
4429 @option{-C} option).
4432 There is no special support for typewriter-like devices.
4435 @code{groff -ms} does not provide cut marks.
4438 Multiple line spacing is not supported. Use a larger vertical spacing
4442 Some Unix @code{ms} documentation says that the @code{CW} and @code{GW}
4443 number registers can be used to control the column width and gutter
4444 width, respectively. These number registers are not used in @code{groff
4448 Macros that cause a reset (paragraphs, headings, etc.@:) may change the
4449 indentation. Macros that change the indentation do not increment or
4450 decrement the indentation, but rather set it absolutely. This can cause
4451 problems for documents that define additional macros of their own. The
4452 solution is to use not the @code{in} request but instead the @code{RS}
4453 and @code{RE} macros.
4456 To make @code{groff -ms} use the default page offset (which also
4457 specifies the left margin), the @code{PO} register must stay undefined
4458 until the first @file{-ms} macro is evaluated. This implies that
4459 @code{PO} should not be used early in the document, unless it is changed
4460 also: Remember that accessing an undefined register automatically
4465 This number register is set to@tie{}1 by the @code{groff -ms} macros,
4466 but it is not used by the @code{AT&T} @code{troff -ms} macros.
4467 Documents that need to determine whether they are being formatted with
4468 @code{AT&T} @code{troff -ms} or @code{groff -ms} should use this number
4472 Emulations of a few ancient Bell Labs macros can be re-enabled by
4473 calling the otherwise undocumented @code{SC} section-header macro.
4474 Calling @code{SC} enables @code{UC} for marking up a product or
4475 application name, and the pair @code{P1}/@code{P2} for surrounding code
4478 These are not enabled by default because (a)@tie{}they were not
4479 documented, in the original @code{ms} manual, and (b)@tie{}the @code{P1}
4480 and @code{UC} macros collide with different macros with the same names
4481 in the Berkeley version of @code{ms}.
4483 These @code{groff} emulations are sufficient to give back the 1976
4484 Kernighan@tie{}& Cherry paper @cite{Typesetting Mathematics -- User's
4485 Guide} its section headings, and restore some text that had gone missing
4486 as arguments of undefined macros. No warranty express or implied is
4487 given as to how well the typographic details these produce match the
4488 original Bell Labs macros.
4491 * Missing ms Macros::
4492 * Additional ms Macros::
4495 @c ---------------------------------------------------------------------
4497 @node Missing ms Macros, Additional ms Macros, Differences from AT&T ms, Differences from AT&T ms
4498 @subsubsection @code{troff} macros not appearing in @code{groff}
4500 Macros missing from @code{groff -ms} are cover page macros specific to
4501 Bell Labs and Berkeley. The macros known to be missing are:
4505 Technical memorandum; a cover sheet style
4508 Internal memorandum; a cover sheet style
4511 Memo for record; a cover sheet style
4514 Memo for file; a cover sheet style
4517 Engineer's notes; a cover sheet style
4520 Computing Science Tech Report; a cover sheet style
4526 Cover sheet information
4532 @c ---------------------------------------------------------------------
4534 @node Additional ms Macros, , Missing ms Macros, Differences from AT&T ms
4535 @subsubsection @code{groff} macros not appearing in @acronym{AT&T} @code{troff}
4537 The @code{groff -ms} macros have a few minor extensions compared to the
4538 @acronym{AT&T} @code{troff -ms} macros.
4541 Improved accent marks. @xref{ms Strings and Special Characters}, for
4545 @Defmac {DS, @t{I}, ms}
4546 Indented display. The default behavior of @acronym{AT&T} @code{troff
4547 -ms} was to indent; the @code{groff} default prints displays flush left
4552 Print text in @code{constant width} (Courier) font.
4556 Indexing term (printed on standard error). You can write a script to
4557 capture and process an index generated in this manner.
4560 The following additional number registers
4561 appear in @code{groff -ms}:
4563 @Defmpreg {MINGW, ms}
4564 Specifies a minimum space between columns (for multi-column output);
4565 this takes the place of the @code{GW} register that was documented but
4566 apparently not implemented in @acronym{AT&T} @code{troff}.
4569 Several new string registers are available as well. You can change
4570 these to handle (for example) the local language. @xref{ms Strings and
4571 Special Characters}, for details.
4573 @c ---------------------------------------------------------------------
4575 @node Naming Conventions, , Differences from AT&T ms, ms
4576 @subsection Naming Conventions
4577 @cindex @code{ms} macros, naming conventions
4578 @cindex naming conventions, @code{ms} macros
4580 The following conventions are used for names of macros, strings and
4581 number registers. External names available to documents that use the
4582 @code{groff -ms} macros contain only uppercase letters and digits.
4584 Internally the macros are divided into modules; naming conventions are
4589 Names used only within one module are of the form
4590 @var{module}@code{*}@var{name}.
4593 Names used outside the module in which they are defined are of the form
4594 @var{module}@code{@@}@var{name}.
4597 Names associated with a particular environment are of the form
4598 @var{environment}@code{:}@var{name}; these are used only within the
4602 @var{name} does not have a module prefix.
4605 Constructed names used to implement arrays are of the form
4606 @var{array}@code{!}@var{index}.
4609 Thus the groff ms macros reserve the following names:
4613 Names containing the characters @code{*}, @code{@@}, and@tie{}@code{:}.
4616 Names containing only uppercase letters and digits.
4620 @c =====================================================================
4622 @node me, mm, ms, Macro Packages
4624 @cindex @code{me} macro package
4626 @c XXX documentation
4627 @c XXX this is a placeholder until we get stuff knocked into shape
4628 See the @file{meintro.me} and @file{meref.me} documents in groff's
4629 @file{doc} directory.
4632 @c =====================================================================
4634 @node mm, mom, me, Macro Packages
4636 @cindex @code{mm} macro package
4638 @c XXX documentation
4639 @c XXX this is a placeholder until we get stuff knocked into shape
4640 See the @cite{groff_mm(7)} man page (type @command{man groff_mm} at the
4644 @c =====================================================================
4646 @node mom, , mm, Macro Packages
4648 @cindex @code{mom} macro package
4650 @c XXX documentation
4651 @c XXX this is a placeholder until we get stuff knocked into shape
4652 The main documentation files for the @file{mom} macros are in
4653 @acronym{HTML} format. Additional, useful documentation is in PDF
4654 format. See the @cite{groff(1)} man page, section ``Installation
4655 Directories'', for their location.
4661 Entry point to the full mom manual.
4664 @file{macrolist.html}
4666 Hyperlinked index of macros with brief descriptions, arranged by
4672 PDF features and usage.
4675 The mom macros are in active development between groff releases.
4676 The most recent version, along with up-to-date documentation, is
4677 available at @uref{http://www.schaffter.ca/mom/mom-05.html}.
4679 The @cite{groff_mom(7)} man page (type @command{man groff_mom} at the
4680 command line) contains a partial list of available macros, however their
4681 usage is best understood by consulting the @acronym{HTML} documentation.
4683 @c =====================================================================
4684 @c =====================================================================
4686 @node gtroff Reference, Preprocessors, Macro Packages, Top
4687 @chapter @code{gtroff} Reference
4688 @cindex reference, @code{gtroff}
4689 @cindex @code{gtroff}, reference
4691 This chapter covers @strong{all} of the facilities of @code{gtroff}.
4692 Users of macro packages may skip it if not interested in details.
4700 * Embedded Commands::
4702 * Manipulating Filling and Adjusting::
4703 * Manipulating Hyphenation::
4704 * Manipulating Spacing::
4706 * Character Translations::
4707 * Troff and Nroff Mode::
4712 * Fonts and Symbols::
4715 * Conditionals and Loops::
4718 * Drawing Requests::
4722 * Suppressing output::
4725 * Postprocessor Access::
4727 * Gtroff Internals::
4729 * Implementation Differences::
4733 @c =====================================================================
4735 @node Text, Measurements, gtroff Reference, gtroff Reference
4737 @cindex text, @code{gtroff} processing
4739 @code{gtroff} input files contain text with control commands
4740 interspersed throughout. But, even without control codes, @code{gtroff}
4741 still does several things with the input text:
4745 filling and adjusting
4748 adding additional space after sentences
4754 inserting implicit line breaks
4758 * Filling and Adjusting::
4762 * Implicit Line Breaks::
4763 * Input Conventions::
4767 @c ---------------------------------------------------------------------
4769 @node Filling and Adjusting, Hyphenation, Text, Text
4770 @subsection Filling and Adjusting
4774 When @code{gtroff} reads text, it collects words from the input and fits
4775 as many of them together on one output line as it can. This is known as
4778 @cindex leading spaces
4779 @cindex spaces, leading and trailing
4780 @cindex extra spaces
4781 @cindex trailing spaces
4782 Once @code{gtroff} has a @dfn{filled} line, it tries to @dfn{adjust} it.
4783 This means it widens the spacing between words until the text reaches
4784 the right margin (in the default adjustment mode). Extra spaces between
4785 words are preserved, but spaces at the end of lines are ignored. Spaces
4786 at the front of a line cause a @dfn{break} (breaks are explained in
4787 @ref{Implicit Line Breaks}).
4789 @xref{Manipulating Filling and Adjusting}.
4791 @c ---------------------------------------------------------------------
4793 @node Hyphenation, Sentences, Filling and Adjusting, Text
4794 @subsection Hyphenation
4797 Since the odds are not great for finding a set of words, for every
4798 output line, which fit nicely on a line without inserting excessive
4799 amounts of space between words, @code{gtroff} hyphenates words so that
4800 it can justify lines without inserting too much space between words. It
4801 uses an internal hyphenation algorithm (a simplified version of the
4802 algorithm used within @TeX{}) to indicate which words can be hyphenated
4803 and how to do so. When a word is hyphenated, the first part of the word
4804 is added to the current filled line being output (with an attached
4805 hyphen), and the other portion is added to the next line to be filled.
4807 @xref{Manipulating Hyphenation}.
4809 @c ---------------------------------------------------------------------
4811 @node Sentences, Tab Stops, Hyphenation, Text
4812 @subsection Sentences
4815 Although it is often debated, some typesetting rules say there should be
4816 different amounts of space after various punctuation marks. For
4817 example, the @cite{Chicago typesetting manual} says that a period at the
4818 end of a sentence should have twice as much space following it as would
4819 a comma or a period as part of an abbreviation.
4821 @c XXX exact citation of Chicago manual
4823 @cindex sentence space
4824 @cindex space between sentences
4825 @cindex french-spacing
4826 @code{gtroff} does this by flagging certain characters (normally
4827 @samp{!}, @samp{?}, and @samp{.}) as @dfn{end-of-sentence} characters.
4828 When @code{gtroff} encounters one of these characters at the end of a
4829 line, it appends a normal space followed by a @dfn{sentence space} in
4830 the formatted output. (This justifies one of the conventions mentioned
4831 in @ref{Input Conventions}.)
4833 @cindex transparent characters
4834 @cindex character, transparent
4835 @cindex @code{dg} glyph, at end of sentence
4836 @cindex @code{rq} glyph, at end of sentence
4837 @cindex @code{cq} glyph, at end of sentence
4838 @cindex @code{"}, at end of sentence
4839 @cindex @code{'}, at end of sentence
4840 @cindex @code{)}, at end of sentence
4841 @cindex @code{]}, at end of sentence
4842 @cindex @code{*}, at end of sentence
4843 In addition, the following characters and symbols are treated
4844 transparently while handling end-of-sentence characters: @samp{"},
4845 @samp{'}, @samp{)}, @samp{]}, @samp{*}, @code{\[dg]}, @code{\[rq]}, and
4848 See the @code{cflags} request in @ref{Using Symbols}, for more details.
4850 @cindex @code{\&}, at end of sentence
4851 To prevent the insertion of extra space after an end-of-sentence
4852 character (at the end of a line), append @code{\&}.
4854 @c ---------------------------------------------------------------------
4856 @node Tab Stops, Implicit Line Breaks, Sentences, Text
4857 @subsection Tab Stops
4859 @cindex stops, tabulator
4860 @cindex tab character
4861 @cindex character, tabulator
4863 @cindex @acronym{EBCDIC} encoding
4864 @cindex encoding, @acronym{EBCDIC}
4865 @code{gtroff} translates @dfn{tabulator characters}, also called
4866 @dfn{tabs} (normally code point @acronym{ASCII} @code{0x09} or
4867 @acronym{EBCDIC} @code{0x05}), in the input into movements to the next
4868 tabulator stop. These tab stops are initially located every half inch
4869 across the page. Using this, simple tables can be made easily.
4870 However, it can often be deceptive as the appearance (and width) of the
4871 text on a terminal and the results from @code{gtroff} can vary greatly.
4873 Also, a possible sticking point is that lines beginning with tab
4874 characters are still filled, again producing unexpected results. For
4875 example, the following input
4877 @multitable {12345678} {12345678} {12345678} {12345678}
4879 @tab 1 @tab 2 @tab 3
4887 @multitable {12345678} {12345678} {12345678} {12345678} {12345678} {12345678} {12345678}
4889 @tab 1 @tab 2 @tab 3 @tab @tab 4 @tab 5
4892 @xref{Tabs and Fields}.
4894 @c ---------------------------------------------------------------------
4896 @node Implicit Line Breaks, Input Conventions, Tab Stops, Text
4897 @subsection Implicit Line Breaks
4898 @cindex implicit line breaks
4899 @cindex implicit breaks of lines
4900 @cindex line, implicit breaks
4901 @cindex break, implicit
4904 An important concept in @code{gtroff} is the @dfn{break}. When a break
4905 occurs, @code{gtroff} outputs the partially filled line (unjustified),
4906 and resumes collecting and filling text on the next output line.
4911 @cindex blank line macro (@code{blm})
4912 There are several ways to cause a break in @code{gtroff}. A blank line
4913 not only causes a break, but it also outputs a one-line vertical space
4914 (effectively a blank line). Note that this behaviour can be modified
4915 with the blank line macro request @code{blm}. @xref{Blank Line Traps}.
4919 @cindex leading spaces macro (@code{lsm})
4920 A line that begins with a space causes a break and the space is output
4921 at the beginning of the next line. Note that this space isn't adjusted,
4922 even in fill mode; however, the behaviour can be modified with the
4923 leading spaces macro request @code{lsm}. @xref{Leading Spaces Traps}.
4925 The end of file also causes a break -- otherwise the last line of the
4926 document may vanish!
4928 Certain requests also cause breaks, implicitly or explicitly. This is
4929 discussed in @ref{Manipulating Filling and Adjusting}.
4931 @c ---------------------------------------------------------------------
4933 @node Input Conventions, Input Encodings, Implicit Line Breaks, Text
4934 @subsection Input Conventions
4935 @cindex input conventions
4936 @cindex conventions for input
4938 Since @code{gtroff} does filling automatically, it is traditional in
4939 @code{groff} not to try and type things in as nicely formatted
4940 paragraphs. These are some conventions commonly used when typing
4945 Break lines after punctuation, particularly at the end of a sentence and
4946 in other logical places. Keep separate phrases on lines by themselves,
4947 as entire phrases are often added or deleted when editing.
4950 Try to keep lines less than 40--60@tie{}characters, to allow space for
4951 inserting more text.
4954 Do not try to do any formatting in a @acronym{WYSIWYG} manner (i.e.,
4955 don't try using spaces to get proper indentation).
4958 @c ---------------------------------------------------------------------
4960 @node Input Encodings, , Input Conventions, Text
4961 @subsection Input Encodings
4963 Currently, the following input encodings are available.
4967 @cindex encoding, input, @acronym{EBCDIC}
4968 @cindex @acronym{EBCDIC}, input encoding
4969 @cindex input encoding, @acronym{EBCDIC}
4970 @cindex encoding, input, cp1047
4971 @cindex cp1047, input encoding
4972 @cindex input encoding, cp1047
4973 @cindex IBM cp1047 input encoding
4975 This input encoding works only on @acronym{EBCDIC} platforms (and vice
4976 versa, the other input encodings don't work with @acronym{EBCDIC}); the
4977 file @file{cp1047.tmac} is by default loaded at start-up.
4980 @cindex encoding, input, @w{latin-1} (ISO @w{8859-1})
4981 @cindex @w{latin-1} (ISO @w{8859-1}), input encoding
4982 @cindex ISO @w{8859-1} (@w{latin-1}), input encoding
4983 @cindex input encoding, @w{latin-1} (ISO @w{8859-1})
4985 This is the default input encoding on non-@acronym{EBCDIC} platforms;
4986 the file @file{latin1.tmac} is loaded at start-up.
4989 @cindex encoding, input, @w{latin-2} (ISO @w{8859-2})
4990 @cindex @w{latin-2} (ISO @w{8859-2}), input encoding
4991 @cindex ISO @w{8859-2} (@w{latin-2}), input encoding
4992 @cindex input encoding, @w{latin-2} (ISO @w{8859-2})
4994 To use this encoding, either say @w{@samp{.mso latin2.tmac}} at the very
4995 beginning of your document or use @samp{-mlatin2} as a command-line
4996 argument for @code{groff}.
4999 @cindex encoding, input, @w{latin-5} (ISO @w{8859-9})
5000 @cindex @w{latin-5} (ISO @w{8859-9}), input encoding
5001 @cindex ISO @w{8859-9} (@w{latin-5}), input encoding
5002 @cindex input encoding, @w{latin-5} (ISO @w{8859-9})
5004 For Turkish. Either say @w{@samp{.mso latin5.tmac}} at the very
5005 beginning of your document or use @samp{-mlatin5} as a command-line
5006 argument for @code{groff}.
5008 @item latin-9 (latin-0)
5009 @cindex encoding, input, @w{latin-9} (@w{latin-0}, ISO @w{8859-15})
5010 @cindex @w{latin-9} (@w{latin-0}, ISO @w{8859-15}), input encoding
5011 @cindex ISO @w{8859-15} (@w{latin-9}, @w{latin-0}), input encoding
5012 @cindex input encoding, @w{latin-9} (@w{latin-9}, ISO @w{8859-15})
5014 This encoding is intended (at least in Europe) to replace @w{latin-1}
5015 encoding. The main difference to @w{latin-1} is that @w{latin-9}
5016 contains the Euro character. To use this encoding, either say
5017 @w{@samp{.mso latin9.tmac}} at the very beginning of your document or
5018 use @samp{-mlatin9} as a command-line argument for @code{groff}.
5021 Note that it can happen that some input encoding characters are not
5022 available for a particular output device. For example, saying
5025 groff -Tlatin1 -mlatin9 ...
5029 fails if you use the Euro character in the input. Usually, this
5030 limitation is present only for devices that have a limited set of
5031 output glyphs (e.g.@: @option{-Tascii} and @option{-Tlatin1}); for other
5032 devices it is usually sufficient to install proper fonts that contain
5033 the necessary glyphs.
5035 @pindex freeeuro.pfa
5037 Due to the importance of the Euro glyph in Europe, the groff package now
5038 comes with a @sc{PostScript} font called @file{freeeuro.pfa}, which
5039 provides various glyph shapes for the Euro. In other words,
5040 @w{latin-9} encoding is supported for the @option{-Tps} device out of
5041 the box (@w{latin-2} isn't).
5043 By its very nature, @option{-Tutf8} supports all input encodings;
5044 @option{-Tdvi} has support for both @w{latin-2} and @w{latin-9} if the
5045 command-line @option{-mec} is used also to load the file @file{ec.tmac}
5046 (which flips to the EC fonts).
5049 @c =====================================================================
5051 @node Measurements, Expressions, Text, gtroff Reference
5052 @section Measurements
5053 @cindex measurements
5054 @cindex scaling indicator
5055 @cindex indicator, scaling
5057 @cindex units of measurement
5058 @cindex basic unit (@code{u})
5059 @cindex machine unit (@code{u})
5060 @cindex measurement unit
5061 @cindex @code{u} unit
5062 @cindex unit, @code{u}
5063 @code{gtroff} (like many other programs) requires numeric parameters to
5064 specify various measurements. Most numeric parameters@footnote{those
5065 that specify vertical or horizontal motion or a type size} may have a
5066 @dfn{measurement unit} attached. These units are specified as a single
5067 character that immediately follows the number or expression. Each of
5068 these units are understood, by @code{gtroff}, to be a multiple of its
5069 @dfn{basic unit}. So, whenever a different measurement unit is
5070 specified @code{gtroff} converts this into its @dfn{basic units}. This
5071 basic unit, represented by a @samp{u}, is a device dependent measurement,
5072 which is quite small, ranging from 1/75@dmn{th} to 1/72000@dmn{th} of an
5073 inch. The values may be given as fractional numbers; however,
5074 fractional basic units are always rounded to integers.
5076 Some of the measurement units are completely independent of any of the
5077 current settings (e.g.@: type size) of @code{gtroff}.
5079 Although groff's basic unit is device-dependent, it may still be smaller
5080 than the smallest unit the device is capable of producing. The register
5081 @code{.H} specifies how many groff basic units constitute the current
5082 device's basic unit horizontally, and the register @code{.V} specifies
5083 this value vertically.
5087 @cindex inch unit (@code{i})
5088 @cindex @code{i} unit
5089 @cindex unit, @code{i}
5090 Inches. An antiquated measurement unit still in use in certain
5091 backwards countries with incredibly low-cost computer equipment. One
5092 inch is defined to be 2.54@tie{}cm (worldwide since 1964).
5095 @cindex centimeter unit (@code{c})
5096 @cindex @code{c} unit
5097 @cindex unit, @code{c}
5098 Centimeters. One centimeter is about 0.3937@tie{}in.
5101 @cindex point unit (@code{p})
5102 @cindex @code{p} unit
5103 @cindex unit, @code{p}
5104 Points. This is a typesetter's measurement used for measure type size.
5105 It is 72@tie{}points to an inch.
5108 @cindex pica unit (@code{P})
5109 @cindex @code{P} unit
5110 @cindex unit, @code{P}
5111 Pica. Another typesetting measurement. 6@tie{}picas to an inch (and
5112 12@tie{}points to a pica).
5116 @cindex @code{s} unit
5117 @cindex unit, @code{s}
5118 @cindex @code{z} unit
5119 @cindex unit, @code{z}
5120 @xref{Fractional Type Sizes}, for a discussion of these units.
5123 @cindex @code{f} unit
5124 @cindex unit, @code{f}
5125 Fractions. Value is 65536.
5126 @xref{Colors}, for usage.
5129 The other measurements understood by @code{gtroff} depend on settings
5130 currently in effect in @code{gtroff}. These are very useful for
5131 specifying measurements that should look proper with any size of text.
5135 @cindex em unit (@code{m})
5136 @cindex @code{m} unit
5137 @cindex unit, @code{m}
5138 Ems. This unit is equal to the current font size in points. So called
5139 because it is @emph{approximately} the width of the letter@tie{}@samp{m}
5140 in the current font.
5143 @cindex en unit (@code{n})
5144 @cindex @code{n} unit
5145 @cindex unit, @code{n}
5146 Ens. In @code{groff}, this is half of an em.
5149 @cindex vertical space unit (@code{v})
5150 @cindex space, vertical, unit (@code{v})
5151 @cindex @code{v} unit
5152 @cindex unit, @code{v}
5153 Vertical space. This is equivalent to the current line spacing.
5154 @xref{Sizes}, for more information about this.
5157 @cindex @code{M} unit
5158 @cindex unit, @code{M}
5166 @c ---------------------------------------------------------------------
5168 @node Default Units, , Measurements, Measurements
5169 @subsection Default Units
5170 @cindex default units
5171 @cindex units, default
5173 Many requests take a default unit. While this can be helpful at times,
5174 it can cause strange errors in some expressions. For example, the line
5175 length request expects em units. Here are several attempts to get a
5176 line length of 3.5@tie{}inches and their results:
5182 (7 / 2)u @result{} 0i
5184 7i/2u @result{} 3.5i
5188 Everything is converted to basic units first. In the above example it
5189 is assumed that 1@dmn{i} equals@tie{}240@dmn{u}, and 1@dmn{m}
5190 equals@tie{}10@dmn{p} (thus 1@dmn{m} equals@tie{}33@dmn{u}). The value
5191 7@dmn{i}/2 is first handled as 7@dmn{i}/2@dmn{m}, then converted to
5192 1680@dmn{u}/66@dmn{u}, which is 25@dmn{u}, and this is approximately
5193 0.1@dmn{i}. As can be seen, a scaling indicator after a closing
5194 parenthesis is simply ignored.
5196 @cindex measurements, specifying safely
5197 Thus, the safest way to specify measurements is to always attach a
5198 scaling indicator. If you want to multiply or divide by a certain
5199 scalar value, use @samp{u} as the unit for that value.
5202 @c =====================================================================
5204 @node Expressions, Identifiers, Measurements, gtroff Reference
5205 @section Expressions
5208 @code{gtroff} has most arithmetic operators common to other languages:
5212 @cindex arithmetic operators
5213 @cindex operators, arithmetic
5219 Arithmetic: @samp{+} (addition), @samp{-} (subtraction), @samp{/}
5220 (division), @samp{*} (multiplication), @samp{%} (modulo).
5222 @code{gtroff} only provides integer arithmetic. The internal type used
5223 for computing results is @samp{int}, which is usually a 32-bit signed
5227 @cindex comparison operators
5228 @cindex operators, comparison
5235 Comparison: @samp{<} (less than), @samp{>} (greater than), @samp{<=}
5236 (less than or equal), @samp{>=} (greater than or equal), @samp{=}
5237 (equal), @samp{==} (the same as @samp{=}).
5240 @cindex logical operators
5241 @cindex operators, logical
5247 @opindex @r{<colon>}
5249 Logical: @samp{&} (logical and), @samp{:} (logical or).
5252 @cindex unary operators
5253 @cindex operators, unary
5257 @cindex @code{if} request, and the @samp{!} operator
5258 @cindex @code{while} request, and the @samp{!} operator
5259 Unary operators: @samp{-} (negating, i.e.@: changing the sign), @samp{+}
5260 (just for completeness; does nothing in expressions), @samp{!} (logical
5261 not; this works only within @code{if} and @code{while}
5262 requests).@footnote{Note that, for example, @samp{!(-1)} evaluates to
5263 `true' because @code{gtroff} treats both negative numbers and zero as
5264 `false'.} See below for the use of unary operators in motion requests.
5266 @cindex logical not, limitation in expression
5267 @cindex expression, limitation of logical not in
5268 The logical not operator,
5270 works only within @code{if} and @code{while} requests.
5271 Furthermore, it may appear
5272 only at the beginning of an expression,
5273 and negates the entire expression.
5274 Attempting to insert the @samp{!} operator
5275 within the expression results in a
5276 @samp{numeric expression expected} warning. This
5277 maintains compatibility
5278 with old versions of @code{troff}.
5285 .\" This does not work as expected
5286 .if (\n[X])&(!\n[Y]) .nop X only
5288 .\" Use this construct instead
5289 .if (\n[X]=1)&(\n[Y]=0) .nop X only
5293 @cindex extremum operators (@code{>?}, @code{<?})
5294 @cindex operators, extremum (@code{>?}, @code{<?})
5297 Extrema: @samp{>?} (maximum), @samp{<?} (minimum).
5304 .nr z (\n[x] >? \n[y])
5308 The register@tie{}@code{z} now contains@tie{}5.
5311 @cindex scaling operator
5312 @cindex operator, scaling
5313 Scaling: @code{(@var{c};@var{e})}. Evaluate@tie{}@var{e}
5314 using@tie{}@var{c} as the default scaling indicator. If @var{c} is
5315 missing, ignore scaling indicators in the evaluation of@tie{}@var{e}.
5319 @cindex order of evaluation in expressions
5320 @cindex expression, order of evaluation
5323 Parentheses may be used as in any other language. However, in
5324 @code{gtroff} they are necessary to ensure order of evaluation.
5325 @code{gtroff} has no operator precedence; expressions are evaluated left
5326 to right. This means that @code{gtroff} evaluates @samp{3+5*4} as if it
5327 were parenthesized like @samp{(3+5)*4}, not as @samp{3+(5*4)}, as might
5330 @cindex @code{+}, and page motion
5331 @cindex @code{-}, and page motion
5332 @cindex motion operators
5333 @cindex operators, motion
5334 For many requests that cause a motion on the page, the unary operators
5335 @samp{+} and @samp{-} work differently if leading an expression. They
5336 then indicate a motion relative to the current position (down or up,
5339 @cindex @code{|}, and page motion
5340 @cindex absolute position operator (@code{|})
5341 @cindex position, absolute, operator (@code{|})
5342 Similarly, a leading @samp{|} operator indicates an absolute position.
5343 For vertical movements, it specifies the distance from the top of the
5344 page; for horizontal movements, it gives the distance from the beginning
5345 of the @emph{input} line.
5347 @cindex @code{bp} request, using @code{+} and@tie{}@code{-}
5348 @cindex @code{in} request, using @code{+} and@tie{}@code{-}
5349 @cindex @code{ll} request, using @code{+} and@tie{}@code{-}
5350 @cindex @code{lt} request, using @code{+} and@tie{}@code{-}
5351 @cindex @code{nm} request, using @code{+} and@tie{}@code{-}
5352 @cindex @code{nr} request, using @code{+} and@tie{}@code{-}
5353 @cindex @code{pl} request, using @code{+} and@tie{}@code{-}
5354 @cindex @code{pn} request, using @code{+} and@tie{}@code{-}
5355 @cindex @code{po} request, using @code{+} and@tie{}@code{-}
5356 @cindex @code{ps} request, using @code{+} and@tie{}@code{-}
5357 @cindex @code{pvs} request, using @code{+} and@tie{}@code{-}
5358 @cindex @code{rt} request, using @code{+} and@tie{}@code{-}
5359 @cindex @code{ti} request, using @code{+} and@tie{}@code{-}
5360 @cindex @code{\H}, using @code{+} and@tie{}@code{-}
5361 @cindex @code{\R}, using @code{+} and@tie{}@code{-}
5362 @cindex @code{\s}, using @code{+} and@tie{}@code{-}
5363 @samp{+} and @samp{-} are also treated differently by the following
5364 requests and escapes: @code{bp}, @code{in}, @code{ll}, @code{lt},
5365 @code{nm}, @code{nr}, @code{pl}, @code{pn}, @code{po}, @code{ps},
5366 @code{pvs}, @code{rt}, @code{ti}, @code{\H}, @code{\R}, and @code{\s}.
5367 Here, leading plus and minus signs indicate increments and decrements.
5369 @xref{Setting Registers}, for some examples.
5371 @Defesc {\\B, ', anything, '}
5372 @cindex numeric expression, valid
5373 @cindex valid numeric expression
5374 Return@tie{}1 if @var{anything} is a valid numeric expression; or@tie{}0
5375 if @var{anything} is empty or not a valid numeric expression.
5378 @cindex space characters, in expressions
5379 @cindex expressions, and space characters
5380 Due to the way arguments are parsed, spaces are not allowed in
5381 expressions, unless the entire expression is surrounded by parentheses.
5383 @xref{Request and Macro Arguments}, and @ref{Conditionals and Loops}.
5386 @c =====================================================================
5388 @node Identifiers, Embedded Commands, Expressions, gtroff Reference
5389 @section Identifiers
5392 Like any other language, @code{gtroff} has rules for properly formed
5393 @dfn{identifiers}. In @code{gtroff}, an identifier can be made up of
5394 almost any printable character, with the exception of the following
5399 @cindex whitespace characters
5400 @cindex newline character
5401 @cindex character, whitespace
5402 Whitespace characters (spaces, tabs, and newlines).
5405 @cindex character, backspace
5406 @cindex backspace character
5407 @cindex @acronym{EBCDIC} encoding of backspace
5408 Backspace (@acronym{ASCII}@tie{}@code{0x08} or
5409 @acronym{EBCDIC}@tie{}@code{0x16}) and character code @code{0x01}.
5412 @cindex invalid input characters
5413 @cindex input characters, invalid
5414 @cindex characters, invalid input
5416 The following input characters are invalid and are ignored if
5417 @code{groff} runs on a machine based on @acronym{ASCII}, causing a
5418 warning message of type @samp{input} (see @ref{Debugging}, for more
5419 details): @code{0x00}, @code{0x0B}, @code{0x0D}--@code{0x1F},
5420 @code{0x80}--@code{0x9F}.
5422 And here are the invalid input characters if @code{groff} runs on an
5423 @acronym{EBCDIC} host: @code{0x00}, @code{0x08}, @code{0x09},
5424 @code{0x0B}, @code{0x0D}--@code{0x14}, @code{0x17}--@code{0x1F},
5425 @code{0x30}--@code{0x3F}.
5427 Currently, some of these reserved codepoints are used internally, thus
5428 making it non-trivial to extend @code{gtroff} to cover Unicode or other
5429 character sets and encodings that use characters of these ranges.
5431 Note that invalid characters are removed before parsing; an identifier
5432 @code{foo}, followed by an invalid character, followed by @code{bar} is
5433 treated as @code{foobar}.
5436 For example, any of the following is valid.
5446 @cindex @code{]}, as part of an identifier
5448 Note that identifiers longer than two characters with a closing bracket
5449 (@samp{]}) in its name can't be accessed with escape sequences that
5450 expect an identifier as a parameter. For example, @samp{\[foo]]}
5451 accesses the glyph @samp{foo}, followed by @samp{]}, whereas
5452 @samp{\C'foo]'} really asks for glyph @samp{foo]}.
5454 @cindex @code{refer}, and macro names starting with @code{[} or @code{]}
5455 @cindex @code{[}, macro names starting with, and @code{refer}
5456 @cindex @code{]}, macro names starting with, and @code{refer}
5457 @cindex macro names, starting with @code{[} or @code{]}, and @code{refer}
5458 To avoid problems with the @code{refer} preprocessor, macro names should
5459 not start with @samp{[} or @samp{]}. Due to backwards compatibility,
5460 everything after @samp{.[} and @samp{.]} is handled as a special
5461 argument to @code{refer}. For example, @samp{.[foo} makes @code{refer}
5462 to start a reference, using @samp{foo} as a parameter.
5464 @Defesc {\\A, ', ident, '}
5465 Test whether an identifier @var{ident} is valid in @code{gtroff}. It
5466 expands to the character@tie{}1 or@tie{}0 according to whether its
5467 argument (usually delimited by quotes) is or is not acceptable as the
5468 name of a string, macro, diversion, number register, environment, or
5469 font. It returns@tie{}0 if no argument is given. This is useful for
5470 looking up user input in some sort of associative table.
5478 @xref{Escapes}, for details on parameter delimiting characters.
5480 Identifiers in @code{gtroff} can be any length, but, in some contexts,
5481 @code{gtroff} needs to be told where identifiers end and text begins
5482 (and in different ways depending on their length):
5488 @cindex @code{(}, starting a two-character identifier
5490 Two characters. Must be prefixed with @samp{(} in some situations.
5492 @cindex @code{[}, starting an identifier
5493 @cindex @code{]}, ending an identifier
5495 Arbitrary length (@code{gtroff} only). Must be bracketed with @samp{[}
5496 and@tie{}@samp{]} in some situations. Any length identifier can be put
5500 @cindex undefined identifiers
5501 @cindex identifiers, undefined
5502 Unlike many other programming languages, undefined identifiers are
5503 silently ignored or expanded to nothing. When @code{gtroff} finds an
5504 undefined identifier, it emits a warning, doing the following:
5508 If the identifier is a string, macro, or diversion, @code{gtroff}
5509 defines it as empty.
5512 If the identifier is a number register, @code{gtroff} defines it with a
5516 @xref{Warnings}., @ref{Interpolating Registers}, and @ref{Strings}.
5518 Note that macros, strings, and diversions share the same name space.
5535 As can be seen in the previous example, @code{gtroff} reuses the
5536 identifier @samp{xxx}, changing it from a macro to a diversion. No
5537 warning is emitted! The contents of the first macro definition is lost.
5539 @xref{Interpolating Registers}, and @ref{Strings}.
5542 @c =====================================================================
5544 @node Embedded Commands, Registers, Identifiers, gtroff Reference
5545 @section Embedded Commands
5546 @cindex embedded commands
5547 @cindex commands, embedded
5549 Most documents need more functionality beyond filling, adjusting and
5550 implicit line breaking. In order to gain further functionality,
5551 @code{gtroff} allows commands to be embedded into the text, in two ways.
5553 The first is a @dfn{request} that takes up an entire line, and does
5554 some large-scale operation (e.g.@: break lines, start new pages).
5556 The other is an @dfn{escape} that can be usually embedded anywhere in
5557 the text; most requests can accept it even as an argument. Escapes
5558 generally do more minor operations like sub- and superscripts, print a
5567 @c ---------------------------------------------------------------------
5569 @node Requests, Macros, Embedded Commands, Embedded Commands
5570 @subsection Requests
5573 @cindex control character (@code{.})
5574 @cindex character, control (@code{.})
5575 @cindex no-break control character (@code{'})
5576 @cindex character, no-break control (@code{'})
5577 @cindex control character, no-break (@code{'})
5578 A request line begins with a control character, which is either a single
5579 quote (@samp{'}, the @dfn{no-break control character}) or a period
5580 (@samp{.}, the normal @dfn{control character}). These can be changed;
5581 see @ref{Character Translations}, for details. After this there may be
5582 optional tabs or spaces followed by an identifier, which is the name of
5583 the request. This may be followed by any number of space-separated
5584 arguments (@emph{no} tabs here).
5586 @cindex structuring source code of documents or macro packages
5587 @cindex documents, structuring the source code
5588 @cindex macro packages, structuring the source code
5589 Since a control character followed by whitespace only is ignored, it is
5590 common practice to use this feature for structuring the source code of
5591 documents or macro packages.
5605 @cindex blank line macro (@code{blm})
5606 Another possibility is to use the blank line macro request @code{blm} by
5607 assigning an empty macro to it.
5612 .blm do-nothing \" activate blank line macro
5623 .blm \" deactivate blank line macro
5626 @xref{Blank Line Traps}.
5628 @cindex zero width space character (@code{\&})
5629 @cindex character, zero width space (@code{\&})
5630 @cindex space character, zero width (@code{\&})
5631 @cindex @code{\&}, escaping control characters
5632 To begin a line with a control character without it being interpreted,
5633 precede it with @code{\&}. This represents a zero width space, which
5634 means it does not affect the output.
5636 In most cases the period is used as a control character. Several
5637 requests cause a break implicitly; using the single quote control
5638 character prevents this.
5641 A read-only number register, which is set to@tie{}1 if a macro is called
5642 with the normal control character (as defined with the @code{cc}
5643 request), and set to@tie{}0 otherwise.
5645 @cindex modifying requests
5646 @cindex requests, modifying
5647 This allows reliable modification of requests.
5653 . ie \\n[.br] .bp*orig
5659 Using this register outside of a macro makes no sense (it always returns
5660 zero in such cases).
5662 If a macro is called as a string (that is, using @code{\*}), the value
5663 of the @code{.br} register is inherited from the caller.
5667 * Request and Macro Arguments::
5670 @node Request and Macro Arguments, , Requests, Requests
5671 @subsubsection Request and Macro Arguments
5672 @cindex request arguments
5673 @cindex macro arguments
5674 @cindex arguments to requests and macros
5676 @cindex tabs, and macro arguments
5677 @cindex macro arguments, and tabs
5678 @cindex arguments to macros, and tabs
5679 Arguments to requests and macros are processed much like the shell:
5680 The line is split into arguments according to
5681 spaces.@footnote{Plan@tie{}9's @code{troff} implementation also allows
5682 tabs for argument separation -- @code{gtroff} intentionally doesn't
5685 @cindex spaces, in a macro argument
5686 An argument to a macro that is intended to contain spaces can either be
5687 enclosed in double quotes, or have the spaces @dfn{escaped} with
5688 backslashes. This is @emph{not} true for requests.
5690 Here are a few examples for a hypothetical macro @code{uh}:
5693 .uh The Mouse Problem
5694 .uh "The Mouse Problem"
5695 .uh The\ Mouse\ Problem
5698 @cindex @code{\~}, difference to @code{\@key{SP}}
5699 @cindex @code{\@key{SP}}, difference to @code{\~}
5701 The first line is the @code{uh} macro being called with 3 arguments,
5702 @samp{The}, @samp{Mouse}, and @samp{Problem}. The latter two have the
5703 same effect of calling the @code{uh} macro with one argument, @samp{The
5704 Mouse Problem}.@footnote{The last solution, i.e., using escaped spaces,
5705 is ``classical'' in the sense that it can be found in most @code{troff}
5706 documents. Nevertheless, it is not optimal in all situations, since
5707 @w{@samp{\ }} inserts a fixed-width, non-breaking space character that
5708 can't stretch. @code{gtroff} provides a different command @code{\~} to
5709 insert a stretchable, non-breaking space.}
5711 @cindex @code{"}, in a macro argument
5712 @cindex double quote, in a macro argument
5713 A double quote that isn't preceded by a space doesn't start a macro
5714 argument. If not closing a string, it is printed literally.
5719 .xxx a" "b c" "de"fg"
5723 has the arguments @samp{a"}, @w{@samp{b c}}, @samp{de}, and @samp{fg"}.
5724 Don't rely on this obscure behaviour!
5726 There are two possibilities to get a double quote reliably.
5730 Enclose the whole argument with double quotes and use two consecutive
5731 double quotes to represent a single one. This traditional solution has
5732 the disadvantage that double quotes don't survive argument expansion
5733 again if called in compatibility mode (using the @option{-C} option of
5738 . tm xx: `\\$1' `\\$2' `\\$3'
5740 . yy "\\$1" "\\$2" "\\$3"
5743 . tm yy: `\\$1' `\\$2' `\\$3'
5745 .xx A "test with ""quotes""" .
5746 @result{} xx: `A' `test with "quotes"' `.'
5747 @result{} yy: `A' `test with ' `quotes""'
5751 If not in compatibility mode, you get the expected result
5754 xx: `A' `test with "quotes"' `.'
5755 yy: `A' `test with "quotes"' `.'
5759 since @code{gtroff} preserves the input level.
5762 Use the double quote glyph @code{\(dq}. This works with and without
5763 compatibility mode enabled since @code{gtroff} doesn't convert
5764 @code{\(dq} back to a double quote input character.
5766 Note that this method won't work with Unix @code{troff} in general since
5767 the glyph `dq' isn't defined normally.
5770 @cindex @code{ds} request, and double quotes
5771 Double quotes in the @code{ds} request are handled differently.
5772 @xref{Strings}, for more details.
5774 @c ---------------------------------------------------------------------
5776 @node Macros, Escapes, Requests, Embedded Commands
5780 @code{gtroff} has a @dfn{macro} facility for defining a series of lines
5781 that can be invoked by name. They are called in the same manner as
5782 requests -- arguments also may be passed basically in the same manner.
5784 @xref{Writing Macros}, and @ref{Request and Macro Arguments}.
5786 @c ---------------------------------------------------------------------
5788 @node Escapes, , Macros, Embedded Commands
5792 Escapes may occur anywhere in the input to @code{gtroff}. They usually
5793 begin with a backslash and are followed by a single character, which
5794 indicates the function to be performed. The escape character can be
5795 changed; see @ref{Character Translations}.
5797 Escape sequences that require an identifier as a parameter accept three
5798 possible syntax forms.
5802 The next single character is the identifier.
5804 @cindex @code{(}, starting a two-character identifier
5806 If this single character is an opening parenthesis, take the following
5807 two characters as the identifier. Note that there is no closing
5808 parenthesis after the identifier.
5810 @cindex @code{[}, starting an identifier
5811 @cindex @code{]}, ending an identifier
5813 If this single character is an opening bracket, take all characters
5814 until a closing bracket as the identifier.
5826 @cindex @code{'}, delimiting arguments
5827 @cindex argument delimiting characters
5828 @cindex characters, argument delimiting
5829 @cindex delimiting characters for arguments
5830 Other escapes may require several arguments and/or some special format.
5831 In such cases the argument is traditionally enclosed in single quotes
5832 (and quotes are always used in this manual for the definitions of escape
5833 sequences). The enclosed text is then processed according to what that
5834 escape expects. Example:
5840 @cindex @code{\o}, possible quote characters
5841 @cindex @code{\b}, possible quote characters
5842 @cindex @code{\X}, possible quote characters
5843 Note that the quote character can be replaced with any other character
5844 that does not occur in the argument (even a newline or a space
5845 character) in the following escapes: @code{\o}, @code{\b}, and
5846 @code{\X}. This makes e.g.
5855 @result{} A café in Paris
5859 possible, but it is better not to use this feature to avoid confusion.
5861 @cindex @code{\%}, used as delimiter
5862 @cindex @code{\@key{SP}}, used as delimiter
5863 @cindex @code{\|}, used as delimiter
5864 @cindex @code{\^}, used as delimiter
5865 @cindex @code{\@{}, used as delimiter
5866 @cindex @code{\@}}, used as delimiter
5867 @cindex @code{\'}, used as delimiter
5868 @cindex @code{\`}, used as delimiter
5869 @cindex @code{\-}, used as delimiter
5870 @cindex @code{\_}, used as delimiter
5871 @cindex @code{\!}, used as delimiter
5872 @cindex @code{\?}, used as delimiter
5873 @cindex @code{\)}, used as delimiter
5874 @cindex @code{\/}, used as delimiter
5875 @cindex @code{\,}, used as delimiter
5876 @cindex @code{\&}, used as delimiter
5878 @cindex @code{\:}, used as delimiter
5881 @cindex @code{\@r{<colon>}}, used as delimiter
5883 @cindex @code{\~}, used as delimiter
5884 @cindex @code{\0}, used as delimiter
5885 @cindex @code{\a}, used as delimiter
5886 @cindex @code{\c}, used as delimiter
5887 @cindex @code{\d}, used as delimiter
5888 @cindex @code{\e}, used as delimiter
5889 @cindex @code{\E}, used as delimiter
5890 @cindex @code{\p}, used as delimiter
5891 @cindex @code{\r}, used as delimiter
5892 @cindex @code{\t}, used as delimiter
5893 @cindex @code{\u}, used as delimiter
5894 The following escape sequences (which are handled similarly to
5895 characters since they don't take a parameter) are also allowed as
5896 delimiters: @code{\%}, @w{@samp{\ }}, @code{\|}, @code{\^}, @code{\@{},
5897 @code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
5898 @code{\?}, @code{\)}, @code{\/}, @code{\,}, @code{\&}, @code{\:},
5899 @code{\~}, @code{\0}, @code{\a}, @code{\c}, @code{\d}, @code{\e},
5900 @code{\E}, @code{\p}, @code{\r}, @code{\t}, and @code{\u}. Again, don't
5901 use these if possible.
5903 @cindex @code{\A}, allowed delimiters
5904 @cindex @code{\B}, allowed delimiters
5905 @cindex @code{\Z}, allowed delimiters
5906 @cindex @code{\C}, allowed delimiters
5907 @cindex @code{\w}, allowed delimiters
5908 No newline characters as delimiters are allowed in the following
5909 escapes: @code{\A}, @code{\B}, @code{\Z}, @code{\C}, and @code{\w}.
5911 @cindex @code{\D}, allowed delimiters
5912 @cindex @code{\h}, allowed delimiters
5913 @cindex @code{\H}, allowed delimiters
5914 @cindex @code{\l}, allowed delimiters
5915 @cindex @code{\L}, allowed delimiters
5916 @cindex @code{\N}, allowed delimiters
5917 @cindex @code{\R}, allowed delimiters
5918 @cindex @code{\s}, allowed delimiters
5919 @cindex @code{\S}, allowed delimiters
5920 @cindex @code{\v}, allowed delimiters
5921 @cindex @code{\x}, allowed delimiters
5922 Finally, the escapes @code{\D}, @code{\h}, @code{\H}, @code{\l},
5923 @code{\L}, @code{\N}, @code{\R}, @code{\s}, @code{\S}, @code{\v}, and
5924 @code{\x} can't use the following characters as delimiters:
5928 @cindex numbers, and delimiters
5929 @cindex digits, and delimiters
5930 The digits @code{0}-@code{9}.
5933 @cindex operators, as delimiters
5934 @cindex @code{+}, as delimiter
5935 @cindex @code{-}, as delimiter
5936 @cindex @code{/}, as delimiter
5937 @cindex @code{*}, as delimiter
5938 @cindex @code{%}, as delimiter
5939 @cindex @code{<}, as delimiter
5940 @cindex @code{>}, as delimiter
5941 @cindex @code{=}, as delimiter
5942 @cindex @code{&}, as delimiter
5944 @cindex @code{:}, as delimiter
5947 @cindex <colon>, as delimiter
5949 @cindex @code{(}, as delimiter
5950 @cindex @code{)}, as delimiter
5951 @cindex @code{.}, as delimiter
5952 The (single-character) operators @samp{+-/*%<>=&:().}.
5955 @cindex space character
5956 @cindex character, space
5957 @cindex tab character
5958 @cindex character, tab
5959 @cindex newline character
5960 @cindex character, newline
5961 The space, tab, and newline characters.
5964 @cindex @code{\%}, used as delimiter
5966 @cindex @code{\:}, used as delimiter
5969 @cindex @code{\@r{<colon>}}, used as delimiter
5971 @cindex @code{\@{}, used as delimiter
5972 @cindex @code{\@}}, used as delimiter
5973 @cindex @code{\'}, used as delimiter
5974 @cindex @code{\`}, used as delimiter
5975 @cindex @code{\-}, used as delimiter
5976 @cindex @code{\_}, used as delimiter
5977 @cindex @code{\!}, used as delimiter
5978 @cindex @code{\/}, used as delimiter
5979 @cindex @code{\c}, used as delimiter
5980 @cindex @code{\e}, used as delimiter
5981 @cindex @code{\p}, used as delimiter
5982 All escape sequences except @code{\%}, @code{\:}, @code{\@{},
5983 @code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
5984 @code{\/}, @code{\c}, @code{\e}, and @code{\p}.
5987 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
5988 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
5989 To have a backslash (actually, the current escape character) appear in
5990 the output several escapes are defined: @code{\\}, @code{\e} or
5991 @code{\E}. These are very similar, and only differ with respect to
5992 being used in macros or diversions. @xref{Character Translations}, for
5993 an exact description of those escapes.
5995 @xref{Implementation Differences}, @ref{Copy-in Mode}, and
5996 @ref{Diversions}, @ref{Identifiers}, for more information.
6002 @node Comments, , Escapes, Escapes
6003 @subsubsection Comments
6006 Probably one of the most@footnote{Unfortunately, this is a lie. But
6007 hopefully future @code{gtroff} hackers will believe it @code{:-)}}
6008 common forms of escapes is the comment.
6011 Start a comment. Everything to the end of the input line is ignored.
6013 This may sound simple, but it can be tricky to keep the comments from
6014 interfering with the appearance of the final output.
6016 @cindex @code{ds}, @code{ds1} requests, and comments
6017 @cindex @code{as}, @code{as1} requests, and comments
6018 If the escape is to the right of some text or a request, that portion of
6019 the line is ignored, but the space leading up to it is noticed by
6020 @code{gtroff}. This only affects the @code{ds} and @code{as} request
6023 @cindex tabs, before comments
6024 @cindex comments, lining up with tabs
6025 One possibly irritating idiosyncracy is that tabs must not be used to
6026 line up comments. Tabs are not treated as whitespace between the
6027 request and macro arguments.
6029 @cindex undefined request
6030 @cindex request, undefined
6031 A comment on a line by itself is treated as a blank line, because after
6032 eliminating the comment, that is all that remains:
6049 To avoid this, it is common to start the line with @code{.\"}, which
6050 causes the line to be treated as an undefined request and thus ignored
6053 @cindex @code{'}, as a comment
6054 Another commenting scheme seen sometimes is three consecutive single
6055 quotes (@code{'''}) at the beginning of a line. This works, but
6056 @code{gtroff} gives a warning about an undefined macro (namely
6057 @code{''}), which is harmless, but irritating.
6061 To avoid all this, @code{gtroff} has a new comment mechanism using the
6062 @code{\#} escape. This escape works the same as @code{\"} except that
6063 the newline is also ignored:
6082 @Defreq {ig, [@Var{end}]}
6083 Ignore all input until @code{gtroff} encounters the macro named
6084 @code{.}@var{end} on a line by itself (or @code{..} if @var{end} is not
6085 specified). This is useful for commenting out large blocks of text:
6090 This is part of a large block
6091 of text that has been
6092 temporarily(?) commented out.
6094 We can restore it simply by removing
6095 the .ig request and the ".." at the
6098 More text text text...
6105 text text text@dots{} More text text text@dots{}
6109 Note that the commented-out block of text does not cause a break.
6111 @cindex @code{ig} request, and copy-in mode
6112 @cindex copy-in mode, and @code{ig} request
6113 @cindex mode, copy-in, and @code{ig} request
6114 @cindex @code{ig} request, and auto-increment
6115 @cindex auto-increment, and @code{ig} request
6116 The input is read in copy-mode; auto-incremented registers @emph{are}
6117 affected (@pxref{Auto-increment}).
6121 @c =====================================================================
6123 @node Registers, Manipulating Filling and Adjusting, Embedded Commands, gtroff Reference
6127 Numeric variables in @code{gtroff} are called @dfn{registers}. There
6128 are a number of built-in registers, supplying anything from the date to
6129 details of formatting parameters.
6131 @xref{Identifiers}, for details on register identifiers.
6134 * Setting Registers::
6135 * Interpolating Registers::
6137 * Assigning Formats::
6138 * Built-in Registers::
6141 @c ---------------------------------------------------------------------
6143 @node Setting Registers, Interpolating Registers, Registers, Registers
6144 @subsection Setting Registers
6145 @cindex setting registers (@code{nr}, @code{\R})
6146 @cindex registers, setting (@code{nr}, @code{\R})
6148 Define or set registers using the @code{nr} request or the @code{\R}
6151 Although the following requests and escapes can be used to create
6152 registers, simply using an undefined register will cause it to be
6155 @DefreqList {nr, ident value}
6156 @DefescListEndx {\\R, ', ident value, '}
6157 Set number register @var{ident} to @var{value}. If @var{ident} doesn't
6158 exist, @code{gtroff} creates it.
6160 The argument to @code{\R} usually has to be enclosed in quotes.
6161 @xref{Escapes}, for details on parameter delimiting characters.
6163 The @code{\R} escape doesn't produce an input token in @code{gtroff};
6164 in other words, it vanishes completely after @code{gtroff} has
6167 For example, the following two lines are equivalent:
6170 .nr a (((17 + (3 * 4))) % 4)
6171 \R'a (((17 + (3 * 4))) % 4)'
6175 Note that the complete transparency of @code{\R} can cause surprising
6176 effects if you use number registers like @code{.k}, which get evaluated
6177 at the time they are accessed.
6182 aaa bbb ccc ddd eee fff ggg hhh\R':k \n[.k]'
6184 @result{} :k == 126950
6188 aaa bbb ccc ddd eee fff ggg hhh\h'0'\R':k \n[.k]'
6190 @result{} :k == 15000
6193 If you process this with the @sc{PostScript} device (@code{-Tps}),
6194 there will be a line break eventually after @code{ggg} in both input
6195 lines. However, after processing the space after @code{ggg}, the
6196 partially collected line is not overfull yet, so @code{troff}
6197 continues to collect input until it sees the space (or in this case,
6198 the newline) after @code{hhh}. At this point, the line is longer
6199 than the line length, and the line gets broken.
6201 In the first input line, since the @code{\R} escape leaves no traces,
6202 the check for the overfull line hasn't been done yet at the point where
6203 @code{\R} gets handled, and you get a value for the @code{.k} number
6204 register that is even greater than the current line length.
6206 In the second input line, the insertion of @code{\h'0'} to emit an
6207 invisible zero-width space forces @code{troff} to check the line length,
6208 which in turn causes the start of a new output line. Now @code{.k}
6209 returns the expected value.
6212 Both @code{nr} and @code{\R} have two additional special forms to
6213 increment or decrement a register.
6215 @DefreqList {nr, ident @t{+}@Var{value}}
6216 @DefreqItem {nr, ident @t{-}@Var{value}}
6217 @DefescItemx {\\R, ', ident @t{+}value, '}
6218 @DefescListEnd {\\R, ', ident @t{-}value, '}
6219 Increment (decrement) register @var{ident} by @var{value}.
6228 @cindex negating register values
6229 To assign the negated value of a register to another register, some care
6230 must be taken to get the desired result:
6244 The surrounding parentheses prevent the interpretation of the minus sign
6245 as a decrementing operator. An alternative is to start the assignment
6261 @cindex removing number register (@code{rr})
6262 @cindex number register, removing (@code{rr})
6263 @cindex register, removing (@code{rr})
6264 Remove number register @var{ident}. If @var{ident} doesn't exist, the
6268 @Defreq {rnn, ident1 ident2}
6269 @cindex renaming number register (@code{rnn})
6270 @cindex number register, renaming (@code{rnn})
6271 @cindex register, renaming (@code{rnn})
6272 Rename number register @var{ident1} to @var{ident2}. If either
6273 @var{ident1} or @var{ident2} doesn't exist, the request is ignored.
6276 @Defreq {aln, ident1 ident2}
6277 @cindex alias, number register, creating (@code{aln})
6278 @cindex creating alias, for number register (@code{aln})
6279 @cindex number register, creating alias (@code{aln})
6280 @cindex register, creating alias (@code{aln})
6281 Create an alias @var{ident1} for a number register @var{ident2}. The
6282 new name and the old name are exactly equivalent. If @var{ident1} is
6283 undefined, a warning of type @samp{reg} is generated, and the request is
6284 ignored. @xref{Debugging}, for information about warnings.
6287 @c ---------------------------------------------------------------------
6289 @node Interpolating Registers, Auto-increment, Setting Registers, Registers
6290 @subsection Interpolating Registers
6291 @cindex interpolating registers (@code{\n})
6292 @cindex registers, interpolating (@code{\n})
6294 Numeric registers can be accessed via the @code{\n} escape.
6296 @DefescList {\\n, , i, }
6297 @DefescItem {\\n, @Lparen{}, id, }
6298 @DefescListEnd {\\n, @Lbrack{}, ident, @Rbrack{}}
6299 @cindex nested assignments
6300 @cindex assignments, nested
6301 @cindex indirect assignments
6302 @cindex assignments, indirect
6303 Interpolate number register with name @var{ident} (one-character
6304 name@tie{}@var{i}, two-character name @var{id}). This means that the
6305 value of the register is expanded in-place while @code{gtroff} is
6306 parsing the input line. Nested assignments (also called indirect
6307 assignments) are possible.
6328 @c ---------------------------------------------------------------------
6330 @node Auto-increment, Assigning Formats, Interpolating Registers, Registers
6331 @subsection Auto-increment
6332 @cindex auto-increment
6333 @cindex increment, automatic
6335 Number registers can also be auto-incremented and auto-decremented. The
6336 increment or decrement value can be specified with a third argument to
6337 the @code{nr} request or @code{\R} escape.
6339 @Defreq {nr, ident value incr}
6340 @cindex @code{\R}, difference to @code{nr}
6341 Set number register @var{ident} to @var{value}; the increment for
6342 auto-incrementing is set to @var{incr}. Note that the @code{\R} escape
6343 doesn't support this notation.
6346 To activate auto-incrementing, the escape @code{\n} has a special syntax
6349 @DefescList {\\n, +, i, }
6350 @DefescItem {\\n, -, i, }
6351 @DefescItem {\\n, +@Lparen{}, id, }
6352 @DefescItem {\\n, -@Lparen{}, id, }
6353 @DefescItem {\\n, +@Lbrack{}, ident, @Rbrack{}}
6354 @DefescListEnd {\\n, -@Lbrack{}, ident, @Rbrack{}}
6355 Before interpolating, increment or decrement @var{ident} (one-character
6356 name@tie{}@var{i}, two-character name @var{id}) by the auto-increment
6357 value as specified with the @code{nr} request (or the @code{\R} escape).
6358 If no auto-increment value has been specified, these syntax forms are
6359 identical to @code{\n}.
6368 \n+a, \n+a, \n+a, \n+a, \n+a
6370 \n-(xx, \n-(xx, \n-(xx, \n-(xx, \n-(xx
6372 \n+[foo], \n+[foo], \n+[foo], \n+[foo], \n+[foo]
6380 -5, -10, -15, -20, -25
6384 @cindex increment value without changing the register
6385 @cindex value, incrementing without changing the register
6386 To change the increment value without changing the value of a register
6387 (@var{a} in the example), the following can be used:
6393 @c ---------------------------------------------------------------------
6395 @node Assigning Formats, Built-in Registers, Auto-increment, Registers
6396 @subsection Assigning Formats
6397 @cindex assigning formats (@code{af})
6398 @cindex formats, assigning (@code{af})
6400 When a register is used, it is always textually replaced (or
6401 interpolated) with a representation of that number. This output format
6402 can be changed to a variety of formats (numbers, Roman numerals, etc.).
6403 This is done using the @code{af} request.
6405 @Defreq {af, ident format}
6406 Change the output format of a number register. The first argument
6407 @var{ident} is the name of the number register to be changed, and the
6408 second argument @var{format} is the output format. The following output
6409 formats are available:
6413 Decimal arabic numbers. This is the default format: 0, 1, 2,
6417 Decimal numbers with as many digits as specified. So, @samp{00} would
6418 result in printing numbers as 01, 02, 03,@tie{}@enddots{}
6420 In fact, any digit instead of zero does work; @code{gtroff} only counts
6421 how many digits are specified. As a consequence, @code{af}'s default
6422 format @samp{1} could be specified as @samp{0} also (and exactly this is
6423 returned by the @code{\g} escape, see below).
6426 @cindex Roman numerals
6427 @cindex numerals, Roman
6428 Upper-case Roman numerals: 0, I, II, III, IV,@tie{}@enddots{}
6431 Lower-case Roman numerals: 0, i, ii, iii, iv,@tie{}@enddots{}
6434 Upper-case letters: 0, A, B, C, @dots{},@tie{}Z, AA, AB,@tie{}@enddots{}
6437 Lower-case letters: 0, a, b, c, @dots{},@tie{}z, aa, ab,@tie{}@enddots{}
6440 Omitting the number register format causes a warning of type
6441 @samp{missing}. @xref{Debugging}, for more details. Specifying a
6442 nonexistent format causes an error.
6444 The following example produces @samp{10, X, j, 010}:
6448 .af a 1 \" the default format
6458 @cindex Roman numerals, maximum and minimum
6459 @cindex maximum values of Roman numerals
6460 @cindex minimum values of Roman numerals
6461 The largest number representable for the @samp{i} and @samp{I} formats
6462 is 39999 (or @minus{}39999); Unix @code{troff} uses @samp{z} and
6463 @samp{w} to represent 10000 and 5000 in Roman numerals, and so does
6464 @code{gtroff}. Currently, the correct glyphs of Roman numeral five
6465 thousand and Roman numeral ten thousand (Unicode code points
6466 @code{U+2182} and @code{U+2181}, respectively) are not available.
6468 If @var{ident} doesn't exist, it is created.
6470 @cindex read-only register, changing format
6471 @cindex changing format, and read-only registers
6472 Changing the output format of a read-only register causes an error. It
6473 is necessary to first copy the register's value to a writeable register,
6474 then apply the @code{af} request to this other register.
6477 @DefescList {\\g, , i, }
6478 @DefescItem {\\g, @Lparen{}, id, }
6479 @DefescListEnd {\\g, @Lbrack{}, ident, @Rbrack{}}
6480 @cindex format of register (@code{\g})
6481 @cindex register, format (@code{\g})
6482 Return the current format of the specified register @var{ident}
6483 (one-character name@tie{}@var{i}, two-character name @var{id}). For
6484 example, @samp{\ga} after the previous example would produce the string
6485 @samp{000}. If the register hasn't been defined yet, nothing is
6489 @c ---------------------------------------------------------------------
6491 @node Built-in Registers, , Assigning Formats, Registers
6492 @subsection Built-in Registers
6493 @cindex built-in registers
6494 @cindex registers, built-in
6496 The following lists some built-in registers that are not described
6497 elsewhere in this manual. Any register that begins with a @samp{.} is
6498 read-only. A complete listing of all built-in registers can be found in
6499 @ref{Register Index}.
6503 @cindex current input file name register (@code{.F})
6504 @cindex input file name, current, register (@code{.F})
6506 This string-valued register returns the current input file name.
6509 @cindex horizontal resolution register (@code{.H})
6510 @cindex resolution, horizontal, register (@code{.H})
6512 Number of basic units per horizontal unit of output device resolution.
6513 @xref{Measurements}.
6516 @cindex number of registers register (@code{.R})
6517 @cindex registers, number of, register (@code{.R})
6519 The number of number registers available. This is always 10000 in
6520 GNU@tie{}@code{troff}; it exists for backward compatibility.
6526 @cindex mode, unsafe
6528 If @code{gtroff} is called with the @option{-U} command-line option to
6529 activate unsafe mode, the number register @code{.U} is set to@tie{}1,
6530 and to zero otherwise. @xref{Groff Options}.
6533 @cindex vertical resolution register (@code{.V})
6534 @cindex resolution, vertical, register (@code{.V})
6536 Number of basic units per vertical unit of output device resolution.
6537 @xref{Measurements}.
6540 @cindex seconds, current time (@code{seconds})
6541 @cindex time, current, seconds (@code{seconds})
6542 @cindex current time, seconds (@code{seconds})
6544 The number of seconds after the minute, normally in the range@tie{}0
6545 to@tie{}59, but can be up to@tie{}61 to allow for leap seconds.
6546 Initialized at start-up of @code{gtroff}.
6549 @cindex minutes, current time (@code{minutes})
6550 @cindex time, current, minutes (@code{minutes})
6551 @cindex current time, minutes (@code{minutes})
6553 The number of minutes after the hour, in the range@tie{}0 to@tie{}59.
6554 Initialized at start-up of @code{gtroff}.
6557 @cindex hours, current time (@code{hours})
6558 @cindex time, current, hours (@code{hours})
6559 @cindex current time, hours (@code{hours})
6561 The number of hours past midnight, in the range@tie{}0 to@tie{}23.
6562 Initialized at start-up of @code{gtroff}.
6565 @cindex day of the week register (@code{dw})
6566 @cindex date, day of the week register (@code{dw})
6568 Day of the week (1--7).
6571 @cindex day of the month register (@code{dy})
6572 @cindex date, day of the month register (@code{dy})
6574 Day of the month (1--31).
6577 @cindex month of the year register (@code{mo})
6578 @cindex date, month of the year register (@code{mo})
6580 Current month (1--12).
6583 @cindex date, year register (@code{year}, @code{yr})
6584 @cindex year, current, register (@code{year}, @code{yr})
6590 The current year minus@tie{}1900. Unfortunately, the documentation of
6591 Unix Version@tie{}7's @code{troff} had a year@tie{}2000 bug: It
6592 incorrectly claimed that @code{yr} contains the last two digits of the
6593 year. That claim has never been true of either @acronym{AT&T}
6594 @code{troff} or GNU @code{troff}. Old @code{troff} input that looks
6598 '\" The following line stopped working after 1999
6599 This document was formatted in 19\n(yr.
6603 can be corrected as follows:
6606 This document was formatted in \n[year].
6610 or, to be portable to older @code{troff} versions, as follows:
6614 This document was formatted in \n(y4.
6621 @cindex input line number register (@code{.c}, @code{c.})
6622 @cindex line number, input, register (@code{.c}, @code{c.})
6623 The current @emph{input} line number. Register @samp{.c} is read-only,
6624 whereas @samp{c.} (a @code{gtroff} extension) is writable also,
6625 affecting both @samp{.c} and @samp{c.}.
6629 @cindex output line number register (@code{ln})
6630 @cindex line number, output, register (@code{ln})
6631 The current @emph{output} line number after a call to the @code{nm}
6632 request to activate line numbering.
6634 @xref{Miscellaneous}, for more information about line numbering.
6638 @cindex major version number register (@code{.x})
6639 @cindex version number, major, register (@code{.x})
6640 The major version number. For example, if the version number is 1.03
6641 then @code{.x} contains@tie{}@samp{1}.
6645 @cindex minor version number register (@code{.y})
6646 @cindex version number, minor, register (@code{.y})
6647 The minor version number. For example, if the version number is 1.03
6648 then @code{.y} contains@tie{}@samp{03}.
6652 @cindex revision number register (@code{.Y})
6653 The revision number of @code{groff}.
6657 @cindex process ID of @code{gtroff} register (@code{$$})
6658 @cindex @code{gtroff}, process ID register (@code{$$})
6659 The process ID of @code{gtroff}.
6663 @cindex @code{gtroff}, identification register (@code{.g})
6664 @cindex GNU-specific register (@code{.g})
6665 Always@tie{}1. Macros should use this to determine whether they are
6666 running under GNU @code{troff}.
6670 @cindex @acronym{ASCII} approximation output register (@code{.A})
6671 If the command-line option @option{-a} is used to produce an
6672 @acronym{ASCII} approximation of the output, this is set to@tie{}1, zero
6673 otherwise. @xref{Groff Options}.
6677 This read-only register is set to the suppression nesting level (see
6678 escapes @code{\O}). @xref{Suppressing output}.
6682 This register is set to@tie{}1 (and to@tie{}0 otherwise) if the current
6683 page is actually being printed, i.e., if the @option{-o} option is being
6684 used to only print selected pages. @xref{Groff Options}, for more
6689 If @code{gtroff} is called with the @option{-T} command-line option, the
6690 number register @code{.T} is set to@tie{}1, and zero otherwise.
6691 @xref{Groff Options}.
6695 @cindex output device name string register (@code{.T})
6696 A single read-write string register that contains the current output
6697 device (for example, @samp{latin1} or @samp{ps}). This is the only
6698 string register defined by @code{gtroff}.
6702 @c =====================================================================
6704 @node Manipulating Filling and Adjusting, Manipulating Hyphenation, Registers, gtroff Reference
6705 @section Manipulating Filling and Adjusting
6706 @cindex manipulating filling and adjusting
6707 @cindex filling and adjusting, manipulating
6708 @cindex adjusting and filling, manipulating
6709 @cindex justifying text
6710 @cindex text, justifying
6714 @cindex @code{bp} request, causing implicit linebreak
6715 @cindex @code{ce} request, causing implicit linebreak
6716 @cindex @code{cf} request, causing implicit linebreak
6717 @cindex @code{fi} request, causing implicit linebreak
6718 @cindex @code{fl} request, causing implicit linebreak
6719 @cindex @code{in} request, causing implicit linebreak
6720 @cindex @code{nf} request, causing implicit linebreak
6721 @cindex @code{rj} request, causing implicit linebreak
6722 @cindex @code{sp} request, causing implicit linebreak
6723 @cindex @code{ti} request, causing implicit linebreak
6724 @cindex @code{trf} request, causing implicit linebreak
6725 Various ways of causing @dfn{breaks} were given in @ref{Implicit Line
6726 Breaks}. The @code{br} request likewise causes a break. Several other
6727 requests also cause breaks, but implicitly. These are @code{bp},
6728 @code{ce}, @code{cf}, @code{fi}, @code{fl}, @code{in}, @code{nf},
6729 @code{rj}, @code{sp}, @code{ti}, and @code{trf}.
6732 Break the current line, i.e., the input collected so far is emitted
6735 If the no-break control character is used, @code{gtroff} suppresses the
6746 Initially, @code{gtroff} fills and adjusts text to both margins.
6747 Filling can be disabled via the @code{nf} request and re-enabled with
6748 the @code{fi} request.
6751 @DefregListEndx {.u}
6752 @cindex fill mode (@code{fi})
6753 @cindex mode, fill (@code{fi})
6754 Activate fill mode (which is the default). This request implicitly
6755 enables adjusting; it also inserts a break in the text currently being
6756 filled. The read-only number register @code{.u} is set to@tie{}1.
6758 The fill mode status is associated with the current environment
6759 (@pxref{Environments}).
6761 See @ref{Line Control}, for interaction with the @code{\c} escape.
6765 @cindex no-fill mode (@code{nf})
6766 @cindex mode, no-fill (@code{nf})
6767 Activate no-fill mode. Input lines are output as-is, retaining line
6768 breaks and ignoring the current line length. This command implicitly
6769 disables adjusting; it also causes a break. The number register
6770 @code{.u} is set to@tie{}0.
6772 The fill mode status is associated with the current environment
6773 (@pxref{Environments}).
6775 See @ref{Line Control}, for interaction with the @code{\c} escape.
6778 @DefreqList {ad, [@Var{mode}]}
6779 @DefregListEndx {.j}
6782 Activation and deactivation of adjusting is done implicitly with calls
6783 to the @code{fi} or @code{nf} requests.
6785 @var{mode} can have one of the following values:
6789 @cindex ragged-right
6790 Adjust text to the left margin. This produces what is traditionally
6791 called ragged-right text.
6795 Adjust text to the right margin, producing ragged-left text.
6798 @cindex centered text
6799 @cindex @code{ce} request, difference to @samp{.ad@tie{}c}
6800 Center filled text. This is different to the @code{ce} request, which
6801 only centers text without filling.
6805 Justify to both margins. This is the default used by @code{gtroff}.
6808 Finally, @var{mode} can be the numeric argument returned by the
6811 Using @code{ad} without argument is the same as saying
6812 @w{@code{.ad \[.j]}}. In particular, @code{gtroff} adjusts lines
6813 in the same way it did before adjusting was deactivated (with a call
6814 to @code{na}, say). For example, this input code
6835 .AD \" back to centering
6837 .AD \n[ad] \" back to right justifying
6842 produces the following output:
6853 @cindex adjustment mode register (@code{.j})
6854 As just demonstrated, the current adjustment mode is available in the
6855 read-only number register @code{.j}; it can be stored and
6856 subsequently used to set adjustment.
6858 The adjustment mode status is associated with the current environment
6859 (@pxref{Environments}).
6863 Disable adjusting. This request won't change the current adjustment
6864 mode: A subsequent call to @code{ad} uses the previous adjustment
6867 The adjustment mode status is associated with the current environment
6868 (@pxref{Environments}).
6872 @DefescListEndx {\\p, , , }
6873 Break, adjusting the current line per the current adjustment mode.
6875 With @code{\p}, this break will happen at the next word boundary. The
6876 @code{\p} itself is removed entirely, adding neither a break nor a space
6877 where it appears in input; it can thus be placed in the middle of a word
6878 to cause a break at the end of that word.
6880 In most cases this produces very ugly results since @code{gtroff}
6881 doesn't have a sophisticated paragraph building algorithm (as @TeX{}
6882 has, for example); instead, @code{gtroff} fills and adjusts a paragraph
6886 This is an uninteresting sentence.
6887 This is an uninteresting sentence.\p
6888 This is an uninteresting sentence.
6895 This is an uninteresting sentence. This is an
6896 uninteresting sentence.
6897 This is an uninteresting sentence.
6901 @DefreqList {ss, word_space_size [@Var{sentence_space_size}]}
6903 @DefregListEndx {.sss}
6904 @cindex word space size register (@code{.ss})
6905 @cindex size of word space register (@code{.ss})
6906 @cindex space between words register (@code{.ss})
6907 @cindex sentence space size register (@code{.sss})
6908 @cindex size of sentence space register (@code{.sss})
6909 @cindex space between sentences register (@code{.sss})
6910 Change the size of a space between words. It takes its units as one
6911 twelfth of the space width parameter for the current font. Initially
6912 both the @var{word_space_size} and @var{sentence_space_size}
6913 are@tie{}12. In fill mode, the values specify the minimum distance.
6917 If two arguments are given to the @code{ss} request, the second argument
6918 sets the sentence space size. If the second argument is not given,
6919 sentence space size is set to @var{word_space_size}. The sentence space
6920 size is used in two circumstances: If the end of a sentence occurs at
6921 the end of a line in fill mode, then both an inter-word space and a
6922 sentence space are added; if two spaces follow the end of a sentence in
6923 the middle of a line, then the second space is a sentence space. If a
6924 second argument is never given to the @code{ss} request, the behaviour
6925 of Unix @code{troff} is the same as that exhibited by GNU @code{troff}.
6926 In GNU @code{troff}, as in Unix @code{troff}, a sentence should always
6927 be followed by either a newline or two spaces.
6929 The read-only number registers @code{.ss} and @code{.sss} hold the
6930 values of the parameters set by the first and second arguments of the
6933 The word space and sentence space values are associated with the current
6934 environment (@pxref{Environments}).
6936 Contrary to @acronym{AT&T} @code{troff}, this request is @emph{not}
6937 ignored if a TTY output device is used; the given values are then
6938 rounded down to a multiple of@tie{}12 (@pxref{Implementation
6941 The request is ignored if there is no parameter.
6943 @cindex discardable horizontal space
6944 @cindex space, discardable, horizontal
6945 @cindex horizontal discardable space
6946 Another useful application of the @code{ss} request is to insert
6947 discardable horizontal space, i.e., space that is discarded at a line
6948 break. For example, paragraph-style footnotes could be separated this
6953 1.\ This is the first footnote.\c
6957 2.\ This is the second footnote.
6964 1. This is the first footnote. 2. This
6965 is the second footnote.
6969 Note that the @code{\h} escape produces unbreakable space.
6972 @DefreqList {ce, [@Var{nnn}]}
6973 @DefregListEndx {.ce}
6974 @cindex centering lines (@code{ce})
6975 @cindex lines, centering (@code{ce})
6976 Center text. While the @w{@samp{.ad c}} request also centers text, it
6977 fills the text as well. @code{ce} does not fill the text it affects.
6978 This request causes a break. The number of lines still to be centered
6979 is associated with the current environment (@pxref{Environments}).
6981 The following example demonstrates the differences. Here is the input:
6986 This is a small text fragment that shows the differences
6987 between the `.ce' and the `.ad c' request.
6991 This is a small text fragment that shows the differences
6992 between the `.ce' and the `.ad c' request.
6996 And here the result:
6999 This is a small text fragment that
7000 shows the differences
7001 between the `.ce' and the `.ad c' request.
7003 This is a small text fragment that
7004 shows the differences between the `.ce'
7005 and the `.ad c' request.
7008 With no arguments, @code{ce} centers the next line of text. @var{nnn}
7009 specifies the number of lines to be centered. If the argument is zero
7010 or negative, centering is disabled.
7012 The basic length for centering text is the line length (as set with the
7013 @code{ll} request) minus the indentation (as set with the @code{in}
7014 request). Temporary indentation is ignored.
7016 As can be seen in the previous example, it is a common idiom to turn on
7017 centering for a large number of lines, and to turn off centering after
7018 text to be centered. This is useful for any request that takes a
7019 number of lines as an argument.
7021 The @code{.ce} read-only number register contains the number of lines
7022 remaining to be centered, as set by the @code{ce} request.
7025 @DefreqList {rj, [@Var{nnn}]}
7026 @DefregListEndx {.rj}
7027 @cindex justifying text (@code{rj})
7028 @cindex text, justifying (@code{rj})
7029 @cindex right-justifying (@code{rj})
7030 Justify unfilled text to the right margin. Arguments are identical to
7031 the @code{ce} request. The @code{.rj} read-only number register is the
7032 number of lines to be right-justified as set by the @code{rj} request.
7033 This request causes a break. The number of lines still to be
7034 right-justified is associated with the current environment
7035 (@pxref{Environments}).
7039 @c =====================================================================
7041 @node Manipulating Hyphenation, Manipulating Spacing, Manipulating Filling and Adjusting, gtroff Reference
7042 @section Manipulating Hyphenation
7043 @cindex manipulating hyphenation
7044 @cindex hyphenation, manipulating
7046 Here a description of requests that influence hyphenation.
7048 @DefreqList {hy, [@Var{mode}]}
7049 @DefregListEndx {.hy}
7050 Enable hyphenation. The request has an optional numeric argument,
7051 @var{mode}, to restrict hyphenation if necessary:
7055 The default argument if @var{mode} is omitted: hyphenation is enabled,
7056 and the first and the last characters of a word are not hyphenated.
7057 This is also the start-up value of @code{gtroff}.
7060 Do not hyphenate the last word on a page or column.
7063 Do not hyphenate the last two characters of a word.
7066 Do not hyphenate the first two characters of a word.
7069 Allow hyphenation before the last character of a word.
7072 Allow hyphenation after the first character of a word.
7075 The values in the previous table are additive. For example,
7076 value@tie{}12 causes @code{gtroff} to neither hyphenate the last two nor
7077 the first two characters of a word. Note that value@tie{}13 would do
7078 exactly the same; in other words, value@tie{}1 need not be added if the
7079 value is larger than@tie{}1.
7081 Some values cannot be used together because they contradict; for
7082 instance, values 4 and@tie{}16, and values 8 and@tie{}32.
7084 The number of characters at the beginning of a word after which the
7085 first hyphenation point should be inserted is determined by the patterns
7086 themselves; it can't be reduced further without introducing additional,
7087 invalid hyphenation points (unfortunately, this information is not part
7088 of a pattern file, you have to know it in advance). The same is true
7089 for the number of characters at the end of word before the last
7090 hyphenation point should be inserted. For example, the code
7108 instead of the correct `split-ting'. US-English patterns as distributed
7109 with groff need two characters at the beginning and three characters at
7110 the end; this means that value@tie{}4 of @code{hy} is mandatory.
7111 Value@tie{}8 is possible as an additional restriction, but values@tie{}1
7112 (the default!), 16, and@tie{}32 should be avoided.
7114 Here is a table of left and right minimum values for hyphenation as needed
7115 by the patterns distributed with groff; see the @cite{groff_tmac(5) man
7116 page} (type @command{man groff_tmac} at the command line) for more
7117 information on groff's language macro files.
7119 @multitable {German traditional} {pattern name} {left min} {right min}
7120 @headitem language @tab pattern name @tab left min @tab right min
7121 @item Czech @tab cs @tab 2 @tab 2
7122 @item US English @tab us @tab 2 @tab 3
7123 @item French @tab fr @tab 2 @tab 3
7124 @item German traditional @tab det @tab 2 @tab 2
7125 @item German reformed @tab den @tab 2 @tab 2
7126 @item Swedish @tab sv @tab 1 @tab 2
7129 Hyphenation exceptions within pattern files (i.e., the words within a
7130 @code{\hyphenation} group) also obey the hyphenation restrictions given
7131 by @code{hy}. However, exceptions specified with the @code{hw} do not.
7133 @cindex hyphenation restrictions register (@code{.hy})
7134 The current hyphenation restrictions can be found in the read-only
7135 number register @samp{.hy}.
7137 The hyphenation mode is associated with the current environment
7138 (@pxref{Environments}).
7142 Disable hyphenation (i.e., set the hyphenation mode to zero). Note that
7143 the hyphenation mode of the last call to @code{hy} is not remembered.
7145 The hyphenation mode is associated with the current environment
7146 (@pxref{Environments}).
7149 @DefreqList {hlm, [@Var{nnn}]}
7151 @DefregListEndx {.hlc}
7152 @cindex explicit hyphen (@code{\%})
7153 @cindex hyphen, explicit (@code{\%})
7154 @cindex consecutive hyphenated lines (@code{hlm})
7155 @cindex lines, consecutive hyphenated (@code{hlm})
7156 @cindex hyphenated lines, consecutive (@code{hlm})
7157 Set the maximum number of consecutive hyphenated lines to @var{nnn}. If
7158 this number is negative, there is no maximum. The default value
7159 is@tie{}@minus{}1 if @var{nnn} is omitted. This value is associated
7160 with the current environment (@pxref{Environments}). Only lines output
7161 from a given environment count towards the maximum associated with that
7162 environment. Hyphens resulting from @code{\%} are counted; explicit
7165 The current setting of @code{hlm} is available in the @code{.hlm}
7166 read-only number register. Also the number of immediately preceding
7167 consecutive hyphenated lines are available in the read-only number
7168 register @samp{.hlc}.
7171 @Defreq {hw, word1 word2 @dots{}}
7172 Define how @var{word1}, @var{word2}, etc.@: are to be hyphenated. The
7173 words must be given with hyphens at the hyphenation points. For
7181 Besides the space character, any character whose hyphenation code value
7182 is zero can be used to separate the arguments of @code{hw} (see the
7183 documentation for the @code{hcode} request below for more information).
7184 In addition, this request can be used more than once.
7186 @cindex @code{hw} request, and @code{hy} restrictions
7187 Hyphenation points specified with @code{hw} are not subject to the
7188 restrictions given by the @code{hy} request.
7190 Hyphenation exceptions specified with the @code{hw} request are
7191 associated with the current hyphenation language; it causes an error if
7192 there is no current hyphenation language.
7194 This request is ignored if there is no parameter.
7196 In old versions of @code{troff} there was a limited amount of space to
7197 store such information; fortunately, with @code{gtroff}, this is no
7198 longer a restriction.
7201 @DefescList {\\%, , , }
7202 @deffnx Escape @t{\:}
7207 @esindex \@r{<colon>}
7209 @cindex hyphenation character (@code{\%})
7210 @cindex character, hyphenation (@code{\%})
7211 @cindex disabling hyphenation (@code{\%})
7212 @cindex hyphenation, disabling (@code{\%})
7213 To tell @code{gtroff} how to hyphenate words on the fly, use the
7214 @code{\%} escape, also known as the @dfn{hyphenation character}.
7215 Preceding a word with this character prevents it from being
7216 hyphenated; putting it inside a word indicates to @code{gtroff} that
7217 the word may be hyphenated at that point. Note that this mechanism
7218 only affects that one occurrence of the word; to change the
7219 hyphenation of a word for the entire document, use the @code{hw}
7222 The @code{\:} escape inserts a zero-width break point (that is, the word
7223 breaks but without adding a hyphen).
7226 ... check the /var/log/\:httpd/\:access_log file ...
7229 @cindex @code{\X}, followed by @code{\%}
7230 @cindex @code{\Y}, followed by @code{\%}
7231 @cindex @code{\%}, following @code{\X} or @code{\Y}
7232 Note that @code{\X} and @code{\Y} start a word, that is, the @code{\%}
7233 escape in (say) @w{@samp{\X'...'\%foobar}} and
7234 @w{@samp{\Y'...'\%foobar}} no longer prevents hyphenation but inserts a
7235 hyphenation point at the beginning of @samp{foobar}; most likely this
7236 isn't what you want to do.
7239 @Defreq {hc, [@Var{char}]}
7240 Change the hyphenation character to @var{char}. This character then
7241 works the same as the @code{\%} escape, and thus, no longer appears in
7242 the output. Without an argument, @code{hc} resets the hyphenation
7243 character to be @code{\%} (the default) only.
7245 The hyphenation character is associated with the current environment
7246 (@pxref{Environments}).
7249 @DefreqList {hpf, pattern_file}
7250 @DefreqItemx {hpfa, pattern_file}
7251 @DefreqListEndx {hpfcode, a b [c d @dots{}]}
7252 @cindex hyphenation patterns (@code{hpf})
7253 @cindex patterns for hyphenation (@code{hpf})
7254 Read in a file of hyphenation patterns. This file is searched for in
7255 the same way as @file{@var{name}.tmac} (or @file{tmac.@var{name}}) is
7256 searched for if the @option{-m@var{name}} option is specified.
7258 It should have the same format as (simple) @TeX{} patterns files. More
7259 specifically, the following scanning rules are implemented.
7263 A percent sign starts a comment (up to the end of the line) even if
7264 preceded by a backslash.
7267 No support for `digraphs' like @code{\$}.
7270 @code{^^@var{xx}} (@var{x} is 0--9 or a--f) and @code{^^@var{x}}
7271 (character code of @var{x} in the range 0--127) are recognized; other use
7272 of @code{^} causes an error.
7278 @code{hpf} checks for the expression @code{\patterns@{@dots{}@}}
7279 (possibly with whitespace before and after the braces). Everything
7280 between the braces is taken as hyphenation patterns. Consequently,
7281 @code{@{} and @code{@}} are not allowed in patterns.
7284 Similarly, @code{\hyphenation@{@dots{}@}} gives a list of hyphenation
7288 @code{\endinput} is recognized also.
7291 For backwards compatibility, if @code{\patterns} is missing, the whole
7292 file is treated as a list of hyphenation patterns (only recognizing the
7293 @code{%} character as the start of a comment).
7296 If no @code{hpf} request is specified (either in the document or in a
7297 macro package), @code{gtroff} won't hyphenate at all.
7299 The @code{hpfa} request appends a file of patterns to the current list.
7301 The @code{hpfcode} request defines mapping values for character codes in
7302 hyphenation patterns. @code{hpf} or @code{hpfa} then apply the mapping
7303 (after reading the patterns) before replacing or appending them to the
7304 current list of patterns. Its arguments are pairs of character codes --
7305 integers from 0 to@tie{}255. The request maps character
7306 code@tie{}@var{a} to code@tie{}@var{b}, code@tie{}@var{c} to
7307 code@tie{}@var{d}, and so on. You can use character codes that would
7308 be invalid otherwise. By default, everything maps to itself except
7309 letters `A' to `Z', which map to `a' to `z'.
7316 The set of hyphenation patterns is associated with the current language
7317 set by the @code{hla} request. The @code{hpf} request is usually
7318 invoked by the @file{troffrc} or @file{troffrc-end} file; by default,
7319 @file{troffrc} loads hyphenation patterns and exceptions for American
7320 English (in files @file{hyphen.us} and @file{hyphenex.us}).
7322 A second call to @code{hpf} (for the same language) replaces the
7323 hyphenation patterns with the new ones.
7325 Invoking @code{hpf} causes an error if there is no current hyphenation
7329 @Defreq {hcode, c1 code1 [c2 code2 @dots{}]}
7330 @cindex hyphenation code (@code{hcode})
7331 @cindex code, hyphenation (@code{hcode})
7332 Set the hyphenation code of character @var{c1} to @var{code1}, that of
7333 @var{c2} to @var{code2}, etc. A hyphenation code must be a single input
7334 character (not a special character) other than a digit or a space.
7336 To make hyphenation work, hyphenation codes must be set up. At
7337 start-up, groff only assigns hyphenation codes to the letters
7338 @samp{a}--@samp{z} (mapped to themselves) and to the letters
7339 @samp{A}--@samp{Z} (mapped to @samp{a}--@samp{z}); all other hyphenation
7340 codes are set to zero. Normally, hyphenation patterns contain only
7341 lowercase letters, which should be applied regardless of case. In
7342 other words, the words `FOO' and `Foo' should be hyphenated exactly the
7343 same way as the word `foo' is hyphenated, and this is what @code{hcode}
7344 is good for. Words that contain other letters won't be hyphenated
7345 properly if the corresponding hyphenation patterns actually do contain
7346 them. For example, the following @code{hcode} requests are necessary to
7347 assign hyphenation codes to the letters @samp{ÄäÖöÜüß} (this is needed
7357 Without those assignments, groff treats German words like
7358 @w{`Kindergärten'} (the plural form of `kindergarten') as two substrings
7359 @w{`kinderg'} and @w{`rten'} because the hyphenation code of the
7360 umlaut@tie{}a is zero by default. There is a German hyphenation pattern
7361 that covers @w{`kinder'}, so groff finds the hyphenation `kin-der'.
7362 The other two hyphenation points (`kin-der-gär-ten') are missed.
7364 This request is ignored if it has no parameter.
7367 @DefreqList {hym, [@Var{length}]}
7368 @DefregListEndx {.hym}
7369 @cindex hyphenation margin (@code{hym})
7370 @cindex margin for hyphenation (@code{hym})
7371 @cindex @code{ad} request, and hyphenation margin
7372 Set the (right) hyphenation margin to @var{length}. If the current
7373 adjustment mode is not @samp{b} or @samp{n}, the line is not hyphenated
7374 if it is shorter than @var{length}. Without an argument, the
7375 hyphenation margin is reset to its default value, which is@tie{}0. The
7376 default scaling indicator for this request is @samp{m}. The hyphenation
7377 margin is associated with the current environment
7378 (@pxref{Environments}).
7380 A negative argument resets the hyphenation margin to zero, emitting a
7381 warning of type @samp{range}.
7383 @cindex hyphenation margin register (@code{.hym})
7384 The current hyphenation margin is available in the @code{.hym} read-only
7388 @DefreqList {hys, [@Var{hyphenation_space}]}
7389 @DefregListEndx {.hys}
7390 @cindex hyphenation space (@code{hys})
7391 @cindex @code{ad} request, and hyphenation space
7392 Set the hyphenation space to @var{hyphenation_space}. If the current
7393 adjustment mode is @samp{b} or @samp{n}, don't hyphenate the line if it
7394 can be justified by adding no more than @var{hyphenation_space} extra
7395 space to each word space. Without argument, the hyphenation space is
7396 set to its default value, which is@tie{}0. The default scaling
7397 indicator for this request is @samp{m}. The hyphenation space is
7398 associated with the current environment (@pxref{Environments}).
7400 A negative argument resets the hyphenation space to zero, emitting a
7401 warning of type @samp{range}.
7403 @cindex hyphenation space register (@code{.hys})
7404 The current hyphenation space is available in the @code{.hys} read-only
7408 @Defreq {shc, [@Var{glyph}]}
7409 @cindex soft hyphen character, setting (@code{shc})
7410 @cindex character, soft hyphen, setting (@code{shc})
7411 @cindex glyph, soft hyphen (@code{hy})
7412 @cindex soft hyphen glyph (@code{hy})
7413 @cindex @code{char} request, and soft hyphen character
7414 @cindex @code{tr} request, and soft hyphen character
7415 Set the @dfn{soft hyphen character} to @var{glyph}.@footnote{@dfn{Soft
7416 hyphen character} is a misnomer since it is an output glyph.} If the
7417 argument is omitted, the soft hyphen character is set to the default
7418 glyph @code{\(hy} (this is the start-up value of @code{gtroff} also).
7419 The soft hyphen character is the glyph that is inserted when a word is
7420 hyphenated at a line break. If the soft hyphen character does not exist
7421 in the font of the character immediately preceding a potential break
7422 point, then the line is not broken at that point. Neither definitions
7423 (specified with the @code{char} request) nor translations (specified
7424 with the @code{tr} request) are considered when finding the soft hyphen
7428 @DefreqList {hla, language}
7429 @DefregListEndx {.hla}
7430 @cindex @code{hpf} request, and hyphenation language
7431 @cindex @code{hw} request, and hyphenation language
7434 Set the current hyphenation language to the string @var{language}.
7435 Hyphenation exceptions specified with the @code{hw} request and
7436 hyphenation patterns specified with the @code{hpf} and @code{hpfa}
7437 requests are both associated with the current hyphenation language. The
7438 @code{hla} request is usually invoked by the @file{troffrc} or the
7439 @file{troffrc-end} files; @file{troffrc} sets the default language to
7442 @cindex hyphenation language register (@code{.hla})
7443 The current hyphenation language is available as a string in the
7444 read-only number register @samp{.hla}.
7447 .ds curr_language \n[.hla]
7454 @c =====================================================================
7456 @node Manipulating Spacing, Tabs and Fields, Manipulating Hyphenation, gtroff Reference
7457 @section Manipulating Spacing
7458 @cindex manipulating spacing
7459 @cindex spacing, manipulating
7461 @Defreq {sp, [@Var{distance}]}
7462 Space downwards @var{distance}. With no argument it advances
7463 1@tie{}line. A negative argument causes @code{gtroff} to move up the
7464 page the specified distance. If the argument is preceded by a @samp{|}
7465 then @code{gtroff} moves that distance from the top of the page. This
7466 request causes a line break, and that adds the current line spacing to
7467 the space you have just specified. The default scaling indicator is
7470 For convenience you may wish to use the following macros to set the
7471 height of the next line at a given distance from the top or the bottom
7480 . sp |\\n[.p]u-\\$1-\\n[.v]u
7485 A call to @samp{.y-from-bot-up 10c} means that the bottom of the next
7486 line will be at 10@tie{}cm from the paper edge at the bottom.
7488 If a vertical trap is sprung during execution of @code{sp}, the amount
7489 of vertical space after the trap is discarded. For example, this
7517 @cindex @code{sp} request, and traps
7518 @cindex discarded space in traps
7519 @cindex space, discarded, in traps
7520 @cindex traps, and discarded space
7521 The amount of discarded space is available in the number register
7524 To protect @code{sp} against vertical traps, use the @code{vpt} request:
7533 @DefreqList {ls, [@Var{nnn}]}
7534 @DefregListEndx {.L}
7535 @cindex double-spacing (@code{ls})
7536 Output @w{@var{nnn}@minus{}1} blank lines after each line of text. With
7537 no argument, @code{gtroff} uses the previous value before the last
7541 .ls 2 \" This causes double-spaced output
7542 .ls 3 \" This causes triple-spaced output
7543 .ls \" Again double-spaced
7546 The line spacing is associated with the current environment
7547 (@pxref{Environments}).
7549 @cindex line spacing register (@code{.L})
7550 The read-only number register @code{.L} contains the current line
7554 @xref{Changing Type Sizes}, for the requests @code{vs} and @code{pvs} as
7555 alternatives to @code{ls}.
7557 @DefescList {\\x, ', spacing, '}
7558 @DefregListEndx {.a}
7559 Sometimes, extra vertical spacing is only needed occasionally, e.g.@: to
7560 allow space for a tall construct (like an equation). The @code{\x}
7561 escape does this. The escape is given a numerical argument, usually
7562 enclosed in quotes (like @samp{\x'3p'}); the default scaling indicator
7563 is @samp{v}. If this number is positive extra vertical space is
7564 inserted below the current line. A negative number adds space above.
7565 If this escape is used multiple times on the same line, the maximum of
7568 @xref{Escapes}, for details on parameter delimiting characters.
7570 @cindex extra post-vertical line space register (@code{.a})
7571 The @code{.a} read-only number register contains the most recent
7572 (non-negative) extra vertical line space.
7574 Using @code{\x} can be necessary in combination with the @code{\b}
7575 escape, as the following example shows.
7578 This is a test with the \[rs]b escape.
7580 This is a test with the \[rs]b escape.
7582 This is a test with \b'xyz'\x'-1m'\x'1m'.
7584 This is a test with the \[rs]b escape.
7586 This is a test with the \[rs]b escape.
7593 This is a test with the \b escape.
7594 This is a test with the \b escape.
7596 This is a test with y.
7598 This is a test with the \b escape.
7599 This is a test with the \b escape.
7605 @DefregListEndx {.ns}
7606 @cindex @code{sp} request, and no-space mode
7607 @cindex no-space mode (@code{ns})
7608 @cindex mode, no-space (@code{ns})
7609 @cindex blank lines, disabling
7610 @cindex lines, blank, disabling
7611 Enable @dfn{no-space mode}. In this mode, spacing (either via @code{sp}
7612 or via blank lines) is disabled. The @code{bp} request to advance to
7613 the next page is also disabled, except if it is accompanied by a page
7614 number (see @ref{Page Control}, for more information). This mode ends
7615 when actual text is output or the @code{rs} request is encountered, which
7616 ends no-space mode. The read-only number register @code{.ns} is set
7617 to@tie{}1 as long as no-space mode is active.
7619 This request is useful for macros that conditionally insert vertical
7620 space before the text starts (for example, a paragraph macro could
7621 insert some space except when it is the first paragraph after a section
7626 @c =====================================================================
7628 @node Tabs and Fields, Character Translations, Manipulating Spacing, gtroff Reference
7629 @section Tabs and Fields
7630 @cindex tabs, and fields
7631 @cindex fields, and tabs
7633 @cindex @acronym{EBCDIC} encoding of a tab
7634 A tab character (@acronym{ASCII} char@tie{}9, @acronym{EBCDIC}
7635 char@tie{}5) causes a horizontal movement to the next tab stop (much
7636 like it did on a typewriter).
7639 @cindex tab character, non-interpreted (@code{\t})
7640 @cindex character, tab, non-interpreted (@code{\t})
7641 @cindex @code{\t}, and copy-in mode
7642 @cindex copy-in mode, and @code{\t}
7643 @cindex mode, copy-in, and @code{\t}
7644 This escape is a non-interpreted tab character. In copy mode
7645 (@pxref{Copy-in Mode}), @code{\t} is the same as a real tab character.
7648 @DefreqList {ta, [@Var{n1} @Var{n2} @dots{} @Var{nn} @t{T} @Var{r1} @Var{r2} @dots{} @Var{rn}]}
7649 @DefregListEndx {.tabs}
7650 Change tab stop positions. This request takes a series of tab
7651 specifiers as arguments (optionally divided into two groups with the
7652 letter @samp{T}) that indicate where each tab stop is to be (overriding
7653 any previous settings).
7655 Tab stops can be specified absolutely, i.e., as the distance from the
7656 left margin. For example, the following sets 6@tie{}tab stops every one
7660 .ta 1i 2i 3i 4i 5i 6i
7663 Tab stops can also be specified using a leading @samp{+}, which means
7664 that the specified tab stop is set relative to the previous tab stop.
7665 For example, the following is equivalent to the previous example.
7668 .ta 1i +1i +1i +1i +1i +1i
7671 @code{gtroff} supports an extended syntax to specify repeat values after
7672 the @samp{T} mark (these values are always taken as relative) -- this is
7673 the usual way to specify tabs set at equal intervals. The following is,
7674 yet again, the same as the previous examples. It does even more since
7675 it defines an infinite number of tab stops separated by one inch.
7681 Now we are ready to interpret the full syntax given at the beginning:
7682 Set tabs at positions @var{n1}, @var{n2}, @dots{}, @var{nn} and then set
7683 tabs at @var{nn}+@var{r1}, @var{nn}+@var{r2}, @dots{}, @var{nn}+@var{rn}
7684 and then at @var{nn}+@var{rn}+@var{r1}, @var{nn}+@var{rn}+@var{r2},
7685 @dots{}, @var{nn}+@var{rn}+@var{rn}, and so on.
7687 Example: @samp{4c +6c T 3c 5c 2c} is equivalent to @samp{4c 10c 13c 18c
7688 20c 23c 28c 30c @dots{}}.
7690 The material in each tab column (i.e., the column between two tab stops)
7691 may be justified to the right or left or centered in the column. This
7692 is specified by appending @samp{R}, @samp{L}, or @samp{C} to the tab
7693 specifier. The default justification is @samp{L}. Example:
7703 The default unit of the @code{ta} request is @samp{m}.
7706 A tab stop is converted into a non-breakable horizontal movement that
7707 can be neither stretched nor squeezed. For example,
7716 creates a single line, which is a bit longer than 10@tie{}inches (a
7717 string is used to show exactly where the tab characters are). Now
7718 consider the following:
7727 @code{gtroff} first converts the tab stops of the line into unbreakable
7728 horizontal movements, then splits the line after the second @samp{b}
7729 (assuming a sufficiently short line length). Usually, this isn't what
7733 Superfluous tabs (i.e., tab characters that do not correspond to a tab
7734 stop) are ignored except the first one, which delimits the characters
7735 belonging to the last tab stop for right-justifying or centering.
7736 Consider the following example
7740 .ds ZZ foo\tbar\tfoobar
7741 .ds ZZZ foo\tbar\tfoo\tbar
7752 which produces the following output:
7761 The first line right-justifies the second `foo' relative to the tab
7762 stop. The second line right-justifies `foobar'. The third line finally
7763 right-justifies only `foo' because of the additional tab character, which
7764 marks the end of the string belonging to the last defined tab stop.
7767 Tab stops are associated with the current environment
7768 (@pxref{Environments}).
7771 Calling @code{ta} without an argument removes all tab stops.
7774 @cindex tab stops, for TTY output devices
7775 The start-up value of @code{gtroff} is @w{@samp{T 0.5i}}.
7778 @cindex tab settings register (@code{.tabs})
7779 The read-only number register @code{.tabs} contains a string
7780 representation of the current tab settings suitable for use as an
7781 argument to the @code{ta} request.
7784 .ds tab-string \n[.tabs]
7789 @cindex @code{.S} register, Plan@tie{}9 alias for @code{.tabs}
7790 @cindex @code{.tabs} register, Plan@tie{}9 alias (@code{.S})
7791 The @code{troff} version of the Plan@tie{}9 operating system uses
7792 register @code{.S} for the same purpose.
7795 @Defreq {tc, [@Var{fill-glyph}]}
7796 @cindex tab repetition character (@code{tc})
7797 @cindex character, tab repetition (@code{tc})
7798 @cindex glyph, tab repetition (@code{tc})
7799 Normally @code{gtroff} fills the space to the next tab stop with
7800 whitespace. This can be changed with the @code{tc} request. With no
7801 argument @code{gtroff} reverts to using whitespace, which is the
7802 default. The value of this @dfn{tab repetition character} is associated
7803 with the current environment (@pxref{Environments}).@footnote{@dfn{Tab
7804 repetition character} is a misnomer since it is an output glyph.}
7807 @DefreqList {linetabs, n}
7808 @DefregListEndx {.linetabs}
7809 @cindex tab, line-tabs mode
7810 @cindex line-tabs mode
7811 @cindex mode, line-tabs
7812 If @var{n} is missing or not zero, enable @dfn{line-tabs} mode, or
7813 disable it otherwise (the default). In line-tabs mode, @code{gtroff}
7814 computes tab distances relative to the (current) output line instead of
7817 For example, the following code:
7830 in normal mode, results in the output
7837 in line-tabs mode, the same code outputs
7843 Line-tabs mode is associated with the current environment. The
7844 read-only register @code{.linetabs} is set to@tie{}1 if in line-tabs
7845 mode, and 0 in normal mode.
7853 @c ---------------------------------------------------------------------
7855 @node Leaders, Fields, Tabs and Fields, Tabs and Fields
7859 Sometimes it may be desirable to use the @code{tc} request to fill a
7860 particular tab stop with a given glyph (for example dots in a table of
7861 contents), but also normal tab stops on the rest of the line.
7862 For this @code{gtroff} provides an alternate tab mechanism, called
7863 @dfn{leaders}, which does just that.
7865 @cindex leader character
7866 A leader character (character code@tie{}1) behaves similarly to a tab
7867 character: It moves to the next tab stop. The only difference is that
7868 for this movement, the fill glyph defaults to a period character and not
7872 @cindex leader character, non-interpreted (@code{\a})
7873 @cindex character, leader, non-interpreted (@code{\a})
7874 @cindex @code{\a}, and copy-in mode
7875 @cindex copy-in mode, and @code{\a}
7876 @cindex mode, copy-in, and @code{\a}
7877 This escape is a non-interpreted leader character. In copy mode
7878 (@pxref{Copy-in Mode}), @code{\a} is the same as a real leader
7882 @Defreq {lc, [@Var{fill-glyph}]}
7883 @cindex leader repetition character (@code{lc})
7884 @cindex character, leader repetition (@code{lc})
7885 @cindex glyph, leader repetition (@code{lc})
7886 Declare the @dfn{leader repetition character}.@footnote{@dfn{Leader
7887 repetition character} is a misnomer since it is an output glyph.}
7888 Without an argument, leaders act the same as tabs (i.e., using
7889 whitespace for filling). @code{gtroff}'s start-up value is a dot
7890 (@samp{.}). The value of the leader repetition character is associated
7891 with the current environment (@pxref{Environments}).
7894 @cindex table of contents
7895 @cindex contents, table of
7896 For a table of contents, to name an example, tab stops may be defined so
7897 that the section number is one tab stop, the title is the second with
7898 the remaining space being filled with a line of dots, and then the page
7899 number slightly separated from the dots.
7902 .ds entry 1.1\tFoo\a\t12
7912 1.1 Foo.......................................... 12
7915 @c ---------------------------------------------------------------------
7917 @node Fields, , Leaders, Tabs and Fields
7921 @cindex field delimiting character (@code{fc})
7922 @cindex delimiting character, for fields (@code{fc})
7923 @cindex character, field delimiting (@code{fc})
7924 @cindex field padding character (@code{fc})
7925 @cindex padding character, for fields (@code{fc})
7926 @cindex character, field padding (@code{fc})
7927 @dfn{Fields} are a more general way of laying out tabular data. A field
7928 is defined as the data between a pair of @dfn{delimiting characters}.
7929 It contains substrings that are separated by @dfn{padding characters}.
7930 The width of a field is the distance on the @emph{input} line from the
7931 position where the field starts to the next tab stop. A padding
7932 character inserts stretchable space similar to @TeX{}'s @code{\hss}
7933 command (thus it can even be negative) to make the sum of all substring
7934 lengths plus the stretchable space equal to the field width. If more
7935 than one padding character is inserted, the available space is evenly
7936 distributed among them.
7938 @Defreq {fc, [@Var{delim-char} [@Var{padding-char}]]}
7939 Define a delimiting and a padding character for fields. If the latter
7940 is missing, the padding character defaults to a space character. If
7941 there is no argument at all, the field mechanism is disabled (which is
7942 the default). Note that contrary to e.g.@: the tab repetition
7943 character, delimiting and padding characters are @emph{not} associated
7944 to the current environment (@pxref{Environments}).
7957 and here the result:
7966 @c =====================================================================
7968 @node Character Translations, Troff and Nroff Mode, Tabs and Fields, gtroff Reference
7969 @section Character Translations
7970 @cindex character translations
7971 @cindex translations of characters
7973 @cindex control character, changing (@code{cc})
7974 @cindex character, control, changing (@code{cc})
7975 @cindex no-break control character, changing (@code{c2})
7976 @cindex character, no-break control, changing (@code{c2})
7977 @cindex control character, no-break, changing (@code{c2})
7978 The control character (@samp{.}) and the no-break control character
7979 (@samp{'}) can be changed with the @code{cc} and @code{c2} requests,
7982 @Defreq {cc, [@Var{c}]}
7983 Set the control character to@tie{}@var{c}. With no argument the default
7984 control character @samp{.} is restored. The value of the control
7985 character is associated with the current environment
7986 (@pxref{Environments}).
7989 @Defreq {c2, [@Var{c}]}
7990 Set the no-break control character to@tie{}@var{c}. With no argument
7991 the default control character @samp{'} is restored. The value of the
7992 no-break control character is associated with the current environment
7993 (@pxref{Environments}).
7999 @cindex disabling @code{\} (@code{eo})
8000 @cindex @code{\}, disabling (@code{eo})
8001 Disable the escape mechanism completely. After executing this request,
8002 the backslash character @samp{\} no longer starts an escape sequence.
8004 This request can be very helpful in writing macros since it is not
8005 necessary then to double the escape character. Here an example:
8008 .\" This is a simplified version of the
8009 .\" .BR request from the man macro package
8013 . while (\n[.$] >= 2) \@{\
8014 . as result \fB\$1\fR\$2
8017 . if \n[.$] .as result \fB\$1
8025 @Defreq {ec, [@Var{c}]}
8026 @cindex escape character, changing (@code{ec})
8027 @cindex character, escape, changing (@code{ec})
8028 Set the escape character to@tie{}@var{c}. With no argument the default
8029 escape character @samp{\} is restored. It can be also used to re-enable
8030 the escape mechanism after an @code{eo} request.
8032 Note that changing the escape character globally likely breaks macro
8033 packages since @code{gtroff} has no mechanism to `intern' macros, i.e.,
8034 to convert a macro definition into an internal form that is independent
8035 of its representation (@TeX{} has this mechanism). If a macro is
8036 called, it is executed literally.
8040 @DefreqListEndx {ecr, }
8041 The @code{ecs} request saves the current escape character in an internal
8042 register. Use this request in combination with the @code{ec} request to
8043 temporarily change the escape character.
8045 The @code{ecr} request restores the escape character saved with
8046 @code{ecs}. Without a previous call to @code{ecs}, this request sets
8047 the escape character to @code{\}.
8050 @DefescList {\\\\, , , }
8051 @DefescItemx {\\e, , , }
8052 @DefescListEndx {\\E, , , }
8053 Print the current escape character (which is the backslash character
8054 @samp{\} by default).
8056 @code{\\} is a `delayed' backslash; more precisely, it is the default
8057 escape character followed by a backslash, which no longer has special
8058 meaning due to the leading escape character. It is @emph{not} an escape
8059 sequence in the usual sense! In any unknown escape sequence
8060 @code{\@var{X}} the escape character is ignored and @var{X} is printed.
8061 But if @var{X} is equal to the current escape character, no warning is
8064 @cindex @code{\E}, and copy-in mode
8065 @cindex copy-in mode, and @code{\E}
8066 @cindex mode, copy-in, and @code{\E}
8067 As a consequence, only at top-level or in a diversion a backslash glyph
8068 is printed; in copy-in mode, it expands to a single backslash, which then
8069 combines with the following character to an escape sequence.
8071 The @code{\E} escape differs from @code{\e} by printing an escape
8072 character that is not interpreted in copy mode. Use this to define
8073 strings with escapes that work when used in copy mode (for example, as a
8074 macro argument). The following example defines strings to begin and end
8078 .ds @{ \v'-.3m'\s'\En[.s]*60/100'
8082 Another example to demonstrate the differences between the various
8083 escape sequences, using a strange escape character, @samp{-}.
8095 The result is surprising for most users, expecting @samp{1} since
8096 @samp{foo} is a valid identifier. What has happened? As mentioned
8097 above, the leading escape character makes the following character
8098 ordinary. Written with the default escape character the sequence
8099 @samp{--} becomes @samp{\-} -- this is the minus sign.
8101 If the escape character followed by itself is a valid escape sequence,
8102 only @code{\E} yields the expected result:
8115 Similar to @code{\\}, the sequence @code{\.} isn't a real escape
8116 sequence. As before, a warning message is suppressed if the escape
8117 character is followed by a dot, and the dot itself is printed.
8134 The first backslash is consumed while the macro is read, and the second
8135 is swallowed while executing macro @code{foo}.
8138 A @dfn{translation} is a mapping of an input character to an output
8139 glyph. The mapping occurs at output time, i.e., the input character
8140 gets assigned the metric information of the mapped output character
8141 right before input tokens are converted to nodes (@pxref{Gtroff
8142 Internals}, for more on this process).
8144 @DefreqList {tr, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
8145 @DefreqListEndx {trin, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
8146 Translate character @var{a} to glyph@tie{}@var{b}, character @var{c} to
8147 glyph@tie{}@var{d}, etc. If there is an odd number of arguments, the
8148 last one is translated to an unstretchable space (@w{@samp{\ }}).
8150 The @code{trin} request is identical to @code{tr}, but when you unformat
8151 a diversion with @code{asciify} it ignores the translation.
8152 @xref{Diversions}, for details about the @code{asciify} request.
8158 @cindex @code{\(}, and translations
8159 @cindex @code{\[}, and translations
8160 @cindex @code{\'}, and translations
8161 @cindex @code{\`}, and translations
8162 @cindex @code{\-}, and translations
8163 @cindex @code{\_}, and translations
8164 @cindex @code{\C}, and translations
8165 @cindex @code{\N}, and translations
8166 @cindex @code{char} request, and translations
8167 @cindex special characters
8168 @cindex character, special
8169 @cindex numbered glyph (@code{\N})
8170 @cindex glyph, numbered (@code{\N})
8171 Special characters (@code{\(@var{xx}}, @code{\[@var{xxx}]},
8172 @code{\C'@var{xxx}'}, @code{\'}, @code{\`}, @code{\-}, @code{\_}),
8173 glyphs defined with the @code{char} request, and numbered glyphs
8174 (@code{\N'@var{xxx}'}) can be translated also.
8177 @cindex @code{\e}, and translations
8178 The @code{\e} escape can be translated also.
8181 @cindex @code{\%}, and translations
8182 @cindex @code{\~}, and translations
8183 Characters can be mapped onto the @code{\%} and @code{\~} escapes (but
8184 @code{\%} and @code{\~} can't be mapped onto another glyph).
8187 @cindex backspace character, and translations
8188 @cindex character, backspace, and translations
8189 @cindex leader character, and translations
8190 @cindex character, leader, and translations
8191 @cindex newline character, and translations
8192 @cindex character, newline, and translations
8193 @cindex tab character, and translations
8194 @cindex character, tab, and translations
8195 @cindex @code{\a}, and translations
8196 @cindex @code{\t}, and translations
8197 The following characters can't be translated: space (with one exception,
8198 see below), backspace, newline, leader (and @code{\a}), tab (and
8202 @cindex @code{shc} request, and translations
8203 Translations are not considered for finding the soft hyphen character
8204 set with the @code{shc} request.
8207 @cindex @code{\&}, and translations
8208 The pair @samp{@var{c}\&} (this is an arbitrary character@tie{}@var{c}
8209 followed by the zero width space character) maps this character to
8219 It is even possible to map the space character to nothing:
8228 As shown in the example, the space character can't be the first
8229 character/glyph pair as an argument of @code{tr}. Additionally, it is
8230 not possible to map the space character to any other glyph; requests
8231 like @w{@samp{.tr aa x}} undo @w{@samp{.tr aa \&}} instead.
8233 If justification is active, lines are justified in spite of the `empty'
8234 space character (but there is no minimal distance, i.e.@: the space
8235 character, between words).
8238 After an output glyph has been constructed (this happens at the moment
8239 immediately before the glyph is appended to an output glyph list, either
8240 by direct output, in a macro, diversion, or string), it is no longer
8241 affected by @code{tr}.
8244 Translating character to glyphs where one of them or both are undefined
8245 is possible also; @code{tr} does not check whether the entities in its
8248 @xref{Gtroff Internals}.
8251 @code{troff} no longer has a hard-coded dependency on @w{Latin-1}; all
8252 @code{char@var{XXX}} entities have been removed from the font
8253 description files. This has a notable consequence that shows up in
8254 warnings like @code{can't find character with input code @var{XXX}} if
8255 the @code{tr} request isn't handled properly.
8257 Consider the following translation:
8264 This maps input character @code{é} onto glyph @code{É}, which is
8265 identical to glyph @code{char201}. But this glyph intentionally doesn't
8266 exist! Instead, @code{\[char201]} is treated as an input character
8267 entity and is by default mapped onto @code{\['E]}, and @code{gtroff}
8268 doesn't handle translations of translations.
8270 The right way to write the above translation is
8277 In other words, the first argument of @code{tr} should be an input
8278 character or entity, and the second one a glyph entity.
8281 Without an argument, the @code{tr} request is ignored.
8285 @Defreq {trnt, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
8286 @cindex @code{\!}, and @code{trnt}
8287 @code{trnt} is the same as the @code{tr} request except that the
8288 translations do not apply to text that is transparently throughput into
8289 a diversion with @code{\!}. @xref{Diversions}, for more information.
8302 prints @samp{b} to the standard error stream; if @code{trnt} is used
8303 instead of @code{tr} it prints @samp{a}.
8307 @c =====================================================================
8309 @node Troff and Nroff Mode, Line Layout, Character Translations, gtroff Reference
8310 @section Troff and Nroff Mode
8316 Originally, @code{nroff} and @code{troff} were two separate programs,
8317 the former for TTY output, the latter for everything else. With GNU
8318 @code{troff}, both programs are merged into one executable, sending its
8319 output to a device driver (@code{grotty} for TTY devices, @code{grops}
8320 for @sc{PostScript}, etc.)@: which interprets the intermediate output of
8321 @code{gtroff}. For Unix @code{troff} it makes sense to talk about
8322 @dfn{Nroff mode} and @dfn{Troff mode} since the differences are
8323 hardcoded. For GNU @code{troff}, this distinction is not appropriate
8324 because @code{gtroff} simply takes the information given in the font
8325 files for a particular device without handling requests specially if a
8326 TTY output device is used.
8328 Usually, a macro package can be used with all output devices.
8329 Nevertheless, it is sometimes necessary to make a distinction between
8330 TTY and non-TTY devices: @code{gtroff} provides two built-in conditions
8331 @samp{n} and @samp{t} for the @code{if}, @code{ie}, and @code{while}
8332 requests to decide whether @code{gtroff} shall behave like @code{nroff}
8333 or like @code{troff}.
8338 Make the @samp{t} built-in condition true (and the @samp{n} built-in
8339 condition false) for @code{if}, @code{ie}, and @code{while} conditional
8340 requests. This is the default if @code{gtroff} (@emph{not}
8341 @code{groff}) is started with the @option{-R} switch to avoid loading of
8342 the start-up files @file{troffrc} and @file{troffrc-end}. Without
8343 @option{-R}, @code{gtroff} stays in troff mode if the output device is
8344 not a TTY (e.g.@: `ps').
8349 Make the @samp{n} built-in condition true (and the @samp{t} built-in
8350 condition false) for @code{if}, @code{ie}, and @code{while} conditional
8351 requests. This is the default if @code{gtroff} uses a TTY output
8352 device; the code for switching to nroff mode is in the file
8353 @file{tty.tmac}, which is loaded by the start-up file @code{troffrc}.
8356 @xref{Conditionals and Loops}, for more details on built-in conditions.
8359 @c =====================================================================
8361 @node Line Layout, Line Control, Troff and Nroff Mode, gtroff Reference
8362 @section Line Layout
8364 @cindex layout, line
8366 @cindex dimensions, line
8367 @cindex line dimensions
8368 The following drawing shows the dimensions that @code{gtroff} uses for
8369 placing a line of output onto the page. They are labeled with the
8370 request that manipulates each dimension.
8374 |<-----------ll------------>|
8375 +----+----+----------------------+----+
8377 +----+----+----------------------+----+
8379 |<--------paper width---------------->|
8383 These dimensions are:
8387 @cindex left margin (@code{po})
8388 @cindex margin, left (@code{po})
8389 @cindex page offset (@code{po})
8390 @cindex offset, page (@code{po})
8391 @dfn{Page offset} -- this is the leftmost position of text on the final
8392 output, defining the @dfn{left margin}.
8395 @cindex indentation (@code{in})
8396 @cindex line indentation (@code{in})
8397 @dfn{Indentation} -- this is the distance from the left margin where
8401 @cindex line length (@code{ll})
8402 @cindex length of line (@code{ll})
8403 @dfn{Line length} -- this is the distance from the left margin to right
8407 A simple demonstration:
8411 This is text without indentation.
8412 The line length has been set to 3\~inch.
8415 Now the left and right margins are both increased.
8418 Calling .in and .ll without parameters restore
8419 the previous values.
8425 This is text without indenta-
8426 tion. The line length has
8431 Calling .in and .ll without
8432 parameters restore the previ-
8436 @DefreqList {po, [@Var{offset}]}
8437 @DefreqItem {po, @t{+}@Var{offset}}
8438 @DefreqItem {po, @t{-}@Var{offset}}
8439 @DefregListEndx {.o}
8441 Set horizontal page offset to @var{offset} (or increment or decrement
8442 the current value by @var{offset}). Note that this request does not
8443 cause a break, so changing the page offset in the middle of text being
8444 filled may not yield the expected result. The initial value is
8445 1@dmn{i}. For TTY output devices, it is set to 0 in the startup file
8446 @file{troffrc}; the default scaling indicator is @samp{m} (and not
8447 @samp{v} as incorrectly documented in the original Unix troff manual).
8449 The current page offset can be found in the read-only number register
8452 If @code{po} is called without an argument, the page offset is reset to
8453 the previous value before the last call to @code{po}.
8468 @DefreqList {in, [@Var{indent}]}
8469 @DefreqItem {in, @t{+}@Var{indent}}
8470 @DefreqItem {in, @t{-}@Var{indent}}
8471 @DefregListEndx {.i}
8472 Set indentation to @var{indent} (or increment or decrement the current
8473 value by @var{indent}). This request causes a break. Initially, there
8476 If @code{in} is called without an argument, the indentation is reset to
8477 the previous value before the last call to @code{in}. The default
8478 scaling indicator is @samp{m}.
8480 The indentation is associated with the current environment
8481 (@pxref{Environments}).
8483 If a negative indentation value is specified (which is not allowed),
8484 @code{gtroff} emits a warning of type @samp{range} and sets the
8485 indentation to zero.
8487 The effect of @code{in} is delayed until a partially collected line (if
8488 it exists) is output. A temporary indentation value is reset to zero
8491 The current indentation (as set by @code{in}) can be found in the
8492 read-only number register @samp{.i}.
8495 @DefreqList {ti, offset}
8496 @DefreqItem {ti, @t{+}@Var{offset}}
8497 @DefreqItem {ti, @t{-}@Var{offset}}
8498 @DefregListEndx {.in}
8499 Temporarily indent the next output line by @var{offset}. If an
8500 increment or decrement value is specified, adjust the temporary
8501 indentation relative to the value set by the @code{in} request.
8503 This request causes a break; its value is associated with the current
8504 environment (@pxref{Environments}). The default scaling indicator is
8505 @samp{m}. A call of @code{ti} without an argument is ignored.
8507 If the total indentation value is negative (which is not allowed),
8508 @code{gtroff} emits a warning of type @samp{range} and sets the
8509 temporary indentation to zero. `Total indentation' is either
8510 @var{offset} if specified as an absolute value, or the temporary plus
8511 normal indentation, if @var{offset} is given as a relative value.
8513 The effect of @code{ti} is delayed until a partially collected line (if
8514 it exists) is output.
8516 The read-only number register @code{.in} is the indentation that applies
8517 to the current output line.
8519 The difference between @code{.i} and @code{.in} is that the latter takes
8520 into account whether a partially collected line still uses the old
8521 indentation value or a temporary indentation value is active.
8524 @DefreqList {ll, [@Var{length}]}
8525 @DefreqItem {ll, @t{+}@Var{length}}
8526 @DefreqItem {ll, @t{-}@Var{length}}
8528 @DefregListEndx {.ll}
8529 Set the line length to @var{length} (or increment or decrement the
8530 current value by @var{length}). Initially, the line length is set to
8531 6.5@dmn{i}. The effect of @code{ll} is delayed until a partially
8532 collected line (if it exists) is output. The default scaling indicator
8535 If @code{ll} is called without an argument, the line length is reset to
8536 the previous value before the last call to @code{ll}. If a negative
8537 line length is specified (which is not allowed), @code{gtroff} emits a
8538 warning of type @samp{range} and sets the line length to zero.
8540 The line length is associated with the current environment
8541 (@pxref{Environments}).
8543 @cindex line length register (@code{.l})
8544 The current line length (as set by @code{ll}) can be found in the
8545 read-only number register @samp{.l}. The read-only number register
8546 @code{.ll} is the line length that applies to the current output line.
8548 Similar to @code{.i} and @code{.in}, the difference between @code{.l}
8549 and @code{.ll} is that the latter takes into account whether a partially
8550 collected line still uses the old line length value.
8554 @c =====================================================================
8556 @node Line Control, Page Layout, Line Layout, gtroff Reference
8557 @section Line Control
8558 @cindex line control
8559 @cindex control, line
8561 It is important to understand how @code{gtroff} handles input and output
8564 Many escapes use positioning relative to the input line. For example,
8568 This is a \h'|1.2i'test.
8583 The main usage of this feature is to define macros that act exactly at
8584 the place where called.
8587 .\" A simple macro to underline a word
8589 . nop \\$1\l'|0\[ul]'
8594 In the above example, @samp{|0} specifies a negative distance from the
8595 current position (at the end of the just emitted argument @code{\$1})
8596 back to the beginning of the input line. Thus, the @samp{\l} escape
8597 draws a line from right to left.
8599 @cindex input line continuation (@code{\})
8600 @cindex line, input, continuation (@code{\})
8601 @cindex continuation, input line (@code{\})
8602 @cindex output line, continuation (@code{\c})
8603 @cindex line, output, continuation (@code{\c})
8604 @cindex continuation, output line (@code{\c})
8605 @cindex interrupted line
8606 @cindex line, interrupted
8607 @code{gtroff} makes a difference between input and output line
8608 continuation; the latter is also called @dfn{interrupting} a line.
8610 @DefescList {\\@key{RET}, , ,}
8611 @DefescItemx {\\c, , ,}
8612 @DefregListEndx {.int}
8613 Continue a line. @code{\@key{RET}} (this is a backslash at the end of a
8614 line immediately followed by a newline) works on the input level,
8615 suppressing the effects of the following newline in the input.
8620 @result{} This is a .test
8623 The @samp{|} operator is also affected.
8625 @cindex @code{\R}, after @code{\c}
8626 @code{\c} works on the output level. Anything after this escape on the
8627 same line is ignored except @code{\R}, which works as usual. Anything
8628 before @code{\c} on the same line is appended to the current partial
8629 output line. The next non-command line after an interrupted line counts
8630 as a new input line.
8632 The visual results depend on whether no-fill mode is active.
8636 @cindex @code{\c}, and no-fill mode
8637 @cindex no-fill mode, and @code{\c}
8638 @cindex mode, no-fill, and @code{\c}
8639 If no-fill mode is active (using the @code{nf} request), the next input
8640 text line after @code{\c} is handled as a continuation of the same input
8647 @result{} This is a test.
8651 @cindex @code{\c}, and fill mode
8652 @cindex fill mode, and @code{\c}
8653 @cindex mode, fill, and @code{\c}
8654 If fill mode is active (using the @code{fi} request), a word interrupted
8655 with @code{\c} is continued with the text on the next input text line,
8656 without an intervening space.
8661 @result{} This is a test.
8665 Note that an intervening control line that causes a break is stronger
8666 than @code{\c}, flushing out the current partial line in the usual way.
8668 @cindex interrupted line register (@code{.int})
8669 The @code{.int} register contains a positive value if the last output
8670 line was interrupted with @code{\c}; this is associated with the current
8671 environment (@pxref{Environments}).
8675 @c =====================================================================
8677 @node Page Layout, Page Control, Line Control, gtroff Reference
8678 @section Page Layout
8680 @cindex layout, page
8682 @code{gtroff} provides some very primitive operations for controlling
8685 @DefreqList {pl, [@Var{length}]}
8686 @DefreqItem {pl, @t{+}@Var{length}}
8687 @DefreqItem {pl, @t{-}@Var{length}}
8688 @DefregListEndx {.p}
8689 @cindex page length (@code{pl})
8690 @cindex length of page (@code{pl})
8691 Set the @dfn{page length} to @var{length} (or increment or decrement the
8692 current value by @var{length}). This is the length of the physical
8693 output page. The default scaling indicator is @samp{v}.
8695 @cindex page length register (@code{.p})
8696 The current setting can be found in the read-only number register
8701 @cindex bottom margin
8702 @cindex margin, bottom
8703 Note that this only specifies the size of the page, not the top and
8704 bottom margins. Those are not set by @code{gtroff} directly.
8705 @xref{Traps}, for further information on how to do this.
8707 Negative @code{pl} values are possible also, but not very useful: No
8708 trap is sprung, and each line is output on a single page (thus
8709 suppressing all vertical spacing).
8711 If no argument or an invalid argument is given, @code{pl} sets the page
8712 length to 11@dmn{i}.
8718 @code{gtroff} provides several operations that help in setting up top
8719 and bottom titles (or headers and footers).
8721 @Defreq {tl, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}}
8722 @cindex title line (@code{tl})
8723 @cindex three-part title (@code{tl})
8724 @cindex page number character (@code{%})
8725 Print a @dfn{title line}. It consists of three parts: a left justified
8726 portion, a centered portion, and a right justified portion. The
8727 argument separator @samp{'} can be replaced with any character not
8728 occurring in the title line. The @samp{%} character is replaced with
8729 the current page number. This character can be changed with the
8730 @code{pc} request (see below).
8732 Without argument, @code{tl} is ignored.
8738 The line length set by the @code{ll} request is not honoured by
8739 @code{tl}; use the @code{lt} request (described below) instead, to
8740 control line length for text set by @code{tl}.
8743 A title line is not restricted to the top or bottom of a page.
8746 @code{tl} prints the title line immediately, ignoring a partially filled
8747 line (which stays untouched).
8750 It is not an error to omit closing delimiters. For example,
8751 @w{@samp{.tl /foo}} is equivalent to @w{@samp{.tl /foo///}}: It prints a
8752 title line with the left justified word @samp{foo}; the centered and
8753 right justified parts are empty.
8756 @code{tl} accepts the same parameter delimiting characters as the
8757 @code{\A} escape; see @ref{Escapes}.
8761 @DefreqList {lt, [@Var{length}]}
8762 @DefreqItem {lt, @t{+}@Var{length}}
8763 @DefreqItem {lt, @t{-}@Var{length}}
8764 @DefregListEndx {.lt}
8765 @cindex length of title line (@code{lt})
8766 @cindex title line, length (@code{lt})
8767 @cindex title line length register (@code{.lt})
8768 The title line is printed using its own line length, which is specified
8769 (or incremented or decremented) with the @code{lt} request. Initially,
8770 the title line length is set to 6.5@dmn{i}. If a negative line length
8771 is specified (which is not allowed), @code{gtroff} emits a warning of
8772 type @samp{range} and sets the title line length to zero. The default
8773 scaling indicator is @samp{m}. If @code{lt} is called without an
8774 argument, the title length is reset to the previous value before the
8775 last call to @code{lt}.
8777 The current setting of this is available in the @code{.lt} read-only
8778 number register; it is associated with the current environment
8779 (@pxref{Environments}).
8782 @DefreqList {pn, page}
8783 @DefreqItem {pn, @t{+}@Var{page}}
8784 @DefreqItem {pn, @t{-}@Var{page}}
8785 @DefregListEndx {.pn}
8786 @cindex page number (@code{pn})
8787 @cindex number, page (@code{pn})
8788 Change (increase or decrease) the page number of the @emph{next} page.
8789 The only argument is the page number; the request is ignored without a
8792 The read-only number register @code{.pn} contains the number of the next
8793 page: either the value set by a @code{pn} request, or the number of the
8794 current page plus@tie{}1.
8797 @Defreq {pc, [@Var{char}]}
8798 @cindex changing the page number character (@code{pc})
8799 @cindex page number character, changing (@code{pc})
8801 Change the page number character (used by the @code{tl} request) to a
8802 different character. With no argument, this mechanism is disabled.
8803 Note that this doesn't affect the number register@tie{}@code{%}.
8809 @c =====================================================================
8811 @node Page Control, Fonts and Symbols, Page Layout, gtroff Reference
8812 @section Page Control
8813 @cindex page control
8814 @cindex control, page
8816 @DefreqList {bp, [@Var{page}]}
8817 @DefreqItem {bp, @t{+}@Var{page}}
8818 @DefreqItem {bp, @t{-}@Var{page}}
8820 @cindex new page (@code{bp})
8821 @cindex page, new (@code{bp})
8822 Stop processing the current page and move to the next page. This
8823 request causes a break. It can also take an argument to set (increase,
8824 decrease) the page number of the next page (which actually becomes the
8825 current page after @code{bp} has finished). The difference between
8826 @code{bp} and @code{pn} is that @code{pn} does not cause a break or
8827 actually eject a page. @xref{Page Layout}.
8830 .de newpage \" define macro
8832 'sp .5i \" vertical space
8833 .tl 'left top'center top'right top' \" title
8834 'sp .3i \" vertical space
8838 @cindex @code{bp} request, and top-level diversion
8839 @cindex top-level diversion, and @code{bp}
8840 @cindex diversion, top-level, and @code{bp}
8841 @code{bp} has no effect if not called within the top-level diversion
8842 (@pxref{Diversions}).
8844 @cindex page number register (@code{%})
8845 @cindex current page number (@code{%})
8846 The read-write register@tie{}@code{%} holds the current page number.
8848 The number register @code{.pe} is set to@tie{}1 while @code{bp} is
8849 active. @xref{Page Location Traps}.
8852 @Defreq {ne, [@Var{space}]}
8853 @cindex orphan lines, preventing with @code{ne}
8854 @cindex conditional page break (@code{ne})
8855 @cindex page break, conditional (@code{ne})
8856 It is often necessary to force a certain amount of space before a new
8857 page occurs. This is most useful to make sure that there is not a
8858 single @dfn{orphan} line left at the bottom of a page. The @code{ne}
8859 request ensures that there is a certain distance, specified by the first
8860 argument, before the next page is triggered (see @ref{Traps}, for
8861 further information). The default scaling indicator for @code{ne} is
8862 @samp{v}; the default value of @var{space} is@tie{}1@dmn{v} if no
8865 For example, to make sure that no fewer than 2@tie{}lines get orphaned,
8866 do the following before each paragraph:
8873 @code{ne} then automatically causes a page break if there is space for
8877 @DefreqList {sv, [@Var{space}]}
8878 @DefreqListEndx {os, }
8879 @cindex @code{ne} request, comparison with @code{sv}
8880 @code{sv} is similar to the @code{ne} request; it reserves the specified
8881 amount of vertical space. If the desired amount of space exists before
8882 the next trap (or the bottom page boundary if no trap is set), the space
8883 is output immediately (ignoring a partially filled line, which stays
8884 untouched). If there is not enough space, it is stored for later output
8885 via the @code{os} request. The default value is@tie{}1@dmn{v} if no
8886 argument is given; the default scaling indicator is @samp{v}.
8888 @cindex @code{sv} request, and no-space mode
8889 @cindex @code{os} request, and no-space mode
8890 Both @code{sv} and @code{os} ignore no-space mode. While the @code{sv}
8891 request allows negative values for @var{space}, @code{os} ignores them.
8895 @cindex current vertical position (@code{nl})
8896 @cindex vertical position, current (@code{nl})
8897 @cindex position, vertical, current (@code{nl})
8898 This register contains the current vertical position. If the vertical
8899 position is zero and the top of page transition hasn't happened yet,
8900 @code{nl} is set to negative value. @code{gtroff} itself does this at
8901 the very beginning of a document before anything has been printed, but
8902 the main usage is to plant a header trap on a page if this page has
8905 Consider the following:
8937 Without resetting @code{nl} to a negative value, the just planted trap
8938 would be active beginning with the @emph{next} page, not the current
8941 @xref{Diversions}, for a comparison with the @code{.h} and @code{.d}
8946 @c =====================================================================
8948 @node Fonts and Symbols, Sizes, Page Control, gtroff Reference
8949 @section Fonts and Symbols
8952 @code{gtroff} can switch fonts at any point in the text.
8954 The basic set of fonts is @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
8955 These are Times Roman, Italic, Bold, and Bold Italic. For non-TTY
8956 devices, there is also at least one symbol font that contains various
8957 special symbols (Greek, mathematics).
8964 * Character Classes::
8966 * Artificial Fonts::
8967 * Ligatures and Kerning::
8970 @c ---------------------------------------------------------------------
8972 @node Changing Fonts, Font Families, Fonts and Symbols, Fonts and Symbols
8973 @subsection Changing Fonts
8976 @DefreqList {ft, [@Var{font}]}
8977 @DefescItemx {\\f, , f, }
8978 @DefescItem {\\f, @Lparen{}, fn, }
8979 @DefescItem {\\f, @Lbrack{}, font, @Rbrack{}}
8980 @DefregListEndx {.sty}
8981 @cindex changing fonts (@code{ft}, @code{\f})
8982 @cindex fonts, changing (@code{ft}, @code{\f})
8983 @cindex @code{sty} request, and changing fonts
8984 @cindex @code{fam} request, and changing fonts
8985 @cindex @code{\F}, and changing fonts
8989 The @code{ft} request and the @code{\f} escape change the current font
8990 to @var{font} (one-character name@tie{}@var{f}, two-character name
8993 If @var{font} is a style name (as set with the @code{sty} request or
8994 with the @code{styles} command in the @file{DESC} file), use it within
8995 the current font family (as set with the @code{fam} request, the
8996 @code{\F} escape, or the @code{family} command in the @file{DESC} file).
8998 It is not possible to switch to a font with the name @samp{DESC}
8999 (whereas this name could be used as a style name; however, this is not
9002 @cindex previous font (@code{ft}, @code{\f[]}, @code{\fP})
9003 @cindex font, previous (@code{ft}, @code{\f[]}, @code{\fP})
9004 With no argument or using @samp{P} as an argument, @code{.ft} switches
9005 to the previous font. Use @code{\f[]} to do this with the escape. The
9006 old syntax forms @code{\fP} or @code{\f[P]} are also supported.
9008 Fonts are generally specified as upper-case strings, which are usually
9009 1@tie{}to 4 characters representing an abbreviation or acronym of the
9010 font name. This is no limitation, just a convention.
9012 The example below produces two identical lines.
9021 eggs, bacon, \fBspam\fP and sausage.
9024 Note that @code{\f} doesn't produce an input token in @code{gtroff}. As
9025 a consequence, it can be used in requests like @code{mc} (which expects
9026 a single character as an argument) to change the font on the fly:
9032 The current style name is available in the read-only number register
9033 @samp{.sty} (this is a string-valued register); if the current font
9034 isn't a style, the empty string is returned. It is associated with the
9035 current environment.
9037 @xref{Font Positions}, for an alternative syntax.
9040 @Defreq {ftr, f [@Var{g}]}
9041 @cindex font translation (@code{ftr})
9042 @cindex @code{ft} request, and font translations
9043 @cindex @code{ul} request, and font translations
9044 @cindex @code{bd} request, and font translations
9045 @cindex @code{\f}, and font translations
9046 @cindex @code{cs} request, and font translations
9047 @cindex @code{tkf} request, and font translations
9048 @cindex @code{special} request, and font translations
9049 @cindex @code{fspecial} request, and font translations
9050 @cindex @code{fp} request, and font translations
9051 @cindex @code{sty} request, and font translations
9052 @cindex @code{if} request, and font translations
9053 @cindex @code{ie} request, and font translations
9054 @cindex @code{while} request, and font translations
9055 Translate font@tie{}@var{f} to font@tie{}@var{g}. Whenever a font
9056 named@tie{}@var{f} is referred to in a @code{\f} escape sequence, in the
9057 @code{F} and @code{S} conditional operators, or in the @code{ft},
9058 @code{ul}, @code{bd}, @code{cs}, @code{tkf}, @code{special},
9059 @code{fspecial}, @code{fp}, or @code{sty} requests, font@tie{}@var{g} is
9060 used. If @var{g} is missing or equal to@tie{}@var{f} the translation is
9063 Note that it is not possible to chain font translations. Example:
9069 @result{} warning: can't find font `XXX'
9073 @DefreqList {fzoom, f [@Var{zoom}]}
9074 @DefregListEndx {.zoom}
9075 @cindex magnification of a font (@code{fzoom})
9076 @cindex font, magnification (@code{fzoom})
9077 @cindex zoom factor of a font (@code{fzoom})
9078 @cindex factor, zoom, of a font (@code{fzoom})
9079 @cindex font, zoom factor (@code{fzoom})
9080 @cindex optical size of a font
9081 @cindex font, optical size
9082 @cindex size, optical, of a font
9083 Set magnification of font@tie{}@var{f} to factor @var{zoom}, which must
9084 be a non-negative integer multiple of 1/1000th. This request is useful
9085 to adjust the optical size of a font in relation to the others. In the
9086 example below, font @code{CR} is magnified by 10% (the zoom factor is
9093 Palatino and \f[CR]Courier\f[]
9096 A missing or zero value of @var{zoom} is the same as a value of 1000,
9097 which means no magnification. @var{f}@tie{}must be a real font name,
9100 Note that the magnification of a font is completely transparent to
9101 troff; a change of the zoom factor doesn't cause any effect except that
9102 the dimensions of glyphs, (word) spaces, kerns, etc., of the affected
9103 font are adjusted accordingly.
9105 The zoom factor of the current font is available in the read-only number
9106 register @samp{.zoom}, in multiples of 1/1000th. It returns zero if
9107 there is no magnification.
9110 @c ---------------------------------------------------------------------
9112 @node Font Families, Font Positions, Changing Fonts, Fonts and Symbols
9113 @subsection Font Families
9114 @cindex font families
9115 @cindex families, font
9117 @cindex styles, font
9119 Due to the variety of fonts available, @code{gtroff} has added the
9120 concept of @dfn{font families} and @dfn{font styles}. The fonts are
9121 specified as the concatenation of the font family and style. Specifying
9122 a font without the family part causes @code{gtroff} to use that style of
9125 @cindex PostScript fonts
9126 @cindex fonts, PostScript
9127 Currently, fonts for the devices @option{-Tps}, @option{-Tpdf},
9128 @option{-Tdvi}, @option{-Tlj4}, @option{-Tlbp}, and the X11 fonts are
9129 set up to this mechanism. By default, @code{gtroff} uses the Times
9130 family with the four styles @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
9132 This way, it is possible to use the basic four fonts and to select a
9133 different font family on the command line (@pxref{Groff Options}).
9135 @DefreqList {fam, [@Var{family}]}
9137 @DefescItemx {\\F, , f, }
9138 @DefescItem {\\F, @Lparen{}, fm, }
9139 @DefescItem {\\F, @Lbrack{}, family, @Rbrack{}}
9140 @DefregListEndx {.fn}
9141 @cindex changing font family (@code{fam}, @code{\F})
9142 @cindex font family, changing (@code{fam}, @code{\F})
9143 Switch font family to @var{family} (one-character name@tie{}@var{f},
9144 two-character name @var{fm}). If no argument is given, switch back to
9145 the previous font family. Use @code{\F[]} to do this with the escape.
9146 Note that @code{\FP} doesn't work; it selects font family @samp{P}
9149 The value at start-up is @samp{T}. The current font family is available
9150 in the read-only number register @samp{.fam} (this is a string-valued
9151 register); it is associated with the current environment.
9155 .fam H \" helvetica family
9156 spam, \" used font is family H + style R = HR
9157 .ft B \" family H + style B = font HB
9159 .fam T \" times family
9160 spam, \" used font is family T + style B = TB
9161 .ft AR \" font AR (not a style)
9163 .ft R \" family T + style R = font TR
9167 Note that @code{\F} doesn't produce an input token in @code{gtroff}. As
9168 a consequence, it can be used in requests like @code{mc} (which expects
9169 a single character as an argument) to change the font family on the fly:
9175 The @samp{.fn} register contains the current @dfn{real font name} of the
9176 current font. This is a string-valued register. If the current font is
9177 a style, the value of @code{\n[.fn]} is the proper concatenation of
9178 family and style name.
9181 @Defreq {sty, n style}
9182 @cindex changing font style (@code{sty})
9183 @cindex font style, changing (@code{sty})
9184 @cindex @code{cs} request, and font styles
9185 @cindex @code{bd} request, and font styles
9186 @cindex @code{tkf} request, and font styles
9187 @cindex @code{uf} request, and font styles
9188 @cindex @code{fspecial} request, and font styles
9189 Associate @var{style} with font position@tie{}@var{n}. A font position
9190 can be associated either with a font or with a style. The current font
9191 is the index of a font position and so is also either a font or a style.
9192 If it is a style, the font that is actually used is the font which name
9193 is the concatenation of the name of the current family and the name of
9194 the current style. For example, if the current font is@tie{}1 and font
9195 position@tie{}1 is associated with style @samp{R} and the current font
9196 family is @samp{T}, then font @samp{TR} is used. If the current font is
9197 not a style, then the current family is ignored. If the requests
9198 @code{cs}, @code{bd}, @code{tkf}, @code{uf}, or @code{fspecial} are
9199 applied to a style, they are instead applied to the member of the
9200 current family corresponding to that style.
9202 @var{n}@tie{}must be a non-negative integer value.
9206 The default family can be set with the @option{-f} option (@pxref{Groff
9207 Options}). The @code{styles} command in the @file{DESC} file controls
9208 which font positions (if any) are initially associated with styles
9209 rather than fonts. For example, the default setting for @sc{PostScript}
9226 @code{fam} and @code{\F} always check whether the current font position
9227 is valid; this can give surprising results if the current font position
9228 is associated with a style.
9230 In the following example, we want to access the @sc{PostScript} font
9231 @code{FooBar} from the font family @code{Foo}:
9236 @result{} warning: can't find font `FooR'
9240 The default font position at start-up is@tie{}1; for the @sc{PostScript}
9241 device, this is associated with style @samp{R}, so @code{gtroff} tries
9242 to open @code{FooR}.
9244 A solution to this problem is to use a dummy font like the following:
9247 .fp 0 dummy TR \" set up dummy font at position 0
9248 .sty \n[.fp] Bar \" register style `Bar'
9249 .ft 0 \" switch to font at position 0
9250 .fam Foo \" activate family `Foo'
9251 .ft Bar \" switch to font `FooBar'
9254 @xref{Font Positions}.
9257 @c ---------------------------------------------------------------------
9259 @node Font Positions, Using Symbols, Font Families, Fonts and Symbols
9260 @subsection Font Positions
9261 @cindex font positions
9262 @cindex positions, font
9264 For the sake of old phototypesetters and compatibility with old versions
9265 of @code{troff}, @code{gtroff} has the concept of font @dfn{positions},
9266 on which various fonts are mounted.
9268 @DefreqList {fp, pos font [@Var{external-name}]}
9270 @DefregListEndx {.fp}
9271 @cindex mounting font (@code{fp})
9272 @cindex font, mounting (@code{fp})
9273 Mount font @var{font} at position @var{pos} (which must be a
9274 non-negative integer). This numeric position can then be referred to
9275 with font changing commands. When @code{gtroff} starts it is using font
9276 position@tie{}1 (which must exist; position@tie{}0 is unused usually at
9279 @cindex font position register (@code{.f})
9280 The current font in use, as a font position, is available in the
9281 read-only number register @samp{.f}. This can be useful to remember the
9282 current font for later recall. It is associated with the current
9283 environment (@pxref{Environments}).
9286 .nr save-font \n[.f]
9288 ... text text text ...
9292 @cindex next free font position register (@code{.fp})
9293 The number of the next free font position is available in the read-only
9294 number register @samp{.fp}. This is useful when mounting a new font,
9298 .fp \n[.fp] NEATOFONT
9301 @pindex DESC@r{, and font mounting}
9302 Fonts not listed in the @file{DESC} file are automatically mounted on
9303 the next available font position when they are referenced. If a font is
9304 to be mounted explicitly with the @code{fp} request on an unused font
9305 position, it should be mounted on the first unused font position, which
9306 can be found in the @code{.fp} register. Although @code{gtroff} does
9307 not enforce this strictly, it is not allowed to mount a font at a
9308 position whose number is much greater (approx.@: 1000 positions) than
9309 that of any currently used position.
9311 The @code{fp} request has an optional third argument. This argument
9312 gives the external name of the font, which is used for finding the font
9313 description file. The second argument gives the internal name of the
9314 font, which is used to refer to the font in @code{gtroff} after it has
9315 been mounted. If there is no third argument then the internal name is
9316 used as the external name. This feature makes it possible to use fonts
9317 with long names in compatibility mode.
9320 Both the @code{ft} request and the @code{\f} escape have alternative
9321 syntax forms to access font positions.
9323 @DefreqList {ft, nnn}
9324 @DefescItemx {\\f, , n, }
9325 @DefescItem {\\f, @Lparen{}, nn, }
9326 @DefescListEnd {\\f, @Lbrack{}, nnn, @Rbrack{}}
9327 @cindex changing font position (@code{\f})
9328 @cindex font position, changing (@code{\f})
9329 @cindex @code{sty} request, and font positions
9330 @cindex @code{fam} request, and font positions
9331 @cindex @code{\F}, and font positions
9335 Change the current font position to @var{nnn} (one-digit
9336 position@tie{}@var{n}, two-digit position @var{nn}), which must be a
9337 non-negative integer.
9339 If @var{nnn} is associated with a style (as set with the @code{sty}
9340 request or with the @code{styles} command in the @file{DESC} file), use
9341 it within the current font family (as set with the @code{fam} request,
9342 the @code{\F} escape, or the @code{family} command in the
9349 .ft \" switch back to font 1
9353 this is font 1 again
9356 @xref{Changing Fonts}, for the standard syntax form.
9359 @c ---------------------------------------------------------------------
9361 @node Using Symbols, Character Classes, Font Positions, Fonts and Symbols
9362 @subsection Using Symbols
9363 @cindex using symbols
9364 @cindex symbols, using
9369 A @dfn{glyph} is a graphical representation of a @dfn{character}. While
9370 a character is an abstract entity containing semantic information, a
9371 glyph is something that can be actually seen on screen or paper. It is
9372 possible that a character has multiple glyph representation forms (for
9373 example, the character `A' can be either written in a roman or an italic
9374 font, yielding two different glyphs); sometimes more than one character
9375 maps to a single glyph (this is a @dfn{ligature} -- the most common is
9379 @cindex special fonts
9382 @cindex @code{special} request, and glyph search order
9383 @cindex @code{fspecial} request, and glyph search order
9384 A @dfn{symbol} is simply a named glyph. Within @code{gtroff}, all glyph
9385 names of a particular font are defined in its font file. If the user
9386 requests a glyph not available in this font, @code{gtroff} looks up an
9387 ordered list of @dfn{special fonts}. By default, the @sc{PostScript}
9388 output device supports the two special fonts @samp{SS} (slanted symbols)
9389 and @samp{S} (symbols) (the former is looked up before the latter).
9390 Other output devices use different names for special fonts. Fonts
9391 mounted with the @code{fonts} keyword in the @file{DESC} file are
9392 globally available. To install additional special fonts locally (i.e.@:
9393 for a particular font), use the @code{fspecial} request.
9395 Here are the exact rules how @code{gtroff} searches a given symbol:
9399 If the symbol has been defined with the @code{char} request, use it.
9400 This hides a symbol with the same name in the current font.
9403 Check the current font.
9406 If the symbol has been defined with the @code{fchar} request, use it.
9409 Check whether the current font has a font-specific list of special
9410 fonts; test all fonts in the order of appearance in the last
9411 @code{fspecial} call if appropriate.
9414 If the symbol has been defined with the @code{fschar} request for the
9415 current font, use it.
9418 Check all fonts in the order of appearance in the last @code{special}
9422 If the symbol has been defined with the @code{schar} request, use it.
9425 As a last resort, consult all fonts loaded up to now for special fonts
9426 and check them, starting with the lowest font number. Note that this
9427 can sometimes lead to surprising results since the @code{fonts} line in
9428 the @file{DESC} file often contains empty positions, which are filled
9429 later on. For example, consider the following:
9436 This mounts font @code{foo} at font position@tie{}3. We assume that
9437 @code{FOO} is a special font, containing glyph @code{foo}, and that no
9438 font has been loaded yet. The line
9445 makes font @code{BAZ} special only if font @code{BAR} is active. We
9446 further assume that @code{BAZ} is really a special font, i.e., the font
9447 description file contains the @code{special} keyword, and that it also
9448 contains glyph @code{foo} with a special shape fitting to font
9449 @code{BAR}. After executing @code{fspecial}, font @code{BAR} is loaded
9450 at font position@tie{}1, and @code{BAZ} at position@tie{}2.
9452 We now switch to a new font @code{XXX}, trying to access glyph
9453 @code{foo} that is assumed to be missing. There are neither
9454 font-specific special fonts for @code{XXX} nor any other fonts made
9455 special with the @code{special} request, so @code{gtroff} starts the
9456 search for special fonts in the list of already mounted fonts, with
9457 increasing font positions. Consequently, it finds @code{BAZ} before
9458 @code{FOO} even for @code{XXX}, which is not the intended behaviour.
9461 @xref{Font Files}, and @ref{Special Fonts}, for more details.
9463 @cindex list of available glyphs (@cite{groff_char(7)} man page)
9464 @cindex available glyphs, list (@cite{groff_char(7)} man page)
9465 @cindex glyphs, available, list (@cite{groff_char(7)} man page)
9466 The list of available symbols is device dependent; see the
9467 @cite{groff_char(7)} man page for a complete list of all glyphs. For
9471 man -Tdvi groff_char > groff_char.dvi
9475 for a list using the default DVI fonts (not all versions of the
9476 @code{man} program support the @option{-T} option). If you want to use
9477 an additional macro package to change the used fonts, @code{groff} must
9481 groff -Tdvi -mec -man groff_char.7 > groff_char.dvi
9484 @cindex composite glyph names
9485 @cindex glyph names, composite
9486 @cindex groff glyph list (GGL)
9487 @cindex GGL (groff glyph list)
9488 @cindex adobe glyph list (AGL)
9489 @cindex AGL (adobe glyph list)
9490 Glyph names not listed in groff_char(7) are derived algorithmically,
9491 using a simplified version of the Adobe Glyph List (AGL) algorithm, which
9492 is described in @uref{https://github.com@//adobe-type-tools@//agl-aglfn}.
9493 The (frozen) set of glyph names that can't be derived algorithmically
9494 is called @dfn{groff glyph list (GGL)}.
9498 A glyph for Unicode character U+@var{XXXX}[@var{X}[@var{X}]], which is
9499 not a composite character is named
9500 @code{u@var{XXXX}@r{[}@var{X}@r{[}@var{X}@r{]]}}. @var{X} must be an
9501 uppercase hexadecimal digit. Examples: @code{u1234}, @code{u008E},
9502 @code{u12DB8}. The largest Unicode value is 0x10FFFF. There must be at
9503 least four @code{X} digits; if necessary, add leading zeroes (after the
9504 @samp{u}). No zero padding is allowed for character codes greater than
9505 0xFFFF. Surrogates (i.e., Unicode values greater than 0xFFFF
9506 represented with character codes from the surrogate area U+D800-U+DFFF)
9507 are not allowed too.
9510 A glyph representing more than a single input character is named
9513 @samp{u} @var{component1} @samp{_} @var{component2} @samp{_} @var{component3} @dots{}
9517 Example: @code{u0045_0302_0301}.
9519 For simplicity, all Unicode characters that are composites must be
9520 decomposed maximally (this is normalization form@tie{}D in the Unicode
9521 standard); for example, @code{u00CA_0301} is not a valid glyph name
9522 since U+00CA (@sc{latin capital letter e with circumflex}) can be
9523 further decomposed into U+0045 (@sc{latin capital letter e}) and U+0302
9524 (@sc{combining circumflex accent}). @code{u0045_0302_0301} is thus the
9525 glyph name for U+1EBE, @sc{latin capital letter e with circumflex and
9529 groff maintains a table to decompose all algorithmically derived glyph
9530 names that are composites itself. For example, @code{u0100} (@sc{latin
9531 letter a with macron}) is automatically decomposed into
9532 @code{u0041_0304}. Additionally, a glyph name of the GGL is preferred
9533 to an algorithmically derived glyph name; groff also automatically does
9534 the mapping. Example: The glyph @code{u0045_0302} is mapped to
9538 glyph names of the GGL can't be used in composite glyph names; for
9539 example, @code{^E_u0301} is invalid.
9542 @DefescList {\\, @Lparen{}, nm, }
9543 @DefescItem {\\, @Lbrack{}, name, @Rbrack{}}
9544 @DefescListEnd {\\, @Lbrack{}, component1 component2 @dots{}, @Rbrack{}}
9545 Insert a symbol @var{name} (two-character name @var{nm}) or a composite
9546 glyph with component glyphs @var{component1}, @var{component2},
9547 @enddots{} There is no special syntax for one-character names -- the
9548 natural form @samp{\@var{n}} would collide with escapes.@footnote{Note
9549 that a one-character symbol is not the same as an input character, i.e.,
9550 the character @code{a} is not the same as @code{\[a]}. By default,
9551 @code{groff} defines only a single one-character symbol, @code{\[-]}; it
9552 is usually accessed as @code{\-}. On the other hand, @code{gtroff} has
9553 the special feature that @code{\[char@var{XXX}]} is the same as the
9554 input character with character code @var{XXX}. For example,
9555 @code{\[char97]} is identical to the letter @code{a} if @acronym{ASCII}
9556 encoding is active.}
9558 If @var{name} is undefined, a warning of type @samp{char} is generated,
9559 and the escape is ignored. @xref{Debugging}, for information about
9562 groff resolves @code{\[...]} with more than a single component as
9567 Any component that is found in the GGL is converted to the
9568 @code{u@var{XXXX}} form.
9571 Any component @code{u@var{XXXX}} that is found in the list of
9572 decomposable glyphs is decomposed.
9575 The resulting elements are then concatenated with @samp{_} in between,
9576 dropping the leading @samp{u} in all elements but the first.
9579 No check for the existence of any component (similar to @code{tr}
9586 @samp{A} maps to @code{u0041}, @samp{ho} maps to @code{u02DB}, thus the
9587 final glyph name would be @code{u0041_02DB}. Note this is not the
9588 expected result: The ogonek glyph @samp{ho} is a spacing ogonek, but for
9589 a proper composite a non-spacing ogonek (U+0328) is necessary. Looking
9590 into the file @file{composite.tmac} one can find @w{@samp{.composite ho
9591 u0328}}, which changes the mapping of @samp{ho} while a composite glyph
9592 name is constructed, causing the final glyph name to be
9599 @samp{^E} maps to @code{u0045_0302}, thus the final glyph name is
9600 @code{u0045_0302_0301} in all forms (assuming proper calls of the
9601 @code{composite} request).
9604 It is not possible to define glyphs with names like @w{@samp{A ho}}
9605 within a groff font file. This is not really a limitation; instead, you
9606 have to define @code{u0041_0328}.
9609 @Defesc {\\C, ', xxx, '}
9610 @cindex named character (@code{\C})
9611 @cindex character, named (@code{\C})
9612 Typeset the glyph named @var{xxx}.@footnote{@code{\C} is actually a
9613 misnomer since it accesses an output glyph.} Normally it is more
9614 convenient to use @code{\[@var{xxx}]}, but @code{\C} has the advantage
9615 that it is compatible with newer versions of @acronym{AT&T} @code{troff}
9616 and is available in compatibility mode.
9619 @Defreq {composite, from to}
9620 @pindex composite.tmac
9621 Map glyph name @var{from} to glyph name @var{to} if it is used in
9622 @code{\[...]} with more than one component. See above for examples.
9624 This mapping is based on glyph names only; no check for the existence of
9625 either glyph is done.
9627 A set of default mappings for many accents can be found in the file
9628 @file{composite.tmac}, which is loaded at start-up.
9631 @Defesc {\\N, ', n, '}
9632 @cindex numbered glyph (@code{\N})
9633 @cindex glyph, numbered (@code{\N})
9634 @cindex @code{char} request, used with @code{\N}
9636 Typeset the glyph with code@tie{}@var{n} in the current font
9637 (@code{n}@tie{}is @strong{not} the input character code). The number
9638 @var{n}@tie{}can be any non-negative decimal integer. Most devices only
9639 have glyphs with codes between 0 and@tie{}255; the Unicode output device
9640 uses codes in the range 0--65535. If the current font does not contain
9641 a glyph with that code, special fonts are @emph{not} searched. The
9642 @code{\N} escape sequence can be conveniently used in conjunction with
9643 the @code{char} request:
9646 .char \[phone] \f[ZD]\N'37'
9651 @cindex unnamed glyphs
9652 @cindex glyphs, unnamed
9653 The code of each glyph is given in the fourth column in the font
9654 description file after the @code{charset} command. It is possible to
9655 include unnamed glyphs in the font description file by using a name of
9656 @samp{---}; the @code{\N} escape sequence is the only way to use these.
9658 No kerning is applied to glyphs accessed with @code{\N}.
9661 Some escape sequences directly map onto special glyphs.
9664 This is a backslash followed by the apostrophe character,
9665 @acronym{ASCII} character @code{0x27} (@acronym{EBCDIC} character
9666 @code{0x7D}). The same as @code{\[aa]}, the acute accent.
9670 This is a backslash followed by @acronym{ASCII} character @code{0x60}
9671 (@acronym{EBCDIC} character @code{0x79} usually). The same as
9672 @code{\[ga]}, the grave accent.
9676 This is the same as @code{\[-]}, the minus sign in the current font.
9680 This is the same as @code{\[ul]}, the underline character.
9683 @Defreq {cflags, n c1 c2 @dots{}}
9684 @cindex glyph properties (@code{cflags})
9685 @cindex character properties (@code{cflags})
9686 @cindex properties of glyphs (@code{cflags})
9687 @cindex properties of characters (@code{cflags})
9688 Input characters and symbols have certain properties associated with
9689 it.@footnote{Note that the output glyphs themselves don't have such
9690 properties. For @code{gtroff}, a glyph is a numbered box with a given
9691 width, depth, and height, nothing else. All manipulations with the
9692 @code{cflags} request work on the input level.} These properties can be
9693 modified with the @code{cflags} request. The first argument is the sum
9694 of the desired flags and the remaining arguments are the characters or
9695 symbols to have those properties. It is possible to omit the spaces
9696 between the characters or symbols. Instead of single characters or
9697 symbols you can also use character classes (see @ref{Character Classes}
9702 @cindex end-of-sentence characters
9703 @cindex characters, end-of-sentence
9704 The character ends sentences (initially characters @samp{.?!} have this
9708 @cindex hyphenating characters
9709 @cindex characters, hyphenation
9710 Lines can be broken before the character (initially no characters have
9711 this property). This only works if both the characters before and after
9712 have non-zero hyphenation codes (as set with the @code{hcode} request).
9713 Use value@tie{}64 to override this behaviour.
9716 @cindex @code{hy} glyph, and @code{cflags}
9717 @cindex @code{em} glyph, and @code{cflags}
9718 Lines can be broken after the character (initially the character
9719 @samp{-} and the symbols @samp{\[hy]} and @samp{\[em]} have this
9720 property). This only works if both the characters before and after have
9721 non-zero hyphenation codes (as set with the @code{hcode} request). Use
9722 value@tie{}64 to override this behaviour.
9725 @cindex overlapping characters
9726 @cindex characters, overlapping
9727 @cindex @code{ul} glyph, and @code{cflags}
9728 @cindex @code{rn} glyph, and @code{cflags}
9729 @cindex @code{ru} glyph, and @code{cflags}
9730 @cindex @code{radicalex} glyph, and @code{cflags}
9731 @cindex @code{sqrtex} glyph, and @code{cflags}
9732 The character overlaps horizontally if used as a horizontal line
9733 building element. Initially the symbols @samp{\[ul]}, @samp{\[rn]},
9734 @samp{\[ru]}, @samp{\[radicalex]}, and @samp{\[sqrtex]} have this
9738 @cindex @code{br} glyph, and @code{cflags}
9739 The character overlaps vertically if used as vertical line building
9740 element. Initially symbol @samp{\[br]} has this property.
9743 @cindex transparent characters
9744 @cindex character, transparent
9745 @cindex @code{"}, at end of sentence
9746 @cindex @code{'}, at end of sentence
9747 @cindex @code{)}, at end of sentence
9748 @cindex @code{]}, at end of sentence
9749 @cindex @code{*}, at end of sentence
9750 @cindex @code{dg} glyph, at end of sentence
9751 @cindex @code{rq} glyph, at end of sentence
9752 @cindex @code{cq} glyph, at end of sentence
9753 An end-of-sentence character followed by any number of characters with
9754 this property is treated as the end of a sentence if followed by a
9755 newline or two spaces; in other words the character is @dfn{transparent}
9756 for the purposes of end-of-sentence recognition -- this is the same as
9757 having a zero space factor in @TeX{} (initially characters @samp{"')]*}
9758 and the symbols @samp{\[dg]}, @samp{\[rq]}, and @samp{\[cq]} have this
9762 Ignore hyphenation code values of the surrounding characters. Use this
9763 in combination with values 2 and@tie{}4 (initially no characters have
9764 this property). For example, if you need an automatic break point after
9765 the en-dash in number ranges like `3000--5000', insert
9772 into your document. Note, however, that this can lead to bad layout if
9773 done without thinking; in most situations, a better solution instead of
9774 changing the @code{cflags} value is to insert @code{\:} right after the
9775 hyphen at the places that really need a break point.
9778 Prohibit a line break before the character, but allow a line break after
9779 the character. This works only in combination with flags 256 and 512
9780 (see below) and has no effect otherwise.
9783 Prohibit a line break after the character, but allow a line break before
9784 the character. This works only in combination with flags 128 and 512
9785 (see below) and has no effect otherwise.
9788 Allow line break before or after the character. This works only in
9789 combination with flags 128 and 256 and has no effect otherwise.
9791 Contrary to flag values 2 and@tie{}4, the flags 128, 256, and 512 work
9792 pairwise. If, for example, the left character has value 512, and the
9793 right character 128, no line break gets inserted. If we use
9794 value@tie{}6 instead for the left character, a line break after the
9795 character can't be suppressed since the right neighbour character
9796 doesn't get examined.
9800 @DefreqList {char, g [@Var{string}]}
9801 @DefreqItemx {fchar, g [@Var{string}]}
9802 @DefreqItemx {fschar, f g [@Var{string}]}
9803 @DefreqListEndx {schar, g [@Var{string}]}
9804 @cindex defining character (@code{char})
9805 @cindex defining fallback character (@code{fchar}, @code{fschar}, @code{schar})
9806 @cindex character, defining (@code{char})
9807 @cindex character, defining fallback (@code{fchar}, @code{fschar}, @code{schar})
9808 @cindex fallback character, defining (@code{fchar}, @code{fschar}, @code{schar})
9809 @cindex creating new characters (@code{char})
9810 @cindex defining symbol (@code{char})
9811 @cindex symbol, defining (@code{char})
9812 @cindex defining glyph (@code{char})
9813 @cindex glyph, defining (@code{char})
9814 @cindex escape character, while defining glyph
9815 @cindex character, escape, while defining glyph
9816 @cindex @code{tr} request, and glyph definitions
9817 @cindex @code{cp} request, and glyph definitions
9818 @cindex @code{rc} request, and glyph definitions
9819 @cindex @code{lc} request, and glyph definitions
9820 @cindex @code{\l}, and glyph definitions
9821 @cindex @code{\L}, and glyph definitions
9822 @cindex @code{\&}, and glyph definitions
9823 @cindex @code{\e}, and glyph definitions
9824 @cindex @code{hcode} request, and glyph definitions
9825 Define a new glyph@tie{}@var{g} to be @var{string} (which can be
9826 empty).@footnote{@code{char} is a misnomer since an output glyph is
9827 defined.} Every time glyph@tie{}@var{g} needs to be printed,
9828 @var{string} is processed in a temporary environment and the result is
9829 wrapped up into a single object. Compatibility mode is turned off and
9830 the escape character is set to @samp{\} while @var{string} is being
9831 processed. Any emboldening, constant spacing or track kerning is
9832 applied to this object rather than to individual characters in
9835 A glyph defined by these requests can be used just like a normal glyph
9836 provided by the output device. In particular, other characters can be
9837 translated to it with the @code{tr} or @code{trin} requests; it can be
9838 made the leader character by the @code{lc} request; repeated patterns
9839 can be drawn with the glyph using the @code{\l} and @code{\L} escape
9840 sequences; words containing the glyph can be hyphenated correctly if the
9841 @code{hcode} request is used to give the glyph's symbol a hyphenation
9844 There is a special anti-recursion feature: Use of @code{g} within the
9845 glyph's definition is handled like normal characters and symbols not
9846 defined with @code{char}.
9848 Note that the @code{tr} and @code{trin} requests take precedence if
9849 @code{char} accesses the same symbol.
9863 The @code{fchar} request defines a fallback glyph: @code{gtroff} only
9864 checks for glyphs defined with @code{fchar} if it cannot find the glyph
9865 in the current font. @code{gtroff} carries out this test before
9866 checking special fonts.
9868 @code{fschar} defines a fallback glyph for font@tie{}@var{f}:
9869 @code{gtroff} checks for glyphs defined with @code{fschar} after the
9870 list of fonts declared as font-specific special fonts with the
9871 @code{fspecial} request, but before the list of fonts declared as global
9872 special fonts with the @code{special} request.
9874 Finally, the @code{schar} request defines a global fallback glyph:
9875 @code{gtroff} checks for glyphs defined with @code{schar} after the list
9876 of fonts declared as global special fonts with the @code{special}
9877 request, but before the already mounted special fonts.
9879 @xref{Using Symbols}, for a detailed description of the glyph searching
9880 mechanism in @code{gtroff}.
9883 @DefreqList {rchar, c1 c2 @dots{}}
9884 @DefreqListEndx {rfschar, f c1 c2 @dots{}}
9885 @cindex removing glyph definition (@code{rchar}, @code{rfschar})
9886 @cindex glyph, removing definition (@code{rchar}, @code{rfschar})
9887 @cindex fallback glyph, removing definition (@code{rchar}, @code{rfschar})
9888 Remove the definitions of glyphs @var{c1}, @var{c2},@tie{}@enddots{}
9889 This undoes the effect of a @code{char}, @code{fchar}, or @code{schar}
9892 It is possible to omit the whitespace between arguments.
9894 The request @code{rfschar} removes glyph definitions defined with
9895 @code{fschar} for glyph@tie{}f.
9898 @xref{Special Characters}.
9900 @c ---------------------------------------------------------------------
9902 @node Character Classes, Special Fonts, Using Symbols, Fonts and Symbols
9903 @subsection Character Classes
9904 @cindex character classes
9905 @cindex classes, character
9907 Classes are particularly useful for East Asian languages such as
9908 Chinese, Japanese, and Korean, where the number of needed characters is
9909 much larger than in European languages, and where large sets of
9910 characters share the same properties.
9912 @Defreq {class, n c1 c2 @dots{}}
9913 @cindex character class (@code{class})
9914 @cindex defining character class (@code{class})
9915 @cindex class of characters (@code{class})
9916 In @code{groff}, a @dfn{character class} (or simply ``class'') is a set
9917 of characters, grouped by some user aspect. The @code{class} request
9918 defines such classes so that other requests can refer to all characters
9919 belonging to this set with a single class name. Currently, only the
9920 @code{cflags} request can handle character classes.
9922 A @code{class} request takes a class name followed by a list of
9923 entities. In its simplest form, the entities are characters or symbols:
9926 .class [prepunct] , : ; > @}
9929 Since class and glyph names share the same namespace, it is recommended
9930 to start and end the class name with @code{[} and @code{]},
9931 respectively, to avoid collisions with normal @code{groff} symbols (and
9932 symbols defined by the user). In particular, the presence of @code{]}
9933 in the symbol name intentionally prevents the usage of @code{\[...]},
9934 thus you must use the @code{\C} escape to access a class with such a
9937 @cindex GGL (groff glyph list)
9938 @cindex groff glyph list (GGL)
9939 You can also use a special character range notation, consisting of a
9940 start character or symbol, followed by @samp{-}, and an end character or
9941 symbol. Internally, @code{gtroff} converts these two symbol names to
9942 Unicode values (according to the groff glyph gist), which then give the
9943 start and end value of the range. If that fails, the class definition
9946 Finally, classes can be nested, too.
9948 Here is a more complex example:
9951 .class [prepunctx] \C'[prepunct]' \[u2013]-\[u2016]
9954 The class @samp{prepunctx} now contains the contents of the class
9955 @code{prepunct} as defined above (the set @samp{, : ; > @}}), and
9956 characters in the range between @code{U+2013} and @code{U+2016}.
9958 If you want to add @samp{-} to a class, it must be the first character
9959 value in the argument list, otherwise it gets misinterpreted as a range.
9961 Note that it is not possible to use class names within range
9964 Typical use of the @code{class} request is to control line-breaking and
9965 hyphenation rules as defined by the @code{cflags} request. For example,
9966 to inhibit line breaks before the characters belonging to the
9967 @code{prepunctx} class, you can write:
9970 .cflags 2 \C'[prepunctx]'
9973 See the @code{cflags} request in @ref{Using Symbols}, for more details.
9976 @c ---------------------------------------------------------------------
9978 @node Special Fonts, Artificial Fonts, Character Classes, Fonts and Symbols
9979 @subsection Special Fonts
9980 @cindex special fonts
9981 @cindex fonts, special
9983 Special fonts are those that @code{gtroff} searches when it cannot find
9984 the requested glyph in the current font. The Symbol font is usually a
9987 @code{gtroff} provides the following two requests to add more special
9988 fonts. @xref{Using Symbols}, for a detailed description of the glyph
9989 searching mechanism in @code{gtroff}.
9991 Usually, only non-TTY devices have special fonts.
9993 @DefreqList {special, [@Var{s1} @Var{s2} @dots{}]}
9994 @DefreqListEndx {fspecial, f [@Var{s1} @Var{s2} @dots{}]}
9997 Use the @code{special} request to define special fonts. Initially, this
10000 Use the @code{fspecial} request to designate special fonts only when
10001 font@tie{}@var{f} is active. Initially, this list is empty.
10003 Previous calls to @code{special} or @code{fspecial} are overwritten;
10004 without arguments, the particular list of special fonts is set to empty.
10005 Special fonts are searched in the order they appear as arguments.
10007 All fonts that appear in a call to @code{special} or @code{fspecial}
10010 @xref{Using Symbols}, for the exact search order of glyphs.
10013 @c ---------------------------------------------------------------------
10015 @node Artificial Fonts, Ligatures and Kerning, Special Fonts, Fonts and Symbols
10016 @subsection Artificial Fonts
10017 @cindex artificial fonts
10018 @cindex fonts, artificial
10020 There are a number of requests and escapes for artificially creating
10021 fonts. These are largely vestiges of the days when output devices did
10022 not have a wide variety of fonts, and when @code{nroff} and @code{troff}
10023 were separate programs. Most of them are no longer necessary in GNU
10024 @code{troff}. Nevertheless, they are supported.
10026 @DefescList {\\H, ', height, '}
10027 @DefescItem {\\H, ', @t{+}height, '}
10028 @DefescItem {\\H, ', @t{-}height, '}
10029 @DefregListEndx {.height}
10030 @cindex changing the font height (@code{\H})
10031 @cindex font height, changing (@code{\H})
10032 @cindex height, font, changing (@code{\H})
10033 Change (increment, decrement) the height of the current font, but not
10034 the width. If @var{height} is zero, restore the original height.
10035 Default scaling indicator is @samp{z}.
10037 The read-only number register @code{.height} contains the font height as
10040 Currently, only the @option{-Tps} and @option{-Tpdf} devices support
10043 Note that @code{\H} doesn't produce an input token in @code{gtroff}. As
10044 a consequence, it can be used in requests like @code{mc} (which expects
10045 a single character as an argument) to change the font on the fly:
10051 In compatibility mode, @code{gtroff} behaves differently: If an
10052 increment or decrement is used, it is always taken relative to the
10053 current point size and not relative to the previously selected font
10058 \H'+5'test \H'+5'test
10062 prints the word @samp{test} twice with the same font height (five points
10063 larger than the current font size).
10066 @DefescList {\\S, ', slant, '}
10067 @DefregListEndx {.slant}
10068 @cindex changing the font slant (@code{\S})
10069 @cindex font slant, changing (@code{\S})
10070 @cindex slant, font, changing (@code{\S})
10071 Slant the current font by @var{slant} degrees. Positive values slant to
10072 the right. Only integer values are possible.
10074 The read-only number register @code{.slant} contains the font slant as
10077 Currently, only the @option{-Tps} and @option{-Tpdf} devices support
10080 Note that @code{\S} doesn't produce an input token in @code{gtroff}. As
10081 a consequence, it can be used in requests like @code{mc} (which expects
10082 a single character as an argument) to change the font on the fly:
10088 This request is incorrectly documented in the original Unix troff
10089 manual; the slant is always set to an absolute value.
10092 @Defreq {ul, [@Var{lines}]}
10093 @cindex underlining (@code{ul})
10094 The @code{ul} request normally underlines subsequent lines if a TTY
10095 output device is used. Otherwise, the lines are printed in italics
10096 (only the term `underlined' is used in the following). The single
10097 argument is the number of input lines to be underlined; with no
10098 argument, the next line is underlined. If @var{lines} is zero or
10099 negative, stop the effects of @code{ul} (if it was active). Requests
10100 and empty lines do not count for computing the number of underlined
10101 input lines, even if they produce some output like @code{tl}. Lines
10102 inserted by macros (e.g.@: invoked by a trap) do count.
10104 At the beginning of @code{ul}, the current font is stored and the
10105 underline font is activated. Within the span of a @code{ul} request, it
10106 is possible to change fonts, but after the last line affected by
10107 @code{ul} the saved font is restored.
10109 This number of lines still to be underlined is associated with the
10110 current environment (@pxref{Environments}). The underline font can be
10111 changed with the @code{uf} request.
10113 @c XXX @xref should be changed to grotty
10115 @c @xref{Troff and Nroff Mode}, for a discussion how underlining is
10116 @c implemented in for TTY output devices, and which problems can arise.
10118 The @code{ul} request does not underline spaces.
10121 @Defreq {cu, [@Var{lines}]}
10122 @cindex continuous underlining (@code{cu})
10123 @cindex underlining, continuous (@code{cu})
10124 The @code{cu} request is similar to @code{ul} but underlines spaces as
10125 well (if a TTY output device is used).
10129 @cindex underline font (@code{uf})
10130 @cindex font for underlining (@code{uf})
10131 Set the underline font (globally) used by @code{ul} and @code{cu}. By
10132 default, this is the font at position@tie{}2. @var{font} can be either
10133 a non-negative font position or the name of a font.
10136 @DefreqList {bd, font [@Var{offset}]}
10137 @DefreqItem {bd, font1 font2 [@Var{offset}]}
10138 @DefregListEndx {.b}
10139 @cindex imitating bold face (@code{bd})
10140 @cindex bold face, imitating (@code{bd})
10141 Artificially create a bold font by printing each glyph twice, slightly
10144 Two syntax forms are available.
10148 Imitate a bold font unconditionally. The first argument specifies the
10149 font to embolden, and the second is the number of basic units, minus
10150 one, by which the two glyphs are offset. If the second argument is
10151 missing, emboldening is turned off.
10153 @var{font} can be either a non-negative font position or the name of a
10156 @var{offset} is available in the @code{.b} read-only register if a
10157 special font is active; in the @code{bd} request, its default unit is
10160 @cindex @code{fspecial} request, and imitating bold
10162 @cindex embolding of special fonts
10163 @cindex special fonts, emboldening
10165 Imitate a bold form conditionally. Embolden @var{font1} by @var{offset}
10166 only if font @var{font2} is the current font. This command can be
10167 issued repeatedly to set up different emboldening values for different
10168 current fonts. If the second argument is missing, emboldening is turned
10169 off for this particular current font.
10171 This affects special fonts only (either set up with the @code{special}
10172 command in font files or with the @code{fspecial} request).
10176 @Defreq {cs, font [@Var{width} [@Var{em-size}]]}
10177 @cindex constant glyph space mode (@code{cs})
10178 @cindex mode for constant glyph space (@code{cs})
10179 @cindex glyph, constant space
10180 @cindex @code{ps} request, and constant glyph space mode
10181 Switch to and from @dfn{constant glyph space mode}. If activated, the
10182 width of every glyph is @math{@var{width}/36} ems. The em size is given
10183 absolutely by @var{em-size}; if this argument is missing, the em value
10184 is taken from the current font size (as set with the @code{ps} request)
10185 when the font is effectively in use. Without second and third argument,
10186 constant glyph space mode is deactivated.
10188 Default scaling indicator for @var{em-size} is @samp{z}; @var{width} is
10192 @c ---------------------------------------------------------------------
10194 @node Ligatures and Kerning, , Artificial Fonts, Fonts and Symbols
10195 @subsection Ligatures and Kerning
10196 @cindex ligatures and kerning
10197 @cindex kerning and ligatures
10199 Ligatures are groups of characters that are run together, i.e, producing
10200 a single glyph. For example, the letters `f' and `i' can form a
10201 ligature `fi' as in the word `file'. This produces a cleaner look
10202 (albeit subtle) to the printed output. Usually, ligatures are not
10203 available in fonts for TTY output devices.
10205 Most @sc{PostScript} fonts support the fi and fl ligatures. The C/A/T
10206 typesetter that was the target of @acronym{AT&T} @code{troff} also
10207 supported `ff', `ffi', and `ffl' ligatures. Advanced typesetters or
10208 `expert' fonts may include ligatures for `ft' and `ct', although GNU
10209 @code{troff} does not support these (yet).
10211 Only the current font is checked for ligatures and kerns; neither
10212 special fonts nor entities defined with the @code{char} request (and its
10213 siblings) are taken into account.
10215 @DefreqList {lg, [@Var{flag}]}
10216 @DefregListEndx {.lg}
10217 @cindex activating ligatures (@code{lg})
10218 @cindex ligatures, activating (@code{lg})
10219 @cindex ligatures enabled register (@code{.lg})
10220 Switch the ligature mechanism on or off; if the parameter is non-zero or
10221 missing, ligatures are enabled, otherwise disabled. Default is on. The
10222 current ligature mode can be found in the read-only number register
10223 @code{.lg} (set to 1 or@tie{}2 if ligatures are enabled,
10226 Setting the ligature mode to@tie{}2 enables the two-character ligatures
10227 (fi, fl, and ff) and disables the three-character ligatures (ffi and
10231 @dfn{Pairwise kerning} is another subtle typesetting mechanism that
10232 modifies the distance between a glyph pair to improve readability. In
10233 most cases (but not always) the distance is decreased.
10235 For example, compare the combination of the letters `V' and `A'. With
10236 kerning, `VA' is printed. Without kerning it appears as `V@w{}A'.
10238 Typewriter-like fonts and fonts for terminals where all glyphs have the
10239 same width don't use kerning.
10241 @DefreqList {kern, [@Var{flag}]}
10242 @DefregListEndx {.kern}
10243 @cindex activating kerning (@code{kern})
10244 @cindex kerning, activating (@code{kern})
10245 @cindex kerning enabled register (@code{.kern})
10246 Switch kerning on or off. If the parameter is non-zero or missing,
10247 enable pairwise kerning, otherwise disable it. The read-only number
10248 register @code{.kern} is set to@tie{}1 if pairwise kerning is enabled,
10251 @cindex zero width space character (@code{\&})
10252 @cindex character, zero width space (@code{\&})
10253 @cindex space character, zero width (@code{\&})
10254 If the font description file contains pairwise kerning information,
10255 glyphs from that font are kerned. Kerning between two glyphs can be
10256 inhibited by placing @code{\&} between them: @samp{V\&A}.
10258 @xref{Font File Format}.
10261 @cindex track kerning
10262 @cindex kerning, track
10263 @dfn{Track kerning} expands or reduces the space between glyphs. This
10264 can be handy, for example, if you need to squeeze a long word onto a
10265 single line or spread some text to fill a narrow column. It must be
10266 used with great care since it is usually considered bad typography if
10267 the reader notices the effect.
10269 @Defreq {tkf, f s1 n1 s2 n2}
10270 @cindex activating track kerning (@code{tkf})
10271 @cindex track kerning, activating (@code{tkf})
10272 Enable track kerning for font@tie{}@var{f}. If the current font
10273 is@tie{}@var{f} the width of every glyph is increased by an amount
10274 between @var{n1} and @var{n2} (@var{n1}, @var{n2} can be negative); if
10275 the current point size is less than or equal to @var{s1} the width is
10276 increased by @var{n1}; if it is greater than or equal to @var{s2} the
10277 width is increased by @var{n2}; if the point size is greater than or
10278 equal to @var{s1} and less than or equal to @var{s2} the increase in
10279 width is a linear function of the point size.
10281 The default scaling indicator is @samp{z} for @var{s1} and @var{s2},
10282 @samp{p} for @var{n1} and @var{n2}.
10284 Note that the track kerning amount is added even to the rightmost glyph
10285 in a line; for large values it is thus recommended to increase the line
10286 length by the same amount to compensate it.
10289 Sometimes, when typesetting letters of different fonts, more or less
10290 space at such boundaries is needed. There are two escapes to help with
10293 @Defesc {\\/, , , }
10294 @cindex italic correction (@code{\/})
10295 @cindex correction, italic (@code{\/})
10296 @cindex correction between italic and roman glyph (@code{\/}, @code{\,})
10297 @cindex roman glyph, correction after italic glyph (@code{\/})
10298 @cindex italic glyph, correction before roman glyph (@code{\/})
10299 @cindex glyph, italic correction (@code{\/})
10300 Increase the width of the preceding glyph so that the spacing between
10301 that glyph and the following glyph is correct if the following glyph is
10302 a roman glyph. For example, if an italic@tie{}@code{f} is immediately
10303 followed by a roman right parenthesis, then in many fonts the top right
10304 portion of the@tie{}@code{f} overlaps the top left of the right
10305 parenthesis. Use this escape sequence whenever an italic glyph is
10306 immediately followed by a roman glyph without any intervening space.
10307 This small amount of space is also called @dfn{italic correction}.
10310 @c can't use @Example...@endExample here
10314 @result{} {@it f}@r{)}
10316 @result{} @i{f}@r{)}
10322 @Defesc {\\\,, , , }
10323 @cindex left italic correction (@code{\,})
10324 @cindex correction, left italic (@code{\,})
10325 @cindex glyph, left italic correction (@code{\,})
10326 @cindex roman glyph, correction before italic glyph (@code{\,})
10327 @cindex italic glyph, correction after roman glyph (@code{\,})
10328 Modify the spacing of the following glyph so that the spacing between
10329 that glyph and the preceding glyph is correct if the preceding glyph is
10330 a roman glyph. Use this escape sequence whenever a roman glyph is
10331 immediately followed by an italic glyph without any intervening space.
10332 In analogy to above, this space could be called @dfn{left italic
10333 correction}, but this term isn't used widely.
10336 @c can't use @Example...@endExample here
10340 @result{} @r{q}@i{f}
10342 @result{} @r{q}@math{@ptexcomma}@i{f}
10348 @Defesc {\\&, , , }
10349 Insert a zero-width character, which is invisible. Its intended use is
10350 to stop interaction of a character with its surroundings.
10354 It prevents the insertion of extra space after an end-of-sentence
10360 @result{} Test. Test.
10363 @result{} Test. Test.
10367 It prevents interpretation of a control character at the beginning of an
10372 @result{} warning: `Test' not defined
10378 It prevents kerning between two glyphs.
10381 @c can't use @Example...@endExample here
10387 @result{} @r{V@w{}A}
10393 It is needed to map an arbitrary character to nothing in the @code{tr}
10394 request (@pxref{Character Translations}).
10398 @Defesc {\\), , , }
10399 This escape is similar to @code{\&} except that it behaves like a
10400 character declared with the @code{cflags} request to be transparent for
10401 the purposes of an end-of-sentence character.
10403 Its main usage is in macro definitions to protect against arguments
10404 starting with a control character.
10416 @result{}This is a test.' This is a test.
10420 @result{}This is a test.' This is a test.
10425 @c =====================================================================
10427 @node Sizes, Strings, Fonts and Symbols, gtroff Reference
10433 @cindex size of type
10434 @cindex vertical spacing
10435 @cindex spacing, vertical
10436 @code{gtroff} uses two dimensions with each line of text, type size and
10437 vertical spacing. The @dfn{type size} is approximately the height of
10438 the tallest glyph.@footnote{This is usually the parenthesis. Note that
10439 in most cases the real dimensions of the glyphs in a font are @emph{not}
10440 related to its type size! For example, the standard @sc{PostScript}
10441 font families `Times Roman', `Helvetica', and `Courier' can't be used
10442 together at 10@dmn{pt}; to get acceptable output, the size of
10443 `Helvetica' has to be reduced by one point, and the size of `Courier'
10444 must be increased by one point.} @dfn{Vertical spacing} is the amount
10445 of space @code{gtroff} allows for a line of text; normally, this is
10446 about 20%@tie{}larger than the current type size. Ratios smaller than
10447 this can result in hard-to-read text; larger than this, it spreads the
10448 text out more vertically (useful for term papers). By default,
10449 @code{gtroff} uses 10@tie{}point type on 12@tie{}point spacing.
10452 The difference between type size and vertical spacing is known, by
10453 typesetters, as @dfn{leading} (this is pronounced `ledding').
10456 * Changing Type Sizes::
10457 * Fractional Type Sizes::
10460 @c ---------------------------------------------------------------------
10462 @node Changing Type Sizes, Fractional Type Sizes, Sizes, Sizes
10463 @subsection Changing Type Sizes
10465 @DefreqList {ps, [@Var{size}]}
10466 @DefreqItem {ps, @t{+}@Var{size}}
10467 @DefreqItem {ps, @t{-}@Var{size}}
10468 @DefescItemx {\\s, , size, }
10469 @DefregListEndx {.s}
10470 @cindex changing type sizes (@code{ps}, @code{\s})
10471 @cindex type sizes, changing (@code{ps}, @code{\s})
10472 @cindex point sizes, changing (@code{ps}, @code{\s})
10473 Use the @code{ps} request or the @code{\s} escape to change (increase,
10474 decrease) the type size (in points). Specify @var{size} as either an
10475 absolute point size, or as a relative change from the current size. The
10476 size@tie{}0 (for both @code{.ps} and @code{\s}), or no argument (for
10477 @code{.ps} only), goes back to the previous size.
10479 Default scaling indicator of @code{size} is @samp{z}. If @code{size} is
10480 negative, it is set to 1@dmn{u}.
10482 @cindex type size registers (@code{.s}, @code{.ps})
10483 @cindex point size registers (@code{.s}, @code{.ps})
10484 The read-only number register @code{.s} returns the point size in points
10485 as a decimal fraction. This is a string. To get the point size in
10486 scaled points, use the @code{.ps} register instead.
10488 @code{.s} is associated with the current environment
10489 (@pxref{Environments}).
10496 wink, wink, \s+2nudge, nudge,\s+8 say no more!
10500 The @code{\s} escape may be called in a variety of ways. Much like
10501 other escapes there must be a way to determine where the argument ends
10502 and the text begins. Any of the following forms are valid:
10506 Set the point size to @var{n}@tie{}points. @var{n}@tie{}must be either
10507 0 or in the range 4 to@tie{}39.
10511 Increase or decrease the point size by @var{n}@tie{}points.
10512 @var{n}@tie{}must be exactly one digit.
10515 Set the point size to @var{nn}@tie{}points. @var{nn} must be exactly
10519 @itemx \s-(@var{nn}
10520 @itemx \s(+@var{nn}
10521 @itemx \s(-@var{nn}
10522 Increase or decrease the point size by @var{nn}@tie{}points. @var{nn}
10523 must be exactly two digits.
10526 Note that @code{\s} doesn't produce an input token in @code{gtroff}. As
10527 a consequence, it can be used in requests like @code{mc} (which expects
10528 a single character as an argument) to change the font on the fly:
10534 @xref{Fractional Type Sizes}, for yet another syntactical form of using
10535 the @code{\s} escape.
10538 @Defreq {sizes, s1 s2 @dots{} sn [0]}
10539 Some devices may only have certain permissible sizes, in which case
10540 @code{gtroff} rounds to the nearest permissible size. The @file{DESC}
10541 file specifies which sizes are permissible for the device.
10543 Use the @code{sizes} request to change the permissible sizes for the
10544 current output device. Arguments are in scaled points; the
10545 @code{sizescale} line in the @file{DESC} file for the output device
10546 provides the scaling factor. For example, if the scaling factor is
10547 1000, then the value 12000 is 12@tie{}points.
10549 Each argument can be a single point size (such as @samp{12000}), or a
10550 range of sizes (such as @samp{4000-72000}). You can optionally end the
10554 @DefreqList {vs, [@Var{space}]}
10555 @DefreqItem {vs, @t{+}@Var{space}}
10556 @DefreqItem {vs, @t{-}@Var{space}}
10557 @DefregListEndx {.v}
10558 @cindex changing vertical line spacing (@code{vs})
10559 @cindex vertical line spacing, changing (@code{vs})
10560 @cindex vertical line spacing register (@code{.v})
10561 Change (increase, decrease) the vertical spacing by @var{space}. The
10562 default scaling indicator is @samp{p}.
10564 If @code{vs} is called without an argument, the vertical spacing is
10565 reset to the previous value before the last call to @code{vs}.
10567 @cindex @code{.V} register, and @code{vs}
10568 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
10569 negative; the vertical spacing is then set to smallest positive value,
10570 the vertical resolution (as given in the @code{.V} register).
10572 Note that @w{@samp{.vs 0}} isn't saved in a diversion since it doesn't
10573 result in a vertical motion. You explicitly have to repeat this command
10574 before inserting the diversion.
10576 The read-only number register @code{.v} contains the current vertical
10577 spacing; it is associated with the current environment
10578 (@pxref{Environments}).
10581 @cindex vertical line spacing, effective value
10582 The effective vertical line spacing consists of four components.
10583 Breaking a line causes the following actions (in the given order).
10587 @cindex extra pre-vertical line space (@code{\x})
10588 @cindex line space, extra pre-vertical (@code{\x})
10589 Move the current point vertically by the @dfn{extra pre-vertical line
10590 space}. This is the minimum value of all @code{\x} escapes with a
10591 negative argument in the current output line.
10594 Move the current point vertically by the vertical line spacing as set
10595 with the @code{vs} request.
10598 Output the current line.
10601 @cindex extra post-vertical line space (@code{\x})
10602 @cindex line space, extra post-vertical (@code{\x})
10603 Move the current point vertically by the @dfn{extra post-vertical line
10604 space}. This is the maximum value of all @code{\x} escapes with a
10605 positive argument in the line that has just been output.
10608 @cindex post-vertical line spacing
10609 @cindex line spacing, post-vertical (@code{pvs})
10610 Move the current point vertically by the @dfn{post-vertical line
10611 spacing} as set with the @code{pvs} request.
10614 @cindex double-spacing (@code{vs}, @code{pvs})
10615 It is usually better to use @code{vs} or @code{pvs} instead of @code{ls}
10616 to produce double-spaced documents: @code{vs} and @code{pvs} have a
10617 finer granularity for the inserted vertical space compared to @code{ls};
10618 furthermore, certain preprocessors assume single-spacing.
10620 @xref{Manipulating Spacing}, for more details on the @code{\x} escape
10621 and the @code{ls} request.
10623 @DefreqList {pvs, [@Var{space}]}
10624 @DefreqItem {pvs, @t{+}@Var{space}}
10625 @DefreqItem {pvs, @t{-}@Var{space}}
10626 @DefregListEndx {.pvs}
10627 @cindex @code{ls} request, alternative to (@code{pvs})
10628 @cindex post-vertical line spacing, changing (@code{pvs})
10629 @cindex post-vertical line spacing register (@code{.pvs})
10630 Change (increase, decrease) the post-vertical spacing by @var{space}.
10631 The default scaling indicator is @samp{p}.
10633 If @code{pvs} is called without an argument, the post-vertical spacing
10634 is reset to the previous value before the last call to @code{pvs}.
10636 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
10637 zero or negative; the vertical spacing is then set to zero.
10639 The read-only number register @code{.pvs} contains the current
10640 post-vertical spacing; it is associated with the current environment
10641 (@pxref{Environments}).
10644 @c ---------------------------------------------------------------------
10646 @node Fractional Type Sizes, , Changing Type Sizes, Sizes
10647 @subsection Fractional Type Sizes
10648 @cindex fractional type sizes
10649 @cindex fractional point sizes
10650 @cindex type sizes, fractional
10651 @cindex point sizes, fractional
10652 @cindex sizes, fractional
10654 @cindex @code{s} unit
10655 @cindex unit, @code{s}
10656 @cindex @code{z} unit
10657 @cindex unit, @code{z}
10658 @cindex @code{ps} request, with fractional type sizes
10659 @cindex @code{cs} request, with fractional type sizes
10660 @cindex @code{tkf} request, with fractional type sizes
10661 @cindex @code{\H}, with fractional type sizes
10662 @cindex @code{\s}, with fractional type sizes
10663 A @dfn{scaled point} is equal to @math{1/@var{sizescale}} points, where
10664 @var{sizescale} is specified in the @file{DESC} file (1@tie{}by
10665 default). There is a new scale indicator @samp{z}, which has the effect
10666 of multiplying by @var{sizescale}. Requests and escape sequences in
10667 @code{gtroff} interpret arguments that represent a point size as being
10668 in units of scaled points, but they evaluate each such argument using a
10669 default scale indicator of @samp{z}. Arguments treated in this way are
10670 the argument to the @code{ps} request, the third argument to the
10671 @code{cs} request, the second and fourth arguments to the @code{tkf}
10672 request, the argument to the @code{\H} escape sequence, and those
10673 variants of the @code{\s} escape sequence that take a numeric expression
10674 as their argument (see below).
10676 For example, suppose @var{sizescale} is@tie{}1000; then a scaled point
10677 is equivalent to a millipoint; the request @w{@samp{.ps 10.25}} is
10678 equivalent to @w{@samp{.ps 10.25z}} and thus sets the point size to
10679 10250@tie{}scaled points, which is equal to 10.25@tie{}points.
10681 @code{gtroff} disallows the use of the @samp{z} scale indicator in
10682 instances where it would make no sense, such as a numeric expression
10683 whose default scale indicator was neither @samp{u} nor @samp{z}.
10684 Similarly it would make no sense to use a scaling indicator other than
10685 @samp{z} or @samp{u} in a numeric expression whose default scale
10686 indicator was @samp{z}, and so @code{gtroff} disallows this as well.
10688 There is also new scale indicator @samp{s}, which multiplies by the
10689 number of units in a scaled point. So, for example, @samp{\n[.ps]s} is
10690 equal to @samp{1m}. Be sure not to confuse the @samp{s} and @samp{z}
10694 A read-only number register returning the point size in scaled points.
10696 @code{.ps} is associated with the current environment
10697 (@pxref{Environments}).
10701 @DefregListEndx {.sr}
10702 @cindex last-requested point size registers (@code{.psr}, @code{.sr})
10703 @cindex point size registers, last-requested (@code{.psr}, @code{.sr})
10704 @cindex @code{.ps} register, in comparison with @code{.psr}
10705 @cindex @code{.s} register, in comparison with @code{.sr}
10706 The last-requested point size in scaled points is contained in the
10707 @code{.psr} read-only number register. The last requested point size in
10708 points as a decimal fraction can be found in @code{.sr}. This is a
10709 string-valued read-only number register.
10711 Note that the requested point sizes are device-independent, whereas the
10712 values returned by the @code{.ps} and @code{.s} registers are not. For
10713 example, if a point size of 11@dmn{pt} is requested, and a @code{sizes}
10714 request (or a @code{sizescale} line in a @file{DESC} file) specifies
10715 10.95@dmn{pt} instead, this value is actually used.
10717 Both registers are associated with the current environment
10718 (@pxref{Environments}).
10721 The @code{\s} escape has the following syntax for working with
10722 fractional type sizes:
10727 Set the point size to @var{n}@tie{}scaled points; @var{n}@tie{}is a
10728 numeric expression with a default scale indicator of @samp{z}.
10731 @itemx \s[-@var{n}]
10732 @itemx \s+[@var{n}]
10733 @itemx \s-[@var{n}]
10734 @itemx \s'+@var{n}'
10735 @itemx \s'-@var{n}'
10736 @itemx \s+'@var{n}'
10737 @itemx \s-'@var{n}'
10738 Increase or decrease the point size by @var{n}@tie{}scaled points;
10739 @var{n}@tie{}is a numeric expression (which may start with a minus sign)
10740 with a default scale indicator of @samp{z}.
10746 @c =====================================================================
10748 @node Strings, Conditionals and Loops, Sizes, gtroff Reference
10752 @code{gtroff} has string variables, which are entirely for user
10753 convenience (i.e.@: there are no built-in strings except @code{.T}, but
10754 even this is a read-write string variable).
10756 Although the following requests can be used to create strings,
10757 simply using an undefined string will cause it to be defined as empty.
10758 @xref{Identifiers}.
10760 @DefreqList {ds, name [@Var{string}]}
10761 @DefreqItemx {ds1, name [@Var{string}]}
10762 @DefescItemx {\\*, , n, }
10763 @DefescItem {\\*, @Lparen{}, nm, }
10764 @DefescListEnd {\\*, @Lbrack{}, name arg1 arg2 @dots{}, @Rbrack{}}
10765 @cindex string interpolation (@code{\*})
10766 @cindex string expansion (@code{\*})
10767 @cindex interpolation of strings (@code{\*})
10768 @cindex expansion of strings (@code{\*})
10769 @cindex string arguments
10770 @cindex arguments, of strings
10771 Define and access a string variable @var{name} (one-character
10772 name@tie{}@var{n}, two-character name @var{nm}). If @var{name} already
10773 exists, @code{ds} overwrites the previous definition. Only the syntax
10774 form using brackets can take arguments that are handled identically to
10775 macro arguments; the single exception is that a closing bracket as an
10776 argument must be enclosed in double quotes. @xref{Request and Macro
10777 Arguments}, and @ref{Parameters}.
10782 .ds foo a \\$1 test
10784 This is \*[foo nice].
10785 @result{} This is a nice test.
10788 The @code{\*} escape @dfn{interpolates} (expands in-place) a
10789 previously defined string variable. To be more precise, the stored
10790 string is pushed onto the input stack, which is then parsed by
10791 @code{gtroff}. Similar to number registers, it is possible to nest
10792 strings, i.e., string variables can be called within string variables.
10794 If the string named by the @code{\*} escape does not exist, it is
10795 defined as empty, and a warning of type @samp{mac} is emitted (see
10796 @ref{Debugging}, for more details).
10798 @cindex comments, with @code{ds}
10799 @cindex @code{ds} request, and comments
10800 @strong{Caution:} Unlike other requests, the second argument to the
10801 @code{ds} request takes up the entire line including trailing spaces.
10802 This means that comments on a line with such a request can introduce
10803 unwanted space into a string.
10806 .ds TeX T\h'-.2m'\v'.2m'E\v'-.2m'\h'-.1m'X \" Knuth's TeX
10810 Instead the comment should be put on another line or have the comment
10811 escape adjacent with the end of the string.
10814 .ds TeX T\h'-.2m'\v'.2m'E\v'-.2m'\h'-.1m'X\" Knuth's TeX
10817 @cindex trailing quotes
10818 @cindex quotes, trailing
10819 @cindex leading spaces with @code{ds}
10820 @cindex spaces with @code{ds}
10821 @cindex @code{ds} request, and leading spaces
10822 To produce leading space the string can be started with a double quote.
10823 No trailing quote is needed; in fact, any trailing quote is included in
10827 .ds sign " Yours in a white wine sauce,
10830 @cindex multi-line strings
10831 @cindex strings, multi-line
10832 @cindex newline character, in strings, escaping
10833 @cindex escaping newline characters, in strings
10834 Strings are not limited to a single line of text. A string can span
10835 several lines by escaping the newlines with a backslash. The resulting
10836 string is stored @emph{without} the newlines.
10839 .ds foo lots and lots \
10840 of text are on these \
10844 It is not possible to have real newlines in a string. To put a single
10845 double quote character into a string, use two consecutive double quote
10848 The @code{ds1} request turns off compatibility mode while interpreting a
10849 string. To be more precise, a @dfn{compatibility save} input token is
10850 inserted at the beginning of the string, and a @dfn{compatibility
10851 restore} input token at the end.
10855 .ds aa The value of xxx is \\n[xxx].
10856 .ds1 bb The value of xxx is \\n[xxx].
10861 @result{} warning: number register `[' not defined
10862 @result{} The value of xxx is 0xxx].
10864 @result{} The value of xxx is 12345.
10867 @cindex name space, common, of macros, diversions, and strings
10868 @cindex common name space of macros, diversions, and strings
10869 @cindex macros, shared name space with strings and diversions
10870 @cindex strings, shared name space with macros and diversions
10871 @cindex diversions, shared name space with macros and strings
10872 Strings, macros, and diversions (and boxes) share the same name space.
10873 Internally, even the same mechanism is used to store them. This has
10874 some interesting consequences. For example, it is possible to call a
10875 macro with string syntax and vice versa.
10882 @result{} This is a funny test.
10884 .ds yyy a funny test
10887 @result{} This is a funny test.
10890 In particular, interpolating a string does not hide existing macro
10891 arguments. Thus in a macro, a more efficient way of doing
10905 Note that the latter calling syntax doesn't change the value of
10906 @code{\$0}, which is then inherited from the calling macro.
10908 Diversions and boxes can be also called with string syntax.
10910 Another consequence is that you can copy one-line diversions or boxes to
10918 .ds yyy This is \*[xxx]\c
10920 @result{} @r{This is a }@i{test}.
10924 As the previous example shows, it is possible to store formatted output
10925 in strings. The @code{\c} escape prevents the insertion of an
10926 additional blank line in the output.
10928 Copying diversions longer than a single output line produces unexpected
10938 .ds yyy This is \*[xxx]\c
10940 @result{} test This is a funny.
10943 Usually, it is not predictable whether a diversion contains one or more
10944 output lines, so this mechanism should be avoided. With Unix
10945 @code{troff}, this was the only solution to strip off a final newline
10946 from a diversion. Another disadvantage is that the spaces in the copied
10947 string are already formatted, making them unstretchable. This can cause
10950 @cindex stripping final newline in diversions
10951 @cindex diversion, stripping final newline
10952 @cindex final newline, stripping in diversions
10953 @cindex newline, final, stripping in diversions
10954 @cindex horizontal space, unformatting
10955 @cindex space, horizontal, unformatting
10956 @cindex unformatting horizontal space
10957 A clean solution to this problem is available in GNU @code{troff}, using
10958 the requests @code{chop} to remove the final newline of a diversion, and
10959 @code{unformat} to make the horizontal spaces stretchable again.
10971 @result{} This is a funny test.
10974 @xref{Gtroff Internals}, for more information.
10977 @DefreqList {as, name [@Var{string}]}
10978 @DefreqListEndx {as1, name [@Var{string}]}
10979 @cindex appending to a string (@code{as})
10980 @cindex string, appending (@code{as})
10981 The @code{as} request is similar to @code{ds} but appends @var{string}
10982 to the string stored as @var{name} instead of redefining it. If
10983 @var{name} doesn't exist yet, it is created.
10986 .as sign " with shallots, onions and garlic,
10989 The @code{as1} request is similar to @code{as}, but compatibility mode
10990 is switched off while the appended string is interpreted. To be more
10991 precise, a @dfn{compatibility save} input token is inserted at the
10992 beginning of the appended string, and a @dfn{compatibility restore}
10993 input token at the end.
10996 Rudimentary string manipulation routines are given with the next two
10999 @Defreq {substring, str n1 [@Var{n2}]}
11000 @cindex substring (@code{substring})
11001 Replace the string named @var{str} with the substring defined by the
11002 indices @var{n1} and @var{n2}. The first character in the string has
11003 index@tie{}0. If @var{n2} is omitted, it is implicitly set to the
11004 largest valid value (the string length minus one). If the index value
11005 @var{n1} or @var{n2} is negative, it is counted from the end of the
11006 string, going backwards: The last character has index@tie{}@minus{}1,
11007 the character before the last character has index@tie{}@minus{}2, etc.
11011 .substring xxx 1 -4
11020 @Defreq {length, reg str}
11021 @cindex length of a string (@code{length})
11022 @cindex string, length of (@code{length})
11023 @cindex @code{length} request, and copy-in mode
11024 @cindex copy-in mode, and @code{length} request
11025 @cindex mode, copy-in, and @code{length} request
11026 Compute the number of characters of @var{str} and return it in the
11027 number register @var{reg}. If @var{reg} doesn't exist, it is created.
11028 @code{str} is read in copy mode.
11031 .ds xxx abcd\h'3i'efgh
11032 .length yyy \*[xxx]
11038 @Defreq {rn, xx yy}
11039 @cindex renaming request (@code{rn})
11040 @cindex request, renaming (@code{rn})
11041 @cindex renaming macro (@code{rn})
11042 @cindex macro, renaming (@code{rn})
11043 @cindex renaming string (@code{rn})
11044 @cindex string, renaming (@code{rn})
11045 @cindex renaming diversion (@code{rn})
11046 @cindex diversion, renaming (@code{rn})
11047 Rename the request, macro, diversion, or string @var{xx} to @var{yy}.
11051 @cindex removing request (@code{rm})
11052 @cindex request, removing (@code{rm})
11053 @cindex removing macro (@code{rm})
11054 @cindex macro, removing (@code{rm})
11055 @cindex removing string (@code{rm})
11056 @cindex string, removing (@code{rm})
11057 @cindex removing diversion (@code{rm})
11058 @cindex diversion, removing (@code{rm})
11059 Remove the request, macro, diversion, or string @var{xx}. @code{gtroff}
11060 treats subsequent invocations as if the object had never been defined.
11064 @Defreq {als, new old}
11065 @cindex alias, string, creating (@code{als})
11066 @cindex alias, macro, creating (@code{als})
11067 @cindex alias, diversion, creating (@code{als})
11068 @cindex creating alias, for string (@code{als})
11069 @cindex creating alias, for macro (@code{als})
11070 @cindex creating alias, for diversion (@code{als})
11071 @cindex string, creating alias (@code{als})
11072 @cindex macro, creating alias (@code{als})
11073 @cindex diversion, creating alias (@code{als})
11074 Create an alias named @var{new} for the request, string, macro, or
11075 diversion object named @var{old}. The new name and the old name are
11076 exactly equivalent (it is similar to a hard rather than a soft link). If
11077 @var{old} is undefined, @code{gtroff} generates a warning of type
11078 @samp{mac} and ignores the request.
11080 To understand how the @code{als} request works it is probably best to
11081 think of two different pools: one pool for objects (macros, strings,
11082 etc.), and another one for names. As soon as an object is defined,
11083 @code{gtroff} adds it to the object pool, adds its name to the name
11084 pool, and creates a link between them. When @code{als} creates an
11085 alias, it adds a new name to the name pool that gets linked to the same
11086 object as the old name.
11088 Now consider this example.
11101 @result{} input stack limit exceeded
11105 The definition of macro @code{bar} replaces the old object this name is
11106 linked to. However, the alias to @code{foo} is still active! In
11107 other words, @code{foo} is still linked to the same object as
11108 @code{bar}, and the result of calling @code{bar} is an infinite,
11109 recursive loop that finally leads to an error.
11111 @cindex alias, string, removing (@code{rm})
11112 @cindex alias, macro, removing (@code{rm})
11113 @cindex alias, diversion, removing (@code{rm})
11114 @cindex removing alias, for string (@code{rm})
11115 @cindex removing alias, for macro (@code{rm})
11116 @cindex removing alias, for diversion (@code{rm})
11117 @cindex string, removing alias (@code{rm})
11118 @cindex macro, removing alias (@code{rm})
11119 @cindex diversion, removing alias (@code{rm})
11120 To undo an alias, simply call @code{rm} on the aliased name. The object
11121 itself is not destroyed until there are no more aliases.
11125 Remove (chop) the last character from the macro, string, or diversion
11126 named @var{xx}. This is useful for removing the newline from the end of
11127 diversions that are to be interpolated as strings. This command can be
11128 used repeatedly; see @ref{Gtroff Internals}, for details on nodes
11129 inserted additionally by @code{gtroff}.
11132 @xref{Identifiers}, and @ref{Comments}.
11135 @c =====================================================================
11137 @node Conditionals and Loops, Writing Macros, Strings, gtroff Reference
11138 @section Conditionals and Loops
11139 @cindex conditionals and loops
11140 @cindex loops and conditionals
11143 * Operators in Conditionals::
11148 @c ---------------------------------------------------------------------
11150 @node Operators in Conditionals, if-else, Conditionals and Loops, Conditionals and Loops
11151 @subsection Operators in Conditionals
11153 @cindex @code{if} request, operators to use with
11154 @cindex @code{ie} request, operators to use with
11155 @cindex @code{while} request, operators to use with
11156 In @code{if}, @code{ie}, and @code{while} requests, in addition to ordinary
11157 @ref{Expressions}, there are several more operators available:
11162 True if the current page is even or odd numbered (respectively).
11165 @cindex conditional output for terminal (TTY)
11166 @cindex TTY, conditional output for
11167 @cindex terminal, conditional output for
11168 True if the document is being processed in nroff mode (i.e., the
11169 @code{.nroff} command has been issued). @xref{Troff and Nroff Mode}.
11172 True if the document is being processed in troff mode (i.e., the
11173 @code{.troff} command has been issued). @xref{Troff and Nroff Mode}.
11176 Always false. This condition is for compatibility with other
11177 @code{troff} versions only (identifying a @code{-Tversatec} device).
11179 @item '@var{xxx}'@var{yyy}'
11180 True if the output produced by @var{xxx} is equal to the output produced
11181 by @var{yyy}. Other characters can be used in place of the single
11182 quotes; the same set of delimiters as for the @code{\D} escape is used
11183 (@pxref{Escapes}). @code{gtroff} formats @var{xxx} and @var{yyy} in
11184 separate environments; after the comparison the resulting data is
11196 The resulting motions, glyph sizes, and fonts have to
11197 match,@footnote{The created output nodes must be identical.
11198 @xref{Gtroff Internals}.} and not the individual motion, size, and font
11199 requests. In the previous example, @samp{|} and @samp{\fR|\fP} both
11200 result in a roman @samp{|} glyph with the same point size and at the
11201 same location on the page, so the strings are equal. If
11202 @samp{.ft@tie{}I} had been added before the @samp{.ie}, the result would
11203 be ``false'' because (the first) @samp{|} produces an italic @samp{|}
11204 rather than a roman one.
11206 @cindex string comparison
11207 @cindex comparison of strings
11208 To compare strings without processing, surround the data with @code{\?}.
11211 .ie "\?|\?"\?\fR|\fP\?" \
11218 @cindex @code{\?}, and copy-in mode
11219 @cindex copy-in mode, and @code{\?}
11220 @cindex mode, copy-in, and @code{\?}
11222 Since data protected with @code{\?} is read in copy-in mode it is even
11223 possible to use incomplete input without causing an error.
11228 .ie '\?\*a\?'\?\*b\?' \
11236 True if there is a number register named @var{xxx}.
11239 True if there is a string, macro, diversion, or request named @var{xxx}.
11242 True if there is a color named @var{xxx}.
11245 True if there is a glyph @var{g} available@footnote{The name of this
11246 conditional operator is a misnomer since it tests names of output
11247 glyphs.}; @var{g} is either an @acronym{ASCII} character or a special
11248 character (@code{\N'@var{xxx}'}, @code{\(@var{gg}} or
11249 @code{\[@var{ggg}]}); the condition is also true if @var{g} has been
11250 defined by the @code{char} request.
11253 True if a font named @var{font} exists. @var{font} is handled as if it
11254 was opened with the @code{ft} request (that is, font translation and
11255 styles are applied), without actually mounting it.
11257 This test doesn't load the complete font but only its header to verify
11260 @item S @var{style}
11261 True if style @var{style} has been registered. Font translation is
11265 Note that these operators can't be combined with other operators like
11266 @samp{:} or @samp{&}; only a leading @samp{!} (without whitespace
11267 between the exclamation mark and the operator) can be used to negate the
11279 A whitespace after @samp{!} always evaluates to zero (this bizarre
11280 behaviour is due to compatibility with Unix @code{troff}).
11288 @result{} r xxx true
11291 It is possible to omit the whitespace before the argument to the
11292 @samp{r}, @samp{d}, and @samp{c} operators.
11294 @xref{Expressions}.
11296 @c ---------------------------------------------------------------------
11298 @node if-else, while, Operators in Conditionals, Conditionals and Loops
11299 @subsection if-else
11302 @code{gtroff} has if-then-else constructs like other languages, although
11303 the formatting can be painful.
11305 @Defreq {if, expr anything}
11307 Evaluate the expression @var{expr}, and executes @var{anything} (the
11308 remainder of the line) if @var{expr} evaluates to a value greater than
11309 zero (true). @var{anything} is interpreted as though it was on a line
11310 by itself (except that leading spaces are swallowed).
11311 @xref{Operators in Conditionals}, for more info.
11316 .if ((\n[xxx] == 1) & (\n[yyy] == 2)) true
11321 @Defreq {nop, anything}
11322 Executes @var{anything}. This is similar to @code{.if@tie{}1}.
11325 @DefreqList {ie, expr anything}
11326 @DefreqListEndx {el, anything}
11327 Use the @code{ie} and @code{el} requests to write an if-then-else. The
11328 first request is the `if' part and the latter is the `else' part.
11331 .ie n .ls 2 \" double-spacing in nroff
11332 .el .ls 1 \" single-spacing in troff
11336 @c there is a bug in makeinfo <= 4.1a: you can't have `@{' as an argument
11339 @c and in 4.2 you still can't use @{ in macros.
11341 @c @DefescList {\@{, , , }
11342 @c @DefescListEnd {\@}, , , }
11343 @deffn Escape @t{\@{}
11344 @deffnx Escape @t{\@}}
11347 @cindex begin of conditional block (@code{\@{})
11348 @cindex end of conditional block (@code{\@}})
11349 @cindex conditional block, begin (@code{\@{})
11350 @cindex conditional block, end (@code{\@}})
11351 @cindex block, conditional, begin (@code{\@{})
11352 @cindex block, conditional, end (@code{\@}})
11353 In many cases, an if (or if-else) construct needs to execute more than
11354 one request. This can be done using the escapes @code{\@{} (which must
11355 start the first line) and @code{\@}} (which must end the last line).
11370 @xref{Expressions}.
11372 @c ---------------------------------------------------------------------
11374 @node while, , if-else, Conditionals and Loops
11378 @code{gtroff} provides a looping construct using the @code{while}
11379 request, which is used much like the @code{if} (and related) requests.
11381 @Defreq {while, expr anything}
11382 Evaluate the expression @var{expr}, and repeatedly execute
11383 @var{anything} (the remainder of the line) until @var{expr} evaluates
11388 .while (\na < 9) \@{\
11392 @result{} 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
11397 @cindex @code{de} request, and @code{while}
11400 The body of a @code{while} request is treated like the body of a
11401 @code{de} request: @code{gtroff} temporarily stores it in a macro that
11402 is deleted after the loop has been exited. It can considerably slow
11403 down a macro if the body of the @code{while} request (within the macro)
11404 is large. Each time the macro is executed, the @code{while} body is
11405 parsed and stored again as a temporary macro.
11410 . while (\\n[num] > 0) \@{\
11411 . \" many lines of code
11417 @cindex recursive macros
11418 @cindex macros, recursive
11420 The traditional and often better solution (Unix @code{troff} doesn't
11421 have the @code{while} request) is to use a recursive macro instead that
11422 is parsed only once during its definition.
11426 . if (\\n[num] > 0) \@{\
11427 . \" many lines of code
11440 Note that the number of available recursion levels is set to@tie{}1000
11441 (this is a compile-time constant value of @code{gtroff}).
11444 The closing brace of a @code{while} body must end a line.
11449 . while (\n[a] < 10) \@{\
11452 @result{} unbalanced \@{ \@}
11458 @cindex @code{while} request, confusing with @code{br}
11459 @cindex @code{break} request, in a @code{while} loop
11460 @cindex @code{continue} request, in a @code{while} loop
11461 Break out of a @code{while} loop. Be sure not to confuse this with the
11462 @code{br} request (causing a line break).
11465 @Defreq {continue, }
11466 Finish the current iteration of a @code{while} loop, immediately
11467 restarting the next iteration.
11470 @xref{Expressions}.
11473 @c =====================================================================
11475 @node Writing Macros, Page Motions, Conditionals and Loops, gtroff Reference
11476 @section Writing Macros
11477 @cindex writing macros
11478 @cindex macros, writing
11480 A @dfn{macro} is a collection of text and embedded commands that can be
11481 invoked multiple times. Use macros to define common operations.
11482 @xref{Strings}, for a (limited) alternative syntax to call macros.
11484 Although the following requests can be used to create macros,
11485 simply using an undefined macro will cause it to be defined as empty.
11486 @xref{Identifiers}.
11488 @DefreqList {de, name [@Var{end}]}
11489 @DefreqItemx {de1, name [@Var{end}]}
11490 @DefreqItemx {dei, name [@Var{end}]}
11491 @DefreqListEndx {dei1, name [@Var{end}]}
11492 Define a new macro named @var{name}. @code{gtroff} copies subsequent
11493 lines (starting with the next one) into an internal buffer until it
11494 encounters the line @samp{..} (two dots). If the optional second
11495 argument to @code{de} is present it is used as the macro closure
11496 request instead of @samp{..}.
11498 There can be whitespace after the first dot in the line containing the
11499 ending token (either @samp{.} or macro @samp{@var{end}}). Don't insert
11500 a tab character immediately after the @samp{..}, otherwise it isn't
11501 recognized as the end-of-macro symbol.@footnote{While it is possible to
11502 define and call a macro @samp{.} with
11509 .. \" This calls macro `.'!
11513 you can't use this as the end-of-macro macro: during a macro definition,
11514 @samp{..} is never handled as a call to @samp{.}, even if you say
11515 @samp{.de foo .} explicitly.}
11517 Here a small example macro called @samp{P} that causes a break and
11518 inserts some vertical space. It could be used to separate paragraphs.
11527 The following example defines a macro within another. Remember that
11528 expansion must be protected twice; once for reading the macro and once
11532 \# a dummy macro to avoid a warning
11538 . nop \f[B]Hello \\\\$1!\f[]
11544 @result{} @b{Hello Joe!}
11548 Since @code{\f} has no expansion, it isn't necessary to protect its
11549 backslash. Had we defined another macro within @code{bar} that takes a
11550 parameter, eight backslashes would be necessary before @samp{$1}.
11552 The @code{de1} request turns off compatibility mode while executing the
11553 macro. On entry, the current compatibility mode is saved and restored
11560 The value of xxx is \\n[xxx].
11563 The value of xxx is \\n[xxx].
11569 @result{} warning: number register `[' not defined
11570 @result{} The value of xxx is 0xxx].
11572 @result{} The value of xxx is 12345.
11575 The @code{dei} request defines a macro indirectly. That is, it expands
11576 strings whose names are @var{name} or @var{end} before performing the
11594 The @code{dei1} request is similar to @code{dei} but with compatibility
11595 mode switched off during execution of the defined macro.
11597 If compatibility mode is on, @code{de} (and @code{dei}) behave similar
11598 to @code{de1} (and @code{dei1}): A `compatibility save' token is
11599 inserted at the beginning, and a `compatibility restore' token at the
11600 end, with compatibility mode switched on during execution. @xref{Gtroff
11601 Internals}, for more information on switching compatibility mode on and
11602 off in a single document.
11605 Using @file{trace.tmac}, you can trace calls to @code{de} and
11608 Note that macro identifiers are shared with identifiers for strings and
11611 @xref{als,,the description of the @code{als} request}, for possible
11612 pitfalls if redefining a macro that has been aliased.
11615 @DefreqList {am, name [@Var{end}]}
11616 @DefreqItemx {am1, name [@Var{end}]}
11617 @DefreqItemx {ami, name [@Var{end}]}
11618 @DefreqListEndx {ami1, name [@Var{end}]}
11619 @cindex appending to a macro (@code{am})
11620 @cindex macro, appending (@code{am})
11621 Works similarly to @code{de} except it appends onto the macro named
11622 @var{name}. So, to make the previously defined @samp{P} macro actually
11623 do indented instead of block paragraphs, add the necessary code to the
11624 existing macro like this:
11632 The @code{am1} request turns off compatibility mode while executing the
11633 appended macro piece. To be more precise, a @dfn{compatibility save}
11634 input token is inserted at the beginning of the appended code, and a
11635 @dfn{compatibility restore} input token at the end.
11637 The @code{ami} request appends indirectly, meaning that @code{gtroff}
11638 expands strings whose names are @var{name} or @var{end} before
11639 performing the append.
11641 The @code{ami1} request is similar to @code{ami} but compatibility mode
11642 is switched off during execution of the defined macro.
11645 Using @file{trace.tmac}, you can trace calls to @code{am} and
11649 @xref{Strings}, for the @code{als} and @code{rn} request to create an
11650 alias and rename a macro, respectively.
11652 The @code{de}, @code{am}, @code{di}, @code{da}, @code{ds}, and @code{as}
11653 requests (together with their variants) only create a new object if the
11654 name of the macro, diversion or string is currently undefined
11655 or if it is defined to be a request; normally they modify the value of
11656 an existing object.
11658 @Defreq {return, [@Var{anything}]}
11659 Exit a macro, immediately returning to the caller.
11661 If called with an argument, exit twice, namely the current macro and the
11662 macro one level higher. This is used to define a wrapper macro for
11663 @code{return} in @file{trace.tmac}.
11671 @c ---------------------------------------------------------------------
11673 @node Copy-in Mode, Parameters, Writing Macros, Writing Macros
11674 @subsection Copy-in Mode
11676 @cindex copy-in mode
11678 @cindex mode, copy-in
11680 @cindex @code{\n}, when reading text for a macro
11681 @cindex @code{\$}, when reading text for a macro
11682 @cindex @code{\*}, when reading text for a macro
11683 @cindex @code{\\}, when reading text for a macro
11684 @cindex \@key{RET}, when reading text for a macro
11685 When @code{gtroff} reads in the text for a macro, string, or diversion,
11686 it copies the text (including request lines, but excluding escapes) into
11687 an internal buffer.
11688 Escapes are converted into an internal form, except for @code{\n},
11689 @code{\$}, @code{\*}, @code{\\} and @code{\@key{RET}}, which are evaluated
11690 and inserted into the text where the escape was located.
11691 This is known as @dfn{copy-in} mode or @dfn{copy} mode.
11693 What this means is that you can specify when these escapes are to be
11694 evaluated (either at copy-in time or at the time of use) by insulating
11695 the escapes with an extra backslash. Compare this to the @code{\def}
11696 and @code{\edef} commands in @TeX{}.
11698 The following example prints the numbers 20 and@tie{}10:
11710 @c ---------------------------------------------------------------------
11712 @node Parameters, , Copy-in Mode, Writing Macros
11713 @subsection Parameters
11716 The arguments to a macro or string can be examined using a variety of
11720 @cindex number of arguments register (@code{.$})
11721 The number of arguments passed to a macro or string. This is a
11722 read-only number register.
11724 Note that the @code{shift} request can change its value.
11727 Any individual argument can be retrieved with one of the following
11730 @DefescList {\\$, , n, }
11731 @DefescItem {\\$, @Lparen{}, nn, }
11732 @DefescListEnd {\\$, @Lbrack{}, nnn, @Rbrack{}}
11733 @cindex copy-in mode, and macro arguments
11734 @cindex mode, copy-in, and macro arguments
11735 @cindex macro, arguments (@code{\$})
11736 @cindex arguments, macro (@code{\$})
11737 Retrieve the @var{n}@dmn{th}, @var{nn}@dmn{th} or @var{nnn}@dmn{th}
11738 argument. As usual, the first form only accepts a single number (larger
11739 than zero), the second a two-digit number (larger or equal to@tie{}10),
11740 and the third any positive integer value (larger than zero). Macros and
11741 strings can have an unlimited number of arguments. Note that due to
11742 copy-in mode, use two backslashes on these in actual use to prevent
11743 interpolation until the macro is actually invoked.
11746 @Defreq {shift, [@Var{n}]}
11747 Shift the arguments 1@tie{}position, or as many positions as specified
11748 by its argument. After executing this request, argument@tie{}@var{i}
11749 becomes argument @math{@var{i}-@var{n}}; arguments 1 to@tie{}@var{n} are
11750 no longer available. Shifting by negative amounts is currently
11753 The register @code{.$} is adjusted accordingly.
11756 @DefescList {\\$*, , , }
11757 @DefescListEndx {\\$@@, , , }
11758 In some cases it is convenient to use all of the arguments at once (for
11759 example, to pass the arguments along to another macro). The @code{\$*}
11760 escape concatenates all the arguments separated by spaces. A similar
11761 escape is @code{\$@@}, which concatenates all the arguments with each
11762 surrounded by double quotes, and separated by spaces. If not in
11763 compatibility mode, the input level of double quotes is preserved (see
11764 @ref{Request and Macro Arguments}).
11767 @Defesc {\\$^, , , }
11768 Handle the parameters of a macro as if they were an argument to the
11769 @code{ds} or similar requests.
11779 .foo " This is a "test"
11780 @result{} $1=` This is a '
11781 @result{} $2=`test"'
11782 @result{} $*=` This is a test"'
11783 @result{} $@@=`" This is a " "test""'
11784 @result{} $^=`" This is a "test"'
11787 This escape is useful mainly for macro packages like @file{trace.tmac},
11788 which redefines some requests and macros for debugging purposes.
11791 @Defesc {\\$0, , , }
11792 @cindex macro name register (@code{\$0})
11793 @cindex @code{als} request, and @code{\$0}
11794 The name used to invoke the current macro. The @code{als} request can
11795 make a macro have more than one name.
11797 If a macro is called as a string (within another macro), the value of
11798 @code{\$0} isn't changed.
11834 @xref{Request and Macro Arguments}.
11837 @c =====================================================================
11839 @node Page Motions, Drawing Requests, Writing Macros, gtroff Reference
11840 @section Page Motions
11841 @cindex page motions
11842 @cindex motions, page
11844 @xref{Manipulating Spacing}, for a discussion of the main request for
11845 vertical motion, @code{sp}.
11847 @DefreqList {mk, [@Var{reg}]}
11848 @DefreqListEndx {rt, [@Var{dist}]}
11849 @cindex marking vertical page location (@code{mk})
11850 @cindex page location, vertical, marking (@code{mk})
11851 @cindex location, vertical, page, marking (@code{mk})
11852 @cindex vertical page location, marking (@code{mk})
11853 @cindex returning to marked vertical page location (@code{rt})
11854 @cindex page location, vertical, returning to marked (@code{rt})
11855 @cindex location, vertical, page, returning to marked (@code{rt})
11856 @cindex vertical page location, returning to marked (@code{rt})
11857 The request @code{mk} can be used to mark a location on a page, for
11858 movement to later. This request takes a register name as an argument in
11859 which to store the current page location. With no argument it stores
11860 the location in an internal register. The results of this can be used
11861 later by the @code{rt} or the @code{sp} request (or the @code{\v}
11864 The @code{rt} request returns @emph{upwards} to the location marked with
11865 the last @code{mk} request. If used with an argument, return to a
11866 position which distance from the top of the page is @var{dist} (no
11867 previous call to @code{mk} is necessary in this case). Default scaling
11868 indicator is @samp{v}.
11870 If a page break occurs between a @code{mk} request and its
11871 matching @code{rt} request, the @code{rt} is silently ignored.
11873 Here a primitive solution for a two-column macro.
11876 .nr column-length 1.5i
11878 .nr bottom-margin 1m
11885 . ll \\n[column-length]u
11886 . wh -\\n[bottom-margin]u 2c-trap
11893 . ie \\n[right-side] \@{\
11895 . po -(\\n[column-length]u + \\n[column-gap]u)
11897 . wh -\\n[bottom-margin]u
11900 . \" switch to right side
11902 . po +(\\n[column-length]u + \\n[column-gap]u)
11911 This is a small test that shows how the
11912 rt request works in combination with mk.
11915 Starting here, text is typeset in two columns.
11916 Note that this implementation isn't robust
11917 and thus not suited for a real two-column
11924 This is a small test that shows how the
11925 rt request works in combination with mk.
11927 Starting here, isn't robust
11928 text is typeset and thus not
11929 in two columns. suited for a
11930 Note that this real two-column
11931 implementation macro.
11935 The following escapes give fine control of movements about the page.
11937 @Defesc {\\v, ', e, '}
11938 @cindex vertical motion (@code{\v})
11939 @cindex motion, vertical (@code{\v})
11940 Move vertically, usually from the current location on the page (if no
11941 absolute position operator @samp{|} is used). The argument@tie{}@var{e}
11942 specifies the distance to move; positive is downwards and negative
11943 upwards. The default scaling indicator for this escape is @samp{v}.
11944 Beware, however, that @code{gtroff} continues text processing at the
11945 point where the motion ends, so you should always balance motions to
11946 avoid interference with text processing.
11948 @code{\v} doesn't trigger a trap. This can be quite useful; for
11949 example, consider a page bottom trap macro that prints a marker in the
11950 margin to indicate continuation of a footnote or something similar.
11953 There are some special-case escapes for vertical motion.
11955 @Defesc {\\r, , , }
11956 Move upwards@tie{}1@dmn{v}.
11959 @Defesc {\\u, , , }
11960 Move upwards@tie{}.5@dmn{v}.
11963 @Defesc {\\d, , , }
11964 Move down@tie{}.5@dmn{v}.
11967 @Defesc {\\h, ', e, '}
11968 @cindex inserting horizontal space (@code{\h})
11969 @cindex horizontal space (@code{\h})
11970 @cindex space, horizontal (@code{\h})
11971 @cindex horizontal motion (@code{\h})
11972 @cindex motion, horizontal (@code{\h})
11973 Move horizontally, usually from the current location (if no absolute
11974 position operator @samp{|} is used). The expression@tie{}@var{e}
11975 indicates how far to move: positive is rightwards and negative
11976 leftwards. The default scaling indicator for this escape is @samp{m}.
11978 This horizontal space is not discarded at the end of a line. To insert
11979 discardable space of a certain length use the @code{ss} request.
11982 There are a number of special-case escapes for horizontal motion.
11984 @Defesc {\\@key{SP}, , , }
11985 @cindex space, unbreakable
11986 @cindex unbreakable space
11987 An unbreakable and unpaddable (i.e.@: not expanded during filling)
11988 space. (Note: This is a backslash followed by a space.)
11991 @Defesc {\\~, , , }
11992 An unbreakable space that stretches like a normal inter-word space when
11993 a line is adjusted.
11996 @Defesc {\\|, , , }
11997 A 1/6@dmn{th} em space. Ignored for TTY output devices (rounded to
12000 However, if there is a glyph defined in the current font file with name
12001 @code{\|} (note the leading backslash), the width of this glyph is used
12002 instead (even for TTYs).
12005 @Defesc {\\^, , , }
12006 A 1/12@dmn{th} em space. Ignored for TTY output devices (rounded to
12009 However, if there is a glyph defined in the current font file with name
12010 @code{\^} (note the leading backslash), the width of this glyph is used
12011 instead (even for TTYs).
12014 @Defesc {\\0, , , }
12015 @cindex space, width of a digit (@code{\0})
12016 @cindex digit width space (@code{\0})
12017 A space the size of a digit.
12020 The following string sets the @TeX{} logo:
12023 .ds TeX T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
12026 @DefescList {\\w, ', text, '}
12033 @DefregListEndx {skw}
12034 @cindex width escape (@code{\w})
12035 Return the width of the specified @var{text} in basic units. This
12036 allows horizontal movement based on the width of some arbitrary text
12037 (e.g.@: given as an argument to a macro).
12040 The length of the string `abc' is \w'abc'u.
12041 @result{} The length of the string `abc' is 72u.
12044 Font changes may occur in @var{text}, which don't affect current
12047 After use, @code{\w} sets several registers:
12052 The highest and lowest point of the baseline, respectively, in
12057 Like the @code{st} and @code{sb} registers, but takes account of the
12058 heights and depths of glyphs. In other words, this gives the highest
12059 and lowest point of @var{text}. Values below the baseline are negative.
12062 Defines the kinds of glyphs occurring in @var{text}:
12066 only short glyphs, no descenders or tall glyphs.
12069 at least one descender.
12072 at least one tall glyph.
12075 at least one each of a descender and a tall glyph.
12079 The amount of horizontal space (possibly negative) that should be added
12080 to the last glyph before a subscript.
12083 How far to right of the center of the last glyph in the @code{\w}
12084 argument, the center of an accent from a roman font should be placed
12089 @DefescList {\\k, , p, }
12090 @DefescItem {\\k, @Lparen{}, ps, }
12091 @DefescListEnd {\\k, @Lbrack{}, position, @Rbrack{}}
12092 @cindex saving horizontal input line position (@code{\k})
12093 @cindex horizontal input line position, saving (@code{\k})
12094 @cindex input line position, horizontal, saving (@code{\k})
12095 @cindex position, horizontal input line, saving (@code{\k})
12096 @cindex line, input, horizontal position, saving (@code{\k})
12097 Store the current horizontal position in the @emph{input} line in number
12098 register with name @var{position} (one-character name@tie{}@var{p},
12099 two-character name @var{ps}). Use this, for example, to return to the
12100 beginning of a string for highlighting or other decoration.
12104 @cindex horizontal input line position register (@code{hp})
12105 @cindex input line, horizontal position, register (@code{hp})
12106 @cindex position, horizontal, in input line, register (@code{hp})
12107 @cindex line, input, horizontal position, register (@code{hp})
12108 The current horizontal position at the input line.
12112 @cindex horizontal output line position register (@code{.k})
12113 @cindex output line, horizontal position, register (@code{.k})
12114 @cindex position, horizontal, in output line, register (@code{.k})
12115 @cindex line, output, horizontal position, register (@code{.k})
12116 A read-only number register containing the current horizontal output
12117 position (relative to the current indentation).
12120 @Defesc {\\o, ', abc, '}
12121 @cindex overstriking glyphs (@code{\o})
12122 @cindex glyphs, overstriking (@code{\o})
12123 Overstrike glyphs @var{a}, @var{b}, @var{c}, @dots{}; the glyphs are
12124 centered, and the resulting spacing is the largest width of the affected
12128 @Defesc {\\z, , g, }
12129 @cindex zero-width printing (@code{\z}, @code{\Z})
12130 @cindex printing, zero-width (@code{\z}, @code{\Z})
12131 Print glyph @var{g} with zero width, i.e., without spacing. Use this to
12132 overstrike glyphs left-aligned.
12135 @Defesc {\\Z, ', anything, '}
12136 @cindex zero-width printing (@code{\z}, @code{\Z})
12137 @cindex printing, zero-width (@code{\z}, @code{\Z})
12138 Print @var{anything}, then restore the horizontal and vertical position.
12139 The argument may not contain tabs or leaders.
12141 The following is an example of a strike-through macro:
12146 \Z@@\v'-.25m'\l'\\n[ww]u'@@\\$1
12151 an actual emergency!
12156 @c =====================================================================
12158 @node Drawing Requests, Traps, Page Motions, gtroff Reference
12159 @section Drawing Requests
12160 @cindex drawing requests
12161 @cindex requests for drawing
12163 @code{gtroff} provides a number of ways to draw lines and other figures
12164 on the page. Used in combination with the page motion commands (see
12165 @ref{Page Motions}, for more info), a wide variety of figures can be
12166 drawn. However, for complex drawings these operations can be quite
12167 cumbersome, and it may be wise to use graphic preprocessors like
12168 @code{gpic} or @code{ggrn}. @xref{gpic}, and @ref{ggrn}, for more
12171 All drawing is done via escapes.
12173 @DefescList {\\l, ', l, '}
12174 @DefescListEnd {\\l, ', lg, '}
12175 @cindex drawing horizontal lines (@code{\l})
12176 @cindex horizontal line, drawing (@code{\l})
12177 @cindex line, horizontal, drawing (@code{\l})
12178 Draw a line horizontally. @var{l} is the length of the line to be
12179 drawn. If it is positive, start the line at the current location and
12180 draw to the right; its end point is the new current location. Negative
12181 values are handled differently: The line starts at the current location
12182 and draws to the left, but the current location doesn't move.
12184 @var{l} can also be specified absolutely (i.e.@: with a leading
12185 @samp{|}), which draws back to the beginning of the input line. Default
12186 scaling indicator is @samp{m}.
12188 @cindex underscore glyph (@code{\[ru]})
12189 @cindex glyph, underscore (@code{\[ru]})
12190 @cindex line drawing glyph
12191 @cindex glyph, for line drawing
12192 The optional second parameter@tie{}@var{g} is a glyph to draw the line
12193 with. If this second argument is not specified, @code{gtroff} uses the
12194 underscore glyph, @code{\[ru]}.
12196 @cindex zero width space character (@code{\&})
12197 @cindex character, zero width space (@code{\&})
12198 @cindex space character, zero width (@code{\&})
12199 To separate the two arguments (to prevent @code{gtroff} from
12200 interpreting a drawing glyph as a scaling indicator if the glyph is
12201 represented by a single character) use @code{\&}.
12203 Here a small useful example:
12207 \[br]\\$*\[br]\l'|0\[rn]'\l'|0\[ul]'
12212 Note that this works by outputting a box rule (a vertical line), then
12213 the text given as an argument and then another box rule. Finally, the
12214 line drawing escapes both draw from the current location to the
12215 beginning of the @emph{input} line -- this works because the line length
12216 is negative, not moving the current point.
12219 @DefescList {\\L, ', l, '}
12220 @DefescListEnd {\\L, ', lg, '}
12221 @cindex drawing vertical lines (@code{\L})
12222 @cindex vertical line drawing (@code{\L})
12223 @cindex line, vertical, drawing (@code{\L})
12224 @cindex line drawing glyph
12225 @cindex glyph for line drawing
12226 @cindex box rule glyph (@code{\[br]})
12227 @cindex glyph, box rule (@code{\[br]})
12228 Draw vertical lines. Its parameters are similar to the @code{\l}
12229 escape, except that the default scaling indicator is @samp{v}. The
12230 movement is downwards for positive values, and upwards for negative
12231 values. The default glyph is the box rule glyph, @code{\[br]}. As with
12232 the vertical motion escapes, text processing blindly continues where the
12236 This is a \L'3v'test.
12240 Here is the result, produced with @code{grotty}.
12250 @Defesc {\\D, ', command arg @dots{}, '}
12251 The @code{\D} escape provides a variety of drawing functions. Note that
12252 on character devices, only vertical and horizontal lines are supported
12253 within @code{grotty}; other devices may only support a subset of the
12254 available drawing functions.
12256 The default scaling indicator for all subcommands of @code{\D} is
12257 @samp{m} for horizontal distances and @samp{v} for vertical ones.
12258 Exceptions are @w{@code{\D'f @dots{}'}} and @w{@code{\D't @dots{}'}},
12259 which use @code{u} as the default, and @w{@code{\D'F@var{x} @dots{}'}},
12260 which arguments are treated similar to the @code{defcolor} request.
12263 @item \D'l @var{dx} @var{dy}'
12264 @cindex line, drawing (@w{@code{\D'l @dots{}'}})
12265 @cindex drawing a line (@w{@code{\D'l @dots{}'}})
12266 Draw a line from the current location to the relative point specified by
12267 (@var{dx},@var{dy}), where positive values mean right and down,
12268 respectively. The end point of the line is the new current location.
12270 The following example is a macro for creating a box around a text
12271 string; for simplicity, the box margin is taken as a fixed value,
12278 \h'-.2m'\v'(.2m - \\n[rsb]u)'\
12279 \D'l 0 -(\\n[rst]u - \\n[rsb]u + .4m)'\
12280 \D'l (\\n[@@wd]u + .4m) 0'\
12281 \D'l 0 (\\n[rst]u - \\n[rsb]u + .4m)'\
12282 \D'l -(\\n[@@wd]u + .4m) 0'\
12283 \h'.2m'\v'-(.2m - \\n[rsb]u)'\
12290 First, the width of the string is stored in register @code{@@wd}. Then,
12291 four lines are drawn to form a box, properly offset by the box margin.
12292 The registers @code{rst} and @code{rsb} are set by the @code{\w} escape,
12293 containing the largest height and depth of the whole string.
12295 @item \D'c @var{d}'
12296 @cindex circle, drawing (@w{@code{\D'c @dots{}'}})
12297 @cindex drawing a circle (@w{@code{\D'c @dots{}'}})
12298 Draw a circle with a diameter of@tie{}@var{d} with the leftmost point at
12299 the current position. After drawing, the current location is positioned
12300 at the rightmost point of the circle.
12302 @item \D'C @var{d}'
12303 @cindex circle, solid, drawing (@w{@code{\D'C @dots{}'}})
12304 @cindex drawing a solid circle (@w{@code{\D'C @dots{}'}})
12305 @cindex solid circle, drawing (@w{@code{\D'C @dots{}'}})
12306 Draw a solid circle with the same parameters and behaviour as an
12307 outlined circle. No outline is drawn.
12309 @item \D'e @var{x} @var{y}'
12310 @cindex drawing an ellipse (@w{@code{\D'e @dots{}'}})
12311 @cindex ellipse, drawing (@w{@code{\D'e @dots{}'}})
12312 Draw an ellipse with a horizontal diameter of @var{x} and a vertical
12313 diameter of @var{y} with the leftmost point at the current position.
12314 After drawing, the current location is positioned at the rightmost point
12317 @item \D'E @var{x} @var{y}'
12318 @cindex ellipse, solid, drawing (@w{@code{\D'E @dots{}'}})
12319 @cindex drawing a solid ellipse (@w{@code{\D'E @dots{}'}})
12320 @cindex solid ellipse, drawing (@w{@code{\D'E @dots{}'}})
12321 Draw a solid ellipse with the same parameters and behaviour as an
12322 outlined ellipse. No outline is drawn.
12324 @item \D'a @var{dx1} @var{dy1} @var{dx2} @var{dy2}'
12325 @cindex arc, drawing (@w{@code{\D'a @dots{}'}})
12326 @cindex drawing an arc (@w{@code{\D'a @dots{}'}})
12327 Draw an arc clockwise from the current location through the two
12328 specified relative locations (@var{dx1},@var{dy1}) and
12329 (@var{dx2},@var{dy2}). The coordinates of the first point are relative
12330 to the current position, and the coordinates of the second point are
12331 relative to the first point. After drawing, the current position is
12332 moved to the final point of the arc.
12334 @item \D'~ @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
12335 @cindex drawing a spline (@w{@code{\D'~ @dots{}'}})
12336 @cindex spline, drawing (@w{@code{\D'~ @dots{}'}})
12337 Draw a spline from the current location to the relative point
12338 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}), and so on. The
12339 current position is moved to the terminal point of the drawn curve.
12341 @item \D'f @var{n}'
12342 @cindex gray shading (@w{@code{\D'f @dots{}'}})
12343 @cindex shading filled objects (@w{@code{\D'f @dots{}'}})
12344 Set the shade of gray to be used for filling solid objects
12345 to@tie{}@var{n}; @var{n}@tie{}must be an integer between 0
12346 and@tie{}1000, where 0 corresponds solid white and 1000 to solid black,
12347 and values in between correspond to intermediate shades of gray. This
12348 applies only to solid circles, solid ellipses, and solid polygons. By
12349 default, a level of 1000 is used.
12351 Despite of being silly, the current point is moved horizontally to the
12352 right by@tie{}@var{n}.
12354 @cindex @w{@code{\D'f @dots{}'}} and horizontal resolution
12355 Don't use this command! It has the serious drawback that it is always
12356 rounded to the next integer multiple of the horizontal resolution (the
12357 value of the @code{hor} keyword in the @file{DESC} file). Use @code{\M}
12358 (@pxref{Colors}) or @w{@code{\D'Fg @dots{}'}} instead.
12360 @item \D'p @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
12361 @cindex drawing a polygon (@w{@code{\D'p @dots{}'}})
12362 @cindex polygon, drawing (@w{@code{\D'p @dots{}'}})
12363 Draw a polygon from the current location to the relative position
12364 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}) and so on. When
12365 the specified data points are exhausted, a line is drawn back to the
12366 starting point. The current position is changed by adding the sum of
12367 all arguments with odd index to the actual horizontal position and the
12368 even ones to the vertical position.
12370 @item \D'P @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
12371 @cindex polygon, solid, drawing (@w{@code{\D'P @dots{}'}})
12372 @cindex drawing a solid polygon (@w{@code{\D'P @dots{}'}})
12373 @cindex solid polygon, drawing (@w{@code{\D'P @dots{}'}})
12374 Draw a solid polygon with the same parameters and behaviour as an
12375 outlined polygon. No outline is drawn.
12377 Here a better variant of the box macro to fill the box with some color.
12378 Note that the box must be drawn before the text since colors in
12379 @code{gtroff} are not transparent; the filled polygon would hide the
12386 \h'-.2m'\v'(.2m - \\n[rsb]u)'\
12388 \D'P 0 -(\\n[rst]u - \\n[rsb]u + .4m) \
12389 (\\n[@@wd]u + .4m) 0 \
12390 0 (\\n[rst]u - \\n[rsb]u + .4m) \
12391 -(\\n[@@wd]u + .4m) 0'\
12392 \h'.2m'\v'-(.2m - \\n[rsb]u)'\
12399 If you want a filled polygon that has exactly the same size as an
12400 unfilled one, you must draw both an unfilled and a filled polygon. A
12401 filled polygon is always smaller than an unfilled one because the latter
12402 uses straight lines with a given line thickness to connect the polygon's
12403 corners, while the former simply fills the area defined by the
12408 \# increase line thickness
12410 \# draw unfilled polygon
12411 \Z'\D'p 3 3 -6 0''\
12412 \# draw filled polygon
12416 @item \D't @var{n}'
12417 @cindex line thickness (@w{@code{\D't @dots{}'}})
12418 @cindex thickness of lines (@w{@code{\D't @dots{}'}})
12419 Set the current line thickness to @var{n}@tie{}machine units. A value
12420 of zero selects the smallest available line thickness. A negative value
12421 makes the line thickness proportional to the current point size (this is
12422 the default behaviour of @acronym{AT&T} @code{troff}).
12424 Despite of being silly, the current point is moved horizontally to the
12425 right by@tie{}@var{n}.
12427 @item \D'F@var{scheme} @var{color_components}'
12428 @cindex unnamed fill colors (@code{\D'F@dots{}'})
12429 @cindex fill colors, unnamed (@code{\D'F@dots{}'})
12430 @cindex colors, fill, unnamed (@code{\D'F@dots{}'})
12431 Change current fill color. @var{scheme} is a single letter denoting the
12432 color scheme: @samp{r} (rgb), @samp{c} (cmy), @samp{k} (cmyk), @samp{g}
12433 (gray), or @samp{d} (default color). The color components use exactly
12434 the same syntax as in the @code{defcolor} request (@pxref{Colors}); the
12435 command @code{\D'Fd'} doesn't take an argument.
12437 @emph{No} position changing!
12442 \D'Fg .3' \" same gray as \D'f 700'
12443 \D'Fr #0000ff' \" blue
12448 @xref{Graphics Commands}.
12450 @Defesc {\\b, ', string, '}
12451 @cindex pile, glyph (@code{\b})
12452 @cindex glyph pile (@code{\b})
12453 @cindex stacking glyphs (@code{\b})
12454 @dfn{Pile} a sequence of glyphs vertically, and center it vertically on
12455 the current line. Use it to build large brackets and braces.
12457 Here an example how to create a large opening brace:
12460 \b'\[lt]\[bv]\[lk]\[bv]\[lb]'
12463 @cindex @code{\b}, limitations
12464 @cindex limitations of @code{\b} escape
12465 The first glyph is on the top, the last glyph in @var{string} is at the
12466 bottom. Note that @code{gtroff} separates the glyphs vertically by
12467 1@dmn{m}, and the whole object is centered 0.5@dmn{m} above the current
12468 baseline; the largest glyph width is used as the width for the whole
12469 object. This rather unflexible positioning algorithm doesn't work with
12470 @option{-Tdvi} since the bracket pieces vary in height for this device.
12471 Instead, use the @code{eqn} preprocessor.
12473 @xref{Manipulating Spacing}, how to adjust the vertical spacing with the
12478 @c =====================================================================
12480 @node Traps, Diversions, Drawing Requests, gtroff Reference
12484 @dfn{Traps} are locations that, when reached, call a specified macro.
12485 These traps can occur at a given location on the page, at a given
12486 location in the current diversion, at a blank line, after a certain
12487 number of input lines, or at the end of input.
12489 @cindex planting a trap
12490 @cindex trap, planting
12491 Setting a trap is also called @dfn{planting}.
12492 @cindex trap, springing
12493 @cindex springing a trap
12494 It is also said that a trap is @dfn{sprung} if the associated macro is
12498 * Page Location Traps::
12499 * Diversion Traps::
12500 * Input Line Traps::
12501 * Blank Line Traps::
12502 * Leading Spaces Traps::
12503 * End-of-input Traps::
12506 @c ---------------------------------------------------------------------
12508 @node Page Location Traps, Diversion Traps, Traps, Traps
12509 @subsection Page Location Traps
12510 @cindex page location traps
12511 @cindex traps, page location
12513 @dfn{Page location traps} perform an action when @code{gtroff} reaches
12514 or passes a certain vertical location on the page. Page location traps
12515 have a variety of purposes, including:
12519 setting headers and footers
12522 setting body text in multiple columns
12528 @DefreqList {vpt, flag}
12529 @DefregListEndx {.vpt}
12530 @cindex enabling vertical position traps (@code{vpt})
12531 @cindex vertical position traps, enabling (@code{vpt})
12532 @cindex vertical position trap enable register (@code{.vpt})
12533 Enable vertical position traps if @var{flag} is non-zero, or disables
12534 them otherwise. Vertical position traps are traps set by the @code{wh}
12535 or @code{dt} requests. Traps set by the @code{it} request are not
12536 vertical position traps. The parameter that controls whether vertical
12537 position traps are enabled is global. Initially vertical position traps
12538 are enabled. The current setting of this is available in the
12539 @code{.vpt} read-only number register.
12541 Note that a page can't be ejected if @code{vpt} is set to zero.
12544 @Defreq {wh, dist [@Var{macro}]}
12545 Set a page location trap. Non-negative values for @var{dist} set the
12546 trap relative to the top of the page; negative values set the trap
12547 relative to the bottom of the page. Default scaling indicator is
12548 @samp{v}; values of @var{dist} are always rounded to be multiples of the
12549 vertical resolution (as given in register @code{.V}).
12551 @var{macro} is the name of the macro to execute when the trap is sprung.
12552 If @var{macro} is missing, remove the first trap (if any) at @var{dist}.
12554 @cindex page headers
12555 @cindex page footers
12558 The following is a simple example of how many macro packages set headers
12562 .de hd \" Page header
12568 .de fo \" Page footer
12574 .wh 0 hd \" trap at top of the page
12575 .wh -1i fo \" trap one inch from bottom
12578 A trap at or below the bottom of the page is ignored; it can be made
12579 active by either moving it up or increasing the page length so that the
12580 trap is on the page.
12582 Negative trap values always use the @emph{current} page length; they are
12583 not converted to an absolute vertical position:
12595 It is possible to have more than one trap at the same location; to do
12596 so, the traps must be defined at different locations, then moved
12597 together with the @code{ch} request; otherwise the second trap would
12598 replace the first one. Earlier defined traps hide later defined traps
12599 if moved to the same position (the many empty lines caused by the
12600 @code{bp} request are omitted in the following example):
12633 @cindex distance to next trap register (@code{.t})
12634 @cindex trap, distance, register (@code{.t})
12635 A read-only number register holding the distance to the next trap.
12637 If there are no traps between the current position and the bottom of the
12638 page, it contains the distance to the page bottom. In a diversion, the
12639 distance to the page bottom is infinite (the returned value is the
12640 biggest integer that can be represented in @code{groff}) if there are
12641 no diversion traps.
12644 @Defreq {ch, macro [@Var{dist}]}
12645 @cindex changing trap location (@code{ch})
12646 @cindex trap, changing location (@code{ch})
12647 Change the location of a trap. The first argument is the name of the
12648 macro to be invoked at the trap, and the second argument is the new
12649 location for the trap (note that the parameters are specified in
12650 opposite order as in the @code{wh} request). This is useful for
12651 building up footnotes in a diversion to allow more space at the bottom
12652 of the page for them.
12654 Default scaling indicator for @var{dist} is @samp{v}. If @var{dist} is
12655 missing, the trap is removed.
12661 ... (simplified) footnote example ...
12667 The read-only number register @code{.ne} contains the amount of space
12668 that was needed in the last @code{ne} request that caused a trap to be
12669 sprung. Useful in conjunction with the @code{.trunc} register.
12670 @xref{Page Control}, for more information.
12672 Since the @code{.ne} register is only set by traps it doesn't make much
12673 sense to use it outside of trap macros.
12677 @cindex @code{ne} request, and the @code{.trunc} register
12678 @cindex truncated vertical space register (@code{.trunc})
12679 A read-only register containing the amount of vertical space truncated
12680 from an @code{sp} request by the most recently sprung vertical
12681 position trap, or, if the trap was sprung by an @code{ne} request,
12682 minus the amount of vertical motion produced by the @code{ne}
12683 request. In other words, at the point a trap is sprung, it
12684 represents the difference of what the vertical position would have
12685 been but for the trap, and what the vertical position actually is.
12687 Since the @code{.trunc} register is only set by traps it doesn't make
12688 much sense to use it outside of trap macros.
12692 @cindex @code{bp} request, and traps (@code{.pe})
12693 @cindex traps, sprung by @code{bp} request (@code{.pe})
12694 @cindex page ejecting register (@code{.pe})
12695 A read-only register that is set to@tie{}1 while a page is ejected with
12696 the @code{bp} request (or by the end of input).
12698 Outside of traps this register is always zero. In the following
12699 example, only the second call to@tie{}@code{x} is caused by @code{bp}.
12720 @cindex diversions, and traps
12721 @cindex traps, and diversions
12722 An important fact to consider while designing macros is that diversions
12723 and traps do not interact normally. For example, if a trap invokes a
12724 header macro (while outputting a diversion) that tries to change the
12725 font on the current page, the effect is not visible before the diversion
12726 has completely been printed (except for input protected with @code{\!}
12727 or @code{\?}) since the data in the diversion is already formatted. In
12728 most cases, this is not the expected behaviour.
12730 @c ---------------------------------------------------------------------
12732 @node Diversion Traps, Input Line Traps, Page Location Traps, Traps
12733 @subsection Diversion Traps
12734 @cindex diversion traps
12735 @cindex traps, diversion
12737 @Defreq {dt, [@Var{dist} @Var{macro}]}
12738 @cindex @code{.t} register, and diversions
12739 @cindex setting diversion trap (@code{dt})
12740 @cindex diversion trap, setting (@code{dt})
12741 @cindex trap, diversion, setting (@code{dt})
12742 Set a trap @emph{within} a diversion. @var{dist} is the location of the
12743 trap (identical to the @code{wh} request; default scaling indicator is
12744 @samp{v}) and @var{macro} is the name of the macro to be invoked. If
12745 called without arguments, the diversion trap is removed.
12747 Note that there exists only a single diversion trap.
12749 The number register @code{.t} still works within diversions.
12750 @xref{Diversions}, for more information.
12753 @c ---------------------------------------------------------------------
12755 @node Input Line Traps, Blank Line Traps, Diversion Traps, Traps
12756 @subsection Input Line Traps
12757 @cindex input line traps
12758 @cindex traps, input line
12760 @DefreqList {it, n macro}
12761 @DefreqListEndx {itc, n macro}
12762 @cindex setting input line trap (@code{it})
12763 @cindex input line trap, setting (@code{it})
12764 @cindex trap, input line, setting (@code{it})
12765 Set an input line trap. @var{n}@tie{}is the number of lines of input
12766 that may be read before springing the trap, @var{macro} is the macro to
12767 be invoked. Request lines are not counted as input lines.
12769 For example, one possible use is to have a macro that prints the next
12770 @var{n}@tie{}lines in a bold font.
12783 @cindex input line traps and interrupted lines (@code{itc})
12784 @cindex interrupted lines and input line traps (@code{itc})
12785 @cindex traps, input line, and interrupted lines (@code{itc})
12786 @cindex lines, interrupted, and input line traps (@code{itc})
12787 The @code{itc} request is identical except that an interrupted text line
12788 (ending with @code{\c}) is not counted as a separate line.
12790 Both requests are associated with the current environment
12791 (@pxref{Environments}); switching to another environment disables the
12792 current input trap, and going back reactivates it, restoring the number
12793 of already processed lines.
12796 @c ---------------------------------------------------------------------
12798 @node Blank Line Traps, Leading Spaces Traps, Input Line Traps, Traps
12799 @subsection Blank Line Traps
12800 @cindex blank line traps
12801 @cindex traps, blank line
12803 @Defreq {blm, macro}
12804 @cindex blank line macro (@code{blm})
12805 Set a blank line trap. @code{gtroff} executes @var{macro} when it
12806 encounters a blank line in the input file.
12809 @c ---------------------------------------------------------------------
12811 @node Leading Spaces Traps, End-of-input Traps, Blank Line Traps, Traps
12812 @subsection Leading Spaces Traps
12813 @cindex leading spaces traps
12814 @cindex traps, leading spaces
12816 @DefreqList {lsm, macro}
12818 @DefregListEndx {lss}
12819 @cindex leading spaces macro (@code{lsm})
12820 Set a leading spaces trap. @code{gtroff} executes @var{macro} when it
12821 encounters leading spaces in an input line; the implicit line break
12822 that normally happens in this case is suppressed. A line consisting
12823 of spaces only, however, is treated as an empty line, possibly subject
12824 to an empty line macro set with the @code{blm} request.
12826 Leading spaces are removed from the input line before calling the
12827 leading spaces macro. The number of removed spaces is stored in
12828 register @code{lsn}; the horizontal space that would be emitted if
12829 there was no leading space macro is stored in register @code{lss}.
12830 Note that @code{lsn} and @code{lss} are available even if no leading
12831 space macro has been set.
12833 The first thing a leading space macro sees is a token. However, some
12834 escapes like @code{\f} or @code{\m} are handled on the fly (see
12835 @ref{Gtroff Internals}, for a complete list) without creating a token
12836 at all. Consider that a line starts with two spaces followed by
12837 @code{\fIfoo}. While skipping the spaces @code{\fI} is handled too so
12838 that groff's current font is properly set to @samp{I}, but the leading
12839 space macro only sees @code{foo}, without the preceding @code{\fI}.
12840 If the macro should see the font escape you have to `protect' it with
12841 something that creates a token, for example with @code{\&\fIfoo}.
12844 @c ---------------------------------------------------------------------
12846 @node End-of-input Traps, , Leading Spaces Traps, Traps
12847 @subsection End-of-input Traps
12848 @cindex end-of-input traps
12849 @cindex traps, end-of-input
12851 @Defreq {em, macro}
12852 @cindex setting end-of-input trap (@code{em})
12853 @cindex end-of-input trap, setting (@code{em})
12854 @cindex trap, end-of-input, setting (@code{em})
12855 @cindex end-of-input macro (@code{em})
12856 @cindex macro, end-of-input (@code{em})
12857 Set a trap at the end of input. @var{macro} is executed after the last
12858 line of the input file has been processed.
12860 For example, if the document had to have a section at the bottom of the
12861 last page for someone to approve it, the @code{em} request could be
12868 . sp (\\n[.t]u - 3v)
12880 The @code{\c} in the above example needs explanation. For historical
12881 reasons (and for compatibility with @acronym{AT&T} @code{troff}), the
12882 end macro exits as soon as it causes a page break and no remaining
12883 data is in the partially collected line.
12885 Let us assume that there is no @code{\c} in the above @code{approval}
12886 macro, and that the page is full and has been ended with, say, a
12887 @code{br} request. The @code{ne} request now causes the start of a new
12888 page, which in turn makes @code{troff} exit immediately for the reasons
12889 just described. In most situations this is not intended.
12891 To always force processing the whole end macro independently of this
12892 behaviour it is thus advisable to insert something that starts an
12893 empty partially filled line (@code{\c}) whenever there is a chance that
12894 a page break can happen. In the above example, the call of the
12895 @code{ne} request assures that the remaining code stays on the same
12896 page, so we have to insert @code{\c} only once.
12898 The next example shows how to append three lines, then starting a new
12899 page unconditionally. Since @w{@samp{.ne 1}} doesn't give the desired
12900 effect -- there is always one line available or we are already at the
12901 beginning of the next page -- we temporarily increase the page length
12902 by one line so that we can use @w{@samp{.ne 2}}.
12926 Note that this specific feature affects only the first potential page
12927 break caused by the end macro; further page breaks emitted by the end
12928 macro are handled normally.
12930 Another possible use of the @code{em} request is to make @code{gtroff}
12931 emit a single large page instead of multiple pages. For example, one
12932 may want to produce a long plain-text file for reading on-screen. The
12933 idea is to set the page length at the beginning of the document to a
12934 very large value to hold all the text, and automatically adjust it to
12935 the exact height of the document after the text has been output.
12938 .de adjust-page-length
12940 . pl \\n[nl]u \" \n[nl] holds the current vert. position
12943 .de single-page-mode
12945 . em adjust-page-length
12948 .\" activate the above code
12952 Since only one end-of-input trap does exist and other macro packages
12953 may already use it, care must be taken not to break the mechanism. A
12954 simple solution would be to append the above macro to the macro
12955 package's end-of-input macro using the @code{.am} request.
12959 @c =====================================================================
12961 @node Diversions, Environments, Traps, gtroff Reference
12962 @section Diversions
12965 In @code{gtroff} it is possible to @dfn{divert} text into a named
12966 storage area. Due to the similarity to defining macros it is sometimes
12967 said to be stored in a macro. This is used for saving text for output
12968 at a later time, which is useful for keeping blocks of text on the same
12969 page, footnotes, tables of contents, and indices.
12971 @cindex top-level diversion
12972 @cindex diversion, top-level
12973 For orthogonality it is said that @code{gtroff} is in the @dfn{top-level
12974 diversion} if no diversion is active (i.e., the data is diverted to the
12977 Although the following requests can be used to create diversions,
12978 simply using an undefined diversion will cause it to be defined as empty.
12979 @xref{Identifiers}.
12981 @DefreqList {di, macro}
12982 @DefreqListEndx {da, macro}
12983 @cindex beginning diversion (@code{di})
12984 @cindex diversion, beginning (@code{di})
12985 @cindex ending diversion (@code{di})
12986 @cindex diversion, ending (@code{di})
12987 @cindex appending to a diversion (@code{da})
12988 @cindex diversion, appending (@code{da})
12989 Begin a diversion. Like the @code{de} request, it takes an argument of
12990 a macro name to divert subsequent text into. The @code{da} macro
12991 appends to an existing diversion.
12993 @code{di} or @code{da} without an argument ends the diversion.
12995 The current partially filled line is included into the diversion. See
12996 the @code{box} request below for an example. Note that switching to
12997 another (empty) environment (with the @code{ev} request) avoids the
12998 inclusion of the current partially filled line.
13001 @DefreqList {box, macro}
13002 @DefreqListEndx {boxa, macro}
13003 Begin (or append to) a diversion like the @code{di} and @code{da}
13004 requests. The difference is that @code{box} and @code{boxa} do not
13005 include a partially filled line in the diversion.
13017 @result{} Before the box. After the box.
13019 @result{} In the box.
13026 Before the diversion.
13031 After the diversion.
13033 @result{} After the diversion.
13035 @result{} Before the diversion. In the diversion.
13038 @code{box} or @code{boxa} without an argument ends the diversion.
13042 @DefregListEndx {.d}
13043 @cindex @code{nl} register, and @code{.d}
13044 @cindex nested diversions
13045 @cindex diversion, nested
13046 @cindex diversion name register (@code{.z})
13047 @cindex vertical position in diversion register (@code{.d})
13048 @cindex position, vertical, in diversion, register (@code{.d})
13049 @cindex diversion, vertical position in, register (@code{.d})
13050 Diversions may be nested. The read-only number register @code{.z}
13051 contains the name of the current diversion (this is a string-valued
13052 register). The read-only number register @code{.d} contains the current
13053 vertical place in the diversion. If not in a diversion it is the same
13054 as register @code{nl}.
13058 @cindex high-water mark register (@code{.h})
13059 @cindex mark, high-water, register (@code{.h})
13060 @cindex position of lowest text line (@code{.h})
13061 @cindex text line, position of lowest (@code{.h})
13062 The @dfn{high-water mark} on the current page or in the current
13063 diversion. It corresponds to the text baseline of the lowest line
13064 on the page. This is a read-only register.
13067 .tm .h==\n[.h], nl==\n[nl]
13068 @result{} .h==0, nl==-1
13072 .tm .h==\n[.h], nl==\n[nl]
13073 @result{} .h==40, nl==120
13076 @cindex @code{.h} register, difference to @code{nl}
13077 @cindex @code{nl} register, difference to @code{.h}
13079 As can be seen in the previous example, empty lines are not considered
13080 in the return value of the @code{.h} register.
13084 @DefregListEndx {dl}
13085 @cindex @code{dn} register, and @code{da} (@code{boxa})
13086 @cindex @code{dl} register, and @code{da} (@code{boxa})
13087 @cindex @code{da} request, and @code{dn} (@code{dl})
13088 @cindex @code{boxa} request, and @code{dn} (@code{dl})
13089 After completing a diversion, the read-write number registers @code{dn}
13090 and @code{dl} contain the vertical and horizontal size of the diversion.
13091 Note that only the just processed lines are counted: For the computation
13092 of @code{dn} and @code{dl}, the requests @code{da} and @code{boxa} are
13093 handled as if @code{di} and @code{box} had been used -- lines that have
13094 been already stored in a macro are not taken into account.
13097 .\" Center text both horizontally & vertically
13099 .\" Enclose macro definitions in .eo and .ec
13100 .\" to avoid the doubling of the backslash
13102 .\" macro .(c starts centering mode
13113 .\" macro .)c terminates centering mode
13118 . nr @@s (((\n[.t]u - \n[dn]u) / 2u) - 1v)
13129 .\" End of macro definitions, restore escape mechanism
13134 @DefescList {\\!, , , }
13135 @DefescListEndx {\\?, , anything, \\?}
13136 @cindex transparent output (@code{\!}, @code{\?})
13137 @cindex output, transparent (@code{\!}, @code{\?})
13138 Prevent requests, macros, and escapes from being interpreted when read
13139 into a diversion. Both escapes take the given text and
13140 @dfn{transparently} embed it into the diversion. This is useful for
13141 macros that shouldn't be invoked until the diverted text is actually
13144 The @code{\!} escape transparently embeds text up to and including the
13145 end of the line. The @code{\?} escape transparently embeds text until
13146 the next occurrence of the @code{\?} escape. Example:
13152 @cindex @code{\?}, and copy-in mode
13153 @cindex copy-in mode, and @code{\?}
13154 @cindex mode, copy-in, and @code{\?}
13155 @cindex @code{\!}, and copy-in mode
13156 @cindex copy-in mode, and @code{\!}
13157 @cindex mode, copy-in, and @code{\!}
13159 @var{anything} may not contain newlines; use @code{\!} to embed
13160 newlines in a diversion. The escape sequence @code{\?} is also
13161 recognized in copy mode and turned into a single internal code; it is
13162 this code that terminates @var{anything}. Thus the following example
13169 \?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
13183 Both escapes read the data in copy mode.
13185 @cindex @code{\!}, in top-level diversion
13186 @cindex top-level diversion, and @code{\!}
13187 @cindex diversion, top-level, and @code{\!}
13188 If @code{\!} is used in the top-level diversion, its argument is
13189 directly embedded into the @code{gtroff} intermediate output. This can
13190 be used for example to control a postprocessor that processes the data
13191 before it is sent to the device driver.
13193 @cindex @code{\?}, in top-level diversion
13194 @cindex top-level diversion, and @code{\?}
13195 @cindex diversion, top-level, and @code{\?}
13196 The @code{\?} escape used in the top-level diversion produces no output
13197 at all; its argument is simply ignored.
13200 @cindex @code{\!}, and @code{output} request
13201 @cindex @code{output} request, and @code{\!}
13202 @cindex @code{output} request, and copy-in mode
13203 @cindex copy-in mode, and @code{output} request
13204 @cindex mode, copy-in, and @code{output} request
13205 @Defreq {output, string}
13206 Emit @var{string} directly to the @code{gtroff} intermediate output
13207 (subject to copy mode interpretation); this is similar to @code{\!} used
13208 at the top level. An initial double quote in @var{string} is stripped
13209 off to allow initial blanks.
13211 This request can't be used before the first page has started -- if you
13212 get an error, simply insert @code{.br} before the @code{output} request.
13214 Without argument, @code{output} is ignored.
13216 Use with caution! It is normally only needed for mark-up used by a
13217 postprocessor that does something with the output before sending it to
13218 the output device, filtering out @var{string} again.
13221 @Defreq {asciify, div}
13222 @cindex unformatting diversions (@code{asciify})
13223 @cindex diversion, unformatting (@code{asciify})
13224 @cindex @code{trin} request, and @code{asciify}
13225 @dfn{Unformat} the diversion specified by @var{div} in such a way that
13226 @acronym{ASCII} characters, characters translated with the @code{trin}
13227 request, space characters, and some escape sequences that were formatted
13228 and diverted are treated like ordinary input characters when the
13229 diversion is reread. It can be also used for gross hacks; for example,
13230 the following sets register@tie{}@code{n} to@tie{}1.
13243 Note that @code{asciify} cannot return all items in a diversion back
13244 to their source equivalent, nodes such as @code{\N[...]} will still
13245 remain as nodes, so the result cannot be guaranteed to be a pure string.
13247 @xref{Copy-in Mode}.
13250 @Defreq {unformat, div}
13251 Like @code{asciify}, unformat the specified diversion. However,
13252 @code{unformat} only unformats spaces and tabs between words.
13253 Unformatted tabs are treated as input tokens, and spaces are stretchable
13256 The vertical size of lines is not preserved; glyph information (font,
13257 font size, space width, etc.)@: is retained.
13261 @c =====================================================================
13263 @node Environments, Suppressing output, Diversions, gtroff Reference
13264 @section Environments
13265 @cindex environments
13267 It happens frequently that some text should be printed in a certain
13268 format regardless of what may be in effect at the time, for example, in
13269 a trap invoked macro to print headers and footers. To solve this
13270 @code{gtroff} processes text in @dfn{environments}. An environment
13271 contains most of the parameters that control text processing. It is
13272 possible to switch amongst these environments; by default @code{gtroff}
13273 processes text in environment@tie{}0. The following is the information
13274 kept in an environment.
13278 font parameters (size, family, style, glyph height and slant, space and
13279 sentence space size)
13282 page parameters (line length, title length, vertical spacing, line
13283 spacing, indentation, line numbering, centering, right-justifying,
13284 underlining, hyphenation data)
13287 fill and adjust mode
13290 tab stops, tab and leader characters, escape character, no-break and
13291 hyphen indicators, margin character data
13294 partially collected lines
13300 drawing and fill colours
13303 These environments may be given arbitrary names (see @ref{Identifiers},
13304 for more info). Old versions of @code{troff} only had environments
13305 named @samp{0}, @samp{1}, and @samp{2}.
13307 @DefreqList {ev, [@Var{env}]}
13308 @DefregListEndx {.ev}
13309 @cindex switching environments (@code{ev})
13310 @cindex environment, switching (@code{ev})
13311 @cindex environment number/name register (@code{.ev})
13312 Switch to another environment. The argument @var{env} is the name of
13313 the environment to switch to. With no argument, @code{gtroff} switches
13314 back to the previous environment. There is no limit on the number of
13315 named environments; they are created the first time that they are
13316 referenced. The @code{.ev} read-only register contains the name or
13317 number of the current environment. This is a string-valued register.
13319 Note that a call to @code{ev} (with argument) pushes the previously
13320 active environment onto a stack. If, say, environments @samp{foo},
13321 @samp{bar}, and @samp{zap} are called (in that order), the first
13322 @code{ev} request without parameter switches back to environment
13323 @samp{bar} (which is popped off the stack), and a second call switches
13324 back to environment @samp{foo}.
13326 Here is an example:
13339 \(dg Note the large, friendly letters.
13345 @cindex copying environment (@code{evc})
13346 @cindex environment, copying (@code{evc})
13347 Copy the environment @var{env} into the current environment.
13349 The following environment data is not copied:
13353 Partially filled lines.
13356 The status whether the previous line was interrupted.
13359 The number of lines still to center, or to right-justify, or to
13360 underline (with or without underlined spaces); they are set to zero.
13363 The status whether a temporary indentation is active.
13366 Input traps and its associated data.
13369 Line numbering mode is disabled; it can be reactivated with @w{@samp{.nm
13373 The number of consecutive hyphenated lines (set to zero).
13378 @DefregItemx {.cht}
13379 @DefregItemx {.cdp}
13380 @DefregListEndx {.csk}
13381 @cindex environment, dimensions of last glyph (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
13382 @cindex width, of last glyph (@code{.w})
13383 @cindex height, of last glyph (@code{.cht})
13384 @cindex depth, of last glyph (@code{.cdp})
13385 @cindex skew, of last glyph (@code{.csk})
13386 @cindex last glyph, dimensions (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
13387 @cindex glyph, last, dimensions (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
13388 The @code{\n[.w]} register contains the width of the last glyph added to
13389 the current environment.
13391 The @code{\n[.cht]} register contains the height of the last glyph added
13392 to the current environment.
13394 The @code{\n[.cdp]} register contains the depth of the last glyph added
13395 to the current environment. It is positive for glyphs extending below
13398 The @code{\n[.csk]} register contains the @dfn{skew} (how far to the
13399 right of the glyph's center that @code{gtroff} should place an accent)
13400 of the last glyph added to the current environment.
13404 @cindex environment, previous line length (@code{.n})
13405 @cindex line length, previous (@code{.n})
13406 @cindex length of previous line (@code{.n})
13407 @cindex previous line length (@code{.n})
13408 The @code{\n[.n]} register contains the length of the previous output
13409 line in the current environment.
13413 @c =====================================================================
13415 @node Suppressing output, Colors, Environments, gtroff Reference
13416 @section Suppressing output
13418 @Defesc {\\O, , num, }
13419 @cindex suppressing output (@code{\O})
13420 @cindex output, suppressing (@code{\O})
13421 Disable or enable output depending on the value of @var{num}:
13425 Disable any glyphs from being emitted to the device driver, provided
13426 that the escape occurs at the outer level (see @code{\O[3]} and
13427 @code{\O[4]}). Motion is not suppressed so effectively @code{\O[0]}
13428 means @emph{pen up}.
13431 Enable output of glyphs, provided that the escape occurs at the outer
13439 @code{\O0} and @code{\O1} also reset the four registers @samp{opminx},
13440 @samp{opminy}, @samp{opmaxx}, and @samp{opmaxy} to @minus{}1.
13441 @xref{Register Index}. These four registers mark the top left and
13442 bottom right hand corners of a box that encompasses all written glyphs.
13444 For example the input text:
13447 Hello \O[0]world \O[1]this is a test.
13451 produces the following output:
13454 Hello this is a test.
13459 Provided that the escape occurs at the outer level, enable output of
13460 glyphs and also write out to @code{stderr} the page number and four
13461 registers encompassing the glyphs previously written since the last call
13465 Begin a nesting level. At start-up, @code{gtroff} is at outer level.
13466 The current level is contained within the read-only register @code{.O}.
13467 @xref{Built-in Registers}.
13470 End a nesting level. The current level is contained within the
13471 read-only register @code{.O}. @xref{Built-in Registers}.
13473 @item \O[5@var{P}@var{filename}]
13474 This escape is @code{grohtml} specific. Provided that this escape
13475 occurs at the outer nesting level write the @code{filename} to
13476 @code{stderr}. The position of the image, @var{P}, must be specified
13477 and must be one of @code{l}, @code{r}, @code{c}, or@tie{}@code{i} (left,
13478 right, centered, inline). @var{filename} is associated with the
13479 production of the next inline image.
13484 @c =====================================================================
13486 @node Colors, I/O, Suppressing output, gtroff Reference
13490 @DefreqList {color, [@Var{n}]}
13491 @DefregListEndx {.color}
13492 If @var{n} is missing or non-zero, activate colors (this is the
13493 default); otherwise, turn it off.
13495 The read-only number register @code{.color} is@tie{}1 if colors are
13496 active, 0@tie{}otherwise.
13498 Internally, @code{color} sets a global flag; it does not produce a
13499 token. Similar to the @code{cp} request, you should use it at the
13500 beginning of your document to control color output.
13502 Colors can be also turned off with the @option{-c} command-line option.
13505 @Defreq {defcolor, ident scheme color_components}
13506 Define color with name @var{ident}. @var{scheme} can be one of the
13507 following values: @code{rgb} (three components), @code{cmy} (three
13508 components), @code{cmyk} (four components), and @code{gray} or
13509 @code{grey} (one component).
13511 @cindex default color
13512 @cindex color, default
13513 Color components can be given either as a hexadecimal string or as
13514 positive decimal integers in the range 0--65535. A hexadecimal string
13515 contains all color components concatenated. It must start with either
13516 @code{#} or @code{##}; the former specifies hex values in the range
13517 0--255 (which are internally multiplied by@tie{}257), the latter in the
13518 range 0--65535. Examples: @code{#FFC0CB} (pink), @code{##ffff0000ffff}
13519 (magenta). The default color name @c{default} can't be redefined; its
13520 value is device-specific (usually black). It is possible that the
13521 default color for @code{\m} and @code{\M} is not identical.
13523 @cindex @code{f} unit, and colors
13524 @cindex unit, @code{f}, and colors
13525 A new scaling indicator@tie{}@code{f} has been introduced, which
13526 multiplies its value by 65536; this makes it convenient to specify color
13527 components as fractions in the range 0 to@tie{}1 (1f equals 65536u).
13531 .defcolor darkgreen rgb 0.1f 0.5f 0.2f
13534 Note that @code{f} is the default scaling indicator for the
13535 @code{defcolor} request, thus the above statement is equivalent to
13538 .defcolor darkgreen rgb 0.1 0.5 0.2
13542 @DefreqList {gcolor, [@Var{color}]}
13543 @DefescItemx {\\m, , c, }
13544 @DefescItem {\\m, @Lparen{}, co, }
13545 @DefescItem {\\m, @Lbrack{}, color, @Rbrack{}}
13546 @DefregListEndx {.m}
13547 Set (glyph) drawing color. The following examples show how to turn the
13548 next four words red.
13554 and these words are in black.
13558 \m[red]these are in red\m[] and these words are in black.
13561 The escape @code{\m[]} returns to the previous color, as does a call to
13562 @code{gcolor} without an argument.
13564 @cindex drawing color name register (@code{.m})
13565 @cindex name, drawing color, register (@code{.m})
13566 @cindex color name, drawing, register (@code{.m})
13567 The name of the current drawing color is available in the read-only,
13568 string-valued number register @samp{.m}.
13570 The drawing color is associated with the current environment
13571 (@pxref{Environments}).
13573 Note that @code{\m} doesn't produce an input token in @code{gtroff}. As
13574 a consequence, it can be used in requests like @code{mc} (which expects
13575 a single character as an argument) to change the color on the fly:
13582 @DefreqList {fcolor, [@Var{color}]}
13583 @DefescItemx {\\M, , c, }
13584 @DefescItem {\\M, @Lparen{}, co, }
13585 @DefescItem {\\M, @Lbrack{}, color, @Rbrack{}}
13586 @DefregListEndx {.M}
13587 Set fill (background) color for filled objects drawn with the
13588 @code{\D'@dots{}'} commands.
13590 A red ellipse can be created with the following code:
13593 \M[red]\h'0.5i'\D'E 2i 1i'\M[]
13596 The escape @code{\M[]} returns to the previous fill color, as does a
13597 call to @code{fcolor} without an argument.
13599 @cindex background color name register (@code{.M})
13600 @cindex name, background color, register (@code{.M})
13601 @cindex color name, background, register (@code{.M})
13602 @cindex fill color name register (@code{.M})
13603 @cindex name, fill color, register (@code{.M})
13604 @cindex color name, fill, register (@code{.M})
13605 The name of the current fill (background) color is available in the
13606 read-only, string-valued number register @samp{.M}.
13608 The fill color is associated with the current environment
13609 (@pxref{Environments}).
13611 Note that @code{\M} doesn't produce an input token in @code{gtroff}.
13615 @c =====================================================================
13617 @node I/O, Postprocessor Access, Colors, gtroff Reference
13620 @cindex input and output requests
13621 @cindex requests for input and output
13622 @cindex output and input requests
13624 @code{gtroff} has several requests for including files:
13627 @cindex including a file (@code{so})
13628 @cindex file, inclusion (@code{so})
13629 Read in the specified @var{file} and includes it in place of the
13630 @code{so} request. This is quite useful for large documents, e.g.@:
13631 keeping each chapter in a separate file. @xref{gsoelim}, for more
13634 Since @code{gtroff} replaces the @code{so} request with the contents of
13635 @code{file}, it makes a difference whether the data is terminated with a
13636 newline or not: Assuming that file @file{xxx} contains the word
13637 @samp{foo} without a final newline, this
13646 yields @samp{This is foobar}.
13648 The search path for @var{file} can be controlled with the @option{-I}
13649 command-line option.
13652 @Defreq {pso, command}
13653 Read the standard output from the specified @var{command} and includes
13654 it in place of the @code{pso} request.
13657 @cindex mode, safer
13658 @cindex unsafe mode
13659 @cindex mode, unsafe
13660 This request causes an error if used in safer mode (which is the
13661 default). Use @code{groff}'s or @code{troff}'s @option{-U} option to
13662 activate unsafe mode.
13664 The comment regarding a final newline for the @code{so} request is valid
13665 for @code{pso} also.
13668 @Defreq {mso, file}
13669 Identical to the @code{so} request except that @code{gtroff} searches
13670 for the specified @var{file} in the same directories as macro files for
13671 the @option{-m} command-line option.
13672 If the file name to be included has the form @file{@var{name}.tmac} and it
13673 isn't found, @code{mso} tries to include @file{tmac.@var{name}} and vice
13675 If the file does not exist, a warning of type @samp{file} is emitted.
13676 @xref{Debugging}, for information about warnings.
13679 @DefreqList {trf, file}
13680 @DefreqListEndx {cf, file}
13681 @cindex transparent output (@code{cf}, @code{trf})
13682 @cindex output, transparent (@code{cf}, @code{trf})
13683 @cindex @code{cf} request, and copy-in mode
13684 @cindex copy-in mode, and @code{cf} request
13685 @cindex mode, copy-in, and @code{cf} request
13686 @cindex @code{trf} request, and copy-in mode
13687 @cindex copy-in mode, and @code{trf} request
13688 @cindex mode, copy-in, and @code{trf} request
13689 Transparently output the contents of @var{file}. Each line is output as
13690 if it were preceded by @code{\!}; however, the lines are @emph{not}
13691 subject to copy mode interpretation. If the file does not end with a
13692 newline, then a newline is added (@code{trf} only). For example, to
13693 define a macro@tie{}@code{x} containing the contents of
13694 file@tie{}@file{f}, use
13705 The calls to @code{ev} prevent that the current partial input line
13706 becomes part of the diversion.
13708 Both @code{trf} and @code{cf}, when used in a diversion, embeds an
13709 object in the diversion which, when reread, causes the contents of
13710 @var{file} to be transparently copied through to the output. In
13711 Unix @code{troff}, the contents of @var{file} is immediately copied
13712 through to the output regardless of whether there is a current
13713 diversion; this behaviour is so anomalous that it must be considered a
13716 @cindex @code{trf} request, and invalid characters
13717 @cindex characters, invalid for @code{trf} request
13718 @cindex invalid characters for @code{trf} request
13720 While @code{cf} copies the contents of @var{file} completely
13721 unprocessed, @code{trf} disallows characters such as NUL that are not
13722 valid @code{gtroff} input characters (@pxref{Identifiers}).
13724 For @code{cf}, within a diversion, `completely unprocessed' means that
13725 each line of a file to be inserted is handled as if it were preceded by
13728 Both requests cause a line break.
13731 @Defreq {nx, [@Var{file}]}
13732 @cindex processing next file (@code{nx})
13733 @cindex file, processing next (@code{nx})
13734 @cindex next file, processing (@code{nx})
13735 Force @code{gtroff} to continue processing of the file specified as an
13736 argument. If no argument is given, immediately jump to the end of file.
13739 @Defreq {rd, [@Var{prompt} [@Var{arg1} @Var{arg2} @dots{}]]}
13740 @cindex reading from standard input (@code{rd})
13741 @cindex standard input, reading from (@code{rd})
13742 @cindex input, standard, reading from (@code{rd})
13743 Read from standard input, and include what is read as though it were
13744 part of the input file. Text is read until a blank line is encountered.
13746 If standard input is a TTY input device (keyboard), write @var{prompt}
13747 to standard error, followed by a colon (or send BEL for a beep if no
13748 argument is given).
13750 Arguments after @var{prompt} are available for the input. For example,
13757 with the input @w{@samp{This is \$2.}} prints
13764 @cindex form letters
13765 @cindex letters, form
13766 Using the @code{nx} and @code{rd} requests, it is easy to set up form
13767 letters. The form letter template is constructed like this, putting the
13768 following lines into a file called @file{repeat.let}:
13784 @cindex @code{ex} request, used with @code{nx} and @code{rd}
13786 When this is run, a file containing the following lines should be
13787 redirected in. Note that requests included in this file are executed as
13788 though they were part of the form letter. The last block of input is
13789 the @code{ex} request, which tells @code{groff} to stop processing. If
13790 this was not there, @code{groff} would not know when to stop.
13794 708 NW 19th Av., #202
13801 San Diego, CA 92103
13809 Pipe the output of @code{gtroff} to the shell command(s) specified by
13810 @var{pipe}. This request must occur before @code{gtroff} has a chance
13814 @cindex mode, safer
13815 @cindex unsafe mode
13816 @cindex mode, unsafe
13817 @code{pi} causes an error if used in safer mode (which is the default).
13818 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate
13821 Multiple calls to @code{pi} are allowed, acting as a chain. For
13830 is the same as @w{@samp{.pi foo | bar}}.
13832 @cindex @code{groff}, and @code{pi} request
13833 @cindex @code{pi} request, and @code{groff}
13834 Note that the intermediate output format of @code{gtroff} is piped to
13835 the specified commands. Consequently, calling @code{groff} without the
13836 @option{-Z} option normally causes a fatal error.
13839 @DefreqList {sy, cmds}
13840 @DefregListEndx {systat}
13841 Execute the shell command(s) specified by @var{cmds}. The output is not
13842 saved anyplace, so it is up to the user to do so.
13845 @cindex mode, safer
13846 @cindex unsafe mode
13847 @cindex mode, unsafe
13848 This request causes an error if used in safer mode (which is the
13849 default). Use @code{groff}'s or @code{troff}'s @option{-U} option to
13850 activate unsafe mode.
13852 For example, the following code fragment introduces the current time
13855 @cindex time, current
13856 @cindex current time
13859 .sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
13860 (localtime(time))[2,1,0]' > /tmp/x\n[$$]
13862 .sy rm /tmp/x\n[$$]
13867 Note that this works by having the @code{perl} script (run by @code{sy})
13868 print out the @code{nr} requests that set the number registers
13869 @code{H}, @code{M}, and @code{S}, and then reads those commands in with
13870 the @code{so} request.
13872 For most practical purposes, the number registers @code{seconds},
13873 @code{minutes}, and @code{hours}, which are initialized at start-up of
13874 @code{gtroff}, should be sufficient. Use the @code{af} request to get a
13881 \n[hours]:\n[minutes]:\n[seconds]
13884 @cindex @code{system()} return value register (@code{systat})
13885 The @code{systat} read-write number register contains the return value
13886 of the @code{system()} function executed by the last @code{sy} request.
13889 @DefreqList {open, stream file}
13890 @DefreqListEndx {opena, stream file}
13891 @cindex opening file (@code{open})
13892 @cindex file, opening (@code{open})
13893 @cindex appending to a file (@code{opena})
13894 @cindex file, appending to (@code{opena})
13895 Open the specified @var{file} for writing and associates the specified
13896 @var{stream} with it.
13898 The @code{opena} request is like @code{open}, but if the file exists,
13899 append to it instead of truncating it.
13902 @cindex mode, safer
13903 @cindex unsafe mode
13904 @cindex mode, unsafe
13905 Both @code{open} and @code{opena} cause an error if used in safer mode
13906 (which is the default). Use @code{groff}'s or @code{troff}'s
13907 @option{-U} option to activate unsafe mode.
13910 @DefreqList {write, stream data}
13911 @DefreqListEndx {writec, stream data}
13912 @cindex copy-in mode, and @code{write} request
13913 @cindex @code{write} request, and copy-in mode
13914 @cindex mode, copy-in, and @code{write} request
13915 @cindex copy-in mode, and @code{writec} request
13916 @cindex @code{writec} request, and copy-in mode
13917 @cindex mode, copy-in, and @code{writec} request
13918 @cindex writing to file (@code{write}, @code{writec})
13919 @cindex file, writing to (@code{write}, @code{writec})
13920 Write to the file associated with the specified @var{stream}. The
13921 stream must previously have been the subject of an open request. The
13922 remainder of the line is interpreted as the @code{ds} request reads its
13923 second argument: A leading @samp{"} is stripped, and it is read in
13926 The @code{writec} request is like @code{write}, but only @code{write}
13927 appends a newline to the data.
13930 @Defreq {writem, stream xx}
13931 @cindex @code{asciify} request, and @code{writem}
13932 Write the contents of the macro or string @var{xx} to the file
13933 associated with the specified @var{stream}.
13935 @cindex @code{writem} request, and copy-in mode
13936 @cindex copy-in mode, and @code{writem} request
13937 @cindex mode, copy-in, and @code{writem} request
13938 @var{xx} is read in copy mode, i.e., already formatted elements are
13939 ignored. Consequently, diversions must be unformatted with the
13940 @code{asciify} request before calling @code{writem}. Usually, this
13941 means a loss of information.
13944 @Defreq {close, stream}
13945 @cindex closing file (@code{close})
13946 @cindex file, closing (@code{close})
13947 Close the specified @var{stream}; the stream is no longer an acceptable
13948 argument to the @code{write} request.
13950 Here a simple macro to write an index entry.
13956 . write idx \\n[%] \\$*
13965 @DefescList {\\V, , e, }
13966 @DefescItem {\\V, @Lparen{}, ev, }
13967 @DefescListEnd {\\V, @Lbrack{}, env, @Rbrack{}}
13968 @cindex @code{\V}, and copy-in mode
13969 @cindex copy-in mode, and @code{\V}
13970 @cindex mode, copy-in, and @code{\V}
13971 Interpolate the contents of the specified environment variable @var{env}
13972 (one-character name@tie{}@var{e}, two-character name @var{ev}) as
13973 returned by the function @code{getenv}. @code{\V} is interpreted in
13978 @c =====================================================================
13980 @node Postprocessor Access, Miscellaneous, I/O, gtroff Reference
13981 @section Postprocessor Access
13982 @cindex postprocessor access
13983 @cindex access of postprocessor
13985 There are two escapes that give information directly to the
13986 postprocessor. This is particularly useful for embedding
13987 @sc{PostScript} into the final document.
13989 @DefreqList {device, xxx}
13990 @DefescListEndx {\\X, ', xxx, '}
13991 Embeds its argument into the @code{gtroff} output preceded with
13994 @cindex @code{\&}, in @code{\X}
13995 @cindex @code{\)}, in @code{\X}
13996 @cindex @code{\%}, in @code{\X}
13998 @cindex @code{\:}, in @code{\X}
14001 @cindex @code{\@r{<colon>}}, in @code{\X}
14003 The escapes @code{\&}, @code{\)}, @code{\%}, and @code{\:} are ignored
14004 within @code{\X}, @w{@samp{\ }} and @code{\~} are converted to single
14005 space characters. All other escapes (except @code{\\}, which produces a
14006 backslash) cause an error.
14008 @cindex @code{device} request, and copy-in mode
14009 @cindex copy-in mode, and @code{device} request
14010 @cindex mode, copy-in, and @code{device} request
14011 Contrary to @code{\X}, the @code{device} request simply processes its
14012 argument in copy mode (@pxref{Copy-in Mode}).
14014 @kindex use_charnames_in_special
14015 @pindex DESC@r{, and @code{use_charnames_in_special}}
14016 @cindex @code{\X}, and special characters
14017 If the @samp{use_charnames_in_special} keyword is set in the @file{DESC}
14018 file, special characters no longer cause an error; they are simply
14019 output verbatim. Additionally, the backslash is represented as
14022 @samp{use_charnames_in_special} is currently used by @code{grohtml}
14026 @DefreqList {devicem, xx}
14027 @DefescItemx {\\Y, , n, }
14028 @DefescItem {\\Y, @Lparen{}, nm, }
14029 @DefescListEnd {\\Y, @Lbrack{}, name, @Rbrack{}}
14030 This is approximately equivalent to @samp{\X'\*[@var{name}]'}
14031 (one-character name@tie{}@var{n}, two-character name @var{nm}).
14032 However, the contents of the string or macro @var{name} are not
14033 interpreted; also it is permitted for @var{name} to have been defined as
14034 a macro and thus contain newlines (it is not permitted for the argument
14035 to @code{\X} to contain newlines). The inclusion of newlines requires
14036 an extension to the Unix @code{troff} output format, and confuses
14037 drivers that do not know about this extension (@pxref{Device Control
14041 @xref{Output Devices}.
14044 @c =====================================================================
14046 @node Miscellaneous, Gtroff Internals, Postprocessor Access, gtroff Reference
14047 @section Miscellaneous
14049 This section documents parts of @code{gtroff} that cannot (yet) be
14050 categorized elsewhere in this manual.
14052 @Defreq {nm, [@Var{start} [@Var{inc} [@Var{space} [@Var{indent}]]]]}
14053 @cindex printing line numbers (@code{nm})
14054 @cindex line numbers, printing (@code{nm})
14055 @cindex numbers, line, printing (@code{nm})
14056 Print line numbers. @var{start} is the line number of the @emph{next}
14057 output line. @var{inc} indicates which line numbers are printed. For
14058 example, the value@tie{}5 means to emit only line numbers that are
14059 multiples of@tie{}5; this defaults to@tie{}1. @var{space} is the space
14060 to be left between the number and the text; this defaults to one digit
14061 space. The fourth argument is the indentation of the line numbers,
14062 defaulting to zero. Both @var{space} and @var{indent} are given as
14063 multiples of digit spaces; they can be negative also. Without any
14064 arguments, line numbers are turned off.
14066 @code{gtroff} reserves three digit spaces for the line number (which is
14067 printed right-justified) plus the amount given by @var{indent}; the
14068 output lines are concatenated to the line numbers, separated by
14069 @var{space}, and @emph{without} reducing the line length. Depending on
14070 the value of the horizontal page offset (as set with the @code{po}
14071 request), line numbers that are longer than the reserved space stick
14072 out to the left, or the whole line is moved to the right.
14074 Parameters corresponding to missing arguments are not changed; any
14075 non-digit argument (to be more precise, any argument starting with a
14076 character valid as a delimiter for identifiers) is also treated as
14079 If line numbering has been disabled with a call to @code{nm} without an
14080 argument, it can be reactivated with @samp{.nm +0}, using the previously
14081 active line numbering parameters.
14083 The parameters of @code{nm} are associated with the current environment
14084 (@pxref{Environments}). The current output line number is available in
14085 the number register @code{ln}.
14090 This test shows how line numbering works with groff.
14092 This test shows how line numbering works with groff.
14096 This test shows how line numbering works with groff.
14098 This test shows how line numbering works with groff.
14102 And here the result:
14105 This test shows how
14106 line numbering works
14107 999 with groff. This
14108 1000 test shows how line
14109 1001 numbering works with
14111 This test shows how
14114 This test shows how
14115 1005 line numbering
14120 @Defreq {nn, [@Var{skip}]}
14121 Temporarily turn off line numbering. The argument is the number of
14122 lines not to be numbered; this defaults to@tie{}1.
14125 @Defreq {mc, glyph [@Var{dist}]}
14126 @cindex margin glyph (@code{mc})
14127 @cindex glyph, for margins (@code{mc})
14128 Print a @dfn{margin character} to the right of the
14129 text.@footnote{@dfn{Margin character} is a misnomer since it is an
14130 output glyph.} The first argument is the glyph to be printed. The
14131 second argument is the distance away from the right margin. If missing,
14132 the previously set value is used; default is 10@dmn{pt}). For text
14133 lines that are too long (that is, longer than the text length plus
14134 @var{dist}), the margin character is directly appended to the lines.
14136 With no arguments the margin character is turned off. If this occurs
14137 before a break, no margin character is printed.
14139 For compatibility with @acronym{AT&T} @code{troff}, a call to @code{mc}
14140 to set the margin character can't be undone immediately; at least one
14141 line gets a margin character. Thus
14160 @cindex @code{tl} request, and @code{mc}
14161 For empty lines and lines produced by the @code{tl} request no margin
14162 character is emitted.
14164 The margin character is associated with the current environment
14165 (@pxref{Environments}).
14169 This is quite useful for indicating text that has changed, and, in fact,
14170 there are programs available for doing this (they are called
14171 @code{nrchbar} and @code{changebar} and can be found in any
14172 @samp{comp.sources.unix} archive).
14177 This paragraph is highlighted with a margin
14180 Note that vertical space isn't marked.
14184 But we can fake it with `\&'.
14190 This paragraph is highlighted |
14191 with a margin character. |
14193 Note that vertical space isn't |
14196 But we can fake it with `\&'. |
14200 @DefreqList {psbb, filename}
14204 @DefregListEndx {ury}
14205 @cindex PostScript, bounding box
14206 @cindex bounding box
14207 Retrieve the bounding box of the @sc{PostScript} image found in
14208 @var{filename}. The file must conform to Adobe's @dfn{Document
14209 Structuring Conventions} (DSC); the command searches for a
14210 @code{%%BoundingBox} comment and extracts the bounding box values into
14211 the number registers @code{llx}, @code{lly}, @code{urx}, and @code{ury}.
14212 If an error occurs (for example, @code{psbb} cannot find the
14213 @code{%%BoundingBox} comment), it sets the four number registers to
14216 The search path for @var{filename} can be controlled with the
14217 @option{-I} command-line option.
14221 @c =====================================================================
14223 @node Gtroff Internals, Debugging, Miscellaneous, gtroff Reference
14224 @section @code{gtroff} Internals
14226 @cindex input token
14227 @cindex token, input
14228 @cindex output node
14229 @cindex node, output
14230 @code{gtroff} processes input in three steps. One or more input
14231 characters are converted to an @dfn{input token}.@footnote{Except the
14232 escapes @code{\f}, @code{\F}, @code{\H}, @code{\m}, @code{\M},
14233 @code{\R}, @code{\s}, and @code{\S}, which are processed immediately if
14234 not in copy-in mode.} Then, one or more input tokens are converted to
14235 an @dfn{output node}. Finally, output nodes are converted to the
14236 intermediate output language understood by all output devices.
14238 Actually, before step one happens, @code{gtroff} converts certain escape
14239 sequences into reserved input characters (not accessible by the user);
14240 such reserved characters are used for other internal processing also --
14241 this is the very reason why not all characters are valid input.
14242 @xref{Identifiers}, for more on this topic.
14244 For example, the input string @samp{fi\[:u]} is converted into a
14245 character token @samp{f}, a character token @samp{i}, and a special
14246 token @samp{:u} (representing u@tie{}umlaut). Later on, the character
14247 tokens @samp{f} and @samp{i} are merged to a single output node
14248 representing the ligature glyph @samp{fi} (provided the current font has
14249 a glyph for this ligature); the same happens with @samp{:u}. All output
14250 glyph nodes are `processed', which means that they are invariably
14251 associated with a given font, font size, advance width, etc. During the
14252 formatting process, @code{gtroff} itself adds various nodes to control
14255 Macros, diversions, and strings collect elements in two chained lists: a
14256 list of input tokens that have been passed unprocessed, and a list of
14257 output nodes. Consider the following the diversion.
14269 It contains these elements.
14271 @multitable {@i{vertical size node}} {token list} {element number}
14272 @item node list @tab token list @tab element number
14274 @item @i{line start node} @tab --- @tab 1
14275 @item @i{glyph node @code{a}} @tab --- @tab 2
14276 @item @i{word space node} @tab --- @tab 3
14277 @item --- @tab @code{b} @tab 4
14278 @item --- @tab @code{\n} @tab 5
14279 @item @i{glyph node @code{c}} @tab --- @tab 6
14280 @item @i{vertical size node} @tab --- @tab 7
14281 @item @i{vertical size node} @tab --- @tab 8
14282 @item --- @tab @code{\n} @tab 9
14285 @cindex @code{\v}, internal representation
14287 Elements 1, 7, and@tie{}8 are inserted by @code{gtroff}; the latter two
14288 (which are always present) specify the vertical extent of the last line,
14289 possibly modified by @code{\x}. The @code{br} request finishes the
14290 current partial line, inserting a newline input token, which is
14291 subsequently converted to a space when the diversion is reread. Note
14292 that the word space node has a fixed width that isn't stretchable
14293 anymore. To convert horizontal space nodes back to input tokens, use
14294 the @code{unformat} request.
14296 Macros only contain elements in the token list (and the node list is
14297 empty); diversions and strings can contain elements in both lists.
14299 Note that the @code{chop} request simply reduces the number of elements
14300 in a macro, string, or diversion by one. Exceptions are
14301 @dfn{compatibility save} and @dfn{compatibility ignore} input tokens,
14302 which are ignored. The @code{substring} request also ignores those
14305 Some requests like @code{tr} or @code{cflags} work on glyph identifiers
14306 only; this means that the associated glyph can be changed without
14307 destroying this association. This can be very helpful for substituting
14308 glyphs. In the following example, we assume that glyph @samp{foo} isn't
14309 available by default, so we provide a substitution using the
14310 @code{fchar} request and map it to input character @samp{x}.
14318 Now let us assume that we install an additional special font @samp{bar}
14319 that has glyph @samp{foo}.
14327 Since glyphs defined with @code{fchar} are searched before glyphs in
14328 special fonts, we must call @code{rchar} to remove the definition of the
14329 fallback glyph. Anyway, the translation is still active; @samp{x} now
14330 maps to the real glyph @samp{foo}.
14332 @cindex compatibility mode, and parameters
14333 @cindex mode, compatibility, and parameters
14334 @cindex arguments, and compatibility mode
14335 @cindex parameters, and compatibility mode
14336 @cindex macro arguments, and compatibility mode
14337 @cindex request arguments, and compatibility mode
14338 Macro and request arguments preserve the compatibility mode:
14341 .cp 1 \" switch to compatibility mode
14345 .cp 0 \" switch compatibility mode off
14351 Since compatibility mode is on while @code{de} is called, the macro
14352 @code{xx} activates compatibility mode while executing. Argument
14353 @code{$1} can still be handled properly because it inherits the
14354 compatibility mode status which was active at the point where @code{xx}
14357 After expansion of the parameters, the compatibility save and restore
14358 tokens are removed.
14361 @c =====================================================================
14363 @node Debugging, Implementation Differences, Gtroff Internals, gtroff Reference
14367 @code{gtroff} is not easy to debug, but there are some useful features
14368 and strategies for debugging.
14370 @Defreq {lf, line [@Var{filename}]}
14372 @cindex multi-file documents
14373 @cindex documents, multi-file
14374 @cindex setting input line number (@code{lf})
14375 @cindex input line number, setting (@code{lf})
14376 @cindex number, input line, setting (@code{lf})
14377 Change the line number and optionally the file name @code{gtroff} shall
14378 use for error and warning messages. @var{line} is the input line number
14379 of the @emph{next} line.
14381 Without argument, the request is ignored.
14383 This is a debugging aid for documents that are split into many files,
14384 then put together with @code{soelim} and other preprocessors. Usually,
14385 it isn't invoked manually.
14387 Note that other @code{troff} implementations (including the original
14388 @acronym{AT&T} version) handle @code{lf} differently. For them,
14389 @var{line} changes the line number of the @emph{current} line.
14392 @DefreqList {tm, string}
14393 @DefreqItemx {tm1, string}
14394 @DefreqListEndx {tmc, string}
14395 @cindex printing to stderr (@code{tm}, @code{tm1}, @code{tmc})
14396 @cindex stderr, printing to (@code{tm}, @code{tm1}, @code{tmc})
14397 Send @var{string} to the standard error output; this is very useful for
14398 printing debugging messages among other things.
14400 @cindex @code{tm} request, and copy-in mode
14401 @cindex copy-in mode, and @code{tm} request
14402 @cindex mode, copy-in, and @code{tm} request
14403 @cindex @code{tm1} request, and copy-in mode
14404 @cindex copy-in mode, and @code{tm1} request
14405 @cindex mode, copy-in, and @code{tm1} request
14406 @cindex @code{tmc} request, and copy-in mode
14407 @cindex copy-in mode, and @code{tmc} request
14408 @cindex mode, copy-in, and @code{tmc} request
14409 @var{string} is read in copy mode.
14411 The @code{tm} request ignores leading spaces of @var{string}; @code{tm1}
14412 handles its argument similar to the @code{ds} request: a leading double
14413 quote in @var{string} is stripped to allow initial blanks.
14415 The @code{tmc} request is similar to @code{tm1} but does not append a
14416 newline (as is done in @code{tm} and @code{tm1}).
14419 @Defreq {ab, [@Var{string}]}
14420 @cindex aborting (@code{ab})
14421 Similar to the @code{tm} request, except that it causes @code{gtroff} to
14422 stop processing. With no argument it prints @samp{User Abort.} to
14427 @cindex @code{ex} request, use in debugging
14428 @cindex exiting (@code{ex})
14429 The @code{ex} request also causes @code{gtroff} to stop processing; see
14433 When doing something involved it is useful to leave the debugging
14434 statements in the code and have them turned on by a command-line flag.
14437 .if \n(DB .tm debugging output
14441 To activate these statements say
14447 If it is known in advance that there are many errors and no useful
14448 output, @code{gtroff} can be forced to suppress formatted output with
14449 the @option{-z} flag.
14452 @cindex dumping environments (@code{pev})
14453 @cindex environments, dumping (@code{pev})
14454 Print the contents of the current environment and all the currently
14455 defined environments (both named and numbered) on @code{stderr}.
14459 @cindex dumping symbol table (@code{pm})
14460 @cindex symbol table, dumping (@code{pm})
14461 Print the entire symbol table on @code{stderr}. Names of all defined
14462 macros, strings, and diversions are print together with their size in
14463 bytes. Since @code{gtroff} sometimes adds nodes by itself, the returned
14464 size can be larger than expected.
14466 This request differs from Unix @code{troff}: @code{gtroff} reports the
14467 sizes of diversions, ignores an additional argument to print only the
14468 total of the sizes, and the size isn't returned in blocks of 128
14473 @cindex dumping number registers (@code{pnr})
14474 @cindex number registers, dumping (@code{pnr})
14475 Print the names and contents of all currently defined number registers
14480 @cindex dumping traps (@code{ptr})
14481 @cindex traps, dumping (@code{ptr})
14482 Print the names and positions of all traps (not including input line
14483 traps and diversion traps) on @code{stderr}. Empty slots in the page
14484 trap list are printed as well, because they can affect the priority of
14485 subsequently planted traps.
14489 @cindex flush output (@code{fl})
14490 @cindex output, flush (@code{fl})
14491 @cindex interactive use of @code{gtroff}
14492 @cindex @code{gtroff}, interactive use
14493 Instruct @code{gtroff} to flush its output immediately. The intent is
14494 for interactive use, but this behaviour is currently not implemented in
14495 @code{gtroff}. Contrary to Unix @code{troff}, TTY output is sent to a
14496 device driver also (@code{grotty}), making it non-trivial to communicate
14499 This request causes a line break.
14502 @Defreq {backtrace, }
14503 @cindex backtrace of input stack (@code{backtrace})
14504 @cindex input stack, backtrace (@code{backtrace})
14505 Print a backtrace of the input stack to the standard error stream.
14507 Consider the following in file @file{test}:
14521 On execution, @code{gtroff} prints the following:
14524 test:2: backtrace: macro `xxx'
14525 test:5: backtrace: macro `yyy'
14526 test:8: backtrace: file `test'
14529 The option @option{-b} of @code{gtroff} internally calls a variant of
14530 this request on each error and warning.
14534 @cindex input stack, setting limit
14535 Use the @code{slimit} number register to set the maximum number of
14536 objects on the input stack. If @code{slimit} is less than or equal
14537 to@tie{}0, there is no limit set. With no limit, a buggy recursive
14538 macro can exhaust virtual memory.
14540 The default value is 1000; this is a compile-time constant.
14543 @Defreq {warnscale, si}
14544 Set the scaling indicator used in warnings to @var{si}. Valid values
14545 for @var{si} are @samp{u}, @samp{i}, @samp{c}, @samp{p}, and @samp{P}.
14546 At startup, it is set to @samp{i}.
14549 @Defreq {spreadwarn, [@Var{limit}]}
14550 Make @code{gtroff} emit a warning if the additional space inserted for
14551 each space between words in an output line is larger or equal to
14552 @var{limit}. A negative value is changed to zero; no argument toggles
14553 the warning on and off without changing @var{limit}. The default
14554 scaling indicator is @samp{m}. At startup, @code{spreadwarn} is
14555 deactivated, and @var{limit} is set to 3@dmn{m}.
14564 causes a warning if @code{gtroff} must add 0.2@dmn{m} or more for each
14565 interword space in a line.
14567 This request is active only if text is justified to both margins (using
14572 @code{gtroff} has command-line options for printing out more warnings
14573 (@option{-w}) and for printing backtraces (@option{-b}) when a warning
14574 or an error occurs. The most verbose level of warnings is @option{-ww}.
14576 @DefreqList {warn, [@Var{flags}]}
14577 @DefregListEndx {.warn}
14578 @cindex level of warnings (@code{warn})
14579 @cindex warnings, level (@code{warn})
14580 Control the level of warnings checked for. The @var{flags} are the sum
14581 of the numbers associated with each warning that is to be enabled; all
14582 other warnings are disabled. The number associated with each warning is
14583 listed below. For example, @w{@code{.warn 0}} disables all warnings,
14584 and @w{@code{.warn 1}} disables all warnings except that about missing
14585 glyphs. If no argument is given, all warnings are enabled.
14587 The read-only number register @code{.warn} contains the current warning
14595 @c ---------------------------------------------------------------------
14597 @node Warnings, , Debugging, Debugging
14598 @subsection Warnings
14601 The warnings that can be given to @code{gtroff} are divided into the
14602 following categories. The name associated with each warning is used by
14603 the @option{-w} and @option{-W} options; the number is used by the
14604 @code{warn} request and by the @code{.warn} register.
14609 Non-existent glyphs.@footnote{@code{char} is a misnomer since it reports
14610 missing glyphs -- there aren't missing input characters, only invalid
14611 ones.} This is enabled by default.
14615 Invalid numeric expressions. This is enabled by default.
14616 @xref{Expressions}.
14622 In fill mode, lines that could not be broken so that their length was
14623 less than the line length. This is enabled by default.
14627 Missing or mismatched closing delimiters.
14631 @cindex @code{ie} request, and warnings
14632 @cindex @code{el} request, and warnings
14633 Use of the @code{el} request with no matching @code{ie} request.
14638 Meaningless scaling indicators.
14642 Out of range arguments.
14646 Dubious syntax in numeric expressions.
14650 @cindex @code{di} request, and warnings
14651 @cindex @code{da} request, and warnings
14652 Use of @code{di} or @code{da} without an argument when there is no
14657 @cindex @code{de}, @code{de1}, @code{dei} requests, and warnings
14658 @cindex @code{am}, @code{am1}, @code{ami} requests, and warnings
14659 @cindex @code{ds}, @code{ds1} requests, and warnings
14660 @cindex @code{as}, @code{as1} requests, and warnings
14661 @cindex @code{di} request, and warnings
14662 @cindex @code{da} request, and warnings
14663 @cindex @code{box}, @code{boxa} requests, and warnings
14664 @cindex @code{\*}, and warnings
14665 Use of undefined strings, macros and diversions. When an undefined
14666 string, macro, or diversion is used, that string is automatically
14667 defined as empty. So, in most cases, at most one warning is given for
14672 @cindex @code{nr} request, and warnings
14673 @cindex @code{\R}, and warnings
14674 @cindex @code{\n}, and warnings
14675 Use of undefined number registers. When an undefined number register is
14676 used, that register is automatically defined to have a value of@tie{}0.
14677 So, in most cases, at most one warning is given for use of a particular
14682 @cindex @code{\t}, and warnings
14683 Use of a tab character where a number was expected.
14687 @cindex @code{\@}}, and warnings
14688 Use of @code{\@}} where a number was expected.
14692 Requests that are missing non-optional arguments.
14696 Invalid input characters.
14700 Unrecognized escape sequences. When an unrecognized escape sequence
14701 @code{\@var{X}} is encountered, the escape character is ignored, and
14702 @var{X} is printed.
14706 @cindex compatibility mode
14707 Missing space between a request or macro and its argument. This warning
14708 is given when an undefined name longer than two characters is
14709 encountered, and the first two characters of the name make a defined
14710 name. The request or macro is not invoked. When this warning is given,
14711 no macro is automatically defined. This is enabled by default. This
14712 warning never occurs in compatibility mode.
14716 Non-existent fonts. This is enabled by default.
14720 Invalid escapes in text ignored with the @code{ig} request. These are
14721 conditions that are errors when they do not occur in ignored text.
14725 Color related warnings.
14729 Missing files. The @code{mso} request gives this warning when the
14730 requested macro file does not exist. This is enabled by default.
14733 All warnings except @samp{di}, @samp{mac} and @samp{reg}. It is
14734 intended that this covers all warnings that are useful with traditional
14742 @c =====================================================================
14744 @node Implementation Differences, , Debugging, gtroff Reference
14745 @section Implementation Differences
14746 @cindex implementation differences
14747 @cindex differences in implementation
14748 @cindex incompatibilities with @acronym{AT&T} @code{troff}
14749 @cindex compatibility mode
14750 @cindex mode, compatibility
14752 GNU @code{troff} has a number of features that cause incompatibilities
14753 with documents written with old versions of @code{troff}.
14756 @cindex names, long
14757 Long names cause some incompatibilities. Unix @code{troff} interprets
14763 @cindex @code{\*}, incompatibilities with @acronym{AT&T} @code{troff}
14764 @cindex @code{\n}, incompatibilities with @acronym{AT&T} @code{troff}
14766 as defining a string @samp{ab} with contents @samp{cd}. Normally, GNU
14767 @code{troff} interprets this as a call of a macro named @code{dsabcd}.
14768 Also Unix @code{troff} interprets @code{\*[} or @code{\n[} as references
14769 to a string or number register called @samp{[}. In GNU @code{troff},
14770 however, this is normally interpreted as the start of a long name. In
14771 compatibility mode GNU @code{troff} interprets long names in the
14772 traditional way (which means that they are not recognized as names).
14774 @DefreqList {cp, [@Var{n}]}
14775 @DefreqItemx {do, cmd}
14776 @DefregListEndx {.C}
14777 If @var{n} is missing or non-zero, turn on compatibility mode;
14778 otherwise, turn it off.
14780 The read-only number register @code{.C} is@tie{}1 if compatibility mode
14781 is on, 0@tie{}otherwise.
14783 Compatibility mode can be also turned on with the @option{-C}
14784 command-line option.
14786 The @code{do} request turns off compatibility mode while executing its
14787 arguments as a @code{gtroff} command. However, it does not turn off
14788 compatibility mode while processing the macro itself. To do that, use
14789 the @code{de1} request (or manipulate the @code{.C} register manually).
14790 @xref{Writing Macros}.
14797 executes the @code{fam} request when compatibility mode is enabled.
14799 @code{gtroff} restores the previous compatibility setting before
14800 interpreting any files sourced by the @var{cmd}.
14803 @cindex input level in delimited arguments
14804 @cindex delimited arguments, incompatibilities with @acronym{AT&T} @code{troff}
14805 Two other features are controlled by @option{-C}. If not in
14806 compatibility mode, GNU @code{troff} preserves the input level in
14807 delimited arguments:
14815 In compatibility mode, the string @samp{72def'} is returned; without
14816 @option{-C} the resulting string is @samp{168} (assuming a TTY output
14819 @cindex @code{\f}, incompatibilities with @acronym{AT&T} @code{troff}
14820 @cindex @code{\H}, incompatibilities with @acronym{AT&T} @code{troff}
14821 @cindex @code{\s}, incompatibilities with @acronym{AT&T} @code{troff}
14822 @cindex @code{\S}, incompatibilities with @acronym{AT&T} @code{troff}
14823 Finally, the escapes @code{\f}, @code{\H}, @code{\m}, @code{\M},
14824 @code{\R}, @code{\s}, and @code{\S} are transparent for recognizing the
14825 beginning of a line only in compatibility mode (this is a rather obscure
14826 feature). For example, the code
14836 prints @samp{Hello!} in bold face if in compatibility mode, and
14837 @samp{.xx} in bold face otherwise.
14839 @cindex @code{\A}, incompatibilities with @acronym{AT&T} @code{troff}
14840 @cindex @code{\|}, incompatibilities with @acronym{AT&T} @code{troff}
14841 @cindex @code{\^}, incompatibilities with @acronym{AT&T} @code{troff}
14842 @cindex @code{\&}, incompatibilities with @acronym{AT&T} @code{troff}
14843 @cindex @code{\@{}, incompatibilities with @acronym{AT&T} @code{troff}
14844 @cindex @code{\@}}, incompatibilities with @acronym{AT&T} @code{troff}
14845 @cindex @code{\@key{SP}}, incompatibilities with @acronym{AT&T} @code{troff}
14846 @cindex @code{\'}, incompatibilities with @acronym{AT&T} @code{troff}
14847 @cindex @code{\`}, incompatibilities with @acronym{AT&T} @code{troff}
14848 @cindex @code{\-}, incompatibilities with @acronym{AT&T} @code{troff}
14849 @cindex @code{\_}, incompatibilities with @acronym{AT&T} @code{troff}
14850 @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
14851 @cindex @code{\%}, incompatibilities with @acronym{AT&T} @code{troff}
14852 @cindex @code{\c}, incompatibilities with @acronym{AT&T} @code{troff}
14853 GNU @code{troff} does not allow the use of the escape sequences
14854 @code{\|}, @code{\^}, @code{\&}, @code{\@{}, @code{\@}},
14855 @code{\@key{SP}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
14856 @code{\%}, and @code{\c} in names of strings, macros, diversions, number
14857 registers, fonts or environments; Unix @code{troff} does. The @code{\A}
14858 escape sequence (@pxref{Identifiers}) may be helpful in avoiding use of
14859 these escape sequences in names.
14861 @cindex fractional point sizes
14862 @cindex fractional type sizes
14863 @cindex point sizes, fractional
14864 @cindex type sizes, fractional
14865 @cindex sizes, fractional
14866 @cindex @code{ps} request, incompatibilities with @acronym{AT&T} @code{troff}
14867 Fractional point sizes cause one noteworthy incompatibility. In
14868 Unix @code{troff} the @code{ps} request ignores scale indicators and
14876 sets the point size to 10@tie{}points, whereas in GNU @code{troff} it
14877 sets the point size to 10@tie{}scaled points. @xref{Fractional Type
14878 Sizes}, for more information.
14880 @cindex @code{bd} request, incompatibilities with @acronym{AT&T} @code{troff}
14881 @cindex @code{cs} request, incompatibilities with @acronym{AT&T} @code{troff}
14882 @cindex @code{tr} request, incompatibilities with @acronym{AT&T} @code{troff}
14883 @cindex @code{fp} request, incompatibilities with @acronym{AT&T} @code{troff}
14884 @cindex input characters and output glyphs, compatibility with @acronym{AT&T} @code{troff}
14885 @cindex output glyphs, and input characters,compatibility with @acronym{AT&T} @code{troff}
14886 @cindex characters, input, and output glyphs, compatibility with @acronym{AT&T} @code{troff}
14887 @cindex glyphs, output, and input characters, compatibility with @acronym{AT&T} @code{troff}
14888 In GNU @code{troff} there is a fundamental difference between
14889 (unformatted) input characters and (formatted) output glyphs.
14890 Everything that affects how a glyph is output is stored with the glyph
14891 node; once a glyph node has been constructed it is unaffected by any
14892 subsequent requests that are executed, including @code{bd}, @code{cs},
14893 @code{tkf}, @code{tr}, or @code{fp} requests. Normally glyphs are
14894 constructed from input characters at the moment immediately before the
14895 glyph is added to the current output line. Macros, diversions and
14896 strings are all, in fact, the same type of object; they contain lists of
14897 input characters and glyph nodes in any combination. A glyph node does
14898 not behave like an input character for the purposes of macro processing;
14899 it does not inherit any of the special properties that the input
14900 character from which it was constructed might have had. For example,
14910 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
14911 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
14912 @cindex @code{\e}, incompatibilities with @acronym{AT&T} @code{troff}
14913 @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
14914 @cindex @code{\?}, incompatibilities with @acronym{AT&T} @code{troff}
14915 @cindex transparent output, incompatibilities with @acronym{AT&T} @code{troff}
14916 @cindex output, transparent, incompatibilities with @acronym{AT&T} @code{troff}
14918 prints @samp{\\} in GNU @code{troff}; each pair of input backslashes is
14919 turned into one output backslash and the resulting output backslashes
14920 are not interpreted as escape characters when they are reread.
14921 Unix @code{troff} would interpret them as escape characters when they
14922 were reread and would end up printing one @samp{\}. The correct way to
14923 obtain a printable backslash is to use the @code{\e} escape sequence:
14924 This always prints a single instance of the current escape character,
14925 regardless of whether or not it is used in a diversion; it also works in
14926 both GNU @code{troff} and Unix @code{troff}.@footnote{To be completely
14927 independent of the current escape character, use @code{\(rs}, which
14928 represents a reverse solidus (backslash) glyph.} To store, for some
14929 reason, an escape sequence in a diversion that is interpreted when the
14930 diversion is reread, either use the traditional @code{\!} transparent
14931 output facility, or, if this is unsuitable, the new @code{\?} escape
14934 @xref{Diversions}, and @ref{Gtroff Internals}, for more information.
14938 @c =====================================================================
14939 @c =====================================================================
14941 @node Preprocessors, Output Devices, gtroff Reference, Top
14942 @chapter Preprocessors
14943 @cindex preprocessors
14945 This chapter describes all preprocessors that come with @code{groff} or
14946 which are freely available.
14961 @c =====================================================================
14963 @node geqn, gtbl, Preprocessors, Preprocessors
14964 @section @code{geqn}
14965 @cindex @code{eqn}, the program
14966 @cindex @code{geqn}, the program
14974 @c ---------------------------------------------------------------------
14976 @node Invoking geqn, , geqn, geqn
14977 @subsection Invoking @code{geqn}
14978 @cindex invoking @code{geqn}
14979 @cindex @code{geqn}, invoking
14984 @c =====================================================================
14986 @node gtbl, gpic, geqn, Preprocessors
14987 @section @code{gtbl}
14988 @cindex @code{tbl}, the program
14989 @cindex @code{gtbl}, the program
14997 @c ---------------------------------------------------------------------
14999 @node Invoking gtbl, , gtbl, gtbl
15000 @subsection Invoking @code{gtbl}
15001 @cindex invoking @code{gtbl}
15002 @cindex @code{gtbl}, invoking
15007 @c =====================================================================
15009 @node gpic, ggrn, gtbl, Preprocessors
15010 @section @code{gpic}
15011 @cindex @code{pic}, the program
15012 @cindex @code{gpic}, the program
15020 @c ---------------------------------------------------------------------
15022 @node Invoking gpic, , gpic, gpic
15023 @subsection Invoking @code{gpic}
15024 @cindex invoking @code{gpic}
15025 @cindex @code{gpic}, invoking
15030 @c =====================================================================
15032 @node ggrn, grap, gpic, Preprocessors
15033 @section @code{ggrn}
15034 @cindex @code{grn}, the program
15035 @cindex @code{ggrn}, the program
15043 @c ---------------------------------------------------------------------
15045 @node Invoking ggrn, , ggrn, ggrn
15046 @subsection Invoking @code{ggrn}
15047 @cindex invoking @code{ggrn}
15048 @cindex @code{ggrn}, invoking
15053 @c =====================================================================
15055 @node grap, gchem, ggrn, Preprocessors
15056 @section @code{grap}
15057 @cindex @code{grap}, the program
15059 A free implementation of @code{grap}, written by Ted Faber,
15060 is available as an extra package from the following address:
15063 @uref{http://www.lunabase.org/~faber/Vault/software/grap/}
15067 @c =====================================================================
15069 @node gchem, grefer, grap, Preprocessors
15070 @section @code{gchem}
15071 @cindex @code{chem}, the program
15072 @cindex @code{gchem}, the program
15080 @c ---------------------------------------------------------------------
15082 @node Invoking gchem, , gchem, gchem
15083 @subsection Invoking @code{gchem}
15084 @cindex invoking @code{gchem}
15085 @cindex @code{gchem}, invoking
15090 @c =====================================================================
15092 @node grefer, gsoelim, gchem, Preprocessors
15093 @section @code{grefer}
15094 @cindex @code{refer}, the program
15095 @cindex @code{grefer}, the program
15100 * Invoking grefer::
15103 @c ---------------------------------------------------------------------
15105 @node Invoking grefer, , grefer, grefer
15106 @subsection Invoking @code{grefer}
15107 @cindex invoking @code{grefer}
15108 @cindex @code{grefer}, invoking
15113 @c =====================================================================
15115 @node gsoelim, preconv, grefer, Preprocessors
15116 @section @code{gsoelim}
15117 @cindex @code{soelim}, the program
15118 @cindex @code{gsoelim}, the program
15123 * Invoking gsoelim::
15126 @c ---------------------------------------------------------------------
15128 @node Invoking gsoelim, , gsoelim, gsoelim
15129 @subsection Invoking @code{gsoelim}
15130 @cindex invoking @code{gsoelim}
15131 @cindex @code{gsoelim}, invoking
15136 @c =====================================================================
15138 @node preconv, , gsoelim, Preprocessors
15139 @section @code{preconv}
15140 @cindex @code{preconv}, the program
15145 * Invoking preconv::
15148 @c ---------------------------------------------------------------------
15150 @node Invoking preconv, , preconv, preconv
15151 @subsection Invoking @code{preconv}
15152 @cindex invoking @code{preconv}
15153 @cindex @code{preconv}, invoking
15158 @c =====================================================================
15159 @c =====================================================================
15161 @node Output Devices, File formats, Preprocessors, Top
15162 @chapter Output Devices
15163 @cindex output devices
15164 @cindex devices for output
15169 * Special Characters::
15181 @c =====================================================================
15183 @node Special Characters, grotty, Output Devices, Output Devices
15184 @section Special Characters
15185 @cindex special characters
15186 @cindex characters, special
15193 @c =====================================================================
15195 @node grotty, grops, Special Characters, Output Devices
15196 @section @code{grotty}
15197 @cindex @code{grotty}, the program
15199 The postprocessor @code{grotty} translates the output from GNU
15200 @code{troff} into a form suitable for typewriter-like devices. It is
15201 fully documented on its manual page, @cite{grotty(1)}.
15204 * Invoking grotty::
15207 @c ---------------------------------------------------------------------
15209 @node Invoking grotty, , grotty, grotty
15210 @subsection Invoking @code{grotty}
15211 @cindex invoking @code{grotty}
15212 @cindex @code{grotty}, invoking
15214 The postprocessor @command{grotty} accepts the following command-line
15219 Do not overstrike bold glyphs. Ignored if @option{-c} isn't used.
15222 Do not underline bold-italic glyphs. Ignored if @option{-c} isn't
15226 Use overprint and disable colours for printing on legacy Teletype
15227 printers (see below).
15230 Do not render lines (that is, ignore all @code{\D} escapes).
15233 Use form feed control characters in the output.
15236 Put the directory @file{@var{dir}/dev@var{name}} in front of the
15237 search path for the font and device description files, given the
15238 target device @var{name}.
15241 Use horizontal tabs for sequences of 8 space characters.
15244 Request italic glyphs from the terminal. Ignored if @option{-c} is
15251 Highlight italic glyphs. Ignored if @option{-c} is active.
15254 Do not underline italic glyphs. Ignored if @option{-c} isn't used.
15257 Do not overstrike bold-italic glyphs. Ignored if @option{-c} isn't
15261 Print the version number.
15266 @cindex ISO 6249 SGR
15267 @cindex terminal control sequences
15268 @cindex control sequences, for terminals
15269 The @option{-c} mode for TTY output devices means that underlining is
15270 done by emitting sequences of @samp{_} and @samp{^H} (the backspace
15271 character) before the actual character. Literally, this is printing
15272 an underline character, then moving the caret back one character
15273 position, and printing the actual character at the same position as
15274 the underline character (similar to a typewriter). Usually, a modern
15275 terminal can't interpret this (and the original Teletype machines for
15276 which this sequence was appropriate are no longer in use). You need
15277 a pager program like @code{less} that translates this into
15278 ISO@tie{}6429 SGR sequences to control terminals.
15281 @c =====================================================================
15283 @node grops, gropdf, grotty, Output Devices
15284 @section @code{grops}
15285 @cindex @code{grops}, the program
15287 The postprocessor @command{grops} translates the output from GNU
15288 @command{troff} into a form suitable for Adobe @sc{PostScript}
15289 devices. It is fully documented on its manual page, @cite{grops(1)}.
15294 * Embedding PostScript::
15297 @c ---------------------------------------------------------------------
15299 @node Invoking grops, Embedding PostScript, grops, grops
15300 @subsection Invoking @code{grops}
15301 @cindex invoking @code{grops}
15302 @cindex @code{grops}, invoking
15304 The postprocessor @code{grops} accepts the following command-line
15308 @item -b@var{flags}
15309 Use backward compatibility settings given by @var{flags} as
15310 documented in the @cite{grops(1)} manual page. Overrides the command
15311 @option{broken} in the @file{DESC} file.
15314 Print @var{n} copies of each page.
15317 Put the directory @file{@var{dir}/dev@var{name}} in front of the
15318 search path for the font, prologue and device description files,
15319 given the target device @var{name}, usually @strong{ps}.
15322 Tell the printer to guess the page length. Useful for printing
15323 vertically centered pages when the paper dimensions are determined at
15326 @item -I@var{path} @dots{}
15327 Consider the directory @file{@var{path}} for searching included files
15328 specified with relative paths. The current directory is searched as
15332 Use landscape orientation.
15337 @item -p@var{papersize}
15338 Set the page dimensions. Overrides the commands @option{papersize},
15339 @option{paperlength}, and @option{paperwidth} in the @file{DESC}
15340 file. See the @cite{groff_font(5)} manual page for details.
15342 @item -P@var{prologue}
15343 Use the @var{prologue} in the font path as the prologue instead of
15344 the default @file{prologue}. Overrides the environment variable
15345 @env{GROPS_PROLOGUE}.
15348 Set the line thickness to @var{n}/1000@dmn{em}. Overrides the
15349 default value @var{n} = 40.
15352 Print the version number.
15355 @c ---------------------------------------------------------------------
15357 @node Embedding PostScript, , Invoking grops, grops
15358 @subsection Embedding @sc{PostScript}
15359 @cindex embedding PostScript
15360 @cindex PostScript, embedding
15362 The escape sequence
15364 @code{\X'ps: import @var{file} @var{llx} @var{lly} @var{urx} @var{ury}
15365 @var{width} [@var{height}]'}
15368 places a rectangle of the specified @var{width} containing the
15369 @sc{PostScript} drawing from file @var{file} bound by the box from
15370 @var{llx} @var{lly} to @var{urx} @var{ury} (in @sc{PostScript}
15371 coordinates) at the insertion point. If @var{height} is not
15372 specified, the embedded drawing is scaled proportionally.
15374 @xref{Miscellaneous}, for the @code{psbb} request, which automatically
15375 generates the bounding box.
15377 This escape sequence is used internally by the macro @code{PSPIC}
15378 (see the @cite{groff_tmac(5)} manual page).
15381 @c =====================================================================
15383 @node gropdf, grodvi, grops, Output Devices
15384 @section @code{gropdf}
15385 @cindex @code{gropdf}, the program
15387 The postprocessor @command{gropdf} translates the output from GNU
15388 @command{troff} into a form suitable for Adobe PDF devices. It is fully
15389 documented on its manual page, @cite{gropdf(1)}.
15392 * Invoking gropdf::
15396 @c ---------------------------------------------------------------------
15398 @node Invoking gropdf, Embedding PDF, gropdf, gropdf
15399 @subsection Invoking @code{gropdf}
15400 @cindex invoking @code{gropdf}
15401 @cindex @code{gropdf}, invoking
15403 The postprocessor @code{gropdf} accepts the following command-line
15408 Produce uncompressed PDFs that include debugging comments.
15411 This forces @code{gropdf} to embed all used fonts in the PDF,
15412 even if they are one of the 14 base Adobe fonts.
15415 Put the directory @file{@var{dir}/dev@var{name}} in front of the
15416 search path for the font, prologue and device description files,
15417 given the target device @var{name}, usually @strong{pdf}.
15419 @item -y@var{foundry}
15420 This forces the use of a different font foundry.
15423 Use landscape orientation.
15425 @item -p@var{papersize}
15426 Set the page dimensions. Overrides the commands @option{papersize},
15427 @option{paperlength}, and @option{paperwidth} in the @file{DESC}
15428 file. See the @cite{groff_font(5)} manual page for details.
15431 Print the version number.
15434 Append a comment line to end of PDF showing statistics, i.e. number of
15435 pages in document. Ghostscript's @cite{ps2pdf(1)} complains about this
15436 line if it is included, but works anyway.
15438 @item -u@var{filename}
15439 @code{gropdf} normally includes a ToUnicode CMap with any font created
15440 using @file{text.enc} as the encoding file, this makes it easier to
15441 search for words that contain ligatures. You can include your own CMap
15442 by specifying a @var{filename} or have no CMap at all by omitting the
15446 @c ---------------------------------------------------------------------
15448 @node Embedding PDF, , Invoking gropdf, gropdf
15449 @subsection Embedding PDF
15450 @cindex embedding PDF
15451 @cindex PDF, embedding
15453 The escape sequence
15455 @code{\X'pdf: pdfpic @var{file} @var{alignment} @var{width} [@var{height}]
15456 [@var{linelength}]'}
15459 places a rectangle of the specified @var{width} containing the PDF
15460 drawing from file @var{file} of desired @var{width} and @var{height} (if
15461 @var{height} is missing or zero then it is scaled proportionally). If
15462 @var{alignment} is @code{-L} the drawing is left aligned. If it is
15463 @code{-C} or @code{-R} a @var{linelength} greater than the width of the
15464 drawing is required as well. If @var{width} is specified as zero then
15465 the width is scaled in proportion to the height.
15468 @c =====================================================================
15470 @node grodvi, grolj4, gropdf, Output Devices
15471 @section @code{grodvi}
15472 @cindex @code{grodvi}, the program
15474 The postprocessor @command{grodvi} translates the output from GNU
15475 @command{troff} into the @strong{DVI} output format compatible with
15476 the @strong{@TeX{}} document preparation system. It is fully
15477 documented on its manual page, @cite{grodvi(1)}.
15480 * Invoking grodvi::
15483 @c ---------------------------------------------------------------------
15485 @node Invoking grodvi, , grodvi, grodvi
15486 @subsection Invoking @code{grodvi}
15487 @cindex invoking @code{grodvi}
15488 @cindex @code{grodvi}, invoking
15490 The postprocessor @code{grodvi} accepts the following command-line
15495 Do not use @strong{tpic} specials to implement drawing commands.
15498 Put the directory @file{@var{dir}/dev@var{name}} in front of the
15499 search path for the font and device description files, given the
15500 target device @var{name}, usually @strong{dvi}.
15503 Use landscape orientation.
15505 @item -p@var{papersize}
15506 Set the page dimensions. Overrides the commands @option{papersize},
15507 @option{paperlength}, and @option{paperwidth} in the @file{DESC}
15508 file. See @cite{groff_font(5)} manual page for details.
15511 Print the version number.
15514 Set the line thickness to @var{n}/1000@dmn{em}. Overrides the
15515 default value @var{n} = 40.
15519 @c =====================================================================
15521 @node grolj4, grolbp, grodvi, Output Devices
15522 @section @code{grolj4}
15523 @cindex @code{grolj4}, the program
15525 The postprocessor @command{grolj4} translates the output from GNU
15526 @command{troff} into the @strong{PCL5} output format suitable for
15527 printing on a @strong{HP LaserJet@tie{}4} printer. It is fully
15528 documented on its manual page, @cite{grolj4(1)}.
15531 * Invoking grolj4::
15534 @c ---------------------------------------------------------------------
15536 @node Invoking grolj4, , grolj4, grolj4
15537 @subsection Invoking @code{grolj4}
15538 @cindex invoking @code{grolj4}
15539 @cindex @code{grolj4}, invoking
15541 The postprocessor @code{grolj4} accepts the following command-line
15546 Print @var{n} copies of each page.
15549 Put the directory @file{@var{dir}/dev@var{name}} in front of the
15550 search path for the font and device description files, given the
15551 target device @var{name}, usually @strong{lj4}.
15554 Use landscape orientation.
15557 Set the page dimensions. Valid values for @var{size} are:
15558 @code{letter}, @code{legal}, @code{executive}, @code{a4},
15559 @code{com10}, @code{monarch}, @code{c5}, @code{b5}, @code{d1}.
15562 Print the version number.
15565 Set the line thickness to @var{n}/1000@dmn{em}. Overrides the
15566 default value @var{n} = 40.
15569 The special drawing command @code{\D'R @var{dh} @var{dv}'} draws a
15570 horizontal rectangle from the current position to the position at
15571 offset (@var{dh},@var{dv}).
15574 @c =====================================================================
15576 @node grolbp, grohtml, grolj4, Output Devices
15577 @section @code{grolbp}
15578 @cindex @code{grolbp}, the program
15580 The postprocessor @command{grolbp} translates the output from GNU
15581 @command{troff} into the @strong{LBP} output format suitable for
15582 printing on @strong{Canon CAPSL} printers. It is fully documented on
15583 its manual page, @cite{grolbp(1)}.
15586 * Invoking grolbp::
15589 @c ---------------------------------------------------------------------
15591 @node Invoking grolbp, , grolbp, grolbp
15592 @subsection Invoking @code{grolbp}
15593 @cindex invoking @code{grolbp}
15594 @cindex @code{grolbp}, invoking
15596 The postprocessor @code{grolbp} accepts the following command-line
15601 Print @var{n} copies of each page.
15604 Put the directory @file{@var{dir}/dev@var{name}} in front of the
15605 search path for the font, prologue and device description files,
15606 given the target device @var{name}, usually @strong{lbp}.
15609 Use landscape orientation.
15611 @item -o@var{orientation}
15612 Use the @var{orientation} specified: @code{portrait} or
15615 @item -p@var{papersize}
15616 Set the page dimensions. See @cite{groff_font(5)} manual page for
15620 Set the line thickness to @var{n}/1000@dmn{em}. Overrides the
15621 default value @var{n} = 40.
15624 Print the version number.
15627 Print command-line help.
15631 @c =====================================================================
15633 @node grohtml, gxditview, grolbp, Output Devices
15634 @section @code{grohtml}
15635 @cindex @code{grohtml}, the program
15637 The @code{grohtml} front end (which consists of a preprocessor,
15638 @code{pre-grohtml}, and a device driver, @code{post-grohtml}) translates
15639 the output of GNU @code{troff} to @acronym{HTML}. Users should always
15640 invoke @code{grohtml} via the @code{groff} command with a @code{\-Thtml}
15641 option. If no files are given, @code{grohtml} will read the standard
15642 input. A filename of @code{-} will also cause @code{grohtml} to read
15643 the standard input. @acronym{HTML} output is written to the standard
15644 output. When @code{grohtml} is run by @code{groff}, options can be
15645 passed to @code{grohtml} using @code{groff}'s @option{-P} option.
15647 @code{grohtml} invokes @code{groff} twice. In the first pass, pictures,
15648 equations, and tables are rendered using the @code{ps} device, and in
15649 the second pass @acronym{HTML} output is generated by the @code{html}
15652 @code{grohtml} always writes output in @code{UTF-8} encoding and has
15653 built-in entities for all non-composite unicode characters. In spite of
15654 this, @code{groff} may issue warnings about unknown special characters
15655 if they can't be found during the first pass. Such warnings can be
15656 safely ignored unless the special characters appear inside a table or
15657 equation, in which case glyphs for these characters must be defined for
15658 the @code{ps} device as well.
15660 This output device is fully documented on its manual page,
15664 * Invoking grohtml::
15665 * grohtml specific registers and strings::
15668 @c ---------------------------------------------------------------------
15670 @node Invoking grohtml, grohtml specific registers and strings, grohtml, grohtml
15671 @subsection Invoking @code{grohtml}
15672 @cindex invoking @code{grohtml}
15673 @cindex @code{grohtml}, invoking
15675 The postprocessor @code{grohtml} accepts the following command-line
15680 Use this number of @var{bits} (= 1, 2 or 4) for text antialiasing.
15681 Default: @var{bits} = 4.
15684 Do not use text antialiasing.
15687 Use white background.
15690 Store rendered images in the directory @file{@var{dir}}.
15693 Put the directory @file{@var{dir}/dev@var{name}} in front of the
15694 search path for the font, prologue and device description files,
15695 given the target device @var{name}, usually @strong{html}.
15698 Use this number of @var{bits} (= 1, 2 or 4) for antialiasing of
15699 drawings. Default: @var{bits} = 4.
15702 Do not use antialiasing for drawings.
15705 Use the @code{B} element for section headings.
15707 @item -i@var{resolution}
15708 Use the @var{resolution} for rendered images. Default:
15709 @var{resolution} = 100@dmn{dpi}.
15712 Set the images' @var{stem name}. Default: @var{stem} =
15713 @file{grohtml-@var{XXX}} (@var{XXX} is the process ID).
15716 Place each section in a separate file called
15717 @file{@var{stem}-@var{n}.html} (where @var{n} is a generated section
15721 Do not generate the table of contents.
15724 Generate simple fragment identifiers.
15726 @item -o@var{offset}
15727 Use vertical padding @var{offset} for images.
15730 Display the page rendering progress to @code{stderr}.
15733 Do not use horizontal rules to separate headers and footers.
15736 Set the base font size, to be modified using the elements @code{BIG}
15739 @item -S@var{level}
15740 Generate separate files for sections at level @var{level}.
15743 Print the version number.
15746 Generate a validator button at the bottom.
15749 Generate a signature of groff after the validator button, if any.
15753 @c ---------------------------------------------------------------------
15755 @node grohtml specific registers and strings, , Invoking grohtml, grohtml
15756 @subsection @code{grohtml} specific registers and strings
15757 @cindex registers specific to @code{grohtml}
15758 @cindex strings specific to @code{grohtml}
15759 @cindex @code{grohtml}, registers and strings
15761 @DefmpregList {ps4html, grohtml}
15762 @DefstrListEndx {www-image-template, grohtml}
15763 The registers @code{ps4html} and @code{www-image-template} are defined
15764 by the @code{pre-grohtml} preprocessor. @code{pre-grohtml} reads in the
15765 @code{troff} input, marks up the inline equations and passes the result
15769 troff -Tps -rps4html=1 -dwww-image-template=@var{template}
15787 The @sc{PostScript} device is used to create all the image files (for
15788 @option{-Thtml}; if @option{-Txhtml} is used, all equations are passed
15789 to @code{geqn} to produce @acronym{MathML}, and the register
15790 @code{ps4html} enables the macro sets to ignore floating keeps, footers,
15793 The register @code{www-image-template} is set to the user specified
15794 template name or the default name.
15798 @c =====================================================================
15800 @node gxditview, , grohtml, Output Devices
15801 @section @code{gxditview}
15802 @cindex @code{gxditview}, the program
15807 * Invoking gxditview::
15810 @c ---------------------------------------------------------------------
15812 @node Invoking gxditview, , gxditview, gxditview
15813 @subsection Invoking @code{gxditview}
15814 @cindex invoking @code{gxditview}
15815 @cindex @code{gxditview}, invoking
15822 @c =====================================================================
15823 @c =====================================================================
15825 @node File formats, Installation, Output Devices, Top
15826 @chapter File formats
15827 @cindex file formats
15828 @cindex formats, file
15830 All files read and written by @code{gtroff} are text files. The
15831 following two sections describe their format.
15839 @c =====================================================================
15841 @node gtroff Output, Font Files, File formats, File formats
15842 @section @code{gtroff} Output
15843 @cindex @code{gtroff}, output
15844 @cindex output, @code{gtroff}
15846 This section describes the intermediate output format of GNU
15847 @code{troff}. This output is produced by a run of @code{gtroff} before
15848 it is fed into a device postprocessor program.
15850 As @code{groff} is a wrapper program around @code{gtroff} that
15851 automatically calls a postprocessor, this output does not show up
15852 normally. This is why it is called @dfn{intermediate}. @code{groff}
15853 provides the option @option{-Z} to inhibit postprocessing, such that the
15854 produced intermediate output is sent to standard output just like
15855 calling @code{gtroff} manually.
15857 @cindex troff output
15858 @cindex output, troff
15859 @cindex intermediate output
15860 @cindex output, intermediate
15861 Here, the term @dfn{troff output} describes what is output by
15862 @code{gtroff}, while @dfn{intermediate output} refers to the language
15863 that is accepted by the parser that prepares this output for the
15864 postprocessors. This parser is smarter on whitespace and implements
15865 obsolete elements for compatibility, otherwise both formats are the
15866 same.@footnote{The parser and postprocessor for intermediate output can
15867 be found in the file@*
15868 @file{@var{groff-source-dir}/src/libs/libdriver/input.cpp}.}
15870 The main purpose of the intermediate output concept is to facilitate the
15871 development of postprocessors by providing a common programming
15872 interface for all devices. It has a language of its own that is
15873 completely different from the @code{gtroff} language. While the
15874 @code{gtroff} language is a high-level programming language for text
15875 processing, the intermediate output language is a kind of low-level
15876 assembler language by specifying all positions on the page for writing
15879 The intermediate output produced by @code{gtroff} is fairly readable,
15880 while output from @acronym{AT&T} @code{troff} is rather hard to
15881 understand because of strange habits that are still supported, but not
15882 used any longer by @code{gtroff}.
15885 * Language Concepts::
15886 * Command Reference::
15887 * Intermediate Output Examples::
15888 * Output Language Compatibility::
15891 @c ---------------------------------------------------------------------
15893 @node Language Concepts, Command Reference, gtroff Output, gtroff Output
15894 @subsection Language Concepts
15896 During the run of @code{gtroff}, the input data is cracked down to the
15897 information on what has to be printed at what position on the intended
15898 device. So the language of the intermediate output format can be quite
15899 small. Its only elements are commands with and without arguments. In
15900 this section, the term @dfn{command} always refers to the intermediate
15901 output language, and never to the @code{gtroff} language used for
15902 document formatting. There are commands for positioning and text
15903 writing, for drawing, and for device controlling.
15911 @node Separation, Argument Units, Language Concepts, Language Concepts
15912 @subsubsection Separation
15914 @acronym{AT&T} @code{troff} output has strange requirements on
15915 whitespace. The @code{gtroff} output parser, however, is smart about
15916 whitespace by making it maximally optional. The whitespace characters,
15917 i.e., the tab, space, and newline characters, always have a syntactical
15918 meaning. They are never printable because spacing within the output is
15919 always done by positioning commands.
15921 Any sequence of space or tab characters is treated as a single
15922 @dfn{syntactical space}. It separates commands and arguments, but is
15923 only required when there would occur a clashing between the command code
15924 and the arguments without the space. Most often, this happens when
15925 variable-length command names, arguments, argument lists, or command
15926 clusters meet. Commands and arguments with a known, fixed length need
15927 not be separated by syntactical space.
15929 A line break is a syntactical element, too. Every command argument can
15930 be followed by whitespace, a comment, or a newline character. Thus a
15931 @dfn{syntactical line break} is defined to consist of optional
15932 syntactical space that is optionally followed by a comment, and a
15935 The normal commands, those for positioning and text, consist of a single
15936 letter taking a fixed number of arguments. For historical reasons, the
15937 parser allows stacking of such commands on the same line, but
15938 fortunately, in @code{gtroff}'s intermediate output, every command with
15939 at least one argument is followed by a line break, thus providing
15940 excellent readability.
15942 The other commands -- those for drawing and device controlling -- have a
15943 more complicated structure; some recognize long command names, and some
15944 take a variable number of arguments. So all @samp{D} and @samp{x}
15945 commands were designed to request a syntactical line break after their
15946 last argument. Only one command, @w{@samp{x X}}, has an argument that
15947 can stretch over several lines; all other commands must have all of
15948 their arguments on the same line as the command, i.e., the arguments may
15949 not be split by a line break.
15951 Empty lines (these are lines containing only space and/or a comment),
15952 can occur everywhere. They are just ignored.
15954 @node Argument Units, Document Parts, Separation, Language Concepts
15955 @subsubsection Argument Units
15957 Some commands take integer arguments that are assumed to represent
15958 values in a measurement unit, but the letter for the corresponding scale
15959 indicator is not written with the output command arguments. Most
15960 commands assume the scale indicator @samp{u}, the basic unit of the
15961 device, some use @samp{z}, the scaled point unit of the device, while
15962 others, such as the color commands, expect plain integers.
15964 Note that single characters can have the eighth bit set, as can the
15965 names of fonts and special characters. The names of characters and
15966 fonts can be of arbitrary length. A character that is to be printed is
15967 always in the current font.
15969 A string argument is always terminated by the next whitespace character
15970 (space, tab, or newline); an embedded @samp{#} character is regarded as
15971 part of the argument, not as the beginning of a comment command. An
15972 integer argument is already terminated by the next non-digit character,
15973 which then is regarded as the first character of the next argument or
15976 @node Document Parts, , Argument Units, Language Concepts
15977 @subsubsection Document Parts
15979 A correct intermediate output document consists of two parts, the
15980 @dfn{prologue} and the @dfn{body}.
15982 The task of the prologue is to set the general device parameters using
15983 three exactly specified commands. @code{gtroff}'s prologue is
15984 guaranteed to consist of the following three lines (in that order):
15988 x res @var{n} @var{h} @var{v}
15993 with the arguments set as outlined in @ref{Device Control Commands}.
15994 Note that the parser for the intermediate output format is able to
15995 swallow additional whitespace and comments as well even in the prologue.
15997 The body is the main section for processing the document data.
15998 Syntactically, it is a sequence of any commands different from the ones
15999 used in the prologue. Processing is terminated as soon as the first
16000 @w{@samp{x stop}} command is encountered; the last line of any
16001 @code{gtroff} intermediate output always contains such a command.
16003 Semantically, the body is page oriented. A new page is started by a
16004 @samp{p} command. Positioning, writing, and drawing commands are always
16005 done within the current page, so they cannot occur before the first
16006 @samp{p} command. Absolute positioning (by the @samp{H} and @samp{V}
16007 commands) is done relative to the current page; all other positioning is
16008 done relative to the current location within this page.
16010 @c ---------------------------------------------------------------------
16012 @node Command Reference, Intermediate Output Examples, Language Concepts, gtroff Output
16013 @subsection Command Reference
16015 This section describes all intermediate output commands, both from
16016 @acronym{AT&T} @code{troff} as well as the @code{gtroff} extensions.
16019 * Comment Command::
16020 * Simple Commands::
16021 * Graphics Commands::
16022 * Device Control Commands::
16023 * Obsolete Command::
16026 @node Comment Command, Simple Commands, Command Reference, Command Reference
16027 @subsubsection Comment Command
16030 @item #@var{anything}@angles{end of line}
16031 A comment. Ignore any characters from the @samp{#} character up to the
16032 next newline character.
16034 This command is the only possibility for commenting in the intermediate
16035 output. Each comment can be preceded by arbitrary syntactical space;
16036 every command can be terminated by a comment.
16039 @node Simple Commands, Graphics Commands, Comment Command, Command Reference
16040 @subsubsection Simple Commands
16042 The commands in this subsection have a command code consisting of a
16043 single character, taking a fixed number of arguments. Most of them are
16044 commands for positioning and text writing. These commands are smart
16045 about whitespace. Optionally, syntactical space can be inserted before,
16046 after, and between the command letter and its arguments. All of these
16047 commands are stackable, i.e., they can be preceded by other simple
16048 commands or followed by arbitrary other commands on the same line. A
16049 separating syntactical space is only necessary when two integer
16050 arguments would clash or if the preceding argument ends with a string
16055 .if (\n[@USE_ENV_STACK] == 1) \{\
16057 Open a new environment by copying the actual device configuration data
16058 to the environment stack.
16060 The current environment is setup by the device specification and
16061 manipulated by the setting commands.
16065 Close the actual environment (opened by a preceding
16067 and restore the previous environment from the environment
16068 stack as the actual device configuration data.
16070 \} \" endif @USE_ENV_STACK
16073 @item C @var{xxx}@angles{whitespace}
16074 Print a special character named @var{xxx}. The trailing syntactical
16075 space or line break is necessary to allow glyph names of arbitrary
16076 length. The glyph is printed at the current print position; the glyph's
16077 size is read from the font file. The print position is not changed.
16080 Print glyph@tie{}@var{g} at the current print
16081 position;@footnote{@samp{c} is actually a misnomer since it outputs a
16082 glyph.} the glyph's size is read from the font file. The print position
16086 Set font to font number@tie{}@var{n} (a non-negative integer).
16089 Move right to the absolute vertical position@tie{}@var{n} (a
16090 non-negative integer in basic units @samp{u} relative to left edge of
16094 Move @var{n} (a non-negative integer) basic units @samp{u} horizontally
16095 to the right. The original Unix troff manual allows negative
16096 values for @var{n} also, but @code{gtroff} doesn't use this.
16098 @item m @var{color-scheme} @r{[}@var{component} @dots{}@r{]}
16099 Set the color for text (glyphs), line drawing, and the outline of
16100 graphic objects using different color schemes; the analogous command
16101 for the filling color of graphic objects is @samp{DF}. The color
16102 components are specified as integer arguments between 0 and 65536. The
16103 number of color components and their meaning vary for the different
16104 color schemes. These commands are generated by @code{gtroff}'s escape
16105 sequence @code{\m}. No position changing. These commands are a
16106 @code{gtroff} extension.
16109 @item mc @var{cyan} @var{magenta} @var{yellow}
16110 Set color using the CMY color scheme, having the 3@tie{}color components
16111 @var{cyan}, @var{magenta}, and @var{yellow}.
16114 Set color to the default color value (black in most cases). No
16115 component arguments.
16117 @item mg @var{gray}
16118 Set color to the shade of gray given by the argument, an integer between
16119 0 (black) and 65536 (white).
16121 @item mk @var{cyan} @var{magenta} @var{yellow} @var{black}
16122 Set color using the CMYK color scheme, having the 4@tie{}color
16123 components @var{cyan}, @var{magenta}, @var{yellow}, and @var{black}.
16125 @item mr @var{red} @var{green} @var{blue}
16126 Set color using the RGB color scheme, having the 3@tie{}color components
16127 @var{red}, @var{green}, and @var{blue}.
16131 Print glyph with index@tie{}@var{n} (a non-negative integer) of the
16132 current font. This command is a @code{gtroff} extension.
16134 @item n @var{b} @var{a}
16135 Inform the device about a line break, but no positioning is done by this
16136 command. In @acronym{AT&T} @code{troff}, the integer arguments @var{b}
16137 and@tie{}@var{a} informed about the space before and after the current
16138 line to make the intermediate output more human readable without
16139 performing any action. In @code{groff}, they are just ignored, but they
16140 must be provided for compatibility reasons.
16143 Begin a new page in the outprint. The page number is set
16144 to@tie{}@var{n}. This page is completely independent of pages formerly
16145 processed even if those have the same page number. The vertical
16146 position on the outprint is automatically set to@tie{}0. All
16147 positioning, writing, and drawing is always done relative to a page, so
16148 a @samp{p} command must be issued before any of these commands.
16151 Set point size to @var{n}@tie{}scaled points (this is unit @samp{z}).
16152 @acronym{AT&T} @code{troff} used the unit points (@samp{p}) instead.
16153 @xref{Output Language Compatibility}.
16155 @item t @var{xxx}@angles{whitespace}
16156 @itemx t @var{xxx} @var{dummy-arg}@angles{whitespace}
16157 Print a word, i.e., a sequence of characters @var{xxx} representing
16158 output glyphs which names are single characters, terminated by a space
16159 character or a line break; an optional second integer argument is
16160 ignored (this allows the formatter to generate an even number of
16161 arguments). The first glyph should be printed at the current position,
16162 the current horizontal position should then be increased by the width of
16163 the first glyph, and so on for each glyph. The widths of the glyphs are
16164 read from the font file, scaled for the current point size, and rounded
16165 to a multiple of the horizontal resolution. Special characters cannot
16166 be printed using this command (use the @samp{C} command for special
16167 characters). This command is a @code{gtroff} extension; it is only used
16168 for devices whose @file{DESC} file contains the @code{tcommand} keyword
16169 (@pxref{DESC File Format}).
16171 @item u @var{n} @var{xxx}@angles{whitespace}
16172 Print word with track kerning. This is the same as the @samp{t} command
16173 except that after printing each glyph, the current horizontal position
16174 is increased by the sum of the width of that glyph and@tie{}@var{n} (an
16175 integer in basic units @samp{u}). This command is a @code{gtroff}
16176 extension; it is only used for devices whose @file{DESC} file contains
16177 the @code{tcommand} keyword (@pxref{DESC File Format}).
16180 Move down to the absolute vertical position@tie{}@var{n} (a non-negative
16181 integer in basic units @samp{u}) relative to upper edge of current page.
16184 Move @var{n}@tie{}basic units @samp{u} down (@var{n} is a non-negative
16185 integer). The original Unix troff manual allows negative values for
16186 @var{n} also, but @code{gtroff} doesn't use this.
16189 Informs about a paddable white space to increase readability. The
16190 spacing itself must be performed explicitly by a move command.
16193 @node Graphics Commands, Device Control Commands, Simple Commands, Command Reference
16194 @subsubsection Graphics Commands
16196 Each graphics or drawing command in the intermediate output starts with
16197 the letter @samp{D}, followed by one or two characters that specify a
16198 subcommand; this is followed by a fixed or variable number of integer
16199 arguments that are separated by a single space character. A @samp{D}
16200 command may not be followed by another command on the same line (apart
16201 from a comment), so each @samp{D} command is terminated by a syntactical
16204 @code{gtroff} output follows the classical spacing rules (no space
16205 between command and subcommand, all arguments are preceded by a single
16206 space character), but the parser allows optional space between the
16207 command letters and makes the space before the first argument optional.
16208 As usual, each space can be any sequence of tab and space characters.
16210 Some graphics commands can take a variable number of arguments. In this
16211 case, they are integers representing a size measured in basic units
16212 @samp{u}. The arguments called @var{h1}, @var{h2}, @dots{}, @var{hn}
16213 stand for horizontal distances where positive means right, negative
16214 left. The arguments called @var{v1}, @var{v2}, @dots{}, @var{vn} stand
16215 for vertical distances where positive means down, negative up. All
16216 these distances are offsets relative to the current location.
16218 Each graphics command directly corresponds to a similar @code{gtroff}
16219 @code{\D} escape sequence. @xref{Drawing Requests}.
16221 Unknown @samp{D} commands are assumed to be device-specific. Its
16222 arguments are parsed as strings; the whole information is then sent to
16225 In the following command reference, the syntax element @angles{line
16226 break} means a syntactical line break as defined above.
16229 @item D~ @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
16230 Draw B-spline from current position to offset (@var{h1},@var{v1}), then
16231 to offset (@var{h2},@var{v2}), if given, etc.@: up to
16232 (@var{hn},@var{vn}). This command takes a variable number of argument
16233 pairs; the current position is moved to the terminal point of the drawn
16236 @item Da @var{h1} @var{v1} @var{h2} @var{v2}@angles{line break}
16237 Draw arc from current position to
16238 (@var{h1},@var{v1})@math{+}(@var{h2},@var{v2}) with center at
16239 (@var{h1},@var{v1}); then move the current position to the final point
16242 @item DC @var{d}@angles{line break}
16243 @itemx DC @var{d} @var{dummy-arg}@angles{line break}
16244 Draw a solid circle using the current fill color with
16245 diameter@tie{}@var{d} (integer in basic units @samp{u}) with leftmost
16246 point at the current position; then move the current position to the
16247 rightmost point of the circle. An optional second integer argument is
16248 ignored (this allows the formatter to generate an even number of
16249 arguments). This command is a @code{gtroff} extension.
16251 @item Dc @var{d}@angles{line break}
16252 Draw circle line with diameter@tie{}@var{d} (integer in basic units
16253 @samp{u}) with leftmost point at the current position; then move the
16254 current position to the rightmost point of the circle.
16256 @item DE @var{h} @var{v}@angles{line break}
16257 Draw a solid ellipse in the current fill color with a horizontal
16258 diameter of@tie{}@var{h} and a vertical diameter of@tie{}@var{v} (both
16259 integers in basic units @samp{u}) with the leftmost point at the current
16260 position; then move to the rightmost point of the ellipse. This command
16261 is a @code{gtroff} extension.
16263 @item De @var{h} @var{v}@angles{line break}
16264 Draw an outlined ellipse with a horizontal diameter of@tie{}@var{h} and
16265 a vertical diameter of@tie{}@var{v} (both integers in basic units
16266 @samp{u}) with the leftmost point at current position; then move to the
16267 rightmost point of the ellipse.
16269 @item DF @var{color-scheme} @r{[}@var{component} @dots{}@r{]}@angles{line break}
16270 Set fill color for solid drawing objects using different color schemes;
16271 the analogous command for setting the color of text, line graphics, and
16272 the outline of graphic objects is @samp{m}. The color components are
16273 specified as integer arguments between 0 and 65536. The number of color
16274 components and their meaning vary for the different color schemes.
16275 These commands are generated by @code{gtroff}'s escape sequences
16276 @w{@code{\D'F @dots{}'}} and @code{\M} (with no other corresponding
16277 graphics commands). No position changing. This command is a
16278 @code{gtroff} extension.
16281 @item DFc @var{cyan} @var{magenta} @var{yellow}@angles{line break}
16282 Set fill color for solid drawing objects using the CMY color scheme,
16283 having the 3@tie{}color components @var{cyan}, @var{magenta}, and
16286 @item DFd@angles{line break}
16287 Set fill color for solid drawing objects to the default fill color value
16288 (black in most cases). No component arguments.
16290 @item DFg @var{gray}@angles{line break}
16291 Set fill color for solid drawing objects to the shade of gray given by
16292 the argument, an integer between 0 (black) and 65536 (white).
16294 @item DFk @var{cyan} @var{magenta} @var{yellow} @var{black}@angles{line break}
16295 Set fill color for solid drawing objects using the CMYK color scheme,
16296 having the 4@tie{}color components @var{cyan}, @var{magenta},
16297 @var{yellow}, and @var{black}.
16299 @item DFr @var{red} @var{green} @var{blue}@angles{line break}
16300 Set fill color for solid drawing objects using the RGB color scheme,
16301 having the 3@tie{}color components @var{red}, @var{green}, and
16305 @item Df @var{n}@angles{line break}
16306 The argument@tie{}@var{n} must be an integer in the range @math{-32767}
16310 @item @math{0 @value{LE} @var{n} @value{LE} 1000}
16311 Set the color for filling solid drawing objects to a shade of gray,
16312 where 0 corresponds to solid white, 1000 (the default) to solid black,
16313 and values in between to intermediate shades of gray; this is obsoleted
16314 by command @samp{DFg}.
16316 @item @math{@var{n} < 0} or @math{@var{n} > 1000}
16317 Set the filling color to the color that is currently being used for the
16318 text and the outline, see command @samp{m}. For example, the command
16327 sets all colors to blue.
16331 No position changing. This command is a @code{gtroff} extension.
16333 @item Dl @var{h} @var{v}@angles{line break}
16334 Draw line from current position to offset (@var{h},@var{v}) (integers in
16335 basic units @samp{u}); then set current position to the end of the drawn
16338 @item Dp @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
16339 Draw a polygon line from current position to offset (@var{h1},@var{v1}),
16340 from there to offset (@var{h2},@var{v2}), etc.@: up to offset
16341 (@var{hn},@var{vn}), and from there back to the starting position. For
16342 historical reasons, the position is changed by adding the sum of all
16343 arguments with odd index to the actual horizontal position and the even
16344 ones to the vertical position. Although this doesn't make sense it is
16345 kept for compatibility.
16347 As the polygon is closed, the end of drawing is the starting point, so
16348 the position doesn't change.
16350 This command is a @code{gtroff} extension.
16352 @item DP @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
16353 Draw a solid polygon in the current fill color rather than an outlined
16354 polygon, using the same arguments and positioning as the corresponding
16357 No position changing.
16359 This command is a @code{gtroff} extension.
16361 @item Dt @var{n}@angles{line break}
16362 Set the current line thickness to@tie{}@var{n} (an integer in basic
16363 units @samp{u}) if @math{@var{n}>0}; if @math{@var{n}=0} select the
16364 smallest available line thickness; if @math{@var{n}<0} set the line
16365 thickness proportional to the point size (this is the default before the
16366 first @samp{Dt} command was specified). For historical reasons, the
16367 horizontal position is changed by adding the argument to the actual
16368 horizontal position, while the vertical position is not changed.
16369 Although this doesn't make sense it is kept for compatibility.
16371 No position changing.
16373 This command is a @code{gtroff} extension.
16376 @node Device Control Commands, Obsolete Command, Graphics Commands, Command Reference
16377 @subsubsection Device Control Commands
16379 Each device control command starts with the letter @samp{x}, followed by
16380 a space character (optional or arbitrary space or tab in @code{gtroff})
16381 and a subcommand letter or word; each argument (if any) must be preceded
16382 by a syntactical space. All @samp{x} commands are terminated by a
16383 syntactical line break; no device control command can be followed by
16384 another command on the same line (except a comment).
16386 The subcommand is basically a single letter, but to increase
16387 readability, it can be written as a word, i.e., an arbitrary sequence of
16388 characters terminated by the next tab, space, or newline character. All
16389 characters of the subcommand word but the first are simply ignored. For
16390 example, @code{gtroff} outputs the initialization command @w{@samp{x i}}
16391 as @w{@samp{x init}} and the resolution command @w{@samp{x r}} as
16394 In the following, the syntax element @angles{line break} means a
16395 syntactical line break (@pxref{Separation}).
16398 @item xF @var{name}@angles{line break}
16399 The @samp{F} stands for @var{Filename}.
16401 Use @var{name} as the intended name for the current file in error
16402 reports. This is useful for remembering the original file name when
16403 @code{gtroff} uses an internal piping mechanism. The input file is not
16404 changed by this command. This command is a @code{gtroff} extension.
16406 @item xf @var{n} @var{s}@angles{line break}
16407 The @samp{f} stands for @var{font}.
16409 Mount font position@tie{}@var{n} (a non-negative integer) with font
16410 named@tie{}@var{s} (a text word). @xref{Font Positions}.
16412 @item xH @var{n}@angles{line break}
16413 The @samp{H} stands for @var{Height}.
16415 Set glyph height to@tie{}@var{n} (a positive integer in scaled points
16416 @samp{z}). @acronym{AT&T} @code{troff} uses the unit points (@samp{p})
16417 instead. @xref{Output Language Compatibility}.
16419 @item xi@angles{line break}
16420 The @samp{i} stands for @var{init}.
16422 Initialize device. This is the third command of the prologue.
16424 @item xp@angles{line break}
16425 The @samp{p} stands for @var{pause}.
16427 Parsed but ignored. The original Unix troff manual writes
16430 pause device, can be restarted
16433 @item xr @var{n} @var{h} @var{v}@angles{line break}
16434 The @samp{r} stands for @var{resolution}.
16436 Resolution is@tie{}@var{n}, while @var{h} is the minimal horizontal
16437 motion, and @var{v} the minimal vertical motion possible with this
16438 device; all arguments are positive integers in basic units @samp{u} per
16439 inch. This is the second command of the prologue.
16441 @item xS @var{n}@angles{line break}
16442 The @samp{S} stands for @var{Slant}.
16444 Set slant to@tie{}@var{n} (an integer in basic units @samp{u}).
16446 @item xs@angles{line break}
16447 The @samp{s} stands for @var{stop}.
16449 Terminates the processing of the current file; issued as the last
16450 command of any intermediate troff output.
16452 @item xt@angles{line break}
16453 The @samp{t} stands for @var{trailer}.
16455 Generate trailer information, if any. In @var{gtroff}, this is actually
16458 @item xT @var{xxx}@angles{line break}
16459 The @samp{T} stands for @var{Typesetter}.
16461 Set name of device to word @var{xxx}, a sequence of characters ended by
16462 the next white space character. The possible device names coincide with
16463 those from the @code{groff} @option{-T} option. This is the first
16464 command of the prologue.
16466 @item xu @var{n}@angles{line break}
16467 The @samp{u} stands for @var{underline}.
16469 Configure underlining of spaces. If @var{n} is@tie{}1, start
16470 underlining of spaces; if @var{n} is@tie{}0, stop underlining of spaces.
16471 This is needed for the @code{cu} request in nroff mode and is ignored
16472 otherwise. This command is a @code{gtroff} extension.
16474 @item xX @var{anything}@angles{line break}
16475 The @samp{x} stands for @var{X-escape}.
16477 Send string @var{anything} uninterpreted to the device. If the line
16478 following this command starts with a @samp{+} character this line is
16479 interpreted as a continuation line in the following sense. The @samp{+}
16480 is ignored, but a newline character is sent instead to the device, the
16481 rest of the line is sent uninterpreted. The same applies to all
16482 following lines until the first character of a line is not a @samp{+}
16483 character. This command is generated by the @code{gtroff} escape
16484 sequence @code{\X}. The line-continuing feature is a @code{gtroff}
16488 @node Obsolete Command, , Device Control Commands, Command Reference
16489 @subsubsection Obsolete Command
16490 In @acronym{AT&T} @code{troff} output, the writing of a single glyph is
16491 mostly done by a very strange command that combines a horizontal move
16492 and a single character giving the glyph name. It doesn't have a command
16493 code, but is represented by a 3-character argument consisting of exactly
16494 2@tie{}digits and a character.
16497 @item @var{dd}@var{g}
16498 Move right @var{dd} (exactly two decimal digits) basic units @samp{u},
16499 then print glyph@tie{}@var{g} (represented as a single character).
16501 In @code{gtroff}, arbitrary syntactical space around and within this
16502 command is allowed to be added. Only when a preceding command on the
16503 same line ends with an argument of variable length a separating space is
16504 obligatory. In @acronym{AT&T} @code{troff}, large clusters of these and
16505 other commands are used, mostly without spaces; this made such output
16509 For modern high-resolution devices, this command does not make sense
16510 because the width of the glyphs can become much larger than two decimal
16511 digits. In @code{gtroff}, this is only used for the devices @code{X75},
16512 @code{X75-12}, @code{X100}, and @code{X100-12}. For other devices, the
16513 commands @samp{t} and @samp{u} provide a better functionality.
16515 @c ---------------------------------------------------------------------
16517 @node Intermediate Output Examples, Output Language Compatibility, Command Reference, gtroff Output
16518 @subsection Intermediate Output Examples
16520 This section presents the intermediate output generated from the same
16521 input for three different devices. The input is the sentence @samp{hell
16522 world} fed into @code{gtroff} on the command line.
16525 @item High-resolution device @code{ps}
16527 This is the standard output of @code{gtroff} if no @option{-T} option is
16532 shell> echo "hell world" | groff -Z -T ps
16558 This output can be fed into @code{grops} to get its representation as a
16559 @sc{PostScript} file.
16561 @item Low-resolution device @code{latin1}
16563 This is similar to the high-resolution device except that the
16564 positioning is done at a minor scale. Some comments (lines starting
16565 with @samp{#}) were added for clarification; they were not generated by
16570 shell> echo "hell world" | groff -Z -T latin1
16583 # initial positioning on the page
16586 # write text `hell'
16588 # inform about space, and issue a horizontal jump
16590 # write text `world'
16592 # announce line break, but do nothing because ...
16595 # ... the end of the document has been reached
16603 This output can be fed into @code{grotty} to get a formatted text
16606 @item @acronym{AT&T} @code{troff} output
16607 Since a computer monitor has a very low resolution compared to modern
16608 printers the intermediate output for the X@tie{}Window devices can use
16609 the jump-and-write command with its 2-digit displacements.
16613 shell> echo "hell world" | groff -Z -T X100
16625 # write text with jump-and-write commands
16626 ch07e07l03lw06w11o07r05l03dh7
16636 This output can be fed into @code{xditview} or @code{gxditview} for
16637 displaying in@tie{}X.
16639 Due to the obsolete jump-and-write command, the text clusters in the
16640 @acronym{AT&T} @code{troff} output are almost unreadable.
16643 @c ---------------------------------------------------------------------
16645 @node Output Language Compatibility, , Intermediate Output Examples, gtroff Output
16646 @subsection Output Language Compatibility
16648 The intermediate output language of @acronym{AT&T} @code{troff} was
16649 first documented in the Unix troff manual, with later additions
16650 documented in @cite{A Typesetter-independent TROFF}, written by Brian
16653 The @code{gtroff} intermediate output format is compatible with this
16654 specification except for the following features.
16658 The classical quasi device independence is not yet implemented.
16661 The old hardware was very different from what we use today. So the
16662 @code{groff} devices are also fundamentally different from the ones
16663 in @acronym{AT&T} @code{troff}. For example, the @acronym{AT&T}
16664 @sc{PostScript} device is called @code{post} and has a resolution of
16665 only 720 units per inch, suitable for printers 20 years ago, while
16666 @code{groff}'s @code{ps} device has a resolution of 72000 units per
16667 inch. Maybe, by implementing some rescaling mechanism similar to the
16668 classical quasi device independence, @code{groff} could emulate
16669 @acronym{AT&T}'s @code{post} device.
16672 The B-spline command @samp{D~} is correctly handled by the intermediate
16673 output parser, but the drawing routines aren't implemented in some of
16674 the postprocessor programs.
16677 The argument of the commands @samp{s} and @w{@samp{x H}} has the
16678 implicit unit scaled point @samp{z} in @code{gtroff}, while
16679 @acronym{AT&T} @code{troff} has point (@samp{p}). This isn't an
16680 incompatibility but a compatible extension, for both units coincide for
16681 all devices without a @code{sizescale} parameter in the @file{DESC}
16682 file, including all postprocessors from @acronym{AT&T} and
16683 @code{groff}'s text devices. The few @code{groff} devices with a
16684 @code{sizescale} parameter either do not exist for @acronym{AT&T}
16685 @code{troff}, have a different name, or seem to have a different
16686 resolution. So conflicts are very unlikely.
16689 The position changing after the commands @samp{Dp}, @samp{DP}, and
16690 @samp{Dt} is illogical, but as old versions of @code{gtroff} used this
16691 feature it is kept for compatibility reasons.
16694 Temporarily, there existed some confusion on the positioning after the
16695 @samp{D} commands that are groff extensions. This has been clarified by
16696 establishing the classical rule for all @code{groff} drawing commands:
16700 The position after a graphic object has been drawn is at its end; for
16701 circles and ellipses, the `end' is at the right side.
16704 From this, the positionings specified for the drawing commands above
16705 follow quite naturally.
16712 @c =====================================================================
16714 @node Font Files, , gtroff Output, File formats
16715 @section Font Files
16717 @cindex files, font
16719 The @code{gtroff} font format is roughly a superset of the
16720 @code{ditroff} font format (as used in later versions of @acronym{AT&T}
16721 @code{troff} and its descendants). Unlike the @code{ditroff} font
16722 format, there is no associated binary format; all files are text
16723 files.@footnote{Plan@tie{}9 @code{troff} has also abandoned the binary
16724 format.} The font files for device @var{name} are stored in a directory
16725 @file{dev@var{name}}. There are two types of file: a device description
16726 file called @file{DESC} and for each font@tie{}@var{f} a font file
16727 called@tie{}@file{@var{f}}.
16730 * DESC File Format::
16731 * Font File Format::
16734 @c ---------------------------------------------------------------------
16736 @node DESC File Format, Font File Format, Font Files, Font Files
16737 @subsection @file{DESC} File Format
16738 @cindex @file{DESC} file, format
16739 @cindex font description file, format
16740 @cindex format of font description file
16741 @pindex DESC@r{ file format}
16743 The @file{DESC} file can contain the following types of line. Except
16744 for the @code{charset} keyword, which must come last (if at all), the
16745 order of the lines is not important. Later entries in the file,
16746 however, override previous values.
16751 This line and everything following in the file are ignored. It is
16752 allowed for the sake of backwards compatibility.
16754 @item family @var{fam}
16756 The default font family is @var{fam}.
16758 @item fonts @var{n} @var{F1} @var{F2} @var{F3} @dots{} @var{Fn}
16760 Fonts @var{F1} @dots{} @var{Fn} are mounted in the font positions
16761 @var{m}+1, @dots{}, @var{m}+@var{n} where @var{m} is the number of
16762 styles. This command may extend over more than one line. A font name
16763 of@tie{}0 means no font is mounted on the corresponding font position.
16767 @cindex horizontal resolution
16768 @cindex resolution, horizontal
16769 The horizontal resolution is @var{n}@tie{}machine units. All horizontal
16770 quantities are rounded to be multiples of this value.
16772 @item image_generator @var{string}
16773 @kindex image_generator
16774 @cindex PostScript, PNG image generation
16775 @cindex PNG image generation from PostScript
16776 Needed for @code{grohtml} only. It specifies the program to generate
16777 PNG images from @sc{PostScript} input. Under GNU/Linux this is
16778 usually @code{gs} but under other systems (notably cygwin) it might
16779 be set to another name.
16781 @item paperlength @var{n}
16782 @kindex paperlength
16783 The physical vertical dimension of the output medium in machine units.
16784 This isn't used by @code{troff} itself but by output devices.
16785 Deprecated. Use @code{papersize} instead.
16787 @item papersize @var{string} @dots{}
16789 Select a paper size. Valid values for @var{string} are the ISO paper
16790 types @code{A0}--@code{A7}, @code{B0}--@code{B7}, @code{C0}--@code{C7},
16791 @code{D0}--@code{D7}, @code{DL}, and the US paper types @code{letter},
16792 @code{legal}, @code{tabloid}, @code{ledger}, @code{statement},
16793 @code{executive}, @code{com10}, and @code{monarch}. Case is not
16794 significant for @var{string} if it holds predefined paper types.
16795 Alternatively, @var{string} can be a file name (e.g.@:
16796 @file{/etc/papersize}); if the file can be opened, @code{groff} reads
16797 the first line and tests for the above paper sizes. Finally,
16798 @var{string} can be a custom paper size in the format
16799 @code{@var{length},@var{width}} (no spaces before and after the comma).
16800 Both @var{length} and @var{width} must have a unit appended; valid
16801 values are @samp{i} for inches, @samp{c} for centimeters, @samp{p} for
16802 points, and @samp{P} for picas. Example: @code{12c,235p}. An argument
16803 that starts with a digit is always treated as a custom paper format.
16804 @code{papersize} sets both the vertical and horizontal dimension of the
16807 More than one argument can be specified; @code{groff} scans from left to
16808 right and uses the first valid paper specification.
16810 @item paperwidth @var{n}
16812 The physical horizontal dimension of the output medium in machine units.
16813 This isn't used by @code{troff} itself but by output devices.
16814 Deprecated. Use @code{papersize} instead.
16816 @item pass_filenames
16817 @kindex pass_filenames
16818 Tell @code{gtroff} to emit the name of the source file currently being
16819 processed. This is achieved by the intermediate output command
16820 @samp{F}. Currently, this is only used by the @code{grohtml} output
16823 @item postpro @var{program}
16825 Call @var{program} as a postprocessor. For example, the line
16832 in the file @file{devdvi/DESC} makes @code{groff} call @code{grodvi} if
16833 option @option{-Tdvi} is given (and @option{-Z} isn't used).
16835 @item prepro @var{program}
16837 Call @var{program} as a preprocessor. Currently, this keyword is used
16838 by @code{groff} with option @option{-Thtml} or @option{-Txhtml} only.
16840 @item print @var{program}
16842 Use @var{program} as a spooler program for printing. If omitted, the
16843 @option{-l} and @option{-L} options of @code{groff} are ignored.
16847 @cindex device resolution
16848 @cindex resolution, device
16849 There are @var{n}@tie{}machine units per inch.
16851 @item sizes @var{s1} @var{s2} @dots{} @var{sn} 0
16853 This means that the device has fonts at @var{s1}, @var{s2}, @dots{}
16854 @var{sn} scaled points. The list of sizes must be terminated by@tie{}0
16855 (this is digit zero). Each @var{si} can also be a range of sizes
16856 @var{m}--@var{n}. The list can extend over more than one line.
16858 @item sizescale @var{n}
16860 The scale factor for point sizes. By default this has a value
16861 of@tie{}1. One scaled point is equal to one point/@var{n}. The
16862 arguments to the @code{unitwidth} and @code{sizes} commands are given in
16863 scaled points. @xref{Fractional Type Sizes}, for more information.
16865 @item styles @var{S1} @var{S2} @dots{} @var{Sm}
16867 The first @var{m}@tie{}font positions are associated with styles
16868 @var{S1} @dots{} @var{Sm}.
16872 This means that the postprocessor can handle the @samp{t} and @samp{u}
16873 intermediate output commands.
16877 Indicate that the output device supports the complete Unicode
16878 repertoire. Useful only for devices that produce @emph{character
16879 entities} instead of glyphs.
16881 If @code{unicode} is present, no @code{charset} section is required in
16882 the font description files since the Unicode handling built into
16883 @code{groff} is used. However, if there are entries in a @code{charset}
16884 section, they either override the default mappings for those particular
16885 characters or add new mappings (normally for composite characters).
16887 This is used for @option{-Tutf8}, @option{-Thtml}, and @option{-Txhtml}.
16889 @item unitwidth @var{n}
16891 Quantities in the font files are given in machine units for fonts whose
16892 point size is @var{n}@tie{}scaled points.
16894 @item unscaled_charwidths
16895 @kindex unscaled_charwidths
16896 Make the font handling module always return unscaled character widths.
16897 Needed for the @code{grohtml} device.
16899 @item use_charnames_in_special
16900 @kindex use_charnames_in_special
16901 This command indicates that @code{gtroff} should encode special
16902 characters inside special commands. Currently, this is only used by the
16903 @code{grohtml} output device. @xref{Postprocessor Access}.
16907 @cindex vertical resolution
16908 @cindex resolution, vertical
16909 The vertical resolution is @var{n}@tie{}machine units. All vertical
16910 quantities are rounded to be multiples of this value.
16913 The @code{res}, @code{unitwidth}, @code{fonts}, and @code{sizes} lines
16914 are mandatory. Other commands are ignored by @code{gtroff} but may be
16915 used by postprocessors to store arbitrary information about the device
16916 in the @file{DESC} file.
16920 @kindex biggestfont
16921 Here a list of obsolete keywords that are recognized by @code{groff}
16922 but completely ignored: @code{spare1}, @code{spare2},
16923 @code{biggestfont}.
16925 @c ---------------------------------------------------------------------
16927 @node Font File Format, , DESC File Format, Font Files
16928 @subsection Font File Format
16929 @cindex font file, format
16930 @cindex font description file, format
16931 @cindex format of font files
16932 @cindex format of font description files
16934 A @dfn{font file}, also (and probably better) called a @dfn{font
16935 description file}, has two sections. The first section is a sequence of
16936 lines each containing a sequence of blank delimited words; the first
16937 word in the line is a key, and subsequent words give a value for that
16943 The name of the font is@tie{}@var{f}.
16945 @item spacewidth @var{n}
16947 The normal width of a space is@tie{}@var{n}.
16949 @item slant @var{n}
16951 The glyphs of the font have a slant of @var{n}@tie{}degrees. (Positive
16954 @item ligatures @var{lig1} @var{lig2} @dots{} @var{lign} [0]
16956 Glyphs @var{lig1}, @var{lig2}, @dots{}, @var{lign} are ligatures;
16957 possible ligatures are @samp{ff}, @samp{fi}, @samp{fl}, @samp{ffi} and
16958 @samp{ffl}. For backwards compatibility, the list of ligatures may be
16959 terminated with a@tie{}0. The list of ligatures may not extend over
16960 more than one line.
16963 @cindex special fonts
16965 The font is @dfn{special}; this means that when a glyph is requested
16966 that is not present in the current font, it is searched for in any
16967 special fonts that are mounted.
16970 Other commands are ignored by @code{gtroff} but may be used by
16971 postprocessors to store arbitrary information about the font in the font
16974 @cindex comments in font files
16975 @cindex font files, comments
16977 The first section can contain comments, which start with the @samp{#}
16978 character and extend to the end of a line.
16980 The second section contains one or two subsections. It must contain a
16981 @code{charset} subsection and it may also contain a @code{kernpairs}
16982 subsection. These subsections can appear in any order. Each subsection
16983 starts with a word on a line by itself.
16986 The word @code{charset} starts the character set
16987 subsection.@footnote{This keyword is misnamed since it starts a list of
16988 ordered glyphs, not characters.} The @code{charset} line is followed by
16989 a sequence of lines. Each line gives information for one glyph. A line
16990 comprises a number of fields separated by blanks or tabs. The format is
16993 @var{name} @var{metrics} @var{type} @var{code} [@var{entity-name}]
16994 [@code{--} @var{comment}]
16997 @cindex 8-bit input
16998 @cindex input, 8-bit
16999 @cindex accessing unnamed glyphs with @code{\N}
17000 @cindex unnamed glyphs, accessing with @code{\N}
17001 @cindex characters, unnamed, accessing with @code{\N}
17002 @cindex glyphs, unnamed, accessing with @code{\N}
17005 @var{name} identifies the glyph name@footnote{The distinction between
17006 input, characters, and output, glyphs, is not clearly separated in the
17007 terminology of @code{groff}; for example, the @code{char} request should
17008 be called @code{glyph} since it defines an output entity.}: If
17009 @var{name} is a single character@tie{}@var{c} then it corresponds to the
17010 @code{gtroff} input character@tie{}@var{c}; if it is of the form
17011 @samp{\@var{c}} where @var{c} is a single character, then it corresponds
17012 to the special character @code{\[@var{c}]}; otherwise it corresponds to
17013 the special character @samp{\[@var{name}]}. If it is exactly two
17014 characters @var{xx} it can be entered as @samp{\(@var{xx}}. Note that
17015 single-letter special characters can't be accessed as @samp{\@var{c}};
17016 the only exception is @samp{\-}, which is identical to @code{\[-]}.
17018 @code{gtroff} supports 8-bit input characters; however some utilities
17019 have difficulties with eight-bit characters. For this reason, there is
17020 a convention that the entity name @samp{char@var{n}} is equivalent to
17021 the single input character whose code is@tie{}@var{n}. For example,
17022 @samp{char163} would be equivalent to the character with code@tie{}163,
17023 which is the pounds sterling sign in the ISO@tie{}@w{Latin-1} character
17024 set. You shouldn't use @samp{char@var{n}} entities in font description
17025 files since they are related to input, not output. Otherwise, you get
17026 hard-coded connections between input and output encoding, which prevents
17027 use of different (input) character sets.
17029 The name @samp{---} is special and indicates that the glyph is unnamed;
17030 such glyphs can only be used by means of the @code{\N} escape sequence
17033 The @var{type} field gives the glyph type:
17037 the glyph has a descender, for example, @samp{p};
17040 the glyph has an ascender, for example, @samp{b};
17043 the glyph has both an ascender and a descender, for example, @samp{(}.
17046 The @var{code} field gives the code that the postprocessor uses to
17047 print the glyph. The glyph can also be input to @code{gtroff} using
17048 this code by means of the @code{\N} escape sequence. @var{code} can be
17049 any integer. If it starts with @samp{0} it is interpreted as octal; if
17050 it starts with @samp{0x} or @samp{0X} it is interpreted as hexadecimal.
17051 Note, however, that the @code{\N} escape sequence only accepts a decimal
17054 The @var{entity-name} field gives an @acronym{ASCII} string identifying
17055 the glyph that the postprocessor uses to print the @code{gtroff} glyph
17056 @var{name}. This field is optional and has been introduced so that the
17057 @code{grohtml} device driver can encode its character set. For example,
17058 the glyph @samp{\[Po]} is represented as @samp{£} in
17059 @acronym{HTML} 4.0.
17061 Anything on the line after the @var{entity-name} field resp.@: after
17062 @samp{--} is ignored.
17064 The @var{metrics} field has the form:
17068 @var{width}[@code{,}@var{height}[@code{,}@var{depth}[@code{,}@var{italic-correction}
17069 [@code{,}@var{left-italic-correction}[@code{,}@var{subscript-correction}]]]]]
17074 There must not be any spaces between these subfields (it has been split
17075 here into two lines for better legibility only). Missing subfields are
17076 assumed to be@tie{}0. The subfields are all decimal integers. Since
17077 there is no associated binary format, these values are not required to
17078 fit into a variable of type @samp{char} as they are in @code{ditroff}.
17079 The @var{width} subfield gives the width of the glyph. The @var{height}
17080 subfield gives the height of the glyph (upwards is positive); if a glyph
17081 does not extend above the baseline, it should be given a zero height,
17082 rather than a negative height. The @var{depth} subfield gives the depth
17083 of the glyph, that is, the distance from the baseline to the lowest
17084 point below the baseline to which the glyph extends (downwards is
17085 positive); if a glyph does not extend below the baseline, it should be
17086 given a zero depth, rather than a negative depth. The
17087 @var{italic-correction} subfield gives the amount of space that should
17088 be added after the glyph when it is immediately to be followed by a
17089 glyph from a roman font. The @var{left-italic-correction} subfield
17090 gives the amount of space that should be added before the glyph when it
17091 is immediately to be preceded by a glyph from a roman font. The
17092 @var{subscript-correction} gives the amount of space that should be
17093 added after a glyph before adding a subscript. This should be less than
17094 the italic correction.
17096 A line in the @code{charset} section can also have the format
17103 This indicates that @var{name} is just another name for the glyph
17104 mentioned in the preceding line.
17107 The word @code{kernpairs} starts the kernpairs section. This contains a
17108 sequence of lines of the form:
17111 @var{c1} @var{c2} @var{n}
17115 This means that when glyph @var{c1} appears next to glyph @var{c2} the
17116 space between them should be increased by@tie{}@var{n}. Most entries in
17117 the kernpairs section have a negative value for@tie{}@var{n}.
17121 @c =====================================================================
17122 @c =====================================================================
17124 @node Installation, Copying This Manual, File formats, Top
17125 @chapter Installation
17126 @cindex installation
17132 @c =====================================================================
17133 @c =====================================================================
17135 @node Copying This Manual, Request Index, Installation, Top
17136 @appendix Copying This Manual
17142 @c =====================================================================
17143 @c =====================================================================
17145 @node Request Index, Escape Index, Copying This Manual, Top
17146 @appendix Request Index
17148 Requests appear without the leading control character (normally either
17149 @samp{.} or @samp{'}).
17155 @c =====================================================================
17156 @c =====================================================================
17158 @node Escape Index, Operator Index, Request Index, Top
17159 @appendix Escape Index
17161 Any escape sequence @code{\@var{X}} with @var{X} not in the list below
17162 emits a warning, printing glyph @var{X}.
17168 @c =====================================================================
17169 @c =====================================================================
17171 @node Operator Index, Register Index, Escape Index, Top
17172 @appendix Operator Index
17178 @c =====================================================================
17179 @c =====================================================================
17181 @node Register Index, Macro Index, Operator Index, Top
17182 @appendix Register Index
17184 The macro package or program a specific register belongs to is appended in
17187 A register name@tie{}@code{x} consisting of exactly one character can be
17188 accessed as @samp{\nx}. A register name @code{xx} consisting of exactly
17189 two characters can be accessed as @samp{\n(xx}. Register names
17190 @code{xxx} of any length can be accessed as @samp{\n[xxx]}.
17196 @c =====================================================================
17197 @c =====================================================================
17199 @node Macro Index, String Index, Register Index, Top
17200 @appendix Macro Index
17202 The macro package a specific macro belongs to is appended in brackets.
17203 They appear without the leading control character (normally @samp{.}).
17209 @c =====================================================================
17210 @c =====================================================================
17212 @node String Index, Glyph Name Index, Macro Index, Top
17213 @appendix String Index
17215 The macro package or program a specific string belongs to is appended in
17218 A string name@tie{}@code{x} consisting of exactly one character can be
17219 accessed as @samp{\*x}. A string name @code{xx} consisting of exactly
17220 two characters can be accessed as @samp{\*(xx}. String names @code{xxx}
17221 of any length can be accessed as @samp{\*[xxx]}.
17228 @c =====================================================================
17229 @c =====================================================================
17231 @node Glyph Name Index, Font File Keyword Index, String Index, Top
17232 @appendix Glyph Name Index
17234 A glyph name @code{xx} consisting of exactly two characters can be
17235 accessed as @samp{\(xx}. Glyph names @code{xxx} of any length can be
17236 accessed as @samp{\[xxx]}.
17242 @c =====================================================================
17243 @c =====================================================================
17245 @node Font File Keyword Index, Program and File Index, Glyph Name Index, Top
17246 @appendix Font File Keyword Index
17252 @c =====================================================================
17253 @c =====================================================================
17255 @node Program and File Index, Concept Index, Font File Keyword Index, Top
17256 @appendix Program and File Index
17262 @c =====================================================================
17263 @c =====================================================================
17265 @node Concept Index, , Program and File Index, Top
17266 @appendix Concept Index
17273 @c Local Variables:
17278 @c vim: set textwidth=72: