troff
This articleis missing informationabout short list of books typeset with troff.(January 2021) |
Original author(s) | Joe Ossanna |
---|---|
Developer(s) | AT&T Bell Laboratories |
Written in | C |
Operating system | Unix,Unix-like,Plan 9 |
Platform | Cross-platform |
Type | Command |
License | Plan 9:MIT License |
Website | troff |
troff(/ˈtiːrɒf/), short for "typesetter roff", is the major component of adocument processing systemdeveloped byBell Labsfor theUnixoperating system. troff and the relatednroffwere both developed from the originalroff.
While nroff was intended to produce output on terminals and line printers, troff was intended to produce output ontypesettingsystems, specifically theGraphic Systems CATthat had been introduced in 1972. Both used the same underlyingmarkup languageand a single source file could normally be used by nroff or troff without change.
trofffeatures commands to designate fonts, spacing, paragraphs, margins, footnotes and more. Unlike many other text formatters,troffcan 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.
Extensivemacro packageshave been created for various document styles. A typical distribution oftroffincludes thememacros for formatting research papers,manandmdocmacros for creating Unixman pages,mvmacros for creating mountabletransparencies,and themsandmmmacros for letters, books, technical memoranda, and reports.
History
[edit]troff's origins can be traced to atext-formattingprogramcalledRUNOFF,which was written byJerome H. SaltzerforMIT'sCTSSoperating systemin the mid-1960s. (The name allegedly came from the phraseI'll run off a document.)
Bob Morrisported it to theGE 635architecture and called the programroff(an abbreviation ofrunoff).[citation needed]It was rewritten asrffor thePDP-7,and at the same time (1969),Doug McIlroyrewrote an extended and simplified version ofroffin theBCPLprogramming language.
The first version ofUnixwas developed on a PDP-7 which was sitting aroundBell Labs.In 1971 the developers wanted to get aPDP-11for 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'sroff,written byJoe F. Ossanna.
When they needed a more flexible language, a new version ofroffcallednroff(newer "roff") was written, which provided the basis for all future versions. When they got aGraphic Systems CAT phototypesetter,Ossanna modifiednroffto support multiple fonts andproportional spacing.Dubbedtroff,fortypesetter roff,its sophisticated output amazed the typesetter manufacturer and confusedpeer reviewers,who thought that manuscripts usingtroffhad been published before.[2][3]As such, the nametroffis pronounced/ˈtiːrɒf/rather than */ˈtrɒf/.
Withtroffcamenroff(they were actually almost the same program), which was for producing output forline printersand characterterminals.It understood everythingtroffdid, and ignored the commands which were not applicable, e.g.,fontchanges.
Ossanna'stroffwas written inPDP-11assembly languageand produced output specifically for theCAT phototypesetter.He rewrote it inC,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, soBrian Kernighantook on the task of rewritingtroff.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 oftroff(often calledditrofffordevice independent troff) had several extensions, which included drawing functions.[4]The program's documentation defines the output format ofditroff,which is used by many moderntroffclones like GNUgroff.
In 1983,troffwas one of several UNIX tools available for Charles River Data Systems'UNOSoperating system underBell Laboratorieslicense.[5]
Thetroffcollection of tools (includingpre- and post-processors) was eventually calledDocumenter's WorkBench(DWB), and was under continuous development in Bell Labs and later at the spin-offUnix System Laboratories(USL) through 1994. At that time,SoftQuadtook over the maintenance, although Brian Kernighan continued to improvetroffon his own. Thus, there are at least the following variants of the original Bell Labstroffin use:
- the SoftQuad DWB, based on USL DWB 2.0 from 1994;
- the DWB 3.4 fromLucentSoftware Solutions (formerly USL);
- troff,Plan 9edition.
Whiletroffhas been supplanted by other programs such asInterleaf,FrameMaker,andLaTeX,it is still being used quite extensively. It remains the default formatter for theUNIX documentation.
The software was reimplemented asgrofffor theGNUsystem beginning in 1990. In addition, due to theopen sourcingofAncient UNIXsystems, as well as modern successors such as the ditroff-based open-sourced versions found onOpenSolarisandPlan 9 from Bell Labs,there are several versions of AT&T troff (CAT and ditroff-based[6]) available under various open-source licenses.
Macros
[edit]In general, one was not encouraged to use troff directly, but rather go through some easier-to-use interface.[7][8] Troff includesmacrosthat 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. Thecommand-line argumentfor including a macro set is-mname,which has led to many macro sets being known as the base filename with a leadingm.[9]
The standard macro sets, with leadingmare:
- manfor creatingmanualpages[10][11]
- mdocfor semantically-annotatedmanualpages, which are better adapted tomandocconversion to other formats.[12][13]
mandoc
is a fusion that supports both sets of manual commands.[14] - mefor creating research papers[15]
- mmfor creatingmemorandums[16]
- msfor creating books, reports, and technical documentation[17]
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 thetyping poolat Bell Labs and, over time, this happened and the mm macros became a standard at Bell Labs.[19]AT&T made the mm macros commercially available for System V Unix.[18]In contrast, the me macros were developed at Berkeley.[18]
An example of a simple business letter prepared with the mm macros would be:
.ND "January 10, 1993"
.AU "Ms. Jane Smith"
.AT "Upcoming appointment"
.MT 5
.DS
Reference #A12345
.sp 4
Mr. Samuel Jones
Field director, Bureau of Inspections
1010 Government Plaza
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 atmac(5)
manual page.[14]
Preprocessors
[edit]Astroffevolved, since there are several things which cannot be done easily introff,severalpreprocessorswere developed. These programs transform certain parts of a document intotroffinput, fitting naturally into the use of "pipelines" in Unix — sending the output of one program as the input to another (seepipes 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.
- eqnpreprocessor allows mathematical formulae to be specified in simple and intuitive manner.[20]
- tbl is a preprocessor for formatting tables.
- refer(and the similar programbib) processes citations in a document according to abibliographicdatabase.
Three preprocessors providetroffwith drawing capabilities by defining adomain-specific languagefor describing the picture.
- picis aprocedural programming languageproviding various drawing functions likecircleandbox.[21]
- idealallows the drawing of picturesdeclaratively,deriving the picture by solving a system ofsimultaneous equationsbased on vectors and transformations described by its input.[22]
- grndescribes the pictures through graphical elements drawn at absolute coordinates, based on thegremlin file formatdefined by an early graphics workstation.[23]
In addition, there is a commandsoelimthat removes.so
inclusion directives from the input text.[24]
A typical structure of the pipeline might be:
soelimfile| refer | ideal | pic | tbl | eqn | troff
Yet more preprocessors allow the drawing of more complex pictures by generating output forpic.
- grapdrawscharts,likescatter plotsandhistograms.[25]
- chemdrawschemical structure diagrams.[26]
- dformatdrawsrecord-baseddata structures.[27]
Other front-ends
[edit]Several other front-ends have been developed that are intended to be friendlier interfaces to troff.
One of them isSanscribe,originally developed at Berkeley and then enhanced during the 1980s by several users includingIntelandInterACT.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 isvgrind,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 justFortran,C,andC++but also domain-specific tools such asBourne shellandyaccas well as those further afield such asEmacs LispandIcon.[24]
A different approach is employed by theCADiZsuite of tools for theZ notation.Rather than thecadiz
program being a preprocessor in the front of the pipeline, it interacts multiple times withtroff
as both input and output, using saved files rather than a pipe. CADiZ also contains its own set of macros, called.ZA
through.ZZ
.[29]
See also
[edit]- Desktop publishing
- DocBook
- groffGNU troff/nroff replacement
- nroff
- SGML
- TeX
- Scribe (markup language)
References
[edit]- ^Kernighan, B. W.(October 2019).Unix: A History and a Memoir.Kindle Direct Publishing. p. 42.ISBN9781695978553.
- ^J. F. Ossanna.Nroff/Troff User's Manual.CSTR #54, Bell Labs, 1976. Revised by B. W. Kernighan, 1992.
- ^McIlroy, M. D.(1987).A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971–1986(PDF)(Technical report). CSTR. Bell Labs. 139.
- ^B. W. Kernighan.A Typesetter-Independent TROFF.CSTR #97, Bell Labs, 1981, revised March 1982.
- ^The Insider's Guide To The Universe(PDF).Charles River Data Systems, Inc. 1983. p. 13.
- ^See the man page of the ditroff -> postscript converter on OpenSolaris:illumosandOpenSolarisUser Commands ReferenceManualfrom latest Sun basedOpenSolaris –
- ^Emerson, Sandra L.; Paulsell, Karen (1987).Troff Typesetting for UNIX Systems ·.Englewood Cliffs, New Jersey: Prentice-Hall. p. 9.
- ^Gehani, Narain (1992).Document Formatting and Typesetting on the UNIX System(Second ed.). Summit, New Jersey: Silicon Press. pp. 11–12.ISBN978-0-9615336-2-5.
- ^Lindholm, Stephen."groff/troff macros: ms, mm, me or mom"....RetrievedJune 3,2024.
- ^"Writing and Formmating UNIX Manual Pages with -man macros".home.fnal.gov.Retrieved7 May2019.
- ^LinuxMiscellaneaManual –
- ^FreeBSDMiscellaneous InformationManual –
- ^"Index - Mandoc extended documentation".Mandoc.Retrieved7 May2019.
- ^abLinuxFile FormatsManual –
- ^LinuxMiscellaneaManual –
- ^LinuxMiscellaneaManual –
- ^LinuxMiscellaneaManual –
- ^abcSrinivasan, B. (1993).UNIX Document Processing and Typesetting.Singapore: World Scientific. pp. 11–12.ISBN978-981-02-0605-5.
- ^Mashey, 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.RetrievedMay 26,2024.
- ^B. W. Kernighan and Lorinda L. Cherry.A System for Typesetting Mathematics.CSTR #17, Bell Labs, May 1974.
- ^B. W. Kernighan.PIC — A Graphics Language for Typesetting (Revised User Manual).CSTR #116, Bell Labs, December 1984.
- ^C. J. Van Wyk.IDEAL User's Manual.CSTR #103, Bell Labs, December 1981.
- ^grn — groff preprocessor for gremlin files[1].
- ^abRobbins, 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.ISBN978-1-56592-427-7.
- ^J. L. Bentley and B. W. Kernighan.GRAP — A Language for Typesetting Graphs (Tutorial and User Manual).CSTR #114, Bell Labs, August 1984.
- ^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.
- ^J. L. Bentley.DFORMAT — A Program for Typesetting Data Formats.CSTR #142, Bell Labs, April 1988.
- ^Sanscribe: User's Guide and Reference(Revision 3.0 ed.).... January 13, 1989. pp. 1–1, 2–1, 3–2, 6–1.
- ^Jordan, 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.
External links
[edit]- The Text Processor for Typesetters
- The history of troff
- Free troff implementation
- 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 Berkeleysection 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 theDocumenter's Workbench (DWB) Release 3.3(ported to current UNIX systems fromhttp://www2.research.att.com/sw/download)