[Tex/LaTex] Images in LaTeX – what’s the solution

graphics

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?

Best Answer

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.