如何在表格中将数字与单位对齐?我尝试使用 siunitx,但没有效果:
\begin{table}
\centering
\caption{Caption goes here.}
\begin{tabular}[t]{lS}
\toprule
Substance & Amounts \\ \midrule
A & 1 $mL$ \\
B & 100 $mg$ \\
C & 0.5 $mg$ \\
D & 82 $\mu L$ \\
E & 0.1 $g$ \\bottomrule
\end{tabular}
\end{table}
如果有可能的话,我也会手动执行此操作,因为我确实不需要很多表格。提前致谢
答案1
像这样吗?
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{siunitx,booktabs,array}
\begin{document}
\begin{table}
\centering
\caption{Caption goes here.}
\begin{tabular}[t]{ @{}
l
S[table-format=2.1]
@{\,}
s[table-unit-alignment=left]
@{} }
\toprule
Substance & \multicolumn{2}{c@{}}{Amounts} \\
\midrule
A & 1 & \milli\liter \\
B & 100 & \milli\gram \\
C & 0.5 & \milli\gram \\
D & 82 & \micro\liter \\
E & 0.1 & \gram \\
\bottomrule
\end{tabular}
\end{table}
\end{document}