home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
-
- III. DOCUMENT PREPARATION
-
- systems are used extensively for document preparation.
- There are two major formatting programs, that is, programs
- that produce a text with justified right margins, automatic
- page numbering and titling, automatic hyphenation, and the
- like. nroff-is designed to produce output on terminals and
- line-printers. troff- (pronounced ``tee-roff'') instead
- drives a phototypesetter, which produces very high quality
- output on photographic paper. This paper was formatted with
- troff.
-
- Formatting Packages
-
- The basic idea of nroff-and troff-is that the text to
- be formatted contains within it ``formatting commands'' that
- indicate in detail how the formatted text is to look. For
- example, there might be commands that specify how long lines
- are, whether to use single or double spacing, and what run-
- ning titles to use on each page.
-
- Because nroff-and troff-are relatively hard to learn to
- use effectively, several ``packages'' of canned formatting
- requests are available to let you specify paragraphs, run-
- ning titles, footnotes, multi-column output, and so on, with
- little effort and without having to learn nroff- and troff.
- These packages take a modest effort to learn, but the
- rewards for using them are so great that it is time well
- spent.
-
- In this section, we will provide a hasty look at the
- ``manuscript'' package known as -ms. Formatting requests
- typically consist of a period and two upper-case letters,
- such as .TL, which is used to introduce a title, or .PP- to
- begin a new paragraph.
-
- A document is typed so it looks something like this:
- .TL title of document .AU author name .SH section heading
- .PP paragraph ... .PP another paragraph ... .SH another
- section heading .PP etc. The lines that begin with a period
- are the formatting requests. For example, .PP-calls for
- starting a new paragraph. The precise meaning of .PP-
- depends on what output device is being used (typesetter or
- terminal, for instance), and on what publication the docu-
- ment will appear in. For example, -ms-normally assumes that
- a paragraph is preceded by a space (one line in nroff, 1/2
- line in troff), and the first word is indented. These rules
- can be changed if you like, but they are changed by changing
- the interpretation of .PP, not by re-typing the document.
-
- To actually produce a document in standard format using
- -ms, use the command troff -ms files ... for the typeset-
- ter, and nroff -ms files ... for a terminal. The -ms-argu-
- ment tells troff-and nroff-to use the manuscript package of
-
-
-
-
-
-
-
-
-
- -2-
-
-
- formatting requests.
-
- There are several similar packages; check with a local
- expert to determine which ones are in common use on your
- machine.
-
- Supporting Tools
-
- In addition to the basic formatters, there is a host of
- supporting programs that help with document preparation.
- The list in the next few paragraphs is far from complete, so
- browse through the manual and check with people around you
- for other possibilities.
-
- eqn- and neqn- let you integrate mathematics into the
- text of a document, in an easy-to-learn language that
- closely resembles the way you would speak it aloud. For
- example, the eqn-input sum from i=0 to n x sub i ~=~ pi over
- 2 produces the output
-
- sum from i=0 to n x sub i ~=~ pi over 2
-
-
- The program tbl- provides an analogous service for
- preparing tabular material; it does all the computations
- necessary to align complicated columns with elements of
- varying widths.
-
- refer-prepares bibliographic citations from a data
- base, in whatever style is defined by the formatting pack-
- age. It looks after all the details of numbering references
- in sequence, filling in page and volume numbers, getting the
- author's initials and the journal name right, and so on.
-
- spell-and typo-detect possible spelling mistakes in a
- document.- spell-works by comparing the words in your docu-
- ment to a dictionary, printing those that are not in the
- dictionary. It knows enough about English spelling to
- detect plurals and the like, so it does a very good job.
- typo- looks for words which are ``unusual'', and prints
- those. Spelling mistakes tend to be more unusual, and thus
- show up early when the most unusual words are printed first.
-
- grep-looks through a set of files for lines that con-
- tain a particular text pattern (rather like the editor's
- context search does, but on a bunch of files). For example,
- grep 'ing$' chap* will find all lines that end with the let-
- ters ing-in the files chap*. (It is almost always a good
- practice to put single quotes around the pattern you're
- searching for, in case it contains characters like *- or $-
- that have a special meaning to the shell.) grep-is often
- useful for finding out in which of a set of files the
- -----------
- - "typo" is not provided with Berkeley Unix.
-
-
-
-
-
-
-
-
-
- -3-
-
-
- misspelled words detected by spell-are actually located.
-
- diff- prints a list of the differences between two
- files, so you can compare two versions of something automat-
- ically (which certainly beats proofreading by hand).
-
- wc- counts the words, lines and characters in a set of
- files. tr-translates characters into other characters; for
- example it will convert upper to lower case and vice versa.
- This translates upper into lower: tr A-Z a-z <input >output
-
- sort-sorts files in a variety of ways; cref- makes
- cross-references; ptx- makes a permuted index (keyword-in-
- context listing). sed-provides many of the editing facili-
- ties of ed, but can apply them to arbitrarily long inputs.
- awk-provides the ability to do both pattern matching and
- numeric computations, and to conveniently process fields
- within lines. These programs are for more advanced users,
- and they are not limited to document preparation. Put them
- on your list of things to learn about.
-
- Most of these programs are either independently docu-
- mented (like eqn-and tbl), or are sufficiently simple that
- the description in the Programmer's Manual is adequate
- explanation.
-
- Hints for Preparing Documents
-
- Most documents go through several versions (always more
- than you expected) before they are finally finished.
- Accordingly, you should do whatever possible to make the job
- of changing them easy.
-
- First, when you do the purely mechanical operations of
- typing, type so that subsequent editing will be easy. Start
- each sentence on a new line. Make lines short, and break
- lines at natural places, such as after commas and semi-
- colons, rather than randomly. Since most people change doc-
- uments by rewriting phrases and adding, deleting and rear-
- ranging sentences, these precautions simplify any editing
- you have to do later.
-
- Keep the individual files of a document down to modest
- size, perhaps ten to fifteen thousand characters. Larger
- files edit more slowly, and of course if you make a dumb
- mistake it's better to have clobbered a small file than a
- big one. Split into files at natural boundaries in the doc-
- ument, for the same reasons that you start each sentence on
- a new line.
-
- The second aspect of making change easy is to not com-
- mit yourself to formatting details too early. One of the
- advantages of formatting packages like -ms-is that they per-
- mit you to delay decisions to the last possible moment.
-
-
-
-
-
-
-
-
-
- -4-
-
-
- Indeed, until a document is printed, it is not even decided
- whether it will be typeset or put on a line printer.
-
- As a rule of thumb, for all but the most trivial jobs,
- you should type a document in terms of a set of requests
- like .PP, and then define them appropriately, either by
- using one of the canned packages (the better way) or by
- defining your own nroff-and troff-commands. As long as you
- have entered the text in some systematic way, it can always
- be cleaned up and re-formatted by a judicious combination of
- editing commands and request definitions.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-