Skip to content
Main menu
  • Main page
  • Discover
  • Unexpected connections
  • Topics
  • Random article
  • Search
Your library
  • Saved articles
  • Recent discoveries
  • Rabbit-hole trails
Topic areas
  • Computer Science
  • Mathematics
  • Physics
  • Engineering
  • Biology
  • Economics
  • Curiosities
WikiholeDeeper into Wikipedia
EnglishEN
  • Saved
  • History

  • Article text and media come live from Wikipedia via the official MediaWiki API and are available under the Creative Commons Attribution-ShareAlike 4.0 License; additional terms may apply. Each article links to its source and revision.
  • WikiHole is an independent project and is not affiliated with the Wikimedia Foundation.
  • How ranking works
  • All topics
  • Reading history
  • Random article
  • MediaWiki API

troff

  • Article
  • Rabbit hole
  • Read
  • View history
Tools
Actions
  • Read
  • View history
General
  • Recent changes
  • Related articles
  • Random discovery
This article
Reading time
8 min
Topic
Computer Science
Quality
C-class
Views
1.1k in 14 days
Last edited
16 Aug 2026
Print/export
  • Printable version
In other projects
  • Wikidata item
From Wikipedia, the free encyclopedia
Rabbit hole:
  1. Troff
Troff
Original authorJoe Ossanna
DeveloperAT&T Bell Laboratories
Written inC
Operating systemUnix, Unix-like, Plan 9
PlatformCross-platform
TypeCommand
LicensePlan 9: MIT License
Websitetroff.org

troff (/ˈtiːrɒf/), 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

This article is about the Unix document processing system. For the command in BASIC, see TROFF. For the chess grandmaster, see Kayden Troff.

Not to be confused with Trough (disambiguation).

"tbl" redirects here. For other uses, see TBL (disambiguation).

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

Loading the rest of the article…

Recent changes

Rabbit hole

Where Troff leads. Every connection below has a source: a link in this article, a shared Wikipedia category, or CirrusSearch text similarity. Articles already on your trail are left out.

Contents
  • (Top)
  • History
  • Macros
  • Preprocessors
  • Other front-ends
  • See also
  • References
  • External links
  • Recent changes
  • Rabbit hole
Contents
Contents9 sections
  • (Top)
  • History
  • Macros
  • Preprocessors
  • Other front-ends
  • See also
  • References
  • External links
  • Recent changes
  • Rabbit hole
Study aids for Troff

Terminology

me
Extensive macro packages have been created for various document styles.
man
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.
mdoc
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.
mv
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.
ms
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.
mm
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.
ditroff
Also, this new version of troff (often called ditroff for device independent troff) had several extensions, which included drawing functions.
macros
Troff includes macros that are run before starting to process the document.
Sanscribe
One of them is Sanscribe, originally developed at Berkeley and then enhanced during the 1980s by several users including Intel and InterACT.
vgrind
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.

Terms the article defines in bold, quoted in context.

Categories:
  • Troff
  • Free typesetting software
  • Page description languages
  • History of software
  • Plan 9 commands
  • Unix text processing utilities

1,616 words · 29 references · revision 1369665627 · CC BY-SA 4.0

General
  • Recent changes
  • Related articles
  • Random discovery
This article
Reading time
8 min
Topic
Computer Science
Quality
C-class
Views
1.1k in 14 days
Last edited
16 Aug 2026

Key concepts

  • CAT (phototypesetter)3
  • Bell Labs2
  • Unix2
  • Nroff2
  • Roff (software)2
  • UNIX manual2
  • Document processing system1
  • Typesetting1
  • Markup language1
  • Overhead projector1

The articles this one links to most, weighted towards the introduction.

Print/export
  • Printable version
In other projects
  • Wikidata item

History

troff's origins can be traced to a text-formatting program called RUNOFF, which was written by Jerome H. Saltzer for MIT's CTSS operating system in the mid-1960s. (The name allegedly came from the phrase 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 Bell Labs patents department.1 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, 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 peer reviewers, who thought that manuscripts using troff had been published before.23 As such, the name troff is pronounced /ˈtiːrɒf/ rather than */ˈtrɒf/.

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.4 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.5

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:

  • the SoftQuad DWB, based on USL DWB 2.0 from 1994;
  • the DWB 3.4 from Lucent Software Solutions (formerly USL);
  • troff, Plan 9 edition.

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 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 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-based6) available under various open-source licenses.

