The MWE below points out that expl3
booleans value are printed as Γ and ∆ (or, if \usepackage[T1]{fontenc}
is used, as back and forward quotes ` and ́) depending whether they are false or true:
\documentclass{article}
\usepackage{xparse}
\usepackage[T1]{fontenc}
\ExplSyntaxOn
\bool_new:N \falsebool
\bool_new:N \truebool
\bool_set_true:N \truebool
\cs_new_protected:Nn \_boolean_value:n
{
A~\bool_if:NTF {#1}{true~($=1$)}{false~($=0$)}~ boolean~ is~ printed~ as:~#1
}
\NewDocumentCommand { \displaybooleans } { m }
{
\_boolean_value:n{#1}
}
\ExplSyntaxOff
\begin{document}
\begin{itemize}
\item \displaybooleans{\falsebool}
\item \displaybooleans{\truebool}
\end{itemize}
\end{document}
Do you know why? Why, outside tests, aren't their values printed as e.g. 0 and 1?
Edit
Here is the background, the real use case: in a package of mine, which is coded thanks to expl3
, I provide some (in fact many) options that let the user fix floating points variables, token list variables, boolean variables, etc. And I consider to provide a macro that displays all the options (default ones and user defined ones) in use. The floating points variables and token list variables can be printed in a rather direct way:
The nice floating point variable is set to: \fp_use:N\g_a_nice_floating_point_variable_fp
(though one could expect in a typesetting context, by opposite to a computing context,The nice floating point variable is set to: \g_a_nice_floating_point_variable_fp
to be enough, i.e.\fp_use:N
to be superfluous),The nice token list variable is set to: \g_a_nice_token_list_variable_tl
.
And my question is: in order to print the current value of a boolean variable, is it necessary to go through a \bool_if:NTF \g_a_nice_boolean_variable_bool { ... } { ... }
test to print its current value or is there a more direct way to do?
\_boolean_value:n
control sequence.\bool_if:NTF \l_db_bool { 1 } { 0 }
. In any case, you are now expecing1
and0
, but may be in other contexts other may expecttrue
andfalse
for instance.\cs_new:Npn \db_bool_use:N #1 { \bool_if:NTF #1 { 1 } { 0 } }
and there you go,\tl_use:N \l_tmpa_tl
,\fp_use:N \l_tmpa_fp
and\db_bool_use:N \l_tmpa_bool
. But again, it's logic what a\tl_use:N
and\fp_use:N
should do, but\bool_use:N
has no obvious standard definition (I have yet to find a moment in the last few years in which I needed a default function that converted a true bool to a1
token and a false bool to a0
token).