我有这个代码:
\documentclass[11pt]{article}
\usepackage[margin=2.5cm, showframe]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{caption}
\usepackage{setspace}
\usepackage{lipsum}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage[skip=0.33\baselineskip]{caption}
\captionsetup[table]{
font=bf,
size=normalsize,
justification=centerlast,
labelsep=newline
}
\renewcommand\thetable{\Roman{table}}
\begin{document}
\begin{spacing}{1.5}
\noindent
\def\arraystretch{1.25}
\begin{table}[ht]
\centering
\setlength\tabcolsep{0pt}
\sisetup{table-format=2.2}
\caption{\large{Fancy Table Header}}
\parbox{\linewidth}{\small\lipsum[1]\vspace{2ex}}
\medskip
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
l
S[table-format=-2.2]
*{6}{S}
}
\toprule
\multicolumn{1}{c}{Description}
& {Column 1} & {Column 2} & {Column 3}
& {Column 4} & {Column 5} & {Column 6}\\
\midrule
Variable 1 &626 &293.00 &1,349.65 &1.75 &64.04 &0.68\\
\midrule
Variable 2\\
Sub--variable 2.1 &325 &150.98 &1,677.02 &1.72 &71.92 &0.66\\
Sub--variable 2.2 &169 &81.27 &872.07 &1.85 &56.76 &0.72\\
Sub--variable 2.3 &132 &60.75 &1,155.07 &1.70 &53.96 &0.69\\
\midrule
Variable 3\\
Sub--variable 3.1 &360 &154.02 &81.16 &1.94 &71.73 &0.61\\
Sub--variable 3.2 &155 &76.97 &557.67 &1.64 &60.52 &0.70\\
Sub--variable 3.3 &111 &62.01 &6,569.60 &1.27 &44.00 &0.84\\
\midrule
Variable 4\\
Sub--variable 4.1 &190 &90.15 &3,263.74 &0.92 &57.98 &0.77\\
Sub--variable 4.2 &202 &92.31 &545.90 &1.50 &75.23 &0.72\\
Sub--variable 4.3 &234 &110.54 &489.31 &2.63 &59.30 &0.58\\
\midrule
Variable 5\\
Sub--variable 5.1 &229 &115.50 &2,050.25 &1.87 &15.54 &0.69\\
Sub--variable 5.2 &185 &78.23 &1,498.76 &1.58 &43.13 &0.71\\
Sub--variable 5.3 &212 &99.26 &462.76 &1.76 &134.68 &0.65\\
\bottomrule
\end{tabular*}
\end{table}
\end{spacing}
\end{document}
生成以下表格:
在第 3 列中,一些数字超过 1,000,但由于某种原因未显示这些数字,我不知道为什么。有人知道吗?
提前致谢!
答案1
我建议省略逗号并让它siunitx
为您完成工作。
\documentclass[11pt]{article}
\usepackage[margin=2.5cm, showframe]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{caption}
\usepackage{setspace}
\usepackage{lipsum}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage[skip=0.33\baselineskip]{caption}
\captionsetup[table]{
font=bf,
size=normalsize,
justification=centerlast,
labelsep=newline
}
\renewcommand\thetable{\Roman{table}}
\begin{document}
\begin{spacing}{1.5}
\noindent
\def\arraystretch{1.25}
\begin{table}[ht]
\centering
\setlength\tabcolsep{0pt}
\sisetup{table-format=2.2, group-separator={,}, group-minimum-digits=4}
\caption{\large{Fancy Table Header}}
\parbox{\linewidth}{\small\lipsum[1]\vspace{2ex}}
\medskip
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
l
S[table-format=-2.2]
*{6}{S}
}
\toprule
\multicolumn{1}{c}{Description}
& {Column 1} & {Column 2} & {Column 3}
& {Column 4} & {Column 5} & {Column 6}\\
\midrule
Variable 1 &626 &293.00 &1349.65 &1.75 &64.04 &0.68\\
\midrule
Variable 2\\
Sub--variable 2.1 &325 &150.98 &1677.02 &1.72 &71.92 &0.66\\
Sub--variable 2.2 &169 &81.27 &872.07 &1.85 &56.76 &0.72\\
Sub--variable 2.3 &132 &60.75 &1155.07 &1.70 &53.96 &0.69\\
\midrule
Variable 3\\
Sub--variable 3.1 &360 &154.02 &81.16 &1.94 &71.73 &0.61\\
Sub--variable 3.2 &155 &76.97 &557.67 &1.64 &60.52 &0.70\\
Sub--variable 3.3 &111 &62.01 &6569.60 &1.27 &44.00 &0.84\\
\midrule
Variable 4\\
Sub--variable 4.1 &190 &90.15 &3263.74 &0.92 &57.98 &0.77\\
Sub--variable 4.2 &202 &92.31 &545.90 &1.50 &75.23 &0.72\\
Sub--variable 4.3 &234 &110.54 &489.31 &2.63 &59.30 &0.58\\
\midrule
Variable 5\\
Sub--variable 5.1 &229 &115.50 &2050.25 &1.87 &15.54 &0.69\\
Sub--variable 5.2 &185 &78.23 &1498.76 &1.58 &43.13 &0.71\\
Sub--variable 5.3 &212 &99.26 &462.76 &1.76 &134.68 &0.65\\
\bottomrule
\end{tabular*}
\end{table}
\end{spacing}
\end{document}