Formatting is specified by embedding brief codes (called requests ) into the text source file. These codes act as directives to nroff and troff when they run. For example, to center a line of text, type the following code in a file:
.ce This text should be centered.
When formatted, the output appears centered:
This text should be centered.
There are two types of formatting codes:
Requests, also known as primitives , allow direct control of almost any feature of page layout and formatting. Macros combine requests to create a total effect. In a sense, requests are like atoms, and macros are like molecules.
All nroff /troff requests are two-letter lowercase names. Macros are usually upper- or mixed-case names.
The most commonly used requests are:
.ad .ds .ll .nr .sp .br .fi .na .po .ta .bp .ft .ne .ps .ti .ce .in .nf .so .vs .de .ls
For example, a simple macro could be written as follows:
. \" Ps macro - show literal text display .de Ps \" Define a macro named "Ps" .sp .5 \" Space down half a line .in 1i \" Indent one inch .ta 10n +10n \" Set new tabstops .ps 8 \" Use 8-point type .vs 10 \" Use 10-point vertical spacing .ft CW \" Use constant width font .br \" Break line (.ne begins count on next line) .ne 3 \" Keep 3 lines together .nf \" No-fill mode (output lines as is) .. \" End macro definition
With some requests, the numeric argument can be followed by a scale indicator that specifies a unit of measurement. The valid indicators and their meanings are listed in the following table. Note that all measurements are internally converted to basic units (this conversion is shown in the last column). A basic unit is the smallest possible size on the printer device. The device resolution (e.g., 600 dots per inch) determines the size of a basic unit. Also, T specifies the current point size, and R specifies the device resolution.
It is worth noting that all numbers in nroff /troff are stored internally using integers. This applies even to apparently fractional values in commands such as:
which spaces down one-half of the current vertical spacing..sp .5
An "em" is the width of the letter "m" in the current font and point size. An "en" is the width of the letter "n" in the current font and point size. Note that in nroff , an "em" and an "en" are the same -- the width of one character.
You can specify a scale indicator for any of the requests in the following table, except for
A line break occurs when nroff /troff writes the current output line, even if it is not completely filled. Most requests can be interspersed with text without causing a line break in the output. The following requests cause a break:
.bp .ce .fi .in .sp .br .cf .fl .nf .ti
If you need to prevent these requests from causing a break, begin them with the "no break" control character (normally
In addition to requests and macros, which are written on their own separate lines, you may also have formatting controls embedded within your text lines. These typically provide the following capabilities:
Later sections in this chapter describe the predefined special characters, strings and number registers, and all of the escape sequences that are available.