4 Last update: 22 Apr 2002
6 This file is part of groff, the GNU roff type-setting system.
8 Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
9 written by Bernd Warken <bwarken@mayn.de>
10 maintained by Werner Lemberg <wl@gnu.org>
12 Permission is granted to copy, distribute and/or modify this document
13 under the terms of the GNU Free Documentation License, Version 1.1 or
14 any later version published by the Free Software Foundation; with the
15 Invariant Sections being this .ig-section and AUTHORS, with no
16 Front-Cover Texts, and with no Back-Cover Texts.
18 A copy of the Free Documentation License is included as a file called
19 FDL in the main directory of the groff source package.
22 .\" --------------------------------------------------------------------
24 .\" --------------------------------------------------------------------
40 .\" --------------------------------------------------------------------
41 .\" String definitions
43 .\" Final `\""' comments are used to make Emacs happy, sic \""
45 .\" The `-' sign for options.
55 .ds Comment \.\[rs]\[dq]\"
56 .ds Ellipsis \.\|.\|.\&\"
59 .\" --------------------------------------------------------------------
60 .\" Begin of macro definitions
63 .\" this is like a comment request when escape mechanism is off
68 .c ---------------------------------------------------------------------
84 . Text \f[B]\[rs]\*[@1]\f[]\$*
91 . nop `\f[B]\*[@1]\f[]'\$*
95 .c --------------------------------------------------------------------
97 .c a shell command line
102 . Text \f[I]sh#\h'1m'\f[]\f[CR]\$*\f[]\&\"
109 .c --------------------------------------------------------------------
111 .c ShortOpt ([c [punct]])
113 .c `-c' somewhere in the text.
114 .c The second argument is some trailing punctuation.
120 . Text \f[CB]\*[@-]\f[]\f[B]\*[@1]\f[]\/\$*
131 .c --------------------------------------------------------------------
141 .\" End of macro definitions
144 .\" --------------------------------------------------------------------
146 .\" --------------------------------------------------------------------
148 .TH ROFF @MAN7EXT@ "@MDATE@" "Groff Version @VERSION@"
150 roff \- concepts and history of roff typesetting
153 .\" --------------------------------------------------------------------
155 .\" --------------------------------------------------------------------
158 is the general name for a set of type-setting programs, known under
166 A roff type-setting system consists of an extensible text formatting
167 language and a set of programs for printing and converting to other
170 Traditionally, it is the main text processing system of Unix; every
171 Unix-like operating system still distributes a roff system as a core
175 The most common roff system today is the free software implementation
177 .BR groff (@MAN1EXT@).
179 The pre-groff implementations are referred to as
181 (dating back as long as 1973).
184 implements the look-and-feel and functionality of its classical
185 ancestors, but has many extensions.
189 is the only roff system that is available for every (or almost every)
190 computer system it is the de-facto roff standard today.
193 In some ancient Unix systems, there was a binary called
195 that implemented the even more ancient
199 operating system, cf. section
201 The functionality of this program was very restricted even in
202 comparison to ancient troff; it is not supported any longer.
204 Consequently, in this document, the term
206 always refers to the general meaning of
208 not to the ancient roff binary.
211 In spite of its age, roff is in wide use today, for example, the manual
212 pages on UNIX systems
213 .RI ( man\~pages\/ ),
214 many software books, system documentation, standards, and corporate
215 documents are written in roff.
217 The roff output for text devices is still unmatched, and its graphical
218 output has the same quality as other free type-setting programs and is
219 better than some of the commercial systems.
222 The most popular application of roff is the concept of
226 this is the standard documentation system on many operating systems.
229 This document describes the historical facts around the development
232 some usage aspects common to all roff versions, details on the roff
233 pipeline, which is usually hidden behind front-ends like
234 .BR groff (@MAN1EXT@);
235 an general overview of the formatting language; some tips for editing
236 roff files; and many pointers to further readings.
239 .\" --------------------------------------------------------------------
241 .\" --------------------------------------------------------------------
245 text processing system has a very long history, dating back to the
248 The roff system itself is intimately connected to the Unix operating
249 system, but its roots go back to the earlier operating systems CTSS
253 .\" --------------------------------------------------------------------
254 .SS "The Predecessor runoff"
255 .\" --------------------------------------------------------------------
260 is intimately related to the history of the operating systems.
269 .RI ( "Compatible Time Sharing System" )
272 When CTTS was further developed into the operating system
273 .URL http://\:www.multicians.org "Multics" ,
274 the famous predecessor of Unix from 1963,
276 became the main format for documentation and text processing.
278 Both operating systems could only be run on very expensive computers
279 at that time, so they were mostly used in research and for official
283 The possibilities of the
285 language were quite limited as compared to modern roff.
287 Only text output was possible in the 1960s.
289 This could be implemented by a set of requests of length\~2, many of
290 which are still identically used in roff.
292 The language was modelled according to the habits of typesetting in
293 the pre-computer age, where lines starting with a dot were used in
294 manuscripts to denote formatting requests to the person who would
295 perform the typesetting manually later on.
298 The runoff program was written in the
300 language first, later on in
302 the grandmother of the
304 programming language.
306 In the Multics operating system, the help system was handled by
307 runoff, similar to roff's task to manage the Unix manual pages.
309 There are still documents written in the runoff language; for examples
310 see Saltzer's home page, cf. section
314 .\" --------------------------------------------------------------------
315 .SS "The Classical nroff/troff System"
316 .\" --------------------------------------------------------------------
318 In the 1970s, the Multics off-spring
320 became more and more popular because it could be run on affordable
321 machines and was easily available for universities at that time.
323 At MIT (the Massachusetts Institute of Technology), there was a need to
325 .I Graphic Systems CAT
326 typesetter, a graphical output device from a PDP-11 computer running
329 As runoff was too limited for this task it was further developed into
330 a more powerful text formatting system by
331 .IR "Josef F. Osanna" ,
332 a main developer of the Multics operating system and programmer of
333 several runoff ports.
340 The greatly enlarged language of Osanna's concept included already all
344 All modern roff systems try to implement compatibility to this system.
346 So Joe Osanna can be called the father of all roff systems.
351 had three formatter programs.
355 .RI ( "typesetter roff\/" )
356 generated a graphical output for the
358 typesetter as its only device.
362 produced text output suitable for terminals and line printers.
366 was the reimplementation of the former runoff program with its limited
367 features; this program was abandoned in later versions.
371 is used to refer to a troff/\:nroff sytem as a whole.
374 Osanna first version was written in the PDP-11 assembly language and
380 development by rewriting it in the C\~programming language.
382 The C\~version was released in 1975.
385 The syntax of the formatting language of the
387 programs was documented in the famous
388 .IR "Troff User's Manual [CSTR\~#54]" ,
389 first published in 1976, with further revisions up to 1992 by Brian
392 This document is the specification of the
393 .IR "classical troff" .
396 systems tried to establish compatibility with this specification.
399 After Osanna had died in 1977 by a heart-attack at the age of about\~50,
400 Kernighan went on with developing troff.
402 The next milestone was to equip troff with a general interface to
403 support more devices, the intermediate output format and the
404 postprocessor system.
406 This completed the structure of a
408 as it is still in use today; see section
411 In 1979, these novelties were described in the paper
413 This new troff version is the basis for all existing newer troff
417 On some systems, this
418 .I device independent troff
419 got a binary of its own, called
420 .BR ditroff (@MAN7EXT@).
424 programs already provide the full ditroff capabilities automatically.
427 .\" --------------------------------------------------------------------
428 .SS "Commercialization"
429 .\" --------------------------------------------------------------------
431 A major degradation occurred when the easily available Unix\~7
432 operating system was commercialized.
434 A whole bunch of divergent operating systems emerged, fighting each
435 other with incompatibilities in their extensions.
437 Luckily, the incompatibilities did not fight the original troff.
439 All of the different commercial roff systems made heavy use of
440 Osanna/\:Kernighan's open source code and documentation, but sold them
441 as \[lq]their\[rq] system \[em] with only minor additions.
444 The source code of both the ancient Unix and classical troff weren't
445 available for two decades.
447 Fortunately, Caldera bought SCO UNIX in 2001.
449 In the following, Caldera made the ancient source code accessible
450 on-line for non-commercial use, cf. section
454 .\" --------------------------------------------------------------------
456 .\" --------------------------------------------------------------------
458 None of the commercial roff systems could attain the status of a
459 successor for the general roff development.
461 Everyone was only interested in their own stuff.
463 This led to a steep downfall of the once excellent
464 Unix operating system during the 1980s.
467 As a counter-measure to the galopping commercialization, AT&T Bell
468 Labs tried to launch a rescue project with their
472 It is freely available for non-commercial use, even the source code,
473 but has a proprietary license that empedes the free development.
475 This concept is outdated, so Plan\~9 was not accepted as a platform to
476 bundle the main-stream development.
479 The only remedy came from the emerging free operatings systems
480 (386BSD, GNU/\:Linux, etc.) and software projects during the 1980s and
483 These implemented the ancient Unix features and many extensions, such
484 that the old experience is not lost.
486 In the 21st century, Unix-like systems are again a major factor in
487 computer industry \[em] thanks to free software.
490 The most important free roff project was the GNU port of troff,
491 created by James Clark and put under the
492 .URL http://\:www.gnu.org/\:copyleft "GNU Public License" .
498 .BR groff (@MAN1EXT@)
502 The groff system is still actively developed.
504 It is compatible to the classical troff, but many extensions were
507 It is the first roff system that is available on almost all operating
508 systems \[em] and it is free.
510 This makes groff the de-facto roff standard today.
513 .\" --------------------------------------------------------------------
515 .\" --------------------------------------------------------------------
517 Most people won't even notice that they are actually using roff.
519 When you read a system manual page (man page) roff is working in the
522 Roff documents can be viewed with a native viewer called
524 a standard program of the X window distribution, see
527 But using roff explicitly isn't difficult either.
530 Some roff implementations provide wrapper programs that make it easy
531 to use the roff system on the shell command line.
533 For example, the GNU roff implementation
534 .BR groff (@MAN1EXT@)
535 provides command line options to avoid the long command pipes of
536 classical troff; a program
538 tries to guess from the document which arguments should be used for a
539 run of groff; people who do not like specifying command line options
541 .BR groffer (@MAN1EXT@)
542 program for graphically displaying groff files and man pages.
545 .\" --------------------------------------------------------------------
547 .\" --------------------------------------------------------------------
549 Each roff system consists of preprocessors, roff formatter programs,
550 and a set of device postprocessors.
552 This concept makes heavy use of the
554 mechanism, that is, a series of programs is called one after the other,
555 where the output of each program in the queue is taken as the input
556 for the next program.
560 .ds @1 "cat \f[I]file\f[P] |\""
561 .ds @2 "\*[Ellipsis] | \f[I]preproc\f[P] | \*[Ellipsis] |\""
562 .ds @3 "troff \f[I]options\f[P] | \f[I]postproc\f[P]\""
564 .ShellCommand "\*[@1] \*[@2] \*[@3]"
570 The preprocessors generate roff code that is fed into a roff formatter
571 (e.g. troff), which in turn generates
572 .I intermediate output
573 that is fed into a device postprocessor program for printing or final
577 All of these parts use programming languages of their own; each
578 language is totally unrelated to the other parts.
580 Moreover, roff macro packages that were tailored for special purposes
584 Most roff documents use the macros of some package, intermixed with
585 code for one or more preprocessors, spiced with some elements from the
588 The full power of the roff formatting language is seldom needed by
589 users; only programmers of macro packages need to know about the gory
594 .\" --------------------------------------------------------------------
596 .\" --------------------------------------------------------------------
598 A roff preprocessor is any program that generates output that
599 syntactically obeys the rules of the roff formatting language.
601 Each preprocessor defines a language of its own that is translated
602 into roff code when run through the preprocessor program.
604 Parts written in these languages may be included within a roff
605 document; they are identified by special roff requests or macros.
607 Each document that is enhanced by preprocessor code must be run
608 through all corresponding preprocessors before it is fed into the
609 actual roff formatter program, for the formatter just ignores all
612 The preprocessor programs extract and transform only the document
613 parts that are determined for them.
616 There are a lot of free and commercial roff preprocessors.
618 Some of them aren't available on each system, but there is a small
619 set of preprocessors that are considered as an integral part of each
622 The classical preprocessors are
626 .\" local indent for .TP
627 .TP \\w'\\f[B]soelim\\f[P]'u+2n
637 for mathematical formul\[ae]
643 for bibliographic references
646 for including macro files from standard locations
651 Other known preprocessors that are not available on all systems
659 for drawing chemical formul\[ae].
662 for constructing graphical elements.
673 .\" --------------------------------------------------------------------
674 .SS "Formatter Programs"
675 .\" --------------------------------------------------------------------
679 is a program that parses documents written in the roff formatting
680 language or uses some of the roff macro packages.
683 .IR "intermediate output" ,
684 which is intended to be fed into a single device postprocessor that
685 must be specified by a command-line option to the formatter program.
687 The documents must have been run through all necessary preprocessors
691 The output produced by a roff formatter is represented in yet another
693 .IR "intermediate output format"
696 This language was first specified in
698 its GNU extension is documented in
699 .BR groff_out (@MAN5EXT@).
701 The intermediate output language is a kind of assembly language
702 compared to the high-level roff language.
704 The generated intermediate output is optimized for a special device,
705 but the language is the same for every device.
708 The roff formatter is the heart of the roff system.
710 The traditional roff had two formatters,
714 for graphical devices.
719 is used as a general term to refer to both formatters.
722 .\" --------------------------------------------------------------------
723 .SS "Devices and Postprocessors"
724 .\" --------------------------------------------------------------------
726 Devices are hardware interfaces like printers, text or graphical
727 terminals, etc., or software interfaces such as a conversion into a
728 different text or graphical format.
731 A roff postprocessor is a program that transforms troff output into a
732 form suitable for a special device.
734 The roff postprocessors are like device drivers for the output target.
737 For each device there is a postprocessor program that fits the device
740 The postprocessor parses the generated intermediate output and
741 generates device-specific code that is sent directly to the device.
744 The names of the devices and the postprocessor programs are not fixed
745 because they greatly depend on the software and hardware abilities of
748 For example, the classical devices mentioned in
750 have greatly changed since the classical times.
752 The old hardware doesn't exist any longer and the old graphical
753 conversions were quite imprecise when compared to their modern
757 For example, the Postscript device
759 in classical troff had a resolution
760 of 720, while groff's
762 device has 72000, a refinement of factor 100.
765 Today the operating systems provide device drivers for most
766 printer-like hardware, so it isn't necessary to write a special
767 hardware postprocessor for each printer.
770 .\" --------------------------------------------------------------------
771 .SH "ROFF PROGRAMMING"
772 .\" --------------------------------------------------------------------
774 Documents using roff are normal text files decorated by roff
777 The roff formatting language is quite powerful; it is almost a full
778 programming language and provides elements to enlarge the language.
780 With these, it became possible to develop macro packages that are
781 tailored for special applications.
783 Such macro packages are much handier than plain roff.
785 So most people will choose a macro package without worrying about the
786 internals of the roff language.
789 .\" --------------------------------------------------------------------
791 .\" --------------------------------------------------------------------
793 Macro packages are collections of macros that are suitable to format a
794 special kind of documents in a convenient way.
796 This greatly eases the usage of roff.
798 The macro definitions of a package are kept in a file called
804 All tmac files are stored in one or more directories at standardized
807 Details on the naming of macro packages and their placement is found
809 .BR groff_tmac (@MAN5EXT@).
812 A macro package that is to be used in a document can be announced to
813 the formatter by the command line option
816 .BR troff (@MAN1EXT@),
817 or it can be specified within a document using the file inclusion
818 requests of the roff language, see
819 .BR groff (@MAN7EXT@).
822 Famous classical macro packages are
824 for traditional man pages,
826 for BSD-style manual pages;
827 the macro sets for books, articles, and letters are
829 (probably from the first name of its creator
834 .IR "Manuscript Macros\/" ),
838 .IR "Memorandum Macros\/" ).
841 .\" --------------------------------------------------------------------
842 .SS "The roff Formatting Language"
843 .\" --------------------------------------------------------------------
845 The classical roff formatting language is documented in the
846 .I Troff User's Manual
849 The roff language is a full programming language providing requests,
850 definition of macros, escape sequences, string variables, number or
851 size registers, and flow controls.
855 are the predefined basic formatting commands similar to the commands
858 The user can define request-like elements using predefined roff
861 These are then called
864 A document writer will not note any difference in usage for requests
865 or macros; both are written on a line on their own starting with a dot.
869 are roff elements starting with a backslash
871 They can be inserted anywhere, also in the midst of text in a line.
873 They are used to implement various features, including the insertion of
874 non-ASCII characters with
878 in-line comments with
880 the escaping of special control characters like
882 and many other features.
886 are variables that can store a string.
888 A string is stored by the
892 The stored string can be retrieved later by the
898 store numbers and sizes.
900 A register can be set with the request
902 and its value can be retrieved by the escape sequence
906 .\" --------------------------------------------------------------------
907 .SH "FILE NAME EXTENSIONS"
908 .\" --------------------------------------------------------------------
910 Manual pages (man pages) take the section number as a file name
911 extension, e.g., the filename for this document is
913 i.e., it is kept in section\~7
917 The classical macro packages take the package name as an extension, e.g.
919 for a document using the
935 But there is no general naming scheme for roff documents, though
939 is seen now and then.
941 Maybe there should be a standardization for the filename extensions of
945 File name extensions can be very handy in conjunction with the
949 It provides the possibility to feed all input into a command-line pipe
950 that is specified in the shell environment variable
952 This process is not well documented, so here an example:
955 .ShellCommand LESSOPEN='|lesspipe %s'
960 is either a system supplied command or a shell script of your own.
963 .\" --------------------------------------------------------------------
965 .\" --------------------------------------------------------------------
967 The best program for editing a roff document is Emacs (or Xemacs), see
971 mode that is suitable for all kinds of roff dialects.
973 This mode can be activated by the following methods.
976 When editing a file within Emacs the mode can be changed by typing
977 .RI ` "M-x nroff-mode" ',
980 means to hold down the
989 But it is also possible to have the mode automatically selected when
990 the file is loaded into the editor.
993 The most general method is to include the following 3 comment lines at
998 .B \*[Comment] Local Variables:
999 .B \*[Comment] mode: nroff
1004 There is a set of file name extensions, e.g. the man pages that
1005 trigger the automatic activation of the nroff mode.
1008 Theoretically, it is possible to write the sequence
1010 .B \*[Comment] \%-*-\ nroff\ -*-
1012 as the first line of a file to have it started in nroff mode when
1015 Unfortunately, some applications such as the
1017 program are confused by this; so this is deprecated.
1020 All roff formatters provide automated line breaks and horizontal and
1023 In order to not disturb this, the following tips can be helpful.
1026 Never include empty or blank lines in a roff document.
1028 Instead, use the empty request (a line consisting of a dot only) or a
1031 if a structuring element is needed.
1034 Never start a line with whitespace because this can lead to
1035 unexpected behavior.
1037 Indented paragraphs can be constructed in a controlled way by roff
1041 Start each sentence on a line of its own, for the spacing after a dot
1042 is handled differently depending on whether it terminates an
1043 abbreviation or a sentence.
1045 To distinguish both cases, do a line break after each sentence.
1048 To additionally use the auto-fill mode in Emacs, it is best to insert
1049 an empty roff request (a line consisting of a dot only) after each
1053 The following example shows how optimal roff editing could look.
1057 This is an example for a roff document.
1059 This is the next sentence in the same paragraph.
1061 This is a longer sentence stretching over several
1062 lines; abbreviations like `cf.' are easily
1063 identified because the dot is not followed by a
1066 In the output, this will still go to the same
1071 Besides Emacs, some other editors provide nroff style files too, e.g.\&
1078 .\" --------------------------------------------------------------------
1080 .\" --------------------------------------------------------------------
1083 is a registered trademark of the Open Group.
1085 But things have improved considerably after Caldera had bought SCO
1089 .\" --------------------------------------------------------------------
1091 .\" --------------------------------------------------------------------
1093 There is a lot of documentation on roff.
1095 The original papers on classical troff are still available, and all
1096 aspects of groff are documented in great detail.
1099 .\" --------------------------------------------------------------------
1100 .SS "Internet sites"
1101 .\" --------------------------------------------------------------------
1105 .URL http://\:www.troff.org "The historical troff site"
1106 provides an overview and pointers to all historical aspects of roff.
1108 This web site is under construction; once, it will be the major source
1113 .URL http://\:www.multicians.org "The Multics site"
1114 contains a lot of information on the MIT projects, CTSS, Multics,
1115 early Unix, including
1117 especially useful are a glossary and the many links to ancient
1122 .URL http://\:www.tuhs.org/\:Archive/ \
1123 "The Ancient Unixes Archive"
1125 provides the source code and some binaries of the ancient Unixes
1126 (including the source code of troff and its documentation) that were
1127 made public by Caldera since 2001, e.g. of the famous Unix version\~7
1129 .URL http://\:www.tuhs.org/\:Archive/\:PDP-11/\:Trees/\:V7 \
1133 Developers at AT&T Bell Labs
1134 .URL http://\:cm.bell-labs.com/\:cm/\:index.html \
1135 "Bell Labs Computing and Mathematical Sciences Research"
1137 provides a search facility for tracking information on the early
1142 .URL http://\:plan9.bell-labs.com "The Plan\~9 operating system"
1148 .URL http://web.mit.edu/\:Saltzer/\:www/\:publications/\:pubs.html \
1149 "Jerry Saltzer's home page"
1151 stores some documents using the ancient runoff formatting language.
1155 .URL http://\:cm.bell-labs.com/\:cm/\:cs/\:cstr.html \
1156 "The Bell Labs CSTR site"
1158 stores the original troff manuals (CSTR #54, #97, #114, #116, #122)
1159 and famous historical documents on programming.
1163 .URL http://\:www.gnu.org/\:software/\:groff "The groff web site"
1164 provides the free roff implementation groff, the actual standard roff.
1167 .\" --------------------------------------------------------------------
1168 .SS "Historical roff Documentation"
1169 .\" --------------------------------------------------------------------
1173 documents are still available on-line.
1175 The two main manuals of the troff language are
1180 .URL http://\:cm.bell-labs.com/\:cm/\:cs/\:54.ps \
1181 "\fINroff/\:Troff User's Manual\fP" ;
1183 Bell Labs, 1976; revised by Brian Kernighan, 1992.
1189 .URL http://\:cm.bell-labs.com/\:cm/\:cs/\:97.ps \
1190 "\fIA Typesetter-independent TROFF\fP" ,
1192 Bell Labs, 1981, revised March 1982.
1195 The "little language" roff papers are
1199 Jon L. Bentley and Brian W. Kernighan,
1200 .URL http://\:cm.bell-labs.com/\:cm/\:cs/\:114.ps \
1201 "\fIGRAP \(em A Language for Typesetting Graphs\fP" ;
1203 Bell Labs, August 1984.
1208 .URL http://\:cm.bell-labs.com/\:cm/\:cs/\:116.ps \
1209 "\fIPIC -- A Graphics Language for Typesetting\fP" ;
1211 Bell Labs, December 1984.
1215 J. L. Bentley, L. W. Jelinski, and B. W. Kernighan,
1216 .URL http://\:cm.bell-labs.com/\:cm/\:cs/\:122.ps \
1217 "\fICHEM \(em A Program for Typesetting Chemical Structure Diagrams, \
1218 Computers and Chemistry\fP" ;
1220 Bell Labs, April 1986.
1223 .\" --------------------------------------------------------------------
1225 .\" --------------------------------------------------------------------
1227 Due to its complex structure, a full roff system has many man pages,
1228 each describing a single aspect of roff.
1230 Unfortunately, there is no general naming scheme for the
1231 documentation among the different roff implementations.
1237 .BR groff (@MAN1EXT@)
1238 contains a survey of all documentation available in groff.
1241 On other systems, you are on your own, but
1243 might be a good starting point.
1246 .\" --------------------------------------------------------------------
1248 .\" --------------------------------------------------------------------
1250 Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
1253 This document is distributed under the terms of the FDL (GNU Free
1254 Documentation License) version 1.1 or later.
1256 You should have received a copy of the FDL on your system, it is also
1257 available on-line at the
1258 .URL http://\:www.gnu.org/\:copyleft/\:fdl.html "GNU copyleft site" .
1261 This document is part of
1263 the GNU roff distribution.
1266 .MTO bwarken@mayn.de "Bernd Warken" ;
1268 .MTO wl@gnu.org "Werner Lemberg".
1271 .\" --------------------------------------------------------------------
1273 .\" --------------------------------------------------------------------
1275 .\" Local Variables: