Back to Table of Contents | Next: Page headers/footers, pagination |
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.
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.
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
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
• <indent>, <width>, <height> and <vertical adjustment> require a unit of measure
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 optional SCALE argument 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.
The final optional argument is the vertical adjustment to apply to the image. A plus value raises the image within the space allotted for it; a negative value lowers it. The value must have a unit of measure appended.
Remember that mom files with embedded PDF images must be processed
with
pdfmom doc.mom > doc.pdf
Note: Mom automatically applies shimming after PDF_IMAGE. See SHIM for a discussion of shimming, and how to disable it.
Additional note: Mom treats single, discrete images inserted into a document with PDF_IMAGE somewhat like 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, and a message is printed to stderr advising you where the deferment has taken place.
However, if more than one image does not fit on the output page, mom defers only the first; the remainder are silently ignored. Therefore, if you insert several images close together in the text, it is highly recommended that you wrap the images in floats, which do not have this restriction.
PSPIC is not actually part of mom, but rather a macro included with every groff installation. Although its arguments are identical to PDF_IMAGE (except for SCALE and ADJUST, which are missing), its behaviour is slightly different.
man groff_tmac contains the documentation for PSPIC, but I’ll repeat it here with a few modifications for clarity.
<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.
Additionally, 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 invoking .PSPIC, I strongly recommend using the SHIM macro so that the bottom margin of running text falls where it should. Please note that with PDF_IMAGE, this is not necessary.
Remember that mom files with embedded EPS images must be processed
with
pdfmom -Tps doc.mom > doc.pdf
Mom documents can include tables generated with the groff pre-processor, tbl. tbl usage itself is beyond the scope of this documentation, but is covered in the manpage tbl(1). You can also download a copy of Tbl - A Program to Format Tables, which, in addition to providing a thorough introduction to tbl, contains some fine examples.
Tables formatted with tbl begin with the macro .TS (Table Sart) 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.
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.
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.
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 .TE. In either case, you will still likely want to adjust the spacing around with table with ALD or RLD. Tables inside floats are more easily adjusted with the ADJUST argument to FLOAT.
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 must be invoked before entering a tbl block. You may give as many or as few of its arguments as required, in any order.
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.
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
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
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.
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. If you place it immediately underneath your tbl formatting specifications, the last line of which always ends with a period (see tbl(1)), there will be no running header. If you place it under the first row of tbl data, the first row will form the header; under the second row, the first and second rows form the header, and so on.
tbl blocks must be terminated with .TE. Arguments to TE are optional. If “<caption>” is given, you may use as many or as few of the subsequent arguments as you wish, in any order.
If you wish a table to have a caption, or label, underneath, surround the caption in double-quotes after .TE, like this: .TE "Table 1"
If you would like to increase the space between the bottom of a table and its caption, enter the increase with a digit to which is appended a unit of measure: .TE "Table 1" 3p
By default, mom aligns captions with the left side of tables. If this is what you want, you may enter LEFT, or simply skip stating where you want the caption. If you would prefer centered or right placement, use CENTER or RIGHT.
By default, mom adds shimming underneath tables. This behaviour may be disabled with the NO_SHIM argument, which, moreover, can be used for tables without a caption, like this: .TE NO_SHIM
At present, mom has no integrated support or special features for the pic preprocessor, however pic may be used successfully within a mom document. Generally, it’s best to wrap pic blocks within a float (see below). If you want your pics centred, you must include -mpic in the options passed to pdfmom or groff.
At present, mom has no integrated support or special features for the eqn preprocessor, however eqn may be used successfully within a mom document. Generally, it’s best to wrap eqn blocks within a float (see below).
refer support is covered in the section Bibliographies and references.
Images and graphics (including those created with tbl and pic) 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 (tables, for example, generally need only appear near related text, not at a precise location), 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.
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. This usually results in a small amount of extra whitespace after the float. The ADJUST argument to FLOAT allows you to fine-tune the vertical centering.
If you’d like more space around a float, you must add it manually, for example with ALD or SPACE.
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 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.
The 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.
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.
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.
Back to Table of Contents | Top | Next: Page headers/footers, pagination |