Brendan
Brendan

Reputation: 19393

How to convert an image (i.e. pdf) for use in a LaTeX document?

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.

Upvotes: 4

Views: 17154

Answers (10)

simon
simon

Reputation: 7022

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.

Upvotes: 1

Uri
Uri

Reputation: 89799

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.

Upvotes: 1

Bellman
Bellman

Reputation: 152

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

Upvotes: 0

Svante
Svante

Reputation: 51511

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.

Upvotes: 2

John Fouhy
John Fouhy

Reputation: 42193

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.

Upvotes: 1

John D. Cook
John D. Cook

Reputation: 30089

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:

Upvotes: 10

Kaarel
Kaarel

Reputation: 10672

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

Upvotes: 5

Volker Stolz
Volker Stolz

Reputation: 7402

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

Upvotes: 1

Brendan
Brendan

Reputation: 19393

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}

Upvotes: 1

Mork0075
Mork0075

Reputation: 5945

I always include images in PNG format.

Upvotes: 0

Related Questions