将固定宽度的列与小数点对齐

将固定宽度的列与小数点对齐

我为固定宽度的列定义了一种新的列类型,其中文本居中对齐,如下所示:

\newcolumntype{d}[2]{>{{\rightdots{#1}}r<{\rightdots}\let\newline\\\arraybackslash\hspace{0pt}}m{#2}}  

该命令接受两个参数,{#1} 表示小数点后的位数,{#2} 表示列宽。

然后我在表中使用此列类型,如下所示:

\usepackage{array} % for table sizing
\usepackage{booktabs} % for table formatting
\usepackage{dcolumn} % for aligning columns to the decimal point
\usepackage{xfrac} % for slanted fractions
\begin{document}

\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{d}[2]{>{{\rightdots{#1}}r<{\rightdots}\let\newline\\\arraybackslash\hspace{0pt}}m{#2}}

\begin{table}[h]
\centering
\caption{Processed Data at Blower Frequency of 40 $\left[Hz\right]$}\label{40Hzresults}
\renewcommand{\arraystretch}{1.8}
\begin{tabular}{C{2.3cm} C{2.3cm} d{3}{2.3cm} C{2.3cm} C{2.3cm} d{3}{2.3cm}}
\toprule
Sphere Size \newline $\left[\textit{mm}\right]$ & Wind Speed \newline $\left[\textit{$\frac{m}{s}$}\right]$ & \multicolumn{1}{c}{Drag Force \newline $\left[\textit{N}\right]$} & Reynolds Number \newline $\left[\textit{--}\right]$ & Experimental Drag Coefficient \newline $\left[\textit{--}\right]$ & \multicolumn{1}{c}{Theoretical Drag Coefficient \newline $\left[\textit{--}\right]$} \\
\midrule
64 & 25.66\newline$\pm$0.314 & 0.862 & 108043\newline$\pm$1616.190 & 0.691\newline$\pm$0.060 & 0.455 \\
76 & 25.709\newline$\pm$0.315 & 0.425 & 128544\newline$\pm$1842.879 & 0.241\newline$\pm$0.021 & 0.447 \\
102 & 25.563\newline$\pm$1.16 & 0.313 & 171538\newline$\pm$2337.997 & 0.369\newline$\pm$0.031 & 0.424 \\
\bottomrule
\end{tabular}
\end{table}
\end{document} 

我发现小数对齐列不符合要求的宽度,并且 \newline 命令不起作用。这是因为小数对齐吗?siunitx 是唯一的可能性吗,还是可以对此进行硬编码?

相关内容