我想在表格中插入一个文本列,其他列由 siunitx 格式化
\documentclass{standalone}
\usepackage{siunitx}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{ r
S[table-format = 2.1]
S[table-format = 2]}
\toprule
overlay & SS & df\\
\midrule
Data & 72.9 & 29\\
\bottomrule
\end{tabular}
\end{document}
我收到一个错误:
Package siunitx Error: Invalid number 'd'.
答案1
siunitx
将尝试“猜测”哪些条目是非数字的,但如果您使用括号或标记它们,它会更干净地工作\multicolumn
:
\documentclass{standalone}
\usepackage{siunitx}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{ r
S[table-format = 2.1]
S[table-format = 2]}
\toprule
overlay & SS & {df}\\
\midrule
Data & 72.9 & 29\\
\bottomrule
\end{tabular}
\begin{tabular}{ r
S[table-format = 2.1]
S[table-format = 2]}
\toprule
overlay & SS & \multicolumn{1}{c}{df}\\
\midrule
Data & 72.9 & 29\\
\bottomrule
\end{tabular}
\end{document}