9

With LaTeX3 and l3keys (included in expl3), is there a way to have a choice that includes a default value (or an empty choice)?

\documentclass{minimal}
\usepackage{expl3}
\begin{document}
\ExplSyntaxOn
\keys_define:nn {test}
  {
    font .choice:,
    font / sf .code:n = {},
    font .default:n = {},
  }
\keys_set:nn { test } { font= }  % ERROR
\end{document}

1 Answer 1

10

The .default:n part is for supplying a value when no = follows the key.

You can of course define an empty choice, if you want, and assign it also as the default value.

\documentclass{minimal}
\usepackage{expl3}
\begin{document}
\ExplSyntaxOn
\keys_define:nn {test}
  {
    font .choice:,
    font / sf .code:n = {sf},
    font / bf .code:n = {bf},
    font /  .code:n = {empty},
    font .default:n = {},
  }
\keys_set:nn { test } { font }
\par
\keys_set:nn { test } { font= }
\par
\keys_set:nn { test } { font=bf }
\end{document}

This will print

enter image description here

You must log in to answer this question.

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