3

I get weird thinspaces inserted into my decimal-aligned columns when using the S column type of siunitx. It is easier to show the problem than explain in words.

weird spacing in table

The unwanted space is shown in the second column with the pink arrow marks.

Here is the MWE that produces this table

\documentclass{article}
\usepackage{siunitx}
\usepackage{booktabs}
\begin{document}
\begin{table}[!htb]
    \centering
    \begin{tabular}{@{}lS[table-format=1.6] S[table-format=3.2]@{}}
        \toprule
        {First} & {Second} & {Third} \\
        \midrule
        foo1    & 1.25     & 111     \\
        foo2    & 2.203762 & 222.2   \\
        foo3    & 3.3453   & 3.33    \\
        foo4    & 4.87902  & 4       \\
        \bottomrule
    \end{tabular}
\end{table}
\end{document}

How do I suppress these unwanted spaces?

5

Grouping digits can be turned off by using group-digits=false as shown in the following MWE. Its default value is true, as described in section '5.6 Printing numbers' (page 27) of the siunitx manual (to version 2.7s).

According to the manual, one can also separately activate the grouping for the integer and the decimal part of numbers by using one of the following choices: group-digits = decimal (to enable grouping only in the decimal part) or group-digits = integer (for grouping in the integer part only).

\documentclass{article}
\usepackage[group-digits=false]{siunitx}
\usepackage{booktabs}
\begin{document}
\begin{table}[!htb]
    \centering
    \begin{tabular}{@{}lS[table-format=1.6] S[table-format=3.2]@{}}
        \toprule
        {First} & {Second} & {Third} \\
        \midrule
        foo1    & 1.25     & 111     \\
        foo2    & 2.203762 & 222.2   \\
        foo3    & 3.3453   & 3.33    \\
        foo4    & 4.87902  & 4       \\
        \bottomrule
    \end{tabular}
\end{table}
\end{document}

enter image description here

3
  • 1
    thank you for the answer. Accepted. Shouldn't this be the default behaviour for the numbers following the decimal point? – Dr Krishnakumar Gopalakrishnan Aug 1 '18 at 17:26
  • @Krishna: I have added information on how to enable the gropuing for the integer part of numbers while keeping the decimal part ungrouped. – leandriis Aug 1 '18 at 17:32
  • 2
    @Krishna - Answers to questions about which options should be enabled by default are likely purely opinion-based and thus off-topic for this site. Feel free to contact the author/maintainer of the siunitx package (contact information may be found on page 1 of the package's user guide) with your opinions. – Mico Aug 1 '18 at 17:34

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.