4

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}
  • input-ignore={,},input-decimal-markers={.} – Johannes_B May 30 '15 at 14:44
  • Seems the group separator is included for numbers greater than 9999. – Johannes_B May 30 '15 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.) – Ethan Bolker May 30 '15 at 15:00
8

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

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.