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, 2009
9
Free Software Foundation, Inc.
10
written by Bernd Warken <groff-bernd.warken-72@web.de> and
11
Werner Lemberg <wl@gnu.org>
13
Permission is granted to copy, distribute and/or modify this document
14
under the terms of the GNU Free Documentation License, Version 1.3 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.
23
A copy of the GNU Free Documentation License is also available in this
24
Debian package as /usr/share/doc/groff/copyright.
26
.ds Ellipsis \&.\|.\|.\&\"
28
.TH GROFF_TMAC @MAN5EXT@ "@MDATE@" "Groff Version @VERSION@"
30
groff_tmac \- macro files in the roff typesetting system
33
.\" --------------------------------------------------------------------
35
.\" --------------------------------------------------------------------
39
type-setting system provides a set of macro packages suitable for
40
special kinds of documents.
42
Each macro package stores its macros and definitions in a file called
45
The name is deduced from
51
The tmac files are normal roff source documents, except that they
52
usually contain only definitions and setup commands, but no text.
54
All tmac files are kept in a single or a small number of directories,
60
.\" --------------------------------------------------------------------
61
.SH "GROFF MACRO PACKAGES"
62
.\" --------------------------------------------------------------------
65
provides all classical macro packages, some more full packages, and
66
some secondary packages for special purposes.
68
Note that it is not possible to use multiple primary macro packages at the
69
same time; saying e.g.\&
73
\fIsh#\fP groff \-m man \-m ms foo
81
\fIsh#\fP groff \-m man foo \-m ms bar
86
Exception to this is the use of man pages written with either the
91
See below the description of the
96
.\" --------------------------------------------------------------------
98
.\" --------------------------------------------------------------------
102
This is the classical macro package for UNIX manual pages
103
(man\~pages); it is quite handy and easy to use; see
104
.BR groff_man (@MAN7EXT@).
111
An alternative macro package for man\~pages mainly used in BSD
112
systems; it provides many new features, but it is not the standard for
114
.BR groff_mdoc (@MAN7EXT@).
121
Use this file in case you don't know whether the
125
package should be used.
126
Multiple man pages (in either format) can be handled.
129
.\" --------------------------------------------------------------------
131
.\" --------------------------------------------------------------------
133
The packages in this section provide a complete set of macros for
134
writing documents of any kind, up to whole books.
136
They are similar in functionality; it is a matter of taste which one
145
.BR groff_me (@MAN7EXT@).
153
.BR groff_mm (@MAN7EXT@).
160
macro package, only available in groff.
162
As this is not based on other packages, it can be freely designed.
164
So it is expected to become quite a nice, modern macro package.
167
.BR groff_mom (@MAN7EXT@).
175
.BR groff_ms (@MAN7EXT@).
178
.\" --------------------------------------------------------------------
179
.SS "Language-specific Packages"
180
.\" --------------------------------------------------------------------
184
This file adds support for Czech localization, including the main macro
185
packages (me, mom, mm, and ms).
190
sets the input encoding to latin-2.
197
German localization support, including the main macro packages (me, mom, mm,
202
selects hyphenation patterns for traditional orthography, and
204
does the same for the new orthography (`Recht\%schreib\%reform').
206
It should be used as the last macro package on the command line.
211
This file adds support for French localization, including the main macro
212
packages (me, mom, mm, and ms).
219
\fIsh#\fP groff -ms -mfr foo.ms > foo.ps
226
sets the input encoding to latin-9 to get proper support of the `oe'
232
Swedish localization support, including the me, mom, and ms macro packages.
234
Note that Swedish for the mm macros is handled separately; see
235
.BR groff_mmse (@MAN7EXT@).
237
It should be used as the last macro package on the command line.
240
.\" --------------------------------------------------------------------
241
.SS "Input Encodings"
242
.\" --------------------------------------------------------------------
253
Various input encodings supported directly by groff.
255
Normally, this macro is loaded at the very beginning of a document or
256
specified as the first macro argument on the command line.
259
loads latin1 by default at start-up.
261
Note that these macro packages don't work on EBCDIC hosts.
266
Encoding support for EBCDIC.
268
On those platforms it is loaded automatically at start-up.
270
Due to different character ranges used in
272
it doesn't work on architectures which are based on ASCII.
276
Note that it can happen that some input encoding characters are not
277
available for a particular output device.
283
groff -Tlatin1 -mlatin9 ...
287
fails if you use the Euro character in the input.
289
Usually, this limitation is present only for devices which have a
290
limited set of output glyphs
293
for other devices it is usually sufficient to install proper
294
fonts which contain the necessary glyphs.
297
.\" --------------------------------------------------------------------
298
.SS "Special Packages"
299
.\" --------------------------------------------------------------------
301
The macro packages in this section are not intended for stand-alone
302
usage, but can be used to add special functionality to any other
303
macro package or to plain groff.
308
Provide some macros for addition, multiplication, and division of 60bit
309
integers (allowing safe multiplication of 30bit integers, for example).
314
Switch to the EC and TC font families.
317
.BR \%grodvi (@MAN1EXT@)
318
\[en] this man page also gives more details of how to use it.
323
This macro file is already loaded at start-up by
325
so it isn't necessary to call it explicitly.
327
It provides an interface to set the paper size on the command line with
328
the option \f[B]\%\-dpaper=\f[]\f[I]size\f[].
332
are the same as the predefined
334
values in the DESC file (only lowercase; see
335
.BR groff_font (@MAN5EXT@)
341
(ell) character denotes landscape orientation.
349
Most output drivers need additional command line switches
353
to override the default paper length and orientation as set in the driver
356
For example, use the following for PS output on A4 paper in landscape
362
\fIsh#\fP groff \-Tps \-dpaper=a4l \-P\-pa4 \-P\-l \-ms foo.ms > foo.ps
368
This file provides proper definitions for the macros
373
.BR @g@pic (@MAN1EXT@)
376
They center each picture.
378
Use it only if your macro package doesn't provide proper definitions
379
for those two macros (actually, most of them already do).
384
A single macro is provided in this file,
386
to include a PostScript graphic in a document.
388
The following output devices support inclusion of PS images:
394
for all other devices the image is replaced with a hollow rectangle
397
This macro file is already loaded at start-up by
399
so it isn't necessary to call it explicitly.
409
|\|\fB\-I\fP\ \fIn\fP] \
410
\fI\|file\fP [\fIwidth\fP [\fIheight\fP]]
415
is the name of the PostScript file;
419
give the desired width and height of the image.
425
argument is specified, the image's natural width (as given in
426
the file's bounding box) or the current line length is used
427
as the width, whatever is smaller.
433
arguments may have scaling indicators attached;
434
the default scaling indicator is\~\c
437
This macro scales the graphic uniformly
438
in the x and y\~directions so that it is no more than
447
centers the graphic horizontally, which is the default.
453
options cause the graphic to be left-aligned and right-aligned,
458
option causes the graphic to be indented by\~\c
460
(default scaling indicator is\~\c
466
within a diversion it is recommended to extend it with
467
the following code, assuring that the diversion's width completely
468
covers the image's width.
475
\&\[rs]h'(\[rs]\[rs]n[ps-offset]u + \[rs]\[rs]n[ps-deswid]u)'
485
A single macro is provided in this file,
487
for formatting permuted index entries as produces by the GNU
491
In case you need a different formatting, copy the macro into
492
your document and adapt it to your needs.
497
Use this for tracing macro calls.
499
It is only useful for debugging.
502
.BR groff_trace (@MAN7EXT@) .
507
Overrides the definition of standard troff characters and some groff
508
characters for TTY devices.
510
The optical appearance is intentionally inferior compared to that of
511
normal TTY formatting to allow processing with critical equipment.
516
Additions of elements known from the HTML format, as used in the
517
internet (World Wide Web) pages; this includes URL links and mail
519
.BR groff_www (@MAN7EXT@).
522
.\" --------------------------------------------------------------------
524
.\" --------------------------------------------------------------------
526
Classical roff systems were designed before the conventions of the
529
call evolved, and used a naming scheme for macro packages that looks
530
odd to modern eyes. Macro packages were always included with the option
532
when this option was directly followed by its argument without an
533
intervening space, this looked like a long option preceded by a single
534
minus \[em] a sensation in the computer stone age.
535
To make this invocation form work, classical troff
536
macro packages used names that started with the letter `m',
537
which was omitted in the naming of the macro file.
541
For example, the macro package for the man pages was called
545
So it could be activated by the argument
555
For similar reasons, macro packages that did not start with an `m'
557
added in the documentation and in speech; for example, the package
562
in the documentation, although a more suitable name would be
564
For, when omitting the space between the option and its argument, the
565
command line option for activating this package reads
570
To cope with all situations, actual versions of
571
.BR groff (@MAN1EXT@)
572
are smart about both naming schemes by providing two macro files
573
for the inflicted macro packages; one with a leading `m'
574
the other one without it.
580
macro package may be specified as on of the following four methods:
584
\fIsh#\fP groff\ \-m\ man
585
\fIsh#\fP groff\ \-man
586
\fIsh#\fP groff\ \-mman
587
\fIsh#\fP groff\ \-m\ an
592
Recent packages that do not start with `m'
593
do not use an additional `m'
594
in the documentation.
598
macro package may be specified only as one of the two methods:
602
\fIsh#\fP groff\ \-m\ www
603
\fIsh#\fP groff\ \-mwww
608
Obviously, variants like
610
would not make much sense.
614
A second strange feature of classical troff was to name macro files
615
in the form \f[B]tmac.\f[]\f[I]name\f[].
616
In modern operating systems, the type of a file is specified as a
617
postfix, the file name extension.
619
Again, groff copes with this situation by searching both
629
The easiest way to find out which macro packages are available on a
630
system is to check the man\~page
631
.BR groff (@MAN1EXT@),
632
or the contents of the
640
most macro packages are described in\~man pages called
641
.BR groff_\f[I]name\f[] (@MAN7EXT@),
643
for the classical packages.
646
.\" --------------------------------------------------------------------
648
.\" --------------------------------------------------------------------
650
There are several ways to use a macro package in a document.
652
The classical way is to specify the troff/groff option
655
at run-time; this makes the contents of the macro package
661
is searched within the tmac path; if not found,
663
is searched for instead.
667
Alternatively, it is also possible to include a macro file by adding
671
into the document; the argument must be the full file name of an
672
existing file, possibly with the directory where it is kept.
674
In groff, this was improved by the similar request
677
which added searching in the tmac path, just like option
683
Note that in order to resolve the
687
requests, the roff preprocessor
688
.BR soelim (@MAN1EXT@)
689
must be called if the files to be included need preprocessing.
691
This can be done either directly by a pipeline on the command line or
692
by using the troff/groff option
696
calls soelim automatically.
700
For example, suppose a macro file is stored as
703
.I @MACRODIR@/macros.tmac
706
and is used in some document called
711
At run-time, the formatter call for this is
715
\fIsh#\fP groff \-m macros docu.roff
720
To include the macro file directly in the document either
732
\&.so @MACRODIR@/macros.tmac
737
In both cases, the formatter should be called with option
743
\fIsh#\fP groff \-s docu.roff
748
If you want to write your own groff macro file, call it
750
and put it in some directory of the tmac path, see section
752
Then documents can include it with the
754
request or the option
759
.\" --------------------------------------------------------------------
761
.\" --------------------------------------------------------------------
763
.\" This section does not fit into the framework of this document.
765
There is a convention that is supported by many modern roff
770
described in the following.
773
If the first line in a document is a comment, the first word (after the
774
comment characters and a blank) constitutes the
777
That means that the letters of this word are interpreted as
778
abbreviations for those preprocessor commands that should be run
779
when formatting the document.
781
Mostly, only the letters corresponding to the options for the
782
preprocessors are recognized,
802
.BR roff (@MAN7EXT@)).
806
Besides being a good reminder for the user, some formatters (like the
808
program) are even able to automatically start the preprocessors
809
specified in the preprocessor word, but do not bet on this.
815
program handles some preprocessors automatically, such that in
816
man\~pages only the following characters should be used:
821
.\" --------------------------------------------------------------------
823
.\" --------------------------------------------------------------------
827
document is a text file that is enriched by predefined formatting
828
constructs, such as requests, escape sequences, strings, numeric
829
registers, and macros from a macro package.
831
These elements are described in
832
.BR roff (@MAN7EXT@).
836
To give a document a personal style, it is most useful to extend the
837
existing elements by defining some macros for repeating tasks; the best
838
place for this is near the beginning of the document or in a separate
843
Macros without arguments are just like strings.
845
But the full power of macros reveals when arguments are passed with a
848
Within the macro definition, the arguments are available as the escape
853
.BR \[rs]$[ \*[Ellipsis] ] ,
857
the name under which the macro was called is in
859
and the number of arguments is in register
862
.BR groff (@MAN7EXT@).
865
.\" --------------------------------------------------------------------
867
.\" --------------------------------------------------------------------
869
The phase when groff reads a macro is called
875
This is comparable to the C\~preprocessing phase during the development
876
of a program written in the C\~language.
880
In this phase, groff interprets all backslashes; that means that all
881
escape sequences in the macro body are interpreted and replaced by
884
For constant expressions, this is wanted, but strings and registers
885
that might change between calls of the macro must be protected from
888
This is most easily done by doubling the backslash that introduces the
891
This doubling is most important for the positional parameters.
893
For example, to print information on the arguments that were passed to
894
the macro to the terminal, define a macro named `.print_args',
899
.ds @1 \[rs]f[I]\[rs]\[rs]$0\[rs]f[]\"
902
\&.ds midpart was called with
904
\&.\ \ tm\ \*[@1]\ \[rs]*[midpart]\ \[rs]\[rs]n[.$]\ \*[@2]
905
\&.\ \ tm\ \[rs]\[rs]$*
913
When calling this macro by
917
\&.print_args arg1 arg2
921
the following text is printed to the terminal:
925
\&\f[CI]print_args\f[] was called with the following 2 arguments:
931
Let's analyze each backslash in the macro definition.
933
As the positional parameters and the number of arguments change
934
with each call of the macro their leading backslash must be doubled,
939
The same applies to the macro name because it could be called with an
947
is a constant string, it does not change, so no doubling for
948
.IR \[rs]*[midpart] .
951
escape sequences are predefined groff elements for setting the font
954
Of course, this behavior does not change, so no doubling with
960
.\" --------------------------------------------------------------------
962
.\" --------------------------------------------------------------------
964
Writing groff macros is easy when the escaping mechanism is temporarily
967
In groff, this is done by enclosing the macro definition(s) into a
974
Then the body in the macro definition is just like a normal part of
975
the document \[em] text enhanced by calls of requests, macros,
976
strings, registers, etc.
978
For example, the code above can be written in a simpler way by
982
.ds @1 \[rs]f[I]\[rs]$0\[rs]f[]\"
986
\&.ds midpart was called with
988
\&.\ \ tm\ \*[@1]\ \[rs]*[midpart]\ \[rs]n[.$]\ \*[@2]
998
Unfortunately, draft mode cannot be used universally.
1000
Although it is good enough for defining normal macros, draft mode
1001
fails with advanced applications, such as indirectly defined
1002
strings, registers, etc.
1004
An optimal way is to define and test all macros in draft mode and then
1005
do the backslash doubling as a final step; do not forget to remove the
1010
.\" --------------------------------------------------------------------
1011
.SS "Tips for Macro Definitions"
1012
.\" --------------------------------------------------------------------
1015
Start every line with a dot, for example, by using the groff request
1017
for text lines, or write your own macro that handles also text lines
1024
\&.\ \ if (\[rs]\[rs]n[.$] == 0)\ \[rs]
1026
\&.\ \ nop\ \[rs])\[rs]\[rs]$*\[rs])
1032
Write a comment macro that works both for copy-in and draft mode; for
1033
as escaping is off in draft mode, trouble might occur when normal
1036
For example, the following macro just ignores its arguments, so it
1037
acts like a comment line:
1044
\&.c\ This\ is\ like\ a\ comment\ line.
1049
In long macro definitions, make ample use of comment lines or
1050
almost-empty lines (this is, lines which have a leading dot
1051
and nothing else) for a better structuring.
1054
To increase readability, use groff's indentation facility for requests
1055
and macro calls (arbitrary whitespace after the leading dot).
1058
.\" --------------------------------------------------------------------
1060
.\" --------------------------------------------------------------------
1062
Diversions can be used to implement quite advanced programming
1065
They are comparable to pointers to large data structures in the
1066
C\~programming language, but their usage is quite different.
1070
In their simplest form, diversions are multi-line strings, but
1071
they get their power when diversions are used dynamically within macros.
1073
The (formatted) information stored in a diversion can be retrieved by
1074
calling the diversion just like a macro.
1078
Most of the problems arising with diversions can be avoided if you remain
1079
aware of the fact that diversions always store complete lines.
1081
If diversions are used when the line buffer has not been flushed,
1082
strange results are produced; not knowing this, many people get
1083
desperate about diversions.
1085
To ensure that a diversion works, line breaks should be added at the
1088
To be on the secure side, enclose everything that has to do with
1089
diversions into a pair of line breaks; for example, by explicitly using
1093
This rule should be applied to diversion definition, both inside and
1094
outside, and to all calls of diversions.
1096
This is a bit of overkill, but it works nicely.
1100
[If you really need diversions which should ignore the current partial
1101
line, use environments to save the current partial line and/\:or use the
1107
The most powerful feature using diversions is to start a diversion
1108
within a macro definition and end it within another macro.
1110
Then everything between each call of this macro pair is stored within
1111
the diversion and can be manipulated from within the macros.
1114
.\" --------------------------------------------------------------------
1116
.\" --------------------------------------------------------------------
1118
All macro names must be named
1120
to fully use the tmac mechanism.
1123
as with classical packages is possible as well, but deprecated.
1127
The macro files are kept in the
1128
.IR "tmac directories" ;
1129
a colon separated list of these constitutes the
1134
The search sequence for macro files is (in that order):
1137
the directories specified with troff/groff's
1142
the directories given in the
1144
environment variable
1147
the current directory (only if in unsafe mode, which is enabled by the
1149
command line switch)
1155
a platform-specific directory, being
1163
in this installation
1166
a site-specific (platform-independent) directory, being
1174
in this installation
1177
the main tmac directory, being
1185
in this installation
1188
.\" --------------------------------------------------------------------
1190
.\" --------------------------------------------------------------------
1194
A colon separated list of additional tmac directories in which to search
1197
See the previous section for a detailed description.
1200
.\" --------------------------------------------------------------------
1202
.\" --------------------------------------------------------------------
1204
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009
1205
Free Software Foundation, Inc.
1208
This document is distributed under the terms of the FDL (GNU Free
1209
Documentation License) version 1.3 or later.
1211
You should have received a copy of the FDL on your system, it is also
1212
available on-line at the
1213
.UR http://\:www.gnu.org/\:copyleft/\:fdl.html
1218
This document is part of
1220
the GNU roff distribution.
1223
.MT groff-bernd.warken-72@web.de
1232
.\" --------------------------------------------------------------------
1234
.\" --------------------------------------------------------------------
1236
A complete reference for all parts of the groff system is found in the
1243
.BR groff (@MAN1EXT@)
1244
an overview of the groff system.
1248
.BR groff_man (@MAN7EXT@),
1250
.BR groff_mdoc (@MAN7EXT@),
1252
.BR groff_me (@MAN7EXT@),
1254
.BR groff_mm (@MAN7EXT@),
1256
.BR groff_mom (@MAN7EXT@),
1258
.BR groff_ms (@MAN7EXT@),
1260
.BR groff_trace (@MAN7EXT@),
1262
.BR groff_www (@MAN7EXT@).
1263
the groff tmac macro packages.
1267
.BR groff (@MAN7EXT@)
1272
The Filesystem Hierarchy Standard is available at the
1273
.UR http://\:www.pathname.com/\:fhs/
1277
.\" Local Variables: