4 Last update: 1 Jun 2004
6 This file is part of groff, the GNU roff type-setting system.
8 Copyright (C) 2000, 2001, 2002, 2003, 2004 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 .\" --------------------------------------------------------------------
43 .\" --------------------------------------------------------------------
44 .\" String definitions
46 .\" Final `\""' comments are used to make Emacs happy, sic \""
48 .\" The `-' sign for options.
58 .ds Comment \.\[rs]\[dq]\"
59 .ds Ellipsis \.\|.\|.\&\"
62 .\" --------------------------------------------------------------------
63 .\" Begin of macro definitions
66 .\" this is like a comment request when escape mechanism is off
71 .c ---------------------------------------------------------------------
87 . Text \f[B]\[rs]\*[@1]\f[]\$*
94 . nop `\f[B]\*[@1]\f[]'\$*
98 .c --------------------------------------------------------------------
100 .c a shell command line
105 . Text \f[I]sh#\h'1m'\f[]\f[CR]\$*\f[]\&\"
112 .c --------------------------------------------------------------------
114 .c ShortOpt ([c [punct]])
116 .c `-c' somewhere in the text.
117 .c The second argument is some trailing punctuation.
123 . Text \f[CB]\*[@-]\f[]\f[B]\*[@1]\f[]\/\$*
134 .c --------------------------------------------------------------------
144 .\" End of macro definitions
147 .\" --------------------------------------------------------------------
149 .\" --------------------------------------------------------------------
151 .TH ROFF @MAN7EXT@ "@MDATE@" "Groff Version @VERSION@"
153 roff \- concepts and history of roff typesetting
156 .\" --------------------------------------------------------------------
158 .\" --------------------------------------------------------------------
161 is the general name for a set of type-setting programs, known under
169 A roff type-setting system consists of an extensible text formatting
170 language and a set of programs for printing and converting to other
173 Traditionally, it is the main text processing system of Unix; every
174 Unix-like operating system still distributes a roff system as a core
178 The most common roff system today is the free software implementation
180 .BR groff (@MAN1EXT@).
182 The pre-groff implementations are referred to as
184 (dating back as long as 1973).
187 implements the look-and-feel and functionality of its classical
188 ancestors, but has many extensions.
192 is the only roff system that is available for every (or almost every)
193 computer system it is the de-facto roff standard today.
196 In some ancient Unix systems, there was a binary called
198 that implemented the even more ancient
202 operating system, cf. section
204 The functionality of this program was very restricted even in
205 comparison to ancient troff; it is not supported any longer.
207 Consequently, in this document, the term
209 always refers to the general meaning of
211 not to the ancient roff binary.
214 In spite of its age, roff is in wide use today, for example, the manual
215 pages on UNIX systems
216 .RI ( man\~pages\/ ),
217 many software books, system documentation, standards, and corporate
218 documents are written in roff.
220 The roff output for text devices is still unmatched, and its graphical
221 output has the same quality as other free type-setting programs and is
222 better than some of the commercial systems.
225 The most popular application of roff is the concept of
229 this is the standard documentation system on many operating systems.
232 This document describes the historical facts around the development
235 some usage aspects common to all roff versions, details on the roff
236 pipeline, which is usually hidden behind front-ends like
237 .BR groff (@MAN1EXT@);
238 an general overview of the formatting language; some tips for editing
239 roff files; and many pointers to further readings.
242 .\" --------------------------------------------------------------------
244 .\" --------------------------------------------------------------------
248 text processing system has a very long history, dating back to the
251 The roff system itself is intimately connected to the Unix operating
252 system, but its roots go back to the earlier operating systems CTSS
256 .\" --------------------------------------------------------------------
257 .SS "The Predecessor runoff"
258 .\" --------------------------------------------------------------------
263 is intimately related to the history of the operating systems.
272 .RI ( "Compatible Time Sharing System" )
275 When CTSS was further developed into the operating system
276 .URL http://\:www.multicians.org "Multics" ,
277 the famous predecessor of Unix from 1963,
279 became the main format for documentation and text processing.
281 Both operating systems could only be run on very expensive computers
282 at that time, so they were mostly used in research and for official
286 The possibilities of the
288 language were quite limited as compared to modern roff.
290 Only text output was possible in the 1960s.
292 This could be implemented by a set of requests of length\~2, many of
293 which are still identically used in roff.
295 The language was modelled according to the habits of typesetting in
296 the pre-computer age, where lines starting with a dot were used in
297 manuscripts to denote formatting requests to the person who would
298 perform the typesetting manually later on.
301 The runoff program was written in the
303 language first, later on in
305 the grandmother of the
307 programming language.
309 In the Multics operating system, the help system was handled by
310 runoff, similar to roff's task to manage the Unix manual pages.
312 There are still documents written in the runoff language; for examples
313 see Saltzer's home page, cf. section
317 .\" --------------------------------------------------------------------
318 .SS "The Classical nroff/troff System"
319 .\" --------------------------------------------------------------------
321 In the 1970s, the Multics off-spring
323 became more and more popular because it could be run on affordable
324 machines and was easily available for universities at that time.
326 At MIT (the Massachusetts Institute of Technology), there was a need to
328 .I Graphic Systems CAT
329 typesetter, a graphical output device from a PDP-11 computer running
332 As runoff was too limited for this task it was further developed into
333 a more powerful text formatting system by
334 .IR "Josef F. Osanna" ,
335 a main developer of the Multics operating system and programmer of
336 several runoff ports.
343 The greatly enlarged language of Osanna's concept included already all
347 All modern roff systems try to implement compatibility to this system.
349 So Joe Osanna can be called the father of all roff systems.
354 had three formatter programs.
358 .RI ( "typesetter roff\/" )
359 generated a graphical output for the
361 typesetter as its only device.
365 produced text output suitable for terminals and line printers.
369 was the reimplementation of the former runoff program with its limited
370 features; this program was abandoned in later versions.
374 is used to refer to a troff/\:nroff sytem as a whole.
377 Osanna first version was written in the PDP-11 assembly language and
383 development by rewriting it in the C\~programming language.
385 The C\~version was released in 1975.
388 The syntax of the formatting language of the
390 programs was documented in the famous
391 .IR "Troff User's Manual [CSTR\~#54]" ,
392 first published in 1976, with further revisions up to 1992 by Brian
395 This document is the specification of the
396 .IR "classical troff" .
399 systems tried to establish compatibility with this specification.
402 After Osanna had died in 1977 by a heart-attack at the age of about\~50,
403 Kernighan went on with developing troff.
405 The next milestone was to equip troff with a general interface to
406 support more devices, the intermediate output format and the
407 postprocessor system.
409 This completed the structure of a
411 as it is still in use today; see section
414 In 1979, these novelties were described in the paper
416 This new troff version is the basis for all existing newer troff
420 On some systems, this
421 .I device independent troff
422 got a binary of its own, called
423 .BR ditroff (@MAN7EXT@).
427 programs already provide the full ditroff capabilities automatically.
430 .\" --------------------------------------------------------------------
431 .SS "Commercialization"
432 .\" --------------------------------------------------------------------
434 A major degradation occurred when the easily available Unix\~7
435 operating system was commercialized.
437 A whole bunch of divergent operating systems emerged, fighting each
438 other with incompatibilities in their extensions.
440 Luckily, the incompatibilities did not fight the original troff.
442 All of the different commercial roff systems made heavy use of
443 Osanna/\:Kernighan's open source code and documentation, but sold them
444 as \[lq]their\[rq] system \[em] with only minor additions.
447 The source code of both the ancient Unix and classical troff weren't
448 available for two decades.
450 Fortunately, Caldera bought SCO UNIX in 2001.
452 In the following, Caldera made the ancient source code accessible
453 on-line for non-commercial use, cf. section
457 .\" --------------------------------------------------------------------
459 .\" --------------------------------------------------------------------
461 None of the commercial roff systems could attain the status of a
462 successor for the general roff development.
464 Everyone was only interested in their own stuff.
466 This led to a steep downfall of the once excellent
467 Unix operating system during the 1980s.
470 As a counter-measure to the galopping commercialization, AT&T Bell
471 Labs tried to launch a rescue project with their
475 It is freely available for non-commercial use, even the source code,
476 but has a proprietary license that impedes the free development.
478 This concept is outdated, so Plan\~9 was not accepted as a platform to
479 bundle the main-stream development.
482 The only remedy came from the emerging free operatings systems
483 (386BSD, GNU/\:Linux, etc.) and software projects during the 1980s and
486 These implemented the ancient Unix features and many extensions, such
487 that the old experience is not lost.
489 In the 21st century, Unix-like systems are again a major factor in
490 computer industry \[em] thanks to free software.
493 The most important free roff project was the GNU port of troff,
494 created by James Clark and put under the
495 .URL http://\:www.gnu.org/\:copyleft "GNU Public License" .
501 .BR groff (@MAN1EXT@)
505 The groff system is still actively developed.
507 It is compatible to the classical troff, but many extensions were
510 It is the first roff system that is available on almost all operating
511 systems \[em] and it is free.
513 This makes groff the de-facto roff standard today.
516 .\" --------------------------------------------------------------------
518 .\" --------------------------------------------------------------------
520 Most people won't even notice that they are actually using roff.
522 When you read a system manual page (man page) roff is working in the
525 Roff documents can be viewed with a native viewer called
527 a standard program of the X window distribution, see
530 But using roff explicitly isn't difficult either.
533 Some roff implementations provide wrapper programs that make it easy
534 to use the roff system on the shell command line.
536 For example, the GNU roff implementation
537 .BR groff (@MAN1EXT@)
538 provides command line options to avoid the long command pipes of
539 classical troff; a program
541 tries to guess from the document which arguments should be used for a
542 run of groff; people who do not like specifying command line options
544 .BR groffer (@MAN1EXT@)
545 program for graphically displaying groff files and man pages.
548 .\" --------------------------------------------------------------------
550 .\" --------------------------------------------------------------------
552 Each roff system consists of preprocessors, roff formatter programs,
553 and a set of device postprocessors.
555 This concept makes heavy use of the
557 mechanism, that is, a series of programs is called one after the other,
558 where the output of each program in the queue is taken as the input
559 for the next program.
563 .ds @1 "cat \f[I]file\f[P] |\""
564 .ds @2 "\*[Ellipsis] | \f[I]preproc\f[P] | \*[Ellipsis] |\""
565 .ds @3 "troff \f[I]options\f[P] | \f[I]postproc\f[P]\""
567 .ShellCommand "\*[@1] \*[@2] \*[@3]"
573 The preprocessors generate roff code that is fed into a roff formatter
574 (e.g. troff), which in turn generates
575 .I intermediate output
576 that is fed into a device postprocessor program for printing or final
580 All of these parts use programming languages of their own; each
581 language is totally unrelated to the other parts.
583 Moreover, roff macro packages that were tailored for special purposes
587 Most roff documents use the macros of some package, intermixed with
588 code for one or more preprocessors, spiced with some elements from the
591 The full power of the roff formatting language is seldom needed by
592 users; only programmers of macro packages need to know about the gory
597 .\" --------------------------------------------------------------------
599 .\" --------------------------------------------------------------------
601 A roff preprocessor is any program that generates output that
602 syntactically obeys the rules of the roff formatting language.
604 Each preprocessor defines a language of its own that is translated
605 into roff code when run through the preprocessor program.
607 Parts written in these languages may be included within a roff
608 document; they are identified by special roff requests or macros.
610 Each document that is enhanced by preprocessor code must be run
611 through all corresponding preprocessors before it is fed into the
612 actual roff formatter program, for the formatter just ignores all
615 The preprocessor programs extract and transform only the document
616 parts that are determined for them.
619 There are a lot of free and commercial roff preprocessors.
621 Some of them aren't available on each system, but there is a small
622 set of preprocessors that are considered as an integral part of each
625 The classical preprocessors are
629 .\" local indent for .TP
630 .TP \\w'\\f[B]soelim\\f[P]'u+2n
640 for mathematical formul\[ae]
646 for bibliographic references
649 for including macro files from standard locations
654 Other known preprocessors that are not available on all systems
662 for drawing chemical formul\[ae].
665 for constructing graphical elements.
676 .\" --------------------------------------------------------------------
677 .SS "Formatter Programs"
678 .\" --------------------------------------------------------------------
682 is a program that parses documents written in the roff formatting
683 language or uses some of the roff macro packages.
686 .IR "intermediate output" ,
687 which is intended to be fed into a single device postprocessor that
688 must be specified by a command-line option to the formatter program.
690 The documents must have been run through all necessary preprocessors
694 The output produced by a roff formatter is represented in yet another
696 .IR "intermediate output format"
699 This language was first specified in
701 its GNU extension is documented in
702 .BR groff_out (@MAN5EXT@).
704 The intermediate output language is a kind of assembly language
705 compared to the high-level roff language.
707 The generated intermediate output is optimized for a special device,
708 but the language is the same for every device.
711 The roff formatter is the heart of the roff system.
713 The traditional roff had two formatters,
717 for graphical devices.
722 is used as a general term to refer to both formatters.
725 .\" --------------------------------------------------------------------
726 .SS "Devices and Postprocessors"
727 .\" --------------------------------------------------------------------
729 Devices are hardware interfaces like printers, text or graphical
730 terminals, etc., or software interfaces such as a conversion into a
731 different text or graphical format.
734 A roff postprocessor is a program that transforms troff output into a
735 form suitable for a special device.
737 The roff postprocessors are like device drivers for the output target.
740 For each device there is a postprocessor program that fits the device
743 The postprocessor parses the generated intermediate output and
744 generates device-specific code that is sent directly to the device.
747 The names of the devices and the postprocessor programs are not fixed
748 because they greatly depend on the software and hardware abilities of
751 For example, the classical devices mentioned in
753 have greatly changed since the classical times.
755 The old hardware doesn't exist any longer and the old graphical
756 conversions were quite imprecise when compared to their modern
760 For example, the Postscript device
762 in classical troff had a resolution
763 of 720, while groff's
765 device has 72000, a refinement of factor 100.
768 Today the operating systems provide device drivers for most
769 printer-like hardware, so it isn't necessary to write a special
770 hardware postprocessor for each printer.
773 .\" --------------------------------------------------------------------
774 .SH "ROFF PROGRAMMING"
775 .\" --------------------------------------------------------------------
777 Documents using roff are normal text files decorated by roff
780 The roff formatting language is quite powerful; it is almost a full
781 programming language and provides elements to enlarge the language.
783 With these, it became possible to develop macro packages that are
784 tailored for special applications.
786 Such macro packages are much handier than plain roff.
788 So most people will choose a macro package without worrying about the
789 internals of the roff language.
792 .\" --------------------------------------------------------------------
794 .\" --------------------------------------------------------------------
796 Macro packages are collections of macros that are suitable to format a
797 special kind of documents in a convenient way.
799 This greatly eases the usage of roff.
801 The macro definitions of a package are kept in a file called
807 All tmac files are stored in one or more directories at standardized
810 Details on the naming of macro packages and their placement is found
812 .BR groff_tmac (@MAN5EXT@).
815 A macro package that is to be used in a document can be announced to
816 the formatter by the command line option
819 .BR troff (@MAN1EXT@),
820 or it can be specified within a document using the file inclusion
821 requests of the roff language, see
822 .BR groff (@MAN7EXT@).
825 Famous classical macro packages are
827 for traditional man pages,
829 for BSD-style manual pages;
830 the macro sets for books, articles, and letters are
832 (probably from the first name of its creator
837 .IR "Manuscript Macros\/" ),
841 .IR "Memorandum Macros\/" ).
844 .\" --------------------------------------------------------------------
845 .SS "The roff Formatting Language"
846 .\" --------------------------------------------------------------------
848 The classical roff formatting language is documented in the
849 .I Troff User's Manual
852 The roff language is a full programming language providing requests,
853 definition of macros, escape sequences, string variables, number or
854 size registers, and flow controls.
858 are the predefined basic formatting commands similar to the commands
861 The user can define request-like elements using predefined roff
864 These are then called
867 A document writer will not note any difference in usage for requests
868 or macros; both are written on a line on their own starting with a dot.
872 are roff elements starting with a backslash
874 They can be inserted anywhere, also in the midst of text in a line.
876 They are used to implement various features, including the insertion of
877 non-ASCII characters with
881 in-line comments with
883 the escaping of special control characters like
885 and many other features.
889 are variables that can store a string.
891 A string is stored by the
895 The stored string can be retrieved later by the
901 store numbers and sizes.
903 A register can be set with the request
905 and its value can be retrieved by the escape sequence
909 .\" --------------------------------------------------------------------
910 .SH "FILE NAME EXTENSIONS"
911 .\" --------------------------------------------------------------------
913 Manual pages (man pages) take the section number as a file name
914 extension, e.g., the filename for this document is
916 i.e., it is kept in section\~7
920 The classical macro packages take the package name as an extension, e.g.
922 for a document using the
938 But there is no general naming scheme for roff documents, though
942 is seen now and then.
944 Maybe there should be a standardization for the filename extensions of
948 File name extensions can be very handy in conjunction with the
952 It provides the possibility to feed all input into a command-line pipe
953 that is specified in the shell environment variable
955 This process is not well documented, so here an example:
958 .ShellCommand LESSOPEN='|lesspipe %s'
963 is either a system supplied command or a shell script of your own.
966 .\" --------------------------------------------------------------------
968 .\" --------------------------------------------------------------------
970 The best program for editing a roff document is Emacs (or Xemacs), see
974 mode that is suitable for all kinds of roff dialects.
976 This mode can be activated by the following methods.
979 When editing a file within Emacs the mode can be changed by typing
980 .RI ` "M-x nroff-mode" ',
983 means to hold down the
992 But it is also possible to have the mode automatically selected when
993 the file is loaded into the editor.
996 The most general method is to include the following 3 comment lines at
1001 .B \*[Comment] Local Variables:
1002 .B \*[Comment] mode: nroff
1007 There is a set of file name extensions, e.g. the man pages that
1008 trigger the automatic activation of the nroff mode.
1011 Theoretically, it is possible to write the sequence
1013 .B \*[Comment] \%-*-\ nroff\ -*-
1015 as the first line of a file to have it started in nroff mode when
1018 Unfortunately, some applications such as the
1020 program are confused by this; so this is deprecated.
1023 All roff formatters provide automated line breaks and horizontal and
1026 In order to not disturb this, the following tips can be helpful.
1029 Never include empty or blank lines in a roff document.
1031 Instead, use the empty request (a line consisting of a dot only) or a
1034 if a structuring element is needed.
1037 Never start a line with whitespace because this can lead to
1038 unexpected behavior.
1040 Indented paragraphs can be constructed in a controlled way by roff
1044 Start each sentence on a line of its own, for the spacing after a dot
1045 is handled differently depending on whether it terminates an
1046 abbreviation or a sentence.
1048 To distinguish both cases, do a line break after each sentence.
1051 To additionally use the auto-fill mode in Emacs, it is best to insert
1052 an empty roff request (a line consisting of a dot only) after each
1056 The following example shows how optimal roff editing could look.
1060 This is an example for a roff document.
1062 This is the next sentence in the same paragraph.
1064 This is a longer sentence stretching over several
1065 lines; abbreviations like `cf.' are easily
1066 identified because the dot is not followed by a
1069 In the output, this will still go to the same
1074 Besides Emacs, some other editors provide nroff style files too, e.g.\&
1081 .\" --------------------------------------------------------------------
1083 .\" --------------------------------------------------------------------
1086 is a registered trademark of the Open Group.
1088 But things have improved considerably after Caldera had bought SCO
1092 .\" --------------------------------------------------------------------
1094 .\" --------------------------------------------------------------------
1096 There is a lot of documentation on roff.
1098 The original papers on classical troff are still available, and all
1099 aspects of groff are documented in great detail.
1102 .\" --------------------------------------------------------------------
1103 .SS "Internet sites"
1104 .\" --------------------------------------------------------------------
1108 .URL http://\:www.troff.org "The historical troff site"
1109 provides an overview and pointers to all historical aspects of roff.
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, 2003, 2004 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".
1272 .\" --------------------------------------------------------------------
1274 .\" --------------------------------------------------------------------
1276 .\" Local Variables: