Share to: share facebook share twitter share wa share telegram print page

Troff

troff
Original author(s)Joe Ossanna
Developer(s)AT&T Bell Laboratories
Written inC
Operating systemUnix, Unix-like, Plan 9
PlatformCross-platform
TypeCommand
LicensePlan 9: MIT License
Websitetroff.org Edit this on Wikidata

troff (/ˈtrɒ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.

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 that 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 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

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).[citation needed] 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.[2][3] As such, the name troff is pronounced /ˈtrɒ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-based[6]) 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.[7][8] 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 pages[10][11]
  • mdoc for semantically-annotated manual pages, which are better adapted to mandoc conversion to other formats.[12][13] mandoc is a fusion that supports both sets of manual commands.[14]
  • me for creating research papers[15]
  • mm for creating memorandums[16]
  • ms for 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 the typing pool at 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 a tmac(5) manual page.[14]

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.

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.

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 cadiz program being a preprocessor in the front of the pipeline, it interacts multiple times with troff 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

References

  1. ^ Kernighan, B. W. (October 2019). Unix: A History and a Memoir. Kindle Direct Publishing. p. 42. ISBN 9781695978553.
  2. ^ J. F. Ossanna. Nroff/Troff User's Manual. CSTR #54, Bell Labs, 1976. Revised by B. W. Kernighan, 1992.
  3. ^ McIlroy, M. D. (1987). A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971–1986 (PDF) (Technical report). CSTR. Bell Labs. 139.
  4. ^ B. W. Kernighan. A Typesetter-Independent TROFF. CSTR #97, Bell Labs, 1981, revised March 1982.
  5. ^ The Insider's Guide To The Universe (PDF). Charles River Data Systems, Inc. 1983. p. 13.
  6. ^ See the man page of the ditroff -> postscript converter on OpenSolaris: dpost(1) – illumos and OpenSolaris User Commands Reference Manual from latest Sun based OpenSolaris
  7. ^ Emerson, Sandra L.; Paulsell, Karen (1987). Troff Typesetting for UNIX Systems ·. Englewood Cliffs, New Jersey: Prentice-Hall. p. 9.
  8. ^ Gehani, 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.
  9. ^ Lindholm, Stephen. "groff/troff macros: ms, mm, me or mom". ... Retrieved June 3, 2024.
  10. ^ "Writing and Formmating UNIX Manual Pages with -man macros". home.fnal.gov. Retrieved 7 May 2019.
  11. ^ man(7) – Linux Miscellanea Manual
  12. ^ mdoc(7) – FreeBSD Miscellaneous Information Manual
  13. ^ "Index - Mandoc extended documentation". Mandoc. Retrieved 7 May 2019.
  14. ^ a b groff_tmac(5) – Linux File Formats Manual
  15. ^ groff_me(7) – Linux Miscellanea Manual
  16. ^ groff_mm(7) – Linux Miscellanea Manual
  17. ^ groff_ms(7) – Linux Miscellanea Manual
  18. ^ a b c Srinivasan, B. (1993). UNIX Document Processing and Typesetting. Singapore: World Scientific. pp. 11–12. ISBN 978-981-02-0605-5.
  19. ^ 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. Retrieved May 26, 2024.
  20. ^ B. W. Kernighan and Lorinda L. Cherry. A System for Typesetting Mathematics. CSTR #17, Bell Labs, May 1974.
  21. ^ B. W. Kernighan. PIC — A Graphics Language for Typesetting (Revised User Manual). CSTR #116, Bell Labs, December 1984.
  22. ^ C. J. Van Wyk. IDEAL User's Manual. CSTR #103, Bell Labs, December 1981.
  23. ^ grn — groff preprocessor for gremlin files [1].
  24. ^ a b Robbins, 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.
  25. ^ J. L. Bentley and B. W. Kernighan. GRAP — A Language for Typesetting Graphs (Tutorial and User Manual). CSTR #114, Bell Labs, August 1984.
  26. ^ 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.
  27. ^ J. L. Bentley. DFORMAT — A Program for Typesetting Data Formats. CSTR #142, Bell Labs, April 1988.
  28. ^ Sanscribe: User's Guide and Reference (Revision 3.0 ed.). ... January 13, 1989. pp. 1–1, 2–1, 3–2, 6–1.
  29. ^ 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.

Read other articles:

Meat of domestic sheep Mutton redirects here. For goat meat, which is what 'mutton' primarily refers to in South Asia and the Caribbean, see goat meat. For other uses, see Mutton (disambiguation). Lamb Mutton Lamb, hogget, and mutton, generically sheep meat,[1] are the meat of domestic sheep, Ovis aries. A sheep in its first year is a lamb and its meat is also lamb. The meat from sheep in their second year is hogget. Older sheep meat is mutton. Generally, hogget and sheep meat are not...