Macros

In general, one was not encouraged to use troff directly, but rather go through some easier-to-use interface.78 Troff includes macros that are run before starting to process the document. These macros include setting up page headers and footers, defining new commands, and influencing how the output will be formatted. The command-line argument for including a macro set is -mname, which has led to many macro sets being known as the base filename with a leading m.9

The standard macro sets, with leading m are:

  • man for creating manual pages1011
  • mdoc for semantically annotated manual pages, replacing man in BSDs121314
  • me for creating research papers15
  • mm for creating memorandums16
  • ms for creating books, reports, and technical documentation17

The ms macros were the first of these, developed at AT&T, before they were supplanted by the mm macros.18 One goal of the mm macros was that they be usable by the 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.

Preprocessors

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.20
  • 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.21
  • ideal allows the drawing of pictures declaratively, deriving the picture by solving a system of based on vectors and transformations described by its input.

Other front-ends

Several other front-ends have been developed that are intended to be friendlier interfaces to troff.

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.28

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.24

A different approach is employed by the CADiZ suite of tools for the Z notation. Rather than the program being a preprocessor in the front of the pipeline, it interacts multiple times with as both input and output, using saved files rather than a pipe. CADiZ also contains its own set of macros, called to .

See also

  • Desktop publishing
  • DocBook
  • groff GNU troff/nroff replacement
  • nroff
  • SGML
  • TeX
  • Scribe (markup language)

References

  1. 1Kernighan, B. W. (October 2019). Unix: A History and a Memoir. Kindle Direct Publishing. p. 42. ISBN 9781695978553. Archived from the original on 2021-02-10. Retrieved 2020-06-20.
  2. 2J. F. Ossanna. Nroff/Troff User's Manual. CSTR #54, Bell Labs, 1976. Revised by B. W. Kernighan, 1992.
  3. 3McIlroy, M. D. (1987). A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971–1986 (PDF) (Technical report). CSTR. Bell Labs. 139.
  4. 4B. W. Kernighan. A Typesetter-Independent TROFF. CSTR #97, Bell Labs, 1981, revised March 1982.
  5. 5The Insider's Guide To The Universe (PDF). Charles River Data Systems, Inc. 1983. p. 13. Archived (PDF) from the original on 2024-02-25. Retrieved 2024-02-10.
  6. 6See the man page of the ditroff -> postscript converter on OpenSolaris: dpost(1) – illumos and User Commands Reference from latest Sun based

External links

  • The Text Processor for Typesetters
  • The history of troff
  • Free troff implementation Archived 2022-11-30 at the Wayback Machine
  • OpenSolaris-derived port of troff and related programs
  • User manual for the Plan 9 edition of troff (In PostScript format)
  • 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 http://www2.research.att.com/sw/download)
typing pool
19
18
18

An example of a simple business letter prepared with the mm macros would be:

.TL
.ND "January 10, 1993"
.AU "Ms. Jane Smith"
.AT "Upcoming appointment"
.MT 5
Reference #A12345
.sp 4
Mr. Samuel Jones
.sp 0
Field director, Bureau of Inspections
.sp 0
1010 Government Plaza
.sp 0
Capitoltown, ST
.sp 3
Dear Mr. Jones,
.sp 2
.P
Making reference to the noted obligation to submit for state inspection our newly created production process, we request that you consider the possible inappropriateness of subjecting the  innovative technologies of tomorrow to the largely antiquated requirements of yesterday.  If our great state is to prosper in the twenty-first century, we must take steps 
.B now ,
in 
.I this 
year of 
.I this 
decade, to prepare our industrial base for the interstate and international competition that is sure to appear.  Our new process does precisely that.  Please do not let it be undone by a regulatory environment that is no longer apt.
.P
Thank you for your consideration of our position.
.FC Sincerely
.SG

A comprehensive list of macros available is usually listed in a tmac(5) manual page.14

