Buy GNU books!
As the GNU roff processor groff(@MAN1EXT@) is a wrapper program around troff that automatically calls a postprocessor, this output does not show up normally. This is why it is called intermediate within the groff system. The groff program provides the option -Z to inhibit postprocessing, such that the produced intermediate output is sent to standard output just like calling troff manually.
In this document, the term troff output describes what is output by the GNU troff program, while intermediate output refers to the language that is accepted by the parser that prepares this output for the postprocessors. This parser is smarter on whitespace and implements obsolete elements for compatibility, otherwise both formats are the same. The pre-groff roff versions are denoted as classical troff.
The main purpose of the intermediate output concept is to facilitate the development of postprocessors by providing a common programming interface for all devices. It has a language of its own that is completely different from the groff(@MAN7EXT@) language. While the groff language is a high-level programming language for text processing, the intermediate output language is a kind of low-level assembler language by specifying all positions on the page for writing and drawing.
The intermediate output produced by groff is fairly readable, while classical troff output was hard to understand because of strange habits that are still supported, but not used any longer by GNU troff.
Any sequence of space or tab characters is treated as a single syntactical space. It separates commands and arguments, but is only required when there would occur a clashing between the command code and the arguments without the space. Most often, this happens when variable length command names, arguments, argument lists, or command clusters meet. Commands and arguments with a known, fixed length need not be separated by syntactical space.
A line break is a syntactical element, too. Every command argument can be followed by whitespace, a comment, or a newline character. Thus a syntactical line break is defined to consist of optional syntactical space that is optionally followed by a comment, and a newline character.
The normal commands, those for positioning and text, consist of a single letter taking a fixed number of arguments. For historical reasons, the parser allows to stack such commands on the same line, but fortunately, in groff intermediate output, every command with at least one argument is followed by a line break, thus providing excellent readability.
The other commands [em] those for drawing and device controlling [em] have a more complicated structure; some recognize long command names, and some take a variable number of arguments. So all D and x commands were designed to request a syntactical line break after their last argument. Only one command, `x X' has an argument that can stretch over several lines, all other commands must have all of their arguments on the same line as the command, i.e. the arguments may not be splitted by a line break.
Empty lines, i.e. lines containing only space and/or a comment, can occur everywhere. They are just ignored.
Note that single characters can have the eighth bit set, as can the names of fonts and special characters. The names of characters and fonts can be of arbitrary length. A character that is to be printed will always be in the current font.
A string argument is always terminated by the next whitespace character (space, tab, or newline); an embedded # character is regarded as part of the argument, not as the beginning of a comment command. An integer argument is already terminated by the next non-digit character, which then is regarded as the first character of the next argument or command.
The task of the prologue is to set the general device parameters using three exactly specified commands. The groff prologue is guaranteed to consist of the following three lines (in that order):
x res n h v
with the arguments set as outlined in the section Device Control Commands. But the parser for the intermediate output format is able to swallow additional whitespace and comments as well.
The body is the main section for processing the document data. Syntactically, it is a sequence of any commands different from the ones used in the prologue. Processing is terminated as soon as the first x stop command is encountered; the last line of any groff intermediate output always contains such a command.
Semantically, the body is page oriented. A new page is started by a p command. Positioning, writing, and drawing commands are always done within the current page, so they cannot occur before the first p command. Absolute positioning (by the H and V commands) is done relative to the current page, all other positioning is done relative to the current location within this page.
This command is the only possibility for commenting in the intermediate output. Each comment can be preceded by arbitrary syntactical space; every command can be terminated by a comment.
troff output follows the classical spacing rules (no space between command and subcommand, all arguments are preceded by a single space character), but the parser allows optional space between the command letters and makes the space before the first argument optional. As usual, each space can be any sequence of tab and space characters.
Some graphics commands can take a variable number of arguments. In this case, they are integers representing a size measured in basic units The arguments called stand for horizontal distances where positive means right, negative left. The arguments called stand for vertical distances where positive means down, negative up. All these distances are offsets relative to the current location.
Unless indicated otherwise, each graphics command directly corresponds to a similar groff [[@backslash]D escape sequence; see groff(@MAN7EXT@).
Unknown D commands are assumed to be device-specific. Its arguments are parsed as strings; the whole information is then sent to the postprocessor.
In the following command reference, the syntax element [la]line_break[ra] means a syntactical line break as defined in section Separation. Draw B-spline from current position to offset then to offset if given, etc. up to This command takes a variable number of argument pairs; the current position is moved to the terminal point of the drawn curve. Draw arc from current position to with center at then move the current position to the final point of the arc. Draw a solid circle using the current fill color with diameter (integer in basic units with leftmost point at the current position; then move the current position to the rightmost point of the circle. An optional second integer argument is ignored (this allows to the formatter to generate an even number of arguments). This command is a groff extension. Draw circle line with diameter (integer in basic units with leftmost point at the current position; then move the current position to the rightmost point of the circle. Draw a solid ellipse in the current fill color with a horizontal diameter of and a vertical diameter of (both integers in basic units with the leftmost point at the current position; then move to the rightmost point of the ellipse. This command is a groff extension. Draw an outlined ellipse with a horizontal diameter of and a vertical diameter of (both integers in basic units with the leftmost point at current position; then move to the rightmost point of the ellipse. Set fill color for solid drawing objects using different color schemes; the analoguous command for setting the color of text, line graphics, and the outline of graphic objects is m. The color components are specified as integer arguments between 0 and [@maxcolor]. The number of color components and their meaning vary for the different color schemes. These commands are generated by the groff escape sequences [[@backslash]D'F ...' and [[@backslash]M (with no other corresponding graphics commands). No position changing. This command is a groff extension.
No position changing. This command is a groff extension.
The subcommand is basically a single letter, but to increase readability, it can be written as a word, i.e. an arbitrary sequence of characters terminated by the next tab, space, or newline character. All characters of the subcommand word but the first are simply ignored. For example, troff outputs the initialization command x i as x init and the resolution command x r as x res. But writings like x i_like_groff and x roff_is_groff resp. are accepted as well to mean the same commands.
In the following, the syntax element [la]line_break[ra] means a syntactical line break as defined in section Separation. Use as the intended name for the current file in error reports. This is useful for remembering the original file name when groff uses an internal piping mechanism. The input file is not changed by this command. This command is a groff extension. Mount font position (a non-negative integer) with font named (a text word), cf. groff_font(@MAN5EXT@). Set character height to (a positive integer in scaled points Classical troff used the unit points (instead; see section COMPATIBILITY. Initialize device. This is the third command of the prologue. Parsed but ignored. The classical documentation reads pause device, can be restarted. Resolution is while is the minimal horizontal motion, and the minimal vertical motion possible with this device; all arguments are positive integers in basic units per inch. This is the second command of the prologue. Set slant to (an integer in basic units Terminates the processing of the current file; issued as the last command of any intermediate troff output. Generate trailer information, if any. In groff, this is actually just ignored. Set name of device to word a sequence of characters ended by the next whitespace character. The possible device names coincide with those from the groff -T option. This is the first command of the prologue. Configure underlining of spaces. If is 1, start underlining of spaces; if is 0, stop underlining of spaces. This is needed for the cu request in nroff mode and is ignored otherwise. This command is a groff extension. Send string uninterpreted to the device. If the line following this command starts with a + character this line is interpreted as a continuation line in the following sense. The + is ignored, but a newline character is sent instead to the device, the rest of the line is sent uninterpreted. The same applies to all following lines until the first character of a line is not a + character. This command is generated by the groff escape sequence [[@backslash]X. The line-continuing feature is a groff extension.
In groff, arbitrary syntactical space around and within this command is allowed to be added. Only when a preceding command on the same line ends with an argument of variable length a separating space is obligatory. In classical troff, large clusters of these and other commands were used, mostly without spaces; this made such output almost unreadable.
For modern high-resolution devices, this command does not make sense because the width of the characters can become much larger than two decimal digits. In groff, this is only used for the devices X75, X75-12, X100, and X100-12. For other devices, the commands t and u provide a better functionality.
There is a library function that parses the intermediate output and sends the information obtained to the device via methods of a class with a common interface for each device. So a groff postprocessor must only redefine the methods of this class. For details, see the reference in section FILES.
x T ps
x res 72000 1 1
x font 5 TR
This output can be fed into the postprocessor grops(@MAN1EXT@) to get its representation as a PostScript file. Low-resolution device latin1
This is similar to the high-resolution device except that the positioning is done at a minor scale. Some comments (lines starting with #) were added for clarification; they were not generated by the formatter.
x T latin1
x res 240 24 40
# begin a new page
# font setup
x font 1 R
# initial positioning on the page
# write text `hell'
# inform about a space, and do it by a horizontal jump
# write text `world'
# announce line break, but do nothing because ...
# ... the end of the document has been reached
This output can be fed into the postprocessor grotty(@MAN1EXT@) to get a formatted text document. Classical style output
As a computer monitor has a very low resolution compared to modern printers the intermediate output for the X devices can use the jump-and-write command with its 2-digit displacements.
x T X100
x res 100 1 1
x font 5 TR
# write text with old-style jump-and-write command
This output can be fed into the postprocessor xditview(1x) or gxditview(@MAN1EXT@) for displaying in X.
Due to the obsolete jump-and-write command, the text clusters in the classical output are almost unreadable.
The position after a graphic object has been drawn is at its end; for circles and ellipses, the end is at the right side.
From this, the positionings specified for the drawing commands above follow quite naturally.
The differences between groff and classical troff are documented in groff_diff(@MAN7EXT@).
For more details, see man(1).
For a treatment of all aspects of the groff system within a single document, see the groff info file. It can be read within the integrated help systems, within emacs(1) or from the shell prompt by
The classical troff output language is described in two AT&T Bell Labs CSTR documents available on-line at "Bell Labs CSTR site" .
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 with this package; it is also available on-line at the
This document is part of groff, the GNU roff distribution. It is based on a former version - published under the GPL - that described only parts of the groff extensions of the output language. It has been rewritten 2002 by and is maintained by
|webmaster donations bookstore||delorie software privacy|
|Copyright © 2003 by The Free Software Foundation||Updated Jun 2003|