11

How do I typeset the "spectral voltage noise density" unit "volt/sqrt(hertz)" with siunitx?

My naive (and unsuccessful) approach was:

\SI{100}[per-mode=symbol]{\nano\volt\per\sqrt{\hertz}}
sergej
  • 6,461
  • 32
  • 62

1 Answers1

12

siunitx sets units in text mode, so you have to ensure to be in math mode (thanks egreg and Joseph) for the root and then switch back to text for the unit. Not that complicated if you define a new unit and use it afterwards.

\documentclass{article}
\usepackage{siunitx}
\DeclareSIUnit{\sqrthz}{\ensuremath{\sqrt{\text{\hertz}}}}
\DeclareSIUnit{\voltnoise}{\volt\per\sqrthz}
\begin{document}
\SI[per-mode=symbol]{100}{\nano\voltnoise}
\[ \SI{3.5}{\mega\voltnoise} \sqrt{7} \]
\end{document}
Johannes_B
  • 24,235
  • 10
  • 93
  • 248
  • 1
    Of course, if you always want to have the fraction as the symbol, you can add the optional argument to the declaration. – Johannes_B Dec 21 '14 at 13:05
  • As of today (03.02.2018) one can use \sqrt in siunitx in text without further stuff, unless one uses the option detect-mode (or detect-all of course). Then the above seems to be a good workaround. – Skillmon Feb 03 '18 at 19:45
  • In siunitx v3 this does not work (\hertz undefined). I use \DeclareSIUnit{\sqrthz}{\ensuremath{\sqrt\mathrm{Hz}}}, but probably there is a smarter way. – Rmano Oct 24 '23 at 12:31
  • @Rmano you could as well define \hertz beforehand and use it then as done above. – Skillmon Oct 24 '23 at 12:32
  • @Skillmon \hertz is defined, the problem is that it is not "seen" inside the \sqrt (sorry, I expressed myself badly) – Rmano Oct 24 '23 at 12:35
  • @Rmano \sqrt{\unit{\hertz}} (also, in your comment above the braces after the \sqrt are missing, it should be \sqrt{\mathrm{Hz}}). – Skillmon Oct 24 '23 at 13:16
  • @Skillmon yes, you're right! – Rmano Oct 24 '23 at 14:55