GROFF_TMAC(5) | File Formats Manual | GROFF_TMAC(5) |
NAME
groff_tmac - macro files in the roff typesetting systemDESCRIPTION
The roff(7) type-setting system provides a set of macro packages suitable for special kinds of documents. Each macro package stores its macros and definitions in a file called the package's tmac file. The name is deduced from `TroffMACros'.GROFF MACRO PACKAGES
groff provides all classical macro packages, some more full packages, and some secondary packages for special purposes. Note that it is not possible to use multiple primary macro packages at the same time; saying e.g.-
sh# groff -m man -m ms foo
-
sh# groff -m man foo -m ms bar
Man Pages
- man
- This is the classical macro package for UNIX manual pages (man pages); it is quite handy and easy to use; see groff_man(7).
- 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(7).
- andoc
- mandoc Use this file in case you don't know whether the man macros or the mdoc package should be used. Multiple man pages (in either format) can be handled.
Full Packages
The packages in this section provide a complete set of macros for writing documents of any kind, up to whole books. They are similar in functionality; it is a matter of taste which one to use.- me
- The classical me macro package; see groff_me(7).
- mm
- The semi-classical mm macro package; see groff_mm(7).
- 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(7).
- ms
- The classical ms macro package; see groff_ms(7).
Language-specific Packages
- cs
- This file adds support for Czech localization, including the main macro packages (me, mom, mm, and ms).
- Note that cs.tmac sets the input encoding to latin-2.
- de
- den German localization support, including the main macro packages (me, mom, mm, and ms).
- de.tmac selects hyphenation patterns for traditional orthography, and den.tmac does the same for the new orthography (`Rechtschreibreform'). It should be used as the last macro package on the command line.
- fr
- This file adds support for French localization, including the main macro packages (me, mom, mm, and ms). Example:
-
sh# groff -ms -mfr foo.ms > foo.ps
- Note that fr.tmac sets the input encoding to latin-9 to get proper support of the `oe' ligature.
- sv
- Swedish localization support, including the me, mom, and ms macro packages. Note that Swedish for the mm macros is handled separately; see groff_mmse(7). It should be used as the last macro package on the command line.
Input Encodings
- latin1
- latin2 latin5 latin9 Various input encodings supported directly by groff. Normally, this macro is loaded at the very beginning of a document or specified as the first macro argument on the command line. roff loads latin1 by default at start-up. Note that these macro packages don't work on EBCDIC hosts.
- cp1047
- Encoding support for EBCDIC. On those platforms it is loaded automatically at start-up. Due to different character ranges used in roff it doesn't work on architectures which are based on ASCII.
groff -Tlatin1 -mlatin9 ...
Special Packages
The macro packages in this section are not intended for stand-alone usage, but can be used to add special functionality to any other macro package or to plain groff.- 60bit
- Provide some macros for addition, multiplication, and division of 60bit integers (allowing safe multiplication of 30bit integers, for example).
- ec
- Switch to the EC and TC font families. To be used with grodvi(1) – this man page also gives more details of how to use it.
- papersize
- This macro file is already loaded at start-up by 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 -dpaper=size. Possible values for size are the same as the predefined papersize values in the DESC file (only lowercase; see groff_font(5) 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:
-
sh# 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 pic(1) preprocessor. They center each picture. Use it only if your macro package doesn't provide proper definitions for those two macros (actually, most of them already do).
- pspic
- A single macro is provided in this file, PSPIC, to include a PostScript graphic in a document. The following output devices support inclusion of PS images: -Tps, -Tdvi, -Thtml, and -Txhtml; for all other devices the image is replaced with a hollow rectangle of the same size. This macro file is already loaded at start-up by troff so it isn't necessary to call it explicitly.
- Syntax:
- .PSPIC [-L|-R|-C|-I n] file [width [height]]
- file is the name of the PostScript file; width and height give the desired width and height of the image. If neither a width nor a height argument is specified, the image's natural width (as given in the file's bounding box) or the current line length is used as the width, whatever is smaller. The width and height arguments may have scaling indicators attached; the default scaling indicator is i. This macro scales the graphic uniformly in the x and y directions so that it is no more than width wide and height high. Option -C centers the graphic horizontally, which is the default. 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 n (default scaling indicator is m).
- For use of .PSPIC within a diversion it is recommended to extend it with the following code, assuring that the diversion's width completely covers the image's width.
-
.am PSPIC
. vpt 0
\h'(\\n[ps-offset]u + \\n[ps-deswid]u)'
. sp -1
. vpt 1
..
- ptx
- A single macro is provided in this file, xx, for formatting permuted index entries as produces by the GNU ptx(1) program. In case you need a different formatting, copy the macro into your document and adapt it to your needs.
- trace
- Use this for tracing macro calls. It is only useful for debugging. See groff_trace(7).
- 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 used in the internet (World Wide Web) pages; this includes URL links and mail addresses; see groff_www(7).
NAMING
Classical roff systems were designed before the conventions of the modern C getopt(3) call evolved, and used a naming scheme for macro packages that looks odd to modern eyes. Macro packages were always included with the option -m; when this option was directly followed by its argument without an intervening space, this looked like a long option preceded by a single minus — a sensation in the computer stone age. To make this invocation form work, classical troff macro packages used names that started with the letter `m', which was omitted in the naming of the macro file.-
sh# groff -m man
sh# groff -man
sh# groff -mman
sh# groff -m an
-
sh# groff -m www
sh# groff -mwww
INCLUSION
There are several ways to use a macro package in a document. The classical way is to specify the troff/groff option -m name at run-time; this makes the contents of the macro package name available. In groff, the file name.tmac is searched within the tmac path; if not found, tmac.name is searched for instead.- /share/groff/1.22.1/tmac/macros.tmac
-
sh# groff -m macros docu.roff
-
.mso macros.tmac
-
.so /share/groff/1.22.1/tmac/macros.tmac
-
sh# groff -s docu.roff
WRITING MACROS
A roff(7) document is a text file that is enriched by predefined formatting constructs, such as requests, escape sequences, strings, numeric registers, and macros from a macro package. These elements are described in roff(7).Copy-in Mode
The phase when groff reads a macro is called copy-in mode or copy mode in roff-talk. This is comparable to the C preprocessing phase during the development of a program written in the C language.-
.ds midpart was called with
.de print_args
. tm \f[I]\\$0\f[] \*[midpart] \\n[.$] arguments:
. tm \\$*
..
-
.print_args arg1 arg2
-
print_args was called with the following 2 arguments:
arg1 arg2
Draft Mode
Writing groff macros is easy when the escaping mechanism is temporarily disabled. In groff, this is done by enclosing the macro definition(s) into a pair of .eo and .ec requests. Then the body in the macro definition is just like a normal part of the document — text enhanced by calls of requests, macros, strings, registers, etc. For example, the code above can be written in a simpler way by-
.eo
.ds midpart was called with
.de print_args
. tm \f[I]\$0\f[] \*[midpart] \n[.$] arguments:
. tm \$*
..
.ec
Tips for Macro Definitions
- •
- Start every line with a dot, for example, by using the groff request .nop for text lines, or write your own macro that handles also text lines with a leading dot.
-
.de Text
. if (\\n[.$] == 0) \
. return
. nop \)\\$*\)
..
- •
- Write a comment macro that works both for copy-in and draft mode; for as escaping is off in draft mode, trouble might occur when normal comments are used. For example, the following macro just ignores its arguments, so it acts like a comment line:
-
.de c
..
.c This is like a comment line.
- •
- In long macro definitions, make ample use of comment lines or almost-empty lines (this is, lines which have a leading dot and nothing else) for a better structuring.
- •
- To increase readability, use groff's indentation facility for requests and macro calls (arbitrary whitespace after the leading dot).
Diversions
Diversions can be used to implement quite advanced programming constructs. They are comparable to pointers to large data structures in the C programming language, but their usage is quite different.FILES
All macro names must be named name.tmac to fully use the tmac mechanism. tmac.name as with classical packages is possible as well, but deprecated.- •
- the directories specified with troff/groff's -M command line option
- •
- the directories given in the $GROFF_TMAC_PATH environment variable
- •
- the current directory (only if in unsafe mode, which is enabled by the -U command line switch)
- •
- the home directory
- •
- a platform-specific directory, being
- /lib/groff/site-tmac
- in this installation
- •
- a site-specific (platform-independent) directory, being
- /share/groff/site-tmac
- in this installation
- •
- the main tmac directory, being
- /share/groff/1.22.1/tmac
- in this installation
ENVIRONMENT
- $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.
AUTHOR
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.SEE ALSO
A complete reference for all parts of the groff system is found in the groff info(1) file.- groff(1)
- an overview of the groff system.
- groff_man(7),
- groff_mdoc(7), groff_me(7), groff_mm(7), groff_mom(7), groff_ms(7), groff_trace(7), groff_www(7). the groff tmac macro packages.
- groff(7)
- the groff language.
30 December 2012 | Groff Version 1.22.1 |