TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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]

\RequirePackage[margin=1in]{geometry}% Sets page margins
\RequirePackage{graphicx}% Allows adding images to documents



Document file:






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.

share|improve this question
Actually the error message is a bit misleading. As Heiko explains, the contents of the optional argument to \includegraphics is not expanded when the command is executed; however the error messages do expand things, so you find scale=2 undefined. If you mistype an option, for example \includegraphics[scaled=2]{file}, you'd get scaled undefined and you can see that the part from = onward would not appear. – egreg Oct 29 '12 at 13:42
up vote 3 down vote accepted

There is no need for \@empty as default argument. It only would costs extra work.


The option parser needs explicit key value settings:


If I remember correctly, then \@logoimage is expanded once by graphics. Otherwise it also would have to be expanded for parsing the file name.

share|improve this answer

Since the options and the image file must be expandable, we can avoid a chain of \expandafter.

% Default setting, in case Ben User calls \maketitle without first calling \logo:
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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