Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This question already has an answer here:

Is there a way to define a new command so that existing

\includegraphics[scale=x]{fig_name}

becomes

\includegraphics[scale=x]{fig_name.eps}

for any x and fig_name? This is for automatic conversion of eps to pdf because eps may cause out of memeory issues with xdvipdfmx: xdvipdfmx out of memory.

share|improve this question

marked as duplicate by Werner, Claudio Fiandrino, Thorsten, Jesse, ChrisS Apr 3 at 7:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer 1

up vote 2 down vote accepted

If all your usages exclude the use of a file extension, then you can simply do

\usepackage{graphicx,letltxmacro}
\LetLtxMacro{\oldincludegraphics}{\includegraphics}
\renewcommand{\includegraphics}[2][]{\oldincludegraphics[#1]{#2.eps}}

which would transform

\includegraphics[*]{**}

to

\includegraphics[*]{**.eps}

The use of letltxmacro is required in order to cope with the optional argument of \includegraphics. See When to use \LetLtxMacro?

Alternatively, and perhaps much easier, you can use

\DeclareGraphicsExtensions{.eps}

See File format preference with graphicx.

share|improve this answer

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