我尝试在表格中输入%,但是它重叠了。
\documentclass[12pt,oneside]{book}
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
\usepackage{makecell,siunitx}
\usepackage{booktabs}
\begin{document}
\begin{table}[h!]
\centering
\sisetup{table-format=3.0, table-number-alignment=left, table-column-width=2.0cm}
\begin{tabular}{lSS}
\toprule
& \multicolumn{2}{c}{\thead{\makebox[0pt]{Testing 123 (\%)}}}\\
\cmidrule{2-3}
&{\small \textbf{Accuracy}}
& {\small\textbf{Inaccuracy}} \\
\midrule
N & 20 & 20 \\
Mean & 50.45\% & 58.55\% \\
Median & 78.74\% & 665.26\% \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案1
您保留的数字有误。
此外,如果不是所有表格条目都表示百分比,则标题中不应有 % 符号。非百分比的条目不应在小数点处对齐。
\documentclass[12pt,oneside]{book}
\usepackage{siunitx}
\usepackage{booktabs}
\begin{document}
\begin{table}[htp!]
\centering
\begin{tabular}{
l
S[table-format=2.2,table-space-text-post=\%]
S[table-format=3.2,,table-space-text-post=\%]
}
\toprule
& \multicolumn{2}{c}{Testing 123} \\
\cmidrule{2-3}
& \textbf{Accuracy}
& \textbf{Inaccuracy} \\
\midrule
N & {20} & {20} \\
Mean & 50.45\% & 58.55\% \\
Median & 78.74\% & 665.26\% \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案2
这可以通过使用dcolumn
包而不是来实现siunitx
,下面是修改后的标签:
\documentclass[12pt,oneside]{book}
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
\usepackage{makecell}
\usepackage{booktabs}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D{.}{.}{#1}}%
\begin{document}
\begin{table}[h!]
\centering
\begin{tabular}{ld{2,3}d{3,3}}
\toprule
& \multicolumn{2}{c}{Testing 123 (\%)}\\
\cmidrule{2-3}
&\multicolumn{1}{c}{\small \textbf{Accuracy}}
& \multicolumn{1}{c}{\small\textbf{Inaccuracy}} \\
\midrule
N & 20 & 20 \\
Mean & 50.45\% & 58.55\% \\
Median & 78.74\% & 665.26\% \\
\bottomrule
\end{tabular}
\end{table}
\end{document}