The tmac files are normal roff source documents, except that they
usually contain only definitions and setup commands, but no text.
.
All tmac files are kept in a single or a small number of directories,
the
tmac directories.
.
.
--------------------------------------------------------------------
or .
.Shell_cmd "groff -m man foo -m ms bar" .
will fail.
.
.
--------------------------------------------------------------------
man This is the classical macro package for UNIX manual pages (man\~pages); it is quite handy and easy to use; see groff_man (@MAN7EXT@). . .
doc
+
mdoc An alternative macro package for man\~pages mainly used in BSD
systems; it provides many new features, but it is not the standard for
man\~pages; see
groff_mdoc (@MAN7EXT@). .
.
--------------------------------------------------------------------
me The classical me macro package; see groff_me (@MAN7EXT@). . .
mm The semi-classical mm macro package; see groff_mm (@MAN7EXT@). . .
mom The new mom macro package, only available in groff. . As this is not based on other packages, it can be freely designed. . So it is expected to become quite a nice, modern macro package. . See groff_mom (@MAN7EXT@). . .
ms The classical
ms macro package; see
groff_ms (@MAN7EXT@). .
.
--------------------------------------------------------------------
papersize This macro file is already loaded at start-up by @g@troff so it isn't necessary to call it explicitly. . It provides an interface to set the paper size on the command line with the option \f[B]\%-dpaper=\f[]\f[I]size\f[]. . Possible values for size are the same as the predefined papersize values in the DESC file (only lowercase; see groff_font (@MAN5EXT@) for more) except a7 - d7 . . An appended l (ell) character denotes landscape orientation. . Examples: a4 , c3l , letterl . .
Most output drivers need additional command line switches -p and -l to override the default paper length and orientation as set in the driver specific DESC file. . For example, use the following for PS output on A4 paper in landscape orientation: . .Shell_cmd "groff -Tps -dpaper=a4l -P-pa4 -P-l -ms foo.ms > foo.ps" . .pic This file provides proper definitions for the macros PS and PE , needed for the @g@pic (@MAN1EXT@) preprocessor. . They will center each picture. . Use it only if your macro package doesn't provide proper definitions for those two macros (actually, most of them already have). . .
pspic A single macro is provided in this file, PSPIC , to include a PostScript graphic in a document. . It makes only sense for output devices which support inclusion of PS images: -Tps , -Tdvi , and -Thtml ; the file is then loaded automatically. . Syntax:
\fB.PSPIC [-L|-R|-I n] \|file [width [height]] . file is the name of the file containing the illustration; width and height give the desired width and height of the graphic. . The width and height arguments may have scaling indicators attached; the default scaling indicator is\~\c i . . This macro will scale the graphic uniformly in the x and y\~directions so that it is no more than width wide and height high. . By default, the graphic will be horizontally centered. . The -L and -R options cause the graphic to be left-aligned and right-aligned, respectively. . The -I option causes the graphic to be indented by\~\c n (default scaling indicator is\~\c m ). . .trace Use this for tracing macro calls. . It is only useful for debugging. . See groff_trace (@MAN7EXT@) . . .
tty-char Overrides the definition of standard troff characters and some groff characters for tty devices. . The optical appearance is intentionally inferior compared to that of normal tty formatting to allow processing with critical equipment. . .
www Additions of elements known from the html format, as being used in the
internet (World Wide Web) pages; this includes URL links and mail
addresses; see
groff_www (@MAN7EXT@). .
.
--------------------------------------------------------------------
For example, the macro package for the man pages was called man , while its macro file tmac.an . So it could be activated by the argument an to option .option -m , or .option -man for short. . .
For similar reasons, macro packages that did not start with an .'char m had a leading .'char m added in the documentation and in talking; for example, the package corresponding to tmac.doc was called mdoc in the documentation, although a more suitable name would be doc . For, when omitting the space between the option and its argument, the command line option for activating this package reads .option "-mdoc" . . .
To cope with all situations, actual versions of groff (@MAN1EXT@) are smart about both naming schemes by providing two macro files for the inflicted macro packages; one with a leading .'char m , the other one without it. . So in groff , the man macro package may be specified as on of the following four methods: .
.Shell_cmd "groff\~-m\~man" .Shell_cmd "groff\~-man" .Shell_cmd "groff\~-mman" .Shell_cmd "groff\~-m\~an" . .Recent packages that do not start with .'char m do not use an additional .'char m in the documentation. . For example, the www macro package may be specified only as one of the two methods: .
.Shell_cmd "groff\~-m\~www" .Shell_cmd "groff\~-mwww" . .Obviously, variants like -mmwww would not make much sense. . .
A second strange feature of classical troff was to name macro files according to R tmac. name . In modern operating systems, the type of a file is specified as postfix, the file name extension. . Again, groff copes with this situation by searching both anything .tmac and tmac. anything if only anything is specified. . .
The easiest way to find out which macro packages are available on a system is to check the man\~page groff (@MAN1EXT@), or the contents of the tmac directories. . .
In
groff , most macro packages are described in\~man pages called
groff_\f[I]name\f[] (@MAN7EXT@), with a leading
.'char m
for the classical packages.
.
.
--------------------------------------------------------------------
Alternatively, it is also possible to include a macro file by adding the request .request so filename into the document; the argument must be the full file name of an existing file, possibly with the directory where it is kept. . In groff, this was improved by the similar request .request mso package , which added searching in the tmac path, just like option .option -m does. . .
Note that in order to resolve the .request so and .request mso requests, the roff preprocessor soelim (@MAN1EXT@) must be called if the files to be included need preprocessing. . This can be done either directly by a pipeline on the command line or by using the troff/groff option .option -s . . man calls soelim automatically. . .
For example, suppose a macro file is stored as @MACRODIR@/macros.tmac and is used in some document called docu.roff . . .
At run-time, the formatter call for this is .
.Shell_cmd "groff\~-m\~" "macrofile\~document.roff" . .To include the macro file directly in the document either .
.Example . Text .mso macrofile.tmac ./Example .is used or .
.Example . Text .so @MACRODIR@/macros.tmac ./Example . .In both cases, the formatter is called with
.Shell_cmd "groff\~-s\~" docu.roff . .
If you want to write your own groff macro file, call it
whatever .tmac and put it in some directory of the tmac path, see section
FILES . Then documents can include it with the
.request mso
request or the option
.option -m .
.
.
--------------------------------------------------------------------
If the first line in a document is a comment, the first word (after the
comment characters and a blank) constitutes the
preprocessor word . That means that the letters of this word are interpreted as
abbreviations for those preprocessor commands that should be run
when formatting the document.
.
Mostly, only the letters corresponding to the options for the
preprocessors are recognized,
.'char e
(for
eqn ), 'char G ,
'char g ,
.'char p ,
(for
pic ), .'char R
(for
refer ), .'char s
(for
soelim ), and
.'char t
(for
tbl ). (see
roff (@MAN7EXT@)). .
.
Besides being a good reminder for the user, some formatters (like the man (1) program) are even able to automatically start the preprocessors specified in the preprocessor word, but do not bet on this. . .
The
man program handles some preprocessors automatically, such that in
man\~pages only the following characters should be used:
.'char e ,
.'char p ,
and
.'char t .
.
.
..
--------------------------------------------------------------------
To give a document a personal style, it is most useful to extend the existing elements by defining some macros for repeating tasks; the best place for this is near the beginning of the document or in a separate file. . .
Macros without arguments are just like strings.
.
But the full power of macros reveals when arguments are passed with a
macro call.
.
Within the macro definition, the arguments are available as the escape
sequences
$1 , \*[Ellipsis],
$9 , $[ \*[Ellipsis] ] , $* , and
$@ , the name under which the macro was called is in
$0 , and the number of arguments is in register
\n[.$] ; see
groff (@MAN7EXT@). .
.
--------------------------------------------------------------------
In this phase, groff interprets all backslashes; that means that all escape sequences in the macro body are interpreted and replaced by their value. . For constant expression, this is wanted, but strings and registers that might change between calls of the macro must be protected from being evaluated. . This is most easily done by doubling the backslash that introduces the escape sequence. . This doubling is most important for the positional parameters. . For example, to print information on the arguments that were passed to the macro to the terminal, define a macro named `.print_args', say. . .
.Example . Text .ds midpart was called with . Text .de print_args . Text .\~\~tm\~\*[@1]\~\[rs]\[rs]*[midpart]\~\[rs]\[rs]n[.$]\~\*[@2] . Text .\~\~tm\~\[rs]\[rs]$* . Text .. ./Example . .
When calling this macro by .
.Example . Text .print_args arg1 arg2 ./Example .
the following text is printed to the terminal: .
.Example . Text \f[CI]print_args\f[] was called with the following 2 arguments: arg1 arg2 ./Example . .
Let's analyze each backslash in the macro definition. . As the positional parameters and the number of arguments will change with each call of the macro their leading backslash must be doubled, which results in \[rs]\[rs]$* and \[rs]\[rs][.$] . The same applies to the macro name because it could be called with an alias name, so \[rs]\[rs]$0 . . .
On the other hand,
midpart is a constant string, it will not change, so no doubling for
\[rs]*[midpart] . The
\[rs]f escape sequences are predefined groff elements for setting the font
within the text.
.
Of course, this behavior will not change, so no doubling with
\[rs]f[I] and
\[rs]f[] . .
.
--------------------------------------------------------------------
.Example . Text .eo . Text .ds midpart was called with . Text .de print_args . Text .\~\~tm\~\*[@1]\~\[rs]*[midpart]\~\[rs]n[.$]\~\*[@2] . Text .\~\~tm\~\[rs]$* . Text .. . Text .ec ./Example . .
Unfortunately, draft mode cannot be used universally.
.
Although it is good enough for defining normal macros, draft mode
will fail with advanced applications, such as indirectly defined
strings, registers, etc.
.
An optimal way is to define and test all macros in draft mode and then
do the backslash doubling as a final step; do not forget to remove the
.eo request.
.
.
--------------------------------------------------------------------
In their simplest form, diversions are multi-line strings, but they get their power when diversions are used dynamically within macros. . The information stored in a diversion can be retrieved by calling the diversion just like a macro. . .
Most of the problems arising with diversions can be avoided if you are conscious about the fact that diversions always deal with complete lines. . If diversions are used when the line buffer has not been flashed, strange results are produced; not knowing this, many people get desperate about diversions. . To ensure that a diversion works, line breaks should be added at the right places. . To be on the secure side, enclose everything that has to do with diversions into a pair of line breaks; for example, by amply using .br requests. . This rule should be applied to diversion definition, both inside and outside, and to all calls of diversions. . This is a bit of overkill, but it works nicely. . .
[If you really need diversions which should ignore the current partial line, use environments to save the current partial line and/\:or use the .box request.] . .
The most powerful feature using diversions is to start a diversion
within a macro definition and end it within another macro.
.
Then everything between each call of this macro pair is stored within
the diversion and can be manipulated from within the macros.
.
.
--------------------------------------------------------------------
The macro files are kept in the "tmac directories" ; a colon separated list of these constitutes the "tmac path" . . .
The search sequence for macro files is (in that order):
.
.Topic
the directories specified with troff/groff's
-M command line option
.
.Topic
the directories given in the
.Env_var $GROFF_TMAC_PATH
environment variable
.
.Topic
the current directory (only if in unsafe mode, which is enabled by the
-U command line switch)
.
.Topic
the home directory
.
.Topic
a platform-specific directory, being
@SYSTEMMACRODIR@ in this installation
.
.Topic
a site-specific (platform-independent) directory, being
@LOCALMACRODIR@ in this installation
.
.Topic
the main tmac directory, being
@MACRODIR@ in this installation
.
.
--------------------------------------------------------------------
.Env_var $GROFF_TMAC_PATH
A colon separated list of additional tmac directories in which to search
for macro files.
.
See the previous section for a detailed description.
.
.
--------------------------------------------------------------------
This document is distributed under the terms of the FDL (GNU Free Documentation License) version 1.1 or later. . You should have received a copy of the FDL on your system, it is also available on-line at the RL http://\:www.gnu.org/\:copyleft/\:fdl.html "GNU copyleft site" . .
This document is part of
groff , the GNU roff distribution.
.
It was written by
.MTO bwarken (at] mayn.de "Bernd Warken" ;
it is maintained by
.MTO wl (at] gnu.org "Werner Lemberg" .
.
.
--------------------------------------------------------------------
groff (@MAN1EXT@) an overview of the groff system. . .
groff_man (@MAN7EXT@),
+ groff_mdoc (@MAN7EXT@),
+ groff_me (@MAN7EXT@),
+ groff_mm (@MAN7EXT@),
+ groff_mom (@MAN7EXT@),
+ groff_ms (@MAN7EXT@),
+ groff_trace (@MAN7EXT@),
+ groff_www (@MAN7EXT@). the groff tmac macro packages. . .
groff (@MAN7EXT@) the groff language. . .
The Filesystem Hierarchy Standard is available at the
RL http://\:www.pathname.com/\:fhs/ "FHS web site" . .
.cp \n[groff_tmac_C]
.
Local Variables:
mode: nroff
End: