
\$
この表で値を適切に中央揃えにするにはどうすればよいでしょうか?
これは簡単なはずですが、このサイトと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}