{
    "mode": "man",
    "parameter": "groff_tmac",
    "section": "5",
    "url": "https://www.chedong.com/phpMan.php/man/groff_tmac/5/json",
    "generated": "2026-10-09T12:50:13Z",
    "sections": {
        "Name": {
            "content": "grofftmac - macro files in the GNU roff typesetting system\n",
            "subsections": []
        },
        "Description": {
            "content": "Definitions  of macros, strings, and registers for use in a roff(7) document can be collected\ninto macro files, roff input files designed to produce no output themselves but instead  ease\nthe  preparation of other roff documents.  There is no syntactical difference between a macro\nfile and any other roff document; only its purpose distinguishes it.  When a  macro  file  is\ninstalled  at  a standard location, named according to a certain convention, and suitable for\nuse by a general audience, it is termed a macro package.  Macro packages  can  be  loaded  by\nsupplying the -m option to troff(1) or a groff front end.\n\nEach  macro  package  stores  its macro, string, and register definitions in one or more tmac\nfiles.  This name originated in early Unix culture as an abbreviation of “troff macros”.\n\nA macro file must have a name in the form name.tmac (or tmac.name) and be placed in  a  “tmac\ndirectory”  to  be  loadable with the -mname option.  Section “Environment” of troff(1) lists\nthese directories.  Alternatively, a groff document requiring a macro file can load  it  with\nthe mso (“macro source”) request.\n\nLike  any  other roff document, a macro file can use the “so” request (“source”) to load fur‐\nther files relative to its own location.\n\nMacro files are named for their most noteworthy application, but a macro file need not define\nany macros.  It can restrict itself to defining registers and strings or invoking other groff\nrequests.  It can even be empty.\n",
            "subsections": []
        },
        "Macro packages": {
            "content": "Macro packages come in two varieties; those which assume responsibility for page  layout  and\nother  critical  functions (“major” or “full-service”) and those which do not (“supplemental”\nor “auxiliary”).  GNU roff provides most major macro packages found in AT&T and BSD Unix sys‐\ntems, an additional full-service package, and many supplemental packages.  Multiple full-ser‐\nvice macro packages cannot be used by the same document.  Auxiliary packages can generally be\nfreely combined, though attention to their use of the groff language name spaces for  identi‐\nfiers  (particularly  registers, macros, strings, and diversions) should be paid.  Name space\nmanagement was a significant challenge in AT&T troff; groff's support  for  arbitrarily  long\nidentifiers  affords  few  excuses  for name collisions, apart from attempts at compatibility\nwith the demands of historical documents.\n",
            "subsections": [
                {
                    "name": "Man pages",
                    "content": "an\nman    an is used to compose man pages in the format originating in Version  7  Unix  (1979).\nIt has a small macro interface and is widely used; see groffman(7).\n\ndoc\nmdoc   doc  is used to compose man pages in the format originating in 4.3BSD-Reno (1990).  It\nprovides many more features than an, but is also larger,  more  complex,  and  not  as\nwidely adopted; see groffmdoc(7).\n\nBecause  readers  of man pages often do not know in advance which macros are used to format a\ngiven document, a wrapper is available.\n\nandoc\nmandoc This macro file, specific to groff, recognizes whether a document  uses  man  or  mdoc\nformat  and loads the corresponding macro package.  Multiple man pages, in either for‐\nmat, can be handled; andoc reloads each macro package as necessary.\n"
                },
                {
                    "name": "Full-service packages",
                    "content": "The 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 mom macro package, only available in groff.  As this was not based on other  pack‐\nages, it was freely designed as quite a nice, modern macro package.  See groffmom(7).\n\nms     The classical ms macro package; see groffms(7).\n"
                },
                {
                    "name": "Localization packages",
                    "content": "For  Western languages, the localization file sets the hyphenation mode and loads hyphenation\npatterns and exceptions.  Localization files can also adjust  the  date  format  and  provide\ntranslations  of strings used by some of the full-service macro packages; alter the input en‐\ncoding (see the next section); and change the amount of additional inter-sentence space.  For\nEastern languages, the localization file defines character classes and sets  flags  on  them.\nBy default, troffrc loads the localization file for English.\n\ntrans  loads  localized  strings  used  by various macro packages after their localized forms\nhave been prepared by a localization macro file.\n\ngroff provides the following localization files.\n\ncs     Czech; localizes man, me, mm, mom, and ms.  Sets the  input  encoding  to  Latin-2  by\nloading latin2.tmac.\n\nde\nden    German;  localizes  man,  me,  mm, mom, and ms.  Sets the input encoding to Latin-1 by\nloading latin1.tmac.\n\nde.tmac selects hyphenation patterns for traditional orthography,  and  den.tmac  does\nthe same for the new orthography (“Rechtschreibreform”).\n\nen     English.\n\nfr     French;  localizes  man,  me,  mm, mom, and ms.  Sets the input encoding to Latin-9 by\nloading latin9.tmac.\n\nit     Italian; localizes man, me, mm, mom, and ms.\n\nja     Japanese.\n\nsv     Swedish; localizes man, me, mm, mom, and ms.  Sets the input encoding  to  Latin-1  by\nloading  latin1.tmac.   Some  of  the  localization of the mm package is handled sepa‐\nrately; see groffmmse(7) (only in Swedish locales).\n\nzh     Chinese.\n"
                },
                {
                    "name": "Input encodings",
                    "content": "latin1\nlatin2\nlatin5\nlatin9 are various ISO 8859 input encodings supported by groff.  On systems using ISO charac‐\nter encodings, groff loads latin1.tmac automatically at startup.  A document that uses\nLatin-2, Latin-5, or Latin-9 can specify one of these alternative encodings.\n\ncp1047 provides  support  for  EBCDIC-based  systems.   On  those  platforms,   groff   loads\ncp1047.tmac automatically at startup.\n\nBecause  different  input  character codes constitute valid GNU troff input on ISO and EBCDIC\nsystems, the latin macro files cannot be used on EBCDIC systems, and cp1047 cannot be used on\nISO systems.\n"
                },
                {
                    "name": "Auxiliary packages",
                    "content": "The macro packages in this section are not intended for stand-alone use, but  can  add  func‐\ntionality to any other macro package or to plain (“raw”) groff documents.\n\n62bit  provides  macros for addition, multiplication, and division of 62-bit integers (allow‐\ning safe multiplication of signed 31-bit integers, for example).\n\nhdtbl  allows the generation of tables using a syntax similar to the HTML table model.   This\nHeidelberger  table  macro  package  is not a preprocessor, which can be useful if the\ncontents of table entries are determined by  macro  calls  or  string  interpolations.\nCompare  to  tbl(1).   It  works  only  with  the  ps  and  pdf  output  devices.  See\ngroffhdtbl(7).\n\npapersize\nenables the paper format to be set on the command line by giving a  “-d  paper=format”\noption  to  troff.   Possible  values  for format are the ISO and DIN formats “A0–A6”,\n“B0–B6”,  “C0–C6”,  and  “D0–D6”;  the  U.S.  formats  “letter”,  “legal”,  “tabloid”,\n“ledger”,  “statement”,  and “executive”; and the envelope formats “com10”, “monarch”,\nand “DL”.  All formats, even those for envelopes, are  in  portrait  orientation:  the\nlength measurement is vertical.  Appending “l” (ell) to any of these denotes landscape\norientation  instead.   This  macro file assumes one-inch horizontal margins, and sets\nregisters recognized by the groff man, mdoc, mm, mom, and  ms  packages  to  configure\nthem accordingly.  If you want different margins, you will need to use those packages'\nfacilities, or troff ll and/or po requests to adjust them.  An output device typically\nrequires  command-line options -p and -l to override the paper dimensions and orienta‐\ntion, respectively, defined in  its  DESC  file;  see  subsection  “Paper  format”  of\ngroff(1).  This macro file is normally loaded at startup by the troffrc file when for‐\nmatting for a typesetting device (but not a terminal).\n\npdfpic provides a single macro, PDFPIC, to include a PDF graphic in a document using features\nof the pdf output driver.  For other output devices, PDFPIC calls PSPIC, with which it\nshares an interface (see below).  This macro file is normally loaded at startup by the\ntroffrc file.\n\npic    supplies  definitions  of the macros PS, PE, and PF, usable with the pic(1) preproces‐\nsor.  They center each picture.  Use it if your document does not use  a  full-service\nmacro  package, or that package does not supply working pic macro definitions.  Except\nfor man and mdoc, those provided with groff already do so (exception: mm  employs  the\nname PF for a different purpose).\n\npspic  provides  a  macro,  PSPIC, that includes a PostScript graphic in a document.  The ps,\ndvi, html, and xhtml output devices support such inclusions; for  all  other  drivers,\nthe  image  is  replaced  with  a  rectangular border of the same size.  pspic.tmac is\nloaded at startup by the troffrc file.\n\nIts syntax is as follows.\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 units attached; the default scaling unit is i.  PSPIC scales the graphic  uni‐\nformly in the horizontal and vertical directions so that it is no more than width wide\nand height high.  Option -C centers the graphic horizontally; this is the default.  -L\nand  -R  left- and right-align the graphic, respectively.  -I indents the graphic by n\n(with a default scaling unit of m).\n\nTo use PSPIC within a diversion, we recommend extending it with  the  following  code,\nassuring 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\nFailure  to load PSPIC's image argument is not an error.  (The psbb request does issue\nan error diagnostic.)  To make such a failure fatal, append  to  the  pspic*error-hook\nmacro.\n\n.am pspic*error-hook\n.  ab\n..\n\nptx    provides  a  macro, xx, to format permuted index entries as produced by the GNU ptx(1)\nprogram.  If your formatting needs differ, copy the macro into your document and adapt\nit to your needs.\n\nrfc1345\ndefines special character escape sequences named for the glyph mnemonics specified  in\nRFC 1345 and the digraph table of the Vim text editor.  See groffrfc1345(7).\n\nsboxes offers  an  interface  to  the  “pdf:  background” device control command supported by\ngropdf(1).  Using this package, groff ms documents can draw colored rectangles beneath\nany output.\n\n.BOXSTART SHADED color OUTLINED color INDENT size WEIGHT size\nbegins a box, where the argument after SHADED gives the fill color and that af‐\nter OUTLINED the border color.  Omit the former to get a borderless filled  box\nand  the latter for a border with no fill.  The specified WEIGHT is used if the\nbox is OUTLINED.\n\nINDENT precedes a value which leaves a gap between the border and the  contents\ninside the box.\n\nEach  color must be a defined groff color name, and each size a valid groff nu‐\nmeric expression.  The keyword/value pairs can be specified in any order.\n\nBoxes can be stacked, so you can start a box within another  box;  usually  the  later\nboxes  would be smaller than the containing box, but this is not enforced.  When using\nBOXSTART, the left position is the current indent minus the INDENT in the command, and\nthe right position is the left position  (calculated  above)  plus  the  current  line\nlength and twice the indent.\n\n.BOXSTOP\ntakes  no  parameters.   It closes the most recently started box at the current\nvertical position after adding its INDENT spacing.\n\nYour groff documents can conditionally exercise the sboxes macros.  The register GSBOX\nis defined if the package is loaded, and interpolates a true value if the  pdf  output\ndevice is in use.\n\nsboxes  furthermore  hooks  into the groffms(7) package to receive notifications when\nfootnotes are growing, so that it can close boxes  on  a  page  before  footnotes  are\nprinted.   When  that condition obtains, sboxes will close open boxes two points above\nthe footnote separator and re-open them on the next page.  (This amount probably  will\nnot match the box's INDENT.)\n\nSee “Using PDF boxes with groff and the ms macros” for a demonstration.\n\ntrace  aids the debugging of groff documents by tracing macro calls.  See grofftrace(7).\n\nwww    defines macros corresponding to HTML elements.  See groffwww(7).\n"
                }
            ]
        },
        "Naming": {
            "content": "AT&T  nroff  and troff were implemented 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  typically loaded using the -m option to the formatter; when directly followed\nby its argument without an intervening space, this looked like a long option  preceded  by  a\nsingle  minus—a  sensation  in  the  computer stone age.  Macro packages therefore came to be\nknown by names that started with the letter “m”, which was omitted from the name of the macro\nfile as stored on disk.  For example, the manuscript macro package was stored as  tmac.s  and\nloaded with the option -ms.\n\ngroff  commands  permit  space  between  an option and its argument.  The syntax “groff -m s”\nmakes the macro file name more clear but may surprise users familiar with the  original  con‐\nvention, unaware that the package's “real” name was “s” all along.  For such packages of long\npedigree,  groff  accommodates different users' expectations by supplying wrapper macro files\nthat load the desired file with mso requests.  Thus, all of “groff  -m  s”,  “groff  -m  ms”,\n“groff -ms”, and “groff -mms” serve to load the manuscript macros.\n\nWrappers are not provided for packages of more recent vintage, like www.tmac.\n\nAs  noted in passing above, AT&T troff named macro files in the form tmac.name.  It has since\nbecome conventional in operating systems to use a suffixed file name extension to  suggest  a\nfile type or format.\n",
            "subsections": []
        },
        "Inclusion": {
            "content": "The  traditional  method  of employing a macro package is to specify the -m package option to\nthe formatter, which then reads package's macro file prior to any input files.  Historically,\npackage was sought in a file named tmac.package (that is, with a “tmac.” prefix).  GNU  troff\nsearches for package.tmac in the macro path; if not found, it looks for tmac.package instead,\nand vice versa.\n\nAlternatively,  one  could  include  a macro file by using the request “.so file-name” in the\ndocument; file-name is resolved relative to the location of the input  document.   GNU  troff\noffers an improved feature in the similar request “mso package-file-name”, which searches the\nmacro path for package-file-name.  Because its argument is a file name, its “.tmac” component\nmust  be  included  for the file to be found; however, as a convenience, if opening it fails,\nmso strips any such suffix and tries again with a “tmac.” prefix, and vice versa.\n\nIf a sourced file requires preprocessing, for example if it includes tbl tables or eqn  equa‐\ntions,  the preprocessor soelim(1) must be used.  This can be achieved with a pipeline or, in\ngroff, by specifying the -s option to the formatter (or front end).   man(1)  librarian  pro‐\ngrams  generally  call soelim automatically.  (Macro packages themselves generally do not re‐\nquire preprocessing.)\n",
            "subsections": []
        },
        "Writing macros": {
            "content": "A 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 occurs when ar‐\nguments are passed with a macro call.  Within the macro definition, the arguments are  avail‐\nable  as  the escape sequences \\$1, ..., \\$9, \\$[...], \\$*, and \\$@, the name under which the\nmacro was called is in \\$0, and the number of arguments is in register \\n[.$]; see groff(7).\n",
            "subsections": [
                {
                    "name": "Draft mode",
                    "content": "Writing groff macros is easy when the escaping mechanism is temporarily disabled.  In  groff,\nthis  is  done  by  enclosing  the macro definition(s) within a pair of .eo and .ec requests.\nThen the body in the macro definition is just like a normal part of the document —  text  en‐\nhanced  by  calls  of requests, macros, strings, registers, etc.  For example, the code above\ncan be written in a simpler way by\n\n.eo\n.ds midpart was called with the following\n.de printargs\n\\f[I]\\$0\\f[] \\*[midpart] \\n[.$] arguments:\n\\$*\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"
                },
                {
                    "name": "Tips for macro definitions",
                    "content": "•      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 and draft modes; since the escape char‐\nacter is off in draft mode, trouble might occur  when  comment  escape  sequences  are\nused.   For example, the following macro just ignores its arguments, so it acts like a\ncomment 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"
                },
                {
                    "name": "Diversions",
                    "content": "Diversions 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 diversions get their power\nwhen used dynamically within macros.  The (formatted) information stored in a  diversion  can\nbe retrieved by calling the diversion just like a macro.\n\nMost  of  the problems arising with diversions can be avoided if you remember that diversions\nalways store complete lines.  Using diversions when the line buffer has not been flushed pro‐\nduces strange results; not knowing this, many people get desperate about diversions.  To  en‐\nsure that a diversion works, add line breaks at the right places.  To be safe, enclose every‐\nthing that has to do with diversions within a pair of line breaks; for example, by explicitly\nusing  .br  requests.   This  rule should be applied to diversion definition, both inside and\noutside, and to all calls of diversions.  This is 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"
                }
            ]
        },
        "Authors": {
            "content": "This document was written by Bernd Warken, Werner Lemberg, and G. Branden Robinson.\n\nSee also\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\nThe Filesystem Hierarchy Standard is maintained by the Linux Foundation.\n\ngroff(1)\nis an overview of the groff system.\n\ngroffman(7),\ngroffmdoc(7),\ngroffme(7),\ngroffmm(7),\ngroffmom(7),\ngroffms(7),\ngroffrfc1345(7),\ngrofftrace(7),\nand\ngroffwww(7)\nare groff macro packages.\n\ngroff(7)\nsummarizes the language recognized by GNU troff.\n\ntroff(1)\ndocuments the default macro file search path.\n\ngroff 1.23.0                                31 March 2024                              grofftmac(5)",
            "subsections": []
        }
    },
    "flags": [],
    "examples": [],
    "see_also": []
}