Back to Table of Contents Next: Page headers/footers, pagination

Graphics, floats, and preprocessor support


Inserting images and graphics

In order to include images in mom documents, the images must be in either PDF (.pdf) or EPS (.eps) format. Each format requires its own macro, but both take the same arguments, and in the same order.

Please note that there are differences in the way the files containing PDF and EPS images must be processed, hence documents may not contain a mix.

Image conversion and file processing

When your image files are not in PDF or EPS format—jpgs, for example—you must convert them before including them in a mom document. Any utility for converting images may used. The ImageMagick suite of programmes, present on most GNU/Linux systems, contains convert, which is simple and effective.

PDF

Assuming a jpg image, conversion to PDF is done like this:
convert <image>.jpg <image>.pdf Any image type supported by convert may be converted this way.

Mom files containing PDF images must be processed using groff’s pdf driver. Use of pdfmom is strongly recommended, which natively invokes the pdf driver.
pdfmom doc.mom > doc.pdf

EPS

Assuming a jpg image, conversion to EPS is done like this:
convert <image>.jpg <image>.eps Any image type supported by convert may be converted this way. There have been reports of trouble with PostScript level 2 images, so don’t save your images in this format.

Mom files containing EPS images must be processed using groff’s postscript driver. Use of pdfmom, which can be told to use the postscript driver, is strongly recommended.
pdfmom -Tps doc.mom > doc.pdf

PDF_IMAGE

Macro: PDF_IMAGE [ -L | -C | -R | -I <indent> ] \
<image-file.pdf> <width> <height> [ SCALE <factor> ] \
[ ADJUST +|-<vertical adjustment> ] [ NO_SHIM ] \
[ FRAME ] \
[ CAPTION "<caption>" ] [ SHORT_CAPTION "<short caption>" ] \
[ LABEL "<label>" ]

•  <indent>, <width>, <height> and <vertical adjustment> require a unit of measure

Note: Arguments may be broken into several lines using the “line-continued” backslash (\), as shown above.

Unlike PSPIC, which it resembles, PDF_IMAGE requires that the pdf image’s dimensions (the bounding box, see below) be supplied each time it’s called.

The first optional argument tells mom how to align the image horizontally, with -L, -C, and -R standing for left, centre and right respectively. If you need more precise placement, the -I argument allows you to give an indent from the left margin. Thus, to indent a PDF image 6 picas from the left margin
.PDF_IMAGE -I 6P <remaining arguments> If you omit the first argument, the image will be centred.

<pdf image> must be in PDF format, with a .pdf extension. If it is not, mom will abort with a message. See here for instructions on converting image formats to PDF.

<width> and <height> are the dimensions of the image’s bounding box. The most reliable way of getting the bounding box is with the utility, pdfinfo:
pdfinfo <image.pdf> | grep "Page *size" This will spit out a line that looks like this:
Page size: width x height pts pts means points, therefore the unit of measure appended to <width> and <height> must be p.

The remaining arguments are optional and may be entered in any order, although it’s best to put CAPTION, SHORT_CAPTION, and LABEL last.

'SCALE'

SCALE allows you to scale the image by <factor>. The factor is a percentage of the image’s original dimensions, thus SCALE 50 scales the image to 50 percent of its original size. No percent sign or unit of measure should be appended.

'ADJUST'

ADJUST lets you raise (+) or lower (-) the image within the space allotted for it by the amount you specify. This is useful for achieving good optical centering between surrounding blocks of type. A unit of measure is required.

'NO_SHIM'

NO_SHIM instructs mom not to apply shimming after the image, which she does by default. Shimming ensures that running text after the image falls properly on the page’s baseline grid, but usually results in slightly unequal spacing above and below, which must be corrected with the ADJUST argument. Mom’s default shimming is generally a good idea since it ensures properly aligned bottom margins for running text, however if you have several images on the page, there may be visible differences in the spacing beneath images. NO_SHIM corrects the problem, but will result in running text that does not completely fill the page unless shimming is applied manually elsewhere on the same page.

'FRAME'

FRAME instructs mom to put a frame around the image. Parameters for the frame are set with PDF_IMAGE_FRAME.

'CAPTION'

CAPTION allows you to give the image a caption. By default, the caption appears above the image, but may be attached to the label that appears beneath the image. See CAPTION_AFTER_LABEL in Captions and labels. The text of the caption must be surrounded by double-quotes.

'SHORT_CAPTION'

SHORT_CAPTION allows you to trim long captions for inclusion in the List of Figures. The text you supply, surrounded by double-quotes, is what will appear in the List.

'LABEL'

LABEL, if given, appears beneath the image. The text you supply, surrounded by double-quotes, is how the image is labelled in both the document proper and the List of Figures. Mom provides an auto-labelling facility for images (see AUTOLABEL), which, if enabled, overrides the LABEL argument.

Remember that mom files with embedded PDF images must be processed with
pdfmom doc.mom > doc.pdf

Note: Version 2.0-c change
Mom now treats all pdf images identically to floats, which is to say that if an image doesn’t fit on the output page, she will defer it to the top of the next page while continuing to process running text. ADJUST is ignored whenever an image is deferred, except when moving from column to column on the same page, when the image may need to be optically adjusted. Subsequent images that do not fit, if any, are output in order immediately after the first.

