Formatter Command Summary
This appendix is divided into ten subsections, each covering a different facet of the nroff
/troff
formatting system. These sections are:
nrof
/troff
command-line syntaxnroff
/troff
requests- escape sequences
- predefined number registers
- special characters
- the
ms
macro package - the
mm
macro package - the
tbl
preprocessor - the
eqn
preprocessor - the
pic
preprocessor
In the following sections, italics are used for values that you supply. Optional arguments to requests or macros are enclosed in brackets.
▪ nroff/troff
Command-Line Syntax ▪
nroff
[options] [files]
-c name |
Prepend /usr/lib/macros/cmp.n. [dt] .name to files (old versions of nroff only). |
-e |
Space words equally on the line instead of in full multiples of the space character. |
-h |
Use tabs in large spaces. |
-i |
Read standard input after files are processed. |
-k name |
Compact macros and output to [dt] .name (old versions of nroff only). |
-m name |
Prepend /usr/lib/tmac/tmac .name to files. |
-n n |
Number first page n. |
-o list |
Print only pages contained in list. Individual pages in list should be separated by commas; a page range is specified by n–m; n–indicates from page n to the end. |
-q |
Invoke simultaneous input/output of .rd requests. |
-r an |
Set register a to n. |
-s n |
Stop every n pages. |
-T name |
Output is for device type name. Values are shown in Table B-l. (Check your manual for other devices, especially those supported by the mm command.) |
-u n |
Embolden characters by overstriking n times. |
- z |
Throw away output except messages from .tm request. |
troff
Options
troff
[options] [files]
-a |
Send printable ASCII approximation to standard output. otroff sends its output directly to a connected typesetter unless the -t or -a option is specified, in which case it is sent to standard output, ditroff always writes to standard output. |
-b |
Report phototypesetter status (otroff only). |
-c name |
Prepend /usr/lib/raacros/cmp . t. [dt] .name to files (otroff only). |
-f |
Do not stop the phototypesetter when the formatting run is done (otroff only). |
-F dir |
Format output for device name using the font tables in directory dir instead of /usr/lib/font (ditroff only). |
-i |
Read standard input after files. |
-k name |
Compact macros and output to [dt] .name (otroff only). |
-m name |
Prepend /usr/lib/tmac/tmac
.name to files. |
-n n |
Number first page n. |
-o list |
Print only pages contained in list. Individual pages in list should be separated by commas. A page range is specified by n–m; n–indicates from page n to the end. |
-p n |
Print all characters in point size n, but retain motions for sizes specified in document (otroff only). |
-q |
Do not echo . rd requests. |
-r an |
Assign value n to register a. |
-s n |
Stop every n pages. |
-t | Send output to standard output instead of directly to the phototypesetter (otroff only). |
-T name |
Format output for device name using the device description and font width tables in /usr/lib/font/dev name (ditroff only). |
-w |
If the phototypesetter is busy, wait until it is free (otroff only). |
▪ nroff/troff
Requests ▪
▪ Escape Sequences ▪
▪ Predefined Number Registers ▪
Read-Only Registers
.$ |
Number of arguments available at the current macro level. |
.$$ |
Process ID of troff process (ditroff only). |
.A |
Set to 1 in troff , if –a option used; always 1 in nroff . |
.H |
Available horizontal resolution in basic units. |
.T |
In nroff , set to 1 if -T option used; in troff , always 0; in ditroff , you can print the value of -T with the string \ * (.T . |
.V |
Available vertical resolution in basic units. |
.a |
Extra line space most recently utilized using \x'N' . |
.c |
Number of lines read from current input file. |
.d |
Current vertical place in current diversion; equal to nl if no diversion. |
.f |
Current font as physical quadrant (1 to 4 in otroff ; no limit in ditroff ). |
.h |
Text baseline high-water mark on current page or diversion. |
.i |
Current indent. |
.j |
Current adjustment type (0=.adl or .na; 1=.adb; 3=.adb; 3=.adc; 5=.adr ). |
.l |
Current line length. |
.n |
Length of text portion on previous output line. |
.o |
Current page offset. |
.P |
Current page length. |
.s |
Current point size. |
.t |
Distance to the next trap. |
.u |
Equal to 1 in fill mode and 0 in no-fill mode. |
.V |
Current vertical line spacing. |
.w |
Width of previous character. |
.X |
Reserved version-dependent register. |
.y |
Reserved version-dependent register. |
.z |
Name of current diversion. |
Read/Write Registers
▪ Special Characters ▪
On the Standard Fonts
The following special characters are usually found on the standard fonts:
' |
' |
close quote |
' |
' |
open quote |
— |
\(em |
3/4 em dash |
- |
\ |
hyphen |
- |
\ (hy |
hyphen |
- |
\- |
current font minus sign |
• | \ (bu |
bullet |
▪ | \ (sq |
square |
- |
\ (ru |
rule |
1/4 | \ (14 |
1/4 |
1/2 | \ (12 |
1/2 |
3/4 | \ (34 |
3/4 |
fi | \ (fi |
fi ligature |
fl | \ (fl |
fl ligature |
ff | \ (ff |
ff ligature |
ffi | \ (Fi |
ffi ligature |
ffl | \ (Fl |
ffl ligature |
o | \ (de |
degree |
† | \ (dg |
dagger |
' | \ (fm |
foot mark |
¢ | \ (ct |
cent sign |
™ | \ (rg |
registered trademark |
© | \ (co |
copyright |
On the Special Font
The following characters are usually found on the special font except for the uppercase Greek letter names followed by † which are mapped into uppercase English letters in whatever font is mounted on font position one (default is Times Roman).
Miscellaneous Characters
§ | \ (sc |
section |
' | \ (aa |
acute accent |
' | \ (ga |
grave accent |
– | \ (ul |
underrule |
→ | \ (-> |
right arrow |
← | \ (<- |
left arrow |
↑ | \ (ua |
up arrow |
↓ | \ (da |
down arrow |
| | \ (br |
box rule |
‡ | \ (dd |
double dagger |
\ (rh |
right hand | |
\ (lh |
left hand | |
○ | \ (ci |
circle |
Mathematic Symbols
+ | \ (pl |
math plus |
– | \ (mi |
math minus |
= | \ (eq |
math equals |
* | \ (** |
math star |
/ | \ (sl |
slash (matching backslash) |
\ (sr |
square root | |
\ (rn |
root en extender | |
≥ | \ (>= |
greater than or equal to |
≤ | \ (<= |
less than or equal to |
≡ | \(== |
identically equal |
≠ | \(~= |
approx equal |
~ | \ (ap |
approximates |
≠ | \(! = |
not equal |
× | \ (mu |
multiply |
÷ | \ (di |
divide |
± | \ (+- |
plus-minus |
∪ | \ (cu |
cup (union) |
∩ | \ (ca |
cap (intersection) |
\ (sb |
subset of | |
\ (sp |
superset of | |
\ (ib |
improper subset | |
\ (ip |
improper superset | |
∞ | \ (if |
infinity |
\ (pd |
partial derivative | |
▽ | \ (gr |
gradient |
\ (no |
not | |
∫ | \ (is |
integral sign |
∝ | \ (pt |
proportional to |
Ø | \ (es |
empty set |
\ (mo |
member of | |
| | \ (or |
or |
Bracket Building Symbols
\ (It \ (lk \ (lb \ (rt \ (rk \ (rb \ (lc \ (bv \ (lf \ (rc \ (rf |
left top of large curly bracket left center of large curly bracket left bottom of large curly bracket right top of large curly bracket right center of large curly bracket right bottom of large curly bracket left ceiling (top) of large square bracket bold vertical left floor (bottom) of large square bracket right ceiling (top) of large square bracket right floor (bottom) of large square bracket |
Greek Characters
α | \ (*a |
alpha |
β | \ (*b |
beta |
γ | \ (*g |
gamma |
δ | \ (*d |
delta |
ε | \ (*e |
epsilon |
ζ | \ (*z |
Zetat |
η | \ (*y |
eta |
θ | \ *h |
theta |
ι | \ (*i |
iota |
κ | \ (*k |
kappa |
λ | \ (*l |
lambda |
μ | \ (*m |
mu |
ν | \ (*n |
nu |
ξ | \ (*c |
xi |
Ό | \ (*o |
omicron |
π | \ (*p |
pi |
ρ | \ (*r |
rho |
σ | \ (*s |
sigma |
ς | \ (ts |
terminal sigma |
τ | \ (*t |
tau |
υ | \ (*u |
upsilon |
Φ | \ (*f |
phi |
χ | \ (*x |
chi |
ψ | \ (*q |
Psi |
ω | \ (*w |
omega |
Α | \ (*A |
Alpha† |
Β | \ (*B |
Beta† |
Γ | \ (*G |
Gamma |
Δ | \ (*D |
Delta |
Ε | \ (*E |
Epsilon† |
Ζ | \ (*Z |
Zeta† |
Η | \ (*Y |
Eta† |
Θ | \ (*H |
Theta |
Ι | \ (*I |
Iota† |
κ | \ (*K |
Kappa† |
Λ | \ (*L |
Lambda |
Μ | \ (*M |
Mu† |
Ν | \ (*N |
Nu† |
Ξ | \ (*C |
Xi |
Ο | \ (*O |
Omicron† |
Π | \ (*P |
Pi |
Ρ | \ (*R |
Rho† |
Σ | \ (*S |
Sigma |
Τ | \ (*T |
Tau† |
Υ | \ (*U |
Upsilon |
Φ | \ (*F |
Phi |
Χ | \ (*X |
Chi† |
Ψ | \ (*Q |
Psi |
Ω | \ (*W |
Omega |
▪ The ms Macros ▪
Summary of ms Macros
Internal Macros Worth Knowing About
.IZ |
Basic initialization; executed automatically before any text is processed. It is then removed, and cannot be invoked again. |
.RT |
Reset. Invoked by all paragraph macros, plus .RS, .RE, .TS, .TE, .SH, and .NH .Resets various values to defaults stored in number registers listed below. |
.BG |
Prints cover sheet, if any. Also performs some special first page initialization. Invoked once by the very first .RT in a document. |
.NP |
New page. Invoked at the top of each page. Performs various page top resets, and calls .PT . |
.PT |
Page titles. Contains running headers. Can be redefined. Invoked by .NP at \n (HMu from the top of the page. |
.BT |
Bottom titles. Continuous running footers. Invoked by trap at \n (FMu /2u from the bottom of the page. |
.FO |
Footer. The bottom of the text on the page. Invoked by trap at \n (FMu . |
Number Registers Containing Page Layout Defaults
CW |
Column width (default 7/15 of line length). |
FL |
Footnote length (default 11/12 of line length). |
FM |
Bottom margin (default 1 inch). |
GW |
Intercolumn gap width for multiple columns (default 1/15 of line length). |
HM |
Top margin (default 1 inch). |
LL |
Line length (default 6 inches). |
LT |
Title length (default 6 inches). |
PD |
Paragraph spacing (default 0.3 of vertical spacing). |
PI |
Paragraph indent (default 5 ens). |
PO |
Page offset (default 26/27 inches). |
PS |
Point size (default 10 points). |
VS |
Vertical line spacing (default 12 points). |
Predefined and User-Definable Strings
DY |
The current date. |
LH |
Left header, printed by .tl '\\*(LH'\\*CH'\\*(RH' in PT macro. Null unless user-defined. |
CH |
Center header, printed by .tl '\\*(LH'\\*CH'\\*(RH' in PT macro. Null unless user-defined. |
RH |
Right header, printed by .tl '\\*(LH'\\*CH'\\*(RH' in PT macro. Null unless user-defined. |
LF |
Left footer, printed by .tl '\\*(LH'\\*CH'\\(RH' in BT macro. Null unless user-defined. |
CF |
Center footer, printed by .tl '\\*(LH'\\*CH'\\RH' in BT macro. Contains PN by default. |
RF |
Right footer, printed by .tl '\\*(LH'\\*CH'\\RH' in BT macro. Contains PN by default. |
Reserved Macro and String Names
The following macro and string names are used by the ms
package. Avoid using these names for compatibility with the existing macros. An italicized n means that the name contains a numeral (generally the interpolated value of a number register).
The following number register names are used by the ms
package. An italicized n means that the name contains a numeral (generally the interpolated value of another number register).
Note that with the exception of [c
and [o
, none of the number register, macro, or string names contain lowercase letters, so lowercase or mixed case names are a safe bet when you’re writing your own macros.
▪ The mm
Macros ▪
Summary of mm
Macros
Predefined String Names
BU |
Bullet; same as \ (bu . |
Ci |
List of indents for table of contents levels. |
DT |
Current date, unless overridden. Month, day, year (e.g., July 28, 1986). |
EM |
Em dash string (em dash in troff and a double hyphen in nroff ). |
F |
Footnote number generator. |
HF |
Fonts used for each level of heading (1=roman, 2=italic, 3=bold). |
HP |
Point size used for each level of heading. |
Le |
Title set for List Of Equations. |
Lf |
Title set for List Of Figures. |
Lt |
Title set for List Of Tables. |
Lx |
Title set for List Of Exhibits. |
RE |
SCCS Release and Level of mm. |
Rf |
Reference number generator. |
Rp |
Title for references. |
TM |
Trademark string. Places the letters TM one-half line above the text that it follows. |
Number Registers Used in mm
A dagger (†
) next to a register name indicates that the register can only be set from the command line or before the nun macro definitions are read by the formatter. Any register that has a single-character name can be set from the command line.
Other Reserved Macro and String Names
In mm
, the only macro and string names you can safely use are names consisting of a single lowercase letter, or two character names whose first character is a lowercase letter and whose second character is anything but a lowercase letter. Of these, c2
and nP
are already used.
▪ tbl
Command Characters and Words ▪
.TS |
Start table. |
.TE |
End table. |
.TS H |
Used when the table will continue onto more than one page. |
Used with .TH to define a header that will print on every page. |
|
.TH |
With .TS H , ends the header portion of the table. |
.T& |
Continue table after changing format line. |
Options
Options affect the entire table. The options should be separated by commas, and the option line must be terminated by a semicolon.
center |
Center with current margins. |
expand |
Flush with current right and left margins. |
(blank) | Flush with current left margin (default). |
box |
Enclose table in a box. |
doublebox |
Enclose table in two boxes. |
allbox |
Enclose each table entry in a box. |
tab (x) |
Define the tab symbol as x. |
linesize (n) |
Set lines or rules (e.g., from box) to n point type. |
delim (xy) |
Recognize x and y as the eqn delimiters. |
Format
The format line affects the layout of individual columns and rows of the table. Each line contains a key letter for each column of the table. The column entries should be separated by spaces, and the format section must be terminated by a period. Each line of format corresponds to one line of the table, except for the last, which corresponds to all following lines up to the next .T&
, if any.
Key letters
c |
Center. |
l |
Left justify. |
r |
Right justify. |
n |
Align numerical entries. |
a |
Align alphabetic subcolumns. |
s |
Horizontally span previous column entry across this column. |
^ |
Vertically continue entry from previous row down through this row. |
Other choices (must follow a key letter)
b |
Boldface. Must be followed by a space. |
i |
Italics. Must be followed by a space. |
pn |
Point size n. |
t |
Begin any corresponding vertically spanned table entry at the top line of its range. |
e |
Equal width columns. |
w(n) |
Minimum column width. Also used with text blocks, n can be given in any acceptable troff units. |
vn |
Vertical line spacing. Used only with text blocks. |
n |
Amount of separation between columns (default is 3n ). |
| | Single vertical line. Typed between key letters. |
|| | Double vertical line. Typed between key letters. |
- | Single horizontal line. Used in place of a key letter. |
= | Double horizontal line. Used in place of a key letter. |
Data
The data portion includes both the heading and text of the table. Each table entry must be separated by a tab symbol.
.xx |
troff commands may be used (such as .sp # and .ce # ). Do not use macros, unless you know what you’re doing. |
\ | As last character in a line, combine following line with current line (\ is hidden). |
\^ | Vertically spanned table entry. Span table entry immediately above over this row. |
_ or = | As the only character in a line, extend a single or double horizontal line the full width of the table. |
\$_ or \$ = | Extend a single or double horizontal line the full width of the column. |
\_ | Extend a single horizontal line the width of the contents of the column. |
\Rx |
Print x’s as wide as the contents of the column. |
...T{ | Start text block as a table entry. Must be used with w n, column width option. |
...T } |
End text block. |
▪ eqn
Command Characters ▪
.EQ | Start typesetting mathematics |
.EN | End typesetting mathematics |
Character Translations
The following character sequences are recognized and translated as shown.
> = | ≥ | approx |
≈ |
< = | ≤ | nothing |
|
= = | ≡ | cdot |
. |
! = | ≠ | times |
× |
+ − | ± | del |
∇ |
− > | → | grad |
∇ |
< − | ← | ... | ... |
<< | ≪ | , . . . , | , . . . , |
>> | ≫ | sum |
Σ |
inf |
∞ | int |
∫ |
partial |
∂ | prod |
∏ |
half |
½ | union |
⋃ |
prime |
′ | inter |
⋂ |
Digits, parentheses, brackets, punctuation marks, and the following words are converted to roman font when encountered:
sin cos tan sinh cosh tanh arc
max min lin log ln exp
Re Im and if for det
Greek letters can be printed in uppercase or lowercase. To obtain Greek letters, simply spell them out in the case you want:
alpha |
α | sigma |
σ |
beta |
β | tau |
τ |
gamma |
γ | upsilon |
υ |
delta |
δ |
phi |
Φ |
epsilon |
ε | chi |
χ |
zeta |
ζ | psi |
Ψ |
eta |
η | omega |
ω |
theta |
θ | GAMMA |
Γ |
iota |
ι | DELTA |
Δ |
kappa |
κ | THETA |
Θ |
lambda |
λ | LAMBDA |
Λ |
mu |
μ | XI |
Ξ |
nu |
ν | PI |
Π |
xi |
ξ | SIGMA |
Σ |
omicron |
Ο | UPSILON |
Υ |
Pi |
π | PHI |
Φ |
rho |
ρ | PSI |
Ψ |
OMEGA |
Ω |
The following words translate to marks on the tops of characters.
x dot |
x vec |
||
x dotdot |
x dyad |
||
x hat |
x bar |
||
x tilde |
x under |
Words Recognized By eqn
Precedence
If you don’t use braces, eqn
will do operations in the order shown in the following list.
dyad vec under bar tilde hat dot dotdot
fwd back down up
fat roman italic bold size
sub sup sqrt over
from to
These operations group to the left:
over sqrt left right
All others group to the right.
▪ The pic
Preprocessor ▪
In pic
there are often dozens of ways to draw a picture, not only because of the many permissible abbreviations, but because pic
combines the language of geometry with English. You can specify a line, for example, with direction, magnitude, and starting point, yet often achieve the same effect by simply stating, “from there to there.”
Full descriptions of primitive objects in pic
can be ended by starting another line, or by the semicolon character (;). A single primitive description can be continued on the next line, however, by ending the first with a backslash character (\). Comments may be placed on lines beginning with #.
pic
Macros
The following macros are used to delimit pic
input from the body of the source file. Only text within these macros will be processed by pic
.
.PS [h [w]] |
Start pic description, h and w, if specified, are the desired height and width of the picture; the full picture will expand or contract to fill this space. |
.PS <file |
Read contents of file in place of current line. |
.PE |
End pic description. |
.PF |
End pic description and return to vertical position before matching PS . |
Declarations
At the beginning of a pic
description, you may declare a new scale, and declare any number of variables.
pic
assumes you want a 1-to-1 scale, with 1 = one inch. You can declare a different scale, say 1 = one-nth of an inch, by declaring, scale
= n.
pic
takes variable substitutions for numbers used in the description. Instead of specifying, line right
n, you may use a lowercase character as a variable, for example, a
, by declaring at the top of the description:
a = n
You may then write line right a
.
Primitives
Primitives may be followed by relevant options. Options are discussed later in this section.
arc
[cw
] [options] [“text”]A fraction of a circle. (Default = 1/4 of a circle.) The
cw
option specifies a clockwise arc; default is counterclockwise.
arrow
[options] [“text”] [then . . . ]Draw an arrow. Essentially the same as
line
−>.
box
[options] [“text”]Draw a box.
circle
[options] [“text”]Draw a circle.
Draw an ellipse.
line
[options] [“text”] [then . . .]Draw a line.
move
[options] [“text”]A move of position in the drawing. (Essentially, an invisible line.)
spline
[options] [“text”] [then
. . .]A line, with the feature that a “then” results in a gradual (sloped) change in direction.
“text”
Text centered at current point.
Options
Text
Place text within quotation marks. To break the line, break into two (or more) sets of quotation marks. Text always appears centered within the object, unless given one of the following arguments:
l just |
Text appears left justified to the center. |
r just |
Text appears right justified to the center. |
above |
Text appears above the center. |
below |
Text appears below the center. |
Object Blocks
A complex object that is the combination of several primitives (for example, an octagon) can be treated as a single object by declaring it as a block:
Object:[
description
.
.
.
]
Brackets are used as delimiters. Note that the object is declared as a proper noun, hence it should begin with a capital letter.
Macros
The same sequence of commands can be repeated by using macros. The syntax is:
define sequence %
description
.
.
.
%
In this example, we have used the percent sign (%) as the delimiter, but any character that is not in the description may be used.
Macros can take variables, expressed in the definition as “$1” through “$9”. Invoke the macro with the syntax: sequence(value1,value2,...)
Positioning
In a pic
description, the first action will begin at (0,0), unless otherwise specified with coordinates. Thus, the point (0,0) will move down and right on the drawing, as objects are placed above and to the left of the first object.
All points are ultimately translated by the formatter into x- and y-coordinates. You may therefore refer to a specific point in the picture by incrementing or decrementing by coordinates, i.e., 2nd ellipse
- (3,1).
You may refer to the x- and y-coordinates of an object by placing .x
or .y
at the end. For example, last box.x
will refer to the x-coordinate of the most recent box drawn. Some of the physical attributes of the object may also be referred to similarly, as follows:
.x |
X-coordinate of object’s center. |
.y |
Y-coordinate of object’s center. |
.ht |
Height of object. |
.wid |
Width of object. |
.rad |
Radius of object. |
Unless otherwise positioned, each object will begin at the point where the last object left off. If a command (or sequence of commands) is set off by braces ({ }), however, pic
will then return to the point before the first brace.
Positioning between Objects
When referring to a previous object, you must use proper names. This can be done two ways:
By referring to it by order, e.g., 1st box, 3rd box, last box, 2nd last box, etc
.
By declaring it with a name, in initial caps, on its declaration line, e.g., Line1: line 1.5 right from last box.sw
To refer to a point between two objects, or between two points on the same object, you may write: fraction of the way between
first.position and
second.position or (abbreviated) fraction<first.position,second.position>
Corners
When you refer to a previous object, pic will assume that you mean the center of the object, unless you use a corner to specify a particular point on the object. The syntax is:
.corner of object
for example, .sw of last box.
You can also use an abbreviated syntax:
object.corner
for example, last box.sw
.
These corners may be:
n |
North (same as t ) |
s |
South (same as b ) |
e |
East (same as r ) |
w |
West (same as l ) |
ne |
Northeast |
nw |
Northwest |
se |
Southeast |
sw |
Southwest |
t |
Top (same as n ) |
b |
Bottom (same as s ) |
r |
Right (same as e ) |
l |
Left (same as w ) |
start |
Point where drawing of object began |
end |
Point where drawing of object ended |
You may also refer to the upper right, upper left, lower right
, and lower left
of an object.
Numerical Operators
Several operators are functional in pic
. These are:
+ | Addition |
− | Subtraction |
* | Multiplication |
/ | Division |
% | Modulo |
Default Values
arcrad |
0.25 | ellipsewid |
0.75 |
arrowwid |
0.05 | linewid |
0.5 |
arrowht |
0.1 | lineht |
0.5 |
boxwid |
0.75 | movewid |
0.5 |
boxht |
0.5 | moveht |
0.5 |
circlerad |
0.25 | scale |
1 |
dashwid |
0.05 | textht |
0 |
ellipseht |
0.5 | textwid |
0 |
Get UNIX° TEXT PROCESSING now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.