为什么下面的代码会过满?如果我理解正确的话,表格有足够的空间来容纳数据。
平均能量损失
\documentclass[11pt,draft]{report}
\usepackage{tabularx}
\usepackage{siunitx,array,booktabs}
\usepackage{showframe}
\begin{document}
\begin{table}[hb]\centering
%\setlength\tabcolsep{8pt}
\begin{tabularx}{\linewidth}{%
c@{\extracolsep{\fill}}%
S[table-format=2]%
S[table-format=4]%
S[table-format=2]%
S[table-format=2]%
S[table-format=2.2]%
S[table-format=1.2]%
S[table-format=2.2]%
c@{\extracolsep{\fill}}%
}
\\\toprule
& 1 & 75 & 15 & 5 & 44.42 & 8.89 & 14.67\% & \\
& 2 & 150 & 30 & 5 & 36.92 & 8.29 & 14.67\% & \\
& 3 & 300 & 60 & 5 & 49.73 & 9.01 & 40.67\% & \\
& 40 & 450 & 90 & 5 & 51.50 & 9.59 & 25.44\% & \\
& 17 & 600 & 15 & 40 & 23.28 & 7.24 & 11.50\% & \\
& 18 & 1200 & 30 & 40 & 27.18 & 7.27 & 07.00\% & \\
& 19 & 2400 & 60 & 40 & 17.82 & 6.62 & 03.75\% & \\
& 20 & 3600 & 90 & 40 & 21.06 & 7.16 & 12.07\% & \\
\bottomrule
\end{tabularx}
\caption{Why overfull?}
\end{table}
\end{document}
答案1
siunitx 要求最后一列包含一个小数点前两位、小数点后两位的数字。它无法识别 % 符号。
\documentclass[11pt,draft]{report}
\usepackage{tabularx}
\usepackage{siunitx,array,booktabs}
\usepackage{showframe}
\begin{document}
\begin{table}[hb]\centering
%\setlength\tabcolsep{8pt}
\begin{tabularx}{\linewidth}{%
c@{\extracolsep{\fill}}%
S[table-format=2]%
S[table-format=4]%
S[table-format=2]%
S[table-format=2]%
S[table-format=2.2]%
S[table-format=1.2]%
S[table-format=2.2,table-space-text-post=\%]%
c@{\extracolsep{\fill}}%
}
\\\toprule
& 1 & 75 & 15 & 5 & 44.42 & 8.89 & 14.67\% & \\
& 2 & 150 & 30 & 5 & 36.92 & 8.29 & 14.67\% & \\
& 3 & 300 & 60 & 5 & 49.73 & 9.01 & 40.67\% & \\
& 40 & 450 & 90 & 5 & 51.50 & 9.59 & 25.44\% & \\
& 17 & 600 & 15 & 40 & 23.28 & 7.24 & 11.50\% & \\
& 18 & 1200 & 30 & 40 & 27.18 & 7.27 & 07.00\% & \\
& 19 & 2400 & 60 & 40 & 17.82 & 6.62 & 03.75\% & \\
& 20 & 3600 & 90 & 40 & 21.06 & 7.16 & 12.07\% & \\
\bottomrule
\end{tabularx}
\caption{Why overfull?}
\end{table}
\end{document}