Today, I had to deal with large number blocks with >10 digits. With my current setup, the whole number is shown without any grouping or decimal point, making it hard to read them, especially when they contain large amounts of zeros.
My preamble:
\documentclass[paper=a4, fontsize=12pt,]{scrartcl}
% Für Spracheingaben und korrekte Trennung
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
% Matherelevante Pakete
\usepackage[decimalsymbol=comma]{siunitx}
\usepackage{icomma}
\usepackage{amsmath}
% Sonstige Parameter
\setlength{\parindent}{0pt}
\numberwithin{equation}{subsection}
As you can see, I’m using commas as the regular decimal symbol, so a comma as a decimal point wouldn’t make too much sense.
Anyway, how do I get digits to be grouped automatically? So far, I’ve been using the following, manual way to achieve spacing between larger numbers, but that isn’t too comfortable:
\sqrt[2]{1,6 \cdot 10^{13}} = \sqrt[2]{16\,000\,000\,000\,000} &= 4\,000\,000\
So my question is: How do I get automatic digit grouping with the decimal point being either an apostrophe or a non-braking space?
Best Answer
The
siunitx
package you're already loading provides the\num
command for formatting numbers.This command is very handy, because it allows to get output independently on how the input is formatted.
The two inputs will give the same output, namely
Note that
decimalsymbol=comma
is a "version 1" option, so it forcessiunitx
to use only the less powerful features present in version 1. The options I passed in the example are the "modern" ones.In case you're stuck with the old version because of an outdated TeX distribution, update it or use
In any case, never use anything other than thin spaces for separating groups of digits.