\documentclass[a4paper,10pt,twoside]{book}
\usepackage[demo]{graphicx}
\begin{document}
\newcommand{\scalefactor}{scale = 0.25}
\begin{figure}[!ht]
\centering
%Next line does not work
\includegraphics[\scalefactor]{image}
% The following line works
%\includegraphics[scale = 0.25]{image}
\end{figure}
\end{document}
Output:
! Package keyval Error: scale = 0.25 undefined.
I need to scale a number of images by the same factor, hence the command.
- How to solve this and more importantly
- Why is this only specific to
\includegraphics
\expandafter\includegraphics\expandafter[\scalefactor]{image}which is longer than the intented shortcut. – percusse Feb 08 '13 at 12:31\includegraphicsbut of most (if not all) arguments that consist of key=value options. – egreg Feb 08 '13 at 12:35\expandafterhurt the general case? If not clear please let me know I will edit the question – aiao Feb 08 '13 at 12:47=to split both parts. If it is included in a macro it can see it and therefore the whole macro is incorrectly taken as one value-less key, which is of course not defined. – Martin Scharrer Jun 25 '13 at 10:30