It is notoriously difficult to figure
out how to include drawings in your LaTeX documents. There
are dozens of inconsistent standards, hundreds of incomprehensible
websites on the subject, and everyone seems to have a different opinion
of how it is done. After years of battling the various
obstacles, I have settled on what I believe to be the easiest way to go
about it. Since I wish someone had said this to me, here it
is. Please don't email me if it doesn't work. Note:
most of the discussion below is OS-independent.
There are three steps:
1. Create a graphic.
2. Put the graphic in your file.
3. Compile. Pull hair out, scream at monitor, pace
maniacally... then either enjoy your handiwork or go on the the dark
realm of PDF (discussed below).
Step I: Create a Graphic
This is the fun part, once you figure out how to do it. Until
that point, it's decidedly not fun. First, you have to pick
some software to do it. Adobe Illustrator is my medium of
choice, though it's got a steep learning curve and an even steeper
price. Illustrator is quality, though. If you want
to save money and/or support open source, try GIMP, a
none-too-shabby GNU image editor. Your machine might even
have xfig on it,
thought I wouldn't recommend using it. There's also Skencil, Inkscape, jPicEdt,
and METAGRAF-3D.
Sometimes specialized mathematical software is the way to go, since no
one wants to draw a rhombicosahedron
by hand. Mathematica,
among others, can output EPS files.
The key things you need in graphic design software are (1) ease of
drawing nifty stuff, and (2) the ability to output EPS (Encapsulated
PostScript) files. Actually, you can get around #2 if you
really know what you're doing, but then you wouldn't be reading this.
I ought to mention that, since we're doing this the "easy way", some
forethought is necessary. It is possible to display only part
of a graphic you've created, or resize it, or do even more complicated
things to it within a LaTeX document. However, I can never
remember how to do these things. Anyway, image editors were
made for such tasks. So make sure that the graphic that is
outputted (which may or may not agree with the one you see in the
design software's window) is just what you want: the right size, no
extra whitespace on the margins, etc. There are few
experiences more frustrating than not being able to figure out why your
graphic is off-center in the compiled DVI file, only to realize four
cups of coffee later that the image file contains your drawing
surrounded by an enormous, empty canvas.
Step II: Include the Graphic
Put the image file in a directory that the LaTeX engine can see --
usually the directory containing the document is a good
choice. Assuming that your document is a \documentclass{article}, you should include
the following commands near the top of the file:
\usepackage{graphicx}
\usepackage{color}
\usepackage{epsfig}
Then, wherever you want to include your file.eps
graphic, insert the following:
\begin{figure}[h]
\begin{center}
\begin{tabular}{c}
\includegraphics{file}
\end{tabular}
\caption{This is a drawing.}
\end{center}
\end{figure}
Make the obvious replacements whereever necessary. The [h] near the top means you
are telling LaTeX to put this graphic "here", i.e., wherever it appears
in the text of the LaTeX source. There are other directives
one can use: t for top of the page,
b
for bottom, etc.
See the links at the top of this page for more information.
The {c}
means that the graphic will be centered. One can also
use {l}
and {r} for left and right, respectively.
Step III: Compiling
Compiling the file should go smoothly at this point. If you
want to make a PDF file out of your document, use PDFLaTeX.
The code above should actually work for this purpose, amazingly, with
one caveat: you've got to make a PDF version of the graphic.
Again, there is software to do this: Illustrator, Acrobat, PDFWriter,
and Distiller can all handle the conversion. There is also epstopdf
and ImageMagick.
Put the PDF file in a directory PDFLaTeX can see, and compile.
|
|
|