
nroff and troff
The vi editor lets you edit text, but it is not much good at formatting. A text file such as program source code might be formatted with a simple program like pr, which inserts a header at the top of every page and handles pagination, but otherwise prints the document exactly as it appears in the file. But for any application requiring the preparation of neatly formatted text, you will use the nroff (“en-roff”) or troff (“tee-roff”) formatting program.
These programs are used to process an input text file, usually coded or “marked up” with formatting instructions. When you use a wysiwyg program like most word processors, you use commands to lay out the text on the screen as it will be laid out on the page. With a markup language like that used by nroff and troff, you enter commands into the text that tell the formatting program what to do.
Our purpose in this chapter is twofold. We want to introduce the basic formatting codes that you will find useful. But at the same time, we want to present them in the context of what the formatter is doing and how it works. If you find this chapter rough-going—especially if this is your first exposure to nroff/troff—skip ahead to either Chapter 5 or Chapter 6 and become familiar with one of the macro packages, ms or mm; then come back and resume this chapter. We assume that you are reading this book because you would like more ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access