12.04.2015 Views

Using Imported Graphics in LaTeX and pdfLaTeX - Mirror

Using Imported Graphics in LaTeX and pdfLaTeX - Mirror

Using Imported Graphics in LaTeX and pdfLaTeX - Mirror

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Then use the comm<strong>and</strong> \usebox{\mygraphic} wherever you want the graphic.<br />

(The graphics can be scaled by plac<strong>in</strong>g the \usebox comm<strong>and</strong> <strong>in</strong>side a \scalebox<br />

or \resizebox comm<strong>and</strong>.)<br />

3. When the eps file conta<strong>in</strong>s vector graphics (as opposed to bitmapped graphics),<br />

it is possible to write a PostScript comm<strong>and</strong> which draws the graphics 23 . The<br />

graphic can then be <strong>in</strong>cluded by issu<strong>in</strong>g the PostScript comm<strong>and</strong> wherever the<br />

graphic is needed. Section 16.1 on Page 50 describes this procedure.<br />

S<strong>in</strong>ce the f<strong>in</strong>al PostScript file <strong>in</strong>cludes the graphics comm<strong>and</strong>s only once, the<br />

f<strong>in</strong>al PostScript file is much smaller. Note that s<strong>in</strong>ce the graphics comm<strong>and</strong>s<br />

are stored <strong>in</strong> pr<strong>in</strong>ter memory while the f<strong>in</strong>al PostScript file is be<strong>in</strong>g pr<strong>in</strong>ted,<br />

this method may cause the pr<strong>in</strong>ter to run out of memory <strong>and</strong> not pr<strong>in</strong>t the<br />

document.<br />

Although this method results <strong>in</strong> a small f<strong>in</strong>al PostScript file, it still requires<br />

L A TEX to f<strong>in</strong>d <strong>and</strong> read the file conta<strong>in</strong><strong>in</strong>g the PostScript comm<strong>and</strong>s.<br />

4. Like the previous method, def<strong>in</strong>e a PostScript comm<strong>and</strong> which draws the graphics,<br />

but <strong>in</strong>clude this comm<strong>and</strong> <strong>in</strong> a L A TEX box. This results <strong>in</strong> a small f<strong>in</strong>al<br />

PostScript file <strong>and</strong> only requires L A TEX to f<strong>in</strong>d <strong>and</strong> read the file once.<br />

16.1 Def<strong>in</strong><strong>in</strong>g a PostScript Comm<strong>and</strong><br />

This section describes how to created a PostScript comm<strong>and</strong> which draws the graphics<br />

from an eps file conta<strong>in</strong><strong>in</strong>g vector graphics. This procedure does not work if the<br />

eps file conta<strong>in</strong>s bitmapped graphics.<br />

To convert the eps graphics <strong>in</strong>to a PostScript comm<strong>and</strong>, the eps file must be<br />

broken <strong>in</strong>to two files, one which def<strong>in</strong>es the PostScript dictionary <strong>and</strong> the graphics<br />

comm<strong>and</strong>s, <strong>and</strong> another which <strong>in</strong>cludes the header <strong>in</strong>formation <strong>and</strong> the uses the<br />

previously-def<strong>in</strong>ed PostScript comm<strong>and</strong>. For example, an eps file created by Xfig<br />

has the form<br />

%!PS-Adobe-2.0 EPSF-2.0<br />

%%Title: /tmp/xfig-fig017255<br />

%%Creator: fig2dev Version 2.1.8 Patchlevel 0<br />

%%CreationDate: Sun Sep 3 15:36:01 1995<br />

%%Orientation: Portrait<br />

%%Bound<strong>in</strong>gBox: 0 0 369 255<br />

%%Pages: 0<br />

%%EndComments<br />

/$F2psDict 200 dict def<br />

$F2psDict beg<strong>in</strong><br />

...<br />

%%EndProlog<br />

$F2psBeg<strong>in</strong><br />

...<br />

$F2psEnd<br />

23 While it is possible to construct a PostScript comm<strong>and</strong> which draws vector graphics, it turns out<br />

to be a “feature” of eps that is impossible to construct such a comm<strong>and</strong> for bitmapped graphics.<br />

Bitmapped graphics are usually converted to eps by hav<strong>in</strong>g the image (or colorimage) PostScript<br />

operators read the current file as data. It is not possible to put such constructs <strong>in</strong>to a PostScript<br />

procedure. It is possible to change the eps file so that it passes the image data as PostScript str<strong>in</strong>gs<br />

rather than read<strong>in</strong>g the file, but this is difficult to automate <strong>and</strong> generally requires a fair amount of<br />

h<strong>and</strong> edit<strong>in</strong>g of the PostScript.<br />

S<strong>in</strong>ce most people are not PostScript experts, h<strong>and</strong>-edit<strong>in</strong>g the PostScript is generally not an<br />

option. If the graphic can be described by PostScript vector primitives, it may be possible to use<br />

the kvec program (see page 19) to successfully convert the graphic to vector format.<br />

50

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!