[Tex/LaTex] Strip one level of braces for using keyval-value within nested keyval


I have defined my own figure command using xkeyval and I want to pass arguments for the nested \includegraphics as one of its keyvalues (maybe I stripped too much code, but I hope you get the idea):


    \setkeys[foo]{bar}{options={}, label={}, caption={}}


I want to use it like:

\MySpecialFigure[options={width=0.5\textwidth, draft}, 
                 caption={My Caption}]

Because of the braces around the options, the whole block gets parsed as one value at \includegraphics and behaves like:

\includegraphics[{width=0.5\textwidth, draft}]{my-pic.png}

I get error:

Package xkeyval Error:'width=0.5\textwidth, draft' undefined in families 'Gin'

I tried


but that wouldn' strip the braces either.

How can I solve this?

Best Answer

You need to expand the \FooBarOptions before you feed it to \includegraphics, otherwise it is taken as one key. This has nothing to do with an extra layer of braces.





should fix it.

Related Question