Prior to 2.0-c, it was recommended that images be wrapped inside FLOAT, but this is now no longer required, and should, in fact, be avoided.

PDF_IMAGE_FRAME

Macro: PDF_IMAGE_FRAME <inset amount> <rule weight> <color>

• <inset amount> requires a unit of measure; conversely, <rule weight> must not have a unit of measure appended

PDF_IMAGE_FRAME establishes the parameters for subsequent invocations of PDF_IMAGE when the FRAME argument is given. Arguments must appear in order, and any you wish left at the current value should be entered as two adjacent double-quotes. So, for example, .PDF_IMAGE_FRAME "" "" blue leaves the inset value and rule weight at their current value and changes the frame colour to blue.

Frames are drawn outside the image at its requested dimensions inclusive of scaling. Colours must be pre-initialized with XCOLOR or NEWCOLOR.

The default inset is 6 points, the default rule weight is .5 (points), and the default colour is black.

PSPIC

Macro: PSPIC [ -L | -R | -I <n> ] <file> [ width [ height ] ]

PSPIC is not actually part of mom, but rather a macro included with every groff installation. man groff_tmac contains the documentation for PSPIC, but I’ll repeat it here with a few modifications for clarity.

From groff_tmac

<file> is the name of the file containing the image; width and height give the desired width and height of the image as you wish it to appear within the document. The width and height arguments may have units of measure attached; the default unit of measure is i. PSPIC 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 centred. 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>; the default unit of measure is m (ems).

It is not necessary to pass PSPIC the <width> and <height> arguments unless you are scaling the image, in which case you will most likely need the original dimensions of the EPS image’s bounding box. These can be found with gs -q -dBATCH -dNOPAUSE -sDEVICE=bbox <image file>.pdf 2>&1 \ | grep "%%BoundingBox" | cut -d " " -f4,5 The two digits returned are in points, therefore the unit of measure p must be appended to them.

Because PSPIC lacks the ADJUST option offered by PDF_IMAGE a certain amount of manual tweaking of the vertical placement of the image will probably be required, typically by using the ALD and RLD macros. Wrapping the image in a float and using FLOAT’s ADJUST option can also be used to correct optical centering.

Additionally, non-floated EPS images inserted into running text will almost certainly disrupt the baseline placement of running text. In order to get mom back on track after inserting a non-floated .PSPIC image, I strongly recommend using the SHIM macro so that the bottom margin of running text falls where it should.

Remember that mom files with embedded EPS images must be processed with
pdfmom -Tps doc.mom > doc.pdf

Please note: PSPIC does not support autolabelling, labels, captions, or inclusion in the List of Figures. If you wish this functionality, convert your images to pdf and use PDF_IMAGE instead, then process the file with pdfmom (without the -Tps option).


Introduction to floats

Non-textual insertions in a document (tables, for example) sometimes do not fit on the output page of a PDF or PostScript document at the place they’re inserted in the input file. It’s necessary, therefore, to defer them to the next page while carrying on with running text.

Whenever you need this functionality, mom provides the FLOAT macro.

Floats are usually used for images and graphics, but can contain anything you like, including text. Whatever’s in the float will be kept together as a block, output immediately if there’s room, or deferred to the top of the next output page when there isn’t; running text continues to the bottom of the previous page without interruption.

In the case of a float that doesn’t fit being followed by one that does, the second is output in position and the first is deferred. In the case of two or more that don’t fit, they are output in order on the next page.

A key distinction between a float and a QUOTE or BLOCKQUOTE is that while a float keeps everything together and defers output if necessary, quotes and blockquotes are output immediately, and may start on one page and finish on the next.

Floats always deposit a break before they begin, which means the line beforehand will not be filled. Floats, therefore, cannot be inserted in the middle of a paragraph without studying the output file and determining where to break or spread the line before the float. Furthermore, if you want a float between paragraphs, the float should come before .PP, like this:
.FLOAT ... .FLOAT OFF .PP not
.PP .FLOAT ... .FLOAT OFF

Floats begin on the baseline immediately below the running text preceding them. No additional whitespace surrounds them, above or below. Running text below a float is, however, shimmed, unless shimming has been disabled with .NO_SHIM or the NO_SHIM argument is given to FLOAT. Shimming generally results in a small amount of extra whitespace after the float, which can be equalized with the whitespace beforehand using the ADJUST argument to FLOAT.

If you’d like more space around a float, you must add it manually, for example with ALD or SPACE.

FLOAT

Macro: FLOAT [ ADJUST +|-<amount> ] [ FORCE ] [ SPAN ] [ NO_SHIM] | <anything>

Note: FLOAT is intended for use with the document processing macros only.

To begin a float, simply invoke .FLOAT and follow it with whatever you want the float to contain. When you’re done, invoke .FLOAT OFF (or QUIT, END, X, etc).

The optional ADJUST argument tells mom to raise (+) or lower (-) the float within the space allotted to it by the specified amount. <amount> must have a unit of measure appended. ADJUST gives you precise control over the vertical centering of floats, allowing you to compensate for unequal spacing that may result of from the automatic shimming of floats (or the absence thereof). See SHIM for a discussion of automatic shimming.

