Access Keys:
Skip to content (Access Key - 0)
 #nav_header { width:100%; height:35px; background-color:#444; color:#bababa; background-image: -ms-linear-gradient(top, #444444 50%, #222222 100%); /* IE10 */ background-image: -moz-linear-gradient(top, #444444 50%, #222222 100%); /* Mozilla Firefox */ background-image: -o-linear-gradient(top, #444444 50%, #222222 100%); /* Opera */ background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0.5, #444444), color-stop(1, #222222)); /* Webkit (Safari/Chrome 10) */ background-image: -webkit-linear-gradient(top, #444444 50%, #222222 100%); /* Webkit (Chrome 11+) */ background-image: linear-gradient(top, #444444 50%, #222222 100%); /* Proposed W3C Markup */ } #nav_header a { color:#fff; text-decoration:none; } Welcome back,  •  Log In  • Knowledge Base Handbook #header_bottom { width:100%; height:5px; margin:0; background-color:#C6C6C4; background-image: -ms-linear-gradient(top, #C6C6C4 0%, #FFFFFF 100%); /* IE10 */ background-image: -moz-linear-gradient(top, #C6C6C4 0%, #FFFFFF 100%); /* Mozilla Firefox */ background-image: -o-linear-gradient(top, #C6C6C4 0%, #FFFFFF 100%); /* Opera */ background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #C6C6C4), color-stop(1, #FFFFFF)); /* Webkit (Safari/Chrome 10) */ background-image: -webkit-linear-gradient(top, #C6C6C4 0%, #FFFFFF 100%); /* Webkit (Chrome 11+) */ background-image: linear-gradient(top, #C6C6C4 0%, #FFFFFF 100%); /* Proposed W3C Markup */ } .rightfloat { height:50px; margin:20px 0 0 20px; float: right; } .createButton { border:2px solid #aeaaa7; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; margin-top:20px; background-color:#e5e3e0; color:#444; padding:4px 7px 4px 7px; font-family: "ProximaNovaBold" !important; font-weight:bold; font-size:13px !important; float:right; } .rightfloat .searchQuery { height: 32px; width: 200px; border:1px solid #aeaaa7; -webkit-border-top-left-radius: 5px; -webkit-border-bottom-left-radius: 5px; -moz-border-radius-topleft: 5px; -moz-border-radius-bottomleft: 5px; border-top-left-radius: 5px; border-bottom-left-radius: 5px; margin-right: -4px; padding: 0 5px 0 5px; } .rightfloat .searchButton { height: 32px; border: 1px solid #6f6f6f; color:#ffffff; background-color:#6f6f6f; font-weight:bold; -webkit-border-top-right-radius: 5px; -webkit-border-bottom-right-radius: 5px; -moz-border-radius-topright: 5px; -moz-border-radius-bottomright: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; padding: 0 2px 2px 0; margin-left:0; } .space-select {display:none;} Home EditAdministration ViewThis page Other pages Account History

How do I include Postscript graphics in a LaTeX file?

On this page:

Overview

Postscript files can easily be included and scaled in LaTeX documents. For encapsulated postscript files (.eps, .epsi), the easiest method uses the epsf style, and is described below.

On the other hand, if your postscript file is not encapsulated, and does not contain a bounding box, you have two choices:

• you may convert it to an .eps file using the ps2epsi converter in the gnu locker. This command
athena% add gnu
athena% ps2epsi file.ps 

will create file.epsi

• you may use the PSbox macros in the consult locker, and follow the second set of directions below.

Using epsf

1. Add the line
	\usepackage{epsf}

to the beginning of your document, after the \documentclass line.

2. When you want to include the .eps file, use the
\epsfbox{filename.eps}

command. You can scale the postscript file by using either \epsfxsize=width or \epsfysize=height to specify a width or height; the other dimension will be scaled accordingly. You must include the \epsfxsize or \epsfysize command before the \epsfbox; otherwise you'll be scaling the next figure.

3. If you need to center the file and are getting error messages, enclose it in an \mbox:

