I am trying to align numbers on decimal in tabular. I have found some information here:align to decimal point in the table. However, when I adopt that code into my table, it gives an error:
! Package array Error: Illegal pream-token (S[table-format=-1.3, table-space-text-post=***]@{}): `c' used.
I do not understand why it creates the error above, can anybody help me?
Here is my latex code:
\begin{table*}[htb]
\centering
\begin{tabular}{
@{}|l|ccc|ccc|{S[table-format=-1.3,table-space-text-post=***]@{}}}
\toprule
\multirow{2}{*}{} & \multicolumn{3}{c|}{\textbf{2005}} & \multicolumn{3}{c|}{\textbf{2006}} \\ \cmidrule(l){2-7}
& Q1 & Q2 & Q3 & Q1 & Q2 & Q3 \\ \midrule
Price & 0.99 & 5.45 & -0.13 & 0.11* & 0.77 & 5.11 \\
Profit &-0.01*** & -2.09 & 0.01 & -0.22** & 9.33 & -3.01 \\
\bottomrule
\end{tabular}
\end{table*}
Best Answer
I looks like the fact that you've wrapped
S[..]
in braces throws the parser off. At least, removing the{}
removes the error.Note that vertical rules and
booktabs
don't go well together, so below I've removed the rules. I also used anS
column for all the six last columns, that have numbers, and some other small changes.