|
FiguresInLaTeX
How to insert external figures into your thesis
Featured IntroductionMost theses will need to insert graphics generated outside of LaTeX. There are a variety of ways to insert figures, this page attempts to lay out best practices as of January 2009. How to generate PDFThe first thing to be discussed is how to go from the .tex file to the PDF file. One way is to go from DVI to PS to PDF (using dvips and ps2pdf), and this is the method used by the latex-makefile. The author of the makefile suggests that having the PostScript file around is useful for printing and also for use with psfrag. Since I like the latex-makefile, I advocate this method of generating PDFs. LaTeX really only knows how to deal with encapsulated PostScript files (EPS), so if you use LaTeX then you will want your input graphics to be EPS. The other method is to use pdflatex, which goes directly from tex input to PDF. pdflatex can include PNG, JPEG, and PDF files, but not EPS. This tutorial page goes into more detail, but it advocates the pdflatex method. Here is another discussion of the differences between pdflatex and latex for figures. Capturing Figure DataThe first thing to do is capture whatever graphical information you want to put into your document. I recommend capturing the data in a format that is as 'native' as possible, and keep that original around. This ensures that when converting or altering the image, you can always go back to the original without having to recreate the data. If the object is a photograph, you'd probably want to capture it as a JPEG (or possibly PNG or TIFF if you don't want it compressed at all). However, if the data consists of a mixture of text, vector graphics, and images (such as output from a charting program or a web page), you can capture it in either a vector or raster format. Let's take the example of capturing a web page from a browser. One option is to make a screen capture of the browser window, which will result in a raster image of some sort (avoid saving non-photographic images as JPEG to avoid compression artifacts). On Mac OS X, you would use the Grab utility to capture a window or selection, and save it as a PNG file. The other option is to try to print from the application, to capture the graphics in a vector form. For example, on Mac OS X you can Print a file and save it as a PDF document. Raster files are generally easier to capture and crop, but when included into your LaTeX document, the image will often look somewhat fuzzy (especially text) since only a bitmap is available. Raster files are also much larger than vector files in general. If you choose to use pdflatex, then (as mentioned before) you can include PNG, JPEG, and PDF files but not EPS files. Most applications will save or export directly into one of those formats, so you probably won't need to do any conversion. Converting between graphics formatsIf you are running on Unix or Mac OS X, you probably had the "convert" command line utility installed as part of TeX Live. If so, it's easy to convert between formats. Just use "convert foo.format1 foo.format2". This is most likely to be used for converting raster formats into EPS: "convert foo.jpg foo.eps". Capturing a web page in vector format (recommended)This example uses Mac OS X and Adobe Acrobat (not Acrobat Reader). Performing it on other platforms and without Adobe software is left as an exercise for the reader.
Capturing a web page in raster formatThis example uses Mac OS X. Performing it on other platforms is left as an exercise for the reader.
Inserting images in LaTeXNow that you have the EPS files of your images, you are ready to use them as figures in your thesis. This tutorial on inserting images in LaTeX will tell you everything you need to insert the images. The short version is you will use the graphicx package, and the \includegraphics command. However, you will almost certainly want the images to be figures with captions that are listed in the Table of Figures, and there is another tutorial on figures and captions that explains how to do that. |
The way I generate PDF is slightly different from the approaches mentioned. I am sensitive to methods that work correctly on both Windows and Macintosh, since I am a cross-platform kind of guy.
I first generate a .dvi file (using the 'latex' command), then run 'dvipdfmx'. This works well for me on both Windows and Macintosh platforms. I have not had similar cross-platform success with other commands (such as dvipdf).