# [OS X TeX] Error with graphicx/keyval

Manfred Braun manfred.braun at uni-due.de
Fri Aug 13 17:18:33 EDT 2010

On Aug 13, 2010, at 8:49 PM, Chris Goedde wrote:

> Hi all,
>
> Can someone explain to me why the following doesn't work, and what would work instead?
>
> \documentclass[11pt]{article}
>
> \usepackage{graphicx}
>
> \newcommand{\Size}{width=1in}
>
> \begin{document}
>
> \includegraphics[\Size]{testfig}
>
> \end{document}
>
> The error I get is ! Package keyval Error: width=1in undefined.

Apparently the optional argument \Size is not expanded before it is passed to keyval. One possibility is to write

\expandafter\includegraphics\expandafter[\Size]{testfig}

(The first \expandafter jumps over the command \includegraphics, the second over the opening bracket, then the parameter \Size is expanded.)
Of course one can define a macro

\newcommand\Includegraphics{\expandafter\includegraphics\expandafter}

which does the expected job, i.e.,

\Includegraphics[\Size]{testfig}

The solution might be not very elegant, but it works.

Manfred