4

Large numbers have a nice space separator which I want to keep. But these gaps are annoying in small numbers and I want to get rid of them. Here's a MWE showing my issue:

\documentclass[12pt,letterpaper,twoside]{book}
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage{siunitx}

\begin{document}

Blabla bla :
\begin{align}
    x &= \SI{32100000}{\m}, \\[1ex]
    y &= \SI{0.0123456}{\m}
\end{align}

\end{document}

Preview:

enter image description here

So is there a way to keep the spacings in large digit numbers, and remove the spacings in small digit numbers? I checked the SIunitx package documentation and didn't found a way yet.

1
  • 2
    I don't think this is a good thing, typographically. These thin spaces are added to improve readability, so the criterion to add them or not is not the size of the number, but the number of digits. Look at how tables of logarithms were printed.
    – Bernard
    Sep 4, 2020 at 13:41

2 Answers 2

8

You can tell siunitx to group only the integer part of numbers with group-digits=integer.

\documentclass[12pt]{article}
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage{siunitx}

\sisetup{group-digits=integer}

\begin{document}
Blabla bla:
\begin{align}
    x &= \SI{32100000}{\metre}, \\[1ex]
    y &= \SI{0.0123456}{\metre}
\end{align}
\end{document}

Grouped integer, ungrouped decimals.

1
  • Works great ! Thanks a lot.
    – Cham
    Sep 4, 2020 at 13:41
2

Try this

\documentclass[12pt,letterpaper,twoside]{book}
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage{siunitx}


\begin{document}

Blabla bla :
\begin{align}
    x &= \SI{32100000}{\m}, \\[1ex]
    y &= \SI[group-separator =]{0.0123456}{\m}
\end{align}

\end{document}

enter image description here

4
  • 2
    If you want to locally disable grouping I think it would be cleaner to say group-digits=false instead of making the group separator empty.
    – moewe
    Sep 4, 2020 at 13:33
  • For some reason \SI[group-separator = false]{0.0123456}{\m} does not work for me! Sep 4, 2020 at 13:42
  • You want \SI[group-digits=false]{0.0123456}{\m} (i.e. group-digits and not group-separator).
    – moewe
    Sep 4, 2020 at 13:43
  • Using ={} works for me.
    – Cham
    Sep 4, 2020 at 13:44

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.