The FORCE argument instructs mom to output the float exactly where it occurs in the input file. With FORCE, mom immediately breaks to a new page to output the float if it does not fit on the current page. While this is somewhat contrary to the notion of floats (ie that running text should continue to fill the page), there are circumstances where it may be desirable.

ADJUST is ignored whenever a float is deferred to the following page.

The SPAN argument tells mom that a float, if deferred, may carry onto multiple pages. Please note that SPAN may not be used for floats containing a boxed table; mom will abort with a warning should this occur. Unboxed tables, on the other hand, are acceptable within floats that are given the SPAN argument.

NO_SHIM instructs mom not to apply shimming after the float, which she does by default. Shimming ensures that running text after the float falls properly on the page’s baseline grid, but usually results in slightly unequal spacing above and below, which must be corrected with the ADJUST argument. Mom’s default shimming is generally a good idea since it ensures properly aligned bottom margins for running text, however if you have several floats on the page, there may be visible differences in the spacing beneath them. NO_SHIM corrects the problem, but will result in running text that does not completely fill the page unless shimming is applied manually elsewhere on the same page.

Note: Floats use no-fill mode, with each input line beginning at the left margin. If this is not what you want, you must specify the preferred horizontal alignment within the float (eg CENTER or RIGHT).

Furthermore, if you want text filled, you must specify .QUAD L|R|C or .JUSTIFY—again, within the float.


Preprocessor support

Mom offers full support for the eqn (equations), pic (diagrams), tbl (tables), and refer (bibliographies/citations) preprocessors, including captions, labelling, autolabelling, and inclusion in the Lists of Equations, Figures, and Tables.

Other than refer, which is discussed at length in the Bibliographies and references section, it is beyond the scope of this documentation to cover full preprocessor usage. Consult the manpages eqn(1), pic(1), and tbl(1) for instructions.

Version 2.0-c changes
Preprocessor support has been revised and expanded as of version 2.0-c. Please read the following sections thoroughly and update any documents created with versions prior to 2.0-c as necessary.

tbl support

Mom documents can include tables generated with the groff preprocessor, tbl. If you are unfamiliar with tbl, I recommend downloading a copy of Tbl - A Program to Format Tables, which, in addition to providing a thorough introduction, contains some fine examples.

Tables formatted with tbl begin with the macro .TS (Table Start) and end with .TE (Table End). Depending on where you want your tables output in a document, you may need to wrap your tbl code inside a float, or pass the H argument to .TS.

If you put tbl code inside a float, the table will be output immediately if it fits on the page, or deferred to the top of the next page if it doesn’t. If you prefer a table to begin where you say and span over to the next page, or if you know for certain a boxed table will run to multiple pages, simply pass the H argument to .TS, along with a corresponding TH and do not wrap the table inside a float.

Note: If you use .TS H to create a boxed table that spans multiple pages, do not attempt to wrap the table inside a float. For the purposes of boxed, multipage tables, .TS H and .FLOAT should be considered mutually exclusive. This restriction is imposed by the tbl preprocessor itself, not groff or mom.

tbl placement in mom docs

If you use .TS without the H argument (and therefore no .TH), tables that fit on the page are output in position. If there is not enough room to output the table, tbl will abort with message instructing you to use .TS H/.TH. Given that .TS without TH may sometimes fail, it is advisable to begin all tbl blocks with .TS H.

If you give .TS the H argument (with a corresponding .TH), tables will be output in position and span as many pages as necessary to complete output. A table header will be printed at the top of each page’s table output. In the event that there is not enough room to print the table header and at least one row of table data near the bottom of a page, mom will break to a new page before beginning table output, leaving a blank in running text.

Boxed tables inside floats are output in position if they fit on the page. If not, they are deferred to the top of the next page without a break in running text. Boxed tables within floats may not, however, span multiple pages; mom will abort with a message should a boxed table in a float run longer than the page.

Unboxed tables inside floats may span multiple pages provided the SPAN argument has been given to FLOAT.

Note: The vertical spacing around unfloated tables may appear slightly unequal, especially if there are several tables on the page. This is a result of shimming that mom applies automatically after each table. You may disable shimming with .NO_SHIM, or by giving the NO_SHIM argument to .TS. In either case, you will still likely want to adjust the spacing around with table with the AJUST argument to .TS. Tables inside floats should be adjusted with the ADJUST argument to FLOAT, not the ADJUST argument to .TS.

.TS / .TH / .TE

Macro: TS
Arguments:
  [ H ]
  [ BOXED ]
  [ CENTER ]
  [ NEEDS ]
  [ ADJUST +|-<vertical adjustment>]
(unit of measure required)
  [ NO_SHIM ]
  [ CAPTION "<caption>" ]
  [ SHORT_CAPTION "<short caption>" ]
  [ LABEL "<label>" ]

Macro: TH (optional, only if .TS H)
Macro: TE [ SOURCE "<text of table source>" ]

Tables to be formatted with tbl begin with the macro .TS and end with .TE. Global tbl options (“flags”), formatting, and data (per tbl(1)) come between the two macros.
.TS <tbl options, formatting, and data> .TE Tables may be wrapped inside a float, in which case, the entire table will be output on the current page if it fits, or deferred to the next page if it doesn’t.
.FLOAT .TS <tbl options, formatting, and data> .TE .FLOAT OFF

The .TS macro

Note: Version 2.0-c change
2.0-c introduces revisions to the handling of labels and/or captions, which, along with NO_SHIM, must now be given as arguments to .TS rather than .TE, as was the case formerly. Please read this section carefully if you have documents containing tables as they may need to be updated.

IMPORTANT: All arguments to TS must appear on the same line as .TS. Do not attempt to break them up with the “line-continued” backslash. You may want to set your text editor to “wrap” mode in order to see all your arguments. This annoyance stems from the preprocessor mechanism itself, not groff or mom.

The TS macro must be invoked before entering a tbl block. You may give as many or as few of its arguments as required, in any order, although it is advisable to put CAPTION, SHORT_CAPTION, and/or LABEL last.

'H'

With the H argument, a table will span as many pages as necessary, with or without a running header. The placement of the corresponding .TH, which is required whenever the H argument is given, determines what, if anything, goes in the header. Compare the following: .TS H .TS H c s s c s s c s s c s s c c c c c c n n n. n n n. Percent Increase .TH 2002-2012 Percent Increase .TH 2002-2012 <tbl data> <tbl data> .TE .TE The first example will create a table that spans multiple pages if necessary, with a running header (“Percent Increase / 2002-2012”) for that table appearing at the top of each page until the table ends. The second example, equally, may run to several pages, but without the running header. See TH for an explanation of .TH placement.

Tip: Generally speaking, it’s a good idea to get into the habit of using .TS H all the time, since there are no circumstances under which it fails, whereas .TS without H will fail on tables that exceed the page length.

'BOXED'

If a table is to be boxed (ie tbl is given the flags 'box' or 'allbox') you must pass the argument BOXED to .TS, as in this example:
.TS BOXED allbox; c s s c c c n n n. <tbl data> .TE

'CENTER'

If a table is to be centered on the page, (ie tbl is given the 'center' flag), you must pass the argument CENTER to .TS, as in this example, which creates a (possibly) multipage boxed table, centered on the page, with a running header. .TS H BOXED CENTER allbox center; c s s c s s c c c n n n. Percent Increase 2002-2012 .TH <tbl data> .TE

'NEEDS'

If a table is not inside a float and you pass .TS the H argument (which you should; see the tip here), mom begins output immediately where the table occurs in the input file if there is enough room on the output page for the table header plus at least one row of table data. If there isn't enough room, mom breaks to a new page before beginning the table, leaving a gap in running text at the bottom of the previous page. If, for aesthetic reasons, you would prefer that mom require more than one row of table data beneath the header near the bottom of a page, you may increase the number with the NEEDS argument, followed by the desired number of rows.

'ADJUST'

ADJUST lets you raise (+) or lower (-) the image within the space allotted for it by the amount you specify. This is useful for achieving good optical centering between surrounding blocks of type. A unit of measure is required.

'NO_SHIM'

NO_SHIM instructs mom not to apply shimming after the image, which she does by default. Shimming ensures that running text after the image falls properly on the page’s baseline grid, but usually results in slightly unequal spacing above and below, which must be corrected with the ADJUST argument. Mom’s default shimming is generally a good idea since it ensures properly aligned bottom margins for running text, however if you have several images on the page, there may be visible differences in the spacing beneath images. NO_SHIM corrects the problem, but will result in running text that does not completely fill the page unless shimming is applied manually elsewhere on the same page.

'CAPTION'

CAPTION allows you to give the table a caption. By default, the caption appears above the table, but may be attached to the label that appears beneath the table. See CAPTION_AFTER_LABEL in Captions and labels. The text of the caption must be surrounded by double-quotes.

Please note that if your table has a caption, you must invoke TS with the H flag, which also entails the use of TH.

'SHORT_CAPTION'

SHORT_CAPTION allows you to trim long captions for inclusion in the List of Tables. The text you supply, surrounded by double-quotes, is what will appear in the List.

'LABEL'

LABEL, if given, appears beneath the table. The text you supply, surrounded by double-quotes, is how the table is labelled in both the document proper and the List of Tables. Mom provides an auto-labelling facility for tables (see AUTOLABEL), which, if enabled, overrides the LABEL argument.

The .TH macro

The TH macro (Table Header), which is required when you begin a table with .TS H, allows you to determine what goes in a table’s running header if it spans multiple pages. Placing .TH under the first row of tbl data makes the first row the header. If placed under the second row, the first and second rows form the header, and so on.

As there are sometimes reasons to run .TS H when you don’t, in fact, want a running header (e.g. when your table has a caption), you can suppress it by placing .TH immediately underneath your tbl formatting specifications, the last line of which always ends with a period (see tbl(1)).

See the H argument to .TS for examples demonstrating .TH placement.

The .TE macro

tbl blocks must be terminated with .TE, which, as of version 2.0-c, takes a single, optional argument, SOURCE. (Formerly, TE took a label/caption argument along with arguments controlling placement.) The argument is followed by the text of the table’s source, surrounded by double-quotes. The source will appear immediately beneath the label and/or caption underneath the table, or, if MLA (Modern Language Association) is enabled, immediately below the table.


pic support

Mom documents can include diagrams generated with the groff preprocessor, pic. If you are unfamiliar with pic, I recommend downloading a copy of Making Pictures with GNU PIC which provides a thorough introduction and contains many examples.

