4 Last update: 18 Nov 2006
6 This file is part of groff, the GNU roff type-setting system.
8 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006
9 Free Software Foundation, Inc.
10 written by Bernd Warken <bwarken@mayn.de>
11 maintained by Werner Lemberg <wl@gnu.org>
13 Permission is granted to copy, distribute and/or modify this document
14 under the terms of the GNU Free Documentation License, Version 1.1 or
15 any later version published by the Free Software Foundation; with the
16 Invariant Sections being this .ig-section and AUTHORS, with no
17 Front-Cover Texts, and with no Back-Cover Texts.
19 A copy of the Free Documentation License is included as a file called
20 FDL in the main directory of the groff source package.
23 .\" --------------------------------------------------------------------
25 .\" --------------------------------------------------------------------
44 .\" --------------------------------------------------------------------
45 .\" String definitions
47 .\" Final `\""' comments are used to make Emacs happy, sic \""
49 .\" The `-' sign for options.
59 .ds Comment \.\[rs]\[dq]\"
60 .ds Ellipsis \.\|.\|.\&\"
63 .\" --------------------------------------------------------------------
64 .\" Begin of macro definitions
67 .\" this is like a comment request when escape mechanism is off
72 .c ---------------------------------------------------------------------
88 . Text \f[B]\[rs]\*[@1]\f[]\$*
95 . nop `\f[B]\*[@1]\f[]'\$*
99 .c --------------------------------------------------------------------
101 .c a shell command line
106 . Text \f[I]sh#\h'1m'\f[]\f[CR]\$*\f[]\&\"
113 .c --------------------------------------------------------------------
115 .c ShortOpt ([c [punct]])
117 .c `-c' somewhere in the text.
118 .c The second argument is some trailing punctuation.
124 . Text \f[CB]\*[@-]\f[]\f[B]\*[@1]\f[]\/\$*
135 .c --------------------------------------------------------------------
145 .\" End of macro definitions
148 .\" --------------------------------------------------------------------
150 .\" --------------------------------------------------------------------
152 .TH ROFF @MAN7EXT@ "@MDATE@" "Groff Version @VERSION@"
154 roff \- concepts and history of roff typesetting
157 .\" --------------------------------------------------------------------
159 .\" --------------------------------------------------------------------
162 is the general name for a set of type-setting programs, known under
172 type-setting system consists of an extensible text formatting language
173 and a set of programs for printing and converting to other text
176 Traditionally, it is the main text processing system of Unix; every
177 Unix-like operating system still distributes a
179 system as a core package.
184 system today is the free software implementation \f[CR]GNU\f[]
186 .BR groff (@MAN1EXT@).
190 implementations are referred to as
192 (dating back as long as 1973).
195 implements the look-and-feel and functionality of its classical
196 ancestors, but has many extensions.
199 In some ancient Unix systems, there was a binary called
201 that implemented the even more ancient
205 operating system, cf.\& section
207 The functionality of this program was very restricted even in
208 comparison to ancient
210 it is not supported any longer.
212 Consequently, in this document, the term
214 always refers to the general meaning of
223 is in wide use today, for example, the manual pages on UNIX systems
224 .RI ( man\~pages\/ ),
225 many software books, system documentation, standards, and corporate
226 documents are written in roff.
230 output for text devices is still unmatched, and its graphical output
231 has the same quality as other free type-setting programs and is better
232 than some of the commercial systems.
235 The most popular application of
241 this is the standard documentation system on many operating systems.
244 This document describes the historical facts around the development
247 some usage aspects common to all
249 versions, details on the
251 pipeline, which is usually hidden behind front-ends like
252 .BR groff (@MAN1EXT@);
253 a general overview of the formatting language; some tips for editing
255 files; and many pointers to further readings.
258 .\" --------------------------------------------------------------------
260 .\" --------------------------------------------------------------------
264 text processing system has a very long history, dating back to the
269 system itself is intimately connected to the Unix operating system,
270 but its roots go back to the earlier operating systems CTSS and
274 .\" --------------------------------------------------------------------
275 .SS "The Predecessor RUNOFF"
276 .\" --------------------------------------------------------------------
281 is intimately related to the history of the operating systems.
290 .RI ( "Compatible Time Sharing System" )
291 as early as 1964 \[en] note that CTSS commands were all uppercase.
293 When CTSS was further developed into the operating system
294 .URL http://\:www.multicians.org "Multics" ,
295 the famous predecessor of Unix from 1963,
297 has been improved further by people from the Massachusetts Institute of
298 Technology (MIT) and the Bell Technical Laboratory (BTL), including Dennis
299 Ritchie and Joe Ossanna.
301 .BR "Multics runoff" ,
302 for example, was now able to do two-pass operations; it became the main
303 format for documentation and text processing.
305 Both operating systems could only be run on very expensive computers
306 at that time, so they were mostly used in research and for official
310 The possibilities of the
312 language were quite limited as compared to modern
315 Only text output was possible in the 1960s.
317 This could be implemented by a set of requests of length\~2, many of
318 which are still identically used in
321 The language was modelled according to the habits of typesetting in
322 the pre-computer age, where lines starting with a dot were used in
323 manuscripts to denote formatting requests to the person who would
324 perform the typesetting manually later on.
327 The runoff program was written in the
329 language first, later on in
331 the grandmother of the
333 programming language.
335 In the Multics operating system, the help system was handled by
338 task to manage the Unix manual pages.
340 On the other hand, BCPL and runoff were ported to the GCOS system
341 at Bell Labs since BTL left the development of Multics.
344 There are still documents written in the RUNOFF language; for examples
345 see Saltzer's home page, cf.\& section
349 .\" --------------------------------------------------------------------
350 .SS "The Classical nroff/troff System"
351 .\" --------------------------------------------------------------------
353 At the Bell Labs, there was a need to
355 .I Graphic Systems CAT
356 typesetter, a graphical output device from a PDP-11 computer running
359 As runoff was too limited for this task it was further developed into
360 a more powerful text formatting system by
361 .IR "Josef F. Osanna" ,
362 who already programmed several runoff ports.
369 The greatly enlarged language of Osanna's concept included already all
375 systems try to implement compatibility to this system.
377 So Joe Osanna can be called the father of all
384 had three formatter programs.
388 .RI ( "typesetter roff\/" )
389 generated a graphical output for the
391 typesetter as its only device.
395 produced text output suitable for terminals and line printers.
399 was the reimplementation of the former
401 program with its limited features; this program was abandoned in later
406 is used to refer to a
411 Osanna's first version was written in the PDP-11 assembly language and
417 development by rewriting it in the C\~programming language.
419 The C\~version was released in 1975.
422 The syntax of the formatting language of the
424 programs was documented in the famous
425 .IR "Troff User's Manual [CSTR\~#54]" ,
426 first published in 1976, with further revisions up to 1992 by Brian
429 This document is the specification of the
430 .IR "classical troff" .
433 systems tried to establish compatibility with this specification.
436 After Osanna had died in 1977 by a heart-attack at the age of about\~50,
437 Kernighan went on with developing
440 The next milestone was to equip
442 with a general interface to support more devices, the intermediate
443 output format and the postprocessor system.
445 This completed the structure of a
447 as it is still in use today; see section
450 In 1979, these novelties were described in the paper
454 version is the basis for all existing newer
459 On some systems, this
460 .I device independent troff
461 got a binary of its own, called
462 .BR ditroff (@MAN7EXT@).
466 programs already provide the full
468 capabilities automatically.
471 .\" --------------------------------------------------------------------
472 .SS "Commercialization"
473 .\" --------------------------------------------------------------------
475 A major degradation occurred when the easily available Unix\~7
476 operating system was commercialized.
478 A whole bunch of divergent operating systems emerged, fighting each
479 other with incompatibilities in their extensions.
481 Luckily, the incompatibilities did not fight the original
484 All of the different commercial
486 systems made heavy use of Osanna/\:Kernighan's open source code and
487 documentation, but sold them as \[lq]their\[rq] system \[em] with only
491 The source code of both the ancient Unix and classical
493 weren't available for two decades.
495 Fortunately, Caldera bought SCO UNIX in 2001.
497 In the following, Caldera made the ancient source code accessible
498 on-line for non-commercial use, cf. section
502 .\" --------------------------------------------------------------------
504 .\" --------------------------------------------------------------------
506 The most important free
508 project was the \f[CR]GNU\f[] implementation of
510 written from scratch by James Clark and put under the
511 .URL http://\:www.gnu.org/\:copyleft "GNU Public License" .
518 .BR groff (@MAN1EXT@)
524 system is still actively developed.
526 It is compatible to the classical
528 but many extensions were added.
532 system that is available on almost all operating systems \[em] and it
542 An alternative is Gunnar Ritter's
543 .URL http://\:heirloom.sf.net "Heirloom Documentation Tools"
544 project, started in 2005, which provides enhanced versions of the various
545 roff tools found in the OpenSolaris and Plan\~9 operating systems, now
546 available under free licenses.
549 .\" --------------------------------------------------------------------
551 .\" --------------------------------------------------------------------
553 Most people won't even notice that they are actually using
556 When you read a system manual page (man page)
558 is working in the background.
561 documents can be viewed with a native viewer called
563 a standard program of the X window distribution, see
568 explicitly isn't difficult either.
573 implementations provide wrapper programs that make it easy to use the
575 system on the shell command line.
577 For example, the \f[CR]GNU\f[]
580 .BR groff (@MAN1EXT@)
581 provides command line options to avoid the long command pipes of
586 tries to guess from the document which arguments should be used for a
589 people who do not like specifying command line options should try the
590 .BR groffer (@MAN1EXT@)
591 program for graphically displaying
596 .\" --------------------------------------------------------------------
598 .\" --------------------------------------------------------------------
602 system consists of preprocessors,
604 formatter programs, and a set of device postprocessors.
606 This concept makes heavy use of the
608 mechanism, that is, a series of programs is called one after the other,
609 where the output of each program in the queue is taken as the input
610 for the next program.
614 .ds @1 "cat \f[I]file\f[P] |\""
615 .ds @2 "\*[Ellipsis] | \f[I]preproc\f[P] | \*[Ellipsis] |\""
616 .ds @3 "troff \f[I]options\f[P] | \f[I]postproc\f[P]\""
618 .ShellCommand "\*[@1] \*[@2] \*[@3]"
624 The preprocessors generate
626 code that is fed into a
630 which in turn generates
631 .I intermediate output
632 that is fed into a device postprocessor program for printing or final
636 All of these parts use programming languages of their own; each
637 language is totally unrelated to the other parts.
641 macro packages that were tailored for special purposes can be
647 documents use the macros of some package, intermixed with code for one
648 or more preprocessors, spiced with some elements from the plain
652 The full power of the
654 formatting language is seldom needed by users; only programmers of
655 macro packages need to know about the gory details.
659 .\" --------------------------------------------------------------------
661 .\" --------------------------------------------------------------------
665 preprocessor is any program that generates output that syntactically
666 obeys the rules of the
670 Each preprocessor defines a language of its own that is translated
673 code when run through the preprocessor program.
675 Parts written in these languages may be included within a
677 document; they are identified by special
681 Each document that is enhanced by preprocessor code must be run
682 through all corresponding preprocessors before it is fed into the
685 formatter program, for the formatter just ignores all alien code.
687 The preprocessor programs extract and transform only the document
688 parts that are determined for them.
691 There are a lot of free and commercial
695 Some of them aren't available on each system, but there is a small
696 set of preprocessors that are considered as an integral part of each
700 The classical preprocessors are
704 .\" local indent for .TP
705 .TP \\w'\\f[B]soelim\\f[P]'u+2n
715 for mathematical formul\[ae].
718 for drawing diagrams.
721 for bibliographic references.
724 for including macro files from standard locations.
727 for drawing chemical formul\[ae].
732 Other known preprocessors that are not available on all systems
740 for constructing graphical elements.
751 .\" --------------------------------------------------------------------
752 .SS "Formatter Programs"
753 .\" --------------------------------------------------------------------
757 is a program that parses documents written in the
759 formatting language or uses some of the
764 .IR "intermediate output" ,
765 which is intended to be fed into a single device postprocessor that
766 must be specified by a command-line option to the formatter program.
768 The documents must have been run through all necessary preprocessors
772 The output produced by a
774 formatter is represented in yet another language, the
775 .IR "intermediate output format"
778 This language was first specified in
780 its \f[CR]GNU\f[] extension is documented in
781 .BR groff_out (@MAN5EXT@).
783 The intermediate output language is a kind of assembly language
784 compared to the high-level
788 The generated intermediate output is optimized for a special device,
789 but the language is the same for every device.
794 formatter is the heart of the
804 for graphical devices.
809 is used as a general term to refer to both formatters.
812 .\" --------------------------------------------------------------------
813 .SS "Devices and Postprocessors"
814 .\" --------------------------------------------------------------------
816 Devices are hardware interfaces like printers, text or graphical
817 terminals, etc., or software interfaces such as a conversion into a
818 different text or graphical format.
823 postprocessor is a program that transforms
825 output into a form suitable for a special device.
829 postprocessors are like device drivers for the output target.
832 For each device there is a postprocessor program that fits the device
835 The postprocessor parses the generated intermediate output and
836 generates device-specific code that is sent directly to the device.
839 The names of the devices and the postprocessor programs are not fixed
840 because they greatly depend on the software and hardware abilities of
843 For example, the classical devices mentioned in
845 have greatly changed since the classical times.
847 The old hardware doesn't exist any longer and the old graphical
848 conversions were quite imprecise when compared to their modern
852 For example, the Postscript device
856 had a resolution of 720, while
859 device has 72000, a refinement of factor 100.
862 Today the operating systems provide device drivers for most
863 printer-like hardware, so it isn't necessary to write a special
864 hardware postprocessor for each printer.
867 .\" --------------------------------------------------------------------
868 .SH "ROFF PROGRAMMING"
869 .\" --------------------------------------------------------------------
873 are normal text files decorated by
879 formatting language is quite powerful; it is almost a full programming
880 language and provides elements to enlarge the language.
882 With these, it became possible to develop macro packages that are
883 tailored for special applications.
885 Such macro packages are much handier than plain
888 So most people will choose a macro package without worrying about the
894 .\" --------------------------------------------------------------------
896 .\" --------------------------------------------------------------------
898 Macro packages are collections of macros that are suitable to format a
899 special kind of documents in a convenient way.
901 This greatly eases the usage of
904 The macro definitions of a package are kept in a file called
910 All tmac files are stored in one or more directories at standardized
913 Details on the naming of macro packages and their placement is found
915 .BR groff_tmac (@MAN5EXT@).
918 A macro package that is to be used in a document can be announced to
919 the formatter by the command line option
922 .BR troff (@MAN1EXT@),
923 or it can be specified within a document using the file inclusion
927 .BR groff (@MAN7EXT@).
930 Famous classical macro packages are
932 for traditional man pages,
934 for \f[CR]BSD\f[]-style manual pages;
935 the macro sets for books, articles, and letters are
937 (probably from the first name of its creator
942 .IR "Manuscript Macros\/" ),
946 .IR "Memorandum Macros\/" ).
949 .\" --------------------------------------------------------------------
950 .SS "The roff Formatting Language"
951 .\" --------------------------------------------------------------------
955 formatting language is documented in the
956 .I Troff User's Manual
961 language is a full programming language providing requests, definition
962 of macros, escape sequences, string variables, number or size
963 registers, and flow controls.
967 are the predefined basic formatting commands similar to the commands
970 The user can define request-like elements using predefined
974 These are then called
977 A document writer will not note any difference in usage for requests
978 or macros; both are written on a line on their own starting with a dot.
984 elements starting with a backslash
986 They can be inserted anywhere, also in the midst of text in a line.
988 They are used to implement various features, including the insertion of
989 non-\f[CR]ASCII\f[] characters with
993 in-line comments with
995 the escaping of special control characters like
997 and many other features.
1001 are variables that can store a string.
1003 A string is stored by the
1007 The stored string can be retrieved later by the
1013 store numbers and sizes.
1015 A register can be set with the request
1017 and its value can be retrieved by the escape sequence
1021 .\" --------------------------------------------------------------------
1022 .SH "FILE NAME EXTENSIONS"
1023 .\" --------------------------------------------------------------------
1025 Manual pages (man pages) take the section number as a file name
1026 extension, e.g., the filename for this document is
1028 i.e., it is kept in section\~7
1032 The classical macro packages take the package name as an extension, e.g.
1034 for a document using the
1050 But there is no general naming scheme for
1056 is seen now and then.
1058 Maybe there should be a standardization for the filename extensions of
1063 File name extensions can be very handy in conjunction with the
1067 It provides the possibility to feed all input into a command-line pipe
1068 that is specified in the shell environment variable
1070 This process is not well documented, so here an example:
1073 .ShellCommand LESSOPEN='|lesspipe %s'
1078 is either a system supplied command or a shell script of your own.
1081 .\" --------------------------------------------------------------------
1083 .\" --------------------------------------------------------------------
1085 The best program for editing a
1087 document is Emacs (or Xemacs), see
1091 mode that is suitable for all kinds of
1095 This mode can be activated by the following methods.
1098 When editing a file within Emacs the mode can be changed by typing
1099 .RI ` "M-x nroff-mode" ',
1102 means to hold down the
1111 But it is also possible to have the mode automatically selected when
1112 the file is loaded into the editor.
1115 The most general method is to include the following 3 comment lines at
1116 the end of the file.
1120 .B \*[Comment] Local Variables:
1121 .B \*[Comment] mode: nroff
1126 There is a set of file name extensions, e.g. the man pages that
1127 trigger the automatic activation of the
1132 Theoretically, it is possible to write the sequence
1134 .B \*[Comment] \%-*-\ nroff\ -*-
1136 as the first line of a file to have it started in
1140 Unfortunately, some applications such as the
1142 program are confused by this; so this is deprecated.
1147 formatters provide automated line breaks and horizontal and vertical
1150 In order to not disturb this, the following tips can be helpful.
1153 Never include empty or blank lines in a
1157 Instead, use the empty request (a line consisting of a dot only) or a
1160 if a structuring element is needed.
1163 Never start a line with whitespace because this can lead to
1164 unexpected behavior.
1166 Indented paragraphs can be constructed in a controlled way by
1171 Start each sentence on a line of its own, for the spacing after a dot
1172 is handled differently depending on whether it terminates an
1173 abbreviation or a sentence.
1175 To distinguish both cases, do a line break after each sentence.
1178 To additionally use the auto-fill mode in Emacs, it is best to insert
1181 request (a line consisting of a dot only) after each sentence.
1184 The following example shows how optimal
1190 This is an example for a
1194 This is the next sentence in the same paragraph.
1196 This is a longer sentence stretching over several
1197 lines; abbreviations like `cf.' are easily
1198 identified because the dot is not followed by a
1201 In the output, this will still go to the same
1206 Besides Emacs, some other editors provide
1208 style files too, e.g.\&
1215 .\" --------------------------------------------------------------------
1217 .\" --------------------------------------------------------------------
1220 is a registered trademark of the Open Group.
1222 But things have improved considerably after Caldera had bought SCO
1226 .\" --------------------------------------------------------------------
1228 .\" --------------------------------------------------------------------
1230 There is a lot of documentation on
1233 The original papers on classical
1235 are still available, and all aspects of
1237 are documented in great detail.
1240 .\" --------------------------------------------------------------------
1241 .SS "Internet sites"
1242 .\" --------------------------------------------------------------------
1246 .URL http://\:www.troff.org "The historical troff site"
1247 provides an overview and pointers to all historical aspects of
1252 .URL http://\:www.multicians.org "The Multics site"
1253 contains a lot of information on the MIT projects, CTSS, Multics,
1254 early Unix, including
1256 especially useful are a glossary and the many links to ancient
1261 .URL http://\:www.tuhs.org/\:Archive/ \
1262 "The Ancient Unixes Archive"
1264 provides the source code and some binaries of the ancient Unixes
1265 (including the source code of
1267 and its documentation) that were made public by Caldera since 2001,
1268 e.g. of the famous Unix version\~7 for PDP-11 at the
1269 .URL http://\:www.tuhs.org/\:Archive/\:PDP-11/\:Trees/\:V7 \
1273 Developers at AT&T Bell Labs
1274 .URL http://\:cm.bell-labs.com/\:cm/\:index.html \
1275 "Bell Labs Computing and Mathematical Sciences Research"
1277 provides a search facility for tracking information on the early
1282 .URL http://\:plan9.bell-labs.com "The Plan\~9 operating system"
1288 .URL http://web.mit.edu/\:Saltzer/\:www/\:publications/\:pubs.html \
1289 "Jerry Saltzer's home page"
1291 stores some documents using the ancient RUNOFF formatting language.
1295 .URL http://\:cm.bell-labs.com/\:cm/\:cs/\:cstr.html \
1296 "The Bell Labs CSTR site"
1300 manuals (CSTR #54, #97, #114, #116, #122) and famous historical
1301 documents on programming.
1304 \f[CR]GNU\f[] \f[I]roff\f[]
1305 .URL http://\:www.gnu.org/\:software/\:groff "The groff web site"
1314 .\" --------------------------------------------------------------------
1315 .SS "Historical roff Documentation"
1316 .\" --------------------------------------------------------------------
1320 documents are still available on-line.
1322 The two main manuals of the
1329 .URL http://\:cm.bell-labs.com/\:cm/\:cs/\:54.ps \
1330 "\fINroff/\:Troff User's Manual\fP" ;
1332 Bell Labs, 1976; revised by Brian Kernighan, 1992.
1338 .URL http://\:cm.bell-labs.com/\:cm/\:cs/\:97.ps \
1339 "\fIA Typesetter-independent TROFF\fP" ,
1341 Bell Labs, 1981, revised March 1982.
1344 The "little language"
1350 Jon L. Bentley and Brian W. Kernighan,
1351 .URL http://\:cm.bell-labs.com/\:cm/\:cs/\:114.ps \
1352 "\fIGRAP \(em A Language for Typesetting Graphs\fP" ;
1354 Bell Labs, August 1984.
1359 .URL http://\:cm.bell-labs.com/\:cm/\:cs/\:116.ps \
1360 "\fIPIC -- A Graphics Language for Typesetting\fP" ;
1362 Bell Labs, December 1984.
1366 J. L. Bentley, L. W. Jelinski, and B. W. Kernighan,
1367 .URL http://\:cm.bell-labs.com/\:cm/\:cs/\:122.ps \
1368 "\fICHEM \(em A Program for Typesetting Chemical Structure Diagrams, \
1369 Computers and Chemistry\fP" ;
1371 Bell Labs, April 1986.
1374 .\" --------------------------------------------------------------------
1376 .\" --------------------------------------------------------------------
1378 Due to its complex structure, a full
1380 system has many man pages, each describing a single aspect of
1383 Unfortunately, there is no general naming scheme for the documentation
1392 .BR groff (@MAN1EXT@)
1393 contains a survey of all documentation available in
1397 On other systems, you are on your own, but
1399 might be a good starting point.
1402 .\" --------------------------------------------------------------------
1404 .\" --------------------------------------------------------------------
1406 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006
1407 Free Software Foundation, Inc.
1410 This document is distributed under the terms of the \f[CR]FDL\f[]
1411 (\f[CR]GNU Free Documentation License\f[]) version 1.1 or later.
1413 You should have received a copy of the \f[CR]FDL\f[] on your system,
1414 it is also available on-line at the
1415 .URL http://\:www.gnu.org/\:copyleft/\:fdl.html "GNU copyleft site" .
1418 This document is part of
1425 .MTO bwarken@mayn.de "Bernd Warken" ;
1427 .MTO wl@gnu.org "Werner Lemberg".
1431 .\" --------------------------------------------------------------------
1433 .\" --------------------------------------------------------------------
1435 .\" Local Variables: