表格列对齐

表格列对齐

我就是无法正确对齐第三列,有人知道该怎么做吗?

\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表示它使用科学计数法( 代表eexponent,尾数可能有符号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}

相关内容