Diagrams created with pic begin with the macro .PS (Pic Start) and end with .PE (Pic End). Everything between them is intrepreted by the preprocessor as pic instructions.

Pic diagrams are always centered. Note that this represents a change from version 2.0-b of mom, where centering diagrams required passing -mpic to groff or pdfmom on the command line.

In addition, mom treats pic diagrams identically to floats, which is to say that if a diagram doesn’t fit on the output page, she will defer it to the top of the next page while continuing to process running text. ADJUST is ignored whenever a diagram is deferred, except when moving from column to column on the same page, when the diagram may need to be optically adjusted. Subsequent diagrams that do not fit, if any, are output in order immediately after the first.

Lastly, if your diagrams contain text, you may set all the type parameters for the text (family, font, size, leading) separately from the pic block with the macro, PIC_TEXT_STYLE. If you need to change the type parameters within the block on-the-fly, you must use pic’s native facilities for doing so.

.PS / .PE

Macro: PS
Arguments:
  [ width ]
(in inches; no unit of measure required)
  [ height ]
(in inches; no unit of measure required)
  [ ADJUST +|-<vertical adjustment>]
(unit of measure required)
  [ NO_SHIM ]
  [ CAPTION "<caption>" ]
  [ SHORT_CAPTION "<short caption>" ]
  [ LABEL "<label>" ]

Macro: PE (no arguments; ends the pic block)

IMPORTANT: All arguments to PS must appear on the same line as .PS. Do not attempt to break them up with the “line-continued” backslash. You may want to set your text editor to “wrap” mode in order to see all your arguments. This annoyance stems from the preprocessor mechanism itself, not groff or mom.

'width' and 'height'

The width and height arguments to .PS are idiosyncratic owing to the preprocessor itself. If a width argument is supplied, the diagram, but not any text it contains, is scaled to the given width. If a literal width argument of 0 (zero) is given and a height argument is supplied, the diagram, but not any text it contains, will be scaled to the requested height. In the case of two non-zero arguments being given, only the height scaling is applied.

'ADJUST'

ADJUST lets you raise (+) or lower (-) a diagram within the space allotted for it by the amount you specify. This is useful for achieving good optical centering between surrounding blocks of type. A unit of measure is required.

'NO_SHIM'

NO_SHIM instructs mom not to apply shimming after the diagram, which she does by default. Shimming ensures that running text after the diagram falls properly on the page’s baseline grid, but usually results in slightly unequal spacing above and below, which must be corrected with the ADJUST argument. Mom’s default shimming is generally a good idea since it ensures properly aligned bottom margins for running text, however if you have several diagrams on the page, there may be visible differences in the spacing beneath them. NO_SHIM corrects the problem, but will result in running text that does not completely fill the page unless shimming is applied manually elsewhere on the same page.

'CAPTION'

CAPTION allows you to give the diagram a caption. By default, the caption appears above the diagram, but may be attached to the label that appears beneath it. See CAPTION_AFTER_LABEL in Captions and labels. The text of the caption must be surrounded by double-quotes.

'SHORT_CAPTION'

SHORT_CAPTION allows you to trim long captions for inclusion in the List of Figures. The text you supply, surrounded by double-quotes, is what will appear in the List.

'LABEL'

LABEL, if given, appears beneath the diagram. The text you supply, surrounded by double-quotes, is how the diagram is labelled in both the document proper and the List of Figures. Mom provides an auto-labelling facility for diagrams (see AUTOLABEL), which, if enabled, overrides the LABEL argument.

PIC_TEXT_STYLE

Macro: PIC_TEXT_STYLE \
  [ FAMILY ] "<family>" \
  [ FONT ] "<font>" \
  [ SIZE ] "+|-<size>" \
  [ AUTOLEAD ] "<value>"

Diagrams drawn with pic may contain text, and groff inline escapes may be used to alter the text parameters. A problem that arises from so doing is that, in many cases, it clutters up the pic code unnecessarily.

PIC_TEXT_STYLE lets you establish the type parameters for text inside a pic block all at once in cases where so doing improves the readability of your mom source files.

The arguments to PIC_TEXT_STYLE behave identically to the arguments to other control macros, explained here. They may be given in any order, and you may use as many or as few as you like.

Note: Text within pic diagrams does not scale when you provide a scaling argument to .PS. This is a limitation of the preprocessor itself, not groff or mom.


eqn support

Support for eqn is provided via extensions to the standard .EQ/.EN macros. eqn usage itself is beyond the scope of this documentation, but is covered in the manpage eqn(1). You can also download a copy of Ted Harding’s A Guide to Typesetting Mathematics Using GNU eqn, which contains useful examples.

.EQ / .EN

Macro: EQ
Arguments:
  [ -L | -C | -I <ident> ]
(unit of measure required)
  [ ADJUST +|-<vertical adjustment>]
(unit of measure required)
  [ CAPTION "<caption>" ]
  [ LABEL "<label>" ]
  [ SHIFT_LABEL +|-<vertical adjustment> ]
  [ SHORT_CAPTION "<short caption>" ]
Macro: EN [ CONTINUED | CONT | ... ]

