[Next Chapter] [Top page] [Previous Chapter]

CHAPTER 13 - TEXT FORMATTING


There are text formatting facilities available with all Unix implementations. They will not be investigated in any detail here. Many users will prefer to use a PC-based word processing package for document production. Those that want to format text on Unix will have vastly differing needs, and it would be impossible to go into all of the possibilities here. A flavour of the simpler programs is given here, and users can look elsewhere for more extensive documentation.

pr

This is a filter that will format a text, giving a choice of columns, page width, length etc.. It is not capable of sophisticated formatting for document production.

nroff

The simplest of the proper formatters is nroff. You can format a plain text file with nroff, by simply typing:

% nroff  text_file

Formatting commands can be inserted into text files. Some simple commands:

 .ce			centre text .ll			line length .pl			page length .po			page offset (left margin) .sp			blank line

These commands may be followed by a numerical argument, which will make the command apply to the specified number of lines, e.g. .sp 3 to leave three blank lines. Formatting commands must be placed at the beginning of a line to be recognised as such. Normally they appear as the only text on a line. Commands are normally composed of lower-case characters. Here is an example of a text containing some nroff instructions:

.ce
This is the title
.sp 2
And this is the text, which
will be formatted and justified when I run nroff. You will see
that the line
breaks will change, and the text will look tidier. That is what
formatting is all about.
.sp
That was a blank line.

The following is what the output from this file would look like:

This is the title
And this is the text,  which will be formatted and justified when I run nroff.  You will see that the  line breaks will change, and the text will look tidier.  That is what formatting is all about.
That was a blank line.

nroff macros

Macros are a special type of nroff command, identified by being in upper-case characters. Standard macro libraries can be invoked by using option flags with the nroff command, e.g.:

nroff -ms filename

for the standard macros. Other macro libraries can be invoked by the me, mn and mv options. Here are some standard macros:

 .FS				footnote starts .FE				footnote ends .ND				no date .TL				title .PP				start paragraph

The .PP tag, for example, is the equivalent of the following sequence of ordinary nroff instructions:

 .sp 5
 .ce 1
 .sp 5

It is possible write your macros.

More details on nroff can be found in the manual. [Next Chapter] [Top page] [Previous Chapter]