How to put figures in TeX. S. Bell (I assume that you, like me, are using X windows.) To make a figure, I use the xfig command. (xfig is a MacPaint-like program. Below, I explain how to create figures using XMAPLE.) Suppose your figure is going to be called figure_one. To use xfig to create figure_one, type xfig figure_one.fig & in an xterm. When you have made your figure, export it to an ENCAPUSULATED PostScript file. You do this by first clicking on the 'EXPORT' button. In the dialog box, change the orientation from 'landscape' to 'portrait,' check that 'Encapsulated Postscript' appears in the 'Language' box, type a different filename in the 'Output Filename' box if you do not want the figure postscript file to be called figure_one.eps by default, and click on the 'export' button at the bottom. The eps file should appear in the directory that you were in when you started xfig. After exporting your figure to an eps file, select 'Quit.' Save your figure back to figure_one.fig if you might want to edit it later using xfig. The exported eps file is not as useful to the xfig program as the file figure_one.fig that xfig creates. If you want to edit your figure, just type xfig figure_one.fig & Your figure is now in a file called figure_one.eps In an AMS-TeX source file, the figure_one lines look like this: ******************************************************* \magnification=\magstep1 \input amstex \input epsf %<--- Make sure you have this line \documentstyle{imappt} \centerline{Final Exam} Text, etc. \vskip.1in \epsfxsize=2truein % <--- sets horizontal size \centerline{\epsfbox{figure_one.eps}} % <--- centers your figure Text, etc. \enddocument You can adjust the size of the figure by altering the command \epsfxsize=2truein The line \epsfxsize=\hsize will make the figure its natural size. To preview a TeX document containing postscript figures, you will need to use the ghostview command. (If you try to preview a TeX dvi file using something like xdvi, the figures won't show up, however, they will print ok). To preview the document on screen, figures and all, do this: amstex filename.tex dvips -f filename.dvi > out.ps ghostview out.ps & (xv is another tool like ghostview for viewing PostScript files.) ******************************************************* If you have a postscript file that is not encapsulated, you can try something like the following. As an example, I will show you how to create graphics using xmaple. Type xmaple in an xterm. Now that you are in xmaple, create a 2-d plot via > plot( x * sin(x^3) , x = 0..3); The plot appears in a window after a brief period. Select PRINT from the FILE menu above the plot and then select PostScript. Write the PostScript file to a file called plot.ps (that will apear in the directory in which you started XMAPLE.) You will need to modify plot.ps as follows before it can be used in a TeX document. Remove the lines that say 540 82 translate 90 rotate Also, remove the line that says showpage If you don't want a big black box around your figure (and most people don't), go to near the end of the file and remove these lines: %%%% The following draws a box around the plot. [] 0 setdash NP -80 -80 m -80 2529 l 3379 2529 l 3379 -80 l -80 -80 l S Here is a TeX document that will display the plot.ps figure. ******************************************************* \magnification=\magstep1 \NoBlackBoxes \input amstex \documentstyle{imappt} \centerline{Final Exam} Text, etc. \vskip5in % 5 inches of figure \special{psfile=plot.ps hscale=75 vscale=75} % input figure Text, etc. \enddocument ******************************************************* Note that you have to vskip enough space for the figure before you input it. As above, to view the document, do this: amstex file.tex dvips -f file.dvi > out.ps ghostview out.ps & The hscale=75 and vscale=75 create a figure that is 75 percent of its natural size. To move the figure to the right one inch on the page, add hoffset=72 to the special command as follows: \special{psfile=plot.ps hscale=75 vscale=75 hoffset=72} Try this: In xmaple, create a 3-D figure via > f := (x,y) -> cos(x^2 + y^2) / (1 + x^2 + y^2); > plot3d( f(x,y) , x=-3..3 , y=-3..3 ); Print the plot to a PostScript file called plot3d.ps and edit the file as above. You can display the figure in a TeX document via \vskip3in \special{psfile=plot3d.ps hscale=50 vscale=50 hoffset=72} Check out the "psfix" command if your postscript file comes from mathematica graphics. You can also find helpful information in the man pages under dvips. That's all I know. Good luck! -Steve Bell P.S. If you learn of better ways to do these things, please tell me about them. P.S.S. HERE ARE THE RELEVANT PASSAGES FROM THE dvips MAN PAGES -------------------------------------------------------------- \special OPTIONS This DVI driver allows the inclusion of POSTSCRIPT code to be inserted in a TeX file via TeX's \special command. For compatibility with other systems, several different conven- tions are supported. First, there's a flexible key-and-value scheme: \special{psfile="filename"[ key=value]*} This will download the POSTSCRIPT file called filname such that the current point will be the origin of the POSTSCRIPT coordinate system. If the filename string begins with the ` (grave accent) character then the remainder of the filnename field is treated as a Unix Bourne shell script to be exe- cuted with its sysout down loaded as a POSTSCRIPT file. For example: \special{psfile="`zcat packed.ps" ...} will uncompress the file packed.ps.Z for inclusion in dvips output. The optional key/value assignments allow you to specify transformations on the POSTSCRIPT in filename. The possible keys are: hoffset The horizontal offset (default 0) voffset The vertical offset (default 0) hsize The horizontal clipping size (default 612) vsize The vertical clipping size (default 792) hscale The horizontal scaling factor (default 100) vscale The vertical scaling factor (default 100) angle The rotation (default 0) The hoffset, voffset, hsize, and vsize are given in POSTSCRIPT units (1/72 of an inch), called bp elsewhere in TeX; these are the units of the default coordinate system assumed to be valid in the POSTSCRIPT file. The hscale and vscale are given in non-dimensioned percentage units, and the rotate value is specified in degrees. Thus \special{psfile=foo.ps hoffset=72 hscale=90 vscale=90} will shift the graphics produced by file foo.ps right by 1", and will draw it at 0.9 normal size. If either hsize or vsize is specified, the figure will be clipped to a rectangular region from (0,0) to (hsize,vsize) in default coordinates, after scaling, translation, and/or rotation. Otherwise no clipping will be done. Offsets are given rela- tive to the point of the \special command, and are unaf- fected by scaling or rotation. Rotation is counterclockwise about (0,0). The order of operations is: Take the POSTSCRIPT figure, rotate it, then scale it, then offset it, then clip it. For example, if you want to extract a one-inch-square figure bounded by (100,200), (172,200), (172,272), and (100,272) in the POSTSCRIPT coordinates of the graphic in cropthis.ps, you would say \special{psfile=cropthis.ps hoffset=-100 yoffset=-200 hsize=72 vsize=72} Secondly, if your file conforms to the Encapsulated PostScript (EPS) conventions, then it is possible to use a simpler \special command that will automatically reserve the required space. To use, simply say \input epsf % at the beginning of your TeX document \epsfbox{filename.ps} % at the place where you want the figure A vbox of the appropriate size for the bounding box will be built. The height and width of this vbox will be the height and width of the figure; the depth of the vbox will be zero. By default, the graphic will have its `natural' width. If you wish to enlarge or reduce it, simply set the dimension `\epsfxsize' to something else, such as `\hsize'; the figure will be scaled so that \epsfxsize is its final width. A more general facility for sizing is available by defining the `\epsfsize' macro. This macro is used to give \epsfx- size a value each time \epsffile is called. It takes two parameters; the first is the horizontal natural size of the POSTSCRIPT figure, and the second is the vertical natural size. (Natural size, in this case, is the size in POSTSCRIPT points from the bounding box comment.) The default definition of this macro is \def\epsfsize#1#2{\epsfxsize} which just means to take the value that was set before the macro was invoked. Note that the variable \epsfxsize is reset to zero at the end of each call to \epsffile. You can redefine this macro to do almost anything. It must return the xsize to use, or 0 if natural scaling is to be used. Common uses include: \epsfxsize % just leave the old value alone 0pt % use the natural sizes #1 % use the natural sizes \hsize % scale to full width 0.5#1 % scale to 50% of natural size \ifnum#1>\hsize\hsize\else#1\fi % smaller of natural, hsize The resultant vbox can be centered with \centerline, or treated as any other vbox. If you are using LaTeX and the center environment, be sure to execute a \leavevmode before each use of \epsffile, so that LaTeX leaves the vertical mode and enters the paragraph making mode. (This should probably be provided by the LaTeX macros themselves.) (The \epsfbox macro does its job by scanning filename.ps for a standard `BoundingBox' comment. The figure is clipped to the size of that bounding box. If the bounding box is not found, a bounding box of `72 72 540 720' is assumed. If the POSTSCRIPT file to be included is not EPSF, you are probably better off using the psfile special instead.) -----------------------------------------------------------------