\begin{center}
\mbox{\epsfbox{filename.eps}}
\end{center}


Using psbox

1. First, you need to copy two "style files" into the same directory as your latex files. To do this, change into the same directory as your latex files, and then type:
	attach consult
cp /mit/consult/lib/tex/macros/ps*.sty .


Alternately, you can add the path /mit/consult/lib/tex/macros/ to your TEXINPUTS; a line in your .environment file such as

setenv TEXINPUTS .:/mit/sipb/share/tex/macros:/mit/consult/lib/tex/macros/:


will include the LaTeX styles in both the consult and sipb lockers, in addition to the default styles (don't forget the ":" at the end!). Note that sipb and consult must be attached in order for these paths to work.

2. Under Latex2e (the default), add the following line after your \documentclass line:

\usepackage{psbox}

3. If possible, generate the postscript file such that the picture is flush against the lower-left-hand corner. (For example, if idraw is being used, group the entire picture and move it to the lower-left-hand corner of the page. If it is a raw postscript file, add an appropriate translate command, if you know how.) When you do this, the left most 1/4" of the document may not be printed, since although (0,0) is at the lower-left hand corner of the page, on some printers the left most 1/4" part of the page isn't part of the image area. Don't worry about it.
4. Print out the postscript file. There are two reasons for doing this. The first is to make sure that there aren't any errors in the postscript. The second reason is to get the dimensions of the picture and where it is located on the page. Measure the height and the width of the graphic. Also, if the graphic is not located in the lower-left-hand corner, measure the (x,y) distance from the lower-left-hand corder of the page to lower-left-hand corner of the graphic IN INCHES.
NOTE If your postscript file was created in Xfig, make sure that it does not use "fills", as these do not come out correctly when used with dvips on the Athena printers (they come out as solid colors as opposed to shades or cross-hatched patterns).
5. Include the Postscript file
1. If the postscript file has the image in the lower-left-hand corner of the page, it's really easy. At the point where you want the picture to be included, just use the following command:
	\PSbox{/mit/username/filename.PS}{1.7in}{0.25in}


Where the first argument is the filename of the postscript file, the second is the width of the graphic, and the third argument is the height of the graphic. The dimensions can be specified in any format that LaTeX accepts. So, for example, a dimension such as "4cm" will also work. This "PSbox" can be centered, included in a figure, or anything else you want!

2. If you were unfortunate enough as to be unable to get the graphic in the lower-left-hand corner, all is not lost. However, you will need to do a bit more work. Take the distance from the left-hand side of the page (which you measured in inches, right?) and multiply by -72. Call this number the "$hoffset". Take the distance form the bottom of the page to the bottom of the graphic (also measured inches), multiply it by -72, and call it the "$voffset". Then the PSbox command should be modified to be:
\PSbox{/mit/username/filename hoffset=$hoffset voffset=$voffset}{$width}{$length}


For example, to include a file which is 4 inches high and 5 inches wide, which is located 3 inches from the bottom of the page and 2 inches from the left side of the page, the PSbox would be:

	\PSbox{/mit/username/filename.PS hoffset=-144 voffset=-216}{5in}{4in}

6. You can also shrink and scale your postscript figures. For example, if you wanted to include your figure shrunk by half in each direction, you would used:
	\PSbox{/mit/username/filename.PS hscale=50 vscale=50}{2.5in}{2in}


(with the dimensions being the size of the figure once it has been scaled to half size in each direction). Scale values are in percent. Note that it's possible to shrink your figure in one direction and not the other; in most cases, though, you want to scale it equally both horizontally and vertically.

IS&T Contributions

Last Modified:

December 16, 2010

Get Help

Request help
from the Help Desk
Report a security incident
to the Security Team
Labels:
olc-latex olc-latex Delete
ps ps Delete
postscript postscript Delete
latex latex Delete
Enter labels to add to this page:

Looking for a label? Just start typing.
Feedback
This product/service is:

This article is:
Adaptavist Theme Builder (4.2.3) Powered by Atlassian Confluence 3.5.13, the Enterprise Wiki