/contrib/groff/doc/groff-2

https://bitbucket.org/freebsd/freebsd-head/ · #! · 4910 lines · 3933 code · 977 blank · 0 comment · 0 complexity · 49d6f50ba96bba8de8a1912d8cbd463c MD5 · raw file

Large files are truncated click here to view the full file

  1. This is groff, produced by makeinfo version 4.8 from ./groff.texinfo.
  2. This manual documents GNU `troff' version 1.19.2.
  3. Copyright (C) 1994-2000, 2001, 2002, 2003, 2004, 2005 Free Software
  4. Foundation, Inc.
  5. Permission is granted to copy, distribute and/or modify this
  6. document under the terms of the GNU Free Documentation License,
  7. Version 1.1 or any later version published by the Free Software
  8. Foundation; with no Invariant Sections, with the Front-Cover texts
  9. being `A GNU Manual," and with the Back-Cover Texts as in (a)
  10. below. A copy of the license is included in the section entitled
  11. `GNU Free Documentation License."
  12. (a) The FSF's Back-Cover Text is: `You have freedom to copy and
  13. modify this GNU Manual, like GNU software. Copies published by
  14. the Free Software Foundation raise funds for GNU development."
  15. INFO-DIR-SECTION Typesetting
  16. START-INFO-DIR-ENTRY
  17. * Groff: (groff). The GNU troff document formatting system.
  18. END-INFO-DIR-ENTRY
  19. 
  20. File: groff, Node: Drawing Requests, Next: Traps, Prev: Page Motions, Up: gtroff Reference
  21. 5.23 Drawing Requests
  22. =====================
  23. `gtroff' provides a number of ways to draw lines and other figures on
  24. the page. Used in combination with the page motion commands (see *Note
  25. Page Motions::, for more info), a wide variety of figures can be drawn.
  26. However, for complex drawings these operations can be quite
  27. cumbersome, and it may be wise to use graphic preprocessors like `gpic'
  28. or `ggrn'. *Note gpic::, and *Note ggrn::, for more information.
  29. All drawing is done via escapes.
  30. -- Escape: \l'l'
  31. -- Escape: \l'lg'
  32. Draw a line horizontally. L is the length of the line to be
  33. drawn. If it is positive, start the line at the current location
  34. and draw to the right; its end point is the new current location.
  35. Negative values are handled differently: The line starts at the
  36. current location and draws to the left, but the current location
  37. doesn't move.
  38. L can also be specified absolutely (i.e. with a leading `|') which
  39. draws back to the beginning of the input line. Default scaling
  40. indicator is `m'.
  41. The optional second parameter G is a glyph to draw the line with.
  42. If this second argument is not specified, `gtroff' uses the
  43. underscore glyph, `\[ru]'.
  44. To separate the two arguments (to prevent `gtroff' from
  45. interpreting a drawing glyph as a scaling indicator if the glyph is
  46. represented by a single character) use `\&'.
  47. Here a small useful example:
  48. .de box
  49. \[br]\\$*\[br]\l'|0\[rn]'\l'|0\[ul]'
  50. ..
  51. Note that this works by outputting a box rule (a vertical line),
  52. then the text given as an argument and then another box rule.
  53. Finally, the line drawing escapes both draw from the current
  54. location to the beginning of the _input_ line - this works because
  55. the line length is negative, not moving the current point.
  56. -- Escape: \L'l'
  57. -- Escape: \L'lg'
  58. Draw vertical lines. Its parameters are similar to the `\l'
  59. escape, except that the default scaling indicator is `v'. The
  60. movement is downwards for positive values, and upwards for
  61. negative values. The default glyph is the box rule glyph,
  62. `\[br]'. As with the vertical motion escapes, text processing
  63. blindly continues where the line ends.
  64. This is a \L'3v'test.
  65. Here the result, produced with `grotty'.
  66. This is a
  67. |
  68. |
  69. |test.
  70. -- Escape: \D'command arg ...'
  71. The `\D' escape provides a variety of drawing functions. Note
  72. that on character devices, only vertical and horizontal lines are
  73. supported within `grotty'; other devices may only support a subset
  74. of the available drawing functions.
  75. The default scaling indicator for all subcommands of `\D' is `m'
  76. for horizontal distances and `v' for vertical ones. Exceptions
  77. are `\D'f ...'' and `\D't ...'' which use `u' as the default, and
  78. `\D'FX ...'' which arguments are treated similar to the `defcolor'
  79. request.
  80. `\D'l DX DY''
  81. Draw a line from the current location to the relative point
  82. specified by (DX,DY), where positive values mean down and
  83. right, respectively. The end point of the line is the new
  84. current location.
  85. The following example is a macro for creating a box around a
  86. text string; for simplicity, the box margin is taken as a
  87. fixed value, 0.2m.
  88. .de BOX
  89. . nr @wd \w'\\$1'
  90. \h'.2m'\
  91. \h'-.2m'\v'(.2m - \\n[rsb]u)'\
  92. \D'l 0 -(\\n[rst]u - \\n[rsb]u + .4m)'\
  93. \D'l (\\n[@wd]u + .4m) 0'\
  94. \D'l 0 (\\n[rst]u - \\n[rsb]u + .4m)'\
  95. \D'l -(\\n[@wd]u + .4m) 0'\
  96. \h'.2m'\v'-(.2m - \\n[rsb]u)'\
  97. \\$1\
  98. \h'.2m'
  99. ..
  100. First, the width of the string is stored in register `@wd'.
  101. Then, four lines are drawn to form a box, properly offset by
  102. the box margin. The registers `rst' and `rsb' are set by the
  103. `\w' escape, containing the largest height and depth of the
  104. whole string.
  105. `\D'c D''
  106. Draw a circle with a diameter of D with the leftmost point at
  107. the current position. After drawing, the current location is
  108. positioned at the rightmost point of the circle.
  109. `\D'C D''
  110. Draw a solid circle with the same parameters and behaviour as
  111. an outlined circle. No outline is drawn.
  112. `\D'e X Y''
  113. Draw an ellipse with a horizontal diameter of X and a vertical
  114. diameter of Y with the leftmost point at the current position.
  115. After drawing, the current location is positioned at the
  116. rightmost point of the ellipse.
  117. `\D'E X Y''
  118. Draw a solid ellipse with the same parameters and behaviour
  119. as an outlined ellipse. No outline is drawn.
  120. `\D'a DX1 DY1 DX2 DY2''
  121. Draw an arc clockwise from the current location through the
  122. two specified relative locations (DX1,DY1) and (DX2,DY2).
  123. The coordinates of the first point are relative to the
  124. current position, and the coordinates of the second point are
  125. relative to the first point. After drawing, the current
  126. position is moved to the final point of the arc.
  127. `\D'~ DX1 DY1 DX2 DY2 ...''
  128. Draw a spline from the current location to the relative point
  129. (DX1,DY1) and then to (DX2,DY2), and so on. The current
  130. position is moved to the terminal point of the drawn curve.
  131. `\D'f N''
  132. Set the shade of gray to be used for filling solid objects
  133. to N; N must be an integer between 0 and 1000, where 0
  134. corresponds solid white and 1000 to solid black, and values
  135. in between correspond to intermediate shades of gray. This
  136. applies only to solid circles, solid ellipses, and solid
  137. polygons. By default, a level of 1000 is used.
  138. Despite of being silly, the current point is moved
  139. horizontally to the right by N.
  140. Don't use this command! It has the serious drawback that it
  141. will be always rounded to the next integer multiple of the
  142. horizontal resolution (the value of the `hor' keyword in the
  143. `DESC' file). Use `\M' (*note Colors::) or `\D'Fg ...''
  144. instead.
  145. `\D'p DX1 DY1 DX2 DY2 ...''
  146. Draw a polygon from the current location to the relative
  147. position (DX1,DY1) and then to (DX2,DY2) and so on. When the
  148. specified data points are exhausted, a line is drawn back to
  149. the starting point. The current position is changed by
  150. adding the sum of all arguments with odd index to the actual
  151. horizontal position and the even ones to the vertical
  152. position.
  153. `\D'P DX1 DY1 DX2 DY2 ...''
  154. Draw a solid polygon with the same parameters and behaviour
  155. as an outlined polygon. No outline is drawn.
  156. Here a better variant of the box macro to fill the box with
  157. some color. Note that the box must be drawn before the text
  158. since colors in `gtroff' are not transparent; the filled
  159. polygon would hide the text completely.
  160. .de BOX
  161. . nr @wd \w'\\$1'
  162. \h'.2m'\
  163. \h'-.2m'\v'(.2m - \\n[rsb]u)'\
  164. \M[lightcyan]\
  165. \D'P 0 -(\\n[rst]u - \\n[rsb]u + .4m) \
  166. (\\n[@wd]u + .4m) 0 \
  167. 0 (\\n[rst]u - \\n[rsb]u + .4m) \
  168. -(\\n[@wd]u + .4m) 0'\
  169. \h'.2m'\v'-(.2m - \\n[rsb]u)'\
  170. \M[]\
  171. \\$1\
  172. \h'.2m'
  173. ..
  174. `\D't N''
  175. Set the current line thickness to N machine units. A value of
  176. zero selects the smallest available line thickness. A
  177. negative value makes the line thickness proportional to the
  178. current point size (this is the default behaviour of AT&T
  179. `troff').
  180. Despite of being silly, the current point is moved
  181. horizontally to the right by N.
  182. `\D'FSCHEME COLOR_COMPONENTS''
  183. Change current fill color. SCHEME is a single letter
  184. denoting the color scheme: `r' (rgb), `c' (cmy), `k' (cmyk),
  185. `g' (gray), or `d' (default color). The color components use
  186. exactly the same syntax as in the `defcolor' request (*note
  187. Colors::); the command `\D'Fd'' doesn't take an argument.
  188. _No_ position changing!
  189. Examples:
  190. \D'Fg .3' \" same gray as \D'f 700' \D'Fr #0000ff' \"
  191. blue
  192. *Note Graphics Commands::.
  193. -- Escape: \b'string'
  194. "Pile" a sequence of glyphs vertically, and center it vertically
  195. on the current line. Use it to build large brackets and braces.
  196. Here an example how to create a large opening brace:
  197. \b'\[lt]\[bv]\[lk]\[bv]\[lb]'
  198. The first glyph is on the top, the last glyph in STRING is at the
  199. bottom. Note that `gtroff' separates the glyphs vertically by 1m,
  200. and the whole object is centered 0.5m above the current baseline;
  201. the largest glyph width is used as the width for the whole object.
  202. This rather unflexible positioning algorithm doesn't work with
  203. `-Tdvi' since the bracket pieces vary in height for this device.
  204. Instead, use the `eqn' preprocessor.
  205. *Note Manipulating Spacing::, how to adjust the vertical spacing
  206. with the `\x' escape.
  207. 
  208. File: groff, Node: Traps, Next: Diversions, Prev: Drawing Requests, Up: gtroff Reference
  209. 5.24 Traps
  210. ==========
  211. "Traps" are locations, which, when reached, call a specified macro.
  212. These traps can occur at a given location on the page, at a given
  213. location in the current diversion, at a blank line, after a certain
  214. number of input lines, or at the end of input.
  215. Setting a trap is also called "planting". It is also said that a
  216. trap is "sprung" if the associated macro is executed.
  217. * Menu:
  218. * Page Location Traps::
  219. * Diversion Traps::
  220. * Input Line Traps::
  221. * Blank Line Traps::
  222. * End-of-input Traps::
  223. 
  224. File: groff, Node: Page Location Traps, Next: Diversion Traps, Prev: Traps, Up: Traps
  225. 5.24.1 Page Location Traps
  226. --------------------------
  227. "Page location traps" perform an action when `gtroff' reaches or passes
  228. a certain vertical location on the page. Page location traps have a
  229. variety of purposes, including:
  230. * setting headers and footers
  231. * setting body text in multiple columns
  232. * setting footnotes
  233. -- Request: .vpt flag
  234. -- Register: \n[.vpt]
  235. Enable vertical position traps if FLAG is non-zero, or disables
  236. them otherwise. Vertical position traps are traps set by the `wh'
  237. or `dt' requests. Traps set by the `it' request are not vertical
  238. position traps. The parameter that controls whether vertical
  239. position traps are enabled is global. Initially vertical position
  240. traps are enabled. The current setting of this is available in the
  241. `.vpt' read-only number register.
  242. Note that a page can't be ejected if `vpt' is set to zero.
  243. -- Request: .wh dist [macro]
  244. Set a page location trap. Non-negative values for DIST set the
  245. trap relative to the top of the page; negative values set the trap
  246. relative to the bottom of the page. Default scaling indicator is
  247. `v'.
  248. MACRO is the name of the macro to execute when the trap is sprung.
  249. If MACRO is missing, remove the first trap (if any) at DIST.
  250. The following is a simple example of how many macro packages set
  251. headers and footers.
  252. .de hd \" Page header
  253. ' sp .5i
  254. . tl 'Title''date'
  255. ' sp .3i
  256. ..
  257. .
  258. .de fo \" Page footer
  259. ' sp 1v
  260. . tl ''%''
  261. ' bp
  262. ..
  263. .
  264. .wh 0 hd \" trap at top of the page
  265. .wh -1i fo \" trap one inch from bottom
  266. A trap at or below the bottom of the page is ignored; it can be
  267. made active by either moving it up or increasing the page length
  268. so that the trap is on the page.
  269. It is possible to have more than one trap at the same location; to
  270. do so, the traps must be defined at different locations, then
  271. moved together with the `ch' request; otherwise the second trap
  272. would replace the first one. Earlier defined traps hide later
  273. defined traps if moved to the same position (the many empty lines
  274. caused by the `bp' request are omitted in the following example):
  275. .de a
  276. . nop a
  277. ..
  278. .de b
  279. . nop b
  280. ..
  281. .de c
  282. . nop c
  283. ..
  284. .
  285. .wh 1i a
  286. .wh 2i b
  287. .wh 3i c
  288. .bp
  289. => a b c
  290. .ch b 1i
  291. .ch c 1i
  292. .bp
  293. => a
  294. .ch a 0.5i
  295. .bp
  296. => a b
  297. -- Register: \n[.t]
  298. A read-only number register holding the distance to the next trap.
  299. If there are no traps between the current position and the bottom
  300. of the page, it contains the distance to the page bottom. In a
  301. diversion, the distance to the page bottom is infinite (the
  302. returned value is the biggest integer which can be represented in
  303. `groff') if there are no diversion traps.
  304. -- Request: .ch macro [dist]
  305. Change the location of a trap. The first argument is the name of
  306. the macro to be invoked at the trap, and the second argument is
  307. the new location for the trap (note that the parameters are
  308. specified in opposite order as in the `wh' request). This is
  309. useful for building up footnotes in a diversion to allow more
  310. space at the bottom of the page for them.
  311. Default scaling indicator for DIST is `v'. If DIST is missing,
  312. the trap is removed.
  313. -- Register: \n[.ne]
  314. The read-only number register `.ne' contains the amount of space
  315. that was needed in the last `ne' request that caused a trap to be
  316. sprung. Useful in conjunction with the `.trunc' register. *Note
  317. Page Control::, for more information.
  318. Since the `.ne' register is only set by traps it doesn't make much
  319. sense to use it outside of trap macros.
  320. -- Register: \n[.trunc]
  321. A read-only register containing the amount of vertical space
  322. truncated by the most recently sprung vertical position trap, or,
  323. if the trap was sprung by an `ne' request, minus the amount of
  324. vertical motion produced by the `ne' request. In other words, at
  325. the point a trap is sprung, it represents the difference of what
  326. the vertical position would have been but for the trap, and what
  327. the vertical position actually is.
  328. Since the `.trunc' register is only set by traps it doesn't make
  329. much sense to use it outside of trap macros.
  330. -- Register: \n[.pe]
  331. A read-only register which is set to 1 while a page is ejected with
  332. the `bp' request (or by the end of input).
  333. Outside of traps this register is always zero. In the following
  334. example, only the second call to `x' is caused by `bp'.
  335. .de x
  336. \&.pe=\\n[.pe]
  337. .br
  338. ..
  339. .wh 1v x
  340. .wh 4v x
  341. A line.
  342. .br
  343. Another line.
  344. .br
  345. => A line.
  346. .pe=0
  347. Another line.
  348. .pe=1
  349. An important fact to consider while designing macros is that
  350. diversions and traps do not interact normally. For example, if a trap
  351. invokes a header macro (while outputting a diversion) which tries to
  352. change the font on the current page, the effect will not be visible
  353. before the diversion has completely been printed (except for input
  354. protected with `\!' or `\?') since the data in the diversion is already
  355. formatted. In most cases, this is not the expected behaviour.
  356. 
  357. File: groff, Node: Diversion Traps, Next: Input Line Traps, Prev: Page Location Traps, Up: Traps
  358. 5.24.2 Diversion Traps
  359. ----------------------
  360. -- Request: .dt [dist macro]
  361. Set a trap _within_ a diversion. DIST is the location of the trap
  362. (identical to the `wh' request; default scaling indicator is `v')
  363. and MACRO is the name of the macro to be invoked. If called
  364. without arguments, the diversion trap is removed.
  365. Note that there exists only a single diversion trap.
  366. The number register `.t' still works within diversions. *Note
  367. Diversions::, for more information.
  368. 
  369. File: groff, Node: Input Line Traps, Next: Blank Line Traps, Prev: Diversion Traps, Up: Traps
  370. 5.24.3 Input Line Traps
  371. -----------------------
  372. -- Request: .it n macro
  373. -- Request: .itc n macro
  374. Set an input line trap. N is the number of lines of input which
  375. may be read before springing the trap, MACRO is the macro to be
  376. invoked. Request lines are not counted as input lines.
  377. For example, one possible use is to have a macro which prints the
  378. next N lines in a bold font.
  379. .de B
  380. . it \\$1 B-end
  381. . ft B
  382. ..
  383. .
  384. .de B-end
  385. . ft R
  386. ..
  387. The `itc' request is identical except that an interrupted text
  388. line (ending with `\c') is not counted as a separate line.
  389. Both requests are associated with the current environment (*note
  390. Environments::); switching to another environment disables the
  391. current input trap, and going back reactivates it, restoring the
  392. number of already processed lines.
  393. 
  394. File: groff, Node: Blank Line Traps, Next: End-of-input Traps, Prev: Input Line Traps, Up: Traps
  395. 5.24.4 Blank Line Traps
  396. -----------------------
  397. -- Request: .blm macro
  398. Set a blank line trap. `gtroff' executes MACRO when it encounters
  399. a blank line in the input file.
  400. 
  401. File: groff, Node: End-of-input Traps, Prev: Blank Line Traps, Up: Traps
  402. 5.24.5 End-of-input Traps
  403. -------------------------
  404. -- Request: .em macro
  405. Set a trap at the end of input. MACRO is executed after the last
  406. line of the input file has been processed.
  407. For example, if the document had to have a section at the bottom
  408. of the last page for someone to approve it, the `em' request could
  409. be used.
  410. .de approval
  411. . ne 5v
  412. . sp |(\\n[.t] - 6v)
  413. . in +4i
  414. . lc _
  415. . br
  416. Approved:\t\a
  417. . sp
  418. Date:\t\t\a
  419. ..
  420. .
  421. .em approval
  422. 
  423. File: groff, Node: Diversions, Next: Environments, Prev: Traps, Up: gtroff Reference
  424. 5.25 Diversions
  425. ===============
  426. In `gtroff' it is possible to "divert" text into a named storage area.
  427. Due to the similarity to defining macros it is sometimes said to be
  428. stored in a macro. This is used for saving text for output at a later
  429. time, which is useful for keeping blocks of text on the same page,
  430. footnotes, tables of contents, and indices.
  431. For orthogonality it is said that `gtroff' is in the "top-level
  432. diversion" if no diversion is active (i.e., the data is diverted to the
  433. output device).
  434. -- Request: .di macro
  435. -- Request: .da macro
  436. Begin a diversion. Like the `de' request, it takes an argument of
  437. a macro name to divert subsequent text into. The `da' macro
  438. appends to an existing diversion.
  439. `di' or `da' without an argument ends the diversion.
  440. -- Request: .box macro
  441. -- Request: .boxa macro
  442. Begin (or appends to) a diversion like the `di' and `da' requests.
  443. The difference is that `box' and `boxa' do not include a
  444. partially-filled line in the diversion.
  445. Compare this:
  446. Before the box.
  447. .box xxx
  448. In the box.
  449. .br
  450. .box
  451. After the box.
  452. .br
  453. => Before the box. After the box.
  454. .xxx
  455. => In the box.
  456. with this:
  457. Before the diversion.
  458. .di yyy
  459. In the diversion.
  460. .br
  461. .di
  462. After the diversion.
  463. .br
  464. => After the diversion.
  465. .yyy
  466. => Before the diversion. In the diversion.
  467. `box' or `boxa' without an argument ends the diversion.
  468. -- Register: \n[.z]
  469. -- Register: \n[.d]
  470. Diversions may be nested. The read-only number register `.z'
  471. contains the name of the current diversion (this is a string-valued
  472. register). The read-only number register `.d' contains the current
  473. vertical place in the diversion. If not in a diversion it is the
  474. same as register `nl'.
  475. -- Register: \n[.h]
  476. The "high-water mark" on the current page. It corresponds to the
  477. text baseline of the lowest line on the page. This is a read-only
  478. register.
  479. .tm .h==\n[.h], nl==\n[nl]
  480. => .h==0, nl==-1
  481. This is a test.
  482. .br
  483. .sp 2
  484. .tm .h==\n[.h], nl==\n[nl]
  485. => .h==40, nl==120
  486. As can be seen in the previous example, empty lines are not
  487. considered in the return value of the `.h' register.
  488. -- Register: \n[dn]
  489. -- Register: \n[dl]
  490. After completing a diversion, the read-write number registers `dn'
  491. and `dl' contain the vertical and horizontal size of the diversion.
  492. Note that only the just processed lines are counted: For the
  493. computation of `dn' and `dl', the requests `da' and `boxa' are
  494. handled as if `di' and `box' had been used - lines which have been
  495. already stored in a macro are not taken into account.
  496. .\" Center text both horizontally & vertically
  497. .
  498. .\" Enclose macro definitions in .eo and .ec
  499. .\" to avoid the doubling of the backslash
  500. .eo
  501. .\" macro .(c starts centering mode
  502. .de (c
  503. . br
  504. . ev (c
  505. . evc 0
  506. . in 0
  507. . nf
  508. . di @c
  509. ..
  510. .\" macro .)c terminates centering mode
  511. .de )c
  512. . br
  513. . ev
  514. . di
  515. . nr @s (((\n[.t]u - \n[dn]u) / 2u) - 1v)
  516. . sp \n[@s]u
  517. . ce 1000
  518. . @c
  519. . ce 0
  520. . sp \n[@s]u
  521. . br
  522. . fi
  523. . rr @s
  524. . rm @s
  525. . rm @c
  526. ..
  527. .\" End of macro definitions, restore escape mechanism
  528. .ec
  529. -- Escape: \!
  530. -- Escape: \?anything\?
  531. Prevent requests, macros, and escapes from being interpreted when
  532. read into a diversion. Both escapes take the given text and
  533. "transparently" embed it into the diversion. This is useful for
  534. macros which shouldn't be invoked until the diverted text is
  535. actually output.
  536. The `\!' escape transparently embeds text up to and including the
  537. end of the line. The `\?' escape transparently embeds text until
  538. the next occurrence of the `\?' escape. Example:
  539. \?ANYTHING\?
  540. ANYTHING may not contain newlines; use `\!' to embed newlines in
  541. a diversion. The escape sequence `\?' is also recognized in copy
  542. mode and turned into a single internal code; it is this code that
  543. terminates ANYTHING. Thus the following example prints 4.
  544. .nr x 1
  545. .nf
  546. .di d
  547. \?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
  548. .di
  549. .nr x 2
  550. .di e
  551. .d
  552. .di
  553. .nr x 3
  554. .di f
  555. .e
  556. .di
  557. .nr x 4
  558. .f
  559. Both escapes read the data in copy mode.
  560. If `\!' is used in the top-level diversion, its argument is
  561. directly embedded into the `gtroff' intermediate output. This can
  562. be used for example to control a postprocessor which processes the
  563. data before it is sent to the device driver.
  564. The `\?' escape used in the top-level diversion produces no output
  565. at all; its argument is simply ignored.
  566. -- Request: .output string
  567. Emit STRING directly to the `gtroff' intermediate output (subject
  568. to copy-mode interpretation); this is similar to `\!' used at the
  569. top level. An initial double quote in STRING is stripped off to
  570. allow initial blanks.
  571. This request can't be used before the first page has started - if
  572. you get an error, simply insert `.br' before the `output' request.
  573. Without argument, `output' is ignored.
  574. Use with caution! It is normally only needed for mark-up used by a
  575. postprocessor which does something with the output before sending
  576. it to the output device, filtering out STRING again.
  577. -- Request: .asciify div
  578. "Unformat" the diversion specified by DIV in such a way that ASCII
  579. characters, characters translated with the `trin' request, space
  580. characters, and some escape sequences that were formatted and
  581. diverted are treated like ordinary input characters when the
  582. diversion is reread. It can be also used for gross hacks; for
  583. example, the following sets register `n' to 1.
  584. .tr @.
  585. .di x
  586. @nr n 1
  587. .br
  588. .di
  589. .tr @@
  590. .asciify x
  591. .x
  592. *Note Copy-in Mode::.
  593. -- Request: .unformat div
  594. Like `asciify', unformat the specified diversion. However,
  595. `unformat' only unformats spaces and tabs between words.
  596. Unformatted tabs are treated as input tokens, and spaces are
  597. stretchable again.
  598. The vertical size of lines is not preserved; glyph information
  599. (font, font size, space width, etc.) is retained.
  600. 
  601. File: groff, Node: Environments, Next: Suppressing output, Prev: Diversions, Up: gtroff Reference
  602. 5.26 Environments
  603. =================
  604. It happens frequently that some text should be printed in a certain
  605. format regardless of what may be in effect at the time, for example, in
  606. a trap invoked macro to print headers and footers. To solve this
  607. `gtroff' processes text in "environments". An environment contains
  608. most of the parameters that control text processing. It is possible to
  609. switch amongst these environments; by default `gtroff' processes text
  610. in environment 0. The following is the information kept in an
  611. environment.
  612. * font parameters (size, family, style, glyph height and slant, space
  613. and sentence space size)
  614. * page parameters (line length, title length, vertical spacing, line
  615. spacing, indentation, line numbering, centering, right-justifying,
  616. underlining, hyphenation data)
  617. * fill and adjust mode
  618. * tab stops, tab and leader characters, escape character, no-break
  619. and hyphen indicators, margin character data
  620. * partially collected lines
  621. * input traps
  622. * drawing and fill colours
  623. These environments may be given arbitrary names (see *Note
  624. Identifiers::, for more info). Old versions of `troff' only had
  625. environments named `0', `1', and `2'.
  626. -- Request: .ev [env]
  627. -- Register: \n[.ev]
  628. Switch to another environment. The argument ENV is the name of
  629. the environment to switch to. With no argument, `gtroff' switches
  630. back to the previous environment. There is no limit on the number
  631. of named environments; they are created the first time that they
  632. are referenced. The `.ev' read-only register contains the name or
  633. number of the current environment. This is a string-valued
  634. register.
  635. Note that a call to `ev' (with argument) pushes the previously
  636. active environment onto a stack. If, say, environments `foo',
  637. `bar', and `zap' are called (in that order), the first `ev'
  638. request without parameter switches back to environment `bar'
  639. (which is popped off the stack), and a second call switches back
  640. to environment `foo'.
  641. Here is an example:
  642. .ev footnote-env
  643. .fam N
  644. .ps 6
  645. .vs 8
  646. .ll -.5i
  647. .ev
  648. ...
  649. .ev footnote-env
  650. \(dg Note the large, friendly letters.
  651. .ev
  652. -- Request: .evc env
  653. Copy the environment ENV into the current environment.
  654. The following environment data is not copied:
  655. * Partially filled lines.
  656. * The status whether the previous line was interrupted.
  657. * The number of lines still to center, or to right-justify, or
  658. to underline (with or without underlined spaces); they are
  659. set to zero.
  660. * The status whether a temporary indentation is active.
  661. * Input traps and its associated data.
  662. * Line numbering mode is disabled; it can be reactivated with
  663. `.nm +0'.
  664. * The number of consecutive hyphenated lines (set to zero).
  665. -- Register: \n[.w]
  666. -- Register: \n[.cht]
  667. -- Register: \n[.cdp]
  668. -- Register: \n[.csk]
  669. The `\n[.w]' register contains the width of the last glyph added
  670. to the current environment.
  671. The `\n[.cht]' register contains the height of the last glyph
  672. added to the current environment.
  673. The `\n[.cdp]' register contains the depth of the last glyph added
  674. to the current environment. It is positive for glyphs extending
  675. below the baseline.
  676. The `\n[.csk]' register contains the "skew" (how far to the right
  677. of the glyph's center that `gtroff' should place an accent) of the
  678. last glyph added to the current environment.
  679. -- Register: \n[.n]
  680. The `\n[.n]' register contains the length of the previous output
  681. line in the current environment.
  682. 
  683. File: groff, Node: Suppressing output, Next: Colors, Prev: Environments, Up: gtroff Reference
  684. 5.27 Suppressing output
  685. =======================
  686. -- Escape: \Onum
  687. Disable or enable output depending on the value of NUM:
  688. `\O0'
  689. Disable any glyphs from being emitted to the device driver,
  690. provided that the escape occurs at the outer level (see
  691. `\O[3]' and `\O[4]'). Motion is not suppressed so
  692. effectively `\O[0]' means _pen up_.
  693. `\O1'
  694. Enable output of glyphs, provided that the escape occurs at
  695. the outer level.
  696. `\O0' and `\O1' also reset the four registers `opminx', `opminy',
  697. `opmaxx', and `opmaxy' to -1. *Note Register Index::. These four
  698. registers mark the top left and bottom right hand corners of a box
  699. which encompasses all written glyphs.
  700. For example the input text:
  701. Hello \O[0]world \O[1]this is a test.
  702. produces the following output:
  703. Hello this is a test.
  704. `\O2'
  705. Provided that the escape occurs at the outer level, enable
  706. output of glyphs and also write out to `stderr' the page
  707. number and four registers encompassing the glyphs previously
  708. written since the last call to `\O'.
  709. `\O3'
  710. Begin a nesting level. At start-up, `gtroff' is at outer
  711. level.
  712. `\O4'
  713. End a nesting level.
  714. `\O[5PFILENAME]'
  715. This escape is `grohtml' specific. Provided that this escape
  716. occurs at the outer nesting level write the `filename' to
  717. `stderr'. The position of the image, P, must be specified
  718. and must be one of `l', `r', `c', or `i' (left, right,
  719. centered, inline). FILENAME will be associated with the
  720. production of the next inline image.
  721. 
  722. File: groff, Node: Colors, Next: I/O, Prev: Suppressing output, Up: gtroff Reference
  723. 5.28 Colors
  724. ===========
  725. -- Request: .color [n]
  726. -- Register: \n[.color]
  727. If N is missing or non-zero, activate colors (this is the default);
  728. otherwise, turn it off.
  729. The read-only number register `.color' is 1 if colors are active,
  730. 0 otherwise.
  731. Internally, `color' sets a global flag; it does not produce a
  732. token. Similar to the `cp' request, you should use it at the
  733. beginning of your document to control color output.
  734. Colors can be also turned off with the `-c' command line option.
  735. -- Request: .defcolor ident scheme color_components
  736. Define color with name IDENT. SCHEME can be one of the following
  737. values: `rgb' (three components), `cmy' (three components), `cmyk'
  738. (four components), and `gray' or `grey' (one component).
  739. Color components can be given either as a hexadecimal string or as
  740. positive decimal integers in the range 0-65535. A hexadecimal
  741. string contains all color components concatenated. It must start
  742. with either `#' or `##'; the former specifies hex values in the
  743. range 0-255 (which are internally multiplied by 257), the latter
  744. in the range 0-65535. Examples: `#FFC0CB' (pink), `##ffff0000ffff'
  745. (magenta). The default color name value is device-specific
  746. (usually black). It is possible that the default color for `\m'
  747. and `\M' is not identical.
  748. A new scaling indicator `f' has been introduced which multiplies
  749. its value by 65536; this makes it convenient to specify color
  750. components as fractions in the range 0 to 1 (1f equals 65536u).
  751. Example:
  752. .defcolor darkgreen rgb 0.1f 0.5f 0.2f
  753. Note that `f' is the default scaling indicator for the `defcolor'
  754. request, thus the above statement is equivalent to
  755. .defcolor darkgreen rgb 0.1 0.5 0.2
  756. -- Request: .gcolor [color]
  757. -- Escape: \mc
  758. -- Escape: \m(co
  759. -- Escape: \m[color]
  760. -- Register: \n[.m]
  761. Set (glyph) drawing color. The following examples show how to
  762. turn the next four words red.
  763. .gcolor red
  764. these are in red
  765. .gcolor
  766. and these words are in black.
  767. \m[red]these are in red\m[] and these words are in black.
  768. The escape `\m[]' returns to the previous color, as does a call to
  769. `gcolor' without an argument.
  770. The name of the current drawing color is available in the
  771. read-only, string-valued number register `.m'.
  772. The drawing color is associated with the current environment
  773. (*note Environments::).
  774. Note that `\m' doesn't produce an input token in `gtroff'. As a
  775. consequence, it can be used in requests like `mc' (which expects a
  776. single character as an argument) to change the color on the fly:
  777. .mc \m[red]x\m[]
  778. -- Request: .fcolor [color]
  779. -- Escape: \Mc
  780. -- Escape: \M(co
  781. -- Escape: \M[color]
  782. -- Register: \n[.M]
  783. Set fill (background) color for filled objects drawn with the
  784. `\D'...'' commands.
  785. A red ellipse can be created with the following code:
  786. \M[red]\h'0.5i'\D'E 2i 1i'\M[]
  787. The escape `\M[]' returns to the previous fill color, as does a
  788. call to `fcolor' without an argument.
  789. The name of the current fill (background) color is available in the
  790. read-only, string-valued number register `.M'.
  791. The fill color is associated with the current environment (*note
  792. Environments::).
  793. Note that `\M' doesn't produce an input token in `gtroff'.
  794. 
  795. File: groff, Node: I/O, Next: Postprocessor Access, Prev: Colors, Up: gtroff Reference
  796. 5.29 I/O
  797. ========
  798. `gtroff' has several requests for including files:
  799. -- Request: .so file
  800. Read in the specified FILE and includes it in place of the `so'
  801. request. This is quite useful for large documents, e.g. keeping
  802. each chapter in a separate file. *Note gsoelim::, for more
  803. information.
  804. Since `gtroff' replaces the `so' request with the contents of
  805. `file', it makes a difference whether the data is terminated with
  806. a newline or not: Assuming that file `xxx' contains the word `foo'
  807. without a final newline, this
  808. This is
  809. .so xxx
  810. bar
  811. yields `This is foobar'.
  812. The search path for FILE can be controlled with the `-I' command
  813. line option.
  814. -- Request: .pso command
  815. Read the standard output from the specified COMMAND and includes
  816. it in place of the `pso' request.
  817. This request causes an error if used in safer mode (which is the
  818. default). Use `groff''s or `troff''s `-U' option to activate
  819. unsafe mode.
  820. The comment regarding a final newline for the `so' request is valid
  821. for `pso' also.
  822. -- Request: .mso file
  823. Identical to the `so' request except that `gtroff' searches for
  824. the specified FILE in the same directories as macro files for the
  825. the `-m' command line option. If the file name to be included has
  826. the form `NAME.tmac' and it isn't found, `mso' tries to include
  827. `tmac.NAME' and vice versa.
  828. -- Request: .trf file
  829. -- Request: .cf file
  830. Transparently output the contents of FILE. Each line is output as
  831. if it were preceded by `\!'; however, the lines are not subject to
  832. copy mode interpretation. If the file does not end with a newline,
  833. then a newline is added (`trf' only). For example, to define a
  834. macro `x' containing the contents of file `f', use
  835. .di x
  836. .trf f
  837. .di
  838. Both `trf' and `cf', when used in a diversion, embeds an object in
  839. the diversion which, when reread, causes the contents of FILE to
  840. be transparently copied through to the output. In UNIX `troff',
  841. the contents of FILE is immediately copied through to the output
  842. regardless of whether there is a current diversion; this behaviour
  843. is so anomalous that it must be considered a bug.
  844. While `cf' copies the contents of FILE completely unprocessed,
  845. `trf' disallows characters such as NUL that are not valid `gtroff'
  846. input characters (*note Identifiers::).
  847. Both requests cause a line break.
  848. -- Request: .nx [file]
  849. Force `gtroff' to continue processing of the file specified as an
  850. argument. If no argument is given, immediately jump to the end of
  851. file.
  852. -- Request: .rd [prompt [arg1 arg2 ...]]
  853. Read from standard input, and include what is read as though it
  854. were part of the input file. Text is read until a blank line is
  855. encountered.
  856. If standard input is a TTY input device (keyboard), write PROMPT
  857. to standard error, followed by a colon (or send BEL for a beep if
  858. no argument is given).
  859. Arguments after PROMPT are available for the input. For example,
  860. the line
  861. .rd data foo bar
  862. with the input `This is \$2.' prints
  863. This is bar.
  864. Using the `nx' and `rd' requests, it is easy to set up form letters.
  865. The form letter template is constructed like this, putting the
  866. following lines into a file called `repeat.let':
  867. .ce
  868. \*(td
  869. .sp 2
  870. .nf
  871. .rd
  872. .sp
  873. .rd
  874. .fi
  875. Body of letter.
  876. .bp
  877. .nx repeat.let
  878. When this is run, a file containing the following lines should be
  879. redirected in. Note that requests included in this file are executed
  880. as though they were part of the form letter. The last block of input
  881. is the `ex' request which tells `groff' to stop processing. If this
  882. was not there, `groff' would not know when to stop.
  883. Trent A. Fisher
  884. 708 NW 19th Av., #202
  885. Portland, OR 97209
  886. Dear Trent,
  887. Len Adollar
  888. 4315 Sierra Vista
  889. San Diego, CA 92103
  890. Dear Mr. Adollar,
  891. .ex
  892. -- Request: .pi pipe
  893. Pipe the output of `gtroff' to the shell command(s) specified by
  894. PIPE. This request must occur before `gtroff' has a chance to
  895. print anything.
  896. `pi' causes an error if used in safer mode (which is the default).
  897. Use `groff''s or `troff''s `-U' option to activate unsafe mode.
  898. Multiple calls to `pi' are allowed, acting as a chain. For
  899. example,
  900. .pi foo
  901. .pi bar
  902. ...
  903. is the same as `.pi foo | bar'.
  904. Note that the intermediate output format of `gtroff' is piped to
  905. the specified commands. Consequently, calling `groff' without the
  906. `-Z' option normally causes a fatal error.
  907. -- Request: .sy cmds
  908. -- Register: \n[systat]
  909. Execute the shell command(s) specified by CMDS. The output is not
  910. saved anyplace, so it is up to the user to do so.
  911. This request causes an error if used in safer mode (which is the
  912. default). Use `groff''s or `troff''s `-U' option to activate
  913. unsafe mode.
  914. For example, the following code fragment introduces the current
  915. time into a document:
  916. .sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
  917. (localtime(time))[2,1,0]' > /tmp/x\n[$$]
  918. .so /tmp/x\n[$$]
  919. .sy rm /tmp/x\n[$$]
  920. \nH:\nM:\nS
  921. Note that this works by having the `perl' script (run by `sy')
  922. print out the `nr' requests which set the number registers `H',
  923. `M', and `S', and then reads those commands in with the `so'
  924. request.
  925. For most practical purposes, the number registers `seconds',
  926. `minutes', and `hours' which are initialized at start-up of
  927. `gtroff' should be sufficient. Use the `af' request to get a
  928. formatted output:
  929. .af hours 00
  930. .af minutes 00
  931. .af seconds 00
  932. \n[hours]:\n[minutes]:\n[seconds]
  933. The `systat' read-write number register contains the return value
  934. of the `system()' function executed by the last `sy' request.
  935. -- Request: .open stream file
  936. -- Request: .opena stream file
  937. Open the specified FILE for writing and associates the specified
  938. STREAM with it.
  939. The `opena' request is like `open', but if the file exists, append
  940. to it instead of truncating it.
  941. Both `open' and `opena' cause an error if used in safer mode
  942. (which is the default). Use `groff''s or `troff''s `-U' option to
  943. activate unsafe mode.
  944. -- Request: .write stream data
  945. -- Request: .writec stream data
  946. Write to the file associated with the specified STREAM. The
  947. stream must previously have been the subject of an open request.
  948. The remainder of the line is interpreted as the `ds' request reads
  949. its second argument: A leading `"' is stripped, and it is read in
  950. copy-in mode.
  951. The `writec' request is like `write', but only `write' appends a
  952. newline to the data.
  953. -- Request: .writem stream xx
  954. Write the contents of the macro or string XX to the file
  955. associated with the specified STREAM.
  956. XX is read in copy mode, i.e., already formatted elements are
  957. ignored. Consequently, diversions must be unformatted with the
  958. `asciify' request before calling `writem'. Usually, this means a
  959. loss of information.
  960. -- Request: .close stream
  961. Close the specified STREAM; the stream is no longer an acceptable
  962. argument to the `write' request.
  963. Here a simple macro to write an index entry.
  964. .open idx test.idx
  965. .
  966. .de IX
  967. . write idx \\n[%] \\$*
  968. ..
  969. .
  970. .IX test entry
  971. .
  972. .close idx
  973. -- Escape: \Ve
  974. -- Escape: \V(ev
  975. -- Escape: \V[env]
  976. Interpolate the contents of the specified environment variable ENV
  977. (one-character name E, two-character name EV) as returned by the
  978. function `getenv'. `\V' is interpreted in copy-in mode.
  979. 
  980. File: groff, Node: Postprocessor Access, Next: Miscellaneous, Prev: I/O, Up: gtroff Reference
  981. 5.30 Postprocessor Access
  982. =========================
  983. There are two escapes which give information directly to the
  984. postprocessor. This is particularly useful for embedding POSTSCRIPT
  985. into the final document.
  986. -- Escape: \X'xxx'
  987. Embeds its argument into the `gtroff' output preceded with `x X'.
  988. The escapes `\&', `\)', `\%', and `\:' are ignored within `\X',
  989. `\ ' and `\~' are converted to single space characters. All other
  990. escapes (except `\\' which produces a backslash) cause an error.
  991. If the `use_charnames_in_special' keyword is set in the `DESC'
  992. file, special characters no longer cause an error; the name XX is
  993. represented as `\(XX)' in the `x X' output command. Additionally,
  994. the backslash is represented as `\\'.
  995. `use_charnames_in_special' is currently used by `grohtml' only.
  996. -- Escape: \Yn
  997. -- Escape: \Y(nm
  998. -- Escape: \Y[name]
  999. This is approximately equivalent to `\X'\*[NAME]'' (one-character
  1000. name N, two-character name NM). However, the contents of the
  1001. string or macro NAME are not interpreted; also it is permitted for
  1002. NAME to have been defined as a macro and thus contain newlines (it
  1003. is not permitted for the argument to `\X' to contain newlines).
  1004. The inclusion of newlines requires an extension to the UNIX `troff'
  1005. output format, and confuses drivers that do not know about this
  1006. extension (*note Device Control Commands::).
  1007. *Note Output Devices::.
  1008. 
  1009. File: groff, Node: Miscellaneous, Next: Gtroff Internals, Prev: Postprocessor Access, Up: gtroff Reference
  1010. 5.31 Miscellaneous
  1011. ==================
  1012. This section documents parts of `gtroff' which cannot (yet) be
  1013. categorized elsewhere in this manual.
  1014. -- Request: .nm [start [inc [space [indent]]]]
  1015. Print line numbers. START is the line number of the _next_ output
  1016. line. INC indicates which line numbers are printed. For example,
  1017. the value 5 means to emit only line numbers which are multiples
  1018. of 5; this defaults to 1. SPACE is the space to be left between
  1019. the number and the text; this defaults to one digit space. The
  1020. fourth argument is the indentation of the line numbers, defaulting
  1021. to zero. Both SPACE and INDENT are given as multiples of digit
  1022. spaces; they can be negative also. Without any arguments, line
  1023. numbers are turned off.
  1024. `gtroff' reserves three digit spaces for the line number (which is
  1025. printed right-justified) plus the amount given by INDENT; the
  1026. output lines are concatenated to the line numbers, separated by
  1027. SPACE, and _without_ reducing the line length. Depending on the
  1028. value of the horizontal page offset (as set with the `po'
  1029. request), line numbers which are longer than the reserved space
  1030. stick out to the left, or the whole line is moved to the right.
  1031. Parameters corresponding to missing arguments are not changed; any
  1032. non-digit argument (to be more precise, any argument starting with
  1033. a character valid as a delimiter for identifiers) is also treated
  1034. as missing.
  1035. If line numbering has been disabled with a call to `nm' without an
  1036. argument, it can be reactivated with `.nm +0', using the
  1037. previously active line numbering parameters.
  1038. The parameters of `nm' are associated with the current environment
  1039. (*note Environments::). The current output line number is
  1040. available in the number register `ln'.
  1041. .po 1m
  1042. .ll 2i
  1043. This test shows how line numbering works with groff.
  1044. .nm 999
  1045. This test shows how line numbering works with groff.
  1046. .br
  1047. .nm xxx 3 2
  1048. .ll -\w'0'u
  1049. This test shows how line numbering works with groff.
  1050. .nn 2
  1051. This test shows how line numbering works with groff.
  1052. And here the result:
  1053. This test shows how
  1054. line numbering works
  1055. 999 with groff. This
  1056. 1000 test shows how line
  1057. 1001 numbering works with
  1058. 1002 groff.
  1059. This test shows how
  1060. line numbering
  1061. works with groff.
  1062. This test shows how
  1063. 1005 line numbering
  1064. works with groff.
  1065. -- Request: .nn [skip]
  1066. Temporarily turn off line numbering. The argument is the number
  1067. of lines not to be numbered; this defaults to 1.
  1068. -- Request: .mc glyph [dist]
  1069. Print a "margin character" to the right of the text.(1) (*note
  1070. Miscellaneous-Footnote-1::) The first argument is the glyph to be
  1071. printed. The second argument is the distance away from the right
  1072. margin. If missing, the previously set value is used; default is
  1073. 10pt). For text lines that are too long (that is, longer than the
  1074. text length plus DIST), the margin character is directly appended
  1075. to the lines.
  1076. With no arguments the margin character is turned off. If this
  1077. occurs before a break, no margin character is printed.
  1078. For compatibility with AT&T `troff', a call to `mc' to set the
  1079. margin character can't be undone immediately; at least one line
  1080. gets a margin character. Thus
  1081. .ll 1i
  1082. .mc \[br]
  1083. .mc
  1084. xxx
  1085. .br
  1086. xxx
  1087. produces
  1088. xxx |
  1089. xxx
  1090. For empty lines and lines produced by the `tl' request no margin
  1091. character is emitted.
  1092. The margin character is associated with the current environment
  1093. (*note Environments::).
  1094. This is quite useful for indicating text that has changed, and, in
  1095. fact, there are programs available for doing this (they are called
  1096. `nrchbar' and `changebar' and can be found in any
  1097. `comp.sources.unix' archive).…