I defined \mynum
for you which checks if the next token is of catcode “letter”.
\documentclass{article}
\usepackage{siunitx}
\ExplSyntaxOn
\NewDocumentCommand \mynum { o m }
{
\num [ #1 ] { #2 }
\peek_catcode_ignore_spaces:NT \c_catcode_letter_token { \, }
}
\ExplSyntaxOff
\begin{document}
Normal behaviour (very recommended)
\begin{equation}
\num{0,1234}\,a
\end{equation}
Desired behaviour
\begin{equation}
\mynum{0,1234}a
\end{equation}
\end{document}
You can also override the \num
command provided by siunitx
, which is not recommended. Therefore, I copied the definition of \num
from siunitx.sty
and appended the relevant bits.
\documentclass{article}
\usepackage{siunitx}
\ExplSyntaxOn
\RenewDocumentCommand \num { o m }
{
% begin from siunitx.sty
\leavevmode
\group_begin:
\IfNoValueF {#1}
{ \keys_set:nn { siunitx } {#1} }
\__siunitx_number_output:n {#2}
\group_end:
% end from siunitx.sty
\peek_catcode_ignore_spaces:NT \c_catcode_letter_token { \, }
}
\ExplSyntaxOff
\begin{document}
$\num{0,1234}a$
\end{document}
a
is some sort of unit you should use\SI{0.1234}{a}
. Also, while code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the\documentclass
and the appropriate packages so that those trying to help don't have to recreate it.