
如何使\$
值在此表中正確居中?
這應該很簡單,但是在該網站和文件中進行的令人沮喪的搜尋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}