f



setting TeX text variable depending on keyval-generated param? (low-level TeX question)

I am using keyval to set a "scaled" parameter and am having trouble
getting the right behavior, which is:

If I \usepackage{package} with no [scaled] option, I want to set a
variable to a compile-time-specified default, say "s*[a.b]".

If I \usepackage[scaled]{package}, same thing.

And if I \usepackage[scaled=x.y], I want to set the variable to
"s*[x.y]".

(This is for font scaling, and I've used as my model the Helvetica
scaled parameter.)

The variable name (for the purposes of this conversation) is
pnm@scaled. What I have that's not working correctly is:

\expandafter\ifx\csname pmn@scaled\endcsname\relax
  \let\pmn@scaled\@empty
\else
  \edef\pmn@scaled{s*[1.2]}%
\fi

I think what this says is "if pnm@scaled is not defined (case 1), leave
it empty, otherwise set it to "s[1.2]". But  the else clause is not
working correctly, and I don't know how to differentiate between
"defined by keyval but with no value" and "defined by keyval but with a
value". Also I'm pretty sure I don't really know the difference between
\let and \edef. 

Any help gratefully appreciated. Thanks.

JDO

0
john_owens (39)
4/10/2006 10:02:08 PM
comp.text.tex 39027 articles. 3 followers. Post Follow

1 Replies
13000 Views

Similar Articles

[PageSpeed] 32

john_owens@yahoo.com  schrieb:

> I am using keyval to set a "scaled" parameter and am having trouble
> getting the right behavior, which is:
> 
> If I \usepackage{package} with no [scaled] option, I want to set a
> variable to a compile-time-specified default, say "s*[a.b]".
> 
> If I \usepackage[scaled]{package}, same thing.
> 
> And if I \usepackage[scaled=x.y], I want to set the variable to
> "s*[x.y]".
> 
> (This is for font scaling, and I've used as my model the Helvetica
> scaled parameter.)
> 
> The variable name (for the purposes of this conversation) is
> pnm@scaled. What I have that's not working correctly is:
> 
> \expandafter\ifx\csname pmn@scaled\endcsname\relax
>   \let\pmn@scaled\@empty
> \else
>   \edef\pmn@scaled{s*[1.2]}%
> \fi
> 
> I think what this says is "if pnm@scaled is not defined (case 1), leave
> it empty, otherwise set it to "s[1.2]". But  the else clause is not
> working correctly, and I don't know how to differentiate between
> "defined by keyval but with no value" and "defined by keyval but with a
> value". Also I'm pretty sure I don't really know the difference between
> \let and \edef. 

I'm not sure I have understand the problem, but to get the option 
[scaled] be equivalent to the option [scaled=1.2] you can use the 
optional argument that sets a default
\define@key{prefix}{scaled}[1.2]{...}

To get the \if-\else-\fi correct, I guess it would be enough if you 
define \pnm@scaled to be s*[1.2] at the start of your package, and then 
evaluate the package options. Either they will overwrite the predefined 
value or not. 

I would also suggest that you take a look at the xkeyval package. With 
it you can give keys preset values. 


-- 
Ulrike Fischer
e-mail: zus�tzlich meinen Vornamen vor dem @ einf�gen.
e-mail: add my first name between the news and the @.
0
news9686 (1970)
4/11/2006 7:44:48 AM
Reply: