There are two separate issues here: how to redefine variable content any how to alter what you see with siunitx
.
In terms of setting expl3
variables, the normal approach is to use \<thing>_set:Nn
. Here we have a token list, and if you put
\ExplSyntaxOn
\tl_show:N \c__siunitx_minus_tl
\ExplSyntaxOff
after \begin{document}
you will find it has been altered. I'll come back below to why that's not working in the output.
What you will notice here is that the variable is formally a constant (\c_...
), so we should not attempt to set it. One can argue about whether this should be a constant, but as it is the conceptually more 'correct' way to deal with this situation is arguably to delete and recreate
\cs_undefine:N \c__siunitx_minus_tl
\tl_const:N \c__siunitx_minus_tl { + }
(The outcome is much the same, of course: ultimately we are dealing with a TeX macro.)
So why do you see no change? With the standard settings, siunitx
uses math mode for printing numbers, and that means that -
is passed through directly: \c__siunitx_minus_tl
is not used. You will need to force text mode
\documentclass{article}
\usepackage{siunitx}
\sisetup{mode = text}
\ExplSyntaxOn
\cs_undefine:N \c__siunitx_minus_tl
\tl_const:Nn \c__siunitx_minus_tl { + }
\ExplSyntaxOff
\begin{document}
math mode $\num{-42}$
text mode \num{-42}
\end{document}
Of course, with expl3
we don't generally encourage altering internal values from other code. Here, siunitx
has been something of a 'test case' for expl3
and when the current code was written the exact approach required in terms of interfaces was still being refined. I'd expect a v3 release of the package to have clearer interface set up, probably including a public name for \c__siunitx_minus_tl
. (Work is ongoing on v3: tricky but I hope doable.)
expl3
andlatex3
are, please suggest re-tagging if you think something else would be more appropriate.