Following up this answer, I would like to create a \num
-based command that nullifies the white space from the left side of a binary operator and keeps the space on its right side.
In other words, I need to keep the minus sign, in the first line of the example below, aligned with the page margin while having a white space between it and number 3
as that surrounding the minus sign of the second line.
\documentclass{article}
\usepackage{siunitx}
\usepackage[showframe]{geometry}
\ExplSyntaxOn
\NewExpandableDocumentCommand{\snum}{O{}m}
{
\mathbin
{
\fp_compare:nTF { #2 >= 0 }
{ + }
{ - }
}
\num[#1]{ \fp_eval:n { abs(#2) } }
}
\ExplSyntaxOff
\parindent=0pt
\begin{document}
\def\numb{-3}
$\snum{\numb}$\\
${}\snum{\numb}$
\end{document}
Best Answer
The macro
\mynum
, defined in this answer, may be of interest to you.