表格未对齐负数和正数

表格未对齐负数和正数
\begin{table}[b]%
\centering
\caption{determined \emph{hkl} indices and their corresponding.}%
\begin{tabular}{@{}llllll@{}}
\toprule
\multicolumn{6}{c}{\textbf{MO}\\
\midrule
\emph{h} &\emph{k} &\emph{l} & (obs) & (Calc) & Difference\\
\hline

 0          & -1         & 0          & 10.3508       & 10.3893        & -0.0385    \\
 1          &  1         & 0          & 16.1424       & 16.167         & -0.0246    \\
 0          &  0         & 2          & 19.6878       & 19.7087        & -0.0209    \\
-1          & -1         & 2          & 22.4105       & 22.35          & 0.0605     \\
-3          & -1         & 1          & 31.6149       & 31.6054        & 0.0095     

\bottomrule
\end{tabular}
\end{table}

答案1

正如您“发现”的那样,l列类型对列内容执行左对齐。

为了将数字对齐到各自的(显式或隐式)小数标记,您可以加载siunitx包并使用其S列类型(见下文)或dcolumnpanckage 及其D列类型。

我们

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx} % for "S" column type
\begin{document}

\begin{table}[b]%
\centering
\caption{determined \emph{hkl} indices and their corresponding \dots}%
\begin{tabular}{@{}
   S[table-format=-1.0]
   S[table-format=-1.0]
   S[table-format= 1.0]
   S[table-format= 2.4]
   S[table-format= 2.4]
   S[table-format=-1.4]
   @{}}
\toprule
\multicolumn{6}{c}{\textbf{MO}}\\
\cmidrule{1-6} % \cmidrule is thinner than \midrule
{\emph{h}} & {\emph{k}} & {\emph{l}} & {(obs)} & {(Calc)} & {(Diff.)} \\
\midrule % not "\hline"
 0 & -1 & 0 & 10.3508 & 10.3893  & -0.0385 \\
 1 &  1 & 0 & 16.1424 & 16.167   & -0.0246 \\
 0 &  0 & 2 & 19.6878 & 19.7087  & -0.0209 \\
-1 & -1 & 2 & 22.4105 & 22.35    &  0.0605 \\
-3 & -1 & 1 & 31.6149 & 31.6054  &  0.0095 \\  
\bottomrule
\end{tabular}
\end{table}

\end{document}

相关内容