6

I have a table that uses the S column type provided by siunitx. Unfortunately, if a number does not have a . it is not aligned properly. Yes, i could write number. but then the table will list the entry as number.0 instead of just number.

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}

\begin{table} \centering
{\small
\begin{tabular}{SS}
\toprule
{x}   &{x}   \\
\midrule
123 & 23.0e-5  \\
123.0 & 23\\
0.23 & 1.423  \\
0.23 & 1  \\
\bottomrule
\end{tabular}}
\end{table}

\end{document}

Table with S column type

3
  • 2
    You need to tell siunitx the table-format (at least with parse-numbers = true, the standard setting).
    – Joseph Wright
    Commented Dec 2, 2012 at 16:52
  • @cmhughes Dang. :) Queuing here apparently.
    – percusse
    Commented Dec 2, 2012 at 16:57
  • I think for a table like this it is a good idea to have the sample decimals for each number, so 23.000, 1.000, 0.230 etc.
    – Jörg
    Commented Dec 2, 2012 at 18:36

1 Answer 1

8

Here's a solution that specifies the table-format for each column; note that I also grouped {23e-5}

screenshot

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}

\begin{table} \centering
{\small
\begin{tabular}{S[table-format=3.2]S[table-format=2.3]}
\toprule
{x}   &{x}   \\
\midrule
123 & {23.0e-5}  \\
123.0 & 23\\
0.23 & 1.423  \\
0.23 & 1  \\
\bottomrule
\end{tabular}}
\end{table}

\end{document}
3
  • 2
    table-format works with exponents, too. For example S[table-format=2.1e-1] (close \times, overfull hbox for 1.423) or S[table-format=2.3e-1]. Commented Dec 2, 2012 at 17:23
  • Works like a charm together with @Qrrbrbirlbel information!
    – bioslime
    Commented Dec 2, 2012 at 17:34
  • 1
    To explain why this is the case: the standard siunitx alignment strategy is different from that in dcolumn and is based around the idea that numbers will contain a decimal part.
    – Joseph Wright
    Commented Dec 2, 2012 at 17:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .