开发者

Includegraphics problems with a PNG [closed]

开发者 https://www.devze.com 2023-01-11 10:15 出处:网络
Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed. This question is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 9 years ago.

Improve this question

I have problems to insert an image 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 o开发者_如何学Pythonf these extensions: .eps, .ps....

It's a png! In the file 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.


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.


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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消