Hey' I'm trying to use the radians unit with siunitx package like so:


and I get:

Package siunitx Error: Invalid token '\protect ' in numerical input. ^^I\rad{\dfrac{\pi}{3}}
Package siunitx Error: Invalid numerical input '\protect {\displaystyle(siunitx) {\begingroup \pi \endgroup \@@over \relax 3}}'. ^^I\rad{\dfrac{\pi}{3}}

I guess fractions aren't considered numerical inputs? What can I do about that?

  • 4
    \SI parses the first argument, and thus cannot handle abitrarily formatted input. You might want to try if \SI[parse-numers=false]{#1}{\radian} (untested). Also please post a full but minimal example that others can just copy and test instead of a sniplet link this. Here we have to guess and a lot of people does not bother and passes on the question. Others may try it but their choices for the rest of the code might be different than yours – daleif Oct 29 '20 at 15:26

siunitx parses numbers for you. It also provides options for almost every aspect of how they are then formatted. You can just tell it to use \dfrac for quotients (cf. section 5.7 of the documentation).







MWE output

If you really want to, you can of course still use the \rad macro you defined.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.