4

How can I right align the following two columns, just specifying that there will be at most 5 integer digits and never any decimals? I can't seem to get the right combination of options. I can align it properly, but I lose all the commas for some reason.

\documentclass{article}

\usepackage{siunitx}

\begin{document}
\begin{tabular}{r
S[table-format = 5.0,group-digits=true,group-separator={,},table-number-alignment = right,input-ignore={,},input-decimal-markers={.},group-digits=true,group-separator={\,}]
S[table-format = 5.0,group-separator={,},table-number-alignment = right,input-ignore={,},input-decimal-markers={.},group-digits=true,group-separator={\,}]
}
siunitx: &\num{19000}                &\num{19,000} \\
siunitx: &\num{7,000}                &\num{7,000} \\
siunitx: &\num{900}                &\num{900} \\
siunitx: &\num{90}                &\num{90} \\
\end{tabular}
\end{document}
7

You are using \num inside an S column: that's not how it works. The column contents are parsed 'directly':

\documentclass{article}

\usepackage{siunitx}
\sisetup{
  input-decimal-markers = .,input-ignore = {,},table-number-alignment = right,
  group-separator={,}, group-four-digits = true
}

\begin{document}
\begin{tabular}{
  rS[table-format = 5.0]S[table-format = 5.0]
}
siunitx: &19000                &19,000 \\
siunitx: &7,000                &7,000 \\
siunitx: &900                  &900 \\
siunitx: &90                   &90 \\
\end{tabular}
\end{document}
  • The alignment is fine, but the commas are still missing. I need them in the output. How can I put them back after using input-ignore={,}? If I add a group-separator = {,} it doesn't put a comma after the 7 in 7000, only after the 19 in 19000! – user2146441 May 19 '14 at 15:46
  • 2
    @user2146441 They have nothing to do with those in the input: I've added the appropriate options – Joseph Wright May 19 '14 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.