Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
2  
You need to tell siunitx the table-format (at least with parse-numbers = true, the standard setting). –  Joseph Wright Dec 2 '12 at 16:52
    
@cmhughes Dang. :) Queuing here apparently. –  percusse Dec 2 '12 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 Dec 2 '12 at 18:36
add comment

1 Answer 1

up vote 4 down vote accepted

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}
share|improve this answer
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]. –  Qrrbrbirlbel Dec 2 '12 at 17:23
    
Works like a charm together with @Qrrbrbirlbel information! –  bioslime Dec 2 '12 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 Dec 2 '12 at 17:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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