World Library  
Flag as Inappropriate
Email this Article


Article Id: WHEBN0000030811
Reproduction Date:

Title: Troff  
Author: World Heritage Encyclopedia
Language: English
Subject: Markup language, TeX, Brian Kernighan, Unix, Refer (software)
Collection: Free Typesetting Software, History of Software, Page Description Languages, Troff
Publisher: World Heritage Encyclopedia


troff is the major component of a document processing system developed by AT&T Corporation for the Unix operating system.

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 that 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 man pages, mv macros for creating mountable transparencies, and the ms and mm macros for letters, books, technical memoranda, and reports.


  • History 1
  • Preprocessors 2
  • Reimplementations 3
  • See also 4
  • References 5
  • External links 6


troff can trace its origins back to a text formatting program called RUNOFF, written by Jerome H. Saltzer for MIT's CTSS operating system in the mid-1960s. (The name allegedly came from the phrase at the time, I'll run off a document.)

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 AT&T patents division. This first formatting program was a reimplementation of McIllroy's roff, written by Joe F. Ossanna.

When they needed a more flexible language, a new version of roff called nroff (newer "roff") was written. It had a much more complicated syntax, and provided the basis for all future versions. When they got a Graphic Systems CAT phototypesetter, Ossanna wrote a version of nroff that would drive it. It was dubbed troff, for typesetter 'roff'.[1] 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 line printers and character terminals. It understood everything troff did, and ignored the commands which were not applicable, e.g., font 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.[2] The program's documentation defines the output format of ditroff, which is used by many modern troff clones like GNU groff.

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. There are thus currently four variants of the original Bell Labs troff:[3]

  • An ancient variation from Bill Joy, still shipped by Sun Microsystems.
  • The SoftQuad DWB, based on USL DWB 2.0 from 1994
  • The DWB 3.4 from Lucent Software Solutions (USL)
  • Troff, Plan 9 edition

Use of troff and family was reduced somewhat in the 1990s, but it is still being used quite extensively. While troff has been supplanted by other programs such as Interleaf, FrameMaker and LaTeX, it is still the default format of the UNIX documentation.

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 OpenSolaris and Plan 9 from Bell Labs, several versions of AT&T troff are available under various open source licenses.


As troff evolved, since there are several things which cannot be done easily in troff, several preprocessors were developed. These programs transform certain parts of a document into troff input, fitting naturally into the use of "pipelines" in Unix — sending the output of one program as the input to another (see pipes and filters). Typically, each preprocessor translates only sections of the input file that are specially marked, passing the rest of the file through unchanged. The embedded preprocessing instructions are written in a simple application-specific programming language, which provides a high degree of power and flexibility.

  • eqn preprocessor allows mathematical formulae to be specified in simple and intuitive manner.[4]
  • tbl is a preprocessor for formatting tables.
  • refer (and the similar program bib) processes citations in a document according to a bibliographic database.

Three preprocessors provide troff with drawing capabilities by defining a domain-specific language for describing the picture.

  • pic is a procedural programming language providing various drawing functions like circle and box.[5]
  • ideal allows the drawing of pictures declaratively, deriving the picture by solving a system of simultaneous equations based on vectors and transformations described by its input.[6]
  • grn describes the pictures through graphical elements drawn at absolute coordinates, based on the gremlin file format defined by an early graphics workstation.[7]

Yet more preprocessors allow the drawing of more complex pictures by generating output for pic.


  • groff is GNU Project's free replacement for troff and nroff.
  • unroff is an extensible replacement of troff written in Scheme
  • Heirloom troff is based on troff from OpenSolaris. It includes support for OpenType fonts, improved support for Type 1 fonts, support for Unicode, a new paragraph formatting algorithm, and a groff compatibility mode.
  • mandoc is a specialised compiler/formatter only for the man and mdoc macro packages.
  • Neatroff is a new troff implementation, including support for advanced font features and bi-directional text.

See also


  1. ^ J. F. Ossanna. Nroff/Troff User's Manual. CSTR #54, Bell Labs, 1976. Revised by B. W. Kernighan, 1992.
  2. ^ B. W. Kernighan. A Typesetter-Independent TROFF. CSTR #97, Bell Labs, 1981, revised March 1982.
  3. ^ Nils-Peter Nelson. Where does one get real troff these days? [1].
  4. ^ B. W. Kernighan and Lorinda L. Cherry. A System for Typesetting Mathematics. CSTR #17, Bell Labs, May 1974.
  5. ^ B. W. Kernighan. PIC — A Graphics Language for Typesetting (Revised User Manual). CSTR #116, Bell Labs, December 1984.
  6. ^ C. J. Van Wyk. IDEAL User's Manual. CSTR #103, Bell Labs, December 1981.
  7. ^ grn — groff preprocessor for gremlin files [2].
  8. ^ J. L. Bentley and B. W. Kernighan. GRAP — A Language for Typesetting Graphs (Tutorial and User Manual). CSTR #114, Bell Labs, August 1984.
  9. ^ J. L. Bentley, L. W. Jelinski, and B. W. Kernighan. CHEM — A Program for Typesetting Chemical Structure Diagrams. CSTR #122, Computers and Chemistry, Bell Labs, April 1986.
  10. ^ J. L. Bentley. DFORMAT — A Program for Typesetting Data Formats. CSTR #142, Bell Labs, April 1988.

External links

  • The Text Processor for Typesetters
  • The history of troff
  • OpenSolaris-derived port of troff and related programs
  • User manual for the Plan 9 edition of troff
  • A History of UNIX before Berkeley section 3 describes the history of roff, nroff, troff, ditroff, tbl, eqn, and more.
  • The original source code of nroff, troff and the preprocessors from AT&T Bell Labs in form of the Documenter's Workbench (DWB) Release 3.3 (ported to current UNIX systems from
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.

Copyright © World Library Foundation. All rights reserved. eBooks from World Library are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.