How to use the color package with dvips option together with the graphicx package?

I have a problem with the bounding box of my graphics.

Example 1 below, where I only include a PNG image works fine.

Example 2 below, where I also have \usepackage[dvips]{color} in order to include a PS file, does not work - the PNG image is blown up!

Code example 1

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}[htbp]
\includegraphics[scale=0.7]{irg.png}
\end{figure}
\end{document}


Code example 2

\documentclass{article}
\usepackage{graphicx}
\usepackage[dvips]{color}
\begin{document}
\begin{figure}[htbp]
\includegraphics[scale=0.7]{irg.png}
\end{figure}
\begin{figure}[htbp]
\includegraphics{irg2.ps}
\end{figure}
\end{document}

-
In general I would recommend you to use the extended xcolor package instead of color. It should support everything what color does and more. – Martin Scharrer May 31 '11 at 11:53

You cannot mix .png and .eps files in the same document. The short story is that

• if you're using pdflatex to compile your document then you can use .png, .jpg and .pdf pictures; while
• if you're using latex you can only include .eps.

The best solution is to stick to pdflatex and use epstopdf to convert your .eps figure to a .pdf (or, if possible, generate directly a .pdf from your source application).

And you don't need to load color (or xcolor) to include figures.

-
In TeXlive 2010 (or before with the epstopdf package), you can use .eps figures with pdflatex. And XeLaTeX has been able to use both for while now. And the tool is also called epstopdf not eps2pdf. Not sure about .ps files directly though. – frabjous Sep 29 '10 at 15:30
♦ Thanks! – AD. Sep 30 '10 at 7:54
@frabjous, thanks for your comment. I've corrected the name of the tool. – Juan A. Navarro Sep 30 '10 at 10:42

If graphicx is not told the output driver to use it will do its best at auto-detecting it. This is usually the best way to go by far. However, by loading color after graphicx you've told color to use (presumably) another driver than the one graphicx initialised, thus leading to the conflict which caused your figure to "blow up". (I say presumably because you'd need to identify your platform and your LaTeX compiler to know for sure.)

The solution is quite simple. Either,

1. remove the [dvips] driver option to color (do-able if you can convert irg2.ps to, say, pdf format first), or more simply,
2. load graphicx after loading color, i.e., swap the two \usepackage lines to allow graphicx's driver auto-detection routine to initialise itself for the driver you intend to use.

As a footnote, I'd recommend looking into using xcolor rather than color if you possibly can. It provides a more robust colour framework and cohabitates very much better with recent packages than color does.

-