














































































Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Esta página não é visível na pré-visualização
Não perca as partes importantes!















































































Summary This document explains how to use imported graphics in LATEX 2ε documents. While reading the entire document is certainly worthwhile, most users should be able to locate the necessary information by browsing the table of contents on pages 3-5 or the index on pages 84-86. While LATEX can import virtually any graphics format, Encapsulated PostScript
are inserted by specifying \usepackage{graphicx} in the document’s preamble and then using the command \includegraphics{file.eps} Optionally, the graphic can be scaled to a specified height or width \includegraphics[height=4cm]{file.eps} \includegraphics[width=3in]{file.eps} Additionally, the angle option rotates the included graphic \includegraphics[angle=45]{file.eps} The \includegraphics command and the rest of the LATEX 2ε graphics bundle are covered in Part II of this document.
This document is divided into the following four parts Part I: Background Information This part provides historical information and describes basic LATEX terminol-
Part II: The LATEX Graphics Bundle This part describes the commands in the graphics bundle which import, scale, and rotate graphics. This part covers much of the information in the graphics bundle documentation (reference [5]). Part III: Using Graphics Inclusion Commands This part describes how the graphics bundle commands are used to import, rotate, and scale graphics. Three situations where graphics inclusion is mod- ified are also covered:
operating system which supports pipes (such as Unix). When using
Since neither LATEX nor dvips has any built-in decompression or graphics- conversion capabilities, that software must be provided by the user.
© c Copyright 1995-97 by Keith Reckdahl. All rights reserved. Reproduction and distribution is allowed under terms of the gnu General Public License.
mathematical expressions.
Where to Get this Document
This document is available in PostScript form as CTAN/info/epslatex.ps or in pdf form as CTAN/info/epslatex.pdf, where CTAN can be replaced by any of the following
England ftp://ftp.tex.ac.uk/tex-archive/ Deutschland ftp://ftp.dante.de/tex-archive/ Eastern U.S. ftp://tug2.cs.umb.edu/tex-archive/ Western U.S. ftp://ftp.cdrom.com/pub/tex/ctan/ Australia ftp://unsw.edu.au/tex-archive/ Japan ftp://ftp.riken.go.jp/pub/tex-archive/
Acknowledgements I thank David Carlisle for providing me with a great deal of assistance. I also thank Donald Arseneau, Robin Fairbairns, Jim Hafner, Piet van Oostrum, and other contrib- utors to the comp.text.tex newsgroup, whose posts provided much of the information for this document. Thanks also goes to the many people who provided me with valuable
Section 6 describes graphics-conversion programs while Section 13 describes how to use
2 LATEX Terminology
A box is any LATEX object (characters, graphics, etc.) that is treated as a unit (see [1, page 103]). Each box has a reference point on its left side. The box’s baseline is a horizontal line which passes through the reference point (see Figure 1). When LATEX forms lines of text, characters are placed left-to-right with their reference points aligned on a horizontal line called the current baseline, aligning the characters’ baselines with the current baseline. LATEX follows the same process for typesetting graphics or other objects; the reference point of each object is placed on the current baseline.
Baseline
depth
totalheight
height
width
Point
Reference
Figure 1: Sample LATEX Box
The size of each box is described by three lengths: height, depth, width. The height is the distance from the reference point to the top of the box. The depth is the distance from the reference point to the bottom of the box. The width is the width of the box. The totalheight is defined as the distance from the bottom of the box to the top of the box, or totalheight=height+depth.
Reference (^) depth
height
width
depth
width
height
Point
EPS Graphics EPS Graphics
EPS Graphics
width
Figure 2: Rotated LATEX Boxes
box in Figure 2), giving it zero depth and making its totalheight equal its height. The middle box in Figure 2 shows a rotated graphic where the height is not equal to the totalheight. The right box in Figure 2 shows a rotated graphic where the height is zero.
3 Encapsulated PostScript
The PostScript language can describe graphics and text. The PostScript language is
There are two main differences between PS and EPS files
file cannot perform page operations such as selecting a page size (such as letter or a4) or erasing the entire page with erasepage. The following PostScript operators are not
a3 a4 a5 banddevice clear cleardictstack copypage erasepage exitserver framedevice grestoreall initclip initgraphics initmatrix letter legal note prenderbands quit renderbands setdevice setglobal setpagedevice setpageparams setsccbatch setshared startjob stop
problems if not used properly.
nulldevice setcolortransfer setgstate sethalftone setmatrix setscreen settransfer undefinedfont
may cause strange problems like misplaced or invisible graphics. Since many of these operators do not affect the PostScript stack, these problems can often be eliminated by simply deleting the offending operator. Other cases may require more complicated hacking of the PostScript.
By convention, the first line of a PostScript file specifies the type of PostScript and is then followed by a series of comments called the header or preamble. (Like LATEX, PostScript’s comment character is %). One of these comments specifies the Bounding- Box. The BoundingBox line contains four integers
%!PS-Adobe-2.0 EPSF-2. %%Creator: gnuplot %%DocumentFonts: Times-Roman %%BoundingBox: 50 50 410 302 %%EndComments
ica 2.x include a utility called either printps.exe or rasterps which removes the non-standard extensions. On Unix versions of Mathematica 2.x, this can be done with the psfix utility. Reference your Mathematica documentation or contact Wolfram Research for more information.
FrameMaker PostScript produced by FrameMaker fails to follow Adobe’s specification for page independence. PostScript files produced by FrameMaker Version 4 and 5 can be respectively fixed using the scripts
ftp://ftp.irisa.fr/pub/FrameMaker/Filters/fixfm4-1.3.tar.gz ftp://ftp.irisa.fr/pub/FrameMaker/Filters/fixfm5-2.0.tar.gz
Correction scripts for FrameMaker Version 3 and 4 are also available from
ftp://ftp.frame.com/pub/techsup/framers/platform.ind/filters/fixfm3ps.sh ftp://ftp.frame.com/pub/techsup/framers/platform.ind/filters/fixfm4ps.sh
4 How EPS Files are Used by LATEX
space to reserve for the graphic.
This has the following ramifications
ics files. In these cases, the BoundingBox parameters must be specified in the graphics-insertion command (e.g., in the bb option of the \includegraphics com- mand) or stored in a non-compressed text file (see Section 13).
files whenever they are moved.
which the graphics will be inserted. (Some viewers, such as xdvi, use ghostscript
line buffer, the following error is displayed
Unable to read an entire line--bufsize=3000. Please ask a wizard to enlarge me.
of such an error
even though the application cannot interpret PostScript. Currently, relatively few TEX-related applications use such previews. If the binary preview is smaller than the line buffer, the \includegraphics com- mand skips over the preview (this is not the case with \psfig and other obsolete graphics commands). However, the overfull bufsize error occurs if the binary preview is larger than the line buffer. There are a couple work-arounds for this problem (a) If the preview won’t be used, the problem can be avoided by either deleting it with a text editor or by preventing the original graphics application from creating the preview.
are provided by the graphics-insertion command (e.g., the bb option to \includegraphics)
in binary mode from a Macintosh to a Unix machine, the Unix TEX doesn’t see any ^J end-of-line characters and thus thinks the entire file is one big line, overfilling the line buffer.
since the text mode transfer may corrupt the binary section. However, such binary transfer results in incorrect end-of-line characters, requiring the BoundingBox information be provided by the graphics-insertion command (e.g., the bb option to \includegraphics).
5 Obtaining GhostScript
Ghostscript is a PostScript interpreter which runs on most platforms and is distributed for free^2 by Aladdin Enterprises. This allows PostScript and EPS files to be displayed on the screen and printed to non-PostScript printers. Aladdin Ghostscript is avail- able from CTAN/support/ghostscript/aladdin/. It is also available directly from the Ghostscript home page http://www.cs.wisc.edu/~ghost/index.html
Ghostscript which makes the viewing of PostScript much easier.
(^2) Although Aladdin Ghostscript is distributed for free, it is not in the public domain. It is copyrighted and comes with certain limitations such as no commercial distribution. When versions of Aladdin Ghostscript become approximately one year old, Aladdin releases them as “GNU Ghostscript” whose use is governed by the less-restrictive GNU Public License.
Level-2 PostScript printer.
mands, this is difficult for most people. Instead, it is easier to use the following programs
into other vector formats (such as xfig’s .fig format).
The best reference for the graphics and graphicx packages is the graphics guide [5] or the LATEX Graphics Companion [4]. The coverage of the graphicx package in other LATEX references is sporadic: [2] covers both the graphics and graphicx packages, [1] only covers the graphics package and [3] describes neither.
where the options are listed in Tables 1, 2, and 3. Since \includegraphics does not end the current paragraph, it can place graphics within text such as or. The commands \documentclass{article} \usepackage{graphicx} \begin{document} \includegraphics{file.eps} \end{document} include the graphics from file.eps at its natural size. When the specified filename has no extension \includegraphics appends the ex- tensions in the \DeclareGraphicsExtensions extension list (See Section 9.1). Since the default extension list does not include the null extension, \includegraphics{file} does not read file unless the null extension is added to the extension list.
height The height of the graphics (in any of the accepted TEX units). totalheight The totalheight of the graphics, in any of the accepted TEX units. (Added 6/95) width The width of the graphics, in any of the accepted TEX units. scale Scale factor for the graphic. Specifying scale=2 makes the graphic twice as large as its natural size. angle Specifies the angle of rotation, in degrees, with a counter-clockwise (anti-clockwise) rotation being positive. origin The origin command specifies what point to use for the rotation origin. By default, the object is rotated about its reference point. (Added 12/95) The possible origin points are the same as those for the \rotatebox command in Section 8.3. For example, origin=c rotates the graphic about its center. bb Specifies BoundingBox parameters. For example bb=10 20 100 200 specifies that the BoundingBox has its lower-left corner at (10,20) and its upper-right corner at (100,200). Since \includegraphics automatically reads the BoundingBox parameters from the
Specifying The command Width (^) \includegraphics[width=3in]{file.eps} includes the graphics from file.eps scaled such that its width is 3 inches. Instead of making the width be a fixed length such as 3 inches, making the width of function of \textwidth or \em makes a document more portable. For example, the command
\includegraphics[width=\textwidth]{graphic.eps}
scales the included graphic such that it is as wide as the text. The command
\includegraphics[width=0.80\textwidth]{graphic.eps}
makes the included graphic 80% as wide as the text. When the calc package is used, the following command make the graphic width 2 inches less than the width of text
\includegraphics[width=\textwidth-2.0in]{graphic.eps}
(This requires graphicx version 12/95 or later).
8 Rotating and Scaling Objects
In addition to the \includegraphics command, the graphicx package includes 4 other
\scalebox{h-scale}[v-scale]{argument} \resizebox{width}{height}{argument} \resizebox*{width}{totalheight}{argument} \rotatebox[options]{angle}{argument}
Since the graphicx \includegraphics command supports rotating and scaling options such as angle and width, the commands in this section rarely need to be used with
\includegraphics[scale=2]{file.eps} \includegraphics[width=4in]{file.eps} \includegraphics[angle=45]{file.eps}
produce the same three graphics as
\scalebox{2}{\includegraphics{file.eps}} \resizebox{4in}{!}{\includegraphics{file.eps}} \rotatebox{45}{\includegraphics{file.eps}}
However, the first syntax is preferred because it is faster and produces more efficient PostScript.
The \scalebox command scales an object, making its width be h-scale times its original width and making the object’s height be v-scale times its original height. If v-scale is omitted, it defaults to h-scale, keeping the aspect ratio constant. Negative values reflect the object.
The \resizebox command resizes an object to a specified size. Specifying! as either height or width makes that length be such that the aspect ratio remains constant. For example, \resizebox{2in}{!}{argument} scales the argument to be 2 inches wide. The standard LATEX 2ε arguments \height, \width, \totalheight, \depth can be used to refer to the original size of argument. So \resizebox{2in}{\height}{argument} makes argument keep its same height but have a width of 2 inches. The \resizebox* command is identical to \resizebox, except the second argument specifies the totalheight of the object.
The \rotatebox command rotates an object by an angle given in degrees, with a counter-clockwise rotation being positive. By default, the object is rotated about its reference point. The \rotatebox options allow the point of rotation to be specified.
[lt]
[lc]
[lB]
[lb]
[ct]
[c]
[cB]
[cb]
[rt]
[rc]
[rB]
[rb]
Figure 3: Available Origin Points
The horizontal position of the origin points is specified by one of three letters: lcr (which stand for left, center, right, respectively), while the vertical position is specified by one of four letters: t,c,B,b (which stand for top, center, Baseline, bottom, respectively). For example [rb] specifies the bottom-right corner [lt] specifies the top-left corner [cB] specifies the center of the graphic’s Baseline Note that
9 Advanced Commands
This section describes advanced commands which are needed in the following situations
In these situations, the \DeclareGraphicsRule and \DeclareGraphicsExtensions commands are needed to control how LATEX deals with files specified in \includegraphics.
ext The file extension. type The graphics type for that extension. sizefile The extension of the file which contains the BoundingBox information for the graph- ics. If this option is blank, then the size information must be specified by the \includegraphics command’s bb option. command The command to be applied to the file. (often left blank). The command must be preceded by a single backward quote (not to be confused with the more common forward single quote.) Currently, only dvips allows execution of such a command. See Section 13 for examples of using this command for use with compressed and non-
the the BoundingBox information stored in the file with a .eps.bb extension, and the gunzip -c command uncompresses the file. (Since LATEX cannot read BoundingBox information from a compressed file, the BoundingBox line must be stored in an uncom- pressed file.) The \DeclareGraphicsRule allows * to signify any unknown extension. For exam- ple,
\DeclareGraphicsRule{}{eps}{}{}
Periods In The extension is defined as the portion of the filename after the first period, which
avoid confusion, the base portion of the filename should not contain a period. For ex- ample, specifying file.name.eps.gz makes \includegraphics look for a graphics rule associated with the extension name.eps.gz. Since such a graphics rule probably does not exist, the graphics rule for the unknown extension is used. (Filenames with multiple periods work if their type happens to be the default type. For example, when files with
treated correctly.) Pre-defined For convenience, a default set of graphics rules is pre-defined depending on which Commands graphics driver is selected^4.^ For example if the^ dvips^ driver is used, the following graphic rules (defined in dvips.def) are used by default \DeclareGraphicsRule{.eps}{eps}{.eps}{} \DeclareGraphicsRule{.ps}{eps}{.ps}{} \DeclareGraphicsRule{.pz}{eps}{.bb}{‘gunzip -c #1} \DeclareGraphicsRule{.eps.Z}{eps}{.eps.bb}{‘gunzip -c #1} \DeclareGraphicsRule{.ps.Z}{eps}{.ps.bb}{‘gunzip -c #1} \DeclareGraphicsRule{.eps.gz}{eps}{.eps.bb}{‘gunzip -c #1} \DeclareGraphicsRule{.ps.gz}{eps}{.ps.bb}{‘gunzip -c #1} \DeclareGraphicsRule{.pcx}{bmp}{}{} \DeclareGraphicsRule{.bmp}{bmp}{}{} \DeclareGraphicsRule{.msp}{bmp}{}{} \DeclareGraphicsRule{}{eps}{}{}
extensions for bitmaps (see Section 13.3.2). The last command causes filenames with
(^4) Specifying a graphics-driver package option such as \usepackage[dvips]{graphicx} overrides the default graphics driver specified in the graphics.cfg file.
The placement of the graphic is controlled by the current text justification. To center the graphic, put it inside a center environment \begin{center} \includegraphics[width=2in]{graphic.eps} \end{center} If the \includegraphics command is inside an environment (such as minipage or figure), the \centering declaration centers the remaining output of the environment. For example \begin{figure} \centering \includegraphics[width=2in]{graphic.eps} \end{figure} is similar to \begin{figure} \begin{center} \includegraphics[width=2in]{graphic.eps} \end{center} \end{figure} The \centering syntax is preferred because the \begin{center} syntax produces dou- ble vertical space above and below the figure due to the space produced by the figure environment and by the center environment. If extra vertical space is desired, the commands in Section 18.1 should be used. Obsolete Bugs in the \psfig and \epsfbox commands made it difficult to produce horizontally- Syntax centered graphics. The TEX commands \centerline and \leavevmode were used as work-arounds for bugs in \psfig and \epsfbox. Since the \includegraphics command is written correctly, the \centerline and \leavevmode are no longer needed, allowing graphics to be centered with the \centering command or the center environment.
It is important to realize that LATEX arranges graphics the same way it formats other objects such as letters. For example, an interword space is introduced between LATEX input lines unless the line ends with a %. For example, just as Hello World put an interword space between “Hello” and “World” \includegraphics{file.eps} \includegraphics{file.eps} puts an interword space between the graphics. Ending the first line with a comment character \includegraphics{file.eps}% \includegraphics{file.eps} puts no space between the graphics. When horizontal spacing is desired between graph- ics, the \hspace command inserts a specific amount of space^5 while \hfill inserts a rubber length which provides which expands to fill the available space. For example, (^5) Instead of making the \hspace amount a fixed length such as 1 inch, making the \hspace amount a function of \textwidth or \em increases a document’s portability.