home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume26 / wroff / part01 / doc / wroff.tut.w < prev   
Encoding:
Text File  |  1991-12-11  |  15.7 KB  |  657 lines

  1. .fo \f0Bill Walker/page #/October 18, 1989\fP
  2. .ce 10
  3. \fBWroff Tutorial\fP
  4. .ce 0
  5. .sp 3
  6. .in +5
  7. .de PP
  8. .sp
  9. .ti +5
  10. .en
  11. .de OP
  12. .sp
  13. .ti -5
  14. .en
  15. .OP
  16. \fBIntroduction:\fP  
  17. .ls 2
  18. .PP
  19. "Wroff" is a general purpose text formatter,
  20. written in the spirit of Unix's \f2trademark of AT&T\fP 
  21. \f1*roff\fP family.  The purpose
  22. of this document is to make the reader able to use "wroff"
  23. for preparing documents.
  24. .PP
  25. Wroff has been specifically "tuned" to the Hewlett-Packard
  26. LaserJet II printer.  Most of the system defaults will
  27. provide some reasonable output no matter \fBwhat\fP input is
  28. presented.  The LaserJet can do \fBboldface\fP, \fUunderlining\fU,
  29. or even a \fB\fUcombination\fU\fP of the two.  Wroff 
  30. supports \fIitalics\fP as well.  Wroff is aware that a page has
  31. 60 lines, and that a page should be printed with a left
  32. margin of 1 inch.  (These can both be changed, of course.)
  33. .PP
  34. Wroff, when processing text, will space twice after periods,
  35. question marks, exclamation marks, and colons.
  36. .PP
  37. This document was prepared using\f1 wroff\fP.
  38. .ls 1
  39. .bp 
  40. .OP
  41. \fBEmbedded Commands:\fP  
  42. .PP
  43. Wroff works by reading a text file,
  44. (created by using "vi" under Unix) and rearranging the
  45. contents of the file according to instructions which you
  46. give by "embedding" certain commands in the file.
  47. .PP
  48. An example of an embedded command would be this:
  49. .cc #
  50.  
  51. #nf
  52. #in +5
  53. .ce 3
  54. These three lines should
  55. be centered on
  56. the page.
  57.  
  58. #cc .
  59.  
  60. .in -5
  61. .fi
  62.  
  63. The resulting output of wroff would be:
  64.  
  65. .ce 3
  66. These three lines should
  67. be centered on
  68. the page.
  69.  
  70. .PP
  71. The three lines are centered as a result of the ".ce 3"
  72. command being embedded in the text.  ".ce 3" means "center
  73. the next three lines."  
  74. .PP
  75. This is an example of an embedded command.  There are about
  76. forty such commands, most of which are not needed for
  77. ordinary work.  An average document will require only two or
  78. three of the commands.  The rest are present just to do
  79. "fancy stuff".
  80. .PP
  81. An embedded command is usually the only command on a line, and it
  82. usually starts with a period (".").  For this reason,
  83. embedded commands are often called "dot commands".  
  84. It is unusual to want to actually begin
  85. a line with a period, so this works OK.  If you have some reason for
  86. wanting to place a period at the first of a line (we did 
  87. above in the example
  88. for ".ce"), there is a way to do it.  
  89.  
  90. .OP
  91. \fBModes:\fP  
  92. .PP
  93. We need to explain the difference in "fill mode",
  94. and "non-fill" mode.  
  95. .PP
  96. In "fill mode", wroff will pack as many words as possible on
  97. a line, no matter how you typed the lines in the original
  98. file.  If you are in "non-fill" mode, the lines will appear
  99. in the output just the way you typed them in.  Fill mode is
  100. usually "on", but you can turn it off with the command
  101. ".nf".  If you want it back on, just use ".fi".  Here is an
  102. example:
  103.  
  104. .cc #
  105. #nf 
  106. .nf
  107. These lines will appear 
  108. in non-fill mode, just the
  109. way they were typed in.
  110. This is useful for making tables and
  111. other things that need to line up
  112. in a certain way.
  113.  
  114. Here is the output that results:
  115.  
  116.  
  117.     These lines will appear
  118.     in non-fill mode, just the
  119.     way they were typed in.
  120.     This is useful for making tables and
  121.     other things that need to line up
  122.     in a certain way.
  123.  
  124. #fi
  125. Here is the way things would look in fill
  126. mode.  Here is the raw text:
  127.  
  128. #nf
  129. .fi
  130. These lines will appear in
  131. fill mode, with the margins adjusted
  132. properly.  This is the usual default for 
  133. text, and so you can just omit the ".fi" if
  134. you want to.
  135.  
  136. Here is the way they appear after processing by wroff:
  137.  
  138. #fi
  139. #cc .
  140. These lines will appear in
  141. fill mode, with the margins adjusted
  142. properly.  This is the usual default for 
  143. text, and so you can just omit the ".fi" if
  144. you want to.
  145.  
  146. .OP
  147. \fBjustify and non-justify modes:\fP  
  148. .PP
  149. Sometimes we want to place
  150. as many words on a line as possible, but we do not want the
  151. right margins to be justified.  For instance, you may be
  152. writing a business letter, and a ragged right margin gives
  153. sort of a "typed-by-hand" look to a paper.  Use the commands
  154. ".ju" and ".nj" to turn right margin justification on and
  155. off.
  156. .PP
  157. Here is an example.  In the text file, we enter:
  158.  
  159. .nf
  160. .cc #
  161. .fi
  162. .nj
  163. These lines will appear with as
  164. many words on a line as possible, but
  165. with the right margin "ragged."
  166. This makes for a more "typed-by-hand" appearance,
  167. and is useful for correspondence.
  168.  
  169. Here is the output:
  170.  
  171. #nj
  172. #fi
  173. These lines will appear with as
  174. many words on a line as possible, but
  175. with the right margin "ragged."
  176. This makes for a more "typed-by-hand" appearance,
  177. and is useful for correspondence.
  178. #cc .
  179.  
  180. .ju
  181. .fi
  182. .OP
  183. \fBChanging the "command character":\fP  
  184. .PP
  185. Several times in the
  186. above text, we had to print a period (a "dot") as the first
  187. character on a line.  Since an embedded commands usually
  188. starts with a "dot", we had to be sure that the
  189. dot at the first of a line could be ignored if we wanted it
  190. to be.  
  191. .PP
  192. The "dot" is called the "command character", and actually
  193. any character can be used.  If we want some other character
  194. to become the command character instead, we could use the
  195. ".cc" command (for \fBc\fPhange \fBc\fPommand).  Here is how it
  196. works.
  197. .cc *
  198.  
  199. After this, the command character is a "#".  For instance, 
  200.  
  201. *nf
  202. .cc #
  203. I can now type a dot at the first of a line like this:
  204.  
  205. .45 caliber automatic
  206.  
  207. #cc .
  208. Now the command character is changed back to a ".".
  209.  
  210. *fi
  211. *cc .
  212. .PP
  213. We will see another method of accomplishing the same end later.
  214.  
  215. .OP
  216. \fBIndenting:\fP  
  217. .PP
  218. Most text in letters requires indented
  219. printing.  The usual left-hand margin in wroff is set to
  220. 1 inch from the left printable margin on a page.  
  221. However, this
  222. can be changed in three ways.
  223. .PP
  224. The left hand margin can be changed to any other value by
  225. using ".in".  For instance, ".in 20" changes the left margin
  226. to 2 inches from the left printable margin.  
  227. The "20" means that the margin is to be set to 20 deci-inches
  228. (tenths of an inch) from the left printable margin.
  229. Incidentally, the left printable margin, depending on your printer, may not
  230. be at the left edge of the paper.  
  231. .PP
  232. You can also do it slightly differently.
  233. Using ".in +12" would change the left margin to be 1.2 inches
  234. to the right of where it was.  In a like fashion, using ".in
  235. -5" would move the left margin one-half inch to the left.  For
  236. example:
  237.  
  238. .nf
  239. .cc #
  240. .in 10
  241. This would be printed at 1.0 inches from the left of the paper.
  242.  
  243. .in +5
  244. This is placed at inch 1.5.
  245.  
  246. .in 15
  247. This is also placed at inch 1.5.
  248.  
  249. .in -10
  250. This would be printed at inch 0.5 (15 -10).
  251.  
  252. #cc .
  253. .fi
  254. .PP
  255. A variation on setting a margin permanently is just to
  256. change the margin for \fUonly the next line\fU.  Use ".ti +5"
  257. (for \fBt\fPemporary \fBi\fPndent 5 deci-inches) to indent only the next
  258. line (by 0.5 inches).  This is particularly useful at the beginning of
  259. paragraphs.
  260. .PP
  261. As an example,
  262.  
  263. .cc #
  264. #nf
  265. .ti +5
  266. The paragraph printed by processing this text will have an
  267. indented first line.  The remaining lines will not be
  268. indented, but will appear at the left margin.
  269.  
  270. processes into:
  271.  
  272. #fi
  273. #ti +5
  274. The paragraph printed by processing this text will have an
  275. indented first line.  The remaining lines will not be
  276. indented, but will appear at the left margin.
  277.  
  278. #cc .
  279. .PP
  280. An interesting variation is an "outdent", or hanging leader.
  281. Here is an example:
  282.  
  283. .cc #
  284. #nf
  285. .ti -5
  286. This paragraph has an outdent, or hanging leader in its
  287. first line.  This really helps when preparing a report or
  288. other written work with section headings.
  289. #fi
  290.  
  291. The output will appear as:
  292.  
  293. #ti -5
  294. This paragraph has an outdent, or hanging leader in its
  295. first line.  This really helps when preparing a report or
  296. other written work with section headings.
  297.  
  298. #cc .
  299. .OP
  300. \fBBoldfacing\fP, centering, and \fUunderlining\fU:
  301. .PP
  302. Centering text is easy.  Just use ".ce" as in the
  303. example at the first of the paper.  One "trick" is to tell
  304. wroff to center a huge number of lines, and then use ".ce 0"
  305. to turn centering off like this:
  306. .nf
  307.  
  308. .cc #
  309. .ce 100
  310. These and
  311. no telling how
  312. many other
  313. lines
  314. ----
  315. ---
  316. should be centered.
  317. .ce 0
  318. #cc .
  319. .fi
  320.  
  321. .PP
  322. This results in all of the lines between ".ce 100" and ".ce
  323. 0" being centered, with no requirement for having to count
  324. lines ahead of time.  
  325. .PP
  326. The same stunt works on boldface or underlining:
  327. .cc #
  328. #nf
  329.  
  330. .ul 100
  331. .bd 100
  332. All of the words
  333. in this block will be both boldfaced and
  334. underlined
  335. --
  336. -- all the way
  337. down to here, whereever 
  338. this is.
  339. .bd 0
  340. .ul 0
  341.  
  342. #cc .
  343. .fi
  344.  
  345. .PP
  346. Boldfacing and underlining can be accomplished in two ways.
  347. One way is to use either ".bd" or ".ul" as above.
  348. .PP
  349. A second way, which is useful when you want to just
  350. underline or boldface a couple of words is to use an
  351. "in-line font change".
  352. .PP
  353. An illustration probably is sufficient. 
  354. .PP
  355. In this paragraph, we \\fBboldfaced three words\\fP, and \\fUunderlined
  356. two\\fU words, and \\fIitalicized three words\\fP, and printed a \\\\.  
  357. Here is how wroff printed it.
  358. .PP
  359. In this paragraph, we \fBboldfaced three words\fP, and \fUunderlined
  360. two\fU words, and \fIitalicized three words\fP, and printed a \\.  
  361. Here is how wroff printed it.
  362. .PP
  363. In-line font changes are discussed in more detail in a later section.
  364. .OP
  365. \fBUse of Macros:\fP
  366. .PP
  367. "Macros" are collections of frequently used commands that
  368. can be called by a single name.  You get to invent the name.
  369. .PP
  370. In typing this document, we frequently had need to 
  371. "skip 3 lines and then temporarily outdent by 5 spaces" when
  372. we came to a new section.  Rather than always type
  373. .cc #
  374.  
  375. #nf
  376. .sp 3
  377. .ti -5
  378.  
  379. #fi
  380. at the start of every section, we instead defined a "macro"
  381. named ".OP" like this:
  382.  
  383. #nf
  384.  
  385. .de OP
  386. .sp 3
  387. .ti -5
  388. .en
  389.  
  390. #nf
  391. At the start of every new section, we just typed:
  392.  
  393. .OP
  394. The start of the section ...
  395. .PP
  396.  
  397. and went on about our business.
  398. #cc .
  399. .fi
  400. .PP
  401. Macros are really powerful.  A well thought out collection
  402. of macros can make writing a letter or preparing a memo a
  403. breeze.  Macros can be defined and placed in a file for
  404. future use.  The file can be included in any document by
  405. using the ".so" command to read the macro file before you
  406. start processing.
  407. .PP
  408. Don't overlook the power of macros.  Here is a set we use a
  409. lot.  They were placed in a file called "macros" by using
  410. "vi".  
  411.  
  412. .in +5
  413. .OP
  414. file macros contains:
  415. .nf
  416. .cc #
  417.  
  418. .de DATE
  419. .in +30
  420. $1 $2 $3
  421. .br
  422. .en
  423. .de TO
  424. .in 10
  425. .sp 3
  426. .nf
  427. .en
  428. .de TEXT
  429. .sp 3
  430. .fi
  431. .ti +5
  432. .en
  433. .de SIGN
  434. .sp 3
  435. .in +30
  436. .nf
  437. .en
  438. #cc .
  439. .in -5
  440.  
  441. .fi
  442. .OP
  443. Now when we want to write a letter, we write
  444. .nf
  445. .in +5
  446. .cc #
  447.  
  448. .DATE October 4, 1988
  449. .TO
  450. Mr. Joe Smith
  451. SomePlace
  452. Somewhere, USA
  453.  
  454. Dear Joe:
  455. .TEXT
  456. Here is the letter and so forth ...
  457. .SIGN
  458. Yours Truly,
  459.  
  460. Fred
  461. #cc .
  462. .fi
  463. .in -5
  464.  
  465. We print the letter by writing "wroff macros filename".
  466. .bp
  467. .OP
  468. \fBScanning for errors:\fP  
  469. .PP
  470. wroff is somewhat sensitive to
  471. errors in input.  It is sometimes useful to scan a document \fIbefore\fP
  472. you print it to see if all of the wroff commands have been entered 
  473. correctly.  Use the command line option "-s" to scan for errors
  474. if you are concerned.
  475. .PP
  476. If you enter "wroff -s filename", then wroff will not print anything
  477. at all, either on the screen, or on the printer.  If there is some kind
  478. of problem with any of the wroff commands in your paper, wroff will report
  479. that problem, and the approximate location of it, so that you can fix it
  480. before you go to the trouble and expense of printing the document.
  481. .OP
  482. \fBFonts:\fP
  483. .PP
  484. One of the biggest pleasures in using wroff is that you can combine various
  485. typefaces in a document to give a pleasing appearance.  
  486. .PP
  487. There are several fonts available.  Here is a current list:
  488. .nf
  489. \fT
  490. symbol                   font 
  491.  
  492. .in +5
  493. B        Times Roman 12 point boldface 
  494. I        Times Roman 12 point italics
  495. M        mountable - default is Presentation 18 bold
  496. T        Courier 12 point
  497. P        return to previous font
  498. U        toggle underlining
  499. 0            Times Roman 12 point Normal (default)    
  500. 1        Presentation 18 point - synonymous with M
  501. 2        Helvetica Normal 6 point
  502. \fP
  503. .fi
  504. .in -5
  505. .PP
  506. In order to make effective use of fonts, you must
  507. understand what is meant by "proportional spacing."
  508. .PP
  509. You may have noticed that in this document, not all letters in 
  510. a word are the same "width".  For instance, the letter "i" is much more
  511. narrow than the letter "M".  These letters were printed with a proportionally
  512. spaced font.  
  513. .PP
  514. Proportional spacing is pleasant to read.  It gives a "typeset" quality
  515. to printed work.  Most (but not all) of 
  516. this document was printed using Times Roman 12 point
  517. Normal type.
  518. .PP
  519. Wroff, in the default mode, allows for proportional printing, and adjusts
  520. the spacing in lines accordingly.
  521. .PP
  522. In the table above, the only proportional fonts are the "Times Roman" fonts.
  523. The other fonts are "fixed spacing fonts", which means that each letter
  524. takes the same amount of space as any other letter.  Fixed spacing fonts
  525. are especially useful for preparing portions of a document that have
  526. lines which need to "line-up" with previous lines.  One such example is
  527. when preparing a table.
  528. .PP
  529. You can switch fonts, even in the middle of a line, by using
  530. an "embedded font change."  To do this, use a "\\f" followed by the symbol
  531. from the table above that indicates which font you want.
  532. .PP
  533. As an example, the line:
  534. .nf
  535. .in +5
  536.  
  537. \\fBboldface this\\fP and \\fIitalicize this\\fP
  538. .in -5
  539. .fi
  540.  
  541. would print as:
  542. .nf
  543.  
  544. \fBboldface this\fP and \fIitalicize this\fP
  545.  
  546. .fi
  547. .OP
  548. \fBBuilding tables and using '.nf':\fP
  549. .PP
  550. The only fixed spacing fonts available above are the Courier 12 point,
  551. and the Presentation 18 point.  (Point size indicates the height of letters,
  552. not their width.)
  553. .PP
  554. Incidentally, you may occasionally want to print the character "\\".
  555. If you want to enter such a character,  you may enter '\\\\' in the document.
  556. This works for other characters, too.  Entering '\\x' will print the
  557. character 'x'.  This seems useless until you realize that it is an alternative
  558. way of protecting a line that begins with a period.  
  559. .PP
  560. Here is an example table:
  561. .nf
  562. .in +5
  563.  
  564. \fT
  565.  
  566. \.nf
  567. \.in +5
  568. \\fT
  569. Name            Address
  570. Joe Smith        Somewhere
  571. James Jones        Nowhere
  572. Sally Sue        Anywhere
  573. \\.50 caliber           Guns
  574. \\fP
  575. \.in -5
  576.  
  577. .in -5
  578. \fP
  579. .PP
  580. This was printed by wroff as:
  581.  
  582.  
  583. .nf
  584. .in +5
  585. \fT
  586. Name            Address
  587. Joe Smith        Somewhere
  588. James Jones        Nowhere
  589. Sally Sue        Anywhere
  590. \.50 caliber         Guns
  591. \fP
  592. .fi
  593. .in -5
  594.  
  595. .PP
  596. Just switching from a proportional font to a fixed font in the same
  597. line, when in fill mode gives no problems at all.  Wroff may become 
  598. confused when you build tables in non-fill mode and mix several fonts
  599. together.  A good word of advice, then, is to build tables in non-fill
  600. mode, using a fixed font, just as we did above.
  601. .PP
  602. If for some reason
  603. you absolutely \fIinsist\fP on using a proportional font to build a table,
  604. you can use an "anchor".  The "anchor" characters cause a specific
  605. place in the text to appear in a certain column.  The anchor consists of the
  606. string "\\f|".
  607. Here is an example:
  608. .nf
  609. .sp
  610. .in +5
  611. \fT
  612. age    \\f|14
  613. date    \\f|12
  614. today    \\f|2
  615. \fP
  616. .in -5
  617. .fi
  618. .PP
  619. This produces the following output:
  620. .sp
  621. .in +5
  622. .nf
  623. age    \f|14
  624. date    \f|12
  625. today    \f|2
  626. .in -5
  627. .fi
  628. .PP
  629. When processing a line in non-fill mode under a proportional font,
  630. wroff will attempt to duplicate the appearance of the original line as
  631. best it can.   Wroff takes the original line and determines by counting
  632. characters just where on a page that it should begin printing a word.  
  633. It assumes that each character is 0.1 inches in width.
  634. .PP
  635. Wroff then attempts to begin each word in the line at whatever place on
  636. the page is indicated by the character position of the first letter in
  637. the word.  This would make for some "funny" looking lines, unless you
  638. placed the anchors in the line.
  639. .OP
  640. \fBConclusions:\fP  
  641. .PP
  642. There is a lot to wroff, and a lot more to
  643. learn.  Most of the commands are reasonable to use, and
  644. actually most people only need a few of the commands.
  645. Studying the User's Guide will repay a careful reader.
  646. .PP
  647. Appendix A attached to this paper is a technical description
  648. of all of wroff's commands.  After you gain skill with
  649. wroff, this appendix will probably become very useful to
  650. you.
  651. .PP
  652. Appendix B is a listing of the raw unprocessed file that
  653. was used to create this tutorial.  It should provide a treasure
  654. trove of examples.
  655. .PP
  656. Enjoy !
  657.