当表格中包含大量数字时,手工调整小数点和数位的对齐很麻烦,这 时可以使用 Rochester 的 warpcol 宏包[4]。它为 tabular 环境提供了一个列 对齐参数 P,其语法如下,其中 m 和 n 分别是小数点前后的位数,数字前的 负号可选。 语法:P{-m.n}
\begin{table }[ htbp]
\centering
\begin{tabular }{P{2.5}P{ -2.5}}
\toprule
\multicolumn{1}{c}{数学常数} &
\multicolumn{1}{c}{物理常数} \\
\midrule
3.14159 & 2.99792 \\
27.18281 & -17.58819 \\
\ bottomrule
\end{tabular}
\end{table}
multicolumn 命令是为了保护表头,防止它们被 P 参数误 伤。把跨列命令的列数设为 1 是设置单元格格式的一种常用方法。