groff-1 revision 104862
10Sstevel@tonic-gateThis is groff, produced by makeinfo version 4.2 from ./groff.texinfo.
22522Sraf
32522SrafThis manual documents GNU `troff' version 1.18.
42522Sraf
52522Sraf   Copyright (C) 1994-2000, 2001, 2002 Free Software Foundation, Inc.
62522Sraf
72522Sraf     Permission is granted to copy, distribute and/or modify this
82522Sraf     document under the terms of the GNU Free Documentation License,
92522Sraf     Version 1.1 or any later version published by the Free Software
102522Sraf     Foundation; with no Invariant Sections, with the Front-Cover texts
112522Sraf     being `A GNU Manual," and with the Back-Cover Texts as in (a)
120Sstevel@tonic-gate     below.  A copy of the license is included in the section entitled
132522Sraf     `GNU Free Documentation License."
142522Sraf
152522Sraf     (a) The FSF's Back-Cover Text is: `You have freedom to copy and
162522Sraf     modify this GNU Manual, like GNU software.  Copies published by
172522Sraf     the Free Software Foundation raise funds for GNU development."
180Sstevel@tonic-gate   
192522SrafINFO-DIR-SECTION Miscellaneous
202522SrafSTART-INFO-DIR-ENTRY
212522Sraf* Groff: (groff).               The GNU troff document formatting system.
222522SrafEND-INFO-DIR-ENTRY
232522Sraf
242522Sraf
252522SrafFile: groff,  Node: Top,  Next: Introduction,  Prev: (dir),  Up: (dir)
262522Sraf
270Sstevel@tonic-gateGNU troff
280Sstevel@tonic-gate*********
290Sstevel@tonic-gate
302522SrafThis manual documents GNU `troff' version 1.18.
312522Sraf
320Sstevel@tonic-gate   Copyright (C) 1994-2000, 2001, 2002 Free Software Foundation, Inc.
330Sstevel@tonic-gate
340Sstevel@tonic-gate     Permission is granted to copy, distribute and/or modify this
350Sstevel@tonic-gate     document under the terms of the GNU Free Documentation License,
360Sstevel@tonic-gate     Version 1.1 or any later version published by the Free Software
370Sstevel@tonic-gate     Foundation; with no Invariant Sections, with the Front-Cover texts
380Sstevel@tonic-gate     being `A GNU Manual," and with the Back-Cover Texts as in (a)
390Sstevel@tonic-gate     below.  A copy of the license is included in the section entitled
400Sstevel@tonic-gate     `GNU Free Documentation License."
410Sstevel@tonic-gate
420Sstevel@tonic-gate     (a) The FSF's Back-Cover Text is: `You have freedom to copy and
430Sstevel@tonic-gate     modify this GNU Manual, like GNU software.  Copies published by
440Sstevel@tonic-gate     the Free Software Foundation raise funds for GNU development."
450Sstevel@tonic-gate   
460Sstevel@tonic-gate* Menu:
470Sstevel@tonic-gate
480Sstevel@tonic-gate* Introduction::
490Sstevel@tonic-gate* Invoking groff::
500Sstevel@tonic-gate* Tutorial for Macro Users::
510Sstevel@tonic-gate* Macro Packages::
520Sstevel@tonic-gate* gtroff Reference::
530Sstevel@tonic-gate* Preprocessors::
540Sstevel@tonic-gate* Output Devices::
550Sstevel@tonic-gate* File formats::
560Sstevel@tonic-gate* Installation::
570Sstevel@tonic-gate* Copying This Manual::
580Sstevel@tonic-gate* Request Index::
590Sstevel@tonic-gate* Escape Index::
600Sstevel@tonic-gate* Operator Index::
612522Sraf* Register Index::
620Sstevel@tonic-gate* Macro Index::
630Sstevel@tonic-gate* String Index::
640Sstevel@tonic-gate* Glyph Name Index::
650Sstevel@tonic-gate* Font File Keyword Index::
660Sstevel@tonic-gate* Program and File Index::
670Sstevel@tonic-gate* Concept Index::
68
69
70File: groff,  Node: Introduction,  Next: Invoking groff,  Prev: Top,  Up: Top
71
72Introduction
73************
74
75   GNU `troff' (or `groff') is a system for typesetting documents.
76`troff' is very flexible and has been in existence (and use) for about
773 decades.  It is quite widespread and firmly entrenched in the UNIX
78community.
79
80* Menu:
81
82* What Is groff?::
83* History::
84* groff Capabilities::
85* Macro Package Intro::
86* Preprocessor Intro::
87* Output device intro::
88* Credits::
89
90
91File: groff,  Node: What Is groff?,  Next: History,  Prev: Introduction,  Up: Introduction
92
93What Is `groff'?
94================
95
96   `groff' belongs to an older generation of document preparation
97systems, which operate more like compilers than the more recent
98interactive WYSIWYG(1) (*note What Is groff?-Footnote-1::) systems.
99`groff' and its contemporary counterpart, TeX, both work using a
100"batch" paradigm: The input (or "source") files are normal text files
101with embedded formatting commands.  These files can then be processed
102by `groff' to produce a typeset document on a variety of devices.
103
104   Likewise, `groff' should not be confused with a "word processor",
105since that term connotes an integrated system that includes an editor
106and a text formatter.  Also, many word processors follow the WYSIWYG
107paradigm discussed earlier.
108
109   Although WYSIWYG systems may be easier to use, they have a number of
110disadvantages compared to `troff':
111
112   * They must be used on a graphics display to work on a document.
113
114   * Most of the WYSIWYG systems are either non-free or are not very
115     portable.
116
117   * `troff' is firmly entrenched in all UNIX systems.
118
119   * It is difficult to have a wide range of capabilities available
120     within the confines of a GUI/window system.
121
122   * It is more difficult to make global changes to a document.
123
124     "GUIs normally make it simple to accomplish simple actions and
125     impossible to accomplish complex actions."  -Doug Gwyn (22/Jun/91
126     in `comp.unix.wizards')
127
128
129File: groff,  Node: What Is groff?-Footnotes,  Up: What Is groff?
130
131   (1) What You See Is What You Get
132
133
134File: groff,  Node: History,  Next: groff Capabilities,  Prev: What Is groff?,  Up: Introduction
135
136History
137=======
138
139   `troff' can trace its origins back to a formatting program called
140`runoff', written by J. E. Saltzer, which ran on MIT's CTSS operating
141system in the mid-sixties.  This name came from the common phrase of
142the time "I'll run off a document."  Bob Morris ported it to the 635
143architecture and called the program `roff' (an abbreviation of
144`runoff').  It was rewritten as `rf' for the PDP-7 (before having
145UNIX), and at the same time (1969), Doug McIllroy rewrote an extended
146and simplified version of `roff' in the BCPL programming language.
147
148   The first version of UNIX was developed on a PDP-7 which was sitting
149around Bell Labs.  In 1971 the developers wanted to get a PDP-11 for
150further work on the operating system.  In order to justify the cost for
151this system, they proposed that they would implement a document
152formatting system for the AT&T patents division.  This first formatting
153program was a reimplementation of McIllroy's `roff', written by
154J. F. Ossanna.
155
156   When they needed a more flexible language, a new version of `roff'
157called `nroff' ("Newer `roff'") was written.  It had a much more
158complicated syntax, but provided the basis for all future versions.
159When they got a Graphic Systems CAT Phototypesetter, Ossanna wrote a
160version of `nroff' that would drive it.  It was dubbed `troff', for
161"typesetter `roff'", although many people have speculated that it
162actually means "Times `roff'" because of the use of the Times font
163family in `troff' by default.  As such, the name `troff' is pronounced
164`t-roff' rather than `trough'.
165
166   With `troff' came `nroff' (they were actually the same program
167except for some `#ifdef's), which was for producing output for line
168printers and character terminals.  It understood everything `troff'
169did, and ignored the commands which were not applicable (e.g. font
170changes).
171
172   Since there are several things which cannot be done easily in
173`troff', work on several preprocessors began.  These programs would
174transform certain parts of a document into `troff', which made a very
175natural use of pipes in UNIX.
176
177   The `eqn' preprocessor allowed mathematical formulae to be specified
178in a much simpler and more intuitive manner.  `tbl' is a preprocessor
179for formatting tables.  The `refer' preprocessor (and the similar
180program, `bib') processes citations in a document according to a
181bibliographic database.
182
183   Unfortunately, Ossanna's `troff' was written in PDP-11 assembly
184language and produced output specifically for the CAT phototypesetter.
185He rewrote it in C, although it was now 7000 lines of uncommented code
186and still dependent on the CAT.  As the CAT became less common, and was
187no longer supported by the manufacturer, the need to make it support
188other devices became a priority.  However, before this could be done,
189Ossanna was killed in a car accident.
190
191   So, Brian Kernighan took on the task of rewriting `troff'.  The
192newly rewritten version produced device independent code which was very
193easy for postprocessors to read and translate to the appropriate
194printer codes.  Also, this new version of `troff' (called `ditroff' for
195"device independent `troff'") had several extensions, which included
196drawing functions.
197
198   Due to the additional abilities of the new version of `troff',
199several new preprocessors appeared.  The `pic' preprocessor provides a
200wide range of drawing functions.  Likewise the `ideal' preprocessor did
201the same, although via a much different paradigm.  The `grap'
202preprocessor took specifications for graphs, but, unlike other
203preprocessors, produced `pic' code.
204
205   James Clark began work on a GNU implementation of `ditroff' in
206early 1989.  The first version, `groff' 0.3.1, was released June 1990.
207`groff' included:
208
209   * A replacement for `ditroff' with many extensions.
210
211   * The `soelim', `pic', `tbl', and `eqn' preprocessors.
212
213   * Postprocessors for character devices, POSTSCRIPT, TeX DVI, and
214     X Windows.  GNU `troff' also eliminated the need for a separate
215     `nroff' program with a postprocessor which would produce ASCII
216     output.
217
218   * A version of the `me' macros and an implementation of the `man'
219     macros.
220
221   Also, a front-end was included which could construct the, sometimes
222painfully long, pipelines required for all the post- and preprocessors.
223
224   Development of GNU `troff' progressed rapidly, and saw the additions
225of a replacement for `refer', an implementation of the `ms' and `mm'
226macros, and a program to deduce how to format a document (`grog').
227
228   It was declared a stable (i.e. non-beta) package with the release of
229version 1.04 around November 1991.
230
231   Beginning in 1999, `groff' has new maintainers (the package was an
232orphan for a few years).  As a result, new features and programs like
233`grn', a preprocessor for gremlin images, and an output device to
234produce HTML output have been added.
235
236
237File: groff,  Node: groff Capabilities,  Next: Macro Package Intro,  Prev: History,  Up: Introduction
238
239`groff' Capabilities
240====================
241
242   So what exactly is `groff' capable of doing?  `groff' provides a
243wide range of low-level text formatting operations.  Using these, it is
244possible to perform a wide range of formatting tasks, such as
245footnotes, table of contents, multiple columns, etc.  Here's a list of
246the most important operations supported by `groff':
247
248   * text filling, adjusting, and centering
249
250   * hyphenation
251
252   * page control
253
254   * font and glyph size control
255
256   * vertical spacing (e.g. double-spacing)
257
258   * line length and indenting
259
260   * macros, strings, diversions, and traps
261
262   * number registers
263
264   * tabs, leaders, and fields
265
266   * input and output conventions and character translation
267
268   * overstrike, bracket, line drawing, and zero-width functions
269
270   * local horizontal and vertical motions and the width function
271
272   * three-part titles
273
274   * output line numbering
275
276   * conditional acceptance of input
277
278   * environment switching
279
280   * insertions from the standard input
281
282   * input/output file switching
283
284   * output and error messages
285
286
287File: groff,  Node: Macro Package Intro,  Next: Preprocessor Intro,  Prev: groff Capabilities,  Up: Introduction
288
289Macro Packages
290==============
291
292   Since `groff' provides such low-level facilities, it can be quite
293difficult to use by itself.  However, `groff' provides a "macro"
294facility to specify how certain routine operations (e.g. starting
295paragraphs, printing headers and footers, etc.) should be done.  These
296macros can be collected together into a "macro package".  There are a
297number of macro packages available; the most common (and the ones
298described in this manual) are `man', `mdoc', `me', `ms', and `mm'.
299
300
301File: groff,  Node: Preprocessor Intro,  Next: Output device intro,  Prev: Macro Package Intro,  Up: Introduction
302
303Preprocessors
304=============
305
306   Although `groff' provides most functions needed to format a
307document, some operations would be unwieldy (e.g. to draw pictures).
308Therefore, programs called "preprocessors" were written which
309understand their own language and produce the necessary `groff'
310operations.  These preprocessors are able to differentiate their own
311input from the rest of the document via markers.
312
313   To use a preprocessor, UNIX pipes are used to feed the output from
314the preprocessor into `groff'.  Any number of preprocessors may be used
315on a given document; in this case, the preprocessors are linked
316together into one pipeline.  However, with `groff', the user does not
317need to construct the pipe, but only tell `groff' what preprocessors to
318use.
319
320   `groff' currently has preprocessors for producing tables (`tbl'),
321typesetting equations (`eqn'), drawing pictures (`pic' and `grn'), and
322for processing bibliographies (`refer').  An associated program which
323is useful when dealing with preprocessors is `soelim'.
324
325   A free implementation of `grap', a preprocessor for drawing graphs,
326can be obtained as an extra package; `groff' can use `grap' also.
327
328   There are other preprocessors in existence, but, unfortunately, no
329free implementations are available.  Among them are preprocessors for
330drawing mathematical pictures (`ideal') and chemical structures
331(`chem').
332
333
334File: groff,  Node: Output device intro,  Next: Credits,  Prev: Preprocessor Intro,  Up: Introduction
335
336Output Devices
337==============
338
339   `groff' actually produces device independent code which may be fed
340into a postprocessor to produce output for a particular device.
341Currently, `groff' has postprocessors for POSTSCRIPT devices, character
342terminals, X Windows (for previewing), TeX DVI format, HP LaserJet 4
343and Canon LBP printers (which use CAPSL), and HTML.
344
345
346File: groff,  Node: Credits,  Prev: Output device intro,  Up: Introduction
347
348Credits
349=======
350
351   Large portions of this manual were taken from existing documents,
352most notably, the manual pages for the `groff' package by James Clark,
353and Eric Allman's papers on the `me' macro package.
354
355   The section on the `man' macro package is partly based on Susan G.
356Kleinmann's `groff_man' manual page written for the Debian GNU/Linux
357system.
358
359   Larry Kollar contributed the section in the `ms' macro package.
360
361
362File: groff,  Node: Invoking groff,  Next: Tutorial for Macro Users,  Prev: Introduction,  Up: Top
363
364Invoking `groff'
365****************
366
367   This section focuses on how to invoke the `groff' front end.  This
368front end takes care of the details of constructing the pipeline among
369the preprocessors, `gtroff' and the postprocessor.
370
371   It has become a tradition that GNU programs get the prefix `g' to
372distinguish it from its original counterparts provided by the host (see
373*Note Environment::, for more details).  Thus, for example, `geqn' is
374GNU `eqn'.  On operating systems like GNU/Linux or the Hurd, which
375don't contain proprietary versions of `troff', and on
376MS-DOS/MS-Windows, where `troff' and associated programs are not
377available at all, this prefix is omitted since GNU `troff' is the only
378used incarnation of `troff'.  Exception: `groff' is never replaced by
379`roff'.
380
381   In this document, we consequently say `gtroff' when talking about
382the GNU `troff' program.  All other implementations of `troff' are
383called AT&T `troff' which is the common origin of all `troff' derivates
384(with more or less compatible changes).  Similarly, we say `gpic',
385`geqn', etc.
386
387* Menu:
388
389* Groff Options::
390* Environment::
391* Macro Directories::
392* Font Directories::
393* Invocation Examples::
394
395
396File: groff,  Node: Groff Options,  Next: Environment,  Prev: Invoking groff,  Up: Invoking groff
397
398Options
399=======
400
401   `groff' normally runs the `gtroff' program and a postprocessor
402appropriate for the selected device.  The default device is `ps' (but
403it can be changed when `groff' is configured and built).  It can
404optionally preprocess with any of `gpic', `geqn', `gtbl', `ggrn',
405`grap', `grefer', or `gsoelim'.
406
407   This section only documents options to the `groff' front end.  Many
408of the arguments to `groff' are passed on to `gtroff', therefore those
409are also included.  Arguments to pre- or postprocessors can be found in
410*Note Invoking gpic::, *Note Invoking geqn::, *Note Invoking gtbl::,
411*Note Invoking ggrn::, *Note Invoking grefer::, *Note Invoking
412gsoelim::, *Note Invoking grotty::, *Note Invoking grops::, *Note
413Invoking grohtml::, *Note Invoking grodvi::, *Note Invoking grolj4::,
414*Note Invoking grolbp::, and *Note Invoking gxditview::.
415
416   The command line format for `groff' is:
417
418
419     groff [ -abceghilpstvzCEGNRSUVXZ ] [ -FDIR ] [ -mNAME ]
420           [ -TDEF ] [ -fFAM ] [ -wNAME ] [ -WNAME ]
421           [ -MDIR ] [ -dCS ] [ -rCN ] [ -nNUM ]
422           [ -oLIST ] [ -PARG ] [ -LARG ] [ -IDIR ]
423           [ FILES... ]
424
425   The command line format for `gtroff' is as follows.
426
427
428     gtroff [ -abcivzCERU ] [ -wNAME ] [ -WNAME ] [ -dCS ]
429            [ -fFAM ] [ -mNAME ] [ -nNUM ]
430            [ -oLIST ] [ -rCN ] [ -TNAME ]
431            [ -FDIR ] [ -MDIR ] [ FILES... ]
432
433Obviously, many of the options to `groff' are actually passed on to
434`gtroff'.
435
436   Options without an argument can be grouped behind a single `-'.  A
437filename of `-' denotes the standard input.  It is possible to have
438whitespace between an option and its parameter.
439
440   The `grog' command can be used to guess the correct `groff' command
441to format a file.
442
443   Here's the description of the command-line options:
444
445`-h'
446     Print a help message.
447
448`-e'
449     Preprocess with `geqn'.
450
451`-t'
452     Preprocess with `gtbl'.
453
454`-g'
455     Preprocess with `ggrn'.
456
457`-G'
458     Preprocess with `grap'.
459
460`-p'
461     Preprocess with `gpic'.
462
463`-s'
464     Preprocess with `gsoelim'.
465
466`-c'
467     Suppress color output.
468
469`-R'
470     Preprocess with `grefer'.  No mechanism is provided for passing
471     arguments to `grefer' because most `grefer' options have
472     equivalent commands which can be included in the file.  *Note
473     grefer::, for more details.
474
475     Note that `gtroff' also accepts a `-R' option, which is not
476     accessible via `groff'.  This option prevents the loading of the
477     `troffrc' and `troffrc-end' files.
478
479`-v'
480     Make programs run by `groff' print out their version number.
481
482`-V'
483     Print the pipeline on `stdout' instead of executing it.
484
485`-z'
486     Suppress output from `gtroff'.  Only error messages are printed.
487
488`-Z'
489     Do not postprocess the output of `gtroff'.  Normally `groff'
490     automatically runs the appropriate postprocessor.
491
492`-PARG'
493     Pass ARG to the postprocessor.  Each argument should be passed
494     with a separate `-P' option.  Note that `groff' does not prepend
495     `-' to ARG before passing it to the postprocessor.
496
497`-l'
498     Send the output to a spooler for printing.  The command used for
499     this is specified by the `print' command in the device description
500     file (see *Note Font Files::, for more info).  If not present,
501     `-l' is ignored.
502
503`-LARG'
504     Pass ARG to the spooler.  Each argument should be passed with a
505     separate `-L' option.  Note that `groff' does not prepend a `-' to
506     ARG before passing it to the postprocessor.  If the `print'
507     keyword in the device description file is missing, `-L' is ignored.
508
509`-TDEV'
510     Prepare output for device DEV.  The default device is `ps', unless
511     changed when `groff' was configured and built.  The following are
512     the output devices currently available:
513
514    `ps'
515          For POSTSCRIPT printers and previewers.
516
517    `dvi'
518          For TeX DVI format.
519
520    `X75'
521          For a 75dpi X11 previewer.
522
523    `X75-12'
524          For a 75dpi X11 previewer with a 12pt base font in the
525          document.
526
527    `X100'
528          For a 100dpi X11 previewer.
529
530    `X100-12'
531          For a 100dpi X11 previewer with a 12pt base font in the
532          document.
533
534    `ascii'
535          For typewriter-like devices using the (7-bit) ASCII character
536          set.
537
538    `latin1'
539          For typewriter-like devices that support the Latin-1
540          (ISO 8859-1) character set.
541
542    `utf8'
543          For typewriter-like devices which use the Unicode (ISO 10646)
544          character set with UTF-8 encoding.
545
546    `cp1047'
547          For typewriter-like devices which use the EBCDIC encoding IBM
548          cp1047.
549
550    `lj4'
551          For HP LaserJet4-compatible (or other PCL5-compatible)
552          printers.
553
554    `lbp'
555          For Canon CAPSL printers (LBP-4 and LBP-8 series laser
556          printers).
557
558    `html'
559          To produce HTML output.  Note that the HTML driver consists
560          of two parts, a preprocessor (`pre-grohtml') and a
561          postprocessor (`post-grohtml').
562
563     The predefined `gtroff' string register `.T' contains the current
564     output device; the read-only number register `.T' is set to 1 if
565     this option is used (which is always true if `groff' is used to
566     call `gtroff').  *Note Built-in Registers::.
567
568     The postprocessor to be used for a device is specified by the
569     `postpro' command in the device description file.  (*Note Font
570     Files::, for more info.)  This can be overridden with the `-X'
571     option.
572
573`-X'
574     Preview with `gxditview' instead of using the usual postprocessor.
575     This is unlikely to produce good results except with `-Tps'.
576
577     Note that this is not the same as using `-TX75' or `-TX100' to
578     view a document with `gxditview': The former uses the metrics of
579     the specified device, whereas the latter uses X-specific fonts and
580     metrics.
581
582`-N'
583     Don't allow newlines with `eqn' delimiters.  This is the same as
584     the `-N' option in `geqn'.
585
586`-S'
587     Safer mode.  Pass the `-S' option to `gpic' and disable the
588     `open', `opena', `pso', `sy', and `pi' requests.  For security
589     reasons, this is enabled by default.
590
591`-U'
592     Unsafe mode.  This enables the `open', `opena', `pso', `sy', and
593     `pi' requests.
594
595`-a'
596     Generate an ASCII approximation of the typeset output.  The
597     read-only register `.A' is then set to 1.  *Note Built-in
598     Registers::.  A typical example is
599
600
601          groff -a -man -Tdvi troff.man | less
602
603     which shows how lines are broken for the DVI device.  Note that
604     this option is rather useless today since graphic output devices
605     are available virtually everywhere.
606
607`-b'
608     Print a backtrace with each warning or error message.  This
609     backtrace should help track down the cause of the error.  The line
610     numbers given in the backtrace may not always be correct: `gtroff'
611     can get confused by `as' or `am' requests while counting line
612     numbers.
613
614`-i'
615     Read the standard input after all the named input files have been
616     processed.
617
618`-wNAME'
619     Enable warning NAME.  Available warnings are described in *Note
620     Debugging::.  Multiple `-w' options are allowed.
621
622`-WNAME'
623     Inhibit warning NAME.  Multiple `-W' options are allowed.
624
625`-E'
626     Inhibit all error messages.
627
628`-C'
629     Enable compatibility mode.  *Note Implementation Differences::,
630     for the list of incompatibilities between `groff' and AT&T `troff'.
631
632`-dCS'
633`-dNAME=S'
634     Define C or NAME to be a string S.  C must be a one-letter name;
635     NAME can be of arbitrary length.  All string assignments happen
636     before loading any macro file (including the start-up file).
637
638`-fFAM'
639     Use FAM as the default font family.  *Note Font Families::.
640
641`-mNAME'
642     Read in the file `NAME.tmac'.  Normally `groff' searches for this
643     in its macro directories.  If it isn't found, it tries `tmac.NAME'
644     (searching in the same directories).
645
646`-nNUM'
647     Number the first page NUM.
648
649`-oLIST'
650     Output only pages in LIST, which is a comma-separated list of page
651     ranges; `N' means print page N, `M-N' means print every page
652     between M and N, `-N' means print every page up to N, `N-' means
653     print every page beginning with N.  `gtroff' exits after printing
654     the last page in the list.  All the ranges are inclusive on both
655     ends.
656
657     Within `gtroff', this information can be extracted with the `.P'
658     register.  *Note Built-in Registers::.
659
660     If your document restarts page numbering at the beginning of each
661     chapter, then `gtroff' prints the specified page range for each
662     chapter.
663
664`-rCN'
665`-rNAME=N'
666     Set number register C or NAME to the value N.  C must be a
667     one-letter name; NAME can be of arbitrary length.  N can be any
668     `gtroff' numeric expression.  All register  assignments happen
669     before loading any macro file (including the start-up file).
670
671`-FDIR'
672     Search `DIR' for subdirectories `devNAME' (NAME is the name of the
673     device), for the `DESC' file, and for font files before looking in
674     the standard directories (*note Font Directories::).  This option
675     is passed to all pre- and postprocessors using the
676     `GROFF_FONT_PATH' environment variable.
677
678`-MDIR'
679     Search directory `DIR' for macro files before the standard
680     directories (*note Macro Directories::).
681
682`-IDIR'
683     This option is as described in *Note gsoelim::.  It implies the
684     `-s' option.
685
686
687File: groff,  Node: Environment,  Next: Macro Directories,  Prev: Groff Options,  Up: Invoking groff
688
689Environment
690===========
691
692   There are also several environment variables (of the operating
693system, not within `gtroff') which can modify the behavior of `groff'.
694
695`GROFF_COMMAND_PREFIX'
696     If this is set to X, then `groff' runs `Xtroff' instead of
697     `gtroff'.  This also applies to `tbl', `pic', `eqn', `grn',
698     `refer', and `soelim'.  It does not apply to `grops', `grodvi',
699     `grotty', `pre-grohtml', `post-grohtml', `grolj4', and `gxditview'.
700
701     The default command prefix is determined during the installation
702     process.  If a non-GNU troff system is found, prefix `g' is used,
703     none otherwise.
704
705`GROFF_TMAC_PATH'
706     A colon-separated list of directories in which to search for macro
707     files (before the default directories are tried).  *Note Macro
708     Directories::.
709
710`GROFF_TYPESETTER'
711     The default output device.
712
713`GROFF_FONT_PATH'
714     A colon-separated list of directories in which to search for the
715     `dev'NAME directory (before the default directories are tried).
716     *Note Font Directories::.
717
718`GROFF_BIN_PATH'
719     This search path, followed by `PATH', is used for commands executed
720     by `groff'.
721
722`GROFF_TMPDIR'
723     The directory in which `groff' creates temporary files.  If this is
724     not set and `TMPDIR' is set, temporary files are created in that
725     directory.  Otherwise temporary files are created in a
726     system-dependent default directory (on Unix and GNU/Linux systems,
727     this is usually `/tmp').  `grops', `grefer', `pre-grohtml', and
728     `post-grohtml' can create temporary files in this directory.
729
730   Note that MS-DOS and MS-Windows ports of `groff' use semi-colons,
731rather than colons, to separate the directories in the lists described
732above.
733
734
735File: groff,  Node: Macro Directories,  Next: Font Directories,  Prev: Environment,  Up: Invoking groff
736
737Macro Directories
738=================
739
740   All macro file names must be named `NAME.tmac' or `tmac.NAME' to
741make the `-mNAME' command line option work.  The `mso' request doesn't
742have this restriction; any file name can be used, and `gtroff' won't
743try to append or prepend the `tmac' string.
744
745   Macro files are kept in the "tmac directories", all of which
746constitute the "tmac path".  The elements of the search path for macro
747files are (in that order):
748
749   * The directories specified with `gtroff''s or `groff''s `-M'
750     command line option.
751
752   * The directories given in the `GROFF_TMAC_PATH' environment
753     variable.
754
755   * The current directory (only if in unsafe mode using the `-U'
756     command line switch).
757
758   * The home directory.
759
760   * A platform-dependent directory, a site-specific
761     (platform-independent) directory, and the main tmac directory; the
762     default locations are
763
764
765          /usr/local/lib/groff/site-tmac
766          /usr/local/share/groff/site-tmac
767          /usr/local/share/groff/1.18/tmac
768
769     assuming that the version of `groff' is 1.18, and the installation
770     prefix was `/usr/local'.  It is possible to fine-tune those
771     directories during the installation process.
772
773
774File: groff,  Node: Font Directories,  Next: Invocation Examples,  Prev: Macro Directories,  Up: Invoking groff
775
776Font Directories
777================
778
779   Basically, there is no restriction how font files for `groff' are
780named and how long font names are; however, to make the font family
781mechanism work (*note Font Families::), fonts within a family should
782start with the family name, followed by the shape.  For example, the
783Times family uses `T' for the family name and `R', `B', `I', and `BI'
784to indicate the shapes `roman', `bold', `italic', and `bold italic',
785respectively.  Thus the final font names are `TR', `TB', `TI', and
786`TBI'.
787
788   All font files are kept in the "font directories" which constitute
789the "font path".  The file search functions will always append the
790directory `dev'NAME, where NAME is the name of the output device.
791Assuming, say, DVI output, and `/foo/bar' as a font directory, the font
792files for `grodvi' must be in `/foo/bar/devdvi'.
793
794   The elements of the search path for font files are (in that order):
795
796   * The directories specified with `gtroff''s or `groff''s `-F'
797     command line option.  All device drivers and some preprocessors
798     also have this option.
799
800   * The directories given in the `GROFF_FONT_PATH' environment
801     variable.
802
803   * A site-specific directory and the main font directory; the default
804     locations are
805
806
807          /usr/local/share/groff/site-font
808          /usr/local/share/groff/1.18/font
809
810     assuming that the version of `groff' is 1.18, and the installation
811     prefix was `/usr/local'.  It is possible to fine-tune those
812     directories during the installation process.
813
814
815File: groff,  Node: Invocation Examples,  Prev: Font Directories,  Up: Invoking groff
816
817Invocation Examples
818===================
819
820   This section lists several common uses of `groff' and the
821corresponding command lines.
822
823
824     groff file
825
826This command processes `file' without a macro package or a
827preprocessor.  The output device is the default, `ps', and the output
828is sent to `stdout'.
829
830
831     groff -t -mandoc -Tascii file | less
832
833This is basically what a call to the `man' program does.  `gtroff'
834processes the manual page `file' with the `mandoc' macro file (which in
835turn either calls the `man' or the `mdoc' macro package), using the
836`tbl' preprocessor and the ASCII output device.  Finally, the `less'
837pager displays the result.
838
839
840     groff -X -m me file
841
842Preview `file' with `gxditview', using the `me' macro package.  Since
843no `-T' option is specified, use the default device (`ps').  Note that
844you can either say `-m me' or `-me'; the latter is an anachronism from
845the early days of UNIX.(1) (*note Invocation Examples-Footnote-1::)
846
847
848     groff -man -rD1 -z file
849
850Check `file' with the `man' macro package, forcing double-sided
851printing - don't produce any output.
852
853* Menu:
854
855* grog::
856
857
858File: groff,  Node: Invocation Examples-Footnotes,  Up: Invocation Examples
859
860   (1) The same is true for the other main macro packages that come
861with `groff': `man', `mdoc', `ms', `mm', and `mandoc'.  This won't work
862in general; for example, to load `trace.tmac', either `-mtrace' or
863`-m trace' must be used.
864
865
866File: groff,  Node: grog,  Prev: Invocation Examples,  Up: Invocation Examples
867
868`grog'
869------
870
871   `grog' reads files, guesses which of the `groff' preprocessors
872and/or macro packages are required for formatting them, and prints the
873`groff' command including those options on the standard output.  It
874generates one or more of the options `-e', `-man', `-me', `-mm',
875`-mom', `-ms', `-mdoc', `-mdoc-old', `-p', `-R', `-g', `-G', `-s', and
876`-t'.
877
878   A special file name `-' refers to the standard input.  Specifying no
879files also means to read the standard input.  Any specified options are
880included in the printed command.  No space is allowed between options
881and their arguments.  The only options recognized are `-C' (which is
882also passed on) to enable compatibility mode, and `-v' to print the
883version number and exit.
884
885   For example,
886
887
888     grog -Tdvi paper.ms
889
890guesses the appropriate command to print `paper.ms' and then prints it
891to the command line after adding the `-Tdvi' option.  For direct
892execution, enclose the call to `grog' in backquotes at the UNIX shell
893prompt:
894
895
896     `grog -Tdvi paper.ms` > paper.dvi
897
898As seen in the example, it is still necessary to redirect the output to
899something meaningful (i.e. either a file or a pager program like
900`less').
901
902
903File: groff,  Node: Tutorial for Macro Users,  Next: Macro Packages,  Prev: Invoking groff,  Up: Top
904
905Tutorial for Macro Users
906************************
907
908   Most users tend to use a macro package to format their papers.  This
909means that the whole breadth of `groff' is not necessary for most
910people.  This chapter covers the material needed to efficiently use a
911macro package.
912
913* Menu:
914
915* Basics::
916* Common Features::
917
918
919File: groff,  Node: Basics,  Next: Common Features,  Prev: Tutorial for Macro Users,  Up: Tutorial for Macro Users
920
921Basics
922======
923
924   This section covers some of the basic concepts necessary to
925understand how to use a macro package.(1) (*note Basics-Footnote-1::)
926References are made throughout to more detailed information, if desired.
927
928   `gtroff' reads an input file prepared by the user and outputs a
929formatted document suitable for publication or framing.  The input
930consists of text, or words to be printed, and embedded commands
931("requests" and "escapes"), which tell `gtroff' how to format the
932output.  For more detail on this, see *Note Embedded Commands::.
933
934   The word "argument" is used in this chapter to mean a word or number
935which appears on the same line as a request, and which modifies the
936meaning of that request.  For example, the request
937
938
939     .sp
940
941spaces one line, but
942
943
944     .sp 4
945
946spaces four lines.  The number 4 is an argument to the `sp' request
947which says to space four lines instead of one.  Arguments are separated
948from the request and from each other by spaces (_no_ tabs).  More
949details on this can be found in *Note Request Arguments::.
950
951   The primary function of `gtroff' is to collect words from input
952lines, fill output lines with those words, justify the right-hand margin
953by inserting extra spaces in the line, and output the result.  For
954example, the input:
955
956
957     Now is the time
958     for all good men
959     to come to the aid
960     of their party.
961     Four score and seven
962     years ago, etc.
963
964is read, packed onto output lines, and justified to produce:
965
966     Now is the time for all good men to come to the aid of their party.
967     Four score and seven years ago, etc.
968
969   Sometimes a new output line should be started even though the current
970line is not yet full; for example, at the end of a paragraph.  To do
971this it is possible to cause a "break", which starts a new output line.
972Some requests cause a break automatically, as normally do blank input
973lines and input lines beginning with a space.
974
975   Not all input lines are text to be formatted.  Some input lines are
976requests which describe how to format the text.  Requests always have a
977period (`.') or an apostrophe (`'') as the first character of the input
978line.
979
980   The text formatter also does more complex things, such as
981automatically numbering pages, skipping over page boundaries, putting
982footnotes in the correct place, and so forth.
983
984   Here are a few hints for preparing text for input to `gtroff'.
985
986   * First, keep the input lines short.  Short input lines are easier to
987     edit, and `gtroff' packs words onto longer lines anyhow.
988
989   * In keeping with this, it is helpful to begin a new line after every
990     comma or phrase, since common corrections are to add or delete
991     sentences or phrases.
992
993   * End each sentence with two spaces - or better, start each sentence
994     on a new line.  `gtroff' recognizes characters that usually end a
995     sentence, and inserts sentence space accordingly.
996
997   * Do not hyphenate words at the end of lines - `gtroff' is smart
998     enough to hyphenate words as needed, but is not smart enough to
999     take hyphens out and join a word back together.  Also, words such
1000     as "mother-in-law" should not be broken over a line, since then a
1001     space can occur where not wanted, such as "mother- in-law".
1002
1003   `gtroff' double-spaces output text automatically if you use the
1004request `.ls 2'.  Reactivate single-spaced mode by typing `.ls 1'.(2)
1005(*note Basics-Footnote-2::)
1006
1007   A number of requests allow to change the way the output looks,
1008sometimes called the "layout" of the output page.  Most of these
1009requests adjust the placing of "whitespace" (blank lines or spaces).
1010
1011   The `bp' request starts a new page, causing a line break.
1012
1013   The request `.sp N' leaves N lines of blank space.  N can be omitted
1014(meaning skip a single line) or can be of the form Ni (for N inches) or
1015Nc (for N centimeters).  For example, the input:
1016
1017
1018     .sp 1.5i
1019     My thoughts on the subject
1020     .sp
1021
1022leaves one and a half inches of space, followed by the line "My
1023thoughts on the subject", followed by a single blank line (more
1024measurement units are available, see *Note Measurements::).
1025
1026   Text lines can be centered by using the `ce' request.  The line
1027after `ce' is centered (horizontally) on the page.  To center more than
1028one line, use `.ce N' (where N is the number of lines to center),
1029followed by the N lines.  To center many lines without counting them,
1030type:
1031
1032
1033     .ce 1000
1034     lines to center
1035     .ce 0
1036
1037The `.ce 0' request tells `groff' to center zero more lines, in other
1038words, stop centering.
1039
1040   All of these requests cause a break; that is, they always start a new
1041line.  To start a new line without performing any other action, use
1042`br'.
1043
1044
1045File: groff,  Node: Basics-Footnotes,  Up: Basics
1046
1047   (1) This section is derived from `Writing Papers with nroff using
1048-me' by Eric P. Allman.
1049
1050   (2) If you need finer granularity of the vertical space, use the
1051`pvs' request (*note Changing Type Sizes::).
1052
1053
1054File: groff,  Node: Common Features,  Prev: Basics,  Up: Tutorial for Macro Users
1055
1056Common Features
1057===============
1058
1059   `gtroff' provides very low-level operations for formatting a
1060document.  There are many common routine operations which are done in
1061all documents.  These common operations are written into "macros" and
1062collected into a "macro package".
1063
1064   All macro packages provide certain common capabilities which fall
1065into the following categories.
1066
1067* Menu:
1068
1069* Paragraphs::
1070* Sections and Chapters::
1071* Headers and Footers::
1072* Page Layout Adjustment::
1073* Displays::
1074* Footnotes and Annotations::
1075* Table of Contents::
1076* Indices::
1077* Paper Formats::
1078* Multiple Columns::
1079* Font and Size Changes::
1080* Predefined Strings::
1081* Preprocessor Support::
1082* Configuration and Customization::
1083
1084
1085File: groff,  Node: Paragraphs,  Next: Sections and Chapters,  Prev: Common Features,  Up: Common Features
1086
1087Paragraphs
1088----------
1089
1090   One of the most common and most used capability is starting a
1091paragraph.  There are a number of different types of paragraphs, any of
1092which can be initiated with macros supplied by the macro package.
1093Normally, paragraphs start with a blank line and the first line
1094indented, like the text in this manual.  There are also block style
1095paragraphs, which omit the indentation:
1096
1097
1098     Some   men  look   at  constitutions   with  sanctimonious
1099     reverence, and deem them like the ark of the covenant, too
1100     sacred to be touched.
1101
1102And there are also indented paragraphs which begin with a tag or label
1103at the margin and the remaining text indented.
1104
1105
1106     one   This is  the first paragraph.  Notice  how the first
1107           line of  the resulting  paragraph lines up  with the
1108           other lines in the paragraph.
1109
1110
1111     longlabel
1112           This  paragraph   had  a  long   label.   The  first
1113           character of text on the first line does not line up
1114           with  the  text  on  second  and  subsequent  lines,
1115           although they line up with each other.
1116
1117   A variation of this is a bulleted list.
1118
1119
1120     .     Bulleted lists start with a bullet.   It is possible
1121           to use other glyphs instead of the bullet.  In nroff
1122           mode using the ASCII character set for output, a dot
1123           is used instead of a real bullet.
1124
1125
1126File: groff,  Node: Sections and Chapters,  Next: Headers and Footers,  Prev: Paragraphs,  Up: Common Features
1127
1128Sections and Chapters
1129---------------------
1130
1131   Most macro packages supply some form of section headers.  The
1132simplest kind is simply the heading on a line by itself in bold type.
1133Others supply automatically numbered section heading or different
1134heading styles at different levels.  Some, more sophisticated, macro
1135packages supply macros for starting chapters and appendices.
1136
1137
1138File: groff,  Node: Headers and Footers,  Next: Page Layout Adjustment,  Prev: Sections and Chapters,  Up: Common Features
1139
1140Headers and Footers
1141-------------------
1142
1143   Every macro package gives some way to manipulate the "headers" and
1144"footers" (also called "titles") on each page.  This is text put at the
1145top and bottom of each page, respectively, which contain data like the
1146current page number, the current chapter title, and so on.  Its
1147appearance is not affected by the running text.  Some packages allow
1148for different ones on the even and odd pages (for material printed in a
1149book form).
1150
1151   The titles are called "three-part titles", that is, there is a
1152left-justified part, a centered part, and a right-justified part.  An
1153automatically generated page number may be put in any of these fields
1154with the `%' character (see *Note Page Layout::, for more details).
1155
1156
1157File: groff,  Node: Page Layout Adjustment,  Next: Displays,  Prev: Headers and Footers,  Up: Common Features
1158
1159Page Layout
1160-----------
1161
1162   Most macro packages let the user specify top and bottom margins and
1163other details about the appearance of the printed pages.
1164
1165
1166File: groff,  Node: Displays,  Next: Footnotes and Annotations,  Prev: Page Layout Adjustment,  Up: Common Features
1167
1168Displays
1169--------
1170
1171   "Displays" are sections of text to be set off from the body of the
1172paper.  Major quotes, tables, and figures are types of displays, as are
1173all the examples used in this document.
1174
1175   "Major quotes" are quotes which are several lines long, and hence
1176are set in from the rest of the text without quote marks around them.
1177
1178   A "list" is an indented, single-spaced, unfilled display.  Lists
1179should be used when the material to be printed should not be filled and
1180justified like normal text, such as columns of figures or the examples
1181used in this paper.
1182
1183   A "keep" is a display of lines which are kept on a single page if
1184possible.  An example for a keep might be a diagram.  Keeps differ from
1185lists in that lists may be broken over a page boundary whereas keeps are
1186not.
1187
1188   "Floating keeps" move relative to the text.  Hence, they are good for
1189things which are referred to by name, such as "See figure 3".  A
1190floating keep appears at the bottom of the current page if it fits;
1191otherwise, it appears at the top of the next page.  Meanwhile, the
1192surrounding text `flows' around the keep, thus leaving no blank areas.
1193
1194
1195File: groff,  Node: Footnotes and Annotations,  Next: Table of Contents,  Prev: Displays,  Up: Common Features
1196
1197Footnotes and Annotations
1198-------------------------
1199
1200   There are a number of requests to save text for later printing.
1201
1202   "Footnotes" are printed at the bottom of the current page.
1203
1204   "Delayed text" is very similar to a footnote except that it is
1205printed when called for explicitly.  This allows a list of references to
1206appear (for example) at the end of each chapter, as is the convention in
1207some disciplines.
1208
1209   Most macro packages which supply this functionality also supply a
1210means of automatically numbering either type of annotation.
1211
1212
1213File: groff,  Node: Table of Contents,  Next: Indices,  Prev: Footnotes and Annotations,  Up: Common Features
1214
1215Table of Contents
1216-----------------
1217
1218   "Tables of contents" are a type of delayed text having a tag
1219(usually the page number) attached to each entry after a row of dots.
1220The table accumulates throughout the paper until printed, usually after
1221the paper has ended.  Many macro packages provide the ability to have
1222several tables of contents (e.g. a standard table of contents, a list
1223of tables, etc).
1224
1225
1226File: groff,  Node: Indices,  Next: Paper Formats,  Prev: Table of Contents,  Up: Common Features
1227
1228Indices
1229-------
1230
1231   While some macro packages use the term "index", none actually
1232provide that functionality.  The facilities they call indices are
1233actually more appropriate for tables of contents.
1234
1235   To produce a real index in a document, external tools like the
1236`makeindex' program are necessary.
1237
1238
1239File: groff,  Node: Paper Formats,  Next: Multiple Columns,  Prev: Indices,  Up: Common Features
1240
1241Paper Formats
1242-------------
1243
1244   Some macro packages provide stock formats for various kinds of
1245documents.  Many of them provide a common format for the title and
1246opening pages of a technical paper.  The `mm' macros in particular
1247provide formats for letters and memoranda.
1248
1249
1250File: groff,  Node: Multiple Columns,  Next: Font and Size Changes,  Prev: Paper Formats,  Up: Common Features
1251
1252Multiple Columns
1253----------------
1254
1255   Some macro packages (but not `man') provide the ability to have two
1256or more columns on a page.
1257
1258
1259File: groff,  Node: Font and Size Changes,  Next: Predefined Strings,  Prev: Multiple Columns,  Up: Common Features
1260
1261Font and Size Changes
1262---------------------
1263
1264   The built-in font and size functions are not always intuitive, so all
1265macro packages provide macros to make these operations simpler.
1266
1267
1268File: groff,  Node: Predefined Strings,  Next: Preprocessor Support,  Prev: Font and Size Changes,  Up: Common Features
1269
1270Predefined Strings
1271------------------
1272
1273   Most macro packages provide various predefined strings for a variety
1274of uses; examples are sub- and superscripts, printable dates, quotes and
1275various special characters.
1276
1277
1278File: groff,  Node: Preprocessor Support,  Next: Configuration and Customization,  Prev: Predefined Strings,  Up: Common Features
1279
1280Preprocessor Support
1281--------------------
1282
1283   All macro packages provide support for various preprocessors and may
1284extend their functionality.
1285
1286   For example, all macro packages mark tables (which are processed with
1287`gtbl') by placing them between `TS' and `TE' macros.  The `ms' macro
1288package has an option, `.TS H', that prints a caption at the top of a
1289new page (when the table is too long to fit on a single page).
1290
1291
1292File: groff,  Node: Configuration and Customization,  Prev: Preprocessor Support,  Up: Common Features
1293
1294Configuration and Customization
1295-------------------------------
1296
1297   Some macro packages provide means of customizing many of the details
1298of how the package behaves.  This ranges from setting the default type
1299size to changing the appearance of section headers.
1300
1301
1302File: groff,  Node: Macro Packages,  Next: gtroff Reference,  Prev: Tutorial for Macro Users,  Up: Top
1303
1304Macro Packages
1305**************
1306
1307   This chapter documents the main macro packages that come with
1308`groff'.
1309
1310* Menu:
1311
1312* man::
1313* mdoc::
1314* ms::
1315* me::
1316* mm::
1317
1318
1319File: groff,  Node: man,  Next: mdoc,  Prev: Macro Packages,  Up: Macro Packages
1320
1321`man'
1322=====
1323
1324   This is the most popular and probably the most important macro
1325package of `groff'.  It is easy to use, and a vast majority of manual
1326pages are based on it.
1327
1328* Menu:
1329
1330* Man options::
1331* Man usage::
1332* Man font macros::
1333* Miscellaneous man macros::
1334* Predefined man strings::
1335* Preprocessors in man pages::
1336
1337
1338File: groff,  Node: Man options,  Next: Man usage,  Prev: man,  Up: man
1339
1340Options
1341-------
1342
1343   The command line format for using the `man' macros with `groff' is:
1344
1345
1346     groff -m man [ -rLL=LENGTH ] [ -rLT=LENGTH ]
1347           [ -rcR=1 ] [ -rC1 ] [ -rD1 ] [ -rPNNN ]
1348           [ -rSXX ] [ -rXNNN ] [ FILES... ]
1349
1350It is possible to use `-man' instead of `-m man'.
1351
1352`-rLL=LENGTH'
1353     Set line length to LENGTH.  If not specified, the line length
1354     defaults to 78 en in nroff mode (this is 78 characters per line)
1355     and 6.5 inch otherwise.
1356
1357`-rLT=LENGTH'
1358     Set title length to LENGTH.  If not specified, the title length
1359     defaults to 78 en in nroff mode (this is 78 characters per line)
1360     and 6.5 inch otherwise.
1361
1362`-rcR=1'
1363     This option (the default if a TTY output device is used) creates a
1364     single, very long page instead of multiple pages.  Use `-rcR=0' to
1365     disable it.
1366
1367`-rC1'
1368     If more than one manual page is given on the command line, number
1369     the pages continuously, rather than starting each at 1.
1370
1371`-rD1'
1372     Double-sided printing.  Footers for even and odd pages are
1373     formatted differently.
1374
1375`-rPNNN'
1376     Page numbering starts with NNN rather than with 1.
1377
1378`-rSXX'
1379     Use XX (which can be 10, 11, or 12pt) as the base document font
1380     size instead of the default value of 10pt.
1381
1382`-rXNNN'
1383     After page NNN, number pages as NNNa, NNNb, NNNc, etc.  For
1384     example, the option `-rX2' produces the following page numbers: 1,
1385     2, 2a, 2b, 2c, etc.
1386
1387