/contrib/groff/man/roff.man

https://bitbucket.org/freebsd/freebsd-head/ · Unknown · 1278 lines · 1271 code · 7 blank · 0 comment · 0 complexity · c8ed4c1fd13e0e7b4525d7aae953f7a7 MD5 · raw file

  1. .ig
  2. roff.man
  3. Last update: 1 Jun 2004
  4. This file is part of groff, the GNU roff type-setting system.
  5. Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
  6. written by Bernd Warken <bwarken@mayn.de>
  7. maintained by Werner Lemberg <wl@gnu.org>
  8. Permission is granted to copy, distribute and/or modify this document
  9. under the terms of the GNU Free Documentation License, Version 1.1 or
  10. any later version published by the Free Software Foundation; with the
  11. Invariant Sections being this .ig-section and AUTHORS, with no
  12. Front-Cover Texts, and with no Back-Cover Texts.
  13. A copy of the Free Documentation License is included as a file called
  14. FDL in the main directory of the groff source package.
  15. ..
  16. .
  17. .\" --------------------------------------------------------------------
  18. .\" Setup
  19. .\" --------------------------------------------------------------------
  20. .
  21. .do nr roff_C \n[.C]
  22. .cp 0
  23. .
  24. .mso www.tmac
  25. .
  26. .if n \{\
  27. . mso tty-char.tmac
  28. . ftr CR R
  29. . ftr CI I
  30. . ftr CB B
  31. .\}
  32. .
  33. .if '\*[.T]'dvi' \{\
  34. . ftr CB CW
  35. .\}
  36. .
  37. .
  38. .\" --------------------------------------------------------------------
  39. .\" String definitions
  40. .
  41. .\" Final `\""' comments are used to make Emacs happy, sic \""
  42. .
  43. .\" The `-' sign for options.
  44. .ie t \{\
  45. . ds @- \-\"
  46. . ds @-- \-\-\"
  47. .\}
  48. .el \{\
  49. . ds @- -\"
  50. . ds @-- --\"
  51. .\}
  52. .
  53. .ds Comment \.\[rs]\[dq]\"
  54. .ds Ellipsis \.\|.\|.\&\"
  55. .
  56. .
  57. .\" --------------------------------------------------------------------
  58. .\" Begin of macro definitions
  59. .
  60. .de c
  61. .\" this is like a comment request when escape mechanism is off
  62. ..
  63. .
  64. .eo
  65. .
  66. .c ---------------------------------------------------------------------
  67. .
  68. .de Text
  69. . nop \)\$*
  70. ..
  71. .
  72. .de CodeSkip
  73. . ie t \
  74. . sp 0.2v
  75. . el \
  76. . sp
  77. ..
  78. .
  79. .de Esc
  80. . ds @1 \$1\"
  81. . shift
  82. . Text \f[B]\[rs]\*[@1]\f[]\$*
  83. . rm @1
  84. ..
  85. .
  86. .de QuotedChar
  87. . ds @1 \$1
  88. . shift
  89. . nop `\f[B]\*[@1]\f[]'\$*
  90. . rm @1
  91. ..
  92. .
  93. .c --------------------------------------------------------------------
  94. .
  95. .c a shell command line
  96. .de ShellCommand
  97. . br
  98. . ad l
  99. . nh
  100. . Text \f[I]sh#\h'1m'\f[]\f[CR]\$*\f[]\&\"
  101. . ft R
  102. . ft P
  103. . hy
  104. . ad
  105. ..
  106. .
  107. .c --------------------------------------------------------------------
  108. .
  109. .c ShortOpt ([c [punct]])
  110. .c
  111. .c `-c' somewhere in the text.
  112. .c The second argument is some trailing punctuation.
  113. .c
  114. .de ShortOpt
  115. . ds @1 \$1\"
  116. . shift
  117. . nh
  118. . Text \f[CB]\*[@-]\f[]\f[B]\*[@1]\f[]\/\$*
  119. . hy
  120. . rm @1
  121. ..
  122. .
  123. .de TP+
  124. . br
  125. . ns
  126. . TP \$1
  127. ..
  128. .
  129. .c --------------------------------------------------------------------
  130. .
  131. .c Topic
  132. .c
  133. .de Topic
  134. . TP 2m
  135. . Text \[bu]
  136. ..
  137. .
  138. .ec
  139. .\" End of macro definitions
  140. .
  141. .
  142. .\" --------------------------------------------------------------------
  143. .\" Title
  144. .\" --------------------------------------------------------------------
  145. .
  146. .TH ROFF @MAN7EXT@ "@MDATE@" "Groff Version @VERSION@"
  147. .SH NAME
  148. roff \- concepts and history of roff typesetting
  149. .
  150. .
  151. .\" --------------------------------------------------------------------
  152. .SH DESCRIPTION
  153. .\" --------------------------------------------------------------------
  154. .
  155. .I roff
  156. is the general name for a set of type-setting programs, known under
  157. names like
  158. .IR troff ,
  159. .IR nroff ,
  160. .IR ditroff ,
  161. .IR groff ,
  162. etc.
  163. .
  164. A roff type-setting system consists of an extensible text formatting
  165. language and a set of programs for printing and converting to other
  166. text formats.
  167. .
  168. Traditionally, it is the main text processing system of Unix; every
  169. Unix-like operating system still distributes a roff system as a core
  170. package.
  171. .
  172. .P
  173. The most common roff system today is the free software implementation
  174. .IR "GNU roff",
  175. .BR groff (@MAN1EXT@).
  176. .
  177. The pre-groff implementations are referred to as
  178. .I classical
  179. (dating back as long as 1973).
  180. .
  181. .I groff
  182. implements the look-and-feel and functionality of its classical
  183. ancestors, but has many extensions.
  184. .
  185. As
  186. .I groff
  187. is the only roff system that is available for every (or almost every)
  188. computer system it is the de-facto roff standard today.
  189. .
  190. .P
  191. In some ancient Unix systems, there was a binary called
  192. .B roff
  193. that implemented the even more ancient
  194. .B runoff
  195. of the
  196. .I Multics
  197. operating system, cf. section
  198. .BR HISTORY .
  199. The functionality of this program was very restricted even in
  200. comparison to ancient troff; it is not supported any longer.
  201. .
  202. Consequently, in this document, the term
  203. .I roff
  204. always refers to the general meaning of
  205. .IR "roff system" ,
  206. not to the ancient roff binary.
  207. .
  208. .P
  209. In spite of its age, roff is in wide use today, for example, the manual
  210. pages on UNIX systems
  211. .RI ( man\~pages\/ ),
  212. many software books, system documentation, standards, and corporate
  213. documents are written in roff.
  214. .
  215. The roff output for text devices is still unmatched, and its graphical
  216. output has the same quality as other free type-setting programs and is
  217. better than some of the commercial systems.
  218. .
  219. .P
  220. The most popular application of roff is the concept of
  221. .I manual pages
  222. or shortly
  223. .IR "man pages" ;
  224. this is the standard documentation system on many operating systems.
  225. .
  226. .P
  227. This document describes the historical facts around the development
  228. of the
  229. .IR "roff system" ;
  230. some usage aspects common to all roff versions, details on the roff
  231. pipeline, which is usually hidden behind front-ends like
  232. .BR groff (@MAN1EXT@);
  233. an general overview of the formatting language; some tips for editing
  234. roff files; and many pointers to further readings.
  235. .
  236. .
  237. .\" --------------------------------------------------------------------
  238. .SH "HISTORY"
  239. .\" --------------------------------------------------------------------
  240. .
  241. The
  242. .I roff
  243. text processing system has a very long history, dating back to the
  244. 1960s.
  245. .
  246. The roff system itself is intimately connected to the Unix operating
  247. system, but its roots go back to the earlier operating systems CTSS
  248. and Multics.
  249. .
  250. .
  251. .\" --------------------------------------------------------------------
  252. .SS "The Predecessor runoff"
  253. .\" --------------------------------------------------------------------
  254. .
  255. .P
  256. The evolution of
  257. .I roff
  258. is intimately related to the history of the operating systems.
  259. .
  260. Its predecessor
  261. .B runoff
  262. was written by
  263. .I Jerry Saltzer
  264. on the
  265. .I CTSS
  266. operating system
  267. .RI ( "Compatible Time Sharing System" )
  268. as early as 1961.
  269. .
  270. When CTSS was further developed into the operating system
  271. .URL http://\:www.multicians.org "Multics" ,
  272. the famous predecessor of Unix from 1963,
  273. .I runoff
  274. became the main format for documentation and text processing.
  275. .
  276. Both operating systems could only be run on very expensive computers
  277. at that time, so they were mostly used in research and for official
  278. and military tasks.
  279. .
  280. .P
  281. The possibilities of the
  282. .I runoff
  283. language were quite limited as compared to modern roff.
  284. .
  285. Only text output was possible in the 1960s.
  286. .
  287. This could be implemented by a set of requests of length\~2, many of
  288. which are still identically used in roff.
  289. .
  290. The language was modelled according to the habits of typesetting in
  291. the pre-computer age, where lines starting with a dot were used in
  292. manuscripts to denote formatting requests to the person who would
  293. perform the typesetting manually later on.
  294. .
  295. .P
  296. The runoff program was written in the
  297. .I PL/1
  298. language first, later on in
  299. .IR BCPL ,
  300. the grandmother of the
  301. .IR C \~\c
  302. programming language.
  303. .
  304. In the Multics operating system, the help system was handled by
  305. runoff, similar to roff's task to manage the Unix manual pages.
  306. .
  307. There are still documents written in the runoff language; for examples
  308. see Saltzer's home page, cf. section
  309. .BR "SEE ALSO" .
  310. .
  311. .
  312. .\" --------------------------------------------------------------------
  313. .SS "The Classical nroff/troff System"
  314. .\" --------------------------------------------------------------------
  315. .
  316. In the 1970s, the Multics off-spring
  317. .I Unix
  318. became more and more popular because it could be run on affordable
  319. machines and was easily available for universities at that time.
  320. .
  321. At MIT (the Massachusetts Institute of Technology), there was a need to
  322. drive the Wang
  323. .I Graphic Systems CAT
  324. typesetter, a graphical output device from a PDP-11 computer running
  325. Unix.
  326. .
  327. As runoff was too limited for this task it was further developed into
  328. a more powerful text formatting system by
  329. .IR "Josef F. Osanna" ,
  330. a main developer of the Multics operating system and programmer of
  331. several runoff ports.
  332. .
  333. .P
  334. The name
  335. .I runoff
  336. was shortened to
  337. .IR roff .
  338. The greatly enlarged language of Osanna's concept included already all
  339. elements of a full
  340. .IR "roff system" .
  341. .
  342. All modern roff systems try to implement compatibility to this system.
  343. .
  344. So Joe Osanna can be called the father of all roff systems.
  345. .
  346. .P
  347. This first
  348. .I roff system
  349. had three formatter programs.
  350. .
  351. .TP
  352. .B troff
  353. .RI ( "typesetter roff\/" )
  354. generated a graphical output for the
  355. .I CAT
  356. typesetter as its only device.
  357. .
  358. .TP
  359. .B nroff
  360. produced text output suitable for terminals and line printers.
  361. .
  362. .TP
  363. .B roff
  364. was the reimplementation of the former runoff program with its limited
  365. features; this program was abandoned in later versions.
  366. .
  367. Today, the name
  368. .I roff
  369. is used to refer to a troff/\:nroff sytem as a whole.
  370. .
  371. .P
  372. Osanna first version was written in the PDP-11 assembly language and
  373. released in 1973.
  374. .
  375. .I Brian Kernighan
  376. joined the
  377. .I roff
  378. development by rewriting it in the C\~programming language.
  379. .
  380. The C\~version was released in 1975.
  381. .
  382. .P
  383. The syntax of the formatting language of the
  384. .BR nroff / troff
  385. programs was documented in the famous
  386. .IR "Troff User's Manual [CSTR\~#54]" ,
  387. first published in 1976, with further revisions up to 1992 by Brian
  388. Kernighan.
  389. .
  390. This document is the specification of the
  391. .IR "classical troff" .
  392. All later
  393. .I roff
  394. systems tried to establish compatibility with this specification.
  395. .
  396. .P
  397. After Osanna had died in 1977 by a heart-attack at the age of about\~50,
  398. Kernighan went on with developing troff.
  399. .
  400. The next milestone was to equip troff with a general interface to
  401. support more devices, the intermediate output format and the
  402. postprocessor system.
  403. .
  404. This completed the structure of a
  405. .I "roff system"
  406. as it is still in use today; see section
  407. .BR "USING ROFF" .
  408. .
  409. In 1979, these novelties were described in the paper
  410. .IR "[CSTR\~#97]" .
  411. This new troff version is the basis for all existing newer troff
  412. systems, including
  413. .IR groff .
  414. .
  415. On some systems, this
  416. .I device independent troff
  417. got a binary of its own, called
  418. .BR ditroff (@MAN7EXT@).
  419. .
  420. All modern
  421. .B troff
  422. programs already provide the full ditroff capabilities automatically.
  423. .
  424. .
  425. .\" --------------------------------------------------------------------
  426. .SS "Commercialization"
  427. .\" --------------------------------------------------------------------
  428. .
  429. A major degradation occurred when the easily available Unix\~7
  430. operating system was commercialized.
  431. .
  432. A whole bunch of divergent operating systems emerged, fighting each
  433. other with incompatibilities in their extensions.
  434. .
  435. Luckily, the incompatibilities did not fight the original troff.
  436. .
  437. All of the different commercial roff systems made heavy use of
  438. Osanna/\:Kernighan's open source code and documentation, but sold them
  439. as \[lq]their\[rq] system \[em] with only minor additions.
  440. .
  441. .P
  442. The source code of both the ancient Unix and classical troff weren't
  443. available for two decades.
  444. .
  445. Fortunately, Caldera bought SCO UNIX in 2001.
  446. .
  447. In the following, Caldera made the ancient source code accessible
  448. on-line for non-commercial use, cf. section
  449. .BR "SEE ALSO" .
  450. .
  451. .
  452. .\" --------------------------------------------------------------------
  453. .SS "Free roff"
  454. .\" --------------------------------------------------------------------
  455. .
  456. None of the commercial roff systems could attain the status of a
  457. successor for the general roff development.
  458. .
  459. Everyone was only interested in their own stuff.
  460. .
  461. This led to a steep downfall of the once excellent
  462. Unix operating system during the 1980s.
  463. .
  464. .P
  465. As a counter-measure to the galopping commercialization, AT&T Bell
  466. Labs tried to launch a rescue project with their
  467. .I Plan\~9
  468. operating system.
  469. .
  470. It is freely available for non-commercial use, even the source code,
  471. but has a proprietary license that impedes the free development.
  472. .
  473. This concept is outdated, so Plan\~9 was not accepted as a platform to
  474. bundle the main-stream development.
  475. .
  476. .P
  477. The only remedy came from the emerging free operatings systems
  478. (386BSD, GNU/\:Linux, etc.) and software projects during the 1980s and
  479. 1990s.
  480. .
  481. These implemented the ancient Unix features and many extensions, such
  482. that the old experience is not lost.
  483. .
  484. In the 21st century, Unix-like systems are again a major factor in
  485. computer industry \[em] thanks to free software.
  486. .
  487. .P
  488. The most important free roff project was the GNU port of troff,
  489. created by James Clark and put under the
  490. .URL http://\:www.gnu.org/\:copyleft "GNU Public License" .
  491. .
  492. It was called
  493. .I groff
  494. .RI ( "GNU roff" ).
  495. See
  496. .BR groff (@MAN1EXT@)
  497. for an overview.
  498. .
  499. .P
  500. The groff system is still actively developed.
  501. .
  502. It is compatible to the classical troff, but many extensions were
  503. added.
  504. .
  505. It is the first roff system that is available on almost all operating
  506. systems \[em] and it is free.
  507. .
  508. This makes groff the de-facto roff standard today.
  509. .
  510. .
  511. .\" --------------------------------------------------------------------
  512. .SH "USING ROFF"
  513. .\" --------------------------------------------------------------------
  514. .
  515. Most people won't even notice that they are actually using roff.
  516. .
  517. When you read a system manual page (man page) roff is working in the
  518. background.
  519. .
  520. Roff documents can be viewed with a native viewer called
  521. .BR \%xditview (1x),
  522. a standard program of the X window distribution, see
  523. .BR X (7x).
  524. .
  525. But using roff explicitly isn't difficult either.
  526. .
  527. .P
  528. Some roff implementations provide wrapper programs that make it easy
  529. to use the roff system on the shell command line.
  530. .
  531. For example, the GNU roff implementation
  532. .BR groff (@MAN1EXT@)
  533. provides command line options to avoid the long command pipes of
  534. classical troff; a program
  535. .BR grog (@MAN1EXT@)
  536. tries to guess from the document which arguments should be used for a
  537. run of groff; people who do not like specifying command line options
  538. should try the
  539. .BR groffer (@MAN1EXT@)
  540. program for graphically displaying groff files and man pages.
  541. .
  542. .
  543. .\" --------------------------------------------------------------------
  544. .SS "The roff Pipe"
  545. .\" --------------------------------------------------------------------
  546. .
  547. Each roff system consists of preprocessors, roff formatter programs,
  548. and a set of device postprocessors.
  549. .
  550. This concept makes heavy use of the
  551. .I piping
  552. mechanism, that is, a series of programs is called one after the other,
  553. where the output of each program in the queue is taken as the input
  554. for the next program.
  555. .
  556. .CodeSkip
  557. .
  558. .ds @1 "cat \f[I]file\f[P] |\""
  559. .ds @2 "\*[Ellipsis] | \f[I]preproc\f[P] | \*[Ellipsis] |\""
  560. .ds @3 "troff \f[I]options\f[P] | \f[I]postproc\f[P]\""
  561. .
  562. .ShellCommand "\*[@1] \*[@2] \*[@3]"
  563. .
  564. .rm @1
  565. .rm @2
  566. .rm @3
  567. .P
  568. The preprocessors generate roff code that is fed into a roff formatter
  569. (e.g. troff), which in turn generates
  570. .I intermediate output
  571. that is fed into a device postprocessor program for printing or final
  572. output.
  573. .
  574. .P
  575. All of these parts use programming languages of their own; each
  576. language is totally unrelated to the other parts.
  577. .
  578. Moreover, roff macro packages that were tailored for special purposes
  579. can be included.
  580. .
  581. .P
  582. Most roff documents use the macros of some package, intermixed with
  583. code for one or more preprocessors, spiced with some elements from the
  584. plain roff language.
  585. .
  586. The full power of the roff formatting language is seldom needed by
  587. users; only programmers of macro packages need to know about the gory
  588. details.
  589. .
  590. .
  591. .
  592. .\" --------------------------------------------------------------------
  593. .SS "Preprocessors"
  594. .\" --------------------------------------------------------------------
  595. .
  596. A roff preprocessor is any program that generates output that
  597. syntactically obeys the rules of the roff formatting language.
  598. .
  599. Each preprocessor defines a language of its own that is translated
  600. into roff code when run through the preprocessor program.
  601. .
  602. Parts written in these languages may be included within a roff
  603. document; they are identified by special roff requests or macros.
  604. .
  605. Each document that is enhanced by preprocessor code must be run
  606. through all corresponding preprocessors before it is fed into the
  607. actual roff formatter program, for the formatter just ignores all
  608. alien code.
  609. .
  610. The preprocessor programs extract and transform only the document
  611. parts that are determined for them.
  612. .
  613. .P
  614. There are a lot of free and commercial roff preprocessors.
  615. .
  616. Some of them aren't available on each system, but there is a small
  617. set of preprocessors that are considered as an integral part of each
  618. roff system.
  619. .
  620. The classical preprocessors are
  621. .
  622. .de @TP
  623. .\" local indent for .TP
  624. .TP \\w'\\f[B]soelim\\f[P]'u+2n
  625. ..
  626. .P
  627. .RS
  628. .PD 0
  629. .@TP
  630. .B tbl
  631. for tables
  632. .@TP
  633. .B eqn
  634. for mathematical formul\[ae]
  635. .@TP
  636. .B pic
  637. for drawing diagrams
  638. .@TP
  639. .B refer
  640. for bibliographic references
  641. .@TP
  642. .B soelim
  643. for including macro files from standard locations
  644. .PD
  645. .RE
  646. .
  647. .P
  648. Other known preprocessors that are not available on all systems
  649. include
  650. .
  651. .P
  652. .RS
  653. .PD 0
  654. .@TP
  655. .B chem
  656. for drawing chemical formul\[ae].
  657. .@TP
  658. .B grap
  659. for constructing graphical elements.
  660. .@TP
  661. .B grn
  662. for including
  663. .BR gremlin (1)
  664. pictures.
  665. .PD
  666. .RE
  667. .
  668. .rm @TP
  669. .
  670. .\" --------------------------------------------------------------------
  671. .SS "Formatter Programs"
  672. .\" --------------------------------------------------------------------
  673. .
  674. A
  675. .I roff formatter
  676. is a program that parses documents written in the roff formatting
  677. language or uses some of the roff macro packages.
  678. .
  679. It generates
  680. .IR "intermediate output" ,
  681. which is intended to be fed into a single device postprocessor that
  682. must be specified by a command-line option to the formatter program.
  683. .
  684. The documents must have been run through all necessary preprocessors
  685. before.
  686. .
  687. .P
  688. The output produced by a roff formatter is represented in yet another
  689. language, the
  690. .IR "intermediate output format"
  691. or
  692. .IR "troff output" .
  693. This language was first specified in
  694. .IR "[CSTR\~#97]" ;
  695. its GNU extension is documented in
  696. .BR groff_out (@MAN5EXT@).
  697. .
  698. The intermediate output language is a kind of assembly language
  699. compared to the high-level roff language.
  700. .
  701. The generated intermediate output is optimized for a special device,
  702. but the language is the same for every device.
  703. .
  704. .P
  705. The roff formatter is the heart of the roff system.
  706. .
  707. The traditional roff had two formatters,
  708. .B nroff
  709. for text devices and
  710. .B troff
  711. for graphical devices.
  712. .
  713. .P
  714. Often, the name
  715. .I troff
  716. is used as a general term to refer to both formatters.
  717. .
  718. .
  719. .\" --------------------------------------------------------------------
  720. .SS "Devices and Postprocessors"
  721. .\" --------------------------------------------------------------------
  722. .
  723. Devices are hardware interfaces like printers, text or graphical
  724. terminals, etc., or software interfaces such as a conversion into a
  725. different text or graphical format.
  726. .
  727. .P
  728. A roff postprocessor is a program that transforms troff output into a
  729. form suitable for a special device.
  730. .
  731. The roff postprocessors are like device drivers for the output target.
  732. .
  733. .P
  734. For each device there is a postprocessor program that fits the device
  735. optimally.
  736. .
  737. The postprocessor parses the generated intermediate output and
  738. generates device-specific code that is sent directly to the device.
  739. .
  740. .P
  741. The names of the devices and the postprocessor programs are not fixed
  742. because they greatly depend on the software and hardware abilities of
  743. the actual computer.
  744. .
  745. For example, the classical devices mentioned in
  746. .I [CSTR\~#54]
  747. have greatly changed since the classical times.
  748. .
  749. The old hardware doesn't exist any longer and the old graphical
  750. conversions were quite imprecise when compared to their modern
  751. counterparts.
  752. .
  753. .P
  754. For example, the Postscript device
  755. .I post
  756. in classical troff had a resolution
  757. of 720, while groff's
  758. .I ps
  759. device has 72000, a refinement of factor 100.
  760. .
  761. .P
  762. Today the operating systems provide device drivers for most
  763. printer-like hardware, so it isn't necessary to write a special
  764. hardware postprocessor for each printer.
  765. .
  766. .
  767. .\" --------------------------------------------------------------------
  768. .SH "ROFF PROGRAMMING"
  769. .\" --------------------------------------------------------------------
  770. .
  771. Documents using roff are normal text files decorated by roff
  772. formatting elements.
  773. .
  774. The roff formatting language is quite powerful; it is almost a full
  775. programming language and provides elements to enlarge the language.
  776. .
  777. With these, it became possible to develop macro packages that are
  778. tailored for special applications.
  779. .
  780. Such macro packages are much handier than plain roff.
  781. .
  782. So most people will choose a macro package without worrying about the
  783. internals of the roff language.
  784. .
  785. .
  786. .\" --------------------------------------------------------------------
  787. .SS "Macro Packages"
  788. .\" --------------------------------------------------------------------
  789. .
  790. Macro packages are collections of macros that are suitable to format a
  791. special kind of documents in a convenient way.
  792. .
  793. This greatly eases the usage of roff.
  794. .
  795. The macro definitions of a package are kept in a file called
  796. .IB name .tmac
  797. (classically
  798. .BI tmac. name\c
  799. ).
  800. .
  801. All tmac files are stored in one or more directories at standardized
  802. positions.
  803. .
  804. Details on the naming of macro packages and their placement is found
  805. in
  806. .BR groff_tmac (@MAN5EXT@).
  807. .
  808. .P
  809. A macro package that is to be used in a document can be announced to
  810. the formatter by the command line option
  811. .ShortOpt m ,
  812. see
  813. .BR troff (@MAN1EXT@),
  814. or it can be specified within a document using the file inclusion
  815. requests of the roff language, see
  816. .BR groff (@MAN7EXT@).
  817. .
  818. .P
  819. Famous classical macro packages are
  820. .I man
  821. for traditional man pages,
  822. .I mdoc
  823. for BSD-style manual pages;
  824. the macro sets for books, articles, and letters are
  825. .I me
  826. (probably from the first name of its creator
  827. .I Eric
  828. Allman),
  829. .I ms
  830. (from
  831. .IR "Manuscript Macros\/" ),
  832. and
  833. .I mm
  834. (from
  835. .IR "Memorandum Macros\/" ).
  836. .
  837. .
  838. .\" --------------------------------------------------------------------
  839. .SS "The roff Formatting Language"
  840. .\" --------------------------------------------------------------------
  841. .
  842. The classical roff formatting language is documented in the
  843. .I Troff User's Manual
  844. .IR "[CSTR\~#54]" .
  845. .
  846. The roff language is a full programming language providing requests,
  847. definition of macros, escape sequences, string variables, number or
  848. size registers, and flow controls.
  849. .
  850. .P
  851. .I Requests
  852. are the predefined basic formatting commands similar to the commands
  853. at the shell prompt.
  854. .
  855. The user can define request-like elements using predefined roff
  856. elements.
  857. .
  858. These are then called
  859. .IR macros .
  860. .
  861. A document writer will not note any difference in usage for requests
  862. or macros; both are written on a line on their own starting with a dot.
  863. .
  864. .P
  865. .I Escape sequences
  866. are roff elements starting with a backslash
  867. .QuotedChar \[rs] .
  868. They can be inserted anywhere, also in the midst of text in a line.
  869. .
  870. They are used to implement various features, including the insertion of
  871. non-ASCII characters with
  872. .Esc ( ,
  873. font changes with
  874. .Esc f ,
  875. in-line comments with
  876. .Esc \[dq] ,
  877. the escaping of special control characters like
  878. .Esc \[rs] ,
  879. and many other features.
  880. .
  881. .P
  882. .I Strings
  883. are variables that can store a string.
  884. .
  885. A string is stored by the
  886. .B .ds
  887. request.
  888. .
  889. The stored string can be retrieved later by the
  890. .B \[rs]*
  891. escape sequence.
  892. .
  893. .P
  894. .I Registers
  895. store numbers and sizes.
  896. .
  897. A register can be set with the request
  898. .B .nr
  899. and its value can be retrieved by the escape sequence
  900. .BR "\[rs]n" .
  901. .
  902. .
  903. .\" --------------------------------------------------------------------
  904. .SH "FILE NAME EXTENSIONS"
  905. .\" --------------------------------------------------------------------
  906. .
  907. Manual pages (man pages) take the section number as a file name
  908. extension, e.g., the filename for this document is
  909. .IR roff.7 ,
  910. i.e., it is kept in section\~7
  911. of the man pages.
  912. .
  913. .P
  914. The classical macro packages take the package name as an extension, e.g.
  915. .IB file. me
  916. for a document using the
  917. .I me
  918. macro package,
  919. .IB file. mm
  920. for
  921. .IR mm ,
  922. .IB file. ms
  923. for
  924. .IR ms ,
  925. .IB file. pic
  926. for
  927. .I pic
  928. files,
  929. etc.
  930. .
  931. .P
  932. But there is no general naming scheme for roff documents, though
  933. .IB file. tr
  934. for
  935. .I troff file
  936. is seen now and then.
  937. .
  938. Maybe there should be a standardization for the filename extensions of
  939. roff files.
  940. .
  941. .P
  942. File name extensions can be very handy in conjunction with the
  943. .BR less (1)
  944. pager.
  945. .
  946. It provides the possibility to feed all input into a command-line pipe
  947. that is specified in the shell environment variable
  948. .BR LESSOPEN .
  949. This process is not well documented, so here an example:
  950. .
  951. .CodeSkip
  952. .ShellCommand LESSOPEN='|lesspipe %s'
  953. .CodeSkip
  954. .
  955. where
  956. .B lesspipe
  957. is either a system supplied command or a shell script of your own.
  958. .
  959. .
  960. .\" --------------------------------------------------------------------
  961. .SH "EDITING ROFF"
  962. .\" --------------------------------------------------------------------
  963. .
  964. The best program for editing a roff document is Emacs (or Xemacs), see
  965. .BR emacs (1).
  966. It provides an
  967. .I nroff
  968. mode that is suitable for all kinds of roff dialects.
  969. .
  970. This mode can be activated by the following methods.
  971. .
  972. .P
  973. When editing a file within Emacs the mode can be changed by typing
  974. .RI ` "M-x nroff-mode" ',
  975. where
  976. .B M-x
  977. means to hold down the
  978. .B Meta
  979. key (or
  980. .BR Alt )
  981. and hitting the
  982. .BR x\~ key
  983. at the same time.
  984. .
  985. .P
  986. But it is also possible to have the mode automatically selected when
  987. the file is loaded into the editor.
  988. .
  989. .Topic
  990. The most general method is to include the following 3 comment lines at
  991. the end of the file.
  992. .
  993. .CodeSkip
  994. .nf
  995. .B \*[Comment] Local Variables:
  996. .B \*[Comment] mode: nroff
  997. .B \*[Comment] End:
  998. .fi
  999. .
  1000. .Topic
  1001. There is a set of file name extensions, e.g. the man pages that
  1002. trigger the automatic activation of the nroff mode.
  1003. .
  1004. .Topic
  1005. Theoretically, it is possible to write the sequence
  1006. .CodeSkip
  1007. .B \*[Comment] \%-*-\ nroff\ -*-
  1008. .CodeSkip
  1009. as the first line of a file to have it started in nroff mode when
  1010. loaded.
  1011. .
  1012. Unfortunately, some applications such as the
  1013. .B man
  1014. program are confused by this; so this is deprecated.
  1015. .
  1016. .P
  1017. All roff formatters provide automated line breaks and horizontal and
  1018. vertical spacing.
  1019. .
  1020. In order to not disturb this, the following tips can be helpful.
  1021. .
  1022. .Topic
  1023. Never include empty or blank lines in a roff document.
  1024. .
  1025. Instead, use the empty request (a line consisting of a dot only) or a
  1026. line comment
  1027. .B \*[Comment]
  1028. if a structuring element is needed.
  1029. .
  1030. .Topic
  1031. Never start a line with whitespace because this can lead to
  1032. unexpected behavior.
  1033. .
  1034. Indented paragraphs can be constructed in a controlled way by roff
  1035. requests.
  1036. .
  1037. .Topic
  1038. Start each sentence on a line of its own, for the spacing after a dot
  1039. is handled differently depending on whether it terminates an
  1040. abbreviation or a sentence.
  1041. .
  1042. To distinguish both cases, do a line break after each sentence.
  1043. .
  1044. .Topic
  1045. To additionally use the auto-fill mode in Emacs, it is best to insert
  1046. an empty roff request (a line consisting of a dot only) after each
  1047. sentence.
  1048. .
  1049. .P
  1050. The following example shows how optimal roff editing could look.
  1051. .
  1052. .IP
  1053. .nf
  1054. This is an example for a roff document.
  1055. .Text .
  1056. This is the next sentence in the same paragraph.
  1057. .Text .
  1058. This is a longer sentence stretching over several
  1059. lines; abbreviations like `cf.' are easily
  1060. identified because the dot is not followed by a
  1061. line break.
  1062. .Text .
  1063. In the output, this will still go to the same
  1064. paragraph.
  1065. .fi
  1066. .
  1067. .P
  1068. Besides Emacs, some other editors provide nroff style files too, e.g.\&
  1069. .BR vim (1),
  1070. an extension of the
  1071. .BR vi (1)
  1072. program.
  1073. .
  1074. .
  1075. .\" --------------------------------------------------------------------
  1076. .SH BUGS
  1077. .\" --------------------------------------------------------------------
  1078. .
  1079. .I UNIX\[rg]
  1080. is a registered trademark of the Open Group.
  1081. .
  1082. But things have improved considerably after Caldera had bought SCO
  1083. UNIX in 2001.
  1084. .
  1085. .
  1086. .\" --------------------------------------------------------------------
  1087. .SH "SEE ALSO"
  1088. .\" --------------------------------------------------------------------
  1089. .
  1090. There is a lot of documentation on roff.
  1091. .
  1092. The original papers on classical troff are still available, and all
  1093. aspects of groff are documented in great detail.
  1094. .
  1095. .
  1096. .\" --------------------------------------------------------------------
  1097. .SS "Internet sites"
  1098. .\" --------------------------------------------------------------------
  1099. .
  1100. .TP
  1101. troff.org
  1102. .URL http://\:www.troff.org "The historical troff site"
  1103. provides an overview and pointers to all historical aspects of roff.
  1104. .
  1105. .TP
  1106. Multics
  1107. .URL http://\:www.multicians.org "The Multics site"
  1108. contains a lot of information on the MIT projects, CTSS, Multics,
  1109. early Unix, including
  1110. .IR runoff ;
  1111. especially useful are a glossary and the many links to ancient
  1112. documents.
  1113. .
  1114. .TP
  1115. Unix Archive
  1116. .URL http://\:www.tuhs.org/\:Archive/ \
  1117. "The Ancient Unixes Archive"
  1118. .
  1119. provides the source code and some binaries of the ancient Unixes
  1120. (including the source code of troff and its documentation) that were
  1121. made public by Caldera since 2001, e.g. of the famous Unix version\~7
  1122. for PDP-11 at the
  1123. .URL http://\:www.tuhs.org/\:Archive/\:PDP-11/\:Trees/\:V7 \
  1124. "Unix V7 site" .
  1125. .
  1126. .TP
  1127. Developers at AT&T Bell Labs
  1128. .URL http://\:cm.bell-labs.com/\:cm/\:index.html \
  1129. "Bell Labs Computing and Mathematical Sciences Research"
  1130. .
  1131. provides a search facility for tracking information on the early
  1132. developers.
  1133. .
  1134. .TP
  1135. Plan 9
  1136. .URL http://\:plan9.bell-labs.com "The Plan\~9 operating system"
  1137. .
  1138. by AT&T Bell Labs.
  1139. .
  1140. .TP
  1141. runoff
  1142. .URL http://web.mit.edu/\:Saltzer/\:www/\:publications/\:pubs.html \
  1143. "Jerry Saltzer's home page"
  1144. .
  1145. stores some documents using the ancient runoff formatting language.
  1146. .
  1147. .TP
  1148. CSTR Papers
  1149. .URL http://\:cm.bell-labs.com/\:cm/\:cs/\:cstr.html \
  1150. "The Bell Labs CSTR site"
  1151. .
  1152. stores the original troff manuals (CSTR #54, #97, #114, #116, #122)
  1153. and famous historical documents on programming.
  1154. .
  1155. .TP
  1156. GNU roff
  1157. .URL http://\:www.gnu.org/\:software/\:groff "The groff web site"
  1158. provides the free roff implementation groff, the actual standard roff.
  1159. .
  1160. .
  1161. .\" --------------------------------------------------------------------
  1162. .SS "Historical roff Documentation"
  1163. .\" --------------------------------------------------------------------
  1164. .
  1165. Many classical
  1166. .B troff
  1167. documents are still available on-line.
  1168. .
  1169. The two main manuals of the troff language are
  1170. .
  1171. .TP
  1172. [CSTR\~#54]
  1173. J. F. Osanna,
  1174. .URL http://\:cm.bell-labs.com/\:cm/\:cs/\:54.ps \
  1175. "\fINroff/\:Troff User's Manual\fP" ;
  1176. .
  1177. Bell Labs, 1976; revised by Brian Kernighan, 1992.
  1178. .
  1179. .TP
  1180. [CSTR\~#97]
  1181. Brian Kernighan,
  1182. .URL http://\:cm.bell-labs.com/\:cm/\:cs/\:97.ps \
  1183. "\fIA Typesetter-independent TROFF\fP" ,
  1184. .
  1185. Bell Labs, 1981, revised March 1982.
  1186. .
  1187. .P
  1188. The "little language" roff papers are
  1189. .
  1190. .TP
  1191. [CSTR\~#114]
  1192. Jon L. Bentley and Brian W. Kernighan,
  1193. .URL http://\:cm.bell-labs.com/\:cm/\:cs/\:114.ps \
  1194. "\fIGRAP \(em A Language for Typesetting Graphs\fP" ;
  1195. .
  1196. Bell Labs, August 1984.
  1197. .
  1198. .TP
  1199. [CSTR\~#116]
  1200. Brian W. Kernighan,
  1201. .URL http://\:cm.bell-labs.com/\:cm/\:cs/\:116.ps \
  1202. "\fIPIC -- A Graphics Language for Typesetting\fP" ;
  1203. .
  1204. Bell Labs, December 1984.
  1205. .
  1206. .TP
  1207. [CSTR\~#122]
  1208. J. L. Bentley, L. W. Jelinski, and B. W. Kernighan,
  1209. .URL http://\:cm.bell-labs.com/\:cm/\:cs/\:122.ps \
  1210. "\fICHEM \(em A Program for Typesetting Chemical Structure Diagrams, \
  1211. Computers and Chemistry\fP" ;
  1212. .
  1213. Bell Labs, April 1986.
  1214. .
  1215. .
  1216. .\" --------------------------------------------------------------------
  1217. .SS "Manual Pages"
  1218. .\" --------------------------------------------------------------------
  1219. .
  1220. Due to its complex structure, a full roff system has many man pages,
  1221. each describing a single aspect of roff.
  1222. .
  1223. Unfortunately, there is no general naming scheme for the
  1224. documentation among the different roff implementations.
  1225. .
  1226. .P
  1227. In
  1228. .IR groff ,
  1229. the man page
  1230. .BR groff (@MAN1EXT@)
  1231. contains a survey of all documentation available in groff.
  1232. .
  1233. .P
  1234. On other systems, you are on your own, but
  1235. .BR troff (1)
  1236. might be a good starting point.
  1237. .
  1238. .
  1239. .\" --------------------------------------------------------------------
  1240. .SH AUTHORS
  1241. .\" --------------------------------------------------------------------
  1242. .
  1243. Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
  1244. .
  1245. .P
  1246. This document is distributed under the terms of the FDL (GNU Free
  1247. Documentation License) version 1.1 or later.
  1248. .
  1249. You should have received a copy of the FDL on your system, it is also
  1250. available on-line at the
  1251. .URL http://\:www.gnu.org/\:copyleft/\:fdl.html "GNU copyleft site" .
  1252. .
  1253. .P
  1254. This document is part of
  1255. .IR groff ,
  1256. the GNU roff distribution.
  1257. .
  1258. It was written by
  1259. .MTO bwarken@mayn.de "Bernd Warken" ;
  1260. it is maintained by
  1261. .MTO wl@gnu.org "Werner Lemberg".
  1262. .
  1263. .cp \n[roff_C]
  1264. .
  1265. .\" --------------------------------------------------------------------
  1266. .\" Emacs setup
  1267. .\" --------------------------------------------------------------------
  1268. .
  1269. .\" Local Variables:
  1270. .\" mode: nroff
  1271. .\" End: