I use pgfkeys to hold specific values (text). Now I'd be able to limit the possible values of that key (only some values valid). How is this possible with pgfkeys? (I saw .is choice but don't know how to use this to limit key values since its primarily use is for the .code or .style handler)

  • 1
    What't the current codes when no limit on key values is added? Oct 7, 2020 at 18:18
  • 1
    So you want to use \pgfkeys(getvalue|valueof) with that key while have the ability to only accept selected values? I mean, alternatively, you can use sth like \pgfkeys{mykey/.is choice, mykey/value1/.code={\def\store@value{value1}}}. Oct 8, 2020 at 20:54
  • 1
    \def is local to the current group, \gdef is global. Oct 8, 2020 at 21:56
  • 1
    Yes. And you can choose other macro names. Oct 8, 2020 at 22:06
  • 1
    "so that the macro cannot be used normally in normal LaTeX ... ?" Yes Oct 8, 2020 at 22:10

1 Answer 1


Perhaps you can define the key as

  mykey/.is choice,
  % more allowed values

and use \mykey@value to retrieve the value passed to mykey, like \pgfkeysvalueof{mykey} if it is defined by \pgfkeys{mykey/.initial}.

You must log in to answer this question.

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