I've faced so many problems using images in LaTeX. See for example, another question at https://stackoverflow.com/questions/382590/latex-using-eps-images-builds-slowly

What tools do you use to make figures for inclusion into LaTeX? Is there a simple solution to this? Some scenarios described below:

  • I want to add a screenshot into LaTeX;
  • I want to include a figure from visio into LaTeX;
  • I plot a graph, export into png, and the image does not seem to have a bounding box.

How to handle these scenarios?

migrated from stackoverflow.com Aug 31 '11 at 20:01

This question came from our site for professional and enthusiast programmers.


I believe an update to my original answer is in order because my image inclusion practices have changed since 2009: I now almost exclusively use TikZ to directly create diagrams using TeX commands. In my (and many other people's) opinion it consistently produces the best-looking graphics, and also makes it easy to embed them within a LaTeX document because there is no separate image file involved; you don't need to worry about bounding boxes, file formats, driver compatibility, etc. It works with both PostScript output (dvips) and PDF output (pdflatex).

I used to prefer the EPS format for inclusion in LaTeX documents, but because it's a vector graphics format, anything that is drawn in EPS can in principle be closely reproduced with TikZ, so I don't use EPS figures anymore. I could see that being a useful option if you had some complex EPS figure that would take a long time to convert to TikZ; however, pdflatex does not allow EPS figures. You can convert the EPS to a PDF file and include that, though.

For cases which require a raster image, e.g. if you're trying to include a photograph or screenshot, you can use pdflatex with the package graphicx (or graphics, they're very similar) to directly include PNG images in LaTeX files:

\includegraphics[width=4in,height=4in,viewport=0 0 300 300]{figure.png}

latex + dvipdf might also accept PNGs, I'm not sure. The disadvantage of this is that you can't use any Postscript-specific packages, like pstricks or draftcopy; however, again, the functionality of these packages is mostly duplicated by TikZ.

  • 2
    +1 for using pdflatex. I often make figures in powerpoint or visio, export to pdf and include pdf's in my latex document using pdflatex. Works great! – Eyvind Mar 28 '09 at 17:25
  • 2
    You can include PDF figures (also a vector format, afterall) in pdflatex documents for high quality printing. This is the direction 've been moving in of late. – dmckee Mar 28 '09 at 18:20
  • 1
    Yep, PDFLatex works with all the common image formats (png jpg and so on). Of course, just to be difficult, it does not work with eps images... So it's one or the other. Everything else would be too straightforward ;) – jalf Mar 28 '09 at 18:50
  • Specifying both width and height is a bit strong. I rarely need more than just \includegraphics[width=\linewidth]{foo} or ...[scale=.8]... – Damien Pollet Jun 17 '10 at 5:48
  • 1
    I never used it but there is a package named auto-pst-pdf which should enable using PS-Code in pdflatex. – Tobi Aug 31 '11 at 22:48

Related answer here

Short story

  • store your raster pictures as .png (or .jpg, but lossless is better where you can).

  • don't export your plotted graph as a .png. It's a vector object, and any decent plotting package will output it as a .pdf or .eps.

  • depending on your final output, you might want to save vector figures as .pdf's and then use pdflatex to generate a pdf file. There are good reasons to avoid this sometimes, though.

  • if you do need to go the .dvi -> ps/whatever route, you'll have to generate .eps files even for your raster images. Imagemagick or a similar tool is your friend here.

  • other general tips: use graphicx package, don't include suffixes on the filename when you include the figure.


In case of plotting, I use Gnuplot - it supports saving files in eps format and it's better than png, because it is saved as a vector not a bitmap (you can zoom it without any reasonable limits).

pdflatex supports png, jpg, tiff and pdf graphics, so you can add it without converting. If you want to include eps file to pdflatex, use the eps2pdf tool which is installed with Latex.

If you really want to convert everything to eps, try Gimp.

  • 1
    Or ImageMagick.. – John Fouhy Mar 30 '09 at 2:48
  • Gnuplot can output PDF directly, and pdftex can include some .eps files respecting a subset of the format (metapost generates that, for instance) – Damien Pollet Apr 16 '09 at 22:26

My papers are very heavy on screenshots and diagrams.

I have had great luck exporting or saving as PDF (rather than EPS) and then embedding it. PDFs (if exported as images, not as an actual print) have fairly decent sizing info, and embed in an instant.

On a Mac, you get that functionality from OmniGraffle (a Visio analogue), but perhaps Visio does it these as well.


I use \includegraphics with pdflatex and recommend this combination highly. I have a few hints that might make sense. (Note that these come from my background in technical writing, which can be figure-laden.)

  1. Always specify graphic width (or height) in the [] block. This will allow you to use graphics of different rendered sizes.

  2. Do not supply the file extension suffix. That way, if you decide that you can make the file smaller or better as a .png or a .jpg or whatever, then your latex code will not have to change. (I commonly create diagrams in a variety of formats, to get small size. See also the last point below, about experimentation.)

  3. If you are creating diagrams yourself, make them wider than they are tall, perhaps using a 2/3 ratio. This looks good, and it will let latex fit figures into your document more easily. (If your figures have to be at a 1:1 ratio, use white space on the sides, to avoid using more than a relatively small fraction of page height.)

  4. Again, if you are creating diagrams yourself, take a bit of time to experiment with font size and image geometry. The normal rule is that text on a diagram should not use a font that is smaller than in the caption or main text. Once you find a good formula, you can stick to it for all your diagrams. This will make the document look good, and it will save you a lot of time spent twiddling geometries on a per-figure basis.

  • 1
    I don't agree with statements 1: there's no need to always specify width or height: particularly with JPG images that in general should not be scaled. I partially don't agree with statement 2: choosing the format is not about getting small size, but about what format is good for the particular graphic object. – egreg Aug 31 '11 at 22:47
  • @egreg: But there's no harm in specifying the width explicitly for a JPEG: The scaling done when specifying width or height with \includegraphics is lossless, and there's no native resolution for PDF and printed documents (unlike for a computer screen). Explicitly specifying the size can spare you some surprises with oversized imaged or incorrect resolution metadata in the images. – Jake Sep 1 '11 at 11:25
  • @Jake: Scaling a JPEG can show artifacts. Also scaling a PNG is not recommended, IMO. – egreg Sep 1 '11 at 11:37
  • @egreg: What kind of artifacts do you mean? And why should PNGs not be scaled? The scaling done when including a JPEG or a PNG using \includegraphics is not the same as that done using a raster image editor. What you're doing when specifying a width is merely to fix the physical width over which the pixels are distributed, but the pixels of the image themselves are not altered in any way, so you can't introduce artifacts. This is different if you scale a raster in Gimp, from, say, 100x100 pixels to 150x150 pixels, which leads to problems with interpolation. – Jake Sep 1 '11 at 11:51
  • 1
    @egreg: You will get the same artifacts if you don't scale the image, unless both your screen and your printer also have a resolution of exactly 300 dpi. – Jake Sep 1 '11 at 12:59

I have been using the tikz and the standalone package. The figure are placed in separate files and \input into the main file. For example, here is the contents of file Ellpise.tex:



\coordinate (EllipseOrigin) at (0,0);

\draw [blue, thin, ->] (-5,0) -- (5,0) node [right] {$x$};
\draw [blue, thin, ->] (0,-4) -- (0,4) node [above] {$y$};

\draw [red, ultra thick]% Graph Ellipse
    (EllipseOrigin) ellipse [x radius=\XRadius,y radius=\YRadius];


Then in the main file I have:


Here is the graph of an ellipse:


I keep the figures in a separate directory and can compile them separately to ensure that I get them the way I want them. There are various other options you could do to such as to place these in a Figure environment if desired.


On the side of creating figures one can use the Inskscape program, it uses vector graphics and has good pdf support.

In my experience I found it to be very nice to pdflatex. I like TikZ but it has quite the learning cuve,and for creating figures a more WYSISWYG approach makes sense to me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.