groff
front-end for the groff document formatting system
1. groff.1.man
Manpage of GROFF
GROFF
Section: User Commands (1)Updated: 3 July 2005
Index Return to Main Contents
NAME
groff - front-end for the groff document formatting systemSYNOPSIS
nopsis groffortOpt[] abcegilpstzCEGNRSUVXZ
ortOpt[] d cs
ortOpt[] f fam
ortOpt[] F dir
ortOpt[] I dir
ortOpt[] L arg
ortOpt[] m name
ortOpt[] M dir
ortOpt[] n num
ortOpt[] o list
ortOpt[] P arg
ortOpt[] r cn
ortOpt[] T dev
ortOpt[] w name
ortOpt[] W name
[file dSynopsis nopsis groffortOpt h
| dSynopsis nopsis groffortOpt v
| [option dSynopsis The command line is parsed according to the usual GNU convention. The whitespace between a command line option and its argument is optional. Options can be grouped behind a singleortOpt
(minus character). A filename ofortOpt
(minus character) denotes the standard input.DESCRIPTION
This document describes the groff program, the main front-end for the groff document formatting system. The groff program and macro suite is the implementation of a roff(7) system within the free software collection The groff system has all features of the classical roff, but adds many extensions. The groff program allows to control the whole groff system by command line options. This is a great simplification in comparison to the classical case (which uses pipes only).OPTIONS
As groff is a wrapper program for troff both programs share a set of options. But the groff program has some additional, native options and gives a new meaning to some troff options. On the other hand, not all troff options can be fed into groff.Native groff Options
The following options either do not exist for troff or are differently interpreted by groff. [tDef e] Preprocess with eqn. [tDef g] Preprocess with grn. [tDef G] Preprocess with grap. [tDef h help] Print a help message. [tDef I dir] This option may be used to specify a directory to search for files (both those on the command line and those named in .psbb and .so requests, and \X'ps: import' and \X'ps: file' escapes). The current directory is always searched first. This option may be specified more than once; the directories will be searched in the order specified. No directory search is performed for files specified using an absolute path. This option implies theortOpt s
option. [tDef l] Send the output to a spooler program for printing. The command that should be used for this is specified by the print command in the device description file, see groff_font(5). If this command is not present, the output is piped into the lpr(1) program by default. See optionsortOpt L
andortOpt X
[tDef L arg] Pass arg to the spooler program. Several arguments should be passed with a separateortOpt L
option each. Note that groff does not prependortOpt(a minus sign) to
arg before passing it to the spooler program. [tDef N] Don't allow newlines within eqn delimiters. This is the same as theortOpt N
option in eqn. [tDef p] Preprocess with pic. [tDef P @-]option] [tDef+ P @-]option CB]@-]P] arg] Pass @-]option or @-]option arg to the postprocessor. The option must be specified with the necessary preceding minus sign(s) or because groff does not prepend any dashes before passing it to the postprocessor. For example, to pass a title to the gxditview postprocessor, the shell commandellCommand groff @-]X @-]P @-]title @-]P 'groff it' I]foo]
- is equivalent to
ellCommand groff @-]X @-]Z I]foo] |
gxditview @-]title 'groff it' @-] [tDef R] Preprocess with refer. No mechanism is provided for passing arguments to refer because most refer options have equivalent language elements that can be specified within the document. See refer(1) for more details. [tDef s] Preprocess with soelim. [tDef S] Safer mode. Pass theortOpt S
option to pic and disable the following troff requests: .open, .opena, .pso, .sy, and .pi. For security reasons, safer mode is enabled by default. [tDef t] Preprocess with tbl. [tDef T dev] Set output device to dev. For this device, troff generates the intermediate output; see groff_out(5). Then groff calls a postprocessor to convert troff's intermediate output to its final format. Real devices in groff are-
-
- dvi
- TeX DVI format (postprocessor is grodvi).
-
HTML output (preprocessors are
soelim
and
pre-gr,
postprocessor is
post-gr).
- lbp
- Canon CAPSL printers (LBP-4 and LBP-8 series laser printers; postprocessor is grolbp).
- lj4
- HP LaserJet4 compatible (or other PCL5 compatible) printers (postprocessor is grolj4).
- ps
- PostScript output (postprocessor is grops).
-
- For the following TTY output devices (postprocessor is always grotty),
ortOpt T
selects the output encoding:-
-
- ascii
- 7bit ASCII.
- cp1047
- Latin-1 character set for EBCDIC hosts.
- latin1
- ISO 8859-1.
- utf8
- Unicode character set in UTF-8 encoding.
-
-
The following arguments select
gxditview
as the `postprocessor' (it is rather a viewing program):
-
-
- X75
- 75dpi resolution, 10pt document base font.
- X75-12
- 75dpi resolution, 12pt document base font.
- X100
- 100dpi resolution, 10pt document base font.
- X100-12
- 100dpi resolution, 12pt document base font.
-
-
- The default device is ps. [tDef U] Unsafe mode. Reverts to the (old) unsafe behaviour; see option
ortOpt S
[tDef v version] Output version information of groff and of all programs that are run by it; that is, the given command line is parsed in the usual way, passingortOpt v
to all subprograms. [tDef V] Output the pipeline that would be run by groff (as a wrapper program) on the standard output, but do not execute it. If given more than once, the commands will be both printed on the standard error and run. [tDef X] Use gxditview instead of using the usual postprocessor to (pre)view a document. The printing spooler behavior as outlined with optionsortOpt l
andortOpt L
is carried over to gxditview(1) by determining an argument for the @-]printCommand option of gxditview(1). This sets the default Print action and the corresponding menu entry to that value.ortOpt X
only produces good results withortOpt Tps
ortOpt TX75
ortOpt TX75-12
ortOpt TX100
andortOpt TX100-12
The default resolution for previewingortOpt Tps
output is 75dpi; this can be changed by passing theortOpt resolution
option to gxditview, for exampleellCommand groff @-]X @-]P@-]resolution @-]P100 @-]man foo.1
[tDef z] Suppress output generated by troff. Only error messages will be printed. [tDef Z] Print the groff intermediate output to standard output; see groff_out(5). Normally groff calls automatically a postprocessor. With this option, the output of troff for the device, the so-called intermediate output is issued without postprocessing.Transparent Options
The following options are transparently handed over to the formatter program troff that is called by groff subsequently. These options are described in more detail in troff(1). [tDef a] ascii approximation of output. [tDef b] backtrace on error or warning. [tDef c] disable color output. Please consult the grotty(1) man page for more details. [tDef C] enable compatibility mode. [tDef d cs] [tDef+ d name=s] define string. [tDef E] disable troff error messages. [tDef f fam] set default font family. [tDef F dir] set path for font DESC files. [tDef i] process standard input after the specified input files. [tDef m name] include macro file I]name]B].tmac] (or B]tmac.]I]name]); see also groff_tmac(5). [tDef M dir] path for macro files. [tDef n num] number the first page num. [tDef o list] output only pages in list. [tDef r cn] [tDef+ r name=n] set number register. [tDef w name] enable warning name. [tDef W name] disable warning name.USING GROFF
The groff system implements the infrastructure of classical roff; see roff(7) for a survey on how a roff system works in general. Due to the front-end programs available within the groff system, using groff is much easier than classical roff. This section gives an overview of the parts that constitute the groff system. It complements roff(7) with groff-specific features. This section can be regarded as a guide to the documentation around the groff system.Paper Size
The virtual paper size used by troff to format the input is controlled globally with the requests .po, .pl, and .ll. See groff_tmac(5) for the `papersize' macro package which provides a convenient interface. The physical paper size, giving the actual dimensions of the paper sheets, is controlled by output devices like grops with the command line options -p and -l. See groff_font(5) and the man pages of the output devices for more details. groff uses the command line option -P to pass options to output devices; for example, the following selects A4 paper in landscape orientation for the PS device:- groff -Tps -P-pa4 -P-l ...
Front-ends
The groff program is a wrapper around the troff(1) program. It allows to specify the preprocessors by command line options and automatically runs the postprocessor that is appropriate for the selected device. Doing so, the sometimes tedious piping mechanism of classical roff(7) can be avoided. The grog(1) program can be used for guessing the correct groff command line to format a file. The groffer(1) program is an allround-viewer for groff files and man pages.Preprocessors
The groff preprocessors are reimplementations of the classical preprocessors with moderate extensions. The preprocessors distributed with the groff package are- eqn(1)
- for mathematical formulae,
- grn(1)
- for including gremlin(1) pictures,
- pic(1)
- for drawing diagrams,
- refer(1)
- for bibliographic references,
- soelim(1)
- for including macro files from standard locations, and
- tbl(1)
- for tables. Besides these, there are some internal preprocessors that are automatically run with some devices. These aren't visible to the user.
Macro Packages
Macro packages can be included by optionortOpt m
The groff system implements and extends all classical macro packages in a compatible way and adds some packages of its own. Actually, the following macro packages come with groff:- man
- The traditional man page format; see groff_man(7). It can be specified on the command line as
ortOpt man
orortOpt m
man.- mandoc
- The general package for man pages; it automatically recognizes whether the documents uses the man or the mdoc format and branches to the corresponding macro package. It can be specified on the command line as
ortOpt mandoc
orortOpt m
mandoc.- mdoc
- The BSD-style man page format; see groff_mdoc(7). It can be specified on the command line as
ortOpt mdoc
orortOpt m
mdoc.- me
- The classical me document format; see groff_me(7). It can be specified on the command line as
ortOpt me
orortOpt m
me.- mm
- The classical mm document format; see groff_mm(7). It can be specified on the command line as
ortOpt mm
orortOpt m
mm.- ms
- The classical ms document format; see groff_ms(7). It can be specified on the command line as
ortOpt ms
orortOpt m
ms.- www
- HTML-like macros for inclusion in arbitrary groff documents; see groff_www(7). Details on the naming of macro files and their placement can be found in groff_tmac(5); this man page also documents some other, minor auxiliary macro packages not mentioned here.
Programming Language
General concepts common to all roff programming languages are described in roff(7). The groff extensions to the classical troff language are documented in groff_diff(7). The groff language as a whole is described in the (still incomplete) groff info file; a short (but complete) reference can be found in groff(7).Formatters
The central roff formatter within the groff system is troff(1). It provides the features of both the classical troff and nroff, as well as the groff extensions. The command line optionortOpt C
switches troff into compatibility mode which tries to emulate classical roff as much as possible. There is a shell script nroff(1) that emulates the behavior of classical nroff. It tries to automatically select the proper output encoding, according to the current locale. The formatter program generates intermediate output; see groff_out(7).Devices
In roff, the output targets are called devices. A device can be a piece of hardware, e.g. a printer, or a software file format. A device is specified by the optionortOpt T
The groff devices are as follows.- ascii
- Text output using the ascii(7) character set.
- cp1047
- Text output using the EBCDIC code page IBM cp1047 (e.g. OS/390 Unix).
- dvi
- TeX DVI format.
-
- HTML output.
- latin1
- Text output using the ISO Latin-1 (ISO 8859-1) character set; see iso_8859_1(7).
- lbp
- Output for Canon CAPSL printers (LBP-4 and LBP-8 series laser printers).
- lj4
- HP LaserJet4-compatible (or other PCL5-compatible) printers.
- ps
- PostScript output; suitable for printers and previewers like gv(1).
- utf8
- Text output using the Unicode (ISO 10646) character set with UTF-8 encoding; see unicode(7).
- X75
- 75dpi X Window System output suitable for the previewers xditview(1x) and gxditview(1). A variant for a 12pt document base font is X75-12.
- X100
- 100dpi X Window System output suitable for the previewers xditview(1x) and gxditview(1). A variant for a 12pt document base font is X100-12. The postprocessor to be used for a device is specified by the postpro command in the device description file; see groff_font(5). This can be overridden with the @-]X option. The default device is ps.
Postprocessors
groff provides 3~hardware postprocessors:- grolbp(1)
- for some Canon printers,
- grolj4(1)
- for printers compatible to the HP LaserJet~4 and PCL5,
- grotty(1)
- for text output using various encodings, e.g. on text-oriented terminals or line-printers. Today, most printing or drawing hardware is handled by the operating system, by device drivers, or by software interfaces, usually accepting PostScript. Consequently, there isn't an urgent need for more hardware device postprocessors. The groff software devices for conversion into other document file formats are
- grodvi(1)
- for the DVI format,
- gr(1)
- for HTML format,
- grops(1)
- for PostScript. Combined with the many existing free conversion tools this should be sufficient to convert a troff document into virtually any existing data format.
Utilities
The following utility programs around groff are available.- addftinfo(1)
- Add information to troff font description files for use with groff.
- afmtodit(1)
- Create font description files for PostScript device.
- groffer(1)
- General viewer program for groff files and man pages.
- gxditview(1)
- The groff X viewer, the GNU version of xditview.
- hpftodit(1)
- Create font description files for lj4 device.
- indxbib(1)
- Make inverted index for bibliographic databases.
- lkbib(1)
- Search bibliographic databases.
- lookbib(1)
- Interactively search bibliographic databases.
- pfbtops(1)
- Translate a PostScript font in .pfb format to ASCII.
- tfmtodit(1)
- Create font description files for TeX DVI device.
- xditview(1x)
- roff viewer distributed with X window.
ENVIRONMENT
Normally, the path separator in the following environment variables is the colon; this may vary depending on the operating system. For example, DOS and Windows use a semicolon instead.- vVarGROFF_BIN_PATH
- This search path, followed by vVar$PATH will be used for commands that are executed by groff. If it is not set then the directory where the groff binaries were installed is prepended to vVarPATH
- vVarGROFF_COMMAND_PREFIX
- When there is a need to run different roff implementations at the same time groff provides the facility to prepend a prefix to most of its programs that could provoke name clashings at run time (default is to have none). Historically, this prefix was the character g, but it can be anything. For example, gtroff stood for groff's troff, gtbl for the groff version of tbl. By setting vVarGROFF_COMMAND_PREFIX to different values, the different roff installations can be addressed. More exactly, if it is set to prefix xxx then groff as a wrapper program will internally call xxxtroff instead of troff. This also applies to the preprocessors eqn, grn, pic, refer, tbl, soelim, and to the utilities indxbib and lookbib. This feature does not apply to any programs different from the ones above (most notably groff itself) since they are unique to the groff package.
- vVarGROFF_FONT_PATH
- A list of directories in which to search for the devname directory in addition to the default ones. See troff(1) and groff_font(5) for more details.
- vVarGROFF_TMAC_PATH
- A list of directories in which to search for macro files in addition to the default directories. See troff(1) and groff_tmac(5) for more details.
- vVarGROFF_TMPDIR
- The directory in which temporary files will be created. If this is not set but the environment variable vVarTMPDIR instead, temporary files will be created in the directory vVar$TMPDIR On MS-DOS and Windows 32 platforms, the environment variables vVarTMP and vVarTEMP (in that order) are searched also, after vVarGROFF_TMPDIR and vVarTMPDIR Otherwise, temporary files will be created in /tmp. The refer(1), groffer(1), gr(1), and grops(1) commands use temporary files.
- vVarGROFF_TYPESETTER
- Preset the default device. If this is not set the ps device is used as default. This device name is overwritten by the option
ortOpt T
FILES
There are some directories in which groff installs all of its data files. Due to different installation habits on different operating systems, their locations are not absolutely fixed, but their function is clearly defined and coincides on all systems.groff Macro Directory
This contains all information related to macro packages. Note that more than a single directory is searched for those files as documented in groff_tmac(5). For the groff installation corresponding to this document, it is located at /usr/share/groff/1.19.2/tmac. The following files contained in the groff macro directory have a special meaning:- troffrc
- Initialization file for troff. This is interpreted by troff before reading the macro sets and any input.
- troffrc-end
- Final startup file for troff, it is parsed after all macro sets have been read.
- name.tmac
- tmac.name
- Macro file for macro package name.
groff Font Directory
This contains all information related to output devices. Note that more than a single directory is searched for those files; see troff(1). For the groff installation corresponding to this document, it is located at /usr/share/groff/1.19.2/font. The following files contained in the groff font directory have a special meaning:- devname/DESC
- Device description file for device name, see groff_font(5).
- devname/F
- Font file for font F of device name.
EXAMPLES
The following example illustrates the power of the groff program as a wrapper around troff. To process a roff file using the preprocessors tbl and pic and the me macro set, classical troff had to be called byellCommand pic foo.me | tbl | troff @-]me @-]Tlatin1 | grotty
Using groff, this pipe can be shortened to the equivalent commandellCommand groff @-]p @-]t @-]me @-]T latin1 foo.me
An even easier way to call this is to use grog(1) to guess the preprocessor and macro options and execute the generated command (by using backquotes to specify shell command substitution)ellCommand `grog @-]Tlatin1 foo.me`
The simplest way is to view the contents in an automated way by callingellCommand groffer foo.me
BUGS
On EBCDIC hosts (e.g. OS/390 Unix), output devices ascii and latin1 aren't available. Similarly, output for EBCDIC code page cp1047 is not available on ASCII based operating systems. Report bugs to bug-groff@gnu.org. Include a complete, self-contained example that will allow the bug to be reproduced, and say which version of groff you are using.AVAILABILITY
Information on how to get groff and related information is available at the The most recent released version of groff is available for anonymous ftp at the Three groff mailing lists are available:- for reporting bugs,
- for general discussion of groff,
- a read-only list showing logs of commitments to the CVS repository. Details on CVS access and much more can be found in the file README at the top directory of the groff source package. There is a free implementation of the grap preprocessor, written by The actual version can be found at the This is the only grap version supported by groff.
AUTHORS
Copyright © 1989, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This document is distributed under the terms of the FDL (GNU Free Documentation License) version 1.1 or later. You should have received a copy of the FDL on your system, it is also available on-line at the This document is based on the original groff man page written by It was rewritten, enhanced, and put under the FDL license by m[blue]Bernd Warkenm[]. It is maintained by groff is a GNU free software project. All parts of the groff package are protected by GNU copyleft licenses. The software files are distributed under the terms of the GNU General Public License (GPL), while the documentation files mostly use the GNU Free Documentation License (FDL).SEE ALSO
The groff info file contains all information on the groff system within a single document. Beneath the detailed documentation of all aspects, it provides examples and background information. See info(1) on how to read it. Due to its complex structure, the groff system has many man pages. They can be read with man(1) or groffer(1).- Introduction, history and further readings:
- roff(7).
- Viewer for groff files:
- groffer(1), gxditview(1), xditview(1x).
- Wrapper programs for formatters:
- groff(1), grog(1).
- Roff preprocessors:
- eqn(1), grn(1), pic(1), refer(1), soelim(1), tbl(1), grap(1).
- Roff language with the groff extensions:
- groff(7), groff_char(7), groff_diff(7), groff_font(5).
- Roff formatter programs:
- nroff(1), troff(1), ditroff(7).
- The
- intermediate output language: groff_out(7).
- Postprocessors for the output devices:
- grodvi(1), gr(1), grolbp(1), grolj4(1), lj4_font(5), grops(1), grotty(1).
- Groff macro packages and macro-specific utilities:
- groff_tmac(5), groff_man(7), groff_mdoc(7), groff_me(7), groff_mm(7), groff_mmse(7), groff_mom(7), groff_ms(7), groff_www(7), groff_trace(7), mmroff(7).
- The following utilities are available:
-
addftinfo(1),
afmtodit(1),
eqn2graph(1),
grap2graph(1),
groffer(1),
gxditview(1),
hpftodit(1),
indxbib(1),
lookbib(1),
pfbtops(1),
pic2graph(1),
tfmtodit(1).
Index
- NAME
- SYNOPSIS
- ortOpt[] abcegilpstzCEGNRSUVXZ
- ortOpt[] d cs
- ortOpt[] f fam
- ortOpt[] F dir
- ortOpt[] I dir
- ortOpt[] L arg
- ortOpt[] m name
- ortOpt[] M dir
- ortOpt[] n num
- ortOpt[] o list
- ortOpt[] P arg
- ortOpt[] r cn
- ortOpt[] T dev
- ortOpt[] w name
- ortOpt[] W name
- ortOpt h
- ortOpt v
- ortOpt
- ortOpt
- DESCRIPTION
- OPTIONS
- ortOpt s
- ortOpt L
- ortOpt X .
- ortOpt L
- ortOpt(a minus sign) to
- ortOpt N
- ellCommand groff @-]X @-]P @-]title @-]P 'groff it' I]foo]
- ellCommand groff @-]X @-]Z I]foo] | gxditview @-]title 'groff it' @-]
- ortOpt S
- ortOpt T
- ortOpt S .
- ortOpt v
- ortOpt l
- ortOpt L
- ortOpt X
- ortOpt Tps ,
- ortOpt TX75 ,
- ortOpt TX75-12 ,
- ortOpt TX100 ,
- ortOpt TX100-12 .
- ortOpt Tps
- ortOpt resolution
- ellCommand groff @-]X @-]P@-]resolution @-]P100 @-]man foo.1
- USING GROFF
- ortOpt m .
- ortOpt man
- ortOpt m
- ortOpt mandoc
- ortOpt m
- ortOpt mdoc
- ortOpt m
- ortOpt me
- ortOpt m
- ortOpt mm
- ortOpt m
- ortOpt ms
- ortOpt m
- ortOpt C
- ortOpt T .
- ENVIRONMENT
- ortOpt T .
- FILES
- EXAMPLES
- ellCommand pic foo.me | tbl | troff @-]me @-]Tlatin1 | grotty
- ellCommand groff @-]p @-]t @-]me @-]T latin1 foo.me
- ellCommand `grog @-]Tlatin1 foo.me`
- ellCommand groffer foo.me
- BUGS
- AVAILABILITY
- AUTHORS
- SEE ALSO
This document was created by man2html using the manual pages.
Time: 00:20:52 GMT, November 20, 2008
2. groff.7.man
Manpage of GROFF
GROFF
Section: Environments, Tables, and Troff Macros (7)Updated: 16 February 2005
Index Return to Main Contents
NAME
groff - a short reference for the GNU roff languageDESCRIPTION
The name groff stands for GNU roff and is the free implementation of the roff type-setting system. See roff(7) for a survey and the background of the groff system. This document gives only short descriptions of the predefined roff language elements as used in groff. Both the classical features and the groff extensions are provided. Historically, the roff language was called troff. groff is compatible with the classical system and provides proper extensions. So in GNU, the terms roff, troff, and groff language could be used as synonyms. However troff slightly tends to refer more to the classical aspects, whereas groff emphasizes the GNU extensions, and roff is the general term for the language. This file is only a short version of the complete documentation that is found in the groff info(1) file, which contains more detailed, actual, and concise information. The general syntax for writing groff documents is relatively easy, but writing extensions to the roff language can be a bit harder. The roff language is line-oriented. There are only two kinds of lines, control lines and text lines. The control lines start with a control character, by default a period @m] "@s]R]" or a single quote @m] "@s]R]" all other lines are text lines. Control lines represent commands, optionally with arguments. They have the following syntax. The leading control character can be followed by a command name; arguments, if any, are separated by blanks from the command name and among themselves, for example,- 1.
- Printable backslashes must be denoted as To be more precise, represents the current escape character. To get a backslash glyph, use or
- 2.
- Double all backslashes.
- 3.
- Begin all text lines with the special non-spacing character This does not produce the most efficient code, but it should work as a first measure. For better strategies, see the groff info file and groff_tmac(5). Reading roff source files is easier, just reduce all double backslashes to a single one in all macro definitions.
GROFF ELEMENTS
The roff language elements add formatting information to a text file. The fundamental elements are predefined commands and variables that make roff a full-blown programming language. There are two kinds of roff commands, possibly with arguments. Requests are written on a line of their own starting with a dot @m] "@s]R]" or a @m] "@s]R]" whereas Escape sequences are in-line functions and in-word formatting elements starting with a backslash @m] "@s]R]" The user can define her own formatting commands using the request. These commands are called macros, but they are used exactly like requests. Macro packages are pre-defined sets of macros written in the groff language. A user's possibilities to create escape sequences herself is very limited, only special characters can be mapped. The groff language provides several kinds of variables with different interfaces. There are pre-defined variables, but the user can define her own variables as well. String variables store character sequences. They are set with the request and retrieved by the escape sequences. Strings can have variables. Register variables can store numerical values, numbers with a scale unit, and occasionally string-like objects. They are set with the request and retrieved by the escape sequences. Environments allow the user to temporarily store global formatting parameters like line length, font size, etc. for later reuse. This is done by the request. Fonts are identified either by a name or by an internal number. The current font is chosen by the request or by the escape sequences. Each device has special fonts, but the following fonts are available for all devices. R is the standard font Roman. B is its bold counterpart. The italic font is called I and is available everywhere, but on text devices it is displayed as an underlined Roman font. For the graphical output devices, there exist constant-width pendants of these fonts, CR, CI, and CB. On text devices, all characters have a constant width anyway. Moreover, there are some advanced roff elements. A diversion stores information into a macro for later usage. A trap is a positional condition like a certain number of lines from page top or in a diversion or in the input. Some action can be prescribed to be run automatically when the condition is met. More detailed information and examples can be found in the groff info file.CONTROL CHARACTERS
There is a small set of characters that have a special controlling task in certain conditions.- @m] "@s]R]"
- A dot is only special at the beginning of a line or after the condition in the requests and There it is the control character that introduces a request (or macro). The special behavior can be delayed by using the escape. By using the request, the control character can be set to a different character, making the dot @m] "@s]R]" a non-special character.
- In all other positions, it just means a dot character. In text paragraphs, it is advantageous to start each sentence at a line of its own.
- @m] "@s]R]"
- The single quote has two controlling tasks. At the beginning of a line and in the conditional requests it is the non-breaking control character. That means that it introduces a request like the dot, but with the additional property that this request doesn't cause a linebreak. By using the request, the non-break control character can be set to a different character.
- As a second task, it is the most commonly used argument separator in some functional escape sequences (but any pair of characters not part of the argument will work). In all other positions, it denotes the single quote or apostrophe character. Groff provides a printable representation with the escape sequence.
- @m] "@s]R]"
- The double quote is used to enclose arguments in requests, macros, and strings. In the and requests, a leading double quote in the argument will be stripped off, making everything else afterwards the string to be defined (enabling leading whitespace). The escaped double quote introduces a comment. Otherwise, it is not special. Groff provides a printable representation with the escape sequence.
- @m] "@s]R]"
- The backslash usually introduces an escape sequence (this can be changed with the request). A printed version of the escape character is the escape; a backslash glyph can be obtained by
- @m] "@s]R]"
- The open parenthesis is only special in escape sequences when introducing an escape name or argument consisting of exactly two characters. In groff, this behavior can be replaced by the CB][]] construct.
- @m] "@s]R]"
- The opening bracket is only special in groff escape sequences; there it is used to introduce a long escape name or long escape argument. Otherwise, it is non-special, e.g. in macro calls.
- @m] "@s]R]"
- The closing bracket is only special in groff escape sequences; there it terminates a long escape name or long escape argument. Otherwise, it is non-special.
- CI]space]
- Space characters are only functional characters. They separate the arguments in requests, macros, and strings, and the words in text lines. They are subject to groff's horizontal spacing calculations. To get a defined space width, escape sequences like @m] "@s]R]" (this is the escape character followed by a space), or should be used.
- CI]newline]
- In text paragraphs, newlines mostly behave like space characters. Continuation lines can be specified by an escaped newline, i.e., by specifying a backslash @m] "@s]R]" as the last character of a line.
- CI]tab]
- If a tab character occurs during text the interpreter makes a horizontal jump to the next pre-defined tab position. There is a sophisticated interface for handling tab positions.
NUMERICAL EXPRESSIONS
A numerical value is a signed or unsigned integer or float with or without an appended scaling indicator. A scaling indicator is a one-character abbreviation for a unit of measurement. A number followed by a scaling indicator signifies a size value. By default, numerical values do not have a scaling indicator, i.e., they are normal numbers. The roff language defines the following scaling indicators.-
- c
- Centimeter
- i
- Inch
- P
- Pica [eq] 1/6 inch
- p
- Point [eq] 1/72 inch
- m
- Em [eq] R]the font size in points (width of letter `CR]mR]')
- M
- 100th R]of an CR]Em
- n
- En [eq] Em/2
- u
- Basic unit for actual output device
- v
- Vertical line space in basic units scaled point [eq] 1/CI]sizescaleR] of a point (defined in font I]DESC] file)
- f
- Scale by 65536.
-
- +
- Addition
- -
- Subtraction
- *
- Multiplication
- /
- Division
- %
- Modulo
- =
- Equals
- ==
- Equals
- <
- Less than
- >
- Greater than
- <=
- Less or equal
- >=
- Greater or equal
- &
- Logical and
- :
- Logical or
- !
- Logical not
- (
- Grouping of expressions
- )
- Close current grouping
-
- @m] "@s]R]"
- The maximum of e1 and e2.
- @m] "@s]R]"
- The minimum of e1 and e2.
- @m] "@s]R]"
- Evaluate e using c as the default scaling indicator.
CONDITIONS
Conditions occur in tests raised by the and the requests. The following table characterizes the different types of conditions.-
- N
- A numerical expression N yields true if its value is greater than~0.
- !N
- True if the value of I is~0.
- 's1's2'
- True if string~s1 is identical to string~s2.
- !'s1's2'
- True if string~s1 is not identical to string~s2.
- cch
- True if there is a character~ch available.
- dname
- True if there is a string, macro, diversion, or request called name.
- e
- Current page number is even.
- o
- Current page number is odd.
- mname
- True if there is a color called name.
- n
- Formatter is nroff.
- rreg
- True if there is a register named reg.
- t
- Formatter is troff.
- Ffont
- True if there exists a font named font.
- Sstyle
- True if a style named style has been registered.
REQUESTS
This section provides a short reference for the predefined requests. In groff, request and macro names can be arbitrarily long. No bracketing or marking of long names is needed. Most requests take one or more arguments. The arguments are separated by space characters (no tabs!); there is no inherent limit for their length or number. An argument can be enclosed by a pair of double quotes. This is very handy if an argument contains space characters, e.g., [dq]arg with space[dq] denotes a single argument. Some requests have optional arguments with a different behaviour. Not all of these details are outlined here. Refer to the groff info file and groff_diff(7) for all details. In the following request specifications, most argument names were chosen to be descriptive. Only the following denotations need clarification.-
- c
- denotes a single character.
- font
- a font either specified as a font name or a font number.
- anything
- all characters up to the end of the line or within and
- n
- is a numerical expression that evaluates to an integer value.
- N
- is an arbitrary numerical expression, signed or unsigned.
- [+-]N
- has three meanings depending on its sign, described below.
Request Short Reference
Empty line, ignored. Useful for structuring documents. Complete line is a comment. Print string on standard error, exit program. Begin line adjustment for output lines in current adjust mode. Start line adjustment in mode c (CI]c]CR][eq]l,r,b,n]). Assign format c to register (CI]c]CR][eq]l,i,I,a,A]). Create alias name for register. Create alias name for request, string, macro, or diversion object. Append to macro until .. is encountered. Append to macro until is called. Same as but with compatibility mode switched off during macro expansion. Same as but with compatibility mode switched off during macro expansion. Append to a macro whose name is contained in the string register macro until .. is encountered. Append to a macro indirectly. macro and end are string registers whose contents are interpolated for the macro name and the end macro, respectively. Same as but with compatibility mode switched off during macro expansion. Same as but with compatibility mode switched off during macro expansion. Append anything to stringvar. Same as but with compatibility mode switched off during string expansion. Unformat ASCII characters, spaces, and some escape sequences in diversion. Print a backtrace of the input on stderr. Embolden font by N-1 units. Embolden Special Font S when current font is font. Unset the blank line macro. Set the blank line macro to macro. End current diversion. Divert to macro, omitting a partially filled line. End current diversion. Divert and append to macro, omitting a partially filled line. Eject current page and begin new page. Eject current page; next page number [+-]N. Line break. Break and spread output line. Same as Break out of a while loop. Reset no-break control character to @m] "@s]R]" Set no-break control character to c. Reset control character to @m] "@s]R]" Set control character to c. Center the next input line. Center following N input lines. Copy contents of file filename unprocessed to stdout or to the diversion. Treat characters c1, c2, ... according to mode number. Change trap location to N . Define character c as string anything. Chop the last character off macro, string, or diversion object. Close the stream. Enable colors. If N is zero disable colors, otherwise enable them. Map glyph name from to glyph name to while constructing a composite glyph name. Finish the current iteration of a while loop. Enable compatibility mode. If N is zero disable compatibility mode, otherwise enable it. Set constant character width mode for font to N/36 ems with em M. Continuous underline in nroff, like in troff. End current diversion. Divert and append to macro. Define or redefine macro until .. is encountered. Define or redefine macro until is called. Same as but with compatibility mode switched off during macro expansion. Same as but with compatibility mode switched off during macro expansion. Define or redefine a color with name color. scheme can be rgb, cym, cymk, gray, or grey. component can be single components specified as fractions in the range 0 to 1 (default scaling indicator~ as a string of two-digit hexadecimal color components with a leading #, or as a string of four-digit hexadecimal components with two leading #. The color default can't be redefined. Define or redefine a macro whose name is contained in the string register macro until .. is encountered. Define or redefine a macro indirectly. macro and end are string registers whose contents are interpolated for the macro name and the end macro, respectively. Same as but with compatibility mode switched off during macro expansion. Same as but with compatibility mode switched off during macro expansion. End current diversion. Divert to macro . Interpret with compatibility mode disabled. Set stringvar to anything. Same as but with compatibility mode switched off during string expansion. Set diversion trap to position N (default scaling indicator~ Reset escape character to @m] "@s]R]" Set escape character to c. Restore escape character saved with Save current escape character. Else part for if-else ( request. The macro will be run after the end of input. Turn off escape character mechanism. Switch to previous environment. Push down environment number or name env and switch to it. Copy the contents of environment env to the current environment. No pushing or popping. Exit from roff processing. Return to previous font family. Set the current font family to name. Disable field mechanism. Set field delimiter to a and pad character to space. Set field delimiter to a and pad character to b. Define fallback character c as string anything. Set fill color to previous fill color. Set fill color to c. Fill output lines. Flush output buffer. Mount font on position n. Mount font with long external name to short internal name on position n. Define fallback character c for font f as string anything. Reset list of special fonts for font to be empty. When the current font is font, then the fonts s1, s2, ... will be special. Return to previous font. Same as or Change to font name or number font; same as escape sequence. Translate font1 to font2. Set glyph color to previous glyph color. Set glyph color to c. Remove additional hyphenation indicator character. Set up additional hyphenation indicator character~c. Set the hyphenation code of character c1 to code1, that of c2 to code2, etc. Set the current hyphenation language to lang. Set the maximum number of consecutive hyphenated lines to n. Read hyphenation patterns from file. Append hyphenation patterns from file. Set input mapping for List of words with exceptional hyphenation. Switch to hyphenation mode N. Set the hyphenation margin to n (default scaling indicator~ Set the hyphenation space to n. If cond then anything else goto If cond then anything; otherwise do nothing. Ignore text until .. is encountered. Ignore text until Change to previous indent value. Change indent according to [+-]N (default scaling indicator~ Set an input-line count trap for the next N lines. Same as but count lines interrupted with as one line. Enable pairwise kerning. If n is zero, disable pairwise kerning, otherwise enable it. Remove leader repetition character. Set leader repetition character to~c. Write the length of the string anything in register. Enable line-tabs mode (i.e., calculate tab positions relative to output line). If n is zero, disable line-tabs mode, otherwise enable it. Set input line number to N. Set input line number to N and filename to file. Ligature mode on if N>0. Change to previous line length. Set line length according to [+-]N (default size default scaling indicator~ Change to the previous value of additional intra-line skip. Set additional intra-line skip value to N, i.e., N-1 blank lines are inserted after each text output line. Length of title (default scaling indicator~ Margin character off. Print character c after each text line at actual distance from right margin. Set margin character to c and distance to N from right margin (default scaling indicator~ Mark current vertical position in register. The same as the .so request except that file is searched in the tmac directories. No output-line adjusting. Need a one-line vertical space. Need N vertical space (default scaling indicator~ No filling or adjusting of output-lines. No hyphenation. Number mode off. In line number mode, set number, multiple, spacing, and indent. Do not number next line. Do not number next N lines. Always execute anything. Define or modify register using [+-]N with auto-increment M. Make the built-in condition n true and t false. Turn no-space mode on. Immediately jump to end of current file. Next file. Open for writing and associate the stream named with it. Like but append to it. Output vertical distance that was saved by the request. Emit string directly to intermediate output, allowing leading whitespace if string starts with @m] "@s]R]" (which will be stripped off). Reset page number character to~ @m] "@s]R]" Page number character. Pipe output to program (nroff only). Set page length to default The current page length is stored in Change page length to [+-]N (default scaling indicator~ Print macro names and sizes (number of blocks of 128 bytes). Print only total of sizes of macros (number of 128 bytes blocks). Next page number N. Print the names and contents of all currently defined number registers on stderr. Change to previous page offset. The current page offset is available in Page offset N. Return to previous point-size. Point size; same as Get the bounding box of a PostScript image filename. This behaves like the request except that input comes from the standard output of command. Print the names and positions of all traps (not including input line traps and diversion traps) on stderr. Change to previous post-vertical line spacing. Change post-vertical line spacing according to [+-]N (default scaling indicator~ Remove the definitions of characters c1, c2, ... Read insertion. Return from a macro. Return twice, namely from the macro at the current level and from the macro one level higher. Remove the definitions of characters c1, c2, ... for font f. Right justify the next n input lines. Remove request, macro, or string name. Rename request, macro, or string old to new. Rename register reg1 to reg2. Remove register. Restore spacing; turn no-space mode off. Return (upward only) to marked vertical place (default scaling indicator~ Define global fallback character c as string anything. Reset soft hyphen character to Set the soft hyphen character to c. In a macro, shift the arguments by n~positions. Set available font sizes similar to the sizes command in a DESC file. Include source file. Skip one line vertically. Space vertical distance N up or down according to sign of N (default scaling indicator~ Reset global list of special fonts to be empty. Fonts s1, s2, etc. are special and will be searched for characters not in the current font. Toggle the spread warning on and off without changing its value. Emit a warning if each space in an output line is widened by limit or more (default scaling indicator~ Space-character size set to N/12 of the spacewidth in the current font. Space-character size set to N/12 and sentence space size set to M/12 of the spacewidth in the current font (CR][eq]1/3 em]). Associate style with font position n. Replace the string named xx with the substring defined by the indices n1 and n2. Save of vertical space. Save the vertical distance N for later output with request. Execute program command-line. Set tabs after every position that is a multiple of N (default scaling indicator~ Set tabs at positions n1, n2, nn, then set tabs at nn+r1, nn+r2, nn+rn, then at nn+rn+r1, nn+rn+r2, nn+rn+rn, and so on. Remove tab repition character. Set tab repetition character to~c. Temporary indent next line (default scaling indicator~ Enable track kerning for font. Three-part title. Print anything on terminal (UNIX standard message output). Print anything on terminal (UNIX standard message output), allowing leading whitespace if anything starts with @m] "@s]R]" (which will be stripped off). Similar to without emitting a final newline. Translate a to b, c to d, etc. on output. Transparently output the contents of file filename. This is the same as the request except that the asciify request will use the character code (if any) before the character translation. This is the same as the request except that the translations do not apply to text that is transparently throughput into a diversion with Make the built-in condition t true and n false. Underline font set to font (to be switched to by Underline (italicize in troff) N input lines. Unformat space characters and tabs, preserving font information in diversion. Enable vertical position traps if n is non-zero, disable them otherwise. Change to previous vertical base line spacing. Set vertical base line spacing according to [+-]N (default scaling indicator~ Default value is Set warnings code to n. Set scaling indicator used in warnings to si. Remove (first) trap at position N. Set location trap; negative means from page bottom. While condition cond is true, accept anything as input. Write anything to the stream named stream. Similar to without emitting a final newline. Write contents of macro or string xx to the stream named stream. Besides these standard groff requests, there might be further macro calls. They can originate from a macro package (see roff(7) for an overview) or from a preprocessor. Preprocessor macros are easy to be recognized. They enclose their code into a pair of characteristic macros.
| |||||||||||||||||||||||||||