Note: Version 2.0-c change
2.0-c introduces revisions to EQ, including the addition of a dash (-) to the positioning arguments (-L, -C, and -I) and the removal of a default value for -I. Other changes include passing all options to .EQ (including the label) such that .EN takes only a single, optional argument saying whether the equation is to be continued at the next invocation of .EQ. Please read this section carefully if you have documents containing equations as they may need to be updated.

IMPORTANT: All arguments to EQ must appear on the same line as .EQ. Do not attempt to break them up with the “line-continued” backslash. You may want to set your text editor to “wrap” mode in order to see all your arguments. This annoyance stems from the preprocessor mechanism itself, not groff or mom.

The .EQ macro

Equations to be set with eqn begin with .EQ, followed by eqn code. Equations are centered by default, but may be set flush left or indented from the left margin if -L or -I are passed as arguments to .EQ.

'ADJUST'

ADJUST lets you raise (+) or lower (-) an equation within the space allotted for it by the amount you specify. This is useful for achieving good optical centering between surrounding blocks of type. A unit of measure is required.

'NO_SHIM'

NO_SHIM instructs mom not to apply shimming after the equation, which she does by default. Shimming ensures that running text after the equation falls properly on the page’s baseline grid, but usually results in slightly unequal spacing above and below, which must be corrected with the ADJUST argument. Mom’s default shimming is generally a good idea since it ensures properly aligned bottom margins for running text, however if you have several equations on the page, there may be visible differences in the spacing beneath them. NO_SHIM corrects the problem, but will result in running text that does not completely fill the page unless shimming is applied manually elsewhere on the same page.

'CAPTION'

CAPTION allows you to give the equation a caption. Equation captions always appear beneath the equation.

'SHORT_CAPTION'

SHORT_CAPTION allows you to trim long captions for inclusion in the List of Equations. The text you supply, surrounded by double-quotes, is what will appear in the List.

'LABEL'

LABEL, if given, appears on the same baseline as the last line of the equation, flush with the left or right margin, depending on the equation’s horizontal position. The text you supply, surrounded by double-quotes, is how the equation is labelled in both the document proper and the List of Equations. Mom provides an auto-labelling facility for equations (see AUTOLABEL), which, if enabled, overrides the LABEL argument.

'SHIFT_LABEL'

SHIFT_LABEL allows you to raise (-) or lower (+) the equation label. It’s primary use is to center equation labels vertically on the equation rather than flush with the last line. Assuming a three-line equation, .EQ SHIFT_LABEL -1v would raise the label by one line, thus centering it vertically on the equation.

The .EN macro

A block of eqn code is terminated with .EN.

If an equation needs to span multiple lines, possibly aligned with eqn’s 'mark' and 'lineup' directives, separate invocations of .EQ/.EN are required for each line, and the optional argument, CONTINUED (or CONT, or ... [three dots, an ellipsis]), must be passed to .EN.

If -L or -I is given to the first .EQ of a multi-line equation, they remain in effect until the final .EN, which does not have the CONTINUED argument.

Mom does not treat equations as floats, therefore it is possible to begin an equation on one page and terminate it on the next. If you wish to keep all lines of an equation together, you must wrap the equation, including all invocations of .EQ/.EN, inside a float.


refer support

refer support is covered in the section Bibliographies and references.


Captions and labels

Mom includes facilities for adding captions and labels to figures, tables, equations, and pdf images, including auto-labelling. If Lists of Figures, Tables, and Equations are desired, captions (if any) and labels (if any) are collected and output in the Lists with the appropriate page number.

The distinction between a caption and a label is that labels are identifiers, e.g. “Fig. 1” or “Table 3”, while captions are descriptive or informative. For most types of writing, it is usual to provide both.

By default, mom sets captions above figures (i.e. pic output and pdf images) and tables. This behaviour may be modified with the macro CAPTION_AFTER_LABEL. Equations always have their captions set underneath. All aspects of the text style for captions may be set with the macro, CAPTIONS.

Labels for tables are set underneath the table unless the MLA macro has been invoked, in which case the label and caption appear above the table, per MLA style, and the source for the table, if any, appears underneath. Labels for figures are set underneath. Equation labels, by default, are set on the same baseline as the last line of the equation. Like captions, all aspects of text style for labels may be established with a single macro, LABELS. Furthermore, mom can autolabel figures, tables, and equations, with or without a prefixed chapter number.

Autolabel

Macro: AUTOLABEL_EQUATIONS
Macro: AUTOLABEL_IMAGES
Macro: AUTOLABEL_PIC
Macro: AUTOLABEL_TABLES
Arguments:
[ PREFIX "<string>"] [ SUFFIX "<string>"] [ PREFIX_CHAPTER [ <n> ] ]

AUTOLABEL_<type> takes care of labelling <type> by identifying each with a separate, incrementing numeric scheme, which is also collected for output in Lists of Figures, Equations, and Tables. By default, the label numbers are prefixed, and, in the case of equations, suffixed, with strings such that they appear for tables as “Table <n>”, for pic diagrams and pdf images as “Fig. <n>”, and for equations as “(<n>)”.

