3

I am facing the problem that in a collaborative research paper there are several different number formats within the text, if the number is not pasted in math mode.

For example: 10.000,00 or 10,000.00 or 10000 or 10000,00

I am looking for a solution, where I can wrap a function around a number and it is formatted in the whole document in the same way.

2
  • 2
    siunitx comes with a \num macro that does this and many other goodies
    – percusse
    Aug 16, 2015 at 12:31
  • Does the answer below solve your question? Dec 31, 2015 at 18:15

1 Answer 1

8

There is: \num from siunitx or \numprint from the paronymous package. Both work in tables (alignment of the decimal part symbol), are language-aware and highly customisable. You can have automatic rounding of numbers to a fixed number of decimals, a convenient way of typing numbers in scientific notation (6.022141e23 will produce a correct formatting of the Avogadro constant), thousand and thousandth separators, &c. See the documentations for details.

Here is a demo. As you can see, the defaults are different for numprint and siunitx:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{numprint, SIunitx}

\begin{document}

\begin{tabular}{ll}
\texttt{With numprint: } & Avogadro’s number is $ \mathrm{NA} =\numprint[mol^{-1}]{6.02214129e23} $\bigskip\\
\texttt{With SIunitx: } & Avogadro’s number is $ \mathrm{NA} =\SI{6.02214129e23}{\per\mole} $
\end{tabular}

\end{document}

enter image description here

6
  • I'm sure a few examples wouldn't go amiss. Currently, my money is on siunitx, as it offers a very wide range of functionalities for this, plus it is very actively and skilfully maintained. But I have yet to meet the homonymous package, googling didn't reveal much.
    – moewe
    Aug 16, 2015 at 12:45
  • @moewe:You made me find the word seems to be an americanism. Doesn't seem to exist in British dictionaries. Anyway, paronymous is more appropriate.Other than that, I'll follow you suggestion and try to add an illuminating example.
    – Bernard
    Aug 16, 2015 at 13:07
  • Oh! That was an embarrassing brain block on my part. Shame on me for not remembering my Greek lessons.... "Paronymous" is a word I haven't actually seen before (while "homonymous" should have been in the back of my mind), "of the same name" is probably a safer alternative for the likes of me.
    – moewe
    Aug 16, 2015 at 13:19
  • Yes, but the package lacks the backslash (sounds like a good title for a detective novel, don't you think? ;o)), whence the paronymous (παρ̀α means ‘near’ if I remember well).
    – Bernard
    Aug 16, 2015 at 13:30
  • I will give you that, true. Para can mean quite a lot, I seem to remember, depending on the case, which reminds me of this great little exchange (they even have someone homonymous to you there :-D).
    – moewe
    Aug 16, 2015 at 13:43

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.