逗号格式错误(siunitx)

逗号格式错误(siunitx)

在此处输入图片描述

为什么在渲染时缺少逗号1,089

梅威瑟:

\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}

答案1

默认值为group-minimum-digits5,整数 1089 只有 4 位数字。

\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}

结果

相关内容