Added new font `SC' (cmtex10) to devdvi.
[s-roff.git] / man / groff_tmac.man
blobf8b34523847778c03a98a2bb93b4f7a8476701df
2 .TH GROFF_TMAC @MAN5EXT@ "@MDATE@" "Groff Version @VERSION@"
3 .SH NAME
4 groff_tmac \- macro files in the roff typesetting system
5 .SH DESCRIPTION
6 .\" The .SH was moved to this place to make `apropos' happy.
9 .\" --------------------------------------------------------------------
10 .\" Legalize
11 .\" --------------------------------------------------------------------
13 .ig
14 groff_tmac.5
16 File position: <groff-source>/man/groff_tmac.man
18 Last update: 20 Oct 2002
20 This file is part of groff, the GNU roff type-setting system.
22 Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
23 written by Bernd Warken <bwarken@mayn.de> and Werner Lemberg
24 <wl@gnu.org>
26 Permission is granted to copy, distribute and/or modify this document
27 under the terms of the GNU Free Documentation License, Version 1.1 or
28 any later version published by the Free Software Foundation; with the
29 Invariant Sections being this .ig-section and AUTHOR, with no
30 Front-Cover Texts, and with no Back-Cover Texts.
32 A copy of the Free Documentation License is included as a file called
33 FDL in the main directory of the groff source package.
36 .\" --------------------------------------------------------------------
37 .\" Setup
38 .\" --------------------------------------------------------------------
40 .mso www.tmac
42 .if n \{\
43 .  mso tty-char.tmac
44 .  ftr CR R
45 .  ftr CI I
46 .  ftr CB B
47 .\}
49 .ds Ellipsis \&.\|.\|.\&\"
51 .\" Global static variables for inter-macro communication
52 .rr @+Example_font
54 .\" --------------------------------------------------------------------
55 .\" setup for the macro definitions below
56 .\"
57 .\" naming:  namespace:cathegory_macro.variable_name  (experimental)
59 .\" --------------------------------------------------------------------
60 .\" configuration of prompt for `.Shell_cmd'* macros
61 .ds groffer:Shell_cmd.prompt_text sh#\"    prompt for shell commands
62 .ds groffer:Shell_cmd+.prompt_text >\"     prompt on continuation lines
63 .ds groffer:Shell_cmd_base.prompt_font I\" font for prompts
65 .\" automatically determine setup from the configuration above
66 .als @f groffer:Shell_cmd_base.prompt_font\"
67 .als @t groffer:Shell_cmd.prompt_text\"
68 .als @t+ groffer:Shell_cmd+.prompt_text\"
69 .ds groffer:Shell_cmd.prompt \f[\*[@f]]\*[@t]\f[]\"            needed
70 .ds groffer:Shell_cmd+.prompt \f[\*[@f]]\*[@t+]\f[]\"          needed
71 .nr @w \w'\*[groffer:Shell_cmd.prompt]'\"
72 .nr @w+ \w'\*[groffer:Shell_cmd+.prompt]'\"
73 .ft \*[@f]
74 .\" Full prompt width is maximum of texts plus 1m
75 .nr groffer:Shell_cmd_base.prompt_width (\n[@w]>?\n[@w+]+1m)\" needed
76 .ft
77 .rm @f
78 .rm @f+
79 .rm @t
80 .rm @t+
81 .rr @w
82 .rr @w+
84 .\"--------------------------------------------------------------------
85 .\" Ignore all arguments like a comment, even after a .eo call.
86 .de c
88 .c --------------------------------------------------------------------
89 .de BIR
90 .  ie (\\n[.$] < 3) \
91 .    BI \\$@
92 .  el \{\
93 .    ds @tmp@ \fB\\$1\f[]\fI\\$2\f[]
94 .    shift 2
95 .    Text \\*[@tmp@]\fR\\$*\f[]
96 .    rm @tmp@
97 .  \}
99 .c --------------------------------------------------------------------
100 .c .Env_var  (<env_var_name> [<punct>])
102 .c Display an environment variable, with optional punctuation.
104 .de Env_var
105 .  nh
106 .  SM
107 .  Text \f[CB]\\$1\f[]\\$2
108 .  hy
110 .c --------------------------------------------------------------------
111 .c .Error  (<text>...)
113 .c Print error message to terminal and abort.
115 .de Error
116 .  tm \\$*
117 .  ab
119 .c --------------------------------------------------------------------
120 .de Example
121 .  if r@+Example_font \
122 .    Error previous .Example was not terminated by a ./Example
123 .  nr @+Example_font \\n[.f]
124 .  nh
125 .  nf
126 .  RS
127 .  ft CR
129 .c --------------------------------------------------------------------
130 .de /Example
131 .  if !r@+Example_font \
132 .    Error no previous call to .Example
133 .  ft \\n[@+Example_font]
134 .  RE
135 .  fi
136 .  hy
137 .  rr @+Example_font
140 .c --------------------------------------------------------------------
141 .c .Shell_cmd  (<CR> [<CI>] ...)
143 .c A shell command line; display args alternating in fonts CR and CI.
145 .c Examples:
146 .c   .Shell_cmd "groffer --dpi 100 file"
147 .c     result: `sh#  groffer --dpi 100 file'
148 .c             with 'sh#' in font I, the rest in CR
150 .c   .Shell_cmd groffer\~--dpi\~100\~file
151 .c     result: the same as above
153 .c   .Shell_cmd "groffer --dpi=" value " file"
154 .c     result: sh#  groffer --dpi=value file
155 .c             with `groffer --dpi=' and `file' in CR; `value' in CI
157 .c   .Shell_cmd groffer\~--dpi= value \~file
158 .c     result: the same as the previous example
160 .de Shell_cmd
161 .  groffer:Shell_cmd_base "\*[groffer:Shell_cmd.prompt]" \\$@
163 .c --------------------------------------------------------------------
164 .c .Shell_cmd+  (<CR> [<CI>] ...)
166 .c A continuation line for .Shell_cmd.
168 .de Shell_cmd+
169 .  groffer:Shell_cmd_base "\*[groffer:Shell_cmd+.prompt]" \\$@
171 .c --------------------------------------------------------------------
172 .c .Shell_cmd_base  (<prompt> [<CR> [<CI>] ...])
174 .c A shell command line; display args alternating in fonts CR and CI.
175 .c Internal, do not use directly.
177 .c Globals: read-only register @.Shell_cmd_width
179 .de groffer:Shell_cmd_base
180 .  if (\\n[.$] <= 0) \
181 .    return
182 .  nr @+font \\n[.f]\"
183 .  ds @prompt \\$1\"
184 .  ft CR
185 .  c gap between prompt and command
186 .  nr @+gap \\n[groffer:Shell_cmd_base.prompt_width]-\\w'\\*[@prompt]'\"
187 .  ds @res \\*[@prompt]\h'\\n[@+gap]u'\"
188 .  shift
189 .  ds @cf CR\"
190 .  while (\\n[.$] > 0) \{\
191 .    as @res \\f[\\*[@cf]]\\$1\"
192 .    shift
193 .    ie '\\*[@cf]'CR' \
194 .      ds @cf I\"
195 .    el \
196 .      ds @cf CR\"
197 .  \}
198 .  br
199 .  ad l
200 .  nh
201 .  nf
202 .  Text \\*[@res]\"
203 .  fi
204 .  hy
205 .  ad
206 .  br
207 .  ft \\n[@+font]
208 .  rr @+font
209 .  rr @+gap
210 .  rm @cf
211 .  rm @res
213 .c --------------------------------------------------------------------
214 .c .Text  (<text>...)
216 .c Treat the arguments as text, no matter how they look.
218 .de Text
219 .  if (\\n[.$] == 0) \
220 .    return
221 .  nop \)\\$*\)
223 .c --------------------------------------------------------------------
224 .c .Topic  ([<indent>])
226 .c A bulleted paragraph
228 .de Topic
229 .  ie (\\n[.$] = 0) \
230 .    ds @indent 2m\"
231 .  el \
232 .    ds @indent \\$1\"
233 .  TP \\*[@indent]
234 .  Text \[bu]
235 .  rm @indent
237 .c --------------------------------------------------------------------
238 .c .TP+  ()
240 .c Continuation line for .TP header.
242 .de TP+
243 .  br
244 .  ns
245 .  TP \\$1
247 .c --------------------------------------------------------------------
248 .de 'char
249 .  ds @tmp@ `\f(CR\\$1\f[]'
250 .  shift
251 .  Text \\*[@tmp@]\\$*
252 .  rm @tmp@
254 .c --------------------------------------------------------------------
255 .de option
256 .  ds @tmp@ \f(CB\\$1\f[]
257 .  shift 1
258 .  Text \\*[@tmp@]\\$*
259 .  rm @tmp@
261 .c --------------------------------------------------------------------
262 .de argument
263 .  ds @tmp@ \f(CI\\$1\f[]
264 .  shift 1
265 .  Text \\*[@tmp@]\\$*
266 .  rm @tmp@
268 .c --------------------------------------------------------------------
269 .de request
270 .  ds @tmp@ \f(CB\\$1\f[]
271 .  shift 1
272 .  Text .\\*[@tmp@]\\$*
273 .  rm @tmp@
275 .c --------------------------------------------------------------------
276 .de escape
277 .  ds @tmp@ \f[CB]\\$1\f[]
278 .  shift 1
279 .  Text \[rs]\\*[@tmp@]\\$*
280 .  rm @tmp@
282 .\" --------------------------------------------------------------------
283 .\" SH DESCRIPTION
284 .\" --------------------------------------------------------------------
287 .BR roff (@MAN7EXT@)
288 type-setting system provides a set of macro packages suitable for
289 special kinds of documents.
291 Each macro package stores its macros and definitions in a file called
292 the package's
293 .BR "tmac file" .
294 The name is deduced from
295 .RB ` T\c
296 .IB roff MAC\c
297 .IR ros '.
300 The tmac files are normal roff source documents, except that they
301 usually contain only definitions and setup commands, but no text.
303 All tmac files are kept in a single or a small number of directories,
305 .B tmac
306 directories.
309 .\" --------------------------------------------------------------------
310 .SH "GROFF MACRO PACKAGES"
311 .\" --------------------------------------------------------------------
313 .I groff
314 provides all classical macro packages, some more full packages, and
315 some secondary packages for special purposes.
317 Note that it is not possible to use multiple primary macro packages at the
318 same time; saying e.g.\&
321 .Shell_cmd "groff \-m man \-m ms foo"
327 .Shell_cmd "groff \-m man foo \-m ms bar"
330 will fail.
333 .\" --------------------------------------------------------------------
334 .SS "Man\~Pages"
335 .\" --------------------------------------------------------------------
338 .B man
339 This is the classical macro package for UNIX manual pages
340 (man\~pages); it is quite handy and easy to use; see
341 .BR groff_man (@MAN7EXT@).
344 .B doc
345 .TP+
346 .B mdoc
347 An alternative macro package for man\~pages mainly used in BSD
348 systems; it provides many new features, but it is not the standard for
349 man\~pages; see
350 .BR groff_mdoc (@MAN7EXT@).
353 .\" --------------------------------------------------------------------
354 .SS "Full Packages"
355 .\" --------------------------------------------------------------------
357 The packages in this section provide a complete set of macros for
358 writing documents of any kind, up to whole books.
360 They are similar in functionality; it is a matter of taste which one
361 to use.
365 .B me
366 The classical
367 .I me
368 macro package; see
369 .BR groff_me (@MAN7EXT@).
373 .B mm
374 The semi-classical
375 .I mm
376 macro package; see
377 .BR groff_mm (@MAN7EXT@).
381 .B mom
382 The new
383 .I mom
384 macro package, only available in groff.
386 As this is not based on other packages, it can be freely designed.
388 So it is expected to become quite a nice, modern macro package.
391 .BR groff_mom (@MAN7EXT@).
395 .B ms
396 The classical
397 .I ms
398 macro package; see
399 .BR groff_ms (@MAN7EXT@).
402 .\" --------------------------------------------------------------------
403 .SS "Special Packages"
404 .\" --------------------------------------------------------------------
406 The macro packages in this section are not intended for stand-alone
407 usage, but can be used to add special functionality to any other
408 macro package or to plain groff.
412 .B tty-char
413 Overrides the definition of standard troff characters and some groff
414 characters for tty devices.
416 The optical appearance is intentionally inferior compared to that of
417 normal tty formatting to allow processing with critical equipment.
421 .B www
422 Additions of elements known from the html format, as being used in the
423 internet (World Wide Web) pages; this includes URL links and mail
424 addresses; see
425 .BR groff_www (@MAN7EXT@).
428 .\" --------------------------------------------------------------------
429 .SH NAMING
430 .\" --------------------------------------------------------------------
432 In classical roff systems, there was a funny naming scheme for macro
433 packages, due to a simplistic design in option parsing.
435 Macro packages were always included by option
436 .option -m;
437 when this option was directly followed by its argument without an
438 intervening space, this looked like a long option preceded by a single
439 minus \[em] a sensation in the computer stone age.
441 To make this optically working for macro package names, all classical
442 macro packages choose a name that started with the letter
443 .'char m ,
444 which was omitted in the naming of the macro file.
448 For example, the macro package for the man pages was called
449 .IR man ,
450 while its macro file
451 .IR tmac.an .
452 So it could be activated by the argument
453 .I an
454 to option
455 .option -m ,
457 .option -man
458 for short.
462 For similar reasons, macro packages that did not start with an
463 .'char m
464 had a leading
465 .'char m
466 added in the documentation and in talking; for example, the package
467 corresponding to
468 .I tmac.doc
469 was called
470 .I mdoc
471 in the documentation, although a more suitable name would be
472 .IR doc .
473 For, when omitting the space between the option and its argument, the
474 command line option for activating this package reads
475 .option "-mdoc" .
479 To cope with all situations, actual versions of
480 .BR groff (@MAN1EXT@)
481 are smart about both naming schemes by providing two macro files
482 for the inflicted macro packages; one with a leading
483 .'char m ,
484 the other one without it.
486 So in
487 .IR groff ,
489 .I man
490 macro package may be specified as on of the following four methods:
493 .Shell_cmd "groff\~\-m\~man"
494 .Shell_cmd "groff\~\-man"
495 .Shell_cmd "groff\~\-mman"
496 .Shell_cmd "groff\~\-m\~an"
500 Recent packages that do not start with
501 .'char m
502 do not use an additional
503 .'char m
504 in the documentation.
506 For example, the
507 .I www
508 macro package may be specified only as one of the two methods:
511 .Shell_cmd "groff\~\-m\~www"
512 .Shell_cmd "groff\~\-mwww"
516 Obviously, variants like
517 .I -mmwww
518 would not make much sense.
522 A second strange feature of classical troff was to name macro files
523 according to
524 .BIR tmac. name .
525 In modern operating systems, the type of a file is specified as
526 postfix, the file name extension.
528 Again, groff copes with this situation by searching both
529 .IB anything .tmac
531 .BI tmac. anything
532 if only
533 .I anything
534 is specified.
538 The easiest way to find out which macro packages are available on a
539 system is to check the man\~page
540 .BR groff (@MAN1EXT@),
541 or the contents of the
542 .I tmac
543 directories.
548 .IR groff ,
549 most macro packages are described in\~man pages called
550 .BR groff_\f[I]name\f[] (@MAN7EXT@),
551 with a leading
552 .'char m
553 for the classical packages.
556 .\" --------------------------------------------------------------------
557 .SH INCLUSION
558 .\" --------------------------------------------------------------------
560 There are several ways to use a macro package in a document.
562 The classical way is to specify the troff/groff option
563 .option \-m
564 .argument name
565 at run-time; this makes the contents of the macro package
566 .I name
567 available.
569 In groff, the file
570 .IB name .tmac
571 is searched within the tmac path; if not found,
572 .BI tmac. name
573 will be searched for instead.
577 Alternatively, it is also possible to include a macro file by adding
578 the request
579 .request so
580 .I filename
581 into the document; the argument must be the full file name of an
582 existing file, possibly with the directory where it is kept.
584 In groff, this was improved by the similar request
585 .request mso
586 .IR package ,
587 which added searching in the tmac path, just like option
588 .option -m
589 does.
593 Note that in order to resolve the
594 .request so
596 .request mso
597 requests, the roff preprocessor
598 .BR soelim (@MAN1EXT@)
599 must be called if the files to be included need preprocessing.
601 This can be done either directly by a pipeline on the command line or
602 by using the troff/groff option
603 .option \-s .
605 .I man
606 calls soelim automatically.
610 For example, suppose a macro file is stored as
611 .I @MACRODIR@/macros.tmac
612 and is used in some document called
613 .IR docu.roff .
617 At run-time, the formatter call for this is
620 .Shell_cmd "groff\~\-m\~" "macrofile\~document.roff"
624 To include the macro file directly in the document either
627 .Example
628 .  Text .mso macrofile.tmac
629 ./Example
632 is used or
635 .Example
636 .  Text .so @MACRODIR@/macros.tmac
637 ./Example
641 In both cases, the formatter is called with
643 .Shell_cmd "troff\~\-s\~" docu.roff
647 If you want to write your own groff macro file, call it
648 .IB whatever .tmac
649 and put it in some directory of the tmac path, see section
650 .BR FILES .
651 Then documents can include it with the
652 .request mso
653 request or the option
654 .option -m .
658 .\" --------------------------------------------------------------------
659 .SH CONVENTION
660 .\" --------------------------------------------------------------------
662 .\" This section does not fit into the framework of this document.
664 There is a convention that is supported by many modern roff
665 type-setters and
666 .BR man (1)
667 programs, the
668 .I preprocessor word
669 described in the following.
672 If the first line in a document is a comment, the first word (after the
673 comment characters and a blank) constitutes the
674 .B preprocessor
675 .BR word .
676 That means that the letters of this word are interpreted as
677 abbreviations for those preprocessor commands that should be run
678 when formatting the document.
680 Mostly, only the letters corresponding to the options for the
681 preprocessors are recognized,
682 .'char e
683 (for
684 .BR eqn ),
685 .\" 'char G ,
686 .\" 'char g ,
687 .'char p ,
688 (for
689 .BR pic ),
690 .'char R
691 (for
692 .BR refer ),
693 .'char s
694 (for
695 .BR soelim ),
697 .'char t
698 (for
699 .BR tbl ).
700 (see
701 .BR roff (@MAN7EXT@)).
705 Besides being a good reminder for the user, some formatters (like the
706 .BR man (1)
707 program) are even able to automatically start the preprocessors
708 specified in the preprocessor word, but do not bet on this.
713 .I man
714 program handles some preprocessors automatically, such that in
715 man\~pages only the following characters should be used:
716 .'char e ,
717 .'char p ,
719 .'char t .
723 .\" --------------------------------------------------------------------
724 .SH "WRITING MACROS"
725 .\" --------------------------------------------------------------------
728 .BR roff (@MAN7EXT@)
729 document is a text file that is enriched by predefined formatting
730 constructs, such as requests, escape sequences, strings, numeric
731 registers, and macros from a macro package.
733 These elements are described in
734 .BR roff (@MAN7EXT@).
738 To give a document a personal style, it is most useful to extend the
739 existing elements by defining some macros for repeating tasks; the best
740 place for this is near the beginning of the document or in a separate
741 file.
745 Macros without arguments are just like strings.
747 But the full power of macros reveals when arguments are passed with a
748 macro call.
750 Within the macro definition, the arguments are available as the escape
751 sequences
752 .BR $1 ,
753 \*[Ellipsis],
754 .BR $9 ,
755 .BR $[ \*[Ellipsis] ] ,
756 .BR $* ,
758 .BR $@ ,
759 the name under which the macro was called is in
760 .BR $0 ,
761 and the number of arguments is in register
762 .BR \n[.$] ;
764 .BR groff (@MAN7EXT@).
767 .\" --------------------------------------------------------------------
768 .SS "Copy-in Mode"
769 .\" --------------------------------------------------------------------
771 The phase when groff reads a macro is called
772 .I "copy-in mode"
773 in roff-talk.
775 This is comparable to the C\~preprocessing phase during the development
776 of a program written in the C\~language.
780 In this phase, groff interprets all backslashes; that means that all
781 escape sequences in the macro body are interpreted and replaced by
782 their value.
784 For constant expression, this is wanted, but strings and registers
785 that might change between calls of the macro must be protected from
786 being evaluated.
788 This is most easily done by doubling the backslash that introduces the
789 escape sequence.
791 This doubling is most important for the positional parameters.
793 For example, to print information on the arguments that were passed to
794 the macro to the terminal, define a macro named `.print_args',
795 say.
799 .ds @1 \[rs]f[I]\[rs]\[rs]$0\[rs]f[]\"
800 .ds @2 arguments:\"
801 .Example
802 .  Text .ds midpart was called with
803 .  Text .de print_args
804 .  Text .\~\~tm\~\*[@1]\~\[rs]\[rs]*[midpart]\~\[rs]\[rs]n[.$]\~\*[@2]
805 .  Text .\~\~tm\~\[rs]\[rs]$*
806 .  Text ..
807 ./Example
808 .rm @1
809 .rm @2
813 When calling this macro by
815 .Example
816 .  Text .print_args arg1 arg2
817 ./Example
819 the following text is printed to the terminal:
820 .Example
821 .  Text \f[CI]print_args\f[] was called with the following 2 arguments:
822 arg1 arg2
823 ./Example
827 Let's analyze each backslash in the macro definition.
829 As the positional parameters and the number of arguments will change
830 with each call of the macro their leading backslash must be doubled,
831 which results in
832 .I \[rs]\[rs]$*
834 .IR \[rs]\[rs][.$] .
835 The same applies to the macro name because it could be called with an
836 alias name, so
837 .IR \[rs]\[rs]$0 .
841 On the other hand,
842 .I midpart
843 is a constant string, it will not change, so no doubling for
844 .IR \[rs]*[midpart] .
846 .I \[rs]f
847 escape sequences are predefined groff elements for setting the font
848 within the text.
850 Of course, this behavior will not change, so no doubling with
851 .I \[rs]f[I]
853 .IR \[rs]f[] .
856 .\" --------------------------------------------------------------------
857 .SS "Draft Mode"
858 .\" --------------------------------------------------------------------
860 Writing groff macros is easy when the escaping mechanism is temporarily
861 disabled.
863 In groff, this is done by enclosing the macro definition(s) into a
864 pair of
865 .B .eo
867 .B .ec
868 requests.
870 Then the body in the macro definition is just like a normal part of
871 the document \[em] text enhanced by calls of requests, macros,
872 strings, registers, etc.
874 For example, the code above can be written in a simpler way by
878 .ds @1 \[rs]f[I]\[rs]$0\[rs]f[]\"
879 .ds @2 arguments:\"
880 .Example
881 .  Text .eo
882 .  Text .ds midpart was called with
883 .  Text .de print_args
884 .  Text .\~\~tm\~\*[@1]\~\[rs]*[midpart]\~\[rs]n[.$]\~\*[@2]
885 .  Text .\~\~tm\~\[rs]$*
886 .  Text ..
887 .  Text .ec
888 ./Example
889 .rm @1
890 .rm @2
894 Unfortunately, draft mode cannot be used universally.
896 Although it is good enough for defining normal macros, draft mode
897 will fail with advanced applications, such as indirectly defined
898 strings, registers, etc.
900 An optimal way is to define and test all macros in draft mode and then
901 do the backslash doubling as a final step; do not forget to remove the
902 .I .eo
903 request.
906 .\" --------------------------------------------------------------------
907 .SS "Tips for Macro Definitions"
908 .\" --------------------------------------------------------------------
910 .Topic
911 Start every line with a dot, for example, by using the groff request
912 .B .nop
913 for text lines, or write your own macro that handles also text lines
914 with a leading dot.
917 .Example
918 .  Text .de Text
919 .  Text .\~\~if (\[rs]\[rs]n[.$] == 0)\~\[rs]
920 .  Text .\~\~\~\~return
921 .  Text .\~nop\~\[rs])\[rs]\[rs]$*[rs]\)
922 .  Text ..
923 ./Example
925 .Topic
926 Write a comment macro that works both for copy-in and draft mode; for
927 as escaping is off in draft mode, trouble might occur when normal
928 comments are used.
930 For example, the following macro just ignores its arguments, so it
931 acts like a comment line:
934 .Example
935 .  Text .de\~c
936 .  Text ..
937 .  Text .c\~This\~is\~like\~a\~comment\~line.
938 ./Example
940 .Topic
941 In long macro definitions, make ample use of comment lines or empty
942 lines for a better structuring.
944 .Topic
945 To increase readability, use groff's indentation facility for requests
946 and macro calls (arbitrary whitespace after the leading dot).
949 .\" --------------------------------------------------------------------
950 .SS "Diversions"
951 .\" --------------------------------------------------------------------
953 Diversions can be used to realize quite advanced programming
954 constructs.
956 They are comparable to pointers to large data structures in the
957 C\~programming language, but their usage is quite different.
961 In their simplest form, diversions are multi-line strings, but
962 they get their power when diversions are used dynamically within macros.
964 The information stored in a diversion can be retrieved by calling the
965 diversion just like a macro.
969 Most of the problems arising with diversions can be avoided if you are
970 conscious about the fact that diversions always deal with complete
971 lines.
973 If diversions are used when the line buffer has not been flashed,
974 strange results are produced; not knowing this, many people get
975 desperate about diversions.
977 To ensure that a diversion works, line breaks should be added at the
978 right places.
980 To be on the secure side, enclose everything that has to do with
981 diversions into a pair of line breaks; for example, by amply using
982 .B .br
983 requests.
985 This rule should be applied to diversion definition, both inside and
986 outside, and to all calls of diversions.
988 This is a bit of overkill, but it works nicely.
992 [If you really need diversions which should ignore the current partial
993 line, use environments to save the current partial line and/\:or use the
994 .B .box
995 request.]
999 The most powerful feature using diversions is to start a diversion
1000 within a macro definition and end it within another macro.
1002 Then everything between each call of this macro pair is stored within
1003 the diversion and can be manipulated from within the macros.
1006 .\" --------------------------------------------------------------------
1007 .SH FILES
1008 .\" --------------------------------------------------------------------
1010 All macro names must be named
1011 .IB name .tmac
1012 to fully use the tmac mechanism.
1014 .BI tmac. name
1015 as with classical packages is possible as well, but deprecated.
1019 The macro files are kept in the
1020 .IR "tmac directories" ;
1021 a colon separated list of these constitutes the
1022 .IR "tmac path" .
1026 The search sequence for macro files is (in that order):
1028 .Topic
1029 the directories specified with troff/groff's
1030 .B \-M
1031 command line option
1033 .Topic
1034 the directories given in the
1035 .Env_var $GROFF_TMAC_PATH
1036 environment variable
1038 .Topic
1039 the current directory (only if in unsafe mode, which is enabled by the
1040 .B \-U
1041 command line switch)
1043 .Topic
1044 the home directory
1046 .Topic
1047 a platform-specific directory, being
1048 .B @SYSTEMMACRODIR@
1049 in this installation
1051 .Topic
1052 a site-specific (platform-independent) directory, being
1053 .B @LOCALMACRODIR@
1054 in this installation
1056 .Topic
1057 the main tmac directory, being
1058 .B @MACRODIR@
1059 in this installation
1062 .\" --------------------------------------------------------------------
1063 .SH ENVIRONMENT
1064 .\" --------------------------------------------------------------------
1067 .Env_var $GROFF_TMAC_PATH
1068 A colon separated list of additional tmac directories in which to search
1069 for macro files.
1071 See the previous section for a detailed description.
1074 .\" --------------------------------------------------------------------
1075 .SH AUTHOR
1076 .\" --------------------------------------------------------------------
1078 Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
1081 This document is distributed under the terms of the FDL (GNU Free
1082 Documentation License) version 1.1 or later.
1084 You should have received a copy of the FDL on your system, it is also
1085 available on-line at the
1086 .URL http://\:www.gnu.org/\:copyleft/\:fdl.html "GNU copyleft site" .
1089 This document is part of
1090 .IR groff ,
1091 the GNU roff distribution.
1093 It was written by
1094 .MTO bwarken@mayn.de "Bernd Warken" ;
1095 it is maintained by
1096 .MTO wl@gnu.org "Werner Lemberg" .
1099 .\" --------------------------------------------------------------------
1100 .SH "SEE ALSO"
1101 .\" --------------------------------------------------------------------
1103 A complete reference for all parts of the groff system is found in the
1104 groff
1105 .BR info (1)
1106 file.
1109 .BR groff (@MAN1EXT@)
1110 an overview of the groff system.
1113 .BR groff_man (@MAN7EXT@),
1114 .TP+
1115 .BR groff_mdoc (@MAN7EXT@),
1116 .TP+
1117 .BR groff_me (@MAN7EXT@),
1118 .TP+
1119 .BR groff_mm (@MAN7EXT@),
1120 .TP+
1121 .BR groff_mom (@MAN7EXT@),
1122 .TP+
1123 .BR groff_ms (@MAN7EXT@),
1124 .TP+
1125 .BR groff_www (@MAN7EXT@).
1126 the groff tmac macro packages.
1129 .BR groff (@MAN7EXT@)
1130 the groff language.
1134 The Filesystem Hierarchy Standard is available at the
1135 .URL http://\:www.pathname.com/\:fhs/ "FHS web site" .
1137 .\" Local Variables:
1138 .\" mode: nroff
1139 .\" End: