Troff Macros
   HOME

TheInfoList



OR:

troff (), short for "typesetter roff", is the major component of a
document processing system 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. Early word processors were stand-alone devices dedicated to the function, but current ...
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 mult ...
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, and ot ...
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 to fo ...
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 Ho ...
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 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 ev ...
, mv macros for creating mountable
transparencies A transparency, also known variously as a viewfoil, foil, or viewgraph, is a thin sheet of transparency (optics), transparent flexible material, typically polyester (historically cellulose acetate), onto which figures can be drawn. These are then ...
, 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 * Progra ...
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 market ...
, 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 ...
for
MIT The Massachusetts Institute of Technology (MIT) is a private land-grant research university in Cambridge, Massachusetts. Established in 1861, MIT has played a key role in the development of modern technology and science, and is one of the mo ...
's CTSS
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. Time-sharing operating systems schedule tasks for efficient use of the system and may also in ...
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 The GE-600 series was a family of 36-bit mainframe computers originating in the 1960s, built by General Electric (GE). When GE left the mainframe business the line was sold to Honeywell, which built similar systems into the 1990s as the division m ...
architecture and called the program roff (an abbreviation of ''runoff''). It was rewritten as rf for the
PDP-7 The PDP-7 was a minicomputer produced by Digital Equipment Corporation as part of the PDP series. Introduced in 1964, shipped since 1965, it was the first to use their Flip-Chip technology. With a cost of , it was cheap but powerful by the st ...
, and at the same time (1969),
Doug McIlroy Malcolm Douglas McIlroy (born 1932) is a mathematician, engineer, and programmer. As of 2019 he is an Adjunct Professor of Computer Science at Dartmouth College. McIlroy is best known for having originally proposed Unix pipelines and developed se ...
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, and ot ...
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 mult ...
. 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 sold, ...
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 to fo ...
(''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 A typeface (or font family) is the design of lettering that can include variations in size, weight (e.g. bold), slope (e.g. italic), width (e.g. condensed), and so on. Each of these variations of the typeface is a font. There are thousands o ...
. 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 review ...
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 devic ...
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 mod ...
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 sold, ...
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 be ...
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-au ...
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 Pre or PRE may refer to: Places *Preston railway station, UK National Rail code PRE *Prince Edward station, on Hong Kong's MTR People *Steve Prefontaine (1951–1975), an American runner nicknamed "Pre" Arts, entertainment, and media *Pre (ba ...
- 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 SoftQuad Software was a Canadian software company best known for HoTMetaL, the first commercial HTML editor. It is also known for Author/Editor, the first specialized SGML editor, and Panorama, the first browser plugin for SGML. Panorama demonstrat ...
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 corporation, multinational telecommunications equipment company headquartered in Murray Hill, New Jersey, Murray Hill, New Jersey. It was established on September 30, 1996, through the dives ...
Software Solutions (formerly USL); * troff, Plan 9 edition. While ''troff'' has been supplanted by other programs such as
Interleaf Interleaf, Inc., was a company that created computer software products for the technical publishing creation and distribution process. Founded in 1981, its initial product was the first commercial document processor that integrated text and graphi ...
,
FrameMaker Adobe FrameMaker is a document processor designed for writing and editing large or complex documents, including structured documents. It was originally developed by Frame Technology Corporation, which was bought by Adobe. Overview 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 Open-source software (OSS) is computer software that is released under a license in which the copyright holder grants users the rights to use, study, change, and distribute the software and its source code to anyone and for any purpose. Open ...
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 publicati ...
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 th ...
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 A command-line interpreter or command-line processor uses a command-line interface (CLI) to receive commands from a user in the form of lines of text. This provides a means of setting parameters for the environment, invoking executables and pro ...
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 * Instruction manual (gaming) * Online help Other uses * Manual (music), a keyboard, as for an organ * Manual (band) * Manual transmission * Manual, a bicycle technique similar to ...
pages * mdoc for semantically-annotated
manual Manual may refer to: Instructions * User guide * Owner's manual * Instruction manual (gaming) * Online help Other uses * Manual (music), a keyboard, as for an organ * Manual (band) * Manual transmission * Manual, a bicycle technique similar to ...
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 tha ...
conversion to other formats. mandoc is a fusion that supports both sets of manual commands. * me for creating research papers * mm for creating
memorandum A memorandum ( : memoranda; abbr: memo; from the Latin ''memorandum'', "(that) which is to be remembered") is a written message that is typically used in a professional setting. Commonly abbreviated "memo," these messages are usually brief and ...
s * 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 ev ...
.


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 Pipe(s), PIPE(S) or piping may refer to: Objects * Pipe (fluid conveyance), a hollow cylinder following certain dimension rules ** Piping, the use of pipes in industry * Smoking pipe ** Tobacco pipe * Half-pipe and quarter pipe, semi-circula ...
). 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 Part of the troff suite of Unix document layout tools, tbl is a preprocessor that formats tables in preparation for processing with troff/nroff. Overview Mike Lesk is the original author of tbl. Like the main troff program, it uses command li ...
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 perso ...
(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 f ...
for describing the picture. * '' pic'' is a
procedural programming language Procedural programming is a programming paradigm, derived from imperative programming, based on the concept of the ''procedure call''. Procedures (a type of routine or subroutine) simply contain a series of computational steps to be carried ...
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 In mathematics, a set of simultaneous equations, also known as a system of equations or an equation system, is a finite set of equations for which common solutions are sought. An equation system is usually classified in the same manner as single e ...
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 tabu ...
s, like
scatter plots A scatter plot (also called a scatterplot, scatter graph, scatter chart, scattergram, or scatter diagram) is a type of plot or mathematical diagram using Cartesian coordinates to display values for typically two variables for a set of data. ...
and
histograms A histogram is an approximate representation of the frequency distribution, distribution of numerical data. The term was first introduced by Karl Pearson. To construct a histogram, the first step is to "Data binning, bin" (or "Data binning, buck ...
. * ''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, a ...
.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 c ...
*
DocBook DocBook is a semantic markup language for technical documentation. It was originally intended for writing technical documents related to computer hardware and software, but it can be used for any other sort of documentation. As a semantic languag ...
* 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 to fo ...
*
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 des ...
*
TeX Tex may refer to: People and fictional characters * Tex (nickname), a list of people and fictional characters with the nickname * Joe Tex (1933–1982), stage name of American soul singer Joseph Arrington Jr. Entertainment * ''Tex'', the Italian ...
*
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