PageRenderTime 120ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 1ms

/contrib/groff/doc/groff.texinfo

https://bitbucket.org/freebsd/freebsd-head/
Unknown | 15454 lines | 12574 code | 2880 blank | 0 comment | 0 complexity | 8b088c4112aed0fed1c425e0f04bd15a MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, BSD-3-Clause, LGPL-2.0, LGPL-2.1, BSD-2-Clause, 0BSD, JSON, AGPL-1.0, GPL-2.0
  1. \input texinfo @c -*-texinfo-*-
  2. @c
  3. @c Please convert this manual with `texi2dvi -e groff.texinfo' due to
  4. @c problems in texinfo regarding expansion of user-defined macros.
  5. @c
  6. @c You need texinfo 4.6 or newer to format this document!
  7. @c
  8. @c %**start of header (This is for running Texinfo on a region.)
  9. @setfilename groff
  10. @settitle The GNU Troff Manual
  11. @setchapternewpage odd
  12. @footnotestyle separate
  13. @c %**end of header (This is for running Texinfo on a region.)
  14. @documentlanguage en
  15. @documentencoding ISO-8859-1
  16. @smallbook
  17. @finalout
  18. @copying
  19. This manual documents GNU @code{troff} version 1.19.2.
  20. Copyright @copyright{} 1994-2000, 2001, 2002, 2003, 2004, 2005
  21. Free Software Foundation, Inc.
  22. @quotation
  23. Permission is granted to copy, distribute and/or modify this document
  24. under the terms of the GNU Free Documentation License, Version 1.1 or
  25. any later version published by the Free Software Foundation; with no
  26. Invariant Sections, with the Front-Cover texts being `A GNU Manual,''
  27. and with the Back-Cover Texts as in (a) below. A copy of the
  28. license is included in the section entitled `GNU Free Documentation
  29. License.''
  30. (a) The FSF's Back-Cover Text is: `You have freedom to copy and modify
  31. this GNU Manual, like GNU software. Copies published by the Free
  32. Software Foundation raise funds for GNU development.''
  33. @end quotation
  34. @end copying
  35. @c We use the following indices:
  36. @c
  37. @c cindex: concepts
  38. @c rqindex: requests
  39. @c esindex: escapes
  40. @c vindex: registers
  41. @c kindex: commands in font files
  42. @c pindex: programs and files
  43. @c tindex: environment variables
  44. @c maindex: macros
  45. @c stindex: strings
  46. @c opindex: operators
  47. @c
  48. @c tindex and cindex are merged.
  49. @defcodeindex rq
  50. @defcodeindex es
  51. @defcodeindex ma
  52. @defcodeindex st
  53. @defcodeindex op
  54. @syncodeindex tp cp
  55. @c To avoid uppercasing in @deffn while converting to info, we define
  56. @c our special @Var{}.
  57. @macro Var{arg}
  58. @r{@slanted{\arg\}}
  59. @end macro
  60. @c To assure correct HTML translation, some ugly hacks are necessary.
  61. @c While processing a @def... request, the HTML translator looks at the
  62. @c next line to decide whether it should start indentation or not. If
  63. @c it is something starting with @def... (e.g. @deffnx), it doesn't.
  64. @c So we must assure during macro expansion that a @def... is seen.
  65. @c
  66. @c The following macros have to be used:
  67. @c
  68. @c One item:
  69. @c
  70. @c @Def...
  71. @c
  72. @c Two items:
  73. @c
  74. @c @Def...List
  75. @c @Def...ListEnd
  76. @c
  77. @c More than two:
  78. @c
  79. @c @Def...List
  80. @c @Def...Item
  81. @c @Def...Item
  82. @c ...
  83. @c @Def...ListEnd
  84. @c
  85. @c The definition block must end with
  86. @c
  87. @c @endDef...
  88. @c
  89. @c The above is valid for texinfo 4.0f and above.
  90. @c a dummy macro to assure the `@def...'
  91. @macro defdummy
  92. @c
  93. @end macro
  94. @c definition of requests
  95. @macro Defreq{name, arg}
  96. @deffn Request @t{.\name\} \arg\
  97. @rqindex \name\
  98. @c
  99. @end macro
  100. @macro DefreqList{name, arg}
  101. @deffn Request @t{.\name\} \arg\
  102. @defdummy
  103. @rqindex \name\
  104. @c
  105. @end macro
  106. @macro DefreqItem{name, arg}
  107. @deffnx Request @t{.\name\} \arg\
  108. @defdummy
  109. @rqindex \name\
  110. @c
  111. @end macro
  112. @macro DefreqListEnd{name, arg}
  113. @deffnx Request @t{.\name\} \arg\
  114. @rqindex \name\
  115. @c
  116. @end macro
  117. @macro endDefreq
  118. @end deffn
  119. @end macro
  120. @c definition of escapes
  121. @macro Defesc{name, delimI, arg, delimII}
  122. @deffn Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
  123. @esindex \name\
  124. @c
  125. @end macro
  126. @macro DefescList{name, delimI, arg, delimII}
  127. @deffn Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
  128. @defdummy
  129. @esindex \name\
  130. @c
  131. @end macro
  132. @macro DefescItem{name, delimI, arg, delimII}
  133. @deffnx Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
  134. @defdummy
  135. @esindex \name\
  136. @c
  137. @end macro
  138. @macro DefescListEnd{name, delimI, arg, delimII}
  139. @deffnx Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
  140. @esindex \name\
  141. @c
  142. @end macro
  143. @macro endDefesc
  144. @end deffn
  145. @end macro
  146. @c definition of registers
  147. @macro Defreg{name}
  148. @deffn Register @t{\\n[\name\]}
  149. @vindex \name\
  150. @c
  151. @end macro
  152. @macro DefregList{name}
  153. @deffn Register @t{\\n[\name\]}
  154. @defdummy
  155. @vindex \name\
  156. @c
  157. @end macro
  158. @macro DefregItem{name}
  159. @deffnx Register @t{\\n[\name\]}
  160. @defdummy
  161. @vindex \name\
  162. @c
  163. @end macro
  164. @macro DefregListEnd{name}
  165. @deffnx Register @t{\\n[\name\]}
  166. @vindex \name\
  167. @c
  168. @end macro
  169. @macro endDefreg
  170. @end deffn
  171. @end macro
  172. @c definition of registers specific to macro packages, preprocessors, etc.
  173. @macro Defmpreg{name, package}
  174. @deffn Register @t{\\n[\name\]}
  175. @vindex \name\ @r{[}\package\@r{]}
  176. @c
  177. @end macro
  178. @macro DefmpregList{name, package}
  179. @deffn Register @t{\\n[\name\]}
  180. @defdummy
  181. @vindex \name\ @r{[}\package\@r{]}
  182. @c
  183. @end macro
  184. @macro DefmpregItem{name, package}
  185. @deffnx Register @t{\\n[\name\]}
  186. @defdummy
  187. @vindex \name\ @r{[}\package\@r{]}
  188. @c
  189. @end macro
  190. @macro DefmpregListEnd{name, package}
  191. @deffnx Register @t{\\n[\name\]}
  192. @vindex \name\ @r{[}\package\@r{]}
  193. @c
  194. @end macro
  195. @macro endDefmpreg
  196. @end deffn
  197. @end macro
  198. @c definition of macros
  199. @macro Defmac{name, arg, package}
  200. @defmac @t{.\name\} \arg\
  201. @maindex \name\ @r{[}\package\@r{]}
  202. @c
  203. @end macro
  204. @macro DefmacList{name, arg, package}
  205. @defmac @t{.\name\} \arg\
  206. @defdummy
  207. @maindex \name\ @r{[}\package\@r{]}
  208. @c
  209. @end macro
  210. @macro DefmacItem{name, arg, package}
  211. @defmacx @t{.\name\} \arg\
  212. @defdummy
  213. @maindex \name\ @r{[}\package\@r{]}
  214. @c
  215. @end macro
  216. @macro DefmacListEnd{name, arg, package}
  217. @defmacx @t{.\name\} \arg\
  218. @maindex \name\ @r{[}\package\@r{]}
  219. @c
  220. @end macro
  221. @macro endDefmac
  222. @end defmac
  223. @end macro
  224. @c definition of strings
  225. @macro Defstr{name, package}
  226. @deffn String @t{\\*[\name\]}
  227. @stindex \name\ @r{[}\package\@r{]}
  228. @c
  229. @end macro
  230. @macro DefstrList{name, package}
  231. @deffn String @t{\\*[\name\]}
  232. @defdummy
  233. @stindex \name\ @r{[}\package\@r{]}
  234. @c
  235. @end macro
  236. @macro DefstrItem{name, package}
  237. @deffnx String @t{\\*[\name\]}
  238. @defdummy
  239. @stindex \name\ @r{[}\package\@r{]}
  240. @c
  241. @end macro
  242. @macro DefstrListEnd{name, package}
  243. @deffnx String @t{\\*[\name\]}
  244. @stindex \name\ @r{[}\package\@r{]}
  245. @c
  246. @end macro
  247. @macro endDefstr
  248. @end deffn
  249. @end macro
  250. @c our example macro
  251. @macro Example
  252. @example
  253. @group
  254. @end macro
  255. @macro endExample
  256. @end group
  257. @end example
  258. @end macro
  259. @c <text>
  260. @tex
  261. \gdef\Langlemacro{\angleleft}
  262. \gdef\Ranglemacro{\angleright}
  263. @end tex
  264. @iftex
  265. @set Langlemacro @Langlemacro
  266. @set Ranglemacro @Ranglemacro
  267. @end iftex
  268. @ifnottex
  269. @set Langlemacro <
  270. @set Ranglemacro >
  271. @end ifnottex
  272. @macro angles{text}
  273. @value{Langlemacro}@r{\text\}@value{Ranglemacro}
  274. @end macro
  275. @c a <= sign
  276. @c
  277. @c A value defined with @set is embedded into three group levels if
  278. @c called with @value, so we need seven \aftergroup to put \le outside
  279. @c of the groups -- this is necessary to get proper mathematical spacing.
  280. @tex
  281. \gdef\LEmacro{\aftergroup\aftergroup\aftergroup\aftergroup
  282. \aftergroup\aftergroup\aftergroup\le}
  283. @end tex
  284. @iftex
  285. @set LEmacro @LEmacro
  286. @end iftex
  287. @ifnottex
  288. @set LEmacro <=
  289. @end ifnottex
  290. @macro LE
  291. @value{LEmacro}
  292. @end macro
  293. @c We need special parentheses, brackets, and braces:
  294. @c
  295. @c . Real parentheses in @deffn produce an error while compiling with
  296. @c TeX.
  297. @c . Real brackets use the wrong font in @deffn, overriding @t{}.
  298. @c
  299. @c . @{ and @} fail with info if used in a macro.
  300. @c
  301. @c Since macros aren't expanded in @deffn during -E, the following
  302. @c definitions are for non-TeX only.
  303. @c
  304. @c This is true for texinfo 4.0 and above.
  305. @iftex
  306. @set Lparenmacro @lparen
  307. @set Rparenmacro @rparen
  308. @set Lbrackmacro @lbrack
  309. @set Rbrackmacro @rbrack
  310. @set Lbracemacro @{
  311. @set Rbracemacro @}
  312. @end iftex
  313. @ifnottex
  314. @set Lparenmacro (
  315. @set Rparenmacro )
  316. @set Lbrackmacro [
  317. @set Rbrackmacro ]
  318. @set Lbracemacro @{
  319. @set Rbracemacro @}
  320. @end ifnottex
  321. @macro Lparen{}
  322. @value{Lparenmacro}
  323. @end macro
  324. @macro Rparen{}
  325. @value{Rparenmacro}
  326. @end macro
  327. @macro Lbrack{}
  328. @value{Lbrackmacro}
  329. @end macro
  330. @macro Rbrack{}
  331. @value{Rbrackmacro}
  332. @end macro
  333. @macro Lbrace{}
  334. @value{Lbracemacro}
  335. @end macro
  336. @macro Rbrace{}
  337. @value{Rbracemacro}
  338. @end macro
  339. @c This suppresses the word `Appendix' in the appendix headers.
  340. @tex
  341. \gdef\gobblefirst#1#2{#2}
  342. \gdef\putwordAppendix{\gobblefirst}
  343. @end tex
  344. @c We map some latin-1 characters to corresponding texinfo macros.
  345. @tex
  346. \global\catcode`^^e4\active % ä
  347. \gdef^^e4{\"a}
  348. \global\catcode`^^c4\active % Ä
  349. \gdef^^c4{\"A}
  350. \global\catcode`^^e9\active % é
  351. \gdef^^e9{\'e}
  352. \global\catcode`^^c9\active % É
  353. \gdef^^c9{\'E}
  354. \global\catcode`^^f6\active % ö
  355. \gdef^^f6{\"o}
  356. \global\catcode`^^d6\active % Ö
  357. \gdef^^d6{\"O}
  358. \global\catcode`^^fc\active % ü
  359. \gdef^^fc{\"u}
  360. \global\catcode`^^dc\active % Ü
  361. \gdef^^dc{\"U}
  362. \global\catcode`^^e6\active % ć
  363. \gdef^^e6{\ae}
  364. \global\catcode`^^c6\active % Ć
  365. \gdef^^c6{\AE}
  366. \global\catcode`^^df\active % ß
  367. \gdef^^df{\ss}
  368. @end tex
  369. @c Note: We say `Roman numerals' but `roman font'.
  370. @dircategory Typesetting
  371. @direntry
  372. * Groff: (groff). The GNU troff document formatting system.
  373. @end direntry
  374. @titlepage
  375. @title groff
  376. @subtitle The GNU implementation of @code{troff}
  377. @subtitle Edition 1.19.2
  378. @subtitle Summer 2005
  379. @author by Trent A.@tie{}Fisher
  380. @author and Werner Lemberg (@email{bug-groff@@gnu.org})
  381. @page
  382. @vskip 0pt plus 1filll
  383. @insertcopying
  384. @end titlepage
  385. @contents
  386. @ifinfo
  387. @node Top, Introduction, (dir), (dir)
  388. @top GNU troff
  389. @insertcopying
  390. @end ifinfo
  391. @ifhtml
  392. @menu
  393. * Introduction::
  394. * Invoking groff::
  395. * Tutorial for Macro Users::
  396. * Macro Packages::
  397. * gtroff Reference::
  398. * Preprocessors::
  399. * Output Devices::
  400. * File formats::
  401. * Installation::
  402. * Copying This Manual::
  403. * Request Index::
  404. * Escape Index::
  405. * Operator Index::
  406. * Register Index::
  407. * Macro Index::
  408. * String Index::
  409. * Glyph Name Index::
  410. * Font File Keyword Index::
  411. * Program and File Index::
  412. * Concept Index::
  413. @end menu
  414. @node Top, Introduction, (dir), (dir)
  415. @top GNU troff
  416. @insertcopying
  417. @end ifhtml
  418. @menu
  419. * Introduction::
  420. * Invoking groff::
  421. * Tutorial for Macro Users::
  422. * Macro Packages::
  423. * gtroff Reference::
  424. * Preprocessors::
  425. * Output Devices::
  426. * File formats::
  427. * Installation::
  428. * Copying This Manual::
  429. * Request Index::
  430. * Escape Index::
  431. * Operator Index::
  432. * Register Index::
  433. * Macro Index::
  434. * String Index::
  435. * Glyph Name Index::
  436. * Font File Keyword Index::
  437. * Program and File Index::
  438. * Concept Index::
  439. @end menu
  440. @c =====================================================================
  441. @c =====================================================================
  442. @node Introduction, Invoking groff, Top, Top
  443. @chapter Introduction
  444. @cindex introduction
  445. GNU @code{troff} (or @code{groff}) is a system for typesetting
  446. documents. @code{troff} is very flexible and has been in existence (and
  447. use) for about 3@tie{}decades. It is quite widespread and firmly
  448. entrenched in the @acronym{UNIX} community.
  449. @menu
  450. * What Is groff?::
  451. * History::
  452. * groff Capabilities::
  453. * Macro Package Intro::
  454. * Preprocessor Intro::
  455. * Output device intro::
  456. * Credits::
  457. @end menu
  458. @c =====================================================================
  459. @node What Is groff?, History, Introduction, Introduction
  460. @section What Is @code{groff}?
  461. @cindex what is @code{groff}?
  462. @cindex @code{groff} -- what is it?
  463. @code{groff} belongs to an older generation of document preparation
  464. systems, which operate more like compilers than the more recent
  465. interactive @acronym{WYSIWYG}@footnote{What You See Is What You Get}
  466. systems. @code{groff} and its contemporary counterpart, @TeX{}, both
  467. work using a @dfn{batch} paradigm: The input (or @dfn{source}) files are
  468. normal text files with embedded formatting commands. These files can
  469. then be processed by @code{groff} to produce a typeset document on a
  470. variety of devices.
  471. Likewise, @code{groff} should not be confused with a @dfn{word
  472. processor}, since that term connotes an integrated system that includes
  473. an editor and a text formatter. Also, many word processors follow the
  474. @acronym{WYSIWYG} paradigm discussed earlier.
  475. Although @acronym{WYSIWYG} systems may be easier to use, they have a
  476. number of disadvantages compared to @code{troff}:
  477. @itemize @bullet
  478. @item
  479. They must be used on a graphics display to work on a document.
  480. @item
  481. Most of the @acronym{WYSIWYG} systems are either non-free or are not
  482. very portable.
  483. @item
  484. @code{troff} is firmly entrenched in all @acronym{UNIX} systems.
  485. @item
  486. It is difficult to have a wide range of capabilities available within
  487. the confines of a GUI/window system.
  488. @item
  489. It is more difficult to make global changes to a document.
  490. @end itemize
  491. @quotation
  492. ``GUIs normally make it simple to accomplish simple actions and
  493. impossible to accomplish complex actions.'' --Doug Gwyn (22/Jun/91 in
  494. @code{comp.unix.wizards})
  495. @end quotation
  496. @c =====================================================================
  497. @node History, groff Capabilities, What Is groff?, Introduction
  498. @section History
  499. @cindex history
  500. @cindex @code{runoff}, the program
  501. @cindex @code{rf}, the program
  502. @code{troff} can trace its origins back to a formatting program called
  503. @code{runoff}, written by J.@tie{}E.@tie{}Saltzer, which ran on MIT's CTSS
  504. operating system in the mid-sixties. This name came from the common
  505. phrase of the time ``I'll run off a document.'' Bob Morris ported it to
  506. the 635 architecture and called the program @code{roff} (an abbreviation
  507. of @code{runoff}). It was rewritten as @code{rf} for the @w{PDP-7}
  508. (before having @acronym{UNIX}), and at the same time (1969), Doug
  509. McIllroy rewrote an extended and simplified version of @code{roff} in
  510. the @acronym{BCPL} programming language.
  511. @cindex @code{roff}, the program
  512. The first version of @acronym{UNIX} was developed on a @w{PDP-7} which
  513. was sitting around Bell Labs. In 1971 the developers wanted to get a
  514. @w{PDP-11} for further work on the operating system. In order to
  515. justify the cost for this system, they proposed that they would
  516. implement a document formatting system for the @acronym{AT&T} patents
  517. division. This first formatting program was a reimplementation of
  518. McIllroy's @code{roff}, written by J.@tie{}F.@tie{}Ossanna.
  519. @cindex @code{nroff}, the program
  520. When they needed a more flexible language, a new version of @code{roff}
  521. called @code{nroff} (``Newer @code{roff}'') was written. It had a much
  522. more complicated syntax, but provided the basis for all future versions.
  523. When they got a Graphic Systems CAT Phototypesetter, Ossanna wrote a
  524. version of @code{nroff} that would drive it. It was dubbed
  525. @code{troff}, for ``typesetter @code{roff}'', although many people have
  526. speculated that it actually means ``Times @code{roff}'' because of the
  527. use of the Times font family in @code{troff} by default. As such, the
  528. name @code{troff} is pronounced `@w{t-roff}' rather than `trough'.
  529. With @code{troff} came @code{nroff} (they were actually the same program
  530. except for some @samp{#ifdef}s), which was for producing output for line
  531. printers and character terminals. It understood everything @code{troff}
  532. did, and ignored the commands which were not applicable (e.g.@: font
  533. changes).
  534. Since there are several things which cannot be done easily in
  535. @code{troff}, work on several preprocessors began. These programs would
  536. transform certain parts of a document into @code{troff}, which made a
  537. very natural use of pipes in @acronym{UNIX}.
  538. The @code{eqn} preprocessor allowed mathematical formulć to be
  539. specified in a much simpler and more intuitive manner. @code{tbl} is a
  540. preprocessor for formatting tables. The @code{refer} preprocessor (and
  541. the similar program, @code{bib}) processes citations in a document
  542. according to a bibliographic database.
  543. Unfortunately, Ossanna's @code{troff} was written in @w{PDP-11} assembly
  544. language and produced output specifically for the CAT phototypesetter.
  545. He rewrote it in C, although it was now 7000@tie{}lines of uncommented
  546. code and still dependent on the CAT. As the CAT became less common, and
  547. was no longer supported by the manufacturer, the need to make it support
  548. other devices became a priority. However, before this could be done,
  549. Ossanna was killed in a car accident.
  550. @pindex ditroff
  551. @cindex @code{ditroff}, the program
  552. So, Brian Kernighan took on the task of rewriting @code{troff}. The
  553. newly rewritten version produced device independent code which was
  554. very easy for postprocessors to read and translate to the appropriate
  555. printer codes. Also, this new version of @code{troff} (called
  556. @code{ditroff} for ``device independent @code{troff}'') had several
  557. extensions, which included drawing functions.
  558. Due to the additional abilities of the new version of @code{troff},
  559. several new preprocessors appeared. The @code{pic} preprocessor
  560. provides a wide range of drawing functions. Likewise the @code{ideal}
  561. preprocessor did the same, although via a much different paradigm. The
  562. @code{grap} preprocessor took specifications for graphs, but, unlike
  563. other preprocessors, produced @code{pic} code.
  564. James Clark began work on a GNU implementation of @code{ditroff} in
  565. early@tie{}1989. The first version, @code{groff}@tie{}0.3.1, was released
  566. June@tie{}1990. @code{groff} included:
  567. @itemize @bullet
  568. @item
  569. A replacement for @code{ditroff} with many extensions.
  570. @item
  571. The @code{soelim}, @code{pic}, @code{tbl}, and @code{eqn} preprocessors.
  572. @item
  573. Postprocessors for character devices, @sc{PostScript}, @TeX{} DVI, and
  574. X@tie{}Windows. GNU @code{troff} also eliminated the need for a
  575. separate @code{nroff} program with a postprocessor which would produce
  576. @acronym{ASCII} output.
  577. @item
  578. A version of the @file{me} macros and an implementation of the
  579. @file{man} macros.
  580. @end itemize
  581. Also, a front-end was included which could construct the, sometimes
  582. painfully long, pipelines required for all the post- and preprocessors.
  583. Development of GNU @code{troff} progressed rapidly, and saw the
  584. additions of a replacement for @code{refer}, an implementation of the
  585. @file{ms} and @file{mm} macros, and a program to deduce how to format a
  586. document (@code{grog}).
  587. It was declared a stable (i.e.@: non-beta) package with the release of
  588. version@tie{}1.04 around November@tie{}1991.
  589. Beginning in@tie{}1999, @code{groff} has new maintainers (the package was
  590. an orphan for a few years). As a result, new features and programs like
  591. @code{grn}, a preprocessor for gremlin images, and an output device to
  592. produce @acronym{HTML} output have been added.
  593. @c =====================================================================
  594. @node groff Capabilities, Macro Package Intro, History, Introduction
  595. @section @code{groff} Capabilities
  596. @cindex @code{groff} capabilities
  597. @cindex capabilities of @code{groff}
  598. So what exactly is @code{groff} capable of doing? @code{groff} provides
  599. a wide range of low-level text formatting operations. Using these, it
  600. is possible to perform a wide range of formatting tasks, such as
  601. footnotes, table of contents, multiple columns, etc. Here's a list of
  602. the most important operations supported by @code{groff}:
  603. @itemize @bullet
  604. @item
  605. text filling, adjusting, and centering
  606. @item
  607. hyphenation
  608. @item
  609. page control
  610. @item
  611. font and glyph size control
  612. @item
  613. vertical spacing (e.g.@: double-spacing)
  614. @item
  615. line length and indenting
  616. @item
  617. macros, strings, diversions, and traps
  618. @item
  619. number registers
  620. @item
  621. tabs, leaders, and fields
  622. @item
  623. input and output conventions and character translation
  624. @item
  625. overstrike, bracket, line drawing, and zero-width functions
  626. @item
  627. local horizontal and vertical motions and the width function
  628. @item
  629. three-part titles
  630. @item
  631. output line numbering
  632. @item
  633. conditional acceptance of input
  634. @item
  635. environment switching
  636. @item
  637. insertions from the standard input
  638. @item
  639. input/output file switching
  640. @item
  641. output and error messages
  642. @end itemize
  643. @c =====================================================================
  644. @node Macro Package Intro, Preprocessor Intro, groff Capabilities, Introduction
  645. @section Macro Packages
  646. @cindex macro packages
  647. Since @code{groff} provides such low-level facilities, it can be quite
  648. difficult to use by itself. However, @code{groff} provides a
  649. @dfn{macro} facility to specify how certain routine operations
  650. (e.g.@tie{}starting paragraphs, printing headers and footers, etc.)@:
  651. should be done. These macros can be collected together into a @dfn{macro
  652. package}. There are a number of macro packages available; the most
  653. common (and the ones described in this manual) are @file{man},
  654. @file{mdoc}, @file{me}, @file{ms}, and @file{mm}.
  655. @c =====================================================================
  656. @node Preprocessor Intro, Output device intro, Macro Package Intro, Introduction
  657. @section Preprocessors
  658. @cindex preprocessors
  659. Although @code{groff} provides most functions needed to format a
  660. document, some operations would be unwieldy (e.g.@: to draw pictures).
  661. Therefore, programs called @dfn{preprocessors} were written which
  662. understand their own language and produce the necessary @code{groff}
  663. operations. These preprocessors are able to differentiate their own
  664. input from the rest of the document via markers.
  665. To use a preprocessor, @acronym{UNIX} pipes are used to feed the output
  666. from the preprocessor into @code{groff}. Any number of preprocessors
  667. may be used on a given document; in this case, the preprocessors are
  668. linked together into one pipeline. However, with @code{groff}, the user
  669. does not need to construct the pipe, but only tell @code{groff} what
  670. preprocessors to use.
  671. @code{groff} currently has preprocessors for producing tables
  672. (@code{tbl}), typesetting equations (@code{eqn}), drawing pictures
  673. (@code{pic} and @code{grn}), and for processing bibliographies
  674. (@code{refer}). An associated program which is useful when dealing with
  675. preprocessors is @code{soelim}.
  676. A free implementation of @code{grap}, a preprocessor for drawing graphs,
  677. can be obtained as an extra package; @code{groff} can use @code{grap}
  678. also.
  679. There are other preprocessors in existence, but, unfortunately, no free
  680. implementations are available. Among them are preprocessors for drawing
  681. mathematical pictures (@code{ideal}) and chemical structures
  682. (@code{chem}).
  683. @c =====================================================================
  684. @node Output device intro, Credits, Preprocessor Intro, Introduction
  685. @section Output Devices
  686. @cindex postprocessors
  687. @cindex output devices
  688. @cindex devices for output
  689. @code{groff} actually produces device independent code which may be
  690. fed into a postprocessor to produce output for a particular device.
  691. Currently, @code{groff} has postprocessors for @sc{PostScript}
  692. devices, character terminals, X@tie{}Windows (for previewing), @TeX{}
  693. DVI format, HP LaserJet@tie{}4 and Canon LBP printers (which use
  694. @acronym{CAPSL}), and @acronym{HTML}.
  695. @c =====================================================================
  696. @node Credits, , Output device intro, Introduction
  697. @section Credits
  698. @cindex credits
  699. Large portions of this manual were taken from existing documents, most
  700. notably, the manual pages for the @code{groff} package by James Clark,
  701. and Eric Allman's papers on the @file{me} macro package.
  702. The section on the @file{man} macro package is partly based on
  703. Susan@tie{}G.@: Kleinmann's @file{groff_man} manual page written for the
  704. Debian GNU/Linux system.
  705. Larry Kollar contributed the section in the @file{ms} macro package.
  706. @c =====================================================================
  707. @c =====================================================================
  708. @node Invoking groff, Tutorial for Macro Users, Introduction, Top
  709. @chapter Invoking @code{groff}
  710. @cindex invoking @code{groff}
  711. @cindex @code{groff} invocation
  712. This section focuses on how to invoke the @code{groff} front end. This
  713. front end takes care of the details of constructing the pipeline among
  714. the preprocessors, @code{gtroff} and the postprocessor.
  715. It has become a tradition that GNU programs get the prefix @samp{g} to
  716. distinguish it from its original counterparts provided by the host (see
  717. @ref{Environment}, for more details). Thus, for example, @code{geqn} is
  718. GNU @code{eqn}. On operating systems like GNU/Linux or the Hurd, which
  719. don't contain proprietary versions of @code{troff}, and on
  720. MS-DOS/MS-Windows, where @code{troff} and associated programs are not
  721. available at all, this prefix is omitted since GNU @code{troff} is the
  722. only used incarnation of @code{troff}. Exception: @samp{groff} is never
  723. replaced by @samp{roff}.
  724. In this document, we consequently say @samp{gtroff} when talking about
  725. the GNU @code{troff} program. All other implementations of @code{troff}
  726. are called @acronym{AT&T} @code{troff} which is the common origin of
  727. all @code{troff} derivates (with more or less compatible changes).
  728. Similarly, we say @samp{gpic}, @samp{geqn}, etc.
  729. @menu
  730. * Groff Options::
  731. * Environment::
  732. * Macro Directories::
  733. * Font Directories::
  734. * Paper Size::
  735. * Invocation Examples::
  736. @end menu
  737. @c =====================================================================
  738. @node Groff Options, Environment, Invoking groff, Invoking groff
  739. @section Options
  740. @cindex options
  741. @pindex groff
  742. @pindex gtroff
  743. @pindex gpic
  744. @pindex geqn
  745. @pindex ggrn
  746. @pindex grap
  747. @pindex gtbl
  748. @pindex grefer
  749. @pindex gsoelim
  750. @code{groff} normally runs the @code{gtroff} program and a postprocessor
  751. appropriate for the selected device. The default device is @samp{ps}
  752. (but it can be changed when @code{groff} is configured and built). It
  753. can optionally preprocess with any of @code{gpic}, @code{geqn},
  754. @code{gtbl}, @code{ggrn}, @code{grap}, @code{grefer}, or @code{gsoelim}.
  755. This section only documents options to the @code{groff} front end. Many
  756. of the arguments to @code{groff} are passed on to @code{gtroff},
  757. therefore those are also included. Arguments to pre- or postprocessors
  758. can be found in @ref{Invoking gpic}, @ref{Invoking geqn}, @ref{Invoking
  759. gtbl}, @ref{Invoking ggrn}, @ref{Invoking grefer}, @ref{Invoking
  760. gsoelim}, @ref{Invoking grotty}, @ref{Invoking grops}, @ref{Invoking
  761. grohtml}, @ref{Invoking grodvi}, @ref{Invoking grolj4}, @ref{Invoking
  762. grolbp}, and @ref{Invoking gxditview}.
  763. The command line format for @code{groff} is:
  764. @Example
  765. groff [ -abceghilpstvzCEGNRSUVXZ ] [ -F@var{dir} ] [ -m@var{name} ]
  766. [ -T@var{def} ] [ -f@var{fam} ] [ -w@var{name} ] [ -W@var{name} ]
  767. [ -M@var{dir} ] [ -d@var{cs} ] [ -r@var{cn} ] [ -n@var{num} ]
  768. [ -o@var{list} ] [ -P@var{arg} ] [ -L@var{arg} ] [ -I@var{dir} ]
  769. [ @var{files}@dots{} ]
  770. @endExample
  771. The command line format for @code{gtroff} is as follows.
  772. @Example
  773. gtroff [ -abcivzCERU ] [ -w@var{name} ] [ -W@var{name} ] [ -d@var{cs} ]
  774. [ -f@var{fam} ] [ -m@var{name} ] [ -n@var{num} ]
  775. [ -o@var{list} ] [ -r@var{cn} ] [ -T@var{name} ]
  776. [ -F@var{dir} ] [ -M@var{dir} ] [ @var{files}@dots{} ]
  777. @endExample
  778. @noindent
  779. Obviously, many of the options to @code{groff} are actually passed on to
  780. @code{gtroff}.
  781. Options without an argument can be grouped behind a single@tie{}@option{-}.
  782. A filename of@tie{}@file{-} denotes the standard input. It is possible to
  783. have whitespace between an option and its parameter.
  784. The @code{grog} command can be used to guess the correct @code{groff}
  785. command to format a file.
  786. Here's the description of the command-line options:
  787. @cindex command-line options
  788. @table @samp
  789. @item -h
  790. Print a help message.
  791. @item -e
  792. Preprocess with @code{geqn}.
  793. @item -t
  794. Preprocess with @code{gtbl}.
  795. @item -g
  796. Preprocess with @code{ggrn}.
  797. @item -G
  798. Preprocess with @code{grap}.
  799. @item -p
  800. Preprocess with @code{gpic}.
  801. @item -s
  802. Preprocess with @code{gsoelim}.
  803. @item -c
  804. Suppress color output.
  805. @item -R
  806. Preprocess with @code{grefer}. No mechanism is provided for passing
  807. arguments to @code{grefer} because most @code{grefer} options have
  808. equivalent commands which can be included in the file. @xref{grefer},
  809. for more details.
  810. @pindex troffrc
  811. @pindex troffrc-end
  812. Note that @code{gtroff} also accepts a @option{-R} option, which is not
  813. accessible via @code{groff}. This option prevents the loading of the
  814. @file{troffrc} and @file{troffrc-end} files.
  815. @item -v
  816. Make programs run by @code{groff} print out their version number.
  817. @item -V
  818. Print the pipeline on @code{stdout} instead of executing it. If specified
  819. more than once, print the pipeline on @code{stderr} and execute it.
  820. @item -z
  821. Suppress output from @code{gtroff}. Only error messages are printed.
  822. @item -Z
  823. Do not postprocess the output of @code{gtroff}. Normally @code{groff}
  824. automatically runs the appropriate postprocessor.
  825. @item -P@var{arg}
  826. Pass @var{arg} to the postprocessor. Each argument should be passed
  827. with a separate @option{-P} option. Note that @code{groff} does not
  828. prepend @samp{-} to @var{arg} before passing it to the postprocessor.
  829. @item -l
  830. Send the output to a spooler for printing. The command used for this is
  831. specified by the @code{print} command in the device description file
  832. (see @ref{Font Files}, for more info). If not present, @option{-l} is
  833. ignored.
  834. @item -L@var{arg}
  835. Pass @var{arg} to the spooler. Each argument should be passed with a
  836. separate @option{-L} option. Note that @code{groff} does not prepend
  837. a @samp{-} to @var{arg} before passing it to the postprocessor.
  838. If the @code{print} keyword in the device description file is missing,
  839. @option{-L} is ignored.
  840. @item -T@var{dev}
  841. Prepare output for device @var{dev}. The default device is @samp{ps},
  842. unless changed when @code{groff} was configured and built. The
  843. following are the output devices currently available:
  844. @table @code
  845. @item ps
  846. For @sc{PostScript} printers and previewers.
  847. @item dvi
  848. For @TeX{} DVI format.
  849. @item X75
  850. For a 75@dmn{dpi} X11 previewer.
  851. @item X75-12
  852. For a 75@dmn{dpi} X11 previewer with a 12@dmn{pt} base font in the
  853. document.
  854. @item X100
  855. For a 100@dmn{dpi} X11 previewer.
  856. @item X100-12
  857. For a 100@dmn{dpi} X11 previewer with a 12@dmn{pt} base font in the
  858. document.
  859. @item ascii
  860. @cindex encoding, output, @acronym{ASCII}
  861. @cindex @acronym{ASCII}, output encoding
  862. @cindex output encoding, @acronym{ASCII}
  863. For typewriter-like devices using the (7-bit) @acronym{ASCII}
  864. character set.
  865. @item latin1
  866. @cindex encoding, output, @w{latin-1} (ISO @w{8859-1})
  867. @cindex @w{latin-1} (ISO @w{8859-1}), output encoding
  868. @cindex ISO @w{8859-1} (@w{latin-1}), output encoding
  869. @cindex output encoding, @w{latin-1} (ISO @w{8859-1})
  870. For typewriter-like devices that support the @w{Latin-1}
  871. (ISO@tie{}@w{8859-1}) character set.
  872. @item utf8
  873. @cindex encoding, output, @w{utf-8}
  874. @cindex @w{utf-8}, output encoding
  875. @cindex output encoding, @w{utf-8}
  876. For typewriter-like devices which use the Unicode (ISO@tie{}10646)
  877. character set with @w{UTF-8} encoding.
  878. @item cp1047
  879. @cindex encoding, output, @acronym{EBCDIC}
  880. @cindex @acronym{EBCDIC}, output encoding
  881. @cindex output encoding, @acronym{EBCDIC}
  882. @cindex encoding, output, cp1047
  883. @cindex cp1047, output encoding
  884. @cindex output encoding, cp1047
  885. @cindex IBM cp1047 output encoding
  886. For typewriter-like devices which use the @acronym{EBCDIC} encoding IBM
  887. cp1047.
  888. @item lj4
  889. For HP LaserJet4-compatible (or other PCL5-compatible) printers.
  890. @item lbp
  891. For Canon @acronym{CAPSL} printers (@w{LBP-4} and @w{LBP-8} series laser
  892. printers).
  893. @pindex pre-grohtml
  894. @pindex post-grohtml
  895. @cindex @code{grohtml}, the program
  896. @item html
  897. To produce @acronym{HTML} output. Note that the @acronym{HTML} driver
  898. consists of two parts, a preprocessor (@code{pre-grohtml}) and a
  899. postprocessor (@code{post-grohtml}).
  900. @end table
  901. @cindex output device name string register (@code{.T})
  902. @cindex output device usage number register (@code{.T})
  903. The predefined @code{gtroff} string register @code{.T} contains the
  904. current output device; the read-only number register @code{.T} is set
  905. to@tie{}1 if this option is used (which is always true if @code{groff} is
  906. used to call @code{gtroff}). @xref{Built-in Registers}.
  907. The postprocessor to be used for a device is specified by the
  908. @code{postpro} command in the device description file. (@xref{Font
  909. Files}, for more info.) This can be overridden with the @option{-X}
  910. option.
  911. @item -X
  912. Preview with @code{gxditview} instead of using the usual postprocessor.
  913. This is unlikely to produce good results except with @option{-Tps}.
  914. Note that this is not the same as using @option{-TX75} or
  915. @option{-TX100} to view a document with @code{gxditview}: The former
  916. uses the metrics of the specified device, whereas the latter uses
  917. X-specific fonts and metrics.
  918. @item -N
  919. Don't allow newlines with @code{eqn} delimiters. This is the same as
  920. the @option{-N} option in @code{geqn}.
  921. @item -S
  922. @cindex @code{open} request, and safer mode
  923. @cindex @code{opena} request, and safer mode
  924. @cindex @code{pso} request, and safer mode
  925. @cindex @code{sy} request, and safer mode
  926. @cindex @code{pi} request, and safer mode
  927. @cindex safer mode
  928. @cindex mode, safer
  929. Safer mode. Pass the @option{-S} option to @code{gpic} and disable the
  930. @code{open}, @code{opena}, @code{pso}, @code{sy}, and @code{pi}
  931. requests. For security reasons, this is enabled by default.
  932. @item -U
  933. @cindex mode, unsafe
  934. @cindex unsafe mode
  935. Unsafe mode. This enables the @code{open}, @code{opena}, @code{pso},
  936. @code{sy}, and @code{pi} requests.
  937. @item -a
  938. @cindex @acronym{ASCII} approximation output register (@code{.A})
  939. Generate an @acronym{ASCII} approximation of the typeset output. The
  940. read-only register @code{.A} is then set to@tie{}1. @xref{Built-in
  941. Registers}. A typical example is
  942. @Example
  943. groff -a -man -Tdvi troff.man | less
  944. @endExample
  945. @noindent
  946. which shows how lines are broken for the DVI device. Note that this
  947. option is rather useless today since graphic output devices are
  948. available virtually everywhere.
  949. @item -b
  950. Print a backtrace with each warning or error message. This backtrace
  951. should help track down the cause of the error. The line numbers given
  952. in the backtrace may not always be correct: @code{gtroff} can get
  953. confused by @code{as} or @code{am} requests while counting line numbers.
  954. @item -i
  955. Read the standard input after all the named input files have been
  956. processed.
  957. @item -w@var{name}
  958. Enable warning @var{name}. Available warnings are described in
  959. @ref{Debugging}. Multiple @option{-w} options are allowed.
  960. @item -W@var{name}
  961. Inhibit warning @var{name}. Multiple @option{-W} options are allowed.
  962. @item -E
  963. Inhibit all error messages.
  964. @item -C
  965. Enable compatibility mode. @xref{Implementation Differences}, for the
  966. list of incompatibilities between @code{groff} and @acronym{AT&T}
  967. @code{troff}.
  968. @item -d@var{c}@var{s}
  969. @itemx -d@var{name}=@var{s}
  970. Define @var{c} or @var{name} to be a string@tie{}@var{s}. @var{c}@tie{}must
  971. be a one-letter name; @var{name} can be of arbitrary length. All string
  972. assignments happen before loading any macro file (including the start-up
  973. file).
  974. @item -f@var{fam}
  975. Use @var{fam} as the default font family. @xref{Font Families}.
  976. @item -m@var{name}
  977. Read in the file @file{@var{name}.tmac}. Normally @code{groff} searches
  978. for this in its macro directories. If it isn't found, it tries
  979. @file{tmac.@var{name}} (searching in the same directories).
  980. @item -n@var{num}
  981. Number the first page @var{num}.
  982. @item -o@var{list}
  983. @cindex print current page register (@code{.P})
  984. Output only pages in @var{list}, which is a comma-separated list of page
  985. ranges; @samp{@var{n}} means print page@tie{}@var{n}, @samp{@var{m}-@var{n}}
  986. means print every page between @var{m} and@tie{}@var{n}, @samp{-@var{n}}
  987. means print every page up to@tie{}@var{n}, @samp{@var{n}-} means print every
  988. page beginning with@tie{}@var{n}. @code{gtroff} exits after printing the
  989. last page in the list. All the ranges are inclusive on both ends.
  990. Within @code{gtroff}, this information can be extracted with the
  991. @samp{.P} register. @xref{Built-in Registers}.
  992. If your document restarts page numbering at the beginning of each
  993. chapter, then @code{gtroff} prints the specified page range for each
  994. chapter.
  995. @item -r@var{c}@var{n}
  996. @itemx -r@var{name}=@var{n}
  997. Set number register@tie{}@var{c} or @var{name} to the value@tie{}@var{n}.
  998. @var{c}@tie{}must be a one-letter name; @var{name} can be of arbitrary
  999. length. @var{n}@tie{}can be any @code{gtroff} numeric expression. All
  1000. register assignments happen before loading any macro file (including
  1001. the start-up file).
  1002. @item -F@var{dir}
  1003. Search @file{@var{dir}} for subdirectories @file{dev@var{name}}
  1004. (@var{name} is the name of the device), for the @file{DESC} file, and
  1005. for font files before looking in the standard directories (@pxref{Font
  1006. Directories}). This option is passed to all pre- and postprocessors
  1007. using the @env{GROFF_FONT_PATH} environment variable.
  1008. @item -M@var{dir}
  1009. Search directory @file{@var{dir}} for macro files before the standard
  1010. directories (@pxref{Macro Directories}).
  1011. @item -I@var{dir}
  1012. This option may be used to specify a directory to search for files.
  1013. It is passed to the following programs:
  1014. @itemize
  1015. @item
  1016. @code{gsoelim} (see @ref{gsoelim} for more details);
  1017. it also implies @code{groff}'s @option{-s} option.
  1018. @item
  1019. @code{gtroff}; it is used to search files named in the @code{psbb} and
  1020. @code{so} requests.
  1021. @item
  1022. @code{grops}; it is used to search files named in the
  1023. @w{@code{\X'ps: import}} and @w{@code{\X'ps: file}} escapes.
  1024. @end itemize
  1025. The current directory is always searched first. This option may be specified
  1026. more than once; the directories will be searched in the order specified. No
  1027. directory search is performed for files specified using an absolute path.
  1028. @end table
  1029. @c =====================================================================
  1030. @node Environment, Macro Directories, Groff Options, Invoking groff
  1031. @section Environment
  1032. @cindex environment variables
  1033. @cindex variables in environment
  1034. There are also several environment variables (of the operating system,
  1035. not within @code{gtroff}) which can modify the behavior of @code{groff}.
  1036. @table @code
  1037. @item GROFF_COMMAND_PREFIX
  1038. @tindex GROFF_COMMAND_PREFIX@r{, environment variable}
  1039. @cindex command prefix
  1040. @cindex prefix, for commands
  1041. If this is set to@tie{}@var{X}, then @code{groff} runs @code{@var{X}troff}
  1042. instead of @code{gtroff}. This also applies to @code{tbl}, @code{pic},
  1043. @code{eqn}, @code{grn}, @code{refer}, and @code{soelim}. It does not
  1044. apply to @code{grops}, @code{grodvi}, @code{grotty}, @code{pre-grohtml},
  1045. @code{post-grohtml}, @code{grolj4}, and @code{gxditview}.
  1046. The default command prefix is determined during the installation process.
  1047. If a non-GNU troff system is found, prefix @samp{g} is used, none
  1048. otherwise.
  1049. @item GROFF_TMAC_PATH
  1050. @tindex GROFF_TMAC_PATH@r{, environment variable}
  1051. A colon-separated list of directories in which to search for macro files
  1052. (before the default directories are tried). @xref{Macro Directories}.
  1053. @item GROFF_TYPESETTER
  1054. @tindex GROFF_TYPESETTER@r{, environment variable}
  1055. The default output device.
  1056. @item GROFF_FONT_PATH
  1057. @tindex GROFF_FONT_PATH@r{, environment variable}
  1058. A colon-separated list of directories in which to search for the
  1059. @code{dev}@var{name} directory (before the default directories are
  1060. tried). @xref{Font Directories}.
  1061. @item GROFF_BIN_PATH
  1062. @tindex GROFF_BIN_PATH@r{, environment variable}
  1063. This search path, followed by @code{PATH}, is used for commands executed
  1064. by @code{groff}.
  1065. @item GROFF_TMPDIR
  1066. @tindex GROFF_TMPDIR@r{, environment variable}
  1067. @tindex TMPDIR@r{, environment variable}
  1068. The directory in which @code{groff} creates temporary files. If this is
  1069. not set and @env{TMPDIR} is set, temporary files are created in that
  1070. directory. Otherwise temporary files are created in a system-dependent
  1071. default directory (on Unix and GNU/Linux systems, this is usually
  1072. @file{/tmp}). @code{grops}, @code{grefer}, @code{pre-grohtml}, and
  1073. @code{post-grohtml} can create temporary files in this directory.
  1074. @end table
  1075. Note that MS-DOS and MS-Windows ports of @code{groff} use semi-colons,
  1076. rather than colons, to separate the directories in the lists described
  1077. above.
  1078. @c =====================================================================
  1079. @node Macro Directories, Font Directories, Environment, Invoking groff
  1080. @section Macro Directories
  1081. @cindex macro directories
  1082. @cindex directories for macros
  1083. @cindex searching macros
  1084. @cindex macros, searching
  1085. All macro file names must be named @code{@var{name}.tmac} or
  1086. @code{tmac.@var{name}} to make the @option{-m@var{name}} command line
  1087. option work. The @code{mso} request doesn't have this restriction; any
  1088. file name can be used, and @code{gtroff} won't try to append or prepend
  1089. the @samp{tmac} string.
  1090. @cindex tmac, directory
  1091. @cindex directory, for tmac files
  1092. @cindex tmac, path
  1093. @cindex path, for tmac files
  1094. @cindex searching macro files
  1095. @cindex macro files, searching
  1096. @cindex files, macro, searching
  1097. Macro files are kept in the @dfn{tmac directories}, all of which
  1098. constitute the @dfn{tmac path}. The elements of the search path for
  1099. macro files are (in that order):
  1100. @itemize @bullet
  1101. @item
  1102. The directories specified with @code{gtroff}'s or @code{groff}'s
  1103. @option{-M} command line option.
  1104. @item
  1105. @tindex GROFF_TMAC_PATH@r{, environment variable}
  1106. The directories given in the @env{GROFF_TMAC_PATH} environment
  1107. variable.
  1108. @item
  1109. @cindex safer mode
  1110. @cindex mode, safer
  1111. @cindex unsafe mode
  1112. @cindex mode, unsafe
  1113. @cindex current directory
  1114. @cindex directory, current
  1115. The current directory (only if in unsafe mode using the @option{-U}
  1116. command line switch).
  1117. @item
  1118. @cindex home directory
  1119. @cindex directory, home
  1120. The home directory.
  1121. @item
  1122. @cindex site-specific directory
  1123. @cindex directory, site-specific
  1124. @cindex platform-specific directory
  1125. @cindex directory, platform-specific
  1126. A platform-dependent directory, a site-specific (platform-independent)
  1127. directory, and the main tmac directory; the default locations are
  1128. @Example
  1129. /usr/local/lib/groff/site-tmac
  1130. /usr/local/share/groff/site-tmac
  1131. /usr/local/share/groff/1.18.2/tmac
  1132. @endExample
  1133. @noindent
  1134. assuming that the version of @code{groff} is 1.18.2, and the installation
  1135. prefix was @file{/usr/local}. It is possible to fine-tune those
  1136. directories during the installation process.
  1137. @end itemize
  1138. @c =====================================================================
  1139. @node Font Directories, Paper Size, Macro Directories, Invoking groff
  1140. @section Font Directories
  1141. @cindex font directories
  1142. @cindex directories for fonts
  1143. @cindex searching fonts
  1144. @cindex fonts, searching
  1145. Basically, there is no restriction how font files for @code{groff} are
  1146. named and how long font names are; however, to make the font family
  1147. mechanism work (@pxref{Font Families}), fonts within a family should
  1148. start with the family name, followed by the shape. For example, the
  1149. Times family uses @samp{T} for the family name and @samp{R}, @samp{B},
  1150. @samp{I}, and @samp{BI} to indicate the shapes `roman', `bold',
  1151. `italic', and `bold italic', respectively. Thus the final font names
  1152. are @samp{TR}, @samp{TB}, @samp{TI}, and @samp{TBI}.
  1153. @cindex font path
  1154. @cindex path, for font files
  1155. All font files are kept in the @dfn{font directories} which constitute
  1156. the @dfn{font path}. The file search functions will always append the
  1157. directory @code{dev}@var{name}, where @var{name} is the name of the
  1158. output device. Assuming, say, DVI output, and @file{/foo/bar} as a
  1159. font directory, the font files for @code{grodvi} must be in
  1160. @file{/foo/bar/devdvi}.
  1161. The elements of the search path for font files are (in that order):
  1162. @itemize @bullet
  1163. @item
  1164. The directories specified with @code{gtroff}'s or @code{groff}'s
  1165. @option{-F} command line option. All device drivers and some
  1166. preprocessors also have this option.
  1167. @item
  1168. @tindex GROFF_FONT_PATH@r{, environment variable}
  1169. The directories given in the @env{GROFF_FONT_PATH} environment
  1170. variable.
  1171. @item
  1172. @cindex site-specific directory
  1173. @cindex directory, site-specific
  1174. A site-specific directory and the main font directory; the default
  1175. locations are
  1176. @Example
  1177. /usr/local/share/groff/site-font
  1178. /usr/local/share/groff/1.18.2/font
  1179. @endExample
  1180. @noindent
  1181. assuming that the version of @code{groff} is 1.18.2, and the installation
  1182. prefix was @file{/usr/local}. It is possible to fine-tune those
  1183. directories during the installation process.
  1184. @end itemize
  1185. @c =====================================================================
  1186. @node Paper Size, Invocation Examples, Font Directories, Invoking groff
  1187. @section Paper Size
  1188. @cindex paper size
  1189. @cindex size, paper
  1190. @cindex landscape page orientation
  1191. @cindex orientation, landscape
  1192. @cindex page orientation, landscape
  1193. In groff, the page size for @code{gtroff} and for output devices are
  1194. handled separately. @xref{Page Layout}, for vertical manipulation of
  1195. the page size. @xref{Line Layout}, for horizontal changes.
  1196. A default paper size can be set in the device's @file{DESC} file. Most
  1197. output devices also have a command line option @option{-p} to override
  1198. the default paper size and option @option{-l} to use landscape
  1199. orientation. @xref{DESC File Format}, for a description of the
  1200. @code{papersize} keyword which takes the same argument as @option{-p}.
  1201. @pindex papersize.tmac
  1202. @pindex troffrc
  1203. A convenient shorthand to set a particular paper size for @code{gtroff}
  1204. is command line option @option{-dpaper=@var{size}}. This defines string
  1205. @code{paper} which is processed in file @file{papersize.tmac} (loaded in
  1206. the start-up file @file{troffrc} by default). Possible values for
  1207. @var{size} are the same as the predefined values for the
  1208. @code{papersize} keyword (but only in lowercase) except
  1209. @code{a7}-@code{d7}. An appended @samp{l} (ell) character denotes
  1210. landscape orientation.
  1211. For example, use the following for PS output on A4 paper in landscape
  1212. orientation:
  1213. @Example
  1214. groff -Tps -dpaper=a4l -P-pa4 -P-l -ms foo.ms > foo.ps
  1215. @endExample
  1216. Note that it is up to the particular macro package to respect default
  1217. page dimensions set in this way (most do).
  1218. @c =====================================================================
  1219. @node Invocation Examples, , Paper Size, Invoking groff
  1220. @section Invocation Examples
  1221. @cindex invocation examples
  1222. @cindex examples of invocation
  1223. This section lists several common uses of @code{groff} and the
  1224. corresponding command lines.
  1225. @Example
  1226. groff file
  1227. @endExample
  1228. @noindent
  1229. This command processes @file{file} without a macro package or a
  1230. preprocessor. The output device is the default, @samp{ps}, and the
  1231. output is sent to @code{stdout}.
  1232. @Example
  1233. groff -t -mandoc -Tascii file | less
  1234. @endExample
  1235. @noindent
  1236. This is basically what a call to the @code{man} program does.
  1237. @code{gtroff} processes the manual page @file{file} with the
  1238. @file{mandoc} macro file (which in turn either calls the @file{man} or
  1239. the @file{mdoc} macro package), using the @code{tbl} preprocessor and
  1240. the @acronym{ASCII} output device. Finally, the @code{less} pager
  1241. displays the result.
  1242. @Example
  1243. groff -X -m me file
  1244. @endExample
  1245. @noindent
  1246. Preview @file{file} with @code{gxditview}, using the @file{me} macro
  1247. package. Since no @option{-T} option is specified, use the default
  1248. device (@samp{ps}). Note that you can either say @w{@samp{-m me}} or
  1249. @w{@samp{-me}}; the latter is an anachronism from the early days of
  1250. @acronym{UNIX}.@footnote{The same is true for the other main macro
  1251. packages that come with @code{groff}: @file{man}, @file{mdoc},
  1252. @file{ms}, @file{mm}, and @file{mandoc}. This won't work in general;
  1253. for example, to load @file{trace.tmac}, either @samp{-mtrace} or
  1254. @w{@samp{-m trace}} must be used.}
  1255. @Example
  1256. groff -man -rD1 -z file
  1257. @endExample
  1258. @noindent
  1259. Check @file{file} with the @file{man} macro package, forcing
  1260. double-sided printing -- don't produce any output.
  1261. @menu
  1262. * grog::
  1263. @end menu
  1264. @c ---------------------------------------------------------------------
  1265. @node grog, , Invocation Examples, Invocation Examples
  1266. @subsection @code{grog}
  1267. @pindex grog
  1268. @code{grog} reads files, guesses which of the @code{groff} preprocessors
  1269. and/or macro packages are required for formatting them, and prints the
  1270. @code{groff} command including those options on the standard output. It
  1271. generates one or more of the options @option{-e}, @option{-man},
  1272. @option{-me}, @option{-mm}, @option{-mom}, @option{-ms}, @option{-mdoc},
  1273. @option{-mdoc-old}, @option{-p}, @option{-R}, @option{-g}, @option{-G},
  1274. @option{-s}, and @option{-t}.
  1275. A special file name@tie{}@file{-} refers to the standard input. Specifying
  1276. no files also means to read the standard input. Any specified options
  1277. are included in the printed command. No space is allowed between
  1278. options and their arguments. The only options recognized are
  1279. @option{-C} (which is also passed on) to enable compatibility mode, and
  1280. @option{-v} to print the version number and exit.
  1281. For example,
  1282. @Example
  1283. grog -Tdvi paper.ms
  1284. @endExample
  1285. @noindent
  1286. guesses the appropriate command to print @file{paper.ms} and then prints
  1287. it to the command line after adding the @option{-Tdvi} option. For
  1288. direct execution, enclose the call to @code{grog} in backquotes at the
  1289. @acronym{UNIX} shell prompt:
  1290. @Example
  1291. `grog -Tdvi paper.ms` > paper.dvi
  1292. @endExample
  1293. @noindent
  1294. As seen in the example, it is still necessary to redirect the output to
  1295. something meaningful (i.e.@: either a file or a pager program like
  1296. @code{less}).
  1297. @c =====================================================================
  1298. @c =====================================================================
  1299. @node Tutorial for Macro Users, Macro Packages, Invoking groff, Top
  1300. @chapter Tutorial for Macro Users
  1301. @cindex tutorial for macro users
  1302. @cindex macros, tutorial for users
  1303. @cindex user's tutorial for macros
  1304. @cindex user's macro tutorial
  1305. Most users tend to use a macro package to format their papers. This
  1306. means that the whole breadth of @code{groff} is not necessary for most
  1307. people. This chapter covers the material needed to efficiently use a
  1308. macro package.
  1309. @menu
  1310. * Basics::
  1311. * Common Features::
  1312. @end menu
  1313. @c =====================================================================
  1314. @node Basics, Common Features, Tutorial for Macro Users, Tutorial for Macro Users
  1315. @section Basics
  1316. @cindex basics of macros
  1317. @cindex macro basics
  1318. This section covers some of the basic concepts necessary to understand
  1319. how to use a macro package.@footnote{This section is derived from
  1320. @cite{Writing Papers with nroff using -me} by Eric P.@tie{}Allman.}
  1321. References are made throughout to more detailed information, if desired.
  1322. @code{gtroff} reads an input file prepared by the user and outputs a
  1323. formatted document suitable for publication or framing. The input
  1324. consists of text, or words to be printed, and embedded commands
  1325. (@dfn{requests} and @dfn{escapes}), which tell @code{gtroff} how to
  1326. format the output. For more detail on this, see @ref{Embedded
  1327. Commands}.
  1328. The word @dfn{argument} is used in this chapter to mean a word or number
  1329. which appears on the same line as a request, and which modifies the
  1330. meaning of that request. For example, the request
  1331. @Example
  1332. .sp
  1333. @endExample
  1334. @noindent
  1335. spaces one line, but
  1336. @Example
  1337. .sp 4
  1338. @endExample
  1339. @noindent
  1340. spaces four lines. The number@tie{}4 is an argument to the @code{sp}
  1341. request which says to space four lines instead of one. Arguments are
  1342. separated from the request and from each other by spaces (@emph{no}
  1343. tabs). More details on this can be found in @ref{Request and Macro
  1344. Arguments}.
  1345. The primary function of @code{gtroff} is to collect words from input
  1346. lines, fill output lines with those words, justify the right-hand margin
  1347. by inserting extra spaces in the line, and output the result. For
  1348. example, the input:
  1349. @Example
  1350. Now is the time
  1351. for all good men
  1352. to come to the aid
  1353. of their party.
  1354. Four score and seven
  1355. years ago, etc.
  1356. @endExample
  1357. @noindent
  1358. is read, packed onto output lines, and justified to produce:
  1359. @quotation
  1360. Now is the time for all good men to come to the aid of their party.
  1361. Four score and seven years ago, etc.
  1362. @end quotation
  1363. @cindex break
  1364. @cindex line break
  1365. Sometimes a new output line should be started even though the current
  1366. line is not yet full; for example, at the end of a paragraph. To do
  1367. this it is possible to cause a @dfn{break}, which starts a new output
  1368. line. Some requests cause a break automatically, as normally do blank
  1369. input lines and input lines beginning with a space.
  1370. Not all input lines are text to be formatted. Some input lines are
  1371. requests which describe how to format the text. Requests always have a
  1372. period (@samp{.}) or an apostrophe (@samp{'}) as the first character of
  1373. the input line.
  1374. The text formatter also does more complex things, such as automatically
  1375. numbering pages, skipping over page boundaries, putting footnotes in the
  1376. correct place, and so forth.
  1377. Here are a few hints for preparing text for input to @code{gtroff}.
  1378. @itemize @bullet
  1379. @item
  1380. First, keep the input lines short. Short input lines are easier to
  1381. edit, and @code{gtroff} packs words onto longer lines anyhow.
  1382. @item
  1383. In keeping with this, it is helpful to begin a new line after every
  1384. comma or phrase, since common corrections are to add or delete sentences
  1385. or phrases.
  1386. @item
  1387. End each sentence with two spaces -- or better, start each sentence on a
  1388. new line. @code{gtroff} recognizes characters that usually end a
  1389. sentence, and inserts sentence space accordingly.
  1390. @item
  1391. Do not hyphenate words at the end of lines -- @code{gtroff} is smart
  1392. enough to hyphenate words as needed, but is not smart enough to take
  1393. hyphens out and join a word back together. Also, words such as
  1394. ``mother-in-law'' should not be broken over a line, since then a space
  1395. can occur where not wanted, such as ``@w{mother- in}-law''.
  1396. @end itemize
  1397. @cindex double-spacing (@code{ls})
  1398. @cindex spacing
  1399. @code{gtroff} double-spaces output text automatically if you use the
  1400. request @w{@samp{.ls 2}}. Reactivate single-spaced mode by typing
  1401. @w{@samp{.ls 1}}.@footnote{If you need finer granularity of the
  1402. vertical space, use the @code{pvs} request (@pxref{Changing Type
  1403. Sizes}).}
  1404. A number of requests allow to change the way the output looks,
  1405. sometimes called the @dfn{layout} of the output page. Most of these
  1406. requests adjust the placing of @dfn{whitespace} (blank lines or
  1407. spaces).
  1408. @cindex new page (@code{bp})
  1409. The @code{bp} request starts a new page, causing a line break.
  1410. @cindex blank line (@code{sp})
  1411. @cindex empty line (@code{sp})
  1412. @cindex line, empty (@code{sp})
  1413. The request @w{@samp{.sp @var{N}}} leaves @var{N}@tie{}lines of blank
  1414. space. @var{N}@tie{}can be omitted (meaning skip a single line) or can
  1415. be of the form @var{N}i (for @var{N}@tie{}inches) or @var{N}c (for
  1416. @var{N}@tie{}centimeters). For example, the input:
  1417. @Example
  1418. .sp 1.5i
  1419. My thoughts on the subject
  1420. .sp
  1421. @endExample
  1422. @noindent
  1423. leaves one and a half inches of space, followed by the line ``My
  1424. thoughts on the subject'', followed by a single blank line (more
  1425. measurement units are available, see @ref{Measurements}).
  1426. @cindex centering lines (@code{ce})
  1427. @cindex lines, centering (@code{ce})
  1428. Text lines can be centered by using the @code{ce} request. The line
  1429. after @code{ce} is centered (horizontally) on the page. To center more
  1430. than one line, use @w{@samp{.ce @var{N}}} (where @var{N} is the number
  1431. of lines to center), followed by the @var{N}@tie{}lines. To center many
  1432. lines without counting them, type:
  1433. @Example
  1434. .ce 1000
  1435. lines to center
  1436. .ce 0
  1437. @endExample
  1438. @noindent
  1439. The @w{@samp{.ce 0}} request tells @code{groff} to center zero more
  1440. lines, in other words, stop centering.
  1441. @cindex line break (@code{br})
  1442. @cindex break (@code{br})
  1443. All of these requests cause a break; that is, they always start a new
  1444. line. To start a new line without performing any other action, use
  1445. @code{br}.
  1446. @c =====================================================================
  1447. @node Common Features, , Basics, Tutorial for Macro Users
  1448. @section Common Features
  1449. @cindex common features
  1450. @cindex features, common
  1451. @code{gtroff} provides very low-level operations for formatting a
  1452. document. There are many common routine operations which are done in
  1453. all documents. These common operations are written into @dfn{macros}
  1454. and collected into a @dfn{macro package}.
  1455. All macro packages provide certain common capabilities which fall into
  1456. the following categories.
  1457. @menu
  1458. * Paragraphs::
  1459. * Sections and Chapters::
  1460. * Headers and Footers::
  1461. * Page Layout Adjustment::
  1462. * Displays::
  1463. * Footnotes and Annotations::
  1464. * Table of Contents::
  1465. * Indices::
  1466. * Paper Formats::
  1467. * Multiple Columns::
  1468. * Font and Size Changes::
  1469. * Predefined Strings::
  1470. * Preprocessor Support::
  1471. * Configuration and Customization::
  1472. @end menu
  1473. @c ---------------------------------------------------------------------
  1474. @node Paragraphs, Sections and Chapters, Common Features, Common Features
  1475. @subsection Paragraphs
  1476. @cindex paragraphs
  1477. One of the most common and most used capability is starting a
  1478. paragraph. There are a number of different types of paragraphs, any
  1479. of which can be initiated with macros supplied by the macro package.
  1480. Normally, paragraphs start with a blank line and the first line
  1481. indented, like the text in this manual. There are also block style
  1482. paragraphs, which omit the indentation:
  1483. @Example
  1484. Some men look at constitutions with sanctimonious
  1485. reverence, and deem them like the ark of the covenant, too
  1486. sacred to be touched.
  1487. @endExample
  1488. @noindent
  1489. And there are also indented paragraphs which begin with a tag or label
  1490. at the margin and the remaining text indented.
  1491. @Example
  1492. one This is the first paragraph. Notice how the first
  1493. line of the resulting paragraph lines up with the
  1494. other lines in the paragraph.
  1495. @endExample
  1496. @Example
  1497. longlabel
  1498. This paragraph had a long label. The first
  1499. character of text on the first line does not line up
  1500. with the text on second and subsequent lines,
  1501. although they line up with each other.
  1502. @endExample
  1503. A variation of this is a bulleted list.
  1504. @Example
  1505. . Bulleted lists start with a bullet. It is possible
  1506. to use other glyphs instead of the bullet. In nroff
  1507. mode using the ASCII character set for output, a dot
  1508. is used instead of a real bullet.
  1509. @endExample
  1510. @c ---------------------------------------------------------------------
  1511. @node Sections and Chapters, Headers and Footers, Paragraphs, Common Features
  1512. @subsection Sections and Chapters
  1513. Most macro packages supply some form of section headers. The simplest
  1514. kind is simply the heading on a line by itself in bold type. Others
  1515. supply automatically numbered section heading or different heading
  1516. styles at different levels. Some, more sophisticated, macro packages
  1517. supply macros for starting chapters and appendices.
  1518. @c ---------------------------------------------------------------------
  1519. @node Headers and Footers, Page Layout Adjustment, Sections and Chapters, Common Features
  1520. @subsection Headers and Footers
  1521. Every macro package gives some way to manipulate the @dfn{headers} and
  1522. @dfn{footers} (also called @dfn{titles}) on each page. This is text
  1523. put at the top and bottom of each page, respectively, which contain
  1524. data like the current page number, the current chapter title, and so
  1525. on. Its appearance is not affected by the running text. Some packages
  1526. allow for different ones on the even and odd pages (for material printed
  1527. in a book form).
  1528. The titles are called @dfn{three-part titles}, that is, there is a
  1529. left-justified part, a centered part, and a right-justified part. An
  1530. automatically generated page number may be put in any of these fields
  1531. with the @samp{%} character (see @ref{Page Layout}, for more details).
  1532. @c ---------------------------------------------------------------------
  1533. @node Page Layout Adjustment, Displays, Headers and Footers, Common Features
  1534. @subsection Page Layout
  1535. Most macro packages let the user specify top and bottom margins and
  1536. other details about the appearance of the printed pages.
  1537. @c ---------------------------------------------------------------------
  1538. @node Displays, Footnotes and Annotations, Page Layout Adjustment, Common Features
  1539. @subsection Displays
  1540. @cindex displays
  1541. @dfn{Displays} are sections of text to be set off from the body of
  1542. the paper. Major quotes, tables, and figures are types of displays, as
  1543. are all the examples used in this document.
  1544. @cindex quotes, major
  1545. @cindex major quotes
  1546. @dfn{Major quotes} are quotes which are several lines long, and hence
  1547. are set in from the rest of the text without quote marks around them.
  1548. @cindex list
  1549. A @dfn{list} is an indented, single-spaced, unfilled display. Lists
  1550. should be used when the material to be printed should not be filled and
  1551. justified like normal text, such as columns of figures or the examples
  1552. used in this paper.
  1553. @cindex keep
  1554. A @dfn{keep} is a display of lines which are kept on a single page if
  1555. possible. An example for a keep might be a diagram. Keeps differ from
  1556. lists in that lists may be broken over a page boundary whereas keeps are
  1557. not.
  1558. @cindex keep, floating
  1559. @cindex floating keep
  1560. @dfn{Floating keeps} move relative to the text. Hence, they are good for
  1561. things which are referred to by name, such as ``See figure@tie{}3''. A
  1562. floating keep appears at the bottom of the current page if it fits;
  1563. otherwise, it appears at the top of the next page. Meanwhile, the
  1564. surrounding text `flows' around the keep, thus leaving no blank areas.
  1565. @c ---------------------------------------------------------------------
  1566. @node Footnotes and Annotations, Table of Contents, Displays, Common Features
  1567. @subsection Footnotes and Annotations
  1568. @cindex footnotes
  1569. @cindex annotations
  1570. There are a number of requests to save text for later printing.
  1571. @dfn{Footnotes} are printed at the bottom of the current page.
  1572. @cindex delayed text
  1573. @dfn{Delayed text} is very similar to a footnote except that it is
  1574. printed when called for explicitly. This allows a list of references to
  1575. appear (for example) at the end of each chapter, as is the convention in
  1576. some disciplines.
  1577. Most macro packages which supply this functionality also supply a means
  1578. of automatically numbering either type of annotation.
  1579. @c ---------------------------------------------------------------------
  1580. @node Table of Contents, Indices, Footnotes and Annotations, Common Features
  1581. @subsection Table of Contents
  1582. @cindex table of contents
  1583. @cindex contents, table of
  1584. @dfn{Tables of contents} are a type of delayed text having a tag
  1585. (usually the page number) attached to each entry after a row of dots.
  1586. The table accumulates throughout the paper until printed, usually after
  1587. the paper has ended. Many macro packages provide the ability to have
  1588. several tables of contents (e.g.@: a standard table of contents, a list
  1589. of tables, etc).
  1590. @c ---------------------------------------------------------------------
  1591. @node Indices, Paper Formats, Table of Contents, Common Features
  1592. @subsection Indices
  1593. @cindex index, in macro package
  1594. While some macro packages use the term @dfn{index}, none actually
  1595. provide that functionality. The facilities they call indices are
  1596. actually more appropriate for tables of contents.
  1597. @pindex makeindex
  1598. To produce a real index in a document, external tools like the
  1599. @code{makeindex} program are necessary.
  1600. @c ---------------------------------------------------------------------
  1601. @node Paper Formats, Multiple Columns, Indices, Common Features
  1602. @subsection Paper Formats
  1603. @cindex paper formats
  1604. Some macro packages provide stock formats for various kinds of
  1605. documents. Many of them provide a common format for the title and
  1606. opening pages of a technical paper. The @file{mm} macros in particular
  1607. provide formats for letters and memoranda.
  1608. @c ---------------------------------------------------------------------
  1609. @node Multiple Columns, Font and Size Changes, Paper Formats, Common Features
  1610. @subsection Multiple Columns
  1611. Some macro packages (but not @file{man}) provide the ability to have two
  1612. or more columns on a page.
  1613. @c ---------------------------------------------------------------------
  1614. @node Font and Size Changes, Predefined Strings, Multiple Columns, Common Features
  1615. @subsection Font and Size Changes
  1616. The built-in font and size functions are not always intuitive, so all
  1617. macro packages provide macros to make these operations simpler.
  1618. @c ---------------------------------------------------------------------
  1619. @node Predefined Strings, Preprocessor Support, Font and Size Changes, Common Features
  1620. @subsection Predefined Strings
  1621. Most macro packages provide various predefined strings for a variety of
  1622. uses; examples are sub- and superscripts, printable dates, quotes and
  1623. various special characters.
  1624. @c ---------------------------------------------------------------------
  1625. @node Preprocessor Support, Configuration and Customization, Predefined Strings, Common Features
  1626. @subsection Preprocessor Support
  1627. All macro packages provide support for various preprocessors and may
  1628. extend their functionality.
  1629. For example, all macro packages mark tables (which are processed with
  1630. @code{gtbl}) by placing them between @code{TS} and @code{TE} macros.
  1631. The @file{ms} macro package has an option, @samp{.TS@tie{}H}, that prints
  1632. a caption at the top of a new page (when the table is too long to fit on
  1633. a single page).
  1634. @c ---------------------------------------------------------------------
  1635. @node Configuration and Customization, , Preprocessor Support, Common Features
  1636. @subsection Configuration and Customization
  1637. Some macro packages provide means of customizing many of the details of
  1638. how the package behaves. This ranges from setting the default type size
  1639. to changing the appearance of section headers.
  1640. @c =====================================================================
  1641. @c =====================================================================
  1642. @node Macro Packages, gtroff Reference, Tutorial for Macro Users, Top
  1643. @chapter Macro Packages
  1644. @cindex macro packages
  1645. @cindex packages, macros
  1646. This chapter documents the main macro packages that come with
  1647. @code{groff}.
  1648. Different main macro packages can't be used at the same time; for example
  1649. @Example
  1650. groff -m man foo.man -m ms bar.doc
  1651. @endExample
  1652. @noindent
  1653. doesn't work. Note that option arguments are processed before non-option
  1654. arguments; the above (failing) sample is thus reordered to
  1655. @Example
  1656. groff -m man -m ms foo.man bar.doc
  1657. @endExample
  1658. @menu
  1659. * man::
  1660. * mdoc::
  1661. * ms::
  1662. * me::
  1663. * mm::
  1664. @end menu
  1665. @c =====================================================================
  1666. @node man, mdoc, Macro Packages, Macro Packages
  1667. @section @file{man}
  1668. @cindex manual pages
  1669. @cindex man pages
  1670. @pindex an.tmac
  1671. @pindex man.tmac
  1672. @pindex man-old.tmac
  1673. This is the most popular and probably the most important macro package
  1674. of @code{groff}. It is easy to use, and a vast majority of manual pages
  1675. are based on it.
  1676. @menu
  1677. * Man options::
  1678. * Man usage::
  1679. * Man font macros::
  1680. * Miscellaneous man macros::
  1681. * Predefined man strings::
  1682. * Preprocessors in man pages::
  1683. * Optional man extensions::
  1684. @end menu
  1685. @c ---------------------------------------------------------------------
  1686. @node Man options, Man usage, man, man
  1687. @subsection Options
  1688. The command line format for using the @file{man} macros with
  1689. @code{groff} is:
  1690. @Example
  1691. groff -m man [ -rLL=@var{length} ] [ -rLT=@var{length} ] [ -rFT=@var{dist} ]
  1692. [ -rcR=1 ] [ -rC1 ] [ -rD1 ] [-rHY=@var{flags} ]
  1693. [ -rP@var{nnn} ] [ -rS@var{xx} ] [ -rX@var{nnn} ]
  1694. [ -rIN=@var{length} ] [ -rSN=@var{length} ] [ @var{files}@dots{} ]
  1695. @endExample
  1696. @noindent
  1697. It is possible to use @samp{-man} instead of @w{@samp{-m man}}.
  1698. @table @code
  1699. @item -rcR=1
  1700. This option (the default if a TTY output device is used) creates a
  1701. single, very long page instead of multiple pages. Use @code{-rcR=0}
  1702. to disable it.
  1703. @item -rC1
  1704. If more than one manual page is given on the command line, number the
  1705. pages continuously, rather than starting each at@tie{}1.
  1706. @item -rD1
  1707. Double-sided printing. Footers for even and odd pages are formatted
  1708. differently.
  1709. @item -rFT=@var{dist}
  1710. Set the position of the footer text to @var{dist}. If positive, the
  1711. distance is measured relative to the top of the page, otherwise it is
  1712. relative to the bottom. The default is @minus{}0.5@dmn{i}.
  1713. @item -rHY=@var{flags}
  1714. Set hyphenation flags. Possible values are 1@tie{}to hyphenate without
  1715. restrictions, 2@tie{} to not hyphenate the last word on a page,
  1716. 4@tie{}to not hyphenate the last two characters of a word, and
  1717. 8@tie{}to not hyphenate the first two characters of a word. These
  1718. values are additive; the default is@tie{}14.
  1719. @item -rIN=@var{length}
  1720. Set the body text indentation to @var{length}.
  1721. If not specified, the indentation defaults to 7@dmn{n}
  1722. (7@tie{}characters) in nroff mode and 7.2@dmn{n} otherwise.
  1723. For nroff, this value should always be an integer multiple of unit @samp{n}
  1724. to get consistent indentation.
  1725. @item -rLL=@var{length}
  1726. Set line length to @var{length}. If not specified, the line length
  1727. is set to respect any value set by a prior @samp{ll} request (which
  1728. @emph{must} be in effect when the @samp{TH} macro is invoked), if
  1729. this differs from the built-in default for the formatter; otherwise it
  1730. defaults to 78@dmn{n} in nroff mode (this is 78 characters per
  1731. line) and 6.5@dmn{i} in troff mode.@footnote{Note that the use of
  1732. a @samp{.ll @var{length}} request to initialize the line length, prior
  1733. to use of the @samp{TH} macro, is supported for backward compatibility
  1734. with some versions of the @code{man} program. @emph{Always} use the
  1735. @option{-rLL=@var{length}} option, or an equivalent @samp{.nr LL @var{length}}
  1736. request, in preference to such a @samp{.ll @var{length}} request.
  1737. In particular, note that in nroff mode, the request @samp{.ll 65n},
  1738. (with any @var{length} expression which evaluates equal to 65@dmn{n},
  1739. i.e., the formatter's default line length in nroff mode), will @emph{not}
  1740. set the line length to 65@dmn{n} (it will be adjusted to the @code{man}
  1741. macro package's default setting of 78@dmn{n}), whereas the use of the
  1742. @option{-rLL=65n} option, or the @samp{.nr LL 65n}
  1743. request @emph{will} establish a line length of 65@dmn{n}.}
  1744. @item -rLT=@var{length}
  1745. Set title length to @var{length}. If not specified, the title length
  1746. defaults to the line length.
  1747. @item -rP@var{nnn}
  1748. Page numbering starts with @var{nnn} rather than with@tie{}1.
  1749. @item -rS@var{xx}
  1750. Use @var{xx} (which can be 10, 11, or@tie{}12@dmn{pt}) as the base
  1751. document font size instead of the default value of@tie{}10@dmn{pt}.
  1752. @item -rSN=@var{length}
  1753. Set the indentation for sub-subheadings to @var{length}.
  1754. If not specified, the indentation defaults to 3@dmn{n}.
  1755. @item -rX@var{nnn}
  1756. After page @var{nnn}, number pages as @var{nnn}a, @var{nnn}b,
  1757. @var{nnn}c, etc. For example, the option @option{-rX2} produces the
  1758. following page numbers: 1, 2, 2a, 2b, 2c, etc.
  1759. @end table
  1760. @c ---------------------------------------------------------------------
  1761. @node Man usage, Man font macros, Man options, man
  1762. @subsection Usage
  1763. @cindex @code{man} macros
  1764. @cindex macros for manual pages [@code{man}]
  1765. @pindex man.local
  1766. This section describes the available macros for manual pages. For
  1767. further customization, put additional macros and requests into the file
  1768. @file{man.local} which is loaded immediately after the @file{man}
  1769. package.
  1770. @Defmac {TH, title section [@Var{extra1} [@Var{extra2} [@Var{extra3}]]], man}
  1771. Set the title of the man page to @var{title} and the section to
  1772. @var{section}, which must have a value between 1 and@tie{}8. The value
  1773. of @var{section} may also have a string appended, e.g.@: @samp{.pm},
  1774. to indicate a specific subsection of the man pages.
  1775. Both @var{title} and @var{section} are positioned at the left and right
  1776. in the header line (with @var{section} in parentheses immediately
  1777. appended to @var{title}. @var{extra1} is positioned in the middle of
  1778. the footer line. @var{extra2} is positioned at the left in the footer
  1779. line (or at the left on even pages and at the right on odd pages if
  1780. double-sided printing is active). @var{extra3} is centered in the
  1781. header line.
  1782. For @acronym{HTML} output, headers and footers are completely suppressed.
  1783. Additionally, this macro starts a new page; the new line number is@tie{}1
  1784. again (except if the @option{-rC1} option is given on the command line)
  1785. -- this feature is intended only for formatting multiple man pages; a
  1786. single man page should contain exactly one @code{TH} macro at the
  1787. beginning of the file.
  1788. @endDefmac
  1789. @Defmac {SH, [@Var{heading}], man}
  1790. Set up an unnumbered section heading sticking out to the left. Prints
  1791. out all the text following @code{SH} up to the end of the line (or the
  1792. text in the next line if there is no argument to @code{SH}) in bold
  1793. face (or the font specified by the string @code{HF}), one size larger than
  1794. the base document size. Additionally, the left margin and the indentation
  1795. for the following text is reset to its default value.
  1796. @endDefmac
  1797. @Defmac {SS, [@Var{heading}], man}
  1798. Set up an unnumbered (sub)section heading. Prints out all the text
  1799. following @code{SS} up to the end of the line (or the text in the next
  1800. line if there is no argument to @code{SS}) in bold face (or the font
  1801. specified by the string @code{HF}), at the same size as the base document
  1802. size. Additionally, the left margin and the indentation for the
  1803. following text is reset to its default value.
  1804. @endDefmac
  1805. @Defmac {TP, [@Var{nnn}], man}
  1806. Set up an indented paragraph with label. The indentation is set to
  1807. @var{nnn} if that argument is supplied (the default unit is @samp{n}
  1808. if omitted), otherwise it is set to the previous indentation value
  1809. specified with @code{TP}, @code{IP}, or @code{HP} (or to the default
  1810. value if none of them have been used yet).
  1811. The first line of text following this macro is interpreted as a string
  1812. to be printed flush-left, as it is appropriate for a label. It is not
  1813. interpreted as part of a paragraph, so there is no attempt to fill the
  1814. first line with text from the following input lines. Nevertheless, if
  1815. the label is not as wide as the indentation the paragraph starts
  1816. at the same line (but indented), continuing on the following lines.
  1817. If the label is wider than the indentation the descriptive part
  1818. of the paragraph begins on the line following the label, entirely
  1819. indented. Note that neither font shape nor font size of the label is
  1820. set to a default value; on the other hand, the rest of the text has
  1821. default font settings.
  1822. @endDefmac
  1823. @DefmacList {LP, , man}
  1824. @DefmacItem {PP, , man}
  1825. @DefmacListEnd {P, , man}
  1826. These macros are mutual aliases. Any of them causes a line break at
  1827. the current position, followed by a vertical space downwards by the
  1828. amount specified by the @code{PD} macro. The font size and shape are
  1829. reset to the default value (10@dmn{pt} roman if no @option{-rS} option
  1830. is given on the command line). Finally, the current left margin and the
  1831. indentation is restored.
  1832. @endDefmac
  1833. @Defmac {IP, [@Var{designator} [@Var{nnn}]], man}
  1834. Set up an indented paragraph, using @var{designator} as a tag to mark
  1835. its beginning. The indentation is set to @var{nnn} if that argument
  1836. is supplied (default unit is @samp{n}), otherwise it is set to the
  1837. previous indentation value specified with @code{TP}, @code{IP}, or
  1838. @code{HP} (or the default value if none of them have been used yet).
  1839. Font size and face of the paragraph (but not the designator) are reset
  1840. to their default values.
  1841. To start an indented paragraph with a particular indentation but without
  1842. a designator, use @samp{""} (two double quotes) as the first argument of
  1843. @code{IP}.
  1844. For example, to start a paragraph with bullets as the designator and
  1845. 4@tie{}en indentation, write
  1846. @Example
  1847. .IP \(bu 4
  1848. @endExample
  1849. @endDefmac
  1850. @Defmac {HP, [@Var{nnn}], man}
  1851. @cindex hanging indentation [@code{man}]
  1852. @cindex @code{man} macros, hanging indentation
  1853. Set up a paragraph with hanging left indentation. The indentation is
  1854. set to @var{nnn} if that argument is supplied (default unit is
  1855. @samp{n}), otherwise it is set to the previous indentation value
  1856. specified with @code{TP}, @code{IP}, or @code{HP} (or the default
  1857. value if non of them have been used yet). Font size and face are reset
  1858. to their default values.
  1859. @endDefmac
  1860. @Defmac {RS, [@Var{nnn}], man}
  1861. @cindex left margin, how to move [@code{man}]
  1862. @cindex @code{man} macros, moving left margin
  1863. Move the left margin to the right by the value @var{nnn} if specified
  1864. (default unit is @samp{n}); otherwise it is set to the previous
  1865. indentation value specified with @code{TP}, @code{IP}, or @code{HP}
  1866. (or to the default value if none of them have been used yet). The
  1867. indentation value is then set to the default.
  1868. Calls to the @code{RS} macro can be nested.
  1869. @endDefmac
  1870. @Defmac {RE, [@Var{nnn}], man}
  1871. Move the left margin back to level @var{nnn}, restoring the previous left
  1872. margin. If no argument is given, it moves one level back. The first
  1873. level (i.e., no call to @code{RS} yet) has number@tie{}1, and each call
  1874. to @code{RS} increases the level by@tie{}1.
  1875. @endDefmac
  1876. @cindex line breaks, with vertical space [@code{man}]
  1877. @cindex @code{man} macros, line breaks with vertical space
  1878. To summarize, the following macros cause a line break with the insertion
  1879. of vertical space (which amount can be changed with the @code{PD}
  1880. macro): @code{SH}, @code{SS}, @code{TP}, @code{LP} (@code{PP},
  1881. @code{P}), @code{IP}, and @code{HP}.
  1882. @cindex line breaks, without vertical space [@code{man}]
  1883. @cindex @code{man} macros, line breaks without vertical space
  1884. The macros @code{RS} and @code{RE} also cause a break but do not insert
  1885. vertical space.
  1886. @cindex default indentation, resetting [@code{man}]
  1887. @cindex indentaion, resetting to default [@code{man}]
  1888. @cindex @code{man} macros, resetting default indentation
  1889. Finally, the macros @code{SH}, @code{SS}, @code{LP} (@code{PP}, @code{P}),
  1890. and @code{RS} reset the indentation to its default value.
  1891. @c ---------------------------------------------------------------------
  1892. @node Man font macros, Miscellaneous man macros, Man usage, man
  1893. @subsection Macros to set fonts
  1894. @cindex font selection [@code{man}]
  1895. @cindex @code{man} macros, how to set fonts
  1896. The standard font is roman; the default text size is 10@tie{}point.
  1897. If command line option @option{-rS=@var{n}} is given, use
  1898. @var{n}@dmn{pt} as the default text size.
  1899. @Defmac {SM, [@Var{text}], man}
  1900. Set the text on the same line or the text on the next line in a font
  1901. that is one point size smaller than the default font.
  1902. @endDefmac
  1903. @Defmac {SB, [@Var{text}], man}
  1904. @cindex bold face [@code{man}]
  1905. @cindex @code{man} macros, bold face
  1906. Set the text on the same line or the text on the next line in bold face
  1907. font, one point size smaller than the default font.
  1908. @endDefmac
  1909. @Defmac {BI, text, man}
  1910. Set its arguments alternately in bold face and italic, without a space
  1911. between the arguments. Thus,
  1912. @Example
  1913. .BI this "word and" that
  1914. @endExample
  1915. @noindent
  1916. produces ``thisword andthat'' with ``this'' and ``that'' in bold face,
  1917. and ``word and'' in italics.
  1918. @endDefmac
  1919. @Defmac {IB, text, man}
  1920. Set its arguments alternately in italic and bold face, without a space
  1921. between the arguments.
  1922. @endDefmac
  1923. @Defmac {RI, text, man}
  1924. Set its arguments alternately in roman and italic, without a space between
  1925. the arguments.
  1926. @endDefmac
  1927. @Defmac {IR, text, man}
  1928. Set its arguments alternately in italic and roman, without a space between
  1929. the arguments.
  1930. @endDefmac
  1931. @Defmac {BR, text, man}
  1932. Set its arguments alternately in bold face and roman, without a space
  1933. between the arguments.
  1934. @endDefmac
  1935. @Defmac {RB, text, man}
  1936. Set its arguments alternately in roman and bold face, without a space
  1937. between the arguments.
  1938. @endDefmac
  1939. @Defmac {B, [@Var{text}], man}
  1940. Set @var{text} in bold face. If no text is present on the line where
  1941. the macro is called, then the text of the next line appears in bold
  1942. face.
  1943. @endDefmac
  1944. @Defmac {I, [@Var{text}], man}
  1945. @cindex italic fonts [@code{man}]
  1946. @cindex @code{man} macros, italic fonts
  1947. Set @var{text} in italic. If no text is present on the line where the
  1948. macro is called, then the text of the next line appears in italic.
  1949. @endDefmac
  1950. @c ---------------------------------------------------------------------
  1951. @node Miscellaneous man macros, Predefined man strings, Man font macros, man
  1952. @subsection Miscellaneous macros
  1953. @pindex grohtml
  1954. @cindex @code{man} macros, default indentation
  1955. @cindex default indentation [@code{man}]
  1956. The default indentation is 7.2@dmn{n} in troff mode and 7@dmn{n} in
  1957. nroff mode except for @code{grohtml} which ignores indentation.
  1958. @Defmac {DT, , man}
  1959. @cindex tab stops [@code{man}]
  1960. @cindex @code{man} macros, tab stops
  1961. Set tabs every 0.5@tie{}inches. Since this macro is always executed
  1962. during a call to the @code{TH} macro, it makes sense to call it only if
  1963. the tab positions have been changed.
  1964. @endDefmac
  1965. @Defmac {PD, [@Var{nnn}], man}
  1966. @cindex empty space before a paragraph [@code{man}]
  1967. @cindex @code{man} macros, empty space before a paragraph
  1968. Adjust the empty space before a new paragraph (or section). The
  1969. optional argument gives the amount of space (default unit is
  1970. @samp{v}); without parameter, the value is reset to its default value
  1971. (1@tie{}line in nroff mode, 0.4@dmn{v}@tie{}otherwise).
  1972. This affects the macros @code{SH}, @code{SS}, @code{TP}, @code{LP} (as
  1973. well as @code{PP} and @code{P}), @code{IP}, and @code{HP}.
  1974. @endDefmac
  1975. The following two macros are included for
  1976. BSD compatibility.
  1977. @Defmac {AT, [@Var{system} [@Var{release}]], man}
  1978. @cindex @code{man}macros, BSD compatibility
  1979. Alter the footer for use with @acronym{AT&T} manpages.
  1980. This command exists only for compatibility; don't use it.
  1981. The first argument @var{system} can be:
  1982. @table @code
  1983. @item 3
  1984. 7th Edition (the default)
  1985. @item 4
  1986. System III
  1987. @item 5
  1988. System V
  1989. @end table
  1990. An optional second argument @var{release} to @code{AT} specifies the
  1991. release number (such as ``System V Release 3'').
  1992. @endDefmac
  1993. @Defmac {UC, [@Var{version}], man}
  1994. @cindex @code{man}macros, BSD compatibility
  1995. Alters the footer for use with @acronym{BSD} manpages.
  1996. This command exists only for compatibility; don't use it.
  1997. The argument can be:
  1998. @table @code
  1999. @item 3
  2000. 3rd Berkeley Distribution (the default)
  2001. @item 4
  2002. 4th Berkeley Distribution
  2003. @item 5
  2004. 4.2 Berkeley Distribution
  2005. @item 6
  2006. 4.3 Berkeley Distribution
  2007. @item 7
  2008. 4.4 Berkeley Distribution
  2009. @end table
  2010. @endDefmac
  2011. @c ---------------------------------------------------------------------
  2012. @node Predefined man strings, Preprocessors in man pages, Miscellaneous man macros, man
  2013. @subsection Predefined strings
  2014. The following strings are defined:
  2015. @Defstr {S, man}
  2016. Switch back to the default font size.
  2017. @endDefstr
  2018. @Defstr {HF, man}
  2019. The typeface used for headings.
  2020. The default is @samp{B}.
  2021. @endDefstr
  2022. @Defstr {R, man}
  2023. The `registered' sign.
  2024. @endDefstr
  2025. @Defstr {Tm, man}
  2026. The `trademark' sign.
  2027. @endDefstr
  2028. @DefstrList {lq, man}
  2029. @DefstrListEnd {rq, man}
  2030. @cindex @code{lq} glyph, and @code{lq} string [@code{man}]
  2031. @cindex @code{rq} glyph, and @code{rq} string [@code{man}]
  2032. Left and right quote. This is equal to @code{\(lq} and @code{\(rq},
  2033. respectively.
  2034. @endDefstr
  2035. @c ---------------------------------------------------------------------
  2036. @node Preprocessors in man pages, Optional man extensions, Predefined man strings, man
  2037. @subsection Preprocessors in @file{man} pages
  2038. @cindex preprocessor, calling convention
  2039. @cindex calling convention of preprocessors
  2040. If a preprocessor like @code{gtbl} or @code{geqn} is needed, it has
  2041. become common usage to make the first line of the man page look like
  2042. this:
  2043. @Example
  2044. '\" @var{word}
  2045. @endExample
  2046. @pindex geqn@r{, invocation in manual pages}
  2047. @pindex grefer@r{, invocation in manual pages}
  2048. @pindex gtbl@r{, invocation in manual pages}
  2049. @pindex man@r{, invocation of preprocessors}
  2050. @noindent
  2051. Note the single space character after the double quote. @var{word}
  2052. consists of letters for the needed preprocessors: @samp{e} for
  2053. @code{geqn}, @samp{r} for @code{grefer}, @samp{t} for @code{gtbl}.
  2054. Modern implementations of the @code{man} program read this first line
  2055. and automatically call the right preprocessor(s).
  2056. @c ---------------------------------------------------------------------
  2057. @node Optional man extensions, , Preprocessors in man pages, man
  2058. @subsection Optional @file{man} extensions
  2059. @pindex man.local
  2060. Use the file @file{man.local} for local extensions
  2061. to the @code{man} macros or for style changes.
  2062. @unnumberedsubsubsec Custom headers and footers
  2063. @cindex @code{man} macros, custom headers and footers
  2064. In groff versions 1.18.2 and later, you can specify custom
  2065. headers and footers by redefining the following macros in
  2066. @file{man.local}.
  2067. @Defmac {PT, , man}
  2068. Control the content of the headers.
  2069. Normally, the header prints the command name
  2070. and section number on either side, and the
  2071. optional fifth argument to @code{TH} in the center.
  2072. @endDefmac
  2073. @Defmac {BT, , man}
  2074. Control the content of the footers.
  2075. Normally, the footer prints the page number
  2076. and the third and fourth arguments to @code{TH}.
  2077. Use the @code{FT} number register to specify the
  2078. footer position.
  2079. The default is @minus{}0.5@dmn{i}.
  2080. @endDefmac
  2081. @unnumberedsubsubsec Ultrix-specific man macros
  2082. @cindex Ultrix-specific @code{man} macros
  2083. @cindex @code{man} macros, Ultrix-specific
  2084. @pindex man.ultrix
  2085. The @code{groff} source distribution includes
  2086. a file named @file{man.ultrix}, containing
  2087. macros compatible with the Ultrix variant of
  2088. @code{man}.
  2089. Copy this file into @file{man.local} (or use the @code{mso} request to
  2090. load it) to enable the following macros.
  2091. @Defmac {CT, @Var{key}, man}
  2092. Print @samp{<CTRL/@var{key}>}.
  2093. @endDefmac
  2094. @Defmac {CW, , man}
  2095. Print subsequent text using the constant width (Courier) typeface.
  2096. @endDefmac
  2097. @Defmac {Ds, , man}
  2098. Begin a non-filled display.
  2099. @endDefmac
  2100. @Defmac {De, , man}
  2101. End a non-filled display started with @code{Ds}.
  2102. @endDefmac
  2103. @Defmac {EX, [@Var{indent}], man}
  2104. Begins a non-filled display
  2105. using the constant width (Courier) typeface.
  2106. Use the optional @var{indent} argument to
  2107. indent the display.
  2108. @endDefmac
  2109. @Defmac {EE, , man}
  2110. End a non-filled display started with @code{EX}.
  2111. @endDefmac
  2112. @Defmac {G, [@Var{text}], man}
  2113. Sets @var{text} in Helvetica.
  2114. If no text is present on the line where
  2115. the macro is called, then the text of the
  2116. next line appears in Helvetica.
  2117. @endDefmac
  2118. @Defmac {GL, [@Var{text}], man}
  2119. Sets @var{text} in Helvetica Oblique.
  2120. If no text is present on the line where
  2121. the macro is called, then the text of the
  2122. next line appears in Helvetica Oblique.
  2123. @endDefmac
  2124. @Defmac {HB, [@Var{text}], man}
  2125. Sets @var{text} in Helvetica Bold.
  2126. If no text is present on the line where
  2127. the macro is called, then all text up to
  2128. the next @code{HB} appears in Helvetica Bold.
  2129. @endDefmac
  2130. @Defmac {TB, [@Var{text}], man}
  2131. Identical to @code{HB}.
  2132. @endDefmac
  2133. @Defmac {MS, @Var{title} @Var{sect} [@Var{punct}], man}
  2134. Set a manpage reference in Ultrix format.
  2135. The @var{title} is in Courier instead of italic.
  2136. Optional punctuation follows the section number without
  2137. an intervening space.
  2138. @endDefmac
  2139. @Defmac {NT, [@code{C}] [@Var{title}], man}
  2140. Begin a note.
  2141. Print the optional @Var{title}, or the word ``Note'',
  2142. centered on the page.
  2143. Text following the macro makes up the body of the note,
  2144. and is indented on both sides.
  2145. If the first argument is @code{C}, the body of the
  2146. note is printed centered (the second argument replaces
  2147. the word ``Note'' if specified).
  2148. @endDefmac
  2149. @Defmac {NE, , man}
  2150. End a note begun with @code{NT}.
  2151. @endDefmac
  2152. @Defmac {PN, @Var{path} [@Var{punct}], man}
  2153. Set the path name in constant width (Courier),
  2154. followed by optional punctuation.
  2155. @endDefmac
  2156. @Defmac {Pn, [@Var{punct}] @Var{path} [@Var{punct}], man}
  2157. When called with two arguments, identical to @code{PN}.
  2158. When called with three arguments,
  2159. set the second argument in constant width (Courier),
  2160. bracketed by the first and third arguments in the current font.
  2161. @endDefmac
  2162. @Defmac {R, , man}
  2163. Switch to roman font and turn off any underlining in effect.
  2164. @endDefmac
  2165. @Defmac {RN, , man}
  2166. Print the string @samp{<RETURN>}.
  2167. @endDefmac
  2168. @Defmac {VS, [@code{4}], man}
  2169. Start printing a change bar in the margin if
  2170. the number @code{4} is specified.
  2171. Otherwise, this macro does nothing.
  2172. @endDefmac
  2173. @Defmac {VE, , man}
  2174. End printing the change bar begun by @code{VS}.
  2175. @endDefmac
  2176. @unnumberedsubsubsec Simple example
  2177. The following example @file{man.local} file
  2178. alters the @code{SH} macro to add some extra
  2179. vertical space before printing the heading.
  2180. Headings are printed in Helvetica Bold.
  2181. @Example
  2182. .\" Make the heading fonts Helvetica
  2183. .ds HF HB
  2184. .
  2185. .\" Put more whitespace in front of headings.
  2186. .rn SH SH-orig
  2187. .de SH
  2188. . if t .sp (u;\\n[PD]*2)
  2189. . SH-orig \\$*
  2190. ..
  2191. @endExample
  2192. @c =====================================================================
  2193. @node mdoc, ms, man, Macro Packages
  2194. @section @file{mdoc}
  2195. @cindex @code{mdoc} macros
  2196. @c XXX documentation
  2197. @c XXX this is a placeholder until we get stuff knocked into shape
  2198. See the @cite{groff_mdoc(7)} man page (type @command{man groff_mdoc}
  2199. at the command line).
  2200. @c =====================================================================
  2201. @node ms, me, mdoc, Macro Packages
  2202. @section @file{ms}
  2203. @cindex @code{ms} macros
  2204. The @file{-ms} macros are suitable for reports, letters, books, user
  2205. manuals, and so forth. The package provides macros for cover pages,
  2206. section headings, paragraphs, lists, footnotes, pagination, and a
  2207. table of contents.
  2208. @menu
  2209. * ms Intro::
  2210. * General ms Structure::
  2211. * ms Document Control Registers::
  2212. * ms Cover Page Macros::
  2213. * ms Body Text::
  2214. * ms Page Layout::
  2215. * Differences from AT&T ms::
  2216. * Naming Conventions::
  2217. @end menu
  2218. @c ---------------------------------------------------------------------
  2219. @node ms Intro, General ms Structure, ms, ms
  2220. @subsection Introduction to @file{ms}
  2221. The original @file{-ms} macros were included with @acronym{AT&T}
  2222. @code{troff} as well as the @file{man} macros. While the @file{man}
  2223. package is intended for brief documents that can be read on-line as
  2224. well as printed, the @file{ms} macros are suitable for longer
  2225. documents that are meant to be printed rather than read on-line.
  2226. The @file{ms} macro package included with @code{groff} is a complete,
  2227. bottom-up re-implementation. Several macros (specific to
  2228. @acronym{AT&T} or Berkeley) are not included, while several new
  2229. commands are. @xref{Differences from AT&T ms}, for more information.
  2230. @c ---------------------------------------------------------------------
  2231. @node General ms Structure, ms Document Control Registers, ms Intro, ms
  2232. @subsection General structure of an @file{ms} document
  2233. @cindex @code{ms} macros, general structure
  2234. The @file{ms} macro package expects a certain amount of structure, but
  2235. not as much as packages such as @file{man} or @file{mdoc}.
  2236. The simplest documents can begin with a paragraph macro (such as
  2237. @code{LP} or @code{PP}), and consist of text separated by paragraph
  2238. macros or even blank lines. Longer documents have a structure as
  2239. follows:
  2240. @table @strong
  2241. @item Document type
  2242. If you invoke the @code{RP} (report) macro on the first line of the
  2243. document, @code{groff} prints the cover page information on its own
  2244. page; otherwise it prints the information on the first page with your
  2245. document text immediately following. Other document formats found in
  2246. @acronym{AT&T} @code{troff} are specific to @acronym{AT&T} or
  2247. Berkeley, and are not supported in @code{groff}.
  2248. @item Format and layout
  2249. By setting number registers, you can change your document's type (font
  2250. and size), margins, spacing, headers and footers, and footnotes.
  2251. @xref{ms Document Control Registers}, for more details.
  2252. @item Cover page
  2253. A cover page consists of a title, the author's name and institution,
  2254. an abstract, and the date.@footnote{Actually, only the title is
  2255. required.} @xref{ms Cover Page Macros}, for more details.
  2256. @item Body
  2257. Following the cover page is your document. You can use the @file{ms}
  2258. macros to write reports, letters, books, and so forth. The package is
  2259. designed for structured documents, consisting of paragraphs
  2260. interspersed with headings and augmented by lists, footnotes, tables,
  2261. and other common constructs. @xref{ms Body Text}, for more details.
  2262. @item Table of contents
  2263. Longer documents usually include a table of contents, which you can
  2264. invoke by placing the @code{TC} macro at the end of your document.
  2265. The @file{ms} macros have minimal indexing facilities, consisting of
  2266. the @code{IX} macro, which prints an entry on standard error.
  2267. Printing the table of contents at the end is necessary since
  2268. @code{groff} is a single-pass text formatter, thus it cannot determine
  2269. the page number of each section until that section has actually been
  2270. set and printed. Since @file{ms} output is intended for hardcopy, you
  2271. can manually relocate the pages containing the table of contents
  2272. between the cover page and the body text after printing.
  2273. @end table
  2274. @c ---------------------------------------------------------------------
  2275. @node ms Document Control Registers, ms Cover Page Macros, General ms Structure, ms
  2276. @subsection Document control registers
  2277. @cindex @code{ms} macros, document control registers
  2278. The following is a list of document control number registers. For the
  2279. sake of consistency, set registers related to margins at the beginning
  2280. of your document, or just after the @code{RP} macro. You can set
  2281. other registers later in your document, but you should keep them
  2282. together at the beginning to make them easy to find and edit as
  2283. necessary.
  2284. @unnumberedsubsubsec Margin Settings
  2285. @Defmpreg {PO, ms}
  2286. Defines the page offset (i.e., the left margin). There is no explicit
  2287. right margin setting; the combination of the @code{PO} and @code{LL}
  2288. registers implicitly define the right margin width.
  2289. Effective: next page.
  2290. Default value: 1@dmn{i}.
  2291. @endDefmpreg
  2292. @Defmpreg {LL, ms}
  2293. Defines the line length (i.e., the width of the body text).
  2294. Effective: next paragraph.
  2295. Default: 6@dmn{i}.
  2296. @endDefmpreg
  2297. @Defmpreg {LT, ms}
  2298. Defines the title length (i.e., the header and footer width). This
  2299. is usually the same as @code{LL}, but not necessarily.
  2300. Effective: next paragraph.
  2301. Default: 6@dmn{i}.
  2302. @endDefmpreg
  2303. @Defmpreg {HM, ms}
  2304. Defines the header margin height at the top of the page.
  2305. Effective: next page.
  2306. Default: 1@dmn{i}.
  2307. @endDefmpreg
  2308. @Defmpreg {FM, ms}
  2309. Defines the footer margin height at the bottom of the page.
  2310. Effective: next page.
  2311. Default: 1@dmn{i}.
  2312. @endDefmpreg
  2313. @unnumberedsubsubsec Text Settings
  2314. @Defmpreg {PS, ms}
  2315. Defines the point size of the body text. If the value is larger than
  2316. or equal to 1000, divide it by 1000 to get a fractional point size.
  2317. For example, @samp{.nr PS 10250} sets the document's point size to
  2318. 10.25@dmn{p}.
  2319. Effective: next paragraph.
  2320. Default: 10@dmn{p}.
  2321. @endDefmpreg
  2322. @Defmpreg {VS, ms}
  2323. Defines the space between lines (line height plus leading). If the
  2324. value is larger than or equal to 1000, divide it by 1000 to get a
  2325. fractional point size. Due to backwards compatibility, @code{VS} must
  2326. be smaller than 40000 (this is 40.0@dmn{p}).
  2327. Effective: next paragraph.
  2328. Default: 12@dmn{p}.
  2329. @endDefmpreg
  2330. @Defmpreg {PSINCR, ms}
  2331. Defines an increment in point size, which will be applied to section
  2332. headings at nesting levels below the value specified in @code{GROWPS}.
  2333. The value of @code{PSINCR} should be specified in points, with the
  2334. @dmn{p} scaling factor, and may include a fractional component; for
  2335. example, @w{@samp{.nr PSINCR 1.5p}} sets a point size increment of
  2336. 1.5@dmn{p}.
  2337. Effective: next section heading.
  2338. Default: 1@dmn{p}.
  2339. @endDefmpreg
  2340. @Defmpreg {GROWPS, ms}
  2341. Defines the heading level below which the point size increment set by
  2342. @code{PSINCR} becomes effective. Section headings at and above the
  2343. level specified by @code{GROWPS} will be printed at the point size set
  2344. by @code{PS}; for each level below the value of @code{GROWPS}, the
  2345. point size will be increased in steps equal to the value of
  2346. @code{PSINCR}. Setting @code{GROWPS} to any value less than@tie{}2
  2347. disables the incremental heading size feature.
  2348. Effective: next section heading.
  2349. Default: 0.
  2350. @endDefmpreg
  2351. @Defmpreg {HY, ms}
  2352. Defines the hyphenation level. @code{HY} sets safely the value of the
  2353. low-level @code{hy} register. Setting the value of @code{HY}
  2354. to@tie{}0 is equivalent to using the @code{nh} request.
  2355. Effective: next paragraph.
  2356. Default: 14.
  2357. @endDefmpreg
  2358. @Defmpreg {FAM, ms}
  2359. Defines the font family used to typeset the document.
  2360. Effective: next paragraph.
  2361. Default: as defined in the output device.
  2362. @endDefmpreg
  2363. @unnumberedsubsubsec Paragraph Settings
  2364. @Defmpreg {PI, ms}
  2365. Defines the initial indentation of a (@code{PP} macro) paragraph.
  2366. Effective: next paragraph.
  2367. Default: 5@dmn{n}.
  2368. @endDefmpreg
  2369. @Defmpreg {PD, ms}
  2370. Defines the space between paragraphs.
  2371. Effective: next paragraph.
  2372. Default: 0.3@dmn{v}.
  2373. @endDefmpreg
  2374. @Defmpreg {QI, ms}
  2375. Defines the indentation on both sides of a quoted (@code{QP} macro)
  2376. paragraph.
  2377. Effective: next paragraph.
  2378. Default: 5@dmn{n}.
  2379. @endDefmpreg
  2380. @Defmpreg {PORPHANS, ms}
  2381. Defines the minimum number of initial lines of any paragraph which
  2382. should be kept together, to avoid orphan lines at the bottom of a
  2383. page. If a new paragraph is started close to the bottom of a page,
  2384. and there is insufficient space to accommodate @code{PORPHANS} lines
  2385. before an automatic page break, then the page break will be forced,
  2386. before the start of the paragraph.
  2387. Effective: next paragraph.
  2388. Default: 1.
  2389. @endDefmpreg
  2390. @Defmpreg {HORPHANS, ms}
  2391. Defines the minimum number of lines of the following paragraph which
  2392. should be kept together with any section heading introduced by the
  2393. @code{NH} or @code{SH} macros. If a section heading is placed close
  2394. to the bottom of a page, and there is insufficient space to
  2395. accommodate both the heading and at least @code{HORPHANS} lines of the
  2396. following paragraph, before an automatic page break, then the page
  2397. break will be forced before the heading.
  2398. Effective: next paragraph.
  2399. Default: 1.
  2400. @endDefmpreg
  2401. @unnumberedsubsubsec Footnote Settings
  2402. @Defmpreg {FL, ms}
  2403. Defines the length of a footnote.
  2404. Effective: next footnote.
  2405. Default: @math{@code{@\n[LL]} * 5 / 6}.
  2406. @endDefmpreg
  2407. @Defmpreg {FI, ms}
  2408. Defines the footnote indentation.
  2409. Effective: next footnote.
  2410. Default: 2@dmn{n}.
  2411. @endDefmpreg
  2412. @Defmpreg {FF, ms}
  2413. The footnote format:
  2414. @table @code
  2415. @item 0
  2416. Print the footnote number as a superscript; indent the footnote
  2417. (default).
  2418. @item 1
  2419. Print the number followed by a period (like 1.@:) and indent the
  2420. footnote.
  2421. @item 2
  2422. Like 1, without an indentation.
  2423. @item 3
  2424. Like 1, but print the footnote number as a hanging paragraph.
  2425. @end table
  2426. Effective: next footnote.
  2427. Default: 0.
  2428. @endDefmpreg
  2429. @Defmpreg {FPS, ms}
  2430. Defines the footnote point size. If the value is larger than or equal
  2431. to 1000, divide it by 1000 to get a fractional point size.
  2432. Effective: next footnote.
  2433. Default: @math{@code{@\n[PS]} - 2}.
  2434. @endDefmpreg
  2435. @Defmpreg {FVS, ms}
  2436. Defines the footnote vertical spacing. If the value is larger than or
  2437. equal to 1000, divide it by 1000 to get a fractional point size.
  2438. Effective: next footnote.
  2439. Default: @math{@code{@\n[FPS]} + 2}.
  2440. @endDefmpreg
  2441. @Defmpreg {FPD, ms}
  2442. Defines the footnote paragraph spacing.
  2443. Effective: next footnote.
  2444. Default: @math{@code{@\n[PD]} / 2}.
  2445. @endDefmpreg
  2446. @unnumberedsubsubsec Miscellaneous Number Registers
  2447. @Defmpreg {MINGW, ms}
  2448. Defines the minimum width between columns in a multi-column document.
  2449. Effective: next page.
  2450. Default: 2@dmn{n}.
  2451. @endDefmpreg
  2452. @c ---------------------------------------------------------------------
  2453. @node ms Cover Page Macros, ms Body Text, ms Document Control Registers, ms
  2454. @subsection Cover page macros
  2455. @cindex @code{ms} macros, cover page
  2456. @cindex cover page macros, [@code{ms}]
  2457. Use the following macros to create a cover page for your document in
  2458. the order shown.
  2459. @Defmac {RP, [@code{no}], ms}
  2460. Specifies the report format for your document. The report format
  2461. creates a separate cover page. The default action (no @code{RP}
  2462. macro) is to print a subset of the cover page on page@tie{}1 of your
  2463. document.
  2464. If you use the word @code{no} as an optional argument, @code{groff}
  2465. prints a title page but does not repeat any of the title page
  2466. information (title, author, abstract, etc.@:) on page@tie{}1 of the
  2467. document.
  2468. @endDefmac
  2469. @Defmac {P1, , ms}
  2470. (P-one) Prints the header on page@tie{}1. The default is to suppress
  2471. the header.
  2472. @endDefmac
  2473. @Defmac {DA, [@dots{}], ms}
  2474. (optional) Prints the current date, or the arguments to the macro if
  2475. any, on the title page (if specified) and in the footers. This is the
  2476. default for @code{nroff}.
  2477. @endDefmac
  2478. @Defmac {ND, [@dots{}], ms}
  2479. (optional) Prints the current date, or the arguments to the macro if
  2480. any, on the title page (if specified) but not in the footers. This is
  2481. the default for @code{troff}.
  2482. @endDefmac
  2483. @Defmac {TL, , ms}
  2484. Specifies the document title. @code{groff} collects text following
  2485. the @code{TL} macro into the title, until reaching the author name or
  2486. abstract.
  2487. @endDefmac
  2488. @Defmac {AU, , ms}
  2489. Specifies the author's name, which appears on the line (or lines)
  2490. immediately following. You can specify multiple authors as follows:
  2491. @Example
  2492. .AU
  2493. John Doe
  2494. .AI
  2495. University of West Bumblefuzz
  2496. .AU
  2497. Martha Buck
  2498. .AI
  2499. Monolithic Corporation
  2500. ...
  2501. @endExample
  2502. @endDefmac
  2503. @Defmac {AI, , ms}
  2504. Specifies the author's institution. You can specify multiple
  2505. institutions in the same way that you specify multiple authors.
  2506. @endDefmac
  2507. @Defmac {AB, [@code{no}], ms}
  2508. Begins the abstract. The default is to print the word
  2509. @acronym{ABSTRACT}, centered and in italics, above the text of the
  2510. abstract. The word @code{no} as an optional argument suppresses this
  2511. heading.
  2512. @endDefmac
  2513. @Defmac {AE, , ms}
  2514. Ends the abstract.
  2515. @endDefmac
  2516. The following is example mark-up for a title page.
  2517. @cindex title page, example markup
  2518. @cindex example markup, title page
  2519. @Example
  2520. @cartouche
  2521. .RP
  2522. .TL
  2523. The Inevitability of Code Bloat
  2524. in Commercial and Free Software
  2525. .AU
  2526. J. Random Luser
  2527. .AI
  2528. University of West Bumblefuzz
  2529. .AB
  2530. This report examines the long-term growth
  2531. of the code bases in two large, popular software
  2532. packages; the free Emacs and the commercial
  2533. Microsoft Word.
  2534. While differences appear in the type or order
  2535. of features added, due to the different
  2536. methodologies used, the results are the same
  2537. in the end.
  2538. .PP
  2539. The free software approach is shown to be
  2540. superior in that while free software can
  2541. become as bloated as commercial offerings,
  2542. free software tends to have fewer serious
  2543. bugs and the added features are in line with
  2544. user demand.
  2545. .AE
  2546. ... the rest of the paper follows ...
  2547. @end cartouche
  2548. @endExample
  2549. @c ---------------------------------------------------------------------
  2550. @node ms Body Text, ms Page Layout, ms Cover Page Macros, ms
  2551. @subsection Body text
  2552. @cindex @code{ms} macros, body text
  2553. This section describes macros used to mark up the body of your
  2554. document. Examples include paragraphs, sections, and other groups.
  2555. @menu
  2556. * Paragraphs in ms::
  2557. * Headings in ms::
  2558. * Highlighting in ms::
  2559. * Lists in ms::
  2560. * Indentation values in ms::
  2561. * Tabstops in ms::
  2562. * ms Displays and Keeps::
  2563. * ms Insertions::
  2564. * Example multi-page table::
  2565. * ms Footnotes::
  2566. @end menu
  2567. @c ---------------------------------------------------------------------
  2568. @node Paragraphs in ms, Headings in ms, ms Body Text, ms Body Text
  2569. @subsubsection Paragraphs
  2570. @cindex @code{ms} macros, paragraph handling
  2571. The following paragraph types are available.
  2572. @DefmacList {PP, , ms}
  2573. @DefmacListEnd {LP, , ms}
  2574. Sets a paragraph with an initial indentation.
  2575. @endDefmac
  2576. @Defmac {QP, , ms}
  2577. Sets a paragraph that is indented at both left and right margins. The
  2578. effect is identical to the @acronym{HTML} @code{<BLOCKQUOTE>} element.
  2579. The next paragraph or heading returns margins to normal.
  2580. @endDefmac
  2581. @Defmac {XP, , ms}
  2582. Sets a paragraph whose lines are indented, except for the first line.
  2583. This is a Berkeley extension.
  2584. @endDefmac
  2585. The following markup uses all four paragraph macros.
  2586. @Example
  2587. @cartouche
  2588. .NH 2
  2589. Cases used in the study
  2590. .LP
  2591. The following software and versions were
  2592. considered for this report.
  2593. .PP
  2594. For commercial software, we chose
  2595. .B "Microsoft Word for Windows" ,
  2596. starting with version 1.0 through the
  2597. current version (Word 2000).
  2598. .PP
  2599. For free software, we chose
  2600. .B Emacs ,
  2601. from its first appearance as a standalone
  2602. editor through the current version (v20).
  2603. See [Bloggs 2002] for details.
  2604. .QP
  2605. Franklin's Law applied to software:
  2606. software expands to outgrow both
  2607. RAM and disk space over time.
  2608. .LP
  2609. Bibliography:
  2610. .XP
  2611. Bloggs, Joseph R.,
  2612. .I "Everyone's a Critic" ,
  2613. Underground Press, March 2002.
  2614. A definitive work that answers all questions
  2615. and criticisms about the quality and usability of
  2616. free software.
  2617. @end cartouche
  2618. @endExample
  2619. The @code{PORPHANS} register (@pxref{ms Document Control Registers})
  2620. operates in conjunction with each of these macros, to inhibit the
  2621. printing of orphan lines at the bottom of any page.
  2622. @c ---------------------------------------------------------------------
  2623. @node Headings in ms, Highlighting in ms, Paragraphs in ms, ms Body Text
  2624. @subsubsection Headings
  2625. @cindex @code{ms} macros, headings
  2626. Use headings to create a hierarchical structure for your document.
  2627. The @file{ms} macros print headings in @strong{bold}, using the same
  2628. font family and point size as the body text.
  2629. The following describes the heading macros:
  2630. @DefmacList {NH, @Var{curr-level}, ms}
  2631. @DefmacListEnd {NH, @t{S} @Var{level0} @dots{}, ms}
  2632. Numbered heading. The argument is either a numeric argument to
  2633. indicate the level of the heading, or the letter@tie{}@code{S}
  2634. followed by numeric arguments to set the heading level explicitly.
  2635. If you specify heading levels out of sequence, such as invoking
  2636. @samp{.NH 3} after @samp{.NH 1}, @code{groff} prints a warning on
  2637. standard error.
  2638. @endDefmac
  2639. @DefstrList {SN, ms}
  2640. @DefstrItem {SN-DOT, ms}
  2641. @DefstrListEnd {SN-NO-DOT, ms}
  2642. After invocation of @code{NH}, the assigned section number is made
  2643. available in the strings @code{SN-DOT} (exactly as it appears in the
  2644. printed section heading) and @code{SN-NO-DOT} (with the final period
  2645. omitted). The string @code{SN} is also defined, as an alias for
  2646. @code{SN-DOT}; if preferred, you may redefine it as an alias for
  2647. @code{SN-NO-DOT}, by including the initialization
  2648. @Example
  2649. .ds SN-NO-DOT
  2650. .als SN SN-NO-DOT
  2651. @endExample
  2652. @noindent
  2653. @strong{before} your first use of @code{NH}, or simply
  2654. @Example
  2655. .als SN SN-NO-DOT
  2656. @endExample
  2657. @noindent
  2658. @strong{after} your first use of @code{NH}.
  2659. @endDefstr
  2660. @Defmac {SH, [@Var{match-level}], ms}
  2661. Unnumbered subheading.
  2662. The optional @var{match-level} argument is a GNU extension. It is a
  2663. number indicating the level of the heading, in a manner analogous to
  2664. the @var{curr-level} argument to @code{.NH}. Its purpose is to match
  2665. the point size, at which the heading is printed, to the size of a
  2666. numbered heading at the same level, when the @code{GROWPS} and
  2667. @code{PSINCR} heading size adjustment mechanism is in effect.
  2668. @xref{ms Document Control Registers}.
  2669. @endDefmac
  2670. The @code{HORPHANS} register (@pxref{ms Document Control Registers})
  2671. operates in conjunction with the @code{NH} and @code{SH} macros, to
  2672. inhibit the printing of orphaned section headings at the bottom of any
  2673. page.
  2674. @c ---------------------------------------------------------------------
  2675. @node Highlighting in ms, Lists in ms, Headings in ms, ms Body Text
  2676. @subsubsection Highlighting
  2677. @cindex @code{ms} macros, highlighting
  2678. The @file{ms} macros provide a variety of methods to highlight or
  2679. emphasize text:
  2680. @Defmac {B, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
  2681. Sets its first argument in @strong{bold type}. If you specify a
  2682. second argument, @code{groff} prints it in the previous font after the
  2683. bold text, with no intervening space (this allows you to set
  2684. punctuation after the highlighted text without highlighting the
  2685. punctuation). Similarly, it prints the third argument (if any) in the
  2686. previous font @strong{before} the first argument. For example,
  2687. @Example
  2688. .B foo ) (
  2689. @endExample
  2690. prints (@strong{foo}).
  2691. If you give this macro no arguments, @code{groff} prints all text
  2692. following in bold until the next highlighting, paragraph, or heading
  2693. macro.
  2694. @endDefmac
  2695. @Defmac {R, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
  2696. Sets its first argument in roman (or regular) type. It operates
  2697. similarly to the @code{B}@tie{}macro otherwise.
  2698. @endDefmac
  2699. @Defmac {I, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
  2700. Sets its first argument in @emph{italic type}. It operates similarly
  2701. to the @code{B}@tie{}macro otherwise.
  2702. @endDefmac
  2703. @Defmac {CW, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
  2704. Sets its first argument in a @code{constant width face}. It operates
  2705. similarly to the @code{B}@tie{}macro otherwise.
  2706. @endDefmac
  2707. @Defmac {BI, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
  2708. Sets its first argument in bold italic type. It operates similarly to
  2709. the @code{B}@tie{}macro otherwise.
  2710. @endDefmac
  2711. @Defmac {BX, [@Var{txt}], ms}
  2712. Prints its argument and draws a box around it. If you want to box a
  2713. string that contains spaces, use a digit-width space (@code{\0}).
  2714. @endDefmac
  2715. @Defmac {UL, [@Var{txt} [@Var{post}]], ms}
  2716. Prints its first argument with an underline. If you specify a second
  2717. argument, @code{groff} prints it in the previous font after the
  2718. underlined text, with no intervening space.
  2719. @endDefmac
  2720. @Defmac {LG, , ms}
  2721. Prints all text following in larger type (two points larger than the
  2722. current point size) until the next font size, highlighting, paragraph,
  2723. or heading macro. You can specify this macro multiple times to
  2724. enlarge the point size as needed.
  2725. @endDefmac
  2726. @Defmac {SM, , ms}
  2727. Prints all text following in smaller type (two points smaller than the
  2728. current point size) until the next type size, highlighting, paragraph,
  2729. or heading macro. You can specify this macro multiple times to reduce
  2730. the point size as needed.
  2731. @endDefmac
  2732. @Defmac {NL, , ms}
  2733. Prints all text following in the normal point size (that is, the value
  2734. of the @code{PS} register).
  2735. @endDefmac
  2736. @DefstrList {@Lbrace{}, ms}
  2737. @DefstrListEnd {@Rbrace{}, ms}
  2738. Text enclosed with @code{\*@{} and @code{\*@}} is printed as a
  2739. superscript.
  2740. @endDefstr
  2741. @c ---------------------------------------------------------------------
  2742. @node Lists in ms, Indentation values in ms, Highlighting in ms, ms Body Text
  2743. @subsubsection Lists
  2744. @cindex @code{ms} macros, lists
  2745. The @code{IP} macro handles duties for all lists.
  2746. @Defmac {IP, [@Var{marker} [@Var{width}]], ms}
  2747. The @var{marker} is usually a bullet glyph (@code{\[bu]}) for
  2748. unordered lists, a number (or auto-incrementing number register) for
  2749. numbered lists, or a word or phrase for indented (glossary-style)
  2750. lists.
  2751. The @var{width} specifies the indentation for the body of each list
  2752. item; its default unit is @samp{n}. Once specified, the indentation
  2753. remains the same for all list items in the document until specified
  2754. again.
  2755. The @code{PORPHANS} register (@pxref{ms Document Control Registers})
  2756. operates in conjunction with the @code{IP} macro, to inhibit the
  2757. printing of orphaned list markers at the bottom of any page.
  2758. @endDefmac
  2759. The following is an example of a bulleted list.
  2760. @cindex example markup, bulleted list [@code{ms}]
  2761. @cindex bulleted list, example markup [@code{ms}]
  2762. @Example
  2763. A bulleted list:
  2764. .IP \[bu] 2
  2765. lawyers
  2766. .IP \[bu]
  2767. guns
  2768. .IP \[bu]
  2769. money
  2770. @endExample
  2771. Produces:
  2772. @Example
  2773. A bulleted list:
  2774. o lawyers
  2775. o guns
  2776. o money
  2777. @endExample
  2778. The following is an example of a numbered list.
  2779. @cindex example markup, numbered list [@code{ms}]
  2780. @cindex numbered list, example markup [@code{ms}]
  2781. @Example
  2782. .nr step 1 1
  2783. A numbered list:
  2784. .IP \n[step] 3
  2785. lawyers
  2786. .IP \n+[step]
  2787. guns
  2788. .IP \n+[step]
  2789. money
  2790. @endExample
  2791. Produces:
  2792. @Example
  2793. A numbered list:
  2794. 1. lawyers
  2795. 2. guns
  2796. 3. money
  2797. @endExample
  2798. Note the use of the auto-incrementing number register in this example.
  2799. The following is an example of a glossary-style list.
  2800. @cindex example markup, glossary-style list [@code{ms}]
  2801. @cindex glossary-style list, example markup [@code{ms}]
  2802. @Example
  2803. A glossary-style list:
  2804. .IP lawyers 0.4i
  2805. Two or more attorneys.
  2806. .IP guns
  2807. Firearms, preferably
  2808. large-caliber.
  2809. .IP money
  2810. Gotta pay for those
  2811. lawyers and guns!
  2812. @endExample
  2813. Produces:
  2814. @Example
  2815. A glossary-style list:
  2816. lawyers
  2817. Two or more attorneys.
  2818. guns Firearms, preferably large-caliber.
  2819. money
  2820. Gotta pay for those lawyers and guns!
  2821. @endExample
  2822. In the last example, the @code{IP} macro places the definition on the
  2823. same line as the term if it has enough space; otherwise, it breaks to
  2824. the next line and starts the definition below the term. This may or
  2825. may not be the effect you want, especially if some of the definitions
  2826. break and some do not. The following examples show two possible ways
  2827. to force a break.
  2828. The first workaround uses the @code{br} request to force a break after
  2829. printing the term or label.
  2830. @Example
  2831. @cartouche
  2832. A glossary-style list:
  2833. .IP lawyers 0.4i
  2834. Two or more attorneys.
  2835. .IP guns
  2836. .br
  2837. Firearms, preferably large-caliber.
  2838. .IP money
  2839. Gotta pay for those lawyers and guns!
  2840. @end cartouche
  2841. @endExample
  2842. The second workaround uses the @code{\p} escape to force the break.
  2843. Note the space following the escape; this is important. If you omit
  2844. the space, @code{groff} prints the first word on the same line as the
  2845. term or label (if it fits) @strong{then} breaks the line.
  2846. @Example
  2847. @cartouche
  2848. A glossary-style list:
  2849. .IP lawyers 0.4i
  2850. Two or more attorneys.
  2851. .IP guns
  2852. \p Firearms, preferably large-caliber.
  2853. .IP money
  2854. Gotta pay for those lawyers and guns!
  2855. @end cartouche
  2856. @endExample
  2857. To set nested lists, use the @code{RS} and @code{RE} macros.
  2858. @xref{Indentation values in ms}, for more information.
  2859. @cindex @code{ms} macros, nested lists
  2860. @cindex nested lists [@code{ms}]
  2861. For example:
  2862. @Example
  2863. @cartouche
  2864. .IP \[bu] 2
  2865. Lawyers:
  2866. .RS
  2867. .IP \[bu]
  2868. Dewey,
  2869. .IP \[bu]
  2870. Cheatham,
  2871. .IP \[bu]
  2872. and Howe.
  2873. .RE
  2874. .IP \[bu]
  2875. Guns
  2876. @end cartouche
  2877. @endExample
  2878. Produces:
  2879. @Example
  2880. o Lawyers:
  2881. o Dewey,
  2882. o Cheatham,
  2883. o and Howe.
  2884. o Guns
  2885. @endExample
  2886. @c ---------------------------------------------------------------------
  2887. @node Indentation values in ms, Tabstops in ms, Lists in ms, ms Body Text
  2888. @subsubsection Indentation values
  2889. In many situations, you may need to indentation a section of text
  2890. while still wrapping and filling. @xref{Lists in ms}, for an example
  2891. of nested lists.
  2892. @DefmacList {RS, , ms}
  2893. @DefmacListEnd {RE, , ms}
  2894. These macros begin and end an indented section. The @code{PI}
  2895. register controls the amount of indentation, allowing the indented
  2896. text to line up under hanging and indented paragraphs.
  2897. @endDefmac
  2898. @xref{ms Displays and Keeps}, for macros to indentation and turn off
  2899. filling.
  2900. @c ---------------------------------------------------------------------
  2901. @node Tabstops in ms, ms Displays and Keeps, Indentation values in ms, ms Body Text
  2902. @subsubsection Tab Stops
  2903. Use the @code{ta} request to define tab stops as needed. @xref{Tabs
  2904. and Fields}.
  2905. @Defmac{TA, , ms}
  2906. Use this macro to reset the tab stops to the default for @file{ms}
  2907. (every 5n). You can redefine the @code{TA} macro to create a
  2908. different set of default tab stops.
  2909. @endDefmac
  2910. @c ---------------------------------------------------------------------
  2911. @node ms Displays and Keeps, ms Insertions, Tabstops in ms, ms Body Text
  2912. @subsubsection Displays and keeps
  2913. @cindex @code{ms} macros, displays
  2914. @cindex @code{ms} macros, keeps
  2915. @cindex keeps [@code{ms}]
  2916. @cindex displays [@code{ms}]
  2917. Use displays to show text-based examples or figures (such as code
  2918. listings).
  2919. Displays turn off filling, so lines of code are displayed as-is
  2920. without inserting @code{br} requests in between each line. Displays
  2921. can be @dfn{kept} on a single page, or allowed to break across pages.
  2922. @DefmacList {DS, @t{L}, ms}
  2923. @DefmacItem {LD, , ms}
  2924. @DefmacListEnd {DE, , ms}
  2925. Left-justified display. The @samp{.DS L} call generates a page break,
  2926. if necessary, to keep the entire display on one page. The @code{LD}
  2927. macro allows the display to break across pages. The @code{DE} macro
  2928. ends the display.
  2929. @endDefmac
  2930. @DefmacList {DS, @t{I}, ms}
  2931. @DefmacItem {ID, , ms}
  2932. @DefmacListEnd {DE, , ms}
  2933. Indents the display as defined by the @code{DI} register. The
  2934. @samp{.DS I} call generates a page break, if necessary, to keep the
  2935. entire display on one page. The @code{ID} macro allows the display to
  2936. break across pages. The @code{DE} macro ends the display.
  2937. @endDefmac
  2938. @DefmacList {DS, @t{B}, ms}
  2939. @DefmacItem {BD, , ms}
  2940. @DefmacListEnd {DE, , ms}
  2941. Sets a block-centered display: the entire display is left-justified,
  2942. but indented so that the longest line in the display is centered on
  2943. the page. The @samp{.DS B} call generates a page break, if necessary,
  2944. to keep the entire display on one page. The @code{BD} macro allows
  2945. the display to break across pages. The @code{DE} macro ends the
  2946. display.
  2947. @endDefmac
  2948. @DefmacList {DS, @t{C}, ms}
  2949. @DefmacItem {CD, , ms}
  2950. @DefmacListEnd {DE, , ms}
  2951. Sets a centered display: each line in the display is centered. The
  2952. @samp{.DS C} call generates a page break, if necessary, to keep the
  2953. entire display on one page. The @code{CD} macro allows the display to
  2954. break across pages. The @code{DE} macro ends the display.
  2955. @endDefmac
  2956. @DefmacList {DS, @t{R}, ms}
  2957. @DefmacItem {RD, , ms}
  2958. @DefmacListEnd {DE, , ms}
  2959. Right-justifies each line in the display. The @samp{.DS R} call
  2960. generates a page break, if necessary, to keep the entire display on
  2961. one page. The @code{RD} macro allows the display to break across
  2962. pages. The @code{DE} macro ends the display.
  2963. @endDefmac
  2964. @DefmacList {Ds, , ms}
  2965. @DefmacListEnd {De, , ms}
  2966. These two macros were formerly provided as aliases for @code{DS} and
  2967. @code{DE}, respectively. They have been removed, and should no longer
  2968. be used. The original implementations of @code{DS} and @code{DE} are
  2969. retained, and should be used instead. X11 documents which actually
  2970. use @code{Ds} and @code{De} always load a specific macro file from the
  2971. X11 distribution (@file{macros.t}) which provides proper definitions
  2972. for the two macros.
  2973. @endDefmac
  2974. On occasion, you may want to @dfn{keep} other text together on a page.
  2975. For example, you may want to keep two paragraphs together, or a
  2976. paragraph that refers to a table (or list, or other item) immediately
  2977. following. The @file{ms} macros provide the @code{KS} and @code{KE}
  2978. macros for this purpose.
  2979. @DefmacList {KS, , ms}
  2980. @DefmacListEnd {KE, , ms}
  2981. The @code{KS} macro begins a block of text to be kept on a single
  2982. page, and the @code{KE} macro ends the block.
  2983. @endDefmac
  2984. @DefmacList {KF, , ms}
  2985. @DefmacListEnd {KE, , ms}
  2986. Specifies a @dfn{floating keep}; if the keep cannot fit on the current
  2987. page, @code{groff} holds the contents of the keep and allows text
  2988. following the keep (in the source file) to fill in the remainder of
  2989. the current page. When the page breaks, whether by an explicit
  2990. @code{bp} request or by reaching the end of the page, @code{groff}
  2991. prints the floating keep at the top of the new page. This is useful
  2992. for printing large graphics or tables that do not need to appear
  2993. exactly where specified.
  2994. @endDefmac
  2995. You can also use the @code{ne} request to force a page break if there
  2996. is not enough vertical space remaining on the page.
  2997. Use the following macros to draw a box around a section of text (such
  2998. as a display).
  2999. @DefmacList {B1, , ms}
  3000. @DefmacListEnd {B2, , ms}
  3001. Marks the beginning and ending of text that is to have a box drawn
  3002. around it. The @code{B1} macro begins the box; the @code{B2} macro
  3003. ends it. Text in the box is automatically placed in a diversion
  3004. (keep).
  3005. @endDefmac
  3006. @c ---------------------------------------------------------------------
  3007. @node ms Insertions, Example multi-page table, ms Displays and Keeps, ms Body Text
  3008. @subsubsection Tables, figures, equations, and references
  3009. @cindex @code{ms} macros, tables
  3010. @cindex @code{ms} macros, figures
  3011. @cindex @code{ms} macros, equations
  3012. @cindex @code{ms} macros, references
  3013. @cindex tables [@code{ms}]
  3014. @cindex figures [@code{ms}]
  3015. @cindex equations [@code{ms}]
  3016. @cindex references [@code{ms}]
  3017. The @file{ms} macros support the standard @code{groff} preprocessors:
  3018. @code{tbl}, @code{pic}, @code{eqn}, and @code{refer}.
  3019. @pindex tbl
  3020. @pindex pic
  3021. @pindex eqn
  3022. @pindex refer
  3023. You mark text meant for preprocessors by enclosing it
  3024. in pairs of tags as follows.
  3025. @DefmacList {TS, [@code{H}], ms}
  3026. @DefmacListEnd {TE, , ms}
  3027. Denotes a table, to be processed by the @code{tbl} preprocessor. The
  3028. optional argument@tie{}@code{H} to @code{TS} instructs @code{groff} to
  3029. create a running header with the information up to the @code{TH}
  3030. macro. @code{groff} prints the header at the beginning of the table;
  3031. if the table runs onto another page, @code{groff} prints the header on
  3032. the next page as well.
  3033. @endDefmac
  3034. @DefmacList {PS, , ms}
  3035. @DefmacListEnd {PE, , ms}
  3036. Denotes a graphic, to be processed by the @code{pic} preprocessor.
  3037. You can create a @code{pic} file by hand, using the @acronym{AT&T}
  3038. @code{pic} manual available on the Web as a reference, or by using a
  3039. graphics program such as @code{xfig}.
  3040. @endDefmac
  3041. @DefmacList {EQ, [@Var{align}], ms}
  3042. @DefmacListEnd {EN, , ms}
  3043. Denotes an equation, to be processed by the @code{eqn} preprocessor.
  3044. The optional @var{align} argument can be @code{C}, @code{L},
  3045. or@tie{}@code{I} to center (the default), left-justify, or indent the
  3046. equation.
  3047. @endDefmac
  3048. @DefmacList {[, , ms}
  3049. @DefmacListEnd {], , ms}
  3050. Denotes a reference, to be processed by the @code{refer} preprocessor.
  3051. The @acronym{GNU} @cite{refer(1)} man page provides a comprehensive
  3052. reference to the preprocessor and the format of the bibliographic
  3053. database.
  3054. @endDefmac
  3055. @menu
  3056. * Example multi-page table::
  3057. @end menu
  3058. @c ---------------------------------------------------------------------
  3059. @node Example multi-page table, ms Footnotes, ms Insertions, ms Body Text
  3060. @subsubsection An example multi-page table
  3061. @cindex example markup, multi-page table [@code{ms}]
  3062. @cindex multi-page table, example markup [@code{ms}]
  3063. The following is an example of how to set up a table that may print
  3064. across two or more pages.
  3065. @Example
  3066. @cartouche
  3067. .TS H
  3068. allbox expand;
  3069. cb | cb .
  3070. Text ...of heading...
  3071. _
  3072. .TH
  3073. .T&
  3074. l | l .
  3075. ... the rest of the table follows...
  3076. .CW
  3077. .TE
  3078. @end cartouche
  3079. @endExample
  3080. @c ---------------------------------------------------------------------
  3081. @node ms Footnotes, , Example multi-page table, ms Body Text
  3082. @subsubsection Footnotes
  3083. @cindex @code{ms} macros, footnotes
  3084. @cindex footnotes [@code{ms}]
  3085. The @file{ms} macro package has a flexible footnote system. You can
  3086. specify either numbered footnotes or symbolic footnotes (that is,
  3087. using a marker such as a dagger symbol).
  3088. @Defstr {*, ms}
  3089. Specifies the location of a numbered footnote marker in the text.
  3090. @endDefesc
  3091. @DefmacList {FS, , ms}
  3092. @DefmacListEnd {FE, , ms}
  3093. Specifies the text of the footnote. The default action is to create a
  3094. numbered footnote; you can create a symbolic footnote by specifying a
  3095. @dfn{mark} glyph (such as @code{\[dg]} for the dagger glyph) in the
  3096. body text and as an argument to the @code{FS} macro, followed by the
  3097. text of the footnote and the @code{FE} macro.
  3098. @endDefmac
  3099. You can control how @code{groff} prints footnote numbers by changing
  3100. the value of the @code{FF} register. @xref{ms Document Control
  3101. Registers}.
  3102. @cindex footnotes, and keeps [@code{ms}]
  3103. @cindex keeps, and footnotes [@code{ms}]
  3104. @cindex footnotes, and displays [@code{ms}]
  3105. @cindex displays, and footnotes [@code{ms}]
  3106. Footnotes can be safely used within keeps and displays, but you should
  3107. avoid using numbered footnotes within floating keeps. You can set a
  3108. second @code{\**} marker between a @code{\**} and its corresponding
  3109. @code{.FS} entry; as long as each @code{FS} macro occurs @emph{after}
  3110. the corresponding @code{\**} and the occurrences of @code{.FS} are in
  3111. the same order as the corresponding occurrences of @code{\**}.
  3112. @c ---------------------------------------------------------------------
  3113. @node ms Page Layout, Differences from AT&T ms, ms Body Text, ms
  3114. @subsection Page layout
  3115. @cindex @code{ms} macros, page layout
  3116. @cindex page layout [@code{ms}]
  3117. The default output from the @file{ms} macros provides a minimalist
  3118. page layout: it prints a single column, with the page number centered
  3119. at the top of each page. It prints no footers.
  3120. You can change the layout by setting the proper number registers and
  3121. strings.
  3122. @menu
  3123. * ms Headers and Footers::
  3124. * ms Margins::
  3125. * ms Multiple Columns::
  3126. * ms TOC::
  3127. * ms Strings and Special Characters::
  3128. @end menu
  3129. @c ---------------------------------------------------------------------
  3130. @node ms Headers and Footers, ms Margins, ms Page Layout, ms Page Layout
  3131. @subsubsection Headers and footers
  3132. @cindex @code{ms} macros, headers
  3133. @cindex @code{ms} macros, footers
  3134. @cindex headers [@code{ms}]
  3135. @cindex footers [@code{ms}]
  3136. For documents that do not distinguish between odd and even pages, set
  3137. the following strings:
  3138. @DefstrList {LH, ms}
  3139. @DefstrItem {CH, ms}
  3140. @DefstrListEnd {RH, ms}
  3141. Sets the left, center, and right headers.
  3142. @endDefstr
  3143. @DefstrList {LF, ms}
  3144. @DefstrItem {CF, ms}
  3145. @DefstrListEnd {RF, ms}
  3146. Sets the left, center, and right footers.
  3147. @endDefstr
  3148. For documents that need different information printed in the even and
  3149. odd pages, use the following macros:
  3150. @DefmacList {OH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
  3151. @DefmacItem {EH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
  3152. @DefmacItem {OF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
  3153. @DefmacListEnd {EF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
  3154. The @code{OH} and @code{EH} macros define headers for the odd and even
  3155. pages; the @code{OF} and @code{EF} macros define footers for the odd
  3156. and even pages. This is more flexible than defining the individual
  3157. strings.
  3158. You can replace the quote (@code{'}) marks with any character not
  3159. appearing in the header or footer text.
  3160. @endDefmac
  3161. @c ---------------------------------------------------------------------
  3162. @node ms Margins, ms Multiple Columns, ms Headers and Footers, ms Page Layout
  3163. @subsubsection Margins
  3164. @cindex @code{ms} macros, margins
  3165. You control margins using a set of number registers. @xref{ms
  3166. Document Control Registers}, for details.
  3167. @c ---------------------------------------------------------------------
  3168. @node ms Multiple Columns, ms TOC, ms Margins, ms Page Layout
  3169. @subsubsection Multiple columns
  3170. @cindex @code{ms} macros, multiple columns
  3171. @cindex multiple columns [@code{ms}]
  3172. The @file{ms} macros can set text in as many columns as will
  3173. reasonably fit on the page. The following macros are available; all
  3174. of them force a page break if a multi-column mode is already set.
  3175. However, if the current mode is single-column, starting a multi-column
  3176. mode does @emph{not} force a page break.
  3177. @Defmac {1C, , ms}
  3178. Single-column mode.
  3179. @endDefmac
  3180. @Defmac {2C, , ms}
  3181. Two-column mode.
  3182. @endDefmac
  3183. @Defmac {MC, [@Var{width} [@Var{gutter}]], ms}
  3184. Multi-column mode. If you specify no arguments, it is equivalent to
  3185. the @code{2C} macro. Otherwise, @var{width} is the width of each
  3186. column and @var{gutter} is the space between columns. The
  3187. @code{MINGW} number register controls the default gutter width.
  3188. @endDefmac
  3189. @c ---------------------------------------------------------------------
  3190. @node ms TOC, ms Strings and Special Characters, ms Multiple Columns, ms Page Layout
  3191. @subsubsection Creating a table of contents
  3192. @cindex @code{ms} macros, creating table of contents
  3193. @cindex table of contents, creating [@code{ms}]
  3194. The facilities in the @file{ms} macro package for creating a table of
  3195. contents are semi-automated at best. Assuming that you want the table
  3196. of contents to consist of the document's headings, you need to repeat
  3197. those headings wrapped in @code{XS} and @code{XE} macros.
  3198. @DefmacList {XS, [@Var{page}], ms}
  3199. @DefmacItem {XA, [@Var{page}], ms}
  3200. @DefmacListEnd {XE, , ms}
  3201. These macros define a table of contents or an individual entry in the
  3202. table of contents, depending on their use. The macros are very
  3203. simple; they cannot indent a heading based on its level. The easiest
  3204. way to work around this is to add tabs to the table of contents
  3205. string. The following is an example:
  3206. @Example
  3207. @cartouche
  3208. .NH 1
  3209. Introduction
  3210. .XS
  3211. Introduction
  3212. .XE
  3213. .LP
  3214. ...
  3215. .CW
  3216. .NH 2
  3217. Methodology
  3218. .XS
  3219. Methodology
  3220. .XE
  3221. .LP
  3222. ...
  3223. @end cartouche
  3224. @endExample
  3225. You can manually create a table of contents by beginning with the
  3226. @code{XS} macro for the first entry, specifying the page number for
  3227. that entry as the argument to @code{XS}. Add subsequent entries using
  3228. the @code{XA} macro, specifying the page number for that entry as the
  3229. argument to @code{XA}. The following is an example:
  3230. @Example
  3231. @cartouche
  3232. .XS 1
  3233. Introduction
  3234. .XA 2
  3235. A Brief History of the Universe
  3236. .XA 729
  3237. Details of Galactic Formation
  3238. ...
  3239. .XE
  3240. @end cartouche
  3241. @endExample
  3242. @endDefmac
  3243. @Defmac {TC, [@code{no}], ms}
  3244. Prints the table of contents on a new page, setting the page number
  3245. to@tie{}@strong{i} (Roman lowercase numeral one). You should usually
  3246. place this macro at the end of the file, since @code{groff} is a
  3247. single-pass formatter and can only print what has been collected up to
  3248. the point that the @code{TC} macro appears.
  3249. The optional argument @code{no} suppresses printing the title
  3250. specified by the string register @code{TOC}.
  3251. @endDefmac
  3252. @Defmac{PX, [@code{no}], ms}
  3253. Prints the table of contents on a new page, using the current page
  3254. numbering sequence. Use this macro to print a manually-generated
  3255. table of contents at the beginning of your document.
  3256. The optional argument @code{no} suppresses printing the title
  3257. specified by the string register @code{TOC}.
  3258. @endDefmac
  3259. The @cite{Groff and Friends HOWTO} includes a @code{sed} script that
  3260. automatically inserts @code{XS} and @code{XE} macro entries after each
  3261. heading in a document.
  3262. Altering the @code{NH} macro to automatically build the table of
  3263. contents is perhaps initially more difficult, but would save a great
  3264. deal of time in the long run if you use @file{ms} regularly.
  3265. @c ---------------------------------------------------------------------
  3266. @node ms Strings and Special Characters, , ms TOC, ms Page Layout
  3267. @subsubsection Strings and Special Characters
  3268. @cindex @code{ms} macros, strings
  3269. @cindex @code{ms} macros, special characters
  3270. @cindex @code{ms} macros, accent marks
  3271. @cindex accent marks [@code{ms}]
  3272. @cindex special characters [@code{ms}]
  3273. @cindex strings [@code{ms}]
  3274. The @file{ms} macros provide the following predefined strings. You
  3275. can change the string definitions to help in creating documents in
  3276. languages other than English.
  3277. @Defstr {REFERENCES, ms}
  3278. Contains the string printed at the beginning of the references
  3279. (bibliography) page. The default is @samp{References}.
  3280. @endDefstr
  3281. @Defstr {ABSTRACT, ms}
  3282. Contains the string printed at the beginning of the abstract. The
  3283. default is @samp{ABSTRACT}.
  3284. @endDefstr
  3285. @Defstr {TOC, ms}
  3286. Contains the string printed at the beginning of the table of contents.
  3287. @endDefstr
  3288. @DefstrList {MONTH1, ms}
  3289. @DefstrItem {MONTH2, ms}
  3290. @DefstrItem {MONTH3, ms}
  3291. @DefstrItem {MONTH4, ms}
  3292. @DefstrItem {MONTH5, ms}
  3293. @DefstrItem {MONTH6, ms}
  3294. @DefstrItem {MONTH7, ms}
  3295. @DefstrItem {MONTH8, ms}
  3296. @DefstrItem {MONTH9, ms}
  3297. @DefstrItem {MONTH10, ms}
  3298. @DefstrItem {MONTH11, ms}
  3299. @DefstrListEnd {MONTH12, ms}
  3300. Prints the full name of the month in dates. The default is
  3301. @samp{January}, @samp{February}, etc.
  3302. @endDefstr
  3303. The following special characters are available@footnote{For an
  3304. explanation what special characters are see @ref{Special
  3305. Characters}.}:
  3306. @Defstr {-, ms}
  3307. Prints an em dash.
  3308. @endDefstr
  3309. @DefstrList {Q, ms}
  3310. @DefstrListEnd {U, ms}
  3311. Prints typographer's quotes in troff, and plain quotes in nroff.
  3312. @code{\*Q} is the left quote and @code{\*U} is the right quote.
  3313. @endDefstr
  3314. Improved accent marks are available in the @file{ms} macros.
  3315. @Defmac {AM, , ms}
  3316. Specify this macro at the beginning of your document to enable
  3317. extended accent marks and special characters. This is a Berkeley
  3318. extension.
  3319. To use the accent marks, place them @strong{after} the character being
  3320. accented.
  3321. Note that groff's native support for accents is superior to the
  3322. following definitions.
  3323. @endDefmac
  3324. The following accent marks are available after invoking the @code{AM}
  3325. macro:
  3326. @Defstr {\', ms}
  3327. Acute accent.
  3328. @endDefstr
  3329. @Defstr {\`, ms}
  3330. Grave accent.
  3331. @endDefstr
  3332. @Defstr {^, ms}
  3333. Circumflex.
  3334. @endDefstr
  3335. @Defstr {\,, ms}
  3336. Cedilla.
  3337. @endDefstr
  3338. @Defstr {~, ms}
  3339. Tilde.
  3340. @endDefstr
  3341. @deffn String @t{\*[:]}
  3342. @ifnotinfo
  3343. @stindex : @r{[}ms@r{]}
  3344. @end ifnotinfo
  3345. @ifinfo
  3346. @stindex \*[@r{<colon>}] @r{[}ms@r{]}
  3347. @end ifinfo
  3348. Umlaut.
  3349. @end deffn
  3350. @Defstr {v, ms}
  3351. Hacek.
  3352. @endDefstr
  3353. @Defstr {_, ms}
  3354. Macron (overbar).
  3355. @endDefstr
  3356. @Defstr {., ms}
  3357. Underdot.
  3358. @endDefstr
  3359. @Defstr {o, ms}
  3360. Ring above.
  3361. @endDefstr
  3362. The following are standalone characters available after invoking the
  3363. @code{AM} macro:
  3364. @Defstr {?, ms}
  3365. Upside-down question mark.
  3366. @endDefstr
  3367. @Defstr {!, ms}
  3368. Upside-down exclamation point.
  3369. @endDefstr
  3370. @Defstr {8, ms}
  3371. German ß ligature.
  3372. @endDefstr
  3373. @Defstr {3, ms}
  3374. Yogh.
  3375. @endDefstr
  3376. @Defstr {Th, ms}
  3377. Uppercase thorn.
  3378. @endDefstr
  3379. @Defstr {th, ms}
  3380. Lowercase thorn.
  3381. @endDefstr
  3382. @Defstr {D-, ms}
  3383. Uppercase eth.
  3384. @endDefstr
  3385. @Defstr {d-, ms}
  3386. Lowercase eth.
  3387. @endDefstr
  3388. @Defstr {q, ms}
  3389. Hooked o.
  3390. @endDefstr
  3391. @Defstr {ae, ms}
  3392. Lowercase ć ligature.
  3393. @endDefstr
  3394. @Defstr {Ae, ms}
  3395. Uppercase Ć ligature.
  3396. @endDefstr
  3397. @c ---------------------------------------------------------------------
  3398. @node Differences from AT&T ms, Naming Conventions, ms Page Layout, ms
  3399. @subsection Differences from @acronym{AT&T} @file{ms}
  3400. @cindex @code{ms} macros, differences from @acronym{AT&T}
  3401. @cindex @acronym{AT&T} @code{troff}, @code{ms} macro package differences
  3402. This section lists the (minor) differences between the @code{groff
  3403. -ms} macros and @acronym{AT&T} @code{troff -ms} macros.
  3404. @itemize @bullet
  3405. @item
  3406. The internals of @code{groff -ms} differ from the internals of
  3407. @acronym{AT&T} @code{troff -ms}. Documents that depend upon
  3408. implementation details of @acronym{AT&T} @code{troff -ms} may not
  3409. format properly with @code{groff -ms}.
  3410. @item
  3411. The general error-handling policy of @code{groff -ms} is to detect and
  3412. report errors, rather than silently to ignore them.
  3413. @item
  3414. @code{groff -ms} does not work in compatibility mode (this is, with
  3415. the @option{-C} option).
  3416. @item
  3417. There is no special support for typewriter-like devices.
  3418. @item
  3419. @code{groff -ms} does not provide cut marks.
  3420. @item
  3421. Multiple line spacing is not supported. Use a larger vertical spacing
  3422. instead.
  3423. @item
  3424. Some @acronym{UNIX} @code{ms} documentation says that the @code{CW}
  3425. and @code{GW} number registers can be used to control the column width
  3426. and gutter width, respectively. These number registers are not used in
  3427. @code{groff -ms}.
  3428. @item
  3429. Macros that cause a reset (paragraphs, headings, etc.@:) may change
  3430. the indentation. Macros that change the indentation do not increment
  3431. or decrement the indentation, but rather set it absolutely. This can
  3432. cause problems for documents that define additional macros of their
  3433. own. The solution is to use not the @code{in} request but instead the
  3434. @code{RS} and @code{RE} macros.
  3435. @item
  3436. To make @code{groff -ms} use the default page offset (which also
  3437. specifies the left margin), the @code{PO} register must stay undefined
  3438. until the first @file{-ms} macro is evaluated. This implies that
  3439. @code{PO} should not be used early in the document, unless it is
  3440. changed also: Remember that accessing an undefined register
  3441. automatically defines it.
  3442. @end itemize
  3443. @Defmpreg {GS, ms}
  3444. This number register is set to@tie{}1 by the @code{groff -ms} macros,
  3445. but it is not used by the @code{AT&T} @code{troff -ms} macros.
  3446. Documents that need to determine whether they are being formatted with
  3447. @code{AT&T} @code{troff -ms} or @code{groff -ms} should use this
  3448. number register.
  3449. @endDefmpreg
  3450. @menu
  3451. * Missing ms Macros::
  3452. * Additional ms Macros::
  3453. @end menu
  3454. @c ---------------------------------------------------------------------
  3455. @node Missing ms Macros, Additional ms Macros, Differences from AT&T ms, Differences from AT&T ms
  3456. @subsubsection @code{troff} macros not appearing in @code{groff}
  3457. Macros missing from @code{groff -ms} are cover page macros specific to
  3458. Bell Labs and Berkeley. The macros known to be missing are:
  3459. @table @code
  3460. @item .TM
  3461. Technical memorandum; a cover sheet style
  3462. @item .IM
  3463. Internal memorandum; a cover sheet style
  3464. @item .MR
  3465. Memo for record; a cover sheet style
  3466. @item .MF
  3467. Memo for file; a cover sheet style
  3468. @item .EG
  3469. Engineer's notes; a cover sheet style
  3470. @item .TR
  3471. Computing Science Tech Report; a cover sheet style
  3472. @item .OK
  3473. Other keywords
  3474. @item .CS
  3475. Cover sheet information
  3476. @item .MH
  3477. A cover sheet macro
  3478. @end table
  3479. @c ---------------------------------------------------------------------
  3480. @node Additional ms Macros, , Missing ms Macros, Differences from AT&T ms
  3481. @subsubsection @code{groff} macros not appearing in @acronym{AT&T} @code{troff}
  3482. The @code{groff -ms} macros have a few minor extensions
  3483. compared to the @acronym{AT&T} @code{troff -ms} macros.
  3484. @Defmac {AM, , ms}
  3485. Improved accent marks.
  3486. @xref{ms Strings and Special Characters}, for details.
  3487. @endDefmac
  3488. @Defmac {DS, @t{I}, ms}
  3489. Indented display.
  3490. The default behavior of @acronym{AT&T} @code{troff -ms}
  3491. was to indent; the @code{groff} default prints displays
  3492. flush left with the body text.
  3493. @endDefmac
  3494. @Defmac {CW, , ms}
  3495. Print text in @code{constant width} (Courier) font.
  3496. @endDefmac
  3497. @Defmac {IX, , ms}
  3498. Indexing term (printed on standard error).
  3499. You can write a script to capture and process an index
  3500. generated in this manner.
  3501. @endDefmac
  3502. The following additional number registers
  3503. appear in @code{groff -ms}:
  3504. @Defmpreg {MINGW, ms}
  3505. Specifies a minimum space
  3506. between columns (for multi-column output); this takes the
  3507. place of the @code{GW} register that was documented but apparently
  3508. not implemented in @acronym{AT&T} @code{troff}.
  3509. @endDefmpreg
  3510. Several new string registers are available as well.
  3511. You can change these to handle (for example) the local language.
  3512. @xref{ms Strings and Special Characters}, for details.
  3513. @c ---------------------------------------------------------------------
  3514. @node Naming Conventions, , Differences from AT&T ms, ms
  3515. @subsection Naming Conventions
  3516. @cindex @code{ms} macros, naming conventions
  3517. @cindex naming conventions, @code{ms} macros
  3518. The following conventions are used for names of macros, strings and
  3519. number registers. External names available to documents that use the
  3520. @code{groff -ms} macros contain only uppercase letters and digits.
  3521. Internally the macros are divided into modules; naming conventions are
  3522. as follows:
  3523. @itemize @bullet
  3524. @item
  3525. Names used only within one module are of the form
  3526. @var{module}@code{*}@var{name}.
  3527. @item
  3528. Names used outside the module in which they are defined are of the
  3529. form @var{module}@code{@@}@var{name}.
  3530. @item
  3531. Names associated with a particular environment are of the form
  3532. @var{environment}@code{:}@var{name}; these are used only within the
  3533. @code{par} module.
  3534. @item
  3535. @var{name} does not have a module prefix.
  3536. @item
  3537. Constructed names used to implement arrays are of the form
  3538. @var{array}@code{!}@var{index}.
  3539. @end itemize
  3540. Thus the groff ms macros reserve the following names:
  3541. @itemize @bullet
  3542. @item
  3543. Names containing the characters @code{*}, @code{@@},
  3544. and@tie{}@code{:}.
  3545. @item
  3546. Names containing only uppercase letters and digits.
  3547. @end itemize
  3548. @c =====================================================================
  3549. @node me, mm, ms, Macro Packages
  3550. @section @file{me}
  3551. @cindex @code{me} macro package
  3552. @c XXX documentation
  3553. @c XXX this is a placeholder until we get stuff knocked into shape
  3554. See the @file{meintro.me} and @file{meref.me} documents in
  3555. groff's @file{doc} directory.
  3556. @c =====================================================================
  3557. @node mm, , me, Macro Packages
  3558. @section @file{mm}
  3559. @cindex @code{mm} macro package
  3560. @c XXX documentation
  3561. @c XXX this is a placeholder until we get stuff knocked into shape
  3562. See the @cite{groff_mm(7)} man page (type @command{man groff_mm} at
  3563. the command line).
  3564. @c =====================================================================
  3565. @c =====================================================================
  3566. @node gtroff Reference, Preprocessors, Macro Packages, Top
  3567. @chapter @code{gtroff} Reference
  3568. @cindex reference, @code{gtroff}
  3569. @cindex @code{gtroff}, reference
  3570. This chapter covers @strong{all} of the facilities of @code{gtroff}.
  3571. Users of macro packages may skip it if not interested in details.
  3572. @menu
  3573. * Text::
  3574. * Measurements::
  3575. * Expressions::
  3576. * Identifiers::
  3577. * Embedded Commands::
  3578. * Registers::
  3579. * Manipulating Filling and Adjusting::
  3580. * Manipulating Hyphenation::
  3581. * Manipulating Spacing::
  3582. * Tabs and Fields::
  3583. * Character Translations::
  3584. * Troff and Nroff Mode::
  3585. * Line Layout::
  3586. * Line Control::
  3587. * Page Layout::
  3588. * Page Control::
  3589. * Fonts and Symbols::
  3590. * Sizes::
  3591. * Strings::
  3592. * Conditionals and Loops::
  3593. * Writing Macros::
  3594. * Page Motions::
  3595. * Drawing Requests::
  3596. * Traps::
  3597. * Diversions::
  3598. * Environments::
  3599. * Suppressing output::
  3600. * Colors::
  3601. * I/O::
  3602. * Postprocessor Access::
  3603. * Miscellaneous::
  3604. * Gtroff Internals::
  3605. * Debugging::
  3606. * Implementation Differences::
  3607. @end menu
  3608. @c =====================================================================
  3609. @node Text, Measurements, gtroff Reference, gtroff Reference
  3610. @section Text
  3611. @cindex text, @code{gtroff} processing
  3612. @code{gtroff} input files contain text with control commands
  3613. interspersed throughout. But, even without control codes, @code{gtroff}
  3614. still does several things with the input text:
  3615. @itemize @bullet
  3616. @item
  3617. filling and adjusting
  3618. @item
  3619. adding additional space after sentences
  3620. @item
  3621. hyphenating
  3622. @item
  3623. inserting implicit line breaks
  3624. @end itemize
  3625. @menu
  3626. * Filling and Adjusting::
  3627. * Hyphenation::
  3628. * Sentences::
  3629. * Tab Stops::
  3630. * Implicit Line Breaks::
  3631. * Input Conventions::
  3632. * Input Encodings::
  3633. @end menu
  3634. @c ---------------------------------------------------------------------
  3635. @node Filling and Adjusting, Hyphenation, Text, Text
  3636. @subsection Filling and Adjusting
  3637. @cindex filling
  3638. @cindex adjusting
  3639. When @code{gtroff} reads text, it collects words from the input and fits
  3640. as many of them together on one output line as it can. This is known as
  3641. @dfn{filling}.
  3642. @cindex leading spaces
  3643. @cindex spaces, leading and trailing
  3644. @cindex extra spaces
  3645. @cindex trailing spaces
  3646. Once @code{gtroff} has a @dfn{filled} line, it tries to @dfn{adjust}
  3647. it. This means it widens the spacing between words until the text
  3648. reaches the right margin (in the default adjustment mode). Extra spaces
  3649. between words are preserved, but spaces at the end of lines are ignored.
  3650. Spaces at the front of a line cause a @dfn{break} (breaks are
  3651. explained in @ref{Implicit Line Breaks}).
  3652. @xref{Manipulating Filling and Adjusting}.
  3653. @c ---------------------------------------------------------------------
  3654. @node Hyphenation, Sentences, Filling and Adjusting, Text
  3655. @subsection Hyphenation
  3656. @cindex hyphenation
  3657. Since the odds are not great for finding a set of words, for every
  3658. output line, which fit nicely on a line without inserting excessive
  3659. amounts of space between words, @code{gtroff} hyphenates words so
  3660. that it can justify lines without inserting too much space between
  3661. words. It uses an internal hyphenation algorithm (a simplified version
  3662. of the algorithm used within @TeX{}) to indicate which words can be
  3663. hyphenated and how to do so. When a word is hyphenated, the first part
  3664. of the word is added to the current filled line being output (with
  3665. an attached hyphen), and the other portion is added to the next
  3666. line to be filled.
  3667. @xref{Manipulating Hyphenation}.
  3668. @c ---------------------------------------------------------------------
  3669. @node Sentences, Tab Stops, Hyphenation, Text
  3670. @subsection Sentences
  3671. @cindex sentences
  3672. Although it is often debated, some typesetting rules say there should be
  3673. different amounts of space after various punctuation marks. For
  3674. example, the @cite{Chicago typsetting manual} says that a period at the
  3675. end of a sentence should have twice as much space following it as would
  3676. a comma or a period as part of an abbreviation.
  3677. @c XXX exact citation of Chicago manual
  3678. @cindex sentence space
  3679. @cindex space between sentences
  3680. @cindex french-spacing
  3681. @code{gtroff} does this by flagging certain characters (normally
  3682. @samp{!}, @samp{?}, and @samp{.}) as @dfn{end-of-sentence} characters.
  3683. When @code{gtroff} encounters one of these characters at the end of a
  3684. line, it appends a normal space followed by a @dfn{sentence space} in
  3685. the formatted output. (This justifies one of the conventions mentioned
  3686. in @ref{Input Conventions}.)
  3687. @cindex transparent characters
  3688. @cindex character, transparent
  3689. @cindex @code{dg} glyph, at end of sentence
  3690. @cindex @code{rq} glyph, at end of sentence
  3691. @cindex @code{"}, at end of sentence
  3692. @cindex @code{'}, at end of sentence
  3693. @cindex @code{)}, at end of sentence
  3694. @cindex @code{]}, at end of sentence
  3695. @cindex @code{*}, at end of sentence
  3696. In addition, the following characters and symbols are treated
  3697. transparently while handling end-of-sentence characters: @samp{"},
  3698. @samp{'}, @samp{)}, @samp{]}, @samp{*}, @code{\[dg]}, and @code{\[rq]}.
  3699. See the @code{cflags} request in @ref{Using Symbols}, for more details.
  3700. @cindex @code{\&}, at end of sentence
  3701. To prevent the insertion of extra space after an end-of-sentence
  3702. character (at the end of a line), append @code{\&}.
  3703. @c ---------------------------------------------------------------------
  3704. @node Tab Stops, Implicit Line Breaks, Sentences, Text
  3705. @subsection Tab Stops
  3706. @cindex tab stops
  3707. @cindex stops, tabulator
  3708. @cindex tab character
  3709. @cindex character, tabulator
  3710. @cindex @acronym{EBCDIC} encoding
  3711. @cindex encoding, @acronym{EBCDIC}
  3712. @code{gtroff} translates @dfn{tabulator characters}, also called
  3713. @dfn{tabs} (normally code point @acronym{ASCII} @code{0x09} or
  3714. @acronym{EBCDIC} @code{0x05}), in the input into movements to the next
  3715. tabulator stop. These tab stops are initially located every half inch
  3716. across the page. Using this, simple tables can be made easily.
  3717. However, it can often be deceptive as the appearance (and width) of the
  3718. text on a terminal and the results from @code{gtroff} can vary greatly.
  3719. Also, a possible sticking point is that lines beginning with tab
  3720. characters are still filled, again producing unexpected results.
  3721. For example, the following input
  3722. @multitable {12345678} {12345678} {12345678} {12345678}
  3723. @item
  3724. @tab 1 @tab 2 @tab 3
  3725. @item
  3726. @tab @tab 4 @tab 5
  3727. @end multitable
  3728. @noindent
  3729. produces
  3730. @multitable {12345678} {12345678} {12345678} {12345678} {12345678} {12345678} {12345678}
  3731. @item
  3732. @tab 1 @tab 2 @tab 3 @tab @tab 4 @tab 5
  3733. @end multitable
  3734. @xref{Tabs and Fields}.
  3735. @c ---------------------------------------------------------------------
  3736. @node Implicit Line Breaks, Input Conventions, Tab Stops, Text
  3737. @subsection Implicit Line Breaks
  3738. @cindex implicit line breaks
  3739. @cindex implicit breaks of lines
  3740. @cindex line, implicit breaks
  3741. @cindex break, implicit
  3742. @cindex line break
  3743. An important concept in @code{gtroff} is the @dfn{break}. When a break
  3744. occurs, @code{gtroff} outputs the partially filled line
  3745. (unjustified), and resumes collecting and filling text on the next output
  3746. line.
  3747. @cindex blank line
  3748. @cindex empty line
  3749. @cindex line, blank
  3750. @cindex blank line macro (@code{blm})
  3751. There are several ways to cause a break in @code{gtroff}. A blank
  3752. line not only causes a break, but it also outputs a one-line vertical
  3753. space (effectively a blank line). Note that this behaviour can be
  3754. modified with the blank line macro request @code{blm}.
  3755. @xref{Blank Line Traps}.
  3756. @cindex fill mode
  3757. @cindex mode, fill
  3758. A line that begins with a space causes a break and the space is
  3759. output at the beginning of the next line. Note that this space isn't
  3760. adjusted, even in fill mode.
  3761. The end of file also causes a break -- otherwise the last line of
  3762. the document may vanish!
  3763. Certain requests also cause breaks, implicitly or explicitly. This is
  3764. discussed in @ref{Manipulating Filling and Adjusting}.
  3765. @c ---------------------------------------------------------------------
  3766. @node Input Conventions, Input Encodings, Implicit Line Breaks, Text
  3767. @subsection Input Conventions
  3768. @cindex input conventions
  3769. @cindex conventions for input
  3770. Since @code{gtroff} does filling automatically, it is traditional in
  3771. @code{groff} not to try and type things in as nicely formatted
  3772. paragraphs. These are some conventions commonly used when typing
  3773. @code{gtroff} text:
  3774. @itemize @bullet
  3775. @item
  3776. Break lines after punctuation, particularly at the end of a sentence
  3777. and in other logical places. Keep separate phrases on lines by
  3778. themselves, as entire phrases are often added or deleted when editing.
  3779. @item
  3780. Try to keep lines less than 40-60@tie{}characters, to allow space for
  3781. inserting more text.
  3782. @item
  3783. Do not try to do any formatting in a @acronym{WYSIWYG} manner (i.e.,
  3784. don't try using spaces to get proper indentation).
  3785. @end itemize
  3786. @c ---------------------------------------------------------------------
  3787. @node Input Encodings, , Input Conventions, Text
  3788. @subsection Input Encodings
  3789. Currently, the following input encodings are available.
  3790. @table @asis
  3791. @item cp1047
  3792. @cindex encoding, input, @acronym{EBCDIC}
  3793. @cindex @acronym{EBCDIC}, input encoding
  3794. @cindex input encoding, @acronym{EBCDIC}
  3795. @cindex encoding, input, cp1047
  3796. @cindex cp1047, input encoding
  3797. @cindex input encoding, cp1047
  3798. @cindex IBM cp1047 input encoding
  3799. @pindex cp1047.tmac
  3800. This input encoding works only on @acronym{EBCDIC} platforms (and vice
  3801. versa, the other input encodings don't work with @acronym{EBCDIC}); the
  3802. file @file{cp1047.tmac} is by default loaded at start-up.
  3803. @item latin-1
  3804. @cindex encoding, input, @w{latin-1} (ISO @w{8859-1})
  3805. @cindex @w{latin-1} (ISO @w{8859-1}), input encoding
  3806. @cindex ISO @w{8859-1} (@w{latin-1}), input encoding
  3807. @cindex input encoding, @w{latin-1} (ISO @w{8859-1})
  3808. @pindex latin1.tmac
  3809. This is the default input encoding on non-@acronym{EBCDIC} platforms;
  3810. the file @file{latin1.tmac} is loaded at start-up.
  3811. @item latin-2
  3812. @cindex encoding, input, @w{latin-2} (ISO @w{8859-2})
  3813. @cindex @w{latin-2} (ISO @w{8859-2}), input encoding
  3814. @cindex ISO @w{8859-2} (@w{latin-2}), input encoding
  3815. @cindex input encoding, @w{latin-2} (ISO @w{8859-2})
  3816. @pindex latin2.tmac
  3817. To use this encoding, either say @w{@samp{.mso latin2.tmac}} at the very
  3818. beginning of your document or use @samp{-mlatin2} as a command line
  3819. argument for @code{groff}.
  3820. @item latin-9 (latin-0)
  3821. @cindex encoding, input, @w{latin-9} (@w{latin-0}, ISO @w{8859-15})
  3822. @cindex @w{latin-9} (@w{latin-0}, ISO @w{8859-15}), input encoding
  3823. @cindex ISO @w{8859-15} (@w{latin-9}, @w{latin-0}), input encoding
  3824. @cindex input encoding, @w{latin-9} (@w{latin-9}, ISO @w{8859-15})
  3825. @pindex latin9.tmac
  3826. This encoding is intended (at least in Europe) to replace @w{latin-1}
  3827. encoding. The main difference to @w{latin-1} is that @w{latin-9}
  3828. contains the Euro character. To use this encoding, either say
  3829. @w{@samp{.mso latin9.tmac}} at the very beginning of your document or
  3830. use @samp{-mlatin9} as a command line argument for @code{groff}.
  3831. @end table
  3832. Note that it can happen that some input encoding characters are not
  3833. available for a particular output device. For example, saying
  3834. @Example
  3835. groff -Tlatin1 -mlatin9 ...
  3836. @endExample
  3837. @noindent
  3838. will fail if you use the Euro character in the input. Usually, this
  3839. limitation is present only for devices which have a limited set of
  3840. output glyphs (e.g.@: @option{-Tascii} and @option{-Tlatin1}); for other
  3841. devices it is usually sufficient to install proper fonts which contain
  3842. the necessary glyphs.
  3843. @pindex freeeuro.pfa
  3844. @pindex ec.tmac
  3845. Due to the importance of the Euro glyph in Europe, the groff package now
  3846. comes with a @sc{PostScript} font called @file{freeeuro.pfa} which
  3847. provides various glyph shapes for the Euro. With other words,
  3848. @w{latin-9} encoding is supported for the @option{-Tps} device out of
  3849. the box (@w{latin-2} isn't).
  3850. By its very nature, @option{-Tutf8} supports all input encodings;
  3851. @option{-Tdvi} has support for both @w{latin-2} and @w{latin-9} if the
  3852. command line @option{-mec} is used also to load the file @file{ec.tmac}
  3853. (which flips to the EC fonts).
  3854. @c =====================================================================
  3855. @node Measurements, Expressions, Text, gtroff Reference
  3856. @section Measurements
  3857. @cindex measurements
  3858. @cindex units of measurement
  3859. @cindex basic unit (@code{u})
  3860. @cindex machine unit (@code{u})
  3861. @cindex measurement unit
  3862. @cindex @code{u} unit
  3863. @cindex unit, @code{u}
  3864. @code{gtroff} (like many other programs) requires numeric parameters to
  3865. specify various measurements. Most numeric parameters@footnote{those
  3866. that specify vertical or horizontal motion or a type size} may have a
  3867. @dfn{measurement unit} attached. These units are specified as a single
  3868. character which immediately follows the number or expression. Each of
  3869. these units are understood, by @code{gtroff}, to be a multiple of its
  3870. @dfn{basic unit}. So, whenever a different measurement unit is
  3871. specified @code{gtroff} converts this into its @dfn{basic units}. This
  3872. basic unit, represented by a @samp{u}, is a device dependent measurement
  3873. which is quite small, ranging from 1/75@dmn{th} to 1/72000@dmn{th} of an
  3874. inch. The values may be given as fractional numbers; however,
  3875. fractional basic units are always rounded to integers.
  3876. Some of the measurement units are completely independent of any of the
  3877. current settings (e.g.@: type size) of @code{gtroff}.
  3878. @table @code
  3879. @item i
  3880. @cindex inch unit (@code{i})
  3881. @cindex @code{i} unit
  3882. @cindex unit, @code{i}
  3883. Inches. An antiquated measurement unit still in use in certain
  3884. backwards countries with incredibly low-cost computer equipment. One
  3885. inch is equal to@tie{}2.54@dmn{cm}.
  3886. @item c
  3887. @cindex centimeter unit (@code{c})
  3888. @cindex @code{c} unit
  3889. @cindex unit, @code{c}
  3890. Centimeters. One centimeter is equal to@tie{}0.3937@dmn{in}.
  3891. @item p
  3892. @cindex point unit (@code{p})
  3893. @cindex @code{p} unit
  3894. @cindex unit, @code{p}
  3895. Points. This is a typesetter's measurement used for measure type size.
  3896. It is 72@tie{}points to an inch.
  3897. @item P
  3898. @cindex pica unit (@code{P})
  3899. @cindex @code{P} unit
  3900. @cindex unit, @code{P}
  3901. Pica. Another typesetting measurement. 6@tie{}Picas to an inch (and
  3902. 12@tie{}points to a pica).
  3903. @item s
  3904. @itemx z
  3905. @cindex @code{s} unit
  3906. @cindex unit, @code{s}
  3907. @cindex @code{z} unit
  3908. @cindex unit, @code{z}
  3909. @xref{Fractional Type Sizes}, for a discussion of these units.
  3910. @item f
  3911. @cindex @code{f} unit
  3912. @cindex unit, @code{f}
  3913. Fractions. Value is 65536.
  3914. @xref{Colors}, for usage.
  3915. @end table
  3916. The other measurements understood by @code{gtroff} depend on
  3917. settings currently in effect in @code{gtroff}. These are very useful
  3918. for specifying measurements which should look proper with any size of
  3919. text.
  3920. @table @code
  3921. @item m
  3922. @cindex em unit (@code{m})
  3923. @cindex @code{m} unit
  3924. @cindex unit, @code{m}
  3925. Ems. This unit is equal to the current font size in points. So called
  3926. because it is @emph{approximately} the width of the letter@tie{}@samp{m}
  3927. in the current font.
  3928. @item n
  3929. @cindex en unit (@code{n})
  3930. @cindex @code{n} unit
  3931. @cindex unit, @code{n}
  3932. Ens. In @code{groff}, this is half of an em.
  3933. @item v
  3934. @cindex vertical space unit (@code{v})
  3935. @cindex space, vertical, unit (@code{v})
  3936. @cindex @code{v} unit
  3937. @cindex unit, @code{v}
  3938. Vertical space. This is equivalent to the current line spacing.
  3939. @xref{Sizes}, for more information about this.
  3940. @item M
  3941. @cindex @code{M} unit
  3942. @cindex unit, @code{M}
  3943. 100ths of an em.
  3944. @end table
  3945. @menu
  3946. * Default Units::
  3947. @end menu
  3948. @c ---------------------------------------------------------------------
  3949. @node Default Units, , Measurements, Measurements
  3950. @subsection Default Units
  3951. @cindex default units
  3952. @cindex units, default
  3953. Many requests take a default unit. While this can be helpful at times,
  3954. it can cause strange errors in some expressions. For example, the line
  3955. length request expects em units. Here are several attempts to get a
  3956. line length of 3.5@tie{}inches and their results:
  3957. @Example
  3958. 3.5i @result{} 3.5i
  3959. 7/2 @result{} 0i
  3960. 7/2i @result{} 0i
  3961. (7 / 2)u @result{} 0i
  3962. 7i/2 @result{} 0.1i
  3963. 7i/2u @result{} 3.5i
  3964. @endExample
  3965. @noindent
  3966. Everything is converted to basic units first. In the above example it
  3967. is assumed that 1@dmn{i} equals@tie{}240@dmn{u}, and 1@dmn{m}
  3968. equals@tie{}10@dmn{p} (thus 1@dmn{m} equals@tie{}33@dmn{u}). The value
  3969. 7@dmn{i}/2 is first handled as 7@dmn{i}/2@dmn{m}, then converted to
  3970. 1680@dmn{u}/66@dmn{u} which is 25@dmn{u}, and this is approximately
  3971. 0.1@dmn{i}. As can be seen, a scaling indicator after a closing
  3972. parenthesis is simply ignored.
  3973. @cindex measurements, specifying safely
  3974. Thus, the safest way to specify measurements is to always
  3975. attach a scaling indicator. If you want to multiply or divide by a
  3976. certain scalar value, use @samp{u} as the unit for that value.
  3977. @c =====================================================================
  3978. @node Expressions, Identifiers, Measurements, gtroff Reference
  3979. @section Expressions
  3980. @cindex expressions
  3981. @code{gtroff} has most arithmetic operators common to other languages:
  3982. @itemize @bullet
  3983. @item
  3984. @cindex arithmetic operators
  3985. @cindex operators, arithmetic
  3986. @opindex +
  3987. @opindex -
  3988. @opindex /
  3989. @opindex *
  3990. @opindex %
  3991. Arithmetic: @samp{+} (addition), @samp{-} (subtraction), @samp{/}
  3992. (division), @samp{*} (multiplication), @samp{%} (modulo).
  3993. @code{gtroff} only provides integer arithmetic. The internal type used
  3994. for computing results is @samp{int}, which is usually a 32@dmn{bit}
  3995. signed integer.
  3996. @item
  3997. @cindex comparison operators
  3998. @cindex operators, comparison
  3999. @opindex <
  4000. @opindex >
  4001. @opindex >=
  4002. @opindex <=
  4003. @opindex =
  4004. @opindex ==
  4005. Comparison: @samp{<} (less than), @samp{>} (greater than), @samp{<=}
  4006. (less than or equal), @samp{>=} (greater than or equal), @samp{=}
  4007. (equal), @samp{==} (the same as @samp{=}).
  4008. @item
  4009. @cindex logical operators
  4010. @cindex operators, logical
  4011. @opindex &
  4012. @ifnotinfo
  4013. @opindex :
  4014. @end ifnotinfo
  4015. @ifinfo
  4016. @opindex @r{<colon>}
  4017. @end ifinfo
  4018. Logical: @samp{&} (logical and), @samp{:} (logical or).
  4019. @item
  4020. @cindex unary operators
  4021. @cindex operators, unary
  4022. @opindex -
  4023. @opindex +
  4024. @opindex !
  4025. @cindex @code{if} request, and the @samp{!} operator
  4026. @cindex @code{while} request, and the @samp{!} operator
  4027. Unary operators: @samp{-} (negating, i.e.@: changing the sign), @samp{+}
  4028. (just for completeness; does nothing in expressions), @samp{!} (logical
  4029. not; this works only within @code{if} and @code{while} requests). See
  4030. below for the use of unary operators in motion requests.
  4031. @item
  4032. @cindex extremum operators (@code{>?}, @code{<?})
  4033. @cindex operators, extremum (@code{>?}, @code{<?})
  4034. @opindex >?
  4035. @opindex <?
  4036. Extrema: @samp{>?} (maximum), @samp{<?} (minimum).
  4037. Example:
  4038. @Example
  4039. .nr x 5
  4040. .nr y 3
  4041. .nr z (\n[x] >? \n[y])
  4042. @endExample
  4043. @noindent
  4044. The register@tie{}@code{z} now contains@tie{}5.
  4045. @item
  4046. @cindex scaling operator
  4047. @cindex operator, scaling
  4048. Scaling: @code{(@var{c};@var{e})}. Evaluate@tie{}@var{e} using@tie{}@var{c}
  4049. as the default scaling indicator. If @var{c} is missing, ignore scaling
  4050. indicators in the evaluation of@tie{}@var{e}.
  4051. @end itemize
  4052. @cindex parentheses
  4053. @cindex order of evaluation in expressions
  4054. @cindex expression, order of evaluation
  4055. @opindex (
  4056. @opindex )
  4057. Parentheses may be used as in any other language. However, in
  4058. @code{gtroff} they are necessary to ensure order of evaluation.
  4059. @code{gtroff} has no operator precedence; expressions are evaluated left
  4060. to right. This means that @code{gtroff} evaluates @samp{3+5*4} as if it were
  4061. parenthesized like @samp{(3+5)*4}, not as @samp{3+(5*4)}, as might be
  4062. expected.
  4063. @cindex @code{+}, and page motion
  4064. @cindex @code{-}, and page motion
  4065. @cindex motion operators
  4066. @cindex operators, motion
  4067. For many requests which cause a motion on the page, the unary operators
  4068. @samp{+} and @samp{-} work differently if leading an expression. They
  4069. then indicate a motion relative to the current position (down or up,
  4070. respectively).
  4071. @cindex @code{|}, and page motion
  4072. @cindex absolute position operator (@code{|})
  4073. @cindex position, absolute, operator (@code{|})
  4074. Similarly, a leading @samp{|} operator indicates an absolute position.
  4075. For vertical movements, it specifies the distance from the top of the
  4076. page; for horizontal movements, it gives the distance from the beginning
  4077. of the @emph{input} line.
  4078. @cindex @code{bp} request, using @code{+} and@tie{}@code{-}
  4079. @cindex @code{in} request, using @code{+} and@tie{}@code{-}
  4080. @cindex @code{ll} request, using @code{+} and@tie{}@code{-}
  4081. @cindex @code{lt} request, using @code{+} and@tie{}@code{-}
  4082. @cindex @code{nm} request, using @code{+} and@tie{}@code{-}
  4083. @cindex @code{nr} request, using @code{+} and@tie{}@code{-}
  4084. @cindex @code{pl} request, using @code{+} and@tie{}@code{-}
  4085. @cindex @code{pn} request, using @code{+} and@tie{}@code{-}
  4086. @cindex @code{po} request, using @code{+} and@tie{}@code{-}
  4087. @cindex @code{ps} request, using @code{+} and@tie{}@code{-}
  4088. @cindex @code{pvs} request, using @code{+} and@tie{}@code{-}
  4089. @cindex @code{rt} request, using @code{+} and@tie{}@code{-}
  4090. @cindex @code{ti} request, using @code{+} and@tie{}@code{-}
  4091. @cindex @code{\H}, using @code{+} and@tie{}@code{-}
  4092. @cindex @code{\R}, using @code{+} and@tie{}@code{-}
  4093. @cindex @code{\s}, using @code{+} and@tie{}@code{-}
  4094. @samp{+} and @samp{-} are also treated differently by the following
  4095. requests and escapes: @code{bp}, @code{in}, @code{ll}, @code{lt},
  4096. @code{nm}, @code{nr}, @code{pl}, @code{pn}, @code{po}, @code{ps},
  4097. @code{pvs}, @code{rt}, @code{ti}, @code{\H}, @code{\R}, and @code{\s}.
  4098. Here, leading plus and minus signs indicate increments and decrements.
  4099. @xref{Setting Registers}, for some examples.
  4100. @Defesc {\\B, ', anything, '}
  4101. @cindex numeric expression, valid
  4102. @cindex valid numeric expression
  4103. Return@tie{}1 if @var{anything} is a valid numeric expression;
  4104. or@tie{}0 if @var{anything} is empty or not a valid numeric expression.
  4105. @endDefesc
  4106. @cindex space characters, in expressions
  4107. @cindex expressions, and space characters
  4108. Due to the way arguments are parsed, spaces are not allowed in
  4109. expressions, unless the entire expression is surrounded by parentheses.
  4110. @xref{Request and Macro Arguments}, and @ref{Conditionals and Loops}.
  4111. @c =====================================================================
  4112. @node Identifiers, Embedded Commands, Expressions, gtroff Reference
  4113. @section Identifiers
  4114. @cindex identifiers
  4115. Like any other language, @code{gtroff} has rules for properly formed
  4116. @dfn{identifiers}. In @code{gtroff}, an identifier can be made up of
  4117. almost any printable character, with the exception of the following
  4118. characters:
  4119. @itemize @bullet
  4120. @item
  4121. @cindex whitespace characters
  4122. @cindex newline character
  4123. @cindex character, whitespace
  4124. Whitespace characters (spaces, tabs, and newlines).
  4125. @item
  4126. @cindex character, backspace
  4127. @cindex backspace character
  4128. @cindex @acronym{EBCDIC} encoding of backspace
  4129. Backspace (@acronym{ASCII}@tie{}@code{0x08} or
  4130. @acronym{EBCDIC}@tie{}@code{0x16}) and character code @code{0x01}.
  4131. @item
  4132. @cindex invalid input characters
  4133. @cindex input characters, invalid
  4134. @cindex characters, invalid input
  4135. @cindex Unicode
  4136. The following input characters are invalid and are ignored if
  4137. @code{groff} runs on a machine based on @acronym{ASCII}, causing a
  4138. warning message of type @samp{input} (see @ref{Debugging}, for more
  4139. details): @code{0x00}, @code{0x0B}, @code{0x0D}-@code{0x1F},
  4140. @code{0x80}-@code{0x9F}.
  4141. And here are the invalid input characters if @code{groff} runs on an
  4142. @acronym{EBCDIC} host: @code{0x00}, @code{0x08}, @code{0x09},
  4143. @code{0x0B}, @code{0x0D}-@code{0x14}, @code{0x17}-@code{0x1F},
  4144. @code{0x30}-@code{0x3F}.
  4145. Currently, some of these reserved codepoints are used internally, thus
  4146. making it non-trivial to extend @code{gtroff} to cover Unicode or other
  4147. character sets and encodings which use characters of these ranges.
  4148. Note that invalid characters are removed before parsing; an
  4149. identifier @code{foo}, followed by an invalid character, followed by
  4150. @code{bar} is treated as @code{foobar}.
  4151. @end itemize
  4152. For example, any of the following is valid.
  4153. @Example
  4154. br
  4155. PP
  4156. (l
  4157. end-list
  4158. @@_
  4159. @endExample
  4160. @cindex @code{]}, as part of an identifier
  4161. @noindent
  4162. Note that identifiers longer than two characters with a closing bracket
  4163. (@samp{]}) in its name can't be accessed with escape sequences which
  4164. expect an identifier as a parameter. For example, @samp{\[foo]]}
  4165. accesses the glyph @samp{foo}, followed by @samp{]}, whereas
  4166. @samp{\C'foo]'} really asks for glyph @samp{foo]}.
  4167. @cindex @code{refer}, and macro names starting with @code{[} or @code{]}
  4168. @cindex @code{[}, macro names starting with, and @code{refer}
  4169. @cindex @code{]}, macro names starting with, and @code{refer}
  4170. @cindex macro names, starting with @code{[} or @code{]}, and @code{refer}
  4171. To avoid problems with the @code{refer} preprocessor, macro names
  4172. should not start with @samp{[} or @samp{]}. Due to backwards
  4173. compatibility, everything after @samp{.[} and @samp{.]} is handled as
  4174. a special argument to @code{refer}. For example, @samp{.[foo} makes
  4175. @code{refer} to start a reference, using @samp{foo} as a parameter.
  4176. @Defesc {\\A, ', ident, '}
  4177. Test whether an identifier @var{ident} is valid in @code{gtroff}. It
  4178. expands to the character@tie{}1 or@tie{}0 according to whether its
  4179. argument (usually delimited by quotes) is or is not acceptable as the
  4180. name of a string, macro, diversion, number register, environment, or
  4181. font. It returns@tie{}0 if no argument is given. This is useful for
  4182. looking up user input in some sort of associative table.
  4183. @Example
  4184. \A'end-list'
  4185. @result{} 1
  4186. @endExample
  4187. @endDefesc
  4188. @xref{Escapes}, for details on parameter delimiting characters.
  4189. Identifiers in @code{gtroff} can be any length, but, in some contexts,
  4190. @code{gtroff} needs to be told where identifiers end and text begins
  4191. (and in different ways depending on their length):
  4192. @itemize @bullet
  4193. @item
  4194. Single character.
  4195. @cindex @code{(}, starting a two-character identifier
  4196. @item
  4197. Two characters. Must be prefixed with @samp{(} in some situations.
  4198. @cindex @code{[}, starting an identifier
  4199. @cindex @code{]}, ending an identifier
  4200. @item
  4201. Arbitrary length (@code{gtroff} only). Must be bracketed with @samp{[}
  4202. and@tie{}@samp{]} in some situations. Any length identifier can be put
  4203. in brackets.
  4204. @end itemize
  4205. @cindex undefined identifiers
  4206. @cindex identifiers, undefined
  4207. Unlike many other programming languages, undefined identifiers are
  4208. silently ignored or expanded to nothing.
  4209. When @code{gtroff} finds an undefined identifier, it emits a
  4210. warning, doing the following:
  4211. @itemize @bullet
  4212. @item
  4213. If the identifier is a string, macro, or diversion,
  4214. @code{gtroff} defines it as empty.
  4215. @item
  4216. If the identifier is a number register, @code{gtroff}
  4217. defines it with a value of@tie{}0.
  4218. @end itemize
  4219. @xref{Warnings}., @ref{Interpolating Registers}, and @ref{Strings}.
  4220. Note that macros, strings, and diversions share the same name space.
  4221. @Example
  4222. .de xxx
  4223. . nop foo
  4224. ..
  4225. .
  4226. .di xxx
  4227. bar
  4228. .br
  4229. .di
  4230. .
  4231. .xxx
  4232. @result{} bar
  4233. @endExample
  4234. @noindent
  4235. As can be seen in the previous example, @code{gtroff} reuses the
  4236. identifier @samp{xxx}, changing it from a macro to a diversion.
  4237. No warning is emitted! The contents of the first macro definition is
  4238. lost.
  4239. @xref{Interpolating Registers}, and @ref{Strings}.
  4240. @c =====================================================================
  4241. @node Embedded Commands, Registers, Identifiers, gtroff Reference
  4242. @section Embedded Commands
  4243. @cindex embedded commands
  4244. @cindex commands, embedded
  4245. Most documents need more functionality beyond filling, adjusting and
  4246. implicit line breaking. In order to gain further functionality,
  4247. @code{gtroff} allows commands to be embedded into the text, in two ways.
  4248. The first is a @dfn{request} which takes up an entire line, and does
  4249. some large-scale operation (e.g.@: break lines, start new pages).
  4250. The other is an @dfn{escape} which can be usually embedded anywhere
  4251. in the text; most requests can accept it even as an argument.
  4252. Escapes generally do more minor operations like sub- and superscripts,
  4253. print a symbol, etc.
  4254. @menu
  4255. * Requests::
  4256. * Macros::
  4257. * Escapes::
  4258. @end menu
  4259. @c ---------------------------------------------------------------------
  4260. @node Requests, Macros, Embedded Commands, Embedded Commands
  4261. @subsection Requests
  4262. @cindex requests
  4263. @cindex control character (@code{.})
  4264. @cindex character, control (@code{.})
  4265. @cindex no-break control character (@code{'})
  4266. @cindex character, no-break control (@code{'})
  4267. @cindex control character, no-break (@code{'})
  4268. A request line begins with a control character, which is either a single
  4269. quote (@samp{'}, the @dfn{no-break control character}) or a period
  4270. (@samp{.}, the normal @dfn{control character}). These can be changed;
  4271. see @ref{Character Translations}, for details. After this there may be
  4272. optional tabs or spaces followed by an identifier which is the name of
  4273. the request. This may be followed by any number of space-separated
  4274. arguments (@emph{no} tabs here).
  4275. @cindex structuring source code of documents or macro packages
  4276. @cindex documents, structuring the source code
  4277. @cindex macro packages, structuring the source code
  4278. Since a control character followed by whitespace only is ignored, it
  4279. is common practice to use this feature for structuring the source code
  4280. of documents or macro packages.
  4281. @Example
  4282. .de foo
  4283. . tm This is foo.
  4284. ..
  4285. .
  4286. .
  4287. .de bar
  4288. . tm This is bar.
  4289. ..
  4290. @endExample
  4291. @cindex blank line
  4292. @cindex blank line macro (@code{blm})
  4293. Another possibility is to use the blank line macro request @code{blm}
  4294. by assigning an empty macro to it.
  4295. @Example
  4296. .de do-nothing
  4297. ..
  4298. .blm do-nothing \" activate blank line macro
  4299. .de foo
  4300. . tm This is foo.
  4301. ..
  4302. .de bar
  4303. . tm This is bar.
  4304. ..
  4305. .blm \" deactivate blank line macro
  4306. @endExample
  4307. @xref{Blank Line Traps}.
  4308. @cindex zero width space character (@code{\&})
  4309. @cindex character, zero width space (@code{\&})
  4310. @cindex space character, zero width (@code{\&})
  4311. @cindex @code{\&}, escaping control characters
  4312. To begin a line with a control character without it being interpreted,
  4313. precede it with @code{\&}. This represents a zero width space, which
  4314. means it does not affect the output.
  4315. In most cases the period is used as a control character. Several
  4316. requests cause a break implicitly; using the single quote control
  4317. character prevents this.
  4318. @menu
  4319. * Request and Macro Arguments::
  4320. @end menu
  4321. @node Request and Macro Arguments, , Requests, Requests
  4322. @subsubsection Request and Macro Arguments
  4323. @cindex request arguments
  4324. @cindex macro arguments
  4325. @cindex arguments to requests and macros
  4326. Arguments to requests and macros are processed much like the shell:
  4327. The line is split into arguments according to
  4328. spaces.@footnote{Plan@tie{}9's @code{troff} implementation also allows
  4329. tabs for argument separation -- @code{gtroff} intentionally doesn't
  4330. support this.}
  4331. @cindex spaces, in a macro argument
  4332. An argument to a macro which is intended to contain spaces can either be
  4333. enclosed in double quotes, or have the spaces @dfn{escaped} with
  4334. backslashes. This is @emph{not} true for requests.
  4335. Here are a few examples for a hypothetical macro @code{uh}:
  4336. @Example
  4337. .uh The Mouse Problem
  4338. .uh "The Mouse Problem"
  4339. .uh The\ Mouse\ Problem
  4340. @endExample
  4341. @cindex @code{\~}, difference to @code{\@key{SP}}
  4342. @cindex @code{\@key{SP}}, difference to @code{\~}
  4343. @noindent
  4344. The first line is the @code{uh} macro being called with 3 arguments,
  4345. @samp{The}, @samp{Mouse}, and @samp{Problem}. The latter two have the
  4346. same effect of calling the @code{uh} macro with one argument, @samp{The
  4347. Mouse Problem}.@footnote{The last solution, i.e., using escaped spaces,
  4348. is ``classical'' in the sense that it can be found in most @code{troff}
  4349. documents. Nevertheless, it is not optimal in all situations, since
  4350. @w{@samp{\ }} inserts a fixed-width, non-breaking space character which
  4351. can't stretch. @code{gtroff} provides a different command @code{\~} to
  4352. insert a stretchable, non-breaking space.}
  4353. @cindex @code{"}, in a macro argument
  4354. @cindex double quote, in a macro argument
  4355. A double quote which isn't preceded by a space doesn't start a macro
  4356. argument. If not closing a string, it is printed literally.
  4357. For example,
  4358. @Example
  4359. .xxx a" "b c" "de"fg"
  4360. @endExample
  4361. @noindent
  4362. has the arguments @samp{a"}, @w{@samp{b c}}, @samp{de}, and @samp{fg"}.
  4363. Don't rely on this obscure behaviour!
  4364. There are two possibilities to get a double quote reliably.
  4365. @itemize @bullet
  4366. @item
  4367. Enclose the whole argument with double quotes and use two consecutive double
  4368. quotes to represent a single one. This traditional solution has the
  4369. disadvantage that double quotes don't survive argument expansion again if
  4370. called in compatibility mode (using the @option{-C} option of @code{groff}):
  4371. @Example
  4372. .de xx
  4373. . tm xx: `\\$1' `\\$2' `\\$3'
  4374. .
  4375. . yy "\\$1" "\\$2" "\\$3"
  4376. ..
  4377. .de yy
  4378. . tm yy: `\\$1' `\\$2' `\\$3'
  4379. ..
  4380. .xx A "test with ""quotes""" .
  4381. @result{} xx: `A' `test with "quotes"' `.'
  4382. @result{} yy: `A' `test with ' `quotes""'
  4383. @endExample
  4384. @noindent
  4385. If not in compatibility mode, you get the expected result
  4386. @Example
  4387. xx: `A' `test with "quotes"' `.'
  4388. yy: `A' `test with "quotes"' `.'
  4389. @endExample
  4390. @noindent
  4391. since @code{gtroff} preserves the input level.
  4392. @item
  4393. Use the double quote glyph @code{\(dq}. This works with and without
  4394. compatibility mode enabled since @code{gtroff} doesn't convert @code{\(dq}
  4395. back to a double quote input character.
  4396. Not that this method won't work with @acronym{UNIX} @code{troff} in general
  4397. since the glyph `dq' isn't defined normally.
  4398. @end itemize
  4399. @cindex @code{ds} request, and double quotes
  4400. Double quotes in the @code{ds} request are handled differently.
  4401. @xref{Strings}, for more details.
  4402. @c ---------------------------------------------------------------------
  4403. @node Macros, Escapes, Requests, Embedded Commands
  4404. @subsection Macros
  4405. @cindex macros
  4406. @code{gtroff} has a @dfn{macro} facility for defining a series of lines
  4407. which can be invoked by name. They are called in the same manner as
  4408. requests -- arguments also may be passed basically in the same manner.
  4409. @xref{Writing Macros}, and @ref{Request and Macro Arguments}.
  4410. @c ---------------------------------------------------------------------
  4411. @node Escapes, , Macros, Embedded Commands
  4412. @subsection Escapes
  4413. @cindex escapes
  4414. Escapes may occur anywhere in the input to @code{gtroff}. They usually
  4415. begin with a backslash and are followed by a single character which
  4416. indicates the function to be performed. The escape character can be
  4417. changed; see @ref{Character Translations}.
  4418. Escape sequences which require an identifier as a parameter accept three
  4419. possible syntax forms.
  4420. @itemize @bullet
  4421. @item
  4422. The next single character is the identifier.
  4423. @cindex @code{(}, starting a two-character identifier
  4424. @item
  4425. If this single character is an opening parenthesis, take the following
  4426. two characters as the identifier. Note that there is no closing
  4427. parenthesis after the identifier.
  4428. @cindex @code{[}, starting an identifier
  4429. @cindex @code{]}, ending an identifier
  4430. @item
  4431. If this single character is an opening bracket, take all characters
  4432. until a closing bracket as the identifier.
  4433. @end itemize
  4434. @noindent
  4435. Examples:
  4436. @Example
  4437. \fB
  4438. \n(XX
  4439. \*[TeX]
  4440. @endExample
  4441. @cindex @code{'}, delimiting arguments
  4442. @cindex argument delimiting characters
  4443. @cindex characters, argument delimiting
  4444. @cindex delimiting characters for arguments
  4445. Other escapes may require several arguments and/or some special format.
  4446. In such cases the argument is traditionally enclosed in single quotes
  4447. (and quotes are always used in this manual for the definitions of escape
  4448. sequences). The enclosed text is then processed according to what that
  4449. escape expects. Example:
  4450. @Example
  4451. \l'1.5i\(bu'
  4452. @endExample
  4453. @cindex @code{\o}, possible quote characters
  4454. @cindex @code{\b}, possible quote characters
  4455. @cindex @code{\X}, possible quote characters
  4456. Note that the quote character can be replaced with any other character
  4457. which does not occur in the argument (even a newline or a space
  4458. character) in the following escapes: @code{\o}, @code{\b}, and
  4459. @code{\X}. This makes e.g.
  4460. @Example
  4461. A caf
  4462. \o
  4463. e\'
  4464. in Paris
  4465. @result{} A café in Paris
  4466. @endExample
  4467. @noindent
  4468. possible, but it is better not to use this feature to avoid confusion.
  4469. @cindex @code{\%}, used as delimiter
  4470. @cindex @code{\@key{SP}}, used as delimiter
  4471. @cindex @code{\|}, used as delimiter
  4472. @cindex @code{\^}, used as delimiter
  4473. @cindex @code{\@{}, used as delimiter
  4474. @cindex @code{\@}}, used as delimiter
  4475. @cindex @code{\'}, used as delimiter
  4476. @cindex @code{\`}, used as delimiter
  4477. @cindex @code{\-}, used as delimiter
  4478. @cindex @code{\_}, used as delimiter
  4479. @cindex @code{\!}, used as delimiter
  4480. @cindex @code{\?}, used as delimiter
  4481. @cindex @code{\@@}, used as delimiter
  4482. @cindex @code{\)}, used as delimiter
  4483. @cindex @code{\/}, used as delimiter
  4484. @cindex @code{\,}, used as delimiter
  4485. @cindex @code{\&}, used as delimiter
  4486. @ifnotinfo
  4487. @cindex @code{\:}, used as delimiter
  4488. @end ifnotinfo
  4489. @ifinfo
  4490. @cindex @code{\@r{<colon>}}, used as delimiter
  4491. @end ifinfo
  4492. @cindex @code{\~}, used as delimiter
  4493. @cindex @code{\0}, used as delimiter
  4494. @cindex @code{\a}, used as delimiter
  4495. @cindex @code{\c}, used as delimiter
  4496. @cindex @code{\d}, used as delimiter
  4497. @cindex @code{\e}, used as delimiter
  4498. @cindex @code{\E}, used as delimiter
  4499. @cindex @code{\p}, used as delimiter
  4500. @cindex @code{\r}, used as delimiter
  4501. @cindex @code{\t}, used as delimiter
  4502. @cindex @code{\u}, used as delimiter
  4503. The following escapes sequences (which are handled similarly to
  4504. characters since they don't take a parameter) are also allowed as
  4505. delimiters: @code{\%}, @w{@samp{\ }}, @code{\|}, @code{\^}, @code{\@{},
  4506. @code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
  4507. @code{\?}, @code{\@@}, @code{\)}, @code{\/}, @code{\,}, @code{\&},
  4508. @code{\:}, @code{\~}, @code{\0}, @code{\a}, @code{\c}, @code{\d},
  4509. @code{\e}, @code{\E}, @code{\p}, @code{\r}, @code{\t}, and @code{\u}.
  4510. Again, don't use these if possible.
  4511. @cindex @code{\A}, allowed delimiters
  4512. @cindex @code{\B}, allowed delimiters
  4513. @cindex @code{\Z}, allowed delimiters
  4514. @cindex @code{\C}, allowed delimiters
  4515. @cindex @code{\w}, allowed delimiters
  4516. No newline characters as delimiters are allowed in the following
  4517. escapes: @code{\A}, @code{\B}, @code{\Z}, @code{\C}, and @code{\w}.
  4518. @cindex @code{\D}, allowed delimiters
  4519. @cindex @code{\h}, allowed delimiters
  4520. @cindex @code{\H}, allowed delimiters
  4521. @cindex @code{\l}, allowed delimiters
  4522. @cindex @code{\L}, allowed delimiters
  4523. @cindex @code{\N}, allowed delimiters
  4524. @cindex @code{\R}, allowed delimiters
  4525. @cindex @code{\s}, allowed delimiters
  4526. @cindex @code{\S}, allowed delimiters
  4527. @cindex @code{\v}, allowed delimiters
  4528. @cindex @code{\x}, allowed delimiters
  4529. Finally, the escapes @code{\D}, @code{\h}, @code{\H}, @code{\l},
  4530. @code{\L}, @code{\N}, @code{\R}, @code{\s}, @code{\S}, @code{\v},
  4531. and @code{\x} can't use the following characters as delimiters:
  4532. @itemize @bullet
  4533. @item
  4534. @cindex numbers, and delimiters
  4535. @cindex digits, and delimiters
  4536. The digits @code{0}-@code{9}.
  4537. @item
  4538. @cindex operators, as delimiters
  4539. @cindex @code{+}, as delimiter
  4540. @cindex @code{-}, as delimiter
  4541. @cindex @code{/}, as delimiter
  4542. @cindex @code{*}, as delimiter
  4543. @cindex @code{%}, as delimiter
  4544. @cindex @code{<}, as delimiter
  4545. @cindex @code{>}, as delimiter
  4546. @cindex @code{=}, as delimiter
  4547. @cindex @code{&}, as delimiter
  4548. @ifnotinfo
  4549. @cindex @code{:}, as delimiter
  4550. @end ifnotinfo
  4551. @ifinfo
  4552. @cindex <colon>, as delimiter
  4553. @end ifinfo
  4554. @cindex @code{(}, as delimiter
  4555. @cindex @code{)}, as delimiter
  4556. @cindex @code{.}, as delimiter
  4557. The (single-character) operators @samp{+-/*%<>=&:().}.
  4558. @item
  4559. @cindex space character
  4560. @cindex character, space
  4561. @cindex tab character
  4562. @cindex character, tab
  4563. @cindex newline character
  4564. @cindex character, newline
  4565. The space, tab, and newline characters.
  4566. @item
  4567. @cindex @code{\%}, used as delimiter
  4568. @ifnotinfo
  4569. @cindex @code{\:}, used as delimiter
  4570. @end ifnotinfo
  4571. @ifinfo
  4572. @cindex @code{\@r{<colon>}}, used as delimiter
  4573. @end ifinfo
  4574. @cindex @code{\@{}, used as delimiter
  4575. @cindex @code{\@}}, used as delimiter
  4576. @cindex @code{\'}, used as delimiter
  4577. @cindex @code{\`}, used as delimiter
  4578. @cindex @code{\-}, used as delimiter
  4579. @cindex @code{\_}, used as delimiter
  4580. @cindex @code{\!}, used as delimiter
  4581. @cindex @code{\@@}, used as delimiter
  4582. @cindex @code{\/}, used as delimiter
  4583. @cindex @code{\c}, used as delimiter
  4584. @cindex @code{\e}, used as delimiter
  4585. @cindex @code{\p}, used as delimiter
  4586. All escape sequences except @code{\%}, @code{\:}, @code{\@{}, @code{\@}},
  4587. @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!}, @code{\@@},
  4588. @code{\/}, @code{\c}, @code{\e}, and @code{\p}.
  4589. @end itemize
  4590. @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
  4591. @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
  4592. To have a backslash (actually, the current escape character) appear in the
  4593. output several escapes are defined: @code{\\}, @code{\e} or @code{\E}.
  4594. These are very similar, and only differ with respect to being used in
  4595. macros or diversions. @xref{Character Translations}, for an exact
  4596. description of those escapes.
  4597. @xref{Implementation Differences}, @ref{Copy-in Mode}, and @ref{Diversions},
  4598. @ref{Identifiers}, for more information.
  4599. @menu
  4600. * Comments::
  4601. @end menu
  4602. @node Comments, , Escapes, Escapes
  4603. @subsubsection Comments
  4604. @cindex comments
  4605. Probably one of the most@footnote{Unfortunately, this is a lie. But
  4606. hopefully future @code{gtroff} hackers will believe it @code{:-)}}
  4607. common forms of escapes is the comment.
  4608. @Defesc {\\", , , }
  4609. Start a comment. Everything to the end of the input line is ignored.
  4610. This may sound simple, but it can be tricky to keep the comments from
  4611. interfering with the appearance of the final output.
  4612. @cindex @code{ds}, @code{ds1} requests, and comments
  4613. @cindex @code{as}, @code{as1} requests, and comments
  4614. If the escape is to the right of some text or a request, that portion
  4615. of the line is ignored, but the space leading up to it is noticed by
  4616. @code{gtroff}. This only affects the @code{ds} and @code{as}
  4617. request and its variants.
  4618. @cindex tabs, before comments
  4619. @cindex comments, lining up with tabs
  4620. One possibly irritating idiosyncracy is that tabs must not be used to
  4621. line up comments. Tabs are not treated as whitespace between the
  4622. request and macro arguments.
  4623. @cindex undefined request
  4624. @cindex request, undefined
  4625. A comment on a line by itself is treated as a blank line, because
  4626. after eliminating the comment, that is all that remains:
  4627. @Example
  4628. Test
  4629. \" comment
  4630. Test
  4631. @endExample
  4632. @noindent
  4633. produces
  4634. @Example
  4635. Test
  4636. Test
  4637. @endExample
  4638. To avoid this, it is common to start the line with @code{.\"} which
  4639. causes the line to be treated as an undefined request and thus ignored
  4640. completely.
  4641. @cindex @code{'}, as a comment
  4642. Another commenting scheme seen sometimes is three consecutive single
  4643. quotes (@code{'''}) at the beginning of a line. This works, but
  4644. @code{gtroff} gives a warning about an undefined macro (namely
  4645. @code{''}), which is harmless, but irritating.
  4646. @endDefesc
  4647. @Defesc {\\#, , , }
  4648. To avoid all this, @code{gtroff} has a new comment mechanism using the
  4649. @code{\#} escape. This escape works the same as @code{\"} except that
  4650. the newline is also ignored:
  4651. @Example
  4652. Test
  4653. \# comment
  4654. Test
  4655. @endExample
  4656. @noindent
  4657. produces
  4658. @Example
  4659. Test Test
  4660. @endExample
  4661. @noindent
  4662. as expected.
  4663. @endDefesc
  4664. @Defreq {ig, [@Var{end}]}
  4665. Ignore all input until @code{gtroff} encounters the macro named
  4666. @code{.}@var{end} on a line by itself (or @code{..} if @var{end} is not
  4667. specified). This is useful for commenting out large blocks of text:
  4668. @Example
  4669. text text text...
  4670. .ig
  4671. This is part of a large block
  4672. of text that has been
  4673. temporarily(?) commented out.
  4674. We can restore it simply by removing
  4675. the .ig request and the ".." at the
  4676. end of the block.
  4677. ..
  4678. More text text text...
  4679. @endExample
  4680. @noindent
  4681. produces
  4682. @Example
  4683. text text text@dots{} More text text text@dots{}
  4684. @endExample
  4685. @noindent
  4686. Note that the commented-out block of text does not
  4687. cause a break.
  4688. The input is read in copy-mode; auto-incremented registers @emph{are}
  4689. affected (@pxref{Auto-increment}).
  4690. @endDefreq
  4691. @c =====================================================================
  4692. @node Registers, Manipulating Filling and Adjusting, Embedded Commands, gtroff Reference
  4693. @section Registers
  4694. @cindex registers
  4695. Numeric variables in @code{gtroff} are called @dfn{registers}. There
  4696. are a number of built-in registers, supplying anything from the date to
  4697. details of formatting parameters.
  4698. @xref{Identifiers}, for details on register identifiers.
  4699. @menu
  4700. * Setting Registers::
  4701. * Interpolating Registers::
  4702. * Auto-increment::
  4703. * Assigning Formats::
  4704. * Built-in Registers::
  4705. @end menu
  4706. @c ---------------------------------------------------------------------
  4707. @node Setting Registers, Interpolating Registers, Registers, Registers
  4708. @subsection Setting Registers
  4709. @cindex setting registers (@code{nr}, @code{\R})
  4710. @cindex registers, setting (@code{nr}, @code{\R})
  4711. Define or set registers using the @code{nr} request or the
  4712. @code{\R} escape.
  4713. @DefreqList {nr, ident value}
  4714. @DefescListEnd {\\R, ', ident value, '}
  4715. Set number register @var{ident} to @var{value}. If @var{ident}
  4716. doesn't exist, @code{gtroff} creates it.
  4717. The argument to @code{\R} usually has to be enclosed in quotes.
  4718. @xref{Escapes}, for details on parameter delimiting characters.
  4719. The @code{\R} escape doesn't produce an input token in @code{gtroff};
  4720. with other words, it vanishes completely after @code{gtroff} has
  4721. processed it.
  4722. @endDefreq
  4723. For example, the following two lines are equivalent:
  4724. @Example
  4725. .nr a (((17 + (3 * 4))) % 4)
  4726. \R'a (((17 + (3 * 4))) % 4)'
  4727. @result{} 1
  4728. @endExample
  4729. Both @code{nr} and @code{\R} have two additional special forms to
  4730. increment or decrement a register.
  4731. @DefreqList {nr, ident @t{+}@Var{value}}
  4732. @DefreqItem {nr, ident @t{-}@Var{value}}
  4733. @DefescItem {\\R, ', ident @t{+}value, '}
  4734. @DefescListEnd {\\R, ', ident @t{-}value, '}
  4735. Increment (decrement) register @var{ident} by @var{value}.
  4736. @Example
  4737. .nr a 1
  4738. .nr a +1
  4739. \na
  4740. @result{} 2
  4741. @endExample
  4742. @cindex negating register values
  4743. To assign the negated value of a register to another register, some care
  4744. must be taken to get the desired result:
  4745. @Example
  4746. .nr a 7
  4747. .nr b 3
  4748. .nr a -\nb
  4749. \na
  4750. @result{} 4
  4751. .nr a (-\nb)
  4752. \na
  4753. @result{} -3
  4754. @endExample
  4755. @noindent
  4756. The surrounding parentheses prevent the interpretation of the minus sign
  4757. as a decrementing operator. An alternative is to start the assignment
  4758. with a @samp{0}:
  4759. @Example
  4760. .nr a 7
  4761. .nr b -3
  4762. .nr a \nb
  4763. \na
  4764. @result{} 4
  4765. .nr a 0\nb
  4766. \na
  4767. @result{} -3
  4768. @endExample
  4769. @endDefreq
  4770. @Defreq {rr, ident}
  4771. @cindex removing number register (@code{rr})
  4772. @cindex number register, removing (@code{rr})
  4773. @cindex register, removing (@code{rr})
  4774. Remove number register @var{ident}. If @var{ident} doesn't exist, the
  4775. request is ignored.
  4776. @endDefreq
  4777. @Defreq {rnn, ident1 ident2}
  4778. @cindex renaming number register (@code{rnn})
  4779. @cindex number register, renaming (@code{rnn})
  4780. @cindex register, renaming (@code{rnn})
  4781. Rename number register @var{ident1} to @var{ident2}. If either
  4782. @var{ident1} or @var{ident2} doesn't exist, the request is ignored.
  4783. @endDefreq
  4784. @Defreq {aln, ident1 ident2}
  4785. @cindex alias, number register, creating (@code{aln})
  4786. @cindex creating alias, for number register (@code{aln})
  4787. @cindex number register, creating alias (@code{aln})
  4788. @cindex register, creating alias (@code{aln})
  4789. Create an alias @var{ident1} for a number register @var{ident2}. The
  4790. new name and the old name are exactly equivalent. If @var{ident1} is
  4791. undefined, a warning of type @samp{reg} is generated, and the request
  4792. is ignored. @xref{Debugging}, for information about warnings.
  4793. @endDefreq
  4794. @c ---------------------------------------------------------------------
  4795. @node Interpolating Registers, Auto-increment, Setting Registers, Registers
  4796. @subsection Interpolating Registers
  4797. @cindex interpolating registers (@code{\n})
  4798. @cindex registers, interpolating (@code{\n})
  4799. Numeric registers can be accessed via the @code{\n} escape.
  4800. @DefescList {\\n, , i, }
  4801. @DefescItem {\\n, @Lparen{}, id, }
  4802. @DefescListEnd {\\n, @Lbrack{}, ident, @Rbrack{}}
  4803. @cindex nested assignments
  4804. @cindex assignments, nested
  4805. @cindex indirect assignments
  4806. @cindex assignments, indirect
  4807. Interpolate number register with name @var{ident} (one-character
  4808. name@tie{}@var{i}, two-character name @var{id}). This means that the value
  4809. of the register is expanded in-place while @code{gtroff} is parsing the
  4810. input line. Nested assignments (also called indirect assignments) are
  4811. possible.
  4812. @Example
  4813. .nr a 5
  4814. .nr as \na+\na
  4815. \n(as
  4816. @result{} 10
  4817. @endExample
  4818. @Example
  4819. .nr a1 5
  4820. .nr ab 6
  4821. .ds str b
  4822. .ds num 1
  4823. \n[a\n[num]]
  4824. @result{} 5
  4825. \n[a\*[str]]
  4826. @result{} 6
  4827. @endExample
  4828. @endDefesc
  4829. @c ---------------------------------------------------------------------
  4830. @node Auto-increment, Assigning Formats, Interpolating Registers, Registers
  4831. @subsection Auto-increment
  4832. @cindex auto-increment
  4833. @cindex increment, automatic
  4834. Number registers can also be auto-incremented and auto-decremented.
  4835. The increment or decrement value can be specified with a third
  4836. argument to the @code{nr} request or @code{\R} escape.
  4837. @Defreq {nr, ident value incr}
  4838. @cindex @code{\R}, difference to @code{nr}
  4839. Set number register @var{ident} to @var{value}; the increment for
  4840. auto-incrementing is set to @var{incr}. Note that the @code{\R}
  4841. escape doesn't support this notation.
  4842. @endDefreq
  4843. To activate auto-incrementing, the escape @code{\n} has a special
  4844. syntax form.
  4845. @DefescList {\\n, +, i, }
  4846. @DefescItem {\\n, -, i, }
  4847. @DefescItem {\\n, @Lparen{}+, id, }
  4848. @DefescItem {\\n, @Lparen{}-, id, }
  4849. @DefescItem {\\n, +@Lparen{}, id, }
  4850. @DefescItem {\\n, -@Lparen{}, id, }
  4851. @DefescItem {\\n, @Lbrack{}+, ident, @Rbrack{}}
  4852. @DefescItem {\\n, @Lbrack{}-, ident, @Rbrack{}}
  4853. @DefescItem {\\n, +@Lbrack{}, ident, @Rbrack{}}
  4854. @DefescListEnd {\\n, -@Lbrack{}, ident, @Rbrack{}}
  4855. Before interpolating, increment or decrement @var{ident}
  4856. (one-character name@tie{}@var{i}, two-character name @var{id}) by the
  4857. auto-increment value as specified with the @code{nr} request (or the
  4858. @code{\R} escape). If no auto-increment value has been specified,
  4859. these syntax forms are identical to @code{\n}.
  4860. @endDefesc
  4861. For example,
  4862. @Example
  4863. .nr a 0 1
  4864. .nr xx 0 5
  4865. .nr foo 0 -2
  4866. \n+a, \n+a, \n+a, \n+a, \n+a
  4867. .br
  4868. \n-(xx, \n-(xx, \n-(xx, \n-(xx, \n-(xx
  4869. .br
  4870. \n+[foo], \n+[foo], \n+[foo], \n+[foo], \n+[foo]
  4871. @endExample
  4872. @noindent
  4873. produces
  4874. @Example
  4875. 1, 2, 3, 4, 5
  4876. -5, -10, -15, -20, -25
  4877. -2, -4, -6, -8, -10
  4878. @endExample
  4879. @cindex increment value without changing the register
  4880. @cindex value, incrementing without changing the register
  4881. To change the increment value without changing the value of a register
  4882. (@var{a} in the example), the following can be used:
  4883. @Example
  4884. .nr a \na 10
  4885. @endExample
  4886. @c ---------------------------------------------------------------------
  4887. @node Assigning Formats, Built-in Registers, Auto-increment, Registers
  4888. @subsection Assigning Formats
  4889. @cindex assigning formats (@code{af})
  4890. @cindex formats, assigning (@code{af})
  4891. When a register is used in the text of an input file (as opposed to
  4892. part of an expression), it is textually replaced (or interpolated)
  4893. with a representation of that number. This output format can be
  4894. changed to a variety of formats (numbers, Roman numerals, etc.). This
  4895. is done using the @code{af} request.
  4896. @Defreq {af, ident format}
  4897. Change the output format of a number register. The first argument
  4898. @var{ident} is the name of the number register to be changed, and the
  4899. second argument @var{format} is the output format. The following
  4900. output formats are available:
  4901. @table @code
  4902. @item 1
  4903. Decimal arabic numbers. This is the default format: 0, 1, 2,
  4904. 3,@tie{}@enddots{}
  4905. @item 0@dots{}0
  4906. Decimal numbers with as many digits as specified. So, @samp{00} would
  4907. result in printing numbers as 01, 02, 03,@tie{}@enddots{}
  4908. In fact, any digit instead of zero will do; @code{gtroff} only counts
  4909. how many digits are specified. As a consequence, @code{af}'s default
  4910. format @samp{1} could be specified as @samp{0} also (and exactly this is
  4911. returned by the @code{\g} escape, see below).
  4912. @item I
  4913. @cindex Roman numerals
  4914. @cindex numerals, Roman
  4915. Upper-case Roman numerals: 0, I, II, III, IV,@tie{}@enddots{}
  4916. @item i
  4917. Lower-case Roman numerals: 0, i, ii, iii, iv,@tie{}@enddots{}
  4918. @item A
  4919. Upper-case letters: 0, A, B, C, @dots{},@tie{}Z, AA, AB,@tie{}@enddots{}
  4920. @item a
  4921. Lower-case letters: 0, a, b, c, @dots{},@tie{}z, aa, ab,@tie{}@enddots{}
  4922. @end table
  4923. Omitting the number register format causes a warning of type
  4924. @samp{missing}. @xref{Debugging}, for more details. Specifying a
  4925. nonexistent format causes an error.
  4926. The following example produces @samp{10, X, j, 010}:
  4927. @Example
  4928. .nr a 10
  4929. .af a 1 \" the default format
  4930. \na,
  4931. .af a I
  4932. \na,
  4933. .af a a
  4934. \na,
  4935. .af a 001
  4936. \na
  4937. @endExample
  4938. @cindex Roman numerals, maximum and minimum
  4939. @cindex maximum values of Roman numerals
  4940. @cindex minimum values of Roman numerals
  4941. The largest number representable for the @samp{i} and @samp{I} formats
  4942. is 39999 (or @minus{}39999); @acronym{UNIX} @code{troff} uses @samp{z}
  4943. and @samp{w} to represent 10000 and 5000 in Roman numerals, and so does
  4944. @code{gtroff}. Currently, the correct glyphs of Roman numeral five
  4945. thousand and Roman numeral ten thousand (Unicode code points
  4946. @code{U+2182} and @code{U+2181}, respectively) are not available.
  4947. If @var{ident} doesn't exist, it is created.
  4948. @cindex read-only register, changing format
  4949. @cindex changing format, and read-only registers
  4950. Changing the output format of a read-only register causes an error. It
  4951. is necessary to first copy the register's value to a writeable register,
  4952. then apply the @code{af} request to this other register.
  4953. @endDefreq
  4954. @DefescList {\\g, , i, }
  4955. @DefescItem {\\g, @Lparen{}, id, }
  4956. @DefescListEnd {\\g, @Lbrack{}, ident, @Rbrack{}}
  4957. @cindex format of register (@code{\g})
  4958. @cindex register, format (@code{\g})
  4959. Return the current format of the specified register @var{ident}
  4960. (one-character name@tie{}@var{i}, two-character name @var{id}). For
  4961. example, @samp{\ga} after the previous example would produce the
  4962. string @samp{000}. If the register hasn't been defined yet, nothing
  4963. is returned.
  4964. @endDefesc
  4965. @c ---------------------------------------------------------------------
  4966. @node Built-in Registers, , Assigning Formats, Registers
  4967. @subsection Built-in Registers
  4968. @cindex built-in registers
  4969. @cindex registers, built-in
  4970. The following lists some built-in registers which are not described
  4971. elsewhere in this manual. Any register which begins with a @samp{.} is
  4972. read-only. A complete listing of all built-in registers can be found in
  4973. @ref{Register Index}.
  4974. @table @code
  4975. @item \n[.F]
  4976. @cindex current input file name register (@code{.F})
  4977. @cindex input file name, current, register (@code{.F})
  4978. @vindex .F
  4979. This string-valued register returns the current input file name.
  4980. @item \n[.H]
  4981. @cindex horizontal resolution register (@code{.H})
  4982. @cindex resolution, horizontal, register (@code{.H})
  4983. @vindex .H
  4984. Horizontal resolution in basic units.
  4985. @item \n[.U]
  4986. @cindex safer mode
  4987. @cindex mode, safer
  4988. @cindex unsafe mode
  4989. @cindex mode, unsafe
  4990. If @code{gtroff} is called with the @option{-U} command line option, the
  4991. number register @code{.U} is set to@tie{}1, and zero otherwise.
  4992. @xref{Groff Options}.
  4993. @item \n[.V]
  4994. @cindex vertical resolution register (@code{.V})
  4995. @cindex resolution, vertical, register (@code{.V})
  4996. @vindex .V
  4997. Vertical resolution in basic units.
  4998. @item \n[seconds]
  4999. @cindex seconds, current time (@code{seconds})
  5000. @cindex time, current, seconds (@code{seconds})
  5001. @cindex current time, seconds (@code{seconds})
  5002. @vindex seconds
  5003. The number of seconds after the minute, normally in the range@tie{}0
  5004. to@tie{}59, but can be up to@tie{}61 to allow for leap seconds. Initialized
  5005. at start-up of @code{gtroff}.
  5006. @item \n[minutes]
  5007. @cindex minutes, current time (@code{minutes})
  5008. @cindex time, current, minutes (@code{minutes})
  5009. @cindex current time, minutes (@code{minutes})
  5010. @vindex minutes
  5011. The number of minutes after the hour, in the range@tie{}0 to@tie{}59.
  5012. Initialized at start-up of @code{gtroff}.
  5013. @item \n[hours]
  5014. @cindex hours, current time (@code{hours})
  5015. @cindex time, current, hours (@code{hours})
  5016. @cindex current time, hours (@code{hours})
  5017. @vindex hours
  5018. The number of hours past midnight, in the range@tie{}0 to@tie{}23.
  5019. Initialized at start-up of @code{gtroff}.
  5020. @item \n[dw]
  5021. @cindex day of the week register (@code{dw})
  5022. @cindex date, day of the week register (@code{dw})
  5023. @vindex dw
  5024. Day of the week (1-7).
  5025. @item \n[dy]
  5026. @cindex day of the month register (@code{dy})
  5027. @cindex date, day of the month register (@code{dy})
  5028. @vindex dy
  5029. Day of the month (1-31).
  5030. @item \n[mo]
  5031. @cindex month of the year register (@code{mo})
  5032. @cindex date, month of the year register (@code{mo})
  5033. @vindex mo
  5034. Current month (1-12).
  5035. @item \n[year]
  5036. @cindex date, year register (@code{year}, @code{yr})
  5037. @cindex year, current, register (@code{year}, @code{yr})
  5038. @vindex year
  5039. The current year.
  5040. @item \n[yr]
  5041. @vindex yr
  5042. The current year minus@tie{}1900. Unfortunately, the documentation of
  5043. @acronym{UNIX} Version@tie{}7's @code{troff} had a year@tie{}2000 bug: It
  5044. incorrectly claimed that @code{yr} contains the last two digits of the
  5045. year. That claim has never been true of either @acronym{AT&T}
  5046. @code{troff} or GNU @code{troff}. Old @code{troff} input that looks
  5047. like this:
  5048. @Example
  5049. '\" The following line stopped working after 1999
  5050. This document was formatted in 19\n(yr.
  5051. @endExample
  5052. @noindent
  5053. can be corrected as follows:
  5054. @Example
  5055. This document was formatted in \n[year].
  5056. @endExample
  5057. @noindent
  5058. or, to be portable to older @code{troff} versions, as follows:
  5059. @Example
  5060. .nr y4 1900+\n(yr
  5061. This document was formatted in \n(y4.
  5062. @endExample
  5063. @item \n[.c]
  5064. @vindex .c
  5065. @itemx \n[c.]
  5066. @vindex c.
  5067. @cindex input line number register (@code{.c}, @code{c.})
  5068. @cindex line number, input, register (@code{.c}, @code{c.})
  5069. The current @emph{input} line number. Register @samp{.c} is read-only,
  5070. whereas @samp{c.} (a @code{gtroff} extension) is writable also,
  5071. affecting both @samp{.c} and @samp{c.}.
  5072. @item \n[ln]
  5073. @vindex ln
  5074. @cindex output line number register (@code{ln})
  5075. @cindex line number, output, register (@code{ln})
  5076. The current @emph{output} line number after a call to the @code{nm}
  5077. request to activate line numbering.
  5078. @xref{Miscellaneous}, for more information about line numbering.
  5079. @item \n[.x]
  5080. @vindex .x
  5081. @cindex major version number register (@code{.x})
  5082. @cindex version number, major, register (@code{.x})
  5083. The major version number. For example, if the version number
  5084. is 1.03 then @code{.x} contains@tie{}@samp{1}.
  5085. @item \n[.y]
  5086. @vindex .y
  5087. @cindex minor version number register (@code{.y})
  5088. @cindex version number, minor, register (@code{.y})
  5089. The minor version number. For example, if the version number
  5090. is 1.03 then @code{.y} contains@tie{}@samp{03}.
  5091. @item \n[.Y]
  5092. @vindex .Y
  5093. @cindex revision number register (@code{.Y})
  5094. The revision number of @code{groff}.
  5095. @item \n[$$]
  5096. @vindex $$
  5097. @cindex process ID of @code{gtroff} register (@code{$$})
  5098. @cindex @code{gtroff}, process ID register (@code{$$})
  5099. The process ID of @code{gtroff}.
  5100. @item \n[.g]
  5101. @vindex .g
  5102. @cindex @code{gtroff}, identification register (@code{.g})
  5103. @cindex GNU-specific register (@code{.g})
  5104. Always@tie{}1. Macros should use this to determine whether they are
  5105. running under GNU @code{troff}.
  5106. @item \n[.A]
  5107. @vindex .A
  5108. @cindex @acronym{ASCII} approximation output register (@code{.A})
  5109. If the command line option @option{-a} is used to produce an
  5110. @acronym{ASCII} approximation of the output, this is set to@tie{}1, zero
  5111. otherwise. @xref{Groff Options}.
  5112. @item \n[.P]
  5113. @vindex .P
  5114. This register is set to@tie{}1 (and to@tie{}0 otherwise) if the current
  5115. page is actually being printed, i.e., if the @option{-o} option is being
  5116. used to only print selected pages. @xref{Groff Options}, for more
  5117. information.
  5118. @item \n[.T]
  5119. @vindex .T
  5120. If @code{gtroff} is called with the @option{-T} command line option, the
  5121. number register @code{.T} is set to@tie{}1, and zero otherwise.
  5122. @xref{Groff Options}.
  5123. @item \*[.T]
  5124. @stindex .T
  5125. @cindex output device name string register (@code{.T})
  5126. A single read-write string register which contains the current output
  5127. device (for example, @samp{latin1} or @samp{ps}). This is the only
  5128. string register defined by @code{gtroff}.
  5129. @end table
  5130. @c =====================================================================
  5131. @node Manipulating Filling and Adjusting, Manipulating Hyphenation, Registers, gtroff Reference
  5132. @section Manipulating Filling and Adjusting
  5133. @cindex manipulating filling and adjusting
  5134. @cindex filling and adjusting, manipulating
  5135. @cindex adjusting and filling, manipulating
  5136. @cindex justifying text
  5137. @cindex text, justifying
  5138. @cindex break
  5139. @cindex line break
  5140. @cindex @code{bp} request, causing implicit linebreak
  5141. @cindex @code{ce} request, causing implicit linebreak
  5142. @cindex @code{cf} request, causing implicit linebreak
  5143. @cindex @code{fi} request, causing implicit linebreak
  5144. @cindex @code{fl} request, causing implicit linebreak
  5145. @cindex @code{in} request, causing implicit linebreak
  5146. @cindex @code{nf} request, causing implicit linebreak
  5147. @cindex @code{rj} request, causing implicit linebreak
  5148. @cindex @code{sp} request, causing implicit linebreak
  5149. @cindex @code{ti} request, causing implicit linebreak
  5150. @cindex @code{trf} request, causing implicit linebreak
  5151. Various ways of causing @dfn{breaks} were given in @ref{Implicit Line
  5152. Breaks}. The @code{br} request likewise causes a break. Several
  5153. other requests also cause breaks, but implicitly. These are
  5154. @code{bp}, @code{ce}, @code{cf}, @code{fi}, @code{fl}, @code{in},
  5155. @code{nf}, @code{rj}, @code{sp}, @code{ti}, and @code{trf}.
  5156. @Defreq {br, }
  5157. Break the current line, i.e., the input collected so far is emitted
  5158. without adjustment.
  5159. If the no-break control character is used, @code{gtroff} suppresses
  5160. the break:
  5161. @Example
  5162. a
  5163. 'br
  5164. b
  5165. @result{} a b
  5166. @endExample
  5167. @endDefreq
  5168. Initially, @code{gtroff} fills and adjusts text to both margins.
  5169. Filling can be disabled via the @code{nf} request and re-enabled with
  5170. the @code{fi} request.
  5171. @DefreqList {fi, }
  5172. @DefregListEnd {.u}
  5173. @cindex fill mode (@code{fi})
  5174. @cindex mode, fill (@code{fi})
  5175. Activate fill mode (which is the default). This request implicitly
  5176. enables adjusting; it also inserts a break in the text currently being
  5177. filled. The read-only number register @code{.u} is set to@tie{}1.
  5178. The fill mode status is associated with the current environment
  5179. (@pxref{Environments}).
  5180. See @ref{Line Control}, for interaction with the @code{\c} escape.
  5181. @endDefreq
  5182. @Defreq {nf, }
  5183. @cindex no-fill mode (@code{nf})
  5184. @cindex mode, no-fill (@code{nf})
  5185. Activate no-fill mode. Input lines are output as-is, retaining line
  5186. breaks and ignoring the current line length. This command implicitly
  5187. disables adjusting; it also causes a break. The number register
  5188. @code{.u} is set to@tie{}0.
  5189. The fill mode status is associated with the current environment
  5190. (@pxref{Environments}).
  5191. See @ref{Line Control}, for interaction with the @code{\c} escape.
  5192. @endDefreq
  5193. @DefreqList {ad, [@Var{mode}]}
  5194. @DefregListEnd {.j}
  5195. Set adjusting mode.
  5196. Activation and deactivation of adjusting is done implicitly with
  5197. calls to the @code{fi} or @code{nf} requests.
  5198. @var{mode} can have one of the following values:
  5199. @table @code
  5200. @item l
  5201. @cindex ragged-right
  5202. Adjust text to the left margin. This produces what is traditionally
  5203. called ragged-right text.
  5204. @item r
  5205. @cindex ragged-left
  5206. Adjust text to the right margin, producing ragged-left text.
  5207. @item c
  5208. @cindex centered text
  5209. @cindex @code{ce} request, difference to @samp{.ad@tie{}c}
  5210. Center filled text. This is different to the @code{ce} request which
  5211. only centers text without filling.
  5212. @item b
  5213. @itemx n
  5214. Justify to both margins. This is the default used by @code{gtroff}.
  5215. @end table
  5216. Finally, @var{mode} can be the numeric argument returned by the @code{.j}
  5217. register.
  5218. With no argument, @code{gtroff} adjusts lines in the same way it did
  5219. before adjusting was deactivated (with a call to @code{na}, for
  5220. example).
  5221. @Example
  5222. text
  5223. .ad r
  5224. .nr ad \n[.j]
  5225. text
  5226. .ad c
  5227. text
  5228. .na
  5229. text
  5230. .ad \" back to centering
  5231. text
  5232. .ad \n[ad] \" back to right justifying
  5233. @endExample
  5234. @cindex adjustment mode register (@code{.j})
  5235. The current adjustment mode is available in the read-only number
  5236. register @code{.j}; it can be stored and subsequently used to set
  5237. adjustment.
  5238. The adjustment mode status is associated with the current environment
  5239. (@pxref{Environments}).
  5240. @endDefreq
  5241. @Defreq {na, }
  5242. Disable adjusting. This request won't change the current adjustment
  5243. mode: A subsequent call to @code{ad} uses the previous adjustment
  5244. setting.
  5245. The adjustment mode status is associated with the current environment
  5246. (@pxref{Environments}).
  5247. @endDefreq
  5248. @DefreqList {brp, }
  5249. @DefescListEnd {\\p, , , }
  5250. Adjust the current line and cause a break.
  5251. In most cases this produces very ugly results since @code{gtroff}
  5252. doesn't have a sophisticated paragraph building algorithm (as @TeX{}
  5253. have, for example); instead, @code{gtroff} fills and adjusts a paragraph
  5254. line by line:
  5255. @Example
  5256. This is an uninteresting sentence.
  5257. This is an uninteresting sentence.\p
  5258. This is an uninteresting sentence.
  5259. @endExample
  5260. @noindent
  5261. is formatted as
  5262. @Example
  5263. This is an uninteresting sentence. This is an
  5264. uninteresting sentence.
  5265. This is an uninteresting sentence.
  5266. @endExample
  5267. @endDefreq
  5268. @DefreqList {ss, word_space_size [@Var{sentence_space_size}]}
  5269. @DefregItem {.ss}
  5270. @DefregListEnd {.sss}
  5271. @cindex word space size register (@code{.ss})
  5272. @cindex size of word space register (@code{.ss})
  5273. @cindex space between words register (@code{.ss})
  5274. @cindex sentence space size register (@code{.sss})
  5275. @cindex size of sentence space register (@code{.sss})
  5276. @cindex space between sentences register (@code{.sss})
  5277. Change the size of a space between words. It takes its units as one
  5278. twelfth of the space width parameter for the current font.
  5279. Initially both the @var{word_space_size} and @var{sentence_space_size}
  5280. are@tie{}12. In fill mode, the values specify the minimum distance.
  5281. @cindex fill mode
  5282. @cindex mode, fill
  5283. If two arguments are given to the @code{ss} request, the second
  5284. argument sets the sentence space size. If the second argument is not
  5285. given, sentence space size is set to @var{word_space_size}. The
  5286. sentence space size is used in two circumstances: If the end of a
  5287. sentence occurs at the end of a line in fill mode, then both an
  5288. inter-word space and a sentence space are added; if two spaces follow
  5289. the end of a sentence in the middle of a line, then the second space
  5290. is a sentence space. If a second argument is never given to the
  5291. @code{ss} request, the behaviour of @acronym{UNIX} @code{troff} is the
  5292. same as that exhibited by GNU @code{troff}. In GNU @code{troff}, as
  5293. in @acronym{UNIX} @code{troff}, a sentence should always be followed
  5294. by either a newline or two spaces.
  5295. The read-only number registers @code{.ss} and @code{.sss} hold the
  5296. values of the parameters set by the first and second arguments of the
  5297. @code{ss} request.
  5298. The word space and sentence space values are associated with the current
  5299. environment (@pxref{Environments}).
  5300. Contrary to @acronym{AT&T} @code{troff}, this request is @emph{not}
  5301. ignored if a TTY output device is used; the given values are then
  5302. rounded down to a multiple of@tie{}12 (@pxref{Implementation Differences}).
  5303. The request is ignored if there is no parameter.
  5304. @cindex discardable horizontal space
  5305. @cindex space, discardable, horizontal
  5306. @cindex horizontal discardable space
  5307. Another useful application of the @code{ss} request is to insert
  5308. discardable horizontal space, i.e., space which is discarded at a line
  5309. break. For example, paragraph-style footnotes could be separated this
  5310. way:
  5311. @Example
  5312. .ll 4.5i
  5313. 1.\ This is the first footnote.\c
  5314. .ss 48
  5315. .nop
  5316. .ss 12
  5317. 2.\ This is the second footnote.
  5318. @endExample
  5319. @noindent
  5320. The result:
  5321. @Example
  5322. 1. This is the first footnote. 2. This
  5323. is the second footnote.
  5324. @endExample
  5325. @noindent
  5326. Note that the @code{\h} escape produces unbreakable space.
  5327. @endDefreq
  5328. @DefreqList {ce, [@Var{nnn}]}
  5329. @DefregListEnd {.ce}
  5330. @cindex centering lines (@code{ce})
  5331. @cindex lines, centering (@code{ce})
  5332. Center text. While the @w{@samp{.ad c}} request also centers text,
  5333. it fills the text as well. @code{ce} does not fill the
  5334. text it affects. This request causes a break. The number of lines
  5335. still to be centered is associated with the current environment
  5336. (@pxref{Environments}).
  5337. The following example demonstrates the differences.
  5338. Here the input:
  5339. @Example
  5340. .ll 4i
  5341. .ce 1000
  5342. This is a small text fragment which shows the differences
  5343. between the `.ce' and the `.ad c' request.
  5344. .ce 0
  5345. .ad c
  5346. This is a small text fragment which shows the differences
  5347. between the `.ce' and the `.ad c' request.
  5348. @endExample
  5349. @noindent
  5350. And here the result:
  5351. @Example
  5352. This is a small text fragment which
  5353. shows the differences
  5354. between the `.ce' and the `.ad c' request.
  5355. This is a small text fragment which
  5356. shows the differences between the `.ce'
  5357. and the `.ad c' request.
  5358. @endExample
  5359. With no arguments, @code{ce} centers the next line of text. @var{nnn}
  5360. specifies the number of lines to be centered. If the argument is zero
  5361. or negative, centering is disabled.
  5362. The basic length for centering text is the line length (as set with the
  5363. @code{ll} request) minus the indentation (as set with the @code{in}
  5364. request). Temporary indentation is ignored.
  5365. As can be seen in the previous example, it is a common idiom to turn
  5366. on centering for a large number of lines, and to turn off centering
  5367. after text to be centered. This is useful for any request which takes
  5368. a number of lines as an argument.
  5369. The @code{.ce} read-only number register contains the number of lines
  5370. remaining to be centered, as set by the @code{ce} request.
  5371. @endDefreq
  5372. @DefreqList {rj, [@Var{nnn}]}
  5373. @DefregListEnd {.rj}
  5374. @cindex justifying text (@code{rj})
  5375. @cindex text, justifying (@code{rj})
  5376. @cindex right-justifying (@code{rj})
  5377. Justify unfilled text to the right margin. Arguments are identical to
  5378. the @code{ce} request. The @code{.rj} read-only number register is
  5379. the number of lines to be right-justified as set by the @code{rj}
  5380. request. This request causes a break. The number of lines still to be
  5381. right-justified is associated with the current environment
  5382. (@pxref{Environments}).
  5383. @endDefreq
  5384. @c =====================================================================
  5385. @node Manipulating Hyphenation, Manipulating Spacing, Manipulating Filling and Adjusting, gtroff Reference
  5386. @section Manipulating Hyphenation
  5387. @cindex manipulating hyphenation
  5388. @cindex hyphenation, manipulating
  5389. Here a description of requests which influence hyphenation.
  5390. @DefreqList {hy, [@Var{mode}]}
  5391. @DefregListEnd {.hy}
  5392. Enable hyphenation. The request has an optional numeric argument,
  5393. @var{mode}, to restrict hyphenation if necessary:
  5394. @table @code
  5395. @item 1
  5396. The default argument if @var{mode} is omitted. Hyphenate without
  5397. restrictions. This is also the start-up value of @code{gtroff}.
  5398. @item 2
  5399. Do not hyphenate the last word on a page or column.
  5400. @item 4
  5401. Do not hyphenate the last two characters of a word.
  5402. @item 8
  5403. Do not hyphenate the first two characters of a word.
  5404. @end table
  5405. Values in the previous table are additive. For example, the
  5406. value@tie{}12 causes @code{gtroff} to neither hyphenate the last
  5407. two nor the first two characters of a word.
  5408. @cindex hyphenation restrictions register (@code{.hy})
  5409. The current hyphenation restrictions can be found in the read-only
  5410. number register @samp{.hy}.
  5411. The hyphenation mode is associated with the current environment
  5412. (@pxref{Environments}).
  5413. @endDefreq
  5414. @Defreq {nh, }
  5415. Disable hyphenation (i.e., set the hyphenation mode to zero). Note
  5416. that the hyphenation mode of the last call to @code{hy} is not
  5417. remembered.
  5418. The hyphenation mode is associated with the current environment
  5419. (@pxref{Environments}).
  5420. @endDefreq
  5421. @DefreqList {hlm, [@Var{nnn}]}
  5422. @DefregItem {.hlm}
  5423. @DefregListEnd {.hlc}
  5424. @cindex explicit hyphen (@code{\%})
  5425. @cindex hyphen, explicit (@code{\%})
  5426. @cindex consecutive hyphenated lines (@code{hlm})
  5427. @cindex lines, consecutive hyphenated (@code{hlm})
  5428. @cindex hyphenated lines, consecutive (@code{hlm})
  5429. Set the maximum number of consecutive hyphenated lines to @var{nnn}.
  5430. If this number is negative, there is no maximum. The default value
  5431. is@tie{}@minus{}1 if @var{nnn} is omitted. This value is associated
  5432. with the current environment (@pxref{Environments}). Only lines
  5433. output from a given environment count towards the maximum associated
  5434. with that environment. Hyphens resulting from @code{\%} are counted;
  5435. explicit hyphens are not.
  5436. The current setting of @code{hlm} is available in the @code{.hlm}
  5437. read-only number register. Also the number of immediately preceding
  5438. consecutive hyphenated lines are available in the read-only number
  5439. register @samp{.hlc}.
  5440. @endDefreq
  5441. @Defreq {hw, word1 word2 @dots{}}
  5442. Define how @var{word1}, @var{word2}, etc.@: are to be hyphenated. The
  5443. words must be given with hyphens at the hyphenation points. For
  5444. example:
  5445. @Example
  5446. .hw in-sa-lub-rious
  5447. @endExample
  5448. @noindent
  5449. Besides the space character, any character whose hyphenation code value
  5450. is zero can be used to separate the arguments of @code{hw} (see the
  5451. documentation for the @code{hcode} request below for more information).
  5452. In addition, this request can be used more than once.
  5453. Hyphenation exceptions specified with the @code{hw} request are
  5454. associated with the current hyphenation language; it causes an error
  5455. if there is no current hyphenation language.
  5456. This request is ignored if there is no parameter.
  5457. In old versions of @code{troff} there was a limited amount of space to
  5458. store such information; fortunately, with @code{gtroff}, this is no
  5459. longer a restriction.
  5460. @endDefreq
  5461. @DefescList {\\%, , , }
  5462. @deffnx Escape @t{\:}
  5463. @ifnotinfo
  5464. @esindex \:
  5465. @end ifnotinfo
  5466. @ifinfo
  5467. @esindex \@r{<colon>}
  5468. @end ifinfo
  5469. @cindex hyphenation character (@code{\%})
  5470. @cindex character, hyphenation (@code{\%})
  5471. @cindex disabling hyphenation (@code{\%})
  5472. @cindex hyphenation, disabling (@code{\%})
  5473. To tell @code{gtroff} how to hyphenate words on the fly, use the
  5474. @code{\%} escape, also known as the @dfn{hyphenation character}.
  5475. Preceding a word with this character prevents it from being
  5476. hyphenated; putting it inside a word indicates to @code{gtroff} that
  5477. the word may be hyphenated at that point. Note that this mechanism
  5478. only affects that one occurrence of the word; to change the
  5479. hyphenation of a word for the entire document, use the @code{hw}
  5480. request.
  5481. The @code{\:} escape inserts a zero-width break point
  5482. (that is, the word breaks but without adding a hyphen).
  5483. @Example
  5484. ... check the /var/log/\:httpd/\:access_log file ...
  5485. @endExample
  5486. @cindex @code{\X}, followed by @code{\%}
  5487. @cindex @code{\Y}, followed by @code{\%}
  5488. @cindex @code{\%}, following @code{\X} or @code{\Y}
  5489. Note that @code{\X} and @code{\Y} start a word, that is, the @code{\%}
  5490. escape in (say) @w{@samp{\X'...'\%foobar}} and
  5491. @w{@samp{\Y'...'\%foobar}} no longer prevents hyphenation but inserts
  5492. a hyphenation point at the beginning of @samp{foobar}; most likely
  5493. this isn't what you want to do.
  5494. @endDefesc
  5495. @Defreq {hc, [@Var{char}]}
  5496. Change the hyphenation character to @var{char}. This character then
  5497. works the same as the @code{\%} escape, and thus, no longer appears in
  5498. the output. Without an argument, @code{hc} resets the hyphenation
  5499. character to be @code{\%} (the default) only.
  5500. The hyphenation character is associated with the current environment
  5501. (@pxref{Environments}).
  5502. @endDefreq
  5503. @DefreqList {hpf, pattern_file}
  5504. @DefreqItem {hpfa, pattern_file}
  5505. @DefreqListEnd {hpfcode, a b [c d @dots{}]}
  5506. @cindex hyphenation patterns (@code{hpf})
  5507. @cindex patterns for hyphenation (@code{hpf})
  5508. Read in a file of hyphenation patterns. This file is searched for in
  5509. the same way as @file{@var{name}.tmac} (or @file{tmac.@var{name}}) is
  5510. searched for if the @option{-m@var{name}} option is specified.
  5511. It should have the same format as (simple) @TeX{} patterns files.
  5512. More specifically, the following scanning rules are implemented.
  5513. @itemize @bullet
  5514. @item
  5515. A percent sign starts a comment (up to the end of the line)
  5516. even if preceded by a backslash.
  5517. @item
  5518. No support for `digraphs' like @code{\$}.
  5519. @item
  5520. @code{^^@var{xx}} (@var{x} is 0-9 or a-f) and @code{^^@var{x}} (character
  5521. code of @var{x} in the range 0-127) are recognized; other use of @code{^}
  5522. causes an error.
  5523. @item
  5524. No macro expansion.
  5525. @item
  5526. @code{hpf} checks for the expression @code{\patterns@{@dots{}@}}
  5527. (possibly with whitespace before and after the braces).
  5528. Everything between the braces is taken as hyphenation patterns.
  5529. Consequently, @code{@{} and @code{@}} are not allowed in patterns.
  5530. @item
  5531. Similarly, @code{\hyphenation@{@dots{}@}} gives a list of hyphenation
  5532. exceptions.
  5533. @item
  5534. @code{\endinput} is recognized also.
  5535. @item
  5536. For backwards compatibility, if @code{\patterns} is missing,
  5537. the whole file is treated as a list of hyphenation patterns
  5538. (only recognizing the @code{%} character as the start of a comment).
  5539. @end itemize
  5540. If no @code{hpf} request is specified (either in the document or in a
  5541. macro package), @code{gtroff} won't hyphenate at all.
  5542. The @code{hpfa} request appends a file of patterns to the current list.
  5543. The @code{hpfcode} request defines mapping values for character codes in
  5544. hyphenation patterns. @code{hpf} or @code{hpfa} then apply the mapping
  5545. (after reading the patterns) before replacing or appending them to
  5546. the current list of patterns. Its arguments are pairs of character codes
  5547. -- integers from 0 to@tie{}255. The request maps character code@tie{}@var{a}
  5548. to code@tie{}@var{b}, code@tie{}@var{c} to code@tie{}@var{d}, and so on. You
  5549. can use character codes which would be invalid otherwise.
  5550. @pindex troffrc
  5551. @pindex troffrc-end
  5552. @pindex hyphen.us
  5553. @pindex hyphenex.us
  5554. The set of hyphenation patterns is associated with the current language
  5555. set by the @code{hla} request. The @code{hpf} request is usually
  5556. invoked by the @file{troffrc} or @file{troffrc-end} file; by default,
  5557. @file{troffrc} loads hyphenation patterns and exceptions for American
  5558. English (in files @file{hyphen.us} and @file{hyphenex.us}).
  5559. A second call to @code{hpf} (for the same language) will replace the
  5560. hyphenation patterns with the new ones.
  5561. Invoking @code{hpf} causes an error if there is no current hyphenation
  5562. language.
  5563. @endDefreq
  5564. @Defreq {hcode, c1 code1 [c2 code2 @dots{}]}
  5565. @cindex hyphenation code (@code{hcode})
  5566. @cindex code, hyphenation (@code{hcode})
  5567. Set the hyphenation code of character @var{c1} to @var{code1}, that of
  5568. @var{c2} to @var{code2}, etc. A hyphenation code must be a single
  5569. input character (not a special character) other than a digit or a
  5570. space.
  5571. To make hyphenation work, hyphenation codes must be set up. At
  5572. start-up, groff only assigns hyphenation codes to the letters
  5573. @samp{a}-@samp{z} (mapped to themselves) and to the letters
  5574. @samp{A}-@samp{Z} (mapped to @samp{a}-@samp{z}); all other hyphenation
  5575. codes are set to zero. Normally, hyphenation patterns contain only
  5576. lowercase letters which should be applied regardless of case. With
  5577. other words, the words `FOO' and `Foo' should be hyphenated exactly the
  5578. same way as the word `foo' is hyphenated, and this is what @code{hcode}
  5579. is good for. Words which contain other letters won't be hyphenated
  5580. properly if the corresponding hyphenation patterns actually do contain
  5581. them. For example, the following @code{hcode} requests are necessary to
  5582. assign hyphenation codes to the letters @samp{ÄäÖöÜüß} (this is needed
  5583. for German):
  5584. @Example
  5585. .hcode ä ä Ä ä
  5586. .hcode ö ö Ö ö
  5587. .hcode ü ü Ü ü
  5588. .hcode ß ß
  5589. @endExample
  5590. Without those assignments, groff treats German words like
  5591. @w{`Kindergärten'} (the plural form of `kindergarten') as two
  5592. substrings @w{`kinderg'} and @w{`rten'} because the hyphenation code
  5593. of the umlaut@tie{}a is zero by default. There is a German
  5594. hyphenation pattern which covers @w{`kinder'}, so groff finds the
  5595. hyphenation `kin-der'. The other two hyphenation points
  5596. (`kin-der-gär-ten') are missed.
  5597. This request is ignored if it has no parameter.
  5598. @endDefreq
  5599. @DefreqList {hym, [@Var{length}]}
  5600. @DefregListEnd {.hym}
  5601. @cindex hyphenation margin (@code{hym})
  5602. @cindex margin for hyphenation (@code{hym})
  5603. @cindex @code{ad} request, and hyphenation margin
  5604. Set the (right) hyphenation margin to @var{length}. If the current
  5605. adjustment mode is not @samp{b} or @samp{n}, the line is not
  5606. hyphenated if it is shorter than @var{length}. Without an argument,
  5607. the hyphenation margin is reset to its default value, which is@tie{}0.
  5608. The default scaling indicator for this request is @samp{m}. The
  5609. hyphenation margin is associated with the current environment
  5610. (@pxref{Environments}).
  5611. A negative argument resets the hyphenation margin to zero, emitting
  5612. a warning of type @samp{range}.
  5613. @cindex hyphenation margin register (@code{.hym})
  5614. The current hyphenation margin is available in the @code{.hym} read-only
  5615. number register.
  5616. @endDefreq
  5617. @DefreqList {hys, [@Var{hyphenation_space}]}
  5618. @DefregListEnd {.hys}
  5619. @cindex hyphenation space (@code{hys})
  5620. @cindex @code{ad} request, and hyphenation space
  5621. Set the hyphenation space to @var{hyphenation_space}. If the current
  5622. adjustment mode is @samp{b} or @samp{n}, don't hyphenate the line
  5623. if it can be justified by adding no more than @var{hyphenation_space}
  5624. extra space to each word space. Without argument, the hyphenation
  5625. space is set to its default value, which is@tie{}0. The default
  5626. scaling indicator for this request is @samp{m}. The hyphenation
  5627. space is associated with the current environment
  5628. (@pxref{Environments}).
  5629. A negative argument resets the hyphenation space to zero, emitting a
  5630. warning of type @samp{range}.
  5631. @cindex hyphenation space register (@code{.hys})
  5632. The current hyphenation space is available in the @code{.hys} read-only
  5633. number register.
  5634. @endDefreq
  5635. @Defreq {shc, [@Var{glyph}]}
  5636. @cindex soft hyphen character, setting (@code{shc})
  5637. @cindex character, soft hyphen, setting (@code{shc})
  5638. @cindex glyph, soft hyphen (@code{hy})
  5639. @cindex soft hyphen glyph (@code{hy})
  5640. @cindex @code{char} request, and soft hyphen character
  5641. @cindex @code{tr} request, and soft hyphen character
  5642. Set the @dfn{soft hyphen character} to @var{glyph}.@footnote{@dfn{Soft
  5643. hyphen character} is a misnomer since it is an output glyph.} If the
  5644. argument is omitted, the soft hyphen character is set to the default
  5645. glyph @code{\(hy} (this is the start-up value of @code{gtroff} also).
  5646. The soft hyphen character is the glyph that is inserted when a word is
  5647. hyphenated at a line break. If the soft hyphen character does not
  5648. exist in the font of the character immediately preceding a potential
  5649. break point, then the line is not broken at that point. Neither
  5650. definitions (specified with the @code{char} request) nor translations
  5651. (specified with the @code{tr} request) are considered when finding the
  5652. soft hyphen character.
  5653. @endDefreq
  5654. @DefreqList {hla, language}
  5655. @DefregListEnd {.hla}
  5656. @cindex @code{hpf} request, and hyphenation language
  5657. @cindex @code{hw} request, and hyphenation language
  5658. @pindex troffrc
  5659. @pindex troffrc-end
  5660. Set the current hyphenation language to the string @var{language}.
  5661. Hyphenation exceptions specified with the @code{hw} request and
  5662. hyphenation patterns specified with the @code{hpf} and @code{hpfa}
  5663. requests are both associated with the current hyphenation language.
  5664. The @code{hla} request is usually invoked by the @file{troffrc} or the
  5665. @file{troffrc-end} files; @file{troffrc} sets the default language to
  5666. @samp{us}.
  5667. @cindex hyphenation language register (@code{.hla})
  5668. The current hyphenation language is available as a string in the
  5669. read-only number register @samp{.hla}.
  5670. @Example
  5671. .ds curr_language \n[.hla]
  5672. \*[curr_language]
  5673. @result{} us
  5674. @endExample
  5675. @endDefreq
  5676. @c =====================================================================
  5677. @node Manipulating Spacing, Tabs and Fields, Manipulating Hyphenation, gtroff Reference
  5678. @section Manipulating Spacing
  5679. @cindex manipulating spacing
  5680. @cindex spacing, manipulating
  5681. @Defreq {sp, [@Var{distance}]}
  5682. Space downwards @var{distance}. With no argument it advances
  5683. 1@tie{}line. A negative argument causes @code{gtroff} to move up the page
  5684. the specified distance. If the argument is preceded by a @samp{|}
  5685. then @code{gtroff} moves that distance from the top of the page. This
  5686. request causes a line break. The default scaling indicator is @samp{v}.
  5687. If a vertical trap is sprung during execution of @code{sp}, the amount of
  5688. vertical space after the trap is discarded. For example, this
  5689. @Example
  5690. .de xxx
  5691. ..
  5692. .
  5693. .wh 0 xxx
  5694. .
  5695. .pl 5v
  5696. foo
  5697. .sp 2
  5698. bar
  5699. .sp 50
  5700. baz
  5701. @endExample
  5702. @noindent
  5703. results in
  5704. @Example
  5705. foo
  5706. bar
  5707. baz
  5708. @endExample
  5709. @cindex @code{sp} request, and traps
  5710. @cindex discarded space in traps
  5711. @cindex space, discarded, in traps
  5712. @cindex traps, and discarded space
  5713. The amount of discarded space is available in the number register
  5714. @code{.trunc}.
  5715. To protect @code{sp} against vertical traps, use the @code{vpt} request:
  5716. @Example
  5717. .vpt 0
  5718. .sp -3
  5719. .vpt 1
  5720. @endExample
  5721. @endDefreq
  5722. @DefreqList {ls, [@Var{nnn}]}
  5723. @DefregListEnd {.L}
  5724. @cindex double-spacing (@code{ls})
  5725. Output @w{@var{nnn}@minus{}1} blank lines after each line of text.
  5726. With no argument, @code{gtroff} uses the previous value before the
  5727. last @code{ls} call.
  5728. @Example
  5729. .ls 2 \" This causes double-spaced output
  5730. .ls 3 \" This causes triple-spaced output
  5731. .ls \" Again double-spaced
  5732. @endExample
  5733. The line spacing is associated with the current environment
  5734. (@pxref{Environments}).
  5735. @cindex line spacing register (@code{.L})
  5736. The read-only number register @code{.L} contains the current line
  5737. spacing setting.
  5738. @endDefreq
  5739. @xref{Changing Type Sizes}, for the requests @code{vs} and @code{pvs}
  5740. as alternatives to @code{ls}.
  5741. @DefescList {\\x, ', spacing, '}
  5742. @DefregListEnd {.a}
  5743. Sometimes, extra vertical spacing is only needed occasionally, e.g.@:
  5744. to allow space for a tall construct (like an equation). The @code{\x}
  5745. escape does this. The escape is given a numerical argument, usually
  5746. enclosed in quotes (like @samp{\x'3p'}); the default scaling indicator
  5747. is @samp{v}. If this number is positive extra vertical space is
  5748. inserted below the current line. A negative number adds space above.
  5749. If this escape is used multiple times on the same line, the maximum of
  5750. the values is used.
  5751. @xref{Escapes}, for details on parameter delimiting characters.
  5752. @cindex extra post-vertical line space register (@code{.a})
  5753. The @code{.a} read-only number register contains the most recent
  5754. (nonnegative) extra vertical line space.
  5755. Using @code{\x} can be necessary in combination with the @code{\b}
  5756. escape, as the following example shows.
  5757. @Example
  5758. This is a test with the \[rs]b escape.
  5759. .br
  5760. This is a test with the \[rs]b escape.
  5761. .br
  5762. This is a test with \b'xyz'\x'-1m'\x'1m'.
  5763. .br
  5764. This is a test with the \[rs]b escape.
  5765. .br
  5766. This is a test with the \[rs]b escape.
  5767. @endExample
  5768. @noindent
  5769. produces
  5770. @Example
  5771. This is a test with the \b escape.
  5772. This is a test with the \b escape.
  5773. x
  5774. This is a test with y.
  5775. z
  5776. This is a test with the \b escape.
  5777. This is a test with the \b escape.
  5778. @endExample
  5779. @endDefesc
  5780. @DefreqList {ns, }
  5781. @DefreqItem {rs, }
  5782. @DefregListEnd {.ns}
  5783. @cindex @code{sp} request, and no-space mode
  5784. @cindex no-space mode (@code{ns})
  5785. @cindex mode, no-space (@code{ns})
  5786. @cindex blank lines, disabling
  5787. @cindex lines, blank, disabling
  5788. Enable @dfn{no-space mode}. In this mode, spacing (either via
  5789. @code{sp} or via blank lines) is disabled. The @code{bp} request to
  5790. advance to the next page is also disabled, except if it is accompanied
  5791. by a page number (see @ref{Page Control}, for more information). This
  5792. mode ends when actual text is output or the @code{rs} request is
  5793. encountered which ends no-space mode. The read-only number register
  5794. @code{.ns} is set to@tie{}1 as long as no-space mode is active.
  5795. This request is useful for macros that conditionally
  5796. insert vertical space before the text starts
  5797. (for example, a paragraph macro could insert some space
  5798. except when it is the first paragraph after a section header).
  5799. @endDefreq
  5800. @c =====================================================================
  5801. @node Tabs and Fields, Character Translations, Manipulating Spacing, gtroff Reference
  5802. @section Tabs and Fields
  5803. @cindex tabs, and fields
  5804. @cindex fields, and tabs
  5805. @cindex @acronym{EBCDIC} encoding of a tab
  5806. A tab character (@acronym{ASCII} char@tie{}9, @acronym{EBCDIC}
  5807. char@tie{}5) causes a horizontal movement to the next tab stop (much
  5808. like it did on a typewriter).
  5809. @Defesc {\\t, , , }
  5810. @cindex tab character, non-interpreted (@code{\t})
  5811. @cindex character, tab, non-interpreted (@code{\t})
  5812. This escape is a non-interpreted tab character. In copy mode
  5813. (@pxref{Copy-in Mode}), @code{\t} is the same as a real tab character.
  5814. @endDefesc
  5815. @DefreqList {ta, [@Var{n1} @Var{n2} @dots{} @Var{nn} @t{T} @Var{r1} @Var{r2} @dots{} @Var{rn}]}
  5816. @DefregListEnd {.tabs}
  5817. Change tab stop positions. This request takes a series of tab
  5818. specifiers as arguments (optionally divided into two groups with the
  5819. letter @samp{T}) which indicate where each tab stop is to be
  5820. (overriding any previous settings).
  5821. Tab stops can be specified absolutely, i.e., as the distance from the
  5822. left margin. For example, the following sets 6@tie{}tab stops every
  5823. one inch.
  5824. @Example
  5825. .ta 1i 2i 3i 4i 5i 6i
  5826. @endExample
  5827. Tab stops can also be specified using a leading @samp{+}
  5828. which means that the specified tab stop is set relative to
  5829. the previous tab stop. For example, the following is equivalent to the
  5830. previous example.
  5831. @Example
  5832. .ta 1i +1i +1i +1i +1i +1i
  5833. @endExample
  5834. @code{gtroff} supports an extended syntax to specify repeat values after
  5835. the @samp{T} mark (these values are always taken as relative) -- this is
  5836. the usual way to specify tabs set at equal intervals. The following is,
  5837. yet again, the same as the previous examples. It does even more since
  5838. it defines an infinite number of tab stops separated by one inch.
  5839. @Example
  5840. .ta T 1i
  5841. @endExample
  5842. Now we are ready to interpret the full syntax given at the beginning:
  5843. Set tabs at positions @var{n1}, @var{n2}, @dots{}, @var{nn} and then set
  5844. tabs at @var{nn}+@var{r1}, @var{nn}+@var{r2}, @dots{}, @var{nn}+@var{rn}
  5845. and then at @var{nn}+@var{rn}+@var{r1}, @var{nn}+@var{rn}+@var{r2},
  5846. @dots{}, @var{nn}+@var{rn}+@var{rn}, and so on.
  5847. Example: @samp{4c +6c T 3c 5c 2c} is equivalent to @samp{4c 10c 13c 18c
  5848. 20c 23c 28c 30c @dots{}}.
  5849. The material in each tab column (i.e., the column between two tab stops)
  5850. may be justified to the right or left or centered in the column. This
  5851. is specified by appending @samp{R}, @samp{L}, or @samp{C} to the tab
  5852. specifier. The default justification is @samp{L}. Example:
  5853. @Example
  5854. .ta 1i 2iC 3iR
  5855. @endExample
  5856. Some notes:
  5857. @itemize @bullet
  5858. @item
  5859. The default unit of the @code{ta} request is @samp{m}.
  5860. @item
  5861. A tab stop is converted into a non-breakable horizontal movement which
  5862. can be neither stretched nor squeezed. For example,
  5863. @Example
  5864. .ds foo a\tb\tc
  5865. .ta T 5i
  5866. \*[foo]
  5867. @endExample
  5868. @noindent
  5869. creates a single line which is a bit longer than 10@tie{}inches (a string
  5870. is used to show exactly where the tab characters are). Now consider the
  5871. following:
  5872. @Example
  5873. .ds bar a\tb b\tc
  5874. .ta T 5i
  5875. \*[bar]
  5876. @endExample
  5877. @noindent
  5878. @code{gtroff} first converts the tab stops of the line into unbreakable
  5879. horizontal movements, then splits the line after the second @samp{b}
  5880. (assuming a sufficiently short line length). Usually, this isn't what
  5881. the user wants.
  5882. @item
  5883. Superfluous tabs (i.e., tab characters which do not correspond to a tab
  5884. stop) are ignored except the first one which delimits the characters
  5885. belonging to the last tab stop for right-justifying or centering.
  5886. Consider the following example
  5887. @Example
  5888. .ds Z foo\tbar\tfoo
  5889. .ds ZZ foo\tbar\tfoobar
  5890. .ds ZZZ foo\tbar\tfoo\tbar
  5891. .ta 2i 4iR
  5892. \*[Z]
  5893. .br
  5894. \*[ZZ]
  5895. .br
  5896. \*[ZZZ]
  5897. .br
  5898. @endExample
  5899. @noindent
  5900. which produces the following output:
  5901. @Example
  5902. foo bar foo
  5903. foo bar foobar
  5904. foo bar foobar
  5905. @endExample
  5906. @noindent
  5907. The first line right-justifies the second `foo' relative to the tab
  5908. stop. The second line right-justifies `foobar'. The third line finally
  5909. right-justifies only `foo' because of the additional tab character which
  5910. marks the end of the string belonging to the last defined tab stop.
  5911. @item
  5912. Tab stops are associated with the current environment
  5913. (@pxref{Environments}).
  5914. @item
  5915. Calling @code{ta} without an argument removes all tab stops.
  5916. @item
  5917. @cindex tab stops, for TTY output devices
  5918. The start-up value of @code{gtroff} is @w{@samp{T 0.8i}}.
  5919. @end itemize
  5920. @cindex tab settings register (@code{.tabs})
  5921. The read-only number register @code{.tabs} contains a string
  5922. representation of the current tab settings suitable for use as an
  5923. argument to the @code{ta} request.
  5924. @Example
  5925. .ds tab-string \n[.tabs]
  5926. \*[tab-string]
  5927. @result{} T120u
  5928. @endExample
  5929. @cindex @code{.S} register, Plan@tie{}9 alias for @code{.tabs}
  5930. @cindex @code{.tabs} register, Plan@tie{}9 alias (@code{.S})
  5931. The @code{troff} version of the Plan@tie{}9 operating system uses
  5932. register @code{.S} for the same purpose.
  5933. @endDefreq
  5934. @Defreq {tc, [@Var{fill-glyph}]}
  5935. @cindex tab repetition character (@code{tc})
  5936. @cindex character, tab repetition (@code{tc})
  5937. @cindex glyph, tab repetition (@code{tc})
  5938. Normally @code{gtroff} fills the space to the next tab stop with
  5939. whitespace. This can be changed with the @code{tc} request. With no
  5940. argument @code{gtroff} reverts to using whitespace, which is the
  5941. default. The value of this @dfn{tab repetition character} is
  5942. associated with the current environment
  5943. (@pxref{Environments}).@footnote{@dfn{Tab repetition character} is a
  5944. misnomer since it is an output glyph.}
  5945. @endDefreq
  5946. @DefreqList {linetabs, n}
  5947. @DefregListEnd {.linetabs}
  5948. @cindex tab, line-tabs mode
  5949. @cindex line-tabs mode
  5950. @cindex mode, line-tabs
  5951. If @var{n} is missing or not zero, enable @dfn{line-tabs} mode,
  5952. or disable it otherwise (the default).
  5953. In line-tabs mode, @code{gtroff} computes tab distances
  5954. relative to the (current) output line instead of the input line.
  5955. For example, the following code:
  5956. @Example
  5957. .ds x a\t\c
  5958. .ds y b\t\c
  5959. .ds z c
  5960. .ta 1i 3i
  5961. \*x
  5962. \*y
  5963. \*z
  5964. @endExample
  5965. @noindent
  5966. in normal mode, results in the output
  5967. @Example
  5968. a b c
  5969. @endExample
  5970. @noindent
  5971. in line-tabs mode, the same code outputs
  5972. @Example
  5973. a b c
  5974. @endExample
  5975. Line-tabs mode is associated with the current environment.
  5976. The read-only register @code{.linetabs} is set to@tie{}1 if in line-tabs
  5977. mode, and 0 in normal mode.
  5978. @endDefreq
  5979. @menu
  5980. * Leaders::
  5981. * Fields::
  5982. @end menu
  5983. @c ---------------------------------------------------------------------
  5984. @node Leaders, Fields, Tabs and Fields, Tabs and Fields
  5985. @subsection Leaders
  5986. @cindex leaders
  5987. Sometimes it may may be desirable to use the @code{tc} request to fill a
  5988. particular tab stop with a given glyph (for example dots in a table
  5989. of contents), but also normal tab stops on the rest of the line. For
  5990. this @code{gtroff} provides an alternate tab mechanism, called
  5991. @dfn{leaders} which does just that.
  5992. @cindex leader character
  5993. A leader character (character code@tie{}1) behaves similarly to a tab
  5994. character: It moves to the next tab stop. The only difference is that
  5995. for this movement, the fill glyph defaults to a period character and
  5996. not to space.
  5997. @Defesc {\\a, , , }
  5998. @cindex leader character, non-interpreted (@code{\a})
  5999. @cindex character, leader, non-interpreted (@code{\a})
  6000. This escape is a non-interpreted leader character. In copy mode
  6001. (@pxref{Copy-in Mode}), @code{\a} is the same as a real leader
  6002. character.
  6003. @endDefesc
  6004. @Defreq {lc, [@Var{fill-glyph}]}
  6005. @cindex leader repetition character (@code{lc})
  6006. @cindex character, leader repetition (@code{lc})
  6007. @cindex glyph, leader repetition (@code{lc})
  6008. Declare the @dfn{leader repetition character}.@footnote{@dfn{Leader
  6009. repetition character} is a misnomer since it is an output glyph.}
  6010. Without an argument, leaders act the same as tabs (i.e., using
  6011. whitespace for filling). @code{gtroff}'s start-up value is a dot
  6012. (@samp{.}). The value of the leader repetition character is
  6013. associated with the current environment (@pxref{Environments}).
  6014. @endDefreq
  6015. @cindex table of contents
  6016. @cindex contents, table of
  6017. For a table of contents, to name an example, tab stops may be defined so
  6018. that the section number is one tab stop, the title is the second with
  6019. the remaining space being filled with a line of dots, and then the page
  6020. number slightly separated from the dots.
  6021. @Example
  6022. .ds entry 1.1\tFoo\a\t12
  6023. .lc .
  6024. .ta 1i 5i +.25i
  6025. \*[entry]
  6026. @endExample
  6027. @noindent
  6028. This produces
  6029. @Example
  6030. 1.1 Foo.......................................... 12
  6031. @endExample
  6032. @c ---------------------------------------------------------------------
  6033. @node Fields, , Leaders, Tabs and Fields
  6034. @subsection Fields
  6035. @cindex fields
  6036. @cindex field delimiting character (@code{fc})
  6037. @cindex delimiting character, for fields (@code{fc})
  6038. @cindex character, field delimiting (@code{fc})
  6039. @cindex field padding character (@code{fc})
  6040. @cindex padding character, for fields (@code{fc})
  6041. @cindex character, field padding (@code{fc})
  6042. @dfn{Fields} are a more general way of laying out tabular data. A field
  6043. is defined as the data between a pair of @dfn{delimiting characters}.
  6044. It contains substrings which are separated by @dfn{padding characters}.
  6045. The width of a field is the distance on the @emph{input} line from the
  6046. position where the field starts to the next tab stop. A padding
  6047. character inserts stretchable space similar to @TeX{}'s @code{\hss}
  6048. command (thus it can even be negative) to make the sum of all substring
  6049. lengths plus the stretchable space equal to the field width. If more
  6050. than one padding character is inserted, the available space is evenly
  6051. distributed among them.
  6052. @Defreq {fc, [@Var{delim-char} [@Var{padding-char}]]}
  6053. Define a delimiting and a padding character for fields. If the latter
  6054. is missing, the padding character defaults to a space character. If
  6055. there is no argument at all, the field mechanism is disabled (which is
  6056. the default). Note that contrary to e.g.@: the tab repetition
  6057. character, delimiting and padding characters are @emph{not} associated
  6058. to the current environment (@pxref{Environments}).
  6059. Example:
  6060. @Example
  6061. .fc # ^
  6062. .ta T 3i
  6063. #foo^bar^smurf#
  6064. .br
  6065. #foo^^bar^smurf#
  6066. @endExample
  6067. @noindent
  6068. and here the result:
  6069. @Example
  6070. foo bar smurf
  6071. foo bar smurf
  6072. @endExample
  6073. @endDefreq
  6074. @c =====================================================================
  6075. @node Character Translations, Troff and Nroff Mode, Tabs and Fields, gtroff Reference
  6076. @section Character Translations
  6077. @cindex character translations
  6078. @cindex translations of characters
  6079. @cindex control character, changing (@code{cc})
  6080. @cindex character, control, changing (@code{cc})
  6081. @cindex no-break control character, changing (@code{c2})
  6082. @cindex character, no-break control, changing (@code{c2})
  6083. @cindex control character, no-break, changing (@code{c2})
  6084. The control character (@samp{.}) and the no-break control character
  6085. (@samp{'}) can be changed with the @code{cc} and @code{c2} requests,
  6086. respectively.
  6087. @Defreq {cc, [@Var{c}]}
  6088. Set the control character to@tie{}@var{c}. With no argument the default
  6089. control character @samp{.} is restored. The value of the control
  6090. character is associated with the current environment
  6091. (@pxref{Environments}).
  6092. @endDefreq
  6093. @Defreq {c2, [@Var{c}]}
  6094. Set the no-break control character to@tie{}@var{c}. With no argument the
  6095. default control character @samp{'} is restored. The value of the
  6096. no-break control character is associated with the current environment
  6097. (@pxref{Environments}).
  6098. @endDefreq
  6099. @Defreq {eo, }
  6100. @cindex disabling @code{\} (@code{eo})
  6101. @cindex @code{\}, disabling (@code{eo})
  6102. Disable the escape mechanism completely. After executing this
  6103. request, the backslash character @samp{\} no longer starts an escape
  6104. sequence.
  6105. This request can be very helpful in writing macros since it is not
  6106. necessary then to double the escape character. Here an example:
  6107. @Example
  6108. .\" This is a simplified version of the
  6109. .\" .BR request from the man macro package
  6110. .eo
  6111. .de BR
  6112. . ds result \&
  6113. . while (\n[.$] >= 2) \@{\
  6114. . as result \fB\$1\fR\$2
  6115. . shift 2
  6116. . \@}
  6117. . if \n[.$] .as result \fB\$1
  6118. \*[result]
  6119. . ft R
  6120. ..
  6121. .ec
  6122. @endExample
  6123. @endDefreq
  6124. @Defreq {ec, [@Var{c}]}
  6125. @cindex escape character, changing (@code{ec})
  6126. @cindex character, escape, changing (@code{ec})
  6127. Set the escape character to@tie{}@var{c}. With no argument the default
  6128. escape character @samp{\} is restored. It can be also used to
  6129. re-enable the escape mechanism after an @code{eo} request.
  6130. Note that changing the escape character globally will likely break
  6131. macro packages since @code{gtroff} has no mechanism to `intern' macros,
  6132. i.e., to convert a macro definition into an internal form which is
  6133. independent of its representation (@TeX{} has this mechanism).
  6134. If a macro is called, it is executed literally.
  6135. @endDefreq
  6136. @DefreqList {ecs, }
  6137. @DefreqListEnd {ecr, }
  6138. The @code{ecs} request saves the current escape character
  6139. in an internal register.
  6140. Use this request in combination with the @code{ec} request to
  6141. temporarily change the escape character.
  6142. The @code{ecr} request restores the escape character
  6143. saved with @code{ecs}.
  6144. Without a previous call to @code{ecs}, this request
  6145. sets the escape character to @code{\}.
  6146. @endDefreq
  6147. @DefescList {\\\\, , , }
  6148. @DefescItem {\\e, , , }
  6149. @DefescListEnd {\\E, , , }
  6150. Print the current escape character (which is the backslash character
  6151. @samp{\} by default).
  6152. @code{\\} is a `delayed' backslash; more precisely, it is the default
  6153. escape character followed by a backslash, which no longer has special
  6154. meaning due to the leading escape character. It is @emph{not} an escape
  6155. sequence in the usual sense! In any unknown escape sequence
  6156. @code{\@var{X}} the escape character is ignored and @var{X} is printed.
  6157. But if @var{X} is equal to the current escape character, no warning is
  6158. emitted.
  6159. As a consequence, only at top-level or in a diversion a backslash glyph is
  6160. printed; in copy-in mode, it expands to a single backslash which then
  6161. combines with the following character to an escape sequence.
  6162. The @code{\E} escape differs from @code{\e} by printing an escape
  6163. character that is not interpreted in copy mode.
  6164. Use this to define strings with escapes that work
  6165. when used in copy mode (for example, as a macro argument).
  6166. The following example defines strings to begin and end
  6167. a superscript:
  6168. @Example
  6169. .ds @{ \v'-.3m'\s'\En[.s]*60/100'
  6170. .ds @} \s0\v'.3m'
  6171. @endExample
  6172. Another example to demonstrate the differences between the various escape
  6173. sequences, using a strange escape character, @samp{-}.
  6174. @Example
  6175. .ec -
  6176. .de xxx
  6177. --A'123'
  6178. ..
  6179. .xxx
  6180. @result{} -A'foo'
  6181. @endExample
  6182. @noindent
  6183. The result is surprising for most users, expecting @samp{1} since
  6184. @samp{foo} is a valid identifier. What has happened? As mentioned
  6185. above, the leading escape character makes the following character
  6186. ordinary. Written with the default escape character the sequence
  6187. @samp{--} becomes @samp{\-} -- this is the minus sign.
  6188. If the escape character followed by itself is a valid escape sequence,
  6189. only @code{\E} yields the expected result:
  6190. @Example
  6191. .ec -
  6192. .de xxx
  6193. -EA'123'
  6194. ..
  6195. .xxx
  6196. @result{} 1
  6197. @endExample
  6198. @endDefesc
  6199. @Defesc {\\., , , }
  6200. Similar to @code{\\}, the sequence @code{\.} isn't a real escape sequence.
  6201. As before, a warning message is suppressed if the escape character is
  6202. followed by a dot, and the dot itself is printed.
  6203. @Example
  6204. .de foo
  6205. . nop foo
  6206. .
  6207. . de bar
  6208. . nop bar
  6209. \\..
  6210. .
  6211. ..
  6212. .foo
  6213. .bar
  6214. @result{} foo bar
  6215. @endExample
  6216. @noindent
  6217. The first backslash is consumed while the macro is read, and the second
  6218. is swallowed while exexuting macro @code{foo}.
  6219. @endDefesc
  6220. A @dfn{translation} is a mapping of an input character to an output
  6221. glyph. The mapping occurs at output time, i.e., the input character
  6222. gets assigned the metric information of the mapped output character
  6223. right before input tokens are converted to nodes (@pxref{Gtroff
  6224. Internals}, for more on this process).
  6225. @DefreqList {tr, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
  6226. @DefreqListEnd {trin, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
  6227. Translate character @var{a} to glyph@tie{}@var{b}, character @var{c} to
  6228. glyph@tie{}@var{d}, etc. If there is an odd number of arguments, the
  6229. last one is translated to an unstretchable space (@w{@samp{\ }}).
  6230. The @code{trin} request is identical to @code{tr},
  6231. but when you unformat a diversion with @code{asciify}
  6232. it ignores the translation.
  6233. @xref{Diversions}, for details about the @code{asciify} request.
  6234. Some notes:
  6235. @itemize @bullet
  6236. @item
  6237. @cindex @code{\(}, and translations
  6238. @cindex @code{\[}, and translations
  6239. @cindex @code{\'}, and translations
  6240. @cindex @code{\`}, and translations
  6241. @cindex @code{\-}, and translations
  6242. @cindex @code{\_}, and translations
  6243. @cindex @code{\C}, and translations
  6244. @cindex @code{\N}, and translations
  6245. @cindex @code{char} request, and translations
  6246. @cindex special characters
  6247. @cindex character, special
  6248. @cindex numbered glyph (@code{\N})
  6249. @cindex glyph, numbered (@code{\N})
  6250. Special characters (@code{\(@var{xx}}, @code{\[@var{xxx}]},
  6251. @code{\C'@var{xxx}'}, @code{\'}, @code{\`}, @code{\-}, @code{\_}),
  6252. glyphs defined with the @code{char} request, and numbered glyphs
  6253. (@code{\N'@var{xxx}'}) can be translated also.
  6254. @item
  6255. @cindex @code{\e}, and translations
  6256. The @code{\e} escape can be translated also.
  6257. @item
  6258. @cindex @code{\%}, and translations
  6259. @cindex @code{\~}, and translations
  6260. Characters can be mapped onto the @code{\%} and @code{\~} escapes (but
  6261. @code{\%} and @code{\~} can't be mapped onto another glyph).
  6262. @item
  6263. @cindex backspace character, and translations
  6264. @cindex character, backspace, and translations
  6265. @cindex leader character, and translations
  6266. @cindex character, leader, and translations
  6267. @cindex newline character, and translations
  6268. @cindex character, newline, and translations
  6269. @cindex tab character, and translations
  6270. @cindex character, tab, and translations
  6271. @cindex @code{\a}, and translations
  6272. @cindex @code{\t}, and translations
  6273. The following characters can't be translated: space (with one exception,
  6274. see below), backspace, newline, leader (and @code{\a}), tab (and
  6275. @code{\t}).
  6276. @item
  6277. @cindex @code{shc} request, and translations
  6278. Translations are not considered for finding the soft hyphen character
  6279. set with the @code{shc} request.
  6280. @item
  6281. @cindex @code{\&}, and translations
  6282. The pair @samp{@var{c}\&} (this is an arbitrary character@tie{}@var{c}
  6283. followed by the zero width space character) maps this character to nothing.
  6284. @Example
  6285. .tr a\&
  6286. foo bar
  6287. @result{} foo br
  6288. @endExample
  6289. @noindent
  6290. It is even possible to map the space character to nothing:
  6291. @Example
  6292. .tr aa \&
  6293. foo bar
  6294. @result{} foobar
  6295. @endExample
  6296. @noindent
  6297. As shown in the example, the space character can't be the first
  6298. character/glyph pair as an argument of @code{tr}. Additionally, it is
  6299. not possible to map the space character to any other glyph; requests
  6300. like @w{@samp{.tr aa x}} undo @w{@samp{.tr aa \&}} instead.
  6301. If justification is active, lines are justified in spite of the
  6302. `empty' space character (but there is no minimal distance, i.e.@: the
  6303. space character, between words).
  6304. @item
  6305. After an output glyph has been constructed (this happens at the
  6306. moment immediately before the glyph is appended to an output
  6307. glyph list, either by direct output, in a macro, diversion, or
  6308. string), it is no longer affected by @code{tr}.
  6309. @item
  6310. Translating character to glyphs where one of them or both are
  6311. undefined is possible also; @code{tr} does not check whether the
  6312. entities in its argument do exist.
  6313. @xref{Gtroff Internals}.
  6314. @item
  6315. @code{troff} no longer has a hard-coded dependency on @w{Latin-1};
  6316. all @code{char@var{XXX}} entities have been removed from the font
  6317. description files. This has a notable consequence which shows up in
  6318. warnings like @code{can't find character with input code @var{XXX}}
  6319. if the @code{tr} request isn't handled properly.
  6320. Consider the following translation:
  6321. @Example
  6322. .tr éÉ
  6323. @endExample
  6324. @noindent
  6325. This maps input character @code{é} onto glyph @code{É}, which is
  6326. identical to glyph @code{char201}. But this glyph intentionally
  6327. doesn't exist! Instead, @code{\[char201]} is treated as an input
  6328. character entity and is by default mapped onto @code{\['E]}, and
  6329. @code{gtroff} doesn't handle translations of translations.
  6330. The right way to write the above translation is
  6331. @Example
  6332. .tr é\['E]
  6333. @endExample
  6334. @noindent
  6335. With other words, the first argument of @code{tr} should be an input
  6336. character or entity, and the second one a glyph entity.
  6337. @item
  6338. Without an argument, the @code{tr} request is ignored.
  6339. @end itemize
  6340. @endDefreq
  6341. @Defreq {trnt, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
  6342. @cindex @code{\!}, and @code{trnt}
  6343. @code{trnt} is the same as the @code{tr} request except that the
  6344. translations do not apply to text that is transparently throughput
  6345. into a diversion with @code{\!}. @xref{Diversions}, for more
  6346. information.
  6347. For example,
  6348. @Example
  6349. .tr ab
  6350. .di x
  6351. \!.tm a
  6352. .di
  6353. .x
  6354. @endExample
  6355. @noindent
  6356. prints @samp{b} to the standard error stream; if @code{trnt} is used
  6357. instead of @code{tr} it prints @samp{a}.
  6358. @endDefreq
  6359. @c =====================================================================
  6360. @node Troff and Nroff Mode, Line Layout, Character Translations, gtroff Reference
  6361. @section Troff and Nroff Mode
  6362. @cindex troff mode
  6363. @cindex mode, troff
  6364. @cindex nroff mode
  6365. @cindex mode, nroff
  6366. Originally, @code{nroff} and @code{troff} were two separate programs,
  6367. the former for TTY output, the latter for everything else. With GNU
  6368. @code{troff}, both programs are merged into one executable, sending
  6369. its output to a device driver (@code{grotty} for TTY devices,
  6370. @code{grops} for @sc{PostScript}, etc.) which interprets the
  6371. intermediate output of @code{gtroff}. For @acronym{UNIX} @code{troff}
  6372. it makes sense to talk about @dfn{Nroff mode} and @dfn{Troff mode}
  6373. since the differences are hardcoded. For GNU @code{troff}, this
  6374. distinction is not appropriate because @code{gtroff} simply takes the
  6375. information given in the font files for a particular device without
  6376. handling requests specially if a TTY output device is used.
  6377. Usually, a macro package can be used with all output devices.
  6378. Nevertheless, it is sometimes necessary to make a distinction between
  6379. TTY and non-TTY devices: @code{gtroff} provides two built-in
  6380. conditions @samp{n} and @samp{t} for the @code{if}, @code{ie}, and
  6381. @code{while} requests to decide whether @code{gtroff} shall behave
  6382. like @code{nroff} or like @code{troff}.
  6383. @Defreq {troff, }
  6384. @pindex troffrc
  6385. @pindex troffrc-end
  6386. Make the @samp{t} built-in condition true (and the @samp{n} built-in
  6387. condition false) for @code{if}, @code{ie}, and @code{while}
  6388. conditional requests. This is the default if @code{gtroff}
  6389. (@emph{not} @code{groff}) is started with the @option{-R} switch to
  6390. avoid loading of the start-up files @file{troffrc} and
  6391. @file{troffrc-end}. Without @option{-R}, @code{gtroff} stays in troff
  6392. mode if the output device is not a TTY (e.g.@: `ps').
  6393. @endDefreq
  6394. @Defreq {nroff, }
  6395. @pindex tty.tmac
  6396. Make the @samp{n} built-in condition true (and the @samp{t} built-in
  6397. condition false) for @code{if}, @code{ie}, and @code{while}
  6398. conditional requests. This is the default if @code{gtroff} uses a TTY
  6399. output device; the code for switching to nroff mode is in the file
  6400. @file{tty.tmac} which is loaded by the start-up file @code{troffrc}.
  6401. @endDefreq
  6402. @xref{Conditionals and Loops}, for more details on built-in
  6403. conditions.
  6404. @c =====================================================================
  6405. @node Line Layout, Line Control, Troff and Nroff Mode, gtroff Reference
  6406. @section Line Layout
  6407. @cindex line layout
  6408. @cindex layout, line
  6409. @cindex dimensions, line
  6410. @cindex line dimensions
  6411. The following drawing shows the dimensions which @code{gtroff} uses for
  6412. placing a line of output onto the page. They are labeled with the
  6413. request which manipulates each dimension.
  6414. @Example
  6415. -->| in |<--
  6416. |<-----------ll------------>|
  6417. +----+----+----------------------+----+
  6418. | : : : |
  6419. +----+----+----------------------+----+
  6420. -->| po |<--
  6421. |<--------paper width---------------->|
  6422. @endExample
  6423. @noindent
  6424. These dimensions are:
  6425. @ftable @code
  6426. @item po
  6427. @cindex left margin (@code{po})
  6428. @cindex margin, left (@code{po})
  6429. @cindex page offset (@code{po})
  6430. @cindex offset, page (@code{po})
  6431. @dfn{Page offset} -- this is the leftmost position of text on the final
  6432. output, defining the @dfn{left margin}.
  6433. @item in
  6434. @cindex indentation (@code{in})
  6435. @cindex line indentation (@code{in})
  6436. @dfn{Indentation} -- this is the distance from the left margin where
  6437. text is printed.
  6438. @item ll
  6439. @cindex line length (@code{ll})
  6440. @cindex length of line (@code{ll})
  6441. @dfn{Line length} -- this is the distance from the left margin to right
  6442. margin.
  6443. @end ftable
  6444. A simple demonstration:
  6445. @Example
  6446. .ll 3i
  6447. This is text without indentation.
  6448. The line length has been set to 3\~inch.
  6449. .in +.5i
  6450. .ll -.5i
  6451. Now the left and right margins are both increased.
  6452. .in
  6453. .ll
  6454. Calling .in and .ll without parameters restore
  6455. the previous values.
  6456. @endExample
  6457. Result:
  6458. @Example
  6459. This is text without indenta-
  6460. tion. The line length has
  6461. been set to 3 inch.
  6462. Now the left and
  6463. right margins are
  6464. both increased.
  6465. Calling .in and .ll without
  6466. parameters restore the previ-
  6467. ous values.
  6468. @endExample
  6469. @DefreqList {po, [@Var{offset}]}
  6470. @DefreqItem {po, @t{+}@Var{offset}}
  6471. @DefreqItem {po, @t{-}@Var{offset}}
  6472. @DefregListEnd {.o}
  6473. @pindex troffrc
  6474. Set horizontal page offset to @var{offset} (or increment or decrement
  6475. the current value by @var{offset}). Note that this request does not
  6476. cause a break, so changing the page offset in the middle of text being
  6477. filled may not yield the expected result. The initial value is
  6478. 1@dmn{i}. For TTY output devices, it is set to 0 in the startup file
  6479. @file{troffrc}; the default scaling indicator is @samp{m} (and
  6480. not @samp{v} as incorrectly documented in the original
  6481. @acronym{UNIX} troff manual).
  6482. The current page offset can be found in the read-only number register
  6483. @samp{.o}.
  6484. If @code{po} is called without an argument, the page offset is reset to
  6485. the previous value before the last call to @code{po}.
  6486. @Example
  6487. .po 3i
  6488. \n[.o]
  6489. @result{} 720
  6490. .po -1i
  6491. \n[.o]
  6492. @result{} 480
  6493. .po
  6494. \n[.o]
  6495. @result{} 720
  6496. @endExample
  6497. @endDefreq
  6498. @DefreqList {in, [@Var{indent}]}
  6499. @DefreqItem {in, @t{+}@Var{indent}}
  6500. @DefreqItem {in, @t{-}@Var{indent}}
  6501. @DefregListEnd {.i}
  6502. Set indentation to @var{indent} (or increment or decrement the
  6503. current value by @var{indent}). This request causes a break.
  6504. Initially, there is no indentation.
  6505. If @code{in} is called without an argument, the indentation is reset to
  6506. the previous value before the last call to @code{in}. The default
  6507. scaling indicator is @samp{m}.
  6508. The indentation is associated with the current environment
  6509. (@pxref{Environments}).
  6510. If a negative indentation value is specified (which is not allowed),
  6511. @code{gtroff} emits a warning of type @samp{range} and sets the
  6512. indentation to zero.
  6513. The effect of @code{in} is delayed until a partially collected line
  6514. (if it exists) is output. A temporary indentation value is reset to
  6515. zero also.
  6516. The current indentation (as set by @code{in}) can be found in the
  6517. read-only number register @samp{.i}.
  6518. @endDefreq
  6519. @DefreqList {ti, offset}
  6520. @DefreqItem {ti, @t{+}@Var{offset}}
  6521. @DefreqItem {ti, @t{-}@Var{offset}}
  6522. @DefregListEnd {.in}
  6523. Temporarily indent the next output line by @var{offset}. If an
  6524. increment or decrement value is specified, adjust the temporary
  6525. indentation relative to the value set by the @code{in} request.
  6526. This request causes a break; its value is associated with the current
  6527. environment (@pxref{Environments}). The default scaling indicator
  6528. is @samp{m}. A call of @code{ti} without an argument is ignored.
  6529. If the total indentation value is negative (which is not allowed),
  6530. @code{gtroff} emits a warning of type @samp{range} and sets the
  6531. temporary indentation to zero. `Total indentation' is either
  6532. @var{offset} if specified as an absolute value, or the temporary plus
  6533. normal indentation, if @var{offset} is given as a relative value.
  6534. The effect of @code{ti} is delayed until a partially collected line (if
  6535. it exists) is output.
  6536. The read-only number register @code{.in} is the indentation that applies
  6537. to the current output line.
  6538. The difference between @code{.i} and @code{.in} is that the latter takes
  6539. into account whether a partially collected line still uses the old
  6540. indentation value or a temporary indentation value is active.
  6541. @endDefreq
  6542. @DefreqList {ll, [@Var{length}]}
  6543. @DefreqItem {ll, @t{+}@Var{length}}
  6544. @DefreqItem {ll, @t{-}@Var{length}}
  6545. @DefregItem {.l}
  6546. @DefregListEnd {.ll}
  6547. Set the line length to @var{length} (or increment or decrement the
  6548. current value by @var{length}). Initially, the line length is set to
  6549. 6.5@dmn{i}. The effect of @code{ll} is delayed until a partially
  6550. collected line (if it exists) is output. The default scaling
  6551. indicator is @samp{m}.
  6552. If @code{ll} is called without an argument, the line length is reset to
  6553. the previous value before the last call to @code{ll}. If a negative
  6554. line length is specified (which is not allowed), @code{gtroff} emits a
  6555. warning of type @samp{range} and sets the line length to zero.
  6556. The line length is associated with the current environment
  6557. (@pxref{Environments}).
  6558. @cindex line length register (@code{.l})
  6559. The current line length (as set by @code{ll}) can be found in the
  6560. read-only number register @samp{.l}. The read-only number register
  6561. @code{.ll} is the line length that applies to the current output line.
  6562. Similar to @code{.i} and @code{.in}, the difference between @code{.l}
  6563. and @code{.ll} is that the latter takes into account whether a partially
  6564. collected line still uses the old line length value.
  6565. @endDefreq
  6566. @c =====================================================================
  6567. @node Line Control, Page Layout, Line Layout, gtroff Reference
  6568. @section Line Control
  6569. @cindex line control
  6570. @cindex control, line
  6571. It is important to understand how @code{gtroff} handles input and output
  6572. lines.
  6573. Many escapes use positioning relative to the input line. For example,
  6574. this
  6575. @Example
  6576. This is a \h'|1.2i'test.
  6577. This is a
  6578. \h'|1.2i'test.
  6579. @endExample
  6580. @noindent
  6581. produces
  6582. @Example
  6583. This is a test.
  6584. This is a test.
  6585. @endExample
  6586. The main usage of this feature is to define macros which act exactly
  6587. at the place where called.
  6588. @Example
  6589. .\" A simple macro to underline a word
  6590. .de underline
  6591. . nop \\$1\l'|0\[ul]'
  6592. ..
  6593. @endExample
  6594. @noindent
  6595. In the above example, @samp{|0} specifies a negative distance from the
  6596. current position (at the end of the just emitted argument @code{\$1}) back
  6597. to the beginning of the input line. Thus, the @samp{\l} escape draws a
  6598. line from right to left.
  6599. @cindex input line continuation (@code{\})
  6600. @cindex line, input, continuation (@code{\})
  6601. @cindex continuation, input line (@code{\})
  6602. @cindex output line, continuation (@code{\c})
  6603. @cindex line, output, continuation (@code{\c})
  6604. @cindex continuation, output line (@code{\c})
  6605. @cindex interrupted line
  6606. @cindex line, interrupted
  6607. @code{gtroff} makes a difference between input and output line
  6608. continuation; the latter is also called @dfn{interrupting} a line.
  6609. @DefescList {\\@key{RET}, , ,}
  6610. @DefescItem {\\c, , ,}
  6611. @DefregListEnd{.int}
  6612. Continue a line. @code{\@key{RET}} (this is a backslash at the end
  6613. of a line immediately followed by a newline) works on the input level,
  6614. suppressing the effects of the following newline in the input.
  6615. @Example
  6616. This is a \
  6617. .test
  6618. @result{} This is a .test
  6619. @endExample
  6620. The @samp{|} operator is also affected.
  6621. @cindex @code{\R}, after @code{\c}
  6622. @code{\c} works on the output level. Anything after this escape on the
  6623. same line is ignored, except @code{\R} which works as usual. Anything
  6624. before @code{\c} on the same line will be appended to the current partial
  6625. output line. The next non-command line after an interrupted line counts
  6626. as a new input line.
  6627. The visual results depend on whether no-fill mode is active.
  6628. @itemize @bullet
  6629. @item
  6630. @cindex @code{\c}, and no-fill mode
  6631. @cindex no-fill mode, and @code{\c}
  6632. @cindex mode, no-fill, and @code{\c}
  6633. If no-fill mode is active (using the @code{nf} request), the next input
  6634. text line after @code{\c} will be handled as a continuation of the same
  6635. input text line.
  6636. @Example
  6637. .nf
  6638. This is a \c
  6639. test.
  6640. @result{} This is a test.
  6641. @endExample
  6642. @item
  6643. @cindex @code{\c}, and fill mode
  6644. @cindex fill mode, and @code{\c}
  6645. @cindex mode, fill, and @code{\c}
  6646. If fill mode is active (using the @code{fi} request), a word interrupted
  6647. with @code{\c} will be continued with the text on the next input text line,
  6648. without an intervening space.
  6649. @Example
  6650. This is a te\c
  6651. st.
  6652. @result{} This is a test.
  6653. @endExample
  6654. @end itemize
  6655. Note that an intervening control line which causes a break is stronger
  6656. than @code{\c}, flushing out the current partial line in the usual way.
  6657. @cindex interrupted line register (@code{.int})
  6658. The @code{.int} register contains a positive value
  6659. if the last output line was interrupted with @code{\c}; this is
  6660. associated with the current environment (@pxref{Environments}).
  6661. @endDefesc
  6662. @c =====================================================================
  6663. @node Page Layout, Page Control, Line Control, gtroff Reference
  6664. @section Page Layout
  6665. @cindex page layout
  6666. @cindex layout, page
  6667. @code{gtroff} provides some very primitive operations for controlling
  6668. page layout.
  6669. @DefreqList {pl, [@Var{length}]}
  6670. @DefreqItem {pl, @t{+}@Var{length}}
  6671. @DefreqItem {pl, @t{-}@Var{length}}
  6672. @DefregListEnd {.p}
  6673. @cindex page length (@code{pl})
  6674. @cindex length of page (@code{pl})
  6675. Set the @dfn{page length} to @var{length} (or increment or decrement
  6676. the current value by @var{length}). This is the length of the
  6677. physical output page. The default scaling indicator is @samp{v}.
  6678. @cindex page length register (@code{.p})
  6679. The current setting can be found in the read-only number register
  6680. @samp{.p}.
  6681. @cindex top margin
  6682. @cindex margin, top
  6683. @cindex bottom margin
  6684. @cindex margin, bottom
  6685. Note that this only specifies the size of the page, not the top and
  6686. bottom margins. Those are not set by @code{gtroff} directly.
  6687. @xref{Traps}, for further information on how to do this.
  6688. Negative @code{pl} values are possible also, but not very useful: No
  6689. trap is sprung, and each line is output on a single page (thus
  6690. suppressing all vertical spacing).
  6691. If no argument or an invalid argument is given, @code{pl} sets the page
  6692. length to 11@dmn{i}.
  6693. @endDefreq
  6694. @cindex headers
  6695. @cindex footers
  6696. @cindex titles
  6697. @code{gtroff} provides several operations which help in setting up top
  6698. and bottom titles (or headers and footers).
  6699. @Defreq {tl, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}}
  6700. @cindex title line (@code{tl})
  6701. @cindex three-part title (@code{tl})
  6702. @cindex page number character (@code{%})
  6703. Print a @dfn{title line}. It consists of three parts: a left
  6704. justified portion, a centered portion, and a right justified portion.
  6705. The argument separator @samp{'} can be replaced with any character not
  6706. occurring in the title line. The @samp{%} character is replaced with
  6707. the current page number. This character can be changed with the
  6708. @code{pc} request (see below).
  6709. Without argument, @code{tl} is ignored.
  6710. Some notes:
  6711. @itemize @bullet
  6712. @item
  6713. A title line is not restricted to the top or bottom of a page.
  6714. @item
  6715. @code{tl} prints the title line immediately, ignoring a partially filled
  6716. line (which stays untouched).
  6717. @item
  6718. It is not an error to omit closing delimiters. For example,
  6719. @w{@samp{.tl /foo}} is equivalent to @w{@samp{.tl /foo///}}: It prints a
  6720. title line with the left justified word @samp{foo}; the centered and
  6721. right justfied parts are empty.
  6722. @item
  6723. @code{tl} accepts the same parameter delimiting characters as the
  6724. @code{\A} escape; see @ref{Escapes}.
  6725. @end itemize
  6726. @endDefreq
  6727. @DefreqList {lt, [@Var{length}]}
  6728. @DefreqItem {lt, @t{+}@Var{length}}
  6729. @DefreqItem {lt, @t{-}@Var{length}}
  6730. @DefregListEnd {.lt}
  6731. @cindex length of title line (@code{lt})
  6732. @cindex title line, length (@code{lt})
  6733. @cindex title line length register (@code{.lt})
  6734. The title line is printed using its own line length, which is
  6735. specified (or incremented or decremented) with the @code{lt} request.
  6736. Initially, the title line length is set to 6.5@dmn{i}. If a negative
  6737. line length is specified (which is not allowed), @code{gtroff} emits a
  6738. warning of type @samp{range} and sets the title line length to zero.
  6739. The default scaling indicator is @samp{m}. If @code{lt} is called
  6740. without an argument, the title length is reset to the previous value
  6741. before the last call to @code{lt}.
  6742. The current setting of this is available in the @code{.lt} read-only
  6743. number register; it is associated with the current environment
  6744. (@pxref{Environments}).
  6745. @endDefreq
  6746. @DefreqList {pn, page}
  6747. @DefreqItem {pn, @t{+}@Var{page}}
  6748. @DefreqItem {pn, @t{-}@Var{page}}
  6749. @DefregListEnd {.pn}
  6750. @cindex page number (@code{pn})
  6751. @cindex number, page (@code{pn})
  6752. Change (increase or decrease) the page number of the @emph{next} page.
  6753. The only argument is the page number; the request is ignored without a
  6754. parameter.
  6755. The read-only number register @code{.pn} contains the number of the next
  6756. page: either the value set by a @code{pn} request, or the number of the
  6757. current page plus@tie{}1.
  6758. @endDefreq
  6759. @Defreq {pc, [@Var{char}]}
  6760. @cindex changing the page number character (@code{pc})
  6761. @cindex page number character, changing (@code{pc})
  6762. @vindex %
  6763. Change the page number character (used by the @code{tl} request) to a
  6764. different character. With no argument, this mechanism is disabled.
  6765. Note that this doesn't affect the number register@tie{}@code{%}.
  6766. @endDefreq
  6767. @xref{Traps}.
  6768. @c =====================================================================
  6769. @node Page Control, Fonts and Symbols, Page Layout, gtroff Reference
  6770. @section Page Control
  6771. @cindex page control
  6772. @cindex control, page
  6773. @DefreqList {bp, [@Var{page}]}
  6774. @DefreqItem {bp, @t{+}@Var{page}}
  6775. @DefreqItem {bp, @t{-}@Var{page}}
  6776. @DefregListEnd {%}
  6777. @cindex new page (@code{bp})
  6778. @cindex page, new (@code{bp})
  6779. Stop processing the current page and move to the next page. This
  6780. request causes a break. It can also take an argument to set
  6781. (increase, decrease) the page number of the next page (which actually
  6782. becomes the current page after @code{bp} has finished). The
  6783. difference between @code{bp} and @code{pn} is that @code{pn} does not
  6784. cause a break or actually eject a page. @xref{Page Layout}.
  6785. @Example
  6786. .de newpage \" define macro
  6787. 'bp \" begin page
  6788. 'sp .5i \" vertical space
  6789. .tl 'left top'center top'right top' \" title
  6790. 'sp .3i \" vertical space
  6791. .. \" end macro
  6792. @endExample
  6793. @cindex @code{bp} request, and top-level diversion
  6794. @cindex top-level diversion, and @code{bp}
  6795. @cindex diversion, top-level, and @code{bp}
  6796. @code{bp} has no effect if not called within the top-level diversion
  6797. (@pxref{Diversions}).
  6798. @cindex page number register (@code{%})
  6799. @cindex current page number (@code{%})
  6800. The read-write register@tie{}@code{%} holds the current page number.
  6801. The number register @code{.pe} is set to@tie{}1 while @code{bp} is
  6802. active. @xref{Page Location Traps}.
  6803. @endDefreq
  6804. @Defreq {ne, [@Var{space}]}
  6805. @cindex orphan lines, preventing with @code{ne}
  6806. @cindex conditional page break (@code{ne})
  6807. @cindex page break, conditional (@code{ne})
  6808. It is often necessary to force a certain amount of space before a new
  6809. page occurs. This is most useful to make sure that there is not a
  6810. single @dfn{orphan} line left at the bottom of a page. The @code{ne}
  6811. request ensures that there is a certain distance, specified by the
  6812. first argument, before the next page is triggered (see @ref{Traps},
  6813. for further information). The default scaling indicator for @code{ne}
  6814. is @samp{v}; the default value of @var{space} is@tie{}1@dmn{v} if no
  6815. argument is given.
  6816. For example, to make sure that no fewer than 2@tie{}lines get orphaned,
  6817. do the following before each paragraph:
  6818. @Example
  6819. .ne 2
  6820. text text text
  6821. @endExample
  6822. @code{ne} will then automatically cause a page break if there is space
  6823. for one line only.
  6824. @endDefreq
  6825. @DefreqList {sv, [@Var{space}]}
  6826. @DefreqListEnd {os, }
  6827. @cindex @code{ne} request, comparison with @code{sv}
  6828. @code{sv} is similar to the @code{ne} request; it reserves the
  6829. specified amount of vertical space. If the desired amount of space
  6830. exists before the next trap (or the bottom page boundary if no trap is
  6831. set), the space is output immediately (ignoring a partially filled line
  6832. which stays untouched). If there is not enough space, it is stored for
  6833. later output via the @code{os} request. The default value is@tie{}1@dmn{v}
  6834. if no argument is given; the default scaling indicator is @samp{v}.
  6835. @cindex @code{sv} request, and no-space mode
  6836. @cindex @code{os} request, and no-space mode
  6837. Both @code{sv} and @code{os} ignore no-space mode. While the @code{sv}
  6838. request allows negative values for @var{space}, @code{os} will ignore
  6839. them.
  6840. @endDefreq
  6841. @Defreg {nl}
  6842. @cindex current vertical position (@code{nl})
  6843. @cindex vertical position, current (@code{nl})
  6844. @cindex position, vertical, current (@code{nl})
  6845. This register contains the current vertical position. If the vertical
  6846. position is zero and the top of page transition hasn't happened yet,
  6847. @code{nl} is set to negative value. @code{gtroff} itself does this at
  6848. the very beginning of a document before anything has been printed, but
  6849. the main usage is to plant a header trap on a page if this page has
  6850. already started.
  6851. Consider the following:
  6852. @Example
  6853. .de xxx
  6854. . sp
  6855. . tl ''Header''
  6856. . sp
  6857. ..
  6858. .
  6859. First page.
  6860. .bp
  6861. .wh 0 xxx
  6862. .nr nl (-1)
  6863. Second page.
  6864. @endExample
  6865. @noindent
  6866. Result:
  6867. @Example
  6868. First page.
  6869. ...
  6870. Header
  6871. Second page.
  6872. ...
  6873. @endExample
  6874. @noindent
  6875. Without resetting @code{nl} to a negative value, the just planted trap
  6876. would be active beginning with the @emph{next} page, not the current
  6877. one.
  6878. @xref{Diversions}, for a comparison with the @code{.h} and @code{.d}
  6879. registers.
  6880. @endDefreg
  6881. @c =====================================================================
  6882. @node Fonts and Symbols, Sizes, Page Control, gtroff Reference
  6883. @section Fonts and Symbols
  6884. @cindex fonts
  6885. @code{gtroff} can switch fonts at any point in the text.
  6886. The basic set of fonts is @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
  6887. These are Times Roman, Italic, Bold, and Bold Italic. For non-TTY
  6888. devices, there is also at least one symbol font which contains various
  6889. special symbols (Greek, mathematics).
  6890. @menu
  6891. * Changing Fonts::
  6892. * Font Families::
  6893. * Font Positions::
  6894. * Using Symbols::
  6895. * Special Fonts::
  6896. * Artificial Fonts::
  6897. * Ligatures and Kerning::
  6898. @end menu
  6899. @c ---------------------------------------------------------------------
  6900. @node Changing Fonts, Font Families, Fonts and Symbols, Fonts and Symbols
  6901. @subsection Changing Fonts
  6902. @cindex fonts
  6903. @DefreqList {ft, [@Var{font}]}
  6904. @DefescItem {\\f, , f, }
  6905. @DefescItem {\\f, @Lparen{}, fn, }
  6906. @DefescItem {\\f, @Lbrack{}, font, @Rbrack{}}
  6907. @DefregListEnd {.sty}
  6908. @cindex changing fonts (@code{ft}, @code{\f})
  6909. @cindex fonts, changing (@code{ft}, @code{\f})
  6910. @cindex @code{sty} request, and changing fonts
  6911. @cindex @code{fam} request, and changing fonts
  6912. @cindex @code{\F}, and changing fonts
  6913. @kindex styles
  6914. @kindex family
  6915. @pindex DESC
  6916. The @code{ft} request and the @code{\f} escape change the current font
  6917. to @var{font} (one-character name@tie{}@var{f}, two-character name
  6918. @var{fn}).
  6919. If @var{font} is a style name (as set with the @code{sty} request or
  6920. with the @code{styles} command in the @file{DESC} file), use it within
  6921. the current font family (as set with the @code{fam} request, @code{\F}
  6922. escape, or with the @code{family} command in the @file{DESC} file).
  6923. @cindex previous font (@code{ft}, @code{\f[]}, @code{\fP})
  6924. @cindex font, previous (@code{ft}, @code{\f[]}, @code{\fP})
  6925. With no argument or using @samp{P} as an argument, @code{.ft} switches
  6926. to the previous font. Use @code{\f[]} to do this with the escape. The
  6927. old syntax forms @code{\fP} or @code{\f[P]} are also supported.
  6928. Fonts are generally specified as upper-case strings, which are usually
  6929. 1@tie{}to 4 characters representing an abbreviation or acronym of the
  6930. font name. This is no limitation, just a convention.
  6931. The example below produces two identical lines.
  6932. @Example
  6933. eggs, bacon,
  6934. .ft B
  6935. spam
  6936. .ft
  6937. and sausage.
  6938. eggs, bacon, \fBspam\fP and sausage.
  6939. @endExample
  6940. Note that @code{\f} doesn't produce an input token in @code{gtroff}.
  6941. As a consequence, it can be used in requests like @code{mc} (which
  6942. expects a single character as an argument) to change the font on
  6943. the fly:
  6944. @Example
  6945. .mc \f[I]x\f[]
  6946. @endExample
  6947. The current style name is available in the read-only number register
  6948. @samp{.sty} (this is a string-valued register); if the current font
  6949. isn't a style, the empty string is returned. It is associated with
  6950. the current environment.
  6951. @xref{Font Positions}, for an alternative syntax.
  6952. @endDefreq
  6953. @Defreq {ftr, f [@Var{g}]}
  6954. @cindex @code{ft} request, and font translations
  6955. @cindex @code{ul} request, and font translations
  6956. @cindex @code{bd} request, and font translations
  6957. @cindex @code{\f}, and font translations
  6958. @cindex @code{cs} request, and font translations
  6959. @cindex @code{tkf} request, and font translations
  6960. @cindex @code{special} request, and font translations
  6961. @cindex @code{fspecial} request, and font translations
  6962. @cindex @code{fp} request, and font translations
  6963. @cindex @code{sty} request, and font translations
  6964. @cindex @code{if} request, and font translations
  6965. @cindex @code{ie} request, and font translations
  6966. @cindex @code{while} request, and font translations
  6967. Translate font@tie{}@var{f} to font@tie{}@var{g}. Whenever a font
  6968. named@tie{}@var{f} is referred to in a @code{\f} escape sequence,
  6969. in the @code{F} and @code{S} conditional operators, or in the
  6970. @code{ft}, @code{ul}, @code{bd}, @code{cs}, @code{tkf},
  6971. @code{special}, @code{fspecial}, @code{fp}, or @code{sty} requests,
  6972. font@tie{}@var{g} is used. If @var{g} is missing or equal to@tie{}@var{f}
  6973. the translation is undone.
  6974. @endDefreq
  6975. @c ---------------------------------------------------------------------
  6976. @node Font Families, Font Positions, Changing Fonts, Fonts and Symbols
  6977. @subsection Font Families
  6978. @cindex font families
  6979. @cindex families, font
  6980. @cindex font styles
  6981. @cindex styles, font
  6982. Due to the variety of fonts available, @code{gtroff} has added the
  6983. concept of @dfn{font families} and @dfn{font styles}. The fonts are
  6984. specified as the concatenation of the font family and style. Specifying
  6985. a font without the family part causes @code{gtroff} to use that style of
  6986. the current family.
  6987. @cindex PostScript fonts
  6988. @cindex fonts, PostScript
  6989. Currently, fonts for the devices @option{-Tps}, @option{-Tdvi},
  6990. @option{-Tlj4}, @option{-Tlbp}, and the X11 fonts are set up to this
  6991. mechanism. By default, @code{gtroff} uses the Times family with the four
  6992. styles @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
  6993. This way, it is possible to use the basic four fonts and to select a
  6994. different font family on the command line (@pxref{Groff Options}).
  6995. @DefreqList {fam, [@Var{family}]}
  6996. @DefregItem {.fam}
  6997. @DefescItem {\\F, , f, }
  6998. @DefescItem {\\F, @Lparen{}, fm, }
  6999. @DefescItem {\\F, @Lbrack{}, family, @Rbrack{}}
  7000. @DefregListEnd {.fn}
  7001. @cindex changing font family (@code{fam}, @code{\F})
  7002. @cindex font family, changing (@code{fam}, @code{\F})
  7003. Switch font family to @var{family} (one-character name@tie{}@var{f},
  7004. two-character name @var{fm}). If no argument is given, switch
  7005. back to the previous font family. Use @code{\F[]} to do this with the
  7006. escape. Note that @code{\FP} doesn't work; it selects font family
  7007. @samp{P} instead.
  7008. The value at start-up is @samp{T}.
  7009. The current font family is available in the read-only number register
  7010. @samp{.fam} (this is a string-valued register); it is associated with
  7011. the current environment.
  7012. @Example
  7013. spam,
  7014. .fam H \" helvetica family
  7015. spam, \" used font is family H + style R = HR
  7016. .ft B \" family H + style B = font HB
  7017. spam,
  7018. .fam T \" times family
  7019. spam, \" used font is family T + style B = TB
  7020. .ft AR \" font AR (not a style)
  7021. baked beans,
  7022. .ft R \" family T + style R = font TR
  7023. and spam.
  7024. @endExample
  7025. Note that @code{\F} doesn't produce an input token in @code{gtroff}.
  7026. As a consequence, it can be used in requests like @code{mc} (which
  7027. expects a single character as an argument) to change the font family on
  7028. the fly:
  7029. @Example
  7030. .mc \F[P]x\F[]
  7031. @endExample
  7032. The @samp{.fn} register contains the current @dfn{real font name}
  7033. of the current font.
  7034. This is a string-valued register.
  7035. If the current font is a style, the value of @code{\n[.fn]}
  7036. is the proper concatenation of family and style name.
  7037. @endDefreq
  7038. @Defreq {sty, n style}
  7039. @cindex changing font style (@code{sty})
  7040. @cindex font style, changing (@code{sty})
  7041. @cindex @code{cs} request, and font styles
  7042. @cindex @code{bd} request, and font styles
  7043. @cindex @code{tkf} request, and font styles
  7044. @cindex @code{uf} request, and font styles
  7045. @cindex @code{fspecial} request, and font styles
  7046. Associate @var{style} with font position@tie{}@var{n}. A font position
  7047. can be associated either with a font or with a style. The current
  7048. font is the index of a font position and so is also either a font or a
  7049. style. If it is a style, the font that is actually used is the font
  7050. which name is the concatenation of the name of the current
  7051. family and the name of the current style. For example, if the current
  7052. font is@tie{}1 and font position@tie{}1 is associated with style
  7053. @samp{R} and the current font family is @samp{T}, then font
  7054. @samp{TR} will be used. If the current font is not a style, then the
  7055. current family is ignored. If the requests @code{cs}, @code{bd},
  7056. @code{tkf}, @code{uf}, or @code{fspecial} are applied to a style,
  7057. they will instead be applied to the member of the current family
  7058. corresponding to that style.
  7059. @var{n}@tie{}must be a non-negative integer value.
  7060. @pindex DESC
  7061. @kindex styles
  7062. The default family can be set with the @option{-f} option
  7063. (@pxref{Groff Options}). The @code{styles} command in the @file{DESC}
  7064. file controls which font positions (if any) are initially associated
  7065. with styles rather than fonts. For example, the default setting for
  7066. @sc{PostScript} fonts
  7067. @Example
  7068. styles R I B BI
  7069. @endExample
  7070. @noindent
  7071. is equivalent to
  7072. @Example
  7073. .sty 1 R
  7074. .sty 2 I
  7075. .sty 3 B
  7076. .sty 4 BI
  7077. @endExample
  7078. @code{fam} and @code{\F} always check whether the current font position
  7079. is valid; this can give surprising results if the current font position is
  7080. associated with a style.
  7081. In the following example, we want to access the @sc{PostScript} font
  7082. @code{FooBar} from the font family @code{Foo}:
  7083. @Example
  7084. .sty \n[.fp] Bar
  7085. .fam Foo
  7086. @result{} warning: can't find font `FooR'
  7087. @endExample
  7088. @noindent
  7089. The default font position at start-up is@tie{}1; for the
  7090. @sc{PostScript} device, this is associated with style @samp{R}, so
  7091. @code{gtroff} tries to open @code{FooR}.
  7092. A solution to this problem is to use a dummy font like the following:
  7093. @Example
  7094. .fp 0 dummy TR \" set up dummy font at position 0
  7095. .sty \n[.fp] Bar \" register style `Bar'
  7096. .ft 0 \" switch to font at position 0
  7097. .fam Foo \" activate family `Foo'
  7098. .ft Bar \" switch to font `FooBar'
  7099. @endExample
  7100. @xref{Font Positions}.
  7101. @endDefreq
  7102. @c ---------------------------------------------------------------------
  7103. @node Font Positions, Using Symbols, Font Families, Fonts and Symbols
  7104. @subsection Font Positions
  7105. @cindex font positions
  7106. @cindex positions, font
  7107. For the sake of old phototypesetters and compatibility with old versions
  7108. of @code{troff}, @code{gtroff} has the concept of font @dfn{positions},
  7109. on which various fonts are mounted.
  7110. @DefreqList {fp, pos font [@Var{external-name}]}
  7111. @DefregItem {.f}
  7112. @DefregListEnd {.fp}
  7113. @cindex mounting font (@code{fp})
  7114. @cindex font, mounting (@code{fp})
  7115. Mount font @var{font} at position @var{pos} (which must be a
  7116. non-negative integer). This numeric position can then be referred to
  7117. with font changing commands. When @code{gtroff} starts it is using
  7118. font position@tie{}1 (which must exist; position@tie{}0 is unused
  7119. usually at start-up).
  7120. @cindex font position register (@code{.f})
  7121. The current font in use, as a font position, is available in the
  7122. read-only number register @samp{.f}. This can be useful to remember the
  7123. current font for later recall. It is associated with the current
  7124. environment (@pxref{Environments}).
  7125. @Example
  7126. .nr save-font \n[.f]
  7127. .ft B
  7128. ... text text text ...
  7129. .ft \n[save-font]
  7130. @endExample
  7131. @cindex next free font position register (@code{.fp})
  7132. The number of the next free font position is available in the read-only
  7133. number register @samp{.fp}. This is useful when mounting a new font,
  7134. like so:
  7135. @Example
  7136. .fp \n[.fp] NEATOFONT
  7137. @endExample
  7138. @pindex DESC@r{, and font mounting}
  7139. Fonts not listed in the @file{DESC} file are automatically mounted on
  7140. the next available font position when they are referenced. If a font
  7141. is to be mounted explicitly with the @code{fp} request on an unused
  7142. font position, it should be mounted on the first unused font position,
  7143. which can be found in the @code{.fp} register. Although @code{gtroff}
  7144. does not enforce this strictly, it is not allowed to mount a font at a
  7145. position whose number is much greater (approx.@: 1000 positions) than
  7146. that of any currently used position.
  7147. The @code{fp} request has an optional third argument. This argument
  7148. gives the external name of the font, which is used for finding the font
  7149. description file. The second argument gives the internal name of the
  7150. font which is used to refer to the font in @code{gtroff} after it has
  7151. been mounted. If there is no third argument then the internal name is
  7152. used as the external name. This feature makes it possible to use
  7153. fonts with long names in compatibility mode.
  7154. @endDefreq
  7155. Both the @code{ft} request and the @code{\f} escape have alternative
  7156. syntax forms to access font positions.
  7157. @DefreqList {ft, nnn}
  7158. @DefescItem {\\f, , n, }
  7159. @DefescItem {\\f, @Lparen{}, nn, }
  7160. @DefescListEnd {\\f, @Lbrack{}, nnn, @Rbrack{}}
  7161. @cindex changing font position (@code{\f})
  7162. @cindex font position, changing (@code{\f})
  7163. @cindex @code{sty} request, and font positions
  7164. @cindex @code{fam} request, and font positions
  7165. @cindex @code{\F}, and font positions
  7166. @kindex styles
  7167. @kindex family
  7168. @pindex DESC
  7169. Change the current font position to @var{nnn} (one-digit
  7170. position@tie{}@var{n}, two-digit position @var{nn}), which must be a
  7171. non-negative integer.
  7172. If @var{nnn} is associated with a style (as set with the @code{sty}
  7173. request or with the @code{styles} command in the @file{DESC} file), use
  7174. it within the current font family (as set with the @code{fam} request,
  7175. the @code{\F} escape, or with the @code{family} command in the @file{DESC}
  7176. file).
  7177. @Example
  7178. this is font 1
  7179. .ft 2
  7180. this is font 2
  7181. .ft \" switch back to font 1
  7182. .ft 3
  7183. this is font 3
  7184. .ft
  7185. this is font 1 again
  7186. @endExample
  7187. @xref{Changing Fonts}, for the standard syntax form.
  7188. @endDefreq
  7189. @c ---------------------------------------------------------------------
  7190. @node Using Symbols, Special Fonts, Font Positions, Fonts and Symbols
  7191. @subsection Using Symbols
  7192. @cindex using symbols
  7193. @cindex symbols, using
  7194. @cindex glyph
  7195. @cindex character
  7196. @cindex ligature
  7197. A @dfn{glyph} is a graphical representation of a @dfn{character}.
  7198. While a character is an abstract entity containing semantic
  7199. information, a glyph is something which can be actually seen on screen
  7200. or paper. It is possible that a character has multiple glyph
  7201. representation forms (for example, the character `A' can be either
  7202. written in a roman or an italic font, yielding two different glyphs);
  7203. sometimes more than one character maps to a single glyph (this is a
  7204. @dfn{ligature} -- the most common is `fi').
  7205. @cindex symbol
  7206. @cindex special fonts
  7207. @kindex fonts
  7208. @pindex DESC
  7209. @cindex @code{special} request, and glyph search order
  7210. @cindex @code{fspecial} request, and glyph search order
  7211. A @dfn{symbol} is simply a named glyph. Within @code{gtroff}, all
  7212. glyph names of a particular font are defined in its font file. If the
  7213. user requests a glyph not available in this font, @code{gtroff} looks
  7214. up an ordered list of @dfn{special fonts}. By default, the
  7215. @sc{PostScript} output device supports the two special fonts @samp{SS}
  7216. (slanted symbols) and @samp{S} (symbols) (the former is looked up
  7217. before the latter). Other output devices use different names for
  7218. special fonts. Fonts mounted with the @code{fonts} keyword in the
  7219. @file{DESC} file are globally available. To install additional
  7220. special fonts locally (i.e.@: for a particular font), use the
  7221. @code{fspecial} request.
  7222. Here the exact rules how @code{gtroff} searches a given symbol:
  7223. @itemize @bullet
  7224. @item
  7225. If the symbol has been defined with the @code{char} request, use it.
  7226. This hides a symbol with the same name in the current font.
  7227. @item
  7228. Check the current font.
  7229. @item
  7230. If the symbol has been defined with the @code{fchar} request, use it.
  7231. @item
  7232. Check whether the current font has a font-specific list of special fonts;
  7233. test all fonts in the order of appearance in the last @code{fspecial}
  7234. call if appropriate.
  7235. @item
  7236. If the symbol has been defined with the @code{fschar} request for the
  7237. current font, use it.
  7238. @item
  7239. Check all fonts in the order of appearance in the last @code{special}
  7240. call.
  7241. @item
  7242. If the symbol has been defined with the @code{schar} request, use it.
  7243. @item
  7244. As a last resort, consult all fonts loaded up to now for special fonts
  7245. and check them, starting with the lowest font number. Note that this can
  7246. sometimes lead to surprising results since the @code{fonts} line in the
  7247. @file{DESC} file often contains empty positions which are filled later
  7248. on. For example, consider the following:
  7249. @Example
  7250. fonts 3 0 0 FOO
  7251. @endExample
  7252. @noindent
  7253. This mounts font @code{foo} at font position@tie{}3. We assume that
  7254. @code{FOO} is a special font, containing glyph @code{foo},
  7255. and that no font has been loaded yet. The line
  7256. @Example
  7257. .fspecial BAR BAZ
  7258. @endExample
  7259. @noindent
  7260. makes font @code{BAZ} special only if font @code{BAR} is active. We
  7261. further assume that @code{BAZ} is really a special font, i.e., the font
  7262. description file contains the @code{special} keyword, and that it
  7263. also contains glyph @code{foo} with a special shape fitting to font
  7264. @code{BAR}. After executing @code{fspecial}, font @code{BAR} is loaded at
  7265. font position@tie{}1, and @code{BAZ} at position@tie{}2.
  7266. We now switch to a new font @code{XXX}, trying to access glyph @code{foo}
  7267. which is assumed to be missing. There are neither font-specific special
  7268. fonts for @code{XXX} nor any other fonts made special with the
  7269. @code{special} request, so @code{gtroff} starts the search for special
  7270. fonts in the list of already mounted fonts, with increasing font
  7271. positions. Consequently, it finds @code{BAZ} before @code{FOO} even for
  7272. @code{XXX} which is not the intended behaviour.
  7273. @end itemize
  7274. @xref{Font Files}, and @ref{Special Fonts}, for more details.
  7275. @cindex list of available glyphs (@cite{groff_char(7)} man page)
  7276. @cindex available glyphs, list (@cite{groff_char(7)} man page)
  7277. @cindex glyphs, available, list (@cite{groff_char(7)} man page)
  7278. The list of available symbols is device dependent; see the
  7279. @cite{groff_char(7)} man page for a complete list of all glyphs. For
  7280. example, say
  7281. @Example
  7282. man -Tdvi groff_char > groff_char.dvi
  7283. @endExample
  7284. @noindent
  7285. for a list using the default DVI fonts (not all versions of the
  7286. @code{man} program support the @option{-T} option). If you want to
  7287. use an additional macro package to change the used fonts, @code{groff}
  7288. must be called directly:
  7289. @Example
  7290. groff -Tdvi -mec -man groff_char.7 > groff_char.dvi
  7291. @endExample
  7292. @cindex composite glyph names
  7293. @cindex glyph names, composite
  7294. @cindex groff glyph list (GGL)
  7295. @cindex GGL (groff glyph list)
  7296. @cindex adobe glyph list (AGL)
  7297. @cindex AGL (adobe glyph list)
  7298. Glyph names not listed in groff_char(7) are derived algorithmically,
  7299. using a simplified version of the Adobe Glyph List (AGL) algorithm
  7300. which is described in
  7301. @uref{http://partners.adobe.com@//asn@//tech@//type@//unicodegn.jsp}.
  7302. The (frozen) set of glyph names which can't be derived algorithmically
  7303. is called @dfn{groff glyph list (GGL)}.
  7304. @itemize @bullet
  7305. @item
  7306. A glyph for Unicode character U+@var{XXXX}[@var{X}[@var{X}]] which is
  7307. not a composite character will be named
  7308. @code{u@var{XXXX}@r{[}@var{X}@r{[}@var{X}@r{]]}}. @var{X} must be an
  7309. uppercase hexadecimal digit. Examples: @code{u1234}, @code{u008E},
  7310. @code{u12DB8}. The largest Unicode value is 0x10FFFF. There must be at
  7311. least four @code{X} digits; if necessary, add leading zeroes (after the
  7312. @samp{u}). No zero padding is allowed for character codes greater than
  7313. 0xFFFF. Surrogates (i.e., Unicode values greater than 0xFFFF
  7314. represented with character codes from the surrogate area U+D800-U+DFFF)
  7315. are not allowed too.
  7316. @item
  7317. A glyph representing more than a single input character will be named
  7318. @display
  7319. @samp{u} @var{component1} @samp{_} @var{component2} @samp{_} @var{component3} @dots{}
  7320. @end display
  7321. @noindent
  7322. Example: @code{u0045_0302_0301}.
  7323. For simplicity, all Unicode characters which are composites must be
  7324. decomposed maximally (this is normalization form@tie{}D in the Unicode
  7325. standard); for example, @code{u00CA_0301} is not a valid glyph name
  7326. since U+00CA (@sc{latin capital letter e with circumflex}) can be
  7327. further decomposed into U+0045 (@sc{latin capital letter e}) and U+0302
  7328. (@sc{combining circumflex accent}). @code{u0045_0302_0301} is thus the
  7329. glyph name for U+1EBE, @sc{latin capital letter e with circumflex and
  7330. acute}.
  7331. @item
  7332. groff maintains a table to decompose all algorithmically derived glyph
  7333. names which are composites itself. For example, @code{u0100} (@sc{latin
  7334. letter a with macron}) will be automatically decomposed into
  7335. @code{u0041_0304}. Additionally, a glyph name of the GGL is preferred
  7336. to an algorithmically derived glyph name; groff also automatically does
  7337. the mapping. Example: The glyph @code{u0045_0302} will be mapped to
  7338. @code{^E}.
  7339. @item
  7340. glyph names of the GGL can't be used in composite glyph names; for
  7341. example, @code{^E_u0301} is invalid.
  7342. @end itemize
  7343. @DefescList {\\, @Lparen{}, nm, }
  7344. @DefescItem {\\, @Lbrack{}, name, @Rbrack{}}
  7345. @DefescListEnd {\\, @Lbrack{}, component1 component2 @dots{}, @Rbrack{}}
  7346. Insert a symbol @var{name} (two-character name @var{nm}) or a composite
  7347. glyph with component glyphs @var{component1}, @var{component2},
  7348. @enddots{} There is no special syntax for one-character names -- the
  7349. natural form @samp{\@var{n}} would collide with escapes.@footnote{Note
  7350. that a one-character symbol is not the same as an input character, i.e.,
  7351. the character @code{a} is not the same as @code{\[a]}. By default,
  7352. @code{groff} defines only a single one-character symbol, @code{\[-]}; it
  7353. is usually accessed as @code{\-}. On the other hand, @code{gtroff} has
  7354. the special feature that @code{\[char@var{XXX}]} is the same as the
  7355. input character with character code @var{XXX}. For example,
  7356. @code{\[char97]} is identical to the letter @code{a} if @acronym{ASCII}
  7357. encoding is active.}
  7358. If @var{name} is undefined, a warning of type @samp{char} is generated,
  7359. and the escape is ignored. @xref{Debugging}, for information about
  7360. warnings.
  7361. groff resolves @code{\[...]} with more than a single component as
  7362. follows:
  7363. @itemize @bullet
  7364. @item
  7365. Any component which is found in the GGL will be converted to the
  7366. @code{u@var{XXXX}} form.
  7367. @item
  7368. Any component @code{u@var{XXXX}} which is found in the list of
  7369. decomposable glyphs will be decomposed.
  7370. @item
  7371. The resulting elements are then concatenated with @samp{_} inbetween,
  7372. dropping the leading @samp{u} in all elements but the first.
  7373. @end itemize
  7374. No check for the existence of any component (similar to @code{tr}
  7375. request) will be done.
  7376. Examples:
  7377. @table @code
  7378. @item \[A ho]
  7379. @samp{A} maps to @code{u0041}, @samp{ho} maps to @code{u02DB}, thus the
  7380. final glyph name would be @code{u0041_02DB}. Note this is not the
  7381. expected result: The ogonek glyph @samp{ho} is a spacing ogonek, but for
  7382. a proper composite a non-spacing ogonek (U+0328) is necessary. Looking
  7383. into the file @file{composite.tmac} one can find @w{@samp{.composite ho
  7384. u0328}} which changes the mapping of @samp{ho} while a composite glyph
  7385. name is constructed, causing the final glyph name to be
  7386. @code{u0041_0328}.
  7387. @item \[^E u0301]
  7388. @itemx \[^E aa]
  7389. @itemx \[E a^ aa]
  7390. @itemx \[E ^ ']
  7391. @samp{^E} maps to @code{u0045_0302}, thus the final glyph name is
  7392. @code{u0045_0302_0301} in all forms (assuming proper calls of the
  7393. @code{composite} request).
  7394. @end table
  7395. It is not possible to define glyphs with names like @w{@samp{A ho}}
  7396. within a groff font file. This is not really a limitation; instead, you
  7397. have to define @code{u0041_0328}.
  7398. @endDefesc
  7399. @Defesc {\\C, ', xxx, '}
  7400. @cindex named character (@code{\C})
  7401. @cindex character, named (@code{\C})
  7402. Typeset the glyph named @var{xxx}.@footnote{@code{\C} is actually a
  7403. misnomer since it accesses an output glyph.} Normally it is more
  7404. convenient to use @code{\[@var{xxx}]}, but @code{\C} has the advantage
  7405. that it is compatible with newer versions of @acronym{AT&T}
  7406. @code{troff} and is available in compatibility mode.
  7407. @endDefesc
  7408. @Defreq {composite, from to}
  7409. @pindex composite.tmac
  7410. Map glyph name @var{from} to glyph name @var{to} if it is used in
  7411. @code{\[...]} with more than one component. See above for examples.
  7412. This mapping is based on glyph names only; no check for the existence of
  7413. either glyph is done.
  7414. A set of default mappings for many accents can be found in the file
  7415. @file{composite.tmac} which is loaded at start-up.
  7416. @endDefreq
  7417. @Defesc {\\N, ', n, '}
  7418. @cindex numbered glyph (@code{\N})
  7419. @cindex glyph, numbered (@code{\N})
  7420. @cindex @code{char} request, used with @code{\N}
  7421. @cindex Unicode
  7422. Typeset the glyph with code@tie{}@var{n} in the current font
  7423. (@code{n}@tie{}is @strong{not} the input character code). The
  7424. number @var{n}@tie{}can be any non-negative decimal integer. Most devices
  7425. only have glyphs with codes between 0 and@tie{}255; the Unicode
  7426. output device uses codes in the range 0--65535. If the current
  7427. font does not contain a glyph with that code, special fonts are
  7428. @emph{not} searched. The @code{\N} escape sequence can be
  7429. conveniently used in conjunction with the @code{char} request:
  7430. @Example
  7431. .char \[phone] \f[ZD]\N'37'
  7432. @endExample
  7433. @noindent
  7434. @pindex DESC
  7435. @cindex unnamed glyphs
  7436. @cindex glyphs, unnamed
  7437. The code of each glyph is given in the fourth column in the font
  7438. description file after the @code{charset} command. It is possible to
  7439. include unnamed glyphs in the font description file by using a
  7440. name of @samp{---}; the @code{\N} escape sequence is the only way to
  7441. use these.
  7442. No kerning is applied to glyphs accessed with @code{\N}.
  7443. @endDefesc
  7444. Some escape sequences directly map onto special glyphs.
  7445. @Defesc {\\', , , }
  7446. This is a backslash followed by the apostrophe character, @acronym{ASCII}
  7447. character @code{0x27} (@acronym{EBCDIC} character @code{0x7D}). The same
  7448. as @code{\[aa]}, the acute accent.
  7449. @endDefesc
  7450. @Defesc {\\`, , , }
  7451. This is a backslash followed by @acronym{ASCII} character @code{0x60}
  7452. (@acronym{EBCDIC} character @code{0x79} usually). The same as
  7453. @code{\[ga]}, the grave accent.
  7454. @endDefesc
  7455. @Defesc {\\-, , , }
  7456. This is the same as @code{\[-]}, the minus sign in the current font.
  7457. @endDefesc
  7458. @Defreq {cflags, n c1 c2 @dots{}}
  7459. @cindex glyph properties (@code{cflags})
  7460. @cindex character properties (@code{cflags})
  7461. @cindex properties of glyphs (@code{cflags})
  7462. @cindex properties of characters (@code{cflags})
  7463. Input characters and symbols have certain properties associated
  7464. with it.@footnote{Note that the output glyphs themselves don't have
  7465. such properties. For @code{gtroff}, a glyph is a numbered box with
  7466. a given width, depth, and height, nothing else. All manipulations
  7467. with the @code{cflags} request work on the input level.} These
  7468. properties can be modified with the @code{cflags} request. The
  7469. first argument is the sum of the desired flags and the remaining
  7470. arguments are the characters or symbols to have those properties.
  7471. It is possible to omit the spaces between the characters or symbols.
  7472. @table @code
  7473. @item 1
  7474. @cindex end-of-sentence characters
  7475. @cindex characters, end-of-sentence
  7476. The character ends sentences (initially characters @samp{.?!} have this
  7477. property).
  7478. @item 2
  7479. @cindex hyphenating characters
  7480. @cindex characters, hyphenation
  7481. Lines can be broken before the character (initially no characters have
  7482. this property).
  7483. @item 4
  7484. @cindex @code{hy} glyph, and @code{cflags}
  7485. @cindex @code{em} glyph, and @code{cflags}
  7486. Lines can be broken after the character (initially the character
  7487. @samp{-} and the symbols @samp{\[hy]} and @samp{\[em]} have this property).
  7488. @item 8
  7489. @cindex overlapping characters
  7490. @cindex characters, overlapping
  7491. @cindex @code{ul} glyph, and @code{cflags}
  7492. @cindex @code{rn} glyph, and @code{cflags}
  7493. @cindex @code{ru} glyph, and @code{cflags}
  7494. @cindex @code{radicalex} glyph, and @code{cflags}
  7495. @cindex @code{sqrtex} glyph, and @code{cflags}
  7496. The character overlaps horizontally if used as a horizontal line building
  7497. element. Initially the symbols @samp{\[ul]}, @samp{\[rn]}, @samp{\[ru]},
  7498. @samp{\[radicalex]}, and @samp{\[sqrtex]} have this property.
  7499. @item 16
  7500. @cindex @code{br} glyph, and @code{cflags}
  7501. The character overlaps vertically if used as vertical line building element.
  7502. Initially symbol @samp{\[br]} has this property.
  7503. @item 32
  7504. @cindex transparent characters
  7505. @cindex character, transparent
  7506. @cindex @code{"}, at end of sentence
  7507. @cindex @code{'}, at end of sentence
  7508. @cindex @code{)}, at end of sentence
  7509. @cindex @code{]}, at end of sentence
  7510. @cindex @code{*}, at end of sentence
  7511. @cindex @code{dg} glyph, at end of sentence
  7512. @cindex @code{rq} glyph, at end of sentence
  7513. An end-of-sentence character followed by any number of characters with
  7514. this property is treated as the end of a sentence if followed by a
  7515. newline or two spaces; in other words the character is
  7516. @dfn{transparent} for the purposes of end-of-sentence recognition --
  7517. this is the same as having a zero space factor in @TeX{} (initially
  7518. characters @samp{"')]*} and the symbols @samp{\[dg]} and @samp{\[rq]} have
  7519. this property).
  7520. @end table
  7521. @endDefreq
  7522. @DefreqList {char, g [@Var{string}]}
  7523. @DefreqItem {fchar, g [@Var{string}]}
  7524. @DefreqItem {fschar, f g [@Var{string}]}
  7525. @DefreqListEnd {schar, g [@Var{string}]}
  7526. @cindex defining character (@code{char})
  7527. @cindex defining fallback character (@code{fchar}, @code{fschar}, @code{schar})
  7528. @cindex character, defining (@code{char})
  7529. @cindex character, defining fallback (@code{fchar}, @code{fschar}, @code{schar})
  7530. @cindex fallback character, defining (@code{fchar}, @code{fschar}, @code{schar})
  7531. @cindex creating new characters (@code{char})
  7532. @cindex defining symbol (@code{char})
  7533. @cindex symbol, defining (@code{char})
  7534. @cindex defining glyph (@code{char})
  7535. @cindex glyph, defining (@code{char})
  7536. @cindex escape character, while defining glyph
  7537. @cindex character, escape, while defining glyph
  7538. @cindex @code{tr} request, and glyph definitions
  7539. @cindex @code{cp} request, and glyph definitions
  7540. @cindex @code{rc} request, and glyph definitions
  7541. @cindex @code{lc} request, and glyph definitions
  7542. @cindex @code{\l}, and glyph definitions
  7543. @cindex @code{\L}, and glyph definitions
  7544. @cindex @code{\&}, and glyph definitions
  7545. @cindex @code{\e}, and glyph definitions
  7546. @cindex @code{hcode} request, and glyph definitions
  7547. Define a new glyph@tie{}@var{g} to be @var{string} (which can be
  7548. empty).@footnote{@code{char} is a misnomer since an output glyph is
  7549. defined.} Every time glyph@tie{}@var{g} needs to be printed,
  7550. @var{string} is processed in a temporary environment and the result is
  7551. wrapped up into a single object. Compatibility mode is turned off and
  7552. the escape character is set to @samp{\} while @var{string} is being
  7553. processed. Any emboldening, constant spacing or track kerning is
  7554. applied to this object rather than to individual characters in
  7555. @var{string}.
  7556. A glyph defined by these requests can be used just
  7557. like a normal glyph provided by the output device. In particular,
  7558. other characters can be translated to it with the @code{tr} or
  7559. @code{trin} requests; it can be made the leader character by the
  7560. @code{lc} request; repeated patterns can be drawn with the glyph
  7561. using the @code{\l} and @code{\L} escape sequences; words containing
  7562. the glyph can be hyphenated correctly if the @code{hcode} request
  7563. is used to give the glyph's symbol a hyphenation code.
  7564. There is a special anti-recursion feature: Use of @code{g} within
  7565. the glyph's definition is handled like normal characters and symbols
  7566. not defined with @code{char}.
  7567. Note that the @code{tr} and @code{trin} requests take precedence if
  7568. @code{char} accesses the same symbol.
  7569. @Example
  7570. .tr XY
  7571. X
  7572. @result{} Y
  7573. .char X Z
  7574. X
  7575. @result{} Y
  7576. .tr XX
  7577. X
  7578. @result{} Z
  7579. @endExample
  7580. The @code{fchar} request defines a fallback glyph:
  7581. @code{gtroff} only checks for glyphs defined with @code{fchar}
  7582. if it cannot find the glyph in the current font.
  7583. @code{gtroff} carries out this test before checking special fonts.
  7584. @code{fschar} defines a fallback glyph for font@tie{}@var{f}: @code{gtroff}
  7585. checks for glyphs defined with @code{fschar} after the list of fonts
  7586. declared as font-specific special fonts with the @code{fspecial} request,
  7587. but before the list of fonts declared as global special fonts with the
  7588. @code{special} request.
  7589. Finally, the @code{schar} request defines a global fallback glyph:
  7590. @code{gtroff} checks for glyphs defined with @code{schar} after the list
  7591. of fonts declared as global special fonts with the @code{special} request,
  7592. but before the already mounted special fonts.
  7593. @xref{Using Symbols}, for a detailed description of the glyph
  7594. searching mechanism in @code{gtroff}.
  7595. @endDefreq
  7596. @DefreqList {rchar, c1 c2 @dots{}}
  7597. @DefreqListEnd {rfschar, f c1 c2 @dots{}}
  7598. @cindex removing glyph definition (@code{rchar}, @code{rfschar})
  7599. @cindex glyph, removing definition (@code{rchar}, @code{rfschar})
  7600. @cindex fallback glyph, removing definition (@code{rchar}, @code{rfschar})
  7601. Remove the definitions of glyphs @var{c1}, @var{c2},@tie{}@enddots{}
  7602. This undoes the effect of a @code{char}, @code{fchar}, or
  7603. @code{schar} request.
  7604. It is possible to omit the whitespace between arguments.
  7605. The request @code{rfschar} removes glyph definitions defined with
  7606. @code{fschar} for glyph@tie{}f.
  7607. @endDefreq
  7608. @xref{Special Characters}.
  7609. @c ---------------------------------------------------------------------
  7610. @node Special Fonts, Artificial Fonts, Using Symbols, Fonts and Symbols
  7611. @subsection Special Fonts
  7612. @cindex special fonts
  7613. @cindex fonts, special
  7614. Special fonts are those that @code{gtroff} searches
  7615. when it cannot find the requested glyph in the current font.
  7616. The Symbol font is usually a special font.
  7617. @code{gtroff} provides the following two requests to add more special
  7618. fonts. @xref{Using Symbols}, for a detailed description of the glyph
  7619. searching mechanism in @code{gtroff}.
  7620. Usually, only non-TTY devices have special fonts.
  7621. @DefreqList {special, [@Var{s1} @Var{s2} @dots{}]}
  7622. @DefreqListEnd {fspecial, f [@Var{s1} @Var{s2} @dots{}]}
  7623. @kindex fonts
  7624. @pindex DESC
  7625. Use the @code{special} request to define special fonts. Initially, this
  7626. list is empty.
  7627. Use the @code{fspecial} request to designate special fonts only when
  7628. font@tie{}@var{f} is active. Initially, this list is empty.
  7629. Previous calls to @code{special} or @code{fspecial} are overwritten;
  7630. without arguments, the particular list of special fonts is set to empty.
  7631. Special fonts are searched in the order they appear as arguments.
  7632. All fonts which appear in a call to @code{special} or @code{fspecial} are
  7633. loaded.
  7634. @xref{Using Symbols}, for the exact search order of glyphs.
  7635. @endDefreq
  7636. @c ---------------------------------------------------------------------
  7637. @node Artificial Fonts, Ligatures and Kerning, Special Fonts, Fonts and Symbols
  7638. @subsection Artificial Fonts
  7639. @cindex artificial fonts
  7640. @cindex fonts, artificial
  7641. There are a number of requests and escapes for artificially creating
  7642. fonts. These are largely vestiges of the days when output devices
  7643. did not have a wide variety of fonts, and when @code{nroff} and
  7644. @code{troff} were separate programs. Most of them are no longer
  7645. necessary in GNU @code{troff}. Nevertheless, they are supported.
  7646. @DefescList {\\H, ', height, '}
  7647. @DefescItem {\\H, ', @t{+}height, '}
  7648. @DefescItem {\\H, ', @t{-}height, '}
  7649. @DefregListEnd {.height}
  7650. @cindex changing the font height (@code{\H})
  7651. @cindex font height, changing (@code{\H})
  7652. @cindex height, font, changing (@code{\H})
  7653. Change (increment, decrement) the height of the current font, but not
  7654. the width. If @var{height} is zero, restore the original height.
  7655. Default scaling indicator is @samp{z}.
  7656. The read-only number register @code{.height} contains the font height as
  7657. set by @code{\H}.
  7658. Currently, only the @option{-Tps} device supports this feature.
  7659. Note that @code{\H} doesn't produce an input token in @code{gtroff}.
  7660. As a consequence, it can be used in requests like @code{mc} (which
  7661. expects a single character as an argument) to change the font on
  7662. the fly:
  7663. @Example
  7664. .mc \H'+5z'x\H'0'
  7665. @endExample
  7666. In compatibility mode, @code{gtroff} behaves differently: If an
  7667. increment or decrement is used, it is always taken relative to the
  7668. current point size and not relative to the previously selected font
  7669. height. Thus,
  7670. @Example
  7671. .cp 1
  7672. \H'+5'test \H'+5'test
  7673. @endExample
  7674. @noindent
  7675. prints the word @samp{test} twice with the same font height (five
  7676. points larger than the current font size).
  7677. @endDefesc
  7678. @DefescList {\\S, ', slant, '}
  7679. @DefregListEnd {.slant}
  7680. @cindex changing the font slant (@code{\S})
  7681. @cindex font slant, changing (@code{\S})
  7682. @cindex slant, font, changing (@code{\S})
  7683. Slant the current font by @var{slant} degrees. Positive values slant
  7684. to the right. Only integer values are possible.
  7685. The read-only number register @code{.slant} contains the font slant as
  7686. set by @code{\S}.
  7687. Currently, only the @option{-Tps} device supports this feature.
  7688. Note that @code{\S} doesn't produce an input token in @code{gtroff}.
  7689. As a consequence, it can be used in requests like @code{mc} (which
  7690. expects a single character as an argument) to change the font on
  7691. the fly:
  7692. @Example
  7693. .mc \S'20'x\S'0'
  7694. @endExample
  7695. This request is incorrectly documented in the original @acronym{UNIX}
  7696. troff manual; the slant is always set to an absolute value.
  7697. @endDefesc
  7698. @Defreq {ul, [@Var{lines}]}
  7699. @cindex underlining (@code{ul})
  7700. The @code{ul} request normally underlines subsequent lines if a TTY
  7701. output device is used. Otherwise, the lines are printed in italics
  7702. (only the term `underlined' is used in the following). The single
  7703. argument is the number of input lines to be underlined; with no
  7704. argument, the next line is underlined. If @var{lines} is zero or
  7705. negative, stop the effects of @code{ul} (if it was active). Requests
  7706. and empty lines do not count for computing the number of underlined
  7707. input lines, even if they produce some output like @code{tl}. Lines
  7708. inserted by macros (e.g.@: invoked by a trap) do count.
  7709. At the beginning of @code{ul}, the current font is stored and the
  7710. underline font is activated. Within the span of a @code{ul} request,
  7711. it is possible to change fonts, but after the last line affected by
  7712. @code{ul} the saved font is restored.
  7713. This number of lines still to be underlined is associated with the
  7714. current environment (@pxref{Environments}). The underline font can be
  7715. changed with the @code{uf} request.
  7716. @c XXX @xref should be changed to grotty
  7717. @c @xref{Troff and Nroff Mode}, for a discussion how underlining is
  7718. @c implemented in for TTY output devices, and which problems can arise.
  7719. The @code{ul} request does not underline spaces.
  7720. @endDefreq
  7721. @Defreq {cu, [@Var{lines}]}
  7722. @cindex continuous underlining (@code{cu})
  7723. @cindex underlining, continuous (@code{cu})
  7724. The @code{cu} request is similar to @code{ul} but underlines spaces as
  7725. well (if a TTY output device is used).
  7726. @endDefreq
  7727. @Defreq {uf, font}
  7728. @cindex underline font (@code{uf})
  7729. @cindex font for underlining (@code{uf})
  7730. Set the underline font (globally) used by @code{ul} and @code{cu}. By
  7731. default, this is the font at position@tie{}2. @var{font} can be either
  7732. a non-negative font position or the name of a font.
  7733. @endDefreq
  7734. @DefreqList {bd, font [@Var{offset}]}
  7735. @DefreqItem {bd, font1 font2 [@Var{offset}]}
  7736. @DefregListEnd {.b}
  7737. @cindex imitating bold face (@code{bd})
  7738. @cindex bold face, imitating (@code{bd})
  7739. Artificially create a bold font by printing each glyph twice,
  7740. slightly offset.
  7741. Two syntax forms are available.
  7742. @itemize @bullet
  7743. @item
  7744. Imitate a bold font unconditionally. The first argument specifies the
  7745. font to embolden, and the second is the number of basic units, minus
  7746. one, by which the two glyphs are offset. If the second argument is
  7747. missing, emboldening is turned off.
  7748. @var{font} can be either a non-negative font position or the name of a
  7749. font.
  7750. @var{offset} is available in the @code{.b} read-only register if a
  7751. special font is active; in the @code{bd} request, its default unit is
  7752. @samp{u}.
  7753. @cindex @code{fspecial} request, and imitating bold
  7754. @kindex special
  7755. @cindex embolding of special fonts
  7756. @cindex special fonts, emboldening
  7757. @item
  7758. Imitate a bold form conditionally. Embolden @var{font1} by
  7759. @var{offset} only if font @var{font2} is the current font. This
  7760. command can be issued repeatedly to set up different emboldening
  7761. values for different current fonts. If the second argument is
  7762. missing, emboldening is turned off for this particular current font.
  7763. This affects special fonts only (either set up with the @code{special}
  7764. command in font files or with the @code{fspecial} request).
  7765. @end itemize
  7766. @endDefreq
  7767. @Defreq {cs, font [@Var{width} [@Var{em-size}]]}
  7768. @cindex constant glyph space mode (@code{cs})
  7769. @cindex mode for constant glyph space (@code{cs})
  7770. @cindex glyph, constant space
  7771. @cindex @code{ps} request, and constant glyph space mode
  7772. Switch to and from @dfn{constant glyph space mode}. If activated, the
  7773. width of every glyph is @math{@var{width}/36} ems. The em size is
  7774. given absolutely by @var{em-size}; if this argument is missing, the em
  7775. value is taken from the current font size (as set with the @code{ps}
  7776. request) when the font is effectively in use. Without second and
  7777. third argument, constant glyph space mode is deactivated.
  7778. Default scaling indicator for @var{em-size} is @samp{z}; @var{width} is
  7779. an integer.
  7780. @endDefreq
  7781. @c ---------------------------------------------------------------------
  7782. @node Ligatures and Kerning, , Artificial Fonts, Fonts and Symbols
  7783. @subsection Ligatures and Kerning
  7784. @cindex ligatures and kerning
  7785. @cindex kerning and ligatures
  7786. Ligatures are groups of characters that are run together, i.e, producing
  7787. a single glyph. For example, the letters `f' and `i' can form a
  7788. ligature `fi' as in the word `file'. This produces a cleaner look
  7789. (albeit subtle) to the printed output. Usually, ligatures are not
  7790. available in fonts for TTY output devices.
  7791. Most @sc{PostScript} fonts support the fi and fl ligatures. The C/A/T
  7792. typesetter that was the target of @acronym{AT&T} @code{troff} also
  7793. supported `ff', `ffi', and `ffl' ligatures. Advanced typesetters or
  7794. `expert' fonts may include ligatures for `ft' and `ct', although GNU
  7795. @code{troff} does not support these (yet).
  7796. Only the current font is checked for ligatures and kerns; neither special
  7797. fonts nor entities defined with the @code{char} request (and its siblings)
  7798. are taken into account.
  7799. @DefreqList {lg, [@Var{flag}]}
  7800. @DefregListEnd {.lg}
  7801. @cindex activating ligatures (@code{lg})
  7802. @cindex ligatures, activating (@code{lg})
  7803. @cindex ligatures enabled register (@code{.lg})
  7804. Switch the ligature mechanism on or off; if the parameter is non-zero
  7805. or missing, ligatures are enabled, otherwise disabled. Default is on.
  7806. The current ligature mode can be found in the read-only number register
  7807. @code{.lg} (set to 1 or@tie{}2 if ligatures are enabled, 0@tie{}otherwise).
  7808. Setting the ligature mode to@tie{}2 enables the two-character ligatures
  7809. (fi, fl, and ff) and disables the three-character ligatures (ffi and
  7810. ffl).
  7811. @endDefreq
  7812. @dfn{Pairwise kerning} is another subtle typesetting mechanism that
  7813. modifies the distance between a glyph pair to improve readability.
  7814. In most cases (but not always) the distance is decreased.
  7815. @iftex
  7816. For example, compare the combination of the letters `V' and `A'. With
  7817. kerning, `VA' is printed. Without kerning it appears as `V@w{}A'.
  7818. @end iftex
  7819. Typewriter-like fonts and fonts for terminals where all glyphs
  7820. have the same width don't use kerning.
  7821. @DefreqList {kern, [@Var{flag}]}
  7822. @DefregListEnd {.kern}
  7823. @cindex activating kerning (@code{kern})
  7824. @cindex kerning, activating (@code{kern})
  7825. @cindex kerning enabled register (@code{.kern})
  7826. Switch kerning on or off. If the parameter is non-zero or missing,
  7827. enable pairwise kerning, otherwise disable it. The read-only number
  7828. register @code{.kern} is set to@tie{}1 if pairwise kerning is enabled,
  7829. 0@tie{}otherwise.
  7830. @cindex zero width space character (@code{\&})
  7831. @cindex character, zero width space (@code{\&})
  7832. @cindex space character, zero width (@code{\&})
  7833. If the font description file contains pairwise kerning information,
  7834. glyphs from that font are kerned. Kerning between two glyphs
  7835. can be inhibited by placing @code{\&} between them: @samp{V\&A}.
  7836. @xref{Font File Format}.
  7837. @endDefreq
  7838. @cindex track kerning
  7839. @cindex kerning, track
  7840. @dfn{Track kerning} expands or reduces the space between glyphs.
  7841. This can be handy, for example, if you need to squeeze a long word
  7842. onto a single line or spread some text to fill a narrow column. It
  7843. must be used with great care since it is usually considered bad
  7844. typography if the reader notices the effect.
  7845. @Defreq {tkf, f s1 n1 s2 n2}
  7846. @cindex activating track kerning (@code{tkf})
  7847. @cindex track kerning, activating (@code{tkf})
  7848. Enable track kerning for font@tie{}@var{f}. If the current font
  7849. is@tie{}@var{f} the width of every glyph is increased by an amount
  7850. between @var{n1} and @var{n2} (@var{n1}, @var{n2} can be negative); if
  7851. the current point size is less than or equal to @var{s1} the width is
  7852. increased by @var{n1}; if it is greater than or equal to @var{s2} the
  7853. width is increased by @var{n2}; if the point size is greater than or
  7854. equal to @var{s1} and less than or equal to @var{s2} the increase in
  7855. width is a linear function of the point size.
  7856. The default scaling indicator is @samp{z} for @var{s1} and @var{s2},
  7857. @samp{p} for @var{n1} and @var{n2}.
  7858. Note that the track kerning amount is added even to the rightmost glyph
  7859. in a line; for large values it is thus recommended to increase the line
  7860. length by the same amount to compensate it.
  7861. @endDefreq
  7862. Sometimes, when typesetting letters of different fonts, more or less
  7863. space at such boundaries are needed. There are two escapes to help
  7864. with this.
  7865. @Defesc {\\/, , , }
  7866. @cindex italic correction (@code{\/})
  7867. @cindex correction, italic (@code{\/})
  7868. @cindex correction between italic and roman glyph (@code{\/}, @code{\,})
  7869. @cindex roman glyph, correction after italic glyph (@code{\/})
  7870. @cindex italic glyph, correction before roman glyph (@code{\/})
  7871. @cindex glyph, italic correction (@code{\/})
  7872. Increase the width of the preceding glyph so that the spacing
  7873. between that glyph and the following glyph is correct if the
  7874. following glyph is a roman glyph. For example, if an
  7875. italic@tie{}@code{f} is immediately followed by a roman right
  7876. parenthesis, then in many fonts the top right portion of the@tie{}@code{f}
  7877. overlaps the top left of the right parenthesis. Use this escape
  7878. sequence whenever an italic glyph is immediately followed by a
  7879. roman glyph without any intervening space. This small amount of
  7880. space is also called @dfn{italic correction}.
  7881. @iftex
  7882. @c can't use @Example...@endExample here
  7883. @example
  7884. @group
  7885. \f[I]f\f[R])
  7886. @result{} {@it f}@r{)}
  7887. \f[I]f\/\f[R])
  7888. @result{} @i{f}@r{)}
  7889. @end group
  7890. @end example
  7891. @end iftex
  7892. @endDefesc
  7893. @Defesc {\\\,, , , }
  7894. @cindex left italic correction (@code{\,})
  7895. @cindex correction, left italic (@code{\,})
  7896. @cindex glyph, left italic correction (@code{\,})
  7897. @cindex roman glyph, correction before italic glyph (@code{\,})
  7898. @cindex italic glyph, correction after roman glyph (@code{\,})
  7899. Modify the spacing of the following glyph so that the spacing
  7900. between that glyph and the preceding glyph is correct if the
  7901. preceding glyph is a roman glyph. Use this escape sequence
  7902. whenever a roman glyph is immediately followed by an italic
  7903. glyph without any intervening space. In analogy to above, this
  7904. space could be called @dfn{left italic correction}, but this term
  7905. isn't used widely.
  7906. @iftex
  7907. @c can't use @Example...@endExample here
  7908. @example
  7909. @group
  7910. q\f[I]f
  7911. @result{} @r{q}@i{f}
  7912. q\,\f[I]f
  7913. @result{} @r{q}@math{@ptexcomma}@i{f}
  7914. @end group
  7915. @end example
  7916. @end iftex
  7917. @endDefesc
  7918. @Defesc {\\&, , , }
  7919. Insert a zero-width character, which is invisible. Its intended use
  7920. is to stop interaction of a character with its surrounding.
  7921. @itemize @bullet
  7922. @item
  7923. It prevents the insertion of extra space after an end-of-sentence
  7924. character.
  7925. @Example
  7926. Test.
  7927. Test.
  7928. @result{} Test. Test.
  7929. Test.\&
  7930. Test.
  7931. @result{} Test. Test.
  7932. @endExample
  7933. @item
  7934. It prevents interpretation of a control character at the beginning of
  7935. an input line.
  7936. @Example
  7937. .Test
  7938. @result{} warning: `Test' not defined
  7939. \&.Test
  7940. @result{} .Test
  7941. @endExample
  7942. @item
  7943. It prevents kerning between two glyphs.
  7944. @iftex
  7945. @c can't use @Example...@endExample here
  7946. @example
  7947. @group
  7948. VA
  7949. @result{} @r{VA}
  7950. V\&A
  7951. @result{} @r{V@w{}A}
  7952. @end group
  7953. @end example
  7954. @end iftex
  7955. @item
  7956. It is needed to map an arbitrary character to nothing in the @code{tr}
  7957. request (@pxref{Character Translations}).
  7958. @end itemize
  7959. @endDefesc
  7960. @Defesc {\\), , , }
  7961. This escape is similar to @code{\&} except that it behaves like a
  7962. character declared with the @code{cflags} request to be transparent
  7963. for the purposes of an end-of-sentence character.
  7964. Its main usage is in macro definitions to protect against arguments
  7965. starting with a control character.
  7966. @Example
  7967. .de xxx
  7968. \)\\$1
  7969. ..
  7970. .de yyy
  7971. \&\\$1
  7972. ..
  7973. This is a test.\c
  7974. .xxx '
  7975. This is a test.
  7976. @result{}This is a test.' This is a test.
  7977. This is a test.\c
  7978. .yyy '
  7979. This is a test.
  7980. @result{}This is a test.' This is a test.
  7981. @endExample
  7982. @endDefesc
  7983. @c =====================================================================
  7984. @node Sizes, Strings, Fonts and Symbols, gtroff Reference
  7985. @section Sizes
  7986. @cindex sizes
  7987. @cindex baseline
  7988. @cindex type size
  7989. @cindex size of type
  7990. @cindex vertical spacing
  7991. @cindex spacing, vertical
  7992. @code{gtroff} uses two dimensions with each line of text, type size
  7993. and vertical spacing. The @dfn{type size} is approximately the height
  7994. of the tallest glyph.@footnote{This is usually the parenthesis.
  7995. Note that in most cases the real dimensions of the glyphs in a font
  7996. are @emph{not} related to its type size! For example, the standard
  7997. @sc{PostScript} font families `Times Roman', `Helvetica', and
  7998. `Courier' can't be used together at 10@dmn{pt}; to get acceptable
  7999. output, the size of `Helvetica' has to be reduced by one point, and
  8000. the size of `Courier' must be increased by one point.} @dfn{Vertical
  8001. spacing} is the amount of space @code{gtroff} allows for a line of
  8002. text; normally, this is about 20%@tie{}larger than the current type
  8003. size. Ratios smaller than this can result in hard-to-read text;
  8004. larger than this, it spreads the text out more vertically (useful for
  8005. term papers). By default, @code{gtroff} uses 10@tie{}point type on
  8006. 12@tie{}point spacing.
  8007. @cindex leading
  8008. The difference between type size and vertical spacing is known, by
  8009. typesetters, as @dfn{leading} (this is pronounced `ledding').
  8010. @menu
  8011. * Changing Type Sizes::
  8012. * Fractional Type Sizes::
  8013. @end menu
  8014. @c ---------------------------------------------------------------------
  8015. @node Changing Type Sizes, Fractional Type Sizes, Sizes, Sizes
  8016. @subsection Changing Type Sizes
  8017. @DefreqList {ps, [@Var{size}]}
  8018. @DefreqItem {ps, @t{+}@Var{size}}
  8019. @DefreqItem {ps, @t{-}@Var{size}}
  8020. @DefescItem {\\s, , size, }
  8021. @DefregListEnd {.s}
  8022. @cindex changing type sizes (@code{ps}, @code{\s})
  8023. @cindex type sizes, changing (@code{ps}, @code{\s})
  8024. @cindex point sizes, changing (@code{ps}, @code{\s})
  8025. Use the @code{ps} request or the @code{\s} escape to change (increase,
  8026. decrease) the type size (in points). Specify @var{size} as either an
  8027. absolute point size, or as a relative change from the current size.
  8028. The size@tie{}0, or no argument, goes back to the previous size.
  8029. Default scaling indicator of @code{size} is @samp{z}. If @code{size}
  8030. is zero or negative, it is set to 1@dmn{u}.
  8031. @cindex type size registers (@code{.s}, @code{.ps})
  8032. @cindex point size registers (@code{.s}, @code{.ps})
  8033. The read-only number register @code{.s} returns the point size in
  8034. points as a decimal fraction. This is a string. To get the point
  8035. size in scaled points, use the @code{.ps} register instead.
  8036. @code{.s} is associated with the current environment
  8037. (@pxref{Environments}).
  8038. @Example
  8039. snap, snap,
  8040. .ps +2
  8041. grin, grin,
  8042. .ps +2
  8043. wink, wink, \s+2nudge, nudge,\s+8 say no more!
  8044. .ps 10
  8045. @endExample
  8046. The @code{\s} escape may be called in a variety of ways. Much like
  8047. other escapes there must be a way to determine where the argument ends
  8048. and the text begins. Any of the following forms are valid:
  8049. @table @code
  8050. @item \s@var{n}
  8051. Set the point size to @var{n}@tie{}points. @var{n}@tie{}must be either
  8052. 0 or in the range 4 to@tie{}39.
  8053. @item \s+@var{n}
  8054. @itemx \s-@var{n}
  8055. Increase or decrease the point size by @var{n}@tie{}points.
  8056. @var{n}@tie{}must be exactly one digit.
  8057. @item \s(@var{nn}
  8058. Set the point size to @var{nn}@tie{}points. @var{nn} must be exactly
  8059. two digits.
  8060. @item \s+(@var{nn}
  8061. @itemx \s-(@var{nn}
  8062. @itemx \s(+@var{nn}
  8063. @itemx \s(-@var{nn}
  8064. Increase or decrease the point size by @var{nn}@tie{}points. @var{nn}
  8065. must be exactly two digits.
  8066. @end table
  8067. Note that @code{\s} doesn't produce an input token in @code{gtroff}.
  8068. As a consequence, it can be used in requests like @code{mc} (which
  8069. expects a single character as an argument) to change the font on
  8070. the fly:
  8071. @Example
  8072. .mc \s[20]x\s[0]
  8073. @endExample
  8074. @xref{Fractional Type Sizes}, for yet another syntactical form of
  8075. using the @code{\s} escape.
  8076. @endDefreq
  8077. @Defreq {sizes, s1 s2 @dots{} sn [0]}
  8078. Some devices may only have certain permissible sizes, in which case
  8079. @code{gtroff} rounds to the nearest permissible size.
  8080. The @file{DESC} file specifies which sizes are permissible for the device.
  8081. Use the @code{sizes} request to change the permissible sizes
  8082. for the current output device.
  8083. Arguments are in scaled points;
  8084. the @code{sizescale} line in the
  8085. @file{DESC} file for the output device
  8086. provides the scaling factor.
  8087. For example, if the scaling factor is 1000,
  8088. then the value 12000 is 12@tie{}points.
  8089. Each argument can be a single point size (such as @samp{12000}),
  8090. or a range of sizes (such as @samp{4000-72000}).
  8091. You can optionally end the list with a zero.
  8092. @endDefreq
  8093. @DefreqList {vs, [@Var{space}]}
  8094. @DefreqItem {vs, @t{+}@Var{space}}
  8095. @DefreqItem {vs, @t{-}@Var{space}}
  8096. @DefregListEnd {.v}
  8097. @cindex changing vertical line spacing (@code{vs})
  8098. @cindex vertical line spacing, changing (@code{vs})
  8099. @cindex vertical line spacing register (@code{.v})
  8100. Change (increase, decrease) the vertical spacing by @var{space}. The
  8101. default scaling indicator is @samp{p}.
  8102. If @code{vs} is called without an argument, the vertical spacing is
  8103. reset to the previous value before the last call to @code{vs}.
  8104. @cindex @code{.V} register, and @code{vs}
  8105. @code{gtroff} creates a warning of type @samp{range} if @var{space} is
  8106. negative; the vertical spacing is then set to smallest positive value,
  8107. the vertical resolution (as given in the @code{.V} register).
  8108. Note that @w{@samp{.vs 0}} isn't saved in a diversion since it doesn't
  8109. result in a vertical motion. You explicitly have to repeat this command
  8110. before inserting the diversion.
  8111. The read-only number register @code{.v} contains the current vertical
  8112. spacing; it is associated with the current environment
  8113. (@pxref{Environments}).
  8114. @endDefreq
  8115. @cindex vertical line spacing, effective value
  8116. The effective vertical line spacing consists of four components. Breaking
  8117. a line causes the following actions (in the given order).
  8118. @itemize @bullet
  8119. @item
  8120. @cindex extra pre-vertical line space (@code{\x})
  8121. @cindex line space, extra pre-vertical (@code{\x})
  8122. Move the current point vertically by the @dfn{extra pre-vertical line
  8123. space}. This is the minimum value of all @code{\x} escapes with a
  8124. negative argument in the current output line.
  8125. @item
  8126. Move the current point vertically by the vertical line spacing as set with
  8127. the @code{vs} request.
  8128. @item
  8129. Output the current line.
  8130. @item
  8131. @cindex extra post-vertical line space (@code{\x})
  8132. @cindex line space, extra post-vertical (@code{\x})
  8133. Move the current point vertically by the @dfn{extra post-vertical line
  8134. space}. This is the maximum value of all @code{\x} escapes with a
  8135. positive argument in the line which has just been output.
  8136. @item
  8137. @cindex post-vertical line spacing
  8138. @cindex line spacing, post-vertical (@code{pvs})
  8139. Move the current point vertically by the @dfn{post-vertical line spacing}
  8140. as set with the @code{pvs} request.
  8141. @end itemize
  8142. @cindex double-spacing (@code{vs}, @code{pvs})
  8143. It is usually better to use @code{vs} or @code{pvs} instead of @code{ls}
  8144. to produce double-spaced documents: @code{vs} and @code{pvs} have a finer
  8145. granularity for the inserted vertical space compared to @code{ls};
  8146. furthermore, certain preprocessors assume single-spacing.
  8147. @xref{Manipulating Spacing}, for more details on the @code{\x} escape
  8148. and the @code{ls} request.
  8149. @DefreqList {pvs, [@Var{space}]}
  8150. @DefreqItem {pvs, @t{+}@Var{space}}
  8151. @DefreqItem {pvs, @t{-}@Var{space}}
  8152. @DefregListEnd {.pvs}
  8153. @cindex @code{ls} request, alternative to (@code{pvs})
  8154. @cindex post-vertical line spacing, changing (@code{pvs})
  8155. @cindex post-vertical line spacing register (@code{.pvs})
  8156. Change (increase, decrease) the post-vertical spacing by
  8157. @var{space}. The default scaling indicator is @samp{p}.
  8158. If @code{pvs} is called without an argument, the post-vertical spacing is
  8159. reset to the previous value before the last call to @code{pvs}.
  8160. @code{gtroff} creates a warning of type @samp{range} if @var{space} is
  8161. zero or negative; the vertical spacing is then set to zero.
  8162. The read-only number register @code{.pvs} contains the current
  8163. post-vertical spacing; it is associated with the current environment
  8164. (@pxref{Environments}).
  8165. @endDefreq
  8166. @c ---------------------------------------------------------------------
  8167. @node Fractional Type Sizes, , Changing Type Sizes, Sizes
  8168. @subsection Fractional Type Sizes
  8169. @cindex fractional type sizes
  8170. @cindex fractional point sizes
  8171. @cindex type sizes, fractional
  8172. @cindex point sizes, fractional
  8173. @cindex sizes, fractional
  8174. @cindex @code{s} unit
  8175. @cindex unit, @code{s}
  8176. @cindex @code{z} unit
  8177. @cindex unit, @code{z}
  8178. @cindex @code{ps} request, with fractional type sizes
  8179. @cindex @code{cs} request, with fractional type sizes
  8180. @cindex @code{tkf} request, with fractional type sizes
  8181. @cindex @code{\H}, with fractional type sizes
  8182. @cindex @code{\s}, with fractional type sizes
  8183. A @dfn{scaled point} is equal to @math{1/@var{sizescale}} points,
  8184. where @var{sizescale} is specified in the @file{DESC} file (1@tie{}by
  8185. default). There is a new scale indicator @samp{z} which has the
  8186. effect of multiplying by @var{sizescale}. Requests and escape
  8187. sequences in @code{gtroff} interpret arguments that represent a point
  8188. size as being in units of scaled points, but they evaluate each such
  8189. argument using a default scale indicator of @samp{z}. Arguments
  8190. treated in this way are the argument to the @code{ps} request, the
  8191. third argument to the @code{cs} request, the second and fourth
  8192. arguments to the @code{tkf} request, the argument to the @code{\H}
  8193. escape sequence, and those variants of the @code{\s} escape sequence
  8194. that take a numeric expression as their argument (see below).
  8195. For example, suppose @var{sizescale} is@tie{}1000; then a scaled point
  8196. is equivalent to a millipoint; the request @w{@samp{.ps 10.25}} is
  8197. equivalent to @w{@samp{.ps 10.25z}} and thus sets the point size to
  8198. 10250@tie{}scaled points, which is equal to 10.25@tie{}points.
  8199. @code{gtroff} disallows the use of the @samp{z} scale indicator in
  8200. instances where it would make no sense, such as a numeric
  8201. expression whose default scale indicator was neither @samp{u} nor
  8202. @samp{z}. Similarly it would make
  8203. no sense to use a scaling indicator other than @samp{z} or @samp{u} in a
  8204. numeric expression whose default scale indicator was @samp{z}, and so
  8205. @code{gtroff} disallows this as well.
  8206. There is also new scale indicator @samp{s} which multiplies by the
  8207. number of units in a scaled point. So, for example, @samp{\n[.ps]s} is
  8208. equal to @samp{1m}. Be sure not to confuse the @samp{s} and @samp{z}
  8209. scale indicators.
  8210. @Defreg {.ps}
  8211. A read-only number register returning the point size in scaled points.
  8212. @code{.ps} is associated with the current environment
  8213. (@pxref{Environments}).
  8214. @endDefreg
  8215. @DefregList {.psr}
  8216. @DefregListEnd {.sr}
  8217. @cindex last-requested point size registers (@code{.psr}, @code{.sr})
  8218. @cindex point size registers, last-requested (@code{.psr}, @code{.sr})
  8219. @cindex @code{.ps} register, in comparison with @code{.psr}
  8220. @cindex @code{.s} register, in comparison with @code{.sr}
  8221. The last-requested point size in scaled points is contained in the
  8222. @code{.psr} read-only number register. The last requested point size
  8223. in points as a decimal fraction can be found in @code{.sr}. This is a
  8224. string-valued read-only number register.
  8225. Note that the requested point sizes are device-independent, whereas
  8226. the values returned by the @code{.ps} and @code{.s} registers are not.
  8227. For example, if a point size of 11@dmn{pt} is requested, and a
  8228. @code{sizes} request (or a @code{sizescale} line in a @file{DESC} file)
  8229. specifies 10.95@dmn{pt} instead, this value is actually used.
  8230. Both registers are associated with the current environment
  8231. (@pxref{Environments}).
  8232. @endDefreg
  8233. The @code{\s} escape has the following syntax for working with
  8234. fractional type sizes:
  8235. @table @code
  8236. @item \s[@var{n}]
  8237. @itemx \s'@var{n}'
  8238. Set the point size to @var{n}@tie{}scaled points; @var{n}@tie{}is a numeric
  8239. expression with a default scale indicator of @samp{z}.
  8240. @item \s[+@var{n}]
  8241. @itemx \s[-@var{n}]
  8242. @itemx \s+[@var{n}]
  8243. @itemx \s-[@var{n}]
  8244. @itemx \s'+@var{n}'
  8245. @itemx \s'-@var{n}'
  8246. @itemx \s+'@var{n}'
  8247. @itemx \s-'@var{n}'
  8248. Increase or or decrease the point size by @var{n}@tie{}scaled points;
  8249. @var{n}@tie{}is a numeric expression with a default scale indicator of
  8250. @samp{z}.
  8251. @end table
  8252. @xref{Font Files}.
  8253. @c =====================================================================
  8254. @node Strings, Conditionals and Loops, Sizes, gtroff Reference
  8255. @section Strings
  8256. @cindex strings
  8257. @code{gtroff} has string variables, which are entirely for user
  8258. convenience (i.e.@: there are no built-in strings exept @code{.T}, but
  8259. even this is a read-write string variable).
  8260. @DefreqList {ds, name [@Var{string}]}
  8261. @DefreqItem {ds1, name [@Var{string}]}
  8262. @DefescItem {\\*, , n, }
  8263. @DefescItem {\\*, @Lparen{}, nm, }
  8264. @DefescListEnd {\\*, @Lbrack{}, name arg1 arg2 @dots{}, @Rbrack{}}
  8265. @cindex string interpolation (@code{\*})
  8266. @cindex string expansion (@code{\*})
  8267. @cindex interpolation of strings (@code{\*})
  8268. @cindex expansion of strings (@code{\*})
  8269. @cindex string arguments
  8270. @cindex arguments, of strings
  8271. Define and access a string variable @var{name} (one-character
  8272. name@tie{}@var{n}, two-character name @var{nm}). If @var{name} already
  8273. exists, @code{ds} overwrites the previous definition. Only the syntax form
  8274. using brackets can take arguments which are handled identically to
  8275. macro arguments; the single exception is that a closing bracket as an
  8276. argument must be enclosed in double quotes. @xref{Request and Macro
  8277. Arguments}, and @ref{Parameters}.
  8278. Example:
  8279. @Example
  8280. .ds foo a \\$1 test
  8281. .
  8282. This is \*[foo nice].
  8283. @result{} This is a nice test.
  8284. @endExample
  8285. The @code{\*} escape @dfn{interpolates} (expands in-place) a
  8286. previously-defined string variable. To be more precise, the stored
  8287. string is pushed onto the input stack which is then parsed by
  8288. @code{gtroff}. Similar to number registers, it is possible to nest
  8289. strings, i.e. string variables can be called within string variables.
  8290. If the string named by the @code{\*} escape does not exist, it is
  8291. defined as empty, and a warning of type @samp{mac} is emitted (see
  8292. @ref{Debugging}, for more details).
  8293. @cindex comments, with @code{ds}
  8294. @cindex @code{ds} request, and comments
  8295. @strong{Caution:} Unlike other requests, the second argument to the
  8296. @code{ds} request takes up the entire line including trailing spaces.
  8297. This means that comments on a line with such a request can introduce
  8298. unwanted space into a string.
  8299. @Example
  8300. .ds UX \s-1UNIX\s0\u\s-3tm\s0\d \" UNIX trademark
  8301. @endExample
  8302. @noindent
  8303. Instead the comment should be put on another line or have the comment
  8304. escape adjacent with the end of the string.
  8305. @Example
  8306. .ds UX \s-1UNIX\s0\u\s-3tm\s0\d\" UNIX trademark
  8307. @endExample
  8308. @cindex trailing quotes
  8309. @cindex quotes, trailing
  8310. @cindex leading spaces with @code{ds}
  8311. @cindex spaces with @code{ds}
  8312. @cindex @code{ds} request, and leading spaces
  8313. To produce leading space the string can be started with a double
  8314. quote. No trailing quote is needed; in fact, any trailing quote is
  8315. included in your string.
  8316. @Example
  8317. .ds sign " Yours in a white wine sauce,
  8318. @endExample
  8319. @cindex multi-line strings
  8320. @cindex strings, multi-line
  8321. @cindex newline character, in strings, escaping
  8322. @cindex escaping newline characters, in strings
  8323. Strings are not limited to a single line of text. A string can span
  8324. several lines by escaping the newlines with a backslash. The
  8325. resulting string is stored @emph{without} the newlines.
  8326. @Example
  8327. .ds foo lots and lots \
  8328. of text are on these \
  8329. next several lines
  8330. @endExample
  8331. It is not possible to have real newlines in a string. To put a single
  8332. double quote character into a string, use two consecutive double quote
  8333. characters.
  8334. The @code{ds1} request turns off compatibility mode
  8335. while interpreting a string. To be more precise, a @dfn{compatibility
  8336. save} input token is inserted at the beginning of the string, and a
  8337. @dfn{compatibility restore} input token at the end.
  8338. @Example
  8339. .nr xxx 12345
  8340. .ds aa The value of xxx is \\n[xxx].
  8341. .ds1 bb The value of xxx ix \\n[xxx].
  8342. .
  8343. .cp 1
  8344. .
  8345. \*(aa
  8346. @result{} warning: number register `[' not defined
  8347. @result{} The value of xxx is 0xxx].
  8348. \*(bb
  8349. @result{} The value of xxx ix 12345.
  8350. @endExample
  8351. @cindex name space, common, of macros, diversions, and strings
  8352. @cindex common name space of macros, diversions, and strings
  8353. @cindex macros, shared name space with strings and diversions
  8354. @cindex strings, shared name space with macros and diversions
  8355. @cindex diversions, shared name space with macros and strings
  8356. Strings, macros, and diversions (and boxes) share the same name space.
  8357. Internally, even the same mechanism is used to store them. This has
  8358. some interesting consequences. For example, it is possible to call a
  8359. macro with string syntax and vice versa.
  8360. @Example
  8361. .de xxx
  8362. a funny test.
  8363. ..
  8364. This is \*[xxx]
  8365. @result{} This is a funny test.
  8366. .ds yyy a funny test
  8367. This is
  8368. .yyy
  8369. @result{} This is a funny test.
  8370. @endExample
  8371. Diversions and boxes can be also called with string syntax.
  8372. Another consequence is that you can copy one-line diversions or boxes
  8373. to a string.
  8374. @Example
  8375. .di xxx
  8376. a \fItest\fR
  8377. .br
  8378. .di
  8379. .ds yyy This is \*[xxx]\c
  8380. \*[yyy].
  8381. @result{} @r{This is a }@i{test}.
  8382. @endExample
  8383. @noindent
  8384. As the previous example shows, it is possible to store formatted
  8385. output in strings. The @code{\c} escape prevents the insertion of an
  8386. additional blank line in the output.
  8387. Copying diversions longer than a single output line produces
  8388. unexpected results.
  8389. @Example
  8390. .di xxx
  8391. a funny
  8392. .br
  8393. test
  8394. .br
  8395. .di
  8396. .ds yyy This is \*[xxx]\c
  8397. \*[yyy].
  8398. @result{} test This is a funny.
  8399. @endExample
  8400. Usually, it is not predictable whether a diversion contains one or
  8401. more output lines, so this mechanism should be avoided. With
  8402. @acronym{UNIX} @code{troff}, this was the only solution to strip off a
  8403. final newline from a diversion. Another disadvantage is that the
  8404. spaces in the copied string are already formatted, making them
  8405. unstretchable. This can cause ugly results.
  8406. @cindex stripping final newline in diversions
  8407. @cindex diversion, stripping final newline
  8408. @cindex final newline, stripping in diversions
  8409. @cindex newline, final, stripping in diversions
  8410. @cindex horizontal space, unformatting
  8411. @cindex space, horizontal, unformatting
  8412. @cindex unformatting horizontal space
  8413. A clean solution to this problem is available in GNU @code{troff},
  8414. using the requests @code{chop} to remove the final newline of a
  8415. diversion, and @code{unformat} to make the horizontal spaces
  8416. stretchable again.
  8417. @Example
  8418. .box xxx
  8419. a funny
  8420. .br
  8421. test
  8422. .br
  8423. .box
  8424. .chop xxx
  8425. .unformat xxx
  8426. This is \*[xxx].
  8427. @result{} This is a funny test.
  8428. @endExample
  8429. @xref{Gtroff Internals}, for more information.
  8430. @endDefreq
  8431. @DefreqList {as, name [@Var{string}]}
  8432. @DefreqListEnd {as1, name [@Var{string}]}
  8433. @cindex appending to a string (@code{as})
  8434. @cindex string, appending (@code{as})
  8435. The @code{as} request is similar to @code{ds} but appends @var{string}
  8436. to the string stored as @var{name} instead of redefining it. If
  8437. @var{name} doesn't exist yet, it is created.
  8438. @Example
  8439. .as sign " with shallots, onions and garlic,
  8440. @endExample
  8441. The @code{as1} request is similar to @code{as}, but compatibility mode
  8442. is switched off while the appended string is interpreted. To be more
  8443. precise, a @dfn{compatibility save} input token is inserted at the
  8444. beginning of the appended string, and a @dfn{compatibility restore}
  8445. input token at the end.
  8446. @endDefreq
  8447. Rudimentary string manipulation routines are given with the next two
  8448. requests.
  8449. @Defreq {substring, str n1 [@Var{n2}]}
  8450. @cindex substring (@code{substring})
  8451. Replace the string named @var{str} with the substring
  8452. defined by the indices @var{n1} and@tie{}@var{n2}. The first character
  8453. in the string has index@tie{}0. If @var{n2} is omitted, it is taken to
  8454. be equal to the string's length. If the index value @var{n1} or
  8455. @var{n2} is negative, it is counted from the end of the
  8456. string, going backwards: The last character has index@tie{}@minus{}1, the
  8457. character before the last character has index@tie{}@minus{}2, etc.
  8458. @Example
  8459. .ds xxx abcdefgh
  8460. .substring xxx 1 -4
  8461. \*[xxx]
  8462. @result{} bcde
  8463. @endExample
  8464. @endDefreq
  8465. @Defreq {length, reg str}
  8466. @cindex length of a string (@code{length})
  8467. @cindex string, length of (@code{length})
  8468. Compute the number of characters of @var{str} and return it in the
  8469. number register @var{reg}. If @var{reg} doesn't exist, it is created.
  8470. @code{str} is read in copy mode.
  8471. @Example
  8472. .ds xxx abcd\h'3i'efgh
  8473. .length yyy \*[xxx]
  8474. \n[yyy]
  8475. @result{} 14
  8476. @endExample
  8477. @endDefreq
  8478. @Defreq {rn, xx yy}
  8479. @cindex renaming request (@code{rn})
  8480. @cindex request, renaming (@code{rn})
  8481. @cindex renaming macro (@code{rn})
  8482. @cindex macro, renaming (@code{rn})
  8483. @cindex renaming string (@code{rn})
  8484. @cindex string, renaming (@code{rn})
  8485. @cindex renaming diversion (@code{rn})
  8486. @cindex diversion, renaming (@code{rn})
  8487. Rename the request, macro, diversion, or string @var{xx} to @var{yy}.
  8488. @endDefreq
  8489. @Defreq {rm, xx}
  8490. @cindex removing request (@code{rm})
  8491. @cindex request, removing (@code{rm})
  8492. @cindex removing macro (@code{rm})
  8493. @cindex macro, removing (@code{rm})
  8494. @cindex removing string (@code{rm})
  8495. @cindex string, removing (@code{rm})
  8496. @cindex removing diversion (@code{rm})
  8497. @cindex diversion, removing (@code{rm})
  8498. Remove the request, macro, diversion, or string @var{xx}. @code{gtroff}
  8499. treats subsequent invocations as if the object had never been defined.
  8500. @endDefreq
  8501. @Defreq {als, new old}
  8502. @cindex alias, string, creating (@code{als})
  8503. @cindex alias, macro, creating (@code{als})
  8504. @cindex alias, diversion, creating (@code{als})
  8505. @cindex creating alias, for string (@code{als})
  8506. @cindex creating alias, for macro (@code{als})
  8507. @cindex creating alias, for diversion (@code{als})
  8508. @cindex string, creating alias (@code{als})
  8509. @cindex macro, creating alias (@code{als})
  8510. @cindex diversion, creating alias (@code{als})
  8511. Create an alias named @var{new} for the request, string, macro, or
  8512. diversion object named @var{old}. The new name and the old name are
  8513. exactly equivalent (it is similar to a hard rather than a soft
  8514. link). If @var{old} is undefined, @code{gtroff} generates a warning of
  8515. type @samp{mac} and ignores the request.
  8516. @endDefreq
  8517. @Defreq {chop, xx}
  8518. Remove (chop) the last character from the macro, string, or diversion
  8519. named @var{xx}. This is useful for removing the newline from the end
  8520. of diversions that are to be interpolated as strings. This command
  8521. can be used repeatedly; see @ref{Gtroff Internals}, for details on
  8522. nodes inserted additionally by @code{gtroff}.
  8523. @endDefreq
  8524. @xref{Identifiers}, and @ref{Comments}.
  8525. @c =====================================================================
  8526. @node Conditionals and Loops, Writing Macros, Strings, gtroff Reference
  8527. @section Conditionals and Loops
  8528. @cindex conditionals and loops
  8529. @cindex loops and conditionals
  8530. @menu
  8531. * Operators in Conditionals::
  8532. * if-else::
  8533. * while::
  8534. @end menu
  8535. @c ---------------------------------------------------------------------
  8536. @node Operators in Conditionals, if-else, Conditionals and Loops, Conditionals and Loops
  8537. @subsection Operators in Conditionals
  8538. @cindex @code{if} request, operators to use with
  8539. @cindex @code{while} request, operators to use with
  8540. In @code{if} and @code{while} requests, there are several more
  8541. operators available:
  8542. @table @code
  8543. @item e
  8544. @itemx o
  8545. True if the current page is even or odd numbered (respectively).
  8546. @item n
  8547. True if the document is being processed in nroff mode (i.e., the
  8548. @code{.nroff} command has been issued).
  8549. @item t
  8550. True if the document is being processed in troff mode (i.e., the
  8551. @code{.troff} command has been issued).
  8552. @item v
  8553. Always false. This condition is for compatibility with other
  8554. @code{troff} versions only (identifying a @code{-Tversatec} device).
  8555. @item '@var{xxx}'@var{yyy}'
  8556. True if the string @var{xxx} is equal to the string @var{yyy}. Other
  8557. characters can be used in place of the single quotes; the same set of
  8558. delimiters as for the @code{\D} escape is used (@pxref{Escapes}).
  8559. @code{gtroff} formats the strings before being compared:
  8560. @Example
  8561. .ie "|"\fR|\fP" \
  8562. true
  8563. .el \
  8564. false
  8565. @result{} true
  8566. @endExample
  8567. @noindent
  8568. The resulting motions, glyph sizes, and fonts have to
  8569. match,@footnote{The created output nodes must be identical.
  8570. @xref{Gtroff Internals}.} and not the individual motion, size, and
  8571. font requests. In the previous example, @samp{|} and @samp{\fR|\fP}
  8572. both result in a roman @samp{|} glyph with the same point size and
  8573. at the same location on the page, so the strings are equal. If
  8574. @samp{.ft@tie{}I} had been added before the @samp{.ie}, the result
  8575. would be ``false'' because (the first) @samp{|} produces an italic
  8576. @samp{|} rather than a roman one.
  8577. @item r @var{xxx}
  8578. True if there is a number register named @var{xxx}.
  8579. @item d @var{xxx}
  8580. True if there is a string, macro, diversion, or request named @var{xxx}.
  8581. @item m @var{xxx}
  8582. True if there is a color named @var{xxx}.
  8583. @item c @var{g}
  8584. True if there is a glyph @var{g} available@footnote{The name of this
  8585. conditional operator is a misnomer since it tests names of output
  8586. glyphs.}; @var{g} is either an @acronym{ASCII} character or a special
  8587. character (@code{\(@var{gg}} or @code{\[@var{ggg}]}); the condition
  8588. is also true if @var{g} has been defined by the @code{char} request.
  8589. @item F @var{font}
  8590. True if a font named @var{font} exists. @var{font} is handled as if it was
  8591. opened with the @code{ft} request (this is, font translation and styles are
  8592. applied), without actually mounting it.
  8593. This test doesn't load the complete font but only its header to verify
  8594. its validity.
  8595. @item S @var{style}
  8596. True if style @var{style} has been registered. Font translation is applied.
  8597. @end table
  8598. Note that these operators can't be combined with other operators like
  8599. @samp{:} or @samp{&}; only a leading @samp{!} (without whitespace
  8600. between the exclamation mark and the operator) can be used to negate
  8601. the result.
  8602. @Example
  8603. .nr xxx 1
  8604. .ie !r xxx \
  8605. true
  8606. .el \
  8607. false
  8608. @result{} false
  8609. @endExample
  8610. A whitespace after @samp{!} always evaluates to zero (this bizarre
  8611. behaviour is due to compatibility with @acronym{UNIX} @code{troff}).
  8612. @Example
  8613. .nr xxx 1
  8614. .ie ! r xxx \
  8615. true
  8616. .el \
  8617. false
  8618. @result{} r xxx true
  8619. @endExample
  8620. It is possible to omit the whitespace before the argument to the
  8621. @samp{r}, @samp{d}, and @samp{c} operators.
  8622. @xref{Expressions}.
  8623. @c ---------------------------------------------------------------------
  8624. @node if-else, while, Operators in Conditionals, Conditionals and Loops
  8625. @subsection if-else
  8626. @cindex if-else
  8627. @code{gtroff} has if-then-else constructs like other languages, although
  8628. the formatting can be painful.
  8629. @Defreq {if, expr anything}
  8630. Evaluate the expression @var{expr}, and executes @var{anything} (the
  8631. remainder of the line) if @var{expr} evaluates to a value greater than
  8632. zero (true). @var{anything} is interpreted as though it was on a line
  8633. by itself (except that leading spaces are swallowed).
  8634. @xref{Expressions}, for more info.
  8635. @Example
  8636. .nr xxx 1
  8637. .nr yyy 2
  8638. .if ((\n[xxx] == 1) & (\n[yyy] == 2)) true
  8639. @result{} true
  8640. @endExample
  8641. @endDefreq
  8642. @Defreq{nop, anything}
  8643. Executes @var{anything}.
  8644. This is similar to @code{.if@tie{}1}.
  8645. @endDefreq
  8646. @DefreqList {ie, expr anything}
  8647. @DefreqListEnd {el, anything}
  8648. Use the @code{ie} and @code{el} requests to write an if-then-else.
  8649. The first request is the `if' part and the latter is the `else' part.
  8650. @Example
  8651. .ie n .ls 2 \" double-spacing in nroff
  8652. .el .ls 1 \" single-spacing in troff
  8653. @endExample
  8654. @endDefreq
  8655. @c there is a bug in makeinfo <= 4.1a: you can't have `@{' as an argument
  8656. @c to @deffn
  8657. @c
  8658. @c and in 4.2 you still can't use @{ in macros.
  8659. @c @DefescList {\@{, , , }
  8660. @c @DefescListEnd {\@}, , , }
  8661. @deffn Escape @t{\@{}
  8662. @deffnx Escape @t{\@}}
  8663. @esindex \@{
  8664. @esindex \@}
  8665. @cindex begin of conditional block (@code{\@{})
  8666. @cindex end of conditional block (@code{\@}})
  8667. @cindex conditional block, begin (@code{\@{})
  8668. @cindex conditional block, end (@code{\@}})
  8669. @cindex block, conditional, begin (@code{\@{})
  8670. @cindex block, condititional, end (@code{\@}})
  8671. In many cases, an if (or if-else) construct needs to execute more than
  8672. one request. This can be done using the @code{\@{} and @code{\@}}
  8673. escapes. The following example shows the possible ways to use these
  8674. escapes (note the position of the opening and closing braces).
  8675. @Example
  8676. .ie t \@{\
  8677. . ds lq ``
  8678. . ds rq ''
  8679. .\@}
  8680. .el \
  8681. .\@{\
  8682. . ds lq "
  8683. . ds rq "\@}
  8684. @endExample
  8685. @c @endDefesc
  8686. @end deffn
  8687. @xref{Expressions}.
  8688. @c ---------------------------------------------------------------------
  8689. @node while, , if-else, Conditionals and Loops
  8690. @subsection while
  8691. @cindex while
  8692. @code{gtroff} provides a looping construct using the @code{while}
  8693. request, which is used much like the @code{if} (and related) requests.
  8694. @Defreq {while, expr anything}
  8695. Evaluate the expression @var{expr}, and repeatedly execute
  8696. @var{anything} (the remainder of the line) until @var{expr} evaluates
  8697. to@tie{}0.
  8698. @Example
  8699. .nr a 0 1
  8700. .while (\na < 9) \@{\
  8701. \n+a,
  8702. .\@}
  8703. \n+a
  8704. @result{} 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
  8705. @endExample
  8706. Some remarks.
  8707. @cindex @code{de} request, and @code{while}
  8708. @itemize @bullet
  8709. @item
  8710. The body of a @code{while} request is treated like the body of a
  8711. @code{de} request: @code{gtroff} temporarily stores it in a macro
  8712. which is deleted after the loop has been exited. It can considerably
  8713. slow down a macro if the body of the @code{while} request (within the
  8714. macro) is large. Each time the macro is executed, the @code{while}
  8715. body is parsed and stored again as a temporary macro.
  8716. @Example
  8717. .de xxx
  8718. . nr num 10
  8719. . while (\\n[num] > 0) \@{\
  8720. . \" many lines of code
  8721. . nr num -1
  8722. . \@}
  8723. ..
  8724. @endExample
  8725. @cindex recursive macros
  8726. @cindex macros, recursive
  8727. @noindent
  8728. The traditional and ofter better solution (@acronym{UNIX} @code{troff}
  8729. doesn't have the @code{while} request) is to use a recursive macro
  8730. instead which is parsed only once during its definition.
  8731. @Example
  8732. .de yyy
  8733. . if (\\n[num] > 0) \@{\
  8734. . \" many lines of code
  8735. . nr num -1
  8736. . yyy
  8737. . \@}
  8738. ..
  8739. .
  8740. .de xxx
  8741. . nr num 10
  8742. . yyy
  8743. ..
  8744. @endExample
  8745. @noindent
  8746. Note that the number of available recursion levels is set to@tie{}1000
  8747. (this is a compile-time constant value of @code{gtroff}).
  8748. @item
  8749. The closing brace of a @code{while} body must end a line.
  8750. @Example
  8751. .if 1 \@{\
  8752. . nr a 0 1
  8753. . while (\n[a] < 10) \@{\
  8754. . nop \n+[a]
  8755. .\@}\@}
  8756. @result{} unbalanced \@{ \@}
  8757. @endExample
  8758. @end itemize
  8759. @endDefreq
  8760. @Defreq {break, }
  8761. @cindex @code{while} request, confusing with @code{br}
  8762. @cindex @code{break} request, in a @code{while} loop
  8763. @cindex @code{continue} request, in a @code{while} loop
  8764. Break out of a @code{while} loop. Be sure not to confuse this with
  8765. the @code{br} request (causing a line break).
  8766. @endDefreq
  8767. @Defreq {continue, }
  8768. Finish the current iteration of a @code{while} loop, immediately
  8769. restarting the next iteration.
  8770. @endDefreq
  8771. @xref{Expressions}.
  8772. @c =====================================================================
  8773. @node Writing Macros, Page Motions, Conditionals and Loops, gtroff Reference
  8774. @section Writing Macros
  8775. @cindex writing macros
  8776. @cindex macros, writing
  8777. A @dfn{macro} is a collection of text and embedded commands which can
  8778. be invoked multiple times. Use macros to define common operations.
  8779. @DefreqList {de, name [@Var{end}]}
  8780. @DefreqItem {de1, name [@Var{end}]}
  8781. @DefreqItem {dei, name [@Var{end}]}
  8782. @DefreqListEnd {dei1, name [@Var{end}]}
  8783. Define a new macro named @var{name}. @code{gtroff} copies subsequent
  8784. lines (starting with the next one) into an internal buffer until it
  8785. encounters the line @samp{..} (two dots). The optional second
  8786. argument to @code{de} changes this to a macro to @samp{.@var{end}}.
  8787. There can be whitespace after the first dot in the line containing the
  8788. ending token (either @samp{.} or macro @samp{@var{end}}).
  8789. Here a small example macro called @samp{P} which causes a break and
  8790. inserts some vertical space. It could be used to separate paragraphs.
  8791. @Example
  8792. .de P
  8793. . br
  8794. . sp .8v
  8795. ..
  8796. @endExample
  8797. The following example defines a macro within another. Remember that
  8798. expansion must be protected twice; once for reading the macro and
  8799. once for executing.
  8800. @Example
  8801. \# a dummy macro to avoid a warning
  8802. .de end
  8803. ..
  8804. .
  8805. .de foo
  8806. . de bar end
  8807. . nop \f[B]Hallo \\\\$1!\f[]
  8808. . end
  8809. ..
  8810. .
  8811. .foo
  8812. .bar Joe
  8813. @result{} @b{Hallo Joe!}
  8814. @endExample
  8815. @noindent
  8816. Since @code{\f} has no expansion, it isn't necessary to protect its
  8817. backslash. Had we defined another macro within @code{bar} which takes
  8818. a parameter, eight backslashes would be necessary before @samp{$1}.
  8819. The @code{de1} request turns off compatibility mode
  8820. while executing the macro. On entry, the current compatibility mode
  8821. is saved and restored at exit.
  8822. @Example
  8823. .nr xxx 12345
  8824. .
  8825. .de aa
  8826. The value of xxx is \\n[xxx].
  8827. ..
  8828. .de1 bb
  8829. The value of xxx ix \\n[xxx].
  8830. ..
  8831. .
  8832. .cp 1
  8833. .
  8834. .aa
  8835. @result{} warning: number register `[' not defined
  8836. @result{} The value of xxx is 0xxx].
  8837. .bb
  8838. @result{} The value of xxx ix 12345.
  8839. @endExample
  8840. The @code{dei} request defines a macro indirectly.
  8841. That is, it expands strings whose names
  8842. are @var{name} or @var{end} before performing the append.
  8843. This:
  8844. @Example
  8845. .ds xx aa
  8846. .ds yy bb
  8847. .dei xx yy
  8848. @endExample
  8849. @noindent
  8850. is equivalent to:
  8851. @Example
  8852. .de aa bb
  8853. @endExample
  8854. The @code{dei1} request is similar to @code{dei} but with compatibility
  8855. mode switched off during execution of the defined macro.
  8856. If compatibility mode is on, @code{de} (and @code{dei}) behave similar to
  8857. @code{de1} (and @code{dei1}): A `compatibility save' token is inserted at
  8858. the beginning, and a `compatibility restore' token at the end, with
  8859. compatibility mode switched on during execution. @xref{Gtroff Internals},
  8860. for more information on switching compatibility mode on and off in a
  8861. single document.
  8862. @pindex trace.tmac
  8863. Using @file{trace.tmac}, you can trace calls to @code{de} and @code{de1}.
  8864. Note that macro identifiers are shared with identifiers for strings and
  8865. diversions.
  8866. @endDefreq
  8867. @DefreqList {am, name [@Var{end}]}
  8868. @DefreqItem {am1, name [@Var{end}]}
  8869. @DefreqItem {ami, name [@Var{end}]}
  8870. @DefreqListEnd {ami1, name [@Var{end}]}
  8871. @cindex appending to a macro (@code{am})
  8872. @cindex macro, appending (@code{am})
  8873. Works similarly to @code{de} except it appends onto the macro named
  8874. @var{name}. So, to make the previously defined @samp{P} macro actually
  8875. do indented instead of block paragraphs, add the necessary code to the
  8876. existing macro like this:
  8877. @Example
  8878. .am P
  8879. .ti +5n
  8880. ..
  8881. @endExample
  8882. The @code{am1} request turns off compatibility mode
  8883. while executing the appended macro piece. To be more precise, a
  8884. @dfn{compatibility save} input token is inserted at the beginning of
  8885. the appended code, and a @dfn{compatibility restore} input token at
  8886. the end.
  8887. The @code{ami} request appends indirectly,
  8888. meaning that @code{gtroff} expands strings whose names
  8889. are @var{name} or @var{end} before performing the append.
  8890. The @code{ami1} request is similar to @code{ami} but compatibility mode
  8891. is switched off during execution of the defined macro.
  8892. @pindex trace.tmac
  8893. Using @file{trace.tmac}, you can trace calls to @code{am} and @code{am1}.
  8894. @endDefreq
  8895. @xref{Strings}, for the @code{als} request to rename a macro.
  8896. The @code{de}, @code{am}, @code{di}, @code{da}, @code{ds}, and
  8897. @code{as} requests (together with its variants) only create a new object
  8898. if the name of the macro, diversion or string diversion is currently
  8899. undefined or if it is defined to be a request; normally they modify the
  8900. value of an existing object.
  8901. @Defreq {return, [@Var{anything}]}
  8902. Exit a macro, immediately returning to the caller.
  8903. If called with an argument, exit twice, namely the current macro and the
  8904. macro one level higher. This is used to define a wrapper macro for
  8905. @code{return} in @file{trace.tmac}.
  8906. @endDefreq
  8907. @menu
  8908. * Copy-in Mode::
  8909. * Parameters::
  8910. @end menu
  8911. @c ---------------------------------------------------------------------
  8912. @node Copy-in Mode, Parameters, Writing Macros, Writing Macros
  8913. @subsection Copy-in Mode
  8914. @cindex copy-in mode
  8915. @cindex mode, copy-in
  8916. @cindex @code{\n}, when reading text for a macro
  8917. @cindex @code{\$}, when reading text for a macro
  8918. @cindex @code{\*}, when reading text for a macro
  8919. @cindex @code{\\}, when reading text for a macro
  8920. @cindex \@key{RET}, when reading text for a macro
  8921. When @code{gtroff} reads in the text for a macro, string, or diversion,
  8922. it copies the text (including request lines, but excluding escapes) into
  8923. an internal buffer. Escapes are converted into an internal form,
  8924. except for @code{\n}, @code{\$}, @code{\*}, @code{\\} and
  8925. @code{\@key{RET}} which are evaluated and inserted into the text where
  8926. the escape was located. This is known as @dfn{copy-in} mode or
  8927. @dfn{copy} mode.
  8928. What this means is that you can specify when these escapes are to be
  8929. evaluated (either at copy-in time or at the time of use) by insulating
  8930. the escapes with an extra backslash. Compare this to the @code{\def}
  8931. and @code{\edef} commands in @TeX{}.
  8932. The following example prints the numbers 20 and@tie{}10:
  8933. @Example
  8934. .nr x 20
  8935. .de y
  8936. .nr x 10
  8937. \&\nx
  8938. \&\\nx
  8939. ..
  8940. .y
  8941. @endExample
  8942. @c ---------------------------------------------------------------------
  8943. @node Parameters, , Copy-in Mode, Writing Macros
  8944. @subsection Parameters
  8945. @cindex parameters
  8946. The arguments to a macro or string can be examined using a variety of
  8947. escapes.
  8948. @Defreg {.$}
  8949. @cindex number of arguments register (@code{.$})
  8950. The number of arguments passed to a macro or string. This is a read-only
  8951. number register.
  8952. Note that the @code{shift} request can change its value.
  8953. @endDefreg
  8954. Any individual argument can be retrieved with one of the following
  8955. escapes:
  8956. @DefescList {\\$, , n, }
  8957. @DefescItem {\\$, @Lparen{}, nn, }
  8958. @DefescListEnd {\\$, @Lbrack{}, nnn, @Rbrack{}}
  8959. @cindex copy-in mode, and macro arguments
  8960. @cindex macro, arguments (@code{\$})
  8961. @cindex arguments, macro (@code{\$})
  8962. Retrieve the @var{n}@dmn{th}, @var{nn}@dmn{th} or @var{nnn}@dmn{th}
  8963. argument. As usual, the first form only accepts a single number
  8964. (larger than zero), the second a two-digit number (larger or equal
  8965. to@tie{}10), and the third any positive integer value (larger
  8966. than zero). Macros and strings can have an unlimited number of arguments.
  8967. Note that due to copy-in mode, use two backslashes on these in actual use
  8968. to prevent interpolation until the macro is actually invoked.
  8969. @endDefesc
  8970. @Defreq {shift, [@Var{n}]}
  8971. Shift the arguments 1@tie{}position, or as
  8972. many positions as specified by its argument. After executing this
  8973. request, argument@tie{}@var{i} becomes argument @math{@var{i}-@var{n}};
  8974. arguments 1 to@tie{}@var{n} are no longer available. Shifting by
  8975. negative amounts is currently undefined.
  8976. The register @code{.$} is adjusted accordingly.
  8977. @endDefreq
  8978. @DefescList {\\$*, , , }
  8979. @DefescListEnd {\\$@@, , , }
  8980. In some cases it is convenient to use all of the arguments at once (for
  8981. example, to pass the arguments along to another macro). The @code{\$*}
  8982. escape concatenates all the arguments separated by spaces. A
  8983. similar escape is @code{\$@@}, which concatenates all the
  8984. arguments with each surrounded by double quotes, and separated by
  8985. spaces. If not in compatibility mode, the input level of double quotes
  8986. is preserved (see @ref{Request and Macro Arguments}).
  8987. @endDefesc
  8988. @Defesc {\\$0, , , }
  8989. @cindex macro name register (@code{\$0})
  8990. @cindex @code{als} request, and @code{\$0}
  8991. The name used to invoke the current macro.
  8992. The @code{als} request can make a macro have more than one name.
  8993. @Example
  8994. .de generic-macro
  8995. . ...
  8996. . if \\n[error] \@{\
  8997. . tm \\$0: Houston, we have a problem.
  8998. . return
  8999. . \@}
  9000. ..
  9001. .
  9002. .als foo generic-macro
  9003. .als bar generic-macro
  9004. @endExample
  9005. @endDefesc
  9006. @xref{Request and Macro Arguments}.
  9007. @c =====================================================================
  9008. @node Page Motions, Drawing Requests, Writing Macros, gtroff Reference
  9009. @section Page Motions
  9010. @cindex page motions
  9011. @cindex motions, page
  9012. @xref{Manipulating Spacing}, for a discussion of the main request for
  9013. vertical motion, @code{sp}.
  9014. @DefreqList {mk, [@Var{reg}]}
  9015. @DefreqListEnd {rt, [@Var{dist}]}
  9016. @cindex marking vertical page location (@code{mk})
  9017. @cindex page location, vertical, marking (@code{mk})
  9018. @cindex location, vertical, page, marking (@code{mk})
  9019. @cindex vertical page location, marking (@code{mk})
  9020. @cindex returning to marked vertical page location (@code{rt})
  9021. @cindex page location, vertical, returning to marked (@code{rt})
  9022. @cindex location, vertical, page, returning to marked (@code{rt})
  9023. @cindex vertical page location, returning to marked (@code{rt})
  9024. The request @code{mk} can be used to mark a location on a page, for
  9025. movement to later. This request takes a register name as an argument
  9026. in which to store the current page location. With no argument it
  9027. stores the location in an internal register. The results of this can
  9028. be used later by the @code{rt} or the @code{sp} request (or the
  9029. @code{\v} escape).
  9030. The @code{rt} request returns @emph{upwards} to the location marked
  9031. with the last @code{mk} request. If used with an argument, return to
  9032. a position which distance from the top of the page is @var{dist} (no
  9033. previous call to @code{mk} is necessary in this case). Default scaling
  9034. indicator is @samp{v}.
  9035. Here a primitive solution for a two-column macro.
  9036. @Example
  9037. .nr column-length 1.5i
  9038. .nr column-gap 4m
  9039. .nr bottom-margin 1m
  9040. .
  9041. @endExample
  9042. @Example
  9043. .de 2c
  9044. . br
  9045. . mk
  9046. . ll \\n[column-length]u
  9047. . wh -\\n[bottom-margin]u 2c-trap
  9048. . nr right-side 0
  9049. ..
  9050. .
  9051. @endExample
  9052. @Example
  9053. .de 2c-trap
  9054. . ie \\n[right-side] \@{\
  9055. . nr right-side 0
  9056. . po -(\\n[column-length]u + \\n[column-gap]u)
  9057. . \" remove trap
  9058. . wh -\\n[bottom-margin]u
  9059. . \@}
  9060. . el \@{\
  9061. . \" switch to right side
  9062. . nr right-side 1
  9063. . po +(\\n[column-length]u + \\n[column-gap]u)
  9064. . rt
  9065. . \@}
  9066. ..
  9067. .
  9068. @endExample
  9069. @Example
  9070. .pl 1.5i
  9071. .ll 4i
  9072. This is a small test which shows how the
  9073. rt request works in combination with mk.
  9074. .2c
  9075. Starting here, text is typeset in two columns.
  9076. Note that this implementation isn't robust
  9077. and thus not suited for a real two-column
  9078. macro.
  9079. @endExample
  9080. Result:
  9081. @Example
  9082. This is a small test which shows how the
  9083. rt request works in combination with mk.
  9084. Starting here, isn't robust
  9085. text is typeset and thus not
  9086. in two columns. suited for a
  9087. Note that this real two-column
  9088. implementation macro.
  9089. @endExample
  9090. @endDefreq
  9091. The following escapes give fine control of movements about the page.
  9092. @Defesc {\\v, ', e, '}
  9093. @cindex vertical motion (@code{\v})
  9094. @cindex motion, vertical (@code{\v})
  9095. Move vertically, usually from the current location on the page (if no
  9096. absolute position operator @samp{|} is used). The
  9097. argument@tie{}@var{e} specifies the distance to move; positive is
  9098. downwards and negative upwards. The default scaling indicator for this
  9099. escape is @samp{v}. Beware, however, that @code{gtroff} continues text
  9100. processing at the point where the motion ends, so you should always
  9101. balance motions to avoid interference with text processing.
  9102. @code{\v} doesn't trigger a trap. This can be quite useful; for example,
  9103. consider a page bottom trap macro which prints a marker in the margin to
  9104. indicate continuation of a footnote or something similar.
  9105. @endDefesc
  9106. There are some special-case escapes for vertical motion.
  9107. @Defesc {\\r, , , }
  9108. Move upwards@tie{}1@dmn{v}.
  9109. @endDefesc
  9110. @Defesc {\\u, , , }
  9111. Move upwards@tie{}.5@dmn{v}.
  9112. @endDefesc
  9113. @Defesc {\\d, , , }
  9114. Move down@tie{}.5@dmn{v}.
  9115. @endDefesc
  9116. @Defesc {\\h, ', e, '}
  9117. @cindex inserting horizontal space (@code{\h})
  9118. @cindex horizontal space (@code{\h})
  9119. @cindex space, horizontal (@code{\h})
  9120. @cindex horizontal motion (@code{\h})
  9121. @cindex motion, horizontal (@code{\h})
  9122. Move horizontally, usually from the current location (if no absolute
  9123. position operator @samp{|} is used). The expression@tie{}@var{e}
  9124. indicates how far to move: positive is rightwards and negative
  9125. leftwards. The default scaling indicator for this escape is @samp{m}.
  9126. This horizontal space is not discarded at the end of a line. To insert
  9127. discardable space of a certain length use the @code{ss} request.
  9128. @endDefesc
  9129. There are a number of special-case escapes for horizontal motion.
  9130. @Defesc {\\@key{SP}, , , }
  9131. @cindex space, unbreakable
  9132. @cindex unbreakable space
  9133. An unbreakable and unpaddable (i.e.@: not expanded during filling)
  9134. space. (Note: This is a backslash followed by a space.)
  9135. @endDefesc
  9136. @Defesc {\\~, , , }
  9137. An unbreakable space that stretches like a normal inter-word space
  9138. when a line is adjusted.
  9139. @endDefesc
  9140. @Defesc {\\|, , , }
  9141. A 1/6@dmn{th} em space. Ignored for TTY output devices (rounded to
  9142. zero).
  9143. @endDefesc
  9144. @Defesc {\\^, , , }
  9145. A 1/12@dmn{th} em space. Ignored for TTY output devices (rounded to
  9146. zero).
  9147. @endDefesc
  9148. @Defesc {\\0, , , }
  9149. @cindex space, width of a digit (@code{\0})
  9150. @cindex digit width space (@code{\0})
  9151. A space the size of a digit.
  9152. @endDefesc
  9153. The following string sets the @TeX{} logo:
  9154. @Example
  9155. .ds TeX T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
  9156. @endExample
  9157. @DefescList {\\w, ', text, '}
  9158. @DefregItem {st}
  9159. @DefregItem {sb}
  9160. @DefregItem {rst}
  9161. @DefregItem {rsb}
  9162. @DefregItem {ct}
  9163. @DefregItem {ssc}
  9164. @DefregListEnd {skw}
  9165. @cindex width escape (@code{\w})
  9166. Return the width of the specified @var{text} in basic units.
  9167. This allows horizontal movement based on the width of some
  9168. arbitrary text (e.g.@: given as an argument to a macro).
  9169. @Example
  9170. The length of the string `abc' is \w'abc'u.
  9171. @result{} The length of the string `abc' is 72u.
  9172. @endExample
  9173. Font changes may occur in @var{text} which don't affect current
  9174. settings.
  9175. After use, @code{\w} sets several registers:
  9176. @table @code
  9177. @item st
  9178. @itemx sb
  9179. The highest and lowest point of the baseline, respectively, in @var{text}.
  9180. @item rst
  9181. @itemx rsb
  9182. Like the @code{st} and @code{sb} registers, but takes account of the
  9183. heights and depths of glyphs. With other words, this gives the
  9184. highest and lowest point of @var{text}. Values below the baseline are
  9185. negative.
  9186. @item ct
  9187. Defines the kinds of glyphs occurring in @var{text}:
  9188. @table @asis
  9189. @item 0
  9190. only short glyphs, no descenders or tall glyphs.
  9191. @item 1
  9192. at least one descender.
  9193. @item 2
  9194. at least one tall glyph.
  9195. @item 3
  9196. at least one each of a descender and a tall glyph.
  9197. @end table
  9198. @item ssc
  9199. The amount of horizontal space (possibly negative) that should be added
  9200. to the last glyph before a subscript.
  9201. @item skw
  9202. How far to right of the center of the last glyph in the @code{\w}
  9203. argument, the center of an accent from a roman font should be placed
  9204. over that glyph.
  9205. @end table
  9206. @endDefesc
  9207. @DefescList {\\k, , p, }
  9208. @DefescItem {\\k, @Lparen{}, ps, }
  9209. @DefescListEnd {\\k, @Lbrack{}, position, @Rbrack{}}
  9210. @cindex saving horizontal input line position (@code{\k})
  9211. @cindex horizontal input line position, saving (@code{\k})
  9212. @cindex input line position, horizontal, saving (@code{\k})
  9213. @cindex position, horizontal input line, saving (@code{\k})
  9214. @cindex line, input, horizontal position, saving (@code{\k})
  9215. Store the current horizontal position in the @emph{input} line in
  9216. number register with name @var{position} (one-character name@tie{}@var{p},
  9217. two-character name @var{ps}). Use this, for example, to return to the
  9218. beginning of a string for highlighting or other decoration.
  9219. @endDefesc
  9220. @Defreg {hp}
  9221. @cindex horizontal input line position register (@code{hp})
  9222. @cindex input line, horizontal position, register (@code{hp})
  9223. @cindex position, horizontal, in input line, register (@code{hp})
  9224. @cindex line, input, horizontal position, register (@code{hp})
  9225. The current horizontal position at the input line.
  9226. @endDefreg
  9227. @Defreg {.k}
  9228. @cindex horizontal output line position register (@code{.k})
  9229. @cindex output line, horizontal position, register (@code{.k})
  9230. @cindex position, horizontal, in output line, register (@code{.k})
  9231. @cindex line, output, horizontal position, register (@code{.k})
  9232. A read-only number register containing the current horizontal output
  9233. position (relative to the current indentation).
  9234. @endDefreg
  9235. @Defesc {\\o, ', abc, '}
  9236. @cindex overstriking glyphs (@code{\o})
  9237. @cindex glyphs, overstriking (@code{\o})
  9238. Overstrike glyphs @var{a}, @var{b}, @var{c}, @dots{}; the glyphs
  9239. are centered, and the resulting spacing is the largest width of the
  9240. affected glyphs.
  9241. @endDefesc
  9242. @Defesc {\\z, , g, , }
  9243. @cindex zero-width printing (@code{\z}, @code{\Z})
  9244. @cindex printing, zero-width (@code{\z}, @code{\Z})
  9245. Print glyph @var{g} with zero width, i.e., without spacing. Use
  9246. this to overstrike glyphs left-aligned.
  9247. @endDefesc
  9248. @Defesc {\\Z, ', anything, '}
  9249. @cindex zero-width printing (@code{\z}, @code{\Z})
  9250. @cindex printing, zero-width (@code{\z}, @code{\Z})
  9251. Print @var{anything}, then restore the horizontal and vertical position.
  9252. The argument may not contain tabs or leaders.
  9253. The following is an example of a strike-through macro:
  9254. @Example
  9255. .de ST
  9256. .nr ww \w'\\$1'
  9257. \Z@@\v'-.25m'\l'\\n[ww]u'@@\\$1
  9258. ..
  9259. .
  9260. This is
  9261. .ST "a test"
  9262. an actual emergency!
  9263. @endExample
  9264. @endDefesc
  9265. @c =====================================================================
  9266. @node Drawing Requests, Traps, Page Motions, gtroff Reference
  9267. @section Drawing Requests
  9268. @cindex drawing requests
  9269. @cindex requests for drawing
  9270. @code{gtroff} provides a number of ways to draw lines and other figures
  9271. on the page. Used in combination with the page motion commands (see
  9272. @ref{Page Motions}, for more info), a wide variety of figures can be
  9273. drawn. However, for complex drawings these operations can be quite
  9274. cumbersome, and it may be wise to use graphic preprocessors like
  9275. @code{gpic} or @code{ggrn}. @xref{gpic}, and @ref{ggrn}, for more
  9276. information.
  9277. All drawing is done via escapes.
  9278. @DefescList {\\l, ', l, '}
  9279. @DefescListEnd {\\l, ', lg, '}
  9280. @cindex drawing horizontal lines (@code{\l})
  9281. @cindex horizontal line, drawing (@code{\l})
  9282. @cindex line, horizontal, drawing (@code{\l})
  9283. Draw a line horizontally. @var{l} is the length of the line to be
  9284. drawn. If it is positive, start the line at the current location and
  9285. draw to the right; its end point is the new current location. Negative
  9286. values are handled differently: The line starts at the current location
  9287. and draws to the left, but the current location doesn't move.
  9288. @var{l} can also be specified absolutely (i.e.@: with a leading
  9289. @samp{|}) which draws back to the beginning of the input line.
  9290. Default scaling indicator is @samp{m}.
  9291. @cindex underscore glyph (@code{\[ru]})
  9292. @cindex glyph, underscore (@code{\[ru]})
  9293. @cindex line drawing glyph
  9294. @cindex glyph, for line drawing
  9295. The optional second parameter@tie{}@var{g} is a glyph to draw the line
  9296. with. If this second argument is not specified, @code{gtroff} uses
  9297. the underscore glyph, @code{\[ru]}.
  9298. @cindex zero width space character (@code{\&})
  9299. @cindex character, zero width space (@code{\&})
  9300. @cindex space character, zero width (@code{\&})
  9301. To separate the two arguments (to prevent @code{gtroff} from
  9302. interpreting a drawing glyph as a scaling indicator if the glyph is
  9303. represented by a single character) use @code{\&}.
  9304. Here a small useful example:
  9305. @Example
  9306. .de box
  9307. \[br]\\$*\[br]\l'|0\[rn]'\l'|0\[ul]'
  9308. ..
  9309. @endExample
  9310. @noindent
  9311. Note that this works by outputting a box rule (a vertical line), then
  9312. the text given as an argument and then another box rule. Finally, the
  9313. line drawing escapes both draw from the current location to the
  9314. beginning of the @emph{input} line -- this works because the line
  9315. length is negative, not moving the current point.
  9316. @endDefesc
  9317. @DefescList {\\L, ', l, '}
  9318. @DefescListEnd {\\L, ', lg, '}
  9319. @cindex drawing vertical lines (@code{\L})
  9320. @cindex vertical line drawing (@code{\L})
  9321. @cindex line, vertical, drawing (@code{\L})
  9322. @cindex line drawing glyph
  9323. @cindex glyph for line drawing
  9324. @cindex box rule glyph (@code{\[br]})
  9325. @cindex glyph, box rule (@code{\[br]})
  9326. Draw vertical lines. Its parameters are
  9327. similar to the @code{\l} escape, except that the default scaling
  9328. indicator is @samp{v}. The movement is downwards for positive values,
  9329. and upwards for negative values. The default glyph is the box rule
  9330. glyph, @code{\[br]}. As with the vertical motion escapes, text
  9331. processing blindly continues where the line ends.
  9332. @Example
  9333. This is a \L'3v'test.
  9334. @endExample
  9335. @noindent
  9336. Here the result, produced with @code{grotty}.
  9337. @Example
  9338. This is a
  9339. |
  9340. |
  9341. |test.
  9342. @endExample
  9343. @endDefesc
  9344. @Defesc {\\D, ', command arg @dots{}, '}
  9345. The @code{\D} escape provides a variety of drawing functions.
  9346. Note that on character devices, only vertical and horizontal lines are
  9347. supported within @code{grotty}; other devices may only support a subset
  9348. of the available drawing functions.
  9349. The default scaling indicator for all subcommands of @code{\D} is
  9350. @samp{m} for horizontal distances and @samp{v} for vertical ones.
  9351. Exceptions are @w{@code{\D'f @dots{}'}} and @w{@code{\D't @dots{}'}}
  9352. which use @code{u} as the default, and @w{@code{\D'F@var{x} @dots{}'}}
  9353. which arguments are treated similar to the @code{defcolor} request.
  9354. @table @code
  9355. @item \D'l @var{dx} @var{dy}'
  9356. @cindex line, drawing (@w{@code{\D'l @dots{}'}})
  9357. @cindex drawing a line (@w{@code{\D'l @dots{}'}})
  9358. Draw a line from the current location to the relative point specified by
  9359. (@var{dx},@var{dy}), where positive values mean down and right,
  9360. respectively. The end point of the line is the new current location.
  9361. The following example is a macro for creating a box around a text string;
  9362. for simplicity, the box margin is taken as a fixed value, 0.2@dmn{m}.
  9363. @Example
  9364. .de BOX
  9365. . nr @@wd \w'\\$1'
  9366. \h'.2m'\
  9367. \h'-.2m'\v'(.2m - \\n[rsb]u)'\
  9368. \D'l 0 -(\\n[rst]u - \\n[rsb]u + .4m)'\
  9369. \D'l (\\n[@@wd]u + .4m) 0'\
  9370. \D'l 0 (\\n[rst]u - \\n[rsb]u + .4m)'\
  9371. \D'l -(\\n[@@wd]u + .4m) 0'\
  9372. \h'.2m'\v'-(.2m - \\n[rsb]u)'\
  9373. \\$1\
  9374. \h'.2m'
  9375. ..
  9376. @endExample
  9377. @noindent
  9378. First, the width of the string is stored in register @code{@@wd}. Then,
  9379. four lines are drawn to form a box, properly offset by the box margin.
  9380. The registers @code{rst} and @code{rsb} are set by the @code{\w} escape,
  9381. containing the largest height and depth of the whole string.
  9382. @item \D'c @var{d}'
  9383. @cindex circle, drawing (@w{@code{\D'c @dots{}'}})
  9384. @cindex drawing a circle (@w{@code{\D'c @dots{}'}})
  9385. Draw a circle with a diameter of@tie{}@var{d} with the leftmost point at the
  9386. current position. After drawing, the current location is positioned at the
  9387. rightmost point of the circle.
  9388. @item \D'C @var{d}'
  9389. @cindex circle, solid, drawing (@w{@code{\D'C @dots{}'}})
  9390. @cindex drawing a solid circle (@w{@code{\D'C @dots{}'}})
  9391. @cindex solid circle, drawing (@w{@code{\D'C @dots{}'}})
  9392. Draw a solid circle with the same parameters and behaviour as an outlined
  9393. circle. No outline is drawn.
  9394. @item \D'e @var{x} @var{y}'
  9395. @cindex drawing an ellipse (@w{@code{\D'e @dots{}'}})
  9396. @cindex ellipse, drawing (@w{@code{\D'e @dots{}'}})
  9397. Draw an ellipse with a horizontal diameter of @var{x} and a vertical
  9398. diameter of @var{y} with the leftmost point at the current position.
  9399. After drawing, the current location is positioned at the rightmost point of
  9400. the ellipse.
  9401. @item \D'E @var{x} @var{y}'
  9402. @cindex ellipse, solid, drawing (@w{@code{\D'E @dots{}'}})
  9403. @cindex drawing a solid ellipse (@w{@code{\D'E @dots{}'}})
  9404. @cindex solid ellipse, drawing (@w{@code{\D'E @dots{}'}})
  9405. Draw a solid ellipse with the same parameters and behaviour as an
  9406. outlined ellipse. No outline is drawn.
  9407. @item \D'a @var{dx1} @var{dy1} @var{dx2} @var{dy2}'
  9408. @cindex arc, drawing (@w{@code{\D'a @dots{}'}})
  9409. @cindex drawing an arc (@w{@code{\D'a @dots{}'}})
  9410. Draw an arc clockwise from the current location through the two
  9411. specified relative locations (@var{dx1},@var{dy1}) and
  9412. (@var{dx2},@var{dy2}). The coordinates of the first point are relative
  9413. to the current position, and the coordinates of the second point are
  9414. relative to the first point. After drawing, the current position is moved
  9415. to the final point of the arc.
  9416. @item \D'~ @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
  9417. @cindex drawing a spline (@w{@code{\D'~ @dots{}'}})
  9418. @cindex spline, drawing (@w{@code{\D'~ @dots{}'}})
  9419. Draw a spline from the current location to the relative point
  9420. (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}), and so on.
  9421. The current position is moved to the terminal point of the drawn curve.
  9422. @item \D'f @var{n}'
  9423. @cindex gray shading (@w{@code{\D'f @dots{}'}})
  9424. @cindex shading filled objects (@w{@code{\D'f @dots{}'}})
  9425. Set the shade of gray to be used for filling solid objects to@tie{}@var{n};
  9426. @var{n}@tie{}must be an integer between 0 and@tie{}1000, where 0
  9427. corresponds solid white and 1000 to solid black, and values in between
  9428. correspond to intermediate shades of gray. This applies only to solid
  9429. circles, solid ellipses, and solid polygons. By default, a level of
  9430. 1000 is used.
  9431. Despite of being silly, the current point is moved horizontally to the
  9432. right by@tie{}@var{n}.
  9433. @cindex @w{@code{\D'f @dots{}'}} and horizontal resolution
  9434. Don't use this command! It has the serious drawback that it will be
  9435. always rounded to the next integer multiple of the horizontal resolution
  9436. (the value of the @code{hor} keyword in the @file{DESC} file). Use
  9437. @code{\M} (@pxref{Colors}) or @w{@code{\D'Fg @dots{}'}} instead.
  9438. @item \D'p @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
  9439. @cindex drawing a polygon (@w{@code{\D'p @dots{}'}})
  9440. @cindex polygon, drawing (@w{@code{\D'p @dots{}'}})
  9441. Draw a polygon from the current location to the relative position
  9442. (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}) and so on.
  9443. When the specified data points are exhausted, a line is drawn back
  9444. to the starting point. The current position is changed by adding the
  9445. sum of all arguments with odd index to the actual horizontal position and
  9446. the even ones to the vertical position.
  9447. @item \D'P @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
  9448. @cindex polygon, solid, drawing (@w{@code{\D'P @dots{}'}})
  9449. @cindex drawing a solid polygon (@w{@code{\D'P @dots{}'}})
  9450. @cindex solid polygon, drawing (@w{@code{\D'P @dots{}'}})
  9451. Draw a solid polygon with the same parameters and behaviour as an
  9452. outlined polygon. No outline is drawn.
  9453. Here a better variant of the box macro to fill the box with some color.
  9454. Note that the box must be drawn before the text since colors in
  9455. @code{gtroff} are not transparent; the filled polygon would hide the
  9456. text completely.
  9457. @Example
  9458. .de BOX
  9459. . nr @@wd \w'\\$1'
  9460. \h'.2m'\
  9461. \h'-.2m'\v'(.2m - \\n[rsb]u)'\
  9462. \M[lightcyan]\
  9463. \D'P 0 -(\\n[rst]u - \\n[rsb]u + .4m) \
  9464. (\\n[@@wd]u + .4m) 0 \
  9465. 0 (\\n[rst]u - \\n[rsb]u + .4m) \
  9466. -(\\n[@@wd]u + .4m) 0'\
  9467. \h'.2m'\v'-(.2m - \\n[rsb]u)'\
  9468. \M[]\
  9469. \\$1\
  9470. \h'.2m'
  9471. ..
  9472. @endExample
  9473. @item \D't @var{n}'
  9474. @cindex line thickness (@w{@code{\D't @dots{}'}})
  9475. @cindex thickness of lines (@w{@code{\D't @dots{}'}})
  9476. Set the current line thickness to @var{n}@tie{}machine units. A value of
  9477. zero selects the smallest available line thickness. A negative value
  9478. makes the line thickness proportional to the current point size (this is
  9479. the default behaviour of @acronym{AT&T} @code{troff}).
  9480. Despite of being silly, the current point is moved horizontally to the
  9481. right by@tie{}@var{n}.
  9482. @item \D'F@var{scheme} @var{color_components}'
  9483. @cindex unnamed fill colors (@code{\D'F@dots{}'})
  9484. @cindex fill colors, unnamed (@code{\D'F@dots{}'})
  9485. @cindex colors, fill, unnamed (@code{\D'F@dots{}'})
  9486. Change current fill color. @var{scheme} is a single letter denoting the
  9487. color scheme: @samp{r} (rgb), @samp{c} (cmy), @samp{k} (cmyk), @samp{g}
  9488. (gray), or @samp{d} (default color). The color components use exactly
  9489. the same syntax as in the @code{defcolor} request (@pxref{Colors}); the
  9490. command @code{\D'Fd'} doesn't take an argument.
  9491. @emph{No} position changing!
  9492. Examples:
  9493. @Example
  9494. @endExample
  9495. \D'Fg .3' \" same gray as \D'f 700'
  9496. \D'Fr #0000ff' \" blue
  9497. @end table
  9498. @endDefesc
  9499. @xref{Graphics Commands}.
  9500. @Defesc {\\b, ', string, '}
  9501. @cindex pile, glyph (@code{\b})
  9502. @cindex glyph pile (@code{\b})
  9503. @cindex stacking glyphs (@code{\b})
  9504. @dfn{Pile} a sequence of glyphs vertically, and center it vertically
  9505. on the current line. Use it to build large brackets and braces.
  9506. Here an example how to create a large opening brace:
  9507. @Example
  9508. \b'\[lt]\[bv]\[lk]\[bv]\[lb]'
  9509. @endExample
  9510. @cindex @code{\b}, limitations
  9511. @cindex limitations of @code{\b} escape
  9512. The first glyph is on the top, the last glyph in @var{string} is
  9513. at the bottom. Note that @code{gtroff} separates the glyphs
  9514. vertically by 1@dmn{m}, and the whole object is centered 0.5@dmn{m}
  9515. above the current baseline; the largest glyph width is used as the
  9516. width for the whole object. This rather unflexible positioning
  9517. algorithm doesn't work with @option{-Tdvi} since the bracket pieces vary
  9518. in height for this device. Instead, use the @code{eqn} preprocessor.
  9519. @xref{Manipulating Spacing}, how to adjust the vertical spacing with
  9520. the @code{\x} escape.
  9521. @endDefesc
  9522. @c =====================================================================
  9523. @node Traps, Diversions, Drawing Requests, gtroff Reference
  9524. @section Traps
  9525. @cindex traps
  9526. @dfn{Traps} are locations, which, when reached, call a specified
  9527. macro. These traps can occur at a given location on the page, at a
  9528. given location in the current diversion, at a blank line,
  9529. after a certain number of input lines, or at the end of input.
  9530. @cindex planting a trap
  9531. @cindex trap, planting
  9532. Setting a trap is also called @dfn{planting}.
  9533. @cindex trap, springing
  9534. @cindex springing a trap
  9535. It is also said that a trap is @dfn{sprung} if the associated macro
  9536. is executed.
  9537. @menu
  9538. * Page Location Traps::
  9539. * Diversion Traps::
  9540. * Input Line Traps::
  9541. * Blank Line Traps::
  9542. * End-of-input Traps::
  9543. @end menu
  9544. @c ---------------------------------------------------------------------
  9545. @node Page Location Traps, Diversion Traps, Traps, Traps
  9546. @subsection Page Location Traps
  9547. @cindex page location traps
  9548. @cindex traps, page location
  9549. @dfn{Page location traps} perform an action when @code{gtroff}
  9550. reaches or passes a certain vertical location on the page. Page
  9551. location traps have a variety of purposes, including:
  9552. @itemize
  9553. @item
  9554. setting headers and footers
  9555. @item
  9556. setting body text in multiple columns
  9557. @item
  9558. setting footnotes
  9559. @end itemize
  9560. @DefreqList {vpt, flag}
  9561. @DefregListEnd {.vpt}
  9562. @cindex enabling vertical position traps (@code{vpt})
  9563. @cindex vertical position traps, enabling (@code{vpt})
  9564. @cindex vertical position trap enable register (@code{.vpt})
  9565. Enable vertical position traps if @var{flag} is non-zero, or disables
  9566. them otherwise. Vertical position traps are traps set by the @code{wh}
  9567. or @code{dt} requests. Traps set by the @code{it} request are not
  9568. vertical position traps. The parameter that controls whether vertical
  9569. position traps are enabled is global. Initially vertical position traps
  9570. are enabled. The current setting of this is available in the
  9571. @code{.vpt} read-only number register.
  9572. Note that a page can't be ejected if @code{vpt} is set to zero.
  9573. @endDefreq
  9574. @Defreq {wh, dist [@Var{macro}]}
  9575. Set a page location trap. Non-negative values for @var{dist} set
  9576. the trap relative to the top of the page; negative values set
  9577. the trap relative to the bottom of the page. Default scaling
  9578. indicator is @samp{v}.
  9579. @var{macro} is the name of the macro to execute when the
  9580. trap is sprung. If @var{macro} is missing, remove the first trap
  9581. (if any) at @var{dist}.
  9582. @cindex page headers
  9583. @cindex page footers
  9584. @cindex headers
  9585. @cindex footers
  9586. The following is a simple example of how many macro packages
  9587. set headers and footers.
  9588. @Example
  9589. .de hd \" Page header
  9590. ' sp .5i
  9591. . tl 'Title''date'
  9592. ' sp .3i
  9593. ..
  9594. .
  9595. .de fo \" Page footer
  9596. ' sp 1v
  9597. . tl ''%''
  9598. ' bp
  9599. ..
  9600. .
  9601. .wh 0 hd \" trap at top of the page
  9602. .wh -1i fo \" trap one inch from bottom
  9603. @endExample
  9604. A trap at or below the bottom of the page is ignored; it can be made
  9605. active by either moving it up or increasing the page length so that the
  9606. trap is on the page.
  9607. It is possible to have more than one trap at the same location; to do so,
  9608. the traps must be defined at different locations, then moved together with
  9609. the @code{ch} request; otherwise the second trap would replace the first
  9610. one. Earlier defined traps hide later defined traps if moved to the same
  9611. position (the many empty lines caused by the @code{bp} request are omitted
  9612. in the following example):
  9613. @Example
  9614. .de a
  9615. . nop a
  9616. ..
  9617. .de b
  9618. . nop b
  9619. ..
  9620. .de c
  9621. . nop c
  9622. ..
  9623. .
  9624. .wh 1i a
  9625. .wh 2i b
  9626. .wh 3i c
  9627. .bp
  9628. @result{} a b c
  9629. @endExample
  9630. @Example
  9631. .ch b 1i
  9632. .ch c 1i
  9633. .bp
  9634. @result{} a
  9635. @endExample
  9636. @Example
  9637. .ch a 0.5i
  9638. .bp
  9639. @result{} a b
  9640. @endExample
  9641. @endDefreq
  9642. @Defreg {.t}
  9643. @cindex distance to next trap register (@code{.t})
  9644. @cindex trap, distance, register (@code{.t})
  9645. A read-only number register holding the distance to the next trap.
  9646. If there are no traps between the current position and the bottom of the
  9647. page, it contains the distance to the page bottom. In a diversion, the
  9648. distance to the page bottom is infinite (the returned value is the biggest
  9649. integer which can be represented in @code{groff}) if there are no diversion
  9650. traps.
  9651. @endDefreg
  9652. @Defreq {ch, macro [@Var{dist}]}
  9653. @cindex changing trap location (@code{ch})
  9654. @cindex trap, changing location (@code{ch})
  9655. Change the location of a trap.
  9656. The first argument is the name of the macro to be invoked at
  9657. the trap, and the second argument is the new location for the trap
  9658. (note that the parameters are specified in opposite order as in the
  9659. @code{wh} request). This is useful for building up footnotes in a
  9660. diversion to allow more space at the bottom of the page for them.
  9661. Default scaling indicator for @var{dist} is @samp{v}. If @var{dist}
  9662. is missing, the trap is removed.
  9663. @c XXX
  9664. @ignore
  9665. @Example
  9666. ... (simplified) footnote example ...
  9667. @endExample
  9668. @end ignore
  9669. @endDefreq
  9670. @Defreg {.ne}
  9671. The read-only number register @code{.ne} contains the amount of space
  9672. that was needed in the last @code{ne} request that caused a trap to be
  9673. sprung. Useful in conjunction with the @code{.trunc} register.
  9674. @xref{Page Control}, for more information.
  9675. Since the @code{.ne} register is only set by traps it doesn't make
  9676. much sense to use it outside of trap macros.
  9677. @endDefreg
  9678. @Defreg {.trunc}
  9679. @cindex @code{ne} request, and the @code{.trunc} register
  9680. @cindex truncated vertical space register (@code{.trunc})
  9681. A read-only register containing the amount of vertical space truncated
  9682. by the most recently sprung vertical position trap, or, if the trap was
  9683. sprung by an @code{ne} request, minus the amount of vertical motion
  9684. produced by the @code{ne} request. In other words, at the point a trap
  9685. is sprung, it represents the difference of what the vertical position
  9686. would have been but for the trap, and what the vertical position
  9687. actually is.
  9688. Since the @code{.trunc} register is only set by traps it doesn't make
  9689. much sense to use it outside of trap macros.
  9690. @endDefreg
  9691. @Defreg {.pe}
  9692. @cindex @code{bp} request, and traps (@code{.pe})
  9693. @cindex traps, sprung by @code{bp} request (@code{.pe})
  9694. @cindex page ejecting register (@code{.pe})
  9695. A read-only register which is set to@tie{}1 while a page is ejected with
  9696. the @code{bp} request (or by the end of input).
  9697. Outside of traps this register is always zero. In the following example,
  9698. only the second call to@tie{}@code{x} is caused by @code{bp}.
  9699. @Example
  9700. .de x
  9701. \&.pe=\\n[.pe]
  9702. .br
  9703. ..
  9704. .wh 1v x
  9705. .wh 4v x
  9706. A line.
  9707. .br
  9708. Another line.
  9709. .br
  9710. @result{} A line.
  9711. .pe=0
  9712. Another line.
  9713. .pe=1
  9714. @endExample
  9715. @endDefreg
  9716. @cindex diversions, and traps
  9717. @cindex traps, and diversions
  9718. An important fact to consider while designing macros is that diversions and
  9719. traps do not interact normally. For example, if a trap invokes a header
  9720. macro (while outputting a diversion) which tries to change the font on the
  9721. current page, the effect will not be visible before the diversion has
  9722. completely been printed (except for input protected with @code{\!} or
  9723. @code{\?}) since the data in the diversion is already formatted. In most
  9724. cases, this is not the expected behaviour.
  9725. @c ---------------------------------------------------------------------
  9726. @node Diversion Traps, Input Line Traps, Page Location Traps, Traps
  9727. @subsection Diversion Traps
  9728. @cindex diversion traps
  9729. @cindex traps, diversion
  9730. @Defreq {dt, [@Var{dist} @Var{macro}]}
  9731. @cindex @code{.t} register, and diversions
  9732. @cindex setting diversion trap (@code{dt})
  9733. @cindex diversion trap, setting (@code{dt})
  9734. @cindex trap, diversion, setting (@code{dt})
  9735. Set a trap @emph{within} a diversion.
  9736. @var{dist} is the location of the trap
  9737. (identical to the @code{wh} request; default scaling indicator is
  9738. @samp{v}) and @var{macro} is the name of the macro to be invoked.
  9739. If called without arguments, the diversion trap is removed.
  9740. Note that there exists only a single diversion trap.
  9741. The number register @code{.t} still works within diversions.
  9742. @xref{Diversions}, for more information.
  9743. @endDefreq
  9744. @c ---------------------------------------------------------------------
  9745. @node Input Line Traps, Blank Line Traps, Diversion Traps, Traps
  9746. @subsection Input Line Traps
  9747. @cindex input line traps
  9748. @cindex traps, input line
  9749. @DefreqList {it, n macro}
  9750. @DefreqItem {itc, n macro}
  9751. @cindex setting input line trap (@code{it})
  9752. @cindex input line trap, setting (@code{it})
  9753. @cindex trap, input line, setting (@code{it})
  9754. Set an input line trap.
  9755. @var{n}@tie{}is the number of lines of input which may be read before
  9756. springing the trap, @var{macro} is the macro to be invoked.
  9757. Request lines are not counted as input lines.
  9758. For example, one possible use is to have a macro which prints the
  9759. next @var{n}@tie{}lines in a bold font.
  9760. @Example
  9761. .de B
  9762. . it \\$1 B-end
  9763. . ft B
  9764. ..
  9765. .
  9766. .de B-end
  9767. . ft R
  9768. ..
  9769. @endExample
  9770. @cindex input line traps and interrupted lines (@code{itc})
  9771. @cindex interrupted lines and input line traps (@code{itc})
  9772. @cindex traps, input line, and interrupted lines (@code{itc})
  9773. @cindex lines, interrupted, and input line traps (@code{itc})
  9774. The @code{itc} request is identical
  9775. except that an interrupted text line (ending with @code{\c})
  9776. is not counted as a separate line.
  9777. Both requests are associated with the current environment
  9778. (@pxref{Environments}); switching to another environment disables the
  9779. current input trap, and going back reactivates it, restoring the number
  9780. of already processed lines.
  9781. @endDefreq
  9782. @c ---------------------------------------------------------------------
  9783. @node Blank Line Traps, End-of-input Traps, Input Line Traps, Traps
  9784. @subsection Blank Line Traps
  9785. @cindex blank line traps
  9786. @cindex traps, blank line
  9787. @Defreq {blm, macro}
  9788. @cindex blank line macro (@code{blm})
  9789. Set a blank line trap.
  9790. @code{gtroff} executes @var{macro} when it encounters a blank line in
  9791. the input file.
  9792. @endDefreq
  9793. @c ---------------------------------------------------------------------
  9794. @node End-of-input Traps, , Blank Line Traps, Traps
  9795. @subsection End-of-input Traps
  9796. @cindex end-of-input traps
  9797. @cindex traps, end-of-input
  9798. @Defreq {em, macro}
  9799. @cindex setting end-of-input trap (@code{em})
  9800. @cindex end-of-input trap, setting (@code{em})
  9801. @cindex trap, end-of-input, setting (@code{em})
  9802. @cindex end-of-input macro (@code{em})
  9803. @cindex macro, end-of-input (@code{em})
  9804. Set a trap at the end of input. @var{macro} is executed after the
  9805. last line of the input file has been processed.
  9806. For example, if the document had to have a section at the bottom of the
  9807. last page for someone to approve it, the @code{em} request could be
  9808. used.
  9809. @Example
  9810. .de approval
  9811. . ne 5v
  9812. . sp |(\\n[.t] - 6v)
  9813. . in +4i
  9814. . lc _
  9815. . br
  9816. Approved:\t\a
  9817. . sp
  9818. Date:\t\t\a
  9819. ..
  9820. .
  9821. .em approval
  9822. @endExample
  9823. @endDefreq
  9824. @c =====================================================================
  9825. @node Diversions, Environments, Traps, gtroff Reference
  9826. @section Diversions
  9827. @cindex diversions
  9828. In @code{gtroff} it is possible to @dfn{divert} text into a named
  9829. storage area. Due to the similarity to defining macros it is sometimes
  9830. said to be stored in a macro. This is used for saving text for output
  9831. at a later time, which is useful for keeping blocks of text on the same
  9832. page, footnotes, tables of contents, and indices.
  9833. @cindex top-level diversion
  9834. @cindex diversion, top-level
  9835. For orthogonality it is said that @code{gtroff} is in the @dfn{top-level
  9836. diversion} if no diversion is active (i.e., the data is diverted to the
  9837. output device).
  9838. @DefreqList {di, macro}
  9839. @DefreqListEnd {da, macro}
  9840. @cindex beginning diversion (@code{di})
  9841. @cindex diversion, beginning (@code{di})
  9842. @cindex ending diversion (@code{di})
  9843. @cindex diversion, ending (@code{di})
  9844. @cindex appending to a diversion (@code{da})
  9845. @cindex diversion, appending (@code{da})
  9846. Begin a diversion. Like the @code{de}
  9847. request, it takes an argument of a macro name to divert subsequent text
  9848. into. The @code{da} macro appends to an existing diversion.
  9849. @code{di} or @code{da} without an argument ends the diversion.
  9850. @endDefreq
  9851. @DefreqList {box, macro}
  9852. @DefreqListEnd {boxa, macro}
  9853. Begin (or appends to) a diversion like the
  9854. @code{di} and @code{da} requests.
  9855. The difference is that @code{box} and @code{boxa}
  9856. do not include a partially-filled line in the diversion.
  9857. Compare this:
  9858. @Example
  9859. Before the box.
  9860. .box xxx
  9861. In the box.
  9862. .br
  9863. .box
  9864. After the box.
  9865. .br
  9866. @result{} Before the box. After the box.
  9867. .xxx
  9868. @result{} In the box.
  9869. @endExample
  9870. @noindent
  9871. with this:
  9872. @Example
  9873. Before the diversion.
  9874. .di yyy
  9875. In the diversion.
  9876. .br
  9877. .di
  9878. After the diversion.
  9879. .br
  9880. @result{} After the diversion.
  9881. .yyy
  9882. @result{} Before the diversion. In the diversion.
  9883. @endExample
  9884. @code{box} or @code{boxa} without an argument ends the diversion.
  9885. @endDefreq
  9886. @DefregList {.z}
  9887. @DefregListEnd {.d}
  9888. @cindex @code{nl} register, and @code{.d}
  9889. @cindex nested diversions
  9890. @cindex diversion, nested
  9891. @cindex diversion name register (@code{.z})
  9892. @cindex vertical position in diversion register (@code{.d})
  9893. @cindex position, vertical, in diversion, register (@code{.d})
  9894. @cindex diversion, vertical position in, register (@code{.d})
  9895. Diversions may be nested. The read-only number register @code{.z}
  9896. contains the name of the current diversion (this is a string-valued
  9897. register). The read-only number register @code{.d} contains the current
  9898. vertical place in the diversion. If not in a diversion it is the same
  9899. as register @code{nl}.
  9900. @endDefreg
  9901. @Defreg {.h}
  9902. @cindex high-water mark register (@code{.h})
  9903. @cindex mark, high-water, register (@code{.h})
  9904. @cindex position of lowest text line (@code{.h})
  9905. @cindex text line, position of lowest (@code{.h})
  9906. The @dfn{high-water mark} on the current page. It corresponds to the
  9907. text baseline of the lowest line on the page. This is a read-only
  9908. register.
  9909. @Example
  9910. .tm .h==\n[.h], nl==\n[nl]
  9911. @result{} .h==0, nl==-1
  9912. This is a test.
  9913. .br
  9914. .sp 2
  9915. .tm .h==\n[.h], nl==\n[nl]
  9916. @result{} .h==40, nl==120
  9917. @endExample
  9918. @cindex @code{.h} register, difference to @code{nl}
  9919. @cindex @code{nl} register, difference to @code{.h}
  9920. @noindent
  9921. As can be seen in the previous example, empty lines are not considered
  9922. in the return value of the @code{.h} register.
  9923. @endDefreg
  9924. @DefregList {dn}
  9925. @DefregListEnd {dl}
  9926. @cindex @code{dn} register, and @code{da} (@code{boxa})
  9927. @cindex @code{dl} register, and @code{da} (@code{boxa})
  9928. @cindex @code{da} request, and @code{dn} (@code{dl})
  9929. @cindex @code{boxa} request, and @code{dn} (@code{dl})
  9930. After completing a diversion, the read-write number registers @code{dn}
  9931. and @code{dl} contain the vertical and horizontal size of the diversion.
  9932. Note that only the just processed lines are counted: For the computation
  9933. of @code{dn} and @code{dl}, the requests @code{da} and @code{boxa} are
  9934. handled as if @code{di} and @code{box} had been used -- lines which have
  9935. been already stored in a macro are not taken into account.
  9936. @Example
  9937. .\" Center text both horizontally & vertically
  9938. .
  9939. .\" Enclose macro definitions in .eo and .ec
  9940. .\" to avoid the doubling of the backslash
  9941. .eo
  9942. .\" macro .(c starts centering mode
  9943. .de (c
  9944. . br
  9945. . ev (c
  9946. . evc 0
  9947. . in 0
  9948. . nf
  9949. . di @@c
  9950. ..
  9951. @endExample
  9952. @Example
  9953. .\" macro .)c terminates centering mode
  9954. .de )c
  9955. . br
  9956. . ev
  9957. . di
  9958. . nr @@s (((\n[.t]u - \n[dn]u) / 2u) - 1v)
  9959. . sp \n[@@s]u
  9960. . ce 1000
  9961. . @@c
  9962. . ce 0
  9963. . sp \n[@@s]u
  9964. . br
  9965. . fi
  9966. . rr @@s
  9967. . rm @@s
  9968. . rm @@c
  9969. ..
  9970. .\" End of macro definitions, restore escape mechanism
  9971. .ec
  9972. @endExample
  9973. @endDefreg
  9974. @DefescList {\\!, , , }
  9975. @DefescListEnd {\\?, , anything, \\?}
  9976. @cindex transparent output (@code{\!}, @code{\?})
  9977. @cindex output, transparent (@code{\!}, @code{\?})
  9978. Prevent requests, macros, and escapes from being
  9979. interpreted when read into a diversion. Both escapes take the given text
  9980. and @dfn{transparently} embed it into the diversion. This is useful for
  9981. macros which shouldn't be invoked until the diverted text is actually
  9982. output.
  9983. The @code{\!} escape transparently embeds text up to
  9984. and including the end of the line.
  9985. The @code{\?} escape transparently embeds text until the next
  9986. occurrence of the @code{\?} escape. Example:
  9987. @Example
  9988. \?@var{anything}\?
  9989. @endExample
  9990. @noindent
  9991. @var{anything} may not contain newlines; use @code{\!} to embed
  9992. newlines in a diversion. The escape sequence @code{\?} is also
  9993. recognized in copy mode and turned into a single internal code; it is
  9994. this code that terminates @var{anything}. Thus the following example
  9995. prints@tie{}4.
  9996. @Example
  9997. .nr x 1
  9998. .nf
  9999. .di d
  10000. \?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
  10001. .di
  10002. .nr x 2
  10003. .di e
  10004. .d
  10005. .di
  10006. .nr x 3
  10007. .di f
  10008. .e
  10009. .di
  10010. .nr x 4
  10011. .f
  10012. @endExample
  10013. Both escapes read the data in copy mode.
  10014. @cindex @code{\!}, in top-level diversion
  10015. @cindex top-level diversion, and @code{\!}
  10016. @cindex diversion, top-level, and @code{\!}
  10017. If @code{\!} is used in the top-level diversion, its argument is
  10018. directly embedded into the @code{gtroff} intermediate output. This can
  10019. be used for example to control a postprocessor which processes the data
  10020. before it is sent to the device driver.
  10021. @cindex @code{\?}, in top-level diversion
  10022. @cindex top-level diversion, and @code{\?}
  10023. @cindex diversion, top-level, and @code{\?}
  10024. The @code{\?} escape used in the top-level diversion produces no output
  10025. at all; its argument is simply ignored.
  10026. @endDefesc
  10027. @cindex @code{\!}, and @code{output}
  10028. @cindex @code{output} request, and @code{\!}
  10029. @Defreq {output, string}
  10030. Emit @var{string} directly to the @code{gtroff} intermediate output
  10031. (subject to copy-mode interpretation); this is similar to @code{\!} used
  10032. at the top level. An initial double quote in @var{string} is stripped off
  10033. to allow initial blanks.
  10034. This request can't be used before the first page has started -- if you get
  10035. an error, simply insert @code{.br} before the @code{output} request.
  10036. Without argument, @code{output} is ignored.
  10037. Use with caution! It is normally only needed for mark-up used by a
  10038. postprocessor which does something with the output before sending it to
  10039. the output device, filtering out @var{string} again.
  10040. @endDefreq
  10041. @Defreq {asciify, div}
  10042. @cindex unformatting diversions (@code{asciify})
  10043. @cindex diversion, unformatting (@code{asciify})
  10044. @cindex @code{trin} request, and @code{asciify}
  10045. @dfn{Unformat} the diversion specified by @var{div}
  10046. in such a way that @acronym{ASCII} characters, characters translated with
  10047. the @code{trin} request, space characters, and some escape sequences that
  10048. were formatted and diverted are treated like ordinary input
  10049. characters when the diversion is reread. It can be also used for gross
  10050. hacks; for example, the following sets register@tie{}@code{n} to@tie{}1.
  10051. @Example
  10052. .tr @@.
  10053. .di x
  10054. @@nr n 1
  10055. .br
  10056. .di
  10057. .tr @@@@
  10058. .asciify x
  10059. .x
  10060. @endExample
  10061. @xref{Copy-in Mode}.
  10062. @endDefreq
  10063. @Defreq {unformat, div}
  10064. Like @code{asciify}, unformat the specified diversion.
  10065. However, @code{unformat} only unformats spaces and tabs
  10066. between words.
  10067. Unformatted tabs are treated as input tokens,
  10068. and spaces are stretchable again.
  10069. The vertical size of lines is not preserved; glyph information (font,
  10070. font size, space width, etc.)@: is retained.
  10071. @endDefreq
  10072. @c =====================================================================
  10073. @node Environments, Suppressing output, Diversions, gtroff Reference
  10074. @section Environments
  10075. @cindex environments
  10076. It happens frequently that some text should be printed in a certain
  10077. format regardless of what may be in effect at the time, for example, in
  10078. a trap invoked macro to print headers and footers. To solve this
  10079. @code{gtroff} processes text in @dfn{environments}. An
  10080. environment contains most of the parameters that control text
  10081. processing. It is possible to switch amongst these environments; by
  10082. default @code{gtroff} processes text in environment@tie{}0. The
  10083. following is the information kept in an environment.
  10084. @itemize @bullet
  10085. @item
  10086. font parameters (size, family, style, glyph height and slant, space
  10087. and sentence space size)
  10088. @item
  10089. page parameters (line length, title length, vertical spacing,
  10090. line spacing, indentation, line numbering, centering, right-justifying,
  10091. underlining, hyphenation data)
  10092. @item
  10093. fill and adjust mode
  10094. @item
  10095. tab stops, tab and leader characters, escape character,
  10096. no-break and hyphen indicators, margin character data
  10097. @item
  10098. partially collected lines
  10099. @item
  10100. input traps
  10101. @item
  10102. drawing and fill colours
  10103. @end itemize
  10104. These environments may be given arbitrary names (see @ref{Identifiers},
  10105. for more info). Old versions of @code{troff} only had environments
  10106. named @samp{0}, @samp{1}, and @samp{2}.
  10107. @DefreqList {ev, [@Var{env}]}
  10108. @DefregListEnd {.ev}
  10109. @cindex switching environments (@code{ev})
  10110. @cindex environment, switching (@code{ev})
  10111. @cindex environment number/name register (@code{.ev})
  10112. Switch to another environment. The argument @var{env} is the name of
  10113. the environment to switch to. With no argument, @code{gtroff} switches
  10114. back to the previous environment. There is no limit on the number of
  10115. named environments; they are created the first time that they are
  10116. referenced. The @code{.ev} read-only register contains the name or
  10117. number of the current environment. This is a string-valued register.
  10118. Note that a call to @code{ev} (with argument) pushes the previously
  10119. active environment onto a stack. If, say, environments @samp{foo},
  10120. @samp{bar}, and @samp{zap} are called (in that order), the first
  10121. @code{ev} request without parameter switches back to environment
  10122. @samp{bar} (which is popped off the stack), and a second call
  10123. switches back to environment @samp{foo}.
  10124. Here is an example:
  10125. @Example
  10126. .ev footnote-env
  10127. .fam N
  10128. .ps 6
  10129. .vs 8
  10130. .ll -.5i
  10131. .ev
  10132. ...
  10133. .ev footnote-env
  10134. \(dg Note the large, friendly letters.
  10135. .ev
  10136. @endExample
  10137. @endDefreq
  10138. @Defreq {evc, env}
  10139. @cindex copying environment (@code{evc})
  10140. @cindex environment, copying (@code{evc})
  10141. Copy the environment @var{env} into the current environment.
  10142. The following environment data is not copied:
  10143. @itemize @bullet
  10144. @item
  10145. Partially filled lines.
  10146. @item
  10147. The status whether the previous line was interrupted.
  10148. @item
  10149. The number of lines still to center, or to right-justify, or to underline
  10150. (with or without underlined spaces); they are set to zero.
  10151. @item
  10152. The status whether a temporary indentation is active.
  10153. @item
  10154. Input traps and its associated data.
  10155. @item
  10156. Line numbering mode is disabled; it can be reactivated with
  10157. @w{@samp{.nm +0}}.
  10158. @item
  10159. The number of consecutive hyphenated lines (set to zero).
  10160. @end itemize
  10161. @endDefreq
  10162. @DefregList {.w}
  10163. @DefregItem {.cht}
  10164. @DefregItem {.cdp}
  10165. @DefregListEnd {.csk}
  10166. @cindex environment, dimensions of last glyph (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
  10167. @cindex width, of last glyph (@code{.w})
  10168. @cindex height, of last glyph (@code{.cht})
  10169. @cindex depth, of last glyph (@code{.cdp})
  10170. @cindex skew, of last glyph (@code{.csk})
  10171. @cindex last glyph, dimensions (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
  10172. @cindex glyph, last, dimensions (@code{.w}, @code{.cht}, @code{.cdp}, @code{.csk})
  10173. The @code{\n[.w]} register contains the
  10174. width of the last glyph added to the current environment.
  10175. The @code{\n[.cht]} register contains the
  10176. height of the last glyph added to the current environment.
  10177. The @code{\n[.cdp]} register contains the
  10178. depth of the last glyph added to the current environment.
  10179. It is positive for glyphs extending below the baseline.
  10180. The @code{\n[.csk]} register contains the
  10181. @dfn{skew} (how far to the right of the glyph's center
  10182. that @code{gtroff} should place an accent)
  10183. of the last glyph added to the current environment.
  10184. @endDefreg
  10185. @Defreg {.n}
  10186. @cindex environment, previous line length (@code{.n})
  10187. @cindex line length, previous (@code{.n})
  10188. @cindex length of previous line (@code{.n})
  10189. @cindex previous line length (@code{.n})
  10190. The @code{\n[.n]} register contains the
  10191. length of the previous output line in the current environment.
  10192. @endDefreg
  10193. @c =====================================================================
  10194. @node Suppressing output, Colors, Environments, gtroff Reference
  10195. @section Suppressing output
  10196. @Defesc {\\O, , num, }
  10197. @cindex suppressing output (@code{\O})
  10198. @cindex output, suppressing (@code{\O})
  10199. Disable or enable output depending on the value of @var{num}:
  10200. @table @samp
  10201. @item \O0
  10202. Disable any glyphs from being emitted to the device driver, provided that
  10203. the escape occurs at the outer level (see @code{\O[3]} and @code{\O[4]}).
  10204. Motion is not suppressed so effectively @code{\O[0]} means @emph{pen up}.
  10205. @item \O1
  10206. Enable output of glyphs, provided that the escape occurs at the outer
  10207. level.
  10208. @end table
  10209. @vindex opminx
  10210. @vindex opminy
  10211. @vindex opmaxx
  10212. @vindex opmaxy
  10213. @code{\O0} and @code{\O1} also reset the four registers @samp{opminx},
  10214. @samp{opminy}, @samp{opmaxx}, and @samp{opmaxy} to @minus{}1.
  10215. @xref{Register Index}. These four registers mark the top left and
  10216. bottom right hand corners of a box which encompasses all written glyphs.
  10217. For example the input text:
  10218. @Example
  10219. Hello \O[0]world \O[1]this is a test.
  10220. @endExample
  10221. @noindent
  10222. produces the following output:
  10223. @Example
  10224. Hello this is a test.
  10225. @endExample
  10226. @table @samp
  10227. @item \O2
  10228. Provided that the escape occurs at the outer level, enable output of
  10229. glyphs and also write out to @code{stderr} the page number and four
  10230. registers encompassing the glyphs previously written since the last call
  10231. to @code{\O}.
  10232. @item \O3
  10233. Begin a nesting level. At start-up, @code{gtroff} is at outer level.
  10234. @item \O4
  10235. End a nesting level.
  10236. @item \O[5@var{P}@var{filename}]
  10237. This escape is @code{grohtml} specific. Provided that this escape
  10238. occurs at the outer nesting level write the @code{filename} to
  10239. @code{stderr}. The position of the image, @var{P}, must be specified
  10240. and must be one of @code{l}, @code{r}, @code{c}, or@tie{}@code{i} (left,
  10241. right, centered, inline). @var{filename} will be associated with the
  10242. production of the next inline image.
  10243. @end table
  10244. @endDefesc
  10245. @c =====================================================================
  10246. @node Colors, I/O, Suppressing output, gtroff Reference
  10247. @section Colors
  10248. @cindex colors
  10249. @DefreqList {color, [@Var{n}]}
  10250. @DefregListEnd {.color}
  10251. If @var{n} is missing or non-zero, activate colors (this is the default);
  10252. otherwise, turn it off.
  10253. The read-only number register @code{.color} is@tie{}1 if colors are active,
  10254. 0@tie{}otherwise.
  10255. Internally, @code{color} sets a global flag; it does not produce a token.
  10256. Similar to the @code{cp} request, you should use it at the beginning of
  10257. your document to control color output.
  10258. Colors can be also turned off with the @option{-c} command line option.
  10259. @endDefreq
  10260. @Defreq {defcolor, ident scheme color_components}
  10261. Define color with name @var{ident}. @var{scheme} can be one of the
  10262. following values: @code{rgb} (three components), @code{cmy} (three
  10263. components), @code{cmyk} (four components), and @code{gray} or
  10264. @code{grey} (one component).
  10265. @cindex default color
  10266. @cindex color, default
  10267. Color components can be given either as a hexadecimal string or as
  10268. positive decimal integers in the range 0--65535. A hexadecimal string
  10269. contains all color components concatenated. It must start with either
  10270. @code{#} or @code{##}; the former specifies hex values in the range
  10271. 0--255 (which are internally multiplied by@tie{}257), the latter in the
  10272. range 0--65535. Examples: @code{#FFC0CB} (pink), @code{##ffff0000ffff}
  10273. (magenta). The default color name @c{default} can't be redefined; its
  10274. value is device-specific (usually black). It is possible that the
  10275. default color for @code{\m} and @code{\M} is not identical.
  10276. @cindex @code{f} unit, and colors
  10277. @cindex unit, @code{f}, and colors
  10278. A new scaling indicator@tie{}@code{f} has been introduced which multiplies
  10279. its value by 65536; this makes it convenient to specify color components
  10280. as fractions in the range 0 to@tie{}1 (1f equals 65536u). Example:
  10281. @Example
  10282. .defcolor darkgreen rgb 0.1f 0.5f 0.2f
  10283. @endExample
  10284. Note that @code{f} is the default scaling indicator for the
  10285. @code{defcolor} request, thus the above statement is equivalent to
  10286. @Example
  10287. .defcolor darkgreen rgb 0.1 0.5 0.2
  10288. @endExample
  10289. @endDefreq
  10290. @DefreqList {gcolor, [@Var{color}]}
  10291. @DefescItem {\\m, , c, }
  10292. @DefescItem {\\m, @Lparen{}, co, }
  10293. @DefescItem {\\m, @Lbrack{}, color, @Rbrack{}}
  10294. @DefregListEnd {.m}
  10295. Set (glyph) drawing color. The following examples show how to turn the
  10296. next four words red.
  10297. @Example
  10298. .gcolor red
  10299. these are in red
  10300. .gcolor
  10301. and these words are in black.
  10302. @endExample
  10303. @Example
  10304. \m[red]these are in red\m[] and these words are in black.
  10305. @endExample
  10306. The escape @code{\m[]} returns to the previous color, as does a call to
  10307. @code{gcolor} without an argument.
  10308. @cindex drawing color name register (@code{.m})
  10309. @cindex name, drawing color, register (@code{.m})
  10310. @cindex color name, drawing, register (@code{.m})
  10311. The name of the current drawing color is available in the read-only,
  10312. string-valued number register @samp{.m}.
  10313. The drawing color is associated with the current environment
  10314. (@pxref{Environments}).
  10315. Note that @code{\m} doesn't produce an input token in @code{gtroff}.
  10316. As a consequence, it can be used in requests like @code{mc} (which
  10317. expects a single character as an argument) to change the color on
  10318. the fly:
  10319. @Example
  10320. .mc \m[red]x\m[]
  10321. @endExample
  10322. @endDefesc
  10323. @DefreqList {fcolor, [@Var{color}]}
  10324. @DefescItem {\\M, , c, }
  10325. @DefescItem {\\M, @Lparen{}, co, }
  10326. @DefescItem {\\M, @Lbrack{}, color, @Rbrack{}}
  10327. @DefregListEnd {.M}
  10328. Set fill (background) color for filled objects drawn with the
  10329. @code{\D'@dots{}'} commands.
  10330. A red ellipse can be created with the following code:
  10331. @Example
  10332. \M[red]\h'0.5i'\D'E 2i 1i'\M[]
  10333. @endExample
  10334. The escape @code{\M[]} returns to the previous fill color, as does a call to
  10335. @code{fcolor} without an argument.
  10336. @cindex background color name register (@code{.M})
  10337. @cindex name, background color, register (@code{.M})
  10338. @cindex color name, background, register (@code{.M})
  10339. @cindex fill color name register (@code{.M})
  10340. @cindex name, fill color, register (@code{.M})
  10341. @cindex color name, fill, register (@code{.M})
  10342. The name of the current fill (background) color is available in the
  10343. read-only, string-valued number register @samp{.M}.
  10344. The fill color is associated with the current environment
  10345. (@pxref{Environments}).
  10346. Note that @code{\M} doesn't produce an input token in @code{gtroff}.
  10347. @endDefesc
  10348. @c =====================================================================
  10349. @node I/O, Postprocessor Access, Colors, gtroff Reference
  10350. @section I/O
  10351. @cindex i/o
  10352. @cindex input and output requests
  10353. @cindex requests for input and output
  10354. @cindex output and input requests
  10355. @code{gtroff} has several requests for including files:
  10356. @Defreq {so, file}
  10357. @cindex including a file (@code{so})
  10358. @cindex file, inclusion (@code{so})
  10359. Read in the specified @var{file} and
  10360. includes it in place of the @code{so} request. This is quite useful for
  10361. large documents, e.g.@: keeping each chapter in a separate file.
  10362. @xref{gsoelim}, for more information.
  10363. Since @code{gtroff} replaces the @code{so} request with the contents
  10364. of @code{file}, it makes a difference whether the data is terminated with
  10365. a newline or not: Assuming that file @file{xxx} contains the word
  10366. @samp{foo} without a final newline, this
  10367. @Example
  10368. This is
  10369. .so xxx
  10370. bar
  10371. @endExample
  10372. @noindent
  10373. yields @samp{This is foobar}.
  10374. The search path for @var{file} can be controlled with the @option{-I} command
  10375. line option.
  10376. @endDefreq
  10377. @Defreq {pso, command}
  10378. Read the standard output from the specified @var{command}
  10379. and includes it in place of the @code{pso} request.
  10380. @cindex safer mode
  10381. @cindex mode, safer
  10382. @cindex unsafe mode
  10383. @cindex mode, unsafe
  10384. This request causes an error if used in safer mode (which is the default).
  10385. Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
  10386. mode.
  10387. The comment regarding a final newline for the @code{so} request is valid
  10388. for @code{pso} also.
  10389. @endDefreq
  10390. @Defreq {mso, file}
  10391. Identical to the @code{so} request except that @code{gtroff} searches for
  10392. the specified @var{file} in the same directories as macro files for the
  10393. the @option{-m} command line option. If the file name to be included
  10394. has the form @file{@var{name}.tmac} and it isn't found, @code{mso} tries
  10395. to include @file{tmac.@var{name}} and vice versa.
  10396. @endDefreq
  10397. @DefreqList {trf, file}
  10398. @DefreqListEnd {cf, file}
  10399. @cindex transparent output (@code{cf}, @code{trf})
  10400. @cindex output, transparent (@code{cf}, @code{trf})
  10401. Transparently output the contents of @var{file}. Each line is output
  10402. as if it were preceded by @code{\!}; however, the lines are not subject
  10403. to copy mode interpretation. If the file does not end with a newline,
  10404. then a newline is added (@code{trf} only). For example, to define a
  10405. macro@tie{}@code{x} containing the contents of file@tie{}@file{f}, use
  10406. @Example
  10407. .di x
  10408. .trf f
  10409. .di
  10410. @endExample
  10411. Both @code{trf} and @code{cf}, when used in a diversion,
  10412. embeds an object in the diversion which, when reread, causes the
  10413. contents of @var{file} to be transparently copied through to the
  10414. output. In @acronym{UNIX} @code{troff}, the contents of @var{file}
  10415. is immediately copied through to the output regardless of whether there
  10416. is a current diversion; this behaviour is so anomalous that it must be
  10417. considered a bug.
  10418. @cindex @code{trf} request, and invalid characters
  10419. @cindex characters, invalid for @code{trf} request
  10420. @cindex invalid characters for @code{trf} request
  10421. While @code{cf} copies the contents of @var{file} completely unprocessed,
  10422. @code{trf} disallows characters such as NUL that are not valid
  10423. @code{gtroff} input characters (@pxref{Identifiers}).
  10424. Both requests cause a line break.
  10425. @endDefreq
  10426. @Defreq {nx, [@Var{file}]}
  10427. @cindex processing next file (@code{nx})
  10428. @cindex file, processing next (@code{nx})
  10429. @cindex next file, processing (@code{nx})
  10430. Force @code{gtroff} to continue processing of
  10431. the file specified as an argument. If no argument is given, immediately
  10432. jump to the end of file.
  10433. @endDefreq
  10434. @Defreq {rd, [@Var{prompt} [@Var{arg1} @Var{arg2} @dots{}]]}
  10435. @cindex reading from standard input (@code{rd})
  10436. @cindex standard input, reading from (@code{rd})
  10437. @cindex input, standard, reading from (@code{rd})
  10438. Read from standard input, and include what is read as though it
  10439. were part of the input file. Text is read until a blank line
  10440. is encountered.
  10441. If standard input is a TTY input device (keyboard), write @var{prompt}
  10442. to standard error, followed by a colon (or send BEL for a beep if no
  10443. argument is given).
  10444. Arguments after @var{prompt} are available for the input. For example,
  10445. the line
  10446. @Example
  10447. .rd data foo bar
  10448. @endExample
  10449. with the input @w{@samp{This is \$2.}} prints
  10450. @Example
  10451. This is bar.
  10452. @endExample
  10453. @endDefreq
  10454. @cindex form letters
  10455. @cindex letters, form
  10456. Using the @code{nx} and @code{rd} requests,
  10457. it is easy to set up form letters. The form
  10458. letter template is constructed like this, putting the following lines
  10459. into a file called @file{repeat.let}:
  10460. @Example
  10461. .ce
  10462. \*(td
  10463. .sp 2
  10464. .nf
  10465. .rd
  10466. .sp
  10467. .rd
  10468. .fi
  10469. Body of letter.
  10470. .bp
  10471. .nx repeat.let
  10472. @endExample
  10473. @cindex @code{ex} request, used with @code{nx} and @code{rd}
  10474. @noindent
  10475. When this is run, a file containing the following lines should be
  10476. redirected in. Note that requests included in this file are executed
  10477. as though they were part of the form letter. The last block of input
  10478. is the @code{ex} request which tells @code{groff} to stop processing. If
  10479. this was not there, @code{groff} would not know when to stop.
  10480. @Example
  10481. Trent A. Fisher
  10482. 708 NW 19th Av., #202
  10483. Portland, OR 97209
  10484. Dear Trent,
  10485. Len Adollar
  10486. 4315 Sierra Vista
  10487. San Diego, CA 92103
  10488. Dear Mr. Adollar,
  10489. .ex
  10490. @endExample
  10491. @Defreq {pi, pipe}
  10492. Pipe the output of @code{gtroff} to the shell command(s)
  10493. specified by @var{pipe}. This request must occur before
  10494. @code{gtroff} has a chance to print anything.
  10495. @cindex safer mode
  10496. @cindex mode, safer
  10497. @cindex unsafe mode
  10498. @cindex mode, unsafe
  10499. @code{pi} causes an error if used in safer mode (which is the default).
  10500. Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
  10501. mode.
  10502. Multiple calls to @code{pi} are allowed, acting as a chain. For example,
  10503. @Example
  10504. .pi foo
  10505. .pi bar
  10506. ...
  10507. @endExample
  10508. is the same as @w{@samp{.pi foo | bar}}.
  10509. @cindex @code{groff}, and @code{pi} request
  10510. @cindex @code{pi} request, and @code{groff}
  10511. Note that the intermediate output format of @code{gtroff} is piped to
  10512. the specified commands. Consequently, calling @code{groff} without the
  10513. @option{-Z} option normally causes a fatal error.
  10514. @endDefreq
  10515. @DefreqList {sy, cmds}
  10516. @DefregListEnd {systat}
  10517. Execute the shell command(s) specified by @var{cmds}. The output is not
  10518. saved anyplace, so it is up to the user to do so.
  10519. @cindex safer mode
  10520. @cindex mode, safer
  10521. @cindex unsafe mode
  10522. @cindex mode, unsafe
  10523. This request causes an error if used in safer mode (which is the default).
  10524. Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
  10525. mode.
  10526. For example, the following code fragment introduces the current time into a
  10527. document:
  10528. @cindex time, current
  10529. @cindex current time
  10530. @pindex perl
  10531. @Example
  10532. .sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
  10533. (localtime(time))[2,1,0]' > /tmp/x\n[$$]
  10534. .so /tmp/x\n[$$]
  10535. .sy rm /tmp/x\n[$$]
  10536. \nH:\nM:\nS
  10537. @endExample
  10538. @noindent
  10539. Note that this works by having the @code{perl} script (run by @code{sy})
  10540. print out the @code{nr} requests which set the number registers
  10541. @code{H}, @code{M}, and @code{S}, and then reads those commands in with
  10542. the @code{so} request.
  10543. For most practical purposes, the number registers @code{seconds},
  10544. @code{minutes}, and @code{hours} which are initialized at start-up of
  10545. @code{gtroff} should be sufficient. Use the @code{af} request to get a
  10546. formatted output:
  10547. @Example
  10548. .af hours 00
  10549. .af minutes 00
  10550. .af seconds 00
  10551. \n[hours]:\n[minutes]:\n[seconds]
  10552. @endExample
  10553. @cindex @code{system()} return value register (@code{systat})
  10554. The @code{systat} read-write number register contains the return value
  10555. of the @code{system()} function executed by the last @code{sy} request.
  10556. @endDefreq
  10557. @DefreqList {open, stream file}
  10558. @DefreqListEnd {opena, stream file}
  10559. @cindex opening file (@code{open})
  10560. @cindex file, opening (@code{open})
  10561. @cindex appending to a file (@code{opena})
  10562. @cindex file, appending to (@code{opena})
  10563. Open the specified @var{file} for writing and
  10564. associates the specified @var{stream} with it.
  10565. The @code{opena} request is like @code{open}, but if the file exists,
  10566. append to it instead of truncating it.
  10567. @cindex safer mode
  10568. @cindex mode, safer
  10569. @cindex unsafe mode
  10570. @cindex mode, unsafe
  10571. Both @code{open} and @code{opena} cause an error if used in safer mode
  10572. (which is the default). Use @code{groff}'s or @code{troff}'s @option{-U}
  10573. option to activate unsafe mode.
  10574. @endDefreq
  10575. @DefreqList {write, stream data}
  10576. @DefreqListEnd {writec, stream data}
  10577. @cindex copy-in mode, and @code{write} requests
  10578. @cindex mode, copy-in, and @code{write} requests
  10579. @cindex writing to file (@code{write})
  10580. @cindex file, writing to (@code{write})
  10581. Write to the file associated with the specified @var{stream}.
  10582. The stream must previously have
  10583. been the subject of an open request. The remainder of the line is
  10584. interpreted as the @code{ds} request reads its second argument: A
  10585. leading @samp{"} is stripped, and it is read in copy-in mode.
  10586. The @code{writec} request is like @code{write}, but only
  10587. @code{write} appends a newline to the data.
  10588. @endDefreq
  10589. @Defreq {writem, stream xx}
  10590. @cindex @code{asciify} request, and @code{writem}
  10591. Write the contents of the macro or string @var{xx}
  10592. to the file associated with the specified @var{stream}.
  10593. @var{xx} is read in copy mode, i.e., already formatted elements are
  10594. ignored. Consequently, diversions must be unformatted with the
  10595. @code{asciify} request before calling @code{writem}. Usually, this
  10596. means a loss of information.
  10597. @endDefreq
  10598. @Defreq {close, stream}
  10599. @cindex closing file (@code{close})
  10600. @cindex file, closing (@code{close})
  10601. Close the specified @var{stream};
  10602. the stream is no longer an acceptable argument to the
  10603. @code{write} request.
  10604. Here a simple macro to write an index entry.
  10605. @Example
  10606. .open idx test.idx
  10607. .
  10608. .de IX
  10609. . write idx \\n[%] \\$*
  10610. ..
  10611. .
  10612. .IX test entry
  10613. .
  10614. .close idx
  10615. @endExample
  10616. @endDefreq
  10617. @DefescList {\\V, , e, }
  10618. @DefescItem {\\V, @Lparen{}, ev, }
  10619. @DefescListEnd {\\V, @Lbrack{}, env, @Rbrack{}}
  10620. Interpolate the contents of the specified environment variable
  10621. @var{env} (one-character name@tie{}@var{e}, two-character name @var{ev})
  10622. as returned by the function @code{getenv}. @code{\V} is interpreted
  10623. in copy-in mode.
  10624. @endDefesc
  10625. @c =====================================================================
  10626. @node Postprocessor Access, Miscellaneous, I/O, gtroff Reference
  10627. @section Postprocessor Access
  10628. @cindex postprocessor access
  10629. @cindex access of postprocessor
  10630. There are two escapes which give information directly to the
  10631. postprocessor. This is particularly useful for embedding
  10632. @sc{PostScript} into the final document.
  10633. @Defesc {\\X, ', xxx, '}
  10634. Embeds its argument into the @code{gtroff}
  10635. output preceded with @w{@samp{x X}}.
  10636. @cindex @code{\&}, in @code{\X}
  10637. @cindex @code{\)}, in @code{\X}
  10638. @cindex @code{\%}, in @code{\X}
  10639. @ifnotinfo
  10640. @cindex @code{\:}, in @code{\X}
  10641. @end ifnotinfo
  10642. @ifinfo
  10643. @cindex @code{\@r{<colon>}}, in @code{\X}
  10644. @end ifinfo
  10645. The escapes @code{\&}, @code{\)}, @code{\%}, and @code{\:} are ignored
  10646. within @code{\X}, @w{@samp{\ }} and @code{\~} are converted to single
  10647. space characters. All other escapes (except @code{\\} which produces a
  10648. backslash) cause an error.
  10649. @kindex use_charnames_in_special
  10650. @pindex DESC@r{, and @code{use_charnames_in_special}}
  10651. @cindex @code{\X}, and special characters
  10652. If the @samp{use_charnames_in_special} keyword is set in the @file{DESC}
  10653. file, special characters no longer cause an error; the name @var{xx} is
  10654. represented as @samp{\(@var{xx})} in the @w{@samp{x X}} output command.
  10655. Additionally, the backslash is represented as @code{\\}.
  10656. @samp{use_charnames_in_special} is currently used by @code{grohtml} only.
  10657. @endDefesc
  10658. @DefescList {\\Y, , n, }
  10659. @DefescItem {\\Y, @Lparen{}, nm, }
  10660. @DefescListEnd {\\Y, @Lbrack{}, name, @Rbrack{}}
  10661. This is approximately equivalent to @samp{\X'\*[@var{name}]'}
  10662. (one-character name@tie{}@var{n}, two-character name @var{nm}).
  10663. However, the contents of the string or macro @var{name} are not
  10664. interpreted; also it is permitted for @var{name} to have been defined
  10665. as a macro and thus contain newlines (it is not permitted for the
  10666. argument to @code{\X} to contain newlines). The inclusion of
  10667. newlines requires an extension to the @acronym{UNIX} @code{troff}
  10668. output format, and confuses drivers that do not know about this
  10669. extension (@pxref{Device Control Commands}).
  10670. @endDefesc
  10671. @xref{Output Devices}.
  10672. @c =====================================================================
  10673. @node Miscellaneous, Gtroff Internals, Postprocessor Access, gtroff Reference
  10674. @section Miscellaneous
  10675. This section documents parts of @code{gtroff} which cannot (yet) be
  10676. categorized elsewhere in this manual.
  10677. @Defreq {nm, [@Var{start} [@Var{inc} [@Var{space} [@Var{indent}]]]]}
  10678. @cindex printing line numbers (@code{nm})
  10679. @cindex line numbers, printing (@code{nm})
  10680. @cindex numbers, line, printing (@code{nm})
  10681. Print line numbers.
  10682. @var{start} is the line number of the @emph{next}
  10683. output line. @var{inc} indicates which line numbers are printed.
  10684. For example, the value@tie{}5 means to emit only line numbers which
  10685. are multiples of@tie{}5; this defaults to@tie{}1. @var{space} is the
  10686. space to be left between the number and the text; this defaults to
  10687. one digit space. The fourth argument is the indentation of the line
  10688. numbers, defaulting to zero. Both @var{space} and @var{indent} are
  10689. given as multiples of digit spaces; they can be negative also.
  10690. Without any arguments, line numbers are turned off.
  10691. @code{gtroff} reserves three digit spaces for the line number (which is
  10692. printed right-justified) plus the amount given by @var{indent}; the
  10693. output lines are concatenated to the line numbers, separated by
  10694. @var{space}, and @emph{without} reducing the line length. Depending
  10695. on the value of the horizontal page offset (as set with the
  10696. @code{po} request), line numbers which are longer than the reserved
  10697. space stick out to the left, or the whole line is moved to the right.
  10698. Parameters corresponding to missing arguments are not changed; any
  10699. non-digit argument (to be more precise, any argument starting with a
  10700. character valid as a delimiter for identifiers) is also treated as
  10701. missing.
  10702. If line numbering has been disabled with a call to @code{nm} without
  10703. an argument, it can be reactivated with @samp{.nm +0}, using the
  10704. previously active line numbering parameters.
  10705. The parameters of @code{nm} are associated with the current environment
  10706. (@pxref{Environments}). The current output line number is available
  10707. in the number register @code{ln}.
  10708. @Example
  10709. .po 1m
  10710. .ll 2i
  10711. This test shows how line numbering works with groff.
  10712. .nm 999
  10713. This test shows how line numbering works with groff.
  10714. .br
  10715. .nm xxx 3 2
  10716. .ll -\w'0'u
  10717. This test shows how line numbering works with groff.
  10718. .nn 2
  10719. This test shows how line numbering works with groff.
  10720. @endExample
  10721. @noindent
  10722. And here the result:
  10723. @Example
  10724. This test shows how
  10725. line numbering works
  10726. 999 with groff. This
  10727. 1000 test shows how line
  10728. 1001 numbering works with
  10729. 1002 groff.
  10730. This test shows how
  10731. line numbering
  10732. works with groff.
  10733. This test shows how
  10734. 1005 line numbering
  10735. works with groff.
  10736. @endExample
  10737. @endDefreq
  10738. @Defreq {nn, [@Var{skip}]}
  10739. Temporarily turn off line numbering. The argument is the number
  10740. of lines not to be numbered; this defaults to@tie{}1.
  10741. @endDefreq
  10742. @Defreq {mc, glyph [@Var{dist}]}
  10743. @cindex margin glyph (@code{mc})
  10744. @cindex glyph, for margins (@code{mc})
  10745. Print a @dfn{margin character} to the right of the
  10746. text.@footnote{@dfn{Margin character} is a misnomer since it is an
  10747. output glyph.} The first argument is the glyph to be
  10748. printed. The second argument is the distance away from the right
  10749. margin. If missing, the previously set value is used; default is
  10750. 10@dmn{pt}). For text lines that are too long (that is, longer than
  10751. the text length plus @var{dist}), the margin character is directly
  10752. appended to the lines.
  10753. With no arguments the margin character is turned off.
  10754. If this occurs before a break, no margin character is printed.
  10755. For compatibility with @acronym{AT&T} @code{troff}, a call to @code{mc}
  10756. to set the margin character can't be undone immediately; at least one
  10757. line gets a margin character. Thus
  10758. @Example
  10759. .ll 1i
  10760. .mc \[br]
  10761. .mc
  10762. xxx
  10763. .br
  10764. xxx
  10765. @endExample
  10766. @noindent
  10767. produces
  10768. @Example
  10769. xxx |
  10770. xxx
  10771. @endExample
  10772. @cindex @code{tl} request, and @code{mc}
  10773. For empty lines and lines produced by the @code{tl} request no margin
  10774. character is emitted.
  10775. The margin character is associated with the current environment
  10776. (@pxref{Environments}).
  10777. @pindex nrchbar
  10778. @pindex changebar
  10779. This is quite useful for indicating text that has changed, and, in fact,
  10780. there are programs available for doing this (they are called
  10781. @code{nrchbar} and @code{changebar} and can be found in any
  10782. @samp{comp.sources.unix} archive).
  10783. @Example
  10784. .ll 3i
  10785. .mc |
  10786. This paragraph is highlighted with a margin
  10787. character.
  10788. .sp
  10789. Note that vertical space isn't marked.
  10790. .br
  10791. \&
  10792. .br
  10793. But we can fake it with `\&'.
  10794. @endExample
  10795. Result:
  10796. @Example
  10797. This paragraph is highlighted |
  10798. with a margin character. |
  10799. Note that vertical space isn't |
  10800. marked. |
  10801. |
  10802. But we can fake it with `\&'. |
  10803. @endExample
  10804. @endDefreq
  10805. @DefreqList {psbb, filename}
  10806. @DefregItem {llx}
  10807. @DefregItem {lly}
  10808. @DefregItem {urx}
  10809. @DefregListEnd {ury}
  10810. @cindex PostScript, bounding box
  10811. @cindex bounding box
  10812. Retrieve the bounding box of the PostScript image
  10813. found in @var{filename}.
  10814. The file must conform to
  10815. Adobe's @dfn{Document Structuring Conventions} (DSC);
  10816. the command searches for a @code{%%BoundingBox} comment
  10817. and extracts the bounding box values into the number registers
  10818. @code{llx}, @code{lly}, @code{urx}, and @code{ury}.
  10819. If an error occurs (for example, @code{psbb} cannot find
  10820. the @code{%%BoundingBox} comment),
  10821. it sets the four number registers to zero.
  10822. The search path for @var{filename} can be controlled with the @option{-I}
  10823. command line option.
  10824. @endDefreq
  10825. @c =====================================================================
  10826. @node Gtroff Internals, Debugging, Miscellaneous, gtroff Reference
  10827. @section @code{gtroff} Internals
  10828. @cindex input token
  10829. @cindex token, input
  10830. @cindex output node
  10831. @cindex node, output
  10832. @code{gtroff} processes input in three steps. One or more input
  10833. characters are converted to an @dfn{input token}.@footnote{Except the
  10834. escapes @code{\f}, @code{\F}, @code{\H}, @code{\m}, @code{\M}, @code{\R},
  10835. @code{\s}, and @code{\S} which are processed immediately if not in
  10836. copy-in mode.} Then, one or more input tokens are converted to an
  10837. @dfn{output node}. Finally, output nodes are converted to the
  10838. intermediate output language understood by all output devices.
  10839. Actually, before step one happens, @code{gtroff} converts certain
  10840. escape sequences into reserved input characters (not accessible by
  10841. the user); such reserved characters are used for other internal
  10842. processing also -- this is the very reason why not all characters
  10843. are valid input. @xref{Identifiers}, for more on this topic.
  10844. For example, the input string @samp{fi\[:u]} is converted into a
  10845. character token @samp{f}, a character token @samp{i}, and a special
  10846. token @samp{:u} (representing u@tie{}umlaut). Later on, the character
  10847. tokens @samp{f} and @samp{i} are merged to a single output node
  10848. representing the ligature glyph @samp{fi} (provided the current font
  10849. has a glyph for this ligature); the same happens with @samp{:u}. All
  10850. output glyph nodes are `processed' which means that they are invariably
  10851. associated with a given font, font size, advance width, etc. During
  10852. the formatting process, @code{gtroff} itself adds various nodes to
  10853. control the data flow.
  10854. Macros, diversions, and strings collect elements in two chained lists:
  10855. a list of input tokens which have been passed unprocessed, and a list
  10856. of output nodes. Consider the following the diversion.
  10857. @Example
  10858. .di xxx
  10859. a
  10860. \!b
  10861. c
  10862. .br
  10863. .di
  10864. @endExample
  10865. @noindent
  10866. It contains these elements.
  10867. @multitable {@i{vertical size node}} {token list} {element number}
  10868. @item node list @tab token list @tab element number
  10869. @item @i{line start node} @tab --- @tab 1
  10870. @item @i{glyph node @code{a}} @tab --- @tab 2
  10871. @item @i{word space node} @tab --- @tab 3
  10872. @item --- @tab @code{b} @tab 4
  10873. @item --- @tab @code{\n} @tab 5
  10874. @item @i{glyph node @code{c}} @tab --- @tab 6
  10875. @item @i{vertical size node} @tab --- @tab 7
  10876. @item @i{vertical size node} @tab --- @tab 8
  10877. @item --- @tab @code{\n} @tab 9
  10878. @end multitable
  10879. @cindex @code{\v}, internal representation
  10880. @noindent
  10881. Elements 1, 7, and@tie{}8 are inserted by @code{gtroff}; the latter two
  10882. (which are always present) specify the vertical extent of the last
  10883. line, possibly modified by @code{\x}. The @code{br} request finishes
  10884. the current partial line, inserting a newline input token which is
  10885. subsequently converted to a space when the diversion is reread. Note
  10886. that the word space node has a fixed width which isn't stretchable
  10887. anymore. To convert horizontal space nodes back to input tokens, use
  10888. the @code{unformat} request.
  10889. Macros only contain elements in the token list (and the node list is
  10890. empty); diversions and strings can contain elements in both lists.
  10891. Note that the @code{chop} request simply reduces the number of elements in a
  10892. macro, string, or diversion by one. Exceptions are @dfn{compatibility save}
  10893. and @dfn{compatibility ignore} input tokens which are ignored. The
  10894. @code{substring} request also ignores those input tokens.
  10895. Some requests like @code{tr} or @code{cflags} work on glyph
  10896. identifiers only; this means that the associated glyph can be changed
  10897. without destroying this association. This can be very helpful for
  10898. substituting glyphs. In the following example, we assume that
  10899. glyph @samp{foo} isn't available by default, so we provide a
  10900. substitution using the @code{fchar} request and map it to input
  10901. character @samp{x}.
  10902. @Example
  10903. .fchar \[foo] foo
  10904. .tr x \[foo]
  10905. @endExample
  10906. @noindent
  10907. Now let us assume that we install an additional special font
  10908. @samp{bar} which has glyph @samp{foo}.
  10909. @Example
  10910. .special bar
  10911. .rchar \[foo]
  10912. @endExample
  10913. @noindent
  10914. Since glyphs defined with @code{fchar} are searched before glyphs
  10915. in special fonts, we must call @code{rchar} to remove the definition
  10916. of the fallback glyph. Anyway, the translation is still active;
  10917. @samp{x} now maps to the real glyph @samp{foo}.
  10918. @cindex compatibility mode, and parameters
  10919. @cindex mode, compatibility, and parameters
  10920. @cindex arguments, and compatibility mode
  10921. @cindex parameters, and compatibility mode
  10922. @cindex macro arguments, and compatibility mode
  10923. @cindex request arguments, and compatibility mode
  10924. Macro and request arguments preserve the compatibility mode:
  10925. @Example
  10926. .cp 1 \" switch to compatibility mode
  10927. .de xx
  10928. \\$1
  10929. ..
  10930. .cp 0 \" switch compatibility mode off
  10931. .xx caf\['e]
  10932. @result{} café
  10933. @endExample
  10934. @noindent
  10935. Since compatibility mode is on while @code{de} is called, the macro
  10936. @code{xx} activates compatibility mode while executing. Argument
  10937. @code{$1} can still be handled properly because it inherits the
  10938. compatibility mode status which was active at the point where @code{xx}
  10939. is called.
  10940. After expansion of the parameters, the compatibility save and restore
  10941. tokens are removed.
  10942. @c =====================================================================
  10943. @node Debugging, Implementation Differences, Gtroff Internals, gtroff Reference
  10944. @section Debugging
  10945. @cindex debugging
  10946. @code{gtroff} is not easy to debug, but there are some useful features
  10947. and strategies for debugging.
  10948. @Defreq {lf, line [@Var{filename}]}
  10949. @pindex soelim
  10950. @cindex multi-file documents
  10951. @cindex documents, multi-file
  10952. @cindex setting input line number (@code{lf})
  10953. @cindex input line number, setting (@code{lf})
  10954. @cindex number, input line, setting (@code{lf})
  10955. Change the line number and optionally the file name @code{gtroff} shall
  10956. use for error and warning messages. @var{line} is the input line number
  10957. of the @emph{next} line.
  10958. Without argument, the request is ignored.
  10959. This is a debugging aid for documents which are split into many files,
  10960. then put together with @code{soelim} and other preprocessors. Usually,
  10961. it isn't invoked manually.
  10962. Note that other @code{troff} implementations (including the original
  10963. @acronym{AT&T} version) handle @code{lf} differently. For them,
  10964. @var{line} changes the line number of the @emph{current} line.
  10965. @endDefreq
  10966. @DefreqList {tm, string}
  10967. @DefreqItem {tm1, string}
  10968. @DefreqListEnd {tmc, string}
  10969. @cindex printing to stderr (@code{tm}, @code{tm1}, @code{tmc})
  10970. @cindex stderr, printing to (@code{tm}, @code{tm1}, @code{tmc})
  10971. Send @var{string} to the standard error output;
  10972. this is very useful for printing debugging messages among other things.
  10973. @var{string} is read in copy mode.
  10974. The @code{tm} request ignores leading spaces of @var{string}; @code{tm1}
  10975. handles its argument similar to the @code{ds} request: a leading double
  10976. quote in @var{string} is stripped to allow initial blanks.
  10977. The @code{tmc} request is similar to @code{tm1} but does
  10978. not append a newline (as is done in @code{tm} and @code{tm1}).
  10979. @endDefreq
  10980. @Defreq {ab, [@Var{string}]}
  10981. @cindex aborting (@code{ab})
  10982. Similar to the @code{tm} request, except that
  10983. it causes @code{gtroff} to stop processing. With no argument it
  10984. prints @samp{User Abort.} to standard error.
  10985. @endDefreq
  10986. @Defreq {ex, }
  10987. @cindex @code{ex} request, use in debugging
  10988. @cindex exiting (@code{ex})
  10989. The @code{ex} request also causes @code{gtroff} to stop processing;
  10990. see also @ref{I/O}.
  10991. @endDefreq
  10992. When doing something involved it is useful to leave the debugging
  10993. statements in the code and have them turned on by a command line flag.
  10994. @Example
  10995. .if \n(DB .tm debugging output
  10996. @endExample
  10997. @noindent
  10998. To activate these statements say
  10999. @Example
  11000. groff -rDB=1 file
  11001. @endExample
  11002. If it is known in advance that there will be many errors and no useful
  11003. output, @code{gtroff} can be forced to suppress formatted output with
  11004. the @option{-z} flag.
  11005. @Defreq {pm, }
  11006. @cindex dumping symbol table (@code{pm})
  11007. @cindex symbol table, dumping (@code{pm})
  11008. Print the entire symbol table on @code{stderr}. Names of all defined
  11009. macros, strings, and diversions are print together with their size in
  11010. bytes. Since @code{gtroff} sometimes adds nodes by itself, the
  11011. returned size can be larger than expected.
  11012. This request differs from @acronym{UNIX} @code{troff}: @code{gtroff}
  11013. reports the sizes of diversions, ignores an additional argument to
  11014. print only the total of the sizes, and the size isn't returned in
  11015. blocks of 128 characters.
  11016. @endDefreq
  11017. @Defreq {pnr, }
  11018. @cindex dumping number registers (@code{pnr})
  11019. @cindex number registers, dumping (@code{pnr})
  11020. Print the names and contents of all
  11021. currently defined number registers on @code{stderr}.
  11022. @endDefreq
  11023. @Defreq {ptr, }
  11024. @cindex dumping traps (@code{ptr})
  11025. @cindex traps, dumping (@code{ptr})
  11026. Print the names and positions of all traps
  11027. (not including input line traps and diversion traps) on @code{stderr}.
  11028. Empty slots in the page trap list are printed as well, because they can
  11029. affect the priority of subsequently planted traps.
  11030. @endDefreq
  11031. @Defreq {fl, }
  11032. @cindex flush output (@code{fl})
  11033. @cindex output, flush (@code{fl})
  11034. @cindex interactive use of @code{gtroff}
  11035. @cindex @code{gtroff}, interactive use
  11036. Instruct @code{gtroff} to flush its output immediately. The intent
  11037. is for interactive use, but this behaviour is currently not
  11038. implemented in @code{gtroff}. Contrary to @acronym{UNIX} @code{troff},
  11039. TTY output is sent to a device driver also (@code{grotty}), making it
  11040. non-trivial to communicate interactively.
  11041. This request causes a line break.
  11042. @endDefreq
  11043. @Defreq {backtrace, }
  11044. @cindex backtrace of input stack (@code{backtrace})
  11045. @cindex input stack, backtrace (@code{backtrace})
  11046. Print a backtrace of the input stack to the standard error stream.
  11047. Consider the following in file @file{test}:
  11048. @Example
  11049. .de xxx
  11050. . backtrace
  11051. ..
  11052. .de yyy
  11053. . xxx
  11054. ..
  11055. .
  11056. .yyy
  11057. @endExample
  11058. @noindent
  11059. On execution, @code{gtroff} prints the following:
  11060. @Example
  11061. test:2: backtrace: macro `xxx'
  11062. test:5: backtrace: macro `yyy'
  11063. test:8: backtrace: file `test'
  11064. @endExample
  11065. The option @option{-b} of @code{gtroff} internally calls a variant of
  11066. this request on each error and warning.
  11067. @endDefreq
  11068. @Defreg {slimit}
  11069. @cindex input stack, setting limit
  11070. Use the @code{slimit} number register
  11071. to set the maximum number of objects on the input stack.
  11072. If @code{slimit} is less than or equal to@tie{}0,
  11073. there is no limit set.
  11074. With no limit, a buggy recursive macro can exhaust virtual memory.
  11075. The default value is 1000; this is a compile-time constant.
  11076. @endDefreg
  11077. @Defreq {warnscale, si}
  11078. Set the scaling indicator used in warnings to @var{si}. Valid values for
  11079. @var{si} are @samp{u}, @samp{i}, @samp{c}, @samp{p}, and @samp{P}. At
  11080. startup, it is set to @samp{i}.
  11081. @endDefreq
  11082. @Defreq {spreadwarn, [@Var{limit}]}
  11083. Make @code{gtroff} emit a warning if the additional space inserted for
  11084. each space between words in an output line is larger or equal to
  11085. @var{limit}. A negative value is changed to zero; no argument toggles the
  11086. warning on and off without changing @var{limit}. The default scaling
  11087. indicator is @samp{m}. At startup, @code{spreadwarn} is deactivated, and
  11088. @var{limit} is set to 3@dmn{m}.
  11089. For example,
  11090. @Example
  11091. .spreadwarn 0.2m
  11092. @endExample
  11093. @noindent
  11094. will cause a warning if @code{gtroff} must add 0.2@dmn{m} or more for each
  11095. interword space in a line.
  11096. This request is active only if text is justified to both margins (using
  11097. @w{@samp{.ad b}}).
  11098. @endDefreq
  11099. @cindex warnings
  11100. @code{gtroff} has command line options for printing out more warnings
  11101. (@option{-w}) and for printing backtraces (@option{-b}) when a warning
  11102. or an error occurs. The most verbose level of warnings is @option{-ww}.
  11103. @DefreqList {warn, [@Var{flags}]}
  11104. @DefregListEnd {.warn}
  11105. @cindex level of warnings (@code{warn})
  11106. @cindex warnings, level (@code{warn})
  11107. Control the level of warnings checked for. The @var{flags} are the sum
  11108. of the numbers associated with each warning that is to be enabled; all
  11109. other warnings are disabled. The number associated with each warning is
  11110. listed below. For example, @w{@code{.warn 0}} disables all warnings,
  11111. and @w{@code{.warn 1}} disables all warnings except that about missing
  11112. glyphs. If no argument is given, all warnings are enabled.
  11113. The read-only number register @code{.warn} contains the current warning
  11114. level.
  11115. @endDefreq
  11116. @menu
  11117. * Warnings::
  11118. @end menu
  11119. @c ---------------------------------------------------------------------
  11120. @node Warnings, , Debugging, Debugging
  11121. @subsection Warnings
  11122. @cindex warnings
  11123. The warnings that can be given to @code{gtroff} are divided into the
  11124. following categories. The name associated with each warning is used by
  11125. the @option{-w} and @option{-W} options; the number is used by the
  11126. @code{warn} request and by the @code{.warn} register.
  11127. @table @samp
  11128. @item char
  11129. @itemx 1
  11130. Non-existent glyphs.@footnote{@code{char} is a misnomer since it reports
  11131. missing glyphs -- there aren't missing input characters, only invalid
  11132. ones.} This is enabled by default.
  11133. @item number
  11134. @itemx 2
  11135. Invalid numeric expressions. This is enabled by default.
  11136. @xref{Expressions}.
  11137. @item break
  11138. @itemx 4
  11139. @cindex fill mode
  11140. @cindex mode, fill
  11141. In fill mode, lines which could not be broken so that their length was
  11142. less than the line length. This is enabled by default.
  11143. @item delim
  11144. @itemx 8
  11145. Missing or mismatched closing delimiters.
  11146. @item el
  11147. @itemx 16
  11148. @cindex @code{ie} request, and warnings
  11149. @cindex @code{el} request, and warnings
  11150. Use of the @code{el} request with no matching @code{ie} request.
  11151. @xref{if-else}.
  11152. @item scale
  11153. @itemx 32
  11154. Meaningless scaling indicators.
  11155. @item range
  11156. @itemx 64
  11157. Out of range arguments.
  11158. @item syntax
  11159. @itemx 128
  11160. Dubious syntax in numeric expressions.
  11161. @item di
  11162. @itemx 256
  11163. @cindex @code{di} request, and warnings
  11164. @cindex @code{da} request, and warnings
  11165. Use of @code{di} or @code{da} without an argument when there is no
  11166. current diversion.
  11167. @item mac
  11168. @itemx 512
  11169. @cindex @code{de}, @code{de1}, @code{dei} requests, and warnings
  11170. @cindex @code{am}, @code{am1}, @code{ami} requests, and warnings
  11171. @cindex @code{ds}, @code{ds1} requests, and warnings
  11172. @cindex @code{as}, @code{as1} requests, and warnings
  11173. @cindex @code{di} request, and warnings
  11174. @cindex @code{da} request, and warnings
  11175. @cindex @code{box}, @code{boxa} requests, and warnings
  11176. @cindex @code{\*}, and warnings
  11177. Use of undefined strings, macros and diversions. When an undefined
  11178. string, macro, or diversion is used, that string is automatically
  11179. defined as empty. So, in most cases, at most one warning is given
  11180. for each name.
  11181. @item reg
  11182. @itemx 1024
  11183. @cindex @code{nr} request, and warnings
  11184. @cindex @code{\R}, and warnings
  11185. @cindex @code{\n}, and warnings
  11186. Use of undefined number registers. When an undefined number register is
  11187. used, that register is automatically defined to have a value of@tie{}0.
  11188. So, in most cases, at most one warning is given for use of a particular
  11189. name.
  11190. @item tab
  11191. @itemx 2048
  11192. @cindex @code{\t}, and warnings
  11193. Use of a tab character where a number was expected.
  11194. @item right-brace
  11195. @itemx 4096
  11196. @cindex @code{\@}}, and warnings
  11197. Use of @code{\@}} where a number was expected.
  11198. @item missing
  11199. @itemx 8192
  11200. Requests that are missing non-optional arguments.
  11201. @item input
  11202. @itemx 16384
  11203. Invalid input characters.
  11204. @item escape
  11205. @itemx 32768
  11206. Unrecognized escape sequences. When an unrecognized escape sequence
  11207. @code{\@var{X}} is encountered, the escape character is ignored, and
  11208. @var{X} is printed.
  11209. @item space
  11210. @itemx 65536
  11211. @cindex compatibility mode
  11212. Missing space between a request or macro and its argument. This warning
  11213. is given when an undefined name longer than two characters is
  11214. encountered, and the first two characters of the name make a defined
  11215. name. The request or macro is not invoked. When this warning is
  11216. given, no macro is automatically defined. This is enabled by default.
  11217. This warning never occurs in compatibility mode.
  11218. @item font
  11219. @itemx 131072
  11220. Non-existent fonts. This is enabled by default.
  11221. @item ig
  11222. @itemx 262144
  11223. Invalid escapes in text ignored with the @code{ig} request. These are
  11224. conditions that are errors when they do not occur in ignored text.
  11225. @item color
  11226. @itemx 524288
  11227. Color related warnings.
  11228. @item all
  11229. All warnings except @samp{di}, @samp{mac} and @samp{reg}. It is
  11230. intended that this covers all warnings that are useful with traditional
  11231. macro packages.
  11232. @item w
  11233. All warnings.
  11234. @end table
  11235. @c =====================================================================
  11236. @node Implementation Differences, , Debugging, gtroff Reference
  11237. @section Implementation Differences
  11238. @cindex implementation differences
  11239. @cindex differences in implementation
  11240. @cindex incompatibilities with @acronym{AT&T} @code{troff}
  11241. @cindex compatibility mode
  11242. @cindex mode, compatibility
  11243. GNU @code{troff} has a number of features which cause incompatibilities
  11244. with documents written with old versions of @code{troff}.
  11245. @cindex long names
  11246. @cindex names, long
  11247. Long names cause some incompatibilities. @acronym{UNIX} @code{troff}
  11248. interprets
  11249. @Example
  11250. .dsabcd
  11251. @endExample
  11252. @cindex @code{\*}, incompatibilities with @acronym{AT&T} @code{troff}
  11253. @cindex @code{\n}, incompatibilities with @acronym{AT&T} @code{troff}
  11254. @noindent
  11255. as defining a string @samp{ab} with contents @samp{cd}. Normally, GNU
  11256. @code{troff} interprets this as a call of a macro named
  11257. @code{dsabcd}. Also @acronym{UNIX} @code{troff} interprets
  11258. @code{\*[} or @code{\n[} as references to a string or number register
  11259. called @samp{[}. In GNU @code{troff}, however, this is normally
  11260. interpreted as the start of a long name. In compatibility mode GNU
  11261. @code{troff} interprets long names in the traditional way
  11262. (which means that they are not recognized as names).
  11263. @DefreqList {cp, [@Var{n}]}
  11264. @DefreqItem {do, cmd}
  11265. @DefregListEnd {.C}
  11266. If @var{n} is missing or non-zero, turn on compatibility mode;
  11267. otherwise, turn it off.
  11268. The read-only number register @code{.C} is@tie{}1 if compatibility mode is
  11269. on, 0@tie{}otherwise.
  11270. Compatibility mode can be also turned on with the @option{-C} command line
  11271. option.
  11272. The @code{do} request turns off compatibility mode
  11273. while executing its arguments as a @code{gtroff} command.
  11274. @Example
  11275. .do fam T
  11276. @endExample
  11277. @noindent
  11278. executes the @code{fam} request when compatibility mode
  11279. is enabled.
  11280. @code{gtroff} restores the previous compatibility setting
  11281. before interpreting any files sourced by the @var{cmd}.
  11282. @endDefreq
  11283. @cindex input level in delimited arguments
  11284. @cindex delimited arguments, incompatibilities with @acronym{AT&T} @code{troff}
  11285. Two other features are controlled by @option{-C}. If not in
  11286. compatibility mode, GNU @code{troff} preserves the input level in
  11287. delimited arguments:
  11288. @Example
  11289. .ds xx '
  11290. \w'abc\*(xxdef'
  11291. @endExample
  11292. @noindent
  11293. In compatibility mode, the string @samp{72def'} is returned; without
  11294. @option{-C} the resulting string is @samp{168} (assuming a TTY output
  11295. device).
  11296. @cindex @code{\f}, incompatibilities with @acronym{AT&T} @code{troff}
  11297. @cindex @code{\H}, incompatibilities with @acronym{AT&T} @code{troff}
  11298. @cindex @code{\s}, incompatibilities with @acronym{AT&T} @code{troff}
  11299. @cindex @code{\S}, incompatibilities with @acronym{AT&T} @code{troff}
  11300. Finally, the escapes @code{\f}, @code{\H}, @code{\m}, @code{\M},
  11301. @code{\R}, @code{\s}, and @code{\S} are transparent for recognizing the
  11302. beginning of a line only in compatibility mode (this is a rather obscure
  11303. feature). For example, the code
  11304. @Example
  11305. .de xx
  11306. Hallo!
  11307. ..
  11308. \fB.xx\fP
  11309. @endExample
  11310. @noindent
  11311. prints @samp{Hallo!} in bold face if in compatibility mode, and
  11312. @samp{.xx} in bold face otherwise.
  11313. @cindex @code{\A}, incompatibilities with @acronym{AT&T} @code{troff}
  11314. @cindex @code{\|}, incompatibilities with @acronym{AT&T} @code{troff}
  11315. @cindex @code{\^}, incompatibilities with @acronym{AT&T} @code{troff}
  11316. @cindex @code{\&}, incompatibilities with @acronym{AT&T} @code{troff}
  11317. @cindex @code{\@{}, incompatibilities with @acronym{AT&T} @code{troff}
  11318. @cindex @code{\@}}, incompatibilities with @acronym{AT&T} @code{troff}
  11319. @cindex @code{\@key{SP}}, incompatibilities with @acronym{AT&T} @code{troff}
  11320. @cindex @code{\'}, incompatibilities with @acronym{AT&T} @code{troff}
  11321. @cindex @code{\`}, incompatibilities with @acronym{AT&T} @code{troff}
  11322. @cindex @code{\-}, incompatibilities with @acronym{AT&T} @code{troff}
  11323. @cindex @code{\_}, incompatibilities with @acronym{AT&T} @code{troff}
  11324. @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
  11325. @cindex @code{\%}, incompatibilities with @acronym{AT&T} @code{troff}
  11326. @cindex @code{\c}, incompatibilities with @acronym{AT&T} @code{troff}
  11327. GNU @code{troff} does not allow the use of the escape sequences
  11328. @code{\|}, @code{\^}, @code{\&}, @code{\@{}, @code{\@}},
  11329. @code{\@key{SP}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
  11330. @code{\%}, and @code{\c} in names of strings, macros, diversions, number
  11331. registers, fonts or environments; @acronym{UNIX} @code{troff} does. The
  11332. @code{\A} escape sequence (@pxref{Identifiers}) may be helpful in
  11333. avoiding use of these escape sequences in names.
  11334. @cindex fractional point sizes
  11335. @cindex fractional type sizes
  11336. @cindex point sizes, fractional
  11337. @cindex type sizes, fractional
  11338. @cindex sizes, fractional
  11339. @cindex @code{ps} request, incompatibilities with @acronym{AT&T} @code{troff}
  11340. Fractional point sizes cause one noteworthy incompatibility. In
  11341. @acronym{UNIX} @code{troff} the @code{ps} request ignores scale
  11342. indicators and thus
  11343. @Example
  11344. .ps 10u
  11345. @endExample
  11346. @noindent
  11347. sets the point size to 10@tie{}points, whereas in GNU @code{troff} it
  11348. sets the point size to 10@tie{}scaled points. @xref{Fractional Type
  11349. Sizes}, for more information.
  11350. @cindex @code{bd} request, incompatibilities with @acronym{AT&T} @code{troff}
  11351. @cindex @code{cs} request, incompatibilities with @acronym{AT&T} @code{troff}
  11352. @cindex @code{tr} request, incompatibilities with @acronym{AT&T} @code{troff}
  11353. @cindex @code{fp} request, incompatibilities with @acronym{AT&T} @code{troff}
  11354. @cindex input characters and output glyphs, compatibility with @acronym{AT&T} @code{troff}
  11355. @cindex output glyphs, and input characters,compatibility with @acronym{AT&T} @code{troff}
  11356. @cindex characters, input, and output glyphs, compatibility with @acronym{AT&T} @code{troff}
  11357. @cindex glyphs, output, and input characters, compatibility with @acronym{AT&T} @code{troff}
  11358. In GNU @code{troff} there is a fundamental difference between
  11359. (unformatted) input characters and (formatted) output glyphs.
  11360. Everything that affects how a glyph is output is stored
  11361. with the glyph node; once a glyph node has been constructed it is
  11362. unaffected by any subsequent requests that are executed, including
  11363. @code{bd}, @code{cs}, @code{tkf}, @code{tr}, or @code{fp} requests.
  11364. Normally glyphs are constructed from input characters at the
  11365. moment immediately before the glyph is added to the current output
  11366. line. Macros, diversions and strings are all, in fact, the same type of
  11367. object; they contain lists of input characters and glyph nodes in
  11368. any combination. A glyph node does not behave like an input
  11369. character for the purposes of macro processing; it does not inherit any
  11370. of the special properties that the input character from which it was
  11371. constructed might have had. For example,
  11372. @Example
  11373. .di x
  11374. \\\\
  11375. .br
  11376. .di
  11377. .x
  11378. @endExample
  11379. @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
  11380. @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
  11381. @cindex @code{\e}, incompatibilities with @acronym{AT&T} @code{troff}
  11382. @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
  11383. @cindex @code{\?}, incompatibilities with @acronym{AT&T} @code{troff}
  11384. @cindex transparent output, incompatibilities with @acronym{AT&T} @code{troff}
  11385. @cindex output, transparent, incompatibilities with @acronym{AT&T} @code{troff}
  11386. @noindent
  11387. prints @samp{\\} in GNU @code{troff}; each pair of input backslashes
  11388. is turned into one output backslash and the resulting output backslashes
  11389. are not interpreted as escape characters when they are reread.
  11390. @acronym{UNIX} @code{troff} would interpret them as escape characters
  11391. when they were reread and would end up printing one @samp{\}. The
  11392. correct way to obtain a printable backslash is to use the @code{\e}
  11393. escape sequence: This always prints a single instance of the current
  11394. escape character, regardless of whether or not it is used in a
  11395. diversion; it also works in both GNU @code{troff} and @acronym{UNIX}
  11396. @code{troff}.@footnote{To be completely independent of the current
  11397. escape character, use @code{\(rs} which represents a reverse solidus
  11398. (backslash) glyph.} To store, for some reason, an escape sequence in a
  11399. diversion that will be interpreted when the diversion is reread, either
  11400. use the traditional @code{\!} transparent output facility, or, if this
  11401. is unsuitable, the new @code{\?} escape sequence.
  11402. @xref{Diversions}, and @ref{Gtroff Internals}, for more information.
  11403. @c =====================================================================
  11404. @c =====================================================================
  11405. @node Preprocessors, Output Devices, gtroff Reference, Top
  11406. @chapter Preprocessors
  11407. @cindex preprocessors
  11408. This chapter describes all preprocessors that come with @code{groff} or
  11409. which are freely available.
  11410. @menu
  11411. * geqn::
  11412. * gtbl::
  11413. * gpic::
  11414. * ggrn::
  11415. * grap::
  11416. * grefer::
  11417. * gsoelim::
  11418. @end menu
  11419. @c =====================================================================
  11420. @node geqn, gtbl, Preprocessors, Preprocessors
  11421. @section @code{geqn}
  11422. @cindex @code{eqn}, the program
  11423. @cindex @code{geqn}, the program
  11424. @c XXX
  11425. @menu
  11426. * Invoking geqn::
  11427. @end menu
  11428. @c ---------------------------------------------------------------------
  11429. @node Invoking geqn, , geqn, geqn
  11430. @subsection Invoking @code{geqn}
  11431. @cindex invoking @code{geqn}
  11432. @cindex @code{geqn}, invoking
  11433. @c XXX
  11434. @c =====================================================================
  11435. @node gtbl, gpic, geqn, Preprocessors
  11436. @section @code{gtbl}
  11437. @cindex @code{tbl}, the program
  11438. @cindex @code{gtbl}, the program
  11439. @c XXX
  11440. @menu
  11441. * Invoking gtbl::
  11442. @end menu
  11443. @c ---------------------------------------------------------------------
  11444. @node Invoking gtbl, , gtbl, gtbl
  11445. @subsection Invoking @code{gtbl}
  11446. @cindex invoking @code{gtbl}
  11447. @cindex @code{gtbl}, invoking
  11448. @c XXX
  11449. @c =====================================================================
  11450. @node gpic, ggrn, gtbl, Preprocessors
  11451. @section @code{gpic}
  11452. @cindex @code{pic}, the program
  11453. @cindex @code{gpic}, the program
  11454. @c XXX
  11455. @menu
  11456. * Invoking gpic::
  11457. @end menu
  11458. @c ---------------------------------------------------------------------
  11459. @node Invoking gpic, , gpic, gpic
  11460. @subsection Invoking @code{gpic}
  11461. @cindex invoking @code{gpic}
  11462. @cindex @code{gpic}, invoking
  11463. @c XXX
  11464. @c =====================================================================
  11465. @node ggrn, grap, gpic, Preprocessors
  11466. @section @code{ggrn}
  11467. @cindex @code{grn}, the program
  11468. @cindex @code{ggrn}, the program
  11469. @c XXX
  11470. @menu
  11471. * Invoking ggrn::
  11472. @end menu
  11473. @c ---------------------------------------------------------------------
  11474. @node Invoking ggrn, , ggrn, ggrn
  11475. @subsection Invoking @code{ggrn}
  11476. @cindex invoking @code{ggrn}
  11477. @cindex @code{ggrn}, invoking
  11478. @c XXX
  11479. @c =====================================================================
  11480. @node grap, grefer, ggrn, Preprocessors
  11481. @section @code{grap}
  11482. @cindex @code{grap}, the program
  11483. A free implementation of @code{grap}, written by Ted Faber,
  11484. is available as an extra package from the following address:
  11485. @display
  11486. @uref{http://www.lunabase.org/~faber/Vault/software/grap/}
  11487. @end display
  11488. @c =====================================================================
  11489. @node grefer, gsoelim, grap, Preprocessors
  11490. @section @code{grefer}
  11491. @cindex @code{refer}, the program
  11492. @cindex @code{grefer}, the program
  11493. @c XXX
  11494. @menu
  11495. * Invoking grefer::
  11496. @end menu
  11497. @c ---------------------------------------------------------------------
  11498. @node Invoking grefer, , grefer, grefer
  11499. @subsection Invoking @code{grefer}
  11500. @cindex invoking @code{grefer}
  11501. @cindex @code{grefer}, invoking
  11502. @c XXX
  11503. @c =====================================================================
  11504. @node gsoelim, , grefer, Preprocessors
  11505. @section @code{gsoelim}
  11506. @cindex @code{soelim}, the program
  11507. @cindex @code{gsoelim}, the program
  11508. @c XXX
  11509. @menu
  11510. * Invoking gsoelim::
  11511. @end menu
  11512. @c ---------------------------------------------------------------------
  11513. @node Invoking gsoelim, , gsoelim, gsoelim
  11514. @subsection Invoking @code{gsoelim}
  11515. @cindex invoking @code{gsoelim}
  11516. @cindex @code{gsoelim}, invoking
  11517. @c XXX
  11518. @c =====================================================================
  11519. @c =====================================================================
  11520. @node Output Devices, File formats, Preprocessors, Top
  11521. @chapter Output Devices
  11522. @cindex output devices
  11523. @cindex devices for output
  11524. @c XXX
  11525. @menu
  11526. * Special Characters::
  11527. * grotty::
  11528. * grops::
  11529. * grodvi::
  11530. * grolj4::
  11531. * grolbp::
  11532. * grohtml::
  11533. * gxditview::
  11534. @end menu
  11535. @c =====================================================================
  11536. @node Special Characters, grotty, Output Devices, Output Devices
  11537. @section Special Characters
  11538. @cindex special characters
  11539. @cindex characters, special
  11540. @c XXX
  11541. @xref{Font Files}.
  11542. @c =====================================================================
  11543. @node grotty, grops, Special Characters, Output Devices
  11544. @section @code{grotty}
  11545. @cindex @code{grotty}, the program
  11546. @c XXX
  11547. @menu
  11548. * Invoking grotty::
  11549. @end menu
  11550. @c ---------------------------------------------------------------------
  11551. @node Invoking grotty, , grotty, grotty
  11552. @subsection Invoking @code{grotty}
  11553. @cindex invoking @code{grotty}
  11554. @cindex @code{grotty}, invoking
  11555. @c XXX
  11556. @c The following is no longer true; fix and extend it.
  11557. @c @pindex less
  11558. @c @cindex Teletype
  11559. @c @cindex ISO 6249 SGR
  11560. @c @cindex terminal control sequences
  11561. @c @cindex control sequences, for terminals
  11562. @c For TTY output devices, underlining is done by emitting sequences of
  11563. @c @samp{_} and @samp{\b} (the backspace character) before the actual
  11564. @c character. Literally, this is printing an underline character, then
  11565. @c moving back one character position, and printing the actual character
  11566. @c at the same position as the underline character (similar to a
  11567. @c typewriter). Usually, a modern terminal can't interpret this (and the
  11568. @c original Teletype machines for which this sequence was appropriate are
  11569. @c no longer in use). You need a pager program like @code{less} which
  11570. @c translates this into ISO 6429 SGR sequences to control terminals.
  11571. @c =====================================================================
  11572. @node grops, grodvi, grotty, Output Devices
  11573. @section @code{grops}
  11574. @cindex @code{grops}, the program
  11575. @c XXX
  11576. @menu
  11577. * Invoking grops::
  11578. * Embedding PostScript::
  11579. @end menu
  11580. @c ---------------------------------------------------------------------
  11581. @node Invoking grops, Embedding PostScript, grops, grops
  11582. @subsection Invoking @code{grops}
  11583. @cindex invoking @code{grops}
  11584. @cindex @code{grops}, invoking
  11585. @c XXX
  11586. @c ---------------------------------------------------------------------
  11587. @node Embedding PostScript, , Invoking grops, grops
  11588. @subsection Embedding @sc{PostScript}
  11589. @cindex embedding PostScript
  11590. @cindex PostScript, embedding
  11591. @c XXX
  11592. @c =====================================================================
  11593. @node grodvi, grolj4, grops, Output Devices
  11594. @section @code{grodvi}
  11595. @cindex @code{grodvi}, the program
  11596. @c XXX
  11597. @menu
  11598. * Invoking grodvi::
  11599. @end menu
  11600. @c ---------------------------------------------------------------------
  11601. @node Invoking grodvi, , grodvi, grodvi
  11602. @subsection Invoking @code{grodvi}
  11603. @cindex invoking @code{grodvi}
  11604. @cindex @code{grodvi}, invoking
  11605. @c XXX
  11606. @c =====================================================================
  11607. @node grolj4, grolbp, grodvi, Output Devices
  11608. @section @code{grolj4}
  11609. @cindex @code{grolj4}, the program
  11610. @c XXX
  11611. @menu
  11612. * Invoking grolj4::
  11613. @end menu
  11614. @c ---------------------------------------------------------------------
  11615. @node Invoking grolj4, , grolj4, grolj4
  11616. @subsection Invoking @code{grolj4}
  11617. @cindex invoking @code{grolj4}
  11618. @cindex @code{grolj4}, invoking
  11619. @c XXX
  11620. @c =====================================================================
  11621. @node grolbp, grohtml, grolj4, Output Devices
  11622. @section @code{grolbp}
  11623. @cindex @code{grolbp}, the program
  11624. @c XXX
  11625. @menu
  11626. * Invoking grolbp::
  11627. @end menu
  11628. @c ---------------------------------------------------------------------
  11629. @node Invoking grolbp, , grolbp, grolbp
  11630. @subsection Invoking @code{grolbp}
  11631. @cindex invoking @code{grolbp}
  11632. @cindex @code{grolbp}, invoking
  11633. @c XXX
  11634. @c =====================================================================
  11635. @node grohtml, gxditview, grolbp, Output Devices
  11636. @section @code{grohtml}
  11637. @cindex @code{grohtml}, the program
  11638. @c XXX
  11639. @menu
  11640. * Invoking grohtml::
  11641. * grohtml specific registers and strings::
  11642. @end menu
  11643. @c ---------------------------------------------------------------------
  11644. @node Invoking grohtml, grohtml specific registers and strings, grohtml, grohtml
  11645. @subsection Invoking @code{grohtml}
  11646. @cindex invoking @code{grohtml}
  11647. @cindex @code{grohtml}, invoking
  11648. @c XXX
  11649. @c ---------------------------------------------------------------------
  11650. @node grohtml specific registers and strings, , Invoking grohtml, grohtml
  11651. @subsection @code{grohtml} specific registers and strings
  11652. @cindex registers specific to @code{grohtml}
  11653. @cindex strings specific to @code{grohtml}
  11654. @cindex @code{grohtml}, registers and strings
  11655. @DefmpregList {ps4html, grohtml}
  11656. @DefstrListEnd {www-image-template, grohtml}
  11657. The registers @code{ps4html} and @code{www-image-template} are defined
  11658. by the @code{pre-grohtml} preprocessor. @code{pre-grohtml} reads in
  11659. the @code{troff} input, marks up the inline equations and passes the
  11660. result firstly to
  11661. @Example
  11662. troff -Tps -rps4html=1 -dwww-image-template=@var{template}
  11663. @endExample
  11664. @noindent
  11665. and secondly to
  11666. @Example
  11667. troff -Thtml
  11668. @endExample
  11669. The PostScript device is used to create all the image files, and the
  11670. register @code{ps4html} enables the macro sets to ignore floating
  11671. keeps, footers, and headings.
  11672. The register @code{www-image-template} is set to the user specified
  11673. template name or the default name.
  11674. @endDefmpreg
  11675. @c =====================================================================
  11676. @node gxditview, , grohtml, Output Devices
  11677. @section @code{gxditview}
  11678. @cindex @code{gxditview}, the program
  11679. @c XXX
  11680. @menu
  11681. * Invoking gxditview::
  11682. @end menu
  11683. @c ---------------------------------------------------------------------
  11684. @node Invoking gxditview, , gxditview, gxditview
  11685. @subsection Invoking @code{gxditview}
  11686. @cindex invoking @code{gxditview}
  11687. @cindex @code{gxditview}, invoking
  11688. @c XXX
  11689. @c X11's xditview
  11690. @c =====================================================================
  11691. @c =====================================================================
  11692. @node File formats, Installation, Output Devices, Top
  11693. @chapter File formats
  11694. @cindex file formats
  11695. @cindex formats, file
  11696. All files read and written by @code{gtroff} are text files. The
  11697. following two sections describe their format.
  11698. @menu
  11699. * gtroff Output::
  11700. * Font Files::
  11701. @end menu
  11702. @c =====================================================================
  11703. @node gtroff Output, Font Files, File formats, File formats
  11704. @section @code{gtroff} Output
  11705. @cindex @code{gtroff}, output
  11706. @cindex output, @code{gtroff}
  11707. This section describes the intermediate output format of GNU
  11708. @code{troff}. This output is produced by a run of @code{gtroff}
  11709. before it is fed into a device postprocessor program.
  11710. As @code{groff} is a wrapper program around @code{gtroff} that
  11711. automatically calls a postprocessor, this output does not show up
  11712. normally. This is why it is called @dfn{intermediate}.
  11713. @code{groff} provides the option @option{-Z} to inhibit postprocessing,
  11714. such that the produced intermediate output is sent to standard output
  11715. just like calling @code{gtroff} manually.
  11716. @cindex troff output
  11717. @cindex output, troff
  11718. @cindex intermediate output
  11719. @cindex output, intermediate
  11720. Here, the term @dfn{troff output} describes what is output by
  11721. @code{gtroff}, while @dfn{intermediate output} refers to the language
  11722. that is accepted by the parser that prepares this output for the
  11723. postprocessors. This parser is smarter on whitespace and implements
  11724. obsolete elements for compatibility, otherwise both formats are the
  11725. same.@footnote{The parser and postprocessor for intermediate output
  11726. can be found in the file@*
  11727. @file{@var{groff-source-dir}/src/libs/libdriver/input.cpp}.}
  11728. The main purpose of the intermediate output concept is to facilitate
  11729. the development of postprocessors by providing a common programming
  11730. interface for all devices. It has a language of its own that is
  11731. completely different from the @code{gtroff} language. While the
  11732. @code{gtroff} language is a high-level programming language for text
  11733. processing, the intermediate output language is a kind of low-level
  11734. assembler language by specifying all positions on the page for writing
  11735. and drawing.
  11736. The intermediate output produced by @code{gtroff} is fairly readable,
  11737. while output from @acronym{AT&T} @code{troff} is rather hard to
  11738. understand because of strange habits that are still supported, but not
  11739. used any longer by @code{gtroff}.
  11740. @menu
  11741. * Language Concepts::
  11742. * Command Reference::
  11743. * Intermediate Output Examples::
  11744. * Output Language Compatibility::
  11745. @end menu
  11746. @c ---------------------------------------------------------------------
  11747. @node Language Concepts, Command Reference, gtroff Output, gtroff Output
  11748. @subsection Language Concepts
  11749. During the run of @code{gtroff}, the input data is cracked down to the
  11750. information on what has to be printed at what position on the intended
  11751. device. So the language of the intermediate output format can be quite
  11752. small. Its only elements are commands with and without arguments.
  11753. In this section, the term @dfn{command} always refers to the intermediate
  11754. output language, and never to the @code{gtroff} language used for document
  11755. formatting. There are commands for positioning and text writing, for drawing, and
  11756. for device controlling.
  11757. @menu
  11758. * Separation::
  11759. * Argument Units::
  11760. * Document Parts::
  11761. @end menu
  11762. @node Separation, Argument Units, Language Concepts, Language Concepts
  11763. @subsubsection Separation
  11764. @acronym{AT&T} @code{troff} output has strange requirements on whitespace.
  11765. The @code{gtroff} output parser, however, is smart about whitespace by
  11766. making it maximally optional. The whitespace characters, i.e., the
  11767. tab, space, and newline characters, always have a syntactical meaning.
  11768. They are never printable because spacing within the output is always
  11769. done by positioning commands.
  11770. Any sequence of space or tab characters is treated as a single
  11771. @dfn{syntactical space}. It separates commands and arguments, but is
  11772. only required when there would occur a clashing between the command code
  11773. and the arguments without the space. Most often, this happens when
  11774. variable-length command names, arguments, argument lists, or command
  11775. clusters meet. Commands and arguments with a known, fixed length need
  11776. not be separated by syntactical space.
  11777. A line break is a syntactical element, too. Every command argument can be
  11778. followed by whitespace, a comment, or a newline character. Thus a
  11779. @dfn{syntactical line break} is defined to consist of optional
  11780. syntactical space that is optionally followed by a comment, and a
  11781. newline character.
  11782. The normal commands, those for positioning and text, consist of a
  11783. single letter taking a fixed number of arguments. For historical reasons,
  11784. the parser allows to stack such commands on the same line, but
  11785. fortunately, in @code{gtroff}'s intermediate output, every command with
  11786. at least one argument is followed by a line break, thus providing
  11787. excellent readability.
  11788. The other commands -- those for drawing and device controlling --
  11789. have a more complicated structure; some recognize long command names,
  11790. and some take a variable number of arguments. So all @samp{D} and
  11791. @samp{x} commands were designed to request a syntactical line break
  11792. after their last argument. Only one command, @w{@samp{x X}},
  11793. has an argument that can stretch over several lines; all other
  11794. commands must have all of their arguments on the same line as the
  11795. command, i.e., the arguments may not be splitted by a line break.
  11796. Empty lines (these are lines containing only space and/or a comment), can
  11797. occur everywhere. They are just ignored.
  11798. @node Argument Units, Document Parts, Separation, Language Concepts
  11799. @subsubsection Argument Units
  11800. Some commands take integer arguments that are assumed to represent
  11801. values in a measurement unit, but the letter for the corresponding
  11802. scale indicator is not written with the output command arguments.
  11803. Most commands assume the scale indicator @samp{u}, the basic unit of
  11804. the device, some use @samp{z}, the scaled point unit of the device,
  11805. while others, such as the color commands, expect plain integers.
  11806. Note that single characters can have the eighth bit set, as can the
  11807. names of fonts and special characters. The names of characters and
  11808. fonts can be of arbitrary length. A character that is to be printed
  11809. will always be in the current font.
  11810. A string argument is always terminated by the next whitespace
  11811. character (space, tab, or newline); an embedded @samp{#} character is
  11812. regarded as part of the argument, not as the beginning of a comment
  11813. command. An integer argument is already terminated by the next
  11814. non-digit character, which then is regarded as the first character of
  11815. the next argument or command.
  11816. @node Document Parts, , Argument Units, Language Concepts
  11817. @subsubsection Document Parts
  11818. A correct intermediate output document consists of two parts, the
  11819. @dfn{prologue} and the @dfn{body}.
  11820. The task of the prologue is to set the general device parameters
  11821. using three exactly specified commands. @code{gtroff}'s prologue
  11822. is guaranteed to consist of the following three lines (in that order):
  11823. @Example
  11824. x T @var{device}
  11825. x res @var{n} @var{h} @var{v}
  11826. x init
  11827. @endExample
  11828. @noindent
  11829. with the arguments set as outlined in @ref{Device Control Commands}.
  11830. Note that the parser for the intermediate output format is able to
  11831. swallow additional whitespace and comments as well even in the
  11832. prologue.
  11833. The body is the main section for processing the document data.
  11834. Syntactically, it is a sequence of any commands different from the
  11835. ones used in the prologue. Processing is terminated as soon as the
  11836. first @w{@samp{x stop}} command is encountered; the last line of any
  11837. @code{gtroff} intermediate output always contains such a command.
  11838. Semantically, the body is page oriented. A new page is started by a
  11839. @samp{p} command. Positioning, writing, and drawing commands are
  11840. always done within the current page, so they cannot occur before the
  11841. first @samp{p} command. Absolute positioning (by the @samp{H} and
  11842. @samp{V} commands) is done relative to the current page; all other
  11843. positioning is done relative to the current location within this page.
  11844. @c ---------------------------------------------------------------------
  11845. @node Command Reference, Intermediate Output Examples, Language Concepts, gtroff Output
  11846. @subsection Command Reference
  11847. This section describes all intermediate output commands, both from
  11848. @acronym{AT&T} @code{troff} as well as the @code{gtroff} extensions.
  11849. @menu
  11850. * Comment Command::
  11851. * Simple Commands::
  11852. * Graphics Commands::
  11853. * Device Control Commands::
  11854. * Obsolete Command::
  11855. @end menu
  11856. @node Comment Command, Simple Commands, Command Reference, Command Reference
  11857. @subsubsection Comment Command
  11858. @table @code
  11859. @item #@var{anything}@angles{end of line}
  11860. A comment. Ignore any characters from the @samp{#} character up to
  11861. the next newline character.
  11862. This command is the only possibility for commenting in the intermediate
  11863. output. Each comment can be preceded by arbitrary syntactical space;
  11864. every command can be terminated by a comment.
  11865. @end table
  11866. @node Simple Commands, Graphics Commands, Comment Command, Command Reference
  11867. @subsubsection Simple Commands
  11868. The commands in this subsection have a command code consisting of a
  11869. single character, taking a fixed number of arguments. Most of them
  11870. are commands for positioning and text writing. These commands are
  11871. smart about whitespace. Optionally, syntactical space can be inserted
  11872. before, after, and between the command letter and its arguments.
  11873. All of these commands are stackable, i.e., they can be preceded by
  11874. other simple commands or followed by arbitrary other commands on the
  11875. same line. A separating syntactical space is only necessary when two
  11876. integer arguments would clash or if the preceding argument ends with a
  11877. string argument.
  11878. @table @code
  11879. @ignore
  11880. .if (\n[@USE_ENV_STACK] == 1) \{\
  11881. .command {
  11882. Open a new environment by copying the actual device configuration data
  11883. to the environment stack.
  11884. .
  11885. The current environment is setup by the device specification and
  11886. manipulated by the setting commands.
  11887. .
  11888. .
  11889. .command }
  11890. Close the actual environment (opened by a preceding
  11891. .BR { \~command)
  11892. and restore the previous environment from the environment
  11893. stack as the actual device configuration data.
  11894. .
  11895. \} \" endif @USE_ENV_STACK
  11896. @end ignore
  11897. @item C @var{xxx}@angles{whitespace}
  11898. Print a special character named @var{xxx}. The trailing
  11899. syntactical space or line break is necessary to allow glyph names
  11900. of arbitrary length. The glyph is printed at the current print
  11901. position; the glyph's size is read from the font file. The print
  11902. position is not changed.
  11903. @item c @var{g}
  11904. Print glyph@tie{}@var{g} at the current print position;@footnote{@samp{c}
  11905. is actually a misnomer since it outputs a glyph.} the glyph's size is
  11906. read from the font file. The print position is not changed.
  11907. @item f @var{n}
  11908. Set font to font number@tie{}@var{n} (a non-negative integer).
  11909. @item H @var{n}
  11910. Move right to the absolute vertical position@tie{}@var{n} (a
  11911. non-negative integer in basic units @samp{u} relative to left edge
  11912. of current page.
  11913. @item h @var{n}
  11914. Move @var{n} (a non-negative integer) basic units @samp{u} horizontally
  11915. to the right. The original @acronym{UNIX} troff manual allows negative
  11916. values for @var{n} also, but @code{gtroff} doesn't use this.
  11917. @item m @var{color-scheme} @r{[}@var{component} @dots{}@r{]}
  11918. Set the color for text (glyphs), line drawing, and the outline of
  11919. graphic objects using different color schemes; the analoguous command
  11920. for the filling color of graphic objects is @samp{DF}. The color
  11921. components are specified as integer arguments between 0 and 65536.
  11922. The number of color components and their meaning vary for the
  11923. different color schemes. These commands are generated by
  11924. @code{gtroff}'s escape sequence @code{\m}. No position changing.
  11925. These commands are a @code{gtroff} extension.
  11926. @table @code
  11927. @item mc @var{cyan} @var{magenta} @var{yellow}
  11928. Set color using the CMY color scheme, having the 3@tie{}color components
  11929. @var{cyan}, @var{magenta}, and @var{yellow}.
  11930. @item md
  11931. Set color to the default color value (black in most cases).
  11932. No component arguments.
  11933. @item mg @var{gray}
  11934. Set color to the shade of gray given by the argument, an integer
  11935. between 0 (black) and 65536 (white).
  11936. @item mk @var{cyan} @var{magenta} @var{yellow} @var{black}
  11937. Set color using the CMYK color scheme, having the 4@tie{}color components
  11938. @var{cyan}, @var{magenta}, @var{yellow}, and @var{black}.
  11939. @item mr @var{red} @var{green} @var{blue}
  11940. Set color using the RGB color scheme, having the 3@tie{}color components
  11941. @var{red}, @var{green}, and @var{blue}.
  11942. @end table
  11943. @item N @var{n}
  11944. Print glyph with index@tie{}@var{n} (a non-negative integer) of the
  11945. current font. This command is a @code{gtroff} extension.
  11946. @item n @var{b} @var{a}
  11947. Inform the device about a line break, but no positioning is done by
  11948. this command. In @acronym{AT&T} @code{troff}, the integer arguments
  11949. @var{b} and@tie{}@var{a} informed about the space before and after the
  11950. current line to make the intermediate output more human readable
  11951. without performing any action. In @code{groff}, they are just ignored, but
  11952. they must be provided for compatibility reasons.
  11953. @item p @var{n}
  11954. Begin a new page in the outprint. The page number is set
  11955. to@tie{}@var{n}. This page is completely independent of pages formerly
  11956. processed even if those have the same page number. The vertical
  11957. position on the outprint is automatically set to@tie{}0. All
  11958. positioning, writing, and drawing is always done relative to a page,
  11959. so a @samp{p} command must be issued before any of these commands.
  11960. @item s @var{n}
  11961. Set point size to @var{n}@tie{}scaled points (this is unit @samp{z}).
  11962. @acronym{AT&T} @code{troff} used the unit points (@samp{p}) instead.
  11963. @xref{Output Language Compatibility}.
  11964. @item t @var{xxx}@angles{whitespace}
  11965. @itemx t @var{xxx} @var{dummy-arg}@angles{whitespace}
  11966. Print a word, i.e., a sequence of characters @var{xxx} representing
  11967. output glyphs which names are single characters, terminated by
  11968. a space character or a line break; an optional second integer argument
  11969. is ignored (this allows the formatter to generate an even number of
  11970. arguments). The first glyph should be printed at the current
  11971. position, the current horizontal position should then be increased by
  11972. the width of the first glyph, and so on for each glyph.
  11973. The widths of the glyphs are read from the font file, scaled for the
  11974. current point size, and rounded to a multiple of the horizontal
  11975. resolution. Special characters cannot be printed using this command
  11976. (use the @samp{C} command for special characters). This command is a
  11977. @code{gtroff} extension; it is only used for devices whose @file{DESC}
  11978. file contains the @code{tcommand} keyword (@pxref{DESC File Format}).
  11979. @item u @var{n} @var{xxx}@angles{whitespace}
  11980. Print word with track kerning. This is the same as the @samp{t}
  11981. command except that after printing each glyph, the current
  11982. horizontal position is increased by the sum of the width of that
  11983. glyph and@tie{}@var{n} (an integer in basic units @samp{u}).
  11984. This command is a @code{gtroff} extension; it is only used for devices
  11985. whose @file{DESC} file contains the @code{tcommand} keyword
  11986. (@pxref{DESC File Format}).
  11987. @item V @var{n}
  11988. Move down to the absolute vertical position@tie{}@var{n} (a
  11989. non-negative integer in basic units @samp{u}) relative to upper edge
  11990. of current page.
  11991. @item v @var{n}
  11992. Move @var{n}@tie{}basic units @samp{u} down (@var{n} is a non-negative
  11993. integer). The original @acronym{UNIX} troff manual allows negative
  11994. values for @var{n} also, but @code{gtroff} doesn't use this.
  11995. @item w
  11996. Informs about a paddable white space to increase readability.
  11997. The spacing itself must be performed explicitly by a move command.
  11998. @end table
  11999. @node Graphics Commands, Device Control Commands, Simple Commands, Command Reference
  12000. @subsubsection Graphics Commands
  12001. Each graphics or drawing command in the intermediate output starts
  12002. with the letter @samp{D}, followed by one or two characters that
  12003. specify a subcommand; this is followed by a fixed or variable number
  12004. of integer arguments that are separated by a single space character.
  12005. A @samp{D} command may not be followed by another command on the same line
  12006. (apart from a comment), so each @samp{D} command is terminated by a
  12007. syntactical line break.
  12008. @code{gtroff} output follows the classical spacing rules (no space
  12009. between command and subcommand, all arguments are preceded by a
  12010. single space character), but the parser allows optional space between
  12011. the command letters and makes the space before the first argument
  12012. optional. As usual, each space can be any sequence of tab and space
  12013. characters.
  12014. Some graphics commands can take a variable number of arguments.
  12015. In this case, they are integers representing a size measured in basic
  12016. units @samp{u}. The arguments called @var{h1}, @var{h2}, @dots{},
  12017. @var{hn} stand for horizontal distances where positive means right,
  12018. negative left. The arguments called @var{v1}, @var{v2}, @dots{},
  12019. @var{vn} stand for vertical distances where positive means down,
  12020. negative up. All these distances are offsets relative to the current
  12021. location.
  12022. Each graphics command directly corresponds to a similar @code{gtroff}
  12023. @code{\D} escape sequence. @xref{Drawing Requests}.
  12024. Unknown @samp{D} commands are assumed to be device-specific.
  12025. Its arguments are parsed as strings; the whole information is then
  12026. sent to the postprocessor.
  12027. In the following command reference, the syntax element
  12028. @angles{line break} means a syntactical line break as defined above.
  12029. @table @code
  12030. @item D~ @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
  12031. Draw B-spline from current position to offset (@var{h1},@var{v1}),
  12032. then to offset (@var{h2},@var{v2}), if given, etc.@: up to
  12033. (@var{hn},@var{vn}). This command takes a variable number of argument
  12034. pairs; the current position is moved to the terminal point of the drawn
  12035. curve.
  12036. @item Da @var{h1} @var{v1} @var{h2} @var{v2}@angles{line break}
  12037. Draw arc from current position to
  12038. (@var{h1},@var{v1})@math{+}(@var{h2},@var{v2}) with center at
  12039. (@var{h1},@var{v1}); then move the current position to the final point
  12040. of the arc.
  12041. @item DC @var{d}@angles{line break}
  12042. @itemx DC @var{d} @var{dummy-arg}@angles{line break}
  12043. Draw a solid circle using the current fill color with
  12044. diameter@tie{}@var{d} (integer in basic units @samp{u}) with leftmost
  12045. point at the current position; then move the current position to the
  12046. rightmost point of the circle. An optional second integer argument is
  12047. ignored (this allows the formatter to generate an even number of
  12048. arguments). This command is a @code{gtroff} extension.
  12049. @item Dc @var{d}@angles{line break}
  12050. Draw circle line with diameter@tie{}@var{d} (integer in basic units
  12051. @samp{u}) with leftmost point at the current position; then move the
  12052. current position to the rightmost point of the circle.
  12053. @item DE @var{h} @var{v}@angles{line break}
  12054. Draw a solid ellipse in the current fill color with a horizontal
  12055. diameter of@tie{}@var{h} and a vertical diameter of@tie{}@var{v} (both
  12056. integers in basic units @samp{u}) with the leftmost point at the
  12057. current position; then move to the rightmost point of the ellipse.
  12058. This command is a @code{gtroff} extension.
  12059. @item De @var{h} @var{v}@angles{line break}
  12060. Draw an outlined ellipse with a horizontal diameter of@tie{}@var{h}
  12061. and a vertical diameter of@tie{}@var{v} (both integers in basic units
  12062. @samp{u}) with the leftmost point at current position; then move to
  12063. the rightmost point of the ellipse.
  12064. @item DF @var{color-scheme} @r{[}@var{component} @dots{}@r{]}@angles{line break}
  12065. Set fill color for solid drawing objects using different color
  12066. schemes; the analoguous command for setting the color of text, line
  12067. graphics, and the outline of graphic objects is @samp{m}.
  12068. The color components are specified as integer arguments between 0 and
  12069. 65536. The number of color components and their meaning vary for the
  12070. different color schemes. These commands are generated by @code{gtroff}'s
  12071. escape sequences @w{@code{\D'F @dots{}'}} and @code{\M} (with no other
  12072. corresponding graphics commands). No position changing. This command
  12073. is a @code{gtroff} extension.
  12074. @table @code
  12075. @item DFc @var{cyan} @var{magenta} @var{yellow}@angles{line break}
  12076. Set fill color for solid drawing objects using the CMY color scheme,
  12077. having the 3@tie{}color components @var{cyan}, @var{magenta}, and
  12078. @var{yellow}.
  12079. @item DFd@angles{line break}
  12080. Set fill color for solid drawing objects to the default fill color value
  12081. (black in most cases). No component arguments.
  12082. @item DFg @var{gray}@angles{line break}
  12083. Set fill color for solid drawing objects to the shade of gray given by
  12084. the argument, an integer between 0 (black) and 65536 (white).
  12085. @item DFk @var{cyan} @var{magenta} @var{yellow} @var{black}@angles{line break}
  12086. Set fill color for solid drawing objects using the CMYK color scheme,
  12087. having the 4@tie{}color components @var{cyan}, @var{magenta}, @var{yellow},
  12088. and @var{black}.
  12089. @item DFr @var{red} @var{green} @var{blue}@angles{line break}
  12090. Set fill color for solid drawing objects using the RGB color scheme,
  12091. having the 3@tie{}color components @var{red}, @var{green}, and @var{blue}.
  12092. @end table
  12093. @item Df @var{n}@angles{line break}
  12094. The argument@tie{}@var{n} must be an integer in the range @math{-32767}
  12095. to 32767.
  12096. @table @asis
  12097. @item @math{0 @LE{} @var{n} @LE{} 1000}
  12098. Set the color for filling solid drawing objects to a shade of gray,
  12099. where 0 corresponds to solid white, 1000 (the default) to solid black,
  12100. and values in between to intermediate shades of gray; this is
  12101. obsoleted by command @samp{DFg}.
  12102. @item @math{@var{n} < 0} or @math{@var{n} > 1000}
  12103. Set the filling color to the color that is currently being used for
  12104. the text and the outline, see command @samp{m}. For example, the
  12105. command sequence
  12106. @Example
  12107. mg 0 0 65536
  12108. Df -1
  12109. @endExample
  12110. @noindent
  12111. sets all colors to blue.
  12112. @end table
  12113. @noindent
  12114. No position changing. This command is a @code{gtroff} extension.
  12115. @item Dl @var{h} @var{v}@angles{line break}
  12116. Draw line from current position to offset (@var{h},@var{v}) (integers
  12117. in basic units @samp{u}); then set current position to the end of the
  12118. drawn line.
  12119. @item Dp @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
  12120. Draw a polygon line from current position to offset (@var{h1},@var{v1}),
  12121. from there to offset (@var{h2},@var{v2}), etc.@: up to offset
  12122. (@var{hn},@var{vn}), and from there back to the starting position.
  12123. For historical reasons, the position is changed by adding the sum of
  12124. all arguments with odd index to the actual horizontal position and the
  12125. even ones to the vertical position. Although this doesn't make sense
  12126. it is kept for compatibility.
  12127. @ignore
  12128. As the polygon is closed, the end of drawing is the starting point, so
  12129. the position doesn't change.
  12130. @end ignore
  12131. This command is a @code{gtroff} extension.
  12132. @item Dp @var{h1} @var{v1} @var{h2} @var{v2} @dots{} @var{hn} @var{vn}@angles{line break}
  12133. Draw a solid polygon in the current fill color rather than an outlined
  12134. polygon, using the same arguments and positioning as the corresponding
  12135. @samp{Dp} command.
  12136. @ignore
  12137. No position changing.
  12138. @end ignore
  12139. This command is a @code{gtroff} extension.
  12140. @item Dt @var{n}@angles{line break}
  12141. Set the current line thickness to@tie{}@var{n} (an integer in basic
  12142. units @samp{u}) if @math{@var{n}>0}; if @math{@var{n}=0} select the
  12143. smallest available line thickness; if @math{@var{n}<0} set the line
  12144. thickness proportional to the point size (this is the default before
  12145. the first @samp{Dt} command was specified). For historical reasons,
  12146. the horizontal position is changed by adding the argument to the actual
  12147. horizontal position, while the vertical position is not changed.
  12148. Although this doesn't make sense it is kept for compatibility.
  12149. @ignore
  12150. No position changing.
  12151. @end ignore
  12152. This command is a @code{gtroff} extension.
  12153. @end table
  12154. @node Device Control Commands, Obsolete Command, Graphics Commands, Command Reference
  12155. @subsubsection Device Control Commands
  12156. Each device control command starts with the letter @samp{x},
  12157. followed by a space character (optional or arbitrary space or tab in
  12158. @code{gtroff}) and a subcommand letter or word; each argument (if any)
  12159. must be preceded by a syntactical space. All @samp{x} commands are
  12160. terminated by a syntactical line break; no device control command can
  12161. be followed by another command on the same line (except a comment).
  12162. The subcommand is basically a single letter, but to increase
  12163. readability, it can be written as a word, i.e., an arbitrary sequence
  12164. of characters terminated by the next tab, space, or newline character.
  12165. All characters of the subcommand word but the first are simply ignored.
  12166. For example, @code{gtroff} outputs the initialization command
  12167. @w{@samp{x i}} as @w{@samp{x init}} and the resolution command
  12168. @w{@samp{x r}} as @w{@samp{x res}}.
  12169. In the following, the syntax element @angles{line break} means a
  12170. syntactical line break (@pxref{Separation}).
  12171. @table @code
  12172. @item xF @var{name}@angles{line break}
  12173. The @samp{F} stands for @var{Filename}.
  12174. Use @var{name} as the intended name for the current file in error
  12175. reports. This is useful for remembering the original file name when
  12176. @code{gtroff} uses an internal piping mechanism. The input file is
  12177. not changed by this command. This command is a @code{gtroff} extension.
  12178. @item xf @var{n} @var{s}@angles{line break}
  12179. The @samp{f} stands for @var{font}.
  12180. Mount font position@tie{}@var{n} (a non-negative integer) with font
  12181. named@tie{}@var{s} (a text word). @xref{Font Positions}.
  12182. @item xH @var{n}@angles{line break}
  12183. The @samp{H} stands for @var{Height}.
  12184. Set glyph height to@tie{}@var{n} (a positive integer in scaled
  12185. points @samp{z}). @acronym{AT&T} @code{troff} uses the unit points
  12186. (@samp{p}) instead. @xref{Output Language Compatibility}.
  12187. @item xi@angles{line break}
  12188. The @samp{i} stands for @var{init}.
  12189. Initialize device. This is the third command of the prologue.
  12190. @item xp@angles{line break}
  12191. The @samp{p} stands for @var{pause}.
  12192. Parsed but ignored. The original @acronym{UNIX} troff manual writes
  12193. @display
  12194. pause device, can be restarted
  12195. @end display
  12196. @item xr @var{n} @var{h} @var{v}@angles{line break}
  12197. The @samp{r} stands for @var{resolution}.
  12198. Resolution is@tie{}@var{n}, while @var{h} is the minimal horizontal
  12199. motion, and @var{v} the minimal vertical motion possible with this
  12200. device; all arguments are positive integers in basic units @samp{u}
  12201. per inch. This is the second command of the prologue.
  12202. @item xS @var{n}@angles{line break}
  12203. The @samp{S} stands for @var{Slant}.
  12204. Set slant to@tie{}@var{n} (an integer in basic units @samp{u}).
  12205. @item xs@angles{line break}
  12206. The @samp{s} stands for @var{stop}.
  12207. Terminates the processing of the current file; issued as the last
  12208. command of any intermediate troff output.
  12209. @item xt@angles{line break}
  12210. The @samp{t} stands for @var{trailer}.
  12211. Generate trailer information, if any. In @var{gtroff}, this is
  12212. actually just ignored.
  12213. @item xT @var{xxx}@angles{line break}
  12214. The @samp{T} stands for @var{Typesetter}.
  12215. Set name of device to word @var{xxx}, a sequence of characters ended
  12216. by the next white space character. The possible device names coincide
  12217. with those from the @code{groff} @option{-T} option. This is the first
  12218. command of the prologue.
  12219. @item xu @var{n}@angles{line break}
  12220. The @samp{u} stands for @var{underline}.
  12221. Configure underlining of spaces. If @var{n} is@tie{}1, start
  12222. underlining of spaces; if @var{n} is@tie{}0, stop underlining of spaces.
  12223. This is needed for the @code{cu} request in nroff mode and is ignored
  12224. otherwise. This command is a @code{gtroff} extension.
  12225. @item xX @var{anything}@angles{line break}
  12226. The @samp{x} stands for @var{X-escape}.
  12227. Send string @var{anything} uninterpreted to the device. If the line
  12228. following this command starts with a @samp{+} character this line is
  12229. interpreted as a continuation line in the following sense. The
  12230. @samp{+} is ignored, but a newline character is sent instead to the
  12231. device, the rest of the line is sent uninterpreted. The same applies
  12232. to all following lines until the first character of a line is not a
  12233. @samp{+} character. This command is generated by the @code{gtroff}
  12234. escape sequence @code{\X}. The line-continuing feature is a
  12235. @code{gtroff} extension.
  12236. @end table
  12237. @node Obsolete Command, , Device Control Commands, Command Reference
  12238. @subsubsection Obsolete Command
  12239. In @acronym{AT&T} @code{troff} output, the writing of a single
  12240. glyph is mostly done by a very strange command that combines a
  12241. horizontal move and a single character giving the glyph name. It
  12242. doesn't have a command code, but is represented by a 3-character
  12243. argument consisting of exactly 2@tie{}digits and a character.
  12244. @table @asis
  12245. @item @var{dd}@var{g}
  12246. Move right @var{dd} (exactly two decimal digits) basic units @samp{u},
  12247. then print glyph@tie{}@var{g} (represented as a single character).
  12248. In @code{gtroff}, arbitrary syntactical space around and within this
  12249. command is allowed to be added. Only when a preceding command on the
  12250. same line ends with an argument of variable length a separating space
  12251. is obligatory. In @acronym{AT&T} @code{troff}, large clusters of these
  12252. and other commands are used, mostly without spaces; this made such output
  12253. almost unreadable.
  12254. @end table
  12255. For modern high-resolution devices, this command does not make sense
  12256. because the width of the glyphs can become much larger than two
  12257. decimal digits. In @code{gtroff}, this is only used for the devices
  12258. @code{X75}, @code{X75-12}, @code{X100}, and @code{X100-12}. For other
  12259. devices, the commands @samp{t} and @samp{u} provide a better
  12260. functionality.
  12261. @c ---------------------------------------------------------------------
  12262. @node Intermediate Output Examples, Output Language Compatibility, Command Reference, gtroff Output
  12263. @subsection Intermediate Output Examples
  12264. This section presents the intermediate output generated from the same
  12265. input for three different devices. The input is the sentence
  12266. @samp{hell world} fed into @code{gtroff} on the command line.
  12267. @table @asis
  12268. @item High-resolution device @code{ps}
  12269. This is the standard output of @code{gtroff} if no @option{-T} option
  12270. is given.
  12271. @example
  12272. @group
  12273. shell> echo "hell world" | groff -Z -T ps
  12274. x T ps
  12275. x res 72000 1 1
  12276. x init
  12277. @end group
  12278. p1
  12279. x font 5 TR
  12280. f5
  12281. s10000
  12282. V12000
  12283. H72000
  12284. thell
  12285. wh2500
  12286. tw
  12287. H96620
  12288. torld
  12289. n12000 0
  12290. @group
  12291. x trailer
  12292. V792000
  12293. x stop
  12294. @end group
  12295. @end example
  12296. @noindent
  12297. This output can be fed into @code{grops} to get its representation as
  12298. a PostScript file.
  12299. @item Low-resolution device @code{latin1}
  12300. This is similar to the high-resolution device except that the
  12301. positioning is done at a minor scale. Some comments (lines starting
  12302. with @samp{#}) were added for clarification; they were not generated
  12303. by the formatter.
  12304. @example
  12305. @group
  12306. shell> echo "hell world" | groff -Z -T latin1
  12307. # prologue
  12308. x T latin1
  12309. x res 240 24 40
  12310. x init
  12311. @end group
  12312. # begin a new page
  12313. p1
  12314. # font setup
  12315. x font 1 R
  12316. f1
  12317. s10
  12318. # initial positioning on the page
  12319. V40
  12320. H0
  12321. # write text `hell'
  12322. thell
  12323. # inform about space, and issue a horizontal jump
  12324. wh24
  12325. # write text `world'
  12326. tworld
  12327. # announce line break, but do nothing because ...
  12328. n40 0
  12329. @group
  12330. # ... the end of the document has been reached
  12331. x trailer
  12332. V2640
  12333. x stop
  12334. @end group
  12335. @end example
  12336. @noindent
  12337. This output can be fed into @code{grotty} to get a formatted text
  12338. document.
  12339. @item @acronym{AT&T} @code{troff} output
  12340. Since a computer monitor has a very low resolution compared to modern
  12341. printers the intermediate output for the X@tie{}Window devices can use
  12342. the jump-and-write command with its 2-digit displacements.
  12343. @example
  12344. @group
  12345. shell> echo "hell world" | groff -Z -T X100
  12346. x T X100
  12347. x res 100 1 1
  12348. x init
  12349. @end group
  12350. p1
  12351. x font 5 TR
  12352. f5
  12353. s10
  12354. V16
  12355. H100
  12356. # write text with jump-and-write commands
  12357. ch07e07l03lw06w11o07r05l03dh7
  12358. n16 0
  12359. @group
  12360. x trailer
  12361. V1100
  12362. x stop
  12363. @end group
  12364. @end example
  12365. @noindent
  12366. This output can be fed into @code{xditview} or @code{gxditview}
  12367. for displaying in@tie{}X.
  12368. Due to the obsolete jump-and-write command, the text clusters in the
  12369. @acronym{AT&T} @code{troff} output are almost unreadable.
  12370. @end table
  12371. @c ---------------------------------------------------------------------
  12372. @node Output Language Compatibility, , Intermediate Output Examples, gtroff Output
  12373. @subsection Output Language Compatibility
  12374. The intermediate output language of @acronym{AT&T} @code{troff}
  12375. was first documented in the @acronym{UNIX} troff manual, with later
  12376. additions documented in @cite{A Typesetter-indenpendent TROFF},
  12377. written by Brian Kernighan.
  12378. The @code{gtroff} intermediate output format is compatible with this
  12379. specification except for the following features.
  12380. @itemize @bullet
  12381. @item
  12382. The classical quasi device independence is not yet implemented.
  12383. @item
  12384. The old hardware was very different from what we use today. So the
  12385. @code{groff} devices are also fundamentally different from the ones in
  12386. @acronym{AT&T} @code{troff}. For example, the @acronym{AT&T}
  12387. PostScript device is called @code{post} and has a resolution of only
  12388. 720 units per inch, suitable for printers 20 years ago, while
  12389. @code{groff}'s @code{ps} device has a resolution of
  12390. 72000 units per inch. Maybe, by implementing some rescaling
  12391. mechanism similar to the classical quasi device independence,
  12392. @code{groff} could emulate @acronym{AT&T}'s @code{post} device.
  12393. @item
  12394. The B-spline command @samp{D~} is correctly handled by the
  12395. intermediate output parser, but the drawing routines aren't
  12396. implemented in some of the postprocessor programs.
  12397. @item
  12398. The argument of the commands @samp{s} and @w{@samp{x H}} has the
  12399. implicit unit scaled point @samp{z} in @code{gtroff}, while
  12400. @acronym{AT&T} @code{troff} has point (@samp{p}). This isn't an
  12401. incompatibility but a compatible extension, for both units coincide
  12402. for all devices without a @code{sizescale} parameter in the @file{DESC}
  12403. file, including all postprocessors from @acronym{AT&T} and
  12404. @code{groff}'s text devices. The few @code{groff} devices with
  12405. a @code{sizescale} parameter either do not exist for @acronym{AT&T}
  12406. @code{troff}, have a different name, or seem to have a different
  12407. resolution. So conflicts are very unlikely.
  12408. @item
  12409. The position changing after the commands @samp{Dp}, @samp{DP}, and
  12410. @samp{Dt} is illogical, but as old versions of @code{gtroff} used this
  12411. feature it is kept for compatibility reasons.
  12412. @ignore
  12413. Temporarily, there existed some confusion on the positioning after the
  12414. @samp{D} commands that are groff extensions. This has been clarified
  12415. by establishing the classical rule for all @code{groff} drawing commands:
  12416. @itemize
  12417. @item
  12418. The position after a graphic object has been drawn is at its end;
  12419. for circles and ellipses, the `end' is at the right side.
  12420. @item
  12421. From this, the positionings specified for the drawing commands above
  12422. follow quite naturally.
  12423. @end itemize
  12424. @end ignore
  12425. @end itemize
  12426. @c =====================================================================
  12427. @node Font Files, , gtroff Output, File formats
  12428. @section Font Files
  12429. @cindex font files
  12430. @cindex files, font
  12431. The @code{gtroff} font format is roughly a superset of the
  12432. @code{ditroff} font format (as used in later versions of @acronym{AT&T}
  12433. @code{troff} and its descendants). Unlike the @code{ditroff} font
  12434. format, there is no associated binary format; all files are text
  12435. files.@footnote{Plan@tie{}9 @code{troff} has also abandoned the binary
  12436. format.} The font files for device @var{name} are stored in a directory
  12437. @file{dev@var{name}}. There are two types of file: a device description
  12438. file called @file{DESC} and for each font@tie{}@var{f} a font file
  12439. called@tie{}@file{@var{f}}.
  12440. @menu
  12441. * DESC File Format::
  12442. * Font File Format::
  12443. @end menu
  12444. @c ---------------------------------------------------------------------
  12445. @node DESC File Format, Font File Format, Font Files, Font Files
  12446. @subsection @file{DESC} File Format
  12447. @cindex @file{DESC} file, format
  12448. @cindex font description file, format
  12449. @cindex format of font description file
  12450. @pindex DESC@r{ file format}
  12451. The @file{DESC} file can contain the following types of line. Except
  12452. for the @code{charset} keyword which must comes last (if at all), the
  12453. order of the lines is not important.
  12454. @table @code
  12455. @item res @var{n}
  12456. @kindex res
  12457. @cindex device resolution
  12458. @cindex resolution, device
  12459. There are @var{n}@tie{}machine units per inch.
  12460. @item hor @var{n}
  12461. @kindex hor
  12462. @cindex horizontal resolution
  12463. @cindex resolution, horizontal
  12464. The horizontal resolution is @var{n}@tie{}machine units. All horizontal
  12465. quantities are rounded to be multiples of this value.
  12466. @item vert @var{n}
  12467. @kindex vert
  12468. @cindex vertical resolution
  12469. @cindex resolution, vertical
  12470. The vertical resolution is @var{n}@tie{}machine units. All vertical
  12471. quantities are rounded to be multiples of this value.
  12472. @item sizescale @var{n}
  12473. @kindex sizescale
  12474. The scale factor for point sizes. By default this has a value of@tie{}1.
  12475. One scaled point is equal to one point/@var{n}. The arguments to the
  12476. @code{unitwidth} and @code{sizes} commands are given in scaled points.
  12477. @xref{Fractional Type Sizes}, for more information.
  12478. @item unitwidth @var{n}
  12479. @kindex unitwidth
  12480. Quantities in the font files are given in machine units for fonts whose
  12481. point size is @var{n}@tie{}scaled points.
  12482. @item prepro @var{program}
  12483. @kindex prepro
  12484. Call @var{program} as a preprocessor. Currently, this keyword is used
  12485. by @code{groff} with option @option{-Thtml} only.
  12486. @item postpro @var{program}
  12487. @kindex postpro
  12488. Call @var{program} as a postprocessor. For example, the line
  12489. @Example
  12490. postpro grodvi
  12491. @endExample
  12492. @noindent
  12493. in the file @file{devdvi/DESC} makes @code{groff} call @code{grodvi}
  12494. if option @option{-Tdvi} is given (and @option{-Z} isn't used).
  12495. @item tcommand
  12496. @kindex tcommand
  12497. This means that the postprocessor can handle the @samp{t} and @samp{u}
  12498. intermediate output commands.
  12499. @item sizes @var{s1} @var{s2} @dots{} @var{sn} 0
  12500. @kindex sizes
  12501. This means that the device has fonts at @var{s1}, @var{s2}, @dots{}
  12502. @var{sn} scaled points. The list of sizes must be terminated by@tie{}0
  12503. (this is digit zero). Each @var{si} can also be a range of sizes
  12504. @var{m}-@var{n}. The list can extend over more than one line.
  12505. @item styles @var{S1} @var{S2} @dots{} @var{Sm}
  12506. @kindex styles
  12507. The first @var{m}@tie{}font positions are associated with styles
  12508. @var{S1} @dots{} @var{Sm}.
  12509. @item fonts @var{n} @var{F1} @var{F2} @var{F3} @dots{} @var{Fn}
  12510. @kindex fonts
  12511. Fonts @var{F1} @dots{} @var{Fn} are mounted in the font positions
  12512. @var{m}+1, @dots{}, @var{m}+@var{n} where @var{m} is the number of
  12513. styles. This command may extend over more than one line. A font name
  12514. of@tie{}0 means no font is mounted on the corresponding font position.
  12515. @item family @var{fam}
  12516. @kindex family
  12517. The default font family is @var{fam}.
  12518. @item use_charnames_in_special
  12519. @kindex use_charnames_in_special
  12520. This command indicates that @code{gtroff} should encode special
  12521. characters inside special commands. Currently, this is only used
  12522. by the @acronym{HTML} output device. @xref{Postprocessor Access}.
  12523. @item papersize @var{string} @dots{}
  12524. @kindex papersize
  12525. Select a paper size. Valid values for @var{string} are the ISO paper
  12526. types @code{A0}-@code{A7}, @code{B0}-@code{B7}, @code{C0}-@code{C7},
  12527. @code{D0}-@code{D7}, @code{DL}, and the US paper types @code{letter},
  12528. @code{legal}, @code{tabloid}, @code{ledger}, @code{statement},
  12529. @code{executive}, @code{com10}, and @code{monarch}. Case is not significant
  12530. for @var{string} if it holds predefined paper types. Alternatively,
  12531. @var{string} can be a file name (e.g.@: @file{/etc/papersize}); if the file
  12532. can be opened, @code{groff} reads the first line and tests for the above
  12533. paper sizes. Finally, @var{string} can be a custom paper size in the format
  12534. @code{@var{length},@var{width}} (no spaces before and after the comma).
  12535. Both @var{length} and @var{width} must have a unit appended; valid values
  12536. are @samp{i} for inches, @samp{C} for centimeters, @samp{p} for points, and
  12537. @samp{P} for picas. Example: @code{12c,235p}. An argument which starts
  12538. with a digit is always treated as a custom paper format. @code{papersize}
  12539. sets both the vertical and horizontal dimension of the output medium.
  12540. More than one argument can be specified; @code{groff} scans from left to
  12541. right and uses the first valid paper specification.
  12542. @item pass_filenames
  12543. @kindex pass_filenames
  12544. Tell @code{gtroff} to emit the name of the source file currently
  12545. being processed. This is achieved by the intermediate output command
  12546. @samp{F}. Currently, this is only used by the @acronym{HTML} output
  12547. device.
  12548. @item print @var{program}
  12549. @kindex print
  12550. Use @var{program} as a spooler program for printing. If omitted,
  12551. the @option{-l} and @option{-L} options of @code{groff} are ignored.
  12552. @item charset
  12553. @kindex charset
  12554. This line and everything following in the file are ignored. It is
  12555. allowed for the sake of backwards compatibility.
  12556. @end table
  12557. The @code{res}, @code{unitwidth}, @code{fonts}, and @code{sizes} lines
  12558. are mandatory. Other commands are ignored by @code{gtroff} but may be
  12559. used by postprocessors to store arbitrary information about the device
  12560. in the @file{DESC} file.
  12561. @kindex spare1
  12562. @kindex spare2
  12563. @kindex biggestfont
  12564. Here a list of obsolete keywords which are recognized by @code{groff}
  12565. but completely ignored: @code{spare1}, @code{spare2},
  12566. @code{biggestfont}.
  12567. @c ---------------------------------------------------------------------
  12568. @node Font File Format, , DESC File Format, Font Files
  12569. @subsection Font File Format
  12570. @cindex font file, format
  12571. @cindex font description file, format
  12572. @cindex format of font files
  12573. @cindex format of font description files
  12574. A @dfn{font file}, also