I'm trying to make a class file to help me draft bylaws for clubs, but I'm running into a problem with \includegraphics. I want to be able to define a club logo using a \logo command (see class file), with the option of passing options to \includegraphics, but it doesn't want to work.
Class file:
\ProvidesClass{bylaws_min}[2012/10/27 version 0.01 "alpha" Bylaws]
\NeedsTeXFormat{LaTeX2e}
\RequirePackage[margin=1in]{geometry}% Sets page margins
\RequirePackage{graphicx}% Allows adding images to documents
\newcommand{\logo}[2][\@empty]{\def\@logoopts{#1}\def\@logoimage{#2}}
\renewcommand{\maketitle}{%
\begin{center}
\ifx\@empty\@logoopts\includegraphics{\@logoimage}\else\includegraphics[\@logoopts]{\@logoimage}\fi
\end{center}%
}
Document file:
\documentclass{bylaws_min}
\logo[scale=2]{imagefile.jpg}
\begin{document}
\maketitle
\end{document}
I've tried both \logo[scale=2]{imagefile.jpg} (or some other option other than scale=2), or just \logo{imagefile.jpg}, and I get variations on this error:
Package keyval Error: scale=2 undefined.
See the keyval package documentation for explanation.
Type H <return> for immediate help.
...
1.7 \maketitle
I've played around with this for a while, and it seems that there are two problems. First, \ifx never sees \@logoopts as \@empty (in other words, the comparison always fails, and the \else statement always happens). Second, if I explicitly create an image like \includegrahpics[scale=2]{imagefile.jpg} in \maketitle, everything works, but if I try to pass it the options with \@logoopts it fails. But passing it the image file name with \@logoimage always works.
\includegraphicsis not expanded when the command is executed; however the error messages do expand things, so you findscale=2 undefined. If you mistype an option, for example\includegraphics[scaled=2]{file}, you'd getscaled undefinedand you can see that the part from=onward would not appear. – egreg Oct 29 '12 at 13:42