2

The following question has probably already been answered on this site but I can't find anything in the questions/answers archive.

How to I use siunitx to group the decimal part of a number in two instead of three?

I've searched through the manual but I couldn't find anything regarding this exact issue.

1 Answers1

1

If you want both the decimal and the integer part in groups of two that can be done with the options digit-group-first-size=2, digit-group-other-size=2. However, if you want different grouping for the two parts then need a macro that seprates the integer and decimal parts and applies the desired settings to both parts:

enter image description here

Code:

\documentclass{article}
\usepackage{siunitx}
\usepackage{xstring}

\makeatletter \newcommand{\numI}[1]{% \StrBehind{#1}{.}[@DecimalPart]% \StrBefore{#1}{.}[@IntegerPart]% \num[ digit-group-first-size=3, digit-group-other-size=3, ]{@IntegerPart}% \num[ digit-group-first-size=2, digit-group-other-size=2, ]{.@DecimalPart}% } \makeatother

\begin{document} $\numI{123456789.123456789}$ \end{document}

Peter Grill
  • 223,288
  • Opps, there is a problem with this: The siunitx package adds a leading 0 if no digits are given in the integer part. Thus, there is an extra 0 in the ouptut number that was not in the input. I don't see an option to have the num macro to suppress that leading 0. – Peter Grill Dec 18 '23 at 17:20