I need to prepare a PDF and PS file from the same latex source but got stuck on including figures. When using pdflatex I can insert a png file like:


However, this does not work when producing the PS file. To produce PS I need to set the bounding box and set the scale differently. For the same figure my code looks like this:

\includegraphics[scale=0.073,bb=0 0 2200 1510]{figure.png}

Now I'd like to switch between these two versions depending on the output I want to produce: PS or PDF. Is there any way to determine the output automatically so I can use a conditional clause like ifthenelse to switch between the commands?

Do you know any easier way to include png files in PS and PDF?

  • There's an ifpdf package, but how are you including a png when producing postscript?
    – TH.
    Aug 16, 2011 at 12:24
  • I use MiKTeX; it just works. And ifpdf does the trick! Thanks.
    – Jacek
    Aug 16, 2011 at 12:31

1 Answer 1


do not use an extension, nearly all drivers can detect the mode automatically and will then use the image depending to the used command pdflatex or latex. The mode can be detected inside a document with:


  do something pdf specific
  do something non-pdf specific
  • But this does not solve the issue and also when not using the extension latex complains it can't find file 'figure'...
    – Jacek
    Aug 16, 2011 at 12:21
  • 3
    for latex you need an eps version of the figure
    – user2478
    Aug 16, 2011 at 12:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .