siunitx S 表列中的中心美元值

siunitx S 表列中的中心美元值

如何使\$值在此表中正確居中?

在此輸入影像描述

這應該很簡單,但是在該網站和文件中進行的令人沮喪的搜尋siunitx並沒有幫助我。當然,我總是可以將單位放在標題行中,如第一列中,但我很好奇。

微量元素:

\documentclass{article}

\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}

\begin{tabular}{cS[table-format=3.2]S[table-format=2.0]S[table-format=4.2]}
\toprule
Plan & {Phone cost (\$)} & {Monthly charge} & {Two year cost} \\
\midrule
Cricket Wireless & 499.99 & \$55 & \$1,819.99 \\
Virgin Mobile &  649 & \$30 & \$1,369 \\
\bottomrule
\end{tabular}

\end{document}

答案1

最好的方法是在所有標題中添加 ($):在多個單元格中重複 $ 是乏味且乏味的。

\documentclass{article}

\usepackage{booktabs}
\usepackage{siunitx}

\sisetup{
  group-separator={,},
  group-four-digits,
}

\begin{document}

\begin{tabular}{
  l
  S[table-format=3.2]
  S[table-format=2.0]
  S[table-format=4.2]
}
\toprule
Plan & {Phone cost} & {Monthly charge} & {Two year cost} \\
& {(\$)} & {(\$)} & {(\$)} \\
\midrule
Cricket Wireless & 499.99 & 55 & 1819.99 \\
Virgin Mobile &  649 & 30 & 1369 \\
\bottomrule
\end{tabular}

\end{document}

在此輸入影像描述

不推薦的方式:

\documentclass{article}

\usepackage{booktabs}
\usepackage{siunitx}

\sisetup{
  group-separator={,},
  group-four-digits,
}

\begin{document}

\begin{tabular}{
  l
  S[table-format=3.2]
  S[table-format=2.0,table-space-text-pre={\$}]
  S[table-format=4.2,table-space-text-pre={\$}]
}
\toprule
Plan & {Phone cost (\$)} & {Monthly charge} & {Two year cost} \\
\midrule
Cricket Wireless & 499.99 & {\$}55 & {\$}1819.99 \\
Virgin Mobile &  649 & {\$}30 & {\$}1369 \\
\bottomrule
\end{tabular}

\end{document}

在此輸入影像描述

相關內容