1 .\" Emacs mode: -*- nroff -*-
2 .TH GROFF_TMAC @MAN5EXT@ "@MDATE@" "Groff Version @VERSION@"
4 groff_tmac \- macro files in the roff typesetting system
7 .\" Source file position: <groff_source>/man/groff_tmac.man
8 .\" Installed position: <prefix>/share/man/man5/groff_tmac.5
10 .\" --------------------------------------------------------------------
12 .\" --------------------------------------------------------------------
15 Copyright \[co] 2000-2014 Free Software Foundation, Inc.
17 This file is part of groff, the GNU roff type-setting system.
19 Permission is granted to copy, distribute and/or modify this document
20 under the terms of the GNU Free Documentation License, Version 1.3 or
21 any later version published by the Free Software Foundation; with no
22 Front-Cover Texts, and with no Back-Cover Texts.
24 A copy of the Free Documentation License is included as a file called
25 FDL in the main directory of the groff source package, it is also
26 available on\-line at the
27 .UR http://\:www.gnu.org/\:copyleft/\:fdl.html
33 This file was written by
34 .ME groff-bernd.warken-72@web.de
43 .ds Ellipsis \&.\|.\|.\&\"
46 .\" --------------------------------------------------------------------
48 .\" --------------------------------------------------------------------
52 type-setting system provides a set of macro packages suitable for
53 special kinds of documents.
55 Each macro package stores its macros and definitions in a file called
59 The name is deduced from
66 The tmac files are normal roff source documents, except that they
67 usually contain only definitions and setup commands, but no text.
69 All tmac files are kept in a single or a small number of directories,
75 .\" --------------------------------------------------------------------
76 .SH "GROFF MACRO PACKAGES"
77 .\" --------------------------------------------------------------------
80 provides all classical macro packages, some more full packages, and
81 some secondary packages for special purposes.
83 Note that it is not possible to use multiple primary macro packages at the
84 same time; saying e.g.\&
88 \fIsh#\fP groff \-m man \-m ms foo
97 \fIsh#\fP groff \-m man foo \-m ms bar
103 Exception to this is the use of man pages written with either the
108 See below the description of the
113 .\" --------------------------------------------------------------------
115 .\" --------------------------------------------------------------------
119 This is the classical macro package for UNIX manual pages
120 (man\~pages); it is quite handy and easy to use; see
121 .BR groff_man (@MAN7EXT@).
128 An alternative macro package for man\~pages mainly used in BSD
129 systems; it provides many new features, but it is not the standard for
131 .BR groff_mdoc (@MAN7EXT@).
138 Use this file in case you don\[aq]t know whether the
142 package should be used.
143 Multiple man pages (in either format) can be handled.
146 .\" --------------------------------------------------------------------
148 .\" --------------------------------------------------------------------
150 The packages in this section provide a complete set of macros for
151 writing documents of any kind, up to whole books.
153 They are similar in functionality; it is a matter of taste which one
162 .BR groff_me (@MAN7EXT@).
170 .BR groff_mm (@MAN7EXT@).
177 macro package, only available in groff.
179 As this is not based on other packages, it can be freely designed.
181 So it is expected to become quite a nice, modern macro package.
184 .BR groff_mom (@MAN7EXT@).
192 .BR groff_ms (@MAN7EXT@).
195 .\" --------------------------------------------------------------------
196 .SS "Language-specific Packages"
197 .\" --------------------------------------------------------------------
201 This file adds support for Czech localization, including the main macro
202 packages (me, mom, mm, and ms).
207 sets the input encoding to latin-2.
214 German localization support, including the main macro packages (me, mom, mm,
219 selects hyphenation patterns for traditional orthography, and
221 does the same for the new orthography
222 (\[oq]Recht\%schreib\%reform\[cq]).
224 It should be used as the last macro package on the command line.
229 This file adds support for French localization, including the main macro
230 packages (me, mom, mm, and ms).
237 \fIsh#\fP groff \-ms \-mfr foo.ms > foo.ps
244 sets the input encoding to latin-9 to get proper support of the
245 \[oq]oe\[cq] ligature.
250 Swedish localization support, including the me, mom, and ms macro packages.
252 Note that Swedish for the mm macros is handled separately; see
253 .BR groff_mmse (@MAN7EXT@).
255 It should be used as the last macro package on the command line.
258 .\" --------------------------------------------------------------------
259 .SS "Input Encodings"
260 .\" --------------------------------------------------------------------
271 Various input encodings supported directly by groff.
273 Normally, this macro is loaded at the very beginning of a document or
274 specified as the first macro argument on the command line.
277 loads latin1 by default at start-up.
279 Note that these macro packages don\[aq]t work on EBCDIC hosts.
284 Encoding support for EBCDIC.
286 On those platforms it is loaded automatically at start-up.
288 Due to different character ranges used in
290 it doesn\[aq]t work on architectures which are based on ASCII.
294 Note that it can happen that some input encoding characters are not
295 available for a particular output device.
301 groff \-Tlatin1 \-mlatin9 ...
305 fails if you use the Euro character in the input.
307 Usually, this limitation is present only for devices which have a
308 limited set of output glyphs
311 for other devices it is usually sufficient to install proper
312 fonts which contain the necessary glyphs.
315 .\" --------------------------------------------------------------------
316 .SS "Special Packages"
317 .\" --------------------------------------------------------------------
319 The macro packages in this section are not intended for stand-alone
320 usage, but can be used to add special functionality to any other
321 macro package or to plain groff.
326 Provide some macros for addition, multiplication, and division of 60bit
327 integers (allowing safe multiplication of 31bit integers, for example).
332 Switch to the EC and TC font families.
335 .BR \%grodvi (@MAN1EXT@)
336 \[en] this man page also gives more details of how to use it.
341 This macro file is already loaded at start-up by
343 so it isn\[aq]t necessary to call it explicitly.
345 It provides an interface to set the paper size on the command line with
346 the option \f[B]\%\-dpaper=\f[]\,\f[I]size\f[].
350 are the same as the predefined
352 values in the DESC file (only lowercase; see
353 .BR groff_font (@MAN5EXT@)
359 (ell) character denotes landscape orientation.
367 Most output drivers need additional command line switches
371 to override the default paper length and orientation as set in the driver
374 For example, use the following for PS output on A4 paper in landscape
380 \fIsh#\fP groff \-Tps \-dpaper=a4l \-P\-pa4 \-P\-l \-ms foo.ms > foo.ps
386 This file provides proper definitions for the macros
391 .BR @g@pic (@MAN1EXT@)
394 They center each picture.
396 Use it only if your macro package doesn\[aq]t provide proper
397 definitions for those two macros (actually, most of them already do).
402 A single macro is provided in this file,
404 to include a PostScript graphic in a document.
406 The following output devices support inclusion of PS images:
412 for all other devices the image is replaced with a hollow rectangle
415 This macro file is already loaded at start-up by
417 so it isn\[aq]t necessary to call it explicitly.
427 |\|\fB\-I\fP\ \fIn\fP] \
428 \fI\|file\fP [\fIwidth\fP [\,\fIheight\/\fP]]
433 is the name of the PostScript file;
437 give the desired width and height of the image.
443 argument is specified, the image\[aq]s natural width (as given in the
444 file\[aq]s bounding box) or the current line length is used as the
445 width, whatever is smaller.
451 arguments may have scaling indicators attached;
452 the default scaling indicator is\~\c
455 This macro scales the graphic uniformly
456 in the x and y\~directions so that it is no more than
465 centers the graphic horizontally, which is the default.
471 options cause the graphic to be left-aligned and right-aligned,
476 option causes the graphic to be indented by\~\c
478 (default scaling indicator is\~\c
484 within a diversion it is recommended to extend it with the following
485 code, assuring that the diversion\[aq]s width completely covers the
493 \&\[rs]h'(\[rs]\[rs]n[ps-offset]u + \[rs]\[rs]n[ps-deswid]u)'
503 A single macro is provided in this file,
505 for formatting permuted index entries as produced by the GNU
509 In case you need a different formatting, copy the macro into
510 your document and adapt it to your needs.
515 Use this for tracing macro calls.
517 It is only useful for debugging.
520 .BR groff_trace (@MAN7EXT@) .
525 Overrides the definition of standard troff characters and some groff
526 characters for TTY devices.
528 The optical appearance is intentionally inferior compared to that of
529 normal TTY formatting to allow processing with critical equipment.
534 Additions of elements known from the HTML format, as used in the
535 internet (World Wide Web) pages; this includes URL links and mail
537 .BR groff_www (@MAN7EXT@).
540 .\" --------------------------------------------------------------------
542 .\" --------------------------------------------------------------------
544 Classical roff systems were designed before the conventions of the
547 call evolved, and used a naming scheme for macro packages that looks
550 Macro packages were always included with the option
552 when this option was directly followed by its argument without an
553 intervening space, this looked like a long option preceded by a single
554 minus \[em] a sensation in the computer stone age.
556 To make this invocation form work, classical troff
557 macro packages used names that started with the letter \[oq]m\[cq],
558 which was omitted in the naming of the macro file.
562 For example, the macro package for the man pages was called
566 So it could be activated by the argument
576 For similar reasons, macro packages that did not start with an
577 \[oq]m\[cq] had a leading \[oq]m\[cq] added in the documentation and
578 in speech; for example, the package corresponding to
582 in the documentation, although a more suitable name would be
584 For, when omitting the space between the option and its argument, the
585 command line option for activating this package reads
590 To cope with all situations, actual versions of
591 .BR groff (@MAN1EXT@)
592 are smart about both naming schemes by providing two macro files
593 for the inflicted macro packages; one with a leading \[oq]m\[cq]
594 the other one without it.
600 macro package may be specified as on of the following four methods:
604 \fIsh#\fP groff\ \-m\ man
605 \fIsh#\fP groff\ \-man
606 \fIsh#\fP groff\ \-mman
607 \fIsh#\fP groff\ \-m\ an
612 Recent packages that do not start with \[oq]m\[cq] do not use an
613 additional \[oq]m\[cq] in the documentation.
617 macro package may be specified only as one of the two methods:
621 \fIsh#\fP groff\ \-m\ www
622 \fIsh#\fP groff\ \-mwww
627 Obviously, variants like
629 would not make much sense.
633 A second strange feature of classical troff was to name macro files
634 in the form \f[B]tmac.\f[]\,\f[I]name\f[].
635 In modern operating systems, the type of a file is specified as a
636 postfix, the file name extension.
638 Again, groff copes with this situation by searching both
648 The easiest way to find out which macro packages are available on a
649 system is to check the man\~page
650 .BR groff (@MAN1EXT@),
651 or the contents of the
659 most macro packages are described in\~man pages called
660 .BR groff_\f[I]name\f[] (@MAN7EXT@),
661 with a leading \[oq]m\[cq] for the classical packages.
664 .\" --------------------------------------------------------------------
666 .\" --------------------------------------------------------------------
668 There are several ways to use a macro package in a document.
670 The classical way is to specify the troff/groff option
673 at run-time; this makes the contents of the macro package
679 is searched within the tmac path; if not found,
681 is searched for instead.
685 Alternatively, it is also possible to include a macro file by adding
689 into the document; the argument must be the full file name of an
690 existing file, possibly with the directory where it is kept.
692 In groff, this was improved by the similar request
695 which added searching in the tmac path, just like option
701 Note that in order to resolve the
705 requests, the roff preprocessor
706 .BR soelim (@MAN1EXT@)
707 must be called if the files to be included need preprocessing.
709 This can be done either directly by a pipeline on the command line or
710 by using the troff/groff option
714 calls soelim automatically.
718 For example, suppose a macro file is stored as
721 .I @MACRODIR@/macros.tmac
724 and is used in some document called
729 At run-time, the formatter call for this is
733 \fIsh#\fP groff \-m macros docu.roff
738 To include the macro file directly in the document either
750 \&.so @MACRODIR@/macros.tmac
755 In both cases, the formatter should be called with option
761 \fIsh#\fP groff \-s docu.roff
766 If you want to write your own groff macro file, call it
768 and put it in some directory of the tmac path, see section
770 Then documents can include it with the
772 request or the option
777 .\" --------------------------------------------------------------------
779 .\" --------------------------------------------------------------------
781 .\" This section does not fit into the framework of this document.
783 There is a convention that is supported by many modern roff
788 described in the following.
791 If the first line in a document is a comment, the first word (after the
792 comment characters and a blank) constitutes the
795 That means that the letters of this word are interpreted as
796 abbreviations for those preprocessor commands that should be run
797 when formatting the document.
799 Mostly, only the letters corresponding to the options for the
800 preprocessors are recognized,
820 .BR roff (@MAN7EXT@)).
824 Besides being a good reminder for the user, some formatters (like the
826 program) are even able to automatically start the preprocessors
827 specified in the preprocessor word, but do not bet on this.
833 program handles some preprocessors automatically, such that in
834 man\~pages only the following characters should be used:
835 \[oq]e\[cq], \[oq]p\[cq], and \[oq]t\[cq].
839 .\" --------------------------------------------------------------------
841 .\" --------------------------------------------------------------------
845 document is a text file that is enriched by predefined formatting
846 constructs, such as requests, escape sequences, strings, numeric
847 registers, and macros from a macro package.
849 These elements are described in
850 .BR roff (@MAN7EXT@).
854 To give a document a personal style, it is most useful to extend the
855 existing elements by defining some macros for repeating tasks; the best
856 place for this is near the beginning of the document or in a separate
861 Macros without arguments are just like strings.
863 But the full power of macros reveals when arguments are passed with a
866 Within the macro definition, the arguments are available as the escape
871 .BR \[rs]$[ \*[Ellipsis] ] ,
875 the name under which the macro was called is in
877 and the number of arguments is in register
880 .BR groff (@MAN7EXT@).
883 .\" --------------------------------------------------------------------
885 .\" --------------------------------------------------------------------
887 The phase when groff reads a macro is called
893 This is comparable to the C\~preprocessing phase during the development
894 of a program written in the C\~language.
898 In this phase, groff interprets all backslashes; that means that all
899 escape sequences in the macro body are interpreted and replaced by
902 For constant expressions, this is wanted, but strings and registers
903 that might change between calls of the macro must be protected from
906 This is most easily done by doubling the backslash that introduces the
909 This doubling is most important for the positional parameters.
911 For example, to print information on the arguments that were passed to
912 the macro to the terminal, define a macro named \[oq].print_args\[cq],
917 .ds @1 \[rs]f[I]\[rs]\[rs]$0\[rs]f[]\"
920 \&.ds midpart was called with
922 \&.\ \ tm\ \*[@1]\ \[rs]*[midpart]\ \[rs]\[rs]n[.$]\ \*[@2]
923 \&.\ \ tm\ \[rs]\[rs]$*
931 When calling this macro by
935 \&.print_args arg1 arg2
939 the following text is printed to the terminal:
943 \&\f[CI]print_args\f[] was called with the following 2 arguments:
949 Let\[aq]s analyze each backslash in the macro definition.
951 As the positional parameters and the number of arguments change
952 with each call of the macro their leading backslash must be doubled,
956 .RI \[rs]\[rs] [.$] .
957 The same applies to the macro name because it could be called with an
965 is a constant string, it does not change, so no doubling for
966 .RI \[rs] *[midpart] .
969 escape sequences are predefined groff elements for setting the font
972 Of course, this behavior does not change, so no doubling with
978 .\" --------------------------------------------------------------------
980 .\" --------------------------------------------------------------------
982 Writing groff macros is easy when the escaping mechanism is temporarily
985 In groff, this is done by enclosing the macro definition(s) into a
992 Then the body in the macro definition is just like a normal part of
993 the document \[em] text enhanced by calls of requests, macros,
994 strings, registers, etc.
996 For example, the code above can be written in a simpler way by
1000 .ds @1 \[rs]f[I]\[rs]$0\[rs]f[]\"
1004 \&.ds midpart was called with
1006 \&.\ \ tm\ \*[@1]\ \[rs]*[midpart]\ \[rs]n[.$]\ \*[@2]
1016 Unfortunately, draft mode cannot be used universally.
1018 Although it is good enough for defining normal macros, draft mode
1019 fails with advanced applications, such as indirectly defined
1020 strings, registers, etc.
1022 An optimal way is to define and test all macros in draft mode and then
1023 do the backslash doubling as a final step; do not forget to remove the
1028 .\" --------------------------------------------------------------------
1029 .SS "Tips for Macro Definitions"
1030 .\" --------------------------------------------------------------------
1033 Start every line with a dot, for example, by using the groff request
1035 for text lines, or write your own macro that handles also text lines
1042 \&.\ \ if (\[rs]\[rs]n[.$] == 0)\ \[rs]
1044 \&.\ \ nop\ \[rs])\[rs]\[rs]$*\[rs])
1050 Write a comment macro that works both for copy-in and draft mode; for
1051 as escaping is off in draft mode, trouble might occur when normal
1054 For example, the following macro just ignores its arguments, so it
1055 acts like a comment line:
1062 \&.c\ This\ is\ like\ a\ comment\ line.
1067 In long macro definitions, make ample use of comment lines or
1068 almost-empty lines (this is, lines which have a leading dot
1069 and nothing else) for a better structuring.
1072 To increase readability, use groff\[aq]s indentation facility for
1073 requests and macro calls (arbitrary whitespace after the leading dot).
1076 .\" --------------------------------------------------------------------
1078 .\" --------------------------------------------------------------------
1080 Diversions can be used to implement quite advanced programming
1083 They are comparable to pointers to large data structures in the
1084 C\~programming language, but their usage is quite different.
1088 In their simplest form, diversions are multi-line strings, but
1089 they get their power when diversions are used dynamically within macros.
1091 The (formatted) information stored in a diversion can be retrieved by
1092 calling the diversion just like a macro.
1096 Most of the problems arising with diversions can be avoided if you remain
1097 aware of the fact that diversions always store complete lines.
1099 If diversions are used when the line buffer has not been flushed,
1100 strange results are produced; not knowing this, many people get
1101 desperate about diversions.
1103 To ensure that a diversion works, line breaks should be added at the
1106 To be on the secure side, enclose everything that has to do with
1107 diversions into a pair of line breaks; for example, by explicitly using
1111 This rule should be applied to diversion definition, both inside and
1112 outside, and to all calls of diversions.
1114 This is a bit of overkill, but it works nicely.
1118 [If you really need diversions which should ignore the current partial
1119 line, use environments to save the current partial line and/\:or use the
1125 The most powerful feature using diversions is to start a diversion
1126 within a macro definition and end it within another macro.
1128 Then everything between each call of this macro pair is stored within
1129 the diversion and can be manipulated from within the macros.
1132 .\" --------------------------------------------------------------------
1134 .\" --------------------------------------------------------------------
1136 All macro names must be named
1138 to fully use the tmac mechanism.
1141 as with classical packages is possible as well, but deprecated.
1145 The macro files are kept in the
1146 .IR "tmac directories" ;
1147 a colon separated list of these constitutes the
1152 The search sequence for macro files is (in that order):
1155 the directories specified with troff/groff\[aq]s
1160 the directories given in the
1162 environment variable
1165 the current directory (only if in unsafe mode, which is enabled by the
1167 command line switch)
1173 a platform-specific directory, being
1181 in this installation
1184 a site-specific (platform-independent) directory, being
1192 in this installation
1195 the main tmac directory, being
1203 in this installation
1206 .\" --------------------------------------------------------------------
1208 .\" --------------------------------------------------------------------
1212 A colon separated list of additional tmac directories in which to search
1215 See the previous section for a detailed description.
1218 .\" --------------------------------------------------------------------
1220 .\" --------------------------------------------------------------------
1222 A complete reference for all parts of the groff system is found in the
1229 .BR groff (@MAN1EXT@)
1230 an overview of the groff system.
1234 .BR groff_man (@MAN7EXT@),
1236 .BR groff_mdoc (@MAN7EXT@),
1238 .BR groff_me (@MAN7EXT@),
1240 .BR groff_mm (@MAN7EXT@),
1242 .BR groff_mom (@MAN7EXT@),
1244 .BR groff_ms (@MAN7EXT@),
1246 .BR groff_trace (@MAN7EXT@),
1248 .BR groff_www (@MAN7EXT@).
1249 the groff tmac macro packages.
1253 .BR groff (@MAN7EXT@)
1258 The Filesystem Hierarchy Standard is available at the
1259 .UR http://\:www.pathname.com/\:fhs/
1264 .\" --------------------------------------------------------------------
1266 .\" --------------------------------------------------------------------
1268 .\" --------------------------------------------------------------------
1270 .\" --------------------------------------------------------------------