HOME

TheInfoList



OR:

troff (), short for "typesetter roff", is the major component of a document processing system developed by
Bell Labs Nokia Bell Labs, originally named Bell Telephone Laboratories (1925–1984), then AT&T Bell Laboratories (1984–1996) and Bell Labs Innovations (1996–2007), is an American industrial research and scientific development company owned by mul ...
for the
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, ...
operating system. troff and the related
nroff nroff (short for "new roff") is a text-formatting program on Unix and Unix-like operating systems. It produces output suitable for simple fixed-width printers and terminal windows. It is an integral part of the Unix help system, being used t ...
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 Typesetting is the composition of text by means of arranging physical ''type'' (or ''sort'') in mechanical systems or '' glyphs'' in digital systems representing '' characters'' (letters and other symbols).Dictionary.com Unabridged. Random ...
systems, specifically the Graphic Systems CAT that had been introduced in 1972. Both used the same underlying
markup language Markup language refers to a text-encoding system consisting of a set of symbols inserted in a text document to control its structure, formatting, or the relationship between its parts. Markup is often used to control the display of the document ...
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 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 A transparency, also known variously as a viewfoil, foil, or viewgraph, is a thin sheet of transparent flexible material, typically polyester (historically cellulose acetate), onto which figures can be drawn. These are then placed on an overhea ...
, and the ms and mm macros for letters, books, technical memoranda, and reports.


History

''troffs origins can be traced to a
text-formatting Typesetting is the composition of text by means of arranging physical ''type'' (or ''sort'') in mechanical systems or ''glyphs'' in digital systems representing ''characters'' (letters and other symbols).Dictionary.com Unabridged. Random Ho ...
program Program, programme, programmer, or programming may refer to: Business and management * Program management, the process of managing several related projects * Time management * Program, a part of planning Arts and entertainment Audio * Programm ...
called
RUNOFF Runoff, run-off or RUNOFF may refer to: * RUNOFF, the first computer text-formatting program * Runoff or run-off, another name for bleed, printing that lies beyond the edges to which a printed sheet is trimmed * Runoff or run-off, a stock marke ...
, which was written by
Jerome H. Saltzer Jerome Howard "Jerry" Saltzer (born October 9, 1939) is an American computer scientist. Career Jerry Saltzer received an ScD in Electrical Engineering from MIT in 1966. His dissertation Traffic Control in a Multiplexed System was advised by ...
for MIT's CTSS
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
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 BCPL ("Basic Combined Programming Language") is a procedural, imperative, and structured programming language. Originally intended for writing compilers for other languages, BCPL is no longer in common use. However, its influence is still ...
programming language A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming ...
. The first version of
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, ...
was developed on a PDP-7 which was sitting around
Bell Labs Nokia Bell Labs, originally named Bell Telephone Laboratories (1925–1984), then AT&T Bell Laboratories (1984–1996) and Bell Labs Innovations (1996–2007), is an American industrial research and scientific development company owned by mul ...
. In 1971 the developers wanted to get a
PDP-11 The PDP-11 is a series of 16-bit minicomputers sold by Digital Equipment Corporation (DEC) from 1970 into the 1990s, one of a set of products in the Programmed Data Processor (PDP) series. In total, around 600,000 PDP-11s of all models were sol ...
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 F. Ossanna. When they needed a more flexible language, a new version of ''roff'' called
nroff nroff (short for "new roff") is a text-formatting program on Unix and Unix-like operating systems. It produces output suitable for simple fixed-width printers and terminal windows. It is an integral part of the Unix help system, being used t ...
(''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 review Peer review is the evaluation of work by one or more people with similar competencies as the producers of the work ( peers). It functions as a form of self-regulation by qualified members of a profession within the relevant field. Peer revie ...
ers, who thought that manuscripts using ''troff'' had been published before. 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 printer A line printer prints one entire line of text before advancing to another line. Most early line printers were impact printers. Line printers are mostly associated with unit record equipment and the early days of digital computing, but the ...
s and character
terminal Terminal may refer to: Computing Hardware * Terminal (electronics), a device for joining electrical circuits together * Terminal (telecommunication), a device communicating over a line * Computer terminal, a set of primary input and output devi ...
s. It understood everything ''troff'' did, and ignored the commands which were not applicable, e.g.,
font In metal typesetting, a font is a particular size, weight and style of a typeface. Each font is a matched set of type, with a piece (a " sort") for each glyph. A typeface consists of a range of such fonts that shared an overall design. In mo ...
changes. Ossanna's ''troff'' was written in
PDP-11 The PDP-11 is a series of 16-bit minicomputers sold by Digital Equipment Corporation (DEC) from 1970 into the 1990s, one of a set of products in the Programmed Data Processor (PDP) series. In total, around 600,000 PDP-11s of all models were sol ...
assembly language In computer programming, assembly language (or assembler language, or symbolic machine code), often referred to simply as Assembly and commonly abbreviated as ASM or asm, is any low-level programming language with a very strong correspondence b ...
and produced output specifically for the CAT
phototypesetter Phototypesetting is a method of setting type. It uses photography to make columns of type on a scroll of photographic paper. It has been made obsolete by the popularity of the personal computer and desktop publishing (digital typesetting). The ...
. 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 Brian Wilson Kernighan (; born 1942) is a Canadian computer scientist. He worked at Bell Labs and contributed to the development of Unix alongside Unix creators Ken Thompson and Dennis Ritchie. Kernighan's name became widely known through co- ...
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. 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 Unix System Laboratories (USL), sometimes written UNIX System Laboratories to follow relevant trademark guidelines of the time, was an American software laboratory and product development company that existed from 1989 through 1993. At first wh ...
(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 Lucent Technologies, Inc. was an American multinational telecommunications equipment company headquartered in Murray Hill, New Jersey. It was established on September 30, 1996, through the divestiture of the former AT&T Technologies business u ...
Software Solutions (formerly USL); * troff, Plan 9 edition. While ''troff'' has been supplanted by other programs such as Interleaf, FrameMaker, and
LaTeX Latex is an emulsion (stable dispersion) of polymer microparticles in water. Latexes are found in nature, but synthetic latexes are common as well. In nature, latex is found as a milky fluid found in 10% of all flowering plants (angiosperms ...
, 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 GNU () is an extensive collection of free software (383 packages as of January 2022), which can be used as an operating system or can be used in parts with other operating systems. The use of the completed GNU tools led to the family of operat ...
system beginning in 1990. In addition, due to the open sourcing of
Ancient UNIX Ancient UNIX is any early release of the Unix code base prior to Unix System III, particularly the Research Unix releases prior to and including Version 7 (the base for UNIX/32V as well as later developments of AT&T Unix). After the publica ...
systems, as well as modern successors such as the ditroff-based open-sourced versions found on
OpenSolaris OpenSolaris () is a discontinued open-source computer operating system based on Solaris and created by Sun Microsystems. It was also, perhaps confusingly, the name of a project initiated by Sun to build a developer and user community around t ...
and
Plan 9 from Bell Labs Plan 9 from Bell Labs is a distributed operating system which originated from the Computing Science Research Center (CSRC) at Bell Labs in the mid-1980s and built on UNIX concepts first developed there in the late 1960s. Since 2000, Plan 9 has be ...
, there are several versions of AT&T troff (CAT and ditroff-based) available under various open-source licenses.


Macros

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 ''-m''name, which has led to many macro sets being known as the base filename with a leading m. The standard macro sets, with leading m are: * man for creating
manual Manual may refer to: Instructions * User guide * Owner's manual An owner's manual (also called an instruction manual or a user guide) is an instructional book or booklet that is supplied with almost all technologically advanced consumer ...
pages * mdoc for semantically-annotated
manual Manual may refer to: Instructions * User guide * Owner's manual An owner's manual (also called an instruction manual or a user guide) is an instructional book or booklet that is supplied with almost all technologically advanced consumer ...
pages, which are better adapted to
mandoc mandoc (historically called mdocml) is a utility used for formatting man pages in BSD Operating Systems (e.g. NetBSD), specifically those written in the ''mdoc'' and ''man'' macro languages. Unlike the groff and older troff and nroff tools that ...
conversion to other formats. mandoc is a fusion that supports both sets of manual commands. * me for creating research papers * mm for creating memorandums * ms for creating books, reports, and technical documentation A more comprehensive list of macros available is usually listed in a tmac(5)
manual page A man page (short for manual page) is a form of software documentation usually found on a Unix or Unix-like operating system. Topics covered include computer programs (including library and system calls), formal standards and conventions, and ...
.


Preprocessors

As ''troff'' evolved, since there are several things which cannot be done easily in ''troff'', several
preprocessor In computer science, a preprocessor (or precompiler) is a program that processes its input data to produce output that is used as input in another program. The output is said to be a preprocessed form of the input data, which is often used by so ...
s 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. * tbl is a preprocessor for formatting tables. *
refer Refer or referral may refer to: * Reference, a relation of designation or linking between objects **Word-sense disambiguation, when a single term may refer to multiple meanings * Referral marketing, to personally recommend, endorse, and pass a per ...
(and the similar program ''bib'') processes citations in a document according to a
bibliographic Bibliography (from and ), as a discipline, is traditionally the academic study of books as physical, cultural objects; in this sense, it is also known as bibliology (from ). English author and bibliographer John Carter describes ''bibliography ...
database. Three preprocessors provide ''troff'' with drawing capabilities by defining a
domain-specific language A domain-specific language (DSL) is a computer language specialized to a particular application domain. This is in contrast to a general-purpose language (GPL), which is broadly applicable across domains. There are a wide variety of DSLs, ranging ...
for describing the picture. * '' pic'' is a procedural programming language providing various drawing functions like ''circle'' and ''box''. * ''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. * ''grn'' describes the pictures through graphical elements drawn at absolute coordinates, based on the '' gremlin file format'' defined by an early graphics workstation. Yet more preprocessors allow the drawing of more complex pictures by generating output for ''pic''. * ''grap'' draws
chart A chart (sometimes known as a graph) is a graphical representation for data visualization, in which "the data is represented by symbols, such as bars in a bar chart, lines in a line chart, or slices in a pie chart". A chart can represent ...
s, like scatter plots and
histograms A histogram is an approximate representation of the distribution of numerical data. The term was first introduced by Karl Pearson. To construct a histogram, the first step is to " bin" (or "bucket") the range of values—that is, divide the en ...
. * ''chem'' draws chemical structure diagrams. * ''dformat'' draws record-based
data structures In computer science, a data structure is a data organization, management, and storage format that is usually chosen for efficient access to data. More precisely, a data structure is a collection of data values, the relationships among them, ...
.J. L. Bentley. ''DFORMAT — A Program for Typesetting Data Formats''. CSTR #142, Bell Labs, April 1988.


See also

*
Desktop publishing Desktop publishing (DTP) is the creation of documents using page layout software on a personal ("desktop") computer. It was first used almost exclusively for print publications, but now it also assists in the creation of various forms of online ...
* DocBook * groff GNU troff/nroff replacement *
nroff nroff (short for "new roff") is a text-formatting program on Unix and Unix-like operating systems. It produces output suitable for simple fixed-width printers and terminal windows. It is an integral part of the Unix help system, being used t ...
*
SGML The Standard Generalized Markup Language (SGML; ISO 8879:1986) is a standard for defining generalized markup languages for documents. ISO 8879 Annex A.1 states that generalized markup is "based on two postulates": * Declarative: Markup should ...
* TeX *
Scribe (markup language) Scribe is a markup language and word processing system that pioneered the use of descriptive markup. Scribe was revolutionary when it was proposed, because it involved for the first time a clean separation of presentation and content. History ...


References


External links


The Text Processor for Typesetters



Free troff implementation



User manual for the Plan 9 edition of troff
(In PostScript format)

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 th
Documenter's Workbench (DWB) Release 3.3
(ported to current UNIX systems from http://www2.research.att.com/sw/download) {{Plan 9 commands Free typesetting software Page description languages History of software Plan 9 commands Unix text processing utilities