GROFF(7) | Miscellaneous Information Manual | GROFF(7) |
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 or a single quote 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,
For indentation, any number of space or tab characters can be inserted between the leading control character and the command name, but the control character must be on the first position of the line.
Text lines represent the parts that will be printed. They can be modified by escape sequences, which are recognized by a leading backslash These are in-line or even in-word formatting elements or functions. Some of these take arguments separated by single quotes others are regulated by a length encoding introduced by an open parenthesis or enclosed in brackets and
The roff language provides flexible instruments for writing language extension, such as macros. When interpreting macro definitions, the roff system enters a special operating mode, called the copy mode.
The copy mode behavior can be quite tricky, but there are some rules that ensure a safe usage.
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.
There are two kinds of roff commands, possibly with arguments. Requests are written on a line of their own starting with a dot or a whereas Escape sequences are in-line functions and in-word formatting elements starting with a backslash
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 \n 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 \f 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.
The roff language defines the following scaling indicators.
Numerical expressions are combinations of the numerical values defined above with the following arithmetical operators already defined in classical troff.
Moreover, groff added the following operators for numerical expressions:
For details see the groff info file.
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., "arg with space" 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.
If an expression defined as ±N starts with a sign the resulting value of the expression will be added to an already existing value inherent to the related request, e.g. adding to a number register. If the expression starts with a the value of the expression will be subtracted from the request value.
Without a sign, N replaces the existing value directly. To assign a negative number either prepend 0 or enclose the negative number in parentheses.
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.
This is done by enclosing names (escape name and arguments consisting of a variable name) by a pair of brackets [name] and constant arguments (number expressions and characters) by apostrophes (ASCII 0x27) like ’constant’.
There are abbreviations for short names. Two character escape names can be specified by an opening parenthesis like \(xy without a closing counterpart. And all one-character names different from the special characters and can even be specified without a marker in the form \c.
Constant arguments of length 1 can omit the marker apostrophes, too, but there is no two-character analogue.
While 1-character escape sequences are mainly used for in-line functions and system related tasks, the 2-letter names following the \( construct are used for special characters predefined by the roff system. Escapes sequences with names of more than two characters denote user defined named characters (see the $* request).
The escape sequences \e, \., \", \$, \*, \a, \n, \t, \g, and are interpreted in copy mode.
Escape sequences starting with \( or \[ do not represent single character escape sequences, but introduce escape names with two or more characters.
If a backslash is followed by a character that does not constitute a defined escape sequence the backslash is silently ignored and the character maps to itself.
Bullet sign Copyright Cent Double dagger Degree Dagger Printable double quote Em-dash Hyphen Registered sign Printable backslash character Section sign Underline character Identical Larger or equal Less or equal Not equal Right arrow Left arrow Plus-minus sign
Strings share their name space with macros. So strings and macros without arguments are roughly equivalent; it is possible to call a string like a macro and vice-versa, but this often leads to unpredictable results. The following strings are predefined in groff.
Each register is given a name. Arbitrary registers can be defined and set with the request $* register.
The value stored in a register can be retrieved by the escape sequences introduced by \n.
Most useful are predefined registers. In the following the notation name is used to refer to a register called $* to make clear that we speak about registers. Please keep in mind that the decoration is not part of the register name.
The groff system provides a compatibility mode, see groff(1) on how to invoke this.
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 part of groff, the GNU roff distribution. It was written by it is maintained by
February 6, 2006 | Groff Version 1.19.2 |