这是我对 siunitx 用户的问题:是否有必要在序言中指定输入符号参数,而不是在 S[] 中?
我为什么要问?
这是我的 R 函数 outreg(在包 rockchalk 中)生成的表格。
\documentclass[11pt,letterpaper,english]{extarticle}
\usepackage{booktabs}
\usepackage{dcolumn}
\usepackage{array}
\usepackage{siunitx}
%following now in each table
\sisetup{
input-symbols = ( )
}
\begin{document}
\begin{table}
\caption{Still have showAIC argument, as in previous versions}\label{tab:ex5ds}
\centering\begin{tabular}{@{}l*{2}S[input-symbols = ( ),
group-digits = false,
table-format = 3.3,
table-number-alignment = center,
table-space-text-pre = (,
table-space-text-post = {***},
table-align-text-pre = false,
table-align-text-post = false,
parse-units = false]@{}}
\hline
& \multicolumn{1}{c}{Whichever}& \multicolumn{1}{c}{Whatever}\tabularnewline
& \multicolumn{1}{c}{Estimate}& \multicolumn{1}{c}{Estimate}\tabularnewline
& \multicolumn{1}{c}{(S.E.)}& \multicolumn{1}{c}{(S.E.)}\tabularnewline
\hline
\hline
(Intercept) &403.245*** &29.774*** \tabularnewline
& (0.618) & (0.522)\tabularnewline
x1 &1.546*& \multicolumn{1}{c}{\phantom{000}.} \tabularnewline
& (0.692) & \tabularnewline
x2 & \multicolumn{1}{c}{\phantom{000}.} &3.413** \tabularnewline
& & (0.512)\tabularnewline
\hline
N& \multicolumn{1}{c}{100}& \multicolumn{1}{c}{100} \tabularnewline
RMSE &6.121 &5.205 \tabularnewline
$R^2$ &0.048 &0.312 \tabularnewline
adj $R^2$ &0.039 &0.305 \tabularnewline
AIC &617.694 &617.694\tabularnewline
\hline
\hline
\multicolumn{3}{l}{${* p}\le 0.05$${*\!\!* p}\le 0.01$${*\!\!*\!\!* p}\le 0.001$}\tabularnewline
\end{tabular}
\end{table}
\end{document}
感谢本组成员的帮助,在我看来,输出结果基本足够了。我无法提前知道可能使用多少位数字,因此我不依赖表格格式来收紧对齐。这就是为什么我一直对表格不同部分的居中问题耿耿于怀。但说实话,这比我以前用过的好多了。
我现在要问的是序言和 sisetup。我希望表格标记尽可能接近可移植性,而不依赖于任何序言细节。
我想完全消除 sisetup 的使用,但如果我将其从此示例中删除,则它无法编译,因为编译器无法理解括号:
! siunitx error: "invalid-number"
!
! Invalid numerical input '(0.618)'.
!
! See the siunitx documentation for further information.
序言 sisetup 是唯一的修正吗?
答案1
你的表格序言语法有误。你使用了*{2}S[...]
但你应该在第二个参数周围加上括号,这样 S 的可选参数也会被处理:
\documentclass[11pt,letterpaper,english]{extarticle}
\usepackage{booktabs}
\usepackage{dcolumn}
\usepackage{array}
\usepackage{siunitx}
%following now in each table
\sisetup{
% input-symbols = ( )
}
\begin{document}
\begin{table}
\caption{Still have showAIC argument, as in previous versions}\label{tab:ex5ds}
\centering\begin{tabular}{@{}l*{2}{S[
input-symbols = ( ),
group-digits = false,
table-format = 3.3,
table-number-alignment = center,
table-space-text-pre = (,
table-space-text-post = {***},
table-align-text-pre = false,
table-align-text-post = false,
parse-units = false
]}@{}}
& (0.618) & (0.522)\tabularnewline
\end{tabular}
\end{table}
\end{document}