0

siunitx is a package that provides several macros to autoformat numbers along with prefixes and units. There is also a \num{} macro, that lets the user format a stand-alone number without any prefix or units attached. I found this macro to be really handy, because it automatically formats for thousands-separator, rounding, is able to do exponential formatting etc.

When should I use this macro instead of just using math-mode ($\pi = 3.14159$ vs. $\pi = \num{3.14159}$)?

0

1 Answer 1

1

The rule is that the International Bureau of Weights and Measures states that "when there are only four digits before or after the decimal marker, it is customary not to use a space to isolate a single digit". i.e, is not only that "3.141 5" is not more readable, it is also that it seems mistyped. In Spanish, where there are an undisputed language authority, the Real academia Española (RAE), the official rule is congruent with this bureau, so the rule is "more than four".

So with four or fewer digits is only a problem of pragmatism: type 3.141 5 is just easier that type \num{3.1415} because the command correctly does nothing on these cases, so there are no question here.

For more, the separator may be used, i.e., it is a recommendation, not a rule, so the real dilemma is readability:

Have you any doubt about the convenience of use \num with 3.1415926535897932384?

Is not an easy question, because indeed is easier to read with spaces for humans, but not for computers (e.g., a search failed because of the lack of the spaces). So the real question is the benefits in readability. The shorter the numbers, the less profit in readability. Thus:

Is it still "3.141 59" more readable than "3.14159"?

Well, it is a debatable question, but if you disregard the rule of "more than four" only in these cases the lack of consistency in the format of long numbers may even confuse to the readers (i.e., people can wrongly count four decimals when there are five, because the lack of the separator).

In summary, use \num{3.14159} if you will use \num{} somewhere else in the document. In case of doubt, always use \num with \sisetup{group-minimum-digits=5}, so if you change your mind later, it is enough change the setup in the preamble.

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.