# [texhax] package option with arguments

Joseph Wright joseph.wright at morningstar2.co.uk
Mon Aug 3 20:26:33 CEST 2009

Arno Trautmann wrote:
> Hi!
>
> I’m trying to set up a package that has one optional argument. This
> option can have several values that can be combined, like
>
> \usepackage[exclude={greek,math}]{package}
>
> Later I want to check if the argument has a certain string in it, in
> this case e.g. if ”greek“ is given. I tried it with \in@ but had no
> success. This is my code:
>
> \DeclareOptionX{exclude}{\def\excludeoptions{#1}}
> \ProcessOptionsX
>
> \in@{greek}{\excludeoptions}
> \ifin@ \AtBeginDocument{greek is in}\fi
>
> I use xkeyval for option processing.
> \excludeoptions contains the expected string, but I did not manage to
> get a true \ifin@, no matter how I used \expandafter or similar things.
>
> Is this a total wrong way to do the task? Is there a tool that does it
> less low-leve? I am totally clueless at the moment :(
>
> cheers
> Arno

Is something like (I'm assuming e-TeX):

\def\package at test@exclude{%
\@for\@tempa:=\excludeoptions\do{%
\ifcsname package at option@\@tempa\endcsname
\@nameuse{package at option@\@tempa}%
\fi
}%
}
\ifx\excludeoptions\@emtpy\else
\expandafter\package at test@exclude
\fi

a possible?  This of course assumes each potential exclusion is created
as a macro. (You could then trap unknowns by, for example, using
something else in place of \@tempa and ensuring that each option will
clear it, so if after the \do loop there is still something in the
variable then it's not been matched.)
--
Joseph Wright