Is there a way to format number strings while printing?
Suppose I have the following declaration:
\newcommand{\MyNumberA}{40}
\newcommand{\MyNumberB}{60}
The following in the text:
\the\numexpr(\MyNumberA*\MyNumberB)\relax
will produce 2400. I want to print 2,400 or 2,400.00.
Am I asking too much or this can be done? How?
Best Answer
You can use
siunitx
package to do this:which produces:
You can define your own command to handle this too:
Regarding comment about non-integer values:
I would follow @egreg's suggestion and take advantage of the fact that
siunitx
uesesexpl3
internally. In this following example, I create a separate command to handle floating point values. I also provided the macro with two arguments. The first argument is optional to allow you to modify howsiunitx
handles its content: