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