I pass a bunch of numbers into a custom command defined via \newcommand{\mycmd}[1]{...}
:
\mycmd{1.12}
\mycmd{5.32}
\mycmd
uses the number to draw a certain figure. On top of that, I would like to print the number in \mycmd
, but with a comma instead of a decimal point: 1,12
, 5,32
.
Any suggestion would be appreciated.
Best Answer
I'm sure the
siunitx
package is the way to go because it will catch all corner cases. Out of curiosity, here is a simple solution that uses TeX's pattern matching capabilities.Note that it won't work if you pass an argument that has no dot, like
\mycmd{2}
. Is this too simple and there is something else that I have overlooked?