[texhax] keyval package

Lars Madsen daleif at imf.au.dk
Tue Mar 22 20:17:22 CET 2005

Chris Bourke :

> I'm finding the keyval package documentation confusing; first a question:
> Up to now, I've avoided using the keyval package.  To get the same effect,
> I define something like
> \DeclareOption{font=sanserif}{ <my code here> }
> which simulates what the keyval package is doing.  My question is, if I
> continue to do this, will there be any problems?  Can I use this cheap
> trick instead of using keyval?
> I am trying to convert everything over to use keyval, but its not working
> so far.  For example,
> \define at key{font}{sanserif}{ <my code here> }
> by iteself, doesn't work.  Not only that, but when I use
> \usepackage[font=sanserif]{MyPackage}, it throws a Warning (unknown
> option).  I've check and rechecked the documentation, but It's not making
> sense to me.  Do I have to use \PassOptionsToPackage somehow?  Do I have
> to previously declare the entire set of values explicitly?  I've been
> looking at some other packages that use keyval but have the same problems.
> Does anyone have a *minimal* example that works?

this might help a bit

\newlength\my at height \setlength\my at height{1cm}
\newlength\my at width  \setlength\my at width{1cm}
\define at key{myseries}{height}{\setlength\my at height{#1}}
\define at key{myseries}{width}{\setlength\my at width{#1}}
   \rule{\my at width}{\my at height}%







the first argument to \define at keys is a kind of series such that keys with 
the same names but different series does not get messed up (or something 
like that), the second is the name of the key you want to use and in your 
code bit, #1 is equal to the argument given to the key.



``You cannot help men permanently by doing for them 
what they could and should do for themselves. ''
  -- Abraham Lincoln

More information about the texhax mailing list