views:

1053

answers:

10

What is the preferred way to convert various images, bitmap and vector, for use in a LaTeX and PDFLaTeX document?

There are many ways to do this, some make use of standard inclusions in the various LaTeX packages, others give better results.

A: 

I always include images in PNG format.

Mork0075
It's not a good idea to convert vector graphics into PNG. The outcome will be ugly.
Kaarel
The question was about both bitmap and vector images; the -1 was unjustified. +1 from me.
ShreevatsaR
A: 

My current preferred way is using bmeps and epstopdf included in MikTeX. For the generation of pdf and eps versions of a png.

In a file called convertimage.bat,


bmeps -p3 -c -e8f -tpng %1.png > %1.eps
epstopdf %1.eps

Use by including in the path and writing convertimage.bat filenameminusextension

Include in the documents using,


\begin{figure}[h]
\begin{center}
\includegraphics[scale=0.25]{path/to/fileminuxextension}
\caption{My caption here}
\label{somelabelforreference}
\end{center}
\end{figure}
Brendan
+1  A: 

I only use Encapsulated PostScript (.eps) figures (converting bitmaps with NetPBM first), since I always use dvips + ps2pdf anyway, and then I do \includegraphics{file}.

ShiDoiSi
+5  A: 

I convert bitmaps into PNG, and vector graphics (e.g. SVG) into PDF. pdflatex understand both PNG and PDF.

Kaarel
+8  A: 

You can include a PDF image directly into a LaTeX document if you want to produce your final output using pdflatex, but not if you want to produce a dvi file.

pdflatex can use PDF, PNG, and JPEG

latex/dvips can use PS, EPS

See more details:

John D. Cook
+1  A: 

As John D. Cook says, your available image formats depend on whether you are using latex or pdflatex.

I find ImageMagick a useful tool for converting images between formats. Handles bitmap images, plus ps/pdf/eps (with ghostscript) and a zillion others. Available through apt, macports, etc.

John Fouhy
+2  A: 

If you have an image "as PDF", and you don't want to include it as pdf, you may want to extract the complete image data first with pdfimages. Other conversions may render the image only with reduced resolution.

Svante
A: 

If you compile your code with pdflatex, then you also can use the \includegraphics to include images in pdf (you have to include the package graphix

Bellman
A: 

I use a mac so I use GraphicConverter to load images and export as PDFs. When I draw diagrams, I use Omnigraffle which lets me export as PDFs. On windows I used to use Visio which supported EPSs which I also had no problems embedding.

Uri
+1  A: 

The basic issues are that a) you want to handle raster and vector images differently and b) this introduces potential pitfalls.

The "right" thing to do depends a bit on your final output.

If your final output is going to be a .pdf file, and you don't need pstricks or anything else that these days you're probably better off just using pdflatex to directly produce the file.

In this case:

  • store all vector figures as .pdf
  • store all raster figures as .png (or jpeg if they were originally jpeg)
  • use graphicx package and \includegraphics{filename-without-suffix}

If you don't do the above, your raster figures will be converted to jpegs and may gain compression artifacts. png is the best bet if you can choose output.

If you are headed for .dvi file you're going to want .eps for everything. (You can gzip these files as long as you generate a bounding box file).

If you're careful you can do both. I store all vector figures as (compressed) .eps because there are a few things .pdf can't do that .eps can. I store all raster figures as .png. Using make, I can have temporary copies of these canonical versions generated on the fly for .dvi or .pdf output as needed.

Someone above pointed out the filename issue. You want to avoid "." in the file names, and avoid suffixes always in your latex file itself.

simon