Use PREFIX <"string"> to change what comes before the automatic numbering. For example, if you are including musical excerpts in your document, MLA style requires that they be labelled “Ex. <n>”. Since musical excerpts are likely to be scanned images (in pdf format, don’t forget), you have to change the prefix string for pdf images:
.AUTOLABEL_IMAGES PREFIX "Ex. " If you need a suffix after the automatic numbering, use SUFFIX <"string">, like this:
.AUTOLABEL_IMAGES PREFIX "(Fig. " SUFFIX ")" Note that the double-quotes around the single-character SUFFIX string are optional.

Prefixing chapter numbers

If you would like mom to prefix chapter numbers to the label, pass AUTOLABEL_<type> the argument PREFIX_CHAPTER.

If you have not given mom a CHAPTER <n> prior to invoking AUTOLABEL_<type> PREFIX_CHAPTER, you must give the chapter number after PREFIX_CHAPTER. Once done, all subsequent chapters or collated document sections will increment the chapter number by one automatically. Failure to provide a chapter number after PREFIX_CHAPTER when it is required will result in mom aborting with a reminder to do so.

Captions after labels

Macro: CAPTION_AFTER_LABEL IMG | PIC | TBL | ALL [ <anything> ]

By default, mom sets captions above figures (pic output and pdf images) and tables; labels are always underneath.

.CAPTION_AFTER_LABEL, with one of the required arguments, instructs mom to attach captions directly to the appropriate labels, beginning on the same line. Any argument after the first disables this behaviour, restoring caption placement to mom’s default. For example,
.CAPTION_AFTER_LABEL ALL would enable captions after labels globally, while a subsequent
.CAPTION_AFTER_LABEL IMG OFF would disable captions after labels for pdf images only. OFF can be anything you like (X, NO, etc).

If MLA is enabled, there's no need to invoke CAPTION_AFTER_LABEL as this is implied.

Note: A separate invocation of .CAPTION_AFTER_LABEL is required for each one of the required first arguments. You cannot, for example, do
.CAPTION_AFTER_LABEL IMG TBL Rather, you must do
.CAPTION_AFTER_LABEL IMG .CAPTION_AFTER_LABEL TBL

MLA-style captioning and labelling

Macro: MLA [ <anything> ]

Modern Language Association style dictates that captions should always go after labels. Furthermore, labels and captions for tables should go above the tables, with the source for the table, if any, underneath.

Invoking .MLA by itself takes care of these details. If you need to disable MLA-style captioning and labelling mid-document, .MLA OFF does the trick. OFF can be anything you like (X, NO, etc).

Style parameters for captions, labels and sources

Macro: CAPTIONS EQN | IMG | PIC | TBL | ALL
Macro: LABELS EQN | IMG | PIC | TBL | ALL
Macro: SOURCES TBL
Style arguments:
  FAMILY <family> \
  FONT <font> \
  SIZE "+|-<size>" \
  AUTOLEAD "<value>" \
  COLOR "<color>" \
  QUAD LEFT | CENTER | RIGHT [ ON_LL ] \
  ADJUST +|-<vertical adjustment>

Note: Arguments may be broken into several lines using the “line-continued” backslash (\), as shown above.

Additional note: Mom’s default style for labels, captions, and sources is the same as the style used for running text, with two exceptions: labels are set in bold, except for eqn which is roman medium, and the autolead value for all three is “2”, effectively tightening the lead. Furthermore, they are quadded left (except eqn, which is quadded right.)

With the exception of ADJUST and QUAD (which requires a bit of explanation), the style arguments to CAPTIONS, LABELS, and SOURCES (which is only available for tables) behave identically to the arguments to control macros.

The first, required argument after CAPTIONS, LABELS, and SOURCES indicates the preprocessor type for which you are setting the parameters. (For convenience PDF_IMAGE—argument IMG—is here treated as a preprocessor.) An argument of ALL sets a unified style for every preprocessor. If the ALL argument is given, arguments to subsequent invocations of CAPTIONS, LABELS, or SOURCES overwrite only the explicitly named style parameters.

QUAD — quadding of labels, captions, and sources

By default, figures (pic output and pdf images) and tables have their captions and labels set quad left. Sources (for tables) are also set quad left. Equations have their labels set quad right, and their captions centered. Regardless of the quad direction, captions, labels, and sources are quadded over the width of figures and tables unless you pass the optional ON_LL argument to QUAD <direction>.

Equations behave differently. By default, equation labels are set flush right with the page’s right margin regardless of equation positioning, which is, again by default, centered. If the equation is positioned left, the label will appear at the right margin regardless of the direction you give to QUAD. If the equation is indented with the -I <indent> option, a quad direction of LEFT is observed, but may overprint the last line of the equation. Note that there is no CENTER option for equation labels, and that captions are always quadded over the full line length.

ADJUST

The ADJUST argument allows you to add(+) or subtract (-) vertical space between labels and captions and the output to which they are attached. The argument requires a unit of measure. For example, if you find that table labels are a bit too close to the table itself,
.LABELS TBL ADJUST +3p would put three extra points of space between the bottoms of tables and the labels that appear beneath them.

Lists of Figures, Tables, and Equations

Besides a Table of Contents, mom can generate Lists of Figures, Tables, and Equations. Labels and captions are collected and concatenated, and output in lists with the appropriate page number, just like a Table of Contents. Including such lists in a document is as simple as adding whichever you need of
.LIST_OF_FIGURES .LIST_OF_EQUATIONS .LIST_OF_TABLES to the end of your input file.

