3

In the MWE below I was expecting that even with the option parse-numbers=false. I would have the f written in math mode, not as regular text.

\documentclass{article}

\usepackage{siunitx}
\sisetup{detect-all}

\begin{document}

\noindent
using siunitx (normal): $\SI[parse-numbers=false]{f \pm \Delta}{\Hz}$\\
using siunitx (hacked): $\SI[parse-numbers=false]{\text{$f$} \pm \Delta}{\Hz}$\\
math: $f$\\
roman: f

\end{document}
  • Why not use \si{} instead? \SI{}{} is for typesetting numbers with units, not units alone. – erik Sep 30 '15 at 0:31
  • @erik - Maybe the OP is keen on getting the correct space between \Delta and Hz -- which won't be obtained if one writes $f\pm\Delta\si{\Hz}$. – Mico Sep 30 '15 at 1:24
  • The main idea was in fact to use the correct spacing – cacamailg Sep 30 '15 at 3:06
  • In that case I think $f \pm \Delta\,\si{\Hz}$ would do the trick. I also like that \SI{}{} handles the spacing automatically, but the function is designed to accept numbers in the first argument, which is why parse-numbers=false isn't useful if you don't have numbers. – erik Sep 30 '15 at 3:18
  • It is written in math mode, but in \mathrm as that's the most sensible font choice on average (it's a number so any non-digit content should be upright not italic). – Joseph Wright Sep 30 '15 at 5:12
3

While the siunitx package greatly simplifies typesetting and spacing of numbers, angles, units, etc., this question demonstrates how \SI{}{} expects numbers in the first argument (and the reason for having a separate function \si{}). In this case, I think using the units-only command \si{} and explicitly defining the spacing with \, is the better approach. The results should be identical.

\documentclass{article}
\usepackage{siunitx}
\sisetup{detect-all}
\begin{document}
\noindent
$\SI[parse-numbers=false]{f \pm \Delta}{\Hz}$\\
$\SI[parse-numbers=false]{\text{$f$} \pm \Delta}{\Hz}$\\
$f \pm \Delta\,\si{\Hz}$\\
math: $f$\\
roman: f
\end{document}

enter image description here

| improve this answer | |
1

I preferred to use \SI[parse-numbers=false]{\text{$f \pm \Delta$}}{\Hz}.

\documentclass{article}
\usepackage{siunitx}
\sisetup{detect-all}
\begin{document}
\noindent
$\SI[parse-numbers=false]{f \pm \Delta}{\Hz}$\\
\SI[parse-numbers=false]{\text{$f \pm \Delta$}}{\Hz}\\ % <- my solution
math: $f$\\
text: f
\end{document}
| improve this answer | |

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.