# including .png images with PDFLaTeX through Kile

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

\documentclass[a4paper,10pt]{report}
\usepackage[latin1]{inputenc}
\usepackage{graphicx}
\usepackage[danish,UKenglish]{babel}
\usepackage[english]{varioref}
\usepackage{prettyref}
\usepackage{amsmath,amssymb,mathrsfs}
\usepackage{pdfpages}


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

\begin{figure}
\centering
\includegraphics[width=\LineWidth,keepaspectratio=true]{
figures/betterBarrier.png }
\end{figure}


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.

-

## migrated from stackoverflow.comFeb 8 '12 at 14:59

This question came from our site for professional and enthusiast programmers.

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
@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

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