1 <?xml version="1.0" encoding="utf-8"?>
3 This file is part of groff, the GNU roff type-setting system.
5 Copyright (C) 2004, 2005, 2006, 2009, 2010,
6 2011, 2012, 2013 Free Software Foundation, Inc.
7 Written by Peter Schaffter (peter@schaffter.ca).
9 Permission is granted to copy, distribute and/or modify this document
10 under the terms of the GNU Free Documentation License, Version 1.3 or
11 any later version published by the Free Software Foundation; with the
12 Invariant Sections being this comment section, with no Front-Cover
13 Texts, and with no Back-Cover Texts.
15 A copy of the Free Documentation License is included as a file called
16 FDL in the main directory of the groff source package.
19 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
20 <html xmlns="http://www.w3.org/1999/xhtml">
23 <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
24 <title>Mom -- Graphics and floats</title>
25 <link rel="stylesheet" type="text/css" href="stylesheet.css" />
28 <body style="background-color: #f5faff;">
30 <!-- ==================================================================== -->
32 <div id="top" class="page">
34 <!-- Navigation links -->
35 <table style="width: 100%;">
37 <td><a href="toc.html">Back to Table of Contents</a></td>
38 <td style="text-align: right;"><a href="headfootpage.html#top">Next: Page headers/footers, pagination</a></td>
42 <h1 class="docs">Graphics and floats</h1>
44 <div style="width: 55%; margin: auto;">
45 <ul class="no-enumerator" style="margin-left: -1em;">
46 <li><a href="#images-intro">Introduction to inserting images and graphics</a>
47 <li><a href="#converting">Image conversion and file processing</a>
48 <ul style="margin-left: -.5em; list-style-type: disc;">
49 <li><a href="#pdf">PDF</a></li>
50 <li><a href="#eps">EPS</a></li>
52 <li><a href="#pdf-image">The PDF_IMAGE macro</a></li>
53 <li><a href="#pspic">The PSPIC macro</a></li>
54 <li><a href="#floats-intro">Introduction to floats</a></li>
55 <li><a href="#float">The FLOAT macro</a>
56 <ul style="margin-left: -.5em; list-style-type: disc;">
57 <li><a href="#tbl-with-float">Using tbl with FLOAT</a></li>
62 <div class="rule-medium"><hr/></div>
64 <h2 id="images-intro" class="docs">Introduction to inserting images and graphics</h2>
67 In order to include images in mom documents, the images must be in
68 either PDF (.pdf) or EPS (.eps) format. Each format requires its own
69 macro, but both take the same arguments, and in the same order.
73 Please note that there are differences in the way the files
74 containing PDF and EPS images must be processed, hence documents may
78 <h3 id=converting class="docs">Image conversion and file processing</h3>
81 When your image files are not in PDF or EPS format—jpgs,
82 for example—you must convert them before including them in
83 a mom document. Any utility for converting images may used. The
84 ImageMagick suite of programmes, present on most GNU/Linux
85 systems, contains <b>convert</b>, which is simple and effective.
88 <h4 id="pdf" class="docs">PDF</h4>
91 Assuming a jpg image, conversion to PDF is done like this:
93 <span class="pre-in-pp">
94 convert <image>.jpg <image>.pdf
96 Any image type supported by <b>convert</b> may be converted this
101 Mom files containing PDF images must be processed using
102 groff’s pdf driver. Use of
103 <a href="using.html#pdfmom" style="font-weight: bold">pdfmom</a>
104 is strongly recommended, which natively invokes the pdf driver.
106 <span class="pre-in-pp">
107 pdfmom doc.mom > doc.pdf
111 <h4 id="eps" class="docs">EPS</h4>
114 Assuming a jpg image, conversion to EPS is done like this:
116 <span class="pre-in-pp">
117 convert <image>.jpg <image>.eps
119 Any image type supported by <b>convert</b> may be converted this
120 way. There have been reports of trouble with PostScript level 2
121 images, so don’t save your images in this format.
125 Mom files containing EPS images must be processed using
126 groff’s postscript driver. Use of
127 <a href="using.html#pdfmom" style="font-weight: bold">pdfmom</a>,
128 which can be told to use the postscript driver, is strongly
131 <span class="pre-in-pp">
132 pdfmom -Tps doc.mom > doc.pdf
138 <div class="macro-id-overline">
139 <h3 id="pdf-image" class= "macro-id">PDF_IMAGE</h3>
142 <div class="box-macro-args">
143 Macro: <b>PDF_IMAGE</b> <kbd class="macro-args">[ -L | -C | -R | -I <indent> ] \
145 <pdf image> <width> <height> \
147 [ SCALE <factor> ] [ ADJUST +|-<vertical adjustment> ]</kbd>
150 • <span style="font-style: normal">
151 <kbd><indent></kbd>,
152 <kbd><width></kbd>,
153 <kbd><height></kbd></span>
155 <span style="font-style: normal">
156 <kbd><vertical adjustment></kbd></span>
158 <a href="definitions.html#unitofmeasure">unit of measure</a>
163 <a href="#pspic">PSPIC</a>,
164 which it resembles, PDF_IMAGE requires that the pdf image’s
165 dimensions (the bounding box,
166 <a href="#bounding-box">see below</a>)
167 be supplied each time it’s called.
171 The first optional argument tells mom how to align the image
172 horizontally, with <kbd>-L</kbd>, <kbd>-C</kbd>, and <kbd>-R</kbd>
173 standing for left, centre and right respectively. If you need more
174 precise placement, the <kbd>-I</kbd> argument allows you to give an
175 indent from the left margin. Thus, to indent a PDF image 6
176 <a href="definitions.html#picaspoints">picas</a>
179 <span class="pre-in-pp">
180 .PDF_IMAGE -I 6P <remaining arguments>
182 If you omit the first argument, the image will be centred.
186 <kbd><pdf image></kbd> must be in PDF format, with a .pdf
187 extension. If it is not, mom will abort with a message. See <a
188 href="#pdf">here</a> for instructions on converting image formats to
192 <p id="bounding-box">
193 <kbd><width></kbd> and <kbd><height></kbd> are the
194 dimensions of the image’s bounding box. The most reliable way
195 of getting the bounding box is with the utility, <strong>pdfinfo</strong>:
197 <span class="pre-in-pp">
198 pdfinfo <image.pdf> | grep "Page *size"
200 This will spit out a line that looks like this:
202 <span class="pre-in-pp">
203 Page size: width x height pts
206 <a href="definitions.html#picaspoints">points</a>,
207 therefore the unit of measure appended to <kbd><width></kbd>
208 and <kbd><height></kbd> must be <kbd>p</kbd>.
212 The optional <kbd>SCALE</kbd> argument allows you to scale the image
213 by <kbd><factor></kbd>. The factor is a percentage of the
214 image’s original dimensions, thus
216 <span class="pre-in-pp">
219 scales the image to 50 percent of its original size. No percent
220 sign or unit of measure should be appended.
224 The final optional argument is the vertical adjustment to apply to
225 the image. A plus value raises the image
226 <span style="font-style: italic">within the space allotted for it</span>;
227 a negative value lowers it. The value must have a unit of measure
232 Remember that mom files with embedded PDF images must be processed
235 <span class="pre-in-pp">
236 pdfmom doc.mom > doc.pdf
240 <div class="box-tip">
242 <span class="note">Note:</span>
243 Mom automatically applies shimming after PDF_IMAGE. See
244 <a href="docprocessing.html#shim">SHIM</a>
245 for a discussion of shimming, and how to disable it.
249 <span class="note">Additional note:</span>
250 Mom treats single, discrete images inserted into a document with
251 PDF_IMAGE somewhat like
252 <a href="#floats-intro">floats</a>,
253 which is to say that if an image doesn’t fit on the output
254 page, she will defer it to the top of the next page while continuing
256 <a href="definitions.html#running">running text</a>.
257 <kbd>ADJUST</kbd> is ignored whenever an image is deferred, and a
258 message is printed to stderr advising you where the deferment has
262 <p class="tip-bottom">
263 However, if more than one image does not fit on the output page,
264 mom defers only the first; the remainder are silently ignored.
265 Therefore, if you insert several images close together in the text,
266 it is highly recommended that you wrap the images in floats, which
267 do not have this restriction.
273 <div class="macro-id-overline">
274 <h3 id="pspic" class= "macro-id">PSPIC</h3>
277 <div class="box-macro-args">
278 Macro: <b>PSPIC</b> <kbd class="macro-args">[ -L | -R | -I <n> ] <file> [ width [ height ] ]</kbd>
282 PSPIC is not actually part of mom, but rather a macro included with
283 every groff installation. Although its arguments are identical to
284 PDF_IMAGE (except for <kbd>SCALE</kbd> and <kbd>ADJUST</kbd>, which
285 are missing), its behaviour is slightly different.
289 <kbd>man groff_tmac</kbd> contains the documentation for PSPIC, but
290 I’ll repeat it here with a few modifications for clarity.
293 <div class="examples-container">
294 <h3 id="groff-tmac" class="docs" style="margin-top: .5em;">From <span style="text-transform: none">groff_tmac</span></h3>
295 <p style="margin-top: .5em; margin-bottom: .5em;">
296 <kbd><file></kbd> is the name of the file containing the
297 image; <kbd>width</kbd> and <kbd>height</kbd> give the desired
298 width and height of the image as you wish it to appear within the
299 document. The width and height arguments may have
300 <a href="definitions.html#unitofmeasure">units of measure</a>
301 attached; the default unit of measure is
302 <kbd>i</kbd>. PSPIC will scale the graphic
303 uniformly in the x and y directions so that it is no more than
304 <kbd>width</kbd> wide and <kbd>height</kbd> high. By default, the
305 graphic will be horizontally centred. The <kbd>-L</kbd> and
306 <kbd>-R</kbd> options cause the graphic to be left-aligned and
307 right-aligned, respectively. The <kbd>-I</kbd> option causes
308 the graphic to be indented by <kbd><n></kbd>; the default unit of
309 measure is <kbd>m</kbd>
310 (<a href="definitions.html#em">ems</a>).
315 It is not necessary to pass PSPIC the
316 <kbd><width></kbd> and <kbd><height></kbd> arguments unless
317 you are scaling the image, in which case you will most likely need
318 the original dimensions of the EPS image’s bounding box.
319 These can be found with
320 <span class="pre-in-pp">
321 gs -q -dBATCH -dNOPAUSE -sDEVICE=bbox <image file>.pdf 2>&1 \
322 | grep "%%BoundingBox" | cut -d " " -f4,5
324 The two digits returned are in
325 <a href="definitions.html#picaspoints">points</a>,
327 <a href="definitions.html#unitofmeasure">unit of measure</a>
328 <kbd>p</kbd> must be appended to them.
332 Because PSPIC lacks the <kbd>ADJUST</kbd> option offered by
333 <a href="#pdf-image">PDF_IMAGE</a>
334 a certain amount of manual tweaking of the vertical placement of the
335 image will probably be required, typically by using the
336 <a href="typesetting.html#ald">ALD</a>
338 <a href="typesetting.html#rld">RLD</a>
343 Additionally, EPS images inserted into
344 <a href="definitions.html#running">running text</a>
345 will almost certainly disrupt the baseline placement of running
346 text. In order to get mom back on track after
347 invoking <kbd>.PSPIC</kbd>, I strongly recommend using the
348 <a href="docprocessing.html#shim">SHIM</a>
349 macro so that the bottom margin of running text falls where it
350 should. Please note that with PDF_IMAGE, this is not necessary.
354 Remember that mom files with embedded EPS images must be processed
357 <span class="pre-in-pp">
358 pdfmom -Tps doc.mom > doc.pdf
362 <div class="rule-medium"><hr/></div>
364 <h2 id="floats-intro" class="docs">Introduction to floats</h2>
367 Images and graphics (including those created with
368 <strong>tbl</strong> and <strong>pic</strong>) sometimes do not
369 fit on the output page of a PDF or PostScript document at the
370 place they’re inserted in the input file. It’s
371 necessary, therefore, to defer them to the next page while carrying
373 <a href="definitions.html#running">running text</a>.
377 Whenever you need this functionality (tables, for example, generally
378 need only appear near related text, not at a precise location), mom
379 provides the FLOAT macro.
383 Floats are usually used for images and graphics, but can contain
384 anything you like, including text. Whatever’s in the
385 float will be kept together as a block, output immediately if
386 there’s room, or deferred to the top of the next output page
387 when there isn’t; running text continues to the bottom of the
388 previous page without interruption.
392 In the case of a float that doesn’t fit being followed by
393 one that does, the second is output in position and the first is
394 deferred. In the case of two or more that don’t fit, they are
395 output in order on the next page.
399 A key distinction between a float and a
400 <a href="docelement.html#quote">QUOTE</a>
402 <a href="docelement.html#blockquote">BLOCKQUOTE</a>
403 is that while a float keeps everything together and defers output if
404 necessary, quotes and blockquotes are output immediately, and may
405 start on one page and finish on the next.
409 Floats always deposit a break before they begin, which means the
410 line beforehand will not be
411 <a href="definitions.html#filled">filled</a>.
412 Floats, therefore, cannot be inserted in the middle of a paragraph
413 without studying the output file and determining where to break or
414 <a href="typesetting.html#spread">spread</a>
415 the line before the float.
418 <p id="float-spacing">
419 Floats begin on the baseline immediately below the running text
420 preceding them. No additional whitespace surrounds them, above or
421 below. Running text below a float is, however,
422 <a href="docprocessing.html#shim">shimmed</a>,
423 unless shimming has been disabled with <kbd>.NO_SHIM</kbd>. This
424 usually results in a small amount of extra whitespace after the
425 float. The <kbd>ADJUST</kbd> argument to FLOAT allows you to
426 fine-tune the vertical centering.
430 If you’d like more space around a float, you must add it
431 manually, for example with
432 <a href="typesetting.html#ald">ALD</a>
434 <a href="typesetting.html#space">SPACE</a>.
439 <div class="macro-id-overline">
440 <h3 id="float" class= "macro-id">FLOAT</h3>
443 <div class="box-macro-args">
444 Macro: <b>FLOAT</b> <kbd class="macro-args">[ FORCE ] [ ADJUST +|-<amount> ] | <anything></kbd>
447 <div class="box-tip">
449 <span class="note">Note:</span>
450 FLOAT is intended for use with the document processing macros only.
454 <p style="margin-top: -.5em">
455 To begin a float, simply invoke <kbd>.FLOAT</kbd> and follow it with
456 whatever you want the float to contain. When you’re done,
457 invoke <kbd>.FLOAT OFF</kbd> (or <kbd>QUIT, END, X</kbd>, etc).
461 The optional <kbd>FORCE</kbd> argument instructs mom to output
462 the float exactly where it occurs in the input file. With
463 <kbd>FORCE</kbd>, mom immediately breaks to a new page to output
464 the float if it does not fit on the current page. While this is
465 somewhat contrary to the notion of floats (ie that running text
466 should continue to fill the page), there are circumstances where it
471 The <kbd>ADJUST</kbd> argument tells mom to raise
472 (<kbd>+</kbd>) or lower (<kbd>-</kbd>) the float <i>within the space
473 allotted to it</i> by the specified amount.
474 <kbd><amount></kbd> must have a
475 <a href="definitions.html#unitofmeasure">unit of measure</a>
476 appended. <kbd>ADJUST</kbd> gives you precise control over
477 the vertical centering of floats, allowing you to compensate for
478 unequal spacing that may result of from the automatic shimming of
479 floats (or the absence thereof). See
480 <a href="docprocessing.html#shim">SHIM</a>
481 for a discussion of automatic shimming.
485 <kbd>ADJUST</kbd> is ignored whenever a float is deferred to
489 <div class="box-tip">
491 <span class="note">Note:</span>
493 <a href="definitions.html#filled">no-fill mode</a>,
494 with each input line beginning at the left margin. If this is not
495 what you want, you must specify the preferred horizontal alignment
496 <i>within the float</i> (eg
497 <a href="typesetting.html#lrc">CENTER</a>
499 <a href="typesetting.html#lrc">RIGHT</a>).
502 <p class="tip-bottom">
503 Furthermore, if you want text
504 <a href="definitions.html#filled">filled</a>,
506 <a href="typesetting.html#quad"><kbd>.QUAD L|R|C</kbd></a>
508 <a href="typesetting.html#justify"><kbd>.JUSTIFY</kbd></a>—again,
513 <h4 id="tbl-with-float" class="docs">Using tbl with FLOAT</h4>
516 Unboxed tables created with <strong>tbl</strong> (see <kbd>man
517 tbl(1)</kbd>) may be put in a float with the usual start and end
518 macros, <kbd>.TS</kbd> and <kbd>.TE</kbd>.
522 Boxed tables don’t play nice with FLOAT, and require that you
523 pass the argument <kbd>BOXED</kbd> to <kbd>.TS</kbd>, otherwise mom
524 cannot guarantee the vertical spacing of the float will be
525 <a href="#float-spacing">as described</a>.
527 <span class="pre-in-pp">
534 You may put text (or anything else you like) above or below the
535 table; mom will ensure the float is spaced correctly.
538 <div class="rule-long"><hr/></div>
540 <!-- Navigation links -->
541 <table style="width: 100%; margin-top: 12px;">
543 <td style="width: 33%;"><a href="toc.html">Back to Table of Contents</a></td>
544 <td style="width: 20%; text-align: center;"><a href="#top">Top</a></td>
545 <td style="width: 46%; text-align: right;"><a href="headfootpage.html">Next: Page headers/footers, pagination</a></td>
551 <div class="bottom-spacer"><br/></div>
555 <!-- vim: fileencoding=utf-8: nomodified: -->