5 This file is part of groff, the GNU roff type-setting system.
7 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008
8 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.
23 .\" --------------------------------------------------------------------
29 . nop \f[B]\[rs]\\*[@1]\f[]\\$*
37 . nop `\f[B]\\*[@1]\f[]'\\$*
42 .\" --------------------------------------------------------------------
44 .\" --------------------------------------------------------------------
46 .TH ROFF @MAN7EXT@ "@MDATE@" "Groff Version @VERSION@"
48 roff \- concepts and history of roff typesetting
51 .\" --------------------------------------------------------------------
53 .\" --------------------------------------------------------------------
56 is the general name for a set of type-setting programs, known under
66 type-setting system consists of an extensible text formatting language
67 and a set of programs for printing and converting to other text
70 Traditionally, it is the main text processing system of Unix; every
71 Unix-like operating system still distributes a
73 system as a core package.
78 system today is the free software implementation \f[CR]GNU\f[]
80 .BR groff (@MAN1EXT@).
84 implementations are referred to as
86 (dating back as long as 1973).
89 implements the look-and-feel and functionality of its classical
90 ancestors, but has many extensions.
93 In some ancient Unix systems, there was a binary called
95 that implemented the even more ancient
99 operating system, cf.\& section
102 The functionality of this program was very restricted even in
103 comparison to ancient
105 it is not supported any longer.
107 Consequently, in this document, the term
109 always refers to the general meaning of
118 is in wide use today, for example, the manual pages on UNIX systems
119 .RI ( man\~pages\/ ),
120 many software books, system documentation, standards, and corporate
121 documents are written in roff.
125 output for text devices is still unmatched, and its graphical output
126 has the same quality as other free type-setting programs and is better
127 than some of the commercial systems.
130 The most popular application of
136 this is the standard documentation system on many operating systems.
139 This document describes the historical facts around the development
142 some usage aspects common to all
144 versions, details on the
146 pipeline, which is usually hidden behind front-ends like
147 .BR groff (@MAN1EXT@);
148 a general overview of the formatting language; some tips for editing
150 files; and many pointers to further readings.
153 .\" --------------------------------------------------------------------
155 .\" --------------------------------------------------------------------
159 text processing system has a very long history, dating back to the
164 system itself is intimately connected to the Unix operating system,
165 but its roots go back to the earlier operating systems CTSS and
169 .\" --------------------------------------------------------------------
170 .SS "The Predecessor RUNOFF"
171 .\" --------------------------------------------------------------------
176 is intimately related to the history of the operating systems.
185 .RI ( "Compatible Time Sharing System" )
186 as early as 1964 \[en] note that CTSS commands were all uppercase.
188 When CTSS was further developed into the operating system
189 .UR http://\:www.multicians.org
192 the famous predecessor of Unix from 1963,
194 has been improved further by people from the Massachusetts Institute of
195 Technology (MIT) and the Bell Technical Laboratory (BTL), including Dennis
196 Ritchie and Joe Ossanna.
198 .BR "Multics runoff" ,
199 for example, was now able to do two-pass operations; it became the main
200 format for documentation and text processing.
202 Both operating systems could only be run on very expensive computers
203 at that time, so they were mostly used in research and for official
207 The possibilities of the
209 language were quite limited as compared to modern
212 Only text output was possible in the 1960s.
214 This could be implemented by a set of requests of length\~2, many of
215 which are still identically used in
218 The language was modelled according to the habits of typesetting in
219 the pre-computer age, where lines starting with a dot were used in
220 manuscripts to denote formatting requests to the person who would
221 perform the typesetting manually later on.
224 The runoff program was written in the
226 language first, later on in
229 .IR "Doug McIlroy" ),
230 the grandmother of the
232 programming language.
234 In the Multics operating system, the help system was handled by
237 task to manage the Unix manual pages.
239 On the other hand, BCPL and runoff were ported to the GCOS system
240 at Bell Labs since BTL left the development of Multics.
243 There are still documents written in the RUNOFF language; for examples
244 see Saltzer's home page, cf.\& section
248 .\" --------------------------------------------------------------------
249 .SS "The Classical nroff/troff System"
250 .\" --------------------------------------------------------------------
252 At the Bell Labs, there was a need to
254 .I Graphic Systems CAT
255 typesetter, a graphical output device from a PDP-11 computer running
258 rewrote runoff for the PDP-11; however, as runoff was too limited for
259 the CAT it was further developed into the more powerful
263 .IR "Joseph F.\& Ossanna" ,
264 who already programmed several runoff ports.
266 On the hardware side, Ossanna wired the nominal paper-tape reader of
267 the CAT straight into the PDP-11.
275 The greatly enlarged language of Ossanna's concept included already all
281 systems try to implement compatibility to this system.
283 So Joe Ossanna can be called the father of all
290 had three formatter programs.
294 .RI ( "typesetter roff\/" )
295 generated a graphical output for the
297 typesetter as its only device.
301 produced text output suitable for terminals and line printers.
305 was the reimplementation of the former
307 program with its limited features; this program was abandoned in later
312 is used to refer to a
317 Ossanna's first version was written in the PDP-11 assembly language and
323 development by rewriting it in the C\~programming language.
325 The C\~version was released in 1975.
328 The syntax of the formatting language of the
330 programs was documented in the famous
331 .IR "Troff User's Manual [CSTR\~#54]" ,
332 first published in 1976, with further revisions up to 1992 by Brian
335 This document is the specification of the
336 .IR "classical troff" .
340 systems tried to establish compatibility with this specification.
343 After Ossanna had died in 1977 by a heart-attack at the age of about\~50,
344 Kernighan went on with developing
347 The next milestone was to equip
349 with a general interface to support more devices, the intermediate
350 output format and the postprocessor system.
352 This completed the structure of a
354 as it is still in use today; see section
357 In 1979, these novelties were described in the paper
362 version is the basis for all existing newer
367 On some systems, this
368 .I device independent troff
369 got a binary of its own, called
370 .BR ditroff (@MAN7EXT@).
374 programs already provide the full
376 capabilities automatically.
379 .\" --------------------------------------------------------------------
380 .SS "Commercialization"
381 .\" --------------------------------------------------------------------
383 A major degradation occurred when the easily available Unix\~7
384 operating system was commercialized.
386 A whole bunch of divergent operating systems emerged, fighting each
387 other with incompatibilities in their extensions.
389 Luckily, the incompatibilities did not fight the original
392 All of the different commercial
394 systems made heavy use of Ossanna/\:Kernighan's open source code and
395 documentation, but sold them as \[lq]their\[rq] system \[en] with only
399 The source code of both the ancient Unix and classical
401 wasn't available for two decades.
403 Meanwhile, it is accessible again (on-line) for non-commercial use,
408 .\" --------------------------------------------------------------------
410 .\" --------------------------------------------------------------------
412 The most important free
414 project was the \f[CR]GNU\f[] implementation of
416 written from scratch by James Clark and put under the
417 .UR http://\:www.gnu.org/\:copyleft
427 .BR groff (@MAN1EXT@)
433 system is still actively developed.
435 It is compatible to the classical
437 but many extensions were added.
441 system that is available on almost all operating systems \[en] and it
451 An alternative is Gunnar Ritter's
452 .UR http://\:heirloom.sf.net
453 Heirloom Documentation Tools
455 project, started in 2005, which provides enhanced versions of the various
456 roff tools found in the OpenSolaris and Plan\~9 operating systems, now
457 available under free licenses.
460 .\" --------------------------------------------------------------------
462 .\" --------------------------------------------------------------------
464 Most people won't even notice that they are actually using
467 When you read a system manual page (man page)
469 is working in the background.
472 documents can be viewed with a native viewer called
474 a standard program of the X window distribution, see
479 explicitly isn't difficult either.
484 implementations provide wrapper programs that make it easy to use the
486 system on the shell command line.
488 For example, the \f[CR]GNU\f[]
491 .BR groff (@MAN1EXT@)
492 provides command line options to avoid the long command pipes of
497 tries to guess from the document which arguments should be used for a
500 people who do not like specifying command line options should try the
501 .BR groffer (@MAN1EXT@)
502 program for graphically displaying
507 .\" --------------------------------------------------------------------
509 .\" --------------------------------------------------------------------
513 system consists of preprocessors,
515 formatter programs, and a set of device postprocessors.
517 This concept makes heavy use of the
519 mechanism, that is, a series of programs is called one after the other,
520 where the output of each program in the queue is taken as the input
521 for the next program.
527 | \f[I]preproc\f[P] \
529 | troff \f[I]options\f[P] \
534 The preprocessors generate
536 code that is fed into a
540 which in turn generates
541 .I intermediate output
542 that is fed into a device postprocessor program for printing or final
546 All of these parts use programming languages of their own; each
547 language is totally unrelated to the other parts.
551 macro packages that were tailored for special purposes can be
557 documents use the macros of some package, intermixed with code for one
558 or more preprocessors, spiced with some elements from the plain
562 The full power of the
564 formatting language is seldom needed by users; only programmers of
565 macro packages need to know about the gory details.
569 .\" --------------------------------------------------------------------
571 .\" --------------------------------------------------------------------
575 preprocessor is any program that generates output that syntactically
576 obeys the rules of the
580 Each preprocessor defines a language of its own that is translated
583 code when run through the preprocessor program.
585 Parts written in these languages may be included within a
587 document; they are identified by special
591 Each document that is enhanced by preprocessor code must be run
592 through all corresponding preprocessors before it is fed into the
595 formatter program, for the formatter just ignores all alien code.
597 The preprocessor programs extract and transform only the document
598 parts that are determined for them.
601 There are a lot of free and commercial
605 Some of them aren't available on each system, but there is a small
606 set of preprocessors that are considered as an integral part of each
610 The classical preprocessors are
617 eqn@for mathematical formul\[ae].
618 pic@for drawing diagrams.
619 refer@for bibliographic references.
620 soelim@for including macro files from standard locations.
621 chem@for drawing chemical formul\[ae].
626 Other known preprocessors that are not available on all systems
633 grap@for constructing graphical elements.
634 grn@for including \fBgremlin\fR(1) pictures.
638 .\" --------------------------------------------------------------------
639 .SS "Formatter Programs"
640 .\" --------------------------------------------------------------------
644 is a program that parses documents written in the
646 formatting language or uses some of the
651 .IR "intermediate output" ,
652 which is intended to be fed into a single device postprocessor that
653 must be specified by a command-line option to the formatter program.
655 The documents must have been run through all necessary preprocessors
659 The output produced by a
661 formatter is represented in yet another language, the
662 .IR "intermediate output format"
666 This language was first specified in
668 its \f[CR]GNU\f[] extension is documented in
669 .BR groff_out (@MAN5EXT@).
671 The intermediate output language is a kind of assembly language
672 compared to the high-level
676 The generated intermediate output is optimized for a special device,
677 but the language is the same for every device.
682 formatter is the heart of the
692 for graphical devices.
697 is used as a general term to refer to both formatters.
700 .\" --------------------------------------------------------------------
701 .SS "Devices and Postprocessors"
702 .\" --------------------------------------------------------------------
704 Devices are hardware interfaces like printers, text or graphical
705 terminals, etc., or software interfaces such as a conversion into a
706 different text or graphical format.
711 postprocessor is a program that transforms
713 output into a form suitable for a special device.
717 postprocessors are like device drivers for the output target.
720 For each device there is a postprocessor program that fits the device
723 The postprocessor parses the generated intermediate output and
724 generates device-specific code that is sent directly to the device.
727 The names of the devices and the postprocessor programs are not fixed
728 because they greatly depend on the software and hardware abilities of
731 For example, the classical devices mentioned in
733 have greatly changed since the classical times.
735 The old hardware doesn't exist any longer and the old graphical
736 conversions were quite imprecise when compared to their modern
740 For example, the Postscript device
744 had a resolution of 720 units per inch, while
747 device has 72000, a refinement of factor 100.
750 Today the operating systems provide device drivers for most
751 printer-like hardware, so it isn't necessary to write a special
752 hardware postprocessor for each printer.
755 .\" --------------------------------------------------------------------
756 .SH "ROFF PROGRAMMING"
757 .\" --------------------------------------------------------------------
761 are normal text files decorated by
767 formatting language is quite powerful; it is almost a full programming
768 language and provides elements to enlarge the language.
770 With these, it became possible to develop macro packages that are
771 tailored for special applications.
773 Such macro packages are much handier than plain
776 So most people will choose a macro package without worrying about the
782 .\" --------------------------------------------------------------------
784 .\" --------------------------------------------------------------------
786 Macro packages are collections of macros that are suitable to format a
787 special kind of documents in a convenient way.
789 This greatly eases the usage of
792 The macro definitions of a package are kept in a file called
798 All tmac files are stored in one or more directories at standardized
801 Details on the naming of macro packages and their placement is found
803 .BR groff_tmac (@MAN5EXT@).
806 A macro package that is to be used in a document can be announced to
807 the formatter by the command line option
810 .BR troff (@MAN1EXT@),
811 or it can be specified within a document using the file inclusion
815 .BR groff (@MAN7EXT@).
818 Famous classical macro packages are
820 for traditional man pages,
822 for \f[CR]BSD\f[]-style manual pages;
823 the macro sets for books, articles, and letters are
825 (probably from the first name of its creator
830 .IR "Manuscript Macros\/" ),
834 .IR "Memorandum Macros\/" ).
837 .\" --------------------------------------------------------------------
838 .SS "The roff Formatting Language"
839 .\" --------------------------------------------------------------------
843 formatting language is documented in the
844 .I Troff User's Manual
849 language is a full programming language providing requests, definition
850 of macros, escape sequences, string variables, number or size
851 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
862 These are then called
865 A document writer will not note any difference in usage for requests
866 or macros; both are written on a line on their own starting with a dot.
872 elements starting with a backslash
875 They can be inserted anywhere, also in the midst of text in a line.
877 They are used to implement various features, including the insertion of
878 non-\f[CR]ASCII\f[] characters with
882 in-line comments with
884 the escaping of special control characters like
886 and many other features.
890 are variables that can store a string.
892 A string is stored by the
896 The stored string can be retrieved later by the
902 store numbers and sizes.
904 A register can be set with the request
906 and its value can be retrieved by the escape sequence
910 .\" --------------------------------------------------------------------
911 .SH "FILE NAME EXTENSIONS"
912 .\" --------------------------------------------------------------------
914 Manual pages (man pages) take the section number as a file name
915 extension, e.g., the filename for this document is
917 i.e., it is kept in section\~7
921 The classical macro packages take the package name as an extension, e.g.\&
923 for a document using the
939 But there is no general naming scheme for
945 is seen now and then.
947 Maybe there should be a standardization for the filename extensions of
952 File name extensions can be very handy in conjunction with the
956 It provides the possibility to feed all input into a command-line pipe
957 that is specified in the shell environment variable
960 This process is not well documented, so here an example:
965 LESSOPEN='|lesspipe %s'
972 is either a system supplied command or a shell script of your own.
975 .\" --------------------------------------------------------------------
977 .\" --------------------------------------------------------------------
979 The best program for editing a
981 document is Emacs (or Xemacs), see
986 mode that is suitable for all kinds of
990 This mode can be activated by the following methods.
993 When editing a file within Emacs the mode can be changed by typing
994 .RI ` "M-x nroff-mode" ',
997 means to hold down the
1006 But it is also possible to have the mode automatically selected when
1007 the file is loaded into the editor.
1010 The most general method is to include the following 3 comment lines at
1011 the end of the file.
1016 \&.\[rs]" Local Variables:
1017 \&.\[rs]" mode: nroff
1023 There is a set of file name extensions, e.g.\& the man pages that
1024 trigger the automatic activation of the
1029 Theoretically, it is possible to write the sequence
1034 \&.\[rs]" \%-*-\ nroff\ -*-
1039 as the first line of a file to have it started in
1043 Unfortunately, some applications such as the
1045 program are confused by this; so this is deprecated.
1050 formatters provide automated line breaks and horizontal and vertical
1053 In order to not disturb this, the following tips can be helpful.
1056 Never include empty or blank lines in a
1060 Instead, use the empty request (a line consisting of a dot only) or a
1063 if a structuring element is needed.
1066 Never start a line with whitespace because this can lead to
1067 unexpected behavior.
1069 Indented paragraphs can be constructed in a controlled way by
1074 Start each sentence on a line of its own, for the spacing after a dot
1075 is handled differently depending on whether it terminates an
1076 abbreviation or a sentence.
1078 To distinguish both cases, do a line break after each sentence.
1081 To additionally use the auto-fill mode in Emacs, it is best to insert
1084 request (a line consisting of a dot only) after each sentence.
1087 The following example shows how optimal
1094 This is an example for a
1098 This is the next sentence in the same paragraph.
1100 This is a longer sentence stretching over several
1101 lines; abbreviations like `cf.' are easily
1102 identified because the dot is not followed by a
1105 In the output, this will still go to the same
1111 Besides Emacs, some other editors provide
1113 style files too, e.g.\&
1120 .\" --------------------------------------------------------------------
1122 .\" --------------------------------------------------------------------
1124 There is a lot of documentation on
1127 The original papers on classical
1129 are still available, and all aspects of
1131 are documented in great detail.
1134 .\" --------------------------------------------------------------------
1135 .SS "Internet sites"
1136 .\" --------------------------------------------------------------------
1140 .UR http://\:www.troff.org
1141 The historical troff site
1143 provides an overview and pointers to all historical aspects of
1148 .UR http://\:www.multicians.org
1151 contains a lot of information on the MIT projects, CTSS, Multics,
1152 early Unix, including
1154 especially useful are a glossary and the many links to ancient
1159 .UR http://\:www.tuhs.org/\:Archive/
1160 The Ancient Unixes Archive
1163 provides the source code and some binaries of the ancient Unixes
1164 (including the source code of
1166 and its documentation) that were made public by Caldera since 2001,
1167 e.g.\& of the famous Unix version\~7 for PDP-11 at the
1168 .UR http://\:www.tuhs.org/\:Archive/\:PDP-11/\:Trees/\:V7
1173 Developers at AT&T Bell Labs
1174 .UR http://\:www.bell-labs.com/
1175 Bell Labs Computing and Mathematical Sciences Research
1178 provides a search facility for tracking information on the early
1183 .UR http://\:plan9.bell-labs.com
1184 The Plan\~9 operating system
1191 .UR http://\:web.mit.edu/\:Saltzer/\:www/\:publications/\:pubs.html
1192 Jerry Saltzer's home page
1195 stores some documents using the ancient RUNOFF formatting language.
1199 .UR http://\:cm.bell-labs.com/\:cm/\:cs/\:cstr.html
1200 The Bell Labs CSTR site
1205 manuals (CSTR #54, #97, #114, #116, #122) and famous historical
1206 documents on programming.
1209 \f[CR]GNU\f[] \f[I]roff\f[]
1210 .UR http://\:www.gnu.org/\:software/\:groff
1221 .\" --------------------------------------------------------------------
1222 .SS "Historical roff Documentation"
1223 .\" --------------------------------------------------------------------
1227 documents are still available on-line.
1229 The two main manuals of the
1236 .UR http://\:cm.bell-labs.com/\:cm/\:cs/\:cstr/\:54.ps.gz
1237 .I "Nroff/\:Troff User's Manual"
1240 Bell Labs, 1976; revised by Brian Kernighan, 1992.
1245 .UR http://\:cm.bell-labs.com/\:cm/\:cs/\:cstr/\:97.ps.gz
1246 .I "A Typesetter-independent TROFF"
1249 Bell Labs, 1981, revised March 1982.
1252 The \[lq]little language\[rq]
1258 Jon L. Bentley and Brian W. Kernighan,
1259 .UR http://\:cm.bell-labs.com/\:cm/\:cs/\:cstr/\:114.ps.gz
1260 .I "GRAP \[en] A Language for Typesetting Graphs"
1263 Bell Labs, August 1984.
1268 .UR http://\:cm.bell-labs.com/\:cm/\:cs/\:cstr/\:116.ps.gz
1269 .I "PIC \[en] A Graphics Language for Typesetting"
1272 Bell Labs, December 1984.
1276 J. L. Bentley, L. W. Jelinski, and B. W. Kernighan,
1277 .UR http://\:cm.bell-labs.com/\:cm/\:cs/\:cstr/\:122.ps.gz
1278 .I "CHEM \[en] A Program for Typesetting Chemical Structure Diagrams,"
1279 .I "Computers and Chemistry"
1282 Bell Labs, April 1986.
1285 .\" --------------------------------------------------------------------
1287 .\" --------------------------------------------------------------------
1289 Due to its complex structure, a full
1291 system has many man pages, each describing a single aspect of
1294 Unfortunately, there is no general naming scheme for the documentation
1303 .BR groff (@MAN1EXT@)
1304 contains a survey of all documentation available in
1308 On other systems, you are on your own, but
1310 might be a good starting point.
1313 .\" --------------------------------------------------------------------
1315 .\" --------------------------------------------------------------------
1317 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008
1318 Free Software Foundation, Inc.
1321 This document is distributed under the terms of the \f[CR]FDL\f[]
1322 (\f[CR]GNU Free Documentation License\f[]) version 1.1 or later.
1324 You should have received a copy of the \f[CR]FDL\f[] on your system,
1325 it is also available on-line at the
1326 .UR http://\:www.gnu.org/\:copyleft/\:fdl.html
1331 This document is part of
1346 .\" --------------------------------------------------------------------
1348 .\" --------------------------------------------------------------------
1350 .\" Local Variables: