1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
|
.\" -*- nroff -*-
.ig
roff.7
This file is part of groff, the GNU roff type-setting system.
Copyright (C) 2000 Free Software Foundation, Inc.
written by Bernd Warken <bwarken@mayn.de>
Last update: 17 May 2000
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1 or
any later version published by the Free Software Foundation; with the
Invariant Sections being this .ig-section and AUTHOR, with no
Front-Cover Texts, and with no Back-Cover Texts.
A copy of the Free Documentation License is included as a file called
FDL in the main directory of the groff source package.
..
.
.\" --------------------------------------------------------------------
.\" Setup
.\" --------------------------------------------------------------------
.
.if n \{\
. mso tmac.tty-char
. ftr CR R
. ftr CI I
. ftr CB B
.\}
.
.\" text lines in macro definitions or bracketed sections \{...\}
.de text
. if 1 \&\\$*\&
..
.
.de option
. ds @tmp@ \f(CB\\$1\fP
. shift 1
. text \\*[@tmp@]\\$*
. rm @tmp@
..
.
.de 'char
. ds @tmp@ `\f(CB\\$1\fP'
. shift
. text \\*[@tmp@]\\$*
. rm @tmp@
..
.
.de esc
. ds @tmp@ \f(CB\e\\$1\fP
. shift
. text \\*[@tmp@]\\$*
. rm @tmp@
..
.
.de argname
. ds @tmp@ \f(CI\\$1\fP
. shift 1
. text \\*[@tmp@]\\$*
. rm @tmp@
..
.
.de prefixednumber
. ds @tmp@ \&\\$1\ \f(CR\\$2\fP
. shift 2
. text \\*[@tmp@]\\$*
. rm @tmp@
..
.
.\" --------------------------------------------------------------------
.\" Title
.\" --------------------------------------------------------------------
.TH ROFF @MAN7EXT@ "@MDATE@" "Groff Version @VERSION@"
.SH NAME
roff \- a survey of the roff typesetting system
.\" --------------------------------------------------------------------
.SH DESCRIPTION
.\" --------------------------------------------------------------------
.I roff
is the general name for a set of type-setting programs, known under
names like
.IR troff ,
.IR nroff ,
.IR groff ,
etc.
.LP
The roff type-setting system consists of a formatting language, macro
packages, preprocessors, postprocessors for output devices, user
front-end programs, and conversion tools.
.LP
The most common roff system today is the free software implementation
.I groff
(from `GNU\ roff').
The pre-groff implementations are referred to as `classical' (dating
back as long as 1973).
.LP
.I groff
is backward-compatible to its classical ancestors, but has many
extensions, and is still evolving.
As it is available for almost every computer system it is the de-facto
roff standard today.
.LP
In spite of its age, roff is in wide use today, e.g., the manual pages
on UNIX systems
.RI ( man-pages )
are written in roff.
The roff output for text devices is still unmatched, and its graphical
output has the same quality as the other free type-setting programs and
is better than some of the commercial systems.
.LP
This document gives only an overview and provides pointers to further
documentation.
This document is not maintained and might be out of date. For the real
documentation refer to the groff info file that contains the detailed,
actual and concise reference information.
.\" --------------------------------------------------------------------
.SH "FORMATTING LANGUAGE"
.\" --------------------------------------------------------------------
There are three terms that refer to the language of the
.I roff
system.
The term
.I troff language
is used when the classical aspects of
.I roff
are stressed, the term
.I groff language
includes the GNU extensions, whereas
.I roff language
is the general term.
.LP
The main source of documentation for all aspects of the
.I groff language
is the groff info file. The manual page
.BR groff (@MAN7EXT@)
gives a short description of all predefined language elements.
.LP
Documents using roff are normal text files decorated by formatting
elements.
It is very easy to write high-quality documents by using one of the
macro packages.
These are like high-level programming languages, while the bare roff
language compares to a low-level language like C or assembler.
.LP
The roff language is a full programming language providing low-level
requests, definition of macros, escape sequences, string variables,
number or size registers, and C-like flow controls.
.ig /
In the 1980s, it was even possible to write the common utilities for
system administration by only using troff.
There were contests on writing the most unreadable program fake by
exclusively using troff.
Because of security impacts, these dangerous features were removed in
.IR groff .
./
.LP
Some clarification on the language elements seems to be wanted.
Requests are basic formatting commands defined by programming languages
like C, C++, etc., whereas macros are formatting commands that are
written in the roff language.
A document writer will not note any difference in usage for requests or
macros, both are written on a line on their own starting with a dot
.'char . .
But the user may define her own macros if desired.
.LP
Escape sequences are in-line elements starting with a backslash
.'char \e .
They are used to implement various features, including the insertion of
non-ASCII characters with
.esc ( ,
the content of strings with
.esc *
and register variables with
.esc n ,
font changes with
.esc f ,
in-line comments with
.esc \(dq ,
the escaping of special control characters like
.esc \e ,
and many other features.
.\" --------------------------------------------------------------------
.SH FORMATTERS
.\" --------------------------------------------------------------------
Formatters are the front-end programs that analyze a groff document and
translate it into a form that is suitable for a special device.
The traditional
.I roff
had two formatters,
.B nroff
for text devices and
.B troff
for graphical devices.
.LP
These programs still exist in the
.I groff
implementation, but usually they are accessed through a program called
.BR groff .
This combined and extended the old functionality into a single program.
It has many command-line options, most of them herited from
.BR troff .
To ease the option jungle, the user-friendly utility
.B grog
(from `groff guess') was created.
It tries to guess from the document which arguments should be used and
displays a suitable command line.
Though not being perfect, it is a good starting point.
.\" --------------------------------------------------------------------
.SH PREPROCESSORS
.\" --------------------------------------------------------------------
The classical preprocessors that are still available in groff.
.RS
.LP
.PD 0
.TP
.I eqn
for including mathematical equations.
.TP
.I grap
for constructing graphical elements (this preprocessor doesn't come with
groff; it is an extra package).
.TP
.I grn
for including gremlin pictures.
.TP
.I pic
for creating diagrams.
.TP
.I refer
for bibliographic references.
.TP
.I soelim
for including other roff files.
.TP
.I tbl
for rectangular tables.
.PD
.RE
.LP
Each of these preprocessors defines its own language that is translated
into roff code when run through the preprocessor program.
So parts written in these languages may be included within a roff
document.
Such an enhanced document is run through one or more corresponding
preprocessors before it is fed into the actual formatter.
.LP
The preprocessor programs extract and transform the document parts
determined for them.
They can be called either in a UNIX pipeline with their program name or
automatically with a groff option.
.LP
.TS
center, box, tab (@);
C | C
CfCB | CfCB.
preprocessor@groff option
=
eqn@\-e
grap@\-G
grn@\-g
pic@\-p
refer@\-R
tbl@\-r
soelim@\-s
.TE
.LP
.
.\" --------------------------------------------------------------------
.SH "MACRO PACKAGES"
.\" --------------------------------------------------------------------
Macro packages are collections of macros that are suitable to format a
special kind of documents in a convenient way.
This greatly eases the usage of roff.
The macro definitions of a package are kept in a file called
.BI tmac. name
where
.I name
is the internal roff name for this package.
All tmac files are stored in a single or few directories at standard
positions.
.LP
A macro package that is used in a document is specified by the command line
option
.option \-m
for the formatter like
.option "troff\ \-m"
.argname name
or
.option "groff\ \-m"
.argname name .
General details on the naming of macro packages and their placement is
found in
.BR tmac (@MAN5EXT@).
.LP
Famous classical macro packages are
.IR man ,
.IR mandoc ,
and
.I mdoc
for manual pages and
.IR me ,
.IR ms ,
and
.I mm
for books, articles, and letters.
Besides these collections, groff provides an increasing number of new
macro packages for various applications, for example integration of or
conversion into other file formats.
.\" --------------------------------------------------------------------
.SH "FILE NAME EXTENSIONS"
.\" --------------------------------------------------------------------
Manual pages (man-pages) take the section number as a file name
extension, e.g., the filename for this document is
.IR roff.7 ,
i.e., it is kept in
.prefixednumber section 7
of the man-pages.
.LP
The classical macro packages take the package name as an extension, e.g.
.IB file. me
for a document using the
.I me
macro package,
.IB file. mm
for
.IR mm ,
.IB file. ms
for
.IR ms ,
.IB file. pic
for
.I pic
files,
etc.
.ig
.LP
But there is no general naming scheme for roff documents, though
.IB file. roff
or
.IB file. rof
seems to be a good choice.
.LP
File name extensions can be very handy in conjunction with the
.BR less (1)
pager.
It provides the possibility to feed all input into a command-line pipe that
is specified in the shell environment variable
.B LESSOPEN
This process is not well documented, so here an example
.B LESSOPEN='|lesspipe %s'
where
.B lesspipe
is either a system supplied command or a shell script of your own.
..
.\" --------------------------------------------------------------------
.SH EDITING
.\" --------------------------------------------------------------------
Most text editors provide support for editing documents using roff.
Especially useful is the
.B nroff-mode
in all flavors of the Emacs editor.
.\" --------------------------------------------------------------------
.SH ENVIRONMENT
.\" --------------------------------------------------------------------
.TP
.SM
.B GROFF_TMAC_PATH
A colon separated list of directories in which to search for
macro files, see
.BR tmac (@MAN5EXT@).
.TP
.SM
.B GROFF_TYPESETTER
Default device.
.TP
.SM
.B GROFF_FONT_PATH
A colon separated list of directories in which to search for the
.BI dev name
directory.
.B troff
will search in directories given in the
.option \-F
option before these, and in standard directories
.RB ( .:/usr/local/share/groff/font:/usr/lib/font )
after these.
.\" --------------------------------------------------------------------
.SH FILES
.\" --------------------------------------------------------------------
By default,
.I groff
installs all of its library files in a directory tree under
.IR /usr/local/share/groff .
This location might vary for different systems.
In the following, this directory is referred to as
.IR <groff_dir> .
.LP
.TP
.IB <groff_dir> /tmac/troffrc
Initialization file for troff.
.TP
.IB <groff_dir> /tmac/tmac. name
Macro files.
.TP
.IB <groff_dir> /font/dev name /DESC
Device description file for device
.IR name .
.TP
.IB <groff_dir> /font/dev name / F
Font file for font
.I F
of device
.IR name .
.\" --------------------------------------------------------------------
.SH BUGS
.\" --------------------------------------------------------------------
The groff documentation is in evolution at the moment.
It is possible that small inconsistencies between different documents exist
temporarily.
.\" --------------------------------------------------------------------
.SH AUTHOR
.\" --------------------------------------------------------------------
This document is part of groff, the GNU roff distribution. It was
written by Bernd Warken <bwarken@mayn.de>.
.LP
It 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 under
.RS
.LP
.IR <http://www.gnu.org/copyleft/fdl.html> .
.RE
.\" --------------------------------------------------------------------
.SH "SEE ALSO"
.\" --------------------------------------------------------------------
The main source of information is the
.I groff
.BR info (1)
file.
.LP
The predefined elements of the
.I groff
language are also documented in the manual page
.BR groff (@MAN7EXT@).
.LP
Formatters and their wrappers:
.BR groff (@MAN1EXT@),
.BR grog (@MAN1EXT@),
.BR nroff (@MAN1EXT@),
and
.BR troff (@MAN1EXT@).
.LP
Postprocessors for the output devices:
.BR grodvi (@MAN1EXT@),
.BR grohtml (@MAN1EXT@),
.BR grolbp (@MAN1EXT@),
.BR grolj4 (@MAN1EXT@),
.BR grops (@MAN1EXT@),
and
.BR grotty (@MAN1EXT@).
.LP
Standard preprocessors:
.BR eqn (@MAN1EXT@),
.BR grn (@MAN1EXT@),
.BR grap (1),
.BR pic (@MAN1EXT@),
.BR refer (@MAN1EXT@),
.BR soelim (@MAN1EXT@),
and
.BR tbl (@MAN1EXT@).
.LP
The man pages for macro packages include
.BR groff_tmac (@MAN5EXT@),
.BR groff_man (@MAN7EXT@),
.BR groff_markup (@MAN7EXT@),
.BR groff_mdoc (@MAN7EXT@),
.BR groff_mdoc.samples (@MAN7EXT@),
.BR groff_me (@MAN7EXT@),
.BR groff_mm (@MAN7EXT@),
.BR groff_mmroff (@MAN7EXT@),
.BR groff_ms (@MAN7EXT@),
and
.BR groff_msafer (@MAN7EXT@).
.LP
The following utilities are available:
.BR addftinfo (@MAN1EXT@),
.BR afmtodif (@MAN1EXT@),
.BR hpftodit (@MAN1EXT@),
.BR indxbib (@MAN1EXT@),
.BR lookbib (@MAN1EXT@),
.BR pfbtops (@MAN1EXT@),
.BR tfmtodit (@MAN1EXT@),
and
.BR gxditview (@MAN1EXT@).
.LP
For details on the GNU implementation of the
.I roff
system see
.BR groff_char (@MAN7EXT@),
.BR groff_font (@MAN7EXT@),
.BR groff_out (@MAN7EXT@),
and the file
.I README
in the main directory of the groff source distribution.
These also give details on how to contact or join the
.I groff
developer group.
.LP
Many classical
.troff
documents are still available on-line.
Especially informative are the original Bell Labs proceedings for the old,
free UNIX 7 found at
.I http://cm.bell-labs.com/cm/cs/cstr.html
and the collection of the late Richard S. Stevens at
.IR http://www.kohala.com/start/troff/ .
|