العلاقات اليمنية الباكستانية   اليمن   باكستان السفارات سفارة اليمن في باكستان سفارة باكستان في اليمن تعديل مصدري - تعديل   العلاقات اليمنية الباكستانية، هي العلاقات الثنائية بين اليمن وباكستان. تعود العلاقات بين البلدين عندما كانت كلا البلدين جزء من الطرق الت

1988 animated film Peter PanTitle cardDirected byDavid CherkasskiyRichard TruebloodWritten byPaul Leadon, J. M. Barrie (original author)Produced byRoz PhillipsStarringPhillip HintonKeith ScottDaniel FloydCarol AdamsOlivia MartinJaye RosenbergBen BrennanMichael AnthonyEdited byMark D'Arcy Irvine, Peter JenningsMusic byJohn StuartProductioncompanyBurbank Animation StudiosDistributed byNuTech DigitalRelease date June 23, 1988 (1988-06-23) Running time50 minutesCountryAustraliaLang...

اليمامة (بالإنجليزية: Dove)‏ طائر صغير يشبه الحمامة. يرمز إلى السلام (الدنيوى، أو إلى الروح القدس دينيا) ولقد كان يضحى للإلهة عشتار في حضارات الشرق القديم، وكذلك للإلهة أفروديت في حضارة اليونان باليمام في معبديهما. وتروى الأسطورة اليونانية أصل اليمام الذي يجر عربة أفروديت فتق

Os primeiros socorros em saúde mental são uma extensão do conceito de primeiros socorros tradicionais para cobrir condições de saúde mental. Os primeiros socorros em saúde mental são a primeira e imediata assistência prestada a qualquer pessoa que esteja passando ou desenvolvendo uma condição de saúde mental, como depressão ou transtornos de ansiedade, ou passando por uma situação de crise de saúde mental, como ideação suicida ou ataque de pânico. Primeiros socorros em saú...

