I have a lot of experience using LaTeX with Miktex/TeXnicCenter on windows, but am only taking baby steps in learning how to do it on ubuntu. I am using Kile as IDE, since I got the impression from others that that was a good choice.

For some reason, I can't include .png images? My preamble is


and I am compiling using the "PDFLaTeX-button", such that the "Log and Messages" goes (for some reason it won't let me copy-paste):

[PDFLateX] metaStable.tex 0> metaStable.pdf (pdflatex)
[PDFLaTeX]finished with exit code 1
(some warnings about hyphenation patterns and the fact that no \author is given)
./metastable.tex:33:Unknown graphics extension: .png . figures/betterBarrier.png}
[PDFLaTeX] 1 error, 2 warnings, 0 badboxes

The offending bit of code is

figures/betterBarrier.png }

I assume I am doing something wrong in my build command, but I have no idea where to go look.

The output seems fine except for the lack of the figure.

  • 1
    It isn't necessary to put the file extension in the \includegraphics command (i.e., you can just use \includegraphics{figures/betterBarrier}, that way you can easily change the file format), but I don't think it should cause problems either. Have you tried making a bare bones document that only contains the image - maybe one of the other packages is interfering? – James Feb 8 '12 at 12:15
  • yes, I have tried that (using only documentclass, graphicx and pdfpages), still the same error. – Kaare Feb 8 '12 at 14:23
  • I don't know what you actually tried, but you need to drop the extension. So just figures/betterBarrier without the .png. – Roelof Spijker Feb 8 '12 at 15:12
  • @wh1t3 You may drop the extension, but it should never be wrong to include it. – David Carlisle Feb 8 '12 at 15:15
  • 1
    @DavidCarlisle: You are right. However, if the OP has an eps and a png version of the file then removing the extension will allow him to compile with either latex or pdflatex without problems. It shouldn't cause an error though, that's certainly true. Reading my comment again it does indeed look like I suggest that it does. – Roelof Spijker Feb 8 '12 at 15:44

Two things here:

  1. You should usually not add an extension to your graphics: LaTeX will pick it up automatically
  2. If you do give an extension, watch spaces. You have {figures/betterBarrier.png }, which has a space at the end and so looks for an extension '.png ', and which is therefore wrong. Remove the space.
  • 1
    This answer's better than mine so I've deleted mine. If we do this again we should probably strip trailing spaces, perhaps. – David Carlisle Feb 8 '12 at 15:53
  • @DavidCarlisle I'm going to revise the file module for LaTeX3 later today. Stripping spaces is on the list. (More generally, there is a feeling that all functions of the \foo{ ... } should remove spaces at the ends of their arguments. Easy enough using xparse.) – Joseph Wright Feb 8 '12 at 15:58
  • yes, that solved it. I eventually took a working example from TeXnicCenter, which of course turned out to compile fine with Kile / TeXLive as well, and worked out the problem from there. thanks :) – Kaare Feb 9 '12 at 21:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.