xkeyval provides \DeclareOptionX which effectively defines a key like \define@key does but that can be used as a package option.

How can I \DeclareOptionXs that behave like \define@choicekey or \define@boolkey would?

I've done the following, but it isn't ideal.


This isn't great since the error doesn't refer to the key it should refer to, that is, to the key that the user sets.

Is there some obvious way of doing this that I am missing?

1 Answer 1


You do not have to use \DeclareOptionX to set up options using xkeyval. As with any other keyval package for LaTeX, anything which is set up as a key will work as an option for the appropriate family. Thus you can use \define@choicekey or \define@boolkey directly:

\define@choicekey*{fam}{key}{val1,Val2,VAL3}{You chose: #1}

makes key available as a choice key when loading the package or class the code is contained in.

  • 1
    Huh. I was fairly sure I tried exactly this and it didn't work! It does work now. I wonder what I was doing wrong... [Also, isn't it \DeclareOptionX not \DefineOptionX?]
    – Seamus
    Commented Jul 18, 2011 at 14:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .