home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 43.12 Typesetting Overview Chapter 43
Printing
Next: 43.14 nroff/troff and Macro Packages
 

43.13 The Text Formatters nroff, troff, ditroff, ...

Have you used a WYSIWYG (What You See Is What You Get) desktop publishing program like FrameMaker, WordPerfect, Interleaf, and so on? Then you might not have much experience with the original UNIX formatters, nroff and troff .

Instead of showing a picture of the completed document on your screen as you type, these formatters read a source file full of text and special formatting commands. The formatted output goes into a file (text, PostScript, or some other format) or straight to a printer. You create and edit the source file with any text editor (like vi ). O'Reilly & Associates still uses troff to produce many of its books. For example, the start of the source file for this article looks like:

.Ah 2520 "The Text Formatters nroff, troff, ditroff, ..."
Have you used a WYSIWYG (What You See Is What You Get) desktop
publishing program  like FrameMaker, WordPerfect, Interleaf and so on?
Then you might not have much experience with the original UNIX
formatters, \fInroff\fP and \fItroff\fP.
.LP
Instead of showing a picture of the completed document on your
screen as you type, these formatters read a \fIsource file\fP full
...

You might wonder, "Why use these dinosaurs?"

  • All UNIX systems have them or can get them, so they're portable.

  • The source files are usually much smaller than WYSIWYG formatters' files.

  • The source files are plain text with no non-printable characters; they're easy to copy from one system to another. For instance, I work on books on my DOS laptop, then transfer the files to UNIX for formatting.

  • The formatting language that's used has a powerful set of features that gives professional typesetters (like O'Reilly & Associates) excellent control over the way the output page looks.

  • You can use UNIX utilities-grep , awk , shell scripts, and many others - to process the text. This adds even more power to the formatting setup. For example, that 2520 following the .Ah in the example above is the filename. Each article in this book has an arbitrary four digit filename; this is mapped into the section number printed in the margin and in all the cross references throughout the book using a system of scripts I wrote. I also built a crude outline processor so that we could control the organization of the book by changing a single file. All this was possible only because troff wasn't forced to work alone - we could apply the full power of the UNIX environment.

Batch formatters like nroff and troff aren't the answer for all formatting jobs, but they're worth looking into - especially for small or very complex jobs.

- JP


Previous: 43.12 Typesetting Overview UNIX Power Tools Next: 43.14 nroff/troff and Macro Packages
43.12 Typesetting Overview Book Index 43.14 nroff/troff and Macro Packages

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System