我使用tabularray
表格包并将X
列与si
选项结合起来。
我尝试调整一些选项,但我真的不知道我哪里出错了,因为没有错误或警告。或者也许这是一个错误,我不知道?有人能告诉我问题出在哪里并修复它吗?
梅威瑟:
\documentclass[12pt, listof=totoc, numbers=noenddot]{scrartcl}
\usepackage{tabularray}
\usepackage[version=4]{mhchem}
\usepackage[detect-all]{siunitx}
\UseTblrLibrary{amsmath, siunitx}
\begin{document}
\begin{tblr}{hlines, vlines,
colspec = { l| *{8}{X[c, si={exponent-mode=scientific}]} },
rowsep = 4pt,
row{1} = {guard}
}
Koeffizient &A &B &C &D &E &F &G \\ \hline
\ce{H2} &392,8422 &2,4906 &-3,6262 &-1,9624 &35,6197 &-81,3691 &62,666 \\
\ce{H2O} &706,3032 &5,1703 &-6,0865 &-6,6011 &36,2723 &-63,0965 &46,2085\\
\end{tblr}
\end{document}
答案1
像这样?
- 您定义模式的方式
scientific
是错误的,它应该在表之前定义。 - 你的表格太宽了。因此,我将数字四舍五入为四位数字,并
table-format
分别定义scientific
格式的位置,并区分负数和正数:
\documentclass[12pt, listof=totoc, numbers=noenddot]{scrartcl}
\usepackage{geometry}
\usepackage{tabularray}
\usepackage[version=4]{mhchem}
\usepackage[detect-all]{siunitx}
\UseTblrLibrary{booktabs, siunitx}
\begin{document}
\sisetup{exponent-mode = scientific, exponent-product=\cdot, tight-spacing,
round-mode = figures, round-precision=4,
locale=DE
}%
\begin{table}[ht]
\centering
\begin{tblr}{colspec = {@{} l
Q[c, si={table-format= 1.3e1}]
Q[c, si={table-format= 1.3}]
*{2}{Q[c, si={table-format=-1.3}]}
Q[c, si={table-format= 1.3}]
Q[c, si={table-format=-1.3e1}]
Q[c, si={table-format= 1.3e1}]
@{}},
row{1} = {guard}
}
\toprule
Koeffizient &A &B &C &D &E &F &G \\
\midrule
\ce{H2} &392,8422 &2,4906 &-3,6262 &-1,9624 &35,6197 &-81,3691 &62,666 \\
\ce{H2O} &706,3032 &5,1703 &-6,0865 &-6,6011 &36,2723 &-63,0965 &46,2085\\
\bottomrule
\end{tblr}
\end{table}
\end{document}
正如您所看到的,我还将单元格内容从垂直和不必要的水平线的“监狱”中“解放”出来。
答案2
你不需要tabularray
。
\documentclass[12pt, listof=totoc, numbers=noenddot]{scrartcl}
\usepackage[version=4]{mhchem}
\usepackage[detect-all]{siunitx}
\usepackage{booktabs} % for the second table
\begin{document}
\begin{table}[htp]
\begin{tabular*}{\textwidth}{
@{\extracolsep{\fill}} | c ||
S[table-format=3.4] |
S[table-format=1.4] |
S[table-format=-1.4] |
S[table-format=-1.4] |
S[table-format=2.4] |
S[table-format=-2.4] |
S[table-format=2.4] |
}
\hline
Koeffizient & {A} & {B} & {C} & {D} & {E} & {F} & {G} \\
\hline
\ce{H2} & 392,8422 & 2,4906 & -3,6262 & -1,9624 & 35,6197 & -81,3691 & 62,666 \\
\ce{H2O} & 706,3032 & 5,1703 & -6,0865 & -6,6011 & 36,2723 & -63,0965 & 46,2085 \\
\hline
\end{tabular*}
\caption{A caption}
\end{table}
\begin{table}[htp]
\setlength{\tabcolsep}{0pt} % leave the spacing to TeX
\begin{tabular*}{\textwidth}{
@{\extracolsep{\fill}} c
S[table-format=3.4]
S[table-format=1.4]
S[table-format=-1.4]
S[table-format=-1.4]
S[table-format=2.4]
S[table-format=-2.4]
S[table-format=2.4]
}
\toprule
Koeffizient & {A} & {B} & {C} & {D} & {E} & {F} & {G} \\
\midrule
\ce{H2} & 392,8422 & 2,4906 & -3,6262 & -1,9624 & 35,6197 & -81,3691 & 62,666 \\
\ce{H2O} & 706,3032 & 5,1703 & -6,0865 & -6,6011 & 36,2723 & -63,0965 & 46,2085 \\
\bottomrule
\end{tabular*}
\caption{A caption}
\end{table}
\end{document}
当然,我更喜欢后一种实现。
采用指数形式,第一个表必须简化\tabcolsep
才能适合。
\documentclass[12pt, listof=totoc, numbers=noenddot]{scrartcl}
\usepackage[version=4]{mhchem}
\usepackage[detect-all]{siunitx}
\usepackage{booktabs} % for the second table
\begin{document}
\begin{table}[htp]
\sisetup{
exponent-mode = scientific,
% exponent-product=\cdot,
tight-spacing,
round-mode = figures,
round-precision=4,
}
\addtolength{\tabcolsep}{-1.8pt}
\begin{tabular*}{\textwidth}{
@{\extracolsep{\fill}} | c ||
S[table-format=1.3e1] |
S[table-format=1.3] |
S[table-format=-1.3] |
S[table-format=-1.3] |
S[table-format=1.3e1] |
S[table-format=-1.3e1] |
S[table-format=1.3e1] |
}
\hline
Koeffizient & {A} & {B} & {C} & {D} & {E} & {F} & {G} \\
\hline
\ce{H2} & 392,8422 & 2,4906 & -3,6262 & -1,9624 & 35,6197 & -81,3691 & 62,666 \\
\ce{H2O} & 706,3032 & 5,1703 & -6,0865 & -6,6011 & 36,2723 & -63,0965 & 46,2085 \\
\hline
\end{tabular*}
\caption{A caption}
\end{table}
\begin{table}[htp]
\setlength{\tabcolsep}{0pt} % leave the spacing to TeX
\sisetup{
exponent-mode = scientific,
% exponent-product=\cdot,
tight-spacing,
round-mode = figures,
round-precision=4,
}
\begin{tabular*}{\textwidth}{
@{\extracolsep{\fill}} c
S[table-format=1.3e1]
S[table-format=1.3]
S[table-format=-1.3]
S[table-format=-1.3]
S[table-format=1.3e1]
S[table-format=-1.3e1]
S[table-format=1.3e1]
}
\toprule
Koeffizient & {A} & {B} & {C} & {D} & {E} & {F} & {G} \\
\midrule
\ce{H2} & 392,8422 & 2,4906 & -3,6262 & -1,9624 & 35,6197 & -81,3691 & 62,666 \\
\ce{H2O} & 706,3032 & 5,1703 & -6,0865 & -6,6011 & 36,2723 & -63,0965 & 46,2085 \\
\bottomrule
\end{tabular*}
\caption{A caption}
\end{table}
\end{document}
尖端:
- 切勿在表格中使用双重规则;
- 切勿在表格中使用垂直线。