siunitx S テーブル列のドル値を中央揃えにする

siunitx S テーブル列のドル値を中央揃えにする

\$この表で値を適切に中央揃えにするにはどうすればよいでしょうか?

ここに画像の説明を入力してください

これは簡単なはずですが、このサイトとsiunitxドキュメントでイライラしながら検索しても役に立ちませんでした。もちろん、最初の列のように、単位をヘッダー行に配置することもできますが、興味があります。

MWE:

\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}

ここに画像の説明を入力してください

関連情報