TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to define a key, which, if set, sets a boolean variable to false.

The documentation is not clear on that point. It states (source3.pdf, sect. 87, p. 134):

Defines <key> to set <bool> to <value> (which must be either true or false).

However, I cannot see where to put the false value in the key definition. <value> is not present in the synopsis. It seems that the default behaviour is to set <bool> to true.

share|improve this question
up vote 6 down vote accepted

The .bool_set:N key property is intended to work as

\keys_define:nn { module }
    key-name .bool_set:N = \l_my_bool

which will be used as key-name = true or key-name = false. If you want to have the key name alone to be equivalent to setting false, you need a default:

\keys_define:nn { module }
    key-name .bool_set:N = \l_my_bool ,
    key-name .default:n  = false

However, I'd probably use a raw .code:n approach, as this seems to be 'backward' compared to what I'd expect

\bool_new:N \l_my_bool
\keys_define:nn { module } 
    key-name .code:n = { \bool_set_false:N \l_my_bool } 
share|improve this answer
Thanks. So, if I understand correctly, a key-name defined as .bool_set:N always requires a value and key-name alone raises an error? Is there no implicit .default:n = true? – AlexG Apr 15 '11 at 15:30
@Alexander: It should set the default as true. – Joseph Wright Apr 15 '11 at 19:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.