ROFF(7) | Miscellaneous Information Manual | ROFF(7) |
NAME
roff - concepts and history of roff typesettingDESCRIPTION
roff is the general name for a set of text formatting programs, known under names like troff, nroff, ditroff, groff, etc. A roff system consists of an extensible text formatting language and a set of programs for printing and converting to other text formats. Unix-like operating systems distribute a roff system as a core package.HISTORY
Document formatting by computer dates back to the 1960s. The roff system itself is intimately connected to the Unix operating system, but its roots go back to the earlier operating systems CTSS and Multics.The Predecessor RUNOFF
roff's ancestor RUNOFF was written in the MAD language by Jerry Saltzer for the Compatible Time Sharing System (CTSS), a project of the Massachusetts Institute of Technology (MIT), in 1963 and 1964 – note that CTSS commands were all uppercase.The Classical nroff/troff System
At BTL, there was a need to drive the Graphic Systems CAT typesetter, a graphical output device from a PDP-11 computer running Unix. As runoff was too limited for this task it was further developed into a more powerful text formatting system by Joseph F. Ossanna, who already programmed several runoff ports.- troff
- (typesetter roff/) generated a graphical output for the CAT typesetter as its only device.
- nroff
- produced text output suitable for terminals and line printers.
- roff
- was the reimplementation of the former runoff program with its limited features; this program was abandoned in later versions. Today, the name roff is used to refer to a troff/nroff system as a whole.
Availability
The source code of both the ancient Unix and classical troff weren't available for two decades. Meanwhile, it is accessible again (on-line) for non-commercial use, cf. section SEE ALSO.Free roff
The most important free roff project was the GNU implementation of troff, written from scratch by James Clark and put under the GNU Public License It was called groff (GNU roff). See groff(1) for an overview.USING ROFF
Most people won't even notice that they are actually using roff. When you read a system manual page (man page) roff is working in the background. roff documents can be viewed with a native viewer called xditview(1x), a standard program of the X window distribution, see X(7x). But using roff explicitly isn't difficult either.The roff Pipe
Each roff system consists of preprocessors, roff formatter programs, and a set of device postprocessors. This concept makes heavy use of the piping mechanism, that is, a series of programs is called one after the other, where the output of each program in the queue is taken as the input for the next program.Preprocessors
A roff preprocessor is any program that generates output that syntactically obeys the rules of the roff formatting language. Each preprocessor defines a language of its own that is translated into roff code when run through the preprocessor program. Parts written in these languages may be included within a roff document; they are identified by special roff requests or macros. Each document that is enhanced by preprocessor code must be run through all corresponding preprocessors before it is fed into the actual roff formatter program, for the formatter just ignores all alien code. The preprocessor programs extract and transform only the document parts that are determined for them.tbl | for tables. |
eqn | for mathematical formulæ. |
pic | for drawing diagrams. |
refer | for bibliographic references. |
soelim | for including macro files from standard locations. |
chem | for drawing chemical formulæ. |
grap | for constructing graphical elements. |
grn | for including gremlin(1) pictures. |
Formatter Programs
A roff formatter is a program that parses documents written in the roff formatting language or uses some of the roff macro packages. It generates intermediate output, which is intended to be fed into a single device postprocessor that must be specified by a command-line option to the formatter program. The documents must have been run through all necessary preprocessors before.Devices and Postprocessors
Devices are hardware interfaces like printers, text or graphical terminals, etc., or software interfaces such as a conversion into a different text or graphical format.ROFF PROGRAMMING
Documents using roff are normal text files decorated by roff formatting elements. The roff formatting language is quite powerful; it is almost a full programming language and provides elements to enlarge the language. With these, it became possible to develop macro packages that are tailored for special applications. Such macro packages are much handier than plain roff. So most people will choose a macro package without worrying about the internals of the roff language.Macro Packages
Macro packages are collections of macros that are suitable to format a special kind of documents in a convenient way. This greatly eases the usage of roff. The macro definitions of a package are kept in a file called name.tmac (classically tmac.name). All tmac files are stored in one or more directories at standardized positions. Details on the naming of macro packages and their placement is found in groff_tmac(5).The roff Formatting Language
The classical roff formatting language is documented in the Troff User's Manual [CSTR #54]. The roff language is a full programming language providing requests, definition of macros, escape sequences, string variables, number or size registers, and flow controls.FILE NAME EXTENSIONS
Manual pages (man pages) take the section number as a file name extension, e.g., the filename for this document is roff.7, i.e., it is kept in section 7 of the man pages.LESSOPEN='|lesspipe %s'
EDITING ROFF
The best program for editing a roff document is Emacs (or Xemacs), see emacs(1). It provides an nroff mode that is suitable for all kinds of roff dialects. This mode can be activated by the following methods.- •
- The most general method is to include the following 3 comment lines at the end of the file.
-
.\" Local Variables:
.\" mode: nroff
.\" End:
- •
- There is a set of file name extensions, e.g. the man pages that trigger the automatic activation of the nroff mode.
- •
- Theoretically, it is possible to write the sequence
-
.\" -*- nroff -*-
- as the first line of a file to have it started in nroff mode when loaded. Unfortunately, some applications such as the man program are confused by this; so this is deprecated.
- •
- Never include empty or blank lines in a roff document. Instead, use the empty request (a line consisting of a dot only) or a line comment .\" if a structuring element is needed.
- •
- Never start a line with whitespace because this can lead to unexpected behavior. Indented paragraphs can be constructed in a controlled way by roff requests.
- •
- Start each sentence on a line of its own, for the spacing after a dot is handled differently depending on whether it terminates an abbreviation or a sentence. To distinguish both cases, do a line break after each sentence.
- •
- To additionally use the auto-fill mode in Emacs, it is best to insert an empty roff request (a line consisting of a dot only) after each sentence.
This is an example for a
.I roff
document.
.
This is the next sentence in the same paragraph.
.
This is a longer sentence stretching over several
lines; abbreviations like `cf.' are easily
identified because the dot is not followed by a
line break.
.
In the output, this will still go to the same
paragraph.
SEE ALSO
There is a lot of documentation on roff. The original papers on classical troff are still available, and all aspects of groff are documented in great detail.Internet sites
- troff.org
- Multics
- Unix Archive
- Developers at AT&T Bell Labs
- Plan 9
- runoff
- CSTR Papers
- GNU roff
Historical roff Documentation
Many classical troff documents are still available on-line. The two main manuals of the troff language are- [CSTR #54]
- J. F. Ossanna,
- [CSTR #97]
- Brian Kernighan,
- [CSTR #114]
- Jon L. Bentley and Brian W. Kernighan,
- [CSTR #116]
- Brian W. Kernighan,
- [CSTR #122]
- J. L. Bentley, L. W. Jelinski, and B. W. Kernighan,
Manual Pages
Due to its complex structure, a full roff system has many man pages, each describing a single aspect of roff. Unfortunately, there is no general naming scheme for the documentation among the different roff implementations.AUTHORS
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.30 December 2012 | Groff Version 1.22.1 |