4 Last update: 08 Jan 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 .\" Begin of macro definitions
53 . Text \f[B]\[rs]\*[@1]\f[]\$*
59 . Text \f[B]\*[@1]\f[]\$*
65 . nop `\fB\*[@1]\fP'\$*
70 . IR "shell#" "\h'1m'\f[CB]\$*\f[]\/"
83 .\" End of macro definitions
86 .\" --------------------------------------------------------------------
88 .\" --------------------------------------------------------------------
90 .TH ROFF @MAN7EXT@ "@MDATE@" "Groff Version @VERSION@"
92 roff \- introduction and overview of roff typesetting
95 .\" --------------------------------------------------------------------
97 .\" --------------------------------------------------------------------
100 is the general name for a set of type-setting programs, known under
108 A roff type-setting system consists of an extensible text formatting
109 language and a set of programs for printing and converting to other
112 Traditionally, it is the main text processing system of Unix; every
113 Unix-like operating system still distributes a roff system as a core
117 The most common roff system today is the free software implementation
121 The pre-groff implementations are referred to as
123 (dating back as long as 1973).
126 implements the look-and-feel and functionality of its classical
127 ancestors, but has many extensions.
131 is the only roff system that is available for every (or almost every)
132 computer system it is the de-facto roff standard today.
135 In spite of its age, roff is in wide use today, e.g., the manual pages
137 .RI ( man\~pages\/ ),
138 many software books, system documentation, standards, and corporate
139 documents are written in roff.
141 The roff output for text devices is still unmatched, and its graphical
142 output has the same quality as other free type-setting programs and is
143 better than some of the commercial systems.
146 This document gives only an overview and provides pointers to further
147 documentation, cf. section
151 .\" --------------------------------------------------------------------
153 .\" --------------------------------------------------------------------
157 text processing system has a very long history, dating back to the
160 The roff system itself is intimately connected to the Unix operating
161 system, but roff had roots in the earlier operating systems CTSS and
166 evolved from its predecessor
173 .RI ( "Compatible Time Sharing System" )
174 in 1961, which was further developed into the famous Unix predecessor
176 .URL http://\:www.multicians.org "Multics" ,
179 Both operating systems could only be run on very expensive computers
180 at that time, so they were mostly used in research and for official
184 The possibilities of the
186 program were quite limited as compared to roff.
188 Only text output was needed in the 1960s.
190 This could be implemented by a set of requests of length\~2, many of
191 which are still identically used in roff.
193 The runoff program was first written in
197 the grandmother of the
199 programming language.
201 In the Multics operating system, the help system was handled by
202 runoff, similar to roff's task on the Unix manual pages.
204 There are still documents written in the runoff language; for examples
205 see Saltzer's homepage (follow the links on the Multics web page).
208 In the 1970s, the Multics off-spring
210 became more and more popular because it could be run on affordable
211 machines and was free at that time.
213 At MIT (the Massachusetts Institute of Technology), there was a need to
215 .I Graphic Systems CAT
216 typesetter, a graphical output device from a PDP-11 computer running
219 As runoff was too limited for this task it was further developed into
220 a more powerful text formatting system by
221 .IR "Josef F. Osanna" ,
222 a main developer of Multics and runoff ports.
229 The first version was written in the PDP-11 assembly language and
233 joined the roff development by rewriting it in the C programming
236 The C version was released in 1975.
239 This first roff system could produce output for only 2\~devices:
241 .RI ( "typesetter roff\/" )
242 had a graphical output for the
244 typesetter as its only device, while
246 produced text output suitable for terminals or line printers.
249 The syntax of the formatting language of the
251 programs was documented in the famous
252 .IR "Troff User's Manual [CSTR\~#54]" ,
253 first published in 1976, with further revisions up to 1992 by Brian
256 The system described therein is referred to as the
257 .IR "classical troff" .
260 systems tried to establish compatibility with this specification.
263 After Osanna had died in 1977 by a heart-attack at the age of about\~50
264 Kernighan went on with developping troff.
266 The next milestone was to equip troff with a general interface to
267 support more devices, the intermediate output format and the
268 postprocessor system.
270 This completed the structure of a
272 as it is still in use today; see section
275 In 1979, these novelties were described in the paper
277 This new troff version is the basis for all existing newer troff
282 A major catastrophy occurred when the freely available Unix\~7
283 operating system was commercialized.
285 A whole bunch of divergent operating systems emerged, fighting each
286 other with incompatibilities, finally causing many different roff
289 All of them used Osanna/Kernighan's free source code and his troff
290 papers as their main documentation, but sold them together with
291 "their" system \[em] with only minor modifications.
293 Though most commercial roff systems added incompatible extensions, all
294 of them try to achieve compatibility with the original, free troff.
296 Some of these roff implementations were renamed into
297 .BR ditroff (@MAN1EXT@),
299 .IR "device independent troff" .
300 This name is an exaggeration.
303 As a counter-measure to the galopping commercialization, more and more
304 free software projects emerged during the 1980s and 1990s.
306 The most important roff project was the GNU port of troff, created by
313 The groff system is actively developed.
315 Though being compatible with the classical troff, many extensions were
316 added that greatly simplify roff programming.
318 It is the first roff system that is available on almost all operating
319 systems \[em] and it is free.
321 This makes groff the de-facto roff standard today.
324 .\" --------------------------------------------------------------------
326 .\" --------------------------------------------------------------------
328 Most people won't even notice that they are actually using roff.
330 When you read a system manual page (man page) roff is working in the
333 Arbitrary roff documents can be viewed with a native roff viewer
336 a standard program of the
340 But using roff explicitly isn't difficult either.
343 Some roff implementations provide wrapper programs that make it easy
344 to use the roff system on the shell command line.
346 For example, the GNU roff implementation
347 .BR groff (@MAN1EXT@)
348 provides command line options to avoid the long command pipes of
349 classical troff; a program
351 tries to guess from the document which arguments should be used for a
352 run of groff; people who do not like specifying command line options
354 .BR groffer (@MAN1EXT@)
355 program for graphically displaying groff files and man pages.
358 .\" --------------------------------------------------------------------
360 .\" --------------------------------------------------------------------
362 Each roff system consists of preprocessors, roff formatter programs,
363 and a set of device postprocessors.
365 This concept makes heavily use of the
367 mechanism, i.e. a series of programs is called one after the other,
368 where the output of each program in the queue is taken as the input
369 for the next program.
383 The preprocessors generate roff code that is fed into a roff formatter
384 (e.g. troff), which in turn generates
385 .I intermediate output
386 that is fed into a device postprocessor program for printing or final
390 All of these parts use programming languages of their own; each
391 language is totally unrelated to the other parts.
393 Moreover, roff macro packages can be inluded.
395 So most roff documents use the macros of some package, intermixed with
396 code for one or more preprocessors, but do not need many elements from
397 the plain roff language.
400 .\" --------------------------------------------------------------------
402 .\" --------------------------------------------------------------------
404 A roff preprocessor is any program that generates output that
405 syntactically obeys the rules of the roff formatting language.
407 Each preprocessor defines a language of its own that is translated
408 into roff code when run through the preprocessor program.
410 Parts written in these languages may be included within a roff
411 document; they are identified by special roff requests or macros.
413 Each document that is enhanced by preprocessor code must be run
414 through all corresponding preprocessors before it is fed into the
415 actual roff formatter program; for the formatter just ignores all
418 The preprocessor programs extract and transform only the document
419 parts that are determined for them.
422 There are a lot of free and commercial roff preprocessors.
424 Some of these aren't available on each system, but there is a small
425 set of preprocessors that are considered as an integral part of each
428 The classical preprocessors are
438 for mathematical formul\[ae]
444 for bibliographic references
447 for including macro files from standard locations
452 Other known preprocessors that are not available on all systems
460 for drawing chemical formul\[ae].
463 for constructing graphical elements.
473 .\" --------------------------------------------------------------------
474 .SS "Formatter Programs"
475 .\" --------------------------------------------------------------------
479 is a program that parses documents written in the roff formatting
480 language or uses some of the roff macro packages.
483 .IR "intermediate output" ,
484 which is intended to be fed into a single device postprocessor that
485 must be specified by a command-line option to the formatter program.
487 The documents must have been run through all necessary preprocessors
491 The output produced by a roff formatter is represented in yet another
493 .IR "intermediate output format"
496 This language was first specified in
498 its GNU extension is documented in
499 .BR groff_out (@MAN5EXT@).
501 The intermediate output language is a kind of assembly language
502 compared to the high-level roff language.
504 The generated intermediate output is optimized for a special device,
505 but the language is the same for every device.
508 The roff formatter is the heart of the roff system.
510 The traditional roff had two formatters,
514 for graphical devices.
519 is used as a general term to refer to both formatters.
522 .\" --------------------------------------------------------------------
523 .SS "Devices and Postprocessors"
524 .\" --------------------------------------------------------------------
526 Devices are hardware interfaces like printers, text or graphical
527 terminals, etc., or software interfaces such as a conversion into a
528 different text or graphical format.
531 A roff postprocessor is a program that transforms troff output into a
532 form suitable for a special device.
534 The roff postprocessors are like device drivers for the output target.
537 For each device there is a postprocessor program that fits the device
540 The postprocessor parses the generated intermediate output and
541 generates device-specific code that is sent directly to the device.
544 The names of the devices and the postprocessor programs are not fixed
545 because they greatly depend on the software and hardware abilities of
548 For example, the classical devices mentioned in
550 have greatly changed since the classical times.
552 The old hardware doesn't exist any longer and the old graphical
553 conversions were quite imprecise when compared to their modern
557 For example, the Postscript device
559 in classical troff had a resolution
562 has 72000, a refinement of factor 100.
565 Today the operating systems provide device drivers for most
566 printer-like hardware, so it isn't necessary to write a special
567 hardware postprocessor for each printer.
570 .\" --------------------------------------------------------------------
571 .SH "ROFF PROGRAMMING"
572 .\" --------------------------------------------------------------------
574 Documents using roff are normal text files decorated by roff
577 The roff formatting language is quite powerful; it is almost a full
578 programming language and provides elements to enlarge the language.
580 With these, it became possible to develop macro packages that are
581 tailored for special applications.
583 Such macro packages are much handier than plain roff.
585 So most people will choose a macro package without worrying about the
586 internals of the roff language.
589 .\" --------------------------------------------------------------------
591 .\" --------------------------------------------------------------------
593 Macro packages are collections of macros that are suitable to format a
594 special kind of documents in a convenient way.
596 This greatly eases the usage of roff.
598 The macro definitions of a package are kept in a file called
604 All tmac files are stored in one or more directories at standardized
607 Details on the naming of macro packages and their placement is found
609 .BR groff_tmac (@MAN5EXT@).
612 A macro package that is to be used in a document can be announced to
613 the formatter by the command line option
616 .BR troff (@MAN1EXT@),
617 or it can be specified within a document using the file inclusion
618 requests of the roff language, see
619 .BR groff (@MAN7EXT@).
622 Famous classical macro packages are
624 for traditional man pages,
626 for BSD-style manual pages;
627 the macro sets for books, articles, and letters are
629 (probably from the first name of its creator
634 .IR "Manuscript Macros\/" ),
638 .IR "Memorandum Macros\/" ).
641 .\" --------------------------------------------------------------------
642 .SS "The roff Formatting Language"
643 .\" --------------------------------------------------------------------
645 The classical roff formatting language is documented in the
646 .I Troff User's Manual
649 The roff language is a full programming language providing requests,
650 definition of macros, escape sequences, string variables, number or
651 size registers, and flow controls.
655 are the predefined basic formatting commands similar to the commands
658 The user can define request-like elements using predefined roff
661 These are then called
664 A document writer will not note any difference in usage for requests
665 or macros; both are written on a line on their own starting with a dot
670 are roff elements starting with a backslash
672 They can be inserted anywhere, also in the midst of text in a line.
674 They are used to implement various features, including the insertion of
675 non-ASCII characters with
679 in-line comments with
681 the escaping of special control characters like
683 and many other features.
687 are variables that can store a string.
689 A string is stored by the
693 The stored string can be retrieved later by the
699 store numbers and sizes.
701 A register can be set with the request
703 and its value can be retrieved by the escape sequence
707 .\" --------------------------------------------------------------------
708 .SH "FILE NAME EXTENSIONS"
709 .\" --------------------------------------------------------------------
711 Manual pages (man pages) take the section number as a file name
712 extension, e.g., the filename for this document is
714 i.e., it is kept in section\~7
718 The classical macro packages take the package name as an extension, e.g.
720 for a document using the
736 But there is no general naming scheme for roff documents, though
740 is seen now and then.
742 Maybe there should be a standardization for the filename extensions of
746 File name extensions can be very handy in conjunction with the
750 It provides the possibility to feed all input into a command-line pipe
751 that is specified in the shell environment variable
753 This process is not well documented, so here an example:
756 .B LESSOPEN='|lesspipe %s'
761 is either a system supplied command or a shell script of your own.
764 .\" --------------------------------------------------------------------
766 .\" --------------------------------------------------------------------
768 The best program for editing a roff document is Emacs (or Xemacs), see
772 mode that is suitable for all kinds of roff dialects.
774 This mode can be activated by the following methods.
777 When editing a file within Emacs the mode can be changed by typing
778 .RI ` "M-x nroff-mode" ',
781 means to hold down the
790 But it is also possible to have the mode automatically selected when
791 the file is loaded into the editor.
794 There is a set of file name extensions, e.g. the man pages that
795 trigger the automatic activation of the nroff mode.
797 Any file containing the character
800 in the first line is switched into nroff mode when loaded.
802 But do not use this, it confuses some applications such as the
807 The best method is to include the following 3 comment lines at the end
812 .B .\*[comment] Local Variables:
813 .B .\*[comment] mode: nroff
818 All roff processors handle automated spacing after the end of a
821 The safest way to not disturb this or to mix it up with abbreviations
822 is to start each sentence on a line of its own without preceding white
825 To additionally use the auto-fill mode in Emacs, it is best to insert
826 an empty roff request (a line consisting of a dot
828 only) after each sentence.
830 This suits the general roff rule to never use blank lines because they
831 can produce unexpected behavior in the vertical spacing; so each line
832 that is supposed to be empty or blank should instead use the line
835 or the empty request, a line consisting of a dot only.
837 The following example shows how optimal roff editing could look.
843 This is a longer sentence stretching over
850 Besides Emacs, some other editors provide nroff style files too, e.g.\&
857 .\" --------------------------------------------------------------------
859 .\" --------------------------------------------------------------------
862 is a registered trademark of the Open Group.
865 .\" --------------------------------------------------------------------
867 .\" --------------------------------------------------------------------
869 There is a lot of documentation on roff.
871 The original papers on classical troff are still available, and all
872 aspects of groff are documented in great detail.
875 .\" --------------------------------------------------------------------
876 .SS "Historical roff Documentation"
877 .\" --------------------------------------------------------------------
881 documents are still available on-line.
884 The old history is best documented at the
885 .URL http://\:www.multicians.org "Multics site" .
886 This contains a lot of information on the MIT projects, CTSS, Multics,
887 early Unix, including runoff.
889 Especially useful are a glossary and the many links to other documents.
893 .URL http://\:cm.bell-labs.com/\:cm/\:index.html \
894 "Bell Labs Computing and Mathematical Sciences Research"
895 provides a search facility for tracking information on the early
899 The best documentation on the issues of the original, free Unix with
900 its standard programs are the papers in the series
901 .URL http://\:cm.bell-labs.com/\:cm/\:cs/\:cstr.html "Bell Labs CSTR" .
903 These also contain the two main documents of the early nroff/troff,
907 The 1992\~revision of Osanna/Kernighan's 1976\~paper
908 .URL http://\:cm.bell-labs.com/\:cm/\:cs/\:54.ps \
909 "Nroff/\:Troff User's Manual" .
912 Brian Kernighan's 1979\~paper
913 .URL http://\:cm.bell-labs.com/\:cm/\:cs/\:97.ps \
914 "A Typesetter-independent TROFF" .
917 .\" --------------------------------------------------------------------
919 .\" --------------------------------------------------------------------
925 are the main documentation system on many operating system.
927 Due to its complex structure, a full roff system has many man pages,
928 each describing a single aspect of roff.
931 A reference to a man page looks like this:
932 .BR groff (@MAN7EXT@).
934 This refers to the manual page on
939 To read the example, call from the shell prompt
942 .ShellCommand man @MAN7EXT@ groff
945 For more details, see the documentation of the
947 program in section\~1, i.e.
951 For the different roff implementations, there is no general naming
952 scheme for its documentation.
957 .BR groff (@MAN1EXT@)
958 contains a survey of all documentation available in groff.
960 On other systems, you are on your own, but
962 might be a good starting point.
965 .\" --------------------------------------------------------------------
967 .\" --------------------------------------------------------------------
969 Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
972 This document is distributed under the terms of the FDL (GNU Free
973 Documentation License) version 1.1 or later.
975 You should have received a copy of the FDL on your system, it is also
976 available on-line at the
977 .URL http://\:www.gnu.org/\:copyleft/\:fdl.html "GNU copyleft site" .
980 This document is part of
982 the GNU roff distribution.
985 .MTO bwarken@mayn.de "Bernd Warken" ;
987 .MTO wl@gnu.org "Werner Lemberg".
990 .\" --------------------------------------------------------------------
992 .\" --------------------------------------------------------------------