troff (), short for "typesetter roff", is the major component of a document processing system developed by Bell Labs for the Unix operating system. troff and the related nroff were both developed from the original roff.
While nroff was intended to produce output on terminals and line printers, troff was intended to produce output on typesetting systems, specifically the Graphic Systems CAT, which had been introduced in 1972. Both used the same underlying markup language, and a single source file could normally be used by nroff or troff without change.
troff features commands to designate fonts, spacing, paragraphs, margins, footnotes and more. Unlike many other text formatters, troff can position characters arbitrarily on a page, even overlapping them, and has a fully programmable input language. Separate preprocessors are used for more convenient production of tables, diagrams, and mathematics. Inputs to troff are plain text files and can be created by any text editor.
Extensive macro packages have been created for various document styles. A typical distribution of troff includes the me macros for formatting research papers, man and mdoc macros for creating Unix UNIX manual, mv macros for creating mountable transparencies, and the ms and mm macros for letters, books, technical memoranda, and reports.
Bob Morris ported it to the GE 635 architecture and called the program roff (an abbreviation of runoff). It was rewritten as rf for the PDP-7, and at the same time (1969), Doug McIlroy rewrote an extended and simplified version of roff in the BCPL programming language.
The first version of Unix was developed on a PDP-7 which was sitting around Bell Labs. In 1971 the developers wanted to get a PDP-11 for further work on the operating system. In order to justify the cost for this system, they proposed that they would implement a document-formatting system for the Bell Labs patents department. This first formatting program was a reimplementation of McIllroy's roff, written by Joe Ossanna.
When they needed a more flexible language, a new version of roff called nroff ( newer "roff") was written, which provided the basis for all future versions. When they got a Graphic Systems CAT phototypesetter, Ossanna modified nroff to support multiple fonts and proportional spacing. Dubbed troff, for typesetter roff, its sophisticated output amazed the typesetter manufacturer and confused , who thought that manuscripts using troff had been published before.J. F. Ossanna. Nroff/Troff User's Manual. CSTR #54, Bell Labs, 1976. Revised by B. W. Kernighan, 1992. As such, the name troff is pronounced rather than *.
With troff came nroff (they were actually almost the same program), which was for producing output for and character terminals. It understood everything troff did, and ignored the commands which were not applicable, e.g., typeface changes.
Ossanna's troff was written in PDP-11 assembly language and produced output specifically for the CAT phototypesetter. He rewrote it in C, although it was now 7000 lines of uncommented code and still dependent on the CAT. As the CAT became less common, and was no longer supported by the manufacturer, the need to make it support other devices became a priority. Ossanna died before this task was completed, so Brian Kernighan took on the task of rewriting troff. The newly rewritten version produced a device-independent code which was very easy for post-processors to read and translate to the appropriate printer codes. Also, this new version of troff (often called ditroff for device independent troff) had several extensions, which included drawing functions.B. W. Kernighan. A Typesetter-Independent TROFF. CSTR #97, Bell Labs, 1981, revised March 1982. The program's documentation defines the output format of ditroff, which is used by many modern troff clones like GNU groff.
In 1983, troff was one of several UNIX tools available for Charles River Data Systems' UNOS operating system under Bell Laboratories license.
The troff collection of tools (including pre- and post-processors) was eventually called Documenter's WorkBench (DWB), and was under continuous development in Bell Labs and later at the spin-off Unix System Laboratories (USL) through 1994. At that time, SoftQuad took over the maintenance, although Brian Kernighan continued to improve troff on his own. Thus, there are at least the following variants of the original Bell Labs troff in use:
While troff has been supplanted by other programs such as Interleaf, FrameMaker, and LaTeX, it is still being used quite extensively. It remains the default formatter for the UNIX manual.
The software was reimplemented as groff for the GNU system beginning in 1990. In addition, due to the open sourcing of Ancient UNIX systems, as well as modern successors such as the ditroff-based open-sourced versions found on OpenSolaris and Plan 9 from Bell Labs, there are several versions of AT&T troff (CAT and ditroff-basedSee the man page of the ditroff -> postscript converter on OpenSolaris: ) available under various open-source licenses.
The standard macro sets, with leading m are:
The ms macros were the first of these, developed at AT&T, before they were supplanted by the mm macros. One goal of the mm macros was that they be usable by the typing pool at Bell Labs and, over time, this happened and the mm macros became a standard at Bell Labs. AT&T made the mm macros commercially available for System V Unix. In contrast, the me macros were developed at Berkeley.
An example of a simple business letter prepared with the mm macros would be:
A comprehensive list of macros available is usually listed in a tmac(5) manual page.
Three preprocessors provide troff with drawing capabilities by defining a domain-specific language for describing the picture.
In addition, there is a command soelim that removes .so inclusion directives from the input text.
A typical structure of the pipeline might be:
soelim <i>file</i> | refer | ideal | pic | tbl | eqn | troff
Yet more preprocessors allow the drawing of more complex pictures by generating output for pic.
One of them is Sanscribe, originally developed at Berkeley and then enhanced during the 1980s by several users including Intel and InterACT. Used for writing memos, reports, documents, Sanscribe is built upon basic troff commands as well as the me macros and various pre- and post-processors such as soelim, eqn, tbl, grap, and pic. However it is a main program binary, not a preprocessor. The conditional inclusion capability renders it especially useful for maintaining multi-platform reference manuals. However, Sanscribe is fragile and prone to giving cryptic errors or producing weirdly formatted results.
A special-purpose front-end is vgrind, which generates nicely formatted source program listings, with such features as putting comments in italics, keywords in bold, and function names highlighted in margins. It can run either as a filter or as a main program with its output being passed to troff. It has support for the languages in use at Bell Labs facilities, including not just Fortran, C, and C++ but also domain-specific tools such as Bourne shell and yacc as well as those further afield such as Emacs Lisp and Icon.
A different approach is employed by the CADiZ suite of tools for the Z notation. Rather than the cadiz program being a preprocessor in the front of the pipeline, it interacts multiple times with troff as both input and output, using saved files rather than a pipe. CADiZ also contains its own set of macros, called .ZA to .ZZ.
|
|