5

enter image description here

Why is the comma missing in the rendering of 1,089 ?

MWE:

\documentclass{article}

\usepackage{booktabs}
\usepackage{multirow}
\usepackage{siunitx}
\sisetup{input-ignore={,},input-decimal-markers={.},group-separator={,}}

\begin{document}

{\renewcommand{\arraystretch}{1.2}% for the vertical padding
\begin{tabular}{|cc
|
S[table-format=3.0]
S[table-format=5.0]
|
S[table-format=6.0]
|
}
\hline
& &   \multicolumn{2}{c|}{suffers from X} & \\
& &    {yes} & {no} & {total} \\
\hline
\multirow{2}{*}{test + for X}
     & yes &  90  & 999  & 1,089 \\
     & no  &  10  & 98,901 & 98,911 \\
\hline
 & total & 100  & 99,900  & 100,000 \\
\hline
\end{tabular}
}

\end{document}
3
  • input-ignore={,},input-decimal-markers={.}
    – Johannes_B
    Commented May 30, 2015 at 14:44
  • Seems the group separator is included for numbers greater than 9999.
    – Johannes_B
    Commented May 30, 2015 at 14:52
  • @Johannes_B That may indeed be the issue - but I think it makes the column harder to read. Is there a workaround other than ignoring siunitx, right justifying the column? (Your first comment isn't a fix.) Commented May 30, 2015 at 15:00

1 Answer 1

9

The default for group-minimum-digits is 5, the integer 1089 has 4 digits only.

\documentclass{article}

\usepackage{booktabs}
\usepackage{multirow}
\usepackage{siunitx}
\sisetup{
  input-ignore={,},
  input-decimal-markers={.},
  group-separator={,},
  group-minimum-digits=4,
}

\begin{document}

{\renewcommand{\arraystretch}{1.2}% for the vertical padding
\begin{tabular}{|cc
|
S[table-format=3.0]
S[table-format=5.0]
|
S[table-format=6.0]
|
}
\hline
& &   \multicolumn{2}{c|}{suffers from X} & \\
& &    {yes} & {no} & {total} \\
\hline
\multirow{2}{*}{test + for X}
     & yes &  90  & 999  & 1,089 \\
     & no  &  10  & 98,901 & 98,911 \\
\hline
 & total & 100  & 99,900  & 100,000 \\
\hline
\end{tabular}% remove unwanted space by line end
}
\end{document}

Result

4
  • Seems like a curious value for the default? Would anyone know why? cc: @JosephWright Commented May 31, 2015 at 6:03
  • 1
    @Brent.Longborough, see "How the world separates its digits" Commented May 31, 2015 at 6:59
  • Thank you; all I can say is "true, but strange". :) Commented May 31, 2015 at 7:27
  • @HeikoOberdiek Nevermind, I deleted my comment. It was indeed very confusing.
    – Andyc
    Commented Jan 10, 2022 at 23:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .