
我只是無法正確對齊第三列,請問有人知道怎麼做嗎?
\documentclass[a4paper,12pt]{report}
\usepackage{multirow}
\usepackage{siunitx,booktabs}%for table decimals number
\usepackage[export]{adjustbox}
\begin{table}[!htbp]
\centering
\begin{tabular}{>{\bfseries}l S[table-format=-1.2(2)] S[table-format=-1.1e1]}
\toprule
{\textbf{Res.}} & {$\boldsymbol{\beta}$} & {$\boldsymbol{\chi^{2}}$} \\
\midrule
4 & -0.60(14) & 1738 \\
5 & -0.39(11) & 1348\\
6 & -0.32(10) & 612 \\
7 & -0.54(17) & 1159 \\
8a & -0.36(10) & 621 \\
9 & -0.50(14) & 800 \\
10 & -0.26(14) & 544 \\
11a & -0.54(16) & -1140 \\
11b & -0.50(15) & 867 \\
\bottomrule
\end{tabular}
\caption[]{}
\end{table}
答案1
siunitx
我將嘗試從您的程式碼中解釋數字的格式:
table-format=-1.1e1
表示它使用科學記數法(用於e
)exponent
,尾數可能有符號—
,1 digit
小數點之前 ( 1.
) 和1 digit
小數點之後 ( .1
)。指數的使用1 digit
(這是e1
格式的一部分)。
table-format=-1.2(2)
不使用科學記數法,但有一個uncertainty part
使用2 digits
.
因此,對於你的最後一欄,你應該有
table-format=-4.0
(四位數字可能帶有 - 符號,並且沒有小數部分)。
答案2
改成。意思是:「為以符號開頭的四位數留出足夠的空間,並且不為數字留出任何空間S[table-format=-1.1e1]
S[table-format=-4.0]
-4.0
-
後小數點標記」(因為我們處理的是整數)。為什麼放-4.0
?這是因為第三列中最大的數字(絕對值)是「-1140」。
\documentclass[a4paper,12pt]{report}
\usepackage{bm,siunitx,booktabs}%for table decimals number
\begin{document}
\begin{table}[!htbp]
\centering
\begin{tabular}{>{\bfseries}l
S[table-format=-1.2(2)]
S[table-format=-4.0] }
\toprule
{\textbf{Res.}} & {$\bm{\beta}$} & {$\bm{\chi^{2}}$} \\
\midrule
4 & -0.60(14) & 1738 \\
5 & -0.39(11) & 1348\\
6 & -0.32(10) & 612 \\
7 & -0.54(17) & 1159 \\
8a & -0.36(10) & 621 \\
9 & -0.50(14) & 800 \\
10 & -0.26(14) & 544 \\
11a & -0.54(16) & -1140 \\
11b & -0.50(15) & 867 \\
\bottomrule
\end{tabular}
\caption[]{}
\end{table}
\end{document}