我正在尝试对齐这个表的标题,但到目前为止没有成功,有人能告诉我我做错了什么吗?
\documentclass[a4paper,12pt]{report}
\usepackage{multirow}
\usepackage{siunitx,booktabs}%for table decimals number
\usepackage[export]{adjustbox}
\begin{document}
\begin{table}[!htbp]
\centering
\begin{tabular}{p{2cm}p{2cm}p{2cm}}
\toprule
\multicolumn{1}{l}{\textbf{Res.}}
& \multicolumn{1}{l}{\textbf{$\boldsymbol{\beta}$}}
& \multicolumn{1}{c}{\textbf{$\boldsymbol{\chi^{2}}$}} \\
\midrule
\textbf{1} & -0.61$\pm$0.32 & 9.1$\times$10$^{7}$\\
\textbf{2} & -0.37$\pm$0.12 & 2.5$\times$10$^{6}$\\
\textbf{3} & -0.39$\pm$0.19 & 1.0$\times$10$^{7}$\\
\textbf{4} & -0.14$\pm$0.13 & 8.0$\times$10$^{6}$\\
\textbf{5} & -0.10$\pm$0.12 & 2.3$\times$10$^{6}$\\
\textbf{6} & -0.44$\pm$0.13 & 1.8$\times$10$^{6}$\\
\textbf{7} & -0.55$\pm$0.16 & 2.0$\times$10$^{6}$\\
\textbf{8a} & -0.54$\pm$0.16 & 1.9$\times$10$^{6}$\\
\bottomrule
\end{tabular}
\caption[$\beta$ results measured in this work for the 3d $Mg^{+}$ in the $hv$ range between 54.50 and 57.45 eV]{The $\beta$ parameter results measured in this work for the 3d $Mg^{+}$ in the $hv$ range between 54.50 and 57.45 eV.}
\label{table:120}
\end{table}
\end{document}
答案1
像这样?
我建议使用siunitx
包。使用它的列类型S
和输入数字的方式可以大大简化你的表格代码:
\documentclass{article}
\usepackage{amsmath, amssymb}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\begin{table}[!htbp]
\sisetup{separate-uncertainty}%
\centering
\begin{tabular}{>{\bfseries}l
S[table-format=-1.2(2)]
S[table-format=-1.1e1]
}
\toprule
Res. & {$\boldsymbol{\beta}$} & {$\boldsymbol{\chi^{2}}$} \\
\midrule
1 & -0.61(32) & 9.1e7 \\
2 & -0.37(12) & 2.5e6 \\
3 & -0.39(19) & 1.0e7 \\
4 & -0.14(13) & 8.0e6 \\
5 & -0.10(12) & 2.3e6 \\
6 & -0.44(13) & 1.8e6 \\
7 & -0.55(16) & 2.0e6 \\
8a & -0.54(16) & 1.9e6 \\
\bottomrule
\end{tabular}
\caption[$\beta$ results measured in this work for the 3d $Mg^{+}$ in the $hv$ range between 54.50 and 57.45 eV]{The $\beta$ parameter results measured in this work for the 3d $Mg^{+}$ in the $hv$ range between 54.50 and 57.45 eV.}
\label{table:120}
\end{table}
\end{document}
p{...}
如果您希望第二列和第三列更宽,那么您可以像在列类型中一样规定它们的宽度:sisetup
添加所需的列宽度:
\sisetup{separate-uncertainty,
table-column-width = 22mm}%
在这种情况下表变成:
答案2
如果要对齐表格中的数字,请使用siunitx
。我建议你看一下文档,特别是第 3.6 和 5.14 条,表格材料。
\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{cellspace}
\setlength{\cellspacetoplimit}{6pt}
\setlength{\cellspacebottomlimit}{6pt}
\usepackage{makecell}
\newcommand*{\topdblline}{\Xhline{0.15ex}\\[-2.6ex]\hline}
\newcommand*{\botdblline}{\hline\\[-2.6ex]\Xhline{0.15ex}}
\begin{document}
\begin{table}[!htbp]
\centering\sisetup{separate-uncertainty, table-figures-uncertainty =2}
\begin{tabular}{ > {\bfseries}lS[table-format =-1.2(2)]S[table-figures-exponent =1]} \toprule
\multicolumn{1}{l}{Res.}
&{$ \boldsymbol{\beta} $} & {$\boldsymbol{\chi^{2}}$} \\%
\midrule%
1 & -0.61(32) & 9.1e7\\%
2 & -0.37(12) & 2.5e6\\%
3 & -0.39(19) & 1.0e7\\%
4 & -0.14(13) & 8.0e6\\%
5 & -0.10(12) & 2.3e6\\%
6 & -0.44(13)& 1.8e6\\%
7 & -0.55(16) & 2.0e6 \\%
8a & -0.54(16) & 1.9e6\\%
\bottomrule
\end{tabular}
\caption[$\beta$ results measured in this work for the 3d $Mg^{+}$ in the $hv$ range between 54.50 and 57.45 eV]{The $\beta$ parameter results measured in this work for the 3d $Mg^{+}$ in the $hv$ range between 54.50 and 57.45 eV.}
\label{table:120}
\end{table}
\end{document}