1

I have a problem when using the siunitx package, specifically when using the detect-all option and trying to use the \pi symbol as a number.

Minimum working example (MWE) below:

\documentclass{article}
\usepackage{XCharter}
\usepackage{siunitx}

\begin{document}

This works happily: \SI{2\pi e15}{\radian\per\second}

\sisetup{detect-all,}
But this gives an error : \SI{2\pi e15}{\radian\per\second}.

\end{document}
4
  • What does \sisetup{detect-all,} do?
    – Someone
    Apr 21 '20 at 14:16
  • \sisetup{detect-all} is an option for the siunitx package, which essentially makes all usage of numbers and units with the package "fit in" with the text around them. So while \SI{10}{m} will normally use whatever Maths font is loaded when used in the middle of a standard text section (which looks odd, in my opinion), it will instead change the font to the standard font if \sisetup{detect-all} is enabled.
    – bth-root
    Apr 21 '20 at 15:21
  • @bth-root - The explanation "it will instead change the font to the standard font" is not quite right. Rather, it's the current font -- which need not be a "standard" font -- that'll be used. What is "current" is determined at the start of the operation of the \SI macro.
    – Mico
    Apr 21 '20 at 16:06
  • 1
    @Mico - Thanks for the clarification. Mine was definitely a layperson's explanation - it's good to have the proper description down for posterity.
    – bth-root
    Apr 22 '20 at 8:53
1

If you run \sisetup{detect-all}, siunitx requires the entire \SI directive to be in math mode in order to process \pi correctly, i.e., it requires you to run

$\SI{2\pi e15}{\radian\per\second}$

On p. 5 of the package's user guide, one finds:

By default, all text is typeset in the current upright math font. This can be changed by setting the appropriate options: \sisetup{detect-all} will use the current font for typesetting.

What this means is that if detect-all is in force, siunitx does not automatically use a math font to generate the output of \SI and \si. Thus the need for the $ symbols.


enter image description here

\documentclass{article}
\usepackage{XCharter,siunitx}
\begin{document}
\SI{2\pi e15}{\radian\per\second}

\sisetup{detect-all}
$\SI{2\pi e15}{\radian\per\second}$
\end{document}
1
  • Just a follow on from this, as I wanted to avoid using a math font in the main text of my document: a once-off, slightly ugly fix was to input the "2pi" and "times" symbol separately from the rest of the SI macro, with appropriate spacing, as follows: 2\textpi\,$\times$\,\SI{e15}{\radian\per\second} (Doing so required loading the \textgreek package for the pi symbol.)
    – bth-root
    Apr 22 '20 at 12:26

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.