TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

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

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
share|improve this answer
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 '11 at 12:21
for latex you need an eps version of the figure – Herbert Aug 16 '11 at 12:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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