simultaneous equations
22
  • grn describes the pictures through graphical elements drawn at absolute coordinates, based on the gremlin file format defined by an early graphics workstation.23
  • In addition, there is a command soelim that removes .so inclusion directives from the input text.24

    A typical structure of the pipeline might be:

    soelim file | refer | ideal | pic | tbl | eqn | troff

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

    • grap draws charts, like scatter plots and histograms.25
    • chem draws chemical structure diagrams.26
    • dformat draws record-based data structures.27
    cadiz
    troff
    .ZA
    .ZZ
    29
    OpenSolaris
    Manual
    OpenSolaris
  • 7Emerson, Sandra L.; Paulsell, Karen (1987). Troff Typesetting for UNIX Systems ·. Englewood Cliffs, New Jersey: Prentice-Hall. p. 9.
  • 8Gehani, Narain (1992). Document Formatting and Typesetting on the UNIX System (Second ed.). Summit, New Jersey: Silicon Press. pp. 11–12. ISBN 978-0-9615336-2-5.
  • 9Lindholm, Stephen. "groff/troff macros: ms, mm, me or mom". ... Archived from the original on July 14, 2024. Retrieved June 3, 2024.
  • 10"Writing and Formmating UNIX Manual Pages with -man macros". home.fnal.gov. Archived from the original on 30 July 2019. Retrieved 7 May 2019.
  • 11man(7) – Linux Miscellanea Manual from ManKier.com
  • 12mdoc(7) – FreeBSD Miscellaneous Information Manual
  • 13"Index - Mandoc extended documentation". Mandoc. Archived from the original on 11 February 2021. Retrieved 7 May 2019.
  • 14groff_tmac(5) – Linux File Formats Manual from ManKier.com
  • 15groff_me(7) – Linux Miscellanea Manual from ManKier.com
  • 16groff_mm(7) – Linux Miscellanea Manual from ManKier.com
  • 17groff_ms(7) – Linux Miscellanea Manual from ManKier.com
  • 18Srinivasan, B. (1993). UNIX Document Processing and Typesetting. Singapore: World Scientific. pp. 11–12. ISBN 978-981-02-0605-5.
  • 19Mashey, John (July 18, 2018). Dag Spicer (ed.). "Oral History of John Mashey" (PDF) (Interview). Interviewed by John Markoff. Mountain View, California: Computer History Museum. pp. 27–29, 37. Retrieved May 26, 2024.
  • 20B. W. Kernighan and Lorinda L. Cherry. A System for Typesetting Mathematics. CSTR #17, Bell Labs, May 1974.
  • 21B. W. Kernighan. PIC — A Graphics Language for Typesetting (Revised User Manual). CSTR #116, Bell Labs, December 1984.
  • 22C. J. Van Wyk. IDEAL User's Manual. CSTR #103, Bell Labs, December 1981.
  • 23grn — groff preprocessor for gremlin files [1].
  • 24Robbins, Arnold (1999). UNIX in a Nutshell: A Desktop Quick Reference for System V Release 4 and Solaris 7 (Third ed.). Sebastopol, California: O'Reilly Media. pp. 151, 187–189. ISBN 978-1-56592-427-7. Archived from the original on 2024-07-13. Retrieved 2024-07-13.
  • 25J. L. Bentley and B. W. Kernighan. GRAP — A Language for Typesetting Graphs (Tutorial and User Manual). CSTR #114, Bell Labs, August 1984.
  • 26J. 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.
  • 27J. L. Bentley. DFORMAT — A Program for Typesetting Data Formats. CSTR #142, Bell Labs, April 1988.
  • 28Sanscribe: User's Guide and Reference (Revision 3.0 ed.). ... January 13, 1989. pp. 1–1, 2–1, 3–2, 6–1.
  • 29Jordan, David; McDermid, John A.; Toyn, Ian (1991). Nicholls, J. E. (ed.). CADi – Computer Aided Design in Z. Z User Workshop, Oxford 1990: Proceedings of the Fifth Annual Z User Meeting, Oxford: 17–18 December 1990. Berlin, Heidelberg: Springer-Verlag. pp. 93–104.
  • Created
    30 Sept 2001
    History
    261 edits
    179 contributors
    No edits in the last 30 days
    Last edited
    16 Aug 2026

    261 revisions in total · 179 contributors

    1. 16 Aug 2026, 10:28 UTCInternetArchiveBotRescuing 1 sources and tagging 0 as dead.) #IABot (v2.0.9.5+116diff
    2. 23 Jul 2026, 04:32 UTCNasssaNser§ Macros andoc is a groff-specific wrapper; mdoc appears in 4.4BSD, before mandoc the program−118diff
    3. 12 Jul 2026, 18:49 UTCAnomieBOTmDating maintenance tags: {{Dead link}}+15diff
    4. 12 Jul 2026, 18:28 UTCSurv1v4l1st§ External links Reporting dead link+13diff
    5. 3 Feb 2026, 05:11 UTCYello231Rescuing 6 sources and tagging 0 as dead.) #IABot (v2.0.9.5+973diff
    6. 8 Jan 2026, 06:32 UTCTemporary account§ Fixed wikitext header markup (removed spaces)−2diff
    7. 11 Aug 2025, 03:56 UTCBender the Botm§ External links HTTP to HTTPS for SourceForge+1diff
    8. 31 Jul 2025, 07:52 UTCCedar101m§ Macros {{codett}}+316diff

    View full revision history

    Created
    30 Sept 2001
    History
    261 edits
    179 contributors
    No edits in the last 30 days
    Last edited
    16 Aug 2026

    Go deeper: linked from this article

    • Listed under See also

      TeX

      Typesetting system

      TeX, stylized as TeX, is a free and open source software typesetting program that was designed and written by computer scientist and Stanford University professor Donald Knuth and first released in 1978.

      19 min readGo deeper
    • Listed under See also

      Standard Generalized Markup Language

      Markup language

      The Standard Generalized Markup Language (SGML; ISO 8879:1986) is a standard for defining generalized markup languages for documents.

      12 min readGo deeper
    • Linked from the introduction

      Unix

      Operating system

      Unix (YOO-niks; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, the development of which started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and others.

      22 min readGo deeper
    • Linked from the introduction

      Typesetting

      Composition of text by means of arranging physical types or digital equivalents

      Typesetting is the composition of text for publication, display, or distribution by means of arranging physical type (or sort) in mechanical systems or glyphs in digital systems representing characters (letters and other symbols).

      9 min readGo deeper
    • Listed under See also

      Desktop publishing

      Page layout using a personal computer

      Desktop publishing (DTP) is the creation of documents using dedicated software on a personal ("desktop") computer.

      8 min readGo deeper
    • Linked from the introduction

      Word processor

      Device or computer program used for writing and editing documents

      A word processor (WP) is a device or computer program that provides for input, editing, formatting, and output of text, often with some additional features.

      15 min readGo deeper
    • Listed under See also

      DocBook

      Markup language for documentation

      DocBook is a semantic markup language for technical documentation.

      7 min readGo deeper
    • Linked from the introduction

      Overhead projector

      Device that projects a transparent image

      An overhead projector (often abbreviated to OHP), like a film or slide projector, uses light to project an enlarged image on a screen, allowing the view of a small document or picture to be shared with a large audience.

      9 min readGo deeper
    • Linked from the introduction

      CAT (phototypesetter)

      Computer-controlled phototypesetter

      The GSI C/A/T (Computer Assisted Typesetter) is a phototypesetter developed by Graphic Systems in 1972.

      3 min readGo deeper

    Adjacent: shared categories and similar text

    • Linked in “History”

      Typeface

      Set of characters that share common design features

      A typeface is a design of letters, numbers and other symbols, to be used in printing or for electronic display.

      22 min readGo deeper
    • Linked in “History”

      Peer review

      Evaluation by peers with similar expertise

      Peer review is the evaluation of work by one or more people with similar competencies as the producers of the work (peers).

      18 min readGo deeper
    • Linked in “History”

      Line printer

      Impact printer that prints one entire line of text at a time

      A line printer prints one entire line of text before advancing to another line.

      8 min readGo deeper
    • Linked in “History”

      Massachusetts Institute of Technology

      Private research university in Cambridge, Massachusetts, United States

      The Massachusetts Institute of Technology (MIT) is a private research university in Cambridge, Massachusetts, United States.

      77 min readGo deeper
    • Linked in “History”

      Lucent Technologies

      American telecommunications company (1996-2006)

      Lucent Technologies, Inc. was an American multinational telecommunications equipment company headquartered in Murray Hill, New Jersey.

      26 min readGo deeper