{
    "content": [
        {
            "type": "text",
            "text": "# groff_tmac(5) (man)\n\n**Summary:** grofftmac - macro files in the roff typesetting system\n\n## See Also\n\n- groff(1)\n- groffman(7)\n- groffmdoc(7)\n- groffme(7)\n- groffmm(7)\n- groffmom(7)\n- groffms(7)\n- grofftrace(7)\n- groffwww(7)\n- groff(7)\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **DESCRIPTION** (8 lines)\n- **GROFF MACRO PACKAGES** (13 lines) — 5 subsections\n  - Man Pages (11 lines)\n  - Full Packages (14 lines)\n  - Language-specific Packages (24 lines)\n  - Input Encodings (21 lines)\n  - Special Packages (84 lines)\n- **NAMING** (46 lines)\n- **INCLUSION** (41 lines)\n- **WRITING MACROS** (14 lines) — 4 subsections\n  - Copy-in Mode (37 lines)\n  - Draft Mode (19 lines)\n  - Tips for Macro Definitions (23 lines)\n  - Diversions (24 lines)\n- **FILES** (35 lines)\n- **ENVIRONMENT** (4 lines)\n- **AUTHORS** (3 lines)\n- **SEE ALSO** (25 lines)\n\n## Full Content\n\n### NAME\n\ngrofftmac - macro files in the roff typesetting system\n\n### DESCRIPTION\n\nThe  roff(7)  type-setting system provides a set of macro packages suitable for special kinds\nof documents.  Each macro package stores its macros and definitions  in  a  file  called  the\npackage's tmac file.  The name is deduced from ‘TroffMACros’.\n\nThe  tmac files are normal roff source documents, except that they usually contain only defi‐\nnitions and setup commands, but no text.  All tmac files are kept in a single or a small num‐\nber of directories, the tmac directories.\n\n### GROFF MACRO PACKAGES\n\ngroff  provides  all  classical  macro  packages, some more full packages, and some secondary\npackages for special purposes.  Note that it is not possible to use  multiple  primary  macro\npackages at the same time; saying e.g.\n\nsh# groff -m man -m ms foo\n\nor\n\nsh# groff -m man foo -m ms bar\n\nfails.   Exception  to  this  is the use of man pages written with either the mdoc or the man\nmacro package.  See below the description of the andoc.tmac file.\n\n#### Man Pages\n\nman    This is the classical macro package for Unix manual pages (man  pages);  it  is  quite\nhandy and easy to use; see groffman(7).\n\ndoc\nmdoc   An  alternative  macro  package  for man pages mainly used in BSD systems; it provides\nmany new features, but it is not the standard for man pages; see groffmdoc(7).\n\nandoc\nmandoc Use this file in case you don't know whether the man macros or the mdoc package should\nbe used.  Multiple man pages (in either format) can be handled.\n\n#### Full Packages\n\nThe  packages  in  this section provide a complete set of macros for writing documents of any\nkind, up to whole books.  They are similar in functionality; it is a matter  of  taste  which\none to use.\n\nme     The classical me macro package; see groffme(7).\n\nmm     The semi-classical mm macro package; see groffmm(7).\n\nmom    The  new  mom  macro  package, only available in groff.  As this is not based on other\npackages, it can be freely designed.  So it is expected to become quite a nice, modern\nmacro package.  See groffmom(7).\n\nms     The classical ms macro package; see groffms(7).\n\n#### Language-specific Packages\n\ncs     This  file adds support for Czech localization, including the main macro packages (me,\nmom, mm, and ms).\n\nNote that cs.tmac sets the input encoding to latin-2.\n\nde\nden    German localization support, including the main macro packages (me, mom, mm, and ms).\n\nde.tmac selects hyphenation patterns for traditional orthography,  and  den.tmac  does\nthe  same  for  the  new orthography (‘Rechtschreibreform’).  It should be used as the\nlast macro package on the command line.\n\nfr     This file adds support for French localization, including the main macro packages (me,\nmom, mm, and ms).  Example:\n\nsh# groff -ms -mfr foo.ms > foo.ps\n\nNote that fr.tmac sets the input encoding to latin-9 to get proper support of the ‘oe’\nligature.\n\nsv     Swedish localization support, including the me, mom, and ms macro packages.  Note that\nSwedish  for  the  mm macros is handled separately; see groffmmse(7) (only in Swedish\nlocales).  It should be used as the last macro package on the command line.\n\n#### Input Encodings\n\nlatin1\nlatin2\nlatin5\nlatin9 Various input encodings supported directly by groff.  Normally, this macro  is  loaded\nat  the  very  beginning of a document or specified as the first macro argument on the\ncommand line.  roff loads latin1 by default at start-up.  Note that these macro  pack‐\nages don't work on EBCDIC hosts.\n\ncp1047 Encoding  support for EBCDIC.  On those platforms it is loaded automatically at start-\nup.  Due to different character ranges used in roff it doesn't work  on  architectures\nwhich are based on ASCII.\n\nNote  that it can happen that some input encoding characters are not available for a particu‐\nlar output device.  For example, saying\n\ngroff -Tlatin1 -mlatin9 ...\n\nfails if you use the Euro character in the input.  Usually, this limitation is  present  only\nfor  devices which have a limited set of output glyphs (-Tascii, -Tlatin1); for other devices\nit is usually sufficient to install proper fonts which contain the necessary glyphs.\n\n#### Special Packages\n\nThe macro packages in this section are not intended for stand-alone usage, but can be used to\nadd special functionality to any other macro package or to plain groff.\n\n62bit  Provides  macros for addition, multiplication, and division of 62-bit integers (allow‐\ning safe multiplication of 31-bit integers, for example).\n\nec     Switch to the EC and TC font families.  To be used with grodvi(1) – this man page also\ngives more details of how to use it.\n\nhdtbl  The  Heidelberger table macros, contributed by Joachim Walsdorff, allow the generation\nof tables through a syntax similar to the HTML table model.   Note  that  hdtbl  is  a\nmacro  package,  not  a  preprocessor like tbl(1).  hdtbl works only with the -Tps and\n-Tpdf output devices.  See groffhdtbl(7).\n\npapersize\nThis macro file is already loaded at start-up by troff so it isn't necessary  to  call\nit  explicitly.   It  provides  an interface to set the paper size on the command line\nwith the option -dpaper=size.  Possible values for size are the same as the predefined\npapersize  values in the DESC file (only lowercase; see grofffont(5) for more) except\na7–d7.  An appended l (ell) character denotes landscape  orientation.   Examples:  a4,\nc3l, letterl.\n\nMost  output  drivers  need additional command-line switches -p and -l to override the\ndefault paper length and orientation as set in the driver-specific DESC file.  For ex‐\nample, use the following for PS output on A4 paper in landscape orientation:\n\nsh# groff -Tps -dpaper=a4l -P-pa4 -P-l -ms foo.ms > foo.ps\n\npdfpic A  single  macro  is provided in this file, PSPIC, to include a PDF graphic in a docu‐\nment, i.e., under the output device -Tpdf.  For all other devices, pspic is used.   So\npdfpic  is  an extension of pspic.  By that you can now even replace all PSPIC by PDF‐‐\nPIC, nothing gets lost by that.  The options of PDFPIC are identical to the PSDIF  op‐\ntions.\n\npic    This  file provides proper definitions for the macros PS and PE, needed for the pic(1)\npreprocessor.  They center each picture.  Use it only if your  macro  package  doesn't\nprovide proper definitions for those two macros (actually, most of them already do).\n\npspic  A  single  macro is provided in this file, PSPIC, to include a PostScript graphic in a\ndocument.  The following output devices support inclusion of PS images:  -Tps,  -Tdvi,\n-Thtml, and -Txhtml; for all other devices the image is replaced with a hollow rectan‐\ngle of the same size.  This macro file is already loaded at start-up by  troff  so  it\nisn't necessary to call it explicitly.\n\nSyntax:\n\n.PSPIC [-L|-R|-C|-I n] file [width [height]]\n\nfile  is  the name of the PostScript file; width and height give the desired width and\nheight of the image.  If neither a width nor a height argument is specified,  the  im‐\nage's  natural  width (as given in the file's bounding box) or the current line length\nis used as the width, whatever is smaller.  The width and height  arguments  may  have\nscaling  indicators  attached;  the default scaling indicator is i.  This macro scales\nthe graphic uniformly in the x and y directions so that it is no more than width  wide\nand  height  high.   Option -C centers the graphic horizontally, which is the default.\nThe -L and -R options cause the graphic to be left-aligned and right-aligned,  respec‐\ntively.  The -I option causes the graphic to be indented by n (default scaling indica‐\ntor is m).\n\nFor use of .PSPIC within a diversion it is recommended to extend it with the following\ncode, assuring that the diversion's width completely covers the image's width.\n\n.am PSPIC\n.  vpt 0\n\\h'(\\\\n[ps-offset]u + \\\\n[ps-deswid]u)'\n.  sp -1\n.  vpt 1\n..\n\nptx    A  single macro is provided in this file, xx, for formatting permuted index entries as\nproduced by the GNU ptx(1) program.  In case you need a different formatting, copy the\nmacro into your document and adapt it to your needs.\n\ntrace  Use   this   for  tracing  macro  calls.   It  is  only  useful  for  debugging.   See\ngrofftrace(7).\n\ntty-char\nOverrides the definition of standard troff characters and some  groff  characters  for\nTTY  devices.   The  optical  appearance is intentionally inferior compared to that of\nnormal TTY formatting to allow processing with critical equipment.\n\nwww    Additions of elements known from the HTML format, as used in the internet (World  Wide\nWeb) pages; this includes URL links and mail addresses; see groffwww(7).\n\n### NAMING\n\nClassical  roff  systems  were designed before the conventions of the modern C getopt(3) call\nevolved, and used a naming scheme for macro packages that looks odd to  modern  eyes.   Macro\npackages  were  always included with the option -m; when this option was directly followed by\nits argument without an intervening space, this looked like a long option preceded by a  sin‐\ngle  minus — a sensation in the computer stone age.  To make this invocation form work, clas‐\nsical troff macro packages used names that started with the letter ‘m’, which was omitted  in\nthe naming of the macro file.\n\nFor  example,  the  macro  package  for  the  man  pages was called man, while its macro file\ntmac.an.  So it could be activated by the argument an to option -m, or -man for short.\n\nFor similar reasons, macro packages that did not start with an ‘m’ had a leading ‘m’ added in\nthe  documentation  and  in  speech;  for  example, the package corresponding to tmac.doc was\ncalled mdoc in the documentation, although a more suitable name  would  be  doc.   For,  when\nomitting  the space between the option and its argument, the command-line option for activat‐\ning this package reads -mdoc.\n\nTo cope with all situations, actual versions of groff(1) are smart about both naming  schemes\nby  providing  two  macro  files for the inflicted macro packages; one with a leading ‘m’ the\nother one without it.  So in groff, the man macro package may be specified as one of the fol‐\nlowing four methods:\n\nsh# groff -m man\nsh# groff -man\nsh# groff -mman\nsh# groff -m an\n\nRecent packages that do not start with ‘m’ do not use an additional ‘m’ in the documentation.\nFor example, the www macro package may be specified only as one of the two methods:\n\nsh# groff -m www\nsh# groff -mwww\n\nObviously, variants like -mmwww would not make much sense.\n\nA second strange feature of classical troff was to name macro files in  the  form  tmac.name.\nIn  modern operating systems, the type of a file is specified as a postfix, the file name ex‐\ntension.  Again, groff  copes  with  this  situation  by  searching  both  anything.tmac  and\ntmac.anything if only anything is specified.\n\nThe  easiest  way  to find out which macro packages are available on a system is to check the\nman page groff(1), or the contents of the tmac directories.\n\nIn groff, most macro packages are described in man pages called groffname(7), with a leading\n‘m’ for the classical packages.\n\n### INCLUSION\n\nThere are several ways to use a macro package in a document.  The classical way is to specify\nthe troff/groff option -m name at run-time; this makes the contents of the macro package name\navailable.   In  groff,  the  file  name.tmac is searched within the tmac path; if not found,\ntmac.name is searched for instead.\n\nAlternatively, it is also possible to include a macro file by adding the request .so filename\ninto the document; the argument must be the full file name of an existing file, possibly with\nthe directory where it is kept.  In groff, this was improved  by  the  similar  request  .mso\npackage, which added searching in the tmac path, just like option -m does.\n\nNote that in order to resolve the .so and .mso requests, the roff preprocessor soelim(1) must\nbe called if the files to be included need preprocessing.  This can be done  either  directly\nby  a  pipeline  on the command line or by using the troff/groff option -s.  man calls soelim\nautomatically.\n\nFor example, suppose a macro file is stored as\n\n/usr/share/groff/1.22.4/tmac/macros.tmac\n\nand is used in some document called docu.roff.\n\nAt run-time, the formatter call for this is\n\nsh# groff -m macros docu.roff\n\nTo include the macro file directly in the document either\n\n.mso macros.tmac\n\nis used or\n\n.so /usr/share/groff/1.22.4/tmac/macros.tmac\n\nIn both cases, the formatter should be called with option -s to invoke soelim.\n\nsh# groff -s docu.roff\n\nIf you want to write your own groff macro file, call it whatever.tmac and put it in a  direc‐\ntory  in  the  tmac  path; see section “Files” below.  Then documents can include it with the\n.mso request or the option -m.\n\n### WRITING MACROS\n\nA roff(7) document is a text file that is enriched by predefined formatting constructs,  such\nas  requests,  escape sequences, strings, numeric registers, and macros from a macro package.\nThese elements are described in roff(7).\n\nTo give a document a personal style, it is most useful to extend  the  existing  elements  by\ndefining  some  macros  for repeating tasks; the best place for this is near the beginning of\nthe document or in a separate file.\n\nMacros without arguments are just like strings.  But the full power of  macros  reveals  when\narguments  are  passed  with  a  macro  call.  Within the macro definition, the arguments are\navailable as the escape sequences \\$1, ..., \\$9, \\$[...], \\$*, and \\$@, the name under  which\nthe  macro  was  called  is  in  \\$0,  and the number of arguments is in register \\n[.$]; see\ngroff(7).\n\n#### Copy-in Mode\n\nThe phase when groff reads a macro is called copy-in mode or copy mode in roff-talk.  This is\ncomparable  to  the  C preprocessing phase during the development of a program written in the\nC language.\n\nIn this phase, groff interprets all backslashes; that means that all escape sequences in  the\nmacro  body  are  interpreted and replaced by their value.  For constant expressions, this is\nwanted, but strings and registers that might change between calls of the macro must  be  pro‐\ntected  from being evaluated.  This is most easily done by doubling the backslash that intro‐\nduces the escape sequence.  This doubling is most important for  the  positional  parameters.\nFor  example, to print information on the arguments that were passed to the macro to the ter‐\nminal, define a macro named ‘.printargs’, say.\n\n.ds midpart was called with\n.de printargs\n.  tm \\f[I]\\\\$0\\f[] \\*[midpart] \\\\n[.$] arguments:\n.  tm \\\\$*\n..\n\nWhen calling this macro by\n\n.printargs arg1 arg2\n\nthe following text is printed to the terminal:\n\nprintargs was called with the following 2 arguments:\narg1 arg2\n\nLet's analyze each backslash in the macro definition.  As the positional parameters  and  the\nnumber  of  arguments change with each call of the macro their leading backslash must be dou‐\nbled, which results in \\\\$* and \\\\[.$].  The same applies to the macro name because it  could\nbe called with an alias name, so \\\\$0.\n\nOn  the  other  hand,  midpart  is  a constant string, it does not change, so no doubling for\n\\*[midpart].  The \\f escape sequences are predefined groff  elements  for  setting  the  font\nwithin  the  text.   Of  course, this behavior does not change, so no doubling with \\f[I] and\n\\f[].\n\n#### Draft Mode\n\nWriting groff macros is easy when the escaping mechanism is temporarily disabled.  In  groff,\nthis  is done by enclosing the macro definition(s) into a pair of .eo and .ec requests.  Then\nthe body in the macro definition is just like a normal part of the document —  text  enhanced\nby  calls  of  requests, macros, strings, registers, etc.  For example, the code above can be\nwritten in a simpler way by\n\n.eo\n.ds midpart was called with\n.de printargs\n.  tm \\f[I]\\$0\\f[] \\*[midpart] \\n[.$] arguments:\n.  tm \\$*\n..\n.ec\n\nUnfortunately, draft mode cannot be used universally.  Although it is good enough for  defin‐\ning  normal  macros,  draft mode fails with advanced applications, such as indirectly defined\nstrings, registers, etc.  An optimal way is to define and test all macros in draft  mode  and\nthen do the backslash doubling as a final step; do not forget to remove the .eo request.\n\n#### Tips for Macro Definitions\n\n•      Start  every  line  with  a dot, for example, by using the groff request .nop for text\nlines, or write your own macro that handles also text lines with a leading dot.\n\n.de Text\n.  if (\\\\n[.$] == 0) \\\n.    return\n.  nop \\)\\\\$*\\)\n..\n\n•      Write a comment macro that works both for copy-in and draft mode; for as  escaping  is\noff  in  draft  mode, trouble might occur when normal comments are used.  For example,\nthe following macro just ignores its arguments, so it acts like a comment line:\n\n.de c\n..\n.c This is like a comment line.\n\n•      In long macro definitions, make ample use of comment lines or almost-empty lines (this\nis, lines which have a leading dot and nothing else) for a better structuring.\n\n•      To increase readability, use groff's indentation facility for requests and macro calls\n(arbitrary whitespace after the leading dot).\n\n#### Diversions\n\nDiversions can be used to implement quite advanced programming constructs.  They are compara‐\nble  to  pointers  to large data structures in the C programming language, but their usage is\nquite different.\n\nIn their simplest form, diversions are multi-line strings, but they get their power when  di‐\nversions  are used dynamically within macros.  The (formatted) information stored in a diver‐\nsion can be retrieved by calling the diversion just like a macro.\n\nMost of the problems arising with diversions can be avoided if you remain aware of  the  fact\nthat diversions always store complete lines.  If diversions are used when the line buffer has\nnot been flushed, strange results are produced; not knowing this, many people  get  desperate\nabout diversions.  To ensure that a diversion works, line breaks should be added at the right\nplaces.  To be on the secure side, enclose everything that has to do with diversions  into  a\npair  of line breaks; for example, by explicitly using .br requests.  This rule should be ap‐\nplied to diversion definition, both inside and outside, and to all calls of diversions.  This\nis a bit of overkill, but it works nicely.\n\n[If you really need diversions which should ignore the current partial line, use environments\nto save the current partial line and/or use the .box request.]\n\nThe most powerful feature using diversions is to start a diversion within a macro  definition\nand  end  it  within  another macro.  Then everything between each call of this macro pair is\nstored within the diversion and can be manipulated from within the macros.\n\n### FILES\n\nAll macro package files must be named name.tmac to fully use the tmac  mechanism.   tmac.name\nas with classical packages is possible as well, but deprecated.\n\nThe macro files are kept in the tmac directories; a colon separated list of these constitutes\nthe tmac path.\n\nThe search sequence for macro files is (in that order):\n\n•      the directories specified with troff/groff's -M command-line option\n\n•      the directories given in the GROFFTMACPATH environment variable\n\n•      the current directory (only if in unsafe mode, which is enabled by the -U command-line\nswitch)\n\n•      the home directory\n\n•      a platform-specific directory, being\n\n/usr/lib/groff/site-tmac\n\nin this installation\n\n•      a site-specific (platform-independent) directory, being\n\n/usr/share/groff/site-tmac\n\nin this installation\n\n•      the main tmac directory, being\n\n/usr/share/groff/1.22.4/tmac\n\nin this installation\n\n### ENVIRONMENT\n\nGROFFTMACPATH\nA  colon  separated  list  of additional tmac directories in which to search for macro\nfiles.  See the previous section for a detailed description.\n\n### AUTHORS\n\nThis document was written by Bernd Warken ⟨groff-bernd.warken-72@web.de⟩ and  Werner  Lemberg\n⟨wl@gnu.org⟩.\n\n### SEE ALSO\n\nGroff: The GNU Implementation of troff, by Trent A. Fisher and Werner Lemberg, is the primary\ngroff manual.  You can browse it interactively with “info groff”.\n\ngroff(1)\nan overview of the groff system.\n\ngroffman(7),\ngroffmdoc(7),\ngroffme(7),\ngroffmm(7),\ngroffmom(7),\ngroffms(7),\ngrofftrace(7),\ngroffwww(7).\nthe groff tmac macro packages.\n\ngroff(7)\nthe groff language.\n\nThe Filesystem Hierarchy Standard is available at the FHS web site  ⟨http://www.pathname.com/\nfhs/⟩.\n\n\n\ngroff 1.22.4                                23 March 2022                              GROFFTMAC(5)\n\n"
        }
    ],
    "structuredContent": {
        "command": "groff_tmac",
        "section": "5",
        "mode": "man",
        "summary": "grofftmac - macro files in the roff typesetting system",
        "synopsis": null,
        "flags": [],
        "examples": [],
        "see_also": [
            {
                "name": "groff",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/groff/1/json"
            },
            {
                "name": "groffman",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/groffman/7/json"
            },
            {
                "name": "groffmdoc",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/groffmdoc/7/json"
            },
            {
                "name": "groffme",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/groffme/7/json"
            },
            {
                "name": "groffmm",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/groffmm/7/json"
            },
            {
                "name": "groffmom",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/groffmom/7/json"
            },
            {
                "name": "groffms",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/groffms/7/json"
            },
            {
                "name": "grofftrace",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/grofftrace/7/json"
            },
            {
                "name": "groffwww",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/groffwww/7/json"
            },
            {
                "name": "groff",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/groff/7/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "GROFF MACRO PACKAGES",
                "lines": 13,
                "subsections": [
                    {
                        "name": "Man Pages",
                        "lines": 11
                    },
                    {
                        "name": "Full Packages",
                        "lines": 14
                    },
                    {
                        "name": "Language-specific Packages",
                        "lines": 24
                    },
                    {
                        "name": "Input Encodings",
                        "lines": 21
                    },
                    {
                        "name": "Special Packages",
                        "lines": 84
                    }
                ]
            },
            {
                "name": "NAMING",
                "lines": 46,
                "subsections": []
            },
            {
                "name": "INCLUSION",
                "lines": 41,
                "subsections": []
            },
            {
                "name": "WRITING MACROS",
                "lines": 14,
                "subsections": [
                    {
                        "name": "Copy-in Mode",
                        "lines": 37
                    },
                    {
                        "name": "Draft Mode",
                        "lines": 19
                    },
                    {
                        "name": "Tips for Macro Definitions",
                        "lines": 23
                    },
                    {
                        "name": "Diversions",
                        "lines": 24
                    }
                ]
            },
            {
                "name": "FILES",
                "lines": 35,
                "subsections": []
            },
            {
                "name": "ENVIRONMENT",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 25,
                "subsections": []
            }
        ]
    }
}