In the package created by the following source, how can one change the value of \optB to true if \optA is true — so that the message written to the log would become >>> optB is true even though the option \optB=false had been passed to the package, as shown (but optA=true had been passed, as shown).

% what code here to switch value of optB *if* optA is true?
\ifMY@optB \typeout{>>> optB is true} \else \typeout{>>> optB is false}\fi

1 Answer 1


For each Boolean option three commands are created:

  • \if<prefix><option name> which acts as one of TeX's conditional commands,
  • \<prefix><option name>true to enable the option, and
  • \<prefix><option name>false to disable the option.

Based on these commands, you can easily define custom conditions to override the values passed from the user (after the \ProcessKeyvalOptions call). In your case it's simply:

  • Thank you for the explanation, not just the method. The explanation fleshes out, and puts together, the terse information in the kvoptions documentation (in section 2.2.2, where it says, for a boolean option verbose, that the corresponding switch is initialized as \foobar@verbosefalse; and the "Summary of internal macros" section 2.4, where it lists \if<prefix><key>true and \if<prefix><key>false to enable & disable the switch, respectively.
    – murray
    Jul 15, 2019 at 13:09

You must log in to answer this question.

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