
Wie zentriere ich \$
die Werte in dieser Tabelle richtig?
Das sollte eigentlich ganz einfach sein, aber eine frustrierende Suche auf dieser Site und in der siunitx
Dokumentation hat mir nicht geholfen. Natürlich kann ich die Einheiten immer in die Kopfzeile setzen, wie in die erste Spalte, aber ich bin neugierig.
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}
Antwort1
Am besten fügen Sie allen Überschriften ein ($) hinzu: Die Wiederholung von $ in mehreren Zellen ist langweilig und öde.
\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}
Nicht empfohlener Weg:
\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}