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.
尝试使用 sam2ps 将图像转换为 eps 格式 - 我曾经遇到过类似的问题,构建为 DVI 可以使用 PNG,但构建为 PDF 会失败,除非我有 EPS 文件。
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.
发布评论
评论(4)
您可以使用 PDFLaTeX 代替 LaTeX。 PDFLaTeX 可以导入 PNG 图像。不过,您不能在 PDFLaTeX 中使用 EPS 图像;您必须使用 PDF 作为矢量图像格式。我建议使用 ImageMagick 来转换图像。
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 是对的:您正在生成 DVI 文件 & Graphicx 使用 Postscript 特殊格式处理 DVI 文件中的图形,而后者无法处理 PNG。生成 PDF 时,graphicx 可以处理 PNG(而不是 .eps)。
令人困惑的是,使用 Pdftex 并不能确保生成 PDF:如果您使用
latex
调用 Pdftex,它会返回到 Web2c 兼容模式,并生成 DVI。您必须使用 pdflatex 显式调用它。或者使用 Xetex,目前它只能生成 PDF。如果有的话,请使用 xelatex 调用它。
没有办法在一个 Latex 文件中同时使用 EPS 图形和 PNG(至少在 Taco Hoekwater 在 Luatex 中实现他的 Postscript 解释器之前是这样),并且在此之前,您必须选择并使用众多优秀的转换器之一可用。
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 usingpdflatex
.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.
尝试使用 sam2ps 将图像转换为 eps 格式 - 我曾经遇到过类似的问题,构建为 DVI 可以使用 PNG,但构建为 PDF 会失败,除非我有 EPS 文件。
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 正在寻找 Blockdiagram.eps,而不是 Blockdiagram.png 。理想情况下,您应该尝试使用矢量 eps 格式的图形。您是如何创建图表的? (什么软件等?)
例如,matlab 可以导出为 eps 以及 png。 Inkscape 是一个从头开始绘制矢量图像的好程序。
编辑:
要进行转换,您可以使用 sam2p 或此在线工具
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