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?
siunitx
with the macro\num
, possibly passing some options.$\sqrt{\num{1.6e13}} = \sqrt{\num{16 000 000 000 000}} = \num{4 000 000}$
. You can separate groups also in the input and\num
will take care of reformatting them independently of the input format. If you have many decimal numbers it's even handier than relying onicomma
: you can use either a comma or a dot in the input and the number will be formatted as requested with the options passed tosiunitx
.decimalsymbol
option is proper of version 1 ofsiunitx
and forces it to use version 1 features. If you're not stuck with that version because of an outdated TeX distribution, it's better to useoutput-decimal-marker={,}
for setting the comma.