How to Include Postscript Files


Postscript files CAN be included into LaTeX documents, and it becomes quite easy if you take a bit of time and do it step by step:
  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 .
    The . is important, and tells cp to copy the files to the current working directory.

  2. Add psbox to your \documentstyle line; i.e, if you had
    \documentstyle[]{report}
    change it to:
    \documentstyle[psbox]{report}
  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.

  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, For example, if you wanted to include your figure shrunk by half in each direction, you would used:
    \PSbox{/mit/username/filename.PS hscale=0.5 vscale=0.5}{2.5in}{2in}
    (with the dimensions being the size of the figure once it has been scaled to half size in each direction). 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.

    Another note: these scale values are for use with dvi2ps ONLY. See the stock answer on How to use dvips, if you are using dvips instead.

NOTE: xdvi cannot show included postscript figures; instead, it leaves a blank space of the correct size. xdvi will also print a warning that says xdvi: special "filename" not implemented every time you preview a page with a postscript figure on it. This is nothing to worry about- it's just reminding you that it can't preview the postscript figure- it should still print out without any problems.

If you want to preview where the postscript image will appear using xdvi, you can change the psbox in your documentstyle line to be psframe.

Assuming that you have specified the arguments to \PSbox correctly, this will result in a box being drawn around the area where the postscript image will appear. However, when you print your latex document, the box will appear on the printed output as well. You will need to change the psframe back to psbox and re-latex your file to make the box go away when you want to print your final copy.

If you have troubles when you use the above procedures and things do not print well, try using the dvips program instead of dvi2ps. dvips is a newer .dvi to PostScript converter that has better support for PostScript inserts. To find out more information about it, type:

add sipb
man dvips
To run it, type:
add sipb
dvips -Pprinter filename.dvi
You are STRONGLY advised, however, to read the man page and/or the stock answer on it first, as the syntax between the two programs is VERY different. The stock answer What is DVIPS? can be found in the LaTeX submenu.