views:

54

answers:

4

Hi,

I have problems to insert a figure into my .tex file. This is the code:

\begin{figure}
 \includegraphics[width=1\textwidth]{Blockdiagram}
  \caption{Diagram}
  \label{figure:BlockDiagram}
\end{figure}

It says that it cannot find the file! The same with Blockdiagram.png.

The figure is in the same folder. The main .tex is outside this folder, and I tried copying the image there, but the problem persists.

If I type H for help I have:

I could not locate the file with any of these extensions: .eps, .ps....

¿??¿ It's a png! I have both:

\usepackage{graphicx}
\usepackage{epsfig}

And I tried commenting epsfig.... but nothing happens.

Same error.

Any ideas¿¿?

EDIT: I have several PNG files, is it possible to use PNG files? I am using LEd under WinXP.

Thanks

A: 

latex is looking for Blockdiagram.eps, not Blockdiagram.png . Ideally you should try to use graphics in vector eps format. How did you create your diagram? (what software etc?)

E.g. matlab can export to eps as well as png. Inkscape is a good program for drawing vector images from scratch.

edit: to convert you can use sam2p or this online tool

second
Well, I will do that for new images, but I have a lot of PNG files now... what can I do?Why is looking for eps¿? Can I use PNG or other formats? I did it before... The same code in a different editor works, but I must use this now...
andofor
I tried converting the file to EPS with the online tool, but nothing :/
andofor
stranged, worked for me. gimp www.gimp.org can save to eps
second
A: 

Try using sam2ps to convert your images to eps format - I had a similar problem once where building to DVI would work with PNGs, but building to PDF would then fail unless I had EPS files.

Andy
I have same problem when I compile PDF or LaTeX.
andofor
+3  A: 

You could use PDFLaTeX instead of LaTeX. PDFLaTeX can import PNG images. You cannot use EPS images in PDFLaTeX, though; you would have to use PDF as a vector image format. I would recommend to use ImageMagick to convert images.

Svante
A: 

Andy & Svante are right: you are generating a DVI file & graphicx handles graphics in DVI files using Postscript specials, which can't handle PNGs. When generating a PDF, the graphicx can handle PNGs (and not .eps).

What's confusing is that using Pdftex does not ensure that you generate a PDF: if you invoke Pdftex with latex, it drops back into Web2c-compatibility mode, and generates a DVI. You mush explicitly invoke it using pdflatex.

Or use Xetex, which these days only generates PDFs. Invoke that with xelatex, if you have it.

There's no way to use both EPS figures and PNGs natively in one Latex file (at least not until Taco Hoekwater implements his Postscript interpreter in Luatex...), and 'til then, you must choose and use one of the many fine converters that are available.

Charles Stewart