Next: Processing, previewing and printing Up: Preparing Printed Output Previous: Including plt figures in a LATEX document

Margins, cropping, and bounding boxes

Every PostScript file included in a LATEX document must have a defined bounding box. Normally, the bounding box is defined using a structured comment at the beginning of the PostScript file. For example, the PostScript source for the figures shown above begins like this:

%!PS-Adobe-3.0
%%BoundingBox: 90 252 540 684


In some cases, you may need to redefine the bounding box, either to adjust the amount of white space surrounding the figure or to crop your figure by selecting a clipping region. You may do so either by editing the PostScript file or in the LATEX source file. Any bounding box definitions in the LATEX source override those in the PostScript file. For details, see section 11.3, Merging Text and PostScript Graphics'', in The LATEX Companion, pp. 317-320.

An easy way to determine the correct bounding box is to view your figure using ghostview. Move the mouse pointer to the lower left corner of the figure and note the coordinates (displayed by ghostview immediately above the File button); these are the first two numbers in the BoundingBox line. Now move the mouse pointer to the upper right corner of the figure; the coordinates displayed are the last two numbers in the BoundingBox line.

Using this technique, we can find a bounding box for the upper left panel in fig.ps. To plot that panel only, as shown here

we can use the commands
\begin{center}
\epsfig{file=fig,height=6cm,bbllx=100,bblly=425,bburx=300,
bbury=625,clip=}
\end{center}

(This plot does not float'' within the text, since it was not put into a figure environment; rather, it appears in the same place in the output as in the LATEX source file.) Note that the ='' is required in the clip= option, although no value follows the =''. Also note that the clip= option is ignored by pdfLATEX (see this figure in the PDF version of this book).

In some cases, plt does not respect its own window definitions and may plot elements that fall outside of the bounding box. These elements will appear in the LATEX output unless you choose to suppress them using the clip= option. Such elements are usually close to the bounding box, and no special treatment is required.

Next: Processing, previewing and printing Up: Preparing Printed Output Previous: Including plt figures in a LATEX document
George B. Moody (george@mit.edu)
2005-04-26