4 File position: <groff-source>/man/groff_tmac.man
6 Last update: 8 Feb 2007
8 This file is part of groff, the GNU roff type-setting system.
10 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007
11 Free Software Foundation, Inc.
12 written by Bernd Warken <bwarken@mayn.de> and Werner Lemberg
15 Permission is granted to copy, distribute and/or modify this document
16 under the terms of the GNU Free Documentation License, Version 1.1 or
17 any later version published by the Free Software Foundation; with the
18 Invariant Sections being this .ig-section and AUTHOR, with no
19 Front-Cover Texts, and with no Back-Cover Texts.
21 A copy of the Free Documentation License is included as a file called
22 FDL in the main directory of the groff source package.
24 .ds Ellipsis \&.\|.\|.\&\"
26 .TH GROFF_TMAC @MAN5EXT@ "@MDATE@" "Groff Version @VERSION@"
28 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
84 .\" --------------------------------------------------------------------
86 .\" --------------------------------------------------------------------
90 This is the classical macro package for UNIX manual pages
91 (man\~pages); it is quite handy and easy to use; see
92 .BR groff_man (@MAN7EXT@).
99 An alternative macro package for man\~pages mainly used in BSD
100 systems; it provides many new features, but it is not the standard for
102 .BR groff_mdoc (@MAN7EXT@).
105 .\" --------------------------------------------------------------------
107 .\" --------------------------------------------------------------------
109 The packages in this section provide a complete set of macros for
110 writing documents of any kind, up to whole books.
112 They are similar in functionality; it is a matter of taste which one
121 .BR groff_me (@MAN7EXT@).
129 .BR groff_mm (@MAN7EXT@).
136 macro package, only available in groff.
138 As this is not based on other packages, it can be freely designed.
140 So it is expected to become quite a nice, modern macro package.
143 .BR groff_mom (@MAN7EXT@).
151 .BR groff_ms (@MAN7EXT@).
154 .\" --------------------------------------------------------------------
155 .SS "Language-specific Packages"
156 .\" --------------------------------------------------------------------
163 German localization support, including the main macro packages (me, mom, mm,
168 selects hyphenation patterns for traditional orthography, and
170 does the same for the new orthography (`Rechtschreibreform').
172 It should be used as the last macro package on the command line.
177 This file adds support for French localization, including the main macro
178 packages (me, mom, mm, and ms).
185 \fIsh#\fP groff -ms -mfr foo.ms > foo.ps
191 sets the input encoding to latin-9 to get proper support of the `oe'
197 Swedish localization support, including the me, mom, and ms macro packages.
199 Note that Swedish for the mm macros is handled separately; see
200 .BR groff_mmse (@MAN7EXT@).
202 It should be used as the last macro package on the command line.
205 .\" --------------------------------------------------------------------
206 .SS "Input Encodings"
207 .\" --------------------------------------------------------------------
218 Various input encodings supported directly by groff.
220 Normally, this macro is loaded at the very beginning of a document or
221 specified as the first macro argument on the command line.
224 loads latin1 by default at start-up.
226 Note that these macro packages don't work on EBCDIC hosts.
231 Encoding support for EBCDIC.
233 On those platforms it is loaded automatically at start-up.
235 Due to different character ranges used in
237 it doesn't work on architectures which are based on ASCII.
241 Note that it can happen that some input encoding characters are not
242 available for a particular output device.
248 groff -Tlatin1 -mlatin9 ...
252 fails if you use the Euro character in the input.
254 Usually, this limitation is present only for devices which have a
255 limited set of output glyphs
258 for other devices it is usually sufficient to install proper
259 fonts which contain the necessary glyphs.
262 .\" --------------------------------------------------------------------
263 .SS "Special Packages"
264 .\" --------------------------------------------------------------------
266 The macro packages in this section are not intended for stand-alone
267 usage, but can be used to add special functionality to any other
268 macro package or to plain groff.
273 Provide some macros for addition, multiplication, and division of 60bit
274 integers (allowing safe multiplication of 30bit integers, for example).
279 Switch to the EC and TC font families.
282 .BR \%grodvi (@MAN1EXT@)
283 \[en] this man page also gives more details of how to use it.
288 This macro file is already loaded at start-up by
290 so it isn't necessary to call it explicitly.
292 It provides an interface to set the paper size on the command line with
293 the option \f[B]\%\-dpaper=\f[]\f[I]size\f[].
297 are the same as the predefined
299 values in the DESC file (only lowercase; see
300 .BR groff_font (@MAN5EXT@)
306 (ell) character denotes landscape orientation.
314 Most output drivers need additional command line switches
318 to override the default paper length and orientation as set in the driver
321 For example, use the following for PS output on A4 paper in landscape
326 \fIsh#\fP groff \-Tps \-dpaper=a4l \-P\-pa4 \-P\-l \-ms foo.ms > foo.ps
332 This file provides proper definitions for the macros
337 .BR @g@pic (@MAN1EXT@)
340 They center each picture.
342 Use it only if your macro package doesn't provide proper definitions
343 for those two macros (actually, most of them already do).
348 A single macro is provided in this file,
350 to include a PostScript graphic in a document.
352 The following output devices support inclusion of PS images:
357 for all other devices the image is replaced with a hollow rectangle
360 This macro file is already loaded at start-up by
362 so it isn't necessary to call it explicitly.
368 \&\fB.PSPIC\fP [\fB\-L\fP\||\|\fB-R\fP\||\|\fB\-I\fP\ \fIn\fP] \
369 \fI\|file\fP [\fIwidth\fP [\fIheight\fP]]
374 is the name of the PostScript file;
378 give the desired width and height of the image.
384 argument is specified, the image's natural width (as given in
385 the file's bounding box) or the current line length is used
386 as the width, whatever is smaller.
392 arguments may have scaling indicators attached;
393 the default scaling indicator is\~\c
396 This macro scales the graphic uniformly
397 in the x and y\~directions so that it is no more than
404 By default, the graphic is horizontally centered.
410 options cause the graphic to be left-aligned and right-aligned,
415 option causes the graphic to be indented by\~\c
417 (default scaling indicator is\~\c
423 within a diversion it is recommended to extend it with
424 the following code, assuring that the diversion's width completely
425 covers the image's width.
432 \&\eh'(\e\en[ps-offset]u + \e\en[ps-deswid]u)'
442 Use this for tracing macro calls.
444 It is only useful for debugging.
447 .BR groff_trace (@MAN7EXT@) .
452 Overrides the definition of standard troff characters and some groff
453 characters for tty devices.
455 The optical appearance is intentionally inferior compared to that of
456 normal tty formatting to allow processing with critical equipment.
461 Additions of elements known from the html format, as used in the
462 internet (World Wide Web) pages; this includes URL links and mail
464 .BR groff_www (@MAN7EXT@).
467 .\" --------------------------------------------------------------------
469 .\" --------------------------------------------------------------------
471 Classical roff systems were designed before the conventions of the
474 call evolved, and used a naming scheme for macro packages that looks
475 odd to modern eyes. Macro packages were always included with the option
477 when this option was directly followed by its argument without an
478 intervening space, this looked like a long option preceded by a single
479 minus \[em] a sensation in the computer stone age.
480 To make this invocation form work, classical troff
481 macro packages used names that started with the letter `m',
482 which was omitted in the naming of the macro file.
486 For example, the macro package for the man pages was called
490 So it could be activated by the argument
500 For similar reasons, macro packages that did not start with an `m'
502 added in the documentation and in speech; for example, the package
507 in the documentation, although a more suitable name would be
509 For, when omitting the space between the option and its argument, the
510 command line option for activating this package reads
515 To cope with all situations, actual versions of
516 .BR groff (@MAN1EXT@)
517 are smart about both naming schemes by providing two macro files
518 for the inflicted macro packages; one with a leading `m'
519 the other one without it.
525 macro package may be specified as on of the following four methods:
529 \fIsh#\fP groff\ \-m\ man
530 \fIsh#\fP groff\ \-man
531 \fIsh#\fP groff\ \-mman
532 \fIsh#\fP groff\ \-m\ an
537 Recent packages that do not start with `m'
538 do not use an additional `m'
539 in the documentation.
543 macro package may be specified only as one of the two methods:
547 \fIsh#\fP groff\ \-m\ www
548 \fIsh#\fP groff\ \-mwww
553 Obviously, variants like
555 would not make much sense.
559 A second strange feature of classical troff was to name macro files
560 in the form \fBtmac.\fIname\fR.
561 In modern operating systems, the type of a file is specified as a
562 postfix, the file name extension.
564 Again, groff copes with this situation by searching both
574 The easiest way to find out which macro packages are available on a
575 system is to check the man\~page
576 .BR groff (@MAN1EXT@),
577 or the contents of the
585 most macro packages are described in\~man pages called
586 .BR groff_\f[I]name\f[] (@MAN7EXT@),
588 for the classical packages.
591 .\" --------------------------------------------------------------------
593 .\" --------------------------------------------------------------------
595 There are several ways to use a macro package in a document.
597 The classical way is to specify the troff/groff option
600 at run-time; this makes the contents of the macro package
606 is searched within the tmac path; if not found,
608 is searched for instead.
612 Alternatively, it is also possible to include a macro file by adding
616 into the document; the argument must be the full file name of an
617 existing file, possibly with the directory where it is kept.
619 In groff, this was improved by the similar request
622 which added searching in the tmac path, just like option
628 Note that in order to resolve the
632 requests, the roff preprocessor
633 .BR soelim (@MAN1EXT@)
634 must be called if the files to be included need preprocessing.
636 This can be done either directly by a pipeline on the command line or
637 by using the troff/groff option
641 calls soelim automatically.
645 For example, suppose a macro file is stored as
646 .I @MACRODIR@/macros.tmac
647 and is used in some document called
652 At run-time, the formatter call for this is
656 \fIsh#\fP groff\ \-m\ \fImacrofile\ document.roff\fP
661 To include the macro file directly in the document either
665 \&.mso macrofile.tmac
673 \&.so @MACRODIR@/macros.tmac
678 In both cases, the formatter is called with
681 \fIsh#\fP groff\ \-s\ \fIdocu.roff\fP
686 If you want to write your own groff macro file, call it
688 and put it in some directory of the tmac path, see section
690 Then documents can include it with the
692 request or the option
697 .\" --------------------------------------------------------------------
699 .\" --------------------------------------------------------------------
701 .\" This section does not fit into the framework of this document.
703 There is a convention that is supported by many modern roff
708 described in the following.
711 If the first line in a document is a comment, the first word (after the
712 comment characters and a blank) constitutes the
715 That means that the letters of this word are interpreted as
716 abbreviations for those preprocessor commands that should be run
717 when formatting the document.
719 Mostly, only the letters corresponding to the options for the
720 preprocessors are recognized,
740 .BR roff (@MAN7EXT@)).
744 Besides being a good reminder for the user, some formatters (like the
746 program) are even able to automatically start the preprocessors
747 specified in the preprocessor word, but do not bet on this.
753 program handles some preprocessors automatically, such that in
754 man\~pages only the following characters should be used:
759 .\" --------------------------------------------------------------------
761 .\" --------------------------------------------------------------------
765 document is a text file that is enriched by predefined formatting
766 constructs, such as requests, escape sequences, strings, numeric
767 registers, and macros from a macro package.
769 These elements are described in
770 .BR roff (@MAN7EXT@).
774 To give a document a personal style, it is most useful to extend the
775 existing elements by defining some macros for repeating tasks; the best
776 place for this is near the beginning of the document or in a separate
781 Macros without arguments are just like strings.
783 But the full power of macros reveals when arguments are passed with a
786 Within the macro definition, the arguments are available as the escape
791 .BR $[ \*[Ellipsis] ] ,
795 the name under which the macro was called is in
797 and the number of arguments is in register
800 .BR groff (@MAN7EXT@).
803 .\" --------------------------------------------------------------------
805 .\" --------------------------------------------------------------------
807 The phase when groff reads a macro is called
811 This is comparable to the C\~preprocessing phase during the development
812 of a program written in the C\~language.
816 In this phase, groff interprets all backslashes; that means that all
817 escape sequences in the macro body are interpreted and replaced by
820 For constant expression, this is wanted, but strings and registers
821 that might change between calls of the macro must be protected from
824 This is most easily done by doubling the backslash that introduces the
827 This doubling is most important for the positional parameters.
829 For example, to print information on the arguments that were passed to
830 the macro to the terminal, define a macro named `.print_args',
835 .ds @1 \ef[I]\e\e$0\ef[]\"
838 \&.ds midpart was called with
840 \&.\ \ tm\ \*[@1]\ \e\e*[midpart]\ \e\en[.$]\ \*[@2]
849 When calling this macro by
853 \&.print_args arg1 arg2
857 the following text is printed to the terminal:
861 \&\f[CI]print_args\f[] was called with the following 2 arguments:
867 Let's analyze each backslash in the macro definition.
869 As the positional parameters and the number of arguments change
870 with each call of the macro their leading backslash must be doubled,
875 The same applies to the macro name because it could be called with an
883 is a constant string, it does not change, so no doubling for
887 escape sequences are predefined groff elements for setting the font
890 Of course, this behavior does not change, so no doubling with
896 .\" --------------------------------------------------------------------
898 .\" --------------------------------------------------------------------
900 Writing groff macros is easy when the escaping mechanism is temporarily
903 In groff, this is done by enclosing the macro definition(s) into a
910 Then the body in the macro definition is just like a normal part of
911 the document \[em] text enhanced by calls of requests, macros,
912 strings, registers, etc.
914 For example, the code above can be written in a simpler way by
918 .ds @1 \ef[I]\e$0\ef[]\"
922 \&.ds midpart was called with
924 \&.\ \ tm\ \*[@1]\ \e*[midpart]\ \en[.$]\ \*[@2]
934 Unfortunately, draft mode cannot be used universally.
936 Although it is good enough for defining normal macros, draft mode
937 fails with advanced applications, such as indirectly defined
938 strings, registers, etc.
940 An optimal way is to define and test all macros in draft mode and then
941 do the backslash doubling as a final step; do not forget to remove the
946 .\" --------------------------------------------------------------------
947 .SS "Tips for Macro Definitions"
948 .\" --------------------------------------------------------------------
951 Start every line with a dot, for example, by using the groff request
953 for text lines, or write your own macro that handles also text lines
960 \&.\ \ if (\e\en[.$] == 0)\ \e
962 \&.\ \ nop\ \e)\e\e$*[rs]\)
968 Write a comment macro that works both for copy-in and draft mode; for
969 as escaping is off in draft mode, trouble might occur when normal
972 For example, the following macro just ignores its arguments, so it
973 acts like a comment line:
980 \&.c\ This\ is\ like\ a\ comment\ line.
985 In long macro definitions, make ample use of comment lines or empty
986 lines for a better structuring.
989 To increase readability, use groff's indentation facility for requests
990 and macro calls (arbitrary whitespace after the leading dot).
993 .\" --------------------------------------------------------------------
995 .\" --------------------------------------------------------------------
997 Diversions can be used to implement quite advanced programming
1000 They are comparable to pointers to large data structures in the
1001 C\~programming language, but their usage is quite different.
1005 In their simplest form, diversions are multi-line strings, but
1006 they get their power when diversions are used dynamically within macros.
1008 The information stored in a diversion can be retrieved by calling the
1009 diversion just like a macro.
1013 Most of the problems arising with diversions can be avoided if you remain
1014 aware of the fact that diversions always store complete lines.
1016 If diversions are used when the line buffer has not been flushed,
1017 strange results are produced; not knowing this, many people get
1018 desperate about diversions.
1020 To ensure that a diversion works, line breaks should be added at the
1023 To be on the secure side, enclose everything that has to do with
1024 diversions into a pair of line breaks; for example, by explicitly using
1028 This rule should be applied to diversion definition, both inside and
1029 outside, and to all calls of diversions.
1031 This is a bit of overkill, but it works nicely.
1035 [If you really need diversions which should ignore the current partial
1036 line, use environments to save the current partial line and/\:or use the
1042 The most powerful feature using diversions is to start a diversion
1043 within a macro definition and end it within another macro.
1045 Then everything between each call of this macro pair is stored within
1046 the diversion and can be manipulated from within the macros.
1049 .\" --------------------------------------------------------------------
1051 .\" --------------------------------------------------------------------
1053 All macro names must be named
1055 to fully use the tmac mechanism.
1058 as with classical packages is possible as well, but deprecated.
1062 The macro files are kept in the
1063 .IR "tmac directories" ;
1064 a colon separated list of these constitutes the
1069 The search sequence for macro files is (in that order):
1072 the directories specified with troff/groff's
1077 the directories given in the
1079 environment variable
1082 the current directory (only if in unsafe mode, which is enabled by the
1084 command line switch)
1090 a platform-specific directory, being
1092 in this installation
1095 a site-specific (platform-independent) directory, being
1097 in this installation
1100 the main tmac directory, being
1102 in this installation
1105 .\" --------------------------------------------------------------------
1107 .\" --------------------------------------------------------------------
1111 A colon separated list of additional tmac directories in which to search
1114 See the previous section for a detailed description.
1117 .\" --------------------------------------------------------------------
1119 .\" --------------------------------------------------------------------
1121 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007
1122 Free Software Foundation, Inc.
1125 This document is distributed under the terms of the FDL (GNU Free
1126 Documentation License) version 1.1 or later.
1128 You should have received a copy of the FDL on your system, it is also
1129 available on-line at the
1130 .UR http://www.gnu.org/copyleft/fdl.html
1135 This document is part of
1137 the GNU roff distribution.
1149 .\" --------------------------------------------------------------------
1151 .\" --------------------------------------------------------------------
1153 A complete reference for all parts of the groff system is found in the
1160 .BR groff (@MAN1EXT@)
1161 an overview of the groff system.
1165 .BR groff_man (@MAN7EXT@),
1167 .BR groff_mdoc (@MAN7EXT@),
1169 .BR groff_me (@MAN7EXT@),
1171 .BR groff_mm (@MAN7EXT@),
1173 .BR groff_mom (@MAN7EXT@),
1175 .BR groff_ms (@MAN7EXT@),
1177 .BR groff_trace (@MAN7EXT@),
1179 .BR groff_www (@MAN7EXT@).
1180 the groff tmac macro packages.
1184 .BR groff (@MAN7EXT@)
1189 The Filesystem Hierarchy Standard is available at the
1190 .UR http://www.pathname.com/fhs/
1194 .\" Local Variables: