[Tex/LaTex] Use unit name instead of unit symbol with siunitx

siunitxunits

Is it possible to ask siunitx to output the unit name instead of the symbol?

For example, in certain places I want to have "123 nanoseconds" instead of "123 ns".

Is that possible?

Best Answer

You can declare your own unit. In the following example I have declared the unit \nsec. As daleif pointed out, the spacing between the number and the spelled out units is too tight. I used the option number-unit-product to increase the spacing of the unit \nanosec:

\documentclass{article}
\usepackage{siunitx}
    \DeclareSIUnit\nsec{\text{nanoseconds}}
    \DeclareSIUnit[number-unit-product = \ ]\nanosec{\text{nanoseconds}}

\begin{document}
\noindent
It takes about \SI{123}{\nsec} to compile this document.\\
It takes about \SI{123}{\nanosec} to compile this document.\\
It takes about $123$~nanoseconds to compile this document.\\
\end{document}

compiled

Be advised that you can not declare it as \ns. I tried that, but apparently it is used internally by siunitx as the macro for ns. It does not give an error about that, but simply displays the number ans units as 123 ns instead, thereby ignoring your custom SI unit.

Related Question