I'm writing a package with two options; one of the defaults should change, depending on the other option. Currently, the definitions are:


Now, if the user provides either the write or the nowrite option, I want to obey that rigorously. If, however, neither option is given, then I want to default to write if bibfile is empty and nowrite otherwise.

My starter attempt is this (using xstring):

    \somehowsetoption{nowrite} if neither write or nowrite given

What's the simplest way to provide the \somehowsetoption command(s)? (Please note: changing the \Declare...s is OK.

I haven't included an MWE, as I think this is more about "how-to" rather than "what's-wrong".

1 Answer 1


You could use \AddToKeyvalOption{gitlog}{write}{...} to define some macro (the same for the nowrite option). Then said macro will only be defined if either option has been used and you can test for its existance. Here is a complete example that defines \gitLog@writeset only if either write or nowrite has been set (I use etoolbox instead of xstring – simply because I know it better):



% write:

% nowrite:

% bibfile:

% process options:

% check if write/nowrite has been set:
  {% write/nowrite option has not been set,
   % set boolean depending on value of \gitLog@bibfile:


% \usepackage{foo} % false
\usepackage[bibfile=foo]{foo} % true
% \usepackage[nowrite,bibfile=foo]{foo} % false
% \usepackage[write]{foo} % true



  • Thank you so much. I took the liberty of fixing one small, though important, bug. (:-)) Commented Nov 19, 2015 at 19:10
  • @Brent.Longborough you're welcome :)
    – cgnieder
    Commented Nov 19, 2015 at 23:27

You must log in to answer this question.

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