16

Here is an example:

\documentclass{scrartcl}
\usepackage[quotient-mode = fraction]{siunitx}
\begin{document}
  \[\SI{1 / 2500 \pi ^ 2}{\micro \farad}\]
\end{document}

It produces:

siunitx error: "invalid-token-in-number"

Thank you for your help in advance!

3
  • 1
    siunitx expects a number, since it uses a parsing engine. Thus you can't give it stuff it would have to evaluate first. I don't know if there is a way to turn it off, but here you'd probably fare best to git for \[ {1 / 2500 \pi ^ 2}~\si{\micro \farad} \]
    – Timm
    Mar 16, 2017 at 12:31
  • @ Timm I assume that the OP does not want to have it evaluated, but just to get \pi squared ...
    – Jürgen
    Mar 16, 2017 at 12:37
  • @Jürgen: Is assumed that, I intended to use "evaluated" as a more general term for read-and-figure-out-what-it-is. Maybe a question for English Language & Usage ;).
    – Timm
    Mar 16, 2017 at 13:17

1 Answer 1

22

The number parser can be disabled using

\SI[parse-numbers=false]{1 / 2500 \pi ^ 2}{\micro \farad}

for this single case or generally with

\sisetup{parse-numbers = false}

As to the 'why' part: the package is focussed on physical quantities, and real measurements cannot delivery \pi^2 or similar as an outcome, only (here)

\SI{3.95e-3}{\micro \farad}

or similar

7
  • 1
    Though of course if you want to compare a measured value with a theoretical prediction, you might well want to typeset them the same - presumably hence why it's possible but not the default.
    – Chris H
    Mar 16, 2017 at 13:42
  • @ChrisH Perhaps though the value you are comparing will still be a real number
    – Joseph Wright
    Mar 16, 2017 at 17:35
  • Personally I use \si instead of \SI in cases like this. Sometimes you do want the units attached to an exact real or irrational value.
    – Chris H
    Mar 16, 2017 at 17:50
  • It would be interesting if the error message mentioned this option. Mar 16, 2017 at 18:52
  • Thank you @Joseph Wright and all other for the answer and comments! When I use parse-numbers = false then is the package option quotient-mode = fraction is disabled. Can I have both things? Thank you for your help in advance!
    – Su-47
    Mar 17, 2017 at 6:22

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.