/contrib/groff/doc/groff.texinfo

https://bitbucket.org/freebsd/freebsd-head/ · Unknown · 15797 lines · 12816 code · 2981 blank · 0 comment · 0 complexity · 8b088c4112aed0fed1c425e0f04bd15a MD5 · raw file

Large files are truncated click here to view the full file

  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