Also like the Table of Contents, entries in the Lists' output are clickable PDF links when a document is viewed at the screen.

Placement of Lists

Lists normally appear after the Table of Contents, and continue the page numbering scheme used for it. By default, the Table of Contents begins on roman-numeral page “i”.

If you are using mom’s AUTO_RELOCATE_TOC feature, you have two options for placement of the Lists within the document. If you want the Lists shifted to the top of the document along with the Table of Contents, invoke the Lists macros after .TOC. If you prefer to have the Lists at the end of the document, invoke the Lists macros before .TOC.

Lists shifted with the Table of Contents do not appear in the Table of Contents itself, but do appear as clickable links in the PDF outline typically available in the left panel of most PDF viewers. Lists that are not shifted with the Table of Contents appear in both the Table of Contents itself and the PDF outline.

Macros to generate Lists

Macro: LIST_OF_EQUATIONS
Macro: LIST_OF_FIGURES
Macro: LIST_OF_TABLES
Arguments:
  [ TITLE_STRING "<string>" ] [ START_PAGENUM <page number> ]

The first optional argument to the LIST_OF_<type> macros allows you to change the title that appears at the top of the page. This is useful not only for internationalization, or to meet the requirements of various style guides, but is also useful for, say, documents containing musical examples, which, per MLA-style, should be labelled “Example ” or “Ex. ”. When it comes time to output the List of Figures (to which musical examples, usually scanned pdf images, belong),
LIST_OF_FIGURES TITLE_STRING "List of Examples" ensures that the title of the List is correct.

The second optional argument allows you to give a starting page number for a list in cases where mom’s pagination scheme does not provide the List with the starting page number you want.

Formatting and style parameters for Lists

Like the Table of Contents, nearly every aspect of Lists can be designed independently of a document’s overall style. By default, Lists follow the formatting and style parameters of the Table of Contents, both mom’s defaults and any changes you may have made to the Table of Contents.

If you wish to make changes to any aspect of Lists formatting or styling, the macro LISTS_STYLE provides all the tools necessary. It is unlikely that you’ll want the formatting of the various list types to differ one from the other, so LISTS_STYLE applies to all Lists. In the event that you do need to change some aspect of the formatting for different list types, simply invoke LISTS_STYLE immediately prior to each list whose formatting needs to be changed.

Lists style

Macro: LISTS_STYLE
Arguments:
  FAMILY <family> \
  FONT <font> \
  PT_SIZE <size> \
  LEAD <leading> \
  TITLE_FAMILY <family> \
  TITLE_FONT <font> \
  TITLE_SIZE +|-<size> \
  TITLE_QUAD LEFT | CENTER | RIGHT \
  TITLE_COLOR <color> \
  PN_FAMILY <family> \
  PN_FONT <font> \
  PN_SIZE +|-<size> \
  EQN_PN_PADDING <placeholders> \
  FIG_PN_PADDING <placeholders> \
  TBL_PN_PADDING <placeholders> \
  PAGENUM_STYLE DIGIT | ROMAN | roman | ALPHA | alpha \
  NO_PAGINATION

Note: Arguments may be broken into several lines using the “line-continued” backslash (\), as shown above.

FAMILY is the family for the entirety of Lists pages.

FONT is the font for the entirety of Lists pages.

PT_SIZE is the base point size for the entirety of Lists pages.

LEAD is the base leading for the entirety of Lists pages.

TITLE_FAMILY is the family for the Lists titles if you want it different from the family otherwise used for the Lists pages.

TITLE_FONT is the font for the Lists titles if you want it different from the font otherwise used for the Lists pages.

TITLE_SIZE tells mom by how much to increase (+) or decrease (-) the point size of the titles relative to the overall point size of Lists pages.

TITLE_QUAD tells mom how to position the title horizontally.

TITLE_COLOR sets the colour for the titles. The colour must be pre-initialized with NEWCOLOR or XCOLOR.

PN_FAMILY sets the family for entry pagenumbers.

PN_FONT sets the font for entry pagenumbers.

PN_SIZE tells mom by how much to increase (+) or decrease (-) the point size of entry pagenumbers relative to the overall point size of Lists pages.

EQN_PN_PADDING, FIG_PN_PADDING, and TBL_PN_PADDING tells mom how many placeholders to reserve for the entry pagenumbers in their respective Lists. If, for example, a document with both tables and figures runs to over a hundred pages, but there are no tables after page 99,
LISTS_STYLE FIG_PN_PADDING 3 LISTS_STYLE TBL_PN_PADDING 2 would prevent an unneeded, reserved placeholder from putting too much space between the leader and the entry pagenumber in the List of Tables.

The padding in effect, unless you change it, is whatever was set for the Tables of Contents; mom’s default is “3”.

PAGENUM_STYLE tells mom which pagination format to use for the page numbers of the Lists pages themselves. By default, since Lists observe what is in effect for the Table of Contents, the pagination format is “roman”. Please note that the starting page number for any of the Lists is given as an argument to the LISTS_0F_<type> macro.

NO_PAGINATION disables pagination of Lists pages.


Back to Table of Contents Top Next: Page headers/footers, pagination