4 File position: <groff-source>/man/groff_tmac.man
6 This file is part of groff, the GNU roff type-setting system.
8 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008
9 Free Software Foundation, Inc.
10 written by Bernd Warken <bwarken@mayn.de> and Werner Lemberg
13 Permission is granted to copy, distribute and/or modify this document
14 under the terms of the GNU Free Documentation License, Version 1.1 or
15 any later version published by the Free Software Foundation; with the
16 Invariant Sections being this .ig-section and AUTHOR, with no
17 Front-Cover Texts, and with no Back-Cover Texts.
19 A copy of the Free Documentation License is included as a file called
20 FDL in the main directory of the groff source package.
22 .ds Ellipsis \&.\|.\|.\&\"
24 .TH GROFF_TMAC @MAN5EXT@ "@MDATE@" "Groff Version @VERSION@"
26 groff_tmac \- macro files in the roff typesetting system
29 .\" --------------------------------------------------------------------
31 .\" --------------------------------------------------------------------
35 type-setting system provides a set of macro packages suitable for
36 special kinds of documents.
38 Each macro package stores its macros and definitions in a file called
41 The name is deduced from
47 The tmac files are normal roff source documents, except that they
48 usually contain only definitions and setup commands, but no text.
50 All tmac files are kept in a single or a small number of directories,
56 .\" --------------------------------------------------------------------
57 .SH "GROFF MACRO PACKAGES"
58 .\" --------------------------------------------------------------------
61 provides all classical macro packages, some more full packages, and
62 some secondary packages for special purposes.
64 Note that it is not possible to use multiple primary macro packages at the
65 same time; saying e.g.\&
69 \fIsh#\fP groff \-m man \-m ms foo
77 \fIsh#\fP groff \-m man foo \-m ms bar
82 Exception to this is the use of man pages written with either the
87 See below the description of the
92 .\" --------------------------------------------------------------------
94 .\" --------------------------------------------------------------------
98 This is the classical macro package for UNIX manual pages
99 (man\~pages); it is quite handy and easy to use; see
100 .BR groff_man (@MAN7EXT@).
107 An alternative macro package for man\~pages mainly used in BSD
108 systems; it provides many new features, but it is not the standard for
110 .BR groff_mdoc (@MAN7EXT@).
117 Use this file in case you don't know whether the
121 package should be used.
122 Multiple man pages (in either format) can be handled.
125 .\" --------------------------------------------------------------------
127 .\" --------------------------------------------------------------------
129 The packages in this section provide a complete set of macros for
130 writing documents of any kind, up to whole books.
132 They are similar in functionality; it is a matter of taste which one
141 .BR groff_me (@MAN7EXT@).
149 .BR groff_mm (@MAN7EXT@).
156 macro package, only available in groff.
158 As this is not based on other packages, it can be freely designed.
160 So it is expected to become quite a nice, modern macro package.
163 .BR groff_mom (@MAN7EXT@).
171 .BR groff_ms (@MAN7EXT@).
174 .\" --------------------------------------------------------------------
175 .SS "Language-specific Packages"
176 .\" --------------------------------------------------------------------
180 This file adds support for Czech localization, including the main macro
181 packages (me, mom, mm, and ms).
186 sets the input encoding to latin-2.
193 German localization support, including the main macro packages (me, mom, mm,
198 selects hyphenation patterns for traditional orthography, and
200 does the same for the new orthography (`Recht\%schreib\%reform').
202 It should be used as the last macro package on the command line.
207 This file adds support for French localization, including the main macro
208 packages (me, mom, mm, and ms).
215 \fIsh#\fP groff -ms -mfr foo.ms > foo.ps
222 sets the input encoding to latin-9 to get proper support of the `oe'
228 Swedish localization support, including the me, mom, and ms macro packages.
230 Note that Swedish for the mm macros is handled separately; see
231 .BR groff_mmse (@MAN7EXT@).
233 It should be used as the last macro package on the command line.
236 .\" --------------------------------------------------------------------
237 .SS "Input Encodings"
238 .\" --------------------------------------------------------------------
249 Various input encodings supported directly by groff.
251 Normally, this macro is loaded at the very beginning of a document or
252 specified as the first macro argument on the command line.
255 loads latin1 by default at start-up.
257 Note that these macro packages don't work on EBCDIC hosts.
262 Encoding support for EBCDIC.
264 On those platforms it is loaded automatically at start-up.
266 Due to different character ranges used in
268 it doesn't work on architectures which are based on ASCII.
272 Note that it can happen that some input encoding characters are not
273 available for a particular output device.
279 groff -Tlatin1 -mlatin9 ...
283 fails if you use the Euro character in the input.
285 Usually, this limitation is present only for devices which have a
286 limited set of output glyphs
289 for other devices it is usually sufficient to install proper
290 fonts which contain the necessary glyphs.
293 .\" --------------------------------------------------------------------
294 .SS "Special Packages"
295 .\" --------------------------------------------------------------------
297 The macro packages in this section are not intended for stand-alone
298 usage, but can be used to add special functionality to any other
299 macro package or to plain groff.
304 Provide some macros for addition, multiplication, and division of 60bit
305 integers (allowing safe multiplication of 30bit integers, for example).
310 Switch to the EC and TC font families.
313 .BR \%grodvi (@MAN1EXT@)
314 \[en] this man page also gives more details of how to use it.
319 This macro file is already loaded at start-up by
321 so it isn't necessary to call it explicitly.
323 It provides an interface to set the paper size on the command line with
324 the option \f[B]\%\-dpaper=\f[]\f[I]size\f[].
328 are the same as the predefined
330 values in the DESC file (only lowercase; see
331 .BR groff_font (@MAN5EXT@)
337 (ell) character denotes landscape orientation.
345 Most output drivers need additional command line switches
349 to override the default paper length and orientation as set in the driver
352 For example, use the following for PS output on A4 paper in landscape
358 \fIsh#\fP groff \-Tps \-dpaper=a4l \-P\-pa4 \-P\-l \-ms foo.ms > foo.ps
364 This file provides proper definitions for the macros
369 .BR @g@pic (@MAN1EXT@)
372 They center each picture.
374 Use it only if your macro package doesn't provide proper definitions
375 for those two macros (actually, most of them already do).
380 A single macro is provided in this file,
382 to include a PostScript graphic in a document.
384 The following output devices support inclusion of PS images:
390 for all other devices the image is replaced with a hollow rectangle
393 This macro file is already loaded at start-up by
395 so it isn't necessary to call it explicitly.
405 |\|\fB\-I\fP\ \fIn\fP] \
406 \fI\|file\fP [\fIwidth\fP [\fIheight\fP]]
411 is the name of the PostScript file;
415 give the desired width and height of the image.
421 argument is specified, the image's natural width (as given in
422 the file's bounding box) or the current line length is used
423 as the width, whatever is smaller.
429 arguments may have scaling indicators attached;
430 the default scaling indicator is\~\c
433 This macro scales the graphic uniformly
434 in the x and y\~directions so that it is no more than
443 centers the graphic horizontally, which is the default.
449 options cause the graphic to be left-aligned and right-aligned,
454 option causes the graphic to be indented by\~\c
456 (default scaling indicator is\~\c
462 within a diversion it is recommended to extend it with
463 the following code, assuring that the diversion's width completely
464 covers the image's width.
471 \&\[rs]h'(\[rs]\[rs]n[ps-offset]u + \[rs]\[rs]n[ps-deswid]u)'
481 Use this for tracing macro calls.
483 It is only useful for debugging.
486 .BR groff_trace (@MAN7EXT@) .
491 Overrides the definition of standard troff characters and some groff
492 characters for TTY devices.
494 The optical appearance is intentionally inferior compared to that of
495 normal TTY formatting to allow processing with critical equipment.
500 Additions of elements known from the HTML format, as used in the
501 internet (World Wide Web) pages; this includes URL links and mail
503 .BR groff_www (@MAN7EXT@).
506 .\" --------------------------------------------------------------------
508 .\" --------------------------------------------------------------------
510 Classical roff systems were designed before the conventions of the
513 call evolved, and used a naming scheme for macro packages that looks
514 odd to modern eyes. Macro packages were always included with the option
516 when this option was directly followed by its argument without an
517 intervening space, this looked like a long option preceded by a single
518 minus \[em] a sensation in the computer stone age.
519 To make this invocation form work, classical troff
520 macro packages used names that started with the letter `m',
521 which was omitted in the naming of the macro file.
525 For example, the macro package for the man pages was called
529 So it could be activated by the argument
539 For similar reasons, macro packages that did not start with an `m'
541 added in the documentation and in speech; for example, the package
546 in the documentation, although a more suitable name would be
548 For, when omitting the space between the option and its argument, the
549 command line option for activating this package reads
554 To cope with all situations, actual versions of
555 .BR groff (@MAN1EXT@)
556 are smart about both naming schemes by providing two macro files
557 for the inflicted macro packages; one with a leading `m'
558 the other one without it.
564 macro package may be specified as on of the following four methods:
568 \fIsh#\fP groff\ \-m\ man
569 \fIsh#\fP groff\ \-man
570 \fIsh#\fP groff\ \-mman
571 \fIsh#\fP groff\ \-m\ an
576 Recent packages that do not start with `m'
577 do not use an additional `m'
578 in the documentation.
582 macro package may be specified only as one of the two methods:
586 \fIsh#\fP groff\ \-m\ www
587 \fIsh#\fP groff\ \-mwww
592 Obviously, variants like
594 would not make much sense.
598 A second strange feature of classical troff was to name macro files
599 in the form \f[B]tmac.\f[]\f[I]name\f[].
600 In modern operating systems, the type of a file is specified as a
601 postfix, the file name extension.
603 Again, groff copes with this situation by searching both
613 The easiest way to find out which macro packages are available on a
614 system is to check the man\~page
615 .BR groff (@MAN1EXT@),
616 or the contents of the
624 most macro packages are described in\~man pages called
625 .BR groff_\f[I]name\f[] (@MAN7EXT@),
627 for the classical packages.
630 .\" --------------------------------------------------------------------
632 .\" --------------------------------------------------------------------
634 There are several ways to use a macro package in a document.
636 The classical way is to specify the troff/groff option
639 at run-time; this makes the contents of the macro package
645 is searched within the tmac path; if not found,
647 is searched for instead.
651 Alternatively, it is also possible to include a macro file by adding
655 into the document; the argument must be the full file name of an
656 existing file, possibly with the directory where it is kept.
658 In groff, this was improved by the similar request
661 which added searching in the tmac path, just like option
667 Note that in order to resolve the
671 requests, the roff preprocessor
672 .BR soelim (@MAN1EXT@)
673 must be called if the files to be included need preprocessing.
675 This can be done either directly by a pipeline on the command line or
676 by using the troff/groff option
680 calls soelim automatically.
684 For example, suppose a macro file is stored as
687 .I @MACRODIR@/macros.tmac
690 and is used in some document called
695 At run-time, the formatter call for this is
699 \fIsh#\fP groff \-m macros docu.roff
704 To include the macro file directly in the document either
716 \&.so @MACRODIR@/macros.tmac
721 In both cases, the formatter should be called with option
727 \fIsh#\fP groff \-s docu.roff
732 If you want to write your own groff macro file, call it
734 and put it in some directory of the tmac path, see section
736 Then documents can include it with the
738 request or the option
743 .\" --------------------------------------------------------------------
745 .\" --------------------------------------------------------------------
747 .\" This section does not fit into the framework of this document.
749 There is a convention that is supported by many modern roff
754 described in the following.
757 If the first line in a document is a comment, the first word (after the
758 comment characters and a blank) constitutes the
761 That means that the letters of this word are interpreted as
762 abbreviations for those preprocessor commands that should be run
763 when formatting the document.
765 Mostly, only the letters corresponding to the options for the
766 preprocessors are recognized,
786 .BR roff (@MAN7EXT@)).
790 Besides being a good reminder for the user, some formatters (like the
792 program) are even able to automatically start the preprocessors
793 specified in the preprocessor word, but do not bet on this.
799 program handles some preprocessors automatically, such that in
800 man\~pages only the following characters should be used:
805 .\" --------------------------------------------------------------------
807 .\" --------------------------------------------------------------------
811 document is a text file that is enriched by predefined formatting
812 constructs, such as requests, escape sequences, strings, numeric
813 registers, and macros from a macro package.
815 These elements are described in
816 .BR roff (@MAN7EXT@).
820 To give a document a personal style, it is most useful to extend the
821 existing elements by defining some macros for repeating tasks; the best
822 place for this is near the beginning of the document or in a separate
827 Macros without arguments are just like strings.
829 But the full power of macros reveals when arguments are passed with a
832 Within the macro definition, the arguments are available as the escape
837 .BR \[rs]$[ \*[Ellipsis] ] ,
841 the name under which the macro was called is in
843 and the number of arguments is in register
846 .BR groff (@MAN7EXT@).
849 .\" --------------------------------------------------------------------
851 .\" --------------------------------------------------------------------
853 The phase when groff reads a macro is called
859 This is comparable to the C\~preprocessing phase during the development
860 of a program written in the C\~language.
864 In this phase, groff interprets all backslashes; that means that all
865 escape sequences in the macro body are interpreted and replaced by
868 For constant expressions, this is wanted, but strings and registers
869 that might change between calls of the macro must be protected from
872 This is most easily done by doubling the backslash that introduces the
875 This doubling is most important for the positional parameters.
877 For example, to print information on the arguments that were passed to
878 the macro to the terminal, define a macro named `.print_args',
883 .ds @1 \[rs]f[I]\[rs]\[rs]$0\[rs]f[]\"
886 \&.ds midpart was called with
888 \&.\ \ tm\ \*[@1]\ \[rs]*[midpart]\ \[rs]\[rs]n[.$]\ \*[@2]
889 \&.\ \ tm\ \[rs]\[rs]$*
897 When calling this macro by
901 \&.print_args arg1 arg2
905 the following text is printed to the terminal:
909 \&\f[CI]print_args\f[] was called with the following 2 arguments:
915 Let's analyze each backslash in the macro definition.
917 As the positional parameters and the number of arguments change
918 with each call of the macro their leading backslash must be doubled,
923 The same applies to the macro name because it could be called with an
931 is a constant string, it does not change, so no doubling for
932 .IR \[rs]*[midpart] .
935 escape sequences are predefined groff elements for setting the font
938 Of course, this behavior does not change, so no doubling with
944 .\" --------------------------------------------------------------------
946 .\" --------------------------------------------------------------------
948 Writing groff macros is easy when the escaping mechanism is temporarily
951 In groff, this is done by enclosing the macro definition(s) into a
958 Then the body in the macro definition is just like a normal part of
959 the document \[em] text enhanced by calls of requests, macros,
960 strings, registers, etc.
962 For example, the code above can be written in a simpler way by
966 .ds @1 \[rs]f[I]\[rs]$0\[rs]f[]\"
970 \&.ds midpart was called with
972 \&.\ \ tm\ \*[@1]\ \[rs]*[midpart]\ \[rs]n[.$]\ \*[@2]
982 Unfortunately, draft mode cannot be used universally.
984 Although it is good enough for defining normal macros, draft mode
985 fails with advanced applications, such as indirectly defined
986 strings, registers, etc.
988 An optimal way is to define and test all macros in draft mode and then
989 do the backslash doubling as a final step; do not forget to remove the
994 .\" --------------------------------------------------------------------
995 .SS "Tips for Macro Definitions"
996 .\" --------------------------------------------------------------------
999 Start every line with a dot, for example, by using the groff request
1001 for text lines, or write your own macro that handles also text lines
1008 \&.\ \ if (\[rs]\[rs]n[.$] == 0)\ \[rs]
1010 \&.\ \ nop\ \[rs])\[rs]\[rs]$*\[rs])
1016 Write a comment macro that works both for copy-in and draft mode; for
1017 as escaping is off in draft mode, trouble might occur when normal
1020 For example, the following macro just ignores its arguments, so it
1021 acts like a comment line:
1028 \&.c\ This\ is\ like\ a\ comment\ line.
1033 In long macro definitions, make ample use of comment lines or
1034 almost-empty lines (this is, lines which have a leading dot
1035 and nothing else) for a better structuring.
1038 To increase readability, use groff's indentation facility for requests
1039 and macro calls (arbitrary whitespace after the leading dot).
1042 .\" --------------------------------------------------------------------
1044 .\" --------------------------------------------------------------------
1046 Diversions can be used to implement quite advanced programming
1049 They are comparable to pointers to large data structures in the
1050 C\~programming language, but their usage is quite different.
1054 In their simplest form, diversions are multi-line strings, but
1055 they get their power when diversions are used dynamically within macros.
1057 The (formatted) information stored in a diversion can be retrieved by
1058 calling the diversion just like a macro.
1062 Most of the problems arising with diversions can be avoided if you remain
1063 aware of the fact that diversions always store complete lines.
1065 If diversions are used when the line buffer has not been flushed,
1066 strange results are produced; not knowing this, many people get
1067 desperate about diversions.
1069 To ensure that a diversion works, line breaks should be added at the
1072 To be on the secure side, enclose everything that has to do with
1073 diversions into a pair of line breaks; for example, by explicitly using
1077 This rule should be applied to diversion definition, both inside and
1078 outside, and to all calls of diversions.
1080 This is a bit of overkill, but it works nicely.
1084 [If you really need diversions which should ignore the current partial
1085 line, use environments to save the current partial line and/\:or use the
1091 The most powerful feature using diversions is to start a diversion
1092 within a macro definition and end it within another macro.
1094 Then everything between each call of this macro pair is stored within
1095 the diversion and can be manipulated from within the macros.
1098 .\" --------------------------------------------------------------------
1100 .\" --------------------------------------------------------------------
1102 All macro names must be named
1104 to fully use the tmac mechanism.
1107 as with classical packages is possible as well, but deprecated.
1111 The macro files are kept in the
1112 .IR "tmac directories" ;
1113 a colon separated list of these constitutes the
1118 The search sequence for macro files is (in that order):
1121 the directories specified with troff/groff's
1126 the directories given in the
1128 environment variable
1131 the current directory (only if in unsafe mode, which is enabled by the
1133 command line switch)
1139 a platform-specific directory, being
1147 in this installation
1150 a site-specific (platform-independent) directory, being
1158 in this installation
1161 the main tmac directory, being
1169 in this installation
1172 .\" --------------------------------------------------------------------
1174 .\" --------------------------------------------------------------------
1178 A colon separated list of additional tmac directories in which to search
1181 See the previous section for a detailed description.
1184 .\" --------------------------------------------------------------------
1186 .\" --------------------------------------------------------------------
1188 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008
1189 Free Software Foundation, Inc.
1192 This document is distributed under the terms of the FDL (GNU Free
1193 Documentation License) version 1.1 or later.
1195 You should have received a copy of the FDL on your system, it is also
1196 available on-line at the
1197 .UR http://\:www.gnu.org/\:copyleft/\:fdl.html
1202 This document is part of
1204 the GNU roff distribution.
1216 .\" --------------------------------------------------------------------
1218 .\" --------------------------------------------------------------------
1220 A complete reference for all parts of the groff system is found in the
1227 .BR groff (@MAN1EXT@)
1228 an overview of the groff system.
1232 .BR groff_man (@MAN7EXT@),
1234 .BR groff_mdoc (@MAN7EXT@),
1236 .BR groff_me (@MAN7EXT@),
1238 .BR groff_mm (@MAN7EXT@),
1240 .BR groff_mom (@MAN7EXT@),
1242 .BR groff_ms (@MAN7EXT@),
1244 .BR groff_trace (@MAN7EXT@),
1246 .BR groff_www (@MAN7EXT@).
1247 the groff tmac macro packages.
1251 .BR groff (@MAN7EXT@)
1256 The Filesystem Hierarchy Standard is available at the
1257 .UR http://\:www.pathname.com/\:fhs/
1261 .\" Local Variables: