48

In most language, long numbers are split into groups of three digits, to increase readability.

In Dutch (my native language), 1000000 is usually written as 1 000 000. In English, this would be 1,000,000.

Now, I would like to know how to use this kind of formatting in LaTeX. I searched google, but I only found some articles that explain how to split very long numbers over multiple lines, which is not what I need.

Is there a package that does this automatically? Or a certain tag I can use for this?

3
52

Normally you would use \, for a thin space $1\,000\,000$ If you are entering that by hand. As noted in the comments siunitx or other packages have the ability to parse the bare number 1000000 and then format it according to formatting parameters with commas or thin spaces, so it depends what you want to do (and where the numbers are generated). Whether it is a few numbers in a hand authored text or if you are typesetting thousands of numbers in table data where hand editing to add grouping separator is not really an option.

2
  • Is there any method to automatically apply siunitx to all the numbers of my document without needing to write \num in front of each one? I would like to have all my numbers shown with groups of 3 digits and a small space in between. – skan Oct 27 '20 at 19:52
  • @skan not really (but you could ask a new question see if anyone has any suggestions) – David Carlisle Oct 27 '20 at 20:02
18

There is a good package for all of these formatting issues with numbers, either in text or in tabular: \usepackage{numprint}. Please study the manual, it provides a lot of detailed information. You get the manual usually with something like texdoc numprinton the command line.

A small MWE for numprint to answer your question:

\documentclass[english]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{numprint}
\npthousandsep{\,}

\begin{document}

This would be a line with a price tag: \numprint{1000000} EUR.

And as a tabular: 
\begin{tabular}{N{7}{0}}
  1000000 {~EUR}\\
\end{tabular}
\end{document}

We get this:

numprint example

As you can see, just tell numprint how the thousand separator should look like. You can do much more, rounding numbers e.g.

2
  • 1
    Note that numprint have an option to specify the unit this way \numprint[EUR]{1000000} or \numprint[nm^2]{5} – Opsse Jul 13 '20 at 17:30
  • @Opsse I'm astonished, never noticed that option. Thank you! – Keks Dose Jul 14 '20 at 9:00
0

Use the package "Ziffer" which helps if you want to write 100000 as "100.000,00" it will show "10 000,00" (no space after the comma and a space instead of the dot)

2
  • 8
    Please improve your answer with small. complete document, which will show syntax of using mentioned package. – Zarko Jul 24 '16 at 18:23
  • 1
    Your comment would technically apply to the accepted answer as well. – Mitja Sep 18 '17 at 18: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.