1 .TH GROFF_TMAC @MAN5EXT@ "@MDATE@" "groff @VERSION@"
3 groff_tmac \- macro files in the roff typesetting system
6 .\" Source file position: <groff_source>/man/groff_tmac.man
7 .\" Installed position: <prefix>/share/man/man5/groff_tmac.5
10 .\" Save and disable compatibility mode (for, e.g., Solaris 10/11).
11 .do nr groff_tmac_C \n[.C]
15 .\" ====================================================================
17 .\" ====================================================================
19 .\" Copyright (C) 2000-2018 Free Software Foundation, Inc.
21 .\" This file is part of groff, the GNU roff type-setting system.
23 .\" Permission is granted to copy, distribute and/or modify this
24 .\" document under the terms of the GNU Free Documentation License,
25 .\" Version 1.3 or any later version published by the Free Software
26 .\" Foundation; with no Invariant Sections, with no Front-Cover Texts,
27 .\" and with no Back-Cover Texts.
29 .\" A copy of the Free Documentation License is included as a file
30 .\" called FDL in the main directory of the groff source package.
33 .ds Ellipsis \&.\|.\|.\&\"
36 .\" ====================================================================
38 .\" ====================================================================
42 type-setting system provides a set of macro packages suitable for
43 special kinds of documents.
45 Each macro package stores its macros and definitions in a file called
49 The name is deduced from
56 The tmac files are normal roff source documents, except that they
57 usually contain only definitions and setup commands, but no text.
59 All tmac files are kept in a single or a small number of directories,
65 .\" ====================================================================
66 .SH "GROFF MACRO PACKAGES"
67 .\" ====================================================================
70 provides all classical macro packages, some more full packages, and
71 some secondary packages for special purposes.
73 Note that it is not possible to use multiple primary macro packages at
74 the same time; saying e.g.\&
78 \fIsh#\fP groff \-m man \-m ms foo
87 \fIsh#\fP groff \-m man foo \-m ms bar
93 Exception to this is the use of man pages written with either the
98 See below the description of the
103 .\" ====================================================================
105 .\" ====================================================================
109 This is the classical macro package for Unix manual pages
110 (man\~pages); it is quite handy and easy to use; see
111 .BR groff_man (@MAN7EXT@).
118 An alternative macro package for man\~pages mainly used in BSD
119 systems; it provides many new features, but it is not the standard for
121 .BR groff_mdoc (@MAN7EXT@).
128 Use this file in case you don't know whether the
132 package should be used.
133 Multiple man pages (in either format) can be handled.
136 .\" ====================================================================
138 .\" ====================================================================
140 The packages in this section provide a complete set of macros for
141 writing documents of any kind, up to whole books.
143 They are similar in functionality; it is a matter of taste which one
152 .BR groff_me (@MAN7EXT@).
160 .BR groff_mm (@MAN7EXT@).
167 macro package, only available in groff.
169 As this is not based on other packages, it can be freely designed.
171 So it is expected to become quite a nice, modern macro package.
174 .BR groff_mom (@MAN7EXT@).
182 .BR groff_ms (@MAN7EXT@).
185 .\" ====================================================================
186 .SS "Language-specific Packages"
187 .\" ====================================================================
191 This file adds support for Czech localization, including the main macro
192 packages (me, mom, mm, and ms).
197 sets the input encoding to latin-2.
204 German localization support, including the main macro packages (me, mom,
209 selects hyphenation patterns for traditional orthography, and
211 does the same for the new orthography
212 (\[oq]Recht\%schreib\%reform\[cq]).
214 It should be used as the last macro package on the command line.
219 This file adds support for French localization, including the main macro
220 packages (me, mom, mm, and ms).
227 \fIsh#\fP groff \-ms \-mfr foo.ms > foo.ps
234 sets the input encoding to latin-9 to get proper support of the
235 \[oq]oe\[cq] ligature.
240 Swedish localization support, including the me, mom, and ms macro
243 Note that Swedish for the mm macros is handled separately; see
244 .BR groff_mmse (@MAN7EXT@).
246 It should be used as the last macro package on the command line.
249 .\" ====================================================================
250 .SS "Input Encodings"
251 .\" ====================================================================
262 Various input encodings supported directly by groff.
264 Normally, this macro is loaded at the very beginning of a document or
265 specified as the first macro argument on the command line.
268 loads latin1 by default at start-up.
270 Note that these macro packages don't work on EBCDIC hosts.
275 Encoding support for EBCDIC.
277 On those platforms it is loaded automatically at start-up.
279 Due to different character ranges used in
281 it doesn't work on architectures which are based on ASCII.
285 Note that it can happen that some input encoding characters are not
286 available for a particular output device.
292 groff \-Tlatin1 \-mlatin9 ...
296 fails if you use the Euro character in the input.
298 Usually, this limitation is present only for devices which have a
299 limited set of output glyphs
302 for other devices it is usually sufficient to install proper
303 fonts which contain the necessary glyphs.
306 .\" ====================================================================
307 .SS "Special Packages"
308 .\" ====================================================================
310 The macro packages in this section are not intended for stand-alone
311 usage, but can be used to add special functionality to any other
312 macro package or to plain groff.
317 Provides macros for addition, multiplication, and division of 62-bit
318 integers (allowing safe multiplication of 31-bit integers, for example).
323 Switch to the EC and TC font families.
326 .BR \%grodvi (@MAN1EXT@)
327 \[en] this man page also gives more details of how to use it.
332 The Heidelberger table macros, contributed by Joachim Walsdorff, allow
333 the generation of tables through a syntax similar to the HTML table
338 is a macro package, not a preprocessor like
349 .BR groff_hdtbl (@MAN7EXT@) .
354 This macro file is already loaded at start-up by
356 so it isn't necessary to call it explicitly.
358 It provides an interface to set the paper size on the command line with
359 the option \f[B]\%\-dpaper=\f[]\,\f[I]size\f[].
363 are the same as the predefined
365 values in the DESC file (only lowercase; see
366 .BR groff_font (@MAN5EXT@)
372 (ell) character denotes landscape orientation.
380 Most output drivers need additional command-line switches
384 to override the default paper length and orientation as set in the
385 driver-specific DESC file.
387 For example, use the following for PS output on A4 paper in landscape
392 \fIsh#\fP groff \-Tps \-dpaper=a4l \-P\-pa4 \-P\-l \-ms foo.ms > foo.ps
398 A single macro is provided in this file,
400 to include a PDF graphic in a document, i.e., under the output device
403 For all other devices,
412 By that you can now even replace all
416 nothing gets lost by that.
427 This file provides proper definitions for the macros
432 .BR @g@pic (@MAN1EXT@)
435 They center each picture.
437 Use it only if your macro package doesn't provide proper
438 definitions for those two macros (actually, most of them already do).
443 A single macro is provided in this file,
445 to include a PostScript graphic in a document.
447 The following output devices support inclusion of PS images:
453 for all other devices the image is replaced with a hollow rectangle
456 This macro file is already loaded at start-up by
458 so it isn't necessary to call it explicitly.
468 |\|\fB\-I\fP\ \fIn\fP] \
469 \fI\|file\fP [\fIwidth\fP [\,\fIheight\/\fP]]
474 is the name of the PostScript file;
478 give the desired width and height of the image.
484 argument is specified, the image's natural width (as given in the
485 file's bounding box) or the current line length is used as the
486 width, whatever is smaller.
492 arguments may have scaling indicators attached;
493 the default scaling indicator is\~\c
496 This macro scales the graphic uniformly
497 in the x and y\~directions so that it is no more than
506 centers the graphic horizontally, which is the default.
512 options cause the graphic to be left-aligned and right-aligned,
517 option causes the graphic to be indented by\~\c
519 (default scaling indicator is\~\c
525 within a diversion it is recommended to extend it with the following
526 code, assuring that the diversion's width completely covers the
534 \&\[rs]h'(\[rs]\[rs]n[ps-offset]u + \[rs]\[rs]n[ps-deswid]u)'
544 A single macro is provided in this file,
546 for formatting permuted index entries as produced by the GNU
550 In case you need a different formatting, copy the macro into
551 your document and adapt it to your needs.
556 Use this for tracing macro calls.
558 It is only useful for debugging.
561 .BR groff_trace (@MAN7EXT@) .
566 Overrides the definition of standard troff characters and some groff
567 characters for TTY devices.
569 The optical appearance is intentionally inferior compared to that of
570 normal TTY formatting to allow processing with critical equipment.
575 Additions of elements known from the HTML format, as used in the
576 internet (World Wide Web) pages; this includes URL links and mail
578 .BR groff_www (@MAN7EXT@).
581 .\" ====================================================================
583 .\" ====================================================================
585 Classical roff systems were designed before the conventions of the
588 call evolved, and used a naming scheme for macro packages that looks
591 Macro packages were always included with the option
593 when this option was directly followed by its argument without an
594 intervening space, this looked like a long option preceded by a single
595 minus \[em] a sensation in the computer stone age.
597 To make this invocation form work, classical troff
598 macro packages used names that started with the letter \[oq]m\[cq],
599 which was omitted in the naming of the macro file.
603 For example, the macro package for the man pages was called
607 So it could be activated by the argument
617 For similar reasons, macro packages that did not start with an
618 \[oq]m\[cq] had a leading \[oq]m\[cq] added in the documentation and
619 in speech; for example, the package corresponding to
623 in the documentation, although a more suitable name would be
625 For, when omitting the space between the option and its argument, the
626 command-line option for activating this package reads
631 To cope with all situations, actual versions of
632 .BR groff (@MAN1EXT@)
633 are smart about both naming schemes by providing two macro files
634 for the inflicted macro packages; one with a leading \[oq]m\[cq]
635 the other one without it.
641 macro package may be specified as one of the following four methods:
645 \fIsh#\fP groff\ \-m\ man
646 \fIsh#\fP groff\ \-man
647 \fIsh#\fP groff\ \-mman
648 \fIsh#\fP groff\ \-m\ an
653 Recent packages that do not start with \[oq]m\[cq] do not use an
654 additional \[oq]m\[cq] in the documentation.
658 macro package may be specified only as one of the two methods:
662 \fIsh#\fP groff\ \-m\ www
663 \fIsh#\fP groff\ \-mwww
668 Obviously, variants like
670 would not make much sense.
674 A second strange feature of classical troff was to name macro files
677 In modern operating systems, the type of a file is specified as a
678 postfix, the file name extension.
680 Again, groff copes with this situation by searching both
690 The easiest way to find out which macro packages are available on a
691 system is to check the man\~page
692 .BR groff (@MAN1EXT@),
693 or the contents of the
701 most macro packages are described in\~man pages called
702 .BR groff_\f[I]name\f[] (@MAN7EXT@),
703 with a leading \[oq]m\[cq] for the classical packages.
706 .\" ====================================================================
708 .\" ====================================================================
710 There are several ways to use a macro package in a document.
712 The classical way is to specify the troff/groff option
715 at run-time; this makes the contents of the macro package
721 is searched within the tmac path; if not found,
723 is searched for instead.
727 Alternatively, it is also possible to include a macro file by adding
731 into the document; the argument must be the full file name of an
732 existing file, possibly with the directory where it is kept.
734 In groff, this was improved by the similar request
737 which added searching in the tmac path, just like option
743 Note that in order to resolve the
747 requests, the roff preprocessor
748 .BR soelim (@MAN1EXT@)
749 must be called if the files to be included need preprocessing.
751 This can be done either directly by a pipeline on the command line or
752 by using the troff/groff option
756 calls soelim automatically.
760 For example, suppose a macro file is stored as
763 .I @MACRODIR@/macros.tmac
766 and is used in some document called
771 At run-time, the formatter call for this is
775 \fIsh#\fP groff \-m macros docu.roff
780 To include the macro file directly in the document either
792 \&.so @MACRODIR@/macros.tmac
797 In both cases, the formatter should be called with option
803 \fIsh#\fP groff \-s docu.roff
808 If you want to write your own groff macro file, call it
810 and put it in a directory in the tmac path;
811 see section \[lq]Files\[rq] below.
813 Then documents can include it with the
815 request or the option
820 .\" ====================================================================
822 .\" ====================================================================
824 .\" This section does not fit into the framework of this document.
826 There is a convention that is supported by many modern roff
831 described in the following.
834 If the first line in a document is a comment, the first word (after the
835 comment characters and a blank) constitutes the
838 That means that the letters of this word are interpreted as
839 abbreviations for those preprocessor commands that should be run
840 when formatting the document.
842 Mostly, only the letters corresponding to the options for the
843 preprocessors are recognized,
863 .BR roff (@MAN7EXT@)).
867 Besides being a good reminder for the user, some formatters (like the
869 program) are even able to automatically start the preprocessors
870 specified in the preprocessor word, but do not bet on this.
876 program handles some preprocessors automatically, such that in
877 man\~pages only the following characters should be used:
878 \[oq]e\[cq], \[oq]p\[cq], and \[oq]t\[cq].
882 .\" ====================================================================
884 .\" ====================================================================
888 document is a text file that is enriched by predefined formatting
889 constructs, such as requests, escape sequences, strings, numeric
890 registers, and macros from a macro package.
892 These elements are described in
893 .BR roff (@MAN7EXT@).
897 To give a document a personal style, it is most useful to extend the
898 existing elements by defining some macros for repeating tasks; the best
899 place for this is near the beginning of the document or in a separate
904 Macros without arguments are just like strings.
906 But the full power of macros reveals when arguments are passed with a
909 Within the macro definition, the arguments are available as the escape
914 .BR \[rs]$[ \*[Ellipsis] ] ,
918 the name under which the macro was called is in
920 and the number of arguments is in register
923 .BR groff (@MAN7EXT@).
926 .\" ====================================================================
928 .\" ====================================================================
930 The phase when groff reads a macro is called
936 This is comparable to the C\~preprocessing phase during the development
937 of a program written in the C\~language.
941 In this phase, groff interprets all backslashes; that means that all
942 escape sequences in the macro body are interpreted and replaced by
945 For constant expressions, this is wanted, but strings and registers
946 that might change between calls of the macro must be protected from
949 This is most easily done by doubling the backslash that introduces the
952 This doubling is most important for the positional parameters.
954 For example, to print information on the arguments that were passed to
955 the macro to the terminal, define a macro named \[oq].print_args\[cq],
960 .ds @1 \[rs]f[I]\[rs]\[rs]$0\[rs]f[]\"
963 \&.ds midpart was called with
965 \&.\ \ tm\ \*[@1]\ \[rs]*[midpart]\ \[rs]\[rs]n[.$]\ \*[@2]
966 \&.\ \ tm\ \[rs]\[rs]$*
974 When calling this macro by
978 \&.print_args arg1 arg2
982 the following text is printed to the terminal:
986 \&\f[CI]print_args\f[] was called with the following 2 arguments:
992 Let's analyze each backslash in the macro definition.
994 As the positional parameters and the number of arguments change
995 with each call of the macro their leading backslash must be doubled,
999 .RI \[rs]\[rs] [.$] .
1000 The same applies to the macro name because it could be called with an
1008 is a constant string, it does not change, so no doubling for
1009 .RI \[rs] *[midpart] .
1012 escape sequences are predefined groff elements for setting the font
1015 Of course, this behavior does not change, so no doubling with
1021 .\" ====================================================================
1023 .\" ====================================================================
1025 Writing groff macros is easy when the escaping mechanism is temporarily
1028 In groff, this is done by enclosing the macro definition(s) into a
1035 Then the body in the macro definition is just like a normal part of
1036 the document \[em] text enhanced by calls of requests, macros,
1037 strings, registers, etc.
1039 For example, the code above can be written in a simpler way by
1043 .ds @1 \[rs]f[I]\[rs]$0\[rs]f[]\"
1047 \&.ds midpart was called with
1049 \&.\ \ tm\ \*[@1]\ \[rs]*[midpart]\ \[rs]n[.$]\ \*[@2]
1059 Unfortunately, draft mode cannot be used universally.
1061 Although it is good enough for defining normal macros, draft mode
1062 fails with advanced applications, such as indirectly defined
1063 strings, registers, etc.
1065 An optimal way is to define and test all macros in draft mode and then
1066 do the backslash doubling as a final step; do not forget to remove the
1071 .\" ====================================================================
1072 .SS "Tips for Macro Definitions"
1073 .\" ====================================================================
1076 Start every line with a dot, for example, by using the groff request
1078 for text lines, or write your own macro that handles also text lines
1085 \&.\ \ if (\[rs]\[rs]n[.$] == 0)\ \[rs]
1087 \&.\ \ nop\ \[rs])\[rs]\[rs]$*\[rs])
1093 Write a comment macro that works both for copy-in and draft mode; for
1094 as escaping is off in draft mode, trouble might occur when normal
1097 For example, the following macro just ignores its arguments, so it
1098 acts like a comment line:
1105 \&.c\ This\ is\ like\ a\ comment\ line.
1110 In long macro definitions, make ample use of comment lines or
1111 almost-empty lines (this is, lines which have a leading dot
1112 and nothing else) for a better structuring.
1115 To increase readability, use groff's indentation facility for
1116 requests and macro calls (arbitrary whitespace after the leading dot).
1119 .\" ====================================================================
1121 .\" ====================================================================
1123 Diversions can be used to implement quite advanced programming
1126 They are comparable to pointers to large data structures in the
1127 C\~programming language, but their usage is quite different.
1131 In their simplest form, diversions are multi-line strings, but
1132 they get their power when diversions are used dynamically within macros.
1134 The (formatted) information stored in a diversion can be retrieved by
1135 calling the diversion just like a macro.
1139 Most of the problems arising with diversions can be avoided if you
1140 remain aware of the fact that diversions always store complete lines.
1142 If diversions are used when the line buffer has not been flushed,
1143 strange results are produced; not knowing this, many people get
1144 desperate about diversions.
1146 To ensure that a diversion works, line breaks should be added at the
1149 To be on the secure side, enclose everything that has to do with
1150 diversions into a pair of line breaks; for example, by explicitly using
1154 This rule should be applied to diversion definition, both inside and
1155 outside, and to all calls of diversions.
1157 This is a bit of overkill, but it works nicely.
1161 [If you really need diversions which should ignore the current partial
1162 line, use environments to save the current partial line and/\:or use the
1168 The most powerful feature using diversions is to start a diversion
1169 within a macro definition and end it within another macro.
1171 Then everything between each call of this macro pair is stored within
1172 the diversion and can be manipulated from within the macros.
1175 .\" ====================================================================
1177 .\" ====================================================================
1179 All macro package files must be named
1181 to fully use the tmac mechanism.
1184 as with classical packages is possible as well, but deprecated.
1188 The macro files are kept in the
1189 .IR "tmac directories" ;
1190 a colon separated list of these constitutes the
1195 The search sequence for macro files is (in that order):
1198 the directories specified with troff/groff's
1203 the directories given in the
1205 environment variable
1208 the current directory (only if in unsafe mode, which is enabled by the
1210 command-line switch)
1216 a platform-specific directory, being
1224 in this installation
1227 a site-specific (platform-independent) directory, being
1235 in this installation
1238 the main tmac directory, being
1246 in this installation
1249 .\" ====================================================================
1251 .\" ====================================================================
1255 A colon separated list of additional tmac directories in which to search
1258 See the previous section for a detailed description.
1261 .\" ====================================================================
1263 .\" ====================================================================
1264 This document was written by
1265 .MT groff\-bernd.warken\-72@\:web.de
1272 .\" ====================================================================
1274 .\" ====================================================================
1276 .IR "Groff: The GNU Implementation of troff" ,
1277 by Trent A.\& Fisher and Werner Lemberg,
1282 You can browse it interactively with \[lq]info groff\[rq].
1286 .BR groff (@MAN1EXT@)
1287 an overview of the groff system.
1291 .BR groff_man (@MAN7EXT@),
1293 .BR groff_mdoc (@MAN7EXT@),
1295 .BR groff_me (@MAN7EXT@),
1297 .BR groff_mm (@MAN7EXT@),
1299 .BR groff_mom (@MAN7EXT@),
1301 .BR groff_ms (@MAN7EXT@),
1303 .BR groff_trace (@MAN7EXT@),
1305 .BR groff_www (@MAN7EXT@).
1306 the groff tmac macro packages.
1310 .BR groff (@MAN7EXT@)
1315 The Filesystem Hierarchy Standard is available at the
1316 .UR http://\:www.pathname.com/\:fhs/
1321 .\" Restore compatibility mode (for, e.g., Solaris 10/11).
1322 .cp \n[groff_tmac_C]
1325 .\" ====================================================================
1327 .\" ====================================================================
1329 .\" Local Variables:
1333 .\" vim: set filetype=groff textwidth=72: