My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
FiguresInLaTeX  
How to insert external figures into your thesis
Featured
Updated Apr 20, 2010 by rbre...@gmail.com

Introduction

Most 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 PDF

The 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 Data

The 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 formats

If 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.

  1. Use your browser to set up the page the way you want it to be captured
  2. Select Print from the File menu
  3. From the PDF button in the lower left corner, select Save as PDF
  4. Open the resulting PDF in Acrobat
  5. Select the Crop tool from the Tools menu
  6. Select the area of the PDF that you want for your figure
  7. Double-click in the center of the rectangle to bring up crop window
  8. Crop the image
  9. Save the cropped PDF file (possibly under a different name if you are paranoid)
  10. Save the cropped PDF file as EPS (this is what you will actually use in LaTeX)

Capturing a web page in raster format

This example uses Mac OS X. Performing it on other platforms is left as an exercise for the reader.

  1. Use your browser to set up the page the way you want it to be captured
  2. Run the Grab application from the Application->Utilities folder
  3. Grab the selection of the web page you are interested in
  4. Copy the image to the Clipboard
  5. Run the Preview application
  6. Select File->New from Clipboard
  7. Save the file as a PNG file
  8. Convert the PNG file into EPS using convert: "convert foo.png foo.eps"

Inserting images in LaTeX

Now 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.

Comment by project member philipmj...@gmail.com, Jan 20, 2009

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).


Sign in to add a comment
Powered by Google Project Hosting