Skip to content Accesskey=4Skip to sub-navigation Accesskey=3View our Accessibility Options MIT Information Systems Home About IS&T Contact IS&T Site Map Search Advanced Search
Getting StartedGetting Services by Topic or Alphabetically Getting Help

On This Page

[Help]

  

Quick Links

Top Level

Related Links

Ask OLC a question

Athena Consulting Homepage

Helpdesk Stock Answers (for Mac/PC questions)


Including POSTSCRIPT pictures into a LaTeX file

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:

1) you may convert it to an .eps file using the ps2epsi converter in
   the gnu locker:
	athena% add gnu
	athena% ps2epsi file.ps 
   will create file.epsi

2) 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.   
  
3. 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.  

4. 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. a) 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!

   b) 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 (read RELEASE NOTE
   below!)  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. 

   RELEASE NOTE: these scale values are for use with dvips ONLY, and will
   not work with dvi2ps (on machines running Release 7.6 or older). For
   dvi2ps, hscale and vscale values should be specified in decimal fractions
   (.5 instead of 50). 


----------------------------------------------------------------------

$Date: 2007/11/21 15:41:45 $

MIT Home | Getting Started | Getting Services | Getting Help | About IS&T | Accessibility
Ask a technology question or send a comment about this web page.