3

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?

  • 1
    Welcome to TeX.SX! I guess the answer is no. I grepped in the siunitx files for nano and second, but couldn't find them as literal strings, just as part of command names. – gernot Mar 5 '17 at 16:08
  • 2
    You simply type $123$~nanoseconds. – egreg Mar 5 '17 at 16:15
  • 2
    Remember explicitly here, as egreg notes, that in this case the spacing between the value and unit name is a full word space, here a tie char to avoid line break – daleif Mar 5 '17 at 16:25
3

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.

  • Note that the spacing is wrong here (it can be specified as a part of the unit definition). Full word units should be separated from the value by a word space, which it clearly is not in your image. – daleif Mar 5 '17 at 18:02
  • Do you mean the spacing from number to units is too tight? How do you suggest it should be? I have compared it with ordinary units via siunitx, and the spacing is the same. – Lucademicus Mar 5 '17 at 18:14
  • Ordinary units are abbreviations, rules dictate a thin space when the units are presented as abbreviations, but here they are spelled out, and thus a full world space is needed. There are methods in siunitx to specify the spacing. I'm not at a pc, so cannot chech it. This is also the reason for egregs comment above, if I'd just easier that way, as one seldom spell the unit out in full. – daleif Mar 5 '17 at 18:44
  • 1
    I'll see if I can find the option. – Lucademicus Mar 5 '17 at 19:02
  • If Joseph will be happy with this?;-) – user31729 Mar 5 '17 at 19:12
3

This is just the same as

One day, a person went to a horse racing area. Instead of counting the number of humans and horses, he counted 74 heads and 196 legs. How many humans and horses were there?
(blatant advertising)

or something like Fifteen men on the dead man’s chest. The difference between the two is just that “big” numbers are usually written in numerals rather than spelled out fully.

When you write ”123 nanoseconds” you are not using a symbol, so the code should simply be

\num{123}~nanoseconds

I'd recommend \num for consistency with other usages such as \SI{123}{\nano\second}.

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.