American baseball player Baseball player Steel Arm Johnny TaylorPitcher / ManagerBorn: (1879-08-12)August 12, 1879Anderson, South CarolinaDied: March 25, 1956(1956-03-25) (aged 76)Peoria, IllinoisBatted: RightThrew: Right Teams Greenwood, South Carolina Red Stockings (1898) Greenville, South Carolina (1898) Anderson, South Carolina (1899–1900) Birmingham Giants (1903–1909) St. Paul Colored Gophers (1909) Chicago Giants (1910)[1] West Baden Sprudels (1910) St. Louis Giants (19...

Play written by Leo Butler RedundantWritten byLeo ButlerDate premiered2001 Royal Court in LondonOriginal languageEnglish Redundant by Leo Butler premiered at the Royal Court Theatre in 2001 starring Lyndsey Marshal and directed by Dominic Cooke. Set in seventeen-year-old Lucy's Sheffield council flat, the play follows a year in the promiscuous teenager's life as she makes one disastrous choice after another. It is a dark, often humorous, examination of social poverty. In the introduction in h...

Hubungan Israel–Panama Israel Panama Reuven Rivlin dan Juan Carlos Varela, Mei 2018, Israel. Elio V. Ortiz datang ke Beit HaNassi untuk menghadiri pelantikan Zalman Shazar, 1967. Hubungan Israel–Panama adalah hubungan bilateral antara Negara Israel dan Republik Panama. Dua negar tersebut memiliki hubungan yang dekat dan bersahabat. Panama adalah satu-satunya negara di Amerika Tengah yang tak mengakui Negara Palestina dan tak memiliki hubungan dengan PLO. Panama memiliki kedubes di Tel Avi...

School of modern yoga Iyengar YogaUtthita Trikonasana, with a Yoga brick to assist correct alignmentFounderB. K. S. IyengarEstablished1970sDerivative formsAnusara Yoga, Forrest YogaPractice emphasesAttention to detail and precise focus on body alignment often with the use of propsRelated schoolsAshtanga Vinyasa Yoga Iyengar Yoga, named after and developed by B. K. S. Iyengar, and described in his bestselling[1] 1966 book Light on Yoga, is a form of yoga as exercise that has an emphasi...

Albanian mufti, theologian and publicist Grand MuftiVehbi DibraPersonalBorn(1867-03-12)12 March 1867Dibra, Ottoman Empire (modern-day North Macedonia)Died24 March 1937(1937-03-24) (aged 70)Tirana, AlbaniaReligionIslamNationalityAlbanianChildrenAhmet, Hatixhe, Muhamet, Mereme, Asije and Edip AgolliParentAhmet (Effendi) AgolliDenominationSunniSignatureMuslim leaderPeriod in office1923–1929SuccessorBehexhet ShapatiPostHead of the Muslim Community of Albania Vehbi Dibra Abdyl Aziz Veh...

2017 Indian filmValla DesamDirected byN. T. NanthaWritten byN. T. NanthaProduced byK. RaveendranEmmanuelStarringAnu HasanNassarDavid YuvarajanCinematographyN. T. NanthaEdited byDeepak S. DwaraknathMusic byL. V. MuthukumarasamyR. K. SundarProductioncompanyLakxshanna PicturesRelease date 22 September 2017 (2017-09-22) CountryIndiaLanguageTamil Valla Desam (transl. Highly Developed country) is a 2017 Indian Tamil-language action film written and directed by N. T. Nantha. The...

Superhero in the DC Comics Universe For the comic book, see Animal Man (comic book). Comics character Animal ManAnimal Man as depicted in 52 #20 (November 2006) by J. G. Jones.Publication informationPublisherDC ComicsFirst appearanceStrange Adventures #180 (September 1965)Created byDave WoodCarmine InfantinoIn-story informationAlter egoBernhard Buddy BakerSpeciesMetahumanTeam affiliationsJustice League EuropeForgotten HeroesWhite Lantern CorpsJustice League UnitedJustice LeagueJustice Le...

For other uses, see Northern Star (disambiguation). The Northern Star was the newspaper of the Society of United Irishmen, which was published from 1792 until its suppression in May 1797 by a group of Monaghan militiamen. Origin The publication of an Irish newspaper that reflected and disseminated liberal views was an early goal of Irish republicans in the late 18th century. By the founding of the Society of United Irishmen in October 1791, the project was well underway and the first edition ...

For the town and archaeological site in Costa Rica, see Rivas District. Municipality and City in Rivas Department, NicaraguaRivasMunicipality and CityStreet in Rivas, Nicaragua.RivasLocation in NicaraguaCoordinates: 11°26′21.51″N 85°49′37.19″W / 11.4393083°N 85.8269972°W / 11.4393083; -85.8269972Country NicaraguaDepartmentRivas DepartmentArea • Municipality and City281 km2 (108 sq mi)Population (2022 estimate)[1]...

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Scottish Asians – news · newspapers · books · scholar · JSTOR (July 2007) (Learn how and when to remove this template message) Scottish Asian (Asian-Scottish or Asian-Scots) is a term defined within the 2011 Scottish census as including people of Bangladeshi, C...

Children's animated television series Sunny DayCreated byAbie LongstaffBased onThe Fairytale Hairdresser books by Abbie LongstaffDeveloped byPaula RosenthalWritten byJodi Reynolds (head writer)Brian Hohlfeld (head writer; season 1)Alan Denton (head writer; season 2)Directed byShawn SelesDave Barton ThomasJoey SoVoices ofLilla CrawfordRob MorrisonÉlan Luz RiveraTaylor LoudermanKevin DudaMelissa van der SchyffEleanor SnowdonTheme music composerJoleen BelleJoaquim SvarreMichelle BuzzComposersGe...

Artikel ini tidak memiliki referensi atau sumber tepercaya sehingga isinya tidak bisa dipastikan. Tolong bantu perbaiki artikel ini dengan menambahkan referensi yang layak. Tulisan tanpa sumber dapat dipertanyakan dan dihapus sewaktu-waktu.Cari sumber: Dowan, Gunem, Rembang – berita · surat kabar · buku · cendekiawan · JSTOR artikel ini perlu dirapikan agar memenuhi standar Wikipedia. Tidak ada alasan yang diberikan. Silakan kembangkan artikel ini sema...

Australian drag performer Coco JumboCoco Jumbo at RuPaul's DragCon LA, 2023BornLuke VitoNationalityAustralianTelevisionRuPaul's Drag Race Down Under (season 1) Coco Jumbo is the stage name of Luke Vito,[1] a Fijan-Australian[2] drag performer who competed on season 1 of RuPaul's Drag Race Down Under. Career Coco Jumbo was named DIVA Entertainer of the Year 2017.[3] She competed on season 1 of RuPaul's Drag Race Down Under.[4] She impersonated Lizzo for the Snat...

Sri Duto DhanisworoKomandan SekkauPetahanaMulai menjabat 17 November 2023PendahuluAli GusmanKomandan Pangkalan Udara SuryadarmaMasa jabatan16 Januari 2023 – 17 November 2023PendahuluTarjoniPenggantiSapuan Informasi pribadiLahirSurabaya, Jawa TimurAlma materAkademi Angkatan Udara (1992)Karier militerPihak IndonesiaDinas/cabang TNI Angkatan UdaraMasa dinas1992—sekarangPangkat Marsekal Pertama TNISatuanKorps Penerbang (Helikopter)Sunting kotak info • L • ...

Pioneering semiconductor developer founded by William Shockley Shockley Semiconductor LaboratoryTypePublicIndustrySemiconductorsFounded1955 (1955)FoundersWilliam ShockleyDefunct1968FateAcquired by CleviteHeadquarters391 San Antonio Road, Mountain View, California, United StatesArea servedWorldwideProductsFour-layer diodeNumber of employees9,000ParentBeckman Instruments (1955-1960)[1] Clevite (1960-1968) ITT (1968) The original Shockley building at 391 San Antonio Road, Mountain V...

Kembali kehalaman sebelumnya