(I assume that you are using X windows on or from a math dept SUN.)
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 & and repeat the process above.)
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{amsppt} \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.
In a LaTeX or AMS-LaTeX source file, the figure_one lines could look like this:
\documentclass[12pt]{article} \usepackage{amsmath, amsthm} % if you want to use amslatex \usepackage{epsfig} % input picture package \begin{document} This is the main text of your paper. You are going to put your picture below this line. % if the picture is in eps format, for example from xfig \epsfig{file=figure_one.eps,height=1.5in} % if the picture is in postscript format, for example, from Matlab \epsfig{file=figure_one.ps,height=1.5in} You can use all the usual commands in latex to position your pictures wherever you want. The figures are not floating objects. So they are exactly where you want them to be. \end{document}
Another way to put figures in LaTeX is to use the new graphicx package. For example, a good way to include a figure picture.eps centered and scaled to 2inches is:
documentclass[12pt]{amsart} % or whatever \usepackage{graphicx} \usepackage... ... \begin{center}\includegraphics[height=2in]{picture}\end{center} % height is optional
To preview a TeX document containing postscript figures, you will need to use the new xdvi command. Just type
xdvi filename
If the figures do not show up in the xdvi previewer, you might be using an old version of xdvi that doesn't do figures (but even though the figures don't show up on screen, they will print ok). The following method will also let you preview on the screen what will print on the printer.
amstex filename.tex dvips -f filename.dvi > out.ps ghostview out.ps &
(xv and gs are other tools 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.)
(Maple 8 can now export eps directly, which makes life a lot easier. Plot a picture in xmaple, then click the right mouse button over the plot. You'll get a menu that gives you this option.)
You will probably want to modify plot.ps as follows before using it 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), you can go to near the end of the file and remove the lines like these:
%%%% 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
Or another (and perhaps even better way) to remove the box is to find the line
/drawborder true def
in the EPS file and change true to false. This has the advantage that if you change your mind and want the box back, you won't hate yourself for having deleted those lines.
Here is a TeX document that will display the plot.ps figure.
\magnification=\magstep1 \NoBlackBoxes \input amstex \documentstyle{amsppt} \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.
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. Here are the relevant passages from the dvips MAN PAGES.
Rodrigo Bañuelos points out that one can even import pictures in other formats such as pdf, jpg or tif provided one uses pdflatex or pdftex to go directly from the tex file to a pdf file. With lots of pictures (actual photos for example), if one imports the files in jpg format, this seems to produce much smaller pdf files than what one would get by changing the pictures to eps format, producing the dvi file, then the ps file, and then the pdf file with distiller. (Unfortunately it appears that you cannot do this using the Math Department tex since it seems to have an old version of pdftex.) See Network News Volume 2 for information about creating PDF files from TeX files.
NOTE: This page is rather outdated. The new Linux servers support the commands pdflatex and pdftex that create a PDF file directly from the TeX source file. If you run TeX to create a DVI file, you can then run dvipdf, which will create a PDF file from the DVI file. There is also ps2pdf that will convert a PostScript file to PDF.
Back to the Network News Index Page
Back to the MATH 2000 HOME PAGE