I'd like to define some figure/graphic sizes in the preamble and then reference those in the \includegraphics
options throughout the document (this way, I can change the size once and it will change throughout the entire document). Here's an example of what I'm trying to do (it gives me a "package keyval error"):
%%
\documentclass[11pt]{article}
\usepackage{geometry}
\usepackage[demo]{graphicx}
%%GRAPHIC/FIGURE SIZES%%
%FULL PAGE GRAPHIC
\newcommand{\grfull}{width=6.25in,height=9.25in}
%LARGE GRAPHIC
\newcommand{\grlarge}{width=5.25in,height=6.5in}
%NORMAL GRAPHIC
\newcommand{\grnormal}{width=4.25in,height=5.25in}
%SMALL GRAPHIC (FOR WRAPFIG)
\newcommand{\grsmall}{width=3.5in,height=4.25in}
%TINY GRAPHIC (FOR SUBFIG)
\newcommand{\grtiny}{width=3.2in,height=3.8in}
\begin{document}
Here's the working figure:
\begin{figure}[htbp]
\centering
\includegraphics[width=3in,height=2in]{example}
\caption{example caption 1}
\label{fig:example1}
\end{figure}
The text substitution works here for \grtiny and for \grsmall .
Here's the non-working figure:
\begin{figure}[htbp]
\centering
\includegraphics[\grsmall]{example}
\caption{example caption 1}
\label{fig:example1}
\end{figure}
\end{document}
%%
Is \newcommand
the right command for this task or should I be using something else?
Best Answer
It works if you use
\expandafter
for expanding your macro before\includegraphics
is called: