Beruflich Dokumente
Kultur Dokumente
ABSTRACT
TROFF is a language for typesetting text, available since the
early 1970s in many similarly-named variants and implementations. Today it is mostly known as the language in which
Unix manual pages are written.
March, 2003
-2-
Requests
appear on lines of their own, with a . followed by one or two characters and (sometimes) arguments.
Escape sequences
appear in the text, and are introduced by a \.
Builtin TROFF commands such as .sp, and macros (user-defined or from a
macro package) such as .PP are accessed as requests. Escape sequences
are used to access builtin TROFF commands, special characters, string variables and register variables.
Macro packages provide higher-level commands and a common style:
cover pages, headings, paragraphs, page numbering, footnotes . . . The
most common ones are man for Unix man pages and ms for short technical reports, articles and papers.
-3-
Some things that can be expressed in TROFF but are too cumbersome to
type in are implemented as preprocessors for little languages. For
example, a table is implemented in the tbl language, bracketed in the
TROFF source by the .TS and .TE macros. The user is then responsible for
filtering the source through tbl(1) before typesetting it. tbl replaces the tbl
parts with TROFF source implementing the actual table, and the macro
package provides suitable definitions of the bracketing macros, possibly to
center the table or marking it as a float.
5. Sources of information
TROFF documentation is, unfortunately, scattered and patchy. A user is
practically helpless if all she has is the documentation that came with the
systemeven in the case of groff, which comes with a texinfo manual.
This is an attempt to trace the major sources still widely and freely
available.
5.1. UNIX Text Processing
The 1987 book UNIX Text Processing by Dougherty and OReilly is available for free download these days, and may be the best TROFF documentation available. The re-troffed versions from the UTP Revival Project are
probably the most manageable; see http://www.troff.org for details and
pointers.
-4-
-5-
-6-
description groff elements control characters numerical expressions conditions requests request short reference escape
sequences single character escapes special characters registers
(read-only, writable) warnings compatibility . . .
troff(1) format documents
Contains a long chapter describing groff extensions to the language.
groff_char(7) groff character names
Enumerates all characters known to groff, without mentioning which
ones are classic. References the 1989 report An extension to the troff
character set for Europe.
grops(1) PostScript driver for groff
Documents, among other things, which TROFF fonts are available when
groff is typesetting to PostScript. (The font lists for different output
devices are, by the way, very obvious in a groff installationlook in a
directory named /usr/share/groff/1.17.2/font/devps or similarly.)
Kernighan: A Typesetter-independent TROFF (CSTR 97)
Describes changes made to AT&T TROFF in 1979, including language
changes and additions having to do with fonts, graphics et cetera.
(These changes should be reflected in the users manual, since it was
revised later than this paper.)
6.3. Macro packages
Lesk: Typing Documents on the UNIX System: Using the ms macros
with Troff and Nroff
A fairly brief but seemingly complete ms tutorial and reference,
revised in 1978. The ms macros are, aside from the man macros, the
most widely used ones.
introduction text beginning cover sheets and first pages page
headings multi-column formats headings indented paragraphs
emphasis footnotes displays and tables boxing words or
lines keeping blocks together nroff/troff commands date signature line registers accents use references and further study
list of commands number registers used by ms string registers
used by ms order of commands in input
Tuthill: A Revised Version of ms
Describes fixes and additions that went into the BSD version of ms
(and apparently into the groff version): automatically numbered footnotes, exdented paragraphs, better support for references, table of
contents support, even and odd page footers. Available as USD:21.
Allman: Writing Papers with NROFF using me
A longish paper on how to use the me macros, also good for TROFF in
general. Available as USD:22.
basics of text processing paragraphs headers and footers double spacing page layout underlining major quotes lists
keeps fancier displays footnotes delayed text indexes more
paragraphs section headings parts of the basic paper equations
and tables two column output defining macros annotations
inside keeps fonts point sizes quotes acknowledgments
Allman: me Reference Manual
Available as USD:23.
Mashey & Smith: PWB/MM . . .
Supposedly documents the mm macros. Not rediscovered.
-7-
-8-
TROFF forces you to use escapes for many national characters, such as
and , making input text in most western-european languages unreadable. Most TROFF implementations silently strip non-ASCII input characters. You could, perhaps, use groff, which accepts the full ISO8859-1.
There are probably a lot of other things you can do. For example, .so can
be used for include statements.
9. Style and typography
No typesetting system can produce excellent printed output without
human intervention. Microsoft Word documents need an expert writer to
look anything like adequate. LaTeX does some of the job, but needs much
help from the writer. And TROFF, I think its fair to say, needs more help
than LaTeX.
Whats good printed style varies somewhat with language and culture.
Theres usually a national organization which codifies and publishes the
rules. Here, Ive used Svenska skrivregler and my understanding of whats
the US norm.
9.1. Line length
The default text width in TROFF is too wide to be readable (60 characters a
line is a good rule), and macro packages dont seem to change this. There
are various solutions to this:
enter two-column mode (but you need a text that is easily rebroken and
you need good hyphenation)
adjust the line length (using the ms macros, you can put something
like .nr LL 60n near the start of the document)
switch to a different font that is wider than the default Times (but these
fonts tend to be harder to read onscreen)
increase the point size and line spacing
9.2. Paragraphs
Paragraphs are usually not separated by vertical space. If they follow
another paragraph, the first line is indented a few millimeters.
You should use your macro packages paragraph macros. Most of them
seem to use vertical spacing by default. The ms macros are pretty OK;
they have little vertical spacing and separate macros (.LP and .PP) for
unindented and indented paragraphs. The default indent is too large;
change it with .nr PI 2n.
-9-
\(**
.LP
9.3. Ligatures
Well typeset text may, depending on the font, use special glyphs for some
combinations of the letter f and other letters. Compare, for example,
fish and fish.
groff uses these by default (although it can be turned off), and makes
them available as escapes too (\(fi etc). I dont know about the other
TROFF implementations.
9.4. Hyphenation and line breaking
Groff hyphenates by default, using American English rules. Apparently it
can be made to use othersalthough the distribution comes with just
English and the way to add others is undocumented. Its unclear to me
whether all modern TROFFs hyphenate; at least the Solaris version does.
To introduce soft hyphens in problematic words, use \%.
To prevent line breaking on space where its unsuitable (e.g. between
initials in a persons name), escape the space with a \. Other escapes are
available for other spacings. Your style guide is likely to give elaborate
advice on where different spacings should be used, and where line breaking is inappropriate.
9.5. Dashes
A style guide will have detailed advice on various dashes: in which situations they are used and how/if they should be surrounded by spacing.
Tastes seem to vary a lot here. I frequently use the long dash without
spacinglike thisand while that looks appealing to me, others might
find it arcane. (Its up to the reader to blame my fascination by Fitzgerald,
Lovecraft, Salinger and older science fictionor the awfully typeset Word
documents I encounter daily at work.)
At least four different dashes are available in TROFF. They appear in the
input as , \, \(en and \(em.
9.6. Quotation marks
The proper way of quoting differs between cultures. The standard way of
quoting in English is like this, while in Swedish it is like this.
As in TeX, these appears in the source as two characters each: the
ASCII backtick and single quote, respectively.
Other cultures have other quotation marks. The guillemots are used in
Spain, and in older Swedish texts, like this or like this. Its unclear to
me if these are possible to typeset in classic TROFF. In groff, they can be
entered directly (since they are part of ISO8859-1) or using the escapes
\(Fo and \(Fc.
9.7. Ellipsis
My style guide says that ellipsis should be written without any extra spacing ... like this. On the other hand, LaTeX (or is it TeX?) provides the
\ldots macro for properly spaced ellipsis, and at least older US literature
uses something . . . like this, which can be accomplished with a couple of
non-breaking spaces: .\<sp>.\<sp>..
-10-