I tried my first steps with siunitx, but I have trouble achieving the following in the minimal example below:
1) aligning the entries in the first column with respect to the decimal dot
2) getting a bold entry in the second column
3) getting the entries in the second column aligned according to the decimal dot.
The code is currently not running due to the \rowcolor command. I adapted this from the manual siunitx.pdf, why is it not working?
\documentclass{article}
\usepackage{siunitx, tabularx, etoolbox, xcolor}
\begin{document}
\begin{table}
\robustify\bfseries% see 7.15 in siunitx.pdf
\centering
\begin{tabular}{lS[table-format=2.3]S[table-format=1.4]}
\multicolumn{1}{c}{$a\ (b)$}&\multicolumn{1}{c}{col 1}&\multicolumn{1}{c}{col 2}\\\hline
0.05\ (0.1)&\SI{20.64}{s}&\rowcolor[gray]\bfseries\SI{3.0601}{s}\\
0.1\ \phantom{5}(0.2)&\SI{16.82}{s}&\SI{1.59}{s}\\
0.3\ \phantom{5}(0.4)&\SI{22.48}{s$^\ast$}&\SI{0.64}{s}\\
0.4\ \phantom{5}(0.5)&\multicolumn{1}{c}{$-$}&\SI{0.52}{s}\\
\end{tabular}
\end{table}
\end{document}
Update After Joseph's first suggestion, I changed the table like this:
\documentclass{article}
\usepackage{siunitx, tabularx, etoolbox, xcolor, booktabs}
\begin{document}
\begin{table}
\robustify\bfseries
\centering
\begin{tabular}{ScS[table-format=2.2]lS[table-format=1.4, detect-weight]}
\toprule
$a$ & $(b)$ & \multicolumn{2}{c}{col 1, unit} & {col 2/\si{\s}}\\
\midrule
0.05 & (0.123) & 20.64 & s & \bfseries 3.0601\\
0.1 & 0.2 & 16.82 & s2 & 1.59\\
0.3 & 0.4 & 22.48 & s$^\ast$ & 0.64\\
0.4 & 0.5 & {--} & kg & 0.52\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
My remaining questions are:
1) How can I align the entries of the second column when one of the entries has surrounding parenthesis? [(0.123)]
2) Putting the unit in a different column creates a too large spaces between the units and the numbers (especially if some numbers have more digits such as 2.3 kg vs 1.232525 kg). Is there a solution which aligns the entries of the col 1 according to the decimal point but allows entries to be specified by \SI{}{} to get proper spacing between numbers and units?
3) \rowcolor still does not work, I obtain an Undefined control sequence error. Do I need additional packages?
\rowcolorpart is really entirely independent ofsiunitx, so you may want to ask that separately. – Joseph Wright Jun 16 '12 at 12:23colortbl(as mentioned in the manual). – Marius Hofert Jun 16 '12 at 12:51