home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / unix / riscbsd / datafile / usd / 01_begin / u3_txt < prev    next >
Encoding:
Text File  |  1996-10-12  |  8.1 KB  |  265 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7. III. DOCUMENT PREPARATION
  8.  
  9.      systems  are used extensively for document preparation.
  10. There are two major formatting programs, that  is,  programs
  11. that  produce a text with justified right margins, automatic
  12. page numbering and titling, automatic hyphenation,  and  the
  13. like.   nroff-is designed to produce output on terminals and
  14. line-printers.   troff- (pronounced  ``tee-roff'')   instead
  15. drives  a  phototypesetter, which produces very high quality
  16. output on photographic paper.  This paper was formatted with
  17. troff.
  18.  
  19. Formatting Packages
  20.  
  21.      The  basic  idea of nroff-and troff-is that the text to
  22. be formatted contains within it ``formatting commands'' that
  23. indicate  in  detail how the formatted text is to look.  For
  24. example, there might be commands that specify how long lines
  25. are,  whether to use single or double spacing, and what run-
  26. ning titles to use on each page.
  27.  
  28.      Because nroff-and troff-are relatively hard to learn to
  29. use  effectively,  several ``packages'' of canned formatting
  30. requests are available to let you specify  paragraphs,  run-
  31. ning titles, footnotes, multi-column output, and so on, with
  32. little effort and without having to learn nroff- and  troff.
  33. These  packages  take  a  modest  effort  to  learn, but the
  34. rewards for using them are so great that  it  is  time  well
  35. spent.
  36.  
  37.      In  this  section,  we will provide a hasty look at the
  38. ``manuscript'' package known as  -ms.   Formatting  requests
  39. typically  consist  of  a period and two upper-case letters,
  40. such as .TL, which is used to introduce a title, or  .PP- to
  41. begin a new paragraph.
  42.  
  43.      A  document  is  typed so it looks something like this:
  44. .TL title of document .AU author name  .SH  section  heading
  45. .PP  paragraph  ...   .PP another paragraph ...  .SH another
  46. section heading .PP etc.  The lines that begin with a period
  47. are  the  formatting  requests.   For example, .PP-calls for
  48. starting a  new  paragraph.   The  precise  meaning  of  .PP-
  49. depends  on  what output device is being used (typesetter or
  50. terminal, for instance), and on what publication  the  docu-
  51. ment will appear in.  For example, -ms-normally assumes that
  52. a paragraph is preceded by a space (one line in  nroff,  1/2
  53. line in troff), and the first word is indented.  These rules
  54. can be changed if you like, but they are changed by changing
  55. the interpretation of .PP, not by re-typing the document.
  56.  
  57.      To actually produce a document in standard format using
  58. -ms, use the command troff -ms files ...  for  the  typeset-
  59. ter, and nroff -ms files ...  for a terminal.  The -ms-argu-
  60. ment tells troff-and nroff-to use the manuscript package  of
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.                              -2-
  71.  
  72.  
  73. formatting requests.
  74.  
  75.      There  are several similar packages; check with a local
  76. expert to determine which ones are in  common  use  on  your
  77. machine.
  78.  
  79. Supporting Tools
  80.  
  81.      In addition to the basic formatters, there is a host of
  82. supporting programs that  help  with  document  preparation.
  83. The list in the next few paragraphs is far from complete, so
  84. browse through the manual and check with people  around  you
  85. for other possibilities.
  86.  
  87.      eqn- and  neqn- let  you integrate mathematics into the
  88. text of  a  document,  in  an  easy-to-learn  language  that
  89. closely  resembles  the  way  you would speak it aloud.  For
  90. example, the eqn-input sum from i=0 to n x sub i ~=~ pi over
  91. 2 produces the output
  92.  
  93.            sum from i=0 to n x sub i ~=~ pi over 2
  94.  
  95.  
  96.      The  program  tbl- provides  an  analogous  service for
  97. preparing tabular material; it  does  all  the  computations
  98. necessary  to  align  complicated  columns  with elements of
  99. varying widths.
  100.  
  101.      refer-prepares  bibliographic  citations  from  a  data
  102. base,  in  whatever style is defined by the formatting pack-
  103. age.  It looks after all the details of numbering references
  104. in sequence, filling in page and volume numbers, getting the
  105. author's initials and the journal name right, and so on.
  106.  
  107.      spell-and typo-detect possible spelling mistakes  in  a
  108. document.-  spell-works by comparing the words in your docu-
  109. ment to a dictionary, printing those that  are  not  in  the
  110. dictionary.   It  knows  enough  about  English  spelling to
  111. detect plurals and the like, so it does  a  very  good  job.
  112. typo- looks  for  words  which  are  ``unusual'', and prints
  113. those.  Spelling mistakes tend to be more unusual, and  thus
  114. show up early when the most unusual words are printed first.
  115.  
  116.      grep-looks through a set of files for lines  that  con-
  117. tain  a  particular  text  pattern (rather like the editor's
  118. context search does, but on a bunch of files).  For example,
  119. grep 'ing$' chap* will find all lines that end with the let-
  120. ters ing-in the files chap*.  (It is almost  always  a  good
  121. practice  to  put  single  quotes  around the pattern you're
  122. searching for, in case it contains characters like  *- or  $-
  123. that  have  a  special meaning to the shell.)  grep-is often
  124. useful for finding out in  which  of  a  set  of  files  the
  125. -----------
  126. - "typo" is not provided with Berkeley Unix.
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.                              -3-
  137.  
  138.  
  139. misspelled words detected by spell-are actually located.
  140.  
  141.      diff- prints  a  list  of  the  differences between two
  142. files, so you can compare two versions of something automat-
  143. ically (which certainly beats proofreading by hand).
  144.  
  145.      wc- counts  the words, lines and characters in a set of
  146. files.  tr-translates characters into other characters;  for
  147. example  it will convert upper to lower case and vice versa.
  148. This translates upper into lower: tr A-Z a-z <input >output
  149.  
  150.      sort-sorts files in  a  variety  of  ways;  cref- makes
  151. cross-references;  ptx- makes  a permuted index (keyword-in-
  152. context listing).  sed-provides many of the editing  facili-
  153. ties  of  ed, but can apply them to arbitrarily long inputs.
  154. awk-provides the ability to do  both  pattern  matching  and
  155. numeric  computations,  and  to  conveniently process fields
  156. within lines.  These programs are for more  advanced  users,
  157. and  they are not limited to document preparation.  Put them
  158. on your list of things to learn about.
  159.  
  160.      Most of these programs are either  independently  docu-
  161. mented  (like  eqn-and tbl), or are sufficiently simple that
  162. the description  in  the  Programmer's  Manual  is  adequate
  163. explanation.
  164.  
  165. Hints for Preparing Documents
  166.  
  167.      Most documents go through several versions (always more
  168. than  you  expected)  before  they  are  finally   finished.
  169. Accordingly, you should do whatever possible to make the job
  170. of changing them easy.
  171.  
  172.      First, when you do the purely mechanical operations  of
  173. typing, type so that subsequent editing will be easy.  Start
  174. each sentence on a new line.  Make lines  short,  and  break
  175. lines  at  natural  places,  such  as after commas and semi-
  176. colons, rather than randomly.  Since most people change doc-
  177. uments  by  rewriting phrases and adding, deleting and rear-
  178. ranging sentences, these precautions  simplify  any  editing
  179. you have to do later.
  180.  
  181.      Keep  the individual files of a document down to modest
  182. size, perhaps ten to fifteen  thousand  characters.   Larger
  183. files  edit  more  slowly,  and of course if you make a dumb
  184. mistake it's better to have clobbered a small  file  than  a
  185. big one.  Split into files at natural boundaries in the doc-
  186. ument, for the same reasons that you start each sentence  on
  187. a new line.
  188.  
  189.      The  second aspect of making change easy is to not com-
  190. mit yourself to formatting details too early.   One  of  the
  191. advantages of formatting packages like -ms-is that they per-
  192. mit you to delay decisions  to  the  last  possible  moment.
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.                              -4-
  203.  
  204.  
  205. Indeed,  until a document is printed, it is not even decided
  206. whether it will be typeset or put on a line printer.
  207.  
  208.      As a rule of thumb, for all but the most trivial  jobs,
  209. you  should  type  a  document in terms of a set of requests
  210. like .PP, and then  define  them  appropriately,  either  by
  211. using  one  of  the  canned  packages (the better way) or by
  212. defining your own nroff-and troff-commands.  As long as  you
  213. have  entered the text in some systematic way, it can always
  214. be cleaned up and re-formatted by a judicious combination of
  215. editing commands and request definitions.
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.